    ; ---------------------------------------------------------------------------

    ExplosionStruct struc ; (sizeof=0x54, standard type)
    Debris dd ?                             ; offset (FFFFFFFF)
    Frame dw ?
    data2 db 6 dup(?)
    FXGaf dd ?                              ; offset (FFFFFFFF)
    data3 db 12 dup(?)
    XPos dd ?
    ZPos dd ?
    YPos dd ?
    data4 db 36 dup(?)
    XTurn dw ?
    ZTurn dw ?
    YTurn dw ?
    data5 db 2 dup(?)
    ExplosionStruct ends

    ; ---------------------------------------------------------------------------

    ProjectileStruct struc ; (sizeof=0x6b, standard type)
    Weapon dd ?                             ; offset (FFFFFFFF)
    XPos dd ?
    ZPos dd ?
    YPos dd ?
    XPosStart dd ?
    ZPosStart dd ?
    YPosStart dd ?
    XSpeed dd ?
    ZSpeed dd ?
    YSpeed dd ?
    data1 db 14 dup(?)
    XTurn dw ?
    ZTurn dw ?
    YTurn dw ?
    data2 db 45 dup(?)
    WeaponFlags db ?
    data3 db ?
    ProjectileStruct ends

    ; ---------------------------------------------------------------------------

    WeaponStruct struc ; (sizeof=0x115, standard type)
    WeaponName db 32 dup(?)
    WeaponDescription db 64 dup(?)
    Unkn1 dd ?
    pWeaponUnkStruct dd ?                   ; offset (FFFFFFFF)
    data3 db 16 dup(?)
    LandExplodeAsGFX dd ?                   ; offset (FFFFFFFF)
    WaterExplodeAsGFX dd ?                  ; offset (FFFFFFFF)
    data4 db 84 dup(?)
    DefaultDamage dw ?
    AOE dw ?
    EdgeEffectivnes dd ?
    Range dw ?
    data5 db 21 dup(?)
    ShakeMagnitude dd ?
    data6 db 15 dup(?)
    nTolerance dw ?
    data8 db 2 dup(?)
    ID db ?
    cFireStarter db ?
    RenderType db ?
    data7 db 8 dup(?)
    WeaponStruct ends

    ; ---------------------------------------------------------------------------

    PlayerResourcesStruct struc ; (sizeof=0x20, standard type)
    fCurrentEnergy dd ?
    fEnergyProducton dd ?
    fEnergyExpense dd ?
    fCurrentMetal dd ?
    fMetalProduction dd ?
    fMetalExpense dd ?
    fMaxEnergyStorage dd ?
    fMaxMetalStorage dd ?
    PlayerResourcesStruct ends

    ; ---------------------------------------------------------------------------

    UnitDefStruct struc ; (sizeof=0x246, standard type)
    Name db 32 dup(?)
    UnitName db 32 dup(?)
    UnitDescription db 64 dup(?)
    ObjectName db 32 dup(?)
    Side db 3 dup(?)
    data5 db 167 dup(?)
    FootX dw ?
    FootY dw ?
    YardMap dd ?                            ; offset (FFFFFFFF)
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    XWidth dd ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    YWidth dd ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    ZWidth dd ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    lRawSpeed dd ?
    data9 db 42 dup(?)
    ExplodeAs dd ?                          ; offset (FFFFFFFF)
    SelfeDestructAs dd ?                    ; offset (FFFFFFFF)
    data7 db 50 dup(?)
    nMaxHP dw ?
    data8 db 2 dup(?)
    nWorkerTime dw ?
    nHealTime dw ?
    nSightDistance dw ?
    nRadarDistance dw ?
    nSonarDistance dw ?
    data1 db 8 dup(?)
    nBuildDistance dw ?
    data3 db 2 dup(?)
    nManeuverLeashLength dw ?
    data2 db 5 dup(?)
    nCruiseAlt dw ?
    data4 db 41 dup(?)
    UnitDefStruct ends

    ; ---------------------------------------------------------------------------

    UnitStruct struc ; (sizeof=0x119, standard type)
    pIsUnit dd ?                            ; offset (FFFFFFFF)
    data1 db 12 dup(?)
    Weapon1 dd ?                            ; offset (FFFFFFFF)
    data2 db 11 dup(?)
    Builder db ?
    data3 db 12 dup(?)
    Weapon2 dd ?                            ; offset (FFFFFFFF)
    data4 db 24 dup(?)
    Weapon3 dd ?                            ; offset (FFFFFFFF)
    data5 db 16 dup(?)
    UnitOrders dd ?                         ; offset (FFFFFFFF)
    UnitState db ?
    data6 db 3 dup(?)
    ZTurn dw ?
    XTurn dw ?
    YTurn dw ?
    XPos dd ?
    ZPos dd ?
    YPos dd ?
    XGridPos dw ?
    YGridPos dw ?
    XLargeGridPos dw ?
    YLargeGridPos dw ?
    data8 db 4 dup(?)
    UnkPTR1 dd ?                            ; offset (FFFFFFFF)
    data15 db 8 dup(?)
    FirstUnit dd ?                          ; struct UnitStruct offset
    UnitType dd ?                           ; struct UnitDefStruct offset
    Owner dd ?                              ; struct PlayerStruct offset
    UnitScriptingData dd ?                  ; struct UnitScriptingData offset
    Object3do dd ?                          ; offset (FFFFFFFF)
    data9 db 22 dup(?)
    Kills dw ?
    data17 db 50 dup(?)
    Owner2 dd ?                             ; struct PlayerStruct offset
    pAttacker dd ?                          ; struct UnitStruct offset
    data16 db 2 dup(?)
    HealthPerA db ?
    HealthPerB db ?
    data19 db 2 dup(?)
    RecentDamage db ?
    Height db ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    OwnerIndex db ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    Nanoframe dd ?
    Health dw ?
    data14 db 4 dup(?)
    cIsCloaked db ?
    data18 db ?
    UnitSelected db ?                       ; the next 4 bytes are partof the status bitflags
    cStatus db ?
    field_112 db ?
    field_113 db ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    field_118 db ?
    UnitStruct ends

    ; ---------------------------------------------------------------------------

    PlayerStruct struc ; (sizeof=0x14b, standard type)
    PlayerActive dd ?
    field_4 dd ?                            ; player localness? ()
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    PlayerNum db ?                          ; wtf is this?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    field_10 dd ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    field_22 db ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    PlayerInfo dd ?                         ; struct PlayerInfoStruct offset
    Name db 30 dup(?)
    SecondName db 30 dup(?)
    Units dd ?                              ; struct UnitStruct offset
    Units_End dd ?                          ; struct UnitStruct offset
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    PlayerType db ?                         ; enum PlayerType
    field_74 dd ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    field_7C dd ?                           ; LOS related field?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    field_88 dd ?                           ; LOS related field?
    Resources PlayerResourcesStruct ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    SharedMetalLimit dd ?
    SharedEnergyLimit dd ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    field_108 db 10 dup(?)                  ; Player index is used in this to determine some visibility stats
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    field_140 dd ?
    NumUnits dw ?
    PlayerNumber db ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    field_14A db ?
    PlayerStruct ends

    ; ---------------------------------------------------------------------------

    PlayerInfoStruct struc ; (sizeof=0x9c, standard type)
    MapName db 32 dup(?)
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    PlayerColor db ?
    SharedBits db ?                         ; enum SharedStates
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    field_9B db ?
    PlayerInfoStruct ends

    ; ---------------------------------------------------------------------------

    PlayerData struc ; (sizeof=0x9c)
    field_0 PlayerInfoStruct ?
    PlayerData ends

    ; [00000024 BYTES. COLLAPSED STRUCT tm. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    ScriptSlot struc ; (sizeof=0x64)
    Flags dd ?                              ; enum COB_RunningFlags
    InstrIndex dd ?
    StackIndex dd ?
    LoopsToWait dd ?                        ; wait time in process loops?
    field_10 dd ?
    field_14 dd ?                           ; pointer to an array/struct
    ScriptToWaitOn dd ?
    field_1C dd ?                           ; Known values: 1
    MethodReturnedCallBack dd ?             ; Known Values: 0
    Stack dd ?                              ; offset (00000000)
    field_28 dd ?
    field_2C dd ?
    field_30 dd ?
    field_34 dd ?
    field_38 dd ?
    field_3C dd ?
    field_40 dd 8 dup(?)                    ; slots in use for *something*
    field_60 dd ?
    ScriptSlot ends

    ; ---------------------------------------------------------------------------

    CobHeader struc ; (sizeof=0x2c)
    Version dd ?
    MethodCount dd ?
    PieceCount dd ?
    BytecodeLength dd ?
    StaticVariablesCount dd ?
    Always_0 dd ?
    MethodEntryPoints dd ?                  ; pointer to the array of entrypoints
    MethodNameOffsets dd ?                  ; pointer to the array of method name offsets
    PieceNameOffsets dd ?                   ; pointer to the array of piece name offsets
    ByteCodeStart dd ?                      ; Pointer to the start of the bytecode
    NameArray dd ?                          ; pointer to the array which contains the text for pieces & names
    CobHeader ends

    ; ---------------------------------------------------------------------------

    ScriptSlotArray struc ; (sizeof=0x320)
    ScriptSlots ScriptSlot 8 dup(?)
    ScriptSlotArray ends

    ; ---------------------------------------------------------------------------

    UnitScriptingData struc ; (sizeof=0x540)
    field_0 db 8 dup(?)
    pCOB dd ?                               ; pointer to COB file data (Directly points to the method count)
    field_C dd ?
    GlobalVars dd ?                         ; offset (00000000)
    field_14 dd ?
    field_18 dd ?                           ; pointer?
    ScriptSlots ScriptSlotArray ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    StartRunningNow dd ?                    ; Indicator of the number of scripts waiting to run?
    UnitScriptingData ends

    ; ---------------------------------------------------------------------------

    COB_StackFrame struc ; (sizeof=0x64)
    field_0 ScriptSlot ?
    COB_StackFrame ends

    ; ---------------------------------------------------------------------------

    HAPINET struc ; (sizeof=0x4c9)
    Buffer db 1200 dup(?)
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    DataSize dd ?
    BufferPtr dd ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    DirectPlayInterface dd ?
    HAPINET ends

    ; ---------------------------------------------------------------------------

    StaticVarStuct_1 struc ; (sizeof=0x23c)
    FunctionPtr dd ?                        ; offset (00000000)
    field_4 db 16 dup(?)
    field_14 dd ?
    field_18 db 48 dup(?)
    field_48 dd ?
    field_4C db 480 dup(?)
    field_22C dd ?
    field_230 dd ?
    field_234 dd ?
    field_238 dd ?
    StaticVarStuct_1 ends

    ; ---------------------------------------------------------------------------

    RadarPicStruc struc ; (sizeof=0x10, standard type)
    XSize dd ?
    YSize dd ?
    Unk1 dd ?
    PixelPTR dd ?                           ; offset (FFFFFFFF)
    RadarPicStruc ends

    ; ---------------------------------------------------------------------------

    TAdynmemStruct struc ; (sizeof=0x39239, standard type)
    field_0 db 16 dup(?)
    DSound dd ?                             ; offset (FFFFFFFF)
    HAPINET_Object dd ?                     ; struct HAPINET offset
    field_18 db 1201 dup(?)
    field_4C9 dd ?                          ; player ID for something?
    field_4CD dd ?                          ; player ID for something?
    field_4D1 db 72 dup(?)
    field_519 dd ?                          ; offset (00000000)
    field_51D db 108 dup(?)
    AlteredUnitLimit db ?
    field_58A db 5278 dup(?)
    field_1A28 dd ?
    field_1A2C db 311 dup(?)
    Players PlayerStruct 10 dup(?)
    field_2851 db 331 dup(?)
    field_299C dd ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    PacketBufferSize dd ?
    PacketBuffer dd ?                       ; offset (00000000)
    LOS_Radar dw ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    SharedBits db ?                         ; Definitly something todo with radar (player index?)
    LOS_Sight db ?                          ; The player to use for LOS calcs
    NetworkLayerEnabled db ?
    field_2A45 db 585 dup(?)
    BuildPosX dw ?
    BuildPosY dw ?
    BuildPosRealX dd ?
    Height dd ?
    BuildPosRealY dd ?
    unk1 dd ?
    Height2 dd ?
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    db ? ; undefined
    MouseMapPosX dw ?
    db ? ; undefined
    db ? ; undefined
    field_2CB0 dw ?
    db ? ; undefined
    db ? ; undefined
    MouseMapPosY dw ?
    field_2CB6 db 4 dup(?)
    MouseOverUnit dw ?
    field_2CBC db 8 dup(?)
    BuildNum dw ?
    BuildSpotState db ?
    data18 db 44 dup(?)
    Weapons WeaponStruct 256 dup(?)
    NumProjectiles dd ?
    Projectiles dd ?                        ; offset (FFFFFFFF)
    field_141FB db 16 dup(?)
    WreckageInfo dd ?                       ; offset (FFFFFFFF)
    data14 db 36 dup(?)
    FeatureMapSizeX dd ?
    FeatureMapSizeY dd ?
    data7 db 24 dup(?)
    NumFeatureDefs dd ?
    data15 db 24 dup(?)
    FeatureDef dd ?                         ; offset (FFFFFFFF)
    field_14273 dd ?
    field_14277 dd ?
    EyeBallMemory dd ?                      ; offset (FFFFFFFF)
    data12 db 8 dup(?)
    Features dd ?                           ; offset (FFFFFFFF)
    data3 db 64 dup(?)
    MinimapRect tagRECT ?
    RadarFinal dd ?                         ; struct RadarPicStruc offset
    RadarMapped dd ?                        ; struct RadarPicStruc offset
    RadarPicture dd ?                       ; struct RadarPicStruc offset
    data20 db 4 dup(?)
    RadarPicSizeX dw ?
    RadarPicSizeY dw ?
    data25 db 4 dup(?)
    CirclePointer dd ?
    data19 db 40 dup(?)
    MapX dd ?
    MapY dd ?
    MapXScrollingTo dd ?
    MapYScrollingTo dd ?
    field_1432F db 36 dup(?)
    UnitCount_Unk dd ?
    Units dd ?                              ; offset (FFFFFFFF)
    Units_EndMarker dd ?                    ; offset (FFFFFFFF)
    HotUnits dd ?                           ; offset (FFFFFFFF)
    HotRadarUnits dd ?                      ; offset (FFFFFFFF)
    NumHotUnits dd ?
    NumHotRadarUnits dd ?
    field_1436F dw ?
    field_14371 db 42 dup(?)
    UnitDef dd ?                            ; offset (FFFFFFFF)
    data11 db 1404 dup(?)
    NumExplosions dd ?
    Explosions ExplosionStruct 300 dup(?)
    Unk2 dd ?                               ; offset (FFFFFFFF)
    field_1AB93 db 119444 dup(?)
    field_37E27 dd ?
    field_37E2B db 193 dup(?)
    UnitLimit dw ?
    CurrentAIProfile dd ?
    field_37EF2 db 2901 dup(?)
    GameTime dd ?
    field_38A4B db 1950 dup(?)
    MapFile dd ?                            ; offset (FFFFFFFF)
    field_391ED db 72 dup(?)
    RenderingOptions dd ?
    TAdynmemStruct ends

    ; [0000000C BYTES. COLLAPSED STRUCT _SECURITY_ATTRIBUTES. PRESS KEYPAD "+" TO EXPAND]
    ; [00000012 BYTES. COLLAPSED STRUCT _cpinfo. PRESS KEYPAD "+" TO EXPAND]
    ; [0000013E BYTES. COLLAPSED STRUCT _WIN32_FIND_DATAA. PRESS KEYPAD "+" TO EXPAND]
    ; [00000044 BYTES. COLLAPSED STRUCT _STARTUPINFOA. PRESS KEYPAD "+" TO EXPAND]
    ; [000000AC BYTES. COLLAPSED STRUCT _TIME_ZONE_INFORMATION. PRESS KEYPAD "+" TO EXPAND]
    ; [00000094 BYTES. COLLAPSED STRUCT _OSVERSIONINFOA. PRESS KEYPAD "+" TO EXPAND]
    ; [00000010 BYTES. COLLAPSED STRUCT RECT. PRESS KEYPAD "+" TO EXPAND]
    ; [0000002C BYTES. COLLAPSED STRUCT WINDOWPLACEMENT. PRESS KEYPAD "+" TO EXPAND]
    ; [00000010 BYTES. COLLAPSED STRUCT SYSTEMTIME. PRESS KEYPAD "+" TO EXPAND]
    ; [00000010 BYTES. COLLAPSED STRUCT _SYSTEMTIME. PRESS KEYPAD "+" TO EXPAND]
    ; [00000004 BYTES. COLLAPSED STRUCT _SYSTEM_INFO::$41710344DA04EC56A327D4EA11DEF6D2::$AA04DEB0C6383F89F13D312A174572A9. PRESS KEYPAD "+" TO EXPAND]
    ; [00000004 BYTES. COLLAPSED STRUCT _SYSTEM_INFO::$41710344DA04EC56A327D4EA11DEF6D2. PRESS KEYPAD "+" TO EXPAND]
    ; [00000024 BYTES. COLLAPSED STRUCT _SYSTEM_INFO. PRESS KEYPAD "+" TO EXPAND]
    ; [00000008 BYTES. COLLAPSED STRUCT FILETIME. PRESS KEYPAD "+" TO EXPAND]
    ; [00000008 BYTES. COLLAPSED STRUCT _FILETIME. PRESS KEYPAD "+" TO EXPAND]
    ; [00000018 BYTES. COLLAPSED STRUCT _RTL_CRITICAL_SECTION. PRESS KEYPAD "+" TO EXPAND]
    ; [0000001C BYTES. COLLAPSED STRUCT _MEMORY_BASIC_INFORMATION. PRESS KEYPAD "+" TO EXPAND]
    ; [00000030 BYTES. COLLAPSED STRUCT tagAUXCAPSA. PRESS KEYPAD "+" TO EXPAND]
    ; [00000010 BYTES. COLLAPSED STRUCT tagRECT. PRESS KEYPAD "+" TO EXPAND]
    ; [00000008 BYTES. COLLAPSED STRUCT tagPOINT. PRESS KEYPAD "+" TO EXPAND]
    ; [00000004 BYTES. COLLAPSED STRUCT RGBQUAD. PRESS KEYPAD "+" TO EXPAND]
    ; [00000028 BYTES. COLLAPSED STRUCT BITMAPINFOHEADER. PRESS KEYPAD "+" TO EXPAND]
    ; [0000002C BYTES. COLLAPSED STRUCT BITMAPINFO. PRESS KEYPAD "+" TO EXPAND]
    ; [0000001C BYTES. COLLAPSED STRUCT MSG. PRESS KEYPAD "+" TO EXPAND]
    ; [00000008 BYTES. COLLAPSED STRUCT POINT. PRESS KEYPAD "+" TO EXPAND]
    ; [0000001C BYTES. COLLAPSED STRUCT tagMSG. PRESS KEYPAD "+" TO EXPAND]
    ; [00000008 BYTES. COLLAPSED STRUCT _LARGE_INTEGER::$837407842DC9087486FDFA5FEB63B74E. PRESS KEYPAD "+" TO EXPAND]
    ; [00000008 BYTES. COLLAPSED STRUCT LARGE_INTEGER. PRESS KEYPAD "+" TO EXPAND]
    ; [00000020 BYTES. COLLAPSED STRUCT _MEMORYSTATUS. PRESS KEYPAD "+" TO EXPAND]
    ; [00000008 BYTES. COLLAPSED STRUCT _msExcInfo. PRESS KEYPAD "+" TO EXPAND]
    ; [00000020 BYTES. COLLAPSED STRUCT _msExcept. PRESS KEYPAD "+" TO EXPAND]
    ; [00000014 BYTES. COLLAPSED STRUCT _msExcExt. PRESS KEYPAD "+" TO EXPAND]
    ; [00000010 BYTES. COLLAPSED STRUCT _msRttiDscr. PRESS KEYPAD "+" TO EXPAND]
    ; [0000000C BYTES. COLLAPSED STRUCT _msEH. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    ; enum COB_Opcodes
    COB_MovePieceWithSpeed  = 10001000h
    COB_TurnPieceWithSpeed  = 10002000h
    COB_StartSpin  = 10003000h
    COB_StopSpin  = 10004000h
    COB_ShowPiece  = 10005000h
    COB_HidePiece  = 10006000h
    COB_CachePiece  = 10007000h
    COB_DontCachePiece  = 10008000h
    COB_Unknown4  = 10009000h
    COB_DontShadow  = 1000A000h
    COB_MovePieceNow  = 1000B000h
    COB_TurnPieceNow  = 1000C000h
    COB_Shade  = 1000D000h
    COB_DontShade  = 1000E000h
    COB_EmitSfx  = 1000F000h
    COB_WaitForTurn  = 10011000h
    COB_WaitForMove  = 10012000h
    COB_Sleep  = 10013000h
    COB_MetaPush  = 10021000h
    COB_PushConstantOntoStack  = 10021001h
    COB_PushLocalVariableOntoStack  = 10021002h
    COB_PushStaticVariableOntoStack  = 10021004h
    COB_StackAllocate  = 10022000h
    COB_MetaPop  = 10023000h
    COB_SetLocalVariable  = 10023002h
    COB_SetStaticVariable  = 10023004h
    COB_PopStack  = 10024000h
    COB_Add  = 10031000h
    COB_Subtract  = 10032000h
    COB_Multiply  = 10033000h
    COB_Divide  = 10034000h
    COB_BitwiseAnd  = 10035000h
    COB_BitwiseOr  = 10036000h
    COB_BitwiseXor  = 10037000h
    COB_BitwiseNot  = 10038000h
    COB_Unknown1  = 10039000h
    COB_Unknown2  = 1003A000h
    COB_Unknown3  = 1003B000h
    COB_Random  = 10041000h
    COB_GetUnitValue  = 10042000h
    COB_GetFunctionResult  = 10043000h
    COB_Unknown11  = 10044000h              ; takes 1 thing off stack, puts another back on
    COB_Unknown12  = 10045000h
    COB_LessThan  = 10051000h
    COB_LessThanOrEqual  = 10052000h
    COB_GreaterThan  = 10053000h
    COB_GreaterThanOrEqual  = 10054000h
    COB_Equal  = 10055000h
    COB_NotEqual  = 10056000h
    COB_Unknown13  = 10057000h
    COB_LogicalOr  = 10058000h
    COB_LogicalXor(check)  = 10059000h
    COB_Unknown15  = 1005A000h              ; pop value off stack, test for zero, push result on stack
    COB_StartScript  = 10061000h
    COB_CallScript  = 10062000h
    COB_Unknown16  = 10063000h              ; Pops a load of stuff off the stack and stores it somewere for something
    COB_JumpToOffset  = 10064000h
    COB_Return  = 10065000h                 ; Invokes a callback which has the ret value assigned to it. Script methods *must* return a value
    COB_JumpToOffsetIfFalse  = 10066000h
    COB_Signal  = 10067000h
    COB_SetSignalMask  = 10068000h
    COB_Explode  = 10071000h
    COB_PlaySound  = 10072000h
    COB_MapCommand  = 10073000h
    COB_SetUnitValue  = 10082000h
    COB_AttachUnit  = 10083000h
    COB_DropUnit  = 10084000h
    COB_ValidOPMask  = 100FF000h

    ; ---------------------------------------------------------------------------

    ; enum COB_RunningFlags
    COB_NotInUse  = 0
    COB_RunningFlags_2  = 100000h
    COB_RunningFlags_3  = 200000h
    COB_RunningFlags_4  = 400000h
    COB_IsRunnable  = 1000000h
    COB_RunningFlags_1  = 2000000h
    COB_CallScriptWait  = 2800000h

    ; ---------------------------------------------------------------------------

    ; enum PacketID
    PacketID_Encypted  = 3
    PacketID_Compressed  = 4
    PacketID_ObjectState  = 0Ch

    ; ---------------------------------------------------------------------------

    ; enum PlayerType
    Player_none  = 0
    Player_LocalHuman  = 1
    Player_AI  = 2
    Player_RemoteHuman  = 3
    Player_RemoteAI  = 4                    ; not positive on this one

    ; ---------------------------------------------------------------------------

    ; enum SharedStates
    SharedMetal  = 2
    SharedEnergy  = 4
    SharedLOS  = 8
    SharedMappings  = 20h
    SharedRadar  = 40h

    ;
    ; +-------------------------------------------------------------------------+
    ; ¦     This file is generated by The Interactive Disassembler (IDA)        ¦
    ; ¦     Copyright (c) 2003 by DataRescue sa/nv, <ida@datarescue.com>        ¦
    ; ¦          Licensed to: Thomas Wright, DVDMods, 1 user, special           ¦
    ; +-------------------------------------------------------------------------+
    ;
    ; File Name   : D:\ida\TA\TotalA.exe
    ; Format      : Portable executable for IBM PC (PE)
    ; Section 1. (virtual address 00001000)
    ; Virtual size                  : 000FA92A (1026346.)
    ; Section size in file          : 000FAA00 (1026560.)
    ; Offset to raw data for section: 00000400
    ; Flags 60000020: Text Executable Readable
    ; Alignment     : 16 bytes ?
    ; OS type         :  MS Windows
    ; Application type:  Executable 32bit
    ;

    unicode         macro page,string,zero
    irpc c,<string>
    db '&c', page
    endm
    ifnb <zero>
    dw zero
    endif
    endm

    model flat

    ; ---------------------------------------------------------------------------

    ; Segment type: Pure code
    ; Segment permissions: Read/Execute
    _text segment para public 'CODE' use32
    assume cs:_text
    ;org 401000h
    assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_401000 proc near                    ; CODE XREF: sub_42A8D0+86p
                                            ; sub_460E20+CFp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_8]
    dec     eax
    js      short locret_401027
    push    edi
    push    esi
    mov     esi, [esp+8+arg_0]
    push    ebp
    mov     ebp, [esp+0Ch+arg_4]
    push    ebx
    mov     ebx, [esp+10h+arg_C]
    lea     edi, [eax+1]

    loc_40101A:                             ; CODE XREF: sub_401000+21j
    mov     ecx, esi
    call    ebx
    add     esi, ebp
    dec     edi
    jnz     short loc_40101A
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    locret_401027:                          ; CODE XREF: sub_401000+5j
    retn    10h
    sub_401000 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+0Ch]
    push    ebx
    mov     ebx, [esp+0Ch]
    mov     ecx, eax
    imul    ecx, ebx
    push    esi
    mov     esi, [esp+0Ch]
    add     esi, ecx
    dec     eax
    js      short loc_40105C
    push    edi
    push    ebp
    mov     ebp, [esp+20h]
    lea     edi, [eax+1]

    loc_401051:                             ; CODE XREF: .text:00401058j
    sub     esi, ebx
    mov     ecx, esi
    call    ebp
    dec     edi
    jnz     short loc_401051
    pop     ebp
    pop     edi

    loc_40105C:                             ; CODE XREF: .text:00401046j
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_401070 proc near                    ; CODE XREF: sub_464700+EAp
                                            ; sub_485A40+2CAp

    arg_0= dword ptr  8

    push    esi
    mov     edx, ecx
    push    edi
    mov     ecx, 0Dh
    xor     eax, eax
    mov     edi, edx
    rep stosd
    mov     eax, [esp+4+arg_0]
    mov     esi, TAdynmemStructPtr
    and     eax, 0FFh
    pop     edi
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2+1B63h]
    pop     esi
    mov     [edx+30h], eax
    retn    4
    sub_401070 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4010B0 proc near                    ; CODE XREF: sub_4876C0+11Ap

    var_20= dword ptr -20h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 20h
    xor     eax, eax
    lea     edx, [esp+20h+var_20]
    push    esi
    push    edi
    mov     edi, ecx
    mov     ecx, [esp+28h+arg_0]
    mov     ax, [ecx+0A8h]
    push    eax
    push    offset aU04xacc                 ; "u%04xacc"
    push    edx
    call    _sprintf
    mov     esi, [esp+34h+arg_4]
    add     esp, 0Ch
    lea     eax, [esp+28h+var_20]
    mov     ecx, esi
    push    eax
    call    sub_4B4BA0
    push    0
    mov     ecx, esi
    call    sub_4B4C10
    push    18h
    push    edi
    mov     ecx, esi
    call    sub_4B4CF0
    add     edi, 18h
    push    18h
    push    edi
    mov     ecx, esi
    call    sub_4B4CF0
    pop     edi
    pop     esi
    add     esp, 20h
    retn    8
    sub_4010B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_401110 proc near                    ; CODE XREF: sub_487080+4B0p

    var_20= dword ptr -20h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 20h
    xor     eax, eax
    lea     edx, [esp+20h+var_20]
    push    esi
    push    edi
    mov     edi, ecx
    mov     ecx, [esp+28h+arg_0]
    mov     ax, [ecx+0A8h]
    push    eax
    push    offset aU04xacc                 ; "u%04xacc"
    push    edx
    call    _sprintf
    mov     esi, [esp+34h+arg_4]
    add     esp, 0Ch
    lea     eax, [esp+28h+var_20]
    mov     ecx, esi
    push    eax
    call    sub_4B4BA0
    test    eax, eax
    jz      short loc_40116B
    push    0
    mov     ecx, esi
    call    sub_4B4C10
    push    18h
    push    edi
    mov     ecx, esi
    call    sub_4B4C80
    add     edi, 18h
    push    18h
    push    edi
    mov     ecx, esi
    call    sub_4B4C80

    loc_40116B:                             ; CODE XREF: sub_401110+39j
    pop     edi
    pop     esi
    add     esp, 20h
    retn    8
    sub_401110 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_401180 proc near                    ; CODE XREF: sub_41BD10+A7p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_0]
    fld     dword ptr [ecx+0Ch]
    fcomp   ds:flt_4FC478
    fld     [esp+arg_4]
    fadd    dword ptr [ecx+4]
    fnstsw  ax
    fstp    dword ptr [ecx+4]
    test    ah, 41h
    jnz     short loc_4011A3
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4011A3:                             ; CODE XREF: sub_401180+1Cj
    fld     [esp+arg_4]
    fadd    dword ptr [ecx+8]
    mov     eax, 1
    fstp    dword ptr [ecx+8]
    retn    8
    sub_401180 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4011C0 proc near                    ; CODE XREF: .text:00402C6Bp
                                            ; sub_41BA60+200p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    fld     dword ptr [ecx+0Ch]
    fcomp   ds:flt_4FC478
    fld     [esp+arg_4]
    fld     [esp+arg_0]
    fadd    dword ptr [ecx+4]
    fxch    st(1)
    fadd    dword ptr [ecx+1Ch]
    fxch    st(1)
    fnstsw  ax
    fstp    dword ptr [ecx+4]
    test    ah, 41h
    fstp    dword ptr [ecx+1Ch]
    jz      short ___crtDummySetSpinCount@8 ; __crtDummySetSpinCount(x,x)
    fld     dword ptr [ecx+24h]
    fcomp   ds:flt_4FC478
    fnstsw  ax
    test    ah, 41h
    jz      short ___crtDummySetSpinCount@8 ; __crtDummySetSpinCount(x,x)
    fld     [esp+arg_4]
    fld     [esp+arg_0]
    fadd    dword ptr [ecx+8]
    fxch    st(1)
    fadd    dword ptr [ecx+20h]
    fxch    st(1)
    mov     eax, 1
    fstp    dword ptr [ecx+8]
    fstp    dword ptr [ecx+20h]
    retn    8
    sub_4011C0 endp

    ; [00000005 BYTES: COLLAPSED FUNCTION __crtDummySetSpinCount(x,x). PRESS KEYPAD "+" TO EXPAND]
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_401220 proc near                    ; CODE XREF: sub_464B30+94p

    arg_0= dword ptr  4

    mov     edx, [ecx+30h]
    fld     dword ptr [edx+8Ch]
    fcomp   [esp+arg_0]
    fnstsw  ax
    test    ah, 1
    jnz     short loc_401258
    fld     dword ptr [edx+8Ch]
    fsub    [esp+arg_0]
    fld     [esp+arg_0]
    fxch    st(1)
    mov     eax, 1
    fstp    dword ptr [edx+8Ch]
    fadd    dword ptr [ecx+4]
    fstp    dword ptr [ecx+4]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_401258:                             ; CODE XREF: sub_401220+12j
    xor     eax, eax
    retn    4
    sub_401220 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_401260 proc near                    ; CODE XREF: sub_464C60+94p

    arg_0= dword ptr  4

    mov     edx, [ecx+30h]
    fld     dword ptr [edx+98h]
    fcomp   [esp+arg_0]
    fnstsw  ax
    test    ah, 1
    jnz     short loc_401298
    fld     dword ptr [edx+98h]
    fsub    [esp+arg_0]
    fld     [esp+arg_0]
    fxch    st(1)
    mov     eax, 1
    fstp    dword ptr [edx+98h]
    fadd    dword ptr [ecx+1Ch]
    fstp    dword ptr [ecx+1Ch]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_401298:                             ; CODE XREF: sub_401260+12j
    xor     eax, eax
    retn    4
    sub_401260 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4012A0 proc near                    ; CODE XREF: sub_49E1A0+393p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [ecx+30h]
    fld     dword ptr [edx+8Ch]
    fcomp   [esp+arg_0]
    fnstsw  ax
    test    ah, 1
    jnz     short loc_401319
    fld     dword ptr [edx+98h]
    fcomp   [esp+arg_4]
    fnstsw  ax
    test    ah, 1
    jnz     short loc_401319
    fld     dword ptr [edx+8Ch]
    fsub    [esp+arg_0]
    fld     [esp+arg_0]
    fxch    st(1)
    fstp    dword ptr [edx+8Ch]
    mov     edx, [ecx+30h]
    fadd    dword ptr [ecx+4]
    fstp    dword ptr [ecx+4]
    fld     dword ptr [edx+98h]
    fcomp   [esp+arg_4]
    fnstsw  ax
    test    ah, 1
    jnz     short loc_401311
    fld     dword ptr [edx+98h]
    fsub    [esp+arg_4]
    fld     [esp+arg_4]
    fxch    st(1)
    fstp    dword ptr [edx+98h]
    fadd    dword ptr [ecx+1Ch]
    fstp    dword ptr [ecx+1Ch]

    loc_401311:                             ; CODE XREF: sub_4012A0+53j
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_401319:                             ; CODE XREF: sub_4012A0+12j
                                            ; sub_4012A0+23j
    xor     eax, eax
    retn    8
    sub_4012A0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    fld     dword ptr [esp+8]
    fmul    dword ptr [eax+0Ch]
    mov     ecx, [eax+4]
    mov     edx, [eax]
    mov     [eax+14h], ecx
    xor     ecx, ecx
    fsubr   dword ptr [eax+0Ch]
    fld     dword ptr [esp+0Ch]
    fmul    dword ptr [eax+8]
    mov     [eax+10h], edx
    mov     [eax+4], ecx
    mov     [eax], ecx
    fsubr   dword ptr [eax+8]
    mov     [eax+8], ecx
    faddp   st(1), st
    fstp    dword ptr [eax+0Ch]
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_401360(int)
    sub_401360 proc near                    ; CODE XREF: UpdateDatePlayers+5DAp

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 28h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+38h+arg_0]
    xor     ebx, ebx
    mov     [esp+38h+var_10], ebx
    mov     [esp+38h+var_C], ebx
    mov     esi, [edi+67h]
    mov     eax, [edi+6Bh]
    cmp     esi, eax
    mov     [edi+0A8h], ebx
    mov     [edi+0A4h], ebx
    mov     [esp+38h+var_28], ebx
    mov     [esp+38h+var_24], ebx
    mov     [esp+38h+var_18], ebx
    mov     [esp+38h+var_14], ebx
    mov     [esp+38h+var_20], ebx
    mov     [esp+38h+var_1C], ebx
    mov     ebp, 10000000h
    ja      loc_40190E

    loc_4013AC:                             ; CODE XREF: sub_401360+5A8j
    mov     eax, [esi+110h]
    test    ebp, eax
    jz      loc_4018FD
    test    eax, 20000000h
    jz      loc_401617
    test    byte ptr [esi+10Eh], 1
    jz      loc_4016C5
    mov     eax, [esi+92h]
    fld     dword ptr [eax+1C6h]
    fcom    ds:flt_4FC478
    fnstsw  ax
    test    ah, 1
    jnz     short loc_401429
    fld     st
    fadd    dword ptr [esi+0C0h]
    fstp    dword ptr [esi+0C0h]
    fld     dword ptr [esi+0C8h]
    fcomp   ds:flt_4FC478
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_401414
    xor     eax, eax
    fstp    st
    mov     edx, eax
    jmp     short loc_401480
    ; ---------------------------------------------------------------------------

    loc_401414:                             ; CODE XREF: sub_401360+AAj
    fadd    dword ptr [esi+0C4h]
    mov     eax, 1
    mov     edx, eax
    fstp    dword ptr [esi+0C4h]
    jmp     short loc_401480
    ; ---------------------------------------------------------------------------

    loc_401429:                             ; CODE XREF: sub_401360+89j
    mov     eax, [esi+0ECh]
    fchs
    cmp     [eax], ebx
    jz      short loc_401472
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_401472
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+TAdynmemStruct.CurrentAIProfile]
    sub     eax, ebx
    jz      short loc_401460
    dec     eax
    jnz     short loc_401472
    fmul    ds:dbl_4FC480
    fld     dword ptr [esi+0BCh]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_401478
    ; ---------------------------------------------------------------------------

    loc_401460:                             ; CODE XREF: sub_401360+E9j
    fmul    ds:dbl_4FC488
    fld     dword ptr [esi+0BCh]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_401478
    ; ---------------------------------------------------------------------------

    loc_401472:                             ; CODE XREF: sub_401360+D3j
                                            ; sub_401360+D9j ...
    fadd    dword ptr [esi+0BCh]

    loc_401478:                             ; CODE XREF: sub_401360+FEj
                                            ; sub_401360+110j
    fstp    dword ptr [esi+0BCh]
    xor     edx, edx

    loc_401480:                             ; CODE XREF: sub_401360+B2j
                                            ; sub_401360+C7j
    mov     ecx, [esi+92h]
    fld     dword ptr [ecx+1CEh]
    fcomp   ds:flt_4FC478
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4014CA
    cmp     edx, ebx
    jz      loc_4016C5
    mov     eax, [esi+0ECh]
    fld     dword ptr [esi+58h]
    cmp     [eax], ebx
    jz      loc_40153F
    cmp     byte ptr [eax+73h], 2
    jnz     loc_40153F
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+TAdynmemStruct.CurrentAIProfile]
    jmp     short loc_401504
    ; ---------------------------------------------------------------------------

    loc_4014CA:                             ; CODE XREF: sub_401360+137j
    mov     al, [ecx+22Dh]
    cmp     al, bl
    jz      short loc_401550
    cmp     edx, ebx
    jz      loc_4016C5
    and     eax, 0FFh
    mov     [esp+38h+arg_0], eax
    mov     eax, [esi+0ECh]
    fild    [esp+38h+arg_0]
    cmp     [eax], ebx
    jz      short loc_40153F
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_40153F
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+TAdynmemStruct.CurrentAIProfile]

    loc_401504:                             ; CODE XREF: sub_401360+168j
    sub     eax, ebx
    jz      short loc_401524
    dec     eax
    jz      short loc_40151C
    fadd    dword ptr [esi+0D4h]
    fstp    dword ptr [esi+0D4h]
    jmp     loc_4016C5
    ; ---------------------------------------------------------------------------

    loc_40151C:                             ; CODE XREF: sub_401360+1A9j
    fmul    ds:dbl_4FC480
    jmp     short loc_40152A
    ; ---------------------------------------------------------------------------

    loc_401524:                             ; CODE XREF: sub_401360+1A6j
    fmul    ds:dbl_4FC488

    loc_40152A:                             ; CODE XREF: sub_401360+1C2j
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    fstp    dword ptr [esi+0D4h]
    jmp     loc_4016C5
    ; ---------------------------------------------------------------------------

    loc_40153F:                             ; CODE XREF: sub_401360+14Cj
                                            ; sub_401360+156j ...
    fadd    dword ptr [esi+0D4h]
    fstp    dword ptr [esi+0D4h]
    jmp     loc_4016C5
    ; ---------------------------------------------------------------------------

    loc_401550:                             ; CODE XREF: sub_401360+172j
    fld     dword ptr [ecx+1D2h]
    fcomp   ds:flt_4FC478
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4015BC
    mov     edx, TAdynmemStructPtr
    mov     eax, [esi+0ECh]
    fld     dword ptr [edx+37EDEh]
    fmul    dword ptr [ecx+1D2h]
    cmp     [eax], ebx
    jz      short loc_4015AB
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_4015AB
    mov     eax, [edx+TAdynmemStruct.CurrentAIProfile]
    sub     eax, ebx
    jz      loc_40169D
    dec     eax
    jz      loc_401695
    fadd    dword ptr [esi+0BCh]
    fstp    dword ptr [esi+0BCh]
    jmp     loc_4016C5
    ; ---------------------------------------------------------------------------

    loc_4015AB:                             ; CODE XREF: sub_401360+21Dj
                                            ; sub_401360+223j
    fadd    dword ptr [esi+0BCh]
    fstp    dword ptr [esi+0BCh]
    jmp     loc_4016C5
    ; ---------------------------------------------------------------------------

    loc_4015BC:                             ; CODE XREF: sub_401360+201j
    fld     dword ptr [ecx+1D6h]
    fcomp   ds:flt_4FC478
    fnstsw  ax
    test    ah, 41h
    jnz     loc_4016C5
    mov     edx, TAdynmemStructPtr
    mov     eax, [esi+0ECh]
    fld     dword ptr [edx+14267h]
    fmul    dword ptr [ecx+1D6h]
    cmp     [eax], ebx
    jz      loc_4016B5
    cmp     byte ptr [eax+73h], 2
    jnz     loc_4016B5
    mov     eax, [edx+37EEEh]
    sub     eax, ebx
    jz      loc_40169D
    dec     eax
    jz      loc_401695
    jmp     loc_4016B5
    ; ---------------------------------------------------------------------------

    loc_401617:                             ; CODE XREF: sub_401360+5Fj
    test    byte ptr [esi+10Eh], 1
    jnz     short loc_401628
    test    al, 0Ch
    jbe     loc_4016C5

    loc_401628:                             ; CODE XREF: sub_401360+2BEj
    mov     ecx, [esi+92h]
    fld     dword ptr [ecx+1C6h]
    fcom    ds:flt_4FC478
    fnstsw  ax
    test    ah, 1
    jnz     short loc_401670
    fld     st
    fadd    dword ptr [esi+0C0h]
    fstp    dword ptr [esi+0C0h]
    fld     dword ptr [esi+0C8h]
    fcomp   ds:flt_4FC478
    fnstsw  ax
    test    ah, 41h
    jz      short loc_4016C3
    fadd    dword ptr [esi+0C4h]
    fstp    dword ptr [esi+0C4h]
    jmp     short loc_4016C5
    ; ---------------------------------------------------------------------------

    loc_401670:                             ; CODE XREF: sub_401360+2DFj
    mov     eax, [esi+0ECh]
    fchs
    cmp     [eax], ebx
    jz      short loc_4016B5
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_4016B5
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+TAdynmemStruct.CurrentAIProfile]
    sub     eax, ebx
    jz      short loc_40169D
    dec     eax
    jnz     short loc_4016B5

    loc_401695:                             ; CODE XREF: sub_401360+234j
                                            ; sub_401360+2ACj
    fmul    ds:dbl_4FC480
    jmp     short loc_4016A3
    ; ---------------------------------------------------------------------------

    loc_40169D:                             ; CODE XREF: sub_401360+22Dj
                                            ; sub_401360+2A5j ...
    fmul    ds:dbl_4FC488

    loc_4016A3:                             ; CODE XREF: sub_401360+33Bj
    fld     dword ptr [esi+0BCh]
    fxch    st(1)
    fsubp   st(1), st
    fstp    dword ptr [esi+0BCh]
    jmp     short loc_4016C5
    ; ---------------------------------------------------------------------------

    loc_4016B5:                             ; CODE XREF: sub_401360+28Dj
                                            ; sub_401360+297j ...
    fld     dword ptr [esi+0BCh]
    fadd    st, st(1)
    fstp    dword ptr [esi+0BCh]

    loc_4016C3:                             ; CODE XREF: sub_401360+300j
    fstp    st

    loc_4016C5:                             ; CODE XREF: sub_401360+6Cj
                                            ; sub_401360+13Bj ...
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FC478
    fnstsw  ax
    test    ah, 40h
    jz      loc_4017CB
    mov     eax, [esi+92h]
    fld     dword ptr [eax+1C2h]
    mov     eax, [esi+0ECh]
    cmp     [eax], ebx
    jz      short loc_40172B
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_40172B
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+TAdynmemStruct.CurrentAIProfile]
    sub     eax, ebx
    jz      short loc_401713
    dec     eax
    jnz     short loc_40172B
    fmul    ds:dbl_4FC480
    jmp     short loc_401719
    ; ---------------------------------------------------------------------------

    loc_401713:                             ; CODE XREF: sub_401360+3A6j
    fmul    ds:dbl_4FC488

    loc_401719:                             ; CODE XREF: sub_401360+3B1j
    fld     dword ptr [esi+0BCh]
    fxch    st(1)
    fsubp   st(1), st
    fstp    dword ptr [esi+0BCh]
    jmp     short loc_40173B
    ; ---------------------------------------------------------------------------

    loc_40172B:                             ; CODE XREF: sub_401360+390j
                                            ; sub_401360+396j ...
    fld     dword ptr [esi+0BCh]
    fadd    st, st(1)
    fstp    dword ptr [esi+0BCh]
    fstp    st

    loc_40173B:                             ; CODE XREF: sub_401360+3C9j
    mov     eax, [esi+0ECh]
    mov     edx, [esi+92h]
    mov     ecx, [eax]
    fld     dword ptr [edx+1CAh]
    cmp     ecx, ebx
    jz      short loc_40178F
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_40178F
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+TAdynmemStruct.CurrentAIProfile]
    sub     eax, ebx
    jz      short loc_40177D
    dec     eax
    jnz     short loc_40178F
    fmul    ds:dbl_4FC480
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_401795
    ; ---------------------------------------------------------------------------

    loc_40177D:                             ; CODE XREF: sub_401360+406j
    fmul    ds:dbl_4FC488
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_401795
    ; ---------------------------------------------------------------------------

    loc_40178F:                             ; CODE XREF: sub_401360+3F1j
                                            ; sub_401360+3F7j ...
    fadd    dword ptr [esi+0D4h]

    loc_401795:                             ; CODE XREF: sub_401360+41Bj
                                            ; sub_401360+42Dj
    fstp    dword ptr [esi+0D4h]
    mov     ecx, [esi+92h]
    fld     dword ptr [ecx+1E6h]
    fadd    dword ptr [edi+0A8h]
    fstp    dword ptr [edi+0A8h]
    mov     edx, [esi+92h]
    fld     dword ptr [edx+1E2h]
    fadd    dword ptr [edi+0A4h]
    fstp    dword ptr [edi+0A4h]

    loc_4017CB:                             ; CODE XREF: sub_401360+376j
    cmp     [edi], ebx
    jz      short loc_4017D9
    cmp     byte ptr [edi+73h], 3
    jz      loc_401877

    loc_4017D9:                             ; CODE XREF: sub_401360+46Dj
    mov     eax, [esi+110h]
    mov     ecx, eax
    shr     ecx, 0Bh
    test    cl, 1
    jz      loc_40186D
    test    ah, 10h
    jnz     short loc_40186D
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esi+0B0h]
    cmp     edx, [ecx+TAdynmemStruct.GameTime]
    ja      short loc_40186D
    test    al, 0Ch
    jbe     short loc_401818
    mov     edx, [esi+92h]
    fld     dword ptr [edx+1DEh]
    jmp     short loc_401824
    ; ---------------------------------------------------------------------------

    loc_401818:                             ; CODE XREF: sub_401360+4A8j
    mov     eax, [esi+92h]
    fld     dword ptr [eax+1DAh]

    loc_401824:                             ; CODE XREF: sub_401360+4B6j
    call    __ftol
    mov     ecx, [esi+0ECh]
    mov     [esp+38h+arg_0], eax
    fild    [esp+38h+arg_0]
    fcom    dword ptr [ecx+8Ch]
    fnstsw  ax
    test    ah, 41h
    jz      short loc_401866
    fld     dword ptr [ecx+8Ch]
    fsub    st, st(1)
    mov     eax, 1
    push    eax
    fstp    dword ptr [ecx+8Ch]
    fadd    dword ptr [esi+0C0h]
    fstp    dword ptr [esi+0C0h]
    jmp     short loc_40186E
    ; ---------------------------------------------------------------------------

    loc_401866:                             ; CODE XREF: sub_401360+4E2j
    xor     eax, eax
    fstp    st
    push    eax
    jmp     short loc_40186E
    ; ---------------------------------------------------------------------------

    loc_40186D:                             ; CODE XREF: sub_401360+487j
                                            ; sub_401360+490j ...
    push    ebx                             ; int

    loc_40186E:                             ; CODE XREF: sub_401360+504j
                                            ; sub_401360+50Bj
    push    4                               ; idTo
    mov     ecx, esi
    call    sub_48B090

    loc_401877:                             ; CODE XREF: sub_401360+473j
    fld     dword ptr [esi+0BCh]
    fld     dword ptr [esi+0C0h]
    fld     dword ptr [esi+0C4h]
    fld     dword ptr [esi+0C8h]
    fld     dword ptr [esi+0D4h]
    fld     dword ptr [esi+0D8h]
    fxch    st(5)
    fadd    [esp+38h+var_10]
    fstp    [esp+38h+var_10]
    fld     dword ptr [esi+0DCh]
    fxch    st(4)
    fadd    [esp+38h+var_28]
    fstp    [esp+38h+var_28]
    fld     dword ptr [esi+0E0h]
    fxch    st(3)
    fadd    [esp+38h+var_18]
    fstp    [esp+38h+var_18]
    fxch    st(1)
    fadd    [esp+38h+var_20]
    fxch    st(1)
    fadd    [esp+38h+var_C]
    fxch    st(4)
    fadd    [esp+38h+var_24]
    fxch    st(3)
    fadd    [esp+38h+var_14]
    fxch    st(2)
    fadd    [esp+38h+var_1C]
    fxch    st(1)
    fstp    [esp+38h+var_20]
    fxch    st(3)
    fstp    [esp+38h+var_C]
    fxch    st(1)
    fstp    [esp+38h+var_24]
    fstp    [esp+38h+var_14]
    fstp    [esp+38h+var_1C]

    loc_4018FD:                             ; CODE XREF: sub_401360+54j
    mov     eax, [edi+6Bh]
    add     esi, 118h
    cmp     esi, eax
    jbe     loc_4013AC

    loc_40190E:                             ; CODE XREF: sub_401360+46j
    mov     eax, [edi+0ECh]
    fld     dword ptr [eax]
    fld     dword ptr [eax+4]
    fld     dword ptr [eax+8]
    fld     dword ptr [eax+0Ch]
    fld     dword ptr [eax+18h]
    fld     dword ptr [eax+1Ch]
    fxch    st(5)
    fadd    [esp+38h+var_10]
    fld     dword ptr [eax+20h]
    fxch    st(5)
    fadd    [esp+38h+var_28]
    fstp    [esp+38h+var_28]
    fld     dword ptr [eax+24h]
    fxch    st(4)
    fadd    [esp+38h+var_18]
    test    byte ptr [edi+149h], 1
    fstp    [esp+38h+var_18]
    fxch    st(2)
    fadd    [esp+38h+var_20]
    fxch    st(1)
    fadd    [esp+38h+var_C]
    fxch    st(5)
    fadd    [esp+38h+var_24]
    fxch    st(4)
    fadd    [esp+38h+var_14]
    fxch    st(3)
    fadd    [esp+38h+var_1C]
    fxch    st(1)
    fstp    [esp+38h+var_20]
    fxch    st(4)
    fstp    [esp+38h+var_C]
    fxch    st(2)
    fstp    [esp+38h+var_24]
    fstp    [esp+38h+var_14]
    fxch    st(1)
    fstp    [esp+38h+var_1C]
    jz      short loc_4019B0
    fld     dword ptr [edi+0E0h]
    fld     dword ptr [edi+0DCh]
    fadd    dword ptr [edi+0A4h]
    fxch    st(1)
    fadd    dword ptr [edi+0A8h]
    fxch    st(1)
    fstp    dword ptr [edi+0A4h]
    fstp    dword ptr [edi+0A8h]

    loc_4019B0:                             ; CODE XREF: sub_401360+626j
    fld     st
    fld     [esp+38h+var_28]
    fld     [esp+38h+var_C]
    fld     [esp+38h+var_24]
    fld     st(4)
    fld     [esp+38h+var_C]
    fxch    st(6)
    fstp    dword ptr [edi+90h]
    fxch    st(4)
    fadd    qword ptr [edi+0ACh]
    mov     ecx, [esp+38h+var_28]
    mov     esi, 3F800000h
    mov     [edi+94h], ecx
    xor     ecx, ecx
    fstp    qword ptr [edi+0ACh]
    fxch    st(2)
    fadd    qword ptr [edi+0BCh]
    fld     [esp+38h+var_C]
    fxch    st(1)
    fstp    qword ptr [edi+0BCh]
    fld     [esp+38h+var_24]
    fxch    st(1)
    fstp    dword ptr [edi+9Ch]
    fxch    st(1)
    fadd    qword ptr [edi+0B4h]
    fxch    st(2)
    fadd    qword ptr [edi+0C4h]
    fxch    st(3)
    fadd    dword ptr [edi+8Ch]
    fxch    st(4)
    fadd    dword ptr [edi+98h]
    fxch    st(1)
    fstp    dword ptr [edi+0A0h]
    fxch    st(1)
    fstp    qword ptr [edi+0B4h]
    fxch    st(1)
    fstp    qword ptr [edi+0C4h]
    fxch    st(1)
    fstp    [esp+38h+var_10]
    fstp    [esp+38h+var_C]

    loc_401A4D:                             ; CODE XREF: sub_401360+751j
    fld     [esp+ecx+38h+var_20]
    fcomp   [esp+ecx+38h+var_10]
    lea     edx, [esp+ecx+38h+var_10]
    fnstsw  ax
    test    ah, 41h
    jz      short loc_401A6A
    fld     [esp+ecx+38h+var_20]
    mov     [esp+ecx+38h+var_8], esi
    jmp     short loc_401A76
    ; ---------------------------------------------------------------------------

    loc_401A6A:                             ; CODE XREF: sub_401360+6FEj
    fld     dword ptr [edx]
    fld     dword ptr [edx]
    fdiv    [esp+ecx+38h+var_20]
    fstp    [esp+ecx+38h+var_8]

    loc_401A76:                             ; CODE XREF: sub_401360+708j
    fsubr   dword ptr [edx]
    fld     [esp+ecx+38h+var_18]
    fld     st(1)
    fxch    st(2)
    fxch    st(1)
    fcomp   st(2)
    fstp    dword ptr [edx]
    fnstsw  ax
    test    ah, 41h
    jz      short loc_401A97
    fld     [esp+ecx+38h+var_18]
    mov     [esp+ecx+38h+var_28], esi
    jmp     short loc_401AA3
    ; ---------------------------------------------------------------------------

    loc_401A97:                             ; CODE XREF: sub_401360+72Bj
    fld     st
    fld     st(1)
    fdiv    [esp+ecx+38h+var_18]
    fstp    [esp+ecx+38h+var_28]

    loc_401AA3:                             ; CODE XREF: sub_401360+735j
    fxch    st(1)
    fsub    st, st(1)
    add     ecx, 4
    cmp     ecx, 8
    fstp    dword ptr [edx]
    fstp    st
    jl      short loc_401A4D
    fld     [esp+38h+var_10]
    fcomp   dword ptr [edi+0A4h]
    mov     edx, [esp+38h+var_10]
    mov     [edi+8Ch], edx
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_401AF0
    fld     [esp+38h+var_10]
    fsub    dword ptr [edi+0A4h]
    mov     eax, [edi+0A4h]
    mov     [edi+8Ch], eax
    fadd    qword ptr [edi+0CCh]
    fstp    qword ptr [edi+0CCh]

    loc_401AF0:                             ; CODE XREF: sub_401360+76Cj
    fld     [esp+38h+var_C]
    fcomp   dword ptr [edi+0A8h]
    mov     ecx, [esp+38h+var_C]
    mov     [edi+98h], ecx
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_401B2D
    fld     [esp+38h+var_C]
    fsub    dword ptr [edi+0A8h]
    mov     edx, [edi+0A8h]
    mov     [edi+98h], edx
    fadd    qword ptr [edi+0D4h]
    fstp    qword ptr [edi+0D4h]

    loc_401B2D:                             ; CODE XREF: sub_401360+7A9j
    mov     ecx, [edi+67h]
    mov     eax, [edi+6Bh]
    cmp     ecx, eax
    ja      short loc_401BAE
    lea     eax, [ecx+0C0h]

    loc_401B3D:                             ; CODE XREF: sub_401360+84Cj
    test    [eax+50h], ebp
    jz      short loc_401B9C
    fld     [esp+38h+var_28]
    fmul    dword ptr [eax+4]
    mov     edx, [eax]
    mov     [eax], ebx
    mov     [eax+10h], edx
    mov     edx, [eax-4]
    fsubr   dword ptr [eax+4]
    fld     [esp+38h+var_8]
    fmul    dword ptr [eax+8]
    mov     [eax+0Ch], edx
    mov     [eax-4], ebx
    mov     [eax+4], ebx
    fsubr   dword ptr [eax+8]
    faddp   st(1), st
    fstp    dword ptr [eax+8]
    fld     [esp+38h+var_24]
    fmul    dword ptr [eax+1Ch]
    mov     edx, [eax+18h]
    mov     [eax+18h], ebx
    mov     [eax+28h], edx
    mov     edx, [eax+14h]
    fsubr   dword ptr [eax+1Ch]
    fld     [esp+38h+var_4]
    fmul    dword ptr [eax+20h]
    mov     [eax+24h], edx
    mov     [eax+14h], ebx
    mov     [eax+1Ch], ebx
    fsubr   dword ptr [eax+20h]
    faddp   st(1), st
    fstp    dword ptr [eax+20h]

    loc_401B9C:                             ; CODE XREF: sub_401360+7E0j
    mov     edx, [edi+6Bh]
    add     ecx, 118h
    add     eax, 118h
    cmp     ecx, edx
    jbe     short loc_401B3D

    loc_401BAE:                             ; CODE XREF: sub_401360+7D5j
    mov     eax, [edi+0ECh]
    fld     [esp+38h+var_28]
    fmul    dword ptr [eax+8]
    mov     ecx, [eax+4]
    mov     edx, [eax]
    mov     [eax+14h], ecx
    mov     [eax+10h], edx
    fsubr   dword ptr [eax+8]
    fld     [esp+38h+var_8]
    fmul    dword ptr [eax+0Ch]
    mov     [eax+4], ebx
    mov     [eax], ebx
    mov     [eax+8], ebx
    fsubr   dword ptr [eax+0Ch]
    faddp   st(1), st
    fstp    dword ptr [eax+0Ch]
    mov     eax, [edi+0ECh]
    pop     edi
    fld     [esp+34h+var_24]
    fmul    dword ptr [eax+20h]
    add     eax, 18h
    pop     esi
    pop     ebp
    fsubr   dword ptr [eax+8]
    fld     [esp+2Ch+var_4]
    fmul    dword ptr [eax+0Ch]
    mov     ecx, [eax+4]
    mov     edx, [eax]
    mov     [eax+4], ebx
    mov     [eax], ebx
    fsubr   dword ptr [eax+0Ch]
    mov     [eax+8], ebx
    mov     [eax+14h], ecx
    mov     [eax+10h], edx
    pop     ebx
    faddp   st(1), st
    fstp    dword ptr [eax+0Ch]
    add     esp, 28h
    retn    4
    sub_401360 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_401C20 proc near                    ; DATA XREF: .rdata:004FC494o

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_4]
    push    esi
    push    0
    call    sub_438880
    push    0
    mov     esi, [esp+8+arg_0]
    push    esi
    call    sub_48A0F0
    push    1
    push    esi
    call    sub_48A0F0
    push    2
    push    esi
    call    sub_48A0F0
    mov     eax, [esi+110h]
    and     eax, 3
    cmp     al, 2
    jnz     short loc_401CB2
    mov     ecx, [esi+92h]
    mov     eax, [ecx+241h]
    test    ah, 8
    jz      short loc_401CB2
    push    edi
    push    56h                             ; int
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    test    edi, edi
    jz      short loc_401CA8
    push    0
    push    0
    lea     edx, [esi+6Ah]
    push    0
    push    edx
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aVtol_landifcan          ; char *
    call    sub_438760
    mov     ecx, edi
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43ACB0
    pop     edi
    mov     eax, 5
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401CA8:                             ; CODE XREF: sub_401C20+55j
    xor     eax, eax
    push    eax
    push    esi
    call    sub_43ACB0
    pop     edi

    loc_401CB2:                             ; CODE XREF: sub_401C20+33j
                                            ; sub_401C20+44j
    mov     eax, 5
    pop     esi
    retn    0Ch
    sub_401C20 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     ecx, [eax+110h]
    and     ch, 7Fh
    or      ecx, 20h
    mov     [eax+110h], ecx
    mov     eax, 5
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 10h
    push    esi
    mov     esi, [esp+1Ch]
    mov     eax, [esi+3Ah]
    test    eax, eax
    jz      loc_401DB7
    mov     cl, [esp+1Ch]
    lea     edx, [esp+4]
    push    edx
    push    0
    push    eax
    mov     eax, [esp+24h]
    mov     [esp+10h], cl
    xor     edx, edx
    mov     dl, [eax+0FFh]
    lea     ecx, [eax+6Ah]
    push    ecx
    push    edx
    mov     dword ptr [esp+1Ch], 0
    mov     dword ptr [esp+20h], 0
    mov     dword ptr [esp+24h], 0
    call    sub_40AD80
    mov     ecx, [esp+8]
    test    ecx, ecx
    jnz     short loc_401D3D
    xor     eax, eax
    jmp     short loc_401D46
    ; ---------------------------------------------------------------------------

    loc_401D3D:                             ; CODE XREF: .text:00401D37j
    mov     eax, [esp+0Ch]
    sub     eax, ecx
    sar     eax, 2

    loc_401D46:                             ; CODE XREF: .text:00401D3Bj
    xor     edx, edx
    test    eax, eax
    setz    dl
    test    dl, dl
    jnz     short loc_401D66
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 5
    pop     esi
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401D66:                             ; CODE XREF: .text:00401D4Fj
    mov     eax, [esi+36h]
    test    eax, eax
    jg      short loc_401D82
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 5
    pop     esi
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401D82:                             ; CODE XREF: .text:00401D6Bj
    push    1Eh
    call    GetRandom
    mov     ecx, [esi+36h]
    add     eax, 96h
    sub     ecx, eax
    push    eax
    mov     [esi+36h], ecx
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esp+8]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 2
    pop     esi
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401DB7:                             ; CODE XREF: .text:00401CEDj
    xor     eax, eax
    mov     al, [esi+5]
    sub     eax, 0
    jz      short loc_401DDC
    dec     eax
    jz      short loc_401DD0
    mov     eax, 7
    pop     esi
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401DD0:                             ; CODE XREF: .text:00401DC2j
    mov     eax, 5
    pop     esi
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401DDC:                             ; CODE XREF: .text:00401DBFj
    mov     ecx, [esi+36h]
    push    ecx
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 1
    pop     esi
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 10h
    xor     eax, eax
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+24h]
    push    edi
    mov     al, [esi+5]
    sub     eax, 0
    jz      loc_401F8E
    dec     eax
    jz      short loc_401E2B
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401E2B:                             ; CODE XREF: .text:00401E1Aj
    mov     eax, TAdynmemStructPtr
    xor     ebx, ebx
    mov     [esp+14h], ebx
    mov     dword ptr [esp+10h], 7FFFFFFFh
    mov     edi, [eax+14357h]
    mov     ecx, [eax+1435Bh]
    add     edi, 118h
    cmp     edi, ecx
    ja      loc_401F1C
    jmp     short loc_401E5E
    ; ---------------------------------------------------------------------------

    loc_401E5A:                             ; CODE XREF: .text:00401F12j
    mov     esi, [esp+28h]

    loc_401E5E:                             ; CODE XREF: .text:00401E58j
    mov     ecx, [esi+36h]
    xor     eax, eax
    mov     ax, [edi+0A6h]
    cmp     eax, ecx
    jnz     loc_401F00
    mov     ecx, [edi+96h]
    xor     edx, edx
    mov     dl, [ecx+146h]
    mov     eax, edx
    mov     edx, [esp+24h]
    mov     ecx, [edx+96h]
    mov     bl, [eax+ecx+108h]
    test    bl, bl
    jnz     short loc_401F00
    mov     eax, [edi+6Ah]
    mov     esi, [edx+6Ah]
    mov     ebx, [edx+72h]
    mov     ecx, [edi+72h]
    sub     eax, esi
    sub     ecx, ebx
    cdq
    mov     esi, eax
    mov     ebx, edx
    mov     eax, ecx
    push    ebx
    cdq
    push    esi
    push    ebx
    push    esi
    mov     ebp, eax
    mov     [esp+2Ch], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     esi, eax
    mov     eax, [esp+1Ch]
    push    eax
    push    ebp
    push    eax
    push    ebp
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     esi, eax
    mov     eax, esi
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    GetRandom
    sub     esi, eax
    cmp     esi, [esp+10h]
    jg      short loc_401F00
    mov     [esp+14h], edi
    mov     [esp+10h], esi

    loc_401F00:                             ; CODE XREF: .text:00401E6Cj
                                            ; .text:00401E95j ...
    mov     edx, TAdynmemStructPtr
    add     edi, 118h
    cmp     edi, [edx+1435Bh]
    jbe     loc_401E5A
    mov     ebx, [esp+14h]

    loc_401F1C:                             ; CODE XREF: .text:00401E52j
    test    ebx, ebx
    jz      short loc_401F7F
    mov     esi, [esp+24h]
    push    0
    push    ebx
    push    esi
    lea     eax, [esp+30h]
    push    3
    push    eax
    call    sub_43F0E0
    push    56h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_401F6A
    mov     ecx, [esp+24h]
    push    0
    push    0
    push    0
    push    0
    push    ebx
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43ACB0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401F6A:                             ; CODE XREF: .text:00401F40j
    xor     eax, eax
    push    eax
    push    esi
    call    sub_43ACB0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401F7F:                             ; CODE XREF: .text:00401F1Ej
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401F8E:                             ; CODE XREF: .text:00401E13j
    mov     edx, [esp+24h]
    mov     eax, [edx+92h]
    test    byte ptr [eax+245h], 10h
    jnz     short loc_401FB0
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401FB0:                             ; CODE XREF: .text:00401F9Fj
    push    5Ah
    call    GetRandom
    inc     eax
    mov     ecx, esi
    push    eax
    call    sub_439E80
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, [esp+8]
    mov     eax, [ecx+16h]
    test    eax, eax
    jnz     short loc_401FE3
    mov     eax, 5
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401FE3:                             ; CODE XREF: .text:00401FD9j
    xor     eax, eax
    mov     al, [ecx+5]
    sub     eax, 0
    jz      short loc_402000
    dec     eax
    jz      short loc_401FF8
    mov     eax, 7
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_401FF8:                             ; CODE XREF: .text:00401FEEj
    mov     eax, 5
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402000:                             ; CODE XREF: .text:00401FEBj
    mov     dword ptr [ecx+6], 18h
    ; [00000008 BYTES: COLLAPSED FUNCTION DllMain(x,x,x). PRESS KEYPAD "+" TO EXPAND]
    align 4
    sub     esp, 18h
    push    ebp
    mov     ebp, [esp+20h]
    push    esi
    mov     esi, [esp+28h]
    push    edi
    test    dword ptr [esi+3Ah], 0F0000000h
    jnz     short loc_402042
    mov     eax, [ebp+92h]
    mov     ecx, [eax+245h]
    shr     ecx, 14h
    and     ecx, 7
    or      ecx, 0F0000000h
    mov     [esi+3Ah], ecx

    loc_402042:                             ; CODE XREF: .text:00402025j
    mov     eax, [esi+36h]
    test    eax, eax
    jnz     loc_40213C
    mov     edx, [ebp+92h]
    test    dword ptr [edx+245h], 700000h
    jbe     loc_40213C
    mov     al, [esp+30h]
    mov     dword ptr [esp+0Ch], 16h
    test    al, 2
    mov     dword ptr [esp+10h], 15h
    mov     dword ptr [esp+14h], 14h
    mov     dword ptr [esp+18h], 13h
    mov     dword ptr [esp+1Ch], 12h
    mov     dword ptr [esp+20h], 11h
    jz      short loc_4020C2
    mov     eax, [ebp+110h]
    test    ah, 40h
    jnz     loc_40214C
    push    0
    push    17h
    push    ebp
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4020C2:                             ; CODE XREF: .text:00402099j
    mov     edi, [esi+3Ah]
    and     edi, 0FFFFFFFh
    jnz     short loc_4020D6
    mov     dword ptr [esi+36h], 1
    jmp     short loc_4020E1
    ; ---------------------------------------------------------------------------

    loc_4020D6:                             ; CODE XREF: .text:004020CBj
    lea     eax, [edi-1]
    or      eax, 0F0000000h
    mov     [esi+3Ah], eax

    loc_4020E1:                             ; CODE XREF: .text:004020D4j
    test    edi, edi
    jl      short loc_40213C
    mov     ecx, [esp+edi*4+0Ch]
    push    0
    push    ecx
    push    ebp
    call    sub_47F780
    test    edi, edi
    jle     short loc_402115
    push    1Eh
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 2
    mov     [esi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402115:                             ; CODE XREF: .text:004020F4j
    jnz     short loc_40213C
    push    0Fh
    call    GetRandom
    push    eax
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 2
    mov     [esi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40213C:                             ; CODE XREF: .text:00402047j
                                            ; .text:0040205Dj ...
    push    0
    push    3
    push    7530h
    push    ebp
    push    ebp
    call    sub_489BB0

    loc_40214C:                             ; CODE XREF: .text:004020A4j
    pop     edi
    pop     esi
    mov     eax, 5
    pop     ebp
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+0Ch]
    push    edi
    mov     eax, [esi+16h]
    test    eax, eax
    jz      short loc_4021E3
    test    dword ptr [esp+14h], 10808h
    jnz     short loc_4021E3
    xor     eax, eax
    mov     al, [esi+5]
    sub     eax, 0
    jz      short loc_4021D0
    dec     eax
    jz      short loc_4021A6
    dec     eax
    jz      short loc_402191
    mov     eax, 7
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402191:                             ; CODE XREF: .text:00402185j
    mov     ecx, [esp+0Ch]
    push    3
    call    sub_489800
    mov     eax, 9
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4021A6:                             ; CODE XREF: .text:00402182j
    mov     edi, [esp+0Ch]
    push    0
    mov     ecx, edi
    call    sub_4898B0
    mov     eax, [esi+16h]
    push    0
    push    eax
    push    edi
    call    sub_48A060
    mov     dword ptr [esi+6], 11808h
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4021D0:                             ; CODE XREF: .text:0040217Fj
    push    0
    mov     ecx, esi
    call    sub_438880
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4021E3:                             ; CODE XREF: .text:0040216Bj
                                            ; .text:00402175j
    pop     edi
    mov     eax, 5
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, [esp+0Ch]
    sub     esp, 10h
    test    ecx, 10008h
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      short loc_40221A
    mov     eax, [esp+28h]
    mov     byte ptr [eax+5], 3
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40221A:                             ; CODE XREF: .text:00402201j
    mov     esi, [esp+28h]
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_402403                      ; default
    jmp     ds:off_402414[eax*4]            ; switch jump

    loc_402233:                             ; DATA XREF: .text:00402414o
    mov     ecx, [esp+24h]                  ; case 0x0
    push    3
    call    sub_489800
    push    1Eh
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402256:                             ; CODE XREF: .text:0040222Cj
                                            ; DATA XREF: .text:00402414o
    mov     edi, [esp+24h]                  ; case 0x1
    xor     ebp, ebp
    push    ebp
    push    edi
    call    sub_48A190
    push    eax
    lea     ecx, [esi+12h]
    call    sub_489690
    mov     eax, [esi+16h]
    cmp     eax, ebp
    jz      short loc_4022C7
    test    dword ptr [eax+110h], 10000000h
    jz      short loc_4022C7
    add     eax, 6Ah
    lea     ecx, [esi+22h]
    push    ebp
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    mov     ecx, edi
    call    sub_4898B0
    mov     ecx, [esi+16h]
    push    ebp
    push    ecx
    push    edi
    call    sub_48A060
    push    3
    mov     [esi+36h], ebp
    call    GetRandom
    add     eax, 3
    mov     [esi+3Ah], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4022C7:                             ; CODE XREF: .text:00402271j
                                            ; .text:0040227Dj
    push    1Eh
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4022DF:                             ; CODE XREF: .text:0040222Cj
                                            ; DATA XREF: .text:00402414o
    xor     ebp, ebp                        ; case 0x2
    test    ch, 40h
    jz      short loc_4022EB
    mov     [esi+36h], ebp
    jmp     short loc_4022EE
    ; ---------------------------------------------------------------------------

    loc_4022EB:                             ; CODE XREF: .text:004022E4j
    inc     dword ptr [esi+36h]

    loc_4022EE:                             ; CODE XREF: .text:004022E9j
    mov     edx, [esi+36h]
    mov     eax, [esi+3Ah]
    cmp     edx, eax
    jg      short loc_402325
    mov     eax, [esi+16h]
    mov     ecx, [esp+24h]
    push    ebp
    push    eax
    push    ecx
    call    sub_49ABB0
    test    eax, eax
    jz      short loc_402325
    mov     eax, [esi+6]
    or      eax, 7008h
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402325:                             ; CODE XREF: .text:004022F6j
                                            ; .text:00402309j
    push    64h
    call    GetRandom
    cmp     eax, 50h
    jge     loc_4023F7
    mov     [esi+36h], ebp
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402347:                             ; CODE XREF: .text:0040222Cj
                                            ; DATA XREF: .text:00402414o
    mov     dl, [esp+24h]                   ; case 0x3
    mov     ebx, [esp+24h]
    lea     eax, [esp+10h]
    mov     [esp+10h], dl
    xor     ebp, ebp
    push    eax
    xor     edx, edx
    push    ebp
    mov     dl, [ebx+0FFh]
    lea     ecx, [esi+22h]
    push    280h
    push    ecx
    push    edx
    mov     [esp+28h], ebp
    mov     [esp+2Ch], ebp
    mov     [esp+30h], ebp
    call    sub_40AD80
    mov     edi, [esp+18h]
    mov     eax, [esp+14h]
    cmp     eax, ebp
    jnz     short loc_40238E
    xor     ecx, ecx
    jmp     short loc_402395
    ; ---------------------------------------------------------------------------

    loc_40238E:                             ; CODE XREF: .text:00402388j
    mov     ecx, edi
    sub     ecx, eax
    sar     ecx, 2

    loc_402395:                             ; CODE XREF: .text:0040238Cj
    xor     edx, edx
    cmp     ecx, ebp
    setz    dl
    test    dl, dl
    jnz     short loc_4023EE
    cmp     eax, ebp
    jnz     short loc_4023A8
    xor     ecx, ecx
    jmp     short loc_4023AF
    ; ---------------------------------------------------------------------------

    loc_4023A8:                             ; CODE XREF: .text:004023A2j
    sub     edi, eax
    sar     edi, 2
    mov     ecx, edi

    loc_4023AF:                             ; CODE XREF: .text:004023A6j
    push    ecx
    mov     edi, eax
    call    GetRandom
    mov     eax, [edi+eax*4]
    lea     ecx, [esi+12h]
    push    eax
    call    sub_489690
    mov     ecx, [esi+16h]
    push    ebp
    push    ecx
    push    ebx
    call    sub_48A060
    mov     byte ptr [esi+5], 1
    mov     edx, [esp+14h]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4023EE:                             ; CODE XREF: .text:0040239Ej
    push    eax
    call    sub_4B4F20
    add     esp, 4

    loc_4023F7:                             ; CODE XREF: .text:0040232Fj
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402403:                             ; CODE XREF: .text:00402226j
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_402414 dd offset loc_402233         ; DATA XREF: .text:0040222Cr
    dd offset loc_402256                    ; jump table for switch statement
    dd offset loc_4022DF
    dd offset loc_402347
    align 10h
    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+3Ch]
    mov     ecx, [edi+16h]
    test    ecx, ecx
    jnz     short loc_402462
    mov     eax, [esp+38h]
    push    offset aRepairAborted_          ; "Repair aborted."
    push    7
    push    eax
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402462:                             ; CODE XREF: .text:00402440j
    xor     eax, eax
    mov     al, [edi+5]
    sub     eax, 0
    jz      loc_4025D7
    dec     eax
    jz      short loc_4024A5
    dec     eax
    jz      short loc_402485
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402485:                             ; CODE XREF: .text:00402474j
    mov     ecx, [esp+38h]
    push    offset aUnitRepaired            ; "Unit repaired"
    push    0Ah
    push    ecx
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4024A5:                             ; CODE XREF: .text:00402471j
    mov     esi, [esp+38h]
    mov     eax, [esi+92h]
    movsx   edx, word ptr [esi+108h]
    cmp     edx, [eax+1FAh]
    jb      short loc_4024CD
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4024CD:                             ; CODE XREF: .text:004024BCj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+38A47h]
    xor     ecx, ecx
    add     edx, 96h
    mov     [esi+0B0h], edx
    mov     ebx, [edi+16h]
    mov     eax, [ebx+92h]
    mov     cx, [eax+1FEh]
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 4
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    push    ecx
    mov     [esp+3Ch], edx
    fild    dword ptr [esp+3Ch]
    fstp    dword ptr [esp]
    push    esi
    push    ebx
    call    sub_41BD10
    test    eax, eax
    jz      loc_4025B7
    mov     eax, [edi+16h]
    lea     edx, [esp+10h]
    push    edx
    push    eax
    call    sub_43E400
    mov     ebp, [esi+6Eh]
    lea     eax, [esi+6Ah]
    mov     edi, eax
    mov     [esp+20h], ebp
    mov     ebx, [eax]
    mov     ebp, [eax+8]
    mov     ecx, [edi]
    mov     eax, [esi+92h]
    mov     [esp+28h], ecx
    mov     [esp+1Ch], ebx
    mov     edx, [edi+4]
    mov     [esp+24h], ebp
    mov     [esp+2Ch], edx
    push    6
    mov     edi, [edi+8]
    mov     [esp+34h], edi
    mov     esi, [eax+15Eh]
    add     ebx, esi
    mov     [esp+20h], ebx
    mov     esi, [eax+166h]
    add     ebp, esi
    mov     [esp+28h], ebp
    mov     ebp, [eax+16Ah]
    add     ecx, ebp
    mov     [esp+2Ch], ecx
    mov     ebx, [eax+172h]
    add     edi, ebx
    lea     ecx, [esp+20h]
    mov     [esp+34h], edi
    mov     edi, [eax+16Eh]
    add     edx, edi
    push    ecx
    mov     [esp+34h], edx
    lea     edx, [esp+18h]
    push    edx
    call    sub_4720D0
    mov     edi, [esp+3Ch]

    loc_4025B7:                             ; CODE XREF: .text:0040251Fj
    push    1
    mov     ecx, edi
    call    sub_439E80
    mov     eax, [edi+6]
    or      al, 8
    mov     [edi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4025D7:                             ; CODE XREF: .text:0040246Aj
    mov     eax, [ecx+92h]
    test    byte ptr [eax+241h], 40h
    jnz     short loc_4025F5
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4025F5:                             ; CODE XREF: .text:004025E4j
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FC6D0
    fnstsw  ax
    test    ah, 40h
    jz      short loc_40262B
    mov     ecx, [esp+38h]
    test    byte ptr [ecx+10Eh], 1
    jz      short loc_40262B
    push    3
    call    sub_4898B0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40262B:                             ; CODE XREF: .text:00402606j
                                            ; .text:00402613j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 8
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     al, [esp+0Ch]
    sub     esp, 30h
    test    al, 2
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      loc_402726
    mov     edi, [esp+48h]
    mov     esi, [esp+44h]
    mov     eax, [edi+16h]
    test    eax, eax
    jz      loc_402706
    fld     ds:flt_4FC6D4
    fsub    dword ptr [eax+104h]
    mov     eax, [eax+92h]
    fmul    dword ptr [eax+18Ah]
    call    __ftol
    mov     [esp+10h], eax
    mov     eax, [esi+0ECh]
    mov     dword ptr [esp+14h], 0
    mov     ecx, [eax]
    fild    qword ptr [esp+10h]
    test    ecx, ecx
    jz      short loc_4026DD
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_4026DD
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+37EEEh]
    sub     eax, 0
    jz      short loc_4026CB
    dec     eax
    jnz     short loc_4026DD
    fmul    ds:dbl_4FC6D8
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_4026E3
    ; ---------------------------------------------------------------------------

    loc_4026CB:                             ; CODE XREF: .text:004026B4j
    fmul    ds:dbl_4FC6E0
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_4026E3
    ; ---------------------------------------------------------------------------

    loc_4026DD:                             ; CODE XREF: .text:0040269Dj
                                            ; .text:004026A3j ...
    fadd    dword ptr [esi+0D4h]

    loc_4026E3:                             ; CODE XREF: .text:004026C9j
                                            ; .text:004026DBj
    fstp    dword ptr [esi+0D4h]
    mov     edx, [edi+16h]
    push    edx
    push    esi
    call    sub_41B8D0
    mov     eax, [edi+16h]
    push    0
    push    9
    push    7530h
    push    eax
    push    esi
    call    sub_489BB0

    loc_402706:                             ; CODE XREF: .text:00402660j
    push    0
    push    9
    mov     ecx, esi
    call    sub_48B090
    push    esi
    call    sub_41C150
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402726:                             ; CODE XREF: .text:0040264Dj
    test    al, 8
    jz      short loc_402754
    mov     esi, [esp+44h]
    push    offset aConstructionSt          ; "Construction stopped"
    push    7
    push    esi
    call    sub_47F780
    push    esi
    mov     eax, [esp+4Ch]
    dec     dword ptr [eax+3Ah]
    call    sub_41C150
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402754:                             ; CODE XREF: .text:00402728j
    mov     esi, [esp+48h]
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 4                          ; switch 5 cases
    ja      loc_402B4D                      ; default
    jmp     ds:off_402B5C[eax*4]            ; switch jump

    loc_40276D:                             ; DATA XREF: .text:00402B5Co
    push    0                               ; case 0x0
    lea     ecx, [esi+12h]
    call    sub_489690
    mov     ecx, [esp+44h]
    test    dword ptr [ecx+110h], 20000000h
    jz      loc_402B4D                      ; default
    mov     eax, [esi+3Ah]
    test    eax, eax
    jg      short loc_4027AA
    push    0
    push    1
    call    sub_48B090
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4027AA:                             ; CODE XREF: .text:00402790j
    push    1
    push    1
    call    sub_48B090
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4027C2:                             ; CODE XREF: .text:00402766j
                                            ; DATA XREF: .text:00402B5Co
    mov     ecx, [esp+44h]                  ; case 0x1
    push    2
    push    esi
    push    ecx
    call    sub_438700
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4027D9:                             ; CODE XREF: .text:00402766j
                                            ; DATA XREF: .text:00402B5Co
    mov     edi, [esp+44h]                  ; case 0x2
    push    0
    push    0
    lea     edx, [esp+50h]
    mov     ecx, [edi+9Ah]
    push    0
    push    edx
    push    offset aQuerybuildinfo          ; "QueryBuildInfo"
    mov     dword ptr [esp+5Ch], 0FFFFFFFFh
    call    sub_4B0BC0
    lea     ecx, [esp+1Ch]
    mov     eax, [esp+48h]
    push    eax
    push    edi
    push    ecx
    call    sub_43E060
    lea     ebp, [esi+22h]
    mov     edx, eax
    mov     ecx, ebp
    mov     ebx, [edx]
    mov     [ecx], ebx
    mov     ebx, [edx+4]
    mov     [ecx+4], ebx
    mov     edx, [edx+8]
    mov     [ecx+8], edx
    mov     edx, [esi+36h]
    mov     ecx, edx
    mov     ebx, [eax+4]
    shl     ecx, 6
    add     ecx, edx
    mov     edx, TAdynmemStructPtr
    mov     [esp+14h], ebx
    mov     edx, [edx+1439Bh]
    lea     ecx, [ecx+ecx*8]
    add     edx, ecx
    mov     ecx, [edx+14Ah]
    mov     [esp+44h], ecx
    mov     ecx, [eax]
    movsx   ebx, word ptr [esp+44h]
    shl     ebx, 13h
    sub     ecx, ebx
    mov     eax, [eax+8]
    add     ecx, 80000h
    sar     ecx, 14h
    mov     [esp+4Ch], cx
    movsx   ecx, word ptr [esp+46h]
    shl     ecx, 13h
    sub     eax, ecx
    add     eax, 80000h
    sar     eax, 14h
    mov     [esp+4Eh], ax
    mov     eax, [edi+110h]
    mov     ecx, [esp+4Ch]
    and     eax, 3
    push    eax
    push    ecx
    push    0
    push    edx
    call    sub_47DB70
    test    eax, eax
    jnz     short loc_4028C2
    push    0Fh
    mov     ecx, esi
    call    sub_439E80
    mov     ecx, [esi+6]
    mov     eax, 2
    or      ecx, eax
    mov     [esi+6], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4028C2:                             ; CODE XREF: .text:004028A0j
    mov     eax, [ebp+0]
    push    0
    push    1
    push    0
    mov     ecx, [ebp+4]
    sub     esp, 0Ch
    mov     edx, esp
    mov     [edx], eax
    mov     eax, [ebp+8]
    mov     [edx+4], ecx
    mov     cx, [esi+36h]
    push    ecx
    mov     [edx+8], eax
    mov     dl, [edi+0FFh]
    push    edx
    call    sub_485F50
    push    eax
    lea     ecx, [esi+12h]
    call    sub_489690
    mov     eax, [esi+16h]
    test    eax, eax
    jnz     short loc_40292F
    push    offset aUnableToCreate          ; "Unable to create any more units"
    push    7
    push    edi
    call    sub_47F780
    push    12Ch
    mov     ecx, esi
    call    sub_439E80
    mov     ecx, [esi+6]
    mov     eax, 2
    or      ecx, eax
    mov     [esi+6], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40292F:                             ; CODE XREF: .text:004028FDj
    push    offset aStartingConstr          ; "Starting construction"
    push    9
    push    edi
    call    sub_47F780
    mov     ecx, [esi+16h]
    push    1
    mov     eax, [esp+4Ch]
    push    eax
    push    edi
    push    ecx
    call    sub_48AAC0
    mov     eax, [esi+16h]
    mov     edx, [edi+110h]
    push    0
    push    0
    mov     ecx, [eax+110h]
    push    0
    xor     edx, ecx
    push    edi
    and     edx, 0C0000h
    xor     edx, ecx
    mov     [eax+110h], edx
    mov     eax, [esi+16h]
    mov     edx, [edi+110h]
    mov     ecx, [eax+110h]
    xor     edx, ecx
    and     edx, 300000h
    xor     edx, ecx
    mov     [eax+110h], edx
    mov     eax, [esi+16h]
    push    eax
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aGetbuilt                ; "getbuilt"
    call    sub_438760
    call    sub_43ADC0
    push    1
    push    8
    mov     ecx, edi
    call    sub_48B090
    push    edi
    call    sub_41C150
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4029CA:                             ; CODE XREF: .text:00402766j
                                            ; DATA XREF: .text:00402B5Co
    mov     ebx, [esi+16h]                  ; case 0x3
    test    ebx, ebx
    jz      loc_402B4D                      ; default
    mov     edi, [esp+44h]
    xor     ecx, ecx
    mov     eax, 88888889h
    mov     edx, [edi+92h]
    mov     cx, [edx+1FEh]
    imul    ecx
    add     edx, ecx
    push    ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+48h], edx
    fild    dword ptr [esp+48h]
    fstp    dword ptr [esp]
    push    ebx
    push    edi
    call    sub_41BA60
    test    eax, eax
    jz      loc_402AC2
    lea     ecx, [esp+10h]
    push    ecx
    push    edi
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    lea     ecx, [eax+6Ah]
    mov     ebx, ecx
    mov     edx, [ebx]
    mov     [esp+38h], edx
    mov     edi, [ebx+4]
    mov     [esp+3Ch], edi
    mov     ebx, [ebx+8]
    mov     [esp+40h], ebx
    mov     ebp, [ecx]
    mov     [esp+2Ch], ebp
    mov     ebp, [ecx+4]
    mov     [esp+30h], ebp
    mov     ecx, [ecx+8]
    mov     ebp, [esp+2Ch]
    mov     [esp+34h], ecx
    mov     ecx, [eax+92h]
    mov     ecx, [ecx+15Eh]
    add     ebp, ecx
    mov     [esp+2Ch], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [esp+34h]
    mov     ecx, [ecx+166h]
    add     ebp, ecx
    mov     [esp+34h], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [ecx+16Ah]
    lea     ecx, [esp+2Ch]
    add     edx, ebp
    push    ecx
    mov     [esp+3Ch], edx
    mov     edx, [eax+92h]
    mov     ebp, [edx+172h]
    lea     edx, [esp+18h]
    add     ebx, ebp
    push    edx
    mov     [esp+48h], ebx
    mov     eax, [eax+92h]
    add     edi, [eax+16Eh]
    mov     [esp+44h], edi
    call    sub_4720D0

    loc_402AC2:                             ; CODE XREF: .text:00402A10j
    mov     eax, [esi+16h]
    fld     dword ptr [eax+104h]
    fcomp   ds:flt_4FC6D0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_402AF8
    push    1
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 0Ah
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402AF8:                             ; CODE XREF: .text:00402AD6j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402B07:                             ; CODE XREF: .text:00402766j
                                            ; DATA XREF: .text:00402B5Co
    mov     edi, [esp+44h]                  ; case 0x4
    push    0
    push    8
    push    edi
    call    sub_47F780
    push    0
    push    8
    mov     ecx, edi
    call    sub_48B090
    mov     ecx, [esi+16h]
    push    ecx
    push    edi
    call    sub_41B8D0
    push    0
    lea     ecx, [esi+12h]
    call    sub_489690
    mov     ecx, [esi+3Ah]
    push    edi
    dec     ecx
    mov     [esi+3Ah], ecx
    call    sub_41C150
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402B4D:                             ; CODE XREF: .text:00402760j
                                            ; .text:00402785j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    off_402B5C dd offset loc_40276D         ; DATA XREF: .text:00402766r
    dd offset loc_4027C2                    ; jump table for switch statement
    dd offset loc_4027D9
    dd offset loc_4029CA
    dd offset loc_402B07
    ; ---------------------------------------------------------------------------
    sub     esp, 8
    mov     edx, [esp+0Ch]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+1Ch]
    push    edi
    mov     eax, [esi+36h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     edi, [edx+ecx*4+10h]
    lea     eax, [edx+ecx*4]
    xor     ecx, ecx
    mov     cl, [esi+5]
    sub     ecx, 0
    jz      loc_402CB4
    dec     ecx
    jz      short loc_402BD4
    dec     ecx
    jz      short loc_402BB3
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402BB3:                             ; CODE XREF: .text:00402BA2j
    mov     bl, [eax+1Eh]
    push    edx
    inc     bl
    mov     [eax+1Eh], bl
    mov     ecx, [esi+3Ah]
    dec     ecx
    mov     [esi+3Ah], ecx
    call    sub_41C150
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402BD4:                             ; CODE XREF: .text:00402B9Fj
    mov     eax, [esi+3Eh]
    mov     [esp+10h], eax
    lea     ecx, [eax+5]
    xor     eax, eax
    mov     ax, [edi+0E4h]
    mov     ebx, ecx
    cmp     ecx, eax
    mov     [esp+14h], eax
    jl      short loc_402BF3
    mov     ebx, eax

    loc_402BF3:                             ; CODE XREF: .text:00402BEFj
    fild    dword ptr [esp+10h]
    fild    dword ptr [esp+14h]
    mov     [esp+20h], ebx
    fld     st(1)
    fmul    dword ptr [edi+0C4h]
    fild    dword ptr [esp+20h]
    fxch    st(1)
    fdiv    st, st(2)
    call    __ftol
    fld     st
    fmul    dword ptr [edi+0C4h]
    mov     ebp, eax
    fdiv    st, st(2)
    call    __ftol
    fmul    dword ptr [edi+0C0h]
    sub     eax, ebp
    push    ecx
    mov     [esp+24h], eax
    fdiv    st, st(1)
    fild    dword ptr [esp+24h]
    fstp    dword ptr [esp]
    call    __ftol
    fxch    st(1)
    fmul    dword ptr [edi+0C0h]
    mov     ebp, eax
    fdiv    st, st(1)
    call    __ftol
    mov     edx, [esp+20h]
    sub     ebp, eax
    fstp    st
    mov     [esp+24h], ebp
    push    ecx
    fild    dword ptr [esp+28h]
    lea     ecx, [edx+0BCh]
    fstp    dword ptr [esp]
    call    sub_4011C0
    test    eax, eax
    jz      short loc_402C9C
    xor     eax, eax
    mov     [esi+3Eh], ebx
    mov     ax, [edi+0E4h]
    cmp     ebx, eax
    jge     short loc_402CF2
    push    5
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402C9C:                             ; CODE XREF: .text:00402C72j
    push    0Ah
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402CB4:                             ; CODE XREF: .text:00402B98j
    mov     ecx, [esi+3Ah]
    test    ecx, ecx
    jg      short loc_402CCA
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402CCA:                             ; CODE XREF: .text:00402CB9j
    cmp     byte ptr [eax+1Eh], 0C8h
    jb      short loc_402CEB
    push    12Ch
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402CEB:                             ; CODE XREF: .text:00402CCEj
    mov     dword ptr [esi+3Eh], 0

    loc_402CF2:                             ; CODE XREF: .text:00402C82j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebp
    mov     ebp, [esp+0Ch]
    mov     eax, [ebp+36h]
    test    eax, eax
    jnz     short loc_402D31
    mov     ecx, [esp+8]
    push    eax
    push    10h
    call    sub_48B090
    mov     eax, 5
    pop     ebp
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402D31:                             ; CODE XREF: .text:00402D1Aj
    push    edi
    push    esi
    cmp     eax, 708h
    push    ebx
    jle     short loc_402D42
    mov     dword ptr [ebp+36h], 708h

    loc_402D42:                             ; CODE XREF: .text:00402D39j
    mov     edi, [esp+14h]
    push    3
    mov     ecx, edi
    call    sub_4898B0
    xor     esi, esi
    mov     ebx, 3

    loc_402D56:                             ; CODE XREF: .text:00402D5Fj
    push    esi
    push    edi
    call    sub_48A0F0
    inc     esi
    dec     ebx
    jnz     short loc_402D56
    push    0
    mov     ecx, ebp
    call    sub_4388D0
    mov     eax, [ebp+36h]
    mov     ecx, ebp
    push    eax
    call    sub_439E80
    push    1
    push    10h
    mov     ecx, edi
    mov     dword ptr [ebp+36h], 0
    call    sub_48B090
    pop     ebx
    pop     esi
    pop     edi
    mov     eax, 1
    pop     ebp
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+1Ch]
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FC6D0
    fnstsw  ax
    test    ah, 40h
    jz      loc_402F0E
    push    edi
    call    sub_41C110
    cmp     dword ptr [edi], 0
    jz      loc_402EFF
    mov     ebp, [esp+20h]
    xor     ebx, ebx
    mov     eax, [ebp+16h]
    test    eax, eax
    jz      loc_402EE2
    push    offset aQmove_0                 ; "QMove"
    lea     ecx, [esp+14h]
    call    sub_438760
    push    offset aQpatrol_0               ; "QPatrol"
    lea     ecx, [esp+18h]
    call    sub_438760
    mov     eax, [ebp+16h]
    mov     esi, [eax+5Ch]
    test    esi, esi
    jz      short loc_402E6F

    loc_402E08:                             ; CODE XREF: .text:00402E6Dj
    mov     cl, [esi+4]
    mov     dl, [esp+10h]
    xor     al, al
    cmp     cl, dl
    mov     [esp+24h], al
    jnz     short loc_402E29
    lea     eax, [esi+22h]
    lea     ecx, [esp+20h]
    push    eax
    push    0
    push    edi
    push    2
    push    ecx
    jmp     short loc_402E3D
    ; ---------------------------------------------------------------------------

    loc_402E29:                             ; CODE XREF: .text:00402E17j
    cmp     cl, [esp+14h]
    jnz     short loc_402E48
    lea     edx, [esi+22h]
    lea     eax, [esp+1Ch]
    push    edx
    push    0
    push    edi
    push    9
    push    eax

    loc_402E3D:                             ; CODE XREF: .text:00402E27j
    call    sub_43F0E0
    mov     al, [eax]
    mov     [esp+24h], al

    loc_402E48:                             ; CODE XREF: .text:00402E2Dj
    test    al, al
    jz      short loc_402E68
    mov     edx, [esp+24h]
    push    0
    lea     ecx, [esi+22h]
    push    0
    push    ecx
    push    0
    push    edi
    push    1
    push    edx
    call    sub_43ADC0
    mov     ebx, 1

    loc_402E68:                             ; CODE XREF: .text:00402E4Aj
    mov     esi, [esi+4Ah]
    test    esi, esi
    jnz     short loc_402E08

    loc_402E6F:                             ; CODE XREF: .text:00402E06j
    mov     ecx, [edi+110h]
    test    ecx, 10000000h
    jz      short loc_402EE2
    test    ch, 40h
    jnz     short loc_402EE2
    mov     eax, [ebp+16h]
    mov     edx, [eax+110h]
    test    edx, 10000000h
    jz      short loc_402EE2
    test    dh, 40h
    jnz     short loc_402EE2
    mov     eax, edx
    xor     eax, ecx
    and     eax, 0C0000h
    xor     eax, ecx
    mov     [edi+110h], eax
    mov     ecx, [ebp+16h]
    mov     ecx, [ecx+110h]
    xor     ecx, eax
    and     ecx, 300000h
    xor     ecx, eax
    mov     eax, [edi+96h]
    mov     [edi+110h], ecx
    cmp     dword ptr [eax], 0
    jz      short loc_402EE2
    cmp     byte ptr [eax+73h], 1
    jnz     short loc_402EE2
    mov     eax, [ebp+16h]
    mov     edx, [eax+0ACh]
    mov     [edi+0ACh], edx

    loc_402EE2:                             ; CODE XREF: .text:00402DDCj
                                            ; .text:00402E7Bj ...
    test    ebx, ebx
    jnz     short loc_402EFF
    push    ebx
    push    ebx
    push    ebx
    push    ebx
    push    edi
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aPark                    ; "PARK"
    call    sub_438760
    call    sub_43ADC0

    loc_402EFF:                             ; CODE XREF: .text:00402DCBj
                                            ; .text:00402EE4j
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402F0E:                             ; CODE XREF: .text:00402DBCj
    mov     esi, [esp+20h]
    xor     eax, eax
    mov     al, [esi+5]
    sub     eax, 0
    jz      short loc_402F8C
    dec     eax
    jz      short loc_402F88
    dec     eax
    jz      short loc_402F31
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402F31:                             ; CODE XREF: .text:00402F20j
    mov     eax, [esp+24h]
    test    ah, 80h
    jz      short loc_402F5B
    push    1Eh
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      ah, 80h
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402F5B:                             ; CODE XREF: .text:00402F38j
    test    al, 1
    jz      short loc_402F70
    push    0Bh
    mov     ecx, esi
    call    sub_439E80
    push    0Bh
    push    edi
    call    sub_41BCD0

    loc_402F70:                             ; CODE XREF: .text:00402F5Dj
    mov     eax, [esi+6]
    or      ah, 80h
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402F88:                             ; CODE XREF: .text:00402F1Dj
    push    1Eh
    jmp     short loc_402F9A
    ; ---------------------------------------------------------------------------

    loc_402F8C:                             ; CODE XREF: .text:00402F1Aj
    push    3
    mov     ecx, edi
    call    sub_4898B0
    push    12Ch

    loc_402F9A:                             ; CODE XREF: .text:00402F8Aj
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    pop     edi
    or      ah, 80h
    mov     [esi+6], eax
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     edx, [esp+4]
    mov     eax, [edx+86h]
    test    eax, eax
    jnz     short loc_402FD6
    mov     eax, 5
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402FD6:                             ; CODE XREF: .text:00402FCCj
    mov     ecx, [esp+8]
    xor     eax, eax
    mov     al, [ecx+5]
    sub     eax, 0
    jz      short loc_402FFE
    dec     eax
    jz      short loc_402FEF
    mov     eax, 7
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402FEF:                             ; CODE XREF: .text:00402FE5j
    push    0Ah
    call    sub_439E80
    mov     eax, 2
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_402FFE:                             ; CODE XREF: .text:00402FE2j
    push    3
    mov     ecx, edx
    call    sub_4898B0
    mov     eax, 1
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, [esp+4]
    mov     eax, [ecx+92h]
    mov     edx, [eax+245h]
    shr     edx, 2
    test    dl, 1
    jz      short loc_403031
    push    1
    push    1
    call    sub_48B090

    loc_403031:                             ; CODE XREF: .text:00403026j
    mov     eax, 5
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    mov     eax, [ecx+92h]
    mov     edx, [eax+245h]
    shr     edx, 2
    test    dl, 1
    jz      short loc_403061
    push    0
    push    1
    call    sub_48B090

    loc_403061:                             ; CODE XREF: .text:00403056j
    mov     eax, 5
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     ecx, [eax+92h]
    mov     edx, [ecx+245h]
    shr     edx, 0Dh
    test    dl, 1
    jz      short loc_403097
    mov     ecx, [eax+110h]
    or      ch, 8
    mov     [eax+110h], ecx

    loc_403097:                             ; CODE XREF: .text:00403086j
    mov     eax, 5
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    mov     ecx, [eax+92h]
    mov     edx, [ecx+245h]
    shr     edx, 0Dh
    test    dl, 1
    jz      short loc_4030C7
    mov     ecx, [eax+110h]
    and     ch, 0F7h
    mov     [eax+110h], ecx

    loc_4030C7:                             ; CODE XREF: .text:004030B6j
    mov     eax, 5
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, [esp+8]
    mov     eax, [esp+4]
    mov     edx, [ecx+36h]
    mov     ecx, [eax+110h]
    and     edx, 3
    and     ecx, 0FFF3FFFFh
    shl     edx, 12h
    or      edx, ecx
    mov     [eax+110h], edx
    mov     eax, 5
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+8]
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch]
    mov     ecx, [eax+36h]
    push    esi
    mov     edx, [ebp+110h]
    and     ecx, 3
    shl     ecx, 14h
    and     edx, 0FFCFFFFFh
    push    edi
    or      ecx, edx
    mov     [ebp+110h], ecx
    mov     eax, [eax+36h]
    test    eax, eax
    jz      short loc_403135
    cmp     eax, 1
    jnz     short loc_403152

    loc_403135:                             ; CODE XREF: .text:0040312Ej
    xor     esi, esi
    lea     edi, [ebp+1Fh]
    mov     ebx, 3

    loc_40313F:                             ; CODE XREF: .text:00403150j
    test    byte ptr [edi], 10h
    jz      short loc_40314B
    push    esi
    push    ebp
    call    sub_48A0F0

    loc_40314B:                             ; CODE XREF: .text:00403142j
    inc     esi
    add     edi, 1Ch
    dec     ebx
    jnz     short loc_40313F

    loc_403152:                             ; CODE XREF: .text:00403133j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 5
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, [esp+8]
    push    3Ch
    call    sub_439E80
    mov     eax, 6
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_403180 proc near                    ; CODE XREF: sub_43C050+2E4p
    push    17h
    push    offset off_4FC490
    call    sub_43BC90
    retn
    sub_403180 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, [esp+4]
    push    esi
    mov     esi, [esp+0Ch]
    push    0
    lea     edx, [esp+10h]
    mov     eax, [esi+16h]
    push    eax
    push    ecx
    push    3
    push    edx
    call    sub_43F0E0
    mov     al, [eax]
    mov     ecx, esi
    push    eax
    call    sub_438B90
    mov     eax, 2
    mov     [esi+36h], eax
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+0Ch]
    xor     eax, eax
    mov     al, [esi+5]
    sub     eax, 0
    jz      short loc_403212
    dec     eax
    jz      short loc_4031EB
    mov     eax, 7
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4031EB:                             ; CODE XREF: .text:004031E0j
    test    byte ptr [esp+10h], 20h
    jz      short loc_403209
    mov     eax, [esp+8]
    push    0
    push    6
    push    eax
    call    sub_47F780
    mov     eax, 5
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403209:                             ; CODE XREF: .text:004031F0j
    mov     eax, 9
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403212:                             ; CODE XREF: .text:004031DDj
    mov     ecx, [esp+8]
    mov     eax, [ecx+86h]
    test    eax, eax
    jz      short loc_403229
    mov     eax, 7
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403229:                             ; CODE XREF: .text:0040321Ej
    push    0
    mov     ecx, esi
    call    sub_438880
    mov     edx, [esi+36h]
    lea     eax, [esi+22h]
    add     edx, 4
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_438930
    mov     dword ptr [esi+6], 0E0h
    mov     eax, 1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+0Ch]
    push    esi
    test    ecx, 10008h
    push    edi
    jz      short loc_403278
    mov     eax, 5
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403278:                             ; CODE XREF: .text:0040326Cj
    mov     esi, [esp+10h]
    mov     eax, [esi+16h]
    test    eax, eax
    jz      short loc_403299
    add     eax, 6Ah
    lea     edx, [esi+22h]
    mov     edi, [eax]
    mov     [edx], edi
    mov     edi, [eax+4]
    mov     [edx+4], edi
    mov     eax, [eax+8]
    mov     [edx+8], eax

    loc_403299:                             ; CODE XREF: .text:00403281j
    xor     eax, eax
    mov     al, [esi+5]
    sub     eax, 0
    jz      loc_403336
    dec     eax
    jz      short loc_4032B4
    mov     eax, 7
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4032B4:                             ; CODE XREF: .text:004032A8j
    test    cl, 20h
    jz      short loc_403319
    mov     edi, [esp+0Ch]
    push    0
    push    6
    push    edi
    call    sub_47F780
    push    56h
    call    sub_4B4F10
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jz      short loc_403306
    push    0
    push    0
    push    1
    push    0
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aSelfdestruct            ; "SELFDESTRUCT"
    call    sub_438760
    mov     ecx, esi
    call    sub_43A0C0
    push    eax
    push    edi
    call    sub_43ACB0
    mov     eax, 5
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403306:                             ; CODE XREF: .text:004032D5j
    xor     eax, eax
    push    eax
    push    edi
    call    sub_43ACB0
    mov     eax, 5
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403319:                             ; CODE XREF: .text:004032B7j
    test    cl, 40h
    jz      short loc_403328
    mov     eax, 8
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403328:                             ; CODE XREF: .text:0040331Cj
    mov     byte ptr [esi+5], 0
    mov     eax, 2
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403336:                             ; CODE XREF: .text:004032A1j
    mov     edi, [esp+0Ch]
    mov     eax, [edi+86h]
    test    eax, eax
    jz      short loc_40334E
    mov     eax, 7
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40334E:                             ; CODE XREF: .text:00403342j
    push    0
    mov     ecx, esi
    call    sub_438880
    mov     ecx, [edi+92h]
    mov     ax, [ecx+218h]
    cmp     ax, 10h
    jnb     short loc_403371
    mov     eax, 10h
    jmp     short loc_403376
    ; ---------------------------------------------------------------------------

    loc_403371:                             ; CODE XREF: .text:00403368j
    and     eax, 0FFFFh

    loc_403376:                             ; CODE XREF: .text:0040336Fj
    lea     edx, [esi+22h]
    push    eax
    push    edx
    mov     ecx, esi
    call    sub_438930
    push    3Ch
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    pop     edi
    or      al, 0E0h
    mov     [esi+6], eax
    mov     eax, 1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, [esp+0Ch]
    xor     eax, eax
    push    edi
    mov     al, [esi+5]
    sub     eax, 0
    jz      loc_40345C
    dec     eax
    jz      short loc_403429
    dec     eax
    jz      short loc_4033C4
    mov     eax, 7
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4033C4:                             ; CODE XREF: .text:004033B8j
    test    byte ptr [esp+14h], 0E0h
    jz      short loc_4033D9
    mov     byte ptr [esi+5], 1
    mov     eax, 6
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4033D9:                             ; CODE XREF: .text:004033C9j
    mov     edi, [esp+0Ch]
    push    edi
    call    sub_43B700
    test    eax, eax
    jz      short loc_403409
    push    0
    push    eax
    push    edi
    call    sub_43B1F0
    test    eax, eax
    jz      short loc_403409
    mov     dword ptr [esi+6], 0
    mov     byte ptr [esi+5], 1
    mov     eax, 3
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403409:                             ; CODE XREF: .text:004033E5j
                                            ; .text:004033F2j
    push    1Eh
    call    GetRandom
    add     eax, 1Eh
    mov     ecx, esi
    push    eax
    call    sub_439E80
    mov     byte ptr [esi+5], 1
    mov     eax, 4
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403429:                             ; CODE XREF: .text:004033B5j
    mov     ecx, [esp+0Ch]
    push    3
    call    sub_489800
    lea     eax, [esi+22h]
    push    0
    push    eax
    mov     ecx, esi
    call    sub_438930
    push    0Fh
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 0E0h
    mov     [esi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40345C:                             ; CODE XREF: .text:004033AEj
    mov     edi, [esp+0Ch]
    cmp     dword ptr [edi], 0
    jnz     short loc_40346F
    mov     eax, 7
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40346F:                             ; CODE XREF: .text:00403463j
    push    0
    mov     ecx, esi
    call    sub_438880
    push    esi
    push    edi
    call    sub_43A020
    push    1
    mov     ecx, esi
    call    sub_439E80
    pop     edi
    mov     eax, 1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 0Ch
    push    ebx
    mov     ebx, [esp+1Ch]
    push    ebp
    push    esi
    mov     esi, [esp+20h]
    push    edi
    test    bh, 8
    mov     ebp, [esi+36h]
    jnz     loc_403853
    mov     eax, [esi+16h]
    test    eax, eax
    jz      loc_403853
    test    ebx, 10008h
    jnz     loc_403853
    mov     eax, [esi+3Eh]
    mov     edi, [esp+20h]
    test    eax, eax
    jz      short loc_403524
    movsx   eax, word ptr [edi+74h]
    movsx   ecx, word ptr [esi+30h]
    movsx   edx, word ptr [edi+6Ch]
    sub     eax, ecx
    sub     esp, 8
    mov     [esp+2Ch], eax
    sub     esp, 8
    movsx   eax, word ptr [esi+2Eh]
    fild    dword ptr [esp+34h]
    sub     edx, eax
    fstp    qword ptr [esp+8]
    mov     [esp+34h], edx
    fild    dword ptr [esp+34h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, [esi+3Eh]
    jge     loc_403853

    loc_403524:                             ; CODE XREF: .text:004034DBj
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_403844                      ; default
    jmp     ds:off_403864[eax*4]            ; switch jump

    loc_403539:                             ; DATA XREF: .text:00403864o
    cmp     dword ptr [edi], 0              ; case 0x0
    jz      loc_403844                      ; default
    mov     ecx, [edi+92h]
    mov     eax, [ecx+241h]
    test    ah, 8
    jnz     loc_403844                      ; default
    test    dword ptr [edi+110h], 80000000h
    jz      loc_403844                      ; default
    push    0
    mov     ecx, esi
    call    sub_438880
    lea     edx, [edi+6Ah]
    lea     eax, [esi+22h]
    test    ebp, ebp
    mov     ecx, [edx]
    mov     [eax], ecx
    mov     ecx, [edx+4]
    mov     [eax+4], ecx
    mov     edx, [edx+8]
    mov     dword ptr [esi+3Ah], 0
    mov     [eax+8], edx
    jnz     loc_4037A7
    mov     ecx, edi
    call    sub_4897E0
    and     eax, 0FFh
    mov     [esi+36h], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4035B3:                             ; CODE XREF: .text:00403532j
                                            ; DATA XREF: .text:00403864o
    push    0                               ; case 0x1
    mov     ecx, esi
    call    sub_4388D0
    test    bh, 30h
    jz      short loc_4035D0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4035D0:                             ; CODE XREF: .text:004035BFj
    mov     eax, [esi+16h]
    push    ebp
    push    eax
    push    edi
    call    sub_49ABB0
    test    eax, eax
    jnz     short loc_4035EE
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4035EE:                             ; CODE XREF: .text:004035DDj
    push    0
    mov     ecx, edi
    call    sub_4898B0
    push    2
    mov     ecx, edi
    call    sub_4898B0
    mov     ecx, [esi+16h]
    push    ebp
    push    ecx
    push    edi
    call    sub_48A060
    mov     dword ptr [esi+6], 13808h
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; case 0x2

    sub_403621 proc near                    ; CODE XREF: .text:00403532j
                                            ; DATA XREF: .text:00403864o

    arg_C= dword ptr  18h
    arg_10= dword ptr  1Ch
    arg_14= dword ptr  20h
    arg_20= dword ptr  2Ch

    push    ebp
    push    edi
    call    sub_49ADF0
    mov     ebp, eax
    mov     eax, [esi+3Ah]
    cmp     eax, 8                          ; switch 9 cases
    ja      loc_403844                      ; default
    jmp     ds:off_403874[eax*4]            ; switch jump

    loc_40363D:                             ; DATA XREF: .text:00403874o
    push    ebp                             ; case 0x0
    jmp     loc_403715
    ; ---------------------------------------------------------------------------

    loc_403643:                             ; CODE XREF: sub_403621+15j
                                            ; DATA XREF: .text:00403874o
    mov     ecx, [esi+16h]                  ; case 0x1
    mov     eax, [edi+6Eh]
    sub     eax, [ecx+6Eh]
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 80000h
    jle     short loc_403681
    mov     eax, ebp
    add     ecx, 6Ah
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    push    ecx
    mov     ecx, esi
    call    sub_438930
    mov     dword ptr [esi+3Ah], 6
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403681:                             ; CODE XREF: sub_403621+35j
    add     edi, 6Ah
    add     ecx, 6Ah
    push    edi
    push    ecx
    call    sub_48A980
    push    8000h                           ; int
    mov     edi, eax
    call    GetRandom
    mov     ebx, ebp
    lea     eax, [edi+eax-4000h]
    shl     ebx, 10h
    push    ebx
    push    eax
    mov     [esp+arg_20], eax
    call    sub_4B70EF
    add     esp, 8
    mov     edi, eax
    mov     eax, [esp-8+arg_20]
    push    ebx
    push    eax
    neg     edi
    call    sub_4B7123
    mov     ecx, [esi+16h]
    add     esp, 8
    add     ecx, 6Ah
    neg     eax
    mov     edx, [ecx]
    add     edi, edx
    mov     edx, [ecx+4]
    mov     ecx, [ecx+8]
    mov     [esp-8+arg_10], edx
    add     ecx, eax
    mov     eax, ebp
    cdq
    and     edx, 3
    mov     [esp-8+arg_14], ecx
    add     eax, edx
    lea     ecx, [esp-8+arg_C]
    sar     eax, 2
    push    eax
    push    ecx
    mov     ecx, esi
    mov     [esp+arg_C], edi
    call    sub_438930
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40370D:                             ; CODE XREF: sub_403621+15j
                                            ; DATA XREF: .text:00403874o
    mov     eax, ebp                        ; case 0x5
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax

    loc_403715:                             ; CODE XREF: sub_403621+1Dj
    mov     edx, [esi+16h]
    mov     ecx, esi
    add     edx, 6Ah
    push    edx
    call    sub_438930
    mov     eax, [esi+3Ah]
    inc     eax
    mov     [esi+3Ah], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403739:                             ; CODE XREF: sub_403621+15j
                                            ; DATA XREF: .text:00403874o
    mov     eax, [esi+16h]                  ; case 0x6
    push    0
    add     eax, 6Ah
    mov     ecx, esi
    push    eax
    call    sub_438930
    mov     eax, [esi+3Ah]
    inc     eax
    mov     [esi+3Ah], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40375F:                             ; CODE XREF: sub_403621+15j
                                            ; DATA XREF: .text:00403874o
    mov     ecx, [esi+16h]                  ; case 0x7
    mov     eax, ebp
    cdq
    sub     eax, edx
    add     ecx, 6Ah
    sar     eax, 1
    push    eax
    push    ebp
    push    ecx
    mov     ecx, esi
    call    sub_438A00
    mov     eax, [esi+3Ah]
    inc     eax
    mov     [esi+3Ah], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40378C:                             ; CODE XREF: sub_403621+15j
                                            ; DATA XREF: .text:00403874o
    mov     eax, [esi+16h]                  ; case 0x8
    lea     edx, [ebp+ebp+0]
    push    ebp
    add     eax, 6Ah
    push    edx
    push    eax
    mov     ecx, esi
    call    sub_438A00
    mov     dword ptr [esi+3Ah], 0

    loc_4037A7:                             ; CODE XREF: .text:0040358Fj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4037B6:                             ; CODE XREF: .text:00403532j
                                            ; DATA XREF: .text:00403864o
    test    ebx, 40E0h                      ; case 0x3
    jz      short loc_4037D1
    mov     byte ptr [esi+5], 1
    mov     eax, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4037D1:                             ; CODE XREF: sub_403621+19Bj
    mov     ecx, [esi+16h]
    push    ebp
    push    ecx
    push    edi
    call    sub_49ABB0
    test    eax, eax
    jz      short loc_40381C
    push    0
    mov     ecx, edi
    call    sub_4898B0
    push    2
    mov     ecx, edi
    call    sub_4898B0
    mov     edx, [esi+16h]
    push    ebp
    push    edx
    push    edi
    call    sub_48A060
    push    1Eh
    mov     ecx, esi
    mov     dword ptr [esi+6], 148E8h
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40381C:                             ; CODE XREF: sub_403621+1BDj
    push    3
    mov     ecx, edi
    call    sub_489800
    push    1Eh
    mov     ecx, esi
    mov     dword ptr [esi+6], 100E8h
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403844:                             ; CODE XREF: .text:0040352Cj
                                            ; .text:0040353Cj ...
    mov     eax, 7                          ; default
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_403621 endp ; sp =  1Ch

    ; ---------------------------------------------------------------------------

    loc_403853:                             ; CODE XREF: .text:004034B5j
                                            ; .text:004034C0j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 5
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_403864 dd offset loc_403539         ; DATA XREF: .text:00403532r
    dd offset loc_4035B3                    ; jump table for switch statement
    dd offset sub_403621
    dd offset loc_4037B6
    off_403874 dd offset loc_40363D         ; DATA XREF: sub_403621+15r
    dd offset loc_403643                    ; jump table for switch statement
    dd offset loc_403643
    dd offset loc_403643
    dd offset loc_403643
    dd offset loc_40370D
    dd offset loc_403739
    dd offset loc_40375F
    dd offset loc_40378C
    align 10h
    push    ebx
    mov     ebx, [esp+10h]
    push    esi
    push    edi
    test    bh, 8
    jz      short loc_4038B7
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4038B7:                             ; CODE XREF: .text:004038AAj
    mov     esi, [esp+14h]
    xor     eax, eax
    mov     al, [esi+5]
    sub     eax, 0
    jz      loc_4039D9
    dec     eax
    jz      loc_40396B
    dec     eax
    jz      short loc_4038DE
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4038DE:                             ; CODE XREF: .text:004038D1j
    mov     edi, [esp+10h]
    push    3
    mov     ecx, edi
    call    sub_489800
    test    bh, 4
    jz      short loc_4038FF
    mov     byte ptr [esi+5], 1
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4038FF:                             ; CODE XREF: .text:004038EEj
    cmp     dword ptr [edi], 0
    jz      short loc_403960
    mov     eax, [esi+3Ah]
    test    eax, eax
    jg      short loc_403916
    mov     eax, 9
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403916:                             ; CODE XREF: .text:00403909j
    push    eax
    lea     eax, [esi+22h]
    push    eax
    mov     ecx, esi
    call    sub_438930
    mov     cl, [esi+36h]
    mov     dword ptr [esi+6], 0E0h
    push    ecx
    push    edi
    call    sub_49ADF0
    mov     ecx, eax
    mov     eax, 55555556h
    imul    ecx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    push    edx
    call    GetRandom
    mov     ecx, [esi+3Ah]
    mov     byte ptr [esi+5], 1
    sub     ecx, eax
    mov     eax, 4
    mov     [esi+3Ah], ecx
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403960:                             ; CODE XREF: .text:00403902j
    mov     eax, 9
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40396B:                             ; CODE XREF: .text:004038CAj
    cmp     dword ptr [esi+36h], 2
    jnz     short loc_40399C
    mov     edi, [esp+10h]
    push    3
    mov     ecx, edi
    call    sub_4898B0
    lea     ecx, [esi+22h]
    push    2
    push    ecx
    push    edi
    call    sub_48A0A0
    mov     dword ptr [esi+6], 1C00h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40399C:                             ; CODE XREF: .text:0040396Fj
    mov     edi, [esp+10h]
    push    0
    mov     ecx, edi
    call    sub_4898B0
    push    1
    mov     ecx, edi
    call    sub_4898B0
    lea     ebx, [esi+22h]
    push    0
    push    ebx
    push    edi
    call    sub_48A0A0
    push    1
    push    ebx
    push    edi
    call    sub_48A0A0
    mov     dword ptr [esi+6], 1C00h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4039D9:                             ; CODE XREF: .text:004038C3j
    mov     edi, [esp+10h]
    mov     edx, [edi+92h]
    mov     eax, [edx+241h]
    shr     eax, 0Bh
    test    al, 1
    jz      short loc_4039FB
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4039FB:                             ; CODE XREF: .text:004039EEj
    push    0
    mov     ecx, esi
    call    sub_438880
    mov     cl, [esi+36h]
    push    ecx
    push    edi
    call    sub_49ADF0
    mov     [esi+3Ah], eax
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     dl, [esp+0Ch]
    sub     esp, 24h
    test    dl, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      short loc_403A56
    mov     esi, [esp+38h]
    push    offset aConstructionTe          ; "Construction terminated"
    push    7
    push    esi
    call    sub_47F780
    push    esi
    call    sub_41C110
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403A56:                             ; CODE XREF: .text:00403A2Ej
    test    dl, 2
    jz      short loc_403A74
    mov     eax, [esp+38h]
    push    eax
    call    sub_41C110
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403A74:                             ; CODE XREF: .text:00403A59j
    mov     esi, [esp+3Ch]
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 4                          ; switch 5 cases
    ja      loc_403F4D                      ; default
    jmp     ds:off_403F5C[eax*4]            ; switch jump

    loc_403A8D:                             ; DATA XREF: .text:00403F5Co
    mov     ecx, [esi+36h]                  ; case 0x0
    lea     edi, [esi+22h]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    lea     edx, [eax+eax*8]
    mov     eax, [ecx+1439Bh]
    mov     ecx, edi
    add     edx, eax
    mov     eax, [ecx]
    mov     ebx, [edx+14Ah]
    mov     [esp+38h], ebx
    mov     ebp, [ecx+4]
    mov     [esp+14h], ebp
    movsx   ebp, word ptr [esp+38h]
    shl     ebp, 13h
    mov     ecx, [ecx+8]
    sub     eax, ebp
    movsx   ebp, word ptr [esp+3Ah]
    add     eax, 80000h
    mov     [esp+38h], ebx
    sar     eax, 14h
    mov     [esp+40h], ax
    movsx   eax, ax
    movsx   ebx, bx
    shl     ebp, 13h
    sub     ecx, ebp
    lea     eax, [ebx+eax*2]
    add     ecx, 80000h
    sar     ecx, 14h
    shl     eax, 13h
    mov     [esp+42h], cx
    mov     [edi], eax
    movsx   eax, word ptr [esp+3Ah]
    movsx   ecx, cx
    lea     ecx, [eax+ecx*2]
    mov     eax, [esp+40h]
    shl     ecx, 13h
    mov     [edi+8], ecx
    mov     dword ptr [esi+3Eh], 0
    mov     edx, [edx+14Ah]
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_438AD0
    mov     dword ptr [esi+6], 0E0h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403B45:                             ; CODE XREF: .text:00403A86j
                                            ; DATA XREF: .text:00403F5Co
    mov     ecx, [esi+36h]                  ; case 0x1
    mov     edi, [esp+38h]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     ebp, [eax+1439Bh]
    add     ebp, ecx
    test    dl, 40h
    jz      loc_403C59
    mov     ecx, [edi+72h]
    mov     edx, [esi+2Ah]
    mov     eax, [esi+22h]
    sub     ecx, edx
    mov     edx, [edi+6Ah]
    mov     [esp+38h], ecx
    fild    dword ptr [esp+38h]
    sub     esp, 8
    sub     edx, eax
    mov     [esp+40h], edx
    fstp    qword ptr [esp]
    fild    dword ptr [esp+40h]
    sub     esp, 8
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    movsx   ecx, word ptr [edi+7Eh]
    mov     [esp+40h], eax
    sub     esp, 8
    movsx   eax, word ptr [edi+80h]
    mov     [esp+40h], eax
    sub     esp, 8
    fild    dword ptr [esp+48h]
    mov     [esp+48h], ecx
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+48h]
    fstp    qword ptr [esp]
    call    __hypot
    fmul    ds:dbl_4FC910
    add     esp, 10h
    call    __ftol
    movsx   edx, word ptr [ebp+14Ch]
    movsx   ebx, word ptr [esp+42h]
    mov     [esp+38h], edx
    sub     ebx, eax
    fild    dword ptr [esp+38h]
    movsx   eax, word ptr [ebp+14Ah]
    sub     esp, 8
    mov     [esp+40h], eax
    fstp    qword ptr [esp]
    fild    dword ptr [esp+40h]
    sub     esp, 8
    fstp    qword ptr [esp]
    call    __hypot
    fmul    ds:dbl_4FC918
    add     esp, 10h
    call    __ftol
    mov     ecx, [edi+92h]
    xor     edx, edx
    add     ebx, eax
    mov     dx, [ecx+212h]
    cmp     ebx, edx
    jle     short loc_403C59
    push    offset aICanTReachTheC          ; "I can't reach the construction site"
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403C59:                             ; CODE XREF: .text:00403B66j
                                            ; .text:00403C3Bj
    mov     ecx, [esi+36h]
    lea     ebx, [esi+22h]
    mov     eax, ecx
    push    1
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1439Bh]
    lea     eax, [eax+eax*8]
    mov     ecx, ebx
    mov     eax, [edx+eax+14Ah]
    mov     [esp+3Ch], eax
    mov     eax, [ecx]
    mov     edx, [ecx+4]
    mov     [esp+18h], edx
    movsx   edx, word ptr [esp+3Ch]
    shl     edx, 13h
    sub     eax, edx
    mov     ecx, [ecx+8]
    add     eax, 80000h
    sar     eax, 14h
    mov     [esp+44h], ax
    movsx   eax, word ptr [esp+3Eh]
    shl     eax, 13h
    sub     ecx, eax
    add     ecx, 80000h
    sar     ecx, 14h
    mov     [esp+46h], cx
    mov     ecx, [esp+44h]
    push    ecx
    push    0
    push    ebp
    call    sub_47DB70
    test    eax, eax
    jnz     short loc_403D24
    mov     eax, [esi+3Eh]
    test    eax, eax
    jnz     short loc_403D03
    push    offset aWaitingForTarg          ; "Waiting for target area to clear"
    push    7
    push    edi
    call    sub_47F780

    loc_403CE4:                             ; CODE XREF: .text:00403D06j
    mov     ecx, [esi+3Eh]
    push    1Eh
    inc     ecx
    mov     [esi+3Eh], ecx
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403D03:                             ; CODE XREF: .text:00403CD5j
    cmp     eax, 0Ah
    jle     short loc_403CE4
    push    offset aTargetAreaWasB          ; "Target area was blocked"
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403D24:                             ; CODE XREF: .text:00403CCEj
    push    3
    mov     ecx, edi
    call    sub_4898B0
    push    ebx
    push    ebp
    call    sub_47DDC0
    mov     eax, [ebx]
    push    0
    push    1
    push    0
    mov     ecx, [ebx+4]
    sub     esp, 0Ch
    mov     edx, esp
    mov     [edx], eax
    mov     eax, [ebx+8]
    mov     [edx+4], ecx
    mov     cx, [esi+36h]
    push    ecx
    mov     [edx+8], eax
    mov     dl, [edi+0FFh]
    push    edx
    call    sub_485F50
    push    eax
    lea     ecx, [esi+12h]
    call    sub_489690
    mov     eax, [esi+16h]
    test    eax, eax
    jnz     short loc_403D98
    push    offset aUnableToCreate          ; "Unable to create any more units"
    push    7
    push    edi
    call    sub_47F780
    push    12Ch
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403D98:                             ; CODE XREF: .text:00403D6Ej
    push    offset aStartingConstr          ; "Starting construction"
    push    9
    push    edi
    call    sub_47F780
    push    edi
    call    sub_41C110
    mov     eax, [esi+16h]
    push    0
    push    0
    push    0
    push    edi
    push    eax
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aGetbuilt                ; "getbuilt"
    call    sub_438760
    call    sub_43ADC0
    mov     ecx, [esi+16h]
    lea     edx, [edi+6Ah]
    add     ecx, 6Ah
    push    ecx
    push    edx
    call    sub_48A980
    sub     ax, [edi+66h]
    push    eax
    push    esi
    push    edi
    call    sub_438590
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403DF5:                             ; CODE XREF: .text:00403A86j
                                            ; DATA XREF: .text:00403F5Co
    mov     eax, [esp+38h]                  ; case 0x2
    push    0Ah
    push    esi
    push    eax
    call    sub_438700
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403E0C:                             ; CODE XREF: .text:00403A86j
                                            ; DATA XREF: .text:00403F5Co
    mov     ebx, [esp+38h]                  ; case 0x3
    xor     ecx, ecx
    mov     eax, 88888889h
    mov     edx, [ebx+92h]
    mov     cx, [edx+1FEh]
    imul    ecx
    add     edx, ecx
    push    ecx
    sar     edx, 4
    mov     eax, edx
    mov     ecx, [esi+16h]
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+3Ch], edx
    fild    dword ptr [esp+3Ch]
    fstp    dword ptr [esp]
    push    ecx
    push    ebx
    call    sub_41BA60
    test    eax, eax
    jz      loc_403ED1
    lea     edx, [esp+10h]
    push    edx
    push    ebx
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    mov     ecx, [eax+92h]
    mov     edx, [eax+6Ah]
    mov     ebp, [eax+6Eh]
    add     ecx, 15Eh
    mov     edi, [ecx]
    add     edx, edi
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    add     edi, ebp
    mov     ebp, [eax+72h]
    mov     [esp+20h], edx
    add     ecx, ebp
    mov     [esp+24h], edi
    mov     [esp+28h], ecx
    mov     ecx, [eax+92h]
    mov     edx, [eax+6Ah]
    mov     ebp, [eax+6Eh]
    mov     edi, [ecx+16Ah]
    add     ecx, 16Ah
    add     edx, edi
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    add     edi, ebp
    mov     ebp, [eax+72h]
    add     ecx, ebp
    lea     eax, [esp+20h]
    mov     [esp+34h], ecx
    lea     ecx, [esp+14h]
    push    eax
    push    ecx
    mov     [esp+34h], edx
    mov     [esp+38h], edi
    call    sub_4720D0

    loc_403ED1:                             ; CODE XREF: .text:00403E4Aj
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+38A47h]
    add     eax, 12Ch
    mov     [ebx+0B0h], eax
    mov     ecx, [esi+16h]
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FC920
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_403F1E
    push    1
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 0Ah
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403F1E:                             ; CODE XREF: .text:00403EFCj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403F2D:                             ; CODE XREF: .text:00403A86j
                                            ; DATA XREF: .text:00403F5Co
    mov     edx, [esp+38h]                  ; case 0x4
    push    offset aBuildingComple          ; "Building complete"
    push    8
    push    edx
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403F4D:                             ; CODE XREF: .text:00403A80j
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    off_403F5C dd offset loc_403A8D         ; DATA XREF: .text:00403A86r
    dd offset loc_403B45                    ; jump table for switch statement
    dd offset loc_403DF5
    dd offset loc_403E0C
    dd offset loc_403F2D
    ; ---------------------------------------------------------------------------
    mov     cl, [esp+0Ch]
    sub     esp, 24h
    test    cl, 2
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      short loc_403F99
    mov     eax, [esp+38h]
    push    eax
    call    sub_41C110
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403F99:                             ; CODE XREF: .text:00403F7Ej
    mov     edi, [esp+3Ch]
    mov     esi, [edi+16h]
    test    esi, esi
    jnz     short loc_403FC4
    mov     ecx, [esp+38h]
    push    offset aConstructionTe          ; "Construction terminated"
    push    7
    push    ecx
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_403FC4:                             ; CODE XREF: .text:00403FA2j
    xor     eax, eax
    mov     al, [edi+5]
    cmp     eax, 4                          ; switch 5 cases
    ja      loc_40424B                      ; default
    jmp     ds:off_40425C[eax*4]            ; switch jump

    loc_403FD9:                             ; DATA XREF: .text:0040425Co
    mov     eax, [esp+38h]                  ; case 0x0
    cmp     dword ptr [eax], 0
    jz      loc_40424B                      ; default
    mov     ebx, [eax+92h]
    test    byte ptr [ebx+241h], 40h
    jz      loc_40424B                      ; default
    mov     eax, [esi+92h]
    movsx   edx, word ptr [eax+14Ah]
    movsx   eax, word ptr [eax+14Ch]
    mov     [esp+38h], edx
    fild    dword ptr [esp+38h]
    mov     [esp+38h], eax
    fild    dword ptr [esp+38h]
    fld     st(1)
    fmul    st, st(2)
    fadd    st, st(1)
    fadd    st, st(1)
    fsqrt
    fmul    ds:dbl_4FC928
    call    __ftol
    cdq
    fstp    st
    sub     eax, edx
    xor     ecx, ecx
    mov     cx, [ebx+212h]
    add     esi, 6Ah
    sar     eax, 1
    add     ecx, eax
    push    eax
    push    ecx
    push    esi
    mov     ecx, edi
    fstp    st
    call    sub_438A00
    mov     dword ptr [edi+6], 0E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404069:                             ; CODE XREF: .text:00403FD2j
                                            ; DATA XREF: .text:0040425Co
    test    cl, 40h                         ; case 0x1
    jz      short loc_40408E
    mov     edx, [esp+38h]
    push    offset aICanTGetThere           ; "I can't get there"
    push    7
    push    edx
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40408E:                             ; CODE XREF: .text:0040406Cj
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FC920
    fnstsw  ax
    test    ah, 40h
    jz      short loc_4040B0
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4040B0:                             ; CODE XREF: .text:0040409Fj
    mov     esi, [esp+38h]
    push    3
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [edi+16h]
    lea     ecx, [esi+6Ah]
    add     eax, 6Ah
    push    eax
    push    ecx
    call    sub_48A980
    sub     ax, [esi+66h]
    push    eax
    push    edi
    push    esi
    call    sub_438590
    push    esi
    call    sub_41C110
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4040EE:                             ; CODE XREF: .text:00403FD2j
                                            ; DATA XREF: .text:0040425Co
    mov     edx, [esp+38h]                  ; case 0x2
    push    0Ah
    push    edi
    push    edx
    call    sub_438700
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404105:                             ; CODE XREF: .text:00403FD2j
                                            ; DATA XREF: .text:0040425Co
    mov     ebx, [esp+38h]                  ; case 0x3
    xor     ecx, ecx
    mov     eax, [ebx+92h]
    mov     cx, [eax+1FEh]
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 4
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    push    ecx
    mov     [esp+3Ch], edx
    fild    dword ptr [esp+3Ch]
    fstp    dword ptr [esp]
    push    esi
    push    ebx
    call    sub_41BA60
    test    eax, eax
    jz      loc_4041C7
    lea     edx, [esp+10h]
    push    edx
    push    ebx
    call    sub_43E400
    mov     eax, [edi+16h]
    push    6
    mov     ecx, [eax+92h]
    mov     edx, [eax+6Ah]
    mov     ebp, [eax+6Eh]
    add     ecx, 15Eh
    mov     esi, [ecx]
    add     edx, esi
    mov     esi, [ecx+4]
    mov     ecx, [ecx+8]
    add     esi, ebp
    mov     ebp, [eax+72h]
    mov     [esp+20h], edx
    add     ecx, ebp
    mov     [esp+24h], esi
    mov     [esp+28h], ecx
    mov     ecx, [eax+92h]
    mov     edx, [eax+6Ah]
    mov     ebp, [eax+6Eh]
    mov     esi, [ecx+16Ah]
    add     ecx, 16Ah
    add     edx, esi
    mov     esi, [ecx+4]
    mov     ecx, [ecx+8]
    add     esi, ebp
    mov     ebp, [eax+72h]
    add     ecx, ebp
    lea     eax, [esp+20h]
    mov     [esp+34h], ecx
    lea     ecx, [esp+14h]
    push    eax
    push    ecx
    mov     [esp+34h], edx
    mov     [esp+38h], esi
    call    sub_4720D0

    loc_4041C7:                             ; CODE XREF: .text:00404140j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+38A47h]
    add     eax, 12Ch
    mov     [ebx+0B0h], eax
    mov     ecx, [edi+16h]
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FC920
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_404214
    push    1
    mov     ecx, edi
    call    sub_439E80
    mov     eax, [edi+6]
    or      al, 0Ah
    mov     [edi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404214:                             ; CODE XREF: .text:004041F2j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404223:                             ; CODE XREF: .text:00403FD2j
                                            ; DATA XREF: .text:0040425Co
    mov     edx, [esp+38h]                  ; case 0x4
    push    offset aBuildingComple          ; "Building complete"
    push    8
    push    edx
    call    sub_47F780
    mov     eax, [edi+6]
    or      al, 2
    mov     [edi+6], eax
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40424B:                             ; CODE XREF: .text:00403FCCj
                                            ; .text:00403FE0j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_40425C dd offset loc_403FD9         ; DATA XREF: .text:00403FD2r
    dd offset loc_404069                    ; jump table for switch statement
    dd offset loc_4040EE
    dd offset loc_404105
    dd offset loc_404223
    ; ---------------------------------------------------------------------------
    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+38h]
    push    edi
    mov     eax, [esi+16h]
    test    eax, eax
    jz      loc_4046F2
    mov     edx, [esp+40h]
    test    edx, 10008h
    jnz     loc_4046F2
    xor     ecx, ecx
    mov     cl, [esi+5]
    cmp     ecx, 5                          ; switch 6 cases
    ja      loc_4046E3                      ; default
    jmp     ds:off_404714[ecx*4]            ; switch jump

    loc_4042AB:                             ; DATA XREF: .text:00404714o
    mov     ebx, [esp+38h]                  ; case 0x0
    cmp     dword ptr [ebx], 0
    jnz     short loc_4042C3
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4042C3:                             ; CODE XREF: .text:004042B2j
    mov     ecx, [ebx+92h]
    mov     edx, [ecx+245h]
    test    dh, 10h
    jnz     short loc_4042E3
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4042E3:                             ; CODE XREF: .text:004042D2j
    mov     edx, [eax+92h]
    mov     ecx, [edx+245h]
    shr     ecx, 0Ch
    test    cl, 1
    jz      short loc_404313
    push    offset aThatUnitCannot          ; "That unit cannot be captured"
    push    7
    push    ebx
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404313:                             ; CODE XREF: .text:004042F5j
    fld     dword ptr [eax+104h]
    fcomp   ds:flt_4FC920
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_404342
    push    offset aThatUnitIsAClo          ; "That unit is a cloud of vapor and canno"...
    push    7
    push    ebx
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404342:                             ; CODE XREF: .text:00404324j
    push    offset aCapturing               ; "Capturing"
    mov     ecx, esi
    call    sub_438880
    mov     eax, [esi+16h]
    mov     edx, [eax+92h]
    mov     eax, edx
    fld     dword ptr [edx+186h]
    fmul    ds:flt_4FC930
    fmul    ds:flt_4FC934
    fld     dword ptr [eax+18Ah]
    fmul    ds:flt_4FC930
    fmul    ds:flt_4FC938
    fsubp   st(1), st
    fsub    ds:flt_4FC93C
    call    __ftol
    cmp     eax, 708h
    mov     [esi+3Ah], eax
    mov     edx, eax
    jl      short loc_40439B
    mov     edx, 708h

    loc_40439B:                             ; CODE XREF: .text:00404394j
    mov     [esi+3Ah], edx
    mov     ecx, [esi+16h]
    push    3
    mov     edi, [ecx+92h]
    movsx   eax, word ptr [ecx+108h]
    mov     ebp, [edi+1FAh]
    mov     ecx, edi
    add     eax, ebp
    mov     ecx, [ecx+1FAh]
    imul    eax, edx
    shl     ecx, 1
    xor     edx, edx
    div     ecx
    xor     ecx, ecx
    mov     edi, eax
    mov     eax, 66666667h
    mov     [esi+3Ah], edi
    mov     edx, [esi+16h]
    mov     cx, [edx+0B8h]
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    lea     eax, [edx+eax+0Ah]
    imul    eax, edi
    lea     ecx, [eax+eax*4]
    mov     eax, 51EB851Fh
    shl     ecx, 1
    imul    ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, ebx
    mov     [esi+3Ah], edx
    call    sub_4898B0
    mov     eax, [esi+16h]
    mov     ecx, esi
    mov     edx, [eax+7Eh]
    mov     eax, [eax+76h]
    push    edx
    push    eax
    call    sub_438AD0
    mov     dword ptr [esi+6], 100E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404437:                             ; CODE XREF: .text:004042A4j
                                            ; DATA XREF: .text:00404714o
    test    dl, 40h                         ; case 0x1
    jnz     loc_404703
    mov     edi, [esp+38h]
    mov     ebx, [eax+72h]
    sub     esp, 8
    mov     ecx, [edi+72h]
    mov     edx, [edi+6Ah]
    sub     ecx, ebx
    lea     ebp, [edi+6Ah]
    mov     [esp+40h], ecx
    mov     ecx, [eax+6Ah]
    fild    dword ptr [esp+40h]
    sub     edx, ecx
    sub     esp, 8
    mov     [esp+48h], edx
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+48h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    movsx   ecx, word ptr [edi+7Eh]
    mov     [esp+3Ch], eax
    sub     esp, 8
    movsx   eax, word ptr [edi+80h]
    mov     [esp+40h], eax
    sub     esp, 8
    fild    dword ptr [esp+48h]
    mov     [esp+48h], ecx
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+48h]
    fstp    qword ptr [esp]
    call    __hypot
    fmul    ds:dbl_4FC910
    add     esp, 10h
    call    __ftol
    movsx   ebx, word ptr [esp+3Eh]
    sub     ebx, eax
    mov     eax, [esi+16h]
    sub     esp, 8
    movsx   edx, word ptr [eax+80h]
    movsx   eax, word ptr [eax+7Eh]
    mov     [esp+40h], edx
    sub     esp, 8
    fild    dword ptr [esp+48h]
    mov     [esp+48h], eax
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+48h]
    fstp    qword ptr [esp]
    call    __hypot
    fmul    ds:dbl_4FC918
    add     esp, 10h
    call    __ftol
    mov     ecx, [edi+92h]
    xor     edx, edx
    add     ebx, eax
    mov     dx, [ecx+212h]
    cmp     ebx, edx
    jle     short loc_404526
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404526:                             ; CODE XREF: .text:00404518j
    mov     eax, [esi+16h]
    add     eax, 6Ah
    push    eax
    push    ebp
    call    sub_48A980
    sub     ax, [edi+66h]
    push    eax
    push    esi
    push    edi
    call    sub_438590
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40454E:                             ; CODE XREF: .text:004042A4j
                                            ; DATA XREF: .text:00404714o
    mov     ecx, [esp+38h]                  ; case 0x2
    push    10008h
    push    esi
    push    ecx
    call    sub_438700
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404568:                             ; CODE XREF: .text:004042A4j
                                            ; DATA XREF: .text:00404714o
    mov     edx, [esp+38h]                  ; case 0x3
    push    0
    push    0Bh
    push    edx
    call    sub_47F780
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404585:                             ; CODE XREF: .text:004042A4j
                                            ; DATA XREF: .text:00404714o
    cmp     dword ptr [eax], 0              ; case 0x4
    jz      short loc_4045B3
    test    byte ptr [eax+110h], 0Ch
    jz      short loc_4045B3
    mov     eax, [esp+38h]
    push    esi
    push    eax
    call    sub_4385F0
    push    1Eh
    mov     ecx, esi
    call    sub_439E80
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4045B3:                             ; CODE XREF: .text:00404588j
                                            ; .text:00404591j
    mov     ecx, [esi+36h]
    mov     eax, [esi+3Ah]
    cmp     ecx, eax
    jl      short loc_4045CC
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4045CC:                             ; CODE XREF: .text:004045BBj
    mov     eax, [esi+0Eh]
    lea     edx, [esp+10h]
    push    edx
    push    eax
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    lea     ecx, [eax+6Ah]
    mov     ebx, ecx
    mov     edx, [ebx]
    mov     [esp+2Ch], edx
    mov     edi, [ebx+4]
    mov     [esp+30h], edi
    mov     ebx, [ebx+8]
    mov     [esp+34h], ebx
    mov     ebp, [ecx]
    mov     [esp+20h], ebp
    mov     ebp, [ecx+4]
    mov     [esp+24h], ebp
    mov     ecx, [ecx+8]
    mov     ebp, [esp+20h]
    mov     [esp+28h], ecx
    mov     ecx, [eax+92h]
    mov     ecx, [ecx+15Eh]
    add     ebp, ecx
    mov     [esp+20h], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [esp+28h]
    mov     ecx, [ecx+166h]
    add     ebp, ecx
    mov     [esp+28h], ebp
    mov     ecx, [eax+92h]
    add     edx, [ecx+16Ah]
    mov     [esp+2Ch], edx
    mov     edx, [eax+92h]
    mov     ebp, [edx+172h]
    lea     edx, [esp+20h]
    add     ebx, ebp
    mov     [esp+34h], ebx
    mov     eax, [eax+92h]
    mov     ecx, [eax+16Eh]
    add     edi, ecx
    lea     ecx, [esp+14h]
    push    ecx
    push    edx
    mov     [esp+38h], edi
    call    sub_472200
    mov     eax, TAdynmemStructPtr
    push    2
    mov     edx, [esp+3Ch]
    mov     ecx, [eax+38A47h]
    add     ecx, 384h
    mov     [edx+0B0h], ecx
    mov     ecx, [esi+36h]
    add     ecx, 2
    mov     [esi+36h], ecx
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4046B7:                             ; CODE XREF: .text:004042A4j
                                            ; DATA XREF: .text:00404714o
    mov     esi, [esp+38h]                  ; case 0x5
    push    0
    mov     ecx, [esi+96h]
    push    ecx
    push    eax
    call    sub_488570
    push    0
    push    10h
    push    esi
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4046E3:                             ; CODE XREF: .text:0040429Ej
    mov     eax, 7                          ; default
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4046F2:                             ; CODE XREF: .text:00404280j
                                            ; .text:00404290j
    mov     edx, [esp+38h]
    push    offset aCaptureFailed           ; "Capture failed"
    push    7
    push    edx
    call    sub_47F780

    loc_404703:                             ; CODE XREF: .text:0040443Aj
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 8
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_404714 dd offset loc_4042AB         ; DATA XREF: .text:004042A4r
    dd offset loc_404437                    ; jump table for switch statement
    dd offset loc_40454E
    dd offset loc_404568
    dd offset loc_404585
    dd offset loc_4046B7
    align 8
    sub     esp, 2Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+40h]
    push    edi
    mov     ecx, [esi+16h]
    test    ecx, ecx
    jz      loc_404A9F
    mov     edx, [esp+48h]
    test    edx, 10008h
    jnz     loc_404A9F
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 5                          ; switch 6 cases
    ja      loc_404A90                      ; default
    jmp     ds:off_404AB0[eax*4]            ; switch jump

    loc_40476B:                             ; DATA XREF: .text:00404AB0o
    mov     edi, [esp+40h]                  ; case 0x0
    cmp     dword ptr [edi], 0
    jz      short loc_4047DE
    mov     eax, [edi+92h]
    mov     edx, [eax+245h]
    test    dh, 4
    jz      short loc_4047DE
    push    ecx
    mov     ecx, edi
    call    sub_489960
    test    eax, eax
    jnz     short loc_4047BA
    push    offset aThatUnitCann_0          ; "That unit cannot be reclaimed"
    push    7
    push    edi
    call    sub_47F780
    push    offset aReclamationFai          ; "Reclamation failed"
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4047BA:                             ; CODE XREF: .text:0040478Fj
    push    offset aReclaiming              ; "Reclaiming"
    mov     ecx, esi
    call    sub_438880
    push    3
    mov     ecx, edi
    call    sub_4898B0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4047DE:                             ; CODE XREF: .text:00404772j
                                            ; .text:00404783j
    push    offset aReclamationFai          ; "Reclamation failed"
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4047FA:                             ; CODE XREF: .text:00404764j
                                            ; DATA XREF: .text:00404AB0o
    test    dl, 20h                         ; case 0x1
    jz      short loc_40480E
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40480E:                             ; CODE XREF: .text:004047FDj
    mov     edx, [ecx+7Eh]
    mov     eax, [ecx+76h]
    push    edx
    push    eax
    mov     ecx, esi
    call    sub_438AD0
    mov     ebp, [esi+6]
    push    0Fh
    or      ebp, 100E8h
    mov     ecx, esi
    mov     [esi+6], ebp
    call    sub_439E80
    mov     ecx, [esi+16h]
    push    0Fh
    mov     edx, [esp+44h]
    push    ecx
    push    edx
    call    sub_438650
    mov     [esi+36h], eax
    mov     dword ptr [esi+3Ah], 0
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40485B:                             ; CODE XREF: .text:00404764j
                                            ; DATA XREF: .text:00404AB0o
    test    dl, 40h                         ; case 0x2
    jz      short loc_40486F
    mov     eax, 9
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40486F:                             ; CODE XREF: .text:0040485Ej
    mov     edi, [esp+40h]
    add     ecx, 6Ah
    push    ecx
    lea     eax, [edi+6Ah]
    push    eax
    call    sub_48A980
    sub     ax, [edi+66h]
    push    eax
    push    esi
    push    edi
    call    sub_438590
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40489B:                             ; CODE XREF: .text:00404764j
                                            ; DATA XREF: .text:00404AB0o
    mov     ecx, [esp+40h]                  ; case 0x3
    push    10008h
    push    esi
    push    ecx
    call    sub_438700
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4048B5:                             ; CODE XREF: .text:00404764j
                                            ; DATA XREF: .text:00404AB0o
    mov     edx, [esp+40h]                  ; case 0x4
    push    0
    push    0Bh
    push    edx
    call    sub_47F780
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4048D2:                             ; CODE XREF: .text:00404764j
                                            ; DATA XREF: .text:00404AB0o
    mov     ebx, [esp+40h]                  ; case 0x5
    mov     edx, [ecx+6Ah]
    mov     edi, [ecx+72h]
    mov     ecx, [ecx+92h]
    mov     eax, [ebx+6Ah]
    mov     ebp, [ebx+72h]
    sub     eax, edx
    mov     edx, [ebx+92h]
    sub     ebp, edi
    xor     edi, edi
    mov     di, [edx+212h]
    movsx   edx, word ptr [ecx+184h]
    add     edi, edx
    cdq
    mov     ecx, eax
    mov     eax, ebp
    mov     [esp+14h], edx
    cdq
    mov     ebp, eax
    mov     eax, [esp+14h]
    push    eax
    push    ecx
    push    eax
    push    ecx
    mov     [esp+2Ch], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ecx, eax
    mov     eax, [esp+1Ch]
    push    eax
    push    ebp
    push    eax
    push    ebp
    mov     [esp+50h], ecx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edx, edi
    mov     ecx, [esp+40h]
    imul    edx, edi
    add     ecx, eax
    cmp     ecx, edx
    jg      loc_404A74
    mov     eax, [esi+16h]
    mov     ecx, ebx
    push    eax
    call    sub_489960
    test    eax, eax
    jz      loc_404A74
    cmp     dword ptr [esi+3Ah], 0Fh
    jl      short loc_40498D
    mov     eax, [esi+36h]
    mov     ecx, [esi+16h]
    push    0
    push    5
    push    eax
    push    ecx
    push    ebx
    call    sub_489BB0
    mov     dword ptr [esi+3Ah], 0

    loc_40498D:                             ; CODE XREF: .text:00404972j
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+18h]
    push    ecx
    mov     eax, [edx+38A47h]
    add     eax, 384h
    mov     [ebx+0B0h], eax
    mov     edx, [esi+0Eh]
    push    edx
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    lea     ecx, [eax+6Ah]
    mov     ebx, ecx
    mov     edx, [ebx]
    mov     [esp+34h], edx
    mov     edi, [ebx+4]
    mov     [esp+38h], edi
    mov     ebx, [ebx+8]
    mov     [esp+3Ch], ebx
    mov     ebp, [ecx]
    mov     [esp+28h], ebp
    mov     ebp, [ecx+4]
    mov     [esp+2Ch], ebp
    mov     ecx, [ecx+8]
    mov     ebp, [esp+28h]
    mov     [esp+30h], ecx
    mov     ecx, [eax+92h]
    mov     ecx, [ecx+15Eh]
    add     ebp, ecx
    mov     [esp+28h], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [esp+30h]
    mov     ecx, [ecx+166h]
    add     ebp, ecx
    mov     [esp+30h], ebp
    mov     ecx, [eax+92h]
    add     edx, [ecx+16Ah]
    mov     [esp+34h], edx
    mov     edx, [eax+92h]
    mov     ebp, [edx+172h]
    lea     edx, [esp+28h]
    add     ebx, ebp
    mov     [esp+3Ch], ebx
    mov     eax, [eax+92h]
    mov     ecx, [eax+16Eh]
    add     edi, ecx
    lea     ecx, [esp+1Ch]
    push    ecx
    push    edx
    mov     [esp+40h], edi
    call    sub_472200
    push    2
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+3Ah]
    add     eax, 2
    mov     [esi+3Ah], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404A74:                             ; CODE XREF: .text:00404955j
                                            ; .text:00404968j
    push    0Fh
    mov     ecx, esi
    call    sub_439E80
    push    esi
    push    ebx
    call    sub_4385F0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404A90:                             ; CODE XREF: .text:0040475Ej
    mov     eax, 7                          ; default
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404A9F:                             ; CODE XREF: .text:00404740j
                                            ; .text:00404750j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 5
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_404AB0 dd offset loc_40476B         ; DATA XREF: .text:00404764r
    dd offset loc_4047FA                    ; jump table for switch statement
    dd offset loc_40485B
    dd offset loc_40489B
    dd offset loc_4048B5
    dd offset loc_4048D2
    align 10h
    sub     esp, 28h
    lea     eax, [esp+0]
    lea     ecx, [esp+30h]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+40h]
    push    eax
    push    ecx
    lea     ebp, [edi+22h]
    push    ebp
    call    sub_421DA0
    cmp     ax, 0FFFFh
    jnz     short loc_404B14
    mov     edx, [esp+3Ch]
    push    offset aReclamationFai          ; "Reclamation failed"
    push    7
    push    edx
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404B14:                             ; CODE XREF: .text:00404AF2j
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFFFh
    shl     eax, 8
    add     eax, [ecx+1426Fh]
    mov     esi, eax
    test    byte ptr [esi+0FEh], 80h
    jnz     short loc_404B42
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404B42:                             ; CODE XREF: .text:00404B31j
    xor     eax, eax
    mov     al, [edi+5]
    cmp     eax, 5
    ja      loc_404D7A
    mov     ebx, [esp+3Ch]
    jmp     ds:off_404D8C[eax*4]

    loc_404B5B:                             ; DATA XREF: .text:00404D8Co
    mov     eax, [esp+3Ch]
    cmp     dword ptr [eax], 0
    jz      loc_404D7A
    mov     edx, [eax+92h]
    mov     eax, [edx+245h]
    test    ah, 4
    jz      loc_404D7A
    mov     eax, [esp+10h]
    mov     ecx, [esp+40h]
    push    eax
    push    ecx
    mov     ecx, edi
    call    sub_438AD0
    mov     dword ptr [edi+6], 0E0h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404BA4:                             ; CODE XREF: .text:00404B54j
                                            ; DATA XREF: .text:00404D90o
    test    byte ptr [esp+44h], 40h
    jz      short loc_404BBA
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404BBA:                             ; CODE XREF: .text:00404BA9j
    fld     dword ptr [esi+0ECh]
    fadd    dword ptr [esi+0F0h]
    fmul    ds:flt_4FC940
    fsubr   ds:flt_4FC944
    call    __ftol
    movsx   edx, word ptr [esp+40h]
    mov     [edi+36h], eax
    movsx   eax, word ptr [esp+10h]
    lea     ecx, [eax+edx*2]
    movsx   edx, word ptr [esp+42h]
    movsx   eax, word ptr [esp+12h]
    shl     ecx, 13h
    mov     [esp+14h], ecx
    lea     ecx, [eax+edx*2]
    xor     edx, edx
    mov     dl, [esi+0FAh]
    shl     ecx, 13h
    push    edx
    mov     [esp+20h], ecx
    call    GetRandom
    mov     esi, eax
    lea     eax, [esp+14h]
    push    eax
    call    sub_485070
    add     esi, eax
    lea     ecx, [esp+14h]
    shl     esi, 10h
    mov     [esp+18h], esi
    mov     esi, [esp+3Ch]
    push    ecx
    lea     edx, [esi+6Ah]
    push    edx
    call    sub_48A980
    sub     ax, [esi+66h]
    push    eax
    push    edi
    push    esi
    call    sub_438590
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404C52:                             ; CODE XREF: .text:00404B54j
                                            ; DATA XREF: .text:00404D94o
    mov     eax, [esp+3Ch]
    push    0
    push    edi
    push    eax
    call    sub_438700
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404C69:                             ; CODE XREF: .text:00404B54j
                                            ; DATA XREF: .text:00404D98o
    push    0
    push    0Bh
    push    ebx
    call    sub_47F780

    loc_404C73:                             ; CODE XREF: .text:00404B54j
                                            ; DATA XREF: .text:00404D9Co
    push    2
    mov     ecx, edi
    call    sub_439E80
    mov     ecx, [edi+36h]
    add     ecx, 0FFFFFFFEh
    mov     eax, ecx
    mov     [edi+36h], ecx
    test    eax, eax
    jg      short loc_404C9A
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404C9A:                             ; CODE XREF: .text:00404C89j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+38A47h]
    add     edx, 12Ch
    mov     [ebx+0B0h], edx
    mov     eax, [edi+36h]
    cmp     eax, 0Fh
    jle     loc_404D51
    lea     eax, [esp+14h]
    push    eax
    push    ebx
    call    sub_43E400
    lea     eax, [esp+20h]
    movsx   ecx, word ptr [esp+40h]
    movsx   edx, word ptr [esp+42h]
    shl     ecx, 14h
    shl     edx, 14h
    push    eax
    mov     [esp+24h], ecx
    mov     [esp+2Ch], edx
    call    sub_485070
    movsx   edi, word ptr [esi+94h]
    mov     ecx, [esp+20h]
    mov     edx, [esp+28h]
    shl     edi, 14h
    mov     [esp+2Ch], ecx
    add     edi, ecx
    movsx   ecx, word ptr [esi+96h]
    shl     ecx, 14h
    add     edx, ecx
    push    6
    mov     [esp+38h], edx
    xor     edx, edx
    mov     dl, [esi+0FAh]
    lea     ecx, [esp+24h]
    shl     eax, 10h
    shl     edx, 10h
    mov     [esp+28h], eax
    add     eax, edx
    mov     [esp+34h], eax
    lea     eax, [esp+18h]
    push    eax
    push    ecx
    mov     [esp+38h], edi
    call    sub_472200
    lea     edx, [esp+14h]
    push    6
    lea     eax, [esp+24h]
    push    edx
    push    eax
    call    sub_472200

    loc_404D51:                             ; CODE XREF: .text:00404CB8j
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404D60:                             ; CODE XREF: .text:00404B54j
                                            ; DATA XREF: .text:00404DA0o
    mov     ecx, [esp+3Ch]
    push    ebp
    push    ecx
    call    sub_4237D0
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404D7A:                             ; CODE XREF: .text:00404B4Aj
                                            ; .text:00404B62j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_404D8C dd offset loc_404B5B         ; DATA XREF: .text:00404B54r
    dd offset loc_404BA4
    dd offset loc_404C52
    dd offset loc_404C69
    dd offset loc_404C73
    dd offset loc_404D60
    align 10h
    mov     eax, TAdynmemStructPtr
    sub     esp, 68h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+7Ch]
    push    edi
    mov     edi, [eax+1426Fh]
    mov     al, [esi+5]
    add     edi, 0FFFF00h
    cmp     al, 5
    ja      short loc_404E27
    lea     ecx, [esp+10h]
    lea     edx, [esp+80h]
    push    ecx
    lea     eax, [esi+22h]
    push    edx
    push    eax
    call    sub_421DA0
    cmp     ax, 0FFFFh
    jnz     short loc_404DF9
    push    offset aResurrectionFa          ; "Resurrection failed"
    jmp     loc_404F74
    ; ---------------------------------------------------------------------------

    loc_404DF9:                             ; CODE XREF: .text:00404DEDj
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFFFh
    shl     eax, 8
    add     eax, [edx+1426Fh]
    mov     edi, eax
    test    byte ptr [edi+0FEh], 80h
    jnz     short loc_404E27
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404E27:                             ; CODE XREF: .text:00404DD1j
                                            ; .text:00404E16j
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 6                          ; switch 7 cases
    ja      loc_4052C6                      ; default
    jmp     ds:off_4052D8[eax*4]            ; switch jump

    loc_404E3C:                             ; DATA XREF: .text:004052D8o
    mov     eax, [esp+7Ch]                  ; case 0x0
    cmp     dword ptr [eax], 0
    jz      loc_4052C6                      ; default
    mov     eax, [eax+92h]
    mov     ecx, [eax+245h]
    test    ch, 8
    jz      loc_4052C6                      ; default
    mov     ecx, [esp+10h]
    mov     edx, [esp+80h]
    push    ecx
    push    edx
    mov     ecx, esi
    call    sub_438AD0
    mov     dword ptr [esi+6], 0E0h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404E88:                             ; CODE XREF: .text:00404E35j
                                            ; DATA XREF: .text:004052D8o
    test    byte ptr [esp+84h], 40h         ; case 0x1
    jz      short loc_404EA1
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404EA1:                             ; CODE XREF: .text:00404E90j
    movsx   eax, word ptr [esp+80h]
    movsx   ecx, word ptr [esp+10h]
    lea     edx, [ecx+eax*2]
    movsx   eax, word ptr [esp+82h]
    movsx   ecx, word ptr [esp+12h]
    shl     edx, 13h
    mov     [esp+14h], edx
    lea     edx, [ecx+eax*2]
    xor     eax, eax
    mov     al, [edi+0FAh]
    shl     edx, 13h
    push    eax
    mov     [esp+20h], edx
    call    GetRandom
    lea     ecx, [esp+14h]
    mov     edi, eax
    push    ecx
    call    sub_485070
    add     edi, eax
    lea     edx, [esp+14h]
    shl     edi, 10h
    mov     [esp+18h], edi
    mov     edi, [esp+7Ch]
    push    edx
    lea     eax, [edi+6Ah]
    push    eax
    call    sub_48A980
    sub     ax, [edi+66h]
    push    eax
    push    esi
    push    edi
    call    sub_438590
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404F1F:                             ; CODE XREF: .text:00404E35j
                                            ; DATA XREF: .text:004052D8o
    mov     ecx, [esp+7Ch]                  ; case 0x2
    push    0
    push    esi
    push    ecx
    call    sub_438700
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404F36:                             ; CODE XREF: .text:00404E35j
                                            ; DATA XREF: .text:004052D8o
    push    40h                             ; case 0x3
    lea     edx, [esp+3Ch]
    push    edi
    push    edx
    call    ds:lstrcpynA
    xor     eax, eax
    mov     cl, 5Fh

    loc_404F48:                             ; CODE XREF: .text:00404F52j
    cmp     [esp+eax+38h], cl
    jz      short loc_404F56
    inc     eax
    cmp     eax, 40h
    jl      short loc_404F48
    jmp     short loc_404F5B
    ; ---------------------------------------------------------------------------

    loc_404F56:                             ; CODE XREF: .text:00404F4Cj
    mov     byte ptr [esp+eax+38h], 0

    loc_404F5B:                             ; CODE XREF: .text:00404F54j
    lea     eax, [esp+38h]
    push    eax
    call    sub_488B10
    and     eax, 0FFFFh
    mov     [esi+36h], eax
    jnz     short loc_404F92
    push    offset aRessurectionFa          ; "Ressurection failed"

    loc_404F74:                             ; CODE XREF: .text:00404DF4j
    mov     ecx, [esp+80h]
    push    7
    push    ecx
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_404F92:                             ; CODE XREF: .text:00404F6Dj
    mov     ecx, eax
    mov     edi, [esp+7Ch]
    shl     ecx, 6
    add     ecx, eax
    mov     eax, TAdynmemStructPtr
    lea     edx, [ecx+ecx*8]
    mov     ecx, [eax+1439Bh]
    mov     eax, 88888889h
    fild    dword ptr [ecx+edx+1EAh]
    mov     edx, [edi+92h]
    xor     ecx, ecx
    mov     cx, [edx+1FEh]
    imul    ecx
    fmul    ds:dbl_4FC948
    add     edx, ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+7Ch], edx
    fild    dword ptr [esp+7Ch]
    fdivp   st(1), st
    call    __ftol
    push    0
    push    0Bh
    push    edi
    mov     [esi+3Ah], eax
    call    sub_47F780
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405005:                             ; CODE XREF: .text:00404E35j
                                            ; DATA XREF: .text:004052D8o
    mov     eax, [esi+3Ah]                  ; case 0x4
    test    eax, eax
    lea     ecx, [eax-1]
    mov     [esi+3Ah], ecx
    jz      loc_405234
    mov     ebx, [esp+7Ch]
    lea     edx, [esp+14h]
    push    edx
    push    ebx
    call    sub_43E400
    lea     edx, [esp+20h]
    movsx   eax, word ptr [esp+80h]
    movsx   ecx, word ptr [esp+82h]
    shl     eax, 14h
    shl     ecx, 14h
    push    edx
    mov     [esp+24h], eax
    mov     [esp+2Ch], ecx
    call    sub_485070
    movsx   ebp, word ptr [edi+94h]
    mov     ecx, [esp+20h]
    mov     edx, [esp+28h]
    shl     ebp, 14h
    mov     [esp+2Ch], ecx
    add     ebp, ecx
    movsx   ecx, word ptr [edi+96h]
    shl     ecx, 14h
    add     edx, ecx
    push    6
    mov     [esp+38h], edx
    xor     edx, edx
    mov     dl, [edi+0FAh]
    lea     ecx, [esp+18h]
    shl     eax, 10h
    shl     edx, 10h
    mov     [esp+28h], eax
    add     eax, edx
    mov     [esp+34h], eax
    lea     eax, [esp+24h]
    push    eax
    push    ecx
    mov     [esp+38h], ebp
    call    sub_4720D0
    mov     edx, TAdynmemStructPtr
    push    1
    mov     ecx, esi
    mov     eax, [edx+38A47h]
    add     eax, 12Ch
    mov     [ebx+0B0h], eax
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4050D1:                             ; CODE XREF: .text:00404E35j
                                            ; DATA XREF: .text:004052D8o
    push    0                               ; case 0x5
    push    1
    lea     ebx, [esi+22h]
    push    0
    sub     esp, 0Ch
    mov     ecx, ebx
    mov     edx, esp
    mov     ebp, [esp+94h]
    mov     eax, [ecx]
    mov     [edx], eax
    mov     eax, [ecx+4]
    mov     [edx+4], eax
    mov     al, [ebp+0FFh]
    mov     ecx, [ecx+8]
    mov     [edx+8], ecx
    mov     dx, [esi+36h]
    push    edx
    push    eax
    call    sub_485F50
    push    eax
    lea     ecx, [esi+12h]
    call    sub_489690
    mov     eax, [esi+16h]
    test    eax, eax
    jnz     short loc_405141
    push    offset aUnableToCreate          ; "Unable to create any more units"
    push    7
    push    ebp
    call    sub_47F780
    push    12Ch
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405141:                             ; CODE XREF: .text:00405117j
    push    ebx
    call    sub_4815F0
    mov     edi, eax
    push    edi
    call    sub_421E60
    cmp     ax, 0FFFBh
    jb      short loc_405164
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405164:                             ; CODE XREF: .text:00405153j
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     ax, [edi+0Ah]
    mov     edx, [ecx+1420Bh]
    lea     eax, [eax+eax*2]
    shl     eax, 4
    add     eax, edx
    jz      short loc_405195
    mov     edx, [esi+16h]
    add     eax, 20h
    add     edx, 64h
    mov     ecx, [eax]
    mov     [edx], ecx
    mov     ax, [eax+4]
    mov     [edx+4], ax

    loc_405195:                             ; CODE XREF: .text:0040517Ej
    push    0
    push    ebx
    call    sub_4815A0
    push    eax
    call    sub_4246B0
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_405215
    mov     ebx, TAdynmemStructPtr
    mov     eax, 4EC4EC4Fh
    push    6
    sub     edi, [ebx+14287h]
    imul    edi
    sar     edx, 2
    mov     eax, edx
    mov     edi, [ebx+14233h]
    shr     eax, 1Fh
    add     edx, eax
    mov     byte ptr [esp+18h], 0Fh
    mov     ecx, edx
    mov     byte ptr [esp+19h], 0FFh
    mov     eax, ecx
    cdq
    idiv    edi
    mov     eax, ecx
    lea     ecx, [esp+18h]
    push    ecx
    mov     bx, dx
    cdq
    idiv    edi
    mov     edx, [ebp+96h]
    mov     [esp+1Eh], bx
    mov     [esp+20h], ax
    mov     eax, [edx+4]
    push    eax
    call    sub_451DF0

    loc_405215:                             ; CODE XREF: .text:004051B7j
    mov     ecx, [esi+16h]
    push    ebp
    mov     dword ptr [ecx+104h], 0
    mov     edx, [esi+16h]
    mov     word ptr [edx+108h], 1
    call    sub_41C110

    loc_405234:                             ; CODE XREF: .text:00405010j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405243:                             ; CODE XREF: .text:00404E35j
                                            ; DATA XREF: .text:004052D8o
    mov     edi, [esp+7Ch]                  ; case 0x6
    push    offset aResurrectionCo          ; "Resurrection complete"
    push    8
    push    edi
    call    sub_47F780
    mov     eax, [esi+16h]
    push    0
    push    eax
    push    edi
    lea     ecx, [esp+88h]
    push    8
    push    ecx
    call    sub_43F0E0
    mov     al, [esp+7Ch]
    test    al, al
    jz      short loc_4052B7
    push    56h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4052AE
    mov     edx, [esi+16h]
    mov     ecx, [esp+7Ch]
    push    0
    push    0
    push    0
    push    0
    push    edx
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    push    eax
    push    edi
    call    sub_43ACB0
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4052AE:                             ; CODE XREF: .text:0040527Ej
    xor     eax, eax
    push    eax
    push    edi
    call    sub_43ACB0

    loc_4052B7:                             ; CODE XREF: .text:00405270j
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4052C6:                             ; CODE XREF: .text:00404E2Fj
                                            ; .text:00404E43j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_4052D8 dd offset loc_404E3C         ; DATA XREF: .text:00404E35r
    dd offset loc_404E88                    ; jump table for switch statement
    dd offset loc_404F1F
    dd offset loc_404F36
    dd offset loc_405005
    dd offset loc_4050D1
    dd offset loc_405243
    align 10h
    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+38h]
    push    edi
    mov     eax, [esi+16h]
    test    eax, eax
    jnz     short loc_405332
    mov     eax, [esp+38h]
    push    offset aRepairsUnsucce          ; "Repairs unsuccessful."
    push    7
    push    eax
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405332:                             ; CODE XREF: .text:00405310j
    mov     eax, [esi+3Eh]
    mov     edi, [esp+38h]
    test    eax, eax
    jz      short loc_40538F
    movsx   ecx, word ptr [esi+30h]
    movsx   edx, word ptr [edi+74h]
    movsx   eax, word ptr [esi+2Eh]
    sub     edx, ecx
    sub     esp, 8
    movsx   ecx, word ptr [edi+6Ch]
    mov     [esp+40h], edx
    sub     ecx, eax
    fild    dword ptr [esp+40h]
    mov     [esp+40h], ecx
    sub     esp, 8
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+48h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, [esi+3Eh]
    jl      short loc_40538F
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40538F:                             ; CODE XREF: .text:0040533Bj
                                            ; .text:0040537Ej
    mov     eax, [esi+16h]
    mov     ecx, [eax+110h]
    mov     edx, ecx
    and     edx, 3
    cmp     dl, 1
    jz      short loc_4053BE
    push    offset aRepairsUnsucce          ; "Repairs unsuccessful."
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4053BE:                             ; CODE XREF: .text:004053A0j
    xor     edx, edx
    mov     dl, [esi+5]
    cmp     edx, 4                          ; switch 5 cases
    ja      loc_405712                      ; default
    jmp     ds:off_405724[edx*4]            ; switch jump

    loc_4053D3:                             ; DATA XREF: .text:00405724o
    cmp     dword ptr [edi], 0              ; case 0x0
    jz      loc_405712                      ; default
    mov     ecx, [edi+92h]
    test    byte ptr [ecx+241h], 40h
    jz      loc_405712                      ; default
    fld     dword ptr [eax+104h]
    fcomp   ds:flt_4FC920
    fnstsw  ax
    test    ah, 40h
    jz      loc_405712                      ; default
    push    offset aRepairing               ; "Repairing"
    mov     ecx, esi
    call    sub_438880
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405421:                             ; CODE XREF: .text:004053CCj
                                            ; DATA XREF: .text:00405724o
    test    byte ptr [esp+40h], 40h         ; case 0x1
    jz      short loc_405437
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405437:                             ; CODE XREF: .text:00405426j
    mov     edx, [edi+72h]
    mov     ecx, [eax+72h]
    sub     edx, ecx
    mov     ecx, [edi+6Ah]
    lea     ebp, [edi+6Ah]
    mov     [esp+38h], edx
    fild    dword ptr [esp+38h]
    mov     edx, [eax+6Ah]
    sub     esp, 8
    sub     ecx, edx
    fstp    qword ptr [esp]
    mov     [esp+40h], ecx
    sub     esp, 8
    fild    dword ptr [esp+48h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    movsx   edx, word ptr [edi+80h]
    mov     [esp+38h], edx
    mov     [esp+3Ch], eax
    fild    dword ptr [esp+38h]
    movsx   eax, word ptr [edi+7Eh]
    sub     esp, 8
    mov     [esp+40h], eax
    fstp    qword ptr [esp]
    fild    dword ptr [esp+40h]
    sub     esp, 8
    fstp    qword ptr [esp]
    call    __hypot
    fmul    ds:dbl_4FC910
    add     esp, 10h
    call    __ftol
    movsx   ebx, word ptr [esp+3Eh]
    sub     ebx, eax
    mov     eax, [esi+16h]
    sub     esp, 8
    movsx   ecx, word ptr [eax+80h]
    movsx   edx, word ptr [eax+7Eh]
    mov     [esp+40h], ecx
    sub     esp, 8
    fild    dword ptr [esp+48h]
    mov     [esp+48h], edx
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+48h]
    fstp    qword ptr [esp]
    call    __hypot
    fmul    ds:dbl_4FC918
    add     esp, 10h
    call    __ftol
    add     ebx, eax
    mov     eax, [edi+92h]
    xor     ecx, ecx
    mov     cx, [eax+212h]
    cmp     ebx, ecx
    jle     short loc_405546
    mov     eax, [esi+16h]
    mov     ecx, esi
    mov     edx, [eax+7Eh]
    mov     eax, [eax+76h]
    push    edx
    push    eax
    call    sub_438AD0
    push    1Eh
    call    GetRandom
    add     eax, 1Eh
    mov     ecx, esi
    push    eax
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 0E8h
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405546:                             ; CODE XREF: .text:00405509j
    push    3
    mov     ecx, edi
    call    sub_4898B0
    mov     ecx, [esi+16h]
    add     ecx, 6Ah
    push    ecx
    push    ebp
    call    sub_48A980
    sub     ax, [edi+66h]
    push    eax
    push    esi
    push    edi
    call    sub_438590
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405577:                             ; CODE XREF: .text:004053CCj
                                            ; DATA XREF: .text:00405724o
    push    8                               ; case 0x2
    push    esi
    push    edi
    call    sub_438700
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40558A:                             ; CODE XREF: .text:004053CCj
                                            ; DATA XREF: .text:00405724o
    movsx   edx, word ptr [eax+108h]        ; case 0x3
    mov     eax, [eax+92h]
    cmp     edx, [eax+1FAh]
    jb      short loc_4055AE
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4055AE:                             ; CODE XREF: .text:0040559Dj
    test    cl, 0Ch
    jz      short loc_4055CF
    push    esi
    push    edi
    call    sub_4385F0
    push    0Fh
    mov     ecx, esi
    call    sub_439E80
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4055CF:                             ; CODE XREF: .text:004055B1j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [edi+92h]
    mov     edx, [ecx+38A47h]
    xor     ecx, ecx
    add     edx, 96h
    mov     [edi+0B0h], edx
    mov     cx, [eax+1FEh]
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 4
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    push    ecx
    mov     [esp+3Ch], edx
    mov     edx, [esi+16h]
    fild    dword ptr [esp+3Ch]
    fstp    dword ptr [esp]
    push    edx
    push    edi
    call    sub_41BD10
    test    eax, eax
    jz      loc_4056D6
    mov     ecx, [esi+0Eh]
    lea     eax, [esp+10h]
    push    eax
    push    ecx
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    lea     ecx, [eax+6Ah]
    mov     ebx, ecx
    mov     edx, [ebx]
    mov     [esp+2Ch], edx
    mov     edi, [ebx+4]
    mov     [esp+30h], edi
    mov     ebx, [ebx+8]
    mov     [esp+34h], ebx
    mov     ebp, [ecx]
    mov     [esp+20h], ebp
    mov     ebp, [ecx+4]
    mov     [esp+24h], ebp
    mov     ecx, [ecx+8]
    mov     ebp, [esp+20h]
    mov     [esp+28h], ecx
    mov     ecx, [eax+92h]
    mov     ecx, [ecx+15Eh]
    add     ebp, ecx
    mov     [esp+20h], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [esp+28h]
    mov     ecx, [ecx+166h]
    add     ebp, ecx
    mov     [esp+28h], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [ecx+16Ah]
    lea     ecx, [esp+20h]
    add     edx, ebp
    push    ecx
    mov     [esp+30h], edx
    mov     edx, [eax+92h]
    mov     ebp, [edx+172h]
    lea     edx, [esp+18h]
    add     ebx, ebp
    push    edx
    mov     [esp+3Ch], ebx
    mov     eax, [eax+92h]
    add     edi, [eax+16Eh]
    mov     [esp+38h], edi
    call    sub_4720D0

    loc_4056D6:                             ; CODE XREF: .text:00405621j
    push    1
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 8
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4056F6:                             ; CODE XREF: .text:004053CCj
                                            ; DATA XREF: .text:00405724o
    push    offset aUnitRepaired            ; case 0x4
    push    0Ah
    push    edi
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405712:                             ; CODE XREF: .text:004053C6j
                                            ; .text:004053D6j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_405724 dd offset loc_4053D3         ; DATA XREF: .text:004053CCr
    dd offset loc_405421                    ; jump table for switch statement
    dd offset loc_405577
    dd offset loc_40558A
    dd offset loc_4056F6
    align 10h
    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+38h]
    push    edi
    mov     edx, [esi+16h]
    test    edx, edx
    jnz     short loc_405772
    mov     eax, [esp+38h]
    push    offset aRepairsUnsucce          ; "Repairs unsuccessful."
    push    7
    push    eax
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405772:                             ; CODE XREF: .text:00405750j
    xor     eax, eax
    mov     al, [esi+5]
    sub     eax, 0
    jz      loc_40591B
    dec     eax
    jz      short loc_4057B5
    dec     eax
    jz      short loc_405795
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405795:                             ; CODE XREF: .text:00405784j
    mov     ecx, [esp+38h]
    push    offset aUnitRepaired            ; "Unit repaired"
    push    0Ah
    push    ecx
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4057B5:                             ; CODE XREF: .text:00405781j
    mov     ecx, [edx+92h]
    movsx   eax, word ptr [edx+108h]
    cmp     eax, [ecx+1FAh]
    jb      short loc_4057D9
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4057D9:                             ; CODE XREF: .text:004057C8j
    test    byte ptr [edx+110h], 0Ch
    jz      short loc_4057F1
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4057F1:                             ; CODE XREF: .text:004057E0j
    mov     edx, TAdynmemStructPtr
    mov     edi, [esp+38h]
    xor     ecx, ecx
    mov     eax, [edx+38A47h]
    mov     edx, [edi+92h]
    add     eax, 96h
    mov     [edi+0B0h], eax
    mov     cx, [edx+1FEh]
    mov     eax, 88888889h
    push    ecx
    imul    ecx
    add     edx, ecx
    mov     ecx, [esi+16h]
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+3Ch], edx
    fild    dword ptr [esp+3Ch]
    fstp    dword ptr [esp]
    push    ecx
    push    edi
    call    sub_41BD10
    test    eax, eax
    jz      loc_4058FB
    mov     eax, [esi+0Eh]
    lea     edx, [esp+10h]
    push    edx
    push    eax
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    lea     ecx, [eax+6Ah]
    mov     ebx, ecx
    mov     edx, [ebx]
    mov     [esp+2Ch], edx
    mov     edi, [ebx+4]
    mov     [esp+30h], edi
    mov     ebx, [ebx+8]
    mov     [esp+34h], ebx
    mov     ebp, [ecx]
    mov     [esp+20h], ebp
    mov     ebp, [ecx+4]
    mov     [esp+24h], ebp
    mov     ecx, [ecx+8]
    mov     ebp, [esp+20h]
    mov     [esp+28h], ecx
    mov     ecx, [eax+92h]
    mov     ecx, [ecx+15Eh]
    add     ebp, ecx
    mov     [esp+20h], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [esp+28h]
    mov     ecx, [ecx+166h]
    add     ebp, ecx
    mov     [esp+28h], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [ecx+16Ah]
    lea     ecx, [esp+20h]
    add     edx, ebp
    push    ecx
    mov     [esp+30h], edx
    mov     edx, [eax+92h]
    mov     ebp, [edx+172h]
    lea     edx, [esp+18h]
    add     ebx, ebp
    push    edx
    mov     [esp+3Ch], ebx
    mov     eax, [eax+92h]
    add     edi, [eax+16Eh]
    mov     [esp+38h], edi
    call    sub_4720D0

    loc_4058FB:                             ; CODE XREF: .text:00405846j
    push    1
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 8
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40591B:                             ; CODE XREF: .text:0040577Aj
    mov     ecx, [esp+38h]
    mov     eax, [ecx+92h]
    test    byte ptr [eax+241h], 40h
    jnz     short loc_40593D
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40593D:                             ; CODE XREF: .text:0040592Cj
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FC920
    fnstsw  ax
    test    ah, 40h
    jz      short loc_40596F
    test    byte ptr [ecx+10Eh], 1
    jz      short loc_40596F
    push    3
    call    sub_4898B0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40596F:                             ; CODE XREF: .text:0040594Ej
                                            ; .text:00405957j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 8
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 30h
    xor     eax, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+48h]
    xor     ebx, ebx
    mov     al, [edi+5]
    sub     eax, ebx
    jz      loc_405D59
    dec     eax
    jz      short loc_4059AC
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4059AC:                             ; CODE XREF: .text:0040599Bj
    test    byte ptr [esp+4Ch], 0E0h
    jz      short loc_4059C2
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4059C2:                             ; CODE XREF: .text:004059B1j
    lea     eax, [edi+22h]
    push    10h
    push    eax
    mov     ecx, edi
    call    sub_438930
    push    3Ch
    mov     ecx, edi
    call    sub_439E80
    mov     eax, [edi+6]
    mov     esi, [esp+44h]
    or      al, 0E0h
    mov     [edi+6], eax
    mov     ecx, [esi+96h]
    fld     dword ptr [ecx+8Ch]
    fld     dword ptr [ecx+0A4h]
    fmul    ds:dbl_4FC950
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 41h
    jz      loc_405B18
    mov     dl, [esp+44h]
    mov     eax, [esi+92h]
    mov     [esp+20h], dl
    mov     [esp+24h], ebx
    mov     [esp+28h], ebx
    mov     [esp+2Ch], ebx
    movsx   eax, word ptr [eax+202h]
    lea     edx, [esp+30h]
    mov     [esp+34h], ecx
    shl     eax, 10h
    push    edx
    push    eax
    lea     eax, [esi+6Ah]
    lea     ecx, [esp+28h]
    push    eax
    mov     [esp+44h], ecx
    mov     [esp+48h], esi
    mov     dword ptr [esp+3Ch], offset off_4FC960
    call    sub_47E890
    mov     ebp, [esp+28h]
    mov     eax, [esp+24h]
    cmp     eax, ebx
    jnz     short loc_405A64
    xor     ecx, ecx
    jmp     short loc_405A6B
    ; ---------------------------------------------------------------------------

    loc_405A64:                             ; CODE XREF: .text:00405A5Ej
    mov     ecx, ebp
    sub     ecx, eax
    sar     ecx, 2

    loc_405A6B:                             ; CODE XREF: .text:00405A62j
    xor     edx, edx
    cmp     ecx, ebx
    setz    dl
    test    dl, dl
    jnz     loc_405B0F
    cmp     eax, ebx
    jnz     short loc_405A82
    xor     ecx, ecx
    jmp     short loc_405A89
    ; ---------------------------------------------------------------------------

    loc_405A82:                             ; CODE XREF: .text:00405A7Cj
    sub     ebp, eax
    sar     ebp, 2
    mov     ecx, ebp

    loc_405A89:                             ; CODE XREF: .text:00405A80j
    push    ecx
    mov     ebp, eax
    call    GetRandom
    mov     ebp, [ebp+eax*4+0]
    mov     edx, [esi+96h]
    xor     ecx, ecx
    mov     eax, [ebp+96h]
    mov     cl, [eax+146h]
    cmp     [ecx+edx+108h], bl
    jz      short loc_405B0B
    push    ebx
    push    ebp
    push    esi
    lea     eax, [esp+50h]
    push    8
    push    eax
    call    sub_43F0E0
    cmp     [esp+44h], bl
    jz      short loc_405B0B
    push    ebx
    push    ebp
    push    esi
    call    sub_43B400
    test    eax, eax
    jz      short loc_405AEF
    mov     ecx, [esp+24h]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405AEF:                             ; CODE XREF: .text:00405AD1j
    mov     edx, [esp+24h]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405B0B:                             ; CODE XREF: .text:00405AB0j
                                            ; .text:00405AC5j
    mov     eax, [esp+24h]

    loc_405B0F:                             ; CODE XREF: .text:00405A74j
    push    eax
    call    sub_4B4F20
    add     esp, 4

    loc_405B18:                             ; CODE XREF: .text:00405A03j
    mov     ecx, [esi+96h]
    fld     dword ptr [ecx+8Ch]
    fld     dword ptr [ecx+0A4h]
    fmul    ds:dbl_4FC950
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 41h
    jz      short loc_405B5A
    fld     dword ptr [ecx+0A8h]
    fmul    ds:dbl_4FC950
    fld     dword ptr [ecx+98h]
    fxch    st(1)
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 41h
    jnz     loc_405D4A

    loc_405B5A:                             ; CODE XREF: .text:00405B37j
    mov     edx, [esi+92h]
    lea     eax, [esp+14h]
    lea     ecx, [esp+20h]
    mov     [esp+48h], eax
    mov     [esp+44h], ecx
    lea     ecx, [esp+4Ch]
    movsx   eax, word ptr [edx+202h]
    lea     edx, [esp+44h]
    push    ecx
    push    edx
    lea     ecx, [esp+18h]
    lea     edx, [esp+50h]
    push    ecx
    shl     eax, 10h
    push    edx
    push    eax
    lea     eax, [esi+6Ah]
    push    eax
    call    sub_47EA40
    test    eax, eax
    jz      loc_405D4A
    mov     edx, [esp+44h]
    cmp     edx, ebx
    jz      short loc_405C25
    mov     eax, [esi+96h]
    fld     dword ptr [eax+0A8h]
    fmul    ds:dbl_4FC950
    fld     dword ptr [eax+98h]
    fxch    st(1)
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_405C25
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    cmp     ebp, ebx
    jz      short loc_405C02
    mov     ecx, [esp+44h]
    push    ebx
    push    ebx
    push    ebx
    push    ecx
    push    ebx
    push    ecx
    mov     ecx, esp
    push    offset aReclaim                 ; "RECLAIM"
    call    sub_438760
    mov     ecx, ebp
    call    sub_43A0C0
    jmp     short loc_405C04
    ; ---------------------------------------------------------------------------

    loc_405C02:                             ; CODE XREF: .text:00405BE1j
    xor     eax, eax

    loc_405C04:                             ; CODE XREF: .text:00405C00j
    push    eax
    push    esi
    call    sub_43ACB0
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     [edi+6], ebx
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405C25:                             ; CODE XREF: .text:00405BA6j
                                            ; .text:00405BC9j
    mov     ecx, [esp+48h]
    cmp     ecx, ebx
    jz      short loc_405C79
    mov     eax, [esi+96h]
    fld     dword ptr [eax+0A4h]
    fmul    ds:dbl_4FC950
    fld     dword ptr [eax+8Ch]
    fxch    st(1)
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_405C79
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    cmp     ebp, ebx
    jz      loc_405D2F
    mov     edx, [esp+48h]
    push    ebx
    push    ebx
    push    ebx
    push    edx
    jmp     loc_405D01
    ; ---------------------------------------------------------------------------

    loc_405C79:                             ; CODE XREF: .text:00405C2Bj
                                            ; .text:00405C4Ej
    cmp     edx, ebx
    jz      short loc_405CBC
    mov     eax, [esi+96h]
    fld     dword ptr [eax+98h]
    fadd    dword ptr [esp+4Ch]
    fcomp   dword ptr [eax+0A8h]
    fnstsw  ax
    test    ah, 41h
    jz      short loc_405CBC
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    cmp     ebp, ebx
    jz      short loc_405D2F
    mov     eax, [esp+44h]
    push    ebx
    push    ebx
    push    ebx
    push    eax
    jmp     short loc_405D01
    ; ---------------------------------------------------------------------------

    loc_405CBC:                             ; CODE XREF: .text:00405C7Bj
                                            ; .text:00405C98j
    cmp     ecx, ebx
    jz      loc_405D4A
    mov     eax, [esi+96h]
    fld     dword ptr [eax+8Ch]
    fadd    dword ptr [esp+10h]
    fcomp   dword ptr [eax+0A4h]
    fnstsw  ax
    test    ah, 41h
    jz      short loc_405D4A
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    cmp     ebp, ebx
    jz      short loc_405D2F
    mov     ecx, [esp+48h]
    push    ebx
    push    ebx
    push    ebx
    push    ecx

    loc_405D01:                             ; CODE XREF: .text:00405C74j
                                            ; .text:00405CBAj
    push    ebx
    push    ecx
    mov     ecx, esp
    push    offset aReclaim                 ; "RECLAIM"
    call    sub_438760
    mov     ecx, ebp
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43ACB0
    mov     [edi+6], ebx
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405D2F:                             ; CODE XREF: .text:00405C66j
                                            ; .text:00405CB0j ...
    xor     eax, eax
    push    eax
    push    esi
    call    sub_43ACB0
    mov     [edi+6], ebx
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405D4A:                             ; CODE XREF: .text:00405B54j
                                            ; .text:00405B9Aj ...
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405D59:                             ; CODE XREF: .text:00405994j
    mov     eax, [edi+16h]
    cmp     eax, ebx
    jz      short loc_405D76
    add     eax, 6Ah
    lea     edx, [edi+22h]
    mov     ecx, [eax]
    mov     [edx], ecx
    mov     ecx, [eax+4]
    mov     [edx+4], ecx
    mov     eax, [eax+8]
    mov     [edx+8], eax

    loc_405D76:                             ; CODE XREF: .text:00405D5Ej
    mov     ecx, [esp+44h]
    push    edi
    push    ecx
    call    sub_43A020
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 30h
    retn    0Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_405D90 proc near                    ; DATA XREF: .rdata:004FC960o

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    mov     eax, [ecx+0Ch]
    sub     esp, 8
    cmp     edx, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      loc_405FC8
    mov     eax, [edx+96h]
    mov     esi, [ecx+4]
    xor     ebx, ebx
    mov     bl, [eax+146h]
    mov     al, [ebx+esi+108h]
    test    al, al
    jz      loc_405FC8
    mov     eax, [edx+110h]
    and     eax, 3
    cmp     al, 1
    jnz     loc_405FC8
    mov     eax, [edx+92h]
    movsx   edi, word ptr [edx+108h]
    cmp     edi, [eax+1FAh]
    jb      short loc_405E03
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FC920
    fnstsw  ax
    test    ah, 40h
    jnz     loc_405FC8

    loc_405E03:                             ; CODE XREF: sub_405D90+5Aj
    mov     al, [edx+0F4h]
    mov     bl, [esi+146h]
    cmp     al, bl
    jnz     short loc_405E20
    cmp     byte ptr [edx+0F5h], 5
    jz      loc_405FC8

    loc_405E20:                             ; CODE XREF: sub_405D90+81j
    mov     esi, [ecx+8]
    mov     eax, [esi+8]
    mov     ecx, [esi+0Ch]
    sub     ecx, eax
    mov     edi, eax
    sar     ecx, 2
    cmp     ecx, 1
    jnb     loc_405F2E
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_405E44
    xor     ecx, ecx
    jmp     short loc_405E4B
    ; ---------------------------------------------------------------------------

    loc_405E44:                             ; CODE XREF: sub_405D90+AEj
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2

    loc_405E4B:                             ; CODE XREF: sub_405D90+B2j
    cmp     ecx, 1
    jbe     short loc_405E61
    test    edx, edx
    jnz     short loc_405E58
    xor     ecx, ecx
    jmp     short loc_405E66
    ; ---------------------------------------------------------------------------

    loc_405E58:                             ; CODE XREF: sub_405D90+C2j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_405E66
    ; ---------------------------------------------------------------------------

    loc_405E61:                             ; CODE XREF: sub_405D90+BEj
    mov     ecx, 1

    loc_405E66:                             ; CODE XREF: sub_405D90+C6j
                                            ; sub_405D90+CFj
    test    edx, edx
    jnz     short loc_405E6E
    xor     eax, eax
    jmp     short loc_405E73
    ; ---------------------------------------------------------------------------

    loc_405E6E:                             ; CODE XREF: sub_405D90+D8j
    sub     eax, edx
    sar     eax, 2

    loc_405E73:                             ; CODE XREF: sub_405D90+DCj
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_405E7F
    xor     eax, eax

    loc_405E7F:                             ; CODE XREF: sub_405D90+EBj
    lea     edx, ds:0[eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    mov     ebx, [esi+4]
    add     esp, 4
    cmp     ebx, edi
    mov     [esp+18h+var_8], eax
    mov     ebp, eax
    jz      short loc_405EAD

    loc_405E9C:                             ; CODE XREF: sub_405D90+11Bj
    push    ebx
    push    ebp
    call    sub_406C70
    add     ebx, 4
    add     ebp, 4
    cmp     ebx, edi
    jnz     short loc_405E9C

    loc_405EAD:                             ; CODE XREF: sub_405D90+10Aj
    lea     eax, [esp+18h+arg_0]
    mov     ecx, esi
    push    eax
    push    1
    push    ebp
    call    sub_406C40
    mov     ecx, [esi+8]
    add     ebp, 4
    push    ebp
    push    ecx
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     edx, [esi+8]
    mov     eax, [esi+4]
    push    edx
    push    eax
    mov     ecx, esi
    call    nullsub_1
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+1Ch+var_8]
    mov     ecx, [esp+1Ch+var_4]
    add     esp, 4
    lea     eax, [edx+ecx*4]
    mov     [esi+0Ch], eax
    mov     eax, [esi+4]
    test    eax, eax
    jnz     short loc_405F12
    xor     ecx, ecx
    mov     [esi+4], edx
    lea     ecx, [edx+ecx*4+4]
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_405F12:                             ; CODE XREF: sub_405D90+16Aj
    mov     ecx, [esi+8]
    mov     [esi+4], edx
    sub     ecx, eax
    sar     ecx, 2
    lea     ecx, [edx+ecx*4+4]
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_405F2E:                             ; CODE XREF: sub_405D90+A3j
    mov     edx, eax
    sub     edx, edi
    sar     edx, 2
    cmp     edx, 1
    jnb     short loc_405F88
    lea     ecx, [edi+4]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+8]
    lea     edx, [esp+18h+arg_0]
    mov     ecx, eax
    push    edx
    sub     ecx, edi
    mov     edx, 1
    sar     ecx, 2
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_406C40
    mov     eax, [esi+8]
    cmp     edi, eax
    jz      short loc_405FC4

    loc_405F6D:                             ; CODE XREF: sub_405D90+1E8j
    mov     ecx, [esp+18h+arg_0]
    mov     [edi], ecx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_405F6D
    add     dword ptr [esi+8], 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_405F88:                             ; CODE XREF: sub_405D90+1A8j
    push    eax
    push    eax
    add     eax, 0FFFFFFFCh
    mov     ecx, esi
    push    eax
    call    sub_406C10
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_405FAE

    loc_405F9F:                             ; CODE XREF: sub_405D90+21Cj
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_405F9F

    loc_405FAE:                             ; CODE XREF: sub_405D90+20Dj
    lea     ecx, [edi+4]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_405FC4

    loc_405FB7:                             ; CODE XREF: sub_405D90+232j
    mov     edx, [esp+18h+arg_0]
    mov     [eax], edx
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_405FB7

    loc_405FC4:                             ; CODE XREF: sub_405D90+1DBj
                                            ; sub_405D90+225j
    add     dword ptr [esi+8], 4

    loc_405FC8:                             ; CODE XREF: sub_405D90+10j
                                            ; sub_405D90+30j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_405D90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_405FE0 proc near                    ; DATA XREF: .rdata:004FC6ECo

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_4]
    xor     eax, eax
    push    edi
    mov     al, [esi+5]
    sub     eax, 0
    jz      short loc_406049
    dec     eax
    jz      short loc_405FFD
    mov     eax, 7
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_405FFD:                             ; CODE XREF: sub_405FE0+11j
    mov     edi, [esp+4+arg_0]
    push    edi
    call    sub_43B700
    test    eax, eax
    jz      short loc_406022
    push    0
    push    eax
    push    edi
    call    sub_43B1F0
    test    eax, eax
    jz      short loc_406022
    mov     eax, 5
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406022:                             ; CODE XREF: sub_405FE0+29j
                                            ; sub_405FE0+36j
    mov     eax, [esi+6]
    push    1Eh                             ; int
    or      eax, 10000h
    mov     [esi+6], eax
    call    GetRandom
    add     eax, 1Eh
    mov     ecx, esi
    push    eax
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406049:                             ; CODE XREF: sub_405FE0+Ej
    mov     ecx, [esp+4+arg_0]
    cmp     dword ptr [ecx], 0
    jnz     short loc_40605C
    mov     eax, 7
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40605C:                             ; CODE XREF: sub_405FE0+70j
    push    3
    call    sub_489800
    mov     ecx, [esi+6]
    push    1
    or      ecx, 10000h
    mov     [esi+6], ecx
    mov     ecx, esi
    call    sub_439E80
    pop     edi
    mov     eax, 1
    pop     esi
    retn    0Ch
    sub_405FE0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+0Ch]
    xor     eax, eax
    push    edi
    mov     al, [esi+5]
    sub     eax, 0
    jz      loc_406151
    dec     eax
    jz      short loc_4060B1
    mov     eax, 7
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4060B1:                             ; CODE XREF: .text:004060A5j
    mov     edi, [esp+0Ch]
    push    edi
    call    sub_43B700
    test    eax, eax
    jz      short loc_40612A
    mov     eax, [eax+110h]
    and     eax, 3
    cmp     al, 1
    jnz     short loc_40612A
    test    dword ptr [edi+110h], 300000h
    jz      short loc_40612A
    push    56h
    call    sub_4B4F10
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jz      short loc_406117
    push    0
    push    0
    push    1
    push    0
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aSelfdestruct            ; "SELFDESTRUCT"
    call    sub_438760
    mov     ecx, esi
    call    sub_43A0C0
    push    eax
    push    edi
    call    sub_43ACB0
    mov     eax, 5
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406117:                             ; CODE XREF: .text:004060E6j
    xor     eax, eax
    push    eax
    push    edi
    call    sub_43ACB0
    mov     eax, 5
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40612A:                             ; CODE XREF: .text:004060BDj
                                            ; .text:004060CAj ...
    mov     eax, [esi+6]
    push    1Eh
    or      eax, 10000h
    mov     [esi+6], eax
    call    GetRandom
    add     eax, 1Eh
    mov     ecx, esi
    push    eax
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406151:                             ; CODE XREF: .text:0040609Ej
    mov     ecx, [esp+0Ch]
    test    dword ptr [ecx+110h], 20000000h
    jnz     short loc_40616B
    mov     eax, 7
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40616B:                             ; CODE XREF: .text:0040615Fj
    push    3
    call    sub_489800
    mov     ecx, [esi+6]
    push    1
    or      ecx, 10000h
    mov     [esi+6], ecx
    mov     ecx, esi
    call    sub_439E80
    pop     edi
    mov     eax, 1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 14h
    xor     eax, eax
    push    esi
    mov     esi, [esp+20h]
    push    edi
    mov     al, [esi+5]
    sub     eax, 0
    jz      short loc_4061FE
    dec     eax
    jz      short loc_4061C3
    mov     eax, 7
    pop     edi
    pop     esi
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4061C3:                             ; CODE XREF: .text:004061B4j
    test    byte ptr [esp+28h], 20h
    jz      short loc_4061D7
    mov     eax, 5
    pop     edi
    pop     esi
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4061D7:                             ; CODE XREF: .text:004061C8j
    mov     eax, [esi+4Ah]
    test    eax, eax
    jz      short loc_4061EB
    mov     eax, 5
    pop     edi
    pop     esi
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4061EB:                             ; CODE XREF: .text:004061DCj
    push    1Eh
    mov     ecx, esi
    call    sub_439E80
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4061FE:                             ; CODE XREF: .text:004061B1j
    mov     ecx, [esp+20h]
    cmp     dword ptr [ecx], 0
    jnz     short loc_406214
    mov     eax, 7
    pop     edi
    pop     esi
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406214:                             ; CODE XREF: .text:00406205j
    mov     edx, [ecx+92h]
    mov     eax, [edx+241h]
    shr     eax, 0Bh
    test    al, 1
    jz      short loc_40625B
    add     ecx, 6Ah
    lea     edx, [esi+22h]
    mov     eax, [ecx]
    mov     [edx], eax
    mov     eax, [ecx+4]
    mov     [edx+4], eax
    mov     ecx, [ecx+8]
    push    ecx
    mov     [edx+8], ecx
    mov     ecx, esp
    push    offset aVtol_move               ; "VTOL_MOVE"
    call    sub_438760
    mov     ecx, esi
    call    sub_438B90
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40625B:                             ; CODE XREF: .text:00406225j
    cmp     word ptr [edx+1C0h], 0
    movsx   eax, word ptr [ecx+7Eh]
    jl      short loc_40626C
    add     eax, 3

    loc_40626C:                             ; CODE XREF: .text:00406267j
    lea     edx, ds:0[eax*4]
    add     ecx, 6Ah
    mov     [esp+14h], dx
    lea     edx, [eax+eax*2]
    mov     [esp+16h], dx
    mov     edx, ecx
    mov     ecx, [edx]
    shr     ecx, 14h
    mov     edi, [edx+4]
    mov     [esp+8], cx
    mov     [esp+0Ch], edi
    mov     edx, [edx+8]
    shr     edx, 14h
    mov     [esp+0Ah], dx
    mov     ecx, [esp+8]
    mov     edx, [esp+14h]
    sub     ecx, edx
    mov     edx, [esp+0Ah]
    mov     [esp+28h], cx
    mov     ecx, [esp+16h]
    sub     edx, ecx
    lea     ecx, ds:0[eax*8]
    mov     [esp+2Ah], dx
    lea     edx, [eax+eax*2]
    shl     edx, 1
    mov     [esp+24h], cx
    mov     ecx, [esp+28h]
    mov     [esp+26h], dx
    mov     eax, [esp+24h]
    push    eax
    push    ecx
    mov     ecx, esi
    call    sub_438AD0
    mov     dword ptr [esi+6], 0E0h
    pop     edi
    mov     eax, 1
    pop     esi
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 18h
    push    ebx
    mov     ebx, [esp+24h]
    push    ebp
    push    esi
    mov     eax, [ebx+16h]
    push    edi
    test    eax, eax
    jnz     short loc_406321
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406321:                             ; CODE XREF: .text:00406310j
    mov     edi, [esp+2Ch]
    mov     ecx, [edi+86h]
    test    ecx, ecx
    jz      short loc_40633E
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40633E:                             ; CODE XREF: .text:0040632Dj
    mov     ecx, [eax+92h]
    mov     edx, [ecx+241h]
    shr     edx, 0Bh
    test    dl, 1
    jz      short loc_406361
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406361:                             ; CODE XREF: .text:00406350j
    xor     ecx, ecx
    mov     cl, [ebx+5]
    sub     ecx, 0
    jz      loc_406705
    dec     ecx
    jz      short loc_406381
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406381:                             ; CODE XREF: .text:00406370j
    mov     eax, [eax+0F0h]
    test    eax, eax
    mov     [esp+18h], eax
    jz      loc_4064C2
    mov     ecx, [edi+96h]
    xor     edx, edx
    mov     dl, [ecx+146h]
    mov     ecx, [eax+96h]
    cmp     byte ptr [ecx+edx+108h], 0
    jnz     loc_4064C2
    test    byte ptr [esp+34h], 10h
    jz      loc_4064C2
    mov     cx, [eax+0A6h]
    mov     esi, [edi+92h]
    and     ecx, 0FFFFh
    mov     ebp, 1
    mov     esi, [esi+23Dh]
    mov     edx, ecx
    and     ecx, 1Fh
    shr     edx, 5
    shl     ebp, cl
    test    [esi+edx*4], ebp
    jnz     loc_4064C2
    push    1
    push    eax
    push    edi
    call    sub_43B1F0
    test    eax, eax
    jz      short loc_406414
    mov     dword ptr [ebx+6], 0
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406414:                             ; CODE XREF: .text:004063FCj
    test    dword ptr [edi+110h], 300000h
    jz      loc_4064C2
    lea     ecx, [edi+1Fh]
    mov     byte ptr [esp+10h], 0
    xor     ebp, ebp
    mov     [esp+14h], ecx

    loc_406432:                             ; CODE XREF: .text:004064BCj
    mov     al, [ecx]
    test    al, 2
    jz      short loc_4064A4
    test    al, 10h
    jz      short loc_4064A4
    mov     eax, [ecx-0Fh]
    mov     ecx, [eax+111h]
    shr     ecx, 1Ah
    test    cl, 1
    jnz     short loc_4064A4
    push    ebp
    push    edi
    call    sub_48A190
    mov     esi, eax
    test    esi, esi
    jz      short loc_406498
    mov     edx, [esp+10h]
    push    edx
    push    esi
    push    edi
    call    sub_49ABB0
    test    eax, eax
    jz      short loc_406498
    mov     cx, [esi+0A6h]
    mov     eax, [edi+92h]
    and     ecx, 0FFFFh
    mov     esi, 1
    mov     eax, [eax+ebp*4+231h]
    mov     edx, ecx
    and     ecx, 1Fh
    shr     edx, 5
    shl     esi, cl
    test    [eax+edx*4], esi
    jz      short loc_4064A4

    loc_406498:                             ; CODE XREF: .text:00406458j
                                            ; .text:00406468j
    mov     ecx, [esp+18h]
    push    ebp
    push    ecx
    push    edi
    call    sub_48A060

    loc_4064A4:                             ; CODE XREF: .text:00406436j
                                            ; .text:0040643Aj ...
    mov     al, [esp+10h]
    mov     ecx, [esp+14h]
    inc     al
    inc     ebp
    add     ecx, 1Ch
    cmp     al, 3
    mov     [esp+10h], al
    mov     [esp+14h], ecx
    jb      loc_406432

    loc_4064C2:                             ; CODE XREF: .text:0040638Dj
                                            ; .text:004063AFj ...
    mov     eax, [ebx+16h]
    mov     ecx, [eax+92h]
    movsx   edx, word ptr [eax+108h]
    cmp     edx, [ecx+1FAh]
    jnb     short loc_406549
    mov     edx, [edi+92h]
    test    byte ptr [edx+241h], 40h
    jz      short loc_406549
    xor     ebp, ebp
    push    ebp
    push    eax
    push    edi
    lea     eax, [esp+20h]
    push    8
    push    eax
    call    sub_43F0E0
    mov     al, [esp+14h]
    test    al, al
    jz      short loc_40654B
    push    ebp
    mov     ecx, ebx
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      loc_406691
    mov     ecx, [ebx+16h]
    mov     edx, [esp+14h]
    push    ebp
    push    ebp
    push    ebp
    push    ebp
    push    ecx
    push    edx
    mov     ecx, eax
    call    sub_43A0C0
    push    eax
    push    edi
    call    sub_43ACB0
    mov     [ebx+6], ebp
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406549:                             ; CODE XREF: .text:004064D8j
                                            ; .text:004064E7j
    xor     ebp, ebp

    loc_40654B:                             ; CODE XREF: .text:00406500j
    mov     eax, [ebx+16h]
    mov     ecx, [eax+5Ch]
    cmp     ecx, ebp
    jz      loc_4066AC
    mov     dl, [ecx+4]
    test    dl, dl
    jz      loc_4066AC
    mov     edx, [edi+92h]
    test    byte ptr [edx+241h], 40h
    jz      loc_4066AC
    mov     edx, [eax+92h]
    test    byte ptr [edx+241h], 40h
    jz      loc_4066AC
    test    dword ptr [ecx+42h], 100000h
    jz      loc_4066AC
    cmp     edi, [ecx+16h]
    jz      loc_4066AC
    push    offset aMobilebuild_0           ; "MobileBuild"
    lea     ecx, [esp+34h]
    call    sub_438760
    mov     eax, [ebx+16h]
    mov     dl, [esp+30h]
    mov     esi, [eax+5Ch]
    mov     cl, [esi+4]
    cmp     cl, dl
    jz      short loc_4065E2
    push    offset aBuildingbuild           ; "BuildingBuild"
    lea     ecx, [esp+30h]
    call    sub_438760
    mov     eax, [ebx+16h]
    mov     cl, [esp+2Ch]
    mov     esi, [eax+5Ch]
    mov     dl, [esi+4]
    cmp     dl, cl
    jz      short loc_4065E2
    xor     edx, edx
    jmp     short loc_4065E7
    ; ---------------------------------------------------------------------------

    loc_4065E2:                             ; CODE XREF: .text:004065BDj
                                            ; .text:004065DCj
    mov     edx, 1

    loc_4065E7:                             ; CODE XREF: .text:004065E0j
    mov     ecx, [esi+42h]
    test    ch, 2
    jz      short loc_4065F4
    cmp     [esi+16h], ebp
    jnz     short loc_4065FD

    loc_4065F4:                             ; CODE XREF: .text:004065EDj
    test    ch, 4
    jnz     short loc_4065FD
    xor     ecx, ecx
    jmp     short loc_406602
    ; ---------------------------------------------------------------------------

    loc_4065FD:                             ; CODE XREF: .text:004065F2j
                                            ; .text:004065F7j
    mov     ecx, 1

    loc_406602:                             ; CODE XREF: .text:004065FBj
    cmp     edx, ebp
    jnz     short loc_406629
    cmp     ecx, ebp
    jz      short loc_406621
    push    ebp
    mov     ecx, ebx
    call    sub_4388D0
    mov     eax, [ebx+16h]
    mov     ecx, [eax+5Ch]
    mov     dl, [ecx+4]
    mov     [esp+10h], dl
    jmp     short loc_40664A
    ; ---------------------------------------------------------------------------

    loc_406621:                             ; CODE XREF: .text:00406608j
    cmp     edx, ebp
    jz      loc_4066AC

    loc_406629:                             ; CODE XREF: .text:00406604j
    cmp     [esi+16h], ebp
    jz      short loc_4066AC
    push    ebp
    mov     ecx, ebx
    call    sub_4388D0
    push    offset aHelpbuild_0             ; "HelpBuild"
    lea     ecx, [esp+38h]
    call    sub_438760
    mov     al, [eax]
    mov     [esp+10h], al

    loc_40664A:                             ; CODE XREF: .text:0040661Fj
    push    56h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_406691
    mov     edx, [ebx+16h]
    push    ebp
    push    ebp
    push    ebp
    mov     ecx, [edx+5Ch]
    mov     edx, [edx+5Ch]
    add     ecx, 22h
    push    ecx
    mov     ecx, [edx+16h]
    mov     edx, [esp+20h]
    push    ecx
    push    edx
    mov     ecx, eax
    call    sub_43A0C0
    push    eax
    push    edi
    call    sub_43ACB0
    mov     [ebx+6], ebp
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406691:                             ; CODE XREF: .text:00406516j
                                            ; .text:00406656j
    xor     eax, eax
    push    eax
    push    edi
    call    sub_43ACB0
    mov     [ebx+6], ebp
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4066AC:                             ; CODE XREF: .text:00406553j
                                            ; .text:0040655Ej ...
    mov     ecx, [eax+6Ah]
    mov     edx, [ebx+22h]
    mov     ebp, [eax+6Eh]
    mov     edi, [eax+72h]
    mov     eax, [ebx+36h]
    add     ecx, edx
    mov     edx, [ebx+26h]
    mov     esi, [ebx+2Ah]
    add     edx, ebp
    add     esi, edi
    mov     [esp+20h], edx
    mov     [esp+1Ch], ecx
    cdq
    sub     eax, edx
    mov     ecx, ebx
    sar     eax, 1
    push    eax
    lea     eax, [esp+20h]
    push    eax
    mov     [esp+2Ch], esi
    call    sub_438930
    push    1Eh
    mov     ecx, ebx
    call    sub_439E80
    mov     eax, [ebx+6]
    or      al, 18h
    mov     [ebx+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406705:                             ; CODE XREF: .text:00406369j
    push    offset aGuarding                ; "Guarding"
    mov     ecx, ebx
    call    sub_438880
    push    3
    mov     ecx, edi
    call    sub_489800
    mov     ecx, [ebx+16h]
    push    10000h
    movsx   eax, word ptr [edi+7Eh]
    movsx   edx, word ptr [ecx+7Eh]
    lea     eax, [edx+eax+2]
    shl     eax, 4
    mov     [ebx+36h], eax
    shl     eax, 10h
    mov     edi, eax
    call    GetRandom
    mov     ebp, eax
    push    edi
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    edi
    push    ebp
    mov     dword ptr [esp+28h], 0
    call    sub_4B7123
    mov     ecx, [esp+28h]
    add     esp, 8
    neg     eax
    add     ebx, 22h
    pop     edi
    mov     [ebx], esi
    pop     esi
    pop     ebp
    mov     [ebx+4], ecx
    mov     [ebx+8], eax
    mov     eax, 1
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    push    esi
    mov     esi, [esp+0Ch]
    push    edi
    mov     eax, [esi+16h]
    test    eax, eax
    jz      loc_4068CB
    test    byte ptr [esp+14h], 8
    jnz     loc_4068CB
    xor     ecx, ecx
    mov     cl, [esi+5]
    cmp     ecx, 5                          ; switch 6 cases
    ja      loc_4068C1                      ; default
    jmp     ds:off_4068E8[ecx*4]            ; switch jump

    loc_4067B1:                             ; DATA XREF: .text:004068E8o
    mov     edx, [esp+0Ch]                  ; case 0x0
    cmp     dword ptr [edx], 0
    jz      loc_4068C1                      ; default
    mov     ecx, [edx+92h]
    test    dword ptr [ecx+245h], 100h
    jz      loc_4068C1                      ; default
    movzx   cx, byte ptr [ecx+22Ah]
    cmp     [eax+7Eh], cx
    jle     short loc_4067F9
    push    offset aUnitIsTooLarge          ; "Unit is too large to transport"
    push    7
    push    edx
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4067F9:                             ; CODE XREF: .text:004067E0j
    push    offset aLoadingUnit             ; "Loading unit"
    mov     ecx, esi
    call    sub_438880
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40680F:                             ; CODE XREF: .text:004067AAj
                                            ; DATA XREF: .text:004068E8o
    mov     edi, [esp+0Ch]                  ; case 0x2
    xor     ecx, ecx
    mov     cx, [eax+0A8h]
    push    0
    push    0
    push    0
    push    ecx
    mov     ecx, [edi+9Ah]
    push    1
    push    1
    push    0
    push    offset aTransportpicku          ; "TransportPickup"
    call    sub_4B0A70
    push    0
    push    0Ch
    push    edi
    call    sub_47F780
    mov     ecx, [esi+36h]
    push    0Fh
    inc     ecx
    mov     [esi+36h], ecx
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40685D:                             ; CODE XREF: .text:004067AAj
                                            ; DATA XREF: .text:004068E8o
    mov     edx, [esp+0Ch]                  ; case 0x1
    push    8
    push    esi
    push    edx
    call    sub_438730
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40686F:                             ; CODE XREF: .text:004067AAj
                                            ; DATA XREF: .text:004068E8o
    mov     ecx, [eax+86h]                  ; case 0x4
    test    ecx, ecx
    jz      short loc_406883
    mov     eax, 5
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406883:                             ; CODE XREF: .text:00406877j
    cmp     dword ptr [esi+36h], 3
    jl      short loc_406893
    mov     eax, 9
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406893:                             ; CODE XREF: .text:00406887j
    add     eax, 6Ah
    push    0
    push    eax
    mov     ecx, esi
    call    sub_438930
    mov     dword ptr [esi+6], 0E8h
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4068B1:                             ; CODE XREF: .text:004067AAj
                                            ; DATA XREF: .text:004068E8o
    push    0                               ; case 0x5
    mov     ecx, esi
    call    sub_4388D0
    xor     eax, eax
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4068C1:                             ; CODE XREF: .text:004067A4j
                                            ; .text:004067B8j ...
    mov     eax, 7                          ; default
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4068CB:                             ; CODE XREF: .text:0040678Bj
                                            ; .text:00406796j
    mov     eax, [esp+0Ch]
    push    offset aTransportMissi          ; "Transport mission failed"
    push    7
    push    eax
    call    sub_47F780
    pop     edi
    mov     eax, 8
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_4068E8 dd offset loc_4067B1         ; DATA XREF: .text:004067AAr
    dd offset loc_40685D                    ; jump table for switch statement
    dd offset loc_40680F
    dd offset loc_40685D
    dd offset loc_40686F
    dd offset loc_4068B1
    ; ---------------------------------------------------------------------------
    mov     al, [esp+0Ch]
    push    esi
    test    al, 8
    push    edi
    jz      short loc_406925
    mov     eax, [esp+0Ch]
    push    offset aUnloadingProce          ; "Unloading process is proceeding non-opt"...
    push    7
    push    eax
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406925:                             ; CODE XREF: .text:00406908j
    mov     esi, [esp+10h]
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_406A7D                      ; default
    jmp     ds:off_406A88[eax*4]            ; switch jump

    loc_40693E:                             ; DATA XREF: .text:00406A88o
    mov     edi, [esp+0Ch]                  ; case 0x0
    cmp     dword ptr [edi], 0
    jz      loc_406A7D                      ; default
    mov     ecx, [edi+92h]
    mov     eax, [ecx+245h]
    test    ah, 1
    jz      loc_406A7D                      ; default
    mov     edx, [edi+8Ah]
    lea     ecx, [esi+12h]
    push    edx
    call    sub_489690
    mov     eax, [esi+16h]
    test    eax, eax
    jnz     short loc_406980
    mov     eax, 5
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406980:                             ; CODE XREF: .text:00406974j
    push    offset aUnloading               ; "Unloading"
    mov     ecx, esi
    call    sub_438880
    mov     eax, [esi+22h]
    mov     ecx, [esi+2Ah]
    mov     edx, [esi+16h]
    and     eax, 0FFFF0000h
    sar     ecx, 10h
    push    0
    add     eax, ecx
    push    0
    push    eax
    xor     eax, eax
    mov     ecx, [edi+9Ah]
    mov     ax, [edx+0A8h]
    push    eax
    push    1
    push    1
    push    0
    push    offset aTransportdrop           ; "TransportDrop"
    call    sub_4B0A70
    mov     ecx, [esi+36h]
    push    0Fh
    inc     ecx
    mov     [esi+36h], ecx
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4069DE:                             ; CODE XREF: .text:00406937j
                                            ; DATA XREF: .text:00406A88o
    mov     ecx, [esp+0Ch]                  ; case 0x1
    push    8
    push    esi
    push    ecx
    call    sub_438730
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4069F0:                             ; CODE XREF: .text:00406937j
                                            ; DATA XREF: .text:00406A88o
    mov     edx, [esi+16h]                  ; case 0x2
    mov     eax, [esp+0Ch]
    cmp     [edx+86h], eax
    jz      short loc_406A13
    push    0
    push    0Dh
    push    eax
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406A13:                             ; CODE XREF: .text:004069FDj
    cmp     dword ptr [esi+36h], 3
    jl      short loc_406A23
    mov     eax, 9
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406A23:                             ; CODE XREF: .text:00406A17j
    mov     eax, [eax+92h]
    mov     ecx, [eax+241h]
    shr     ecx, 0Ch
    test    cl, 1
    jz      short loc_406A58
    movsx   edx, word ptr [eax+180h]
    mov     [esp+0Ch], edx
    fild    dword ptr [esp+0Ch]
    fmul    ds:dbl_4FC958
    call    __ftol
    push    eax
    lea     eax, [esi+22h]
    push    eax
    jmp     short loc_406A5E
    ; ---------------------------------------------------------------------------

    loc_406A58:                             ; CODE XREF: .text:00406A35j
    lea     ecx, [esi+22h]
    push    0
    push    ecx

    loc_406A5E:                             ; CODE XREF: .text:00406A56j
    mov     ecx, esi
    call    sub_438930
    mov     dword ptr [esi+6], 0E8h
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406A76:                             ; CODE XREF: .text:00406937j
                                            ; DATA XREF: .text:00406A88o
    xor     eax, eax                        ; case 0x3
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406A7D:                             ; CODE XREF: .text:00406931j
                                            ; .text:00406945j ...
    pop     edi                             ; default
    mov     eax, 7
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_406A88 dd offset loc_40693E         ; DATA XREF: .text:00406937r
    dd offset loc_4069DE                    ; jump table for switch statement
    dd offset loc_4069F0
    dd offset loc_406A76
    align 10h
    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+34h]
    push    edi
    mov     eax, [esi+92h]
    mov     edx, [esi+6Eh]
    mov     ebx, [esi+6Ah]
    mov     ebp, [esi+6Ah]
    mov     ecx, [eax+162h]
    mov     edi, [eax+15Eh]
    add     ecx, edx
    mov     edx, [eax+166h]
    mov     [esp+20h], ecx
    mov     ecx, [esi+72h]
    add     edx, ecx
    mov     ecx, [eax+16Ah]
    add     ecx, ebx
    mov     ebx, [esi+72h]
    add     ebp, edi
    mov     edi, [eax+16Eh]
    mov     eax, [eax+172h]
    mov     [esp+28h], ecx
    mov     ecx, [esi+6Eh]
    add     eax, ebx
    add     ecx, edi
    mov     [esp+1Ch], ebp
    mov     [esp+2Ch], ecx
    mov     ecx, TAdynmemStructPtr
    mov     [esp+24h], edx
    mov     [esp+30h], eax
    mov     ebx, [ecx+14357h]
    mov     edi, [ecx+1435Bh]
    cmp     ebx, edi
    ja      loc_406BDC
    mov     edi, [esp+3Ch]
    jmp     short loc_406B37
    ; ---------------------------------------------------------------------------

    loc_406B2B:                             ; CODE XREF: .text:00406BD6j
    mov     edx, [esp+24h]
    mov     ebp, [esp+1Ch]
    mov     eax, [esp+30h]

    loc_406B37:                             ; CODE XREF: .text:00406B29j
    mov     ecx, [ebx+6Ah]
    cmp     ecx, ebp
    jl      loc_406BC5
    cmp     ecx, [esp+28h]
    jg      short loc_406BC5
    mov     ebp, [ebx+72h]
    cmp     ebp, edx
    jl      short loc_406BC5
    cmp     ebp, eax
    jg      short loc_406BC5
    mov     edx, [ebx+6Eh]
    mov     eax, [esp+20h]
    cmp     edx, eax
    jl      short loc_406BC5
    cmp     edx, [esp+2Ch]
    jg      short loc_406BC5
    cmp     esi, ebx
    jz      short loc_406BC5
    mov     eax, [edi+22h]
    push    5
    add     eax, ecx
    mov     ecx, [edi+26h]
    add     ecx, edx
    mov     edx, [edi+2Ah]
    add     edx, ebp
    mov     ebp, [esi+6Ah]
    sub     eax, ebp
    mov     ebp, [esi+6Eh]
    mov     [esp+14h], eax
    lea     eax, [esp+14h]
    sub     ecx, ebp
    mov     ebp, [esi+72h]
    push    1Eh
    push    eax
    lea     eax, [ebx+6Ah]
    sub     edx, ebp
    push    eax
    mov     [esp+24h], ecx
    mov     [esp+28h], edx
    call    sub_471FD0
    push    1
    mov     edx, [esp+14h]
    mov     eax, [esp+18h]
    sub     esp, 0Ch
    mov     ecx, esp
    push    ebx
    mov     [ecx], edx
    mov     edx, [esp+2Ch]
    mov     [ecx+4], eax
    mov     [ecx+8], edx
    call    sub_48A9F0

    loc_406BC5:                             ; CODE XREF: .text:00406B3Cj
                                            ; .text:00406B46j ...
    mov     eax, TAdynmemStructPtr
    add     ebx, 118h
    cmp     ebx, [eax+1435Bh]
    jbe     loc_406B2B

    loc_406BDC:                             ; CODE XREF: .text:00406B1Fj
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 5
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_406BF0 proc near                    ; CODE XREF: sub_43C050+2D5p
    push    16h
    push    offset off_4FC6E8
    call    sub_43BC90
    retn
    sub_406BF0 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_1. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_406C10 proc near                    ; CODE XREF: sub_405D90+137p
                                            ; sub_405D90+1B2p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_406C37
    mov     eax, [esp+arg_8]
    push    esi

    loc_406C21:                             ; CODE XREF: sub_406C10+21j
    test    eax, eax
    jz      short loc_406C29
    mov     esi, [ecx]
    mov     [eax], esi

    loc_406C29:                             ; CODE XREF: sub_406C10+13j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_406C21
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406C37:                             ; CODE XREF: sub_406C10+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_406C10 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_406C40 proc near                    ; CODE XREF: sub_405D90+127p
                                            ; sub_405D90+1D1p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_4]
    test    ecx, ecx
    jbe     short locret_406C60
    mov     edx, [esp+arg_8]
    mov     eax, [esp+arg_0]
    push    esi

    loc_406C51:                             ; CODE XREF: sub_406C40+1Dj
    test    eax, eax
    jz      short loc_406C59
    mov     esi, [edx]
    mov     [eax], esi

    loc_406C59:                             ; CODE XREF: sub_406C40+13j
    add     eax, 4
    dec     ecx
    jnz     short loc_406C51
    pop     esi

    locret_406C60:                          ; CODE XREF: sub_406C40+6j
    retn    0Ch
    sub_406C40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_406C70 proc near                    ; CODE XREF: sub_405D90+10Ep
                                            ; sub_40B530+138p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short locret_406C80
    mov     ecx, [esp+arg_4]
    mov     edx, [ecx]
    mov     [eax], edx

    locret_406C80:                          ; CODE XREF: sub_406C70+6j
    retn    8
    sub_406C70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_406C90(int)
    sub_406C90 proc near                    ; DATA XREF: sub_406F00+2o

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    mov     dword_501774, 0
    mov     ebx, 1
    push    edi
    mov     eax, [esi+0D0h]
    mov     edi, ebx
    cmp     eax, ebx
    jle     loc_406D8B
    push    ebp
    mov     ebp, 2

    loc_406CBC:                             ; CODE XREF: sub_406C90+F4j
    push    offset aAny                     ; char *
    push    offset Data
    push    ebx
    mov     ecx, esi
    call    sub_4B73C0
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_406CE1
    mov     dword_501774, ebx

    loc_406CE1:                             ; CODE XREF: sub_406C90+49j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+TAdynmemStruct.CurrentAIProfile]
    test    ecx, ecx
    jnz     short loc_406D15
    push    offset aEasy_0                  ; char *
    push    offset Data
    push    edi
    mov     ecx, esi
    call    sub_4B73C0
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_406D15
    mov     dword_501774, ebx

    loc_406D15:                             ; CODE XREF: sub_406C90+5Ej
                                            ; sub_406C90+7Dj
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+TAdynmemStruct.CurrentAIProfile], ebx
    jnz     short loc_406D48
    push    offset aMedium_0                ; char *
    push    offset Data
    push    edi
    mov     ecx, esi
    call    sub_4B73C0
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_406D48
    mov     dword_501774, ebx

    loc_406D48:                             ; CODE XREF: sub_406C90+91j
                                            ; sub_406C90+B0j
    mov     edx, TAdynmemStructPtr
    cmp     [edx+TAdynmemStruct.CurrentAIProfile], ebp
    jnz     short loc_406D7B
    push    offset aHard_0                  ; char *
    push    offset Data
    push    edi
    mov     ecx, esi
    call    sub_4B73C0
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_406D7B
    mov     dword_501774, ebx

    loc_406D7B:                             ; CODE XREF: sub_406C90+C4j
                                            ; sub_406C90+E3j
    mov     eax, [esi+0D0h]
    inc     edi
    cmp     edi, eax
    jl      loc_406CBC
    pop     ebp

    loc_406D8B:                             ; CODE XREF: sub_406C90+20j
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_406C90 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000000B BYTES: COLLAPSED FUNCTION ___setargv. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_406DB0(int)
    sub_406DB0 proc near                    ; DATA XREF: sub_406F00+13o

    var_44= dword ptr -44h
    var_40= dword ptr -40h
    arg_0= dword ptr  4

    mov     eax, dword_501774
    sub     esp, 44h
    test    eax, eax
    jz      short loc_406E3A
    push    edi
    mov     ecx, 10h
    xor     eax, eax
    lea     edi, [esp+48h+var_40]
    push    esi
    mov     esi, [esp+4Ch+arg_0]
    rep stosd
    push    ebp
    lea     eax, [esp+50h+var_44]
    push    ebx
    push    eax                             ; int
    push    offset Data
    push    1
    mov     ecx, esi
    call    sub_4B73C0
    push    eax                             ; char *
    lea     ecx, [esp+5Ch+var_40]
    call    sub_488D30
    push    0
    push    2
    mov     ecx, esi
    call    sub_4B7410
    xor     esi, esi
    xor     edi, edi
    fstp    [esp+54h+arg_0]
    mov     ebp, [esp+54h+arg_0]
    mov     ebx, 0Ah

    loc_406E0A:                             ; CODE XREF: sub_406DB0+84j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+edi+1BD7h]
    test    eax, eax
    jz      short loc_406E2C
    mov     edx, [esp+54h+var_44]
    lea     eax, [esp+54h+var_40]
    push    edx
    push    ebp
    push    eax
    push    esi
    call    sub_409DC0

    loc_406E2C:                             ; CODE XREF: sub_406DB0+69j
    inc     esi
    add     edi, 14Bh
    dec     ebx
    jnz     short loc_406E0A
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_406E3A:                             ; CODE XREF: sub_406DB0+Aj
    add     esp, 44h
    retn    4
    sub_406DB0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_406E40(int)
    sub_406E40 proc near                    ; DATA XREF: sub_406F00+24o

    var_40= dword ptr -40h
    arg_0= dword ptr  4

    mov     eax, dword_501774
    sub     esp, 40h
    test    eax, eax
    jz      loc_406ED6
    push    edi
    mov     ecx, 10h
    xor     eax, eax
    lea     edi, [esp+44h+var_40]
    push    esi
    mov     esi, [esp+48h+arg_0]
    rep stosd
    push    ebp
    lea     eax, [esp+4Ch+arg_0]
    push    ebx
    push    eax                             ; int
    push    offset Data
    push    1
    mov     ecx, esi
    call    sub_4B73C0
    push    eax                             ; char *
    lea     ecx, [esp+58h+var_40]
    call    sub_488D30
    push    0                               ; int
    push    2                               ; int
    mov     ecx, esi
    call    sub_4B73E0
    mov     ebx, eax
    mov     eax, TAdynmemStructPtr
    xor     edi, edi
    xor     esi, esi
    mov     ebp, 0Ah

    loc_406E9D:                             ; CODE XREF: sub_406E40+90j
    mov     ecx, [eax+esi+1B63h]
    test    ecx, ecx
    jz      short loc_406EC8
    cmp     byte ptr [eax+esi+1BD6h], 2
    jnz     short loc_406EC8
    mov     ecx, [esp+50h+arg_0]
    lea     edx, [esp+50h+var_40]
    push    ecx
    push    ebx
    push    edx
    push    edi
    call    sub_409E90
    mov     eax, TAdynmemStructPtr

    loc_406EC8:                             ; CODE XREF: sub_406E40+66j
                                            ; sub_406E40+70j
    inc     edi
    add     esi, 14Bh
    dec     ebp
    jnz     short loc_406E9D
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_406ED6:                             ; CODE XREF: sub_406E40+Aj
    add     esp, 40h
    retn    4
    sub_406E40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_406EE0 proc near                    ; CODE XREF: sub_40BB00+24Cp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    mov     edx, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    push    eax
    and     edx, 0FFh
    push    ecx
    push    edx
    call    sub_409F20
    retn    0Ch
    sub_406EE0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_406F00 proc near                    ; CODE XREF: sub_43C050+2DFp
    push    8
    push    offset sub_406C90
    push    offset aPlan                    ; "plan"
    call    sub_4B7620
    push    8
    push    offset sub_406DB0
    push    offset aWeight                  ; "weight"
    call    sub_4B7620
    push    8
    push    offset sub_406E40
    push    offset aLimit                   ; "limit"
    call    sub_4B7620
    retn
    sub_406F00 endp

    ; ---------------------------------------------------------------------------
    align 10h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_406F50 proc near                    ; CODE XREF: .text:00499CBCp
                                            ; sub_499EB0+1EBp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     eax, [eax+52h]
    test    eax, eax
    jz      short locret_406F7B
    mov     ecx, [esp+arg_8]
    lea     edx, [ecx+ecx]
    mov     ecx, [esp+arg_4]
    cmp     ecx, edx
    jle     short loc_406F74
    or      byte ptr [eax+0BBh], 40h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_406F74:                             ; CODE XREF: sub_406F50+18j
    or      byte ptr [eax+0BBh], 20h

    locret_406F7B:                          ; CODE XREF: sub_406F50+9j
    retn    0Ch
    sub_406F50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_406F80 proc near                    ; CODE XREF: sub_489CE0+C2p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+10h+arg_4]
    push    edi
    push    10h
    push    esi
    call    sub_4897B0
    xor     ebp, ebp
    mov     eax, [esp+14h+arg_0]
    cmp     eax, ebp
    jz      short loc_406FA8
    cmp     [eax+0A6h], bp
    jnz     short loc_406FA8
    mov     [esp+14h+arg_0], ebp

    loc_406FA8:                             ; CODE XREF: sub_406F80+19j
                                            ; sub_406F80+22j
    mov     eax, [esi+92h]
    mov     ecx, [eax+245h]
    test    ch, 10h
    jz      short loc_406FF6
    mov     eax, [esi+UnitStruct.Owner]
    cmp     [eax], ebp
    jz      short loc_406FF6
    cmp     [eax+PlayerStruct.PlayerType], Player_AI
    jnz     short loc_406FF6
    push    12Ch                            ; int
    call    GetRandom
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    esi
    mov     edx, [ecx+TAdynmemStruct.GameTime]
    mov     ecx, [esi+UnitStruct.Owner]
    lea     eax, [eax+edx+1Eh]
    mov     edx, [ecx+PlayerStruct.field_74]
    mov     [edx+0Dh], eax
    call    sub_439EB0

    loc_406FF6:                             ; CODE XREF: sub_406F80+37j
                                            ; sub_406F80+41j ...
    mov     edi, [esp+14h+arg_0]
    cmp     edi, ebp
    jz      loc_4071B0
    mov     ecx, [esi+UnitStruct.Owner]
    cmp     [ecx], ebp
    jz      loc_4071B0
    mov     al, [ecx+73h]
    cmp     al, 1
    jz      short loc_40701F
    cmp     al, 2
    jnz     loc_4071B0

    loc_40701F:                             ; CODE XREF: sub_406F80+95j
    mov     edx, [esi+UnitStruct.UnitType]
    test    dword ptr [edx+241h], 10010000h
    jz      loc_4071B0
    fld     [esi+UnitStruct.Nanoframe]
    fcomp   ds:flt_4FC968
    fnstsw  ax
    test    ah, 40h
    jz      loc_4071B0
    mov     eax, [edi+96h]
    xor     ebx, ebx
    mov     bl, [eax+146h]
    mov     al, [ebx+ecx+108h]
    test    al, al
    jnz     loc_4071B0
    mov     eax, [esi+UnitStruct.UnitOrders]
    mov     [esp+14h+arg_4], ebp
    cmp     eax, ebp
    jz      short loc_40707D
    test    dword ptr [eax+42h], 20000h
    jz      short loc_4070E6

    loc_40707D:                             ; CODE XREF: sub_406F80+F2j
    mov     ax, [edi+0A6h]
    mov     ebx, [edx+23Dh]
    mov     ecx, eax
    mov     ebp, 1
    and     ecx, 0FFFFh
    mov     edi, ecx
    and     ecx, 1Fh
    shr     edi, 5
    shl     ebp, cl
    test    [ebx+edi*4], ebp
    jnz     short loc_4070E6
    mov     edx, [edx+231h]
    mov     ecx, eax
    and     ecx, 0FFFFh
    mov     edi, 1
    mov     eax, ecx
    and     ecx, 1Fh
    shr     eax, 5
    shl     edi, cl
    test    [edx+eax*4], edi
    jnz     short loc_4070E6
    mov     edi, [esp+14h+arg_0]
    push    0
    push    edi
    push    esi
    call    sub_49ABB0
    test    eax, eax
    jz      short loc_4070E6
    push    0
    push    edi
    push    esi
    call    sub_43B1F0
    mov     [esp+14h+arg_4], eax

    loc_4070E6:                             ; CODE XREF: sub_406F80+FBj
                                            ; sub_406F80+124j ...
    mov     eax, [esp+14h+arg_4]
    test    eax, eax
    jnz     loc_4071B0
    test    dword ptr [esi+UnitStruct.UnitSelected], 300000h
    jz      loc_4071B0
    lea     edi, [esi+UnitStruct.Builder]
    mov     byte ptr [esp+14h+arg_4], 0
    xor     ebp, ebp
    mov     [esp+14h+var_4], edi

    loc_407110:                             ; CODE XREF: sub_406F80+22Aj
    mov     al, [edi]
    test    al, 2
    jz      short loc_407192
    test    al, 10h
    jz      short loc_407192
    mov     ebx, [esp+14h+arg_4]
    mov     eax, [esp+14h+arg_0]
    push    ebx
    push    eax
    push    esi
    call    sub_49ABB0
    test    eax, eax
    jz      short loc_407192
    mov     ecx, [edi-0Fh]
    mov     edx, [ecx+111h]
    shr     edx, 1Ah
    test    dl, 1
    jnz     short loc_407192
    push    ebp
    push    esi
    call    sub_48A190
    mov     edi, eax
    test    edi, edi
    jz      short loc_407186
    push    ebx
    push    edi
    push    esi
    call    sub_49ABB0
    test    eax, eax
    jz      short loc_407186
    mov     cx, [edi+0A6h]
    mov     eax, [esi+UnitStruct.UnitType]
    and     ecx, 0FFFFh
    mov     edi, 1
    mov     eax, [eax+ebp*4+231h]
    mov     edx, ecx
    and     ecx, 1Fh
    shr     edx, 5
    shl     edi, cl
    test    [eax+edx*4], edi
    jz      short loc_407192

    loc_407186:                             ; CODE XREF: sub_406F80+1CAj
                                            ; sub_406F80+1D6j
    mov     ecx, [esp+14h+arg_0]
    push    ebp
    push    ecx
    push    esi
    call    sub_48A060

    loc_407192:                             ; CODE XREF: sub_406F80+194j
                                            ; sub_406F80+198j ...
    mov     al, byte ptr [esp+14h+arg_4]
    mov     edi, [esp+14h+var_4]
    inc     al
    inc     ebp
    add     edi, 1Ch
    cmp     al, 3
    mov     byte ptr [esp+14h+arg_4], al
    mov     [esp+14h+var_4], edi
    jb      loc_407110

    loc_4071B0:                             ; CODE XREF: sub_406F80+7Cj
                                            ; sub_406F80+8Aj ...
    push    esi
    call    sub_438BE0
    test    al, 80h
    jnz     short loc_4071DD
    mov     dl, [esi+0F4h]
    mov     al, [esi+0FFh]
    cmp     dl, al
    jnz     short loc_4071D3
    cmp     byte ptr [esi+0F5h], 1
    jnz     short loc_4071DD

    loc_4071D3:                             ; CODE XREF: sub_406F80+248j
    push    0                               ; int
    push    2                               ; int
    push    esi                             ; Unit
    call    sub_47F850

    loc_4071DD:                             ; CODE XREF: sub_406F80+238j
                                            ; sub_406F80+251j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    sub_406F80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4071F0 proc near                    ; CODE XREF: sub_4077E0+121p
                                            ; sub_407AE0+94p

    var_1D= byte ptr -1Dh
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_8= dword ptr  0Ch

    sub     esp, 20h
    mov     eax, TAdynmemStructPtr
    mov     [esp+20h+var_10], ecx
    push    ebx
    xor     dl, dl
    push    ebp
    lea     ecx, [eax+1BD6h]
    push    esi
    cmp     dl, 0Ah
    push    edi
    mov     [esp+30h+var_18], 7FFFFFFFh
    mov     [esp+30h+var_14], 0
    mov     [esp+30h+var_1D], dl
    mov     [esp+30h+var_1C], ecx
    jnb     loc_40731D

    loc_407229:                             ; CODE XREF: sub_4071F0+140j
    mov     eax, [ecx-73h]
    test    eax, eax
    jz      loc_40731D
    mov     al, [ecx]
    cmp     al, 1
    jz      short loc_407246
    cmp     al, 2
    jz      short loc_407246
    cmp     al, 3
    jnz     loc_40731D

    loc_407246:                             ; CODE XREF: sub_4071F0+48j
                                            ; sub_4071F0+4Cj
    mov     al, [ecx+0D3h]
    cmp     al, 0Ah
    jz      loc_40731D
    mov     esi, [esp+30h+var_10]
    and     eax, 0FFh
    mov     esi, [esi]
    mov     bl, [esi+eax+108h]
    test    bl, bl
    jnz     loc_40731D
    mov     edi, [ecx-0Ch]
    mov     eax, [ecx-8]
    cmp     edi, eax
    mov     [esp+30h+var_C], eax
    ja      loc_40731D

    loc_407280:                             ; CODE XREF: sub_4071F0+123j
    mov     eax, [edi+110h]
    test    eax, 10000000h
    jz      short loc_407307
    mov     edx, eax
    and     edx, 3
    cmp     dl, 2
    jz      short loc_407307
    test    ah, 80h
    jnz     short loc_407307
    test    byte ptr [edi+10Eh], 4
    jnz     short loc_407307
    mov     eax, [esp+30h+arg_0]
    mov     esi, [edi+6Ah]
    mov     ecx, [esp+30h+arg_8]
    mov     ebx, [edi+72h]
    sub     eax, esi
    sub     ecx, ebx
    cdq
    mov     esi, eax
    mov     ebp, edx
    mov     eax, ecx
    push    ebp
    cdq
    push    esi
    push    ebp
    push    esi
    mov     ebx, eax
    mov     [esp+40h+var_4], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     esi, eax
    mov     eax, [esp+30h+var_4]
    push    eax
    push    ebx
    push    eax
    push    ebx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     esi, eax
    mov     eax, [esp+30h+var_18]
    cmp     esi, eax
    jge     short loc_407303
    mov     [esp+30h+var_14], edi
    mov     [esp+30h+var_18], esi

    loc_407303:                             ; CODE XREF: sub_4071F0+109j
    mov     ecx, [esp+30h+var_1C]

    loc_407307:                             ; CODE XREF: sub_4071F0+9Bj
                                            ; sub_4071F0+A5j ...
    mov     eax, [esp+30h+var_C]
    add     edi, 118h
    cmp     edi, eax
    jbe     loc_407280
    mov     dl, [esp+30h+var_1D]

    loc_40731D:                             ; CODE XREF: sub_4071F0+33j
                                            ; sub_4071F0+3Ej ...
    inc     dl
    add     ecx, 14Bh
    cmp     dl, 0Ah
    mov     [esp+30h+var_1D], dl
    mov     [esp+30h+var_1C], ecx
    jb      loc_407229
    mov     eax, [esp+30h+var_14]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    0Ch
    sub_4071F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_407350 proc near                    ; CODE XREF: sub_408CB0+20Ep

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     [eax+8], edx
    xor     edx, edx
    mov     [eax+4], ecx
    mov     dword ptr [eax+0Ch], 0
    mov     dl, [ecx+4]
    mov     dword ptr [eax], offset off_4FC980
    mov     [eax+10h], edx
    retn    8
    sub_407350 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_33. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000020 BYTES: COLLAPSED FUNCTION std::locale::facet::`scalar deleting destructor'(uint). PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------
    push    esi
    mov     esi, ecx
    push    edi
    mov     edi, [esp+0Ch]
    mov     eax, [esi+4]
    push    edi
    mov     ecx, [eax+25h]
    call    sub_407410
    test    eax, eax
    jz      short loc_4073D2
    mov     eax, 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4073D2:                             ; CODE XREF: .text:004073C6j
    mov     ecx, [esi+4]
    push    edi
    mov     ecx, [ecx+15h]
    call    sub_407410
    test    eax, eax
    jz      short loc_4073EC
    mov     eax, 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4073EC:                             ; CODE XREF: .text:004073E0j
    mov     edx, [esi+4]
    push    edi
    mov     ecx, [edx+21h]
    call    sub_407410
    neg     eax
    sbb     eax, eax
    pop     edi
    neg     eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_407410 proc near                    ; CODE XREF: .text:004073BFp
                                            ; .text:004073D9p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    mov     ebx, [ecx+8]
    push    ebp
    push    esi
    mov     eax, [ebx+14h]
    push    edi
    test    eax, eax
    jnz     short loc_407423
    xor     ecx, ecx
    jmp     short loc_40742B
    ; ---------------------------------------------------------------------------

    loc_407423:                             ; CODE XREF: sub_407410+Dj
    mov     ecx, [ebx+18h]
    sub     ecx, eax
    sar     ecx, 2

    loc_40742B:                             ; CODE XREF: sub_407410+11j
    test    ecx, ecx
    mov     [esp+14h+var_4], ecx
    jnz     short loc_40743D
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_40743D:                             ; CODE XREF: sub_407410+21j
    mov     edx, [ebx+14h]
    mov     ebx, [ebx+18h]
    xor     eax, eax
    xor     esi, esi
    xor     edi, edi
    cmp     edx, ebx
    jz      short loc_40746C

    loc_40744D:                             ; CODE XREF: sub_407410+56j
    mov     ecx, [edx]
    add     edx, 4
    movsx   ebp, word ptr [ecx+6Ch]
    add     eax, ebp
    movsx   ebp, word ptr [ecx+70h]
    movsx   ecx, word ptr [ecx+74h]
    add     esi, ebp
    add     edi, ecx
    cmp     edx, ebx
    jnz     short loc_40744D
    mov     ecx, [esp+14h+var_4]

    loc_40746C:                             ; CODE XREF: sub_407410+3Bj
    cdq
    idiv    ecx
    mov     ebx, eax
    mov     eax, esi
    cdq
    idiv    ecx
    shl     ebx, 10h
    mov     esi, eax
    mov     eax, edi
    cdq
    idiv    ecx
    mov     edx, [esp+14h+arg_0]
    pop     edi
    shl     esi, 10h
    mov     [edx], ebx
    mov     [edx+4], esi
    pop     esi
    pop     ebp
    pop     ebx
    shl     eax, 10h
    mov     [edx+8], eax
    mov     eax, 1
    pop     ecx
    retn    4
    sub_407410 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 14h
    mov     eax, [esp+1Ch]
    mov     ecx, [ecx+8]
    imul    eax, eax
    mov     [esp+4], eax
    mov     eax, [ecx]
    push    esi
    mov     dword ptr [esp+4], 0
    mov     esi, [eax+67h]
    mov     eax, [eax+6Bh]
    cmp     esi, eax
    mov     [esp+0Ch], eax
    ja      loc_407552
    mov     eax, [ecx+4]
    push    edi
    push    ebp
    push    ebx
    mov     [esp+2Ch], eax

    loc_4074D8:                             ; CODE XREF: .text:0040754Dj
    mov     ecx, [esp+2Ch]
    mov     eax, [esi+0ACh]
    cmp     eax, ecx
    jnz     short loc_407541
    mov     eax, [esp+28h]
    mov     edi, [esi+6Ah]
    mov     ebx, [esi+72h]
    mov     ecx, [eax+8]
    mov     eax, [eax]
    sub     eax, edi
    sub     ecx, ebx
    cdq
    mov     edi, eax
    mov     ebx, edx
    mov     eax, ecx
    push    ebx
    cdq
    push    edi
    push    ebx
    push    edi
    mov     ebp, eax
    mov     [esp+30h], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edi, eax
    mov     eax, [esp+20h]
    push    eax
    push    ebp
    push    eax
    push    ebp
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     edi, eax
    mov     eax, [esp+14h]
    cmp     edi, eax
    jg      short loc_407541
    inc     dword ptr [esp+10h]

    loc_407541:                             ; CODE XREF: .text:004074E4j
                                            ; .text:0040753Bj
    mov     eax, [esp+18h]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_4074D8
    pop     ebx
    pop     ebp
    pop     edi

    loc_407552:                             ; CODE XREF: .text:004074C8j
    mov     eax, [esp+4]
    pop     esi
    add     esp, 14h
    retn    8
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_407560 proc near                    ; CODE XREF: sub_4077E0+24p

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 2Ch
    push    ebx
    mov     ebx, ecx
    mov     ecx, [esp+30h+arg_0]
    push    ebp
    mov     eax, [ebx+4]
    push    esi
    push    edi
    mov     [esp+3Ch+var_20], ebx
    mov     edi, [eax+ecx*4+11h]
    cmp     edi, ebx
    mov     [esp+3Ch+var_14], edi
    jz      loc_4077CF
    mov     esi, [ebx+8]
    mov     ecx, [esi+14h]
    test    ecx, ecx
    jnz     short loc_407592
    xor     eax, eax
    jmp     short loc_40759A
    ; ---------------------------------------------------------------------------

    loc_407592:                             ; CODE XREF: sub_407560+2Cj
    mov     eax, [esi+18h]
    sub     eax, ecx
    sar     eax, 2

    loc_40759A:                             ; CODE XREF: sub_407560+30j
    xor     edx, edx
    test    eax, eax
    setz    dl
    test    dl, dl
    jz      short loc_4075D9
    mov     ecx, [edi+8]
    mov     edx, [ecx+14h]
    test    edx, edx
    jnz     short loc_4075B3
    xor     eax, eax
    jmp     short loc_4075BB
    ; ---------------------------------------------------------------------------

    loc_4075B3:                             ; CODE XREF: sub_407560+4Dj
    mov     eax, [ecx+18h]
    sub     eax, edx
    sar     eax, 2

    loc_4075BB:                             ; CODE XREF: sub_407560+51j
    xor     edx, edx
    test    eax, eax
    setz    dl
    test    dl, dl
    jnz     loc_4077CF
    mov     ecx, [ecx+14h]
    mov     eax, [esi+4]
    push    eax
    mov     edx, [ecx]
    push    edx
    call    sub_480250

    loc_4075D9:                             ; CODE XREF: sub_407560+43j
    mov     ecx, [ebx+8]
    xor     ebp, ebp
    xor     edi, edi
    mov     [esp+3Ch+var_24], ebp
    mov     eax, [ecx+14h]
    mov     edx, [ecx+18h]
    cmp     eax, edx
    mov     [esp+3Ch+var_2C], edi
    jz      short loc_40760F

    loc_4075F2:                             ; CODE XREF: sub_407560+A5j
    mov     ecx, [eax]
    add     eax, 4
    movsx   esi, word ptr [ecx+6Ch]
    movsx   ecx, word ptr [ecx+74h]
    add     ebp, esi
    add     edi, ecx
    cmp     eax, edx
    jnz     short loc_4075F2
    mov     [esp+3Ch+var_2C], edi
    mov     [esp+3Ch+var_24], ebp

    loc_40760F:                             ; CODE XREF: sub_407560+90j
                                            ; sub_407560+1A2j
    mov     esi, [ebx+8]
    mov     eax, [esi+14h]
    test    eax, eax
    jnz     short loc_40761D
    xor     ecx, ecx
    jmp     short loc_407625
    ; ---------------------------------------------------------------------------

    loc_40761D:                             ; CODE XREF: sub_407560+B7j
    mov     ecx, [esi+18h]
    sub     ecx, eax
    sar     ecx, 2

    loc_407625:                             ; CODE XREF: sub_407560+BBj
    mov     eax, ebp
    cdq
    idiv    ecx
    mov     ebx, eax
    mov     eax, [esi+14h]
    test    eax, eax
    mov     [esp+3Ch+var_18], ebx
    jnz     short loc_40763B
    xor     ecx, ecx
    jmp     short loc_407643
    ; ---------------------------------------------------------------------------

    loc_40763B:                             ; CODE XREF: sub_407560+D5j
    mov     ecx, [esi+18h]
    sub     ecx, eax
    sar     ecx, 2

    loc_407643:                             ; CODE XREF: sub_407560+D9j
    mov     eax, edi
    cdq
    idiv    ecx
    mov     ecx, [esi+14h]
    test    ecx, ecx
    mov     edi, eax
    mov     [esp+3Ch+var_1C], edi
    jnz     short loc_407659
    xor     eax, eax
    jmp     short loc_407661
    ; ---------------------------------------------------------------------------

    loc_407659:                             ; CODE XREF: sub_407560+F3j
    mov     eax, [esi+18h]
    sub     eax, ecx
    sar     eax, 2

    loc_407661:                             ; CODE XREF: sub_407560+F7j
    cmp     eax, 1
    jz      loc_40770F
    mov     ebx, [esi+18h]
    mov     edx, [esi+14h]
    xor     edi, edi
    cmp     edx, ebx
    mov     [esp+3Ch+var_28], ebx
    jz      short loc_4076AF

    loc_40767A:                             ; CODE XREF: sub_407560+149j
    mov     ecx, [edx]
    mov     ebp, [esp+3Ch+var_18]
    movsx   eax, word ptr [ecx+6Ch]
    movsx   ecx, word ptr [ecx+74h]
    sub     eax, ebp
    mov     ebp, [esp+3Ch+var_1C]
    sub     ecx, ebp
    imul    eax, eax
    mov     ebp, ecx
    imul    ebp, ecx
    add     eax, ebp
    cmp     eax, edi
    jle     short loc_4076A4
    mov     edi, eax
    mov     [esp+3Ch+var_28], edx

    loc_4076A4:                             ; CODE XREF: sub_407560+13Cj
    add     edx, 4
    cmp     edx, ebx
    jnz     short loc_40767A
    mov     ebp, [esp+3Ch+var_24]

    loc_4076AF:                             ; CODE XREF: sub_407560+118j
    mov     eax, [esi+14h]
    test    eax, eax
    jnz     short loc_4076BA
    xor     esi, esi
    jmp     short loc_4076C2
    ; ---------------------------------------------------------------------------

    loc_4076BA:                             ; CODE XREF: sub_407560+154j
    mov     esi, [esi+18h]
    sub     esi, eax
    sar     esi, 2

    loc_4076C2:                             ; CODE XREF: sub_407560+158j
    mov     edx, [esp+3Ch+arg_4]
    imul    edx, esi
    cmp     edi, edx
    jl      short loc_407707
    mov     ecx, [esp+3Ch+var_28]
    mov     eax, [esp+3Ch+arg_0]
    push    eax
    mov     edx, [ecx]
    push    edx
    call    sub_480250
    mov     eax, [esp+3Ch+var_28]
    mov     ebx, [esp+3Ch+var_20]
    mov     eax, [eax]
    movsx   ecx, word ptr [eax+6Ch]
    movsx   edx, word ptr [eax+74h]
    mov     eax, [esp+3Ch+var_2C]
    sub     ebp, ecx
    sub     eax, edx
    mov     [esp+3Ch+var_24], ebp
    mov     [esp+3Ch+var_2C], eax
    mov     edi, eax
    jmp     loc_40760F
    ; ---------------------------------------------------------------------------

    loc_407707:                             ; CODE XREF: sub_407560+16Bj
    mov     edi, [esp+3Ch+var_1C]
    mov     ebx, [esp+3Ch+var_18]

    loc_40770F:                             ; CODE XREF: sub_407560+104j
    mov     al, byte ptr [esp+3Ch+arg_0]
    mov     edx, [esp+3Ch+var_14]
    xor     ecx, ecx
    mov     byte ptr [esp+3Ch+var_10], al
    mov     [esp+3Ch+var_C], ecx
    mov     [esp+3Ch+var_8], ecx
    mov     [esp+3Ch+var_4], ecx
    mov     eax, [edx+8]
    mov     esi, [eax+14h]
    mov     edx, [eax+18h]
    cmp     esi, edx
    jz      loc_4077D9

    loc_40773A:                             ; CODE XREF: sub_407560+238j
    mov     ecx, [esi]
    mov     ebp, [esp+3Ch+var_20]
    movsx   eax, word ptr [ecx+6Ch]
    movsx   ecx, word ptr [ecx+74h]
    sub     ecx, edi
    sub     eax, ebx
    mov     edx, ecx
    imul    eax, eax
    imul    edx, ecx
    mov     ecx, [ebp+8]
    add     eax, edx
    add     ecx, 10h
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_407767
    xor     ecx, ecx
    jmp     short loc_40776F
    ; ---------------------------------------------------------------------------

    loc_407767:                             ; CODE XREF: sub_407560+201j
    mov     ecx, [ecx+8]
    sub     ecx, edx
    sar     ecx, 2

    loc_40776F:                             ; CODE XREF: sub_407560+205j
    mov     edx, [esp+3Ch+arg_4]
    imul    edx, ecx
    cmp     eax, edx
    jge     short loc_40778B
    mov     eax, [esp+3Ch+var_8]
    push    esi
    push    1
    push    eax
    lea     ecx, [esp+48h+var_10]
    call    sub_408F30

    loc_40778B:                             ; CODE XREF: sub_407560+218j
    mov     ecx, [esp+3Ch+var_14]
    add     esi, 4
    mov     edx, [ecx+8]
    cmp     esi, [edx+18h]
    jnz     short loc_40773A
    mov     ecx, [esp+3Ch+var_C]

    loc_40779E:                             ; CODE XREF: sub_407560+27Dj
    mov     eax, [esp+3Ch+var_8]
    mov     esi, ecx
    cmp     ecx, eax
    jz      short loc_4077C6

    loc_4077A8:                             ; CODE XREF: sub_407560+260j
    mov     eax, [ebp+8]
    mov     edx, [esi]
    mov     ecx, [eax+4]
    push    ecx
    push    edx
    call    sub_480250
    mov     eax, [esp+3Ch+var_8]
    add     esi, 4
    cmp     esi, eax
    jnz     short loc_4077A8
    mov     ecx, [esp+3Ch+var_C]

    loc_4077C6:                             ; CODE XREF: sub_407560+246j
    push    ecx
    call    sub_4B4F20
    add     esp, 4

    loc_4077CF:                             ; CODE XREF: sub_407560+1Ej
                                            ; sub_407560+64j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4077D9:                             ; CODE XREF: sub_407560+1D4j
    mov     ebp, [esp+3Ch+var_20]
    jmp     short loc_40779E
    sub_407560 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4077E0 proc near                    ; DATA XREF: .rdata:004FC988o

    var_18= dword ptr -18h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     eax, TAdynmemStructPtr
    sub     esp, 18h
    push    esi
    mov     esi, ecx
    mov     ecx, [eax+38A47h]
    mov     edx, [esi+1Ch]
    mov     eax, [esi+20h]
    add     ecx, 12Ch
    push    edx
    mov     [esi+0Ch], ecx
    push    eax
    mov     ecx, esi
    call    sub_407560
    mov     eax, [esi+8]
    mov     edx, [eax+14h]
    test    edx, edx
    jnz     short loc_407817
    xor     ecx, ecx
    jmp     short loc_40781F
    ; ---------------------------------------------------------------------------

    loc_407817:                             ; CODE XREF: sub_4077E0+31j
    mov     ecx, [eax+18h]
    sub     ecx, edx
    sar     ecx, 2

    loc_40781F:                             ; CODE XREF: sub_4077E0+35j
    xor     edx, edx
    test    ecx, ecx
    setz    dl
    test    dl, dl
    jnz     loc_407924
    mov     edx, [eax+14h]
    test    edx, edx
    jnz     short loc_407839
    xor     ecx, ecx
    jmp     short loc_407841
    ; ---------------------------------------------------------------------------

    loc_407839:                             ; CODE XREF: sub_4077E0+53j
    mov     ecx, [eax+18h]
    sub     ecx, edx
    sar     ecx, 2

    loc_407841:                             ; CODE XREF: sub_4077E0+57j
    cmp     ecx, [esi+14h]
    jle     short loc_407869
    mov     ecx, [esi+24h]
    test    ecx, ecx
    jnz     loc_4078D2
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_40785C
    xor     eax, eax
    jmp     short loc_407864
    ; ---------------------------------------------------------------------------

    loc_40785C:                             ; CODE XREF: sub_4077E0+76j
    mov     eax, [eax+18h]
    sub     eax, ecx
    sar     eax, 2

    loc_407864:                             ; CODE XREF: sub_4077E0+7Aj
    cmp     eax, [esi+18h]
    jge     short loc_4078D2

    loc_407869:                             ; CODE XREF: sub_4077E0+64j
    mov     ecx, [esi+4]
    lea     eax, [esp+1Ch+var_18]
    push    eax
    mov     ecx, [ecx+25h]
    call    sub_407410
    test    eax, eax
    jnz     short loc_4078A5
    mov     eax, [esi+4]
    lea     edx, [esp+1Ch+var_18]
    push    edx
    mov     ecx, [eax+15h]
    call    sub_407410
    test    eax, eax
    jnz     short loc_4078A5
    mov     edx, [esi+4]
    lea     ecx, [esp+1Ch+var_18]
    push    ecx
    mov     ecx, [edx+21h]
    call    sub_407410
    test    eax, eax
    jz      short loc_4078D2

    loc_4078A5:                             ; CODE XREF: sub_4077E0+9Bj
                                            ; sub_4077E0+AFj
    mov     dword ptr [esi+24h], 0
    mov     esi, [esi+8]
    push    0
    lea     eax, [esp+20h+var_18]
    mov     ecx, [esi+4]
    mov     edx, [esi]
    push    0A0h
    push    eax
    push    0
    push    0
    push    2
    push    ecx
    push    edx
    call    sub_480460
    pop     esi
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------

    loc_4078D2:                             ; CODE XREF: sub_4077E0+6Bj
                                            ; sub_4077E0+87j ...
    lea     eax, [esp+1Ch+var_C]
    mov     ecx, esi
    push    eax
    mov     dword ptr [esi+24h], 1
    call    sub_407410
    mov     edx, [esp+1Ch+var_C]
    mov     eax, [esp+1Ch+var_8]
    sub     esp, 0Ch
    mov     ecx, esp
    mov     [ecx], edx
    mov     edx, [esp+28h+var_4]
    mov     [ecx+4], eax
    mov     [ecx+8], edx
    mov     ecx, [esi+4]
    call    sub_4071F0
    test    eax, eax
    jz      short loc_407924
    mov     esi, [esi+8]
    push    0
    push    0
    push    0
    mov     ecx, [esi]
    push    eax
    mov     eax, [esi+4]
    push    0
    push    3
    push    eax
    push    ecx
    call    sub_480460

    loc_407924:                             ; CODE XREF: sub_4077E0+48j
                                            ; sub_4077E0+128j
    pop     esi
    add     esp, 18h
    retn
    sub_4077E0 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     edx, [esp+8]
    mov     eax, ecx
    mov     ecx, [esp+4]
    mov     [eax+8], edx
    xor     edx, edx
    mov     [eax+4], ecx
    mov     dword ptr [eax+0Ch], 0
    mov     dl, [ecx+4]
    mov     ecx, [esp+10h]
    mov     [eax+10h], edx
    mov     edx, [esp+0Ch]
    mov     [eax+1Ch], ecx
    mov     [eax+20h], edx
    mov     dword ptr [eax], offset off_4FC988
    mov     dword ptr [eax+24h], 0
    mov     dword ptr [eax+18h], 6
    mov     dword ptr [eax+14h], 3
    retn    10h
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_407980 proc near                    ; DATA XREF: .rdata:004FC98Co

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FC980
    jz      short loc_40799A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_40799A:                             ; CODE XREF: sub_407980+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_407980 endp

    ; ---------------------------------------------------------------------------
    mov     edx, [esp+8]
    mov     eax, ecx
    mov     ecx, [esp+4]
    mov     [eax+8], edx
    xor     edx, edx
    mov     [eax+4], ecx
    mov     dword ptr [eax+0Ch], 0
    mov     dl, [ecx+4]
    mov     ecx, [esp+0Ch]
    mov     [eax+10h], edx
    mov     [eax+14h], ecx
    mov     dword ptr [eax], offset off_4FC990
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4079D0 proc near                    ; DATA XREF: .rdata:004FC994o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FC980
    jz      short loc_4079EA
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4079EA:                             ; CODE XREF: sub_4079D0+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_4079D0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4079F0 proc near                    ; DATA XREF: .rdata:004FC990o

    var_C= dword ptr -0Ch

    mov     eax, TAdynmemStructPtr
    sub     esp, 0Ch
    push    esi
    mov     esi, ecx
    mov     ecx, [eax+38A47h]
    mov     edx, [esi+14h]
    mov     eax, [esi+4]
    add     ecx, 96h
    mov     [esi+0Ch], ecx
    mov     ecx, [eax+edx*4+11h]
    mov     eax, [esi+8]
    add     eax, 10h
    mov     edx, [eax+4]
    test    edx, edx
    jnz     short loc_407A25
    xor     eax, eax
    jmp     short loc_407A2D
    ; ---------------------------------------------------------------------------

    loc_407A25:                             ; CODE XREF: sub_4079F0+2Fj
    mov     eax, [eax+8]
    sub     eax, edx
    sar     eax, 2

    loc_407A2D:                             ; CODE XREF: sub_4079F0+33j
    xor     edx, edx
    test    eax, eax
    setz    dl
    test    dl, dl
    jnz     short loc_407A88
    mov     eax, [ecx+8]
    add     eax, 10h
    mov     edx, [eax+4]
    test    edx, edx
    jnz     short loc_407A49
    xor     eax, eax
    jmp     short loc_407A51
    ; ---------------------------------------------------------------------------

    loc_407A49:                             ; CODE XREF: sub_4079F0+53j
    mov     eax, [eax+8]
    sub     eax, edx
    sar     eax, 2

    loc_407A51:                             ; CODE XREF: sub_4079F0+57j
    xor     edx, edx
    test    eax, eax
    setz    dl
    test    dl, dl
    jnz     short loc_407A88
    lea     eax, [esp+10h+var_C]
    push    eax
    call    sub_407410
    test    eax, eax
    jz      short loc_407A88
    mov     esi, [esi+8]
    push    0
    lea     ecx, [esp+14h+var_C]
    push    0
    mov     edx, [esi+4]
    mov     eax, [esi]
    push    ecx
    push    0
    push    0
    push    2
    push    edx
    push    eax
    call    sub_480460

    loc_407A88:                             ; CODE XREF: sub_4079F0+46j
                                            ; sub_4079F0+6Aj ...
    pop     esi
    add     esp, 0Ch
    retn
    sub_4079F0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, [esp+8]
    mov     eax, ecx
    mov     ecx, [esp+4]
    mov     [eax+8], edx
    xor     edx, edx
    mov     [eax+4], ecx
    mov     dword ptr [eax+0Ch], 0
    mov     dl, [ecx+4]
    mov     dword ptr [eax], offset off_4FC998
    mov     [eax+10h], edx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_407AC0 proc near                    ; DATA XREF: .rdata:004FC99Co

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FC980
    jz      short loc_407ADA
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_407ADA:                             ; CODE XREF: sub_407AC0+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_407AC0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_407AE0 proc near                    ; DATA XREF: .rdata:004FC998o

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_6= dword ptr -6

    sub     esp, 28h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     esi, ecx
    push    384h                            ; int
    mov     [esp+3Ch+var_28], esi
    call    GetRandom
    mov     ecx, TAdynmemStructPtr
    add     eax, 1Eh
    xor     ebx, ebx
    mov     edx, [ecx+38A47h]
    add     edx, eax
    mov     eax, [esi+8]
    add     eax, 10h
    mov     [esi+0Ch], edx
    mov     ecx, [eax+4]
    cmp     ecx, ebx
    jnz     short loc_407B1E
    xor     eax, eax
    jmp     short loc_407B26
    ; ---------------------------------------------------------------------------

    loc_407B1E:                             ; CODE XREF: sub_407AE0+38j
    mov     eax, [eax+8]
    sub     eax, ecx
    sar     eax, 2

    loc_407B26:                             ; CODE XREF: sub_407AE0+3Cj
    cmp     eax, 5
    jge     loc_407C66
    mov     ecx, [esi+10h]
    lea     eax, [esp+38h+var_10]
    push    eax
    push    ecx
    call    sub_40BA80
    mov     edx, [esp+38h+var_10+2]
    mov     ecx, [esp+38h+var_6]
    or      edx, ecx
    test    dx, dx
    jnz     short loc_407B8A
    lea     eax, [esp+38h+var_1C]
    mov     ecx, esi
    push    eax
    call    sub_407410
    mov     edx, [esp+38h+var_1C]
    mov     eax, [esp+38h+var_18]
    sub     esp, 0Ch
    mov     ecx, esp
    mov     [ecx], edx
    mov     edx, [esp+44h+var_14]
    mov     [ecx+4], eax
    mov     [ecx+8], edx
    mov     ecx, [esi+4]
    call    sub_4071F0
    mov     esi, [esi+8]
    push    ebx
    add     eax, 6Ah
    push    ebx
    push    eax
    push    ebx
    push    1
    jmp     loc_407D23
    ; ---------------------------------------------------------------------------

    loc_407B8A:                             ; CODE XREF: sub_407AE0+6Aj
    push    2                               ; int
    call    GetRandom
    mov     edi, TAdynmemStructPtr
    mov     ecx, eax
    add     ecx, 2
    mov     eax, [edi+14223h]
    mov     [esp+38h+var_20], ecx
    cdq
    and     edx, 7
    add     eax, edx
    mov     esi, eax
    mov     eax, [edi+14227h]
    cdq
    and     edx, 7
    add     eax, edx
    mov     edi, eax
    sar     esi, 3
    sar     edi, 3
    cmp     ecx, ebx
    jle     loc_407D31
    mov     eax, esi
    cdq
    sub     eax, edx
    mov     ebp, eax
    mov     eax, edi
    cdq
    sub     eax, edx
    sar     ebp, 1
    sar     eax, 1
    mov     [esp+38h+var_24], eax

    loc_407BDE:                             ; CODE XREF: sub_407AE0+17Cj
    push    esi                             ; int
    call    GetRandom
    mov     edx, [esp+38h+var_10]
    sub     eax, ebp
    shl     eax, 10h
    add     edx, eax
    mov     eax, [esp+38h+var_C]
    push    edi                             ; int
    mov     [esp+3Ch+var_1C], edx
    mov     [esp+3Ch+var_18], eax
    call    GetRandom
    mov     edx, [esp+38h+var_24]
    mov     ecx, [esp+30h]
    sub     eax, edx
    shl     eax, 10h
    add     ecx, eax
    test    ebx, ebx
    mov     [esp+38h+var_14], ecx
    jnz     short loc_407C33
    mov     edx, [esp+38h+var_28]
    push    ebx
    lea     ecx, [esp+3Ch+var_1C]
    push    ebx
    mov     eax, [edx+8]
    push    ecx
    push    ebx
    push    ebx
    mov     edx, [eax+4]
    mov     eax, [eax]
    push    2
    push    edx
    push    eax
    jmp     short loc_407C50
    ; ---------------------------------------------------------------------------

    loc_407C33:                             ; CODE XREF: sub_407AE0+136j
    mov     ecx, [esp+38h+var_28]
    push    0
    lea     edx, [esp+3Ch+var_1C]
    push    0
    mov     eax, [ecx+8]
    push    edx
    push    0
    push    1
    mov     ecx, [eax+4]
    mov     edx, [eax]
    push    9
    push    ecx
    push    edx

    loc_407C50:                             ; CODE XREF: sub_407AE0+151j
    call    sub_480460
    mov     eax, [esp+38h+var_20]
    inc     ebx
    cmp     ebx, eax
    jl      short loc_407BDE
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn
    ; ---------------------------------------------------------------------------

    loc_407C66:                             ; CODE XREF: sub_407AE0+49j
    push    2                               ; int
    mov     [esp+3Ch+var_18], ebx
    call    GetRandom
    test    eax, eax
    jz      short loc_407CCC
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14223h]
    push    ecx                             ; int
    call    GetRandom
    shl     eax, 10h
    push    2                               ; int
    mov     [esp+3Ch+var_1C], eax
    call    GetRandom
    test    eax, eax
    jz      short loc_407CA8
    lea     eax, [esp+38h+var_20]
    mov     [esp+38h+var_20], ebx
    mov     ecx, [eax]
    mov     [esp+38h+var_14], ecx
    jmp     short loc_407D17
    ; ---------------------------------------------------------------------------

    loc_407CA8:                             ; CODE XREF: sub_407AE0+1B6j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14227h]
    add     eax, 0FFFFh
    shl     eax, 10h
    mov     [esp+38h+var_20], eax
    lea     eax, [esp+38h+var_20]
    mov     ecx, [eax]
    mov     [esp+38h+var_14], ecx
    jmp     short loc_407D17
    ; ---------------------------------------------------------------------------

    loc_407CCC:                             ; CODE XREF: sub_407AE0+193j
    push    2                               ; int
    call    GetRandom
    mov     ecx, TAdynmemStructPtr
    test    eax, eax
    jz      short loc_407CE7
    mov     [esp+38h+var_20], ebx
    lea     eax, [esp+38h+var_20]
    jmp     short loc_407CFE
    ; ---------------------------------------------------------------------------

    loc_407CE7:                             ; CODE XREF: sub_407AE0+1FBj
    mov     edx, [ecx+14223h]
    lea     eax, [esp+38h+var_20]
    add     edx, 0FFFFh
    shl     edx, 10h
    mov     [esp+38h+var_20], edx

    loc_407CFE:                             ; CODE XREF: sub_407AE0+205j
    mov     eax, [eax]
    mov     [esp+38h+var_1C], eax
    mov     ecx, [ecx+14227h]
    push    ecx                             ; int
    call    GetRandom
    shl     eax, 10h
    mov     [esp+38h+var_14], eax

    loc_407D17:                             ; CODE XREF: sub_407AE0+1C6j
                                            ; sub_407AE0+1EAj
    mov     esi, [esi+8]
    push    ebx
    lea     edx, [esp+3Ch+var_1C]
    push    ebx
    push    edx
    push    ebx
    push    ebx

    loc_407D23:                             ; CODE XREF: sub_407AE0+A5j
    mov     eax, [esi+4]
    mov     ecx, [esi]
    push    9
    push    eax
    push    ecx
    call    sub_480460

    loc_407D31:                             ; CODE XREF: sub_407AE0+E4j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn
    sub_407AE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_407D40 proc near                    ; CODE XREF: sub_408CB0+23Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    xor     ebp, ebp
    mov     ecx, [esp+0Ch+arg_4]
    xor     edx, edx
    mov     [esi+4], eax
    mov     [esi+8], ecx
    mov     [esi+0Ch], ebp
    mov     dl, [eax+4]
    push    edi
    mov     [esi+10h], edx
    mov     dword ptr [esi], offset off_4FC980
    mov     edi, TAdynmemStructPtr
    mov     eax, [edi+14223h]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+10h+arg_0], eax
    fild    [esp+10h+arg_0]
    fmul    ds:dbl_4FC970
    call    __ftol
    mov     ebx, eax
    mov     eax, [edi+14227h]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+10h+arg_0], eax
    fild    [esp+10h+arg_0]
    fmul    ds:dbl_4FC970
    call    __ftol
    lea     ecx, [esi+14h]
    mov     [esi+14h], ebx
    mov     [ecx+4], ebp
    mov     [ecx+8], eax
    mov     edi, TAdynmemStructPtr
    mov     eax, [edi+14223h]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+10h+arg_0], eax
    fild    [esp+10h+arg_0]
    fmul    ds:dbl_4FC970
    call    __ftol
    mov     ebx, eax
    mov     eax, [edi+14227h]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+10h+arg_0], eax
    fild    [esp+10h+arg_0]
    fmul    ds:dbl_4FC970
    call    __ftol
    lea     edx, [esi+20h]
    mov     [esi+20h], ebx
    mov     [edx+4], ebp
    mov     [edx+8], eax
    mov     edi, TAdynmemStructPtr
    mov     eax, [edi+14223h]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+10h+arg_0], eax
    fild    [esp+10h+arg_0]
    fmul    ds:dbl_4FC970
    call    __ftol
    mov     ebx, eax
    mov     eax, [edi+14227h]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+10h+arg_0], eax
    fild    [esp+10h+arg_0]
    fmul    ds:dbl_4FC970
    call    __ftol
    lea     ecx, [esi+2Ch]
    mov     [esi+38h], ebp
    mov     dword ptr [esi], offset off_4FC9A0
    pop     edi
    mov     [ecx], ebx
    mov     [ecx+4], ebp
    mov     [ecx+8], eax
    mov     eax, esi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_407D40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_407E70 proc near                    ; DATA XREF: .rdata:004FC9A4o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FC980
    jz      short loc_407E8A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_407E8A:                             ; CODE XREF: sub_407E70+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_407E70 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_407E90 proc near                    ; DATA XREF: .rdata:004FC9A0o

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    push    96h                             ; int
    call    GetRandom
    mov     ecx, TAdynmemStructPtr
    add     eax, 1Eh
    mov     edx, [ecx+38A47h]
    add     edx, eax
    mov     eax, [edi+8]
    add     eax, 10h
    mov     [edi+0Ch], edx
    mov     ecx, [eax+4]
    test    ecx, ecx
    jnz     short loc_407EC6
    xor     eax, eax
    jmp     short loc_407ECE
    ; ---------------------------------------------------------------------------

    loc_407EC6:                             ; CODE XREF: sub_407E90+30j
    mov     eax, [eax+8]
    sub     eax, ecx
    sar     eax, 2

    loc_407ECE:                             ; CODE XREF: sub_407E90+34j
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    test    cl, cl
    jnz     loc_40807E
    push    0Ah                             ; int
    call    GetRandom
    test    eax, eax
    jnz     short loc_407F39
    lea     edx, [edi+14h]
    lea     eax, [edi+20h]
    push    10000h                          ; int
    mov     ecx, [edx]
    mov     [eax], ecx
    mov     ecx, [edx+4]
    mov     [eax+4], ecx
    mov     edx, [edx+8]
    mov     [eax+8], edx
    call    GetRandom
    mov     ebx, eax
    push    1400000h
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    1400000h
    push    ebx
    xor     ebp, ebp
    call    sub_4B7123
    lea     ecx, [edi+2Ch]
    add     esp, 8
    neg     eax
    mov     [ecx], esi
    mov     [ecx+4], ebp
    mov     [ecx+8], eax

    loc_407F39:                             ; CODE XREF: sub_407E90+56j
    mov     edx, [edi+2Ch]
    mov     ebx, [edi+20h]
    lea     esi, [edi+20h]
    add     ebx, edx
    mov     ecx, [esi+4]
    mov     ebp, [esi+8]
    mov     [esi], ebx
    mov     eax, [edi+30h]
    add     ecx, eax
    mov     [esi+4], ecx
    mov     ecx, [edi+34h]
    add     ebp, ecx
    mov     [esi+8], ebp
    mov     edx, [edi+8]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [edx]
    mov     dl, [eax+14281h]
    and     dl, 2
    cmp     dl, 2
    jnz     short loc_407FBB
    movsx   ebx, word ptr [esi+6]
    movsx   eax, word ptr [esi+0Ah]
    movsx   edx, word ptr [esi+2]
    sar     ebx, 1
    sub     eax, ebx
    mov     ebx, [ecx+80h]
    sar     edx, 5
    sar     eax, 5
    cmp     edx, ebx
    jnb     short loc_407FB7
    cmp     eax, [ecx+84h]
    jnb     short loc_407FB7
    mov     ebx, [ecx+80h]
    imul    ebx, eax
    mov     eax, [ecx+7Ch]
    add     ebx, edx
    cmp     byte ptr [ebx+eax], 0
    jz      short loc_407FB7
    mov     eax, 1
    jmp     short loc_407FC2
    ; ---------------------------------------------------------------------------

    loc_407FB7:                             ; CODE XREF: sub_407E90+102j
                                            ; sub_407E90+10Aj ...
    xor     eax, eax
    jmp     short loc_407FC2
    ; ---------------------------------------------------------------------------

    loc_407FBB:                             ; CODE XREF: sub_407E90+E2j
    push    esi                             ; int
    push    ecx                             ; int
    call    sub_408090

    loc_407FC2:                             ; CODE XREF: sub_407E90+125j
                                            ; sub_407E90+129j
    test    eax, eax
    jz      short loc_408002
    mov     ecx, [edi+10h]
    push    0A0h
    push    esi
    push    ecx
    call    sub_40B1C0
    mov     edx, [edi+38h]
    mov     ebx, eax
    push    edx                             ; int
    call    GetRandom
    push    ebx                             ; int
    mov     ebp, eax
    call    GetRandom
    cmp     eax, ebp
    jle     short loc_408002
    mov     ecx, [esi]
    mov     edx, [esi+4]
    lea     eax, [edi+14h]
    mov     [edi+38h], ebx
    mov     [eax], ecx
    mov     ecx, [esi+8]
    mov     [eax+4], edx
    mov     [eax+8], ecx

    loc_408002:                             ; CODE XREF: sub_407E90+134j
                                            ; sub_407E90+15Aj
    mov     eax, [edi+8]
    mov     ebp, [eax+14h]
    mov     ecx, [eax+18h]
    cmp     ebp, ecx
    jz      short loc_408074

    loc_40800F:                             ; CODE XREF: sub_407E90+1E2j
    mov     esi, [ebp+0]
    mov     edx, [esi+92h]
    mov     eax, [edx+245h]
    shr     eax, 4
    test    al, 1
    jz      short loc_408069
    cmp     dword ptr [esi], 0
    jnz     short loc_40803E
    lea     ecx, [edi+14h]
    push    0
    lea     edx, [esi+6Ah]
    push    ecx
    push    edx
    push    esi
    call    sub_49AA80
    test    eax, eax
    jz      short loc_408069

    loc_40803E:                             ; CODE XREF: sub_407E90+198j
    lea     ebx, [edi+14h]
    lea     eax, [esp+14h+var_4]
    push    ebx
    push    0
    push    esi
    push    3
    push    eax
    call    sub_43F0E0
    mov     eax, [esp+14h+var_4]
    test    al, al
    jz      short loc_408069
    push    0
    push    0
    push    ebx
    push    0
    push    esi
    push    0
    push    eax
    call    sub_43ADC0

    loc_408069:                             ; CODE XREF: sub_407E90+193j
                                            ; sub_407E90+1ACj ...
    mov     ecx, [edi+8]
    add     ebp, 4
    cmp     ebp, [ecx+18h]
    jnz     short loc_40800F

    loc_408074:                             ; CODE XREF: sub_407E90+17Dj
    push    0
    call    sub_4B4F20
    add     esp, 4

    loc_40807E:                             ; CODE XREF: sub_407E90+47j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_407E90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_408090(int,int)
    sub_408090 proc near                    ; CODE XREF: sub_407E90+12Dp
                                            ; PlayerCanSeeUnit+FBp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    esi
    movsx   edx, word ptr [eax+6]
    movsx   ecx, word ptr [eax+2]
    movsx   eax, word ptr [eax+0Ah]
    sar     edx, 1
    sub     eax, edx
    mov     edx, [esp+4+arg_0]
    sar     ecx, 5
    mov     esi, [edx+80h]
    sar     eax, 5
    cmp     ecx, esi
    jnb     short loc_4080C1
    cmp     eax, [edx+84h]
    jb      short loc_4080C7

    loc_4080C1:                             ; CODE XREF: sub_408090+27j
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4080C7:                             ; CODE XREF: sub_408090+2Fj
    mov     edx, [edx+80h]
    xor     esi, esi
    imul    edx, eax
    add     edx, ecx
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14273h]
    mov     cl, [ecx+TAdynmemStruct.LOS_Sight]
    mov     si, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    mov     eax, esi
    pop     esi
    and     eax, edx
    neg     eax
    sbb     eax, eax
    neg     eax
    retn    8
    sub_408090 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_408100 proc near                    ; DATA XREF: .rdata:004FC9A8o

    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 50h
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ecx, [eax+38A47h]
    push    esi
    mov     eax, [ebx+10h]
    lea     edx, [esp+5Ch+var_3C]
    push    edi
    add     ecx, 5Ah
    push    edx
    push    eax
    mov     [esp+68h+var_48], ebx
    mov     [ebx+0Ch], ecx
    call    sub_40BA80
    mov     eax, [ebx+8]
    mov     edi, [eax+14h]
    mov     ecx, [eax+18h]
    cmp     edi, ecx
    mov     [esp+60h+var_4C], edi
    jz      loc_4082CC

    loc_408141:                             ; CODE XREF: sub_408100+1C6j
    mov     ebp, [edi]
    mov     eax, [ebp+92h]
    mov     ecx, [eax+152h]
    test    ecx, ecx
    jz      loc_4082B9
    mov     ecx, [eax+245h]
    shr     ecx, 0Ch
    test    cl, 1
    jz      short loc_408191
    mov     edx, [ebx+10h]
    push    edx
    call    sub_40C230
    cmp     eax, 5
    jge     loc_4082B9
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ebx+4]
    mov     edx, [ecx+38A47h]
    mov     ecx, [eax+0Dh]
    cmp     edx, ecx
    jb      loc_4082B9

    loc_408191:                             ; CODE XREF: sub_408100+63j
    mov     eax, [ebp+5Ch]
    test    eax, eax
    jz      short loc_4081A2
    test    byte ptr [eax+42h], 8
    jnz     loc_4082B9

    loc_4081A2:                             ; CODE XREF: sub_408100+96j
    mov     eax, [ebx+10h]
    push    ebp
    push    eax
    call    sub_40BDB0
    test    ax, ax
    jz      loc_4082B9
    mov     esi, eax
    lea     ecx, [esp+60h+var_30]
    and     esi, 0FFFFh
    push    ecx
    mov     eax, esi
    shl     eax, 6
    add     eax, esi
    lea     edx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1439Bh]
    mov     eax, [ebx+10h]
    add     ecx, edx
    lea     edx, [ebp+6Ah]
    push    ecx
    push    edx
    push    eax
    call    sub_40BFE0
    mov     ecx, [ebp+92h]
    mov     ebx, eax
    mov     edx, [ecx+245h]
    shr     edx, 0Ch
    test    dl, 1
    jz      loc_408286
    mov     eax, TAdynmemStructPtr
    mov     [esp+60h+var_20], 0
    mov     ecx, [eax+1422Bh]
    mov     edx, [eax+1422Fh]
    add     ecx, edx
    mov     eax, 55555556h
    imul    ecx
    mov     eax, edx
    mov     ecx, [esp+60h+var_2C]
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, [esp+60h+var_3C]
    mov     edi, edx
    mov     edx, [esp+60h+var_30]
    sub     edx, eax
    mov     eax, [esp+60h+var_28]
    mov     [esp+60h+var_24], edx
    mov     edx, [esp+60h+var_34]
    fild    [esp+60h+var_24]
    fild    [esp+60h+var_20]
    sub     eax, edx
    mov     [esp+60h+var_38], ecx
    mov     [esp+60h+var_1C], eax
    fild    [esp+60h+var_1C]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    shl     edi, 10h
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    cmp     eax, edi
    fstp    st
    jle     short loc_408282
    xor     ebx, ebx

    loc_408282:                             ; CODE XREF: sub_408100+17Ej
    mov     edi, [esp+60h+var_4C]

    loc_408286:                             ; CODE XREF: sub_408100+FBj
    test    ebx, ebx
    jz      short loc_4082B5
    lea     ecx, [esp+60h+var_30]
    lea     edx, [esp+60h+var_44]
    push    ecx
    push    0
    push    ebp
    push    0Eh
    push    edx
    call    sub_43F0E0
    mov     ecx, [esp+60h+var_44]
    push    1
    lea     eax, [esp+64h+var_30]
    push    esi
    push    eax
    push    0
    push    ebp
    push    0
    push    ecx
    call    sub_43ADC0

    loc_4082B5:                             ; CODE XREF: sub_408100+188j
    mov     ebx, [esp+60h+var_48]

    loc_4082B9:                             ; CODE XREF: sub_408100+51j
                                            ; sub_408100+71j ...
    mov     edx, [ebx+8]
    add     edi, 4
    mov     [esp+60h+var_4C], edi
    cmp     edi, [edx+18h]
    jnz     loc_408141

    loc_4082CC:                             ; CODE XREF: sub_408100+3Bj
    mov     eax, [ebx+8]
    mov     edi, [eax+14h]
    mov     ecx, [eax+18h]
    cmp     edi, ecx
    mov     [esp+60h+var_4C], edi
    jz      loc_4085BD

    loc_4082E1:                             ; CODE XREF: sub_408100+4B7j
    mov     esi, [edi]
    mov     eax, [esi+5Ch]
    test    eax, eax
    jz      short loc_4082F6
    mov     ecx, [eax+42h]
    test    ch, 40h
    jz      loc_4085AA

    loc_4082F6:                             ; CODE XREF: sub_408100+1E8j
    mov     eax, [esi+92h]
    mov     ecx, [eax+245h]
    shr     ecx, 0Ch
    test    cl, 1
    jz      short loc_40831C
    mov     edx, [ebx+10h]
    push    edx
    call    sub_40C230
    cmp     eax, 5
    jl      loc_4085AA

    loc_40831C:                             ; CODE XREF: sub_408100+208j
    mov     eax, [esp+60h+var_3C]
    mov     edi, [esp+60h+var_38]
    mov     edx, [esp+60h+var_34]
    mov     [esp+60h+var_30], eax
    mov     [esp+60h+var_2C], edi
    mov     [esp+60h+var_28], edx
    mov     ecx, [esi+92h]
    mov     ecx, [ecx+245h]
    shr     ecx, 0Ch
    test    cl, 1
    jz      loc_408461
    mov     ecx, [esi+6Eh]
    mov     [esp+60h+var_38], ecx
    mov     ebp, [esi+6Ah]
    mov     ebx, [esi+6Eh]
    mov     edi, [esi+72h]
    sub     eax, ebp
    sub     ecx, ebx
    mov     [esp+60h+var_18], eax
    mov     [esp+60h+var_14], ecx
    fild    [esp+60h+var_18]
    fild    [esp+60h+var_14]
    sub     edx, edi
    mov     edi, eax
    mov     [esp+60h+var_10], edx
    mov     ebp, ecx
    fild    [esp+60h+var_10]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    mov     ebx, edx
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    cmp     eax, 2800000h
    fstp    st
    jle     short loc_4083D6
    push    10000h                          ; int
    call    GetRandom
    mov     ebx, eax
    push    2800000h
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     edi, eax
    neg     edi
    push    2800000h
    push    ebx
    xor     ebp, ebp
    call    sub_4B7123
    add     esp, 8
    neg     eax
    mov     ebx, eax

    loc_4083D6:                             ; CODE XREF: sub_408100+2A2j
    mov     edx, [esp+60h+var_3C]
    mov     eax, [esp+60h+var_38]
    mov     ecx, [esp+60h+var_34]
    add     edi, edx
    lea     edx, [esp+60h+var_30]
    add     ebp, eax
    push    edx
    push    0
    push    esi
    lea     eax, [esp+1Eh]
    add     ebx, ecx
    push    2
    push    eax
    mov     [esp+74h+var_30], edi
    mov     [esp+74h+var_2C], ebp
    mov     [esp+74h+var_28], ebx
    call    sub_43F0E0
    mov     cl, [eax]
    push    0
    lea     edx, [esp+64h+var_30]
    push    0
    push    edx
    mov     byte ptr [esp+6Ch+var_44], cl
    mov     eax, [esp+6Ch+var_44]
    push    0
    push    esi
    push    0
    push    eax
    call    sub_43ADC0
    lea     ecx, [esp+60h+var_3C]
    lea     edx, [esp+13h]
    push    ecx
    push    0
    push    esi
    push    9
    push    edx
    call    sub_43F0E0
    mov     al, [eax]
    push    0
    lea     ecx, [esp+64h+var_3C]
    push    0
    push    ecx
    mov     byte ptr [esp+6Ch+var_44], al
    mov     edx, [esp+6Ch+var_44]
    push    0
    push    esi
    push    1
    push    edx
    call    sub_43ADC0
    mov     ebx, [esp+60h+var_48]
    jmp     loc_4085A6
    ; ---------------------------------------------------------------------------

    loc_408461:                             ; CODE XREF: sub_408100+246j
    sub     eax, [esi+6Ah]
    mov     ebp, eax
    mov     eax, [esi+6Eh]
    sub     edi, eax
    mov     [esp+60h+var_C], ebp
    fild    [esp+60h+var_C]
    mov     eax, edi
    mov     edi, [esi+72h]
    mov     [esp+60h+var_8], eax
    sub     edx, edi
    fild    [esp+60h+var_8]
    mov     [esp+60h+var_4], edx
    mov     [esp+60h+var_24], ebp
    fild    [esp+60h+var_4]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    mov     [esp+60h+var_20], eax
    mov     [esp+60h+var_1C], edx
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    cmp     eax, 1400000h
    fstp    st
    jge     loc_40857A
    cmp     eax, 100000h
    jge     short loc_4084F7
    push    10000h                          ; int
    call    GetRandom
    mov     edi, eax
    push    1400000h
    push    edi
    call    sub_4B70EF
    add     esp, 8
    mov     ebp, eax
    neg     ebp
    push    1400000h
    push    edi
    xor     ebx, ebx
    call    sub_4B7123
    add     esp, 8
    neg     eax
    jmp     short loc_40855B
    ; ---------------------------------------------------------------------------

    loc_4084F7:                             ; CODE XREF: sub_408100+3C3j
    cdq
    push    edx
    push    eax
    push    140h
    push    0
    call    __alldiv
    cdq
    mov     edi, eax
    mov     eax, ebp
    mov     ebx, edx
    cdq
    push    edx
    push    eax
    push    ebx
    push    edi
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ebp, eax
    mov     eax, [esp+60h+var_20]
    cdq
    push    ebx
    push    edi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esp+60h+var_20], eax
    mov     eax, [esp+60h+var_1C]
    cdq
    push    ebx
    push    edi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ebx, [esp+60h+var_20]

    loc_40855B:                             ; CODE XREF: sub_408100+3F5j
    mov     edi, [esi+6Ah]
    mov     ecx, [esi+6Eh]
    mov     edx, [esi+72h]
    add     ebp, edi
    add     ecx, ebx
    mov     ebx, [esp+60h+var_48]
    add     edx, eax
    mov     [esp+60h+var_30], ebp
    mov     [esp+60h+var_2C], ecx
    mov     [esp+60h+var_28], edx

    loc_40857A:                             ; CODE XREF: sub_408100+3B8j
    lea     eax, [esp+60h+var_30]
    lea     ecx, [esp+60h+var_40]
    push    eax
    push    0
    push    esi
    push    9
    push    ecx
    call    sub_43F0E0
    mov     eax, [esp+60h+var_40]
    push    0
    lea     edx, [esp+64h+var_30]
    push    0
    push    edx
    push    0
    push    esi
    push    0
    push    eax
    call    sub_43ADC0

    loc_4085A6:                             ; CODE XREF: sub_408100+35Cj
    mov     edi, [esp+60h+var_4C]

    loc_4085AA:                             ; CODE XREF: sub_408100+1F0j
                                            ; sub_408100+216j
    mov     ecx, [ebx+8]
    add     edi, 4
    mov     [esp+60h+var_4C], edi
    cmp     edi, [ecx+18h]
    jnz     loc_4082E1

    loc_4085BD:                             ; CODE XREF: sub_408100+1DBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 50h
    retn
    sub_408100 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+8]
    mov     eax, ecx
    mov     ecx, [esp+4]
    mov     [eax+8], edx
    xor     edx, edx
    mov     [eax+4], ecx
    mov     dword ptr [eax+0Ch], 0
    mov     dl, [ecx+4]
    mov     dword ptr [eax], offset off_4FC9A8
    mov     [eax+10h], edx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_408600 proc near                    ; DATA XREF: .rdata:004FC9ACo

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FC980
    jz      short loc_40861A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_40861A:                             ; CODE XREF: sub_408600+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_408600 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_408620(int)
    sub_408620 proc near

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    mov     eax, [esi+5Ch]
    test    eax, eax
    jnz     short loc_408663
    mov     eax, [ecx+10h]
    push    esi
    push    eax
    call    sub_40BDB0
    test    ax, ax
    jz      short loc_408663
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFFFh
    mov     ecx, eax
    push    1                               ; int
    shl     eax, 6
    add     eax, ecx
    push    esi                             ; int
    lea     ecx, [eax+eax*8]
    mov     eax, [edx+TAdynmemStruct.UnitDef]
    lea     ecx, [ecx+eax+20h]
    push    ecx                             ; char *
    call    sub_419B00

    loc_408663:                             ; CODE XREF: sub_408620+Aj
                                            ; sub_408620+19j
    pop     esi
    retn    4
    sub_408620 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_408670 proc near

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    mov     ecx, [esi+96h]
    fld     dword ptr [ecx+98h]
    fadd    st, st
    fcomp   dword ptr [ecx+8Ch]
    fnstsw  ax
    test    ah, 1
    jz      short loc_4086BD
    push    ecx
    call    sub_464AD0
    fcomp   ds:flt_4FC968
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4086C8
    push    5                               ; int
    call    GetRandom
    test    eax, eax
    jz      short loc_4086C8
    push    1                               ; int
    push    1                               ; idTo
    mov     ecx, esi
    call    sub_48B090
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4086BD:                             ; CODE XREF: sub_408670+1Ej
    push    0                               ; int
    push    1                               ; idTo
    mov     ecx, esi
    call    sub_48B090

    loc_4086C8:                             ; CODE XREF: sub_408670+31j
                                            ; sub_408670+3Cj
    pop     esi
    retn    4
    sub_408670 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4086D0 proc near                    ; DATA XREF: .rdata:004FC9B0o
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, ecx
    push    edi
    mov     ecx, [eax+TAdynmemStruct.GameTime]
    mov     eax, [ebx+8]
    add     ecx, 1Eh
    mov     [ebx+0Ch], ecx
    mov     edi, [eax+14h]
    mov     ecx, [eax+18h]
    cmp     edi, ecx
    jz      loc_4087D9
    push    esi

    loc_4086F7:                             ; CODE XREF: sub_4086D0+102j
    mov     esi, [edi]
    mov     eax, [esi+110h]
    test    eax, 20000000h
    jz      loc_4087C9
    test    eax, 10000000h
    jz      loc_4087C9
    test    ah, 40h
    jnz     loc_4087C9
    mov     eax, [esi+92h]
    mov     cl, [eax+22Dh]
    test    cl, cl
    jz      short loc_408781
    mov     ecx, [esi+96h]
    fld     dword ptr [ecx+98h]
    fadd    st, st
    fcomp   dword ptr [ecx+8Ch]
    fnstsw  ax
    test    ah, 1
    jz      short loc_408774
    push    ecx
    call    sub_464AD0
    fcomp   ds:flt_4FC968
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4087C9
    push    5                               ; int
    call    GetRandom
    test    eax, eax
    jz      short loc_4087C9
    push    1                               ; int
    push    1                               ; idTo
    mov     ecx, esi
    call    sub_48B090
    jmp     short loc_4087C9
    ; ---------------------------------------------------------------------------

    loc_408774:                             ; CODE XREF: sub_4086D0+77j
    push    0                               ; int
    push    1                               ; idTo
    mov     ecx, esi
    call    sub_48B090
    jmp     short loc_4087C9
    ; ---------------------------------------------------------------------------

    loc_408781:                             ; CODE XREF: sub_4086D0+5Cj
    mov     ecx, [eax+152h]
    test    ecx, ecx
    jz      short loc_4087C9
    mov     eax, [esi+5Ch]
    test    eax, eax
    jnz     short loc_4087C9
    mov     edx, [ebx+10h]
    push    esi
    push    edx
    call    sub_40BDB0
    test    ax, ax
    jz      short loc_4087C9
    and     eax, 0FFFFh
    push    1                               ; int
    mov     ecx, eax
    push    esi                             ; int
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+TAdynmemStruct.UnitDef]
    lea     eax, [eax+eax*8]
    lea     eax, [edx+eax+20h]
    push    eax                             ; char *
    call    sub_419B00

    loc_4087C9:                             ; CODE XREF: sub_4086D0+34j
                                            ; sub_4086D0+3Fj ...
    mov     ecx, [ebx+8]
    add     edi, 4
    cmp     edi, [ecx+18h]
    jnz     loc_4086F7
    pop     esi

    loc_4087D9:                             ; CODE XREF: sub_4086D0+20j
    pop     edi
    pop     ebx
    retn
    sub_4086D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4087E0 proc near

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     [eax+8], edx
    xor     edx, edx
    mov     [eax+4], ecx
    mov     dword ptr [eax+0Ch], 0
    mov     dl, [ecx+4]
    mov     dword ptr [eax], offset off_4FC9B0
    mov     [eax+10h], edx
    retn    8
    sub_4087E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_408810 proc near                    ; DATA XREF: .rdata:004FC9B4o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FC980
    jz      short loc_40882A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_40882A:                             ; CODE XREF: sub_408810+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_408810 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_408830 proc near                    ; CODE XREF: .text:00408C08p
                                            ; sub_408C40+28p
    push    ebp
    mov     ebp, ecx
    push    esi
    mov     eax, [ebp+0]
    mov     esi, [eax+67h]
    mov     ecx, [eax+6Bh]
    cmp     esi, ecx
    ja      loc_408912
    push    edi

    loc_408846:                             ; CODE XREF: sub_408830+DBj
    mov     eax, [esi+110h]
    test    al, 20h
    jz      loc_4088FF
    mov     ecx, [esi+92h]
    mov     edx, [ecx+245h]
    shr     edx, 0Ch
    test    dl, 1
    jz      short loc_408874
    and     eax, 0FFF7FFFFh
    or      eax, 40000h
    jmp     short loc_40887E
    ; ---------------------------------------------------------------------------

    loc_408874:                             ; CODE XREF: sub_408830+36j
    and     eax, 0FFFBFFFFh
    or      eax, 80000h

    loc_40887E:                             ; CODE XREF: sub_408830+42j
    mov     [esi+110h], eax
    and     eax, 0FFEFFFFFh
    or      eax, 200000h
    mov     [esi+110h], eax
    mov     eax, [esi+0ACh]
    test    eax, eax
    jnz     short loc_4088FF
    mov     edi, [esi+110h]
    test    edi, 20000000h
    jz      short loc_4088BC
    test    edi, 80000000h
    jz      short loc_4088B8
    push    5
    jmp     short loc_4088F9
    ; ---------------------------------------------------------------------------

    loc_4088B8:                             ; CODE XREF: sub_408830+82j
    push    1
    jmp     short loc_4088F9
    ; ---------------------------------------------------------------------------

    loc_4088BC:                             ; CODE XREF: sub_408830+7Aj
    mov     ecx, [esi+92h]
    mov     eax, [ecx+241h]
    mov     edx, eax
    shr     edx, 6
    test    dl, 1
    jz      short loc_4088D6
    push    4
    jmp     short loc_4088F9
    ; ---------------------------------------------------------------------------

    loc_4088D6:                             ; CODE XREF: sub_408830+A0j
    shr     eax, 0Bh
    test    al, 1
    jz      short loc_4088E1
    push    8
    jmp     short loc_4088F9
    ; ---------------------------------------------------------------------------

    loc_4088E1:                             ; CODE XREF: sub_408830+ABj
    cmp     word ptr [ecx+1C0h], 0
    jle     short loc_4088EF
    push    7
    jmp     short loc_4088F9
    ; ---------------------------------------------------------------------------

    loc_4088EF:                             ; CODE XREF: sub_408830+B9j
    test    edi, 80000000h
    jz      short loc_4088FF
    push    3

    loc_4088F9:                             ; CODE XREF: sub_408830+86j
                                            ; sub_408830+8Aj ...
    push    esi
    call    sub_480250

    loc_4088FF:                             ; CODE XREF: sub_408830+1Ej
                                            ; sub_408830+6Cj ...
    mov     eax, [ebp+0]
    add     esi, 118h
    cmp     esi, [eax+6Bh]
    jbe     loc_408846
    pop     edi

    loc_408912:                             ; CODE XREF: sub_408830+Fj
    pop     esi
    pop     ebp
    retn
    sub_408830 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+0Ch]
    mov     eax, esi
    push    edi
    mov     edi, [esp+0Ch]
    shl     eax, 3
    sub     eax, esi
    mov     ecx, [edi+eax*4+10h]
    mov     edx, [ecx+111h]
    shr     edx, 1Eh
    test    dl, 1
    jz      short loc_40895E
    push    esi
    push    edi
    call    sub_49D120
    test    eax, eax
    push    esi
    jz      short loc_40898A
    add     eax, 4
    push    eax
    push    edi
    call    sub_48A0A0
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40895E:                             ; CODE XREF: .text:00408941j
    mov     eax, [edi+110h]
    and     eax, 300000h
    cmp     eax, 200000h
    jnz     short loc_408990
    push    1
    push    esi
    push    edi
    call    sub_40B7B0
    test    eax, eax
    push    esi
    jz      short loc_40898A
    push    eax
    push    edi
    call    sub_48A060
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40898A:                             ; CODE XREF: .text:0040894Dj
                                            ; .text:0040897Cj
    push    edi
    call    sub_48A0F0

    loc_408990:                             ; CODE XREF: .text:0040896Ej
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4089A0(int)
    sub_4089A0 proc near                    ; CODE XREF: sub_408C40+5Ap
                                            ; sub_408C40+67p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 10h
    mov     eax, TAdynmemStructPtr
    push    ebp
    mov     ebp, ecx
    mov     [esp+14h+var_4], 0
    xor     ecx, ecx
    mov     [esp+14h+var_10], ebp
    mov     cx, [eax+37EE6h]
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 4
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    js      loc_408BDB
    push    edi
    push    esi
    push    ebx

    loc_4089DC:                             ; CODE XREF: sub_4089A0+232j
    mov     eax, [ebp+39h]
    test    eax, eax
    jz      short loc_4089F5
    mov     edx, [ebp+0]
    cmp     eax, [edx+6Bh]
    jz      short loc_4089F5
    add     eax, 118h
    mov     [ebp+39h], eax
    jmp     short loc_4089FE
    ; ---------------------------------------------------------------------------

    loc_4089F5:                             ; CODE XREF: sub_4089A0+41j
                                            ; sub_4089A0+49j
    mov     eax, [ebp+0]
    mov     ecx, [eax+67h]
    mov     [ebp+39h], ecx

    loc_4089FE:                             ; CODE XREF: sub_4089A0+53j
    mov     ecx, [ebp+39h]
    cmp     word ptr [ecx+0A6h], 0
    jz      loc_408BA6
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FC968
    fnstsw  ax
    test    ah, 40h
    jz      loc_408BA6
    mov     eax, [ecx+110h]
    test    eax, 80000000h
    jz      loc_408BA6
    and     eax, 300000h
    cmp     eax, 200000h
    jnz     loc_408BA6
    xor     edi, edi
    xor     ebx, ebx
    mov     [esp+20h+var_C], ebx
    mov     [esp+20h+var_8], 3

    loc_408A57:                             ; CODE XREF: sub_4089A0+200j
    mov     eax, [ebp+39h]
    mov     cl, [ebx+eax+1Fh]
    test    cl, 2
    jz      loc_408B8F
    test    cl, 10h
    jz      loc_408B8F
    mov     edx, [ebx+eax+10h]
    mov     ecx, [edx+111h]
    mov     edx, ecx
    shr     edx, 8
    test    dl, 1
    jnz     loc_408B8F
    mov     edx, [esp+20h+arg_0]
    test    edx, edx
    jnz     short loc_408A9C
    test    ecx, 4000000h
    jnz     loc_408B8F

    loc_408A9C:                             ; CODE XREF: sub_4089A0+EEj
    push    edi
    push    eax
    call    sub_48A190
    test    eax, eax
    jz      loc_408B31
    mov     ecx, [eax+96h]
    xor     edx, edx
    mov     dl, [ecx+146h]
    mov     ecx, [ebp+0]
    cmp     byte ptr [edx+ecx+108h], 0
    jnz     short loc_408B25
    mov     cx, [eax+0A6h]
    mov     edx, [ebp+39h]
    and     ecx, 0FFFFh
    mov     ebp, 1
    mov     esi, [edx+92h]
    mov     ebx, ecx
    and     ecx, 1Fh
    mov     esi, [esi+edi*4+231h]
    shr     ebx, 5
    shl     ebp, cl
    test    [esi+ebx*4], ebp
    jnz     short loc_408B19
    mov     ebx, [esp+20h+var_C]
    mov     edx, [ebx+edx+10h]
    test    byte ptr [edx+111h], 80h
    jz      short loc_408B29
    test    byte ptr [eax+10Eh], 10h
    jz      short loc_408B29
    mov     ebp, [esp+20h+var_10]
    xor     eax, eax
    jmp     short loc_408B2D
    ; ---------------------------------------------------------------------------

    loc_408B19:                             ; CODE XREF: sub_4089A0+155j
    mov     ebp, [esp+20h+var_10]
    mov     ebx, [esp+20h+var_C]
    xor     eax, eax
    jmp     short loc_408B2D
    ; ---------------------------------------------------------------------------

    loc_408B25:                             ; CODE XREF: sub_4089A0+124j
    xor     eax, eax
    jmp     short loc_408B2D
    ; ---------------------------------------------------------------------------

    loc_408B29:                             ; CODE XREF: sub_4089A0+166j
                                            ; sub_4089A0+16Fj
    mov     ebp, [esp+20h+var_10]

    loc_408B2D:                             ; CODE XREF: sub_4089A0+177j
                                            ; sub_4089A0+183j ...
    test    eax, eax
    jnz     short loc_408B8F

    loc_408B31:                             ; CODE XREF: sub_4089A0+105j
    mov     esi, [ebp+39h]
    mov     eax, [esi+ebx+10h]
    mov     ecx, [eax+111h]
    shr     ecx, 1Eh
    test    cl, 1
    jz      short loc_408B5E
    push    edi
    push    esi
    call    sub_49D120
    test    eax, eax
    push    edi
    jz      short loc_408B89
    add     eax, 4
    push    eax
    push    esi
    call    sub_48A0A0
    jmp     short loc_408B8F
    ; ---------------------------------------------------------------------------

    loc_408B5E:                             ; CODE XREF: sub_4089A0+1A4j
    mov     edx, [esi+110h]
    and     edx, 300000h
    cmp     edx, 200000h
    jnz     short loc_408B8F
    push    1
    push    edi
    push    esi
    call    sub_40B7B0
    test    eax, eax
    push    edi
    jz      short loc_408B89
    push    eax
    push    esi
    call    sub_48A060
    jmp     short loc_408B8F
    ; ---------------------------------------------------------------------------

    loc_408B89:                             ; CODE XREF: sub_4089A0+1B0j
                                            ; sub_4089A0+1DEj
    push    esi
    call    sub_48A0F0

    loc_408B8F:                             ; CODE XREF: sub_4089A0+C1j
                                            ; sub_4089A0+CAj ...
    mov     eax, [esp+20h+var_8]
    inc     edi
    add     ebx, 1Ch
    dec     eax
    mov     [esp+20h+var_C], ebx
    mov     [esp+20h+var_8], eax
    jnz     loc_408A57

    loc_408BA6:                             ; CODE XREF: sub_4089A0+69j
                                            ; sub_4089A0+80j ...
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, [esp+20h+var_4]
    mov     cx, [eax+37EE6h]
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    inc     esi
    sar     edx, 4
    mov     ecx, edx
    mov     [esp+20h+var_4], esi
    shr     ecx, 1Fh
    add     edx, ecx
    cmp     esi, edx
    jle     loc_4089DC
    pop     ebx
    pop     esi
    pop     edi

    loc_408BDB:                             ; CODE XREF: sub_4089A0+33j
    pop     ebp
    add     esp, 10h
    retn    4
    sub_4089A0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, ecx
    push    edi
    mov     edx, [esi+5]
    dec     edx
    mov     eax, edx
    mov     [esi+5], edx
    test    eax, eax
    jg      short loc_408C0D
    mov     dword ptr [esi+5], 1Eh
    call    sub_408830

    loc_408C0D:                             ; CODE XREF: .text:00408BFFj
    add     esi, 11h
    mov     edi, 0Ah

    loc_408C15:                             ; CODE XREF: .text:00408C34j
    mov     ecx, [esi]
    test    ecx, ecx
    jz      short loc_408C30
    mov     edx, TAdynmemStructPtr
    mov     eax, [ecx+0Ch]
    cmp     eax, [edx+38A47h]
    ja      short loc_408C30
    mov     eax, [ecx]
    call    dword ptr [eax]

    loc_408C30:                             ; CODE XREF: .text:00408C19j
                                            ; .text:00408C2Aj
    add     esi, 4
    dec     edi
    jnz     short loc_408C15
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_408C40()
    sub_408C40 proc near                    ; CODE XREF: UpdateDatePlayers+B1p
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    mov     eax, [edi]
    cmp     dword ptr [eax], 0
    jz      short loc_408CA3
    cmp     [eax+PlayerStruct.PlayerType], Player_AI
    jnz     short loc_408CA3
    mov     ecx, [edi+5]
    dec     ecx
    mov     eax, ecx
    mov     [edi+5], ecx
    test    eax, eax
    jg      short loc_408C6D
    mov     ecx, edi
    mov     dword ptr [edi+5], 1Eh
    call    sub_408830

    loc_408C6D:                             ; CODE XREF: sub_408C40+1Dj
    lea     esi, [edi+11h]
    mov     ebx, 0Ah

    loc_408C75:                             ; CODE XREF: sub_408C40+54j
    mov     ecx, [esi]
    test    ecx, ecx
    jz      short loc_408C90
    mov     edx, TAdynmemStructPtr
    mov     eax, [ecx+0Ch]
    cmp     eax, [edx+TAdynmemStruct.GameTime]
    ja      short loc_408C90
    mov     eax, [ecx]
    call    dword ptr [eax]

    loc_408C90:                             ; CODE XREF: sub_408C40+39j
                                            ; sub_408C40+4Aj
    add     esi, 4
    dec     ebx
    jnz     short loc_408C75
    push    1                               ; int
    mov     ecx, edi
    call    sub_4089A0
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_408CA3:                             ; CODE XREF: sub_408C40+Aj
                                            ; sub_408C40+10j
    push    0                               ; int
    mov     ecx, edi
    call    sub_4089A0
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_408C40 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_408CB0 proc near                    ; CODE XREF: sub_464700+1B8p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    xor     ebx, ebx
    mov     [esi], eax
    mov     al, [eax+146h]
    mov     [esi+4], al
    lea     edi, [esi+11h]
    mov     ecx, 0Ah
    xor     eax, eax
    mov     [esi+9], ebx
    mov     dword ptr [esi+5], 1Eh
    mov     [esi+39h], ebx
    mov     [esi+0Dh], ebx
    rep stosd
    push    14h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_408D11
    mov     ecx, [esi]
    mov     ecx, [ecx+78h]
    mov     [eax+4], esi
    add     ecx, 20h
    xor     edx, edx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ebx
    mov     dl, [esi+4]
    mov     dword ptr [eax], offset off_4FC9B0
    mov     [eax+10h], edx
    jmp     short loc_408D13
    ; ---------------------------------------------------------------------------

    loc_408D11:                             ; CODE XREF: sub_408CB0+3Ej
    xor     eax, eax

    loc_408D13:                             ; CODE XREF: sub_408CB0+5Fj
    push    14h                             ; int
    mov     [esi+15h], eax
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_408D48
    mov     ecx, [esi]
    mov     ecx, [ecx+78h]
    mov     [eax+4], esi
    add     ecx, 80h
    xor     edx, edx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ebx
    mov     dl, [esi+4]
    mov     dword ptr [eax], offset off_4FC9A8
    mov     [eax+10h], edx
    jmp     short loc_408D4A
    ; ---------------------------------------------------------------------------

    loc_408D48:                             ; CODE XREF: sub_408CB0+72j
    xor     eax, eax

    loc_408D4A:                             ; CODE XREF: sub_408CB0+96j
    push    14h                             ; int
    mov     [esi+21h], eax
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_408D7F
    mov     ecx, [esi]
    mov     ecx, [ecx+78h]
    mov     [eax+4], esi
    add     ecx, 0A0h
    xor     edx, edx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ebx
    mov     dl, [esi+4]
    mov     dword ptr [eax], offset off_4FC980
    mov     [eax+10h], edx
    jmp     short loc_408D81
    ; ---------------------------------------------------------------------------

    loc_408D7F:                             ; CODE XREF: sub_408CB0+A9j
    xor     eax, eax

    loc_408D81:                             ; CODE XREF: sub_408CB0+CDj
    push    28h                             ; int
    mov     [esi+25h], eax
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    mov     edi, 3
    jz      short loc_408DCF
    mov     ecx, [esi]
    mov     ecx, [ecx+78h]
    mov     [eax+4], esi
    add     ecx, 40h
    xor     edx, edx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ebx
    mov     dl, [esi+4]
    mov     dword ptr [eax+1Ch], 4E20h
    mov     [eax+10h], edx
    mov     [eax+20h], edi
    mov     dword ptr [eax], offset off_4FC988
    mov     [eax+24h], ebx
    mov     dword ptr [eax+18h], 6
    mov     [eax+14h], edi
    jmp     short loc_408DD1
    ; ---------------------------------------------------------------------------

    loc_408DCF:                             ; CODE XREF: sub_408CB0+E5j
    xor     eax, eax

    loc_408DD1:                             ; CODE XREF: sub_408CB0+11Dj
    push    18h                             ; int
    mov     [esi+19h], eax
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_408E0A
    mov     ecx, [esi]
    mov     ecx, [ecx+78h]
    mov     [eax+4], esi
    add     ecx, 60h
    xor     edx, edx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ebx
    mov     dl, [esi+4]
    mov     dword ptr [eax+14h], 2
    mov     [eax+10h], edx
    mov     dword ptr [eax], offset off_4FC990
    jmp     short loc_408E0C
    ; ---------------------------------------------------------------------------

    loc_408E0A:                             ; CODE XREF: sub_408CB0+130j
    xor     eax, eax

    loc_408E0C:                             ; CODE XREF: sub_408CB0+158j
    push    28h                             ; int
    mov     [esi+1Dh], eax
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_408E5C
    mov     ecx, [esi]
    mov     ecx, [ecx+78h]
    mov     [eax+4], esi
    add     ecx, 0C0h
    xor     edx, edx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ebx
    mov     dl, [esi+4]
    mov     dword ptr [eax+1Ch], 0C350h
    mov     [eax+10h], edx
    mov     dword ptr [eax+20h], 7
    mov     dword ptr [eax], offset off_4FC988
    mov     [eax+24h], ebx
    mov     dword ptr [eax+18h], 6
    mov     [eax+14h], edi
    jmp     short loc_408E5E
    ; ---------------------------------------------------------------------------

    loc_408E5C:                             ; CODE XREF: sub_408CB0+16Bj
    xor     eax, eax

    loc_408E5E:                             ; CODE XREF: sub_408CB0+1AAj
    push    18h                             ; int
    mov     [esi+29h], eax
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_408E9A
    mov     ecx, [esi]
    mov     ecx, [ecx+78h]
    mov     [eax+4], esi
    add     ecx, 0E0h
    xor     edx, edx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ebx
    mov     dl, [esi+4]
    mov     dword ptr [eax+14h], 6
    mov     [eax+10h], edx
    mov     dword ptr [eax], offset off_4FC990
    jmp     short loc_408E9C
    ; ---------------------------------------------------------------------------

    loc_408E9A:                             ; CODE XREF: sub_408CB0+1BDj
    xor     eax, eax

    loc_408E9C:                             ; CODE XREF: sub_408CB0+1E8j
    push    14h                             ; int
    mov     [esi+2Dh], eax
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    cmp     edi, ebx
    jz      short loc_408ECB
    mov     eax, [esi]
    mov     ecx, [eax+78h]
    add     ecx, 100h
    push    ecx
    push    esi
    mov     ecx, edi
    call    sub_407350
    mov     dword ptr [edi], offset off_4FC998
    jmp     short loc_408ECD
    ; ---------------------------------------------------------------------------

    loc_408ECB:                             ; CODE XREF: sub_408CB0+1FDj
    xor     edi, edi

    loc_408ECD:                             ; CODE XREF: sub_408CB0+219j
    push    3Ch                             ; int
    mov     [esi+31h], edi
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_408EFD
    mov     edx, [esi]
    mov     ecx, [edx+78h]
    add     ecx, 120h
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_407D40
    mov     [esi+35h], eax
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_408EFD:                             ; CODE XREF: sub_408CB0+22Cj
    xor     eax, eax
    pop     edi
    mov     [esi+35h], eax
    mov     eax, esi
    pop     esi
    pop     ebx
    retn    4
    sub_408CB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_408F10 proc near                    ; CODE XREF: sub_464A00+5Dp
    push    esi
    push    edi
    lea     esi, [ecx+11h]
    mov     edi, 0Ah

    loc_408F1A:                             ; CODE XREF: sub_408F10+1Bj
    mov     ecx, [esi]
    test    ecx, ecx
    jz      short loc_408F27
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax+4]

    loc_408F27:                             ; CODE XREF: sub_408F10+Ej
    add     esi, 4
    dec     edi
    jnz     short loc_408F1A
    pop     edi
    pop     esi
    retn
    sub_408F10 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_408F30 proc near                    ; CODE XREF: sub_407560+226p
                                            ; sub_40AA40+F6p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ebp, [esp+10h+arg_4]
    mov     ecx, [ebx+8]
    mov     eax, [ebx+0Ch]
    sub     eax, ecx
    push    esi
    sar     eax, 2
    cmp     eax, ebp
    push    edi
    mov     [esp+18h+var_8], ebx
    jnb     loc_409072
    mov     edx, [ebx+4]
    test    edx, edx
    jnz     short loc_408F5F
    xor     eax, eax
    jmp     short loc_408F66
    ; ---------------------------------------------------------------------------

    loc_408F5F:                             ; CODE XREF: sub_408F30+29j
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2

    loc_408F66:                             ; CODE XREF: sub_408F30+2Dj
    cmp     ebp, eax
    jnb     short loc_408F7B
    test    edx, edx
    jnz     short loc_408F72
    xor     eax, eax
    jmp     short loc_408F7D
    ; ---------------------------------------------------------------------------

    loc_408F72:                             ; CODE XREF: sub_408F30+3Cj
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2
    jmp     short loc_408F7D
    ; ---------------------------------------------------------------------------

    loc_408F7B:                             ; CODE XREF: sub_408F30+38j
    mov     eax, ebp

    loc_408F7D:                             ; CODE XREF: sub_408F30+40j
                                            ; sub_408F30+49j
    test    edx, edx
    jnz     short loc_408F85
    xor     ecx, ecx
    jmp     short loc_408F8A
    ; ---------------------------------------------------------------------------

    loc_408F85:                             ; CODE XREF: sub_408F30+4Fj
    sub     ecx, edx
    sar     ecx, 2

    loc_408F8A:                             ; CODE XREF: sub_408F30+53j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_408F96
    xor     eax, eax

    loc_408F96:                             ; CODE XREF: sub_408F30+62j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebx+4]
    mov     ebx, [esp+1Ch+arg_0]
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_408FC9

    loc_408FB7:                             ; CODE XREF: sub_408F30+97j
    test    edx, edx
    jz      short loc_408FBF
    mov     ecx, [eax]
    mov     [edx], ecx

    loc_408FBF:                             ; CODE XREF: sub_408F30+89j
    add     eax, 4
    add     edx, 4
    cmp     eax, ebx
    jnz     short loc_408FB7

    loc_408FC9:                             ; CODE XREF: sub_408F30+85j
    test    ebp, ebp
    mov     eax, edx
    jbe     short loc_408FE3
    mov     esi, [esp+18h+arg_8]
    mov     ecx, ebp

    loc_408FD5:                             ; CODE XREF: sub_408F30+B1j
    test    eax, eax
    jz      short loc_408FDD
    mov     edi, [esi]
    mov     [eax], edi

    loc_408FDD:                             ; CODE XREF: sub_408F30+A7j
    add     eax, 4
    dec     ecx
    jnz     short loc_408FD5

    loc_408FE3:                             ; CODE XREF: sub_408F30+9Dj
    mov     eax, [esp+18h+var_8]
    lea     edi, ds:0[ebp*4]
    mov     esi, [eax+8]
    lea     ecx, [edx+edi]
    cmp     ebx, esi
    jz      short loc_409011
    lea     eax, [ebx+ecx]
    sub     eax, edx
    sub     eax, edi

    loc_408FFF:                             ; CODE XREF: sub_408F30+DFj
    test    ecx, ecx
    jz      short loc_409007
    mov     edx, [eax]
    mov     [ecx], edx

    loc_409007:                             ; CODE XREF: sub_408F30+D1j
    add     eax, 4
    add     ecx, 4
    cmp     eax, esi
    jnz     short loc_408FFF

    loc_409011:                             ; CODE XREF: sub_408F30+C6j
    mov     eax, [esp+18h+var_8]
    mov     eax, [eax+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     esi, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+var_4]
    mov     edx, [esp+1Ch+var_8]
    add     esp, 4
    lea     eax, [esi+ecx*4]
    mov     ecx, [edx+4]
    mov     [edx+0Ch], eax
    test    ecx, ecx
    jnz     short loc_409055
    xor     eax, eax
    mov     [edx+4], esi
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_409055:                             ; CODE XREF: sub_408F30+10Cj
    mov     eax, [edx+8]
    mov     [edx+4], esi
    sub     eax, ecx
    sar     eax, 2
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_409072:                             ; CODE XREF: sub_408F30+1Ej
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, esi
    sar     edx, 2
    cmp     edx, ebp
    jnb     short loc_4090EC
    lea     edi, ds:0[ebp*4]
    cmp     esi, ecx
    lea     edx, [esi+edi]
    jz      short loc_4090A9
    mov     eax, edx
    sub     eax, edi

    loc_409093:                             ; CODE XREF: sub_408F30+177j
    test    edx, edx
    jz      short loc_40909F
    mov     ebx, [eax]
    mov     [edx], ebx
    mov     ebx, [esp+18h+var_8]

    loc_40909F:                             ; CODE XREF: sub_408F30+165j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_409093

    loc_4090A9:                             ; CODE XREF: sub_408F30+15Dj
    mov     eax, [ebx+8]
    mov     edx, [esp+18h+arg_8]
    mov     ecx, eax
    sub     ecx, esi
    sar     ecx, 2
    sub     ebp, ecx
    mov     ecx, ebp
    jz      short loc_4090CB

    loc_4090BD:                             ; CODE XREF: sub_408F30+199j
    test    eax, eax
    jz      short loc_4090C5
    mov     ebp, [edx]
    mov     [eax], ebp

    loc_4090C5:                             ; CODE XREF: sub_408F30+18Fj
    add     eax, 4
    dec     ecx
    jnz     short loc_4090BD

    loc_4090CB:                             ; CODE XREF: sub_408F30+18Bj
    mov     ecx, [ebx+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_409145

    loc_4090D4:                             ; CODE XREF: sub_408F30+1ADj
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4090D4
    add     [ebx+8], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4090EC:                             ; CODE XREF: sub_408F30+14Fj
    test    ebp, ebp
    jbe     short loc_409148
    lea     edi, ds:0[ebp*4]
    mov     eax, ecx
    sub     eax, edi
    mov     edx, ecx
    cmp     eax, ecx
    jz      short loc_409113

    loc_409101:                             ; CODE XREF: sub_408F30+1E1j
    test    edx, edx
    jz      short loc_409109
    mov     ebp, [eax]
    mov     [edx], ebp

    loc_409109:                             ; CODE XREF: sub_408F30+1D3j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_409101

    loc_409113:                             ; CODE XREF: sub_408F30+1CFj
    mov     ecx, [ebx+8]
    mov     eax, ecx
    sub     eax, edi
    cmp     esi, eax
    jz      short loc_40912D

    loc_40911E:                             ; CODE XREF: sub_408F30+1FBj
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, esi
    mov     [ecx], edx
    jnz     short loc_40911E

    loc_40912D:                             ; CODE XREF: sub_408F30+1ECj
    lea     ecx, [esi+edi]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_409145
    mov     edx, [esp+18h+arg_8]

    loc_40913A:                             ; CODE XREF: sub_408F30+213j
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_40913A

    loc_409145:                             ; CODE XREF: sub_408F30+1A2j
                                            ; sub_408F30+204j
    add     [ebx+8], edi

    loc_409148:                             ; CODE XREF: sub_408F30+1BEj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_408F30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_409160 proc near                    ; CODE XREF: sub_40B320+19p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     edx, [esp+4+arg_0]
    push    ebx
    push    ebp
    mov     eax, edx
    push    esi
    mov     esi, ecx
    and     eax, 0FFh
    push    edi
    mov     edi, TAdynmemStructPtr
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edi, eax
    mov     [esi+4], dl
    mov     dl, byte ptr [esp+14h+arg_0]
    lea     ecx, [ecx+ecx*4]
    xor     ebx, ebx
    lea     eax, [edi+ecx*2+1B63h]
    mov     cl, byte ptr [esp+14h+arg_0]
    mov     [esi], eax
    lea     eax, [esp+14h+arg_0]
    mov     [esi+5], cl
    mov     [esi+9], ebx
    mov     [esi+0Dh], ebx
    mov     [esi+11h], ebx
    push    eax
    lea     ecx, [esi+25h]
    mov     [esi+15h], dl
    mov     [esi+19h], ebx
    mov     [esi+1Dh], ebx
    mov     [esi+21h], ebx
    call    sub_40C510
    lea     edx, [esi+35h]
    xor     eax, eax
    xor     ecx, ecx
    lea     ebp, [esi+7Dh]
    mov     [edx], eax
    mov     [edx+4], ecx
    mov     [edx+8], ebx
    lea     edx, [esi+41h]
    mov     [esi+41h], eax
    mov     al, byte ptr [esp+14h+arg_0]
    mov     [edx+4], ecx
    mov     [edx+8], ebx
    mov     [esi+4Dh], al
    mov     [esi+51h], ebx
    mov     [esi+55h], ebx
    mov     [esi+59h], ebx
    mov     edi, TAdynmemStructPtr
    mov     eax, [edi+14237h]
    cdq
    sub     eax, edx
    mov     ecx, eax
    mov     eax, [edi+14233h]
    cdq
    sar     ecx, 1
    sub     eax, edx
    mov     dl, byte ptr [esp+14h+arg_0]
    sar     eax, 1
    mov     [esi+5Fh], cx
    mov     cl, byte ptr [esp+14h+arg_0]
    mov     [esi+61h], ebx
    mov     [esi+5Dh], ax
    mov     al, byte ptr [esp+14h+arg_0]
    mov     [esi+65h], cl
    mov     cl, byte ptr [esp+14h+arg_0]
    mov     [esi+69h], ebx
    mov     [esi+6Dh], ebx
    mov     [esi+71h], ebx
    mov     [esi+75h], ebx
    lea     edi, [esi+9Dh]
    mov     [ebp+0], dl
    mov     [ebp+4], ebx
    mov     [ebp+8], ebx
    mov     [ebp+0Ch], ebx
    mov     [esi+8Dh], al
    mov     [esi+91h], ebx
    mov     [esi+95h], ebx
    mov     [esi+99h], ebx
    mov     [edi], cl
    mov     [edi+4], ebx
    mov     dl, byte ptr [esp+14h+arg_0]
    mov     al, byte ptr [esp+14h+arg_0]
    mov     cl, byte ptr [esp+14h+arg_0]
    mov     [edi+8], ebx
    mov     [edi+0Ch], ebx
    mov     [esi+0ADh], dl
    mov     dl, byte ptr [esp+14h+arg_0]
    mov     [esi+0B1h], ebx
    mov     [esi+0B5h], ebx
    mov     [esi+0B9h], ebx
    mov     [esi+0BDh], al
    mov     [esi+0C1h], ebx
    mov     [esi+0C5h], ebx
    mov     [esi+0C9h], ebx
    mov     [esi+0CDh], cl
    mov     [esi+0D1h], ebx
    mov     [esi+0D5h], ebx
    mov     [esi+0D9h], ebx
    mov     [esi+0DDh], dl
    mov     [esi+0E1h], ebx
    mov     [esi+0E5h], ebx
    mov     [esi+0E9h], ebx
    mov     ecx, esi
    mov     [esi+0EDh], ebx
    mov     [esi+109h], ebx
    call    sub_40A150
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [esp+14h+arg_0], bl
    mov     ecx, [eax+1438Fh]
    mov     eax, [edi+4]
    cmp     eax, ebx
    mov     [esp+14h+var_4], ecx
    jnz     short loc_40930B
    xor     edx, edx
    jmp     short loc_409310
    ; ---------------------------------------------------------------------------

    loc_40930B:                             ; CODE XREF: sub_409160+1A5j
    mov     edx, [edi+8]
    sub     edx, eax

    loc_409310:                             ; CODE XREF: sub_409160+1A9j
    cmp     edx, ecx
    jnb     short loc_409336
    cmp     eax, ebx
    jnz     short loc_40931C
    xor     edx, edx
    jmp     short loc_409321
    ; ---------------------------------------------------------------------------

    loc_40931C:                             ; CODE XREF: sub_409160+1B6j
    mov     edx, [edi+8]
    sub     edx, eax

    loc_409321:                             ; CODE XREF: sub_409160+1BAj
    lea     eax, [esp+14h+arg_0]
    sub     ecx, edx
    push    eax
    push    ecx
    mov     ecx, [edi+8]
    push    ecx
    mov     ecx, edi
    call    sub_40D290
    jmp     short loc_409355
    ; ---------------------------------------------------------------------------

    loc_409336:                             ; CODE XREF: sub_409160+1B2j
    cmp     eax, ebx
    jnz     short loc_40933E
    xor     edx, edx
    jmp     short loc_409343
    ; ---------------------------------------------------------------------------

    loc_40933E:                             ; CODE XREF: sub_409160+1D8j
    mov     edx, [edi+8]
    sub     edx, eax

    loc_409343:                             ; CODE XREF: sub_409160+1DCj
    cmp     ecx, edx
    jnb     short loc_409355
    mov     edx, [edi+8]
    add     eax, ecx
    push    edx
    push    eax
    mov     ecx, edi
    call    sub_40D470

    loc_409355:                             ; CODE XREF: sub_409160+1D4j
                                            ; sub_409160+1E5j
    mov     ecx, ebp
    mov     [esp+14h+arg_0], ebx
    call    sub_40D000
    mov     edi, [esp+14h+var_4]
    cmp     eax, edi
    jnb     short loc_40938E
    mov     eax, [ebp+8]
    lea     ecx, [esp+14h+arg_0]
    push    ecx
    mov     ecx, ebp
    mov     [esp+18h+var_4], eax
    call    sub_40D000
    mov     edx, edi
    mov     ecx, ebp
    sub     edx, eax
    mov     eax, [esp+18h+var_4]
    push    edx
    push    eax
    call    sub_40D020
    jmp     short loc_4093AB
    ; ---------------------------------------------------------------------------

    loc_40938E:                             ; CODE XREF: sub_409160+206j
    mov     ecx, ebp
    call    sub_40D000
    cmp     edi, eax
    jnb     short loc_4093AB
    mov     edx, [ebp+4]
    mov     ecx, [ebp+8]
    push    ecx
    mov     ecx, ebp
    lea     eax, [edx+edi*2]
    push    eax
    call    sub_40D240

    loc_4093AB:                             ; CODE XREF: sub_409160+22Cj
                                            ; sub_409160+237j
    lea     ebp, [esi+65h]
    mov     byte ptr [esp+14h+arg_0], bl
    mov     ecx, ebp
    mov     byte ptr [esp+14h+arg_0+1], bl
    mov     byte ptr [esp+14h+arg_0+2], bl
    call    sub_40CC80
    cmp     eax, edi
    jnb     short loc_4093EB
    mov     ecx, [ebp+8]
    lea     edx, [esp+14h+arg_0]
    mov     [esp+14h+var_4], ecx
    push    edx
    mov     ecx, ebp
    call    sub_40CC80
    mov     edx, [esp+18h+var_4]
    mov     ecx, edi
    sub     ecx, eax
    push    ecx
    push    edx
    mov     ecx, ebp
    call    sub_40CCA0
    jmp     short loc_40940A
    ; ---------------------------------------------------------------------------

    loc_4093EB:                             ; CODE XREF: sub_409160+263j
    mov     ecx, ebp
    call    sub_40CC80
    cmp     edi, eax
    jnb     short loc_40940A
    mov     edx, [ebp+4]
    mov     eax, [ebp+8]
    lea     ecx, [edi+edi*2]
    push    eax
    add     edx, ecx
    mov     ecx, ebp
    push    edx
    call    sub_40CFB0

    loc_40940A:                             ; CODE XREF: sub_409160+289j
                                            ; sub_409160+294j
    lea     eax, [esp+14h+arg_0]
    lea     ecx, [esi+0ADh]
    push    eax
    push    edi
    mov     byte ptr [esp+1Ch+arg_0], bl
    call    sub_40C600
    lea     ecx, [esp+14h+arg_0]
    mov     [esp+14h+arg_0], ebx
    push    ecx
    push    edi
    lea     ecx, [esi+0BDh]
    call    sub_40C7F0
    lea     edx, [esp+14h+arg_0]
    lea     ecx, [esi+0CDh]
    push    edx
    push    edi
    mov     [esp+1Ch+arg_0], ebx
    call    sub_40C7F0
    lea     eax, [esp+14h+arg_0]
    lea     ecx, [esi+0DDh]
    push    eax
    push    edi
    mov     [esp+1Ch+arg_0], ebx
    call    sub_40C7F0
    mov     ecx, esi
    call    sub_409470
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_409160 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_409470 proc near                    ; CODE XREF: sub_409160+300p
                                            ; sub_40A100+27p
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, [eax+1438Fh]
    xor     eax, eax
    test    ebx, ebx
    jle     loc_40951E
    push    edi
    push    esi
    xor     edi, edi

    loc_40948A:                             ; CODE XREF: sub_409470+A6j
    mov     edx, TAdynmemStructPtr
    mov     esi, [ecx+0A1h]
    mov     edx, [edx+1439Bh]
    mov     byte ptr [eax+esi], 0
    add     edx, edi
    cmp     byte ptr [edx+22Fh], 0
    jnz     short loc_4094B6
    mov     esi, [ecx+0A1h]
    add     esi, eax
    add     byte ptr [esi], 28h

    loc_4094B6:                             ; CODE XREF: sub_409470+39j
    mov     esi, [edx+156h]
    test    esi, esi
    jz      short loc_4094CB
    mov     edx, [ecx+0A1h]
    add     edx, eax
    add     byte ptr [edx], 14h

    loc_4094CB:                             ; CODE XREF: sub_409470+4Ej
    mov     edx, [ecx+81h]
    inc     eax
    add     edi, 249h
    cmp     eax, ebx
    mov     word ptr [edx+eax*2-2], 0
    mov     edx, [ecx+0B1h]
    mov     byte ptr [eax+edx-1], 64h
    mov     edx, [ecx+0C1h]
    mov     dword ptr [edx+eax*4-4], 0
    mov     edx, [ecx+0D1h]
    mov     dword ptr [edx+eax*4-4], 0FFFFFFFFh
    mov     edx, [ecx+0E1h]
    mov     dword ptr [edx+eax*4-4], 0
    jl      loc_40948A
    pop     esi
    pop     edi

    loc_40951E:                             ; CODE XREF: sub_409470+10j
    pop     ebx
    retn
    sub_409470 endp

    ; ---------------------------------------------------------------------------
    mov     eax, [esp+4]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+245h]
    push    edi
    shr     ecx, 4
    test    cl, 1
    mov     edi, 1
    jz      short loc_409540
    mov     edi, 0Bh

    loc_409540:                             ; CODE XREF: .text:00409539j
    lea     ebx, [eax+1EEh]
    mov     ebp, 3

    loc_40954B:                             ; CODE XREF: .text:00409594j
    mov     esi, [ebx]
    mov     al, [esi+10Ah]
    test    al, al
    jz      short loc_409590
    xor     ecx, ecx
    mov     eax, 66666667h
    mov     cx, [esi+0D4h]
    mov     esi, [esi+0DCh]
    imul    ecx
    mov     ecx, edx
    mov     eax, 51EB851Fh
    sar     ecx, 4
    mov     edx, ecx
    shr     edx, 1Fh
    add     ecx, edx
    imul    esi
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    add     edx, edi
    lea     edi, [edx+ecx+5]

    loc_409590:                             ; CODE XREF: .text:00409555j
    add     ebx, 4
    dec     ebp
    jnz     short loc_40954B
    cmp     edi, 64h
    mov     eax, 64h
    jg      short loc_4095A2
    mov     eax, edi

    loc_4095A2:                             ; CODE XREF: .text:0040959Ej
    cmp     eax, 0FFFFFF9Ch
    jge     short loc_4095B3
    mov     eax, 0FFFFFF9Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4095B3:                             ; CODE XREF: .text:004095A5j
    cmp     edi, 64h
    mov     eax, 64h
    jg      short loc_4095BF
    mov     eax, edi

    loc_4095BF:                             ; CODE XREF: .text:004095BBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+14h]
    push    edi
    mov     dword ptr [esp+10h], 1
    fld     dword ptr [esi+1CEh]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_4095FC
    mov     dword ptr [esp+10h], 0Bh

    loc_4095FC:                             ; CODE XREF: .text:004095F2j
    mov     al, [esi+22Dh]
    mov     edi, 0Ah
    test    al, al
    jz      short loc_40960F
    add     [esp+10h], edi

    loc_40960F:                             ; CODE XREF: .text:00409609j
    push    esi
    call    sub_488F30
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 1
    jz      short loc_409626
    add     [esp+10h], edi

    loc_409626:                             ; CODE XREF: .text:00409620j
    fild    dword ptr [esp+10h]
    fld     dword ptr [esi+18Ah]
    fmul    ds:flt_4FC9BC
    fsubp   st(1), st
    call    __ftol
    mov     [esp+18h], eax
    fild    dword ptr [esp+18h]
    fld     dword ptr [esi+186h]
    fmul    ds:flt_4FC9C0
    fsubp   st(1), st
    call    __ftol
    mov     ecx, eax
    mov     eax, [esi+245h]
    shr     eax, 4
    test    al, 1
    mov     [esp+10h], ecx
    mov     edi, 1
    jz      short loc_409675
    mov     edi, 0Bh

    loc_409675:                             ; CODE XREF: .text:0040966Ej
    lea     ebx, [esi+1EEh]
    mov     ebp, 3

    loc_409680:                             ; CODE XREF: .text:004096CDj
    mov     esi, [ebx]
    mov     al, [esi+10Ah]
    test    al, al
    jz      short loc_4096C9
    xor     ecx, ecx
    mov     eax, 66666667h
    mov     cx, [esi+0D4h]
    mov     esi, [esi+0DCh]
    imul    ecx
    mov     ecx, edx
    mov     eax, 51EB851Fh
    sar     ecx, 4
    mov     edx, ecx
    shr     edx, 1Fh
    add     ecx, edx
    imul    esi
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    add     edx, edi
    lea     edi, [edx+ecx+5]
    mov     ecx, [esp+10h]

    loc_4096C9:                             ; CODE XREF: .text:0040968Aj
    add     ebx, 4
    dec     ebp
    jnz     short loc_409680
    cmp     edi, 64h
    mov     eax, 64h
    jg      short loc_4096DB
    mov     eax, edi

    loc_4096DB:                             ; CODE XREF: .text:004096D7j
    cmp     eax, 0FFFFFF9Ch
    jge     short loc_4096E7
    mov     eax, 0FFFFFF9Ch
    jmp     short loc_4096F3
    ; ---------------------------------------------------------------------------

    loc_4096E7:                             ; CODE XREF: .text:004096DEj
    cmp     edi, 64h
    mov     eax, 64h
    jg      short loc_4096F3
    mov     eax, edi

    loc_4096F3:                             ; CODE XREF: .text:004096E5j
                                            ; .text:004096EFj
    movsx   edx, al
    add     ecx, edx
    mov     eax, 64h
    cmp     ecx, 64h
    jg      short loc_409704
    mov     eax, ecx

    loc_409704:                             ; CODE XREF: .text:00409700j
    cmp     eax, 0FFFFFF9Ch
    jge     short loc_409716
    mov     eax, 0FFFFFF9Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_409716:                             ; CODE XREF: .text:00409707j
    cmp     ecx, 64h
    mov     eax, 64h
    jg      short loc_409722
    mov     eax, ecx

    loc_409722:                             ; CODE XREF: .text:0040971Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_409730 proc near                    ; CODE XREF: .text:0040AD62p
                                            ; sub_40B2C0+4Cp ...

    var_11= dword ptr -11h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 14h
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     eax, [ebx+91h]
    lea     ebp, [ebx+8Dh]
    push    edi
    mov     edi, TAdynmemStructPtr
    mov     byte ptr [esp+24h+var_11], 0
    mov     [esp+24h+var_4], ebx
    mov     esi, [edi+1438Fh]
    test    eax, eax
    jnz     short loc_409762
    xor     ecx, ecx
    jmp     short loc_409767
    ; ---------------------------------------------------------------------------

    loc_409762:                             ; CODE XREF: sub_409730+2Cj
    mov     ecx, [ebp+8]
    sub     ecx, eax

    loc_409767:                             ; CODE XREF: sub_409730+30j
    cmp     ecx, esi
    jnb     short loc_40978D
    test    eax, eax
    jnz     short loc_409773
    xor     ecx, ecx
    jmp     short loc_409778
    ; ---------------------------------------------------------------------------

    loc_409773:                             ; CODE XREF: sub_409730+3Dj
    mov     ecx, [ebp+8]
    sub     ecx, eax

    loc_409778:                             ; CODE XREF: sub_409730+41j
    lea     eax, [esp+24h+var_11]
    sub     esi, ecx
    mov     ecx, [ebp+8]
    push    eax
    push    esi
    push    ecx
    mov     ecx, ebp
    call    sub_40D290
    jmp     short loc_4097BD
    ; ---------------------------------------------------------------------------

    loc_40978D:                             ; CODE XREF: sub_409730+39j
    test    eax, eax
    jnz     short loc_409795
    xor     ecx, ecx
    jmp     short loc_40979A
    ; ---------------------------------------------------------------------------

    loc_409795:                             ; CODE XREF: sub_409730+5Fj
    mov     ecx, [ebp+8]
    sub     ecx, eax

    loc_40979A:                             ; CODE XREF: sub_409730+63j
    cmp     esi, ecx
    jnb     short loc_4097C3
    mov     edx, [ebp+8]
    add     esi, eax
    cmp     edx, edx
    mov     eax, edx
    jz      short loc_4097B3

    loc_4097A9:                             ; CODE XREF: sub_409730+81j
    mov     cl, [eax]
    mov     [esi], cl
    inc     esi
    inc     eax
    cmp     eax, edx
    jnz     short loc_4097A9

    loc_4097B3:                             ; CODE XREF: sub_409730+77j
    mov     edx, [ebp+8]
    mov     [ebp+8], esi
    mov     [esp+24h+var_8], edx

    loc_4097BD:                             ; CODE XREF: sub_409730+5Bj
    mov     edi, TAdynmemStructPtr

    loc_4097C3:                             ; CODE XREF: sub_409730+6Cj
    mov     esi, [ebx+69h]
    lea     ecx, [ebx+65h]
    mov     byte ptr [esp+24h+var_11+1], 0
    mov     byte ptr [esp+24h+var_11+2], 0
    mov     byte ptr [esp+24h+var_11+3], 0
    mov     ebp, [edi+1438Fh]
    test    esi, esi
    jnz     short loc_4097E6
    xor     edx, edx
    jmp     short loc_4097F9
    ; ---------------------------------------------------------------------------

    loc_4097E6:                             ; CODE XREF: sub_409730+B0j
    mov     edx, [ecx+8]
    mov     eax, 55555556h
    sub     edx, esi
    imul    edx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4097F9:                             ; CODE XREF: sub_409730+B4j
    cmp     edx, ebp
    jnb     short loc_40982B
    test    esi, esi
    jnz     short loc_409805
    xor     edx, edx
    jmp     short loc_409818
    ; ---------------------------------------------------------------------------

    loc_409805:                             ; CODE XREF: sub_409730+CFj
    mov     edx, [ecx+8]
    mov     eax, 55555556h
    sub     edx, esi
    imul    edx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_409818:                             ; CODE XREF: sub_409730+D3j
    lea     eax, [esp+24h+var_11+1]
    sub     ebp, edx
    mov     edx, [ecx+8]
    push    eax
    push    ebp
    push    edx
    call    sub_40CCA0
    jmp     short loc_409859
    ; ---------------------------------------------------------------------------

    loc_40982B:                             ; CODE XREF: sub_409730+CBj
    test    esi, esi
    jnz     short loc_409833
    xor     edx, edx
    jmp     short loc_409846
    ; ---------------------------------------------------------------------------

    loc_409833:                             ; CODE XREF: sub_409730+FDj
    mov     edx, [ecx+8]
    mov     eax, 55555556h
    sub     edx, esi
    imul    edx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_409846:                             ; CODE XREF: sub_409730+101j
    cmp     ebp, edx
    jnb     short loc_40985F
    mov     edx, [ecx+8]
    lea     eax, [esi+ebp*2]
    add     ebp, eax
    push    edx
    push    ebp
    call    sub_40CFB0

    loc_409859:                             ; CODE XREF: sub_409730+F9j
    mov     edi, TAdynmemStructPtr

    loc_40985F:                             ; CODE XREF: sub_409730+118j
    mov     eax, [edi+1438Fh]
    mov     ebp, 1
    cmp     eax, ebp
    mov     [esp+24h+var_C], ebp
    jle     loc_409DB6
    mov     esi, 0Ah
    jmp     short loc_409887
    ; ---------------------------------------------------------------------------

    loc_40987D:                             ; CODE XREF: sub_409730+680j
    mov     esi, 0Ah
    mov     ebp, 1

    loc_409887:                             ; CODE XREF: sub_409730+14Bj
    mov     ecx, [esp+24h+var_C]
    mov     edi, [edi+1439Bh]
    and     ecx, 0FFFFh
    mov     [esp+24h+var_11+1], ebp
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    add     edi, ecx
    fld     dword ptr [edi+1CEh]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_4098C2
    mov     [esp+24h+var_11+1], 0Bh

    loc_4098C2:                             ; CODE XREF: sub_409730+188j
    mov     al, [edi+22Dh]
    test    al, al
    jz      short loc_4098D0
    add     [esp+24h+var_11+1], esi

    loc_4098D0:                             ; CODE XREF: sub_409730+19Aj
    push    edi
    call    sub_488F30
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 1
    jz      short loc_4098E7
    add     [esp+24h+var_11+1], esi

    loc_4098E7:                             ; CODE XREF: sub_409730+1B1j
    fild    [esp+24h+var_11+1]
    fld     dword ptr [edi+18Ah]
    fmul    ds:flt_4FC9BC
    fsubp   st(1), st
    call    __ftol
    mov     [esp+24h+var_8], eax
    fild    [esp+24h+var_8]
    fld     dword ptr [edi+186h]
    fmul    ds:flt_4FC9C0
    fsubp   st(1), st
    call    __ftol
    mov     edx, [edi+245h]
    mov     [esp+24h+var_11+1], eax
    shr     edx, 4
    test    dl, 1
    jz      short loc_409930
    mov     ebp, 0Bh

    loc_409930:                             ; CODE XREF: sub_409730+1F9j
    lea     ebx, [edi+1EEh]
    mov     [esp+24h+var_8], 3

    loc_40993E:                             ; CODE XREF: sub_409730+25Fj
    mov     esi, [ebx]
    mov     al, [esi+10Ah]
    test    al, al
    jz      short loc_409983
    mov     ecx, [esi+0DCh]
    mov     eax, 51EB851Fh
    imul    ecx
    mov     ecx, edx
    xor     edx, edx
    mov     dx, [esi+0D4h]
    sar     ecx, 5
    mov     eax, ecx
    shr     eax, 1Fh
    add     ecx, eax
    mov     eax, 66666667h
    imul    edx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    add     edx, ebp
    lea     ebp, [edx+ecx+5]

    loc_409983:                             ; CODE XREF: sub_409730+218j
    mov     eax, [esp+24h+var_8]
    add     ebx, 4
    dec     eax
    mov     [esp+24h+var_8], eax
    jnz     short loc_40993E
    cmp     ebp, 64h
    mov     eax, 64h
    jg      short loc_40999D
    mov     eax, ebp

    loc_40999D:                             ; CODE XREF: sub_409730+269j
    cmp     eax, 0FFFFFF9Ch
    jge     short loc_4099A9
    mov     eax, 0FFFFFF9Ch
    jmp     short loc_4099B5
    ; ---------------------------------------------------------------------------

    loc_4099A9:                             ; CODE XREF: sub_409730+270j
    cmp     ebp, 64h
    mov     eax, 64h
    jg      short loc_4099B5
    mov     eax, ebp

    loc_4099B5:                             ; CODE XREF: sub_409730+277j
                                            ; sub_409730+281j
    movsx   ecx, al
    mov     eax, [esp+24h+var_11+1]
    add     eax, ecx
    mov     ecx, 64h
    cmp     eax, 64h
    jg      short loc_4099CA
    mov     ecx, eax

    loc_4099CA:                             ; CODE XREF: sub_409730+296j
    cmp     ecx, 0FFFFFF9Ch
    jge     short loc_4099D6
    mov     eax, 0FFFFFF9Ch
    jmp     short loc_4099E0
    ; ---------------------------------------------------------------------------

    loc_4099D6:                             ; CODE XREF: sub_409730+29Dj
    cmp     eax, 64h
    jle     short loc_4099E0
    mov     eax, 64h

    loc_4099E0:                             ; CODE XREF: sub_409730+2A4j
                                            ; sub_409730+2A9j
    mov     edx, [esp+24h+var_4]
    mov     ecx, [esp+24h+var_C]
    mov     [esp+24h+var_11+1], 1
    mov     esi, [edx+91h]
    mov     [esi+ecx], al
    mov     esi, [edx+69h]
    mov     edx, [edx+81h]
    lea     eax, [ecx+ecx*2]
    add     eax, esi
    movsx   esi, word ptr [edx+ecx*2]
    mov     [esp+24h+var_8], eax
    mov     eax, [edi+245h]
    shr     eax, 4
    test    al, 1
    jz      short loc_409A24
    mov     [esp+24h+var_11+1], 15h

    loc_409A24:                             ; CODE XREF: sub_409730+2EAj
    test    byte ptr [edi+241h], 40h
    jz      short loc_409A37
    cmp     esi, 3
    jge     short loc_409A37
    add     [esp+24h+var_11+1], 1Eh

    loc_409A37:                             ; CODE XREF: sub_409730+2FBj
                                            ; sub_409730+300j
    push    edi
    call    sub_488F30
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 1
    jz      short loc_409A4F
    add     [esp+24h+var_11+1], 32h

    loc_409A4F:                             ; CODE XREF: sub_409730+318j
    fld     dword ptr [edi+1CEh]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_409A67
    add     [esp+24h+var_11+1], 32h

    loc_409A67:                             ; CODE XREF: sub_409730+330j
    mov     al, [edi+22Dh]
    test    al, al
    jz      short loc_409A76
    add     [esp+24h+var_11+1], 19h

    loc_409A76:                             ; CODE XREF: sub_409730+33Fj
    mov     ebx, [edi+241h]
    mov     ecx, ebx
    shr     ecx, 0Bh
    test    cl, 1
    jz      short loc_409A8B
    add     [esp+24h+var_11+1], 28h

    loc_409A8B:                             ; CODE XREF: sub_409730+354j
    cmp     word ptr [edi+206h], 0
    jz      short loc_409A9A
    add     [esp+24h+var_11+1], 0Fh

    loc_409A9A:                             ; CODE XREF: sub_409730+363j
    cmp     word ptr [edi+204h], 0
    jz      short loc_409AA9
    add     [esp+24h+var_11+1], 5

    loc_409AA9:                             ; CODE XREF: sub_409730+372j
    fld     dword ptr [edi+1C2h]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_409AC4
    fld     dword ptr [edi+1C2h]
    jmp     short loc_409ACA
    ; ---------------------------------------------------------------------------

    loc_409AC4:                             ; CODE XREF: sub_409730+38Aj
    fld     ds:flt_4FC9B8

    loc_409ACA:                             ; CODE XREF: sub_409730+392j
    fcomp   ds:flt_4FC9C4
    fnstsw  ax
    test    ah, 1
    jz      short loc_409AFA
    fld     dword ptr [edi+1C2h]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_409AF2
    fld     dword ptr [edi+1C2h]
    jmp     short loc_409B00
    ; ---------------------------------------------------------------------------

    loc_409AF2:                             ; CODE XREF: sub_409730+3B8j
    fld     ds:flt_4FC9B8
    jmp     short loc_409B00
    ; ---------------------------------------------------------------------------

    loc_409AFA:                             ; CODE XREF: sub_409730+3A5j
    fld     ds:flt_4FC9C4

    loc_409B00:                             ; CODE XREF: sub_409730+3C0j
                                            ; sub_409730+3C8j
    fild    [esp+24h+var_11+1]
    fadd    st, st(1)
    call    __ftol
    test    esi, esi
    fstp    st
    mov     ecx, eax
    jnz     short loc_409B16
    shl     ecx, 2

    loc_409B16:                             ; CODE XREF: sub_409730+3E1j
    cmp     esi, 1
    jnz     short loc_409B1D
    add     ecx, ecx

    loc_409B1D:                             ; CODE XREF: sub_409730+3E9j
    cmp     word ptr [edi+1C0h], 0
    jl      short loc_409B2A
    lea     ecx, [ecx+ecx*2]

    loc_409B2A:                             ; CODE XREF: sub_409730+3F5j
    mov     esi, TAdynmemStructPtr
    mov     eax, [esp+24h+var_4]
    mov     dx, [esi+1434Fh]
    mov     ebp, [eax]
    shr     dx, 1
    cmp     [ebp+144h], dx
    jbe     short loc_409B5E
    mov     eax, [eax+91h]
    mov     edx, [esp+24h+var_C]
    movsx   eax, byte ptr [eax+edx]
    cdq
    sub     eax, edx
    sar     eax, 1
    add     ecx, eax

    loc_409B5E:                             ; CODE XREF: sub_409730+417j
    mov     eax, [edi+245h]
    shr     eax, 8
    test    al, 1
    jz      short loc_409B71
    xor     ebp, ebp
    xor     ecx, ecx
    jmp     short loc_409B73
    ; ---------------------------------------------------------------------------

    loc_409B71:                             ; CODE XREF: sub_409730+439j
    xor     ebp, ebp

    loc_409B73:                             ; CODE XREF: sub_409730+43Fj
    shr     ebx, 18h
    test    bl, 1
    jz      short loc_409B7D
    xor     ecx, ecx

    loc_409B7D:                             ; CODE XREF: sub_409730+449j
    fld     dword ptr [edi+1D2h]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_409BA7
    mov     eax, [esi+37EC8h]
    cdq
    sub     eax, edx
    mov     edx, [esi+1425Fh]
    sar     eax, 1
    cmp     edx, eax
    jge     short loc_409BA7
    xor     ecx, ecx

    loc_409BA7:                             ; CODE XREF: sub_409730+45Ej
                                            ; sub_409730+473j
    mov     esi, 64h
    cmp     ecx, esi
    jl      short loc_409BB2
    mov     ecx, esi

    loc_409BB2:                             ; CODE XREF: sub_409730+47Ej
    mov     ebx, [esp+24h+var_8]
    push    edi
    mov     [ebx], cl
    fld     dword ptr [edi+186h]
    fmul    ds:flt_4FC9C8
    fstp    [esp+28h+var_8]
    call    sub_488F30
    fmul    ds:flt_4FC9CC
    fld     ds:flt_4FC9D0
    fxch    st(1)
    fsubr   [esp+24h+var_8]
    fxch    st(1)
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 1
    jz      short loc_409BF3
    fld     ds:flt_4FC9D0
    jmp     short loc_409C13
    ; ---------------------------------------------------------------------------

    loc_409BF3:                             ; CODE XREF: sub_409730+4B9j
    fld     dword ptr [edi+186h]
    fmul    ds:flt_4FC9C8
    push    edi
    fstp    [esp+28h+var_8]
    call    sub_488F30
    fmul    ds:flt_4FC9CC
    fsubr   [esp+24h+var_8]

    loc_409C13:                             ; CODE XREF: sub_409730+4C1j
    fld     ds:flt_4FC9B8
    fcomp   st(1)
    fnstsw  ax
    test    ah, 41h
    fstp    st
    jnz     short loc_409C2C
    fld     ds:flt_4FC9B8
    jmp     short loc_409C87
    ; ---------------------------------------------------------------------------

    loc_409C2C:                             ; CODE XREF: sub_409730+4F2j
    fld     dword ptr [edi+186h]
    fmul    ds:flt_4FC9C8
    push    edi
    fstp    [esp+28h+var_8]
    call    sub_488F30
    fmul    ds:flt_4FC9CC
    fld     ds:flt_4FC9D0
    fxch    st(1)
    fsubr   [esp+24h+var_8]
    fxch    st(1)
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 1
    jz      short loc_409C67
    fld     ds:flt_4FC9D0
    jmp     short loc_409C87
    ; ---------------------------------------------------------------------------

    loc_409C67:                             ; CODE XREF: sub_409730+52Dj
    fld     dword ptr [edi+186h]
    fmul    ds:flt_4FC9C8
    push    edi
    fstp    [esp+28h+var_8]
    call    sub_488F30
    fmul    ds:flt_4FC9CC
    fsubr   [esp+24h+var_8]

    loc_409C87:                             ; CODE XREF: sub_409730+4FAj
                                            ; sub_409730+535j
    call    __ftol
    mov     [ebx+2], al
    mov     [esp+24h+var_8], esi
    fld     dword ptr [edi+1CEh]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 40h
    jz      short loc_409CAA
    mov     [esp+24h+var_8], ebp

    loc_409CAA:                             ; CODE XREF: sub_409730+574j
    mov     cl, [edi+22Dh]
    fld     dword ptr [edi+18Ah]
    fmul    ds:flt_4FC9D4
    neg     cl
    sbb     ecx, ecx
    and     ecx, 19h
    mov     [esp+24h+var_11+1], ecx
    fild    [esp+24h+var_11+1]
    fild    [esp+24h+var_8]
    fxch    st(1)
    faddp   st(2), st
    fld     ds:flt_4FC9D0
    fxch    st(2)
    fstp    [esp+24h+var_11+1]
    fadd    [esp+24h+var_11+1]
    fxch    st(1)
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 1
    jz      short loc_409CF6
    fld     ds:flt_4FC9D0
    jmp     short loc_409D19
    ; ---------------------------------------------------------------------------

    loc_409CF6:                             ; CODE XREF: sub_409730+5BCj
    fld     dword ptr [edi+1CEh]
    fcomp   ds:flt_4FC9B8
    mov     [esp+24h+var_8], esi
    fnstsw  ax
    test    ah, 40h
    jz      short loc_409D11
    mov     [esp+24h+var_8], ebp

    loc_409D11:                             ; CODE XREF: sub_409730+5DBj
    fild    [esp+24h+var_8]
    fadd    [esp+24h+var_11+1]

    loc_409D19:                             ; CODE XREF: sub_409730+5C4j
    fld     ds:flt_4FC9B8
    fcomp   st(1)
    fnstsw  ax
    test    ah, 41h
    fstp    st
    jnz     short loc_409D32
    fld     ds:flt_4FC9B8
    jmp     short loc_409D91
    ; ---------------------------------------------------------------------------

    loc_409D32:                             ; CODE XREF: sub_409730+5F8j
    fld     dword ptr [edi+1CEh]
    fcomp   ds:flt_4FC9B8
    mov     [esp+24h+var_8], esi
    fnstsw  ax
    test    ah, 40h
    jz      short loc_409D4D
    mov     [esp+24h+var_8], ebp

    loc_409D4D:                             ; CODE XREF: sub_409730+617j
    fld     ds:flt_4FC9D0
    fild    [esp+24h+var_8]
    fadd    [esp+24h+var_11+1]
    fxch    st(1)
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 1
    jz      short loc_409D6E
    fld     ds:flt_4FC9D0
    jmp     short loc_409D91
    ; ---------------------------------------------------------------------------

    loc_409D6E:                             ; CODE XREF: sub_409730+634j
    fld     dword ptr [edi+1CEh]
    fcomp   ds:flt_4FC9B8
    mov     [esp+24h+var_8], esi
    fnstsw  ax
    test    ah, 40h
    jz      short loc_409D89
    mov     [esp+24h+var_8], ebp

    loc_409D89:                             ; CODE XREF: sub_409730+653j
    fild    [esp+24h+var_8]
    fadd    [esp+24h+var_11+1]

    loc_409D91:                             ; CODE XREF: sub_409730+600j
                                            ; sub_409730+63Cj
    call    __ftol
    mov     [ebx+1], al
    mov     edi, TAdynmemStructPtr
    mov     eax, [esp+24h+var_C]
    mov     ecx, [edi+1438Fh]
    inc     eax
    cmp     eax, ecx
    mov     [esp+24h+var_C], eax
    jl      loc_40987D

    loc_409DB6:                             ; CODE XREF: sub_409730+140j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    sub_409730 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_409DC0 proc near                    ; CODE XREF: sub_406DB0+77p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    edi
    mov     edi, dword_5119C0[eax*4]
    mov     edx, [ecx+1438Fh]
    mov     eax, 1
    cmp     edx, eax
    mov     ebp, eax
    jle     loc_409E8B
    push    esi
    push    ebx

    loc_409DEA:                             ; CODE XREF: sub_409DC0+C3j
    mov     esi, [esp+10h+arg_4]
    mov     ecx, eax
    and     ecx, 1Fh
    mov     edx, 1
    shl     edx, cl
    mov     ecx, eax
    shr     ecx, 5
    test    [esi+ecx*4], edx
    jz      short loc_409E6D
    mov     edx, [edi+0C1h]
    lea     ebx, ds:0[eax*4]
    cmp     dword ptr [ebx+edx], 0
    jnz     short loc_409E6D
    mov     ecx, [edi+0B1h]
    xor     edx, edx
    mov     dl, [ecx+eax]
    lea     esi, [ecx+eax]
    mov     [esp+10h+arg_0], edx
    fild    [esp+10h+arg_0]
    fmul    [esp+10h+arg_8]
    call    __ftol
    xor     ecx, ecx
    test    eax, eax
    setle   cl
    dec     ecx
    and     ecx, eax
    cmp     ecx, 64h
    jge     short loc_409E51
    xor     ecx, ecx
    test    eax, eax
    setle   cl
    dec     ecx
    and     ecx, eax
    jmp     short loc_409E56
    ; ---------------------------------------------------------------------------

    loc_409E51:                             ; CODE XREF: sub_409DC0+83j
    mov     ecx, 64h

    loc_409E56:                             ; CODE XREF: sub_409DC0+8Fj
    mov     eax, [esp+10h+arg_C]
    mov     [esi], cl
    test    eax, eax
    jz      short loc_409E6D
    mov     eax, [edi+0C1h]
    mov     dword ptr [ebx+eax], 1

    loc_409E6D:                             ; CODE XREF: sub_409DC0+42j
                                            ; sub_409DC0+55j ...
    mov     ecx, TAdynmemStructPtr
    inc     ebp
    mov     eax, ebp
    mov     edx, [ecx+1438Fh]
    and     eax, 0FFFFh
    cmp     eax, edx
    jl      loc_409DEA
    pop     ebx
    pop     esi

    loc_409E8B:                             ; CODE XREF: sub_409DC0+22j
    pop     edi
    pop     ebp
    retn    10h
    sub_409DC0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_409E90 proc near                    ; CODE XREF: sub_406E40+7Ep

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    mov     ecx, TAdynmemStructPtr
    push    esi
    push    edi
    mov     edx, dword_5119C0[eax*4]
    mov     edi, [ecx+1438Fh]
    mov     eax, 1
    cmp     edi, eax
    mov     esi, eax
    jle     short loc_409F1B
    mov     edi, [esp+8+arg_C]
    push    ebp
    push    ebx
    mov     ebx, [esp+10h+arg_4]

    loc_409EBE:                             ; CODE XREF: sub_409E90+87j
    mov     ecx, eax
    mov     ebp, 1
    and     ecx, 1Fh
    shl     ebp, cl
    mov     ecx, eax
    shr     ecx, 5
    test    [ebx+ecx*4], ebp
    jz      short loc_409F01
    mov     ecx, [edx+0E1h]
    shl     eax, 2
    cmp     dword ptr [ecx+eax], 0
    jnz     short loc_409F01
    mov     ecx, [edx+0D1h]
    mov     ebp, [esp+10h+arg_8]
    test    edi, edi
    mov     [ecx+eax], ebp
    jz      short loc_409F01
    mov     ecx, [edx+0E1h]
    mov     dword ptr [ecx+eax], 1

    loc_409F01:                             ; CODE XREF: sub_409E90+42j
                                            ; sub_409E90+51j ...
    mov     ecx, TAdynmemStructPtr
    inc     esi
    mov     eax, esi
    mov     ebp, [ecx+1438Fh]
    and     eax, 0FFFFh
    cmp     eax, ebp
    jl      short loc_409EBE
    pop     ebx
    pop     ebp

    loc_409F1B:                             ; CODE XREF: sub_409E90+22j
    pop     edi
    pop     esi
    retn    10h
    sub_409E90 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_409F20 proc near                    ; CODE XREF: sub_406EE0+15p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    cmp     ax, 1
    jb      short loc_409F6E
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFFFh
    cmp     eax, [ecx+1438Fh]
    jge     short loc_409F6E
    mov     edx, [esp+arg_0]
    mov     ecx, dword_5119C0[edx*4]
    mov     ecx, [ecx+0D1h]
    mov     eax, [ecx+eax*4]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_409F5E
    mov     eax, 1
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_409F5E:                             ; CODE XREF: sub_409F20+34j
    mov     ecx, [esp+arg_8]
    xor     edx, edx
    cmp     ecx, eax
    setl    dl
    mov     eax, edx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_409F6E:                             ; CODE XREF: sub_409F20+8j
                                            ; sub_409F20+1Bj
    xor     eax, eax
    retn    0Ch
    sub_409F20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_409F80 proc near                    ; CODE XREF: sub_4648E0+85p

    var_D8= dword ptr -0D8h
    var_D4= dword ptr -0D4h
    arg_0= dword ptr  4

    sub     esp, 0D8h
    mov     eax, [esp+0D8h+arg_0]
    push    ebx
    push    ebp
    mov     ecx, dword_5119C0[eax*4]
    mov     [esp+0E0h+var_D8], ecx
    call    ___setargv
    mov     ebp, TAdynmemStructPtr
    mov     ecx, 1
    mov     ebx, ecx
    cmp     [ebp+1438Fh], ecx
    jle     short loc_40A02E
    push    edi
    push    esi

    loc_409FB6:                             ; CODE XREF: sub_409F80+AAj
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     edx, [eax+eax*8]
    mov     eax, [ebp+1439Bh]
    add     eax, edx
    mov     edx, [eax+241h]
    shr     edx, 5
    test    dl, 1
    jz      short loc_40A019
    mov     edx, [esp+0E8h+var_D8]
    mov     edx, [edx+0C1h]
    cmp     dword ptr [edx+ecx*4], 1
    jz      short loc_40A019
    lea     esi, [eax+0BEh]
    or      ecx, 0FFFFFFFFh
    mov     edi, esi
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ecx
    jz      short loc_40A019
    lea     ecx, [esp+0E8h+var_D4]
    call    sub_4B73B0
    lea     eax, [esp+0E8h+var_D4]
    push    0FFFFFFFFh
    push    eax
    push    edi
    push    esi
    call    sub_4B7A30
    mov     ebp, TAdynmemStructPtr

    loc_40A019:                             ; CODE XREF: sub_409F80+54j
                                            ; sub_409F80+64j ...
    mov     eax, [ebp+1438Fh]
    inc     ebx
    mov     ecx, ebx
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      short loc_409FB6
    pop     esi
    pop     edi

    loc_40A02E:                             ; CODE XREF: sub_409F80+32j
    pop     ebp
    pop     ebx
    add     esp, 0D8h
    retn    4
    sub_409F80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40A040 proc near                    ; CODE XREF: sub_4648E0+8Bp

    var_D8= dword ptr -0D8h
    var_D4= dword ptr -0D4h
    arg_0= dword ptr  4

    sub     esp, 0D8h
    mov     eax, [esp+0D8h+arg_0]
    push    ebx
    push    ebp
    mov     ecx, dword_5119C0[eax*4]
    mov     [esp+0E0h+var_D8], ecx
    call    ___setargv
    mov     ebp, TAdynmemStructPtr
    mov     ecx, 1
    mov     ebx, ecx
    cmp     [ebp+1438Fh], ecx
    jle     short loc_40A0EE
    push    edi
    push    esi

    loc_40A076:                             ; CODE XREF: sub_40A040+AAj
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     edx, [eax+eax*8]
    mov     eax, [ebp+1439Bh]
    add     eax, edx
    mov     edx, [eax+241h]
    shr     edx, 5
    test    dl, 1
    jz      short loc_40A0D9
    mov     edx, [esp+0E8h+var_D8]
    mov     edx, [edx+0E1h]
    cmp     dword ptr [edx+ecx*4], 1
    jz      short loc_40A0D9
    lea     esi, [eax+0BEh]
    or      ecx, 0FFFFFFFFh
    mov     edi, esi
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ecx
    jz      short loc_40A0D9
    lea     ecx, [esp+0E8h+var_D4]
    call    sub_4B73B0
    lea     eax, [esp+0E8h+var_D4]
    push    0FFFFFFFFh
    push    eax
    push    edi
    push    esi
    call    sub_4B7A30
    mov     ebp, TAdynmemStructPtr

    loc_40A0D9:                             ; CODE XREF: sub_40A040+54j
                                            ; sub_40A040+64j ...
    mov     eax, [ebp+1438Fh]
    inc     ebx
    mov     ecx, ebx
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      short loc_40A076
    pop     esi
    pop     edi

    loc_40A0EE:                             ; CODE XREF: sub_40A040+32j
    pop     ebp
    pop     ebx
    add     esp, 0D8h
    retn    4
    sub_40A040 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40A100 proc near                    ; CODE XREF: .text:004174D0p
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    xor     esi, esi
    mov     edi, offset dword_5119C0
    mov     bl, 2

    loc_40A111:                             ; CODE XREF: sub_40A100+40j
    mov     ecx, [eax+esi+1B63h]
    test    ecx, ecx
    jz      short loc_40A131
    cmp     [eax+esi+1BD6h], bl
    jnz     short loc_40A131
    mov     ecx, [edi]
    call    sub_409470
    mov     eax, TAdynmemStructPtr

    loc_40A131:                             ; CODE XREF: sub_40A100+1Aj
                                            ; sub_40A100+23j
    add     edi, 4
    add     esi, 14Bh
    cmp     edi, offset dword_5119E8
    jl      short loc_40A111
    call    sub_4648E0
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_40A100 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40A150 proc near                    ; CODE XREF: sub_409160+188p
    push    esi
    mov     esi, ecx
    push    0Ah                             ; int
    mov     dword ptr [esi+0F9h], 3
    call    GetRandom
    add     ax, [esi+0F9h]
    push    3                               ; int
    add     eax, 8
    mov     [esi+0F1h], ax
    call    GetRandom
    add     ax, [esi+0F9h]
    add     eax, 8
    mov     [esi+0F3h], ax
    movsx   eax, word ptr [esi+0F1h]
    push    eax                             ; int
    call    GetRandom
    mov     ecx, eax
    movsx   eax, word ptr [esi+0F1h]
    cdq
    sub     eax, edx
    movsx   edx, word ptr [esi+0F3h]
    sar     eax, 1
    sub     ecx, eax
    push    edx                             ; int
    mov     [esi+0F5h], cx
    call    GetRandom
    mov     ecx, eax
    push    14h                             ; int
    movsx   eax, word ptr [esi+0F3h]
    cdq
    sub     eax, edx
    mov     dword ptr [esi+105h], 6
    sar     eax, 1
    sub     ecx, eax
    mov     [esi+0F7h], cx
    call    GetRandom
    add     ax, [esi+105h]
    push    3                               ; int
    add     eax, 8
    mov     [esi+0FDh], ax
    call    GetRandom
    add     ax, [esi+105h]
    movsx   edx, word ptr [esi+0FDh]
    add     eax, 8
    push    edx                             ; int
    mov     [esi+0FFh], ax
    call    GetRandom
    mov     ecx, eax
    movsx   eax, word ptr [esi+0FDh]
    cdq
    sub     eax, edx
    movsx   edx, word ptr [esi+0FFh]
    sar     eax, 1
    sub     ecx, eax
    push    edx                             ; int
    mov     [esi+101h], cx
    call    GetRandom
    mov     ecx, eax
    movsx   eax, word ptr [esi+0FFh]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ecx, eax
    mov     [esi+103h], cx
    pop     esi
    retn
    sub_40A150 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40A260 proc near                    ; CODE XREF: sub_40BFE0+1A9p

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+30h+arg_8]
    push    edi
    xor     edi, edi
    mov     ecx, [esi+4]
    cmp     ecx, edi
    jnz     short loc_40A278
    xor     eax, eax
    jmp     short loc_40A280
    ; ---------------------------------------------------------------------------

    loc_40A278:                             ; CODE XREF: sub_40A260+12j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 3

    loc_40A280:                             ; CODE XREF: sub_40A260+16j
    xor     edx, edx
    cmp     eax, edi
    setz    dl
    test    dl, dl
    jz      short loc_40A297
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_40A297:                             ; CODE XREF: sub_40A260+29j
    mov     al, byte ptr [esp+34h+arg_0]
    cmp     ecx, edi
    mov     byte ptr [esp+34h+var_10], al
    mov     [esp+34h+var_C], edi
    mov     [esp+34h+var_8], edi
    mov     [esp+34h+var_4], edi
    jnz     short loc_40A2B3
    xor     esi, esi
    jmp     short loc_40A2BB
    ; ---------------------------------------------------------------------------

    loc_40A2B3:                             ; CODE XREF: sub_40A260+4Dj
    mov     esi, [esi+8]
    sub     esi, ecx
    sar     esi, 3

    loc_40A2BB:                             ; CODE XREF: sub_40A260+51j
    lea     ecx, [esp+34h+var_10]
    call    sub_40CA30
    cmp     eax, esi
    jnb     short loc_40A335
    cmp     esi, edi
    mov     eax, esi
    jge     short loc_40A2D0
    xor     eax, eax

    loc_40A2D0:                             ; CODE XREF: sub_40A260+6Cj
    lea     ecx, ds:0[eax*8]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     edx, [esp+38h+var_8]
    add     esp, 4
    mov     ebp, eax
    mov     eax, [esp+34h+var_C]
    push    ebp
    push    edx
    push    eax
    lea     ecx, [esp+40h+var_10]
    call    sub_40CC40
    mov     ecx, [esp+34h+var_8]
    mov     edx, [esp+34h+var_C]
    push    ecx
    push    edx
    lea     ecx, [esp+3Ch+var_10]
    call    nullsub_2
    mov     eax, [esp+34h+var_C]
    push    eax
    call    sub_4B4F20
    lea     ecx, [ebp+esi*8+0]
    add     esp, 4
    mov     [esp+34h+var_4], ecx
    lea     ecx, [esp+34h+var_10]
    call    sub_40C5B0
    lea     edx, [ebp+eax*8+0]
    mov     [esp+34h+var_C], ebp
    mov     [esp+34h+var_8], edx
    jmp     short loc_40A33D
    ; ---------------------------------------------------------------------------

    loc_40A335:                             ; CODE XREF: sub_40A260+66j
    mov     edx, [esp+34h+var_8]
    mov     ebp, [esp+34h+var_C]

    loc_40A33D:                             ; CODE XREF: sub_40A260+D3j
    mov     esi, [esp+34h+arg_0]
    mov     ecx, [esp+34h+arg_4]
    mov     ebx, [esp+34h+arg_C]
    mov     eax, [esi+14Ah]
    imul    ebx, ebx
    mov     [esp+34h+var_24], eax
    mov     eax, [ecx]
    mov     edi, [ecx+4]
    mov     [esp+34h+var_18], edi
    movsx   edi, word ptr [esp+34h+var_24]
    mov     ecx, [ecx+8]
    shl     edi, 13h
    sub     eax, edi
    movsx   edi, word ptr [esp+34h+var_24+2]
    shl     edi, 13h
    sub     ecx, edi
    add     eax, 80000h
    add     ecx, 80000h
    sar     ecx, 14h
    mov     word ptr [esp+34h+arg_C+2], cx
    mov     ecx, [esp+34h+arg_8]
    sar     eax, 14h
    mov     edi, [ecx+4]
    mov     word ptr [esp+34h+arg_C], ax
    cmp     edi, [ecx+8]
    jz      short loc_40A402
    movsx   ecx, word ptr [esp+34h+arg_C+2]
    movsx   eax, ax
    mov     [esp+34h+arg_4], ecx
    mov     [esp+34h+var_24], eax

    loc_40A3AD:                             ; CODE XREF: sub_40A260+19Cj
    movsx   eax, word ptr [edi+2]
    mov     esi, [esp+34h+arg_4]
    mov     ecx, [esp+34h+var_24]
    sub     eax, esi
    movsx   esi, word ptr [edi]
    sub     esi, ecx
    mov     ecx, eax
    imul    esi, esi
    imul    ecx, eax
    add     esi, ecx
    cmp     esi, ebx
    jg      short loc_40A3F2
    push    edi
    push    edx
    lea     ecx, [esp+3Ch+var_10]
    call    sub_40CA50
    mov     edx, [esp+34h+var_8]
    neg     esi
    mov     [esp+34h+var_20], esi
    fild    [esp+34h+var_20]
    fstp    dword ptr [edx-4]
    mov     edx, [esp+34h+var_8]
    mov     ebp, [esp+34h+var_C]

    loc_40A3F2:                             ; CODE XREF: sub_40A260+16Cj
    mov     eax, [esp+34h+arg_8]
    add     edi, 8
    cmp     edi, [eax+8]
    jnz     short loc_40A3AD
    mov     esi, [esp+34h+arg_0]

    loc_40A402:                             ; CODE XREF: sub_40A260+13Bj
    mov     ecx, edx
    sub     ecx, ebp
    and     ecx, 0FFFFFFF8h
    cmp     ecx, 10h
    jl      short loc_40A421
    push    0
    push    0
    push    edx
    push    ebp
    call    sub_40D620
    mov     edx, [esp+34h+var_8]
    mov     ebp, [esp+34h+var_C]

    loc_40A421:                             ; CODE XREF: sub_40A260+1ACj
    or      ebx, 0FFFFFFFFh
    mov     [esp+34h+arg_4], 0

    loc_40A42C:                             ; CODE XREF: sub_40A260+2FDj
    test    ebp, ebp
    jnz     short loc_40A434
    xor     edx, edx
    jmp     short loc_40A439
    ; ---------------------------------------------------------------------------

    loc_40A434:                             ; CODE XREF: sub_40A260+1CEj
    sub     edx, ebp
    sar     edx, 3

    loc_40A439:                             ; CODE XREF: sub_40A260+1D2j
    xor     eax, eax
    test    edx, edx
    setz    al
    test    al, al
    jnz     loc_40A562
    movsx   eax, word ptr [esi+14Ah]
    mov     ecx, [ebp+0]
    sub     eax, 3
    cdq
    sub     eax, edx
    mov     [esp+34h+arg_8], ecx
    mov     cx, word ptr [esp+34h+arg_8]
    sar     eax, 1
    neg     eax
    add     cx, ax
    movsx   eax, word ptr [esi+14Ch]
    sub     eax, 3
    mov     word ptr [esp+34h+arg_8], cx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     edx, eax
    mov     ax, word ptr [esp+34h+arg_8+2]
    neg     edx
    add     ax, dx
    movsx   edx, word ptr [esp+34h+arg_C+2]
    mov     word ptr [esp+34h+arg_8+2], ax
    movsx   eax, ax
    sub     eax, edx
    movsx   edx, word ptr [esp+34h+arg_C]
    movsx   ecx, cx
    sub     ecx, edx
    mov     esi, ecx
    imul    esi, ecx
    mov     ecx, eax
    imul    ecx, eax
    add     esi, ecx
    test    ebx, ebx
    jl      short loc_40A4BF
    lea     edx, [ebx+0A0h]
    cmp     esi, edx
    jg      loc_40A562

    loc_40A4BF:                             ; CODE XREF: sub_40A260+24Fj
    mov     edi, [esp+34h+arg_8]
    mov     eax, [esp+34h+arg_0]
    push    0
    push    0
    push    edi
    push    eax
    call    sub_47D2E0
    test    eax, eax
    jz      short loc_40A4F5
    call    sub_47C770
    cmp     eax, [esp+34h+arg_4]
    jle     short loc_40A4F5
    mov     [esp+34h+var_20], edi
    call    sub_47C770
    cmp     ebx, 0FFFFFFFFh
    mov     [esp+34h+arg_4], eax
    jnz     short loc_40A4F5
    mov     ebx, esi

    loc_40A4F5:                             ; CODE XREF: sub_40A260+274j
                                            ; sub_40A260+27Fj ...
    mov     ecx, [esp+34h+var_8]
    mov     edi, [esp+34h+var_C]
    push    0
    sub     esp, 8
    lea     esi, [ecx-8]
    mov     ecx, esp
    push    esi
    call    sub_40A5B0
    push    esi
    push    esi
    push    edi
    call    sub_40D700
    mov     ecx, [esp+34h+var_8]
    mov     edx, ecx
    lea     eax, [ecx]
    cmp     eax, ecx
    jz      short loc_40A53C
    lea     ecx, [eax-8]

    loc_40A524:                             ; CODE XREF: sub_40A260+2D6j
    mov     esi, [eax]
    add     eax, 8
    mov     [ecx], esi
    mov     esi, [eax-4]
    mov     [ecx+4], esi
    add     ecx, 8
    cmp     eax, edx
    jnz     short loc_40A524
    mov     ecx, [esp+34h+var_8]

    loc_40A53C:                             ; CODE XREF: sub_40A260+2BFj
    push    ecx
    add     ecx, 0FFFFFFF8h
    push    ecx
    lea     ecx, [esp+3Ch+var_10]
    call    nullsub_2
    mov     edx, [esp+34h+var_8]
    mov     ebp, [esp+34h+var_C]
    mov     esi, [esp+34h+arg_0]
    sub     edx, 8
    mov     [esp+34h+var_8], edx
    jmp     loc_40A42C
    ; ---------------------------------------------------------------------------

    loc_40A562:                             ; CODE XREF: sub_40A260+1E2j
                                            ; sub_40A260+259j
    mov     eax, [esp+34h+arg_4]
    test    eax, eax
    jnz     short loc_40A57F
    push    ebp
    call    sub_4B4F20
    add     esp, 4
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_40A57F:                             ; CODE XREF: sub_40A260+308j
    mov     eax, [esp+34h+arg_10]
    test    eax, eax
    jz      short loc_40A58D
    mov     edx, [esp+34h+var_20]
    mov     [eax], edx

    loc_40A58D:                             ; CODE XREF: sub_40A260+325j
    push    ebp
    call    sub_4B4F20
    add     esp, 4
    mov     al, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    14h
    sub_40A260 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40A5B0 proc near                    ; CODE XREF: sub_40A260+2A8p

    arg_0= dword ptr  4

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     edx, [ecx]
    mov     [eax], edx
    mov     ecx, [ecx+4]
    mov     [eax+4], ecx
    retn    4
    sub_40A5B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40A5D0 proc near                    ; CODE XREF: sub_40BFE0+1C4p

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 28h
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+2Ch+arg_0]
    push    ebp
    mov     edx, [eax+391E9h]
    push    esi
    movsx   esi, word ptr [ebx+14Ch]
    mov     eax, [edx+0D30h]
    push    edi
    movsx   edx, word ptr [ebx+14Ah]
    imul    eax, esi
    imul    eax, edx
    shl     eax, 1
    mov     [esp+38h+var_14], eax
    mov     ax, [ebx+1C0h]
    test    ax, ax
    lea     edx, [ecx+0F1h]
    jl      short loc_40A61E
    lea     edx, [ecx+0FDh]

    loc_40A61E:                             ; CODE XREF: sub_40A5D0+46j
    mov     esi, [edx]
    lea     edx, [ecx+0F5h]
    test    ax, ax
    mov     [esp+38h+var_10], esi
    jl      short loc_40A635
    lea     edx, [ecx+101h]

    loc_40A635:                             ; CODE XREF: sub_40A5D0+5Dj
    mov     edx, [edx]
    test    ax, ax
    mov     [esp+38h+var_8], edx
    jge     short loc_40A64C
    mov     eax, [ecx+0F9h]
    mov     [esp+38h+var_24], eax
    jmp     short loc_40A656
    ; ---------------------------------------------------------------------------

    loc_40A64C:                             ; CODE XREF: sub_40A5D0+6Ej
    mov     ecx, [ecx+105h]
    mov     [esp+38h+var_24], ecx

    loc_40A656:                             ; CODE XREF: sub_40A5D0+7Aj
    movsx   eax, word ptr [esp+38h+var_10+2]
    movsx   edx, si
    mov     [esp+38h+var_20], 0
    mov     [esp+38h+var_1C], edx
    mov     [esp+38h+var_18], eax

    loc_40A66E:                             ; CODE XREF: sub_40A5D0+1B1j
    mov     ecx, [esp+38h+arg_8]
    push    ecx                             ; int
    call    GetRandom
    mov     edi, eax
    push    10000h                          ; int
    shl     edi, 10h
    call    GetRandom
    mov     ebp, eax
    push    edi
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    edi
    push    ebp
    call    sub_4B7123
    mov     ecx, [esp+40h+arg_4]
    mov     edi, [esp+40h+var_1C]
    neg     eax
    mov     edx, [ecx]
    mov     ebp, [ecx+8]
    mov     ecx, [ebx+14Ah]
    add     esi, edx
    mov     [esp+40h+arg_0], ecx
    add     eax, ebp
    movsx   edx, cx
    movsx   ecx, word ptr [esp+40h+arg_0+2]
    shl     ecx, 13h
    mov     ebp, [esp+40h+var_24]
    sub     eax, ecx
    movsx   ecx, word ptr [ebx+14Ah]
    add     eax, 80000h
    add     esp, 8
    shl     edx, 13h
    sar     eax, 14h
    sub     esi, edx
    mov     word ptr [esp+38h+var_28+2], ax
    add     esi, 80000h
    mov     eax, edi
    sar     esi, 14h
    sub     eax, ebp
    mov     word ptr [esp+38h+var_28], si
    mov     edx, [esp+38h+var_28]
    sub     eax, ecx
    push    eax                             ; int
    mov     [esp+3Ch+arg_0], edx
    call    GetRandom
    mov     ecx, eax
    movsx   eax, si
    cdq
    idiv    edi
    mov     edx, [esp+38h+var_8]
    mov     esi, [esp+38h+var_18]
    add     edx, ecx
    movsx   ecx, word ptr [ebx+14Ch]
    imul    eax, [esp+38h+var_10]
    add     eax, edx
    mov     word ptr [esp+38h+arg_0], ax
    mov     eax, esi
    sub     eax, ebp
    sub     eax, ecx
    push    eax                             ; int
    call    GetRandom
    mov     ecx, eax
    push    1
    movsx   eax, word ptr [esp+3Ch+arg_0+2]
    cdq
    idiv    esi
    mov     edx, [esp+3Ch+var_8+2]
    add     edx, ecx
    imul    eax, [esp+3Ch+var_10+2]
    add     eax, edx
    mov     word ptr [esp+3Ch+arg_0+2], ax
    mov     esi, [esp+3Ch+arg_0]
    push    esi
    push    0
    push    ebx
    call    sub_47DB70
    test    eax, eax
    jz      short loc_40A775
    call    sub_47C770
    cmp     eax, [esp+38h+var_14]
    jle     short loc_40A793

    loc_40A775:                             ; CODE XREF: sub_40A5D0+198j
    mov     eax, [esp+38h+var_20]
    inc     eax
    cmp     eax, 1Eh
    mov     [esp+38h+var_20], eax
    jl      loc_40A66E
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_40A793:                             ; CODE XREF: sub_40A5D0+1A3j
    mov     eax, [esp+38h+arg_C]
    test    eax, eax
    jz      short loc_40A79D
    mov     [eax], esi

    loc_40A79D:                             ; CODE XREF: sub_40A5D0+1C9j
    mov     al, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    sub_40A5D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40A7B0 proc near                    ; CODE XREF: sub_40B370+Bp

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 1Ch
    mov     edx, [ecx+55h]
    cmp     edx, edx
    mov     eax, edx
    push    ebx
    push    ebp
    push    esi
    lea     esi, [ecx+4Dh]
    push    edi
    mov     ecx, [esi+4]
    jz      short loc_40A7DA

    loc_40A7C6:                             ; CODE XREF: sub_40A7B0+28j
    mov     edi, [eax]
    add     eax, 8
    mov     [ecx], edi
    mov     edi, [eax-4]
    mov     [ecx+4], edi
    add     ecx, 8
    cmp     eax, edx
    jnz     short loc_40A7C6

    loc_40A7DA:                             ; CODE XREF: sub_40A7B0+14j
    mov     eax, [esi+8]
    mov     [esi+8], ecx
    mov     [esp+2Ch+var_C], eax
    mov     eax, TAdynmemStructPtr
    xor     ebp, ebp
    mov     ecx, [eax+14237h]
    mov     edi, [eax+14233h]
    test    ecx, ecx
    mov     [esp+2Ch+var_C], edi
    mov     [esp+2Ch+var_14], ebp
    jle     loc_40AA2C

    loc_40A807:                             ; CODE XREF: sub_40A7B0+276j
    push    ebp
    push    0
    call    sub_481550
    xor     ebx, ebx
    test    edi, edi
    mov     [esp+2Ch+var_1C], ebx
    jle     loc_40AA16
    add     eax, 8
    mov     [esp+2Ch+var_18], eax

    loc_40A824:                             ; CODE XREF: sub_40A7B0+260j
    mov     ax, [eax]
    cmp     ax, 0FFFBh
    jnb     loc_40A9FA
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFFFh
    shl     eax, 8
    mov     ecx, [ecx+1426Fh]
    add     ecx, eax
    fld     dword ptr [ecx+0F0h]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 40h
    jnz     loc_40A9FA
    test    byte ptr [ecx+0FFh], 2
    jz      loc_40A9FA
    mov     eax, [esi+8]
    mov     edx, [esi+0Ch]
    fld     dword ptr [ecx+0F0h]
    sub     edx, eax
    mov     word ptr [esp+2Ch+var_8], bx
    sar     edx, 3
    fstp    [esp+2Ch+var_4]
    cmp     edx, 1
    mov     word ptr [esp+2Ch+var_8+2], bp
    mov     edi, eax
    jnb     loc_40A952
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_40A8A0
    xor     ecx, ecx
    jmp     short loc_40A8A7
    ; ---------------------------------------------------------------------------

    loc_40A8A0:                             ; CODE XREF: sub_40A7B0+EAj
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 3

    loc_40A8A7:                             ; CODE XREF: sub_40A7B0+EEj
    cmp     ecx, 1
    jbe     short loc_40A8BD
    test    edx, edx
    jnz     short loc_40A8B4
    xor     ebx, ebx
    jmp     short loc_40A8C2
    ; ---------------------------------------------------------------------------

    loc_40A8B4:                             ; CODE XREF: sub_40A7B0+FEj
    sub     eax, edx
    sar     eax, 3
    mov     ebx, eax
    jmp     short loc_40A8C2
    ; ---------------------------------------------------------------------------

    loc_40A8BD:                             ; CODE XREF: sub_40A7B0+FAj
    mov     ebx, 1

    loc_40A8C2:                             ; CODE XREF: sub_40A7B0+102j
                                            ; sub_40A7B0+10Bj
    mov     ecx, esi
    call    sub_40C5B0
    add     eax, ebx
    mov     [esp+2Ch+var_10], eax
    jns     short loc_40A8D3
    xor     eax, eax

    loc_40A8D3:                             ; CODE XREF: sub_40A7B0+11Fj
    shl     eax, 3
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esi+4]
    add     esp, 4
    mov     ebx, eax
    push    ebx
    push    edi
    push    ecx
    mov     ecx, esi
    call    sub_40CC40
    lea     edx, [esp+2Ch+var_8]
    mov     ebp, eax
    push    edx
    push    1
    push    ebp
    mov     ecx, esi
    call    sub_40D5B0
    mov     eax, [esi+8]
    add     ebp, 8
    push    ebp
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_40CC40
    mov     ecx, [esi+8]
    mov     edx, [esi+4]
    push    ecx
    push    edx
    mov     ecx, esi
    call    nullsub_2
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+30h+var_10]
    add     esp, 4
    lea     ecx, [ebx+eax*8]
    mov     [esi+0Ch], ecx
    mov     ecx, esi
    call    sub_40C5B0
    mov     ebp, [esp+2Ch+var_14]
    lea     edx, [ebx+eax*8+8]
    mov     [esi+4], ebx
    mov     ebx, [esp+2Ch+var_1C]
    mov     [esi+8], edx
    jmp     loc_40A9FA
    ; ---------------------------------------------------------------------------

    loc_40A952:                             ; CODE XREF: sub_40A7B0+DFj
    mov     ecx, eax
    sub     ecx, edi
    sar     ecx, 3
    cmp     ecx, 1
    jnb     short loc_40A9A9
    lea     ecx, [edi+8]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_40CC40
    mov     eax, [esi+8]
    lea     edx, [esp+2Ch+var_8]
    mov     ecx, eax
    push    edx
    sub     ecx, edi
    mov     edx, 1
    sar     ecx, 3
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_40D5B0
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40A9F6

    loc_40A993:                             ; CODE XREF: sub_40A7B0+1F5j
    mov     edx, [esp+2Ch+var_8]
    mov     [eax], edx
    mov     edx, [esp+2Ch+var_4]
    mov     [eax+4], edx
    add     eax, 8
    cmp     eax, ecx
    jnz     short loc_40A993
    jmp     short loc_40A9F6
    ; ---------------------------------------------------------------------------

    loc_40A9A9:                             ; CODE XREF: sub_40A7B0+1ACj
    lea     ecx, [eax-8]
    push    eax
    push    eax
    mov     [esp+34h+var_10], ecx
    push    ecx
    mov     ecx, esi
    call    sub_40CC40
    mov     ecx, [esi+8]
    lea     eax, [ecx-8]
    cmp     edi, eax
    jz      short loc_40A9D9

    loc_40A9C4:                             ; CODE XREF: sub_40A7B0+227j
    mov     edx, [eax-8]
    sub     eax, 8
    sub     ecx, 8
    cmp     eax, edi
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    jnz     short loc_40A9C4

    loc_40A9D9:                             ; CODE XREF: sub_40A7B0+212j
    lea     ecx, [edi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40A9F6

    loc_40A9E2:                             ; CODE XREF: sub_40A7B0+244j
    mov     edx, [esp+2Ch+var_8]
    mov     [eax], edx
    mov     edx, [esp+2Ch+var_4]
    mov     [eax+4], edx
    add     eax, 8
    cmp     eax, ecx
    jnz     short loc_40A9E2

    loc_40A9F6:                             ; CODE XREF: sub_40A7B0+1E1j
                                            ; sub_40A7B0+1F7j ...
    add     dword ptr [esi+8], 8

    loc_40A9FA:                             ; CODE XREF: sub_40A7B0+7Bj
                                            ; sub_40A7B0+A8j ...
    mov     eax, [esp+2Ch+var_18]
    mov     edi, [esp+2Ch+var_C]
    inc     ebx
    add     eax, 0Dh
    cmp     ebx, edi
    mov     [esp+2Ch+var_1C], ebx
    mov     [esp+2Ch+var_18], eax
    jl      loc_40A824

    loc_40AA16:                             ; CODE XREF: sub_40A7B0+67j
    mov     eax, TAdynmemStructPtr
    inc     ebp
    mov     [esp+2Ch+var_14], ebp
    cmp     ebp, [eax+14237h]
    jl      loc_40A807

    loc_40AA2C:                             ; CODE XREF: sub_40A7B0+51j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    sub_40A7B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40AA40 proc near                    ; CODE XREF: .text:0040AD3Ep
                                            ; sub_40B2C0+29p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 14h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+0Dh]
    mov     edx, [esi+9]
    lea     ecx, [esi+5]
    push    eax
    push    edx
    call    sub_40C9F0
    mov     eax, [esi+2Dh]
    mov     edx, [esi+29h]
    lea     ecx, [esi+25h]
    push    eax
    push    edx
    call    sub_40C9F0
    mov     eax, [esi+1Dh]
    mov     ecx, [esi+19h]
    lea     edi, [esi+15h]
    push    eax
    push    ecx
    mov     ecx, edi
    call    sub_40C9F0
    xor     edx, edx
    mov     [esi+75h], edx
    mov     [esi+79h], edx
    mov     ecx, [esi+85h]
    mov     eax, [esi+81h]
    cmp     eax, ecx
    mov     [esp+24h+var_10], edx
    mov     [esp+24h+var_C], edx
    mov     [esp+24h+var_8], edx
    mov     [esp+24h+var_4], edx
    jz      short loc_40AAAD

    loc_40AAA3:                             ; CODE XREF: sub_40AA40+6Bj
    mov     [eax], dx
    add     eax, 2
    cmp     eax, ecx
    jnz     short loc_40AAA3

    loc_40AAAD:                             ; CODE XREF: sub_40AA40+61j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14357h]
    add     ecx, 118h
    mov     [esp+24h+var_14], ecx
    mov     edx, [eax+1435Bh]
    cmp     ecx, edx
    ja      loc_40AC9C
    mov     ebx, 1

    loc_40AAD5:                             ; CODE XREF: sub_40AA40+256j
    mov     eax, [ecx+110h]
    test    eax, 10000000h
    jz      loc_40AC81
    test    ah, 40h
    jnz     loc_40AC81
    mov     edx, [ecx+96h]
    mov     eax, [esi]
    mov     dl, [edx+146h]
    mov     ebp, edx
    and     ebp, 0FFh
    cmp     byte ptr [eax+ebp+108h], 0
    jnz     short loc_40AB6A
    push    ecx                             ; Unit
    push    eax                             ; Player
    call    PlayerCanSeeUnit
    mov     ecx, [esp+24h+var_14]
    test    eax, eax
    jz      short loc_40AB3F
    mov     eax, [ecx+110h]
    test    ah, 80h
    jnz     short loc_40AB3F
    mov     edx, [esi+0Dh]
    lea     ecx, [esi+5]
    lea     eax, [esp+24h+var_14]
    push    eax
    push    ebx
    push    edx
    call    sub_408F30
    mov     ecx, [esp+24h+var_14]

    loc_40AB3F:                             ; CODE XREF: sub_40AA40+DCj
                                            ; sub_40AA40+E7j
    mov     eax, [ecx+110h]
    shr     eax, 8
    test    bl, al
    jz      loc_40AC81
    mov     edx, [edi+8]
    lea     ecx, [esp+24h+var_14]
    push    ecx
    push    ebx
    push    edx
    mov     ecx, edi
    call    sub_408F30
    mov     ecx, [esp+24h+var_14]
    jmp     loc_40AC81
    ; ---------------------------------------------------------------------------

    loc_40AB6A:                             ; CODE XREF: sub_40AA40+CDj
    cmp     dl, [eax+146h]
    jnz     loc_40AC81
    fld     dword ptr [ecx+104h]
    fcomp   ds:dbl_4FC9D8
    fnstsw  ax
    test    ah, 40h
    jz      loc_40AC81
    xor     eax, eax
    mov     ax, [ecx+0A6h]
    mov     ecx, [esi+81h]
    inc     word ptr [ecx+eax*2]
    lea     eax, [ecx+eax*2]
    mov     ecx, [esp+24h+var_14]
    mov     edx, [ecx+92h]
    mov     eax, [edx+156h]
    test    eax, eax
    jz      short loc_40ABBA
    inc     dword ptr [esi+75h]

    loc_40ABBA:                             ; CODE XREF: sub_40AA40+175j
    mov     eax, [ecx+92h]
    mov     eax, [eax+241h]
    test    al, 40h
    jz      short loc_40ABED
    test    ah, 2
    jz      short loc_40ABED
    test    [ecx+10Eh], bl
    jz      short loc_40ABED
    mov     edx, [esi+2Dh]
    lea     ecx, [esp+24h+var_14]
    push    ecx
    lea     ecx, [esi+25h]
    push    ebx
    push    edx
    call    sub_408F30
    mov     ecx, [esp+24h+var_14]

    loc_40ABED:                             ; CODE XREF: sub_40AA40+188j
                                            ; sub_40AA40+18Dj ...
    mov     eax, [ecx+92h]
    mov     edx, [eax+241h]
    test    dh, 4
    jz      short loc_40AC09
    test    [ecx+10Eh], bl
    jz      short loc_40AC09
    mov     [esi+79h], ebx

    loc_40AC09:                             ; CODE XREF: sub_40AA40+1BCj
                                            ; sub_40AA40+1C4j
    mov     eax, [esi+0A1h]
    xor     edx, edx
    mov     dx, [ecx+0A6h]
    fild    dword ptr [ecx+6Ah]
    movsx   edx, byte ptr [eax+edx]
    fild    dword ptr [ecx+6Eh]
    fild    dword ptr [ecx+72h]
    mov     [esp+24h+var_14], edx
    fild    [esp+24h+var_14]
    fxch    st(3)
    fmul    st, st(3)
    fld     st(3)
    fxch    st(3)
    fmul    st, st(4)
    fxch    st(3)
    fadd    [esp+24h+var_4]
    fxch    st(2)
    fmul    st, st(4)
    fxch    st(1)
    fmul    ds:flt_4FC9E0
    fxch    st(2)
    fstp    [esp+24h+var_4]
    fxch    st(2)
    fmul    ds:flt_4FC9E0
    fxch    st(1)
    fsubr   [esp+24h+var_10]
    fxch    st(2)
    fmul    ds:flt_4FC9E0
    fxch    st(1)
    fsubr   [esp+24h+var_C]
    fxch    st(2)
    fstp    [esp+24h+var_10]
    fsubr   [esp+24h+var_8]
    fxch    st(1)
    fstp    [esp+24h+var_C]
    fstp    [esp+24h+var_8]
    fstp    st

    loc_40AC81:                             ; CODE XREF: sub_40AA40+A0j
                                            ; sub_40AA40+A9j ...
    mov     eax, TAdynmemStructPtr
    add     ecx, 118h
    mov     [esp+24h+var_14], ecx
    cmp     ecx, [eax+1435Bh]
    jbe     loc_40AAD5

    loc_40AC9C:                             ; CODE XREF: sub_40AA40+8Aj
    fld     [esp+24h+var_4]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_40ACD1
    fld     [esp+24h+var_10]
    fdiv    [esp+24h+var_4]
    fstp    [esp+24h+var_10]
    fld     [esp+24h+var_C]
    fdiv    [esp+24h+var_4]
    fstp    [esp+24h+var_C]
    fld     [esp+24h+var_8]
    fdiv    [esp+24h+var_4]
    fstp    [esp+24h+var_8]

    loc_40ACD1:                             ; CODE XREF: sub_40AA40+26Bj
    fld     [esp+24h+var_10]
    fmul    ds:dbl_4FC9E8
    call    __ftol
    fld     [esp+24h+var_C]
    fmul    ds:dbl_4FC9E8
    mov     edi, eax
    call    __ftol
    fld     [esp+24h+var_8]
    fmul    ds:dbl_4FC9E8
    mov     ebx, eax
    call    __ftol
    add     esi, 35h
    mov     [esi], edi
    pop     edi
    mov     [esi+4], ebx
    mov     [esi+8], eax
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    sub_40AA40 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, ecx
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esi+0EDh]
    mov     edx, [ecx+38A47h]
    add     eax, 1Eh
    cmp     edx, eax
    jb      short loc_40AD67
    mov     ecx, esi
    call    sub_40AA40
    mov     edx, TAdynmemStructPtr
    push    1Eh
    mov     eax, [edx+38A47h]
    mov     [esi+0EDh], eax
    call    GetRandom
    test    eax, eax
    jnz     short loc_40AD67
    mov     ecx, esi
    call    sub_409730

    loc_40AD67:                             ; CODE XREF: .text:0040AD3Aj
                                            ; .text:0040AD5Ej
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+0Ch]
    push    eax
    call    sub_488F30
    fstp    st
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40AD80 proc near                    ; CODE XREF: .text:00401D2Cp
                                            ; .text:00402379p ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_10= dword ptr  14h

    sub     esp, 18h
    mov     eax, [esp+18h+arg_8]
    push    ebx
    imul    eax, eax
    mov     [esp+1Ch+var_18], eax
    mov     eax, [esp+1Ch+arg_0]
    push    ebp
    push    esi
    mov     ecx, dword_5119C0[eax*4]
    mov     eax, [ecx+9]
    mov     esi, [esp+24h+arg_10]
    add     ecx, 5
    push    edi
    mov     [esp+28h+var_14], ecx
    mov     edx, [ecx+8]
    mov     [esp+28h+arg_8], eax
    cmp     eax, edx
    jz      loc_40AE67

    loc_40ADBA:                             ; CODE XREF: sub_40AD80+DFj
    mov     edi, [eax]
    mov     ebx, [esp+28h+arg_4]
    mov     [esp+28h+arg_10], edi
    mov     ecx, [ebx+8]
    mov     eax, [edi+72h]
    mov     ebp, [edi+6Ah]
    sub     ecx, eax
    mov     eax, [ebx]
    sub     eax, ebp
    cdq
    mov     ebp, eax
    mov     eax, ecx
    mov     [esp+28h+var_4], edx
    cdq
    mov     [esp+28h+var_10], eax
    mov     eax, [esp+28h+var_4]
    push    eax
    push    ebp
    push    eax
    push    ebp
    mov     [esp+38h+var_C], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ecx, [esp+28h+var_C]
    mov     ebp, eax
    mov     eax, [esp+28h+var_10]
    push    ecx
    push    eax
    push    ecx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     ebp, eax
    mov     eax, [esp+28h+var_18]
    cmp     ebp, eax
    jg      short loc_40AE4B
    mov     edi, [edi+110h]
    test    edi, 10000000h
    jz      short loc_40AE4B
    test    edi, 4000h
    jnz     short loc_40AE4B
    mov     edx, [esi+8]
    lea     ecx, [esp+28h+arg_10]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_408F30

    loc_40AE4B:                             ; CODE XREF: sub_40AD80+A1j
                                            ; sub_40AD80+AFj ...
    mov     ecx, [esp+28h+var_14]
    mov     eax, [esp+28h+arg_8]
    add     eax, 4
    mov     edx, [ecx+8]
    mov     [esp+28h+arg_8], eax
    cmp     eax, edx
    jnz     loc_40ADBA
    jmp     short loc_40AE6B
    ; ---------------------------------------------------------------------------

    loc_40AE67:                             ; CODE XREF: sub_40AD80+34j
    mov     ebx, [esp+28h+arg_4]

    loc_40AE6B:                             ; CODE XREF: sub_40AD80+E5j
    mov     edx, [esp+28h+arg_0]
    mov     edi, dword_5119C0[edx*4]
    mov     [esp+28h+var_14], edi
    mov     eax, [edi+79h]
    test    eax, eax
    jz      loc_40B0B8
    mov     ecx, [esi+4]
    test    ecx, ecx
    jnz     short loc_40AE90
    xor     eax, eax
    jmp     short loc_40AE98
    ; ---------------------------------------------------------------------------

    loc_40AE90:                             ; CODE XREF: sub_40AD80+10Aj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_40AE98:                             ; CODE XREF: sub_40AD80+10Ej
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    test    cl, cl
    jz      loc_40B0B8
    mov     eax, [edi+19h]
    mov     ecx, [edi+1Dh]
    cmp     eax, ecx
    mov     [esp+28h+arg_8], eax
    jz      loc_40B0B8
    jmp     short loc_40AEC3
    ; ---------------------------------------------------------------------------

    loc_40AEBB:                             ; CODE XREF: sub_40AD80+332j
    mov     eax, [esp+28h+arg_8]
    mov     ebx, [esp+28h+arg_4]

    loc_40AEC3:                             ; CODE XREF: sub_40AD80+139j
    mov     edi, [eax]
    mov     eax, [ebx]
    mov     ecx, [ebx+8]
    mov     [esp+28h+arg_0], edi
    mov     edx, [edi+6Ah]
    mov     ebp, [edi+72h]
    sub     eax, edx
    sub     ecx, ebp
    cdq
    mov     ebx, eax
    mov     ebp, edx
    mov     eax, ecx
    push    ebp
    cdq
    push    ebx
    push    ebp
    push    ebx
    mov     [esp+38h+var_8], eax
    mov     [esp+38h+var_4], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ecx, [esp+28h+var_4]
    mov     ebx, eax
    mov     eax, [esp+28h+var_8]
    push    ecx
    push    eax
    push    ecx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     ebx, eax
    mov     eax, [esp+28h+var_18]
    cmp     ebx, eax
    jg      loc_40B09E
    mov     edi, [edi+110h]
    test    edi, 10000000h
    jz      loc_40B09E
    test    edi, 4000h
    jnz     loc_40B09E
    mov     eax, [esi+8]
    mov     edx, [esi+0Ch]
    sub     edx, eax
    mov     edi, eax
    sar     edx, 2
    cmp     edx, 1
    jnb     loc_40B00C
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_40AF65
    xor     ecx, ecx
    jmp     short loc_40AF6C
    ; ---------------------------------------------------------------------------

    loc_40AF65:                             ; CODE XREF: sub_40AD80+1DFj
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2

    loc_40AF6C:                             ; CODE XREF: sub_40AD80+1E3j
    cmp     ecx, 1
    jbe     short loc_40AF82
    test    edx, edx
    jnz     short loc_40AF79
    xor     ecx, ecx
    jmp     short loc_40AF87
    ; ---------------------------------------------------------------------------

    loc_40AF79:                             ; CODE XREF: sub_40AD80+1F3j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_40AF87
    ; ---------------------------------------------------------------------------

    loc_40AF82:                             ; CODE XREF: sub_40AD80+1EFj
    mov     ecx, 1

    loc_40AF87:                             ; CODE XREF: sub_40AD80+1F7j
                                            ; sub_40AD80+200j
    test    edx, edx
    jnz     short loc_40AF8F
    xor     eax, eax
    jmp     short loc_40AF94
    ; ---------------------------------------------------------------------------

    loc_40AF8F:                             ; CODE XREF: sub_40AD80+209j
    sub     eax, edx
    sar     eax, 2

    loc_40AF94:                             ; CODE XREF: sub_40AD80+20Dj
    add     eax, ecx
    test    eax, eax
    mov     [esp+28h+arg_10], eax
    jge     short loc_40AFA0
    xor     eax, eax

    loc_40AFA0:                             ; CODE XREF: sub_40AD80+21Cj
    shl     eax, 2
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esi+4]
    add     esp, 4
    mov     ebx, eax
    push    ebx
    push    edi
    push    ecx
    mov     ecx, esi
    call    sub_406C10
    lea     edx, [esp+28h+arg_0]
    mov     ebp, eax
    push    edx
    push    1
    push    ebp
    mov     ecx, esi
    call    sub_406C40
    mov     eax, [esi+8]
    add     ebp, 4
    push    ebp
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+4]
    push    eax
    mov     [esp+2Ch+var_10], eax
    call    sub_4B4F20
    mov     ecx, [esp+2Ch+arg_10]
    add     esp, 4
    lea     edx, [ebx+ecx*4]
    mov     ecx, esi
    mov     [esi+0Ch], edx
    call    sub_40C560
    lea     eax, [ebx+eax*4+4]
    mov     [esi+4], ebx
    mov     [esi+8], eax
    jmp     loc_40B09E
    ; ---------------------------------------------------------------------------

    loc_40B00C:                             ; CODE XREF: sub_40AD80+1D4j
    mov     ecx, eax
    sub     ecx, edi
    sar     ecx, 2
    cmp     ecx, 1
    jnb     short loc_40B05A
    lea     ecx, [edi+4]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+8]
    lea     edx, [esp+28h+arg_0]
    mov     ecx, eax
    push    edx
    sub     ecx, edi
    mov     edx, 1
    sar     ecx, 2
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_406C40
    mov     eax, [esi+8]
    cmp     edi, eax
    jz      short loc_40B09A

    loc_40B04B:                             ; CODE XREF: sub_40AD80+2D6j
    mov     ecx, [esp+28h+arg_0]
    mov     [edi], ecx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_40B04B
    jmp     short loc_40B09A
    ; ---------------------------------------------------------------------------

    loc_40B05A:                             ; CODE XREF: sub_40AD80+296j
    lea     ecx, [eax-4]
    push    eax
    push    eax
    mov     [esp+30h+arg_10], ecx
    push    ecx
    mov     ecx, esi
    call    sub_406C10
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_40B084

    loc_40B075:                             ; CODE XREF: sub_40AD80+302j
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_40B075

    loc_40B084:                             ; CODE XREF: sub_40AD80+2F3j
    lea     ecx, [edi+4]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40B09A

    loc_40B08D:                             ; CODE XREF: sub_40AD80+318j
    mov     edx, [esp+28h+arg_0]
    mov     [eax], edx
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_40B08D

    loc_40B09A:                             ; CODE XREF: sub_40AD80+2C9j
                                            ; sub_40AD80+2D8j ...
    add     dword ptr [esi+8], 4

    loc_40B09E:                             ; CODE XREF: sub_40AD80+1A0j
                                            ; sub_40AD80+1B2j ...
    mov     ecx, [esp+28h+var_14]
    mov     eax, [esp+28h+arg_8]
    add     eax, 4
    mov     edx, [ecx+1Dh]
    mov     [esp+28h+arg_8], eax
    cmp     eax, edx
    jnz     loc_40AEBB

    loc_40B0B8:                             ; CODE XREF: sub_40AD80+FFj
                                            ; sub_40AD80+121j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    14h
    sub_40AD80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_40B0D0(int,int,int)
    sub_40B0D0 proc near                    ; CODE XREF: GameUnit_LOS_Radar+288p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 10h
    mov     eax, [esp+10h+arg_8]
    push    ebx
    imul    eax, eax
    mov     [esp+14h+var_10], eax
    mov     eax, [esp+14h+arg_0]
    push    ebp
    push    esi
    mov     ecx, dword_5119C0[eax*4]
    mov     eax, [ecx+9]
    add     ecx, 5
    push    edi
    mov     [esp+20h+arg_8], eax
    mov     ecx, [ecx+8]
    cmp     eax, ecx
    mov     [esp+20h+var_C], ecx
    jz      loc_40B1A9
    mov     ecx, [esp+20h+arg_4]
    mov     edx, [ecx+8]
    mov     ecx, [ecx]
    mov     [esp+20h+arg_0], edx
    mov     [esp+20h+arg_4], ecx

    loc_40B117:                             ; CODE XREF: sub_40B0D0+C8j
    mov     esi, [eax]
    mov     eax, [esp+20h+arg_4]
    mov     ecx, [esp+20h+arg_0]
    mov     edi, [esi+6Ah]
    mov     ebx, [esi+72h]
    sub     eax, edi
    sub     ecx, ebx
    cdq
    mov     edi, eax
    mov     ebx, edx
    mov     eax, ecx
    push    ebx
    cdq
    push    edi
    push    ebx
    push    edi
    mov     ebp, eax
    mov     [esp+30h+var_4], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edi, eax
    mov     eax, [esp+20h+var_4]
    push    eax
    push    ebp
    push    eax
    push    ebp
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     edi, eax
    mov     eax, [esp+20h+var_10]
    cmp     edi, eax
    jg      short loc_40B185
    mov     esi, [esi+110h]
    test    esi, 10000000h
    jz      short loc_40B185
    test    esi, 4000h
    jz      short loc_40B19D

    loc_40B185:                             ; CODE XREF: sub_40B0D0+9Dj
                                            ; sub_40B0D0+ABj
    mov     eax, [esp+20h+arg_8]
    mov     ecx, [esp+20h+var_C]
    add     eax, 4
    cmp     eax, ecx
    mov     [esp+20h+arg_8], eax
    jz      short loc_40B1A9
    jmp     loc_40B117
    ; ---------------------------------------------------------------------------

    loc_40B19D:                             ; CODE XREF: sub_40B0D0+B3j
    mov     al, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40B1A9:                             ; CODE XREF: sub_40B0D0+30j
                                            ; sub_40B0D0+C6j
    pop     edi
    pop     esi
    pop     ebp
    xor     al, al
    pop     ebx
    add     esp, 10h
    retn    0Ch
    sub_40B0D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40B1C0 proc near                    ; CODE XREF: sub_407E90+140p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 18h
    mov     eax, [esp+18h+arg_0]
    mov     [esp+18h+var_18], 0
    mov     ecx, dword_5119C0[eax*4]
    mov     eax, [esp+18h+arg_8]
    imul    eax, eax
    mov     [esp+18h+var_14], eax
    mov     eax, [ecx+9]
    mov     [esp+18h+var_10], ecx
    mov     ecx, [ecx+0Dh]
    cmp     eax, ecx
    mov     [esp+18h+arg_0], eax
    mov     [esp+18h+var_C], ecx
    jz      loc_40B2AA
    mov     ecx, [esp+18h+arg_4]
    push    edi
    push    esi
    push    ebp
    mov     edx, [ecx+8]
    mov     ecx, [ecx]
    push    ebx
    mov     [esp+28h+arg_8], edx
    mov     [esp+28h+arg_4], ecx
    jmp     short loc_40B216
    ; ---------------------------------------------------------------------------

    loc_40B212:                             ; CODE XREF: sub_40B1C0+E0j
    mov     eax, [esp+28h+arg_0]

    loc_40B216:                             ; CODE XREF: sub_40B1C0+50j
    mov     esi, [eax]
    mov     eax, [esp+28h+arg_4]
    mov     ecx, [esp+28h+arg_8]
    mov     edi, [esi+6Ah]
    mov     ebx, [esi+72h]
    sub     eax, edi
    sub     ecx, ebx
    cdq
    mov     edi, eax
    mov     ebx, edx
    mov     eax, ecx
    push    ebx
    cdq
    push    edi
    push    ebx
    push    edi
    mov     ebp, eax
    mov     [esp+38h+var_4], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edi, eax
    mov     eax, [esp+28h+var_4]
    push    eax
    push    ebp
    push    eax
    push    ebp
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     edi, eax
    mov     eax, [esp+28h+var_14]
    cmp     edi, eax
    jg      short loc_40B28F
    mov     eax, [esp+28h+var_10]
    xor     edx, edx
    mov     dx, [esi+0A6h]
    mov     ecx, [eax+91h]
    mov     eax, [esp+28h+var_18]
    movsx   edx, byte ptr [edx+ecx]
    add     eax, edx
    mov     [esp+28h+var_18], eax

    loc_40B28F:                             ; CODE XREF: sub_40B1C0+ACj
    mov     eax, [esp+28h+arg_0]
    mov     ecx, [esp+28h+var_C]
    add     eax, 4
    cmp     eax, ecx
    mov     [esp+28h+arg_0], eax
    jnz     loc_40B212
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_40B2AA:                             ; CODE XREF: sub_40B1C0+35j
    mov     eax, [esp+18h+var_18]
    add     esp, 18h
    retn    0Ch
    sub_40B1C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_40B2C0(int)
    sub_40B2C0 proc near                    ; CODE XREF: UpdateDatePlayers+B7p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, dword_5119C0[eax*4]
    test    esi, esi
    jz      short loc_40B311
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esi+0EDh]
    add     ecx, 30
    cmp     [edx+TAdynmemStruct.GameTime], ecx
    jb      short loc_40B311
    mov     ecx, esi
    call    sub_40AA40
    mov     eax, TAdynmemStructPtr
    push    1Eh                             ; int
    mov     ecx, [eax+TAdynmemStruct.GameTime]
    mov     [esi+0EDh], ecx
    call    GetRandom
    test    eax, eax
    jnz     short loc_40B311
    mov     ecx, esi
    call    sub_409730

    loc_40B311:                             ; CODE XREF: sub_40B2C0+Ej
                                            ; sub_40B2C0+25j ...
    pop     esi
    retn    4
    sub_40B2C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40B320 proc near                    ; CODE XREF: sub_464700+1CDp

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    10Dh                            ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40B350
    push    esi
    mov     ecx, eax
    call    sub_409160
    mov     ecx, eax
    mov     dword_5119C0[esi*4], eax
    call    sub_409730
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_40B350:                             ; CODE XREF: sub_40B320+14j
    xor     eax, eax
    mov     ecx, eax
    mov     dword_5119C0[esi*4], eax
    call    sub_409730
    pop     esi
    retn    4
    sub_40B320 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40B370 proc near                    ; CODE XREF: sub_4649D0+1Dp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, dword_5119C0[eax*4]
    call    sub_40A7B0
    retn    4
    sub_40B370 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40B390 proc near                    ; CODE XREF: sub_464A00+4Fp

    arg_0= dword ptr  8

    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    push    edi
    mov     esi, dword_5119C0[ebp*4]
    xor     edi, edi
    cmp     esi, edi
    jz      loc_40B514
    mov     eax, [esi+0E1h]
    push    ebx
    push    eax
    mov     [esp+10h+arg_0], eax
    call    sub_4B4F20
    lea     ebx, [esi+0CDh]
    add     esp, 4
    mov     [esi+0E1h], edi
    mov     [esi+0E5h], edi
    mov     [esi+0E9h], edi
    mov     eax, [ebx+8]
    mov     ecx, [ebx+4]
    push    eax
    push    ecx
    mov     ecx, ebx
    call    nullsub_4
    mov     edx, [ebx+4]
    push    edx
    call    sub_4B4F20
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     eax, [esi+0C5h]
    mov     ecx, [esi+0C1h]
    lea     ebx, [esi+0BDh]
    add     esp, 4
    push    eax
    push    ecx
    mov     ecx, ebx
    call    nullsub_4
    mov     edx, [ebx+4]
    push    edx
    call    sub_4B4F20
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     eax, [esi+0B5h]
    mov     ecx, [esi+0B1h]
    lea     ebx, [esi+0ADh]
    add     esp, 4
    push    eax
    push    ecx
    mov     ecx, ebx
    call    nullsub_3
    mov     edx, [ebx+4]
    push    edx
    call    sub_4B4F20
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     eax, [esi+0A5h]
    mov     ecx, [esi+0A1h]
    lea     ebx, [esi+9Dh]
    add     esp, 4
    push    eax
    push    ecx
    mov     ecx, ebx
    call    nullsub_39
    mov     edx, [ebx+4]
    push    edx
    call    sub_4B4F20
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     eax, [esi+95h]
    mov     ecx, [esi+91h]
    lea     ebx, [esi+8Dh]
    add     esp, 4
    push    eax
    push    ecx
    mov     ecx, ebx
    call    nullsub_39
    mov     edx, [ebx+4]
    push    edx
    call    sub_4B4F20
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     eax, [esi+85h]
    lea     ebx, [esi+7Dh]
    add     esp, 4
    mov     ecx, [ebx+4]
    push    eax
    push    ecx
    mov     ecx, ebx
    call    nullsub_38
    mov     edx, [ebx+4]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    lea     ecx, [esi+65h]
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    call    sub_40C5D0
    lea     ecx, [esi+4Dh]
    call    sub_40C580
    lea     ecx, [esi+25h]
    call    sub_40C530
    lea     ecx, [esi+15h]
    call    sub_40C530
    lea     ecx, [esi+5]
    call    sub_40C530
    push    esi
    call    sub_4B4F20
    add     esp, 4
    pop     ebx

    loc_40B514:                             ; CODE XREF: sub_40B390+12j
    mov     dword_5119C0[ebp*4], edi
    pop     edi
    pop     esi
    pop     ebp
    retn    4
    sub_40B390 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40B530 proc near                    ; CODE XREF: .text:0041055Fp
                                            ; .text:004109B9p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 10h
    mov     eax, [esp+10h+arg_0]
    mov     ecx, dword_5119C0[eax*4]
    mov     eax, [esp+10h+arg_8]
    imul    eax, eax
    mov     edx, [ecx+2Dh]
    add     ecx, 25h
    mov     [esp+10h+arg_8], eax
    mov     [esp+10h+var_C], ecx
    mov     eax, [ecx+4]
    cmp     eax, edx
    mov     [esp+10h+arg_0], eax
    jz      loc_40B79D
    push    edi
    push    esi
    mov     esi, [esp+18h+arg_C]
    push    ebp
    push    ebx

    loc_40B56A:                             ; CODE XREF: sub_40B530+263j
    mov     edx, [eax]
    mov     ecx, [edx+92h]
    mov     eax, [ecx+241h]
    test    al, 40h
    jz      loc_40B77F
    test    ah, 2
    jz      loc_40B77F
    test    byte ptr [edx+10Eh], 1
    jz      loc_40B77F
    mov     eax, [esp+20h+arg_4]
    mov     edi, [edx+6Ah]
    mov     ebx, [edx+72h]
    mov     ecx, [eax+8]
    mov     eax, [eax]
    sub     eax, edi
    sub     ecx, ebx
    cdq
    mov     edi, eax
    mov     ebx, edx
    mov     eax, ecx
    push    ebx
    cdq
    push    edi
    push    ebx
    push    edi
    mov     ebp, eax
    mov     [esp+30h+var_4], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edi, eax
    mov     eax, [esp+20h+var_4]
    push    eax
    push    ebp
    push    eax
    push    ebp
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     edi, eax
    mov     eax, [esp+20h+arg_8]
    cmp     edi, eax
    jg      loc_40B77F
    mov     eax, [esi+8]
    mov     edx, [esi+0Ch]
    sub     edx, eax
    mov     edi, eax
    sar     edx, 2
    cmp     edx, 1
    jnb     loc_40B6EE
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_40B612
    xor     ecx, ecx
    jmp     short loc_40B619
    ; ---------------------------------------------------------------------------

    loc_40B612:                             ; CODE XREF: sub_40B530+DCj
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2

    loc_40B619:                             ; CODE XREF: sub_40B530+E0j
    cmp     ecx, 1
    jbe     short loc_40B62F
    test    edx, edx
    jnz     short loc_40B626
    xor     ecx, ecx
    jmp     short loc_40B634
    ; ---------------------------------------------------------------------------

    loc_40B626:                             ; CODE XREF: sub_40B530+F0j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_40B634
    ; ---------------------------------------------------------------------------

    loc_40B62F:                             ; CODE XREF: sub_40B530+ECj
    mov     ecx, 1

    loc_40B634:                             ; CODE XREF: sub_40B530+F4j
                                            ; sub_40B530+FDj
    test    edx, edx
    jnz     short loc_40B63C
    xor     eax, eax
    jmp     short loc_40B641
    ; ---------------------------------------------------------------------------

    loc_40B63C:                             ; CODE XREF: sub_40B530+106j
    sub     eax, edx
    sar     eax, 2

    loc_40B641:                             ; CODE XREF: sub_40B530+10Aj
    add     eax, ecx
    test    eax, eax
    mov     [esp+20h+var_10], eax
    jge     short loc_40B64D
    xor     eax, eax

    loc_40B64D:                             ; CODE XREF: sub_40B530+119j
    shl     eax, 2
    push    eax                             ; int
    call    sub_4B4F10
    mov     ebx, [esi+4]
    add     esp, 4
    cmp     ebx, edi
    mov     [esp+20h+arg_C], eax
    mov     ebp, eax
    jz      short loc_40B677

    loc_40B666:                             ; CODE XREF: sub_40B530+145j
    push    ebx
    push    ebp
    call    sub_406C70
    add     ebx, 4
    add     ebp, 4
    cmp     ebx, edi
    jnz     short loc_40B666

    loc_40B677:                             ; CODE XREF: sub_40B530+134j
    mov     ecx, [esp+20h+arg_0]
    push    ecx
    push    1
    push    ebp
    mov     ecx, esi
    call    sub_406C40
    mov     edx, [esi+8]
    add     ebp, 4
    push    ebp
    push    edx
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    eax
    push    ecx
    mov     ecx, esi
    call    nullsub_1
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     ecx, [esp+24h+arg_C]
    mov     edx, [esp+24h+var_10]
    add     esp, 4
    lea     eax, [ecx+edx*4]
    mov     [esi+0Ch], eax
    mov     eax, [esi+4]
    test    eax, eax
    jnz     short loc_40B6D7
    xor     edx, edx
    mov     [esi+4], ecx
    lea     edx, [ecx+edx*4+4]
    mov     [esi+8], edx
    jmp     loc_40B77F
    ; ---------------------------------------------------------------------------

    loc_40B6D7:                             ; CODE XREF: sub_40B530+194j
    mov     edx, [esi+8]
    mov     [esi+4], ecx
    sub     edx, eax
    sar     edx, 2
    lea     edx, [ecx+edx*4+4]
    mov     [esi+8], edx
    jmp     loc_40B77F
    ; ---------------------------------------------------------------------------

    loc_40B6EE:                             ; CODE XREF: sub_40B530+D1j
    mov     ecx, eax
    sub     ecx, edi
    sar     ecx, 2
    cmp     ecx, 1
    jnb     short loc_40B73A
    lea     ecx, [edi+4]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+8]
    mov     ecx, 1
    mov     ebx, [esp+20h+arg_0]
    mov     edx, eax
    sub     edx, edi
    push    ebx
    sar     edx, 2
    sub     ecx, edx
    push    ecx
    push    eax
    mov     ecx, esi
    call    sub_406C40
    mov     eax, [esi+8]
    cmp     edi, eax
    jz      short loc_40B77B

    loc_40B72D:                             ; CODE XREF: sub_40B530+206j
    mov     edx, [ebx]
    mov     [edi], edx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_40B72D
    jmp     short loc_40B77B
    ; ---------------------------------------------------------------------------

    loc_40B73A:                             ; CODE XREF: sub_40B530+1C8j
    lea     ecx, [eax-4]
    push    eax
    push    eax
    mov     [esp+28h+arg_C], ecx
    push    ecx
    mov     ecx, esi
    call    sub_406C10
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_40B764

    loc_40B755:                             ; CODE XREF: sub_40B530+232j
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_40B755

    loc_40B764:                             ; CODE XREF: sub_40B530+223j
    lea     eax, [edi+4]
    cmp     edi, eax
    jz      short loc_40B77B

    loc_40B76B:                             ; CODE XREF: sub_40B530+249j
    mov     ecx, [esp+20h+arg_0]
    add     edi, 4
    cmp     edi, eax
    mov     edx, [ecx]
    mov     [edi-4], edx
    jnz     short loc_40B76B

    loc_40B77B:                             ; CODE XREF: sub_40B530+1FBj
                                            ; sub_40B530+208j ...
    add     dword ptr [esi+8], 4

    loc_40B77F:                             ; CODE XREF: sub_40B530+4Aj
                                            ; sub_40B530+53j ...
    mov     ecx, [esp+20h+var_C]
    mov     eax, [esp+20h+arg_0]
    add     eax, 4
    mov     edx, [ecx+8]
    mov     [esp+20h+arg_0], eax
    cmp     eax, edx
    jnz     loc_40B56A
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_40B79D:                             ; CODE XREF: sub_40B530+2Cj
    add     esp, 10h
    retn    10h
    sub_40B530 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40B7B0 proc near                    ; CODE XREF: .text:00408974p
                                            ; sub_4089A0+1D6p ...

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 38h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+48h+arg_0]
    xor     ebp, ebp
    mov     eax, [edi+96h]
    cmp     [eax], ebp
    jz      short loc_40B7D7
    mov     cl, [eax+73h]
    mov     [esp+48h+var_38], 1
    cmp     cl, 2
    jz      short loc_40B7DB

    loc_40B7D7:                             ; CODE XREF: sub_40B7B0+15j
    mov     [esp+48h+var_38], ebp

    loc_40B7DB:                             ; CODE XREF: sub_40B7B0+25j
    mov     eax, 7FFFFFFFh
    mov     [esp+48h+var_20], ebp
    mov     [esp+48h+var_30], eax
    mov     [esp+48h+var_2C], eax
    mov     al, byte ptr [esp+48h+arg_0]
    mov     [esp+48h+var_24], ebp
    mov     byte ptr [esp+48h+var_10], al
    mov     eax, [esp+48h+arg_8]
    cmp     eax, ebp
    mov     [esp+48h+var_C], ebp
    mov     [esp+48h+var_8], ebp
    mov     [esp+48h+var_4], ebp
    jz      short loc_40B83A
    mov     edx, [esp+48h+arg_4]
    lea     ecx, [esp+48h+var_10]
    push    ecx
    push    ebp
    lea     esi, [edi+6Ah]
    push    edx
    push    edi
    mov     [esp+58h+var_34], esi
    call    sub_49ADF0
    push    eax
    xor     eax, eax
    mov     al, [edi+0FFh]
    push    esi
    push    eax
    call    sub_40AD80
    mov     [esp+48h+var_28], ebp
    jmp     short loc_40B86C
    ; ---------------------------------------------------------------------------

    loc_40B83A:                             ; CODE XREF: sub_40B7B0+5Aj
    mov     edx, [edi+92h]
    lea     ecx, [esp+48h+var_10]
    push    ecx
    lea     eax, [edi+6Ah]
    movsx   ecx, word ptr [edx+202h]
    xor     edx, edx
    push    ebp
    mov     dl, [edi+0FFh]
    push    ecx
    push    eax
    push    edx
    mov     [esp+5Ch+var_34], eax
    call    sub_40AD80
    mov     [esp+48h+var_28], ebp
    jmp     short loc_40B86C
    ; ---------------------------------------------------------------------------

    loc_40B86A:                             ; CODE XREF: sub_40B7B0+291j
    xor     ebp, ebp

    loc_40B86C:                             ; CODE XREF: sub_40B7B0+88j
                                            ; sub_40B7B0+B8j
    mov     ecx, [esp+48h+var_C]
    mov     esi, [esp+48h+var_8]
    cmp     ecx, ebp
    jnz     short loc_40B87C
    xor     eax, eax
    jmp     short loc_40B883
    ; ---------------------------------------------------------------------------

    loc_40B87C:                             ; CODE XREF: sub_40B7B0+C6j
    mov     eax, esi
    sub     eax, ecx
    sar     eax, 2

    loc_40B883:                             ; CODE XREF: sub_40B7B0+CAj
    xor     edx, edx
    cmp     eax, ebp
    setz    dl
    test    dl, dl
    jnz     loc_40BA4D
    cmp     ecx, ebp
    mov     ebx, ecx
    jnz     short loc_40B89C
    xor     esi, esi
    jmp     short loc_40B8A1
    ; ---------------------------------------------------------------------------

    loc_40B89C:                             ; CODE XREF: sub_40B7B0+E6j
    sub     esi, ecx
    sar     esi, 2

    loc_40B8A1:                             ; CODE XREF: sub_40B7B0+EAj
    push    esi                             ; int
    call    GetRandom
    mov     esi, [ebx+eax*4]
    lea     eax, [ebx+eax*4]
    push    eax
    lea     ecx, [esp+4Ch+var_10]
    call    sub_4800C0
    mov     eax, [esi+110h]
    test    eax, 10000000h
    jz      loc_40BA35
    test    ah, 40h
    jnz     loc_40BA35
    mov     eax, [esi+92h]
    mov     ecx, [eax+241h]
    test    ch, 80h
    jnz     short loc_40B8FB
    cmp     [esp+48h+var_38], ebp
    jnz     short loc_40B8FB
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+37F30h], 4
    jz      loc_40BA35

    loc_40B8FB:                             ; CODE XREF: sub_40B7B0+130j
                                            ; sub_40B7B0+136j
    mov     edx, [edi+92h]
    test    dword ptr [edx+241h], 10000000h
    jnz     short loc_40B921
    mov     eax, [esp+48h+arg_4]
    push    eax
    push    esi
    push    edi
    call    sub_49ABB0
    test    eax, eax
    jz      loc_40BA35

    loc_40B921:                             ; CODE XREF: sub_40B7B0+15Bj
    cmp     [esp+48h+arg_8], ebp
    jnz     short loc_40B958
    mov     cx, [esi+0A6h]
    mov     edx, [edi+92h]
    and     ecx, 0FFFFh
    mov     ebx, 1
    mov     edx, [edx+23Dh]
    mov     eax, ecx
    and     ecx, 1Fh
    shr     eax, 5
    shl     ebx, cl
    test    [edx+eax*4], ebx
    jnz     loc_40BA35

    loc_40B958:                             ; CODE XREF: sub_40B7B0+175j
    mov     eax, [esp+48h+arg_4]
    and     eax, 0FFh
    mov     [esp+48h+var_1C], eax
    lea     ecx, ds:0[eax*8]
    sub     ecx, eax
    mov     edx, [edi+ecx*4+10h]
    test    byte ptr [edx+111h], 80h
    jz      short loc_40B988
    test    byte ptr [esi+10Eh], 10h
    jnz     loc_40BA35

    loc_40B988:                             ; CODE XREF: sub_40B7B0+1C9j
    mov     eax, [esp+48h+var_34]
    mov     edx, [esi+6Ah]
    mov     ecx, [edi+72h]
    mov     edi, [esi+72h]
    mov     eax, [eax]
    sub     ecx, edi
    sub     eax, edx
    cdq
    mov     edi, eax
    mov     ebp, edx
    mov     eax, ecx
    push    ebp
    cdq
    push    edi
    push    ebp
    push    edi
    mov     ebx, eax
    mov     [esp+58h+var_14], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edi, eax
    mov     eax, [esp+48h+var_14]
    push    eax
    push    ebx
    push    eax
    push    ebx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     edi, eax
    push    edi                             ; int
    call    GetRandom
    mov     cx, [esi+0A6h]
    mov     edx, [esp+48h+arg_0]
    mov     ebx, [esp+48h+var_1C]
    and     ecx, 0FFFFh
    mov     edx, [edx+92h]
    mov     edi, ecx
    and     ecx, 1Fh
    mov     edx, [edx+ebx*4+231h]
    mov     ebx, 1
    shr     edi, 5
    shl     ebx, cl
    test    [edx+edi*4], ebx
    jz      short loc_40BA23
    cmp     eax, [esp+48h+var_30]
    jge     short loc_40BA31
    mov     [esp+48h+var_30], eax
    mov     [esp+48h+var_20], esi
    jmp     short loc_40BA31
    ; ---------------------------------------------------------------------------

    loc_40BA23:                             ; CODE XREF: sub_40B7B0+261j
    cmp     eax, [esp+48h+var_2C]
    jge     short loc_40BA31
    mov     [esp+48h+var_2C], eax
    mov     [esp+48h+var_24], esi

    loc_40BA31:                             ; CODE XREF: sub_40B7B0+267j
                                            ; sub_40B7B0+271j ...
    mov     edi, [esp+48h+arg_0]

    loc_40BA35:                             ; CODE XREF: sub_40B7B0+112j
                                            ; sub_40B7B0+11Bj ...
    mov     eax, [esp+48h+var_28]
    inc     eax
    cmp     eax, 32h
    mov     [esp+48h+var_28], eax
    jl      loc_40B86A
    mov     ecx, [esp+48h+var_C]
    xor     ebp, ebp

    loc_40BA4D:                             ; CODE XREF: sub_40B7B0+DCj
    mov     esi, [esp+48h+var_24]
    push    ecx
    cmp     esi, ebp
    jz      short loc_40BA6A
    call    sub_4B4F20
    add     esp, 4
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40BA6A:                             ; CODE XREF: sub_40B7B0+2A4j
    call    sub_4B4F20
    mov     eax, [esp+4Ch+var_20]
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    sub_40B7B0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40BA80 proc near                    ; CODE XREF: sub_407AE0+58p
                                            ; sub_408100+27p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     edx, [esp+arg_4]
    mov     ecx, dword_5119C0[eax*4]
    add     ecx, 35h
    mov     eax, [ecx]
    mov     [edx], eax
    mov     eax, [ecx+4]
    mov     [edx+4], eax
    mov     ecx, [ecx+8]
    mov     [edx+8], ecx
    retn    8
    sub_40BA80 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+4]
    push    esi
    mov     edx, [eax+14223h]
    mov     eax, dword_5119C0[ecx*4]
    shl     edx, 10h
    mov     esi, [eax+35h]
    mov     eax, [esp+10h]
    sub     edx, esi
    mov     [eax], edx
    mov     dword ptr [eax+4], 0
    mov     edx, TAdynmemStructPtr
    mov     ecx, dword_5119C0[ecx*4]
    mov     edx, [edx+14223h]
    mov     esi, [ecx+3Dh]
    shl     edx, 10h
    sub     edx, esi
    pop     esi
    mov     [eax+8], edx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40BB00 proc near                    ; CODE XREF: sub_40BDB0+37p
                                            ; .text:00468893p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    mov     ecx, [esp+0Ch+arg_0]
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    ebp
    mov     eax, dword_5119C0[ecx*4]
    push    esi
    mov     [esp+18h+var_4], eax
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    mov     esi, edx
    add     esi, ecx
    push    edi
    lea     eax, [eax+eax*4]
    fld     dword ptr [esi+eax*2+1BEFh]
    fcomp   ds:flt_4FC9F0
    lea     esi, [esi+eax*2+1B63h]
    fnstsw  ax
    test    ah, 1
    jz      short loc_40BB51
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40BB51:                             ; CODE XREF: sub_40BB00+43j
    fld     dword ptr [esi+98h]
    fcomp   ds:flt_4FC9F4
    fnstsw  ax
    test    ah, 1
    jz      short loc_40BB70
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40BB70:                             ; CODE XREF: sub_40BB00+62j
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_40BBB6
    mov     ecx, [esp+1Ch+arg_4]
    mov     edx, TAdynmemStructPtr
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    mov     eax, [edx+1439Bh]
    test    byte ptr [eax+ecx+241h], 20h
    jz      short loc_40BBB6
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40BBB6:                             ; CODE XREF: sub_40BB00+7Ej
                                            ; sub_40BB00+A8j
    fld     dword ptr [esi+0A4h]
    call    __ftol
    cmp     eax, 3E8h
    mov     [esp+1Ch+var_C], 3E8h
    jg      short loc_40BBD4
    mov     [esp+1Ch+var_C], eax

    loc_40BBD4:                             ; CODE XREF: sub_40BB00+CEj
    fld     dword ptr [esi+0A8h]
    call    __ftol
    cmp     eax, 1F4h
    mov     [esp+1Ch+var_8], 1F4h
    jg      short loc_40BBF2
    mov     [esp+1Ch+var_8], eax

    loc_40BBF2:                             ; CODE XREF: sub_40BB00+ECj
    fld     ds:flt_4FC9B8
    fild    [esp+1Ch+var_C]
    fsub    dword ptr [esi+8Ch]
    fmul    ds:flt_4FC9F8
    fxch    st(1)
    fcomp   st(1)
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_40BC1B
    fstp    st
    fld     ds:flt_4FC9B8

    loc_40BC1B:                             ; CODE XREF: sub_40BB00+111j
    call    __ftol
    fld     ds:flt_4FC9B8
    fild    [esp+1Ch+var_8]
    mov     ebp, eax
    fsub    dword ptr [esi+98h]
    fmul    ds:flt_4FC9FC
    fxch    st(1)
    fcomp   st(1)
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_40BC4B
    fstp    st
    fld     ds:flt_4FC9B8

    loc_40BC4B:                             ; CODE XREF: sub_40BB00+141j
    call    __ftol
    push    esi
    mov     edi, eax
    call    sub_464AD0
    fcomp   ds:flt_4FCA00
    fnstsw  ax
    test    ah, 1
    jz      short loc_40BC68
    add     ebp, 14h

    loc_40BC68:                             ; CODE XREF: sub_40BB00+163j
    push    esi
    call    sub_464B10
    fcomp   ds:flt_4FCA00
    fnstsw  ax
    test    ah, 1
    jz      short loc_40BC7E
    add     edi, 14h

    loc_40BC7E:                             ; CODE XREF: sub_40BB00+179j
    push    esi
    call    sub_464AB0
    fcomp   ds:flt_4FC9F0
    fnstsw  ax
    test    ah, 1
    jz      short loc_40BC96
    add     ebp, 64h
    jmp     short loc_40BCAC
    ; ---------------------------------------------------------------------------

    loc_40BC96:                             ; CODE XREF: sub_40BB00+18Fj
    push    esi
    call    sub_464AB0
    fcomp   ds:flt_4FCA04
    fnstsw  ax
    test    ah, 1
    jz      short loc_40BCAC
    add     ebp, 0Ah

    loc_40BCAC:                             ; CODE XREF: sub_40BB00+194j
                                            ; sub_40BB00+1A7j
    push    esi
    call    sub_464AF0
    fcomp   ds:flt_4FCA08
    fnstsw  ax
    test    ah, 1
    jz      short loc_40BCC4
    add     edi, 64h
    jmp     short loc_40BCDA
    ; ---------------------------------------------------------------------------

    loc_40BCC4:                             ; CODE XREF: sub_40BB00+1BDj
    push    esi
    call    sub_464AF0
    fcomp   ds:flt_4FC9CC
    fnstsw  ax
    test    ah, 1
    jz      short loc_40BCDA
    add     edi, 14h

    loc_40BCDA:                             ; CODE XREF: sub_40BB00+1C2j
                                            ; sub_40BB00+1D5j
    xor     ebx, ebx
    test    edi, edi
    setle   bl
    dec     ebx
    and     ebx, edi
    cmp     ebx, 64h
    jl      short loc_40BCEE
    mov     ebx, 64h

    loc_40BCEE:                             ; CODE XREF: sub_40BB00+1E7j
    mov     eax, ebp
    xor     ecx, ecx
    sub     eax, ebx
    test    eax, eax
    setle   cl
    dec     ecx
    and     ecx, eax
    cmp     ecx, 64h
    jge     short loc_40BD0F
    xor     ecx, ecx
    test    eax, eax
    setle   cl
    dec     ecx
    and     ecx, eax
    mov     ebp, ecx
    jmp     short loc_40BD14
    ; ---------------------------------------------------------------------------

    loc_40BD0F:                             ; CODE XREF: sub_40BB00+1FFj
    mov     ebp, 64h

    loc_40BD14:                             ; CODE XREF: sub_40BB00+20Dj
    mov     eax, 64h
    xor     edx, edx
    sub     eax, ebx
    mov     edi, [esp+1Ch+arg_4]
    sub     eax, ebp
    test    eax, eax
    setle   dl
    dec     edx
    and     edi, 0FFFFh
    and     edx, eax
    mov     eax, [esp+1Ch+var_4]
    mov     esi, edx
    mov     ecx, [eax+81h]
    mov     eax, [esp+1Ch+arg_4]
    movsx   edx, word ptr [ecx+edi*2]
    mov     ecx, [esp+1Ch+arg_0]
    push    edx
    push    eax
    push    ecx
    call    sub_406EE0
    test    eax, eax
    jnz     short loc_40BD5F
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40BD5F:                             ; CODE XREF: sub_40BB00+253j
    mov     ecx, [esp+1Ch+var_4]
    lea     edx, [edi+edi*2]
    mov     eax, [ecx+69h]
    mov     ecx, [ecx+0B1h]
    add     eax, edx
    movsx   edx, byte ptr [eax]
    imul    esi, edx
    movsx   edx, byte ptr [eax+1]
    movsx   eax, byte ptr [eax+2]
    imul    edx, ebx
    imul    eax, ebp
    add     esi, edx
    xor     edx, edx
    mov     dl, [ecx+edi]
    add     esi, eax
    imul    esi, edx
    mov     eax, 68DB8BADh
    pop     edi
    imul    esi
    mov     eax, edx
    pop     esi
    sar     eax, 0Ch
    mov     ecx, eax
    pop     ebp
    shr     ecx, 1Fh
    add     eax, ecx
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_40BB00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40BDB0 proc near                    ; CODE XREF: sub_408100+A7p
                                            ; sub_408620+11p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 8
    mov     eax, [esp+8+arg_4]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+92h]
    push    edi
    xor     ebx, ebx
    xor     edi, edi
    mov     ecx, [eax+152h]
    mov     [esp+18h+var_8], edi
    cmp     ecx, ebx
    mov     [esp+18h+var_4], ebx
    jle     short loc_40BE21
    mov     ebp, [esp+18h+arg_0]

    loc_40BDDB:                             ; CODE XREF: sub_40BDB0+6Bj
    mov     ecx, [eax+156h]
    mov     di, [ecx+ebx*2]
    push    edi
    push    ebp
    call    sub_40BB00
    mov     esi, eax
    test    esi, esi
    jle     short loc_40BE0A
    mov     eax, [esp+18h+var_4]
    add     eax, esi
    push    eax                             ; int
    mov     [esp+1Ch+var_4], eax
    call    GetRandom
    cmp     eax, esi
    jge     short loc_40BE0A
    mov     [esp+18h+var_8], edi

    loc_40BE0A:                             ; CODE XREF: sub_40BDB0+40j
                                            ; sub_40BDB0+54j
    mov     edx, [esp+18h+arg_4]
    inc     ebx
    mov     eax, [edx+92h]
    cmp     ebx, [eax+152h]
    jl      short loc_40BDDB
    mov     edi, [esp+18h+var_8]

    loc_40BE21:                             ; CODE XREF: sub_40BDB0+25j
    test    di, di
    jz      short loc_40BE97
    mov     ecx, edi
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1439Bh]
    lea     eax, [eax+eax*8]
    lea     esi, [edx+eax+0A0h]
    mov     eax, [esp+18h+arg_4]
    mov     eax, [eax+92h]
    add     eax, 0A0h

    loc_40BE5A:                             ; CODE XREF: sub_40BDB0+CCj
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_40BE82
    test    cl, cl
    jz      short loc_40BE7E
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_40BE82
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_40BE5A

    loc_40BE7E:                             ; CODE XREF: sub_40BDB0+B6j
    xor     eax, eax
    jmp     short loc_40BE87
    ; ---------------------------------------------------------------------------

    loc_40BE82:                             ; CODE XREF: sub_40BDB0+B2j
                                            ; sub_40BDB0+C2j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_40BE87:                             ; CODE XREF: sub_40BDB0+D0j
    test    eax, eax
    jz      short loc_40BE97
    mov     [esp+18h+var_8], 0
    mov     edi, [esp+18h+var_8]

    loc_40BE97:                             ; CODE XREF: sub_40BDB0+74j
                                            ; sub_40BDB0+D9j
    mov     ax, di
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    sub_40BDB0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 18h
    mov     ecx, [esp+20h]
    push    ebx
    push    ebp
    push    esi
    mov     ebp, [ecx]
    mov     edx, [ecx+4]
    push    edi
    mov     edi, [esp+34h]
    mov     [esp+30h], edx
    mov     ebx, [edi]
    mov     eax, [edi+4]
    sub     ebx, ebp
    sub     eax, edx
    mov     edx, [ecx+8]
    mov     ecx, [edi+8]
    mov     [esp+1Ch], ebx
    mov     [esp+20h], eax
    fild    dword ptr [esp+1Ch]
    fild    dword ptr [esp+20h]
    sub     ecx, edx
    mov     [esp+34h], edx
    mov     [esp+24h], ecx
    mov     [esp+10h], ebx
    fild    dword ptr [esp+24h]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    mov     [esp+14h], eax
    mov     [esp+18h], ecx
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    mov     esi, eax
    mov     eax, [esp+38h]
    fstp    st
    cmp     eax, esi
    fstp    st
    jl      short loc_40BF48
    mov     eax, [esp+2Ch]
    mov     edx, [edi]
    mov     ecx, eax
    mov     [ecx], edx
    mov     edx, [edi+4]
    mov     [ecx+4], edx
    mov     edx, [edi+8]
    mov     [ecx+8], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_40BF48:                             ; CODE XREF: .text:0040BF26j
    cdq
    mov     ecx, 10h
    call    __allshl
    mov     ecx, eax
    mov     eax, esi
    mov     edi, edx
    cdq
    push    edx
    push    eax
    push    edi
    push    ecx
    call    __alldiv
    cdq
    mov     esi, eax
    mov     eax, ebx
    mov     edi, edx
    cdq
    push    edi
    push    esi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ebx, eax
    mov     eax, [esp+14h]
    cdq
    push    edi
    push    esi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esp+14h], eax
    mov     eax, [esp+18h]
    cdq
    push    edi
    push    esi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     edx, [esp+30h]
    mov     ecx, [esp+14h]
    add     ecx, edx
    mov     edx, [esp+34h]
    add     ebp, ebx
    add     edx, eax
    mov     eax, [esp+2Ch]
    pop     edi
    mov     esi, eax
    mov     [esi], ebp
    mov     [esi+4], ecx
    mov     [esi+8], edx
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40BFE0 proc near                    ; CODE XREF: sub_408100+E2p

    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 30h
    mov     eax, [esp+30h+arg_0]
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, dword_5119C0[eax*4]
    mov     eax, [ecx+14223h]
    mov     ecx, [ecx+14227h]
    mov     [esp+40h+var_28], edi
    cmp     eax, ecx
    jg      short loc_40C00E
    mov     eax, ecx

    loc_40C00E:                             ; CODE XREF: sub_40BFE0+2Aj
    mov     edx, [edi+109h]
    cmp     edx, eax
    jge     short loc_40C024
    add     edx, 0A0h
    mov     [edi+109h], edx

    loc_40C024:                             ; CODE XREF: sub_40BFE0+36j
    mov     ecx, [esp+40h+arg_4]
    mov     ebx, [edi+35h]
    mov     eax, [edi+39h]
    mov     esi, [edi+109h]
    mov     ebp, [ecx]
    mov     edx, [ecx+4]
    sub     ebx, ebp
    mov     [esp+40h+var_30], edx
    sub     eax, edx
    mov     edx, [ecx+8]
    mov     ecx, [edi+3Dh]
    mov     [esp+40h+var_18], ebx
    fild    [esp+40h+var_18]
    mov     [esp+40h+var_14], eax
    sub     ecx, edx
    fild    [esp+40h+var_14]
    mov     [esp+40h+var_10], ecx
    mov     [esp+40h+var_2C], edx
    fild    [esp+40h+var_10]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    shl     esi, 10h
    mov     [esp+40h+var_24], ebx
    mov     [esp+40h+var_20], eax
    faddp   st(1), st
    mov     [esp+40h+var_1C], ecx
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    cmp     esi, eax
    mov     [esp+40h+arg_4], eax
    fstp    st
    jl      short loc_40C0A7
    mov     ebp, [edi+35h]
    mov     ecx, [edi+39h]
    mov     eax, [edi+3Dh]
    jmp     loc_40C12D
    ; ---------------------------------------------------------------------------

    loc_40C0A7:                             ; CODE XREF: sub_40BFE0+B7j
    mov     eax, esi
    mov     ecx, 10h
    cdq
    call    __allshl
    mov     ecx, eax
    mov     eax, [esp+40h+arg_4]
    mov     esi, edx
    cdq
    push    edx
    push    eax
    push    esi
    push    ecx
    call    __alldiv
    cdq
    mov     esi, eax
    mov     eax, ebx
    mov     edi, edx
    cdq
    push    edi
    push    esi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ebx, eax
    mov     eax, [esp+40h+var_20]
    cdq
    push    edi
    push    esi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esp+40h+var_20], eax
    mov     eax, [esp+40h+var_1C]
    cdq
    push    edi
    push    esi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     edx, [esp+40h+var_30]
    mov     ecx, [esp+40h+var_20]
    mov     edi, [esp+40h+var_28]
    add     ecx, edx
    mov     edx, [esp+40h+var_2C]
    add     ebp, ebx
    add     eax, edx

    loc_40C12D:                             ; CODE XREF: sub_40BFE0+C2j
    mov     esi, [esp+40h+arg_8]
    mov     [esp+40h+var_4], eax
    mov     [esp+40h+var_C], ebp
    mov     [esp+40h+var_8], ecx
    fld     dword ptr [esi+1CEh]
    fcomp   ds:flt_4FC9B8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_40C190
    push    0FFh                            ; int
    call    GetRandom
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+391E9h]
    cmp     [edx+0D30h], eax
    jge     short loc_40C190
    mov     ecx, [edi+109h]
    lea     eax, [esp+40h+arg_0]
    shl     ecx, 2
    push    eax
    lea     edx, [edi+4Dh]
    push    ecx
    lea     eax, [esp+48h+var_C]
    push    edx
    push    eax
    push    esi
    mov     ecx, edi
    call    sub_40A260
    jmp     short loc_40C1A9
    ; ---------------------------------------------------------------------------

    loc_40C190:                             ; CODE XREF: sub_40BFE0+16Ej
                                            ; sub_40BFE0+18Cj
    mov     edx, [edi+109h]
    lea     ecx, [esp+40h+arg_0]
    push    ecx
    lea     eax, [esp+44h+var_C]
    push    edx
    push    eax
    push    esi
    mov     ecx, edi
    call    sub_40A5D0

    loc_40C1A9:                             ; CODE XREF: sub_40BFE0+1AEj
    and     eax, 0FFh
    test    eax, eax
    jz      short loc_40C1ED
    mov     esi, [esi+14Ah]
    movsx   ecx, word ptr [esp+40h+arg_0]
    movsx   edx, si
    mov     [esp+40h+arg_4], esi
    movsx   esi, word ptr [esp+40h+arg_4+2]
    lea     edx, [edx+ecx*2]
    mov     ecx, [esp+40h+arg_C]
    shl     edx, 13h
    mov     [ecx], edx
    movsx   edx, word ptr [esp+40h+arg_0+2]
    lea     edx, [esi+edx*2]
    shl     edx, 13h
    mov     [ecx+8], edx
    mov     dword ptr [edi+109h], 0

    loc_40C1ED:                             ; CODE XREF: sub_40BFE0+1D0j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    10h
    sub_40BFE0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     edx, [esp+8]
    and     edx, 0FFFFh
    mov     ecx, dword_5119C0[eax*4]
    mov     eax, [ecx+81h]
    movsx   eax, word ptr [eax+edx*2]
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C230 proc near                    ; CODE XREF: sub_408100+69p
                                            ; sub_408100+20Ep

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, dword_5119C0[eax*4]
    mov     eax, [ecx+75h]
    retn    4
    sub_40C230 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C250 proc near                    ; CODE XREF: .text:00418C4Ep

    var_110= dword ptr -110h
    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    sub     esp, 110h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [eax+38A47h]
    mov     eax, 36B06E71h
    mov     ecx, esi
    mul     esi
    sub     ecx, edx
    push    edi
    shr     ecx, 1
    add     ecx, edx
    mov     edi, [esp+120h+arg_0]
    shr     ecx, 10h
    mov     ebp, dword_5119C0[edi*4]
    lea     eax, [ecx+ecx*2]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax*8]
    mov     eax, 91A2B3C5h
    shl     edx, 5
    sub     esi, edx
    imul    esi
    add     edx, esi
    sar     edx, 0Ah
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 88888889h
    mov     ebx, edx
    imul    edx, 708h
    sub     esi, edx
    imul    esi
    add     edx, esi
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    push    edx
    push    ebx
    push    ecx
    lea     ecx, [esp+12Ch+var_100]
    push    offset a02d02d02d               ; "%02d:%02d:%02d"
    push    ecx
    call    _sprintf
    mov     ebx, [esp+134h+arg_4]
    add     esp, 14h
    lea     edx, [esp+120h+var_100]
    push    edx
    push    offset aGametimeS               ; "gametime: '%s'\r\n"
    push    ebx
    call    sub_4E4510
    mov     eax, edi
    mov     ecx, TAdynmemStructPtr
    shl     eax, 5
    add     eax, edi
    add     esp, 0Ch
    lea     eax, [eax+eax*4]
    push    edi
    lea     esi, [edi+eax*2]
    lea     edx, [ecx+esi+1B8Eh]
    push    edx
    push    offset aPlayerSNumD             ; "player:   '%s' num: %d\r\n"
    push    ebx
    call    sub_4E4510
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    add     esp, 10h
    mov     al, [ecx+esi+1BD6h]
    dec     eax
    jz      short loc_40C349
    dec     eax
    lea     edx, [esp+120h+var_100]
    jz      short loc_40C342
    mov     edi, offset aInvalid            ; "INVALID"
    jmp     short loc_40C352
    ; ---------------------------------------------------------------------------

    loc_40C342:                             ; CODE XREF: sub_40C250+E9j
    mov     edi, offset aAi_0               ; "AI"
    jmp     short loc_40C352
    ; ---------------------------------------------------------------------------

    loc_40C349:                             ; CODE XREF: sub_40C250+E2j
    lea     edx, [esp+120h+var_100]
    mov     edi, offset aHuman              ; "HUMAN"

    loc_40C352:                             ; CODE XREF: sub_40C250+F0j
                                            ; sub_40C250+F7j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+120h+var_100]
    push    ecx
    push    offset aControllerS             ; "controller: %s\r\n"
    push    ebx
    call    sub_4E4510
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     esi, 1
    mov     ecx, [edx+391E9h]
    push    esi
    call    sub_4356C0
    push    eax
    push    offset aTerrainS                ; "terrain:    '%s'\r\n"
    push    ebx
    call    sub_4E4510
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     ecx, [eax+391E9h]
    push    7
    call    sub_4356C0
    push    eax
    push    offset aProfileS                ; "profile:    '%s'\r\n"
    push    ebx
    call    sub_4E4510
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     [esp+120h+var_10C], offset aEasy_1 ; "EASY"
    mov     [esp+120h+var_108], offset aMedium_1 ; "MEDIUM"
    mov     edx, [ecx+37EEEh]
    mov     [esp+120h+var_104], offset aHard_1 ; "HARD"
    mov     eax, [esp+edx*4+120h+var_10C]
    push    eax
    push    offset aDifficultyS             ; "difficulty: '%s'\r\n"
    push    ebx
    call    sub_4E4510
    add     esp, 0Ch
    push    offset asc_50183C               ; "======================================="...
    push    ebx
    call    sub_4E4510
    add     esp, 8
    push    offset aLimitBaseBasem          ; "<limit> - <base:baseML:baseEL> : <end r"...
    push    ebx
    call    sub_4E4510
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [esp+120h+var_110], esi
    cmp     [ecx+1438Fh], esi
    jle     loc_40C4DB

    loc_40C432:                             ; CODE XREF: sub_40C250+285j
    mov     eax, esi
    mov     edi, [ecx+1439Bh]
    shl     eax, 6
    add     eax, esi
    lea     edx, [eax+eax*8]
    mov     eax, [ebp+0D1h]
    add     edi, edx
    mov     eax, [eax+esi*4]
    test    eax, eax
    jge     short loc_40C461
    push    offset aNA                      ; "n/a "
    push    ebx
    call    sub_4E4510
    add     esp, 8
    jmp     short loc_40C470
    ; ---------------------------------------------------------------------------

    loc_40C461:                             ; CODE XREF: sub_40C250+1FFj
    push    eax
    push    offset a4d                      ; "%4d"
    push    ebx
    call    sub_4E4510
    add     esp, 0Ch

    loc_40C470:                             ; CODE XREF: sub_40C250+20Fj
    mov     eax, [ebp+69h]
    push    edi
    add     edi, 20h
    xor     edx, edx
    push    edi
    mov     edi, [ebp+0B1h]
    lea     ecx, [esi+esi*2]
    mov     dl, [esi+edi]
    push    edx
    movsx   edx, byte ptr [eax+ecx+2]
    push    edx
    movsx   edx, byte ptr [eax+ecx+1]
    movsx   eax, byte ptr [ecx+eax]
    push    edx
    push    eax
    lea     ecx, [esp+138h+var_100]
    push    offset a3d3d3d3dSS              ; " - %3d : %3d : %3d = %3d - '%s\t\t:%s'\r\n"
    push    ecx
    call    _sprintf
    add     esp, 20h
    lea     edx, [esp+120h+var_100]
    push    edx
    push    ebx
    call    sub_4E4510
    mov     esi, [esp+128h+var_110]
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    inc     esi
    mov     eax, [ecx+1438Fh]
    mov     [esp+120h+var_110], esi
    and     esi, 0FFFFh
    cmp     esi, eax
    jl      loc_40C432

    loc_40C4DB:                             ; CODE XREF: sub_40C250+1DCj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 110h
    retn    8
    sub_40C250 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     ecx, dword_5119C0[eax*4]
    mov     eax, [ecx+79h]
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C510 proc near                    ; CODE XREF: sub_409160+5Ap
                                            ; .text:00410A5Dp ...

    arg_0= dword ptr  4

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     dl, [ecx]
    xor     ecx, ecx
    mov     [eax], dl
    mov     [eax+4], ecx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ecx
    retn    4
    sub_40C510 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C530 proc near                    ; CODE XREF: sub_40B390+165p
                                            ; sub_40B390+16Dp ...

    var_4= dword ptr -4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+4]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    pop     esi
    pop     ecx
    retn
    sub_40C530 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C560 proc near                    ; CODE XREF: sub_40AD80+278p
                                            ; .text:00410568p ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_40C56A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_40C56A:                             ; CODE XREF: sub_40C560+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_40C560 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C580 proc near                    ; CODE XREF: sub_40B390+15Dp

    var_4= dword ptr -4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+4]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    pop     esi
    pop     ecx
    retn
    sub_40C580 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C5B0 proc near                    ; CODE XREF: sub_40A260+C2p
                                            ; sub_40A7B0+114p ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_40C5BA
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_40C5BA:                             ; CODE XREF: sub_40C5B0+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 3
    retn
    sub_40C5B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C5D0 proc near                    ; CODE XREF: sub_40B390+155p

    var_4= dword ptr -4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+4]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    pop     esi
    pop     ecx
    retn
    sub_40C5D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C600 proc near                    ; CODE XREF: sub_409160+2BAp

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_40C614
    xor     eax, eax
    jmp     short loc_40C619
    ; ---------------------------------------------------------------------------

    loc_40C614:                             ; CODE XREF: sub_40C600+Ej
    mov     eax, [esi+8]
    sub     eax, edx

    loc_40C619:                             ; CODE XREF: sub_40C600+12j
    mov     ebp, [esp+18h+arg_0]
    cmp     eax, ebp
    jnb     loc_40C7B3
    test    edx, edx
    jnz     short loc_40C62D
    xor     ecx, ecx
    jmp     short loc_40C632
    ; ---------------------------------------------------------------------------

    loc_40C62D:                             ; CODE XREF: sub_40C600+27j
    mov     ecx, [esi+8]
    sub     ecx, edx

    loc_40C632:                             ; CODE XREF: sub_40C600+2Bj
    mov     eax, [esi+8]
    sub     ebp, ecx
    mov     ecx, [esi+0Ch]
    mov     edi, eax
    sub     ecx, eax
    mov     [esp+18h+arg_0], ebp
    cmp     ecx, ebp
    jnb     loc_40C721
    test    edx, edx
    jnz     short loc_40C652
    xor     ecx, ecx
    jmp     short loc_40C656
    ; ---------------------------------------------------------------------------

    loc_40C652:                             ; CODE XREF: sub_40C600+4Cj
    mov     ecx, eax
    sub     ecx, edx

    loc_40C656:                             ; CODE XREF: sub_40C600+50j
    cmp     ebp, ecx
    jnb     short loc_40C666
    test    edx, edx
    jnz     short loc_40C662
    xor     ebp, ebp
    jmp     short loc_40C666
    ; ---------------------------------------------------------------------------

    loc_40C662:                             ; CODE XREF: sub_40C600+5Cj
    mov     ebp, eax
    sub     ebp, edx

    loc_40C666:                             ; CODE XREF: sub_40C600+58j
                                            ; sub_40C600+60j
    test    edx, edx
    jnz     short loc_40C66E
    xor     eax, eax
    jmp     short loc_40C670
    ; ---------------------------------------------------------------------------

    loc_40C66E:                             ; CODE XREF: sub_40C600+68j
    sub     eax, edx

    loc_40C670:                             ; CODE XREF: sub_40C600+6Cj
    add     eax, ebp
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_40C67C
    xor     eax, eax

    loc_40C67C:                             ; CODE XREF: sub_40C600+78j
    push    eax                             ; int
    call    sub_4B4F10
    mov     ebp, [esi+4]
    add     esp, 4
    cmp     ebp, edi
    mov     [esp+18h+var_8], eax
    mov     ebx, eax
    jz      short loc_40C69F

    loc_40C692:                             ; CODE XREF: sub_40C600+9Dj
    push    ebp
    push    ebx
    call    sub_40D600
    inc     ebx
    inc     ebp
    cmp     ebp, edi
    jnz     short loc_40C692

    loc_40C69F:                             ; CODE XREF: sub_40C600+90j
    mov     edx, [esp+18h+arg_4]
    mov     ebp, [esp+18h+arg_0]
    push    edx
    push    ebp
    push    ebx
    mov     ecx, esi
    call    sub_40D520
    mov     ecx, [esi+8]
    lea     eax, [ebp+ebx+0]
    push    eax
    push    ecx
    push    edi
    mov     ecx, esi
    call    sub_40D4F0
    mov     edx, [esi+8]
    mov     eax, [esi+4]
    push    edx
    push    eax
    mov     ecx, esi
    call    nullsub_3
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+1Ch+var_8]
    mov     ecx, [esp+1Ch+var_4]
    add     esp, 4
    lea     eax, [edx+ecx]
    mov     [esi+0Ch], eax
    mov     eax, [esi+4]
    test    eax, eax
    jnz     short loc_40C708
    xor     ecx, ecx
    add     ebp, edx
    add     ebp, ecx
    mov     [esi+4], edx
    mov     [esi+8], ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40C708:                             ; CODE XREF: sub_40C600+F0j
    mov     ecx, [esi+8]
    add     ebp, edx
    sub     ecx, eax
    mov     [esi+4], edx
    add     ebp, ecx
    mov     [esi+8], ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40C721:                             ; CODE XREF: sub_40C600+44j
    mov     ecx, eax
    sub     ecx, edi
    cmp     ecx, ebp
    jnb     short loc_40C76B
    lea     edx, [ebp+edi+0]
    mov     ecx, esi
    push    edx
    push    eax
    push    edi
    call    sub_40D4F0
    mov     eax, [esi+8]
    mov     ebx, [esp+18h+arg_4]
    lea     ecx, [ebp+edi+0]
    push    ebx
    sub     ecx, eax
    push    ecx
    push    eax
    mov     ecx, esi
    call    sub_40D520
    mov     eax, [esi+8]
    cmp     edi, eax
    jz      short loc_40C7A6

    loc_40C755:                             ; CODE XREF: sub_40C600+15Cj
    mov     dl, [ebx]
    mov     [edi], dl
    inc     edi
    cmp     edi, eax
    jnz     short loc_40C755
    add     [esi+8], ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40C76B:                             ; CODE XREF: sub_40C600+127j
    test    ebp, ebp
    jbe     short loc_40C7E4
    push    eax
    push    eax
    sub     eax, ebp
    mov     ecx, esi
    push    eax
    call    sub_40D4F0
    mov     ecx, [esi+8]
    mov     eax, ecx
    sub     eax, ebp
    cmp     edi, eax
    jz      short loc_40C791

    loc_40C786:                             ; CODE XREF: sub_40C600+18Fj
    mov     dl, [eax-1]
    dec     eax
    dec     ecx
    cmp     eax, edi
    mov     [ecx], dl
    jnz     short loc_40C786

    loc_40C791:                             ; CODE XREF: sub_40C600+184j
    lea     eax, [ebp+edi+0]
    cmp     edi, eax
    jz      short loc_40C7A6
    mov     ecx, [esp+18h+arg_4]

    loc_40C79D:                             ; CODE XREF: sub_40C600+1A4j
    mov     dl, [ecx]
    mov     [edi], dl
    inc     edi
    cmp     edi, eax
    jnz     short loc_40C79D

    loc_40C7A6:                             ; CODE XREF: sub_40C600+153j
                                            ; sub_40C600+197j
    add     [esi+8], ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40C7B3:                             ; CODE XREF: sub_40C600+1Fj
    test    edx, edx
    jnz     short loc_40C7BB
    xor     eax, eax
    jmp     short loc_40C7C0
    ; ---------------------------------------------------------------------------

    loc_40C7BB:                             ; CODE XREF: sub_40C600+1B5j
    mov     eax, [esi+8]
    sub     eax, edx

    loc_40C7C0:                             ; CODE XREF: sub_40C600+1B9j
    cmp     ebp, eax
    jnb     short loc_40C7E4
    mov     ecx, [esi+8]
    lea     edi, [edx+ebp]
    cmp     ecx, ecx
    mov     eax, ecx
    jz      short loc_40C7DA

    loc_40C7D0:                             ; CODE XREF: sub_40C600+1D8j
    mov     dl, [eax]
    mov     [edi], dl
    inc     edi
    inc     eax
    cmp     eax, ecx
    jnz     short loc_40C7D0

    loc_40C7DA:                             ; CODE XREF: sub_40C600+1CEj
    mov     eax, [esi+8]
    mov     [esi+8], edi
    mov     [esp+18h+arg_4], eax

    loc_40C7E4:                             ; CODE XREF: sub_40C600+16Dj
                                            ; sub_40C600+1C2j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    sub_40C600 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C7F0 proc near                    ; CODE XREF: sub_409160+2CFp
                                            ; sub_409160+2E4p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [esi+4]
    test    ecx, ecx
    jnz     short loc_40C802
    xor     eax, eax
    jmp     short loc_40C80A
    ; ---------------------------------------------------------------------------

    loc_40C802:                             ; CODE XREF: sub_40C7F0+Cj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_40C80A:                             ; CODE XREF: sub_40C7F0+10j
    mov     ebx, [esp+14h+arg_0]
    cmp     eax, ebx
    jnb     loc_40C9AF
    test    ecx, ecx
    jnz     short loc_40C81E
    xor     edx, edx
    jmp     short loc_40C826
    ; ---------------------------------------------------------------------------

    loc_40C81E:                             ; CODE XREF: sub_40C7F0+28j
    mov     edx, [esi+8]
    sub     edx, ecx
    sar     edx, 2

    loc_40C826:                             ; CODE XREF: sub_40C7F0+2Cj
    mov     eax, [esi+8]
    sub     ebx, edx
    mov     edx, [esi+0Ch]
    mov     edi, eax
    sub     edx, eax
    sar     edx, 2
    cmp     edx, ebx
    jnb     loc_40C8F6
    test    ecx, ecx
    jnz     short loc_40C845
    xor     edx, edx
    jmp     short loc_40C84C
    ; ---------------------------------------------------------------------------

    loc_40C845:                             ; CODE XREF: sub_40C7F0+4Fj
    mov     edx, eax
    sub     edx, ecx
    sar     edx, 2

    loc_40C84C:                             ; CODE XREF: sub_40C7F0+53j
    cmp     ebx, edx
    jnb     short loc_40C861
    test    ecx, ecx
    jnz     short loc_40C858
    xor     ebp, ebp
    jmp     short loc_40C863
    ; ---------------------------------------------------------------------------

    loc_40C858:                             ; CODE XREF: sub_40C7F0+62j
    sub     eax, ecx
    sar     eax, 2
    mov     ebp, eax
    jmp     short loc_40C863
    ; ---------------------------------------------------------------------------

    loc_40C861:                             ; CODE XREF: sub_40C7F0+5Ej
    mov     ebp, ebx

    loc_40C863:                             ; CODE XREF: sub_40C7F0+66j
                                            ; sub_40C7F0+6Fj
    mov     ecx, esi
    call    sub_40D4C0
    add     eax, ebp
    mov     [esp+14h+var_4], eax
    jns     short loc_40C874
    xor     eax, eax

    loc_40C874:                             ; CODE XREF: sub_40C7F0+80j
    shl     eax, 2
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esi+4]
    add     esp, 4
    mov     ebp, eax
    push    ebp
    push    edi
    push    ecx
    mov     ecx, esi
    call    sub_40D550
    mov     edx, [esp+14h+arg_4]
    mov     ecx, esi
    push    edx
    push    ebx
    push    eax
    mov     [esp+20h+arg_0], eax
    call    sub_40D580
    mov     eax, [esp+14h+arg_0]
    mov     edx, [esi+8]
    lea     ecx, [eax+ebx*4]
    push    ecx
    push    edx
    push    edi
    mov     ecx, esi
    call    sub_40D550
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    eax
    push    ecx
    mov     ecx, esi
    call    nullsub_4
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+18h+var_4]
    add     esp, 4
    mov     ecx, esi
    lea     eax, [ebp+edx*4+0]
    mov     [esi+0Ch], eax
    call    sub_40D4C0
    add     eax, ebx
    mov     [esi+4], ebp
    lea     ecx, [ebp+eax*4+0]
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40C8F6:                             ; CODE XREF: sub_40C7F0+47j
    mov     edx, eax
    sub     edx, edi
    sar     edx, 2
    cmp     edx, ebx
    jnb     short loc_40C95B
    lea     ecx, ds:0[ebx*4]
    mov     [esp+14h+arg_0], ecx
    add     ecx, edi
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_40D550
    mov     eax, [esi+8]
    mov     ebp, [esp+14h+arg_4]
    mov     edx, eax
    push    ebp
    sub     edx, edi
    mov     ecx, esi
    sar     edx, 2
    sub     ebx, edx
    push    ebx
    push    eax
    call    sub_40D580
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40C947

    loc_40C93B:                             ; CODE XREF: sub_40C7F0+155j
    mov     edx, [ebp+0]
    mov     [eax], edx
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_40C93B

    loc_40C947:                             ; CODE XREF: sub_40C7F0+149j
    mov     eax, [esp+14h+arg_0]
    mov     ecx, [esi+8]
    add     ecx, eax
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40C95B:                             ; CODE XREF: sub_40C7F0+10Fj
    test    ebx, ebx
    jbe     loc_40C9E7
    shl     ebx, 2
    push    eax
    push    eax
    sub     eax, ebx
    mov     ecx, esi
    push    eax
    call    sub_40D550
    mov     ecx, [esi+8]
    mov     eax, ecx
    sub     eax, ebx
    cmp     edi, eax
    jz      short loc_40C98C

    loc_40C97D:                             ; CODE XREF: sub_40C7F0+19Aj
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_40C97D

    loc_40C98C:                             ; CODE XREF: sub_40C7F0+18Bj
    lea     ecx, [edi+ebx]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40C9A4
    mov     edx, [esp+14h+arg_4]

    loc_40C999:                             ; CODE XREF: sub_40C7F0+1B2j
    mov     edi, [edx]
    mov     [eax], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_40C999

    loc_40C9A4:                             ; CODE XREF: sub_40C7F0+1A3j
    add     [esi+8], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40C9AF:                             ; CODE XREF: sub_40C7F0+20j
    test    ecx, ecx
    jnz     short loc_40C9B7
    xor     eax, eax
    jmp     short loc_40C9BF
    ; ---------------------------------------------------------------------------

    loc_40C9B7:                             ; CODE XREF: sub_40C7F0+1C1j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_40C9BF:                             ; CODE XREF: sub_40C7F0+1C5j
    cmp     ebx, eax
    jnb     short loc_40C9E7
    mov     edx, [esi+8]
    lea     ecx, [ecx+ebx*4]
    cmp     edx, edx
    mov     eax, edx
    jz      short loc_40C9DD

    loc_40C9CF:                             ; CODE XREF: sub_40C7F0+1EBj
    mov     edi, [eax]
    add     eax, 4
    mov     [ecx], edi
    add     ecx, 4
    cmp     eax, edx
    jnz     short loc_40C9CF

    loc_40C9DD:                             ; CODE XREF: sub_40C7F0+1DDj
    mov     eax, [esi+8]
    mov     [esi+8], ecx
    mov     [esp+14h+arg_4], eax

    loc_40C9E7:                             ; CODE XREF: sub_40C7F0+16Dj
                                            ; sub_40C7F0+1D1j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_40C7F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40C9F0 proc near                    ; CODE XREF: sub_40AA40+14p
                                            ; sub_40AA40+24p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    mov     eax, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     esi, eax
    cmp     edx, edi
    jz      short loc_40CA13
    push    ebx

    loc_40CA04:                             ; CODE XREF: sub_40C9F0+20j
    mov     ebx, [edx]
    add     edx, 4
    mov     [esi], ebx
    add     esi, 4
    cmp     edx, edi
    jnz     short loc_40CA04
    pop     ebx

    loc_40CA13:                             ; CODE XREF: sub_40C9F0+11j
    mov     edx, [ecx+8]
    mov     [ecx+8], esi
    pop     edi
    mov     [esp+4+arg_0], edx
    pop     esi
    retn    8
    sub_40C9F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40CA30 proc near                    ; CODE XREF: sub_40A260+5Fp
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_40CA3A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_40CA3A:                             ; CODE XREF: sub_40CA30+5j
    mov     eax, [ecx+0Ch]
    sub     eax, edx
    sar     eax, 3
    retn
    sub_40CA30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40CA50 proc near                    ; CODE XREF: sub_40A260+174p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     edi, [esp+1Ch+arg_0]
    mov     eax, [esi+8]
    mov     edx, [esi+0Ch]
    mov     ecx, [esi+4]
    mov     ebp, edi
    sub     edx, eax
    sub     ebp, ecx
    sar     edx, 3
    sar     ebp, 3
    cmp     edx, 1
    mov     [esp+1Ch+var_4], ebp
    jnb     loc_40CB6C
    test    ecx, ecx
    jnz     short loc_40CA87
    xor     edx, edx
    jmp     short loc_40CA8E
    ; ---------------------------------------------------------------------------

    loc_40CA87:                             ; CODE XREF: sub_40CA50+31j
    mov     edx, eax
    sub     edx, ecx
    sar     edx, 3

    loc_40CA8E:                             ; CODE XREF: sub_40CA50+35j
    cmp     edx, 1
    jbe     short loc_40CAA4
    test    ecx, ecx
    jnz     short loc_40CA9B
    xor     edx, edx
    jmp     short loc_40CAA9
    ; ---------------------------------------------------------------------------

    loc_40CA9B:                             ; CODE XREF: sub_40CA50+45j
    mov     edx, eax
    sub     edx, ecx
    sar     edx, 3
    jmp     short loc_40CAA9
    ; ---------------------------------------------------------------------------

    loc_40CAA4:                             ; CODE XREF: sub_40CA50+41j
    mov     edx, 1

    loc_40CAA9:                             ; CODE XREF: sub_40CA50+49j
                                            ; sub_40CA50+52j
    test    ecx, ecx
    jnz     short loc_40CAB1
    xor     eax, eax
    jmp     short loc_40CAB6
    ; ---------------------------------------------------------------------------

    loc_40CAB1:                             ; CODE XREF: sub_40CA50+5Bj
    sub     eax, ecx
    sar     eax, 3

    loc_40CAB6:                             ; CODE XREF: sub_40CA50+5Fj
    add     eax, edx
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_40CAC2
    xor     eax, eax

    loc_40CAC2:                             ; CODE XREF: sub_40CA50+6Ej
    shl     eax, 3
    push    eax                             ; int
    call    sub_4B4F10
    mov     ebx, [esi+4]
    add     esp, 4
    cmp     ebx, edi
    mov     [esp+1Ch+var_C], eax
    mov     ebp, eax
    jz      short loc_40CAEC

    loc_40CADB:                             ; CODE XREF: sub_40CA50+9Aj
    push    ebx
    push    ebp
    call    sub_40D5E0
    add     ebx, 8
    add     ebp, 8
    cmp     ebx, edi
    jnz     short loc_40CADB

    loc_40CAEC:                             ; CODE XREF: sub_40CA50+89j
    mov     ebx, ebp
    mov     [esp+1Ch+arg_0], 1

    loc_40CAF6:                             ; CODE XREF: sub_40CA50+BDj
    mov     ecx, [esp+1Ch+arg_4]
    push    ecx
    push    ebx
    call    sub_40D5E0
    mov     eax, [esp+1Ch+arg_0]
    add     ebx, 8
    dec     eax
    mov     [esp+1Ch+arg_0], eax
    jnz     short loc_40CAF6
    mov     edx, [esi+8]
    add     ebp, 8
    push    ebp
    push    edx
    push    edi
    mov     ecx, esi
    call    sub_40CC40
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    eax
    push    ecx
    mov     ecx, esi
    call    nullsub_2
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edi, [esp+20h+var_C]
    mov     edx, [esp+20h+var_8]
    add     esp, 4
    mov     ecx, esi
    lea     eax, [edi+edx*8]
    mov     [esi+0Ch], eax
    call    sub_40C5B0
    mov     ebp, [esp+1Ch+var_4]
    lea     ecx, [edi+eax*8+8]
    mov     [esi+8], ecx
    mov     [esi+4], edi
    mov     esi, edi
    lea     eax, [esi+ebp*8]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40CB6C:                             ; CODE XREF: sub_40CA50+29j
    mov     edx, eax
    sub     edx, edi
    sar     edx, 3
    cmp     edx, 1
    jnb     short loc_40CBC0
    lea     ecx, [edi+8]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_40CC40
    mov     eax, [esi+8]
    mov     ebx, [esp+1Ch+arg_4]
    mov     edx, eax
    mov     ecx, 1
    sub     edx, edi
    push    ebx
    sar     edx, 3
    sub     ecx, edx
    push    ecx
    push    eax
    mov     ecx, esi
    call    sub_40D5B0
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40CC0A

    loc_40CBAD:                             ; CODE XREF: sub_40CA50+16Cj
    mov     edx, [ebx]
    mov     [eax], edx
    mov     edx, [ebx+4]
    mov     [eax+4], edx
    add     eax, 8
    cmp     eax, ecx
    jnz     short loc_40CBAD
    jmp     short loc_40CC0A
    ; ---------------------------------------------------------------------------

    loc_40CBC0:                             ; CODE XREF: sub_40CA50+126j
    push    eax
    push    eax
    add     eax, 0FFFFFFF8h
    mov     ecx, esi
    push    eax
    call    sub_40CC40
    mov     ecx, [esi+8]
    lea     eax, [ecx-8]
    cmp     edi, eax
    jz      short loc_40CBEC

    loc_40CBD7:                             ; CODE XREF: sub_40CA50+19Aj
    mov     edx, [eax-8]
    sub     eax, 8
    sub     ecx, 8
    cmp     eax, edi
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    jnz     short loc_40CBD7

    loc_40CBEC:                             ; CODE XREF: sub_40CA50+185j
    lea     edx, [edi+8]
    mov     eax, edi
    cmp     edi, edx
    jz      short loc_40CC0A
    mov     ecx, [esp+1Ch+arg_4]

    loc_40CBF9:                             ; CODE XREF: sub_40CA50+1B8j
    mov     edi, [ecx]
    mov     [eax], edi
    mov     edi, [ecx+4]
    mov     [eax+4], edi
    add     eax, 8
    cmp     eax, edx
    jnz     short loc_40CBF9

    loc_40CC0A:                             ; CODE XREF: sub_40CA50+15Bj
                                            ; sub_40CA50+16Ej ...
    mov     eax, [esi+8]
    pop     edi
    add     eax, 8
    mov     [esi+8], eax
    mov     esi, [esi+4]
    lea     eax, [esi+ebp*8]
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_40CA50 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_2. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40CC40 proc near                    ; CODE XREF: sub_40A260+91p
                                            ; sub_40A7B0+139p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_40CC6D
    mov     eax, [esp+arg_8]
    push    esi

    loc_40CC51:                             ; CODE XREF: sub_40CC40+27j
    test    eax, eax
    jz      short loc_40CC5F
    mov     esi, [ecx]
    mov     [eax], esi
    mov     esi, [ecx+4]
    mov     [eax+4], esi

    loc_40CC5F:                             ; CODE XREF: sub_40CC40+13j
    add     ecx, 8
    add     eax, 8
    cmp     ecx, edx
    jnz     short loc_40CC51
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40CC6D:                             ; CODE XREF: sub_40CC40+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_40CC40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40CC80 proc near                    ; CODE XREF: sub_409160+25Cp
                                            ; sub_409160+273p ...
    mov     eax, [ecx+4]
    test    eax, eax
    jnz     short loc_40CC88
    retn
    ; ---------------------------------------------------------------------------

    loc_40CC88:                             ; CODE XREF: sub_40CC80+5j
    mov     ecx, [ecx+8]
    sub     ecx, eax
    mov     eax, 55555556h
    imul    ecx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, edx
    retn
    sub_40CC80 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40CCA0 proc near                    ; CODE XREF: sub_409160+284p
                                            ; sub_409730+F4p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    push    ebp
    mov     ebp, ecx
    mov     eax, 55555556h
    mov     ebx, [esp+10h+arg_4]
    push    esi
    mov     ecx, [ebp+8]
    mov     edx, [ebp+0Ch]
    sub     edx, ecx
    push    edi
    imul    edx
    mov     eax, edx
    mov     [esp+18h+var_8], ebp
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ebx
    jnb     loc_40CE49
    mov     esi, [ebp+4]
    test    esi, esi
    jnz     short loc_40CCDA
    xor     edx, edx
    jmp     short loc_40CCEC
    ; ---------------------------------------------------------------------------

    loc_40CCDA:                             ; CODE XREF: sub_40CCA0+34j
    mov     edx, ecx
    mov     eax, 55555556h
    sub     edx, esi
    imul    edx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_40CCEC:                             ; CODE XREF: sub_40CCA0+38j
    cmp     ebx, edx
    jnb     short loc_40CD0E
    test    esi, esi
    jnz     short loc_40CCF8
    xor     edi, edi
    jmp     short loc_40CD10
    ; ---------------------------------------------------------------------------

    loc_40CCF8:                             ; CODE XREF: sub_40CCA0+52j
    mov     edx, ecx
    mov     eax, 55555556h
    sub     edx, esi
    imul    edx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     edi, edx
    jmp     short loc_40CD10
    ; ---------------------------------------------------------------------------

    loc_40CD0E:                             ; CODE XREF: sub_40CCA0+4Ej
    mov     edi, ebx

    loc_40CD10:                             ; CODE XREF: sub_40CCA0+56j
                                            ; sub_40CCA0+6Cj
    test    esi, esi
    jnz     short loc_40CD18
    xor     edx, edx
    jmp     short loc_40CD28
    ; ---------------------------------------------------------------------------

    loc_40CD18:                             ; CODE XREF: sub_40CCA0+72j
    sub     ecx, esi
    mov     eax, 55555556h
    imul    ecx
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_40CD28:                             ; CODE XREF: sub_40CCA0+76j
    lea     eax, [edx+edi]
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_40CD35
    xor     eax, eax

    loc_40CD35:                             ; CODE XREF: sub_40CCA0+91j
    lea     edx, [eax+eax*2]
    push    edx                             ; int
    call    sub_4B4F10
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebp+4]
    mov     ebp, [esp+1Ch+arg_0]
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_40CD70

    loc_40CD52:                             ; CODE XREF: sub_40CCA0+CEj
    test    edx, edx
    jz      short loc_40CD66
    mov     ecx, eax
    mov     esi, edx
    mov     di, [ecx]
    mov     [esi], di
    mov     cl, [ecx+2]
    mov     [esi+2], cl

    loc_40CD66:                             ; CODE XREF: sub_40CCA0+B4j
    add     eax, 3
    add     edx, 3
    cmp     eax, ebp
    jnz     short loc_40CD52

    loc_40CD70:                             ; CODE XREF: sub_40CCA0+B0j
    test    ebx, ebx
    mov     eax, edx
    jbe     short loc_40CD9E
    mov     [esp+18h+arg_0], ebx

    loc_40CD7A:                             ; CODE XREF: sub_40CCA0+FCj
    test    eax, eax
    jz      short loc_40CD90
    mov     ecx, [esp+18h+arg_8]
    mov     esi, eax
    mov     di, [ecx]
    mov     [esi], di
    mov     cl, [ecx+2]
    mov     [esi+2], cl

    loc_40CD90:                             ; CODE XREF: sub_40CCA0+DCj
    mov     ecx, [esp+18h+arg_0]
    add     eax, 3
    dec     ecx
    mov     [esp+18h+arg_0], ecx
    jnz     short loc_40CD7A

    loc_40CD9E:                             ; CODE XREF: sub_40CCA0+D4j
    mov     eax, [esp+18h+var_8]
    lea     edi, [ebx+ebx*2]
    mov     esi, [eax+8]
    lea     ecx, [edx+edi]
    cmp     ebp, esi
    jz      short loc_40CDD5
    lea     eax, [ebp+ecx+0]
    sub     eax, edx
    sub     eax, edi

    loc_40CDB7:                             ; CODE XREF: sub_40CCA0+133j
    test    ecx, ecx
    jz      short loc_40CDCB
    mov     edx, eax
    mov     edi, ecx
    mov     bp, [edx]
    mov     [edi], bp
    mov     dl, [edx+2]
    mov     [edi+2], dl

    loc_40CDCB:                             ; CODE XREF: sub_40CCA0+119j
    add     eax, 3
    add     ecx, 3
    cmp     eax, esi
    jnz     short loc_40CDB7

    loc_40CDD5:                             ; CODE XREF: sub_40CCA0+10Dj
    mov     eax, [esp+18h+var_8]
    mov     eax, [eax+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     edi, [esp+1Ch+arg_4]
    mov     eax, [esp+1Ch+var_4]
    mov     esi, [esp+1Ch+var_8]
    add     esp, 4
    lea     ecx, [edi+eax*2]
    add     eax, ecx
    mov     [esi+0Ch], eax
    mov     eax, [esi+4]
    test    eax, eax
    jnz     short loc_40CE1E
    xor     edx, edx
    mov     [esi+4], edi
    lea     eax, [ebx+edx]
    lea     ecx, [edi+eax*2]
    add     eax, ecx
    mov     [esi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40CE1E:                             ; CODE XREF: sub_40CCA0+162j
    mov     ecx, [esi+8]
    mov     [esi+4], edi
    sub     ecx, eax
    mov     eax, 55555556h
    imul    ecx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    lea     eax, [ebx+edx]
    lea     ecx, [edi+eax*2]
    add     eax, ecx
    mov     [esi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40CE49:                             ; CODE XREF: sub_40CCA0+29j
    mov     edi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, edi
    mov     eax, 55555556h
    imul    edx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ebx
    jnb     loc_40CF14
    lea     edx, [ebx+ebx*2]
    cmp     edi, ecx
    mov     [esp+18h+arg_0], edx
    lea     esi, [edi+edx]
    jz      short loc_40CE9F
    mov     eax, esi
    sub     eax, edx

    loc_40CE79:                             ; CODE XREF: sub_40CCA0+1F9j
    test    esi, esi
    jz      short loc_40CE91
    mov     edx, eax
    mov     ebx, esi
    mov     bp, [edx]
    mov     [ebx], bp
    mov     dl, [edx+2]
    mov     [ebx+2], dl
    mov     ebx, [esp+18h+arg_4]

    loc_40CE91:                             ; CODE XREF: sub_40CCA0+1DBj
    add     eax, 3
    add     esi, 3
    cmp     eax, ecx
    jnz     short loc_40CE79
    mov     ebp, [esp+18h+var_8]

    loc_40CE9F:                             ; CODE XREF: sub_40CCA0+1D3j
    mov     esi, [ebp+8]
    mov     eax, 55555556h
    mov     ecx, esi
    sub     ecx, edi
    imul    ecx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, esi
    mov     esi, [esp+18h+arg_8]
    sub     ebx, edx
    mov     ecx, ebx
    jz      short loc_40CEDE

    loc_40CEC0:                             ; CODE XREF: sub_40CCA0+238j
    test    eax, eax
    jz      short loc_40CED4
    mov     edx, esi
    mov     ebx, eax
    mov     bp, [edx]
    mov     [ebx], bp
    mov     dl, [edx+2]
    mov     [ebx+2], dl

    loc_40CED4:                             ; CODE XREF: sub_40CCA0+222j
    add     eax, 3
    dec     ecx
    jnz     short loc_40CEC0
    mov     ebp, [esp+18h+var_8]

    loc_40CEDE:                             ; CODE XREF: sub_40CCA0+21Ej
    mov     ecx, [ebp+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40CEFE

    loc_40CEE7:                             ; CODE XREF: sub_40CCA0+25Cj
    mov     edx, esi
    mov     edi, eax
    add     eax, 3
    mov     bx, [edx]
    cmp     eax, ecx
    mov     [edi], bx
    mov     dl, [edx+2]
    mov     [edi+2], dl
    jnz     short loc_40CEE7

    loc_40CEFE:                             ; CODE XREF: sub_40CCA0+245j
    mov     eax, [esp+18h+arg_0]
    mov     ecx, [ebp+8]
    add     ecx, eax
    mov     [ebp+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40CF14:                             ; CODE XREF: sub_40CCA0+1C1j
    test    ebx, ebx
    jbe     loc_40CFA3
    lea     ebp, [ebx+ebx*2]
    mov     eax, ecx
    sub     eax, ebp
    mov     esi, ecx
    cmp     eax, ecx
    mov     [esp+18h+arg_0], ebp
    jz      short loc_40CF4F

    loc_40CF2D:                             ; CODE XREF: sub_40CCA0+2A9j
    test    esi, esi
    jz      short loc_40CF41
    mov     edx, eax
    mov     ebx, esi
    mov     bp, [edx]
    mov     [ebx], bp
    mov     dl, [edx+2]
    mov     [ebx+2], dl

    loc_40CF41:                             ; CODE XREF: sub_40CCA0+28Fj
    add     eax, 3
    add     esi, 3
    cmp     eax, ecx
    jnz     short loc_40CF2D
    mov     ebp, [esp+18h+arg_0]

    loc_40CF4F:                             ; CODE XREF: sub_40CCA0+28Bj
    mov     eax, [esp+18h+var_8]
    mov     ecx, [eax+8]
    mov     eax, ecx
    sub     eax, ebp
    cmp     edi, eax
    jz      short loc_40CF78

    loc_40CF5E:                             ; CODE XREF: sub_40CCA0+2D6j
    sub     eax, 3
    sub     ecx, 3
    mov     edx, eax
    mov     esi, ecx
    cmp     eax, edi
    mov     bx, [edx]
    mov     [esi], bx
    mov     dl, [edx+2]
    mov     [esi+2], dl
    jnz     short loc_40CF5E

    loc_40CF78:                             ; CODE XREF: sub_40CCA0+2BCj
    lea     ecx, [edi+ebp]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40CF9C
    mov     esi, [esp+18h+arg_8]

    loc_40CF85:                             ; CODE XREF: sub_40CCA0+2FAj
    mov     edx, esi
    mov     edi, eax
    add     eax, 3
    mov     bx, [edx]
    cmp     eax, ecx
    mov     [edi], bx
    mov     dl, [edx+2]
    mov     [edi+2], dl
    jnz     short loc_40CF85

    loc_40CF9C:                             ; CODE XREF: sub_40CCA0+2DFj
    mov     eax, [esp+18h+var_8]
    add     [eax+8], ebp

    loc_40CFA3:                             ; CODE XREF: sub_40CCA0+276j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_40CCA0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40CFB0 proc near                    ; CODE XREF: sub_409160+2A5p
                                            ; sub_409730+124p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    push    edi
    mov     edi, [ecx+8]
    cmp     edx, edi
    jz      short loc_40CFDF
    push    ebp
    push    ebx

    loc_40CFC3:                             ; CODE XREF: sub_40CFB0+2Bj
    mov     eax, edx
    mov     ebx, esi
    add     edx, 3
    add     esi, 3
    mov     bp, [eax]
    cmp     edx, edi
    mov     [ebx], bp
    mov     al, [eax+2]
    mov     [ebx+2], al
    jnz     short loc_40CFC3
    pop     ebx
    pop     ebp

    loc_40CFDF:                             ; CODE XREF: sub_40CFB0+Fj
    mov     edx, [ecx+8]
    mov     eax, [esp+8+arg_0]
    mov     [ecx+8], esi
    pop     edi
    mov     [esp+4+arg_4], edx
    pop     esi
    retn    8
    sub_40CFB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D000 proc near                    ; CODE XREF: sub_409160+1FBp
                                            ; sub_409160+216p ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_40D00A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_40D00A:                             ; CODE XREF: sub_40D000+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 1
    retn
    sub_40D000 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D020 proc near                    ; CODE XREF: sub_409160+227p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    push    ebp
    mov     ebx, [esp+10h+arg_4]
    mov     ebp, ecx
    push    esi
    push    edi
    mov     ecx, [ebp+8]
    mov     eax, [ebp+0Ch]
    sub     eax, ecx
    mov     [esp+18h+var_8], ebp
    sar     eax, 1
    cmp     eax, ebx
    jnb     loc_40D152
    mov     edx, [ebp+4]
    test    edx, edx
    jnz     short loc_40D04E
    xor     eax, eax
    jmp     short loc_40D054
    ; ---------------------------------------------------------------------------

    loc_40D04E:                             ; CODE XREF: sub_40D020+28j
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 1

    loc_40D054:                             ; CODE XREF: sub_40D020+2Cj
    cmp     ebx, eax
    jnb     short loc_40D068
    test    edx, edx
    jnz     short loc_40D060
    xor     eax, eax
    jmp     short loc_40D06A
    ; ---------------------------------------------------------------------------

    loc_40D060:                             ; CODE XREF: sub_40D020+3Aj
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 1
    jmp     short loc_40D06A
    ; ---------------------------------------------------------------------------

    loc_40D068:                             ; CODE XREF: sub_40D020+36j
    mov     eax, ebx

    loc_40D06A:                             ; CODE XREF: sub_40D020+3Ej
                                            ; sub_40D020+46j
    test    edx, edx
    jnz     short loc_40D072
    xor     ecx, ecx
    jmp     short loc_40D076
    ; ---------------------------------------------------------------------------

    loc_40D072:                             ; CODE XREF: sub_40D020+4Cj
    sub     ecx, edx
    sar     ecx, 1

    loc_40D076:                             ; CODE XREF: sub_40D020+50j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_40D082
    xor     eax, eax

    loc_40D082:                             ; CODE XREF: sub_40D020+5Ej
    lea     ecx, [eax+eax]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+1Ch+arg_0]
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebp+4]
    add     esp, 4
    cmp     eax, ecx
    jz      short loc_40D0B3

    loc_40D09F:                             ; CODE XREF: sub_40D020+91j
    test    edx, edx
    jz      short loc_40D0A9
    mov     si, [eax]
    mov     [edx], si

    loc_40D0A9:                             ; CODE XREF: sub_40D020+81j
    add     eax, 2
    add     edx, 2
    cmp     eax, ecx
    jnz     short loc_40D09F

    loc_40D0B3:                             ; CODE XREF: sub_40D020+7Dj
    test    ebx, ebx
    mov     eax, edx
    jbe     short loc_40D0D3
    mov     edi, [esp+18h+arg_8]
    mov     esi, ebx

    loc_40D0BF:                             ; CODE XREF: sub_40D020+B1j
    test    eax, eax
    jz      short loc_40D0CD
    mov     bp, [edi]
    mov     [eax], bp
    mov     ebp, [esp+18h+var_8]

    loc_40D0CD:                             ; CODE XREF: sub_40D020+A1j
    add     eax, 2
    dec     esi
    jnz     short loc_40D0BF

    loc_40D0D3:                             ; CODE XREF: sub_40D020+97j
    mov     esi, [ebp+8]
    lea     edi, [ebx+ebx]
    cmp     ecx, esi
    lea     eax, [edx+edi]
    jz      short loc_40D0FA
    sub     ecx, edx
    add     ecx, eax
    sub     ecx, edi

    loc_40D0E6:                             ; CODE XREF: sub_40D020+D8j
    test    eax, eax
    jz      short loc_40D0F0
    mov     dx, [ecx]
    mov     [eax], dx

    loc_40D0F0:                             ; CODE XREF: sub_40D020+C8j
    add     ecx, 2
    add     eax, 2
    cmp     ecx, esi
    jnz     short loc_40D0E6

    loc_40D0FA:                             ; CODE XREF: sub_40D020+BEj
    mov     eax, [ebp+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     edx, [esp+1Ch+arg_4]
    mov     eax, [esp+1Ch+var_4]
    add     esp, 4
    lea     ecx, [edx+eax*2]
    mov     [ebp+0Ch], ecx
    mov     ecx, [ebp+4]
    test    ecx, ecx
    jnz     short loc_40D136
    xor     eax, eax
    mov     [ebp+4], edx
    add     ebx, eax
    lea     eax, [edx+ebx*2]
    mov     [ebp+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40D136:                             ; CODE XREF: sub_40D020+FDj
    mov     eax, [ebp+8]
    mov     [ebp+4], edx
    sub     eax, ecx
    sar     eax, 1
    add     ebx, eax
    lea     eax, [edx+ebx*2]
    mov     [ebp+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40D152:                             ; CODE XREF: sub_40D020+1Dj
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, esi
    sar     edx, 1
    cmp     edx, ebx
    jnb     short loc_40D1CC
    lea     edi, [ebx+ebx]
    cmp     esi, ecx
    lea     edx, [esi+edi]
    jz      short loc_40D186
    mov     eax, edx
    sub     eax, edi

    loc_40D16E:                             ; CODE XREF: sub_40D020+164j
    test    edx, edx
    jz      short loc_40D17C
    mov     bp, [eax]
    mov     [edx], bp
    mov     ebp, [esp+18h+var_8]

    loc_40D17C:                             ; CODE XREF: sub_40D020+150j
    add     eax, 2
    add     edx, 2
    cmp     eax, ecx
    jnz     short loc_40D16E

    loc_40D186:                             ; CODE XREF: sub_40D020+148j
    mov     eax, [ebp+8]
    mov     edx, [esp+18h+arg_8]
    mov     ecx, eax
    sub     ecx, esi
    sar     ecx, 1
    sub     ebx, ecx
    mov     ecx, ebx
    jz      short loc_40D1A9

    loc_40D199:                             ; CODE XREF: sub_40D020+187j
    test    eax, eax
    jz      short loc_40D1A3
    mov     bx, [edx]
    mov     [eax], bx

    loc_40D1A3:                             ; CODE XREF: sub_40D020+17Bj
    add     eax, 2
    dec     ecx
    jnz     short loc_40D199

    loc_40D1A9:                             ; CODE XREF: sub_40D020+177j
    mov     ecx, [ebp+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_40D227

    loc_40D1B2:                             ; CODE XREF: sub_40D020+19Dj
    mov     si, [edx]
    mov     [eax], si
    add     eax, 2
    cmp     eax, ecx
    jnz     short loc_40D1B2
    add     [ebp+8], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40D1CC:                             ; CODE XREF: sub_40D020+13Ej
    test    ebx, ebx
    jbe     short loc_40D22A
    lea     edi, [ebx+ebx]
    mov     eax, ecx
    sub     eax, edi
    mov     edx, ecx
    cmp     eax, ecx
    jz      short loc_40D1F1

    loc_40D1DD:                             ; CODE XREF: sub_40D020+1CFj
    test    edx, edx
    jz      short loc_40D1E7
    mov     bx, [eax]
    mov     [edx], bx

    loc_40D1E7:                             ; CODE XREF: sub_40D020+1BFj
    add     eax, 2
    add     edx, 2
    cmp     eax, ecx
    jnz     short loc_40D1DD

    loc_40D1F1:                             ; CODE XREF: sub_40D020+1BBj
    mov     ecx, [ebp+8]
    mov     eax, ecx
    sub     eax, edi
    cmp     esi, eax
    jz      short loc_40D20D

    loc_40D1FC:                             ; CODE XREF: sub_40D020+1EBj
    mov     dx, [eax-2]
    sub     eax, 2
    sub     ecx, 2
    cmp     eax, esi
    mov     [ecx], dx
    jnz     short loc_40D1FC

    loc_40D20D:                             ; CODE XREF: sub_40D020+1DAj
    lea     ecx, [esi+edi]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_40D227
    mov     edx, [esp+18h+arg_8]

    loc_40D21A:                             ; CODE XREF: sub_40D020+205j
    mov     si, [edx]
    mov     [eax], si
    add     eax, 2
    cmp     eax, ecx
    jnz     short loc_40D21A

    loc_40D227:                             ; CODE XREF: sub_40D020+190j
                                            ; sub_40D020+1F4j
    add     [ebp+8], edi

    loc_40D22A:                             ; CODE XREF: sub_40D020+1AEj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_40D020 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D240 proc near                    ; CODE XREF: sub_409160+246p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    mov     eax, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     esi, eax
    cmp     edx, edi
    jz      short loc_40D265
    push    ebx

    loc_40D254:                             ; CODE XREF: sub_40D240+22j
    mov     bx, [edx]
    add     edx, 2
    mov     [esi], bx
    add     esi, 2
    cmp     edx, edi
    jnz     short loc_40D254
    pop     ebx

    loc_40D265:                             ; CODE XREF: sub_40D240+11j
    mov     edx, [ecx+8]
    mov     [ecx+8], esi
    pop     edi
    mov     [esp+4+arg_0], edx
    pop     esi
    retn    8
    sub_40D240 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_38. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D290 proc near                    ; CODE XREF: sub_409160+1CFp
                                            ; sub_409730+56p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    mov     ebx, [esp+0Ch+arg_4]
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     ecx, [ebp+8]
    mov     eax, [ebp+0Ch]
    sub     eax, ecx
    mov     [esp+18h+var_8], ebp
    cmp     eax, ebx
    jnb     loc_40D3B9
    mov     eax, [ebp+4]
    test    eax, eax
    jnz     short loc_40D2BC
    xor     edx, edx
    jmp     short loc_40D2C0
    ; ---------------------------------------------------------------------------

    loc_40D2BC:                             ; CODE XREF: sub_40D290+26j
    mov     edx, ecx
    sub     edx, eax

    loc_40D2C0:                             ; CODE XREF: sub_40D290+2Aj
    cmp     ebx, edx
    jnb     short loc_40D2D2
    test    eax, eax
    jnz     short loc_40D2CC
    xor     edx, edx
    jmp     short loc_40D2D4
    ; ---------------------------------------------------------------------------

    loc_40D2CC:                             ; CODE XREF: sub_40D290+36j
    mov     edx, ecx
    sub     edx, eax
    jmp     short loc_40D2D4
    ; ---------------------------------------------------------------------------

    loc_40D2D2:                             ; CODE XREF: sub_40D290+32j
    mov     edx, ebx

    loc_40D2D4:                             ; CODE XREF: sub_40D290+3Aj
                                            ; sub_40D290+40j
    test    eax, eax
    jnz     short loc_40D2DC
    xor     ecx, ecx
    jmp     short loc_40D2DE
    ; ---------------------------------------------------------------------------

    loc_40D2DC:                             ; CODE XREF: sub_40D290+46j
    sub     ecx, eax

    loc_40D2DE:                             ; CODE XREF: sub_40D290+4Aj
    lea     eax, [ecx+edx]
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_40D2EB
    xor     eax, eax

    loc_40D2EB:                             ; CODE XREF: sub_40D290+57j
    push    eax                             ; int
    call    sub_4B4F10
    mov     edi, [esp+1Ch+arg_0]
    mov     ebx, eax
    mov     eax, [ebp+4]
    add     esp, 4
    cmp     eax, edi
    mov     edx, ebx
    jz      short loc_40D315

    loc_40D303:                             ; CODE XREF: sub_40D290+83j
    test    edx, edx
    jz      short loc_40D30F
    mov     cl, [eax]
    mov     ebp, [esp+18h+var_8]
    mov     [edx], cl

    loc_40D30F:                             ; CODE XREF: sub_40D290+75j
    inc     edx
    inc     eax
    cmp     eax, edi
    jnz     short loc_40D303

    loc_40D315:                             ; CODE XREF: sub_40D290+71j
    mov     esi, [esp+18h+arg_4]
    mov     eax, edx
    test    esi, esi
    jbe     short loc_40D338
    mov     ebp, [esp+18h+arg_8]

    loc_40D323:                             ; CODE XREF: sub_40D290+9Ej
    test    eax, eax
    jz      short loc_40D32C
    mov     cl, [ebp+0]
    mov     [eax], cl

    loc_40D32C:                             ; CODE XREF: sub_40D290+95j
    inc     eax
    dec     esi
    jnz     short loc_40D323
    mov     ebp, [esp+18h+var_8]
    mov     esi, [esp+18h+arg_4]

    loc_40D338:                             ; CODE XREF: sub_40D290+8Dj
    lea     ecx, [edx+esi]
    mov     esi, [ebp+8]
    cmp     edi, esi
    jz      short loc_40D360
    mov     eax, ecx
    sub     eax, edx
    mov     edx, [esp+18h+arg_4]
    sub     eax, edx
    add     eax, edi

    loc_40D34E:                             ; CODE XREF: sub_40D290+CEj
    test    ecx, ecx
    jz      short loc_40D35A
    mov     dl, [eax]
    mov     ebp, [esp+18h+var_8]
    mov     [ecx], dl

    loc_40D35A:                             ; CODE XREF: sub_40D290+C0j
    inc     ecx
    inc     eax
    cmp     eax, esi
    jnz     short loc_40D34E

    loc_40D360:                             ; CODE XREF: sub_40D290+B0j
    mov     eax, [ebp+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     eax, [esp+1Ch+var_4]
    mov     ecx, [ebp+4]
    add     esp, 4
    add     eax, ebx
    test    ecx, ecx
    mov     [ebp+0Ch], eax
    jnz     short loc_40D39B
    xor     eax, eax
    mov     [ebp+4], ebx
    lea     ecx, [ebx+eax]
    mov     eax, [esp+18h+arg_4]
    add     ecx, eax
    mov     [ebp+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40D39B:                             ; CODE XREF: sub_40D290+EEj
    mov     eax, [ebp+8]
    mov     [ebp+4], ebx
    sub     eax, ecx
    lea     ecx, [ebx+eax]
    mov     eax, [esp+18h+arg_4]
    add     ecx, eax
    mov     [ebp+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40D3B9:                             ; CODE XREF: sub_40D290+1Bj
    mov     edi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, edi
    cmp     edx, ebx
    jnb     short loc_40D418
    cmp     edi, ecx
    lea     esi, [ebx+edi]
    jz      short loc_40D3DE
    mov     eax, esi
    sub     eax, ebx

    loc_40D3D0:                             ; CODE XREF: sub_40D290+14Cj
    test    esi, esi
    jz      short loc_40D3D8
    mov     dl, [eax]
    mov     [esi], dl

    loc_40D3D8:                             ; CODE XREF: sub_40D290+142j
    inc     esi
    inc     eax
    cmp     eax, ecx
    jnz     short loc_40D3D0

    loc_40D3DE:                             ; CODE XREF: sub_40D290+13Aj
    mov     eax, [ebp+8]
    mov     esi, [esp+18h+arg_8]
    mov     ecx, ebx
    sub     ecx, eax
    add     ecx, edi
    jz      short loc_40D3F9

    loc_40D3ED:                             ; CODE XREF: sub_40D290+167j
    test    eax, eax
    jz      short loc_40D3F5
    mov     dl, [esi]
    mov     [eax], dl

    loc_40D3F5:                             ; CODE XREF: sub_40D290+15Fj
    inc     eax
    dec     ecx
    jnz     short loc_40D3ED

    loc_40D3F9:                             ; CODE XREF: sub_40D290+15Bj
    mov     ecx, [ebp+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40D460

    loc_40D402:                             ; CODE XREF: sub_40D290+179j
    mov     dl, [esi]
    mov     [eax], dl
    inc     eax
    cmp     eax, ecx
    jnz     short loc_40D402
    add     [ebp+8], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40D418:                             ; CODE XREF: sub_40D290+133j
    test    ebx, ebx
    jbe     short loc_40D463
    mov     eax, ecx
    mov     esi, ecx
    sub     eax, ebx
    cmp     eax, ecx
    jz      short loc_40D434

    loc_40D426:                             ; CODE XREF: sub_40D290+1A2j
    test    esi, esi
    jz      short loc_40D42E
    mov     dl, [eax]
    mov     [esi], dl

    loc_40D42E:                             ; CODE XREF: sub_40D290+198j
    inc     esi
    inc     eax
    cmp     eax, ecx
    jnz     short loc_40D426

    loc_40D434:                             ; CODE XREF: sub_40D290+194j
    mov     ecx, [ebp+8]
    mov     eax, ecx
    sub     eax, ebx
    cmp     edi, eax
    jz      short loc_40D44A

    loc_40D43F:                             ; CODE XREF: sub_40D290+1B8j
    mov     dl, [eax-1]
    dec     eax
    dec     ecx
    cmp     eax, edi
    mov     [ecx], dl
    jnz     short loc_40D43F

    loc_40D44A:                             ; CODE XREF: sub_40D290+1ADj
    lea     ecx, [ebx+edi]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_40D460
    mov     esi, [esp+18h+arg_8]

    loc_40D457:                             ; CODE XREF: sub_40D290+1CEj
    mov     dl, [esi]
    mov     [eax], dl
    inc     eax
    cmp     eax, ecx
    jnz     short loc_40D457

    loc_40D460:                             ; CODE XREF: sub_40D290+170j
                                            ; sub_40D290+1C1j
    add     [ebp+8], ebx

    loc_40D463:                             ; CODE XREF: sub_40D290+18Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_40D290 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D470 proc near                    ; CODE XREF: sub_409160+1F0p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    push    ebp
    mov     ebp, [esp+4+arg_0]
    push    esi
    push    edi
    mov     edi, [ecx+8]
    cmp     edx, edi
    mov     esi, ebp
    jz      short loc_40D48E

    loc_40D484:                             ; CODE XREF: sub_40D470+1Cj
    mov     al, [edx]
    mov     [esi], al
    inc     esi
    inc     edx
    cmp     edx, edi
    jnz     short loc_40D484

    loc_40D48E:                             ; CODE XREF: sub_40D470+12j
    mov     edx, [ecx+8]
    mov     [ecx+8], esi
    pop     edi
    mov     eax, ebp
    pop     esi
    mov     [esp+4+arg_0], edx
    pop     ebp
    retn    8
    sub_40D470 endp

    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_39. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_3. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D4C0 proc near                    ; CODE XREF: sub_40C7F0+75p
                                            ; sub_40C7F0+EDp
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_40D4CA
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_40D4CA:                             ; CODE XREF: sub_40D4C0+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_40D4C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_4. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D4F0 proc near                    ; CODE XREF: sub_40C600+BDp
                                            ; sub_40C600+132p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     eax, [esp+arg_8]
    push    esi
    mov     esi, [esp+4+arg_4]
    cmp     ecx, esi
    jz      short loc_40D50F

    loc_40D501:                             ; CODE XREF: sub_40D4F0+1Dj
    test    eax, eax
    jz      short loc_40D509
    mov     dl, [ecx]
    mov     [eax], dl

    loc_40D509:                             ; CODE XREF: sub_40D4F0+13j
    inc     eax
    inc     ecx
    cmp     ecx, esi
    jnz     short loc_40D501

    loc_40D50F:                             ; CODE XREF: sub_40D4F0+Fj
    pop     esi
    retn    0Ch
    sub_40D4F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D520 proc near                    ; CODE XREF: sub_40C600+ACp
                                            ; sub_40C600+149p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    test    eax, eax
    jbe     short locret_40D540
    push    esi
    mov     esi, [esp+4+arg_8]
    mov     ecx, eax
    mov     eax, [esp+4+arg_0]

    loc_40D533:                             ; CODE XREF: sub_40D520+1Dj
    test    eax, eax
    jz      short loc_40D53B
    mov     dl, [esi]
    mov     [eax], dl

    loc_40D53B:                             ; CODE XREF: sub_40D520+15j
    inc     eax
    dec     ecx
    jnz     short loc_40D533
    pop     esi

    locret_40D540:                          ; CODE XREF: sub_40D520+6j
    retn    0Ch
    sub_40D520 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D550 proc near                    ; CODE XREF: sub_40C7F0+9Ap
                                            ; sub_40C7F0+C0p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_40D577
    mov     eax, [esp+arg_8]
    push    esi

    loc_40D561:                             ; CODE XREF: sub_40D550+21j
    test    eax, eax
    jz      short loc_40D569
    mov     esi, [ecx]
    mov     [eax], esi

    loc_40D569:                             ; CODE XREF: sub_40D550+13j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_40D561
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40D577:                             ; CODE XREF: sub_40D550+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_40D550 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D580 proc near                    ; CODE XREF: sub_40C7F0+ACp
                                            ; sub_40C7F0+13Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_4]
    test    ecx, ecx
    jbe     short locret_40D5A0
    mov     edx, [esp+arg_8]
    mov     eax, [esp+arg_0]
    push    esi

    loc_40D591:                             ; CODE XREF: sub_40D580+1Dj
    test    eax, eax
    jz      short loc_40D599
    mov     esi, [edx]
    mov     [eax], esi

    loc_40D599:                             ; CODE XREF: sub_40D580+13j
    add     eax, 4
    dec     ecx
    jnz     short loc_40D591
    pop     esi

    locret_40D5A0:                          ; CODE XREF: sub_40D580+6j
    retn    0Ch
    sub_40D580 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D5B0 proc near                    ; CODE XREF: sub_40A7B0+14Ap
                                            ; sub_40A7B0+1D5p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     edx, [esp+arg_4]
    test    edx, edx
    jbe     short locret_40D5D6
    mov     ecx, [esp+arg_8]
    mov     eax, [esp+arg_0]
    push    esi

    loc_40D5C1:                             ; CODE XREF: sub_40D5B0+23j
    test    eax, eax
    jz      short loc_40D5CF
    mov     esi, [ecx]
    mov     [eax], esi
    mov     esi, [ecx+4]
    mov     [eax+4], esi

    loc_40D5CF:                             ; CODE XREF: sub_40D5B0+13j
    add     eax, 8
    dec     edx
    jnz     short loc_40D5C1
    pop     esi

    locret_40D5D6:                          ; CODE XREF: sub_40D5B0+6j
    retn    0Ch
    sub_40D5B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D5E0 proc near                    ; CODE XREF: sub_40CA50+8Dp
                                            ; sub_40CA50+ACp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short locret_40D5F6
    mov     ecx, [esp+arg_4]
    mov     edx, [ecx]
    mov     [eax], edx
    mov     ecx, [ecx+4]
    mov     [eax+4], ecx

    locret_40D5F6:                          ; CODE XREF: sub_40D5E0+6j
    retn    8
    sub_40D5E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D600 proc near                    ; CODE XREF: sub_40C600+94p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short locret_40D610
    mov     ecx, [esp+arg_4]
    mov     dl, [ecx]
    mov     [eax], dl

    locret_40D610:                          ; CODE XREF: sub_40D600+6j
    retn    8
    sub_40D600 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D620 proc near                    ; CODE XREF: sub_40A260+1B4p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_4]
    push    ebp
    mov     ebp, [esp+4+arg_0]
    sub     ebx, ebp
    push    esi
    sar     ebx, 3
    mov     eax, ebx
    cdq
    sub     eax, edx
    mov     esi, eax
    sar     esi, 1
    test    esi, esi
    jle     short loc_40D663
    push    edi
    lea     edi, [ebp+esi*8+0]

    loc_40D642:                             ; CODE XREF: sub_40D620+40j
    mov     ecx, [edi-8]
    sub     edi, 8
    sub     esp, 8
    dec     esi
    mov     eax, esp
    push    ebx
    push    esi
    mov     [eax], ecx
    mov     edx, [edi+4]
    push    ebp
    mov     [eax+4], edx
    call    sub_40D670
    test    esi, esi
    jg      short loc_40D642
    pop     edi

    loc_40D663:                             ; CODE XREF: sub_40D620+1Bj
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_40D620 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D670 proc near                    ; CODE XREF: sub_40D620+39p
                                            ; sub_40D700+31p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h

    push    ebx
    mov     edx, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_4]
    push    edi
    mov     edi, [esp+8+arg_8]
    lea     ecx, [esi+esi+2]
    mov     ebx, esi
    cmp     ecx, edi
    jge     short loc_40D6BE

    loc_40D689:                             ; CODE XREF: sub_40D670+4Cj
    fld     dword ptr [edx+ecx*8+4]
    fcomp   dword ptr [edx+ecx*8-4]
    fnstsw  ax
    test    ah, 1
    jz      short loc_40D69F
    mov     eax, 1
    jmp     short loc_40D6A1
    ; ---------------------------------------------------------------------------

    loc_40D69F:                             ; CODE XREF: sub_40D670+26j
    xor     eax, eax

    loc_40D6A1:                             ; CODE XREF: sub_40D670+2Dj
    test    al, al
    jz      short loc_40D6A6
    dec     ecx

    loc_40D6A6:                             ; CODE XREF: sub_40D670+33j
    mov     eax, [edx+ecx*8]
    mov     [edx+esi*8], eax
    mov     eax, [edx+ecx*8+4]
    mov     [edx+esi*8+4], eax
    mov     esi, ecx
    lea     ecx, [ecx+ecx+2]
    cmp     ecx, edi
    jl      short loc_40D689

    loc_40D6BE:                             ; CODE XREF: sub_40D670+17j
    cmp     ecx, edi
    jnz     short loc_40D6D4
    mov     eax, [edx+ecx*8-8]
    mov     [edx+esi*8], eax
    mov     eax, [edx+ecx*8-4]
    mov     [edx+esi*8+4], eax
    lea     esi, [ecx-1]

    loc_40D6D4:                             ; CODE XREF: sub_40D670+50j
    mov     ecx, [esp+8+arg_C]
    sub     esp, 8
    mov     eax, esp
    push    ebx
    push    esi
    mov     [eax], ecx
    mov     ecx, [esp+18h+arg_10]
    push    edx
    mov     [eax+4], ecx
    call    sub_40D740
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_40D670 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D700 proc near                    ; CODE XREF: sub_40A260+2B0p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_8]
    sub     esp, 8
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     edx, [esp+8+arg_C]
    mov     ecx, esp
    mov     [ecx], edx
    mov     edx, [esp+8+arg_10]
    mov     [ecx+4], edx
    mov     ecx, [esp+8+arg_4]
    sub     ecx, eax
    sar     ecx, 3
    push    ecx
    push    0
    push    eax
    call    sub_40D670
    retn    18h
    sub_40D700 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D740 proc near                    ; CODE XREF: sub_40D670+79p

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h
    arg_8= dword ptr  18h
    arg_C= dword ptr  1Ch
    arg_10= dword ptr  20h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_4]
    mov     ebx, [esp+arg_8]
    mov     esi, [esp+arg_0]
    lea     eax, [edi-1]
    cdq
    sub     eax, edx
    mov     ecx, eax
    sar     ecx, 1
    cmp     ebx, edi
    jge     short loc_40D797

    loc_40D75D:                             ; CODE XREF: sub_40D740+55j
    fld     dword ptr [esi+ecx*8+4]
    fcomp   [esp+arg_10]
    fnstsw  ax
    test    ah, 1
    jz      short loc_40D773
    mov     eax, 1
    jmp     short loc_40D775
    ; ---------------------------------------------------------------------------

    loc_40D773:                             ; CODE XREF: sub_40D740+2Aj
    xor     eax, eax

    loc_40D775:                             ; CODE XREF: sub_40D740+31j
    test    al, al
    jz      short loc_40D797
    mov     eax, [esi+ecx*8]
    mov     [esi+edi*8], eax
    mov     edx, [esi+ecx*8+4]
    lea     eax, [ecx-1]
    mov     [esi+edi*8+4], edx
    cdq
    sub     eax, edx
    mov     edi, ecx
    sar     eax, 1
    cmp     ebx, edi
    mov     ecx, eax
    jl      short loc_40D75D

    loc_40D797:                             ; CODE XREF: sub_40D740+1Bj
                                            ; sub_40D740+37j
    mov     eax, [esp+arg_C]
    mov     ecx, [esp+arg_10]
    mov     [esi+edi*8], eax
    mov     [esi+edi*8+4], ecx
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_40D740 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D7B0 proc near                    ; CODE XREF: sub_40DA70+1F3p
                                            ; sub_40E160+48p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     edx, [esp+4+arg_0]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [ecx+64h]
    mov     [esp+14h+var_4], ecx
    cmp     edx, [edi+10h]
    jnb     loc_40D869
    mov     ebp, [esp+14h+arg_4]
    mov     eax, [edi+14h]
    cmp     ebp, eax
    jnb     loc_40D869
    movsx   eax, word ptr [edi+4]
    movsx   ecx, word ptr [edi+6]
    mov     ebx, TAdynmemStructPtr
    sar     edx, 1
    mov     esi, [ebx+14233h]
    sar     eax, 2
    add     edx, eax
    mov     eax, ebp
    sar     eax, 1
    sar     ecx, 2
    sar     esi, 1
    add     eax, ecx
    cmp     edx, esi
    jge     short loc_40D869
    mov     ecx, [ebx+14237h]
    sar     ecx, 1
    cmp     eax, ecx
    jge     short loc_40D869
    imul    eax, esi
    mov     ecx, [esp+14h+var_4]
    add     eax, edx
    mov     edx, [ebx+14273h]
    xor     esi, esi
    mov     cl, [ecx+78h]
    mov     si, [edx+eax*2]
    mov     eax, 1
    shl     eax, cl
    test    eax, esi
    jnz     short loc_40D83E
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40D83E:                             ; CODE XREF: sub_40D7B0+7Fj
    mov     eax, [edi+10h]
    mov     edx, ebp
    sar     edx, 4
    imul    eax, edx
    mov     ebx, [esp+14h+arg_0]
    mov     edx, [edi+18h]
    mov     ecx, ebp
    add     eax, ebx
    and     ecx, 0Fh
    mov     eax, [edx+eax*4]
    shl     ecx, 1
    shr     eax, cl
    and     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40D869:                             ; CODE XREF: sub_40D7B0+13j
                                            ; sub_40D7B0+22j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    8
    sub_40D7B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, ds:dword_4FCA10
    mov     [ecx+68h], eax
    mov     edx, ds:dword_4FCA14
    mov     al, 10h
    mov     [ecx+6Ch], edx
    mov     [ecx+76h], al
    mov     [ecx+74h], al
    mov     [ecx+72h], al
    mov     [ecx+70h], al
    mov     al, 16h
    mov     [ecx+77h], al
    mov     [ecx+75h], al
    mov     [ecx+73h], al
    mov     [ecx+71h], al
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [ecx+20h]
    push    esi
    mov     esi, [esp+8]
    cmp     esi, eax
    jnb     short loc_40D8F2
    mov     edx, [esp+0Ch]
    mov     eax, [ecx+24h]
    cmp     edx, eax
    jnb     short loc_40D8F2
    mov     eax, [ecx+20h]
    imul    eax, edx
    mov     edx, [ecx+1Ch]
    add     eax, esi
    mov     byte ptr [edx+eax*4], 4
    mov     ecx, [ecx+2Ch]
    mov     edx, eax
    shr     edx, 8
    lea     edx, [ecx+edx*4]
    mov     ecx, eax
    shr     ecx, 3
    and     ecx, 1Fh
    mov     eax, 1
    shl     eax, cl
    or      [edx], eax

    loc_40D8F2:                             ; CODE XREF: .text:0040D8BAj
                                            ; .text:0040D8C5j
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40D900 proc near                    ; CODE XREF: sub_40E630+5Bp
                                            ; sub_40E9E0+EBp

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    xor     ebp, ebp
    mov     edi, [esi+28h]
    mov     [esp+14h+var_4], esi
    add     edi, 0FFh
    sar     edi, 8
    dec     edi
    test    edi, edi
    jle     short loc_40D969
    xor     ecx, ecx

    loc_40D920:                             ; CODE XREF: sub_40D900+67j
    mov     eax, [esi+2Ch]
    mov     ebx, [eax+ebp*4]
    lea     eax, [eax+ebp*4]
    test    ebx, ebx
    jz      short loc_40D95E
    mov     dword ptr [eax], 0
    mov     edx, [esi+1Ch]
    add     edx, ecx
    test    ebx, ebx
    jz      short loc_40D95E

    loc_40D93C:                             ; CODE XREF: sub_40D900+5Cj
    test    bl, 1
    jz      short loc_40D955
    mov     eax, edx
    mov     esi, 8

    loc_40D948:                             ; CODE XREF: sub_40D900+4Fj
    mov     byte ptr [eax], 0
    add     eax, 4
    dec     esi
    jnz     short loc_40D948
    mov     esi, [esp+14h+var_4]

    loc_40D955:                             ; CODE XREF: sub_40D900+3Fj
    shr     ebx, 1
    add     edx, 20h
    test    ebx, ebx
    jnz     short loc_40D93C

    loc_40D95E:                             ; CODE XREF: sub_40D900+2Bj
                                            ; sub_40D900+3Aj
    inc     ebp
    add     ecx, 400h
    cmp     ebp, edi
    jl      short loc_40D920

    loc_40D969:                             ; CODE XREF: sub_40D900+1Cj
    mov     ecx, [esi+2Ch]
    mov     edx, [ecx+ebp*4]
    lea     eax, [ecx+ebp*4]
    test    edx, edx
    jz      short loc_40D9B9
    mov     ebx, edx
    mov     edx, ebp
    mov     dword ptr [eax], 0
    mov     edi, [esi+1Ch]
    shl     edx, 0Ah
    add     edi, edx
    test    ebx, ebx
    jz      short loc_40D9B9

    loc_40D98C:                             ; CODE XREF: sub_40D900+B7j
    test    bl, 1
    jz      short loc_40D9B0
    mov     eax, ebp
    mov     edx, edi
    shl     eax, 8
    mov     esi, 8

    loc_40D99D:                             ; CODE XREF: sub_40D900+AEj
    mov     ecx, [esp+14h+var_4]
    cmp     eax, [ecx+28h]
    jge     short loc_40D9A9
    mov     byte ptr [edx], 0

    loc_40D9A9:                             ; CODE XREF: sub_40D900+A4j
    inc     eax
    add     edx, 4
    dec     esi
    jnz     short loc_40D99D

    loc_40D9B0:                             ; CODE XREF: sub_40D900+8Fj
    shr     ebx, 1
    add     edi, 20h
    test    ebx, ebx
    jnz     short loc_40D98C

    loc_40D9B9:                             ; CODE XREF: sub_40D900+74j
                                            ; sub_40D900+8Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_40D900 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    test    eax, eax
    jle     short loc_40D9F2
    mov     ecx, [esp+8]
    cmp     ecx, eax
    jnz     short loc_40D9D8
    mov     eax, 5
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40D9D8:                             ; CODE XREF: .text:0040D9CEj
    neg     eax
    cmp     ecx, eax
    jnz     short loc_40D9E6
    mov     eax, 7
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40D9E6:                             ; CODE XREF: .text:0040D9DCj
    test    ecx, ecx
    jnz     short loc_40DA35
    mov     eax, 6
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40D9F2:                             ; CODE XREF: .text:0040D9C6j
    jge     short loc_40DA1E
    mov     ecx, [esp+8]
    cmp     ecx, eax
    jnz     short loc_40DA04
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40DA04:                             ; CODE XREF: .text:0040D9FAj
    neg     eax
    cmp     ecx, eax
    jnz     short loc_40DA12
    mov     eax, 3
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40DA12:                             ; CODE XREF: .text:0040DA08j
    test    ecx, ecx
    jnz     short loc_40DA35
    mov     eax, 2
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40DA1E:                             ; CODE XREF: .text:0040D9F2j
    mov     eax, [esp+8]
    test    eax, eax
    jle     short loc_40DA2E
    mov     eax, 4
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40DA2E:                             ; CODE XREF: .text:0040DA24j
    jge     short loc_40DA35
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_40DA35:                             ; CODE XREF: .text:0040D9E8j
                                            ; .text:0040DA14j ...
    or      eax, 0FFFFFFFFh
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    mov     edx, [esp+8]
    push    esi
    mov     esi, [ecx+50h]
    mov     ecx, [ecx+60h]
    push    edx
    mov     edx, [esp+0Ch]
    mov     eax, [ecx]
    push    edx
    call    dword ptr [eax+1Ch]
    imul    esi
    mov     ecx, 10h
    call    __allshr
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40DA70 proc near                    ; CODE XREF: .text:0040E034p
                                            ; sub_40EB70+328p

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    sub     esp, 18h
    push    ebx
    mov     bl, [eax+1]
    mov     eax, [esp+1Ch+arg_0]
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+28h+arg_8]
    mov     ebp, ecx
    movsx   ecx, word ptr [eax]
    movsx   edx, word ptr [eax+2]
    add     ebx, edi
    mov     eax, [ebp+20h]
    and     ebx, 7
    movsx   esi, ds:byte_4FD670[ebx]
    movsx   edi, ds:byte_4FD678[ebx]
    add     esi, ecx
    add     edi, edx
    cmp     esi, eax
    jnb     loc_40DEF5
    cmp     edi, [ebp+24h]
    jnb     loc_40DEF5
    mov     ecx, [ebp+20h]
    mov     eax, [ebp+1Ch]
    imul    ecx, edi
    add     ecx, esi
    lea     edx, [eax+ecx*4]
    mov     [esp+28h+arg_4], edx
    mov     al, [edx]
    and     eax, 3
    sub     eax, 0
    jz      loc_40DC41
    dec     eax
    jnz     loc_40DEF5
    xor     eax, eax
    mov     edi, [esp+28h+arg_0]
    mov     ax, [edx+2]
    lea     ecx, [eax+eax*4]
    mov     eax, [ebp+0]
    lea     esi, [eax+ecx*4+4]
    mov     ecx, [esp+28h+arg_8]
    xor     eax, eax
    mov     al, [ebp+ecx+68h]
    xor     ecx, ecx
    mov     cl, [ebx+ebp+70h]
    add     eax, ecx
    mov     ecx, [edi+4]
    add     eax, ecx
    movsx   ecx, word ptr [esi+0Ch]
    add     eax, ecx
    mov     ecx, [esp+28h+arg_8]
    test    ecx, ecx
    jz      short loc_40DB24
    cmp     word ptr [edi+0Eh], 5
    jge     short loc_40DB24
    add     eax, 4Bh

    loc_40DB24:                             ; CODE XREF: sub_40DA70+A8j
                                            ; sub_40DA70+AFj
    cmp     eax, [esi+4]
    jge     loc_40DEF5
    mov     [edx+1], bl
    mov     ebx, eax
    sub     ebx, [esi+4]
    mov     [esi+4], eax
    add     [esi+8], ebx
    test    ecx, ecx
    jz      short loc_40DB46
    mov     eax, 1
    jmp     short loc_40DB4B
    ; ---------------------------------------------------------------------------

    loc_40DB46:                             ; CODE XREF: sub_40DA70+CDj
    movsx   eax, word ptr [edi+0Eh]
    inc     eax

    loc_40DB4B:                             ; CODE XREF: sub_40DA70+D4j
    mov     [esi+0Eh], ax
    mov     ecx, [ebp+18h]
    xor     eax, eax
    mov     ax, [edx+2]
    test    ecx, ecx
    jz      loc_40DC26
    mov     ecx, [ebp+0]
    mov     edx, [ebp+4]
    lea     eax, [eax+eax*4]
    mov     esi, [edx]
    mov     ecx, [ecx+eax*4]
    mov     [esp+28h+arg_8], esi
    test    ecx, ecx
    jz      short loc_40DBBC
    mov     edi, [edx+ecx*4]
    lea     eax, [ecx-1]
    sar     eax, 1
    mov     ebx, [edi+0Ch]
    mov     esi, [edx+eax*4]
    cmp     ebx, [esi+0Ch]
    jge     short loc_40DBB8
    mov     [edx+ecx*4], esi
    mov     [esi], ecx
    test    eax, eax
    mov     edx, eax
    jz      short loc_40DBB0

    loc_40DB94:                             ; CODE XREF: sub_40DA70+13Ej
    mov     esi, [ebp+4]
    mov     ebx, [edi+0Ch]
    dec     eax
    sar     eax, 1
    mov     ecx, [esi+eax*4]
    cmp     ebx, [ecx+0Ch]
    jge     short loc_40DBB0
    mov     [esi+edx*4], ecx
    mov     [ecx], edx
    test    eax, eax
    mov     edx, eax
    jnz     short loc_40DB94

    loc_40DBB0:                             ; CODE XREF: sub_40DA70+122j
                                            ; sub_40DA70+133j
    mov     eax, [ebp+4]
    mov     [eax+edx*4], edi
    mov     [edi], edx

    loc_40DBB8:                             ; CODE XREF: sub_40DA70+117j
    mov     esi, [esp+28h+arg_8]

    loc_40DBBC:                             ; CODE XREF: sub_40DA70+104j
    cmp     dword ptr [esi], 0
    jz      loc_40DEF5
    mov     ecx, [ebp+0]
    mov     eax, 66666667h
    sub     esi, ecx
    mov     dword ptr [ebp+18h], 0
    imul    esi
    sar     edx, 3
    mov     eax, edx
    mov     esi, [ebp+8]
    shr     eax, 1Fh
    add     edx, eax
    lea     eax, [edx+edx*4]
    lea     ecx, [ecx+eax*4]
    mov     eax, [ecx]
    mov     [ecx], esi
    mov     esi, [ebp+14h]
    mov     [ebp+8], edx
    dec     esi
    mov     ecx, esi
    mov     [ebp+14h], esi
    cmp     eax, ecx
    jge     loc_40DEF5
    mov     edx, [ebp+4]
    push    eax
    mov     ecx, [edx+ecx*4]
    mov     [edx+eax*4], ecx
    mov     edx, [ebp+4]
    mov     ecx, [edx+eax*4]
    mov     [ecx], eax
    mov     ecx, ebp
    call    sub_40F060
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40DC26:                             ; CODE XREF: sub_40DA70+EAj
    lea     edx, [eax+eax*4]
    mov     eax, [ebp+0]
    mov     ecx, [eax+edx*4]
    push    ecx
    mov     ecx, ebp
    call    sub_40F000
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40DC41:                             ; CODE XREF: sub_40DA70+64j
    mov     eax, [ebp+2Ch]
    mov     edx, ecx
    shr     edx, 8
    shr     ecx, 3
    lea     eax, [eax+edx*4]
    and     ecx, 1Fh
    mov     edx, 1
    push    edi
    shl     edx, cl
    mov     ecx, [eax]
    push    esi
    or      ecx, edx
    mov     [eax], ecx
    mov     ecx, ebp
    call    sub_40D7B0
    cmp     eax, 1
    mov     [esp+28h+var_14], eax
    jnb     short loc_40DC89
    mov     ecx, [esp+28h+arg_4]
    mov     al, [ecx]
    test    al, 8
    jnz     short loc_40DC89
    or      al, 3
    mov     [ecx], al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40DC89:                             ; CODE XREF: sub_40DA70+1FFj
                                            ; sub_40DA70+209j
    mov     ecx, [ebp+60h]
    mov     eax, [ebp+50h]
    push    edi
    push    esi
    mov     edx, [ecx]
    mov     [esp+30h+var_18], eax
    call    dword ptr [edx+1Ch]
    imul    [esp+28h+var_18]
    mov     ecx, 10h
    call    __allshr
    mov     ecx, [ebp+40h]
    mov     [esp+28h+var_18], eax
    cmp     eax, ecx
    mov     eax, [esp+28h+arg_4]
    mov     cl, [eax]
    jg      short loc_40DCC0
    or      cl, 5
    mov     [eax], cl
    jmp     short loc_40DCC9
    ; ---------------------------------------------------------------------------

    loc_40DCC0:                             ; CODE XREF: sub_40DA70+247j
    or      cl, 1
    mov     [eax], cl
    mov     eax, [esp+28h+arg_4]

    loc_40DCC9:                             ; CODE XREF: sub_40DA70+24Ej
    mov     word ptr [esp+28h+var_10], si
    mov     esi, [esp+28h+arg_8]
    test    esi, esi
    mov     [eax+1], bl
    mov     word ptr [esp+28h+var_10+2], di
    jz      short loc_40DCEB
    mov     edx, [esp+28h+arg_0]
    mov     word ptr [esp+28h+var_4+2], 1
    jmp     short loc_40DCFA
    ; ---------------------------------------------------------------------------

    loc_40DCEB:                             ; CODE XREF: sub_40DA70+26Cj
    mov     edx, [esp+28h+arg_0]
    mov     ax, [edx+0Eh]
    inc     ax
    mov     word ptr [esp+28h+var_4+2], ax

    loc_40DCFA:                             ; CODE XREF: sub_40DA70+279j
    mov     eax, [esp+28h+var_14]
    mov     ecx, 1
    cmp     ecx, eax
    sbb     ecx, ecx
    xor     eax, eax
    mov     al, [ebp+esi+68h]
    and     ecx, 0FFFFFFE2h
    mov     edi, eax
    xor     eax, eax
    mov     al, [ebx+ebp+70h]
    add     ecx, 1Eh
    mov     word ptr [esp+28h+var_4], cx
    add     edi, eax
    mov     eax, [edx+4]
    movsx   ecx, cx
    add     edi, eax
    add     edi, ecx
    test    esi, esi
    mov     [esp+28h+var_C], edi
    jz      short loc_40DD42
    cmp     word ptr [edx+0Eh], 5
    jge     short loc_40DD42
    add     edi, 4Bh
    mov     [esp+28h+var_C], edi

    loc_40DD42:                             ; CODE XREF: sub_40DA70+2C2j
                                            ; sub_40DA70+2C9j
    mov     edx, [esp+28h+var_18]
    mov     ecx, [ebp+18h]
    test    ecx, ecx
    lea     eax, [edi+edx]
    mov     [esp+20h], eax
    jz      short loc_40DDA8
    mov     ecx, [ebp+4]
    push    0
    mov     esi, [ecx]
    mov     ecx, [esp+2Ch+var_10]
    lea     edx, [esi+4]
    mov     [esi+4], ecx
    mov     ecx, ebp
    mov     [edx+4], edi
    mov     [edx+8], eax
    mov     eax, [esp+2Ch+var_4]
    mov     [edx+0Ch], eax
    call    sub_40F060
    mov     ebx, [ebp+0]
    mov     eax, 66666667h
    sub     esi, ebx
    mov     dword ptr [ebp+18h], 0
    imul    esi
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, [esp+28h+arg_4]
    mov     [ecx+2], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40DDA8:                             ; CODE XREF: sub_40DA70+2E2j
    mov     eax, [ebp+10h]
    mov     ecx, [ebp+14h]
    cmp     ecx, eax
    jnz     loc_40DE86
    or      esi, 0FFFFFFFFh
    cmp     eax, 0FFFFFFFFh
    mov     [esp+28h+arg_8], esi
    jle     short loc_40DDD0
    mov     edx, eax
    sar     edx, 1
    lea     eax, [edx+eax+10h]
    mov     [esp+28h+arg_8], eax
    mov     esi, eax

    loc_40DDD0:                             ; CODE XREF: sub_40DA70+350j
    lea     ecx, [esi+esi*4]
    shl     ecx, 2
    push    ecx                             ; int
    call    sub_4B4F10
    mov     ebx, eax
    mov     eax, [ebp+0Ch]
    add     esp, 4
    xor     edx, edx
    test    eax, eax
    jle     short loc_40DE0E
    xor     eax, eax

    loc_40DDEC:                             ; CODE XREF: sub_40DA70+394j
    mov     esi, [ebp+0]
    lea     edi, [ebx+eax]
    add     esi, eax
    mov     ecx, 5
    rep movsd
    mov     ecx, [ebp+0Ch]
    inc     edx
    add     eax, 14h
    cmp     edx, ecx
    jl      short loc_40DDEC
    mov     edi, [esp+28h+var_C]
    mov     esi, [esp+28h+arg_8]

    loc_40DE0E:                             ; CODE XREF: sub_40DA70+378j
    mov     edx, [ebp+0]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    lea     eax, ds:0[esi*4]
    push    eax                             ; int
    call    sub_4B4F10
    mov     [esp+2Ch+arg_0], eax
    mov     eax, [ebp+14h]
    add     esp, 4
    xor     esi, esi
    test    eax, eax
    jle     short loc_40DE69

    loc_40DE37:                             ; CODE XREF: sub_40DA70+3F7j
    mov     ecx, [ebp+4]
    mov     edx, [ebp+0]
    mov     eax, 66666667h
    mov     ecx, [ecx+esi*4]
    sub     ecx, edx
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, [esp+28h+arg_0]
    inc     esi
    lea     ecx, [edx+edx*4]
    lea     edx, [ebx+ecx*4]
    mov     [eax+esi*4-4], edx
    mov     eax, [ebp+14h]
    cmp     esi, eax
    jl      short loc_40DE37

    loc_40DE69:                             ; CODE XREF: sub_40DA70+3C5j
    mov     ecx, [ebp+4]
    push    ecx
    call    sub_4B4F20
    mov     edx, [esp+2Ch+arg_0]
    mov     eax, [esp+2Ch+arg_8]
    add     esp, 4
    mov     [ebp+0], ebx
    mov     [ebp+4], edx
    mov     [ebp+10h], eax

    loc_40DE86:                             ; CODE XREF: sub_40DA70+340j
    mov     ecx, [ebp+14h]
    mov     esi, [ebp+8]
    cmp     esi, 0FFFFFFFFh
    lea     edx, [ecx+1]
    mov     [ebp+14h], edx
    jnz     short loc_40DEA2
    mov     esi, [ebp+0Ch]
    lea     eax, [esi+1]
    mov     [ebp+0Ch], eax
    jmp     short loc_40DEAE
    ; ---------------------------------------------------------------------------

    loc_40DEA2:                             ; CODE XREF: sub_40DA70+425j
    mov     eax, [ebp+0]
    lea     edx, [esi+esi*4]
    mov     edx, [eax+edx*4]
    mov     [ebp+8], edx

    loc_40DEAE:                             ; CODE XREF: sub_40DA70+430j
    mov     edx, [ebp+0]
    mov     ebx, [esp+28h+var_10]
    lea     eax, [esi+esi*4]
    push    ecx
    shl     eax, 2
    lea     edx, [edx+eax+4]
    mov     [edx], ebx
    mov     [edx+4], edi
    mov     edi, [esp+24h]
    mov     [edx+8], edi
    mov     edi, [esp+2Ch+var_4]
    mov     [edx+0Ch], edi
    mov     edx, [ebp+0]
    mov     [edx+eax], ecx
    mov     edx, [ebp+0]
    add     edx, eax
    mov     eax, [ebp+4]
    mov     [eax+ecx*4], edx
    mov     ecx, ebp
    call    sub_40F000
    mov     ecx, [esp+28h+arg_4]
    mov     edx, esi
    mov     [ecx+2], dx

    loc_40DEF5:                             ; CODE XREF: sub_40DA70+3Bj
                                            ; sub_40DA70+44j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    sub_40DA70 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 10h
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+18h]
    test    eax, eax
    jz      short loc_40DF66
    mov     eax, [esi+4]
    mov     edi, [esi]
    mov     dword ptr [esi+18h], 0
    mov     ecx, [eax]
    mov     eax, 66666667h
    sub     ecx, edi
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    lea     eax, [edx+edx*4]
    lea     ecx, [edi+eax*4]
    mov     edi, [esi+8]
    mov     eax, [ecx]
    mov     [ecx], edi
    mov     edi, [esi+14h]
    mov     [esi+8], edx
    dec     edi
    mov     ecx, edi
    mov     [esi+14h], edi
    cmp     eax, ecx
    jge     short loc_40DF66
    mov     edx, [esi+4]
    push    eax
    mov     ecx, [edx+ecx*4]
    mov     [edx+eax*4], ecx
    mov     edx, [esi+4]
    mov     ecx, [edx+eax*4]
    mov     [ecx], eax
    mov     ecx, esi
    call    sub_40F060

    loc_40DF66:                             ; CODE XREF: .text:0040DF0Dj
                                            ; .text:0040DF4Bj
    mov     eax, [esi+4]
    mov     edx, [eax]
    add     edx, 4
    mov     ecx, [edx]
    mov     [esp+0Ch], ecx
    mov     ecx, [edx+4]
    mov     [esp+10h], ecx
    mov     ecx, [edx+8]
    mov     [esp+14h], ecx
    mov     ecx, [esi+18h]
    mov     edx, [edx+0Ch]
    test    ecx, ecx
    mov     [esp+18h], edx
    jnz     short loc_40DF99
    mov     dword ptr [esi+18h], 1
    jmp     short loc_40DFE7
    ; ---------------------------------------------------------------------------

    loc_40DF99:                             ; CODE XREF: .text:0040DF8Ej
    mov     edi, [esi]
    mov     ecx, [eax]
    sub     ecx, edi
    mov     eax, 66666667h
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    lea     ecx, [edx+edx*4]
    mov     eax, [edi+ecx*4]
    lea     ecx, [edi+ecx*4]
    mov     edi, [esi+8]
    mov     [ecx], edi
    mov     edi, [esi+14h]
    dec     edi
    mov     [esi+8], edx
    mov     ecx, edi
    mov     [esi+14h], edi
    cmp     eax, ecx
    jge     short loc_40DFE7
    mov     edx, [esi+4]
    push    eax
    mov     ecx, [edx+ecx*4]
    mov     [edx+eax*4], ecx
    mov     edx, [esi+4]
    mov     ecx, [edx+eax*4]
    mov     [ecx], eax
    mov     ecx, esi
    call    sub_40F060

    loc_40DFE7:                             ; CODE XREF: .text:0040DF97j
                                            ; .text:0040DFCCj
    movsx   edx, word ptr [esp+0Eh]
    mov     ecx, [esi+20h]
    mov     eax, [esp+0Ch]
    imul    ecx, edx
    movsx   edx, ax
    add     ecx, edx
    mov     edx, [esi+1Ch]
    lea     ebx, [edx+ecx*4]
    mov     cl, [edx+ecx*4]
    test    cl, 4
    jz      short loc_40E018
    mov     [esi+34h], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10h
    retn
    ; ---------------------------------------------------------------------------

    loc_40E018:                             ; CODE XREF: .text:0040E007j
    mov     byte ptr [ebx], 2
    mov     eax, [esi+44h]
    mov     edi, eax
    neg     edi
    cmp     edi, eax
    jg      short loc_40E041

    loc_40E026:                             ; CODE XREF: .text:0040E03Fj
    mov     eax, edi
    lea     ecx, [esp+0Ch]
    and     eax, 7
    push    eax
    push    ebx
    push    ecx
    mov     ecx, esi
    call    sub_40DA70
    mov     eax, [esi+44h]
    inc     edi
    cmp     edi, eax
    jle     short loc_40E026

    loc_40E041:                             ; CODE XREF: .text:0040E024j
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    add     esp, 10h
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40E050 proc near                    ; CODE XREF: sub_40EB70+34Ep

    var_208= dword ptr -208h
    var_200= dword ptr -200h
    var_FE= dword ptr -0FEh

    sub     esp, 208h
    movsx   eax, word ptr [ecx+36h]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [ecx+20h]
    imul    esi, eax
    movsx   eax, word ptr [ecx+34h]
    mov     edx, [ecx+34h]
    add     esi, eax
    mov     eax, [ecx+1Ch]
    push    edi
    mov     [esp+218h+var_208], edx
    mov     di, word ptr [esp+218h+var_208]
    movsx   eax, byte ptr [eax+esi*4+1]
    mov     bx, word ptr [esp+218h+var_208+2]
    mov     [esp+218h+var_200], edx
    mov     edx, 1

    loc_40E08C:                             ; CODE XREF: sub_40E050+94j
    cmp     di, [ecx+30h]
    jnz     short loc_40E098
    cmp     bx, [ecx+32h]
    jz      short loc_40E0E6

    loc_40E098:                             ; CODE XREF: sub_40E050+40j
    mov     ebp, [ecx+20h]
    movsx   esi, bx
    imul    ebp, esi
    movsx   esi, di
    add     ebp, esi
    mov     esi, [ecx+1Ch]
    lea     esi, [esi+ebp*4]
    movsx   esi, byte ptr [esi+1]
    cmp     esi, eax
    jz      short loc_40E0C4
    mov     ebp, [esp+218h+var_208]
    mov     eax, esi
    mov     esi, edx
    and     esi, 3Fh
    inc     edx
    mov     [esp+esi*4+218h+var_200], ebp

    loc_40E0C4:                             ; CODE XREF: sub_40E050+62j
    movsx   si, ds:byte_4FD670[eax]
    sub     di, si
    movsx   si, ds:byte_4FD678[eax]
    sub     bx, si
    mov     word ptr [esp+218h+var_208], di
    mov     word ptr [esp+218h+var_208+2], bx
    jmp     short loc_40E08C
    ; ---------------------------------------------------------------------------

    loc_40E0E6:                             ; CODE XREF: sub_40E050+46j
    mov     esi, [ecx+30h]
    mov     eax, edx
    and     eax, 3Fh
    inc     edx
    cmp     edx, 40h
    mov     ebp, edx
    mov     [esp+eax*4+218h+var_200], esi
    jl      short loc_40E0FF
    mov     ebp, 40h

    loc_40E0FF:                             ; CODE XREF: sub_40E050+A8j
    test    ebp, ebp
    jle     short loc_40E142
    mov     esi, [ecx+64h]
    lea     eax, [esp+218h+var_FE]
    mov     ebx, ebp

    loc_40E10F:                             ; CODE XREF: sub_40E050+F0j
    lea     edi, [edx-1]
    add     eax, 4
    and     edi, 3Fh
    mov     edi, [esp+edi*4+218h+var_200]
    mov     [esp+218h+var_208], edi
    add     edi, edi
    add     di, [esi+4]
    shl     edi, 3
    mov     [eax-6], di
    mov     edi, [esp+218h+var_208+2]
    add     edi, edi
    add     di, [esi+6]
    shl     edi, 3
    mov     [eax-4], di
    dec     edx
    dec     ebx
    jnz     short loc_40E10F

    loc_40E142:                             ; CODE XREF: sub_40E050+B1j
    mov     ecx, [ecx+5Ch]
    lea     edx, [esp+118h]
    push    ebp
    push    edx
    call    sub_44F080
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 208h
    retn
    sub_40E050 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40E160 proc near                    ; CODE XREF: sub_40E630+1AFp

    var_40= dword ptr -40h
    var_3A= byte ptr -3Ah
    var_39= byte ptr -39h
    var_38= dword ptr -38h
    var_32= byte ptr -32h
    var_31= byte ptr -31h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch

    sub     esp, 2Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    movsx   edx, word ptr [esi+32h]
    movsx   eax, word ptr [esi+30h]
    mov     ecx, [esi+60h]
    mov     edi, [esi+50h]
    push    edx
    push    eax
    mov     ebx, [ecx]
    mov     [esp+44h+var_20], eax
    mov     [esp+44h+var_24], edx
    call    dword ptr [ebx+1Ch]
    mov     ecx, eax
    mov     eax, edi
    imul    ecx
    mov     ecx, 10h
    call    __allshr
    movsx   ecx, word ptr [esi+30h]
    mov     edi, eax
    movsx   eax, word ptr [esi+32h]
    push    eax
    push    ecx
    mov     ecx, esi
    mov     [esp+44h+var_28], edi
    call    sub_40D7B0
    cmp     eax, 1
    jnb     short loc_40E1BC
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_40E1BC:                             ; CODE XREF: sub_40E160+50j
                                            ; sub_40E160+13Dj ...
    mov     ecx, [esi+4Ch]
    mov     eax, [esp+3Ch+var_28]
    inc     ecx
    test    eax, eax
    mov     [esi+4Ch], ecx
    jz      loc_40E61E
    mov     eax, [esi+38h]
    mov     ecx, [esp+3Ch+var_20]
    sub     eax, ecx
    jns     short loc_40E1E1
    mov     ebx, 2
    jmp     short loc_40E200
    ; ---------------------------------------------------------------------------

    loc_40E1E1:                             ; CODE XREF: sub_40E160+78j
    test    eax, eax
    jle     short loc_40E1EC
    mov     ebx, 6
    jmp     short loc_40E200
    ; ---------------------------------------------------------------------------

    loc_40E1EC:                             ; CODE XREF: sub_40E160+83j
    mov     edx, [esi+3Ch]
    mov     ebx, [esp+3Ch+var_24]
    sub     edx, ebx
    xor     ebx, ebx
    test    edx, edx
    setle   bl
    dec     ebx
    and     ebx, 4

    loc_40E200:                             ; CODE XREF: sub_40E160+7Fj
                                            ; sub_40E160+8Aj
    movsx   eax, bl
    movsx   edi, ds:byte_4FD670[eax]
    movsx   ebp, ds:byte_4FD678[eax]
    add     edi, ecx
    mov     ecx, [esp+3Ch+var_24]
    add     ebp, ecx
    mov     ecx, esi
    push    ebp
    push    edi
    call    sub_40D7B0
    cmp     eax, 1
    jb      loc_40E2AC
    mov     eax, [esi+20h]
    mov     edx, [esi+2Ch]
    imul    eax, ebp
    add     eax, edi
    mov     [esp+3Ch+var_20], edi
    mov     ecx, eax
    mov     [esp+3Ch+var_24], ebp
    shr     ecx, 8
    lea     ecx, [edx+ecx*4]
    mov     edx, 1
    mov     [esp+38h], ecx
    mov     ecx, eax
    shr     ecx, 3
    and     ecx, 1Fh
    shl     edx, cl
    mov     ecx, [esp+38h]
    or      [ecx], edx
    mov     ecx, [esi+1Ch]
    mov     [ecx+eax*4+1], bl
    mov     dl, [ecx+eax*4]
    lea     eax, [ecx+eax*4]
    or      dl, 8
    mov     cl, dl
    mov     [eax], dl
    test    cl, 4
    jnz     loc_40E61E
    mov     ecx, [esi+60h]
    mov     ebx, [esi+50h]
    push    ebp
    push    edi
    mov     edx, [ecx]
    call    dword ptr [edx+1Ch]
    mov     ecx, eax
    mov     eax, ebx
    imul    ecx
    mov     ecx, 10h
    call    __allshr
    cmp     eax, [esp+44h+var_30]
    jge     loc_40E1BC
    mov     [esp+44h+var_30], eax
    jmp     loc_40E1BC
    ; ---------------------------------------------------------------------------

    loc_40E2AC:                             ; CODE XREF: sub_40E160+C5j
    mov     eax, [esp+3Ch+var_20]
    mov     ecx, [esp+3Ch+var_24]
    add     bl, 2
    mov     [esp+3Ch+var_1C], eax
    and     bl, 7
    mov     [esp+3Ch+var_18], ecx
    mov     [esp+3Ch+var_14], eax
    mov     [esp+3Ch+var_10], ecx
    mov     byte ptr [esp+3Ch+var_2C+2], bl
    mov     dword ptr [esp+38h], 0

    loc_40E2D6:                             ; CODE XREF: sub_40E160+496j
                                            ; sub_40E160+4A0j
    mov     edi, [esi+4Ch]
    mov     al, bl
    sub     al, 3
    sub     bl, 2
    and     al, 7
    and     bl, 7
    mov     byte ptr [esp+3Ch+var_2C+3], al
    mov     ecx, [esp+3Ch+var_18]
    movsx   eax, bl
    mov     edx, [esp+3Ch+var_1C]
    inc     edi
    mov     [esi+4Ch], edi
    movsx   ebp, ds:byte_4FD678[eax]
    movsx   edi, ds:byte_4FD670[eax]
    add     ebp, ecx
    add     edi, edx
    push    ebp
    push    edi
    mov     ecx, esi
    call    sub_40D7B0
    cmp     eax, 1
    jnb     short loc_40E352

    loc_40E318:                             ; CODE XREF: sub_40E160+1F0j
    cmp     bl, byte ptr [esp+3Ch+var_2C+3]
    jz      loc_40E612
    inc     bl
    mov     ecx, [esp+3Ch+var_18]
    and     bl, 7
    mov     edx, [esp+3Ch+var_1C]
    movsx   eax, bl
    movsx   ebp, ds:byte_4FD678[eax]
    movsx   edi, ds:byte_4FD670[eax]
    add     ebp, ecx
    add     edi, edx
    push    ebp
    push    edi
    mov     ecx, esi
    call    sub_40D7B0
    cmp     eax, 1
    jb      short loc_40E318

    loc_40E352:                             ; CODE XREF: sub_40E160+1B6j
    mov     eax, [esp+3Ch+var_14]
    mov     ecx, [esp+3Ch+var_1C]
    cmp     ecx, eax
    jnz     short loc_40E37C
    mov     ecx, [esp+3Ch+var_10]
    mov     eax, [esp+3Ch+var_18]
    cmp     eax, ecx
    jnz     short loc_40E37C
    cmp     bl, byte ptr [esp+3Ch+var_2C+2]
    jnz     short loc_40E37C
    mov     eax, [esp+38h]
    test    eax, eax
    jnz     loc_40E612

    loc_40E37C:                             ; CODE XREF: sub_40E160+1FCj
                                            ; sub_40E160+208j ...
    mov     eax, ebp
    mov     ecx, [esi+2Ch]
    imul    eax, [esi+20h]
    add     eax, edi
    mov     [esp+3Ch+var_1C], edi
    mov     edx, eax
    mov     [esp+3Ch+var_18], ebp
    shr     edx, 8
    mov     dword ptr [esp+38h], 1
    lea     edx, [ecx+edx*4]
    mov     ecx, eax
    shr     ecx, 3
    mov     [esp+34h], edx
    and     ecx, 1Fh
    mov     edx, 1
    shl     edx, cl
    mov     ecx, [esp+34h]
    or      [ecx], edx
    mov     ecx, [esi+1Ch]
    mov     [ecx+eax*4+1], bl
    mov     dl, [ecx+eax*4]
    lea     eax, [ecx+eax*4]
    or      dl, 8
    mov     cl, dl
    mov     [eax], dl
    test    cl, 4
    jnz     loc_40E61E
    mov     eax, [esi+38h]
    mov     ecx, [esp+3Ch+var_20]
    mov     edx, [esp+3Ch+var_24]
    sub     eax, ecx
    mov     ecx, [esi+3Ch]
    sub     ecx, edx
    mov     edx, [esp+3Ch+var_20]
    mov     [esp+34h], ecx
    mov     ecx, edi
    sub     ecx, edx
    mov     edx, [esp+3Ch+var_24]
    mov     [esp+3Ch+var_C], ecx
    mov     ecx, ebp
    sub     ecx, edx
    test    eax, eax
    jge     short loc_40E40F
    mov     edx, [esp+3Ch+var_C]
    neg     eax
    neg     edx
    mov     [esp+3Ch+var_C], edx

    loc_40E40F:                             ; CODE XREF: sub_40E160+2A1j
    mov     edx, [esp+34h]
    test    edx, edx
    jge     short loc_40E41F
    neg     edx
    mov     [esp+34h], edx
    neg     ecx

    loc_40E41F:                             ; CODE XREF: sub_40E160+2B5j
    mov     edx, [esp+3Ch+var_C]
    test    ecx, ecx
    jnz     short loc_40E433
    test    edx, edx
    jle     short loc_40E433
    cmp     edx, eax
    jle     loc_40E605

    loc_40E433:                             ; CODE XREF: sub_40E160+2C5j
                                            ; sub_40E160+2C9j
    cmp     edx, eax
    jnz     short loc_40E445
    test    ecx, ecx
    jle     short loc_40E445
    cmp     ecx, [esp+34h]
    jle     loc_40E605

    loc_40E445:                             ; CODE XREF: sub_40E160+2D5j
                                            ; sub_40E160+2D9j
    mov     ecx, [esi+60h]
    mov     eax, [esi+50h]
    push    ebp
    push    edi
    mov     edx, [ecx]
    mov     [esp+3Ch], eax
    call    dword ptr [edx+1Ch]
    imul    [esp+44h+var_10]
    mov     ecx, 10h
    call    __allshr
    cmp     eax, [esp+44h+var_30]
    jge     short loc_40E46E
    mov     [esp+44h+var_30], eax

    loc_40E46E:                             ; CODE XREF: sub_40E160+308j
    mov     cl, [esp+44h+var_32]
    mov     ebp, [esp+44h+var_18]
    mov     al, cl
    add     cl, 2
    add     al, 3
    and     cl, 7
    and     al, 7
    mov     edi, [esp+44h+var_1C]
    mov     [esp+44h+var_31], al
    mov     al, cl
    mov     [esp+44h+var_32], al
    movsx   eax, al
    movsx   edx, ds:byte_4FD678[eax]
    movsx   ecx, ds:byte_4FD670[eax]
    sub     ebp, edx
    sub     edi, ecx
    push    ebp
    push    edi
    mov     ecx, esi
    call    sub_40D7B0
    cmp     eax, 1
    jnb     short loc_40E4F6

    loc_40E4B3:                             ; CODE XREF: sub_40E160+394j
    mov     al, [esp+44h+var_32]
    mov     cl, [esp+44h+var_31]
    cmp     al, cl
    jz      loc_40E612
    dec     al
    mov     ebp, [esp+44h+var_18]
    and     al, 7
    mov     edi, [esp+44h+var_1C]
    mov     [esp+44h+var_32], al
    movsx   eax, al
    movsx   edx, ds:byte_4FD678[eax]
    movsx   ecx, ds:byte_4FD670[eax]
    sub     ebp, edx
    sub     edi, ecx
    push    ebp
    push    edi
    mov     ecx, esi
    call    sub_40D7B0
    cmp     eax, 1
    jb      short loc_40E4B3

    loc_40E4F6:                             ; CODE XREF: sub_40E160+351j
    mov     eax, [esp+44h+var_1C]
    mov     ecx, [esp+44h+var_24]
    cmp     ecx, eax
    jnz     short loc_40E518
    mov     ecx, [esp+44h+var_18]
    mov     eax, [esp+44h+var_20]
    cmp     eax, ecx
    jnz     short loc_40E518
    cmp     bl, [esp+44h+var_32]
    jz      loc_40E612

    loc_40E518:                             ; CODE XREF: sub_40E160+3A0j
                                            ; sub_40E160+3ACj
    mov     eax, ebp
    mov     ecx, [esi+2Ch]
    imul    eax, [esi+20h]
    add     eax, edi
    mov     [esp+44h+var_1C], edi
    mov     edx, eax
    mov     [esp+44h+var_18], ebp
    shr     edx, 8
    lea     edx, [ecx+edx*4]
    mov     ecx, eax
    shr     ecx, 3
    mov     [esp+44h+var_10], edx
    and     ecx, 1Fh
    mov     edx, 1
    shl     edx, cl
    mov     ecx, [esp+44h+var_10]
    or      [ecx], edx
    mov     ecx, [esi+1Ch]
    mov     dl, [esp+44h+var_32]
    lea     eax, [ecx+eax*4]
    mov     [eax+1], dl
    mov     dl, [eax]
    or      dl, 8
    mov     cl, dl
    mov     [eax], dl
    test    cl, 4
    jnz     loc_40E61E
    mov     eax, [esi+38h]
    mov     ecx, [esp+44h+var_28]
    mov     edx, [esp+44h+var_2C]
    sub     eax, ecx
    mov     ecx, [esi+3Ch]
    sub     ecx, edx
    mov     edx, [esp+44h+var_28]
    mov     [esp+44h+var_10], ecx
    mov     ecx, edi
    sub     ecx, edx
    mov     edx, [esp+44h+var_2C]
    mov     [esp+44h+var_14], ecx
    mov     ecx, ebp
    sub     ecx, edx
    test    eax, eax
    jge     short loc_40E5A5
    mov     edx, [esp+44h+var_14]
    neg     eax
    neg     edx
    mov     [esp+44h+var_14], edx

    loc_40E5A5:                             ; CODE XREF: sub_40E160+437j
    mov     edx, [esp+44h+var_10]
    test    edx, edx
    jge     short loc_40E5B5
    neg     edx
    mov     [esp+44h+var_10], edx
    neg     ecx

    loc_40E5B5:                             ; CODE XREF: sub_40E160+44Bj
    mov     edx, [esp+44h+var_14]
    test    ecx, ecx
    jnz     short loc_40E5C5
    test    edx, edx
    jle     short loc_40E5C5
    cmp     edx, eax
    jle     short loc_40E605

    loc_40E5C5:                             ; CODE XREF: sub_40E160+45Bj
                                            ; sub_40E160+45Fj
    cmp     edx, eax
    jnz     short loc_40E5D3
    test    ecx, ecx
    jle     short loc_40E5D3
    cmp     ecx, [esp+44h+var_10]
    jle     short loc_40E605

    loc_40E5D3:                             ; CODE XREF: sub_40E160+467j
                                            ; sub_40E160+46Bj
    mov     ecx, [esi+60h]
    mov     eax, [esi+50h]
    push    ebp
    push    edi
    mov     edx, [ecx]
    mov     [esp+4Ch+var_10], eax
    call    dword ptr [edx+1Ch]
    imul    [esp+4Ch+var_18]
    mov     ecx, 10h
    call    __allshr
    cmp     eax, [esp+4Ch+var_38]
    jge     loc_40E2D6
    mov     [esp+4Ch+var_38], eax
    jmp     loc_40E2D6
    ; ---------------------------------------------------------------------------

    loc_40E605:                             ; CODE XREF: sub_40E160+2CDj
                                            ; sub_40E160+2DFj ...
    mov     [esp+3Ch+var_20], edi
    mov     [esp+3Ch+var_24], ebp
    jmp     loc_40E1BC
    ; ---------------------------------------------------------------------------

    loc_40E612:                             ; CODE XREF: sub_40E160+1BCj
                                            ; sub_40E160+216j ...
    mov     eax, [esp+3Ch+var_28]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_40E61E:                             ; CODE XREF: sub_40E160+69j
                                            ; sub_40E160+116j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 2Ch
    retn
    sub_40E160 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40E630 proc near                    ; CODE XREF: sub_40EB70+216p

    var_30= dword ptr -30h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    arg_0= dword ptr  4

    sub     esp, 20h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+58h]
    push    eax
    mov     ecx, [eax]
    mov     edx, [ecx+4]
    mov     ecx, [esp+34h+arg_0]
    mov     [esi+64h], edx
    mov     [esi+60h], ecx
    mov     edx, [eax+76h]
    mov     ecx, [esi+64h]
    mov     [esi+30h], edx
    call    sub_440AF0
    mov     eax, ds:dword_4FCA10
    mov     [esi+68h], eax
    mov     ecx, ds:dword_4FCA14
    mov     [esi+6Ch], ecx
    mov     al, 16h
    mov     ecx, esi
    mov     byte ptr [esi+76h], 10h
    mov     byte ptr [esi+74h], 10h
    mov     byte ptr [esi+72h], 10h
    mov     byte ptr [esi+70h], 10h
    mov     [esi+77h], al
    mov     [esi+75h], al
    mov     [esi+73h], al
    mov     [esi+71h], al
    call    sub_40D900
    mov     dl, byte ptr [esp+30h+arg_0]
    mov     ecx, [esi+60h]
    xor     ebp, ebp
    mov     byte ptr [esp+30h+var_20], dl
    mov     [esp+30h+var_1C], ebp
    mov     [esp+30h+var_18], ebp
    mov     [esp+30h+var_14], ebp
    mov     eax, [ecx]
    lea     edx, [esp+30h+var_20]
    push    edx
    call    dword ptr [eax+18h]
    mov     edx, [esp+34h+var_20]
    mov     eax, [esp+34h+var_1C]
    cmp     edx, eax
    mov     ebx, 7FFFFFFFh
    jz      short loc_40E73A

    loc_40E6C4:                             ; CODE XREF: sub_40E630+106j
    movsx   eax, word ptr [edx]
    mov     ecx, [esi+20h]
    movsx   edi, word ptr [edx+2]
    cmp     eax, ecx
    jnb     short loc_40E700
    cmp     edi, [esi+24h]
    jnb     short loc_40E700
    mov     ecx, [esi+20h]
    imul    ecx, edi
    add     ecx, eax
    mov     eax, [esi+1Ch]
    mov     byte ptr [eax+ecx*4], 4
    mov     edi, [esi+2Ch]
    mov     eax, ecx
    shr     eax, 8
    shr     ecx, 3
    lea     eax, [edi+eax*4]
    and     ecx, 1Fh
    mov     edi, 1
    shl     edi, cl
    or      [eax], edi

    loc_40E700:                             ; CODE XREF: sub_40E630+A0j
                                            ; sub_40E630+A5j
    movsx   ecx, word ptr [esi+32h]
    movsx   eax, word ptr [edx+2]
    movsx   edi, word ptr [edx]
    sub     ecx, eax
    movsx   eax, word ptr [esi+30h]
    sub     eax, edi
    mov     ebp, ecx
    imul    eax, eax
    imul    ebp, ecx
    add     eax, ebp
    cmp     eax, ebx
    jge     short loc_40E72D
    mov     [esi+38h], edi
    mov     ebx, eax
    movsx   ecx, word ptr [edx+2]
    mov     [esi+3Ch], ecx

    loc_40E72D:                             ; CODE XREF: sub_40E630+EFj
    mov     eax, [esp+34h+var_1C]
    add     edx, 4
    cmp     edx, eax
    jnz     short loc_40E6C4
    xor     ebp, ebp

    loc_40E73A:                             ; CODE XREF: sub_40E630+92j
    movsx   eax, word ptr [esi+32h]
    mov     ecx, [esi+60h]
    push    eax
    movsx   eax, word ptr [esi+30h]
    mov     edx, [ecx]
    push    eax
    call    dword ptr [edx+14h]
    test    eax, eax
    jz      short loc_40E762
    mov     ecx, [esi+60h]
    push    100h
    call    sub_44CED0
    jmp     loc_40E982
    ; ---------------------------------------------------------------------------

    loc_40E762:                             ; CODE XREF: sub_40E630+11Ej
    movsx   edx, word ptr [esi+32h]
    mov     ecx, [esi+60h]
    mov     edi, [esi+50h]
    push    edx
    movsx   edx, word ptr [esi+30h]
    mov     eax, [ecx]
    push    edx
    call    dword ptr [eax+1Ch]
    imul    edi
    mov     ecx, 10h
    call    __allshr
    mov     ecx, [esi+20h]
    mov     edi, eax
    movsx   eax, word ptr [esi+30h]
    cmp     eax, ecx
    mov     [esp+44h+var_10], edi
    jnb     short loc_40E79D
    movsx   ecx, word ptr [esi+32h]
    cmp     ecx, [esi+24h]
    jb      short loc_40E7DD

    loc_40E79D:                             ; CODE XREF: sub_40E630+162j
    mov     ecx, [esi+60h]
    push    200h
    call    sub_44CED0
    mov     ecx, [esi+5Ch]
    push    ebp
    push    ebp
    call    sub_44F080
    mov     edx, [esi+58h]
    mov     ecx, [esi+64h]
    push    edx
    call    sub_440BE0
    mov     eax, [esp+44h+var_30]
    mov     [esi+58h], ebp
    push    eax
    mov     [esi+64h], ebp
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_40E7DD:                             ; CODE XREF: sub_40E630+16Bj
    mov     ecx, esi
    call    sub_40E160
    cmp     eax, ebp
    mov     [esi+40h], eax
    jnz     loc_40E96C
    mov     ecx, [esi+60h]
    push    100h
    call    sub_44CED0

    loc_40E7FC:                             ; CODE XREF: sub_40E630+34Cj
    mov     ax, [esi+32h]
    mov     cx, [esi+30h]
    movsx   edx, ax
    mov     [esi+14h], ebp
    mov     dword ptr [esi+8], 0FFFFFFFFh
    mov     [esi+0Ch], ebp
    mov     [esi+18h], ebp
    mov     word ptr [esp+44h+var_24+2], ax
    mov     eax, [esi+20h]
    imul    eax, edx
    mov     word ptr [esp+44h+var_24], cx
    mov     edi, 1
    movsx   ecx, cx
    add     eax, ecx
    mov     ecx, [esi+2Ch]
    mov     edx, eax
    mov     word ptr [esp+44h+var_18+2], 64h
    shr     edx, 8
    lea     edx, [ecx+edx*4]
    mov     ecx, eax
    shr     ecx, 3
    mov     ebx, [edx]
    and     ecx, 1Fh
    shl     edi, cl
    or      ebx, edi
    mov     [edx], ebx
    mov     edx, [esi+1Ch]
    lea     ebx, ds:0[eax*4]
    mov     cl, [edx+ebx]
    lea     eax, [edx+ebx]
    or      cl, 1
    mov     [eax], cl
    mov     eax, [esi+58h]
    mov     edx, [esi+1Ch]
    mov     cx, [eax+66h]
    add     ecx, 1000h
    sar     ecx, 0Dh
    and     cl, 7
    mov     [edx+ebx+1], cl
    mov     eax, [esi+18h]
    cmp     eax, ebp
    jz      short loc_40E8CB
    mov     eax, [esi+4]
    mov     edx, [esp+44h+var_24]
    push    ebp
    mov     edi, [eax]
    mov     eax, [esp+48h+var_10]
    lea     ecx, [edi+4]
    mov     [edi+4], edx
    mov     edx, [esp+48h+var_18]
    mov     [ecx+4], ebp
    mov     [ecx+8], eax
    mov     [ecx+0Ch], edx
    mov     ecx, esi
    call    sub_40F060
    mov     eax, [esi]
    mov     [esi+18h], ebp
    sub     edi, eax
    mov     eax, 66666667h
    imul    edi
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    jmp     short loc_40E946
    ; ---------------------------------------------------------------------------

    loc_40E8CB:                             ; CODE XREF: sub_40E630+257j
    mov     ecx, [esi+14h]
    mov     eax, [esi+10h]
    cmp     ecx, eax
    jnz     short loc_40E8DE
    push    0FFFFFFFFh
    mov     ecx, esi
    call    sub_40F110

    loc_40E8DE:                             ; CODE XREF: sub_40E630+2A3j
    mov     ecx, [esi+14h]
    mov     edi, [esi+8]
    cmp     edi, 0FFFFFFFFh
    lea     edx, [ecx+1]
    mov     [esi+14h], edx
    jnz     short loc_40E8FA
    mov     edi, [esi+0Ch]
    lea     eax, [edi+1]
    mov     [esi+0Ch], eax
    jmp     short loc_40E905
    ; ---------------------------------------------------------------------------

    loc_40E8FA:                             ; CODE XREF: sub_40E630+2BDj
    mov     eax, [esi]
    lea     edx, [edi+edi*4]
    mov     edx, [eax+edx*4]
    mov     [esi+8], edx

    loc_40E905:                             ; CODE XREF: sub_40E630+2C8j
    mov     edx, [esi]
    lea     eax, [edi+edi*4]
    shl     eax, 2
    push    ecx
    lea     edx, [edx+eax+4]
    mov     ebp, edx
    mov     edx, [esp+48h+var_24]
    mov     [ebp+0], edx
    xor     edx, edx
    mov     [ebp+4], edx
    mov     edx, [esp+48h+var_10]
    mov     [ebp+8], edx
    mov     edx, [esp+48h+var_18]
    mov     [ebp+0Ch], edx
    mov     edx, [esi]
    mov     [edx+eax], ecx
    mov     edx, [esi]
    add     edx, eax
    mov     eax, [esi+4]
    mov     [eax+ecx*4], edx
    mov     ecx, esi
    call    sub_40F000
    mov     edx, edi

    loc_40E946:                             ; CODE XREF: sub_40E630+299j
    mov     ecx, [esi+1Ch]
    mov     [ecx+ebx+2], dx
    mov     dword ptr [esi+44h], 4

    loc_40E955:                             ; CODE XREF: sub_40E630+36Ej
    mov     edx, [esp+44h+var_30]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_40E96C:                             ; CODE XREF: sub_40E630+1B9j
    mov     ecx, [esi+60h]
    push    200h
    call    sub_44CED0
    cmp     [esi+40h], edi
    jl      loc_40E7FC

    loc_40E982:                             ; CODE XREF: sub_40E630+12Dj
    mov     ecx, [esi+5Ch]
    push    ebp
    push    ebp
    call    sub_44F080
    mov     ecx, [esi+58h]
    push    ecx
    mov     ecx, [esi+64h]
    call    sub_440BE0
    mov     [esi+58h], ebp
    mov     [esi+64h], ebp
    jmp     short loc_40E955
    sub_40E630 endp

    ; ---------------------------------------------------------------------------
    push    esi
    mov     esi, ecx
    mov     eax, [esi+58h]
    mov     ecx, [esi+64h]
    push    eax
    call    sub_440BE0
    xor     eax, eax
    mov     [esi+58h], eax
    mov     [esi+64h], eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40E9C0 proc near                    ; CODE XREF: sub_44F040+15p
                                            ; sub_44F2A0+15p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+5Ch]
    cmp     eax, edx
    jnz     short locret_40E9D9
    xor     eax, eax
    mov     [ecx+58h], eax
    mov     [ecx+5Ch], eax
    mov     [ecx+60h], eax
    mov     [ecx+64h], eax

    locret_40E9D9:                          ; CODE XREF: sub_40E9C0+9j
    retn    4
    sub_40E9C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40E9E0 proc near                    ; CODE XREF: sub_44F6A0+13p
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    xor     ebx, ebx
    push    edi
    mov     [esi], ebx
    mov     [esi+4], ebx
    mov     [esi+10h], ebx
    mov     [esi+14h], ebx
    mov     dword ptr [esi+8], 0FFFFFFFFh
    mov     [esi+0Ch], ebx
    mov     [esi+18h], ebx
    mov     [esi+20h], ebx
    mov     [esi+24h], ebx
    mov     [esi+28h], ebx
    mov     [esi+1Ch], ebx
    mov     eax, TAdynmemStructPtr
    mov     edi, [eax+14237h]
    mov     ebp, [eax+14233h]
    mov     eax, [esi+1Ch]
    mov     [esi+20h], ebp
    push    eax
    mov     [esi+24h], edi
    call    sub_4B4F20
    imul    edi, ebp
    add     edi, 7
    add     esp, 4
    and     edi, 0FFFFFFF8h
    mov     [esi+28h], edi
    jz      short loc_40EA4F
    lea     ecx, ds:0[edi*4]
    push    ecx                             ; int
    call    sub_4B4F10
    add     esp, 4
    jmp     short loc_40EA51
    ; ---------------------------------------------------------------------------

    loc_40EA4F:                             ; CODE XREF: sub_40E9E0+5Bj
    xor     eax, eax

    loc_40EA51:                             ; CODE XREF: sub_40E9E0+6Dj
    mov     [esi+1Ch], eax
    mov     eax, [esi+28h]
    add     eax, 0FFh
    sar     eax, 8
    lea     ebp, ds:0[eax*4]
    push    ebp
    push    offset aAisearchTouche          ; "AISearch touched mapentries"
    call    sub_4D83B0
    lea     ecx, [ebp-1]
    mov     edi, eax
    mov     edx, ecx
    or      eax, 0FFFFFFFFh
    shr     ecx, 2
    mov     [esi+2Ch], edi
    add     esp, 8
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     eax, [esi+2Ch]
    mov     [ebp+eax-4], ebx
    mov     ecx, [esi+28h]
    lea     eax, [ecx-100h]
    cmp     eax, ecx
    jnb     short loc_40EAC9

    loc_40EAA1:                             ; CODE XREF: sub_40E9E0+E7j
    mov     edx, [esi+2Ch]
    mov     ecx, eax
    shr     ecx, 8
    mov     edi, 1
    lea     edx, [edx+ecx*4]
    mov     ecx, eax
    shr     ecx, 3
    mov     ebp, [edx]
    and     ecx, 1Fh
    shl     edi, cl
    or      ebp, edi
    inc     eax
    mov     [edx], ebp
    mov     ecx, [esi+28h]
    cmp     eax, ecx
    jb      short loc_40EAA1

    loc_40EAC9:                             ; CODE XREF: sub_40E9E0+BFj
    mov     ecx, esi
    call    sub_40D900
    mov     [esi+58h], ebx
    mov     dword ptr [esi+48h], 535h
    mov     [esi+4Ch], ebx
    mov     [esi+78h], bl
    mov     [esi+50h], ebx
    mov     dword ptr [esi+54h], 18000h
    xor     edx, edx
    mov     eax, offset dword_5119E8
    lea     ecx, [esi+79h]

    loc_40EAF4:                             ; CODE XREF: sub_40E9E0+13Dj
    mov     edi, [esi+54h]
    add     edx, 14Bh
    mov     [eax], edi
    mov     [ecx+28h], ebx
    mov     edi, TAdynmemStructPtr
    add     eax, 4
    add     ecx, 4
    cmp     eax, offset dword_511A10
    mov     edi, [edi+edx+1A7Fh]
    mov     [ecx-4], edi
    jb      short loc_40EAF4
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_40E9E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40EB30 proc near                    ; CODE XREF: sub_44F6E0+12p
    push    esi
    mov     esi, ecx
    mov     eax, [esi+2Ch]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, [esi+1Ch]
    add     esp, 4
    push    ecx
    call    sub_4B4F20
    mov     edx, [esi]
    add     esp, 4
    push    edx
    call    sub_4B4F20
    mov     eax, [esi+4]
    add     esp, 4
    push    eax
    call    sub_4B4F20
    add     esp, 4
    pop     esi
    retn
    sub_40EB30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_40EB70()
    sub_40EB70 proc near                    ; CODE XREF: UpdateDatePlayers+12p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 18h
    push    ebx
    push    ebp
    mov     ebp, TAdynmemStructPtr
    push    esi
    mov     esi, ecx
    xor     ebx, ebx
    mov     cx, [ebp+TAdynmemStruct.LOS_Radar]
    push    edi
    cmp     cx, bx
    jz      loc_40EF11
    mov     eax, [esi+48h]
    and     ecx, 0FFFFh
    cdq
    idiv    ecx
    mov     [esp+28h+var_18], ebx
    mov     [esp+28h+var_14], eax
    mov     eax, dword_511A38
    inc     eax
    cmp     eax, 96h
    mov     dword_511A38, eax
    jl      short loc_40EC1A
    mov     dword_511A38, ebx
    xor     ecx, ecx

    loc_40EBBF:                             ; CODE XREF: sub_40EB70+A8j
    mov     eax, dword_511A10[ecx]
    xor     edi, edi
    mov     di, [ebp+1434Fh]
    cdq
    idiv    edi
    cmp     eax, 1
    jge     short loc_40EBE6
    mov     eax, [esi+54h]
    lea     eax, [eax+eax*2]
    shl     eax, 1
    mov     dword_5119E8[ecx], eax
    jmp     short loc_40EC0C
    ; ---------------------------------------------------------------------------

    loc_40EBE6:                             ; CODE XREF: sub_40EB70+64j
    cmp     eax, 2
    jge     short loc_40EBF3
    mov     eax, [esi+54h]
    lea     edx, [eax+eax*2]
    jmp     short loc_40EC06
    ; ---------------------------------------------------------------------------

    loc_40EBF3:                             ; CODE XREF: sub_40EB70+79j
    cmp     eax, 3
    jge     short loc_40EC03
    mov     eax, [esi+54h]
    mov     dword_5119E8[ecx], eax
    jmp     short loc_40EC0C
    ; ---------------------------------------------------------------------------

    loc_40EC03:                             ; CODE XREF: sub_40EB70+86j
    mov     edx, [esi+54h]

    loc_40EC06:                             ; CODE XREF: sub_40EB70+81j
    mov     dword_5119E8[ecx], edx

    loc_40EC0C:                             ; CODE XREF: sub_40EB70+74j
                                            ; sub_40EB70+91j
    mov     dword_511A10[ecx], ebx
    add     ecx, 4
    cmp     ecx, 28h
    jl      short loc_40EBBF

    loc_40EC1A:                             ; CODE XREF: sub_40EB70+45j
    xor     edx, edx
    lea     edi, [esi+0A1h]

    loc_40EC22:                             ; CODE XREF: sub_40EB70+115j
    cmp     dl, 0Ah
    jnb     short loc_40EC7E
    mov     eax, edx
    mov     ebx, ebp
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2+TAdynmemStruct.Players]
    xor     ebx, ebx
    cmp     [eax], ebx
    jz      short loc_40EC7E
    mov     cl, [eax+PlayerStruct.PlayerType]
    cmp     cl, Player_LocalHuman
    jz      short loc_40EC5B
    cmp     cl, Player_AI
    jz      short loc_40EC5B
    cmp     cl, Player_RemoteHuman
    jnz     short loc_40EC7E

    loc_40EC5B:                             ; CODE XREF: sub_40EB70+DFj
                                            ; sub_40EB70+E4j
    cmp     [eax+PlayerStruct.PlayerNumber], 10
    jz      short loc_40EC7E
    mov     eax, [esp+28h+var_14]
    mov     ecx, [edi]
    add     ecx, eax
    mov     eax, [esp+28h+var_18]
    add     eax, ecx
    mov     [edi], ecx
    mov     ebp, TAdynmemStructPtr
    mov     [esp+28h+var_18], eax

    loc_40EC7E:                             ; CODE XREF: sub_40EB70+B5j
                                            ; sub_40EB70+D7j ...
    inc     edx
    add     edi, 4
    cmp     edx, 0Ah
    jl      short loc_40EC22
    cmp     [esp+28h+var_18], ebx
    jle     loc_40EF11

    loc_40EC91:                             ; CODE XREF: sub_40EB70+39Bj
    mov     eax, [esi+58h]
    mov     [esi+4Ch], ebx
    cmp     eax, ebx
    jnz     loc_40ED90
    mov     al, [esi+78h]
    mov     dword ptr [esi+4Ch], 1
    mov     edx, eax
    and     edx, 0FFh
    cmp     [esi+edx*4+0A1h], ebx
    jg      short loc_40ECDA

    loc_40ECBA:                             ; CODE XREF: sub_40EB70+168j
    inc     al
    cmp     al, 0Ah
    mov     [esi+78h], al
    jb      short loc_40ECC6
    mov     [esi+78h], bl

    loc_40ECC6:                             ; CODE XREF: sub_40EB70+151j
    mov     al, [esi+78h]
    mov     ecx, eax
    and     ecx, 0FFh
    cmp     [esi+ecx*4+0A1h], ebx
    jle     short loc_40ECBA

    loc_40ECDA:                             ; CODE XREF: sub_40EB70+148j
    xor     eax, eax
    mov     al, [esi+78h]
    mov     ecx, eax
    shl     ecx, 5
    mov     ebp, dword_511A10[eax*4]
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    add     ecx, eax
    inc     ebp
    mov     dword_511A10[eax*4], ebp
    lea     ecx, [ecx+edx*2+TAdynmemStruct.Players]
    xor     edx, edx
    mov     dl, [esi+78h]
    mov     edi, [ecx+PlayerStruct.Units_End]
    lea     eax, [esi+edx*4+79h]
    mov     edx, [esi+edx*4+79h]
    cmp     edx, edi
    jnz     short loc_40ED22
    mov     ecx, [ecx+67h]
    mov     [eax], ecx
    jmp     short loc_40ED2A
    ; ---------------------------------------------------------------------------

    loc_40ED22:                             ; CODE XREF: sub_40EB70+1A9j
    add     edx, 118h
    mov     [eax], edx

    loc_40ED2A:                             ; CODE XREF: sub_40EB70+1B0j
    xor     edx, edx
    mov     dl, [esi+78h]
    mov     edi, [esi+edx*4+79h]
    cmp     [edi+0A6h], bx
    jz      loc_40EEE5
    mov     eax, [edi]
    cmp     eax, ebx
    jz      loc_40EEE5
    cmp     [eax+4], ebx
    jz      loc_40EEE5
    mov     ecx, [eax]
    mov     eax, [ecx]
    call    dword ptr [eax+18h]
    cmp     eax, ebx
    mov     [esi+5Ch], eax
    jz      loc_40EEE5
    mov     edx, [esi+4Ch]
    xor     ecx, ecx
    mov     cl, [esi+78h]
    add     edx, 64h
    mov     [esi+58h], edi
    mov     [esi+4Ch], edx
    mov     edx, dword_5119E8[ecx*4]
    mov     ecx, esi
    mov     [esi+50h], edx
    mov     eax, [eax+4]
    push    eax
    call    sub_40E630
    jmp     loc_40EEE5
    ; ---------------------------------------------------------------------------

    loc_40ED90:                             ; CODE XREF: sub_40EB70+129j
    mov     ecx, [esi+14h]
    mov     eax, [esi+18h]
    sub     ecx, eax
    jz      loc_40EEC9

    loc_40ED9E:                             ; CODE XREF: sub_40EB70+344j
    mov     eax, [esi+18h]
    mov     edx, [esi+14h]
    sub     edx, eax
    jz      loc_40EEE5
    mov     edx, [esi+4Ch]
    inc     edx
    cmp     eax, ebx
    mov     [esi+4Ch], edx
    jz      short loc_40EE08
    mov     eax, [esi+4]
    mov     edi, [esi]
    mov     [esi+18h], ebx
    mov     ecx, [eax]
    mov     eax, 66666667h
    sub     ecx, edi
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, esi
    push    edx
    lea     eax, [edx+edx*4]
    mov     edi, [edi+eax*4]
    call    sub_40F1E0
    mov     edx, [esi+14h]
    dec     edx
    mov     eax, edx
    mov     [esi+14h], edx
    cmp     edi, eax
    jge     short loc_40EE08
    mov     ecx, [esi+4]
    push    edi
    mov     edx, [ecx+eax*4]
    mov     [ecx+edi*4], edx
    mov     eax, [esi+4]
    mov     ecx, [eax+edi*4]
    mov     [ecx], edi
    mov     ecx, esi
    call    sub_40F060

    loc_40EE08:                             ; CODE XREF: sub_40EB70+245j
                                            ; sub_40EB70+27Dj
    mov     eax, [esi+4]
    mov     edx, [eax]
    add     edx, 4
    mov     ecx, [edx]
    mov     [esp+28h+var_10], ecx
    mov     edi, [edx+4]
    mov     [esp+28h+var_C], edi
    mov     edi, [edx+8]
    mov     [esp+28h+var_8], edi
    mov     edx, [edx+0Ch]
    mov     [esp+28h+var_4], edx
    mov     edx, [esi+18h]
    cmp     edx, ebx
    jnz     short loc_40EE3B
    mov     dword ptr [esi+18h], 1
    jmp     short loc_40EE5E
    ; ---------------------------------------------------------------------------

    loc_40EE3B:                             ; CODE XREF: sub_40EB70+2C0j
    mov     ecx, [eax]
    mov     eax, [esi]
    sub     ecx, eax
    mov     eax, 66666667h
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    mov     ecx, esi
    shr     eax, 1Fh
    add     edx, eax
    push    edx
    call    sub_40EF20
    mov     ecx, [esp+28h+var_10]

    loc_40EE5E:                             ; CODE XREF: sub_40EB70+2C9j
    movsx   edx, word ptr [esp+28h+var_10+2]
    mov     eax, [esi+20h]
    imul    eax, edx
    movsx   edx, cx
    add     eax, edx
    mov     edx, [esi+1Ch]
    lea     ebp, [edx+eax*4]
    mov     al, [edx+eax*4]
    test    al, 4
    jnz     short loc_40EEB9
    mov     byte ptr [ebp+0], 2
    mov     eax, [esi+44h]
    mov     edi, eax
    neg     edi
    cmp     edi, eax
    jg      short loc_40EEA5

    loc_40EE8A:                             ; CODE XREF: sub_40EB70+333j
    mov     eax, edi
    lea     ecx, [esp+28h+var_10]
    and     eax, 7
    push    eax
    push    ebp
    push    ecx
    mov     ecx, esi
    call    sub_40DA70
    mov     eax, [esi+44h]
    inc     edi
    cmp     edi, eax
    jle     short loc_40EE8A

    loc_40EEA5:                             ; CODE XREF: sub_40EB70+318j
    mov     eax, [esi+4Ch]
    mov     dword ptr [esi+44h], 2
    cmp     eax, 64h
    jge     short loc_40EEE5
    jmp     loc_40ED9E
    ; ---------------------------------------------------------------------------

    loc_40EEB9:                             ; CODE XREF: sub_40EB70+309j
    mov     [esi+34h], ecx
    mov     ecx, esi
    call    sub_40E050
    mov     edx, [esi+58h]
    push    edx
    jmp     short loc_40EED7
    ; ---------------------------------------------------------------------------

    loc_40EEC9:                             ; CODE XREF: sub_40EB70+228j
    mov     ecx, [esi+5Ch]
    push    ebx
    push    ebx
    call    sub_44F080
    mov     eax, [esi+58h]
    push    eax

    loc_40EED7:                             ; CODE XREF: sub_40EB70+357j
    mov     ecx, [esi+64h]
    call    sub_440BE0
    mov     [esi+58h], ebx
    mov     [esi+64h], ebx

    loc_40EEE5:                             ; CODE XREF: sub_40EB70+1CAj
                                            ; sub_40EB70+1D4j ...
    mov     eax, [esi+4Ch]
    mov     edi, [esp+28h+var_18]
    xor     ecx, ecx
    sub     edi, eax
    mov     cl, [esi+78h]
    mov     [esp+28h+var_18], edi
    mov     edx, [esi+ecx*4+0A1h]
    lea     ecx, [esi+ecx*4+0A1h]
    sub     edx, eax
    cmp     edi, ebx
    mov     [ecx], edx
    jg      loc_40EC91

    loc_40EF11:                             ; CODE XREF: sub_40EB70+1Bj
                                            ; sub_40EB70+11Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn
    sub_40EB70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40EF20 proc near                    ; CODE XREF: sub_40EB70+2E5p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    sub     esp, 8
    push    esi
    mov     esi, [ecx]
    lea     eax, [edx+edx*4]
    push    edi
    mov     edi, [ecx+8]
    lea     esi, [esi+eax*4]
    mov     eax, [esi]
    mov     [esi], edi
    mov     esi, [ecx+14h]
    mov     [ecx+8], edx
    dec     esi
    mov     edi, esi
    mov     [ecx+14h], esi
    cmp     eax, edi
    jge     loc_40EFF7
    mov     esi, [ecx+4]
    lea     edx, ds:0[eax*4]
    push    ebp
    push    ebx
    mov     edi, [esi+edi*4]
    mov     [edx+esi], edi
    mov     esi, [ecx+4]
    mov     esi, [esi+edx]
    mov     [esi], eax
    mov     esi, [ecx+4]
    mov     edx, [esi+edx]
    mov     [esp+18h+arg_0], edx

    loc_40EF70:                             ; CODE XREF: sub_40EF20+90j
                                            ; sub_40EF20+A2j ...
    mov     edx, [ecx+14h]
    lea     ebx, [eax+eax+2]
    cmp     ebx, edx
    lea     esi, [eax+eax+1]
    mov     [esp+18h+var_4], ebx
    jge     short loc_40EFC4
    mov     edx, [ecx+4]
    mov     edi, [edx+esi*4]
    mov     ebx, [edx+ebx*4]
    mov     [esp+18h+var_8], ebx
    mov     ebx, [ebx+0Ch]
    mov     ebp, [edi+0Ch]
    cmp     ebx, ebp
    jge     short loc_40EFB2
    mov     esi, [esp+18h+arg_0]
    cmp     ebx, [esi+0Ch]
    jge     short loc_40EFE9
    mov     esi, [esp+18h+var_8]
    mov     [edx+eax*4], esi
    mov     [esi], eax
    mov     eax, [esp+18h+var_4]
    jmp     short loc_40EF70
    ; ---------------------------------------------------------------------------

    loc_40EFB2:                             ; CODE XREF: sub_40EF20+78j
    mov     ebx, [esp+18h+arg_0]
    cmp     ebp, [ebx+0Ch]
    jge     short loc_40EFE9
    mov     [edx+eax*4], edi
    mov     [edi], eax
    mov     eax, esi
    jmp     short loc_40EF70
    ; ---------------------------------------------------------------------------

    loc_40EFC4:                             ; CODE XREF: sub_40EF20+61j
    cmp     esi, edx
    jge     short loc_40EFE9
    mov     edx, [ecx+4]
    mov     ebp, [esp+18h+arg_0]
    mov     edi, [edx+esi*4]
    mov     ebx, [edi+0Ch]
    cmp     ebx, [ebp+0Ch]
    jge     short loc_40EFE9
    mov     [edx+eax*4], edi
    mov     edx, [ecx+4]
    mov     edx, [edx+esi*4]
    mov     [edx], eax
    mov     eax, esi
    jmp     short loc_40EF70
    ; ---------------------------------------------------------------------------

    loc_40EFE9:                             ; CODE XREF: sub_40EF20+81j
                                            ; sub_40EF20+99j ...
    mov     edx, [ecx+4]
    mov     ecx, [esp+18h+arg_0]
    pop     ebx
    pop     ebp
    mov     [edx+eax*4], ecx
    mov     [ecx], eax

    loc_40EFF7:                             ; CODE XREF: sub_40EF20+26j
    pop     edi
    pop     esi
    add     esp, 8
    retn    4
    sub_40EF20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40F000 proc near                    ; CODE XREF: sub_40DA70+1C2p
                                            ; sub_40DA70+476p ...

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    test    edx, edx
    push    edi
    jz      short loc_40F051
    mov     esi, [ecx+4]
    lea     eax, [edx-1]
    sar     eax, 1
    mov     ebx, [esi+edx*4]
    mov     edi, [esi+eax*4]
    mov     ebp, [ebx+0Ch]
    cmp     ebp, [edi+0Ch]
    jge     short loc_40F051
    mov     [esi+edx*4], edi
    mov     [edi], edx
    test    eax, eax
    mov     esi, eax
    jz      short loc_40F049

    loc_40F02D:                             ; CODE XREF: sub_40F000+47j
    mov     edi, [ecx+4]
    mov     ebp, [ebx+0Ch]
    dec     eax
    sar     eax, 1
    mov     edx, [edi+eax*4]
    cmp     ebp, [edx+0Ch]
    jge     short loc_40F049
    mov     [edi+esi*4], edx
    mov     [edx], esi
    test    eax, eax
    mov     esi, eax
    jnz     short loc_40F02D

    loc_40F049:                             ; CODE XREF: sub_40F000+2Bj
                                            ; sub_40F000+3Cj
    mov     eax, [ecx+4]
    mov     [eax+esi*4], ebx
    mov     [ebx], esi

    loc_40F051:                             ; CODE XREF: sub_40F000+Aj
                                            ; sub_40F000+20j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_40F000 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40F060 proc near                    ; CODE XREF: sub_40DA70+1A7p
                                            ; sub_40DA70+304p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    mov     edx, [ecx+4]
    mov     eax, [esp+8+arg_0]
    push    ebx
    push    ebp
    mov     edx, [edx+eax*4]
    push    esi
    push    edi
    mov     [esp+18h+var_8], ecx
    mov     [esp+18h+arg_0], edx

    loc_40F079:                             ; CODE XREF: sub_40F060+55j
                                            ; sub_40F060+6Bj ...
    mov     edx, [ecx+14h]
    lea     ebx, [eax+eax+2]
    cmp     ebx, edx
    lea     esi, [eax+eax+1]
    mov     [esp+18h+var_4], ebx
    jge     short loc_40F0CD
    mov     edx, [ecx+4]
    mov     edi, [edx+esi*4]
    mov     ebx, [edx+ebx*4]
    mov     ecx, [ebx+0Ch]
    mov     ebp, [edi+0Ch]
    cmp     ecx, ebp
    jge     short loc_40F0B7
    mov     esi, [esp+18h+arg_0]
    cmp     ecx, [esi+0Ch]
    jge     short loc_40F0F2
    mov     ecx, [esp+18h+var_8]
    mov     [edx+eax*4], ebx
    mov     [ebx], eax
    mov     eax, [esp+18h+var_4]
    jmp     short loc_40F079
    ; ---------------------------------------------------------------------------

    loc_40F0B7:                             ; CODE XREF: sub_40F060+3Dj
    mov     ecx, [esp+18h+arg_0]
    cmp     ebp, [ecx+0Ch]
    jge     short loc_40F0F2
    mov     ecx, [esp+18h+var_8]
    mov     [edx+eax*4], edi
    mov     [edi], eax
    mov     eax, esi
    jmp     short loc_40F079
    ; ---------------------------------------------------------------------------

    loc_40F0CD:                             ; CODE XREF: sub_40F060+2Aj
    cmp     esi, edx
    jge     short loc_40F0F6
    mov     edx, [ecx+4]
    mov     ebp, [esp+18h+arg_0]
    mov     edi, [edx+esi*4]
    mov     ebx, [edi+0Ch]
    cmp     ebx, [ebp+0Ch]
    jge     short loc_40F0F6
    mov     [edx+eax*4], edi
    mov     edx, [ecx+4]
    mov     edx, [edx+esi*4]
    mov     [edx], eax
    mov     eax, esi
    jmp     short loc_40F079
    ; ---------------------------------------------------------------------------

    loc_40F0F2:                             ; CODE XREF: sub_40F060+46j
                                            ; sub_40F060+5Ej
    mov     ecx, [esp+18h+var_8]

    loc_40F0F6:                             ; CODE XREF: sub_40F060+6Fj
                                            ; sub_40F060+81j
    mov     edx, [ecx+4]
    mov     ecx, [esp+18h+arg_0]
    pop     edi
    pop     esi
    mov     [edx+eax*4], ecx
    pop     ebp
    mov     [ecx], eax
    pop     ebx
    add     esp, 8
    retn    4
    sub_40F060 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40F110 proc near                    ; CODE XREF: sub_40E630+2A9p

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     eax, [ebx+10h]
    mov     esi, [esp+8+arg_0]
    cmp     esi, eax
    push    edi
    jge     short loc_40F12F
    mov     ecx, eax
    sar     ecx, 1
    lea     edx, [ecx+eax+10h]
    mov     [esp+0Ch+arg_0], edx
    mov     esi, edx

    loc_40F12F:                             ; CODE XREF: sub_40F110+Fj
    lea     eax, [esi+esi*4]
    shl     eax, 2
    push    eax                             ; int
    call    sub_4B4F10
    mov     ebp, eax
    mov     eax, [ebx+0Ch]
    add     esp, 4
    xor     edx, edx
    test    eax, eax
    jle     short loc_40F169
    xor     eax, eax

    loc_40F14B:                             ; CODE XREF: sub_40F110+53j
    mov     esi, [ebx]
    lea     edi, [ebp+eax+0]
    add     esi, eax
    mov     ecx, 5
    rep movsd
    mov     ecx, [ebx+0Ch]
    inc     edx
    add     eax, 14h
    cmp     edx, ecx
    jl      short loc_40F14B
    mov     esi, [esp+0Ch+arg_0]

    loc_40F169:                             ; CODE XREF: sub_40F110+37j
    mov     ecx, [ebx]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    lea     edx, ds:0[esi*4]
    push    edx                             ; int
    call    sub_4B4F10
    mov     edi, eax
    mov     eax, [ebx+14h]
    add     esp, 4
    xor     esi, esi
    test    eax, eax
    jle     short loc_40F1BD

    loc_40F18F:                             ; CODE XREF: sub_40F110+ABj
    mov     eax, [ebx+4]
    mov     edx, [ebx]
    mov     ecx, [eax+esi*4]
    mov     eax, 66666667h
    sub     ecx, edx
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    inc     esi
    lea     edx, [edx+edx*4]
    lea     eax, [ebp+edx*4+0]
    mov     [edi+esi*4-4], eax
    mov     eax, [ebx+14h]
    cmp     esi, eax
    jl      short loc_40F18F

    loc_40F1BD:                             ; CODE XREF: sub_40F110+7Dj
    mov     ecx, [ebx+4]
    push    ecx
    call    sub_4B4F20
    mov     edx, [esp+10h+arg_0]
    add     esp, 4
    mov     [ebx+4], edi
    mov     [ebx], ebp
    pop     edi
    pop     esi
    mov     [ebx+10h], edx
    pop     ebp
    pop     ebx
    retn    4
    sub_40F110 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40F1E0 proc near                    ; CODE XREF: sub_40EB70+26Dp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, [ecx]
    push    edi
    mov     edi, [ecx+8]
    lea     edx, [eax+eax*4]
    mov     [esi+edx*4], edi
    pop     edi
    mov     [ecx+8], eax
    pop     esi
    retn    4
    sub_40F1E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall GameUnit_EndTransport(int,int,int)
    GameUnit_EndTransport proc near

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    push    3
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_40F226
    push    2
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_40F226:                             ; CODE XREF: GameUnit_EndTransport+18j
    push    1                               ; int
    push    1                               ; idTo
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     al, [ecx+2Eh]
    and     al, 3
    cmp     al, 1
    jnz     short loc_40F298
    push    2
    push    esi
    call    sub_43D210
    push    36h                             ; int
    call    sub_4B4F10
    mov     ebx, [esp+8+arg_4]
    add     esp, 4
    test    eax, eax
    jz      short loc_40F266
    lea     ecx, [esi+6Ah]
    push    ecx
    push    ebx
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_40F268
    ; ---------------------------------------------------------------------------

    loc_40F266:                             ; CODE XREF: GameUnit_EndTransport+54j
    xor     edi, edi

    loc_40F268:                             ; CODE XREF: GameUnit_EndTransport+64j
    mov     edx, [esi+92h]
    mov     ecx, edi
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    edi
    mov     ecx, ebx
    call    sub_4388D0
    mov     ecx, [ebx+6]
    mov     eax, [esp+4+arg_8]
    or      al, 0E0h
    or      ecx, eax
    mov     [ebx+6], ecx

    loc_40F298:                             ; CODE XREF: GameUnit_EndTransport+3Aj
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 34h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+3Ch+arg_4]
    mov     eax, [edi+4Ah]
    test    eax, eax
    jz      short loc_40F2C1
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F2C1:                             ; CODE XREF: GameUnit_EndTransport+B0j
    mov     dl, byte ptr [esp+3Ch+arg_8]
    test    dl, 40h
    jz      short loc_40F2D9
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F2D9:                             ; CODE XREF: GameUnit_EndTransport+C8j
    mov     ebp, [esp+3Ch+arg_0]
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ebp+82h]
    mov     esi, [ecx+142B7h]
    cmp     eax, esi
    jnz     loc_40F3CC
    mov     eax, [ecx+1422Bh]
    add     ebp, 6Ah
    cdq
    sub     eax, edx
    sar     eax, 1
    shl     eax, 10h
    mov     [esp+3Ch+var_10], eax
    mov     eax, [ecx+1422Fh]
    cdq
    sub     eax, edx
    lea     ecx, [esp+3Ch+var_10]
    sar     eax, 1
    shl     eax, 10h
    push    ecx
    push    ebp
    mov     [esp+44h+var_8], eax
    call    sub_48A980
    mov     ebx, eax
    push    3200000h
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    3200000h
    push    ebx
    call    sub_4B7123
    add     esp, 8
    lea     edx, [esp+3Ch+var_28]
    neg     eax
    mov     [esp+3Ch+var_20], eax
    push    edx
    lea     eax, [esp+40h+var_4]
    xor     ecx, ecx
    push    ebp
    push    eax
    mov     [esp+48h+var_28], esi
    mov     [esp+48h+var_24], ecx
    call    sub_40F790
    mov     ecx, [eax]
    push    36h                             ; int
    mov     [esp+40h+var_1C], ecx
    mov     edx, [eax+4]
    mov     [esp+40h+var_18], edx
    mov     eax, [eax+8]
    mov     [esp+40h+var_14], eax
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40F39E
    lea     ecx, [esp+3Ch+var_1C]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_40F3A0
    ; ---------------------------------------------------------------------------

    loc_40F39E:                             ; CODE XREF: GameUnit_EndTransport+18Bj
    xor     esi, esi

    loc_40F3A0:                             ; CODE XREF: GameUnit_EndTransport+19Cj
    push    80h
    mov     ecx, esi
    call    sub_44E730
    mov     ecx, [edi+6]
    push    esi
    or      cl, 0E0h
    mov     [edi+6], ecx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F3CC:                             ; CODE XREF: GameUnit_EndTransport+F1j
    xor     eax, eax
    mov     al, [edi+5]
    sub     eax, 0
    jz      loc_40F643
    dec     eax
    jz      short loc_40F412
    dec     eax
    jnz     loc_40F738
    test    dl, 20h
    jz      short loc_40F403
    mov     ecx, [ebp+0]
    push    1
    push    ebp
    call    sub_43D210
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F403:                             ; CODE XREF: GameUnit_EndTransport+1E7j
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F412:                             ; CODE XREF: GameUnit_EndTransport+1DBj
    lea     ebx, [ebp+6Ah]
    push    ebx
    push    ebp
    call    sub_47E2D0
    test    eax, eax
    jz      loc_40F4DB
    mov     ecx, [ebp+9Ah]
    push    1                               ; RunNow
    push    0                               ; CompletedScriptMethodCallback
    push    offset aEndtransport            ; FunctionName
    call    InvokeScript
    push    36h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40F453
    push    ebx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_40F455
    ; ---------------------------------------------------------------------------

    loc_40F453:                             ; CODE XREF: GameUnit_EndTransport+244j
    xor     esi, esi

    loc_40F455:                             ; CODE XREF: GameUnit_EndTransport+251j
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    push    ebx
    mov     dl, [eax+TAdynmemStruct.data12]
    mov     [esp+40h+arg_4], edx
    call    sub_485070
    mov     ecx, [esp+3Ch+arg_4]
    cmp     eax, ecx
    jle     short loc_40F47C
    push    ebx
    call    sub_485070
    jmp     short loc_40F47E
    ; ---------------------------------------------------------------------------

    loc_40F47C:                             ; CODE XREF: GameUnit_EndTransport+272j
    mov     eax, ecx

    loc_40F47E:                             ; CODE XREF: GameUnit_EndTransport+27Aj
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [edx+TAdynmemStruct.data12]
    cmp     eax, ecx
    jg      short loc_40F4A8
    push    ebx
    call    sub_485070
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [edx+1427Fh]
    sub     eax, ecx
    jmp     short loc_40F4AA
    ; ---------------------------------------------------------------------------

    loc_40F4A8:                             ; CODE XREF: GameUnit_EndTransport+28Ej
    xor     eax, eax

    loc_40F4AA:                             ; CODE XREF: GameUnit_EndTransport+2A6j
    push    eax
    mov     ecx, esi
    call    sub_44E6C0
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    push    0                               ; int
    push    1                               ; idTo
    mov     ecx, ebp
    mov     dword ptr [edi+6], 0E0h
    call    sub_48B090
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F4DB:                             ; CODE XREF: GameUnit_EndTransport+21Ej
    mov     esi, 40h
    mov     edi, 81h
    mov     [esp+3Ch+arg_0], esi

    loc_40F4E9:                             ; CODE XREF: GameUnit_EndTransport+39Dj
    lea     eax, [ebp+6Ah]
    push    edi                             ; int
    mov     ecx, [eax]
    mov     [esp+40h+var_28], ecx
    mov     edx, [eax+4]
    mov     [esp+40h+var_24], edx
    mov     eax, [eax+8]
    mov     [esp+40h+var_20], eax
    call    GetRandom
    sub     eax, esi
    push    edi                             ; int
    mov     ecx, [esp+40h+var_28]
    shl     eax, 10h
    add     ecx, eax
    mov     [esp+40h+var_28], ecx
    call    GetRandom
    mov     ecx, eax
    mov     eax, [esp+3Ch+var_20]
    sub     ecx, esi
    shl     ecx, 10h
    add     eax, ecx
    mov     ecx, [ebp+7Eh]
    movsx   edx, cx
    mov     [esp+3Ch+var_2C], ecx
    mov     ecx, edx
    shl     ecx, 13h
    mov     esi, ecx
    mov     ecx, [esp+3Ch+var_28]
    sub     ecx, esi
    movsx   esi, word ptr [esp+3Ch+var_2C+2]
    mov     ebx, esi
    add     ecx, 80000h
    shl     ebx, 13h
    sar     ecx, 14h
    sub     eax, ebx
    movsx   ecx, cx
    add     eax, 80000h
    sar     eax, 14h
    lea     edx, [edx+ecx*2]
    movsx   eax, ax
    shl     edx, 13h
    mov     [esp+3Ch+var_28], edx
    lea     ecx, [esi+eax*2]
    lea     edx, [esp+3Ch+var_28]
    shl     ecx, 13h
    push    edx
    push    ebp
    mov     [esp+44h+var_20], ecx
    call    sub_47E2D0
    test    eax, eax
    jnz     loc_40F747
    mov     esi, [esp+3Ch+arg_0]
    add     edi, 20h
    add     esi, 10h
    cmp     edi, 201h
    mov     [esp+3Ch+arg_0], esi
    jl      loc_40F4E9
    mov     al, byte ptr [esp+3Ch+arg_8]
    mov     esi, [esp+3Ch+arg_4]
    mov     ebx, 0E0h
    test    bl, al
    jz      short loc_40F5BB
    add     dword ptr [esi+36h], 0FFFFAAABh

    loc_40F5BB:                             ; CODE XREF: GameUnit_EndTransport+3B2j
    mov     bp, [esi+36h]
    push    0A00000h
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     edi, eax
    neg     edi
    push    0A00000h
    push    ebp
    call    sub_4B7123
    mov     ecx, [esi+22h]
    mov     edx, [esi+2Ah]
    add     esp, 8
    add     ecx, edi
    mov     edi, [esi+26h]
    mov     [esp+3Ch+var_1C], ecx
    neg     eax
    add     edx, eax
    push    36h                             ; int
    mov     [esp+40h+var_18], edi
    mov     [esp+40h+var_14], edx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40F619
    lea     edx, [esp+3Ch+var_1C]
    mov     ecx, eax
    push    edx
    push    esi
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_40F61B
    ; ---------------------------------------------------------------------------

    loc_40F619:                             ; CODE XREF: GameUnit_EndTransport+406j
    xor     edi, edi

    loc_40F61B:                             ; CODE XREF: GameUnit_EndTransport+417j
    push    40h
    mov     ecx, edi
    call    sub_44E730
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     eax, [esi+6]
    or      eax, ebx
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F643:                             ; CODE XREF: GameUnit_EndTransport+1D4j
    cmp     dword ptr [ebp+0], 0
    jz      loc_40F738
    mov     eax, [ebp+92h]
    mov     ecx, [eax+241h]
    test    ch, 8
    jz      loc_40F738
    mov     eax, [edi+22h]
    test    eax, eax
    jnz     short loc_40F68C
    mov     eax, [edi+2Ah]
    test    eax, eax
    jnz     short loc_40F68C
    mov     eax, [edi+26h]
    test    eax, eax
    jnz     short loc_40F68C
    lea     ecx, [ebp+6Ah]
    mov     edx, [ebp+6Ah]
    mov     [edi+22h], edx
    mov     eax, [ecx+4]
    mov     [edi+26h], eax
    mov     ecx, [ecx+8]
    mov     [edi+2Ah], ecx

    loc_40F68C:                             ; CODE XREF: GameUnit_EndTransport+467j
                                            ; GameUnit_EndTransport+46Ej ...
    push    10000h                          ; int
    call    GetRandom
    mov     [edi+36h], eax
    and     eax, 1
    push    3
    mov     ecx, ebp
    mov     [edi+3Ah], eax
    call    sub_4898B0
    mov     eax, [ebp+86h]
    test    eax, eax
    jz      short loc_40F6BE
    push    2
    push    0FFFFFFFFh
    push    0
    push    ebp
    call    sub_48AAC0

    loc_40F6BE:                             ; CODE XREF: GameUnit_EndTransport+4B0j
    push    1                               ; int
    push    1                               ; idTo
    mov     ecx, ebp
    call    sub_48B090
    mov     ecx, [ebp+0]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     short loc_40F729
    push    2
    push    ebp
    call    sub_43D210
    push    36h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40F6FD
    lea     ecx, [ebp+6Ah]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_40F6FF
    ; ---------------------------------------------------------------------------

    loc_40F6FD:                             ; CODE XREF: GameUnit_EndTransport+4EBj
    xor     esi, esi

    loc_40F6FF:                             ; CODE XREF: GameUnit_EndTransport+4FBj
    mov     edx, [ebp+92h]
    mov     ecx, esi
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax

    loc_40F729:                             ; CODE XREF: GameUnit_EndTransport+4D5j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    GameUnit_EndTransport endp

    ; ---------------------------------------------------------------------------

    loc_40F738:                             ; CODE XREF: GameUnit_EndTransport+1DEj
                                            ; GameUnit_EndTransport+447j ...
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F747:                             ; CODE XREF: GameUnit_EndTransport+383j
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40F768
    mov     esi, [esp+4Ch]
    lea     ecx, [esp+14h]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    jmp     short loc_40F76E
    ; ---------------------------------------------------------------------------

    loc_40F768:                             ; CODE XREF: .text:0040F753j
    mov     esi, [esp+4Ch]
    xor     eax, eax

    loc_40F76E:                             ; CODE XREF: .text:0040F766j
    push    eax
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 0E0h
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 2
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40F790 proc near                    ; CODE XREF: GameUnit_EndTransport+166p
                                            ; .text:0040FC83p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    push    esi
    mov     esi, [esp+4+arg_4]
    push    edi
    mov     ecx, [eax]
    mov     edi, [eax+4]
    mov     edx, [esi]
    add     ecx, edx
    mov     edx, [esi+4]
    mov     esi, [esi+8]
    add     edx, edi
    mov     edi, [eax+8]
    mov     eax, [esp+8+arg_0]
    add     esi, edi
    mov     edi, eax
    mov     [edi], ecx
    mov     [edi+4], edx
    mov     [edi+8], esi
    pop     edi
    pop     esi
    retn    0Ch
    sub_40F790 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_40F7D0 proc near                    ; DATA XREF: .rdata:004FCA1Co

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    xor     eax, eax
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+18h+arg_4]
    xor     ebp, ebp
    push    edi
    mov     al, [esi+5]
    sub     eax, ebp
    jz      loc_40F9B8
    dec     eax
    jz      loc_40F988
    dec     eax
    jnz     loc_40FA0F
    mov     ebx, [esp+1Ch+arg_0]
    mov     eax, [ebx+92h]
    mov     ecx, [eax+241h]
    test    ch, 8
    jz      loc_40F957
    mov     ecx, [ebx+110h]
    and     ecx, 3
    cmp     cl, 2
    jnz     loc_40F957
    cmp     [ebx+8Ah], ebp
    jz      loc_40F8F9
    push    10000h                          ; int
    call    GetRandom
    movsx   edx, word ptr [esi+2Eh]
    mov     ebx, eax
    push    20h                             ; int
    movsx   eax, word ptr [esi+30h]
    shl     edx, 10h
    shl     eax, 10h
    mov     [esp+20h+var_C], edx
    mov     [esp+20h+var_8], ebp
    mov     [esp+20h+var_4], eax
    call    GetRandom
    mov     edi, eax
    add     edi, 8
    shl     edi, 10h
    push    edi
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     ebp, eax
    neg     ebp
    push    edi
    push    ebx
    call    sub_4B7123
    mov     ecx, [esp+24h+var_C]
    mov     ebx, [esp+24h+var_4]
    add     esp, 8
    add     ecx, ebp
    neg     eax
    add     ebx, eax
    push    36h                             ; int
    mov     [esp+20h+var_C], ecx
    mov     [esp+20h+var_4], ebx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40F8B1
    lea     ecx, [esp+1Ch+var_C]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_40F8B3
    ; ---------------------------------------------------------------------------

    loc_40F8B1:                             ; CODE XREF: sub_40F7D0+CEj
    xor     edi, edi

    loc_40F8B3:                             ; CODE XREF: sub_40F7D0+DFj
    mov     edx, [esp+1Ch+arg_0]
    mov     eax, [edx+92h]
    movsx   ecx, word ptr [eax+21Ch]
    push    ecx
    mov     ecx, edi
    call    sub_44E6C0
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    push    0Fh                             ; int
    call    GetRandom
    add     eax, 1Eh
    mov     ecx, esi
    push    eax
    call    sub_439E80
    mov     byte ptr [esi+5], 1
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F8F9:                             ; CODE XREF: sub_40F7D0+59j
    push    56h                             ; int
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    cmp     edi, ebp
    jz      short loc_40F93F
    push    ebp
    push    ebp
    add     esi, 22h
    push    ebp
    push    esi
    push    ebp
    push    offset aVtol_landifcan          ; char *
    lea     ecx, [esp+34h+arg_4]
    call    sub_438760
    mov     dl, [eax]
    mov     ecx, edi
    push    edx
    call    sub_43A0C0
    push    eax
    push    ebx
    call    sub_43ACB0
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F93F:                             ; CODE XREF: sub_40F7D0+137j
    xor     eax, eax
    push    eax
    push    ebx
    call    sub_43ACB0
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F957:                             ; CODE XREF: sub_40F7D0+3Bj
                                            ; sub_40F7D0+4Dj
    mov     ebx, [esi+6]
    push    1Eh                             ; int
    or      ebx, 10000h
    mov     [esi+6], ebx
    call    GetRandom
    add     eax, 1Eh
    mov     ecx, esi
    push    eax
    call    sub_439E80
    mov     byte ptr [esi+5], 1
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F988:                             ; CODE XREF: sub_40F7D0+1Bj
    mov     edi, [esp+1Ch+arg_0]
    push    edi
    call    sub_43B700
    cmp     eax, ebp
    jz      short loc_40FA00
    push    ebp
    push    eax
    push    edi
    call    sub_43B1F0
    test    eax, eax
    jz      short loc_40FA00
    mov     [esi+6], ebp
    mov     byte ptr [esi+5], 0
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40F9B8:                             ; CODE XREF: sub_40F7D0+14j
    mov     ecx, [esp+1Ch+arg_0]
    cmp     [ecx], ebp
    jz      short loc_40FA0F
    mov     eax, [ecx+92h]
    mov     edx, [eax+241h]
    test    dh, 8
    jz      short loc_40FA0F
    push    3
    call    sub_4898B0
    mov     ecx, [esi+6]
    push    1
    or      ecx, 10000h
    mov     [esi+6], ecx
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+0Eh]
    mov     cx, [eax+6Ch]
    mov     [esi+2Eh], cx
    mov     dx, [eax+74h]
    mov     [esi+30h], dx

    loc_40FA00:                             ; CODE XREF: sub_40F7D0+1C4j
                                            ; sub_40F7D0+1D0j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40FA0F:                             ; CODE XREF: sub_40F7D0+22j
                                            ; sub_40F7D0+1EEj ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_40F7D0 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 0Ch
    xor     eax, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+24h]
    mov     al, [edi+5]
    sub     eax, 0
    jz      loc_40FB0C
    dec     eax
    jz      short loc_40FA67
    dec     eax
    jnz     loc_40FBC4
    mov     eax, [edi+4Ah]
    test    eax, eax
    jnz     short loc_40FA58
    mov     eax, [esp+20h]
    push    0
    push    6
    push    eax
    call    sub_47F780

    loc_40FA58:                             ; CODE XREF: .text:0040FA48j
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40FA67:                             ; CODE XREF: .text:0040FA3Aj
    push    0
    mov     ecx, edi
    call    sub_438880
    push    3
    mov     esi, [esp+24h]
    mov     ecx, esi
    call    sub_489800
    mov     edx, [esi+7Eh]
    lea     esi, [edi+22h]
    mov     ecx, esi
    mov     [esp+20h], edx
    movsx   edx, dx
    mov     eax, [ecx]
    push    36h
    mov     ebx, [ecx+4]
    mov     [esp+18h], ebx
    mov     ebx, edx
    shl     ebx, 13h
    mov     ecx, [ecx+8]
    sub     eax, ebx
    movsx   ebx, word ptr [esp+26h]
    add     eax, 80000h
    mov     ebp, ebx
    sar     eax, 14h
    shl     ebp, 13h
    sub     ecx, ebp
    movsx   eax, ax
    add     ecx, 80000h
    sar     ecx, 14h
    lea     edx, [edx+eax*2]
    movsx   eax, cx
    shl     edx, 13h
    lea     ecx, [ebx+eax*2]
    mov     [esi], edx
    shl     ecx, 13h
    mov     [esi+8], ecx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40FAEC
    push    esi
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    jmp     short loc_40FAEE
    ; ---------------------------------------------------------------------------

    loc_40FAEC:                             ; CODE XREF: .text:0040FADFj
    xor     eax, eax

    loc_40FAEE:                             ; CODE XREF: .text:0040FAEAj
    push    eax
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 0E0h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40FB0C:                             ; CODE XREF: .text:0040FA33j
    mov     esi, [esp+20h]
    cmp     dword ptr [esi], 0
    jz      loc_40FBC4
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    test    ah, 8
    jz      loc_40FBC4
    push    3
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_40FB4D
    push    2
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_40FB4D:                             ; CODE XREF: .text:0040FB3Fj
    push    1
    push    1
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     al, [ecx+2Eh]
    and     al, 3
    cmp     al, 1
    jnz     short loc_40FBB5
    push    2
    push    esi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40FB89
    lea     ecx, [esi+6Ah]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_40FB8B
    ; ---------------------------------------------------------------------------

    loc_40FB89:                             ; CODE XREF: .text:0040FB77j
    xor     ebx, ebx

    loc_40FB8B:                             ; CODE XREF: .text:0040FB87j
    mov     edx, [esi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax

    loc_40FBB5:                             ; CODE XREF: .text:0040FB61j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40FBC4:                             ; CODE XREF: .text:0040FA3Dj
                                            ; .text:0040FB13j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 54h
    push    ebx
    mov     ebx, [esp+60h]
    push    ebp
    push    esi
    mov     eax, [ebx+16h]
    push    edi
    test    eax, eax
    jz      loc_410341
    mov     dl, [esp+70h]
    test    dl, 48h
    jnz     loc_410341
    mov     esi, [esp+68h]
    mov     ecx, TAdynmemStructPtr
    mov     edi, [esi+82h]
    mov     ebp, [ecx+142B7h]
    cmp     edi, ebp
    jnz     loc_40FCE9
    mov     eax, [ecx+1422Bh]
    add     esi, 6Ah
    cdq
    sub     eax, edx
    sar     eax, 1
    shl     eax, 10h
    mov     [esp+40h], eax
    mov     eax, [ecx+1422Fh]
    cdq
    sub     eax, edx
    sar     eax, 1
    shl     eax, 10h
    mov     [esp+48h], eax
    lea     eax, [esp+40h]
    push    eax
    push    esi
    call    sub_48A980
    mov     ecx, 3200000h
    push    ecx
    lea     ecx, [esp+50h]
    push    eax
    push    ecx
    call    sub_4103A0
    mov     edx, [eax]
    mov     [esp+28h], edx
    mov     ecx, [eax+4]
    mov     [esp+2Ch], ecx
    lea     ecx, [esp+58h]
    mov     edx, [eax+8]
    lea     eax, [esp+28h]
    push    eax
    push    esi
    push    ecx
    mov     [esp+3Ch], edx
    call    sub_40F790
    mov     edx, [eax]
    push    36h
    mov     [esp+38h], edx
    mov     ecx, [eax+4]
    mov     [esp+3Ch], ecx
    mov     edx, [eax+8]
    mov     [esp+40h], edx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_40FCBB
    lea     ecx, [esp+34h]
    push    ecx
    push    ebx
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_40FCBD
    ; ---------------------------------------------------------------------------

    loc_40FCBB:                             ; CODE XREF: .text:0040FCA8j
    xor     esi, esi

    loc_40FCBD:                             ; CODE XREF: .text:0040FCB9j
    push    80h
    mov     ecx, esi
    call    sub_44E730
    mov     ecx, [ebx+6]
    push    esi
    or      cl, 0E0h
    mov     [ebx+6], ecx
    mov     ecx, ebx
    call    sub_4388D0
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40FCE9:                             ; CODE XREF: .text:0040FC1Bj
    add     eax, 6Ah
    lea     ecx, [ebx+22h]
    mov     edi, [eax]
    mov     [ecx], edi
    mov     edi, [eax+4]
    mov     [ecx+4], edi
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    xor     eax, eax
    mov     al, [ebx+5]
    sub     eax, 0
    jz      loc_41025D
    dec     eax
    jz      loc_410245
    dec     eax
    jz      short loc_40FD26
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40FD26:                             ; CODE XREF: .text:0040FD15j
    mov     ecx, [ebx+16h]
    mov     eax, [ecx+0F0h]
    test    eax, eax
    mov     [esp+24h], eax
    jz      loc_40FE68
    mov     edi, [esi+96h]
    xor     ecx, ecx
    mov     cl, [edi+146h]
    mov     edi, [eax+96h]
    cmp     byte ptr [edi+ecx+108h], 0
    jnz     loc_40FE68
    test    dl, 10h
    jz      loc_40FE68
    mov     cx, [eax+0A6h]
    mov     edi, [esi+92h]
    and     ecx, 0FFFFh
    mov     ebp, 1
    mov     edi, [edi+23Dh]
    mov     edx, ecx
    and     ecx, 1Fh
    shr     edx, 5
    shl     ebp, cl
    test    [edi+edx*4], ebp
    jnz     loc_40FE68
    push    1
    push    eax
    push    esi
    call    sub_43B1F0
    test    eax, eax
    jz      short loc_40FDBA
    mov     dword ptr [ebx+6], 0
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40FDBA:                             ; CODE XREF: .text:0040FDA2j
    test    dword ptr [esi+110h], 300000h
    jz      loc_40FE68
    lea     ecx, [esi+1Fh]
    mov     byte ptr [esp+1Ch], 0
    xor     ebp, ebp
    mov     [esp+20h], ecx

    loc_40FDD8:                             ; CODE XREF: .text:0040FE62j
    mov     al, [ecx]
    test    al, 2
    jz      short loc_40FE4A
    test    al, 10h
    jz      short loc_40FE4A
    mov     eax, [ecx-0Fh]
    mov     ecx, [eax+111h]
    shr     ecx, 1Ah
    test    cl, 1
    jnz     short loc_40FE4A
    push    ebp
    push    esi
    call    sub_48A190
    mov     edi, eax
    test    edi, edi
    jz      short loc_40FE3E
    mov     edx, [esp+1Ch]
    push    edx
    push    edi
    push    esi
    call    sub_49ABB0
    test    eax, eax
    jz      short loc_40FE3E
    mov     cx, [edi+0A6h]
    mov     eax, [esi+92h]
    and     ecx, 0FFFFh
    mov     edi, 1
    mov     eax, [eax+ebp*4+231h]
    mov     edx, ecx
    and     ecx, 1Fh
    shr     edx, 5
    shl     edi, cl
    test    [eax+edx*4], edi
    jz      short loc_40FE4A

    loc_40FE3E:                             ; CODE XREF: .text:0040FDFEj
                                            ; .text:0040FE0Ej
    mov     ecx, [esp+24h]
    push    ebp
    push    ecx
    push    esi
    call    sub_48A060

    loc_40FE4A:                             ; CODE XREF: .text:0040FDDCj
                                            ; .text:0040FDE0j ...
    mov     al, [esp+1Ch]
    mov     ecx, [esp+20h]
    inc     al
    inc     ebp
    add     ecx, 1Ch
    cmp     al, 3
    mov     [esp+1Ch], al
    mov     [esp+20h], ecx
    jb      loc_40FDD8

    loc_40FE68:                             ; CODE XREF: .text:0040FD35j
                                            ; .text:0040FD57j ...
    mov     edx, [ebx+16h]
    mov     ecx, esi
    push    edx
    call    sub_4899B0
    test    eax, eax
    jz      short loc_40FEDA
    mov     eax, [ebx+16h]
    xor     ebp, ebp
    push    ebp
    push    eax
    push    esi
    lea     ecx, [esp+2Ch]
    push    8
    push    ecx
    call    sub_43F0E0
    mov     al, [esp+20h]
    test    al, al
    jz      short loc_40FEDC
    push    ebp
    mov     ecx, ebx
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      loc_410120
    mov     edx, [ebx+16h]
    mov     ecx, [esp+20h]
    push    ebp
    push    ebp
    push    ebp
    push    ebp
    push    edx
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43ACB0
    mov     [ebx+6], ebp
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_40FEDA:                             ; CODE XREF: .text:0040FE75j
    xor     ebp, ebp

    loc_40FEDC:                             ; CODE XREF: .text:0040FE91j
    mov     edx, [ebx+16h]
    mov     eax, [edx+5Ch]
    cmp     eax, ebp
    jz      loc_41013B
    mov     cl, [eax+4]
    test    cl, cl
    jz      loc_41013B
    mov     ecx, [esi+92h]
    test    byte ptr [ecx+241h], 40h
    jz      loc_41013B
    mov     edx, [eax+16h]
    mov     ecx, esi
    push    edx
    call    sub_4899B0
    test    eax, eax
    jz      loc_41013B
    mov     eax, [ebx+16h]
    mov     ecx, [eax+92h]
    test    byte ptr [ecx+241h], 40h
    jz      loc_41013B
    mov     eax, [eax+5Ch]
    cmp     eax, ebp
    jz      loc_41013B
    test    dword ptr [eax+42h], 100000h
    jz      loc_41013B
    cmp     esi, [eax+16h]
    jz      loc_41013B
    push    offset aMobilebuild_0           ; "MobileBuild"
    lea     ecx, [esp+6Ch]
    call    sub_438760
    mov     edx, [ebx+16h]
    mov     eax, [edx+5Ch]
    mov     dl, [esp+68h]
    mov     cl, [eax+4]
    cmp     cl, dl
    jz      short loc_40FFB3
    push    offset aBuildingbuild           ; "BuildingBuild"
    lea     ecx, [esp+70h]
    call    sub_438760
    mov     eax, [ebx+16h]
    mov     dl, [esp+6Ch]
    mov     eax, [eax+5Ch]
    mov     cl, [eax+4]
    cmp     cl, dl
    jz      short loc_40FFB3
    push    offset aVtol_mobileb_0          ; "VTOL_MobileBuild"
    lea     ecx, [esp+16h]
    call    sub_438760
    mov     ecx, [ebx+16h]
    mov     dl, [esp+12h]
    mov     eax, [ecx+5Ch]
    mov     cl, [eax+4]
    cmp     cl, dl
    jz      short loc_40FFB3
    xor     edi, edi
    jmp     short loc_40FFB8
    ; ---------------------------------------------------------------------------

    loc_40FFB3:                             ; CODE XREF: .text:0040FF6Fj
                                            ; .text:0040FF8Ej ...
    mov     edi, 1

    loc_40FFB8:                             ; CODE XREF: .text:0040FFB1j
    mov     edx, [eax+42h]
    test    dh, 2
    jz      short loc_40FFC5
    cmp     [eax+16h], ebp
    jnz     short loc_40FFCE

    loc_40FFC5:                             ; CODE XREF: .text:0040FFBEj
    test    dh, 4
    jnz     short loc_40FFCE
    xor     edx, edx
    jmp     short loc_40FFD3
    ; ---------------------------------------------------------------------------

    loc_40FFCE:                             ; CODE XREF: .text:0040FFC3j
                                            ; .text:0040FFC8j
    mov     edx, 1

    loc_40FFD3:                             ; CODE XREF: .text:0040FFCCj
    cmp     edi, ebp
    jnz     loc_4100B1
    cmp     edx, ebp
    jz      loc_4100A9
    mov     [esp+70h], cl
    push    offset aRepairunit              ; "REPAIRUNIT"
    lea     ecx, [esp+17h]
    call    sub_438760
    mov     dl, [esp+70h]
    mov     al, [esp+13h]
    cmp     dl, al

    loc_40FFFF:
    jnz     short loc_410015
    push    offset aVtol_repairuni          ; "VTOL_REPAIRUNIT"
    lea     ecx, [esp+1Bh]
    call    sub_438760
    mov     al, [eax]
    mov     [esp+70h], al

    loc_410015:                             ; CODE XREF: .text:0040FFFFj
    push    offset aReclaim                 ; "RECLAIM"
    lea     ecx, [esp+18h]
    call    sub_438760
    mov     cl, [esp+70h]
    mov     al, [esp+14h]
    cmp     cl, al
    jnz     short loc_410043
    push    offset aVtol_reclaim            ; "VTOL_RECLAIM"
    lea     ecx, [esp+1Ch]
    call    sub_438760
    mov     dl, [eax]
    mov     [esp+70h], dl

    loc_410043:                             ; CODE XREF: .text:0041002Dj
    push    offset aReclaimunit             ; "RECLAIMUNIT"
    lea     ecx, [esp+19h]
    call    sub_438760
    mov     al, [esp+70h]
    mov     cl, [esp+15h]
    cmp     al, cl
    jnz     short loc_410071
    push    offset aVtol_reclaimun          ; "VTOL_RECLAIMUNIT"
    lea     ecx, [esp+1Dh]
    call    sub_438760
    mov     cl, [eax]
    mov     [esp+70h], cl

    loc_410071:                             ; CODE XREF: .text:0041005Bj
    push    offset aHelpbuild               ; "HELPBUILD"
    lea     ecx, [esp+1Ah]
    call    sub_438760
    mov     dl, [esp+70h]
    mov     al, [esp+16h]
    cmp     dl, al
    jnz     short loc_41009F
    push    offset aVtol_helpbuild          ; "VTOL_HELPBUILD"
    lea     ecx, [esp+1Eh]
    call    sub_438760
    mov     al, [eax]
    mov     [esp+70h], al

    loc_41009F:                             ; CODE XREF: .text:00410089j
    push    ebp
    mov     ecx, ebx
    call    sub_4388D0
    jmp     short loc_4100D6
    ; ---------------------------------------------------------------------------

    loc_4100A9:                             ; CODE XREF: .text:0040FFDDj
    cmp     edi, ebp
    jz      loc_41013B

    loc_4100B1:                             ; CODE XREF: .text:0040FFD5j
    cmp     [eax+16h], ebp
    jz      loc_41013B
    push    ebp
    mov     ecx, ebx
    call    sub_4388D0
    push    offset aVtol_helpbui_0          ; "VTOL_HelpBuild"
    lea     ecx, [esp+1Fh]
    call    sub_438760
    mov     al, [eax]
    mov     [esp+70h], al

    loc_4100D6:                             ; CODE XREF: .text:004100A7j
    push    56h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_410120
    mov     edx, [ebx+16h]
    push    ebp
    push    ebp
    push    ebp
    mov     ecx, [edx+5Ch]
    mov     edx, [edx+5Ch]
    add     ecx, 22h
    push    ecx
    mov     ecx, [edx+16h]
    mov     edx, [esp+80h]
    push    ecx
    push    edx
    mov     ecx, eax
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43ACB0
    mov     [ebx+6], ebp
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410120:                             ; CODE XREF: .text:0040FEA7j
                                            ; .text:004100E2j
    xor     eax, eax
    push    eax
    push    esi
    call    sub_43ACB0
    mov     [ebx+6], ebp
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41013B:                             ; CODE XREF: .text:0040FEE4j
                                            ; .text:0040FEEFj ...
    test    byte ptr [esp+70h], 0E0h
    jz      short loc_41015B
    push    2000h
    call    GetRandom
    mov     ecx, [ebx+36h]
    neg     eax
    sub     eax, 4000h
    add     ecx, eax
    mov     [ebx+36h], ecx

    loc_41015B:                             ; CODE XREF: .text:00410140j
    mov     eax, [esi+110h]
    mov     bp, [ebx+36h]
    shr     eax, 1Fh
    test    al, 1
    jz      short loc_4101B0
    mov     ecx, [esi+10h]
    mov     esi, [ecx+0DCh]
    add     esi, 0A0h
    shl     esi, 10h
    push    esi
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     edi, eax
    neg     edi
    push    esi
    push    ebp
    call    sub_4B7123
    mov     ecx, [ebx+16h]
    add     esp, 8
    add     ecx, 6Ah
    neg     eax
    mov     ebp, [ecx]
    mov     edx, [ecx+4]
    mov     ecx, [ecx+8]
    add     edi, ebp
    add     ecx, eax
    mov     [esp+28h], edi
    jmp     short loc_4101E8
    ; ---------------------------------------------------------------------------

    loc_4101B0:                             ; CODE XREF: .text:0041016Aj
    push    1400000h
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    1400000h
    push    ebp
    call    sub_4B7123
    mov     ecx, [ebx+16h]
    add     esp, 8
    add     ecx, 6Ah
    neg     eax
    mov     ebp, [ecx]
    mov     edx, [ecx+4]
    mov     ecx, [ecx+8]
    add     esi, ebp
    add     ecx, eax
    mov     [esp+28h], esi

    loc_4101E8:                             ; CODE XREF: .text:004101AEj
    push    36h
    mov     [esp+30h], edx
    mov     [esp+34h], ecx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_41020F
    lea     edx, [esp+28h]
    mov     ecx, eax
    push    edx
    push    ebx
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_410211
    ; ---------------------------------------------------------------------------

    loc_41020F:                             ; CODE XREF: .text:004101FCj
    xor     esi, esi

    loc_410211:                             ; CODE XREF: .text:0041020Dj
    push    80h
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, ebx
    call    sub_4388D0
    push    1Eh
    mov     ecx, ebx
    call    sub_439E80
    mov     eax, [ebx+6]
    or      al, 0F8h
    mov     [ebx+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410245:                             ; CODE XREF: .text:0040FD0Ej
    push    3
    mov     ecx, esi
    call    sub_489800
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41025D:                             ; CODE XREF: .text:0040FD07j
    cmp     dword ptr [esi], 0
    jz      loc_410332
    mov     eax, [esi+92h]
    mov     ecx, [eax+241h]
    test    ch, 8
    jz      loc_410332
    push    offset aGuarding                ; "Guarding"
    mov     ecx, ebx
    call    sub_438880
    push    3
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_4102A6
    push    2
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_4102A6:                             ; CODE XREF: .text:00410298j
    push    1
    push    1
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     short loc_410310
    push    2
    push    esi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4102E4
    lea     ecx, [esi+6Ah]
    push    ecx
    push    ebx
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_4102E6
    ; ---------------------------------------------------------------------------

    loc_4102E4:                             ; CODE XREF: .text:004102D2j
    xor     edi, edi

    loc_4102E6:                             ; CODE XREF: .text:004102E2j
    mov     edx, [esi+92h]
    mov     ecx, edi
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    edi
    mov     ecx, ebx
    call    sub_4388D0
    mov     eax, [ebx+6]
    or      al, 0E0h
    mov     [ebx+6], eax

    loc_410310:                             ; CODE XREF: .text:004102BCj
    push    10000h
    call    GetRandom
    mov     [ebx+36h], eax
    and     eax, 1
    mov     [ebx+3Ah], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410332:                             ; CODE XREF: .text:00410260j
                                            ; .text:00410275j
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410341:                             ; CODE XREF: .text:0040FBF0j
                                            ; .text:0040FBFDj
    mov     eax, [ebx+4Ah]
    test    eax, eax
    jnz     short loc_410389
    push    56h
    call    sub_4B4F10
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jz      short loc_41037C
    mov     ecx, [ebx+16h]
    push    0
    push    0
    lea     eax, [ebx+22h]
    push    0
    push    eax
    push    ecx
    push    ecx
    mov     ecx, esp
    push    offset aVtol_seekguard          ; "VTOL_SEEKGUARD"
    call    sub_438760
    mov     ecx, esi
    call    sub_43A0C0
    jmp     short loc_41037E
    ; ---------------------------------------------------------------------------

    loc_41037C:                             ; CODE XREF: .text:00410356j
    xor     eax, eax

    loc_41037E:                             ; CODE XREF: .text:0041037Aj
    mov     edx, [esp+68h]
    push    eax
    push    edx
    call    sub_43AD10

    loc_410389:                             ; CODE XREF: .text:00410346j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 5
    pop     ebx
    add     esp, 54h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4103A0 proc near                    ; CODE XREF: .text:0040FC5Fp
                                            ; .text:004108CBp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+0Ch+arg_8]
    push    edi
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    edi
    push    ebx
    xor     ebp, ebp
    call    sub_4B7123
    mov     ecx, [esp+14h+arg_0]
    add     esp, 8
    mov     edx, ecx
    neg     eax
    mov     [edx], esi
    pop     edi
    pop     esi
    mov     [edx+4], ebp
    pop     ebp
    pop     ebx
    mov     [edx+8], eax
    mov     eax, ecx
    retn    0Ch
    sub_4103A0 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 34h
    push    ebx
    mov     bl, [esp+44h]
    push    ebp
    push    esi
    test    bl, 40h
    push    edi
    jz      short loc_4103FF
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4103FF:                             ; CODE XREF: .text:004103EEj
    mov     esi, [esp+48h]
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esi+82h]
    mov     edx, [ecx+142B7h]
    cmp     eax, edx
    jnz     loc_4104F6
    mov     eax, [ecx+1422Bh]
    lea     edi, [esi+6Ah]
    cdq
    sub     eax, edx
    sar     eax, 1
    shl     eax, 10h
    mov     [esp+28h], eax
    mov     eax, [ecx+1422Fh]
    cdq
    sub     eax, edx
    lea     ecx, [esp+28h]
    sar     eax, 1
    shl     eax, 10h
    push    ecx
    push    edi
    mov     [esp+38h], eax
    call    sub_48A980
    mov     ebx, eax
    push    3200000h
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    3200000h
    push    ebx
    xor     ebp, ebp
    call    sub_4B7123
    add     esp, 8
    lea     edx, [esp+10h]
    neg     eax
    mov     [esp+18h], eax
    push    edx
    lea     eax, [esp+3Ch]
    push    edi
    push    eax
    mov     [esp+1Ch], esi
    mov     [esp+20h], ebp
    call    sub_40F790
    mov     ecx, [eax]
    push    36h
    mov     [esp+20h], ecx
    mov     edx, [eax+4]
    mov     [esp+24h], edx
    mov     eax, [eax+8]
    mov     [esp+28h], eax
    call    sub_4B4F10
    mov     edi, [esp+50h]
    add     esp, 4
    test    eax, eax
    jz      short loc_4104C8
    lea     ecx, [esp+1Ch]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_4104CA
    ; ---------------------------------------------------------------------------

    loc_4104C8:                             ; CODE XREF: .text:004104B5j
    xor     esi, esi

    loc_4104CA:                             ; CODE XREF: .text:004104C6j
    push    80h
    mov     ecx, esi
    call    sub_44E730
    mov     ecx, [edi+6]
    push    esi
    or      cl, 0E0h
    mov     [edi+6], ecx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4104F6:                             ; CODE XREF: .text:00410417j
    mov     edi, [esp+4Ch]
    xor     eax, eax
    mov     al, [edi+5]
    sub     eax, 0
    jz      loc_410701
    dec     eax
    jnz     loc_41081F
    push    3
    mov     ecx, esi
    call    sub_489800
    mov     eax, [esi+92h]
    movsx   edx, word ptr [esi+108h]
    mov     eax, [eax+1FAh]
    shr     eax, 2
    lea     ecx, [eax+eax*2]
    cmp     edx, ecx
    jnb     loc_4105FA
    lea     ecx, [esp+28h]
    call    sub_410830
    mov     ecx, [esi+96h]
    lea     edx, [esp+28h]
    push    edx
    xor     edx, edx
    mov     dl, [ecx+146h]
    lea     eax, [esi+6Ah]
    push    0F00h
    push    eax
    push    edx
    call    sub_40B530
    lea     ecx, [esp+28h]
    call    sub_40C560
    neg     eax
    sbb     eax, eax
    inc     eax
    test    al, al
    jnz     short loc_4105F1
    push    0
    mov     ecx, edi
    call    sub_4388D0
    mov     ebx, [esp+2Ch]
    test    ebx, ebx
    jnz     short loc_41058B
    xor     eax, eax
    jmp     short loc_410594
    ; ---------------------------------------------------------------------------

    loc_41058B:                             ; CODE XREF: .text:00410585j
    mov     eax, [esp+30h]
    sub     eax, ebx
    sar     eax, 2

    loc_410594:                             ; CODE XREF: .text:00410589j
    push    eax
    call    GetRandom
    mov     ebp, [ebx+eax*4]
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    jz      short loc_4105CC
    push    0
    push    0
    push    0
    push    0
    push    ebp
    push    ecx
    mov     ecx, esp
    push    offset aVtol_landing            ; "VTOL_LANDING"
    call    sub_438760
    mov     ecx, ebx
    call    sub_43A0C0
    jmp     short loc_4105CE
    ; ---------------------------------------------------------------------------

    loc_4105CC:                             ; CODE XREF: .text:004105ABj
    xor     eax, eax

    loc_4105CE:                             ; CODE XREF: .text:004105CAj
    push    eax
    push    esi
    call    sub_43ACB0
    lea     ecx, [esp+28h]
    mov     dword ptr [edi+6], 0
    call    sub_40C530
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4105F1:                             ; CODE XREF: .text:00410574j
    lea     ecx, [esp+28h]
    call    sub_40C530

    loc_4105FA:                             ; CODE XREF: .text:00410533j
    push    esi
    call    sub_43B700
    test    eax, eax
    jz      short loc_410620
    push    0
    push    eax
    push    esi
    call    sub_43B1F0
    test    eax, eax
    jz      short loc_410620
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410620:                             ; CODE XREF: .text:00410602j
                                            ; .text:0041060Fj
    test    bl, 0E0h
    jz      short loc_41063E
    push    2000h
    call    GetRandom
    mov     ecx, [edi+36h]
    neg     eax
    sub     eax, 5555h
    add     ecx, eax
    mov     [edi+36h], ecx

    loc_41063E:                             ; CODE XREF: .text:00410623j
    mov     eax, [esi+10h]
    mov     bp, [edi+36h]
    mov     esi, [eax+0DCh]
    add     esi, 0A0h
    shl     esi, 10h
    push    esi
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    esi
    push    ebp
    call    sub_4B7123
    xor     ecx, ecx
    add     esp, 8
    neg     eax
    mov     [esp+20h], ecx
    lea     ecx, [esp+1Ch]
    mov     [esp+24h], eax
    lea     edx, [edi+22h]
    push    ecx
    lea     eax, [esp+3Ch]
    push    edx
    push    eax
    mov     [esp+28h], ebx
    call    sub_40F790
    mov     ecx, [eax]
    push    36h
    mov     [esp+14h], ecx
    mov     edx, [eax+4]
    mov     [esp+18h], edx
    mov     eax, [eax+8]
    mov     [esp+1Ch], eax
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4106C2
    lea     ecx, [esp+10h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_4106C4
    ; ---------------------------------------------------------------------------

    loc_4106C2:                             ; CODE XREF: .text:004106AFj
    xor     esi, esi

    loc_4106C4:                             ; CODE XREF: .text:004106C0j
    push    80h
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    push    1Eh
    call    GetRandom
    add     eax, 1Eh
    mov     ecx, edi
    push    eax
    call    sub_439E80
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410701:                             ; CODE XREF: .text:00410502j
    cmp     dword ptr [esi], 0
    jz      loc_41081F
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    test    ah, 8
    jz      loc_41081F
    mov     eax, [edi+16h]
    test    eax, eax
    jz      short loc_41074A
    push    0
    push    eax
    push    esi
    call    sub_43B1F0
    test    eax, eax
    jz      loc_410810
    mov     dword ptr [edi+6], 0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41074A:                             ; CODE XREF: .text:00410724j
    mov     eax, [edi+22h]
    test    eax, eax
    jnz     short loc_410774
    mov     eax, [edi+2Ah]
    test    eax, eax
    jnz     short loc_410774
    mov     eax, [edi+26h]
    test    eax, eax
    jnz     short loc_410774
    lea     eax, [esi+6Ah]
    mov     ecx, [esi+6Ah]
    mov     [edi+22h], ecx
    mov     edx, [eax+4]
    mov     [edi+26h], edx
    mov     eax, [eax+8]
    mov     [edi+2Ah], eax

    loc_410774:                             ; CODE XREF: .text:0041074Fj
                                            ; .text:00410756j ...
    push    10000h
    call    GetRandom
    mov     [edi+36h], eax
    and     eax, 1
    push    3
    mov     ecx, esi
    mov     [edi+3Ah], eax
    call    sub_4898B0
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_4107A6
    push    2
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_4107A6:                             ; CODE XREF: .text:00410798j
    push    1
    push    1
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     short loc_410810
    push    2
    push    esi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4107E4
    lea     ecx, [esi+6Ah]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_4107E6
    ; ---------------------------------------------------------------------------

    loc_4107E4:                             ; CODE XREF: .text:004107D2j
    xor     ebx, ebx

    loc_4107E6:                             ; CODE XREF: .text:004107E2j
    mov     edx, [esi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax

    loc_410810:                             ; CODE XREF: .text:00410731j
                                            ; .text:004107BCj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41081F:                             ; CODE XREF: .text:00410509j
                                            ; .text:00410704j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_410830 proc near                    ; CODE XREF: .text:0041053Dp
                                            ; .text:00410997p

    var_1= byte ptr -1

    push    ecx
    mov     eax, ecx
    mov     cl, [esp+4+var_1]
    mov     [eax], cl
    xor     ecx, ecx
    mov     [eax+4], ecx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ecx
    pop     ecx
    retn
    sub_410830 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 48h
    push    ebx
    mov     bl, [esp+58h]
    push    ebp
    push    esi
    test    bl, 40h
    push    edi
    jz      short loc_41086F
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41086F:                             ; CODE XREF: .text:0041085Ej
    mov     esi, [esp+5Ch]
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esi+82h]
    mov     edx, [ecx+142B7h]
    cmp     eax, edx
    jnz     loc_410959
    mov     eax, [ecx+1422Bh]
    add     esi, 6Ah
    cdq
    sub     eax, edx
    sar     eax, 1
    shl     eax, 10h
    mov     [esp+28h], eax
    mov     eax, [ecx+1422Fh]
    cdq
    sub     eax, edx
    lea     ecx, [esp+28h]
    sar     eax, 1
    shl     eax, 10h
    push    ecx
    push    esi
    mov     [esp+38h], eax
    call    sub_48A980
    mov     ecx, 3200000h
    lea     edx, [esp+38h]
    push    ecx
    push    eax
    push    edx
    call    sub_4103A0
    mov     ecx, [eax]
    mov     [esp+10h], ecx
    lea     ecx, [esp+10h]
    mov     edx, [eax+4]
    push    ecx
    mov     [esp+18h], edx
    lea     edx, [esp+4Ch]
    mov     eax, [eax+8]
    push    esi
    push    edx
    mov     [esp+24h], eax
    call    sub_40F790
    mov     ecx, [eax]
    push    36h
    mov     [esp+20h], ecx
    mov     edx, [eax+4]
    mov     [esp+24h], edx
    mov     eax, [eax+8]
    mov     [esp+28h], eax
    call    sub_4B4F10
    mov     edi, [esp+64h]
    add     esp, 4
    test    eax, eax
    jz      short loc_41092B
    lea     ecx, [esp+1Ch]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_41092D
    ; ---------------------------------------------------------------------------

    loc_41092B:                             ; CODE XREF: .text:00410918j
    xor     esi, esi

    loc_41092D:                             ; CODE XREF: .text:00410929j
    push    80h
    mov     ecx, esi
    call    sub_44E730
    mov     ecx, [edi+6]
    push    esi
    or      cl, 0E0h
    mov     [edi+6], ecx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410959:                             ; CODE XREF: .text:00410887j
    mov     edi, [esp+60h]
    xor     eax, eax
    mov     al, [edi+5]
    sub     eax, 0
    jz      loc_410BFB
    dec     eax
    jnz     loc_410C5C
    mov     edx, [esi+92h]
    movsx   ecx, word ptr [esi+108h]
    mov     eax, [edx+1FAh]
    shr     eax, 2
    lea     eax, [eax+eax*2]
    cmp     ecx, eax
    jnb     loc_410A54
    lea     ecx, [esp+38h]
    call    sub_410830
    mov     ecx, [esi+96h]
    lea     edx, [esp+38h]
    push    edx
    xor     edx, edx
    mov     dl, [ecx+146h]
    lea     eax, [esi+6Ah]
    push    0F00h
    push    eax
    push    edx
    call    sub_40B530
    lea     ecx, [esp+38h]
    call    sub_40C560
    neg     eax
    sbb     eax, eax
    inc     eax
    test    al, al
    jnz     short loc_410A4B
    push    0
    mov     ecx, edi
    call    sub_4388D0
    mov     ebx, [esp+3Ch]
    test    ebx, ebx
    jnz     short loc_4109E5
    xor     eax, eax
    jmp     short loc_4109EE
    ; ---------------------------------------------------------------------------

    loc_4109E5:                             ; CODE XREF: .text:004109DFj
    mov     eax, [esp+40h]
    sub     eax, ebx
    sar     eax, 2

    loc_4109EE:                             ; CODE XREF: .text:004109E3j
    push    eax
    call    GetRandom
    mov     ebp, [ebx+eax*4]
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    jz      short loc_410A26
    push    0
    push    0
    push    0
    push    0
    push    ebp
    push    ecx
    mov     ecx, esp
    push    offset aVtol_landing            ; "VTOL_LANDING"
    call    sub_438760
    mov     ecx, ebx
    call    sub_43A0C0
    jmp     short loc_410A28
    ; ---------------------------------------------------------------------------

    loc_410A26:                             ; CODE XREF: .text:00410A05j
    xor     eax, eax

    loc_410A28:                             ; CODE XREF: .text:00410A24j
    push    eax
    push    esi
    call    sub_43ACB0
    lea     ecx, [esp+38h]
    mov     dword ptr [edi+6], 0
    call    sub_40C530
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410A4B:                             ; CODE XREF: .text:004109CEj
    lea     ecx, [esp+38h]
    call    sub_40C530

    loc_410A54:                             ; CODE XREF: .text:0041098Dj
    lea     eax, [esp+60h]
    lea     ecx, [esp+48h]
    push    eax
    call    sub_40C510
    mov     ecx, [esi+92h]
    mov     edx, [esi+96h]
    movsx   eax, word ptr [ecx+202h]
    mov     [esp+2Ch], edx
    lea     edx, [esp+28h]
    shl     eax, 10h
    push    edx
    push    eax
    lea     eax, [esi+6Ah]
    lea     ecx, [esp+50h]
    push    eax
    mov     [esp+3Ch], ecx
    mov     [esp+40h], esi
    mov     dword ptr [esp+34h], offset off_4FCC60
    call    sub_47E890
    mov     ecx, [esp+4Ch]
    test    ecx, ecx
    jnz     short loc_410AAB
    xor     eax, eax
    jmp     short loc_410AB4
    ; ---------------------------------------------------------------------------

    loc_410AAB:                             ; CODE XREF: .text:00410AA5j
    mov     eax, [esp+50h]
    sub     eax, ecx
    sar     eax, 2

    loc_410AB4:                             ; CODE XREF: .text:00410AA9j
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    test    cl, cl
    jnz     short loc_410B31
    push    0
    mov     ecx, edi
    call    sub_4388D0
    push    0
    lea     ecx, [esp+64h]
    mov     edx, [esp+50h]
    mov     eax, [edx]
    push    eax
    push    esi
    push    7
    push    ecx
    call    sub_43F0E0
    push    56h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_410B09
    mov     edx, [esp+4Ch]
    push    0
    push    0
    push    0
    mov     ecx, [edx]
    mov     edx, [esp+6Ch]
    push    0
    push    ecx
    push    edx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_410B0B
    ; ---------------------------------------------------------------------------

    loc_410B09:                             ; CODE XREF: .text:00410AEAj
    xor     eax, eax

    loc_410B0B:                             ; CODE XREF: .text:00410B07j
    push    eax
    push    esi
    call    sub_43ACB0
    lea     ecx, [esp+48h]
    mov     dword ptr [edi+6], 0
    call    sub_40C530
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410B31:                             ; CODE XREF: .text:00410ABDj
    test    bl, 0E0h
    jz      short loc_410B4F
    push    2000h
    call    GetRandom
    mov     ecx, [edi+36h]
    neg     eax
    sub     eax, 4000h
    add     ecx, eax
    mov     [edi+36h], ecx

    loc_410B4F:                             ; CODE XREF: .text:00410B34j
    mov     eax, [esi+10h]
    mov     bp, [edi+36h]
    mov     esi, [eax+0DCh]
    add     esi, 0A0h
    shl     esi, 10h
    push    esi
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    esi
    push    ebp
    call    sub_4B7123
    mov     ecx, [edi+22h]
    mov     edx, [edi+2Ah]
    mov     esi, [edi+26h]
    add     esp, 8
    neg     eax
    add     ecx, ebx
    add     edx, eax
    push    36h
    mov     [esp+20h], ecx
    mov     [esp+24h], esi
    mov     [esp+28h], edx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_410BB7
    lea     ecx, [esp+1Ch]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_410BB9
    ; ---------------------------------------------------------------------------

    loc_410BB7:                             ; CODE XREF: .text:00410BA4j
    xor     esi, esi

    loc_410BB9:                             ; CODE XREF: .text:00410BB5j
    push    80h
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    push    1Eh
    mov     ecx, edi
    call    sub_439E80
    mov     edx, [edi+6]
    or      dl, 0F8h
    mov     [edi+6], edx
    mov     edx, [esp+4Ch]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410BFB:                             ; CODE XREF: .text:00410965j
    cmp     dword ptr [esi], 0
    jz      short loc_410C5C
    mov     eax, [esi+92h]
    mov     ecx, [eax+241h]
    test    ch, 8
    jz      short loc_410C5C
    mov     eax, [edi+22h]
    test    eax, eax
    jnz     short loc_410C3A
    mov     eax, [edi+2Ah]
    test    eax, eax
    jnz     short loc_410C3A
    mov     eax, [edi+26h]
    test    eax, eax
    jnz     short loc_410C3A
    add     esi, 6Ah
    mov     ecx, [esi]
    mov     [edi+22h], ecx
    mov     edx, [esi+4]
    mov     [edi+26h], edx
    mov     eax, [esi+8]
    mov     [edi+2Ah], eax

    loc_410C3A:                             ; CODE XREF: .text:00410C16j
                                            ; .text:00410C1Dj ...
    push    10000h
    call    GetRandom
    mov     [edi+36h], eax
    and     eax, 1
    mov     [edi+3Ah], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410C5C:                             ; CODE XREF: .text:0041096Cj
                                            ; .text:00410BFEj ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 48h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_410C70 proc near                    ; DATA XREF: .rdata:004FCC60o

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     eax, [ecx+4]
    sub     esp, 8
    xor     edx, edx
    mov     dl, [eax+146h]
    mov     eax, [esp+8+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [eax+96h]
    push    edi
    mov     bl, [edx+esi+108h]
    test    bl, bl
    jz      loc_410E62
    mov     edx, [eax+92h]
    test    dword ptr [edx+241h], 800h
    jnz     loc_410E62
    cmp     eax, [ecx+0Ch]
    jz      loc_410E62
    mov     esi, [ecx+8]
    mov     eax, [esi+8]
    mov     ecx, [esi+0Ch]
    sub     ecx, eax
    mov     edi, eax
    sar     ecx, 2
    cmp     ecx, 1
    jnb     loc_410DC8
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_410CDE
    xor     ecx, ecx
    jmp     short loc_410CE5
    ; ---------------------------------------------------------------------------

    loc_410CDE:                             ; CODE XREF: sub_410C70+68j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2

    loc_410CE5:                             ; CODE XREF: sub_410C70+6Cj
    cmp     ecx, 1
    jbe     short loc_410CFB
    test    edx, edx
    jnz     short loc_410CF2
    xor     ecx, ecx
    jmp     short loc_410D00
    ; ---------------------------------------------------------------------------

    loc_410CF2:                             ; CODE XREF: sub_410C70+7Cj
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_410D00
    ; ---------------------------------------------------------------------------

    loc_410CFB:                             ; CODE XREF: sub_410C70+78j
    mov     ecx, 1

    loc_410D00:                             ; CODE XREF: sub_410C70+80j
                                            ; sub_410C70+89j
    test    edx, edx
    jnz     short loc_410D08
    xor     eax, eax
    jmp     short loc_410D0D
    ; ---------------------------------------------------------------------------

    loc_410D08:                             ; CODE XREF: sub_410C70+92j
    sub     eax, edx
    sar     eax, 2

    loc_410D0D:                             ; CODE XREF: sub_410C70+96j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_410D19
    xor     eax, eax

    loc_410D19:                             ; CODE XREF: sub_410C70+A5j
    lea     edx, ds:0[eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    mov     ebx, [esi+4]
    add     esp, 4
    cmp     ebx, edi
    mov     [esp+18h+var_8], eax
    mov     ebp, eax
    jz      short loc_410D47

    loc_410D36:                             ; CODE XREF: sub_410C70+D5j
    push    ebx
    push    ebp
    call    sub_406C70
    add     ebx, 4
    add     ebp, 4
    cmp     ebx, edi
    jnz     short loc_410D36

    loc_410D47:                             ; CODE XREF: sub_410C70+C4j
    lea     eax, [esp+18h+arg_0]
    mov     ecx, esi
    push    eax
    push    1
    push    ebp
    call    sub_406C40
    mov     ecx, [esi+8]
    add     ebp, 4
    push    ebp
    push    ecx
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     edx, [esi+8]
    mov     eax, [esi+4]
    push    edx
    push    eax
    mov     ecx, esi
    call    nullsub_1
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+1Ch+var_8]
    mov     ecx, [esp+1Ch+var_4]
    add     esp, 4
    lea     eax, [edx+ecx*4]
    mov     [esi+0Ch], eax
    mov     eax, [esi+4]
    test    eax, eax
    jnz     short loc_410DAC
    xor     ecx, ecx
    mov     [esi+4], edx
    lea     ecx, [edx+ecx*4+4]
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_410DAC:                             ; CODE XREF: sub_410C70+124j
    mov     ecx, [esi+8]
    mov     [esi+4], edx
    sub     ecx, eax
    sar     ecx, 2
    lea     ecx, [edx+ecx*4+4]
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_410DC8:                             ; CODE XREF: sub_410C70+5Dj
    mov     edx, eax
    sub     edx, edi
    sar     edx, 2
    cmp     edx, 1
    jnb     short loc_410E22
    lea     ecx, [edi+4]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+8]
    lea     edx, [esp+18h+arg_0]
    mov     ecx, eax
    push    edx
    sub     ecx, edi
    mov     edx, 1
    sar     ecx, 2
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_406C40
    mov     eax, [esi+8]
    cmp     edi, eax
    jz      short loc_410E5E

    loc_410E07:                             ; CODE XREF: sub_410C70+1A2j
    mov     ecx, [esp+18h+arg_0]
    mov     [edi], ecx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_410E07
    add     dword ptr [esi+8], 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_410E22:                             ; CODE XREF: sub_410C70+162j
    push    eax
    push    eax
    add     eax, 0FFFFFFFCh
    mov     ecx, esi
    push    eax
    call    sub_406C10
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_410E48

    loc_410E39:                             ; CODE XREF: sub_410C70+1D6j
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_410E39

    loc_410E48:                             ; CODE XREF: sub_410C70+1C7j
    lea     ecx, [edi+4]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_410E5E

    loc_410E51:                             ; CODE XREF: sub_410C70+1ECj
    mov     edx, [esp+18h+arg_0]
    mov     [eax], edx
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_410E51

    loc_410E5E:                             ; CODE XREF: sub_410C70+195j
                                            ; sub_410C70+1DFj
    add     dword ptr [esi+8], 4

    loc_410E62:                             ; CODE XREF: sub_410C70+25j
                                            ; sub_410C70+3Bj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_410C70 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 1Ch
    xor     eax, eax
    push    ebx
    push    ebp
    mov     ebp, [esp+2Ch]
    push    esi
    push    edi
    mov     al, [ebp+5]
    sub     eax, 0
    jz      loc_4110C3
    dec     eax
    jz      loc_4110AC
    dec     eax
    jnz     loc_411199
    test    byte ptr [esp+38h], 0E0h
    jz      short loc_410EAD
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_410EAD:                             ; CODE XREF: .text:00410E9Cj
    mov     eax, [esp+30h]
    lea     edi, [ebp+22h]
    add     eax, 6Ah
    push    edi
    push    eax
    mov     [esp+3Ch], eax
    call    sub_48A980
    mov     ebx, eax
    push    1400000h
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    1400000h
    push    ebx
    call    sub_4B7123
    mov     ecx, [edi]
    add     esp, 8
    add     esi, ecx
    mov     ecx, [edi+4]
    mov     edi, [edi+8]
    push    36h
    neg     eax
    add     edi, eax
    mov     [esp+14h], esi
    mov     [esp+18h], ecx
    mov     [esp+1Ch], edi
    call    sub_4B4F10
    xor     edi, edi
    add     esp, 4
    cmp     eax, edi
    jz      short loc_410F1F
    lea     ecx, [esp+10h]
    push    ecx
    push    ebp
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_410F21
    ; ---------------------------------------------------------------------------

    loc_410F1F:                             ; CODE XREF: .text:00410F0Cj
    xor     esi, esi

    loc_410F21:                             ; CODE XREF: .text:00410F1Dj
    push    150h
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, ebp
    call    sub_4388D0
    mov     ebx, [ebp+6]
    or      bl, 0E0h
    mov     [ebp+6], ebx
    mov     ebx, [esp+30h]
    mov     edx, [ebx+92h]
    movsx   ecx, word ptr [ebx+108h]
    mov     eax, [edx+1FAh]
    shr     eax, 2
    lea     eax, [eax+eax*2]
    cmp     ecx, eax
    jnb     loc_41106C
    mov     dl, [esp+30h]
    mov     ecx, [esp+34h]
    lea     eax, [esp+1Ch]
    mov     [esp+1Ch], dl
    mov     edx, [ebx+96h]
    push    eax
    xor     eax, eax
    mov     [esp+24h], edi
    mov     [esp+28h], edi
    mov     [esp+2Ch], edi
    mov     al, [edx+146h]
    push    0F00h
    push    ecx
    push    eax
    call    sub_40B530
    mov     esi, [esp+24h]
    mov     ecx, [esp+20h]
    cmp     ecx, edi
    jnz     short loc_410FAA
    xor     eax, eax
    jmp     short loc_410FB1
    ; ---------------------------------------------------------------------------

    loc_410FAA:                             ; CODE XREF: .text:00410FA4j
    mov     eax, esi
    sub     eax, ecx
    sar     eax, 2

    loc_410FB1:                             ; CODE XREF: .text:00410FA8j
    xor     edx, edx
    test    eax, eax
    setz    dl
    test    dl, dl
    jnz     loc_411052
    push    0
    mov     ecx, ebp
    call    sub_4388D0
    mov     esi, [esp+20h]
    test    esi, esi
    jnz     short loc_410FD5
    xor     eax, eax
    jmp     short loc_410FDE
    ; ---------------------------------------------------------------------------

    loc_410FD5:                             ; CODE XREF: .text:00410FCFj
    mov     eax, [esp+24h]
    sub     eax, esi
    sar     eax, 2

    loc_410FDE:                             ; CODE XREF: .text:00410FD3j
    push    eax
    call    GetRandom
    mov     edi, [esi+eax*4]
    push    56h
    call    sub_4B4F10
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jz      short loc_411016
    push    0
    push    0
    push    0
    push    0
    push    edi
    push    ecx
    mov     ecx, esp
    push    offset aVtol_landing            ; "VTOL_LANDING"
    call    sub_438760
    mov     ecx, esi
    call    sub_43A0C0
    jmp     short loc_411018
    ; ---------------------------------------------------------------------------

    loc_411016:                             ; CODE XREF: .text:00410FF5j
    xor     eax, eax

    loc_411018:                             ; CODE XREF: .text:00411014j
    push    eax
    push    ebx
    call    sub_43ACB0
    mov     dword ptr [ebp+6], 0
    mov     eax, [esp+24h]
    mov     ecx, [esp+20h]
    push    eax
    push    ecx
    lea     ecx, [esp+24h]
    call    nullsub_1
    mov     edx, [esp+20h]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411052:                             ; CODE XREF: .text:00410FBAj
    push    esi
    push    ecx
    lea     ecx, [esp+24h]
    call    nullsub_1
    mov     eax, [esp+20h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    xor     edi, edi

    loc_41106C:                             ; CODE XREF: .text:00410F5Dj
    push    ebx
    call    sub_43B700
    cmp     eax, edi
    jz      short loc_411094
    push    edi
    push    eax
    push    ebx
    call    sub_43B1F0
    test    eax, eax
    jz      short loc_411094
    mov     [ebp+6], edi
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411094:                             ; CODE XREF: .text:00411074j
                                            ; .text:00411080j
    push    1Eh
    mov     ecx, ebp
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4110AC:                             ; CODE XREF: .text:00410E8Aj
    mov     eax, [ebp+4Eh]
    and     al, 1Fh
    mov     [ebp+4Eh], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4110C3:                             ; CODE XREF: .text:00410E83j
    mov     esi, [esp+30h]
    cmp     dword ptr [esi], 0
    jz      loc_411199
    mov     ecx, [esi+92h]
    mov     eax, [ecx+241h]
    test    ah, 8
    jz      loc_411199
    push    ebp
    push    esi
    call    sub_43A020
    push    offset aPatrolling              ; "Patrolling"
    mov     ecx, ebp
    call    sub_438880
    push    3
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_411117
    push    2
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_411117:                             ; CODE XREF: .text:00411109j
    push    1
    push    1
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     short loc_411181
    push    2
    push    esi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_411155
    lea     ecx, [esi+6Ah]
    push    ecx
    push    ebp
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_411157
    ; ---------------------------------------------------------------------------

    loc_411155:                             ; CODE XREF: .text:00411143j
    xor     edi, edi

    loc_411157:                             ; CODE XREF: .text:00411153j
    mov     edx, [esi+92h]
    mov     ecx, edi
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    edi
    mov     ecx, ebp
    call    sub_4388D0
    mov     eax, [ebp+6]
    or      al, 0E0h
    mov     [ebp+6], eax

    loc_411181:                             ; CODE XREF: .text:0041112Dj
    push    3
    mov     ecx, esi
    call    sub_489800
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411199:                             ; CODE XREF: .text:00410E91j
                                            ; .text:004110CAj ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 18h
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+2Ch]
    mov     eax, [edi+16h]
    test    eax, eax
    jz      loc_41151A
    mov     edx, [esp+30h]
    test    edx, 10048h
    jnz     loc_41151A
    mov     ecx, [eax+92h]
    mov     ebx, [eax+6Eh]
    mov     esi, TAdynmemStructPtr
    mov     ecx, [ecx+16Eh]
    add     ecx, ebx
    xor     ebx, ebx
    mov     bl, [esi+1427Fh]
    shl     ebx, 10h
    cmp     ecx, ebx
    jg      short loc_41121A
    mov     edx, [esp+28h]
    push    offset aTransportMissi          ; "Transport mission failed"
    push    7
    push    edx
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41121A:                             ; CODE XREF: .text:004111F9j
    mov     esi, [esp+28h]
    mov     ecx, [esi+8Ah]
    test    ecx, ecx
    jnz     loc_41152B
    xor     ecx, ecx
    mov     cl, [edi+5]
    cmp     ecx, 5                          ; switch 6 cases
    ja      loc_41150C                      ; default
    jmp     ds:off_41153C[ecx*4]            ; switch jump

    loc_411241:                             ; DATA XREF: .text:0041153Co
    cmp     dword ptr [esi], 0              ; case 0x0
    jz      loc_41150C                      ; default
    mov     ecx, [esi+92h]
    mov     edx, [ecx+241h]
    test    dh, 8
    jz      loc_41150C                      ; default
    movzx   cx, byte ptr [ecx+22Ah]
    cmp     [eax+7Eh], cx
    jle     short loc_411288
    push    offset aUnitIsTooHeavy          ; "Unit is too heavy to transport"
    push    7
    push    esi
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411288:                             ; CODE XREF: .text:0041126Bj
    push    offset aLoading                 ; "Loading"
    mov     ecx, edi
    call    sub_438880
    push    3
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_4112B3
    push    2
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_4112B3:                             ; CODE XREF: .text:004112A5j
    push    1
    push    1
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     loc_4114F0
    push    2
    push    esi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4112F5
    lea     ecx, [esi+6Ah]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_4112F7
    ; ---------------------------------------------------------------------------

    loc_4112F5:                             ; CODE XREF: .text:004112E3j
    xor     ebx, ebx

    loc_4112F7:                             ; CODE XREF: .text:004112F3j
    mov     edx, [esi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41132F:                             ; CODE XREF: .text:0041123Aj
                                            ; DATA XREF: .text:0041153Co
    push    36h                             ; case 0x1
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_41134D
    mov     ecx, [edi+16h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E190
    mov     ebx, eax
    jmp     short loc_41134F
    ; ---------------------------------------------------------------------------

    loc_41134D:                             ; CODE XREF: .text:0041133Bj
    xor     ebx, ebx

    loc_41134F:                             ; CODE XREF: .text:0041134Bj
    mov     edx, [esi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    push    eax
    call    sub_44E6C0
    push    30h
    mov     ecx, ebx
    call    sub_44E730
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 100E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41138A:                             ; CODE XREF: .text:0041123Aj
                                            ; DATA XREF: .text:0041153Co
    push    offset aPreparingForTr          ; case 0x2
    mov     ecx, edi
    call    sub_438880
    lea     eax, [edi+36h]
    push    0
    push    0
    push    0
    mov     dword ptr [eax], 0FFFFFFFFh
    mov     ecx, [esi+9Ah]
    push    eax
    push    offset aQuerytransport          ; "QueryTransport"
    call    sub_4B0BC0
    mov     dword ptr [edi+6], 100E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4113CB:                             ; CODE XREF: .text:0041123Aj
                                            ; DATA XREF: .text:0041153Co
    mov     ecx, [eax+92h]                  ; case 0x3
    push    0
    push    0
    push    0
    mov     ebx, [ecx+16Eh]
    mov     ecx, [esi+9Ah]
    push    ebx
    push    1
    push    1
    push    0
    push    offset aBegintransport          ; "BeginTransport"
    call    sub_4B0A70
    push    0
    push    0
    push    0
    push    ebx
    push    1
    push    offset aBegintransport          ; "BeginTransport"
    push    esi
    call    sub_456200
    mov     edx, [edi+36h]
    lea     eax, [esp+18h]
    push    edx
    push    esi
    push    eax
    call    sub_43DEF0
    mov     ecx, [eax]
    push    36h
    mov     [esp+10h], ecx
    mov     edx, [eax+4]
    mov     [esp+14h], edx
    mov     eax, [eax+8]
    mov     [esp+18h], eax
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_41144B
    mov     ecx, [edi+16h]
    push    0FFFFFFFFh
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E250
    mov     esi, eax
    jmp     short loc_41144D
    ; ---------------------------------------------------------------------------

    loc_41144B:                             ; CODE XREF: .text:00411437j
    xor     esi, esi

    loc_41144D:                             ; CODE XREF: .text:00411449j
    movsx   edx, word ptr [esp+12h]
    neg     edx
    push    edx
    mov     ecx, esi
    call    sub_44E6C0
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 100EAh
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411479:                             ; CODE XREF: .text:0041123Aj
                                            ; DATA XREF: .text:0041153Co
    test    dl, 42h                         ; case 0x4
    push    0
    jz      short loc_4114A0
    mov     ecx, [esi+9Ah]
    push    0
    push    offset aEndtransport            ; "EndTransport"
    call    InvokeScript
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4114A0:                             ; CODE XREF: .text:0041147Ej
    mov     ecx, [edi+36h]
    push    ecx
    push    esi
    push    eax
    call    sub_48AAC0
    push    0
    push    0Ch
    push    esi
    call    sub_47F780
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4114D1
    lea     edx, [esi+6Ah]
    mov     ecx, eax
    push    edx
    push    edi
    call    sub_44E2D0
    jmp     short loc_4114D3
    ; ---------------------------------------------------------------------------

    loc_4114D1:                             ; CODE XREF: .text:004114C1j
    xor     eax, eax

    loc_4114D3:                             ; CODE XREF: .text:004114CFj
    mov     ecx, [esi+92h]
    movsx   edx, word ptr [ecx+21Ch]
    push    edx
    mov     ecx, eax
    call    sub_44E6C0
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax

    loc_4114F0:                             ; CODE XREF: .text:004112C9j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4114FE:                             ; CODE XREF: .text:0041123Aj
                                            ; DATA XREF: .text:0041153Co
    mov     eax, 5                          ; case 0x5
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41150C:                             ; CODE XREF: .text:00411234j
                                            ; .text:00411244j ...
    mov     eax, 7                          ; default
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41151A:                             ; CODE XREF: .text:004111BFj
                                            ; .text:004111CFj
    mov     eax, [esp+28h]
    push    offset aTransportMissi          ; "Transport mission failed"
    push    7
    push    eax
    call    sub_47F780

    loc_41152B:                             ; CODE XREF: .text:00411226j
    pop     edi
    pop     esi
    mov     eax, 8
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_41153C dd offset loc_411241         ; DATA XREF: .text:0041123Ar
    dd offset loc_41132F                    ; jump table for switch statement
    dd offset loc_41138A
    dd offset loc_4113CB
    dd offset loc_411479
    dd offset loc_4114FE
    align 10h
    sub     esp, 0Ch
    push    ebx
    mov     ebx, [esp+14h]
    push    ebp
    push    esi
    mov     eax, [ebx+8Ah]
    push    edi
    test    eax, eax
    jnz     short loc_411584
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411584:                             ; CODE XREF: .text:00411573j
    mov     esi, [esp+24h]
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_411817                      ; default
    jmp     ds:off_411828[eax*4]            ; switch jump

    loc_41159D:                             ; DATA XREF: .text:00411828o
    cmp     dword ptr [ebx], 0              ; case 0x0
    jz      loc_411817                      ; default
    mov     eax, [ebx+92h]
    mov     ecx, [eax+241h]
    test    ch, 8
    jz      loc_411817                      ; default
    push    offset aUnloading               ; "Unloading"
    mov     ecx, esi
    call    sub_438880
    mov     ecx, [ebx+8Ah]
    push    ecx
    lea     ecx, [esi+12h]
    call    sub_489690
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4115F4
    lea     edx, [esi+22h]
    mov     ecx, eax
    push    edx
    push    esi
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_4115F6
    ; ---------------------------------------------------------------------------

    loc_4115F4:                             ; CODE XREF: .text:004115E2j
    xor     edi, edi

    loc_4115F6:                             ; CODE XREF: .text:004115F2j
    mov     eax, [ebx+92h]
    movsx   ecx, word ptr [eax+21Ch]
    push    ecx
    mov     ecx, edi
    call    sub_44E6C0
    push    140h
    mov     ecx, edi
    call    sub_44E730
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 0E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411635:                             ; CODE XREF: .text:00411596j
                                            ; DATA XREF: .text:00411828o
    mov     edx, [esi+16h]                  ; case 0x1
    lea     edi, [esi+22h]
    mov     ecx, edi
    push    1
    mov     eax, [edx+7Eh]
    mov     edx, [edx+92h]
    mov     [esp+24h], eax
    mov     eax, [ecx]
    mov     ebp, [ecx+4]
    mov     [esp+18h], ebp
    movsx   ebp, word ptr [esp+24h]
    shl     ebp, 13h
    sub     eax, ebp
    mov     ecx, [ecx+8]
    add     eax, 80000h
    sar     eax, 14h
    mov     [esp+28h], ax
    movsx   eax, word ptr [esp+26h]
    shl     eax, 13h
    sub     ecx, eax
    add     ecx, 80000h
    sar     ecx, 14h
    mov     [esp+2Ah], cx
    mov     ecx, [esp+28h]
    push    ecx
    push    0
    push    edx
    call    sub_47DB70
    test    eax, eax
    jz      loc_411769
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4116B7
    push    edi
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_4116B9
    ; ---------------------------------------------------------------------------

    loc_4116B7:                             ; CODE XREF: .text:004116A8j
    xor     edi, edi

    loc_4116B9:                             ; CODE XREF: .text:004116B5j
    mov     eax, [ebx+8Ah]
    mov     ecx, [eax+92h]
    movsx   eax, word ptr [ecx+170h]
    push    eax
    mov     ecx, edi
    call    sub_44E6C0
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 0E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4116F2:                             ; CODE XREF: .text:00411596j
                                            ; DATA XREF: .text:00411828o
    test    byte ptr [esp+28h], 40h         ; case 0x2
    jz      short loc_411708
    mov     eax, 9
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411708:                             ; CODE XREF: .text:004116F7j
    mov     edx, [esi+16h]
    lea     eax, [esi+22h]
    mov     ecx, eax
    push    1
    mov     edi, [edx+7Eh]
    mov     edx, [edx+92h]
    mov     eax, [ecx]
    mov     [esp+28h], edi
    movsx   edi, di
    shl     edi, 13h
    mov     ebp, [ecx+4]
    sub     eax, edi
    add     eax, 80000h
    mov     [esp+18h], ebp
    mov     ecx, [ecx+8]
    sar     eax, 14h
    mov     [esp+24h], ax
    movsx   eax, word ptr [esp+2Ah]
    shl     eax, 13h
    sub     ecx, eax
    add     ecx, 80000h
    sar     ecx, 14h
    mov     [esp+26h], cx
    mov     ecx, [esp+24h]
    push    ecx
    push    0
    push    edx
    call    sub_47DB70
    test    eax, eax
    jnz     short loc_411785

    loc_411769:                             ; CODE XREF: .text:00411696j
    push    offset aUnableToUnload          ; "Unable to unload unit"
    push    7
    push    ebx
    call    sub_47F780
    mov     eax, 9
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411785:                             ; CODE XREF: .text:00411767j
    mov     ecx, [ebx+9Ah]
    push    0
    push    0
    push    offset aEndtransport            ; "EndTransport"
    call    InvokeScript
    mov     eax, [ebx+8Ah]
    push    1
    push    0FFFFFFFFh
    push    0
    push    eax
    call    sub_48AAC0
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4117C9
    lea     ecx, [ebx+6Ah]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_4117CB
    ; ---------------------------------------------------------------------------

    loc_4117C9:                             ; CODE XREF: .text:004117B7j
    xor     edi, edi

    loc_4117CB:                             ; CODE XREF: .text:004117C7j
    mov     edx, [ebx+92h]
    mov     ecx, edi
    movsx   eax, word ptr [edx+21Ch]
    push    eax
    call    sub_44E6C0
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 0E0h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4117FE:                             ; CODE XREF: .text:00411596j
                                            ; DATA XREF: .text:00411828o
    push    0                               ; case 0x3
    push    0Dh
    push    ebx
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411817:                             ; CODE XREF: .text:00411590j
                                            ; .text:004115A0j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_411828 dd offset loc_41159D         ; DATA XREF: .text:00411596r
    dd offset loc_411635                    ; jump table for switch statement
    dd offset loc_4116F2
    dd offset loc_4117FE
    align 10h
    sub     esp, 10h
    push    ebx
    mov     ebx, [esp+18h]
    push    ebp
    push    esi
    mov     esi, [esp+24h]
    or      ebp, 0FFFFFFFFh
    cmp     esi, ebp
    push    edi
    jz      short loc_41186D
    push    esi
    push    ebx
    call    sub_47E570
    test    eax, eax
    jz      short loc_41186D
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_41186D:                             ; CODE XREF: .text:00411854j
                                            ; .text:0041185Fj
    lea     eax, [esp+1Ch]
    lea     ecx, [esp+18h]
    push    eax
    lea     edx, [esp+18h]
    push    ecx
    mov     ecx, [ebx+9Ah]
    lea     eax, [esp+18h]
    push    edx
    push    eax
    push    offset aQuerylandingpa          ; "QueryLandingPad"
    mov     [esp+24h], ebp
    mov     [esp+28h], ebp
    mov     [esp+2Ch], ebp
    mov     [esp+30h], ebp
    call    sub_4B0BC0
    xor     edi, edi
    lea     esi, [esp+10h]

    loc_4118A7:                             ; CODE XREF: .text:004118BFj
    mov     eax, [esi]
    cmp     eax, ebp
    jz      short loc_4118B8
    push    eax
    push    ebx
    call    sub_47E570
    test    eax, eax
    jnz     short loc_4118CD

    loc_4118B8:                             ; CODE XREF: .text:004118ABj
    inc     edi
    add     esi, 4
    cmp     edi, 4
    jl      short loc_4118A7
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4118CD:                             ; CODE XREF: .text:004118B6j
    mov     eax, [esp+edi*4+10h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 30h
    push    ebx
    push    ebp
    mov     ebp, [esp+3Ch]
    push    esi
    mov     esi, [esp+44h]
    push    edi
    mov     eax, [ebp+10h]
    mov     ebx, [esi+16h]
    mov     ecx, [eax+0DCh]
    test    ebx, ebx
    mov     [esp+10h], ecx
    jnz     short loc_41191F
    push    offset aLandingAborted          ; "Landing aborted"
    push    7
    push    ebp
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41191F:                             ; CODE XREF: .text:00411901j
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 6                          ; switch 7 cases
    ja      loc_411F0D                      ; default
    jmp     ds:off_411F28[eax*4]            ; switch jump

    loc_411934:                             ; DATA XREF: .text:00411F28o
    cmp     dword ptr [ebp+0], 0            ; case 0x0
    jz      loc_411F0D                      ; default
    mov     edx, [ebp+92h]
    mov     eax, [edx+241h]
    test    ah, 8
    jz      loc_411F0D                      ; default
    push    offset aLanding                 ; "Landing"
    mov     ecx, esi
    call    sub_438880
    push    3
    mov     ecx, ebp
    call    sub_4898B0
    mov     eax, [ebp+86h]
    test    eax, eax
    jz      short loc_41197E
    push    2
    push    0FFFFFFFFh
    push    0
    push    ebp
    call    sub_48AAC0

    loc_41197E:                             ; CODE XREF: .text:00411970j
    push    1
    push    1
    mov     ecx, ebp
    call    sub_48B090
    mov     ecx, [ebp+0]
    mov     al, [ecx+2Eh]
    and     al, 3
    cmp     al, 1
    jnz     short loc_4119E7
    push    2
    push    ebp
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4119BB
    lea     ecx, [ebp+6Ah]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_4119BD
    ; ---------------------------------------------------------------------------

    loc_4119BB:                             ; CODE XREF: .text:004119A9j
    xor     edi, edi

    loc_4119BD:                             ; CODE XREF: .text:004119B9j
    mov     edx, [ebp+92h]
    mov     ecx, edi
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     eax, [esi+6]
    or      al, 0E0h
    mov     [esi+6], eax

    loc_4119E7:                             ; CODE XREF: .text:00411993j
    push    10000h
    call    GetRandom
    mov     [esi+36h], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411A03:                             ; CODE XREF: .text:0041192Dj
                                            ; DATA XREF: .text:00411F28o
    or      eax, 0FFFFFFFFh                 ; case 0x1
    lea     ecx, [esp+28h]
    mov     [esp+20h], eax
    mov     [esp+24h], eax
    mov     [esp+28h], eax
    mov     [esp+2Ch], eax
    lea     eax, [esp+2Ch]
    lea     edx, [esp+24h]
    push    eax
    push    ecx
    mov     ecx, [ebx+9Ah]
    lea     eax, [esp+28h]
    push    edx
    push    eax
    push    offset aQuerylandingpa          ; "QueryLandingPad"
    call    sub_4B0BC0
    xor     ebp, ebp
    lea     edi, [esp+20h]

    loc_411A40:                             ; CODE XREF: .text:00411A5Dj
    mov     eax, [edi]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_411A56
    push    eax
    push    ebx
    call    sub_47E570
    test    eax, eax
    jnz     loc_411F1C

    loc_411A56:                             ; CODE XREF: .text:00411A45j
    inc     ebp
    add     edi, 4
    cmp     ebp, 4
    jl      short loc_411A40
    or      ebp, 0FFFFFFFFh

    loc_411A62:                             ; CODE XREF: .text:00411F20j
    mov     ebx, [esi+16h]
    or      edi, 0FFFFFFFFh
    cmp     ebp, edi
    jz      short loc_411A77
    push    ebp
    push    ebx
    call    sub_47E570
    test    eax, eax
    jnz     short loc_411ADA

    loc_411A77:                             ; CODE XREF: .text:00411A6Aj
    lea     ecx, [esp+3Ch]
    lea     edx, [esp+38h]
    push    ecx
    lea     eax, [esp+38h]
    push    edx
    lea     ecx, [esp+38h]
    push    eax
    push    ecx
    mov     ecx, [ebx+9Ah]
    push    offset aQuerylandingpa          ; "QueryLandingPad"
    mov     [esp+44h], edi
    mov     [esp+48h], edi
    mov     [esp+4Ch], edi
    mov     [esp+50h], edi
    call    sub_4B0BC0
    xor     ebp, ebp
    lea     edi, [esp+30h]

    loc_411AB1:                             ; CODE XREF: .text:00411ACAj
    mov     eax, [edi]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_411AC3
    push    eax
    push    ebx
    call    sub_47E570
    test    eax, eax
    jnz     short loc_411ACE

    loc_411AC3:                             ; CODE XREF: .text:00411AB6j
    inc     ebp
    add     edi, 4
    cmp     ebp, 4
    jl      short loc_411AB1
    jmp     short loc_411AD4
    ; ---------------------------------------------------------------------------

    loc_411ACE:                             ; CODE XREF: .text:00411AC1j
    mov     ebp, [esp+ebp*4+30h]
    jmp     short loc_411AD7
    ; ---------------------------------------------------------------------------

    loc_411AD4:                             ; CODE XREF: .text:00411ACCj
    or      ebp, 0FFFFFFFFh

    loc_411AD7:                             ; CODE XREF: .text:00411AD2j
    or      edi, 0FFFFFFFFh

    loc_411ADA:                             ; CODE XREF: .text:00411A75j
    cmp     ebp, edi
    jz      short loc_411AF1
    mov     byte ptr [esi+5], 2
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411AF1:                             ; CODE XREF: .text:00411ADCj
    mov     ebx, [esp+10h]
    mov     bp, [esi+36h]
    shl     ebx, 10h
    push    ebx
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     edi, eax
    neg     edi
    push    ebx
    push    ebp
    call    sub_4B7123
    mov     ecx, [esi+16h]
    mov     ebx, [esi+36h]
    add     ecx, 6Ah
    add     esp, 8
    neg     eax
    mov     edx, [ecx]
    add     ebx, 4000h
    add     edx, edi
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    push    36h
    add     ecx, eax
    mov     [esp+18h], edx
    mov     [esp+1Ch], edi
    mov     [esp+20h], ecx
    mov     [esi+36h], ebx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_411B5F
    lea     edx, [esp+14h]
    mov     ecx, eax
    push    edx
    push    esi
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_411B61
    ; ---------------------------------------------------------------------------

    loc_411B5F:                             ; CODE XREF: .text:00411B4Cj
    xor     edi, edi

    loc_411B61:                             ; CODE XREF: .text:00411B5Dj
    push    80h
    mov     ecx, edi
    call    sub_44E730
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 0E8h
    mov     byte ptr [esi+5], 1
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411B8F:                             ; CODE XREF: .text:0041192Dj
                                            ; DATA XREF: .text:00411F28o
    push    36h                             ; case 0x2
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_411BB7
    mov     ecx, [esi+16h]
    push    0FFFFFFFFh
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E250
    mov     edi, eax
    push    0A0h
    jmp     loc_411C71
    ; ---------------------------------------------------------------------------

    loc_411BB7:                             ; CODE XREF: .text:00411B9Bj
    xor     edi, edi
    push    0A0h
    jmp     loc_411C71
    ; ---------------------------------------------------------------------------

    loc_411BC3:                             ; CODE XREF: .text:0041192Dj
                                            ; DATA XREF: .text:00411F28o
    or      eax, 0FFFFFFFFh                 ; case 0x3
    lea     edx, [esp+3Ch]
    mov     [esp+30h], eax
    mov     [esp+34h], eax
    mov     [esp+38h], eax
    mov     [esp+3Ch], eax
    lea     eax, [esp+38h]
    push    edx
    lea     ecx, [esp+38h]
    push    eax
    lea     edx, [esp+38h]
    push    ecx
    mov     ecx, [ebx+9Ah]
    push    edx
    push    offset aQuerylandingpa          ; "QueryLandingPad"
    call    sub_4B0BC0
    xor     ebp, ebp
    lea     edi, [esp+30h]

    loc_411C00:                             ; CODE XREF: .text:00411C19j
    mov     eax, [edi]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_411C12
    push    eax
    push    ebx
    call    sub_47E570
    test    eax, eax
    jnz     short loc_411C1D

    loc_411C12:                             ; CODE XREF: .text:00411C05j
    inc     ebp
    add     edi, 4
    cmp     ebp, 4
    jl      short loc_411C00
    jmp     short loc_411C23
    ; ---------------------------------------------------------------------------

    loc_411C1D:                             ; CODE XREF: .text:00411C10j
    mov     ebp, [esp+ebp*4+30h]
    jmp     short loc_411C26
    ; ---------------------------------------------------------------------------

    loc_411C23:                             ; CODE XREF: .text:00411C1Bj
    or      ebp, 0FFFFFFFFh

    loc_411C26:                             ; CODE XREF: .text:00411C21j
    cmp     ebp, 0FFFFFFFFh
    mov     [esi+36h], ebp
    jnz     short loc_411C4B
    mov     eax, [esp+44h]
    push    offset aLandingFailed           ; "Landing failed"
    push    7
    push    eax
    call    sub_47F780
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411C4B:                             ; CODE XREF: .text:00411C2Cj
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_411C6D
    mov     ecx, [esi+36h]
    mov     edx, [esi+16h]
    push    ecx
    push    edx
    push    esi
    mov     ecx, eax
    call    sub_44E250
    mov     edi, eax
    jmp     short loc_411C6F
    ; ---------------------------------------------------------------------------

    loc_411C6D:                             ; CODE XREF: .text:00411C57j
    xor     edi, edi

    loc_411C6F:                             ; CODE XREF: .text:00411C6Bj
    push    30h

    loc_411C71:                             ; CODE XREF: .text:00411BB2j
                                            ; .text:00411BBEj
    mov     ecx, edi
    call    sub_44E730
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 0E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411C96:                             ; CODE XREF: .text:0041192Dj
                                            ; DATA XREF: .text:00411F28o
    test    byte ptr [esp+4Ch], 20h         ; case 0x5
    jz      short loc_411CAC

    loc_411C9D:                             ; CODE XREF: .text:0041192Dj
                                            ; DATA XREF: .text:00411F28o
    mov     eax, 1                          ; case 0x4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411CAC:                             ; CODE XREF: .text:00411C9Bj
    mov     ebp, [esi+36h]
    cmp     ebp, 0FFFFFFFFh
    jz      short loc_411CBF
    push    ebp
    push    ebx
    call    sub_47E570
    test    eax, eax
    jnz     short loc_411D22

    loc_411CBF:                             ; CODE XREF: .text:00411CB2j
    or      eax, 0FFFFFFFFh
    lea     ecx, [esp+38h]
    mov     [esp+30h], eax
    mov     [esp+34h], eax
    mov     [esp+38h], eax
    mov     [esp+3Ch], eax
    lea     eax, [esp+3Ch]
    lea     edx, [esp+34h]
    push    eax
    push    ecx
    mov     ecx, [ebx+9Ah]
    lea     eax, [esp+38h]
    push    edx
    push    eax
    push    offset aQuerylandingpa          ; "QueryLandingPad"
    call    sub_4B0BC0
    xor     ebp, ebp
    lea     edi, [esp+30h]

    loc_411CFC:                             ; CODE XREF: .text:00411D15j
    mov     eax, [edi]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_411D0E
    push    eax
    push    ebx
    call    sub_47E570
    test    eax, eax
    jnz     short loc_411D19

    loc_411D0E:                             ; CODE XREF: .text:00411D01j
    inc     ebp
    add     edi, 4
    cmp     ebp, 4
    jl      short loc_411CFC
    jmp     short loc_411D1F
    ; ---------------------------------------------------------------------------

    loc_411D19:                             ; CODE XREF: .text:00411D0Cj
    mov     ebp, [esp+ebp*4+30h]
    jmp     short loc_411D22
    ; ---------------------------------------------------------------------------

    loc_411D1F:                             ; CODE XREF: .text:00411D17j
    or      ebp, 0FFFFFFFFh

    loc_411D22:                             ; CODE XREF: .text:00411CBDj
                                            ; .text:00411D1Dj
    cmp     ebp, 0FFFFFFFFh
    mov     [esi+36h], ebp
    jnz     short loc_411D47
    mov     ecx, [esp+44h]
    push    offset aLandingAbort_0          ; "Landing aborted: all pads are occupied"
    push    7
    push    ecx
    call    sub_47F780
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411D47:                             ; CODE XREF: .text:00411D28j
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_411D69
    mov     edx, [esi+36h]
    mov     ecx, [esi+16h]
    push    edx
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E250
    mov     edi, eax
    jmp     short loc_411D6B
    ; ---------------------------------------------------------------------------

    loc_411D69:                             ; CODE XREF: .text:00411D53j
    xor     edi, edi

    loc_411D6B:                             ; CODE XREF: .text:00411D67j
    mov     ebx, [esp+44h]
    mov     eax, [ebx+8Ah]
    test    eax, eax
    jz      short loc_411D89
    mov     edx, [eax+92h]
    movsx   eax, word ptr [edx+170h]
    push    eax
    jmp     short loc_411D8B
    ; ---------------------------------------------------------------------------

    loc_411D89:                             ; CODE XREF: .text:00411D77j
    push    0

    loc_411D8B:                             ; CODE XREF: .text:00411D87j
    mov     ecx, edi
    call    sub_44E6C0
    mov     ecx, [ebx+9Ah]
    push    1
    push    0
    push    offset aEndtransport            ; "EndTransport"
    call    InvokeScript
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    push    0Fh
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    mov     byte ptr [esi+5], 5
    or      al, 0E8h
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411DD2:                             ; CODE XREF: .text:0041192Dj
                                            ; DATA XREF: .text:00411F28o
    mov     al, [esp+4Ch]                   ; case 0x6
    xor     edi, edi
    test    al, 40h
    jz      short loc_411DEB
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411DEB:                             ; CODE XREF: .text:00411DDAj
    mov     ecx, [esi+36h]
    push    ecx
    push    ebx
    call    sub_47E570
    test    eax, eax
    jnz     short loc_411E12
    push    offset aLandingAbort_1          ; "Landing aborted: no pads available"
    push    7
    push    ebp
    call    sub_47F780
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411E12:                             ; CODE XREF: .text:00411DF7j
    mov     eax, [ebp+8Ah]
    push    0
    test    eax, eax
    jz      short loc_411E4D
    mov     ecx, [ebp+9Ah]
    push    0
    push    offset aEndtransport            ; "EndTransport"
    call    InvokeScript
    mov     edx, [esi+36h]
    mov     eax, [esi+16h]
    mov     ecx, [ebp+8Ah]
    push    0
    push    edx
    push    eax
    push    ecx
    call    sub_48AAC0
    mov     edi, 1
    jmp     short loc_411E5B
    ; ---------------------------------------------------------------------------

    loc_411E4D:                             ; CODE XREF: .text:00411E1Cj
    mov     edx, [esi+36h]
    mov     eax, [esi+16h]
    push    edx
    push    eax
    push    ebp
    call    sub_48AAC0

    loc_411E5B:                             ; CODE XREF: .text:00411E4Bj
    test    edi, edi
    jnz     loc_411EFE
    mov     ecx, [ebp+92h]
    movsx   edx, word ptr [ebp+108h]
    cmp     edx, [ecx+1FAh]
    jnb     loc_411EFE
    mov     ecx, [esi+16h]
    mov     eax, [ecx+92h]
    mov     eax, [eax+241h]
    test    ah, 2
    jz      short loc_411EFE
    test    al, 40h
    jz      short loc_411EFE
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FCC40
    fnstsw  ax
    test    ah, 40h
    jz      short loc_411EFE
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    test    edi, edi
    jz      short loc_411EF5
    mov     ecx, [esi+16h]
    push    0
    push    0
    push    0
    push    0
    push    ecx
    push    ecx
    mov     ecx, esp
    push    offset aSelfrepair              ; "SELFREPAIR"
    call    sub_438760
    mov     ecx, edi
    call    sub_43A0C0
    push    eax
    push    ebp
    call    sub_43ACB0
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411EF5:                             ; CODE XREF: .text:00411EBDj
    xor     eax, eax
    push    eax
    push    ebp
    call    sub_43ACB0

    loc_411EFE:                             ; CODE XREF: .text:00411E5Dj
                                            ; .text:00411E76j ...
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411F0D:                             ; CODE XREF: .text:00411927j
                                            ; .text:00411938j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411F1C:                             ; CODE XREF: .text:00411A50j
    mov     ebp, [esp+ebp*4+20h]
    jmp     loc_411A62
    ; ---------------------------------------------------------------------------
    align 4
    off_411F28 dd offset loc_411934         ; DATA XREF: .text:0041192Dr
    dd offset loc_411A03                    ; jump table for switch statement
    dd offset loc_411B8F
    dd offset loc_411BC3
    dd offset loc_411C9D
    dd offset loc_411C96
    dd offset loc_411DD2
    align 10h
    sub     esp, 1Ch
    push    ebx
    mov     ebx, [esp+2Ch]
    push    ebp
    push    esi
    test    ebx, 1000Ah
    push    edi
    jz      loc_411FEA
    mov     esi, [esp+34h]
    mov     eax, [esi+4Ah]
    test    eax, eax
    jnz     loc_4120D2
    mov     ebx, [esp+30h]
    test    dword ptr [ebx+110h], 300000h
    jz      loc_4120D2
    push    56h
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    test    edi, edi
    jz      short loc_411FD2
    mov     ecx, [esi+16h]
    push    0
    push    0
    lea     eax, [esi+22h]
    push    0
    push    eax
    push    ecx
    push    ecx
    mov     ecx, esp
    push    offset aVtol_seekattac          ; "VTOL_SEEKATTACK"
    call    sub_438760
    mov     ecx, edi
    call    sub_43A0C0
    push    eax
    push    ebx
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411FD2:                             ; CODE XREF: .text:00411F98j
    xor     eax, eax
    push    eax
    push    ebx
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_411FEA:                             ; CODE XREF: .text:00411F61j
    mov     edi, [esp+34h]
    mov     eax, [edi+16h]
    test    eax, eax
    jnz     short loc_41206E
    mov     ecx, [edi+42h]
    test    ch, 2
    jz      short loc_41206A
    mov     eax, [edi+4Ah]
    test    eax, eax
    jnz     loc_4120D2
    push    56h
    call    sub_4B4F10
    mov     edi, [esp+34h]
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jz      short loc_412052
    push    0
    push    0
    lea     edx, [edi+6Ah]
    push    0
    push    edx
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aVtol_seekattac          ; "VTOL_SEEKATTACK"
    call    sub_438760
    mov     ecx, esi
    call    sub_43A0C0
    push    eax
    push    edi
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412052:                             ; CODE XREF: .text:0041201Aj
    xor     eax, eax
    push    eax
    push    edi
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41206A:                             ; CODE XREF: .text:00411FFBj
    test    eax, eax
    jz      short loc_412084

    loc_41206E:                             ; CODE XREF: .text:00411FF3j
    add     eax, 6Ah
    lea     ecx, [edi+22h]
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax

    loc_412084:                             ; CODE XREF: .text:0041206Cj
    mov     eax, [edi+3Eh]
    mov     esi, [esp+30h]
    test    eax, eax
    jz      short loc_4120E1
    movsx   ecx, word ptr [esi+74h]
    movsx   edx, word ptr [edi+30h]
    movsx   eax, word ptr [esi+6Ch]
    sub     ecx, edx
    sub     esp, 8
    mov     [esp+38h], ecx
    sub     esp, 8
    movsx   ecx, word ptr [edi+2Eh]
    fild    dword ptr [esp+40h]
    sub     eax, ecx
    fstp    qword ptr [esp+8]
    mov     [esp+40h], eax
    fild    dword ptr [esp+40h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, [edi+3Eh]
    jl      short loc_4120E1

    loc_4120D2:                             ; CODE XREF: .text:00411F70j
                                            ; .text:00411F84j ...
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4120E1:                             ; CODE XREF: .text:0041208Dj
                                            ; .text:004120D0j
    xor     eax, eax
    mov     al, [edi+5]
    cmp     eax, 6                          ; switch 7 cases
    ja      loc_4126DF                      ; default
    jmp     ds:off_4126F0[eax*4]            ; switch jump

    loc_4120F6:                             ; DATA XREF: .text:004126F0o
    cmp     dword ptr [esi], 0              ; case 0x0
    jz      loc_4126DF                      ; default
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    test    ah, 8
    jz      loc_4126DF                      ; default
    push    offset aAttacking               ; "Attacking"
    mov     ecx, edi
    call    sub_438880
    push    3
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_41213F
    push    2
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_41213F:                             ; CODE XREF: .text:00412131j
    push    1
    push    1
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     al, [ecx+2Eh]
    and     al, 3
    cmp     al, 1
    jnz     loc_41252D                      ; case 0x3
    push    2
    push    esi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_41217F
    lea     ecx, [esi+6Ah]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_412181
    ; ---------------------------------------------------------------------------

    loc_41217F:                             ; CODE XREF: .text:0041216Dj
    xor     ebx, ebx

    loc_412181:                             ; CODE XREF: .text:0041217Dj
    mov     edx, [esi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4121BA:                             ; CODE XREF: .text:004120EFj
                                            ; DATA XREF: .text:004126F0o
    push    3                               ; case 0x1
    mov     ecx, esi
    call    sub_489800
    push    0
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [edi+2Ah]
    mov     edx, [esi+72h]
    mov     ecx, [edi+22h]
    sub     eax, edx
    lea     ebp, [edi+22h]
    lea     ebx, [esi+6Ah]
    mov     [esp+30h], eax
    sub     esp, 8
    fild    dword ptr [esp+38h]
    mov     eax, [ebx]
    sub     esp, 8
    sub     ecx, eax
    fstp    qword ptr [esp+8]
    mov     [esp+40h], ecx
    fild    dword ptr [esp+40h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, 1E00000h
    jge     loc_41252D                      ; case 0x3
    push    ebp
    push    ebx
    call    sub_48A980
    mov     ebp, eax
    push    8C00000h
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    8C00000h
    push    ebp
    call    sub_4B7123
    mov     ecx, [ebx]
    add     esp, 8
    add     esi, ecx
    mov     ecx, [ebx+4]
    mov     ebx, [ebx+8]
    push    36h
    neg     eax
    add     ebx, eax
    mov     [esp+14h], esi
    mov     [esp+18h], ecx
    mov     [esp+1Ch], ebx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_412278
    lea     edx, [esp+10h]
    mov     ecx, eax
    push    edx
    push    edi
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_41227A
    ; ---------------------------------------------------------------------------

    loc_412278:                             ; CODE XREF: .text:00412265j
    xor     esi, esi

    loc_41227A:                             ; CODE XREF: .text:00412276j
    push    3C0h
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, [edi+6]
    or      al, 0E2h
    mov     [edi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4122A5:                             ; CODE XREF: .text:004120EFj
                                            ; DATA XREF: .text:004126F0o
    mov     eax, [edi+2Ah]                  ; case 0x2
    mov     ecx, [esi+72h]
    sub     eax, ecx
    mov     ecx, [edi+22h]
    lea     ebp, [edi+22h]
    lea     ebx, [esi+6Ah]
    mov     [esp+30h], eax
    sub     esp, 8
    fild    dword ptr [esp+38h]
    mov     esi, [ebx]
    sub     esp, 8
    sub     ecx, esi
    fstp    qword ptr [esp+8]
    mov     [esp+40h], ecx
    fild    dword ptr [esp+40h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    push    ebp
    push    ebx
    mov     esi, eax
    call    sub_48A980
    push    4000h
    mov     [esp+34h], eax
    mov     eax, esi
    cdq
    sub     eax, edx
    mov     ebp, eax
    sar     ebp, 1
    call    GetRandom
    push    ebp
    mov     edx, [esp+34h]
    lea     eax, [eax+edx-2000h]
    push    eax
    mov     [esp+38h], eax
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    mov     eax, [esp+30h]
    push    ebp
    push    eax
    neg     esi
    call    sub_4B7123
    mov     ecx, [ebx]
    add     esp, 8
    add     esi, ecx
    mov     ecx, [ebx+4]
    mov     ebx, [ebx+8]
    push    36h
    neg     eax
    add     ebx, eax
    mov     [esp+14h], esi
    mov     [esp+18h], ecx
    mov     [esp+1Ch], ebx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_412368
    lea     ecx, [esp+10h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_41236A
    ; ---------------------------------------------------------------------------

    loc_412368:                             ; CODE XREF: .text:00412355j
    xor     esi, esi

    loc_41236A:                             ; CODE XREF: .text:00412366j
    push    1E0h
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 100E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412394:                             ; CODE XREF: .text:004120EFj
                                            ; DATA XREF: .text:004126F0o
    test    bl, 0E0h                        ; case 0x4
    jz      short loc_4123A8
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4123A8:                             ; CODE XREF: .text:00412397j
    mov     eax, TAdynmemStructPtr
    mov     ebp, [esi+92h]
    mov     ecx, [eax+391E9h]
    movsx   edx, word ptr [ebp+21Ch]
    mov     eax, [ecx+0D3Ch]
    mov     [esp+30h], edx
    test    eax, eax
    mov     [esp+34h], eax
    jz      loc_4126DF                      ; default
    fild    dword ptr [esp+30h]
    mov     edx, [esi]
    fadd    st, st
    movsx   eax, word ptr [edx+22h]
    fidiv   dword ptr [esp+34h]
    mov     [esp+30h], eax
    fsqrt
    fmul    ds:flt_4FCC50
    fimul   dword ptr [esp+30h]
    call    __ftol
    mov     ebx, eax
    mov     eax, [edi+16h]
    xor     ecx, ecx
    inc     ebx
    mov     cx, [ebp+216h]
    push    36h
    add     ebx, ecx
    test    eax, eax
    jz      short loc_41242E
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_41244A
    mov     edx, [edi+16h]
    mov     ecx, eax
    push    edx
    push    edi
    call    sub_44E190
    mov     esi, eax
    jmp     short loc_41244C
    ; ---------------------------------------------------------------------------

    loc_41242E:                             ; CODE XREF: .text:00412410j
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_41244A
    lea     ecx, [edi+22h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_41244C
    ; ---------------------------------------------------------------------------

    loc_41244A:                             ; CODE XREF: .text:0041241Cj
                                            ; .text:00412438j
    xor     esi, esi

    loc_41244C:                             ; CODE XREF: .text:0041242Cj
                                            ; .text:00412448j
    push    ebx
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    push    1
    mov     ecx, edi
    call    sub_439E80
    mov     eax, [edi+6]
    or      eax, 100E8h
    mov     [edi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41247F:                             ; CODE XREF: .text:004120EFj
                                            ; DATA XREF: .text:004126F0o
    push    0                               ; case 0x5
    mov     ecx, esi
    call    sub_4898B0
    lea     ebx, [edi+22h]
    push    0
    push    ebx
    push    esi
    call    sub_48A0A0
    lea     ebp, [esi+6Ah]
    push    ebx
    push    ebp
    call    sub_48A980
    mov     edx, [esi+92h]
    xor     esi, esi
    mov     [esp+30h], eax
    mov     si, [edx+216h]
    add     esi, 3C0h
    shl     esi, 10h
    push    esi
    push    eax
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    mov     eax, [esp+30h]
    push    esi
    push    eax
    neg     ebx
    call    sub_4B7123
    mov     esi, [ebp+0]
    mov     ecx, [ebp+4]
    mov     ebp, [ebp+8]
    add     esp, 8
    neg     eax
    add     ebx, esi
    add     ebp, eax
    push    36h
    mov     [esp+14h], ebx
    mov     [esp+18h], ecx
    mov     [esp+1Ch], ebp
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_412510
    lea     ecx, [esp+10h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_412512
    ; ---------------------------------------------------------------------------

    loc_412510:                             ; CODE XREF: .text:004124FDj
    xor     esi, esi

    loc_412512:                             ; CODE XREF: .text:0041250Ej
    push    3C0h
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 0E2h

    loc_41252D:                             ; CODE XREF: .text:004120EFj
                                            ; .text:00412153j ...
    mov     eax, 1                          ; case 0x3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41253C:                             ; CODE XREF: .text:004120EFj
                                            ; DATA XREF: .text:004126F0o
    push    0                               ; case 0x6
    push    esi
    call    sub_48A0F0
    mov     bp, [esi+66h]
    push    5A00000h
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    5A00000h
    push    ebp
    call    sub_4B7123
    mov     ecx, [esi+6Ah]
    lea     ebp, [esi+6Ah]
    add     ebx, ecx
    add     esp, 8
    mov     ecx, [ebp+8]
    mov     edx, [ebp+4]
    neg     eax
    add     ecx, eax
    push    36h
    mov     [esp+14h], ebx
    mov     [esp+18h], edx
    mov     [esp+1Ch], ecx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4125A5
    lea     edx, [esp+10h]
    mov     ecx, eax
    push    edx
    push    edi
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_4125A7
    ; ---------------------------------------------------------------------------

    loc_4125A5:                             ; CODE XREF: .text:00412592j
    xor     ebx, ebx

    loc_4125A7:                             ; CODE XREF: .text:004125A3j
    push    80h
    mov     ecx, ebx
    call    sub_44E730
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 0E2h
    mov     edx, [esi+92h]
    movsx   ecx, word ptr [esi+108h]
    mov     eax, [edx+1FAh]
    shr     eax, 2
    lea     eax, [eax+eax*2]
    cmp     ecx, eax
    jnb     loc_4126CC
    mov     cl, [esp+30h]
    mov     eax, [esi+96h]
    mov     [esp+1Ch], cl
    xor     ebx, ebx
    lea     edx, [esp+1Ch]
    xor     ecx, ecx
    mov     [esp+20h], ebx
    mov     [esp+24h], ebx
    mov     [esp+28h], ebx
    mov     cl, [eax+146h]
    push    edx
    push    0F00h
    push    ebp
    push    ecx
    call    sub_40B530
    mov     ecx, [esp+20h]
    cmp     ecx, ebx
    jnz     short loc_412624
    xor     eax, eax
    jmp     short loc_41262D
    ; ---------------------------------------------------------------------------

    loc_412624:                             ; CODE XREF: .text:0041261Ej
    mov     eax, [esp+24h]
    sub     eax, ecx
    sar     eax, 2

    loc_41262D:                             ; CODE XREF: .text:00412622j
    xor     edx, edx
    cmp     eax, ebx
    setz    dl
    test    dl, dl
    jnz     short loc_4126B7
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     ebp, [esp+20h]
    cmp     ebp, ebx
    jnz     short loc_41264C
    xor     eax, eax
    jmp     short loc_412655
    ; ---------------------------------------------------------------------------

    loc_41264C:                             ; CODE XREF: .text:00412646j
    mov     eax, [esp+24h]
    sub     eax, ebp
    sar     eax, 2

    loc_412655:                             ; CODE XREF: .text:0041264Aj
    push    eax
    call    GetRandom
    mov     ebx, [ebp+eax*4+0]
    push    56h
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jz      short loc_41268E
    push    0
    push    0
    push    0
    push    0
    push    ebx
    push    ecx
    mov     ecx, esp
    push    offset aVtol_landing            ; "VTOL_LANDING"
    call    sub_438760
    mov     ecx, ebp
    call    sub_43A0C0
    jmp     short loc_412690
    ; ---------------------------------------------------------------------------

    loc_41268E:                             ; CODE XREF: .text:0041266Dj
    xor     eax, eax

    loc_412690:                             ; CODE XREF: .text:0041268Cj
    push    eax
    push    esi
    call    sub_43ACB0
    mov     dword ptr [edi+6], 0
    mov     eax, [esp+20h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4126B7:                             ; CODE XREF: .text:00412636j
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4126CC:                             ; CODE XREF: .text:004125DDj
    mov     byte ptr [edi+5], 3
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4126DF:                             ; CODE XREF: .text:004120E9j
                                            ; .text:004120F9j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_4126F0 dd offset loc_4120F6         ; DATA XREF: .text:004120EFr
    dd offset loc_4121BA                    ; jump table for switch statement
    dd offset loc_4122A5
    dd offset loc_41252D
    dd offset loc_412394
    dd offset loc_41247F
    dd offset loc_41253C
    align 8
    sub     esp, 1Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+2Ch]
    push    edi
    mov     edi, [esp+34h]
    mov     eax, [esi+10h]
    mov     ebx, [eax+0DCh]
    mov     eax, [esp+38h]
    test    eax, 1000Ah
    jz      short loc_41279A
    mov     eax, [edi+4Ah]
    test    eax, eax
    jnz     loc_412891
    test    dword ptr [esi+110h], 300000h
    jz      loc_412891
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    jz      loc_4127F6
    mov     edx, [edi+16h]
    push    0
    push    0
    lea     ecx, [edi+22h]
    push    0
    push    ecx
    push    edx
    push    ecx
    mov     ecx, esp
    push    offset aVtol_seekattac          ; "VTOL_SEEKATTACK"
    call    sub_438760
    mov     ecx, ebx
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41279A:                             ; CODE XREF: .text:00412731j
    mov     eax, [edi+16h]
    xor     ebp, ebp
    cmp     eax, ebp
    jnz     short loc_412812
    mov     ecx, [edi+42h]
    test    ch, 2
    jz      short loc_41280E
    cmp     [edi+4Ah], ebp
    jnz     loc_412891
    push    56h
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    cmp     edi, ebp
    jz      short loc_4127F6
    push    ebp
    push    ebp
    lea     eax, [esi+6Ah]
    push    ebp
    push    eax
    push    ebp
    push    ecx
    mov     ecx, esp
    push    offset aVtol_seekattac          ; "VTOL_SEEKATTACK"
    call    sub_438760
    mov     ecx, edi
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4127F6:                             ; CODE XREF: .text:0041275Cj
                                            ; .text:004127C2j
    xor     eax, eax
    push    eax
    push    esi
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41280E:                             ; CODE XREF: .text:004127A9j
    cmp     eax, ebp
    jz      short loc_412828

    loc_412812:                             ; CODE XREF: .text:004127A1j
    add     eax, 6Ah
    lea     ecx, [edi+22h]
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax

    loc_412828:                             ; CODE XREF: .text:00412810j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esi+82h]
    cmp     ecx, [edx+142B7h]
    jnz     short loc_412849
    push    1Eh
    mov     ecx, edi
    call    sub_439E80
    mov     byte ptr [edi+5], 2

    loc_412849:                             ; CODE XREF: .text:0041283Aj
    cmp     [edi+3Eh], ebp
    jz      short loc_4128A0
    movsx   eax, word ptr [edi+30h]
    movsx   ecx, word ptr [esi+74h]
    movsx   edx, word ptr [edi+2Eh]
    sub     ecx, eax
    sub     esp, 8
    movsx   eax, word ptr [esi+6Ch]
    mov     [esp+3Ch], ecx
    sub     eax, edx
    fild    dword ptr [esp+3Ch]
    mov     [esp+3Ch], eax
    sub     esp, 8
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+44h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, [edi+3Eh]
    jl      short loc_4128A0

    loc_412891:                             ; CODE XREF: .text:00412738j
                                            ; .text:00412748j ...
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4128A0:                             ; CODE XREF: .text:0041284Cj
                                            ; .text:0041288Fj
    xor     eax, eax
    mov     al, [edi+5]
    cmp     eax, 5                          ; switch 6 cases
    ja      loc_412D0C                      ; default
    jmp     ds:off_412D1C[eax*4]            ; switch jump

    loc_4128B5:                             ; DATA XREF: .text:00412D1Co
    cmp     [esi], ebp                      ; case 0x0
    jz      loc_412D0C                      ; default
    mov     ecx, [esi+92h]
    mov     eax, [ecx+241h]
    test    ah, 8
    jz      loc_412D0C                      ; default
    push    offset aAttacking               ; "Attacking"
    mov     ecx, edi
    call    sub_438880
    push    3
    mov     ecx, esi
    call    sub_4898B0
    cmp     [esi+86h], ebp
    jz      short loc_4128FA
    push    2
    push    0FFFFFFFFh
    push    ebp
    push    esi
    call    sub_48AAC0

    loc_4128FA:                             ; CODE XREF: .text:004128EDj
    push    1
    push    1
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     loc_412CEA
    push    2
    push    esi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_41293C
    lea     ecx, [esi+6Ah]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_41293E
    ; ---------------------------------------------------------------------------

    loc_41293C:                             ; CODE XREF: .text:0041292Aj
    xor     ebx, ebx

    loc_41293E:                             ; CODE XREF: .text:0041293Aj
    mov     edx, [esi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412977:                             ; CODE XREF: .text:004128AEj
                                            ; DATA XREF: .text:00412D1Co
    push    3                               ; case 0x1
    mov     ecx, esi
    call    sub_489800
    mov     eax, [edi+2Ah]
    mov     ecx, [esi+72h]
    sub     eax, ecx
    mov     ecx, [edi+22h]
    lea     ebp, [edi+22h]
    lea     ebx, [esi+6Ah]
    mov     [esp+34h], eax
    sub     esp, 8
    fild    dword ptr [esp+3Ch]
    mov     esi, [ebx]
    sub     esp, 8
    sub     ecx, esi
    fstp    qword ptr [esp+8]
    mov     [esp+44h], ecx
    fild    dword ptr [esp+44h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    push    ebp
    push    ebx
    mov     esi, eax
    call    sub_48A980
    mov     ebp, eax
    mov     eax, esi
    cdq
    sub     eax, edx
    push    4000h
    mov     esi, eax
    sar     esi, 1
    call    GetRandom
    lea     eax, [eax+ebp-2000h]
    push    esi
    push    eax
    mov     [esp+3Ch], eax
    call    sub_4B70EF
    mov     edx, [esp+3Ch]
    add     esp, 8
    mov     ebp, eax
    push    esi
    push    edx
    neg     ebp
    call    sub_4B7123
    mov     ecx, [ebx]
    mov     edx, [ebx+4]
    mov     ebx, [ebx+8]
    add     esp, 8
    neg     eax
    add     ecx, ebp
    add     ebx, eax
    push    36h
    mov     [esp+14h], ecx
    mov     [esp+18h], edx
    mov     [esp+1Ch], ebx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_412A42
    lea     ecx, [esp+10h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    push    80h
    jmp     short loc_412A8F
    ; ---------------------------------------------------------------------------

    loc_412A42:                             ; CODE XREF: .text:00412A2Aj
    xor     esi, esi
    push    80h
    jmp     short loc_412A8F

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; case 0x2

    sub_412A4B proc near                    ; CODE XREF: .text:004128AEj
                                            ; DATA XREF: .text:00412D1Co
    push    ebp
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [edi+16h]
    push    ebp
    cmp     eax, ebp
    jz      short loc_412A64
    push    eax
    push    esi
    call    sub_48A060
    jmp     short loc_412A6E
    ; ---------------------------------------------------------------------------

    loc_412A64:                             ; CODE XREF: sub_412A4B+Ej
    lea     edx, [edi+22h]
    push    edx
    push    esi
    call    sub_48A0A0

    loc_412A6E:                             ; CODE XREF: sub_412A4B+17j
    push    36h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_412A8C
    lea     ecx, [edi+22h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_412A8E
    ; ---------------------------------------------------------------------------

    loc_412A8C:                             ; CODE XREF: sub_412A4B+2Fj
    xor     esi, esi

    loc_412A8E:                             ; CODE XREF: sub_412A4B+3Fj
    push    ebx

    loc_412A8F:                             ; CODE XREF: .text:00412A40j
                                            ; .text:00412A49j
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 100E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    sub_412A4B endp ; sp =  2Ch

    ; ---------------------------------------------------------------------------

    loc_412AB4:                             ; CODE XREF: .text:004128AEj
                                            ; DATA XREF: .text:00412D1Co
    mov     edx, [esi+72h]                  ; case 0x3
    mov     ecx, [edi+2Ah]
    mov     eax, [esi+6Ah]
    mov     ebp, [edi+22h]
    sub     edx, ecx
    sub     eax, ebp
    push    edx
    push    eax
    call    sub_4B715A
    lea     esi, [ebx+ebx*2]
    add     esp, 8
    shl     esi, 10h
    mov     ebp, eax
    push    esi
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    esi
    push    ebp
    call    sub_4B7123
    mov     ecx, [edi+22h]
    mov     edx, [edi+2Ah]
    mov     esi, [edi+26h]
    add     esp, 8
    neg     eax
    add     ecx, ebx
    add     edx, eax
    push    36h
    mov     [esp+14h], ecx
    mov     [esp+18h], esi
    mov     [esp+1Ch], edx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_412B28
    lea     ecx, [esp+10h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_412B2A
    ; ---------------------------------------------------------------------------

    loc_412B28:                             ; CODE XREF: .text:00412B15j
    xor     esi, esi

    loc_412B2A:                             ; CODE XREF: .text:00412B26j
    push    80h
    call    GetRandom
    add     eax, 80h
    push    eax
    jmp     loc_412CD4
    ; ---------------------------------------------------------------------------

    loc_412B3F:                             ; CODE XREF: .text:004128AEj
                                            ; DATA XREF: .text:00412D1Co
    mov     edx, [esi+92h]                  ; case 0x4
    movsx   ecx, word ptr [esi+108h]
    mov     eax, [edx+1FAh]
    shr     eax, 2
    lea     eax, [eax+eax*2]
    cmp     ecx, eax
    jnb     loc_412C55
    mov     dl, [esp+34h]
    lea     eax, [esp+1Ch]
    mov     [esp+1Ch], dl
    mov     edx, [esi+96h]
    push    eax
    xor     eax, eax
    mov     [esp+24h], ebp
    mov     [esp+28h], ebp
    mov     [esp+2Ch], ebp
    mov     al, [edx+146h]
    lea     ecx, [esi+6Ah]
    push    0F00h
    push    ecx
    push    eax
    call    sub_40B530
    mov     ebp, [esp+20h]
    test    ebp, ebp
    jnz     short loc_412BA2
    xor     eax, eax
    jmp     short loc_412BAB
    ; ---------------------------------------------------------------------------

    loc_412BA2:                             ; CODE XREF: .text:00412B9Cj
    mov     eax, [esp+24h]
    sub     eax, ebp
    sar     eax, 2

    loc_412BAB:                             ; CODE XREF: .text:00412BA0j
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    test    cl, cl
    jnz     loc_412C4C
    push    0
    mov     ecx, edi
    call    sub_4388D0
    mov     ebx, [esp+20h]
    test    ebx, ebx
    jnz     short loc_412BCF
    xor     eax, eax
    jmp     short loc_412BD8
    ; ---------------------------------------------------------------------------

    loc_412BCF:                             ; CODE XREF: .text:00412BC9j
    mov     eax, [esp+24h]
    sub     eax, ebx
    sar     eax, 2

    loc_412BD8:                             ; CODE XREF: .text:00412BCDj
    push    eax
    call    GetRandom
    mov     ebp, [ebx+eax*4]
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    jz      short loc_412C10
    push    0
    push    0
    push    0
    push    0
    push    ebp
    push    ecx
    mov     ecx, esp
    push    offset aVtol_landing            ; "VTOL_LANDING"
    call    sub_438760
    mov     ecx, ebx
    call    sub_43A0C0
    jmp     short loc_412C12
    ; ---------------------------------------------------------------------------

    loc_412C10:                             ; CODE XREF: .text:00412BEFj
    xor     eax, eax

    loc_412C12:                             ; CODE XREF: .text:00412C0Ej
    push    eax
    push    esi
    call    sub_43ACB0
    lea     ecx, [esp+1Ch]
    mov     dword ptr [edi+6], 0
    mov     edx, [esp+24h]
    mov     eax, [esp+20h]
    push    edx
    push    eax
    call    nullsub_1
    mov     ecx, [esp+20h]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412C4C:                             ; CODE XREF: .text:00412BB4j
    push    ebp
    call    sub_4B4F20
    add     esp, 4

    loc_412C55:                             ; CODE XREF: .text:00412B5Aj
    push    2
    call    GetRandom
    mov     bp, [esi+66h]
    test    eax, eax
    jz      short loc_412C6B
    add     bp, 4000h
    jmp     short loc_412C70
    ; ---------------------------------------------------------------------------

    loc_412C6B:                             ; CODE XREF: .text:00412C62j
    sub     bp, 4000h

    loc_412C70:                             ; CODE XREF: .text:00412C69j
    shl     ebx, 10h
    push    ebx
    push    ebp
    mov     [esp+3Ch], ebx
    call    sub_4B70EF
    mov     edx, [esp+3Ch]
    add     esp, 8
    mov     ebx, eax
    push    edx
    push    ebp
    neg     ebx
    call    sub_4B7123
    mov     ecx, [esi+6Ah]
    mov     edx, [esi+6Eh]
    mov     esi, [esi+72h]
    add     esp, 8
    neg     eax
    add     ecx, ebx
    add     esi, eax
    push    36h
    mov     [esp+14h], ecx
    mov     [esp+18h], edx
    mov     [esp+1Ch], esi
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_412CCD
    lea     ecx, [esp+10h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_412CCF
    ; ---------------------------------------------------------------------------

    loc_412CCD:                             ; CODE XREF: .text:00412CBAj
    xor     esi, esi

    loc_412CCF:                             ; CODE XREF: .text:00412CCBj
    push    80h

    loc_412CD4:                             ; CODE XREF: .text:00412B3Aj
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 100EAh

    loc_412CEA:                             ; CODE XREF: .text:00412910j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412CF9:                             ; CODE XREF: .text:004128AEj
                                            ; DATA XREF: .text:00412D1Co
    mov     byte ptr [edi+5], 2             ; case 0x5
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412D0C:                             ; CODE XREF: .text:004128A8j
                                            ; .text:004128B7j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_412D1C dd offset loc_4128B5         ; DATA XREF: .text:004128AEr
    dd offset loc_412977                    ; jump table for switch statement
    dd offset sub_412A4B
    dd offset loc_412AB4
    dd offset loc_412B3F
    dd offset loc_412CF9
    align 10h
    sub     esp, 38h
    push    ebx
    push    ebp
    mov     ebp, [esp+4Ch]
    push    esi
    test    ebp, 10008h
    push    edi
    jz      loc_412DDA
    mov     esi, [esp+50h]
    mov     eax, [esi+4Ah]
    test    eax, eax
    jnz     loc_412F8F
    mov     ebx, [esp+4Ch]
    test    dword ptr [ebx+110h], 300000h
    jz      loc_412F8F
    push    56h
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    test    edi, edi
    jz      short loc_412DC2
    mov     ecx, [esi+16h]
    push    0
    push    0
    lea     eax, [esi+22h]
    push    0
    push    eax
    push    ecx
    push    ecx
    mov     ecx, esp
    push    offset aVtol_seekattac          ; "VTOL_SEEKATTACK"
    call    sub_438760
    mov     ecx, edi
    call    sub_43A0C0
    push    eax
    push    ebx
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412DC2:                             ; CODE XREF: .text:00412D88j
    xor     eax, eax
    push    eax
    push    ebx
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412DDA:                             ; CODE XREF: .text:00412D51j
    mov     edi, [esp+50h]
    xor     ebx, ebx
    cmp     [edi+16h], ebx
    jnz     short loc_412E54
    mov     eax, [edi+42h]
    test    ah, 2
    jz      short loc_412E54
    cmp     [edi+4Ah], ebx
    jnz     loc_412F8F
    push    56h
    call    sub_4B4F10
    mov     edi, [esp+50h]
    mov     esi, eax
    add     esp, 4
    cmp     esi, ebx
    jz      short loc_412E3C
    push    ebx
    push    ebx
    lea     edx, [edi+6Ah]
    push    ebx
    push    edx
    push    ebx
    push    ecx
    mov     ecx, esp
    push    offset aVtol_seekattac          ; "VTOL_SEEKATTACK"
    call    sub_438760
    mov     ecx, esi
    call    sub_43A0C0
    push    eax
    push    edi
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412E3C:                             ; CODE XREF: .text:00412E08j
    xor     eax, eax
    push    eax
    push    edi
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412E54:                             ; CODE XREF: .text:00412DE3j
                                            ; .text:00412DEBj
    mov     esi, [esp+4Ch]
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esi+82h]
    mov     edx, [ecx+142B7h]
    cmp     eax, edx
    jnz     loc_412F47
    mov     eax, [ecx+1422Bh]
    add     esi, 6Ah
    cdq
    sub     eax, edx
    sar     eax, 1
    shl     eax, 10h
    mov     [esp+30h], eax
    mov     eax, [ecx+1422Fh]
    cdq
    sub     eax, edx
    lea     ecx, [esp+30h]
    sar     eax, 1
    shl     eax, 10h
    push    ecx
    push    esi
    mov     [esp+40h], eax
    call    sub_48A980
    mov     ebp, eax
    push    3200000h
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    3200000h
    push    ebp
    call    sub_4B7123
    add     esp, 8
    lea     edx, [esp+10h]
    neg     eax
    mov     [esp+18h], eax
    push    edx
    lea     eax, [esp+40h]
    xor     ecx, ecx
    push    esi
    push    eax
    mov     [esp+1Ch], ebx
    mov     [esp+20h], ecx
    call    sub_40F790
    mov     ecx, [eax]
    push    36h
    mov     [esp+24h], ecx
    mov     edx, [eax+4]
    mov     [esp+28h], edx
    mov     eax, [eax+8]
    mov     [esp+2Ch], eax
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_412F19
    lea     ecx, [esp+20h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_412F1B
    ; ---------------------------------------------------------------------------

    loc_412F19:                             ; CODE XREF: .text:00412F06j
    xor     esi, esi

    loc_412F1B:                             ; CODE XREF: .text:00412F17j
    push    80h
    mov     ecx, esi
    call    sub_44E730
    mov     ecx, [edi+6]
    push    esi
    or      cl, 0E0h
    mov     [edi+6], ecx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412F47:                             ; CODE XREF: .text:00412E6Cj
    cmp     [edi+3Eh], ebx
    jz      short loc_412F9E

    loc_412F4C:                             ; DATA XREF: .data:00508D18o
    movsx   edx, word ptr [edi+30h]
    movsx   eax, word ptr [esi+74h]
    movsx   ecx, word ptr [edi+2Eh]
    sub     eax, edx
    sub     esp, 8
    movsx   edx, word ptr [esi+6Ch]
    mov     [esp+54h], eax
    sub     edx, ecx
    fild    dword ptr [esp+54h]
    mov     [esp+54h], edx
    sub     esp, 8
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+5Ch]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, [edi+3Eh]
    jl      short loc_412F9E

    loc_412F8F:                             ; CODE XREF: .text:00412D60j
                                            ; .text:00412D74j ...
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_412F9E:                             ; CODE XREF: .text:00412F4Aj
                                            ; .text:00412F8Dj
    xor     eax, eax
    mov     al, [edi+5]
    sub     eax, ebx
    jz      loc_413397
    dec     eax
    jnz     loc_41345F
    push    3
    mov     ecx, esi
    call    sub_489800
    push    ebx
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [edi+16h]
    push    ebx
    push    eax
    push    esi
    call    sub_48A060
    and     ebp, 0E0h
    jz      loc_41315B
    mov     ecx, [edi+16h]
    lea     eax, [esi+6Ah]
    add     ecx, 6Ah
    push    ecx
    push    eax
    call    sub_48A980
    mov     ebx, eax
    push    140000h
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    neg     eax
    push    140000h
    push    ebx
    mov     [esp+18h], eax
    call    sub_4B7123
    mov     dx, [esi+66h]
    add     esp, 8
    neg     eax
    mov     [esp+18h], eax
    mov     eax, 140000h
    push    eax
    lea     eax, [esp+40h]
    push    edx
    push    eax
    call    sub_4103A0
    mov     ecx, [eax]
    mov     [esp+20h], ecx
    mov     ecx, [esp+12h]
    mov     edx, [eax+4]
    mov     [esp+24h], edx
    mov     edx, [esp+1Ah]
    mov     eax, [eax+8]
    imul    ecx, [esp+22h]
    mov     [esp+28h], eax
    imul    edx, [esp+2Ah]
    add     ecx, edx
    test    cx, cx
    jle     loc_413159
    mov     eax, [esi+92h]
    mov     eax, [eax+192h]
    lea     ebp, [eax+eax*2]
    mov     ax, [esi+66h]
    mov     [esp+4Ch], eax
    lea     ebp, [ebp+ebp*4+0]
    shl     ebp, 1
    push    ebp
    push    eax
    call    sub_4B70EF
    mov     ecx, [esp+54h]
    add     esp, 8
    mov     ebx, eax
    push    ebp
    push    ecx
    neg     ebx
    call    sub_4B7123
    mov     ecx, [esi+6Ah]
    mov     edx, [esi+6Eh]
    add     ebx, ecx
    mov     ecx, [esi+72h]
    neg     eax
    mov     [esp+1Ch], edx
    mov     edx, [esi+92h]
    add     ecx, eax
    mov     ax, [esi+66h]
    add     esp, 8
    mov     [esp+10h], ebx
    mov     [esp+18h], ecx
    mov     ebp, [edx+192h]
    push    ebp
    push    eax
    mov     [esp+54h], eax
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    mov     eax, [esp+4Ch]
    push    ebp
    push    eax
    neg     ebx
    call    sub_4B7123
    add     esp, 8
    xor     ecx, ecx
    neg     eax
    push    2Ch
    mov     [esp+24h], ebx
    mov     [esp+28h], ecx
    mov     [esp+2Ch], eax
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_413112
    lea     ecx, [esp+20h]
    lea     edx, [esp+10h]
    push    ecx
    push    edx
    push    edi
    mov     ecx, eax
    call    sub_44E740
    mov     ebx, eax
    jmp     short loc_413114
    ; ---------------------------------------------------------------------------

    loc_413112:                             ; CODE XREF: .text:004130FAj
    xor     ebx, ebx

    loc_413114:                             ; CODE XREF: .text:00413110j
    mov     eax, [esi+92h]
    movsx   ecx, word ptr [eax+21Ch]
    push    ecx
    mov     ecx, ebx
    call    nullsub_40
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    push    1Eh
    call    GetRandom
    add     eax, 3Ch
    mov     ecx, edi
    push    eax
    call    sub_439E80
    mov     dword ptr [edi+36h], 0
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413159:                             ; CODE XREF: .text:00413054j
    xor     ebx, ebx

    loc_41315B:                             ; CODE XREF: .text:00412FD4j
    cmp     ebp, ebx
    jnz     loc_41332F
    cmp     dword ptr [edi+36h], 5Ah
    jge     loc_41332F
    mov     edx, [edi+16h]
    lea     ebp, [esi+6Ah]
    add     edx, 6Ah
    push    edx
    push    ebp
    call    sub_48A980
    mov     ebx, eax
    push    140000h
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    neg     eax
    push    140000h
    push    ebx
    mov     [esp+18h], eax
    call    sub_4B7123
    neg     eax
    add     esp, 8
    mov     [esp+18h], eax
    mov     eax, 140000h
    lea     ecx, [esp+3Ch]
    push    eax
    mov     ax, [esi+66h]
    push    eax
    push    ecx
    call    sub_4103A0
    mov     edx, [eax]
    mov     [esp+20h], edx
    mov     ecx, [eax+4]
    mov     [esp+24h], ecx
    mov     ecx, [esp+1Ah]
    mov     edx, [eax+8]
    mov     eax, [esp+12h]
    imul    eax, [esp+22h]
    mov     [esp+28h], edx
    imul    ecx, [esp+2Ah]
    add     eax, ecx
    test    ax, ax
    jle     short loc_4131F2
    mov     dword ptr [edi+36h], 0
    jmp     short loc_4131F6
    ; ---------------------------------------------------------------------------

    loc_4131F2:                             ; CODE XREF: .text:004131E7j
    add     dword ptr [edi+36h], 2Dh

    loc_4131F6:                             ; CODE XREF: .text:004131F0j
    mov     eax, [edi+16h]
    mov     edx, [esi+72h]
    sub     esp, 8
    mov     ecx, [eax+72h]
    mov     esi, [eax+6Ah]
    sub     edx, ecx
    mov     ecx, [ebp+0]
    mov     [esp+54h], edx
    sub     ecx, esi
    fild    dword ptr [esp+54h]
    mov     [esp+54h], ecx
    sub     esp, 8
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+5Ch]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    mov     [esp+4Ch], eax
    cmp     word ptr [esp+4Eh], 0A0h
    jle     loc_41330C
    mov     eax, [edi+16h]
    push    2Ch
    lea     edx, [eax+6Ah]
    mov     ecx, edx
    mov     edx, [ecx]
    mov     [esp+14h], edx
    mov     esi, [ecx+4]
    mov     [esp+18h], esi
    mov     esi, [ecx+8]
    mov     [esp+1Ch], esi
    mov     ecx, [eax]
    mov     ecx, [ecx+8]
    lea     ecx, [ecx+ecx*4]
    mov     ebx, ecx
    add     ebx, edx
    lea     edx, [ebx+ecx*8]
    mov     [esp+14h], edx
    mov     eax, [eax]
    mov     eax, [eax+10h]
    lea     eax, [eax+eax*4]
    mov     ecx, eax
    add     ecx, esi
    lea     edx, [ecx+eax*8]
    mov     [esp+1Ch], edx
    call    sub_4B4F10
    add     esp, 4
    mov     [esp+4Ch], eax
    test    eax, eax
    jz      short loc_413302
    mov     ecx, [edi+16h]
    mov     eax, [ecx+92h]
    mov     bp, [ecx+66h]
    mov     eax, [eax+192h]
    cdq
    sub     eax, edx
    mov     esi, eax
    sar     esi, 1
    push    esi
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    esi
    push    ebp
    call    sub_4B7123
    mov     ecx, [edi+16h]
    add     esp, 8
    neg     eax
    mov     ecx, [ecx]
    add     ecx, 8
    mov     edx, [ecx]
    mov     esi, [ecx+4]
    mov     ecx, [ecx+8]
    add     edx, ebx
    mov     [esp+30h], edx
    add     ecx, eax
    lea     edx, [esp+30h]
    lea     eax, [esp+10h]
    push    edx
    mov     [esp+3Ch], ecx
    mov     ecx, [esp+50h]
    push    eax
    push    edi
    mov     [esp+40h], esi
    call    sub_44E740
    jmp     short loc_413304
    ; ---------------------------------------------------------------------------

    loc_413302:                             ; CODE XREF: .text:00413296j
    xor     eax, eax

    loc_413304:                             ; CODE XREF: .text:00413300j
    push    eax
    mov     ecx, edi
    call    sub_4388D0

    loc_41330C:                             ; CODE XREF: .text:0041323Ej
    push    2Dh
    mov     ecx, edi
    call    sub_439E80
    mov     eax, [edi+6]
    or      eax, 100E8h
    mov     [edi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41332F:                             ; CODE XREF: .text:0041315Dj
                                            ; .text:00413167j
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    cmp     ebp, ebx
    jz      short loc_41337C
    mov     ecx, [edi+16h]
    push    ebx
    push    ebx
    push    ebx
    push    ebx
    push    ecx
    push    ecx
    mov     ecx, esp
    push    offset aVtol_evade              ; "VTOL_EVADE"
    call    sub_438760
    mov     ecx, ebp
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43ACB0
    mov     [edi+36h], ebx
    mov     [edi+6], ebx
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41337C:                             ; CODE XREF: .text:00413345j
    xor     eax, eax
    push    eax
    push    esi
    call    sub_43ACB0
    mov     [edi+36h], ebx
    mov     [edi+6], ebx
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413397:                             ; CODE XREF: .text:00412FA5j
    cmp     [esi], ebx
    jz      loc_41345F
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    test    ah, 8
    jz      loc_41345F
    push    offset aAttacking               ; "Attacking"
    mov     ecx, edi
    call    sub_438880
    push    3
    mov     ecx, esi
    call    sub_4898B0
    cmp     [esi+86h], ebx
    jz      short loc_4133DC
    push    2
    push    0FFFFFFFFh
    push    ebx
    push    esi
    call    sub_48AAC0

    loc_4133DC:                             ; CODE XREF: .text:004133CFj
    push    1
    push    1
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     al, [ecx+2Eh]
    and     al, 3
    cmp     al, 1
    jnz     short loc_413444
    push    2
    push    esi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_413418
    lea     ecx, [esi+6Ah]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebp, eax
    jmp     short loc_41341A
    ; ---------------------------------------------------------------------------

    loc_413418:                             ; CODE XREF: .text:00413406j
    xor     ebp, ebp

    loc_41341A:                             ; CODE XREF: .text:00413416j
    mov     edx, [esi+92h]
    mov     ecx, ebp
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebp
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax

    loc_413444:                             ; CODE XREF: .text:004133F0j
    push    1
    mov     ecx, edi
    call    sub_439E80
    mov     [edi+36h], ebx
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41345F:                             ; CODE XREF: .text:00412FACj
                                            ; .text:00413399j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 38h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+0Ch]
    sub     esp, 34h
    test    eax, 10008h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+48h]
    push    edi
    jz      short loc_413505
    mov     eax, [esi+4Ah]
    test    eax, eax
    jnz     loc_4136B8
    mov     ebx, [esp+48h]
    test    dword ptr [ebx+110h], 300000h
    jz      loc_4136B8
    push    56h
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    test    edi, edi
    jz      short loc_4134ED
    mov     ecx, [esi+16h]
    push    0
    push    0
    lea     eax, [esi+22h]
    push    0
    push    eax
    push    ecx
    push    ecx
    mov     ecx, esp
    push    offset aVtol_seekattac          ; "VTOL_SEEKATTACK"
    call    sub_438760
    mov     ecx, edi
    call    sub_43A0C0
    push    eax
    push    ebx
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4134ED:                             ; CODE XREF: .text:004134B3j
    xor     eax, eax
    push    eax
    push    ebx
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413505:                             ; CODE XREF: .text:00413484j
    mov     eax, [esi+16h]
    xor     ebp, ebp
    cmp     eax, ebp
    jnz     short loc_41357D
    mov     eax, [esi+42h]
    test    ah, 2
    jz      short loc_41357D
    cmp     [esi+4Ah], ebp
    jnz     loc_4136B8
    push    56h
    call    sub_4B4F10
    mov     edi, [esp+4Ch]
    mov     esi, eax
    add     esp, 4
    cmp     esi, ebp
    jz      short loc_413565
    push    ebp
    push    ebp
    lea     edx, [edi+6Ah]
    push    ebp
    push    edx
    push    ebp
    push    ecx
    mov     ecx, esp
    push    offset aVtol_seekattac          ; "VTOL_SEEKATTACK"
    call    sub_438760
    mov     ecx, esi
    call    sub_43A0C0
    push    eax
    push    edi
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413565:                             ; CODE XREF: .text:00413531j
    xor     eax, eax
    push    eax
    push    edi
    call    sub_43AD10
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41357D:                             ; CODE XREF: .text:0041350Cj
                                            ; .text:00413514j
    mov     edi, [esp+48h]
    mov     ecx, TAdynmemStructPtr
    mov     eax, [edi+82h]
    mov     edx, [ecx+142B7h]
    cmp     eax, edx
    jnz     loc_413670
    mov     eax, [ecx+1422Bh]
    add     edi, 6Ah
    cdq
    sub     eax, edx
    sar     eax, 1
    shl     eax, 10h
    mov     [esp+28h], eax
    mov     eax, [ecx+1422Fh]
    cdq
    sub     eax, edx
    lea     ecx, [esp+28h]
    sar     eax, 1
    shl     eax, 10h
    push    ecx
    push    edi
    mov     [esp+38h], eax
    call    sub_48A980
    mov     ebp, eax
    push    3200000h
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    3200000h
    push    ebp
    call    sub_4B7123
    add     esp, 8
    lea     edx, [esp+10h]
    neg     eax
    mov     [esp+18h], eax
    push    edx
    lea     eax, [esp+38h]
    xor     ecx, ecx
    push    edi
    push    eax
    mov     [esp+1Ch], ebx
    mov     [esp+20h], ecx
    call    sub_40F790
    mov     ecx, [eax]
    push    36h
    mov     [esp+20h], ecx
    mov     edx, [eax+4]
    mov     [esp+24h], edx
    mov     eax, [eax+8]
    mov     [esp+28h], eax
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_413642
    lea     ecx, [esp+1Ch]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_413644
    ; ---------------------------------------------------------------------------

    loc_413642:                             ; CODE XREF: .text:0041362Fj
    xor     edi, edi

    loc_413644:                             ; CODE XREF: .text:00413640j
    push    80h
    mov     ecx, edi
    call    sub_44E730
    mov     ecx, [esi+6]
    push    edi
    or      cl, 0E0h
    mov     [esi+6], ecx
    mov     ecx, esi
    call    sub_4388D0
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413670:                             ; CODE XREF: .text:00413595j
    cmp     [esi+3Eh], ebp
    jz      short loc_4136C7
    movsx   edx, word ptr [edi+74h]
    movsx   eax, word ptr [esi+30h]
    movsx   ecx, word ptr [edi+6Ch]
    sub     edx, eax
    sub     esp, 8
    mov     [esp+50h], edx
    sub     esp, 8
    movsx   edx, word ptr [esi+2Eh]
    fild    dword ptr [esp+58h]
    sub     ecx, edx
    fstp    qword ptr [esp+8]
    mov     [esp+58h], ecx
    fild    dword ptr [esp+58h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, [esi+3Eh]
    jl      short loc_4136C7

    loc_4136B8:                             ; CODE XREF: .text:0041348Bj
                                            ; .text:0041349Fj ...
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4136C7:                             ; CODE XREF: .text:00413673j
                                            ; .text:004136B6j
    mov     eax, [edi+10h]
    mov     ebx, [eax+0DCh]
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_413B97                      ; default
    jmp     ds:off_413BA8[eax*4]            ; switch jump

    loc_4136E5:                             ; DATA XREF: .text:00413BA8o
    cmp     [edi], ebp                      ; case 0x0
    jz      loc_413B97                      ; default
    mov     ecx, [edi+92h]
    mov     eax, [ecx+241h]
    test    ah, 8
    jz      loc_413B97                      ; default
    push    offset aAttacking               ; "Attacking"
    mov     ecx, esi
    call    sub_438880
    push    3
    mov     ecx, edi
    call    sub_4898B0
    cmp     [edi+86h], ebp
    jz      short loc_41372A
    push    2
    push    0FFFFFFFFh
    push    ebp
    push    edi
    call    sub_48AAC0

    loc_41372A:                             ; CODE XREF: .text:0041371Dj
    push    1
    push    1
    mov     ecx, edi
    call    sub_48B090
    mov     ecx, [edi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     loc_4138F3
    push    2
    push    edi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_41376C
    lea     ecx, [edi+6Ah]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_41376E
    ; ---------------------------------------------------------------------------

    loc_41376C:                             ; CODE XREF: .text:0041375Aj
    xor     ebx, ebx

    loc_41376E:                             ; CODE XREF: .text:0041376Aj
    mov     edx, [edi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, esi
    call    sub_4388D0
    mov     eax, [esi+6]
    or      al, 0E0h
    mov     [esi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4137A7:                             ; CODE XREF: .text:004136DEj
                                            ; DATA XREF: .text:00413BA8o
    push    3                               ; case 0x1
    mov     ecx, edi
    call    sub_489800
    mov     eax, [esi+16h]
    mov     edx, [edi+72h]
    mov     ebp, [edi+6Ah]
    lea     ebx, [edi+6Ah]
    mov     ecx, [eax+72h]
    sub     esp, 8
    sub     ecx, edx
    mov     edx, [eax+6Ah]
    mov     [esp+50h], ecx
    sub     edx, ebp
    fild    dword ptr [esp+50h]
    mov     [esp+50h], edx
    sub     esp, 8
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+58h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    mov     edi, eax
    mov     eax, [esi+16h]
    add     eax, 6Ah
    push    eax
    push    ebx
    call    sub_48A980
    mov     ebp, eax
    mov     eax, edi
    cdq
    sub     eax, edx
    push    4000h
    mov     edi, eax
    sar     edi, 1
    call    GetRandom
    lea     eax, [eax+ebp-2000h]
    push    edi
    push    eax
    mov     [esp+50h], eax
    call    sub_4B70EF
    mov     ecx, [esp+50h]
    add     esp, 8
    mov     ebp, eax
    push    edi
    push    ecx
    neg     ebp
    call    sub_4B7123
    mov     ecx, [ebx]
    mov     edx, [ebx+4]
    mov     ebx, [ebx+8]
    add     esp, 8
    neg     eax
    add     ecx, ebp
    add     ebx, eax
    push    36h
    mov     [esp+20h], ecx
    mov     [esp+24h], edx
    mov     [esp+28h], ebx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_413874
    lea     edx, [esp+1Ch]
    mov     ecx, eax
    push    edx
    push    esi
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_413876
    ; ---------------------------------------------------------------------------

    loc_413874:                             ; CODE XREF: .text:00413861j
    xor     edi, edi

    loc_413876:                             ; CODE XREF: .text:00413872j
    push    80h
    mov     ecx, edi
    call    sub_44E730
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 100E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; case 0x2

    sub_4138A0 proc near                    ; CODE XREF: .text:004136DEj
                                            ; DATA XREF: .text:00413BA8o
    push    ebp
    mov     ecx, edi
    call    sub_4898B0
    mov     eax, [esi+16h]
    push    ebp
    push    eax
    push    edi
    call    sub_48A060
    push    36h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_4138D4
    mov     ecx, [esi+16h]
    add     ecx, 6Ah
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_4138D6
    ; ---------------------------------------------------------------------------

    loc_4138D4:                             ; CODE XREF: sub_4138A0+1Fj
    xor     edi, edi

    loc_4138D6:                             ; CODE XREF: sub_4138A0+32j
    push    ebx
    mov     ecx, edi
    call    sub_44E730
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 100E8h
    mov     [esi+36h], ebp
    mov     [esi+3Ah], ebp

    loc_4138F3:                             ; CODE XREF: .text:00413740j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    sub_4138A0 endp ; sp =  44h

    ; ---------------------------------------------------------------------------

    loc_413902:                             ; CODE XREF: .text:004136DEj
                                            ; DATA XREF: .text:00413BA8o
    mov     edx, [esi+16h]                  ; case 0x3
    push    ebp
    push    edx
    push    edi
    call    sub_49ABB0
    test    eax, eax
    jnz     short loc_413914
    inc     dword ptr [esi+3Ah]

    loc_413914:                             ; CODE XREF: .text:0041390Fj
    cmp     dword ptr [esi+3Ah], 2
    jl      loc_4139AD
    push    10000h
    mov     [esi+3Ah], ebp
    shl     ebx, 10h
    call    GetRandom
    mov     ebp, eax
    push    ebx
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     edi, eax
    neg     edi
    push    ebx
    push    ebp
    call    sub_4B7123
    mov     ecx, [esi+16h]
    add     esp, 8
    add     ecx, 6Ah
    neg     eax
    mov     edx, [ecx]
    push    36h
    add     edx, edi
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    mov     [esp+20h], edx
    add     ecx, eax
    mov     [esp+24h], edi
    mov     [esp+28h], ecx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_413985
    lea     ecx, [esp+1Ch]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    jmp     short loc_413987
    ; ---------------------------------------------------------------------------

    loc_413985:                             ; CODE XREF: .text:00413974j
    xor     eax, eax

    loc_413987:                             ; CODE XREF: .text:00413983j
    push    80h
    mov     ecx, eax
    call    sub_44E730
    mov     eax, [esi+6]
    or      eax, 110E8h
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4139AD:                             ; CODE XREF: .text:00413918j
    mov     edx, [esi+16h]
    lea     eax, [edi+6Ah]
    add     edx, 6Ah
    push    edx
    push    eax
    call    sub_48A980
    cmp     [esi+36h], ebp
    jz      short loc_4139D0
    add     eax, 2000h
    mov     [esi+36h], ebp
    mov     [esp+48h], eax
    jmp     short loc_4139E0
    ; ---------------------------------------------------------------------------

    loc_4139D0:                             ; CODE XREF: .text:004139C0j
    add     eax, 0FFFFE000h
    mov     dword ptr [esi+36h], 1
    mov     [esp+48h], eax

    loc_4139E0:                             ; CODE XREF: .text:004139CEj
    lea     ecx, [ebx+ebx]
    mov     eax, 55555556h
    imul    ecx
    mov     eax, edx
    mov     ecx, [esp+48h]
    shr     eax, 1Fh
    add     edx, eax
    mov     ebx, edx
    shl     ebx, 10h
    push    ebx
    push    ecx
    call    sub_4B70EF
    mov     edx, [esp+50h]
    add     esp, 8
    mov     ebp, eax
    push    ebx
    push    edx
    neg     ebp
    call    sub_4B7123
    mov     ecx, [esi+16h]
    add     esp, 8
    add     ecx, 6Ah
    neg     eax
    mov     edx, [ecx]
    mov     ebx, [ecx+4]
    mov     ecx, [ecx+8]
    sub     edx, ebp
    sub     ecx, eax
    push    36h
    mov     [esp+14h], edx
    mov     [esp+18h], ebx
    mov     [esp+1Ch], ecx
    call    sub_4B4F10
    xor     ebp, ebp
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_413A5B
    mov     edx, [esi+16h]
    lea     ecx, [esp+10h]
    push    ecx
    push    edx
    push    esi
    mov     ecx, eax
    call    sub_44E330
    mov     ebx, eax
    jmp     short loc_413A5D
    ; ---------------------------------------------------------------------------

    loc_413A5B:                             ; CODE XREF: .text:00413A44j
    xor     ebx, ebx

    loc_413A5D:                             ; CODE XREF: .text:00413A59j
    push    10h
    mov     ecx, ebx
    call    sub_44E730
    mov     eax, [edi+92h]
    movsx   ecx, word ptr [eax+21Ch]
    push    ecx
    mov     ecx, ebx
    call    sub_44E6C0
    push    ebx
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 100E8h
    mov     eax, [edi+92h]
    movsx   edx, word ptr [edi+108h]
    mov     eax, [eax+1FAh]
    shr     eax, 2
    lea     ecx, [eax+eax*2]
    cmp     edx, ecx
    jnb     loc_413B88
    mov     dl, [esp+48h]
    mov     ecx, [edi+96h]
    lea     eax, [esp+34h]
    mov     [esp+34h], dl
    push    eax
    xor     edx, edx
    mov     [esp+3Ch], ebp
    mov     [esp+40h], ebp
    mov     [esp+44h], ebp
    mov     dl, [ecx+146h]
    lea     eax, [edi+6Ah]
    push    0F00h
    push    eax
    push    edx
    call    sub_40B530
    mov     ecx, [esp+38h]
    cmp     ecx, ebp
    jnz     short loc_413AED
    xor     eax, eax
    jmp     short loc_413AF6
    ; ---------------------------------------------------------------------------

    loc_413AED:                             ; CODE XREF: .text:00413AE7j
    mov     eax, [esp+3Ch]
    sub     eax, ecx
    sar     eax, 2

    loc_413AF6:                             ; CODE XREF: .text:00413AEBj
    xor     edx, edx
    cmp     eax, ebp
    setz    dl
    test    dl, dl
    jnz     short loc_413B7F
    push    ebp
    mov     ecx, esi
    call    sub_4388D0
    mov     ebx, [esp+38h]
    cmp     ebx, ebp
    jnz     short loc_413B15
    xor     eax, eax
    jmp     short loc_413B1E
    ; ---------------------------------------------------------------------------

    loc_413B15:                             ; CODE XREF: .text:00413B0Fj
    mov     eax, [esp+3Ch]
    sub     eax, ebx
    sar     eax, 2

    loc_413B1E:                             ; CODE XREF: .text:00413B13j
    push    eax
    call    GetRandom
    mov     ebp, [ebx+eax*4]
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    jz      short loc_413B56
    push    0
    push    0
    push    0
    push    0
    push    ebp
    push    ecx
    mov     ecx, esp
    push    offset aVtol_landing            ; "VTOL_LANDING"
    call    sub_438760
    mov     ecx, ebx
    call    sub_43A0C0
    jmp     short loc_413B58
    ; ---------------------------------------------------------------------------

    loc_413B56:                             ; CODE XREF: .text:00413B35j
    xor     eax, eax

    loc_413B58:                             ; CODE XREF: .text:00413B54j
    push    eax
    push    edi
    call    sub_43ACB0
    mov     dword ptr [esi+6], 0
    mov     eax, [esp+38h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413B7F:                             ; CODE XREF: .text:00413AFFj
    push    ecx
    call    sub_4B4F20
    add     esp, 4

    loc_413B88:                             ; CODE XREF: .text:00413AA5j
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413B97:                             ; CODE XREF: .text:004136D8j
                                            ; .text:004136E7j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 34h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_413BA8 dd offset loc_4136E5         ; DATA XREF: .text:004136DEr
    dd offset loc_4137A7                    ; jump table for switch statement
    dd offset sub_4138A0
    dd offset loc_413902
    align 10h
    sub     esp, 0Ch
    push    ebx
    mov     ebx, [esp+18h]
    push    ebp
    push    esi
    mov     esi, [esp+1Ch]
    push    edi
    mov     eax, [esi+10h]
    mov     edi, [eax+0DCh]
    mov     eax, [ebx+16h]
    test    eax, eax
    jz      loc_413D6A
    test    dword ptr [esp+28h], 10008h
    jnz     loc_413D6A
    xor     eax, eax
    mov     al, [ebx+5]
    sub     eax, 0
    jz      loc_413C9A
    dec     eax
    jz      short loc_413C18
    dec     eax
    jz      loc_413D6A

    loc_413C09:                             ; CODE XREF: .text:00413C9Dj
                                            ; .text:00413CB2j
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413C18:                             ; CODE XREF: .text:00413C00j
    mov     eax, [ebx+36h]
    test    eax, eax
    jz      short loc_413C2F
    shl     edi, 11h
    mov     ebp, edi
    mov     di, [esi+66h]
    sub     di, 4000h
    jmp     short loc_413C3D
    ; ---------------------------------------------------------------------------

    loc_413C2F:                             ; CODE XREF: .text:00413C1Dj
    shl     edi, 11h
    mov     ebp, edi
    mov     di, [esi+66h]
    add     di, 4000h

    loc_413C3D:                             ; CODE XREF: .text:00413C2Dj
    push    ebp
    push    edi
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    ebp
    push    edi
    call    sub_4B7123
    mov     edi, [esi+6Ah]
    mov     ecx, [esi+6Eh]
    mov     esi, [esi+72h]
    add     esp, 8
    neg     eax
    add     ebx, edi
    add     esi, eax
    push    36h
    mov     [esp+14h], ebx
    mov     [esp+18h], ecx
    mov     [esp+1Ch], esi
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      loc_413D3A
    mov     edi, [esp+24h]
    lea     ecx, [esp+10h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     loc_413D40
    ; ---------------------------------------------------------------------------

    loc_413C9A:                             ; CODE XREF: .text:00413BF9j
    cmp     dword ptr [esi], 0
    jz      loc_413C09
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    test    ah, 8
    jz      loc_413C09
    push    2
    call    GetRandom
    test    eax, eax
    mov     [ebx+36h], eax
    jz      short loc_413CD6
    shl     edi, 10h
    mov     ebp, edi
    mov     di, [esi+66h]
    sub     di, 4000h
    jmp     short loc_413CE4
    ; ---------------------------------------------------------------------------

    loc_413CD6:                             ; CODE XREF: .text:00413CC4j
    shl     edi, 10h
    mov     ebp, edi
    mov     di, [esi+66h]
    add     di, 4000h

    loc_413CE4:                             ; CODE XREF: .text:00413CD4j
    push    ebp
    push    edi
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    ebp
    push    edi
    call    sub_4B7123
    mov     edi, [esi+6Ah]
    mov     ecx, [esi+6Eh]
    mov     esi, [esi+72h]
    add     esp, 8
    neg     eax
    add     ebx, edi
    add     esi, eax
    push    36h
    mov     [esp+14h], ebx
    mov     [esp+18h], ecx
    mov     [esp+1Ch], esi
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_413D3A
    mov     edi, [esp+24h]
    lea     ecx, [esp+10h]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     esi, eax
    jmp     short loc_413D40
    ; ---------------------------------------------------------------------------

    loc_413D3A:                             ; CODE XREF: .text:00413C7Cj
                                            ; .text:00413D23j
    mov     edi, [esp+24h]
    xor     esi, esi

    loc_413D40:                             ; CODE XREF: .text:00413C95j
                                            ; .text:00413D38j
    push    80h
    mov     ecx, esi
    call    sub_44E730
    push    esi
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 100E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413D6A:                             ; CODE XREF: .text:00413BDDj
                                            ; .text:00413BEBj ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 5
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     cl, [esp+0Ch]
    sub     esp, 24h
    test    cl, 2
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      short loc_413DA9
    mov     eax, [esp+38h]
    push    eax
    call    sub_41C110
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413DA9:                             ; CODE XREF: .text:00413D8Ej
    test    cl, 8
    jz      short loc_413DD4
    mov     esi, [esp+38h]
    push    offset aConstructionTe          ; "Construction terminated"
    push    7
    push    esi
    call    sub_47F780
    push    esi
    call    sub_41C110
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413DD4:                             ; CODE XREF: .text:00413DACj
    mov     esi, [esp+3Ch]
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 5                          ; switch 6 cases
    ja      loc_414320                      ; default
    jmp     ds:off_414330[eax*4]            ; switch jump

    loc_413DED:                             ; DATA XREF: .text:00414330o
    mov     edi, [esp+38h]                  ; case 0x0
    cmp     dword ptr [edi], 0
    jz      loc_414320                      ; default
    mov     ecx, [edi+92h]
    mov     eax, [ecx+241h]
    test    ah, 8
    jz      loc_414320                      ; default
    push    offset aBuilding                ; "Building"
    mov     ecx, esi
    call    sub_438880
    push    3
    mov     ecx, edi
    call    sub_4898B0
    mov     eax, [edi+86h]
    test    eax, eax
    jz      short loc_413E3A
    push    2
    push    0FFFFFFFFh
    push    0
    push    edi
    call    sub_48AAC0

    loc_413E3A:                             ; CODE XREF: .text:00413E2Cj
    push    1
    push    1
    mov     ecx, edi
    call    sub_48B090
    mov     ecx, [edi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     loc_4142F1
    push    2
    push    edi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_413E7C
    lea     ecx, [edi+6Ah]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_413E7E
    ; ---------------------------------------------------------------------------

    loc_413E7C:                             ; CODE XREF: .text:00413E6Aj
    xor     ebx, ebx

    loc_413E7E:                             ; CODE XREF: .text:00413E7Aj
    mov     edx, [edi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, esi
    call    sub_4388D0
    mov     eax, [esi+6]
    or      al, 0E0h
    mov     [esi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413EB7:                             ; CODE XREF: .text:00413DE6j
                                            ; DATA XREF: .text:00414330o
    mov     ecx, [esi+36h]                  ; case 0x1
    mov     edx, TAdynmemStructPtr
    mov     eax, ecx
    lea     edi, [esi+22h]
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    mov     eax, [edx+1439Bh]
    add     eax, ecx
    mov     ecx, edi
    mov     dword ptr [esi+3Eh], 0
    mov     edx, [eax+14Ah]
    mov     eax, [ecx]
    mov     [esp+3Ch], edx
    push    edx
    mov     ebx, [ecx+4]
    push    edi
    mov     [esp+1Ch], ebx
    movsx   ebx, dx
    shl     ebx, 13h
    sub     eax, ebx
    mov     ecx, [ecx+8]
    add     eax, 80000h
    sar     eax, 14h
    mov     [esp+48h], ax
    movsx   eax, word ptr [esp+46h]
    shl     eax, 13h
    sub     ecx, eax
    add     ecx, 80000h
    sar     ecx, 14h
    mov     [esp+4Ah], cx
    mov     ecx, [esp+48h]
    push    ecx
    call    sub_414350
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_413F48
    push    edi
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_413F4A
    ; ---------------------------------------------------------------------------

    loc_413F48:                             ; CODE XREF: .text:00413F39j
    xor     edi, edi

    loc_413F4A:                             ; CODE XREF: .text:00413F46j
    mov     edx, [esp+38h]
    xor     ecx, ecx
    mov     eax, [edx+92h]
    mov     cx, [eax+212h]
    push    ecx
    mov     ecx, edi
    call    sub_44E730
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 0E0h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413F83:                             ; CODE XREF: .text:00413DE6j
                                            ; DATA XREF: .text:00414330o
    test    cl, 40h                         ; case 0x2
    jz      short loc_413F97
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_413F97:                             ; CODE XREF: .text:00413F86j
    mov     ecx, [esi+36h]
    lea     edi, [esi+22h]
    mov     eax, ecx
    push    1
    shl     eax, 6
    add     eax, ecx
    lea     edx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1439Bh]
    lea     ebx, [ecx+edx]
    mov     ecx, edi
    mov     edx, [ebx+14Ah]
    mov     eax, [ecx]
    mov     [esp+40h], edx
    movsx   edx, dx
    shl     edx, 13h
    mov     ebp, [ecx+4]
    sub     eax, edx
    add     eax, 80000h
    mov     [esp+18h], ebp
    mov     ecx, [ecx+8]
    sar     eax, 14h
    mov     [esp+44h], ax
    movsx   eax, word ptr [esp+42h]
    shl     eax, 13h
    sub     ecx, eax
    add     ecx, 80000h
    sar     ecx, 14h
    mov     [esp+46h], cx
    mov     ecx, [esp+44h]
    push    ecx
    push    0
    push    ebx
    call    sub_47DB70
    test    eax, eax
    jnz     short loc_414069
    mov     eax, [esi+3Eh]
    test    eax, eax
    jnz     short loc_414044
    mov     edx, [esp+38h]
    push    offset aWaitingForTarg          ; "Waiting for target area to clear"
    push    7
    push    edx
    call    sub_47F780

    loc_414025:                             ; CODE XREF: .text:00414047j
    mov     ecx, [esi+3Eh]
    push    1Eh
    inc     ecx
    mov     [esi+3Eh], ecx
    mov     ecx, esi
    call    sub_439E80
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414044:                             ; CODE XREF: .text:00414012j
    cmp     eax, 0Ah
    jle     short loc_414025
    mov     eax, [esp+38h]
    push    offset aTargetAreaWasB          ; "Target area was blocked"
    push    7
    push    eax
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414069:                             ; CODE XREF: .text:0041400Bj
    push    edi
    push    ebx
    call    sub_47DDC0
    mov     edx, [edi]
    push    0
    push    1
    push    0
    mov     eax, [edi+4]
    sub     esp, 0Ch
    mov     ecx, esp
    mov     [ecx], edx
    mov     edx, [edi+8]
    mov     edi, [esp+50h]
    mov     [ecx+4], eax
    mov     ax, [esi+36h]
    push    eax
    mov     [ecx+8], edx
    mov     cl, [edi+0FFh]
    push    ecx
    call    sub_485F50
    push    eax
    lea     ecx, [esi+12h]
    call    sub_489690
    mov     eax, [esi+16h]
    test    eax, eax
    jnz     short loc_4140CC
    push    offset aUnableToCreate          ; "Unable to create any more units"
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4140CC:                             ; CODE XREF: .text:004140AEj
    push    offset aStartingConstr          ; "Starting construction"
    push    9
    push    edi
    call    sub_47F780
    mov     edx, [esi+16h]
    push    0
    push    0
    push    0
    push    edi
    push    edx
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aGetbuilt_0              ; "GETBUILT"
    call    sub_438760
    call    sub_43ADC0
    mov     eax, [esi+16h]
    mov     ecx, [edi+72h]
    mov     edx, [edi+6Ah]
    mov     ebx, [eax+72h]
    mov     ebp, [eax+6Ah]
    sub     ecx, ebx
    sub     edx, ebp
    push    ecx
    push    edx
    call    sub_4B715A
    sub     ax, [edi+66h]
    add     esp, 8
    push    eax
    push    esi
    push    edi
    call    sub_438590
    push    edi
    call    sub_41C110
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414136:                             ; CODE XREF: .text:00413DE6j
                                            ; DATA XREF: .text:00414330o
    mov     edi, [esp+38h]                  ; case 0x3
    push    0Ah
    push    esi
    push    edi
    call    sub_438700
    jmp     short loc_414149
    ; ---------------------------------------------------------------------------

    loc_414145:                             ; CODE XREF: .text:00413DE6j
                                            ; DATA XREF: .text:00414330o
    mov     edi, [esp+38h]                  ; case 0x4

    loc_414149:                             ; CODE XREF: .text:00414143j
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     ecx, 96h
    mov     eax, [eax+38A47h]
    div     ecx
    test    edx, edx
    jnz     loc_414202
    mov     edx, [esi+16h]
    lea     eax, [edi+6Ah]
    add     edx, 6Ah
    push    edx
    push    eax
    call    sub_48A980
    mov     ecx, [edi+92h]
    xor     edi, edi
    mov     ebx, eax
    mov     di, [ecx+212h]
    add     ebx, 0DB6Eh
    shl     edi, 10h
    push    edi
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     ebp, eax
    neg     ebp
    push    edi
    push    ebx
    call    sub_4B7123
    mov     ecx, [esi+16h]
    add     esp, 8
    add     ecx, 6Ah
    neg     eax
    mov     edx, [ecx]
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    sub     edx, ebp
    sub     ecx, eax
    push    36h
    mov     [esp+14h], edx
    mov     [esp+18h], edi
    mov     [esp+1Ch], ecx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4141E6
    lea     edx, [esp+10h]
    mov     ecx, eax
    push    edx
    push    esi
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_4141E8
    ; ---------------------------------------------------------------------------

    loc_4141E6:                             ; CODE XREF: .text:004141D3j
    xor     edi, edi

    loc_4141E8:                             ; CODE XREF: .text:004141E4j
    and     ebx, 0FFFFh
    mov     ecx, edi
    push    ebx
    call    sub_44E720
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     edi, [esp+38h]

    loc_414202:                             ; CODE XREF: .text:0041415Fj
    mov     eax, [edi+92h]
    xor     ecx, ecx
    mov     cx, [eax+1FEh]
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 4
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    push    ecx
    mov     [esp+3Ch], edx
    mov     edx, [esi+16h]
    fild    dword ptr [esp+3Ch]
    fstp    dword ptr [esp]
    push    edx
    push    edi
    call    sub_41BA60
    test    eax, eax
    jz      short loc_4142BB
    lea     eax, [esp+10h]
    push    eax
    push    edi
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    mov     ecx, [eax+92h]
    mov     edx, [eax+6Ah]
    mov     ebx, [eax+6Eh]
    add     ecx, 15Eh
    mov     ebp, [ecx]
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    add     edx, ebp
    mov     ebp, [eax+72h]
    add     edi, ebx
    add     ecx, ebp
    mov     [esp+20h], edx
    mov     [esp+24h], edi
    mov     [esp+28h], ecx
    mov     ecx, [eax+92h]
    mov     edx, [eax+6Ah]
    mov     ebx, [eax+72h]
    add     ecx, 16Ah
    mov     ebp, [eax+6Eh]
    mov     edi, [ecx]
    add     edx, edi
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    mov     [esp+2Ch], edx
    add     ecx, ebx
    lea     edx, [esp+14h]
    mov     [esp+34h], ecx
    lea     ecx, [esp+20h]
    add     edi, ebp
    push    ecx
    push    edx
    mov     [esp+38h], edi
    call    sub_4720D0

    loc_4142BB:                             ; CODE XREF: .text:0041423Cj
    mov     eax, [esi+16h]
    fld     dword ptr [eax+104h]
    fcomp   ds:flt_4FCC40
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_4142F1
    push    1
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 0Ah
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4142F1:                             ; CODE XREF: .text:00413E50j
                                            ; .text:004142CFj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414300:                             ; CODE XREF: .text:00413DE6j
                                            ; DATA XREF: .text:00414330o
    mov     ecx, [esp+38h]                  ; case 0x5
    push    offset aBuildingComple          ; "Building complete"
    push    8
    push    ecx
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414320:                             ; CODE XREF: .text:00413DE0j
                                            ; .text:00413DF4j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_414330 dd offset loc_413DED         ; DATA XREF: .text:00413DE6r
    dd offset loc_413EB7                    ; jump table for switch statement
    dd offset loc_413F83
    dd offset loc_414136
    dd offset loc_414145
    dd offset loc_414300
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_414350 proc near                    ; CODE XREF: .text:00413F28p
                                            ; .text:00414CE1p

    arg_0= word ptr  4
    arg_2= word ptr  6
    arg_4= dword ptr  8
    arg_8= word ptr  0Ch
    arg_A= word ptr  0Eh

    movsx   eax, [esp+arg_0]
    movsx   ecx, [esp+arg_8]
    lea     edx, [ecx+eax*2]
    mov     eax, [esp+arg_4]
    movsx   ecx, [esp+arg_2]
    shl     edx, 13h
    mov     [eax], edx
    movsx   edx, [esp+arg_A]
    lea     ecx, [edx+ecx*2]
    shl     ecx, 13h
    mov     [eax+8], ecx
    retn    0Ch
    sub_414350 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+38h]
    xor     ebx, ebx
    push    edi
    mov     ecx, [esi+16h]
    cmp     ecx, ebx
    jz      loc_414730
    mov     dl, [esp+40h]
    test    dl, 8
    jnz     loc_414730
    test    dl, 2
    jz      short loc_4143C3
    mov     eax, [esp+38h]
    push    eax
    call    sub_41C110
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4143C3:                             ; CODE XREF: .text:004143A8j
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_414721                      ; default
    jmp     ds:off_414758[eax*4]            ; switch jump

    loc_4143D8:                             ; DATA XREF: .text:00414758o
    mov     edi, [esp+38h]                  ; case 0x0
    cmp     [edi], ebx
    jz      loc_414721                      ; default
    mov     eax, [edi+92h]
    mov     ecx, [eax+241h]
    test    ch, 8
    jz      loc_414721                      ; default
    cmp     [eax+156h], ebx
    jnz     short loc_414410
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414410:                             ; CODE XREF: .text:004143FFj
    push    offset aBuilding                ; "Building"
    mov     ecx, esi
    call    sub_438880
    push    3
    mov     ecx, edi
    call    sub_4898B0
    cmp     [edi+86h], ebx
    jz      short loc_414438
    push    2
    push    0FFFFFFFFh
    push    ebx
    push    edi
    call    sub_48AAC0

    loc_414438:                             ; CODE XREF: .text:0041442Bj
    push    1
    push    1
    mov     ecx, edi
    call    sub_48B090
    mov     ecx, [edi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     loc_41455A
    push    2
    push    edi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_414478
    lea     ecx, [edi+6Ah]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax

    loc_414478:                             ; CODE XREF: .text:00414468j
    mov     edx, [edi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, esi
    call    sub_4388D0
    mov     eax, [esi+6]
    or      al, 0E0h
    mov     [esi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4144B1:                             ; CODE XREF: .text:004143D1j
                                            ; DATA XREF: .text:00414758o
    push    36h                             ; case 0x1
    mov     [esi+3Eh], ebx
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_4144D5
    mov     ecx, [esi+16h]
    add     ecx, 6Ah
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_4144D7
    ; ---------------------------------------------------------------------------

    loc_4144D5:                             ; CODE XREF: .text:004144C0j
    xor     edi, edi

    loc_4144D7:                             ; CODE XREF: .text:004144D3j
    mov     edx, [esp+38h]
    xor     ecx, ecx
    mov     eax, [edx+92h]
    mov     cx, [eax+212h]
    push    ecx
    mov     ecx, edi
    call    sub_44E730
    push    edi
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 0E0h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414510:                             ; CODE XREF: .text:004143D1j
                                            ; DATA XREF: .text:00414758o
    test    dl, 40h                         ; case 0x2
    jnz     loc_414747
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FCC40
    fnstsw  ax
    test    ah, 40h
    jz      short loc_41453B
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41453B:                             ; CODE XREF: .text:0041452Aj
    mov     edi, [esp+38h]
    add     ecx, 6Ah
    push    ecx
    lea     edx, [edi+6Ah]
    push    edx
    call    sub_48A980
    push    eax
    push    esi
    push    edi
    call    sub_438590
    push    edi
    call    sub_41C110

    loc_41455A:                             ; CODE XREF: .text:0041444Ej
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414569:                             ; CODE XREF: .text:004143D1j
                                            ; DATA XREF: .text:00414758o
    mov     eax, TAdynmemStructPtr          ; case 0x3
    xor     edx, edx
    mov     edi, 96h
    mov     eax, [eax+38A47h]
    div     edi
    test    edx, edx
    jnz     loc_41461F
    mov     edi, [esp+38h]
    add     ecx, 6Ah
    push    ecx
    lea     ecx, [edi+6Ah]
    push    ecx
    call    sub_48A980
    mov     edx, [edi+92h]
    xor     edi, edi
    mov     ebx, eax
    mov     di, [edx+212h]
    add     ebx, 0DB6Eh
    shl     edi, 10h
    push    edi
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     ebp, eax
    neg     ebp
    push    edi
    push    ebx
    call    sub_4B7123
    mov     ecx, [esi+16h]
    add     esp, 8
    add     ecx, 6Ah
    neg     eax
    mov     edx, [ecx]
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    sub     edx, ebp
    sub     ecx, eax
    push    36h
    mov     [esp+14h], edx
    mov     [esp+18h], edi
    mov     [esp+1Ch], ecx
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_414607
    lea     ecx, [esp+10h]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     edi, eax
    jmp     short loc_414609
    ; ---------------------------------------------------------------------------

    loc_414607:                             ; CODE XREF: .text:004145F4j
    xor     edi, edi

    loc_414609:                             ; CODE XREF: .text:00414605j
    and     ebx, 0FFFFh
    mov     ecx, edi
    push    ebx
    call    sub_44E720
    push    edi
    mov     ecx, esi
    call    sub_4388D0

    loc_41461F:                             ; CODE XREF: .text:0041457Fj
    mov     edi, [esp+38h]
    xor     ecx, ecx
    mov     eax, 88888889h
    mov     edx, [edi+92h]
    mov     cx, [edx+1FEh]
    imul    ecx
    add     edx, ecx
    push    ecx
    sar     edx, 4
    mov     eax, edx
    mov     ecx, [esi+16h]
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+3Ch], edx
    fild    dword ptr [esp+3Ch]
    fstp    dword ptr [esp]
    push    ecx
    push    edi
    call    sub_41BA60
    test    eax, eax
    jz      short loc_4146DC
    lea     edx, [esp+10h]
    push    edx
    push    edi
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    mov     ecx, [eax+92h]
    mov     ebp, [eax+6Ah]
    mov     ebx, [eax+6Eh]
    add     ecx, 15Eh
    mov     edx, [ecx]
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    add     edx, ebp
    mov     ebp, [eax+72h]
    add     edi, ebx
    add     ecx, ebp
    mov     [esp+20h], edx
    mov     [esp+24h], edi
    mov     [esp+28h], ecx
    mov     ecx, [eax+92h]
    mov     edx, [eax+6Ah]
    mov     ebx, [eax+72h]
    add     ecx, 16Ah
    mov     ebp, [eax+6Eh]
    lea     eax, [esp+20h]
    mov     edi, [ecx]
    push    eax
    add     edx, edi
    mov     edi, [ecx+4]
    mov     ecx, [ecx+8]
    add     edi, ebp
    add     ecx, ebx
    mov     [esp+30h], edx
    mov     [esp+38h], ecx
    lea     ecx, [esp+18h]
    push    ecx
    mov     [esp+38h], edi
    call    sub_4720D0

    loc_4146DC:                             ; CODE XREF: .text:0041465Dj
    mov     edx, [esi+16h]
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FCC40
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_414712
    push    1
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 0Ah
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414712:                             ; CODE XREF: .text:004146F0j
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414721:                             ; CODE XREF: .text:004143CBj
                                            ; .text:004143DEj ...
    mov     eax, 7                          ; default
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414730:                             ; CODE XREF: .text:00414392j
                                            ; .text:0041439Fj
    mov     esi, [esp+38h]
    push    offset aConstruction_0          ; "Construction terminated by hostile acti"...
    push    7
    push    esi
    call    sub_47F780
    push    esi
    call    sub_41C110

    loc_414747:                             ; CODE XREF: .text:00414513j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 8
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_414758 dd offset loc_4143D8         ; DATA XREF: .text:004143D1r
    dd offset loc_4144B1                    ; jump table for switch statement
    dd offset loc_414510
    dd offset loc_414569
    align 10h
    sub     esp, 28h
    lea     eax, [esp+0]
    lea     ecx, [esp+30h]
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+3Ch]
    push    eax
    push    ecx
    lea     ebx, [edi+22h]
    push    ebx
    call    sub_421DA0
    cmp     ax, 0FFFFh
    jnz     short loc_4147B2
    mov     edx, [esp+38h]
    push    offset aReclamationFai          ; "Reclamation failed"
    push    7
    push    edx
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4147B2:                             ; CODE XREF: .text:00414791j
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFFFh
    shl     eax, 8
    mov     esi, [ecx+1426Fh]
    add     esi, eax
    test    byte ptr [esi+0FEh], 80h
    jnz     short loc_4147DF
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4147DF:                             ; CODE XREF: .text:004147CFj
    xor     eax, eax
    mov     al, [edi+5]
    cmp     eax, 4                          ; switch 5 cases
    ja      loc_414A5D                      ; default
    jmp     ds:off_414A6C[eax*4]            ; switch jump

    loc_4147F4:                             ; DATA XREF: .text:00414A6Co
    mov     esi, [esp+38h]                  ; case 0x0
    cmp     dword ptr [esi], 0
    jz      loc_414A5D                      ; default
    mov     eax, [esi+92h]
    mov     ecx, [eax+241h]
    test    ch, 8
    jz      loc_414A5D                      ; default
    mov     ecx, [eax+245h]
    test    ch, 4
    jz      loc_414A5D                      ; default
    push    offset aReclaiming              ; "Reclaiming"
    mov     ecx, edi
    call    sub_438880
    push    3
    mov     ecx, esi
    call    sub_4898B0
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_414850
    push    2
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_414850:                             ; CODE XREF: .text:00414842j
    push    1
    push    1
    mov     ecx, esi
    call    sub_48B090
    mov     ecx, [esi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     loc_41496D
    push    2
    push    esi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_414892
    lea     ecx, [esi+6Ah]
    push    ecx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_414894
    ; ---------------------------------------------------------------------------

    loc_414892:                             ; CODE XREF: .text:00414880j
    xor     ebx, ebx

    loc_414894:                             ; CODE XREF: .text:00414890j
    mov     edx, [esi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, edi
    call    sub_4388D0
    mov     eax, [edi+6]
    or      al, 0E0h
    mov     [edi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4148CC:                             ; CODE XREF: .text:004147EDj
                                            ; DATA XREF: .text:00414A6Co
    push    36h                             ; case 0x1
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4148E5
    push    ebx
    push    edi
    mov     ecx, eax
    call    sub_44E2D0
    jmp     short loc_4148E7
    ; ---------------------------------------------------------------------------

    loc_4148E5:                             ; CODE XREF: .text:004148D8j
    xor     eax, eax

    loc_4148E7:                             ; CODE XREF: .text:004148E3j
    push    eax
    mov     ecx, edi
    call    sub_4388D0
    mov     dword ptr [edi+6], 0E0h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414904:                             ; CODE XREF: .text:004147EDj
                                            ; DATA XREF: .text:00414A6Co
    test    byte ptr [esp+40h], 40h         ; case 0x2
    jz      short loc_414919
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414919:                             ; CODE XREF: .text:00414909j
    fld     dword ptr [esi+0F0h]
    fadd    dword ptr [esi+0ECh]
    fmul    ds:flt_4FCC54
    fsubr   ds:flt_4FCC50
    call    __ftol
    mov     [edi+36h], eax
    mov     eax, [esp+38h]
    push    0
    push    0Bh
    push    eax
    call    sub_47F780
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414955:                             ; CODE XREF: .text:004147EDj
                                            ; DATA XREF: .text:00414A6Co
    push    2                               ; case 0x3
    mov     ecx, edi
    call    sub_439E80
    mov     ecx, [edi+36h]
    add     ecx, 0FFFFFFFEh
    mov     eax, ecx
    mov     [edi+36h], ecx
    test    eax, eax
    jg      short loc_41497B

    loc_41496D:                             ; CODE XREF: .text:00414866j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41497B:                             ; CODE XREF: .text:0041496Bj
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+38h]
    mov     edx, [ecx+38A47h]
    add     edx, 12Ch
    mov     [eax+0B0h], edx
    mov     ecx, [edi+36h]
    cmp     ecx, 1Eh
    jle     loc_414A36
    lea     ecx, [esp+10h]
    push    ecx
    push    eax
    call    sub_43E400
    lea     ecx, [esp+1Ch]
    movsx   edx, word ptr [esp+3Ch]
    movsx   eax, word ptr [esp+3Eh]
    shl     edx, 14h
    shl     eax, 14h
    push    ecx
    mov     [esp+20h], edx
    mov     [esp+28h], eax
    call    sub_485070
    movsx   edi, word ptr [esi+94h]
    mov     ecx, [esp+1Ch]
    mov     edx, [esp+24h]
    shl     edi, 14h
    mov     [esp+28h], ecx
    add     edi, ecx
    movsx   ecx, word ptr [esi+96h]
    shl     ecx, 14h
    add     edx, ecx
    push    6
    mov     [esp+34h], edx
    xor     edx, edx
    mov     dl, [esi+0FAh]
    lea     ecx, [esp+20h]
    shl     eax, 10h
    shl     edx, 10h
    mov     [esp+24h], eax
    add     eax, edx
    mov     [esp+30h], eax
    lea     eax, [esp+14h]
    push    eax
    push    ecx
    mov     [esp+34h], edi
    call    sub_472200
    lea     edx, [esp+10h]
    push    6
    lea     eax, [esp+20h]
    push    edx
    push    eax
    call    sub_472200

    loc_414A36:                             ; CODE XREF: .text:0041499Dj
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414A44:                             ; CODE XREF: .text:004147EDj
                                            ; DATA XREF: .text:00414A6Co
    mov     ecx, [esp+38h]                  ; case 0x4
    push    ebx
    push    ecx
    call    sub_4237D0
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414A5D:                             ; CODE XREF: .text:004147E7j
                                            ; .text:004147FBj ...
    pop     edi                             ; default
    pop     esi
    mov     eax, 7
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    off_414A6C dd offset loc_4147F4         ; DATA XREF: .text:004147EDr
    dd offset loc_4148CC                    ; jump table for switch statement
    dd offset loc_414904
    dd offset loc_414955
    dd offset loc_414A44
    ; ---------------------------------------------------------------------------
    sub     esp, 2Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+40h]
    push    edi
    mov     eax, [esi+16h]
    test    eax, eax
    jz      loc_414E56
    mov     edx, [esp+48h]
    test    edx, 10008h
    jnz     loc_414E56
    xor     ecx, ecx
    mov     cl, [esi+5]
    sub     ecx, 0
    jz      loc_414D34
    dec     ecx
    jz      loc_414C7E
    dec     ecx
    jz      short loc_414ACD
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414ACD:                             ; CODE XREF: .text:00414ABCj
    test    dl, 40h
    jz      short loc_414AE1
    mov     eax, 9
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414AE1:                             ; CODE XREF: .text:00414AD0j
    mov     eax, [esi+6]
    mov     ebx, [esp+40h]
    or      eax, 10008h
    mov     [esi+6], eax
    mov     edx, [esi+16h]
    mov     eax, [ebx+6Ah]
    mov     ecx, [ebx+72h]
    mov     edi, [edx+6Ah]
    mov     ebp, [edx+72h]
    mov     edx, [ebx+92h]
    sub     eax, edi
    xor     edi, edi
    sub     ecx, ebp
    mov     di, [edx+212h]
    cdq
    mov     ebp, eax
    mov     eax, ecx
    mov     [esp+1Ch], edx
    cdq
    mov     [esp+10h], eax
    mov     eax, [esp+1Ch]
    push    eax
    push    ebp
    push    eax
    push    ebp
    mov     [esp+24h], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ecx, [esp+14h]
    mov     ebp, eax
    mov     eax, [esp+10h]
    push    ecx
    push    eax
    push    ecx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     ebp, eax
    mov     eax, edi
    imul    eax, edi
    cmp     ebp, eax
    jg      loc_414C69
    mov     eax, [esi+16h]
    mov     ecx, ebx
    push    eax
    call    sub_489960
    test    eax, eax
    jz      loc_414C69
    cmp     dword ptr [esi+3Ah], 0Fh
    jl      short loc_414B99
    mov     ecx, [esi+36h]
    mov     edx, [esi+16h]
    push    0
    push    5
    push    ecx
    push    edx
    push    ebx
    call    sub_489BB0
    mov     dword ptr [esi+3Ah], 0

    loc_414B99:                             ; CODE XREF: .text:00414B7Ej
    mov     ecx, [esi+0Eh]
    lea     eax, [esp+18h]
    push    eax
    push    ecx
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    lea     ecx, [eax+6Ah]
    mov     ebx, ecx
    mov     edx, [ebx]
    mov     [esp+34h], edx
    mov     edi, [ebx+4]
    mov     [esp+38h], edi
    mov     ebx, [ebx+8]
    mov     [esp+3Ch], ebx
    mov     ebp, [ecx]
    mov     [esp+28h], ebp
    mov     ebp, [ecx+4]
    mov     [esp+2Ch], ebp
    mov     ecx, [ecx+8]
    mov     ebp, [esp+28h]
    mov     [esp+30h], ecx
    mov     ecx, [eax+92h]
    mov     ecx, [ecx+15Eh]
    add     ebp, ecx
    mov     [esp+28h], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [esp+30h]
    mov     ecx, [ecx+166h]
    add     ebp, ecx
    mov     [esp+30h], ebp
    mov     ecx, [eax+92h]
    add     edx, [ecx+16Ah]
    mov     [esp+34h], edx
    mov     edx, [eax+92h]
    mov     ebp, [edx+172h]
    lea     edx, [esp+28h]
    add     ebx, ebp
    mov     [esp+3Ch], ebx
    mov     eax, [eax+92h]
    mov     ecx, [eax+16Eh]
    add     edi, ecx
    lea     ecx, [esp+1Ch]
    push    ecx
    push    edx
    mov     [esp+40h], edi
    call    sub_472200
    push    2
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+3Ah]
    add     eax, 2
    mov     [esi+3Ah], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414C69:                             ; CODE XREF: .text:00414B61j
                                            ; .text:00414B74j
    push    1Eh
    mov     ecx, esi
    call    sub_439E80
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414C7E:                             ; CODE XREF: .text:00414AB5j
    mov     ebx, [esp+40h]
    push    0Fh
    push    eax
    push    ebx
    call    sub_438650
    lea     edi, [esi+22h]
    mov     [esi+36h], eax
    mov     ecx, edi
    mov     dword ptr [esi+3Ah], 0
    mov     edx, [ebx+7Eh]
    mov     eax, [ecx]
    mov     [esp+44h], edx
    push    edx
    push    edi
    mov     ebp, [ecx+4]
    mov     [esp+24h], ebp
    movsx   ebp, dx
    shl     ebp, 13h
    sub     eax, ebp
    mov     ecx, [ecx+8]
    add     eax, 80000h
    sar     eax, 14h
    mov     [esp+48h], ax
    movsx   eax, word ptr [esp+4Eh]
    shl     eax, 13h
    sub     ecx, eax
    add     ecx, 80000h
    sar     ecx, 14h
    mov     [esp+4Ah], cx
    mov     ecx, [esp+48h]
    push    ecx
    call    sub_414350
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_414D05
    mov     edx, [esi+16h]
    mov     ecx, eax
    add     edx, 6Ah
    push    edx
    push    esi
    call    sub_44E2D0
    jmp     short loc_414D07
    ; ---------------------------------------------------------------------------

    loc_414D05:                             ; CODE XREF: .text:00414CF2j
    xor     eax, eax

    loc_414D07:                             ; CODE XREF: .text:00414D03j
    push    eax
    mov     ecx, esi
    call    sub_4388D0
    mov     edi, [esi+6]
    push    0
    or      edi, 100E8h
    push    0Bh
    push    ebx
    mov     [esi+6], edi
    call    sub_47F780
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414D34:                             ; CODE XREF: .text:00414AAEj
    mov     edi, [esp+40h]
    cmp     dword ptr [edi], 0
    jz      loc_414E47
    mov     ecx, [edi+92h]
    mov     edx, [ecx+241h]
    test    dh, 8
    jz      loc_414E47
    mov     edx, [ecx+245h]
    test    dh, 4
    jnz     short loc_414D7D
    push    offset aReclamationFai          ; "Reclamation failed"
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414D7D:                             ; CODE XREF: .text:00414D5Fj
    push    eax
    mov     ecx, edi
    call    sub_489960
    test    eax, eax
    jnz     short loc_414DA5
    push    offset aThatUnitCann_0          ; "That unit cannot be reclaimed"
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414DA5:                             ; CODE XREF: .text:00414D87j
    push    offset aReclaiming              ; "Reclaiming"
    mov     ecx, esi
    call    sub_438880
    push    3
    mov     ecx, edi
    call    sub_4898B0
    mov     eax, [edi+86h]
    test    eax, eax
    jz      short loc_414DD0
    push    2
    push    0FFFFFFFFh
    push    0
    push    edi
    call    sub_48AAC0

    loc_414DD0:                             ; CODE XREF: .text:00414DC2j
    push    1
    push    1
    mov     ecx, edi
    call    sub_48B090
    mov     ecx, [edi]
    mov     al, [ecx+2Eh]
    and     al, 3
    cmp     al, 1
    jnz     short loc_414E38
    push    2
    push    edi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_414E0C
    lea     ecx, [edi+6Ah]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_414E0E
    ; ---------------------------------------------------------------------------

    loc_414E0C:                             ; CODE XREF: .text:00414DFAj
    xor     ebx, ebx

    loc_414E0E:                             ; CODE XREF: .text:00414E0Aj
    mov     edx, [edi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, esi
    call    sub_4388D0
    mov     eax, [esi+6]
    or      al, 0E0h
    mov     [esi+6], eax

    loc_414E38:                             ; CODE XREF: .text:00414DE4j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414E47:                             ; CODE XREF: .text:00414D3Bj
                                            ; .text:00414D50j
    mov     eax, 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414E56:                             ; CODE XREF: .text:00414A90j
                                            ; .text:00414AA0j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 5
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+38h]
    push    edi
    mov     eax, [esi+16h]
    test    eax, eax
    jnz     short loc_414EA2
    mov     eax, [esp+38h]
    push    offset aRepairsUnsucce          ; "Repairs unsuccessful."
    push    7
    push    eax
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414EA2:                             ; CODE XREF: .text:00414E80j
    mov     eax, [esi+3Eh]
    mov     edi, [esp+38h]
    test    eax, eax
    jz      short loc_414EFF
    movsx   ecx, word ptr [esi+30h]
    movsx   edx, word ptr [edi+74h]
    movsx   eax, word ptr [esi+2Eh]
    sub     edx, ecx
    sub     esp, 8
    movsx   ecx, word ptr [edi+6Ch]
    mov     [esp+40h], edx
    sub     ecx, eax
    fild    dword ptr [esp+40h]
    mov     [esp+40h], ecx
    sub     esp, 8
    fstp    qword ptr [esp+8]
    fild    dword ptr [esp+48h]
    fstp    qword ptr [esp]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, [esi+3Eh]
    jl      short loc_414EFF
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414EFF:                             ; CODE XREF: .text:00414EABj
                                            ; .text:00414EEEj
    mov     eax, [esi+16h]
    mov     edx, [eax+110h]
    and     edx, 3
    cmp     dl, 1
    jz      short loc_414F2C
    push    offset aRepairsUnsucce          ; "Repairs unsuccessful."
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414F2C:                             ; CODE XREF: .text:00414F0Ej
    lea     ebx, [esi+22h]
    add     eax, 6Ah
    mov     ecx, ebx
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    xor     eax, eax
    mov     al, [esi+5]
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_41522D                      ; default
    jmp     ds:off_41523C[eax*4]            ; switch jump

    loc_414F59:                             ; DATA XREF: .text:0041523Co
    cmp     dword ptr [edi], 0              ; case 0x0
    jz      loc_41522D                      ; default
    mov     ecx, [edi+92h]
    mov     eax, [ecx+241h]
    test    ah, 8
    jz      loc_41522D                      ; default
    mov     edx, [esi+16h]
    mov     ecx, edi
    push    edx
    call    sub_4899B0
    test    eax, eax
    jnz     short loc_414FA2
    push    offset aRepairMissionF          ; "Repair mission failed"
    push    7
    push    edi
    call    sub_47F780
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_414FA2:                             ; CODE XREF: .text:00414F84j
    push    offset aRepairing               ; "Repairing"
    mov     ecx, esi
    call    sub_438880
    push    3
    mov     ecx, edi
    call    sub_4898B0
    mov     eax, [edi+86h]
    test    eax, eax
    jz      short loc_414FCD
    push    2
    push    0FFFFFFFFh
    push    0
    push    edi
    call    sub_48AAC0

    loc_414FCD:                             ; CODE XREF: .text:00414FBFj
    push    1
    push    1
    mov     ecx, edi
    call    sub_48B090
    mov     ecx, [edi]
    mov     al, [ecx+2Eh]
    and     al, 3
    cmp     al, 1
    jnz     loc_4150FE
    push    2
    push    edi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_41500D
    lea     ecx, [edi+6Ah]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_41500F
    ; ---------------------------------------------------------------------------

    loc_41500D:                             ; CODE XREF: .text:00414FFBj
    xor     ebx, ebx

    loc_41500F:                             ; CODE XREF: .text:0041500Bj
    mov     edx, [edi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, esi
    call    sub_4388D0
    mov     eax, [esi+6]
    or      al, 0E0h
    mov     [esi+6], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_415048:                             ; CODE XREF: .text:00414F52j
                                            ; DATA XREF: .text:0041523Co
    push    36h                             ; case 0x1
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_415063
    push    ebx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_415065
    ; ---------------------------------------------------------------------------

    loc_415063:                             ; CODE XREF: .text:00415054j
    xor     ebx, ebx

    loc_415065:                             ; CODE XREF: .text:00415061j
    mov     eax, [edi+92h]
    movsx   ecx, word ptr [eax+21Ch]
    push    ecx
    mov     ecx, ebx
    call    sub_44E6C0
    push    ebx
    mov     ecx, esi
    call    sub_4388D0
    mov     dword ptr [esi+6], 0E8h
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_415098:                             ; CODE XREF: .text:00414F52j
                                            ; DATA XREF: .text:0041523Co
    test    byte ptr [esp+40h], 40h         ; case 0x2
    jz      short loc_4150AE
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4150AE:                             ; CODE XREF: .text:0041509Dj
    mov     ebx, [esi+16h]
    mov     eax, [ebx+110h]
    mov     edx, eax
    and     edx, 3
    cmp     dl, 1
    jz      short loc_4150D0
    mov     eax, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4150D0:                             ; CODE XREF: .text:004150BFj
    test    al, 0Ch
    jz      short loc_4150E9
    push    0Fh
    mov     ecx, esi
    call    sub_439E80
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4150E9:                             ; CODE XREF: .text:004150D2j
    mov     ecx, [ebx+92h]
    movsx   eax, word ptr [ebx+108h]
    cmp     eax, [ecx+1FAh]
    jb      short loc_41510D

    loc_4150FE:                             ; CODE XREF: .text:00414FE1j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41510D:                             ; CODE XREF: .text:004150FCj
    mov     edx, [edi+92h]
    xor     ecx, ecx
    mov     eax, 88888889h
    mov     cx, [edx+1FEh]
    imul    ecx
    add     edx, ecx
    push    ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+3Ch], edx
    fild    dword ptr [esp+3Ch]
    fstp    dword ptr [esp]
    push    ebx
    push    edi
    call    sub_41BD10
    mov     edx, [esi+0Eh]
    lea     ecx, [esp+10h]
    push    ecx
    push    edx
    call    sub_43E400
    mov     eax, [esi+16h]
    push    6
    lea     ecx, [eax+6Ah]
    mov     ebx, ecx
    mov     edx, [ebx]
    mov     [esp+2Ch], edx
    mov     edi, [ebx+4]
    mov     [esp+30h], edi
    mov     ebx, [ebx+8]
    mov     [esp+34h], ebx
    mov     ebp, [ecx]
    mov     [esp+20h], ebp
    mov     ebp, [ecx+4]
    mov     [esp+24h], ebp
    mov     ecx, [ecx+8]
    mov     ebp, [esp+20h]
    mov     [esp+28h], ecx
    mov     ecx, [eax+92h]
    mov     ecx, [ecx+15Eh]
    add     ebp, ecx
    mov     [esp+20h], ebp
    mov     ecx, [eax+92h]
    mov     ebp, [esp+28h]
    mov     ecx, [ecx+166h]
    add     ebp, ecx
    mov     [esp+28h], ebp
    mov     ecx, [eax+92h]
    add     edx, [ecx+16Ah]
    mov     [esp+2Ch], edx
    mov     edx, [eax+92h]
    mov     ebp, [edx+172h]
    lea     edx, [esp+14h]
    add     ebx, ebp
    mov     [esp+34h], ebx
    mov     eax, [eax+92h]
    mov     ecx, [eax+16Eh]
    add     edi, ecx
    lea     ecx, [esp+20h]
    push    ecx
    push    edx
    mov     [esp+38h], edi
    call    sub_4720D0
    push    1
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 8
    mov     [esi+6], eax
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_415211:                             ; CODE XREF: .text:00414F52j
                                            ; DATA XREF: .text:0041523Co
    push    offset aUnitRepaired            ; case 0x3
    push    0Ah
    push    edi
    call    sub_47F780
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41522D:                             ; CODE XREF: .text:00414F4Cj
                                            ; .text:00414F5Cj ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    off_41523C dd offset loc_414F59         ; DATA XREF: .text:00414F52r
    dd offset loc_415048                    ; jump table for switch statement
    dd offset loc_415098
    dd offset loc_415211
    align 8
    push    esi
    mov     esi, [esp+0Ch]
    mov     eax, [esi+16h]
    test    eax, eax
    jnz     short loc_415276
    mov     eax, [esp+8]
    push    offset aRepairAborted_          ; "Repair aborted."
    push    7
    push    eax
    call    sub_47F780
    mov     eax, 8
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_415276:                             ; CODE XREF: .text:0041525Aj
    xor     eax, eax
    mov     al, [esi+5]
    sub     eax, 0
    jz      short loc_4152A6
    dec     eax
    jz      short loc_41528C
    mov     eax, 7
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41528C:                             ; CODE XREF: .text:00415281j
    mov     ecx, [esp+8]
    push    offset aUnitRepaired            ; "Unit repaired"
    push    0Ah
    push    ecx
    call    sub_47F780
    mov     eax, 5
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4152A6:                             ; CODE XREF: .text:0041527Ej
    mov     eax, [esp+8]
    movsx   edx, word ptr [eax+108h]
    mov     eax, [eax+92h]
    cmp     edx, [eax+1FAh]
    jb      short loc_4152C8
    mov     eax, 1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4152C8:                             ; CODE XREF: .text:004152BDj
    push    1Eh
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 8
    mov     [esi+6], eax
    mov     eax, 2
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     cl, [esp+0Ch]
    sub     esp, 44h
    test    cl, 48h
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      short loc_415317
    mov     ecx, [esp+5Ch]
    push    1Eh
    call    sub_439E80
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_415317:                             ; CODE XREF: .text:004152FEj
    mov     esi, [esp+5Ch]
    xor     eax, eax
    xor     ebp, ebp
    mov     al, [esi+5]
    sub     eax, ebp
    jz      loc_4157CC
    dec     eax
    jnz     loc_4158C1
    test    cl, 0E0h
    jz      short loc_415345
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_415345:                             ; CODE XREF: .text:00415334j
    push    36h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_415363

    loc_415353:                             ; DATA XREF: .data:0051108Co
                                            ; .data:00511134o ...
    lea     ecx, [esi+22h]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_415365
    ; ---------------------------------------------------------------------------

    loc_415363:                             ; CODE XREF: .text:00415351j
    xor     ebx, ebx

    loc_415365:                             ; CODE XREF: .text:00415361j
    mov     edi, [esp+58h]
    mov     ecx, ebx
    mov     edx, [edi+92h]
    movsx   eax, word ptr [edx+21Ch]
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, esi
    call    sub_4388D0
    push    2Dh
    mov     ecx, esi
    call    sub_439E80
    mov     eax, [esi+6]
    or      al, 0E0h
    mov     [esi+6], eax
    mov     edx, [edi+92h]
    movsx   ecx, word ptr [edi+108h]
    mov     eax, [edx+1FAh]
    shr     eax, 2
    lea     eax, [eax+eax*2]
    cmp     ecx, eax
    jnb     loc_41547D
    lea     ecx, [esp+5Ch]
    push    ecx
    lea     ecx, [esp+38h]
    call    sub_40C510
    mov     ecx, [edi+96h]
    lea     edx, [esp+34h]
    push    edx
    xor     edx, edx
    mov     dl, [ecx+146h]
    lea     eax, [edi+6Ah]
    push    0F00h
    push    eax
    push    edx
    call    sub_40B530
    lea     ecx, [esp+34h]
    call    sub_40C560
    neg     eax
    sbb     eax, eax
    inc     eax
    test    al, al
    jnz     short loc_415474
    push    ebp
    mov     ecx, esi
    call    sub_4388D0
    mov     ebx, [esp+38h]
    cmp     ebx, ebp
    jnz     short loc_41540E
    xor     eax, eax
    jmp     short loc_415417
    ; ---------------------------------------------------------------------------

    loc_41540E:                             ; CODE XREF: .text:00415408j
    mov     eax, [esp+3Ch]
    sub     eax, ebx
    sar     eax, 2

    loc_415417:                             ; CODE XREF: .text:0041540Cj
    push    eax
    call    GetRandom
    mov     ebp, [ebx+eax*4]
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    jz      short sub_41544F
    push    0
    push    0
    push    0
    push    0
    push    ebp
    push    ecx
    mov     ecx, esp
    push    offset aVtol_landing            ; "VTOL_LANDING"
    call    sub_438760
    mov     ecx, ebx
    call    sub_43A0C0
    jmp     short loc_415451

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41544F proc near                    ; CODE XREF: .text:0041542Ej
                                            ; DATA XREF: .data:00504A14o

    arg_30= dword ptr  34h

    xor     eax, eax

    loc_415451:                             ; CODE XREF: .text:0041544Dj
    push    eax
    push    edi
    call    sub_43ACB0
    lea     ecx, [esp+arg_30]
    mov     dword ptr [esi+6], 0
    call    sub_40C530
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    sub_41544F endp ; sp =  54h

    ; ---------------------------------------------------------------------------

    loc_415474:                             ; CODE XREF: .text:004153F8j
    lea     ecx, [esp+34h]
    call    sub_40C530

    loc_41547D:                             ; CODE XREF: .text:004153B2j
    mov     ecx, [edi+96h]
    fld     dword ptr [ecx+8Ch]
    fld     dword ptr [ecx+0A4h]
    fmul    ds:dbl_4FCC58
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 41h
    jz      loc_415621
    mov     al, [esp+5Ch]
    mov     edx, [edi+92h]
    mov     [esp+34h], al
    mov     [esp+38h], ebp
    mov     [esp+3Ch], ebp
    mov     [esp+40h], ebp
    movsx   eax, word ptr [edx+202h]
    lea     edx, [esp+44h]
    mov     [esp+48h], ecx
    shl     eax, 10h
    push    edx
    push    eax
    lea     eax, [edi+6Ah]
    lea     ecx, [esp+3Ch]
    push    eax
    mov     [esp+58h], ecx
    mov     [esp+5Ch], edi
    mov     dword ptr [esp+50h], offset off_4FCC64
    call    sub_47E890
    mov     eax, [esp+38h]
    cmp     eax, ebp
    mov     ebp, [esp+3Ch]
    jnz     short loc_4154FD
    xor     ecx, ecx
    jmp     short loc_415504
    ; ---------------------------------------------------------------------------

    loc_4154FD:                             ; CODE XREF: .text:004154F7j
    mov     ecx, ebp
    sub     ecx, eax
    sar     ecx, 2

    loc_415504:                             ; CODE XREF: .text:004154FBj
    xor     edx, edx
    test    ecx, ecx
    setz    dl
    test    dl, dl
    jnz     loc_415616
    test    eax, eax
    jnz     short loc_41551B
    xor     ebp, ebp
    jmp     short loc_415520
    ; ---------------------------------------------------------------------------

    loc_41551B:                             ; CODE XREF: .text:00415515j
    sub     ebp, eax
    sar     ebp, 2

    loc_415520:                             ; CODE XREF: .text:00415519j
    push    ebp
    mov     ebx, eax
    call    GetRandom
    mov     ebx, [ebx+eax*4]
    mov     ecx, edi
    push    ebx
    call    sub_4899B0
    test    eax, eax
    jz      short loc_41558F
    fld     dword ptr [ebx+104h]
    fcomp   ds:flt_4FCC40
    fnstsw  ax
    test    ah, 40h
    jz      short loc_41558F
    push    0
    push    ebx
    push    edi
    call    sub_43B400
    test    eax, eax
    jz      short loc_415573
    mov     eax, [esp+38h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_415573:                             ; CODE XREF: .text:00415555j
    mov     ecx, [esp+38h]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41558F:                             ; CODE XREF: .text:00415535j
                                            ; .text:00415548j
    push    ebx
    mov     ecx, edi
    call    sub_4899B0
    test    eax, eax
    jz      short loc_415612
    fld     dword ptr [ebx+104h]
    fcomp   ds:flt_4FCC40
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_415612
    push    0
    mov     ecx, esi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jz      short loc_4155E6
    push    0
    push    0
    push    0
    push    0
    push    ebx
    push    ecx
    mov     ecx, esp
    push    offset aVtol_helpbuild          ; "VTOL_HELPBUILD"
    call    sub_438760
    mov     ecx, ebp
    call    sub_43A0C0
    jmp     short loc_4155E8
    ; ---------------------------------------------------------------------------

    loc_4155E6:                             ; CODE XREF: .text:004155C5j
    xor     eax, eax

    loc_4155E8:                             ; CODE XREF: .text:004155E4j
    push    eax
    push    edi
    call    sub_43ACB0
    mov     dword ptr [esi+6], 0
    mov     edx, [esp+38h]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_415612:                             ; CODE XREF: .text:00415599j
                                            ; .text:004155ACj
    mov     eax, [esp+38h]

    loc_415616:                             ; CODE XREF: .text:0041550Dj
    push    eax
    call    sub_4B4F20
    add     esp, 4
    xor     ebp, ebp

    loc_415621:                             ; CODE XREF: .text:0041549Cj
    lea     ecx, [esp+28h]
    lea     edx, [esp+14h]
    mov     [esp+60h], ecx
    lea     ecx, [esp+60h]
    lea     eax, [esp+1Ch]
    push    edx
    push    ecx
    lea     edx, [esp+20h]
    mov     [esp+18h], eax
    lea     ecx, [esp+18h]
    mov     eax, 0F00000h
    push    edx
    push    ecx
    lea     edx, [edi+6Ah]
    push    eax
    push    edx
    call    sub_47EA40
    test    eax, eax
    jz      loc_4157BD
    mov     ecx, [edi+96h]
    mov     ebx, [esp+60h]
    fld     dword ptr [ecx+98h]
    fld     dword ptr [ecx+0A8h]
    fmul    ds:dbl_4FCC58
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4156AD
    cmp     ebx, ebp
    jz      short loc_4156AD
    push    ebp
    mov     ecx, esi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    cmp     ebx, ebp
    jz      loc_4157A2
    mov     eax, [esp+60h]
    push    ebp
    push    ebp
    push    ebp
    jmp     loc_415773
    ; ---------------------------------------------------------------------------

    loc_4156AD:                             ; CODE XREF: .text:0041567Fj
                                            ; .text:00415683j
    fld     dword ptr [ecx+0A4h]
    fmul    ds:dbl_4FCC58
    fld     dword ptr [ecx+8Ch]
    fxch    st(1)
    fcompp  st(1), st
    mov     edx, [esp+10h]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4156F8
    cmp     edx, ebp
    jz      short loc_4156F8
    push    ebp
    mov     ecx, esi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    cmp     ebx, ebp
    jz      loc_4157A2
    mov     ecx, [esp+10h]
    push    ebp
    push    ebp
    push    ebp
    push    ecx
    jmp     short loc_415774
    ; ---------------------------------------------------------------------------

    loc_4156F8:                             ; CODE XREF: .text:004156CCj
                                            ; .text:004156D0j
    cmp     ebx, ebp
    jz      short loc_415735
    fld     dword ptr [ecx+98h]
    fadd    dword ptr [esp+14h]
    fcomp   dword ptr [ecx+0A8h]
    fnstsw  ax
    test    ah, 41h
    jz      short loc_415735
    push    ebp
    mov     ecx, esi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    cmp     ebx, ebp
    jz      short loc_4157A2
    mov     edx, [esp+60h]
    push    ebp
    push    ebp
    push    ebp
    push    edx
    jmp     short loc_415774
    ; ---------------------------------------------------------------------------

    loc_415735:                             ; CODE XREF: .text:004156FAj
                                            ; .text:00415711j
    cmp     edx, ebp
    jz      loc_4157BD
    fld     dword ptr [ecx+8Ch]
    fadd    dword ptr [esp+18h]
    fcomp   dword ptr [ecx+0A4h]
    fnstsw  ax
    test    ah, 41h
    jz      short loc_4157BD
    push    ebp
    mov     ecx, esi
    call    sub_4388D0
    push    56h
    call    sub_4B4F10
    mov     ebx, eax
    add     esp, 4
    cmp     ebx, ebp
    jz      short loc_4157A2
    mov     eax, [esp+10h]
    push    ebp
    push    ebp
    push    ebp

    loc_415773:                             ; CODE XREF: .text:004156A8j
    push    eax

    loc_415774:                             ; CODE XREF: .text:004156F6j
                                            ; .text:00415733j
    push    ebp
    push    ecx
    mov     ecx, esp
    push    offset aVtol_reclaim            ; "VTOL_RECLAIM"
    call    sub_438760
    mov     ecx, ebx
    call    sub_43A0C0
    push    eax
    push    edi
    call    sub_43ACB0
    mov     [esi+6], ebp
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4157A2:                             ; CODE XREF: .text:0041569Bj
                                            ; .text:004156E8j ...
    xor     eax, eax
    push    eax
    push    edi
    call    sub_43ACB0
    mov     [esi+6], ebp
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4157BD:                             ; CODE XREF: .text:00415656j
                                            ; .text:00415737j ...
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4157CC:                             ; CODE XREF: .text:00415324j
    mov     edi, [esp+58h]
    cmp     [edi], ebp
    jz      loc_4158C1
    mov     eax, [edi+92h]
    mov     ecx, [eax+241h]
    test    ch, 8
    jz      loc_4158C1
    mov     ecx, [eax+245h]
    test    ch, 2
    jz      loc_4158C1
    mov     eax, [esi+16h]
    cmp     eax, ebp
    jz      short loc_415819
    add     eax, 6Ah
    lea     ecx, [esi+22h]
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax

    loc_415819:                             ; CODE XREF: .text:00415801j
    push    esi
    push    edi
    call    sub_43A020
    push    offset aPatrolling              ; "Patrolling"
    mov     ecx, esi
    call    sub_438880
    push    3
    mov     ecx, edi
    call    sub_4898B0
    cmp     [edi+86h], ebp
    jz      short loc_415848
    push    2
    push    0FFFFFFFFh
    push    ebp
    push    edi
    call    sub_48AAC0

    loc_415848:                             ; CODE XREF: .text:0041583Bj
    push    1
    push    1
    mov     ecx, edi
    call    sub_48B090
    mov     ecx, [edi]
    mov     dl, [ecx+2Eh]
    and     dl, 3
    cmp     dl, 1
    jnz     short loc_4158B2
    push    2
    push    edi
    call    sub_43D210
    push    36h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_415886
    lea     ecx, [edi+6Ah]
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44E2D0
    mov     ebx, eax
    jmp     short loc_415888
    ; ---------------------------------------------------------------------------

    loc_415886:                             ; CODE XREF: .text:00415874j
    xor     ebx, ebx

    loc_415888:                             ; CODE XREF: .text:00415884j
    mov     edx, [edi+92h]
    mov     ecx, ebx
    movsx   eax, word ptr [edx+21Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    call    sub_44E6C0
    push    ebx
    mov     ecx, esi
    call    sub_4388D0
    mov     eax, [esi+6]
    or      al, 0E0h
    mov     [esi+6], eax

    loc_4158B2:                             ; CODE XREF: .text:0041585Ej
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4158C1:                             ; CODE XREF: .text:0041532Bj
                                            ; .text:004157D2j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 7
    pop     ebx
    add     esp, 44h
    retn    0Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4158D0 proc near                    ; DATA XREF: .rdata:004FCC64o

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    mov     eax, [ecx+0Ch]
    sub     esp, 8
    cmp     edx, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      loc_415B08
    mov     eax, [edx+96h]
    mov     esi, [ecx+4]
    xor     ebx, ebx
    mov     bl, [eax+146h]
    mov     al, [ebx+esi+108h]
    test    al, al
    jz      loc_415B08
    mov     eax, [edx+110h]
    and     eax, 3
    cmp     al, 1
    jnz     loc_415B08
    mov     edi, [edx+92h]
    movsx   eax, word ptr [edx+108h]
    cmp     eax, [edi+1FAh]
    jb      short loc_415943
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FCC40
    fnstsw  ax
    test    ah, 40h
    jnz     loc_415B08

    loc_415943:                             ; CODE XREF: sub_4158D0+5Aj
    mov     al, [edx+0F4h]
    mov     bl, [esi+146h]
    cmp     al, bl
    jnz     short loc_415960
    cmp     byte ptr [edx+0F5h], 5
    jz      loc_415B08

    loc_415960:                             ; CODE XREF: sub_4158D0+81j
    mov     esi, [ecx+8]
    mov     eax, [esi+8]
    mov     ecx, [esi+0Ch]
    sub     ecx, eax
    mov     edi, eax
    sar     ecx, 2
    cmp     ecx, 1
    jnb     loc_415A6E
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_415984
    xor     ecx, ecx
    jmp     short loc_41598B
    ; ---------------------------------------------------------------------------

    loc_415984:                             ; CODE XREF: sub_4158D0+AEj
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2

    loc_41598B:                             ; CODE XREF: sub_4158D0+B2j
    cmp     ecx, 1
    jbe     short loc_4159A1
    test    edx, edx
    jnz     short loc_415998
    xor     ecx, ecx
    jmp     short loc_4159A6
    ; ---------------------------------------------------------------------------

    loc_415998:                             ; CODE XREF: sub_4158D0+C2j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_4159A6
    ; ---------------------------------------------------------------------------

    loc_4159A1:                             ; CODE XREF: sub_4158D0+BEj
    mov     ecx, 1

    loc_4159A6:                             ; CODE XREF: sub_4158D0+C6j
                                            ; sub_4158D0+CFj
    test    edx, edx
    jnz     short loc_4159AE
    xor     eax, eax
    jmp     short loc_4159B3
    ; ---------------------------------------------------------------------------

    loc_4159AE:                             ; CODE XREF: sub_4158D0+D8j
    sub     eax, edx
    sar     eax, 2

    loc_4159B3:                             ; CODE XREF: sub_4158D0+DCj
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_4159BF
    xor     eax, eax

    loc_4159BF:                             ; CODE XREF: sub_4158D0+EBj
    lea     edx, ds:0[eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    mov     ebx, [esi+4]
    add     esp, 4
    cmp     ebx, edi
    mov     [esp+18h+var_8], eax
    mov     ebp, eax
    jz      short loc_4159ED

    loc_4159DC:                             ; CODE XREF: sub_4158D0+11Bj
    push    ebx
    push    ebp
    call    sub_406C70
    add     ebx, 4
    add     ebp, 4
    cmp     ebx, edi
    jnz     short loc_4159DC

    loc_4159ED:                             ; CODE XREF: sub_4158D0+10Aj
    lea     eax, [esp+18h+arg_0]
    mov     ecx, esi
    push    eax
    push    1
    push    ebp
    call    sub_406C40
    mov     ecx, [esi+8]
    add     ebp, 4
    push    ebp
    push    ecx
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     edx, [esi+8]
    mov     eax, [esi+4]
    push    edx
    push    eax
    mov     ecx, esi
    call    nullsub_1
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+1Ch+var_8]
    mov     ecx, [esp+1Ch+var_4]
    add     esp, 4
    lea     eax, [edx+ecx*4]
    mov     [esi+0Ch], eax
    mov     eax, [esi+4]
    test    eax, eax
    jnz     short loc_415A52
    xor     ecx, ecx
    mov     [esi+4], edx
    lea     ecx, [edx+ecx*4+4]
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_415A52:                             ; CODE XREF: sub_4158D0+16Aj
    mov     ecx, [esi+8]
    mov     [esi+4], edx
    sub     ecx, eax
    sar     ecx, 2
    lea     ecx, [edx+ecx*4+4]
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_415A6E:                             ; CODE XREF: sub_4158D0+A3j
    mov     edx, eax
    sub     edx, edi
    sar     edx, 2
    cmp     edx, 1
    jnb     short loc_415AC8
    lea     ecx, [edi+4]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+8]
    lea     edx, [esp+18h+arg_0]
    mov     ecx, eax
    push    edx
    sub     ecx, edi
    mov     edx, 1
    sar     ecx, 2
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_406C40
    mov     eax, [esi+8]
    cmp     edi, eax
    jz      short loc_415B04

    loc_415AAD:                             ; CODE XREF: sub_4158D0+1E8j
    mov     ecx, [esp+18h+arg_0]
    mov     [edi], ecx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_415AAD
    add     dword ptr [esi+8], 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_415AC8:                             ; CODE XREF: sub_4158D0+1A8j
    push    eax
    push    eax
    add     eax, 0FFFFFFFCh
    mov     ecx, esi
    push    eax
    call    sub_406C10
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_415AEE

    loc_415ADF:                             ; CODE XREF: sub_4158D0+21Cj
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_415ADF

    loc_415AEE:                             ; CODE XREF: sub_4158D0+20Dj
    lea     ecx, [edi+4]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_415B04

    loc_415AF7:                             ; CODE XREF: sub_4158D0+232j
    mov     edx, [esp+18h+arg_0]
    mov     [eax], edx
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_415AF7

    loc_415B04:                             ; CODE XREF: sub_4158D0+1DBj
                                            ; sub_4158D0+225j
    add     dword ptr [esi+8], 4

    loc_415B08:                             ; CODE XREF: sub_4158D0+10j
                                            ; sub_4158D0+30j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_4158D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415B20 proc near                    ; CODE XREF: sub_43C050+2DAp
    push    16h
    push    offset off_4FCA18
    call    sub_43BC90
    retn
    sub_415B20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415B30 proc near                    ; CODE XREF: .text:0049558Ap
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     esi, [eax+148E7h]
    dec     esi
    js      short loc_415B57

    loc_415B3F:                             ; CODE XREF: sub_415B30+25j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+148EBh]
    mov     eax, [edx+esi*4]
    push    eax
    call    sub_4B8B90
    dec     esi
    jns     short loc_415B3F

    loc_415B57:                             ; CODE XREF: sub_415B30+Dj
    pop     esi
    retn
    sub_415B30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415B60 proc near                    ; CODE XREF: sub_48B710+Dp
    mov     eax, ecx
    lea     ecx, [eax+10h]
    mov     dword ptr [eax], 0
    mov     dword ptr [eax+4], 0
    mov     dword ptr [eax+8], 100h
    mov     [eax+0Ch], ecx
    mov     dword ptr [ecx], 0
    retn
    sub_415B60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415B90 proc near                    ; CODE XREF: sub_48B710+1FCp
    mov     eax, [ecx+0Ch]
    add     ecx, 10h
    cmp     eax, ecx
    jz      short locret_415BA3
    push    eax
    call    sub_4B4F20
    add     esp, 4

    locret_415BA3:                          ; CODE XREF: sub_415B90+8j
    retn
    sub_415B90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415BB0 proc near                    ; CODE XREF: sub_44F4A0+65p
                                            ; sub_48B200+EFp ...
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    push    4                               ; int
    mov     edi, [esi+8]
    shl     edi, 1
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_415BCF
    mov     [eax], edi
    mov     ebx, eax
    jmp     short loc_415BD1
    ; ---------------------------------------------------------------------------

    loc_415BCF:                             ; CODE XREF: sub_415BB0+17j
    xor     ebx, ebx

    loc_415BD1:                             ; CODE XREF: sub_415BB0+1Dj
    mov     eax, [esi+0Ch]
    mov     edx, [esi+8]
    mov     ecx, ebx
    lea     edx, [eax+edx*4]
    cmp     eax, edx
    jz      short loc_415BEE

    loc_415BE0:                             ; CODE XREF: sub_415BB0+3Cj
    mov     ebp, [eax]
    add     eax, 4
    mov     [ecx], ebp
    add     ecx, 4
    cmp     eax, edx
    jnz     short loc_415BE0

    loc_415BEE:                             ; CODE XREF: sub_415BB0+2Ej
    mov     eax, [esi+0Ch]
    lea     ecx, [esi+10h]
    cmp     eax, ecx
    jz      short loc_415C01
    push    eax
    call    sub_4B4F20
    add     esp, 4

    loc_415C01:                             ; CODE XREF: sub_415BB0+46j
    mov     [esi+8], edi
    mov     [esi+0Ch], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_415BB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415C10 proc near                    ; CODE XREF: sub_44DDC0+13p
                                            ; sub_44DDC0+27p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     edx, [esp+4+arg_4]
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+4]
    lea     ecx, [edx+eax]
    cmp     ecx, 20h
    jge     short loc_415C58
    mov     ecx, [esi]
    mov     edi, [esi+0Ch]
    mov     ebx, 1
    lea     edi, [edi+ecx*4]
    mov     ecx, edx
    shl     ebx, cl
    mov     ecx, [esp+14h+arg_0]
    dec     ebx
    and     ebx, ecx
    mov     ecx, eax
    shl     ebx, cl
    mov     ecx, [edi]
    or      ecx, ebx
    mov     [edi], ecx
    mov     eax, [esi+4]
    add     eax, edx
    mov     [esi+4], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_415C58:                             ; CODE XREF: sub_415C10+14j
    test    eax, eax
    jnz     short loc_415CD9
    mov     edx, [esi]
    mov     eax, [esi+0Ch]
    mov     ecx, [esp+14h+arg_0]
    mov     [eax+edx*4], ecx
    mov     edi, [esi]
    mov     eax, [esi+8]
    inc     edi
    mov     ecx, edi
    mov     [esi], edi
    cmp     ecx, eax
    jnz     short loc_415CC5
    push    4                               ; int
    lea     ebx, [eax+eax]
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_415C8D
    mov     [eax], ebx
    mov     edi, eax
    jmp     short loc_415C8F
    ; ---------------------------------------------------------------------------

    loc_415C8D:                             ; CODE XREF: sub_415C10+75j
    xor     edi, edi

    loc_415C8F:                             ; CODE XREF: sub_415C10+7Bj
    mov     eax, [esi+0Ch]
    mov     edx, [esi+8]
    mov     ecx, edi
    lea     edx, [eax+edx*4]
    cmp     eax, edx
    jz      short loc_415CAC

    loc_415C9E:                             ; CODE XREF: sub_415C10+9Aj
    mov     ebp, [eax]
    add     eax, 4
    mov     [ecx], ebp
    add     ecx, 4
    cmp     eax, edx
    jnz     short loc_415C9E

    loc_415CAC:                             ; CODE XREF: sub_415C10+8Cj
    mov     eax, [esi+0Ch]
    lea     ecx, [esi+10h]
    cmp     eax, ecx
    jz      short loc_415CBF
    push    eax
    call    sub_4B4F20
    add     esp, 4

    loc_415CBF:                             ; CODE XREF: sub_415C10+A4j
    mov     [esi+8], ebx
    mov     [esi+0Ch], edi

    loc_415CC5:                             ; CODE XREF: sub_415C10+64j
    mov     edx, [esi]
    mov     eax, [esi+0Ch]
    mov     dword ptr [eax+edx*4], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_415CD9:                             ; CODE XREF: sub_415C10+4Aj
    mov     ecx, [esi]
    mov     edi, 20h
    sub     edi, eax
    mov     eax, [esi+0Ch]
    mov     ebx, [esp+14h+arg_0]
    mov     ebp, 1
    lea     eax, [eax+ecx*4]
    mov     ecx, edi
    shl     ebp, cl
    mov     ecx, [esi+4]
    dec     ebp
    and     ebp, ebx
    shl     ebp, cl
    mov     ecx, [eax]
    or      ecx, ebp
    mov     [eax], ecx
    mov     eax, [esi]
    inc     eax
    mov     [esi], eax
    mov     ecx, eax
    mov     eax, [esi+8]
    cmp     ecx, eax
    jnz     short loc_415D74
    lea     ebp, [eax+eax]
    push    4                               ; int
    mov     [esp+18h+var_4], ebp
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_415D2C
    mov     [eax], ebp
    mov     ebp, eax
    jmp     short loc_415D2E
    ; ---------------------------------------------------------------------------

    loc_415D2C:                             ; CODE XREF: sub_415C10+114j
    xor     ebp, ebp

    loc_415D2E:                             ; CODE XREF: sub_415C10+11Aj
    mov     eax, [esi+0Ch]
    mov     edx, [esi+8]
    mov     [esp+14h+arg_0], ebp
    mov     ecx, ebp
    lea     edx, [eax+edx*4]
    cmp     eax, edx
    jz      short loc_415D53

    loc_415D41:                             ; CODE XREF: sub_415C10+13Dj
    mov     ebp, [eax]
    add     eax, 4
    mov     [ecx], ebp
    add     ecx, 4
    cmp     eax, edx
    jnz     short loc_415D41
    mov     ebp, [esp+14h+arg_0]

    loc_415D53:                             ; CODE XREF: sub_415C10+12Fj
    mov     eax, [esi+0Ch]
    lea     ecx, [esi+10h]
    cmp     eax, ecx
    jz      short loc_415D66
    push    eax
    call    sub_4B4F20
    add     esp, 4

    loc_415D66:                             ; CODE XREF: sub_415C10+14Bj
    mov     edx, [esp+14h+var_4]
    mov     [esi+0Ch], ebp
    mov     [esi+8], edx
    mov     edx, [esp+14h+arg_4]

    loc_415D74:                             ; CODE XREF: sub_415C10+FFj
    mov     eax, edx
    mov     ecx, edi
    sub     eax, edi
    mov     edx, 1
    shr     ebx, cl
    mov     ecx, eax
    mov     [esi+4], eax
    mov     eax, [esi]
    pop     edi
    shl     edx, cl
    mov     ecx, [esi+0Ch]
    pop     esi
    pop     ebp
    dec     edx
    and     ebx, edx
    mov     [ecx+eax*4], ebx
    pop     ebx
    pop     ecx
    retn    8
    sub_415C10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415DA0 proc near                    ; CODE XREF: sub_48B710+1B3p
                                            ; sub_48B710+1D3p

    arg_0= dword ptr  4
    arg_4= byte ptr  8

    mov     eax, [ecx+0Ch]
    mov     edx, [esp+arg_0]
    mov     cl, [esp+arg_4]
    mov     [eax+edx], cl
    retn    8
    sub_415DA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415DC0 proc near                    ; CODE XREF: sub_415E60+6p
                                            ; sub_44E080+32p ...

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     edx, ecx
    push    esi
    push    edi
    mov     edi, [esp+8+arg_0]
    mov     ecx, [edx+8]
    lea     esi, [edi+ecx]
    cmp     esi, 20h
    jge     short loc_415DF5
    mov     eax, [edx+4]
    mov     ebx, [edx]
    mov     eax, [ebx+eax*4]
    mov     ebx, 1
    shr     eax, cl
    mov     ecx, edi
    mov     [edx+8], esi
    shl     ebx, cl
    dec     ebx
    and     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_415DF5:                             ; CODE XREF: sub_415DC0+13j
    test    ecx, ecx
    jnz     short loc_415E0C
    mov     ecx, [edx+4]
    mov     eax, [edx]
    mov     eax, [eax+ecx*4]
    inc     ecx
    mov     [edx+4], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_415E0C:                             ; CODE XREF: sub_415DC0+37j
    mov     edi, [edx+4]
    mov     ebx, [edx]
    mov     esi, 20h
    mov     ebp, 1
    mov     eax, [ebx+edi*4]
    sub     esi, ecx
    mov     ecx, [edx+8]
    shr     eax, cl
    mov     ecx, esi
    shl     ebp, cl
    mov     ecx, [esp+8+arg_0]
    sub     ecx, esi
    mov     [edx+8], ecx
    dec     ebp
    and     eax, ebp
    inc     edi
    mov     [edx+4], edi
    mov     edx, 1
    mov     edi, [ebx+edi*4]
    shl     edx, cl
    mov     ecx, esi
    dec     edx
    and     edi, edx
    shl     edi, cl
    or      eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_415DC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415E60 proc near                    ; CODE XREF: sub_48B3F0+189p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    esi
    call    sub_415DC0
    lea     ecx, [esi-1]
    mov     edx, 1
    shl     edx, cl
    test    eax, edx
    jz      short loc_415E82
    or      edx, 0FFFFFFFFh
    mov     ecx, esi
    shl     edx, cl
    or      eax, edx

    loc_415E82:                             ; CODE XREF: sub_415E60+17j
    pop     esi
    retn    4
    sub_415E60 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     ecx, [eax+38A47h]
    mov     dword_511BC0, edx
    mov     dword_511C20, ecx
    mov     dword_511BC4, edx
    mov     ecx, offset dword_511C64
    xor     eax, eax

    loc_415EB6:                             ; CODE XREF: .text:00415ED5j
    mov     dword_511A60[eax], edx
    mov     dword_511A64[eax], edx
    mov     dword_511C60[eax], edx
    mov     [ecx], edx
    add     eax, 8
    add     ecx, 8
    cmp     eax, 160h
    jl      short loc_415EB6
    mov     Global_PacketCount_1, edx
    mov     Global_PacketSumSize_1, edx
    mov     Global_PacketCount_2, edx
    mov     Global_PacketSumSize_2, edx
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415EF0 proc near                    ; CODE XREF: Network_BroadcastMessage+1FBp
                                            ; sub_451DF0+120p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_8]
    mov     edx, [esp+arg_4]
    mov     eax, dword_511BC0[ecx*4]
    add     eax, edx
    mov     dword_511BC0[ecx*4], eax
    mov     eax, [esp+arg_0]
    cmp     al, 1
    jbe     short locret_415F3A
    cmp     al, 2Dh
    jnb     short locret_415F3A
    and     eax, 0FFh
    lea     eax, [ecx+eax*2]
    shl     eax, 2
    mov     ecx, dword_511A58[eax]
    inc     ecx
    mov     dword_511A58[eax], ecx
    mov     ecx, dword_511C58[eax]
    add     ecx, edx
    mov     dword_511C58[eax], ecx

    locret_415F3A:                          ; CODE XREF: sub_415EF0+1Ej
                                            ; sub_415EF0+22j
    retn    0Ch
    sub_415EF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall HAPINET_PacketStatistics(int DataSize,int arg4,int arg8)
    HAPINET_PacketStatistics proc near      ; CODE XREF: sub_44F9C0+CCp
                                            ; Network_SendNetMessage+112p ...

    DataSize= dword ptr  4
    arg4= dword ptr  8
    arg8= dword ptr  0Ch

    mov     eax, [esp+arg4]                 ; arg4 isnt a constant value even with just 1 player
    test    eax, eax
    jle     short loc_415F4E
    add     dword_511DC8, eax

    loc_415F4E:                             ; CODE XREF: HAPINET_PacketStatistics+6j
    mov     eax, [esp+arg8]                 ; arg4 == 0, some other local player?
    test    eax, eax
    jz      short loc_415F76
    mov     eax, Global_PacketCount_1
    mov     ecx, Global_PacketSumSize_1
    inc     eax
    mov     Global_PacketCount_1, eax
    mov     eax, [esp+DataSize]
    add     ecx, eax
    mov     Global_PacketSumSize_1, ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_415F76:                             ; CODE XREF: HAPINET_PacketStatistics+14j
    mov     ecx, Global_PacketCount_2
    mov     eax, Global_PacketSumSize_2
    inc     ecx
    mov     Global_PacketCount_2, ecx
    mov     ecx, [esp+DataSize]
    add     eax, ecx
    mov     Global_PacketSumSize_2, eax
    retn    0Ch
    HAPINET_PacketStatistics endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_415FA0 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+13F3p

    arg_0= dword ptr  8

    push    esi
    call    sub_4B6340
    mov     esi, dword_511DD8
    mov     ecx, eax
    sub     ecx, esi
    cmp     ecx, 1Eh
    jbe     loc_416106
    mov     dword_511DD8, eax
    mov     eax, dword_511C40
    push    edi
    mov     edi, dword_511BC0
    lea     eax, [eax+eax*2]
    push    ebp
    mov     ebp, dword_511C44
    push    ebx
    lea     eax, [eax+eax*4]
    mov     ebx, dword_511BC4
    shl     eax, 1
    mov     edx, eax
    lea     eax, [edi+edi*2]
    mov     esi, ebx
    mov     dword_511C40, edi
    lea     eax, [eax+eax*4]
    sub     esi, ebp
    shl     eax, 1
    sub     eax, edx
    xor     edx, edx
    div     ecx
    xor     edx, edx
    mov     edi, dword_511DC8
    mov     dword_511C44, ebx
    mov     dword_511C38, eax
    lea     eax, [esi+esi*2]
    lea     eax, [eax+eax*4]
    shl     eax, 1
    div     ecx
    test    esi, esi
    mov     dword_511C3C, eax
    jle     short loc_41603C
    mov     eax, dword_511DCC
    add     eax, esi
    sub     eax, edi
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 2
    cdq
    idiv    esi
    mov     dword_511A44, eax
    jmp     short loc_416046
    ; ---------------------------------------------------------------------------

    loc_41603C:                             ; CODE XREF: sub_415FA0+7Ej
    mov     dword_511A44, 0

    loc_416046:                             ; CODE XREF: sub_415FA0+9Aj
    mov     eax, dword_511A4C
    mov     esi, Global_PacketSumSize_1
    mov     dword_511DCC, edi
    mov     edi, Global_PacketSumSize_2
    lea     eax, [eax+eax*2]
    mov     ebx, Global_PacketCount_1
    mov     ebp, Global_PacketCount_2
    mov     dword_511A4C, esi
    lea     edx, [eax+eax*4]
    lea     eax, [esi+esi*2]
    shl     edx, 1
    lea     eax, [eax+eax*4]
    shl     eax, 1
    sub     eax, edx
    xor     edx, edx
    div     ecx
    mov     dword_511C4C, eax
    mov     eax, dword_511BCC
    mov     dword_511BCC, edi
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*4]
    shl     eax, 1
    mov     edx, eax
    lea     eax, [edi+edi*2]
    lea     eax, [eax+eax*4]
    shl     eax, 1
    sub     eax, edx
    xor     edx, edx
    div     ecx
    mov     dword_511C30, eax
    mov     eax, dword_511C24
    mov     dword_511C24, ebx
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*4]
    shl     eax, 1
    mov     edx, eax
    lea     eax, [ebx+ebx*2]
    pop     ebx
    lea     eax, [eax+eax*4]
    shl     eax, 1
    sub     eax, edx
    xor     edx, edx
    div     ecx
    mov     dword_511DC4, eax
    mov     eax, dword_511C28
    mov     dword_511C28, ebp
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*4]
    shl     eax, 1
    mov     edx, eax
    lea     eax, [ebp+ebp*2+0]
    pop     ebp
    pop     edi
    lea     eax, [eax+eax*4]
    shl     eax, 1
    sub     eax, edx
    xor     edx, edx
    div     ecx
    mov     dword_511DC0, eax

    loc_416106:                             ; CODE XREF: sub_415FA0+13j
    mov     eax, dword_511A44
    mov     ecx, dword_511C30
    mov     edx, dword_511DC0
    push    eax
    mov     eax, dword_511C4C
    push    ecx
    mov     ecx, dword_511DC4
    push    edx
    mov     edx, dword_511C38
    push    eax
    mov     eax, dword_511C3C
    push    ecx
    mov     ecx, [esp+14h+arg_0]
    push    edx
    push    eax
    push    offset aPs4dPr4dSD4dRD          ; "pS=%4d pR=%4d (S=%d/%4d, R=%d/%4d) C=%3"...
    push    ecx
    call    _sprintf
    add     esp, 24h
    pop     esi
    retn    4
    sub_415FA0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_416150 proc near                    ; CODE XREF: sub_468380+41p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    edi
    call    sub_4B6340
    mov     edx, dword_511DDC
    mov     edi, eax
    sub     edi, edx
    cmp     edi, 1Eh
    jbe     short loc_4161C6
    mov     ecx, Global_PacketSumSize_1
    mov     edx, dword_511C2C
    mov     dword_511DDC, eax
    push    esi
    lea     eax, [ecx+ecx*2]
    lea     edx, [edx+edx*2]
    mov     esi, Global_PacketSumSize_2
    mov     dword_511C2C, ecx
    lea     eax, [eax+eax*4]
    lea     edx, [edx+edx*4]
    shl     eax, 1
    shl     edx, 1
    sub     eax, edx
    xor     edx, edx
    div     edi
    mov     edx, dword_511A40
    mov     dword_511A40, esi
    lea     edx, [edx+edx*2]
    lea     edx, [edx+edx*4]
    shl     edx, 1
    mov     dword_511A48, eax
    lea     eax, [esi+esi*2]
    pop     esi
    lea     eax, [eax+eax*4]
    shl     eax, 1
    sub     eax, edx
    xor     edx, edx
    div     edi
    mov     dword_511A50, eax

    loc_4161C6:                             ; CODE XREF: sub_416150+13j
    mov     eax, [esp+arg_0]
    mov     ecx, dword_511A48
    mov     edx, [esp+arg_4]
    pop     edi
    mov     [eax], ecx
    mov     eax, dword_511A50
    mov     [edx], eax
    retn    8
    sub_416150 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4161F0()
    sub_4161F0 proc near                    ; CODE XREF: sub_417570p
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     esi, esi
    xor     edi, edi
    xor     ecx, ecx
    xor     edx, edx
    mov     ebx, offset dword_511C64
    xor     eax, eax

    loc_416203:                             ; CODE XREF: sub_4161F0+3Aj
    mov     ebp, dword_511A60[eax]
    add     eax, 8
    add     ecx, ebp
    mov     ebp, dword_511A5C[eax]
    add     edx, ebp
    mov     ebp, dword_511C58[eax]
    add     esi, ebp
    mov     ebp, [ebx]
    add     edi, ebp
    add     ebx, 8
    cmp     eax, 160h
    jl      short loc_416203
    mov     ecx, offset dword_513000
    call    nullsub_41
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4161F0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_416240()
    sub_416240 proc near
    push    0                               ; hTemplateFile
    push    80h                             ; dwFlagsAndAttributes
    push    2                               ; dwCreationDisposition
    push    0                               ; lpSecurityAttributes
    push    0                               ; dwShareMode
    push    40000000h                       ; dwDesiredAccess
    push    offset aMemdump_txt             ; lpFileName
    call    ds:CreateFileA
    test    eax, eax
    jz      short locret_416268
    push    eax                             ; hObject
    call    ds:CloseHandle

    locret_416268:                          ; CODE XREF: sub_416240+1Fj
    retn    4
    sub_416240 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_81. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_416280 proc near                    ; DATA XREF: .data:00501FD4o

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [ecx+2A42h]
    mov     ecx, [esp+arg_0]
    push    eax                             ; int
    push    1                               ; int
    call    sub_4B73E0
    cmp     al, 0Ah
    mov     byte ptr [esp+arg_0], al
    jnb     short locret_416303
    mov     eax, [esp+arg_0]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    add     ecx, eax
    mov     eax, [ecx+edx*2+1B63h]
    lea     ecx, [ecx+edx*2+1B63h]
    test    eax, eax
    jz      short locret_416303
    mov     al, [ecx+73h]
    cmp     al, 1
    jz      short loc_4162DE
    cmp     al, 2
    jz      short loc_4162DE
    cmp     al, 3
    jnz     short locret_416303

    loc_4162DE:                             ; CODE XREF: sub_416280+54j
                                            ; sub_416280+58j
    cmp     byte ptr [ecx+146h], 0Ah
    jz      short locret_416303
    cmp     dword ptr [ecx], 0
    jz      short loc_4162FC
    cmp     byte ptr [ecx+73h], 1
    jnz     short loc_4162FC
    push    2
    call    sub_463C60
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4162FC:                             ; CODE XREF: sub_416280+6Aj
                                            ; sub_416280+70j
    push    1
    call    sub_463C60

    locret_416303:                          ; CODE XREF: sub_416280+20j
                                            ; sub_416280+4Dj ...
    retn    4
    sub_416280 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+8]
    push    offset Data
    push    1
    mov     ecx, esi
    call    sub_4B73C0
    push    eax
    lea     ecx, [esp+0Ch]
    call    sub_438760
    mov     al, [esp+8]
    test    al, al
    jz      short loc_41636C
    push    edi
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    push    0
    push    2
    mov     ecx, esi
    mov     edi, eax
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    push    eax
    mov     eax, [esp+10h]
    push    edi
    push    0
    push    eax
    add     ecx, 2C76h
    push    0
    push    ecx
    call    sub_48CF30
    pop     edi

    loc_41636C:                             ; CODE XREF: .text:00416333j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    call    sub_424840
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    cmp     word ptr [eax+2CBCh], 0FFFBh
    jnb     short locret_4163CD
    movsx   ecx, word ptr [eax+2C90h]
    movsx   edx, word ptr [eax+2C8Eh]
    push    ecx
    push    edx
    call    sub_481550
    push    1
    push    eax
    call    sub_4246B0

    locret_4163CD:                          ; CODE XREF: .text:004163AEj
    retn    4
    ; ---------------------------------------------------------------------------
    mov     ecx, [esp+4]
    push    esi
    push    offset Data
    push    1
    call    sub_4B73C0
    push    eax
    call    sub_422DD0
    mov     esi, eax
    cmp     si, 0FFFFh
    jz      short loc_416417
    mov     eax, TAdynmemStructPtr
    movsx   ecx, word ptr [eax+2C90h]
    movsx   edx, word ptr [eax+2C8Eh]
    push    ecx
    push    edx
    call    sub_481550
    push    0Ah
    push    0
    push    0
    push    esi
    push    eax
    call    sub_423C50

    loc_416417:                             ; CODE XREF: .text:004163EEj
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 20h
    xor     edx, eax
    mov     [ecx+37F06h], dx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1437Bh]
    call    sub_437C80
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+14357h]
    mov     eax, [edx+1435Bh]
    add     ecx, 118h
    cmp     ecx, eax
    ja      short locret_4164A7

    loc_41647C:                             ; CODE XREF: .text:004164A5j
    mov     eax, [ecx+110h]
    test    eax, 10000000h
    jz      short loc_416497
    or      al, 20h
    mov     [ecx+110h], eax
    mov     edx, TAdynmemStructPtr

    loc_416497:                             ; CODE XREF: .text:00416487j
    mov     eax, [edx+1435Bh]
    add     ecx, 118h
    cmp     ecx, eax
    jbe     short loc_41647C

    locret_4164A7:                          ; CODE XREF: .text:0041647Aj
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    cmp     dword ptr [ecx+0D0h], 1
    jnz     short loc_4164D5
    call    sub_486ED0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391EDh]
    call    sub_4904B0
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4164D5:                             ; CODE XREF: .text:004164BBj
    push    0
    push    1
    call    sub_4B73E0
    push    eax
    call    sub_486F10
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391EDh]
    call    sub_4904B0
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 2
    xor     edx, eax
    mov     [ecx+37F06h], dx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1437Bh]
    call    sub_437C80
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 4
    xor     edx, eax
    mov     [ecx+37F06h], dx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1437Bh]
    call    sub_437C80
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 40h
    xor     edx, eax
    mov     [ecx+37F06h], dx
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    cmp     dword ptr [ecx+0D0h], 2
    jge     short loc_4165F7
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    not     edx
    xor     edx, eax
    and     edx, 100h
    xor     edx, eax
    mov     [ecx+37F06h], dx
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4165F7:                             ; CODE XREF: .text:004165CBj
    push    ebx
    push    0
    push    1
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    and     al, 1
    xor     ebx, ebx
    mov     dx, [ecx+37F06h]
    mov     bh, al
    and     edx, 0FEFFh
    or      edx, ebx
    pop     ebx
    mov     [ecx+37F06h], dx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 8
    xor     edx, eax
    mov     [ecx+37F06h], dx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 10h
    xor     edx, eax
    mov     [ecx+37F06h], dx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    push    0
    mov     ax, [ecx+14281h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 4
    xor     edx, eax
    mov     [ecx+14281h], dx
    call    Set_LOS_State
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+8]
    push    0
    push    3
    mov     ecx, esi
    call    sub_4B73E0
    push    eax
    push    0
    push    2
    mov     ecx, esi
    call    sub_4B73E0
    push    eax
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    push    eax
    call    sub_4597F0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1437Bh]
    call    sub_437C80
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1437Bh]
    call    sub_437C80
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+8]
    push    20h
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    push    80h
    push    2
    mov     edx, [ecx+14223h]
    sub     edx, eax
    mov     [ecx+1422Bh], edx
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    pop     esi
    mov     edx, [ecx+14227h]
    sub     edx, eax
    mov     [ecx+1422Fh], edx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+8]
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    test    eax, eax
    jz      short loc_4167AE
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14207h]
    mov     [edx+48h], eax

    loc_4167AE:                             ; CODE XREF: .text:00416792j
    cmp     dword ptr [esi+0D0h], 3
    jnz     short loc_4167E8
    push    offset Data
    push    2
    mov     ecx, esi
    call    sub_4B73C0
    push    eax
    call    _atof
    fmul    ds:dbl_4FCC70
    add     esp, 4
    call    __ftol
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14207h]
    mov     [edx+54h], eax

    loc_4167E8:                             ; CODE XREF: .text:004167B5j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    push    1
    push    0
    push    1
    call    sub_4B73E0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CEB60
    retn    4
    ; ---------------------------------------------------------------------------
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CED40
    retn    4
    ; ---------------------------------------------------------------------------
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CFEA0
    test    eax, eax
    jz      short loc_416847
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CFE90
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------

    loc_416847:                             ; CODE XREF: .text:0041682Fj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CFE80
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, [esp+8]
    push    offset aMove                    ; "move"
    push    offset Data
    push    0
    mov     ecx, esi
    call    sub_4B73C0
    push    eax
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_4168C0
    push    eax
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    push    0
    shl     eax, 14h
    mov     edx, [ecx+2CAAh]
    push    2
    add     edx, eax
    mov     [ecx+2CAAh], edx
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    shl     eax, 14h
    add     [ecx+2CB2h], eax

    loc_4168C0:                             ; CODE XREF: .text:00416883j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    TextCommand_Logo proc near

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    0                               ; int
    push    1                               ; int
    mov     ecx, esi
    call    sub_4B73E0
    test    eax, eax
    jl      loc_4169B8
    push    0                               ; int
    push    1                               ; int
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+148DBh]
    xor     ecx, ecx
    mov     cx, [edx]
    cmp     eax, ecx
    jge     loc_4169B8
    push    0                               ; int
    push    2                               ; int
    mov     ecx, esi
    call    sub_4B73E0
    cmp     al, 0Ah
    mov     byte ptr [esp+arg_0], al
    jnb     loc_4169B8
    mov     eax, [esp+arg_0]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    add     ecx, eax
    lea     eax, [ecx+edx*2+1B63h]
    mov     ecx, [ecx+edx*2+1B63h]
    test    ecx, ecx
    jz      short loc_4169B8
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_416963
    cmp     cl, 2
    jz      short loc_416963
    cmp     cl, 3
    jnz     short loc_4169B8

    loc_416963:                             ; CODE XREF: TextCommand_Logo+87j
                                            ; TextCommand_Logo+8Cj
    cmp     byte ptr [eax+146h], 0Ah
    jz      short loc_4169B8
    push    0                               ; int
    push    1                               ; int
    mov     ecx, esi
    call    sub_4B73E0
    push    0                               ; int
    push    2                               ; int
    mov     ecx, esi
    mov     ebx, eax
    call    sub_4B73E0
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    add     ecx, eax
    mov     edx, [ecx+edx*2+1B8Ah]
    mov     [edx+96h], bl
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1437Bh]
    call    sub_437C80
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4169B8:                             ; CODE XREF: TextCommand_Logo+13j
                                            ; TextCommand_Logo+37j ...
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    offset aInvalidLogoSet          ; char *
    call    sub_463CA0
    pop     esi
    pop     ebx
    retn    4
    TextCommand_Logo endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4169D0 proc near

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    cmp     byte ptr [ecx+95h], 1
    jnz     short loc_4169FE
    push    0
    jmp     short loc_416A00
    ; ---------------------------------------------------------------------------

    loc_4169FE:                             ; CODE XREF: sub_4169D0+28j
    push    1

    loc_416A00:                             ; CODE XREF: sub_4169D0+2Cj
    call    sub_486F10
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 10h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 20h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 4
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    mov     dl, [ecx+95h]
    push    edx
    call    sub_486F10
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 40h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 4
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+arg_0]
    push    0                               ; int
    push    1                               ; int
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+1427Fh], al
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+4+arg_0]
    push    0                               ; int
    push    1                               ; int
    mov     ecx, esi
    call    sub_4B73E0
    cmp     al, 0Ah
    mov     byte ptr [esp+4+arg_0], al
    jnb     short loc_416B3E
    mov     eax, [esp+4+arg_0]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+TAdynmemStruct.Players]
    mov     ecx, [edx+ecx*2+TAdynmemStruct.Players.PlayerActive]
    test    ecx, ecx
    jz      short loc_416B3E
    mov     cl, [eax+PlayerStruct.PlayerType]
    cmp     cl, Player_LocalHuman
    jz      short loc_416B07
    cmp     cl, Player_AI
    jz      short loc_416B07
    cmp     cl, Player_RemoteHuman
    jnz     short loc_416B3E

    loc_416B07:                             ; CODE XREF: sub_4169D0+12Bj
                                            ; sub_4169D0+130j
    cmp     [eax+PlayerStruct.PlayerNumber], 0Ah
    jz      short loc_416B3E
    push    0                               ; int
    push    1                               ; int
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    push    0                               ; int
    push    1                               ; int
    mov     [ecx+TAdynmemStruct.SharedBits], al
    mov     ecx, esi
    call    sub_4B73E0
    mov     edx, TAdynmemStructPtr
    mov     [edx+TAdynmemStruct.LOS_Sight], al

    loc_416B3E:                             ; CODE XREF: sub_4169D0+F6j
                                            ; sub_4169D0+123j ...
    pop     esi
    retn    4
    sub_4169D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall TextCommand_View(int)
    TextCommand_View proc near

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    0                               ; int
    push    1                               ; int
    mov     ecx, esi
    call    sub_4B73E0
    cmp     al, 0Ah
    mov     byte ptr [esp+arg_0], al
    jnb     short loc_416BC7
    mov     eax, [esp+arg_0]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+TAdynmemStruct.Players]
    mov     ecx, [edx+ecx*2+TAdynmemStruct.Players.PlayerActive]
    test    ecx, ecx
    jz      short loc_416BC7
    mov     cl, [eax+PlayerStruct.PlayerType]
    cmp     cl, Player_LocalHuman
    jz      short loc_416BA7
    cmp     cl, Player_AI
    jz      short loc_416BA7
    cmp     cl, Player_RemoteHuman
    jnz     short loc_416BC7

    loc_416BA7:                             ; CODE XREF: TextCommand_View+4Bj
                                            ; TextCommand_View+50j
    cmp     [eax+PlayerStruct.PlayerNumber], 0Ah
    jz      short loc_416BC7
    push    0                               ; int
    push    1                               ; int
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+TAdynmemStruct.LOS_Sight], al ; The player to use for LOS calcs

    loc_416BC7:                             ; CODE XREF: TextCommand_View+16j
                                            ; TextCommand_View+43j ...
    pop     esi
    retn    4
    TextCommand_View endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+8]
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    cmp     al, 0Ah
    mov     [esp+8], al
    jnb     loc_416CE8
    mov     eax, [esp+8]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edx+ecx*2+1B63h]
    lea     ecx, [edx+ecx*2+1B63h]
    test    eax, eax
    jz      loc_416CE8
    mov     al, [ecx+73h]
    cmp     al, 1
    jz      short loc_416C30
    cmp     al, 2
    jz      short loc_416C30
    cmp     al, 3
    jnz     loc_416CE8

    loc_416C30:                             ; CODE XREF: .text:00416C22j
                                            ; .text:00416C26j
    cmp     byte ptr [ecx+146h], 0Ah
    jz      loc_416CE8
    push    offset aMetal_0                 ; "metal"
    push    offset Data
    push    3
    mov     ecx, esi
    call    sub_4B73C0
    push    eax
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_416C92
    push    1
    push    eax
    push    2
    mov     ecx, esi
    call    sub_4B73E0
    push    ecx
    mov     ecx, esi
    mov     [esp+10h], eax
    fild    dword ptr [esp+10h]
    fstp    dword ptr [esp]
    push    0
    push    1
    call    sub_4B73E0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2A42h]
    push    ecx
    call    sub_464C60

    loc_416C92:                             ; CODE XREF: .text:00416C5Bj
    push    offset aEnergy_0                ; "energy"
    push    offset Data
    push    3
    mov     ecx, esi
    call    sub_4B73C0
    push    eax
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_416CE8
    push    1
    push    eax
    push    2
    mov     ecx, esi
    call    sub_4B73E0
    push    ecx
    mov     ecx, esi
    mov     [esp+10h], eax
    fild    dword ptr [esp+10h]
    fstp    dword ptr [esp]
    push    0
    push    1
    call    sub_4B73E0
    mov     edx, TAdynmemStructPtr
    push    eax
    mov     al, [edx+2A42h]
    push    eax
    call    sub_464B30

    loc_416CE8:                             ; CODE XREF: .text:00416BE6j
                                            ; .text:00416C17j ...
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    push    0
    push    1
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+1434Dh], al
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    push    0
    push    1
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37EFAh], eax
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall TextCommand_LOS()
    TextCommand_LOS proc near
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+14281h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 2
    xor     edx, eax
    mov     [ecx+14281h], dx
    call    WriteRegistrySettings_2
    push    0                               ; int
    call    Set_LOS_State
    retn    4
    TextCommand_LOS endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_416D80()
    sub_416D80 proc near
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+14281h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [ecx+14281h], dx
    call    WriteRegistrySettings_2
    push    1                               ; int
    call    Set_LOS_State
    retn    4
    sub_416D80 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, [esp+8]
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B7410
    fmul    ds:flt_4FCC78
    call    __ftol
    push    3F400000h
    push    2
    mov     ecx, esi
    mov     dword_511DD0, eax
    call    sub_4B7410
    fmul    ds:flt_4FCC78
    call    __ftol
    mov     dword_511DD4, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F2Fh]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 4
    xor     edx, eax
    mov     [ecx+37F2Fh], dx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F2Fh]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 8
    xor     edx, eax
    mov     [ecx+37F2Fh], dx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_416E60 proc near                    ; DATA XREF: .data:00501D3Co
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F2Fh]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 10h
    xor     edx, eax
    mov     [ecx+37F2Fh], dx
    retn    4
    sub_416E60 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+10h]
    cmp     dword ptr [edi+0D0h], 6
    jnz     loc_417016
    push    offset Data
    push    1
    mov     ecx, edi
    mov     esi, offset aFilm               ; "Film"
    call    sub_4B73C0

    loc_416EB7:                             ; CODE XREF: .text:00416ED9j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416EDF
    test    cl, cl
    jz      short loc_416EDB
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416EDF
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_416EB7

    loc_416EDB:                             ; CODE XREF: .text:00416EC3j
    xor     eax, eax
    jmp     short loc_416EE4
    ; ---------------------------------------------------------------------------

    loc_416EDF:                             ; CODE XREF: .text:00416EBFj
                                            ; .text:00416ECFj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_416EE4:                             ; CODE XREF: .text:00416EDDj
    test    eax, eax
    jnz     loc_417016
    push    offset Data
    push    2
    mov     ecx, edi
    mov     esi, offset aChris              ; "Chris"
    call    sub_4B73C0

    loc_416EFF:                             ; CODE XREF: .text:00416F21j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416F27
    test    cl, cl
    jz      short loc_416F23
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416F27
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_416EFF

    loc_416F23:                             ; CODE XREF: .text:00416F0Bj
    xor     eax, eax
    jmp     short loc_416F2C
    ; ---------------------------------------------------------------------------

    loc_416F27:                             ; CODE XREF: .text:00416F07j
                                            ; .text:00416F17j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_416F2C:                             ; CODE XREF: .text:00416F25j
    test    eax, eax
    jnz     loc_417016
    push    offset Data
    push    3
    mov     ecx, edi
    mov     esi, offset aInclude            ; "Include"
    call    sub_4B73C0

    loc_416F47:                             ; CODE XREF: .text:00416F69j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416F6F
    test    cl, cl
    jz      short loc_416F6B
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416F6F
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_416F47

    loc_416F6B:                             ; CODE XREF: .text:00416F53j
    xor     eax, eax
    jmp     short loc_416F74
    ; ---------------------------------------------------------------------------

    loc_416F6F:                             ; CODE XREF: .text:00416F4Fj
                                            ; .text:00416F5Fj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_416F74:                             ; CODE XREF: .text:00416F6Dj
    test    eax, eax
    jnz     loc_417016
    push    offset Data
    push    4
    mov     ecx, edi
    mov     esi, offset aReload             ; "Reload"
    call    sub_4B73C0

    loc_416F8F:                             ; CODE XREF: .text:00416FB1j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416FB7
    test    cl, cl
    jz      short loc_416FB3
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416FB7
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_416F8F

    loc_416FB3:                             ; CODE XREF: .text:00416F9Bj
    xor     eax, eax
    jmp     short loc_416FBC
    ; ---------------------------------------------------------------------------

    loc_416FB7:                             ; CODE XREF: .text:00416F97j
                                            ; .text:00416FA7j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_416FBC:                             ; CODE XREF: .text:00416FB5j
    test    eax, eax
    jnz     short loc_417016
    push    offset Data
    push    5
    mov     ecx, edi
    mov     esi, offset aAssert             ; "Assert"
    call    sub_4B73C0

    loc_416FD3:                             ; CODE XREF: .text:00416FF5j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416FFB
    test    cl, cl
    jz      short loc_416FF7
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_416FFB
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_416FD3

    loc_416FF7:                             ; CODE XREF: .text:00416FDFj
    xor     eax, eax
    jmp     short loc_417000
    ; ---------------------------------------------------------------------------

    loc_416FFB:                             ; CODE XREF: .text:00416FDBj
                                            ; .text:00416FEBj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_417000:                             ; CODE XREF: .text:00416FF9j
    test    eax, eax
    jnz     short loc_417016
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F2Fh], 2
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_417016:                             ; CODE XREF: .text:00416E9Ej
                                            ; .text:00416EE6j ...
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebx
    and     word ptr [eax+37F2Fh], 0FFFDh
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F2Fh]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 80h
    xor     edx, eax
    mov     [ecx+37F2Fh], dx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F2Fh]
    mov     edx, eax
    not     edx
    xor     edx, eax
    and     edx, 100h
    xor     edx, eax
    mov     [ecx+37F2Fh], dx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417090 proc near                    ; DATA XREF: .data:00501F4Co
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F2Fh]
    mov     edx, eax
    not     edx
    xor     edx, eax
    and     edx, 200h
    xor     edx, eax
    mov     [ecx+37F2Fh], dx
    retn    4
    sub_417090 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4170C0()
    sub_4170C0 proc near
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    fld     [ecx+eax*2+TAdynmemStruct.Players.Resources.fCurrentEnergy]
    fsub    ds:flt_4FCC7C
    lea     eax, [ecx+eax*2+TAdynmemStruct.Players.Resources]
    fstp    dword ptr [eax]
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    fld     [ecx+eax*2+TAdynmemStruct.Players.Resources.fCurrentMetal]
    fsub    ds:flt_4FCC7C
    lea     eax, [ecx+eax*2+TAdynmemStruct.Players.Resources.fCurrentMetal]
    fstp    dword ptr [eax]
    retn    4
    sub_4170C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417130 proc near
    mov     eax, TAdynmemStructPtr
    xor     dword ptr [eax+37F02h], 1
    call    WriteRegistrySettings_2
    retn    4
    sub_417130 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417150 proc near

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    cmp     dword ptr [edi+0D0h], 1
    jnz     short loc_417171
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+2A42h]
    mov     byte ptr [esp+arg_0], al
    jmp     short loc_417186
    ; ---------------------------------------------------------------------------

    loc_417171:                             ; CODE XREF: sub_417150+Dj
    push    0                               ; int
    push    1                               ; int
    mov     ecx, edi
    call    sub_4B73E0
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [esp+arg_0], al

    loc_417186:                             ; CODE XREF: sub_417150+1Fj
    cmp     al, 0Ah
    jnb     short loc_4171E8
    mov     eax, [esp+arg_0]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     esi, [eax+ecx*2]
    mov     eax, [edx+esi+1B63h]
    test    eax, eax
    jz      short loc_4171E8
    mov     al, [edx+esi+1BD6h]
    cmp     al, 1
    jz      short loc_4171BE
    cmp     al, 2
    jz      short loc_4171BE
    cmp     al, 3
    jnz     short loc_4171E8

    loc_4171BE:                             ; CODE XREF: sub_417150+64j
                                            ; sub_417150+68j
    cmp     byte ptr [edx+esi+1CA9h], 0Ah
    jz      short loc_4171E8
    push    0                               ; int
    push    2                               ; int
    mov     ecx, edi
    call    sub_4B73E0
    mov     edx, TAdynmemStructPtr
    mov     [esp+arg_0], eax
    fild    [esp+arg_0]
    fstp    dword ptr [edx+esi+1BFBh]

    loc_4171E8:                             ; CODE XREF: sub_417150+38j
                                            ; sub_417150+59j ...
    pop     edi
    pop     esi
    retn    4
    sub_417150 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4171F0 proc near

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    cmp     dword ptr [edi+0D0h], 1
    jnz     short loc_417211
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+2A42h]
    mov     byte ptr [esp+arg_0], al
    jmp     short loc_417226
    ; ---------------------------------------------------------------------------

    loc_417211:                             ; CODE XREF: sub_4171F0+Dj
    push    0                               ; int
    push    1                               ; int
    mov     ecx, edi
    call    sub_4B73E0
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [esp+arg_0], al

    loc_417226:                             ; CODE XREF: sub_4171F0+1Fj
    cmp     al, 0Ah
    jnb     short loc_417288
    mov     eax, [esp+arg_0]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     esi, [eax+ecx*2]
    mov     eax, [edx+esi+1B63h]
    test    eax, eax
    jz      short loc_417288
    mov     al, [edx+esi+1BD6h]
    cmp     al, 1
    jz      short loc_41725E
    cmp     al, 2
    jz      short loc_41725E
    cmp     al, 3
    jnz     short loc_417288

    loc_41725E:                             ; CODE XREF: sub_4171F0+64j
                                            ; sub_4171F0+68j
    cmp     byte ptr [edx+esi+1CA9h], 0Ah
    jz      short loc_417288
    push    0                               ; int
    push    2                               ; int
    mov     ecx, edi
    call    sub_4B73E0
    mov     edx, TAdynmemStructPtr
    mov     [esp+arg_0], eax
    fild    [esp+arg_0]
    fstp    dword ptr [edx+esi+1BEFh]

    loc_417288:                             ; CODE XREF: sub_4171F0+38j
                                            ; sub_4171F0+59j ...
    pop     edi
    pop     esi
    retn    4
    sub_4171F0 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, [esp+8]
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    push    ecx
    mov     [esp+0Ch], eax
    fild    dword ptr [esp+0Ch]
    fmul    ds:flt_4FCC80
    fstp    dword ptr [esp]
    call    sub_4BA590
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F08h], eax
    call    WriteRegistrySettings_2
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, dword_51E698
    xor     eax, eax
    test    ecx, ecx
    setz    al
    mov     dword_51E698, eax
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F2Fh]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 40h
    xor     edx, eax
    mov     [ecx+37F2Fh], dx
    call    WriteRegistrySettings_2
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    cmp     dword ptr [ecx+0D0h], 1
    jle     locret_4173DC
    push    edi
    push    esi
    push    offset Data
    push    1
    call    sub_4B73C0
    mov     ecx, TAdynmemStructPtr
    mov     edi, eax
    xor     eax, eax
    lea     edx, [ecx+38A53h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edx, TAdynmemStructPtr
    or      ecx, 0FFFFFFFFh
    lea     esi, [edx+38A53h]
    mov     edi, esi
    repne scasb
    not     ecx
    dec     ecx
    cmp     byte ptr [ecx+edx+38A52h], 5Ch
    jz      short loc_4173B2
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     byte ptr [ecx+edx+38A52h], 2Fh
    jnz     short loc_4173CB

    loc_4173B2:                             ; CODE XREF: .text:0041739Aj
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     [ecx+edx+38A52h], al
    mov     edx, TAdynmemStructPtr

    loc_4173CB:                             ; CODE XREF: .text:004173B0j
    mov     dword ptr [edx+38C5Fh], 1
    call    WriteRegistrySettings_2
    pop     esi
    pop     edi

    locret_4173DC:                          ; CODE XREF: .text:0041733Bj
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+0D0h], 1
    jle     short loc_417429
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    test    eax, eax
    jle     short loc_417429
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38C57h], eax
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+38C63h], 1
    call    WriteRegistrySettings_2

    loc_417429:                             ; CODE XREF: .text:004173ECj
                                            ; .text:004173FBj
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, [esp+4]
    sub     esp, 100h
    cmp     dword ptr [ecx+0D0h], 1
    jle     short loc_417480
    push    offset Data
    push    1
    call    sub_4B73C0
    push    eax
    lea     eax, [esp+4]
    push    offset aSavegameS_sav           ; "savegame\\%s.sav"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    push    offset aSavegame                ; "savegame"
    call    sub_4BCF00
    push    29Ah
    lea     ecx, [esp+4]
    push    offset aGenericGameDes          ; "Generic Game Description"
    push    ecx
    call    sub_4326B0

    loc_417480:                             ; CODE XREF: .text:00417441j
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    push    esi
    cmp     dword ptr [ecx+0D0h], 1
    jle     short loc_4174C3
    push    offset Data
    push    1
    call    sub_4B73C0
    push    eax
    call    sub_488B10
    mov     esi, eax
    test    si, si
    jz      short loc_4174C3
    push    esi
    call    sub_486E80
    push    esi
    call    sub_42D1F0

    loc_4174C3:                             ; CODE XREF: .text:0041749Cj
                                            ; .text:004174B5j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    call    sub_40A100
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14373h]
    mov     edx, eax
    shr     edx, 1
    test    dl, 1
    jz      short loc_417505
    and     al, 0FDh
    mov     [ecx+14373h], eax
    call    sub_41C390
    retn    4
    ; ---------------------------------------------------------------------------

    loc_417505:                             ; CODE XREF: .text:004174F3j
    or      al, 2
    mov     [ecx+14373h], eax
    mov     eax, TAdynmemStructPtr
    mov     word ptr [eax+14371h], 1
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edx, [eax+38DD5h]
    test    edx, edx
    setz    cl
    mov     [eax+38DD5h], ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    1
    and     word ptr [eax+14281h], 0FFFEh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFFDh
    call    Set_LOS_State
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417570 proc near
    call    sub_4161F0
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     ecx, [eax+38A47h]
    mov     dword_511BC0, edx
    mov     dword_511C20, ecx
    mov     dword_511BC4, edx
    mov     ecx, offset dword_511C64
    xor     eax, eax

    loc_41759B:                             ; CODE XREF: sub_417570+4Aj
    mov     dword_511A60[eax], edx
    mov     dword_511A64[eax], edx
    mov     dword_511C60[eax], edx
    mov     [ecx], edx
    add     eax, 8
    add     ecx, 8
    cmp     eax, 160h
    jl      short loc_41759B
    mov     Global_PacketCount_1, edx
    mov     Global_PacketSumSize_1, edx
    mov     Global_PacketCount_2, edx
    mov     Global_PacketSumSize_2, edx
    retn    4
    sub_417570 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4175E0 proc near

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    push    0                               ; int
    push    1                               ; int
    call    sub_4B73E0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CE690
    retn    4
    sub_4175E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417600 proc near

    var_100= dword ptr -100h
    arg_0= dword ptr  4

    sub     esp, 100h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+110h+arg_0]
    mov     esi, 0C80h
    mov     ebx, 960h
    cmp     dword ptr [edi+0D0h], 1
    jle     short loc_417631
    push    0                               ; int
    push    1                               ; int
    mov     ecx, edi
    call    sub_4B73E0
    mov     esi, eax

    loc_417631:                             ; CODE XREF: sub_417600+22j
    cmp     dword ptr [edi+0D0h], 2
    jle     short loc_417647
    push    0                               ; int
    push    2                               ; int
    mov     ecx, edi
    call    sub_4B73E0
    mov     ebx, eax

    loc_417647:                             ; CODE XREF: sub_417600+38j
    push    offset aAll                     ; char *
    push    offset Data
    push    1
    mov     ecx, edi
    call    sub_4B73C0
    push    eax                             ; char *
    call    __strcmpi
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    test    eax, eax
    jnz     short loc_417679
    mov     esi, [ecx+1422Bh]
    mov     ebx, [ecx+1422Fh]

    loc_417679:                             ; CODE XREF: sub_417600+6Bj
    mov     edi, [ecx+1423Bh]
    mov     eax, edi
    shl     eax, 4
    cmp     esi, eax
    jg      short loc_41768A
    mov     esi, eax

    loc_41768A:                             ; CODE XREF: sub_417600+86j
    mov     eax, [ecx+1422Bh]
    cmp     esi, eax
    jl      short loc_417696
    mov     esi, eax

    loc_417696:                             ; CODE XREF: sub_417600+92j
    mov     ebp, [ecx+1423Fh]
    mov     eax, ebp
    shl     eax, 4
    cmp     ebx, eax
    jg      short loc_4176A7
    mov     ebx, eax

    loc_4176A7:                             ; CODE XREF: sub_417600+A3j
    mov     eax, [ecx+1422Fh]
    cmp     ebx, eax
    jl      short loc_4176B3
    mov     ebx, eax

    loc_4176B3:                             ; CODE XREF: sub_417600+AFj
    mov     eax, esi
    cdq
    sub     eax, edx
    mov     edx, [ecx+1431Fh]
    sar     eax, 1
    sub     edx, eax
    mov     eax, ebx
    lea     edi, [edx+edi*8]
    cdq
    sub     eax, edx
    mov     edx, [ecx+14323h]
    sar     eax, 1
    sub     edx, eax
    xor     eax, eax
    test    edi, edi
    setle   al
    dec     eax
    lea     ebp, [edx+ebp*8]
    and     edi, eax
    mov     eax, [ecx+1422Bh]
    sub     eax, esi
    cmp     edi, eax
    jl      short loc_4176EF
    mov     edi, eax

    loc_4176EF:                             ; CODE XREF: sub_417600+EBj
    mov     eax, [ecx+1422Fh]
    xor     edx, edx
    test    ebp, ebp
    setle   dl
    dec     edx
    sub     eax, ebx
    and     ebp, edx
    cmp     ebp, eax
    jl      short loc_417707
    mov     ebp, eax

    loc_417707:                             ; CODE XREF: sub_417600+103j
    add     ecx, 38A53h
    lea     eax, [esp+110h+var_100]
    push    ecx
    push    offset aSScreenshots            ; "%s\\screenshots"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+110h+var_100]
    push    ecx
    call    sub_4BCF00
    push    ebx                             ; int
    push    esi                             ; int
    push    ebp                             ; int
    push    edi                             ; int
    lea     edx, [esp+120h+var_100]
    push    offset aBigshot                 ; int
    push    edx                             ; int
    call    sub_495A30
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     [ecx+38A37h], eax
    pop     ebx
    add     esp, 100h
    retn    4
    sub_417600 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    cmp     dword ptr [ecx+0D0h], 1
    jle     short loc_41778A
    push    0
    push    1
    call    sub_4B73E0
    test    eax, eax
    jz      short loc_417782
    call    sub_437D40
    retn    4
    ; ---------------------------------------------------------------------------

    loc_417782:                             ; CODE XREF: .text:00417778j
    call    sub_437D50
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41778A:                             ; CODE XREF: .text:0041776Bj
    call    sub_438070
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    push    esi
    push    0
    push    1
    call    sub_4B73E0
    mov     esi, TAdynmemStructPtr
    xor     edx, edx
    test    eax, eax
    mov     cx, [esi+37F2Fh]
    setz    dl
    xor     dl, cl
    and     edx, 1
    xor     edx, ecx
    mov     [esi+37F2Fh], dx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    sub     esp, 4Ch
    push    edi
    push    offset Data
    push    0
    call    sub_4B73C0
    push    eax
    lea     eax, [esp+18h]
    push    offset aDebugdatS_txt           ; "debugdat\\%s.txt"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+14h]
    push    ecx
    call    sub_4BB5B0
    mov     edi, eax
    test    edi, edi
    jz      short loc_417884
    mov     edx, TAdynmemStructPtr
    push    esi
    add     edx, 2CAAh
    push    ebp
    push    ebx
    lea     ecx, [esp+10h]
    mov     ebx, [edx]
    push    ecx
    push    edi
    mov     ebp, [edx+4]
    mov     eax, [edx+8]
    lea     edx, [esp+28h]
    push    edx
    mov     [esp+28h], eax
    call    sub_4BBFF0
    mov     esi, eax
    test    esi, esi
    jz      short loc_417863
    mov     eax, [esp+60h]
    mov     ecx, [esp+10h]
    push    0FFFFFFFFh
    push    eax
    push    ecx
    push    esi
    call    sub_4B7A30
    push    esi
    call    sub_4D85A0
    add     esp, 4

    loc_417863:                             ; CODE XREF: .text:00417846j
    push    edi
    call    sub_4BB5D0
    mov     edx, TAdynmemStructPtr
    mov     eax, [esp+1Ch]
    add     edx, 2CAAh
    mov     [edx], ebx
    pop     ebx
    mov     [edx+4], ebp
    pop     ebp
    pop     esi
    mov     [edx+8], eax

    loc_417884:                             ; CODE XREF: .text:00417815j
    pop     edi
    add     esp, 4Ch
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417890 proc near                    ; DATA XREF: sub_419560+7Fo

    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    arg_0= dword ptr  4

    sub     esp, 54h
    mov     edx, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+58h+arg_0]
    push    ebp
    lea     eax, [edx+2CAAh]
    push    esi
    xor     ebp, ebp
    push    edi
    mov     ecx, [eax]
    mov     [esp+64h+var_54], ecx
    mov     ecx, [eax+4]
    mov     [esp+64h+var_50], ecx
    mov     ecx, 1
    mov     eax, [eax+8]
    mov     edi, ecx
    mov     [esp+64h+var_4C], eax
    mov     eax, [edx+1438Fh]
    cmp     eax, ecx
    jle     loc_4179AF

    loc_4178D2:                             ; CODE XREF: sub_417890+119j
    mov     esi, [edx+1439Bh]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    push    offset Data
    push    0
    lea     ecx, [eax+eax*8]
    add     esi, ecx
    mov     ecx, ebx
    call    sub_4B73C0
    lea     edx, [esi+20h]
    push    eax
    push    edx
    call    sub_4BC370
    test    eax, eax
    jz      loc_417992
    test    ebp, ebp
    jz      short loc_417918
    mov     eax, [esi+15Eh]
    mov     ecx, [esp+64h+var_54]
    sub     ecx, eax
    mov     [esp+64h+var_54], ecx

    loc_417918:                             ; CODE XREF: sub_417890+76j
    lea     ecx, [esp+64h+var_54]
    push    ecx
    push    esi
    call    sub_47DDC0
    push    0                               ; int
    push    1                               ; int
    mov     eax, [esp+6Ch+var_54]
    push    1                               ; int
    mov     ecx, [esp+70h+var_50]
    sub     esp, 0Ch                        ; int
    mov     edx, esp
    push    edi                             ; int
    push    0                               ; int
    mov     [edx], eax
    mov     eax, [esp+84h+var_4C]
    push    1                               ; int
    mov     [edx+4], ecx
    mov     ecx, ebx
    mov     [edx+8], eax
    call    sub_4B73E0
    push    eax                             ; int
    call    sub_485F50
    mov     ecx, [esi+16Ah]
    mov     edx, [esp+64h+var_54]
    lea     eax, [edx+ecx+200000h]
    mov     edx, TAdynmemStructPtr
    mov     [esp+64h+var_54], eax
    mov     ecx, [edx+1422Bh]
    shl     ecx, 10h
    cmp     eax, ecx
    jl      short loc_41798F
    mov     ecx, [esp+64h+var_4C]
    mov     eax, 0A00000h
    add     ecx, eax
    mov     [esp+64h+var_54], eax
    mov     [esp+64h+var_4C], ecx

    loc_41798F:                             ; CODE XREF: sub_417890+EAj
    inc     ebp
    jmp     short loc_417998
    ; ---------------------------------------------------------------------------

    loc_417992:                             ; CODE XREF: sub_417890+6Ej
    mov     edx, TAdynmemStructPtr

    loc_417998:                             ; CODE XREF: sub_417890+100j
    mov     eax, [edx+1438Fh]
    inc     edi
    mov     ecx, edi
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      loc_4178D2

    loc_4179AF:                             ; CODE XREF: sub_417890+3Cj
    test    ebp, ebp
    jnz     loc_417A52
    push    offset Data
    push    ebp
    mov     ecx, ebx
    call    sub_4B73C0
    push    eax
    lea     edx, [esp+68h+var_3C]
    push    offset aDebugdatS_txt           ; "debugdat\\%s.txt"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+64h+var_3C]
    push    eax
    call    sub_4BB5B0
    mov     esi, eax
    test    esi, esi
    jz      short loc_417A52
    mov     ecx, TAdynmemStructPtr
    add     ecx, 2CAAh
    mov     ebp, [ecx]
    mov     edx, [ecx+4]
    mov     [esp+64h+var_44], edx
    lea     edx, [esp+64h+var_3C]
    mov     eax, [ecx+8]
    lea     ecx, [esp+64h+arg_0]
    push    ecx
    push    esi
    push    edx
    mov     [esp+70h+var_40], eax
    call    sub_4BBFF0
    mov     edi, eax
    test    edi, edi
    jz      short loc_417A30
    mov     eax, [esp+64h+arg_0]
    push    0FFFFFFFFh
    push    ebx
    push    eax
    push    edi
    call    sub_4B7A30
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_417A30:                             ; CODE XREF: sub_417890+187j
    push    esi
    call    sub_4BB5D0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+64h+var_44]
    mov     eax, [esp+64h+var_40]
    add     ecx, 2CAAh
    mov     [ecx], ebp
    mov     [ecx+4], edx
    mov     [ecx+8], eax

    loc_417A52:                             ; CODE XREF: sub_417890+121j
                                            ; sub_417890+155j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    4
    sub_417890 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    esi
    test    byte ptr [eax+37F2Fh], 2
    jz      loc_417B44
    test    byte ptr [eax+3923Bh], 2
    jz      loc_417B44
    mov     esi, [esp+8]
    mov     eax, [esi+0D0h]
    test    eax, eax
    jle     short loc_417B0B
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    cmp     eax, 1
    jnz     short loc_417AAD

    loc_417A9E:                             ; CODE XREF: .text:00417AABj
    push    2000000h
    call    sub_4B4F10
    add     esp, 4
    jmp     short loc_417A9E
    ; ---------------------------------------------------------------------------

    loc_417AAD:                             ; CODE XREF: .text:00417A9Cj
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    cmp     eax, 2
    jnz     short loc_417AD1

    loc_417ABD:                             ; CODE XREF: .text:00417ACFj
    push    2000000h
    push    offset aForceOutOfMemo          ; "FORCE OUT-OF-MEMORY"
    call    sub_4D83B0
    add     esp, 8
    jmp     short loc_417ABD
    ; ---------------------------------------------------------------------------

    loc_417AD1:                             ; CODE XREF: .text:00417ABBj
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    cmp     eax, 3
    jnz     short loc_417B03
    mov     dword ptr [esp+8], 1
    mov     ecx, [esp+8]
    mov     eax, [esp+8]
    cdq
    sar     ecx, 1
    idiv    ecx
    push    eax
    call    _exit
    ; ---------------------------------------------------------------------------
    add     esp, 4
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_417B03:                             ; CODE XREF: .text:00417ADFj
    mov     eax, [esi+0D0h]
    test    eax, eax

    loc_417B0B:                             ; CODE XREF: .text:00417A8Cj
    jz      short loc_417B1C
    push    0
    push    1
    mov     ecx, esi
    call    sub_4B73E0
    test    eax, eax
    jnz     short loc_417B44

    loc_417B1C:                             ; CODE XREF: .text:00417B0Bj
    call    sub_4B6220
    mov     dl, [eax+0F0h]
    shr     dl, 1
    test    dl, 1
    jz      short loc_417B3E
    call    sub_4B5910
    push    1F4h
    call    ds:Sleep

    loc_417B3E:                             ; CODE XREF: .text:00417B2Cj
    call    ds:DebugBreak

    loc_417B44:                             ; CODE XREF: .text:00417A6Dj
                                            ; .text:00417A7Aj ...
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall InterpretCommand(char *Command,int access)
    InterpretCommand proc near              ; CODE XREF: sub_493BF0+246p
                                            ; .text:00496393p

    var_D4= dword ptr -0D4h
    Command= dword ptr  4
    access= dword ptr  8

    sub     esp, 0D4h
    push    esi
    mov     esi, [esp+0D8h+Command]
    test    esi, esi
    jnz     short loc_417B69
    mov     esi, offset byte_511BD0
    jmp     short loc_417B79
    ; ---------------------------------------------------------------------------

    loc_417B69:                             ; CODE XREF: InterpretCommand+10j
    push    4Fh                             ; size_t
    push    esi                             ; char *
    push    offset byte_511BD0              ; char *
    call    _strncpy
    add     esp, 0Ch

    loc_417B79:                             ; CODE XREF: InterpretCommand+17j
    lea     ecx, [esp+0D8h+var_D4]
    call    sub_4B73B0
    push    0
    push    esi
    lea     ecx, [esp+0E0h+var_D4]
    call    ResetTextCommandStruct
    lea     ecx, [esp+0D8h+var_D4]
    mov     eax, [esp+0D8h+access]
    push    eax                             ; int
    push    ecx                             ; int
    call    DoInterpretCommand
    pop     esi
    add     esp, 0D4h
    retn    8
    InterpretCommand endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417BB0 proc near

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    push    esi
    call    sub_485070
    mov     edx, TAdynmemStructPtr
    movsx   ecx, word ptr [esi+2]
    mov     edi, [edx+1431Fh]
    mov     edx, [esp+4+arg_4]
    sub     ecx, edi
    pop     edi
    add     ecx, 80h
    mov     [edx], ecx
    mov     edx, TAdynmemStructPtr
    movsx   ecx, word ptr [esi+0Ah]
    mov     esi, [edx+14323h]
    sub     ecx, esi
    pop     esi
    sar     eax, 1
    sub     ecx, eax
    mov     eax, [esp-4+arg_8]
    add     ecx, 20h
    mov     [eax], ecx
    retn    0Ch
    sub_417BB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417C00 proc near

    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 0Ch
    mov     eax, [esp+0Ch+arg_0]
    mov     ecx, [esp+0Ch+arg_4]
    lea     edx, [esp+0Ch+var_C]
    push    esi
    shl     eax, 10h
    shl     ecx, 10h
    push    edx
    mov     [esp+14h+var_C], eax
    mov     [esp+14h+var_4], ecx
    call    sub_485070
    mov     edx, TAdynmemStructPtr
    movsx   ecx, word ptr [esp+10h+var_C+2]
    mov     esi, [edx+1431Fh]
    mov     edx, [esp+10h+arg_8]
    sub     ecx, esi
    add     ecx, 80h
    mov     [edx], ecx
    mov     edx, TAdynmemStructPtr
    movsx   ecx, word ptr [esp+10h+var_4+2]
    mov     esi, [edx+14323h]
    sub     ecx, esi
    pop     esi
    sar     eax, 1
    sub     ecx, eax
    mov     eax, [esp+0Ch+arg_C]
    add     ecx, 20h
    mov     [eax], ecx
    add     esp, 0Ch
    retn    10h
    sub_417C00 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 0Ch
    movsx   eax, word ptr [esp+18h]
    push    ebx
    push    esi
    mov     esi, [esp+1Ch]
    push    edi
    shl     eax, 10h
    mov     ecx, [esi]
    mov     ebx, [esi+8]
    add     eax, ecx
    push    esi
    movsx   ecx, word ptr [esp+2Ch]
    shl     ecx, 10h
    add     ecx, ebx
    mov     [esp+10h], eax
    mov     [esp+18h], ecx
    call    sub_485070
    mov     ecx, TAdynmemStructPtr
    movsx   edi, word ptr [esi+2]
    mov     edx, [ecx+1431Fh]
    movsx   esi, word ptr [esi+0Ah]
    sub     edi, edx
    mov     edx, [ecx+14323h]
    sub     esi, edx
    lea     edx, [esp+0Ch]
    sar     eax, 1
    sub     esi, eax
    push    edx
    add     edi, 80h
    add     esi, 20h
    call    sub_485070
    sar     eax, 1
    mov     ecx, [esp+2Ch]
    movsx   edx, word ptr [esp+16h]
    and     ecx, 0FFh
    push    ecx
    mov     ecx, TAdynmemStructPtr
    sub     edx, [ecx+14323h]
    sub     edx, eax
    movsx   eax, word ptr [esp+12h]
    add     edx, 20h
    push    edx
    mov     edx, [ecx+1431Fh]
    mov     ecx, [esp+24h]
    sub     eax, edx
    add     eax, 80h
    push    eax
    push    esi
    push    edi
    push    ecx
    call    sub_4BE950
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0Ch
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 18h
    movsx   eax, word ptr [esp+20h]
    movsx   edx, word ptr [esp+24h]
    movsx   ecx, word ptr [esp+22h]
    shl     eax, 10h
    shl     edx, 10h
    mov     [esp+0], eax
    add     edx, eax
    movsx   eax, word ptr [esp+28h]
    shl     ecx, 10h
    shl     eax, 10h
    push    ebx
    mov     [esp+0Ch], ecx
    add     eax, ecx
    push    esi
    lea     ecx, [esp+8]
    push    edi
    push    ecx
    mov     [esp+1Ch], edx
    mov     [esp+24h], eax
    call    sub_485070
    mov     ecx, TAdynmemStructPtr
    movsx   esi, word ptr [esp+16h]
    movsx   edi, word ptr [esp+0Eh]
    mov     edx, [ecx+14323h]
    mov     ebx, [ecx+1431Fh]
    sub     esi, edx
    lea     edx, [esp+18h]
    sar     eax, 1
    sub     edi, ebx
    sub     esi, eax
    push    edx
    add     edi, 80h
    add     esi, 20h
    call    sub_485070
    sar     eax, 1
    mov     ecx, [esp+38h]
    movsx   edx, word ptr [esp+22h]
    and     ecx, 0FFh
    push    ecx
    mov     ecx, TAdynmemStructPtr
    sub     edx, [ecx+14323h]
    sub     edx, eax
    movsx   eax, word ptr [esp+1Eh]
    add     edx, 20h
    push    edx
    mov     edx, [ecx+1431Fh]
    mov     ecx, [esp+30h]
    sub     eax, edx
    add     eax, 80h
    push    eax
    push    esi
    push    edi
    push    ecx
    call    sub_4BE950
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417E00 proc near                    ; DATA XREF: .rdata:004FD480o

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 20h
    push    ebx
    mov     ebx, ecx
    mov     edx, [esp+24h+arg_0]
    push    ebp
    mov     eax, [ebx+8]
    push    0Fh
    mov     [esp+2Ch+var_1C], ebx
    mov     ecx, [eax+7Eh]
    add     eax, 76h
    push    ecx
    push    eax
    push    edx
    call    sub_46B9D0
    mov     al, [ebx+64h]
    mov     ecx, TAdynmemStructPtr
    and     al, 1
    neg     al
    sbb     eax, eax
    xor     ebp, ebp
    and     al, 0FDh
    add     eax, 0Ch
    mov     dl, [eax+ecx+0DCBh]
    mov     eax, [ebx+5Ch]
    dec     eax
    mov     byte ptr [esp+28h+var_20], dl
    test    eax, eax
    jle     loc_417F20
    mov     eax, [esp+28h+var_20]
    push    edi
    and     eax, 0FFh
    push    esi
    mov     [esp+30h+var_20], eax
    add     ebx, 0Eh

    loc_417E61:                             ; CODE XREF: sub_417E00+118j
    movsx   ecx, word ptr [ebx-2]
    movsx   edx, word ptr [ebx]
    lea     eax, [esp+30h+var_18]
    shl     ecx, 10h
    shl     edx, 10h
    push    eax
    mov     [esp+34h+var_18], ecx
    mov     [esp+34h+var_10], edx
    call    sub_485070
    mov     ecx, TAdynmemStructPtr
    movsx   edi, word ptr [esp+30h+var_18+2]
    mov     edx, [ecx+1431Fh]
    movsx   esi, word ptr [esp+30h+var_10+2]
    sub     edi, edx
    mov     edx, [ecx+14323h]
    movsx   ecx, word ptr [ebx+2]
    sub     esi, edx
    add     edi, 80h
    movsx   edx, word ptr [ebx+4]
    sar     eax, 1
    sub     esi, eax
    lea     eax, [esp+30h+var_C]
    shl     ecx, 10h
    shl     edx, 10h
    push    eax
    add     esi, 20h
    mov     [esp+34h+var_C], ecx
    mov     [esp+34h+var_4], edx
    call    sub_485070
    mov     ecx, [esp+30h+var_20]
    movsx   edx, word ptr [esp+30h+var_4+2]
    push    ecx
    mov     ecx, TAdynmemStructPtr
    sar     eax, 1
    sub     edx, [ecx+14323h]
    sub     edx, eax
    movsx   eax, word ptr [esp+34h+var_C+2]
    add     edx, 20h
    push    edx
    mov     edx, [ecx+1431Fh]
    mov     ecx, [esp+38h+arg_0]
    sub     eax, edx
    add     eax, 80h
    push    eax
    push    esi
    push    edi
    push    ecx
    call    sub_4BE950
    mov     edx, [esp+30h+var_1C]
    inc     ebp
    add     ebx, 4
    mov     eax, [edx+5Ch]
    dec     eax
    cmp     ebp, eax
    jl      loc_417E61
    pop     esi
    pop     edi

    loc_417F20:                             ; CODE XREF: sub_417E00+49j
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    4
    sub_417E00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417F30 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+1090p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    test    eax, eax
    jz      short locret_417F50
    mov     eax, [eax]
    test    eax, eax
    jz      short locret_417F50
    mov     eax, [eax]
    test    eax, eax
    jz      short locret_417F50
    mov     ecx, [esp+arg_0]
    mov     edx, [eax]
    push    ecx
    mov     ecx, eax
    call    dword ptr [edx+28h]

    locret_417F50:                          ; CODE XREF: sub_417F30+6j
                                            ; sub_417F30+Cj ...
    retn    8
    sub_417F30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_417F60 proc near                    ; CODE XREF: sub_4181D0+95p
                                            ; sub_4181D0+C8p ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h
    arg_20= dword ptr  24h
    arg_24= dword ptr  28h

    mov     ecx, [esp+arg_24]
    sub     esp, 0Ch
    push    ebx
    mov     ebx, [esp+10h+arg_18]
    push    ebp
    push    esi
    cmp     ebx, ecx
    push    edi
    jle     short loc_417FA3
    mov     edx, [esp+1Ch+arg_10]
    mov     esi, [esp+1Ch+arg_14]
    mov     edi, [esp+1Ch+arg_20]
    mov     eax, ebx
    mov     ebx, ecx
    mov     ecx, eax
    mov     eax, [esp+1Ch+arg_1C]
    mov     [esp+1Ch+arg_18], ebx
    mov     [esp+1Ch+arg_24], ecx
    mov     [esp+1Ch+arg_10], eax
    mov     [esp+1Ch+arg_14], edi
    mov     [esp+1Ch+arg_1C], edx
    mov     [esp+1Ch+arg_20], esi
    jmp     short loc_417FA7
    ; ---------------------------------------------------------------------------

    loc_417FA3:                             ; CODE XREF: sub_417F60+11j
    mov     eax, [esp+1Ch+arg_10]

    loc_417FA7:                             ; CODE XREF: sub_417F60+41j
    mov     edi, [esp+1Ch+arg_C]
    cmp     edi, ebx
    jle     short loc_417FDB
    mov     esi, [esp+1Ch+arg_8]
    mov     edx, edi
    mov     edi, ebx
    mov     ebx, edx
    mov     edx, [esp+1Ch+arg_4]
    mov     [esp+1Ch+arg_4], eax
    mov     eax, [esp+1Ch+arg_14]
    mov     [esp+1Ch+arg_C], edi
    mov     [esp+1Ch+arg_8], eax
    mov     eax, edx
    mov     [esp+1Ch+arg_18], ebx
    mov     [esp+1Ch+arg_10], eax
    mov     [esp+1Ch+arg_14], esi

    loc_417FDB:                             ; CODE XREF: sub_417F60+4Dj
    cmp     ebx, ecx
    jle     short loc_418009
    mov     esi, [esp+1Ch+arg_1C]
    mov     edx, ebx
    mov     ebx, ecx
    mov     ecx, edx
    mov     edx, [esp+1Ch+arg_14]
    mov     [esp+1Ch+arg_10], esi
    mov     esi, [esp+1Ch+arg_20]
    mov     [esp+1Ch+arg_18], ebx
    mov     [esp+1Ch+arg_24], ecx
    mov     [esp+1Ch+arg_14], esi
    mov     [esp+1Ch+arg_1C], eax
    mov     [esp+1Ch+arg_20], edx

    loc_418009:                             ; CODE XREF: sub_417F60+7Dj
    mov     ebp, dword_511DD0
    mov     eax, ecx
    cdq
    idiv    ebp
    mov     edx, dword_511DD4
    mov     esi, eax
    imul    esi, ebp
    add     esi, edx
    cmp     esi, ecx
    jle     short loc_41802B

    loc_418025:                             ; CODE XREF: sub_417F60+C9j
    sub     esi, ebp
    cmp     esi, ecx
    jg      short loc_418025

    loc_41802B:                             ; CODE XREF: sub_417F60+C3j
    cmp     esi, ebx
    jle     loc_418102
    mov     ebp, ecx
    mov     eax, ecx
    sub     ebp, edi
    sub     eax, ebx
    mov     [esp+1Ch+var_4], ebp
    mov     [esp+1Ch+var_C], eax
    jmp     short loc_41804D
    ; ---------------------------------------------------------------------------

    loc_418045:                             ; CODE XREF: sub_417F60+194j
    mov     edi, [esp+1Ch+arg_C]
    mov     eax, [esp+1Ch+var_C]

    loc_41804D:                             ; CODE XREF: sub_417F60+E3j
    mov     ecx, esi
    xor     edx, edx
    sub     ecx, edi
    mov     edi, esi
    sub     edi, ebx
    mov     ebx, eax
    mov     eax, TAdynmemStructPtr
    sub     ebx, edi
    sub     ebp, ecx
    mov     dl, [eax+1427Fh]
    mov     eax, esi
    sar     eax, 8
    sub     eax, edx
    xor     edx, edx
    add     eax, 100h
    mov     [esp+1Ch+var_8], ebp
    sar     eax, 4
    mov     ebp, [esp+1Ch+var_C]
    mov     dl, byte_501D18[eax]
    mov     eax, [esp+1Ch+arg_14]
    push    edx
    mov     edx, edi
    imul    edx, [esp+20h+arg_20]
    imul    eax, ebx
    add     eax, edx
    cdq
    idiv    ebp
    push    eax
    mov     eax, [esp+24h+arg_10]
    imul    eax, ebx
    mov     ebx, [esp+24h+arg_1C]
    imul    edi, ebx
    add     eax, edi
    mov     edi, [esp+24h+var_8]
    cdq
    idiv    ebp
    mov     edx, ecx
    mov     ebp, [esp+24h+var_4]
    imul    edx, [esp+24h+arg_20]
    imul    ecx, ebx
    push    eax
    mov     eax, [esp+28h+arg_8]
    imul    eax, edi
    add     eax, edx
    cdq
    idiv    ebp
    push    eax
    mov     eax, [esp+2Ch+arg_4]
    imul    eax, edi
    add     eax, ecx
    cdq
    idiv    ebp
    push    eax
    mov     eax, [esp+30h+arg_0]
    push    eax
    call    sub_4BE950
    mov     ecx, dword_511DD0
    mov     ebx, [esp+1Ch+arg_18]
    sub     esi, ecx
    cmp     esi, ebx
    jg      loc_418045
    mov     ecx, [esp+1Ch+arg_24]
    mov     edi, [esp+1Ch+arg_C]

    loc_418102:                             ; CODE XREF: sub_417F60+CDj
    cmp     esi, edi
    jle     loc_4181BF
    sub     ecx, edi
    sub     ebx, edi
    mov     ebp, ecx
    mov     [esp+1Ch+arg_18], ebx
    mov     [esp+1Ch+arg_24], ebp

    loc_418118:                             ; CODE XREF: sub_417F60+259j
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     ecx, esi
    mov     ebx, ebp
    mov     dl, [eax+1427Fh]
    mov     eax, esi
    sar     eax, 8
    sub     eax, edx
    xor     edx, edx
    add     eax, 100h
    sub     ecx, edi
    mov     edi, [esp+1Ch+arg_18]
    mov     ebp, [esp+1Ch+arg_18]
    sar     eax, 4
    sub     edi, ecx
    sub     ebx, ecx
    mov     dl, byte_501D18[eax]
    mov     eax, [esp+1Ch+arg_8]
    push    edx
    mov     edx, ecx
    imul    edx, [esp+20h+arg_14]
    imul    eax, edi
    add     eax, edx
    cdq
    idiv    ebp
    mov     edx, ecx
    imul    edx, [esp+20h+arg_10]
    push    eax
    mov     eax, [esp+24h+arg_4]
    imul    eax, edi
    add     eax, edx
    cdq
    idiv    ebp
    mov     edx, ecx
    mov     ebp, [esp+24h+arg_24]
    imul    edx, [esp+24h+arg_20]
    imul    ecx, [esp+24h+arg_1C]
    push    eax
    mov     eax, [esp+28h+arg_8]
    imul    eax, ebx
    add     eax, edx
    cdq
    idiv    ebp
    push    eax
    mov     eax, [esp+2Ch+arg_4]
    imul    eax, ebx
    add     eax, ecx
    cdq
    idiv    ebp
    push    eax
    mov     eax, [esp+30h+arg_0]
    push    eax
    call    sub_4BE950
    mov     ecx, dword_511DD0
    mov     edi, [esp+1Ch+arg_C]
    sub     esi, ecx
    cmp     esi, edi
    jg      loc_418118

    loc_4181BF:                             ; CODE XREF: sub_417F60+1A4j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    28h
    sub_417F60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4181D0 proc near                    ; CODE XREF: sub_418310+842p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+14h+arg_4]
    push    edi
    mov     eax, [esi]
    mov     ebp, [esi+10h]
    mov     ebx, [esi+18h]
    mov     ecx, [esi+8]
    add     eax, ebp
    mov     edi, [esi+1Ch]
    add     eax, ebx
    mov     ebx, [esi+4]
    lea     eax, [eax+ecx+2]
    xor     ecx, ecx
    cdq
    and     edx, 3
    add     eax, edx
    mov     edx, [esi+0Ch]
    add     edx, ebx
    mov     ebp, eax
    mov     eax, [esi+14h]
    add     edx, edi
    mov     edi, [esp+18h+arg_8]
    xor     ebx, ebx
    lea     eax, [edx+eax+2]
    cdq
    and     edx, 3
    mov     bl, [edi+3]
    add     eax, edx
    mov     cl, [edi+1]
    sar     eax, 2
    mov     [esp+18h+var_4], eax
    xor     eax, eax
    mov     al, [edi]
    xor     edx, edx
    mov     dl, [edi+2]
    mov     [esp+18h+arg_4], eax
    add     eax, edx
    mov     edx, [esi+8]
    add     ebx, eax
    mov     eax, [esp+18h+var_4]
    add     ebx, ecx
    shl     ebx, 6
    sar     ebp, 2
    push    ebx
    push    eax
    mov     eax, [esp+20h+arg_4]
    push    ebp
    shl     ecx, 8
    push    ecx
    mov     ecx, [esi+0Ch]
    push    ecx
    mov     ecx, [esi]
    shl     eax, 8
    push    edx
    mov     edx, [esp+30h+arg_0]
    push    eax
    mov     eax, [esi+4]
    push    eax
    push    ecx
    push    edx
    call    sub_417F60
    xor     ecx, ecx
    mov     edx, [esi+14h]
    mov     eax, [esp+18h+var_4]
    mov     cl, [edi+2]
    push    ebx
    push    eax
    mov     eax, [esi+10h]
    push    ebp
    shl     ecx, 8
    push    ecx
    xor     ecx, ecx
    mov     cl, [edi+1]
    push    edx
    mov     edx, [esi+0Ch]
    push    eax
    shl     ecx, 8
    push    ecx
    push    edx
    mov     eax, [esi+8]
    mov     ecx, [esp+38h+arg_0]
    push    eax
    push    ecx
    call    sub_417F60
    xor     eax, eax
    mov     ecx, [esi+1Ch]
    mov     edx, [esp+18h+var_4]
    mov     al, [edi+3]
    push    ebx
    push    edx
    mov     edx, [esi+18h]
    push    ebp
    shl     eax, 8
    push    eax
    xor     eax, eax
    mov     al, [edi+2]
    push    ecx
    mov     ecx, [esi+14h]
    push    edx
    mov     edx, [esi+10h]
    shl     eax, 8
    push    eax
    mov     eax, [esp+34h+arg_0]
    push    ecx
    push    edx
    push    eax
    call    sub_417F60
    xor     edx, edx
    mov     eax, [esi+4]
    mov     ecx, [esp+18h+var_4]
    mov     dl, [edi]
    push    ebx
    push    ecx
    mov     ecx, [esi]
    push    ebp
    shl     edx, 8
    push    edx
    xor     edx, edx
    mov     dl, [edi+3]
    push    eax
    mov     eax, [esi+1Ch]
    push    ecx
    mov     ecx, [esi+18h]
    shl     edx, 8
    push    edx
    mov     edx, [esp+34h+arg_0]
    push    eax
    push    ecx
    push    edx
    call    sub_417F60
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_4181D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_418310 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+CAp

    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    Player= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= byte ptr -14h
    arg_0= dword ptr  4

    sub     esp, 84h
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    push    edi
    mov     dl, [esi+14280h]
    test    dl, dl
    jnz     short loc_418337
    mov     eax, dword_511DD0
    test    eax, eax
    jz      loc_418B9E

    loc_418337:                             ; CODE XREF: sub_418310+18j
    xor     ecx, ecx
    mov     edi, esi
    mov     cl, [esi+TAdynmemStruct.LOS_Sight]
    mov     [esp+94h+var_38], 0
    mov     eax, ecx
    add     edi, ecx
    shl     eax, 5
    add     eax, ecx
    cmp     dl, 1
    lea     eax, [eax+eax*4]
    lea     ecx, [edi+eax*2+TAdynmemStruct.Players]
    mov     [esp+94h+Player], ecx
    jnz     short loc_418388
    push    0                               ; int
    push    0                               ; int
    call    sub_48C190
    test    eax, eax
    jz      short loc_418382
    mov     edx, [eax+92h]
    mov     eax, [edx+1B6h]
    mov     [esp+94h+var_38], eax

    loc_418382:                             ; CODE XREF: sub_418310+60j
    mov     esi, TAdynmemStructPtr

    loc_418388:                             ; CODE XREF: sub_418310+53j
    mov     eax, [esi+TAdynmemStruct.MapY]
    mov     ecx, dword ptr [esi+TAdynmemStruct.data7]
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     edi, eax
    mov     eax, [esi+TAdynmemStruct.MapX]
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     edx, [esi+TAdynmemStruct.FeatureMapSizeX]
    sar     eax, 4
    sar     edi, 4
    lea     ecx, [ecx+eax+1]
    dec     edx
    cmp     ecx, edx
    mov     [esp+94h+var_2C], eax
    jl      short loc_4183C3
    mov     ecx, edx

    loc_4183C3:                             ; CODE XREF: sub_418310+AFj
    mov     ebx, [esi+14237h]
    mov     edx, edi
    dec     ebx
    mov     [esp+94h+var_44], ecx
    cmp     edi, ebx
    mov     [esp+94h+var_34], ebx
    lea     ebp, [esi+0DCBh]
    mov     [esp+94h+var_84], edx
    jge     loc_418B9E
    mov     edi, [esp+94h+arg_0]

    loc_4183ED:                             ; CODE XREF: sub_418310+888j
    cmp     eax, ecx
    mov     [esp+94h+var_40], 1
    mov     [esp+94h+var_60], eax
    jge     loc_418B85
    lea     ebx, [edx+2]
    lea     ecx, [eax+8]
    shl     ebx, 4
    shl     ecx, 4
    mov     [esp+94h+var_58], ebx
    mov     [esp+94h+var_5C], ecx
    jmp     short loc_418423
    ; ---------------------------------------------------------------------------

    loc_418417:                             ; CODE XREF: sub_418310+867j
    mov     ebx, [esp+94h+var_58]
    mov     edx, [esp+94h+var_84]
    mov     ecx, [esp+94h+var_5C]

    loc_418423:                             ; CODE XREF: sub_418310+105j
    mov     eax, edx
    mov     edx, [esp+94h+var_60]
    imul    eax, [esi+TAdynmemStruct.FeatureMapSizeX]
    add     eax, edx
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    mov     edx, [esi+TAdynmemStruct.Features]
    add     eax, edx
    mov     dl, [eax+4]
    add     eax, 0Dh
    mov     byte ptr [esp+94h+var_4C], dl
    mov     edx, [esi+TAdynmemStruct.MapX]
    sub     ecx, edx
    mov     edx, ebx
    mov     [esp+94h+var_80], ecx
    mov     ecx, [esp+94h+var_4C]
    and     ecx, 0FFh
    shr     ecx, 1
    sub     edx, ecx
    mov     ecx, [esi+TAdynmemStruct.MapY]
    sub     edx, ecx
    mov     ecx, [esp+94h+var_60]
    inc     ecx
    mov     [esp+94h+var_7C], edx
    mov     [esp+94h+var_60], ecx
    mov     ecx, [esp+94h+var_5C]
    add     ecx, 10h
    mov     [esp+94h+var_5C], ecx
    mov     cl, [eax+4]
    mov     byte ptr [esp+94h+var_4C+1], cl
    mov     ecx, [esp+94h+var_5C]
    sub     ecx, [esi+TAdynmemStruct.MapX]
    mov     [esp+94h+var_78], ecx
    mov     ecx, [esp+94h+var_4C+1]
    and     ecx, 0FFh
    shr     ecx, 1
    mov     [esp+94h+var_50], ecx
    mov     ecx, ebx
    mov     ebx, [esp+94h+var_50]
    sub     ecx, ebx
    mov     ebx, [esi+TAdynmemStruct.MapY]
    sub     ecx, ebx
    mov     [esp+94h+var_74], ecx
    mov     ebx, [esi+TAdynmemStruct.FeatureMapSizeX]
    lea     ebx, [ebx+ebx*2]
    lea     ebx, [eax+ebx*4]
    mov     eax, [esi+TAdynmemStruct.FeatureMapSizeX]
    add     eax, ebx
    mov     ebx, [esp+94h+var_84]
    inc     ebx
    mov     [esp+94h+var_54], eax
    mov     al, [eax+4]
    mov     [esp+94h+var_84], ebx
    mov     ebx, [esp+94h+var_58]
    mov     byte ptr [esp+94h+var_4C+2], al
    mov     eax, [esp+94h+var_5C]
    add     ebx, 10h
    mov     [esp+94h+var_58], ebx
    mov     ebx, [esi+TAdynmemStruct.MapX]
    sub     eax, ebx
    mov     ebx, [esp+94h+var_4C+2]
    and     ebx, 0FFh
    mov     [esp+94h+var_70], eax
    mov     eax, [esp+94h+var_58]
    shr     ebx, 1
    sub     eax, ebx
    mov     ebx, [esi+TAdynmemStruct.MapY]
    sub     eax, ebx
    mov     ebx, [esp+94h+var_54]
    mov     [esp+94h+var_6C], eax
    mov     eax, [esp+94h+var_60]
    sub     ebx, 0Dh
    dec     eax
    mov     [esp+94h+var_60], eax
    mov     eax, [esp+94h+var_5C]
    mov     [esp+94h+var_54], ebx
    mov     bl, [ebx+4]
    sub     eax, 10h
    mov     byte ptr [esp+94h+var_4C+3], bl
    mov     ebx, [esi+TAdynmemStruct.MapX]
    mov     [esp+94h+var_5C], eax
    sub     eax, ebx
    mov     ebx, [esp+94h+var_58]
    mov     [esp+94h+var_68], eax
    mov     eax, [esp+94h+var_4C+3]
    and     eax, 0FFh
    shr     eax, 1
    sub     ebx, eax
    mov     eax, [esi+TAdynmemStruct.MapY]
    sub     ebx, eax
    mov     [esp+94h+var_64], ebx
    mov     eax, [esi+TAdynmemStruct.FeatureMapSizeX]
    mov     ebx, eax
    shl     ebx, 3
    sub     ebx, eax
    shl     ebx, 1
    sub     ebx, eax
    neg     ebx
    mov     [esp+94h+var_50], ebx
    mov     ebx, [esp+94h+var_54]
    mov     eax, [esp+94h+var_50]
    add     ebx, eax
    mov     eax, [esp+94h+var_84]
    dec     eax
    mov     [esp+94h+var_84], eax
    mov     eax, [esp+94h+var_58]
    sub     eax, 10h
    mov     [esp+94h+var_58], eax
    mov     eax, [esi+37E23h]
    cmp     edx, eax
    jge     short loc_4185B6
    mov     [esp+94h+var_40], 0

    loc_4185B6:                             ; CODE XREF: sub_418310+29Cj
    mov     al, [esi+14280h]
    cmp     al, 1
    jnz     loc_4187A9
    mov     eax, [esp+94h+var_38]
    test    eax, eax
    jz      loc_418651
    mov     ecx, [esp+94h+var_84]
    mov     ebx, [eax+10h]
    sar     ecx, 4
    imul    ebx, ecx
    mov     ecx, [esp+94h+var_60]
    mov     eax, [eax+18h]
    add     ebx, ecx
    mov     ecx, [esp+94h+var_84]
    and     ecx, 0Fh
    mov     eax, [eax+ebx*4]
    shl     ecx, 1
    shr     eax, cl
    and     eax, 3
    cmp     eax, 3
    jnb     short loc_418651
    xor     ecx, ecx
    mov     cl, ds:byte_4FCC68[eax]
    mov     al, [ecx+ebp]
    mov     ecx, [esp+94h+var_6C]
    mov     byte ptr [esp+94h+var_28], al
    mov     eax, [esp+94h+var_70]
    mov     esi, [esp+94h+var_28]
    and     esi, 0FFh
    push    esi
    push    ecx
    mov     ecx, [esp+9Ch+var_80]
    push    eax
    push    edx
    push    ecx
    push    edi
    call    sub_4BE950
    push    esi
    mov     edx, [esp+98h+var_64]
    mov     eax, [esp+98h+var_68]
    mov     ecx, [esp+98h+var_74]
    push    edx
    mov     edx, [esp+9Ch+var_78]
    push    eax
    push    ecx
    push    edx
    push    edi
    call    sub_4BE950
    mov     esi, TAdynmemStructPtr
    mov     edx, [esp+94h+var_7C]

    loc_418651:                             ; CODE XREF: sub_418310+2BAj
                                            ; sub_418310+2EAj
    mov     eax, [esi+14207h]
    mov     ebx, [esp+94h+var_60]
    add     eax, 1Ch
    mov     ecx, [eax+4]
    mov     eax, [eax]
    imul    ecx, [esp+94h+var_84]
    add     ecx, ebx
    lea     ebx, [eax+ecx*4]
    mov     [esp+94h+var_54], ebx
    test    byte ptr [ebx], 4
    jz      short loc_4186B9
    mov     ecx, [esi+391FDh]
    push    ecx
    call    sub_4C1420
    call    sub_4C13F0
    push    eax
    call    _rand
    and     eax, 0FFh
    push    eax
    call    sub_4C13A0
    push    0FFFFFFFFh
    mov     edx, [esp+98h+var_7C]
    mov     eax, [esp+98h+var_80]
    push    edx
    push    eax
    push    offset aG_0                     ; "G"
    push    edi
    call    PrintGUIText
    mov     esi, TAdynmemStructPtr
    mov     edx, [esp+94h+var_7C]

    loc_4186B9:                             ; CODE XREF: sub_418310+364j
    mov     al, [ebx]
    mov     cl, al
    and     cl, 0FBh
    jz      loc_418B3E
    cmp     cl, 3
    jz      loc_418B3E
    mov     ecx, [esp+94h+var_80]
    and     eax, 0FFh
    dec     eax
    lea     ebx, [edx+8]
    lea     esi, [ecx+8]
    jz      short loc_4186ED
    dec     eax
    jnz     short loc_4186F4
    mov     dl, [ebp+4]
    mov     byte ptr [esp+94h+var_3C], dl
    jmp     short loc_4186F4
    ; ---------------------------------------------------------------------------

    loc_4186ED:                             ; CODE XREF: sub_418310+3CFj
    mov     al, [ebp+0Fh]
    mov     byte ptr [esp+94h+var_3C], al

    loc_4186F4:                             ; CODE XREF: sub_418310+3D2j
                                            ; sub_418310+3DBj
    mov     ecx, [esp+94h+var_54]
    mov     eax, [esp+94h+var_3C]
    and     eax, 0FFh
    movsx   ecx, byte ptr [ecx+1]
    mov     [esp+94h+var_50], eax
    push    eax
    movsx   eax, ds:byte_4FD678[ecx]
    mov     edx, eax
    push    ebx
    shl     edx, 3
    sub     edx, eax
    mov     eax, ebx
    shl     edx, 1
    sub     eax, edx
    push    esi
    push    eax
    mov     edx, esi
    movsx   eax, ds:byte_4FD670[ecx]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    shl     ecx, 1
    sub     edx, ecx
    push    edx
    push    edi
    call    sub_4BE950
    mov     eax, [esp+94h+var_54]
    mov     ecx, [esp+94h+var_50]
    push    ecx
    mov     ecx, ebx
    mov     al, [eax+1]
    push    ebx
    inc     eax
    push    esi
    and     eax, 7
    movsx   edx, ds:byte_4FD678[eax]
    shl     edx, 2
    sub     ecx, edx
    movsx   edx, ds:byte_4FD670[eax]
    shl     edx, 2
    mov     eax, esi
    push    ecx
    sub     eax, edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     ecx, [esp+94h+var_54]
    mov     edx, [esp+94h+var_50]
    push    edx
    push    ebx
    mov     al, [ecx+1]
    push    esi
    dec     eax
    and     eax, 7
    movsx   ecx, ds:byte_4FD678[eax]
    movsx   edx, ds:byte_4FD670[eax]
    shl     ecx, 2
    shl     edx, 2
    sub     ebx, ecx
    sub     esi, edx
    push    ebx
    push    esi
    push    edi
    call    sub_4BE950
    jmp     loc_418B38
    ; ---------------------------------------------------------------------------

    loc_4187A9:                             ; CODE XREF: sub_418310+2AEj
    cmp     al, 2
    jnz     loc_4189D6
    mov     al, [ebx+4]
    cmp     al, [esi+1427Fh]
    jbe     short loc_4187DB
    xor     eax, eax
    mov     al, [ebp+0Fh]
    push    eax
    push    ecx
    mov     ecx, [esp+9Ch+var_78]
    push    ecx
    push    edx
    mov     edx, [esp+0A4h+var_80]
    push    edx
    push    edi
    call    sub_4BE950
    xor     eax, eax
    mov     al, [ebp+0Fh]
    jmp     short loc_4187F8
    ; ---------------------------------------------------------------------------

    loc_4187DB:                             ; CODE XREF: sub_418310+4AAj
    xor     eax, eax
    mov     al, [ebp+0Dh]
    push    eax
    push    ecx
    mov     ecx, [esp+9Ch+var_78]
    push    ecx
    push    edx
    mov     edx, [esp+0A4h+var_80]
    push    edx
    push    edi
    call    sub_4BE950
    xor     eax, eax
    mov     al, [ebp+0Dh]

    loc_4187F8:                             ; CODE XREF: sub_418310+4C9j
    mov     ecx, [esp+94h+var_64]
    mov     edx, [esp+94h+var_68]
    push    eax
    mov     eax, [esp+98h+var_7C]
    push    ecx
    mov     ecx, [esp+9Ch+var_80]
    push    edx
    push    eax
    push    ecx
    push    edi
    call    sub_4BE950
    mov     ax, [ebx]
    test    ax, ax
    jz      short loc_41882A
    and     eax, 0FFh
    lea     edx, [esp+94h+var_80]
    push    eax
    push    4
    push    edx
    jmp     short loc_418844
    ; ---------------------------------------------------------------------------

    loc_41882A:                             ; CODE XREF: sub_418310+509j
    mov     ax, [ebx+8]
    cmp     ax, 0FFFFh
    jz      short loc_41884A
    add     eax, 0FFFFFFC8h
    and     eax, 0FFh
    push    eax
    lea     eax, [esp+98h+var_80]
    push    4
    push    eax

    loc_418844:                             ; CODE XREF: sub_418310+518j
    push    edi
    call    sub_4C0310

    loc_41884A:                             ; CODE XREF: sub_418310+522j
    mov     ax, [ebx+2]
    test    ax, ax
    jz      short loc_418897
    mov     ecx, [esp+94h+var_6C]
    mov     edx, [esp+94h+var_70]
    and     eax, 0FFh
    push    eax
    mov     eax, [esp+98h+var_7C]
    push    ecx
    mov     ecx, [esp+9Ch+var_80]
    push    edx
    push    eax
    push    ecx
    push    edi
    call    sub_4BE950
    mov     dl, [ebx+2]
    mov     eax, [esp+94h+var_64]
    mov     ecx, [esp+94h+var_68]
    and     edx, 0FFh
    push    edx
    mov     edx, [esp+98h+var_74]
    push    eax
    mov     eax, [esp+9Ch+var_78]
    push    ecx
    push    edx
    push    eax
    push    edi
    call    sub_4BE950

    loc_418897:                             ; CODE XREF: sub_418310+541j
    test    byte ptr [ebx+0Ch], 2
    jz      loc_418B38
    mov     edx, [esp+94h+var_6C]
    xor     ecx, ecx
    mov     cl, [ebp+0Fh]
    mov     esi, [esp+94h+var_78]
    push    ecx
    mov     ecx, [esp+98h+var_74]
    lea     eax, [ecx+edx]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    mov     eax, [esp+9Ch+var_70]
    add     eax, esi
    cdq
    sub     eax, edx
    mov     edx, [esp+9Ch+var_7C]
    sar     eax, 1
    sub     eax, 2
    push    eax
    lea     eax, [edx+ecx]
    cdq
    sub     eax, edx
    sar     eax, 1
    add     eax, 2
    push    eax
    mov     eax, [esp+0A4h+var_80]
    add     eax, esi
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    push    edi
    call    sub_4BE950
    xor     ecx, ecx
    mov     esi, [esp+94h+var_70]
    mov     cl, [ebp+0Fh]
    mov     edx, [esp+94h+var_64]
    push    ecx
    mov     ecx, [esp+98h+var_6C]
    lea     eax, [ecx+edx]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     eax, 2
    push    eax
    mov     eax, [esp+9Ch+var_68]
    add     eax, esi
    cdq
    sub     eax, edx
    mov     edx, [esp+9Ch+var_74]
    sar     eax, 1
    push    eax
    lea     eax, [edx+ecx]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    mov     eax, [esp+0A4h+var_78]
    add     eax, esi
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     eax, 2
    push    eax
    push    edi
    call    sub_4BE950
    xor     ecx, ecx
    mov     esi, [esp+94h+var_68]
    mov     cl, [ebp+0Fh]
    mov     edx, [esp+94h+var_7C]
    push    ecx
    mov     ecx, [esp+98h+var_64]
    lea     eax, [ecx+edx]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    mov     eax, [esp+9Ch+var_80]
    add     eax, esi
    cdq
    sub     eax, edx
    mov     edx, [esp+9Ch+var_6C]
    sar     eax, 1
    add     eax, 2
    push    eax
    lea     eax, [edx+ecx]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     eax, 2
    push    eax
    mov     eax, [esp+0A4h+var_70]
    add     eax, esi
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    push    edi
    call    sub_4BE950
    xor     ecx, ecx
    mov     esi, [esp+94h+var_80]
    mov     cl, [ebp+0Fh]
    mov     edx, [esp+94h+var_74]
    push    ecx
    mov     ecx, [esp+98h+var_7C]
    lea     eax, [ecx+edx]
    cdq
    sub     eax, edx
    sar     eax, 1
    add     eax, 2
    push    eax
    mov     eax, [esp+9Ch+var_78]
    add     eax, esi
    cdq
    sub     eax, edx
    mov     edx, [esp+9Ch+var_64]
    sar     eax, 1
    push    eax
    lea     eax, [edx+ecx]
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    mov     eax, [esp+0A4h+var_68]
    add     eax, esi
    cdq
    sub     eax, edx
    sar     eax, 1
    add     eax, 2
    push    eax
    push    edi
    call    sub_4BE950
    jmp     loc_418B38
    ; ---------------------------------------------------------------------------

    loc_4189D6:                             ; CODE XREF: sub_418310+49Bj
    cmp     al, 3
    jnz     loc_418A99
    mov     al, [ebx+4]
    cmp     al, [esi+1427Fh]
    jbe     short loc_418A08
    xor     eax, eax
    mov     al, [ebp+0Fh]
    push    eax
    push    ecx
    mov     ecx, [esp+9Ch+var_78]
    push    ecx
    push    edx
    mov     edx, [esp+0A4h+var_80]
    push    edx
    push    edi
    call    sub_4BE950
    xor     eax, eax
    mov     al, [ebp+0Fh]
    jmp     short loc_418A25
    ; ---------------------------------------------------------------------------

    loc_418A08:                             ; CODE XREF: sub_418310+6D7j
    xor     eax, eax
    mov     al, [ebp+0Dh]
    push    eax
    push    ecx
    mov     ecx, [esp+9Ch+var_78]
    push    ecx
    push    edx
    mov     edx, [esp+0A4h+var_80]
    push    edx
    push    edi
    call    sub_4BE950
    xor     eax, eax
    mov     al, [ebp+0Dh]

    loc_418A25:                             ; CODE XREF: sub_418310+6F6j
    mov     ecx, [esp+94h+var_64]
    mov     edx, [esp+94h+var_68]
    push    eax
    mov     eax, [esp+98h+var_7C]
    push    ecx
    mov     ecx, [esp+9Ch+var_80]
    push    edx
    push    eax
    push    ecx
    push    edi
    call    sub_4BE950
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391FDh]
    push    eax
    call    sub_4C1420
    call    sub_4C13F0
    xor     ecx, ecx
    push    eax
    mov     cl, [ebp+0Fh]
    push    ecx
    call    sub_4C13A0
    push    0FFFFFFFFh
    lea     ecx, [esp+98h+var_14]
    mov     edx, [esp+98h+var_7C]
    mov     eax, [esp+98h+var_80]
    add     edx, 2
    add     eax, 2
    push    edx
    xor     edx, edx
    mov     dl, [ebx+7]
    push    eax
    push    0Ah                             ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    edi
    call    PrintGUIText
    jmp     loc_418B38
    ; ---------------------------------------------------------------------------

    loc_418A99:                             ; CODE XREF: sub_418310+6C8j
    cmp     al, 4
    jnz     loc_418B3E
    xor     eax, eax
    mov     al, [ebp+0]
    push    eax
    push    ecx
    mov     ecx, [esp+9Ch+var_78]
    push    ecx
    push    edx
    mov     edx, [esp+0A4h+var_80]
    push    edx
    push    edi
    call    sub_4BE950
    xor     eax, eax
    mov     al, [ebp+0]
    mov     ecx, [esp+94h+var_64]
    mov     edx, [esp+94h+var_68]
    push    eax
    mov     eax, [esp+98h+var_7C]
    push    ecx
    mov     ecx, [esp+9Ch+var_80]
    push    edx
    push    eax
    push    ecx
    push    edi
    call    sub_4BE950
    mov     eax, [esp+94h+var_84]
    mov     ecx, [esp+94h+Player]
    cdq
    mov     esi, [ecx+80h]
    sub     eax, edx
    sar     eax, 1
    imul    esi, eax
    mov     eax, [esp+94h+var_60]
    cdq
    sub     eax, edx
    mov     edx, [ecx+7Ch]
    sar     eax, 1
    add     esi, eax
    cmp     byte ptr [esi+edx], 0
    jz      short loc_418B38
    mov     eax, [esp+94h+var_80]
    lea     ecx, [eax-5]
    add     eax, 5
    mov     [esp+94h+var_1C], eax
    mov     eax, [esp+94h+var_7C]
    mov     [esp+94h+var_24], ecx
    lea     ecx, [esp+94h+var_24]
    lea     edx, [eax-5]
    add     eax, 5
    mov     [esp+94h+var_18], eax
    xor     eax, eax
    mov     al, [ebp+0Fh]
    mov     [esp+94h+var_20], edx
    push    eax
    push    ecx
    push    edi
    call    sub_4BF6F0

    loc_418B38:                             ; CODE XREF: sub_418310+494j
                                            ; sub_418310+58Bj ...
    mov     esi, TAdynmemStructPtr

    loc_418B3E:                             ; CODE XREF: sub_418310+3B0j
                                            ; sub_418310+3B9j ...
    mov     eax, dword_511DD0
    test    eax, eax
    jz      short loc_418B5D
    lea     edx, [esp+94h+var_4C]
    lea     eax, [esp+94h+var_80]
    push    edx
    push    eax
    push    edi
    call    sub_4181D0
    mov     esi, TAdynmemStructPtr

    loc_418B5D:                             ; CODE XREF: sub_418310+835j
    mov     eax, [esp+94h+var_60]
    mov     ebx, [esp+94h+var_5C]
    mov     ecx, [esp+94h+var_44]
    inc     eax
    add     ebx, 10h
    cmp     eax, ecx
    mov     [esp+94h+var_60], eax
    mov     [esp+94h+var_5C], ebx
    jl      loc_418417
    mov     eax, [esp+94h+var_2C]
    mov     edx, [esp+94h+var_84]

    loc_418B85:                             ; CODE XREF: sub_418310+EBj
    mov     ebx, [esp+94h+var_40]
    test    ebx, ebx
    jnz     short loc_418B9E
    mov     ebx, [esp+94h+var_34]
    inc     edx
    cmp     edx, ebx
    mov     [esp+94h+var_84], edx
    jl      loc_4183ED

    loc_418B9E:                             ; CODE XREF: sub_418310+21j
                                            ; sub_418310+D0j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 84h
    retn    4
    sub_418310 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    push    edi
    mov     edi, [esp+0Ch]
    cmp     dword ptr [edi+0D0h], 3
    jnz     loc_418C5C
    push    0
    push    1
    mov     ecx, edi
    call    sub_4B73E0
    cmp     al, 0Ah
    mov     [esp+0Ch], al
    jnb     loc_418C5C
    mov     eax, [esp+0Ch]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edx+ecx*2+1B63h]
    lea     ecx, [edx+ecx*2+1B63h]
    test    eax, eax
    jz      short loc_418C5C
    mov     al, [ecx+73h]
    cmp     al, 1
    jz      short loc_418C16
    cmp     al, 2
    jz      short loc_418C16
    cmp     al, 3
    jnz     short loc_418C5C

    loc_418C16:                             ; CODE XREF: .text:00418C0Cj
                                            ; .text:00418C10j
    cmp     byte ptr [ecx+146h], 0Ah
    jz      short loc_418C5C
    push    offset aWB                      ; "w+b"
    push    offset Data
    push    2
    mov     ecx, edi
    call    sub_4B73C0
    push    eax
    call    _fopen
    mov     esi, eax
    add     esp, 8
    test    esi, esi
    jz      short loc_418C5C
    push    esi
    push    0
    push    1
    mov     ecx, edi
    call    sub_4B73E0
    push    eax
    call    sub_40C250
    push    esi
    call    _fclose
    add     esp, 4

    loc_418C5C:                             ; CODE XREF: .text:00418BBDj
                                            ; .text:00418BD4j ...
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    cmp     dword ptr [ecx+0D0h], 2
    jnz     short locret_418C9D
    push    0
    push    1
    call    sub_4B73E0
    test    eax, eax
    jl      short loc_418C8F
    cmp     eax, 64h
    jle     short loc_418C91

    loc_418C8F:                             ; CODE XREF: .text:00418C88j
    xor     eax, eax

    loc_418C91:                             ; CODE XREF: .text:00418C8Dj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F35h], eax

    locret_418C9D:                          ; CODE XREF: .text:00418C7Bj
    retn    4
    ; ---------------------------------------------------------------------------
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F2Fh]
    mov     edx, eax
    not     edx
    xor     edx, eax
    and     edx, 400h
    xor     edx, eax
    mov     [ecx+37F2Fh], dx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall TextCommand_ShareMetal()
    TextCommand_ShareMetal proc near

    var_100= byte ptr -100h

    mov     ecx, TAdynmemStructPtr
    sub     esp, 100h
    test    [ecx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_418D79
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    mov     ax, word ptr [ecx+PlayerData.field_0.SharedBits]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, SharedMetal
    xor     edx, eax
    mov     word ptr [ecx+PlayerData.field_0.SharedBits], dx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], SharedMetal
    mov     eax, offset aOn                 ; "ON"
    jnz     short loc_418D51
    mov     eax, offset aOff                ; "OFF"

    loc_418D51:                             ; CODE XREF: TextCommand_ShareMetal+7Aj
    push    eax
    lea     edx, [esp+104h+var_100]
    push    offset aToggledShareme          ; "Toggled ShareMetal to: %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+100h+var_100]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    call    sub_450F90

    loc_418D79:                             ; CODE XREF: TextCommand_ShareMetal+13j
    add     esp, 100h
    retn    4
    TextCommand_ShareMetal endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    TextCommand_ShareEnergy proc near

    var_100= byte ptr -100h

    mov     ecx, TAdynmemStructPtr
    sub     esp, 100h
    test    [ecx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_418E39
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    mov     ax, word ptr [ecx+PlayerData.field_0.SharedBits]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, SharedEnergy
    xor     edx, eax
    mov     word ptr [ecx+PlayerData.field_0.SharedBits], dx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], SharedEnergy
    mov     eax, offset aOn                 ; "ON"
    jnz     short loc_418E11
    mov     eax, offset aOff                ; "OFF"

    loc_418E11:                             ; CODE XREF: TextCommand_ShareEnergy+7Aj
    push    eax
    lea     edx, [esp+104h+var_100]
    push    offset aToggledShareen          ; "Toggled ShareEnergy to: %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+100h+var_100]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    call    sub_450F90

    loc_418E39:                             ; CODE XREF: TextCommand_ShareEnergy+13j
    add     esp, 100h
    retn    4
    TextCommand_ShareEnergy endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall TextCommand_ShareMapping()
    TextCommand_ShareMapping proc near

    var_100= byte ptr -100h

    mov     ecx, TAdynmemStructPtr
    sub     esp, 100h
    test    [ecx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_418EF9
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    mov     ax, word ptr [ecx+PlayerData.field_0.SharedBits]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, SharedMappings
    xor     edx, eax
    mov     word ptr [ecx+PlayerData.field_0.SharedBits], dx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    test    [ecx+PlayerData.field_0.SharedBits], SharedMappings
    mov     eax, offset aOn                 ; "ON"
    jnz     short loc_418ED1
    mov     eax, offset aOff                ; "OFF"

    loc_418ED1:                             ; CODE XREF: TextCommand_ShareMapping+7Aj
    push    eax
    lea     edx, [esp+104h+var_100]
    push    offset aToggledSharema          ; "Toggled ShareMapping to: %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+100h+var_100]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    call    sub_450F90

    loc_418EF9:                             ; CODE XREF: TextCommand_ShareMapping+13j
    add     esp, 100h
    retn    4
    TextCommand_ShareMapping endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall TextCommand_ShareLOS()
    TextCommand_ShareLOS proc near

    TextBuffer= byte ptr -100h

    mov     ecx, TAdynmemStructPtr
    sub     esp, 100h
    test    [ecx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_418FB9
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    mov     ax, word ptr [ecx+PlayerData.field_0.SharedBits]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, SharedLOS
    xor     edx, eax
    mov     word ptr [ecx+PlayerData.field_0.SharedBits], dx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], SharedLOS
    mov     eax, offset aOn                 ; "ON"
    jnz     short loc_418F91
    mov     eax, offset aOff                ; "OFF"

    loc_418F91:                             ; CODE XREF: TextCommand_ShareLOS+7Aj
    push    eax
    lea     edx, [esp+104h+TextBuffer]
    push    offset aToggledSharelo          ; "Toggled ShareLOS to: %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+100h+TextBuffer]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    call    sub_450F90

    loc_418FB9:                             ; CODE XREF: TextCommand_ShareLOS+13j
    add     esp, 100h
    retn    4
    TextCommand_ShareLOS endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall TextCommand_ShareRadar()
    TextCommand_ShareRadar proc near

    var_100= byte ptr -100h

    mov     ecx, TAdynmemStructPtr
    sub     esp, 100h
    test    [ecx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_419079
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    mov     ax, word ptr [ecx+PlayerData.field_0.SharedBits]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, SharedRadar
    xor     edx, eax
    mov     word ptr [ecx+PlayerData.field_0.SharedBits], dx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], SharedRadar
    mov     eax, offset aOn                 ; "ON"
    jnz     short loc_419051
    mov     eax, offset aOff                ; "OFF"

    loc_419051:                             ; CODE XREF: TextCommand_ShareRadar+7Aj
    push    eax
    lea     edx, [esp+104h+var_100]
    push    offset aToggledSharera          ; "Toggled ShareRadar to: %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+100h+var_100]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    call    sub_450F90

    loc_419079:                             ; CODE XREF: TextCommand_ShareRadar+13j
    add     esp, 100h
    retn    4
    TextCommand_ShareRadar endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall TextCommand_ShareAll()
    TextCommand_ShareAll proc near

    TextBuffer= byte ptr -100h

    mov     eax, TAdynmemStructPtr
    sub     esp, 100h
    mov     cl, [eax+TAdynmemStruct.NetworkLayerEnabled]
    push    ebx
    mov     bl, 1
    push    esi
    test    bl, cl
    jz      loc_419330
    test    bl, cl
    jz      loc_419330
    xor     edx, edx
    mov     dl, [eax+TAdynmemStruct.SharedBits]
    mov     ecx, edx
    add     eax, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    mov     esi, [eax+ecx*2+TAdynmemStruct.Players.PlayerInfo]
    mov     cx, word ptr [esi+PlayerData.field_0.SharedBits]
    mov     edx, ecx
    mov     al, cl
    not     edx
    xor     al, dl
    xor     edx, edx
    and     eax, SharedMetal
    xor     eax, ecx
    mov     word ptr [esi+PlayerData.field_0.SharedBits], ax
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], SharedMetal
    mov     eax, offset aOn                 ; "ON"
    jnz     short loc_41911F
    mov     eax, offset aOff                ; "OFF"

    loc_41911F:                             ; CODE XREF: TextCommand_ShareAll+88j
    push    eax
    lea     edx, [esp+10Ch+TextBuffer]
    push    offset aToggledShareme          ; "Toggled ShareMetal to: %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+108h+TextBuffer]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    call    sub_450F90
    mov     eax, TAdynmemStructPtr
    test    [eax+TAdynmemStruct.NetworkLayerEnabled], bl
    jz      loc_419330
    xor     edx, edx
    mov     dl, [eax+TAdynmemStruct.SharedBits]
    mov     ecx, edx
    add     eax, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    mov     esi, [eax+ecx*2+TAdynmemStruct.Players.PlayerInfo]
    mov     cx, word ptr [esi+PlayerData.field_0.SharedBits]
    mov     edx, ecx
    mov     al, cl
    not     edx
    xor     al, dl
    xor     edx, edx
    and     eax, SharedEnergy
    xor     eax, ecx
    mov     word ptr [esi+PlayerData.field_0.SharedBits], ax
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], SharedEnergy
    mov     eax, offset aOn                 ; "ON"
    jnz     short loc_4191C2
    mov     eax, offset aOff                ; "OFF"

    loc_4191C2:                             ; CODE XREF: TextCommand_ShareAll+12Bj
    push    eax
    lea     edx, [esp+10Ch+TextBuffer]
    push    offset aToggledShareen          ; "Toggled ShareEnergy to: %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+108h+TextBuffer]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    call    sub_450F90
    mov     eax, TAdynmemStructPtr
    test    [eax+TAdynmemStruct.NetworkLayerEnabled], bl
    jz      loc_419330
    xor     edx, edx
    mov     dl, [eax+TAdynmemStruct.SharedBits]
    mov     ecx, edx
    add     eax, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    mov     esi, [eax+ecx*2+TAdynmemStruct.Players.PlayerInfo]
    mov     cx, word ptr [esi+PlayerData.field_0.SharedBits]
    mov     edx, ecx
    mov     al, cl
    not     edx
    xor     al, dl
    xor     edx, edx
    and     eax, SharedMappings
    xor     eax, ecx
    mov     word ptr [esi+PlayerData.field_0.SharedBits], ax
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], SharedMappings
    mov     eax, offset aOn                 ; "ON"
    jnz     short loc_419265
    mov     eax, offset aOff                ; "OFF"

    loc_419265:                             ; CODE XREF: TextCommand_ShareAll+1CEj
    push    eax
    lea     edx, [esp+10Ch+TextBuffer]
    push    offset aToggledSharema          ; "Toggled ShareMapping to: %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+108h+TextBuffer]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    call    sub_450F90
    mov     eax, TAdynmemStructPtr
    test    [eax+TAdynmemStruct.NetworkLayerEnabled], bl
    jz      loc_419330
    xor     edx, edx
    mov     dl, [eax+TAdynmemStruct.SharedBits]
    mov     ecx, edx
    add     eax, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    mov     esi, [eax+ecx*2+TAdynmemStruct.Players.PlayerInfo]
    mov     cx, word ptr [esi+PlayerData.field_0.SharedBits]
    mov     edx, ecx
    mov     al, cl
    not     edx
    xor     al, dl
    xor     edx, edx
    and     eax, SharedRadar
    xor     eax, ecx
    mov     word ptr [esi+PlayerData.field_0.SharedBits], ax
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], SharedRadar
    mov     eax, offset aOn                 ; "ON"
    jnz     short loc_419308
    mov     eax, offset aOff                ; "OFF"

    loc_419308:                             ; CODE XREF: TextCommand_ShareAll+271j
    push    eax
    lea     edx, [esp+10Ch+TextBuffer]
    push    offset aToggledSharera          ; "Toggled ShareRadar to: %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+108h+TextBuffer]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    call    sub_450F90

    loc_419330:                             ; CODE XREF: TextCommand_ShareAll+17j
                                            ; TextCommand_ShareAll+1Fj ...
    pop     esi
    pop     ebx
    add     esp, 100h
    retn    4
    TextCommand_ShareAll endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall TextCommand_SetShareMetal(int)
    TextCommand_SetShareMetal proc near

    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= byte ptr -100h
    NewShareLimit= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    sub     esp, 108h
    test    [ecx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_4193F7
    xor     edx, edx
    push    edi
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     edi, [esp+10Ch+NewShareLimit]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    push    esi
    push    0                               ; int
    push    1                               ; int
    lea     eax, [eax+eax*4]
    fld     [ecx+eax*2+TAdynmemStruct.Players.Resources.fMaxMetalStorage]
    lea     esi, [ecx+eax*2+TAdynmemStruct.Players]
    mov     ecx, edi
    fstp    [esp+118h+var_108]
    call    sub_4B73E0
    mov     [esp+110h+var_104], eax
    fild    [esp+110h+var_104]
    fcomp   [esp+110h+var_108]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4193AE
    fld     [esi+PlayerStruct.Resources.fMaxMetalStorage]
    jmp     short loc_4193C1
    ; ---------------------------------------------------------------------------

    loc_4193AE:                             ; CODE XREF: TextCommand_SetShareMetal+64j
    push    0                               ; int
    push    1                               ; int
    mov     ecx, edi
    call    sub_4B73E0
    mov     [esp+110h+var_108], eax
    fild    [esp+110h+var_108]

    loc_4193C1:                             ; CODE XREF: TextCommand_SetShareMetal+6Cj
    push    0                               ; int
    push    1                               ; int
    fstp    [esi+PlayerStruct.SharedMetalLimit]
    mov     ecx, edi
    call    sub_4B73E0
    push    eax
    lea     ecx, [esp+114h+var_100]
    push    offset aOk_WillShareMe          ; "OK.  Will share metal if above %d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+110h+var_100]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    edx                             ; char *
    call    sub_463CA0
    pop     esi
    pop     edi

    loc_4193F7:                             ; CODE XREF: TextCommand_SetShareMetal+13j
    add     esp, 108h
    retn    4
    TextCommand_SetShareMetal endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall TextCommand_SetShareEnergy(int)
    TextCommand_SetShareEnergy proc near

    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= byte ptr -100h
    NewShareLimit= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    sub     esp, 108h
    test    [ecx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_4194B7
    xor     edx, edx
    push    edi
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     edi, [esp+10Ch+NewShareLimit]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    push    esi
    push    0                               ; int
    push    1                               ; int
    lea     eax, [eax+eax*4]
    fld     [ecx+eax*2+TAdynmemStruct.Players.Resources.fMaxEnergyStorage]
    lea     esi, [ecx+eax*2+TAdynmemStruct.Players]
    mov     ecx, edi
    fstp    [esp+118h+var_108]
    call    sub_4B73E0
    mov     [esp+110h+var_104], eax
    fild    [esp+110h+var_104]
    fcomp   [esp+110h+var_108]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41946E
    fld     [esi+PlayerStruct.Resources.fMaxEnergyStorage]
    jmp     short loc_419481
    ; ---------------------------------------------------------------------------

    loc_41946E:                             ; CODE XREF: TextCommand_SetShareEnergy+64j
    push    0                               ; int
    push    1                               ; int
    mov     ecx, edi
    call    sub_4B73E0
    mov     [esp+110h+var_108], eax
    fild    [esp+110h+var_108]

    loc_419481:                             ; CODE XREF: TextCommand_SetShareEnergy+6Cj
    push    0                               ; int
    push    1                               ; int
    fstp    [esi+PlayerStruct.SharedEnergyLimit]
    mov     ecx, edi
    call    sub_4B73E0
    push    eax
    lea     ecx, [esp+114h+var_100]
    push    offset aOk_WillShareEn          ; "OK.  Will share energy if above %d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+110h+var_100]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    edx                             ; char *
    call    sub_463CA0
    pop     esi
    pop     edi

    loc_4194B7:                             ; CODE XREF: TextCommand_SetShareEnergy+13j
    add     esp, 108h
    retn    4
    TextCommand_SetShareEnergy endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4194C0()
    sub_4194C0 proc near
    mov     eax, TAdynmemStructPtr
    xor     dword ptr [eax+391BFh], 1
    retn    4
    sub_4194C0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    sub     esp, 100h
    test    byte ptr [eax+2A44h], 1
    jz      short loc_419534
    mov     edx, [eax+4EDh]
    xor     ecx, ecx
    test    edx, edx
    setz    cl
    mov     [eax+4EDh], ecx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+4EDh]
    test    eax, eax
    mov     eax, offset aOff                ; "OFF"
    jnz     short loc_419511
    mov     eax, offset aOn                 ; "ON"

    loc_419511:                             ; CODE XREF: .text:0041950Aj
    push    eax
    lea     eax, [esp+4]
    push    offset aOk_OutgoingPac          ; "Ok.  Outgoing packet compression turned"...
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+0]
    push    0Ah
    push    0
    push    2
    push    ecx
    call    sub_463CA0

    loc_419534:                             ; CODE XREF: .text:004194E2j
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    xor     dword ptr [eax+391C3h], 1
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    xor     byte_51E608, 1
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_419560 proc near                    ; CODE XREF: sub_4917D0+207p
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     ecx, [eax+38A47h]
    mov     dword_511BC0, edx
    mov     dword_511C20, ecx
    mov     dword_511BC4, edx
    mov     ecx, offset dword_511C64
    xor     eax, eax

    loc_419586:                             ; CODE XREF: sub_419560+45j
    mov     dword_511A60[eax], edx
    mov     dword_511A64[eax], edx
    mov     dword_511C60[eax], edx
    mov     [ecx], edx
    add     eax, 8
    add     ecx, 8
    cmp     eax, 160h
    jl      short loc_419586
    push    offset off_501D38
    mov     Global_PacketCount_1, edx
    mov     Global_PacketSumSize_1, edx
    mov     Global_PacketCount_2, edx
    mov     Global_PacketSumSize_2, edx
    call    sub_4B7760
    push    offset off_501F48
    call    sub_4B7760
    push    offset off_501FD0
    call    sub_4B7760
    push    4
    push    offset sub_417890
    call    sub_4B78E0
    retn
    sub_419560 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+8]
    push    esi
    and     ecx, 0FFFFh
    mov     esi, [esp+8]
    mov     eax, ecx
    push    20h
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1439Bh]
    lea     eax, [eax+eax*8]
    lea     eax, [eax+edx+20h]
    push    eax
    push    esi
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [esi+1Fh], 0
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+0Ch]
    mov     edx, [esp+4]
    sub     esp, 20h
    lea     ecx, [esp+0]
    push    eax
    push    ecx
    push    edx
    call    sub_49FED0
    lea     ecx, [esp+0]
    mov     eax, [esp+28h]
    push    eax
    push    ecx
    call    _strstr
    add     esp, 8
    neg     eax
    sbb     eax, eax
    neg     eax
    add     esp, 20h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_419670 proc near                    ; CODE XREF: sub_498F70+28p

    var_10= word ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 10h
    mov     eax, [esp+10h+arg_0]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [eax+8]
    mov     eax, TAdynmemStructPtr
    shr     edi, 2
    mov     bp, [eax+2CC4h]
    mov     edx, [eax+1439Bh]
    and     ebp, 0FFFFh
    and     edi, 1
    mov     ecx, ebp
    shl     ecx, 6
    add     ecx, ebp
    lea     ecx, [ecx+ecx*8]
    add     edx, ecx
    lea     ecx, [eax+2CAAh]
    mov     esi, ecx
    mov     ecx, [esi]
    mov     [esp+20h+var_C], ecx
    mov     ebx, [esi+4]
    mov     [esp+20h+var_8], ebx
    mov     esi, [esi+8]
    mov     [esp+20h+var_4], esi
    mov     edx, [edx+14Ah]
    movsx   esi, dx
    mov     [esp+20h+arg_0], edx
    mov     edx, esi
    movsx   ebx, word ptr [esp+20h+arg_0+2]
    shl     edx, 13h
    sub     ecx, edx
    mov     edx, [esp+20h+var_4]
    add     ecx, 80000h
    sar     ecx, 14h
    mov     [esp+20h+var_10], cx
    mov     ecx, ebx
    shl     ecx, 13h
    sub     edx, ecx
    movsx   ecx, [esp+20h+var_10]
    add     edx, 80000h
    sar     edx, 14h
    lea     ecx, [esi+ecx*2]
    movsx   edx, dx
    shl     ecx, 13h
    mov     [esp+20h+var_C], ecx
    lea     ecx, [ebx+edx*2]
    shl     ecx, 13h
    mov     [esp+20h+var_4], ecx
    mov     edx, [eax+2C96h]
    shl     edx, 10h
    mov     [esp+20h+var_8], edx
    xor     edx, edx
    mov     dl, [eax+2A42h]
    mov     ecx, edx
    add     eax, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    mov     esi, [eax+ecx*2+1BCAh]
    lea     ebx, [eax+ecx*2+1B63h]
    mov     eax, [eax+ecx*2+1BCEh]
    cmp     esi, eax
    ja      short loc_4197BB

    loc_419755:                             ; CODE XREF: sub_419670+149j
    test    byte ptr [esi+110h], 10h
    jz      short loc_4197AE
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    test    al, 40h
    jz      short loc_4197AE
    test    ah, 8
    jnz     short loc_419789
    push    0
    lea     eax, [esp+24h+var_C]
    push    ebp
    push    eax
    push    0
    push    esi
    push    edi
    push    ecx
    mov     ecx, esp
    push    offset aMobilebuild             ; "MOBILEBUILD"
    jmp     short loc_4197A4
    ; ---------------------------------------------------------------------------

    loc_419789:                             ; CODE XREF: sub_419670+101j
    shr     eax, 0Bh
    test    al, 1
    jz      short loc_4197AE
    push    0
    lea     ecx, [esp+24h+var_C]
    push    ebp
    push    ecx
    push    0
    push    esi
    push    edi
    push    ecx
    mov     ecx, esp
    push    offset aVtol_mobilebui          ; char *

    loc_4197A4:                             ; CODE XREF: sub_419670+117j
    call    sub_438760
    call    sub_43AFC0

    loc_4197AE:                             ; CODE XREF: sub_419670+ECj
                                            ; sub_419670+FCj ...
    mov     eax, [ebx+6Bh]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_419755

    loc_4197BB:                             ; CODE XREF: sub_419670+E3j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    4
    sub_419670 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4197D0 proc near                    ; CODE XREF: .text:00491CDBp
                                            ; .text:00499241p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_8= dword ptr -8

    sub     esp, 14h
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    ebx
    push    esi
    mov     cx, [edx+2CC4h]
    push    edi
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     esi, [eax+eax*8]
    mov     eax, [edx+1439Bh]
    add     esi, eax
    lea     eax, [edx+2CAAh]
    mov     ecx, eax
    mov     edi, [esi+14Ah]
    mov     eax, [ecx]
    mov     [esp+20h+var_10], edi
    movsx   edi, di
    mov     ebx, [ecx+4]
    shl     edi, 13h
    mov     ecx, [ecx+8]
    sub     eax, edi
    movsx   edi, word ptr [esp+20h+var_10+2]
    add     eax, 80000h
    mov     [esp+20h+var_8], ebx
    shl     edi, 13h
    sar     eax, 14h
    sub     ecx, edi
    mov     word ptr [esp+20h+var_14], ax
    add     ecx, 80000h
    movsx   eax, ax
    sar     ecx, 14h
    mov     word ptr [esp+20h+var_14+2], cx
    mov     edi, [esp+20h+var_14]
    shl     eax, 4
    movsx   ecx, cx
    mov     [edx+2C92h], eax
    mov     edx, TAdynmemStructPtr
    shl     ecx, 4
    mov     [edx+2C9Ah], ecx
    mov     eax, [esi+14Ah]
    mov     [esp+20h+var_10], eax
    movsx   ecx, ax
    mov     eax, TAdynmemStructPtr
    movsx   edx, word ptr [esp+20h+var_10+2]
    mov     ebx, [eax+2C92h]
    shl     ecx, 4
    add     ecx, ebx
    mov     [eax+2C9Eh], ecx
    mov     eax, TAdynmemStructPtr
    shl     edx, 4
    add     edx, [eax+2C9Ah]
    mov     [eax+2CA6h], edx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*2+1B63h]
    push    ecx
    push    0
    push    edi
    push    esi
    call    sub_47D2E0
    mov     ecx, TAdynmemStructPtr
    and     al, 1
    shl     al, 6
    mov     dl, [ecx+2CC6h]
    and     dl, 0BFh
    or      dl, al
    mov     [ecx+2CC6h], dl
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2CC6h], 40h
    jz      short loc_4198FC
    call    sub_47C780
    jmp     short loc_419903
    ; ---------------------------------------------------------------------------

    loc_4198FC:                             ; CODE XREF: sub_4197D0+123j
    push    edi
    push    esi
    call    sub_47D820

    loc_419903:                             ; CODE XREF: sub_4197D0+12Aj
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [esp+20h+var_14], al
    mov     eax, [esp+20h+var_14]
    pop     edi
    and     eax, 0FFh
    pop     esi
    mov     [ecx+2C96h], eax
    mov     edx, TAdynmemStructPtr
    pop     ebx
    mov     [edx+2CA2h], eax
    mov     eax, TAdynmemStructPtr
    mov     al, [eax+2CC6h]
    shr     eax, 6
    and     eax, 1
    add     esp, 14h
    retn
    sub_4197D0 endp

    ; ---------------------------------------------------------------------------
    mov     ecx, [esp+8]
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1439Bh]
    mov     ecx, [esp+4]
    lea     eax, [eax+eax*8]
    lea     eax, [eax+edx+20h]
    mov     edx, [ecx+18h]
    push    eax
    mov     eax, [edx+4]
    push    eax
    call    sub_49FF10
    test    eax, eax
    jz      short locret_41999F
    mov     ecx, [esp+0Ch]
    test    ecx, ecx
    jz      short loc_419998
    push    ecx
    add     eax, 0B6h
    push    offset aD_1                     ; "+%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_419998:                             ; CODE XREF: .text:0041997Fj
    mov     byte ptr [eax+0B6h], 0

    locret_41999F:                          ; CODE XREF: .text:00419977j
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4199B0 proc near                    ; CODE XREF: sub_41AA00+25Ep
                                            ; sub_41ACE0+31Ap ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     eax, [esp+4+arg_0]
    mov     ecx, [eax+18h]
    mov     ecx, [ecx+4]
    movsx   eax, word ptr [ecx+0B6h]
    add     ecx, 15Bh
    inc     eax
    cmp     eax, 1
    mov     [esp+4+arg_0], ecx
    jle     loc_419A9E
    push    edi
    push    esi
    dec     eax
    push    ebp
    mov     ebp, [esp+10h+arg_4]
    push    ebx
    lea     esi, [ecx+0B6h]
    mov     [esp+14h+var_4], eax

    loc_4199E9:                             ; CODE XREF: sub_4199B0+E4j
    cmp     byte ptr [ecx], 1
    jnz     loc_419A77
    mov     al, [esi-8Ch]
    test    al, 4
    jz      short loc_419A2B
    lea     edx, [esi-0B4h]
    push    edx                             ; char *
    call    sub_488B10
    test    ax, ax
    jz      short loc_419A77
    and     eax, 0FFFFh
    push    eax
    push    ebp
    call    sub_439D80
    test    eax, eax
    jz      short loc_419A26
    push    eax
    push    offset aD_1                     ; "+%d"
    push    esi
    jmp     short loc_419A6F
    ; ---------------------------------------------------------------------------

    loc_419A26:                             ; CODE XREF: sub_4199B0+6Bj
    mov     byte ptr [esi], 0
    jmp     short loc_419A77
    ; ---------------------------------------------------------------------------

    loc_419A2B:                             ; CODE XREF: sub_4199B0+4Aj
    test    al, 8
    jz      short loc_419A77
    xor     eax, eax
    push    0
    mov     al, [ebp+1Eh]
    push    ebp
    mov     edi, eax
    call    sub_439D80
    test    edi, edi
    mov     ebx, eax
    mov     byte ptr [esi], 0
    jz      short loc_419A56
    push    edi
    push    offset aD_0                     ; "%d"
    push    esi
    call    _sprintf
    add     esp, 0Ch

    loc_419A56:                             ; CODE XREF: sub_4199B0+95j
    test    ebx, ebx
    jz      short loc_419A77
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    ebx
    repne scasb
    not     ecx
    dec     ecx
    push    offset aD                       ; " +%d"
    add     ecx, esi
    push    ecx

    loc_419A6F:                             ; CODE XREF: sub_4199B0+74j
    call    _sprintf
    add     esp, 0Ch

    loc_419A77:                             ; CODE XREF: sub_4199B0+3Cj
                                            ; sub_4199B0+5Bj ...
    mov     ecx, [esp+14h+arg_0]
    mov     eax, [esp+14h+var_4]
    add     ecx, 15Bh
    add     esi, 15Bh
    dec     eax
    mov     [esp+14h+arg_0], ecx
    mov     [esp+14h+var_4], eax
    jnz     loc_4199E9
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_419A9E:                             ; CODE XREF: sub_4199B0+20j
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_49FA90
    pop     ecx
    retn    8
    sub_4199B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_419AC0 proc near

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    offset aOnoff                   ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short locret_419AFD
    mov     ecx, [esp+arg_0]
    mov     dl, [ecx+10Eh]
    and     edx, 1
    push    edx
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A11C0

    locret_419AFD:                          ; CODE XREF: sub_419AC0+1Cj
    retn    4
    sub_419AC0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_419B00(char *,int,int)
    sub_419B00 proc near                    ; CODE XREF: sub_408620+3Ep
                                            ; sub_4086D0+F4p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+4+arg_8]
    push    esi
    mov     esi, [esp+8+arg_4]
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    push    edi
    mov     al, [esi+0FFh]
    cmp     al, dl
    jnz     short loc_419B38
    test    ebx, ebx
    push    0                               ; int
    jle     short loc_419B2E
    push    offset aAddbuild                ; "addbuild"
    jmp     short loc_419B33
    ; ---------------------------------------------------------------------------

    loc_419B2E:                             ; CODE XREF: sub_419B00+25j
    push    offset aSubbuild                ; char *

    loc_419B33:                             ; CODE XREF: sub_419B00+2Cj
    call    sub_47F1A0

    loc_419B38:                             ; CODE XREF: sub_419B00+1Fj
    mov     edi, [esp+0Ch+arg_0]
    push    offset aMakenuke                ; char *
    push    edi                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jnz     short loc_419B97
    push    offset aMakeanti                ; char *
    push    edi                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jnz     short loc_419B97
    push    edi                             ; char *
    call    sub_488B10
    test    ax, ax
    jz      short loc_419BAD
    mov     ecx, [esi]
    mov     edx, offset aMobilebuild        ; "MOBILEBUILD"
    test    ecx, ecx
    jnz     short loc_419B7B
    mov     edx, offset aBuildingbuil_0     ; "BUILDINGBUILD"

    loc_419B7B:                             ; CODE XREF: sub_419B00+74j
    and     eax, 0FFFFh
    push    ebx
    push    eax
    push    esi
    push    ecx
    mov     ecx, esp
    push    edx                             ; char *
    call    sub_438760
    call    sub_43B0B0
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_419B97:                             ; CODE XREF: sub_419B00+4Cj
                                            ; sub_419B00+5Ej
    push    ebx
    push    0
    push    esi
    push    ecx
    mov     ecx, esp
    push    offset aBuildweapon             ; char *
    call    sub_438760
    call    sub_43B0B0

    loc_419BAD:                             ; CODE XREF: sub_419B00+69j
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_419B00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_419BC0 proc near

    arg_0= byte ptr  4

    mov     eax, TAdynmemStructPtr
    mov     cl, [esp+arg_0]
    mov     [eax+2CC3h], cl
    mov     eax, TAdynmemStructPtr
    and     [eax+TAdynmemStruct.BuildSpotState], 0F7h
    retn    4
    sub_419BC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_419BE0 proc near                    ; CODE XREF: sub_41AA00+1CCp

    var_20= byte ptr -20h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    sub     esp, 20h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+30h+arg_0]
    lea     ebx, [eax+2C76h]
    mov     esi, [esp+30h+arg_4]
    mov     eax, [edi+60h]
    lea     ecx, ds:0[eax*8]
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     edx, [esi+eax]
    lea     ecx, [edx+ecx*2]
    mov     ebp, ecx
    cmp     byte ptr [ecx], 1
    jz      short loc_419C20
    mov     ebp, [esp+30h+arg_0]

    loc_419C20:                             ; CODE XREF: sub_419BE0+3Aj
    push    eax                             ; int
    lea     eax, [esp+34h+var_20]
    push    eax                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     ecx, [esp+30h+var_20]
    push    offset aMove_0                  ; char *
    push    ecx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_419C91
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_419C5E
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2CC3h], 1
    jmp     loc_41A0DE
    ; ---------------------------------------------------------------------------

    loc_419C5E:                             ; CODE XREF: sub_419BE0+6Aj
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aImmediateorder          ; char *
    mov     byte ptr [eax+2CC3h], 2
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0F7h
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_419C91:                             ; CODE XREF: sub_419BE0+60j
    mov     ecx, [edi+60h]
    lea     edx, [esp+30h+var_20]
    push    ecx                             ; int
    push    edx                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     eax, [esp+30h+var_20]
    push    offset aStop                    ; char *
    push    eax                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_419CF7
    mov     ecx, TAdynmemStructPtr
    push    0
    push    0
    push    0
    mov     byte ptr [ecx+2CC3h], 1
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2CC6h]
    and     cl, 0F7h
    push    ecx
    mov     [eax+2CC6h], cl
    mov     ecx, esp
    push    offset aStop                    ; char *
    call    sub_438760
    push    0
    push    ebx
    call    sub_48CF30
    jmp     loc_41A0EA
    ; ---------------------------------------------------------------------------

    loc_419CF7:                             ; CODE XREF: sub_419BE0+D4j
    mov     edx, [edi+60h]
    lea     eax, [esp+30h+var_20]
    push    edx                             ; int
    push    eax                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     ecx, [esp+30h+var_20]
    push    offset aAttack                  ; char *
    push    ecx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_419D6B
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_419D38
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2CC3h], 1
    jmp     loc_41A0DE
    ; ---------------------------------------------------------------------------

    loc_419D38:                             ; CODE XREF: sub_419BE0+144j
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aImmediateorder          ; char *
    mov     byte ptr [eax+2CC3h], 3
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0F7h
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_419D6B:                             ; CODE XREF: sub_419BE0+13Aj
    mov     ecx, [edi+60h]
    lea     edx, [esp+30h+var_20]
    push    ecx                             ; int
    push    edx                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     eax, [esp+30h+var_20]
    push    offset aBlast                   ; char *
    push    eax                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_419DE0
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_419DAC
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2CC3h], 1
    jmp     loc_41A0DE
    ; ---------------------------------------------------------------------------

    loc_419DAC:                             ; CODE XREF: sub_419BE0+1B8j
    mov     edx, TAdynmemStructPtr
    push    0                               ; int
    push    offset aImmediateorder          ; char *
    mov     byte ptr [edx+2CC3h], 4
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0F7h
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_419DE0:                             ; CODE XREF: sub_419BE0+1AEj
    mov     eax, [edi+60h]
    lea     ecx, [esp+30h+var_20]
    push    eax                             ; int
    push    ecx                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     edx, [esp+30h+var_20]
    push    offset aDefend                  ; char *
    push    edx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_419E54
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_419E20
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2CC3h], 1
    jmp     loc_41A0DE
    ; ---------------------------------------------------------------------------

    loc_419E20:                             ; CODE XREF: sub_419BE0+22Dj
    mov     ecx, TAdynmemStructPtr
    push    0                               ; int
    push    offset aImmediateorder          ; char *
    mov     byte ptr [ecx+2CC3h], 7
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0F7h
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_419E54:                             ; CODE XREF: sub_419BE0+223j
    mov     edx, [edi+60h]
    lea     eax, [esp+30h+var_20]
    push    edx                             ; int
    push    eax                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     ecx, [esp+30h+var_20]
    push    offset aRepair                  ; char *
    push    ecx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_419EC8
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_419E95
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2CC3h], 1
    jmp     loc_41A06D
    ; ---------------------------------------------------------------------------

    loc_419E95:                             ; CODE XREF: sub_419BE0+2A1j
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aSpecialorders           ; char *
    mov     byte ptr [eax+2CC3h], 8
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0F7h
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_419EC8:                             ; CODE XREF: sub_419BE0+297j
    mov     ecx, [edi+60h]
    lea     edx, [esp+30h+var_20]
    push    ecx                             ; int
    push    edx                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     eax, [esp+30h+var_20]
    push    offset aPatrol                  ; char *
    push    eax                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_419F3D
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_419F09
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2CC3h], 1
    jmp     loc_41A0DE
    ; ---------------------------------------------------------------------------

    loc_419F09:                             ; CODE XREF: sub_419BE0+315j
    mov     edx, TAdynmemStructPtr
    push    0                               ; int
    push    offset aImmediateorder          ; char *
    mov     byte ptr [edx+2CC3h], 9
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0F7h
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_419F3D:                             ; CODE XREF: sub_419BE0+30Bj
    mov     eax, [edi+60h]
    lea     ecx, [esp+30h+var_20]
    push    eax                             ; int
    push    ecx                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     edx, [esp+30h+var_20]
    push    offset aReclaim                 ; char *
    push    edx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_419FB1
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_419F7D
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2CC3h], 1
    jmp     loc_41A06D
    ; ---------------------------------------------------------------------------

    loc_419F7D:                             ; CODE XREF: sub_419BE0+38Aj
    mov     ecx, TAdynmemStructPtr
    push    0                               ; int
    push    offset aSpecialorders           ; char *
    mov     byte ptr [ecx+2CC3h], 0Ch
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0F7h
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_419FB1:                             ; CODE XREF: sub_419BE0+380j
    mov     edx, [edi+60h]
    lea     eax, [esp+30h+var_20]
    push    edx                             ; int
    push    eax                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     ecx, [esp+30h+var_20]
    push    offset aCapture                 ; char *
    push    ecx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_41A022
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_419FEF
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2CC3h], 1
    jmp     short loc_41A06D
    ; ---------------------------------------------------------------------------

    loc_419FEF:                             ; CODE XREF: sub_419BE0+3FEj
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aSpecialorders           ; char *
    mov     byte ptr [eax+2CC3h], 0Dh
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0F7h
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_41A022:                             ; CODE XREF: sub_419BE0+3F4j
    mov     ecx, [edi+60h]
    lea     edx, [esp+30h+var_20]
    push    ecx                             ; int
    push    edx                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     eax, [esp+30h+var_20]
    push    offset aUnload                  ; char *
    push    eax                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_41A094
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_41A060
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2CC3h], 1
    jmp     short loc_41A06D
    ; ---------------------------------------------------------------------------

    loc_41A060:                             ; CODE XREF: sub_419BE0+46Fj
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2CC3h], 5

    loc_41A06D:                             ; CODE XREF: sub_419BE0+2B0j
                                            ; sub_419BE0+398j ...
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aSpecialorders           ; char *
    and     byte ptr [eax+2CC6h], 0F7h
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_41A094:                             ; CODE XREF: sub_419BE0+465j
    mov     eax, [edi+60h]
    lea     ecx, [esp+30h+var_20]
    push    eax                             ; int
    push    ecx                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     edx, [esp+30h+var_20]
    push    offset aLoad                    ; char *
    push    edx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_41A105
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_41A0D1
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2CC3h], 1
    jmp     short loc_41A0DE
    ; ---------------------------------------------------------------------------

    loc_41A0D1:                             ; CODE XREF: sub_419BE0+4E1j
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2CC3h], 6

    loc_41A0DE:                             ; CODE XREF: sub_419BE0+79j
                                            ; sub_419BE0+153j ...
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0F7h

    loc_41A0EA:                             ; CODE XREF: sub_419BE0+112j
    push    0                               ; int
    push    offset aImmediateorder          ; char *
    call    sub_47F1A0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_41A105:                             ; CODE XREF: sub_419BE0+4D7j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 20h
    retn    8
    sub_419BE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41A120 proc near                    ; CODE XREF: sub_41A490+445p
                                            ; sub_41ACE0+307p ...

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebp
    push    esi
    push    edi
    lea     esi, [eax+519h]
    mov     eax, [eax+531h]
    push    offset aBuild                   ; char *
    mov     ebp, [eax+4]
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    mov     edi, [esp+0Ch+arg_0]
    jz      short loc_41A17E
    test    edi, edi
    jz      short loc_41A175
    mov     ecx, [edi+92h]
    mov     dl, [ecx+22Eh]
    test    dl, dl
    jz      short loc_41A175
    mov     edx, [edi+110h]
    shr     edx, 16h
    and     edx, 1
    push    edx
    push    eax
    push    esi
    call    sub_4A11C0
    jmp     short loc_41A17E
    ; ---------------------------------------------------------------------------

    loc_41A175:                             ; CODE XREF: sub_41A120+2Dj
                                            ; sub_41A120+3Dj
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A17E:                             ; CODE XREF: sub_41A120+29j
                                            ; sub_41A120+53j
    push    offset aOrders                  ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A1C3
    test    edi, edi
    jz      short loc_41A1BA
    mov     ecx, [edi+92h]
    mov     dl, [ecx+22Eh]
    test    dl, dl
    jz      short loc_41A1BA
    mov     edx, [edi+110h]
    not     edx
    shr     edx, 16h
    and     edx, 1
    push    edx
    push    eax
    push    esi
    call    sub_4A11C0
    jmp     short loc_41A1C3
    ; ---------------------------------------------------------------------------

    loc_41A1BA:                             ; CODE XREF: sub_41A120+70j
                                            ; sub_41A120+80j
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A1C3:                             ; CODE XREF: sub_41A120+6Cj
                                            ; sub_41A120+98j
    push    offset aCloak                   ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A203
    mov     ecx, TAdynmemStructPtr
    mov     cx, [ecx+37EC0h]
    mov     dl, cl
    and     dl, 18h
    cmp     dl, 18h
    jnz     short loc_41A1F5
    push    1
    push    eax
    push    esi
    call    sub_4A1200
    jmp     short loc_41A203
    ; ---------------------------------------------------------------------------

    loc_41A1F5:                             ; CODE XREF: sub_41A120+C8j
    shr     ecx, 3
    and     ecx, 3
    push    ecx
    push    eax
    push    esi
    call    sub_4A11C0

    loc_41A203:                             ; CODE XREF: sub_41A120+B1j
                                            ; sub_41A120+D3j
    push    offset aOnoff                   ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A243
    mov     ecx, TAdynmemStructPtr
    mov     cx, [ecx+37EC0h]
    mov     dl, cl
    and     dl, 60h
    cmp     dl, 60h
    jnz     short loc_41A235
    push    1
    push    eax
    push    esi
    call    sub_4A1200
    jmp     short loc_41A243
    ; ---------------------------------------------------------------------------

    loc_41A235:                             ; CODE XREF: sub_41A120+108j
    shr     ecx, 5
    and     ecx, 3
    push    ecx
    push    eax
    push    esi
    call    sub_4A11C0

    loc_41A243:                             ; CODE XREF: sub_41A120+F1j
                                            ; sub_41A120+113j
    push    offset aMoveord                 ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A280
    mov     ecx, TAdynmemStructPtr
    mov     cx, [ecx+37EC0h]
    mov     dl, cl
    and     dl, 7
    cmp     dl, 4
    jnz     short loc_41A275
    push    1
    push    eax
    push    esi
    call    sub_4A1200
    jmp     short loc_41A280
    ; ---------------------------------------------------------------------------

    loc_41A275:                             ; CODE XREF: sub_41A120+148j
    and     ecx, 7
    push    ecx
    push    eax
    push    esi
    call    sub_4A11C0

    loc_41A280:                             ; CODE XREF: sub_41A120+131j
                                            ; sub_41A120+153j
    push    offset aFireord                 ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A2C6
    mov     ecx, TAdynmemStructPtr
    mov     cx, [ecx+37EBEh]
    mov     edx, ecx
    and     edx, 7000h
    cmp     edx, 4000h
    jnz     short loc_41A2B8
    push    1
    push    eax
    push    esi
    call    sub_4A1200
    jmp     short loc_41A2C6
    ; ---------------------------------------------------------------------------

    loc_41A2B8:                             ; CODE XREF: sub_41A120+18Bj
    shr     ecx, 0Ch
    and     ecx, 7
    push    ecx
    push    eax
    push    esi
    call    sub_4A11C0

    loc_41A2C6:                             ; CODE XREF: sub_41A120+16Ej
                                            ; sub_41A120+196j
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EC0h], 80h
    jnz     short loc_41A2ED
    push    offset aMove_0                  ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A2ED
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A2ED:                             ; CODE XREF: sub_41A120+1B2j
                                            ; sub_41A120+1C2j
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+37EC1h], 1
    jnz     short loc_41A315
    push    offset aStop                    ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A315
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A315:                             ; CODE XREF: sub_41A120+1DAj
                                            ; sub_41A120+1EAj
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+37EC1h], 2
    jnz     short loc_41A33D
    push    offset aAttack                  ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A33D
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A33D:                             ; CODE XREF: sub_41A120+202j
                                            ; sub_41A120+212j
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EC1h], 4
    jnz     short loc_41A364
    push    offset aDefend                  ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A364
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A364:                             ; CODE XREF: sub_41A120+229j
                                            ; sub_41A120+239j
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+37EC1h], 8
    jnz     short loc_41A38C
    push    offset aPatrol                  ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A38C
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A38C:                             ; CODE XREF: sub_41A120+251j
                                            ; sub_41A120+261j
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+37EC1h], 20h
    jnz     short loc_41A3B4
    push    offset aReclaim                 ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A3B4
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A3B4:                             ; CODE XREF: sub_41A120+279j
                                            ; sub_41A120+289j
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EC1h], 80h
    jnz     short loc_41A3DB
    push    offset aRepair                  ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A3DB
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A3DB:                             ; CODE XREF: sub_41A120+2A0j
                                            ; sub_41A120+2B0j
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+37EC1h], 40h
    jnz     short loc_41A403
    push    offset aCapture                 ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A403
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A403:                             ; CODE XREF: sub_41A120+2C8j
                                            ; sub_41A120+2D8j
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+37EC1h], 10h
    jnz     short loc_41A471
    push    offset aLoad                    ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A42B
    push    0
    push    eax
    push    esi
    call    sub_4A03F0

    loc_41A42B:                             ; CODE XREF: sub_41A120+300j
    push    offset aUnload                  ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A444
    push    1
    push    eax
    push    esi
    call    sub_4A1200

    loc_41A444:                             ; CODE XREF: sub_41A120+319j
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EC2h], 1
    jnz     short loc_41A48A
    push    offset aBlast                   ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A48A
    push    1
    push    eax
    push    esi
    call    sub_4A1200
    pop     edi
    pop     esi
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41A471:                             ; CODE XREF: sub_41A120+2F0j
    push    offset aBlast                   ; char *
    push    ebp                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41A48A
    push    0
    push    eax
    push    esi
    call    sub_4A03F0

    loc_41A48A:                             ; CODE XREF: sub_41A120+330j
                                            ; sub_41A120+340j ...
    pop     edi
    pop     esi
    pop     ebp
    retn    4
    sub_41A120 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41A490 proc near                    ; CODE XREF: sub_41AA00+1BDp

    var_20= byte ptr -20h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    sub     esp, 20h
    mov     cx, [edx+37E9Ch]
    mov     eax, ecx
    push    ebx
    shl     eax, 3
    push    ebp
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    push    esi
    lea     esi, [edx+2C76h]
    mov     edx, [esp+2Ch+arg_0]
    lea     eax, [eax+eax*4]
    push    edi
    mov     ebx, [edx+60h]
    mov     edi, [esp+30h+arg_4]
    lea     ebp, [ecx+eax*8]
    lea     eax, [esp+30h+var_20]
    push    ebx                             ; int
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_49FED0
    lea     ecx, [esp+30h+var_20]
    push    offset aMoveord                 ; char *
    push    ecx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      loc_41A5C9
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+37EC0h]
    and     eax, 7
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_41A5AA                      ; default
    jmp     ds:off_41A900[eax*4]            ; switch jump

    loc_41A50F:                             ; DATA XREF: .text:0041A900o
    push    0                               ; case 0x0
    push    1
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aStanding_mov_0          ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37EC0h]
    and     ecx, 0FFF9h
    or      ecx, 1
    mov     [eax+37EC0h], cx
    jmp     short loc_41A5AA                ; default
    ; ---------------------------------------------------------------------------

    loc_41A548:                             ; CODE XREF: sub_41A490+78j
                                            ; DATA XREF: .text:0041A900o
    push    0                               ; case 0x1
    push    2
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aStanding_mov_0          ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+37EC0h]
    and     edx, 0FFFAh
    or      edx, 2
    mov     [eax+37EC0h], dx
    jmp     short loc_41A5AA                ; default
    ; ---------------------------------------------------------------------------

    loc_41A581:                             ; CODE XREF: sub_41A490+78j
                                            ; DATA XREF: .text:0041A900o
    push    0                               ; case 0x2
    push    0
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aStanding_mov_0          ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EC0h], 0FFF8h

    loc_41A5AA:                             ; CODE XREF: sub_41A490+72j
                                            ; sub_41A490+B6j ...
    push    0                               ; default
    push    offset aSetmoveorders           ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37EC0h]
    and     ecx, 7
    jmp     loc_41A8B3
    ; ---------------------------------------------------------------------------

    loc_41A5C9:                             ; CODE XREF: sub_41A490+5Aj
    lea     edx, [esp+30h+var_20]
    push    ebx                             ; int
    push    edx                             ; char *
    push    edi                             ; int
    call    sub_49FED0
    lea     eax, [esp+30h+var_20]
    push    offset aFireord                 ; char *
    push    eax                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      loc_41A6D1
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37EBEh]
    shr     eax, 0Ch
    and     eax, 7
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_41A6AD                      ; default
    jmp     ds:off_41A910[eax*4]            ; switch jump

    loc_41A612:                             ; DATA XREF: .text:0041A910o
    push    0                               ; case 0x0
    push    1
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aStanding_fir_0          ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+37EBEh]
    and     edx, 9FFFh
    or      dh, 10h
    mov     [eax+37EBEh], dx
    jmp     short loc_41A6AD                ; default
    ; ---------------------------------------------------------------------------

    loc_41A64B:                             ; CODE XREF: sub_41A490+17Bj
                                            ; DATA XREF: .text:0041A910o
    push    0                               ; case 0x1
    push    2
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aStanding_fir_0          ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37EBEh]
    and     ecx, 0AFFFh
    or      ch, 20h
    mov     [eax+37EBEh], cx
    jmp     short loc_41A6AD                ; default
    ; ---------------------------------------------------------------------------

    loc_41A684:                             ; CODE XREF: sub_41A490+17Bj
                                            ; DATA XREF: .text:0041A910o
    push    0                               ; case 0x2
    push    0
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aStanding_fir_0          ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 8FFFh

    loc_41A6AD:                             ; CODE XREF: sub_41A490+175j
                                            ; sub_41A490+1B9j ...
    push    0                               ; default
    push    offset aSetfireorders           ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+37EBEh]
    shr     edx, 0Ch
    and     edx, 7
    push    edx
    jmp     loc_41A8B4
    ; ---------------------------------------------------------------------------

    loc_41A6D1:                             ; CODE XREF: sub_41A490+159j
    lea     eax, [esp+30h+var_20]
    push    ebx                             ; int
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_49FED0
    lea     ecx, [esp+30h+var_20]
    push    offset aStatus_0                ; char *
    push    ecx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jnz     loc_41A7DB
    lea     edx, [esp+30h+var_20]
    push    ebx                             ; int
    push    edx                             ; char *
    push    edi                             ; int
    call    sub_49FED0
    lea     eax, [esp+30h+var_20]
    push    offset aOnoff                   ; char *
    push    eax                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jnz     loc_41A7DB
    lea     ecx, [esp+30h+var_20]
    push    ebx                             ; int
    push    ecx                             ; char *
    push    edi                             ; int
    call    sub_49FED0
    lea     edx, [esp+30h+var_20]
    push    offset aCloak                   ; char *
    push    edx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      loc_41A7CF
    mov     eax, TAdynmemStructPtr
    push    0
    push    0
    push    0
    mov     cl, [eax+37EC0h]
    push    ecx
    test    cl, 18h
    mov     ecx, esp
    jz      short loc_41A77E
    push    offset aCloak_off               ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EC0h], 0FFE7h
    jmp     short loc_41A7AC
    ; ---------------------------------------------------------------------------

    loc_41A77E:                             ; CODE XREF: sub_41A490+2CAj
    push    offset aCloak_on                ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37EC0h]
    and     ecx, 0FFEFh
    or      ecx, 8
    mov     [eax+37EC0h], cx

    loc_41A7AC:                             ; CODE XREF: sub_41A490+2ECj
    push    0                               ; int
    push    offset aSpecialorders           ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37EC0h]
    shr     edx, 3
    and     edx, 3
    push    edx
    jmp     loc_41A8B4
    ; ---------------------------------------------------------------------------

    loc_41A7CF:                             ; CODE XREF: sub_41A490+2ADj
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_41A7DB:                             ; CODE XREF: sub_41A490+261j
                                            ; sub_41A490+287j
    mov     eax, TAdynmemStructPtr
    mov     al, [eax+37EC0h]
    shr     eax, 5
    and     eax, 3
    sub     eax, 0
    jz      short loc_41A85F
    dec     eax
    jz      short loc_41A834
    dec     eax
    jnz     loc_41A896
    push    0
    push    0
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aActivate_0              ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37EC0h]
    and     ecx, 0FFBFh
    or      ecx, 20h
    mov     [eax+37EC0h], cx
    jmp     short loc_41A896
    ; ---------------------------------------------------------------------------

    loc_41A834:                             ; CODE XREF: sub_41A490+362j
    push    0
    push    0
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aDeactivate_0            ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EC0h], 0FF9Fh
    jmp     short loc_41A896
    ; ---------------------------------------------------------------------------

    loc_41A85F:                             ; CODE XREF: sub_41A490+35Fj
    push    0
    push    0
    push    0
    push    ecx
    mov     ecx, esp
    push    offset aActivate_0              ; char *
    call    sub_438760
    push    0
    push    esi
    call    sub_48CF30
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+37EC0h]
    and     edx, 0FFBFh
    or      edx, 20h
    mov     [eax+37EC0h], dx

    loc_41A896:                             ; CODE XREF: sub_41A490+365j
                                            ; sub_41A490+3A2j ...
    push    0                               ; int
    push    offset aSpecialorders           ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37EC0h]
    shr     ecx, 5
    and     ecx, 3

    loc_41A8B3:                             ; CODE XREF: sub_41A490+134j
    push    ecx

    loc_41A8B4:                             ; CODE XREF: sub_41A490+23Cj
                                            ; sub_41A490+33Aj
    add     eax, 519h
    push    ebx
    push    eax
    call    sub_4A11C0
    mov     edx, TAdynmemStructPtr
    mov     ax, [edx+37E9Ch]
    neg     ax
    sbb     eax, eax
    and     eax, ebp
    push    eax
    call    sub_41A120
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 20h
    retn    8
    sub_41A490 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_41A900 dd offset loc_41A50F         ; DATA XREF: sub_41A490+78r
    dd offset loc_41A548                    ; jump table for switch statement
    dd offset loc_41A581
    dd offset loc_41A581
    off_41A910 dd offset loc_41A612         ; DATA XREF: sub_41A490+17Br
    dd offset loc_41A64B                    ; jump table for switch statement
    dd offset loc_41A684
    dd offset loc_41A684
    ; ---------------------------------------------------------------------------
    sub     esp, 100h
    push    esi
    mov     esi, [esp+108h]
    mov     eax, [esi+92h]
    cmp     byte ptr [eax+22Eh], 2
    jnb     loc_41A9EB
    mov     ecx, [esi+96h]
    mov     edx, [ecx+27h]
    xor     ecx, ecx
    mov     cl, [edx+95h]
    mov     edx, TAdynmemStructPtr
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    lea     eax, [edx+ecx*2+37F5Bh]
    lea     ecx, [esp+4]
    push    eax
    push    offset aSprev                   ; "%sPREV"
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+4]
    add     eax, 519h
    push    0
    push    edx
    push    eax
    call    sub_4A0570
    mov     ecx, [esi+96h]
    mov     edx, [ecx+27h]
    xor     ecx, ecx
    mov     cl, [edx+95h]
    mov     edx, TAdynmemStructPtr
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    lea     eax, [edx+ecx*2+37F5Bh]
    lea     ecx, [esp+4]
    push    eax
    push    offset aSnext                   ; "%sNEXT"
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+4]
    add     eax, 519h
    push    0
    push    edx
    push    eax
    call    sub_4A0570

    loc_41A9EB:                             ; CODE XREF: .text:0041A93Bj
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41AA00 proc near                    ; DATA XREF: sub_41ACE0+10Ao
                                            ; sub_41B0F0+81o

    var_134= byte ptr -134h
    var_124= byte ptr -124h
    var_120= byte ptr -120h
    var_100= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 134h
    push    edi
    mov     edi, [esp+138h+arg_0]
    mov     eax, [edi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      loc_41AC7C
    mov     ecx, [edi+18h]
    push    esi
    push    ebp
    push    ebx
    mov     esi, [ecx+4]
    lea     edx, [esp+144h+var_134]
    push    eax                             ; int
    push    edx                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     eax, [esp+144h+var_134]
    mov     [esp+144h+var_124], 0
    push    eax                             ; char *
    call    sub_488B10
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     ebx, eax
    mov     cx, [edx+37E9Ch]
    mov     edx, [edx+14357h]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, [edi+60h]
    push    eax                             ; int
    lea     ebp, [edx+ecx*8]
    lea     ecx, [esp+148h+var_120]
    push    ecx                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    lea     edx, [esp+144h+var_120]
    push    offset aPrev                    ; char *
    push    edx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_41AAA6
    mov     eax, TAdynmemStructPtr
    push    edi
    or      byte ptr [eax+37EBFh], 1
    call    sub_4AB0A0
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi
    add     esp, 134h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41AAA6:                             ; CODE XREF: sub_41AA00+85j
    lea     eax, [esp+144h+var_120]
    push    offset aNext                    ; char *
    push    eax                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_41AADB
    mov     eax, TAdynmemStructPtr
    push    edi
    or      byte ptr [eax+37EBEh], 80h
    call    sub_4AB0A0
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi
    add     esp, 134h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41AADB:                             ; CODE XREF: sub_41AA00+BAj
    lea     ecx, [esp+144h+var_120]
    push    offset aOrders                  ; char *
    push    ecx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_41AB1C
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aOrdersbutton            ; char *
    or      byte ptr [eax+37EBFh], 2
    call    sub_47F1A0
    push    edi
    call    sub_4AB0A0
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi
    add     esp, 134h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41AB1C:                             ; CODE XREF: sub_41AA00+EFj
    lea     edx, [esp+144h+var_120]
    push    offset aBuild                   ; char *
    push    edx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      short loc_41AB5D
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aBuildbutton             ; char *
    or      byte ptr [eax+37EBFh], 4
    call    sub_47F1A0
    push    edi
    call    sub_4AB0A0
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi
    add     esp, 134h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41AB5D:                             ; CODE XREF: sub_41AA00+130j
    test    bx, bx
    jz      short loc_41ABBB
    mov     ecx, ebx
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+1439Bh]
    cmp     byte ptr [ecx+edx+22Fh], 0
    jnz     short loc_41ABBB
    mov     byte ptr [eax+2CC3h], 0Eh
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aAddbuild                ; char *
    mov     [eax+TAdynmemStruct.BuildNum], bx
    call    sub_47F1A0
    push    edi
    call    sub_4AB0A0
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi
    add     esp, 134h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41ABBB:                             ; CODE XREF: sub_41AA00+160j
                                            ; sub_41AA00+187j
    push    esi
    push    edi
    call    sub_41A490
    test    eax, eax
    jnz     loc_41AC73
    push    esi
    push    edi
    call    sub_419BE0
    test    eax, eax
    jnz     loc_41AC73
    mov     ecx, [ebp+110h]
    shr     ecx, 4
    test    cl, 1
    jz      loc_41AC73
    mov     edx, [edi+60h]
    lea     eax, [esp+144h+var_100]
    push    edx                             ; int
    push    eax                             ; char *
    push    esi                             ; int
    call    sub_49FED0
    push    0F9h
    call    sub_4C1B80
    test    eax, eax
    push    edi
    jz      short loc_41AC21
    call    sub_4AB6B0
    cmp     eax, 1
    jnz     short loc_41AC17
    push    5
    jmp     short loc_41AC36
    ; ---------------------------------------------------------------------------

    loc_41AC17:                             ; CODE XREF: sub_41AA00+211j
    push    0FFFFFFFBh
    lea     edx, [esp+148h+var_100]
    push    ebp
    push    edx
    jmp     short loc_41AC3C
    ; ---------------------------------------------------------------------------

    loc_41AC21:                             ; CODE XREF: sub_41AA00+207j
    call    sub_4AB6B0
    cmp     eax, 1
    jnz     short loc_41AC34
    push    eax
    lea     eax, [esp+148h+var_100]
    push    ebp
    push    eax
    jmp     short loc_41AC3C
    ; ---------------------------------------------------------------------------

    loc_41AC34:                             ; CODE XREF: sub_41AA00+229j
    push    0FFFFFFFFh                      ; int

    loc_41AC36:                             ; CODE XREF: sub_41AA00+215j
    lea     ecx, [esp+148h+var_100]
    push    ebp                             ; int
    push    ecx                             ; char *

    loc_41AC3C:                             ; CODE XREF: sub_41AA00+21Fj
                                            ; sub_41AA00+232j
    call    sub_419B00
    test    dword ptr [ebp+110h], 20000000h
    jnz     short loc_41AC5C
    mov     edx, [ebp+10h]
    test    dword ptr [edx+111h], 10000000h
    jz      short loc_41AC63

    loc_41AC5C:                             ; CODE XREF: sub_41AA00+24Bj
    push    ebp
    push    edi
    call    sub_4199B0

    loc_41AC63:                             ; CODE XREF: sub_41AA00+25Aj
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90

    loc_41AC73:                             ; CODE XREF: sub_41AA00+1C4j
                                            ; sub_41AA00+1D3j ...
    push    edi
    call    sub_4AB0A0
    pop     ebx
    pop     ebp
    pop     esi

    loc_41AC7C:                             ; CODE XREF: sub_41AA00+14j
    pop     edi
    add     esp, 134h
    retn    4
    sub_41AA00 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    mov     ebx, [esp+8]
    push    ebp
    push    esi
    mov     eax, [ebx+18h]
    xor     esi, esi
    mov     eax, [eax+4]
    movsx   ebp, word ptr [eax+0B6h]
    test    ebp, ebp
    jle     short loc_41ACD4
    push    edi
    lea     edi, [eax+2]

    loc_41ACAE:                             ; CODE XREF: .text:0041ACD1j
    test    byte ptr [edi+28h], 4
    jz      short loc_41ACC8
    push    edi
    call    sub_488B10
    neg     ax
    sbb     eax, eax
    inc     eax
    push    eax
    push    esi
    push    ebx
    call    sub_4A1200

    loc_41ACC8:                             ; CODE XREF: .text:0041ACB2j
    inc     esi
    add     edi, 15Bh
    cmp     esi, ebp
    jl      short loc_41ACAE
    pop     edi

    loc_41ACD4:                             ; CODE XREF: .text:0041ACA8j
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41ACE0 proc near                    ; CODE XREF: sub_41B2E0+55Ap

    var_310= dword ptr -310h
    var_30C= dword ptr -30Ch
    var_308= dword ptr -308h
    var_304= dword ptr -304h
    var_300= byte ptr -300h
    var_200= dword ptr -200h
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 310h
    push    ebx
    push    ebp
    mov     ebp, [esp+318h+arg_0]
    push    esi
    push    edi
    fld     dword ptr [ebp+104h]
    fcomp   ds:flt_4FCC88
    fnstsw  ax
    test    ah, 40h
    jz      loc_41B0D9
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     edi, [esp+320h+arg_4]
    push    offset off_502828
    mov     dl, [ecx+2A42h]
    push    edi
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    push    offset aGuis                    ; "guis"
    mov     [esp+32Ch+var_310], 0
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*2+1B63h]
    lea     ecx, [esp+32Ch+var_100]
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+320h+var_100]
    push    edx
    call    sub_4BBC40
    test    eax, eax
    jnz     short loc_41AD9E
    mov     eax, [esi+27h]
    xor     ecx, ecx
    mov     cl, [eax+95h]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*4]
    lea     eax, [ecx+edx*8]
    mov     ecx, TAdynmemStructPtr
    lea     edx, [ecx+eax*2+37F5Bh]
    lea     eax, [esp+320h+var_200]
    push    edx
    push    offset aSdl                     ; "%sDL"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    jmp     short loc_41ADC2
    ; ---------------------------------------------------------------------------

    loc_41AD9E:                             ; CODE XREF: sub_41ACE0+7Fj
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+320h+var_200]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_41ADC2:                             ; CODE XREF: sub_41ACE0+BCj
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+320h+var_200]
    push    0
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AA8F0
    mov     ebx, eax
    xor     edi, edi
    cmp     ebx, edi
    jz      loc_41B0D9
    mov     dword ptr [ebx+8], offset sub_41AA00
    mov     [ebx+0Ch], edi
    mov     eax, TAdynmemStructPtr
    mov     [esp+320h+var_304], edi
    cmp     [eax+391C7h], edi
    jle     loc_41AF05
    xor     esi, esi
    mov     [esp+320h+var_308], esi

    loc_41AE0F:                             ; CODE XREF: sub_41ACE0+21Fj
    mov     ecx, [eax+391CBh]
    mov     [esp+320h+var_30C], edi
    cmp     [esi+ecx], edi
    jle     loc_41AEE4
    mov     ebp, esi

    loc_41AE24:                             ; CODE XREF: sub_41ACE0+1F5j
    mov     edx, [esp+320h+arg_0]
    mov     edx, [edx+92h]
    mov     dx, [edx+21Eh]
    cmp     dx, [ebp+ecx+4]
    jnz     short loc_41AEBA
    mov     esi, [esp+320h+arg_8]
    xor     edx, edx
    mov     dl, [ebp+ecx+6]
    dec     edx
    cmp     edx, esi
    jnz     short loc_41AEBA
    xor     eax, eax
    lea     edi, [ebp+ecx+8]
    mov     al, [ebp+ecx+7]
    or      ecx, 0FFFFFFFFh
    add     eax, 4
    lea     edx, [eax+eax*4]
    lea     edx, [eax+edx*4]
    lea     edx, [eax+edx*2]
    lea     edx, [eax+edx*4]
    lea     eax, [eax+edx*2]
    mov     edx, [ebx+4]
    add     edx, eax
    xor     eax, eax
    and     word ptr [edx+13Ch], 0FFFEh
    mov     byte ptr [edx+2Ah], 4
    repne scasb
    not     ecx
    lea     esi, [edx+2]
    sub     edi, ecx
    mov     eax, ecx
    mov     [esp+320h+var_310], esi
    mov     esi, edi
    mov     edi, [esp+320h+var_310]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, 1
    and     ecx, 3
    mov     [esp+320h+var_310], eax
    rep movsb
    or      [edx+0B4h], ax
    mov     eax, TAdynmemStructPtr

    loc_41AEBA:                             ; CODE XREF: sub_41ACE0+15Dj
                                            ; sub_41ACE0+16Fj
    mov     ecx, [eax+391CBh]
    mov     esi, [esp+320h+var_308]
    mov     edx, [esp+320h+var_30C]
    add     ebp, 25h
    mov     edi, [esi+ecx]
    inc     edx
    cmp     edx, edi
    mov     [esp+320h+var_30C], edx
    jl      loc_41AE24
    mov     ebp, [esp+320h+arg_0]
    xor     edi, edi

    loc_41AEE4:                             ; CODE XREF: sub_41ACE0+13Cj
    mov     ecx, [esp+320h+var_304]
    mov     edx, [eax+391C7h]
    inc     ecx
    add     esi, 0BDh
    cmp     ecx, edx
    mov     [esp+320h+var_304], ecx
    mov     [esp+320h+var_308], esi
    jl      loc_41AE0F

    loc_41AF05:                             ; CODE XREF: sub_41ACE0+123j
    cmp     [esp+320h+var_310], edi
    jz      short loc_41AF31
    add     eax, 519h
    push    2
    push    eax
    call    sub_4A81E0
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    mov     eax, TAdynmemStructPtr

    loc_41AF31:                             ; CODE XREF: sub_41ACE0+229j
    mov     edx, [ebp+92h]
    cmp     byte ptr [edx+22Eh], 2
    jnb     loc_41AFE6
    mov     ecx, [ebp+96h]
    mov     edx, [ecx+27h]
    xor     ecx, ecx
    mov     cl, [edx+95h]
    mov     edx, ecx
    shl     ecx, 3
    sub     ecx, edx
    lea     ecx, [ecx+ecx*4]
    lea     edx, [edx+ecx*8]
    lea     ecx, [esp+320h+var_300]
    lea     eax, [eax+edx*2+37F5Bh]
    push    eax
    push    offset aSprev                   ; "%sPREV"
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+320h+var_300]
    add     eax, 519h
    push    edi                             ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, [ebp+96h]
    mov     edx, [ecx+27h]
    xor     ecx, ecx
    mov     cl, [edx+95h]
    mov     edx, TAdynmemStructPtr
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    lea     eax, [edx+ecx*2+37F5Bh]
    lea     ecx, [esp+320h+var_300]
    push    eax
    push    offset aSnext                   ; "%sNEXT"
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+320h+var_300]
    add     eax, 519h
    push    edi                             ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570

    loc_41AFE6:                             ; CODE XREF: sub_41ACE0+25Ej
    push    ebp
    call    sub_41A120
    mov     ecx, TAdynmemStructPtr
    push    ebp
    add     ecx, 519h
    push    ecx
    call    sub_4199B0
    test    dword ptr [ebp+110h], 20000000h
    jz      short loc_41B045
    mov     edx, TAdynmemStructPtr
    push    offset aOnoff                   ; char *
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41B045
    mov     dl, [ebp+10Eh]
    and     edx, 1
    push    edx
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A11C0

    loc_41B045:                             ; CODE XREF: sub_41ACE0+329j
                                            ; sub_41ACE0+348j
    cmp     [esp+320h+arg_8], edi
    jz      short loc_41B09F
    mov     ecx, TAdynmemStructPtr
    xor     esi, esi
    mov     edx, [ecx+531h]
    lea     ebx, [ecx+519h]
    mov     edi, [edx+4]
    movsx   ebp, word ptr [edi+0B6h]
    test    ebp, ebp
    jle     short loc_41B098
    add     edi, 2

    loc_41B073:                             ; CODE XREF: sub_41ACE0+3B6j
    test    byte ptr [edi+28h], 4
    jz      short loc_41B08D
    push    edi                             ; char *
    call    sub_488B10
    neg     ax
    sbb     eax, eax
    inc     eax
    push    eax
    push    esi
    push    ebx
    call    sub_4A1200

    loc_41B08D:                             ; CODE XREF: sub_41ACE0+397j
    inc     esi
    add     edi, 15Bh
    cmp     esi, ebp
    jl      short loc_41B073

    loc_41B098:                             ; CODE XREF: sub_41ACE0+38Ej
    mov     ebp, [esp+320h+arg_0]

    loc_41B09F:                             ; CODE XREF: sub_41ACE0+36Cj
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    mov     edx, TAdynmemStructPtr
    mov     cx, [ebp+0A8h]
    mov     [edx+37E9Ch], cx
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ebp+0A6h]
    mov     [ecx+37E9Eh], ax

    loc_41B0D9:                             ; CODE XREF: sub_41ACE0+22j
                                            ; sub_41ACE0+104j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 310h
    retn    0Ch
    sub_41ACE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41B0F0 proc near                    ; CODE XREF: sub_41B2E0+591p
                                            ; sub_41B2E0+5A3p

    var_100= dword ptr -100h
    arg_0= dword ptr  4

    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    sub     esp, 100h
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    push    esi
    shl     eax, 5
    add     eax, ecx
    mov     esi, edx
    add     esi, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B8Ah]
    xor     eax, eax
    mov     al, [ecx+95h]
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    lea     eax, [esp+104h+var_100]
    lea     edx, [edx+ecx*2+37F5Bh]
    push    edx
    push    offset aSgen_gui                ; "%sGEN.GUI"
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+104h+var_100]
    add     edx, 519h
    push    0
    push    ecx
    push    edx
    call    sub_4AA8F0
    test    eax, eax
    jz      loc_41B1EA
    mov     esi, [esp+104h+arg_0]
    mov     dword ptr [eax+8], offset sub_41AA00
    push    esi
    mov     dword ptr [eax+0Ch], 0
    call    sub_41A120
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    test    esi, esi
    jz      short loc_41B1CD
    mov     edx, TAdynmemStructPtr
    mov     cx, [esi+0A8h]
    mov     [edx+37E9Ch], cx
    mov     ecx, TAdynmemStructPtr
    mov     ax, [esi+0A6h]
    mov     [ecx+37E9Eh], ax
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41B1CD:                             ; CODE XREF: sub_41B0F0+A9j
    mov     edx, TAdynmemStructPtr
    mov     word ptr [edx+37E9Ch], 0
    mov     eax, TAdynmemStructPtr
    mov     word ptr [eax+37E9Eh], 0

    loc_41B1EA:                             ; CODE XREF: sub_41B0F0+74j
    pop     esi
    add     esp, 100h
    retn    4
    sub_41B0F0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     eax, [eax+110h]
    mov     ecx, eax
    shr     ecx, 16h
    test    cl, 1
    jz      short loc_41B21D
    shr     eax, 17h
    and     eax, 7
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41B21D:                             ; CODE XREF: .text:0041B212j
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 100h
    mov     ecx, [esp+108h]
    push    20h
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1439Bh]
    lea     eax, [eax+eax*8]
    lea     ecx, [esp+4]
    lea     eax, [eax+edx+20h]
    push    eax
    push    ecx
    call    _strncpy
    mov     edx, [esp+118h]
    mov     ecx, [esp+110h]
    add     esp, 0Ch
    lea     eax, [esp+0]
    mov     byte ptr [esp+1Fh], 0
    push    edx
    push    eax
    push    offset aSD_gui                  ; "%s%d.GUI"
    push    ecx
    call    _sprintf
    add     esp, 10h
    add     esp, 100h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, TAdynmemStructPtr
    mov     ax, [edx+37E9Ch]
    test    ax, ax
    jz      short loc_41B2D5
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*8+0A6h], 0
    lea     eax, [ecx+eax*8]
    jnz     short locret_41B2D7

    loc_41B2D5:                             ; CODE XREF: .text:0041B2B0j
    xor     eax, eax

    locret_41B2D7:                          ; CODE XREF: .text:0041B2D3j
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41B2E0 proc near                    ; CODE XREF: sub_496790+224p

    var_240= dword ptr -240h
    var_23C= dword ptr -23Ch
    var_238= dword ptr -238h
    var_234= dword ptr -234h
    var_230= dword ptr -230h
    var_22C= dword ptr -22Ch
    var_228= dword ptr -228h
    var_224= dword ptr -224h
    var_220= dword ptr -220h
    var_21C= dword ptr -21Ch
    var_218= dword ptr -218h
    var_214= dword ptr -214h
    var_210= dword ptr -210h
    var_20C= dword ptr -20Ch
    var_208= dword ptr -208h
    var_204= dword ptr -204h
    var_200= byte ptr -200h
    var_1E1= byte ptr -1E1h
    var_100= byte ptr -100h

    sub     esp, 240h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    or      byte ptr [eax+37EBEh], 2
    push    edi
    mov     edi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     eax, 3
    mov     esi, edi
    mov     cl, [edi+2A42h]
    mov     [esp+250h+var_238], eax
    mov     [esp+250h+var_240], eax
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    mov     ebx, 4
    xor     ebp, ebp
    lea     eax, [eax+eax*4]
    mov     edx, ebx
    mov     [esp+250h+var_22C], ebp
    mov     [esp+250h+var_220], ebp
    lea     ecx, [esi+eax*2+1B63h]
    mov     ax, [edi+37E9Ch]
    xor     esi, esi
    mov     [esp+250h+var_218], ebp
    cmp     ax, si
    mov     [esp+250h+var_20C], ebp
    mov     [esp+250h+var_228], ebp
    mov     [esp+250h+var_21C], ebp
    mov     [esp+250h+var_224], ebp
    mov     [esp+250h+var_214], ebp
    mov     [esp+250h+var_210], ebp
    jz      short loc_41B3A6
    and     eax, 0FFFFh
    mov     edx, [edi+14357h]
    mov     ecx, eax
    mov     ebx, 1
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*4]
    cmp     [edx+ecx*8+0A6h], si
    lea     eax, [edx+ecx*8]
    jnz     short loc_41B38A
    xor     eax, eax

    loc_41B38A:                             ; CODE XREF: sub_41B2E0+A6j
    cmp     eax, esi
    mov     ebp, eax
    jnz     loc_41B749
    mov     [edi+37E9Ch], si
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 240h
    retn
    ; ---------------------------------------------------------------------------

    loc_41B3A6:                             ; CODE XREF: sub_41B2E0+7Fj
    mov     [esp+250h+var_234], esi
    mov     [esp+250h+var_230], esi
    mov     esi, [ecx+6Bh]
    mov     ecx, [ecx+67h]
    cmp     ecx, esi
    mov     [esp+250h+var_204], esi
    mov     [esp+250h+var_23C], ecx
    ja      loc_41B54D

    loc_41B3C4:                             ; CODE XREF: sub_41B2E0+267j
    cmp     word ptr [ecx+0A6h], 0
    jz      loc_41B53B
    mov     eax, [ecx+110h]
    test    al, 10h
    mov     [esp+250h+var_208], eax
    jz      loc_41B53B
    mov     esi, [esp+250h+var_234]
    test    esi, esi
    jnz     short loc_41B3F0
    mov     [esp+250h+var_234], ecx

    loc_41B3F0:                             ; CODE XREF: sub_41B2E0+10Aj
    mov     esi, [ecx+92h]
    mov     edi, [esi+245h]
    mov     ecx, edi
    shr     ecx, 1
    test    cl, 1
    jz      short loc_41B425
    cmp     ebx, 4
    jnz     short loc_41B414
    mov     ebx, eax
    shr     ebx, 14h
    and     ebx, 3
    jmp     short loc_41B425
    ; ---------------------------------------------------------------------------

    loc_41B414:                             ; CODE XREF: sub_41B2E0+128j
    mov     ecx, eax
    shr     ecx, 14h
    and     ecx, 3
    cmp     ebx, ecx
    jz      short loc_41B425
    mov     ebx, 3

    loc_41B425:                             ; CODE XREF: sub_41B2E0+123j
                                            ; sub_41B2E0+132j ...
    test    byte ptr [esi+245h], 1
    jz      short loc_41B44E
    cmp     edx, 4
    jnz     short loc_41B43D
    mov     edx, eax
    shr     edx, 12h
    and     edx, 3
    jmp     short loc_41B44E
    ; ---------------------------------------------------------------------------

    loc_41B43D:                             ; CODE XREF: sub_41B2E0+151j
    mov     ecx, eax
    shr     ecx, 12h
    and     ecx, 3
    cmp     edx, ecx
    jz      short loc_41B44E
    mov     edx, 3

    loc_41B44E:                             ; CODE XREF: sub_41B2E0+14Cj
                                            ; sub_41B2E0+15Bj ...
    mov     ecx, edi
    shr     ecx, 2
    test    cl, 1
    jz      short loc_41B476
    mov     esi, [esp+250h+var_240]
    cmp     esi, 3
    jnz     loc_41B893
    mov     ecx, [esp+250h+var_23C]
    mov     cl, [ecx+10Eh]
    and     ecx, 1
    mov     [esp+250h+var_240], ecx

    loc_41B476:                             ; CODE XREF: sub_41B2E0+176j
    mov     esi, 1

    loc_41B47B:                             ; CODE XREF: sub_41B2E0+5D5j
                                            ; sub_41B2E0+5E3j
    mov     ecx, edi
    shr     ecx, 0Dh
    test    cl, 1
    jz      short loc_41B49F
    cmp     [esp+250h+var_238], 3
    jnz     short loc_41B497
    shr     eax, 0Bh
    and     eax, esi
    mov     [esp+250h+var_238], eax
    jmp     short loc_41B49F
    ; ---------------------------------------------------------------------------

    loc_41B497:                             ; CODE XREF: sub_41B2E0+1AAj
    mov     [esp+250h+var_238], 2

    loc_41B49F:                             ; CODE XREF: sub_41B2E0+1A3j
                                            ; sub_41B2E0+1B5j
    mov     eax, edi
    shr     eax, 7
    test    al, 1
    jz      short loc_41B4AC
    mov     [esp+250h+var_22C], esi

    loc_41B4AC:                             ; CODE XREF: sub_41B2E0+1C6j
    mov     ecx, edi
    shr     ecx, 3
    test    cl, 1
    jz      short loc_41B4BA
    mov     [esp+250h+var_210], esi

    loc_41B4BA:                             ; CODE XREF: sub_41B2E0+1D4j
    mov     eax, edi
    shr     eax, 4
    test    al, 1
    jz      short loc_41B4C7
    mov     [esp+250h+var_220], esi

    loc_41B4C7:                             ; CODE XREF: sub_41B2E0+1E1j
    mov     ecx, edi
    shr     ecx, 5
    test    cl, 1
    jz      short loc_41B4D5
    mov     [esp+250h+var_218], esi

    loc_41B4D5:                             ; CODE XREF: sub_41B2E0+1EFj
    mov     eax, edi
    shr     eax, 6
    test    al, 1
    jz      short loc_41B4E2
    mov     [esp+250h+var_20C], esi

    loc_41B4E2:                             ; CODE XREF: sub_41B2E0+1FCj
    mov     ecx, edi
    shr     ecx, 8
    test    cl, 1
    jz      short loc_41B4F0
    mov     [esp+250h+var_228], esi

    loc_41B4F0:                             ; CODE XREF: sub_41B2E0+20Aj
    mov     eax, edi
    shr     eax, 9
    test    al, 1
    jz      short loc_41B4FB
    mov     ebp, esi

    loc_41B4FB:                             ; CODE XREF: sub_41B2E0+217j
    mov     ecx, edi
    shr     ecx, 0Ch
    test    cl, 1
    jz      short loc_41B509
    mov     [esp+250h+var_21C], esi

    loc_41B509:                             ; CODE XREF: sub_41B2E0+223j
    mov     eax, edi
    shr     eax, 0Ah
    test    al, 1
    jz      short loc_41B516
    mov     [esp+250h+var_224], esi

    loc_41B516:                             ; CODE XREF: sub_41B2E0+230j
    mov     ecx, edi
    shr     ecx, 0Eh
    test    cl, 1
    jz      short loc_41B524
    mov     [esp+250h+var_214], esi

    loc_41B524:                             ; CODE XREF: sub_41B2E0+23Ej
    mov     eax, [esp+250h+var_230]
    mov     edi, TAdynmemStructPtr
    mov     ecx, [esp+250h+var_23C]
    mov     esi, [esp+250h+var_204]
    inc     eax
    mov     [esp+250h+var_230], eax

    loc_41B53B:                             ; CODE XREF: sub_41B2E0+ECj
                                            ; sub_41B2E0+FEj
    add     ecx, 118h
    cmp     ecx, esi
    mov     [esp+250h+var_23C], ecx
    jbe     loc_41B3C4

    loc_41B54D:                             ; CODE XREF: sub_41B2E0+DEj
    mov     ax, [edi+37EBEh]
    and     ebx, 7
    and     eax, 8FFFh
    shl     ebx, 0Ch
    or      ebx, eax
    mov     [edi+37EBEh], bx
    mov     ecx, TAdynmemStructPtr
    shl     ebp, 0Fh
    mov     ax, [ecx+37EC0h]
    xor     dl, al
    and     edx, 7
    xor     edx, eax
    mov     eax, [esp+250h+var_238]
    mov     [ecx+37EC0h], dx
    mov     ecx, TAdynmemStructPtr
    and     eax, 3
    mov     dx, [ecx+37EC0h]
    and     edx, 0FFE7h
    shl     eax, 3
    or      edx, eax
    mov     eax, [esp+250h+var_240]
    mov     [ecx+37EC0h], dx
    mov     ecx, TAdynmemStructPtr
    and     eax, 3
    mov     dx, [ecx+37EC0h]
    and     edx, 0FF9Fh
    shl     eax, 5
    or      edx, eax
    mov     al, byte ptr [esp+250h+var_210]
    mov     [ecx+37EC0h], dx
    mov     ecx, TAdynmemStructPtr
    and     al, 1
    xor     edx, edx
    mov     dh, al
    mov     ax, [ecx+37EC0h]
    and     eax, 0FEFFh
    or      edx, eax
    mov     eax, [esp+250h+var_220]
    mov     [ecx+37EC0h], dx
    mov     ecx, TAdynmemStructPtr
    and     eax, 1
    mov     dx, [ecx+37EC0h]
    and     edx, 0FDFFh
    shl     eax, 9
    or      edx, eax
    mov     eax, [esp+250h+var_22C]
    mov     [ecx+37EC0h], dx
    mov     ecx, TAdynmemStructPtr
    and     eax, 1
    mov     dx, [ecx+37EC0h]
    and     edx, 0FF7Fh
    shl     eax, 7
    or      edx, eax
    mov     eax, [esp+250h+var_218]
    mov     [ecx+37EC0h], dx
    mov     ecx, TAdynmemStructPtr
    and     eax, 1
    mov     dx, [ecx+37EC0h]
    shl     eax, 0Ah
    and     edx, 0FBFFh
    or      eax, edx
    mov     [ecx+37EC0h], ax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+250h+var_20C]
    mov     dx, [ecx+37EC0h]
    and     eax, 1
    shl     eax, 0Bh
    and     edx, 0F7FFh
    or      eax, edx
    mov     [ecx+37EC0h], ax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+250h+var_228]
    mov     dx, [ecx+37EC0h]
    and     eax, 1
    shl     eax, 0Ch
    and     edx, 0EFFFh
    or      eax, edx
    mov     [ecx+37EC0h], ax
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37EC0h]
    and     ecx, 7FFFh
    or      ebp, ecx
    mov     ebx, [esp+250h+var_230]
    mov     [eax+37EC0h], bp
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+250h+var_224]
    mov     ebp, [esp+250h+var_234]
    mov     dx, [ecx+37EC0h]
    and     eax, 1
    shl     eax, 0Dh
    and     edx, 0DFFFh
    or      eax, edx
    mov     [ecx+37EC0h], ax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+250h+var_21C]
    mov     dx, [ecx+37EC0h]
    and     eax, 1
    shl     eax, 0Eh
    and     edx, 0BFFFh
    or      eax, edx
    mov     [ecx+37EC0h], ax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+250h+var_214]
    mov     ax, [edx+37EC2h]
    xor     cl, al
    and     ecx, 1
    xor     ecx, eax
    mov     [edx+37EC2h], cx
    mov     edi, TAdynmemStructPtr

    loc_41B749:                             ; CODE XREF: sub_41B2E0+AEj
    test    ebx, ebx
    jnz     short loc_41B758
    push    ebx
    call    sub_491D70
    jmp     loc_41B83F
    ; ---------------------------------------------------------------------------

    loc_41B758:                             ; CODE XREF: sub_41B2E0+46Bj
    cmp     ebx, 1
    jnz     loc_41B853
    mov     ecx, [ebp+92h]
    mov     al, [ecx+22Eh]
    test    al, al
    jz      loc_41B853
    mov     eax, [ebp+110h]
    mov     edx, eax
    shr     edx, 16h
    test    bl, dl
    jz      short loc_41B78E
    shr     eax, 17h
    and     eax, 7
    mov     esi, eax
    jmp     short loc_41B790
    ; ---------------------------------------------------------------------------

    loc_41B78E:                             ; CODE XREF: sub_41B2E0+4A2j
    xor     esi, esi

    loc_41B790:                             ; CODE XREF: sub_41B2E0+4ACj
    test    esi, esi
    jg      short loc_41B7A4
    test    dword ptr [ecx+241h], 80000000h
    jz      loc_41B853

    loc_41B7A4:                             ; CODE XREF: sub_41B2E0+4B2j
    xor     ecx, ecx
    push    20h                             ; size_t
    mov     cx, [ebp+0A6h]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, [edi+1439Bh]
    lea     eax, [eax+eax*8]
    lea     edx, [eax+ecx+20h]
    lea     eax, [esp+254h+var_200]
    push    edx                             ; char *
    push    eax                             ; char *
    call    _strncpy
    add     esp, 0Ch
    lea     ecx, [esp+250h+var_200]
    lea     edx, [esp+250h+var_100]
    mov     [esp+250h+var_1E1], 0
    push    esi
    push    ecx
    push    offset aSD_gui                  ; "%s%d.GUI"
    push    edx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+250h+var_100]
    add     ecx, 519h
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4AB060
    test    eax, eax
    jz      short loc_41B825
    mov     edx, TAdynmemStructPtr
    mov     ax, [edx+37E9Ch]
    cmp     ax, [ebp+0A8h]
    jz      short loc_41B83F

    loc_41B825:                             ; CODE XREF: sub_41B2E0+52Dj
    push    0
    call    sub_491D70
    test    eax, eax
    jz      short loc_41B83F
    lea     ecx, [esp+250h+var_100]
    push    esi
    push    ecx
    push    ebp
    call    sub_41ACE0

    loc_41B83F:                             ; CODE XREF: sub_41B2E0+473j
                                            ; sub_41B2E0+543j ...
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFFDh
    mov     edi, TAdynmemStructPtr

    loc_41B853:                             ; CODE XREF: sub_41B2E0+47Bj
                                            ; sub_41B2E0+48Fj ...
    mov     dl, [edi+37EBEh]
    shr     dl, 1
    test    dl, 1
    jz      short loc_41B888
    push    0
    call    sub_491D70
    test    eax, eax
    jz      short loc_41B888
    cmp     ebx, 1
    jnz     short loc_41B881
    push    ebp
    call    sub_41B0F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 240h
    retn
    ; ---------------------------------------------------------------------------

    loc_41B881:                             ; CODE XREF: sub_41B2E0+58Ej
    push    0
    call    sub_41B0F0

    loc_41B888:                             ; CODE XREF: sub_41B2E0+57Ej
                                            ; sub_41B2E0+589j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 240h
    retn
    ; ---------------------------------------------------------------------------

    loc_41B893:                             ; CODE XREF: sub_41B2E0+17Fj
    mov     eax, [esp+250h+var_23C]
    mov     cl, [eax+10Eh]
    and     ecx, 1
    cmp     esi, ecx
    jz      short loc_41B8BA
    mov     eax, [esp+250h+var_208]
    mov     [esp+250h+var_240], 2
    mov     esi, 1
    jmp     loc_41B47B
    ; ---------------------------------------------------------------------------

    loc_41B8BA:                             ; CODE XREF: sub_41B2E0+5C2j
    mov     eax, [esp+250h+var_208]
    mov     esi, 1
    jmp     loc_41B47B
    sub_41B2E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41B8D0 proc near                    ; CODE XREF: .text:004026EEp
                                            ; .text:00402B25p ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    test    edi, edi
    jz      loc_41BA4F
    mov     ecx, [edi+110h]
    mov     eax, 10000000h
    test    eax, ecx
    jz      loc_41BA4F
    mov     ecx, [edi+92h]
    mov     edx, [ecx+156h]
    test    edx, edx
    jz      loc_41BA4F
    mov     esi, [esp+arg_4]
    test    esi, esi
    jz      loc_41BA4F
    test    [esi+110h], eax
    jz      loc_41BA4F
    mov     edx, [esi+9Eh]
    mov     dword ptr [edx+10h], 0
    mov     eax, [esi+110h]
    or      ah, 20h
    mov     dword ptr [esi+104h], 0
    mov     [esi+110h], eax
    mov     ecx, eax
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_41B9A6
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_41B95B
    cmp     al, 2
    jnz     short loc_41B9A6

    loc_41B95B:                             ; CODE XREF: sub_41B8D0+85j
    test    ecx, 20000000h
    jz      short loc_41B990
    mov     eax, TAdynmemStructPtr
    push    offset aBuilder_gui             ; char *
    add     eax, 519h
    push    eax                             ; int
    call    sub_4AB060
    test    eax, eax
    jz      short loc_41B9A6
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_49FA90
    jmp     short loc_41B9A6
    ; ---------------------------------------------------------------------------

    loc_41B990:                             ; CODE XREF: sub_41B8D0+91j
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_41B9A6
    push    1
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_41B9A6:                             ; CODE XREF: sub_41B8D0+7Ej
                                            ; sub_41B8D0+89j ...
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    shr     eax, 12h
    test    al, 1
    jz      short loc_41B9C4
    push    1                               ; int
    push    1                               ; idTo
    mov     ecx, esi
    call    sub_48B090

    loc_41B9C4:                             ; CODE XREF: sub_41B8D0+E7j
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37E9Ch]
    cmp     cx, [edi+0A8h]
    jnz     short loc_41B9E5
    add     eax, 519h
    push    edi
    push    eax
    call    sub_4199B0

    loc_41B9E5:                             ; CODE XREF: sub_41B8D0+107j
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    shr     eax, 18h
    test    al, 1
    jz      short loc_41BA0E
    mov     eax, [esi+110h]
    mov     byte ptr [esi+0F5h], 7
    or      ah, 40h
    mov     [esi+110h], eax

    loc_41BA0E:                             ; CODE XREF: sub_41B8D0+126j
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_41BA2B
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_41BA24
    cmp     al, 2
    jnz     short loc_41BA2B

    loc_41BA24:                             ; CODE XREF: sub_41B8D0+14Ej
    push    esi
    push    edi
    call    sub_4560C0

    loc_41BA2B:                             ; CODE XREF: sub_41B8D0+147j
                                            ; sub_41B8D0+152j
    mov     cl, [edi+110h]
    mov     eax, 10h
    test    al, cl
    jnz     short loc_41BA42
    test    [esi+110h], al
    jz      short loc_41BA4F

    loc_41BA42:                             ; CODE XREF: sub_41B8D0+168j
    mov     ecx, TAdynmemStructPtr
    or      [ecx+37EBEh], ax

    loc_41BA4F:                             ; CODE XREF: sub_41B8D0+8j
                                            ; sub_41B8D0+1Bj ...
    pop     edi
    pop     esi
    retn    8
    sub_41B8D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41BA60 proc near                    ; CODE XREF: .text:00402A09p
                                            ; .text:00403E43p ...

    var_C= dword ptr -0Ch
    var_8= qword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+18h+arg_4]
    xor     ebx, ebx
    push    edi
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FCC88
    fnstsw  ax
    test    ah, 40h
    jz      short loc_41BA8C
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41BA8C:                             ; CODE XREF: sub_41BA60+1Ej
    fld     [esp+1Ch+arg_8]
    fcomp   ds:flt_4FCC88
    fnstsw  ax
    test    ah, 1
    jnz     short loc_41BAA4
    or      byte ptr [esi+0BBh], 80h

    loc_41BAA4:                             ; CODE XREF: sub_41BA60+3Bj
    fld     [esp+1Ch+arg_8]
    fcomp   ds:flt_4FCC88
    fnstsw  ax
    test    ah, 40h
    jz      short loc_41BAC1
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41BAC1:                             ; CODE XREF: sub_41BA60+53j
    mov     ecx, [esi+92h]
    fld     dword ptr [esi+104h]
    fild    dword ptr [ecx+1EAh]
    fdivr   [esp+1Ch+arg_8]
    fsubr   st, st(1)
    fcom    ds:flt_4FCC88
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41BAEA
    fld     st
    jmp     short loc_41BAF0
    ; ---------------------------------------------------------------------------

    loc_41BAEA:                             ; CODE XREF: sub_41BA60+84j
    fld     ds:flt_4FCC88

    loc_41BAF0:                             ; CODE XREF: sub_41BA60+88j
    fcomp   ds:flt_4FCC8C
    fnstsw  ax
    test    ah, 1
    jz      short loc_41BB1C
    fcom    ds:flt_4FCC88
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41BB10
    fstp    [esp+1Ch+arg_4]
    jmp     short loc_41BB26
    ; ---------------------------------------------------------------------------

    loc_41BB10:                             ; CODE XREF: sub_41BA60+A8j
    fstp    st
    mov     [esp+1Ch+arg_4], 0
    jmp     short loc_41BB26
    ; ---------------------------------------------------------------------------

    loc_41BB1C:                             ; CODE XREF: sub_41BA60+9Bj
    fstp    st
    mov     [esp+1Ch+arg_4], 3F800000h

    loc_41BB26:                             ; CODE XREF: sub_41BA60+AEj
                                            ; sub_41BA60+BAj
    mov     eax, [ecx+1FAh]
    mov     dword ptr [esp+1Ch+var_8+4], ebx
    fld     st
    fsub    [esp+1Ch+arg_4]
    fld     dword ptr [ecx+186h]
    fld     dword ptr [ecx+18Ah]
    mov     dword ptr [esp+1Ch+var_8], eax
    fild    [esp+1Ch+var_8]
    fld     [esp+1Ch+arg_4]
    fxch    st(4)
    fstp    [esp+1Ch+var_C]
    fxch    st(2)
    fmul    [esp+1Ch+var_C]
    fxch    st(1)
    fmul    [esp+1Ch+var_C]
    fxch    st(3)
    fmul    st, st(2)
    fxch    st(1)
    fstp    dword ptr [esp+1Ch+var_8]
    fxch    st(2)
    fstp    [esp+1Ch+var_C]
    fxch    st(1)
    call    __ftol
    fxch    st(1)
    fmul    st, st(1)
    mov     ebp, eax
    call    __ftol
    fstp    st
    fld     [esp+1Ch+arg_8]
    fcomp   ds:flt_4FCC88
    mov     edi, eax
    sub     edi, ebp
    mov     ebp, [esp+1Ch+arg_0]
    fnstsw  ax
    test    ah, 1
    jz      loc_41BC50
    mov     eax, [esi+0ECh]
    fld     [esp+1Ch+var_C]
    cmp     [eax], ebx
    fchs
    jz      short loc_41BBEE
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_41BBEE
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+37EEEh]
    sub     eax, ebx
    jz      short loc_41BBDC
    dec     eax
    jnz     short loc_41BBEE
    fmul    ds:dbl_4FCC90
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_41BBF4
    ; ---------------------------------------------------------------------------

    loc_41BBDC:                             ; CODE XREF: sub_41BA60+165j
    fmul    ds:dbl_4FCC98
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_41BBF4
    ; ---------------------------------------------------------------------------

    loc_41BBEE:                             ; CODE XREF: sub_41BA60+14Fj
                                            ; sub_41BA60+155j ...
    fadd    dword ptr [esi+0D4h]

    loc_41BBF4:                             ; CODE XREF: sub_41BA60+17Aj
                                            ; sub_41BA60+18Cj
    fstp    dword ptr [esi+0D4h]
    movsx   edx, word ptr [esi+108h]
    fld     [esp+1Ch+arg_4]
    fcomp   ds:flt_4FCC8C
    xor     ecx, ecx
    lea     eax, [edi+edx]
    mov     edx, [esp+1Ch+arg_4]
    cmp     eax, ebx
    mov     [esi+104h], edx
    setle   cl
    dec     ecx
    and     eax, ecx
    mov     [esi+108h], ax
    mov     eax, [esi+110h]
    or      ah, 20h
    mov     [esi+110h], eax
    fnstsw  ax
    test    ah, 1
    jnz     short loc_41BCAA
    push    ebx
    push    9
    push    7530h
    push    esi
    push    esi
    call    sub_489BB0
    jmp     short loc_41BCAA
    ; ---------------------------------------------------------------------------

    loc_41BC50:                             ; CODE XREF: sub_41BA60+13Bj
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, dword ptr [esp+1Ch+var_8]
    push    eax
    push    ecx
    lea     ecx, [ebp+0BCh]
    call    sub_4011C0
    test    eax, eax
    jz      short loc_41BCAA
    movsx   edx, word ptr [esi+108h]
    mov     ecx, [esi+92h]
    lea     eax, [edi+edx]
    mov     ecx, [ecx+1FAh]
    cmp     eax, ecx
    jb      short loc_41BC85
    mov     eax, ecx

    loc_41BC85:                             ; CODE XREF: sub_41BA60+221j
    mov     edx, [esp+1Ch+arg_4]
    mov     [esi+108h], ax
    mov     eax, [esi+110h]
    mov     [esi+104h], edx
    or      ah, 20h
    mov     ebx, 1
    mov     [esi+110h], eax

    loc_41BCAA:                             ; CODE XREF: sub_41BA60+1DDj
                                            ; sub_41BA60+1EEj ...
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FCC88
    fnstsw  ax
    test    ah, 40h
    jz      short loc_41BCC4
    push    esi
    push    ebp
    call    sub_41B8D0

    loc_41BCC4:                             ; CODE XREF: sub_41BA60+25Bj
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_41BA60 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41BCD0 proc near                    ; CODE XREF: .text:00402F6Bp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+92h]
    push    ecx
    mov     edx, [ecx+1EAh]
    imul    edx, [esp+4+arg_4]
    mov     [esp+4+arg_0], edx
    fild    [esp+4+arg_0]
    fdiv    dword ptr [ecx+186h]
    fchs
    fstp    [esp+4+var_4]
    push    eax
    push    eax
    call    sub_41BA60
    retn    8
    sub_41BCD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41BD10 proc near                    ; CODE XREF: .text:00402518p
                                            ; .text:0040561Ap ...

    var_18= dword ptr -18h
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+10h+arg_4]
    xor     ebp, ebp
    mov     esi, [edi+92h]
    movsx   edx, word ptr [edi+108h]
    mov     eax, [esi+1FAh]
    mov     ecx, [esi+1EAh]
    cmp     edx, eax
    mov     [esp+10h+arg_4], eax
    mov     [esp+10h+var_4], ecx
    jl      short loc_41BD48
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41BD48:                             ; CODE XREF: sub_41BD10+2Dj
    fild    [esp+10h+var_4]
    fild    [esp+10h+arg_4]
    push    ebx
    fmul    [esp+14h+arg_8]
    fsub    ds:flt_4FCC8C
    fdiv    st, st(1)
    fsub    ds:flt_4FCCA0
    call    __ftol
    fld     dword ptr [esi+186h]
    fmul    [esp+14h+arg_8]
    mov     esi, eax
    fsub    ds:flt_4FCC8C
    fdiv    st, st(1)
    fsub    ds:flt_4FCCA0
    call    __ftol
    cmp     esi, 1
    mov     [esp+14h+arg_8], eax
    fstp    st
    jl      short loc_41BD97
    mov     esi, 1

    loc_41BD97:                             ; CODE XREF: sub_41BD10+80j
    cmp     eax, 1
    jl      short loc_41BDA4
    mov     [esp+14h+arg_8], 1

    loc_41BDA4:                             ; CODE XREF: sub_41BD10+8Aj
    mov     ebx, [esp+14h+arg_0]
    fild    [esp+14h+arg_8]
    lea     ecx, [ebx+0BCh]
    push    ecx
    fstp    [esp+18h+var_18]
    push    ecx
    call    sub_401180
    test    eax, eax
    jz      short loc_41BDD1
    push    0
    push    0Ah
    push    esi
    push    edi
    push    ebx
    call    sub_489BB0
    mov     ebp, 1

    loc_41BDD1:                             ; CODE XREF: sub_41BD10+AEj
    pop     ebx
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ecx
    retn    0Ch
    sub_41BD10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41BDE0 proc near                    ; CODE XREF: sub_41C180+25p
                                            ; .text:0049608Fp

    arg_0= dword ptr  4

    mov     edx, TAdynmemStructPtr
    push    ebx
    push    esi
    mov     ax, [edx+37E9Ch]
    test    ax, ax
    jz      loc_41BEFA
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*8+0A6h], 0
    lea     eax, [ecx+eax*8]
    jnz     short loc_41BE1D
    xor     eax, eax

    loc_41BE1D:                             ; CODE XREF: sub_41BDE0+39j
    test    eax, eax
    jz      loc_41BEFA
    mov     ecx, [esp+8+arg_0]
    test    ecx, ecx
    mov     ecx, [eax+110h]
    jz      short loc_41BE8F
    test    ecx, 400000h
    jnz     short loc_41BE4C
    and     ecx, 0FCFFFFFFh
    or      ecx, 0C00000h
    jmp     loc_41BEE8
    ; ---------------------------------------------------------------------------

    loc_41BE4C:                             ; CODE XREF: sub_41BDE0+59j
    mov     esi, [eax+92h]
    mov     edx, ecx
    xor     ebx, ebx
    mov     bl, [esi+22Eh]
    shr     edx, 17h
    and     edx, 7
    dec     ebx
    cmp     edx, ebx
    jnz     short loc_41BE6F
    and     ecx, 0FFBFFFFFh
    jmp     short loc_41BEE8
    ; ---------------------------------------------------------------------------

    loc_41BE6F:                             ; CODE XREF: sub_41BDE0+85j
    mov     edx, ecx
    and     edx, 0FF800000h
    add     edx, 800000h
    xor     edx, ecx
    and     edx, 3800000h
    xor     edx, ecx
    mov     [eax+110h], edx
    jmp     short loc_41BEEE
    ; ---------------------------------------------------------------------------

    loc_41BE8F:                             ; CODE XREF: sub_41BDE0+51j
    mov     esi, [eax+92h]
    mov     edx, ecx
    xor     ebx, ebx
    mov     bl, [esi+22Eh]
    shr     edx, 17h
    and     edx, 7
    dec     ebx
    cmp     edx, ebx
    jnz     short loc_41BEBE
    and     ecx, 0FCFFFFFFh
    or      ecx, 800000h
    mov     [eax+110h], ecx
    jmp     short loc_41BEDC
    ; ---------------------------------------------------------------------------

    loc_41BEBE:                             ; CODE XREF: sub_41BDE0+C8j
    mov     edx, ecx
    and     edx, 0FF800000h
    add     edx, 800000h
    xor     edx, ecx
    and     edx, 3800000h
    xor     edx, ecx
    mov     [eax+110h], edx

    loc_41BEDC:                             ; CODE XREF: sub_41BDE0+DCj
    mov     ecx, [eax+110h]
    or      ecx, 400000h

    loc_41BEE8:                             ; CODE XREF: sub_41BDE0+67j
                                            ; sub_41BDE0+8Dj
    mov     [eax+110h], ecx

    loc_41BEEE:                             ; CODE XREF: sub_41BDE0+ADj
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37EBEh], 10h

    loc_41BEFA:                             ; CODE XREF: sub_41BDE0+12j
                                            ; sub_41BDE0+3Fj
    push    0                               ; int
    push    offset aNextbuildmenu           ; char *
    call    sub_47F1A0
    pop     esi
    pop     ebx
    retn    4
    sub_41BDE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41BF10 proc near                    ; CODE XREF: sub_41C180+42p
                                            ; .text:00496083p

    arg_0= dword ptr  4

    mov     edx, TAdynmemStructPtr
    push    ebx
    mov     ax, [edx+37E9Ch]
    test    ax, ax
    jz      loc_41C045
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*8+0A6h], 0
    lea     eax, [ecx+eax*8]
    jnz     short loc_41BF4C
    xor     eax, eax

    loc_41BF4C:                             ; CODE XREF: sub_41BF10+38j
    test    eax, eax
    jz      loc_41C045
    mov     ecx, [esp+4+arg_0]
    test    ecx, ecx
    mov     ecx, [eax+110h]
    jz      short loc_41BFD5
    test    ecx, 400000h
    jnz     short loc_41BFA2
    mov     edx, [eax+92h]
    or      ecx, 400000h
    xor     ebx, ebx
    mov     [eax+110h], ecx
    mov     bl, [edx+22Eh]
    add     ebx, 1FFh
    shl     ebx, 17h
    xor     ebx, ecx
    and     ebx, 3800000h
    xor     ebx, ecx
    mov     [eax+110h], ebx
    jmp     loc_41C039
    ; ---------------------------------------------------------------------------

    loc_41BFA2:                             ; CODE XREF: sub_41BF10+58j
    mov     edx, ecx
    and     edx, 3800000h
    cmp     edx, 800000h
    jnz     short loc_41BFBA
    and     ecx, 0FFBFFFFFh
    jmp     short loc_41C033
    ; ---------------------------------------------------------------------------

    loc_41BFBA:                             ; CODE XREF: sub_41BF10+A0j
    mov     edx, ecx
    and     edx, 0FF800000h
    dec     edx
    xor     edx, ecx
    and     edx, 3800000h
    xor     edx, ecx
    mov     [eax+110h], edx
    jmp     short loc_41C039
    ; ---------------------------------------------------------------------------

    loc_41BFD5:                             ; CODE XREF: sub_41BF10+50j
    mov     edx, ecx
    and     edx, 3800000h
    cmp     edx, 1000000h
    jnb     short loc_41C00E
    mov     edx, [eax+92h]
    xor     ebx, ebx
    mov     bl, [edx+22Eh]
    add     ebx, 1FFh
    shl     ebx, 17h
    xor     ebx, ecx
    and     ebx, 3800000h
    xor     ebx, ecx
    mov     [eax+110h], ebx
    jmp     short loc_41C027
    ; ---------------------------------------------------------------------------

    loc_41C00E:                             ; CODE XREF: sub_41BF10+D3j
    mov     edx, ecx
    and     edx, 0FF800000h
    dec     edx
    xor     edx, ecx
    and     edx, 3800000h
    xor     edx, ecx
    mov     [eax+110h], edx

    loc_41C027:                             ; CODE XREF: sub_41BF10+FCj
    mov     ecx, [eax+110h]
    or      ecx, 400000h

    loc_41C033:                             ; CODE XREF: sub_41BF10+A8j
    mov     [eax+110h], ecx

    loc_41C039:                             ; CODE XREF: sub_41BF10+8Dj
                                            ; sub_41BF10+C3j
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37EBEh], 10h

    loc_41C045:                             ; CODE XREF: sub_41BF10+11j
                                            ; sub_41BF10+3Ej
    push    0                               ; int
    push    offset aNextbuildmenu           ; char *
    call    sub_47F1A0
    pop     ebx
    retn    4
    sub_41BF10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C060 proc near                    ; CODE XREF: sub_495E90+14Ep
                                            ; sub_495E90+186p

    arg_0= dword ptr  4

    mov     edx, TAdynmemStructPtr
    push    ebx
    push    esi
    mov     ax, [edx+37E9Ch]
    test    ax, ax
    jz      loc_41C108
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*8+0A6h], 0
    lea     eax, [ecx+eax*8]
    jnz     short loc_41C09D
    xor     eax, eax

    loc_41C09D:                             ; CODE XREF: sub_41C060+39j
    test    eax, eax
    jz      short loc_41C108
    mov     edx, [eax+92h]
    mov     ecx, [esp+8+arg_0]
    xor     ebx, ebx
    mov     bl, [edx+22Eh]
    cmp     ecx, ebx
    jge     short loc_41C108
    mov     esi, [eax+110h]
    xor     edx, edx
    test    ecx, ecx
    setnle  dl
    and     edx, 1
    and     esi, 0FFBFFFFFh
    shl     edx, 16h
    or      edx, esi
    test    ecx, ecx
    mov     [eax+110h], edx
    jz      short loc_41C0F0
    and     ecx, 7
    and     edx, 0FC7FFFFFh
    shl     ecx, 17h
    or      ecx, edx
    mov     [eax+110h], ecx

    loc_41C0F0:                             ; CODE XREF: sub_41C060+7Aj
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aNextbuildmenu           ; char *
    or      byte ptr [eax+37EBEh], 10h
    call    sub_47F1A0

    loc_41C108:                             ; CODE XREF: sub_41C060+12j
                                            ; sub_41C060+3Fj ...
    pop     esi
    pop     ebx
    retn    4
    sub_41C060 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C110 proc near                    ; CODE XREF: .text:00402DC3p
                                            ; .text:00403A42p ...

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     dl, [ecx+0FFh]
    mov     bl, [eax+2A42h]
    cmp     dl, bl
    jnz     short loc_41C140
    mov     bl, [ecx+110h]
    mov     edx, 10h
    test    dl, bl
    jz      short loc_41C140
    or      [eax+37EBEh], dx

    loc_41C140:                             ; CODE XREF: sub_41C110+18j
                                            ; sub_41C110+27j
    pop     ebx
    retn    4
    sub_41C110 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C150 proc near                    ; CODE XREF: .text:00402712p
                                            ; .text:00402743p ...

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+arg_0]
    mov     dx, [eax+37E9Ch]
    cmp     dx, [ecx+0A8h]
    jnz     short locret_41C175
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4199B0

    locret_41C175:                          ; CODE XREF: sub_41C150+17j
    retn    4
    sub_41C150 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C180 proc near                    ; CODE XREF: .text:004992CDp
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37EBEh]
    mov     dl, al
    shr     dl, 7
    test    dl, 1
    jz      short loc_41C1AB
    and     eax, 0FF7Fh
    push    0
    mov     [ecx+37EBEh], ax
    call    sub_41BDE0
    retn
    ; ---------------------------------------------------------------------------

    loc_41C1AB:                             ; CODE XREF: sub_41C180+15j
    xor     edx, edx
    mov     dl, ah
    test    dl, 1
    jz      short loc_41C1C8
    and     eax, 0FEFFh
    push    0
    mov     [ecx+37EBEh], ax
    call    sub_41BF10
    retn
    ; ---------------------------------------------------------------------------

    loc_41C1C8:                             ; CODE XREF: sub_41C180+32j
    mov     edx, eax
    shr     edx, 0Ah
    test    dl, 1
    jz      short loc_41C23C
    and     eax, 0FBFFh
    mov     [ecx+37EBEh], ax
    mov     edx, TAdynmemStructPtr
    mov     ax, [edx+37E9Ch]
    test    ax, ax
    jz      short loc_41C213
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*8+0A6h], 0
    lea     eax, [ecx+eax*8]
    jnz     short loc_41C215

    loc_41C213:                             ; CODE XREF: sub_41C180+6Ej
    xor     eax, eax

    loc_41C215:                             ; CODE XREF: sub_41C180+91j
    test    eax, eax
    jz      locret_41C2AB
    mov     edx, [eax+110h]
    or      edx, 400000h
    mov     [eax+110h], edx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37EBEh], 10h
    retn
    ; ---------------------------------------------------------------------------

    loc_41C23C:                             ; CODE XREF: sub_41C180+50j
    mov     edx, eax
    shr     edx, 9
    test    dl, 1
    jz      short locret_41C2AB
    and     eax, 0FDFFh
    mov     [ecx+37EBEh], ax
    mov     edx, TAdynmemStructPtr
    mov     ax, [edx+37E9Ch]
    test    ax, ax
    jz      short loc_41C287
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*8+0A6h], 0
    lea     eax, [ecx+eax*8]
    jnz     short loc_41C289

    loc_41C287:                             ; CODE XREF: sub_41C180+E2j
    xor     eax, eax

    loc_41C289:                             ; CODE XREF: sub_41C180+105j
    test    eax, eax
    jz      short locret_41C2AB
    mov     edx, [eax+110h]
    and     edx, 0FFBFFFFFh
    mov     [eax+110h], edx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37EBEh], 10h

    locret_41C2AB:                          ; CODE XREF: sub_41C180+97j
                                            ; sub_41C180+C4j ...
    retn
    sub_41C180 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C2B0 proc near                    ; CODE XREF: sub_4917D0+F5p
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    edi
    mov     ecx, 17h
    mov     bl, [edx+1434Dh]
    xor     eax, eax
    lea     edi, [edx+142F3h]
    rep stosd
    mov     eax, TAdynmemStructPtr
    pop     edi
    mov     [eax+1434Dh], bl
    pop     ebx
    retn
    sub_41C2B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C2E0 proc near                    ; CODE XREF: sub_48AD30+344p
                                            ; sub_4964E6+1p ...

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+arg_0]
    push    eax                             ; int
    mov     edx, [ecx+142F3h]
    push    edx                             ; int
    call    sub_48C190
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F3h], eax
    retn    4
    sub_41C2E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C310 proc near                    ; CODE XREF: .text:00496409p
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    esi
    push    edi
    mov     dl, [ecx+2A42h]
    push    offset aCommander_0             ; char *
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     edi, [ecx+eax*2+1B63h]
    call    sub_488C50
    mov     esi, [edi+67h]
    mov     ecx, [edi+6Bh]
    cmp     esi, ecx
    ja      short loc_41C383
    push    ebx

    loc_41C348:                             ; CODE XREF: sub_41C310+70j
    mov     dx, [esi+0A6h]
    mov     ebx, 1
    and     edx, 0FFFFh
    mov     ecx, edx
    and     ecx, 1Fh
    shl     ebx, cl
    shr     edx, 5
    test    [eax+edx*4], ebx
    jz      short loc_41C375
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F3h], esi

    loc_41C375:                             ; CODE XREF: sub_41C310+57j
    mov     ecx, [edi+6Bh]
    add     esi, 118h
    cmp     esi, ecx
    jbe     short loc_41C348
    pop     ebx

    loc_41C383:                             ; CODE XREF: sub_41C310+35j
    pop     edi
    pop     esi
    retn
    sub_41C310 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C390 proc near                    ; CODE XREF: .text:004174FDp
                                            ; sub_48D630+D9p
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     [ecx+1434Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+142F3h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F7h], eax
    retn
    sub_41C390 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_41C3C0()
    sub_41C3C0 proc near                    ; CODE XREF: ScrollMap+DFp
                                            ; sub_41C7C0+D8p ...
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+1422Bh]
    mov     edx, [eax+37E37h]
    mov     esi, [eax+37E3Bh]
    sub     ecx, edx
    mov     edx, [eax+1422Fh]
    sub     edx, esi
    mov     esi, [eax+TAdynmemStruct.MapX]
    test    esi, esi
    jge     short loc_41C3F8
    mov     [eax+TAdynmemStruct.MapX], 0
    jmp     short loc_41C402
    ; ---------------------------------------------------------------------------

    loc_41C3F8:                             ; CODE XREF: sub_41C3C0+2Aj
    cmp     esi, ecx
    jle     short loc_41C407
    mov     [eax+TAdynmemStruct.MapX], ecx

    loc_41C402:                             ; CODE XREF: sub_41C3C0+36j
    mov     eax, TAdynmemStructPtr

    loc_41C407:                             ; CODE XREF: sub_41C3C0+3Aj
    mov     ecx, [eax+TAdynmemStruct.MapY]
    test    ecx, ecx
    jge     short loc_41C42D
    mov     [eax+TAdynmemStruct.MapY], 0
    mov     eax, TAdynmemStructPtr
    add     eax, TAdynmemStruct.MinimapRect
    push    eax                             ; int
    call    MiniMapUpdate_1
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_41C42D:                             ; CODE XREF: sub_41C3C0+4Fj
    cmp     ecx, edx
    jle     short loc_41C43C
    mov     [eax+14323h], edx
    mov     eax, TAdynmemStructPtr

    loc_41C43C:                             ; CODE XREF: sub_41C3C0+6Fj
    add     eax, 142CBh
    push    eax                             ; int
    call    MiniMapUpdate_1
    pop     esi
    retn
    sub_41C3C0 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+1422Bh]
    mov     edx, [eax+37E37h]
    mov     esi, [eax+37E3Bh]
    sub     ecx, edx
    mov     edx, [eax+1422Fh]
    sub     edx, esi
    mov     esi, [eax+14327h]
    test    esi, esi
    jge     short loc_41C488
    mov     dword ptr [eax+14327h], 0
    jmp     short loc_41C492
    ; ---------------------------------------------------------------------------

    loc_41C488:                             ; CODE XREF: .text:0041C47Aj
    cmp     esi, ecx
    jle     short loc_41C497
    mov     [eax+14327h], ecx

    loc_41C492:                             ; CODE XREF: .text:0041C486j
    mov     eax, TAdynmemStructPtr

    loc_41C497:                             ; CODE XREF: .text:0041C48Aj
    mov     ecx, [eax+1432Bh]
    test    ecx, ecx
    jge     short loc_41C4AD
    mov     dword ptr [eax+1432Bh], 0
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_41C4AD:                             ; CODE XREF: .text:0041C49Fj
    cmp     ecx, edx
    jle     short loc_41C4B7
    mov     [eax+1432Bh], edx

    loc_41C4B7:                             ; CODE XREF: .text:0041C4AFj
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall ScrollMap(int MapXScrollingTo,int MapYScrollingTo,int)
    ScrollMap proc near                     ; CODE XREF: sub_495A30+238p
                                            ; sub_495A30+3E1p ...

    MapXScrollingTo= dword ptr  4
    MapYScrollingTo= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    push    esi
    test    eax, eax
    jz      loc_41C574
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+4+MapXScrollingTo]
    mov     [eax+TAdynmemStruct.MapXScrollingTo], ecx
    mov     edx, TAdynmemStructPtr
    mov     eax, [esp+4+MapYScrollingTo]
    mov     [edx+TAdynmemStruct.MapYScrollingTo], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1422Bh]
    mov     edx, [eax+37E37h]
    mov     esi, [eax+37E3Bh]
    sub     ecx, edx
    mov     edx, [eax+1422Fh]
    sub     edx, esi
    mov     esi, [eax+TAdynmemStruct.MapXScrollingTo]
    test    esi, esi
    jge     short loc_41C523
    mov     [eax+TAdynmemStruct.MapXScrollingTo], 0
    jmp     short loc_41C52D
    ; ---------------------------------------------------------------------------

    loc_41C523:                             ; CODE XREF: ScrollMap+55j
    cmp     esi, ecx
    jle     short loc_41C532
    mov     [eax+TAdynmemStruct.MapXScrollingTo], ecx

    loc_41C52D:                             ; CODE XREF: ScrollMap+61j
    mov     eax, TAdynmemStructPtr

    loc_41C532:                             ; CODE XREF: ScrollMap+65j
    mov     ecx, [eax+TAdynmemStruct.MapYScrollingTo]
    test    ecx, ecx
    jge     short loc_41C558
    mov     [eax+TAdynmemStruct.MapYScrollingTo], 0
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41C558:                             ; CODE XREF: ScrollMap+7Aj
    cmp     ecx, edx
    jle     short loc_41C5CB
    mov     [eax+TAdynmemStruct.MapYScrollingTo], edx
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41C574:                             ; CODE XREF: ScrollMap+7j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+4+MapXScrollingTo]
    mov     [ecx+TAdynmemStruct.MapX], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+4+MapYScrollingTo]
    mov     [eax+TAdynmemStruct.MapY], ecx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 2
    call    sub_41C3C0
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+TAdynmemStruct.MapX]
    mov     [eax+TAdynmemStruct.MapXScrollingTo], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+TAdynmemStruct.MapY]
    mov     [eax+TAdynmemStruct.MapYScrollingTo], ecx
    mov     eax, TAdynmemStructPtr

    loc_41C5CB:                             ; CODE XREF: ScrollMap+9Aj
    and     word ptr [eax+14281h], 0FFF7h
    pop     esi
    retn    0Ch
    ScrollMap endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C5E0 proc near

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+37F2Fh], 10h
    jnz     short locret_41C63D
    mov     eax, [esp+arg_8]
    mov     [ecx+1432Fh], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+14333h], eax
    mov     ecx, [esp+arg_0]
    test    ecx, ecx
    jz      short loc_41C619
    mov     edx, TAdynmemStructPtr
    mov     [edx+14337h], ecx

    loc_41C619:                             ; CODE XREF: sub_41C5E0+2Bj
    mov     ecx, [esp+arg_4]
    test    ecx, ecx
    jz      short loc_41C62D
    mov     edx, TAdynmemStructPtr
    mov     [edx+1433Bh], ecx

    loc_41C62D:                             ; CODE XREF: sub_41C5E0+3Fj
    test    eax, eax
    jle     short locret_41C63D
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+1434Eh], 1

    locret_41C63D:                          ; CODE XREF: sub_41C5E0+Dj
                                            ; sub_41C5E0+4Fj
    retn    0Ch
    sub_41C5E0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C640 proc near                    ; CODE XREF: sub_499EB0+10Ap

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+37F2Fh], 10h
    jnz     locret_41C6E7
    test    byte ptr [ecx+1434Eh], 1
    jnz     short loc_41C67B
    mov     dword ptr [ecx+14337h], 0
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+1433Bh], 0
    mov     ecx, TAdynmemStructPtr

    loc_41C67B:                             ; CODE XREF: sub_41C640+1Aj
    mov     eax, [esp+arg_8]
    mov     edx, [ecx+1432Fh]
    add     eax, edx
    cdq
    sub     eax, edx
    mov     edx, [esp+arg_0]
    sar     eax, 1
    mov     [ecx+1432Fh], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1432Fh]
    mov     [eax+14333h], ecx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14337h]
    add     ecx, edx
    mov     [eax+14337h], ecx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+arg_4]
    mov     edx, [eax+1433Bh]
    add     edx, ecx
    mov     [eax+1433Bh], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1432Fh]
    test    ecx, ecx
    jle     short locret_41C6E7
    or      byte ptr [eax+1434Eh], 1

    locret_41C6E7:                          ; CODE XREF: sub_41C640+Dj
                                            ; sub_41C640+9Ej
    retn    0Ch
    sub_41C640 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C6F0 proc near                    ; CODE XREF: sub_41CA10+201p
                                            ; sub_41CA10+222p ...
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     al, [ecx+1434Eh]
    test    al, 1
    jz      loc_41C7B4
    mov     ebx, [ecx+14333h]
    test    ebx, ebx
    jle     loc_41C7AC
    mov     eax, [ecx+14337h]
    mov     esi, [ecx+1432Fh]
    imul    eax, ebx
    cdq
    idiv    esi
    mov     edi, eax
    mov     eax, [ecx+1433Bh]
    imul    eax, ebx
    cdq
    idiv    esi
    mov     ebx, eax
    call    _rand
    imul    edi
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     esi, eax
    mov     eax, edi
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     esi, eax
    call    _rand
    imul    ebx
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, eax
    mov     eax, ebx
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ecx, eax
    mov     eax, TAdynmemStructPtr
    mov     edi, [eax+1431Fh]
    add     edi, esi
    mov     [eax+1431Fh], edi
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14323h]
    add     edx, ecx
    mov     [eax+14323h], edx
    mov     eax, TAdynmemStructPtr
    dec     dword ptr [eax+14333h]
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_41C7AC:                             ; CODE XREF: sub_41C6F0+1Fj
    and     al, 0FEh
    mov     [ecx+1434Eh], al

    loc_41C7B4:                             ; CODE XREF: sub_41C6F0+11j
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_41C6F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C7C0 proc near                    ; CODE XREF: sub_463F60+8Ap

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    esi
    mov     esi, TAdynmemStructPtr
    mov     ecx, [esp+arg_4]
    mov     eax, [esi+37E3Bh]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ecx, eax
    mov     eax, [esi+37E37h]
    cdq
    sub     eax, edx
    mov     edx, eax
    mov     eax, [esp+arg_0]
    sar     edx, 1
    sub     eax, edx
    mov     edx, [esp+arg_8]
    test    edx, edx
    jz      loc_41C87A
    mov     [esi+14327h], eax
    mov     eax, TAdynmemStructPtr
    mov     [eax+1432Bh], ecx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1422Bh]
    mov     edx, [eax+37E37h]
    mov     esi, [eax+37E3Bh]
    sub     ecx, edx
    mov     edx, [eax+1422Fh]
    sub     edx, esi
    mov     esi, [eax+14327h]
    test    esi, esi
    jge     short loc_41C83F
    mov     dword ptr [eax+14327h], 0
    jmp     short loc_41C849
    ; ---------------------------------------------------------------------------

    loc_41C83F:                             ; CODE XREF: sub_41C7C0+71j
    cmp     esi, ecx
    jle     short loc_41C84E
    mov     [eax+14327h], ecx

    loc_41C849:                             ; CODE XREF: sub_41C7C0+7Dj
    mov     eax, TAdynmemStructPtr

    loc_41C84E:                             ; CODE XREF: sub_41C7C0+81j
    mov     ecx, [eax+1432Bh]
    test    ecx, ecx
    jge     short loc_41C874
    mov     dword ptr [eax+1432Bh], 0
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_41C874:                             ; CODE XREF: sub_41C7C0+96j
    cmp     ecx, edx
    jle     short loc_41C8C4
    jmp     short loc_41C8B9
    ; ---------------------------------------------------------------------------

    loc_41C87A:                             ; CODE XREF: sub_41C7C0+31j
    mov     [esi+1431Fh], eax
    mov     edx, TAdynmemStructPtr
    mov     [edx+14323h], ecx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 2
    call    sub_41C3C0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1431Fh]
    mov     [eax+14327h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14323h]

    loc_41C8B9:                             ; CODE XREF: sub_41C7C0+B8j
    mov     [eax+1432Bh], edx
    mov     eax, TAdynmemStructPtr

    loc_41C8C4:                             ; CODE XREF: sub_41C7C0+B6j
    and     word ptr [eax+14281h], 0FFF7h
    pop     esi
    retn    0Ch
    sub_41C7C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41C8E0 proc near                    ; CODE XREF: sub_48D4D0+D0p
                                            ; sub_48D630+E4p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, TAdynmemStructPtr
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    sar     eax, 1
    sub     ecx, eax
    mov     eax, [edi+37E3Bh]
    cdq
    sar     ecx, 10h
    movsx   ecx, cx
    sub     eax, edx
    mov     edx, [esi]
    sar     eax, 1
    sub     ecx, eax
    mov     eax, [edi+37E37h]
    sar     edx, 10h
    movsx   esi, dx
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     esi, eax
    mov     eax, [esp+4+arg_4]
    test    eax, eax
    jz      loc_41C9AE
    mov     [edi+14327h], esi
    mov     eax, TAdynmemStructPtr
    mov     [eax+1432Bh], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+1422Fh]
    mov     esi, [eax+37E3Bh]
    mov     ecx, [eax+1422Bh]
    mov     edi, [eax+37E37h]
    sub     edx, esi
    mov     esi, [eax+14327h]
    sub     ecx, edi
    test    esi, esi
    jge     short loc_41C972
    mov     dword ptr [eax+14327h], 0
    jmp     short loc_41C97C
    ; ---------------------------------------------------------------------------

    loc_41C972:                             ; CODE XREF: sub_41C8E0+84j
    cmp     esi, ecx
    jle     short loc_41C981
    mov     [eax+14327h], ecx

    loc_41C97C:                             ; CODE XREF: sub_41C8E0+90j
    mov     eax, TAdynmemStructPtr

    loc_41C981:                             ; CODE XREF: sub_41C8E0+94j
    mov     ecx, [eax+1432Bh]
    test    ecx, ecx
    jge     short loc_41C9A8
    mov     dword ptr [eax+1432Bh], 0
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_41C9A8:                             ; CODE XREF: sub_41C8E0+A9j
    cmp     ecx, edx
    jle     short loc_41C9F8
    jmp     short loc_41C9ED
    ; ---------------------------------------------------------------------------

    loc_41C9AE:                             ; CODE XREF: sub_41C8E0+44j
    mov     [edi+1431Fh], esi
    mov     edx, TAdynmemStructPtr
    mov     [edx+14323h], ecx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 2
    call    sub_41C3C0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1431Fh]
    mov     [eax+14327h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14323h]

    loc_41C9ED:                             ; CODE XREF: sub_41C8E0+CCj
    mov     [eax+1432Bh], edx
    mov     eax, TAdynmemStructPtr

    loc_41C9F8:                             ; CODE XREF: sub_41C8E0+CAj
    and     word ptr [eax+14281h], 0FFF7h
    pop     edi
    pop     esi
    retn    8
    sub_41C8E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41CA10 proc near                    ; CODE XREF: .text:00495599p
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    esi
    xor     ebp, ebp
    mov     ax, [ecx+1434Bh]
    xor     esi, esi
    cmp     ax, bp
    push    edi
    jz      short loc_41CA3F
    dec     eax
    mov     [ecx+1434Bh], ax
    mov     ecx, TAdynmemStructPtr
    lea     esi, [ecx+1433Fh]
    jmp     short loc_41CA8D
    ; ---------------------------------------------------------------------------

    loc_41CA3F:                             ; CODE XREF: sub_41CA10+17j
    mov     eax, [ecx+142F7h]
    cmp     eax, ebp
    jz      short loc_41CA4E
    lea     esi, [eax+4]
    jmp     short loc_41CA8D
    ; ---------------------------------------------------------------------------

    loc_41CA4E:                             ; CODE XREF: sub_41CA10+37j
    mov     eax, [ecx+142F3h]
    cmp     eax, ebp
    jz      short loc_41CA8D
    test    dword ptr [eax+110h], 10000000h
    jz      short loc_41CA69
    lea     esi, [eax+6Ah]
    jmp     short loc_41CA8D
    ; ---------------------------------------------------------------------------

    loc_41CA69:                             ; CODE XREF: sub_41CA10+52j
    mov     [ecx+1434Bh], bp
    mov     eax, TAdynmemStructPtr
    mov     [eax+142F3h], ebp
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F7h], ebp
    mov     ecx, TAdynmemStructPtr

    loc_41CA8D:                             ; CODE XREF: sub_41CA10+2Dj
                                            ; sub_41CA10+3Cj ...
    cmp     esi, ebp
    jz      loc_41CB4A
    mov     edx, [esi+4]
    mov     eax, [esi+8]
    sar     edx, 1
    sub     eax, edx
    sar     eax, 10h
    movsx   edi, ax
    mov     eax, [ecx+37E3Bh]
    cdq
    sub     eax, edx
    mov     edx, [esi]
    sar     eax, 1
    sub     edi, eax
    mov     eax, [ecx+37E37h]
    sar     edx, 10h
    movsx   esi, dx
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     esi, eax
    mov     [ecx+14327h], esi
    mov     eax, TAdynmemStructPtr
    mov     [eax+1432Bh], edi
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+1422Fh]
    mov     esi, [eax+37E3Bh]
    mov     ecx, [eax+1422Bh]
    mov     edi, [eax+37E37h]
    sub     edx, esi
    mov     esi, [eax+14327h]
    sub     ecx, edi
    cmp     esi, ebp
    jge     short loc_41CB0B
    mov     [eax+14327h], ebp
    jmp     short loc_41CB15
    ; ---------------------------------------------------------------------------

    loc_41CB0B:                             ; CODE XREF: sub_41CA10+F1j
    cmp     esi, ecx
    jle     short loc_41CB1A
    mov     [eax+14327h], ecx

    loc_41CB15:                             ; CODE XREF: sub_41CA10+F9j
    mov     eax, TAdynmemStructPtr

    loc_41CB1A:                             ; CODE XREF: sub_41CA10+FDj
    mov     ecx, [eax+1432Bh]
    cmp     ecx, ebp
    jge     short loc_41CB2C
    mov     [eax+1432Bh], ebp
    jmp     short loc_41CB36
    ; ---------------------------------------------------------------------------

    loc_41CB2C:                             ; CODE XREF: sub_41CA10+112j
    cmp     ecx, edx
    jle     short loc_41CB3B
    mov     [eax+1432Bh], edx

    loc_41CB36:                             ; CODE XREF: sub_41CA10+11Aj
    mov     eax, TAdynmemStructPtr

    loc_41CB3B:                             ; CODE XREF: sub_41CA10+11Ej
    and     word ptr [eax+14281h], 0FFF7h
    mov     ecx, TAdynmemStructPtr

    loc_41CB4A:                             ; CODE XREF: sub_41CA10+7Fj
    mov     edx, [ecx+1431Fh]
    mov     eax, [ecx+14327h]
    cmp     edx, eax
    mov     edi, 2
    jz      short loc_41CBBF
    or      [ecx+142F1h], di
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    mov     esi, TAdynmemStructPtr
    mov     ecx, [esi+1431Fh]
    mov     edx, [esi+14327h]
    mov     eax, ecx
    sub     eax, edx
    cmp     eax, ebp
    jle     short loc_41CB9D
    cmp     eax, 140h
    jle     short loc_41CBAC
    add     ecx, 0FFFFFEC0h
    jmp     short loc_41CBB3
    ; ---------------------------------------------------------------------------

    loc_41CB9D:                             ; CODE XREF: sub_41CA10+17Cj
    cmp     eax, 0FFFFFEC0h
    jge     short loc_41CBAC
    add     ecx, 140h
    jmp     short loc_41CBB3
    ; ---------------------------------------------------------------------------

    loc_41CBAC:                             ; CODE XREF: sub_41CA10+183j
                                            ; sub_41CA10+192j
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ecx, eax

    loc_41CBB3:                             ; CODE XREF: sub_41CA10+18Bj
                                            ; sub_41CA10+19Aj
    mov     [esi+1431Fh], ecx
    mov     ecx, TAdynmemStructPtr

    loc_41CBBF:                             ; CODE XREF: sub_41CA10+14Dj
    mov     eax, [ecx+14323h]
    mov     edx, [ecx+1432Bh]
    cmp     eax, edx
    jz      short loc_41CC4D
    or      [ecx+142F1h], di
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    mov     esi, TAdynmemStructPtr
    mov     ecx, [esi+14323h]
    mov     edi, [esi+1432Bh]
    mov     eax, ecx
    sub     eax, edi
    cmp     eax, ebp
    jle     short loc_41CC1F
    cmp     eax, 140h
    jle     short loc_41CC40
    add     ecx, 0FFFFFEC0h
    mov     [esi+14323h], ecx
    call    sub_41C6F0
    call    sub_41C3C0
    pop     edi
    pop     esi
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------

    loc_41CC1F:                             ; CODE XREF: sub_41CA10+1ECj
    cmp     eax, 0FFFFFEC0h
    jge     short loc_41CC40
    add     ecx, 140h
    mov     [esi+14323h], ecx
    call    sub_41C6F0
    call    sub_41C3C0
    pop     edi
    pop     esi
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------

    loc_41CC40:                             ; CODE XREF: sub_41CA10+1F3j
                                            ; sub_41CA10+214j
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ecx, eax
    mov     [esi+14323h], ecx

    loc_41CC4D:                             ; CODE XREF: sub_41CA10+1BDj
    call    sub_41C6F0
    call    sub_41C3C0
    pop     edi
    pop     esi
    pop     ebp
    retn
    sub_41CA10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41CC60 proc near                    ; CODE XREF: sub_499100+80p
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    push    ebx
    push    esi
    mov     [ecx+1434Bh], ax
    mov     edx, TAdynmemStructPtr
    push    edi
    mov     [edx+142F3h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F7h], eax
    call    sub_4C2470
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+2CDFh], 1
    mov     eax, TAdynmemStructPtr
    mov     ecx, 6
    lea     ebx, [edx+2CC7h]
    lea     esi, [eax+2C76h]
    mov     edi, ebx
    rep movsd
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+1431Fh]
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4
    mov     [ebx+24h], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14323h]
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4
    mov     [ebx+28h], eax
    call    sub_4B6700
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebx+1Ch], eax
    call    sub_4B6710
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebx+20h], eax
    push    eax                             ; Y
    mov     eax, [ebx+1Ch]
    push    eax                             ; X
    call    sub_4C22F0
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_41CC60 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+2CDFh], 0
    add     eax, 2CC7h
    mov     ecx, [eax+4]
    mov     edx, [eax]
    push    ecx
    push    edx

    unknown_libname_1:
    call    sub_4C22F0
    jmp     sub_4C2870
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41CD50 proc near                    ; CODE XREF: .text:00499391p

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= byte ptr -10h

    sub     esp, 1Ch
    push    ebx
    mov     ebx, TAdynmemStructPtr
    push    ebp
    push    esi
    push    edi
    mov     edx, [ebx+2CE7h]
    lea     esi, [ebx+2C76h]
    mov     ecx, 6
    lea     edi, [esp+2Ch+var_18]
    lea     ebp, [ebx+2CEBh]
    rep movsd
    mov     eax, [esp+2Ch+var_14]
    lea     edi, [ebx+2CE7h]
    sub     eax, edx
    lea     esi, [ebx+2CEFh]
    cdq
    and     edx, 3
    add     eax, edx
    lea     edx, [ebx+2CE3h]
    mov     ecx, eax
    mov     eax, [esi]
    sar     ecx, 2
    add     ecx, eax
    mov     eax, [esp+2Ch+var_18]
    sub     eax, [edx]
    mov     [esp+2Ch+var_1C], edx
    shl     ecx, 4
    cdq
    and     edx, 3
    add     eax, edx
    mov     edx, [ebp+0]
    sar     eax, 2
    add     eax, edx
    shl     eax, 4
    mov     [ebx+1431Fh], eax
    mov     eax, TAdynmemStructPtr
    mov     ebx, 2
    mov     [eax+14323h], ecx
    mov     eax, TAdynmemStructPtr
    or      [eax+142F1h], bx
    call    sub_41C3C0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1431Fh]
    mov     [eax+14327h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14323h]
    mov     [eax+1432Bh], edx
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+1431Fh]
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4
    mov     [ebp+0], eax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14323h]
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     edx, [edi]
    sar     eax, 4
    mov     [esi], eax
    mov     eax, [esp+2Ch+var_1C]
    push    edx                             ; Y
    mov     ecx, [eax]
    push    ecx                             ; X
    call    sub_4C22F0
    test    [esp+2Ch+var_10], bl
    jnz     short loc_41CE83
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+2CDFh], 0
    mov     ecx, [edx+2CCBh]
    lea     eax, [edx+2CC7h]
    push    ecx                             ; Y
    mov     edx, [eax]
    push    edx                             ; X
    call    sub_4C22F0
    call    sub_4C2870

    loc_41CE83:                             ; CODE XREF: sub_41CD50+107j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    sub_41CD50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41CE90 proc near                    ; CODE XREF: sub_496790+1E6p

    var_24= dword ptr -24h
    Point= tagPOINT ptr -20h
    var_18= dword ptr -18h
    var_14= dword ptr -14h

    mov     eax, TAdynmemStructPtr
    sub     esp, 24h
    push    ebx
    xor     ebx, ebx
    mov     bl, [eax+1434Dh]
    push    ebp
    imul    ebx, [eax+38A3Fh]
    push    esi
    cmp     ebx, 80h
    push    edi
    jle     short loc_41CEB8
    mov     ebx, 80h

    loc_41CEB8:                             ; CODE XREF: sub_41CE90+21j
    test    ebx, ebx
    jz      loc_41D0B0
    lea     eax, [esp+34h+var_18]
    push    eax
    call    sub_4C2340
    call    sub_4B6220
    mov     cl, [eax+0F0h]
    mov     [esp+34h+var_24], eax
    test    cl, 2
    jnz     loc_41D0B8
    lea     ecx, [esp+34h+Point]
    push    ecx                             ; lpPoint
    call    ds:GetCursorPos
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+34h+Point.x]
    mov     edx, [esp+34h+Point.y]
    mov     esi, [eax+37E1Fh]
    mov     edi, [eax+37E23h]
    cmp     ecx, esi
    jge     short loc_41CF0E
    cmp     edx, edi
    jl      short loc_41CF52

    loc_41CF0E:                             ; CODE XREF: sub_41CE90+78j
    lea     ebp, [esi+64h]
    cmp     ecx, ebp
    jge     short loc_41CF52
    lea     ecx, [edi+64h]
    cmp     edx, ecx
    jge     short loc_41CF52
    call    ds:GetFocus
    mov     edx, [esp+34h+var_24]
    cmp     eax, [edx+40h]
    jnz     short loc_41CF4D
    mov     eax, [esp+34h+Point.x]
    cmp     eax, esi
    mov     [esp+34h+var_18], eax
    jl      short loc_41CF3C
    dec     esi
    mov     [esp+34h+var_18], esi

    loc_41CF3C:                             ; CODE XREF: sub_41CE90+A5j
    mov     eax, [esp+34h+Point.y]
    cmp     eax, edi
    mov     [esp+34h+var_14], eax
    jl      short loc_41CF4D
    dec     edi
    mov     [esp+34h+var_14], edi

    loc_41CF4D:                             ; CODE XREF: sub_41CE90+99j
                                            ; sub_41CE90+B6j
    mov     eax, TAdynmemStructPtr

    loc_41CF52:                             ; CODE XREF: sub_41CE90+7Cj
                                            ; sub_41CE90+83j ...
    add     eax, 519h
    push    offset aTalk_gui                ; char *
    push    eax                             ; int
    call    sub_4AB060
    mov     ebp, eax
    mov     eax, TAdynmemStructPtr
    push    0F4h
    mov     edi, [eax+1431Fh]
    mov     esi, [eax+14323h]
    call    sub_4C1B80
    test    eax, eax
    jz      short loc_41CF87
    test    ebp, ebp
    jz      short loc_41CFA1

    loc_41CF87:                             ; CODE XREF: sub_41CE90+F1j
    mov     eax, [esp+34h+var_18]
    test    eax, eax
    jnz     short loc_41CFA5
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+34h+var_14]
    cmp     eax, [ecx+37E23h]
    jge     short loc_41CFA5

    loc_41CFA1:                             ; CODE XREF: sub_41CE90+F5j
    sub     edi, ebx
    jmp     short loc_41CFCE
    ; ---------------------------------------------------------------------------

    loc_41CFA5:                             ; CODE XREF: sub_41CE90+FDj
                                            ; sub_41CE90+10Fj
    push    0F6h
    call    sub_4C1B80
    test    eax, eax
    jz      short loc_41CFB7
    test    ebp, ebp
    jz      short loc_41CFCC

    loc_41CFB7:                             ; CODE XREF: sub_41CE90+121j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+34h+var_18]
    mov     eax, [edx+37E1Fh]
    dec     eax
    cmp     ecx, eax
    jnz     short loc_41CFCE

    loc_41CFCC:                             ; CODE XREF: sub_41CE90+125j
    add     edi, ebx

    loc_41CFCE:                             ; CODE XREF: sub_41CE90+113j
                                            ; sub_41CE90+13Aj
    push    0F5h
    call    sub_4C1B80
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jz      short loc_41CFE5
    test    ebp, ebp
    jz      short loc_41CFFB

    loc_41CFE5:                             ; CODE XREF: sub_41CE90+14Fj
    mov     ecx, [esp+34h+var_14]
    test    ecx, ecx
    jnz     short loc_41CFFF
    mov     ecx, [esp+34h+var_18]
    mov     edx, [eax+37E1Fh]
    cmp     ecx, edx
    jge     short loc_41CFFF

    loc_41CFFB:                             ; CODE XREF: sub_41CE90+153j
    sub     esi, ebx
    jmp     short loc_41D027
    ; ---------------------------------------------------------------------------

    loc_41CFFF:                             ; CODE XREF: sub_41CE90+15Bj
                                            ; sub_41CE90+169j
    push    0F7h
    call    sub_4C1B80
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jz      short loc_41D016
    test    ebp, ebp
    jz      short loc_41D025

    loc_41D016:                             ; CODE XREF: sub_41CE90+180j
    mov     edx, [eax+37E23h]
    mov     ecx, [esp+34h+var_14]
    dec     edx
    cmp     ecx, edx
    jnz     short loc_41D027

    loc_41D025:                             ; CODE XREF: sub_41CE90+184j
    add     esi, ebx

    loc_41D027:                             ; CODE XREF: sub_41CE90+16Dj
                                            ; sub_41CE90+193j
    cmp     [eax+1431Fh], edi
    jnz     short loc_41D037
    cmp     [eax+14323h], esi
    jz      short loc_41D0B0

    loc_41D037:                             ; CODE XREF: sub_41CE90+19Dj
    mov     [eax+1431Fh], edi
    mov     eax, TAdynmemStructPtr
    mov     [eax+14323h], esi
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 2
    call    sub_41C3C0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1431Fh]
    mov     [eax+14327h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14323h]
    mov     [eax+1432Bh], edx
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     [ecx+1434Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+142F3h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F7h], eax

    loc_41D0B0:                             ; CODE XREF: sub_41CE90+2Aj
                                            ; sub_41CE90+1A5j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn
    ; ---------------------------------------------------------------------------

    loc_41D0B8:                             ; CODE XREF: sub_41CE90+4Cj
    mov     eax, TAdynmemStructPtr
    mov     esi, [esp+34h+var_18]
    mov     ecx, [eax+37E1Fh]
    mov     edx, [eax+37E23h]
    cmp     esi, ecx
    jl      short loc_41D0D6
    dec     ecx
    mov     [esp+34h+var_18], ecx

    loc_41D0D6:                             ; CODE XREF: sub_41CE90+23Fj
    cmp     [esp+34h+var_14], edx
    jl      loc_41CF52
    dec     edx
    mov     [esp+34h+var_14], edx
    jmp     loc_41CF52
    sub_41CE90 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D0F0 proc near                    ; CODE XREF: .text:0049937Dp

    var_18= dword ptr -18h
    var_14= dword ptr -14h

    sub     esp, 18h
    mov     ecx, 6
    push    ebx
    mov     ebx, TAdynmemStructPtr
    push    esi
    push    edi
    lea     esi, [ebx+2C76h]
    lea     edi, [esp+24h+var_18]
    rep movsd
    movsx   ecx, word ptr [ebx+142E9h]
    mov     eax, [esp+24h+var_14]
    sub     eax, ecx
    imul    eax, [ebx+1422Fh]
    movsx   ecx, word ptr [ebx+142EDh]
    cdq
    idiv    ecx
    movsx   esi, word ptr [ebx+142EBh]
    mov     ecx, eax
    mov     eax, [ebx+37E3Bh]
    cdq
    sub     eax, edx
    movsx   edx, word ptr [ebx+142E7h]
    sar     eax, 1
    sub     ecx, eax
    mov     eax, [esp+24h+var_18]
    sub     eax, edx
    imul    eax, [ebx+1422Bh]
    cdq
    idiv    esi
    mov     esi, eax
    mov     eax, [ebx+37E37h]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     esi, eax
    mov     [ebx+1431Fh], esi
    mov     eax, TAdynmemStructPtr
    mov     [eax+14323h], ecx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 2
    call    sub_41C3C0
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebx
    mov     ecx, [eax+1431Fh]
    mov     [eax+14327h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14323h]
    mov     [eax+1432Bh], edx
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     [ecx+1434Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+142F3h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F7h], eax
    add     esp, 18h
    retn
    sub_41D0F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D1F0 proc near                    ; CODE XREF: sub_497180+9C5p
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    xor     eax, eax
    mov     edx, [edi+391E9h]
    mov     ecx, [edx+0DB4h]
    mov     edx, [edx+0DB8h]
    test    edx, edx
    jle     loc_41D2A0

    loc_41D214:                             ; CODE XREF: sub_41D1F0+36j
    cmp     dword ptr [ecx], 1
    jnz     short loc_41D220
    mov     esi, [ecx+4]
    test    esi, esi
    jz      short loc_41D22B

    loc_41D220:                             ; CODE XREF: sub_41D1F0+27j
    inc     eax
    add     ecx, 0Ch
    cmp     eax, edx
    jl      short loc_41D214
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_41D22B:                             ; CODE XREF: sub_41D1F0+2Ej
    mov     eax, [edi+37E3Bh]
    movsx   esi, word ptr [ecx+0Ah]
    cdq
    sub     eax, edx
    sar     eax, 1
    movsx   ecx, word ptr [ecx+8]
    sub     esi, eax
    mov     eax, [edi+37E37h]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ecx, eax
    mov     [edi+1431Fh], ecx
    mov     edx, TAdynmemStructPtr
    mov     [edx+14323h], esi
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 2
    call    sub_41C3C0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1431Fh]
    mov     [eax+14327h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14323h]
    mov     [eax+1432Bh], edx
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h

    loc_41D2A0:                             ; CODE XREF: sub_41D1F0+1Ej
    pop     edi
    pop     esi
    retn
    sub_41D1F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D2B0 proc near                    ; CODE XREF: sub_432610+44p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    push    offset aCamera                  ; char *
    mov     ecx, esi
    call    sub_4B4560
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14323h]
    push    ecx                             ; int
    push    offset aZPosition               ; char *
    mov     ecx, esi
    call    sub_4B4800
    mov     edx, TAdynmemStructPtr
    mov     edi, eax
    mov     ecx, esi
    mov     eax, [edx+1431Fh]
    push    eax                             ; int
    push    offset aXPosition               ; char *
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+1431Fh], eax
    mov     edx, TAdynmemStructPtr
    mov     [edx+14323h], edi
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 2
    call    sub_41C3C0
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    mov     ecx, [eax+1431Fh]
    mov     [eax+14327h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14323h]
    mov     [eax+1432Bh], edx
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    retn    4
    sub_41D2B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D360 proc near                    ; CODE XREF: sub_4326B0+33Dp

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    offset aCamera                  ; char *
    mov     ecx, esi
    call    sub_4B4560
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1431Fh]
    push    ecx                             ; int
    push    offset aXPosition               ; char *
    mov     ecx, esi
    call    sub_4B4630
    mov     edx, TAdynmemStructPtr
    mov     ecx, esi
    mov     eax, [edx+14323h]
    push    eax                             ; int
    push    offset aZPosition               ; char *
    call    sub_4B4630
    pop     esi
    retn    4
    sub_41D360 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D3B0 proc near                    ; CODE XREF: sub_496020+12p

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+arg_0]
    mov     edx, [ecx+1431Fh]
    mov     [ecx+eax*4+142FBh], edx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14323h]
    mov     [ecx+eax*4+1430Bh], edx
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [eax+ecx+1431Bh], 1
    retn    4
    sub_41D3B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D3F0 proc near                    ; CODE XREF: sub_49603C+12p

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    lea     eax, [ecx+1431Bh]
    test    eax, eax
    jz      locret_41D48E
    xor     eax, eax
    mov     [ecx+1434Bh], ax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F3h], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+arg_0]
    mov     [edx+142F7h], eax
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+ecx*4+1430Bh]
    mov     ecx, [eax+ecx*4+142FBh]
    mov     [eax+1431Fh], ecx
    mov     eax, TAdynmemStructPtr
    mov     [eax+14323h], edx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 2
    call    sub_41C3C0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1431Fh]
    mov     [eax+14327h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14323h]
    mov     [eax+1432Bh], edx
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h

    locret_41D48E:                          ; CODE XREF: sub_41D3F0+Ej
    retn    4
    sub_41D3F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D4A0 proc near                    ; CODE XREF: sub_49EE30+35Dp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     dword_502898, eax
    retn    4
    sub_41D4A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D4B0 proc near                    ; CODE XREF: sub_49EE30+307p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     dword_511DE0, eax
    retn    4
    sub_41D4B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D4C0 proc near                    ; CODE XREF: sub_41EC50+321p
                                            ; sub_425D80+8Bp ...

    var_25C= dword ptr -25Ch
    var_258= dword ptr -258h
    FileName= byte ptr -244h
    var_140= dword ptr -140h
    var_100= dword ptr -100h

    mov     eax, dword_50289C
    sub     esp, 25Ch
    test    eax, eax
    jz      loc_41D690
    push    edi
    push    esi
    push    ebx
    call    sub_4BE180
    call    sub_49F540
    push    offset a31                      ; "31"
    lea     eax, [esp+26Ch+var_140]
    push    offset aRevS_gp3                ; "rev%s.GP3"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+268h+var_258]
    lea     edx, [esp+268h+var_140]
    push    1
    push    0FFFFFFFFh
    push    ecx
    push    edx
    call    sub_4BC4B0
    mov     esi, eax
    test    esi, esi
    jl      short loc_41D537

    loc_41D516:                             ; CODE XREF: sub_41D4C0+6Fj
    lea     eax, [esp+268h+FileName]
    push    1                               ; int
    push    eax                             ; lpFileName
    call    sub_4BE0B0
    lea     ecx, [esp+268h+var_258]
    push    ecx
    push    esi
    call    sub_4BC640
    test    eax, eax
    jz      short loc_41D516
    push    esi
    call    sub_4BC8D0

    loc_41D537:                             ; CODE XREF: sub_41D4C0+54j
    push    1
    lea     edx, [esp+26Ch+var_258]
    push    0FFFFFFFFh
    push    edx
    push    offset a_ccx                    ; "*.CCX"
    call    sub_4BC4B0
    mov     esi, eax
    test    esi, esi
    jl      short loc_41D571

    loc_41D550:                             ; CODE XREF: sub_41D4C0+A9j
    lea     eax, [esp+268h+FileName]
    push    1                               ; int
    push    eax                             ; lpFileName
    call    sub_4BE0B0
    lea     ecx, [esp+268h+var_258]
    push    ecx
    push    esi
    call    sub_4BC640
    test    eax, eax
    jz      short loc_41D550
    push    esi
    call    sub_4BC8D0

    loc_41D571:                             ; CODE XREF: sub_41D4C0+8Ej
    push    1
    lea     edx, [esp+26Ch+var_258]
    push    0FFFFFFFFh
    push    edx
    push    offset a_ufo                    ; "*.UFO"
    call    sub_4BC4B0
    mov     esi, eax
    test    esi, esi
    jl      short loc_41D5AB

    loc_41D58A:                             ; CODE XREF: sub_41D4C0+E3j
    lea     eax, [esp+268h+FileName]
    push    0                               ; int
    push    eax                             ; lpFileName
    call    sub_4BE0B0
    lea     ecx, [esp+268h+var_258]
    push    ecx
    push    esi
    call    sub_4BC640
    test    eax, eax
    jz      short loc_41D58A
    push    esi
    call    sub_4BC8D0

    loc_41D5AB:                             ; CODE XREF: sub_41D4C0+C8j
    push    1
    lea     edx, [esp+26Ch+var_258]
    push    0FFFFFFFFh
    push    edx
    push    offset a_hpi                    ; "*.HPI"
    call    sub_4BC4B0
    mov     edi, eax
    mov     esi, 0Ah
    test    edi, edi
    jl      short loc_41D5F3

    loc_41D5C9:                             ; CODE XREF: sub_41D4C0+12Bj
    lea     eax, [esp+268h+FileName]
    push    0                               ; int
    push    eax                             ; lpFileName
    call    sub_4BE0B0
    test    eax, eax
    jz      short loc_41D5DA
    dec     esi

    loc_41D5DA:                             ; CODE XREF: sub_41D4C0+117j
    lea     ecx, [esp+268h+var_258]
    push    ecx
    push    edi
    call    sub_4BC640
    test    eax, eax
    jnz     short loc_41D5ED
    test    esi, esi
    jnz     short loc_41D5C9

    loc_41D5ED:                             ; CODE XREF: sub_41D4C0+127j
    push    edi
    call    sub_4BC8D0

    loc_41D5F3:                             ; CODE XREF: sub_41D4C0+107j
    mov     byte ptr [esp+268h+var_25C], 0

    loc_41D5F8:                             ; CODE XREF: sub_41D4C0+1C2j
    mov     edx, [esp+268h+var_25C]
    push    edx
    call    sub_4BB190
    mov     bl, al
    test    bl, bl
    mov     byte ptr [esp+268h+var_25C], bl
    jz      short loc_41D688
    movsx   edi, bl
    push    edi
    lea     eax, [esp+26Ch+var_100]
    push    offset aC_hpi                   ; "%c:\\*.hpi"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+268h+var_258]
    lea     edx, [esp+268h+var_100]
    push    1
    push    0FFFFFFFFh
    push    ecx
    push    edx
    call    sub_4BC4B0
    mov     esi, eax
    test    esi, esi
    jl      short loc_41D680

    loc_41D641:                             ; CODE XREF: sub_41D4C0+1B8j
    lea     eax, [esp+268h+FileName]
    lea     ecx, [esp+268h+var_100]
    push    eax
    push    edi
    push    offset aCS                      ; "%c:\\%s"
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+268h+var_100]
    push    0                               ; int
    push    edx                             ; lpFileName
    call    sub_4BE0B0
    lea     eax, [esp+268h+var_258]
    push    eax
    push    esi
    call    sub_4BC640
    test    eax, eax
    jz      short loc_41D641
    push    esi
    call    sub_4BC8D0

    loc_41D680:                             ; CODE XREF: sub_41D4C0+17Fj
    test    bl, bl
    jnz     loc_41D5F8

    loc_41D688:                             ; CODE XREF: sub_41D4C0+14Aj
    call    sub_4BE320
    pop     ebx
    pop     esi
    pop     edi

    loc_41D690:                             ; CODE XREF: sub_41D4C0+Dj
    add     esp, 25Ch
    retn
    sub_41D4C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D6A0 proc near                    ; CODE XREF: sub_41D7B0+14p
                                            ; sub_41EC50+2E0p ...

    var_110= dword ptr -110h
    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_100= dword ptr -100h
    arg_0= dword ptr  4

    mov     eax, dword_50289C
    sub     esp, 110h
    test    eax, eax
    push    ebx
    push    esi
    push    edi
    jnz     short loc_41D6C0
    mov     al, 63h
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 110h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41D6C0:                             ; CODE XREF: sub_41D6A0+10j
    mov     eax, [esp+11Ch+arg_0]
    sub     eax, 0
    jz      short loc_41D6DA
    dec     eax
    jnz     loc_41D7A1
    mov     esi, offset aMultiplayer        ; "Multiplayer"
    jmp     short loc_41D6DF
    ; ---------------------------------------------------------------------------

    loc_41D6DA:                             ; CODE XREF: sub_41D6A0+2Aj
    mov     esi, offset aCampaign           ; "Campaign"

    loc_41D6DF:                             ; CODE XREF: sub_41D6A0+38j
    xor     bl, bl
    mov     edi, 1
    mov     byte ptr [esp+11Ch+var_110], bl

    loc_41D6EA:                             ; CODE XREF: sub_41D6A0+E5j
    mov     eax, dword_511DE0
    test    eax, eax
    jz      short loc_41D6FF
    neg     bl
    sbb     bl, bl
    and     bl, 98h
    add     bl, 68h
    jmp     short loc_41D70B
    ; ---------------------------------------------------------------------------

    loc_41D6FF:                             ; CODE XREF: sub_41D6A0+51j
    mov     eax, [esp+11Ch+var_110]
    push    eax
    call    sub_4BB190
    mov     bl, al

    loc_41D70B:                             ; CODE XREF: sub_41D6A0+5Dj
    test    bl, bl
    mov     byte ptr [esp+11Ch+var_110], bl
    jz      loc_41D7A1
    movsx   ecx, bl
    push    ecx
    lea     edx, [esp+120h+var_100]
    push    offset aCTotala_id              ; "%c:\\TOTALA.ID"
    push    edx
    call    _sprintf
    mov     al, byte ptr [esp+128h+var_100]
    add     esp, 0Ch
    cmp     al, bl
    jz      short loc_41D73B
    mov     dword_511DE4, edi

    loc_41D73B:                             ; CODE XREF: sub_41D6A0+93j
    lea     ecx, [esp+11Ch+var_10C]
    call    sub_4C2EA0
    lea     eax, [esp+11Ch+var_100]
    lea     ecx, [esp+11Ch+var_10C]
    push    eax
    call    sub_4C2F60
    test    eax, eax
    jz      short loc_41D778
    push    offset aContents                ; char *
    lea     ecx, [esp+120h+var_10C]
    call    sub_4C3410
    test    eax, eax
    jz      short loc_41D778
    mov     ecx, [esp+11Ch+var_108]
    push    0                               ; int
    push    esi                             ; char *
    call    sub_4C46C0
    test    eax, eax
    jnz     short loc_41D78A

    loc_41D778:                             ; CODE XREF: sub_41D6A0+B4j
                                            ; sub_41D6A0+C6j
    lea     ecx, [esp+11Ch+var_10C]
    call    sub_4C2EB0
    test    bl, bl
    jz      short loc_41D7A1
    jmp     loc_41D6EA
    ; ---------------------------------------------------------------------------

    loc_41D78A:                             ; CODE XREF: sub_41D6A0+D6j
    lea     ecx, [esp+11Ch+var_10C]
    call    sub_4C2EB0
    mov     al, bl
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 110h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41D7A1:                             ; CODE XREF: sub_41D6A0+2Dj
                                            ; sub_41D6A0+71j ...
    pop     edi
    pop     esi
    xor     al, al
    pop     ebx
    add     esp, 110h
    retn    4
    sub_41D6A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D7B0 proc near                    ; CODE XREF: .text:004267A2p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, dword_50289C
    push    ebx
    push    ebp
    push    esi
    test    eax, eax
    push    edi
    jz      loc_41D875
    xor     esi, esi

    loc_41D7C3:                             ; CODE XREF: sub_41D7B0+21j
    push    esi
    call    sub_41D6A0
    test    al, al
    jnz     short loc_41D7E7
    inc     esi
    cmp     esi, 2
    jl      short loc_41D7C3
    test    al, al
    jnz     short loc_41D7E7
    mov     eax, [esp+10h+arg_0]
    mov     byte ptr [eax], 0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_41D7E7:                             ; CODE XREF: sub_41D7B0+1Bj
                                            ; sub_41D7B0+25j
    mov     ecx, [esp+10h+arg_8]
    mov     edx, [esp+10h+arg_4]
    mov     ebx, [esp+10h+arg_0]
    push    ecx
    movsx   eax, al
    push    edx
    push    eax
    push    offset aCSS                     ; "%c:\\%s\\%s"
    push    ebx
    call    _sprintf
    add     esp, 14h
    push    ebx
    call    sub_4BB0F0
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [esp+10h+arg_C]
    mov     edi, edx
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_41D86C
    mov     edi, offset Directory
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_41D86C:                             ; CODE XREF: sub_41D7B0+6Dj
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_41D875:                             ; CODE XREF: sub_41D7B0+Bj
    mov     eax, [esp+10h+arg_C]
    mov     ecx, [esp+10h+arg_8]
    mov     edx, [esp+10h+arg_4]
    push    eax
    mov     eax, [esp+14h+arg_0]
    push    ecx
    push    edx
    push    eax
    call    sub_4290F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_41D7B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D8A0 proc near                    ; CODE XREF: sub_42A8D0+EAp
                                            ; sub_42A8D0+7E7p ...
    mov     eax, dword_50289C
    retn
    sub_41D8A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D8B0 proc near                    ; CODE XREF: sub_42A8D0+7F0p
                                            ; sub_490360+13p
    mov     eax, dword_511DE4
    retn
    sub_41D8B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    push    edi
    call    ds:__imp_GetTickCount
    xor     edx, edx
    mov     ecx, 3E8h
    div     ecx
    mov     esi, edx
    shl     esi, 3
    sub     esi, edx
    mov     edx, [esp+10h]
    lea     edi, [esi+edx]
    push    edi
    call    sub_4B4F10
    mov     ecx, edi
    mov     ebx, eax
    mov     edx, ecx
    xor     eax, eax
    mov     edi, ebx
    add     esp, 4
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    push    ebx
    and     ecx, 3
    rep stosb
    call    nullsub_23
    add     esp, 4
    lea     eax, [ebx+esi]
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D920 proc near                    ; CODE XREF: sub_49E830+42p
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    ds:__imp_GetTickCount
    xor     edx, edx
    mov     ecx, 3E8h
    div     ecx
    mov     esi, edx
    shl     esi, 3
    sub     esi, edx
    lea     edi, [esi+3924Dh]
    push    edi                             ; int
    call    sub_4B4F10
    mov     ecx, edi
    mov     ebx, eax
    mov     edx, ecx
    xor     eax, eax
    mov     edi, ebx
    add     esp, 4
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    push    ebx
    and     ecx, 3
    rep stosb
    call    nullsub_23
    add     esi, ebx
    xor     ebp, ebp
    add     esp, 4
    cmp     esi, ebp
    jz      short loc_41D9E0
    mov     dword ptr [esi+4], offset aJul301998 ; "Jul 30 1998"
    mov     dword ptr [esi+8], offset a111636 ; "11:16:36"
    lea     edi, [esi+1B63h]
    mov     ebx, 0Bh

    loc_41D989:                             ; CODE XREF: sub_41D920+77j
    mov     ecx, edi
    call    sub_463BE0
    add     edi, 14Bh
    dec     ebx
    jnz     short loc_41D989
    mov     [esi+14293h], ebp
    mov     [esi+14297h], ebp
    mov     [esi+1429Bh], ebp
    mov     [esi+1428Fh], ebp
    mov     [esi+142A3h], ebp
    mov     [esi+142A7h], ebp
    mov     [esi+142ABh], ebp
    mov     [esi+1429Fh], ebp
    mov     [esi+142AFh], ebp
    mov     [esi+142B3h], ebp
    mov     TAdynmemStructPtr, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_41D9E0:                             ; CODE XREF: sub_41D920+4Ej
    pop     edi
    mov     TAdynmemStructPtr, ebp
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_41D920 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41D9F0 proc near                    ; CODE XREF: .text:004996F0p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     [ecx+39057h], eax
    retn    4
    sub_41D9F0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+0Ch]
    mov     ecx, [esp+8]
    mov     edx, [esp+4]
    neg     eax
    sbb     al, al
    and     al, 0Bh
    add     al, 4Ch
    mov     [ecx+edx], al
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41DA30 proc near                    ; CODE XREF: .text:00477BC8p
                                            ; sub_47AE60+237p ...
    mov     edx, TAdynmemStructPtr
    push    edi
    mov     ecx, 6
    mov     eax, 55555555h
    lea     edi, [edx+391CFh]
    rep stosd
    stosb
    mov     eax, TAdynmemStructPtr
    pop     edi
    mov     byte ptr [eax+391E8h], 0
    retn
    sub_41DA30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41DA60 proc near                    ; CODE XREF: .text:0041FC12p

    var_100= dword ptr -100h
    var_F8= byte ptr -0F8h

    sub     esp, 100h
    push    esi
    push    edi
    push    400h
    push    offset aFadetable               ; "FadeTable"
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    push    400h
    push    offset aDesiredpalette          ; "desiredPalette"
    mov     [ecx+3908Bh], eax
    call    sub_4D83B0
    mov     edx, TAdynmemStructPtr
    add     esp, 8
    push    400h
    push    offset aCurrentpalette          ; "currentPalette"
    mov     [edx+39087h], eax
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [ecx+39083h], eax
    call    sub_4B6220
    mov     ecx, TAdynmemStructPtr
    mov     edx, [eax+614h]
    push    400h
    push    offset aPalette                 ; "Palette"
    mov     [ecx+3906Fh], edx
    mov     dword ptr [eax+614h], 3F800000h
    call    sub_4D83B0
    mov     edx, TAdynmemStructPtr
    add     esp, 8
    mov     edi, eax
    mov     ecx, [edx+391E9h]
    push    5
    call    sub_4356C0
    mov     esi, eax
    test    esi, esi
    jnz     short loc_41DB1B
    mov     eax, TAdynmemStructPtr
    mov     [eax+3907Bh], esi

    loc_41DB1B:                             ; CODE XREF: sub_41DA60+AEj
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 1
    mov     eax, TAdynmemStructPtr
    jnz     loc_41DBD7
    test    byte ptr [eax+3923Bh], 10h
    jz      loc_41DBD7
    test    esi, esi
    jz      loc_41DBD7
    inc     esi
    push    offset aPcx                     ; "PCX"
    push    esi
    lea     edx, [esp+110h+var_100]
    push    offset aBitmapsGlamour          ; "bitmaps\\glamour"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+108h+var_100]
    push    eax
    call    sub_4BBC40
    test    eax, eax
    push    100h                            ; size_t
    jnz     short loc_41DB8C
    mov     ecx, TAdynmemStructPtr
    push    offset aGlamourArm01_p          ; "glamour\\Arm01.PCX"
    add     ecx, 3908Fh
    push    ecx
    jmp     short loc_41DB9C
    ; ---------------------------------------------------------------------------

    loc_41DB8C:                             ; CODE XREF: sub_41DA60+116j
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+10Ch+var_F8]
    add     eax, 3908Fh
    push    edx                             ; char *
    push    eax                             ; char *

    loc_41DB9C:                             ; CODE XREF: sub_41DA60+12Aj
    call    _strncpy
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    add     ecx, 3908Fh
    push    edi
    push    ecx
    call    sub_429290
    mov     edx, TAdynmemStructPtr
    mov     [edx+3907Bh], eax
    mov     eax, TAdynmemStructPtr
    mov     [eax+3907Fh], edi
    pop     edi
    pop     esi
    add     esp, 100h
    retn
    ; ---------------------------------------------------------------------------

    loc_41DBD7:                             ; CODE XREF: sub_41DA60+D4j
                                            ; sub_41DA60+E1j ...
    mov     ecx, [eax+391E9h]
    call    sub_435100
    push    1
    cmp     eax, 1
    push    0
    push    0
    jnz     short loc_41DC00
    push    offset aOutcome1                ; "Outcome1"
    call    sub_4288D0
    pop     edi
    pop     esi
    add     esp, 100h
    retn
    ; ---------------------------------------------------------------------------

    loc_41DC00:                             ; CODE XREF: sub_41DA60+18Bj
    push    offset aOutcome0                ; "Outcome0"
    call    sub_4288D0
    pop     edi
    pop     esi
    add     esp, 100h
    retn
    sub_41DA60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_41DC20 proc near                    ; CODE XREF: sub_491B60+2Bp

    var_C= dword ptr -0Ch
    var_8= qword ptr -8

    push    ebp
    mov     ebp, esp
    and     esp, 0FFFFFFF8h
    mov     eax, TAdynmemStructPtr
    sub     esp, 10h
    mov     cl, [eax+3923Bh]
    push    ebx
    shr     ecx, 4
    and     ecx, 1
    push    ebp
    mov     [eax+391AFh], ecx
    mov     edx, TAdynmemStructPtr
    push    esi
    push    edi
    mov     ecx, [edx+391E9h]
    lea     esi, [eax+38DD9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_41DC9E
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435C50
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+391ABh], eax
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+391AFh]
    mov     ecx, [eax+391ABh]
    neg     edx
    sbb     dl, dl
    and     dl, 0Bh
    add     dl, 4Ch
    mov     [ecx+eax+391CFh], dl

    loc_41DC9E:                             ; CODE XREF: sub_41DC20+3Ej
    mov     edx, TAdynmemStructPtr
    mov     eax, 0Ah
    mov     edi, esi
    xor     ebx, ebx
    mov     [edx+3918Fh], eax
    mov     ecx, TAdynmemStructPtr
    xor     ebp, ebp
    mov     [ecx+39193h], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, 64h
    mov     [edx+39197h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+3919Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     [edx+3919Fh], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+391A3h], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, 91h
    mov     [edx+391A7h], eax
    xor     eax, eax
    rep stosd
    mov     eax, TAdynmemStructPtr
    add     esi, 1Eh

    loc_41DD13:                             ; CODE XREF: sub_41DC20+2ABj
    mov     ecx, [eax+ebp+1B63h]
    lea     edi, [eax+ebp+1B63h]
    cmp     ecx, ebx
    jz      short loc_41DD4C
    mov     cl, [edi+73h]
    cmp     cl, 1
    jz      short loc_41DD37
    cmp     cl, 2
    jz      short loc_41DD37
    cmp     cl, 3
    jnz     short loc_41DD4C

    loc_41DD37:                             ; CODE XREF: sub_41DC20+10Bj
                                            ; sub_41DC20+110j
    cmp     byte ptr [edi+146h], 0Ah
    jz      short loc_41DD4C
    mov     ecx, [edi+27h]
    test    byte ptr [ecx+9Bh], 40h
    jz      short loc_41DD58

    loc_41DD4C:                             ; CODE XREF: sub_41DC20+103j
                                            ; sub_41DC20+115j ...
    cmp     [edi+140h], ebx
    jz      loc_41DEBC

    loc_41DD58:                             ; CODE XREF: sub_41DC20+12Aj
    cmp     [edi+22h], bl
    jnz     loc_41DEBC
    lea     edx, [edi+2Bh]
    push    1Eh                             ; size_t
    lea     eax, [esi-1Eh]
    push    edx                             ; char *
    push    eax                             ; char *
    call    _strncpy
    movsx   ecx, word ptr [edi+0FCh]
    mov     [esi], ecx
    add     esp, 0Ch
    movsx   edx, word ptr [edi+0FEh]
    mov     [esi+4], edx
    fld     qword ptr [edi+0ACh]
    call    __ftol
    mov     [esi+8], eax
    fld     qword ptr [edi+0B4h]
    call    __ftol
    mov     [esi+0Ch], eax
    fld     qword ptr [edi+0CCh]
    call    __ftol
    mov     [esi+10h], eax
    fld     qword ptr [edi+0D4h]
    call    __ftol
    mov     [esi+14h], eax
    mov     ecx, TAdynmemStructPtr
    mov     eax, 88888889h
    mov     dword ptr [esp+20h+var_8+4], ebx
    mul     dword ptr [ecx+38A47h]
    mov     edi, [ecx+391E9h]
    shr     edx, 5
    mov     dword ptr [esp+20h+var_8], edx
    fild    [esp+20h+var_8]
    fmul    dword ptr [edi+0D58h]
    call    __ftol
    fild    dword ptr [esi]
    mov     edx, eax
    mov     [esp+20h+var_C], edx
    fmul    dword ptr [edi+0D54h]
    call    __ftol
    mov     ecx, [esp+20h+var_C]
    add     eax, ecx
    cmp     eax, ebx
    mov     [esi+18h], eax
    jge     short loc_41DE12
    mov     [esi+18h], ebx

    loc_41DE12:                             ; CODE XREF: sub_41DC20+1EDj
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esi]
    cmp     ecx, [eax+3918Fh]
    jle     short loc_41DE2C
    mov     [eax+3918Fh], ecx
    mov     eax, TAdynmemStructPtr

    loc_41DE2C:                             ; CODE XREF: sub_41DC20+1FFj
    mov     ecx, [esi+4]
    mov     edx, [eax+39193h]
    cmp     ecx, edx
    jle     short loc_41DE44
    mov     [eax+39193h], ecx
    mov     eax, TAdynmemStructPtr

    loc_41DE44:                             ; CODE XREF: sub_41DC20+217j
    mov     ecx, [esi+8]
    mov     edx, [eax+39197h]
    cmp     ecx, edx
    jle     short loc_41DE5C
    mov     [eax+39197h], ecx
    mov     eax, TAdynmemStructPtr

    loc_41DE5C:                             ; CODE XREF: sub_41DC20+22Fj
    mov     ecx, [esi+0Ch]
    mov     edx, [eax+3919Bh]
    cmp     ecx, edx
    jle     short loc_41DE74
    mov     [eax+3919Bh], ecx
    mov     eax, TAdynmemStructPtr

    loc_41DE74:                             ; CODE XREF: sub_41DC20+247j
    mov     ecx, [esi+10h]
    mov     edx, [eax+3919Fh]
    cmp     ecx, edx
    jle     short loc_41DE8C
    mov     [eax+3919Fh], ecx
    mov     eax, TAdynmemStructPtr

    loc_41DE8C:                             ; CODE XREF: sub_41DC20+25Fj
    mov     ecx, [esi+14h]
    mov     edx, [eax+391A3h]
    cmp     ecx, edx
    jle     short loc_41DEA4
    mov     [eax+391A3h], ecx
    mov     eax, TAdynmemStructPtr

    loc_41DEA4:                             ; CODE XREF: sub_41DC20+277j
    mov     ecx, [esi+18h]
    mov     edx, [eax+391A7h]
    cmp     ecx, edx
    jle     short loc_41DEBC
    mov     [eax+391A7h], ecx
    mov     eax, TAdynmemStructPtr

    loc_41DEBC:                             ; CODE XREF: sub_41DC20+132j
                                            ; sub_41DC20+13Bj ...
    add     ebp, 14Bh
    add     esi, 3Ah
    cmp     ebp, 0CEEh
    jl      loc_41DD13
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    sub_41DC20 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+39067h], 0Ah
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    inc     eax
    mov     [ecx+3905Fh], eax
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+39063h], 0
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 10h
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [esp+4], 0
    mov     dword ptr [esp+0], 0
    mov     ecx, [eax+37E1Fh]
    mov     [esp+8], ecx
    mov     edx, [eax+37E23h]
    mov     [esp+0Ch], edx
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+3905Fh], eax
    jnb     short loc_41DFB2
    mov     eax, [ecx+39067h]
    lea     ecx, [esp+0]
    sub     eax, 1Dh
    push    eax
    push    ecx
    push    0
    call    sub_4BF4D0
    call    sub_4B6340
    mov     edx, TAdynmemStructPtr
    inc     eax
    mov     [edx+3905Fh], eax
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+39067h]
    dec     edx
    mov     [eax+39067h], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+39067h]
    test    ecx, ecx
    jnz     short loc_41DFB2
    mov     dword ptr [eax+39063h], 1

    loc_41DFB2:                             ; CODE XREF: .text:0041DF5Dj
                                            ; .text:0041DFA6j
    add     esp, 10h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41DFC0 proc near                    ; CODE XREF: .text:0041FD55p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+0Ch+arg_4]
    push    ebp
    mov     ebp, [esp+10h+arg_0]
    push    esi
    push    edi
    mov     edi, [eax+39087h]
    mov     ecx, 100h
    mov     esi, ebp
    rep movsd
    mov     edx, TAdynmemStructPtr
    mov     ecx, 100h
    mov     esi, ebx
    push    100h
    mov     edi, [edx+39083h]
    push    0
    rep movsd
    push    ebx
    call    sub_4BA200
    mov     eax, TAdynmemStructPtr
    lea     ecx, [ebx+3]
    or      esi, 0FFFFFFFFh
    sub     ebx, ebp
    sub     esi, ebp
    lea     edi, [ebp+1]
    mov     ebp, [esp+18h+arg_8]
    mov     dword ptr [eax+39063h], 0
    mov     [esp+18h+arg_0], ecx
    mov     [esp+18h+var_8], ebx
    mov     [esp+18h+var_4], esi
    mov     [esp+18h+arg_4], 100h
    jmp     short loc_41E043
    ; ---------------------------------------------------------------------------

    loc_41E03B:                             ; CODE XREF: sub_41DFC0+269j
    mov     ebx, [esp+18h+var_8]
    mov     esi, [esp+18h+var_4]

    loc_41E043:                             ; CODE XREF: sub_41DFC0+79j
    mov     edx, [esp+18h+arg_0]
    mov     al, [edi-1]
    mov     cl, [edx-3]
    cmp     cl, al
    jbe     short loc_41E07C
    and     eax, 0FFh
    and     ecx, 0FFh
    sub     eax, ecx
    cdq
    idiv    ebp
    cmp     eax, 0FFFFFFFFh
    jle     short loc_41E069
    or      eax, 0FFFFFFFFh

    loc_41E069:                             ; CODE XREF: sub_41DFC0+A4j
    mov     ecx, TAdynmemStructPtr
    add     esi, edi
    mov     edx, [ecx+3908Bh]
    mov     [edx+esi], al
    jmp     short loc_41E0BC
    ; ---------------------------------------------------------------------------

    loc_41E07C:                             ; CODE XREF: sub_41DFC0+8Fj
    jnz     short loc_41E091
    mov     eax, TAdynmemStructPtr
    add     esi, edi
    mov     ecx, [eax+3908Bh]
    mov     byte ptr [ecx+esi], 0
    jmp     short loc_41E0BC
    ; ---------------------------------------------------------------------------

    loc_41E091:                             ; CODE XREF: sub_41DFC0+BCj
    and     eax, 0FFh
    and     ecx, 0FFh
    sub     eax, ecx
    cdq
    idiv    ebp
    cmp     eax, 1
    jge     short loc_41E0AB
    mov     eax, 1

    loc_41E0AB:                             ; CODE XREF: sub_41DFC0+E4j
    mov     edx, TAdynmemStructPtr
    add     esi, edi
    mov     ecx, [edx+3908Bh]
    mov     [ecx+esi], al

    loc_41E0BC:                             ; CODE XREF: sub_41DFC0+BAj
                                            ; sub_41DFC0+CFj
    mov     cl, [ebx+edi]
    mov     al, [edi]
    cmp     cl, al
    jbe     short loc_41E0EF
    and     ecx, 0FFh
    and     eax, 0FFh
    sub     eax, ecx
    cdq
    idiv    ebp
    cmp     eax, 0FFFFFFFFh
    jle     short loc_41E0DD
    or      eax, 0FFFFFFFFh

    loc_41E0DD:                             ; CODE XREF: sub_41DFC0+118j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+3908Bh]
    mov     [ecx+esi+1], al
    jmp     short loc_41E12E
    ; ---------------------------------------------------------------------------

    loc_41E0EF:                             ; CODE XREF: sub_41DFC0+103j
    jnz     short loc_41E104
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+3908Bh]
    mov     byte ptr [eax+esi+1], 0
    jmp     short loc_41E12E
    ; ---------------------------------------------------------------------------

    loc_41E104:                             ; CODE XREF: sub_41DFC0+12Fj
    and     ecx, 0FFh
    and     eax, 0FFh
    sub     eax, ecx
    cdq
    idiv    ebp
    cmp     eax, 1
    jge     short loc_41E11E
    mov     eax, 1

    loc_41E11E:                             ; CODE XREF: sub_41DFC0+157j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+3908Bh]
    mov     [edx+esi+1], al

    loc_41E12E:                             ; CODE XREF: sub_41DFC0+12Dj
                                            ; sub_41DFC0+142j
    mov     ebx, [esp+18h+arg_0]
    mov     al, [edi+1]
    mov     cl, [ebx-1]
    cmp     cl, al
    jbe     short loc_41E166
    and     eax, 0FFh
    and     ecx, 0FFh
    sub     eax, ecx
    cdq
    idiv    ebp
    cmp     eax, 0FFFFFFFFh
    jle     short loc_41E154
    or      eax, 0FFFFFFFFh

    loc_41E154:                             ; CODE XREF: sub_41DFC0+18Fj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+3908Bh]
    mov     [edx+esi+2], al
    jmp     short loc_41E1A4
    ; ---------------------------------------------------------------------------

    loc_41E166:                             ; CODE XREF: sub_41DFC0+17Aj
    jnz     short loc_41E17A
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+3908Bh]
    mov     byte ptr [ecx+esi+2], 0
    jmp     short loc_41E1A4
    ; ---------------------------------------------------------------------------

    loc_41E17A:                             ; CODE XREF: sub_41DFC0+1A6j
    and     eax, 0FFh
    and     ecx, 0FFh
    sub     eax, ecx
    cdq
    idiv    ebp
    cmp     eax, 1
    jge     short loc_41E194
    mov     eax, 1

    loc_41E194:                             ; CODE XREF: sub_41DFC0+1CDj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+3908Bh]
    mov     [ecx+esi+2], al

    loc_41E1A4:                             ; CODE XREF: sub_41DFC0+1A4j
                                            ; sub_41DFC0+1B8j
    mov     cl, [ebx]
    mov     al, [edi+2]
    cmp     cl, al
    jbe     short loc_41E1D7
    and     ecx, 0FFh
    and     eax, 0FFh
    sub     eax, ecx
    cdq
    idiv    ebp
    cmp     eax, 0FFFFFFFFh
    jle     short loc_41E1C5
    or      eax, 0FFFFFFFFh

    loc_41E1C5:                             ; CODE XREF: sub_41DFC0+200j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+3908Bh]
    mov     [ecx+esi+3], al
    jmp     short loc_41E216
    ; ---------------------------------------------------------------------------

    loc_41E1D7:                             ; CODE XREF: sub_41DFC0+1EBj
    jnz     short loc_41E1EC
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+3908Bh]
    mov     byte ptr [eax+esi+3], 0
    jmp     short loc_41E216
    ; ---------------------------------------------------------------------------

    loc_41E1EC:                             ; CODE XREF: sub_41DFC0+217j
    and     ecx, 0FFh
    and     eax, 0FFh
    sub     eax, ecx
    cdq
    idiv    ebp
    cmp     eax, 1
    jge     short loc_41E206
    mov     eax, 1

    loc_41E206:                             ; CODE XREF: sub_41DFC0+23Fj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+3908Bh]
    mov     [edx+esi+3], al

    loc_41E216:                             ; CODE XREF: sub_41DFC0+215j
                                            ; sub_41DFC0+22Aj
    mov     eax, [esp+18h+arg_4]
    add     ebx, 4
    add     edi, 4
    dec     eax
    mov     [esp+18h+arg_0], ebx
    mov     [esp+18h+arg_4], eax
    jnz     loc_41E03B
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_41DFC0 endp

    ; ---------------------------------------------------------------------------
    align 8
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    inc     eax
    mov     [ecx+3905Fh], eax
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+39063h]
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41E270 proc near                    ; CODE XREF: .text:0041FE02p
    push    esi
    call    sub_4B6340
    mov     esi, TAdynmemStructPtr
    cmp     [esi+3905Fh], eax
    ja      loc_41E41C
    push    edi
    push    ebx
    xor     eax, eax
    jmp     short loc_41E294
    ; ---------------------------------------------------------------------------

    loc_41E28E:                             ; CODE XREF: sub_41E270+154j
    mov     esi, TAdynmemStructPtr

    loc_41E294:                             ; CODE XREF: sub_41E270+1Cj
    mov     edx, [esi+3908Bh]
    mov     ecx, [esi+39083h]
    mov     dl, [edx+eax]
    lea     edi, [ecx+eax]
    xor     ecx, ecx
    mov     cl, [edi]
    movsx   ebx, dl
    add     ecx, ebx
    test    dl, dl
    mov     edx, [esi+39087h]
    jge     short loc_41E2C6
    xor     ebx, ebx
    mov     bl, [edx+eax]
    mov     edx, ebx
    cmp     ecx, edx
    jge     short loc_41E2D3
    jmp     short loc_41E2D1
    ; ---------------------------------------------------------------------------

    loc_41E2C6:                             ; CODE XREF: sub_41E270+47j
    xor     ebx, ebx
    mov     bl, [edx+eax]
    mov     edx, ebx
    cmp     ecx, edx
    jle     short loc_41E2D3

    loc_41E2D1:                             ; CODE XREF: sub_41E270+54j
    mov     ecx, edx

    loc_41E2D3:                             ; CODE XREF: sub_41E270+52j
                                            ; sub_41E270+5Fj
    mov     [edi], cl
    mov     esi, TAdynmemStructPtr
    xor     ebx, ebx
    mov     edx, [esi+3908Bh]
    mov     ecx, [esi+39083h]
    mov     dl, [edx+eax+1]
    mov     bl, [ecx+eax+1]
    lea     edi, [ecx+eax+1]
    movsx   ecx, dl
    add     ecx, ebx
    test    dl, dl
    mov     edx, [esi+39087h]
    jge     short loc_41E312
    xor     ebx, ebx
    mov     bl, [edx+eax+1]
    mov     edx, ebx
    cmp     ecx, edx
    jge     short loc_41E320
    jmp     short loc_41E31E
    ; ---------------------------------------------------------------------------

    loc_41E312:                             ; CODE XREF: sub_41E270+92j
    xor     ebx, ebx
    mov     bl, [edx+eax+1]
    mov     edx, ebx
    cmp     ecx, edx
    jle     short loc_41E320

    loc_41E31E:                             ; CODE XREF: sub_41E270+A0j
    mov     ecx, edx

    loc_41E320:                             ; CODE XREF: sub_41E270+9Ej
                                            ; sub_41E270+ACj
    mov     [edi], cl
    mov     esi, TAdynmemStructPtr
    xor     ebx, ebx
    mov     edx, [esi+3908Bh]
    mov     ecx, [esi+39083h]
    mov     dl, [edx+eax+2]
    mov     bl, [ecx+eax+2]
    lea     edi, [ecx+eax+2]
    movsx   ecx, dl
    add     ecx, ebx
    test    dl, dl
    mov     edx, [esi+39087h]
    jge     short loc_41E35F
    xor     ebx, ebx
    mov     bl, [edx+eax+2]
    mov     edx, ebx
    cmp     ecx, edx
    jge     short loc_41E36D
    jmp     short loc_41E36B
    ; ---------------------------------------------------------------------------

    loc_41E35F:                             ; CODE XREF: sub_41E270+DFj
    xor     ebx, ebx
    mov     bl, [edx+eax+2]
    mov     edx, ebx
    cmp     ecx, edx
    jle     short loc_41E36D

    loc_41E36B:                             ; CODE XREF: sub_41E270+EDj
    mov     ecx, edx

    loc_41E36D:                             ; CODE XREF: sub_41E270+EBj
                                            ; sub_41E270+F9j
    mov     [edi], cl
    mov     esi, TAdynmemStructPtr
    xor     ebx, ebx
    mov     edx, [esi+3908Bh]
    mov     ecx, [esi+39083h]
    mov     dl, [edx+eax+3]
    mov     bl, [ecx+eax+3]
    lea     edi, [ecx+eax+3]
    movsx   ecx, dl
    add     ecx, ebx
    test    dl, dl
    mov     edx, [esi+39087h]
    jge     short loc_41E3AC
    xor     ebx, ebx
    mov     bl, [edx+eax+3]
    mov     edx, ebx
    cmp     ecx, edx
    jge     short loc_41E3BA
    jmp     short loc_41E3B8
    ; ---------------------------------------------------------------------------

    loc_41E3AC:                             ; CODE XREF: sub_41E270+12Cj
    xor     ebx, ebx
    mov     bl, [edx+eax+3]
    mov     edx, ebx
    cmp     ecx, edx
    jle     short loc_41E3BA

    loc_41E3B8:                             ; CODE XREF: sub_41E270+13Aj
    mov     ecx, edx

    loc_41E3BA:                             ; CODE XREF: sub_41E270+138j
                                            ; sub_41E270+146j
    add     eax, 4
    mov     [edi], cl
    cmp     eax, 400h
    jl      loc_41E28E
    mov     eax, TAdynmemStructPtr
    mov     ecx, 400h
    xor     edx, edx
    mov     edi, [eax+39087h]
    mov     esi, [eax+39083h]
    repe cmpsb
    jnz     short loc_41E3F5
    mov     dword ptr [eax+39063h], 1
    mov     eax, TAdynmemStructPtr

    loc_41E3F5:                             ; CODE XREF: sub_41E270+174j
    mov     eax, [eax+39083h]
    push    100h
    push    0
    push    eax
    call    sub_4BA200
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    inc     eax
    pop     ebx
    pop     edi
    mov     [ecx+3905Fh], eax

    loc_41E41C:                             ; CODE XREF: sub_41E270+12j
    pop     esi
    retn
    sub_41E270 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41E420 proc near                    ; CODE XREF: .text:0041F63Ap
                                            ; .text:0041FDACp ...

    var_1F0= dword ptr -1F0h
    var_1EC= dword ptr -1ECh
    var_1E8= byte ptr -1E8h
    var_1E4= byte ptr -1E4h
    var_1D1= word ptr -1D1h
    var_1CF= word ptr -1CFh
    var_1CD= word ptr -1CDh
    var_1CB= word ptr -1CBh
    var_1C5= dword ptr -1C5h
    var_1C1= dword ptr -1C1h
    var_1BB= byte ptr -1BBh
    var_12E= dword ptr -12Eh
    var_12A= dword ptr -12Ah
    var_126= dword ptr -126h
    var_122= dword ptr -122h
    var_11A= dword ptr -11Ah
    var_116= dword ptr -116h
    var_112= dword ptr -112h
    var_10C= dword ptr -10Ch
    var_F9= word ptr -0F9h
    var_F7= word ptr -0F7h
    var_F5= word ptr -0F5h
    var_F3= word ptr -0F3h
    var_F1= dword ptr -0F1h
    var_E3= byte ptr -0E3h
    var_44= dword ptr -44h
    var_40= byte ptr -40h

    sub     esp, 1F0h
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    push    edi
    mov     ecx, 35h
    lea     eax, [esi+519h]
    lea     edi, [esp+200h+var_1E4]
    mov     dword ptr [esp+200h+var_1E8], eax
    xor     edx, edx
    mov     eax, [eax+18h]
    xor     ebp, ebp
    mov     [esp+200h+var_1F0], ebp
    mov     [esp+200h+var_1EC], ebp
    mov     ebx, [eax+4]
    xor     eax, eax
    rep stosd
    stosw
    xor     ecx, ecx
    mov     [esp+200h+var_1BB], 0
    mov     [esp+200h+var_1CF], 5Dh
    mov     [esp+200h+var_1CD], 43h
    mov     [esp+200h+var_1CB], 12h
    mov     cl, [esi+0DCFh]
    mov     [esp+200h+var_1C5], ecx
    mov     dl, [esi+0DD3h]
    mov     ecx, 33h
    xor     eax, eax
    lea     edi, [esp+200h+var_10C]
    mov     [esp+200h+var_1C1], edx
    rep stosd
    mov     eax, [esp+200h+var_44]
    mov     edx, 1
    or      eax, edx
    mov     [esp+200h+var_112], edx
    mov     [esp+200h+var_116], edx
    mov     [esp+200h+var_12A], ebp
    mov     [esp+200h+var_122], edx
    mov     [esp+200h+var_E3], dl
    mov     [esp+200h+var_F1], 400h
    mov     [esp+200h+var_44], eax
    mov     [esi+3906Bh], ebp

    loc_41E4E4:                             ; CODE XREF: sub_41E420+5F7j
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+ebp+38DD9h]
    test    cl, cl
    jz      loc_41E9F9
    mov     ecx, [esp+200h+var_1F0]
    lea     edx, [esp+200h+var_40]
    push    ecx
    push    offset aPlayercolorD            ; LPCSTR
    push    edx                             ; LPSTR
    call    ds:wsprintfA
    lea     edi, [esp+20Ch+var_40]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+200h+var_10C+2]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+200h+var_10C]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, TAdynmemStructPtr
    and     ecx, 3
    add     eax, 519h
    rep movsb
    mov     cx, [esp+200h+var_1CF]
    push    edx
    push    eax
    mov     [esp+208h+var_F9], 10h
    mov     [esp+208h+var_F7], cx
    mov     [esp+208h+var_F5], 5Bh
    mov     [esp+208h+var_F3], 15h
    call    sub_4AB310
    lea     ecx, [esp+200h+var_40]
    push    6
    push    ecx                             ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_41E5E3
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebx
    add     ecx, eax
    lea     eax, [ecx+edx*2]
    test    eax, eax
    jz      short loc_41E5E3
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+148DBh]
    mov     [eax+0BEh], ecx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+204h+var_1F0]
    mov     edx, [edx+ecx+1B8Ah]
    movzx   cx, byte ptr [edx+96h]
    mov     [eax+0C6h], cx

    loc_41E5E3:                             ; CODE XREF: sub_41E420+174j
                                            ; sub_41E420+18Fj
    mov     esi, [esp+204h+var_1EC]
    mov     edx, [esi+0Ch]
    mov     [esi+14h], edx
    call    sub_4A50B0
    mov     ecx, eax
    mov     eax, 14h
    sub     eax, ecx
    push    2                               ; int
    movsx   ecx, word ptr [esp+35h]
    cdq
    sub     eax, edx
    push    0FFFFFFFFh                      ; int
    sar     eax, 1
    add     eax, ecx
    push    eax                             ; __int16
    mov     eax, TAdynmemStructPtr
    push    10h                             ; int
    lea     edx, [eax+ebp+38DD9h]
    mov     eax, [eax+531h]
    push    edx                             ; char *
    push    offset aText_0                  ; int
    push    eax                             ; int
    call    sub_4AB1B0
    movsx   eax, word ptr [ebx+0B6h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    mov     dword ptr [edx+ecx*2+1Bh], 2
    movsx   eax, word ptr [ebx+0B6h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    mov     word ptr [edx+ecx*2+17h], 5Ah
    mov     eax, [esi+8]
    mov     [esi+14h], eax
    mov     eax, TAdynmemStructPtr
    mov     word ptr [esp+2Fh], 70h
    mov     ecx, [eax+ebp+38DF7h]
    mov     [esp+204h+var_12A], ecx
    mov     edx, [eax+3918Fh]
    fild    [esp+204h+var_12A]
    mov     [esp+0D2h], edx
    fmul    ds:flt_4FD008
    fcom    ds:flt_4FD00C
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41E6C1
    fstp    dword ptr [esp+0E6h]
    jmp     short loc_41E6CE
    ; ---------------------------------------------------------------------------

    loc_41E6C1:                             ; CODE XREF: sub_41E420+296j
    fstp    st
    mov     dword ptr [esp+0E6h], 3F800000h

    loc_41E6CE:                             ; CODE XREF: sub_41E420+29Fj
    mov     esi, [esp+10h]
    mov     edi, ds:wsprintfA
    push    esi
    lea     eax, [esp+22h]
    push    offset aKillsD                  ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+204h+var_1E8]
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AB3A0
    mov     eax, TAdynmemStructPtr
    mov     word ptr [esp+2Fh], 0BAh
    mov     ecx, [eax+ebp+38DFBh]
    mov     [esp+204h+var_12A], ecx
    mov     edx, [eax+39193h]
    fild    [esp+204h+var_12A]
    mov     [esp+0D2h], edx
    fmul    ds:flt_4FD008
    fcom    ds:flt_4FD00C
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41E749
    fstp    dword ptr [esp+0E6h]
    jmp     short loc_41E756
    ; ---------------------------------------------------------------------------

    loc_41E749:                             ; CODE XREF: sub_41E420+31Ej
    fstp    st
    mov     dword ptr [esp+0E6h], 3F800000h

    loc_41E756:                             ; CODE XREF: sub_41E420+327j
    push    esi
    lea     eax, [esp+22h]
    push    offset aLossesD                 ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+204h+var_1E8]
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AB3A0
    mov     eax, TAdynmemStructPtr
    mov     word ptr [esp+2Fh], 104h
    mov     ecx, [eax+ebp+38DFFh]
    mov     [esp+204h+var_12A], ecx
    mov     edx, [eax+39197h]
    fild    [esp+204h+var_12A]
    mov     [esp+0D2h], edx
    fmul    ds:flt_4FD008
    fcom    ds:flt_4FD00C
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41E7C7
    fstp    dword ptr [esp+0E6h]
    jmp     short loc_41E7D4
    ; ---------------------------------------------------------------------------

    loc_41E7C7:                             ; CODE XREF: sub_41E420+39Cj
    fstp    st
    mov     dword ptr [esp+0E6h], 3F800000h

    loc_41E7D4:                             ; CODE XREF: sub_41E420+3A5j
    push    esi
    lea     eax, [esp+22h]
    push    offset aEproducedD              ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+204h+var_1E8]
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AB3A0
    mov     eax, TAdynmemStructPtr
    mov     word ptr [esp+2Fh], 14Eh
    mov     ecx, [eax+ebp+38E03h]
    mov     [esp+204h+var_12A], ecx
    mov     edx, [eax+3919Bh]
    fild    [esp+204h+var_12A]
    mov     [esp+0D2h], edx
    fmul    ds:flt_4FD008
    fcom    ds:flt_4FD00C
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41E845
    fstp    dword ptr [esp+0E6h]
    jmp     short loc_41E852
    ; ---------------------------------------------------------------------------

    loc_41E845:                             ; CODE XREF: sub_41E420+41Aj
    fstp    st
    mov     dword ptr [esp+0E6h], 3F800000h

    loc_41E852:                             ; CODE XREF: sub_41E420+423j
    push    esi
    lea     eax, [esp+22h]
    push    offset aMproducedD              ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+204h+var_1E8]
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AB3A0
    mov     eax, TAdynmemStructPtr
    mov     word ptr [esp+2Fh], 198h
    mov     ecx, [eax+ebp+38E07h]
    mov     [esp+204h+var_12A], ecx
    mov     edx, [eax+3919Fh]
    fild    [esp+204h+var_12A]
    mov     [esp+0D2h], edx
    fmul    ds:flt_4FD008
    fcom    ds:flt_4FD00C
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41E8C3
    fstp    dword ptr [esp+0E6h]
    jmp     short loc_41E8D0
    ; ---------------------------------------------------------------------------

    loc_41E8C3:                             ; CODE XREF: sub_41E420+498j
    fstp    st
    mov     dword ptr [esp+0E6h], 3F800000h

    loc_41E8D0:                             ; CODE XREF: sub_41E420+4A1j
    push    esi
    lea     eax, [esp+22h]
    push    offset aEwastedD                ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+204h+var_1E8]
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AB3A0
    mov     eax, TAdynmemStructPtr
    mov     word ptr [esp+2Fh], 1E2h
    mov     ecx, [eax+ebp+38E0Bh]
    mov     [esp+204h+var_12A], ecx
    mov     edx, [eax+391A3h]
    fild    [esp+204h+var_12A]
    mov     [esp+0D2h], edx
    fmul    ds:flt_4FD008
    fcom    ds:flt_4FD00C
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41E941
    fstp    dword ptr [esp+0E6h]
    jmp     short loc_41E94E
    ; ---------------------------------------------------------------------------

    loc_41E941:                             ; CODE XREF: sub_41E420+516j
    fstp    st
    mov     dword ptr [esp+0E6h], 3F800000h

    loc_41E94E:                             ; CODE XREF: sub_41E420+51Fj
    push    esi
    lea     eax, [esp+22h]
    push    offset aMwastedD                ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+204h+var_1E8]
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AB3A0
    mov     eax, TAdynmemStructPtr
    mov     word ptr [esp+2Fh], 22Ch
    mov     ecx, [eax+ebp+38E0Fh]
    mov     [esp+204h+var_12A], ecx
    mov     edx, [eax+391A7h]
    fild    [esp+204h+var_12A]
    mov     [esp+0D2h], edx
    fmul    ds:flt_4FD008
    fcom    ds:flt_4FD00C
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_41E9BF
    fstp    dword ptr [esp+0E6h]
    jmp     short loc_41E9CC
    ; ---------------------------------------------------------------------------

    loc_41E9BF:                             ; CODE XREF: sub_41E420+594j
    fstp    st
    mov     dword ptr [esp+0E6h], 3F800000h

    loc_41E9CC:                             ; CODE XREF: sub_41E420+59Dj
    push    esi
    lea     eax, [esp+22h]
    push    offset aScoreD                  ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+204h+var_1E8]
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AB3A0
    add     word ptr [esp+31h], 14h

    loc_41E9F9:                             ; CODE XREF: sub_41E420+D2j
    mov     eax, [esp+204h+var_1F0]
    mov     edi, [esp+10h]
    add     eax, 14Bh
    inc     edi
    add     ebp, 3Ah
    cmp     eax, 0CEEh
    mov     [esp+10h], edi
    mov     [esp+204h+var_1F0], eax
    jl      loc_41E4E4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1F0h
    retn
    sub_41E420 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     ecx, [eax+531h]
    mov     eax, [ecx+4]
    xor     ecx, ecx
    movsx   edx, word ptr [eax+0B6h]
    test    edx, edx
    jle     short loc_41EA88
    add     eax, 0BAh
    mov     bl, 0Dh

    loc_41EA55:                             ; CODE XREF: .text:0041EA77j
    cmp     [eax-0BAh], bl
    jnz     short loc_41EA6F
    cmp     byte ptr [eax-91h], 0
    jz      short loc_41EA82
    mov     esi, [eax]
    mov     edi, [eax+4]
    cmp     esi, edi
    jl      short loc_41EA82

    loc_41EA6F:                             ; CODE XREF: .text:0041EA5Bj
    inc     ecx
    add     eax, 15Bh
    cmp     ecx, edx
    jl      short loc_41EA55
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_41EA82:                             ; CODE XREF: .text:0041EA64j
                                            ; .text:0041EA6Dj
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_41EA88:                             ; CODE XREF: .text:0041EA4Cj
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41EAA0 proc near                    ; CODE XREF: sub_41F0A0+1D6p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+14h+arg_8]
    shl     edi, 7
    push    edi
    push    offset aScrollitems1            ; "ScrollItems1"
    call    sub_4D83B0
    mov     ecx, edi
    mov     esi, eax
    mov     edx, ecx
    xor     eax, eax
    mov     edi, esi
    mov     ebp, [esp+1Ch+arg_0]
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    add     esp, 8
    and     ecx, 3
    xor     ebx, ebx
    rep stosb
    mov     eax, [esp+14h+arg_8]
    mov     [esp+14h+var_4], esi
    test    eax, eax
    mov     edx, esi
    jle     short loc_41EB49

    loc_41EAE4:                             ; CODE XREF: sub_41EAA0+A3j
    mov     ecx, [esp+14h+arg_4]
    mov     al, [ebx+ecx]
    cmp     al, 4Ch
    jnz     short loc_41EAF4
    mov     byte ptr [edx], 0FFh
    jmp     short loc_41EAFB
    ; ---------------------------------------------------------------------------

    loc_41EAF4:                             ; CODE XREF: sub_41EAA0+4Dj
    cmp     al, 57h
    jnz     short loc_41EB00
    mov     byte ptr [edx], 0FEh

    loc_41EAFB:                             ; CODE XREF: sub_41EAA0+52j
    inc     edx
    mov     byte ptr [edx], 20h
    inc     edx

    loc_41EB00:                             ; CODE XREF: sub_41EAA0+56j
    cmp     byte ptr [ebx+ecx], 55h
    jnz     short loc_41EB0E
    mov     byte ptr [edx], 0FDh
    inc     edx
    mov     byte ptr [edx], 20h
    inc     edx

    loc_41EB0E:                             ; CODE XREF: sub_41EAA0+64j
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+14h+arg_8]
    not     ecx
    add     ebp, ecx
    add     edx, ecx
    inc     ebx
    cmp     ebx, eax
    jl      short loc_41EAE4
    mov     esi, [esp+14h+var_4]

    loc_41EB49:                             ; CODE XREF: sub_41EAA0+42j
    mov     ecx, [esp+14h+arg_0]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    sub_41EAA0 endp

    ; ---------------------------------------------------------------------------
    push    ecx
    push    ebx
    push    ebp
    mov     ebp, [esp+18h]
    push    esi
    mov     eax, ebp
    push    edi
    shl     eax, 7
    add     eax, ebp
    shl     eax, 1
    push    eax
    push    offset aScrollitems2            ; "ScrollItems2"
    call    sub_4D83B0
    mov     edx, eax
    mov     eax, [esp+24h]
    add     esp, 8
    cmp     eax, ebp
    mov     [esp+10h], edx
    jle     short loc_41EB90
    mov     eax, ebp

    loc_41EB90:                             ; CODE XREF: .text:0041EB8Cj
    mov     ebx, [esp+18h]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_41EBD9
    mov     ebp, eax
    mov     [esp+1Ch], eax

    loc_41EBA0:                             ; CODE XREF: .text:0041EBCFj
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    add     ebx, ecx
    add     edx, ecx
    dec     ebp
    jnz     short loc_41EBA0
    mov     ecx, [esp+1Ch]
    mov     ebp, [esp+20h]

    loc_41EBD9:                             ; CODE XREF: .text:0041EB98j
    cmp     ecx, ebp
    jge     short loc_41EC35
    sub     ebp, ecx

    loc_41EBDF:                             ; CODE XREF: .text:0041EC33j
    mov     edi, offset byte_502A20
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    add     edx, 2
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    add     ebx, ecx
    add     edx, ecx
    dec     ebp
    jnz     short loc_41EBDF

    loc_41EC35:                             ; CODE XREF: .text:0041EBDBj
    mov     ecx, [esp+18h]
    push    ecx
    call    sub_4D85A0
    mov     eax, [esp+14h]
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41EC50 proc near                    ; DATA XREF: sub_41F0A0+47o

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     ebx, [eax+4]
    mov     ebp, [eax+0Ch]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     loc_41EDA1
    call    sub_4257A0
    mov     eax, TAdynmemStructPtr
    xor     edi, edi
    mov     eax, [eax+39077h]
    cmp     eax, edi
    jz      short loc_41EC87
    push    eax
    call    sub_4C6AC0

    loc_41EC87:                             ; CODE XREF: sub_41EC50+2Fj
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+3907Bh]
    cmp     eax, edi
    jz      short loc_41EC9D
    push    eax
    call    sub_4C6AC0

    loc_41EC9D:                             ; CODE XREF: sub_41EC50+45j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+3907Fh]
    cmp     eax, edi
    jz      short loc_41ECB6
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_41ECB6:                             ; CODE XREF: sub_41EC50+5Bj
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+39083h]
    cmp     eax, edi
    jz      short loc_41ECCE
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_41ECCE:                             ; CODE XREF: sub_41EC50+73j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+39087h]
    cmp     eax, edi
    jz      short loc_41ECE7
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_41ECE7:                             ; CODE XREF: sub_41EC50+8Cj
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+3908Bh]
    cmp     eax, edi
    jz      short loc_41ED00
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_41ED00:                             ; CODE XREF: sub_41EC50+A5j
    mov     eax, TAdynmemStructPtr
    mov     [eax+39077h], edi
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+3907Bh], edi
    mov     edx, TAdynmemStructPtr
    mov     [edx+3907Fh], edi
    mov     eax, TAdynmemStructPtr
    mov     [eax+39083h], edi
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+39087h], edi
    mov     edx, TAdynmemStructPtr
    mov     [edx+3908Bh], edi
    mov     eax, [ebp+14h]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    ebp                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     dl, [ecx+2BEEh]
    shr     dl, 4
    test    dl, 1
    jz      short loc_41ED74
    call    sub_450E20

    loc_41ED74:                             ; CODE XREF: sub_41EC50+11Dj
    mov     eax, TAdynmemStructPtr
    push    4
    mov     ecx, [eax+10h]
    call    sub_4CE690
    call    sub_4B6220
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+3906Fh]
    mov     [eax+614h], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41EDA1:                             ; CODE XREF: sub_41EC50+15j
    push    offset aLoadgame                ; "LoadGame"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_41EDD4
    push    0                               ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    call    sub_4931D0
    push    esi
    call    sub_4AB0A0
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41EDD4:                             ; CODE XREF: sub_41EC50+15Ej
    push    offset aSavegame_0              ; "SaveGame"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_41EE07
    push    0                               ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    call    sub_493060
    push    esi
    call    sub_4AB0A0
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41EE07:                             ; CODE XREF: sub_41EC50+191j
    push    offset aStart                   ; "Start"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     loc_41EF2D
    push    offset aMissions                ; "Missions"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     loc_41EF2D
    push    offset aMainmenu                ; "MainMenu"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_41EE75
    push    0                               ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    push    offset aCCavedogWarg_0          ; "c:\\cavedog\\wargame\\endgame.cpp"
    push    302h
    push    2
    call    sub_425860
    push    1
    call    sub_490B30
    push    1
    call    sub_4C22D0
    push    14h
    call    sub_491C80
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41EE75:                             ; CODE XREF: sub_41EC50+1EAj
    push    offset aDifficulty              ; "Difficulty"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_41F033
    xor     edi, edi
    push    edi                             ; int
    push    offset aSkirmish                ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EEEh]
    cmp     ecx, edi
    jnz     short loc_41EED1
    mov     eax, [eax+29A0h]
    push    esi
    mov     dword ptr [eax+228h], 1
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+37EEEh], 1
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41EED1:                             ; CODE XREF: sub_41EC50+252j
    cmp     ecx, 1
    jnz     short loc_41EF00
    mov     edx, [eax+29A0h]
    mov     eax, 2
    push    esi
    mov     [edx+228h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37EEEh], eax
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41EF00:                             ; CODE XREF: sub_41EC50+284j
    cmp     ecx, 2
    jnz     loc_41F033
    mov     edx, [eax+29A0h]
    push    esi
    mov     [edx+228h], edi
    mov     eax, TAdynmemStructPtr
    mov     [eax+37EEEh], edi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41EF2D:                             ; CODE XREF: sub_41EC50+1C4j
                                            ; sub_41EC50+1D7j
    xor     edi, edi
    push    edi
    call    sub_41D6A0
    test    al, al
    jnz     short loc_41EF71
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_0          ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4AB0A0

    loc_41EF71:                             ; CODE XREF: sub_41EC50+2E7j
    call    sub_41D4C0
    push    edi                             ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    push    1
    mov     byte ptr [eax+2BC0h], 0Ah
    call    sub_4C22D0
    push    14h
    call    sub_491C80
    push    offset aMissions                ; char *
    push    ebx                             ; int
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, TAdynmemStructPtr
    push    ecx
    mov     ecx, [edx+391E9h]
    call    sub_435C00
    test    eax, eax
    jz      short loc_41F033
    call    sub_425A90
    mov     eax, TAdynmemStructPtr
    mov     esi, 0FFFBh
    push    1
    and     [eax+2A44h], si
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2A44h], 8
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+2A44h], 0FFFEh
    call    sub_434AB0
    mov     eax, TAdynmemStructPtr
    push    offset aCCavedogWarg_0          ; "c:\\cavedog\\wargame\\endgame.cpp"
    push    2F5h
    push    0Dh
    and     word ptr [eax+3923Bh], 0FFEFh
    mov     eax, TAdynmemStructPtr
    and     [eax+3923Bh], si
    call    sub_425860
    push    2
    call    sub_490B30
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41F033:                             ; CODE XREF: sub_41EC50+232j
                                            ; sub_41EC50+2B3j ...
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_41EC50 endp

    ; ---------------------------------------------------------------------------
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_41F09D
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391AFh]
    test    ecx, ecx
    jnz     short loc_41F080
    mov     ecx, [eax+391ABh]
    inc     ecx
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435980
    test    eax, eax
    jz      short unknown_libname_2
    mov     eax, TAdynmemStructPtr

    loc_41F080:                             ; CODE XREF: .text:0041F062j
    mov     edx, [eax+391ABh]
    mov     ecx, [eax+391E9h]
    inc     edx
    push    edx
    call    sub_435980
    test    eax, eax
    jz      short loc_41F09D

    unknown_libname_2:                      ; CODE XREF: .text:0041F079j
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_41F09D:                             ; CODE XREF: .text:0041F053j
                                            ; .text:0041F095j
    xor     eax, eax
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41F0A0 proc near                    ; CODE XREF: .text:0041F635p
                                            ; .text:0041FDA7p ...

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4257A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C6890
    call    sub_4C63A0
    mov     edx, TAdynmemStructPtr
    push    80h
    add     edx, 519h
    push    offset aEndmsn_gui              ; "ENDMSN.GUI"
    push    edx
    call    sub_4AA8F0
    mov     ebp, eax
    push    20h
    push    offset aEndmsngui               ; "EndMsnGUI"
    mov     dword ptr [ebp+8], offset sub_41EC50
    call    sub_4D83B0
    lea     ebx, [eax+14h]
    add     esp, 8
    mov     dword ptr [ebx], 0
    mov     [ebp+0Ch], eax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ebp+4]
    mov     [esp+14h+var_4], eax
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_41F168
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391AFh]
    test    ecx, ecx
    jnz     short loc_41F14A
    mov     edx, [eax+391ABh]
    mov     ecx, [eax+391E9h]
    inc     edx
    push    edx
    call    sub_435980
    test    eax, eax
    jz      short loc_41F161
    mov     eax, TAdynmemStructPtr

    loc_41F14A:                             ; CODE XREF: sub_41F0A0+8Cj
    mov     ecx, [eax+391ABh]
    inc     ecx
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435980
    test    eax, eax
    jz      short loc_41F168

    loc_41F161:                             ; CODE XREF: sub_41F0A0+A3j
    mov     eax, 1
    jmp     short loc_41F16A
    ; ---------------------------------------------------------------------------

    loc_41F168:                             ; CODE XREF: sub_41F0A0+7Dj
                                            ; sub_41F0A0+BFj
    xor     eax, eax

    loc_41F16A:                             ; CODE XREF: sub_41F0A0+C6j
    test    al, al
    jz      short loc_41F1C2
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+391ABh]
    mov     ecx, [eax+391E9h]
    push    edx
    call    sub_435C00
    push    0
    push    1
    push    1
    push    offset aOutcome1_0              ; "outcome1"
    call    sub_4288D0
    mov     edx, [ebp+4]
    mov     edi, offset aStart              ; "Start"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     edx, 0CCh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_41F1E9
    ; ---------------------------------------------------------------------------

    loc_41F1C2:                             ; CODE XREF: sub_41F0A0+CCj
    push    0
    push    1
    push    1
    push    offset aOutcome0_0              ; "outcome0"
    call    sub_4288D0
    mov     ecx, TAdynmemStructPtr
    push    offset aMainmenu                ; "MainMenu"
    add     ecx, 519h
    push    ecx
    call    sub_4A76B0

    loc_41F1E9:                             ; CODE XREF: sub_41F0A0+120j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_41F248
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391AFh]
    test    ecx, ecx
    jnz     short loc_41F22A
    mov     ecx, [eax+391ABh]
    inc     ecx
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435980
    test    eax, eax
    jz      short loc_41F241
    mov     eax, TAdynmemStructPtr

    loc_41F22A:                             ; CODE XREF: sub_41F0A0+16Cj
    mov     edx, [eax+391ABh]
    mov     ecx, [eax+391E9h]
    inc     edx
    push    edx
    call    sub_435980
    test    eax, eax
    jz      short loc_41F248

    loc_41F241:                             ; CODE XREF: sub_41F0A0+183j
    mov     eax, 1
    jmp     short loc_41F24A
    ; ---------------------------------------------------------------------------

    loc_41F248:                             ; CODE XREF: sub_41F0A0+15Dj
                                            ; sub_41F0A0+19Fj
    xor     eax, eax

    loc_41F24A:                             ; CODE XREF: sub_41F0A0+1A6j
    test    al, al
    jz      loc_41F31B
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ecx, [eax+391E9h]
    call    sub_435760
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ebx]
    mov     esi, eax
    add     ecx, 391CFh
    push    esi
    push    ecx
    push    edx
    call    sub_41EAA0
    mov     [ebx], eax
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     bl, 55h

    loc_41F287:                             ; CODE XREF: sub_41F0A0+1F4j
    cmp     [ecx+edx+391CFh], bl
    jz      short loc_41F296
    inc     ecx
    cmp     ecx, 19h
    jl      short loc_41F287

    loc_41F296:                             ; CODE XREF: sub_41F0A0+1EEj
    push    0
    push    esi
    push    eax
    add     edx, 519h
    push    offset aMissions                ; "Missions"
    push    edx
    call    sub_4A32A0
    push    offset aKnob                    ; char *
    mov     eax, [esp+18h+var_4]
    push    eax                             ; int
    call    sub_4A0200
    mov     cx, [eax+19h]
    sub     cx, [eax+142h]
    sub     ecx, 3
    mov     [eax+136h], cx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+391ABh]
    add     eax, 519h
    push    edx
    push    offset aMissions                ; "Missions"
    push    eax
    call    sub_4A2E40
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     ebx, [eax+391AFh]
    mov     edx, [eax+391ABh]
    test    ebx, ebx
    setnz   cl
    add     edx, ecx
    add     eax, 519h
    push    edx
    push    offset aMissions                ; "Missions"
    push    eax
    call    sub_4A2E40
    call    sub_477410

    loc_41F31B:                             ; CODE XREF: sub_41F0A0+1ACj
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     esi, ecx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     esi, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     esi, [esi+eax*2+1B63h]
    mov     eax, [ecx+37E1Fh]
    cdq
    sub     eax, edx
    mov     edx, [ecx+391AFh]
    sar     eax, 1
    test    edx, edx
    jz      short loc_41F37C
    cmp     dword ptr [esi], 0
    jz      short loc_41F364
    mov     edx, [esi+27h]
    test    byte ptr [edx+9Bh], 40h
    jnz     short loc_41F37C

    loc_41F364:                             ; CODE XREF: sub_41F0A0+2B6j
    push    1Ch
    push    eax
    mov     eax, [ecx+14813h]
    push    0
    push    eax
    call    sub_4B7F30
    mov     ecx, [ebp+24h]
    push    eax
    push    ecx
    jmp     short loc_41F392
    ; ---------------------------------------------------------------------------

    loc_41F37C:                             ; CODE XREF: sub_41F0A0+2B1j
                                            ; sub_41F0A0+2C2j
    mov     edx, [ecx+14817h]
    push    1Ch
    push    eax
    push    0
    push    edx
    call    sub_4B7F30
    push    eax
    mov     eax, [ebp+24h]
    push    eax

    loc_41F392:                             ; CODE XREF: sub_41F0A0+2DAj
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2BEEh]
    shr     cl, 4
    test    cl, 1
    jz      short loc_41F3C6
    push    0
    push    offset byte_502AE8
    add     eax, 519h
    push    offset aMainmenu                ; "MainMenu"
    push    eax
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr

    loc_41F3C6:                             ; CODE XREF: sub_41F0A0+308j
    add     eax, 519h
    push    1
    push    eax
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    push    13h
    call    sub_491C80
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_41F0A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_41F400 proc near                    ; CODE XREF: .text:0041F63Fp
                                            ; .text:0041FDB1p ...
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_41F45F
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391AFh]
    test    ecx, ecx
    jnz     short loc_41F441
    mov     ecx, [eax+391ABh]
    inc     ecx
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435980
    test    eax, eax
    jz      short loc_41F458
    mov     eax, TAdynmemStructPtr

    loc_41F441:                             ; CODE XREF: sub_41F400+23j
    mov     edx, [eax+391ABh]
    mov     ecx, [eax+391E9h]
    inc     edx
    push    edx
    call    sub_435980
    test    eax, eax
    jz      short loc_41F45F

    loc_41F458:                             ; CODE XREF: sub_41F400+3Aj
    mov     eax, 1
    jmp     short loc_41F461
    ; ---------------------------------------------------------------------------

    loc_41F45F:                             ; CODE XREF: sub_41F400+14j
                                            ; sub_41F400+56j
    xor     eax, eax

    loc_41F461:                             ; CODE XREF: sub_41F400+5Dj
    test    al, al
    push    1                               ; int
    jz      loc_41F532
    mov     eax, TAdynmemStructPtr
    push    offset aStart                   ; char *
    add     eax, 519h
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    add     ecx, 519h
    push    offset aLoadgame                ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    push    1                               ; int
    add     edx, 519h
    push    offset aSavegame_0              ; char *
    push    edx                             ; int
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    push    1                               ; int
    add     eax, 519h
    push    offset aKnob                    ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    add     ecx, 519h
    push    offset aMissions                ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    push    1                               ; int
    add     edx, 519h
    push    offset aDifficulty              ; char *
    push    edx                             ; int
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    push    1                               ; int
    add     eax, 519h
    push    offset aAdjustdiff              ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    add     ecx, 519h
    push    offset aMainmenu                ; char *
    push    ecx                             ; int
    call    sub_4A0570
    push    offset aMissions                ; int
    jmp     short loc_41F581
    ; ---------------------------------------------------------------------------

    loc_41F532:                             ; CODE XREF: sub_41F400+65j
    mov     eax, TAdynmemStructPtr
    push    offset aMainmenu                ; char *
    add     eax, 519h
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    1
    push    offset aMainmenu                ; char *
    mov     edx, [ecx+531h]
    mov     esi, [edx+4]
    push    esi                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    push    offset aMainmenu                ; "MainMenu"
    shl     ecx, 3
    sub     ecx, eax
    add     esi, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     word ptr [esi+ecx*2+15h], 1A0h

    loc_41F581:                             ; CODE XREF: sub_41F400+130j
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4A76B0
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FAD0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_49FA90
    pop     esi
    retn
    sub_41F400 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 40h
    push    ebx
    mov     ebx, [esp+48h]
    push    ebp
    mov     ebp, ds:wsprintfA
    push    esi
    push    edi
    xor     esi, esi
    xor     edi, edi

    loc_41F5D5:                             ; CODE XREF: .text:0041F617j
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+edi+38DD9h]
    test    cl, cl
    jz      short loc_41F60D
    push    esi
    push    ebx
    lea     ecx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    ecx
    call    ebp ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+10h]
    add     eax, 519h
    push    1
    push    edx
    push    eax
    call    sub_4A0570

    loc_41F60D:                             ; CODE XREF: .text:0041F5E3j
    add     edi, 3Ah
    inc     esi
    cmp     edi, 244h
    jl      short loc_41F5D5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    call    sub_4257A0
    call    sub_41F0A0
    call    sub_41E420
    call    sub_41F400
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FAD0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA90
    push    7
    call    sub_490B30
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+39057h], 7
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_41F680:                             ; DATA XREF: .text:0041F71Co
                                            ; .text:0041FBA5o
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_41F6F0
    push    offset byte_502AE8
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_41F6EA
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    push    0
    call    sub_41D6A0
    test    al, al
    jz      short loc_41F6C4
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+39057h], 5
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_41F6C4:                             ; CODE XREF: .text:0041F6AFj
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_0          ; "Please insert the Campaign CD (Disc 2) "...
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90

    loc_41F6EA:                             ; CODE XREF: .text:0041F698j
    push    esi
    call    sub_4AB0A0

    loc_41F6F0:                             ; CODE XREF: .text:0041F689j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    101h
    add     eax, 519h
    push    offset aCdcheck_gui             ; "CDCHECK.GUI"
    push    eax
    call    sub_4AA8F0
    push    1
    mov     dword ptr [eax+8], offset loc_41F680
    call    sub_4C22D0
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    cmp     dword ptr [eax+39057h], 1
    jnz     short unknown_libname_4
    call    sub_4B6220
    mov     ecx, [eax+0D8h]
    mov     edx, [eax+0D4h]
    mov     eax, TAdynmemStructPtr
    push    ecx
    push    edx
    mov     ecx, [eax+39077h]
    mov     edx, [eax+37E1Bh]
    push    ecx
    push    edx
    call    sub_4C6B70
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_464060
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4A9FD0
    mov     eax, TAdynmemStructPtr
    push    0
    add     eax, 519h
    push    0
    push    eax
    call    sub_4AB170
    call    sub_4C2870
    call    sub_4C63A0

    unknown_libname_3:
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_4:                      ; CODE XREF: .text:0041F76Cj
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    loc_41F7F0:                             ; CODE XREF: .text:00499880j
    mov     eax, TAdynmemStructPtr
    sub     esp, 458h
    mov     ecx, [eax+37E1Bh]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    ecx
    call    sub_4C69A0
    call    Network_Process
    mov     esi, TAdynmemStructPtr
    mov     edi, 8
    mov     eax, [esi+39057h]
    cmp     eax, edi
    ja      loc_42059A
    jmp     ds:off_4205AC[eax*4]            ; case 0x0

    loc_41F830:                             ; DATA XREF: .text:004205ACo
    mov     ecx, [esi+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     loc_41F946
    call    sub_4B6220
    mov     esi, eax
    mov     edx, [esi+0D8h]
    mov     eax, [esi+0D4h]
    push    edx
    push    eax
    push    offset aCopyOfLastGame          ; "Copy of last game frame"
    call    sub_4C69F0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+39077h], eax
    mov     edx, [esi+0D8h]
    mov     eax, [esi+0D4h]
    push    edx
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    mov     edx, [eax+39077h]
    push    ecx
    push    edx
    call    sub_4C6B70
    push    7
    call    RIWrapper_Report
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dword ptr [eax+39057h], 1
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*2+1B63h]
    mov     al, [ecx+eax*2+1B85h]
    test    al, al
    jz      loc_42059A
    cmp     al, 2
    jz      loc_42059A
    and     eax, 0FFh
    push    eax
    call    sub_452C40
    push    1
    push    1
    push    140h
    push    eax
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FAD0
    mov     byte ptr [esi+22h], 0
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41F946:                             ; CODE XREF: .text:0041F83Ej
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+39077h], 0
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+39057h], 2
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41F976:                             ; CODE XREF: .text:0041F829j
                                            ; DATA XREF: .text:004205B0o
    add     esi, 519h
    push    offset aMsgbox_gui              ; "MSGBOX.GUI"
    push    esi
    call    sub_4AB060
    test    eax, eax
    jz      loc_41FA1D
    mov     eax, TAdynmemStructPtr
    cmp     dword ptr [eax+39057h], 1
    jnz     loc_42059A
    call    sub_4B6220
    mov     ecx, [eax+0D8h]
    mov     edx, [eax+0D4h]
    mov     eax, TAdynmemStructPtr
    push    ecx
    push    edx
    mov     ecx, [eax+39077h]
    mov     edx, [eax+37E1Bh]
    push    ecx
    push    edx
    call    sub_4C6B70
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_464060
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4A9FD0
    mov     eax, TAdynmemStructPtr
    push    0
    add     eax, 519h
    push    0
    push    eax
    call    sub_4AB170
    call    sub_4C2870
    call    sub_4C63A0
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FA1D:                             ; CODE XREF: .text:0041F989j
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+39057h], 2
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FA3D:                             ; CODE XREF: .text:0041F829j
                                            ; DATA XREF: .text:004205B4o
    mov     dword ptr [esi+39067h], 0Ah
    call    sub_4B6340
    mov     edx, TAdynmemStructPtr
    inc     eax
    push    0
    mov     [edx+3905Fh], eax
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+39063h], 0
    call    sub_4C22D0
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+39057h], 3
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FA8F:                             ; CODE XREF: .text:0041F829j
                                            ; DATA XREF: .text:004205B8o
    mov     eax, [esi+39063h]
    xor     edi, edi
    cmp     eax, edi
    jnz     loc_41FB36
    mov     [esp+54h], edi
    mov     [esp+50h], edi
    mov     edx, [esi+37E1Fh]
    mov     [esp+58h], edx
    mov     eax, [esi+37E23h]
    mov     [esp+5Ch], eax
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+3905Fh], eax
    jnb     loc_42059A
    mov     ecx, [ecx+39067h]
    lea     edx, [esp+50h]
    sub     ecx, 1Dh
    push    ecx
    push    edx
    push    edi
    call    sub_4BF4D0
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    inc     eax
    mov     [ecx+3905Fh], eax
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+39067h]
    dec     edx
    mov     [eax+39067h], edx
    mov     eax, TAdynmemStructPtr
    cmp     [eax+39067h], edi
    jnz     loc_42059A
    mov     dword ptr [eax+39063h], 1
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FB36:                             ; CODE XREF: .text:0041FA99j
    call    sub_491A70
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+39057h], 4
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FB6C:                             ; CODE XREF: .text:0041F829j
                                            ; DATA XREF: .text:004205BCo
    mov     ecx, [esi+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_41FBF3
    push    0
    call    sub_41D6A0
    test    al, al
    jnz     short loc_41FBF3
    mov     edx, TAdynmemStructPtr
    push    101h
    add     edx, 519h
    push    offset aCdcheck_gui             ; "CDCHECK.GUI"
    push    edx
    call    sub_4AA8F0
    push    1
    mov     dword ptr [eax+8], offset loc_41F680
    call    sub_4C22D0
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    mov     edx, TAdynmemStructPtr
    mov     [edx+39057h], edi
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FBF3:                             ; CODE XREF: .text:0041FB7Aj
                                            ; .text:0041FB85j
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+39057h], 5
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FC12:                             ; CODE XREF: .text:0041F829j
                                            ; DATA XREF: .text:004205C0o
    call    sub_41DA60
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391ABh]
    inc     ecx
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435980
    mov     edx, TAdynmemStructPtr
    mov     esi, eax
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 1
    mov     eax, TAdynmemStructPtr
    mov     bl, 10h
    jnz     loc_41FD0E
    test    [eax+3923Bh], bl
    jz      loc_41FD0E
    test    esi, esi
    jnz     loc_41FD0E
    mov     ecx, [eax+39073h]
    test    ecx, ecx
    jnz     loc_41FD0E
    call    sub_4B6220
    mov     al, [eax+0F0h]
    shr     al, 1
    test    al, 1
    jz      short loc_41FCE6
    mov     ecx, TAdynmemStructPtr
    push    offset aCCavedogWarg_0          ; "c:\\cavedog\\wargame\\endgame.cpp"
    mov     edx, [ecx+1B8Ah]
    mov     al, [edx+95h]
    test    al, al
    jnz     short loc_41FCC3
    push    4CEh
    push    4
    call    sub_425860
    push    2
    call    sub_490B30
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FCC3:                             ; CODE XREF: .text:0041FC9Ej
    push    4D3h
    push    5
    call    sub_425860
    push    2
    call    sub_490B30
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FCE6:                             ; CODE XREF: .text:0041FC83j
    push    offset aCCavedogWarg_0          ; "c:\\cavedog\\wargame\\endgame.cpp"
    push    4D9h
    push    2
    call    sub_425860
    push    2
    call    sub_490B30
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FD0E:                             ; CODE XREF: .text:0041FC4Cj
                                            ; .text:0041FC58j ...
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     loc_41FDA7
    mov     edx, TAdynmemStructPtr
    test    [edx+3923Bh], bl
    jz      short loc_41FDA7
    mov     eax, [edx+3907Bh]
    test    eax, eax
    jz      short loc_41FDA7
    mov     ecx, 100h
    xor     eax, eax
    lea     edi, [esp+68h]
    push    5
    rep stosd
    mov     ecx, [edx+3907Fh]
    lea     eax, [esp+6Ch]
    push    eax
    push    ecx
    call    sub_41DFC0
    call    sub_4B6340
    mov     edx, TAdynmemStructPtr
    inc     eax
    push    0
    push    0
    mov     [edx+3905Fh], eax
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+39057h], 6
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+3907Bh]
    mov     edx, [eax+37E1Bh]
    push    ecx
    push    edx
    call    sub_4C6B70
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FDA7:                             ; CODE XREF: .text:0041FD1Cj
                                            ; .text:0041FD2Ej ...
    call    sub_41F0A0
    call    sub_41E420
    call    sub_41F400
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FAD0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA90
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+39057h], 7
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FDF8:                             ; CODE XREF: .text:0041F829j
                                            ; DATA XREF: .text:004205C4o
    mov     eax, [esi+39063h]
    test    eax, eax
    jnz     short loc_41FE3A
    call    sub_41E270
    call    sub_4B6340
    mov     esi, eax
    call    sub_4B6330
    add     esi, eax
    mov     eax, TAdynmemStructPtr
    mov     [eax+3905Bh], esi
    mov     dword_511DEC, 0
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FE3A:                             ; CODE XREF: .text:0041FE00j
    mov     eax, dword_511DEC
    test    eax, eax
    jnz     short loc_41FE52
    call    sub_476CA0
    mov     dword_511DEC, 1

    loc_41FE52:                             ; CODE XREF: .text:0041FE41j
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+3905Bh], eax
    jnb     loc_42059A
    lea     edx, [esp+50h]
    push    edx
    call    sub_4C2340
    call    sub_4C1AB0
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jnz     short loc_41FE8B
    mov     ecx, [eax+2C7Eh]
    test    ecx, ecx
    jz      short loc_41FED4

    loc_41FE8B:                             ; CODE XREF: .text:0041FE7Fj
    mov     ecx, [eax+10h]
    call    sub_4CFB40
    call    sub_41F0A0
    call    sub_41F400
    call    sub_41E420
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FAD0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA90
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+39057h], 7

    loc_41FED4:                             ; CODE XREF: .text:0041FE89j
    call    sub_4B6330
    lea     esi, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     esi, [eax+3905Bh]
    call    sub_4B6340
    cmp     esi, eax
    jnb     loc_42059A
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     ecx, [eax+37E23h]
    mov     dl, [eax+0DDAh]
    sub     ecx, 14h
    push    ecx
    xor     ecx, ecx
    mov     cl, [eax+0DCBh]
    push    edx
    push    ecx
    push    offset aClickToContinu          ; "Click to continue."
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C1830
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FF42:                             ; CODE XREF: .text:0041F829j
                                            ; DATA XREF: .text:004205C8o
    mov     ecx, [esi+531h]
    mov     eax, [ecx+4]
    xor     ecx, ecx
    movsx   edx, word ptr [eax+0B6h]
    test    edx, edx
    jle     short loc_41FF81
    add     eax, 0BEh
    mov     bl, 0Dh

    loc_41FF5F:                             ; CODE XREF: .text:0041FF7Fj
    cmp     [eax-0BEh], bl
    jnz     short loc_41FF77
    cmp     byte ptr [eax-95h], 0
    jz      short loc_41FFB7
    mov     ebp, [eax-4]
    cmp     ebp, [eax]
    jl      short loc_41FFB7

    loc_41FF77:                             ; CODE XREF: .text:0041FF65j
    inc     ecx
    add     eax, 15Bh
    cmp     ecx, edx
    jl      short loc_41FF5F

    loc_41FF81:                             ; CODE XREF: .text:0041FF56j
    add     esi, 519h
    push    esi
    call    sub_49FA50
    mov     edx, TAdynmemStructPtr
    push    13h
    mov     [edx+39057h], edi
    call    sub_491C80
    push    1
    call    sub_4C22D0
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_41FFB7:                             ; CODE XREF: .text:0041FF6Ej
                                            ; .text:0041FF75j
    add     esi, 519h
    push    esi
    call    sub_4A9FD0
    mov     eax, TAdynmemStructPtr
    push    0
    add     eax, 519h
    push    0
    push    eax
    call    sub_4AB170
    xor     edi, edi
    call    sub_4C1AB0
    mov     esi, eax
    test    esi, esi
    jz      short loc_41FFFF
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jz      short loc_41FFFF
    mov     edi, 1

    loc_41FFFF:                             ; CODE XREF: .text:0041FFE2j
                                            ; .text:0041FFF8j
    call    sub_4B6340
    mov     edx, TAdynmemStructPtr
    cmp     [edx+3905Bh], eax
    jb      short loc_42001A
    test    edi, edi
    jz      loc_42059A

    loc_42001A:                             ; CODE XREF: .text:00420010j
    test    esi, esi
    mov     esi, ds:wsprintfA
    jz      loc_420254
    xor     edi, edi
    xor     ebx, ebx

    loc_42002C:                             ; CODE XREF: .text:00420072j
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+ebx+38DD9h]
    test    cl, cl
    jz      short loc_420068
    push    edi
    push    offset aKills                   ; "Kills"
    lea     ecx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    ecx
    call    esi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+10h]
    add     eax, 519h
    push    1
    push    edx
    push    eax
    call    sub_4A0570

    loc_420068:                             ; CODE XREF: .text:0042003Aj
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_42002C
    xor     edi, edi
    xor     ebx, ebx

    loc_420078:                             ; CODE XREF: .text:004200C1j
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+ebx+38DD9h]
    test    al, al
    jz      short loc_4200B7
    push    edi
    push    offset aLosses                  ; "Losses"
    lea     edx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    edx
    call    esi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+10h]
    add     ecx, 519h
    push    1
    push    eax
    push    ecx
    call    sub_4A0570

    loc_4200B7:                             ; CODE XREF: .text:00420087j
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_420078
    xor     edi, edi
    xor     ebx, ebx

    loc_4200C7:                             ; CODE XREF: .text:00420110j
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+ebx+38DD9h]
    test    al, al
    jz      short loc_420106
    push    edi
    push    offset aEproduced               ; "EProduced"
    lea     eax, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    eax
    call    esi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+10h]
    add     edx, 519h
    push    1
    push    ecx
    push    edx
    call    sub_4A0570

    loc_420106:                             ; CODE XREF: .text:004200D6j
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_4200C7
    xor     edi, edi
    xor     ebx, ebx

    loc_420116:                             ; CODE XREF: .text:0042015Cj
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+ebx+38DD9h]
    test    cl, cl
    jz      short loc_420152
    push    edi
    push    offset aMproduced               ; "MProduced"
    lea     ecx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    ecx
    call    esi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+10h]
    add     eax, 519h
    push    1
    push    edx
    push    eax
    call    sub_4A0570

    loc_420152:                             ; CODE XREF: .text:00420124j
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_420116
    xor     edi, edi
    xor     ebx, ebx

    loc_420162:                             ; CODE XREF: .text:004201ABj
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+ebx+38DD9h]
    test    al, al
    jz      short loc_4201A1
    push    edi
    push    offset aEwasted                 ; "EWasted"
    lea     edx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    edx
    call    esi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+10h]
    add     ecx, 519h
    push    1
    push    eax
    push    ecx
    call    sub_4A0570

    loc_4201A1:                             ; CODE XREF: .text:00420171j
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_420162
    xor     edi, edi
    xor     ebx, ebx

    loc_4201B1:                             ; CODE XREF: .text:004201FAj
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+ebx+38DD9h]
    test    al, al
    jz      short loc_4201F0
    push    edi
    push    offset aMwasted                 ; "MWasted"
    lea     eax, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    eax
    call    esi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+10h]
    add     edx, 519h
    push    1
    push    ecx
    push    edx
    call    sub_4A0570

    loc_4201F0:                             ; CODE XREF: .text:004201C0j
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_4201B1
    xor     edi, edi
    xor     ebx, ebx

    loc_420200:                             ; CODE XREF: .text:00420246j
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+ebx+38DD9h]
    test    cl, cl
    jz      short loc_42023C
    push    edi
    push    offset aScore                   ; "Score"
    lea     ecx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    ecx
    call    esi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+10h]
    add     eax, 519h
    push    1
    push    edx
    push    eax
    call    sub_4A0570

    loc_42023C:                             ; CODE XREF: .text:0042020Ej
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_420200
    push    0
    push    offset aActivateallsta          ; "ActivateAllStatBars"
    call    sub_47F1A0

    loc_420254:                             ; CODE XREF: .text:00420022j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+3906Bh]
    cmp     eax, 6                          ; switch 7 cases
    ja      loc_4204E4                      ; default
    jmp     ds:off_4205D0[eax*4]            ; switch jump

    loc_420270:                             ; CODE XREF: .text:0041F829j
                                            ; DATA XREF: .text:004205D0o
    xor     edi, edi                        ; case 0x0
    xor     ebx, ebx

    loc_420274:                             ; CODE XREF: .text:004202BDj
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+ebx+38DD9h]
    test    al, al
    jz      short loc_4202B3
    push    edi
    push    offset aKills                   ; "Kills"
    lea     eax, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    eax
    call    esi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+10h]
    add     edx, 519h
    push    1
    push    ecx
    push    edx
    call    sub_4A0570

    loc_4202B3:                             ; CODE XREF: .text:00420283j
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_420274
    push    0
    push    offset aEndgamestatbar          ; "EndGameStatBar"
    jmp     loc_4204DF
    ; ---------------------------------------------------------------------------

    loc_4202CB:                             ; CODE XREF: .text:00420269j
                                            ; DATA XREF: .text:004205D0o
    xor     edi, edi                        ; case 0x1
    xor     ebx, ebx

    loc_4202CF:                             ; CODE XREF: .text:00420315j
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+ebx+38DD9h]
    test    cl, cl
    jz      short loc_42030B
    push    edi
    push    offset aLosses                  ; "Losses"
    lea     ecx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    ecx
    call    esi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+10h]
    add     eax, 519h
    push    1
    push    edx
    push    eax
    call    sub_4A0570

    loc_42030B:                             ; CODE XREF: .text:004202DDj
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_4202CF
    push    0
    push    offset aEndgamestatbar          ; "EndGameStatBar"
    jmp     loc_4204DF
    ; ---------------------------------------------------------------------------

    loc_420323:                             ; CODE XREF: .text:00420269j
                                            ; DATA XREF: .text:004205D0o
    xor     edi, edi                        ; case 0x2
    xor     ebx, ebx

    loc_420327:                             ; CODE XREF: .text:00420370j
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+ebx+38DD9h]
    test    al, al
    jz      short loc_420366
    push    edi
    push    offset aEproduced               ; "EProduced"
    lea     edx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    edx
    call    esi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+10h]
    add     ecx, 519h
    push    1
    push    eax
    push    ecx
    call    sub_4A0570

    loc_420366:                             ; CODE XREF: .text:00420336j
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_420327
    push    0
    push    offset aEndgamestatbar          ; "EndGameStatBar"
    jmp     loc_4204DF
    ; ---------------------------------------------------------------------------

    loc_42037E:                             ; CODE XREF: .text:00420269j
                                            ; DATA XREF: .text:004205D0o
    xor     edi, edi                        ; case 0x3
    xor     ebx, ebx

    loc_420382:                             ; CODE XREF: .text:004203CBj
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+ebx+38DD9h]
    test    al, al
    jz      short loc_4203C1
    push    edi
    push    offset aMproduced               ; "MProduced"
    lea     eax, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    eax
    call    esi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+10h]
    add     edx, 519h
    push    1
    push    ecx
    push    edx
    call    sub_4A0570

    loc_4203C1:                             ; CODE XREF: .text:00420391j
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_420382
    push    0
    push    offset aEndgamestatbar          ; "EndGameStatBar"
    jmp     loc_4204DF
    ; ---------------------------------------------------------------------------

    loc_4203D9:                             ; CODE XREF: .text:00420269j
                                            ; DATA XREF: .text:004205D0o
    xor     edi, edi                        ; case 0x4
    xor     ebx, ebx

    loc_4203DD:                             ; CODE XREF: .text:00420423j
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+ebx+38DD9h]
    test    cl, cl
    jz      short loc_420419
    push    edi
    push    offset aEwasted                 ; "EWasted"
    lea     ecx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    ecx
    call    esi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+10h]
    add     eax, 519h
    push    1
    push    edx
    push    eax
    call    sub_4A0570

    loc_420419:                             ; CODE XREF: .text:004203EBj
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_4203DD
    push    0
    push    offset aEndgamestatbar          ; "EndGameStatBar"
    jmp     loc_4204DF
    ; ---------------------------------------------------------------------------

    loc_420431:                             ; CODE XREF: .text:00420269j
                                            ; DATA XREF: .text:004205D0o
    xor     edi, edi                        ; case 0x5
    xor     ebx, ebx

    loc_420435:                             ; CODE XREF: .text:0042047Ej
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+ebx+38DD9h]
    test    al, al
    jz      short loc_420474
    push    edi
    push    offset aMwasted                 ; "MWasted"
    lea     edx, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    edx
    call    esi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+10h]
    add     ecx, 519h
    push    1
    push    eax
    push    ecx
    call    sub_4A0570

    loc_420474:                             ; CODE XREF: .text:00420444j
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_420435
    push    0
    push    offset aEndgamestatbar          ; "EndGameStatBar"
    jmp     short loc_4204DF
    ; ---------------------------------------------------------------------------

    loc_420489:                             ; CODE XREF: .text:00420269j
                                            ; DATA XREF: .text:004205D0o
    xor     edi, edi                        ; case 0x6
    xor     ebx, ebx

    loc_42048D:                             ; CODE XREF: .text:004204D6j
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+ebx+38DD9h]
    test    al, al
    jz      short loc_4204CC
    push    edi
    push    offset aScore                   ; "Score"
    lea     eax, [esp+18h]
    push    offset aSD                      ; "%s%d"
    push    eax
    call    esi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+10h]
    add     edx, 519h
    push    1
    push    ecx
    push    edx
    call    sub_4A0570

    loc_4204CC:                             ; CODE XREF: .text:0042049Cj
    add     ebx, 3Ah
    inc     edi
    cmp     ebx, 244h
    jl      short loc_42048D
    push    0
    push    offset aEndgamescore            ; "EndGameScore"

    loc_4204DF:                             ; CODE XREF: .text:004202C6j
                                            ; .text:0042031Ej ...
    call    sub_47F1A0

    loc_4204E4:                             ; CODE XREF: .text:00420263j
    mov     eax, TAdynmemStructPtr          ; default
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_42052C
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     esi, 2
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    add     ecx, edx
    lea     eax, [eax+eax*4]
    lea     edi, [ecx+eax*2+1B63h]

    loc_42051F:                             ; CODE XREF: .text:0042052Aj
    push    0
    push    0
    push    edi
    call    sub_4573D0
    dec     esi
    jnz     short loc_42051F

    loc_42052C:                             ; CODE XREF: .text:004204F7j
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    add     eax, 0Ah
    mov     [ecx+3905Bh], eax
    mov     eax, TAdynmemStructPtr
    inc     dword ptr [eax+3906Bh]
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------

    loc_42055B:                             ; CODE XREF: .text:0041F829j
                                            ; DATA XREF: .text:004205CCo
    call    sub_4C2470
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4A9FD0
    call    sub_4C2870
    call    sub_4C63A0
    call    sub_4C2470
    mov     eax, TAdynmemStructPtr
    push    0
    add     eax, 519h
    push    0
    push    eax
    call    sub_4AB170
    call    sub_4C2870

    loc_42059A:                             ; CODE XREF: .text:0041F823j
                                            ; .text:0041F8D5j ...
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 458h
    retn
    ; ---------------------------------------------------------------------------
    align 4
    off_4205AC dd offset loc_41F830         ; DATA XREF: .text:0041F829r
    dd offset loc_41F976
    dd offset loc_41FA3D
    dd offset loc_41FA8F
    dd offset loc_41FB6C
    dd offset loc_41FC12
    dd offset loc_41FDF8
    dd offset loc_41FF42
    dd offset loc_42055B
    off_4205D0 dd offset loc_420270         ; DATA XREF: .text:00420269r
    dd offset loc_4202CB                    ; jump table for switch statement
    dd offset loc_420323
    dd offset loc_42037E
    dd offset loc_4203D9
    dd offset loc_420431
    dd offset loc_420489
    align 8
    mov     ecx, offset dword_511F80
    call    sub_4379A0
    push    offset unknown_libname_5
    call    _atexit
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_5:                      ; DATA XREF: .text:004205FAo
    mov     ecx, offset dword_511F80
    jmp     sub_437A20
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_420620 proc near                    ; CODE XREF: sub_4917D0+202p

    var_4= dword ptr -4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    8
    push    16h
    push    16h
    mov     dword ptr [eax+1491Bh], 0
    call    sub_4B91B0
    mov     ecx, TAdynmemStructPtr
    mov     edi, 40h
    push    88h
    push    offset aCalcedexplosio          ; "CalcedExplosion"
    mov     [ecx+1AB9Bh], eax
    mov     eax, 1Eh
    mov     dword_511F90, 18h
    mov     dword_511F94, edi
    mov     dword_511F98, 8
    mov     dword_511F9C, eax
    mov     dword_511FA0, 80h
    mov     dword_511FA4, 10h
    mov     dword_511FA8, eax
    mov     dword_511FAC, 0C8h
    mov     dword_511FB0, 20h
    call    sub_4D83B0
    mov     ebx, eax
    add     esp, 8
    mov     ebp, 0Ch
    mov     word ptr [ebx], 0Ch
    mov     byte ptr [ebx+2], 0
    lea     esi, [ebx+2Ch]

    loc_4206C6:                             ; CODE XREF: sub_420620+BBj
    push    edi
    call    sub_420D20
    mov     [esi-4], eax
    mov     word ptr [esi], 2
    sub     edi, 4
    add     esi, 8
    dec     ebp
    jnz     short loc_4206C6
    mov     edx, TAdynmemStructPtr
    mov     [edx+1AB8Fh], ebx
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+38D74h], 14h
    mov     eax, dword_511F9C
    cdq
    sub     eax, edx
    mov     ebp, dword_511FA4
    mov     edi, eax
    mov     ebx, dword_511FA0
    sar     edi, 1
    lea     ecx, ds:28h[edi*8]
    push    ecx
    push    offset aCalcedexplosio          ; "CalcedExplosion"
    call    sub_4D83B0
    mov     esi, eax
    mov     eax, ebp
    sub     eax, ebx
    add     esp, 8
    cdq
    idiv    edi
    test    edi, edi
    mov     [esp+14h+var_4], esi
    mov     [esi], di
    mov     byte ptr [esi+2], 0
    mov     ebp, eax
    jle     short loc_420759
    add     esi, 2Ch

    loc_42073F:                             ; CODE XREF: sub_420620+133j
    push    ebx
    call    sub_420D20
    mov     [esi-4], eax
    mov     word ptr [esi], 2
    add     ebx, ebp
    add     esi, 8
    dec     edi
    jnz     short loc_42073F
    mov     esi, [esp+14h+var_4]

    loc_420759:                             ; CODE XREF: sub_420620+11Aj
    mov     edx, TAdynmemStructPtr
    mov     [edx+1AB93h], esi
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+38D74h], 32h
    mov     eax, dword_511FA8
    cdq
    sub     eax, edx
    mov     ebp, dword_511FB0
    mov     edi, eax
    mov     ebx, dword_511FAC
    sar     edi, 1
    lea     ecx, ds:28h[edi*8]
    push    ecx
    push    offset aCalcedexplosio          ; "CalcedExplosion"
    call    sub_4D83B0
    mov     esi, eax
    mov     eax, ebp
    sub     eax, ebx
    add     esp, 8
    cdq
    idiv    edi
    test    edi, edi
    mov     [esp+14h+var_4], esi
    mov     [esi], di
    mov     byte ptr [esi+2], 0
    mov     ebp, eax
    jle     short loc_4207D5
    add     esi, 2Ch

    loc_4207BB:                             ; CODE XREF: sub_420620+1AFj
    push    ebx
    call    sub_420D20
    mov     [esi-4], eax
    mov     word ptr [esi], 2
    add     ebx, ebp
    add     esi, 8
    dec     edi
    jnz     short loc_4207BB
    mov     esi, [esp+14h+var_4]

    loc_4207D5:                             ; CODE XREF: sub_420620+196j
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edi, offset aExplodepiece       ; "explodepiece"
    mov     [edx+1AB97h], esi
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     byte ptr [eax+38D74h], 64h
    xor     eax, eax
    or      ebx, 0FFFFFFFFh

    loc_4207FB:                             ; CODE XREF: sub_420620+26Fj
    mov     esi, TAdynmemStructPtr
    add     eax, 34h
    mov     [esi+eax+1AB6Bh], bl
    mov     esi, TAdynmemStructPtr
    mov     dword ptr [esi+eax+1AB6Fh], 8
    mov     esi, TAdynmemStructPtr
    mov     dword ptr [esi+eax+1AB73h], 6
    mov     esi, TAdynmemStructPtr
    mov     [esi+eax+1AB77h], ebx
    mov     esi, TAdynmemStructPtr
    mov     [esi+eax+1AB87h], edi
    mov     esi, TAdynmemStructPtr
    mov     dword ptr [esi+eax+1AB8Bh], 0
    mov     esi, TAdynmemStructPtr
    lea     ebp, [esi+ecx+1E88Fh]
    add     ecx, 60h
    mov     [esi+eax+1AB8Fh], ebp
    mov     esi, TAdynmemStructPtr
    lea     ebp, [esi+edx+2590Fh]
    add     edx, 0C0h
    mov     [esi+eax+1AB93h], ebp
    cmp     ecx, 7080h
    jl      loc_4207FB
    xor     eax, eax
    mov     esi, 1

    loc_42089C:                             ; CODE XREF: sub_420620+2D9j
    mov     ecx, offset dword_502BF8

    loc_4208A1:                             ; CODE XREF: sub_420620+2D2j
    mov     edx, TAdynmemStructPtr
    add     eax, 20h
    mov     ebp, [edx+eax+2590Bh]
    or      ebp, esi
    mov     [edx+eax+2590Bh], ebp
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+eax+258EFh], 0C8h
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+eax+258F3h], 4
    mov     edx, TAdynmemStructPtr
    mov     [edx+eax+258FBh], ecx
    add     ecx, 8
    cmp     ecx, offset aExplodepiece       ; "explodepiece"
    jl      short loc_4208A1
    cmp     eax, 0E100h
    jl      short loc_42089C
    push    186A0h
    mov     ecx, offset dword_511F80
    call    sub_4379B0
    mov     ecx, 64h
    xor     eax, eax
    mov     edi, offset dword_511DF0
    rep stosd
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_420620 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    lea     ecx, [edx+1AB9Fh]

    loc_42092E:                             ; CODE XREF: .text:0042093Cj
    cmp     byte ptr [ecx], 0FFh
    jz      short loc_420941
    inc     eax
    add     ecx, 34h
    cmp     eax, 12Ch
    jl      short loc_42092E
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_420941:                             ; CODE XREF: .text:00420931j
    lea     ecx, [eax+eax*2]
    lea     eax, [eax+ecx*4]
    shl     eax, 2
    mov     byte ptr [edx+eax+1AB9Fh], 0
    mov     edx, TAdynmemStructPtr
    lea     eax, [edx+eax+1AB9Fh]
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_420960 proc near                    ; CODE XREF: sub_491B60+3Fp
    mov     eax, TAdynmemStructPtr
    push    ebp
    xor     ebp, ebp
    cmp     [eax+1AB9Bh], ebp
    jz      loc_420A1F
    push    edi
    push    esi
    push    ebx
    mov     ecx, offset dword_511F80
    call    sub_437A00
    mov     ecx, TAdynmemStructPtr
    xor     esi, esi

    loc_420989:                             ; CODE XREF: sub_420960+A0j
    mov     eax, [ecx+esi+1AB8Fh]
    cmp     eax, ebp
    jz      short loc_4209FA
    xor     ebx, ebx
    cmp     [eax], bp
    jbe     short loc_4209D7
    mov     edi, 28h

    loc_4209A0:                             ; CODE XREF: sub_420960+75j
    mov     ecx, [edi+eax]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    inc     ebx
    add     edi, 8
    mov     eax, [edx+esi+1AB8Fh]
    xor     edx, edx
    mov     [eax+edi-8], ebp
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+esi+1AB8Fh]
    mov     dx, [eax]
    cmp     ebx, edx
    jl      short loc_4209A0

    loc_4209D7:                             ; CODE XREF: sub_420960+39j
    mov     eax, [ecx+esi+1AB8Fh]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     [ecx+esi+1AB8Fh], ebp
    mov     ecx, TAdynmemStructPtr

    loc_4209FA:                             ; CODE XREF: sub_420960+32j
    add     esi, 4
    cmp     esi, 0Ch
    jl      short loc_420989
    mov     edx, [ecx+1AB9Bh]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    pop     ebx
    pop     esi
    mov     [eax+1AB9Bh], ebp
    pop     edi

    loc_420A1F:                             ; CODE XREF: sub_420960+Ej
    pop     ebp
    retn
    sub_420960 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_420A30 proc near                    ; CODE XREF: sub_420F30+16Cp
                                            ; sub_4213B0+90p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, TAdynmemStructPtr
    push    edi
    mov     ecx, [eax+1491Bh]
    lea     edi, [eax+1491Bh]
    cmp     ecx, 12Ch
    jge     loc_420AEE
    lea     eax, ds:0[ecx*8]
    push    esi
    sub     eax, ecx
    push    ebx
    mov     ebx, [esp+0Ch+arg_0]
    inc     ecx
    lea     edx, [eax+eax*2]
    mov     [edi], ecx
    mov     ecx, ebx
    lea     esi, [edi+edx*4+4]
    mov     edx, [ecx]
    lea     eax, [esi+1Ch]
    mov     [esi+1Ch], edx
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     ecx, [ecx+8]
    mov     [eax+8], ecx
    mov     eax, [esp+0Ch+arg_4]
    test    eax, eax
    jz      short loc_420A93
    push    0
    lea     edx, [esi+4]
    push    eax
    push    edx
    call    sub_4B8B30
    jmp     short loc_420A9A
    ; ---------------------------------------------------------------------------

    loc_420A93:                             ; CODE XREF: sub_420A30+53j
    mov     dword ptr [esi+0Ch], 0

    loc_420A9A:                             ; CODE XREF: sub_420A30+61j
    mov     eax, [esp+0Ch+arg_8]
    test    eax, eax
    jl      short loc_420AB7
    mov     eax, [edi+eax*4+6274h]
    push    0
    lea     ecx, [esi+10h]
    push    eax
    push    ecx
    call    sub_4B8B30
    jmp     short loc_420ABE
    ; ---------------------------------------------------------------------------

    loc_420AB7:                             ; CODE XREF: sub_420A30+70j
    mov     dword ptr [esi+18h], 0

    loc_420ABE:                             ; CODE XREF: sub_420A30+85j
    mov     eax, [esp+0Ch+arg_C]
    test    eax, eax
    jnz     short loc_420AE6
    mov     edx, TAdynmemStructPtr
    movzx   ax, byte ptr [edx+1427Fh]
    cmp     [ebx+6], ax
    jle     short loc_420AE6
    push    9
    push    0Fh
    push    7
    push    ebx
    call    sub_472630

    loc_420AE6:                             ; CODE XREF: sub_420A30+94j
                                            ; sub_420A30+A8j
    mov     dword ptr [esi], 0
    pop     ebx
    pop     esi

    loc_420AEE:                             ; CODE XREF: sub_420A30+18j
    pop     edi
    retn    10h
    sub_420A30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_420B00 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+E3Cp

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 14h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     esi, offset dword_511DF0

    loc_420B0C:                             ; CODE XREF: sub_420B00+2Cj
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_420B23
    push    eax
    mov     eax, [esp+28h+arg_0]
    push    eax
    call    sub_421550
    test    eax, eax
    jnz     short loc_420B23
    mov     [esi], eax

    loc_420B23:                             ; CODE XREF: sub_420B00+10j
                                            ; sub_420B00+1Fj
    add     esi, 4
    cmp     esi, offset dword_511F80
    jl      short loc_420B0C
    mov     eax, TAdynmemStructPtr
    xor     ebp, ebp
    mov     edx, [eax+1491Bh]
    lea     ecx, [eax+1491Bh]
    test    edx, edx
    lea     esi, [ecx+4]
    mov     [esp+24h+var_14], ecx
    mov     [esp+24h+var_10], esi
    jle     loc_420BE8
    lea     ebx, [esi+20h]

    loc_420B57:                             ; CODE XREF: sub_420B00+DCj
    mov     ecx, [eax+1431Fh]
    mov     edx, [ebx-4]
    shl     ecx, 10h
    sub     edx, ecx
    add     eax, 37E27h
    mov     [esp+24h+var_C], edx
    mov     ecx, [ebx]
    mov     [esp+24h+var_8], ecx
    mov     edx, [eax-23B04h]
    mov     ecx, [ebx+4]
    shl     edx, 10h
    movsx   esi, word ptr [esp+24h+var_C+2]
    sub     ecx, edx
    add     esi, 80h
    movsx   edx, word ptr [esp+24h+var_8+2]
    mov     [esp+24h+var_4], ecx
    movsx   edi, word ptr [esp+24h+var_4+2]
    sar     edx, 1
    sub     edi, edx
    add     edi, 20h
    push    edi
    push    esi
    push    eax
    call    sub_4B6720
    test    eax, eax
    jz      short loc_420BCB
    mov     eax, [ebx-8]
    test    eax, eax
    jz      short loc_420BCB
    push    edi
    lea     eax, [ebx-10h]
    push    esi
    push    eax
    call    sub_4B7EE0
    push    eax
    mov     ecx, [esp+30h+arg_0]
    push    ecx
    call    sub_4B8EC0

    loc_420BCB:                             ; CODE XREF: sub_420B00+ACj
                                            ; sub_420B00+B3j
    mov     edx, [esp+24h+var_14]
    inc     ebp
    add     ebx, 54h
    mov     eax, [edx]
    cmp     ebp, eax
    mov     eax, TAdynmemStructPtr
    jl      loc_420B57
    mov     esi, [esp+24h+var_10]
    mov     ecx, edx

    loc_420BE8:                             ; CODE XREF: sub_420B00+4Ej
    mov     edx, [ecx]
    xor     ebp, ebp
    test    edx, edx
    jle     loc_420C9A
    jmp     short loc_420BFB
    ; ---------------------------------------------------------------------------

    loc_420BF6:                             ; CODE XREF: sub_420B00+194j
    mov     eax, TAdynmemStructPtr

    loc_420BFB:                             ; CODE XREF: sub_420B00+F4j
    mov     ecx, [eax+1431Fh]
    mov     edx, [esi+1Ch]
    shl     ecx, 10h
    sub     edx, ecx
    add     eax, 37E27h
    mov     [esp+24h+var_C], edx
    mov     ecx, [esi+20h]
    mov     [esp+24h+var_8], ecx
    mov     edx, [eax-23B04h]
    mov     ecx, [esi+24h]
    shl     edx, 10h
    movsx   ebx, word ptr [esp+24h+var_C+2]
    sub     ecx, edx
    add     ebx, 80h
    movsx   edx, word ptr [esp+24h+var_8+2]
    mov     [esp+24h+var_4], ecx
    movsx   edi, word ptr [esp+24h+var_4+2]
    sar     edx, 1
    sub     edi, edx
    add     edi, 20h
    push    edi
    push    ebx
    push    eax
    call    sub_4B6720
    test    eax, eax
    jz      short loc_420C8A
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_420C6D
    lea     ecx, [esi+4Ch]
    lea     edx, [esp+24h+var_C]
    push    ecx
    push    eax
    mov     eax, [esp+2Ch+arg_0]
    push    edx
    push    eax
    call    sub_46BAE0

    loc_420C6D:                             ; CODE XREF: sub_420B00+157j
    mov     eax, [esi+0Ch]
    test    eax, eax
    jz      short loc_420C8A
    push    edi
    lea     ecx, [esi+4]
    push    ebx
    push    ecx
    call    sub_4B7EE0
    push    eax
    mov     edx, [esp+30h+arg_0]
    push    edx
    call    sub_4B7F90

    loc_420C8A:                             ; CODE XREF: sub_420B00+151j
                                            ; sub_420B00+172j
    mov     eax, [esp+24h+var_14]
    inc     ebp
    add     esi, 54h
    cmp     ebp, [eax]
    jl      loc_420BF6

    loc_420C9A:                             ; CODE XREF: sub_420B00+EEj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    4
    sub_420B00 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    mov     ebx, [esp+8]
    push    ebp
    push    esi
    lea     eax, ds:28h[ebx*8]
    push    edi
    push    eax
    push    offset aCalcedexplosio          ; "CalcedExplosion"
    call    sub_4D83B0
    mov     edi, [esp+20h]
    mov     esi, eax
    mov     eax, [esp+24h]
    add     esp, 8
    sub     eax, edi
    mov     [esp+14h], esi
    cdq
    idiv    ebx
    test    ebx, ebx
    mov     [esi], bx
    mov     byte ptr [esi+2], 0
    mov     ebp, eax
    jle     short loc_420D0A
    add     esi, 2Ch

    loc_420CF0:                             ; CODE XREF: .text:00420D04j
    push    edi
    call    sub_420D20
    mov     [esi-4], eax
    mov     word ptr [esi], 2
    add     edi, ebp
    add     esi, 8
    dec     ebx
    jnz     short loc_420CF0
    mov     esi, [esp+14h]

    loc_420D0A:                             ; CODE XREF: .text:00420CEBj
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_420D20 proc near                    ; CODE XREF: sub_420620+A7p
                                            ; sub_420620+120p ...

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= qword ptr -18h
    var_10= qword ptr -10h
    var_8= qword ptr -8
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    and     esp, 0FFFFFFF8h
    sub     esp, 24h
    push    ebx
    push    esi
    mov     esi, [ebp+arg_0]
    push    edi
    mov     eax, esi
    push    esi
    cdq
    sub     eax, edx
    push    esi
    sar     eax, 1
    mov     [esp+38h+var_1C], eax
    push    offset aExplosionframe          ; "ExplosionFrame"
    fild    [esp+3Ch+var_1C]
    fstp    [esp+3Ch+var_18]
    call    sub_4B8DA0
    fld     [esp+30h+var_18]
    mov     edi, eax
    call    __ftol
    xor     ebx, ebx
    mov     [edi+4], ax
    cmp     esi, ebx
    mov     [edi+6], ax
    mov     [esp+30h+var_20], ebx
    jle     loc_420E34

    loc_420D6F:                             ; CODE XREF: sub_420D20+10Ej
    fild    [esp+30h+var_20]
    xor     esi, esi
    mov     [esp+30h+var_1C], esi
    fsubr   [esp+30h+var_18]
    fld     st
    fmul    st, st(1)
    fmul    ds:dbl_4FD010
    fstp    [esp+30h+var_8]
    fstp    st

    loc_420D8D:                             ; CODE XREF: sub_420D20+F8j
    fild    [esp+30h+var_1C]
    fsubr   [esp+30h+var_18]
    fstp    [esp+30h+var_10]
    call    _rand
    cdq
    push    0
    push    0Ah
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     [esp+30h+var_1C], eax
    fild    [esp+30h+var_1C]
    fld     [esp+30h+var_10]
    fmul    [esp+30h+var_10]
    fadd    [esp+30h+var_8]
    fsqrt
    faddp   st(1), st
    fdiv    [esp+30h+var_18]
    fmul    ds:dbl_4FD018
    call    __ftol
    mov     cl, 20h
    sub     cl, al
    cmp     cl, 22h
    jb      short loc_420DF3
    mov     eax, [edi+10h]
    add     eax, esi
    mov     byte ptr [eax+ebx], 0FFh
    jmp     short loc_420E0E
    ; ---------------------------------------------------------------------------

    loc_420DF3:                             ; CODE XREF: sub_420D20+C6j
    cmp     cl, 20h
    jb      short loc_420E03
    mov     ecx, [edi+10h]
    add     ecx, esi
    mov     byte ptr [ecx+ebx], 6Eh
    jmp     short loc_420E0E
    ; ---------------------------------------------------------------------------

    loc_420E03:                             ; CODE XREF: sub_420D20+D6j
    mov     edx, [edi+10h]
    add     cl, 4Fh
    add     edx, esi
    mov     [edx+ebx], cl

    loc_420E0E:                             ; CODE XREF: sub_420D20+D1j
                                            ; sub_420D20+E1j
    mov     eax, [ebp+arg_0]
    inc     esi
    cmp     esi, eax
    mov     [esp+30h+var_1C], esi
    jl      loc_420D8D
    mov     eax, [esp+30h+var_20]
    mov     ecx, [ebp+arg_0]
    inc     eax
    add     ebx, ecx
    cmp     eax, ecx
    mov     [esp+30h+var_20], eax
    jl      loc_420D6F

    loc_420E34:                             ; CODE XREF: sub_420D20+49j
    mov     byte ptr [edi+8], 0FFh
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    sub_420D20 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 30h
    mov     eax, [esp+28h]
    push    esi
    and     al, 0EFh
    push    edi
    mov     edi, [esp+3Ch]
    and     al, 0DFh
    mov     [esp+30h], eax
    mov     [esp+8], edi
    mov     eax, [edi+9Eh]
    mov     dword ptr [esp+28h], 384h
    mov     dword ptr [esp+2Ch], 1
    xor     esi, esi
    cmp     dword ptr [eax], 0
    jle     loc_420F28

    loc_420E8A:                             ; CODE XREF: .text:00420F22j
    push    64h
    call    GetRandom
    and     eax, 1
    push    0BB8h
    mov     ecx, [esp+34h]
    and     ecx, 0FFFFFFFDh
    shl     eax, 1
    or      ecx, eax
    or      ecx, 4
    or      ecx, 8
    mov     [esp+34h], ecx
    call    GetRandom
    push    0BB8h
    mov     [esp+14h], eax
    call    GetRandom
    push    0BB8h
    mov     [esp+18h], eax
    call    GetRandom
    push    28h
    mov     [esp+1Ch], eax
    call    GetRandom
    mov     ecx, 14h
    push    0Ah
    sub     ecx, eax
    shl     ecx, 0Eh
    mov     [esp+20h], ecx
    call    GetRandom
    shl     eax, 10h
    push    28h
    mov     [esp+24h], eax
    call    GetRandom
    mov     edx, 14h
    mov     [esp+0Ch], esi
    sub     edx, eax
    lea     eax, [esp+8]
    shl     edx, 0Eh
    push    eax
    mov     [esp+28h], edx
    call    sub_421620
    mov     ecx, [edi+9Eh]
    inc     esi
    cmp     esi, [ecx]
    jl      loc_420E8A

    loc_420F28:                             ; CODE XREF: .text:00420E84j
    pop     edi
    pop     esi
    add     esp, 30h
    retn    4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_420F30 proc near                    ; CODE XREF: .text:00495539p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_4= dword ptr -4

    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     esi, offset dword_511DF0

    loc_420F3C:                             ; CODE XREF: sub_420F30+27j
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_420F4E
    push    eax
    call    sub_4213B0
    test    eax, eax
    jnz     short loc_420F4E
    mov     [esi], eax

    loc_420F4E:                             ; CODE XREF: sub_420F30+10j
                                            ; sub_420F30+1Aj
    add     esi, 4
    cmp     esi, offset dword_511F80
    jl      short loc_420F3C
    mov     eax, TAdynmemStructPtr
    mov     [esp+28h+var_14], 0
    lea     ebx, [eax+1491Bh]
    mov     [esp+28h+var_18], ebx
    mov     eax, [ebx]
    lea     esi, [ebx+4]
    test    eax, eax
    mov     [esp+28h+var_10], esi
    jle     loc_4210E6

    loc_420F81:                             ; CODE XREF: sub_420F30+1B0j
    cmp     dword ptr [esi], 0
    jz      loc_4210B0
    lea     edi, [esi+1Ch]
    mov     eax, [esi+28h]
    mov     ecx, edi
    push    edi
    mov     ebp, [ecx]
    mov     ebx, [ecx+4]
    mov     edx, [ecx+8]
    mov     ecx, [edi]
    mov     [esp+2Ch+var_4], edx
    mov     edx, [esi+34h]
    add     eax, edx
    mov     edx, [esi+20h]
    add     ecx, eax
    mov     eax, [esi+38h]
    mov     [edi], ecx
    mov     ecx, [esi+2Ch]
    add     ecx, eax
    mov     eax, [esi+24h]
    add     edx, ecx
    mov     ecx, [esi+30h]
    mov     [esi+20h], edx
    mov     edx, [esi+3Ch]
    add     edx, ecx
    add     eax, edx
    mov     [esi+24h], eax
    mov     eax, TAdynmemStructPtr
    mov     edx, [esi+38h]
    mov     ecx, [eax+14263h]
    sub     edx, ecx
    mov     [esi+38h], edx
    mov     dx, [esi+40h]
    mov     ax, [esi+44h]
    mov     cx, [esi+48h]
    add     [esi+4Ch], dx
    add     [esi+4Eh], ax
    add     [esi+50h], cx
    call    sub_485140
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [edx+1427Fh]
    mov     edx, ecx
    shl     edx, 10h
    cmp     [esi+20h], edx
    jg      short loc_42105A
    cmp     eax, ecx
    jge     short loc_42105A
    test    byte ptr [esi+52h], 1
    jz      loc_4210A1
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+391E9h]
    mov     edx, [eax+0D48h]
    test    edx, edx
    jnz     short loc_4210A1
    mov     edx, [eax+0D44h]
    test    edx, edx
    jz      short loc_42104D
    mov     eax, [ecx+147EFh]
    push    1
    push    0FFFFFFFFh
    push    eax
    jmp     short loc_42109B
    ; ---------------------------------------------------------------------------

    loc_42104D:                             ; CODE XREF: sub_420F30+10Ej
    mov     eax, [ecx+147EBh]
    push    1
    push    0FFFFFFFFh
    push    eax
    jmp     short loc_42109B
    ; ---------------------------------------------------------------------------

    loc_42105A:                             ; CODE XREF: sub_420F30+E0j
                                            ; sub_420F30+E4j
    movsx   ecx, word ptr [esi+22h]
    cmp     ecx, eax
    jg      short loc_4210AC
    mov     eax, [esp+28h+var_4]
    mov     edx, edi
    mov     [edx], ebp
    mov     [edx+4], ebx
    mov     [edx+8], eax
    mov     eax, [esi+38h]
    cdq
    sub     eax, edx
    sar     eax, 1
    neg     eax
    mov     [esi+38h], eax
    cmp     word ptr [esi+3Ah], 0
    jg      short loc_4210AC
    test    byte ptr [esi+52h], 1
    jz      short loc_4210A1
    mov     ecx, TAdynmemStructPtr
    push    0
    push    0
    mov     edx, [ecx+147F7h]
    push    edx

    loc_42109B:                             ; CODE XREF: sub_420F30+11Bj
                                            ; sub_420F30+128j
    push    edi
    call    sub_420A30

    loc_4210A1:                             ; CODE XREF: sub_420F30+EAj
                                            ; sub_420F30+104j ...
    mov     eax, [esi]
    mov     byte ptr [eax], 0FFh
    mov     dword ptr [esi], 0

    loc_4210AC:                             ; CODE XREF: sub_420F30+130j
                                            ; sub_420F30+152j
    mov     ebx, [esp+28h+var_18]

    loc_4210B0:                             ; CODE XREF: sub_420F30+54j
    mov     eax, [esi+0Ch]
    test    eax, eax
    jz      short loc_4210C0
    lea     ecx, [esi+4]
    push    ecx
    call    sub_4B8B90

    loc_4210C0:                             ; CODE XREF: sub_420F30+185j
    mov     eax, [esi+18h]
    test    eax, eax
    jz      short loc_4210D0
    lea     edx, [esi+10h]
    push    edx
    call    sub_4B8B90

    loc_4210D0:                             ; CODE XREF: sub_420F30+195j
    mov     eax, [esp+28h+var_14]
    mov     ecx, [ebx]
    inc     eax
    add     esi, 54h
    cmp     eax, ecx
    mov     [esp+28h+var_14], eax
    jl      loc_420F81

    loc_4210E6:                             ; CODE XREF: sub_420F30+4Bj
                                            ; sub_420F30+20Ej
    mov     ecx, [ebx]
    mov     eax, [esp+28h+var_10]
    xor     esi, esi
    xor     edx, edx
    test    ecx, ecx
    jle     short loc_42113C

    loc_4210F4:                             ; CODE XREF: sub_420F30+1DDj
    cmp     dword ptr [eax], 0
    jnz     short loc_421107
    mov     edi, [eax+0Ch]
    test    edi, edi
    jnz     short loc_421107
    mov     edi, [eax+18h]
    test    edi, edi
    jz      short loc_421111

    loc_421107:                             ; CODE XREF: sub_420F30+1C7j
                                            ; sub_420F30+1CEj
    inc     edx
    add     eax, 54h
    cmp     edx, ecx
    jl      short loc_4210F4
    jmp     short loc_42113C
    ; ---------------------------------------------------------------------------

    loc_421111:                             ; CODE XREF: sub_420F30+1D5j
    dec     ecx
    cmp     edx, ecx
    jge     short loc_421132
    lea     ebp, [eax+54h]

    loc_421119:                             ; CODE XREF: sub_420F30+200j
    mov     ecx, 15h
    mov     esi, ebp
    mov     edi, eax
    inc     edx
    rep movsd
    mov     ecx, [ebx]
    add     eax, 54h
    add     ebp, 54h
    dec     ecx
    cmp     edx, ecx
    jl      short loc_421119

    loc_421132:                             ; CODE XREF: sub_420F30+1E4j
    mov     eax, [ebx]
    mov     esi, 1
    dec     eax
    mov     [ebx], eax

    loc_42113C:                             ; CODE XREF: sub_420F30+1C2j
                                            ; sub_420F30+1DFj
    test    esi, esi
    jnz     short loc_4210E6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn
    sub_420F30 endp

    ; ---------------------------------------------------------------------------
    align 10h
    xor     eax, eax
    mov     ecx, offset dword_511DF0

    loc_421157:                             ; CODE XREF: .text:00421166j
    cmp     dword ptr [ecx], 0
    jz      short locret_42116B
    add     ecx, 4
    inc     eax
    cmp     ecx, offset dword_511F80
    jl      short loc_421157
    or      eax, 0FFFFFFFFh

    locret_42116B:                          ; CODE XREF: .text:0042115Aj
    retn
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, offset dword_511DF0

    loc_421176:                             ; CODE XREF: .text:00421191j
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_421188
    push    eax
    call    sub_4213B0
    test    eax, eax
    jnz     short loc_421188
    mov     [esi], eax

    loc_421188:                             ; CODE XREF: .text:0042117Aj
                                            ; .text:00421184j
    add     esi, 4
    cmp     esi, offset dword_511F80
    jl      short loc_421176
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    push    edi
    mov     edi, [esp+0Ch]
    mov     esi, offset dword_511DF0

    loc_4211AB:                             ; CODE XREF: .text:004211C7j
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4211BE
    push    eax
    push    edi
    call    sub_421550
    test    eax, eax
    jnz     short loc_4211BE
    mov     [esi], eax

    loc_4211BE:                             ; CODE XREF: .text:004211AFj
                                            ; .text:004211BAj
    add     esi, 4
    cmp     esi, offset dword_511F80
    jl      short loc_4211AB
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4211D0 proc near                    ; CODE XREF: sub_421550+B0p

    var_3F58= dword ptr -3F58h
    var_3F54= dword ptr -3F54h
    var_3F50= dword ptr -3F50h
    var_3F4C= dword ptr -3F4Ch
    var_3F48= dword ptr -3F48h
    var_3E80= dword ptr -3E80h
    var_3E7C= dword ptr -3E7Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, 3F58h
    call    __alloca_probe
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+3F5Ch+arg_8]
    push    ebp
    mov     ecx, [eax+1431Fh]
    push    esi
    mov     esi, [ebx+16h]
    mov     edx, [ebx+1Ah]
    shl     ecx, 10h
    sub     esi, ecx
    mov     ecx, [eax+14323h]
    push    edi
    mov     edi, [ebx+1Eh]
    shl     ecx, 10h
    mov     [esp+3F68h+var_3F50], edx
    sub     edi, ecx
    movsx   edx, word ptr [esp+3F68h+var_3F50+2]
    mov     [esp+3F68h+var_3F4C], edi
    mov     ebp, [ebx]
    movsx   ecx, word ptr [esp+3F68h+var_3F4C+2]
    sar     edx, 1
    mov     [esp+3F68h+var_3F54], esi
    sub     ecx, edx
    movsx   edx, word ptr [esp+3F68h+var_3F54+2]
    add     ecx, 20h
    add     edx, 80h
    push    ecx
    add     eax, 37E27h
    push    edx
    push    eax
    mov     [esp+3F74h+var_3F58], ebp
    call    sub_4B6720
    test    eax, eax
    jz      loc_421398
    mov     edx, [ebp+4]
    mov     eax, [ebx+22h]
    test    edx, edx
    jle     short loc_4212A3
    lea     ecx, [esp+3F68h+var_3E7C]

    loc_42125D:                             ; CODE XREF: sub_4211D0+CDj
    mov     ebp, [eax]
    mov     ebx, esi
    add     ebx, ebp
    mov     ebp, [eax+8]
    sar     ebx, 10h
    movsx   ebx, bx
    add     ebx, 80h
    add     eax, 0Ch
    mov     [ecx-4], ebx
    mov     ebx, edi
    sub     ebx, ebp
    mov     ebp, [eax-8]
    add     ebp, [esp+3F68h+var_3F50]
    add     ecx, 8
    sar     ebx, 10h
    sar     ebp, 10h
    movsx   ebp, bp
    movsx   ebx, bx
    sar     ebp, 1
    sub     ebx, ebp
    add     ebx, 20h
    dec     edx
    mov     [ecx-8], ebx
    jnz     short loc_42125D
    mov     ebp, [esp+3F68h+var_3F58]

    loc_4212A3:                             ; CODE XREF: sub_4211D0+84j
    mov     eax, [ebp+0Ch]
    mov     esi, [ebp+28h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4212B8
    add     esi, 20h
    mov     edi, 1
    jmp     short loc_4212BA
    ; ---------------------------------------------------------------------------

    loc_4212B8:                             ; CODE XREF: sub_4211D0+DCj
    xor     edi, edi

    loc_4212BA:                             ; CODE XREF: sub_4211D0+E6j
    mov     eax, [ebp+8]
    mov     [esp+3F68h+var_3F58], edi
    cmp     edi, eax
    jge     loc_421398
    mov     ebx, [esp+3F68h+arg_0]

    loc_4212D0:                             ; CODE XREF: sub_4211D0+1C2j
    mov     eax, [esi+4]
    mov     edx, [esi+0Ch]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_421312
    lea     eax, [esp+3F68h+var_3F48]

    loc_4212E0:                             ; CODE XREF: sub_4211D0+135j
    xor     edi, edi
    inc     ecx
    mov     di, [edx]
    add     eax, 8
    add     edx, 2
    mov     ebx, [esp+edi*8+3F68h+var_3E80]
    mov     [eax-8], ebx
    mov     edi, [esp+edi*8+3F68h+var_3E7C]
    mov     [eax-4], edi
    mov     edi, [esi+4]
    cmp     ecx, edi
    jl      short loc_4212E0
    mov     edi, [esp+3F68h+var_3F58]
    mov     ebx, [esp+3F68h+arg_0]

    loc_421312:                             ; CODE XREF: sub_4211D0+10Aj
    mov     eax, [esi+1Ch]
    test    al, 1
    jnz     short loc_421373
    cmp     dword ptr [esi+4], 4
    jnz     short loc_421385
    mov     ecx, eax
    shr     ecx, 1
    test    cl, 1
    jz      short loc_421360
    shr     eax, 2
    test    al, 1
    jz      short loc_421355
    mov     edx, [esp+3F68h+arg_4]
    mov     eax, [edx]
    mov     ecx, [eax+96h]
    xor     eax, eax
    mov     edx, [ecx+27h]
    mov     ecx, [esi+18h]
    mov     al, [edx+96h]
    push    eax
    push    ecx
    call    sub_4B7F30
    jmp     short loc_421363
    ; ---------------------------------------------------------------------------

    loc_421355:                             ; CODE XREF: sub_4211D0+15Dj
    lea     edx, [esi+10h]
    push    edx
    call    sub_4B7EE0
    jmp     short loc_421363
    ; ---------------------------------------------------------------------------

    loc_421360:                             ; CODE XREF: sub_4211D0+156j
    mov     eax, [esi+10h]

    loc_421363:                             ; CODE XREF: sub_4211D0+183j
                                            ; sub_4211D0+18Ej
    lea     ecx, [esp+3F68h+var_3F48]
    push    0
    push    ecx
    push    eax
    push    ebx
    call    sub_4C7580
    jmp     short loc_421385
    ; ---------------------------------------------------------------------------

    loc_421373:                             ; CODE XREF: sub_4211D0+147j
    mov     edx, [esi]
    mov     eax, [esi+4]
    push    edx
    lea     ecx, [esp+3F6Ch+var_3F48]
    push    eax
    push    ecx
    push    ebx
    call    sub_4C0310

    loc_421385:                             ; CODE XREF: sub_4211D0+14Dj
                                            ; sub_4211D0+1A1j
    mov     eax, [ebp+8]
    inc     edi
    add     esi, 20h
    cmp     edi, eax
    mov     [esp+3F68h+var_3F58], edi
    jl      loc_4212D0

    loc_421398:                             ; CODE XREF: sub_4211D0+76j
                                            ; sub_4211D0+F3j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3F58h
    retn    0Ch
    sub_4211D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4213B0 proc near                    ; CODE XREF: sub_420F30+13p
                                            ; .text:0042117Dp

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 0Ch
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+18h+arg_0]
    mov     eax, [edi+20h]
    mov     esi, [edi+2Ch]
    test    eax, eax
    lea     ecx, [eax-1]
    mov     [edi+20h], ecx
    jnz     short loc_4213D3
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4213D3:                             ; CODE XREF: sub_4213B0+18j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esi+1Ah]
    xor     edx, edx
    mov     dl, [ecx+1427Fh]
    shl     edx, 10h
    cmp     eax, edx
    jg      short loc_421450
    test    byte ptr [edi+28h], 10h
    jz      loc_4214D9
    mov     eax, [ecx+391E9h]
    mov     edx, [eax+0D48h]
    test    edx, edx
    jnz     loc_4214D9
    mov     edx, [eax+0D44h]
    test    edx, edx
    jz      short loc_42141B
    mov     ecx, [ecx+147EFh]
    jmp     short loc_421421
    ; ---------------------------------------------------------------------------

    loc_42141B:                             ; CODE XREF: sub_4213B0+61j
    mov     ecx, [ecx+147EBh]

    loc_421421:                             ; CODE XREF: sub_4213B0+69j
    mov     eax, [esi+16h]
    push    1
    mov     [esp+1Ch+var_C], eax
    mov     edx, [esi+1Ah]
    push    0FFFFFFFFh
    push    ecx
    mov     [esp+24h+var_8], edx
    mov     eax, [esi+1Eh]
    lea     ecx, [esp+24h+var_C]
    mov     [esp+24h+var_4], eax
    push    ecx
    call    sub_420A30
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_421450:                             ; CODE XREF: sub_4213B0+39j
    mov     edx, [esi+16h]
    mov     ebx, [edi+18h]
    mov     [esp+18h+var_C], edx
    mov     eax, [esi+1Ah]
    mov     [esp+18h+var_8], eax
    mov     ecx, [esi+1Eh]
    lea     edx, [esp+18h+var_C]
    mov     [esp+18h+var_4], ecx
    push    edx
    call    sub_485140
    mov     edx, [esi+1Ah]
    mov     ecx, ebx
    shl     eax, 10h
    add     ecx, edx
    cmp     ecx, eax
    jg      short loc_4214E4
    mov     edx, [edi+14h]
    mov     ecx, [edi+1Ch]
    sar     ebx, 1
    neg     ebx
    sar     edx, 1
    sar     ecx, 1
    cmp     ebx, 20000h
    mov     [edi+18h], ebx
    mov     [edi+14h], edx
    mov     [edi+1Ch], ecx
    jge     short loc_4214E4
    mov     edx, [edi+28h]
    shr     edx, 4
    test    dl, 1
    jz      short loc_4214D9
    mov     eax, [esi+16h]
    push    0
    mov     [esp+1Ch+var_C], eax
    mov     ecx, [esi+1Ah]
    mov     eax, TAdynmemStructPtr
    mov     [esp+1Ch+var_8], ecx
    mov     edx, [esi+1Eh]
    push    0
    mov     [esp+20h+var_4], edx
    mov     ecx, [eax+147F7h]
    lea     edx, [esp+20h+var_C]
    push    ecx
    push    edx
    call    sub_420A30

    loc_4214D9:                             ; CODE XREF: sub_4213B0+3Fj
                                            ; sub_4213B0+53j ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4214E4:                             ; CODE XREF: sub_4213B0+CEj
                                            ; sub_4213B0+EDj
    mov     eax, [edi+14h]
    mov     ecx, [esi+16h]
    add     ecx, eax
    mov     eax, [esi+1Ah]
    mov     ebx, [esi+1Eh]
    mov     [esi+16h], ecx
    mov     ecx, [edi+18h]
    add     eax, ecx
    mov     [esi+1Ah], eax
    mov     edx, [edi+1Ch]
    add     ebx, edx
    mov     [esi+1Eh], ebx
    mov     ax, [edi+0Ch]
    add     [esi+10h], ax
    mov     cx, [edi+10h]
    add     [esi+12h], cx
    mov     dx, [edi+8]
    add     [esi+14h], dx
    mov     eax, [edi+28h]
    shr     eax, 3
    test    al, 1
    jz      short loc_42153B
    mov     ecx, TAdynmemStructPtr
    mov     eax, [edi+18h]
    mov     edx, [ecx+14263h]
    sub     eax, edx
    mov     [edi+18h], eax

    loc_42153B:                             ; CODE XREF: sub_4213B0+175j
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    add     esp, 0Ch
    retn    4
    sub_4213B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_421550 proc near                    ; CODE XREF: sub_420B00+18p
                                            ; .text:004211B3p

    var_14= dword ptr -14h
    var_10= word ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    push    ebx
    push    ebp
    mov     ebp, [esp+1Ch+arg_4]
    push    esi
    push    edi
    mov     eax, [ebp+28h]
    mov     edi, [ebp+2Ch]
    shr     eax, 1
    test    al, 1
    jz      short loc_421588
    mov     ecx, [edi+16h]
    push    9
    mov     [esp+28h+var_C], ecx
    mov     edx, [edi+1Ah]
    mov     [esp+28h+var_8], edx
    mov     eax, [edi+1Eh]
    lea     ecx, [esp+28h+var_C]
    mov     [esp+28h+var_4], eax
    push    ecx
    call    sub_472810

    loc_421588:                             ; CODE XREF: sub_421550+15j
    test    byte ptr [ebp+28h], 1
    jz      short loc_4215AF
    mov     edx, [edi+16h]
    push    9
    mov     [esp+28h+var_C], edx
    mov     eax, [edi+1Ah]
    mov     [esp+28h+var_8], eax
    mov     ecx, [edi+1Eh]
    lea     edx, [esp+28h+var_C]
    mov     [esp+28h+var_4], ecx
    push    edx
    call    sub_472AB0

    loc_4215AF:                             ; CODE XREF: sub_421550+3Cj
    mov     ax, [edi+14h]
    mov     word ptr [esp+24h+var_14], ax
    mov     cx, [edi+10h]
    mov     [esp+24h+var_10], cx
    mov     dx, [edi+12h]
    mov     word ptr [esp+24h+var_14+2], dx
    mov     eax, [edi]
    mov     eax, [eax+4]
    dec     eax
    js      short loc_4215F9
    lea     esi, [eax+eax*2]
    lea     ebx, [eax+1]
    shl     esi, 2

    loc_4215DB:                             ; CODE XREF: sub_421550+A7j
    mov     eax, [edi]
    mov     edx, [edi+22h]
    lea     ecx, [esp+24h+var_14]
    add     edx, esi
    push    ecx
    mov     ecx, [eax+24h]
    add     ecx, esi
    push    edx
    push    ecx
    call    sub_4B6CC0
    sub     esi, 0Ch
    dec     ebx
    jnz     short loc_4215DB

    loc_4215F9:                             ; CODE XREF: sub_421550+80j
    mov     edx, [esp+24h+arg_0]
    push    edi
    push    ebp
    push    edx
    call    sub_4211D0
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 14h
    retn    8
    sub_421550 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_421620 proc near                    ; CODE XREF: .text:00420F14p
                                            ; sub_481140+FCp

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+4]
    mov     ebx, [esi]
    mov     ecx, [ebx+9Eh]
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*8]
    and     word ptr [ecx+eax*2+4Ah], 0FFFEh
    mov     edx, [esi+28h]
    lea     ebp, [ecx+eax*2+22h]
    shr     edx, 2
    test    dl, 1
    jz      short loc_42165C
    push    esi
    call    sub_421700
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42165C:                             ; CODE XREF: sub_421620+2Dj
    xor     ecx, ecx
    mov     eax, offset dword_511DF0

    loc_421663:                             ; CODE XREF: sub_421620+51j
    cmp     dword ptr [eax], 0
    jz      short loc_421676
    add     eax, 4
    inc     ecx
    cmp     eax, offset dword_511F80
    jl      short loc_421663
    or      ecx, 0FFFFFFFFh

    loc_421676:                             ; CODE XREF: sub_421620+46j
    test    ecx, ecx
    jl      short loc_4216EB
    mov     eax, [ebp+0]
    lea     edi, ds:511DF0h[ecx*4]
    mov     eax, [eax+4]
    lea     ecx, [eax+eax*2]
    lea     edx, ds:66h[ecx*4]
    mov     ecx, offset dword_511F80
    push    edx
    push    edi
    call    sub_437A30
    test    eax, eax
    jz      short loc_4216EB
    mov     eax, [edi]
    mov     ecx, 0Ch
    mov     edi, eax
    rep movsd
    lea     edi, [eax+30h]
    mov     ecx, 0Dh
    mov     esi, ebp
    mov     [eax+2Ch], edi
    rep movsd
    movsw
    mov     ecx, [eax+2Ch]
    lea     edx, [ecx+36h]
    mov     [ecx+22h], edx
    mov     ecx, [eax+2Ch]
    mov     edx, [ebx+6Ah]
    mov     edi, [ecx+16h]
    add     edi, edx
    mov     [ecx+16h], edi
    mov     ecx, [eax+2Ch]
    mov     edx, [ebx+6Eh]
    mov     esi, [ecx+1Ah]
    add     esi, edx
    mov     [ecx+1Ah], esi
    mov     eax, [eax+2Ch]
    mov     ecx, [ebx+72h]
    add     [eax+1Eh], ecx

    loc_4216EB:                             ; CODE XREF: sub_421620+58j
                                            ; sub_421620+7Fj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_421620 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_421700 proc near                    ; CODE XREF: sub_421620+30p

    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_30= dword ptr -30h
    var_24= dword ptr -24h
    var_18= dword ptr -18h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4

    sub     esp, 90h
    mov     ecx, [esp+90h+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [ecx+4]
    mov     ebx, [ecx]
    push    edi
    mov     edi, [ecx+24h]
    mov     edx, [ebx+9Eh]
    lea     eax, [eax+eax*2]
    mov     [esp+0A0h+var_74], ebx
    lea     eax, [eax+eax*8]
    lea     edx, [edx+eax*2+22h]
    mov     eax, TAdynmemStructPtr
    mov     [esp+0A0h+var_80], edx
    mov     ebp, [edx]
    lea     esi, [eax+1491Bh]
    mov     eax, [edx+22h]
    mov     [esp+0A0h+var_7C], esi
    mov     [esp+0A0h+var_78], eax
    xor     eax, eax
    cmp     edi, eax
    mov     [esp+0A0h+var_70], ebp
    jnz     short loc_42175A
    mov     dword ptr [ecx+24h], 1

    loc_42175A:                             ; CODE XREF: sub_421700+51j
    mov     ecx, [ebp+8]
    mov     [esp+0A0h+var_84], eax
    cmp     ecx, eax
    jle     loc_421D6C
    mov     [esp+0A0h+var_8C], eax

    loc_42176D:                             ; CODE XREF: sub_421700+666j
    mov     ecx, [esi]
    cmp     ecx, 12Ch
    jge     loc_421D6C
    mov     eax, [ebp+28h]
    mov     edi, [esp+0A0h+var_8C]
    add     eax, edi
    cmp     dword ptr [eax+4], 4
    jnz     loc_421D4D
    test    byte ptr [eax+1Ch], 1
    jnz     loc_421D4D
    mov     eax, [ebp+0Ch]
    mov     edi, [esp+0A0h+var_84]
    cmp     eax, edi
    jz      loc_421D4D
    lea     eax, ds:0[ecx*8]
    sub     eax, ecx
    inc     ecx
    mov     [esi], ecx
    mov     ecx, [edx+16h]
    lea     eax, [eax+eax*2]
    lea     edi, [esi+eax*4+4]
    mov     eax, [ebx+6Ah]
    mov     esi, [edx+1Ah]
    mov     edx, [edx+1Eh]
    add     eax, ecx
    mov     ecx, [ebx+6Eh]
    add     ecx, esi
    mov     esi, [ebx+72h]
    add     edx, esi
    lea     esi, [edi+1Ch]
    mov     [edi+1Ch], eax
    mov     [esi+4], ecx
    mov     [esi+8], edx
    mov     edx, TAdynmemStructPtr
    xor     esi, esi
    xor     eax, eax
    lea     ecx, [edx+1AB9Fh]

    loc_4217EE:                             ; CODE XREF: sub_421700+100j
    cmp     byte ptr [ecx], 0FFh
    jz      loc_421D79
    inc     eax
    add     ecx, 34h
    cmp     eax, 12Ch
    jl      short loc_4217EE
    xor     eax, eax

    loc_421804:                             ; CODE XREF: sub_421700+697j
    cmp     eax, esi
    mov     [edi], eax
    jz      loc_421D6C
    mov     ecx, [esp+0A0h+arg_0]
    mov     ax, [edi+52h]
    mov     edx, [ecx+28h]
    shr     edx, 5
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [edi+52h], dx
    mov     eax, [ebx]
    cmp     eax, esi
    jz      short loc_42184C
    mov     eax, [eax+8]
    sar     eax, 1
    mov     [edi+28h], eax
    mov     ecx, [ebx]
    mov     edx, [ecx+10h]
    sar     edx, 1
    mov     [edi+30h], edx
    mov     eax, [ebx]
    mov     ecx, [eax+0Ch]
    sar     ecx, 1
    mov     [edi+2Ch], ecx

    loc_42184C:                             ; CODE XREF: sub_421700+12Ej
    push    0A0h                            ; int
    call    GetRandom
    mov     edx, 50h
    push    0A0h                            ; int
    sub     edx, eax
    shl     edx, 9
    mov     [edi+34h], edx
    call    GetRandom
    mov     ecx, 50h
    push    0A0h                            ; int
    sub     ecx, eax
    shl     ecx, 9
    mov     [edi+3Ch], ecx
    call    GetRandom
    mov     edx, 50h
    push    640h                            ; int
    sub     edx, eax
    mov     eax, TAdynmemStructPtr
    shl     edx, 9
    mov     eax, [eax+14263h]
    lea     eax, [eax+eax*2]
    lea     ecx, [eax+eax*4]
    lea     edx, [edx+ecx*2]
    mov     [edi+38h], edx
    call    GetRandom
    mov     ecx, 320h
    push    640h                            ; int
    sub     ecx, eax
    mov     [edi+40h], ecx
    call    GetRandom
    mov     edx, 320h
    push    640h                            ; int
    sub     edx, eax
    mov     [edi+44h], edx
    call    GetRandom
    mov     ecx, 320h
    mov     [edi+4Ch], si
    sub     ecx, eax
    mov     eax, [esp+0A0h+var_8C]
    mov     [edi+48h], ecx
    mov     [edi+4Eh], si
    mov     [edi+50h], si
    mov     [edi+0Ch], esi
    mov     [edi+18h], esi
    mov     edx, [ebp+28h]
    mov     esi, [edi]
    add     eax, edx
    xor     ecx, ecx
    cmp     [eax+4], ecx
    jle     loc_4219A1
    mov     [esp+0A0h+var_88], ecx
    mov     [esp+0A0h+var_90], 54h

    loc_421915:                             ; CODE XREF: sub_421700+29Bj
    mov     edx, [eax+0Ch]
    xor     eax, eax
    mov     ebx, [esi+24h]
    mov     ax, [edx+ecx*2]
    mov     edx, [esp+0A0h+var_78]
    lea     eax, [eax+eax*2]
    lea     eax, [edx+eax*4]
    mov     edx, [esp+0A0h+var_88]
    add     edx, ebx
    mov     ebx, [eax]
    mov     [edx], ebx
    mov     ebx, [eax+4]
    mov     [edx+4], ebx
    mov     eax, [eax+8]
    mov     [edx+8], eax
    mov     edx, [ebp+28h]
    mov     eax, [esp+0A0h+var_8C]
    mov     ebx, [esi+24h]
    mov     edx, [eax+edx+0Ch]
    xor     eax, eax
    mov     ax, [edx+ecx*2]
    mov     edx, [esp+0A0h+var_78]
    lea     eax, [eax+eax*2]
    lea     eax, [edx+eax*4]
    mov     edx, [esp+0A0h+var_90]
    add     edx, ebx
    inc     ecx
    mov     ebx, [eax]
    mov     [edx], ebx
    mov     ebx, [eax+4]
    mov     [edx+4], ebx
    mov     ebx, [esp+0A0h+var_90]
    mov     eax, [eax+8]
    mov     [edx+8], eax
    mov     edx, [esp+0A0h+var_88]
    mov     eax, 0Ch
    add     edx, eax
    sub     ebx, eax
    mov     eax, [esp+0A0h+var_8C]
    mov     [esp+0A0h+var_88], edx
    mov     edx, [ebp+28h]
    mov     [esp+0A0h+var_90], ebx
    add     eax, edx
    cmp     ecx, [eax+4]
    jl      loc_421915

    loc_4219A1:                             ; CODE XREF: sub_421700+203j
    mov     eax, [esi+24h]
    sub     esp, 0Ch
    mov     ecx, esp
    sub     esp, 0Ch
    fild    dword ptr [eax]
    fild    dword ptr [eax+4]
    fild    dword ptr [eax+8]
    fild    dword ptr [eax+0Ch]
    fxch    st(3)
    fmul    ds:flt_4FD020
    fild    dword ptr [eax+10h]
    fxch    st(3)
    fmul    ds:flt_4FD020
    fild    dword ptr [eax+14h]
    fxch    st(2)
    fstp    [esp+0B8h+var_54]
    fxch    st(2)
    fmul    ds:flt_4FD020
    fxch    st(4)
    fmul    ds:flt_4FD020
    fild    dword ptr [eax+18h]
    fxch    st(3)
    fstp    [esp+0B8h+var_50]
    fild    dword ptr [eax+1Ch]
    fxch    st(5)
    fstp    [esp+0B8h+var_4C]
    fild    dword ptr [eax+20h]
    fxch    st(1)
    fstp    [esp+0B8h+var_60]
    fxch    st(3)
    fmul    ds:flt_4FD020
    fxch    st(1)
    fmul    ds:flt_4FD020
    fxch    st(1)
    fstp    [esp+0B8h+var_5C]
    mov     edx, [esp+0B8h+var_54]
    mov     ebx, [esp+0B8h+var_50]
    fxch    st(1)
    fmul    ds:flt_4FD020
    fxch    st(3)
    fmul    ds:flt_4FD020
    fxch    st(2)
    fmul    ds:flt_4FD020
    fxch    st(1)
    fstp    [esp+0B8h+var_58]
    mov     [ecx], edx
    mov     eax, [esp+0B8h+var_58]
    mov     edx, esp
    lea     ebp, [esp+0B8h+var_30]
    mov     [ecx+4], ebx
    mov     ebx, [esp+0B8h+var_4C]
    fxch    st(2)
    fstp    [esp+0B8h+var_48]
    mov     [ecx+8], ebx
    mov     ebx, [esp+0B8h+var_60]
    fstp    [esp+0B8h+var_44]
    push    ebp
    mov     ebp, [esp+0BCh+var_5C]
    mov     [edx], ebx
    fstp    [esp+0BCh+var_40]
    mov     [edx+4], ebp
    mov     [edx+8], eax
    call    sub_4B6EB0
    mov     edx, [eax]
    sub     esp, 0Ch
    mov     [esp+0ACh+var_3C], edx
    mov     ecx, esp
    mov     edx, [eax+4]
    sub     esp, 0Ch
    mov     [esp+0B8h+var_38], edx
    mov     edx, [esp+0B8h+var_3C]
    mov     eax, [eax+8]
    mov     [ecx], edx
    mov     edx, [esp+0B8h+var_38]
    mov     [ecx+4], edx
    mov     edx, [esp+0B8h+var_44]
    mov     [ecx+8], eax
    mov     ecx, [esp+0B8h+var_48]
    mov     eax, esp
    sub     esp, 0Ch
    mov     [eax], ecx
    mov     ecx, [esp+0C4h+var_40]
    mov     [eax+4], edx
    mov     edx, esp
    mov     [eax+8], ecx
    mov     eax, [esp+0C4h+var_58]
    mov     [edx], ebx
    lea     ecx, [esp+0C4h+var_18]
    push    ecx
    mov     [edx+4], ebp
    mov     [edx+8], eax
    call    sub_4B6EB0
    mov     ecx, [eax]
    sub     esp, 0Ch
    mov     edx, esp
    mov     [edx], ecx
    mov     ecx, [eax+4]
    mov     eax, [eax+8]
    mov     [edx+4], ecx
    lea     ecx, [esp+0B8h+var_24]
    push    ecx
    mov     [edx+8], eax
    call    sub_4B6F70
    mov     ecx, [eax]
    sub     esp, 0Ch
    mov     edx, esp
    mov     [edx], ecx
    mov     ecx, [eax+4]
    mov     eax, [eax+8]
    mov     [edx+4], ecx
    lea     ecx, [esp+0ACh+var_C]
    push    ecx
    mov     [edx+8], eax
    call    sub_4B6FF0
    mov     edx, [eax]
    push    0C8h                            ; int
    mov     [esp+0A4h+var_6C], edx
    mov     ecx, [eax+4]
    mov     [esp+0A4h+var_68], ecx
    mov     edx, [eax+8]
    mov     [esp+0A4h+var_64], edx
    call    GetRandom
    mov     ebx, eax
    fld     [esp+0A0h+var_6C]
    fmul    ds:flt_4FD024
    call    __ftol
    movsx   eax, ax
    imul    ebx, eax
    mov     edx, [edi+34h]
    push    0C8h                            ; int
    add     edx, ebx
    mov     [edi+34h], edx
    call    GetRandom
    mov     ebx, eax
    fld     [esp+0A0h+var_64]
    fmul    ds:flt_4FD024
    call    __ftol
    movsx   ecx, ax
    fld     [esp+0A0h+var_6C]
    fmul    ds:flt_4FD028
    imul    ebx, ecx
    sub     [edi+3Ch], ebx
    call    __ftol
    fld     [esp+0A0h+var_68]
    fmul    ds:flt_4FD028
    mov     ebx, eax
    call    __ftol
    fld     [esp+0A0h+var_64]
    fmul    ds:flt_4FD028
    mov     ebp, eax
    call    __ftol
    mov     [esp+0A0h+var_90], eax
    xor     ecx, ecx

    loc_421BB8:                             ; CODE XREF: sub_421700+4FEj
    mov     edi, [esp+0A0h+arg_0]
    mov     edx, [esi+24h]
    mov     eax, ebx
    imul    eax, [edi+24h]
    sub     [ecx+edx+30h], eax
    lea     edx, [ecx+edx+30h]
    mov     edx, [esi+24h]
    mov     eax, ebp
    imul    eax, [edi+24h]
    sub     [ecx+edx+34h], eax
    mov     eax, [esp+0A0h+var_90]
    imul    eax, [edi+24h]
    lea     edx, [ecx+edx+34h]
    mov     edx, [esi+24h]
    mov     edi, [ecx+edx+38h]
    lea     edx, [ecx+edx+38h]
    add     ecx, 0Ch
    sub     edi, eax
    cmp     ecx, 30h
    mov     [edx], edi
    jl      short loc_421BB8
    mov     ecx, [esi+24h]
    xor     eax, eax
    xor     ebp, ebp
    xor     ebx, ebx
    mov     edx, 8

    loc_421C0E:                             ; CODE XREF: sub_421700+520j
    mov     edi, [ecx]
    add     ecx, 0Ch
    add     eax, edi
    mov     edi, [ecx-8]
    add     ebp, edi
    mov     edi, [ecx-4]
    add     ebx, edi
    dec     edx
    jnz     short loc_421C0E
    cdq
    and     edx, 7
    add     eax, edx
    mov     edi, eax
    mov     eax, ebp
    cdq
    and     edx, 7
    add     eax, edx
    mov     ebp, eax
    mov     eax, ebx
    cdq
    and     edx, 7
    add     eax, edx
    sar     edi, 3
    sar     ebp, 3
    sar     eax, 3
    xor     ecx, ecx

    loc_421C47:                             ; CODE XREF: sub_421700+576j
    mov     edx, [esi+24h]
    add     edx, ecx
    mov     ebx, [edx]
    sub     ebx, edi
    mov     [edx], ebx
    mov     edx, [esi+24h]
    mov     ebx, [ecx+edx+4]
    lea     edx, [ecx+edx+4]
    sub     ebx, ebp
    mov     [edx], ebx
    mov     edx, [esi+24h]
    mov     ebx, [ecx+edx+8]
    lea     edx, [ecx+edx+8]
    add     ecx, 0Ch
    sub     ebx, eax
    cmp     ecx, 60h
    mov     [edx], ebx
    jl      short loc_421C47
    mov     eax, [esi+8]
    mov     [esp+0A0h+var_90], 0
    test    eax, eax
    jle     loc_421D37
    mov     ebp, [esp+0A0h+var_70]
    mov     ebx, [esp+0A0h+var_74]
    xor     edi, edi

    loc_421C95:                             ; CODE XREF: sub_421700+62Fj
    mov     eax, [ebp+28h]
    mov     ecx, [esp+0A0h+var_8C]
    lea     edx, [ecx+eax+10h]
    mov     eax, [esi+28h]
    lea     ecx, [edi+eax+10h]
    mov     eax, [edx]
    mov     [ecx], eax
    mov     eax, [edx+4]
    mov     [ecx+4], eax
    mov     edx, [edx+8]
    mov     eax, [esp+0A0h+var_8C]
    mov     [ecx+8], edx
    mov     ecx, [ebp+28h]
    mov     edx, [esi+28h]
    mov     ecx, [eax+ecx+1Ch]
    mov     [edi+edx+1Ch], ecx
    mov     edx, [ebp+28h]
    mov     ecx, [esi+28h]
    mov     edx, [eax+edx]
    mov     [edi+ecx], edx
    mov     eax, [esi+28h]
    add     eax, edi
    mov     ecx, [eax+1Ch]
    test    cl, 1
    jnz     short loc_421D1E
    test    cl, 2
    jz      short loc_421D1E
    test    cl, 4
    jz      short loc_421D1E
    mov     ecx, [ebx+96h]
    mov     edx, [ecx+27h]
    xor     ecx, ecx
    mov     cl, [edx+96h]
    mov     edx, [eax+18h]
    push    ecx
    push    edx
    call    sub_4B7F30
    mov     ecx, [esi+28h]
    mov     [edi+ecx+10h], eax
    mov     edx, [esi+28h]
    mov     ecx, [edi+edx+1Ch]
    lea     eax, [edi+edx+1Ch]
    and     ecx, 0FFFFFFFDh
    mov     [eax], ecx

    loc_421D1E:                             ; CODE XREF: sub_421700+5E0j
                                            ; sub_421700+5E5j ...
    mov     eax, [esp+0A0h+var_90]
    mov     ecx, [esi+8]
    inc     eax
    add     edi, 20h
    cmp     eax, ecx
    mov     [esp+0A0h+var_90], eax
    jl      loc_421C95
    jmp     short loc_421D45
    ; ---------------------------------------------------------------------------

    loc_421D37:                             ; CODE XREF: sub_421700+585j
    mov     esi, [esp+0A0h+var_7C]
    mov     ebp, [esp+0A0h+var_70]
    mov     ebx, [esp+0A0h+var_74]
    jmp     short loc_421D49
    ; ---------------------------------------------------------------------------

    loc_421D45:                             ; CODE XREF: sub_421700+635j
    mov     esi, [esp+0A0h+var_7C]

    loc_421D49:                             ; CODE XREF: sub_421700+643j
    mov     edx, [esp+0A0h+var_80]

    loc_421D4D:                             ; CODE XREF: sub_421700+88j
                                            ; sub_421700+92j ...
    mov     eax, [esp+0A0h+var_84]
    mov     edi, [esp+0A0h+var_8C]
    mov     ecx, [ebp+8]
    inc     eax
    add     edi, 20h
    cmp     eax, ecx
    mov     [esp+0A0h+var_84], eax
    mov     [esp+0A0h+var_8C], edi
    jl      loc_42176D

    loc_421D6C:                             ; CODE XREF: sub_421700+63j
                                            ; sub_421700+75j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 90h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_421D79:                             ; CODE XREF: sub_421700+F1j
    lea     ecx, [eax+eax*2]
    lea     eax, [eax+ecx*4]
    shl     eax, 2
    mov     byte ptr [edx+eax+1AB9Fh], 0
    mov     edx, TAdynmemStructPtr
    lea     eax, [edx+eax+1AB9Fh]
    jmp     loc_421804
    sub_421700 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_421DA0(int,int,int)
    sub_421DA0 proc near                    ; CODE XREF: .text:00404AE9p
                                            ; .text:00404DE4p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, [eax+8]
    mov     esi, [eax]
    sar     edi, 14h
    sar     esi, 14h
    movsx   eax, di
    movsx   ecx, si
    push    eax
    push    ecx
    mov     word ptr [esp+10h+arg_0], si
    mov     word ptr [esp+10h+arg_0+2], di
    call    sub_481550
    test    eax, eax
    jnz     short loc_421DD5
    or      ax, 0FFFFh
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_421DD5:                             ; CODE XREF: sub_421DA0+2Aj
    cmp     word ptr [eax+8], 0FFFEh
    jnz     short loc_421E04
    movzx   dx, byte ptr [eax+0Bh]
    movzx   ax, byte ptr [eax+0Ah]
    sub     di, ax
    sub     si, dx
    movsx   ecx, di
    movsx   edx, si
    push    ecx
    push    edx
    mov     word ptr [esp+10h+arg_0], si
    mov     word ptr [esp+10h+arg_0+2], di
    call    sub_481550

    loc_421E04:                             ; CODE XREF: sub_421DA0+3Bj
    cmp     word ptr [eax+8], 0FFFBh
    jb      short loc_421E15
    or      ax, 0FFFFh
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_421E15:                             ; CODE XREF: sub_421DA0+6Aj
    mov     ecx, [esp+8+arg_4]
    test    ecx, ecx
    jz      short loc_421E23
    mov     edx, [esp+8+arg_0]
    mov     [ecx], edx

    loc_421E23:                             ; CODE XREF: sub_421DA0+7Bj
    mov     ecx, [esp+8+arg_8]
    test    ecx, ecx
    jz      short loc_421E49
    mov     esi, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [eax+8]
    mov     esi, [esi+1426Fh]
    shl     edx, 8
    mov     edx, [esi+edx+94h]
    mov     [ecx], edx

    loc_421E49:                             ; CODE XREF: sub_421DA0+89j
    mov     ax, [eax+8]
    pop     edi
    pop     esi
    retn    0Ch
    sub_421DA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_421E60 proc near                    ; CODE XREF: .text:0040514Ap
                                            ; sub_47EA40+A3p ...

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    mov     ax, [ecx+8]
    cmp     ax, 0FFFBh
    jb      short locret_421EA0
    cmp     ax, 0FFFEh
    jnz     short unknown_libname_6
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [ecx+0Ah]
    imul    eax, [edx+14233h]
    xor     edx, edx
    mov     dl, [ecx+0Bh]
    add     eax, edx
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    sub     ecx, eax
    mov     ax, [ecx+8]
    retn    4
    ; ---------------------------------------------------------------------------

    unknown_libname_6:                      ; CODE XREF: sub_421E60+12j
    or      ax, 0FFFFh

    locret_421EA0:                          ; CODE XREF: sub_421E60+Cj
    retn    4
    sub_421E60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_421EB0 proc near                    ; CODE XREF: sub_49A120+43Ap

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 10h
    mov     eax, [esp+10h+arg_8]
    mov     ecx, [esp+10h+arg_4]
    push    esi
    mov     eax, [eax+94h]
    mov     ecx, [ecx]
    mov     [esp+14h+var_10], eax
    mov     [esp+14h+arg_8], ecx
    movsx   edx, cx
    movsx   eax, ax
    lea     ecx, [eax+edx*2]
    movsx   edx, word ptr [esp+14h+arg_8+2]
    movsx   eax, word ptr [esp+14h+var_10+2]
    shl     ecx, 13h
    mov     [esp+14h+var_C], ecx
    lea     ecx, [eax+edx*2]
    lea     edx, [esp+14h+var_C]
    shl     ecx, 13h
    push    edx
    mov     [esp+18h+var_4], ecx
    call    sub_485070
    mov     esi, [esp+14h+var_C]
    mov     ecx, [esp+14h+arg_0]
    mov     edx, ecx
    shl     eax, 10h
    mov     [edx], esi
    pop     esi
    mov     [edx+4], eax
    mov     eax, [esp+10h+var_4]
    mov     [edx+8], eax
    mov     eax, ecx
    add     esp, 10h
    retn    0Ch
    sub_421EB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_421F20 proc near                    ; CODE XREF: sub_483610+3E4p

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    18000h
    push    offset aFeatureAnimDat          ; "FEATURE ANIM DATA"
    lea     esi, [eax+141FBh]
    call    sub_4D83B0
    mov     edi, eax
    mov     ecx, 6000h
    xor     eax, eax
    mov     [esi+10h], edi
    rep stosd
    or      edx, 0FFFFFFFFh
    xor     ebx, ebx
    add     esp, 8
    mov     [esi+18h], edx
    mov     [esi+1Ch], edx
    mov     [esi+20h], ebx
    xor     ecx, ecx

    loc_421F5F:                             ; CODE XREF: sub_421F20+5Ej
    mov     ebp, [esi+10h]
    lea     edi, [ecx+1]
    mov     [ebp+eax+0], di
    mov     ebp, [esi+10h]
    lea     edi, [ecx-1]
    inc     ecx
    mov     [ebp+eax+2], di
    add     eax, 30h
    cmp     eax, 18000h
    jl      short loc_421F5F
    mov     ecx, [esi+10h]
    push    118h
    push    offset aFeatureUnit             ; "Feature Unit"
    mov     [ecx+2], dx
    mov     eax, [esi+10h]
    mov     [eax+17FD0h], dx
    call    sub_4D83B0
    mov     edi, eax
    mov     ecx, 46h
    xor     eax, eax
    mov     [esi+14h], edi
    rep stosd
    mov     eax, [esi+14h]
    add     esp, 8
    mov     edi, [eax+110h]
    or      edi, 200h
    mov     [eax+110h], edi
    mov     eax, [esi+14h]
    mov     edi, [esp+10h+arg_0]
    mov     edx, [eax+110h]
    or      edx, 20000000h
    mov     [eax+110h], edx
    mov     ecx, [esi+14h]
    mov     [ecx+0A6h], bx
    mov     eax, [esi+14h]
    mov     ecx, [eax+114h]
    or      ecx, 1
    mov     [eax+114h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [esi+14h]
    mov     ecx, [eax+1439Bh]
    mov     [edx+92h], ecx
    mov     [esi+74h], ebx
    mov     [esi+58h], ebx
    mov     eax, [edi+1Ch]
    xor     esi, esi
    cmp     eax, ebx
    jle     short loc_422039

    loc_42201E:                             ; CODE XREF: sub_421F20+117j
    mov     edx, [edi+20h]
    lea     eax, [ebx+edx+4]
    push    eax
    call    sub_4224B0
    mov     eax, [edi+1Ch]
    inc     esi
    add     ebx, 84h
    cmp     esi, eax
    jl      short loc_42201E

    loc_422039:                             ; CODE XREF: sub_421F20+FCj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_421F20 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_422040 proc near                    ; CODE XREF: sub_483610+76Dp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 10h
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    esi
    xor     ebx, ebx
    mov     ecx, [edx+14233h]
    mov     esi, [edx+14237h]
    imul    esi, ecx
    mov     eax, [edx+14287h]
    mov     [esp+18h+var_C], ebx
    test    esi, esi
    jle     loc_422164
    add     eax, 8
    push    edi
    push    ebp
    mov     [esp+20h+var_8], eax

    loc_422077:                             ; CODE XREF: sub_422040+11Cj
    mov     ax, [eax]
    cmp     ax, 0FFFBh
    jnb     loc_42213B
    mov     esi, [edx+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8
    add     esi, eax
    fld     dword ptr [esi+0F0h]
    fcomp   ds:flt_4FD030
    fnstsw  ax
    test    ah, 40h
    jnz     loc_42213B
    test    byte ptr [esi+0FFh], 2
    jz      loc_42213B
    mov     eax, ebx
    cdq
    idiv    ecx
    mov     eax, ebx
    mov     edi, edx
    cdq
    idiv    ecx
    movsx   ecx, word ptr [esi+96h]
    mov     [esp+20h+var_10], edi
    mov     edx, eax
    mov     [esp+20h+var_4], eax
    add     edx, ecx
    mov     ebp, eax
    cmp     eax, edx
    jge     short loc_422135

    loc_4220DD:                             ; CODE XREF: sub_422040+EFj
    movsx   ecx, word ptr [esi+94h]
    mov     edx, edi
    add     edx, ecx
    cmp     edi, edx
    jge     short loc_422121

    loc_4220EC:                             ; CODE XREF: sub_422040+D7j
    push    ebp
    push    edi
    call    sub_481550
    mov     ebx, eax
    test    ebx, ebx
    jz      short loc_422107
    fld     dword ptr [esi+0F0h]
    call    __ftol
    mov     [ebx+7], al

    loc_422107:                             ; CODE XREF: sub_422040+B7j
    movsx   eax, word ptr [esi+94h]
    mov     ecx, [esp+20h+var_10]
    inc     edi
    add     ecx, eax
    cmp     edi, ecx
    jl      short loc_4220EC
    mov     eax, [esp+20h+var_4]
    mov     edi, [esp+20h+var_10]

    loc_422121:                             ; CODE XREF: sub_422040+AAj
    movsx   edx, word ptr [esi+96h]
    mov     ecx, eax
    inc     ebp
    add     ecx, edx
    cmp     ebp, ecx
    jl      short loc_4220DD
    mov     ebx, [esp+20h+var_C]

    loc_422135:                             ; CODE XREF: sub_422040+9Bj
    mov     edx, TAdynmemStructPtr

    loc_42213B:                             ; CODE XREF: sub_422040+3Ej
                                            ; sub_422040+65j ...
    mov     ecx, [edx+14233h]
    mov     esi, [edx+14237h]
    mov     eax, [esp+20h+var_8]
    imul    esi, ecx
    inc     ebx
    add     eax, 0Dh
    cmp     ebx, esi
    mov     [esp+20h+var_C], ebx
    mov     [esp+20h+var_8], eax
    jl      loc_422077
    pop     ebp
    pop     edi

    loc_422164:                             ; CODE XREF: sub_422040+28j
    pop     esi
    pop     ebx
    add     esp, 10h
    retn
    sub_422040 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_422170 proc near                    ; CODE XREF: sub_483DD0+16p
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     ebp, ebp
    xor     edi, edi
    mov     ebx, 1

    loc_422183:                             ; CODE XREF: sub_422170+6Aj
    cmp     edi, ebp
    jz      short loc_42218F
    mov     eax, [ecx+14213h]
    jmp     short loc_422195
    ; ---------------------------------------------------------------------------

    loc_42218F:                             ; CODE XREF: sub_422170+15j
    mov     eax, [ecx+14217h]

    loc_422195:                             ; CODE XREF: sub_422170+1Dj
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4221D7

    loc_42219A:                             ; CODE XREF: sub_422170+65j
    lea     esi, [eax+eax*2]
    mov     eax, [ecx+1420Bh]
    mov     edx, [ecx+1426Fh]
    shl     esi, 4
    add     esi, eax
    xor     eax, eax
    mov     ax, [esi+2Ch]
    shl     eax, 8
    test    [eax+edx+0FEh], bl
    jnz     short loc_4221CF
    mov     eax, [esi+4]
    push    eax
    call    sub_45AAA0
    mov     ecx, TAdynmemStructPtr

    loc_4221CF:                             ; CODE XREF: sub_422170+4Ej
    movsx   eax, word ptr [esi]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_42219A

    loc_4221D7:                             ; CODE XREF: sub_422170+28j
    inc     edi
    cmp     edi, ebx
    jle     short loc_422183
    mov     ecx, [ecx+1420Fh]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     eax, [edx+1420Bh]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    xor     edi, edi
    mov     [ecx+1420Fh], ebp
    mov     edx, TAdynmemStructPtr
    mov     [edx+1420Bh], ebp
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14253h]
    mov     eax, [ecx+1426Fh]
    cmp     edx, ebp
    jle     short loc_422276
    lea     esi, [eax+0A8h]

    loc_422236:                             ; CODE XREF: sub_422170+104j
    test    [esi+56h], bl
    jz      short loc_42224E
    mov     eax, [esi]
    cmp     eax, ebp
    jz      short loc_422261
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [esi], ebp
    jmp     short loc_422261
    ; ---------------------------------------------------------------------------

    loc_42224E:                             ; CODE XREF: sub_422170+C9j
    mov     eax, [esi-10h]
    cmp     eax, ebp
    jz      short loc_422261
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [esi-10h], ebp

    loc_422261:                             ; CODE XREF: sub_422170+CFj
                                            ; sub_422170+DCj ...
    mov     ecx, TAdynmemStructPtr
    inc     edi
    add     esi, 100h
    cmp     edi, [ecx+14253h]
    jl      short loc_422236

    loc_422276:                             ; CODE XREF: sub_422170+BEj
    mov     eax, [ecx+1426Fh]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     [ecx+1426Fh], ebp
    mov     edx, TAdynmemStructPtr
    pop     edi
    pop     esi
    mov     [edx+14253h], ebp
    pop     ebp
    pop     ebx
    retn
    sub_422170 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+0Ch]
    push    edi
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_4222C7
    pop     edi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4222C7:                             ; CODE XREF: .text:004222C1j
    mov     eax, [esp+8]
    push    edx
    push    eax
    call    sub_4B8D40
    pop     edi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4222E0 proc near                    ; CODE XREF: sub_424C00+33p
                                            ; sub_4917D0+D2p

    var_15= byte ptr -15h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 18h
    push    ebx
    push    esi
    push    edi
    push    10h                             ; int
    call    sub_4B4F10
    xor     ebx, ebx
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_42230C
    mov     cl, [esp+24h+var_15]
    mov     [eax+4], ebx
    mov     [eax], cl
    mov     [eax+8], ebx
    mov     [eax+0Ch], ebx
    mov     dword_511FB4, eax
    jmp     short loc_422312
    ; ---------------------------------------------------------------------------

    loc_42230C:                             ; CODE XREF: sub_4222E0+14j
    mov     dword_511FB4, ebx

    loc_422312:                             ; CODE XREF: sub_4222E0+2Aj
    mov     dl, [esp+24h+var_15]
    push    1
    lea     eax, [esp+28h+var_10]
    push    0FFFFFFFFh
    push    eax
    push    offset a_tdf                    ; "*.tdf"
    push    offset aFeatures                ; "features"
    mov     byte ptr [esp+38h+var_10], dl
    mov     [esp+38h+var_C], ebx
    mov     [esp+38h+var_8], ebx
    mov     [esp+38h+var_4], ebx
    call    sub_4BCB50
    mov     esi, [esp+24h+var_C]
    mov     eax, [esp+24h+var_8]
    mov     edi, esi
    cmp     esi, eax
    jnb     short loc_4223B6

    loc_42234C:                             ; CODE XREF: sub_4222E0+D0j
    push    0Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_422363
    mov     ecx, eax
    call    sub_4C2EA0
    jmp     short loc_422365
    ; ---------------------------------------------------------------------------

    loc_422363:                             ; CODE XREF: sub_4222E0+78j
    xor     eax, eax

    loc_422365:                             ; CODE XREF: sub_4222E0+81j
    mov     ecx, [edi]
    mov     [esp+24h+var_14], eax
    push    ecx
    mov     ecx, eax
    call    sub_4C2F60
    test    eax, eax
    jz      short loc_42238F
    mov     ecx, dword_511FB4
    lea     edx, [esp+24h+var_14]
    push    edx
    push    1
    mov     eax, [ecx+8]
    push    eax
    call    sub_425480
    jmp     short loc_4223A7
    ; ---------------------------------------------------------------------------

    loc_42238F:                             ; CODE XREF: sub_4222E0+95j
    mov     ecx, [esp+24h+var_14]
    cmp     ecx, ebx
    mov     esi, ecx
    jz      short loc_4223A7
    call    sub_4C2EB0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4223A7:                             ; CODE XREF: sub_4222E0+ADj
                                            ; sub_4222E0+B7j
    mov     eax, [esp+24h+var_8]
    add     edi, 4
    cmp     edi, eax
    jb      short loc_42234C
    mov     esi, [esp+24h+var_C]

    loc_4223B6:                             ; CODE XREF: sub_4222E0+6Aj
    cmp     esi, eax
    mov     edi, eax
    jz      short loc_4223CE

    loc_4223BC:                             ; CODE XREF: sub_4222E0+E8j
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_4223BC
    mov     esi, [esp+24h+var_C]

    loc_4223CE:                             ; CODE XREF: sub_4222E0+DAj
    push    esi
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn
    sub_4222E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4223E0 proc near                    ; CODE XREF: sub_4917D0+10Ep

    var_4= dword ptr -4

    push    ecx
    mov     eax, dword_511FB4
    push    ebx
    push    esi
    push    edi
    mov     edi, [eax+4]
    mov     ecx, [eax+8]
    cmp     edi, ecx
    jnb     short loc_422418

    loc_4223F3:                             ; CODE XREF: sub_4223E0+36j
    mov     esi, [edi]
    test    esi, esi
    jz      short loc_42240E
    mov     ecx, esi
    call    sub_4C2EB0
    push    esi
    call    sub_4B4F20
    mov     eax, dword_511FB4
    add     esp, 4

    loc_42240E:                             ; CODE XREF: sub_4223E0+17j
    mov     ecx, [eax+8]
    add     edi, 4
    cmp     edi, ecx
    jb      short loc_4223F3

    loc_422418:                             ; CODE XREF: sub_4223E0+11j
    test    eax, eax
    mov     edi, eax
    jz      short loc_422450
    mov     ecx, [eax+4]
    lea     esi, [eax+4]
    push    ecx
    mov     [esp+14h+var_4], ecx
    lea     ebx, [eax+8]
    call    sub_4B4F20
    add     esp, 4
    mov     dword ptr [esi], 0
    mov     dword ptr [ebx], 0
    mov     dword ptr [edi+0Ch], 0
    push    edi
    call    sub_4B4F20
    add     esp, 4

    loc_422450:                             ; CODE XREF: sub_4223E0+3Cj
    pop     edi
    pop     esi
    mov     dword_511FB4, 0
    pop     ebx
    pop     ecx
    retn
    sub_4223E0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, dword_511FB4
    push    esi
    push    edi
    mov     esi, [eax+4]
    mov     ecx, [eax+8]
    cmp     esi, ecx
    jnb     short loc_4224A3
    mov     edi, [esp+0Ch]

    loc_422475:                             ; CODE XREF: .text:00422493j
    mov     ecx, [esi]
    call    sub_4C3E10
    mov     ecx, [esi]
    push    edi
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_42249C
    mov     eax, dword_511FB4
    add     esi, 4
    cmp     esi, [eax+8]
    jb      short loc_422475
    xor     eax, eax
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42249C:                             ; CODE XREF: .text:00422486j
    mov     eax, [esi]
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4224A3:                             ; CODE XREF: .text:0042246Fj
    pop     edi
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4224B0 proc near                    ; CODE XREF: sub_421F20+106p
                                            ; sub_422E40+50p ...

    var_308= dword ptr -308h
    var_304= dword ptr -304h
    var_300= byte ptr -300h
    var_200= byte ptr -200h
    Text= byte ptr -100h
    arg_0= dword ptr  4

    mov     eax, dword_511FB4
    sub     esp, 308h
    mov     ecx, [eax+8]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [eax+4]
    cmp     edi, ecx
    jnb     short loc_4224F5

    loc_4224C9:                             ; CODE XREF: sub_4224B0+43j
    mov     ecx, [edi]
    call    sub_4C3E10
    mov     eax, [esp+318h+arg_0]
    mov     ecx, [edi]
    push    eax                             ; char *
    call    sub_4C3410
    test    eax, eax
    jnz     loc_422DBB
    mov     ecx, dword_511FB4
    add     edi, 4
    cmp     edi, [ecx+8]
    jb      short loc_4224C9

    loc_4224F5:                             ; CODE XREF: sub_4224B0+17j
    xor     esi, esi
    xor     ebx, ebx

    loc_4224F9:                             ; CODE XREF: sub_4224B0+90Fj
    cmp     ebx, esi
    jnz     short loc_422527
    mov     edx, [esp+318h+arg_0]
    lea     eax, [esp+318h+Text]
    push    edx
    push    offset aRecordSMissing          ; "Record \"%s\" missing from feature files"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+318h+Text]
    push    ecx                             ; lpText
    call    sub_4B6290

    loc_422527:                             ; CODE XREF: sub_4224B0+4Bj
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+14253h]
    mov     eax, [eax+1426Fh]
    inc     edx
    shl     edx, 8
    push    edx                             ; int
    push    offset aFeatures_0              ; int
    push    eax                             ; int
    call    Network_ReAllocPacketBuffer
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+324h+arg_0]
    add     esp, 0Ch
    mov     [ecx+1426Fh], eax
    mov     eax, TAdynmemStructPtr
    push    80h                             ; size_t
    push    edx                             ; char *
    mov     ebp, [eax+14253h]
    mov     ecx, [eax+1426Fh]
    shl     ebp, 8
    add     ebp, ecx
    push    ebp                             ; char *
    call    _strncpy
    mov     ecx, [ebx+4]
    add     esp, 0Ch
    lea     eax, [ebp+80h]
    push    offset Data                     ; int
    push    14h                             ; size_t
    push    offset aDescription             ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    mov     ecx, [ebx+4]
    push    esi                             ; int
    push    offset aFootprintx              ; char *
    call    sub_4C46C0
    mov     [ebp+94h], ax
    mov     ecx, [ebx+4]
    push    esi                             ; int
    push    offset aFootprintz              ; char *
    call    sub_4C46C0
    mov     [ebp+96h], ax
    mov     ecx, [ebx+4]
    push    esi                             ; int
    push    offset aHeight                  ; char *
    call    sub_4C46C0
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_200]
    push    offset aObject                  ; char *
    mov     [ebp+0FAh], al
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_422620
    and     word ptr [ebp+0FEh], 0FFFEh
    lea     edx, [esp+318h+var_200]
    push    edx
    call    sub_42A2C0
    mov     [ebp+98h], eax
    jmp     loc_4229FB
    ; ---------------------------------------------------------------------------

    loc_422620:                             ; CODE XREF: sub_4224B0+14Dj
    or      byte ptr [ebp+0FEh], 1
    mov     ecx, [ebx+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     eax, [esp+320h+var_200]
    push    offset aFilename                ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    mov     eax, TAdynmemStructPtr
    xor     edi, edi
    mov     [esp+318h+var_304], edi
    cmp     [eax+14253h], esi
    jle     loc_4226F6

    loc_42265D:                             ; CODE XREF: sub_4224B0+1E3j
    mov     edx, [eax+1426Fh]
    lea     ecx, [esp+318h+var_200]
    push    10h                             ; size_t
    push    ecx                             ; char *
    lea     eax, [edx+esi+98h]
    push    eax                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_42269B
    mov     eax, TAdynmemStructPtr
    inc     edi
    add     esi, 100h
    cmp     edi, [eax+14253h]
    jl      short loc_42265D
    mov     [esp+318h+var_304], edi
    jmp     short loc_4226F4
    ; ---------------------------------------------------------------------------

    loc_42269B:                             ; CODE XREF: sub_4224B0+1CFj
    mov     dword ptr [ebp+0A8h], 0
    mov     ecx, TAdynmemStructPtr
    mov     [esp+318h+var_304], edi
    mov     edx, [ecx+1426Fh]
    or      ecx, 0FFFFFFFFh
    shl     edi, 8
    mov     eax, [edi+edx+0A8h]
    mov     edi, offset aReuse              ; "REUSE"
    mov     [esp+318h+var_308], eax
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [ebp+98h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, TAdynmemStructPtr
    mov     edi, [esp+318h+var_304]

    loc_4226F4:                             ; CODE XREF: sub_4224B0+1E9j
    xor     esi, esi

    loc_4226F6:                             ; CODE XREF: sub_4224B0+1A7j
    cmp     edi, [eax+14253h]
    jnz     short loc_422753
    lea     ecx, [esp+318h+var_200]
    push    offset off_502E38
    push    ecx
    lea     edx, [esp+320h+Text]
    push    offset aAnims                   ; "anims"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+318h+Text]
    push    eax
    call    sub_4B8C60
    lea     ecx, [esp+318h+var_200]
    push    10h                             ; size_t
    lea     edx, [ebp+98h]
    push    ecx                             ; char *
    push    edx                             ; char *
    mov     [ebp+0A8h], eax
    call    _strncpy
    mov     eax, [ebp+0A8h]
    add     esp, 0Ch
    mov     [esp+318h+var_308], eax

    loc_422753:                             ; CODE XREF: sub_4224B0+24Cj
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_300]
    push    offset aSeqname                 ; char *
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_4227A2
    lea     edi, [esp+318h+var_300]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_42278B
    mov     [ebp+0ACh], eax
    jmp     short loc_4227A8
    ; ---------------------------------------------------------------------------

    loc_42278B:                             ; CODE XREF: sub_4224B0+2D1j
    mov     eax, [esp+318h+var_308]
    lea     edx, [esp+318h+var_300]
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     [ebp+0ACh], eax
    jmp     short loc_4227A8
    ; ---------------------------------------------------------------------------

    loc_4227A2:                             ; CODE XREF: sub_4224B0+2C1j
    mov     [ebp+0ACh], esi

    loc_4227A8:                             ; CODE XREF: sub_4224B0+2D9j
                                            ; sub_4224B0+2F0j
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_300]
    push    offset aSeqnameshad             ; char *
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_4227F7
    lea     edi, [esp+318h+var_300]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_4227E0
    mov     [ebp+0B0h], eax
    jmp     short loc_4227FD
    ; ---------------------------------------------------------------------------

    loc_4227E0:                             ; CODE XREF: sub_4224B0+326j
    mov     eax, [esp+318h+var_308]
    lea     edx, [esp+318h+var_300]
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     [ebp+0B0h], eax
    jmp     short loc_4227FD
    ; ---------------------------------------------------------------------------

    loc_4227F7:                             ; CODE XREF: sub_4224B0+316j
    mov     [ebp+0B0h], esi

    loc_4227FD:                             ; CODE XREF: sub_4224B0+32Ej
                                            ; sub_4224B0+345j
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_300]
    push    offset aSeqnameburn             ; char *
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_42284C
    lea     edi, [esp+318h+var_300]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_42283C
    mov     eax, [esp+318h+var_308]
    lea     edx, [esp+318h+var_300]
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40

    loc_42283C:                             ; CODE XREF: sub_4224B0+37Bj
    cmp     eax, esi
    mov     [ebp+0B4h], eax
    jz      short loc_422852
    mov     byte ptr [eax+2], 0
    jmp     short loc_422852
    ; ---------------------------------------------------------------------------

    loc_42284C:                             ; CODE XREF: sub_4224B0+36Bj
    mov     [ebp+0B4h], esi

    loc_422852:                             ; CODE XREF: sub_4224B0+394j
                                            ; sub_4224B0+39Aj
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_300]
    push    offset aSeqnameburnsha          ; char *
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_4228A1
    lea     edi, [esp+318h+var_300]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_422891
    mov     eax, [esp+318h+var_308]
    lea     edx, [esp+318h+var_300]
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40

    loc_422891:                             ; CODE XREF: sub_4224B0+3D0j
    cmp     eax, esi
    mov     [ebp+0B8h], eax
    jz      short loc_4228A7
    mov     byte ptr [eax+2], 0
    jmp     short loc_4228A7
    ; ---------------------------------------------------------------------------

    loc_4228A1:                             ; CODE XREF: sub_4224B0+3C0j
    mov     [ebp+0B8h], esi

    loc_4228A7:                             ; CODE XREF: sub_4224B0+3E9j
                                            ; sub_4224B0+3EFj
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_300]
    push    offset aSeqnamedie              ; char *
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_4228F6
    lea     edi, [esp+318h+var_300]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4228E6
    mov     eax, [esp+318h+var_308]
    lea     edx, [esp+318h+var_300]
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40

    loc_4228E6:                             ; CODE XREF: sub_4224B0+425j
    cmp     eax, esi
    mov     [ebp+0BCh], eax
    jz      short loc_4228FC
    mov     byte ptr [eax+2], 0
    jmp     short loc_4228FC
    ; ---------------------------------------------------------------------------

    loc_4228F6:                             ; CODE XREF: sub_4224B0+415j
    mov     [ebp+0BCh], esi

    loc_4228FC:                             ; CODE XREF: sub_4224B0+43Ej
                                            ; sub_4224B0+444j
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_300]
    push    offset aSeqnamedieshad          ; char *
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_42294B
    lea     edi, [esp+318h+var_300]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_42293B
    mov     eax, [esp+318h+var_308]
    lea     edx, [esp+318h+var_300]
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40

    loc_42293B:                             ; CODE XREF: sub_4224B0+47Aj
    cmp     eax, esi
    mov     [ebp+0C0h], eax
    jz      short loc_422951
    mov     byte ptr [eax+2], 0
    jmp     short loc_422951
    ; ---------------------------------------------------------------------------

    loc_42294B:                             ; CODE XREF: sub_4224B0+46Aj
    mov     [ebp+0C0h], esi

    loc_422951:                             ; CODE XREF: sub_4224B0+493j
                                            ; sub_4224B0+499j
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_300]
    push    offset aSeqnamereclama          ; char *
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_4229A0
    lea     edi, [esp+318h+var_300]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_422990
    mov     eax, [esp+318h+var_308]
    lea     edx, [esp+318h+var_300]
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40

    loc_422990:                             ; CODE XREF: sub_4224B0+4CFj
    cmp     eax, esi
    mov     [ebp+0C4h], eax
    jz      short loc_4229A6
    mov     byte ptr [eax+2], 0
    jmp     short loc_4229A6
    ; ---------------------------------------------------------------------------

    loc_4229A0:                             ; CODE XREF: sub_4224B0+4BFj
    mov     [ebp+0C4h], esi

    loc_4229A6:                             ; CODE XREF: sub_4224B0+4E8j
                                            ; sub_4224B0+4EEj
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_300]
    push    offset aSeqnamerecla_0          ; char *
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_4229F5
    lea     edi, [esp+318h+var_300]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4229E5
    mov     eax, [esp+318h+var_308]
    lea     edx, [esp+318h+var_300]
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40

    loc_4229E5:                             ; CODE XREF: sub_4224B0+524j
    cmp     eax, esi
    mov     [ebp+0C8h], eax
    jz      short loc_4229FB
    mov     byte ptr [eax+2], 0
    jmp     short loc_4229FB
    ; ---------------------------------------------------------------------------

    loc_4229F5:                             ; CODE XREF: sub_4224B0+514j
    mov     [ebp+0C8h], esi

    loc_4229FB:                             ; CODE XREF: sub_4224B0+16Bj
                                            ; sub_4224B0+53Dj ...
    mov     ecx, [ebx+4]
    push    esi                             ; int
    push    offset aSpreadchance            ; char *
    call    sub_4C46C0
    mov     [ebp+0FBh], al
    mov     ecx, [ebx+4]
    push    esi                             ; int
    push    offset aReproduce               ; char *
    call    sub_4C46C0
    mov     [ebp+0FCh], al
    mov     ecx, [ebx+4]
    push    esi                             ; int
    push    offset aReproducearea           ; char *
    call    sub_4C46C0
    mov     [ebp+0FDh], al
    mov     ecx, [ebx+4]
    push    esi                             ; int
    push    offset aMetal_0                 ; char *
    call    sub_4C46C0
    and     eax, 0FFFFh
    push    esi                             ; int
    mov     [esp+31Ch+var_304], eax
    push    offset aEnergy_0                ; char *
    fild    [esp+320h+var_304]
    fstp    dword ptr [ebp+0F0h]
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    and     eax, 0FFFFh
    push    esi                             ; int
    mov     [esp+31Ch+var_304], eax
    push    offset aDamage_0                ; char *
    fild    [esp+320h+var_304]
    fstp    dword ptr [ebp+0ECh]
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     [ebp+0EAh], ax
    mov     ecx, [ebx+4]
    push    esi                             ; int
    push    offset aAnimating               ; char *
    call    sub_4C46C0
    mov     cx, [ebp+0FEh]
    and     eax, 1
    and     ecx, 0FFFDh
    push    esi                             ; int
    shl     eax, 1
    or      ecx, eax
    push    offset aAnimtrans               ; char *
    mov     [ebp+0FEh], cx
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     dx, [ebp+0FEh]
    and     eax, 1
    and     edx, 0FFFBh
    push    esi                             ; int
    shl     eax, 2
    or      edx, eax
    push    offset aShadtrans               ; char *
    mov     [ebp+0FEh], dx
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     cx, [ebp+0FEh]
    and     eax, 1
    and     ecx, 0FFF7h
    push    esi                             ; int
    shl     eax, 3
    or      ecx, eax
    push    offset aFlamable                ; char *
    mov     [ebp+0FEh], cx
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     dx, [ebp+0FEh]
    and     eax, 1
    and     edx, 0FFEFh
    push    esi                             ; int
    shl     eax, 4
    or      edx, eax
    push    offset aGeothermal              ; char *
    mov     [ebp+0FEh], dx
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     cx, [ebp+0FEh]
    and     eax, 1
    and     ecx, 0FFDFh
    shl     eax, 5
    or      ecx, eax
    push    esi                             ; int
    mov     [ebp+0FEh], cx
    mov     ecx, [ebx+4]
    push    offset aBlocking                ; char *
    call    sub_4C46C0
    mov     dx, [ebp+0FEh]
    and     eax, 1
    and     edx, 0FFBFh
    push    esi                             ; int
    shl     eax, 6
    or      edx, eax
    push    offset aReclaimable             ; char *
    mov     [ebp+0FEh], dx
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     cx, [ebp+0FEh]
    and     eax, 1
    and     ecx, 0FF7Fh
    push    1                               ; int
    shl     eax, 7
    or      ecx, eax
    push    offset aAutoreclaimabl          ; char *
    mov     [ebp+0FEh], cx
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     dx, [ebp+0FEh]
    and     al, 1
    xor     ecx, ecx
    and     edx, 0FEFFh
    mov     ch, al
    push    esi                             ; int
    or      edx, ecx
    push    offset aIndestructible          ; char *
    mov     [ebp+0FEh], dx
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     dx, [ebp+0FEh]
    and     eax, 1
    and     edx, 0FDFFh
    push    esi                             ; int
    shl     eax, 9
    or      edx, eax
    push    offset aNodisplayinfo           ; char *
    mov     [ebp+0FEh], dx
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     cx, [ebp+0FEh]
    and     eax, 1
    and     ecx, 0FBFFh
    push    esi                             ; int
    shl     eax, 0Ah
    or      ecx, eax
    push    offset aNodrawundergra          ; char *
    mov     [ebp+0FEh], cx
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     dx, [ebp+0FEh]
    and     eax, 1
    and     edx, 0F7FFh
    push    offset aDragonsteeth            ; char *
    shl     eax, 0Bh
    or      edx, eax
    mov     eax, [esp+31Ch+arg_0]
    push    eax                             ; char *
    mov     [ebp+0FEh], dx
    call    __strcmpi
    add     esp, 8
    mov     edi, 800h
    test    eax, eax
    jnz     short loc_422C81
    or      [ebp+0FEh], di

    loc_422C81:                             ; CODE XREF: sub_4224B0+7C8j
    mov     ecx, [esp+318h+arg_0]
    push    offset aDragonsteeth_c          ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_422CA1
    or      [ebp+0FEh], di

    loc_422CA1:                             ; CODE XREF: sub_4224B0+7E8j
    mov     edx, [esp+318h+arg_0]
    push    offset aFortification           ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_422CC1
    or      [ebp+0FEh], di

    loc_422CC1:                             ; CODE XREF: sub_4224B0+808j
    mov     eax, [esp+318h+arg_0]
    push    offset aFortification_          ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_422CE1
    or      [ebp+0FEh], di

    loc_422CE1:                             ; CODE XREF: sub_4224B0+828j
    mov     ecx, [ebx+4]
    push    esi
    push    esi                             ; __int64
    push    offset aSparktime               ; char *
    call    sub_4C4760
    fmul    ds:dbl_4FD038
    call    __ftol
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+320h+var_300]
    push    offset aBurnweapon              ; char *
    mov     [ebp+0E8h], ax
    push    ecx                             ; char *
    mov     ecx, [ebx+4]
    call    sub_4C48C0
    lea     edx, [esp+318h+var_300]
    push    edx                             ; char *
    call    sub_49E5B0
    mov     cl, [ebp+0FEh]
    mov     [ebp+0E4h], eax
    lea     eax, [ebp+0CCh]
    lea     edi, [ebp+0D8h]
    shr     cl, 1
    test    cl, 1
    mov     [eax], si
    mov     [ebp+0CEh], si
    mov     byte ptr [ebp+0D0h], 0
    mov     [ebp+0D4h], esi
    mov     [edi], si
    mov     [ebp+0DAh], si
    mov     byte ptr [ebp+0DCh], 0
    mov     [ebp+0E0h], esi
    jz      short loc_422D99
    mov     ecx, [ebp+0ACh]
    cmp     ecx, esi
    jz      short loc_422D87
    push    esi
    push    ecx
    push    eax
    call    sub_4B8B30

    loc_422D87:                             ; CODE XREF: sub_4224B0+8CDj
    mov     ebp, [ebp+0B0h]
    cmp     ebp, esi
    jz      short loc_422D99
    push    esi
    push    ebp
    push    edi
    call    sub_4B8B30

    loc_422D99:                             ; CODE XREF: sub_4224B0+8C3j
                                            ; sub_4224B0+8DFj
    mov     ecx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, [ecx+14253h]
    pop     ebx
    lea     edx, [eax+1]
    mov     [ecx+14253h], edx
    add     esp, 308h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_422DBB:                             ; CODE XREF: sub_4224B0+31j
    mov     ebx, [edi]
    xor     esi, esi
    jmp     loc_4224F9
    sub_4224B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_422DD0(char *)
    sub_422DD0 proc near                    ; CODE XREF: .text:004163E2p

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     ecx, [eax+14253h]
    xor     edi, edi
    test    ecx, ecx
    jle     short loc_422E27
    mov     ebx, [esp+0Ch+arg_0]
    xor     esi, esi

    loc_422DEA:                             ; CODE XREF: sub_422DD0+42j
    mov     eax, [eax+1426Fh]
    add     eax, esi
    push    eax                             ; char *
    push    ebx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_422E1E
    mov     eax, TAdynmemStructPtr
    inc     edi
    add     esi, 100h
    cmp     edi, [eax+14253h]
    jl      short loc_422DEA
    or      ax, 0FFFFh
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_422E1E:                             ; CODE XREF: sub_422DD0+2Ej
    mov     ax, di
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_422E27:                             ; CODE XREF: sub_422DD0+12j
    pop     edi
    pop     esi
    or      ax, 0FFFFh
    pop     ebx
    retn    4
    sub_422DD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_422E40(char *)
    sub_422E40 proc near                    ; CODE XREF: sub_42BF40+DABp

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+4+arg_0]
    push    esi
    mov     ecx, [eax+14253h]
    xor     esi, esi
    test    ecx, ecx
    push    edi
    jle     short loc_422E84
    xor     edi, edi

    loc_422E5A:                             ; CODE XREF: sub_422E40+42j
    mov     eax, [eax+1426Fh]
    add     eax, edi
    push    eax                             ; char *
    push    ebx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_422E9B
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     edi, 100h
    cmp     esi, [eax+14253h]
    jl      short loc_422E5A

    loc_422E84:                             ; CODE XREF: sub_422E40+16j
    mov     eax, 0FFFFh

    loc_422E89:                             ; CODE XREF: sub_422E40+5Dj
    cmp     ax, 0FFFFh
    jnz     short loc_422E95
    push    ebx
    call    sub_4224B0

    loc_422E95:                             ; CODE XREF: sub_422E40+4Dj
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_422E9B:                             ; CODE XREF: sub_422E40+2Ej
    mov     eax, esi
    jmp     short loc_422E89
    sub_422E40 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_422EA0 proc near                    ; CODE XREF: sub_424C00+2CDp
                                            ; sub_4917D0+109p

    var_110= dword ptr -110h
    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= byte ptr -100h

    sub     esp, 110h
    mov     eax, TAdynmemStructPtr
    push    ebp
    xor     ebp, ebp
    mov     edx, [eax+14253h]
    lea     ecx, [eax+14253h]
    cmp     edx, ebp
    mov     [esp+114h+var_108], ebp
    mov     [esp+114h+var_104], ecx
    jle     loc_423151
    push    edi
    add     eax, 1426Fh
    push    esi
    push    ebx
    mov     [esp+120h+var_110], eax
    mov     [esp+120h+var_10C], 64h

    loc_422EDE:                             ; CODE XREF: sub_422EA0+2A8j
    mov     eax, [esp+120h+var_110]
    mov     edi, ebp
    mov     edx, [eax]
    mov     eax, dword_511FB4
    add     edi, edx
    mov     esi, [eax+4]
    mov     ecx, [eax+8]
    cmp     esi, ecx
    jnb     short loc_422F1C

    loc_422EF7:                             ; CODE XREF: sub_422EA0+7Aj
    mov     ecx, [esi]
    call    sub_4C3E10
    mov     ecx, [esi]
    push    edi                             ; char *
    call    sub_4C3410
    test    eax, eax
    jnz     loc_423159
    mov     ecx, dword_511FB4
    add     esi, 4
    cmp     esi, [ecx+8]
    jb      short loc_422EF7

    loc_422F1C:                             ; CODE XREF: sub_422EA0+55j
    xor     esi, esi

    loc_422F1E:                             ; CODE XREF: sub_422EA0+2BBj
    mov     ebx, [esi+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+128h+var_100]
    push    offset aFeaturedead             ; char *
    push    edx                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_422FB9
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     ecx, [eax+14253h]
    test    ecx, ecx
    jle     short loc_422F81
    xor     edi, edi

    loc_422F53:                             ; CODE XREF: sub_422EA0+DFj
    mov     eax, [eax+1426Fh]
    lea     ecx, [esp+120h+var_100]
    add     eax, edi
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_422F86
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     edi, 100h
    cmp     esi, [eax+14253h]
    jl      short loc_422F53

    loc_422F81:                             ; CODE XREF: sub_422EA0+AFj
    mov     esi, 0FFFFh

    loc_422F86:                             ; CODE XREF: sub_422EA0+CBj
    cmp     si, 0FFFFh
    jz      short loc_422F9F
    mov     ecx, [esp+120h+var_110]
    mov     eax, esi
    mov     edx, [ecx]
    mov     [ebp+edx+0F4h], ax
    jmp     short loc_422FC9
    ; ---------------------------------------------------------------------------

    loc_422F9F:                             ; CODE XREF: sub_422EA0+EBj
    lea     edx, [esp+120h+var_100]
    push    edx
    call    sub_4224B0
    mov     ecx, [esp+120h+var_110]
    mov     edx, [ecx]
    mov     [ebp+edx+0F4h], ax
    jmp     short loc_422FC9
    ; ---------------------------------------------------------------------------

    loc_422FB9:                             ; CODE XREF: sub_422EA0+9Ej
    mov     eax, [esp+120h+var_110]
    mov     ecx, [eax]
    mov     word ptr [ebp+ecx+0F4h], 0FFFFh

    loc_422FC9:                             ; CODE XREF: sub_422EA0+FDj
                                            ; sub_422EA0+117j
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+128h+var_100]
    push    offset aFeaturereclama          ; char *
    push    edx                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_423061
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     ecx, [eax+14253h]
    test    ecx, ecx
    jle     short loc_423029
    xor     edi, edi

    loc_422FFB:                             ; CODE XREF: sub_422EA0+187j
    mov     eax, [eax+1426Fh]
    lea     ecx, [esp+120h+var_100]
    add     eax, edi
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_42302E
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     edi, 100h
    cmp     esi, [eax+14253h]
    jl      short loc_422FFB

    loc_423029:                             ; CODE XREF: sub_422EA0+157j
    mov     esi, 0FFFFh

    loc_42302E:                             ; CODE XREF: sub_422EA0+173j
    cmp     si, 0FFFFh
    jz      short loc_423047
    mov     eax, esi
    mov     esi, [esp+120h+var_110]
    mov     ecx, [esi]
    mov     [ebp+ecx+0F8h], ax
    jmp     short loc_423071
    ; ---------------------------------------------------------------------------

    loc_423047:                             ; CODE XREF: sub_422EA0+193j
    lea     edx, [esp+120h+var_100]
    push    edx
    call    sub_4224B0
    mov     esi, [esp+120h+var_110]
    mov     ecx, [esi]
    mov     [ebp+ecx+0F8h], ax
    jmp     short loc_423071
    ; ---------------------------------------------------------------------------

    loc_423061:                             ; CODE XREF: sub_422EA0+146j
    mov     esi, [esp+120h+var_110]
    mov     edx, [esi]
    mov     word ptr [ebp+edx+0F8h], 0FFFFh

    loc_423071:                             ; CODE XREF: sub_422EA0+1A5j
                                            ; sub_422EA0+1BFj
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     eax, [esp+128h+var_100]
    push    offset aFeatureburnt            ; char *
    push    eax                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_423109
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     ecx, [eax+14253h]
    test    ecx, ecx
    jle     short loc_4230D1
    xor     edi, edi

    loc_4230A3:                             ; CODE XREF: sub_422EA0+22Fj
    mov     ecx, [eax+1426Fh]
    lea     edx, [esp+120h+var_100]
    add     ecx, edi
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4230D6
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     edi, 100h
    cmp     esi, [eax+14253h]
    jl      short loc_4230A3

    loc_4230D1:                             ; CODE XREF: sub_422EA0+1FFj
    mov     esi, 0FFFFh

    loc_4230D6:                             ; CODE XREF: sub_422EA0+21Bj
    cmp     si, 0FFFFh
    jz      short loc_4230EF
    mov     ecx, [esp+120h+var_110]
    mov     eax, esi
    mov     edx, [ecx]
    mov     [ebp+edx+0F6h], ax
    jmp     short loc_423115
    ; ---------------------------------------------------------------------------

    loc_4230EF:                             ; CODE XREF: sub_422EA0+23Bj
    lea     eax, [esp+120h+var_100]
    push    eax
    call    sub_4224B0
    mov     ecx, [esp+120h+var_110]
    mov     edx, [ecx]
    mov     [ebp+edx+0F6h], ax
    jmp     short loc_423115
    ; ---------------------------------------------------------------------------

    loc_423109:                             ; CODE XREF: sub_422EA0+1EEj
    mov     eax, [esi]
    mov     word ptr [ebp+eax+0F6h], 0FFFFh

    loc_423115:                             ; CODE XREF: sub_422EA0+24Dj
                                            ; sub_422EA0+267j
    mov     ecx, [esp+120h+var_10C]
    mov     esi, [esp+120h+var_104]
    mov     eax, ecx
    add     ecx, 64h
    cdq
    idiv    dword ptr [esi]
    mov     edx, TAdynmemStructPtr
    mov     [esp+120h+var_10C], ecx
    add     ebp, 100h
    mov     [edx+38D72h], al
    mov     eax, [esp+120h+var_108]
    mov     ecx, [esi]
    inc     eax
    cmp     eax, ecx
    mov     [esp+120h+var_108], eax
    jl      loc_422EDE
    pop     ebx
    pop     esi
    pop     edi

    loc_423151:                             ; CODE XREF: sub_422EA0+24j
    pop     ebp
    add     esp, 110h
    retn
    ; ---------------------------------------------------------------------------

    loc_423159:                             ; CODE XREF: sub_422EA0+68j
    mov     esi, [esi]
    jmp     loc_422F1E
    sub_422EA0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_423160 proc near                    ; CODE XREF: sub_483610+53Ep

    var_4= dword ptr -4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    xor     ebx, ebx
    mov     ecx, [eax+391E9h]
    mov     [esp+8+var_4], ebx
    cmp     [ecx+0DC0h], ebx
    jle     loc_423284
    push    edi
    push    esi
    push    ebp

    loc_423182:                             ; CODE XREF: sub_423160+11Bj
    mov     esi, [ecx+0DBCh]
    mov     cl, [esi+ebx]
    add     esi, ebx
    test    cl, cl
    jz      loc_42325E
    mov     ecx, [eax+14253h]
    xor     edi, edi
    test    ecx, ecx
    jle     short loc_4231D1
    xor     ebp, ebp

    loc_4231A3:                             ; CODE XREF: sub_423160+6Fj
    mov     eax, [eax+1426Fh]
    add     eax, ebp
    push    eax                             ; char *
    push    esi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_423287
    mov     eax, TAdynmemStructPtr
    inc     edi
    add     ebp, 100h
    cmp     edi, [eax+14253h]
    jl      short loc_4231A3

    loc_4231D1:                             ; CODE XREF: sub_423160+3Fj
    mov     edi, 0FFFFh

    loc_4231D6:                             ; CODE XREF: sub_423160+12Cj
    cmp     di, 0FFFFh
    jnz     short loc_4231F1
    push    esi
    call    sub_4224B0
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    cmp     di, 0FFFFh
    jz      short loc_42325E

    loc_4231F1:                             ; CODE XREF: sub_423160+7Bj
    mov     edx, [eax+1426Fh]
    mov     ecx, edi
    and     ecx, 0FFFFh
    shl     ecx, 8
    add     ecx, edx
    test    byte ptr [ecx+0FEh], 1
    jz      short loc_42321D
    mov     ecx, [esi+84h]
    mov     edx, [esi+80h]
    push    ecx
    push    edx
    jmp     short loc_423247
    ; ---------------------------------------------------------------------------

    loc_42321D:                             ; CODE XREF: sub_423160+ABj
    movsx   eax, word ptr [ecx+96h]
    cdq
    sub     eax, edx
    mov     edx, [esi+84h]
    sar     eax, 1
    sub     edx, eax
    movsx   eax, word ptr [ecx+94h]
    mov     ecx, [esi+80h]
    push    edx
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ecx, eax
    push    ecx

    loc_423247:                             ; CODE XREF: sub_423160+BBj
    call    sub_481550
    push    0Ah
    push    0
    push    0
    push    edi
    push    eax
    call    sub_423C50
    mov     eax, TAdynmemStructPtr

    loc_42325E:                             ; CODE XREF: sub_423160+2Fj
                                            ; sub_423160+8Fj
    mov     ecx, [eax+391E9h]
    mov     edx, [esp+14h+var_4]
    inc     edx
    add     ebx, 88h
    mov     esi, [ecx+0DC0h]
    mov     [esp+14h+var_4], edx
    cmp     edx, esi
    jl      loc_423182
    pop     ebp
    pop     esi
    pop     edi

    loc_423284:                             ; CODE XREF: sub_423160+19j
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_423287:                             ; CODE XREF: sub_423160+57j
    mov     eax, TAdynmemStructPtr
    jmp     loc_4231D6
    sub_423160 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    mov     esi, [eax+1421Bh]
    lea     edi, [eax+1420Bh]
    cmp     esi, 0FFFFFFFFh
    jnz     short loc_4232C0
    mov     eax, 800h
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4232C0:                             ; CODE XREF: .text:004232B6j
    lea     ecx, [edi+8]
    push    ecx
    push    esi
    call    sub_4232F0
    mov     eax, [edi]
    lea     edx, [esi+esi*2]
    shl     edx, 4
    pop     edi
    mov     cl, [edx+eax+2Fh]
    lea     eax, [edx+eax+2Fh]
    and     cl, 0FEh
    mov     [eax], cl
    mov     eax, esi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4232F0 proc near                    ; CODE XREF: .text:004232C5p
                                            ; sub_4233A0+79p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+arg_0]
    push    ebx
    push    esi
    mov     esi, [eax+1420Bh]
    lea     ecx, [eax+1420Bh]
    lea     eax, [edx+edx*2]
    push    edi
    shl     eax, 4
    add     eax, esi
    mov     di, [eax+2]
    cmp     di, 0FFFFh
    jnz     short loc_423341
    cmp     [ecx+8], edx
    jnz     short loc_423327
    movsx   esi, word ptr [eax]
    mov     [ecx+8], esi
    jmp     short loc_423351
    ; ---------------------------------------------------------------------------

    loc_423327:                             ; CODE XREF: sub_4232F0+2Dj
    cmp     [ecx+0Ch], edx
    jnz     short loc_423334
    movsx   esi, word ptr [eax]
    mov     [ecx+0Ch], esi
    jmp     short loc_423351
    ; ---------------------------------------------------------------------------

    loc_423334:                             ; CODE XREF: sub_4232F0+3Aj
    cmp     [ecx+10h], edx
    jnz     short loc_423351
    movsx   esi, word ptr [eax]
    mov     [ecx+10h], esi
    jmp     short loc_423351
    ; ---------------------------------------------------------------------------

    loc_423341:                             ; CODE XREF: sub_4232F0+28j
    movsx   edi, di
    mov     bx, [eax]
    lea     edi, [edi+edi*2]
    shl     edi, 4
    mov     [edi+esi], bx

    loc_423351:                             ; CODE XREF: sub_4232F0+35j
                                            ; sub_4232F0+42j ...
    mov     si, [eax]
    cmp     si, 0FFFFh
    jz      short loc_42336E
    mov     edi, [ecx]
    mov     bx, [eax+2]
    movsx   esi, si
    lea     esi, [esi+esi*2]
    shl     esi, 4
    mov     [esi+edi+2], bx

    loc_42336E:                             ; CODE XREF: sub_4232F0+68j
    mov     esi, [esp+0Ch+arg_4]
    mov     di, [esi]
    mov     word ptr [eax+2], 0FFFFh
    mov     [eax], di
    mov     [esi], edx
    mov     ax, [eax]
    cmp     ax, 0FFFFh
    jz      short loc_423399
    mov     ecx, [ecx]
    movsx   eax, ax
    lea     eax, [eax+eax*2]
    shl     eax, 4
    mov     [eax+ecx+2], dx

    loc_423399:                             ; CODE XREF: sub_4232F0+97j
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_4232F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4233A0 proc near                    ; CODE XREF: sub_4239C0+8Dp
                                            ; sub_4239C0+195p ...

    idTo= dword ptr -14h
    var_10= word ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    sub     esp, 14h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    eax
    push    ecx
    call    sub_481550
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_42353C
    mov     ax, [ebp+8]
    cmp     ax, 0FFFBh
    jnb     loc_42353C
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFFFh
    shl     eax, 8
    mov     edi, [ecx+TAdynmemStruct.FeatureDef]
    add     edi, eax
    mov     eax, [edi+0B4h]
    test    eax, eax
    jz      loc_42353C
    test    byte ptr [ebp+0Ch], 1
    jnz     loc_42353C
    mov     esi, [ecx+1421Bh]
    lea     ebx, [ecx+1420Bh]
    cmp     esi, 0FFFFFFFFh
    jnz     short loc_423414
    mov     eax, 800h
    jmp     short loc_423439
    ; ---------------------------------------------------------------------------

    loc_423414:                             ; CODE XREF: sub_4233A0+6Bj
    lea     edx, [ebx+8]
    push    edx
    push    esi
    call    sub_4232F0
    mov     ecx, [ebx]
    lea     eax, [esi+esi*2]
    shl     eax, 4
    lea     eax, [eax+ecx+2Fh]
    mov     cl, [eax]
    and     cl, 0FEh
    mov     [eax], cl
    mov     ecx, TAdynmemStructPtr
    mov     eax, esi

    loc_423439:                             ; CODE XREF: sub_4233A0+72j
    cmp     eax, 800h
    jge     loc_42353C
    mov     edx, [ecx+TAdynmemStruct.WreckageInfo]
    lea     esi, [eax+eax*2]
    shl     esi, 4
    add     esi, edx
    mov     dx, [ebp+8]
    push    0
    mov     [esi+2Ch], dx
    mov     [ebp+0Ah], ax
    mov     al, [ebp+0Ch]
    lea     ecx, [esi+4]
    or      al, 1
    mov     [ebp+0Ch], al
    mov     eax, [edi+0B4h]
    push    eax
    push    ecx
    call    sub_4B8B30
    mov     eax, [edi+0B8h]
    test    eax, eax
    jz      short loc_423495
    push    0
    lea     edx, [esi+10h]
    push    eax
    push    edx
    call    sub_4B8B30
    mov     al, [esi+2Fh]
    or      al, 4
    jmp     short loc_42349A
    ; ---------------------------------------------------------------------------

    loc_423495:                             ; CODE XREF: sub_4233A0+E0j
    mov     al, [esi+2Fh]
    and     al, 0FBh

    loc_42349A:                             ; CODE XREF: sub_4233A0+F3j
    mov     ebp, [esp+24h+arg_4]
    mov     bl, al
    mov     [esi+2Fh], al
    mov     ax, word ptr [esp+24h+arg_0]
    or      bl, 1
    xor     ecx, ecx
    mov     [esi+2Fh], bl
    mov     [esi+28h], ax
    mov     [esi+2Ah], bp
    mov     cx, [edi+0E8h]
    shr     ecx, 1
    push    ecx                             ; int
    call    GetRandom
    mov     dx, [edi+0E8h]
    mov     cl, [esi+2Fh]
    mov     ebx, [esp+24h+arg_8]
    and     cl, 0F7h
    shr     edx, 1
    add     al, dl
    push    0                               ; int
    mov     [esi+2Eh], al
    mov     al, bl
    and     al, 1
    shl     al, 3
    or      al, cl
    lea     ecx, [esp+28h+var_C]
    mov     [esi+2Fh], al
    mov     esi, [esp+28h+arg_0]
    mov     edx, esi
    mov     eax, ebp
    shl     edx, 14h
    shl     eax, 14h
    push    ecx                             ; int
    push    offset aTreeburn                ; char *
    mov     [esp+30h+var_C], edx
    mov     [esp+30h+var_4], eax
    call    sub_47F610
    test    ebx, ebx
    jnz     short loc_42353C
    lea     edx, [esp+24h+idTo]
    push    6                               ; idFrom
    push    edx                             ; idTo
    mov     byte ptr [esp+2Ch+idTo], 0Fh
    mov     byte ptr [esp+2Ch+idTo+1], 0FEh
    mov     word ptr [esp+2Ch+idTo+2], si
    mov     [esp+2Ch+var_10], bp
    call    sub_44FDB0
    push    eax                             ; PlayerID
    call    sub_451DF0

    loc_42353C:                             ; CODE XREF: sub_4233A0+1Aj
                                            ; sub_4233A0+28j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    sub_4233A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_423550 proc near                    ; CODE XREF: sub_4237D0+195p
                                            ; sub_4244B0+178p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    push    ebp
    mov     ebp, [esp+10h+arg_4]
    push    esi
    mov     esi, [esp+14h+arg_0]
    push    edi
    push    ebp
    push    esi
    call    sub_481550
    mov     edi, eax
    cmp     word ptr [edi+8], 0FFFEh
    jnz     short loc_42358F
    xor     ecx, ecx
    xor     eax, eax
    mov     cl, [edi+0Ah]
    mov     al, [edi+0Bh]
    sub     ebp, ecx
    sub     esi, eax
    push    ebp
    push    esi
    mov     [esp+20h+arg_0], esi
    mov     [esp+20h+arg_4], ebp
    call    sub_481550
    mov     edi, eax

    loc_42358F:                             ; CODE XREF: sub_423550+1Ej
    mov     cx, [edi+8]
    cmp     cx, 0FFFBh
    jnb     loc_4236F7
    mov     edx, TAdynmemStructPtr
    and     ecx, 0FFFFh
    shl     ecx, 8
    mov     eax, [edx+1426Fh]
    add     eax, ecx
    xor     ecx, ecx
    mov     [esp+18h+var_8], ecx
    mov     [esp+18h+var_4], ecx
    test    byte ptr [eax+0FEh], 1
    mov     ebx, [esp+18h+arg_8]
    jz      short loc_4235F6
    cmp     ebx, ecx
    jz      short loc_4235E2
    mov     ecx, [eax+0C4h]
    mov     eax, [eax+0C8h]
    mov     [esp+18h+var_8], ecx
    jmp     short loc_4235F2
    ; ---------------------------------------------------------------------------

    loc_4235E2:                             ; CODE XREF: sub_423550+7Ej
    mov     ecx, [eax+0BCh]
    mov     eax, [eax+0C0h]
    mov     [esp+18h+var_8], ecx

    loc_4235F2:                             ; CODE XREF: sub_423550+90j
    mov     [esp+18h+var_4], eax

    loc_4235F6:                             ; CODE XREF: sub_423550+7Aj
    mov     eax, [esp+18h+var_8]
    test    eax, eax
    jz      loc_4236EF
    test    byte ptr [edi+0Ch], 1
    jnz     loc_4236F7
    mov     esi, [edx+1421Bh]
    lea     ebp, [edx+1420Bh]
    cmp     esi, 0FFFFFFFFh
    jnz     short loc_423624
    mov     eax, 800h
    jmp     short loc_42364C
    ; ---------------------------------------------------------------------------

    loc_423624:                             ; CODE XREF: sub_423550+CBj
    lea     ecx, [ebp+8]
    push    ecx
    push    esi
    call    sub_4232F0
    mov     eax, [ebp+0]
    lea     edx, [esi+esi*2]
    shl     edx, 4
    mov     cl, [edx+eax+2Fh]
    lea     eax, [edx+eax+2Fh]
    and     cl, 0FEh
    mov     [eax], cl
    mov     edx, TAdynmemStructPtr
    mov     eax, esi

    loc_42364C:                             ; CODE XREF: sub_423550+D2j
    cmp     eax, 800h
    jge     loc_4236F7
    mov     ebp, [edx+1420Bh]
    mov     cx, [edi+8]
    lea     esi, [eax+eax*2]
    xor     edx, edx
    shl     esi, 4
    add     esi, ebp
    push    0
    test    ebx, ebx
    setnz   dl
    mov     [esi+2Ch], cx
    mov     cl, [esi+2Fh]
    and     dl, 1
    and     cl, 0EFh
    shl     dl, 4
    or      dl, cl
    mov     [esi+2Fh], dl
    mov     edx, [esp+1Ch+var_8]
    mov     [edi+0Ah], ax
    mov     al, [edi+0Ch]
    or      al, 1
    push    edx
    mov     [edi+0Ch], al
    lea     eax, [esi+4]
    push    eax
    call    sub_4B8B30
    mov     eax, [esp+18h+var_4]
    test    eax, eax
    jz      short loc_4236BC
    push    0
    lea     ecx, [esi+10h]
    push    eax
    push    ecx
    call    sub_4B8B30
    mov     al, [esi+2Fh]
    or      al, 4
    jmp     short loc_4236C1
    ; ---------------------------------------------------------------------------

    loc_4236BC:                             ; CODE XREF: sub_423550+157j
    mov     al, [esi+2Fh]
    and     al, 0FBh

    loc_4236C1:                             ; CODE XREF: sub_423550+16Aj
    mov     cx, word ptr [esp+18h+arg_4]
    and     bl, 1
    mov     dl, al
    mov     [esi+2Fh], al
    mov     ax, word ptr [esp+18h+arg_0]
    and     dl, 0FCh
    shl     bl, 1
    or      bl, dl
    mov     [esi+28h], ax
    mov     [esi+2Fh], bl
    mov     [esi+2Ah], cx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4236EF:                             ; CODE XREF: sub_423550+ACj
    push    ebx
    push    ebp
    push    esi
    call    sub_423710

    loc_4236F7:                             ; CODE XREF: sub_423550+48j
                                            ; sub_423550+B6j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_423550 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_423710 proc near                    ; CODE XREF: sub_423550+1A2p
                                            ; sub_424050+445p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    push    ebx
    push    esi
    push    edi
    push    eax
    push    ecx
    call    sub_481550
    mov     edi, eax
    test    edi, edi
    jz      loc_4237C3
    mov     ax, [edi+8]
    cmp     ax, 0FFFBh
    jnb     loc_4237C3
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFFFh
    shl     eax, 8
    mov     ecx, [edx+1426Fh]
    add     ecx, eax
    mov     eax, [esp+0Ch+arg_8]
    test    eax, eax
    jz      short loc_423761
    mov     bx, [ecx+0F8h]
    jmp     short loc_423768
    ; ---------------------------------------------------------------------------

    loc_423761:                             ; CODE XREF: sub_423710+46j
    mov     bx, [ecx+0F4h]

    loc_423768:                             ; CODE XREF: sub_423710+4Fj
    test    byte ptr [edi+0Ch], 1
    jz      short loc_4237AE
    xor     eax, eax
    mov     ax, [edi+0Ah]
    lea     esi, [eax+eax*2]
    mov     eax, [edx+1420Bh]
    shl     esi, 4
    add     esi, eax
    test    byte ptr [esi+2Fh], 2
    jz      short loc_42378F
    mov     bx, [ecx+0F8h]

    loc_42378F:                             ; CODE XREF: sub_423710+76j
    push    0
    push    edi
    call    sub_4246B0
    lea     edx, [esi+20h]
    push    0Ah
    add     esi, 8
    push    edx
    push    esi
    push    ebx
    push    edi
    call    sub_423C50
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4237AE:                             ; CODE XREF: sub_423710+5Cj
    push    0
    push    edi
    call    sub_4246B0
    push    0Ah
    push    0
    push    0
    push    ebx
    push    edi
    call    sub_423C50

    loc_4237C3:                             ; CODE XREF: sub_423710+16j
                                            ; sub_423710+24j
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_423710 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4237D0 proc near                    ; CODE XREF: .text:00404D66p
                                            ; .text:00414A4Ap

    idTo= dword ptr -8
    var_4= word ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_4]
    sub     esp, 8
    mov     eax, [ecx]
    push    ebx
    cdq
    and     edx, 0FFFFFh
    push    ebp
    push    esi
    add     eax, edx
    push    edi
    mov     edi, eax
    mov     eax, [ecx+8]
    cdq
    and     edx, 0FFFFFh
    add     eax, edx
    mov     ebp, eax
    sar     ebp, 14h
    sar     edi, 14h
    push    ebp
    push    edi
    call    sub_481550
    push    ebp
    push    edi
    mov     esi, eax
    call    sub_481550
    mov     edx, TAdynmemStructPtr
    test    eax, eax
    jnz     short loc_42381A
    xor     ecx, ecx
    jmp     short loc_423882
    ; ---------------------------------------------------------------------------

    loc_42381A:                             ; CODE XREF: sub_4237D0+44j
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_42383A
    mov     eax, ecx
    mov     ecx, [edx+14253h]
    and     eax, 0FFFFh
    cmp     eax, ecx
    jl      short loc_423877
    xor     ecx, ecx
    jmp     short loc_423882
    ; ---------------------------------------------------------------------------

    loc_42383A:                             ; CODE XREF: sub_4237D0+53j
    cmp     cx, 0FFFEh
    jz      short loc_423845
    xor     ecx, ecx
    jmp     short loc_423882
    ; ---------------------------------------------------------------------------

    loc_423845:                             ; CODE XREF: sub_4237D0+6Fj
    xor     ecx, ecx
    mov     cl, [eax+0Ah]
    mov     ebx, ecx
    mov     ecx, [edx+14233h]
    imul    ecx, ebx
    xor     ebx, ebx
    mov     bl, [eax+0Bh]
    add     ecx, ebx
    lea     ebx, [ecx+ecx*2]
    lea     ecx, [ecx+ebx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_423872
    xor     ecx, ecx
    jmp     short loc_423882
    ; ---------------------------------------------------------------------------

    loc_423872:                             ; CODE XREF: sub_4237D0+9Cj
    and     eax, 0FFFFh

    loc_423877:                             ; CODE XREF: sub_4237D0+64j
    mov     ecx, [edx+1426Fh]
    shl     eax, 8
    add     ecx, eax

    loc_423882:                             ; CODE XREF: sub_4237D0+48j
                                            ; sub_4237D0+68j ...
    test    ecx, ecx
    jnz     short loc_423892
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_423892:                             ; CODE XREF: sub_4237D0+B4j
    test    byte ptr [esi+0Ch], 1
    jz      short loc_4238AD
    test    byte ptr [ecx+0FEh], 1
    jz      short loc_4238AD
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4238AD:                             ; CODE XREF: sub_4237D0+C6j
                                            ; sub_4237D0+CFj
    mov     esi, [esp+18h+arg_0]
    mov     bl, 2
    fld     dword ptr [ecx+0ECh]
    mov     eax, [esi+0ECh]
    cmp     dword ptr [eax], 0
    jz      short loc_4238F7
    cmp     [eax+73h], bl
    jnz     short loc_4238F7
    mov     eax, [edx+37EEEh]
    sub     eax, 0
    jz      short loc_4238DF
    dec     eax
    jnz     short loc_4238F7
    fmul    ds:dbl_4FD040
    jmp     short loc_4238E5
    ; ---------------------------------------------------------------------------

    loc_4238DF:                             ; CODE XREF: sub_4237D0+102j
    fmul    ds:dbl_4FD048

    loc_4238E5:                             ; CODE XREF: sub_4237D0+10Dj
    fld     dword ptr [esi+0BCh]
    fxch    st(1)
    fsubp   st(1), st
    fstp    dword ptr [esi+0BCh]
    jmp     short loc_423907
    ; ---------------------------------------------------------------------------

    loc_4238F7:                             ; CODE XREF: sub_4237D0+F2j
                                            ; sub_4237D0+F7j ...
    fld     dword ptr [esi+0BCh]
    fadd    st, st(1)
    fstp    dword ptr [esi+0BCh]
    fstp    st

    loc_423907:                             ; CODE XREF: sub_4237D0+125j
    mov     eax, [esi+0ECh]
    fld     dword ptr [ecx+0F0h]
    cmp     dword ptr [eax], 0
    jz      short loc_423955
    cmp     [eax+73h], bl
    jnz     short loc_423955
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37EEEh]
    sub     eax, 0
    jz      short loc_423943
    dec     eax
    jnz     short loc_423955
    fmul    ds:dbl_4FD040
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_42395B
    ; ---------------------------------------------------------------------------

    loc_423943:                             ; CODE XREF: sub_4237D0+15Cj
    fmul    ds:dbl_4FD048
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_42395B
    ; ---------------------------------------------------------------------------

    loc_423955:                             ; CODE XREF: sub_4237D0+146j
                                            ; sub_4237D0+14Bj ...
    fadd    dword ptr [esi+0D4h]

    loc_42395B:                             ; CODE XREF: sub_4237D0+171j
                                            ; sub_4237D0+183j
    fstp    dword ptr [esi+0D4h]
    push    1
    push    ebp
    push    edi
    call    sub_423550
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_4239A9
    mov     edx, [esi+96h]
    mov     byte ptr [esp+18h+idTo], 0Fh
    mov     byte ptr [esp+18h+idTo+1], 0FFh
    mov     word ptr [esp+18h+idTo+2], di
    mov     [esp+18h+var_4], bp
    mov     eax, [edx+4]
    lea     ecx, [esp+18h+idTo]
    push    6                               ; idFrom
    push    ecx                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0

    loc_4239A9:                             ; CODE XREF: sub_4237D0+1ADj
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 8
    retn    8
    sub_4237D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4239C0 proc near                    ; CODE XREF: sub_424050+413p

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+30h+arg_4]
    push    edi
    movsx   eax, word ptr [esi+2]
    lea     ebp, [eax-3]
    add     eax, 3
    cmp     ebp, eax
    jg      loc_423A71

    loc_4239DD:                             ; CODE XREF: sub_4239C0+ABj
    movsx   eax, word ptr [esi]
    lea     edi, [eax-3]
    lea     ecx, [eax+3]
    cmp     edi, ecx
    jg      short loc_423A61

    loc_4239EA:                             ; CODE XREF: sub_4239C0+9Fj
    cmp     edi, eax
    jnz     short loc_4239F6
    movsx   edx, word ptr [esi+2]
    cmp     ebp, edx
    jz      short loc_423A56

    loc_4239F6:                             ; CODE XREF: sub_4239C0+2Cj
    push    ebp
    push    edi
    call    sub_481550
    test    eax, eax
    jz      short loc_423A56
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_423A56
    test    byte ptr [eax+0Ch], 1
    jnz     short loc_423A56
    mov     eax, TAdynmemStructPtr
    and     ecx, 0FFFFh
    shl     ecx, 8
    mov     esi, [eax+1426Fh]
    add     esi, ecx
    mov     cl, [esi+0FEh]
    shr     cl, 4
    test    cl, 1
    jz      short loc_423A52
    push    64h                             ; int
    call    GetRandom
    xor     edx, edx
    mov     dl, [esi+0FBh]
    cmp     eax, edx
    jge     short loc_423A52
    push    0
    push    ebp
    push    edi
    call    sub_4233A0

    loc_423A52:                             ; CODE XREF: sub_4239C0+74j
                                            ; sub_4239C0+87j
    mov     esi, [esp+34h+arg_4]

    loc_423A56:                             ; CODE XREF: sub_4239C0+34j
                                            ; sub_4239C0+3Fj ...
    movsx   eax, word ptr [esi]
    inc     edi
    lea     ecx, [eax+3]
    cmp     edi, ecx
    jle     short loc_4239EA

    loc_423A61:                             ; CODE XREF: sub_4239C0+28j
    movsx   edx, word ptr [esi+2]
    inc     ebp
    add     edx, 3
    cmp     ebp, edx
    jle     loc_4239DD

    loc_423A71:                             ; CODE XREF: sub_4239C0+17j
    movsx   edi, word ptr [esi]
    mov     eax, edi
    mov     [esp+34h+var_1C], 5
    shl     eax, 10h
    mov     [esp+34h+var_24], eax
    movsx   eax, word ptr [esi+2]
    mov     ecx, eax
    mov     ebx, eax
    shl     ecx, 10h
    mov     [esp+34h+var_20], ecx

    loc_423A94:                             ; CODE XREF: sub_4239C0+1A7j
    mov     esi, TAdynmemStructPtr
    push    0
    push    20000h
    mov     eax, [esi+37ECCh]
    cdq
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     edx, [esp+34h+var_24]
    push    0
    add     edx, eax
    mov     eax, [esi+37ED4h]
    mov     [esp+38h+var_24], edx
    push    20000h
    cdq
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ecx, [esp+34h+var_20]
    movsx   esi, word ptr [esp+34h+var_24+2]
    add     ecx, eax
    cmp     esi, edi
    mov     [esp+34h+var_20], ecx
    movsx   ebp, word ptr [esp+34h+var_20+2]
    jnz     short loc_423AFE
    cmp     ebp, ebx
    jz      short loc_423B5E

    loc_423AFE:                             ; CODE XREF: sub_4239C0+138j
    push    ebp
    push    esi
    call    sub_481550
    test    eax, eax
    jz      short loc_423B5A
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_423B5A
    test    byte ptr [eax+0Ch], 1
    jnz     short loc_423B5A
    mov     eax, TAdynmemStructPtr
    and     ecx, 0FFFFh
    shl     ecx, 8
    mov     edi, [eax+1426Fh]
    add     edi, ecx
    mov     cl, [edi+0FEh]
    shr     cl, 4
    test    cl, 1
    jz      short loc_423B5A
    push    64h                             ; int
    call    GetRandom
    xor     edx, edx
    mov     dl, [edi+0FBh]
    cmp     eax, edx
    jge     short loc_423B5A
    push    0
    push    ebp
    push    esi
    call    sub_4233A0

    loc_423B5A:                             ; CODE XREF: sub_4239C0+147j
                                            ; sub_4239C0+152j ...
    mov     edi, esi
    mov     ebx, ebp

    loc_423B5E:                             ; CODE XREF: sub_4239C0+13Cj
    mov     eax, [esp+34h+var_1C]
    dec     eax
    mov     [esp+34h+var_1C], eax
    jnz     loc_423A94
    mov     esi, [esp+34h+arg_0]
    mov     eax, [esi+0E4h]
    test    eax, eax
    jz      short loc_423BE5
    mov     ecx, [esp+34h+arg_4]
    mov     eax, [esi+94h]
    mov     [esp+34h+arg_0], eax
    mov     ecx, [ecx]
    movsx   edx, cx
    movsx   eax, ax
    mov     [esp+34h+arg_4], ecx
    lea     ecx, [eax+edx*2]
    movsx   edx, word ptr [esp+34h+arg_4+2]
    movsx   eax, word ptr [esp+34h+arg_0+2]
    shl     ecx, 13h
    mov     [esp+34h+var_18], ecx
    lea     ecx, [eax+edx*2]
    lea     edx, [esp+34h+var_18]
    shl     ecx, 13h
    push    edx
    mov     [esp+38h+var_10], ecx
    call    sub_485070
    shl     eax, 10h
    mov     ecx, [esp+34h+var_18]
    mov     edx, [esp+34h+var_10]
    mov     [esp+34h+var_8], eax
    mov     [esp+34h+var_C], ecx
    mov     ecx, [esi+0E4h]
    lea     eax, [esp+34h+var_C]
    push    eax
    push    ecx
    mov     [esp+3Ch+var_4], edx
    call    sub_49A0C0

    loc_423BE5:                             ; CODE XREF: sub_4239C0+1B9j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    8
    sub_4239C0 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    push    edi
    mov     edi, [esp+0Ch]
    movsx   eax, word ptr [edi+2Ah]
    movsx   ecx, word ptr [edi+28h]
    push    eax
    push    ecx
    call    sub_481550
    mov     esi, eax
    test    esi, esi
    jz      short loc_423C43
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [edi+2Ch]
    push    0
    mov     ecx, [eax+1426Fh]
    push    esi
    shl     edx, 8
    mov     di, [edx+ecx+0F6h]
    call    sub_4246B0
    cmp     di, 0FFFFh
    jz      short loc_423C43
    push    0Ah
    push    0
    push    0
    push    edi
    push    esi
    call    sub_423C50

    loc_423C43:                             ; CODE XREF: .text:00423C09j
                                            ; .text:00423C34j
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_423C50 proc near                    ; CODE XREF: .text:00416412p
                                            ; sub_423160+F4p ...

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 28h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+34h+arg_4]
    cmp     si, 0FFFFh
    push    edi
    mov     [esp+38h+var_28], 0
    jnz     short loc_423C76
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_423C76:                             ; CODE XREF: sub_423C50+18j
    cmp     si, 0FFFCh
    jnz     short loc_423C91
    mov     eax, [esp+38h+arg_0]
    mov     [eax+8], si
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_423C91:                             ; CODE XREF: sub_423C50+2Bj
    mov     edi, TAdynmemStructPtr
    mov     ebp, [esp+38h+arg_0]
    mov     ecx, ebp
    mov     eax, 4EC4EC4Fh
    mov     edx, [edi+14287h]
    mov     ebx, [edi+1426Fh]
    sub     ecx, edx
    mov     edi, [edi+14233h]
    imul    ecx
    sar     edx, 2
    mov     ecx, edx
    and     esi, 0FFFFh
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, edx
    mov     eax, ecx
    cdq
    idiv    edi
    shl     esi, 8
    add     esi, ebx
    mov     eax, ecx
    movsx   ecx, word ptr [esi+94h]
    mov     bx, dx
    cdq
    idiv    edi
    movsx   edx, bx
    mov     [esp+38h+var_20], edx
    add     edx, ecx
    cmp     edx, edi
    mov     word ptr [esp+38h+var_24], bx
    mov     word ptr [esp+38h+var_24+2], ax
    jle     short loc_423D06
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_423D06:                             ; CODE XREF: sub_423C50+A8j
    movsx   edx, word ptr [esi+96h]
    mov     edi, TAdynmemStructPtr
    movsx   eax, ax
    mov     ebx, [edi+14237h]
    mov     [esp+38h+var_1C], eax
    add     eax, edx
    cmp     eax, ebx
    jle     short loc_423D32
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_423D32:                             ; CODE XREF: sub_423C50+D4j
    test    edx, edx
    mov     [esp+38h+arg_0], 0
    jle     short loc_423D96

    loc_423D3E:                             ; CODE XREF: sub_423C50+144j
    mov     edx, TAdynmemStructPtr
    mov     edi, ebp
    xor     ebx, ebx
    mov     eax, [edx+14233h]
    imul    eax, [esp+38h+arg_0]
    add     edi, eax
    lea     edx, [eax+eax*2]
    test    ecx, ecx
    lea     edi, [edi+edx*4]
    jle     short loc_423D82

    loc_423D5F:                             ; CODE XREF: sub_423C50+130j
    cmp     word ptr [edi+8], 0FFFFh
    jz      short loc_423D73
    push    0
    push    edi
    call    sub_4246B0
    test    eax, eax
    jz      short loc_423DE7

    loc_423D73:                             ; CODE XREF: sub_423C50+115j
    movsx   ecx, word ptr [esi+94h]
    inc     ebx
    add     edi, 0Dh
    cmp     ebx, ecx
    jl      short loc_423D5F

    loc_423D82:                             ; CODE XREF: sub_423C50+10Dj
    mov     eax, [esp+38h+arg_0]
    movsx   edx, word ptr [esi+96h]
    inc     eax
    cmp     eax, edx
    mov     [esp+38h+arg_0], eax
    jl      short loc_423D3E

    loc_423D96:                             ; CODE XREF: sub_423C50+ECj
    test    byte ptr [esi+0FEh], 1
    jnz     loc_423EDD
    mov     eax, TAdynmemStructPtr
    mov     edi, [eax+1421Bh]
    lea     ebx, [eax+1420Bh]
    cmp     edi, 0FFFFFFFFh
    jnz     short loc_423DC0
    mov     edi, 800h
    jmp     short loc_423DDF
    ; ---------------------------------------------------------------------------

    loc_423DC0:                             ; CODE XREF: sub_423C50+167j
    lea     ecx, [ebx+8]
    push    ecx
    push    edi
    call    sub_4232F0
    mov     eax, [ebx]
    lea     edx, [edi+edi*2]
    shl     edx, 4
    mov     cl, [edx+eax+2Fh]
    lea     eax, [edx+eax+2Fh]
    and     cl, 0FEh
    mov     [eax], cl

    loc_423DDF:                             ; CODE XREF: sub_423C50+16Ej
    cmp     edi, 800h
    jl      short loc_423DF3

    loc_423DE7:                             ; CODE XREF: sub_423C50+121j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_423DF3:                             ; CODE XREF: sub_423C50+195j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+38h+var_24]
    lea     eax, [edi+edi*2]
    mov     ebx, [ecx+1420Bh]
    mov     ecx, [esp+38h+arg_8]
    shl     eax, 4
    add     eax, ebx
    mov     ebx, [esp+38h+arg_4]
    test    ecx, ecx
    mov     [esp+38h+var_28], eax
    mov     [eax+2Ch], bx
    mov     word ptr [eax+26h], 0
    mov     [eax+28h], edx
    jz      short loc_423E3D
    mov     edx, [ecx]
    add     eax, 8
    mov     [eax], edx
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     ecx, [ecx+8]
    mov     [eax+8], ecx
    jmp     short loc_423E8F
    ; ---------------------------------------------------------------------------

    loc_423E3D:                             ; CODE XREF: sub_423C50+1D6j
    mov     eax, [esi+94h]
    movsx   edx, ax
    mov     [esp+38h+arg_4], eax
    mov     eax, [esp+38h+var_20]
    lea     ecx, [edx+eax*2]
    mov     eax, [esp+38h+var_1C]
    movsx   edx, word ptr [esp+38h+arg_4+2]
    shl     ecx, 13h
    mov     [esp+38h+var_18], ecx
    lea     ecx, [edx+eax*2]
    lea     edx, [esp+38h+var_18]
    shl     ecx, 13h
    push    edx
    mov     [esp+3Ch+var_10], ecx
    call    sub_485070
    shl     eax, 10h
    mov     ecx, [esp+38h+var_28]
    mov     edx, [esp+38h+var_18]
    add     ecx, 8
    mov     [ecx], edx
    mov     [ecx+4], eax
    mov     eax, [esp+38h+var_10]
    mov     [ecx+8], eax

    loc_423E8F:                             ; CODE XREF: sub_423C50+1EBj
    mov     eax, [esp+38h+arg_C]
    test    eax, eax
    jz      short loc_423EAC
    mov     ecx, [esp+38h+var_28]
    mov     edx, [eax]
    add     ecx, 20h
    mov     [ecx], edx
    mov     ax, [eax+4]
    mov     [ecx+4], ax
    jmp     short loc_423EBB
    ; ---------------------------------------------------------------------------

    loc_423EAC:                             ; CODE XREF: sub_423C50+245j
    mov     edx, [esp+38h+var_28]
    xor     ecx, ecx
    add     edx, 20h
    mov     [edx], ecx
    mov     [edx+4], cx

    loc_423EBB:                             ; CODE XREF: sub_423C50+25Aj
    mov     eax, [esi+98h]
    push    eax
    call    sub_45A8D0
    mov     ecx, [esp+38h+var_28]
    mov     [ecx+4], eax
    mov     al, [ebp+0Ch]
    mov     [ebp+8], bx
    mov     [ebp+0Ah], di
    or      al, 1
    jmp     short loc_423EF1
    ; ---------------------------------------------------------------------------

    loc_423EDD:                             ; CODE XREF: sub_423C50+14Dj
    mov     dx, word ptr [esp+38h+arg_4]
    mov     al, [ebp+0Ch]
    mov     [ebp+8], dx
    mov     word ptr [ebp+0Ah], 0
    and     al, 0FEh

    loc_423EF1:                             ; CODE XREF: sub_423C50+28Bj
    mov     [ebp+0Ch], al
    mov     al, byte ptr [esp+38h+arg_10]
    mov     cl, [ebp+0Ch]
    and     al, 0Fh
    shl     al, 3
    and     cl, 87h
    xor     edx, edx
    or      al, cl
    mov     [ebp+0Ch], al
    cmp     [esi+96h], dx
    jle     short loc_423F73
    mov     edi, 0FFFEh

    loc_423F18:                             ; CODE XREF: sub_423C50+321j
    mov     eax, TAdynmemStructPtr
    mov     ebx, ebp
    mov     eax, [eax+14233h]
    imul    eax, edx
    add     ebx, eax
    lea     ecx, [eax+eax*2]
    lea     eax, [ebx+ecx*4]
    xor     ecx, ecx
    cmp     [esi+94h], cx
    jle     short loc_423F67
    add     eax, 0Bh

    loc_423F3E:                             ; CODE XREF: sub_423C50+315j
    test    ecx, ecx
    jnz     short loc_423F46
    test    edx, edx
    jz      short loc_423F58

    loc_423F46:                             ; CODE XREF: sub_423C50+2F0j
    mov     bl, [eax+1]
    mov     [eax-3], di
    and     bl, 0FEh
    mov     [eax], cl
    mov     [eax-1], dl
    mov     [eax+1], bl

    loc_423F58:                             ; CODE XREF: sub_423C50+2F4j
    movsx   ebx, word ptr [esi+94h]
    inc     ecx
    add     eax, 0Dh
    cmp     ecx, ebx
    jl      short loc_423F3E

    loc_423F67:                             ; CODE XREF: sub_423C50+2E9j
    movsx   eax, word ptr [esi+96h]
    inc     edx
    cmp     edx, eax
    jl      short loc_423F18

    loc_423F73:                             ; CODE XREF: sub_423C50+2C1j
    mov     cl, [esi+0FEh]
    shr     cl, 5
    test    cl, 1
    jz      short loc_423FE8
    mov     eax, [esp+38h+arg_8]
    test    eax, eax
    jz      short loc_423F8D
    push    4
    jmp     short loc_423FE2
    ; ---------------------------------------------------------------------------

    loc_423F8D:                             ; CODE XREF: sub_423C50+337j
    mov     eax, [esi+94h]
    movsx   edx, ax
    mov     [esp+38h+arg_10], eax
    mov     eax, [esp+38h+var_20]
    lea     ecx, [edx+eax*2]
    mov     eax, [esp+38h+var_1C]
    movsx   edx, word ptr [esp+38h+arg_10+2]
    shl     ecx, 13h
    mov     [esp+38h+var_18], ecx
    lea     ecx, [edx+eax*2]
    lea     edx, [esp+38h+var_18]
    shl     ecx, 13h
    push    edx
    mov     [esp+3Ch+var_10], ecx
    call    sub_485070
    shl     eax, 10h
    mov     ecx, [esp+38h+var_18]
    mov     edx, [esp+38h+var_10]
    mov     [esp+38h+var_8], eax
    mov     [esp+38h+var_C], ecx
    mov     [esp+38h+var_4], edx
    push    4
    lea     eax, [esp+3Ch+var_C]

    loc_423FE2:                             ; CODE XREF: sub_423C50+33Bj
    push    eax
    call    sub_472C50

    loc_423FE8:                             ; CODE XREF: sub_423C50+32Fj
    mov     edi, TAdynmemStructPtr
    mov     eax, 4EC4EC4Fh
    mov     ecx, [edi+14287h]
    mov     edi, [edi+14233h]
    sub     ebp, ecx
    mov     ecx, ebp
    imul    ecx
    sar     edx, 2
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, edx
    mov     eax, ecx
    cdq
    idiv    edi
    mov     eax, ecx
    mov     word ptr [esp+38h+arg_10], dx
    cdq
    idiv    edi
    mov     edx, [esi+94h]
    push    edx
    mov     word ptr [esp+3Ch+arg_10+2], ax
    mov     eax, [esp+3Ch+arg_10]
    push    eax
    call    sub_440A40
    pop     edi
    pop     esi
    mov     eax, [esp+30h+var_28]
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    14h
    sub_423C50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_424050 proc near                    ; CODE XREF: .text:00495585p

    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     eax, TAdynmemStructPtr
    sub     esp, 34h
    mov     ecx, [eax+14253h]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [eax+1426Fh]
    push    edi
    xor     edi, edi
    test    ecx, ecx
    jle     short loc_4240A3
    add     esi, 0CCh

    loc_424074:                             ; CODE XREF: sub_424050+51j
    mov     cl, [esi+32h]
    shr     cl, 1
    test    cl, 1
    jz      short loc_424092
    push    esi
    call    sub_4B8B90
    lea     edx, [esi+0Ch]
    push    edx
    call    sub_4B8B90
    mov     eax, TAdynmemStructPtr

    loc_424092:                             ; CODE XREF: sub_424050+2Cj
    mov     ecx, [eax+14253h]
    inc     edi
    add     esi, 100h
    cmp     edi, ecx
    jl      short loc_424074

    loc_4240A3:                             ; CODE XREF: sub_424050+1Cj
    mov     ecx, [eax+14257h]
    dec     ecx
    mov     [eax+14257h], ecx
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14257h]
    jns     short loc_4240D7
    mov     eax, [ecx+14233h]
    imul    eax, [ecx+14237h]
    dec     eax
    mov     [ecx+14257h], eax
    jmp     loc_4241A8
    ; ---------------------------------------------------------------------------

    loc_4240D7:                             ; CODE XREF: sub_424050+6Cj
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    mov     edx, [ecx+14287h]
    add     edx, eax
    mov     [esp+44h+var_34], edx
    mov     ax, [edx+8]
    cmp     ax, 0FFFBh
    jnb     loc_4241AE
    test    byte ptr [edx+0Ch], 1
    jnz     loc_4241AE
    mov     esi, [ecx+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8
    push    64h                             ; int
    add     esi, eax
    call    GetRandom
    xor     ecx, ecx
    mov     cl, [esi+0FCh]
    cmp     eax, ecx
    jge     loc_4241A8
    mov     ecx, TAdynmemStructPtr
    mov     edi, [ecx+14257h]
    mov     eax, edi
    cdq
    idiv    dword ptr [ecx+14233h]
    mov     eax, edi
    mov     ebx, edx
    cdq
    idiv    dword ptr [ecx+14237h]
    xor     edx, edx
    mov     dl, [esi+0FDh]
    mov     ebp, edx
    mov     edi, eax
    xor     eax, eax
    mov     al, dl
    push    eax                             ; int
    call    GetRandom
    mov     ecx, ebp
    push    ebp                             ; int
    shr     ecx, 1
    sub     eax, ecx
    add     ebx, eax
    call    GetRandom
    xor     edx, edx
    mov     dl, [esi+0FDh]
    shr     edx, 1
    sub     eax, edx
    add     edi, eax
    push    edi
    push    ebx
    call    sub_481550
    test    eax, eax
    jz      short loc_4241A8
    mov     ecx, [esp+44h+var_34]
    cmp     word ptr [ecx], 0
    jnz     short loc_4241A8
    cmp     word ptr [eax+8], 0FFFFh
    jnz     short loc_4241A8
    mov     cx, [ecx+8]
    push    0Ah
    push    0
    push    0
    push    ecx
    push    eax
    call    sub_423C50

    loc_4241A8:                             ; CODE XREF: sub_424050+82j
                                            ; sub_424050+D2j ...
    mov     ecx, TAdynmemStructPtr

    loc_4241AE:                             ; CODE XREF: sub_424050+A1j
                                            ; sub_424050+ABj
    mov     eax, [ecx+38A47h]
    xor     edx, edx
    mov     esi, 3
    div     esi
    mov     eax, [ecx+14213h]
    neg     edx
    sbb     edx, edx
    inc     edx
    cmp     eax, 0FFFFFFFFh
    mov     [esp+44h+var_34], edx
    jz      loc_4244A5
    jmp     short loc_4241E1
    ; ---------------------------------------------------------------------------

    loc_4241D7:                             ; CODE XREF: sub_424050+44Fj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+44h+var_34]

    loc_4241E1:                             ; CODE XREF: sub_424050+185j
    mov     ebp, [ecx+1420Bh]
    lea     esi, [eax+eax*2]
    mov     ebx, [ecx+1426Fh]
    xor     edi, edi
    shl     esi, 4
    add     esi, ebp
    mov     di, [esi+2Ch]
    movsx   ebp, word ptr [esi]
    shl     edi, 8
    add     ebx, edi
    mov     [esp+44h+var_28], ebp
    test    byte ptr [ebx+0FEh], 1
    jnz     loc_4242CA
    mov     edx, [esi+14h]
    lea     edi, [esi+14h]
    test    edx, edx
    jnz     short loc_424230
    mov     edx, [edi+8]
    test    edx, edx
    jnz     short loc_424230
    mov     edx, [edi+4]
    test    edx, edx
    jz      loc_4242B8

    loc_424230:                             ; CODE XREF: sub_424050+1CCj
                                            ; sub_424050+1D3j
    mov     edx, [edi]
    mov     ebx, [esi+8]
    lea     eax, [esi+8]
    add     ebx, edx
    push    eax
    mov     edx, [eax+4]
    mov     [eax], ebx
    mov     ecx, [edi+4]
    mov     ebx, [eax+8]
    add     edx, ecx
    mov     [eax+4], edx
    mov     edx, [edi+8]
    add     ebx, edx
    mov     [eax+8], ebx
    call    sub_485140
    mov     ecx, [esi+0Ch]
    shl     eax, 10h
    cmp     ecx, eax
    jg      short loc_424278
    mov     [esi+0Ch], eax
    xor     eax, eax
    xor     ecx, ecx
    xor     edx, edx
    mov     [edi], eax
    mov     [edi+4], ecx
    mov     [edi+8], edx
    jmp     loc_42449A
    ; ---------------------------------------------------------------------------

    loc_424278:                             ; CODE XREF: sub_424050+210j
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [eax+1427Fh]
    shl     edx, 10h
    cmp     ecx, edx
    jge     short loc_4242A5
    mov     dword ptr [edi], 0
    mov     dword ptr [esi+18h], 0FFFFD334h
    mov     dword ptr [esi+1Ch], 0
    jmp     loc_42449A
    ; ---------------------------------------------------------------------------

    loc_4242A5:                             ; CODE XREF: sub_424050+23Aj
    mov     eax, [eax+14263h]
    mov     ecx, [esi+18h]
    sub     ecx, eax
    mov     [esi+18h], ecx
    jmp     loc_42449A
    ; ---------------------------------------------------------------------------

    loc_4242B8:                             ; CODE XREF: sub_424050+1DAj
    add     ecx, 14217h
    push    ecx
    push    eax
    call    sub_4232F0
    jmp     loc_42449A
    ; ---------------------------------------------------------------------------

    loc_4242CA:                             ; CODE XREF: sub_424050+1BEj
    test    byte ptr [esi+2Fh], 1
    jz      loc_42446A
    test    edx, edx
    jz      loc_4243D8
    mov     ecx, [esi+28h]
    mov     eax, [ebx+94h]
    mov     [esp+44h+var_30], ecx
    mov     [esp+44h+var_2C], eax
    movsx   ecx, cx
    movsx   edx, ax
    lea     eax, [edx+ecx*2]
    movsx   ecx, word ptr [esp+44h+var_30+2]
    movsx   edx, word ptr [esp+44h+var_2C+2]
    shl     eax, 13h
    mov     [esp+44h+var_18], eax
    lea     eax, [edx+ecx*2]
    lea     ecx, [esp+44h+var_18]
    shl     eax, 13h
    push    ecx
    mov     [esp+48h+var_10], eax
    call    sub_485070
    shl     eax, 10h
    mov     edx, [esp+44h+var_18]
    mov     [esp+44h+var_14], eax
    mov     [esp+44h+var_20], eax
    mov     eax, [esp+44h+var_10]
    lea     ecx, [esi+4]
    mov     [esp+44h+var_24], edx
    push    ecx
    mov     [esp+48h+var_1C], eax
    call    sub_4B7EE0
    mov     ebp, eax
    mov     di, [ebp+0]
    call    _rand
    mov     dx, di
    push    0
    shr     dx, 1
    and     edx, 0FFFFh
    push    8000h
    imul    edx
    push    edx
    push    eax
    call    __alldiv
    sub     ax, [ebp+4]
    shr     di, 2
    add     eax, edi
    mov     di, [ebp+2]
    add     word ptr [esp+44h+var_24+2], ax
    call    _rand
    mov     cx, di
    push    0
    shr     cx, 1
    and     ecx, 0FFFFh
    push    8000h
    imul    ecx
    push    edx
    push    eax
    call    __alldiv
    mov     dx, [ebp+6]
    push    5
    sub     dx, ax
    mov     eax, [esp+48h+var_24]
    shr     di, 2
    shl     edx, 1
    shl     edi, 1
    sub     edx, edi
    mov     [esp+48h+var_C], eax
    add     word ptr [esp+48h+var_20+2], dx
    mov     ecx, [esp+48h+var_20]
    mov     edx, [esp+48h+var_1C]
    lea     eax, [esp+48h+var_C]
    push    eax
    mov     [esp+4Ch+var_8], ecx
    mov     [esp+4Ch+var_4], edx
    call    sub_472810
    mov     ebp, [esp+44h+var_28]

    loc_4243D8:                             ; CODE XREF: sub_424050+286j
    lea     ecx, [esi+4]
    push    ecx
    call    sub_4B8B90
    test    byte ptr [esi+2Fh], 4
    jz      short loc_4243F0
    lea     edx, [esi+10h]
    push    edx
    call    sub_4B8B90

    loc_4243F0:                             ; CODE XREF: sub_424050+395j
    mov     eax, [esi+0Ch]
    test    eax, eax
    jnz     short loc_42444A
    movsx   eax, word ptr [esi+2Ah]
    movsx   ecx, word ptr [esi+28h]
    push    eax
    push    ecx
    call    sub_481550
    mov     edi, eax
    test    edi, edi
    jz      loc_42449A
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [esi+2Ch]
    push    0
    mov     ecx, [eax+1426Fh]
    push    edi
    shl     edx, 8
    mov     si, [ecx+edx+0F6h]
    call    sub_4246B0
    cmp     si, 0FFFFh
    jz      short loc_42449A
    push    0Ah
    push    0
    push    0
    push    esi
    push    edi
    call    sub_423C50
    jmp     short loc_42449A
    ; ---------------------------------------------------------------------------

    loc_42444A:                             ; CODE XREF: sub_424050+3A5j
    mov     al, [esi+2Eh]
    test    al, al
    jbe     short loc_42449A
    test    byte ptr [esi+2Fh], 8
    jnz     short loc_42449A
    dec     al
    mov     [esi+2Eh], al
    jnz     short loc_42449A
    add     esi, 28h
    push    esi
    push    ebx
    call    sub_4239C0
    jmp     short loc_42449A
    ; ---------------------------------------------------------------------------

    loc_42446A:                             ; CODE XREF: sub_424050+27Ej
    lea     edx, [esi+4]
    push    edx
    call    sub_4B8B90
    test    byte ptr [esi+2Fh], 4
    jz      short loc_424482
    lea     eax, [esi+10h]
    push    eax
    call    sub_4B8B90

    loc_424482:                             ; CODE XREF: sub_424050+427j
    mov     eax, [esi+0Ch]
    test    eax, eax
    jnz     short loc_42449A
    movsx   ecx, word ptr [esi+2Ah]
    movsx   edx, word ptr [esi+28h]
    push    0
    push    ecx
    push    edx
    call    sub_423710

    loc_42449A:                             ; CODE XREF: sub_424050+223j
                                            ; sub_424050+250j ...
    cmp     ebp, 0FFFFFFFFh
    mov     eax, ebp
    jnz     loc_4241D7

    loc_4244A5:                             ; CODE XREF: sub_424050+17Fj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn
    sub_424050 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4244B0(int,int,int,int)
    sub_4244B0 proc near                    ; CODE XREF: Network_Process+1756p
                                            ; sub_49A120+506p

    idTo= dword ptr -8
    var_4= word ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     ecx, TAdynmemStructPtr
    sub     esp, 8
    mov     al, [ecx+37F2Fh]
    push    ebx
    push    ebp
    push    esi
    test    al, 8
    push    edi
    jz      loc_42469F
    mov     edi, [esp+18h+arg_0]
    mov     ax, [edi+8]
    cmp     ax, 0FFFBh
    jnb     loc_42469F
    mov     esi, [ecx+TAdynmemStruct.FeatureDef]
    and     eax, 0FFFFh
    shl     eax, 8
    add     esi, eax
    mov     ax, [esi+0FEh]
    shr     eax, 9
    test    al, 1
    jnz     loc_42469F
    mov     ecx, [ecx+TAdynmemStruct.MapFile]
    call    sub_435100
    mov     edx, TAdynmemStructPtr
    cmp     eax, 3
    jnz     short loc_424593
    xor     ecx, ecx
    mov     ebx, edx
    mov     cl, [edx+TAdynmemStruct.LOS_Sight]
    mov     eax, ecx
    add     ebx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [ebx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], 1
    jnz     short loc_424584
    mov     edx, [esp+18h+arg_C]
    mov     cx, word ptr [esp+18h+arg_4]
    push    6                               ; idFrom
    mov     byte ptr [esp+1Ch+idTo], 0Fh
    mov     al, [edx+10Ah]
    mov     dx, word ptr [esp+1Ch+arg_8]
    mov     byte ptr [esp+1Ch+idTo+1], al
    lea     eax, [esp+1Ch+idTo]
    push    eax                             ; idTo
    mov     word ptr [esp+20h+idTo+2], cx
    mov     [esp+20h+var_4], dx
    call    sub_450030
    push    eax                             ; PlayersToSendTo
    call    sub_44FDB0
    push    eax                             ; dwDataSize
    call    Network_BroadcastMessage
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_424584:                             ; CODE XREF: sub_4244B0+89j
    mov     [esp+18h+arg_0], 1
    mov     byte ptr [esp+18h+idTo+1], 0FCh
    jmp     short loc_42459B
    ; ---------------------------------------------------------------------------

    loc_424593:                             ; CODE XREF: sub_4244B0+63j
    mov     [esp+18h+arg_0], 0

    loc_42459B:                             ; CODE XREF: sub_4244B0+E1j
    mov     ax, [esi+0FEh]
    mov     ebx, [esp+18h+arg_4]
    mov     ebp, [esp+18h+arg_C]
    test    al, 10h
    jz      short loc_4245D0
    mov     cl, [ebp+10Bh]
    test    cl, cl
    jz      short loc_4245D0
    test    byte ptr [edi+0Ch], 1
    jnz     short loc_4245D6
    mov     ecx, [esp+18h+arg_8]
    push    0
    push    ecx
    push    ebx
    call    sub_4233A0
    jmp     loc_42466A
    ; ---------------------------------------------------------------------------

    loc_4245D0:                             ; CODE XREF: sub_4244B0+FCj
                                            ; sub_4244B0+106j
    test    byte ptr [edi+0Ch], 1
    jz      short loc_424634

    loc_4245D6:                             ; CODE XREF: sub_4244B0+10Cj
    test    al, 1
    jnz     loc_42466A
    xor     eax, eax
    mov     ax, [edi+0Ah]
    mov     edi, [edx+1420Bh]
    lea     eax, [eax+eax*2]
    shl     eax, 4
    add     eax, edi
    movsx   ecx, word ptr [eax+28h]
    cmp     ecx, ebx
    jnz     loc_42469F
    movsx   edx, word ptr [eax+2Ah]
    cmp     edx, [esp+18h+arg_8]
    jnz     loc_42469F
    mov     di, [ebp+0D4h]
    add     [eax+26h], di
    mov     ax, [eax+26h]
    cmp     ax, [esi+0EAh]
    jb      short loc_42466A
    push    0
    push    edx
    push    ecx
    call    sub_423550
    mov     byte ptr [esp+18h+idTo+1], 0FDh
    jmp     short loc_42466A
    ; ---------------------------------------------------------------------------

    loc_424634:                             ; CODE XREF: sub_4244B0+124j
    xor     eax, eax
    xor     edx, edx
    mov     ax, [ebp+0D4h]
    mov     dx, [edi+0Ah]
    xor     ecx, ecx
    add     eax, edx
    mov     cx, [esi+0EAh]
    cmp     eax, ecx
    jl      short loc_424666
    mov     edx, [esp+18h+arg_8]
    push    0
    push    edx
    push    ebx
    call    sub_423550
    mov     byte ptr [esp+18h+idTo+1], 0FDh
    jmp     short loc_42466A
    ; ---------------------------------------------------------------------------

    loc_424666:                             ; CODE XREF: sub_4244B0+1A0j
    mov     [edi+0Ah], ax

    loc_42466A:                             ; CODE XREF: sub_4244B0+11Bj
                                            ; sub_4244B0+128j ...
    mov     eax, [esp+18h+arg_0]
    test    eax, eax
    jz      short loc_42469F
    cmp     byte ptr [esp+18h+idTo+1], 0FCh
    jbe     short loc_42469F
    mov     ax, word ptr [esp+18h+arg_8]
    lea     ecx, [esp+18h+idTo]
    push    6                               ; idFrom
    push    ecx                             ; idTo
    mov     byte ptr [esp+20h+idTo], 0Fh
    mov     word ptr [esp+20h+idTo+2], bx
    mov     [esp+20h+var_4], ax
    call    sub_44FDB0
    push    eax                             ; PlayerID
    call    sub_451DF0

    loc_42469F:                             ; CODE XREF: sub_4244B0+15j
                                            ; sub_4244B0+27j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    10h
    sub_4244B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4246B0 proc near                    ; CODE XREF: .text:0040519Ep
                                            ; .text:004163C8p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+0Ch+arg_0]
    cmp     word ptr [edi+8], 0FFFEh
    jnz     short loc_4246E8
    xor     eax, eax
    xor     edx, edx
    mov     al, [edi+0Ah]
    mov     dl, [edi+0Bh]
    imul    eax, [ecx+14233h]
    add     eax, edx
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    shl     edx, 1
    sub     edx, eax
    neg     edx
    add     edi, edx

    loc_4246E8:                             ; CODE XREF: sub_4246B0+14j
    mov     ax, [edi+8]
    cmp     ax, 0FFFBh
    jb      short loc_4246FB
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4246FB:                             ; CODE XREF: sub_4246B0+40j
    mov     esi, [ecx+1426Fh]
    mov     ebx, 0FFFFh
    and     eax, ebx
    shl     eax, 8
    add     esi, eax
    mov     eax, [esp+0Ch+arg_4]
    test    eax, eax
    jnz     short loc_424727
    test    byte ptr [esi+0FFh], 2
    jz      short loc_424727
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_424727:                             ; CODE XREF: sub_4246B0+63j
                                            ; sub_4246B0+6Cj
    test    byte ptr [edi+0Ch], 1
    jz      short loc_424774
    mov     ebp, [ecx+1420Bh]
    xor     eax, eax
    mov     ax, [edi+0Ah]
    lea     eax, [eax+eax*2]
    shl     eax, 4
    add     ebp, eax
    mov     al, [esi+0FEh]
    test    al, 1
    jnz     short loc_424761
    mov     ecx, [ebp+4]
    push    ecx
    call    sub_45AAA0
    mov     dword ptr [ebp+4], 0
    mov     ecx, TAdynmemStructPtr

    loc_424761:                             ; CODE XREF: sub_4246B0+99j
    xor     edx, edx
    add     ecx, 1421Bh
    mov     dx, [edi+0Ah]
    push    ecx
    push    edx
    call    sub_4232F0

    loc_424774:                             ; CODE XREF: sub_4246B0+7Bj
    mov     cl, [edi+0Ch]
    xor     edx, edx
    and     cl, 0FEh
    mov     [edi+8], bx
    mov     [edi+0Ch], cl
    cmp     [esi+96h], dx
    jle     short loc_4247DD

    loc_42478C:                             ; CODE XREF: sub_4246B0+12Bj
    mov     eax, TAdynmemStructPtr
    mov     ebp, edi
    mov     eax, [eax+14233h]
    imul    eax, edx
    add     ebp, eax
    lea     ecx, [eax+eax*2]
    lea     eax, [ebp+ecx*4+0]
    xor     ecx, ecx
    cmp     [esi+94h], cx
    jle     short loc_4247D1
    add     eax, 0Ch

    loc_4247B3:                             ; CODE XREF: sub_4246B0+11Fj
    cmp     word ptr [eax-4], 0FFFEh
    jnz     short loc_4247C2
    and     byte ptr [eax], 0FEh
    mov     [eax-4], bx

    loc_4247C2:                             ; CODE XREF: sub_4246B0+109j
    movsx   ebp, word ptr [esi+94h]
    inc     ecx
    add     eax, 0Dh
    cmp     ecx, ebp
    jl      short loc_4247B3

    loc_4247D1:                             ; CODE XREF: sub_4246B0+FEj
    movsx   eax, word ptr [esi+96h]
    inc     edx
    cmp     edx, eax
    jl      short loc_42478C

    loc_4247DD:                             ; CODE XREF: sub_4246B0+DAj
    mov     ebx, TAdynmemStructPtr
    mov     eax, 4EC4EC4Fh
    sub     edi, [ebx+14287h]
    imul    edi
    sar     edx, 2
    mov     ecx, edx
    mov     edi, [ebx+14233h]
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, edx
    mov     eax, ecx
    cdq
    idiv    edi
    mov     eax, ecx
    mov     word ptr [esp+0Ch+arg_0], dx
    cdq
    idiv    edi
    mov     edx, [esi+94h]
    push    edx
    mov     word ptr [esp+10h+arg_0+2], ax
    mov     eax, [esp+10h+arg_0]
    push    eax
    call    sub_440A40
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    8
    sub_4246B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_424840 proc near                    ; CODE XREF: .text:00416390p
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14233h]
    imul    eax, [edx+14237h]
    test    eax, eax
    jle     short locret_42488D
    push    edi
    push    esi
    xor     esi, esi
    mov     edi, eax

    loc_42485D:                             ; CODE XREF: sub_424840+49j
    mov     eax, [edx+14287h]
    add     eax, esi
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jb      short loc_424877
    cmp     cx, 0FFFEh
    jnz     short loc_424885

    loc_424877:                             ; CODE XREF: sub_424840+2Ej
    push    1
    push    eax
    call    sub_4246B0
    mov     edx, TAdynmemStructPtr

    loc_424885:                             ; CODE XREF: sub_424840+35j
    add     esi, 0Dh
    dec     edi
    jnz     short loc_42485D
    pop     esi
    pop     edi

    locret_42488D:                          ; CODE XREF: sub_424840+15j
    retn
    sub_424840 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_424890 proc near                    ; CODE XREF: sub_4326B0+365p

    var_D8= dword ptr -0D8h
    var_D4= dword ptr -0D4h
    var_D0= dword ptr -0D0h
    var_CC= word ptr -0CCh
    var_CA= word ptr -0CAh
    var_C8= byte ptr -0C8h
    var_C7= byte ptr -0C7h
    var_C4= dword ptr -0C4h
    var_C0= dword ptr -0C0h
    var_BC= dword ptr -0BCh
    var_B8= dword ptr -0B8h
    var_B4= word ptr -0B4h
    var_B2= word ptr -0B2h
    var_B0= dword ptr -0B0h
    var_AC= dword ptr -0ACh
    var_A8= word ptr -0A8h
    var_A6= word ptr -0A6h
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= word ptr -94h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_80= dword ptr -80h
    arg_0= dword ptr  4

    sub     esp, 0D8h
    push    ebx
    push    ebp
    mov     ebp, [esp+0E0h+arg_0]
    push    esi
    push    edi
    push    offset aFeatures_1              ; char *
    mov     ecx, ebp
    call    sub_4B4560
    mov     eax, TAdynmemStructPtr
    mov     ebx, [eax+14253h]
    test    ebx, ebx
    mov     eax, ebx
    jge     short loc_4248C0
    xor     eax, eax

    loc_4248C0:                             ; CODE XREF: sub_424890+2Cj
    shl     eax, 7
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [esp+0E8h+var_8C], eax
    test    ebx, ebx
    jbe     short loc_4248F3
    mov     edx, ebx

    loc_4248D6:                             ; CODE XREF: sub_424890+5Dj
    test    eax, eax
    jz      short loc_4248E7
    mov     ecx, 20h
    lea     esi, [esp+0E8h+var_80]
    mov     edi, eax
    rep movsd

    loc_4248E7:                             ; CODE XREF: sub_424890+48j
    add     eax, 80h
    dec     edx
    jnz     short loc_4248D6
    mov     eax, [esp+0E8h+var_8C]

    loc_4248F3:                             ; CODE XREF: sub_424890+42j
    shl     ebx, 7
    add     ebx, eax
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     [esp+0E8h+var_88], ebx
    mov     ecx, [eax+14253h]
    mov     ebx, [eax+1426Fh]
    test    ecx, ecx
    jle     short loc_424941

    loc_424915:                             ; CODE XREF: sub_424890+AFj
    push    80h                             ; size_t
    push    ebx                             ; char *
    push    edi                             ; char *
    call    _strncpy
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    inc     esi
    add     edi, 80h
    mov     eax, [ecx+14253h]
    add     ebx, 100h
    cmp     esi, eax
    jl      short loc_424915

    loc_424941:                             ; CODE XREF: sub_424890+83j
    push    offset aFeatureTypeNam          ; "Feature Type Names"
    mov     ecx, ebp
    call    sub_4B4BA0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+0E8h+var_8C]
    mov     eax, [edx+14253h]
    shl     eax, 7
    push    eax
    push    ecx
    mov     ecx, ebp
    call    sub_4B4CF0
    mov     edx, TAdynmemStructPtr
    xor     ebx, ebx
    mov     [esp+0E8h+var_C0], ebx
    mov     [esp+0E8h+var_C4], ebx
    mov     eax, [edx+14233h]
    mov     esi, [edx+14287h]
    imul    eax, [edx+14237h]
    mov     edi, esi
    mov     [esp+0E8h+var_BC], ebx
    lea     ecx, [eax+eax*2]
    add     edi, eax
    mov     [esp+0E8h+var_D4], ebx
    mov     [esp+0E8h+var_D8], ebx
    lea     eax, [edi+ecx*4]
    cmp     esi, eax
    mov     [esp+0E8h+var_B0], eax
    jnb     loc_424B58

    loc_4249AE:                             ; CODE XREF: sub_424890+2C2j
    mov     cx, [esi+8]
    cmp     cx, 0FFFBh
    jnb     loc_424B2B
    mov     edi, [edx+1426Fh]
    mov     eax, ecx
    and     eax, 0FFFFh
    shl     eax, 8
    add     edi, eax
    test    byte ptr [edi+0FEh], 1
    jnz     loc_424A6E
    mov     edi, [edx+1420Bh]
    xor     eax, eax
    mov     ax, [esi+0Ah]
    mov     dx, word ptr [esp+0E8h+var_D8]
    mov     word ptr [esp+0E8h+var_AC], bx
    mov     word ptr [esp+0E8h+var_AC+2], dx
    lea     eax, [eax+eax*2]
    mov     [esp+0E8h+var_A8], cx
    shl     eax, 4
    add     eax, edi
    push    offset a3dFeatures              ; "3D Features"
    mov     cx, [eax+26h]
    lea     edx, [eax+8]
    mov     [esp+0ECh+var_A6], cx
    add     eax, 20h
    mov     ecx, [edx]
    mov     [esp+0ECh+var_A4], ecx
    mov     ecx, [edx+4]
    mov     [esp+0ECh+var_A0], ecx
    mov     edx, [edx+8]
    mov     [esp+0ECh+var_9C], edx
    mov     ecx, [eax]
    mov     [esp+0ECh+var_98], ecx
    mov     ecx, ebp
    mov     dx, [eax+4]
    mov     [esp+0ECh+var_94], dx
    call    sub_4B4BA0
    mov     ecx, ebp
    call    sub_4B4BF0
    push    eax
    mov     ecx, ebp
    call    sub_4B4C10
    lea     eax, [esp+0E8h+var_AC]
    push    1Ah
    push    eax
    mov     ecx, ebp
    call    sub_4B4CF0
    mov     edx, TAdynmemStructPtr
    inc     [esp+0E8h+var_C4]
    jmp     loc_424B2B
    ; ---------------------------------------------------------------------------

    loc_424A6E:                             ; CODE XREF: sub_424890+146j
    test    byte ptr [esi+0Ch], 1
    jz      loc_424BA5
    xor     eax, eax
    mov     ax, [esi+0Ah]
    lea     eax, [eax+eax*2]
    shl     eax, 4
    add     eax, [edx+1420Bh]
    mov     word ptr [esp+0E8h+var_D0], bx
    mov     bx, word ptr [esp+0E8h+var_D8]
    mov     [esp+0E8h+var_CC], cx
    mov     word ptr [esp+0E8h+var_D0+2], bx
    mov     bl, [esp+0E8h+var_C7]
    mov     cx, [eax+26h]
    mov     [esp+0E8h+var_CA], cx
    mov     cl, [eax+4]
    mov     [esp+0E8h+var_C8], cl
    mov     cl, [eax+2Eh]
    xor     bl, cl
    and     bl, 0Fh
    xor     cl, bl
    mov     ebx, [edi+0B4h]
    mov     [esp+0E8h+var_C7], cl
    mov     eax, [eax+0Ch]
    cmp     eax, ebx
    jnz     short loc_424AD2
    and     cl, 0F0h
    jmp     short loc_424AF0
    ; ---------------------------------------------------------------------------

    loc_424AD2:                             ; CODE XREF: sub_424890+23Bj
    cmp     eax, [edi+0BCh]
    jnz     short loc_424AE2
    and     cl, 0F1h
    or      cl, 1
    jmp     short loc_424AF0
    ; ---------------------------------------------------------------------------

    loc_424AE2:                             ; CODE XREF: sub_424890+248j
    cmp     eax, [edi+0C4h]
    jnz     short loc_424B27
    and     cl, 0F2h
    or      cl, 2

    loc_424AF0:                             ; CODE XREF: sub_424890+240j
                                            ; sub_424890+250j
    mov     [esp+0E8h+var_C7], cl
    push    offset aAnimatingFeatu          ; "Animating Features"
    mov     ecx, ebp
    call    sub_4B4BA0
    mov     ecx, ebp
    call    sub_4B4BF0
    push    eax
    mov     ecx, ebp
    call    sub_4B4C10
    lea     edx, [esp+0E8h+var_D0]
    push    0Ah
    push    edx
    mov     ecx, ebp
    call    sub_4B4CF0
    mov     edx, TAdynmemStructPtr
    inc     [esp+0E8h+var_BC]

    loc_424B27:                             ; CODE XREF: sub_424890+258j
    mov     ebx, [esp+0E8h+var_D4]

    loc_424B2B:                             ; CODE XREF: sub_424890+127j
                                            ; sub_424890+1D9j ...
    mov     eax, [edx+14233h]
    inc     ebx
    cmp     ebx, eax
    mov     [esp+0E8h+var_D4], ebx
    jl      short loc_424B49
    mov     eax, [esp+0E8h+var_D8]
    xor     ebx, ebx
    inc     eax
    mov     [esp+0E8h+var_D4], ebx
    mov     [esp+0E8h+var_D8], eax

    loc_424B49:                             ; CODE XREF: sub_424890+2A8j
    mov     eax, [esp+0E8h+var_B0]
    add     esi, 0Dh
    cmp     esi, eax
    jb      loc_4249AE

    loc_424B58:                             ; CODE XREF: sub_424890+118j
    mov     eax, [esp+0E8h+var_C0]
    mov     ecx, ebp
    push    eax                             ; int
    push    offset aNumberOfNormal          ; char *
    call    sub_4B4630
    mov     ecx, [esp+0E8h+var_C4]
    push    ecx                             ; int
    push    offset aNumberOf3dFeat          ; char *
    mov     ecx, ebp
    call    sub_4B4630
    mov     ecx, ebp
    mov     edx, [esp+0E8h+var_BC]
    push    edx                             ; int
    push    offset aNumberOfAnimat          ; char *
    call    sub_4B4630
    mov     eax, [esp+0E8h+var_8C]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D8h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_424BA5:                             ; CODE XREF: sub_424890+1E2j
    mov     ax, word ptr [esp+0E8h+var_D8]
    mov     [esp+0E8h+var_B4], cx
    mov     cx, [esi+0Ah]
    push    offset aNormalFeatures          ; "Normal Features"
    mov     [esp+0ECh+var_B2], cx
    mov     ecx, ebp
    mov     word ptr [esp+0ECh+var_B8], bx
    mov     word ptr [esp+0ECh+var_B8+2], ax
    call    sub_4B4BA0
    mov     ecx, ebp
    call    sub_4B4BF0
    push    eax
    mov     ecx, ebp
    call    sub_4B4C10
    lea     edx, [esp+0E8h+var_B8]
    push    8
    push    edx
    mov     ecx, ebp
    call    sub_4B4CF0
    mov     edx, TAdynmemStructPtr
    inc     [esp+0E8h+var_C0]
    jmp     loc_424B2B
    sub_424890 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_424C00 proc near                    ; CODE XREF: sub_432610+4Ap

    var_C0= dword ptr -0C0h
    var_BC= dword ptr -0BCh
    var_B8= byte ptr -0B8h
    var_B7= byte ptr -0B7h
    var_B4= dword ptr -0B4h
    var_B0= dword ptr -0B0h
    var_AC= dword ptr -0ACh
    var_A8= dword ptr -0A8h
    var_A4= dword ptr -0A4h
    var_9D= byte ptr -9Dh
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_88= dword ptr -88h
    var_80= dword ptr -80h
    arg_0= dword ptr  4

    sub     esp, 0C0h
    push    ebx
    mov     ebx, [esp+0C4h+arg_0]
    push    ebp
    push    esi
    push    edi
    push    offset aFeatures_1              ; char *
    mov     ecx, ebx
    call    sub_4B4560
    xor     ebp, ebp
    mov     al, [esp+0D0h+var_9D]
    mov     [esp+0D0h+var_B0], ebp
    mov     byte ptr [esp+0D0h+var_B4], al
    mov     [esp+0D0h+var_AC], ebp
    mov     [esp+0D0h+var_A8], ebp
    call    sub_4222E0
    push    offset aFeatureTypeNam          ; "Feature Type Names"
    mov     ecx, ebx
    call    sub_4B4BA0
    test    eax, eax
    jz      loc_424E23
    mov     ecx, ebx
    call    sub_4B4BF0
    mov     ecx, [esp+0D0h+var_B0]
    mov     edx, [esp+0D0h+var_AC]
    mov     esi, eax
    mov     [esp+0D0h+var_A4], ebp
    shr     esi, 7
    cmp     ecx, ebp
    mov     [esp+0D0h+var_C0], esi
    jnz     short loc_424C70
    xor     eax, eax
    jmp     short loc_424C76
    ; ---------------------------------------------------------------------------

    loc_424C70:                             ; CODE XREF: sub_424C00+6Aj
    mov     eax, edx
    sub     eax, ecx
    sar     eax, 1

    loc_424C76:                             ; CODE XREF: sub_424C00+6Ej
    cmp     eax, esi
    jnb     short loc_424C9E
    cmp     ecx, ebp
    jnz     short loc_424C82
    xor     eax, eax
    jmp     short loc_424C88
    ; ---------------------------------------------------------------------------

    loc_424C82:                             ; CODE XREF: sub_424C00+7Cj
    mov     eax, edx
    sub     eax, ecx
    sar     eax, 1

    loc_424C88:                             ; CODE XREF: sub_424C00+80j
    lea     ecx, [esp+0D0h+var_A4]
    push    ecx
    mov     ecx, esi
    sub     ecx, eax
    push    ecx
    push    edx
    lea     ecx, [esp+0DCh+var_B4]
    call    sub_425210
    jmp     short loc_424CC1
    ; ---------------------------------------------------------------------------

    loc_424C9E:                             ; CODE XREF: sub_424C00+78j
    lea     ecx, [esp+0D0h+var_B4]
    call    sub_4251F0
    cmp     esi, eax
    jnb     short loc_424CC1
    mov     eax, [esp+0D0h+var_B0]
    mov     edx, [esp+0D0h+var_AC]
    push    edx
    lea     ecx, [eax+esi*2]
    push    ecx
    lea     ecx, [esp+0D8h+var_B4]
    call    sub_425430

    loc_424CC1:                             ; CODE XREF: sub_424C00+9Cj
                                            ; sub_424C00+A9j
    cmp     esi, ebp
    mov     eax, esi
    jge     short loc_424CC9
    xor     eax, eax

    loc_424CC9:                             ; CODE XREF: sub_424C00+C5j
    shl     eax, 7
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     esi, ebp
    mov     [esp+0D0h+var_98], eax
    jbe     short loc_424CFC
    mov     edx, esi

    loc_424CDF:                             ; CODE XREF: sub_424C00+F6j
    cmp     eax, ebp
    jz      short loc_424CF0
    mov     ecx, 20h
    lea     esi, [esp+0D0h+var_80]
    mov     edi, eax
    rep movsd

    loc_424CF0:                             ; CODE XREF: sub_424C00+E1j
    add     eax, 80h
    dec     edx
    jnz     short loc_424CDF
    mov     esi, [esp+0D0h+var_C0]

    loc_424CFC:                             ; CODE XREF: sub_424C00+DBj
    mov     edi, [esp+0D0h+var_98]
    mov     eax, esi
    shl     eax, 7
    push    eax
    push    edi
    lea     edx, [edi+eax]
    mov     ecx, ebx
    mov     [esp+0D8h+var_94], edx
    call    sub_4B4C80
    cmp     esi, ebp
    jle     loc_424E15
    mov     [esp+0D0h+var_A4], ebp
    mov     ebx, edi

    loc_424D23:                             ; CODE XREF: sub_424C00+209j
    mov     eax, TAdynmemStructPtr
    cmp     ebp, [eax+14253h]
    jge     short loc_424D5C
    mov     eax, [eax+1426Fh]
    mov     edx, [esp+0D0h+var_A4]
    add     eax, edx
    push    eax                             ; char *
    push    ebx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_424D57
    mov     ecx, [esp+0D0h+var_B0]
    mov     [ecx+ebp*2], bp
    jmp     loc_424DF2
    ; ---------------------------------------------------------------------------

    loc_424D57:                             ; CODE XREF: sub_424C00+148j
    mov     eax, TAdynmemStructPtr

    loc_424D5C:                             ; CODE XREF: sub_424C00+12Ej
    mov     ecx, [eax+14253h]
    xor     esi, esi
    test    ecx, ecx
    jle     short loc_424D98
    xor     edi, edi

    loc_424D6A:                             ; CODE XREF: sub_424C00+196j
    mov     edx, [eax+1426Fh]
    add     edx, edi
    push    edx                             ; char *
    push    ebx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_4251CB
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     edi, 100h
    cmp     esi, [eax+14253h]
    jl      short loc_424D6A

    loc_424D98:                             ; CODE XREF: sub_424C00+166j
    mov     ecx, [eax+14253h]
    xor     esi, esi
    test    ecx, ecx
    jle     short loc_424DD0
    xor     edi, edi

    loc_424DA6:                             ; CODE XREF: sub_424C00+1CEj
    mov     ecx, [eax+1426Fh]
    add     ecx, edi
    push    ecx                             ; char *
    push    ebx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_424DD5
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     edi, 100h
    cmp     esi, [eax+14253h]
    jl      short loc_424DA6

    loc_424DD0:                             ; CODE XREF: sub_424C00+1A2j
    mov     esi, 0FFFFh

    loc_424DD5:                             ; CODE XREF: sub_424C00+1BAj
    cmp     si, 0FFFFh
    jz      short loc_424DE0
    mov     eax, esi
    jmp     short loc_424DE6
    ; ---------------------------------------------------------------------------

    loc_424DE0:                             ; CODE XREF: sub_424C00+1DAj
    push    ebx
    call    sub_4224B0

    loc_424DE6:                             ; CODE XREF: sub_424C00+1DEj
    mov     edx, [esp+0D0h+var_B0]
    mov     [edx+ebp*2], ax

    loc_424DEE:                             ; CODE XREF: sub_424C00+5D3j
    mov     esi, [esp+0D0h+var_C0]

    loc_424DF2:                             ; CODE XREF: sub_424C00+152j
    mov     edx, [esp+0D0h+var_A4]
    inc     ebp
    add     edx, 100h
    add     ebx, 80h
    cmp     ebp, esi
    mov     [esp+0D0h+var_A4], edx
    jl      loc_424D23
    mov     edi, [esp+0D0h+var_98]
    xor     ebp, ebp

    loc_424E15:                             ; CODE XREF: sub_424C00+117j
    push    edi
    call    sub_4B4F20
    add     esp, 4
    jmp     loc_424ECD
    ; ---------------------------------------------------------------------------

    loc_424E23:                             ; CODE XREF: sub_424C00+46j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+0D0h+var_B0]
    mov     esi, [esp+0D0h+var_AC]
    mov     [esp+0D0h+var_C0], ebp
    mov     eax, [eax+14253h]
    cmp     ecx, ebp
    jnz     short loc_424E42
    xor     edx, edx
    jmp     short loc_424E48
    ; ---------------------------------------------------------------------------

    loc_424E42:                             ; CODE XREF: sub_424C00+23Cj
    mov     edx, esi
    sub     edx, ecx
    sar     edx, 1

    loc_424E48:                             ; CODE XREF: sub_424C00+240j
    cmp     edx, eax
    jnb     short loc_424E6E
    cmp     ecx, ebp
    jnz     short loc_424E54
    xor     edx, edx
    jmp     short loc_424E5A
    ; ---------------------------------------------------------------------------

    loc_424E54:                             ; CODE XREF: sub_424C00+24Ej
    mov     edx, esi
    sub     edx, ecx
    sar     edx, 1

    loc_424E5A:                             ; CODE XREF: sub_424C00+252j
    lea     ecx, [esp+0D0h+var_C0]
    sub     eax, edx
    push    ecx
    push    eax
    push    esi
    lea     ecx, [esp+0DCh+var_B4]
    call    sub_425210
    jmp     short loc_424EA0
    ; ---------------------------------------------------------------------------

    loc_424E6E:                             ; CODE XREF: sub_424C00+24Aj
    cmp     ecx, ebp
    jnz     short loc_424E76
    xor     edx, edx
    jmp     short loc_424E7C
    ; ---------------------------------------------------------------------------

    loc_424E76:                             ; CODE XREF: sub_424C00+270j
    mov     edx, esi
    sub     edx, ecx
    sar     edx, 1

    loc_424E7C:                             ; CODE XREF: sub_424C00+274j
    cmp     eax, edx
    jnb     short loc_424EA4
    lea     edx, [ecx+eax*2]
    push    edx
    push    esi
    push    esi
    call    sub_4256A0
    mov     esi, eax
    lea     ecx, [esp+0D0h+var_B4]
    mov     eax, [esp+0D0h+var_AC]
    push    eax
    push    esi
    call    nullsub_6
    mov     [esp+0D0h+var_AC], esi

    loc_424EA0:                             ; CODE XREF: sub_424C00+26Cj
    mov     ecx, [esp+0D0h+var_B0]

    loc_424EA4:                             ; CODE XREF: sub_424C00+27Ej
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    cmp     [edx+14253h], ebp
    jle     short loc_424ECD
    jmp     short loc_424EBA
    ; ---------------------------------------------------------------------------

    loc_424EB6:                             ; CODE XREF: sub_424C00+2CBj
    mov     ecx, [esp+0D0h+var_B0]

    loc_424EBA:                             ; CODE XREF: sub_424C00+2B4j
    mov     [ecx+eax*2], ax
    mov     ecx, TAdynmemStructPtr
    inc     eax
    cmp     eax, [ecx+14253h]
    jl      short loc_424EB6

    loc_424ECD:                             ; CODE XREF: sub_424C00+21Ej
                                            ; sub_424C00+2B2j
    call    sub_422EA0
    mov     ecx, dword_511FB4
    mov     edi, [ecx+4]
    mov     eax, [ecx+8]
    cmp     edi, eax
    jnb     short loc_424F08

    loc_424EE2:                             ; CODE XREF: sub_424C00+306j
    mov     esi, [edi]
    cmp     esi, ebp
    jz      short loc_424EFE
    mov     ecx, esi
    call    sub_4C2EB0
    push    esi
    call    sub_4B4F20
    mov     ecx, dword_511FB4
    add     esp, 4

    loc_424EFE:                             ; CODE XREF: sub_424C00+2E6j
    mov     eax, [ecx+8]
    add     edi, 4
    cmp     edi, eax
    jb      short loc_424EE2

    loc_424F08:                             ; CODE XREF: sub_424C00+2E0j
    xor     ebp, ebp
    mov     ebx, ecx
    cmp     ecx, ebp
    jz      short loc_424F3E
    mov     edx, [ecx+8]
    mov     eax, [ecx+4]
    lea     edi, [ecx+8]
    lea     esi, [ecx+4]
    push    edx
    push    eax
    call    nullsub_5
    mov     eax, [esi]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi], ebp
    mov     [edi], ebp
    mov     [ebx+0Ch], ebp
    push    ebx
    call    sub_4B4F20
    add     esp, 4

    loc_424F3E:                             ; CODE XREF: sub_424C00+30Ej
                                            ; DATA XREF: .data:00503EC8o
    mov     dword_511FB4, ebp
    push    ebp                             ; int
    mov     ebp, [esp+0D4h+arg_0]
    push    offset aNumberOfNormal          ; char *
    mov     ecx, ebp
    call    sub_4B4800
    push    offset aNormalFeatures          ; "Normal Features"
    mov     ecx, ebp
    mov     esi, eax
    call    sub_4B4BA0
    test    esi, esi
    jle     short loc_424FD3
    xor     edi, edi
    mov     ebx, esi

    loc_424F6E:                             ; CODE XREF: sub_424C00+3D1j
    push    edi
    mov     ecx, ebp
    call    sub_4B4C10
    lea     ecx, [esp+0D0h+var_C0]
    push    8
    push    ecx
    mov     ecx, ebp
    call    sub_4B4C80
    cmp     eax, 8
    jb      short loc_424FCD
    mov     edx, [esp+0D0h+var_C0+2]
    mov     eax, [esp+0D0h+var_C0]
    and     edx, 0FFFFh
    and     eax, 0FFFFh
    push    edx
    push    eax
    call    sub_481550
    mov     esi, eax
    push    0Ah
    mov     ecx, [esp+0D4h+var_BC]
    mov     edx, [esp+0D4h+var_B0]
    and     ecx, 0FFFFh
    push    0
    push    0
    mov     ax, [edx+ecx*2]
    push    eax
    push    esi
    call    sub_423C50
    mov     cx, word ptr [esp+0D0h+var_BC+2]
    mov     [esi+0Ah], cx

    loc_424FCD:                             ; CODE XREF: sub_424C00+387j
    add     edi, 8
    dec     ebx
    jnz     short loc_424F6E

    loc_424FD3:                             ; CODE XREF: sub_424C00+368j
    push    0                               ; int
    push    offset aNumberOfAnimat          ; char *
    mov     ecx, ebp
    call    sub_4B4800
    push    offset aAnimatingFeatu          ; "Animating Features"
    mov     ecx, ebp
    mov     esi, eax
    call    sub_4B4BA0
    test    esi, esi
    jle     loc_425101
    xor     edi, edi
    mov     ebx, esi

    loc_424FFB:                             ; CODE XREF: sub_424C00+4FBj
    push    edi
    mov     ecx, ebp
    call    sub_4B4C10
    lea     edx, [esp+0D0h+var_C0]
    push    0Ah
    push    edx
    mov     ecx, ebp
    call    sub_4B4C80
    cmp     eax, 0Ah
    jb      loc_4250F7
    mov     eax, [esp+0D0h+var_C0+2]
    mov     ecx, [esp+0D0h+var_C0]
    and     eax, 0FFFFh
    and     ecx, 0FFFFh
    push    eax
    push    ecx
    call    sub_481550
    mov     esi, eax
    push    0Ah
    mov     edx, [esp+0D4h+var_BC]
    mov     eax, [esp+0D4h+var_B0]
    and     edx, 0FFFFh
    push    0
    push    0
    mov     cx, [eax+edx*2]
    push    ecx
    push    esi
    call    sub_423C50
    mov     al, [esp+0D0h+var_B7]
    and     eax, 0Fh
    sub     eax, 0
    jz      short loc_4250A4
    dec     eax
    jz      short loc_425085
    dec     eax
    jnz     short loc_4250C0
    mov     edx, [esp+0D0h+var_C0+2]
    mov     eax, [esp+0D0h+var_C0]
    and     edx, 0FFFFh
    push    1
    and     eax, 0FFFFh
    push    edx
    push    eax
    call    sub_423550
    jmp     short loc_4250C0
    ; ---------------------------------------------------------------------------

    loc_425085:                             ; CODE XREF: sub_424C00+462j
    mov     ecx, [esp+0D0h+var_C0+2]
    mov     edx, [esp+0D0h+var_C0]
    and     ecx, 0FFFFh
    push    0
    and     edx, 0FFFFh
    push    ecx
    push    edx
    call    sub_423550
    jmp     short loc_4250C0
    ; ---------------------------------------------------------------------------

    loc_4250A4:                             ; CODE XREF: sub_424C00+45Fj
    mov     eax, [esp+0D0h+var_C0+2]
    mov     ecx, [esp+0D0h+var_C0]
    and     eax, 0FFFFh
    push    0
    and     ecx, 0FFFFh
    push    eax
    push    ecx
    call    sub_4233A0

    loc_4250C0:                             ; CODE XREF: sub_424C00+465j
                                            ; sub_424C00+483j ...
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     ax, [esi+0Ah]
    mov     cx, word ptr [esp+0D0h+var_BC+2]
    mov     esi, [edx+1420Bh]
    lea     eax, [eax+eax*2]
    shl     eax, 4
    add     eax, esi
    mov     [eax+26h], cx
    movzx   dx, [esp+0D0h+var_B8]
    mov     [eax+4], dx
    mov     cl, [esp+0D0h+var_B7]
    and     cl, 0F0h
    mov     [eax+2Eh], cl

    loc_4250F7:                             ; CODE XREF: sub_424C00+414j
    add     edi, 0Ah
    dec     ebx
    jnz     loc_424FFB

    loc_425101:                             ; CODE XREF: sub_424C00+3F1j
    push    0                               ; int
    push    offset aNumberOf3dFeat          ; char *
    mov     ecx, ebp
    call    sub_4B4800
    push    offset a3dFeatures              ; "3D Features"
    mov     ecx, ebp
    mov     esi, eax
    call    sub_4B4BA0
    test    esi, esi
    jle     loc_4251B1
    xor     edi, edi
    mov     ebx, esi

    loc_425129:                             ; CODE XREF: sub_424C00+5ABj
    push    edi
    mov     ecx, ebp
    call    sub_4B4C10
    lea     edx, [esp+0D0h+var_9C]
    push    1Ah
    push    edx
    mov     ecx, ebp
    call    sub_4B4C80
    cmp     eax, 1Ah
    jb      short loc_4251A7
    mov     eax, [esp+0D0h+var_9C+2]
    mov     ecx, [esp+0D0h+var_9C]
    and     eax, 0FFFFh
    and     ecx, 0FFFFh
    push    eax
    push    ecx
    call    sub_481550
    lea     edx, [esp+0D0h+var_88]
    push    0Ah
    mov     ecx, [esp+0D4h+var_98]
    mov     esi, eax
    push    edx
    mov     edx, [esp+0D8h+var_B0]
    lea     eax, [esp+0D8h+var_94]
    and     ecx, 0FFFFh
    push    eax
    mov     ax, [edx+ecx*2]
    push    eax
    push    esi
    call    sub_423C50
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     ax, [esi+0Ah]
    lea     ecx, [eax+eax*2]
    mov     eax, [edx+1420Bh]
    mov     dx, word ptr [esp+0D0h+var_98+2]
    shl     ecx, 4
    mov     [eax+ecx+26h], dx

    loc_4251A7:                             ; CODE XREF: sub_424C00+542j
    add     edi, 1Ah
    dec     ebx
    jnz     loc_425129

    loc_4251B1:                             ; CODE XREF: sub_424C00+51Fj
    mov     eax, [esp+0D0h+var_B0]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0C0h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4251CB:                             ; CODE XREF: sub_424C00+17Ej
    mov     eax, [esp+0D0h+var_B0]
    mov     [eax+ebp*2], si
    jmp     loc_424DEE
    sub_424C00 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_5. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4251F0 proc near                    ; CODE XREF: sub_424C00+A2p
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_4251FA
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_4251FA:                             ; CODE XREF: sub_4251F0+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 1
    retn
    sub_4251F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_425210 proc near                    ; CODE XREF: sub_424C00+97p
                                            ; sub_424C00+267p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ebp, [esp+10h+arg_4]
    mov     ecx, [ebx+8]
    mov     eax, [ebx+0Ch]
    sub     eax, ecx
    push    esi
    sar     eax, 1
    cmp     eax, ebp
    push    edi
    mov     [esp+18h+var_8], ebx
    jnb     loc_42534C
    mov     edx, [ebx+4]
    test    edx, edx
    jnz     short loc_42523E
    xor     eax, eax
    jmp     short loc_425244
    ; ---------------------------------------------------------------------------

    loc_42523E:                             ; CODE XREF: sub_425210+28j
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 1

    loc_425244:                             ; CODE XREF: sub_425210+2Cj
    cmp     ebp, eax
    jnb     short loc_425258
    test    edx, edx
    jnz     short loc_425250
    xor     eax, eax
    jmp     short loc_42525A
    ; ---------------------------------------------------------------------------

    loc_425250:                             ; CODE XREF: sub_425210+3Aj
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 1
    jmp     short loc_42525A
    ; ---------------------------------------------------------------------------

    loc_425258:                             ; CODE XREF: sub_425210+36j
    mov     eax, ebp

    loc_42525A:                             ; CODE XREF: sub_425210+3Ej
                                            ; sub_425210+46j
    test    edx, edx
    jnz     short loc_425262
    xor     ecx, ecx
    jmp     short loc_425266
    ; ---------------------------------------------------------------------------

    loc_425262:                             ; CODE XREF: sub_425210+4Cj
    sub     ecx, edx
    sar     ecx, 1

    loc_425266:                             ; CODE XREF: sub_425210+50j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_425272
    xor     eax, eax

    loc_425272:                             ; CODE XREF: sub_425210+5Ej
    lea     ecx, [eax+eax]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebx+4]
    mov     ebx, [esp+1Ch+arg_0]
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_4252A3

    loc_42528F:                             ; CODE XREF: sub_425210+91j
    test    edx, edx
    jz      short loc_425299
    mov     cx, [eax]
    mov     [edx], cx

    loc_425299:                             ; CODE XREF: sub_425210+81j
    add     eax, 2
    add     edx, 2
    cmp     eax, ebx
    jnz     short loc_42528F

    loc_4252A3:                             ; CODE XREF: sub_425210+7Dj
    test    ebp, ebp
    mov     eax, edx
    jbe     short loc_4252BF
    mov     esi, [esp+18h+arg_8]
    mov     ecx, ebp

    loc_4252AF:                             ; CODE XREF: sub_425210+ADj
    test    eax, eax
    jz      short loc_4252B9
    mov     di, [esi]
    mov     [eax], di

    loc_4252B9:                             ; CODE XREF: sub_425210+A1j
    add     eax, 2
    dec     ecx
    jnz     short loc_4252AF

    loc_4252BF:                             ; CODE XREF: sub_425210+97j
    mov     eax, [esp+18h+var_8]
    lea     edi, [ebp+ebp+0]
    mov     esi, [eax+8]
    lea     ecx, [edx+edi]
    cmp     ebx, esi
    jz      short loc_4252EC
    lea     eax, [ebx+ecx]
    sub     eax, edx
    sub     eax, edi

    loc_4252D8:                             ; CODE XREF: sub_425210+DAj
    test    ecx, ecx
    jz      short loc_4252E2
    mov     dx, [eax]
    mov     [ecx], dx

    loc_4252E2:                             ; CODE XREF: sub_425210+CAj
    add     eax, 2
    add     ecx, 2
    cmp     eax, esi
    jnz     short loc_4252D8

    loc_4252EC:                             ; CODE XREF: sub_425210+BFj
    mov     eax, [esp+18h+var_8]
    mov     eax, [eax+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     esi, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+var_4]
    mov     edx, [esp+1Ch+var_8]
    add     esp, 4
    lea     eax, [esi+ecx*2]
    mov     ecx, [edx+4]
    mov     [edx+0Ch], eax
    test    ecx, ecx
    jnz     short loc_425330
    xor     eax, eax
    mov     [edx+4], esi
    add     ebp, eax
    lea     ecx, [esi+ebp*2]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_425330:                             ; CODE XREF: sub_425210+107j
    mov     eax, [edx+8]
    mov     [edx+4], esi
    sub     eax, ecx
    sar     eax, 1
    add     ebp, eax
    lea     ecx, [esi+ebp*2]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_42534C:                             ; CODE XREF: sub_425210+1Dj
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, esi
    sar     edx, 1
    cmp     edx, ebp
    jnb     short loc_4253C7
    lea     edi, [ebp+ebp+0]
    cmp     esi, ecx
    lea     edx, [esi+edi]
    jz      short loc_425381
    mov     eax, edx
    sub     eax, edi

    loc_425369:                             ; CODE XREF: sub_425210+16Fj
    test    edx, edx
    jz      short loc_425377
    mov     bx, [eax]
    mov     [edx], bx
    mov     ebx, [esp+18h+var_8]

    loc_425377:                             ; CODE XREF: sub_425210+15Bj
    add     eax, 2
    add     edx, 2
    cmp     eax, ecx
    jnz     short loc_425369

    loc_425381:                             ; CODE XREF: sub_425210+153j
    mov     eax, [ebx+8]
    mov     edx, [esp+18h+arg_8]
    mov     ecx, eax
    sub     ecx, esi
    sar     ecx, 1
    sub     ebp, ecx
    mov     ecx, ebp
    jz      short loc_4253A4

    loc_425394:                             ; CODE XREF: sub_425210+192j
    test    eax, eax
    jz      short loc_42539E
    mov     bp, [edx]
    mov     [eax], bp

    loc_42539E:                             ; CODE XREF: sub_425210+186j
    add     eax, 2
    dec     ecx
    jnz     short loc_425394

    loc_4253A4:                             ; CODE XREF: sub_425210+182j
    mov     ecx, [ebx+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_425423

    loc_4253AD:                             ; CODE XREF: sub_425210+1A8j
    mov     si, [edx]
    mov     [eax], si
    add     eax, 2
    cmp     eax, ecx
    jnz     short loc_4253AD
    add     [ebx+8], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4253C7:                             ; CODE XREF: sub_425210+148j
    test    ebp, ebp
    jbe     short loc_425426
    lea     edi, [ebp+ebp+0]
    mov     eax, ecx
    sub     eax, edi
    mov     edx, ecx
    cmp     eax, ecx
    jz      short loc_4253ED

    loc_4253D9:                             ; CODE XREF: sub_425210+1DBj
    test    edx, edx
    jz      short loc_4253E3
    mov     bp, [eax]
    mov     [edx], bp

    loc_4253E3:                             ; CODE XREF: sub_425210+1CBj
    add     eax, 2
    add     edx, 2
    cmp     eax, ecx
    jnz     short loc_4253D9

    loc_4253ED:                             ; CODE XREF: sub_425210+1C7j
    mov     ecx, [ebx+8]
    mov     eax, ecx
    sub     eax, edi
    cmp     esi, eax
    jz      short loc_425409

    loc_4253F8:                             ; CODE XREF: sub_425210+1F7j
    mov     dx, [eax-2]
    sub     eax, 2
    sub     ecx, 2
    cmp     eax, esi
    mov     [ecx], dx
    jnz     short loc_4253F8

    loc_425409:                             ; CODE XREF: sub_425210+1E6j
    lea     ecx, [esi+edi]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_425423
    mov     edx, [esp+18h+arg_8]

    loc_425416:                             ; CODE XREF: sub_425210+211j
    mov     si, [edx]
    mov     [eax], si
    add     eax, 2
    cmp     eax, ecx
    jnz     short loc_425416

    loc_425423:                             ; CODE XREF: sub_425210+19Bj
                                            ; sub_425210+200j
    add     [ebx+8], edi

    loc_425426:                             ; CODE XREF: sub_425210+1B9j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_425210 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_425430 proc near                    ; CODE XREF: sub_424C00+BCp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    mov     eax, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     esi, eax
    cmp     edx, edi
    jz      short loc_425455
    push    ebx

    loc_425444:                             ; CODE XREF: sub_425430+22j
    mov     bx, [edx]
    add     edx, 2
    mov     [esi], bx
    add     esi, 2
    cmp     edx, edi
    jnz     short loc_425444
    pop     ebx

    loc_425455:                             ; CODE XREF: sub_425430+11j
    mov     edx, [ecx+8]
    mov     [ecx+8], esi
    pop     edi
    mov     [esp+4+arg_0], edx
    pop     esi
    retn    8
    sub_425430 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_6. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_425480 proc near                    ; CODE XREF: sub_4222E0+A8p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    push    ebp
    mov     ebx, [esp+10h+arg_4]
    mov     ebp, ecx
    push    esi
    push    edi
    mov     ecx, [ebp+8]
    mov     eax, [ebp+0Ch]
    sub     eax, ecx
    mov     [esp+18h+var_8], ebp
    sar     eax, 2
    cmp     eax, ebx
    jnb     loc_4255B9
    mov     edx, [ebp+4]
    test    edx, edx
    jnz     short loc_4254AF
    xor     eax, eax
    jmp     short loc_4254B6
    ; ---------------------------------------------------------------------------

    loc_4254AF:                             ; CODE XREF: sub_425480+29j
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2

    loc_4254B6:                             ; CODE XREF: sub_425480+2Dj
    cmp     ebx, eax
    jnb     short loc_4254CB
    test    edx, edx
    jnz     short loc_4254C2
    xor     eax, eax
    jmp     short loc_4254CD
    ; ---------------------------------------------------------------------------

    loc_4254C2:                             ; CODE XREF: sub_425480+3Cj
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2
    jmp     short loc_4254CD
    ; ---------------------------------------------------------------------------

    loc_4254CB:                             ; CODE XREF: sub_425480+38j
    mov     eax, ebx

    loc_4254CD:                             ; CODE XREF: sub_425480+40j
                                            ; sub_425480+49j
    test    edx, edx
    jnz     short loc_4254D5
    xor     ecx, ecx
    jmp     short loc_4254DA
    ; ---------------------------------------------------------------------------

    loc_4254D5:                             ; CODE XREF: sub_425480+4Fj
    sub     ecx, edx
    sar     ecx, 2

    loc_4254DA:                             ; CODE XREF: sub_425480+53j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_4254E6
    xor     eax, eax

    loc_4254E6:                             ; CODE XREF: sub_425480+62j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+1Ch+arg_0]
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebp+4]
    add     esp, 4
    cmp     eax, ecx
    jz      short loc_425519

    loc_425507:                             ; CODE XREF: sub_425480+97j
    test    edx, edx
    jz      short loc_42550F
    mov     esi, [eax]
    mov     [edx], esi

    loc_42550F:                             ; CODE XREF: sub_425480+89j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_425507

    loc_425519:                             ; CODE XREF: sub_425480+85j
    test    ebx, ebx
    mov     eax, edx
    jbe     short loc_425537
    mov     edi, [esp+18h+arg_8]
    mov     esi, ebx

    loc_425525:                             ; CODE XREF: sub_425480+B5j
    test    eax, eax
    jz      short loc_425531
    mov     ebp, [edi]
    mov     [eax], ebp
    mov     ebp, [esp+18h+var_8]

    loc_425531:                             ; CODE XREF: sub_425480+A7j
    add     eax, 4
    dec     esi
    jnz     short loc_425525

    loc_425537:                             ; CODE XREF: sub_425480+9Dj
    mov     esi, [ebp+8]
    lea     edi, ds:0[ebx*4]
    cmp     ecx, esi
    lea     eax, [edx+edi]
    jz      short loc_425560
    sub     ecx, edx
    add     ecx, eax
    sub     ecx, edi

    loc_42554E:                             ; CODE XREF: sub_425480+DEj
    test    eax, eax
    jz      short loc_425556
    mov     edx, [ecx]
    mov     [eax], edx

    loc_425556:                             ; CODE XREF: sub_425480+D0j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, esi
    jnz     short loc_42554E

    loc_425560:                             ; CODE XREF: sub_425480+C6j
    mov     eax, [ebp+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     edx, [esp+1Ch+arg_4]
    mov     eax, [esp+1Ch+var_4]
    add     esp, 4
    lea     ecx, [edx+eax*4]
    mov     [ebp+0Ch], ecx
    mov     ecx, [ebp+4]
    test    ecx, ecx
    jnz     short loc_42559C
    xor     eax, eax
    mov     [ebp+4], edx
    add     ebx, eax
    lea     eax, [edx+ebx*4]
    mov     [ebp+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_42559C:                             ; CODE XREF: sub_425480+103j
    mov     eax, [ebp+8]
    mov     [ebp+4], edx
    sub     eax, ecx
    sar     eax, 2
    add     ebx, eax
    lea     eax, [edx+ebx*4]
    mov     [ebp+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4255B9:                             ; CODE XREF: sub_425480+1Ej
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, esi
    sar     edx, 2
    cmp     edx, ebx
    jnb     short loc_425633
    lea     edi, ds:0[ebx*4]
    cmp     esi, ecx
    lea     edx, [esi+edi]
    jz      short loc_4255F0
    mov     eax, edx
    sub     eax, edi

    loc_4255DA:                             ; CODE XREF: sub_425480+16Ej
    test    edx, edx
    jz      short loc_4255E6
    mov     ebp, [eax]
    mov     [edx], ebp
    mov     ebp, [esp+18h+var_8]

    loc_4255E6:                             ; CODE XREF: sub_425480+15Cj
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_4255DA

    loc_4255F0:                             ; CODE XREF: sub_425480+154j
    mov     eax, [ebp+8]
    mov     edx, [esp+18h+arg_8]
    mov     ecx, eax
    sub     ecx, esi
    sar     ecx, 2
    sub     ebx, ecx
    mov     ecx, ebx
    jz      short loc_425612

    loc_425604:                             ; CODE XREF: sub_425480+190j
    test    eax, eax
    jz      short loc_42560C
    mov     ebx, [edx]
    mov     [eax], ebx

    loc_42560C:                             ; CODE XREF: sub_425480+186j
    add     eax, 4
    dec     ecx
    jnz     short loc_425604

    loc_425612:                             ; CODE XREF: sub_425480+182j
    mov     ecx, [ebp+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_42568C

    loc_42561B:                             ; CODE XREF: sub_425480+1A4j
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_42561B
    add     [ebp+8], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_425633:                             ; CODE XREF: sub_425480+146j
    test    ebx, ebx
    jbe     short loc_42568F
    lea     edi, ds:0[ebx*4]
    mov     eax, ecx
    sub     eax, edi
    mov     edx, ecx
    cmp     eax, ecx
    jz      short loc_42565A

    loc_425648:                             ; CODE XREF: sub_425480+1D8j
    test    edx, edx
    jz      short loc_425650
    mov     ebx, [eax]
    mov     [edx], ebx

    loc_425650:                             ; CODE XREF: sub_425480+1CAj
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_425648

    loc_42565A:                             ; CODE XREF: sub_425480+1C6j
    mov     ecx, [ebp+8]
    mov     eax, ecx
    sub     eax, edi
    cmp     esi, eax
    jz      short loc_425674

    loc_425665:                             ; CODE XREF: sub_425480+1F2j
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, esi
    mov     [ecx], edx
    jnz     short loc_425665

    loc_425674:                             ; CODE XREF: sub_425480+1E3j
    lea     ecx, [esi+edi]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_42568C
    mov     edx, [esp+18h+arg_8]

    loc_425681:                             ; CODE XREF: sub_425480+20Aj
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_425681

    loc_42568C:                             ; CODE XREF: sub_425480+199j
                                            ; sub_425480+1FBj
    add     [ebp+8], edi

    loc_42568F:                             ; CODE XREF: sub_425480+1B5j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_425480 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4256A0 proc near                    ; CODE XREF: sub_424C00+286p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_4256C5
    mov     eax, [esp+arg_8]
    push    esi

    loc_4256B1:                             ; CODE XREF: sub_4256A0+1Fj
    mov     si, [ecx]
    add     ecx, 2
    mov     [eax], si
    add     eax, 2
    cmp     ecx, edx
    jnz     short loc_4256B1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4256C5:                             ; CODE XREF: sub_4256A0+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_4256A0 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 100h
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_425721
    mov     eax, [esp+108h]
    mov     ecx, [esp+104h]
    push    eax
    push    ecx
    lea     edx, [esp+8]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    edx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+0]
    add     ecx, 519h
    push    1
    push    1
    push    1F4h
    push    eax
    push    ecx
    call    sub_4ABD90

    loc_425721:                             ; CODE XREF: .text:004256DDj
    add     esp, 100h
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_425730(char *)
    sub_425730 proc near                    ; CODE XREF: .text:00443255p
                                            ; sub_4437C0+4CDp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    0F9h                            ; size_t
    push    eax                             ; char *
    push    offset byte_511FB8              ; char *
    call    _strncpy
    add     esp, 0Ch
    retn    4
    sub_425730 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    edi
    mov     edi, offset byte_511FB8
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_425790
    push    1
    push    1
    push    offset byte_511FB8
    call    sub_4A5030
    add     eax, 14h
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    offset byte_511FB8
    push    eax
    call    sub_4ABD90
    mov     byte_511FB8, 0

    loc_425790:                             ; CODE XREF: .text:00425760j
    pop     edi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4257A0 proc near                    ; CODE XREF: sub_41EC50+1Bp
                                            ; sub_41F0A0+5p ...
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    push    0
    push    0
    call    sub_4C6890
    jmp     sub_4C63A0
    sub_4257A0 endp

    ; ---------------------------------------------------------------------------
    align 4
    call    sub_4C1AB0
    test    eax, eax
    jz      short locret_4257D2

    loc_4257C9:                             ; CODE XREF: .text:004257D0j
    call    sub_4C1AB0
    test    eax, eax
    jnz     short loc_4257C9

    locret_4257D2:                          ; CODE XREF: .text:004257C7j
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4257E0 proc near                    ; CODE XREF: .text:00443276p

    var_100= dword ptr -100h
    arg_0= byte ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 100h
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_425831
    mov     eax, [esp+100h+arg_8]
    mov     ecx, [esp+100h+arg_4]
    push    eax
    push    ecx
    lea     edx, [esp+108h+var_100]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    edx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+100h+var_100]
    add     ecx, 519h
    push    1
    push    1
    push    1F4h
    push    eax
    push    ecx
    call    sub_4ABD90

    loc_425831:                             ; CODE XREF: sub_4257E0+Dj
    mov     edx, TAdynmemStructPtr
    mov     al, [esp+100h+arg_0]
    mov     [edx+2BBFh], al
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2BC0h], al
    add     esp, 100h
    retn    0Ch
    sub_4257E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_425860 proc near                    ; CODE XREF: sub_41EC50+204p
                                            ; sub_41EC50+3D0p ...

    var_100= dword ptr -100h
    arg_0= byte ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 100h
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_4258B1
    mov     eax, [esp+100h+arg_8]
    mov     ecx, [esp+100h+arg_4]
    push    eax
    push    ecx
    lea     edx, [esp+108h+var_100]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    edx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+100h+var_100]
    add     ecx, 519h
    push    1
    push    1
    push    1F4h
    push    eax
    push    ecx
    call    sub_4ABD90

    loc_4258B1:                             ; CODE XREF: sub_425860+Dj
    mov     eax, TAdynmemStructPtr
    mov     dl, [esp+100h+arg_0]
    mov     [eax+2BBEh], dl
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_425906
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    9Bh
    lea     ecx, [esp+108h+var_100]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+100h+var_100]
    add     eax, 519h
    push    1
    push    1
    push    1F4h
    push    edx
    push    eax
    call    sub_4ABD90

    loc_425906:                             ; CODE XREF: sub_425860+6Aj
    mov     ecx, TAdynmemStructPtr
    xor     al, al
    mov     [ecx+2BBFh], al
    mov     edx, TAdynmemStructPtr
    mov     [edx+2BC0h], al
    add     esp, 100h
    retn    0Ch
    sub_425860 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    sub     esp, 100h
    mov     cl, [eax+2BBFh]
    push    ebx
    mov     bl, [eax+2BC0h]
    cmp     bl, cl
    jz      short loc_4259A8
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_425991
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    0A3h
    lea     eax, [esp+0Ch]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+4]
    add     edx, 519h
    push    1
    push    1
    push    1F4h
    push    ecx
    push    edx
    call    sub_4ABD90

    loc_425991:                             ; CODE XREF: .text:00425953j
    mov     eax, TAdynmemStructPtr
    mov     [eax+2BBFh], bl
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2BC0h], bl

    loc_4259A8:                             ; CODE XREF: .text:0042594Aj
    pop     ebx
    add     esp, 100h
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4259B0 proc near                    ; CODE XREF: sub_491200+157p

    var_100= dword ptr -100h

    sub     esp, 100h
    push    ebx
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_4259FC
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    0A9h
    lea     eax, [esp+10Ch+var_100]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+104h+var_100]
    add     edx, 519h
    push    1
    push    1
    push    1F4h
    push    ecx
    push    edx
    call    sub_4ABD90

    loc_4259FC:                             ; CODE XREF: sub_4259B0+Ej
    mov     eax, TAdynmemStructPtr
    xor     bl, bl
    mov     [eax+2BBEh], bl
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_425A4C
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    9Bh
    lea     ecx, [esp+10Ch+var_100]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+104h+var_100]
    add     eax, 519h
    push    1
    push    1
    push    1F4h
    push    edx
    push    eax
    call    sub_4ABD90

    loc_425A4C:                             ; CODE XREF: sub_4259B0+60j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2BBFh], bl
    mov     edx, TAdynmemStructPtr
    mov     [edx+2BC0h], bl
    mov     eax, TAdynmemStructPtr
    mov     [eax+2BF0h], bl
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+2AAFh], 0FFFEh
    mov     byte_511FB8, bl
    pop     ebx
    add     esp, 100h
    retn
    sub_4259B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_425A90 proc near                    ; CODE XREF: sub_41EC50+373p
                                            ; .text:00496B10p

    var_100= dword ptr -100h

    sub     esp, 100h
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_425ADB
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    0B2h
    lea     eax, [esp+108h+var_100]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+100h+var_100]
    add     edx, 519h
    push    1
    push    1
    push    1F4h
    push    ecx
    push    edx
    call    sub_4ABD90

    loc_425ADB:                             ; CODE XREF: sub_425A90+Dj
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2BBEh], 2
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_425B2A
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    9Bh
    lea     ecx, [esp+108h+var_100]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+100h+var_100]
    add     eax, 519h
    push    1
    push    1
    push    1F4h
    push    edx
    push    eax
    call    sub_4ABD90

    loc_425B2A:                             ; CODE XREF: sub_425A90+5Ej
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    push    eax
    push    eax
    mov     [ecx+2BBFh], al
    mov     edx, TAdynmemStructPtr
    push    eax
    push    eax
    mov     [edx+2BC0h], al
    call    sub_4288D0
    add     esp, 100h
    retn
    sub_425A90 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    call    sub_4C2470
    call    sub_4C2870
    jmp     sub_4C63A0
    ; ---------------------------------------------------------------------------

    loc_425B80:                             ; DATA XREF: .text:00426440o
    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    xor     ebx, ebx
    mov     eax, [eax+531h]
    mov     ecx, [eax+24h]
    cmp     ecx, ebx
    jz      loc_425D6E
    push    edi
    push    esi
    push    ebp
    mov     ebp, [ecx+0Ch]
    mov     ecx, [eax+4]
    mov     esi, dword_512298
    mov     dword ptr [esp+10h], 64h
    mov     edx, [ecx+0BCh]
    mov     edi, [edx+0Ch]

    loc_425BBA:                             ; CODE XREF: .text:00425D53j
    cmp     [esi+4], bl
    jz      loc_425CBF
    mov     eax, [esi+9]
    mov     cl, [ebp+eax+0]
    mov     [edi+eax], cl
    movsx   dx, byte ptr [esi+6]
    movsx   ax, byte ptr [esi+5]
    add     [esi+2], dx
    add     [esi], ax
    cmp     [esi], bx
    jl      loc_425CB7
    cmp     word ptr [esi], 280h
    jge     loc_425CB7
    mov     ax, [esi+2]
    cmp     ax, 1E0h
    jge     loc_425CB7
    cmp     ax, bx
    jl      loc_425CB7
    mov     al, [esi+7]
    cmp     al, bl
    jz      loc_425CB7
    movsx   ecx, byte ptr [esi+5]
    mov     edx, [esi+9]
    dec     al
    mov     [esi+7], al
    mov     al, [esi+6]
    add     edx, ecx
    cmp     al, bl
    mov     [esi+9], edx
    jz      short loc_425C3D
    movsx   eax, al
    lea     edx, [eax+eax*4]
    mov     eax, [esi+9]
    shl     edx, 7
    add     eax, edx
    mov     [esi+9], eax

    loc_425C3D:                             ; CODE XREF: .text:00425C2Aj
    mov     eax, [esi+9]
    add     eax, edi
    mov     cl, [eax]
    and     cl, 0Fh
    cmp     cl, 0Dh
    jnb     short loc_425C54
    mov     [esi+4], bl
    jmp     loc_425D47
    ; ---------------------------------------------------------------------------

    loc_425C54:                             ; CODE XREF: .text:00425C4Aj
    mov     byte ptr [eax], 0AAh
    mov     al, [esi+8]
    cmp     al, bl
    jnz     short loc_425CAD
    cmp     [esi+6], bl
    jz      short loc_425C89
    mov     dl, [esi]
    mov     [esi+6], bl
    and     dl, 1
    neg     dl
    sbb     dl, dl
    and     dl, 0FAh
    add     dl, 3
    mov     [esi+5], dl
    call    _rand
    and     al, 0Fh
    inc     al
    mov     [esi+8], al
    jmp     loc_425D47
    ; ---------------------------------------------------------------------------

    loc_425C89:                             ; CODE XREF: .text:00425C61j
    mov     al, [esi+2]
    and     al, 1
    neg     al
    sbb     al, al
    and     al, 6
    add     al, 0FDh
    mov     [esi+6], al
    mov     [esi+5], bl
    call    _rand
    and     al, 0Fh
    inc     al
    mov     [esi+8], al
    jmp     loc_425D47
    ; ---------------------------------------------------------------------------

    loc_425CAD:                             ; CODE XREF: .text:00425C5Cj
    dec     al
    mov     [esi+8], al
    jmp     loc_425D47
    ; ---------------------------------------------------------------------------

    loc_425CB7:                             ; CODE XREF: .text:00425BE1j
                                            ; .text:00425BECj ...
    mov     [esi+4], bl
    jmp     loc_425D47
    ; ---------------------------------------------------------------------------

    loc_425CBF:                             ; CODE XREF: .text:00425BBDj
    call    _rand
    cdq
    mov     ecx, 280h
    idiv    ecx
    mov     [esi], dx
    call    _rand
    cdq
    mov     ecx, 0DCh
    idiv    ecx
    movsx   eax, dx
    mov     [esi+2], dx
    lea     edx, [eax+eax*4]
    movsx   eax, word ptr [esi]
    shl     edx, 7
    add     eax, edx
    mov     [esi+9], eax
    mov     cl, [edi+eax]
    and     cl, 0Fh
    cmp     cl, 0Ch
    jbe     short loc_425D47
    mov     byte ptr [esi+4], 1
    call    _rand
    inc     al
    mov     [esi+7], al
    call    _rand
    and     al, 1Fh
    inc     al
    mov     [esi+8], al
    mov     al, [esi+7]
    test    al, 1
    jz      short loc_425D35
    test    byte ptr [esi+2], 1
    jz      short loc_425D2C
    mov     byte ptr [esi+6], 0FDh
    mov     [esi+5], bl
    jmp     short loc_425D47
    ; ---------------------------------------------------------------------------

    loc_425D2C:                             ; CODE XREF: .text:00425D21j
    mov     byte ptr [esi+6], 3
    mov     [esi+5], bl
    jmp     short loc_425D47
    ; ---------------------------------------------------------------------------

    loc_425D35:                             ; CODE XREF: .text:00425D1Bj
    test    byte ptr [esi], 1
    jz      short loc_425D40
    mov     byte ptr [esi+5], 0FDh
    jmp     short loc_425D44
    ; ---------------------------------------------------------------------------

    loc_425D40:                             ; CODE XREF: .text:00425D38j
    mov     byte ptr [esi+5], 3

    loc_425D44:                             ; CODE XREF: .text:00425D3Ej
    mov     [esi+6], bl

    loc_425D47:                             ; CODE XREF: .text:00425C4Fj
                                            ; .text:00425C84j ...
    mov     eax, [esp+10h]
    add     esi, 0Dh
    dec     eax
    mov     [esp+10h], eax
    jnz     loc_425BBA
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FAD0
    pop     ebp
    pop     esi
    pop     edi

    loc_425D6E:                             ; CODE XREF: .text:00425B94j
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_425D80 proc near                    ; DATA XREF: .text:00426432o

    var_10C= dword ptr -10Ch
    var_100= dword ptr -100h
    arg_0= dword ptr  4

    sub     esp, 10Ch
    push    esi
    mov     esi, [esp+110h+arg_0]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_425DAC
    mov     eax, dword_512298
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_425DAC:                             ; CODE XREF: sub_425D80+12j
    push    offset aSingle_0                ; "SINGLE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_425DE5
    push    0                               ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    push    14h
    call    sub_491C80
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2BC0h], 5
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_425DE5:                             ; CODE XREF: sub_425D80+39j
    push    offset aMulti                   ; "MULTI"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_425ECF
    push    0                               ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    push    14h
    call    sub_491C80
    call    sub_41D4C0
    push    offset aTdf                     ; "tdf"
    push    offset aMultiplay               ; "multiplay"
    lea     edx, [esp+118h+var_100]
    push    offset aMaps_0                  ; "maps"
    push    edx
    call    sub_4290F0
    lea     ecx, [esp+110h+var_10C]
    call    sub_4C2EA0
    lea     eax, [esp+110h+var_100]
    lea     ecx, [esp+110h+var_10C]
    push    eax
    call    sub_4C2F60
    test    eax, eax
    jz      short loc_425E84
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2BC0h], 6
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C69A0
    push    0
    push    0
    call    sub_4C6890
    call    sub_4C63A0
    lea     ecx, [esp+110h+var_10C]
    call    sub_4C2EB0
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_425E84:                             ; CODE XREF: sub_425D80+C2j
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_1          ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4AB0A0
    lea     ecx, [esp+110h+var_10C]
    call    sub_4C2EB0
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_425ECF:                             ; CODE XREF: sub_425D80+72j
    push    offset aIntro                   ; "INTRO"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_426065
    push    0                               ; int
    push    offset aSmlbutton_1             ; char *
    call    sub_47F1A0
    call    sub_4B6220
    test    byte ptr [eax+0F0h], 2
    jnz     short loc_425F0F
    push    1
    push    1
    push    0C8h
    push    offset aDebugYouMustBe          ; "Debug:  You must be in full-screen mode"...
    jmp     loc_426130
    ; ---------------------------------------------------------------------------

    loc_425F0F:                             ; CODE XREF: sub_425D80+17Aj
    push    0
    call    sub_41D6A0
    test    al, al
    jnz     short loc_425F65
    push    1
    call    sub_41D6A0
    test    al, al
    jnz     short loc_425F65
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsertAT          ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AB0A0
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_425F65:                             ; CODE XREF: sub_425D80+198j
                                            ; sub_425D80+1A3j
    push    14h
    call    sub_491C80
    push    10h                             ; nVirtKey
    call    ds:GetKeyState
    test    ax, ax
    jge     short loc_425F8B
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+39241h], 1
    jmp     short loc_425F9B
    ; ---------------------------------------------------------------------------

    loc_425F8B:                             ; CODE XREF: sub_425D80+1F7j
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+39241h], 0

    loc_425F9B:                             ; CODE XREF: sub_425D80+209j
    call    sub_4C1AB0
    test    eax, eax
    jz      short loc_425FAD

    loc_425FA4:                             ; CODE XREF: sub_425D80+22Bj
    call    sub_4C1AB0
    test    eax, eax
    jnz     short loc_425FA4

    loc_425FAD:                             ; CODE XREF: sub_425D80+222j
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_425FF2
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    244h
    lea     eax, [esp+118h+var_100]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+110h+var_100]
    add     edx, 519h
    push    1
    push    1
    push    1F4h
    push    ecx
    push    edx
    call    sub_4ABD90

    loc_425FF2:                             ; CODE XREF: sub_425D80+234j
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2BBEh], 1
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_426041
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    9Bh
    lea     ecx, [esp+118h+var_100]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    lea     edx, [esp+110h+var_100]
    add     eax, 519h
    push    1
    push    1
    push    1F4h
    push    edx
    push    eax
    call    sub_4ABD90

    loc_426041:                             ; CODE XREF: sub_425D80+285j
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2BBFh], 0
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2BC0h], 0
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_426065:                             ; CODE XREF: sub_425D80+15Cj
    push    offset aExit                    ; "EXIT"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_42609D
    push    0                               ; int
    push    offset aExit_0                  ; char *
    call    sub_47F1A0
    push    14h
    call    sub_491C80
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2BC0h], 8
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42609D:                             ; CODE XREF: sub_425D80+2F2j
    push    offset aCredits                 ; "Credits"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_42617A
    push    0                               ; int
    push    offset aSmlbutton_1             ; char *
    call    sub_47F1A0
    call    sub_4B6220
    test    byte ptr [eax+0F0h], 2
    jnz     short loc_426106
    mov     ecx, TAdynmemStructPtr
    push    1
    push    1
    push    0C8h
    add     ecx, 519h
    push    offset aDebugYouMustBe          ; "Debug:  You must be in full-screen mode"...
    push    ecx
    call    sub_4ABD90
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4AB0A0
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_426106:                             ; CODE XREF: sub_425D80+348j
    push    0
    call    sub_41D6A0
    test    al, al
    jnz     short loc_42615C
    push    1
    call    sub_41D6A0
    test    al, al
    jnz     short loc_42615C
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsertAT          ; int
    call    sub_4C5740
    push    eax

    loc_426130:                             ; CODE XREF: sub_425D80+18Aj
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4AB0A0
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42615C:                             ; CODE XREF: sub_425D80+38Fj
                                            ; sub_425D80+39Aj
    push    14h
    call    sub_491C80
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2BC0h], 9
    pop     esi
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42617A:                             ; CODE XREF: sub_425D80+32Aj
    push    esi
    call    sub_4AB0A0
    pop     esi
    add     esp, 10Ch
    retn    4
    sub_425D80 endp

    ; ---------------------------------------------------------------------------
    align 8

    loc_426190:                             ; DATA XREF: sub_426200+183o
    push    esi
    mov     esi, [esp+8]
    push    edi
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4261EF
    push    0
    push    offset aSmallbutton             ; "SmallButton"
    call    sub_47F1A0
    mov     ecx, [esi+60h]
    push    offset aChoice1                 ; "CHOICE1"
    push    ecx
    push    edi
    call    sub_4A0300
    test    eax, eax
    jz      short loc_4261D6
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CE190
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4261D6:                             ; CODE XREF: .text:004261C1j
    mov     eax, [esi+60h]
    push    offset aChoice2                 ; "CHOICE2"
    push    eax
    push    edi
    call    sub_4A0300
    test    eax, eax
    jnz     short loc_4261EF
    push    esi
    call    sub_4AB0A0

    loc_4261EF:                             ; CODE XREF: .text:004261A2j
                                            ; .text:004261E7j
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_426200 proc near                    ; CODE XREF: .text:00426679p

    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     eax, TAdynmemStructPtr
    sub     esp, 8
    add     eax, 519h
    push    ebp
    push    100h
    push    offset aYesorno_gui             ; "YESORNO.GUI"
    push    eax
    call    sub_4AA8F0
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_42639F
    mov     ecx, TAdynmemStructPtr
    push    edi
    push    esi
    push    ebx
    add     ecx, 519h
    push    1
    push    ecx
    call    sub_49FB10
    mov     ebx, [ebp+4]
    push    1
    push    offset aChoice1                 ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    push    1
    shl     ecx, 3
    sub     ecx, eax
    push    offset aChoice2                 ; char *
    push    ebx                             ; int
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebx
    add     ecx, eax
    lea     edx, [ecx+edx*2]
    mov     [esp+1Ch], edx
    call    sub_49FDF0
    mov     ecx, eax
    mov     edi, offset aChoice1            ; "CHOICE1"
    shl     ecx, 3
    sub     ecx, eax
    push    offset aYes                     ; int
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    lea     eax, [edx+ecx*2]
    or      ecx, 0FFFFFFFFh
    mov     [esp+18h], eax
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [ebx+0CCh]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [ebx+0DCh]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, offset aChoice2            ; "CHOICE2"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    call    sub_4C5740
    mov     edi, eax
    xor     eax, eax
    mov     ecx, [esp+10h]
    lea     edx, [ecx+0B6h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    offset aNo                      ; int
    and     ecx, 3
    rep movsb
    call    sub_4C5740
    mov     edi, eax
    xor     eax, eax
    mov     ecx, [esp+14h]
    push    0
    push    offset aCloseWindowsCd          ; int
    lea     edx, [ecx+0B6h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    offset aTitle                   ; "TITLE"
    push    ecx
    call    sub_4A0BF0
    mov     edx, TAdynmemStructPtr
    push    offset aChoice1                 ; "CHOICE1"
    add     edx, 519h
    push    edx
    call    sub_4A76B0
    mov     dword ptr [ebp+8], offset loc_426190
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    40h
    push    eax
    call    sub_4A81E0
    pop     ebx
    pop     esi
    pop     edi

    loc_42639F:                             ; CODE XREF: sub_426200+22j
    pop     ebp
    add     esp, 8
    retn
    sub_426200 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    sub     esp, 24Ch
    mov     ecx, [eax+531h]
    push    ebp
    push    esi
    push    edi
    test    ecx, ecx
    jz      short loc_4263E2

    loc_4263C8:                             ; CODE XREF: .text:004263E0j
    add     eax, 519h
    push    eax
    call    sub_4A9660
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    test    ecx, ecx
    jnz     short loc_4263C8

    loc_4263E2:                             ; CODE XREF: .text:004263C6j
    call    sub_4C2470
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    push    0
    push    0
    call    sub_4C6890
    call    sub_4C63A0
    call    sub_491A70
    mov     edx, TAdynmemStructPtr
    push    80h
    add     edx, 519h
    push    offset aMainmenu_gui            ; "MAINMENU.GUI"
    push    edx
    call    sub_4AA8F0
    push    0
    push    1
    push    1
    push    offset aFrontendx               ; "FrontendX"
    mov     dword ptr [eax+8], offset sub_425D80
    mov     dword ptr [eax+0Ch], 0
    mov     dword ptr [eax+1Ch], offset loc_425B80
    call    sub_4288D0
    push    0
    push    offset off_5031D4
    call    sub_47F210
    mov     eax, TAdynmemStructPtr
    push    4
    mov     ecx, [eax+10h]
    call    sub_4CE690
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA50
    mov     edx, offset aFrontendx          ; "FrontendX"
    test    edx, edx
    jz      short loc_4264CD
    xor     ebp, ebp
    mov     edi, offset dword_5120C0

    loc_426489:                             ; CODE XREF: .text:004264CBj
    mov     esi, offset aFrontendx          ; "FrontendX"
    mov     eax, edi

    loc_426490:                             ; CODE XREF: .text:004264AEj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4264B4
    test    cl, cl
    jz      short loc_4264B0
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4264B4
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_426490

    loc_4264B0:                             ; CODE XREF: .text:0042649Aj
    xor     eax, eax
    jmp     short loc_4264B9
    ; ---------------------------------------------------------------------------

    loc_4264B4:                             ; CODE XREF: .text:00426496j
                                            ; .text:004264A4j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4264B9:                             ; CODE XREF: .text:004264B2j
    test    eax, eax
    jz      loc_42676B
    add     edi, 28h
    inc     ebp
    cmp     edi, offset dword_512250
    jl      short loc_426489

    loc_4264CD:                             ; CODE XREF: .text:00426480j
    xor     edi, edi

    loc_4264CF:                             ; CODE XREF: .text:00426776j
    push    offset off_5031D0
    push    offset aGuipal                  ; "guipal"
    lea     ecx, [esp+34h]
    push    offset aPalettes                ; "palettes"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+2Ch]
    push    0
    push    edx
    call    sub_4BBE50
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    push    esi
    add     eax, 519h
    push    edi
    push    eax
    call    sub_4AC7D0
    push    esi
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    add     ecx, 519h
    push    0C0h
    push    ecx
    call    sub_4A81E0
    mov     edx, TAdynmemStructPtr
    mov     ebp, 1
    add     edx, 519h
    push    ebp
    push    edx
    call    sub_49FB10
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391F9h]
    push    ecx
    call    sub_4C1420
    mov     edi, offset aV3_1               ; "v3.1"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0Ch]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    ebp
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+30h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    push    offset aDebugstring             ; "DebugString"
    rep movsb
    lea     edi, [esp+14h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+2Ch]
    push    edx
    add     eax, 519h
    push    offset aDebugstring             ; "DebugString"
    push    eax
    call    sub_4A07D0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+531h]
    mov     esi, [edx+4]
    lea     eax, [esp+2Ch]
    push    eax
    call    sub_4A5030
    push    5
    push    offset aDebugstring             ; "DebugString"
    push    esi
    mov     edi, eax
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     eax, edi
    cdq
    sub     eax, edx
    lea     ecx, [esi+ecx*2+13h]
    sar     eax, 1
    neg     eax
    add     [ecx], ax
    call    sub_4C13F0
    push    eax
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [eax+0DDAh]
    push    edx
    call    sub_4C13A0
    call    sub_4C2870
    call    sub_4C2BB0
    push    514h
    push    offset aSparks                  ; "SPARKS"
    call    sub_4D83B0
    mov     edi, eax
    mov     ecx, 145h
    xor     eax, eax
    mov     dword_512298, edi
    rep stosd
    mov     eax, dword_51229C
    add     esp, 8
    test    eax, eax
    jnz     short loc_426684
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CE1D0
    test    eax, eax
    jz      short loc_426684
    call    sub_426200
    mov     dword_51229C, ebp

    loc_426684:                             ; CODE XREF: .text:00426665j
                                            ; .text:00426677j
    mov     eax, dword_51228C
    test    eax, eax
    jnz     short loc_42670A
    push    3
    push    9Bh
    push    0
    push    5
    push    4
    mov     dword_51228C, ebp
    call    sub_4B5070
    test    eax, eax
    jnz     short loc_42670A
    push    offset byte_50319C
    push    offset byte_50319C
    push    offset byte_50319C
    push    offset byte_50319C
    push    offset aWarningTheCurr          ; "Warning! The currently installed versio"...
    call    sub_4C5740
    push    eax
    lea     edx, [esp+140h]
    push    12Ch
    push    edx
    call    __snprintf
    add     esp, 1Ch
    test    eax, eax
    jge     short loc_4266E9
    mov     byte ptr [esp+257h], 0

    loc_4266E9:                             ; CODE XREF: .text:004266DFj
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    ebp
    lea     eax, [esp+134h]
    push    0C8h
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_4ABD90

    loc_42670A:                             ; CODE XREF: .text:0042668Bj
                                            ; .text:004266A7j
    mov     eax, dword_512294
    test    eax, eax
    jnz     short loc_42674D
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CFF20
    test    eax, eax
    jz      short loc_42674D
    push    ebp
    push    ebp
    push    1F4h
    push    offset aNoSoundDriverI          ; "No sound driver is available for use.\n"
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90
    mov     dword_512294, ebp

    loc_42674D:                             ; CODE XREF: .text:00426711j
                                            ; .text:00426723j
    mov     eax, dword_512290
    test    eax, eax
    jnz     short loc_426761
    call    sub_429000
    mov     dword_512290, ebp

    loc_426761:                             ; CODE XREF: .text:00426754j
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 24Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_42676B:                             ; CODE XREF: .text:004264BBj
    lea     eax, [ebp+ebp*4+0]
    mov     edi, dword_5120BC[eax*8]
    jmp     loc_4264CF
    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 100h
    call    sub_47F750
    mov     eax, [esp+104h]
    push    offset aZrb                     ; "zrb"
    push    eax
    lea     ecx, [esp+8]
    push    offset aData                    ; "Data"
    push    ecx
    call    sub_41D7B0
    lea     edx, [esp+0]
    push    edx
    call    sub_4BBC40
    test    eax, eax
    jz      loc_426898
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    push    0
    push    0
    call    sub_4C6890
    call    sub_4C63A0
    push    0
    call    sub_4C22D0

    loc_4267E0:                             ; CODE XREF: .text:0042685Aj
    push    5B8h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_42680F
    push    1
    push    1E8480h
    push    1
    push    927C0h
    lea     edx, [esp+14h]
    push    0
    push    edx
    mov     ecx, eax
    call    sub_47BDF0
    jmp     short loc_426811
    ; ---------------------------------------------------------------------------

    loc_42680F:                             ; CODE XREF: .text:004267EFj
    xor     eax, eax

    loc_426811:                             ; CODE XREF: .text:0042680Dj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38D7Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+38D7Bh]
    call    sub_47C6C0
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+38D7Bh]
    test    esi, esi
    jz      short loc_426852
    mov     ecx, esi
    call    sub_47BF20
    push    esi
    call    sub_4B4F20
    mov     eax, TAdynmemStructPtr
    add     esp, 4

    loc_426852:                             ; CODE XREF: .text:0042683Bj
    mov     ecx, [eax+39241h]
    test    ecx, ecx
    jnz     short loc_4267E0
    mov     dword ptr [eax+38D7Bh], 0
    call    sub_4C1AB0
    test    eax, eax
    jz      short loc_426878

    loc_42686F:                             ; CODE XREF: .text:00426876j
    call    sub_4C1AB0
    test    eax, eax
    jnz     short loc_42686F

    loc_426878:                             ; CODE XREF: .text:0042686Dj
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    push    0
    push    0
    call    sub_4C6890
    call    sub_4C63A0
    pop     esi

    loc_426898:                             ; CODE XREF: .text:004267B3j
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 280h
    lea     eax, [esp+80h]
    push    ebx
    push    esi
    push    edi
    push    eax
    call    sub_4BCEC0
    mov     edi, offset aWarp_ini           ; "\\Warp.ini"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+8Ch]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    lea     eax, [esp+0Ch]
    and     ecx, 3
    rep movsb
    mov     esi, [esp+290h]
    mov     edi, ds:wsprintfA
    push    esi
    push    offset aWarpDcampaign           ; "warp%dcampaign"
    push    eax
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     ecx, [esp+8Ch]
    lea     edx, [esp+18Ch]
    lea     eax, [esp+0Ch]
    push    ecx
    push    100h
    push    edx
    push    offset aDefault                 ; "default"
    push    eax
    push    offset aWarplevels              ; "WARPLEVELS"
    call    ds:GetPrivateProfileStringA
    push    esi
    lea     ecx, [esp+10h]
    push    offset aWarpDmission            ; "warp%dmission"
    push    ecx
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     edx, [esp+8Ch]
    lea     eax, [esp+0Ch]
    push    edx
    push    0
    push    eax
    push    offset aWarplevels              ; "WARPLEVELS"
    call    ds:GetPrivateProfileIntA
    push    1
    mov     esi, eax
    call    sub_434AB0
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+18Ch]
    push    ecx
    mov     ecx, [edx+391E9h]
    call    sub_435110
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+391E9h]
    call    sub_435C00
    test    eax, eax
    jz      short loc_4269B7
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2A44h], 8
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2A44h], 4

    loc_4269B7:                             ; CODE XREF: .text:0042699Dj
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 280h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 280h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4C1AB0
    lea     ebx, [eax-30h]
    cmp     ebx, 3Dh
    ja      loc_426BB6
    xor     ecx, ecx
    mov     cl, ds:byte_426CDC[ebx]
    jmp     ds:off_426CAC[ecx*4]

    loc_4269FA:                             ; DATA XREF: .text:00426CB0o
                                            ; .text:00426CC4o
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    add     ecx, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     byte ptr [ecx+95h], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 280h
    retn
    ; ---------------------------------------------------------------------------

    loc_426A2D:                             ; CODE XREF: .text:004269F3j
                                            ; DATA XREF: .text:00426CB4o ...
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    add     ecx, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     byte ptr [ecx+95h], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 280h
    retn
    ; ---------------------------------------------------------------------------

    loc_426A60:                             ; CODE XREF: .text:004269F3j
                                            ; DATA XREF: .text:00426CB8o ...
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37EEEh], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 280h
    retn
    ; ---------------------------------------------------------------------------

    loc_426A7B:                             ; CODE XREF: .text:004269F3j
                                            ; DATA XREF: .text:00426CC0o ...
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37EEEh], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 280h
    retn
    ; ---------------------------------------------------------------------------

    loc_426A95:                             ; CODE XREF: .text:004269F3j
                                            ; DATA XREF: .text:00426CBCo ...
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+37EEEh], 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 280h
    retn
    ; ---------------------------------------------------------------------------

    loc_426AB0:                             ; CODE XREF: .text:004269F3j
                                            ; DATA XREF: .text:00426CACo
    lea     edx, [esp+190h]
    push    edx
    call    sub_4BCEC0
    mov     edi, offset aWarp_ini           ; "\\Warp.ini"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+190h]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    ebx
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    lea     eax, [esp+14h]
    and     ecx, 3
    push    offset aWarpDcampaign           ; "warp%dcampaign"
    rep movsb
    mov     esi, ds:wsprintfA
    push    eax
    call    esi ; wsprintfA
    add     esp, 0Ch
    lea     ecx, [esp+190h]
    lea     edx, [esp+90h]
    lea     eax, [esp+10h]
    push    ecx
    push    100h
    push    edx
    push    offset aDefault                 ; "default"
    push    eax
    push    offset aWarplevels              ; "WARPLEVELS"
    call    ds:GetPrivateProfileStringA
    push    ebx
    lea     ecx, [esp+14h]
    push    offset aWarpDmission            ; "warp%dmission"
    push    ecx
    call    esi ; wsprintfA
    add     esp, 0Ch
    lea     edx, [esp+190h]
    lea     eax, [esp+10h]
    push    edx
    push    0
    push    eax
    push    offset aWarplevels              ; "WARPLEVELS"
    call    ds:GetPrivateProfileIntA
    push    1
    mov     esi, eax
    call    sub_434AB0
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+90h]
    push    ecx
    mov     ecx, [edx+391E9h]
    call    sub_435110
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+391E9h]
    call    sub_435C00
    test    eax, eax
    jz      loc_426CA0
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2A44h], 8
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2A44h], 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 280h
    retn
    ; ---------------------------------------------------------------------------

    loc_426BB6:                             ; CODE XREF: .text:004269E5j
                                            ; .text:004269F3j
                                            ; DATA XREF: ...
    xor     ebx, ebx
    cmp     eax, ebx
    jnz     short loc_426BDB
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+2C7Eh], ebx
    jnz     short loc_426BDB
    call    sub_4B6340
    cmp     dword_512288, eax
    jge     loc_426CA0

    loc_426BDB:                             ; CODE XREF: .text:00426BBAj
                                            ; .text:00426BC8j
    push    ebx
    push    offset aMainmenu_0              ; "MAINMENU"
    call    sub_47F1A0
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_426C31
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    3AAh
    lea     edx, [esp+98h]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    edx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+90h]
    add     ecx, 519h
    push    1
    push    1
    push    1F4h
    push    eax
    push    ecx
    call    sub_4ABD90

    loc_426C31:                             ; CODE XREF: .text:00426BEDj
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2BBEh], 2
    call    unknown_libname_7
    test    eax, eax
    jz      short loc_426C89
    push    offset aCCavedogWargam          ; "c:\\cavedog\\wargame\\frontend.cpp"
    push    9Bh
    lea     eax, [esp+98h]
    push    offset aCodeSegmentChe          ; "Code segment checksum error found when "...
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    lea     ecx, [esp+90h]
    add     edx, 519h
    push    1
    push    1
    push    1F4h
    push    ecx
    push    edx
    call    sub_4ABD90

    loc_426C89:                             ; CODE XREF: .text:00426C45j
    mov     eax, TAdynmemStructPtr
    mov     [eax+2BBFh], bl
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2BC0h], bl

    loc_426CA0:                             ; CODE XREF: .text:00426B8Dj
                                            ; .text:00426BD5j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 280h
    retn
    ; ---------------------------------------------------------------------------
    align 4
    off_426CAC dd offset loc_426AB0         ; DATA XREF: .text:004269F3r
    dd offset loc_4269FA
    dd offset loc_426A2D
    dd offset loc_426A60
    dd offset loc_426A95
    dd offset loc_426A7B
    dd offset loc_4269FA
    dd offset loc_426A2D
    dd offset loc_426A60
    dd offset loc_426A95
    dd offset loc_426A7B
    dd offset loc_426BB6
    byte_426CDC db 0                        ; DATA XREF: .text:004269EDr
    dd 2 dup(0), 0B0B0B00h, 0B0B0B0Bh, 0B020B01h, 40B0B03h, 0B0B0B0Bh, 0B0B0B05h
    dd 4 dup(0B0B0B0Bh), 0B070B06h, 90B0B08h, 0B0B0B0Bh, 9090900Ah, 81909090h
    dd 100ECh, 0A055E800h, 0C0850002h, 0E8A11874h, 8000511Dh, 2A4488h, 1B80100h
    dd 81000000h, 100C4h, 6853C300h, 0F9h, 50324C68h, 1FB86800h, 4E80051h
    dd 83000BDAh, 5CE80CC4h, 8500001Eh, 683C74C0h, 503004h, 3BC68h, 24448D00h
    dd 2F9C680Ch, 0E8500050h, 0BD52Fh, 1DE8158Bh, 0C4830051h, 244C8D10h, 19C28104h
    dd 6A000005h, 68016A01h, 1F4h, 0ECE85251h, 0A100084Fh, 511DE8h, 2BBE80C6h
    dd 0E80F0000h, 1E0Bh, 3A74C085h, 50300468h, 9B6800h, 4C8D0000h, 9C680C24h
    dd 5100502Fh, 0BD4DEE8h, 1DE8A100h, 0C4830051h, 24548D10h, 5190504h, 16A0000h
    dd 0F468016Ah, 52000001h, 4F9DE850h, 0D8B0008h, 511DE8h, 9988DB32h, 2BBFh
    dd 1DE8158Bh, 9A880051h, 2BC0h, 1DAEE8h, 74C08500h, 3004683Ch, 0BD680050h
    dd 8D000003h, 680C2444h, 502F9Ch, 0D481E850h, 158B000Bh, 511DE8h, 8D10C483h
    dd 8104244Ch, 519C2h, 6A016A00h, 1F46801h, 52510000h, 84F3EE8h, 1DE8A100h
    dd 98880051h, 2BBFh, 1DE80D8Bh, 0C0330051h, 2BC09988h, 815B0000h, 100C4h
    dd 9090C300h, 2 dup(90909090h), 0A1909090h, 511DE8h, 100EC81h, 888A0000h
    dd 2BBFh, 0C0988A53h, 5600002Bh, 7457D93Ah, 3004682Bh, 0A3680050h, 0E8000000h
    dd 0FFFFE823h, 511DE8A1h, 0BF988800h, 8B00002Bh, 511DE80Dh, 0C0998800h
    dd 0A100002Bh, 511DE8h, 888AC933h, 2BBEh, 0F14F983h, 16B587h, 8D24FF00h
    dd 42859Ch, 8F33AE8h, 8BDB3300h, 0E0E853F0h, 8A0009B3h, 0F096h, 0F6EAD000h
    dd 840F01C2h, 9Dh, 511DE8A1h, 3D983900h, 74000392h, 329C6866h, 68E80050h
    dd 68FFFFF8h, 503004h, 3DC68h, 0E7A9E800h, 0E8A1FFFFh, 6800511Dh, 503004h
    dd 9B68h, 0BE80C600h, 100002Bh, 0FFE78EE8h, 0E80D8BFFh, 8800511Dh, 2BBF99h
    dd 0E8158B00h, 8800511Dh, 2BC09Ah, 1DE8A100h, 98890051h, 3923Dh, 9F96E8h
    dd 5B5E5F00h, 100C481h, 39C30000h, 3924598h, 68167500h, 50329Ch, 0FFF7FAE8h
    dd 300468FFh, 0E6680050h, 0EB000003h, 30046816h, 0E9680050h, 0EB000003h
    dd 3004680Ah, 0ED680050h, 0E8000003h, 0FFFFE723h, 1DE80D8Bh, 4680051h
    dd 68005030h, 9Bh, 2BBE81C6h, 0E8020000h, 0FFFFE707h, 635E9h, 0AADDE800h
    dd 0E8A10009h, 3300511Dh, 0BF888AC9h, 8300002Bh, 870F09F9h, 15A6h, 0F08D24FFh
    dd 0E8004285h, 3071Bh, 840FC085h, 96h, 511DE8A1h, 30046800h, 3680050h
    dd 80000004h, 2A4488h, 0E8A10100h, 8000511Dh, 2BEE88h, 0ACE81000h, 8BFFFFE6h
    dd 511DE80Dh, 30046800h, 9B680050h, 0C6000000h, 2BBE81h, 90E81000h, 8BFFFFE6h
    dd 511DE815h, 68DB3300h, 503004h, 40468h, 0BF9A8800h, 0A100002Bh, 511DE8h
    dd 2BC09888h, 68E80000h, 8BFFFFE6h, 511DE80Dh, 6A12B000h, 0BF818801h, 8B00002Bh
    dd 511DE815h, 0C0828800h, 0E800002Bh, 9B247h, 815B5E5Fh, 100C4h, 0DB33C300h
    dd 0DA15E853h, 0E8A10000h, 6600511Dh, 2BEEA081h, 0FFEF0000h, 0FFF302E8h
    dd 2C80A1FFh, 4680051h, 3B005030h, 683475C3h, 40Dh, 0FFE60AE8h, 1DE8A1FFh
    dd 16A0051h, 2BBF80C6h, 8B010000h, 511DE80Dh, 0C081C600h, 100002Bh, 9B1EAE8h
    dd 5B5E5F00h, 100C481h, 68C30000h, 40Fh, 0FFE5D6E8h, 0E8158BFFh, 0B000511Dh
    dd 88016A06h, 2BBF82h, 0E80D8B00h, 8800511Dh, 2BC081h, 0B1B5E800h, 5E5F0009h
    dd 0C4815Bh, 0C3000001h, 84E8036Ah, 0A10000D9h, 511DE8h, 50300468h, 41C6800h
    dd 81660000h, 2A44A0h, 0E8FFF700h, 0FFFFE587h, 511DE8A1h, 30046800h, 9B680050h
    dd 0C6000000h, 2BBE80h, 24E90F00h, 8000000Eh, 2A4488h, 4680800h, 68005030h
    dd 421h, 5E8E9h, 30046800h, 25680050h, 0E8000004h, 0FFFFE547h, 511DE8A1h
    dd 68DB3300h, 503004h, 9B68h, 0BE988800h, 0E800002Bh, 0FFFFE52Bh, 0DE5E9h
    dd 30046800h, 29680050h, 0E8000004h, 0FFFFE517h, 511DE8A1h, 30046800h
    dd 9B680050h, 0C6000000h, 2BBE80h, 0B4E90300h, 8B00000Dh, 37E1B80h, 0C0E85000h
    dd 330009F7h, 0E85353DBh, 9F6A7h, 9F1B2E8h, 3CE85300h, 5F0008F0h, 0C4815B5Eh
    dd 100h, 329468C3h, 78E80050h, 68FFFFF5h, 503004h, 43768h, 260E900h, 8C680000h
    dd 0E8005032h, 0FFFFF55Fh, 50300468h, 43C6800h, 47E90000h, 33000002h, 8ADB33C9h
    dd 2BBF88h, 2BC18B00h, 483574C3h, 1348850Fh, 84680000h, 0E8005032h, 0FFFFF52Fh
    dd 50328C68h, 0F525E800h, 0E8A1FFFFh, 6800511Dh, 503004h, 44A68h, 0A0816600h
    dd 2A44h, 52EBFFFBh, 50300468h, 4436800h, 16E90000h, 33000006h, 8ADB33C9h
    dd 2BBF88h, 2BC18B00h, 487C74C3h, 12F4850Fh, 7C680000h, 0E8005032h, 0FFFFF4DBh
    dd 50328C68h, 0F4D1E800h, 0E8A1FFFFh, 6800511Dh, 503004h, 45B68h, 0A0816600h
    dd 2A44h, 4E8FFFBh, 8BFFFFE4h, 511DE815h, 30046800h, 9B680050h, 0C6000000h
    dd 2BBE82h, 0E8E80200h, 0A1FFFFE3h, 511DE8h, 9888026Ah, 2BBFh, 1DE80D8Bh
    dd 99880051h, 2BC0h, 6982AE8h, 5B5E5F00h, 100C481h, 68C30000h, 503004h
    dd 45468h, 57BE900h, 8CE80000h, 8B0009A7h, 511DE80Dh, 8AC03300h, 2BBF81h
    dd 0EF88300h, 1254870Fh, 0D2330000h, 8638908Ah, 24FF0042h, 42861895h, 451E800h
    dd 7CE80005h, 680003D1h, 503004h, 47C68h, 8B60EB00h, 37E1B91h, 0D2FE900h
    dd 16A0000h, 50ECEE8h, 30046800h, 85680050h, 0E8000004h, 0FFFFE34Fh, 511DE8A1h
    dd 30046800h, 9B680050h, 0C6000000h, 2BBE80h, 34E80800h, 8BFFFFE3h, 511DE80Dh
    dd 68DB3300h, 503004h, 48668h, 0BF998800h, 8B00002Bh, 511DE815h, 0C09A8800h
    dd 0E800002Bh, 0FFFFE30Bh, 511DE8A1h, 0BF80C600h, 100002Bh, 1DE80D8Bh
    dd 81C60051h, 2BC0h, 5B5E5F01h, 100C481h, 0E8C30000h, 85B3h, 0BCE8026Ah
    dd 680000D6h, 503004h, 49368h, 0E2CDE800h, 158BFFFFh, 511DE8h, 2BBE82C6h
    dd 0E9090000h, 0AFAh, 50300468h, 4976800h, 0ACE80000h, 8BFFFFE2h, 511DE815h
    dd 30046800h, 9B680050h, 0C6000000h, 2BBE82h, 90E80A00h, 0A1FFFFE2h, 511DE8h
    dd 9888DB33h, 2BBFh, 1DE80D8Bh, 99880051h, 2BC0h, 38D02E8h, 30046800h
    dd 99680050h, 0E9000004h, 42Dh, 50300468h, 49D6800h, 54E80000h, 8BFFFFE2h
    dd 511DE80Dh, 0BE81C600h, 200002Bh, 164E9h, 0E8016A00h, 50DABh, 50300468h
    dd 4A26800h, 2CE80000h, 8BFFFFE2h, 511DE80Dh, 30046800h, 9B680050h, 0C6000000h
    dd 2BBE81h, 10E80800h, 8BFFFFE2h, 511DE815h, 68DB3300h, 503004h, 4A368h
    dd 0BF9A8800h, 0A100002Bh, 511DE8h, 2BC09888h, 2DE90000h, 33000004h, 0BF888AC9h
    dd 4900002Bh
    dd 7FE840Fh, 0E9830000h, 8F850F02h, 68000010h, 503004h, 4B168h, 253E900h
    dd 9CE80000h, 8B0009A5h, 511DE80Dh, 8AC03300h, 2BBF81h, 0F8834800h, 63870F0Fh
    dd 33000010h, 5C908AD2h, 0FF004286h, 86489524h, 16A0042h, 0D56EE8h, 30046800h
    dd 0C2680050h, 0E8000004h, 0FFFFE17Fh, 1DE80D8Bh, 81C60051h, 2BBEh, 8FE90Bh
    dd 16A0000h, 0D546E8h, 30046800h, 0C7680050h, 0E8000004h, 0FFFFE157h, 1DE80D8Bh
    dd 81C60051h, 2BBEh, 686AEB0Ch, 503004h, 4CB68h, 0E84CEB00h, 9A517h, 1DE80D8Bh
    dd 0C0330051h, 2BBF818Ah, 0F8830000h, 0DF870F03h, 0FF00000Fh, 866C8524h
    dd 0F4E80042h, 68000545h, 503004h, 4D968h, 34AE900h, 818B0000h, 37E1Bh
    dd 725E9h, 30046800h, 0E5680050h, 0E8000004h, 0FFFFE0EBh, 1DE80D8Bh, 81C60051h
    dd 2BBEh, 30046807h, 9B680050h, 0E8000000h, 0FFFFE0CFh, 158BDB33h, 511DE8h
    dd 2BBF9A88h, 0E8A10000h, 8800511Dh, 2BC098h, 5B5E5F00h, 100C481h, 0E8C30000h
    dd 9A487h, 511DE8A1h, 8AC93300h, 2BBF88h, 3F98300h, 0F50870Fh, 24FF0000h
    dd 42867C8Dh, 1835E800h, 4680005h, 68005030h, 4F5h, 2BBE9h, 8AC93300h
    dd 2BBE88h, 83C18B00h, 0F883F5C0h, 1F870F03h, 0FF00000Fh, 868C8524h, 0DB330042h
    dd 0BC1E853h, 4680005h, 68005030h, 505h, 0FFE042E8h, 0E8158BFFh, 6800511Dh
    dd 503004h, 9B68h, 0BE82C600h, 800002Bh, 0FFE026E8h, 1DE8A1FFh, 4680051h
    dd 68005030h, 506h, 2BBF9888h, 0D8B0000h, 511DE8h, 2BC09988h, 0CAE90000h
    dd 6A000001h, 0B69E801h, 4680005h, 68005030h, 50Ah, 0FFDFEAE8h, 0E80D8BFFh
    dd 6800511Dh, 503004h, 9B68h, 0BE81C600h, 800002Bh, 0FFDFCEE8h, 0E8158BFFh
    dd 3300511Dh, 300468DBh, 0B680050h, 88000005h, 2BBF9Ah, 1DE8A100h, 98880051h
    dd 2BC0h, 1EBE9h, 0AD41E800h, 0FCE80009h, 6AFFFF7Eh, 93F5E807h, 76A0006h
    dd 0FF62AEE8h, 0B129E8FFh, 5E5F0009h, 0C4815Bh, 0C3000001h, 0D8E8026Ah
    dd 68000693h, 503004h, 51668h, 0DF69E800h, 0E8A1FFFFh, 6800511Dh, 503004h
    dd 9B68h, 0BE80C600h, 700002Bh, 806E9h, 0A329E800h, 0E8A10009h, 3300511Dh
    dd 0BF888AC9h, 8300002Bh, 870F0DF9h, 0DF2h, 918AD233h, 4286B4h, 9C9524FFh
    dd 66004286h, 2AAFA081h, 0FFFD0000h, 511DE8A1h, 0A0816600h, 2AAFh, 48E8FFFEh
    dd 850002FFh, 83840FC0h, 0A1000000h, 511DE8h, 50300468h, 52D6800h, 88800000h
    dd 2A44h, 0DEE5E801h, 0E8A1FFFFh, 6800511Dh, 503004h, 9B68h, 0BE80C600h
    dd 1000002Bh, 0FFDECAE8h, 0E80D8BFFh, 3300511Dh, 300468DBh, 2E680050h
    dd 88000005h, 2BBF99h, 0E8158B00h, 8800511Dh, 2BC09Ah, 0DEA1E800h, 0D8BFFFFh
    dd 511DE8h, 818812B0h, 2BBFh, 1DE8158Bh, 82880051h, 2BC0h, 815B5E5Fh, 100C4h
    dd 28E8C300h, 6A0001CDh, 0C791E8FFh, 0C0850001h, 50300468h, 682D7400h
    dd 534h, 0FFDE5EE8h, 1DE8A1FFh, 80C60051h, 2BBFh, 0E80D8B02h, 0C600511Dh
    dd 2BC081h, 5E5F0200h, 0C4815Bh, 0C3000001h, 53668h, 0DE31E800h, 158BFFFFh
    dd 511DE8h, 2BBF82C6h, 0A1010000h, 511DE8h, 2BC080C6h, 5F010000h, 0C4815B5Eh
    dd 100h, 300468C3h, 3B680050h, 0E8000005h, 0FFFFDDFFh, 1DE80D8Bh, 4680051h
    dd 68005030h, 9Bh, 2BBE81C6h, 0E80A0000h, 0FFFFDDE3h, 1DE8158Bh, 0DB330051h
    dd 2BBF9A88h, 0E8A10000h, 8800511Dh, 2BC098h, 8855E800h, 4680003h, 68005030h
    dd 53Dh, 0FFDDB6E8h, 0E80D8BFFh, 0C600511Dh, 2BBF81h, 158B0100h, 511DE8h
    dd 2BC082C6h, 5F010000h, 0C4815B5Eh, 100h, 920105C3h, 10B90003h, 0BF000000h
    dd 4FCDC8h, 0D233F08Bh, 7B75A6F3h, 50300468h, 5476800h, 6CE80000h, 0A1FFFFDDh
    dd 511DE8h, 50300468h, 9B6800h, 80C60000h, 2BBEh, 0DD51E814h, 0D8BFFFFh
    dd 511DE8h, 468DB33h, 68005030h, 548h, 2BBF9988h, 158B0000h, 511DE8h, 2BC09A88h
    dd 28E80000h, 0A1FFFFDDh, 511DE8h, 2BBF80C6h, 8B010000h, 511DE80Dh, 0C081C600h
    dd 100002Bh, 1B73AE8h, 5B5E5F00h, 100C481h, 0B9C30000h, 10h, 4FCDB8BFh
    dd 33F08B00h, 75A6F3D2h, 3004687Bh, 4E680050h, 0E8000005h, 0FFFFDCDFh
    dd 511DE8A1h, 30046800h, 9B680050h, 0C6000000h, 2BBE80h, 0C4E81400h, 8BFFFFDCh
    dd 511DE80Dh, 68DB3300h, 503004h, 54F68h, 0BF998800h, 8B00002Bh, 511DE815h
    dd 0C09A8800h, 0E800002Bh, 0FFFFDC9Bh, 511DE8A1h, 0BF80C600h, 100002Bh
    dd 1DE80D8Bh, 81C60051h, 2BC0h, 0AB0DE801h, 5E5F0001h, 0C4815Bh, 0C3000001h
    dd 10B9h, 0CDA8BF00h, 0F08B004Fh, 0A6F3D233h, 4687B75h, 68005030h, 555h
    dd 0FFDC52E8h, 1DE8A1FFh, 4680051h, 68005030h, 9Bh, 2BBE80C6h, 0E8140000h
    dd 0FFFFDC37h, 1DE80D8Bh, 0DB330051h, 50300468h, 5566800h, 99880000h, 2BBFh
    dd 1DE8158Bh, 9A880051h, 2BC0h, 0FFDC0EE8h, 1DE8A1FFh, 80C60051h, 2BBFh
    dd 0E80D8B01h, 0C600511Dh, 2BC081h, 10E80100h, 5F0001A7h, 0C4815B5Eh, 100h
    dd 9291E8C3h, 0C0850002h, 0E8A16474h, 6800511Dh, 503004h, 55D68h, 44888000h
    dd 100002Ah, 0FFDBC2E8h, 1DE8A1FFh, 4680051h, 68005030h, 9Bh, 2BBE80C6h
    dd 0E8100000h, 0FFFFDBA7h, 1DE80D8Bh, 0DB330051h, 50300468h, 55E6800h
    dd 99880000h, 2BBFh, 1DE8158Bh, 9A880051h, 2BC0h, 0FFDB7EE8h, 8C1E9FFh
    dd 0F9680000h, 68000000h, 50324Ch, 511FB868h, 0CBF5E800h, 0C483000Bh, 3004680Ch
    dd 0BC680050h, 0E8000003h, 0FFFFDB53h, 1DE8158Bh, 4680051h, 33005030h
    dd 9B68DBh, 0C6530000h, 2BBE82h, 44E80F00h, 68FFFFDCh, 503004h, 3BD68h
    dd 34E85300h, 5FFFFFDCh, 0C4815B5Eh, 100h, 300468C3h, 64680050h, 0E8000005h
    dd 0FFFFDB0Bh, 1DE8158Bh, 82C60051h, 2BBEh, 338E902h, 0C9330000h, 2BBF888Ah
    dd 0F490000h, 9A985h, 0AF908A00h, 0D000002Ah, 1C2F6EAh, 0FE840Fh, 84E80000h
    dd 85000291h, 0A14874C0h, 511DE8h, 50300468h, 5716800h, 88800000h, 2A44h
    dd 0DAB5E801h, 0E8A1FFFFh, 6800511Dh, 503004h, 9B68DB33h, 53000000h, 2BBE80C6h
    dd 0E8100000h, 0FFFFDBA7h, 50300468h, 5726800h, 8BE90000h, 68000000h, 0F9h
    dd 50324C68h, 1FB86800h, 4E80051h, 83000BCBh, 4680CC4h, 68005030h, 3BCh
    dd 0F0E80F6Ah, 68FFFFDBh, 503004h, 0BD68DB33h, 53000003h, 0FFDB5EE8h, 1DE8A1FFh
    dd 4680051h, 68005030h, 577h, 0AFA08166h, 0FE00002Ah, 1DE8A1FFh, 81660051h
    dd 2AAFA0h, 0E8FFFD00h, 0FFFFDA23h, 511DE8A1h, 30046800h, 9B680050h, 53000000h
    dd 2BBE80C6h, 0E80F0000h, 0FFFFDB17h, 50300468h, 5786800h, 0F8E80000h
    dd 8BFFFFD9h, 511DE80Dh, 0BF998800h, 8B00002Bh, 511DE815h, 0C09A8800h
    dd 0A100002Bh
    dd 511DE8h, 7E1B808Bh, 0E8500003h, 9EC9Fh, 9A76AE8h, 0AB65E800h, 90E80009h
    dd 5F0009E6h, 0C4815B5Eh, 100h, 9D91E8C3h, 0E8A10009h, 3300511Dh, 0BF888AC9h
    dd 8300002Bh, 870F15F9h, 85Ah, 918AD233h, 4286E8h, 0C49524FFh, 6A004286h
    dd 1A45E801h, 468000Ah, 68005030h, 587h, 0FFD976E8h, 1DE8A1FFh, 80C60051h
    dd 2BBFh, 0E80D8B01h, 0C600511Dh, 2BC081h, 58E80100h, 8B0003C7h, 511DE815h
    dd 10B900h, 0C8BF0000h, 33004FCDh, 1828DDBh, 8B000392h, 74A6F3F0h, 0B9F08B12h
    dd 10h, 4FCDB8BFh, 0F3C03300h, 0F64975A6h, 2AAF82h, 19740100h, 50300468h
    dd 58F6800h, 10E80000h, 0BBFFFFD9h, 11h, 1C5E9h, 0DAF0A100h, 0C281004Fh
    dd 2BA2h, 0D8B0289h, 4FDAF4h, 0A1044A89h, 4FDAF8h, 8B084289h, 4FDAFC0Dh
    dd 0C4A8900h, 1BEBAE8h, 1FB8BF00h, 0C9830051h, 0F2C033FFh, 49D1F7AEh, 784840Fh
    dd 16A0000h, 0B868016Ah, 0E800511Fh, 7D217h, 1DE8158Bh, 0C0830051h, 0C2815014h
    dd 519h, 511FB868h, 5CE85200h, 0C600083Fh, 511FB805h, 5E5F0000h, 0C4815Bh
    dd 0C3000001h, 7E1B808Bh, 0E8500003h, 9EB4Fh, 9A61AE8h, 0AA15E800h, 40E80009h
    dd 0BF0009E5h, 511FB8h, 33FFC983h, 0F7AEF2C0h, 840F49D1h, 71Ah, 16A016Ah
    dd 511FB868h, 0D1ADE800h, 0D8B0007h, 511DE8h, 5014C083h, 519C181h, 0B8680000h
    dd 5100511Fh, 83EF2E8h, 0B805C600h, 511Fh, 815B5E5Fh, 100C4h, 8CE8C300h
    dd 8B000296h, 511DE815h, 8A016A00h, 2A4282h, 58E85000h, 85000293h, 8B2774C0h
    dd 511DE80Dh, 8AD23300h, 2A4291h, 3C28B00h, 5E0C1CAh, 48DC203h, 418C8B80h
    dd 1B67h, 8B1DE851h, 4680002h, 68005030h, 5ABh, 0FFD7CEE8h, 0E8158BFFh
    dd 0C600511Dh, 2BBE82h, 4681100h, 68005030h, 9Bh, 0FFD7B2E8h, 0E9DB33FFh
    dd 4F3h, 908AD233h, 2A42h, 0C203CA8Bh, 305E1C1h, 890C8DCAh, 8A48848Bh
    dd 8000001Bh, 9B88h, 0E8A14000h, 3300511Dh, 42908AD2h, 500002Ah, 2BA2h
    dd 83108B52h, 0CC8B10ECh, 508B1189h, 4518904h, 8B08508Bh, 51890C40h, 0C418908h
    dd 29836E8h, 75C08500h, 30046833h, 0B3680050h, 0E8000005h, 0FFFFD743h
    dd 0D8BDB33h, 511DE8h, 2BBF9988h, 158B0000h, 511DE8h, 2BC09A88h, 5E5F0000h
    dd 0C4815Bh, 0C3000001h, 511DE8A1h, 0BFB88000h, 1200002Bh, 9F850Fh, 808B0000h
    dd 37E1Bh, 0E9D1E850h, 0DB330009h, 0B8E85353h, 0E80009E8h, 9E3C3h, 69A8EE8h
    dd 0B6F9E800h, 0C0850001h, 0D8B4474h, 511DE8h, 519C181h, 0E8510000h, 830A3h
    dd 50300468h, 5C16800h, 0C4E80000h, 8BFFFFD6h, 511DE815h, 0BF82C600h, 1400002Bh
    dd 511DE8A1h, 0C080C600h, 1400002Bh, 815B5E5Fh, 100C4h, 468C300h, 68005030h
    dd 5C4h, 0FFD692E8h, 0E80D8BFFh, 0C600511Dh, 2BBF81h, 158B1500h, 511DE8h
    dd 2BC082C6h, 5F150000h, 0C4815B5Eh, 100h, 300468C3h, 0C7680050h, 0E8000005h
    dd 0FFFFD65Fh, 511DE8A1h, 0BF80C600h, 1500002Bh, 1DE80D8Bh, 81C60051h
    dd 2BC0h, 5B5E5F15h, 100C481h, 8BC30000h, 37E1B90h, 0E85200h, 0E80009E9h
    dd 9A3CBh, 9A7C6E8h, 0E2F1E800h, 5E5F0009h, 0C4815Bh, 0C3000001h, 4E5B88Bh
    dd 0DB330000h, 3774FB3Bh, 908AD233h, 2A42h, 0C203CA8Bh, 305E1C1h, 4578BCAh
    dd 0C8DEAD1h, 48B48B89h, 1B8Ah, 97868B66h, 32000000h, 1E283D0h, 8966D033h
    dd 9796h, 3324EB00h, 42908AD2h, 8B00002Ah, 0C1C203CAh, 0CA0305E1h, 8B890C8Dh
    dd 1B8A4884h, 81660000h, 97A0h, 8BFFFE00h, 511DE80Dh, 0BFB98000h, 1300002Bh
    dd 0D2332875h, 2A42918Ah, 0C28B0000h, 0E0C1CA03h, 8DC20305h, 848B8004h
    dd 1B8A41h, 9B888000h, 40000000h, 1DE80D8Bh, 0D2330051h, 918AF18Bh, 2A42h
    dd 2B4C898Ah, 0C28B0000h, 0E0C1F203h, 0C0C20305h, 48D04E9h, 1E18080h, 948AE1D0h
    dd 1B8446h, 46B48D00h, 1B84h, 0AFDE280h, 0A10E88CAh, 511DE8h, 2B4C888Ah
    dd 0E9C00000h, 1C1F604h, 888B6474h, 391E9h, 2AB1908Dh, 0E8520000h, 0D86Bh
    dd 1DE80D8Bh, 0F6330051h, 63319C39h, 7400001Bh, 31848A22h, 1BD6h, 474013Ch
    dd 1375023Ch, 6731848Bh, 5000001Bh, 2882EE8h, 0E80D8B00h, 8100511Dh, 14BC6h
    dd 0EEFE8100h, 7C00000Ch, 448980C7h, 400002Ah, 815B5E5Fh, 100C4h, 0B4E8C300h
    dd 85000009h, 683A74C0h, 503004h, 5EA68h, 244C8D00h, 2F9C6814h, 0E8510050h
    dd 0BC087h, 511DE8A1h, 10C48300h, 0C24548Dh, 51905h, 6A016A00h, 1F46801h
    dd 50520000h, 83B46E8h, 0E80D8B00h, 0C600511Dh, 2BBE81h, 23E91100h, 0E8000003h
    dd 28B6Fh, 95AE8h, 74C08500h, 3004683Ch, 0F0680050h, 8D000005h, 68142454h
    dd 502F9Ch, 0C02DE852h, 0D8B000Bh, 511DE8h, 8D10C483h, 810C2444h, 519C1h
    dd 6A016A00h, 1F46801h, 51500000h, 83AEAE8h, 0E8158B00h, 6800511Dh, 503004h
    dd 9B68h, 0C6006A00h, 2BBE82h, 1CE80F00h, 5FFFFFD5h, 0C4815B5Eh, 100h
    dd 0BBC933C3h, 11h, 2BBF888Ah, 0CB3B0000h, 2AC870Fh, 0D2330000h, 8714918Ah
    dd 24FF0042h, 42870095h, 4480F600h, 400002Ah, 0B0E84A75h, 6A000218h, 4319E801h
    dd 26A0004h, 44312E8h, 30046800h, 0FF680050h, 0E8000005h, 0FFFFD3B3h, 511DE8A1h
    dd 0BF80C600h, 100002Bh, 1DE80D8Bh, 81C60051h, 2BC0h, 8C55E801h, 5E5F0002h
    dd 0C4815Bh, 0C3000001h, 44716E8h, 30046800h, 5680050h, 0E8000006h, 0FFFFD377h
    dd 1DE8158Bh, 9A880051h, 2BBFh, 511DE8A1h, 0C0988800h, 0E800002Bh, 28C1Bh
    dd 815B5E5Fh, 100C4h, 0FCE8C300h, 8B000222h, 511DE80Dh, 1B918B00h, 5200037Eh
    dd 9E60AE8h, 0A0D5E800h, 0D0E80009h, 0E80009A4h, 9DFFBh, 511DE8A1h, 44888A00h
    dd 0C000002Ah, 0C1F602E9h, 0D3840F01h, 0E8000001h, 4469Fh, 1DE8158Bh, 0C2810051h
    dd 519h, 128DE852h, 0E8E80008h, 85000007h, 683C74C0h, 503004h, 61368h
    dd 24448D00h, 2F9C6814h, 0E8500050h, 0BBEBBh, 1DE8158Bh, 0C4830051h, 244C8D10h
    dd 19C2810Ch, 6A000005h, 68016A01h, 1F4h, 78E85251h, 0A1000839h, 511DE8h
    dd 2BBF9888h, 0D8B0000h, 511DE8h, 2BC09988h, 5E5F0000h, 0C4815Bh, 0C3000001h
    dd 1B63B08Dh, 0ABF0000h, 33000000h, 737E80DBh, 53087504h, 0CE8CE8Bh, 810003B8h
    dd 14BC6h, 0E9754F00h, 445FEE8h, 1DE8A100h, 88800051h, 2A44h, 5B5E5F04h
    dd 100C481h, 80C30000h, 2A4488h, 158B0100h, 511DE8h, 5214C283h, 0A1B02E8h
    dd 6A646A00h, 8B89E802h, 84E80003h, 6A000444h, 417DE808h, 0E8E80004h, 0A100043Ch
    dd 511DE8h, 2BEE888Ah, 0E9C00000h, 1C1F604h, 60E80F74h, 5F000289h, 0C4815B5Eh
    dd 100h, 96F1E8C3h, 0DB330001h, 5974C33Bh, 7403F883h, 6E1E854h, 0C0850000h
    dd 4683C74h, 68005030h, 643h, 1424548Dh
    dd 502F9C68h, 0B4E85200h, 8B000BBDh, 511DE80Dh, 10C48300h, 0C24448Dh, 519C181h
    dd 16A0000h, 0F468016Ah, 50000001h, 3871E851h, 158B0008h, 511DE8h, 2BBE82C6h
    dd 0EB100000h, 68DE851h, 0C0850000h, 4683C74h, 68005030h, 640h, 1424448Dh
    dd 502F9C68h, 60E85000h, 8B000BBDh, 511DE815h, 10C48300h, 0C244C8Dh, 519C281h
    dd 16A0000h, 0F468016Ah, 51000001h, 381DE852h, 0E8A10008h, 0C600511Dh
    dd 2BBE80h, 4680F00h, 68005030h, 9Bh, 0D251E853h, 5E5FFFFFh, 0C4815Bh
    dd 0C3000001h, 0E100498Dh, 0FE00426Eh, 0CE004271h, 1700426Fh, 30004272h
    dd 84004272h, 8F004272h, 1F004285h, 0F004273h, 94004275h, 0E8004275h, 24004274h
    dd 3 dup(24004276h), 82004276h, 1A004277h, 0CE00427Dh, 8F004282h, 8F004285h
    dd 0D7004285h, 0F000427Bh, 9400426Fh, 8F004280h, 2 dup(8F004285h), 64004285h
    dd 25004271h, 7A004271h, 0D4004271h, 0AA004271h, 4A004271h, 60004273h
    dd 6D004273h, 6B004274h, 0E8004273h, 15004273h, 8E004274h, 8F004274h, 4285h
    dd 7020701h, 7070707h, 7040307h, 0CB900605h, 88004275h, 3B004275h, 63004275h
    dd 8F004275h, 4285h, 4040104h, 2 dup(4040404h), 0B7030204h, 0CB004275h
    dd 0F6004275h, 0D6004281h, 46004275h, 0F5004276h, 6700427Ch, 5A004284h
    dd 77004276h, 0D0004276h, 2A004276h, 51004277h, 0AC004277h, 0F5004277h
    dd 3E00427Ch, 0B6004279h, 0C200427Bh, 8F004278h, 4285h, 5030201h, 2 dup(5050505h)
    dd 44FF8B04h, 4500427Dh, 5C00427Eh, 0AF004282h, 4C00427Eh, 2500427Fh, 9400427Fh
    dd 0B9004280h, 8F004280h, 4285h, 8020801h, 3 dup(8080808h), 6050403h, 0F2FF8B07h
    dd 7F004282h, 78004283h, 39004284h, 8F004284h, 4285h, 4020401h, 3 dup(4040404h)
    dd 90909003h, 90909090h
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_428730 proc near                    ; CODE XREF: sub_4916A0+56p
                                            ; sub_497F40+41Dp
    push    ebx
    push    esi
    push    edi
    mov     esi, offset dword_5120B8
    xor     ebx, ebx

    loc_42873A:                             ; CODE XREF: sub_428730+6Ej
    mov     eax, [esi]
    cmp     eax, ebx
    jz      short loc_428795
    push    eax
    call    sub_4C6AC0
    mov     eax, [esi+4]
    push    eax                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    mov     edx, [esi]
    add     esp, 4
    mov     ecx, [eax+11EBh]
    cmp     ecx, edx
    jnz     short loc_42876E
    mov     [eax+11EBh], ebx
    mov     eax, TAdynmemStructPtr

    loc_42876E:                             ; CODE XREF: sub_428730+31j
    mov     eax, [eax+531h]
    cmp     eax, ebx
    jz      short loc_428784
    mov     edx, [eax+24h]
    mov     ecx, [esi]
    cmp     edx, ecx
    jnz     short loc_428784
    mov     [eax+24h], ebx

    loc_428784:                             ; CODE XREF: sub_428730+46j
                                            ; sub_428730+4Fj
    mov     [esi], ebx
    mov     ecx, 8
    xor     eax, eax
    lea     edi, [esi+8]
    mov     [esi+4], ebx
    rep stosd

    loc_428795:                             ; CODE XREF: sub_428730+Ej
    add     esi, 28h
    cmp     esi, offset dword_512248
    jl      short loc_42873A
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_428730 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4287B0 proc near                    ; CODE XREF: sub_491200+435p
    push    edi
    mov     ecx, 64h
    xor     eax, eax
    mov     edi, offset dword_5120B8
    rep stosd
    pop     edi
    retn
    sub_4287B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+4]
    push    ebx
    push    ebp
    push    esi
    test    edx, edx
    push    edi
    jz      short loc_42883B
    xor     ebp, ebp
    mov     edi, offset dword_5120C0

    loc_4287E3:                             ; CODE XREF: .text:0042881Ej
    mov     esi, edx
    mov     eax, edi

    loc_4287E7:                             ; CODE XREF: .text:00428805j
    mov     bl, [eax]
    mov     cl, bl
    cmp     bl, [esi]
    jnz     short loc_42880B
    test    cl, cl
    jz      short loc_428807
    mov     bl, [eax+1]
    mov     cl, bl
    cmp     bl, [esi+1]
    jnz     short loc_42880B
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4287E7

    loc_428807:                             ; CODE XREF: .text:004287F1j
    xor     eax, eax
    jmp     short loc_428810
    ; ---------------------------------------------------------------------------

    loc_42880B:                             ; CODE XREF: .text:004287EDj
                                            ; .text:004287FBj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_428810:                             ; CODE XREF: .text:00428809j
    test    eax, eax
    jz      short loc_428829
    add     edi, 28h
    inc     ebp
    cmp     edi, offset dword_512250
    jl      short loc_4287E3
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_428829:                             ; CODE XREF: .text:00428812j
    lea     eax, [ebp+ebp*4+0]
    mov     eax, dword_5120BC[eax*8]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42883B:                             ; CODE XREF: .text:004287DAj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+4]
    push    ebx
    push    ebp
    push    esi
    test    edx, edx
    push    edi
    jz      short loc_4288BB
    xor     ebp, ebp
    mov     edi, offset dword_5120C0

    loc_428863:                             ; CODE XREF: .text:0042889Ej
    mov     esi, edx
    mov     eax, edi

    loc_428867:                             ; CODE XREF: .text:00428885j
    mov     bl, [eax]
    mov     cl, bl
    cmp     bl, [esi]
    jnz     short loc_42888B
    test    cl, cl
    jz      short loc_428887
    mov     bl, [eax+1]
    mov     cl, bl
    cmp     bl, [esi+1]
    jnz     short loc_42888B
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_428867

    loc_428887:                             ; CODE XREF: .text:00428871j
    xor     eax, eax
    jmp     short loc_428890
    ; ---------------------------------------------------------------------------

    loc_42888B:                             ; CODE XREF: .text:0042886Dj
                                            ; .text:0042887Bj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_428890:                             ; CODE XREF: .text:00428889j
    test    eax, eax
    jz      short loc_4288A9
    add     edi, 28h
    inc     ebp
    cmp     edi, offset dword_512250
    jl      short loc_428863
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4288A9:                             ; CODE XREF: .text:00428892j
    lea     eax, [ebp+ebp*4+0]
    mov     eax, dword_5120B8[eax*8]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4288BB:                             ; CODE XREF: .text:0042885Aj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4288D0 proc near                    ; CODE XREF: sub_41DA60+192p
                                            ; sub_41DA60+1A5p ...

    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 30h
    mov     eax, [esp+30h+arg_4]
    push    ebx
    push    ebp
    xor     ebp, ebp
    push    esi
    cmp     eax, ebp
    push    edi
    mov     [esp+40h+var_30], ebp
    mov     [esp+40h+var_2C], ebp
    jz      short loc_428906
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    push    ebp
    push    ebp
    call    sub_4C6890
    call    sub_4C63A0

    loc_428906:                             ; CODE XREF: sub_4288D0+17j
    mov     ebx, [esp+40h+arg_0]
    cmp     ebx, ebp
    jz      loc_428B4D
    mov     edi, offset dword_5120C0

    loc_428917:                             ; CODE XREF: sub_4288D0+82j
    mov     esi, ebx
    mov     eax, edi

    loc_42891B:                             ; CODE XREF: sub_4288D0+69j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_42893F
    test    cl, cl
    jz      short loc_42893B
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_42893F
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_42891B

    loc_42893B:                             ; CODE XREF: sub_4288D0+55j
    xor     eax, eax
    jmp     short loc_428944
    ; ---------------------------------------------------------------------------

    loc_42893F:                             ; CODE XREF: sub_4288D0+51j
                                            ; sub_4288D0+5Fj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_428944:                             ; CODE XREF: sub_4288D0+6Dj
    test    eax, eax
    jz      short loc_428956
    add     edi, 28h
    inc     ebp
    cmp     edi, offset dword_512250
    jl      short loc_428917
    jmp     short loc_4289B8
    ; ---------------------------------------------------------------------------

    loc_428956:                             ; CODE XREF: sub_4288D0+76j
    lea     eax, [ebp+ebp*4+0]
    lea     edi, [esp+40h+var_28]
    shl     eax, 3
    mov     ecx, dword_5120B8[eax]
    lea     esi, dword_5120B8[eax]
    mov     edx, dword_5120BC[eax]
    mov     [esp+40h+var_30], ecx
    mov     ecx, 0Ah
    mov     [esp+40h+var_2C], edx
    rep movsd
    lea     ecx, [ebp-1]
    test    ecx, ecx
    jl      short loc_4289A8
    lea     eax, [ecx+ecx*4]
    lea     edx, [ecx+1]
    lea     eax, ds:5120E0h[eax*8]

    loc_428996:                             ; CODE XREF: sub_4288D0+D6j
    lea     esi, [eax-28h]
    mov     edi, eax
    mov     ecx, 0Ah
    sub     eax, 28h
    dec     edx
    rep movsd
    jnz     short loc_428996

    loc_4289A8:                             ; CODE XREF: sub_4288D0+B7j
    mov     ecx, 0Ah
    lea     esi, [esp+40h+var_28]
    mov     edi, offset dword_5120B8
    rep movsd

    loc_4289B8:                             ; CODE XREF: sub_4288D0+84j
    mov     eax, [esp+40h+var_30]
    test    eax, eax
    jnz     loc_428A6A
    push    400h
    push    offset aPalette                 ; "Palette"
    call    sub_4D83B0
    mov     ecx, [esp+48h+arg_0]
    add     esp, 8
    mov     ebx, eax
    push    ebx
    push    ecx
    call    sub_429290
    mov     edx, TAdynmemStructPtr
    mov     [esp+40h+var_30], eax
    mov     [esp+40h+var_2C], ebx
    cmp     dword ptr [edx+391F1h], 6
    jz      short loc_428A66
    mov     eax, dword_512220
    test    eax, eax
    jz      short loc_428A17
    push    eax
    call    sub_4C6AC0
    mov     eax, dword_512224
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_428A17:                             ; CODE XREF: sub_4288D0+131j
    mov     edi, offset dword_512220

    loc_428A1C:                             ; CODE XREF: sub_4288D0+160j
    lea     eax, [edi-28h]
    mov     ecx, 0Ah
    mov     esi, eax
    rep movsd
    mov     edi, eax
    cmp     edi, offset dword_5120B8
    jg      short loc_428A1C
    mov     ecx, [esp+40h+var_30]
    mov     edi, [esp+40h+arg_0]
    mov     dword_5120B8, ecx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     dword_5120BC, ebx
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, offset dword_5120C0
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_428A66:                             ; CODE XREF: sub_4288D0+128j
    mov     ebx, [esp+40h+arg_0]

    loc_428A6A:                             ; CODE XREF: sub_4288D0+EEj
                                            ; sub_4288D0+281j
    mov     eax, [esp+40h+arg_C]
    test    eax, eax
    jnz     loc_428B41
    mov     eax, TAdynmemStructPtr
    mov     ebp, [esp+40h+var_30]
    mov     ecx, [eax+531h]
    test    ecx, ecx
    jz      short loc_428AB0
    add     eax, 519h
    push    ebp
    push    eax
    call    sub_4AB290
    mov     eax, [esp+40h+arg_8]
    test    eax, eax
    jz      short loc_428AE5
    mov     eax, [esp+40h+var_2C]
    push    100h
    push    0
    push    eax
    call    sub_4BA200
    jmp     short loc_428AE5
    ; ---------------------------------------------------------------------------

    loc_428AB0:                             ; CODE XREF: sub_4288D0+1B7j
    test    ebx, ebx
    mov     [eax+11EBh], ebp
    jz      short loc_428AE5
    mov     ecx, TAdynmemStructPtr
    mov     edi, ebx
    xor     eax, eax
    lea     edx, [ecx+11EFh]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_428AE5:                             ; CODE XREF: sub_4288D0+1CBj
                                            ; sub_4288D0+1DEj ...
    test    ebp, ebp
    jnz     short loc_428AED
    test    ebx, ebx
    jnz     short loc_428B41

    loc_428AED:                             ; CODE XREF: sub_4288D0+217j
    mov     ecx, TAdynmemStructPtr
    test    ebx, ebx
    jz      short loc_428B2B
    lea     edx, [ecx+11EFh]
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, 1
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_428B2B:                             ; CODE XREF: sub_4288D0+225j
    mov     byte ptr [ecx+11EFh], 0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_428B41:                             ; CODE XREF: sub_4288D0+1A0j
                                            ; sub_4288D0+21Bj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_428B4D:                             ; CODE XREF: sub_4288D0+3Cj
    mov     [esp+40h+var_30], ebp
    jmp     loc_428A6A
    sub_4288D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_428B60 proc near                    ; CODE XREF: sub_441080+162p
                                            ; sub_443CB0+241p ...
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    mov     ecx, 1
    cmp     [edx+0B6h], cx
    jl      short locret_428BA1
    push    esi
    push    ebx
    lea     eax, [edx+176h]
    mov     bl, 5

    loc_428B86:                             ; CODE XREF: sub_428B60+3Dj
    cmp     [eax-1Bh], bl
    jnz     short loc_428B8E
    or      dword ptr [eax], 8

    loc_428B8E:                             ; CODE XREF: sub_428B60+29j
    movsx   esi, word ptr [edx+0B6h]
    inc     ecx
    add     eax, 15Bh
    cmp     ecx, esi
    jle     short loc_428B86
    pop     ebx
    pop     esi

    locret_428BA1:                          ; CODE XREF: sub_428B60+1Aj
    retn
    sub_428B60 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_7. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_7. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_35. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_36. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_37. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION unknown_libname_8. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION unknown_libname_9. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION unknown_libname_10. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_52. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_53. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_54. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     eax, ecx
    xor     ecx, ecx
    mov     [eax+80h], ecx
    mov     [eax+84h], ecx
    mov     [eax+88h], ecx
    mov     [eax+8Ch], ecx
    mov     [eax+90h], ecx
    mov     dword ptr [eax+94h], 102h
    mov     [eax], cl
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    mov     edx, [esp+8]
    mov     [ecx+80h], eax
    add     edx, eax
    mov     [ecx+88h], eax
    xor     eax, eax
    mov     [ecx+84h], edx
    mov     [ecx+8Ch], eax
    mov     [ecx+90h], eax
    mov     dword ptr [ecx+94h], 102h
    mov     [ecx], al
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, ecx
    mov     eax, [esi+8Ch]
    test    eax, eax
    jz      short loc_428CE4
    mov     eax, 102h
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_428CE4:                             ; CODE XREF: .text:00428CDBj
    mov     eax, [esi+90h]
    test    eax, eax
    jz      short loc_428D00
    mov     dword ptr [esi+90h], 0
    mov     eax, [esi+94h]
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_428D00:                             ; CODE XREF: .text:00428CECj
    mov     ecx, esi
    call    sub_428D10
    mov     [esi+94h], eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_428D10 proc near                    ; CODE XREF: .text:00428D02p
                                            ; .text:00428EC8p
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+8Ch]
    test    eax, eax
    jz      short loc_428D26
    mov     eax, 102h
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_428D26:                             ; CODE XREF: sub_428D10+Cj
    mov     eax, [esi+88h]
    movsx   ecx, byte ptr [eax]
    push    ecx                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jz      short loc_428D63

    loc_428D3C:                             ; CODE XREF: sub_428D10+51j
    mov     eax, [esi+88h]
    mov     ecx, [esi+84h]
    cmp     eax, ecx
    jz      short loc_428D63
    inc     eax
    mov     [esi+88h], eax
    movsx   edx, byte ptr [eax]
    push    edx                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jnz     short loc_428D3C

    loc_428D63:                             ; CODE XREF: sub_428D10+2Aj
                                            ; sub_428D10+3Aj
    mov     eax, [esi+88h]
    mov     ecx, [esi+84h]
    cmp     eax, ecx
    jz      loc_428E85
    mov     al, [eax]
    test    al, al
    jz      loc_428E85
    movsx   eax, al
    push    eax                             ; int
    call    _ispunct
    add     esp, 4
    test    eax, eax
    jz      short loc_428DA4
    mov     ecx, [esi+88h]
    movsx   eax, byte ptr [ecx]
    inc     ecx
    mov     [esi+88h], ecx
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_428DA4:                             ; CODE XREF: sub_428D10+7Fj
    mov     ecx, [esi+88h]
    xor     edi, edi
    movsx   edx, byte ptr [ecx]
    push    edx                             ; int
    call    _isdigit
    add     esp, 4
    test    eax, eax
    jnz     short loc_428E33
    mov     eax, [esi+88h]
    mov     al, [eax]
    cmp     al, 2Dh
    jz      short loc_428E33
    cmp     al, 2Eh
    jz      short loc_428E33
    movsx   ecx, al
    push    ecx                             ; int
    call    _isalnum
    add     esp, 4
    test    eax, eax
    jz      short loc_428E16

    loc_428DDC:                             ; CODE XREF: sub_428D10+104j
    mov     eax, [esi+88h]
    mov     ecx, [esi+84h]
    cmp     eax, ecx
    jz      short loc_428E16
    cmp     edi, 7Fh
    jge     short loc_428E16
    mov     dl, [eax]
    mov     [edi+esi], dl
    mov     edx, [esi+88h]
    inc     edi
    inc     edx
    mov     eax, edx
    mov     [esi+88h], edx
    movsx   eax, byte ptr [eax]
    push    eax                             ; int
    call    _isalnum
    add     esp, 4
    test    eax, eax
    jnz     short loc_428DDC

    loc_428E16:                             ; CODE XREF: sub_428D10+CAj
                                            ; sub_428D10+DAj ...
    test    edi, edi
    mov     byte ptr [edi+esi], 0
    jz      short loc_428E2B
    cmp     edi, 7Fh
    jz      short loc_428E2B
    mov     eax, 100h
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_428E2B:                             ; CODE XREF: sub_428D10+10Cj
                                            ; sub_428D10+111j
    mov     eax, 102h
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_428E33:                             ; CODE XREF: sub_428D10+AAj
                                            ; sub_428D10+B6j ...
    mov     ecx, [esi+88h]
    mov     edi, 1
    mov     dl, [ecx]
    mov     [esi], dl

    loc_428E42:                             ; CODE XREF: sub_428D10+167j
    mov     eax, [esi+88h]
    inc     eax
    mov     [esi+88h], eax
    movsx   eax, byte ptr [eax]
    push    eax                             ; int
    call    _isdigit
    add     esp, 4
    test    eax, eax
    jnz     short loc_428E6A
    mov     ecx, [esi+88h]
    cmp     byte ptr [ecx], 2Eh
    jnz     short loc_428E79

    loc_428E6A:                             ; CODE XREF: sub_428D10+14Dj
    mov     edx, [esi+88h]
    inc     edi
    mov     al, [edx]
    mov     [edi+esi-1], al
    jmp     short loc_428E42
    ; ---------------------------------------------------------------------------

    loc_428E79:                             ; CODE XREF: sub_428D10+158j
    mov     byte ptr [edi+esi], 0
    mov     eax, 101h
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_428E85:                             ; CODE XREF: sub_428D10+61j
                                            ; sub_428D10+6Bj
    pop     edi
    xor     eax, eax
    pop     esi
    retn
    sub_428D10 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 100h
    push    esi
    mov     esi, ecx
    mov     eax, [esi+8Ch]
    test    eax, eax
    jz      short loc_428EAA
    mov     eax, 102h
    jmp     short loc_428ED3
    ; ---------------------------------------------------------------------------

    loc_428EAA:                             ; CODE XREF: .text:00428EA1j
    mov     eax, [esi+90h]
    test    eax, eax
    jz      short loc_428EC6
    mov     eax, [esi+94h]
    mov     dword ptr [esi+90h], 0
    jmp     short loc_428ED3
    ; ---------------------------------------------------------------------------

    loc_428EC6:                             ; CODE XREF: .text:00428EB2j
    mov     ecx, esi
    call    sub_428D10
    mov     [esi+94h], eax

    loc_428ED3:                             ; CODE XREF: .text:00428EA8j
                                            ; .text:00428EC4j
    cmp     eax, 101h
    jz      short loc_428F23
    mov     eax, [esi+8Ch]
    test    eax, eax
    jnz     short loc_428F0F
    mov     eax, TAdynmemStructPtr
    push    esi
    push    offset aExpectingInt            ; "expecting int"
    push    7
    mov     ecx, [eax+391E9h]
    call    sub_4356C0
    push    eax
    lea     ecx, [esp+10h]
    push    offset aParseErrorRead          ; "parse error reading AI profile %s\n%s\nla"...
    push    ecx
    call    _sprintf
    add     esp, 14h

    loc_428F0F:                             ; CODE XREF: .text:00428EE2j
    mov     dword ptr [esi+8Ch], 1
    xor     eax, eax
    pop     esi
    add     esp, 100h
    retn
    ; ---------------------------------------------------------------------------

    loc_428F23:                             ; CODE XREF: .text:00428ED8j
    push    esi
    call    _atoi
    add     esp, 4
    pop     esi
    add     esp, 100h
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    ecx
    push    eax
    call    __strcmpi
    add     esp, 8
    neg     eax
    sbb     eax, eax
    inc     eax
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 100h
    push    esi
    mov     esi, ecx
    mov     eax, [esi+8Ch]
    test    eax, eax
    jnz     short loc_428FA2
    mov     eax, [esp+108h]
    mov     ecx, TAdynmemStructPtr
    push    esi
    push    eax
    mov     ecx, [ecx+391E9h]
    push    7
    call    sub_4356C0
    push    eax
    lea     edx, [esp+10h]
    push    offset aParseErrorRead          ; "parse error reading AI profile %s\n%s\nla"...
    push    edx
    call    _sprintf
    add     esp, 14h

    loc_428FA2:                             ; CODE XREF: .text:00428F71j
    mov     dword ptr [esi+8Ch], 1
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_428FC0 proc near                    ; CODE XREF: sub_46E160+EAp
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1439Bh]
    push    ecx                             ; wint_t
    call    _iswlower
    add     esp, 4
    retn
    sub_428FC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_428FE0 proc near                    ; CODE XREF: sub_46E160+89p
                                            ; sub_46E160+ABp
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1439Bh]
    push    ecx                             ; wint_t
    call    _iswdigit
    add     esp, 4
    retn
    sub_428FE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_429000 proc near                    ; CODE XREF: .text:00426756p

    var_14C= dword ptr -14Ch
    var_148= dword ptr -148h
    var_140= byte ptr -140h
    var_100= dword ptr -100h

    sub     esp, 14Ch
    lea     ecx, [esp+14Ch+var_14C]
    push    esi
    call    sub_4C2EA0
    push    offset aTdf                     ; "tdf"
    push    offset aVersion_1               ; "version"
    lea     eax, [esp+158h+var_100]
    push    offset aGamedata                ; "gamedata"
    push    eax
    xor     esi, esi
    call    sub_4290F0
    lea     ecx, [esp+150h+var_100]
    push    ecx
    lea     ecx, [esp+154h+var_14C]
    call    sub_4C2F60
    test    eax, eax
    jz      loc_4290DA
    push    offset aVersion                 ; char *
    lea     ecx, [esp+154h+var_14C]
    call    sub_4C3410
    test    eax, eax
    jz      short loc_4290B0
    mov     ecx, [esp+150h+var_148]
    push    offset Data                     ; int
    push    40h                             ; size_t
    lea     edx, [esp+158h+var_140]
    push    offset aGpfversion              ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_4290B0
    lea     eax, [esp+150h+var_140]
    mov     esi, 1
    push    eax                             ; char *
    push    offset aV3_0                    ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4290B0
    push    esi
    push    esi
    push    1E0h
    push    offset aWarningYourCop          ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90

    loc_4290B0:                             ; CODE XREF: sub_429000+51j
                                            ; sub_429000+6Fj ...
    test    esi, esi
    jnz     short loc_4290DA
    push    1
    push    1
    push    1E0h
    push    offset aWarningYourCop          ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90

    loc_4290DA:                             ; CODE XREF: sub_429000+3Bj
                                            ; sub_429000+B2j
    lea     ecx, [esp+150h+var_14C]
    call    sub_4C2EB0
    pop     esi
    add     esp, 14Ch
    retn
    sub_429000 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4290F0 proc near                    ; CODE XREF: sub_41ACE0+6Bp
                                            ; sub_41D7B0+D9p ...

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h
    arg_8= dword ptr  1Ch
    arg_C= dword ptr  20h

    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_49F580
    mov     ebp, [esp+arg_C]
    mov     ebx, [esp+arg_0]
    test    eax, eax
    jz      loc_4291A2
    mov     ecx, [esp+arg_8]
    mov     edx, [esp+arg_4]
    push    ecx
    push    eax
    push    edx
    push    offset aSSS                     ; "%s-%s\\%s"
    push    ebx
    call    _sprintf
    add     esp, 14h
    test    ebp, ebp
    jz      short loc_429189
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_429189
    push    ebx
    call    sub_4BB0F0
    mov     edi, offset Directory
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_429189:                             ; CODE XREF: sub_4290F0+34j
                                            ; sub_4290F0+42j
    push    ebx
    call    sub_4BB5B0
    test    eax, eax
    jz      short loc_4291A2
    push    eax
    call    sub_4BB5D0
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4291A2:                             ; CODE XREF: sub_4290F0+13j
                                            ; sub_4290F0+A1j
    mov     edi, [esp+arg_4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, offset byte_503374
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, [esp+arg_8]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    test    ebp, ebp
    rep movsb
    jz      short loc_429279
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_429279
    push    ebx
    call    sub_4BB0F0
    mov     edi, offset Directory
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_429279:                             ; CODE XREF: sub_4290F0+126j
                                            ; sub_4290F0+132j
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    retn    10h
    sub_4290F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_429290 proc near                    ; CODE XREF: sub_41DA60+152p
                                            ; sub_4288D0+10Ep ...

    Text= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    sub     esp, 100h
    lea     ecx, [esp+100h+Text]
    push    esi
    push    offset aPcx                     ; "PCX"
    push    eax
    push    offset aBitmaps                 ; "bitmaps"
    push    ecx
    call    sub_4290F0
    lea     eax, [esp+104h+Text]
    mov     edx, [esp+104h+arg_4]
    push    edx
    push    eax
    call    sub_4CAF30
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4292D2
    lea     ecx, [esp+104h+Text]
    push    ecx                             ; lpText
    call    sub_4B6290

    loc_4292D2:                             ; CODE XREF: sub_429290+36j
    mov     eax, esi
    pop     esi
    add     esp, 100h
    retn    8
    sub_429290 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    sub     esp, 100h
    lea     ecx, [esp+0]
    push    esi
    push    offset aFnt                     ; "FNT"
    push    eax
    push    offset aFonts                   ; "fonts"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+4]
    push    0
    push    edx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_42931C
    lea     eax, [esp+4]
    push    eax
    call    sub_4B6290

    loc_42931C:                             ; CODE XREF: .text:00429310j
    mov     eax, esi
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_429330 proc near                    ; CODE XREF: sub_42A400+7p

    FileName= byte ptr -200h
    Text= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 200h
    lea     eax, [esp+200h+Text]
    push    esi
    push    edi
    mov     edi, [esp+208h+arg_0]
    push    offset off_5031D0
    push    edi
    push    offset aPalettes                ; "palettes"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+208h+Text]
    push    ecx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_42939B
    lea     edx, [esp+208h+Text]
    push    0
    push    edx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     loc_429459
    lea     eax, [esp+208h+Text]
    push    eax                             ; lpText
    call    sub_4B6290
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 200h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42939B:                             ; CODE XREF: sub_429330+36j
    push    400h
    push    offset aPalette_0               ; "PALETTE"
    call    sub_4D83B0
    add     esp, 8
    lea     ecx, [esp+208h+FileName]
    mov     esi, eax
    push    offset aPcx                     ; "PCX"
    push    edi
    push    offset aPalettes                ; "palettes"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+208h+FileName]
    push    esi
    push    edx
    call    sub_4CB080
    test    eax, eax
    jnz     short loc_4293DD
    lea     eax, [esp+208h+FileName]
    push    eax                             ; lpText
    call    sub_4B6290

    loc_4293DD:                             ; CODE XREF: sub_429330+A1j
    push    400h
    lea     ecx, [esp+20Ch+Text]
    push    esi
    push    ecx
    call    sub_4BC290
    push    offset off_5033A0
    push    offset aPalette_0               ; "PALETTE"
    lea     edx, [esp+210h+FileName]
    push    offset aPalettes                ; "palettes"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+208h+FileName]
    push    eax                             ; lpFileName
    call    sub_4BBC30
    push    offset dword_50339C
    push    offset aPalette_0               ; "PALETTE"
    lea     ecx, [esp+210h+FileName]
    push    offset aPalettes                ; "palettes"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+208h+FileName]
    push    edx                             ; lpFileName
    call    sub_4BBC30
    push    offset off_503398
    push    offset aPalette_0               ; "PALETTE"
    lea     eax, [esp+210h+FileName]
    push    offset aPalettes                ; "palettes"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+208h+FileName]
    push    ecx                             ; lpFileName
    call    sub_4BBC30

    loc_429459:                             ; CODE XREF: sub_429330+4Bj
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 200h
    retn    4
    sub_429330 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_429470 proc near                    ; CODE XREF: sub_42E440+AB6p
                                            ; sub_42E440+AF0p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    mov     ecx, [eax+33A0Fh]
    push    esi
    xor     ebx, ebx
    push    edi
    mov     edi, [esp+10h+arg_0]
    test    ecx, ecx
    jle     short loc_4294E9
    xor     esi, esi

    loc_42948F:                             ; CODE XREF: sub_429470+77j
    test    edi, edi
    jz      short loc_4294BB
    mov     dl, [eax+esi+33E13h]
    lea     ecx, [eax+esi+33E13h]
    test    dl, dl
    jz      short loc_4294DB
    push    20h                             ; size_t
    push    edi                             ; char *
    push    ecx                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jz      loc_4295A4
    jmp     short loc_4294D6
    ; ---------------------------------------------------------------------------

    loc_4294BB:                             ; CODE XREF: sub_429470+21j
    push    20h                             ; size_t
    lea     eax, [eax+esi+35E13h]
    push    ebp                             ; char *
    push    eax                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jz      loc_4295A4

    loc_4294D6:                             ; CODE XREF: sub_429470+49j
    mov     eax, TAdynmemStructPtr

    loc_4294DB:                             ; CODE XREF: sub_429470+33j
    mov     ecx, [eax+33A0Fh]
    inc     ebx
    add     esi, 20h
    cmp     ebx, ecx
    jl      short loc_42948F

    loc_4294E9:                             ; CODE XREF: sub_429470+1Bj
    mov     ecx, [eax+33A0Fh]
    inc     ecx
    cmp     ecx, 100h
    jl      short loc_429501
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_429501:                             ; CODE XREF: sub_429470+86j
    push    ebp
    call    sub_47EFE0
    mov     ecx, TAdynmemStructPtr
    push    20h                             ; size_t
    push    ebp                             ; char *
    mov     edx, [ecx+33A0Fh]
    mov     [ecx+edx*4+33A13h], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+33A0Fh]
    shl     ecx, 5
    lea     edx, [ecx+eax+35E13h]
    push    edx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    test    edi, edi
    jz      short loc_429562
    mov     eax, TAdynmemStructPtr
    push    20h                             ; size_t
    push    edi                             ; char *
    mov     ecx, [eax+33A0Fh]
    shl     ecx, 5
    lea     edx, [ecx+eax+33E13h]
    push    edx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    jmp     short loc_429599
    ; ---------------------------------------------------------------------------

    loc_429562:                             ; CODE XREF: sub_429470+CDj
    mov     eax, TAdynmemStructPtr
    mov     edi, offset Data
    mov     ecx, [eax+33A0Fh]
    shl     ecx, 5
    lea     edx, [ecx+eax+33E13h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_429599:                             ; CODE XREF: sub_429470+F0j
    mov     eax, TAdynmemStructPtr
    inc     dword ptr [eax+33A0Fh]

    loc_4295A4:                             ; CODE XREF: sub_429470+43j
                                            ; sub_429470+60j
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    retn    8
    sub_429470 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4295B0 proc near                    ; CODE XREF: sub_444A20+104p

    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_18= dword ptr -18h
    var_14= byte ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    sub     esp, 4Ch
    push    esi
    push    eax
    call    sub_4BB5B0
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4295CB
    pop     esi
    add     esp, 4Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4295CB:                             ; CODE XREF: sub_4295B0+12j
    push    edi
    push    esi
    call    sub_4BBD00
    lea     ecx, [esp+54h+var_40]
    push    40h
    push    ecx
    push    esi
    call    sub_4BB7C0
    test    [esp+54h+var_14], 1
    jz      short loc_42962A
    mov     edx, [esp+54h+var_18]
    push    edx
    push    esi
    call    sub_4BB710
    lea     eax, [esp+54h+var_4C]
    push    8
    push    eax
    push    esi
    call    sub_4BB7C0
    mov     ecx, [esp+54h+var_48]
    mov     edx, [esp+54h+var_4C]
    push    ecx
    push    edx
    push    offset aRadarpic                ; "RADARPIC"
    call    sub_4B8DA0
    mov     edi, eax
    mov     eax, [esp+54h+var_4C]
    imul    eax, [esp+54h+var_48]
    mov     ecx, [edi+10h]
    push    eax
    push    ecx
    push    esi
    call    sub_4BB7C0
    jmp     short loc_42962C
    ; ---------------------------------------------------------------------------

    loc_42962A:                             ; CODE XREF: sub_4295B0+34j
    xor     edi, edi

    loc_42962C:                             ; CODE XREF: sub_4295B0+78j
    mov     ecx, [esp+54h+arg_4]
    test    ecx, ecx
    jz      short loc_429648
    mov     eax, [esp+54h+arg_8]
    test    eax, eax
    jz      short loc_429648
    mov     edx, [esp+54h+var_3C]
    mov     [ecx], edx
    mov     ecx, [esp+54h+var_38]
    mov     [eax], ecx

    loc_429648:                             ; CODE XREF: sub_4295B0+82j
                                            ; sub_4295B0+8Aj
    push    esi
    call    sub_4BB5D0
    mov     eax, edi
    pop     edi
    pop     esi
    add     esp, 4Ch
    retn    0Ch
    sub_4295B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_429660 proc near                    ; CODE XREF: sub_483610+23p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+10h+arg_0]
    push    edi
    push    esi
    call    sub_4BB5B0
    mov     edi, eax
    test    edi, edi
    jnz     short loc_42967B
    push    esi                             ; lpText
    call    sub_4B6290

    loc_42967B:                             ; CODE XREF: sub_429660+13j
    push    edi
    call    sub_4BBD00
    mov     ecx, eax
    mov     eax, 66666667h
    imul    ecx
    sar     edx, 2
    mov     eax, edx
    push    ecx
    shr     eax, 1Fh
    add     edx, eax
    push    esi
    mov     [esp+1Ch+var_4], ecx
    mov     [esp+1Ch+arg_0], edx
    call    sub_4D83B0
    add     esp, 8
    mov     ebp, eax
    xor     esi, esi
    mov     ebx, 9

    loc_4296AF:                             ; CODE XREF: sub_429660+71j
    mov     ecx, [esp+14h+arg_0]
    lea     edx, [esi+ebp]
    push    ecx
    push    edx
    push    edi
    call    sub_4BB7C0
    add     esi, eax
    mov     eax, TAdynmemStructPtr
    mov     [eax+38D70h], bl
    add     ebx, 9
    cmp     ebx, 5Ah
    jle     short loc_4296AF
    mov     eax, [esp+14h+var_4]
    cmp     esi, eax
    jge     short loc_4296E7
    sub     eax, esi
    add     esi, ebp
    push    eax
    push    esi
    push    edi
    call    sub_4BB7C0

    loc_4296E7:                             ; CODE XREF: sub_429660+79j
    push    edi
    call    sub_4BB5D0
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_429660 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_429700 proc near                    ; CODE XREF: sub_429870+Ep
                                            ; sub_429870+2B2p ...

    Text= byte ptr -100h
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    sub     esp, 100h
    mov     ecx, [eax+147ABh]
    push    ebx
    push    esi
    xor     esi, esi
    push    edi
    mov     edi, [esp+10Ch+arg_0]
    test    ecx, ecx
    jle     short loc_42974E
    xor     ebx, ebx

    loc_429723:                             ; CODE XREF: sub_429700+4Cj
    mov     eax, [eax+147AFh]
    push    edi                             ; char *
    add     eax, ebx
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_42982B
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     ebx, 44h
    cmp     esi, [eax+147ABh]
    jl      short loc_429723

    loc_42974E:                             ; CODE XREF: sub_429700+1Fj
    push    offset off_502E38
    push    edi
    lea     ecx, [esp+114h+Text]
    push    offset aAnims                   ; "anims"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+10Ch+Text]
    push    edx
    call    sub_4B8C60
    mov     ebx, eax
    test    ebx, ebx
    jnz     short loc_42977D
    lea     eax, [esp+10Ch+Text]
    push    eax                             ; lpText
    call    sub_4B6290

    loc_42977D:                             ; CODE XREF: sub_429700+71j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+147ABh]
    inc     eax
    mov     edx, eax
    shl     edx, 4
    add     edx, eax
    mov     eax, [ecx+147AFh]
    shl     edx, 2
    push    edx                             ; int
    push    offset aAnimationFiles          ; int
    push    eax                             ; int
    call    Network_ReAllocPacketBuffer
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     [ecx+147AFh], eax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+147ABh]
    mov     edx, eax
    shl     edx, 4
    add     edx, eax
    mov     eax, [ecx+147AFh]
    or      ecx, 0FFFFFFFFh
    lea     edx, [eax+edx*4]
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+147ABh]
    mov     edx, eax
    shl     edx, 4
    add     edx, eax
    mov     eax, [ecx+147AFh]
    mov     [eax+edx*4+40h], ebx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+147ABh]
    inc     ecx
    mov     [eax+147ABh], ecx
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42982B:                             ; CODE XREF: sub_429700+37j
    mov     edx, TAdynmemStructPtr
    mov     ecx, esi
    shl     ecx, 4
    mov     eax, [edx+147AFh]
    add     ecx, esi
    pop     edi
    pop     esi
    mov     eax, [eax+ecx*4+40h]
    pop     ebx
    add     esp, 100h
    retn    4
    sub_429700 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+8]
    mov     ecx, [esp+4]
    push    eax
    push    ecx
    call    sub_4B8D40
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_429870 proc near                    ; CODE XREF: sub_491200+14Dp

    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_100= byte ptr -100h

    sub     esp, 10Ch
    push    ebx
    push    esi
    push    edi
    push    offset aFx                      ; "fx"
    call    sub_429700
    mov     ecx, TAdynmemStructPtr
    push    offset aSmoke1                  ; char *
    mov     [ecx+148F3h], eax
    mov     edx, TAdynmemStructPtr
    mov     esi, [edx+148F3h]
    push    esi                             ; int
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aSmoke2                  ; char *
    push    esi                             ; int
    mov     [ecx+147CFh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aFire1                   ; char *
    push    esi                             ; int
    mov     [edx+147D3h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aAlfboom1                ; char *
    push    esi                             ; int
    mov     [ecx+147D7h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    xor     ebx, ebx
    push    offset aRadlogo                 ; char *
    push    esi                             ; int
    mov     [edx+147DBh], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+147DBh]
    mov     [ecx+2], bl
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aRadlogohigh             ; char *
    push    esi                             ; int
    mov     [edx+147DFh], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aNuclogo                 ; char *
    push    esi                             ; int
    mov     [ecx+147E3h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aH2oboom2                ; char *
    push    esi                             ; int
    mov     [edx+147E7h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aLavasplash              ; char *
    push    esi                             ; int
    mov     [ecx+147EBh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+147EBh]
    mov     [eax+2], bl
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCannonshell             ; char *
    push    esi                             ; int
    mov     [ecx+147EFh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+147EFh]
    mov     [eax+2], bl
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aPlasmasm                ; char *
    push    esi                             ; int
    mov     [ecx+147BBh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aPlasmamd                ; char *
    push    esi                             ; int
    mov     [edx+147BFh], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aUltrashell              ; char *
    mov     [ecx+147C3h], eax
    push    esi                             ; int
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aPlasmasm                ; char *
    push    esi                             ; int
    mov     [edx+147C7h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aFlamestream             ; char *
    push    esi                             ; int
    mov     [ecx+147CBh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aExplosion               ; char *
    push    esi                             ; int
    mov     [edx+147F3h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aExplode2                ; char *
    push    esi                             ; int
    mov     [ecx+147F7h], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+147F7h]
    mov     [eax+2], bl
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aExplode3                ; char *
    push    esi                             ; int
    mov     [ecx+147FBh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+147FBh]
    mov     [eax+2], bl
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aExplode4                ; char *
    push    esi                             ; int
    mov     [ecx+147FFh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+147FFh]
    mov     [eax+2], bl
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aExplode5                ; char *
    push    esi                             ; int
    mov     [ecx+14803h], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14803h]
    mov     [eax+2], bl
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aNuke1                   ; char *
    push    esi                             ; int
    mov     [ecx+14807h], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14807h]
    mov     [eax+2], bl
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aShadow                  ; char *
    push    esi                             ; int
    mov     [ecx+1480Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1480Bh]
    mov     [eax+2], bl
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aIgtitles                ; "igtitles"
    mov     [ecx+1480Fh], eax
    call    sub_429700
    mov     edx, TAdynmemStructPtr
    push    offset aIgvictory               ; char *
    mov     [edx+148F7h], eax
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+148F7h]
    push    esi                             ; int
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aIgdefeat                ; char *
    push    esi                             ; int
    mov     [ecx+14813h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aIgpaused                ; char *
    push    esi                             ; int
    mov     [edx+14817h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aVismasks                ; "vismasks"
    mov     [ecx+1481Bh], eax
    call    sub_429700
    mov     edx, TAdynmemStructPtr
    push    offset aVismask                 ; char *
    mov     [edx+148FBh], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148FBh]
    push    ecx                             ; int
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aFog                     ; "fog"
    mov     [edx+1485Bh], eax
    call    sub_429700
    mov     ecx, TAdynmemStructPtr
    push    offset aBlack1                  ; char *
    mov     [ecx+148FFh], eax
    mov     edx, TAdynmemStructPtr
    mov     esi, [edx+148FFh]
    push    esi                             ; int
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aBlack2                  ; char *
    push    esi                             ; int
    mov     [ecx+1485Fh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aBlack3                  ; char *
    push    esi                             ; int
    mov     [edx+14863h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aBlack4                  ; char *
    push    esi                             ; int
    mov     [ecx+14867h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aGray1                   ; char *
    push    esi                             ; int
    mov     [edx+1486Bh], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aGray2                   ; char *
    push    esi                             ; int
    mov     [ecx+1486Fh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aGray3                   ; char *
    push    esi                             ; int
    mov     [edx+14873h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aGray4                   ; char *
    push    esi                             ; int
    mov     [ecx+14877h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursors                 ; "cursors"
    mov     [edx+1487Bh], eax
    call    sub_429700
    mov     ecx, TAdynmemStructPtr
    push    offset aCursorattack            ; char *
    mov     [ecx+14903h], eax
    mov     edx, TAdynmemStructPtr
    mov     esi, [edx+14903h]
    push    esi                             ; int
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCursorairstrik          ; char *
    push    esi                             ; int
    mov     [ecx+14883h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursortoofar            ; char *
    mov     [edx+14887h], eax
    push    esi                             ; int
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCursorcapture           ; char *
    push    esi                             ; int
    mov     [ecx+1488Bh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursordefend            ; char *
    push    esi                             ; int
    mov     [edx+1488Fh], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCursorrepair            ; char *
    push    esi                             ; int
    mov     [ecx+14893h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursorpatrol            ; char *
    push    esi                             ; int
    mov     [edx+14897h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCursorpickup            ; char *
    push    esi                             ; int
    mov     [ecx+1489Bh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursorteleport          ; char *
    push    esi                             ; int
    mov     [edx+1489Fh], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCursorreclamat          ; char *
    push    esi                             ; int
    mov     [ecx+148A3h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursorload              ; char *
    push    esi                             ; int
    mov     [edx+148ABh], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCursorunload            ; char *
    push    esi                             ; int
    mov     [ecx+148AFh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursormove              ; char *
    push    esi                             ; int
    mov     [edx+148B3h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCursorselect            ; char *
    push    esi                             ; int
    mov     [ecx+148B7h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursorfindsite          ; char *
    push    esi                             ; int
    mov     [edx+148BBh], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCursorred               ; char *
    push    esi                             ; int
    mov     [ecx+148BFh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursorgrn               ; char *
    push    esi                             ; int
    mov     [edx+148C3h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aCursornormal            ; char *
    push    esi                             ; int
    mov     [ecx+148C7h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursorhourglas          ; char *
    push    esi                             ; int
    mov     [edx+148CBh], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aPathicon                ; char *
    push    esi                             ; int
    mov     [ecx+148CFh], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aCursorrevive            ; char *
    push    esi                             ; int
    mov     [edx+148D3h], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+148A7h], eax
    lea     ecx, [esp+118h+var_10C]
    call    sub_4C2EA0
    push    offset off_50341C
    push    offset aSidedata                ; "sidedata"
    lea     edx, [esp+120h+var_100]
    push    offset aGamedata                ; "gamedata"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+118h+var_100]
    lea     ecx, [esp+118h+var_10C]
    push    eax
    call    sub_4C2F60
    lea     ecx, [esp+118h+var_100]
    push    offset aGeneral                 ; "GENERAL"
    push    ecx
    call    _sprintf
    add     esp, 8
    lea     ecx, [esp+118h+var_10C]
    call    sub_4C3E10
    lea     edx, [esp+118h+var_100]
    lea     ecx, [esp+118h+var_10C]
    push    edx                             ; char *
    call    sub_4C3410
    cmp     eax, 1
    jnz     short loc_429F19
    mov     ecx, [esp+118h+var_108]
    push    1E0h                            ; int
    push    offset aBaseheight              ; char *
    call    sub_4C46C0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+147A7h], eax
    jmp     short loc_429F29
    ; ---------------------------------------------------------------------------

    loc_429F19:                             ; CODE XREF: sub_429870+686j
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+147A7h], 1E0h

    loc_429F29:                             ; CODE XREF: sub_429870+6A7j
    xor     edi, edi

    loc_429F2B:                             ; CODE XREF: sub_429870+771j
    push    edi
    lea     eax, [esp+11Ch+var_100]
    push    offset aSideD                   ; "SIDE%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+118h+var_10C]
    call    sub_4C3E10
    lea     ecx, [esp+118h+var_100]
    push    ecx                             ; char *
    lea     ecx, [esp+11Ch+var_10C]
    call    sub_4C3410
    test    eax, eax
    jz      loc_429FE6
    mov     ecx, [esp+118h+var_108]
    push    offset Data                     ; int
    push    1Eh                             ; size_t
    lea     edx, [esp+120h+var_100]
    push    offset aIntgaf                  ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, ebx
    jz      short loc_429FE0
    lea     eax, [esp+118h+var_100]
    push    eax
    call    sub_429700
    mov     esi, eax
    cmp     esi, ebx
    jz      short loc_429FE0
    mov     ecx, TAdynmemStructPtr
    push    offset aPaneltop                ; char *
    push    esi                             ; int
    mov     [ecx+edi*4+14907h], esi
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    push    offset aPanelside               ; char *
    push    esi                             ; int
    mov     [edx+edi*4+1481Fh], eax
    call    sub_4B8D40
    mov     ecx, TAdynmemStructPtr
    push    offset aPanelbot                ; char *
    push    esi                             ; int
    mov     [ecx+edi*4+14847h], eax
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    mov     [edx+edi*4+14833h], eax

    loc_429FE0:                             ; CODE XREF: sub_429870+709j
                                            ; sub_429870+719j
    inc     edi
    jmp     loc_429F2B
    ; ---------------------------------------------------------------------------

    loc_429FE6:                             ; CODE XREF: sub_429870+6E7j
    lea     ecx, [esp+118h+var_10C]
    call    sub_4C3240
    lea     ecx, [esp+118h+var_10C]
    call    sub_4C2EB0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10Ch
    retn
    sub_429870 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42A010 proc near                    ; CODE XREF: sub_4916A0+ACp
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    xor     ebx, ebx
    mov     ecx, [eax+147ABh]
    xor     esi, esi
    cmp     ecx, ebx
    push    edi
    jle     short loc_42A04C
    xor     edi, edi

    loc_42A028:                             ; CODE XREF: sub_42A010+3Aj
    mov     eax, [eax+147AFh]
    mov     ecx, [eax+edi+40h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    inc     esi
    add     edi, 44h
    cmp     esi, [eax+147ABh]
    jl      short loc_42A028

    loc_42A04C:                             ; CODE XREF: sub_42A010+14j
    mov     edx, [eax+147AFh]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     [eax+147ABh], ebx
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     [ecx+147AFh], ebx
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+37F39h], ebx
    jle     short loc_42A098

    loc_42A082:                             ; CODE XREF: sub_42A010+86j
    mov     [ecx+eax*4+14907h], ebx
    mov     ecx, TAdynmemStructPtr
    inc     eax
    cmp     eax, [ecx+37F39h]
    jl      short loc_42A082

    loc_42A098:                             ; CODE XREF: sub_42A010+70j
    mov     [ecx+14903h], ebx
    mov     edx, TAdynmemStructPtr
    pop     edi
    pop     esi
    mov     [edx+148FFh], ebx
    mov     eax, TAdynmemStructPtr
    mov     [eax+148FBh], ebx
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+148F7h], ebx
    mov     edx, TAdynmemStructPtr
    mov     [edx+148F3h], ebx
    mov     eax, TAdynmemStructPtr
    mov     [eax+148EFh], ebx
    pop     ebx
    retn
    sub_42A010 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148E7h]
    mov     eax, [eax+148EBh]
    lea     edx, ds:4[ecx*4]
    push    edx
    push    offset aAnimplayPointe          ; "Animplay Pointers"
    push    eax
    call    Network_ReAllocPacketBuffer
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     [ecx+148EBh], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+4]
    mov     edx, [eax+148E7h]
    mov     eax, [eax+148EBh]
    mov     [eax+edx*4], ecx
    mov     eax, TAdynmemStructPtr
    inc     dword ptr [eax+148E7h]
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42A140 proc near                    ; CODE XREF: sub_42A140+15p
                                            ; sub_42A140+23p ...

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_4]
    push    edi
    mov     edi, [esp+4+arg_0]
    mov     eax, [edi+2Ch]
    test    eax, eax
    jz      short loc_42A15A
    push    esi
    push    eax
    call    sub_42A140

    loc_42A15A:                             ; CODE XREF: sub_42A140+11j
    mov     eax, [edi+30h]
    test    eax, eax
    jz      short loc_42A168
    push    esi
    push    eax
    call    sub_42A140

    loc_42A168:                             ; CODE XREF: sub_42A140+1Fj
    mov     eax, [edi+8]
    mov     esi, [edi+28h]
    test    eax, eax
    mov     [esp+4+arg_4], 0
    jle     loc_42A2B3
    mov     edi, [esp+4+arg_0]

    loc_42A182:                             ; CODE XREF: sub_42A140+16Dj
    mov     eax, [esi+10h]
    lea     ebp, [esi+10h]
    test    eax, eax
    jz      loc_42A298
    mov     edx, [esi+1Ch]
    xor     ebx, ebx
    and     edx, 0FFFFFFFBh
    mov     [esi+1Ch], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148DFh]
    test    ecx, ecx
    jle     short loc_42A1D8

    loc_42A1AA:                             ; CODE XREF: sub_42A140+8Fj
    mov     edx, [eax+148E3h]
    mov     ecx, [ebp+0]
    push    ecx                             ; char *
    mov     eax, [edx+ebx*4]
    push    eax                             ; int
    call    sub_4B8D40
    mov     edi, eax
    test    edi, edi
    jnz     short loc_42A1D3
    mov     eax, TAdynmemStructPtr
    inc     ebx
    cmp     ebx, [eax+148DFh]
    jl      short loc_42A1AA
    jmp     short loc_42A1D8
    ; ---------------------------------------------------------------------------

    loc_42A1D3:                             ; CODE XREF: sub_42A140+81j
    mov     eax, TAdynmemStructPtr

    loc_42A1D8:                             ; CODE XREF: sub_42A140+68j
                                            ; sub_42A140+91j
    test    edi, edi
    jnz     short loc_42A217
    mov     ecx, [ebp+0]
    mov     edx, [eax+148D7h]
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4B8D40
    mov     edi, eax
    test    edi, edi
    jz      short loc_42A204
    cmp     word ptr [edi], 0Ah
    jnz     short loc_42A200
    mov     eax, [esi+1Ch]
    or      al, 4
    mov     [esi+1Ch], eax

    loc_42A200:                             ; CODE XREF: sub_42A140+B6j
    test    edi, edi
    jnz     short loc_42A217

    loc_42A204:                             ; CODE XREF: sub_42A140+B0j
    mov     eax, [esi+1Ch]
    mov     dword ptr [esi], 0D1h
    or      al, 1
    mov     [esi+1Ch], eax
    jmp     loc_42A298
    ; ---------------------------------------------------------------------------

    loc_42A217:                             ; CODE XREF: sub_42A140+9Aj
                                            ; sub_42A140+C2j
    cmp     word ptr [edi], 1
    jbe     short loc_42A28A
    push    0
    push    edi
    push    ebp
    call    sub_4B8B30
    mov     ecx, [esi+1Ch]
    or      ecx, 2
    mov     [esi+1Ch], ecx
    mov     al, [esi+1Ch]
    test    al, 4
    jnz     short loc_42A298
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148E7h]
    mov     eax, [eax+148EBh]
    lea     edx, ds:4[ecx*4]
    push    edx                             ; int
    push    offset aAnimplayPointe          ; int
    push    eax                             ; int
    call    Network_ReAllocPacketBuffer
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     [ecx+148EBh], eax
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+148E7h]
    mov     eax, [eax+148EBh]
    mov     [eax+edx*4], ebp
    mov     eax, TAdynmemStructPtr
    inc     dword ptr [eax+148E7h]
    jmp     short loc_42A298
    ; ---------------------------------------------------------------------------

    loc_42A28A:                             ; CODE XREF: sub_42A140+DBj
    mov     eax, [esi+1Ch]
    mov     ecx, [edi+28h]
    and     al, 0FDh
    mov     [ebp+0], ecx
    mov     [esi+1Ch], eax

    loc_42A298:                             ; CODE XREF: sub_42A140+4Aj
                                            ; sub_42A140+D2j ...
    mov     edx, [esp+4+arg_0]
    mov     eax, [esp+4+arg_4]
    inc     eax
    add     esi, 20h
    mov     ecx, [edx+8]
    mov     [esp+4+arg_4], eax
    cmp     eax, ecx
    jl      loc_42A182

    loc_42A2B3:                             ; CODE XREF: sub_42A140+38j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_42A140 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42A2C0 proc near                    ; CODE XREF: sub_4224B0+160p

    Text= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 100h
    lea     eax, [esp+100h+Text]
    push    esi
    push    edi
    mov     edi, [esp+108h+arg_0]
    push    offset off_5036F0
    push    edi
    push    offset aObjects3d               ; "objects3d"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+108h+Text]
    push    ecx
    call    sub_4CB560
    mov     esi, eax
    test    esi, esi
    jnz     short loc_42A2FE
    lea     edx, [esp+108h+Text]
    push    edx                             ; lpText
    call    sub_4B6290

    loc_42A2FE:                             ; CODE XREF: sub_42A2C0+32j
    push    esi
    call    sub_4CB590
    push    edi
    push    esi
    call    sub_42A140
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 100h
    retn    4
    sub_42A2C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42A320 proc near                    ; CODE XREF: sub_491200+173p

    Text= byte ptr -100h

    sub     esp, 100h
    lea     eax, [esp+100h+Text]
    push    esi
    push    offset aFnt                     ; "FNT"
    push    offset aComix                   ; "COMIX"
    push    offset aFonts                   ; "fonts"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+104h+Text]
    push    0
    push    ecx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_42A35C
    lea     edx, [esp+104h+Text]
    push    edx                             ; lpText
    call    sub_4B6290

    loc_42A35C:                             ; CODE XREF: sub_42A320+30j
    mov     eax, TAdynmemStructPtr
    push    offset aFnt                     ; "FNT"
    push    offset aSmlfont                 ; "smlfont"
    lea     ecx, [esp+10Ch+Text]
    push    offset aFonts                   ; "fonts"
    push    ecx
    mov     [eax+391F9h], esi
    call    sub_4290F0
    lea     edx, [esp+104h+Text]
    push    0
    push    edx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_42A39C
    lea     eax, [esp+104h+Text]
    push    eax                             ; lpText
    call    sub_4B6290

    loc_42A39C:                             ; CODE XREF: sub_42A320+70j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+391FDh], esi
    pop     esi
    add     esp, 100h
    retn
    sub_42A320 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42A3B0 proc near                    ; CODE XREF: sub_4916A0+A2p
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391FDh]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     dword ptr [edx+391FDh], 0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391F9h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     dword ptr [edx+391F9h], 0
    retn
    sub_42A3B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42A400 proc near                    ; CODE XREF: sub_491200+178p
    push    esi
    push    edi
    push    offset aPalette_0               ; "PALETTE"
    call    sub_429330
    mov     ecx, TAdynmemStructPtr
    mov     esi, eax
    push    eax                             ; int
    lea     edi, [ecx+143A7h]
    mov     ecx, 100h
    rep movsd
    call    sub_4D85A0
    add     esp, 4
    mov     eax, 1
    pop     edi
    pop     esi
    retn
    sub_42A400 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42A440 proc near                    ; CODE XREF: sub_4917D0+CDp

    var_218= dword ptr -218h
    var_118= dword ptr -118h
    var_104= byte ptr -104h

    sub     esp, 218h
    lea     eax, [esp+218h+var_218]
    push    ebx
    push    ebp
    push    esi
    push    offset off_502E38
    push    offset asc_50372C               ; "*"
    push    offset aTextures                ; "textures"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+224h+var_218]
    push    0
    push    ecx
    call    sub_4BC930
    mov     edx, TAdynmemStructPtr
    lea     ebp, [eax-1]
    shl     eax, 2
    push    eax
    push    offset aTexturePtrs             ; "TEXTURE PTRS"
    mov     [edx+148DFh], ebp
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     esi, eax
    lea     edx, [esp+224h+var_118]
    push    1
    push    0FFFFFFFFh
    lea     eax, [esp+22Ch+var_218]
    push    edx
    push    eax
    mov     [ecx+148E3h], esi
    call    sub_4BC4B0
    mov     ebx, eax
    cmp     ebx, 0FFFFFFFFh
    jz      loc_42A543
    push    edi
    xor     edi, edi

    loc_42A4C0:                             ; CODE XREF: sub_42A440+EDj
    lea     ecx, [esp+228h+var_104]
    push    offset aLogos_gaf               ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_42A4DE
    sub     esi, 4
    jmp     short loc_42A517
    ; ---------------------------------------------------------------------------

    loc_42A4DE:                             ; CODE XREF: sub_42A440+97j
    lea     edx, [esp+228h+var_104]
    push    offset off_502E38
    push    edx
    lea     eax, [esp+230h+var_218]
    push    offset aTextures                ; "textures"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+228h+var_218]
    push    ecx
    call    sub_4B8C60
    mov     [esi], eax
    mov     eax, edi
    cdq
    idiv    ebp
    mov     edx, TAdynmemStructPtr
    mov     [edx+38D6Fh], al

    loc_42A517:                             ; CODE XREF: sub_42A440+9Cj
    lea     eax, [esp+228h+var_118]
    push    eax
    push    ebx
    call    sub_4BC640
    add     esi, 4
    add     edi, 64h
    test    eax, eax
    jz      short loc_42A4C0
    mov     ecx, TAdynmemStructPtr
    push    ebx
    mov     byte ptr [ecx+38D6Fh], 64h
    call    sub_4BC8D0
    pop     edi

    loc_42A543:                             ; CODE XREF: sub_42A440+77j
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    pop     esi
    pop     ebp
    mov     [edx+148E7h], eax
    mov     ecx, TAdynmemStructPtr
    pop     ebx
    mov     [ecx+148EBh], eax
    add     esp, 218h
    retn
    sub_42A440 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42A570 proc near                    ; CODE XREF: sub_491B60+CBp
    mov     eax, TAdynmemStructPtr
    push    esi
    xor     esi, esi
    mov     ecx, [eax+148DFh]
    test    ecx, ecx
    jle     short loc_42A5B6

    loc_42A582:                             ; CODE XREF: sub_42A570+44j
    mov     eax, [eax+148E3h]
    mov     ecx, [eax+esi*4]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    inc     esi
    mov     eax, [edx+148E3h]
    mov     dword ptr [eax+esi*4-4], 0
    mov     eax, TAdynmemStructPtr
    cmp     esi, [eax+148DFh]
    jl      short loc_42A582

    loc_42A5B6:                             ; CODE XREF: sub_42A570+10j
    mov     ecx, [eax+148E3h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     dword ptr [edx+148E3h], 0
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+148EBh]
    test    eax, eax
    jz      short loc_42A60D
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     dword ptr [ecx+148EBh], 0
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+148E7h], 0

    loc_42A60D:                             ; CODE XREF: sub_42A570+72j
    pop     esi
    retn
    sub_42A570 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42A610 proc near                    ; CODE XREF: sub_46D970+8Dp
                                            ; sub_46DAD0+358p

    var_158= dword ptr -158h
    var_151= byte ptr -151h
    var_150= dword ptr -150h
    var_14C= dword ptr -14Ch
    var_148= dword ptr -148h
    var_144= dword ptr -144h
    var_140= dword ptr -140h
    var_100= dword ptr -100h
    arg_0= dword ptr  4

    sub     esp, 158h
    push    ebx
    mov     ebx, [esp+15Ch+arg_0]
    mov     eax, [ebx+142h]
    test    eax, eax
    jnz     loc_42A85A
    mov     eax, TAdynmemStructPtr
    push    edi
    push    esi
    mov     ecx, [eax+1439Bh]
    push    ecx                             ; wint_t
    call    _iswdigit
    add     esp, 4
    lea     edi, [ebx+20h]
    lea     edx, [esp+164h+var_100]
    push    offset aCob                     ; "cob"
    push    edi
    push    offset aScripts                 ; "scripts"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+164h+var_158]
    lea     ecx, [esp+164h+var_100]
    push    eax
    push    ecx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jz      short loc_42A691
    mov     edx, [esp+164h+var_158]
    push    edx
    push    esi
    call    sub_4B6BA0
    mov     edx, [ebx+142h]
    push    esi                             ; int
    xor     edx, eax
    mov     [ebx+142h], edx
    call    sub_4D85A0
    add     esp, 4

    loc_42A691:                             ; CODE XREF: sub_42A610+5Dj
    mov     al, [esp+164h+var_151]
    or      ecx, 0FFFFFFFFh
    mov     byte ptr [esp+164h+var_150], al
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+164h+var_140]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+164h+var_140]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    push    offset aGui                     ; "gui"
    rep movsb
    mov     edi, offset asc_50372C          ; "*"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     [esp+168h+var_14C], 0
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     eax, [esp+168h+var_140]
    and     ecx, 3
    push    eax
    rep movsb
    lea     ecx, [esp+16Ch+var_100]
    push    offset aGuis                    ; "guis"
    push    ecx
    mov     [esp+174h+var_148], 0
    mov     [esp+174h+var_144], 0
    call    sub_4290F0
    lea     edx, [esp+164h+var_150]
    lea     eax, [esp+164h+var_100]
    push    edx
    push    0
    push    eax
    call    sub_4BCA30
    xor     edi, edi

    loc_42A72C:                             ; CODE XREF: sub_42A610+185j
    mov     ecx, [esp+164h+var_14C]
    test    ecx, ecx
    jnz     short loc_42A738
    xor     eax, eax
    jmp     short loc_42A741
    ; ---------------------------------------------------------------------------

    loc_42A738:                             ; CODE XREF: sub_42A610+122j
    mov     eax, [esp+164h+var_148]
    sub     eax, ecx
    sar     eax, 2

    loc_42A741:                             ; CODE XREF: sub_42A610+126j
    cmp     edi, eax
    jnb     short loc_42A797
    mov     ecx, [ecx+edi*4]
    push    offset aGui                     ; "gui"
    push    ecx
    lea     edx, [esp+16Ch+var_100]
    push    offset aGuis                    ; "guis"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+164h+var_158]
    lea     ecx, [esp+164h+var_100]
    push    eax
    push    ecx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jz      short loc_42A794
    mov     edx, [esp+164h+var_158]
    push    edx
    push    esi
    call    sub_4B6BA0
    mov     edx, [ebx+142h]
    push    esi                             ; int
    xor     edx, eax
    mov     [ebx+142h], edx
    call    sub_4D85A0
    add     esp, 4

    loc_42A794:                             ; CODE XREF: sub_42A610+160j
    inc     edi
    jmp     short loc_42A72C
    ; ---------------------------------------------------------------------------

    loc_42A797:                             ; CODE XREF: sub_42A610+133j
    lea     eax, [ebx+20h]
    push    offset aTdf                     ; "tdf"
    push    eax
    lea     eax, [esp+16Ch+var_100]
    push    offset aDownload                ; "download"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+164h+var_100]
    push    ecx
    call    sub_4BB5B0
    mov     esi, eax
    test    esi, esi
    jz      short loc_42A808
    push    esi
    call    sub_4BBD00
    test    eax, eax
    mov     [esp+164h+var_158], eax
    jle     short loc_42A802
    push    0
    lea     edx, [esp+168h+var_100]
    push    esi
    push    edx
    call    sub_4BBFF0
    mov     edi, eax
    test    edi, edi
    jz      short loc_42A802
    mov     eax, [esp+164h+var_158]
    push    eax
    push    edi
    call    sub_4B6BA0
    mov     edx, [ebx+142h]
    push    edi                             ; int
    xor     edx, eax
    mov     [ebx+142h], edx
    call    sub_4D85A0
    add     esp, 4

    loc_42A802:                             ; CODE XREF: sub_42A610+1BBj
                                            ; sub_42A610+1CEj
    push    esi
    call    sub_4BB5D0

    loc_42A808:                             ; CODE XREF: sub_42A610+1ADj
    mov     ecx, [ebx+146h]
    mov     esi, [ebx+142h]
    xor     esi, ecx
    mov     [ebx+142h], esi
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1439Bh]
    push    eax                             ; wint_t
    call    _iswlower
    mov     edi, [esp+168h+var_148]
    mov     esi, [esp+168h+var_14C]
    add     esp, 4
    cmp     esi, edi
    jz      short loc_42A84F

    loc_42A83D:                             ; CODE XREF: sub_42A610+239j
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_42A83D
    mov     esi, [esp+164h+var_14C]

    loc_42A84F:                             ; CODE XREF: sub_42A610+22Bj
    push    esi
    call    sub_4B4F20
    add     esp, 4
    pop     esi
    pop     edi

    loc_42A85A:                             ; CODE XREF: sub_42A610+16j
    pop     ebx
    add     esp, 158h
    retn    4
    sub_42A610 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    mov     bl, [esp+8]
    push    ebp
    push    esi
    test    bl, 2
    push    edi
    mov     ebp, ecx
    jz      short loc_42A8B1
    mov     eax, [ebp-4]
    lea     ebx, [ebp-4]
    lea     ecx, [eax+eax*2]
    dec     eax
    lea     esi, [ebp+ecx*4+0]
    js      short loc_42A89F
    lea     edi, [eax+1]

    loc_42A892:                             ; CODE XREF: .text:0042A89Dj
    sub     esi, 0Ch
    mov     ecx, esi
    call    sub_4C2EB0
    dec     edi
    jnz     short loc_42A892

    loc_42A89F:                             ; CODE XREF: .text:0042A88Dj
    push    ebx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42A8B1:                             ; CODE XREF: .text:0042A87Dj
    mov     ecx, ebp
    call    sub_4C2EB0
    test    bl, 1
    jz      short loc_42A8C6
    push    ebp
    call    sub_4B4F20
    add     esp, 4

    loc_42A8C6:                             ; CODE XREF: .text:0042A8BBj
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_42A8D0 proc near                    ; CODE XREF: .text:0042BD29p

    var_378= qword ptr -378h
    var_360= dword ptr -360h
    var_35C= dword ptr -35Ch
    var_358= dword ptr -358h
    var_354= dword ptr -354h
    var_350= dword ptr -350h
    var_34C= dword ptr -34Ch
    var_348= dword ptr -348h
    var_342= byte ptr -342h
    var_341= byte ptr -341h
    var_340= dword ptr -340h
    var_33C= dword ptr -33Ch
    var_338= dword ptr -338h
    var_334= dword ptr -334h
    var_330= dword ptr -330h
    var_32C= dword ptr -32Ch
    var_328= dword ptr -328h
    var_324= dword ptr -324h
    var_320= dword ptr -320h
    var_31C= dword ptr -31Ch
    var_318= qword ptr -318h
    var_310= byte ptr -310h
    var_300= dword ptr -300h
    var_249= dword ptr -249h
    var_200= byte ptr -200h
    var_100= dword ptr -100h
    arg_18= byte ptr  20h
    arg_78= byte ptr  80h
    arg_98= byte ptr  0A0h
    arg_B6= byte ptr  0BEh
    arg_F6= byte ptr  0FEh
    arg_136= dword ptr  13Eh
    arg_13E= dword ptr  146h
    arg_152= dword ptr  15Ah
    arg_17E= dword ptr  186h
    arg_182= dword ptr  18Ah
    arg_216= word ptr  21Eh
    arg_239= dword ptr  241h
    arg_23D= dword ptr  245h

    push    ebp
    mov     ebp, esp
    and     esp, 0FFFFFFF8h
    sub     esp, 360h
    mov     al, [esp+360h+var_341]
    push    ebx
    push    ebp
    push    esi
    lea     ecx, [esp+36Ch+var_358]
    push    edi
    xor     ebx, ebx
    push    ecx
    push    ebx
    push    offset aWeapons_tdf             ; "Weapons\\*.tdf"
    mov     [esp+37Ch+var_33C], ebx
    mov     byte ptr [esp+37Ch+var_358], al
    mov     [esp+37Ch+var_354], ebx
    mov     [esp+37Ch+var_350], ebx
    mov     [esp+37Ch+var_34C], ebx
    call    sub_4BCA30
    lea     ecx, [esp+370h+var_358]
    call    sub_432BE0
    test    eax, eax
    lea     ecx, [esp+370h+var_358]
    jnz     short loc_42A925
    call    sub_432BA0
    jmp     loc_42A9DF
    ; ---------------------------------------------------------------------------

    loc_42A925:                             ; CODE XREF: sub_42A8D0+49j
    call    sub_432BE0
    lea     edx, [eax+eax*2]
    mov     dword_5122A8, eax
    mov     edi, eax
    lea     eax, ds:4[edx*4]
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_42A963
    push    offset sub_4C2EA0
    lea     esi, [eax+4]
    push    edi
    push    0Ch
    push    esi
    mov     [eax], edi
    call    sub_401000
    mov     dword_5122A0, esi
    jmp     short loc_42A969
    ; ---------------------------------------------------------------------------

    loc_42A963:                             ; CODE XREF: sub_42A8D0+76j
    mov     dword_5122A0, ebx

    loc_42A969:                             ; CODE XREF: sub_42A8D0+91j
    mov     edi, [esp+370h+var_354]
    mov     eax, [esp+370h+var_350]
    cmp     edi, eax
    jnb     short loc_42A9D4

    loc_42A975:                             ; CODE XREF: sub_42A8D0+102j
    mov     eax, dword_5122A4
    mov     edx, dword_5122A0
    push    offset off_50341C
    lea     ecx, [eax+eax*2]
    mov     eax, [edi]
    push    eax
    push    offset aWeapons                 ; "Weapons"
    lea     esi, [edx+ecx*4]
    lea     ecx, [esp+37Ch+var_200]
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+370h+var_200]
    mov     ecx, esi
    push    edx
    call    sub_4C2F60
    test    eax, eax
    jz      short loc_42A9C9
    mov     eax, [esi+8]
    test    eax, eax
    jnz     short loc_42A9C3
    call    sub_41D8A0
    test    eax, eax
    jnz     short loc_42A9C9

    loc_42A9C3:                             ; CODE XREF: sub_42A8D0+E8j
    inc     dword_5122A4

    loc_42A9C9:                             ; CODE XREF: sub_42A8D0+E1j
                                            ; sub_42A8D0+F1j
    mov     eax, [esp+370h+var_350]
    add     edi, 4
    cmp     edi, eax
    jb      short loc_42A975

    loc_42A9D4:                             ; CODE XREF: sub_42A8D0+A3j
    lea     ecx, [esp+370h+var_358]
    call    sub_432BA0
    xor     ebx, ebx

    loc_42A9DF:                             ; CODE XREF: sub_42A8D0+50j
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+1439Bh]
    cmp     eax, ebx
    jz      short loc_42AA17
    push    eax                             ; wint_t
    call    _iswdigit
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     edx, [ecx+1439Bh]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     [eax+1439Bh], ebx

    loc_42AA17:                             ; CODE XREF: sub_42A8D0+11Cj
    push    offset off_503928
    push    offset asc_50372C               ; "*"
    lea     ecx, [esp+378h+var_300]
    push    offset aUnits                   ; "units"
    push    ecx
    call    sub_4290F0
    lea     eax, [esp+370h+var_338]
    lea     ecx, [esp+370h+var_300]
    mov     dl, [esp+370h+var_341]
    push    eax
    push    ebx
    push    ecx
    mov     byte ptr [esp+37Ch+var_338], dl
    mov     [esp+37Ch+var_334], ebx
    mov     [esp+37Ch+var_330], ebx
    mov     [esp+37Ch+var_32C], ebx
    call    sub_4BCA30
    mov     eax, [esp+370h+var_334]
    cmp     eax, ebx
    jz      short loc_42AA65
    mov     ebx, [esp+370h+var_330]
    sub     ebx, eax
    sar     ebx, 2

    loc_42AA65:                             ; CODE XREF: sub_42A8D0+18Aj
    inc     ebx
    mov     edx, TAdynmemStructPtr
    mov     eax, ebx
    mov     [esp+370h+var_324], ebx
    shl     eax, 6
    add     eax, ebx
    mov     [edx+1438Fh], ebx
    lea     ebp, [eax+eax*8]
    push    ebp
    push    offset aUnitinfo                ; "UNITINFO"
    mov     [esp+378h+var_340], ebp
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [ecx+1439Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, ebp
    xor     eax, eax
    mov     edi, [edx+1439Bh]
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    push    offset a0000                    ; char *
    and     ecx, 3
    push    offset aCopyright0000H          ; char *
    rep stosb
    mov     eax, TAdynmemStructPtr
    mov     edi, offset aNone               ; "None"
    or      ecx, 0FFFFFFFFh
    mov     edx, [eax+1439Bh]
    xor     eax, eax
    add     edx, 20h
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+1439Bh]
    or      dword ptr [eax+241h], 800000h
    call    _strstr
    mov     esi, 1
    add     esp, 8
    sub     eax, offset aCopyright0000H     ; "Copyright 0000 Humongous Entertainment."...
    cmp     ebx, esi
    mov     [esp+370h+var_320], eax
    mov     [esp+370h+var_328], esi
    jle     loc_42B20A
    mov     ecx, esi

    loc_42AB30:                             ; CODE XREF: sub_42A8D0+8DEj
    mov     eax, ecx
    lea     ebx, ds:0[ecx*4]
    shl     eax, 6
    add     eax, ecx
    push    offset off_503928
    lea     edx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     ebp, [eax+1439Bh]
    mov     [ebp+edx+arg_216], si
    mov     ecx, [esp+374h+var_334]
    add     ebp, edx
    lea     edx, [esp+374h+var_300]
    mov     eax, [ebx+ecx-4]
    push    eax
    push    offset aUnits                   ; "units"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+370h+var_300]
    push    eax
    call    sub_4BB5B0
    mov     edi, eax
    test    edi, edi
    mov     [esp+370h+var_31C], edi
    jz      loc_42B19B
    push    edi
    call    sub_4BBD00
    mov     esi, eax
    lea     ecx, [esp+370h+var_300]
    push    esi
    push    ecx
    call    sub_4D83B0
    add     esp, 8
    mov     [esp+370h+var_348], eax
    push    esi
    push    eax
    push    edi
    call    sub_4BB7C0
    push    esi
    mov     edx, [esp+374h+var_348]
    push    edx
    call    sub_4B6BA0
    lea     ecx, [esp+370h+var_35C]
    mov     [ebp+arg_136], eax
    call    sub_4B3620
    mov     eax, [esp+370h+var_334]
    push    offset off_5038C0
    lea     ecx, [esp+374h+var_100]
    mov     ebx, [ebx+eax-4]
    push    ebx
    push    offset aUnits                   ; "units"
    push    ecx
    call    sub_4290F0
    push    0
    lea     edx, [esp+374h+var_100]
    push    offset aTaUnitOverride          ; "TA Unit Override"
    push    edx
    lea     ecx, [esp+37Ch+var_35C]
    call    sub_4B3770
    test    eax, eax
    jz      short loc_42AC49
    push    offset aCompatability           ; char *
    lea     ecx, [esp+374h+var_35C]
    call    sub_4B4560
    test    eax, eax
    jz      short loc_42AC49
    mov     eax, [ebp+arg_136]
    lea     ecx, [esp+370h+var_310]
    push    eax
    push    offset aU                       ; "%u"
    push    ecx
    call    _sprintf
    mov     edx, [ebp+arg_136]
    add     esp, 0Ch
    lea     eax, [esp+370h+var_310]
    lea     ecx, [esp+370h+var_35C]
    push    edx                             ; int
    push    eax                             ; char *
    call    sub_4B4800
    mov     [ebp+arg_136], eax

    loc_42AC49:                             ; CODE XREF: sub_42A8D0+331j
                                            ; sub_42A8D0+343j
    lea     ecx, [esp+370h+var_358]
    call    sub_4C2EA0
    push    offset aNoFile                  ; "<NO FILE>"
    push    0
    push    esi
    mov     esi, [esp+37Ch+var_348]
    push    esi
    lea     ecx, [esp+380h+var_358]
    call    sub_4C3120
    push    offset aUnitinfo                ; char *
    lea     ecx, [esp+374h+var_358]
    call    sub_4C3410
    test    eax, eax
    jz      loc_42B1BC
    push    0
    push    20h
    push    offset aName                    ; "name"
    lea     ecx, [esp+37Ch+var_358]
    push    ebp
    push    ecx
    call    sub_4C58A0
    push    offset Data                     ; int
    lea     edi, [ebp+arg_18]
    mov     ecx, [esp+374h+var_354]
    push    20h                             ; size_t
    push    offset aUnitname                ; char *
    push    edi                             ; char *
    call    sub_4C48C0
    push    offset Data                     ; int
    push    1Eh                             ; size_t
    mov     ecx, [esp+378h+var_354]
    lea     edx, [ebp+arg_98]
    push    offset aSide                    ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    push    offset Data                     ; int
    push    40h                             ; size_t
    mov     ecx, [esp+378h+var_354]
    lea     eax, [ebp+arg_B6]
    push    offset aAi_weight               ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    push    offset Data                     ; int
    push    40h                             ; size_t
    lea     ecx, [ebp+arg_F6]
    push    offset aAi_limit                ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+380h+var_354]
    call    sub_4C48C0
    push    offset Data                     ; int
    lea     ebx, [ebp+arg_78]
    mov     ecx, [esp+374h+var_354]
    push    20h                             ; size_t
    push    offset aObjectname              ; char *
    push    ebx                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jnz     short loc_42AD3A
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_42AD3A:                             ; CODE XREF: sub_42A8D0+44Dj
    mov     ecx, [esp+370h+var_354]
    push    0                               ; int
    push    offset aBuildcostenerg          ; char *
    call    sub_4C46C0
    push    0                               ; int
    push    offset aBuildcostmetal          ; char *
    mov     ecx, [esp+378h+var_354]
    mov     [esp+378h+var_360], eax
    fild    [esp+378h+var_360]
    fstp    [ebp+arg_17E]
    call    sub_4C46C0
    push    0                               ; int
    push    offset aNorestrict              ; char *
    mov     ecx, [esp+378h+var_354]
    mov     [esp+378h+var_360], eax
    fild    [esp+378h+var_360]
    fstp    [ebp+arg_182]
    call    sub_4C46C0
    mov     ecx, [ebp+arg_23D]
    and     eax, 1
    and     ch, 7Fh
    push    0                               ; int
    shl     eax, 0Fh
    or      ecx, eax
    push    offset aWacky                   ; char *
    mov     [ebp+arg_23D], ecx
    mov     ecx, [esp+378h+var_354]
    call    sub_4C46C0
    mov     edx, [ebp+arg_23D]
    and     eax, 1
    mov     ecx, [esp+370h+var_354]
    and     edx, 0FFFEFFFFh
    shl     eax, 10h
    or      eax, edx
    push    offset aWeapon1                 ; char *
    mov     [ebp+arg_23D], eax
    call    sub_4C4630
    mov     esi, eax
    xor     eax, eax
    cmp     esi, eax
    jz      short loc_42AE29
    cmp     byte ptr [esi], 0
    jz      short loc_42AE29
    mov     ecx, dword_5122A4
    mov     [esp+370h+var_360], eax
    cmp     ecx, eax
    jle     short loc_42AE27
    xor     ebx, ebx

    loc_42ADF2:                             ; CODE XREF: sub_42A8D0+555j
    mov     eax, dword_5122A0
    lea     edi, [ebx+eax]
    mov     ecx, edi
    call    sub_4C3E10
    push    esi                             ; char *
    mov     ecx, edi
    call    sub_4C3410
    test    eax, eax
    jnz     loc_42B364
    mov     eax, [esp+370h+var_360]
    mov     ecx, dword_5122A4
    inc     eax
    add     ebx, 0Ch
    cmp     eax, ecx
    mov     [esp+370h+var_360], eax
    jl      short loc_42ADF2

    loc_42AE27:                             ; CODE XREF: sub_42A8D0+51Ej
    xor     eax, eax

    loc_42AE29:                             ; CODE XREF: sub_42A8D0+50Bj
                                            ; sub_42A8D0+510j ...
    mov     esi, [ebp+arg_13E]
    mov     ecx, [esp+370h+var_354]
    xor     esi, eax
    push    offset aWeapon2                 ; char *
    mov     [ebp+arg_13E], esi
    call    sub_4C4630
    mov     ebx, eax
    xor     eax, eax
    cmp     ebx, eax
    jz      short loc_42AEA0
    cmp     byte ptr [ebx], 0
    jz      short loc_42AEA0
    mov     ecx, dword_5122A4
    mov     [esp+370h+var_360], eax
    cmp     ecx, eax
    jle     short loc_42AE9E
    xor     edi, edi

    loc_42AE62:                             ; CODE XREF: sub_42A8D0+5C2j
    mov     edx, dword_5122A0
    lea     esi, [edi+edx]
    mov     ecx, esi
    call    sub_4C3E10
    push    ebx                             ; char *
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_42AE96
    mov     eax, [esp+370h+var_360]
    mov     ecx, dword_5122A4
    inc     eax
    add     edi, 0Ch
    cmp     eax, ecx
    mov     [esp+370h+var_360], eax
    jl      short loc_42AE62
    jmp     short loc_42AE9E
    ; ---------------------------------------------------------------------------

    loc_42AE96:                             ; CODE XREF: sub_42A8D0+5ACj
    mov     eax, [esi+4]
    mov     eax, [eax+25h]
    jmp     short loc_42AEA0
    ; ---------------------------------------------------------------------------

    loc_42AE9E:                             ; CODE XREF: sub_42A8D0+58Ej
                                            ; sub_42A8D0+5C4j
    xor     eax, eax

    loc_42AEA0:                             ; CODE XREF: sub_42A8D0+57Bj
                                            ; sub_42A8D0+580j ...
    mov     esi, [ebp+arg_13E]
    mov     ecx, [esp+370h+var_354]
    xor     esi, eax
    push    offset aWeapon3                 ; char *
    mov     [ebp+arg_13E], esi
    call    sub_4C4630
    mov     ebx, eax
    xor     eax, eax
    cmp     ebx, eax
    jz      short loc_42AF17
    cmp     byte ptr [ebx], 0
    jz      short loc_42AF17
    mov     ecx, dword_5122A4
    mov     [esp+370h+var_360], eax
    cmp     ecx, eax
    jle     short loc_42AF15
    xor     edi, edi

    loc_42AED9:                             ; CODE XREF: sub_42A8D0+639j
    mov     ecx, dword_5122A0
    lea     esi, [edi+ecx]
    mov     ecx, esi
    call    sub_4C3E10
    push    ebx                             ; char *
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_42AF0D
    mov     eax, [esp+370h+var_360]
    mov     ecx, dword_5122A4
    inc     eax
    add     edi, 0Ch
    cmp     eax, ecx
    mov     [esp+370h+var_360], eax
    jl      short loc_42AED9
    jmp     short loc_42AF15
    ; ---------------------------------------------------------------------------

    loc_42AF0D:                             ; CODE XREF: sub_42A8D0+623j
    mov     edx, [esi+4]
    mov     eax, [edx+25h]
    jmp     short loc_42AF17
    ; ---------------------------------------------------------------------------

    loc_42AF15:                             ; CODE XREF: sub_42A8D0+605j
                                            ; sub_42A8D0+63Bj
    xor     eax, eax

    loc_42AF17:                             ; CODE XREF: sub_42A8D0+5F2j
                                            ; sub_42A8D0+5F7j ...
    mov     esi, [ebp+arg_13E]
    mov     ecx, [esp+370h+var_354]
    xor     esi, eax
    push    offset aExplodeas               ; char *
    mov     [ebp+arg_13E], esi
    call    sub_4C4630
    mov     ebx, eax
    xor     eax, eax
    cmp     ebx, eax
    jz      short loc_42AF8D
    cmp     byte ptr [ebx], 0
    jz      short loc_42AF8D
    mov     ecx, dword_5122A4
    mov     [esp+370h+var_360], eax
    cmp     ecx, eax
    jle     short loc_42AF8B
    xor     edi, edi

    loc_42AF50:                             ; CODE XREF: sub_42A8D0+6AFj
    mov     eax, dword_5122A0
    lea     esi, [edi+eax]
    mov     ecx, esi
    call    sub_4C3E10
    push    ebx                             ; char *
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_42AF83
    mov     eax, [esp+370h+var_360]
    mov     ecx, dword_5122A4
    inc     eax
    add     edi, 0Ch
    cmp     eax, ecx
    mov     [esp+370h+var_360], eax
    jl      short loc_42AF50
    jmp     short loc_42AF8B
    ; ---------------------------------------------------------------------------

    loc_42AF83:                             ; CODE XREF: sub_42A8D0+699j
    mov     ecx, [esi+4]
    mov     eax, [ecx+25h]
    jmp     short loc_42AF8D
    ; ---------------------------------------------------------------------------

    loc_42AF8B:                             ; CODE XREF: sub_42A8D0+67Cj
                                            ; sub_42A8D0+6B1j
    xor     eax, eax

    loc_42AF8D:                             ; CODE XREF: sub_42A8D0+669j
                                            ; sub_42A8D0+66Ej ...
    mov     esi, [ebp+arg_13E]
    mov     ecx, [esp+370h+var_354]
    xor     esi, eax
    push    offset aSelfdestructas          ; char *
    mov     [ebp+arg_13E], esi
    call    sub_4C4630
    mov     ebx, eax
    xor     eax, eax
    cmp     ebx, eax
    jz      short loc_42B004
    cmp     byte ptr [ebx], 0
    jz      short loc_42B004
    mov     ecx, dword_5122A4
    mov     [esp+370h+var_360], eax
    cmp     ecx, eax
    jle     short loc_42B002
    xor     edi, edi

    loc_42AFC6:                             ; CODE XREF: sub_42A8D0+726j
    mov     edx, dword_5122A0
    lea     esi, [edi+edx]
    mov     ecx, esi
    call    sub_4C3E10
    push    ebx                             ; char *
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_42AFFA
    mov     eax, [esp+370h+var_360]
    mov     ecx, dword_5122A4
    inc     eax
    add     edi, 0Ch
    cmp     eax, ecx
    mov     [esp+370h+var_360], eax
    jl      short loc_42AFC6
    jmp     short loc_42B002
    ; ---------------------------------------------------------------------------

    loc_42AFFA:                             ; CODE XREF: sub_42A8D0+710j
    mov     eax, [esi+4]
    mov     eax, [eax+25h]
    jmp     short loc_42B004
    ; ---------------------------------------------------------------------------

    loc_42B002:                             ; CODE XREF: sub_42A8D0+6F2j
                                            ; sub_42A8D0+728j
    xor     eax, eax

    loc_42B004:                             ; CODE XREF: sub_42A8D0+6DFj
                                            ; sub_42A8D0+6E4j ...
    mov     edx, [ebp+arg_13E]
    mov     ecx, [esp+370h+var_354]
    push    0
    xor     edx, eax
    push    0                               ; __int64
    push    offset aVersion                 ; char *
    mov     [ebp+arg_13E], edx
    call    sub_4C4760
    fstp    [esp+370h+var_318]
    mov     ecx, dword ptr [esp+370h+var_318+4]
    mov     edx, dword ptr [esp+370h+var_318]
    push    ecx
    push    edx
    call    _floor
    add     esp, 8
    call    __ftol
    mov     esi, eax
    sub     esp, 8
    mov     [esp+378h+var_360], esi
    fild    [esp+378h+var_360]
    fsubr   [esp+378h+var_318]
    fmul    ds:dbl_4FD208
    fstp    [esp+378h+var_378]
    call    _floor
    add     esp, 8
    call    __ftol
    mov     edx, TAdynmemStructPtr
    movsx   ecx, byte ptr [edx+1]
    cmp     esi, ecx
    jge     short loc_42B081
    mov     eax, [ebp+arg_239]
    or      eax, 800000h
    jmp     short loc_42B0A3
    ; ---------------------------------------------------------------------------

    loc_42B081:                             ; CODE XREF: sub_42A8D0+7A2j
    jnz     short loc_42B098
    movsx   ecx, byte ptr [edx+2]
    cmp     eax, ecx
    jg      short loc_42B098
    mov     eax, [ebp+arg_239]
    or      eax, 800000h
    jmp     short loc_42B0A3
    ; ---------------------------------------------------------------------------

    loc_42B098:                             ; CODE XREF: sub_42A8D0+7B1j
                                            ; sub_42A8D0+7B9j
    mov     eax, [ebp+arg_239]
    and     eax, 0FF7FFFFFh

    loc_42B0A3:                             ; CODE XREF: sub_42A8D0+7AFj
                                            ; sub_42A8D0+7C6j
    mov     edi, [esp+370h+var_31C]
    mov     [ebp+arg_239], eax
    push    edi
    call    sub_4BB650
    test    eax, eax
    jnz     short loc_42B0C0
    call    sub_41D8A0
    test    eax, eax
    jnz     short loc_42B0C9

    loc_42B0C0:                             ; CODE XREF: sub_42A8D0+7E5j
    call    sub_41D8B0
    test    eax, eax
    jz      short loc_42B0E2

    loc_42B0C9:                             ; CODE XREF: sub_42A8D0+7EEj
    mov     eax, [ebp+arg_239]
    mov     [esp+370h+var_33C], 1
    and     eax, 0FF7FFFFFh
    mov     [ebp+arg_239], eax

    loc_42B0E2:                             ; CODE XREF: sub_42A8D0+7F7j
    mov     ecx, [esp+370h+var_354]
    push    offset aRunToTheVillag          ; int
    push    80h                             ; size_t
    lea     edx, [esp+378h+var_200]
    push    offset aCopyright               ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    mov     eax, dword ptr a0000            ; "0000"
    mov     esi, offset aCopyright0000H     ; "Copyright 0000 Humongous Entertainment."...
    mov     ecx, [esp+370h+var_320]
    mov     dword ptr [esp+ecx+370h+var_200], eax
    lea     eax, [esp+370h+var_200]

    loc_42B11E:                             ; CODE XREF: sub_42A8D0+870j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_42B146
    test    cl, cl
    jz      short loc_42B142
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_42B146
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_42B11E

    loc_42B142:                             ; CODE XREF: sub_42A8D0+85Aj
    xor     eax, eax
    jmp     short loc_42B14B
    ; ---------------------------------------------------------------------------

    loc_42B146:                             ; CODE XREF: sub_42A8D0+856j
                                            ; sub_42A8D0+866j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_42B14B:                             ; CODE XREF: sub_42A8D0+874j
    test    eax, eax
    jz      short loc_42B168
    mov     eax, [ebp+arg_239]
    mov     [esp+370h+var_33C], 1
    and     eax, 0FF7FFFFFh
    mov     [ebp+arg_239], eax

    loc_42B168:                             ; CODE XREF: sub_42A8D0+87Dj
    push    edi
    mov     [ebp+arg_152], 0FFFFFFFFh
    call    sub_4BB5D0
    mov     eax, [esp+370h+var_348]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    lea     ecx, [esp+370h+var_358]
    call    sub_4C2EB0
    lea     ecx, [esp+370h+var_35C]
    call    sub_4B3630
    mov     esi, [esp+370h+var_328]

    loc_42B19B:                             ; CODE XREF: sub_42A8D0+2B5j
    mov     eax, [esp+370h+var_324]
    inc     esi
    mov     ecx, esi
    mov     [esp+370h+var_328], esi
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      loc_42AB30
    mov     ebp, [esp+370h+var_340]
    mov     ebx, eax
    jmp     short loc_42B20A
    ; ---------------------------------------------------------------------------

    loc_42B1BC:                             ; CODE XREF: sub_42A8D0+3A8j
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    lea     ecx, [esp+370h+var_358]
    call    sub_4C2EB0
    lea     ecx, [esp+370h+var_35C]
    call    sub_4B3630
    mov     edi, [esp+370h+var_330]
    mov     esi, [esp+370h+var_334]
    cmp     esi, edi
    jz      short loc_42B1F7

    loc_42B1E3:                             ; CODE XREF: sub_42A8D0+921j
    push    0
    mov     ecx, esi
    call    sub_432C00
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_42B1E3
    mov     esi, [esp+370h+var_334]

    loc_42B1F7:                             ; CODE XREF: sub_42A8D0+911j
    push    esi
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------

    loc_42B20A:                             ; CODE XREF: sub_42A8D0+258j
                                            ; sub_42A8D0+8EAj
    mov     edi, dword_5122A0
    xor     eax, eax
    cmp     edi, eax
    jz      short loc_42B248
    mov     eax, [edi-4]
    lea     ecx, [edi-4]
    mov     [esp+370h+var_340], ecx
    lea     edx, [eax+eax*2]
    dec     eax
    lea     edi, [edi+edx*4]
    js      short loc_42B23D
    lea     esi, [eax+1]

    loc_42B22C:                             ; CODE XREF: sub_42A8D0+967j
    sub     edi, 0Ch
    mov     ecx, edi
    call    sub_4C2EB0
    dec     esi
    jnz     short loc_42B22C
    mov     ecx, [esp+370h+var_340]

    loc_42B23D:                             ; CODE XREF: sub_42A8D0+957j
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax

    loc_42B248:                             ; CODE XREF: sub_42A8D0+944j
    lea     edi, [ebx-1]
    mov     dword_5122A0, eax
    cmp     di, ax
    mov     dword_5122A4, eax
    mov     dword_5122A8, eax
    mov     [esp+370h+var_340], ebx
    jbe     loc_42B2EA
    mov     ecx, edi
    and     ecx, 0FFFFh
    mov     eax, ecx
    mov     [esp+370h+var_348], ecx
    shl     eax, 6
    add     eax, ecx
    lea     eax, [eax+eax*8]
    mov     [esp+370h+var_35C], eax

    loc_42B281:                             ; CODE XREF: sub_42A8D0+A18j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+370h+var_35C]
    mov     eax, [ecx+1439Bh]
    mov     ecx, [edx+eax+241h]
    test    ecx, 800000h
    lea     esi, [edx+eax]
    jnz     short loc_42B2C8
    mov     ecx, [esp+370h+var_348]
    dec     ebx
    cmp     ecx, ebx
    jz      short loc_42B2C2
    lea     eax, [ebp+eax+var_249]
    mov     ecx, esi
    push    eax
    call    sub_42B370
    mov     [esi+21Eh], di

    loc_42B2C2:                             ; CODE XREF: sub_42A8D0+9DAj
    sub     ebp, 249h

    loc_42B2C8:                             ; CODE XREF: sub_42A8D0+9D1j
    mov     edx, [esp+370h+var_348]
    mov     ecx, [esp+370h+var_35C]
    add     edi, 0FFFFh
    dec     edx
    sub     ecx, 249h
    mov     [esp+370h+var_348], edx
    test    di, di
    mov     [esp+370h+var_35C], ecx
    ja      short loc_42B281

    loc_42B2EA:                             ; CODE XREF: sub_42A8D0+991j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+370h+var_340]
    cmp     eax, ebx
    mov     [ecx+1438Fh], ebx
    jz      short loc_42B31B
    mov     eax, [esp+370h+var_33C]
    test    eax, eax
    jnz     short loc_42B31B
    push    offset Data
    push    offset aIncompatibleUn          ; int
    call    sub_4C5740
    push    eax                             ; lpText
    call    sub_4B6B80

    loc_42B31B:                             ; CODE XREF: sub_42A8D0+A2Cj
                                            ; sub_42A8D0+A34j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1439Bh]
    push    eax                             ; wint_t
    call    _iswlower
    mov     edi, [esp+378h+var_334]
    mov     esi, [esp+378h+var_338]
    add     esp, 4
    cmp     esi, edi
    jz      short loc_42B34E

    loc_42B33C:                             ; CODE XREF: sub_42A8D0+A78j
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_42B33C
    mov     esi, [esp+374h+var_338]

    loc_42B34E:                             ; CODE XREF: sub_42A8D0+A6Aj
    push    esi
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------

    loc_42B364:                             ; CODE XREF: sub_42A8D0+53Bj
    mov     ecx, [edi+4]
    mov     eax, [ecx+25h]
    jmp     loc_42AE29
    sub_42A8D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42B370 proc near                    ; CODE XREF: sub_42A8D0+9E6p
                                            ; sub_42D2E0+221p ...

    arg_0= dword ptr  4

    mov     eax, ecx
    push    ebx
    mov     ecx, [esp+4+arg_0]
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     edi, eax
    sub     esi, eax
    mov     ebp, 20h

    loc_42B385:                             ; CODE XREF: sub_42B370+1Cj
    mov     dl, [esi+edi]
    mov     [edi], dl
    inc     edi
    dec     ebp
    jnz     short loc_42B385
    mov     ebp, 0FFFFFFE0h
    lea     edi, [eax+20h]
    sub     ebp, eax

    loc_42B398:                             ; CODE XREF: sub_42B370+35j
    mov     dl, [edi+esi]
    mov     [edi], dl
    inc     edi
    lea     edx, [ebp+edi+0]
    cmp     edx, 20h
    jb      short loc_42B398
    mov     ebp, 0FFFFFFC0h
    lea     edi, [eax+40h]
    sub     ebp, eax

    loc_42B3B1:                             ; CODE XREF: sub_42B370+4Ej
    mov     dl, [edi+esi]
    mov     [edi], dl
    inc     edi
    lea     edx, [ebp+edi+0]
    cmp     edx, 40h
    jb      short loc_42B3B1
    mov     ebp, 0FFFFFF80h
    lea     edi, [eax+80h]
    sub     ebp, eax

    loc_42B3CD:                             ; CODE XREF: sub_42B370+6Aj
    mov     dl, [edi+esi]
    mov     [edi], dl
    inc     edi
    lea     edx, [ebp+edi+0]
    cmp     edx, 20h
    jb      short loc_42B3CD
    mov     ebp, 0FFFFFF60h
    lea     edi, [eax+0A0h]
    sub     ebp, eax

    loc_42B3E9:                             ; CODE XREF: sub_42B370+86j
    mov     dl, [edi+esi]
    mov     [edi], dl
    inc     edi
    lea     edx, [ebp+edi+0]
    cmp     edx, 1Eh
    jb      short loc_42B3E9
    mov     ebp, 0FFFFFF42h
    lea     edi, [eax+0BEh]
    sub     ebp, eax

    loc_42B405:                             ; CODE XREF: sub_42B370+A2j
    mov     dl, [edi+esi]
    mov     [edi], dl
    inc     edi
    lea     edx, [ebp+edi+0]
    cmp     edx, 40h
    jb      short loc_42B405
    mov     ebp, 0FFFFFF02h
    lea     edi, [eax+0FEh]
    sub     ebp, eax

    loc_42B421:                             ; CODE XREF: sub_42B370+BEj
    mov     dl, [edi+esi]
    mov     [edi], dl
    inc     edi
    lea     edx, [ebp+edi+0]
    cmp     edx, 40h
    jb      short loc_42B421
    mov     edx, [ecx+13Eh]
    lea     edi, [eax+15Eh]
    mov     [eax+13Eh], edx
    mov     edx, [ecx+142h]
    mov     [eax+142h], edx
    mov     edx, [ecx+146h]
    mov     [eax+146h], edx
    mov     edx, [ecx+14Ah]
    mov     [eax+14Ah], edx
    mov     edx, [ecx+14Eh]
    mov     [eax+14Eh], edx
    mov     edx, [ecx+152h]
    mov     [eax+152h], edx
    mov     edx, [ecx+156h]
    mov     [eax+156h], edx
    mov     edx, [ecx+15Ah]
    mov     [eax+15Ah], edx
    lea     edx, [ecx+15Eh]
    mov     ebx, [ecx+15Eh]
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     edx, [edx+8]
    mov     [edi+8], edx
    lea     edx, [ecx+16Ah]
    lea     edi, [eax+16Ah]
    mov     ebx, [edx]
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     edx, [edx+8]
    mov     [edi+8], edx
    lea     edx, [ecx+176h]
    lea     edi, [eax+176h]
    mov     ebx, [edx]
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     edx, [edx+8]
    mov     [edi+8], edx
    mov     edx, [ecx+182h]
    mov     [eax+182h], edx
    mov     edx, [ecx+186h]
    mov     [eax+186h], edx
    mov     edx, [ecx+18Ah]
    mov     [eax+18Ah], edx
    mov     edx, [ecx+18Eh]
    mov     [eax+18Eh], edx
    mov     edx, [ecx+192h]
    mov     [eax+192h], edx
    mov     edx, [ecx+196h]
    mov     [eax+196h], edx
    mov     edx, [ecx+19Ah]
    mov     [eax+19Ah], edx
    mov     edx, [ecx+19Eh]
    mov     [eax+19Eh], edx
    mov     edx, [ecx+1A2h]
    mov     [eax+1A2h], edx
    mov     edx, [ecx+1A6h]
    mov     [eax+1A6h], edx
    mov     edx, [ecx+1AAh]
    mov     [eax+1AAh], edx
    mov     edx, [ecx+1AEh]
    mov     [eax+1AEh], edx
    mov     edx, [ecx+1B2h]
    mov     [eax+1B2h], edx
    mov     edx, [ecx+1B6h]
    mov     [eax+1B6h], edx
    mov     dx, [ecx+1BAh]
    mov     [eax+1BAh], dx
    mov     dx, [ecx+1BCh]
    mov     [eax+1BCh], dx
    mov     dx, [ecx+1BEh]
    mov     [eax+1BEh], dx
    mov     dx, [ecx+1C0h]
    mov     [eax+1C0h], dx
    mov     edx, [ecx+1C2h]
    mov     [eax+1C2h], edx
    mov     edx, [ecx+1C6h]
    mov     [eax+1C6h], edx
    mov     edx, [ecx+1CAh]
    mov     [eax+1CAh], edx
    mov     edx, [ecx+1CEh]
    mov     [eax+1CEh], edx
    mov     edx, [ecx+1D2h]
    mov     [eax+1D2h], edx
    mov     edx, [ecx+1D6h]
    mov     [eax+1D6h], edx
    mov     edx, [ecx+1DAh]
    mov     [eax+1DAh], edx
    mov     edx, [ecx+1DEh]
    mov     [eax+1DEh], edx
    mov     edx, [ecx+1E2h]
    mov     [eax+1E2h], edx
    mov     edx, [ecx+1E6h]
    mov     [eax+1E6h], edx
    mov     edx, [ecx+1EAh]
    mov     [eax+1EAh], edx
    lea     edx, [eax+1EEh]
    mov     edi, 3

    loc_42B657:                             ; CODE XREF: sub_42B370+2F0j
    mov     ebx, [edx+esi]
    mov     [edx], ebx
    add     edx, 4
    dec     edi
    jnz     short loc_42B657
    mov     edx, [ecx+1FAh]
    mov     edi, 3
    mov     [eax+1FAh], edx
    mov     dx, [ecx+1FEh]
    mov     [eax+1FEh], dx
    mov     dx, [ecx+200h]
    mov     [eax+200h], dx
    mov     dx, [ecx+202h]
    mov     [eax+202h], dx
    mov     dx, [ecx+204h]
    mov     [eax+204h], dx
    mov     dx, [ecx+206h]
    mov     [eax+206h], dx
    mov     dx, [ecx+208h]
    mov     [eax+208h], dx
    mov     dx, [ecx+20Ah]
    mov     [eax+20Ah], dx
    mov     dx, [ecx+20Ch]
    mov     [eax+20Ch], dx
    mov     dx, [ecx+20Eh]
    mov     [eax+20Eh], dx
    mov     dx, [ecx+210h]
    mov     [eax+210h], dx
    mov     dx, [ecx+212h]
    mov     [eax+212h], dx
    mov     dx, [ecx+214h]
    mov     [eax+214h], dx
    mov     dx, [ecx+216h]
    mov     [eax+216h], dx
    mov     dx, [ecx+218h]
    mov     [eax+218h], dx
    mov     dx, [ecx+21Ah]
    mov     [eax+21Ah], dx
    mov     dx, [ecx+21Ch]
    mov     [eax+21Ch], dx
    mov     dx, [ecx+21Eh]
    mov     [eax+21Eh], dx
    mov     edx, [ecx+220h]
    mov     [eax+220h], edx
    mov     edx, [ecx+224h]
    mov     [eax+224h], edx
    mov     dl, [ecx+228h]
    mov     [eax+228h], dl
    mov     dl, [ecx+229h]
    mov     [eax+229h], dl
    mov     dl, [ecx+22Ah]
    mov     [eax+22Ah], dl
    mov     dl, [ecx+22Bh]
    mov     [eax+22Bh], dl
    mov     dl, [ecx+22Ch]
    mov     [eax+22Ch], dl
    mov     dl, [ecx+22Dh]
    mov     [eax+22Dh], dl
    mov     dl, [ecx+22Eh]
    mov     [eax+22Eh], dl
    mov     dl, [ecx+22Fh]
    mov     [eax+22Fh], dl
    mov     dl, [ecx+230h]
    mov     [eax+230h], dl
    lea     edx, [eax+231h]

    loc_42B7EB:                             ; CODE XREF: sub_42B370+484j
    mov     ebx, [edx+esi]
    mov     [edx], ebx
    add     edx, 4
    dec     edi
    jnz     short loc_42B7EB
    mov     edx, [ecx+23Dh]
    mov     esi, [eax+241h]
    mov     [eax+23Dh], edx
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 3
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 0Ch
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 10h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 20h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 40h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 80h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 100h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 200h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 400h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 800h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 1000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 2000h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 4000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 8000h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 10000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 20000h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 40000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 80000h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 100000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 200000h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 400000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 800000h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 1000000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 2000000h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 4000000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 8000000h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 10000000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     ebx, [ecx+241h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 20000000h
    xor     esi, edx
    mov     [eax+241h], esi
    mov     ebx, [ecx+241h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 40000000h
    xor     edx, esi
    mov     [eax+241h], edx
    mov     esi, [ecx+241h]
    xor     edx, esi
    and     edx, 7FFFFFFFh
    xor     edx, esi
    mov     esi, [eax+245h]
    mov     [eax+241h], edx
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 1
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 2
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 4
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 8
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 10h
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 20h
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 40h
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 80h
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 100h
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 200h
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    pop     edi
    and     edx, 400h
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 800h
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 1000h
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 2000h
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 4000h
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 8000h
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 10000h
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 20000h
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 40000h
    xor     edx, esi
    mov     [eax+245h], edx
    mov     ebx, [ecx+245h]
    mov     esi, edx
    xor     esi, ebx
    and     esi, 80000h
    xor     esi, edx
    mov     [eax+245h], esi
    mov     ebx, [ecx+245h]
    mov     edx, esi
    xor     edx, ebx
    and     edx, 700000h
    xor     edx, esi
    pop     esi
    pop     ebp
    mov     [eax+245h], edx
    pop     ebx
    retn    4
    sub_42B370 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42BCC0 proc near                    ; CODE XREF: sub_4916A0+10Ap
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+1439Bh]
    test    eax, eax
    jz      short locret_42BD0C
    push    eax                             ; wint_t
    call    _iswdigit
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     edx, [ecx+1439Bh]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     dword ptr [eax+1439Bh], 0
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+1438Fh], 0

    locret_42BD0C:                          ; CODE XREF: sub_42BCC0+Dj
    retn
    sub_42BCC0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1438Fh]
    test    ecx, ecx
    jz      short loc_42BD29
    mov     ecx, [eax+14397h]
    test    ecx, ecx
    jz      short locret_42BD3D

    loc_42BD29:                             ; CODE XREF: .text:0042BD1Dj
    call    sub_42A8D0
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+14397h], 0

    locret_42BD3D:                          ; CODE XREF: .text:0042BD27j
    retn
    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 84h
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     dword ptr [esp+4], 0
    mov     ecx, [eax+1438Fh]
    mov     esi, [eax+1439Bh]
    test    ecx, ecx
    jle     loc_42BE19
    push    edi
    push    ebp
    push    ebx
    add     esi, 241h

    loc_42BD71:                             ; CODE XREF: .text:0042BE10j
    mov     ecx, [eax+391C7h]
    xor     ebp, ebp
    test    ecx, ecx
    jle     short loc_42BDF9
    lea     edi, [esi-221h]
    xor     ebx, ebx

    loc_42BD85:                             ; CODE XREF: .text:0042BDF7j
    mov     eax, [eax+391CBh]
    push    edi
    lea     ecx, [eax+ebx+8]
    push    ecx
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_42BDE5
    test    byte ptr [esi], 20h
    jnz     short loc_42BDE5
    push    edi
    lea     edx, [esp+18h]
    push    offset aHeySomebodyFor          ; "Hey!  Somebody forgot to set downloadab"...
    push    edx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     ecx, [eax+1439Bh]
    push    ecx
    call    _iswdigit
    mov     edx, [esi]
    add     esp, 4
    or      edx, 20h
    mov     [esi], edx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1439Bh]
    push    eax
    call    _iswlower
    add     esp, 4

    loc_42BDE5:                             ; CODE XREF: .text:0042BD9Bj
                                            ; .text:0042BDA0j
    mov     eax, TAdynmemStructPtr
    inc     ebp
    add     ebx, 0BDh
    cmp     ebp, [eax+391C7h]
    jl      short loc_42BD85

    loc_42BDF9:                             ; CODE XREF: .text:0042BD7Bj
    mov     ecx, [esp+10h]
    mov     edx, [eax+1438Fh]
    inc     ecx
    add     esi, 249h
    cmp     ecx, edx
    mov     [esp+10h], ecx
    jl      loc_42BD71
    pop     ebx
    pop     ebp
    pop     edi

    loc_42BE19:                             ; CODE XREF: .text:0042BD62j
    pop     esi
    add     esp, 84h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42BE30 proc near                    ; CODE XREF: sub_42DCF0+3EEp

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    mov     eax, TAdynmemStructPtr
    push    ebp
    mov     ecx, [eax+1439Bh]
    push    ecx                             ; wint_t
    call    _iswdigit
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     [esp+0Ch+var_8], 0
    mov     eax, [ecx+1438Fh]
    mov     ebp, [ecx+1439Bh]
    test    eax, eax
    jle     loc_42BF22
    push    edi
    push    esi
    push    ebx
    add     ebp, 152h

    loc_42BE73:                             ; CODE XREF: sub_42BE30+E9j
    mov     eax, [ebp+4]
    xor     esi, esi
    cmp     eax, esi
    jz      loc_42BF02
    mov     eax, [ecx+391C7h]
    mov     [esp+18h+var_4], esi
    cmp     eax, esi
    jle     short loc_42BF02

    loc_42BE8E:                             ; CODE XREF: sub_42BE30+D0j
    mov     eax, [ecx+391CBh]
    xor     ebx, ebx
    cmp     dword ptr [esi+eax], 0
    jle     short loc_42BEE9
    xor     edi, edi

    loc_42BE9E:                             ; CODE XREF: sub_42BE30+B7j
    lea     edx, [esi+edi]
    add     eax, edx
    xor     edx, edx
    mov     dx, [eax+4]
    cmp     [esp+18h+var_8], edx
    jnz     short loc_42BEDA
    cmp     dword ptr [ebp+0], 1Eh
    jg      short loc_42BEDA
    add     eax, 8
    push    eax                             ; char *
    call    sub_488B10
    test    ax, ax
    jz      short loc_42BED4
    mov     ecx, [ebp+0]
    mov     edx, [ebp+4]
    mov     [edx+ecx*2], ax
    mov     eax, [ebp+0]
    inc     eax
    mov     [ebp+0], eax

    loc_42BED4:                             ; CODE XREF: sub_42BE30+91j
    mov     ecx, TAdynmemStructPtr

    loc_42BEDA:                             ; CODE XREF: sub_42BE30+7Dj
                                            ; sub_42BE30+83j
    mov     eax, [ecx+391CBh]
    inc     ebx
    add     edi, 25h
    cmp     ebx, [esi+eax]
    jl      short loc_42BE9E

    loc_42BEE9:                             ; CODE XREF: sub_42BE30+6Aj
    mov     eax, [esp+18h+var_4]
    mov     edx, [ecx+391C7h]
    inc     eax
    add     esi, 0BDh
    cmp     eax, edx
    mov     [esp+18h+var_4], eax
    jl      short loc_42BE8E

    loc_42BF02:                             ; CODE XREF: sub_42BE30+4Aj
                                            ; sub_42BE30+5Cj
    mov     eax, [esp+18h+var_8]
    mov     edx, [ecx+1438Fh]
    inc     eax
    add     ebp, 249h
    cmp     eax, edx
    mov     [esp+18h+var_8], eax
    jl      loc_42BE73
    pop     ebx
    pop     esi
    pop     edi

    loc_42BF22:                             ; CODE XREF: sub_42BE30+34j
    mov     eax, [ecx+1439Bh]
    push    eax                             ; wint_t
    call    _iswlower
    add     esp, 4
    pop     ebp
    add     esp, 8
    retn
    sub_42BE30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42BF40 proc near                    ; CODE XREF: sub_42D1F0+79p
                                            ; sub_42D2E0+442p

    var_518= dword ptr -518h
    var_514= dword ptr -514h
    var_50C= dword ptr -50Ch
    var_505= byte ptr -505h
    var_4A0= dword ptr -4A0h
    var_480= byte ptr -480h
    var_400= byte ptr -400h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 518h
    lea     ecx, [esp+518h+var_518]
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4C2EA0
    mov     eax, [esp+528h+arg_0]
    lea     ecx, [esp+528h+var_518]
    push    eax
    call    sub_4C2F60
    test    eax, eax
    jz      loc_42D154
    push    offset aUnitinfo                ; char *
    lea     ecx, [esp+52Ch+var_518]
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_42BF8C
    lea     ecx, [esp+528h+var_518]
    call    sub_4C3240
    jmp     loc_42D154
    ; ---------------------------------------------------------------------------

    loc_42BF8C:                             ; CODE XREF: sub_42BF40+3Cj
    mov     ebp, [esp+528h+arg_4]
    mov     ecx, [esp+528h+var_514]
    push    offset Data                     ; int
    push    20h                             ; size_t
    lea     edi, [ebp+20h]
    push    offset aUnitname                ; char *
    push    edi                             ; char *
    call    sub_4C48C0
    push    0
    push    20h
    push    offset aName                    ; "name"
    lea     ecx, [esp+534h+var_518]
    push    ebp
    push    ecx
    call    sub_4C58A0
    push    0
    push    40h
    lea     edx, [ebp+40h]
    push    offset aDescription_0           ; "description"
    lea     eax, [esp+534h+var_518]
    push    edx
    push    eax
    call    sub_4C58A0
    push    offset Data                     ; int
    push    64h                             ; size_t
    lea     ecx, [esp+2Ch]
    push    offset aDefaultmission          ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+538h+var_514]
    call    sub_4C48C0
    lea     edx, [esp+24h]
    lea     ecx, [esp+528h+var_505]
    push    edx                             ; char *
    call    sub_438760
    push    offset aNone_0                  ; int
    push    64h                             ; size_t
    mov     al, [esp+530h+var_505]
    lea     ecx, [esp+2Ch]
    push    offset aWpri_badtarget          ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+538h+var_514]
    mov     [ebp+230h], al
    call    sub_4C48C0
    lea     edx, [esp+24h]
    push    edx                             ; char *
    call    sub_488C50
    mov     [ebp+231h], eax
    push    offset aNone_0                  ; int
    mov     ecx, [esp+52Ch+var_514]
    push    64h                             ; size_t
    lea     eax, [esp+2Ch]
    push    offset aWsec_badtarget          ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    lea     ecx, [esp+24h]
    push    ecx                             ; char *
    call    sub_488C50
    push    offset aNone_0                  ; int
    push    64h                             ; size_t
    mov     ecx, [esp+530h+var_514]
    lea     edx, [esp+2Ch]
    push    offset aWspe_badtarget          ; char *
    push    edx                             ; char *
    mov     [ebp+235h], eax
    call    sub_4C48C0
    lea     eax, [esp+24h]
    push    eax                             ; char *
    call    sub_488C50
    push    offset aNone_0                  ; int
    push    64h                             ; size_t
    lea     ecx, [esp+2Ch]
    push    offset aNochasecategor          ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+538h+var_514]
    mov     [ebp+239h], eax
    call    sub_4C48C0
    lea     edx, [esp+24h]
    push    edx                             ; char *
    call    sub_488C50
    mov     [ebp+23Dh], eax
    lea     ebx, [ebp+80h]
    mov     ecx, [esp+528h+var_514]
    push    offset Data                     ; int
    push    20h                             ; size_t
    push    offset aObjectname              ; char *
    push    ebx                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jnz     short loc_42C0EC
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_42C0EC:                             ; CODE XREF: sub_42BF40+18Fj
    mov     ecx, [esp+528h+var_514]
    xor     esi, esi
    push    esi                             ; int
    push    offset aBuildcostenerg          ; char *
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aBuildcostmetal          ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [esp+530h+var_50C], eax
    fild    [esp+530h+var_50C]
    fstp    dword ptr [ebp+186h]
    call    sub_4C46C0
    lea     ecx, [esp+528h+var_50C]
    mov     [esp+528h+var_50C], eax
    xor     eax, eax
    fild    [esp+528h+var_50C]
    push    eax                             ; int
    push    offset aMaxvelocity             ; char *
    push    ecx                             ; int
    mov     ecx, [esp+534h+var_514]
    fstp    dword ptr [ebp+18Ah]
    call    sub_4C4800
    mov     edx, [eax]
    xor     eax, eax
    mov     ecx, [esp+528h+var_514]
    push    eax                             ; int
    lea     eax, [esp+52Ch+var_50C]
    push    offset aBrakerate               ; char *
    push    eax                             ; int
    mov     [ebp+192h], edx
    call    sub_4C4800
    mov     ecx, [eax]
    xor     eax, eax
    push    eax                             ; int
    lea     edx, [esp+52Ch+var_50C]
    mov     [ebp+19Ah], ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aAcceleration            ; char *
    push    edx                             ; int
    call    sub_4C4800
    mov     eax, [eax]
    lea     ecx, [esp+528h+var_50C]
    mov     [ebp+19Eh], eax
    mov     eax, 10000h
    push    eax                             ; int
    push    offset aBankscale               ; char *
    push    ecx                             ; int
    mov     ecx, [esp+534h+var_514]
    call    sub_4C4800
    mov     edx, [eax]
    xor     eax, eax
    mov     ecx, [esp+528h+var_514]
    push    eax                             ; int
    lea     eax, [esp+52Ch+var_50C]
    push    offset aPitchscale              ; char *
    push    eax                             ; int
    mov     [ebp+1A2h], edx
    call    sub_4C4800
    mov     ecx, [eax]
    mov     eax, 10000h
    push    eax                             ; int
    lea     edx, [esp+52Ch+var_50C]
    mov     [ebp+1A6h], ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aDamagemodifier          ; char *
    push    edx                             ; int
    call    sub_4C4800
    mov     eax, [eax]
    lea     ecx, [esp+528h+var_50C]
    mov     [ebp+1AAh], eax
    mov     eax, [ebp+192h]
    shl     eax, 1
    push    eax                             ; int
    push    offset aMoverate1_0             ; char *
    push    ecx                             ; int
    mov     ecx, [esp+534h+var_514]
    call    sub_4C4800
    mov     edx, [eax]
    mov     [ebp+1AEh], edx
    mov     eax, [ebp+192h]
    shl     eax, 1
    mov     ecx, [esp+528h+var_514]
    push    eax                             ; int
    lea     eax, [esp+52Ch+var_50C]
    push    offset aMoverate2_0             ; char *
    push    eax                             ; int
    call    sub_4C4800
    mov     ecx, [eax]
    push    esi                             ; int
    mov     [ebp+1B2h], ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aTurnrate                ; char *
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aWaterline               ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+1BAh], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aTransportsize           ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+22Ch], al
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aTransportcapac          ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+22Ah], al
    call    sub_4C46C0
    push    esi
    push    esi                             ; __int64
    mov     ecx, [esp+530h+var_514]
    push    offset aEnergymake              ; char *
    mov     [ebp+22Bh], al
    call    sub_4C4760
    push    esi
    push    esi                             ; __int64
    mov     ecx, [esp+530h+var_514]
    push    offset aEnergyuse               ; char *
    fstp    dword ptr [ebp+1C2h]
    call    sub_4C4760
    push    esi
    push    esi                             ; __int64
    mov     ecx, [esp+530h+var_514]
    push    offset aMetalmake               ; char *
    fstp    dword ptr [ebp+1C6h]
    call    sub_4C4760
    push    esi
    push    esi                             ; __int64
    mov     ecx, [esp+530h+var_514]
    push    offset aExtractsmetal           ; char *
    fstp    dword ptr [ebp+1CAh]
    call    sub_4C4760
    push    esi                             ; int
    push    offset aMakesmetal              ; char *
    mov     ecx, [esp+530h+var_514]
    fstp    dword ptr [ebp+1CEh]
    call    sub_4C46C0
    push    esi
    push    esi                             ; __int64
    mov     ecx, [esp+530h+var_514]
    push    offset aWindgenerator           ; char *
    mov     [ebp+22Dh], al
    call    sub_4C4760
    push    esi
    push    esi                             ; __int64
    mov     ecx, [esp+530h+var_514]
    push    offset aTidalgenerator          ; char *
    fstp    dword ptr [ebp+1D2h]
    call    sub_4C4760
    push    esi
    push    esi                             ; __int64
    mov     ecx, [esp+530h+var_514]
    push    offset aEnergystorage           ; char *
    fstp    dword ptr [ebp+1D6h]
    call    sub_4C4760
    fstp    dword ptr [ebp+1E2h]
    mov     ecx, [esp+528h+var_514]
    push    esi
    push    esi                             ; __int64
    push    offset aMetalstorage            ; char *
    call    sub_4C4760
    push    esi                             ; int
    push    offset aBuildtime               ; char *
    mov     ecx, [esp+530h+var_514]
    fstp    dword ptr [ebp+1E6h]
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aWorkertime              ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+1EAh], eax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aHealtime                ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+1FEh], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aMaxdamage               ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+200h], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aSightdistance           ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+1FAh], eax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aRadardistance           ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+202h], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aSonardistance           ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+204h], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aRadardistancej          ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+206h], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aSonardistancej          ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+20Ah], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aBmcode                  ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+20Ch], ax
    call    sub_4C46C0
    push    2                               ; int
    push    offset aStandingmoveor          ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+22Fh], al
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    push    2                               ; int
    xor     eax, ecx
    push    offset aStandingfireor          ; char *
    and     eax, 3
    xor     eax, ecx
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 3
    mov     ecx, [esp+528h+var_514]
    and     edx, 0FFFFFFF3h
    shl     eax, 2
    or      eax, edx
    push    esi                             ; int
    push    offset aInit_cloaked            ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    shl     eax, 4
    and     ecx, 0FFFFFFEFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aDownloadable            ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0FFFFFFDFh
    shl     eax, 5
    or      eax, edx
    push    esi                             ; int
    push    offset aBuilder                 ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    shl     eax, 6
    and     ecx, 0FFFFFFBFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aStealth                 ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     dh, 0FEh
    shl     eax, 8
    or      eax, edx
    push    esi                             ; int
    push    offset aCloakcost               ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     [esp+528h+var_50C], eax
    fild    [esp+528h+var_50C]
    fst     dword ptr [ebp+1DAh]
    call    __ftol
    mov     ecx, [esp+528h+var_514]
    push    eax                             ; int
    push    offset aCloakcostmovin          ; char *
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aMincloakdistan          ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [esp+530h+var_50C], eax
    fild    [esp+530h+var_50C]
    fstp    dword ptr [ebp+1DEh]
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aBuildangle              ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+208h], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aBuilddistance           ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+210h], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aSortbias                ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+212h], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aCruisealt               ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+21Ah], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aZbuffer                 ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+21Ch], ax
    call    sub_4C46C0
    and     eax, 1
    mov     ecx, [ebp+241h]
    push    esi                             ; int
    shl     eax, 7
    and     cl, 7Fh
    push    offset aIsairbase               ; char *
    or      eax, ecx
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     dh, 0FDh
    shl     eax, 9
    or      eax, edx
    push    esi                             ; int
    push    offset aIstargetingupg          ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    shl     eax, 0Ah
    and     ch, 0FBh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aTeleporter              ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     dh, 0DFh
    shl     eax, 0Dh
    or      edx, eax
    push    esi                             ; int
    push    offset aHidedamage              ; char *
    mov     [ebp+241h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    and     ch, 0BFh
    push    esi                             ; int
    shl     eax, 0Eh
    or      ecx, eax
    push    offset aShootme                 ; char *
    mov     [ebp+241h], ecx
    mov     ecx, [esp+530h+var_514]
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     dh, 7Fh
    shl     eax, 0Fh
    or      edx, eax
    push    esi                             ; int
    push    offset aArmoredstate            ; char *
    mov     [ebp+241h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    shl     eax, 11h
    and     ecx, 0FFFDFFFFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aActivatewhenbu          ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0FFFBFFFFh
    shl     eax, 12h
    or      eax, edx
    push    esi                             ; int
    push    offset aCanfly                  ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    and     eax, 1
    shl     eax, 0Bh
    mov     ecx, [ebp+241h]
    push    esi                             ; int
    and     ch, 0F7h
    push    offset aCanhover                ; char *
    or      eax, ecx
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     dh, 0EFh
    shl     eax, 0Ch
    or      edx, eax
    push    esi                             ; int
    push    offset aUpright                 ; char *
    mov     [ebp+241h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    shl     eax, 14h
    and     ecx, 0FFEFFFFFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aFloater                 ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0FFF7FFFFh
    shl     eax, 13h
    or      eax, edx
    push    esi                             ; int
    push    offset aAmphibious              ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    shl     eax, 15h
    and     ecx, 0FFDFFFFFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aIsfeature               ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0FEFFFFFFh
    shl     eax, 18h
    or      eax, edx
    push    esi                             ; int
    push    offset aNoshadow                ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    shl     eax, 19h
    and     ecx, 0FDFFFFFFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aImmunetoparaly          ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0FBFFFFFFh
    shl     eax, 1Ah
    or      eax, edx
    push    esi                             ; int
    push    offset aHoverattack             ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    shl     eax, 1Bh
    and     ecx, 0F7FFFFFFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aAntiweapons             ; char *
    mov     [ebp+241h], eax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0DFFFFFFFh
    shl     eax, 1Dh
    or      edx, eax
    push    esi                             ; int
    push    offset aDigger                  ; char *
    mov     [ebp+241h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+241h]
    and     eax, 1
    and     ecx, 0BFFFFFFFh
    push    esi                             ; int
    shl     eax, 1Eh
    or      ecx, eax
    push    offset aOnoffable               ; char *
    mov     [ebp+241h], ecx
    mov     ecx, [esp+530h+var_514]
    call    sub_4C46C0
    mov     edx, [ebp+245h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0FFFFFFFBh
    shl     eax, 2
    or      eax, edx
    push    esi                             ; int
    push    offset aMobilestandord          ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+245h]
    push    esi                             ; int
    xor     eax, ecx
    push    offset aFirestandorder          ; char *
    and     eax, 1
    xor     eax, ecx
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+245h]
    and     eax, 1
    shl     eax, 1
    and     ecx, 0FFFFFFFDh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aCanstop                 ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     edx, [ebp+245h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0FFFFFFF7h
    shl     eax, 3
    or      eax, edx
    push    esi                             ; int
    push    offset aCanattack               ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+245h]
    and     eax, 1
    shl     eax, 4
    and     ecx, 0FFFFFFEFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aCanguard                ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     edx, [ebp+245h]
    and     eax, 1
    shl     eax, 5
    and     edx, 0FFFFFFDFh
    or      eax, edx
    mov     ecx, [esp+528h+var_514]
    push    esi                             ; int
    push    offset aCanpatrol               ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+245h]
    and     eax, 1
    shl     eax, 6
    and     ecx, 0FFFFFFBFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aCanmove                 ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     edx, [ebp+245h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     dl, 7Fh
    shl     eax, 7
    or      eax, edx
    push    esi                             ; int
    push    offset aCanload                 ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+245h]
    and     eax, 1
    shl     eax, 8
    and     ch, 0FEh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aCanreclamate            ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     edx, [ebp+245h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     dh, 0FBh
    shl     eax, 0Ah
    or      eax, edx
    push    esi                             ; int
    push    offset aCanresurrect            ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+245h]
    and     eax, 1
    shl     eax, 0Bh
    and     ch, 0F7h
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    mov     edx, eax
    and     ah, 0FDh
    shr     edx, 1
    and     edx, 200h
    push    offset aCancapture              ; char *
    or      edx, eax
    mov     [ebp+245h], edx
    call    sub_4C46C0
    fld     dword ptr [ebp+1DAh]
    mov     ecx, [ebp+245h]
    and     eax, 1
    fcomp   ds:flt_4FD210
    and     ch, 0EFh
    shl     eax, 0Ch
    or      ecx, eax
    fnstsw  ax
    mov     [ebp+245h], ecx
    test    ah, 41h
    jnz     short loc_42CA8B
    mov     eax, 1
    jmp     short loc_42CA8D
    ; ---------------------------------------------------------------------------

    loc_42CA8B:                             ; CODE XREF: sub_42BF40+B42j
    xor     eax, eax

    loc_42CA8D:                             ; CODE XREF: sub_42BF40+B49j
    and     eax, 1
    and     ch, 0DFh
    shl     eax, 0Dh
    or      ecx, eax
    push    esi                             ; int
    mov     [ebp+245h], ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aCandgun                 ; char *
    call    sub_4C46C0
    mov     ecx, [ebp+245h]
    and     eax, 1
    and     ch, 0BFh
    push    esi                             ; int
    shl     eax, 0Eh
    or      ecx, eax
    push    offset aManeuverleashl          ; char *
    mov     [ebp+245h], ecx
    mov     ecx, [esp+530h+var_514]
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aAttackrunlengt          ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+214h], ax
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aKamikaze                ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+216h], ax
    call    sub_4C46C0
    mov     edx, [ebp+241h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0EFFFFFFFh
    shl     eax, 1Ch
    or      edx, eax
    push    esi                             ; int
    push    offset aKamikazedistan          ; char *
    mov     [ebp+241h], edx
    call    sub_4C46C0
    push    esi                             ; int
    push    offset aNorestrict              ; char *
    mov     ecx, [esp+530h+var_514]
    mov     [ebp+218h], ax
    call    sub_4C46C0
    mov     ecx, [ebp+245h]
    and     eax, 1
    and     ch, 7Fh
    push    esi                             ; int
    shl     eax, 0Fh
    or      ecx, eax
    push    offset aShowplayername          ; char *
    mov     [ebp+245h], ecx
    mov     ecx, [esp+530h+var_514]
    call    sub_4C46C0
    mov     edx, [ebp+245h]
    and     eax, 1
    mov     ecx, [esp+528h+var_514]
    and     edx, 0FFFDFFFFh
    shl     eax, 11h
    or      eax, edx
    push    esi                             ; int
    push    offset aCommander               ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+245h]
    and     eax, 1
    shl     eax, 12h
    and     ecx, 0FFFBFFFFh
    push    esi                             ; int
    or      eax, ecx
    mov     ecx, [esp+52Ch+var_514]
    push    offset aCantbetranspor          ; char *
    mov     [ebp+245h], eax
    call    sub_4C46C0
    mov     edx, [ebp+245h]
    and     eax, 1
    shl     eax, 13h
    and     edx, 0FFF7FFFFh
    push    offset aSelfdestructco          ; char *
    or      eax, edx
    mov     [ebp+245h], eax
    mov     ecx, [esp+52Ch+var_514]
    call    sub_4C4630
    cmp     eax, esi
    jz      short loc_42CC07
    push    eax                             ; char *
    call    _atoi
    mov     ecx, [ebp+245h]
    and     eax, 7
    and     ecx, 0FF8FFFFFh
    add     esp, 4
    shl     eax, 14h
    or      ecx, eax
    mov     [ebp+245h], ecx
    jmp     short loc_42CC1F
    ; ---------------------------------------------------------------------------

    loc_42CC07:                             ; CODE XREF: sub_42BF40+CA0j
    mov     edx, [ebp+245h]
    and     edx, 0FFDFFFFFh
    or      edx, offset aMultibyte          ; "MultiByte"
    mov     [ebp+245h], edx

    loc_42CC1F:                             ; CODE XREF: sub_42BF40+CC5j
    mov     ecx, [esp+528h+var_514]
    push    offset Data                     ; int
    push    64h                             ; size_t
    lea     eax, [esp+2Ch]
    push    offset aCategory                ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    lea     ecx, [esp+24h]
    push    ecx
    mov     ecx, ebp
    call    sub_488E70
    push    offset Data                     ; int
    push    64h                             ; size_t
    mov     ecx, [esp+530h+var_514]
    lea     edx, [esp+2Ch]
    push    offset aSoundcategory           ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, esi
    jz      short loc_42CCB8
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E17h]
    test    ecx, ecx
    jle     short loc_42CCA2
    xor     edi, edi

    loc_42CC74:                             ; CODE XREF: sub_42BF40+D60j
    mov     edx, [eax+37E13h]
    lea     ecx, [esp+24h]
    add     edx, edi
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_42CCB8
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     edi, 160h
    cmp     esi, [eax+37E17h]
    jl      short loc_42CC74

    loc_42CCA2:                             ; CODE XREF: sub_42BF40+D30j
    lea     eax, [esp+24h]
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    mov     [ebp+20Eh], ax
    jmp     short loc_42CCBF
    ; ---------------------------------------------------------------------------

    loc_42CCB8:                             ; CODE XREF: sub_42BF40+D21j
                                            ; sub_42BF40+D4Cj
    mov     [ebp+20Eh], si

    loc_42CCBF:                             ; CODE XREF: sub_42BF40+D76j
    push    offset Data                     ; int
    push    64h                             ; size_t
    lea     ecx, [esp+2Ch]
    push    offset aCorpse                  ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+538h+var_514]
    mov     word ptr [ebp+1BCh], 0FFFFh
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42CCF7
    lea     edx, [esp+24h]
    push    edx                             ; char *
    call    sub_422E40
    mov     [ebp+1BCh], ax

    loc_42CCF7:                             ; CODE XREF: sub_42BF40+DA4j
    mov     ecx, [esp+528h+var_514]
    push    offset Data                     ; int
    push    64h                             ; size_t
    lea     eax, [esp+2Ch]
    push    offset aMovementclass           ; char *
    push    eax                             ; char *
    mov     dword ptr [ebp+1B6h], 0
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42CD2F
    lea     ecx, [esp+24h]
    push    ecx                             ; char *
    call    sub_440420
    mov     [ebp+1B6h], eax

    loc_42CD2F:                             ; CODE XREF: sub_42BF40+DDDj
    lea     ecx, [esp+528h+var_4A0]
    call    sub_4402E0
    mov     eax, [ebp+1B6h]
    test    eax, eax
    jnz     short loc_42CD5D
    lea     edx, [esp+528h+var_518]
    lea     ecx, [esp+528h+var_4A0]
    push    edx
    call    sub_440340
    lea     eax, [esp+528h+var_4A0]

    loc_42CD5D:                             ; CODE XREF: sub_42BF40+E03j
    mov     cx, [eax+4]
    mov     [ebp+14Ah], cx
    mov     dx, [eax+6]
    mov     [ebp+14Ch], dx
    mov     cx, [eax+8]
    mov     [ebp+1BEh], cx
    mov     dx, [eax+0Ah]
    mov     [ebp+1C0h], dx
    mov     cl, [eax+0Ch]
    mov     [ebp+228h], cl
    mov     dl, [eax+0Eh]
    xor     eax, eax
    mov     [ebp+229h], dl
    mov     al, cl
    mov     ecx, 10h
    inc     eax
    shl     eax, 10h
    cdq
    mov     esi, eax
    mov     eax, [ebp+192h]
    mov     edi, edx
    cdq
    call    __allshl
    push    edi
    push    esi
    push    edx
    push    eax
    call    __alldiv
    push    offset Data                     ; int
    mov     [ebp+196h], eax
    mov     eax, TAdynmemStructPtr
    push    80h                             ; size_t
    lea     ecx, [esp+530h+var_480]
    push    offset aWeapon1                 ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+538h+var_514]
    lea     esi, [eax+2CF3h]
    call    sub_4C48C0
    lea     edx, [esp+528h+var_480]
    push    edx                             ; char *
    call    sub_49E5B0
    xor     ebx, ebx
    cmp     eax, ebx
    jnz     short loc_42CE08
    mov     eax, esi

    loc_42CE08:                             ; CODE XREF: sub_42BF40+EC4j
    mov     ecx, [esp+528h+var_514]
    mov     [ebp+1EEh], eax
    push    offset Data                     ; int
    push    80h                             ; size_t
    lea     eax, [esp+530h+var_480]
    push    offset aWeapon2                 ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    lea     ecx, [esp+528h+var_480]
    push    ecx                             ; char *
    call    sub_49E5B0
    cmp     eax, ebx
    jnz     short loc_42CE41
    mov     eax, esi

    loc_42CE41:                             ; CODE XREF: sub_42BF40+EFDj
    mov     ecx, [esp+528h+var_514]
    push    offset Data                     ; int
    push    80h                             ; size_t
    lea     edx, [esp+530h+var_480]
    push    offset aWeapon3                 ; char *
    push    edx                             ; char *
    mov     [ebp+1F2h], eax
    call    sub_4C48C0
    lea     eax, [esp+528h+var_480]
    push    eax                             ; char *
    call    sub_49E5B0
    cmp     eax, ebx
    jnz     short loc_42CE7A
    mov     eax, esi

    loc_42CE7A:                             ; CODE XREF: sub_42BF40+F36j
    push    offset Data                     ; int
    push    80h                             ; size_t
    lea     ecx, [esp+530h+var_480]
    push    offset aExplodeas               ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+538h+var_514]
    mov     [ebp+1F6h], eax
    call    sub_4C48C0
    lea     edx, [esp+528h+var_480]
    push    edx                             ; char *
    call    sub_49E5B0
    cmp     eax, ebx
    jnz     short loc_42CEB3
    mov     eax, esi

    loc_42CEB3:                             ; CODE XREF: sub_42BF40+F6Fj
    mov     ecx, [esp+528h+var_514]
    mov     [ebp+220h], eax
    push    offset Data                     ; int
    push    80h                             ; size_t
    lea     eax, [esp+530h+var_480]
    push    offset aSelfdestructas          ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    lea     ecx, [esp+528h+var_480]
    push    ecx                             ; char *
    call    sub_49E5B0
    cmp     eax, ebx
    jnz     short loc_42CEEC
    mov     eax, esi

    loc_42CEEC:                             ; CODE XREF: sub_42BF40+FA8j
    mov     [ebp+224h], eax
    mov     eax, [ebp+1EEh]
    cmp     eax, esi
    jnz     short loc_42CF19
    cmp     [ebp+1F2h], esi
    jnz     short loc_42CF19
    cmp     [ebp+1F6h], esi
    jnz     short loc_42CF19
    mov     eax, [ebp+241h]
    and     eax, 0FFFEFFFFh
    jmp     short loc_42CF24
    ; ---------------------------------------------------------------------------

    loc_42CF19:                             ; CODE XREF: sub_42BF40+FBAj
                                            ; sub_42BF40+FC2j ...
    mov     eax, [ebp+241h]
    or      eax, 10000h

    loc_42CF24:                             ; CODE XREF: sub_42BF40+FD7j
    mov     [ebp+241h], eax
    mov     al, [ebp+22Fh]
    test    al, al
    mov     [ebp+14Eh], ebx
    jnz     loc_42D073
    mov     ecx, [esp+528h+var_514]
    push    offset Data                     ; int
    push    400h                            ; size_t
    lea     edx, [esp+530h+var_400]
    push    offset aYardmap                 ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    movsx   eax, word ptr [ebp+14Ch]
    movsx   ecx, word ptr [ebp+14Ah]
    imul    eax, ecx
    push    eax
    push    offset aBuildingYard            ; "BUILDING YARD"
    call    sub_4D83B0
    mov     [ebp+14Eh], eax
    add     esp, 8
    xor     eax, eax
    cmp     [ebp+14Ch], bx
    lea     esi, [esp+528h+var_400]
    mov     [esp+528h+var_50C], ebx
    jle     loc_42D079

    loc_42CF9D:                             ; CODE XREF: sub_42BF40+112Bj
    xor     edi, edi
    cmp     [ebp+14Ah], bx
    jle     loc_42D059

    loc_42CFAC:                             ; CODE XREF: sub_42BF40+1113j
    movsx   ecx, byte ptr [esi]
    add     ecx, 0FFFFFFD2h
    cmp     ecx, 4Bh
    ja      loc_42D049
    xor     edx, edx
    mov     dl, ds:byte_42D198[ecx]
    jmp     ds:off_42D16C[edx*4]

    loc_42CFCA:                             ; DATA XREF: .text:0042D16Co
    mov     ecx, [ebp+14Eh]
    mov     byte ptr [ecx+eax], 0
    jmp     short loc_42D040
    ; ---------------------------------------------------------------------------

    loc_42CFD6:                             ; CODE XREF: sub_42BF40+1083j
                                            ; DATA XREF: .text:0042D184o
    mov     edx, [ebp+14Eh]
    mov     byte ptr [edx+eax], 6Fh
    jmp     short loc_42D040
    ; ---------------------------------------------------------------------------

    loc_42CFE2:                             ; CODE XREF: sub_42BF40+1083j
                                            ; DATA XREF: .text:0042D188o
    mov     ecx, [ebp+14Eh]
    mov     byte ptr [ecx+eax], 2Fh
    jmp     short loc_42D040
    ; ---------------------------------------------------------------------------

    loc_42CFEE:                             ; CODE XREF: sub_42BF40+1083j
                                            ; DATA XREF: .text:0042D180o
    mov     edx, [ebp+14Eh]
    mov     byte ptr [edx+eax], 2Dh
    jmp     short loc_42D040
    ; ---------------------------------------------------------------------------

    loc_42CFFA:                             ; CODE XREF: sub_42BF40+1083j
                                            ; DATA XREF: .text:0042D178o
    mov     ecx, [ebp+14Eh]
    mov     byte ptr [ecx+eax], 2Bh
    jmp     short loc_42D040
    ; ---------------------------------------------------------------------------

    loc_42D006:                             ; CODE XREF: sub_42BF40+1083j
                                            ; DATA XREF: .text:0042D18Co
    mov     edx, [ebp+14Eh]
    mov     byte ptr [edx+eax], 37h
    jmp     short loc_42D040
    ; ---------------------------------------------------------------------------

    loc_42D012:                             ; CODE XREF: sub_42BF40+1083j
                                            ; DATA XREF: .text:0042D170o
    mov     ecx, [ebp+14Eh]
    mov     byte ptr [ecx+eax], 35h
    jmp     short loc_42D040
    ; ---------------------------------------------------------------------------

    loc_42D01E:                             ; CODE XREF: sub_42BF40+1083j
                                            ; DATA XREF: .text:0042D190o
    mov     edx, [ebp+14Eh]
    mov     byte ptr [edx+eax], 29h
    jmp     short loc_42D040
    ; ---------------------------------------------------------------------------

    loc_42D02A:                             ; CODE XREF: sub_42BF40+1083j
                                            ; DATA XREF: .text:0042D17Co
    mov     ecx, [ebp+14Eh]
    mov     byte ptr [ecx+eax], 31h
    jmp     short loc_42D040
    ; ---------------------------------------------------------------------------

    loc_42D036:                             ; CODE XREF: sub_42BF40+1083j
                                            ; DATA XREF: .text:0042D174o
    mov     edx, [ebp+14Eh]
    mov     byte ptr [edx+eax], 8Fh

    loc_42D040:                             ; CODE XREF: sub_42BF40+1094j
                                            ; sub_42BF40+10A0j ...
    mov     cl, [esi+1]
    inc     edi
    inc     eax
    test    cl, cl
    jz      short loc_42D04A

    loc_42D049:                             ; CODE XREF: sub_42BF40+1075j
                                            ; sub_42BF40+1083j
                                            ; DATA XREF: ...
    inc     esi

    loc_42D04A:                             ; CODE XREF: sub_42BF40+1107j
    movsx   ecx, word ptr [ebp+14Ah]
    cmp     edi, ecx
    jl      loc_42CFAC

    loc_42D059:                             ; CODE XREF: sub_42BF40+1066j
    mov     ecx, [esp+528h+var_50C]
    movsx   edx, word ptr [ebp+14Ch]
    inc     ecx
    cmp     ecx, edx
    mov     [esp+528h+var_50C], ecx
    jl      loc_42CF9D
    jmp     short loc_42D079
    ; ---------------------------------------------------------------------------

    loc_42D073:                             ; CODE XREF: sub_42BF40+FF8j
    mov     [ebp+14Eh], ebx

    loc_42D079:                             ; CODE XREF: sub_42BF40+1057j
                                            ; sub_42BF40+1131j
    movsx   ecx, word ptr [ebp+14Ah]
    mov     eax, ecx
    neg     eax
    movsx   esi, word ptr [ebp+14Ch]
    shl     eax, 14h
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebp+15Eh], eax
    mov     eax, esi
    neg     eax
    shl     eax, 14h
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebp+166h], eax
    mov     eax, ecx
    shl     eax, 14h
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebp+16Ah], eax
    mov     eax, esi
    shl     eax, 14h
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebp+172h], eax
    mov     eax, [ebp+16Ah]
    mov     esi, [ebp+15Eh]
    mov     ecx, [ebp+16Eh]
    mov     edx, [ebp+162h]
    mov     ebx, [ebp+166h]
    sub     eax, esi
    lea     esi, [ebp+176h]
    mov     edi, esi
    sub     ecx, edx
    mov     edx, [ebp+172h]
    mov     [edi], eax
    sub     edx, ebx
    mov     eax, 55555556h
    mov     [edi+4], ecx
    mov     [edi+8], edx
    mov     ecx, [ebp+17Eh]
    add     ecx, [esi]
    imul    ecx
    mov     eax, edx
    lea     ecx, [esp+528h+var_518]
    shr     eax, 1Fh
    add     edx, eax
    mov     [ebp+182h], edx
    call    sub_4C3240
    mov     eax, [ebp+245h]
    test    ah, 20h
    jz      short loc_42D148
    cmp     word ptr [ebp+208h], 0
    jnz     short loc_42D148
    mov     word ptr [ebp+208h], 50h

    loc_42D148:                             ; CODE XREF: sub_42BF40+11F3j
                                            ; sub_42BF40+11FDj
    lea     ecx, [esp+528h+var_4A0]
    call    sub_440320

    loc_42D154:                             ; CODE XREF: sub_42BF40+26j
                                            ; sub_42BF40+47j
    lea     ecx, [esp+528h+var_518]
    call    sub_4C2EB0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 518h
    retn    8
    sub_42BF40 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_42D16C dd offset loc_42CFCA         ; DATA XREF: sub_42BF40+1083r
    dd offset loc_42D012
    dd offset loc_42D036
    dd offset loc_42CFFA
    dd offset loc_42D02A
    dd offset loc_42CFEE
    dd offset loc_42CFD6
    dd offset loc_42CFE2
    dd offset loc_42D006
    dd offset loc_42D01E
    dd offset loc_42D049
    byte_42D198 db 0                        ; DATA XREF: sub_42BF40+107Dr
    ; ---------------------------------------------------------------------------
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    add     [edx], ecx
    or      cl, [edx]
    add     cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    add     ecx, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    add     al, 0Ah
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    add     eax, 0A060A0Ah
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      al, [edi]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [eax]
    or      cl, [ecx]
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42D1F0 proc near                    ; CODE XREF: .text:004174BEp

    var_100= dword ptr -100h
    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    sub     esp, 100h
    test    ax, ax
    push    esi
    push    edi
    jz      loc_42D2D4
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFFFh
    mov     edx, [ecx+1439Bh]
    mov     ecx, eax
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [edx+eax*8]
    add     eax, ecx
    mov     esi, eax
    test    dword ptr [esi+241h], 800000h
    jz      loc_42D2D4
    push    edx                             ; wint_t
    call    _iswdigit
    add     esp, 4
    lea     edi, [esi+20h]
    lea     edx, [esp+108h+var_100]
    push    offset off_503928
    push    edi
    push    offset aUnits                   ; "units"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+108h+var_100]
    push    eax
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_42D2BF
    lea     ecx, [esp+108h+var_100]
    push    esi
    push    ecx
    call    sub_42BF40
    mov     edx, [esi+18Eh]
    push    edx
    call    sub_4B2540
    push    offset off_503EC8
    push    edi
    lea     eax, [esp+110h+var_100]
    push    offset aScripts                 ; "scripts"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+108h+var_100]
    push    ecx
    call    sub_4B2450
    mov     [esi+18Eh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1439Bh]
    push    eax                             ; wint_t
    call    _iswlower
    add     esp, 4
    pop     edi
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42D2BF:                             ; CODE XREF: sub_42D1F0+71j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1439Bh]
    push    edx                             ; wint_t
    call    _iswlower
    add     esp, 4

    loc_42D2D4:                             ; CODE XREF: sub_42D1F0+Fj
                                            ; sub_42D1F0+3Ej
    pop     edi
    pop     esi
    add     esp, 100h
    retn    4
    sub_42D1F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42D2E0 proc near                    ; CODE XREF: sub_4917D0+FAp

    var_610= dword ptr -610h
    var_60C= dword ptr -60Ch
    var_608= dword ptr -608h
    var_604= dword ptr -604h
    var_5FC= dword ptr -5FCh
    var_5F8= dword ptr -5F8h
    var_5F0= byte ptr -5F0h
    var_5D1= byte ptr -5D1h
    var_5D0= dword ptr -5D0h
    var_5B0= dword ptr -5B0h
    var_4B0= byte ptr -4B0h
    Text= byte ptr -44Ch
    var_34C= byte ptr -34Ch
    var_24C= dword ptr -24Ch
    var_22C= byte ptr -22Ch

    sub     esp, 610h
    lea     ecx, [esp+610h+var_5FC]
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4C2EA0
    push    offset off_50341C
    push    offset aMoveinfo                ; "moveinfo"
    lea     eax, [esp+628h+var_5B0]
    push    offset aGamedata                ; "gamedata"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+620h+var_5B0]
    push    ecx
    lea     ecx, [esp+624h+var_5FC]
    call    sub_4C2F60
    test    eax, eax
    jnz     short loc_42D328
    push    offset aCanTLoadMovein          ; lpText
    call    sub_4B6290

    loc_42D328:                             ; CODE XREF: sub_42D2E0+3Cj
    xor     ebx, ebx
    xor     edi, edi
    mov     esi, offset dword_512358

    loc_42D331:                             ; CODE XREF: sub_42D2E0+CAj
    push    edi
    lea     edx, [esp+624h+var_4B0]
    push    offset aClassD                  ; "CLASS%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+620h+var_5FC]
    call    sub_4C3E10
    lea     eax, [esp+620h+var_4B0]
    lea     ecx, [esp+620h+var_5FC]
    push    eax                             ; char *
    call    sub_4C3410
    test    eax, eax
    jz      short loc_42D3A0
    push    offset Data                     ; int
    push    64h                             ; size_t
    lea     ecx, [esp+628h+var_4B0]
    push    offset aName                    ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+630h+var_5F8]
    call    sub_4C48C0
    lea     edx, [esp+620h+var_4B0]
    push    edx
    call    sub_4D8610
    add     esp, 4
    mov     [esi], eax
    lea     eax, [esp+620h+var_5FC]
    mov     ecx, esi
    push    eax
    call    sub_440340

    loc_42D3A0:                             ; CODE XREF: sub_42D2E0+83j
    add     esi, 20h
    inc     edi
    cmp     esi, offset byte_512758
    jl      short loc_42D331
    lea     ecx, [esp+620h+var_5FC]
    call    sub_4C3240
    lea     ecx, [esp+620h+var_5FC]
    call    sub_4C2EB0
    push    14h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_42D3D5
    mov     ecx, eax
    call    sub_458160
    jmp     short loc_42D3D7
    ; ---------------------------------------------------------------------------

    loc_42D3D5:                             ; CODE XREF: sub_42D2E0+EAj
    xor     eax, eax

    loc_42D3D7:                             ; CODE XREF: sub_42D2E0+F3j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+1437Bh], eax
    mov     esi, TAdynmemStructPtr
    mov     edx, [esi+37E23h]
    imul    edx, [esi+37E1Fh]
    shl     edx, 1
    mov     [esp+620h+var_610], edx
    fild    [esp+620h+var_610]
    fmul    ds:dbl_4FD218
    call    __ftol
    mov     [esp+620h+var_60C], eax
    mov     eax, [esi+0Ch]
    fld     ds:flt_4FD220
    mov     eax, [eax+620h]
    cdq
    and     edx, 0FFFFFh
    add     eax, edx
    sar     eax, 14h
    inc     eax
    cmp     eax, 10h
    mov     [esp+620h+var_610], eax
    jle     short loc_42D455
    fstp    st
    fild    [esp+620h+var_610]
    fmul    ds:dbl_4FD228
    fcom    ds:dbl_4FD230
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_42D455
    fstp    st
    fld     ds:flt_4FD238

    loc_42D455:                             ; CODE XREF: sub_42D2E0+152j
                                            ; sub_42D2E0+16Bj
    fild    [esp+620h+var_60C]
    fmul    st, st(1)
    call    __ftol
    mov     ecx, [esi+1437Bh]
    add     eax, 0FFFh
    and     eax, 0FFFFF000h
    push    eax
    fstp    st
    call    sub_458180
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1439Bh]
    push    edx                             ; wint_t
    call    _iswdigit
    mov     esi, TAdynmemStructPtr
    add     esp, 4
    mov     edx, [esi+1438Fh]
    mov     ecx, [esi+1439Bh]
    mov     eax, edx
    shl     eax, 6
    add     eax, edx
    lea     edx, [ecx+eax*8]
    add     eax, edx
    mov     ebp, eax
    lea     eax, [ecx+249h]
    cmp     eax, ebp
    jz      short loc_42D4D4

    loc_42D4B7:                             ; CODE XREF: sub_42D2E0+1EEj
    mov     ecx, [eax+241h]
    not     ecx
    test    ecx, 800000h
    jnz     short loc_42D4D0
    add     eax, 249h
    cmp     eax, ebp
    jnz     short loc_42D4B7

    loc_42D4D0:                             ; CODE XREF: sub_42D2E0+1E5j
    cmp     eax, ebp
    jnz     short loc_42D4DC

    loc_42D4D4:                             ; CODE XREF: sub_42D2E0+1D5j
    mov     edi, eax
    mov     [esp+620h+var_610], edi
    jmp     short loc_42D51A
    ; ---------------------------------------------------------------------------

    loc_42D4DC:                             ; CODE XREF: sub_42D2E0+1F2j
    lea     esi, [eax+249h]
    mov     edi, eax
    cmp     esi, ebp
    jz      short loc_42D510

    loc_42D4E8:                             ; CODE XREF: sub_42D2E0+22Ej
    mov     edx, [esi+241h]
    not     edx
    test    edx, 800000h
    jnz     short loc_42D506
    mov     ecx, edi
    push    esi
    add     edi, 249h
    call    sub_42B370

    loc_42D506:                             ; CODE XREF: sub_42D2E0+216j
    add     esi, 249h
    cmp     esi, ebp
    jnz     short loc_42D4E8

    loc_42D510:                             ; CODE XREF: sub_42D2E0+206j
    mov     esi, TAdynmemStructPtr
    mov     [esp+620h+var_610], edi

    loc_42D51A:                             ; CODE XREF: sub_42D2E0+1FAj
    mov     edx, [esi+1439Bh]
    mov     ecx, edi
    sub     ecx, edx
    mov     eax, 0E00E00E1h
    imul    ecx
    add     edx, ecx
    push    ebx
    sar     edx, 9
    mov     eax, edx
    push    offset loc_42DB60
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 0E00E00E1h
    mov     [esi+1438Fh], edx
    mov     ecx, TAdynmemStructPtr
    push    edi
    mov     esi, [ecx+1439Bh]
    mov     ecx, edi
    add     esi, 249h
    sub     ecx, esi
    push    esi
    imul    ecx
    add     edx, ecx
    sar     edx, 9
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 10h
    jg      short loc_42D57D
    call    sub_432FB0
    jmp     loc_42D612
    ; ---------------------------------------------------------------------------

    loc_42D57D:                             ; CODE XREF: sub_42D2E0+291j
    call    sub_432D40
    lea     ebp, [esi+2490h]
    push    ebx
    push    offset loc_42DB60
    push    ebp
    push    esi
    call    sub_432FB0
    cmp     ebp, edi
    jz      short loc_42D612

    loc_42D599:                             ; CODE XREF: sub_42D2E0+32Ej
    mov     ecx, 92h
    mov     esi, ebp
    lea     edi, [esp+620h+var_24C]
    rep movsd
    movsb
    lea     esi, [ebp-249h]
    lea     ecx, [esp+620h+var_22C]
    mov     edi, ebp
    lea     ebx, [esi+20h]
    push    ebx                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jge     short loc_42D5F5

    loc_42D5CA:                             ; CODE XREF: sub_42D2E0+313j
    push    esi
    mov     ecx, edi
    call    sub_42B370
    sub     ebx, 249h
    lea     edx, [esp+620h+var_22C]
    push    ebx                             ; char *
    mov     edi, esi
    push    edx                             ; char *
    sub     esi, 249h
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jl      short loc_42D5CA

    loc_42D5F5:                             ; CODE XREF: sub_42D2E0+2E8j
    lea     eax, [esp+620h+var_24C]
    mov     ecx, edi
    push    eax
    call    sub_42B370
    add     ebp, 249h
    cmp     ebp, [esp+620h+var_610]
    jnz     short loc_42D599
    xor     ebx, ebx

    loc_42D612:                             ; CODE XREF: sub_42D2E0+298j
                                            ; sub_42D2E0+2B7j
    mov     esi, TAdynmemStructPtr
    xor     edx, edx
    cmp     [esi+1438Fh], ebx
    jle     short loc_42D655
    xor     ecx, ecx

    loc_42D624:                             ; CODE XREF: sub_42D2E0+373j
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    mov     eax, [esi+1439Bh]
    mov     [eax+ecx+21Eh], dx
    mov     esi, TAdynmemStructPtr
    inc     edx
    mov     eax, [esi+1438Fh]
    mov     ecx, edx
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      short loc_42D624

    loc_42D655:                             ; CODE XREF: sub_42D2E0+340j
    mov     eax, [esi+1438Fh]
    mov     [esi+14393h], ebx
    cmp     eax, ebx
    jz      short loc_42D67E

    loc_42D665:                             ; CODE XREF: sub_42D2E0+39Cj
    mov     ecx, TAdynmemStructPtr
    sar     eax, 1
    mov     edx, [ecx+14393h]
    inc     edx
    cmp     eax, ebx
    mov     [ecx+14393h], edx
    jnz     short loc_42D665

    loc_42D67E:                             ; CODE XREF: sub_42D2E0+383j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1438Fh]
    shl     edx, 2
    push    edx
    push    offset aModelPtrs               ; "MODEL PTRS"
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    mov     esi, 1
    add     esp, 8
    mov     [esp+620h+var_610], esi
    mov     [ecx+14377h], eax
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+1438Fh], esi
    jle     loc_42D91F

    loc_42D6C2:                             ; CODE XREF: sub_42D2E0+637j
    mov     eax, esi
    mov     ebp, [ecx+1439Bh]
    shl     eax, 6
    add     eax, esi
    push    offset off_503928
    lea     edx, [eax+eax*8]
    lea     eax, [esi+esi*2]
    add     ebp, edx
    lea     eax, [esi+eax*8]
    shl     eax, 2
    cdq
    idiv    dword ptr [ecx+1438Fh]
    lea     ebx, [ebp+20h]
    lea     edx, [esp+624h+var_5B0]
    push    ebx
    push    offset aUnits                   ; "units"
    push    edx
    mov     [ecx+38D71h], al
    mov     cx, word ptr [esp+630h+var_610]
    mov     [ebp+21Eh], cx
    call    sub_4290F0
    lea     eax, [esp+620h+var_5B0]
    push    eax
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_42D727
    lea     ecx, [esp+620h+var_5B0]
    push    ebp
    push    ecx
    call    sub_42BF40

    loc_42D727:                             ; CODE XREF: sub_42D2E0+43Aj
    lea     edx, [ebp+80h]
    push    20h                             ; size_t
    lea     eax, [esp+624h+var_5F0]
    push    edx                             ; char *
    push    eax                             ; char *
    call    _strncpy
    add     esp, 0Ch
    lea     ecx, [esp+620h+var_5F0]
    lea     edx, [esp+620h+Text]
    mov     [esp+620h+var_5D1], 0
    push    offset off_5036F0
    push    ecx
    push    offset aObjects3d               ; "objects3d"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+620h+Text]
    push    eax
    call    sub_4CB560
    mov     edi, eax
    test    edi, edi
    jnz     short loc_42D77E
    lea     ecx, [esp+620h+Text]
    push    ecx                             ; lpText
    call    sub_4B6290

    loc_42D77E:                             ; CODE XREF: sub_42D2E0+48Fj
    push    edi
    call    sub_4CB590
    lea     edx, [esp+620h+var_5F0]
    push    edx
    push    edi
    call    sub_42A140
    mov     ecx, TAdynmemStructPtr
    lea     eax, ds:0[esi*4]
    mov     edx, [ecx+14377h]
    mov     [edx+eax], edi
    mov     dword ptr [ebp+162h], 0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14377h]
    mov     eax, [edx+eax]
    push    eax
    call    sub_4CB5F0
    mov     ecx, [ebp+162h]
    mov     [ebp+16Eh], eax
    sub     eax, ecx
    mov     edi, ebx
    mov     [ebp+17Ah], eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+620h+var_5F0]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+620h+var_5F0]
    push    ecx
    call    sub_4BB0F0
    lea     edx, [esp+620h+var_5F0]
    lea     eax, [esp+620h+var_5D0]
    push    edx
    push    offset aS0                      ; "%s0"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+620h+var_5D0]
    lea     edx, [esp+620h+var_5B0]
    push    offset off_502828
    push    ecx
    push    offset aGuis                    ; "guis"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+620h+var_5B0]
    push    eax
    call    sub_4BBC40
    test    eax, eax
    mov     eax, [ebp+241h]
    jz      short loc_42D850
    or      eax, 80000000h
    jmp     short loc_42D855
    ; ---------------------------------------------------------------------------

    loc_42D850:                             ; CODE XREF: sub_42D2E0+567j
    and     eax, 7FFFFFFFh

    loc_42D855:                             ; CODE XREF: sub_42D2E0+56Ej
    mov     [ebp+241h], eax
    mov     ebx, 1
    xor     esi, esi

    loc_42D862:                             ; CODE XREF: sub_42D2E0+5C7j
    lea     ecx, [esp+620h+var_5F0]
    push    ebx
    push    ecx
    lea     edx, [esp+628h+var_5D0]
    push    offset aSD                      ; "%s%d"
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+620h+var_5D0]
    lea     ecx, [esp+620h+var_5B0]
    push    offset off_502828
    push    eax
    push    offset aGuis                    ; "guis"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+620h+var_5B0]
    push    edx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_42D8A9
    inc     ebx
    mov     esi, 1
    jmp     short loc_42D862
    ; ---------------------------------------------------------------------------

    loc_42D8A9:                             ; CODE XREF: sub_42D2E0+5BFj
    test    esi, esi
    jz      short loc_42D8B5
    mov     [ebp+22Eh], bl
    jmp     short loc_42D8D2
    ; ---------------------------------------------------------------------------

    loc_42D8B5:                             ; CODE XREF: sub_42D2E0+5CBj
    mov     eax, [ebp+241h]
    shr     eax, 1Fh
    test    al, 1
    jz      short loc_42D8CB
    mov     byte ptr [ebp+22Eh], 1
    jmp     short loc_42D8D2
    ; ---------------------------------------------------------------------------

    loc_42D8CB:                             ; CODE XREF: sub_42D2E0+5E0j
    mov     byte ptr [ebp+22Eh], 0

    loc_42D8D2:                             ; CODE XREF: sub_42D2E0+5D3j
                                            ; sub_42D2E0+5E9j
    lea     eax, [ebp+20h]
    push    offset off_503EC8
    push    eax
    lea     ecx, [esp+628h+var_5B0]
    push    offset aScripts                 ; "scripts"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+620h+var_5B0]
    push    edx
    call    sub_4B2450
    mov     [ebp+18Eh], eax
    mov     ecx, TAdynmemStructPtr
    mov     esi, [esp+620h+var_610]
    mov     eax, [ecx+1438Fh]
    inc     esi
    mov     [esp+620h+var_610], esi
    and     esi, 0FFFFh
    cmp     esi, eax
    jl      loc_42D6C2
    xor     ebx, ebx

    loc_42D91F:                             ; CODE XREF: sub_42D2E0+3DCj
    mov     eax, [ecx+14377h]
    push    eax                             ; wint_t
    call    _iswlower
    add     esp, 4
    lea     ecx, [esp+620h+var_608]
    call    sub_4C2EA0
    push    offset off_50341C
    push    offset aSidedata                ; "sidedata"
    lea     ecx, [esp+628h+var_5B0]
    push    offset aGamedata                ; "gamedata"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+620h+var_5B0]
    lea     ecx, [esp+620h+var_608]
    push    edx
    call    sub_4C2F60
    test    eax, eax
    jnz     short loc_42D971
    push    offset aCanTLoadGameda          ; lpText
    call    sub_4B6290
    jmp     loc_42DB18
    ; ---------------------------------------------------------------------------

    loc_42D971:                             ; CODE XREF: sub_42D2E0+680j
    push    3Ch
    push    offset aTempUtypeList           ; "TEMP UTYPE LIST"
    call    sub_4D83B0
    mov     edx, TAdynmemStructPtr
    mov     ebp, eax
    mov     ecx, 1
    add     esp, 8
    mov     eax, [edx+1438Fh]
    mov     [esp+620h+var_60C], ebp
    cmp     eax, ecx
    mov     [esp+620h+var_610], ecx
    jle     loc_42DB06

    loc_42D9A3:                             ; CODE XREF: sub_42D2E0+820j
    mov     esi, [edx+1439Bh]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     eax, [eax+eax*8]
    add     esi, eax
    mov     ecx, [esi+241h]
    mov     [esi+152h], ebx
    shr     ecx, 6
    test    cl, 1
    mov     [esi+156h], ebx
    jz      loc_42DAE3
    lea     ecx, [esp+620h+var_608]
    call    sub_4C3E10
    push    offset aCanbuild                ; char *
    lea     ecx, [esp+624h+var_608]
    call    sub_4C3410
    test    eax, eax
    jz      loc_42DAA7
    lea     edx, [esi+20h]
    lea     ecx, [esp+620h+var_608]
    push    edx                             ; char *
    call    sub_4C3410
    test    eax, eax
    jz      loc_42DAA7
    mov     edi, 1
    lea     eax, [esp+620h+Text]
    push    edi
    push    offset aCanbuildD               ; "canbuild%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+620h+Text]
    lea     edx, [esp+620h+var_34C]
    push    offset Data                     ; int
    push    20h                             ; size_t
    push    ecx                             ; char *
    mov     ecx, [esp+62Ch+var_604]
    push    edx                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42DA9F

    loc_42DA46:                             ; CODE XREF: sub_42D2E0+7B9j
    lea     eax, [esp+620h+var_34C]
    push    eax                             ; char *
    call    sub_488B10
    test    ax, ax
    jz      short loc_42DA60
    mov     [ebp+0], ax
    inc     ebx
    add     ebp, 2

    loc_42DA60:                             ; CODE XREF: sub_42D2E0+776j
    inc     edi
    lea     ecx, [esp+620h+Text]
    push    edi
    push    offset aCanbuildD               ; "canbuild%d"
    push    ecx
    call    _sprintf
    mov     ecx, [esp+62Ch+var_604]
    add     esp, 0Ch
    lea     edx, [esp+620h+Text]
    lea     eax, [esp+620h+var_34C]
    push    offset Data                     ; int
    push    20h                             ; size_t
    push    edx                             ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jnz     short loc_42DA46
    mov     ebp, [esp+620h+var_60C]

    loc_42DA9F:                             ; CODE XREF: sub_42D2E0+764j
    mov     [esi+152h], ebx
    xor     ebx, ebx

    loc_42DAA7:                             ; CODE XREF: sub_42D2E0+70Cj
                                            ; sub_42D2E0+721j
    lea     ecx, [esi+20h]
    lea     edx, [esp+620h+Text]
    push    ecx
    push    offset aCanbuildS               ; "CANBUILD %s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+620h+Text]
    push    3Ch
    push    eax
    call    sub_4D83B0
    mov     [esi+156h], eax
    mov     ecx, 0Fh
    mov     esi, ebp
    mov     edi, eax
    add     esp, 8
    rep movsd

    loc_42DAE3:                             ; CODE XREF: sub_42D2E0+6EDj
    mov     ecx, [esp+620h+var_610]
    mov     edx, TAdynmemStructPtr
    inc     ecx
    mov     eax, [edx+1438Fh]
    mov     [esp+620h+var_610], ecx
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      loc_42D9A3

    loc_42DB06:                             ; CODE XREF: sub_42D2E0+6BDj
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    lea     ecx, [esp+620h+var_608]
    call    sub_4C3240

    loc_42DB18:                             ; CODE XREF: sub_42D2E0+68Cj
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+38D71h], 64h
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+14397h], 1
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1439Bh]
    push    ecx                             ; wint_t
    call    _iswlower
    add     esp, 4
    lea     ecx, [esp+620h+var_608]
    call    sub_4C2EB0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 610h
    retn
    sub_42D2E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    loc_42DB60:                             ; DATA XREF: sub_42D2E0+253o
                                            ; sub_42D2E0+2A9o
    mov     eax, [esp+8]
    mov     ecx, [esp+4]
    add     eax, 20h
    add     ecx, 20h
    push    eax
    push    ecx
    call    __strcmpi
    add     esp, 8
    xor     edx, edx
    test    eax, eax
    setl    dl
    mov     eax, edx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42DB90 proc near                    ; CODE XREF: sub_491B60+C1p
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+1439Bh]
    push    edi
    push    ecx                             ; wint_t
    call    _iswdigit
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     eax, [edx+14377h]
    push    eax                             ; wint_t
    call    _iswdigit
    mov     edx, TAdynmemStructPtr
    mov     ecx, 1
    add     esp, 4
    xor     ebx, ebx
    mov     eax, [edx+1438Fh]
    mov     ebp, ecx
    cmp     eax, ecx
    jle     loc_42DC83

    loc_42DBDA:                             ; CODE XREF: sub_42DB90+EDj
    mov     esi, [edx+1439Bh]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     edi, ds:0[ecx*4]
    mov     ecx, [edx+14377h]
    lea     eax, [eax+eax*8]
    add     esi, eax
    mov     eax, [ecx+edi]
    cmp     eax, ebx
    jz      short loc_42DC18
    push    eax                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     eax, [edx+14377h]
    mov     [eax+edi], ebx

    loc_42DC18:                             ; CODE XREF: sub_42DB90+6Ej
    mov     eax, [esi+14Eh]
    cmp     eax, ebx
    jz      short loc_42DC31
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [esi+14Eh], ebx

    loc_42DC31:                             ; CODE XREF: sub_42DB90+90j
    mov     eax, [esi+18Eh]
    cmp     eax, ebx
    jz      short loc_42DC47
    push    eax
    call    sub_4B2540
    mov     [esi+18Eh], ebx

    loc_42DC47:                             ; CODE XREF: sub_42DB90+A9j
    mov     eax, [esi+156h]
    cmp     eax, ebx
    jz      short loc_42DC66
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [esi+152h], ebx
    mov     [esi+156h], ebx

    loc_42DC66:                             ; CODE XREF: sub_42DB90+BFj
    mov     edx, TAdynmemStructPtr
    inc     ebp
    mov     ecx, ebp
    mov     eax, [edx+1438Fh]
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      loc_42DBDA

    loc_42DC83:                             ; CODE XREF: sub_42DB90+44j
    mov     esi, [edx+1437Bh]
    cmp     esi, ebx
    jz      short loc_42DC9D
    mov     ecx, esi
    call    sub_4581C0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_42DC9D:                             ; CODE XREF: sub_42DB90+FBj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+1437Bh], ebx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14377h]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     edx, [ecx+1439Bh]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     [eax+14377h], ebx
    mov     ecx, TAdynmemStructPtr
    pop     edi
    pop     esi
    mov     [ecx+1439Bh], ebx
    pop     ebp
    pop     ebx
    retn
    sub_42DB90 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42DCF0 proc near                    ; CODE XREF: sub_4917D0+FFp

    var_2AC= dword ptr -2ACh
    var_2A8= dword ptr -2A8h
    var_2A4= dword ptr -2A4h
    var_29D= byte ptr -29Dh
    var_29C= dword ptr -29Ch
    var_298= dword ptr -298h
    var_290= dword ptr -290h
    var_28C= dword ptr -28Ch
    var_288= dword ptr -288h
    var_284= dword ptr -284h
    var_280= dword ptr -280h
    var_180= dword ptr -180h
    var_100= byte ptr -100h

    sub     esp, 2ACh
    mov     al, [esp+2ACh+var_29D]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    offset off_50341C
    push    offset asc_50372C               ; "*"
    lea     ecx, [esp+2C4h+var_280]
    xor     esi, esi
    push    offset aDownload                ; "download"
    push    ecx
    mov     byte ptr [esp+2CCh+var_290], al
    mov     [esp+2CCh+var_28C], esi
    mov     [esp+2CCh+var_288], esi
    mov     [esp+2CCh+var_284], esi
    call    sub_4290F0
    lea     edx, [esp+2BCh+var_290]
    lea     eax, [esp+2BCh+var_280]
    push    edx
    push    esi
    push    eax
    call    sub_4BCA30
    mov     ecx, [esp+2BCh+var_28C]
    cmp     ecx, esi
    jnz     short loc_42DD49
    xor     ebx, ebx
    mov     [esp+2BCh+var_2AC], ebx
    jmp     short loc_42DD58
    ; ---------------------------------------------------------------------------

    loc_42DD49:                             ; CODE XREF: sub_42DCF0+4Fj
    mov     eax, [esp+2BCh+var_288]
    sub     eax, ecx
    sar     eax, 2
    mov     [esp+2BCh+var_2AC], eax
    mov     ebx, eax

    loc_42DD58:                             ; CODE XREF: sub_42DCF0+57j
    mov     ecx, TAdynmemStructPtr
    mov     eax, ebx
    shl     eax, 6
    sub     eax, ebx
    mov     [ecx+391C7h], ebx
    lea     edx, [eax+eax*2]
    push    edx
    push    offset aDownloadmenu            ; "DOWNLOADMENU"
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    xor     edi, edi
    cmp     ebx, esi
    mov     [ecx+391CBh], eax
    mov     [esp+2BCh+var_2A8], edi
    jle     loc_42DF35

    loc_42DD96:                             ; CODE XREF: sub_42DCF0+23Fj
    lea     ecx, [esp+2BCh+var_29C]
    call    sub_4C2EA0
    mov     edx, [esp+2BCh+var_28C]
    push    offset off_50341C
    lea     ecx, [esp+2C0h+var_280]
    mov     eax, [edx+edi*4]
    push    eax
    push    offset aDownload                ; "download"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+2BCh+var_280]
    lea     ecx, [esp+2BCh+var_29C]
    push    edx
    call    sub_4C2F60
    test    eax, eax
    jz      loc_42DF19
    xor     ebx, ebx
    xor     edi, edi

    loc_42DDD5:                             ; CODE XREF: sub_42DCF0+194j
                                            ; sub_42DCF0+21Cj
    lea     ecx, [esp+2BCh+var_29C]
    call    sub_4C3E10
    push    ebx
    lea     ecx, [esp+2C0h+var_29C]
    call    sub_4C3490
    test    eax, eax
    jz      loc_42DF11
    mov     eax, TAdynmemStructPtr
    lea     ebp, [ebx+1]
    push    offset Data                     ; int
    push    20h                             ; size_t
    mov     ecx, [eax+391CBh]
    lea     edx, [esp+2C4h+var_100]
    push    offset aUnitmenu                ; char *
    push    edx                             ; char *
    mov     [ecx+esi], ebp
    mov     ecx, [esp+2CCh+var_298]
    call    sub_4C48C0
    test    eax, eax
    jz      loc_42DF07
    mov     edx, TAdynmemStructPtr
    xor     ebx, ebx
    mov     eax, [edx+1438Fh]
    test    eax, eax
    jle     loc_42DF07
    xor     eax, eax

    loc_42DE3E:                             ; CODE XREF: sub_42DCF0+18Dj
    lea     ecx, [esp+2BCh+var_100]
    push    ecx                             ; char *
    mov     ecx, eax
    shl     ecx, 6
    add     ecx, eax
    lea     eax, [ecx+ecx*8]
    mov     ecx, [edx+1439Bh]
    lea     edx, [ecx+eax+20h]
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_42DE89
    mov     edx, TAdynmemStructPtr
    inc     ebx
    mov     eax, ebx
    mov     ecx, [edx+1438Fh]
    and     eax, 0FFFFh
    cmp     eax, ecx
    jl      short loc_42DE3E
    mov     ebx, ebp
    add     edi, 25h
    jmp     loc_42DDD5
    ; ---------------------------------------------------------------------------

    loc_42DE89:                             ; CODE XREF: sub_42DCF0+175j
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    push    offset aMenu                    ; char *
    mov     ecx, [eax+391CBh]
    add     ecx, esi
    mov     [ecx+edi+4], bx
    mov     ecx, [esp+2C4h+var_298]
    call    sub_4C46C0
    mov     edx, TAdynmemStructPtr
    push    0                               ; int
    push    offset aButton                  ; char *
    mov     ecx, [edx+391CBh]
    add     ecx, esi
    mov     [ecx+edi+6], al
    mov     ecx, [esp+2C4h+var_298]
    call    sub_4C46C0
    mov     edx, TAdynmemStructPtr
    push    offset Data                     ; int
    push    20h                             ; size_t
    push    offset aUnitname_1              ; char *
    mov     ecx, [edx+391CBh]
    add     ecx, esi
    mov     [ecx+edi+7], al
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391CBh]
    add     eax, esi
    lea     ecx, [eax+edi+8]
    push    ecx                             ; char *
    mov     ecx, [esp+2CCh+var_298]
    call    sub_4C48C0

    loc_42DF07:                             ; CODE XREF: sub_42DCF0+130j
                                            ; sub_42DCF0+146j
    mov     ebx, ebp
    add     edi, 25h
    jmp     loc_42DDD5
    ; ---------------------------------------------------------------------------

    loc_42DF11:                             ; CODE XREF: sub_42DCF0+FAj
    mov     ebx, [esp+2BCh+var_2AC]
    mov     edi, [esp+2BCh+var_2A8]

    loc_42DF19:                             ; CODE XREF: sub_42DCF0+DBj
    lea     ecx, [esp+2BCh+var_29C]
    call    sub_4C2EB0
    inc     edi
    add     esi, 0BDh
    cmp     edi, ebx
    mov     [esp+2BCh+var_2A8], edi
    jl      loc_42DD96

    loc_42DF35:                             ; CODE XREF: sub_42DCF0+A0j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1439Bh]
    push    eax                             ; wint_t
    call    _iswdigit
    mov     edi, TAdynmemStructPtr
    add     esp, 4
    xor     ebp, ebp
    mov     eax, [edi+1438Fh]
    test    eax, eax
    jle     loc_42E001

    loc_42DF60:                             ; CODE XREF: sub_42DCF0+30Bj
    test    ebx, ebx
    jle     loc_42DFEA
    mov     ecx, [esp+2BCh+var_2AC]
    xor     ebx, ebx
    mov     [esp+2BCh+var_2A4], ecx

    loc_42DF72:                             ; CODE XREF: sub_42DCF0+2F4j
    mov     eax, [edi+391CBh]
    xor     edx, edx
    mov     [esp+2BCh+var_2A8], edx
    cmp     [ebx+eax], edx
    jle     short loc_42DFD5

    loc_42DF83:                             ; CODE XREF: sub_42DCF0+2E3j
    lea     esi, [ebx+eax]
    cmp     [esi+edx+4], bp
    jnz     short loc_42DFBC
    mov     ecx, ebp
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, [edi+1439Bh]
    lea     eax, [eax+eax*8]
    lea     eax, [ecx+eax+22Eh]
    mov     cl, [esi+edx+6]
    cmp     [eax], cl
    jnb     short loc_42DFBC
    mov     [eax], cl
    mov     edi, TAdynmemStructPtr

    loc_42DFBC:                             ; CODE XREF: sub_42DCF0+29Bj
                                            ; sub_42DCF0+2C2j
    mov     eax, [edi+391CBh]
    mov     ecx, [esp+2BCh+var_2A8]
    inc     ecx
    add     edx, 25h
    mov     esi, [ebx+eax]
    mov     [esp+2BCh+var_2A8], ecx
    cmp     ecx, esi
    jl      short loc_42DF83

    loc_42DFD5:                             ; CODE XREF: sub_42DCF0+291j
    mov     eax, [esp+2BCh+var_2A4]
    add     ebx, 0BDh
    dec     eax
    mov     [esp+2BCh+var_2A4], eax
    jnz     short loc_42DF72
    mov     ebx, [esp+2BCh+var_2AC]

    loc_42DFEA:                             ; CODE XREF: sub_42DCF0+272j
    mov     eax, [edi+1438Fh]
    inc     ebp
    mov     edx, ebp
    and     edx, 0FFFFh
    cmp     edx, eax
    jl      loc_42DF60

    loc_42E001:                             ; CODE XREF: sub_42DCF0+26Aj
    mov     eax, [edi+1439Bh]
    push    eax                             ; wint_t
    call    _iswlower
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     [esp+2BCh+var_2A4], 0
    mov     ecx, [eax+1438Fh]
    mov     esi, [eax+1439Bh]
    test    ecx, ecx
    jle     loc_42E0DE
    add     esi, 241h

    loc_42E037:                             ; CODE XREF: sub_42DCF0+3E8j
    mov     ecx, [eax+391C7h]
    xor     ebp, ebp
    test    ecx, ecx
    jle     short loc_42E0C1
    lea     edi, [esi-221h]
    xor     ebx, ebx

    loc_42E04B:                             ; CODE XREF: sub_42DCF0+3CFj
    mov     ecx, [eax+391CBh]
    push    edi                             ; char *
    lea     edx, [ecx+ebx+8]
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_42E0AD
    test    byte ptr [esi], 20h
    jnz     short loc_42E0AD
    push    edi
    lea     eax, [esp+2C0h+var_180]
    push    offset aHeySomebodyFor          ; "Hey!  Somebody forgot to set downloadab"...
    push    eax
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     edx, [ecx+1439Bh]
    push    edx                             ; wint_t
    call    _iswdigit
    mov     eax, [esi]
    add     esp, 4
    or      al, 20h
    mov     [esi], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1439Bh]
    push    ecx                             ; wint_t
    call    _iswlower
    add     esp, 4

    loc_42E0AD:                             ; CODE XREF: sub_42DCF0+371j
                                            ; sub_42DCF0+376j
    mov     eax, TAdynmemStructPtr
    inc     ebp
    add     ebx, 0BDh
    cmp     ebp, [eax+391C7h]
    jl      short loc_42E04B

    loc_42E0C1:                             ; CODE XREF: sub_42DCF0+351j
    mov     ecx, [esp+2BCh+var_2A4]
    mov     edx, [eax+1438Fh]
    inc     ecx
    add     esi, 249h
    cmp     ecx, edx
    mov     [esp+2BCh+var_2A4], ecx
    jl      loc_42E037

    loc_42E0DE:                             ; CODE XREF: sub_42DCF0+33Bj
    call    sub_42BE30
    mov     edi, [esp+2BCh+var_288]
    mov     esi, [esp+2BCh+var_28C]
    cmp     esi, edi
    jz      short loc_42E101

    loc_42E0EF:                             ; CODE XREF: sub_42DCF0+40Bj
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_42E0EF
    mov     esi, [esp+2BCh+var_28C]

    loc_42E101:                             ; CODE XREF: sub_42DCF0+3FDj
    push    esi
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2ACh
    retn
    sub_42DCF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42E120 proc near                    ; CODE XREF: sub_491B60+BCp
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391CBh]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    retn
    sub_42E120 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42E140 proc near                    ; CODE XREF: sub_491200+18Fp

    Text= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 100h
    lea     eax, [esp+100h+Text]
    push    esi
    push    offset off_5033A0
    push    offset aPalette_0               ; "PALETTE"
    push    offset aPalettes                ; "palettes"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+104h+Text]
    push    ecx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_42E1A5
    lea     edx, [esp+104h+Text]
    push    0
    push    edx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_42E18A
    lea     eax, [esp+104h+Text]
    push    eax                             ; lpText
    call    sub_4B6290

    loc_42E18A:                             ; CODE XREF: sub_42E140+3Ej
    push    esi
    call    sub_4BAAD0
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, esi
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42E1A5:                             ; CODE XREF: sub_42E140+2Cj
    mov     ecx, [esp+104h+arg_0]
    push    ecx
    call    sub_4BA750
    mov     esi, eax
    push    10000h
    lea     edx, [esp+108h+Text]
    push    esi
    push    edx
    call    sub_4BC290
    mov     eax, esi
    pop     esi
    add     esp, 100h
    retn    4
    sub_42E140 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42E1D0 proc near                    ; CODE XREF: sub_491200+19Fp

    Text= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 100h
    lea     eax, [esp+100h+Text]
    push    esi
    push    offset off_503398
    push    offset aPalette_0               ; "PALETTE"
    push    offset aPalettes                ; "palettes"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+104h+Text]
    push    ecx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_42E235
    lea     edx, [esp+104h+Text]
    push    0
    push    edx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_42E21A
    lea     eax, [esp+104h+Text]
    push    eax                             ; lpText
    call    sub_4B6290

    loc_42E21A:                             ; CODE XREF: sub_42E1D0+3Ej
    push    esi
    call    sub_4BAB00
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, esi
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42E235:                             ; CODE XREF: sub_42E1D0+2Cj
    mov     ecx, [esp+104h+arg_0]
    push    ecx
    call    sub_4BADF0
    mov     esi, eax
    push    2000h
    lea     edx, [esp+108h+Text]
    push    esi
    push    edx
    call    sub_4BC290
    mov     eax, esi
    pop     esi
    add     esp, 100h
    retn    4
    sub_42E1D0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42E260 proc near                    ; CODE XREF: sub_491200+1B1p

    Text= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 100h
    lea     eax, [esp+100h+Text]
    push    esi
    push    offset dword_50339C
    push    offset aPalette_0               ; "PALETTE"
    push    offset aPalettes                ; "palettes"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+104h+Text]
    push    ecx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_42E2C5
    lea     edx, [esp+104h+Text]
    push    0
    push    edx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_42E2AA
    lea     eax, [esp+104h+Text]
    push    eax                             ; lpText
    call    sub_4B6290

    loc_42E2AA:                             ; CODE XREF: sub_42E260+3Ej
    push    esi
    call    sub_4BAB30
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, esi
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42E2C5:                             ; CODE XREF: sub_42E260+2Cj
    mov     ecx, [esp+104h+arg_0]
    push    ecx
    call    sub_4BABD0
    mov     esi, eax
    push    2000h
    lea     edx, [esp+108h+Text]
    push    esi
    push    edx
    call    sub_4BC290
    mov     eax, esi
    pop     esi
    add     esp, 100h
    retn    4
    sub_42E260 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42E2F0 proc near                    ; CODE XREF: sub_491200+1C3p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax
    call    sub_4BAD30
    retn    4
    sub_42E2F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42E300 proc near                    ; CODE XREF: sub_491200+1D3p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax
    call    sub_4BAF30
    retn    4
    sub_42E300 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42E310 proc near                    ; CODE XREF: sub_4917D0+EBp

    var_11D= byte ptr -11Dh
    var_11C= dword ptr -11Ch
    var_118= dword ptr -118h
    var_114= dword ptr -114h
    var_110= dword ptr -110h
    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= dword ptr -100h

    sub     esp, 120h
    xor     edx, edx
    xor     eax, eax
    push    esi
    push    edi

    loc_42E31C:                             ; CODE XREF: sub_42E310+33j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+eax+2DFDh], dl
    inc     edx
    mov     byte ptr [ecx+eax+2CF3h], 0
    lea     ecx, [ecx+eax+2CF3h]
    add     eax, 115h
    cmp     eax, 11500h
    jl      short loc_42E31C
    mov     dl, [esp+128h+var_11D]
    lea     eax, [esp+128h+var_11C]
    push    eax
    push    0
    push    offset aWeapons_tdf             ; "Weapons\\*.tdf"
    mov     byte ptr [esp+134h+var_11C], dl
    mov     [esp+134h+var_118], 0
    mov     [esp+134h+var_114], 0
    mov     [esp+134h+var_110], 0
    call    sub_4BCA30
    mov     esi, [esp+128h+var_118]
    mov     eax, [esp+128h+var_114]
    cmp     esi, eax
    jnb     loc_42E407

    loc_42E386:                             ; CODE XREF: sub_42E310+F1j
    lea     ecx, [esp+128h+var_10C]
    call    sub_4C2EA0
    mov     ecx, [esi]
    push    offset off_50341C
    push    ecx
    lea     edx, [esp+130h+var_100]
    push    offset aWeapons                 ; "Weapons"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+128h+var_100]
    lea     ecx, [esp+128h+var_10C]
    push    eax
    call    sub_4C2F60
    test    eax, eax
    jz      short loc_42E3EF
    mov     eax, [esp+128h+var_104]
    test    eax, eax
    jnz     short loc_42E3C9
    call    sub_41D8A0
    test    eax, eax
    jnz     short loc_42E3EF

    loc_42E3C9:                             ; CODE XREF: sub_42E310+AEj
    xor     edi, edi

    loc_42E3CB:                             ; CODE XREF: sub_42E310+DDj
    lea     ecx, [esp+128h+var_10C]
    call    sub_4C3E10
    push    edi
    lea     ecx, [esp+12Ch+var_10C]
    call    sub_4C3490
    test    eax, eax
    jz      short loc_42E3EF
    mov     ecx, [esp+128h+var_108]
    push    ecx
    call    sub_42E440
    inc     edi
    jmp     short loc_42E3CB
    ; ---------------------------------------------------------------------------

    loc_42E3EF:                             ; CODE XREF: sub_42E310+A6j
                                            ; sub_42E310+B7j ...
    lea     ecx, [esp+128h+var_10C]
    call    sub_4C2EB0
    mov     eax, [esp+128h+var_114]
    add     esi, 4
    cmp     esi, eax
    jb      short loc_42E386
    mov     esi, [esp+128h+var_118]

    loc_42E407:                             ; CODE XREF: sub_42E310+70j
    cmp     esi, eax
    mov     edi, eax
    jz      short loc_42E41F

    loc_42E40D:                             ; CODE XREF: sub_42E310+109j
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_42E40D
    mov     esi, [esp+128h+var_118]

    loc_42E41F:                             ; CODE XREF: sub_42E310+FBj
    push    esi
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    add     esp, 120h
    retn
    sub_42E310 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42E440 proc near                    ; CODE XREF: sub_42E310+D7p

    var_330= dword ptr -330h
    var_32C= dword ptr -32Ch
    var_328= dword ptr -328h
    var_324= dword ptr -324h
    var_31D= byte ptr -31Dh
    var_31C= dword ptr -31Ch
    var_318= dword ptr -318h
    var_314= dword ptr -314h
    var_310= dword ptr -310h
    var_30C= dword ptr -30Ch
    var_308= dword ptr -308h
    var_304= dword ptr -304h
    var_300= byte ptr -300h
    var_200= byte ptr -200h
    Text= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 330h
    push    ebx
    mov     ebx, [esp+334h+arg_0]
    push    ebp
    push    esi
    push    edi
    mov     ecx, ebx
    call    sub_4C4440
    push    0FFFFFFFFh                      ; int
    push    offset aId                      ; char *
    mov     ecx, ebx
    mov     edi, eax
    call    sub_4C46C0
    mov     edx, TAdynmemStructPtr
    lea     ecx, [eax+eax*2]
    shl     ecx, 3
    sub     ecx, eax
    add     edx, eax
    xor     eax, eax
    push    offset Data                     ; int
    lea     ecx, [ecx+ecx*2]
    push    40h                             ; size_t
    push    offset aName                    ; char *
    lea     ebp, [edx+ecx*4+2CF3h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [ebp+20h]
    push    ecx                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    push    0
    push    0                               ; __int64
    push    offset aWeaponvelocity          ; char *
    mov     ecx, ebx
    call    sub_4C4760
    fmul    ds:dbl_4FD240
    call    __ftol
    push    0
    push    0                               ; __int64
    push    offset aStartvelocity           ; char *
    mov     ecx, ebx
    mov     [ebp+68h], eax
    call    sub_4C4760
    fmul    ds:dbl_4FD240
    call    __ftol
    push    0
    push    0                               ; __int64
    push    offset aWeaponaccelera          ; char *
    mov     ecx, ebx
    mov     [ebp+6Ch], eax
    call    sub_4C4760
    fmul    ds:dbl_4FD248
    call    __ftol
    push    7FFFh                           ; int
    push    offset aRange                   ; char *
    mov     ecx, ebx
    mov     [ebp+70h], eax
    call    sub_4C46C0
    push    0                               ; int
    push    offset aCoverage                ; char *
    mov     ecx, ebx
    mov     [ebp+0DCh], eax
    call    sub_4C46C0
    push    0
    push    0                               ; __int64
    push    offset aReloadtime              ; char *
    mov     ecx, ebx
    mov     [ebp+0E0h], eax
    call    sub_4C4760
    fmul    ds:dbl_4FD250
    call    __ftol
    push    0
    push    0                               ; __int64
    push    offset aEnergypershot           ; char *
    mov     ecx, ebx
    mov     [ebp+0E4h], ax
    call    sub_4C4760
    fstp    dword ptr [ebp+0C0h]
    push    0
    push    0                               ; __int64
    push    offset aMetalpershot            ; char *
    mov     ecx, ebx
    call    sub_4C4760
    fstp    dword ptr [ebp+0C4h]
    push    0                               ; int
    push    offset aAreaofeffect            ; char *
    mov     ecx, ebx
    call    sub_4C46C0
    push    0
    push    0                               ; __int64
    push    offset aEdgeeffectiven          ; char *
    mov     ecx, ebx
    mov     [ebp+0D6h], ax
    call    sub_4C4760
    fstp    dword ptr [ebp+0D8h]
    push    0
    push    0                               ; __int64
    push    offset aWeapontimer             ; char *
    mov     ecx, ebx
    call    sub_4C4760
    fmul    ds:dbl_4FD250
    call    __ftol
    push    0                               ; int
    push    offset aNoautorange             ; char *
    mov     ecx, ebx
    mov     [ebp+0E6h], ax
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     edx, 0F7FFFFFFh
    push    0
    shl     eax, 1Bh
    or      edx, eax
    push    0                               ; __int64
    push    offset aTurnrate                ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C4760
    fmul    ds:dbl_4FD258
    call    __ftol
    push    0                               ; int
    push    offset aBurst                   ; char *
    mov     ecx, ebx
    mov     [ebp+0E8h], ax
    call    sub_4C46C0
    push    0
    push    0                               ; __int64
    push    offset aBurstrate               ; char *
    mov     ecx, ebx
    mov     [ebp+0EAh], ax
    call    sub_4C4760
    fmul    ds:dbl_4FD250
    call    __ftol
    push    0                               ; int
    push    offset aSprayangle              ; char *
    mov     ecx, ebx
    mov     [ebp+0ECh], ax
    call    sub_4C46C0
    push    0
    push    0                               ; __int64
    push    offset aDuration                ; char *
    mov     ecx, ebx
    mov     [ebp+0EEh], ax
    call    sub_4C4760
    fmul    ds:dbl_4FD250
    call    __ftol
    push    0
    push    0                               ; __int64
    push    offset aRandomdecay             ; char *
    mov     ecx, ebx
    mov     [ebp+0F0h], ax
    call    sub_4C4760
    fmul    ds:dbl_4FD250
    call    __ftol
    push    0
    push    0                               ; __int64
    push    offset aSmokedelay              ; char *
    mov     ecx, ebx
    mov     [ebp+0F2h], ax
    call    sub_4C4760
    fmul    ds:dbl_4FD250
    call    __ftol
    push    0
    push    0                               ; __int64
    push    offset aFlighttime              ; char *
    mov     ecx, ebx
    mov     [ebp+0FAh], ax
    call    sub_4C4760
    fmul    ds:dbl_4FD250
    call    __ftol
    push    0
    push    0                               ; __int64
    push    offset aHoldtime                ; char *
    mov     ecx, ebx
    mov     [ebp+0FCh], ax
    call    sub_4C4760
    fmul    ds:dbl_4FD250
    call    __ftol
    push    0C0268000h
    push    0                               ; __int64
    push    offset aMinbarrelangle          ; char *
    mov     ecx, ebx
    mov     [ebp+0FEh], ax
    call    sub_4C4760
    fmul    ds:dbl_4FD260
    push    0                               ; int
    push    offset aFirestarter             ; char *
    mov     ecx, ebx
    fstp    dword ptr [ebp+0C8h]
    call    sub_4C46C0
    push    0                               ; int
    push    offset aRendertype              ; char *
    mov     ecx, ebx
    mov     [ebp+10Bh], al
    call    sub_4C46C0
    push    0                               ; int
    push    offset aColor                   ; char *
    mov     ecx, ebx
    mov     [ebp+10Ch], al
    call    sub_4C46C0
    push    0                               ; int
    push    offset aColor2                  ; char *
    mov     ecx, ebx
    mov     [ebp+10Dh], al
    call    sub_4C46C0
    push    0                               ; int
    push    offset aSoundtrigger            ; char *
    mov     ecx, ebx
    mov     [ebp+10Eh], al
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ch, 0F7h
    push    0                               ; int
    shl     eax, 0Bh
    or      ecx, eax
    push    offset aGuidance                ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     dh, 0EFh
    push    0                               ; int
    shl     eax, 0Ch
    or      edx, eax
    push    offset aTracks                  ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     ch, 0DFh
    and     eax, 1
    shl     eax, 0Dh
    or      ecx, eax
    push    0                               ; int
    mov     [ebp+111h], ecx
    push    offset aLineofsight             ; char *
    mov     ecx, ebx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    push    0                               ; int
    mov     edx, ecx
    push    offset aBallistic               ; char *
    xor     edx, eax
    and     edx, 1
    xor     edx, ecx
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    shl     eax, 1
    and     ecx, 0FFFFFFFDh
    push    0                               ; int
    or      eax, ecx
    push    offset aUnitsonly               ; char *
    mov     ecx, ebx
    mov     [ebp+111h], eax
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     dh, 0BFh
    push    0                               ; int
    shl     eax, 0Eh
    or      edx, eax
    push    offset aGroundbounce            ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ch, 7Fh
    push    0                               ; int
    shl     eax, 0Fh
    or      ecx, eax
    push    offset aWaterweapon             ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     edx, 0FFFEFFFFh
    push    0                               ; int
    shl     eax, 10h
    or      edx, eax
    push    offset aToairweapon             ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0FFFDFFFFh
    push    0                               ; int
    shl     eax, 11h
    or      ecx, eax
    push    offset aSmoketrail              ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     edx, 0FFFBFFFFh
    push    0                               ; int
    shl     eax, 12h
    or      edx, eax
    push    offset aTurret                  ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0FFF7FFFFh
    shl     eax, 13h
    or      ecx, eax
    push    0                               ; int
    mov     [ebp+111h], ecx
    push    offset aSelfprop                ; char *
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     edx, 0FFEFFFFFh
    push    0                               ; int
    shl     eax, 14h
    or      edx, eax
    push    offset aPropeller               ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0FFDFFFFFh
    push    0                               ; int
    shl     eax, 15h
    or      ecx, eax
    push    offset aNoexplode               ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     edx, 0FFBFFFFFh
    push    0                               ; int
    shl     eax, 16h
    or      edx, eax
    push    offset aBurnblow                ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0FF7FFFFFh
    push    0                               ; int
    shl     eax, 17h
    or      ecx, eax
    push    offset aTwophase                ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    shl     eax, 18h
    and     edx, 0FEFFFFFFh
    push    0                               ; int
    or      eax, edx
    push    offset aCruise                  ; char *
    mov     ecx, ebx
    mov     [ebp+111h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0FDFFFFFFh
    push    0                               ; int
    shl     eax, 19h
    or      ecx, eax
    push    offset aCommandfire             ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    shl     eax, 1Ah
    and     edx, 0FBFFFFFFh
    push    0                               ; int
    or      eax, edx
    push    offset aStockpile               ; char *
    mov     ecx, ebx
    mov     [ebp+111h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0EFFFFFFFh
    shl     eax, 1Ch
    or      ecx, eax
    mov     [ebp+111h], ecx
    push    0                               ; int
    push    offset aTargetable              ; char *
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     edx, 0DFFFFFFFh
    push    0                               ; int
    shl     eax, 1Dh
    or      edx, eax
    push    offset aInterceptor             ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0BFFFFFFFh
    push    0                               ; int
    shl     eax, 1Eh
    or      ecx, eax
    push    offset aBeamweapon              ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     edx, 0FFFFFFF7h
    push    0                               ; int
    shl     eax, 3
    or      edx, eax
    push    offset aShellweapon             ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0FFFFFFFBh
    push    0                               ; int
    shl     eax, 2
    or      ecx, eax
    push    offset aDropped                 ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    shl     eax, 8
    and     dh, 0FEh
    push    0                               ; int
    or      eax, edx
    push    offset aVlaunch                 ; char *
    mov     ecx, ebx
    mov     [ebp+111h], eax
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0FFFFFFEFh
    push    0                               ; int
    shl     eax, 4
    or      ecx, eax
    push    offset aMeteor                  ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     edx, 0FFFFFFDFh
    push    0                               ; int
    shl     eax, 5
    or      edx, eax
    push    offset aNoradar                 ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ecx, 0FFFFFFBFh
    shl     eax, 6
    or      ecx, eax
    mov     [ebp+111h], ecx
    push    0                               ; int
    push    offset aParalyzer               ; char *
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    and     dl, 7Fh
    push    0                               ; int
    shl     eax, 7
    or      edx, eax
    push    offset aStartsmoke              ; char *
    mov     ecx, ebx
    mov     [ebp+111h], edx
    call    sub_4C46C0
    mov     ecx, [ebp+111h]
    and     eax, 1
    and     ch, 0FDh
    push    0                               ; int
    shl     eax, 9
    or      ecx, eax
    push    offset aEndsmoke                ; char *
    mov     [ebp+111h], ecx
    mov     ecx, ebx
    call    sub_4C46C0
    mov     edx, [ebp+111h]
    and     eax, 1
    shl     eax, 0Ah
    and     dh, 0FBh
    push    0                               ; int
    or      eax, edx
    push    offset aAccuracy                ; char *
    mov     ecx, ebx
    mov     [ebp+111h], eax
    call    sub_4C46C0
    push    0                               ; int
    push    offset aTolerance               ; char *
    mov     ecx, ebx
    mov     [ebp+104h], ax
    call    sub_4C46C0
    push    0                               ; int
    push    offset aPitchtolerance          ; char *
    mov     ecx, ebx
    mov     [ebp+106h], ax
    call    sub_4C46C0
    push    0                               ; int
    push    offset aShakemagnitude          ; char *
    mov     ecx, ebx
    mov     [ebp+108h], ax
    call    sub_4C46C0
    push    0
    push    0                               ; __int64
    push    offset aShakeduration           ; char *
    mov     ecx, ebx
    mov     [ebp+0CCh], eax
    call    sub_4C4760
    fmul    ds:dbl_4FD250
    call    __ftol
    mov     [ebp+0D0h], eax
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     eax, [esp+348h+var_300]
    push    offset aModel                   ; char *
    push    eax                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      loc_42ED9A
    mov     al, [ebp+10Ah]
    mov     byte ptr [esp+340h+var_328], 0
    test    al, al
    mov     byte ptr [esp+340h+var_330], al
    jbe     short loc_42ECF9

    loc_42ECAC:                             ; CODE XREF: sub_42E440+8B7j
    mov     esi, [esp+340h+var_328]
    mov     edx, TAdynmemStructPtr
    mov     eax, esi
    and     eax, 0FFh
    add     edx, eax
    lea     ecx, [eax+eax*2]
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     eax, [edx+ecx*4+2D73h]
    lea     ecx, [esp+340h+var_300]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_42F340
    mov     al, byte ptr [esp+340h+var_328]
    mov     cl, byte ptr [esp+340h+var_330]
    inc     al
    cmp     al, cl
    mov     byte ptr [esp+340h+var_328], al
    jb      short loc_42ECAC

    loc_42ECF9:                             ; CODE XREF: sub_42E440+86Aj
    lea     edx, [esp+340h+var_300]
    push    offset off_5036F0
    push    edx
    lea     eax, [esp+348h+Text]
    push    offset aObjects3d               ; "objects3d"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+340h+Text]
    push    ecx
    call    sub_4CB560
    mov     esi, eax
    test    esi, esi
    jnz     short loc_42ED35
    lea     edx, [esp+340h+Text]
    push    edx                             ; lpText
    call    sub_4B6290

    loc_42ED35:                             ; CODE XREF: sub_42E440+8E6j
    push    esi
    call    sub_4CB590
    lea     eax, [esp+340h+var_300]
    push    eax
    push    esi
    call    sub_42A140
    mov     edx, TAdynmemStructPtr
    lea     edi, [esp+340h+var_300]
    mov     eax, [esp+340h+var_330]
    and     eax, 0FFh
    lea     ecx, [eax+eax*2]
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     eax, [eax+ecx*4]
    mov     [edx+eax+2D67h], esi
    mov     ecx, TAdynmemStructPtr
    lea     edx, [ecx+eax+2D73h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_42EDA1
    ; ---------------------------------------------------------------------------

    loc_42ED9A:                             ; CODE XREF: sub_42E440+853j
    mov     dword ptr [ebp+74h], 0

    loc_42EDA1:                             ; CODE XREF: sub_42E440+958j
                                            ; sub_42E440+F4Ej
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+348h+var_200]
    push    offset aExplosiongaf            ; char *
    xor     edi, edi
    push    ecx                             ; char *
    mov     ecx, ebx
    mov     [ebp+78h], edi
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42EE06
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+348h+var_300]
    push    offset aExplosionart            ; char *
    push    edx                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42EE06
    lea     eax, [esp+340h+var_200]
    push    eax
    call    sub_429700
    lea     ecx, [esp+340h+var_300]
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     byte ptr [eax+2], 0
    mov     [ebp+78h], eax

    loc_42EE06:                             ; CODE XREF: sub_42E440+986j
                                            ; sub_42E440+9A5j
    mov     [ebp+7Ch], edi
    mov     edx, TAdynmemStructPtr
    push    offset Data                     ; int
    push    100h                            ; size_t
    mov     eax, [edx+391E9h]
    cmp     [eax+0D44h], edi
    jz      short loc_42EE76
    lea     ecx, [esp+348h+var_200]
    push    offset aLavaexplosiong          ; char *
    push    ecx                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      loc_42EECC
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+348h+var_300]
    push    offset aLavaexplosiona          ; char *
    push    edx                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42EECC
    lea     eax, [esp+340h+var_200]
    push    eax
    call    sub_429700
    lea     ecx, [esp+340h+var_300]
    push    ecx                             ; int
    jmp     short loc_42EEBF                ; size_t
    ; ---------------------------------------------------------------------------

    loc_42EE76:                             ; CODE XREF: sub_42E440+9E5j
    lea     edx, [esp+348h+var_200]
    push    offset aWaterexplosion          ; char *
    push    edx                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42EECC
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     eax, [esp+348h+var_300]
    push    offset aWaterexplosi_0          ; char *
    push    eax                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42EECC
    lea     ecx, [esp+340h+var_200]
    push    ecx
    call    sub_429700
    lea     edx, [esp+340h+var_300]
    push    edx                             ; char *

    loc_42EEBF:                             ; CODE XREF: sub_42E440+A34j
    push    eax                             ; int
    call    sub_4B8D40
    mov     byte ptr [eax+2], 0
    mov     [ebp+7Ch], eax

    loc_42EECC:                             ; CODE XREF: sub_42E440+9FDj
                                            ; sub_42E440+A20j ...
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     eax, [esp+348h+var_300]
    push    offset aSoundstart              ; char *
    push    eax                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    mov     esi, 0FFFFh
    jz      short loc_42EF04
    lea     ecx, [esp+340h+var_300]
    push    ecx
    push    edi
    call    sub_429470
    mov     [ebp+0F4h], ax
    jmp     short loc_42EF0B
    ; ---------------------------------------------------------------------------

    loc_42EF04:                             ; CODE XREF: sub_42E440+AAEj
    mov     [ebp+0F4h], si

    loc_42EF0B:                             ; CODE XREF: sub_42E440+AC2j
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+348h+var_300]
    push    offset aSoundhit                ; char *
    push    edx                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42EF3E
    lea     eax, [esp+340h+var_300]
    push    eax
    push    edi
    call    sub_429470
    mov     [ebp+0F6h], ax
    jmp     short loc_42EF45
    ; ---------------------------------------------------------------------------

    loc_42EF3E:                             ; CODE XREF: sub_42E440+AE8j
    mov     [ebp+0F6h], si

    loc_42EF45:                             ; CODE XREF: sub_42E440+AFCj
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+348h+var_300]
    push    offset aSoundwater              ; char *
    push    ecx                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42EF78
    lea     edx, [esp+340h+var_300]
    push    edx
    push    edi
    call    sub_429470
    mov     [ebp+0F8h], ax
    jmp     short loc_42EF7F
    ; ---------------------------------------------------------------------------

    loc_42EF78:                             ; CODE XREF: sub_42E440+B22j
    mov     [ebp+0F8h], si

    loc_42EF7F:                             ; CODE XREF: sub_42E440+B36j
    push    offset aDamage                  ; char *
    mov     ecx, ebx
    call    sub_4C4470
    mov     ebx, eax
    cmp     ebx, edi
    mov     [esp+340h+var_308], ebx
    jz      loc_42F326
    push    edi                             ; int
    push    offset aDefault                 ; char *
    mov     ecx, ebx
    call    sub_4C46C0
    push    edi
    mov     ecx, ebx
    mov     [ebp+0D4h], ax
    mov     [esp+344h+var_314], edi
    call    sub_4C45E0
    mov     esi, eax
    cmp     esi, edi
    jz      loc_42F32D

    loc_42EFC3:                             ; CODE XREF: sub_42E440+ECDj
    push    offset aDefault                 ; char *
    push    esi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_42F2F8
    push    edi                             ; int
    push    esi                             ; char *
    mov     ecx, ebx
    call    sub_4C46C0
    mov     [esp+340h+var_310], eax
    mov     eax, [ebp+64h]
    cmp     eax, edi
    jnz     short loc_42F012
    push    11h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    jz      short loc_42F00D
    mov     cl, [esp+340h+var_31D]
    mov     [eax+5], edi
    mov     [eax+1], cl
    mov     [eax+9], edi
    mov     [eax+0Dh], edi
    jmp     short loc_42F00F
    ; ---------------------------------------------------------------------------

    loc_42F00D:                             ; CODE XREF: sub_42E440+BB9j
    xor     eax, eax

    loc_42F00F:                             ; CODE XREF: sub_42E440+BCBj
    mov     [ebp+64h], eax

    loc_42F012:                             ; CODE XREF: sub_42E440+BABj
    push    esi
    lea     ecx, [esp+344h+var_328]
    call    sub_4C91B0
    mov     eax, [ebp+64h]
    mov     edx, [esp+340h+var_328]
    mov     [esp+340h+var_330], eax
    mov     esi, [eax+5]
    mov     ebx, [eax+9]
    cmp     esi, ebx
    mov     [esp+340h+var_32C], edx
    jz      short loc_42F06F

    loc_42F035:                             ; CODE XREF: sub_42E440+C29j
    mov     eax, ebx
    sub     eax, esi
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     ecx, [esi+eax*8]
    lea     edi, [esi+eax*8]
    mov     eax, [esp+340h+var_32C]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     edx, edx
    test    eax, eax
    setl    dl
    test    dl, dl
    jz      short loc_42F065
    lea     esi, [edi+8]
    jmp     short loc_42F067
    ; ---------------------------------------------------------------------------

    loc_42F065:                             ; CODE XREF: sub_42E440+C1Ej
    mov     ebx, edi

    loc_42F067:                             ; CODE XREF: sub_42E440+C23j
    cmp     esi, ebx
    jnz     short loc_42F035
    mov     eax, [esp+340h+var_330]

    loc_42F06F:                             ; CODE XREF: sub_42E440+BF3j
    cmp     esi, [eax+9]
    jz      short loc_42F0BF
    mov     edi, [esp+340h+var_328]
    mov     eax, [esi]

    loc_42F07A:                             ; CODE XREF: sub_42E440+C5Cj
    mov     dl, [eax]
    mov     bl, [edi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_42F0A2
    test    cl, cl
    jz      short loc_42F09E
    mov     dl, [eax+1]
    mov     bl, [edi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_42F0A2
    add     eax, 2
    add     edi, 2
    test    cl, cl
    jnz     short loc_42F07A

    loc_42F09E:                             ; CODE XREF: sub_42E440+C46j
    xor     eax, eax
    jmp     short loc_42F0A7
    ; ---------------------------------------------------------------------------

    loc_42F0A2:                             ; CODE XREF: sub_42E440+C42j
                                            ; sub_42E440+C52j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_42F0A7:                             ; CODE XREF: sub_42E440+C60j
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_42F0BF
    add     esi, 4
    jmp     loc_42F2E3
    ; ---------------------------------------------------------------------------

    loc_42F0BF:                             ; CODE XREF: sub_42E440+C32j
                                            ; sub_42E440+C75j
    lea     edx, [esp+340h+var_328]
    lea     ecx, [esp+340h+var_31C]
    push    edx
    call    sub_4C91A0
    mov     ecx, esi
    mov     [esp+340h+var_318], 0
    mov     eax, [esp+340h+var_330]
    lea     ebx, [eax+1]
    mov     eax, [eax+5]
    mov     edi, [ebx+8]
    sub     ecx, eax
    sar     ecx, 3
    mov     [esp+340h+var_30C], ecx
    mov     ecx, [ebx+0Ch]
    sub     ecx, edi
    sar     ecx, 3
    cmp     ecx, 1
    jnb     loc_42F22B
    test    eax, eax
    jnz     short loc_42F106
    xor     ecx, ecx
    jmp     short loc_42F10D
    ; ---------------------------------------------------------------------------

    loc_42F106:                             ; CODE XREF: sub_42E440+CC0j
    mov     ecx, edi
    sub     ecx, eax
    sar     ecx, 3

    loc_42F10D:                             ; CODE XREF: sub_42E440+CC4j
    cmp     ecx, 1
    jbe     short loc_42F123
    test    eax, eax
    jnz     short loc_42F11A
    xor     ecx, ecx
    jmp     short loc_42F128
    ; ---------------------------------------------------------------------------

    loc_42F11A:                             ; CODE XREF: sub_42E440+CD4j
    mov     ecx, edi
    sub     ecx, eax
    sar     ecx, 3
    jmp     short loc_42F128
    ; ---------------------------------------------------------------------------

    loc_42F123:                             ; CODE XREF: sub_42E440+CD0j
    mov     ecx, 1

    loc_42F128:                             ; CODE XREF: sub_42E440+CD8j
                                            ; sub_42E440+CE1j
    test    eax, eax
    jnz     short loc_42F130
    xor     edi, edi
    jmp     short loc_42F135
    ; ---------------------------------------------------------------------------

    loc_42F130:                             ; CODE XREF: sub_42E440+CEAj
    sub     edi, eax
    sar     edi, 3

    loc_42F135:                             ; CODE XREF: sub_42E440+CEEj
    lea     eax, [edi+ecx]
    test    eax, eax
    mov     [esp+340h+var_324], eax
    jge     short loc_42F142
    xor     eax, eax

    loc_42F142:                             ; CODE XREF: sub_42E440+CFEj
    lea     edx, ds:0[eax*8]
    push    edx                             ; int
    call    sub_4B4F10
    mov     edi, [ebx+4]
    add     esp, 4
    cmp     edi, esi
    mov     [esp+340h+var_304], eax
    mov     [esp+340h+var_330], eax
    jz      short loc_42F17E

    loc_42F161:                             ; CODE XREF: sub_42E440+D3Cj
    mov     eax, [esp+340h+var_330]
    push    edi
    push    eax
    call    sub_432CF0
    add     edi, 8
    mov     edx, [esp+340h+var_330]
    add     edx, 8
    cmp     edi, esi
    mov     [esp+340h+var_330], edx
    jnz     short loc_42F161

    loc_42F17E:                             ; CODE XREF: sub_42E440+D1Fj
    mov     edi, [esp+340h+var_330]
    mov     [esp+340h+var_32C], 1

    loc_42F18A:                             ; CODE XREF: sub_42E440+D61j
    lea     ecx, [esp+340h+var_31C]
    push    ecx
    push    edi
    call    sub_432CF0
    add     edi, 8
    mov     eax, [esp+340h+var_32C]
    dec     eax
    mov     [esp+340h+var_32C], eax
    jnz     short loc_42F18A
    mov     eax, [ebx+8]
    cmp     esi, eax
    mov     [esp+340h+var_32C], eax
    jz      short loc_42F1C8
    mov     edx, [esp+340h+var_330]
    lea     edi, [edx+8]

    loc_42F1B5:                             ; CODE XREF: sub_42E440+D86j
    push    esi
    push    edi
    call    sub_432CF0
    add     esi, 8
    add     edi, 8
    cmp     esi, [esp+340h+var_32C]
    jnz     short loc_42F1B5

    loc_42F1C8:                             ; CODE XREF: sub_42E440+D6Cj
    mov     edi, [ebx+8]
    mov     esi, [ebx+4]
    cmp     esi, edi
    jz      short loc_42F1E2

    loc_42F1D2:                             ; CODE XREF: sub_42E440+DA0j
    push    0
    mov     ecx, esi
    call    sub_432C20
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_42F1D2

    loc_42F1E2:                             ; CODE XREF: sub_42E440+D90j
    mov     eax, [ebx+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+344h+var_304]
    mov     eax, [esp+344h+var_324]
    add     esp, 4
    lea     ecx, [edx+eax*8]
    mov     [ebx+0Ch], ecx
    mov     ecx, [ebx+4]
    test    ecx, ecx
    jnz     short loc_42F214
    xor     eax, eax
    mov     [ebx+4], edx
    lea     eax, [edx+eax*8+8]
    mov     [ebx+8], eax
    jmp     loc_42F2CF
    ; ---------------------------------------------------------------------------

    loc_42F214:                             ; CODE XREF: sub_42E440+DC1j
    mov     eax, [ebx+8]
    mov     [ebx+4], edx
    sub     eax, ecx
    sar     eax, 3
    lea     eax, [edx+eax*8+8]
    mov     [ebx+8], eax
    jmp     loc_42F2CF
    ; ---------------------------------------------------------------------------

    loc_42F22B:                             ; CODE XREF: sub_42E440+CB8j
    mov     ecx, edi
    sub     ecx, esi
    sar     ecx, 3
    cmp     ecx, 1
    jnb     short loc_42F2A1
    cmp     esi, edi
    mov     eax, esi
    jz      short loc_42F253

    loc_42F23D:                             ; CODE XREF: sub_42E440+E11j
    lea     ecx, [eax+8]
    push    eax
    push    ecx
    mov     [esp+348h+var_324], ecx
    call    sub_432CF0
    mov     eax, [esp+340h+var_324]
    cmp     eax, edi
    jnz     short loc_42F23D

    loc_42F253:                             ; CODE XREF: sub_42E440+DFBj
    mov     ecx, [ebx+8]
    mov     eax, 1
    mov     edx, ecx
    mov     edi, ecx
    sub     edx, esi
    sar     edx, 3
    sub     eax, edx
    jz      short loc_42F285
    mov     [esp+340h+var_32C], eax

    loc_42F26C:                             ; CODE XREF: sub_42E440+E43j
    lea     eax, [esp+340h+var_31C]
    push    eax
    push    edi
    call    sub_432CF0
    add     edi, 8
    mov     eax, [esp+340h+var_32C]
    dec     eax
    mov     [esp+340h+var_32C], eax
    jnz     short loc_42F26C

    loc_42F285:                             ; CODE XREF: sub_42E440+E26j
    mov     edi, [ebx+8]
    cmp     esi, edi
    jz      short loc_42F2CB

    loc_42F28C:                             ; CODE XREF: sub_42E440+E5Dj
    lea     ecx, [esp+340h+var_31C]
    push    ecx
    mov     ecx, esi
    call    sub_432D20
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_42F28C
    jmp     short loc_42F2CB
    ; ---------------------------------------------------------------------------

    loc_42F2A1:                             ; CODE XREF: sub_42E440+DF5j
    push    edi
    push    edi
    add     edi, 0FFFFFFF8h
    mov     ecx, ebx
    push    edi
    call    sub_432C40
    mov     eax, [ebx+8]
    push    eax
    add     eax, 0FFFFFFF8h
    push    eax
    push    esi
    call    sub_432CB0
    lea     edx, [esp+340h+var_31C]
    lea     eax, [esi+8]
    push    edx
    push    eax
    push    esi
    call    sub_432C80

    loc_42F2CB:                             ; CODE XREF: sub_42E440+E4Aj
                                            ; sub_42E440+E5Fj
    add     dword ptr [ebx+8], 8

    loc_42F2CF:                             ; CODE XREF: sub_42E440+DCFj
                                            ; sub_42E440+DE6j
    mov     ebx, [ebx+4]
    lea     ecx, [esp+340h+var_31C]
    call    sub_4C9390
    mov     ecx, [esp+340h+var_30C]
    lea     esi, [ebx+ecx*8+4]

    loc_42F2E3:                             ; CODE XREF: sub_42E440+C7Aj
    mov     edx, [esp+340h+var_310]
    lea     ecx, [esp+340h+var_328]
    mov     [esi], edx
    call    sub_4C9390
    mov     ebx, [esp+340h+var_308]
    xor     edi, edi

    loc_42F2F8:                             ; CODE XREF: sub_42E440+B93j
    mov     eax, [esp+340h+var_314]
    mov     ecx, ebx
    inc     eax
    push    eax
    mov     [esp+344h+var_314], eax
    call    sub_4C45E0
    mov     esi, eax
    cmp     esi, edi
    jnz     loc_42EFC3
    push    ebp
    call    sub_49E010
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 330h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42F326:                             ; CODE XREF: sub_42E440+B53j
    mov     [ebp+0D4h], di

    loc_42F32D:                             ; CODE XREF: sub_42E440+B7Dj
    push    ebp
    call    sub_49E010
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 330h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_42F340:                             ; CODE XREF: sub_42E440+8A1j
    mov     eax, [esp+340h+var_330]
    and     esi, 0FFh
    and     eax, 0FFh
    lea     ecx, [eax+eax*2]
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    mov     ecx, esi
    lea     edx, [eax+edx*4]
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+edx+2D73h], 0
    lea     eax, [ecx+ecx*2]
    shl     eax, 3
    sub     eax, ecx
    lea     esi, [eax+eax*2]
    mov     eax, TAdynmemStructPtr
    mov     edi, eax
    add     edi, ecx
    mov     ecx, [edi+esi*4+2D67h]
    mov     [eax+edx+2D67h], ecx
    jmp     loc_42EDA1
    sub_42E440 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42F3A0 proc near                    ; CODE XREF: sub_491B60+C6p

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    xor     ebx, ebx
    push    esi
    push    edi
    mov     [esp+14h+var_4], ebx

    loc_42F3AB:                             ; CODE XREF: sub_42F3A0+9Bj
    mov     eax, TAdynmemStructPtr
    or      ecx, 0FFFFFFFFh
    lea     ebp, [eax+ebx+2CF3h]
    xor     eax, eax
    lea     esi, [ebp+80h]
    mov     edi, esi
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_42F3E1
    mov     ecx, [ebp+74h]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [ebp+74h], 0
    mov     byte ptr [esi], 0

    loc_42F3E1:                             ; CODE XREF: sub_42F3A0+29j
    mov     edi, [ebp+64h]
    test    edi, edi
    jz      short loc_42F42B
    mov     ebx, [edi+9]
    mov     esi, [edi+5]
    cmp     esi, ebx
    jz      short loc_42F400

    loc_42F3F2:                             ; CODE XREF: sub_42F3A0+5Ej
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 8
    cmp     esi, ebx
    jnz     short loc_42F3F2

    loc_42F400:                             ; CODE XREF: sub_42F3A0+50j
    mov     edx, [edi+5]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [edi+5], eax
    mov     [edi+9], eax
    push    edi
    mov     [edi+0Dh], eax
    call    sub_4B4F20
    mov     ebx, [esp+18h+var_4]
    add     esp, 4
    mov     dword ptr [ebp+64h], 0

    loc_42F42B:                             ; CODE XREF: sub_42F3A0+46j
    add     ebx, 115h
    cmp     ebx, 11500h
    mov     [esp+14h+var_4], ebx
    jl      loc_42F3AB
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_42F3A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42F450 proc near                    ; CODE XREF: sub_42F580+114p
                                            ; sub_42F580+13Fp ...

    var_180= byte ptr -180h
    var_140= byte ptr -140h
    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 180h
    lea     eax, [esp+180h+var_140]
    push    esi
    mov     esi, [esp+184h+arg_0]
    push    edi
    mov     edi, [esp+188h+arg_4]
    mov     ecx, [esi+4]
    push    offset Data                     ; int
    push    40h                             ; size_t
    push    edi                             ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jz      loc_42F56C
    push    ebx
    push    offset aText                    ; "text"
    push    edi
    lea     ecx, [esp+194h+var_100]
    push    offset aSS_2                    ; "%s%s"
    push    ecx
    call    _sprintf
    mov     ecx, [esi+4]
    add     esp, 10h
    lea     edx, [esp+18Ch+var_100]
    lea     eax, [esp+18Ch+var_180]
    push    offset Data                     ; int
    push    40h                             ; size_t
    push    edx                             ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jnz     short loc_42F4C3
    mov     [esp+18Ch+var_180], al

    loc_42F4C3:                             ; CODE XREF: sub_42F450+6Dj
    mov     ebx, [esp+18Ch+arg_8]
    mov     ecx, [ebx]
    mov     edx, [ebx+4]
    inc     ecx
    shl     ecx, 6
    push    ecx                             ; int
    push    offset aSayChoiceArray          ; int
    push    edx                             ; int
    call    Network_ReAllocPacketBuffer
    mov     ecx, [ebx+8]
    mov     [ebx+4], eax
    mov     eax, [ebx]
    add     esp, 0Ch
    inc     eax
    shl     eax, 6
    push    eax                             ; int
    push    offset aSayChoiceArray          ; int
    push    ecx                             ; int
    call    Network_ReAllocPacketBuffer
    mov     edx, [ebx]
    mov     ecx, [ebx+4]
    shl     edx, 6
    mov     [ebx+8], eax
    add     edx, ecx
    lea     edi, [esp+198h+var_140]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edx, [ebx]
    mov     ecx, [ebx+8]
    shl     edx, 6
    add     edx, ecx
    lea     edi, [esp+18Ch+var_180]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebx]
    inc     eax
    mov     [ebx], eax
    mov     eax, 1
    pop     ebx
    pop     edi
    pop     esi
    add     esp, 180h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_42F56C:                             ; CODE XREF: sub_42F450+2Dj
    pop     edi
    xor     eax, eax
    pop     esi
    add     esp, 180h
    retn    0Ch
    sub_42F450 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42F580 proc near                    ; CODE XREF: sub_42F7E0+C2p

    var_130= dword ptr -130h
    var_12C= dword ptr -12Ch
    var_124= dword ptr -124h
    var_120= dword ptr -120h
    var_100= dword ptr -100h

    mov     eax, TAdynmemStructPtr
    sub     esp, 130h
    push    ebx
    xor     ebx, ebx
    mov     [eax+37E17h], ebx
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E13h], ebx
    lea     ecx, [esp+134h+var_130]
    call    sub_4C2EA0
    push    offset off_50341C
    push    offset aSound                   ; "sound"
    lea     edx, [esp+13Ch+var_100]
    push    offset aGamedata                ; "gamedata"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+134h+var_100]
    lea     ecx, [esp+134h+var_130]
    push    eax
    call    sub_4C2F60
    test    eax, eax
    jz      loc_42F72F
    mov     ecx, [esp+134h+var_130]
    push    edi
    push    esi
    push    ebp
    call    sub_4C4450
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E17h], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E17h]
    lea     ecx, [eax+eax*4]
    lea     esi, [eax+ecx*2]
    shl     esi, 5
    push    esi
    push    offset aSoundCategorie          ; "Sound Categories"
    call    sub_4D83B0
    mov     edx, TAdynmemStructPtr
    mov     ecx, esi
    add     esp, 8
    xor     ebp, ebp
    mov     [edx+37E13h], eax
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     edi, [edx+37E13h]
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     eax, TAdynmemStructPtr
    cmp     [eax+37E17h], ebx
    jle     loc_42F723
    mov     [esp+140h+var_124], ebx

    loc_42F654:                             ; CODE XREF: sub_42F580+19Dj
    mov     edi, [eax+37E13h]
    lea     ecx, [esp+140h+var_130]
    add     edi, ebx
    call    sub_4C3E10
    push    ebp
    lea     ecx, [esp+144h+var_130]
    call    sub_4C3490
    test    eax, eax
    jz      loc_42F701
    mov     ecx, [esp+140h+var_12C]
    push    3Fh                             ; size_t
    push    edi                             ; char *
    call    sub_4C4420
    mov     esi, offset off_5086FC
    add     edi, 4Ch

    loc_42F68B:                             ; CODE XREF: sub_42F580+17Fj
    mov     eax, [esi]
    push    edi
    lea     ecx, [esp+144h+var_130]
    push    eax
    push    ecx
    call    sub_42F450
    mov     edx, [esi]
    mov     ebx, 1
    push    ebx
    push    edx
    lea     eax, [esp+148h+var_120]
    push    offset aSI                      ; "%s%i"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+140h+var_120]
    lea     edx, [esp+140h+var_130]
    push    edi
    push    ecx
    push    edx
    call    sub_42F450
    test    eax, eax
    jz      short loc_42F6F3

    loc_42F6C8:                             ; CODE XREF: sub_42F580+171j
    mov     eax, [esi]
    inc     ebx
    push    ebx
    push    eax
    lea     ecx, [esp+148h+var_120]
    push    offset aSI                      ; "%s%i"
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+140h+var_120]
    lea     eax, [esp+140h+var_130]
    push    edi
    push    edx
    push    eax
    call    sub_42F450
    test    eax, eax
    jnz     short loc_42F6C8

    loc_42F6F3:                             ; CODE XREF: sub_42F580+146j
    add     esi, 18h
    add     edi, 0Ch
    cmp     esi, offset dword_508924
    jl      short loc_42F68B

    loc_42F701:                             ; CODE XREF: sub_42F580+F1j
    mov     eax, TAdynmemStructPtr
    mov     ebx, [esp+140h+var_124]
    inc     ebp
    add     ebx, 160h
    mov     ecx, [eax+37E17h]
    mov     [esp+140h+var_124], ebx
    cmp     ebp, ecx
    jl      loc_42F654

    loc_42F723:                             ; CODE XREF: sub_42F580+CAj
    lea     ecx, [esp+140h+var_130]
    call    sub_4C3240
    pop     ebp
    pop     esi
    pop     edi

    loc_42F72F:                             ; CODE XREF: sub_42F580+52j
    lea     ecx, [esp+134h+var_130]
    call    sub_4C2EB0
    pop     ebx
    add     esp, 130h
    retn
    sub_42F580 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42F740 proc near                    ; CODE XREF: sub_42F8C0+1p
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+37E17h]
    test    eax, eax
    jle     short loc_42F7C0
    push    ebp
    xor     ebp, ebp
    test    eax, eax
    jle     short loc_42F7AA
    push    edi
    push    esi
    push    ebx
    xor     ebx, ebx

    loc_42F75C:                             ; CODE XREF: sub_42F740+65j
    mov     eax, [ecx+37E13h]
    mov     edi, 18h
    add     eax, ebx
    lea     esi, [eax+44h]

    loc_42F76C:                             ; CODE XREF: sub_42F740+54j
    mov     eax, [esi-4]
    test    eax, eax
    jle     short loc_42F790
    mov     eax, [esi]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, [esi+4]
    add     esp, 4
    push    ecx                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4

    loc_42F790:                             ; CODE XREF: sub_42F740+31j
    add     esi, 0Ch
    dec     edi
    jnz     short loc_42F76C
    mov     eax, [ecx+37E17h]
    inc     ebp
    add     ebx, 160h
    cmp     ebp, eax
    jl      short loc_42F75C
    pop     ebx
    pop     esi
    pop     edi

    loc_42F7AA:                             ; CODE XREF: sub_42F740+15j
    mov     edx, [ecx+37E13h]
    push    edx                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    pop     ebp

    loc_42F7C0:                             ; CODE XREF: sub_42F740+Ej
    xor     eax, eax
    mov     [ecx+37E17h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E13h], eax
    retn
    sub_42F740 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42F7E0 proc near                    ; CODE XREF: sub_491200+17Dp

    var_22C= dword ptr -22Ch
    var_228= dword ptr -228h
    var_220= byte ptr -220h
    var_200= dword ptr -200h
    var_100= byte ptr -100h

    sub     esp, 22Ch
    lea     ecx, [esp+22Ch+var_22C]
    call    sub_4C2EA0
    mov     eax, TAdynmemStructPtr
    push    offset off_50341C
    push    offset aAllsound                ; "allsound"
    lea     ecx, [esp+234h+var_200]
    push    offset aGamedata                ; "gamedata"
    push    ecx
    mov     dword ptr [eax+33A0Fh], 0
    call    sub_4290F0
    lea     edx, [esp+22Ch+var_200]
    lea     ecx, [esp+22Ch+var_22C]
    push    edx
    call    sub_4C2F60
    test    eax, eax
    jz      short loc_42F8A2
    push    esi
    xor     esi, esi
    push    esi
    lea     ecx, [esp+234h+var_22C]
    call    sub_4C3490
    test    eax, eax
    jz      short loc_42F898

    loc_42F83A:                             ; CODE XREF: sub_42F7E0+B6j
    mov     ecx, [esp+230h+var_228]
    lea     eax, [esp+230h+var_220]
    push    20h                             ; size_t
    push    eax                             ; char *
    call    sub_4C4420
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+238h+var_100]
    push    offset aSound                   ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+240h+var_228]
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_42F880
    lea     edx, [esp+230h+var_100]
    lea     eax, [esp+230h+var_220]
    push    edx
    push    eax
    call    sub_429470

    loc_42F880:                             ; CODE XREF: sub_42F7E0+8Cj
    lea     ecx, [esp+230h+var_22C]
    inc     esi
    call    sub_4C3E10
    push    esi
    lea     ecx, [esp+234h+var_22C]
    call    sub_4C3490
    test    eax, eax
    jnz     short loc_42F83A

    loc_42F898:                             ; CODE XREF: sub_42F7E0+58j
    lea     ecx, [esp+230h+var_22C]
    call    sub_4C3240
    pop     esi

    loc_42F8A2:                             ; CODE XREF: sub_42F7E0+47j
    call    sub_42F580
    lea     ecx, [esp+22Ch+var_22C]
    call    sub_4C2EB0
    add     esp, 22Ch
    retn
    sub_42F7E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42F8C0 proc near                    ; CODE XREF: sub_4916A0+9Dp
    push    esi
    call    sub_42F740
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     ecx, [eax+33A0Fh]
    test    ecx, ecx
    jle     short loc_42F8F2

    loc_42F8D7:                             ; CODE XREF: sub_42F8C0+30j
    mov     eax, [eax+esi*4+33A13h]
    push    eax
    call    sub_47F060
    mov     eax, TAdynmemStructPtr
    inc     esi
    cmp     esi, [eax+33A0Fh]
    jl      short loc_42F8D7

    loc_42F8F2:                             ; CODE XREF: sub_42F8C0+15j
    mov     dword ptr [eax+33A0Fh], 0
    pop     esi
    retn
    sub_42F8C0 endp

    ; ---------------------------------------------------------------------------
    align 4
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 0Ch
    push    esi
    push    edi
    mov     edi, [esp+18h]
    xor     esi, esi

    loc_42F91B:                             ; CODE XREF: .text:0042F947j
    push    esi
    lea     eax, [esp+0Ch]
    push    offset aTrackD                  ; "track%d"
    push    eax
    call    _sprintf
    xor     ecx, ecx
    add     esp, 0Ch
    mov     cl, [esi+edi]
    lea     edx, [esp+8]
    push    ecx
    push    edx
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    inc     esi
    cmp     esi, 0Ah
    jl      short loc_42F91B
    pop     edi
    pop     esi
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_42F960 proc near                    ; CODE XREF: sub_442050+14Dp
                                            ; sub_4423C0+12Ap ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    mov     ecx, [esp+arg_4]
    mov     edx, [esp+arg_0]
    push    eax
    push    ecx
    push    edx
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_4
    retn    0Ch
    sub_42F960 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_42F980(LPCSTR lpValueName,BYTE *lpData,LPDWORD lpcbData)
    sub_42F980 proc near                    ; CODE XREF: .text:004422A5p
                                            ; .text:00442608p ...

    lpValueName= dword ptr  4
    lpData= dword ptr  8
    lpcbData= dword ptr  0Ch

    mov     eax, [esp+lpcbData]
    mov     ecx, [esp+lpData]
    mov     edx, [esp+lpValueName]
    push    eax                             ; lpcbData
    push    ecx                             ; lpData
    push    edx                             ; lpValueName
    push    offset aTotalAnnihil_0          ; lpSubKey
    call    WriteRegistryValue_1
    retn    0Ch
    sub_42F980 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl WriteRegistrySettings_1()
    WriteRegistrySettings_1 proc near       ; CODE XREF: sub_47B9F0+162p
                                            ; sub_491200+1F6p

    aDitheredfog= dword ptr -124h
    var_120= byte ptr -120h
    var_100= dword ptr -100h

    sub     esp, 124h
    lea     eax, [esp+124h+aDitheredfog]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    eax
    push    offset aInterfaceType           ; "Interface Type"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    xor     ebx, ebx
    mov     edi, 1
    cmp     eax, ebx
    jz      short loc_42F9E5
    mov     eax, [esp+134h+aDitheredfog]
    cmp     eax, edi
    jle     short loc_42F9D7
    mov     eax, edi
    mov     [esp+134h+aDitheredfog], eax

    loc_42F9D7:                             ; CODE XREF: WriteRegistrySettings_1+2Fj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37EFAh], eax
    jmp     short loc_42FA0C
    ; ---------------------------------------------------------------------------

    loc_42F9E5:                             ; CODE XREF: WriteRegistrySettings_1+27j
    mov     edx, TAdynmemStructPtr
    mov     [edx+37EFAh], ebx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EFAh]
    push    ecx
    push    offset aInterfaceType           ; "Interface Type"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FA0C:                             ; CODE XREF: WriteRegistrySettings_1+43j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aDisplaymodewid          ; "DisplaymodeWidth"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FA36
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     [ecx+37F1Bh], eax
    jmp     short loc_42FA61
    ; ---------------------------------------------------------------------------

    loc_42FA36:                             ; CODE XREF: WriteRegistrySettings_1+82j
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37F1Bh], 280h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F1Bh]
    push    ecx
    push    offset aDisplaymodewid          ; "DisplaymodeWidth"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FA61:                             ; CODE XREF: WriteRegistrySettings_1+94j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aDisplaymodehei          ; "DisplaymodeHeight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FA8B
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     [ecx+37F1Fh], eax
    jmp     short loc_42FAB6
    ; ---------------------------------------------------------------------------

    loc_42FA8B:                             ; CODE XREF: WriteRegistrySettings_1+D7j
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37F1Fh], 1E0h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F1Fh]
    push    ecx
    push    offset aDisplaymodehei          ; "DisplaymodeHeight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FAB6:                             ; CODE XREF: WriteRegistrySettings_1+E9j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aSide                    ; "side"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FAE0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     [ecx+37EF2h], eax
    jmp     short loc_42FB07
    ; ---------------------------------------------------------------------------

    loc_42FAE0:                             ; CODE XREF: WriteRegistrySettings_1+12Cj
    mov     edx, TAdynmemStructPtr
    mov     [edx+37EF2h], ebx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EF2h]
    push    ecx
    push    offset aSide                    ; "side"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FB07:                             ; CODE XREF: WriteRegistrySettings_1+13Ej
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aDifficulty              ; "Difficulty"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FB36
    mov     eax, [esp+134h+aDitheredfog]
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFFFh
    mov     [ecx+37EEEh], eax
    jmp     short loc_42FB5D
    ; ---------------------------------------------------------------------------

    loc_42FB36:                             ; CODE XREF: WriteRegistrySettings_1+17Dj
    mov     edx, TAdynmemStructPtr
    mov     [edx+37EEEh], edi
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EEEh]
    push    ecx
    push    offset aDifficulty              ; "Difficulty"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FB5D:                             ; CODE XREF: WriteRegistrySettings_1+194j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aScrollspeed             ; "scrollspeed"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FB87
    mov     ecx, TAdynmemStructPtr
    mov     al, byte ptr [esp+134h+aDitheredfog]
    mov     [ecx+1434Dh], al
    jmp     short loc_42FBB2
    ; ---------------------------------------------------------------------------

    loc_42FB87:                             ; CODE XREF: WriteRegistrySettings_1+1D3j
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     byte ptr [edx+1434Dh], 20h
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+1434Dh]
    push    eax
    push    offset aScrollspeed             ; "scrollspeed"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FBB2:                             ; CODE XREF: WriteRegistrySettings_1+1E5j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aSinglecommande          ; "SingleCommanderDeath"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FBDC
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     [ecx+39219h], eax
    jmp     short loc_42FC03
    ; ---------------------------------------------------------------------------

    loc_42FBDC:                             ; CODE XREF: WriteRegistrySettings_1+228j
    mov     edx, TAdynmemStructPtr
    mov     [edx+39219h], edi
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+39219h]
    push    ecx
    push    offset aSinglecommande          ; "SingleCommanderDeath"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FC03:                             ; CODE XREF: WriteRegistrySettings_1+23Aj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aSinglemapping           ; "SingleMapping"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FC2D
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     [ecx+3921Dh], eax
    jmp     short loc_42FC54
    ; ---------------------------------------------------------------------------

    loc_42FC2D:                             ; CODE XREF: WriteRegistrySettings_1+279j
    mov     edx, TAdynmemStructPtr
    mov     [edx+3921Dh], edi
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+3921Dh]
    push    ecx
    push    offset aSinglemapping           ; "SingleMapping"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FC54:                             ; CODE XREF: WriteRegistrySettings_1+28Bj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aSinglelineofsi          ; "SingleLineOfSight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FC7E
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     [ecx+39221h], eax
    jmp     short loc_42FCA5
    ; ---------------------------------------------------------------------------

    loc_42FC7E:                             ; CODE XREF: WriteRegistrySettings_1+2CAj
    mov     edx, TAdynmemStructPtr
    mov     [edx+39221h], edi
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+39221h]
    push    ecx
    push    offset aSinglelineofsi          ; "SingleLineOfSight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FCA5:                             ; CODE XREF: WriteRegistrySettings_1+2DCj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aSinglelostype           ; "SingleLOSType"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FCCF
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     [ecx+39225h], eax
    jmp     short loc_42FCF6
    ; ---------------------------------------------------------------------------

    loc_42FCCF:                             ; CODE XREF: WriteRegistrySettings_1+31Bj
    mov     edx, TAdynmemStructPtr
    mov     [edx+39225h], edi
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+39225h]
    push    ecx
    push    offset aSinglelostype           ; "SingleLOSType"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FCF6:                             ; CODE XREF: WriteRegistrySettings_1+32Dj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aScreenchat              ; "screenchat"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FD20
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     [ecx+37F02h], eax
    jmp     short loc_42FD47
    ; ---------------------------------------------------------------------------

    loc_42FD20:                             ; CODE XREF: WriteRegistrySettings_1+36Cj
    mov     edx, TAdynmemStructPtr
    mov     [edx+37F02h], edi
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F02h]
    push    ecx
    push    offset aScreenchat              ; "screenchat"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FD47:                             ; CODE XREF: WriteRegistrySettings_1+37Ej
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aDamagebars              ; "damagebars"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FD7F
    mov     ecx, TAdynmemStructPtr
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     ax, [ecx+37F06h]
    xor     dl, al
    and     edx, edi
    xor     edx, eax
    mov     [ecx+37F06h], dx
    jmp     short loc_42FDAA
    ; ---------------------------------------------------------------------------

    loc_42FD7F:                             ; CODE XREF: WriteRegistrySettings_1+3BDj
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F06h], 0FFFEh
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    and     ecx, edi
    push    ecx
    push    offset aDamagebars              ; "damagebars"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FDAA:                             ; CODE XREF: WriteRegistrySettings_1+3DDj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aSoundMode               ; "Sound Mode"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    mov     esi, 2
    jz      short loc_42FE0B
    cmp     [esp+134h+aDitheredfog], esi
    jnz     short loc_42FDDC
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CFE80
    jmp     short loc_42FDEA
    ; ---------------------------------------------------------------------------

    loc_42FDDC:                             ; CODE XREF: WriteRegistrySettings_1+42Bj
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CFE90

    loc_42FDEA:                             ; CODE XREF: WriteRegistrySettings_1+43Aj
    mov     ecx, TAdynmemStructPtr
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     ax, [ecx+37F19h]
    xor     dl, al
    and     edx, 7
    xor     edx, eax
    mov     [ecx+37F19h], dx
    jmp     short loc_42FE4A
    ; ---------------------------------------------------------------------------

    loc_42FE0B:                             ; CODE XREF: WriteRegistrySettings_1+425j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CFEA0
    neg     eax
    sbb     eax, eax
    neg     eax
    inc     eax
    push    eax
    push    offset aSoundMode               ; "Sound Mode"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37F19h]
    and     ecx, 0FFF9h
    or      ecx, edi
    mov     [eax+37F19h], cx

    loc_42FE4A:                             ; CODE XREF: WriteRegistrySettings_1+469j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aMixingbuffers           ; "MixingBuffers"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FE72
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    push    eax
    mov     ecx, [ecx+10h]
    jmp     short loc_42FE7D
    ; ---------------------------------------------------------------------------

    loc_42FE72:                             ; CODE XREF: WriteRegistrySettings_1+4C0j
    mov     edx, TAdynmemStructPtr
    push    8
    mov     ecx, [edx+10h]

    loc_42FE7D:                             ; CODE XREF: WriteRegistrySettings_1+4D0j
    call    sub_4CF210
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aRestorevolume           ; "RestoreVolume"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    mov     eax, TAdynmemStructPtr
    jz      short loc_42FEC0
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F19h]
    and     edx, edi
    and     ecx, 0FFF7h
    shl     edx, 3
    or      ecx, edx
    mov     [eax+37F19h], cx
    jmp     short loc_42FEC9
    ; ---------------------------------------------------------------------------

    loc_42FEC0:                             ; CODE XREF: WriteRegistrySettings_1+4FDj
    and     word ptr [eax+37F19h], 0FFF7h

    loc_42FEC9:                             ; CODE XREF: WriteRegistrySettings_1+51Ej
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    shr     cl, 3
    test    cl, 1
    jz      short loc_42FF33
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aWaveoutvolume           ; "WaveOutVolume"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FF07
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    push    eax
    mov     ecx, [ecx+10h]
    call    sub_4D0070

    loc_42FF07:                             ; CODE XREF: WriteRegistrySettings_1+552j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aCdaudiovolume           ; "CDAudioVolume"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    jz      short loc_42FF33
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    push    ebx
    push    eax
    mov     ecx, [ecx+10h]
    call    sub_4D00D0

    loc_42FF33:                             ; CODE XREF: WriteRegistrySettings_1+53Aj
                                            ; WriteRegistrySettings_1+57Dj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aAntiAlias               ; "Anti-Alias"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    mov     eax, TAdynmemStructPtr
    jz      short loc_42FF70
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F06h]
    and     edx, edi
    and     ecx, 0FFFDh
    shl     edx, 1
    or      ecx, edx
    mov     [eax+37F06h], cx
    jmp     short loc_42FF96
    ; ---------------------------------------------------------------------------

    loc_42FF70:                             ; CODE XREF: WriteRegistrySettings_1+5AEj
    or      [eax+37F06h], si
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     ecx, 1
    and     ecx, edi
    push    ecx
    push    offset aAntiAlias               ; "Anti-Alias"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FF96:                             ; CODE XREF: WriteRegistrySettings_1+5CEj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aShadows                 ; "Shadows"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    mov     eax, TAdynmemStructPtr
    jz      short loc_42FFD4
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F06h]
    and     edx, edi
    and     ecx, 0FFFBh
    shl     edx, 2
    or      ecx, edx
    mov     [eax+37F06h], cx
    jmp     short loc_42FFFB
    ; ---------------------------------------------------------------------------

    loc_42FFD4:                             ; CODE XREF: WriteRegistrySettings_1+611j
    or      byte ptr [eax+37F06h], 4
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     ecx, 2
    and     ecx, edi
    push    ecx
    push    offset aShadows                 ; "Shadows"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_42FFFB:                             ; CODE XREF: WriteRegistrySettings_1+632j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aFeatureshadows          ; "FeatureShadows"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    mov     eax, TAdynmemStructPtr
    mov     ebp, 10h
    jz      short loc_43003E
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F06h]
    and     edx, edi
    and     ecx, 0FFEFh
    shl     edx, 4
    or      ecx, edx
    mov     [eax+37F06h], cx
    jmp     short loc_430065
    ; ---------------------------------------------------------------------------

    loc_43003E:                             ; CODE XREF: WriteRegistrySettings_1+67Bj
    or      [eax+37F06h], bp
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     ecx, 4
    and     ecx, edi
    push    ecx
    push    offset aFeatureshadows          ; "FeatureShadows"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430065:                             ; CODE XREF: WriteRegistrySettings_1+69Cj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aVehicleshadows          ; "VehicleShadows"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    mov     eax, TAdynmemStructPtr
    jz      short loc_4300A3
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F06h]
    and     edx, edi
    and     ecx, 0FFF7h
    shl     edx, 3
    or      ecx, edx
    mov     [eax+37F06h], cx
    jmp     short loc_4300CA
    ; ---------------------------------------------------------------------------

    loc_4300A3:                             ; CODE XREF: WriteRegistrySettings_1+6E0j
    or      byte ptr [eax+37F06h], 8
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     ecx, 3
    and     ecx, edi
    push    ecx
    push    offset aVehicleshadows          ; "VehicleShadows"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_4300CA:                             ; CODE XREF: WriteRegistrySettings_1+701j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aShading                 ; "Shading"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    mov     eax, TAdynmemStructPtr
    jz      short loc_430108
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F06h]
    and     edx, edi
    and     ecx, 0FFDFh
    shl     edx, 5
    or      ecx, edx
    mov     [eax+37F06h], cx
    jmp     short loc_43012F
    ; ---------------------------------------------------------------------------

    loc_430108:                             ; CODE XREF: WriteRegistrySettings_1+745j
    or      byte ptr [eax+37F06h], 20h
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     ecx, 5
    and     ecx, edi
    push    ecx
    push    offset aShading                 ; "Shading"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_43012F:                             ; CODE XREF: WriteRegistrySettings_1+766j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aDitheredfog             ; "DitheredFog"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, ebx
    mov     eax, TAdynmemStructPtr
    jz      short loc_43016D
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F06h]
    and     edx, edi
    and     ecx, 0FFBFh
    shl     edx, 6
    or      ecx, edx
    mov     [eax+37F06h], cx
    jmp     short loc_430196
    ; ---------------------------------------------------------------------------

    loc_43016D:                             ; CODE XREF: WriteRegistrySettings_1+7AAj
    and     word ptr [eax+37F06h], 0FFBFh
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     ecx, 6
    and     ecx, edi
    push    ecx
    push    offset aDitheredfog             ; "DitheredFog"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430196:                             ; CODE XREF: WriteRegistrySettings_1+7CBj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aGamma                   ; "Gamma"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    mov     ebx, 0Ah
    jz      short loc_4301DA
    mov     eax, [esp+134h+aDitheredfog]
    cmp     eax, ebx
    jnz     short loc_4301CC
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37F08h], 0Ch
    jmp     short loc_430205
    ; ---------------------------------------------------------------------------

    loc_4301CC:                             ; CODE XREF: WriteRegistrySettings_1+819j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F08h], eax
    jmp     short loc_430205
    ; ---------------------------------------------------------------------------

    loc_4301DA:                             ; CODE XREF: WriteRegistrySettings_1+811j
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37F08h], 0Ch
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F08h]
    push    ecx
    push    offset aGamma                   ; "Gamma"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430205:                             ; CODE XREF: WriteRegistrySettings_1+82Aj
                                            ; WriteRegistrySettings_1+838j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aSwitchalt               ; "SwitchAlt"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jz      short loc_43024A
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     si, [eax+37F06h]
    and     dl, 1
    xor     ecx, ecx
    and     esi, 0FEFFh
    mov     ch, dl
    or      esi, ecx
    mov     edi, 1
    mov     [eax+37F06h], si
    jmp     short loc_430274
    ; ---------------------------------------------------------------------------

    loc_43024A:                             ; CODE XREF: WriteRegistrySettings_1+880j
    and     word ptr [eax+37F06h], 0FEFFh
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37F06h]
    shr     ecx, 8
    and     ecx, edi
    push    ecx
    push    offset aSwitchalt               ; "SwitchAlt"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430274:                             ; CODE XREF: WriteRegistrySettings_1+8A8j
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+134h+aDitheredfog]
    add     eax, 2BE3h
    push    edx
    push    eax
    push    offset aPassword                ; "Password"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    mov     [esp+144h+aDitheredfog], 0Bh
    call    WriteRegistryValue_2
    test    eax, eax
    jnz     short loc_4302AB
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2BE3h], al

    loc_4302AB:                             ; CODE XREF: WriteRegistrySettings_1+8FDj
    call    sub_45B660
    test    eax, eax
    mov     esi, 11h
    jz      short loc_4302EA
    mov     al, byte_512D48
    test    al, al
    jz      short loc_4302EA
    mov     edx, TAdynmemStructPtr
    push    ebp                             ; size_t
    push    offset byte_512D48              ; char *
    mov     byte ptr [edx+2BD2h], 0
    mov     eax, TAdynmemStructPtr
    add     eax, 2BD2h
    push    eax                             ; char *
    call    _strncat
    add     esp, 0Ch
    jmp     short loc_43031F
    ; ---------------------------------------------------------------------------

    loc_4302EA:                             ; CODE XREF: WriteRegistrySettings_1+917j
                                            ; WriteRegistrySettings_1+920j
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+134h+aDitheredfog]
    add     edx, 2BD2h
    push    ecx
    push    edx
    push    offset aNickname                ; "Nickname"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    mov     [esp+144h+aDitheredfog], esi
    call    WriteRegistryValue_2
    test    eax, eax
    jnz     short loc_43031F
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2BD2h], 0

    loc_43031F:                             ; CODE XREF: WriteRegistrySettings_1+948j
                                            ; WriteRegistrySettings_1+971j
    mov     al, byte_512CA8
    test    al, al
    jz      short loc_430352
    mov     ecx, TAdynmemStructPtr
    push    ebp                             ; size_t
    push    offset byte_512CA8              ; char *
    mov     byte ptr [ecx+2BC1h], 0
    mov     edx, TAdynmemStructPtr
    add     edx, 2BC1h
    push    edx                             ; char *
    call    _strncat
    add     esp, 0Ch
    jmp     short loc_430387
    ; ---------------------------------------------------------------------------

    loc_430352:                             ; CODE XREF: WriteRegistrySettings_1+986j
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+134h+aDitheredfog]
    add     ecx, 2BC1h
    push    eax
    push    ecx
    push    offset aGameName                ; "Game Name"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    mov     [esp+144h+aDitheredfog], esi
    call    WriteRegistryValue_2
    test    eax, eax
    jnz     short loc_430387
    mov     edx, TAdynmemStructPtr
    mov     [edx+2BC1h], al

    loc_430387:                             ; CODE XREF: WriteRegistrySettings_1+9B0j
                                            ; WriteRegistrySettings_1+9D9j
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+134h+aDitheredfog]
    add     ecx, 38A53h
    push    eax
    push    ecx
    push    offset aImageOutputDir          ; "Image Output Directory"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    mov     [esp+144h+aDitheredfog], 100h
    call    WriteRegistryValue_2
    test    eax, eax
    jnz     short loc_430412
    lea     edx, [esp+134h+var_100]
    push    edx                             ; int
    call    Get_UserName
    test    eax, eax
    jnz     short loc_4303EB
    mov     edi, offset aUser_images        ; "user_images"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+134h+var_100]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edi, 1

    loc_4303EB:                             ; CODE XREF: WriteRegistrySettings_1+A20j
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+134h+var_100]
    push    ecx
    mov     edx, [eax+0Ch]
    add     eax, 38A53h
    add     edx, 628h
    push    edx
    push    offset aSS                      ; "%s\\%s"
    push    eax
    call    _sprintf
    add     esp, 10h

    loc_430412:                             ; CODE XREF: WriteRegistrySettings_1+A12j
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aMovieOutputRat          ; "Movie Output Rate"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_43043C
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [edx+38C57h], ecx
    jmp     short loc_430447
    ; ---------------------------------------------------------------------------

    loc_43043C:                             ; CODE XREF: WriteRegistrySettings_1+A88j
    mov     eax, TAdynmemStructPtr
    mov     [eax+38C57h], ebx

    loc_430447:                             ; CODE XREF: WriteRegistrySettings_1+A9Aj
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aTextlines               ; "textlines"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_430470
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+134h+aDitheredfog]
    mov     [eax+37F27h], edx
    jmp     short loc_43047C
    ; ---------------------------------------------------------------------------

    loc_430470:                             ; CODE XREF: WriteRegistrySettings_1+ABDj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F27h], ebx

    loc_43047C:                             ; CODE XREF: WriteRegistrySettings_1+ACEj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aTextscroll              ; "textscroll"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_4304A6
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     [ecx+37F23h], eax
    jmp     short loc_4304B2
    ; ---------------------------------------------------------------------------

    loc_4304A6:                             ; CODE XREF: WriteRegistrySettings_1+AF2j
    mov     edx, TAdynmemStructPtr
    mov     [edx+37F23h], ebx

    loc_4304B2:                             ; CODE XREF: WriteRegistrySettings_1+B04j
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aMousespeed              ; "mousespeed"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_4304DC
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [edx+37F2Bh], ecx
    jmp     short loc_4304E7
    ; ---------------------------------------------------------------------------

    loc_4304DC:                             ; CODE XREF: WriteRegistrySettings_1+B28j
    mov     eax, TAdynmemStructPtr
    mov     [eax+37F2Bh], ebx

    loc_4304E7:                             ; CODE XREF: WriteRegistrySettings_1+B3Aj
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aGamespeed               ; "gamespeed"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_430512
    mov     eax, TAdynmemStructPtr
    mov     dx, word ptr [esp+134h+aDitheredfog]
    mov     [eax+38A4Bh], dx
    jmp     short loc_43051F
    ; ---------------------------------------------------------------------------

    loc_430512:                             ; CODE XREF: WriteRegistrySettings_1+B5Dj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38A4Bh], bx

    loc_43051F:                             ; CODE XREF: WriteRegistrySettings_1+B70j
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+38A4Bh]
    mov     [eax+38A4Dh], dx
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aUnitchat                ; "unitchat"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_43055C
    mov     edx, TAdynmemStructPtr
    mov     cl, byte ptr [esp+134h+aDitheredfog]
    mov     [edx+37F17h], cl
    jmp     short loc_430567
    ; ---------------------------------------------------------------------------

    loc_43055C:                             ; CODE XREF: WriteRegistrySettings_1+BA8j
    mov     eax, TAdynmemStructPtr
    mov     [eax+37F17h], bl

    loc_430567:                             ; CODE XREF: WriteRegistrySettings_1+BBAj
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aUnitchattext            ; "unitchattext"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_430590
    mov     eax, TAdynmemStructPtr
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     [eax+37F18h], dl
    jmp     short loc_43059D
    ; ---------------------------------------------------------------------------

    loc_430590:                             ; CODE XREF: WriteRegistrySettings_1+BDDj
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+37F18h], 5

    loc_43059D:                             ; CODE XREF: WriteRegistrySettings_1+BEEj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aMusicmode               ; "musicmode"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_4305DB
    mov     ecx, TAdynmemStructPtr
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     edi, 1
    mov     ax, [ecx+37F14h]
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [ecx+37F14h], dx
    jmp     short loc_4305E7
    ; ---------------------------------------------------------------------------

    loc_4305DB:                             ; CODE XREF: WriteRegistrySettings_1+C13j
    mov     eax, TAdynmemStructPtr
    or      [eax+37F14h], di

    loc_4305E7:                             ; CODE XREF: WriteRegistrySettings_1+C39j
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aCdmode                  ; "cdmode"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_430611
    mov     edx, TAdynmemStructPtr
    mov     cl, byte ptr [esp+134h+aDitheredfog]
    mov     [edx+37F16h], cl
    jmp     short loc_43061D
    ; ---------------------------------------------------------------------------

    loc_430611:                             ; CODE XREF: WriteRegistrySettings_1+C5Dj
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+37F16h], 4

    loc_43061D:                             ; CODE XREF: WriteRegistrySettings_1+C6Fj
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aAckfx                   ; "ackfx"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jz      short loc_43065B
    mov     cl, byte ptr [esp+134h+aDitheredfog]
    mov     dx, [eax+37F19h]
    and     ecx, edi
    and     edx, 0FFEFh
    shl     ecx, 4
    or      edx, ecx
    mov     [eax+37F19h], dx
    jmp     short loc_430662
    ; ---------------------------------------------------------------------------

    loc_43065B:                             ; CODE XREF: WriteRegistrySettings_1+C98j
    or      [eax+37F19h], bp

    loc_430662:                             ; CODE XREF: WriteRegistrySettings_1+CB9j
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aBuildfx                 ; "buildfx"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jz      short loc_4306A0
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F19h]
    and     edx, edi
    and     ecx, 0FFDFh
    shl     edx, 5
    or      ecx, edx
    mov     [eax+37F19h], cx
    jmp     short loc_4306A7
    ; ---------------------------------------------------------------------------

    loc_4306A0:                             ; CODE XREF: WriteRegistrySettings_1+CDDj
    or      byte ptr [eax+37F19h], 20h

    loc_4306A7:                             ; CODE XREF: WriteRegistrySettings_1+CFEj
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aSpeechfx                ; "speechfx"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jz      short loc_4306E5
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F19h]
    and     edx, edi
    and     ecx, 0FFBFh
    shl     edx, 6
    or      ecx, edx
    mov     [eax+37F19h], cx
    jmp     short loc_4306EC
    ; ---------------------------------------------------------------------------

    loc_4306E5:                             ; CODE XREF: WriteRegistrySettings_1+D22j
    or      byte ptr [eax+37F19h], 40h

    loc_4306EC:                             ; CODE XREF: WriteRegistrySettings_1+D43j
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aFxvol                   ; "fxvol"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_430716
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [edx+37F0Ch], ecx
    jmp     short loc_430725
    ; ---------------------------------------------------------------------------

    loc_430716:                             ; CODE XREF: WriteRegistrySettings_1+D62j
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37F0Ch], 1Bh

    loc_430725:                             ; CODE XREF: WriteRegistrySettings_1+D74j
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aMusicvol                ; "musicvol"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_43074E
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+134h+aDitheredfog]
    mov     [eax+37F10h], edx
    jmp     short loc_43075E
    ; ---------------------------------------------------------------------------

    loc_43074E:                             ; CODE XREF: WriteRegistrySettings_1+D9Bj
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+37F10h], 20h

    loc_43075E:                             ; CODE XREF: WriteRegistrySettings_1+DACj
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aClock                   ; "clock"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jz      short loc_43079C
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     cx, [eax+37F2Fh]
    and     edx, edi
    and     ecx, 0FFBFh
    shl     edx, 6
    or      ecx, edx
    mov     [eax+37F2Fh], cx
    jmp     short loc_4307A5
    ; ---------------------------------------------------------------------------

    loc_43079C:                             ; CODE XREF: WriteRegistrySettings_1+DD9j
    and     word ptr [eax+37F2Fh], 0FFBFh

    loc_4307A5:                             ; CODE XREF: WriteRegistrySettings_1+DFAj
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aNumskirmishpla          ; "NumSkirmishPlayers"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_4307E5
    mov     eax, [esp+134h+aDitheredfog]
    cmp     eax, edi
    jle     short loc_4307D7
    cmp     eax, ebx
    jg      short loc_4307D7
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38D81h], eax
    jmp     short loc_4307F4
    ; ---------------------------------------------------------------------------

    loc_4307D7:                             ; CODE XREF: WriteRegistrySettings_1+E23j
                                            ; WriteRegistrySettings_1+E27j
    mov     edx, TAdynmemStructPtr
    mov     [edx+38D81h], eax
    jmp     short loc_4307F4
    ; ---------------------------------------------------------------------------

    loc_4307E5:                             ; CODE XREF: WriteRegistrySettings_1+E1Bj
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+38D81h], 4

    loc_4307F4:                             ; CODE XREF: WriteRegistrySettings_1+E35j
                                            ; WriteRegistrySettings_1+E43j
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aMulticommander          ; "MultiCommanderDeath"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_43081D
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+134h+aDitheredfog]
    mov     [eax+39229h], edx
    jmp     short loc_430845
    ; ---------------------------------------------------------------------------

    loc_43081D:                             ; CODE XREF: WriteRegistrySettings_1+E6Aj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+39229h], edi
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+39229h]
    push    eax
    push    offset aMulticommander          ; "MultiCommanderDeath"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430845:                             ; CODE XREF: WriteRegistrySettings_1+E7Bj
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aMultimapping            ; "MultiMapping"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_43086E
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+134h+aDitheredfog]
    mov     [eax+3922Dh], edx
    jmp     short loc_430896
    ; ---------------------------------------------------------------------------

    loc_43086E:                             ; CODE XREF: WriteRegistrySettings_1+EBBj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+3922Dh], edi
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+3922Dh]
    push    eax
    push    offset aMultimapping            ; "MultiMapping"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430896:                             ; CODE XREF: WriteRegistrySettings_1+ECCj
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aMultilineofsig          ; "MultiLineOfSight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_4308BF
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+134h+aDitheredfog]
    mov     [eax+39231h], edx
    jmp     short loc_4308E7
    ; ---------------------------------------------------------------------------

    loc_4308BF:                             ; CODE XREF: WriteRegistrySettings_1+F0Cj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+39231h], edi
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+39231h]
    push    eax
    push    offset aMultilineofsig          ; "MultiLineOfSight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_4308E7:                             ; CODE XREF: WriteRegistrySettings_1+F1Dj
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aMultilostype            ; "MultiLOSType"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_430910
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+134h+aDitheredfog]
    mov     [eax+TAdynmemStruct.RenderingOptions], edx
    jmp     short loc_430938
    ; ---------------------------------------------------------------------------

    loc_430910:                             ; CODE XREF: WriteRegistrySettings_1+F5Dj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+TAdynmemStruct.RenderingOptions], edi
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+TAdynmemStruct.RenderingOptions]
    push    eax
    push    offset aMultilostype            ; "MultiLOSType"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430938:                             ; CODE XREF: WriteRegistrySettings_1+F6Ej
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aSkirmishcomman          ; "SkirmishCommanderDeath"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    mov     edx, TAdynmemStructPtr
    test    eax, eax
    mov     eax, [edx+29A0h]
    jz      short loc_430968
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [eax+108h], ecx
    jmp     short loc_430990
    ; ---------------------------------------------------------------------------

    loc_430968:                             ; CODE XREF: WriteRegistrySettings_1+FBAj
    mov     [eax+108h], edi
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+108h]
    push    eax
    push    offset aSkirmishcomman          ; "SkirmishCommanderDeath"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430990:                             ; CODE XREF: WriteRegistrySettings_1+FC6j
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aSkirmishmappin          ; "SkirmishMapping"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    mov     edx, TAdynmemStructPtr
    test    eax, eax
    mov     eax, [edx+29A0h]
    jz      short loc_4309C0
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [eax+10Ch], ecx
    jmp     short loc_4309E8
    ; ---------------------------------------------------------------------------

    loc_4309C0:                             ; CODE XREF: WriteRegistrySettings_1+1012j
    mov     [eax+10Ch], edi
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+10Ch]
    push    eax
    push    offset aSkirmishmappin          ; "SkirmishMapping"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_4309E8:                             ; CODE XREF: WriteRegistrySettings_1+101Ej
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aSkirmishlineof          ; "SkirmishLineOfSight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    mov     edx, TAdynmemStructPtr
    test    eax, eax
    mov     eax, [edx+29A0h]
    jz      short loc_430A18
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [eax+110h], ecx
    jmp     short loc_430A40
    ; ---------------------------------------------------------------------------

    loc_430A18:                             ; CODE XREF: WriteRegistrySettings_1+106Aj
    mov     [eax+110h], edi
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+110h]
    push    eax
    push    offset aSkirmishlineof          ; "SkirmishLineOfSight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430A40:                             ; CODE XREF: WriteRegistrySettings_1+1076j
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aSkirmishlostyp          ; "SkirmishLOSType"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    mov     edx, TAdynmemStructPtr
    test    eax, eax
    mov     eax, [edx+29A0h]
    jz      short loc_430A70
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [eax+114h], ecx
    jmp     short loc_430A98
    ; ---------------------------------------------------------------------------

    loc_430A70:                             ; CODE XREF: WriteRegistrySettings_1+10C2j
    mov     [eax+114h], edi
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+114h]
    push    eax
    push    offset aSkirmishlostyp          ; "SkirmishLOSType"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430A98:                             ; CODE XREF: WriteRegistrySettings_1+10CEj
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aSkirmishdiffic          ; "SkirmishDifficulty"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_430ACD
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+134h+aDitheredfog]
    and     edx, 0FFFFh
    mov     ecx, [eax+29A0h]
    mov     [ecx+228h], edx
    jmp     short loc_430B01
    ; ---------------------------------------------------------------------------

    loc_430ACD:                             ; CODE XREF: WriteRegistrySettings_1+110Ej
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    mov     [eax+228h], edi
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+228h]
    push    eax
    push    offset aSkirmishdiffic          ; "SkirmishDifficulty"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430B01:                             ; CODE XREF: WriteRegistrySettings_1+112Bj
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aSkirmishlocati          ; "SkirmishLocation"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    mov     edx, TAdynmemStructPtr
    test    eax, eax
    mov     eax, [edx+29A0h]
    jz      short loc_430B31
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [eax+118h], ecx
    jmp     short loc_430B59
    ; ---------------------------------------------------------------------------

    loc_430B31:                             ; CODE XREF: WriteRegistrySettings_1+1183j
    mov     [eax+118h], edi
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+118h]
    push    eax
    push    offset aSkirmishlocati          ; "SkirmishLocation"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6

    loc_430B59:                             ; CODE XREF: WriteRegistrySettings_1+118Fj
    mov     edx, TAdynmemStructPtr
    mov     [esp+134h+aDitheredfog], 100h
    lea     ecx, [esp+134h+aDitheredfog]
    mov     eax, [edx+29A0h]
    push    ecx
    add     eax, 11Ch
    push    eax
    push    offset aSkirmishmap             ; "SkirmishMap"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_2
    test    eax, eax
    jnz     short loc_430BFE
    push    2
    call    sub_434AB0
    mov     ecx, TAdynmemStructPtr
    push    0
    mov     ecx, [ecx+391E9h]
    call    sub_435D30
    mov     edx, TAdynmemStructPtr
    push    100h                            ; size_t
    mov     ecx, [edx+391E9h]
    call    sub_435C30
    push    eax                             ; char *
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    add     ecx, 11Ch
    push    ecx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    push    0
    call    sub_434AB0
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    add     eax, 11Ch
    push    eax
    push    offset aSkirmishmap             ; "SkirmishMap"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_5

    loc_430BFE:                             ; CODE XREF: WriteRegistrySettings_1+11E9j
    mov     ecx, TAdynmemStructPtr
    xor     esi, esi
    mov     eax, [ecx+38D81h]
    test    eax, eax
    jle     loc_430DDD
    mov     edi, ds:wsprintfA
    xor     ebp, ebp
    mov     ebx, 3E8h

    loc_430C21:                             ; CODE XREF: WriteRegistrySettings_1+1437j
    push    esi
    lea     edx, [esp+138h+var_120]
    push    offset aPlayerDcontrol          ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     eax, [esp+134h+aDitheredfog]
    lea     ecx, [esp+134h+var_120]
    push    eax
    push    ecx
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_3
    mov     edx, TAdynmemStructPtr
    test    eax, eax
    mov     eax, [edx+29A0h]
    jz      short loc_430C5E
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [eax+ebp], ecx
    jmp     short loc_430C65
    ; ---------------------------------------------------------------------------

    loc_430C5E:                             ; CODE XREF: WriteRegistrySettings_1+12B3j
    mov     dword ptr [eax+ebp], 0

    loc_430C65:                             ; CODE XREF: WriteRegistrySettings_1+12BCj
    push    esi
    lea     ecx, [esp+138h+var_120]
    push    offset aPlayerDside             ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     edx, [esp+134h+aDitheredfog]
    lea     eax, [esp+134h+var_120]
    push    edx
    push    eax
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_3
    test    eax, eax
    jz      short loc_430C9F
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+134h+aDitheredfog]
    mov     edx, [ecx+29A0h]
    jmp     short loc_430CB9
    ; ---------------------------------------------------------------------------

    loc_430C9F:                             ; CODE XREF: WriteRegistrySettings_1+12EBj
    mov     eax, esi
    mov     ecx, TAdynmemStructPtr
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 1
    xor     eax, edx
    sub     eax, edx
    mov     edx, [ecx+29A0h]

    loc_430CB9:                             ; CODE XREF: WriteRegistrySettings_1+12FDj
    mov     [edx+ebp+4], eax
    push    esi
    lea     eax, [esp+138h+var_120]
    push    offset aPlayerDcolor            ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     ecx, [esp+134h+aDitheredfog]
    lea     edx, [esp+134h+var_120]
    push    ecx
    push    edx
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_3
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    jz      short loc_430CFA
    mov     edx, [esp+134h+aDitheredfog]
    mov     [ecx+ebp+14h], edx
    jmp     short loc_430CFE
    ; ---------------------------------------------------------------------------

    loc_430CFA:                             ; CODE XREF: WriteRegistrySettings_1+134Ej
    mov     [ecx+ebp+14h], esi

    loc_430CFE:                             ; CODE XREF: WriteRegistrySettings_1+1358j
    push    esi
    lea     edx, [esp+138h+var_120]
    push    offset aPlayerDallygro          ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     eax, [esp+134h+aDitheredfog]
    lea     ecx, [esp+134h+var_120]
    push    eax
    push    ecx
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_3
    mov     edx, TAdynmemStructPtr
    test    eax, eax
    mov     eax, [edx+29A0h]
    jz      short loc_430D3C
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [eax+ebp+8], ecx
    jmp     short loc_430D44
    ; ---------------------------------------------------------------------------

    loc_430D3C:                             ; CODE XREF: WriteRegistrySettings_1+1390j
    mov     dword ptr [eax+ebp+8], 5

    loc_430D44:                             ; CODE XREF: WriteRegistrySettings_1+139Aj
    push    esi
    lea     ecx, [esp+138h+var_120]
    push    offset aPlayerDmetal            ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     edx, [esp+134h+aDitheredfog]
    lea     eax, [esp+134h+var_120]
    push    edx
    push    eax
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_3
    mov     ecx, TAdynmemStructPtr
    test    eax, eax
    mov     edx, [ecx+29A0h]
    jz      short loc_430D82
    mov     eax, [esp+134h+aDitheredfog]
    mov     [edx+ebp+0Ch], eax
    jmp     short loc_430D86
    ; ---------------------------------------------------------------------------

    loc_430D82:                             ; CODE XREF: WriteRegistrySettings_1+13D6j
    mov     [edx+ebp+0Ch], ebx

    loc_430D86:                             ; CODE XREF: WriteRegistrySettings_1+13E0j
    push    esi
    lea     eax, [esp+138h+var_120]
    push    offset aPlayerDenergy           ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     ecx, [esp+134h+aDitheredfog]
    lea     edx, [esp+134h+var_120]
    push    ecx
    push    edx
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_3
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    jz      short loc_430DC3
    mov     edx, [esp+134h+aDitheredfog]
    mov     [ecx+ebp+10h], edx
    jmp     short loc_430DC7
    ; ---------------------------------------------------------------------------

    loc_430DC3:                             ; CODE XREF: WriteRegistrySettings_1+1417j
    mov     [ecx+ebp+10h], ebx

    loc_430DC7:                             ; CODE XREF: WriteRegistrySettings_1+1421j
    mov     edx, TAdynmemStructPtr
    inc     esi
    add     ebp, 18h
    cmp     esi, [edx+38D81h]
    jl      loc_430C21

    loc_430DDD:                             ; CODE XREF: WriteRegistrySettings_1+126Ej
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aPlaymovie               ; "PlayMovie"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    xor     esi, esi
    cmp     eax, esi
    jz      short loc_430E09
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+134h+aDitheredfog]
    mov     [edx+3923Dh], ecx
    jmp     short loc_430E18
    ; ---------------------------------------------------------------------------

    loc_430E09:                             ; CODE XREF: WriteRegistrySettings_1+1455j
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+3923Dh], 1

    loc_430E18:                             ; CODE XREF: WriteRegistrySettings_1+1467j
    lea     ecx, [esp+134h+aDitheredfog]
    push    ecx
    push    offset aDisplaymodedep          ; "DisplaymodeDepth"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, esi
    jnz     short loc_430E34
    mov     [esp+134h+aDitheredfog], esi

    loc_430E34:                             ; CODE XREF: WriteRegistrySettings_1+148Ej
    cmp     [esp+134h+aDitheredfog], 100h
    jnz     short loc_430E71
    lea     edx, [esp+134h+aDitheredfog]
    push    edx
    push    offset aGames                   ; "Games"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, esi
    jnz     short loc_430E5A
    mov     [esp+134h+aDitheredfog], esi

    loc_430E5A:                             ; CODE XREF: WriteRegistrySettings_1+14B4j
    mov     eax, [esp+134h+aDitheredfog]
    cmp     eax, 1
    mov     eax, TAdynmemStructPtr
    jnz     short loc_430E76
    or      byte ptr [eax+37F2Fh], 2
    jmp     short loc_430E7F
    ; ---------------------------------------------------------------------------

    loc_430E71:                             ; CODE XREF: WriteRegistrySettings_1+149Cj
    mov     eax, TAdynmemStructPtr

    loc_430E76:                             ; CODE XREF: WriteRegistrySettings_1+14C6j
    and     word ptr [eax+37F2Fh], 0FFFDh

    loc_430E7F:                             ; CODE XREF: WriteRegistrySettings_1+14CFj
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F2Fh], 4
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F2Fh], 8
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F2Fh], 0FFEFh
    lea     eax, [esp+134h+aDitheredfog]
    push    eax
    push    offset aAllmissions             ; "AllMissions"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_3
    cmp     eax, esi
    jz      short loc_430EE7
    mov     ecx, TAdynmemStructPtr
    mov     dl, byte ptr [esp+134h+aDitheredfog]
    mov     ax, [ecx+38D7Fh]
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [ecx+38D7Fh], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 124h
    retn
    ; ---------------------------------------------------------------------------

    loc_430EE7:                             ; CODE XREF: WriteRegistrySettings_1+151Bj
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    and     word ptr [eax+38D7Fh], 0FFFEh
    pop     ebx
    add     esp, 124h
    retn
    WriteRegistrySettings_1 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl WriteRegistrySettings_2()
    WriteRegistrySettings_2 proc near       ; CODE XREF: .text:0041644Fp
                                            ; .text:0041653Fp ...

    var_20= byte ptr -20h

    mov     eax, TAdynmemStructPtr
    sub     esp, 20h
    mov     ecx, [eax+37EFAh]
    push    ebx
    push    esi
    push    edi
    push    ecx
    push    offset aInterfaceType           ; "Interface Type"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37F1Bh]
    push    eax
    push    offset aDisplaymodewid          ; "DisplaymodeWidth"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37F1Fh]
    push    edx
    push    offset aDisplaymodehei          ; "DisplaymodeHeight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EF2h]
    push    ecx
    push    offset aSide                    ; "side"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    mov     ecx, [eax+118h]
    push    ecx
    push    offset aFixedlocations          ; "FixedLocations"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [eax+1434Dh]
    push    edx
    push    offset aScrollspeed             ; "scrollspeed"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+39219h]
    push    edx
    push    offset aSinglecommande          ; "SingleCommanderDeath"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+3921Dh]
    push    ecx
    push    offset aSinglemapping           ; "SingleMapping"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+39221h]
    push    eax
    push    offset aSinglelineofsi          ; "SingleLineOfSight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+39225h]
    push    edx
    push    offset aSinglelostype           ; "SingleLOSType"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F02h]
    push    ecx
    push    offset aScreenchat              ; "screenchat"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+37F06h]
    and     eax, 1
    push    eax
    push    offset aDamagebars              ; "damagebars"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+37F19h]
    and     edx, 7
    push    edx
    push    offset aSoundMode               ; "Sound Mode"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    shr     ecx, 3
    and     ecx, 1
    push    ecx
    push    offset aRestorevolume           ; "RestoreVolume"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CF220
    push    eax
    push    offset aMixingbuffers           ; "MixingBuffers"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    shr     cl, 3
    test    cl, 1
    jz      short loc_431108
    mov     ecx, [eax+10h]
    call    sub_4CFFF0
    push    eax
    push    offset aWaveoutvolume           ; "WaveOutVolume"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4D0040
    push    eax
    push    offset aCdaudiovolume           ; "CDAudioVolume"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr

    loc_431108:                             ; CODE XREF: WriteRegistrySettings_2+1CBj
    mov     al, [eax+37F06h]
    shr     eax, 1
    and     eax, 1
    push    eax
    push    offset aAntiAlias               ; "Anti-Alias"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+37F06h]
    shr     edx, 2
    and     edx, 1
    push    edx
    push    offset aShadows                 ; "Shadows"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     ecx, 4
    and     ecx, 1
    push    ecx
    push    offset aFeatureshadows          ; "FeatureShadows"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+37F06h]
    shr     eax, 3
    and     eax, 1
    push    eax
    push    offset aVehicleshadows          ; "VehicleShadows"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+37F06h]
    shr     edx, 5
    and     edx, 1
    push    edx
    push    offset aShading                 ; "Shading"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     ecx, 6
    and     ecx, 1
    push    ecx
    push    offset aDitheredfog             ; "DitheredFog"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37EEEh]
    push    eax
    push    offset aDifficulty              ; "Difficulty"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37F08h]
    push    edx
    push    offset aGamma                   ; "Gamma"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37F06h]
    shr     ecx, 8
    and     ecx, 1
    push    ecx
    push    offset aSwitchalt               ; "SwitchAlt"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    add     edx, 2BE3h
    push    edx
    push    offset aPassword                ; "Password"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_5
    mov     eax, TAdynmemStructPtr
    add     eax, 2BD2h
    push    eax
    push    offset aNickname                ; "Nickname"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_5
    mov     ecx, TAdynmemStructPtr
    add     ecx, 2BC1h
    push    ecx
    push    offset aGameName                ; "Game Name"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_5
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    cmp     [eax+38C5Fh], esi
    jz      short loc_4312AC
    add     eax, 38A53h
    push    eax
    push    offset aImageOutputDir          ; "Image Output Directory"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_5
    mov     edx, TAdynmemStructPtr
    mov     [edx+38C5Fh], esi
    mov     eax, TAdynmemStructPtr

    loc_4312AC:                             ; CODE XREF: WriteRegistrySettings_2+384j
    cmp     [eax+38C63h], esi
    jz      short loc_4312DB
    mov     eax, [eax+38C57h]
    push    eax
    push    offset aMovieOutputRat          ; "Movie Output Rate"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38C63h], esi
    mov     eax, TAdynmemStructPtr

    loc_4312DB:                             ; CODE XREF: WriteRegistrySettings_2+3B2j
    xor     edx, edx
    mov     dl, [eax+37F17h]
    push    edx
    push    offset aUnitchat                ; "unitchat"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [ecx+37F18h]
    push    eax
    push    offset aUnitchattext            ; "unitchattext"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37F27h]
    push    eax
    push    offset aTextlines               ; "textlines"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37F23h]
    push    edx
    push    offset aTextscroll              ; "textscroll"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F2Bh]
    push    ecx
    push    offset aMousespeed              ; "mousespeed"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [eax+38A4Bh]
    push    edx
    push    offset aGamespeed               ; "gamespeed"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+37F2Fh]
    shr     edx, 6
    and     edx, 1
    push    edx
    push    offset aClock                   ; "clock"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    and     ecx, 1
    push    ecx
    push    offset aMusicmode               ; "musicmode"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [eax+37F16h]
    push    edx
    push    offset aCdmode                  ; "cdmode"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+37F19h]
    shr     edx, 4
    and     edx, 1
    push    edx
    push    offset aAckfx                   ; "ackfx"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    shr     ecx, 5
    and     ecx, 1
    push    ecx
    push    offset aBuildfx                 ; "buildfx"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+37F19h]
    shr     eax, 6
    and     eax, 1
    push    eax
    push    offset aSpeechfx                ; "speechfx"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37F0Ch]
    push    edx
    push    offset aFxvol                   ; "fxvol"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F10h]
    push    ecx
    push    offset aMusicvol                ; "musicvol"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+39229h]
    push    eax
    push    offset aMulticommander          ; "MultiCommanderDeath"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+3922Dh]
    push    edx
    push    offset aMultimapping            ; "MultiMapping"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+39231h]
    push    ecx
    push    offset aMultilineofsig          ; "MultiLineOfSight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+TAdynmemStruct.RenderingOptions]
    push    eax
    push    offset aMultilostype            ; "MultiLOSType"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+108h]
    push    eax
    push    offset aSkirmishcomman          ; "SkirmishCommanderDeath"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+10Ch]
    push    eax
    push    offset aSkirmishmappin          ; "SkirmishMapping"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+110h]
    push    eax
    push    offset aSkirmishlineof          ; "SkirmishLineOfSight"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+114h]
    push    eax
    push    offset aSkirmishlostyp          ; "SkirmishLOSType"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+118h]
    push    eax
    push    offset aSkirmishlocati          ; "SkirmishLocation"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+228h]
    push    eax
    push    offset aSkirmishdiffic          ; "SkirmishDifficulty"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    add     edx, 11Ch
    push    edx
    push    offset aSkirmishmap             ; "SkirmishMap"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_5
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D81h], esi
    jle     loc_431723
    mov     ebx, ds:wsprintfA
    xor     edi, edi

    loc_4315F1:                             ; CODE XREF: WriteRegistrySettings_2+81Dj
    push    esi
    lea     eax, [esp+30h+var_20]
    push    offset aPlayerDcontrol          ; LPCSTR
    push    eax                             ; LPSTR
    call    ebx ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     edx, [ecx+29A0h]
    lea     ecx, [esp+2Ch+var_20]
    mov     eax, [edx+edi]
    push    eax
    push    ecx
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_6
    push    esi
    lea     edx, [esp+30h+var_20]
    push    offset aPlayerDside             ; LPCSTR
    push    edx                             ; LPSTR
    call    ebx ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     ecx, [eax+29A0h]
    lea     eax, [esp+2Ch+var_20]
    mov     edx, [ecx+edi+4]
    push    edx
    push    eax
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_6
    push    esi
    lea     ecx, [esp+30h+var_20]
    push    offset aPlayerDcolor            ; LPCSTR
    push    ecx                             ; LPSTR
    call    ebx ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     eax, [edx+29A0h]
    lea     edx, [esp+2Ch+var_20]
    mov     ecx, [eax+edi+14h]
    push    ecx
    push    edx
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_6
    push    esi
    lea     eax, [esp+30h+var_20]
    push    offset aPlayerDallygro          ; LPCSTR
    push    eax                             ; LPSTR
    call    ebx ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     edx, [ecx+29A0h]
    lea     ecx, [esp+2Ch+var_20]
    mov     eax, [edx+edi+8]
    push    eax
    push    ecx
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_6
    push    esi
    lea     edx, [esp+30h+var_20]
    push    offset aPlayerDmetal            ; LPCSTR
    push    edx                             ; LPSTR
    call    ebx ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     ecx, [eax+29A0h]
    lea     eax, [esp+2Ch+var_20]
    mov     edx, [ecx+edi+0Ch]
    push    edx
    push    eax
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_6
    push    esi
    lea     ecx, [esp+30h+var_20]
    push    offset aPlayerDenergy           ; LPCSTR
    push    ecx                             ; LPSTR
    call    ebx ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     eax, [edx+29A0h]
    lea     edx, [esp+2Ch+var_20]
    mov     ecx, [eax+edi+10h]
    push    ecx
    push    edx
    push    offset aTotalAnnihil_1          ; "Total Annihilation\\Skirmish"
    call    WriteRegistryValue_6
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     edi, 18h
    cmp     esi, [eax+38D81h]
    jl      loc_4315F1

    loc_431723:                             ; CODE XREF: WriteRegistrySettings_2+6E3j
    mov     eax, [eax+3923Dh]
    push    eax
    push    offset aPlaymovie               ; "PlayMovie"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 20h
    retn
    WriteRegistrySettings_2 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_431740 proc near                    ; CODE XREF: sub_497180+35Ep

    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_100= byte ptr -100h

    sub     esp, 10Ch
    lea     ecx, [esp+10Ch+var_10C]
    push    ebx
    push    esi
    push    edi
    call    sub_4C2EA0
    mov     eax, TAdynmemStructPtr
    push    6
    mov     ecx, [eax+391E9h]
    call    sub_4356C0
    test    eax, eax
    jz      loc_4318AB
    push    eax
    lea     ecx, [esp+11Ch+var_10C]
    call    sub_4C2F60
    test    eax, eax
    jz      loc_4318AB
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1439Bh]
    push    edx                             ; wint_t
    call    _iswdigit
    mov     eax, TAdynmemStructPtr
    mov     ecx, 1
    add     esp, 4
    cmp     [eax+1438Fh], ecx
    jle     short loc_4317DA
    mov     edx, 249h

    loc_4317AA:                             ; CODE XREF: sub_431740+98j
    mov     eax, [eax+1439Bh]
    mov     esi, [eax+edx+241h]
    lea     eax, [eax+edx+241h]
    and     esi, 0FF7FFFFFh
    inc     ecx
    mov     [eax], esi
    mov     eax, TAdynmemStructPtr
    add     edx, 249h
    cmp     ecx, [eax+1438Fh]
    jl      short loc_4317AA

    loc_4317DA:                             ; CODE XREF: sub_431740+63j
    lea     ecx, [esp+118h+var_10C]
    call    sub_4C3E10
    xor     ebx, ebx
    lea     ecx, [esp+118h+var_10C]
    push    ebx
    call    sub_4C3490
    test    eax, eax
    jz      loc_431896

    loc_4317F7:                             ; CODE XREF: sub_431740+150j
    lea     ecx, [esp+118h+var_100]
    push    100h                            ; size_t
    push    ecx                             ; char *
    mov     ecx, [esp+120h+var_108]
    call    sub_4C4420
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     ecx, [eax+1438Fh]
    test    ecx, ecx
    jle     short loc_43187A
    xor     edi, edi

    loc_43181D:                             ; CODE XREF: sub_431740+10Bj
    mov     eax, [eax+1439Bh]
    lea     edx, [esp+118h+var_100]
    push    edx                             ; char *
    lea     ecx, [eax+edi+20h]
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_43184F
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     edi, 249h
    cmp     esi, [eax+1438Fh]
    jl      short loc_43181D
    jmp     short loc_43187A
    ; ---------------------------------------------------------------------------

    loc_43184F:                             ; CODE XREF: sub_431740+F7j
    mov     eax, esi
    shl     eax, 6
    add     eax, esi
    lea     edx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1439Bh]
    lea     eax, [ecx+edx+241h]
    mov     ecx, [ecx+edx+241h]
    or      ecx, 800000h
    mov     [eax], ecx

    loc_43187A:                             ; CODE XREF: sub_431740+D9j
                                            ; sub_431740+10Dj
    lea     ecx, [esp+118h+var_10C]
    inc     ebx
    call    sub_4C3E10
    push    ebx
    lea     ecx, [esp+11Ch+var_10C]
    call    sub_4C3490
    test    eax, eax
    jnz     loc_4317F7

    loc_431896:                             ; CODE XREF: sub_431740+B1j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1439Bh]
    push    eax                             ; wint_t
    call    _iswlower
    add     esp, 4

    loc_4318AB:                             ; CODE XREF: sub_431740+26j
                                            ; sub_431740+38j
    lea     ecx, [esp+118h+var_10C]
    call    sub_4C2EB0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10Ch
    retn
    sub_431740 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4318C0 proc near                    ; CODE XREF: sub_491200+286p

    var_100= dword ptr -100h

    sub     esp, 100h
    lea     eax, [esp+100h+var_100]
    push    offset off_502E38
    push    offset aLogos                   ; "logos"
    push    offset aTextures                ; "textures"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+100h+var_100]
    push    ecx
    call    sub_4B8C60
    mov     edx, TAdynmemStructPtr
    push    offset a32xlogos                ; char *
    mov     [edx+148D7h], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148D7h]
    push    ecx                             ; int
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    mov     [edx+148DBh], eax
    add     esp, 100h
    retn
    sub_4318C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_431920 proc near                    ; CODE XREF: sub_4916A0+93p
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148D7h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     dword ptr [edx+148D7h], 0
    retn
    sub_431920 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_431950 proc near                    ; CODE XREF: sub_431A60+8C9p
                                            ; sub_431A60+8E0p ...

    Text= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 100h
    push    ebx
    push    esi
    mov     esi, [esp+108h+arg_0]
    push    edi
    mov     ecx, esi
    call    sub_4C3E20
    mov     edi, [esp+10Ch+arg_8]
    mov     ecx, esi
    push    edi                             ; char *
    mov     ebx, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_4319B5
    mov     eax, [esp+10Ch+arg_C]
    lea     ecx, [esp+10Ch+Text]
    push    eax
    push    edi
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+10Ch+Text]
    push    edx                             ; lpText
    call    sub_4B6290
    push    ebx
    mov     ecx, esi
    call    sub_4C3E30
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 100h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4319B5:                             ; CODE XREF: sub_431950+2Aj
    mov     ecx, [esi+4]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    push    0                               ; int
    push    offset aY1                      ; char *
    mov     edi, [esp+114h+arg_4]
    mov     [edi], eax
    mov     ecx, [esi+4]
    call    sub_4C46C0
    mov     [edi+4], eax
    mov     ecx, [esi+4]
    push    0                               ; int
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [edi+8], eax
    mov     ecx, [esi+4]
    push    0                               ; int
    push    offset aY2                      ; char *
    call    sub_4C46C0
    push    ebx
    mov     ecx, esi
    mov     [edi+0Ch], eax
    call    sub_4C3E30
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 100h
    retn    10h
    sub_431950 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_431A20 proc near                    ; CODE XREF: sub_4916A0+98p
    push    esi
    push    edi
    xor     edi, edi

    loc_431A24:                             ; CODE XREF: sub_431A20+36j
    mov     eax, TAdynmemStructPtr
    lea     esi, [eax+edi+3816Bh]
    mov     eax, [eax+edi+3816Bh]
    test    eax, eax
    jz      short loc_431A4A
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi], 0

    loc_431A4A:                             ; CODE XREF: sub_431A20+19j
    add     edi, 232h
    cmp     edi, 0AFAh
    jl      short loc_431A24
    pop     edi
    pop     esi
    retn
    sub_431A20 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_431A60 proc near                    ; CODE XREF: sub_491200+281p

    var_D14= dword ptr -0D14h
    var_D10= dword ptr -0D10h
    var_D08= dword ptr -0D08h
    var_D04= dword ptr -0D04h
    var_D00= byte ptr -0D00h
    Text= byte ptr -0C00h
    var_B00= dword ptr -0B00h
    var_A00= dword ptr -0A00h
    var_900= dword ptr -900h
    var_800= dword ptr -800h
    var_700= dword ptr -700h
    var_600= dword ptr -600h
    var_500= dword ptr -500h
    var_400= dword ptr -400h
    var_300= dword ptr -300h
    var_200= dword ptr -200h
    var_100= dword ptr -100h

    sub     esp, 0D14h
    push    ebx
    push    ebp
    push    esi
    push    edi
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C2EA0
    push    offset off_50341C
    push    offset aSidedata                ; "sidedata"
    lea     eax, [esp+0D2Ch+var_D00]
    push    offset aGamedata                ; "gamedata"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+0D24h+var_D00]
    push    ecx
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C2F60
    mov     edx, TAdynmemStructPtr
    xor     esi, esi
    mov     [esp+0D24h+var_D08], esi
    lea     ebp, [edx+37F3Dh]
    lea     ebx, [ebp+4Ah]

    loc_431AAF:                             ; CODE XREF: sub_431A60+A84j
    push    esi
    lea     eax, [esp+0D28h+var_D00]
    push    offset aSideD                   ; "SIDE%d"
    push    eax
    mov     [ebx+1E0h], esi
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E10
    lea     ecx, [esp+0D24h+var_D00]
    push    ecx                             ; char *
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3410
    test    eax, eax
    jz      loc_4324E9
    mov     ecx, [esp+0D24h+var_D10]
    push    offset Data                     ; int
    push    1Eh                             ; size_t
    lea     edx, [esp+0D2Ch+var_D00]
    push    offset aName                    ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_431B26
    lea     edi, [esp+0D24h+var_D00]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_431B26:                             ; CODE XREF: sub_431A60+A3j
    push    offset Data                     ; int
    push    4                               ; size_t
    lea     ecx, [esp+0D2Ch+var_D00]
    push    offset aNameprefix              ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+0D34h+var_D10]
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_431B68
    lea     edi, [esp+0D24h+var_D00]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebx-2Ch]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_431B68:                             ; CODE XREF: sub_431A60+E2j
    push    offset Data                     ; int
    push    20h                             ; size_t
    lea     ecx, [esp+0D2Ch+var_D00]
    push    offset aCommander               ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+0D34h+var_D10]
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_431BAA
    lea     edi, [esp+0D24h+var_D00]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebx-28h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_431BAA:                             ; CODE XREF: sub_431A60+124j
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+0D2Ch+var_D00]
    push    offset aFont                    ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+0D34h+var_D10]
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_431C0F
    lea     edx, [esp+0D24h+var_D00]
    push    offset aFnt                     ; "FNT"
    push    edx
    lea     eax, [esp+0D2Ch+Text]
    push    offset aFonts                   ; "fonts"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+0D24h+Text]
    push    0
    push    ecx
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_431C09
    lea     edx, [esp+0D24h+Text]
    push    edx                             ; lpText
    call    sub_4B6290

    loc_431C09:                             ; CODE XREF: sub_431A60+19Aj
    mov     [ebx+1E4h], esi

    loc_431C0F:                             ; CODE XREF: sub_431A60+169j
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aEnergycolor             ; char *
    call    sub_4C46C0
    mov     [ebx+1D8h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aMetalcolor              ; char *
    call    sub_4C46C0
    lea     ecx, [esp+0D24h+var_D14]
    mov     [ebx+1DCh], eax
    call    sub_4C3E20
    push    offset aLogo_0                  ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_431C82
    push    ebp
    push    offset aLogo_0                  ; "LOGO"
    lea     eax, [esp+0D2Ch+var_800]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+0D24h+var_800]
    push    ecx                             ; lpText
    call    sub_4B6290
    jmp     short loc_431CCD
    ; ---------------------------------------------------------------------------

    loc_431C82:                             ; CODE XREF: sub_431A60+1F6j
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx-8], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx-4], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+4], eax

    loc_431CCD:                             ; CODE XREF: sub_431A60+220j
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aEnergybar               ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_431D1E
    push    ebp
    push    offset aEnergybar               ; "ENERGYBAR"
    lea     edx, [esp+0D2Ch+var_200]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+0D24h+var_200]
    push    eax                             ; lpText
    call    sub_4B6290
    jmp     short loc_431D6A
    ; ---------------------------------------------------------------------------

    loc_431D1E:                             ; CODE XREF: sub_431A60+292j
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+8], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+0Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+10h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+14h], eax

    loc_431D6A:                             ; CODE XREF: sub_431A60+2BCj
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aEnergynum               ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_431DBB
    push    ebp
    push    offset aEnergynum               ; "ENERGYNUM"
    lea     ecx, [esp+0D2Ch+var_B00]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+0D24h+var_B00]
    push    edx                             ; lpText
    call    sub_4B6290
    jmp     short loc_431E07
    ; ---------------------------------------------------------------------------

    loc_431DBB:                             ; CODE XREF: sub_431A60+32Fj
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+18h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+1Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+20h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+24h], eax

    loc_431E07:                             ; CODE XREF: sub_431A60+359j
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aMetalbar                ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_431E58
    push    ebp
    push    offset aMetalbar                ; "METALBAR"
    lea     eax, [esp+0D2Ch+var_400]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+0D24h+var_400]
    push    ecx                             ; lpText
    call    sub_4B6290
    jmp     short loc_431EA4
    ; ---------------------------------------------------------------------------

    loc_431E58:                             ; CODE XREF: sub_431A60+3CCj
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+28h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+2Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+30h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+34h], eax

    loc_431EA4:                             ; CODE XREF: sub_431A60+3F6j
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aMetalnum                ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_431EF5
    push    ebp
    push    offset aMetalnum                ; "METALNUM"
    lea     edx, [esp+0D2Ch+var_600]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+0D24h+var_600]
    push    eax                             ; lpText
    call    sub_4B6290
    jmp     short loc_431F41
    ; ---------------------------------------------------------------------------

    loc_431EF5:                             ; CODE XREF: sub_431A60+469j
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+38h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+3Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+40h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+44h], eax

    loc_431F41:                             ; CODE XREF: sub_431A60+493j
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aTotalunits              ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_431F92
    push    ebp
    push    offset aTotalunits              ; "TOTALUNITS"
    lea     ecx, [esp+0D2Ch+var_A00]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+0D24h+var_A00]
    push    edx                             ; lpText
    call    sub_4B6290
    jmp     short loc_431FDE
    ; ---------------------------------------------------------------------------

    loc_431F92:                             ; CODE XREF: sub_431A60+506j
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+48h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+4Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+50h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+54h], eax

    loc_431FDE:                             ; CODE XREF: sub_431A60+530j
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aTotaltime               ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_43202F
    push    ebp
    push    offset aTotaltime               ; "TOTALTIME"
    lea     eax, [esp+0D2Ch+var_900]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+0D24h+var_900]
    push    ecx                             ; lpText
    call    sub_4B6290
    jmp     short loc_43207B
    ; ---------------------------------------------------------------------------

    loc_43202F:                             ; CODE XREF: sub_431A60+5A3j
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+58h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+5Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+60h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+64h], eax

    loc_43207B:                             ; CODE XREF: sub_431A60+5CDj
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aEnergy0                 ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_4320CC
    push    ebp
    push    offset aEnergy0                 ; "ENERGY0"
    lea     edx, [esp+0D2Ch+var_700]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+0D24h+var_700]
    push    eax                             ; lpText
    call    sub_4B6290
    jmp     short loc_432124
    ; ---------------------------------------------------------------------------

    loc_4320CC:                             ; CODE XREF: sub_431A60+640j
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+88h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+8Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+90h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+94h], eax

    loc_432124:                             ; CODE XREF: sub_431A60+66Aj
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aMetal0                  ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_432175
    push    ebp
    push    offset aMetal0                  ; "METAL0"
    lea     ecx, [esp+0D2Ch+var_500]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+0D24h+var_500]
    push    edx                             ; lpText
    call    sub_4B6290
    jmp     short loc_4321CD
    ; ---------------------------------------------------------------------------

    loc_432175:                             ; CODE XREF: sub_431A60+6E9j
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+98h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+9Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+0A0h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+0A4h], eax

    loc_4321CD:                             ; CODE XREF: sub_431A60+713j
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aEnergymax               ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_43221E
    push    ebp
    push    offset aEnergymax               ; "ENERGYMAX"
    lea     eax, [esp+0D2Ch+var_300]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+0D24h+var_300]
    push    ecx                             ; lpText
    call    sub_4B6290
    jmp     short loc_43226A
    ; ---------------------------------------------------------------------------

    loc_43221E:                             ; CODE XREF: sub_431A60+792j
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+68h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+6Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+70h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+74h], eax

    loc_43226A:                             ; CODE XREF: sub_431A60+7BCj
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3E20
    push    offset aMetalmax                ; char *
    lea     ecx, [esp+0D28h+var_D14]
    mov     esi, eax
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_4322BB
    push    ebp
    push    offset aMetalmax                ; "METALMAX"
    lea     edx, [esp+0D2Ch+var_100]
    push    offset aNoSInGamedataS          ; "No [%s] in GAMEDATA/SIDEDATA.TDF for si"...
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+0D24h+var_100]
    push    eax                             ; lpText
    call    sub_4B6290
    jmp     short loc_43230D
    ; ---------------------------------------------------------------------------

    loc_4322BB:                             ; CODE XREF: sub_431A60+82Fj
    mov     ecx, [esp+0D24h+var_D10]
    push    0                               ; int
    push    offset aX1                      ; char *
    call    sub_4C46C0
    mov     [ebx+78h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY1                      ; char *
    call    sub_4C46C0
    mov     [ebx+7Ch], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aX2                      ; char *
    call    sub_4C46C0
    mov     [ebx+80h], eax
    push    0                               ; int
    mov     ecx, [esp+0D28h+var_D10]
    push    offset aY2                      ; char *
    call    sub_4C46C0
    mov     [ebx+84h], eax

    loc_43230D:                             ; CODE XREF: sub_431A60+859j
    push    esi
    lea     ecx, [esp+0D28h+var_D14]
    call    sub_4C3E30
    push    ebp
    lea     ecx, [ebx+0A8h]
    push    offset aEnergyproduced          ; "ENERGYPRODUCED"
    lea     edx, [esp+0D2Ch+var_D14]
    push    ecx
    push    edx
    call    sub_431950
    push    ebp
    lea     eax, [ebx+0B8h]
    push    offset aEnergyconsumed          ; "ENERGYCONSUMED"
    lea     ecx, [esp+0D2Ch+var_D14]
    push    eax
    push    ecx
    call    sub_431950
    push    ebp
    lea     edx, [ebx+0C8h]
    push    offset aMetalproduced           ; "METALPRODUCED"
    lea     eax, [esp+0D2Ch+var_D14]
    push    edx
    push    eax
    call    sub_431950
    push    ebp
    lea     ecx, [ebx+0D8h]
    push    offset aMetalconsumed           ; "METALCONSUMED"
    lea     edx, [esp+0D2Ch+var_D14]
    push    ecx
    push    edx
    call    sub_431950
    push    ebp
    lea     eax, [ebx+0E8h]
    push    offset aLogo2                   ; "LOGO2"
    lea     ecx, [esp+0D2Ch+var_D14]
    push    eax
    push    ecx
    call    sub_431950
    push    ebp
    lea     edx, [ebx+0F8h]
    push    offset aUnitname_1              ; "UNITNAME"
    lea     eax, [esp+0D2Ch+var_D14]
    push    edx
    push    eax
    call    sub_431950
    push    ebp
    lea     ecx, [ebx+108h]
    push    offset aDamagebar               ; "DAMAGEBAR"
    lea     edx, [esp+0D2Ch+var_D14]
    push    ecx
    push    edx
    call    sub_431950
    push    ebp
    lea     eax, [ebx+138h]
    push    offset aUnitmetalmake           ; "UNITMETALMAKE"
    lea     ecx, [esp+0D2Ch+var_D14]
    push    eax
    push    ecx
    call    sub_431950
    push    ebp
    lea     edx, [ebx+148h]
    push    offset aUnitmetaluse            ; "UNITMETALUSE"
    lea     eax, [esp+0D2Ch+var_D14]
    push    edx
    push    eax
    call    sub_431950
    push    ebp
    lea     ecx, [ebx+118h]
    push    offset aUnitenergymake          ; "UNITENERGYMAKE"
    lea     edx, [esp+0D2Ch+var_D14]
    push    ecx
    push    edx
    call    sub_431950
    push    ebp
    lea     eax, [ebx+128h]
    push    offset aUnitenergyuse           ; "UNITENERGYUSE"
    lea     ecx, [esp+0D2Ch+var_D14]
    push    eax
    push    ecx
    call    sub_431950
    push    ebp
    lea     edx, [ebx+158h]
    push    offset aMissiontext             ; "MISSIONTEXT"
    lea     eax, [esp+0D2Ch+var_D14]
    push    edx
    push    eax
    call    sub_431950
    push    ebp
    lea     ecx, [ebx+168h]
    push    offset aUnitname2               ; "UNITNAME2"
    lea     edx, [esp+0D2Ch+var_D14]
    push    ecx
    push    edx
    call    sub_431950
    push    ebp
    lea     eax, [ebx+178h]
    push    offset aDamagebar2              ; "DAMAGEBAR2"
    lea     ecx, [esp+0D2Ch+var_D14]
    push    eax
    push    ecx
    call    sub_431950
    push    ebp
    lea     edx, [ebx+188h]
    push    offset aName_0                  ; "NAME"
    lea     eax, [esp+0D2Ch+var_D14]
    push    edx
    push    eax
    call    sub_431950
    push    ebp
    lea     ecx, [ebx+198h]
    push    offset aDescription_1           ; "DESCRIPTION"
    lea     edx, [esp+0D2Ch+var_D14]
    push    ecx
    push    edx
    call    sub_431950
    mov     esi, 1
    lea     edi, [ebx+1A8h]
    mov     [esp+0D24h+var_D04], 3

    loc_43249A:                             ; CODE XREF: sub_431A60+A6Bj
    push    esi
    lea     eax, [esp+0D28h+var_D00]
    push    offset aReloadD                 ; "RELOAD%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+0D24h+var_D00]
    lea     edx, [esp+0D24h+var_D14]
    push    ebp
    push    ecx
    push    edi
    push    edx
    call    sub_431950
    inc     esi
    add     edi, 10h
    mov     eax, [esp+0D24h+var_D04]
    dec     eax
    mov     [esp+0D24h+var_D04], eax
    jnz     short loc_43249A
    mov     edx, [esp+0D24h+var_D08]
    add     ebp, 232h
    inc     edx
    add     ebx, 232h
    mov     [esp+0D24h+var_D08], edx
    mov     esi, edx
    jmp     loc_431AAF
    ; ---------------------------------------------------------------------------

    loc_4324E9:                             ; CODE XREF: sub_431A60+81j
    lea     ecx, [esp+0D24h+var_D14]
    call    sub_4C3240
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+0D24h+var_D14]
    mov     [eax+37F39h], esi
    call    sub_4C2EB0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D14h
    retn
    sub_431A60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432520 proc near                    ; CODE XREF: sub_491EC0+BAp
                                            ; sub_492360+147p ...

    arg_0= dword ptr  8

    push    esi
    push    4                               ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43253A
    mov     ecx, eax
    call    sub_4B3620
    mov     esi, eax
    jmp     short loc_43253C
    ; ---------------------------------------------------------------------------

    loc_43253A:                             ; CODE XREF: sub_432520+Dj
    xor     esi, esi

    loc_43253C:                             ; CODE XREF: sub_432520+18j
    mov     eax, off_503320
    mov     ecx, dword_50331C
    mov     edx, [esp+arg_0]
    push    eax
    push    ecx
    push    edx
    mov     ecx, esi
    call    sub_4B3770
    test    eax, eax
    jnz     short loc_432573
    test    esi, esi
    jz      short loc_43256D
    mov     ecx, esi
    call    sub_4B3630
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_43256D:                             ; CODE XREF: sub_432520+3Bj
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_432573:                             ; CODE XREF: sub_432520+37j
    mov     eax, off_503320
    mov     ecx, esi
    push    eax                             ; char *
    call    sub_4B4560
    mov     eax, esi
    pop     esi
    retn    4
    sub_432520 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432590 proc near                    ; CODE XREF: sub_491EC0+3C8p
                                            ; sub_492360+168p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jz      short loc_4325A9
    mov     ecx, esi
    call    sub_4B3630
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4325A9:                             ; CODE XREF: sub_432590+7j
    pop     esi
    retn    4
    sub_432590 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4325B0 proc near                    ; CODE XREF: sub_492360+2EAp

    arg_0= dword ptr  8

    push    esi
    push    4                               ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4325CA
    mov     ecx, eax
    call    sub_4B3620
    mov     esi, eax
    jmp     short loc_4325CC
    ; ---------------------------------------------------------------------------

    loc_4325CA:                             ; CODE XREF: sub_4325B0+Dj
    xor     esi, esi

    loc_4325CC:                             ; CODE XREF: sub_4325B0+18j
    mov     eax, dword_50331C
    mov     ecx, [esp+arg_0]
    push    0
    push    eax
    push    ecx
    mov     ecx, esi
    call    sub_4B3770
    test    eax, eax
    jnz     short loc_4325FE
    test    esi, esi
    jz      short loc_4325F8
    mov     ecx, esi
    call    sub_4B3630
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4325F8:                             ; CODE XREF: sub_4325B0+36j
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4325FE:                             ; CODE XREF: sub_4325B0+32j
    mov     eax, esi
    pop     esi
    retn    4
    sub_4325B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432610 proc near                    ; CODE XREF: sub_497180+9A9p

    arg_0= dword ptr  4

    mov     eax, off_503320
    push    esi
    mov     esi, [esp+4+arg_0]
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_4B4560
    push    offset aMaxunits                ; char *
    mov     ecx, esi
    call    sub_4B48F0
    test    eax, eax
    jz      short loc_43264D
    push    0                               ; int
    push    offset aMaxunits                ; char *
    mov     ecx, esi
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37EECh], ax

    loc_43264D:                             ; CODE XREF: sub_432610+20j
    push    esi                             ; int
    call    sub_466050
    push    esi
    call    sub_41D2B0
    push    esi
    call    sub_424C00
    push    esi
    call    sub_484D60
    push    esi
    call    sub_484E80
    push    esi
    call    sub_484FA0
    push    esi
    call    sub_486FD0
    push    esi
    call    sub_438250
    mov     edx, TAdynmemStructPtr
    push    esi
    mov     ecx, [edx+391EDh]
    call    sub_48FE60
    mov     eax, TAdynmemStructPtr
    pop     esi
    or      byte ptr [eax+37EBEh], 10h
    mov     eax, 1
    retn    4
    sub_432610 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4326B0(int,int,int)
    sub_4326B0 proc near                    ; CODE XREF: .text:0041747Bp
                                            ; sub_492DF0+259p

    var_104= dword ptr -104h
    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 104h
    lea     ecx, [esp+104h+var_104]
    push    esi
    call    sub_4B3620
    lea     ecx, [esp+108h+var_104]
    call    sub_4B3750
    mov     eax, off_503320
    lea     ecx, [esp+108h+var_104]
    push    eax                             ; char *
    call    sub_4B4560
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+108h+var_100]
    mov     edx, [ecx+4]
    push    edx
    push    offset aBuildDateS              ; "BUILD DATE: %s"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+108h+var_100]
    push    0                               ; int
    push    ecx                             ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4630
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+108h+var_100]
    mov     eax, [edx+8]
    push    eax
    push    offset aBuildTimeS              ; "BUILD TIME: %s"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+108h+var_100]
    lea     ecx, [esp+108h+var_104]
    push    0                               ; int
    push    edx                             ; char *
    call    sub_4B4630
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     ax, [ecx+37EECh]
    lea     ecx, [esp+108h+var_104]
    push    eax                             ; int
    push    offset aMaxunits                ; char *
    call    sub_4B4630
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_4352B0
    push    eax                             ; int
    push    offset aCampaign                ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4750
    mov     eax, TAdynmemStructPtr
    mov     esi, 6
    cmp     [eax+391F1h], esi
    jz      short loc_432790
    mov     ecx, [eax+391E9h]
    call    sub_435C60
    mov     eax, TAdynmemStructPtr

    loc_432790:                             ; CODE XREF: sub_4326B0+CEj
    mov     ecx, [eax+391E9h]
    call    sub_435C30
    push    eax                             ; int
    push    offset aMission                 ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4750
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435C30
    push    eax                             ; int
    push    offset aMap                     ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4750
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37EEEh]
    lea     ecx, [esp+108h+var_104]
    push    edx                             ; int
    push    offset aDifficulty              ; char *
    call    sub_4B4630
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     dl, [ecx+95h]
    lea     ecx, [esp+108h+var_104]
    push    edx                             ; int
    push    offset aSide_0                  ; char *
    call    sub_4B4630
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     ax, [ecx+TAdynmemStruct.LOS_Radar]
    lea     ecx, [esp+108h+var_104]
    push    eax                             ; int
    push    offset aPlayers                 ; char *
    call    sub_4B4630
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    push    eax                             ; int
    push    offset aGametype                ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4630
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+108h+var_104]
    add     eax, 391CFh
    push    eax                             ; int
    push    offset aThumbs                  ; char *
    call    sub_4B4750
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+TAdynmemStruct.MapFile]
    call    sub_435100
    cmp     eax, 2
    jnz     loc_432932
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+(TAdynmemStruct+29A0h)]
    mov     ecx, [eax+108h]
    push    ecx                             ; int
    push    offset aCommanderdeath          ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4630
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+(TAdynmemStruct+29A0h)]
    mov     ecx, [eax+118h]
    push    ecx                             ; int
    push    offset aLocation                ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4630
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+(TAdynmemStruct+29A0h)]
    mov     ecx, [eax+10Ch]
    push    ecx                             ; int
    push    offset aMapping_0               ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4630
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+(TAdynmemStruct+29A0h)]
    mov     ecx, [eax+110h]
    push    ecx                             ; int
    push    offset aLineofsight_0           ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4630
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    mov     ecx, [eax+114h]
    push    ecx                             ; int
    push    offset aLineofsighttyp          ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4630

    loc_432932:                             ; CODE XREF: sub_4326B0+1D7j
    mov     edx, TAdynmemStructPtr
    cmp     [edx+391F1h], esi
    jz      short loc_432967
    push    1                               ; int
    push    offset aBetweenmission          ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4630
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391ABh]
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435C00

    loc_432967:                             ; CODE XREF: sub_4326B0+28Ej
    mov     eax, [esp+108h+arg_4]
    test    eax, eax
    jz      short loc_432981
    push    eax                             ; int
    push    offset aDescription             ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4750

    loc_432981:                             ; CODE XREF: sub_4326B0+2C0j
    mov     edx, [esp+108h+arg_8]
    lea     ecx, [esp+108h+var_104]
    push    edx                             ; int
    push    offset aGameId                  ; char *
    call    sub_4B4630
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    push    ecx                             ; int
    push    offset aGameTime                ; char *
    lea     ecx, [esp+110h+var_104]
    call    sub_4B4630
    mov     edx, TAdynmemStructPtr
    cmp     [edx+391F1h], esi
    jnz     loc_432A4D
    push    offset aRadarImage              ; "Radar Image"
    lea     ecx, [esp+10Ch+var_104]
    call    sub_4B4BA0
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+108h+var_104]
    push    eax
    mov     edx, [ecx+142DBh]
    push    edx
    call    sub_4C6F10
    lea     eax, [esp+108h+var_104]
    push    eax
    call    sub_41D360
    lea     ecx, [esp+108h+var_104]
    push    ecx
    call    sub_4662F0
    lea     edx, [esp+108h+var_104]
    push    edx
    call    sub_4876C0
    lea     eax, [esp+108h+var_104]
    push    eax
    call    sub_484F50
    lea     ecx, [esp+108h+var_104]
    push    ecx
    call    sub_424890
    lea     edx, [esp+108h+var_104]
    push    edx
    call    sub_484DF0
    lea     eax, [esp+108h+var_104]
    push    eax
    call    sub_484CE0
    lea     ecx, [esp+108h+var_104]
    push    ecx
    call    sub_438180
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+108h+var_104]
    push    edx
    mov     ecx, [eax+391EDh]
    call    sub_48FDF0

    loc_432A4D:                             ; CODE XREF: sub_4326B0+30Dj
    mov     ecx, dword_50331C
    mov     edx, [esp+108h+arg_0]
    push    0
    push    1
    push    ecx
    push    edx
    lea     ecx, [esp+118h+var_104]
    call    sub_4B39C0
    lea     ecx, [esp+108h+var_104]
    mov     esi, eax
    call    sub_4B3630
    mov     eax, esi
    pop     esi
    add     esp, 104h
    retn    0Ch
    sub_4326B0 endp

    ; ---------------------------------------------------------------------------
    mov     eax, [esp+4]
    sub     esp, 40h
    test    eax, eax
    push    esi
    push    edi
    lea     edx, [esp+8]
    mov     edi, offset aCorecamp           ; "CoreCamp"
    jnz     short loc_432A9B
    mov     edi, offset aArmcamp            ; "ArmCamp"

    loc_432A9B:                             ; CODE XREF: .text:00432A94j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     dword ptr [esp+4Ch], 1Ah
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+8]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     esi, [esp+50h]
    lea     ecx, [esp+4Ch]
    push    ecx
    push    esi
    push    edx
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_2
    test    eax, eax
    jnz     short loc_432AF0
    mov     ecx, 6
    mov     eax, 55555555h
    mov     edi, esi
    rep stosd
    stosb
    mov     byte ptr [esi+19h], 0

    loc_432AF0:                             ; CODE XREF: .text:00432ADBj
    pop     edi
    pop     esi
    add     esp, 40h
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    sub     esp, 40h
    test    eax, eax
    push    esi
    push    edi
    lea     edx, [esp+8]
    mov     edi, offset aCorecamp           ; "CoreCamp"
    jnz     short loc_432B1B
    mov     edi, offset aArmcamp            ; "ArmCamp"

    loc_432B1B:                             ; CODE XREF: .text:00432B14j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+50h]
    and     ecx, 3
    push    eax
    rep movsb
    lea     ecx, [esp+0Ch]
    mov     byte ptr [eax+19h], 0
    push    ecx
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_5
    pop     edi
    pop     esi
    add     esp, 40h
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432B60 proc near                    ; CODE XREF: .text:0047757Cp
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+38D7Fh]
    and     ecx, 1
    push    ecx
    push    offset aAllmissions             ; "AllMissions"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    retn
    sub_432B60 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432B80 proc near                    ; CODE XREF: sub_47B9F0+15Dp
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38D81h]
    push    ecx
    push    offset aNumskirmishpla          ; "NumSkirmishPlayers"
    push    offset aTotalAnnihil_0          ; "Total Annihilation"
    call    WriteRegistryValue_6
    retn
    sub_432B80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432BA0 proc near                    ; CODE XREF: sub_42A8D0+4Bp
                                            ; sub_42A8D0+108p
    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    mov     edi, [ebx+8]
    mov     esi, [ebx+4]
    cmp     esi, edi
    jz      short loc_432BBD

    loc_432BAF:                             ; CODE XREF: sub_432BA0+1Bj
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_432BAF

    loc_432BBD:                             ; CODE XREF: sub_432BA0+Dj
    mov     eax, [ebx+4]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [ebx+4], eax
    mov     [ebx+8], eax
    pop     edi
    mov     [ebx+0Ch], eax
    pop     esi
    pop     ebx
    retn
    sub_432BA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432BE0 proc near                    ; CODE XREF: sub_42A8D0+3Ep
                                            ; sub_42A8D0+55p
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_432BEA
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_432BEA:                             ; CODE XREF: sub_432BE0+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_432BE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432C00 proc near                    ; CODE XREF: sub_42A8D0+917p

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    call    sub_4C9390
    test    [esp+arg_0], 1
    jz      short loc_432C18
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_432C18:                             ; CODE XREF: sub_432C00+Dj
    mov     eax, esi
    pop     esi
    retn    4
    sub_432C00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432C20 proc near                    ; CODE XREF: sub_42E440+D96p

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    call    sub_4C9390
    test    [esp+arg_0], 1
    jz      short loc_432C38
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_432C38:                             ; CODE XREF: sub_432C20+Dj
    mov     eax, esi
    pop     esi
    retn    4
    sub_432C20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432C40 proc near                    ; CODE XREF: sub_42E440+E69p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    push    edi
    mov     edi, [esp+8+arg_8]
    cmp     esi, ebx
    jz      short loc_432C6F

    loc_432C53:                             ; CODE XREF: sub_432C40+2Dj
    test    edi, edi
    jz      short loc_432C65
    push    esi
    mov     ecx, edi
    call    sub_4C91A0
    mov     eax, [esi+4]
    mov     [edi+4], eax

    loc_432C65:                             ; CODE XREF: sub_432C40+15j
    add     esi, 8
    add     edi, 8
    cmp     esi, ebx
    jnz     short loc_432C53

    loc_432C6F:                             ; CODE XREF: sub_432C40+11j
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_432C40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432C80 proc near                    ; CODE XREF: sub_42E440+E86p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    cmp     esi, ebx
    jz      short loc_432CA9
    push    edi
    mov     edi, [esp+8+arg_8]

    loc_432C93:                             ; CODE XREF: sub_432C80+26j
    push    edi
    mov     ecx, esi
    call    sub_4C93B0
    mov     eax, [edi+4]
    mov     [esi+4], eax
    add     esi, 8
    cmp     esi, ebx
    jnz     short loc_432C93
    pop     edi

    loc_432CA9:                             ; CODE XREF: sub_432C80+Cj
    pop     esi
    pop     ebx
    retn    0Ch
    sub_432C80 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432CB0 proc near                    ; CODE XREF: sub_42E440+E77p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_4]
    push    edi
    mov     edi, [esp+8+arg_8]
    cmp     ebx, esi
    jz      short loc_432CDB

    loc_432CC3:                             ; CODE XREF: sub_432CB0+29j
    sub     esi, 8
    sub     edi, 8
    push    esi
    mov     ecx, edi
    call    sub_4C93B0
    mov     eax, [esi+4]
    cmp     esi, ebx
    mov     [edi+4], eax
    jnz     short loc_432CC3

    loc_432CDB:                             ; CODE XREF: sub_432CB0+11j
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_432CB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432CF0 proc near                    ; CODE XREF: sub_42E440+D27p
                                            ; sub_42E440+D50p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jz      short loc_432D0D
    push    edi
    mov     edi, [esp+4+arg_4]
    push    edi
    mov     ecx, esi
    call    sub_4C91A0
    mov     eax, [edi+4]
    pop     edi
    mov     [esi+4], eax

    loc_432D0D:                             ; CODE XREF: sub_432CF0+7j
    pop     esi
    retn    8
    sub_432CF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432D20 proc near                    ; CODE XREF: sub_42E440+E53p

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_4C93B0
    mov     eax, [edi+4]
    pop     edi
    mov     [esi+4], eax
    mov     eax, esi
    pop     esi
    retn    4
    sub_432D20 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432D40 proc near                    ; CODE XREF: sub_42D2E0+29Dp
                                            ; sub_432D40+214p ...

    var_DE0= dword ptr -0DE0h
    var_DD8= dword ptr -0DD8h
    var_DD0= dword ptr -0DD0h
    var_DC8= dword ptr -0DC8h
    var_B94= dword ptr -0B94h
    var_B8C= dword ptr -0B8Ch
    var_B84= dword ptr -0B84h
    var_B7C= dword ptr -0B7Ch
    var_948= dword ptr -948h
    var_940= dword ptr -940h
    var_938= dword ptr -938h
    var_930= dword ptr -930h
    var_714= dword ptr -714h
    var_70C= dword ptr -70Ch
    var_704= dword ptr -704h
    var_6FC= dword ptr -6FCh
    var_4B0= dword ptr -4B0h
    var_284= dword ptr -284h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0DC8h
    mov     eax, 0E00E00E1h
    push    ebx
    mov     ebx, [esp+0DCCh+arg_0]
    push    ebp
    mov     ebp, [esp+0DD0h+arg_4]
    mov     ecx, ebp
    sub     ecx, ebx
    imul    ecx
    add     edx, ecx
    sar     edx, 9
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 10h
    jle     loc_432F99
    push    edi
    push    esi
    jmp     short loc_432D88
    ; ---------------------------------------------------------------------------

    loc_432D7A:                             ; CODE XREF: sub_432D40+251j
    mov     ebp, [esp+0DD8h+arg_4]
    mov     ebx, [esp+0DD8h+arg_0]

    loc_432D88:                             ; CODE XREF: sub_432D40+38j
    mov     ecx, 92h
    mov     esi, ebx
    lea     edi, [esp+0DD8h+var_930]
    mov     eax, edx
    rep movsd
    cdq
    sub     eax, edx
    lea     edx, [esp+0DD8h+var_B7C]
    movsb
    sar     eax, 1
    mov     esi, eax
    lea     edi, [esp+0DD8h+var_B7C]
    shl     esi, 6
    add     esi, eax
    lea     eax, [esp+0DD8h+var_930]
    push    edx
    push    eax
    lea     ecx, [ebx+esi*8]
    add     esi, ecx
    mov     ecx, 92h
    rep movsd
    movsb
    lea     esi, [ebp-249h]
    mov     ecx, 92h
    lea     edi, [esp+0DE0h+var_DC8]
    rep movsd
    movsb
    mov     esi, [esp+0DE0h+arg_8]
    call    esi
    test    eax, eax
    jz      short loc_432E1D
    lea     ecx, [esp+0DD8h+var_DC8]
    lea     edx, [esp+0DD8h+var_B7C]
    push    ecx
    push    edx
    call    esi
    test    eax, eax
    jnz     short loc_432E50
    lea     eax, [esp+0DD8h+var_DC8]
    lea     ecx, [esp+0DD8h+var_930]
    push    eax
    push    ecx
    call    esi
    test    eax, eax
    lea     esi, [esp+0DD8h+var_DC8]
    jnz     short loc_432E57
    lea     esi, [esp+0DD8h+var_930]
    jmp     short loc_432E57
    ; ---------------------------------------------------------------------------

    loc_432E1D:                             ; CODE XREF: sub_432D40+A8j
    lea     edx, [esp+0DD8h+var_DC8]
    lea     eax, [esp+0DD8h+var_930]
    push    edx
    push    eax
    call    esi
    test    eax, eax
    jz      short loc_432E39
    lea     esi, [esp+0DD8h+var_930]
    jmp     short loc_432E57
    ; ---------------------------------------------------------------------------

    loc_432E39:                             ; CODE XREF: sub_432D40+EEj
    lea     ecx, [esp+0DD8h+var_DC8]
    lea     edx, [esp+0DD8h+var_B7C]
    push    ecx
    push    edx
    call    esi
    test    eax, eax
    lea     esi, [esp+0DD8h+var_DC8]
    jnz     short loc_432E57

    loc_432E50:                             ; CODE XREF: sub_432D40+BBj
    lea     esi, [esp+0DD8h+var_B7C]

    loc_432E57:                             ; CODE XREF: sub_432D40+D2j
                                            ; sub_432D40+DBj ...
    mov     ecx, 92h
    lea     edi, [esp+940h]
    rep movsd
    movsb
    mov     ecx, 92h
    lea     esi, [esp+940h]
    lea     edi, [esp+6F4h]
    rep movsd
    movsb

    loc_432E7C:                             ; CODE XREF: sub_432D40+1C3j
    mov     edi, [esp+0DD8h+arg_8]
    lea     eax, [esp+6F4h]
    push    eax
    push    ebx
    call    edi
    test    eax, eax
    jz      short loc_432EA7

    loc_432E92:                             ; CODE XREF: sub_432D40+165j
    lea     ecx, [esp+6F4h]
    add     ebx, 249h
    push    ecx
    push    ebx
    call    edi
    test    eax, eax
    jnz     short loc_432E92

    loc_432EA7:                             ; CODE XREF: sub_432D40+150j
    sub     ebp, 249h
    lea     edx, [esp+6F4h]
    push    ebp
    push    edx
    call    edi
    test    eax, eax
    jz      short loc_432ED1

    loc_432EBC:                             ; CODE XREF: sub_432D40+18Fj
    sub     ebp, 249h
    lea     eax, [esp+6F4h]
    push    ebp
    push    eax
    call    edi
    test    eax, eax
    jnz     short loc_432EBC

    loc_432ED1:                             ; CODE XREF: sub_432D40+17Aj
    cmp     ebp, ebx
    jbe     short loc_432F08
    mov     ecx, 92h
    mov     esi, ebx
    lea     edi, [esp+0B8Ch]
    push    ebp
    rep movsd
    mov     ecx, ebx
    movsb
    call    sub_42B370
    lea     ecx, [esp+0B8Ch]
    push    ecx
    mov     ecx, ebp
    call    sub_42B370
    add     ebx, 249h
    jmp     loc_432E7C
    ; ---------------------------------------------------------------------------

    loc_432F08:                             ; CODE XREF: sub_432D40+193j
    mov     esi, [esp+0DD8h+arg_4]
    mov     eax, 0E00E00E1h
    sub     esi, ebx
    mov     ebp, [esp+0DD8h+arg_0]
    imul    esi
    mov     ecx, edx
    mov     eax, 0E00E00E1h
    add     ecx, esi
    mov     esi, ebx
    sar     ecx, 9
    mov     edx, ecx
    sub     esi, ebp
    shr     edx, 1Fh
    add     ecx, edx
    imul    esi
    add     edx, esi
    push    0
    sar     edx, 9
    mov     eax, edx
    push    edi
    shr     eax, 1Fh
    add     edx, eax
    cmp     ecx, edx
    jg      short loc_432F62
    mov     ecx, [esp+0DE0h+arg_4]
    push    ecx
    push    ebx
    call    sub_432D40
    mov     [esp+0DD8h+arg_4], ebx
    jmp     short loc_432F72
    ; ---------------------------------------------------------------------------

    loc_432F62:                             ; CODE XREF: sub_432D40+209j
    push    ebx
    push    ebp
    call    sub_432D40
    mov     ebp, ebx
    mov     [esp+0DD8h+arg_0], ebx

    loc_432F72:                             ; CODE XREF: sub_432D40+220j
    mov     ecx, [esp+0DD8h+arg_4]
    mov     eax, 0E00E00E1h
    sub     ecx, ebp
    imul    ecx
    add     edx, ecx
    sar     edx, 9
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 10h
    jg      loc_432D7A
    pop     esi
    pop     edi

    loc_432F99:                             ; CODE XREF: sub_432D40+30j
    pop     ebp
    pop     ebx
    add     esp, 0DC8h
    retn    10h
    sub_432D40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_432FB0 proc near                    ; CODE XREF: sub_42D2E0+293p
                                            ; sub_42D2E0+2B0p

    var_4B0= dword ptr -4B0h
    var_4A8= dword ptr -4A8h
    var_4A0= dword ptr -4A0h
    var_254= dword ptr -254h
    var_24C= dword ptr -24Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    sub     esp, 498h
    cmp     eax, ecx
    push    ebx
    jz      loc_43309A
    lea     ebx, [eax+249h]
    cmp     ebx, ecx
    jz      loc_43309A
    push    edi
    push    esi
    push    ebp
    mov     ebp, [esp+4A8h+arg_8]
    jmp     short loc_432FE8
    ; ---------------------------------------------------------------------------

    loc_432FE1:                             ; CODE XREF: sub_432FB0+E1j
    mov     eax, [esp+4A8h+arg_0]

    loc_432FE8:                             ; CODE XREF: sub_432FB0+2Fj
    mov     ecx, 92h
    mov     esi, ebx
    lea     edi, [esp+4A8h+var_24C]
    push    eax
    rep movsd
    lea     eax, [esp+4ACh+var_24C]
    push    eax
    movsb
    call    ebp
    test    eax, eax
    jnz     short loc_433052
    mov     ecx, 92h
    lea     esi, [esp+4A8h+var_24C]
    lea     edi, [esp+10h]
    rep movsd
    movsb
    lea     esi, [ebx-249h]
    lea     ecx, [esp+10h]
    push    esi
    push    ecx
    mov     edi, ebx
    call    ebp
    test    eax, eax
    jz      short loc_43304B

    loc_43302F:                             ; CODE XREF: sub_432FB0+99j
    push    esi
    mov     ecx, edi
    call    sub_42B370
    mov     edi, esi
    sub     esi, 249h
    lea     edx, [esp+4B0h+var_4A0]
    push    esi
    push    edx
    call    ebp
    test    eax, eax
    jnz     short loc_43302F

    loc_43304B:                             ; CODE XREF: sub_432FB0+7Dj
    lea     eax, [esp+4B8h+var_4A8]
    push    eax
    jmp     short loc_43307D
    ; ---------------------------------------------------------------------------

    loc_433052:                             ; CODE XREF: sub_432FB0+56j
    mov     edi, [esp+4A8h+arg_0]
    mov     esi, ebx
    cmp     edi, ebx
    jz      short loc_433075

    loc_43305F:                             ; CODE XREF: sub_432FB0+C3j
    sub     esi, 249h
    push    esi
    lea     ecx, [esi+249h]
    call    sub_42B370
    cmp     esi, edi
    jnz     short loc_43305F

    loc_433075:                             ; CODE XREF: sub_432FB0+ADj
    lea     ecx, [esp+4A8h+var_24C]
    push    ecx

    loc_43307D:                             ; CODE XREF: sub_432FB0+A0j
    mov     ecx, edi
    call    sub_42B370
    add     ebx, 249h
    cmp     ebx, [esp+4A8h+arg_4]
    jnz     loc_432FE1
    pop     ebp
    pop     esi
    pop     edi

    loc_43309A:                             ; CODE XREF: sub_432FB0+11j
                                            ; sub_432FB0+1Fj
    pop     ebx
    add     esp, 498h
    retn    10h
    sub_432FB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_4330B0:                             ; CODE XREF: .text:004814F5j
    sub     esp, 8
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebp, ebp
    mov     [esp+10h], edi
    mov     eax, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, eax
    mov     [esp+0Ch], eax
    jz      short loc_43310B
    push    ebx

    loc_4330CD:                             ; CODE XREF: .text:00433104j
    mov     ebx, [esi+8]
    mov     edi, [esi+4]
    cmp     edi, ebx
    jz      short loc_4330E6

    loc_4330D7:                             ; CODE XREF: .text:004330E4j
    push    edi
    mov     ecx, esi
    call    sub_434400
    add     edi, 10h
    cmp     edi, ebx
    jnz     short loc_4330D7

    loc_4330E6:                             ; CODE XREF: .text:004330D5j
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+14h]
    mov     [esi+4], ebp
    mov     [esi+8], ebp
    mov     [esi+0Ch], ebp
    add     esi, 10h
    add     esp, 4
    cmp     esi, eax
    jnz     short loc_4330CD
    mov     edi, [esp+14h]
    pop     ebx

    loc_43310B:                             ; CODE XREF: .text:004330CAj
    mov     ecx, [edi+4]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    mov     [edi+4], ebp
    mov     [edi+8], ebp
    mov     [edi+0Ch], ebp
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433130 proc near                    ; CODE XREF: sub_483610+5A3p

    var_11D= byte ptr -11Dh
    var_11C= dword ptr -11Ch
    var_118= dword ptr -118h
    var_110= dword ptr -110h
    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= dword ptr -100h

    sub     esp, 120h
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+124h+var_11C]
    call    sub_4C2EA0
    push    offset off_50341C
    push    offset aLos                     ; "los"
    lea     eax, [esp+12Ch+var_100]
    push    offset aGamedata                ; "gamedata"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+124h+var_100]
    push    ecx
    lea     ecx, [esp+128h+var_11C]
    call    sub_4C2F60
    test    eax, eax
    jz      loc_433257
    push    esi
    push    ebx
    push    offset aTableinfo               ; char *
    lea     ecx, [esp+130h+var_11C]
    call    sub_4C3410
    test    eax, eax
    jz      loc_43324C
    mov     ecx, [esp+12Ch+var_118]
    xor     esi, esi
    push    esi                             ; int
    push    offset aNumtables               ; char *
    call    sub_4C46C0
    mov     ecx, [edi+4]
    mov     dl, [esp+12Ch+var_11D]
    mov     ebx, eax
    cmp     ecx, esi
    mov     byte ptr [esp+12Ch+var_110], dl
    mov     [esp+12Ch+var_10C], esi
    mov     [esp+12Ch+var_108], esi
    mov     [esp+12Ch+var_104], esi
    movsx   eax, bx
    jnz     short loc_4331BE
    xor     edx, edx
    jmp     short loc_4331C6
    ; ---------------------------------------------------------------------------

    loc_4331BE:                             ; CODE XREF: sub_433130+88j
    mov     edx, [edi+8]
    sub     edx, ecx
    sar     edx, 4

    loc_4331C6:                             ; CODE XREF: sub_433130+8Cj
    cmp     edx, eax
    jnb     short loc_4331EF
    cmp     ecx, esi
    jnz     short loc_4331D2
    xor     edx, edx
    jmp     short loc_4331DA
    ; ---------------------------------------------------------------------------

    loc_4331D2:                             ; CODE XREF: sub_433130+9Cj
    mov     edx, [edi+8]
    sub     edx, ecx
    sar     edx, 4

    loc_4331DA:                             ; CODE XREF: sub_433130+A0j
    lea     ecx, [esp+12Ch+var_110]
    sub     eax, edx
    mov     edx, [edi+8]
    push    ecx
    push    eax
    push    edx
    mov     ecx, edi
    call    sub_4340F0
    jmp     short loc_433214
    ; ---------------------------------------------------------------------------

    loc_4331EF:                             ; CODE XREF: sub_433130+98j
    cmp     ecx, esi
    jnz     short loc_4331F7
    xor     edx, edx
    jmp     short loc_4331FF
    ; ---------------------------------------------------------------------------

    loc_4331F7:                             ; CODE XREF: sub_433130+C1j
    mov     edx, [edi+8]
    sub     edx, ecx
    sar     edx, 4

    loc_4331FF:                             ; CODE XREF: sub_433130+C5j
    cmp     eax, edx
    jnb     short loc_433214
    mov     edx, [edi+8]
    shl     eax, 4
    add     eax, ecx
    push    edx
    push    eax
    mov     ecx, edi
    call    sub_434360

    loc_433214:                             ; CODE XREF: sub_433130+BDj
                                            ; sub_433130+D1j
    mov     eax, [esp+12Ch+var_108]
    mov     ecx, [esp+12Ch+var_10C]
    push    eax
    push    ecx
    lea     ecx, [esp+134h+var_110]
    call    sub_4340B0
    mov     edx, [esp+12Ch+var_10C]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    cmp     bx, si
    jle     short loc_43324C

    loc_433239:                             ; CODE XREF: sub_433130+11Aj
    lea     eax, [esp+12Ch+var_11C]
    push    esi
    push    eax
    mov     ecx, edi
    call    sub_433380
    inc     esi
    cmp     si, bx
    jl      short loc_433239

    loc_43324C:                             ; CODE XREF: sub_433130+53j
                                            ; sub_433130+107j
    lea     ecx, [esp+12Ch+var_11C]
    call    sub_4C3240
    pop     ebx
    pop     esi

    loc_433257:                             ; CODE XREF: sub_433130+3Bj
    lea     ecx, [esp+124h+var_11C]
    call    sub_4C2EB0
    pop     edi
    add     esp, 120h
    retn
    sub_433130 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 10h
    mov     al, [esp+14h]
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    xor     esi, esi
    mov     ecx, [ebp+4]
    mov     [esp+0Ch], al
    movsx   eax, word ptr [esp+20h]
    cmp     ecx, esi
    push    edi
    mov     [esp+14h], esi
    mov     [esp+18h], esi
    mov     [esp+1Ch], esi
    jnz     short loc_43329F
    xor     edx, edx
    jmp     short loc_4332A7
    ; ---------------------------------------------------------------------------

    loc_43329F:                             ; CODE XREF: .text:00433299j
    mov     edx, [ebp+8]
    sub     edx, ecx
    sar     edx, 4

    loc_4332A7:                             ; CODE XREF: .text:0043329Dj
    cmp     edx, eax
    jnb     short loc_4332D0
    cmp     ecx, esi
    jnz     short loc_4332B3
    xor     edx, edx
    jmp     short loc_4332BB
    ; ---------------------------------------------------------------------------

    loc_4332B3:                             ; CODE XREF: .text:004332ADj
    mov     edx, [ebp+8]
    sub     edx, ecx
    sar     edx, 4

    loc_4332BB:                             ; CODE XREF: .text:004332B1j
    lea     ecx, [esp+10h]
    sub     eax, edx
    mov     edx, [ebp+8]
    push    ecx
    push    eax
    push    edx
    mov     ecx, ebp
    call    sub_4340F0
    jmp     short loc_433320
    ; ---------------------------------------------------------------------------

    loc_4332D0:                             ; CODE XREF: .text:004332A9j
    cmp     ecx, esi
    jnz     short loc_4332D8
    xor     edx, edx
    jmp     short loc_4332E0
    ; ---------------------------------------------------------------------------

    loc_4332D8:                             ; CODE XREF: .text:004332D2j
    mov     edx, [ebp+8]
    sub     edx, ecx
    sar     edx, 4

    loc_4332E0:                             ; CODE XREF: .text:004332D6j
    cmp     eax, edx
    jnb     short loc_433320
    mov     ebx, [ebp+8]
    shl     eax, 4
    add     eax, ecx
    cmp     ebx, ebx
    mov     edi, eax
    mov     esi, ebx
    jz      short loc_433306

    loc_4332F4:                             ; CODE XREF: .text:00433304j
    push    esi
    mov     ecx, edi
    call    sub_434770
    add     esi, 10h
    add     edi, 10h
    cmp     esi, ebx
    jnz     short loc_4332F4

    loc_433306:                             ; CODE XREF: .text:004332F2j
    mov     ebx, [ebp+8]
    mov     esi, edi
    cmp     edi, ebx
    jz      short loc_43331D

    loc_43330F:                             ; CODE XREF: .text:0043331Bj
    mov     ecx, esi
    call    sub_433A80
    add     esi, 10h
    cmp     esi, ebx
    jnz     short loc_43330F

    loc_43331D:                             ; CODE XREF: .text:0043330Dj
    mov     [ebp+8], edi

    loc_433320:                             ; CODE XREF: .text:004332CEj
                                            ; .text:004332E2j
    mov     ebx, [esp+18h]
    mov     esi, [esp+14h]
    cmp     esi, ebx
    jz      short loc_433367
    add     esi, 4

    loc_43332F:                             ; CODE XREF: .text:00433365j
    mov     eax, [esi+4]
    mov     ecx, [esi]
    lea     edi, [esi-4]
    push    eax
    push    ecx
    mov     ecx, edi
    call    nullsub_8
    mov     eax, [esi]
    mov     edx, [esi+8]
    sub     edx, eax
    mov     ecx, edi
    sar     edx, 2
    push    edx
    push    eax
    call    sub_433DA0                      ; ?do_narrow@?$ctype@G@std@@MBEDGD@Z
                                            ; doubtful name
    xor     eax, eax
    mov     [esi], eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    add     esi, 10h
    lea     eax, [esi-4]
    cmp     eax, ebx
    jnz     short loc_43332F

    loc_433367:                             ; CODE XREF: .text:0043332Aj
    mov     ecx, [esp+14h]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433380 proc near                    ; CODE XREF: sub_433130+111p

    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_20= byte ptr -20h
    arg_0= dword ptr  4
    arg_4= word ptr  8

    sub     esp, 3Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     di, [esp+4Ch+arg_4]
    mov     esi, ecx
    movsx   eax, di
    inc     eax
    lea     ecx, [esp+4Ch+var_20]
    push    eax
    push    offset aTableD                  ; "TABLE%d"
    push    ecx
    call    _sprintf
    mov     ebx, [esp+58h+arg_0]
    add     esp, 0Ch
    mov     ecx, ebx
    call    sub_4C3E10
    lea     edx, [esp+4Ch+var_20]
    mov     ecx, ebx
    push    edx                             ; char *
    call    sub_4C3410
    test    eax, eax
    jz      loc_4334EF
    mov     ecx, [ebx+4]
    push    0                               ; int
    movsx   eax, di
    mov     edi, [esi+4]
    push    offset aNumlines                ; char *
    shl     eax, 4
    add     edi, eax
    call    sub_4C46C0
    lea     ecx, [esp+4Ch+arg_4]
    mov     esi, eax
    push    ecx
    lea     ecx, [esp+50h+var_30]
    mov     [esp+50h+arg_0], esi
    call    sub_433A10
    movsx   ebp, si
    mov     ecx, edi
    shl     ebp, 2
    call    sub_433B00
    cmp     eax, ebp
    jnb     short loc_433427
    mov     edx, [edi+8]
    lea     eax, [esp+4Ch+var_30]
    push    eax
    mov     ecx, edi
    mov     [esp+50h+var_3C], edx
    call    sub_433B00
    mov     ecx, [esp+50h+var_3C]
    sub     ebp, eax
    push    ebp
    push    ecx
    mov     ecx, edi
    call    sub_433DB0
    jmp     short loc_433446
    ; ---------------------------------------------------------------------------

    loc_433427:                             ; CODE XREF: sub_433380+81j
    mov     ecx, edi
    call    sub_433B00
    cmp     ebp, eax
    jnb     short loc_433446
    mov     ecx, [edi+4]
    mov     edx, [edi+8]
    shl     ebp, 4
    add     ebp, ecx
    push    edx
    push    ebp
    mov     ecx, edi
    call    sub_434020

    loc_433446:                             ; CODE XREF: sub_433380+A5j
                                            ; sub_433380+B0j
    lea     ecx, [esp+4Ch+var_30]
    call    sub_433A30
    mov     eax, [esp+4Ch+arg_0]
    lea     ebp, [esi+esi]
    lea     ecx, [esi+esi*2]
    xor     esi, esi
    test    ax, ax
    mov     [esp+4Ch+var_3C], ebp
    jle     loc_4334EF
    sub     eax, ebp
    mov     dword ptr [esp+4Ch+arg_4], esi
    mov     [esp+4Ch+var_38], eax
    mov     eax, ecx
    sub     eax, ebp
    mov     [esp+4Ch+var_34], eax
    jmp     short loc_433480
    ; ---------------------------------------------------------------------------

    loc_43347C:                             ; CODE XREF: sub_433380+16Dj
    mov     ebp, [esp+4Ch+var_3C]

    loc_433480:                             ; CODE XREF: sub_433380+FAj
    mov     ecx, dword ptr [esp+4Ch+arg_4]
    mov     edx, [edi+4]
    push    0
    push    esi
    push    ebx
    add     ecx, edx
    call    sub_4336F0
    mov     eax, [esp+4Ch+var_38]
    add     ebp, esi
    mov     edx, [edi+4]
    add     eax, ebp
    movsx   ecx, ax
    push    1
    push    esi
    shl     ecx, 4
    push    ebx
    add     ecx, edx
    call    sub_4336F0
    mov     edx, [edi+4]
    push    2
    movsx   ecx, bp
    shl     ecx, 4
    push    esi
    push    ebx
    add     ecx, edx
    call    sub_4336F0
    mov     ecx, [esp+4Ch+var_34]
    push    3
    add     ecx, ebp
    mov     ebp, [edi+4]
    movsx   ecx, cx
    shl     ecx, 4
    push    esi
    push    ebx
    add     ecx, ebp
    call    sub_4336F0
    mov     ecx, dword ptr [esp+4Ch+arg_4]
    inc     esi
    add     ecx, 10h
    cmp     si, word ptr [esp+4Ch+arg_0]
    mov     dword ptr [esp+4Ch+arg_4], ecx
    jl      short loc_43347C

    loc_4334EF:                             ; CODE XREF: sub_433380+3Ej
                                            ; sub_433380+E2j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3Ch
    retn    8
    sub_433380 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433500 proc near                    ; CODE XREF: sub_481930+F2p
                                            ; sub_481D50+FDp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+4]
    dec     eax
    movsx   eax, ax
    shl     eax, 4
    add     eax, edx
    retn    4
    sub_433500 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433520 proc near                    ; CODE XREF: sub_481930+B3p
                                            ; sub_481930+E3p ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_43352A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_43352A:                             ; CODE XREF: sub_433520+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 4
    retn
    sub_433520 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebp, ebp
    mov     [esp+10h], edi
    mov     eax, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, eax
    mov     [esp+0Ch], eax
    jz      short loc_43359B
    push    ebx

    loc_43355D:                             ; CODE XREF: .text:00433594j
    mov     ebx, [esi+8]
    mov     edi, [esi+4]
    cmp     edi, ebx
    jz      short loc_433576

    loc_433567:                             ; CODE XREF: .text:00433574j
    push    edi
    mov     ecx, esi
    call    nullsub_43
    add     edi, 4
    cmp     edi, ebx
    jnz     short loc_433567

    loc_433576:                             ; CODE XREF: .text:00433565j
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+14h]
    mov     [esi+4], ebp
    mov     [esi+8], ebp
    mov     [esi+0Ch], ebp
    add     esi, 10h
    add     esp, 4
    cmp     esi, eax
    jnz     short loc_43355D
    mov     edi, [esp+14h]
    pop     ebx

    loc_43359B:                             ; CODE XREF: .text:0043355Aj
    mov     ecx, [edi+4]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    mov     [edi+4], ebp
    mov     [edi+8], ebp
    mov     [edi+0Ch], ebp
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4335C0 proc near                    ; CODE XREF: sub_481930+FDp
                                            ; sub_481D50+108p ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_4335CA
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_4335CA:                             ; CODE XREF: sub_4335C0+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 4
    retn
    sub_4335C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4335E0 proc near                    ; CODE XREF: sub_481930+15Dp
                                            ; sub_481D50+14Fp ...

    arg_0= word ptr  4

    movsx   eax, [esp+arg_0]
    mov     edx, [ecx+4]
    shl     eax, 4
    add     eax, edx
    retn    4
    sub_4335E0 endp

    ; ---------------------------------------------------------------------------
    sub     esp, 10h
    mov     al, [esp+14h]
    push    ebx
    push    ebp
    mov     [esp+8], al
    movsx   eax, word ptr [esp+1Ch]
    mov     ebp, ecx
    xor     edx, edx
    shl     eax, 2
    mov     ecx, [ebp+4]
    push    esi
    cmp     ecx, edx
    push    edi
    mov     [esp+14h], edx
    mov     [esp+18h], edx
    mov     [esp+1Ch], edx
    jnz     short loc_433622
    xor     esi, esi
    jmp     short loc_43362A
    ; ---------------------------------------------------------------------------

    loc_433622:                             ; CODE XREF: .text:0043361Cj
    mov     esi, [ebp+8]
    sub     esi, ecx
    sar     esi, 4

    loc_43362A:                             ; CODE XREF: .text:00433620j
    cmp     esi, eax
    jnb     short loc_43364F
    cmp     ecx, edx
    jz      short loc_43363A
    mov     edx, [ebp+8]
    sub     edx, ecx
    sar     edx, 4

    loc_43363A:                             ; CODE XREF: .text:00433630j
    lea     ecx, [esp+10h]
    sub     eax, edx
    mov     edx, [ebp+8]
    push    ecx
    push    eax
    push    edx
    mov     ecx, ebp
    call    sub_433DB0
    jmp     short loc_43369B
    ; ---------------------------------------------------------------------------

    loc_43364F:                             ; CODE XREF: .text:0043362Cj
    cmp     ecx, edx
    jz      short loc_43365B
    mov     edx, [ebp+8]
    sub     edx, ecx
    sar     edx, 4

    loc_43365B:                             ; CODE XREF: .text:00433651j
    cmp     eax, edx
    jnb     short loc_43369B
    mov     edi, [ebp+8]
    shl     eax, 4
    add     eax, ecx
    cmp     edi, edi
    mov     ebx, eax
    mov     esi, edi
    jz      short loc_433681

    loc_43366F:                             ; CODE XREF: .text:0043367Fj
    push    esi
    mov     ecx, ebx
    call    sub_4345E0
    add     esi, 10h
    add     ebx, 10h
    cmp     esi, edi
    jnz     short loc_43366F

    loc_433681:                             ; CODE XREF: .text:0043366Dj
    mov     edi, [ebp+8]
    mov     esi, ebx
    cmp     ebx, edi
    jz      short loc_433698

    loc_43368A:                             ; CODE XREF: .text:00433696j
    mov     ecx, esi
    call    sub_433A30
    add     esi, 10h
    cmp     esi, edi
    jnz     short loc_43368A

    loc_433698:                             ; CODE XREF: .text:00433688j
    mov     [ebp+8], ebx

    loc_43369B:                             ; CODE XREF: .text:0043364Dj
                                            ; .text:0043365Dj
    mov     eax, [esp+14h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+4]
    push    eax
    mov     [esp+8], eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4336F0 proc near                    ; CODE XREF: sub_433380+10Dp
                                            ; sub_433380+129p ...

    var_224= dword ptr -224h
    var_220= byte ptr -220h
    var_200= byte ptr -200h
    arg_0= dword ptr  4
    arg_4= word ptr  8
    arg_8= word ptr  0Ch

    movsx   eax, [esp+arg_4]
    sub     esp, 224h
    inc     eax
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    push    eax
    lea     ecx, [esp+238h+var_220]
    push    offset aLineD                   ; "line%d"
    push    ecx
    call    _sprintf
    mov     ecx, [esp+240h+arg_0]
    add     esp, 0Ch
    lea     edx, [esp+234h+var_220]
    lea     eax, [esp+234h+var_200]
    mov     ecx, [ecx+4]
    push    offset Data                     ; int
    push    200h                            ; size_t
    push    edx                             ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jz      loc_433957
    lea     edx, [esp+234h+var_200]
    push    offset asc_504A00               ; char *
    push    edx                             ; char *
    call    _strtok
    add     esp, 8
    test    eax, eax
    jz      loc_433994                      ; default
    push    eax                             ; char *
    call    _atoi
    mov     edi, eax
    mov     eax, [esi+4]
    add     esp, 4
    test    eax, eax
    movsx   ebp, di
    jnz     short loc_433773
    xor     ecx, ecx
    jmp     short loc_43377B
    ; ---------------------------------------------------------------------------

    loc_433773:                             ; CODE XREF: sub_4336F0+7Dj
    mov     ecx, [esi+8]
    sub     ecx, eax
    sar     ecx, 2

    loc_43377B:                             ; CODE XREF: sub_4336F0+81j
    cmp     ecx, ebp
    jnb     short loc_4337A6
    test    eax, eax
    jnz     short loc_433787
    xor     ecx, ecx
    jmp     short loc_43378F
    ; ---------------------------------------------------------------------------

    loc_433787:                             ; CODE XREF: sub_4336F0+91j
    mov     ecx, [esi+8]
    sub     ecx, eax
    sar     ecx, 2

    loc_43378F:                             ; CODE XREF: sub_4336F0+95j
    lea     eax, [esp+234h+var_224]
    mov     edx, ebp
    push    eax
    mov     eax, [esi+8]
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_433B20
    jmp     short loc_4337C3
    ; ---------------------------------------------------------------------------

    loc_4337A6:                             ; CODE XREF: sub_4336F0+8Dj
    mov     ecx, esi
    call    sub_433A60
    cmp     ebp, eax
    jnb     short loc_4337C3
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    push    ecx
    mov     ecx, esi
    lea     edx, [eax+ebp*4]
    push    edx
    call    sub_433D50

    loc_4337C3:                             ; CODE XREF: sub_4336F0+B4j
                                            ; sub_4336F0+BFj
    movsx   eax, [esp+234h+arg_8]           ; switch 4 cases
    cmp     eax, 3
    ja      loc_433994                      ; default
    jmp     ds:off_4339A4[eax*4]            ; switch jump

    loc_4337DB:                             ; DATA XREF: .text:004339A4o
    test    di, di                          ; case 0x0
    jle     loc_433994                      ; default
    xor     edi, edi

    loc_4337E6:                             ; CODE XREF: sub_4336F0+13Bj
    push    offset asc_504A00               ; char *
    push    0                               ; char *
    call    _strtok
    mov     ebx, [esi+4]
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    mov     [ebx+edi], ax
    push    offset asc_504A00               ; char *
    push    0                               ; char *
    call    _strtok
    mov     ebx, [esi+4]
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    neg     eax
    mov     [ebx+edi+2], ax
    add     esp, 4
    add     edi, 4
    dec     ebp
    jnz     short loc_4337E6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 224h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43383A:                             ; CODE XREF: sub_4336F0+E4j
                                            ; DATA XREF: .text:004339A4o
    test    di, di                          ; case 0x1
    jle     loc_433994                      ; default
    xor     edi, edi

    loc_433845:                             ; CODE XREF: sub_4336F0+198j
    push    offset asc_504A00               ; char *
    push    0                               ; char *
    call    _strtok
    mov     ebx, [esi+4]
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    mov     [ebx+edi+2], ax
    push    offset asc_504A00               ; char *
    push    0                               ; char *
    call    _strtok
    mov     ebx, [esi+4]
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    mov     [ebx+edi], ax
    add     esp, 4
    add     edi, 4
    dec     ebp
    jnz     short loc_433845
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 224h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_433897:                             ; CODE XREF: sub_4336F0+E4j
                                            ; DATA XREF: .text:004339A4o
    test    di, di                          ; case 0x2
    jle     loc_433994                      ; default
    xor     edi, edi

    loc_4338A2:                             ; CODE XREF: sub_4336F0+1F7j
    push    offset asc_504A00               ; char *
    push    0                               ; char *
    call    _strtok
    mov     ebx, [esi+4]
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    neg     eax
    push    offset asc_504A00               ; char *
    push    0                               ; char *
    mov     [ebx+edi], ax
    call    _strtok
    mov     ebx, [esi+4]
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    mov     [ebx+edi+2], ax
    add     esp, 4
    add     edi, 4
    dec     ebp
    jnz     short loc_4338A2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 224h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4338F6:                             ; CODE XREF: sub_4336F0+E4j
                                            ; DATA XREF: .text:004339A4o
    test    di, di                          ; case 0x3
    jle     loc_433994                      ; default
    xor     edi, edi

    loc_433901:                             ; CODE XREF: sub_4336F0+258j
    push    offset asc_504A00               ; char *
    push    0                               ; char *
    call    _strtok
    mov     ebx, [esi+4]
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    neg     eax
    push    offset asc_504A00               ; char *
    push    0                               ; char *
    mov     [ebx+edi+2], ax
    call    _strtok
    mov     ebx, [esi+4]
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    neg     eax
    mov     [ebx+edi], ax
    add     esp, 4
    add     edi, 4
    dec     ebp
    jnz     short loc_433901
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 224h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_433957:                             ; CODE XREF: sub_4336F0+4Aj
    mov     edi, [esi+4]
    test    edi, edi
    jnz     short loc_433962
    xor     eax, eax
    jmp     short loc_43396A
    ; ---------------------------------------------------------------------------

    loc_433962:                             ; CODE XREF: sub_4336F0+26Cj
    mov     eax, [esi+8]
    sub     eax, edi
    sar     eax, 2

    loc_43396A:                             ; CODE XREF: sub_4336F0+270j
    test    eax, eax
    jbe     short loc_433994                ; default
    mov     ecx, [esi+8]
    cmp     ecx, ecx
    mov     eax, ecx
    jz      short loc_433985

    loc_433977:                             ; CODE XREF: sub_4336F0+293j
    mov     edx, [eax]
    add     eax, 4
    mov     [edi], edx
    add     edi, 4
    cmp     eax, ecx
    jnz     short loc_433977

    loc_433985:                             ; CODE XREF: sub_4336F0+285j
    mov     eax, [esi+8]
    mov     ecx, esi
    push    eax
    push    edi
    call    nullsub_8
    mov     [esi+8], edi

    loc_433994:                             ; CODE XREF: sub_4336F0+64j
                                            ; sub_4336F0+DEj ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 224h
    retn    0Ch
    sub_4336F0 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4339A4 dd offset loc_4337DB         ; DATA XREF: sub_4336F0+E4r
    dd offset loc_43383A                    ; jump table for switch statement
    dd offset loc_433897
    dd offset loc_4338F6
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4339C0 proc near                    ; CODE XREF: sub_481930+16Ap
                                            ; sub_481D50+15Cp ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_4339CA
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_4339CA:                             ; CODE XREF: sub_4339C0+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_4339C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4339E0 proc near                    ; CODE XREF: sub_481930+1A7p
                                            ; sub_481D50+199p ...

    arg_0= word ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    movsx   eax, [esp+arg_0]
    mov     ecx, [ecx+4]
    mov     dx, [ecx+eax*4]
    lea     eax, [ecx+eax*4]
    mov     ecx, [esp+arg_4]
    mov     [ecx], dx
    mov     dx, [eax+2]
    mov     eax, [esp+arg_8]
    mov     [eax], dx
    retn    0Ch
    sub_4339E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433A10 proc near                    ; CODE XREF: sub_433380+6Dp

    arg_0= dword ptr  4

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     dl, [ecx]
    xor     ecx, ecx
    mov     [eax], dl
    mov     [eax+4], ecx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ecx
    retn    4
    sub_433A10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433A30 proc near                    ; CODE XREF: sub_433380+CAp
                                            ; .text:0043368Cp ...

    var_4= dword ptr -4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+4]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    pop     esi
    pop     ecx
    retn
    sub_433A30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433A60 proc near                    ; CODE XREF: sub_4336F0+B8p
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_433A6A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_433A6A:                             ; CODE XREF: sub_433A60+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_433A60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433A80 proc near                    ; CODE XREF: .text:00433311p
                                            ; sub_4340F0+108p

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebp, ebp
    mov     [esp+14h+var_4], edi
    mov     eax, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, eax
    mov     [esp+14h+var_8], eax
    jz      short loc_433AD9
    push    ebx

    loc_433A9D:                             ; CODE XREF: sub_433A80+52j
    mov     ebx, [esi+8]
    mov     edi, [esi+4]
    cmp     edi, ebx
    jz      short loc_433AB4

    loc_433AA7:                             ; CODE XREF: sub_433A80+32j
    push    edi
    call    nullsub_9
    add     edi, 4
    cmp     edi, ebx
    jnz     short loc_433AA7

    loc_433AB4:                             ; CODE XREF: sub_433A80+25j
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+1Ch+var_8]
    mov     [esi+4], ebp
    mov     [esi+8], ebp
    mov     [esi+0Ch], ebp
    add     esi, 10h
    add     esp, 4
    cmp     esi, eax
    jnz     short loc_433A9D
    mov     edi, [esp+18h+var_4]
    pop     ebx

    loc_433AD9:                             ; CODE XREF: sub_433A80+1Aj
    mov     ecx, [edi+4]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    mov     [edi+4], ebp
    mov     [edi+8], ebp
    mov     [edi+0Ch], ebp
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 8
    retn
    sub_433A80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433B00 proc near                    ; CODE XREF: sub_433380+7Ap
                                            ; sub_433380+91p ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_433B0A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_433B0A:                             ; CODE XREF: sub_433B00+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 4
    retn
    sub_433B00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433B20 proc near                    ; CODE XREF: sub_4336F0+AFp

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ebp, [esp+10h+arg_4]
    mov     ecx, [ebx+8]
    mov     eax, [ebx+0Ch]
    sub     eax, ecx
    push    esi
    sar     eax, 2
    cmp     eax, ebp
    push    edi
    mov     [esp+18h+var_8], ebx
    jnb     loc_433C63
    mov     edx, [ebx+4]
    test    edx, edx
    jnz     short loc_433B4F
    xor     eax, eax
    jmp     short loc_433B56
    ; ---------------------------------------------------------------------------

    loc_433B4F:                             ; CODE XREF: sub_433B20+29j
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2

    loc_433B56:                             ; CODE XREF: sub_433B20+2Dj
    cmp     ebp, eax
    jnb     short loc_433B6B
    test    edx, edx
    jnz     short loc_433B62
    xor     eax, eax
    jmp     short loc_433B6D
    ; ---------------------------------------------------------------------------

    loc_433B62:                             ; CODE XREF: sub_433B20+3Cj
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2
    jmp     short loc_433B6D
    ; ---------------------------------------------------------------------------

    loc_433B6B:                             ; CODE XREF: sub_433B20+38j
    mov     eax, ebp

    loc_433B6D:                             ; CODE XREF: sub_433B20+40j
                                            ; sub_433B20+49j
    test    edx, edx
    jnz     short loc_433B75
    xor     ecx, ecx
    jmp     short loc_433B7A
    ; ---------------------------------------------------------------------------

    loc_433B75:                             ; CODE XREF: sub_433B20+4Fj
    sub     ecx, edx
    sar     ecx, 2

    loc_433B7A:                             ; CODE XREF: sub_433B20+53j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_433B86
    xor     eax, eax

    loc_433B86:                             ; CODE XREF: sub_433B20+62j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebx+4]
    mov     ebx, [esp+1Ch+arg_0]
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_433BB9

    loc_433BA7:                             ; CODE XREF: sub_433B20+97j
    test    edx, edx
    jz      short loc_433BAF
    mov     ecx, [eax]
    mov     [edx], ecx

    loc_433BAF:                             ; CODE XREF: sub_433B20+89j
    add     eax, 4
    add     edx, 4
    cmp     eax, ebx
    jnz     short loc_433BA7

    loc_433BB9:                             ; CODE XREF: sub_433B20+85j
    test    ebp, ebp
    mov     eax, edx
    jbe     short loc_433BD3
    mov     esi, [esp+18h+arg_8]
    mov     ecx, ebp

    loc_433BC5:                             ; CODE XREF: sub_433B20+B1j
    test    eax, eax
    jz      short loc_433BCD
    mov     edi, [esi]
    mov     [eax], edi

    loc_433BCD:                             ; CODE XREF: sub_433B20+A7j
    add     eax, 4
    dec     ecx
    jnz     short loc_433BC5

    loc_433BD3:                             ; CODE XREF: sub_433B20+9Dj
    mov     eax, [esp+18h+var_8]
    lea     edi, ds:0[ebp*4]
    mov     esi, [eax+8]
    lea     ecx, [edx+edi]
    cmp     ebx, esi
    jz      short loc_433C02
    mov     eax, ecx
    sub     eax, edx
    add     eax, ebx
    sub     eax, edi

    loc_433BF0:                             ; CODE XREF: sub_433B20+E0j
    test    ecx, ecx
    jz      short loc_433BF8
    mov     edx, [eax]
    mov     [ecx], edx

    loc_433BF8:                             ; CODE XREF: sub_433B20+D2j
    add     eax, 4
    add     ecx, 4
    cmp     eax, esi
    jnz     short loc_433BF0

    loc_433C02:                             ; CODE XREF: sub_433B20+C6j
    mov     eax, [esp+18h+var_8]
    mov     eax, [eax+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     esi, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+var_4]
    mov     edx, [esp+1Ch+var_8]
    add     esp, 4
    lea     eax, [esi+ecx*4]
    mov     ecx, [edx+4]
    mov     [edx+0Ch], eax
    test    ecx, ecx
    jnz     short loc_433C46
    xor     eax, eax
    mov     [edx+4], esi
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_433C46:                             ; CODE XREF: sub_433B20+10Dj
    mov     eax, [edx+8]
    mov     [edx+4], esi
    sub     eax, ecx
    sar     eax, 2
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_433C63:                             ; CODE XREF: sub_433B20+1Ej
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, esi
    sar     edx, 2
    cmp     edx, ebp
    jnb     short loc_433CDD
    lea     edi, ds:0[ebp*4]
    cmp     esi, ecx
    lea     edx, [esi+edi]
    jz      short loc_433C9A
    mov     eax, edx
    sub     eax, edi

    loc_433C84:                             ; CODE XREF: sub_433B20+178j
    test    edx, edx
    jz      short loc_433C90
    mov     ebx, [eax]
    mov     [edx], ebx
    mov     ebx, [esp+18h+var_8]

    loc_433C90:                             ; CODE XREF: sub_433B20+166j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_433C84

    loc_433C9A:                             ; CODE XREF: sub_433B20+15Ej
    mov     eax, [ebx+8]
    mov     edx, [esp+18h+arg_8]
    mov     ecx, eax
    sub     ecx, esi
    sar     ecx, 2
    sub     ebp, ecx
    mov     ecx, ebp
    jz      short loc_433CBC

    loc_433CAE:                             ; CODE XREF: sub_433B20+19Aj
    test    eax, eax
    jz      short loc_433CB6
    mov     ebp, [edx]
    mov     [eax], ebp

    loc_433CB6:                             ; CODE XREF: sub_433B20+190j
    add     eax, 4
    dec     ecx
    jnz     short loc_433CAE

    loc_433CBC:                             ; CODE XREF: sub_433B20+18Cj
    mov     ecx, [ebx+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_433D36

    loc_433CC5:                             ; CODE XREF: sub_433B20+1AEj
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_433CC5
    add     [ebx+8], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_433CDD:                             ; CODE XREF: sub_433B20+150j
    test    ebp, ebp
    jbe     short loc_433D39
    lea     edi, ds:0[ebp*4]
    mov     eax, ecx
    sub     eax, edi
    mov     edx, ecx
    cmp     eax, ecx
    jz      short loc_433D04

    loc_433CF2:                             ; CODE XREF: sub_433B20+1E2j
    test    edx, edx
    jz      short loc_433CFA
    mov     ebp, [eax]
    mov     [edx], ebp

    loc_433CFA:                             ; CODE XREF: sub_433B20+1D4j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_433CF2

    loc_433D04:                             ; CODE XREF: sub_433B20+1D0j
    mov     ecx, [ebx+8]
    mov     eax, ecx
    sub     eax, edi
    cmp     esi, eax
    jz      short loc_433D1E

    loc_433D0F:                             ; CODE XREF: sub_433B20+1FCj
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, esi
    mov     [ecx], edx
    jnz     short loc_433D0F

    loc_433D1E:                             ; CODE XREF: sub_433B20+1EDj
    lea     ecx, [esi+edi]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_433D36
    mov     edx, [esp+18h+arg_8]

    loc_433D2B:                             ; CODE XREF: sub_433B20+214j
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_433D2B

    loc_433D36:                             ; CODE XREF: sub_433B20+1A3j
                                            ; sub_433B20+205j
    add     [ebx+8], edi

    loc_433D39:                             ; CODE XREF: sub_433B20+1BFj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_433B20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433D50 proc near                    ; CODE XREF: sub_4336F0+CEp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    mov     eax, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     esi, eax
    cmp     edx, edi
    jz      short loc_433D73
    push    ebx

    loc_433D64:                             ; CODE XREF: sub_433D50+20j
    mov     ebx, [edx]
    add     edx, 4
    mov     [esi], ebx
    add     esi, 4
    cmp     edx, edi
    jnz     short loc_433D64
    pop     ebx

    loc_433D73:                             ; CODE XREF: sub_433D50+11j
    mov     edx, [ecx+8]
    mov     [ecx+8], esi
    pop     edi
    mov     [esp+4+arg_0], edx
    pop     esi
    retn    8
    sub_433D50 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_8. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000010 BYTES: COLLAPSED FUNCTION sub_433DA0. PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_433DB0 proc near                    ; CODE XREF: sub_433380+A0p
                                            ; .text:00433648p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    mov     eax, [ecx+0Ch]
    push    ebx
    mov     edx, [esp+10h+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     [esp+1Ch+var_C], ecx
    sub     eax, edi
    sar     eax, 4
    cmp     eax, edx
    jnb     loc_433F0E
    mov     ecx, [ecx+4]
    test    ecx, ecx
    jnz     short loc_433DDD
    xor     eax, eax
    jmp     short loc_433DE4
    ; ---------------------------------------------------------------------------

    loc_433DDD:                             ; CODE XREF: sub_433DB0+27j
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 4

    loc_433DE4:                             ; CODE XREF: sub_433DB0+2Bj
    cmp     edx, eax
    jnb     short loc_433DF9
    test    ecx, ecx
    jnz     short loc_433DF0
    xor     eax, eax
    jmp     short loc_433DFB
    ; ---------------------------------------------------------------------------

    loc_433DF0:                             ; CODE XREF: sub_433DB0+3Aj
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 4
    jmp     short loc_433DFB
    ; ---------------------------------------------------------------------------

    loc_433DF9:                             ; CODE XREF: sub_433DB0+36j
    mov     eax, edx

    loc_433DFB:                             ; CODE XREF: sub_433DB0+3Ej
                                            ; sub_433DB0+47j
    test    ecx, ecx
    jnz     short loc_433E03
    xor     edi, edi
    jmp     short loc_433E08
    ; ---------------------------------------------------------------------------

    loc_433E03:                             ; CODE XREF: sub_433DB0+4Dj
    sub     edi, ecx
    sar     edi, 4

    loc_433E08:                             ; CODE XREF: sub_433DB0+51j
    add     eax, edi
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_433E14
    xor     eax, eax

    loc_433E14:                             ; CODE XREF: sub_433DB0+60j
    shl     eax, 4
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+20h+var_C]
    add     esp, 4
    mov     [esp+1Ch+var_4], eax
    mov     ebx, eax
    mov     esi, [ecx+4]
    mov     ecx, [esp+1Ch+arg_0]
    cmp     esi, ecx
    jz      short loc_433E4F

    loc_433E35:                             ; CODE XREF: sub_433DB0+9Dj
    test    ebx, ebx
    jz      short loc_433E41
    push    esi
    mov     ecx, ebx
    call    sub_434470

    loc_433E41:                             ; CODE XREF: sub_433DB0+87j
    mov     ecx, [esp+1Ch+arg_0]
    add     esi, 10h
    add     ebx, 10h
    cmp     esi, ecx
    jnz     short loc_433E35

    loc_433E4F:                             ; CODE XREF: sub_433DB0+83j
    mov     eax, [esp+1Ch+arg_4]
    mov     esi, ebx
    test    eax, eax
    jbe     short loc_433E79
    mov     ebp, [esp+1Ch+arg_8]
    mov     edi, eax

    loc_433E5F:                             ; CODE XREF: sub_433DB0+BFj
    test    esi, esi
    jz      short loc_433E6B
    push    ebp
    mov     ecx, esi
    call    sub_434470

    loc_433E6B:                             ; CODE XREF: sub_433DB0+B1j
    add     esi, 10h
    dec     edi
    jnz     short loc_433E5F
    mov     eax, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+arg_0]

    loc_433E79:                             ; CODE XREF: sub_433DB0+A7j
    mov     edx, [esp+1Ch+var_C]
    shl     eax, 4
    mov     ebp, [edx+8]
    cmp     ecx, ebp
    lea     edi, [ebx+eax]
    jz      short loc_433EA8
    mov     esi, edi
    sub     esi, ebx
    add     esi, ecx
    sub     esi, eax

    loc_433E92:                             ; CODE XREF: sub_433DB0+F6j
    test    edi, edi
    jz      short loc_433E9E
    push    esi
    mov     ecx, edi
    call    sub_434470

    loc_433E9E:                             ; CODE XREF: sub_433DB0+E4j
    add     esi, 10h
    add     edi, 10h
    cmp     esi, ebp
    jnz     short loc_433E92

    loc_433EA8:                             ; CODE XREF: sub_433DB0+D8j
    mov     edi, [esp+1Ch+var_C]
    mov     ebx, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, ebx
    jz      short loc_433EC4

    loc_433EB6:                             ; CODE XREF: sub_433DB0+112j
    mov     ecx, esi
    call    sub_433A30
    add     esi, 10h
    cmp     esi, ebx
    jnz     short loc_433EB6

    loc_433EC4:                             ; CODE XREF: sub_433DB0+104j
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+20h+var_8]
    mov     edx, [esp+20h+var_4]
    mov     ecx, [edi+4]
    add     esp, 4
    shl     eax, 4
    add     eax, edx
    test    ecx, ecx
    mov     [edi+0Ch], eax
    jnz     short loc_433EEB
    xor     eax, eax
    jmp     short loc_433EF3
    ; ---------------------------------------------------------------------------

    loc_433EEB:                             ; CODE XREF: sub_433DB0+135j
    mov     eax, [edi+8]
    sub     eax, ecx
    sar     eax, 4

    loc_433EF3:                             ; CODE XREF: sub_433DB0+139j
    mov     ecx, [esp+1Ch+arg_4]
    mov     [edi+4], edx
    add     ecx, eax
    shl     ecx, 4
    add     ecx, edx
    mov     [edi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_433F0E:                             ; CODE XREF: sub_433DB0+1Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     eax, edi
    sub     eax, ebp
    sar     eax, 4
    cmp     eax, edx
    jnb     short loc_433F98
    mov     eax, edx
    shl     eax, 4
    cmp     ebp, edi
    mov     [esp+1Ch+arg_0], eax
    lea     ebx, [ebp+eax+0]
    jz      short loc_433F50
    mov     esi, ebx
    sub     esi, eax

    loc_433F32:                             ; CODE XREF: sub_433DB0+19Aj
    test    ebx, ebx
    jz      short loc_433F42
    push    esi
    mov     ecx, ebx
    call    sub_434470
    mov     edx, [esp+1Ch+arg_4]

    loc_433F42:                             ; CODE XREF: sub_433DB0+184j
    add     esi, 10h
    add     ebx, 10h
    cmp     esi, edi
    jnz     short loc_433F32
    mov     ecx, [esp+1Ch+var_C]

    loc_433F50:                             ; CODE XREF: sub_433DB0+17Cj
    mov     esi, [ecx+8]
    mov     ebx, [esp+1Ch+arg_8]
    mov     eax, esi
    sub     eax, ebp
    sar     eax, 4
    sub     edx, eax
    jz      short loc_433F7A
    mov     edi, edx

    loc_433F64:                             ; CODE XREF: sub_433DB0+1C4j
    test    esi, esi
    jz      short loc_433F70
    push    ebx
    mov     ecx, esi
    call    sub_434470

    loc_433F70:                             ; CODE XREF: sub_433DB0+1B6j
    add     esi, 10h
    dec     edi
    jnz     short loc_433F64
    mov     ecx, [esp+1Ch+var_C]

    loc_433F7A:                             ; CODE XREF: sub_433DB0+1B0j
    mov     edi, [ecx+8]
    mov     esi, ebp
    cmp     ebp, edi
    jz      loc_434009

    loc_433F87:                             ; CODE XREF: sub_433DB0+1E4j
    push    ebx
    mov     ecx, esi
    call    sub_4345E0
    add     esi, 10h
    cmp     esi, edi
    jnz     short loc_433F87
    jmp     short loc_434009
    ; ---------------------------------------------------------------------------

    loc_433F98:                             ; CODE XREF: sub_433DB0+16Bj
    test    edx, edx
    jbe     short loc_434014
    shl     edx, 4
    mov     esi, edi
    mov     ebx, edi
    sub     esi, edx
    mov     [esp+1Ch+arg_0], edx
    cmp     esi, edi
    jz      short loc_433FCB

    loc_433FAD:                             ; CODE XREF: sub_433DB0+211j
    test    ebx, ebx
    jz      short loc_433FB9
    push    esi
    mov     ecx, ebx
    call    sub_434470

    loc_433FB9:                             ; CODE XREF: sub_433DB0+1FFj
    add     esi, 10h
    add     ebx, 10h
    cmp     esi, edi
    jnz     short loc_433FAD
    mov     ecx, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]

    loc_433FCB:                             ; CODE XREF: sub_433DB0+1FBj
    mov     edi, [ecx+8]
    mov     esi, edi
    sub     esi, edx
    cmp     ebp, esi
    jz      short loc_433FE8

    loc_433FD6:                             ; CODE XREF: sub_433DB0+236j
    sub     esi, 10h
    sub     edi, 10h
    push    esi
    mov     ecx, edi
    call    sub_4345E0
    cmp     esi, ebp
    jnz     short loc_433FD6

    loc_433FE8:                             ; CODE XREF: sub_433DB0+224j
    mov     edx, [esp+1Ch+arg_0]
    mov     esi, ebp
    lea     edi, [ebp+edx+0]
    cmp     ebp, edi
    jz      short loc_434009
    mov     ebx, [esp+1Ch+arg_8]

    loc_433FFA:                             ; CODE XREF: sub_433DB0+257j
    push    ebx
    mov     ecx, esi
    call    sub_4345E0
    add     esi, 10h
    cmp     esi, edi
    jnz     short loc_433FFA

    loc_434009:                             ; CODE XREF: sub_433DB0+1D1j
                                            ; sub_433DB0+1E6j ...
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, [esp+1Ch+arg_0]
    add     [eax+8], ecx

    loc_434014:                             ; CODE XREF: sub_433DB0+1EAj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_433DB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434020 proc near                    ; CODE XREF: sub_433380+C1p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch+arg_0]
    mov     ebx, ecx
    push    esi
    mov     esi, [esp+10h+arg_4]
    push    edi
    mov     edi, [ebx+8]
    cmp     esi, edi
    mov     [esp+14h+var_4], ebx
    jz      short loc_43404C

    loc_43403A:                             ; CODE XREF: sub_434020+2Aj
    push    esi
    mov     ecx, ebp
    call    sub_4345E0
    add     esi, 10h
    add     ebp, 10h
    cmp     esi, edi
    jnz     short loc_43403A

    loc_43404C:                             ; CODE XREF: sub_434020+18j
    mov     eax, [ebx+8]
    cmp     ebp, eax
    mov     [esp+14h+arg_4], eax
    jz      short loc_434097
    lea     esi, [ebp+4]

    loc_43405A:                             ; CODE XREF: sub_434020+71j
    mov     ebx, [esi+4]
    mov     edi, [esi]
    cmp     edi, ebx
    jz      short loc_434070

    loc_434063:                             ; CODE XREF: sub_434020+4Ej
    push    edi
    call    nullsub_9
    add     edi, 4
    cmp     edi, ebx
    jnz     short loc_434063

    loc_434070:                             ; CODE XREF: sub_434020+41j
    mov     eax, [esi]
    push    eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     [esi], eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     eax, [esp+14h+arg_4]
    add     esi, 10h
    lea     ecx, [esi-4]
    cmp     ecx, eax
    jnz     short loc_43405A
    mov     ebx, [esp+14h+var_4]

    loc_434097:                             ; CODE XREF: sub_434020+35j
    mov     eax, [esp+14h+arg_0]
    pop     edi
    mov     [ebx+8], ebp
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_434020 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4340B0 proc near                    ; CODE XREF: sub_433130+F2p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    cmp     esi, ebx
    jz      short loc_4340E2
    push    edi
    xor     edi, edi

    loc_4340C1:                             ; CODE XREF: sub_4340B0+2Fj
    mov     eax, [esi+4]
    push    eax
    mov     [esp+0Ch+arg_0], eax
    call    sub_4B4F20
    mov     [esi+4], edi
    mov     [esi+8], edi
    mov     [esi+0Ch], edi
    add     esi, 10h
    add     esp, 4
    cmp     esi, ebx
    jnz     short loc_4340C1
    pop     edi

    loc_4340E2:                             ; CODE XREF: sub_4340B0+Cj
    pop     esi
    pop     ebx
    retn    8
    sub_4340B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4340F0 proc near                    ; CODE XREF: sub_433130+B8p
                                            ; .text:004332C9p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    mov     eax, [ecx+0Ch]
    push    ebx
    mov     edx, [esp+10h+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     [esp+1Ch+var_C], ecx
    sub     eax, edi
    sar     eax, 4
    cmp     eax, edx
    jnb     loc_43424E
    mov     ecx, [ecx+4]
    test    ecx, ecx
    jnz     short loc_43411D
    xor     eax, eax
    jmp     short loc_434124
    ; ---------------------------------------------------------------------------

    loc_43411D:                             ; CODE XREF: sub_4340F0+27j
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 4

    loc_434124:                             ; CODE XREF: sub_4340F0+2Bj
    cmp     edx, eax
    jnb     short loc_434139
    test    ecx, ecx
    jnz     short loc_434130
    xor     eax, eax
    jmp     short loc_43413B
    ; ---------------------------------------------------------------------------

    loc_434130:                             ; CODE XREF: sub_4340F0+3Aj
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 4
    jmp     short loc_43413B
    ; ---------------------------------------------------------------------------

    loc_434139:                             ; CODE XREF: sub_4340F0+36j
    mov     eax, edx

    loc_43413B:                             ; CODE XREF: sub_4340F0+3Ej
                                            ; sub_4340F0+47j
    test    ecx, ecx
    jnz     short loc_434143
    xor     edi, edi
    jmp     short loc_434148
    ; ---------------------------------------------------------------------------

    loc_434143:                             ; CODE XREF: sub_4340F0+4Dj
    sub     edi, ecx
    sar     edi, 4

    loc_434148:                             ; CODE XREF: sub_4340F0+51j
    add     eax, edi
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_434154
    xor     eax, eax

    loc_434154:                             ; CODE XREF: sub_4340F0+60j
    shl     eax, 4
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+20h+var_C]
    add     esp, 4
    mov     [esp+1Ch+var_4], eax
    mov     ebx, eax
    mov     esi, [ecx+4]
    mov     ecx, [esp+1Ch+arg_0]
    cmp     esi, ecx
    jz      short loc_43418F

    loc_434175:                             ; CODE XREF: sub_4340F0+9Dj
    test    ebx, ebx
    jz      short loc_434181
    push    esi
    mov     ecx, ebx
    call    sub_4344E0

    loc_434181:                             ; CODE XREF: sub_4340F0+87j
    mov     ecx, [esp+1Ch+arg_0]
    add     esi, 10h
    add     ebx, 10h
    cmp     esi, ecx
    jnz     short loc_434175

    loc_43418F:                             ; CODE XREF: sub_4340F0+83j
    mov     eax, [esp+1Ch+arg_4]
    mov     esi, ebx
    test    eax, eax
    jbe     short loc_4341B9
    mov     ebp, [esp+1Ch+arg_8]
    mov     edi, eax

    loc_43419F:                             ; CODE XREF: sub_4340F0+BFj
    test    esi, esi
    jz      short loc_4341AB
    push    ebp
    mov     ecx, esi
    call    sub_4344E0

    loc_4341AB:                             ; CODE XREF: sub_4340F0+B1j
    add     esi, 10h
    dec     edi
    jnz     short loc_43419F
    mov     eax, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+arg_0]

    loc_4341B9:                             ; CODE XREF: sub_4340F0+A7j
    mov     edx, [esp+1Ch+var_C]
    shl     eax, 4
    mov     ebp, [edx+8]
    cmp     ecx, ebp
    lea     edi, [ebx+eax]
    jz      short loc_4341E8
    mov     esi, edi
    sub     esi, ebx
    add     esi, ecx
    sub     esi, eax

    loc_4341D2:                             ; CODE XREF: sub_4340F0+F6j
    test    edi, edi
    jz      short loc_4341DE
    push    esi
    mov     ecx, edi
    call    sub_4344E0

    loc_4341DE:                             ; CODE XREF: sub_4340F0+E4j
    add     esi, 10h
    add     edi, 10h
    cmp     esi, ebp
    jnz     short loc_4341D2

    loc_4341E8:                             ; CODE XREF: sub_4340F0+D8j
    mov     edi, [esp+1Ch+var_C]
    mov     ebx, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, ebx
    jz      short loc_434204

    loc_4341F6:                             ; CODE XREF: sub_4340F0+112j
    mov     ecx, esi
    call    sub_433A80
    add     esi, 10h
    cmp     esi, ebx
    jnz     short loc_4341F6

    loc_434204:                             ; CODE XREF: sub_4340F0+104j
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+20h+var_8]
    mov     edx, [esp+20h+var_4]
    mov     ecx, [edi+4]
    add     esp, 4
    shl     eax, 4
    add     eax, edx
    test    ecx, ecx
    mov     [edi+0Ch], eax
    jnz     short loc_43422B
    xor     eax, eax
    jmp     short loc_434233
    ; ---------------------------------------------------------------------------

    loc_43422B:                             ; CODE XREF: sub_4340F0+135j
    mov     eax, [edi+8]
    sub     eax, ecx
    sar     eax, 4

    loc_434233:                             ; CODE XREF: sub_4340F0+139j
    mov     ecx, [esp+1Ch+arg_4]
    mov     [edi+4], edx
    add     ecx, eax
    shl     ecx, 4
    add     ecx, edx
    mov     [edi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43424E:                             ; CODE XREF: sub_4340F0+1Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     eax, edi
    sub     eax, ebp
    sar     eax, 4
    cmp     eax, edx
    jnb     short loc_4342D8
    mov     eax, edx
    shl     eax, 4
    cmp     ebp, edi
    mov     [esp+1Ch+arg_0], eax
    lea     ebx, [ebp+eax+0]
    jz      short loc_434290
    mov     esi, ebx
    sub     esi, eax

    loc_434272:                             ; CODE XREF: sub_4340F0+19Aj
    test    ebx, ebx
    jz      short loc_434282
    push    esi
    mov     ecx, ebx
    call    sub_4344E0
    mov     edx, [esp+1Ch+arg_4]

    loc_434282:                             ; CODE XREF: sub_4340F0+184j
    add     esi, 10h
    add     ebx, 10h
    cmp     esi, edi
    jnz     short loc_434272
    mov     ecx, [esp+1Ch+var_C]

    loc_434290:                             ; CODE XREF: sub_4340F0+17Cj
    mov     esi, [ecx+8]
    mov     ebx, [esp+1Ch+arg_8]
    mov     eax, esi
    sub     eax, ebp
    sar     eax, 4
    sub     edx, eax
    jz      short loc_4342BA
    mov     edi, edx

    loc_4342A4:                             ; CODE XREF: sub_4340F0+1C4j
    test    esi, esi
    jz      short loc_4342B0
    push    ebx
    mov     ecx, esi
    call    sub_4344E0

    loc_4342B0:                             ; CODE XREF: sub_4340F0+1B6j
    add     esi, 10h
    dec     edi
    jnz     short loc_4342A4
    mov     ecx, [esp+1Ch+var_C]

    loc_4342BA:                             ; CODE XREF: sub_4340F0+1B0j
    mov     edi, [ecx+8]
    mov     esi, ebp
    cmp     ebp, edi
    jz      loc_434349

    loc_4342C7:                             ; CODE XREF: sub_4340F0+1E4j
    push    ebx
    mov     ecx, esi
    call    sub_434770
    add     esi, 10h
    cmp     esi, edi
    jnz     short loc_4342C7
    jmp     short loc_434349
    ; ---------------------------------------------------------------------------

    loc_4342D8:                             ; CODE XREF: sub_4340F0+16Bj
    test    edx, edx
    jbe     short loc_434354
    shl     edx, 4
    mov     esi, edi
    mov     ebx, edi
    sub     esi, edx
    mov     [esp+1Ch+arg_0], edx
    cmp     esi, edi
    jz      short loc_43430B

    loc_4342ED:                             ; CODE XREF: sub_4340F0+211j
    test    ebx, ebx
    jz      short loc_4342F9
    push    esi
    mov     ecx, ebx
    call    sub_4344E0

    loc_4342F9:                             ; CODE XREF: sub_4340F0+1FFj
    add     esi, 10h
    add     ebx, 10h
    cmp     esi, edi
    jnz     short loc_4342ED
    mov     ecx, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]

    loc_43430B:                             ; CODE XREF: sub_4340F0+1FBj
    mov     edi, [ecx+8]
    mov     esi, edi
    sub     esi, edx
    cmp     ebp, esi
    jz      short loc_434328

    loc_434316:                             ; CODE XREF: sub_4340F0+236j
    sub     esi, 10h
    sub     edi, 10h
    push    esi
    mov     ecx, edi
    call    sub_434770
    cmp     esi, ebp
    jnz     short loc_434316

    loc_434328:                             ; CODE XREF: sub_4340F0+224j
    mov     edx, [esp+1Ch+arg_0]
    mov     esi, ebp
    lea     edi, [ebp+edx+0]
    cmp     ebp, edi
    jz      short loc_434349
    mov     ebx, [esp+1Ch+arg_8]

    loc_43433A:                             ; CODE XREF: sub_4340F0+257j
    push    ebx
    mov     ecx, esi
    call    sub_434770
    add     esi, 10h
    cmp     esi, edi
    jnz     short loc_43433A

    loc_434349:                             ; CODE XREF: sub_4340F0+1D1j
                                            ; sub_4340F0+1E6j ...
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, [esp+1Ch+arg_0]
    add     [eax+8], ecx

    loc_434354:                             ; CODE XREF: sub_4340F0+1EAj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_4340F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434360 proc near                    ; CODE XREF: sub_433130+DFp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch+arg_0]
    mov     ebx, ecx
    push    esi
    mov     esi, [esp+10h+arg_4]
    push    edi
    mov     edi, [ebx+8]
    cmp     esi, edi
    mov     [esp+14h+var_4], ebx
    jz      short loc_43438C

    loc_43437A:                             ; CODE XREF: sub_434360+2Aj
    push    esi
    mov     ecx, ebp
    call    sub_434770
    add     esi, 10h
    add     ebp, 10h
    cmp     esi, edi
    jnz     short loc_43437A

    loc_43438C:                             ; CODE XREF: sub_434360+18j
    mov     eax, [ebx+8]
    cmp     ebp, eax
    mov     [esp+14h+arg_4], eax
    jz      short loc_4343D7
    lea     esi, [ebp+4]

    loc_43439A:                             ; CODE XREF: sub_434360+71j
    mov     ebx, [esi+4]
    mov     edi, [esi]
    cmp     edi, ebx
    jz      short loc_4343B0

    loc_4343A3:                             ; CODE XREF: sub_434360+4Ej
    push    edi
    call    sub_434440
    add     edi, 10h
    cmp     edi, ebx
    jnz     short loc_4343A3

    loc_4343B0:                             ; CODE XREF: sub_434360+41j
    mov     eax, [esi]
    push    eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     [esi], eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     eax, [esp+14h+arg_4]
    add     esi, 10h
    lea     ecx, [esi-4]
    cmp     ecx, eax
    jnz     short loc_43439A
    mov     ebx, [esp+14h+var_4]

    loc_4343D7:                             ; CODE XREF: sub_434360+35j
    mov     eax, [esp+14h+arg_0]
    pop     edi
    mov     [ebx+8], ebp
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_434360 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_43. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434400 proc near                    ; CODE XREF: .text:004330DAp

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    mov     eax, [esi+4]
    push    eax
    mov     [esp+4+arg_0], eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    pop     esi
    retn    4
    sub_434400 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_9. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434440 proc near                    ; CODE XREF: sub_434360+44p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    mov     eax, [esi+4]
    push    eax
    mov     [esp+4+arg_0], eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    pop     esi
    retn    4
    sub_434440 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434470 proc near                    ; CODE XREF: sub_433DB0+8Cp
                                            ; sub_433DB0+B6p ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, ecx
    mov     al, [esi]
    mov     [edi], al
    mov     ecx, [esi+4]
    test    ecx, ecx
    jnz     short loc_434487
    xor     eax, eax
    jmp     short loc_43448F
    ; ---------------------------------------------------------------------------

    loc_434487:                             ; CODE XREF: sub_434470+11j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_43448F:                             ; CODE XREF: sub_434470+15j
    test    eax, eax
    jge     short loc_434495
    xor     eax, eax

    loc_434495:                             ; CODE XREF: sub_434470+21j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [edi+4], eax
    mov     edx, [esi+8]
    mov     ecx, [esi+4]
    add     esp, 4
    cmp     ecx, edx
    jz      short loc_4344C4

    loc_4344B2:                             ; CODE XREF: sub_434470+52j
    test    eax, eax
    jz      short loc_4344BA
    mov     esi, [ecx]
    mov     [eax], esi

    loc_4344BA:                             ; CODE XREF: sub_434470+44j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_4344B2

    loc_4344C4:                             ; CODE XREF: sub_434470+40j
    mov     [edi+8], eax
    mov     [edi+0Ch], eax
    mov     eax, edi
    pop     edi
    pop     esi
    retn    4
    sub_434470 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4344E0 proc near                    ; CODE XREF: sub_4340F0+8Cp
                                            ; sub_4340F0+B6p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+18h+arg_0]
    mov     ebp, ecx
    mov     [esp+18h+var_8], ebp
    mov     al, [edi]
    mov     [ebp+0], al
    mov     ecx, [edi+4]
    test    ecx, ecx
    jnz     short loc_434501
    xor     eax, eax
    jmp     short loc_434509
    ; ---------------------------------------------------------------------------

    loc_434501:                             ; CODE XREF: sub_4344E0+1Bj
    mov     eax, [edi+8]
    sub     eax, ecx
    sar     eax, 4

    loc_434509:                             ; CODE XREF: sub_4344E0+1Fj
    test    eax, eax
    jge     short loc_43450F
    xor     eax, eax

    loc_43450F:                             ; CODE XREF: sub_4344E0+2Bj
    shl     eax, 4
    push    eax                             ; int
    call    sub_4B4F10
    mov     [ebp+4], eax
    mov     ecx, [edi+8]
    mov     edi, [edi+4]
    add     esp, 4
    mov     esi, eax
    cmp     edi, ecx
    mov     [esp+18h+var_4], ecx
    mov     [esp+18h+arg_0], esi
    jz      short loc_4345AA
    lea     ebx, [edi+4]

    loc_434535:                             ; CODE XREF: sub_4344E0+C8j
    test    esi, esi
    jz      short loc_434599
    mov     cl, [ebx-4]
    mov     [esi], cl
    mov     ecx, [ebx]
    test    ecx, ecx
    jnz     short loc_434548
    xor     eax, eax
    jmp     short loc_434550
    ; ---------------------------------------------------------------------------

    loc_434548:                             ; CODE XREF: sub_4344E0+62j
    mov     eax, [ebx+4]
    sub     eax, ecx
    sar     eax, 2

    loc_434550:                             ; CODE XREF: sub_4344E0+66j
    test    eax, eax
    jge     short loc_434556
    xor     eax, eax

    loc_434556:                             ; CODE XREF: sub_4344E0+72j
    lea     edx, ds:0[eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    mov     [esi+4], eax
    mov     ebp, [ebx+4]
    mov     esi, [ebx]
    add     esp, 4
    cmp     esi, ebp
    mov     edi, eax
    jz      short loc_434585

    loc_434574:                             ; CODE XREF: sub_4344E0+A3j
    push    esi
    push    edi
    call    sub_4345C0
    add     esi, 4
    add     edi, 4
    cmp     esi, ebp
    jnz     short loc_434574

    loc_434585:                             ; CODE XREF: sub_4344E0+92j
    mov     eax, [esp+18h+arg_0]
    mov     ebp, [esp+18h+var_8]
    mov     ecx, [esp+18h+var_4]
    mov     esi, eax
    mov     [eax+8], edi
    mov     [eax+0Ch], edi

    loc_434599:                             ; CODE XREF: sub_4344E0+57j
    add     ebx, 10h
    add     esi, 10h
    mov     [esp+18h+arg_0], esi
    lea     eax, [ebx-4]
    cmp     eax, ecx
    jnz     short loc_434535

    loc_4345AA:                             ; CODE XREF: sub_4344E0+50j
    mov     [ebp+8], esi
    mov     [ebp+0Ch], esi
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_4344E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4345C0 proc near                    ; CODE XREF: sub_4344E0+96p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short locret_4345D0
    mov     ecx, [esp+arg_4]
    mov     edx, [ecx]
    mov     [eax], edx

    locret_4345D0:                          ; CODE XREF: sub_4345C0+6j
    retn    8
    sub_4345C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4345E0 proc near                    ; CODE XREF: .text:00433672p
                                            ; sub_433DB0+1DAp ...

    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     ebx, ecx
    cmp     ebx, edi
    jz      loc_43475A
    mov     eax, [edi+4]
    test    eax, eax
    jnz     short loc_4345FC
    xor     esi, esi
    jmp     short loc_434604
    ; ---------------------------------------------------------------------------

    loc_4345FC:                             ; CODE XREF: sub_4345E0+16j
    mov     esi, [edi+8]
    sub     esi, eax
    sar     esi, 2

    loc_434604:                             ; CODE XREF: sub_4345E0+1Aj
    mov     edx, [ebx+4]
    test    edx, edx
    jnz     short loc_43460F
    xor     ecx, ecx
    jmp     short loc_434617
    ; ---------------------------------------------------------------------------

    loc_43460F:                             ; CODE XREF: sub_4345E0+29j
    mov     ecx, [ebx+8]
    sub     ecx, edx
    sar     ecx, 2

    loc_434617:                             ; CODE XREF: sub_4345E0+2Dj
    cmp     esi, ecx
    ja      short loc_434665
    mov     esi, [edi+8]
    mov     ecx, edx
    cmp     eax, esi
    jz      short loc_434632

    loc_434624:                             ; CODE XREF: sub_4345E0+50j
    mov     edx, [eax]
    add     eax, 4
    mov     [ecx], edx
    add     ecx, 4
    cmp     eax, esi
    jnz     short loc_434624

    loc_434632:                             ; CODE XREF: sub_4345E0+42j
    mov     ecx, [edi+4]
    test    ecx, ecx
    jnz     short loc_43464C
    mov     ecx, [ebx+4]
    xor     eax, eax
    lea     edx, [ecx+eax*4]
    mov     eax, ebx
    mov     [ebx+8], edx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43464C:                             ; CODE XREF: sub_4345E0+57j
    mov     eax, [edi+8]
    sub     eax, ecx
    mov     ecx, [ebx+4]
    sar     eax, 2
    lea     edx, [ecx+eax*4]
    mov     eax, ebx
    mov     [ebx+8], edx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_434665:                             ; CODE XREF: sub_4345E0+39j
    test    eax, eax
    jnz     short loc_43466D
    xor     esi, esi
    jmp     short loc_434675
    ; ---------------------------------------------------------------------------

    loc_43466D:                             ; CODE XREF: sub_4345E0+87j
    mov     esi, [edi+8]
    sub     esi, eax
    sar     esi, 2

    loc_434675:                             ; CODE XREF: sub_4345E0+8Bj
    test    edx, edx
    jnz     short loc_43467D
    xor     ecx, ecx
    jmp     short loc_434685
    ; ---------------------------------------------------------------------------

    loc_43467D:                             ; CODE XREF: sub_4345E0+97j
    mov     ecx, [ebx+0Ch]
    sub     ecx, edx
    sar     ecx, 2

    loc_434685:                             ; CODE XREF: sub_4345E0+9Bj
    cmp     esi, ecx
    ja      short loc_4346FF
    test    edx, edx
    jnz     short loc_434691
    xor     ecx, ecx
    jmp     short loc_434699
    ; ---------------------------------------------------------------------------

    loc_434691:                             ; CODE XREF: sub_4345E0+ABj
    mov     ecx, [ebx+8]
    sub     ecx, edx
    sar     ecx, 2

    loc_434699:                             ; CODE XREF: sub_4345E0+AFj
    lea     ecx, [eax+ecx*4]
    cmp     eax, ecx
    jz      short loc_4346AE

    loc_4346A0:                             ; CODE XREF: sub_4345E0+CCj
    mov     esi, [eax]
    add     eax, 4
    mov     [edx], esi
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_4346A0

    loc_4346AE:                             ; CODE XREF: sub_4345E0+BEj
    mov     esi, [edi+8]
    mov     edx, [ebx+8]
    cmp     ecx, esi
    mov     eax, ecx
    jz      short loc_4346CC

    loc_4346BA:                             ; CODE XREF: sub_4345E0+EAj
    test    edx, edx
    jz      short loc_4346C2
    mov     ecx, [eax]
    mov     [edx], ecx

    loc_4346C2:                             ; CODE XREF: sub_4345E0+DCj
    add     eax, 4
    add     edx, 4
    cmp     eax, esi
    jnz     short loc_4346BA

    loc_4346CC:                             ; CODE XREF: sub_4345E0+D8j
    mov     ecx, [edi+4]
    test    ecx, ecx
    jnz     short loc_4346E6
    mov     edx, [ebx+4]
    xor     eax, eax
    lea     eax, [edx+eax*4]
    mov     [ebx+8], eax
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4346E6:                             ; CODE XREF: sub_4345E0+F1j
    mov     eax, [edi+8]
    mov     edx, [ebx+4]
    sub     eax, ecx
    sar     eax, 2
    lea     eax, [edx+eax*4]
    mov     [ebx+8], eax
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4346FF:                             ; CODE XREF: sub_4345E0+A7j
    push    edx
    mov     [esp+4+arg_0], edx
    call    sub_4B4F20
    mov     ecx, [edi+4]
    add     esp, 4
    test    ecx, ecx
    jnz     short loc_434717
    xor     eax, eax
    jmp     short loc_43471F
    ; ---------------------------------------------------------------------------

    loc_434717:                             ; CODE XREF: sub_4345E0+131j
    mov     eax, [edi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_43471F:                             ; CODE XREF: sub_4345E0+135j
    test    eax, eax
    jge     short loc_434725
    xor     eax, eax

    loc_434725:                             ; CODE XREF: sub_4345E0+141j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [ebx+4], eax
    mov     edx, [edi+8]
    mov     ecx, [edi+4]
    add     esp, 4
    cmp     ecx, edx
    jz      short loc_434754

    loc_434742:                             ; CODE XREF: sub_4345E0+172j
    test    eax, eax
    jz      short loc_43474A
    mov     esi, [ecx]
    mov     [eax], esi

    loc_43474A:                             ; CODE XREF: sub_4345E0+164j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_434742

    loc_434754:                             ; CODE XREF: sub_4345E0+160j
    mov     [ebx+8], eax
    mov     [ebx+0Ch], eax

    loc_43475A:                             ; CODE XREF: sub_4345E0+Bj
    pop     edi
    mov     eax, ebx
    pop     esi
    pop     ebx
    retn    4
    sub_4345E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434770 proc near                    ; CODE XREF: .text:004332F7p
                                            ; sub_4340F0+1DAp ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch+arg_0]
    mov     edx, ecx
    push    esi
    cmp     edx, ebp
    push    edi
    mov     [esp+14h+var_4], edx
    jz      loc_4349B0
    mov     esi, [ebp+4]
    test    esi, esi
    jnz     short loc_434792
    xor     ecx, ecx
    jmp     short loc_43479A
    ; ---------------------------------------------------------------------------

    loc_434792:                             ; CODE XREF: sub_434770+1Cj
    mov     ecx, [ebp+8]
    sub     ecx, esi
    sar     ecx, 4

    loc_43479A:                             ; CODE XREF: sub_434770+20j
    mov     edi, [edx+4]
    test    edi, edi
    jnz     short loc_4347A5
    xor     eax, eax
    jmp     short loc_4347AD
    ; ---------------------------------------------------------------------------

    loc_4347A5:                             ; CODE XREF: sub_434770+2Fj
    mov     eax, [edx+8]
    sub     eax, edi
    sar     eax, 4

    loc_4347AD:                             ; CODE XREF: sub_434770+33j
    cmp     ecx, eax
    ja      short loc_434826
    mov     ebx, [ebp+8]
    cmp     esi, ebx
    jz      short loc_4347CE

    loc_4347B8:                             ; CODE XREF: sub_434770+58j
    push    esi
    mov     ecx, edi
    call    sub_4345E0
    add     esi, 10h
    add     edi, 10h
    cmp     esi, ebx
    jnz     short loc_4347B8
    mov     edx, [esp+14h+var_4]

    loc_4347CE:                             ; CODE XREF: sub_434770+46j
    mov     ebx, [edx+8]
    mov     esi, edi
    cmp     edi, ebx
    jz      short loc_4347EB

    loc_4347D7:                             ; CODE XREF: sub_434770+75j
    push    0
    mov     ecx, esi
    call    sub_4349F0
    add     esi, 10h
    cmp     esi, ebx
    jnz     short loc_4347D7
    mov     edx, [esp+14h+var_4]

    loc_4347EB:                             ; CODE XREF: sub_434770+65j
    mov     ecx, [ebp+4]
    test    ecx, ecx
    jnz     short loc_434809
    mov     ecx, [edx+4]
    xor     eax, eax
    shl     eax, 4
    add     eax, ecx
    mov     [edx+8], eax
    mov     eax, edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_434809:                             ; CODE XREF: sub_434770+80j
    mov     eax, [ebp+8]
    sub     eax, ecx
    mov     ecx, [edx+4]
    sar     eax, 4
    shl     eax, 4
    add     eax, ecx
    mov     [edx+8], eax
    mov     eax, edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_434826:                             ; CODE XREF: sub_434770+3Fj
    test    esi, esi
    jnz     short loc_43482E
    xor     ecx, ecx
    jmp     short loc_434836
    ; ---------------------------------------------------------------------------

    loc_43482E:                             ; CODE XREF: sub_434770+B8j
    mov     ecx, [ebp+8]
    sub     ecx, esi
    sar     ecx, 4

    loc_434836:                             ; CODE XREF: sub_434770+BCj
    test    edi, edi
    jnz     short loc_43483E
    xor     eax, eax
    jmp     short loc_434846
    ; ---------------------------------------------------------------------------

    loc_43483E:                             ; CODE XREF: sub_434770+C8j
    mov     eax, [edx+0Ch]
    sub     eax, edi
    sar     eax, 4

    loc_434846:                             ; CODE XREF: sub_434770+CCj
    cmp     ecx, eax
    ja      loc_4348EA
    test    edi, edi
    jnz     short loc_434856
    xor     ebx, ebx
    jmp     short loc_43485E
    ; ---------------------------------------------------------------------------

    loc_434856:                             ; CODE XREF: sub_434770+E0j
    mov     ebx, [edx+8]
    sub     ebx, edi
    sar     ebx, 4

    loc_43485E:                             ; CODE XREF: sub_434770+E4j
    shl     ebx, 4
    add     ebx, esi
    cmp     esi, ebx
    jz      short loc_434879

    loc_434867:                             ; CODE XREF: sub_434770+107j
    push    esi
    mov     ecx, edi
    call    sub_4345E0
    add     esi, 10h
    add     edi, 10h
    cmp     esi, ebx
    jnz     short loc_434867

    loc_434879:                             ; CODE XREF: sub_434770+F5j
    mov     ebp, [ebp+8]
    mov     edx, [esp+14h+var_4]
    cmp     ebx, ebp
    mov     esi, ebx
    mov     edi, [edx+8]
    jz      short loc_4348A3

    loc_434889:                             ; CODE XREF: sub_434770+12Dj
    test    edi, edi
    jz      short loc_434895
    push    esi
    mov     ecx, edi
    call    sub_434470

    loc_434895:                             ; CODE XREF: sub_434770+11Bj
    add     esi, 10h
    add     edi, 10h
    cmp     esi, ebp
    jnz     short loc_434889
    mov     edx, [esp+14h+var_4]

    loc_4348A3:                             ; CODE XREF: sub_434770+117j
    mov     eax, [esp+14h+arg_0]
    mov     ecx, [eax+4]
    test    ecx, ecx
    jnz     short loc_4348C9
    mov     ecx, [edx+4]
    xor     eax, eax
    shl     eax, 4
    add     eax, ecx
    mov     [edx+8], eax
    mov     edx, [esp+14h+var_4]
    mov     eax, edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4348C9:                             ; CODE XREF: sub_434770+13Cj
    mov     eax, [eax+8]
    sub     eax, ecx
    mov     ecx, [edx+4]
    sar     eax, 4
    shl     eax, 4
    add     eax, ecx
    mov     [edx+8], eax
    mov     edx, [esp+14h+var_4]
    mov     eax, edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4348EA:                             ; CODE XREF: sub_434770+D8j
    mov     ebx, [edx+8]
    mov     esi, edi
    cmp     esi, ebx
    jz      short loc_434905

    loc_4348F3:                             ; CODE XREF: sub_434770+18Fj
    mov     ecx, esi
    call    sub_433A30
    add     esi, 10h
    cmp     esi, ebx
    jnz     short loc_4348F3
    mov     edx, [esp+14h+var_4]

    loc_434905:                             ; CODE XREF: sub_434770+181j
    mov     eax, [edx+4]
    push    eax
    call    sub_4B4F20
    mov     ecx, [ebp+4]
    add     esp, 4
    test    ecx, ecx
    jnz     short loc_43491C
    xor     eax, eax
    jmp     short loc_434924
    ; ---------------------------------------------------------------------------

    loc_43491C:                             ; CODE XREF: sub_434770+1A6j
    mov     eax, [ebp+8]
    sub     eax, ecx
    sar     eax, 4

    loc_434924:                             ; CODE XREF: sub_434770+1AAj
    test    eax, eax
    jge     short loc_43492A
    xor     eax, eax

    loc_43492A:                             ; CODE XREF: sub_434770+1B6j
    shl     eax, 4
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+18h+var_4]
    add     esp, 4
    mov     esi, eax
    mov     [ecx+4], eax
    mov     ebx, [ebp+8]
    mov     edi, [ebp+4]
    cmp     edi, ebx
    jz      short loc_4349A6
    add     edi, 4

    loc_43494C:                             ; CODE XREF: sub_434770+230j
    test    esi, esi
    jz      short loc_434995
    mov     al, [edi-4]
    mov     [esi], al
    mov     ecx, [edi]
    test    ecx, ecx
    jnz     short loc_43495F
    xor     eax, eax
    jmp     short loc_434967
    ; ---------------------------------------------------------------------------

    loc_43495F:                             ; CODE XREF: sub_434770+1E9j
    mov     eax, [edi+4]
    sub     eax, ecx
    sar     eax, 2

    loc_434967:                             ; CODE XREF: sub_434770+1EDj
    test    eax, eax
    jge     short loc_43496D
    xor     eax, eax

    loc_43496D:                             ; CODE XREF: sub_434770+1F9j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+4], eax
    mov     edx, [edi+4]
    mov     ecx, [edi]
    push    eax
    push    edx
    push    ecx
    mov     ecx, esi
    call    sub_4349C0
    mov     [esi+8], eax
    mov     [esi+0Ch], eax

    loc_434995:                             ; CODE XREF: sub_434770+1DEj
    add     edi, 10h
    add     esi, 10h
    lea     eax, [edi-4]
    cmp     eax, ebx
    jnz     short loc_43494C
    mov     ecx, [esp+14h+var_4]

    loc_4349A6:                             ; CODE XREF: sub_434770+1D7j
    mov     edx, [esp+14h+var_4]
    mov     [ecx+8], esi
    mov     [ecx+0Ch], esi

    loc_4349B0:                             ; CODE XREF: sub_434770+11j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, edx
    pop     ebx
    pop     ecx
    retn    4
    sub_434770 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4349C0 proc near                    ; CODE XREF: sub_434770+21Ap

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_4349E7
    mov     eax, [esp+arg_8]
    push    esi

    loc_4349D1:                             ; CODE XREF: sub_4349C0+21j
    test    eax, eax
    jz      short loc_4349D9
    mov     esi, [ecx]
    mov     [eax], esi

    loc_4349D9:                             ; CODE XREF: sub_4349C0+13j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_4349D1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4349E7:                             ; CODE XREF: sub_4349C0+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_4349C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4349F0 proc near                    ; CODE XREF: sub_434770+6Bp

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+4]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    mov     al, [esp+8+arg_0]
    test    al, 1
    jz      short loc_434A20
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_434A20:                             ; CODE XREF: sub_4349F0+25j
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_4349F0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    mov     al, [esp+3]
    push    offset loc_434A60
    mov     byte_5122C0, al
    xor     eax, eax
    mov     dword_5122C4, eax
    mov     dword_5122C8, eax
    mov     dword_5122CC, eax
    call    _atexit
    add     esp, 4
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    loc_434A60:                             ; DATA XREF: .text:00434A35o
    push    esi
    mov     esi, dword_5122C4
    push    edi
    mov     edi, dword_5122C8
    cmp     esi, edi
    jz      short loc_434A86

    loc_434A72:                             ; CODE XREF: .text:00434A7Ej
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_434A72
    mov     esi, dword_5122C4

    loc_434A86:                             ; CODE XREF: .text:00434A70j
    push    esi
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     dword_5122C4, eax
    mov     dword_5122C8, eax
    pop     edi
    mov     dword_5122CC, eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434AB0 proc near                    ; CODE XREF: sub_41EC50+3A5p
                                            ; .text:0042696Cp ...

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    xor     ebx, ebx
    mov     esi, [eax+391E9h]
    push    edi
    mov     edi, [esp+0Ch+arg_0]
    cmp     esi, ebx
    jz      short loc_434AE4
    cmp     [esi], edi
    jz      loc_434B7E
    cmp     esi, ebx
    jz      short loc_434AE4
    mov     ecx, esi
    call    sub_434FF0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_434AE4:                             ; CODE XREF: sub_434AB0+16j
                                            ; sub_434AB0+22j
    push    0EC4h                           ; int
    call    sub_4B4F10
    mov     esi, eax
    add     esp, 4
    cmp     esi, ebx
    jz      short loc_434B70
    lea     ecx, [esi+0A08h]
    call    sub_4C2EA0
    push    offset Data
    mov     ecx, esi
    mov     [esi+0DB8h], ebx
    mov     [esi+0DB0h], ebx
    mov     [esi+0DC0h], ebx
    mov     [esi+0DB4h], ebx
    mov     [esi+0DACh], ebx
    mov     [esi+0DBCh], ebx
    mov     [esi+0A04h], ebx
    mov     [esi+0D24h], ebx
    mov     [esi+0D28h], ebx
    mov     [esi+0D2Ch], ebx
    mov     [esi+0C14h], ebx
    mov     [esi+0A14h], bl
    mov     [esi+0B14h], bl
    mov     [esi], edi
    call    sub_435110
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+391E9h], esi
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_434B70:                             ; CODE XREF: sub_434AB0+45j
    mov     ecx, TAdynmemStructPtr
    xor     esi, esi
    mov     [ecx+391E9h], esi

    loc_434B7E:                             ; CODE XREF: sub_434AB0+1Aj
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_434AB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434B90 proc near                    ; CODE XREF: sub_4916A0+11Fp
    mov     eax, dword_5122D4
    push    esi
    push    edi
    xor     edi, edi
    cmp     eax, edi
    jz      short loc_434BAC
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword_5122D4, edi

    loc_434BAC:                             ; CODE XREF: sub_434B90+Bj
    mov     eax, TAdynmemStructPtr
    mov     dword_5122D8, edi
    mov     dword_5122DC, edi
    mov     dword_5122E0, edi
    mov     esi, [eax+391E9h]
    cmp     esi, edi
    jz      short loc_434BDD
    mov     ecx, esi
    call    sub_434FF0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_434BDD:                             ; CODE XREF: sub_434B90+3Bj
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+391E9h], edi
    pop     edi
    pop     esi
    retn
    sub_434B90 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434BF0 proc near                    ; CODE XREF: sub_434BF0+339p
                                            ; sub_435D30+43p ...

    var_329= byte ptr -329h
    var_328= dword ptr -328h
    var_324= dword ptr -324h
    var_320= dword ptr -320h
    var_31C= dword ptr -31Ch
    var_318= dword ptr -318h
    var_314= dword ptr -314h
    var_310= dword ptr -310h
    var_30C= dword ptr -30Ch
    var_300= dword ptr -300h
    MultiByteStr= byte ptr -200h
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, dword_5122D4
    sub     esp, 32Ch
    push    ebp
    xor     ebp, ebp
    push    esi
    cmp     eax, ebp
    push    edi
    jz      short loc_434C7B
    mov     esi, [esp+338h+arg_0]
    cmp     esi, ebp
    jz      short loc_434C6A
    cmp     [esp+338h+arg_8], ebp
    jz      short loc_434C39
    cmp     dword_5122D8, ebp
    jnz     short loc_434C39
    mov     [esi], eax
    mov     eax, dword_5122E0
    mov     dword_5122D4, ebp
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 32Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_434C39:                             ; CODE XREF: sub_434BF0+26j
                                            ; sub_434BF0+2Ej
    mov     eax, dword_5122DC
    push    eax
    push    offset aMultiMaps               ; "MULTI MAPS"
    call    sub_4D83B0
    mov     [esi], eax
    mov     ecx, dword_5122DC
    mov     esi, dword_5122D4
    mov     edx, ecx
    mov     edi, eax
    add     esp, 8
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_434C6A:                             ; CODE XREF: sub_434BF0+1Dj
    mov     eax, dword_5122E0
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 32Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_434C7B:                             ; CODE XREF: sub_434BF0+12j
    push    ebx
    push    14h
    call    sub_491C80
    mov     eax, 1
    cmp     [esp+33Ch+arg_4], ebp
    jnz     short loc_434CA6
    mov     ecx, TAdynmemStructPtr
    mov     [esp+33Ch+var_324], eax
    mov     edx, [ecx+391E9h]
    cmp     dword ptr [edx], 3
    jz      short loc_434CAA

    loc_434CA6:                             ; CODE XREF: sub_434BF0+9Fj
    mov     [esp+33Ch+var_324], ebp

    loc_434CAA:                             ; CODE XREF: sub_434BF0+B4j
    push    eax
    push    offset aMultiMaps               ; "MULTI MAPS"
    xor     ebx, ebx
    mov     dword_5122DC, eax
    call    sub_4D83B0
    add     esp, 8
    lea     ecx, [esp+33Ch+var_31C]
    mov     dword_5122D4, eax
    mov     [eax], bl
    mov     al, [esp+33Ch+var_329]
    push    ecx
    push    ebp
    push    offset aMaps_ota                ; "Maps\\*.ota"
    mov     byte ptr [esp+348h+var_31C], al
    mov     [esp+348h+var_318], ebp
    mov     [esp+348h+var_314], ebp
    mov     [esp+348h+var_310], ebp
    call    sub_4BCA30
    mov     dword_5122E0, ebp
    mov     eax, [esp+33Ch+var_318]
    cmp     eax, ebp
    jnz     short loc_434CFE
    mov     [esp+33Ch+var_328], ebp
    jmp     short loc_434D0B
    ; ---------------------------------------------------------------------------

    loc_434CFE:                             ; CODE XREF: sub_434BF0+106j
    mov     ecx, [esp+33Ch+var_314]
    sub     ecx, eax
    sar     ecx, 2
    mov     [esp+33Ch+var_328], ecx

    loc_434D0B:                             ; CODE XREF: sub_434BF0+10Cj
    mov     ecx, [esp+33Ch+var_328]
    xor     edi, edi
    cmp     ecx, ebp
    mov     [esp+33Ch+var_320], edi
    jle     loc_434EEE
    jmp     short loc_434D23
    ; ---------------------------------------------------------------------------

    loc_434D1F:                             ; CODE XREF: sub_434BF0+2EBj
    mov     eax, [esp+33Ch+var_318]

    loc_434D23:                             ; CODE XREF: sub_434BF0+12Dj
    mov     edx, [eax+edi*4]
    lea     esi, ds:0[edi*4]
    push    offset off_504A14
    push    edx
    lea     eax, [esp+344h+var_100]
    push    offset aMaps                    ; "Maps"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+33Ch+var_30C]
    call    sub_4C2EA0
    lea     ecx, [esp+33Ch+var_100]
    push    ecx
    lea     ecx, [esp+340h+var_30C]
    call    sub_4C2F60
    test    eax, eax
    jz      loc_434EA9
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+33Ch+var_30C]
    push    ebp
    push    edx
    mov     ecx, [eax+391E9h]
    push    3
    call    sub_436860
    test    eax, eax
    jz      loc_434EA9
    mov     eax, [esp+33Ch+var_318]
    or      ecx, 0FFFFFFFFh
    lea     edx, [esp+33Ch+var_300]
    mov     edi, [eax+esi]
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+33Ch+var_300]
    push    ecx
    call    sub_4BB0F0
    lea     edi, [esp+33Ch+var_300]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+33Ch+MultiByteStr]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+33Ch+MultiByteStr]
    push    ecx                             ; lpMultiByteStr
    call    sub_4E8960
    add     esp, 4
    lea     edx, [esp+33Ch+MultiByteStr]
    push    edx                             ; int
    call    sub_4C5740
    mov     esi, eax
    lea     eax, [esp+33Ch+MultiByteStr]
    push    eax                             ; char *
    push    esi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_434E19
    lea     esi, [esp+33Ch+var_300]

    loc_434E19:                             ; CODE XREF: sub_434BF0+223j
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, dword_5122D4
    mov     ebp, ecx
    mov     ecx, dword_5122DC
    inc     ebp
    lea     edx, [ebp+ecx+0]
    push    edx                             ; int
    push    offset aMultiMaps               ; int
    push    eax                             ; int
    call    Network_ReAllocPacketBuffer
    mov     dword_5122D4, eax
    lea     edx, [ebx+eax]
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    lea     eax, [ebp+ebx+0]
    and     ecx, 3
    mov     ebx, eax
    rep movsb
    mov     ecx, dword_5122D4
    mov     byte ptr [ecx+eax], 0
    mov     edx, dword_5122DC
    mov     ecx, dword_5122E0
    mov     eax, [esp+33Ch+arg_4]
    add     edx, ebp
    inc     ecx
    test    eax, eax
    mov     dword_5122DC, edx
    mov     dword_5122E0, ecx
    jnz     short loc_434EE3
    mov     edi, [esp+33Ch+var_320]
    xor     ebp, ebp

    loc_434EA9:                             ; CODE XREF: sub_434BF0+171j
                                            ; sub_434BF0+191j
    cmp     [esp+33Ch+var_324], ebp
    jz      short loc_434EC7
    call    Network_Process
    cmp     dword_506DBC, ebp
    jz      short loc_434EC7
    push    ebp
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_434EC7:                             ; CODE XREF: sub_434BF0+2BDj
                                            ; sub_434BF0+2CAj
    lea     ecx, [esp+33Ch+var_30C]
    call    sub_4C2EB0
    mov     eax, [esp+33Ch+var_328]
    inc     edi
    cmp     edi, eax
    mov     [esp+33Ch+var_320], edi
    jl      loc_434D1F
    jmp     short loc_434EEE
    ; ---------------------------------------------------------------------------

    loc_434EE3:                             ; CODE XREF: sub_434BF0+2B1j
    lea     ecx, [esp+33Ch+var_30C]
    call    sub_4C2EB0
    xor     ebp, ebp

    loc_434EEE:                             ; CODE XREF: sub_434BF0+127j
                                            ; sub_434BF0+2F1j
    push    13h
    call    sub_491C80
    cmp     dword_5122D8, ebp
    jnz     short loc_434F11
    mov     eax, [esp+33Ch+arg_4]
    xor     edx, edx
    cmp     eax, ebp
    setz    dl
    mov     dword_5122D8, edx

    loc_434F11:                             ; CODE XREF: sub_434BF0+30Bj
    mov     eax, [esp+33Ch+arg_8]
    mov     ecx, [esp+33Ch+arg_4]
    mov     edx, [esp+33Ch+arg_0]
    push    eax
    push    ecx
    push    edx
    call    sub_434BF0
    mov     edi, [esp+33Ch+var_314]
    mov     esi, [esp+33Ch+var_318]
    cmp     esi, edi
    mov     ebx, eax
    jz      short loc_434F4E

    loc_434F3C:                             ; CODE XREF: sub_434BF0+358j
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_434F3C
    mov     esi, [esp+33Ch+var_318]

    loc_434F4E:                             ; CODE XREF: sub_434BF0+34Aj
    push    esi
    call    sub_4B4F20
    add     esp, 4
    mov     eax, ebx
    pop     ebx
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 32Ch
    retn    0Ch
    sub_434BF0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, ecx
    lea     ecx, [esi+0A08h]
    call    sub_4C2EA0
    xor     eax, eax
    push    offset Data
    mov     [esi+0DB8h], eax
    mov     [esi+0DB0h], eax
    mov     [esi+0DC0h], eax
    mov     [esi+0DB4h], eax
    mov     [esi+0DACh], eax
    mov     [esi+0DBCh], eax
    mov     [esi+0A04h], eax
    mov     [esi+0D24h], eax
    mov     [esi+0D28h], eax
    mov     [esi+0D2Ch], eax
    mov     [esi+0C14h], eax
    mov     [esi+0A14h], al
    mov     [esi+0B14h], al
    mov     eax, [esp+0Ch]
    mov     ecx, esi
    mov     [esi], eax
    call    sub_435110
    mov     eax, esi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_434FF0 proc near                    ; CODE XREF: sub_434AB0+26p
                                            ; sub_434B90+3Fp
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     edi, [eax+391EDh]
    xor     ebx, ebx
    cmp     edi, ebx
    mov     esi, ecx
    jz      short loc_435022
    mov     ecx, edi
    call    sub_48DFB0
    push    edi
    call    sub_4B4F20
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     [ecx+391EDh], ebx

    loc_435022:                             ; CODE XREF: sub_434FF0+14j
    mov     eax, [esi+0DACh]
    cmp     eax, ebx
    jz      short loc_435035
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_435035:                             ; CODE XREF: sub_434FF0+3Aj
    mov     eax, [esi+0DB4h]
    mov     [esi+0DACh], ebx
    cmp     eax, ebx
    mov     [esi+0DB0h], ebx
    jz      short loc_435054
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_435054:                             ; CODE XREF: sub_434FF0+59j
    mov     eax, [esi+0DBCh]
    mov     [esi+0DB4h], ebx
    cmp     eax, ebx
    mov     [esi+0DB8h], ebx
    jz      short loc_435073
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_435073:                             ; CODE XREF: sub_434FF0+78j
    mov     eax, [esi+0C14h]
    mov     [esi+0DBCh], ebx
    cmp     eax, ebx
    mov     [esi+0DC0h], ebx
    jz      short loc_435098
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [esi+0C14h], ebx

    loc_435098:                             ; CODE XREF: sub_434FF0+97j
    mov     eax, [esi+0D24h]
    cmp     eax, ebx
    jz      short loc_4350AB
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4350AB:                             ; CODE XREF: sub_434FF0+B0j
    mov     eax, [esi+0DBCh]
    cmp     eax, ebx
    jz      short loc_4350BE
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4350BE:                             ; CODE XREF: sub_434FF0+C3j
    mov     eax, [esi+0DB4h]
    cmp     eax, ebx
    jz      short loc_4350D1
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4350D1:                             ; CODE XREF: sub_434FF0+D6j
    mov     eax, [esi+0DACh]
    cmp     eax, ebx
    jz      short loc_4350E4
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4350E4:                             ; CODE XREF: sub_434FF0+E9j
    lea     ecx, [esi+0A08h]
    call    sub_4C2EB0
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_434FF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435100 proc near                    ; CODE XREF: .text:004051AFp
                                            ; sub_40BB00+76p ...
    mov     eax, [ecx]
    retn
    sub_435100 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435110 proc near                    ; CODE XREF: .text:00426985p
                                            ; .text:00426B75p ...

    var_80= byte ptr -80h
    arg_0= dword ptr  4

    sub     esp, 80h
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    push    edi
    lea     ecx, [ebx+0A08h]
    call    sub_4C3240
    mov     edi, [esp+90h+arg_0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebx+4]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    xor     ebp, ebp
    rep movsb

    loc_435150:                             ; CODE XREF: sub_435110+A4j
    mov     ecx, ebp
    mov     edi, offset Data
    shl     ecx, 8
    xor     eax, eax
    lea     edx, [ecx+ebx+104h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    cmp     ebp, 1
    rep movsb
    jnz     short loc_4351B0
    mov     edi, offset Data
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4351A6
    push    offset Data
    call    sub_4BBC40
    mov     [ebx+0A04h], eax
    jmp     short loc_4351B0
    ; ---------------------------------------------------------------------------

    loc_4351A6:                             ; CODE XREF: sub_435110+82j
    mov     dword ptr [ebx+0A04h], 0

    loc_4351B0:                             ; CODE XREF: sub_435110+71j
                                            ; sub_435110+94j
    inc     ebp
    cmp     ebp, 9
    jl      short loc_435150
    mov     edi, [esp+90h+arg_0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_435294
    lea     eax, [ebx+4]
    push    offset off_50341C
    push    eax
    push    offset aCamps                   ; "camps"
    push    0
    mov     ecx, ebx
    call    sub_435430
    mov     edi, [esp+90h+arg_0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_43527E
    lea     esi, [ebx+104h]
    or      ecx, 0FFFFFFFFh
    mov     edi, esi
    xor     edx, edx
    repne scasb
    not     ecx
    dec     ecx
    cmp     edx, ecx
    lea     ecx, [ebx+0A08h]
    sbb     eax, eax
    and     eax, esi
    push    eax
    call    sub_4C2F60
    test    eax, eax
    jnz     short loc_43527E
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    cmp     eax, ecx
    lea     ecx, [esp+90h+var_80]
    sbb     eax, eax
    and     eax, esi
    push    eax
    push    offset aTheRequestedCa          ; LPCSTR
    push    ecx                             ; LPSTR
    call    ds:wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+90h+var_80]
    add     eax, 519h
    push    1
    push    1
    push    1E0h
    push    edx
    push    eax
    call    sub_4ABD90
    push    offset Data
    mov     ecx, ebx
    call    sub_435110
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 80h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43527E:                             ; CODE XREF: sub_435110+E5j
                                            ; sub_435110+111j
    xor     eax, eax
    mov     ecx, ebx
    push    eax
    mov     [ebx+0C1Ch], eax
    mov     [ebx+0C18h], eax
    call    sub_435DA0

    loc_435294:                             ; CODE XREF: sub_435110+B7j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 80h
    retn    4
    sub_435110 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4352B0 proc near                    ; CODE XREF: sub_4326B0+AAp
                                            ; .text:0049975Ep
    lea     edx, [ecx+4]
    push    edi
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    pop     edi
    cmp     eax, ecx
    sbb     eax, eax
    and     eax, edx
    retn
    sub_4352B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    sub     esp, 100h
    lea     ecx, [esp+0]
    push    offset off_50341C
    push    eax
    push    offset aCamps                   ; "camps"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+0]
    push    edx
    call    sub_4BB2C0
    test    eax, eax
    jz      short loc_435311
    push    eax
    call    sub_4BB5D0
    mov     eax, 1
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_435311:                             ; CODE XREF: .text:004352FBj
    xor     eax, eax
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    mov     eax, [ebx+0C14h]
    test    eax, eax
    jz      short loc_435338
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_435338:                             ; CODE XREF: .text:0043532Dj
    lea     edx, [ebx+304h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     eax, ecx
    sbb     esi, esi
    and     esi, edx
    test    esi, esi
    jnz     short loc_43535E
    mov     [ebx+0C14h], esi
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_43535E:                             ; CODE XREF: .text:00435352j
    push    esi
    call    sub_4BBC40
    mov     edi, eax
    test    edi, edi
    jz      short loc_435395
    lea     ecx, [edi+1]
    push    ecx
    push    offset aBriefing                ; "Briefing"
    call    sub_4D83B0
    add     esp, 8
    mov     [ebx+0C14h], eax
    push    edi
    push    0
    push    eax
    push    esi
    call    sub_4BBD30
    mov     edx, [ebx+0C14h]
    mov     byte ptr [edi+edx], 0

    loc_435395:                             ; CODE XREF: .text:00435368j
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4353A0 proc near                    ; CODE XREF: sub_476D80+Fp
    mov     eax, [ecx+0C14h]
    retn
    sub_4353A0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+4]
    push    ebx
    mov     eax, edx
    mov     ebx, ecx
    shl     eax, 8
    push    ebp
    mov     ebp, [esp+10h]
    push    esi
    push    edi
    lea     esi, [eax+ebx+104h]
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     [esp+14h], esi
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+14h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    cmp     edx, 1
    rep movsb
    jnz     short loc_43541F
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_435415
    push    ebp
    call    sub_4BBC40
    mov     [ebx+0A04h], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_435415:                             ; CODE XREF: .text:00435400j
    mov     dword ptr [ebx+0A04h], 0

    loc_43541F:                             ; CODE XREF: .text:004353F2j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435430 proc near                    ; CODE XREF: sub_435110+CFp
                                            ; sub_435DA0+2BDp ...

    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 100h
    xor     eax, eax
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+10Ch+arg_8]
    mov     ebx, ecx
    push    edi
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_4354C1
    mov     edx, [esp+110h+arg_0]
    mov     edi, offset Data
    mov     eax, edx
    or      ecx, 0FFFFFFFFh
    shl     eax, 8
    lea     ebp, [eax+ebx+104h]
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    cmp     edx, 1
    rep movsb
    jnz     loc_4356AF
    mov     edi, offset Data
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_4356A5
    push    offset Data
    call    sub_4BBC40
    mov     [ebx+0A04h], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4354C1:                             ; CODE XREF: sub_435430+1Fj
    call    sub_49F580
    mov     ebp, [esp+110h+arg_C]
    test    eax, eax
    jz      loc_4355C3
    mov     ecx, [esp+110h+arg_4]
    push    esi
    push    eax
    push    ecx
    lea     edx, [esp+11Ch+var_100]
    push    offset aSSS                     ; "%s-%s\\%s"
    push    edx
    call    _sprintf
    add     esp, 14h
    lea     eax, [esp+110h+var_100]
    push    eax
    call    sub_4BB0F0
    mov     edi, offset Directory
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+110h+var_100]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     edx, [esp+110h+var_100]
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     eax, [esp+110h+var_100]
    and     ecx, 3
    push    eax
    rep movsb
    call    sub_4BB5B0
    test    eax, eax
    jz      short loc_4355BC
    push    eax
    call    sub_4BB5D0
    mov     edx, [esp+110h+arg_0]
    lea     edi, [esp+110h+var_100]
    mov     ecx, edx
    xor     eax, eax
    shl     ecx, 8
    lea     ebp, [ecx+ebx+104h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    cmp     edx, 1
    rep movsb
    jnz     loc_4356AF
    lea     edi, [esp+110h+var_100]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_4356A5
    jmp     loc_435688
    ; ---------------------------------------------------------------------------

    loc_4355BC:                             ; CODE XREF: sub_435430+12Ej
    mov     esi, [esp+110h+arg_8]

    loc_4355C3:                             ; CODE XREF: sub_435430+9Fj
    mov     edx, [esp+110h+arg_4]
    push    esi
    push    edx
    lea     eax, [esp+118h+var_100]
    push    offset aSS                      ; "%s\\%s"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+110h+var_100]
    push    ecx
    call    sub_4BB0F0
    or      ecx, 0FFFFFFFFh
    mov     edi, offset Directory
    xor     eax, eax
    lea     edx, [esp+110h+var_100]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     edx, [esp+110h+var_100]
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    mov     edx, [esp+110h+arg_0]
    and     ecx, 3
    mov     eax, edx
    rep movsb
    shl     eax, 8
    lea     edi, [esp+110h+var_100]
    or      ecx, 0FFFFFFFFh
    lea     ebp, [eax+ebx+104h]
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    cmp     edx, 1
    rep movsb
    jnz     short loc_4356AF
    lea     edi, [esp+110h+var_100]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4356A5

    loc_435688:                             ; CODE XREF: sub_435430+187j
    lea     ecx, [esp+110h+var_100]
    push    ecx
    call    sub_4BBC40
    mov     [ebx+0A04h], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4356A5:                             ; CODE XREF: sub_435430+6Ej
                                            ; sub_435430+181j ...
    mov     dword ptr [ebx+0A04h], 0

    loc_4356AF:                             ; CODE XREF: sub_435430+59j
                                            ; sub_435430+16Dj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    10h
    sub_435430 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4356C0 proc near                    ; CODE XREF: sub_40C250+144p
                                            ; sub_40C250+165p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    edi
    shl     eax, 8
    lea     edx, [eax+ecx+104h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    pop     edi
    cmp     eax, ecx
    sbb     eax, eax
    and     eax, edx
    retn    4
    sub_4356C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 80h
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    edi
    lea     edi, [edx+4]
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_435710
    pop     edi
    add     esp, 80h
    retn
    ; ---------------------------------------------------------------------------

    loc_435710:                             ; CODE XREF: .text:00435706j
    push    esi
    xor     edi, edi
    lea     esi, [edx+0A08h]

    loc_435719:                             ; CODE XREF: .text:00435744j
    push    edi
    lea     eax, [esp+0Ch]
    push    offset aMissionD                ; "MISSION%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    mov     ecx, esi
    call    sub_4C3E10
    lea     ecx, [esp+8]
    push    ecx
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jz      short loc_435746
    inc     edi
    jmp     short loc_435719
    ; ---------------------------------------------------------------------------

    loc_435746:                             ; CODE XREF: .text:00435741j
    mov     eax, edi
    pop     esi
    pop     edi
    add     esp, 80h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435760 proc near                    ; CODE XREF: sub_41F0A0+1BEp
                                            ; sub_435A20+13Fp ...

    var_188= dword ptr -188h
    var_184= dword ptr -184h
    var_180= byte ptr -180h
    var_100= dword ptr -100h
    arg_0= dword ptr  4

    sub     esp, 188h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    or      ecx, 0FFFFFFFFh
    lea     edx, [esi+4]
    xor     eax, eax
    mov     edi, edx
    mov     [esp+198h+var_184], esi
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_43578E
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 188h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43578E:                             ; CODE XREF: sub_435760+1Fj
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_4357A4
    xor     esi, esi
    mov     [esp+198h+var_188], esi
    jmp     short loc_4357DF
    ; ---------------------------------------------------------------------------

    loc_4357A4:                             ; CODE XREF: sub_435760+3Aj
    xor     edi, edi
    add     esi, 0A08h

    loc_4357AC:                             ; CODE XREF: sub_435760+77j
    push    edi
    lea     eax, [esp+19Ch+var_180]
    push    offset aMissionD                ; "MISSION%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    mov     ecx, esi
    call    sub_4C3E10
    lea     ecx, [esp+198h+var_180]
    push    ecx                             ; char *
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jz      short loc_4357D9
    inc     edi
    jmp     short loc_4357AC
    ; ---------------------------------------------------------------------------

    loc_4357D9:                             ; CODE XREF: sub_435760+74j
    mov     [esp+198h+var_188], edi
    mov     esi, edi

    loc_4357DF:                             ; CODE XREF: sub_435760+42j
    test    esi, esi
    jz      loc_4358DB
    mov     edx, esi
    shl     edx, 8
    push    edx
    push    offset aMissionlist             ; "MissionList"
    call    sub_4D83B0
    mov     ebp, [esp+1A0h+arg_0]
    add     esp, 8
    xor     ebx, ebx
    mov     [ebp+0], eax
    mov     byte ptr [eax], 0
    test    esi, esi
    jle     loc_4358DB
    mov     eax, [esp+198h+var_184]
    lea     esi, [eax+0A08h]
    mov     [esp+198h+var_184], esi
    jmp     short loc_435825
    ; ---------------------------------------------------------------------------

    loc_435821:                             ; CODE XREF: sub_435760+157j
    mov     esi, [esp+198h+var_184]

    loc_435825:                             ; CODE XREF: sub_435760+BFj
    push    ebx
    lea     ecx, [esp+19Ch+var_180]
    push    offset aMissionD                ; "MISSION%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    mov     ecx, esi
    call    sub_4C3E10
    lea     edx, [esp+198h+var_180]
    mov     ecx, esi
    push    edx                             ; char *
    call    sub_4C3410
    test    eax, eax
    jz      short loc_4358CC
    push    0
    push    100h
    lea     eax, [esp+1A0h+var_100]
    push    offset aMissionname             ; "missionname"
    push    eax
    push    esi
    call    sub_4C58A0
    test    eax, eax
    jz      short loc_435882
    mov     ecx, [ebp+0]
    push    ebx
    push    ecx
    lea     edi, [esp+1A0h+var_100]
    call    sub_4B6AF0
    mov     edx, eax
    jmp     short loc_435893
    ; ---------------------------------------------------------------------------

    loc_435882:                             ; CODE XREF: sub_435760+10Bj
    mov     ecx, [ebp+0]
    push    ebx
    push    ecx
    call    sub_4B6AF0
    mov     edx, eax
    mov     edi, offset aErrorUnnamedMi     ; "Error -- Unnamed Mission"

    loc_435893:                             ; CODE XREF: sub_435760+120j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+198h+var_188]
    and     ecx, 3
    inc     ebx
    cmp     ebx, eax
    rep movsb
    jl      loc_435821
    mov     esi, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 188h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4358CC:                             ; CODE XREF: sub_435760+EDj
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 188h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4358DB:                             ; CODE XREF: sub_435760+81j
                                            ; sub_435760+ABj
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 188h
    retn    4
    sub_435760 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4358F0 proc near                    ; CODE XREF: .text:00440CDEp
                                            ; sub_447B10+646p ...
    mov     eax, [ecx+0A04h]
    retn
    sub_4358F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435900 proc near                    ; CODE XREF: sub_444A20+140p
    lea     eax, [ecx+0C24h]
    retn
    sub_435900 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435910 proc near                    ; CODE XREF: .text:0047906Bp
    lea     eax, [ecx+0CA4h]
    retn
    sub_435910 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435920 proc near                    ; CODE XREF: sub_448C70+E45p
                                            ; Battleroom_Unknown1+4EBp
    mov     eax, [ecx+0A04h]
    cmp     eax, 3E6666h
    jge     short loc_435933
    mov     eax, 10h
    retn
    ; ---------------------------------------------------------------------------

    loc_435933:                             ; CODE XREF: sub_435920+Bj
    cmp     eax, 600000h
    jge     short loc_435940
    mov     eax, 18h
    retn
    ; ---------------------------------------------------------------------------

    loc_435940:                             ; CODE XREF: sub_435920+18j
    cmp     eax, 800000h
    jge     short loc_43594D
    mov     eax, 20h
    retn
    ; ---------------------------------------------------------------------------

    loc_43594D:                             ; CODE XREF: sub_435920+25j
    cmp     eax, 0A00000h
    jge     short loc_43595A
    mov     eax, 30h
    retn
    ; ---------------------------------------------------------------------------

    loc_43595A:                             ; CODE XREF: sub_435920+32j
    xor     ecx, ecx
    cmp     eax, 0C00000h
    setnl   cl
    dec     ecx
    and     ecx, 0FFFFFFC0h
    add     ecx, 80h
    sub_435920 endp

    ; [00000003 BYTES: COLLAPSED FUNCTION Iostream_init::Iostream_init(void). PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435980 proc near                    ; CODE XREF: .text:0041F072p
                                            ; .text:0041F08Ep ...

    var_80= byte ptr -80h
    arg_0= dword ptr  4

    sub     esp, 80h
    xor     eax, eax
    push    esi
    mov     esi, ecx
    push    edi
    or      ecx, 0FFFFFFFFh
    lea     edi, [esi+4]
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_43599D
    xor     edi, edi
    jmp     short loc_4359FA
    ; ---------------------------------------------------------------------------

    loc_43599D:                             ; CODE XREF: sub_435980+17j
    xor     edi, edi
    lea     eax, [esp+88h+var_80]
    push    edi
    push    offset aMissionD                ; "MISSION%d"
    push    eax
    call    _sprintf
    add     esi, 0A08h
    add     esp, 0Ch
    mov     ecx, esi
    call    sub_4C3E10
    lea     ecx, [esp+88h+var_80]
    push    ecx                             ; char *
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jz      short loc_4359FA

    loc_4359CF:                             ; CODE XREF: sub_435980+78j
    inc     edi
    lea     edx, [esp+88h+var_80]
    push    edi
    push    offset aMissionD                ; "MISSION%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    mov     ecx, esi
    call    sub_4C3E10
    lea     eax, [esp+88h+var_80]
    mov     ecx, esi
    push    eax                             ; char *
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_4359CF

    loc_4359FA:                             ; CODE XREF: sub_435980+1Bj
                                            ; sub_435980+4Dj
    mov     ecx, [esp+88h+arg_0]
    xor     eax, eax
    cmp     edi, ecx
    pop     edi
    setnle  al
    pop     esi
    add     esp, 80h
    retn    4
    sub_435980 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435A20 proc near                    ; CODE XREF: sub_435D30+53p
                                            ; .text:00444C77p ...

    var_D0= dword ptr -0D0h
    var_CC= dword ptr -0CCh
    MultiByteStr= dword ptr -0C8h
    arg_0= dword ptr  4

    sub     esp, 0D0h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebx, ebx
    mov     [esp+0E0h+var_CC], edi
    mov     eax, [edi]
    mov     [edi+0C1Ch], ebx
    cmp     eax, 1
    jz      loc_435B58
    jle     loc_435BAF
    cmp     eax, 3
    jg      loc_435BAF
    mov     ebx, [esp+0E0h+arg_0]
    push    ebx
    call    sub_435DA0
    test    eax, eax
    mov     [esp+0E0h+var_D0], eax
    jz      loc_435B22
    call    sub_49F580
    test    eax, eax
    jz      loc_435B22
    push    offset aEnglish                 ; char *
    call    sub_49F580
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_435B22
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0E0h+MultiByteStr]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+0E0h+MultiByteStr]
    push    ecx                             ; lpMultiByteStr
    call    sub_4E8960
    mov     edx, [esp+0E4h+var_CC]
    add     esp, 4
    lea     eax, [esp+0E0h+MultiByteStr]
    push    0FFh                            ; size_t
    push    eax                             ; int
    lea     ebp, [edx+0B14h]
    call    sub_4C5740
    push    eax                             ; char *
    push    ebp                             ; char *
    call    _strncpy
    add     esp, 0Ch
    push    ebx                             ; char *
    push    ebp                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_435B47
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, [esp+0E0h+var_D0]
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D0h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_435B22:                             ; CODE XREF: sub_435A20+45j
                                            ; sub_435A20+52j ...
    lea     edx, [edi+0B14h]
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_435B47:                             ; CODE XREF: sub_435A20+D2j
    mov     eax, [esp+0E0h+var_D0]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D0h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_435B58:                             ; CODE XREF: sub_435A20+1Dj
    lea     ecx, [esp+0E0h+var_D0]
    push    ecx
    mov     ecx, edi
    call    sub_435760
    mov     ebp, eax
    cmp     ebp, ebx
    jle     short loc_435BAF
    mov     esi, [esp+0E0h+var_D0]
    test    ebp, ebp
    jle     short loc_435BA2
    jmp     short loc_435B78
    ; ---------------------------------------------------------------------------

    loc_435B74:                             ; CODE XREF: sub_435A20+180j
    mov     edi, [esp+0E0h+var_CC]

    loc_435B78:                             ; CODE XREF: sub_435A20+152j
    mov     edx, [esp+0E0h+arg_0]
    push    edx                             ; char *
    push    esi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_435BBE
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    inc     ebx
    cmp     ebx, ebp
    lea     esi, [esi+ecx+1]
    jl      short loc_435B74

    loc_435BA2:                             ; CODE XREF: sub_435A20+150j
    mov     ecx, [esp+0E0h+var_D0]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_435BAF:                             ; CODE XREF: sub_435A20+23j
                                            ; sub_435A20+2Cj ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D0h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_435BBE:                             ; CODE XREF: sub_435A20+16Bj
    mov     eax, [esp+0E0h+var_D0]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     ecx, edi
    mov     dword ptr [edi+0C1Ch], 0
    mov     [edi+0C18h], ebx
    push    0
    call    sub_435DA0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D0h
    retn    4
    sub_435A20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435C00 proc near                    ; CODE XREF: sub_41EC50+36Ap
                                            ; sub_41F0A0+E0p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    0
    mov     dword ptr [ecx+0C1Ch], 0
    mov     [ecx+0C18h], eax
    call    sub_435DA0
    retn    4
    sub_435C00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435C20 proc near                    ; CODE XREF: sub_444A20+31p
                                            ; sub_448C70+1CDp ...
    lea     eax, [ecx+0B14h]
    retn
    sub_435C20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435C30 proc near                    ; CODE XREF: WriteRegistrySettings_1+1216p
                                            ; sub_4326B0+E6p ...
    lea     eax, [ecx+0A14h]
    retn
    sub_435C30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435C40 proc near                    ; CODE XREF: sub_444EA0+26p
                                            ; sub_447B10+DC5p ...
    mov     dl, [ecx+0A14h]
    xor     eax, eax
    test    dl, dl
    setnz   al
    retn
    sub_435C40 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435C50 proc near                    ; CODE XREF: sub_41DC20+4Bp
                                            ; .text:0049974Cp
    mov     eax, [ecx+0C18h]
    retn
    sub_435C50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435C60 proc near                    ; CODE XREF: sub_4326B0+D6p

    var_80= byte ptr -80h

    sub     esp, 80h
    xor     eax, eax
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     ebp, [ebx+0C18h]
    push    edi
    lea     edi, [ebx+4]
    or      ecx, 0FFFFFFFFh
    inc     ebp
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_435C86
    xor     edi, edi
    jmp     short loc_435CE3
    ; ---------------------------------------------------------------------------

    loc_435C86:                             ; CODE XREF: sub_435C60+20j
    xor     edi, edi
    lea     eax, [esp+90h+var_80]
    push    edi
    push    offset aMissionD                ; "MISSION%d"
    push    eax
    call    _sprintf
    lea     esi, [ebx+0A08h]
    add     esp, 0Ch
    mov     ecx, esi
    call    sub_4C3E10
    lea     ecx, [esp+90h+var_80]
    push    ecx                             ; char *
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jz      short loc_435CE3

    loc_435CB8:                             ; CODE XREF: sub_435C60+81j
    inc     edi
    lea     edx, [esp+90h+var_80]
    push    edi
    push    offset aMissionD                ; "MISSION%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    mov     ecx, esi
    call    sub_4C3E10
    lea     eax, [esp+90h+var_80]
    mov     ecx, esi
    push    eax                             ; char *
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_435CB8

    loc_435CE3:                             ; CODE XREF: sub_435C60+24j
                                            ; sub_435C60+56j
    cmp     edi, ebp
    jle     short loc_435D17
    mov     ecx, [ebx+0C18h]
    push    0
    inc     ecx
    mov     dword ptr [ebx+0C1Ch], 0
    mov     [ebx+0C18h], ecx
    mov     ecx, ebx
    call    sub_435DA0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 80h
    retn
    ; ---------------------------------------------------------------------------

    loc_435D17:                             ; CODE XREF: sub_435C60+85j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 80h
    retn
    sub_435C60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435D30 proc near                    ; CODE XREF: WriteRegistrySettings_1+1200p
                                            ; .text:004446E5p ...

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+0D2Ch]
    test    eax, eax
    jz      short loc_435D60
    test    ebx, ebx
    jnz     short loc_435D60
    mov     eax, [esi+0D24h]
    test    eax, eax
    jz      short loc_435D60
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [esi+0D24h], ebx

    loc_435D60:                             ; CODE XREF: sub_435D30+11j
                                            ; sub_435D30+15j ...
    mov     eax, [esi+0D24h]
    lea     edi, [esi+0D24h]
    test    eax, eax
    jnz     short loc_435D7E
    push    ebx
    push    ebx
    push    edi
    call    sub_434BF0
    mov     [esi+0D28h], eax

    loc_435D7E:                             ; CODE XREF: sub_435D30+3Ej
    mov     eax, [edi]
    mov     ecx, esi
    push    eax
    call    sub_435A20
    mov     [esi+0D2Ch], ebx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_435D30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_435DA0 proc near                    ; CODE XREF: sub_435110+17Fp
                                            ; sub_435A20+3Ap ...

    var_660= dword ptr -660h
    var_65C= dword ptr -65Ch
    var_654= dword ptr -654h
    var_650= byte ptr -650h
    var_630= dword ptr -630h
    var_62C= dword ptr -62Ch
    var_628= dword ptr -628h
    var_624= dword ptr -624h
    var_620= dword ptr -620h
    var_600= byte ptr -600h
    var_500= byte ptr -500h
    MultiByteStr= byte ptr -400h
    var_380= byte ptr -380h
    var_300= byte ptr -300h
    var_200= dword ptr -200h
    var_100= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 660h
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    lea     ecx, [esp+670h+var_660]
    call    sub_4C2EA0
    mov     eax, TAdynmemStructPtr
    xor     ebx, ebx
    mov     esi, [eax+391EDh]
    cmp     esi, ebx
    jz      short loc_435DD6
    mov     ecx, esi
    call    sub_48DFB0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_435DD6:                             ; CODE XREF: sub_435DA0+24j
    push    8Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_435DF0
    mov     ecx, eax
    call    sub_48DF90
    jmp     short loc_435DF2
    ; ---------------------------------------------------------------------------

    loc_435DF0:                             ; CODE XREF: sub_435DA0+45j
    xor     eax, eax

    loc_435DF2:                             ; CODE XREF: sub_435DA0+4Ej
    mov     ecx, TAdynmemStructPtr
    or      esi, 0FFFFFFFFh
    mov     [ecx+391EDh], eax
    mov     eax, [ebp+0DACh]
    cmp     eax, ebx
    mov     [ebp+0D30h], esi
    mov     [ebp+0D34h], esi
    mov     [ebp+0D38h], esi
    mov     [ebp+0D3Ch], esi
    mov     dword ptr [ebp+0D40h], 0BF800000h
    mov     [ebp+0D44h], ebx
    mov     [ebp+0D48h], ebx
    mov     byte ptr [ebp+0CA4h], 0
    mov     byte ptr [ebp+0C24h], 0
    jz      short loc_435E50
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_435E50:                             ; CODE XREF: sub_435DA0+A5j
    mov     eax, [ebp+0DB4h]
    mov     [ebp+0DACh], ebx
    cmp     eax, ebx
    mov     [ebp+0DB0h], ebx
    jz      short loc_435E6F
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_435E6F:                             ; CODE XREF: sub_435DA0+C4j
    mov     eax, [ebp+0DBCh]
    mov     [ebp+0DB4h], ebx
    cmp     eax, ebx
    mov     [ebp+0DB8h], ebx
    jz      short loc_435E8E
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_435E8E:                             ; CODE XREF: sub_435DA0+E3j
    mov     eax, [ebp+0C14h]
    mov     [ebp+0DBCh], ebx
    cmp     eax, ebx
    mov     [ebp+0DC0h], ebx
    jz      short loc_435EB3
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [ebp+0C14h], ebx

    loc_435EB3:                             ; CODE XREF: sub_435DA0+102j
    mov     eax, [ebp+0]
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_435FEB                      ; default
    jmp     ds:off_436844[eax*4]            ; switch jump

    loc_435EC6:                             ; DATA XREF: .text:00436844o
    mov     edx, [ebp+0C18h]                ; case 0x1
    lea     eax, [esp+670h+var_100]
    push    edx
    push    offset aMissionD                ; "MISSION%d"
    push    eax
    call    _sprintf
    lea     edi, [ebp+0A08h]
    add     esp, 0Ch
    mov     ecx, edi
    call    sub_4C3E10
    lea     ecx, [esp+670h+var_100]
    push    ecx                             ; char *
    mov     ecx, edi
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_435F35
    lea     edx, [esp+670h+var_100]
    lea     eax, [esp+670h+var_300]
    push    edx
    push    offset aTheRequestedMi          ; LPCSTR
    push    eax                             ; LPSTR
    call    ds:wsprintfA
    add     esp, 0Ch
    lea     ecx, [esp+670h+var_300]
    push    1
    push    1
    push    1E0h
    jmp     loc_435FD8
    ; ---------------------------------------------------------------------------

    loc_435F35:                             ; CODE XREF: sub_435DA0+160j
    push    ebx
    push    100h
    lea     eax, [ebp+0A14h]
    push    offset aMissionname             ; "missionname"
    push    eax
    push    edi
    call    sub_4C58A0
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+678h+var_500]
    push    offset aMissionfile             ; char *
    push    ecx                             ; char *
    mov     ecx, [ebp+0A0Ch]
    call    sub_4C48C0
    cmp     eax, ebx
    jz      loc_43609A
    lea     edx, [esp+670h+var_500]
    push    offset off_504A14
    push    edx
    lea     eax, [esp+678h+var_300]
    push    offset aMaps                    ; "Maps"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+670h+var_300]
    push    ecx
    lea     ecx, [esp+674h+var_660]
    call    sub_4C2F60
    test    eax, eax
    jnz     short loc_436003
    lea     edx, [esp+670h+var_500]
    lea     eax, [esp+670h+var_200]
    push    edx
    push    offset aHeyJokerThereI          ; "Hey, joker!  There is no mission defint"...
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+670h+var_200]
    push    1
    push    1
    push    1E0h

    loc_435FD8:                             ; CODE XREF: sub_435DA0+190j
    mov     edx, TAdynmemStructPtr
    push    ecx
    add     edx, 519h
    push    edx
    call    sub_4ABD90

    loc_435FEB:                             ; CODE XREF: sub_435DA0+119j
                                            ; sub_435DA0+11Fj ...
    lea     ecx, [esp+670h+var_660]         ; default
    call    sub_4C2EB0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 660h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_436003:                             ; CODE XREF: sub_435DA0+209j
    lea     ecx, [esp+670h+var_660]
    call    sub_4C3E10
    push    offset aGlobalheader            ; char *
    lea     ecx, [esp+674h+var_660]
    call    sub_4C3410
    test    eax, eax
    jz      short loc_436067
    mov     ecx, [esp+670h+var_65C]
    push    0C8h                            ; int
    push    offset aMaxunits                ; char *
    call    sub_4C46C0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37EE6h], ax
    lea     ecx, [esp+670h+var_660]
    call    sub_4C3E10
    lea     edx, [esp+670h+var_500]
    push    offset aTnt                     ; "TNT"
    push    edx
    push    offset aMaps                    ; "Maps"
    push    1
    mov     ecx, ebp
    call    sub_435430
    jmp     loc_43619A
    ; ---------------------------------------------------------------------------

    loc_436067:                             ; CODE XREF: sub_435DA0+27Cj
    lea     eax, [esp+670h+var_500]
    lea     ecx, [esp+670h+var_200]
    push    eax
    push    offset aHeyJokerMissio          ; "Hey, joker!  Mission file %s is corrupt"...
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+670h+var_200]
    push    1
    push    1
    push    1E0h
    push    edx
    jmp     loc_4361BA
    ; ---------------------------------------------------------------------------

    loc_43609A:                             ; CODE XREF: sub_435DA0+1D1j
    mov     ecx, TAdynmemStructPtr
    push    1
    push    1
    push    1E0h
    add     ecx, 519h
    push    offset aOldTedFormatNo          ; "Old TED format no longer supported!"
    push    ecx
    call    sub_4ABD90
    jmp     loc_435FEB                      ; default
    ; ---------------------------------------------------------------------------

    loc_4360BF:                             ; CODE XREF: sub_435DA0+11Fj
                                            ; DATA XREF: .text:00436844o
    mov     [ebp+0A04h], ebx                ; case 0x2
    mov     ebx, [esp+670h+arg_0]
    mov     edi, ebx
    mov     ecx, esi
    xor     eax, eax
    lea     edx, [ebp+0A14h]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    offset off_504A14
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    push    ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    offset aMaps                    ; "Maps"
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+67Ch+var_500]
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+670h+var_500]
    lea     ecx, [esp+670h+var_660]
    push    edx
    call    sub_4C2F60
    test    eax, eax
    jnz     short loc_436181
    push    ebx                             ; char *
    call    sub_4C5840
    mov     ebx, eax
    test    ebx, ebx
    jz      loc_435FEB                      ; default
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    offset off_504A14
    repne scasb
    not     ecx
    sub     edi, ecx
    push    ebx
    mov     eax, ecx
    mov     esi, edi
    lea     edi, [ebp+0A14h]
    push    offset aMaps                    ; "Maps"
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+67Ch+var_500]
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+670h+var_500]
    lea     ecx, [esp+670h+var_660]
    push    edx
    call    sub_4C2F60
    test    eax, eax
    jz      loc_435FEB                      ; default

    loc_436181:                             ; CODE XREF: sub_435DA0+37Bj
    push    offset aTnt                     ; "TNT"
    push    ebx
    push    offset aMaps                    ; "Maps"
    push    1
    mov     ecx, ebp
    call    sub_435430
    or      esi, 0FFFFFFFFh
    xor     ebx, ebx

    loc_43619A:                             ; CODE XREF: sub_435DA0+2C2j
    push    offset aGlobalheader            ; char *
    lea     ecx, [esp+674h+var_660]
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_4361CF
    push    1
    push    1
    push    1E0h
    push    offset aNoGlobalheader          ; "No GlobalHeader block in mission file!"

    loc_4361BA:                             ; CODE XREF: sub_435DA0+2F5j
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90
    jmp     loc_435FEB                      ; default
    ; ---------------------------------------------------------------------------

    loc_4361CF:                             ; CODE XREF: sub_435DA0+40Aj
    mov     ecx, [esp+670h+var_65C]
    push    offset Data
    push    100h
    lea     eax, [esp+678h+var_600]
    mov     edx, [ecx+25h]
    push    offset aBrief                   ; "brief"
    lea     ecx, [esp+67Ch+var_660]
    push    eax
    push    ecx
    mov     [ebp+0C20h], edx
    call    sub_4C58A0
    lea     edx, [esp+670h+var_600]
    push    offset aTxt                     ; "TXT"
    push    edx
    push    offset aCampsBriefs             ; "camps\\briefs"
    push    2
    mov     ecx, ebp
    call    sub_435430
    mov     eax, [ebp+0C14h]
    cmp     eax, ebx
    jz      short loc_436225
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_436225:                             ; CODE XREF: sub_435DA0+47Aj
    lea     edx, [ebp+304h]
    mov     ecx, esi
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     eax, ecx
    sbb     esi, esi
    and     esi, edx
    cmp     esi, ebx
    jnz     short loc_436248
    mov     [ebp+0C14h], ebx
    jmp     short loc_43627E
    ; ---------------------------------------------------------------------------

    loc_436248:                             ; CODE XREF: sub_435DA0+49Ej
    push    esi
    call    sub_4BBC40
    mov     edi, eax
    cmp     edi, ebx
    jz      short loc_43627E
    lea     ecx, [edi+1]
    push    ecx
    push    offset aBriefing                ; "Briefing"
    call    sub_4D83B0
    add     esp, 8
    mov     [ebp+0C14h], eax
    push    edi
    push    ebx
    push    eax
    push    esi
    call    sub_4BBD30
    mov     edx, [ebp+0C14h]
    mov     byte ptr [edi+edx], 0

    loc_43627E:                             ; CODE XREF: sub_435DA0+4A6j
                                            ; sub_435DA0+4B2j
    push    offset Data
    push    100h
    lea     eax, [esp+678h+var_600]
    push    offset aNarration               ; "narration"
    lea     ecx, [esp+67Ch+var_660]
    push    eax
    push    ecx
    call    sub_4C58A0
    lea     edx, [esp+670h+var_600]
    push    offset aWav                     ; "WAV"
    push    edx
    push    offset aCampsBriefs             ; "camps\\briefs"
    push    3
    mov     ecx, ebp
    call    sub_435430
    push    offset Data
    push    100h
    lea     eax, [esp+678h+var_600]
    push    offset aMissionhint             ; "missionhint"
    lea     ecx, [esp+67Ch+var_660]
    push    eax
    push    ecx
    call    sub_4C58A0
    lea     edx, [esp+670h+var_600]
    push    offset aTxt                     ; "TXT"
    push    edx
    push    offset aCampsHints              ; "camps\\hints"
    push    4
    mov     ecx, ebp
    call    sub_435430
    mov     ecx, [esp+670h+var_65C]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     eax, [esp+678h+var_600]
    push    offset aGlamour                 ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    lea     ecx, [esp+670h+var_600]
    push    offset aPcx                     ; "PCX"
    push    ecx
    push    offset Data
    push    5
    mov     ecx, ebp
    call    sub_435430
    mov     ecx, [esp+670h+var_65C]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+678h+var_600]
    push    offset aGlamoursound            ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    lea     eax, [esp+670h+var_600]
    push    offset aWav                     ; "WAV"
    push    eax
    push    offset aCampsBriefs             ; "camps\\briefs"
    push    8
    mov     ecx, ebp
    call    sub_435430
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+678h+var_600]
    push    offset aUseonlyunits            ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+680h+var_65C]
    call    sub_4C48C0
    lea     edx, [esp+670h+var_600]
    push    offset off_50341C
    push    edx
    push    offset aCampsUseonly            ; "camps\\useonly"
    push    6
    mov     ecx, ebp
    call    sub_435430
    mov     ecx, [esp+670h+var_65C]
    push    ebx                             ; int
    push    offset aMapping                 ; char *
    call    sub_4C46C0
    mov     ecx, TAdynmemStructPtr
    push    ebx                             ; int
    push    offset aLineofsight             ; char *
    mov     [ecx+3921Dh], eax
    mov     ecx, [esp+678h+var_65C]
    call    sub_4C46C0
    mov     edx, TAdynmemStructPtr
    push    offset Data                     ; int
    push    80h                             ; size_t
    push    offset aMemory                  ; char *
    mov     [edx+39221h], eax
    mov     eax, TAdynmemStructPtr
    lea     edx, [ebp+0DC4h]
    mov     dword ptr [eax+39225h], 1
    mov     ecx, TAdynmemStructPtr
    push    edx                             ; char *
    mov     [ecx+39219h], ebx
    mov     ecx, [esp+680h+var_65C]
    call    sub_4C48C0
    mov     ecx, [esp+670h+var_65C]
    push    offset Data                     ; int
    push    80h                             ; size_t
    lea     eax, [ebp+0E44h]
    push    offset aNumplayers              ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    mov     ecx, [esp+670h+var_65C]
    push    offset Data                     ; int
    push    80h                             ; size_t
    lea     eax, [ebp+0CA4h]
    push    offset aPlanet                  ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    mov     ecx, [esp+670h+var_65C]
    push    ebx                             ; int
    push    offset aNomovie                 ; char *
    call    sub_4C46C0
    mov     ecx, TAdynmemStructPtr
    push    offset aNoDescriptionA          ; int
    push    80h                             ; size_t
    lea     edx, [esp+678h+var_380]
    mov     [ecx+39073h], eax
    mov     ecx, [esp+678h+var_65C]
    push    offset aMissiondescrip          ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    lea     edi, [esp+670h+var_380]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+670h+MultiByteStr]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+670h+MultiByteStr]
    push    ecx                             ; lpMultiByteStr
    call    sub_4E8960
    add     esp, 4
    lea     edx, [esp+670h+MultiByteStr]
    push    edx                             ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     ebx, [ebp+0C24h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+670h+MultiByteStr]
    push    ecx                             ; char *
    push    ebx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_436516
    lea     edi, [esp+670h+var_380]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_436516:                             ; CODE XREF: sub_435DA0+752j
    mov     ecx, [esp+670h+var_65C]
    push    0                               ; int
    push    offset aMinwindspeed            ; char *
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    push    0                               ; int
    push    offset aMaxwindspeed            ; char *
    mov     [ebp+0D34h], eax
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    push    0                               ; int
    push    offset aGravity                 ; char *
    mov     [ebp+0D38h], eax
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    push    0
    push    0                               ; __int64
    push    offset aTidalstrength           ; char *
    mov     [ebp+0D3Ch], eax
    call    sub_4C4760
    mov     ecx, [esp+670h+var_65C]
    push    0                               ; int
    fstp    dword ptr [ebp+0D40h]
    push    offset aLavaworld               ; char *
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    push    0                               ; int
    push    offset aNosealeveltrig          ; char *
    mov     [ebp+0D44h], eax
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    push    0                               ; int
    push    offset aWaterdoesdamag          ; char *
    mov     [ebp+0D48h], eax
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    push    0                               ; int
    push    offset aWaterdamage             ; char *
    mov     [ebp+0D4Ch], eax
    call    sub_4C46C0
    mov     [ebp+0D50h], eax
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+670h+var_660]
    mov     ecx, [ecx+391EDh]
    push    eax
    call    sub_48E010
    mov     ecx, [esp+670h+var_65C]
    push    0
    push    0                               ; __int64
    push    offset aKillmul                 ; char *
    call    sub_4C4760
    mov     ecx, [esp+670h+var_65C]
    push    0
    fstp    dword ptr [ebp+0D54h]
    push    0                               ; __int64
    push    offset aTimemul                 ; char *
    call    sub_4C4760
    mov     ecx, [ebp+0]
    lea     edx, [esp+670h+var_620]
    lea     eax, [esp+670h+var_660]
    push    edx
    push    eax
    push    ecx
    fstp    dword ptr [ebp+0D58h]
    mov     ecx, ebp
    call    sub_436860
    test    eax, eax
    jnz     short loc_43663B
    push    offset aMapError                ; "Map error"
    push    offset aNoSuitableSche          ; lpText
    call    sub_4B6B80
    jmp     loc_435FEB                      ; default
    ; ---------------------------------------------------------------------------

    loc_43663B:                             ; CODE XREF: sub_435DA0+885j
    mov     ecx, [esp+670h+var_65C]
    push    0                               ; int
    push    offset aHumanmetal              ; char *
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    mov     [esp+670h+var_654], eax
    fild    [esp+670h+var_654]
    push    0                               ; int
    push    offset aHumanenergy             ; char *
    fstp    dword ptr [ebp+0D5Ch]
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    mov     [esp+670h+var_654], eax
    fild    [esp+670h+var_654]
    push    0                               ; int
    push    offset aComputermetal           ; char *
    fstp    dword ptr [ebp+0D84h]
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    mov     [esp+670h+var_654], eax
    fild    [esp+670h+var_654]
    push    0                               ; int
    push    offset aComputerenergy          ; char *
    fstp    dword ptr [ebp+0D60h]
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    mov     [esp+670h+var_654], eax
    fild    [esp+670h+var_654]
    push    0                               ; int
    push    offset aSurfacemetal            ; char *
    fstp    dword ptr [ebp+0D88h]
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+678h+var_600]
    push    offset aAiprofile               ; char *
    push    edx                             ; char *
    mov     [ebp+0D30h], eax
    call    sub_4C48C0
    lea     eax, [esp+670h+var_600]
    push    offset aTxt_0                   ; "txt"
    push    eax
    push    offset aAi                      ; "ai"
    push    7
    mov     ecx, ebp
    call    sub_435430
    lea     edx, [ebp+804h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     eax, ecx
    sbb     eax, eax
    and     eax, edx
    test    eax, eax
    jnz     short loc_436732
    push    offset aTxt_0                   ; "txt"
    push    offset aDefault                 ; "default"
    push    offset aAi                      ; "ai"
    push    7
    mov     ecx, ebp
    call    sub_435430

    loc_436732:                             ; CODE XREF: sub_435DA0+978j
    push    offset Data                     ; int
    push    20h                             ; size_t
    lea     ecx, [esp+678h+var_650]
    push    offset aMeteorweapon            ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+680h+var_65C]
    call    sub_4C48C0
    lea     edi, [esp+670h+var_650]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_436800
    mov     ecx, [esp+670h+var_65C]
    push    eax                             ; int
    push    offset aMeteorradius            ; char *
    call    sub_4C46C0
    mov     ecx, [esp+670h+var_65C]
    push    0
    push    0                               ; __int64
    push    offset aMeteordensity           ; char *
    mov     [esp+67Ch+var_630], eax
    call    sub_4C4760
    mov     ecx, [esp+670h+var_65C]
    push    0
    fstp    [esp+674h+var_62C]
    push    0                               ; __int64
    push    offset aMeteorduration          ; char *
    call    sub_4C4760
    mov     ecx, [esp+670h+var_65C]
    push    0
    fstp    [esp+674h+var_628]
    push    0                               ; __int64
    push    offset aMeteorinterval          ; char *
    call    sub_4C4760
    mov     eax, [esp+670h+var_630]
    fstp    [esp+670h+var_624]
    test    eax, eax
    jz      short loc_4367F0
    fld     [esp+670h+var_62C]
    fcomp   ds:flt_4FD268
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_4367F0
    fld     [esp+670h+var_628]
    fcomp   ds:flt_4FD268
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_4367F0
    fld     [esp+670h+var_624]
    fcomp   ds:flt_4FD268
    fnstsw  ax
    test    ah, 40h
    jz      short loc_4367F9

    loc_4367F0:                             ; CODE XREF: sub_435DA0+A1Bj
                                            ; sub_435DA0+A2Cj ...
    lea     ecx, [esp+670h+var_650]
    call    sub_438320

    loc_4367F9:                             ; CODE XREF: sub_435DA0+A4Ej
    call    sub_437D40
    jmp     short loc_43680E
    ; ---------------------------------------------------------------------------

    loc_436800:                             ; CODE XREF: sub_435DA0+9BAj
    call    sub_437D50
    lea     ecx, [esp+670h+var_650]
    call    sub_438320

    loc_43680E:                             ; CODE XREF: sub_435DA0+A5Ej
    lea     edx, [esp+670h+var_650]
    push    edx
    call    sub_437D60
    lea     eax, [esp+670h+var_660]
    lea     ecx, [esp+670h+var_620]
    push    eax
    push    ecx
    mov     ecx, ebp
    call    sub_436C30
    lea     ecx, [esp+670h+var_660]
    call    sub_4C2EB0
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 660h
    retn    4
    sub_435DA0 endp

    ; ---------------------------------------------------------------------------
    off_436844 dd offset loc_435FEB         ; DATA XREF: sub_435DA0+11Fr
    dd offset loc_435EC6                    ; jump table for switch statement
    dd offset loc_4360BF
    dd offset loc_4360BF
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_436860 proc near                    ; CODE XREF: sub_434BF0+18Ap
                                            ; sub_435DA0+87Ep

    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= byte ptr -40h
    var_30= byte ptr -30h
    var_20= byte ptr -20h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 90h
    or      eax, 0FFFFFFFFh
    mov     ecx, TAdynmemStructPtr
    mov     [esp+90h+var_90], eax
    push    ebx
    mov     ebx, [esp+94h+arg_0]
    mov     [esp+94h+var_8C], eax
    mov     [esp+94h+var_88], eax
    push    ebp
    mov     [esp+98h+var_84], eax
    push    esi
    xor     eax, eax
    mov     esi, 3
    mov     ax, [ecx+TAdynmemStruct.LOS_Radar]
    cmp     ebx, esi
    push    edi
    mov     [esp+0A0h+var_5C], offset aEasy ; "Easy"
    mov     [esp+0A0h+var_58], offset aMedium ; "Medium"
    mov     [esp+0A0h+var_54], offset aHard ; "Hard"
    mov     [esp+0A0h+var_50], offset aNetwork1 ; "Network 1"
    mov     [esp+0A0h+var_4C], offset aNetwork2 ; "Network 2"
    mov     [esp+0A0h+var_48], offset aNetwork3 ; "Network 3"
    mov     [esp+0A0h+var_44], offset aNetwork4 ; "Network 4"
    mov     [esp+0A0h+var_78], eax
    ja      loc_436BCF
    jmp     ds:off_436C1C[ebx*4]

    loc_4368E3:                             ; DATA XREF: .text:00436C20o
    mov     ecx, [ecx+37EEEh]
    xor     eax, eax
    sub     ecx, eax
    jz      short loc_436928
    dec     ecx
    jz      short loc_436912
    dec     ecx
    jnz     loc_436BCF
    mov     [esp+0A0h+var_90], 2
    mov     [esp+0A0h+var_8C], 1
    mov     [esp+0A0h+var_88], eax
    jmp     loc_43699C
    ; ---------------------------------------------------------------------------

    loc_436912:                             ; CODE XREF: sub_436860+90j
    mov     [esp+0A0h+var_90], 1
    mov     [esp+0A0h+var_8C], eax
    mov     [esp+0A0h+var_88], 2
    jmp     short loc_43699C
    ; ---------------------------------------------------------------------------

    loc_436928:                             ; CODE XREF: sub_436860+8Dj
    mov     [esp+0A0h+var_90], eax
    mov     [esp+0A0h+var_8C], 1
    mov     [esp+0A0h+var_88], 2
    jmp     short loc_43699C
    ; ---------------------------------------------------------------------------

    loc_43693E:                             ; CODE XREF: sub_436860+7Cj
                                            ; DATA XREF: .text:00436C28o
    xor     eax, eax
    lea     edx, [ecx+2C28h]

    loc_436946:                             ; CODE XREF: sub_436860+FFj
    mov     ecx, [edx]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_436958
    test    ecx, ecx
    jz      short loc_436958
    lea     ecx, [eax+1]
    mov     [esp+0A0h+var_78], ecx

    loc_436958:                             ; CODE XREF: sub_436860+EBj
                                            ; sub_436860+EFj
    inc     eax
    add     edx, 4
    cmp     eax, 0Ah
    jl      short loc_436946
    jmp     short loc_436980
    ; ---------------------------------------------------------------------------

    loc_436963:                             ; CODE XREF: sub_436860+7Cj
                                            ; DATA XREF: .text:00436C24o
    mov     ecx, [ecx+29A0h]
    xor     eax, eax

    loc_43696B:                             ; CODE XREF: sub_436860+11Ej
    cmp     dword ptr [ecx], 0
    jz      short loc_436977
    lea     edx, [eax+1]
    mov     [esp+0A0h+var_78], edx

    loc_436977:                             ; CODE XREF: sub_436860+10Ej
    inc     eax
    add     ecx, 18h
    cmp     eax, 0Ah
    jl      short loc_43696B

    loc_436980:                             ; CODE XREF: sub_436860+101j
    mov     [esp+0A0h+var_90], esi
    mov     [esp+0A0h+var_8C], 4
    mov     [esp+0A0h+var_88], 5
    mov     [esp+0A0h+var_84], 6

    loc_43699C:                             ; CODE XREF: sub_436860+ADj
                                            ; sub_436860+C6j ...
    xor     ecx, ecx
    lea     eax, [esp+0A0h+var_90]
    mov     [esp+0A0h+var_68], ecx
    mov     [esp+0A0h+var_74], ecx
    mov     [esp+0A0h+var_6C], ecx
    mov     [esp+0A0h+var_70], ecx
    mov     [esp+0A0h+var_7C], eax
    jmp     short loc_4369BA
    ; ---------------------------------------------------------------------------

    loc_4369B8:                             ; CODE XREF: sub_436860+344j
    xor     ecx, ecx

    loc_4369BA:                             ; CODE XREF: sub_436860+156j
    mov     edx, [esp+0A0h+var_7C]
    mov     edi, [edx]
    cmp     edi, 0FFFFFFFFh
    mov     [esp+0A0h+var_64], edi
    jz      loc_436BAC
    mov     [esp+0A0h+var_80], ecx

    loc_4369D1:                             ; CODE XREF: sub_436860+328j
    mov     esi, [esp+0A0h+arg_4]
    mov     ecx, esi
    call    sub_4C3E10
    push    offset aGlobalheader            ; char *
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jnz     short loc_4369F9
    push    offset aVeryBadNewsNoM          ; lpText
    call    sub_4B6290

    loc_4369F9:                             ; CODE XREF: sub_436860+18Dj
    mov     eax, [esp+0A0h+var_80]
    lea     ecx, [esp+0A0h+var_40]
    push    eax
    push    offset aSchemaI                 ; "Schema %i"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+0A0h+var_40]
    mov     ecx, esi
    push    edx                             ; char *
    call    sub_4C3410
    test    eax, eax
    jz      loc_436B8D
    mov     ecx, [esi+4]
    push    offset Data                     ; int
    push    20h                             ; size_t
    lea     eax, [esp+0A8h+var_20]
    push    offset aType                    ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jz      loc_436B74
    mov     ecx, [esp+edi*4+0A0h+var_5C]
    lea     edx, [esp+0A0h+var_20]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     loc_436B74
    cmp     ebx, 3
    jz      short loc_436A73
    cmp     ebx, 2
    jnz     loc_436BDE

    loc_436A73:                             ; CODE XREF: sub_436860+208j
    mov     ebp, [esp+0A0h+arg_8]
    test    ebp, ebp
    jz      loc_436C0A
    mov     eax, [esi+4]
    push    offset aSpecials                ; char *
    mov     ecx, esi
    mov     [esp+0A4h+var_60], eax
    xor     ebx, ebx
    call    sub_4C3410
    test    eax, eax
    jz      loc_436B23
    mov     ebp, [esi+4]
    xor     esi, esi
    push    esi
    mov     ecx, ebp
    call    sub_4C44C0
    test    eax, eax
    jz      short loc_436B1C

    loc_436AB0:                             ; CODE XREF: sub_436860+2BAj
    push    offset Data                     ; int
    push    10h                             ; size_t
    lea     ecx, [esp+0A8h+var_30]
    push    offset aSpecialwhat             ; char *
    push    ecx                             ; char *
    mov     ecx, eax
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_436B0F
    mov     al, byte_5122B0
    test    al, 1
    jnz     short loc_436AF1
    or      al, 1
    mov     edi, offset aStartpos           ; "StartPos"
    mov     byte_5122B0, al
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     dword_5122D0, ecx

    loc_436AF1:                             ; CODE XREF: sub_436860+273j
    mov     edx, dword_5122D0
    lea     eax, [esp+0A0h+var_30]
    push    edx                             ; size_t
    push    offset aStartpos                ; char *
    push    eax                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_436B0F
    inc     ebx

    loc_436B0F:                             ; CODE XREF: sub_436860+26Aj
                                            ; sub_436860+2ACj
    inc     esi
    mov     ecx, ebp
    push    esi
    call    sub_4C44C0
    test    eax, eax
    jnz     short loc_436AB0

    loc_436B1C:                             ; CODE XREF: sub_436860+24Ej
    mov     ebp, [esp+0A0h+arg_8]

    loc_436B23:                             ; CODE XREF: sub_436860+239j
    test    ebx, ebx
    jz      short loc_436B74
    mov     ecx, [esp+0A0h+var_78]
    cmp     ebx, ecx
    jz      short loc_436B3F
    test    ecx, ecx
    jz      short loc_436B3F
    mov     eax, [esp+0A0h+var_68]
    cmp     ebx, eax
    jle     short loc_436B74
    cmp     eax, ecx
    jz      short loc_436B74

    loc_436B3F:                             ; CODE XREF: sub_436860+2CDj
                                            ; sub_436860+2D1j
    mov     ecx, [esp+0A0h+var_60]
    lea     edi, [esp+0A0h+var_40]
    mov     [esp+0A0h+var_6C], ecx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esp+0A0h+var_68], ebx
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     [esp+0A0h+var_74], 1
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_436B74:                             ; CODE XREF: sub_436860+1E2j
                                            ; sub_436860+1FFj ...
    mov     eax, [esp+0A0h+var_80]
    mov     edi, [esp+0A0h+var_64]
    mov     ebx, [esp+0A0h+arg_0]
    inc     eax
    mov     [esp+0A0h+var_80], eax
    jmp     loc_4369D1
    ; ---------------------------------------------------------------------------

    loc_436B8D:                             ; CODE XREF: sub_436860+1BEj
    mov     eax, [esp+0A0h+var_70]
    mov     edx, [esp+0A0h+var_7C]
    inc     eax
    add     edx, 4
    cmp     eax, 4
    mov     [esp+0A0h+var_70], eax
    mov     [esp+0A0h+var_7C], edx
    jl      loc_4369B8
    xor     ecx, ecx

    loc_436BAC:                             ; CODE XREF: sub_436860+167j
    mov     eax, [esp+0A0h+var_6C]
    cmp     eax, ecx
    jz      short loc_436BBE
    mov     ecx, [esp+0A0h+arg_4]
    mov     [ecx+4], eax

    loc_436BBE:                             ; CODE XREF: sub_436860+352j
    mov     eax, [esp+0A0h+var_74]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 90h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_436BCF:                             ; CODE XREF: sub_436860+76j
                                            ; sub_436860+7Cj ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 90h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_436BDE:                             ; CODE XREF: sub_436860+20Dj
    mov     ebp, [esp+0A0h+arg_8]
    test    ebp, ebp
    jz      short loc_436C0A
    lea     edi, [esp+0A0h+var_40]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_436C0A:                             ; CODE XREF: sub_436860+21Cj
                                            ; sub_436860+387j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 90h
    retn    0Ch
    sub_436860 endp

    ; ---------------------------------------------------------------------------
    off_436C1C dd offset loc_436BCF         ; DATA XREF: sub_436860+7Cr
    dd offset loc_4368E3
    dd offset loc_436963
    dd offset loc_43693E
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_436C30 proc near                    ; CODE XREF: sub_435DA0+A84p

    var_518= dword ptr -518h
    var_514= dword ptr -514h
    var_510= dword ptr -510h
    var_50C= dword ptr -50Ch
    var_508= dword ptr -508h
    var_504= dword ptr -504h
    var_500= byte ptr -500h
    var_400= byte ptr -400h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 518h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+524h+arg_4]
    push    edi
    mov     edi, ecx
    mov     ecx, esi
    mov     [esp+528h+var_50C], edi
    xor     ebx, ebx
    call    sub_4C3E10
    push    offset aGlobalheader_0          ; char *
    mov     ecx, esi
    call    sub_4C3410
    test    eax, eax
    jz      loc_437270
    mov     eax, [esp+528h+arg_0]
    mov     ecx, esi
    push    eax                             ; char *
    call    sub_4C3410
    test    eax, eax
    jz      loc_437270
    mov     ecx, [esi+4]
    push    offset aUnits                   ; char *
    mov     [esp+52Ch+var_504], ecx
    call    sub_4C4470
    mov     ebp, eax
    cmp     ebp, ebx
    mov     [esp+528h+var_508], ebp
    jz      short loc_436CA3
    mov     ecx, ebp
    call    sub_4C4450
    mov     [esp+528h+var_518], eax
    jmp     short loc_436CA7
    ; ---------------------------------------------------------------------------

    loc_436CA3:                             ; CODE XREF: sub_436C30+64j
    mov     [esp+528h+var_518], ebx

    loc_436CA7:                             ; CODE XREF: sub_436C30+71j
    mov     ecx, [esp+528h+var_518]
    xor     eax, eax
    cmp     ecx, ebx
    mov     [esp+528h+var_510], eax
    jle     loc_436D81

    loc_436CB9:                             ; CODE XREF: sub_436C30+147j
    push    eax
    mov     ecx, ebp
    call    sub_4C44C0
    push    offset Data                     ; int
    push    400h                            ; size_t
    lea     ecx, [esp+530h+var_400]
    mov     esi, eax
    push    offset aUnitname_0              ; char *
    push    ecx                             ; char *
    mov     ecx, esi
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_436CFA
    lea     edi, [esp+528h+var_400]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     ebx, [ebx+ecx+1]

    loc_436CFA:                             ; CODE XREF: sub_436C30+B3j
    push    offset Data                     ; int
    push    400h                            ; size_t
    lea     edx, [esp+530h+var_400]
    push    offset aIdent                   ; char *
    push    edx                             ; char *
    mov     ecx, esi
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_436D31
    lea     edi, [esp+528h+var_400]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     ebx, [ebx+ecx+1]

    loc_436D31:                             ; CODE XREF: sub_436C30+EAj
    push    offset Data                     ; int
    push    400h                            ; size_t
    lea     eax, [esp+530h+var_400]
    push    offset aInitialmission          ; char *
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_436D68
    lea     edi, [esp+528h+var_400]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     ebx, [ebx+ecx+1]

    loc_436D68:                             ; CODE XREF: sub_436C30+121j
    mov     eax, [esp+528h+var_510]
    mov     ecx, [esp+528h+var_518]
    inc     eax
    cmp     eax, ecx
    mov     [esp+528h+var_510], eax
    jl      loc_436CB9
    mov     edi, [esp+528h+var_50C]

    loc_436D81:                             ; CODE XREF: sub_436C30+83j
    mov     eax, ebx
    lea     esi, [ecx+ecx*8]
    cdq
    and     edx, 3FFh
    mov     [edi+0DB0h], ecx
    add     eax, edx
    sar     eax, 0Ah
    add     eax, 2
    shl     esi, 2
    shl     eax, 0Ah
    add     eax, esi
    push    eax
    push    offset aMissionunitDat          ; "MISSIONUNIT DATA"
    call    sub_4D83B0
    mov     [edi+0DACh], eax
    lea     edi, [esi+eax]
    mov     eax, [esp+530h+var_518]
    add     esp, 8
    xor     ebx, ebx
    mov     [esp+528h+var_514], edi
    test    eax, eax
    jle     loc_43700C
    mov     [esp+528h+var_510], ebx
    jmp     short loc_436DDA
    ; ---------------------------------------------------------------------------

    loc_436DD2:                             ; CODE XREF: sub_436C30+3D6j
    mov     edi, [esp+528h+var_514]
    mov     ebp, [esp+528h+var_508]

    loc_436DDA:                             ; CODE XREF: sub_436C30+1A0j
    mov     ecx, [esp+528h+var_50C]
    push    ebx
    mov     esi, [ecx+0DACh]
    mov     ecx, [esp+52Ch+var_510]
    add     esi, ecx
    mov     ecx, ebp
    call    sub_4C44C0
    push    offset Data                     ; int
    mov     ebp, eax
    push    400h                            ; size_t
    push    offset aUnitname_0              ; char *
    push    edi                             ; char *
    mov     ecx, ebp
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_436E2B
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esi], edi
    mov     edx, [esp+528h+var_514]
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [edx+ecx+1]
    mov     [esp+528h+var_514], eax
    mov     edi, eax
    jmp     short loc_436E31
    ; ---------------------------------------------------------------------------

    loc_436E2B:                             ; CODE XREF: sub_436C30+1DDj
    mov     dword ptr [esi], 0

    loc_436E31:                             ; CODE XREF: sub_436C30+1F9j
    push    offset Data                     ; int
    push    400h                            ; size_t
    push    offset aIdent                   ; char *
    push    edi                             ; char *
    mov     ecx, ebp
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_436E69
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esi+4], edi
    mov     edx, [esp+528h+var_514]
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [edx+ecx+1]
    mov     [esp+528h+var_514], eax
    mov     edi, eax
    jmp     short loc_436E70
    ; ---------------------------------------------------------------------------

    loc_436E69:                             ; CODE XREF: sub_436C30+21Aj
    mov     dword ptr [esi+4], 0

    loc_436E70:                             ; CODE XREF: sub_436C30+237j
    push    offset Data                     ; int
    push    400h                            ; size_t
    push    offset aInitialmission          ; char *
    push    edi                             ; char *
    mov     ecx, ebp
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_436EA6
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esi+8], edi
    mov     edx, [esp+528h+var_514]
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [edx+ecx+1]
    mov     [esp+528h+var_514], eax
    jmp     short loc_436EAD
    ; ---------------------------------------------------------------------------

    loc_436EA6:                             ; CODE XREF: sub_436C30+259j
    mov     dword ptr [esi+8], 0

    loc_436EAD:                             ; CODE XREF: sub_436C30+274j
    push    0                               ; int
    push    offset aXpos                    ; char *
    mov     ecx, ebp
    call    sub_4C46C0
    shl     eax, 10h
    push    0                               ; int
    push    offset aYpos                    ; char *
    mov     ecx, ebp
    mov     [esi+0Ch], eax
    call    sub_4C46C0
    shl     eax, 10h
    push    0                               ; int
    push    offset aZpos                    ; char *
    mov     ecx, ebp
    mov     [esi+10h], eax
    call    sub_4C46C0
    shl     eax, 10h
    push    0                               ; int
    push    offset aAngle                   ; char *
    mov     ecx, ebp
    mov     [esi+14h], eax
    call    sub_4C46C0
    mov     ecx, eax
    mov     eax, 0B60B60B7h
    shl     ecx, 10h
    imul    ecx
    add     edx, ecx
    push    0                               ; int
    sar     edx, 8
    mov     ecx, edx
    push    offset aPlayer                  ; char *
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, ebp
    mov     [esi+18h], dx
    call    sub_4C46C0
    test    al, al
    mov     [esi+22h], al
    jnz     short loc_436F2C
    mov     byte ptr [esi+22h], 1

    loc_436F2C:                             ; CODE XREF: sub_436C30+2F6j
    push    64h                             ; int
    push    offset aHealthpercenta          ; char *
    mov     ecx, ebp
    call    sub_4C46C0
    push    0                               ; int
    push    offset aBuildpriority           ; char *
    mov     ecx, ebp
    mov     [esi+1Ah], ax
    call    sub_4C46C0
    push    0                               ; int
    push    offset aCreationcountd          ; char *
    mov     ecx, ebp
    mov     [esi+20h], ax
    call    sub_4C46C0
    push    0                               ; int
    push    offset aMissioncritica          ; char *
    mov     ecx, ebp
    mov     [esi+1Ch], eax
    call    sub_4C46C0
    mov     dl, [esi+23h]
    and     al, 1
    and     dl, 0EFh
    push    0                               ; int
    shl     al, 4
    or      dl, al
    push    offset aAiignore                ; char *
    mov     ecx, ebp
    mov     [esi+23h], dl
    call    sub_4C46C0
    mov     cl, [esi+23h]
    and     al, 1
    and     cl, 0DFh
    push    0                               ; int
    shl     al, 5
    or      cl, al
    push    offset aAiprioritytarg          ; char *
    mov     [esi+23h], cl
    mov     ecx, ebp
    call    sub_4C46C0
    mov     dl, [esi+23h]
    and     al, 1
    and     dl, 0BFh
    push    0                               ; int
    shl     al, 6
    or      dl, al
    push    offset aInitialgroup            ; char *
    mov     ecx, ebp
    mov     [esi+23h], dl
    call    sub_4C46C0
    mov     cl, [esi+23h]
    push    0                               ; int
    mov     dl, cl
    push    offset aImmunity                ; char *
    xor     dl, al
    and     dl, 0Fh
    xor     dl, cl
    mov     ecx, ebp
    mov     [esi+23h], dl
    call    sub_4C46C0
    mov     cl, [esi+23h]
    and     cl, 7Fh
    shl     al, 7
    or      cl, al
    mov     eax, [esp+528h+var_518]
    mov     [esi+23h], cl
    mov     ecx, [esp+528h+var_510]
    inc     ebx
    add     ecx, 24h
    cmp     ebx, eax
    mov     [esp+528h+var_510], ecx
    jl      loc_436DD2

    loc_43700C:                             ; CODE XREF: sub_436C30+196j
    mov     ecx, [esp+528h+var_504]
    push    offset aSpecials                ; char *
    call    sub_4C4470
    mov     edi, eax
    test    edi, edi
    mov     [esp+528h+var_508], edi
    jz      short loc_437033
    mov     ecx, edi
    call    sub_4C4450
    mov     ebx, eax
    mov     [esp+528h+var_518], ebx
    jmp     short loc_43703F
    ; ---------------------------------------------------------------------------

    loc_437033:                             ; CODE XREF: sub_436C30+3F2j
    mov     [esp+528h+var_518], 0
    mov     ebx, [esp+528h+var_518]

    loc_43703F:                             ; CODE XREF: sub_436C30+401j
    mov     esi, [esp+528h+var_50C]
    lea     edx, [ebx+ebx*2]
    shl     edx, 2
    push    edx
    push    offset aMissionruleDat          ; "MISSIONRULE DATA"
    mov     [esi+0DB8h], ebx
    call    sub_4D83B0
    xor     ebp, ebp
    add     esp, 8
    cmp     ebx, ebp
    mov     [esi+0DB4h], eax
    mov     [esp+528h+var_514], ebp
    jle     loc_43717F
    mov     [esp+528h+var_510], ebp

    loc_437075:                             ; CODE XREF: sub_436C30+549j
    mov     esi, [esi+0DB4h]
    mov     eax, [esp+528h+var_510]
    add     esi, eax
    push    ebp
    mov     ecx, edi
    mov     dword ptr [esi], 0
    call    sub_4C44C0
    mov     ebx, eax
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     eax, [esp+530h+var_500]
    push    offset aSpecialwhat             ; char *
    push    eax                             ; char *
    mov     ecx, ebx
    call    sub_4C48C0
    test    eax, eax
    jz      loc_437163
    mov     al, byte_5122B8
    test    al, 1
    jnz     short loc_4370DD
    or      al, 1
    mov     edi, offset aStartpos           ; "StartPos"
    mov     byte_5122B8, al
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     edi, [esp+528h+var_508]
    not     ecx
    dec     ecx
    mov     dword_5122B4, ecx

    loc_4370DD:                             ; CODE XREF: sub_436C30+48Bj
    mov     ecx, dword_5122B4
    lea     edx, [esp+528h+var_500]
    push    ecx                             ; size_t
    push    offset aStartpos                ; char *
    push    edx                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_437163
    push    eax                             ; int
    push    offset aXpos                    ; char *
    mov     ecx, ebx
    mov     dword ptr [esi], 1
    call    sub_4C46C0
    push    0                               ; int
    push    offset aZpos                    ; char *
    mov     ecx, ebx
    mov     [esi+8], ax
    call    sub_4C46C0
    mov     [esi+0Ah], ax
    mov     eax, dword_5122B4
    movsx   ecx, [esp+eax+528h+var_500]
    push    ecx                             ; int
    call    _isdigit
    add     esp, 4
    test    eax, eax
    jnz     short loc_437145
    mov     eax, [esp+528h+var_514]
    inc     eax
    mov     [esp+528h+var_514], eax
    jmp     short loc_437158
    ; ---------------------------------------------------------------------------

    loc_437145:                             ; CODE XREF: sub_436C30+508j
    mov     edx, dword_5122B4
    lea     eax, [esp+edx+528h+var_500]
    push    eax                             ; char *
    call    _atoi
    add     esp, 4

    loc_437158:                             ; CODE XREF: sub_436C30+513j
    test    eax, eax
    mov     [esi+4], eax
    jle     short loc_437163
    dec     eax
    mov     [esi+4], eax

    loc_437163:                             ; CODE XREF: sub_436C30+47Ej
                                            ; sub_436C30+4C8j ...
    mov     ecx, [esp+528h+var_510]
    mov     eax, [esp+528h+var_518]
    mov     esi, [esp+528h+var_50C]
    inc     ebp
    add     ecx, 0Ch
    cmp     ebp, eax
    mov     [esp+528h+var_510], ecx
    jl      loc_437075

    loc_43717F:                             ; CODE XREF: sub_436C30+43Bj
    mov     ecx, [esp+528h+var_504]
    push    offset aFeatures                ; char *
    call    sub_4C4470
    mov     edi, eax
    xor     ebx, ebx
    cmp     edi, ebx
    mov     [esp+528h+var_508], edi
    jz      short loc_4371A8
    mov     ecx, edi
    call    sub_4C4450
    mov     ebp, eax
    mov     [esp+528h+var_518], ebp
    jmp     short loc_4371AE
    ; ---------------------------------------------------------------------------

    loc_4371A8:                             ; CODE XREF: sub_436C30+567j
    mov     [esp+528h+var_518], ebx
    mov     ebp, ebx

    loc_4371AE:                             ; CODE XREF: sub_436C30+576j
    mov     eax, [esi+0DBCh]
    mov     [esi+0DC0h], ebp
    cmp     eax, ebx
    jz      short loc_4371C7
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4371C7:                             ; CODE XREF: sub_436C30+58Cj
    mov     ecx, ebp
    shl     ecx, 4
    add     ecx, ebp
    shl     ecx, 3
    push    ecx
    push    offset aMissionfeature          ; "MISSIONFEATURE DATA"
    call    sub_4D83B0
    add     esp, 8
    mov     [esi+0DBCh], eax
    test    ebp, ebp
    jle     loc_437270
    xor     ebp, ebp
    jmp     short loc_4371F5
    ; ---------------------------------------------------------------------------

    loc_4371F1:                             ; CODE XREF: sub_436C30+63Ej
    mov     edi, [esp+528h+var_508]

    loc_4371F5:                             ; CODE XREF: sub_436C30+5BFj
    mov     edx, [esp+528h+var_50C]
    push    ebx
    mov     ecx, edi
    mov     esi, [edx+0DBCh]
    add     esi, ebp
    call    sub_4C44C0
    push    offset Data                     ; int
    mov     edi, eax
    push    80h                             ; size_t
    push    offset aFeaturename             ; char *
    push    esi                             ; char *
    mov     ecx, edi
    call    sub_4C48C0
    test    eax, eax
    jnz     short loc_437228
    mov     [esi], al

    loc_437228:                             ; CODE XREF: sub_436C30+5F4j
    push    0FFFFFFFFh                      ; int
    push    offset aXpos                    ; char *
    mov     ecx, edi
    call    sub_4C46C0
    push    0FFFFFFFFh                      ; int
    push    offset aZpos                    ; char *
    mov     ecx, edi
    mov     [esi+80h], eax
    call    sub_4C46C0
    mov     ecx, [esi+80h]
    mov     [esi+84h], eax
    test    ecx, ecx
    jl      short loc_43725E
    test    eax, eax
    jge     short loc_437261

    loc_43725E:                             ; CODE XREF: sub_436C30+628j
    mov     byte ptr [esi], 0

    loc_437261:                             ; CODE XREF: sub_436C30+62Cj
    mov     eax, [esp+528h+var_518]
    inc     ebx
    add     ebp, 88h
    cmp     ebx, eax
    jl      short loc_4371F1

    loc_437270:                             ; CODE XREF: sub_436C30+2Ej
                                            ; sub_436C30+45j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 518h
    retn    8
    sub_436C30 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, ecx
    push    edi
    xor     edi, edi
    mov     eax, [esi+0DACh]
    cmp     eax, edi
    jz      short loc_437299
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_437299:                             ; CODE XREF: .text:0043728Ej
    mov     eax, [esi+0DB4h]
    mov     [esi+0DACh], edi
    cmp     eax, edi
    mov     [esi+0DB0h], edi
    jz      short loc_4372B8
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4372B8:                             ; CODE XREF: .text:004372ADj
    mov     eax, [esi+0DBCh]
    mov     [esi+0DB4h], edi
    cmp     eax, edi
    mov     [esi+0DB8h], edi
    jz      short loc_4372D7
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4372D7:                             ; CODE XREF: .text:004372CCj
    mov     eax, [esi+0C14h]
    mov     [esi+0DBCh], edi
    cmp     eax, edi
    mov     [esi+0DC0h], edi
    jz      short loc_4372FC
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     [esi+0C14h], edi

    loc_4372FC:                             ; CODE XREF: .text:004372EBj
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437300 proc near                    ; CODE XREF: sub_47AE60+184p
    mov     edx, [ecx+0DB8h]
    xor     eax, eax
    test    edx, edx
    jle     short locret_43731E
    mov     ecx, [ecx+0DB4h]

    loc_437312:                             ; CODE XREF: sub_437300+1Cj
    cmp     dword ptr [ecx], 1
    jnz     short loc_437318
    inc     eax

    loc_437318:                             ; CODE XREF: sub_437300+15j
    add     ecx, 0Ch
    dec     edx
    jnz     short loc_437312

    locret_43731E:                          ; CODE XREF: sub_437300+Aj
    retn
    sub_437300 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437320 proc near                    ; CODE XREF: sub_496EE0+C9p
                                            ; sub_497180+5CCp

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    esi
    mov     esi, [ecx+0DB8h]
    xor     eax, eax
    push    edi
    test    esi, esi
    jle     short loc_43738C
    mov     ebx, [ecx+0DB4h]
    mov     edi, [esp+4+arg_4]
    mov     edx, ebx

    loc_43733B:                             ; CODE XREF: sub_437320+2Bj
    cmp     dword ptr [edx], 1
    jnz     short loc_437345
    cmp     [edx+4], edi
    jz      short loc_437355

    loc_437345:                             ; CODE XREF: sub_437320+1Ej
    inc     eax
    add     edx, 0Ch
    cmp     eax, esi
    jl      short loc_43733B
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_437355:                             ; CODE XREF: sub_437320+23j
    lea     eax, [eax+eax*2]
    mov     edx, [esp+4+arg_0]
    shl     eax, 2
    movsx   esi, word ptr [ebx+eax+8]
    shl     esi, 10h
    mov     [edx], esi
    mov     ecx, [ecx+0DB4h]
    movsx   eax, word ptr [ecx+eax+0Ah]
    shl     eax, 10h
    mov     [edx+8], eax
    mov     dword ptr [edx+4], 0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_43738C:                             ; CODE XREF: sub_437320+Dj
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    8
    sub_437320 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4373A0 proc near                    ; CODE XREF: .text:00440D4Fp
                                            ; sub_444CB0+17Ep ...

    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_30= dword ptr -30h
    var_24= dword ptr -24h
    var_20= dword ptr -20h

    sub     esp, 4Ch
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     ecx, [ebx+0C1Ch]
    push    edi
    test    ecx, ecx
    jz      short loc_4373C3
    mov     eax, [ebx+0C20h]
    xor     eax, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 4Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4373C3:                             ; CODE XREF: sub_4373A0+11j
    lea     edx, [ebx+204h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    mov     esi, dword_5122C4
    not     ecx
    dec     ecx
    cmp     eax, ecx
    mov     eax, dword_5122C8
    sbb     edi, edi
    and     edi, edx
    cmp     esi, eax
    mov     [esp+5Ch+var_4C], edi
    jz      short loc_43740E

    loc_4373EE:                             ; CODE XREF: sub_4373A0+6Cj
    mov     ecx, [esi]
    push    edi                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_437564
    mov     eax, dword_5122C8
    add     esi, 8
    cmp     esi, eax
    jnz     short loc_4373EE

    loc_43740E:                             ; CODE XREF: sub_4373A0+4Cj
    push    edi
    call    sub_4BB5B0
    mov     edi, eax
    test    edi, edi
    jnz     short loc_437422
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 4Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_437422:                             ; CODE XREF: sub_4373A0+78j
    lea     edx, [esp+5Ch+var_40]
    push    40h
    push    edx
    push    edi
    call    sub_4BB7C0
    cmp     [esp+5Ch+var_40], 2000h
    jz      short loc_437443
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 4Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_437443:                             ; CODE XREF: sub_4373A0+97j
    lea     eax, [esp+5Ch+var_40]
    push    40h
    push    eax
    call    sub_4B6BA0
    mov     esi, [ebx+0C1Ch]
    xor     esi, eax
    mov     [ebx+0C1Ch], esi
    mov     esi, [esp+5Ch+var_3C]
    imul    esi, [esp+5Ch+var_38]
    shl     esi, 2
    push    esi
    push    offset aRawPlotData             ; "Raw Plot Data"
    call    sub_4D83B0
    mov     ecx, [esp+64h+var_30]
    add     esp, 8
    mov     ebp, eax
    push    ecx
    push    edi
    call    sub_4BB710
    push    esi
    push    ebp
    push    edi
    call    sub_4BB7C0
    push    esi
    push    ebp
    call    sub_4B6BA0
    mov     edx, [ebx+0C1Ch]
    push    ebp                             ; int
    xor     edx, eax
    mov     [ebx+0C1Ch], edx
    call    sub_4D85A0
    mov     eax, [esp+60h+var_24]
    add     esp, 4
    mov     esi, eax
    shl     esi, 5
    add     esi, eax
    shl     esi, 2
    test    esi, esi
    jle     short loc_4374FD
    push    esi
    push    offset aRawFeatureData          ; "Raw Feature Data"
    call    sub_4D83B0
    mov     edx, [esp+64h+var_20]
    add     esp, 8
    mov     ebp, eax
    push    edx
    push    edi
    call    sub_4BB710
    push    esi
    push    ebp
    push    edi
    call    sub_4BB7C0
    push    esi
    push    ebp
    call    sub_4B6BA0
    mov     edx, [ebx+0C1Ch]
    push    ebp                             ; int
    xor     edx, eax
    mov     [ebx+0C1Ch], edx
    call    sub_4D85A0
    add     esp, 4

    loc_4374FD:                             ; CODE XREF: sub_4373A0+11Aj
    push    edi
    call    sub_4BB5D0
    mov     eax, [esp+5Ch+var_4C]
    lea     ecx, [esp+5Ch+var_4C]
    push    eax
    call    sub_4C91B0
    push    eax
    lea     ecx, [esp+60h+var_48]
    call    sub_4C91A0
    mov     ecx, [ebx+0C1Ch]
    mov     eax, dword_5122C8
    lea     edx, [esp+5Ch+var_48]
    mov     [esp+5Ch+var_44], ecx
    push    edx
    push    1
    push    eax
    mov     ecx, offset byte_5122C0
    call    sub_437580
    lea     ecx, [esp+5Ch+var_48]
    call    sub_4C9390
    lea     ecx, [esp+5Ch+var_4C]
    call    sub_4C9390
    mov     eax, [ebx+0C20h]
    mov     ecx, [ebx+0C1Ch]
    xor     eax, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 4Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_437564:                             ; CODE XREF: sub_4373A0+5Cj
    mov     esi, [esi+4]
    mov     eax, [ebx+0C20h]
    mov     [ebx+0C1Ch], esi
    xor     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 4Ch
    retn
    sub_4373A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437580 proc near                    ; CODE XREF: sub_4373A0+197p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    mov     eax, [ecx+0Ch]
    push    ebx
    mov     edx, [esp+10h+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     [esp+1Ch+var_C], ecx
    sub     eax, edi
    sar     eax, 3
    cmp     eax, edx
    jnb     loc_4376ED
    mov     ecx, [ecx+4]
    test    ecx, ecx
    jnz     short loc_4375AD
    xor     eax, eax
    jmp     short loc_4375B4
    ; ---------------------------------------------------------------------------

    loc_4375AD:                             ; CODE XREF: sub_437580+27j
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 3

    loc_4375B4:                             ; CODE XREF: sub_437580+2Bj
    cmp     edx, eax
    jnb     short loc_4375C9
    test    ecx, ecx
    jnz     short loc_4375C0
    xor     eax, eax
    jmp     short loc_4375CB
    ; ---------------------------------------------------------------------------

    loc_4375C0:                             ; CODE XREF: sub_437580+3Aj
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 3
    jmp     short loc_4375CB
    ; ---------------------------------------------------------------------------

    loc_4375C9:                             ; CODE XREF: sub_437580+36j
    mov     eax, edx

    loc_4375CB:                             ; CODE XREF: sub_437580+3Ej
                                            ; sub_437580+47j
    test    ecx, ecx
    jnz     short loc_4375D3
    xor     edi, edi
    jmp     short loc_4375D8
    ; ---------------------------------------------------------------------------

    loc_4375D3:                             ; CODE XREF: sub_437580+4Dj
    sub     edi, ecx
    sar     edi, 3

    loc_4375D8:                             ; CODE XREF: sub_437580+51j
    add     eax, edi
    test    eax, eax
    mov     [esp+1Ch+var_4], eax
    jge     short loc_4375E4
    xor     eax, eax

    loc_4375E4:                             ; CODE XREF: sub_437580+60j
    lea     ecx, ds:0[eax*8]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     edx, [esp+20h+var_C]
    mov     edi, [esp+20h+arg_0]
    add     esp, 4
    mov     [esp+1Ch+var_8], eax
    mov     esi, [edx+4]
    mov     ebx, eax
    cmp     esi, edi
    jz      short loc_43761F

    loc_437609:                             ; CODE XREF: sub_437580+9Dj
    test    ebx, ebx
    jz      short loc_437615
    push    esi
    mov     ecx, ebx
    call    sub_437820

    loc_437615:                             ; CODE XREF: sub_437580+8Bj
    add     esi, 8
    add     ebx, 8
    cmp     esi, edi
    jnz     short loc_437609

    loc_43761F:                             ; CODE XREF: sub_437580+87j
    mov     ebp, [esp+1Ch+arg_4]
    mov     esi, ebx
    test    ebp, ebp
    jbe     short loc_437643

    loc_437629:                             ; CODE XREF: sub_437580+BDj
    test    esi, esi
    jz      short loc_437639
    mov     eax, [esp+1Ch+arg_8]
    mov     ecx, esi
    push    eax
    call    sub_437820

    loc_437639:                             ; CODE XREF: sub_437580+ABj
    add     esi, 8
    dec     ebp
    jnz     short loc_437629
    mov     ebp, [esp+1Ch+arg_4]

    loc_437643:                             ; CODE XREF: sub_437580+A7j
    mov     ecx, [esp+1Ch+var_C]
    lea     eax, ds:0[ebp*8]
    mov     ebp, [ecx+8]
    lea     esi, [eax+ebx]
    cmp     edi, ebp
    jz      short loc_437674
    sub     edi, ebx
    add     edi, esi
    sub     edi, eax

    loc_43765E:                             ; CODE XREF: sub_437580+F2j
    test    esi, esi
    jz      short loc_43766A
    push    edi
    mov     ecx, esi
    call    sub_437820

    loc_43766A:                             ; CODE XREF: sub_437580+E0j
    add     edi, 8
    add     esi, 8
    cmp     edi, ebp
    jnz     short loc_43765E

    loc_437674:                             ; CODE XREF: sub_437580+D6j
    mov     edi, [esp+1Ch+var_C]
    mov     ebx, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, ebx
    jz      short loc_437690

    loc_437682:                             ; CODE XREF: sub_437580+10Ej
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 8
    cmp     esi, ebx
    jnz     short loc_437682

    loc_437690:                             ; CODE XREF: sub_437580+100j
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+20h+var_8]
    mov     eax, [esp+20h+var_4]
    add     esp, 4
    lea     ecx, [edx+eax*8]
    mov     [edi+0Ch], ecx
    mov     ecx, [edi+4]
    test    ecx, ecx
    jnz     short loc_4376CC
    mov     ecx, [esp+1Ch+arg_4]
    xor     eax, eax
    add     ecx, eax
    mov     [edi+4], edx
    lea     eax, [edx+ecx*8]
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4376CC:                             ; CODE XREF: sub_437580+12Fj
    mov     eax, [edi+8]
    mov     [edi+4], edx
    sub     eax, ecx
    mov     ecx, [esp+1Ch+arg_4]
    sar     eax, 3
    add     ecx, eax
    lea     eax, [edx+ecx*8]
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4376ED:                             ; CODE XREF: sub_437580+1Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     eax, edi
    sub     eax, ebp
    sar     eax, 3
    cmp     eax, edx
    jnb     short loc_437779
    lea     eax, ds:0[edx*8]
    cmp     ebp, edi
    mov     [esp+1Ch+arg_0], eax
    lea     ebx, [ebp+eax+0]
    jz      short loc_437731
    mov     esi, ebx
    sub     esi, eax

    loc_437713:                             ; CODE XREF: sub_437580+1ABj
    test    ebx, ebx
    jz      short loc_437723
    push    esi
    mov     ecx, ebx
    call    sub_437820
    mov     edx, [esp+1Ch+arg_4]

    loc_437723:                             ; CODE XREF: sub_437580+195j
    add     esi, 8
    add     ebx, 8
    cmp     esi, edi
    jnz     short loc_437713
    mov     ecx, [esp+1Ch+var_C]

    loc_437731:                             ; CODE XREF: sub_437580+18Dj
    mov     esi, [ecx+8]
    mov     ebx, [esp+1Ch+arg_8]
    mov     eax, esi
    sub     eax, ebp
    sar     eax, 3
    sub     edx, eax
    jz      short loc_43775B
    mov     edi, edx

    loc_437745:                             ; CODE XREF: sub_437580+1D5j
    test    esi, esi
    jz      short loc_437751
    push    ebx
    mov     ecx, esi
    call    sub_437820

    loc_437751:                             ; CODE XREF: sub_437580+1C7j
    add     esi, 8
    dec     edi
    jnz     short loc_437745
    mov     ecx, [esp+1Ch+var_C]

    loc_43775B:                             ; CODE XREF: sub_437580+1C1j
    mov     edi, [ecx+8]
    mov     esi, ebp
    cmp     ebp, edi
    jz      loc_4377EA

    loc_437768:                             ; CODE XREF: sub_437580+1F5j
    push    ebx
    mov     ecx, esi
    call    sub_437800
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_437768
    jmp     short loc_4377EA
    ; ---------------------------------------------------------------------------

    loc_437779:                             ; CODE XREF: sub_437580+17Aj
    test    edx, edx
    jbe     short loc_4377F5
    shl     edx, 3
    mov     esi, edi
    mov     ebx, edi
    sub     esi, edx
    mov     [esp+1Ch+arg_0], edx
    cmp     esi, edi
    jz      short loc_4377AC

    loc_43778E:                             ; CODE XREF: sub_437580+222j
    test    ebx, ebx
    jz      short loc_43779A
    push    esi
    mov     ecx, ebx
    call    sub_437820

    loc_43779A:                             ; CODE XREF: sub_437580+210j
    add     esi, 8
    add     ebx, 8
    cmp     esi, edi
    jnz     short loc_43778E
    mov     edx, [esp+1Ch+arg_0]
    mov     ecx, [esp+1Ch+var_C]

    loc_4377AC:                             ; CODE XREF: sub_437580+20Cj
    mov     edi, [ecx+8]
    mov     esi, edi
    sub     esi, edx
    cmp     ebp, esi
    jz      short loc_4377C9

    loc_4377B7:                             ; CODE XREF: sub_437580+247j
    sub     esi, 8
    sub     edi, 8
    push    esi
    mov     ecx, edi
    call    sub_437800
    cmp     esi, ebp
    jnz     short loc_4377B7

    loc_4377C9:                             ; CODE XREF: sub_437580+235j
    mov     edx, [esp+1Ch+arg_0]
    mov     esi, ebp
    lea     edi, [ebp+edx+0]
    cmp     ebp, edi
    jz      short loc_4377EA
    mov     ebx, [esp+1Ch+arg_8]

    loc_4377DB:                             ; CODE XREF: sub_437580+268j
    push    ebx
    mov     ecx, esi
    call    sub_437800
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_4377DB

    loc_4377EA:                             ; CODE XREF: sub_437580+1E2j
                                            ; sub_437580+1F7j ...
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, [esp+1Ch+arg_0]
    add     [eax+8], ecx

    loc_4377F5:                             ; CODE XREF: sub_437580+1FBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_437580 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437800 proc near                    ; CODE XREF: sub_437580+1EBp
                                            ; sub_437580+240p ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_4C93B0
    mov     eax, [edi+4]
    pop     edi
    mov     [esi+4], eax
    mov     eax, esi
    pop     esi
    retn    4
    sub_437800 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437820 proc near                    ; CODE XREF: sub_437580+90p
                                            ; sub_437580+B4p ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_4C91A0
    mov     eax, [edi+4]
    pop     edi
    mov     [esi+4], eax
    mov     eax, esi
    pop     esi
    retn    4
    sub_437820 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437840 proc near                    ; CODE XREF: sub_485E90+7Ap
                                            ; sub_485F50+162p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    mov     ebx, [esp+8+arg_0]
    push    ebp
    push    esi
    mov     eax, [ebx+92h]
    push    edi
    fld     dword ptr [eax+1CEh]
    fcomp   ds:flt_4FD270
    fnstsw  ax
    test    ah, 41h
    jnz     loc_437907
    mov     ecx, [ebx+7Eh]
    mov     [esp+14h+arg_0], 0
    movsx   edi, word ptr [ebx+78h]
    mov     [esp+14h+var_4], ecx
    movsx   eax, word ptr [esp+14h+var_4+2]
    add     eax, edi
    cmp     edi, eax
    jge     short loc_4378C6
    movsx   ebp, cx

    loc_437887:                             ; CODE XREF: sub_437840+84j
    movsx   esi, word ptr [ebx+76h]
    lea     ecx, [ebp+esi+0]
    cmp     esi, ecx
    jge     short loc_4378B6

    loc_437893:                             ; CODE XREF: sub_437840+74j
    push    edi
    push    esi
    call    sub_481550
    test    eax, eax
    jz      short loc_4378A9
    movzx   dx, byte ptr [eax+7]
    inc     edx
    add     word ptr [esp+14h+arg_0+2], dx

    loc_4378A9:                             ; CODE XREF: sub_437840+5Cj
    movsx   eax, word ptr [ebx+76h]
    mov     ecx, ebp
    inc     esi
    add     ecx, eax
    cmp     esi, ecx
    jl      short loc_437893

    loc_4378B6:                             ; CODE XREF: sub_437840+51j
    movsx   edx, word ptr [ebx+78h]
    movsx   eax, word ptr [esp+14h+var_4+2]
    inc     edi
    add     edx, eax
    cmp     edi, edx
    jl      short loc_437887

    loc_4378C6:                             ; CODE XREF: sub_437840+42j
    mov     eax, [ebx+92h]
    mov     ecx, [ebx+9Ah]
    test    ecx, ecx
    fld     dword ptr [eax+1CEh]
    fild    [esp+14h+arg_0]
    fmulp   st(1), st
    fmul    ds:dbl_4FD278
    fstp    dword ptr [ebx+58h]
    jz      short loc_437907
    movsx   edx, word ptr [esp+14h+arg_0+2]
    push    0
    push    0
    push    0
    push    edx
    push    1
    push    0
    push    0
    push    offset aSetspeed                ; "SetSpeed"
    call    sub_4B0A70

    loc_437907:                             ; CODE XREF: sub_437840+20j
                                            ; sub_437840+A9j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_437840 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437910 proc near                    ; CODE XREF: sub_48AD30+94p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    mov     eax, [esi+92h]
    fld     dword ptr [eax+1D2h]
    fcomp   ds:flt_4FD270
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_43798F
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EE2h]
    test    ecx, ecx
    jz      short loc_43798F
    xor     ecx, ecx
    push    0
    mov     cx, [eax+37ED8h]
    push    0
    push    0
    push    ecx
    mov     ecx, [esi+9Ah]
    push    1
    push    0
    push    0
    push    offset aSetdirection            ; "SetDirection"
    call    sub_4B0A70
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esi+9Ah]
    push    0
    push    0
    mov     eax, [edx+37EDAh]
    push    0
    shl     eax, 4
    push    eax
    push    1
    push    0
    push    0
    push    offset aSetspeed                ; "SetSpeed"
    call    sub_4B0A70

    loc_43798F:                             ; CODE XREF: sub_437910+1Cj
                                            ; sub_437910+2Bj
    pop     esi
    retn    4
    sub_437910 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4379A0 proc near                    ; CODE XREF: .text:004205F5p
                                            ; sub_458160+3p
    mov     eax, ecx
    xor     ecx, ecx
    mov     [eax+4], ecx
    mov     [eax+0Ch], ecx
    retn
    sub_4379A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4379B0 proc near                    ; CODE XREF: sub_420620+2E5p
                                            ; sub_458180+8p

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4379CB
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+4], 0

    loc_4379CB:                             ; CODE XREF: sub_4379B0+9j
    mov     edi, [esp+4+arg_0]
    push    edi
    push    offset aCmemorycacheCc          ; "CMemoryCache CCH"
    call    sub_4D83B0
    mov     [esi+4], eax
    mov     [esi], edi
    mov     [esi+8], eax
    mov     dword ptr [eax], 0
    mov     eax, [esi+8]
    mov     ecx, [esi]
    add     esp, 8
    mov     [eax+4], ecx
    mov     eax, 1
    pop     edi
    pop     esi
    retn    4
    sub_4379B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437A00 proc near                    ; CODE XREF: sub_420960+1Cp
    push    esi
    mov     esi, ecx
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_437A1A
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+4], 0

    loc_437A1A:                             ; CODE XREF: sub_437A00+8j
    pop     esi
    retn
    sub_437A00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437A20 proc near                    ; CODE XREF: .text:00420615j
                                            ; sub_4581C0+15p
    mov     eax, [ecx+4]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    retn
    sub_437A20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437A30 proc near                    ; CODE XREF: sub_421620+78p
                                            ; sub_437B50+1Ap ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    ebx
    push    ebp
    push    esi
    xor     esi, esi
    push    edi
    test    eax, eax
    jg      short loc_437A4D
    mov     eax, [esp+10h+arg_0]
    mov     [eax], esi
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_437A4D:                             ; CODE XREF: sub_437A30+Cj
    mov     edx, [esp+10h+arg_0]
    lea     ebx, [eax+8]
    mov     eax, [edx]
    test    eax, eax
    jz      short loc_437A5D
    mov     eax, [eax-4]

    loc_437A5D:                             ; CODE XREF: sub_437A30+28j
    cmp     eax, ebx
    jge     loc_437B1B
    mov     eax, [ecx]
    cmp     ebx, eax
    jle     short loc_437A7A
    mov     dword ptr [edx], 0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_437A7A:                             ; CODE XREF: sub_437A30+39j
    mov     edx, [ecx+4]
    lea     edi, [edx+eax]
    mov     eax, [ecx+8]
    lea     ebp, [ebx+eax]
    cmp     ebp, edi
    jle     short loc_437AB5
    cmp     eax, edi
    mov     ebp, edx
    jge     short loc_437AB7

    loc_437A90:                             ; CODE XREF: sub_437A30+81j
    mov     edx, [eax]
    test    edx, edx
    jz      short loc_437AA3
    lea     edi, [eax+8]
    cmp     [edx], edi
    jnz     short loc_437AA3
    mov     dword ptr [edx], 0

    loc_437AA3:                             ; CODE XREF: sub_437A30+64j
                                            ; sub_437A30+6Bj
    mov     edx, [eax+4]
    mov     edi, [ecx+4]
    add     eax, edx
    mov     edx, [ecx]
    add     edx, edi
    cmp     eax, edx
    jl      short loc_437A90
    jmp     short loc_437AB7
    ; ---------------------------------------------------------------------------

    loc_437AB5:                             ; CODE XREF: sub_437A30+58j
    mov     ebp, eax

    loc_437AB7:                             ; CODE XREF: sub_437A30+5Ej
                                            ; sub_437A30+83j
    test    ebx, ebx
    mov     eax, ebp
    jle     short loc_437ADE

    loc_437ABD:                             ; CODE XREF: sub_437A30+ACj
    mov     edx, [eax+4]
    add     esi, edx
    mov     edx, [eax]
    test    edx, edx
    jz      short loc_437AD5
    lea     edi, [eax+8]
    cmp     [edx], edi
    jnz     short loc_437AD5
    mov     dword ptr [edx], 0

    loc_437AD5:                             ; CODE XREF: sub_437A30+96j
                                            ; sub_437A30+9Dj
    mov     edi, [eax+4]
    add     eax, edi
    cmp     esi, ebx
    jl      short loc_437ABD

    loc_437ADE:                             ; CODE XREF: sub_437A30+8Bj
    mov     edx, esi
    sub     edx, ebx
    cmp     edx, 8
    jbe     short loc_437AF6
    lea     eax, [ebp+ebx+0]
    mov     dword ptr [eax], 0
    mov     [eax+4], edx
    jmp     short loc_437B09
    ; ---------------------------------------------------------------------------

    loc_437AF6:                             ; CODE XREF: sub_437A30+B5j
    mov     edx, [ecx+4]
    mov     ebx, esi
    lea     eax, [ebp+esi+0]
    mov     esi, [ecx]
    add     esi, edx
    cmp     eax, esi
    jl      short loc_437B09
    mov     eax, edx

    loc_437B09:                             ; CODE XREF: sub_437A30+C4j
                                            ; sub_437A30+D5j
    mov     [ecx+8], eax
    mov     eax, [esp+10h+arg_0]
    mov     [ebp+0], eax
    mov     [ebp+4], ebx
    add     ebp, 8
    mov     [eax], ebp

    loc_437B1B:                             ; CODE XREF: sub_437A30+2Fj
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    8
    sub_437A30 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    test    eax, eax
    jnz     short loc_437B3B
    retn    4
    ; ---------------------------------------------------------------------------

    loc_437B3B:                             ; CODE XREF: .text:00437B36j
    mov     eax, [eax-4]
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437B50 proc near                    ; CODE XREF: sub_4586A0+62p
                                            ; sub_45A790+DBp

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+0Ch+arg_8]
    mov     esi, edi
    mov     ebp, [esp+0Ch+arg_0]
    imul    esi, ebx
    lea     eax, [esi+18h]
    push    eax
    push    ebp
    call    sub_437A30
    test    eax, eax
    jnz     short loc_437B7A
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_437B7A:                             ; CODE XREF: sub_437B50+21j
    mov     eax, [ebp+0]
    xor     ecx, ecx
    cmp     eax, ecx
    jnz     short loc_437B8C
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_437B8C:                             ; CODE XREF: sub_437B50+31j
    mov     [eax+14h], ecx
    mov     [eax+4], cx
    mov     [eax+6], cx
    mov     [eax+0Ah], cl
    mov     [eax+0Bh], cl
    mov     [eax+0Ch], ecx
    mov     [eax+9], cl
    mov     [eax+2], di
    mov     ecx, esi
    lea     edi, [eax+18h]
    mov     edx, ecx
    mov     [eax], bx
    mov     [eax+10h], edi
    mov     byte ptr [eax+8], 1
    mov     eax, 1010101h
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    0Ch
    sub_437B50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437BE0 proc near                    ; CODE XREF: sub_4586A0+79p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+0Ch+arg_8]
    mov     esi, edi
    mov     ebp, [esp+0Ch+arg_0]
    imul    esi, ebx
    lea     eax, [esi+esi+18h]
    push    eax
    push    ebp
    call    sub_437A30
    test    eax, eax
    jnz     short loc_437C0B
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_437C0B:                             ; CODE XREF: sub_437BE0+22j
    mov     edx, [ebp+0]
    xor     ecx, ecx
    cmp     edx, ecx
    jnz     short loc_437C1D
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_437C1D:                             ; CODE XREF: sub_437BE0+32j
    mov     [edx+4], cx
    mov     [edx+6], cx
    mov     [edx+0Ah], cl
    mov     [edx+0Bh], cl
    mov     [edx+0Ch], ecx
    mov     [edx+9], cl
    lea     eax, [edx+18h]
    mov     ecx, esi
    mov     [edx], bx
    mov     [edx+2], di
    mov     ebx, ecx
    mov     [edx+10h], eax
    lea     edi, [eax+esi]
    xor     eax, eax
    shr     ecx, 2
    mov     [edx+14h], edi
    rep stosd
    mov     ecx, ebx
    and     ecx, 3
    rep stosb
    mov     edi, [edx+10h]
    mov     ecx, esi
    mov     byte ptr [edx+8], 1
    mov     edx, ecx
    mov     eax, 1010101h
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    0Ch
    sub_437BE0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437C80 proc near                    ; CODE XREF: .text:0041644Ap
                                            ; .text:0041653Ap ...
    mov     eax, [ecx]
    lea     edx, [ecx+0Ch]
    sub     eax, 8
    push    eax
    push    edx
    call    sub_437A30
    retn
    sub_437C80 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437C90 proc near                    ; CODE XREF: sub_45AAA0+3Bp
                                            ; sub_45AAA0+50p

    arg_0= dword ptr  4

    mov     eax, [ecx+4]
    push    esi
    mov     esi, [ecx]
    xor     edx, edx
    test    esi, esi
    jle     short loc_437CBE
    mov     esi, [esp+4+arg_0]
    push    edi

    loc_437CA1:                             ; CODE XREF: sub_437C90+2Bj
    mov     edi, [eax+4]
    add     edx, edi
    mov     edi, [eax]
    cmp     edi, esi
    jnz     short loc_437CB2
    mov     dword ptr [eax], 0

    loc_437CB2:                             ; CODE XREF: sub_437C90+1Aj
    mov     edi, [eax+4]
    add     eax, edi
    mov     edi, [ecx]
    cmp     edx, edi
    jl      short loc_437CA1
    pop     edi

    loc_437CBE:                             ; CODE XREF: sub_437C90+Aj
    pop     esi
    retn    4
    sub_437C90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437CD0 proc near                    ; CODE XREF: sub_4917D0+1EEp
    mov     eax, dword_512314
    push    offset dword_5122F0             ; char *
    mov     dword_512318, 0
    mov     dword_5122E8, eax
    call    sub_49E5B0
    test    eax, eax
    mov     dword_512328, eax
    jnz     short loc_437D0A
    mov     ecx, TAdynmemStructPtr
    add     ecx, 2CF3h
    mov     dword_512328, ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_437D0A:                             ; CODE XREF: sub_437CD0+25j
    test    byte ptr [eax+111h], 20h
    jnz     short locret_437D25
    mov     edx, TAdynmemStructPtr
    add     edx, 2CF3h
    mov     dword_512328, edx

    locret_437D25:                          ; CODE XREF: sub_437CD0+41j
    retn
    sub_437CD0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_42. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437D40 proc near                    ; CODE XREF: .text:0041777Ap
                                            ; sub_435DA0+A59p
    mov     dword_51232C, 1
    retn
    sub_437D40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437D50 proc near                    ; CODE XREF: .text:00417782p
                                            ; sub_435DA0+A60p
    mov     dword_51232C, 0
    retn
    sub_437D50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437D60 proc near                    ; CODE XREF: sub_435DA0+A73p

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    fld     ds:flt_4FD280
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, offset dword_5122F0
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [ebx+20h]
    mov     dword_512310, ecx
    fdiv    dword ptr [ebx+24h]
    call    __ftol
    mov     dword_512314, eax
    fld     dword ptr [ebx+28h]
    fmul    ds:flt_4FD280
    call    __ftol
    mov     dword_512324, eax
    fld     dword ptr [ebx+2Ch]
    fmul    ds:flt_4FD280
    call    __ftol
    pop     edi
    pop     esi
    mov     dword_512338, eax
    pop     ebx
    retn    4
    sub_437D60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_437DE0 proc near                    ; CODE XREF: .text:00495594p

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     ecx, TAdynmemStructPtr
    mov     eax, dword_5122E8
    sub     esp, 1Ch
    mov     edx, [ecx+38A47h]
    push    ebx
    push    ebp
    xor     ebp, ebp
    push    esi
    cmp     eax, edx
    push    edi
    ja      loc_437F0A
    mov     eax, dword_512324
    mov     dword_512318, 1
    mov     edx, [ecx+38A47h]
    add     eax, edx
    mov     edx, dword_512338
    add     edx, eax
    mov     dword_51231C, eax
    mov     dword_5122E8, edx
    mov     eax, [ecx+38A47h]
    mov     dword_512330, eax
    call    _rand
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    8000h
    imul    dword ptr [ecx+14237h]
    push    edx
    push    eax
    call    __alldiv
    mov     esi, eax
    call    _rand
    mov     edx, TAdynmemStructPtr
    push    ebp
    push    8000h
    imul    dword ptr [edx+14233h]
    push    edx
    push    eax
    call    __alldiv
    mov     word ptr [esp+2Ch+var_1C], ax
    mov     word ptr [esp+2Ch+var_1C+2], si
    mov     eax, [esp+2Ch+var_1C]
    mov     dword_512334, eax
    call    _rand
    cdq
    push    ebp
    push    0Ah
    push    edx
    push    eax
    call    __allmul
    push    ebp
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     esi, eax
    sub     esi, 0Fh
    call    _rand
    cdq
    push    ebp
    push    1Eh
    push    edx
    push    eax
    call    __allmul
    push    ebp
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     edx, dword_512334
    add     si, word ptr dword_512334+2
    sub     eax, 0Fh
    mov     word ptr [esp+2Ch+var_1C], ax
    mov     ecx, [esp+2Ch+var_1C]
    add     ecx, edx
    mov     word ptr [esp+2Ch+var_1C+2], si
    mov     word ptr [esp+2Ch+var_1C], cx
    mov     eax, [esp+2Ch+var_1C]
    mov     dword_512320, eax
    mov     eax, dword_51232C
    cmp     eax, ebp
    jnz     short loc_437F04
    mov     dword_512318, ebp

    loc_437F04:                             ; CODE XREF: sub_437DE0+11Cj
    mov     ecx, TAdynmemStructPtr

    loc_437F0A:                             ; CODE XREF: sub_437DE0+1Cj
    cmp     dword_512318, ebp
    jz      loc_438065
    mov     edx, dword_512330
    mov     eax, [ecx+38A47h]
    cmp     edx, eax
    ja      loc_43804F
    mov     eax, dword_512314
    mov     edx, [ecx+38A47h]
    movsx   ecx, word ptr dword_512334
    add     eax, edx
    mov     [esp+2Ch+var_8], 0FFF10000h
    movsx   edx, word ptr dword_512320
    sub     ecx, edx
    mov     dword_512330, eax
    shl     ecx, 14h
    mov     eax, 0B60B60B7h
    imul    ecx
    add     edx, ecx
    sar     edx, 6
    movsx   ecx, word ptr dword_512334+2
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 0B60B60B7h
    mov     [esp+2Ch+var_C], edx
    movsx   edx, word ptr dword_512320+2
    sub     ecx, edx
    shl     ecx, 14h
    imul    ecx
    add     edx, ecx
    sar     edx, 6
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+2Ch+var_4], edx
    call    _rand
    imul    dword_512310
    push    ebp
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    shl     eax, 10h
    mov     edi, eax
    call    _rand
    cdq
    push    ebp
    push    10000h
    push    edx
    push    eax
    call    __allmul
    push    ebp
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     ebx, eax
    push    edi
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    edi
    push    ebx
    call    sub_4B7123
    movsx   ecx, word ptr dword_512320
    shl     ecx, 14h
    add     ecx, esi
    mov     [esp+34h+var_18], esi
    neg     eax
    mov     [esp+34h+var_18], ecx
    mov     ecx, [esp+34h+var_8]
    mov     edx, eax
    mov     eax, ecx
    neg     eax
    shl     eax, 2
    sub     eax, ecx
    add     esp, 8
    movsx   ecx, word ptr dword_512320+2
    lea     eax, [eax+eax*8]
    mov     [esp+2Ch+var_14], ebp
    shl     ecx, 14h
    shl     eax, 1
    add     edx, ecx
    mov     [esp+2Ch+var_14], eax
    mov     [esp+2Ch+var_10], edx
    mov     ecx, dword_512328
    lea     edx, [esp+2Ch+var_C]
    push    1
    lea     eax, [esp+30h+var_18]
    push    edx
    push    eax
    push    ecx
    call    sub_49DF10
    mov     ecx, TAdynmemStructPtr

    loc_43804F:                             ; CODE XREF: sub_437DE0+144j
    mov     edx, dword_51231C
    mov     eax, [ecx+38A47h]
    cmp     edx, eax
    ja      short loc_438065
    mov     dword_512318, ebp

    loc_438065:                             ; CODE XREF: sub_437DE0+130j
                                            ; sub_437DE0+27Dj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    sub_437DE0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438070 proc near                    ; CODE XREF: .text:0041778Ap

    var_4= dword ptr -4

    push    ecx
    mov     ecx, TAdynmemStructPtr
    mov     eax, dword_512324
    mov     dword_512318, 1
    push    esi
    mov     edx, [ecx+38A47h]
    add     eax, edx
    mov     edx, dword_512338
    add     edx, eax
    mov     dword_51231C, eax
    mov     dword_5122E8, edx
    mov     eax, [ecx+38A47h]
    mov     dword_512330, eax
    call    _rand
    mov     ecx, TAdynmemStructPtr
    push    0
    push    8000h
    imul    dword ptr [ecx+14237h]
    push    edx
    push    eax
    call    __alldiv
    mov     esi, eax
    call    _rand
    mov     edx, TAdynmemStructPtr
    push    0
    push    8000h
    imul    dword ptr [edx+14233h]
    push    edx
    push    eax
    call    __alldiv
    mov     word ptr [esp+8+var_4], ax
    mov     word ptr [esp+8+var_4+2], si
    mov     eax, [esp+8+var_4]
    mov     dword_512334, eax
    call    _rand
    cdq
    push    0
    push    0Ah
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     esi, eax
    sub     esi, 0Fh
    call    _rand
    cdq
    push    0
    push    1Eh
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     edx, dword_512334
    sub     eax, 0Fh
    mov     word ptr [esp+8+var_4], ax
    mov     ecx, [esp+8+var_4]
    add     ecx, edx
    add     si, word ptr dword_512334+2
    mov     word ptr [esp+8+var_4], cx
    mov     word ptr [esp+8+var_4+2], si
    mov     eax, [esp+8+var_4]
    mov     dword_512320, eax
    pop     esi
    pop     ecx
    retn
    sub_438070 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438180 proc near                    ; CODE XREF: sub_4326B0+383p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    offset aMeteor_0                ; char *
    mov     ecx, esi
    call    sub_4B4560
    mov     eax, dword_51232C
    mov     ecx, esi
    push    eax                             ; int
    push    offset aEnabled                 ; char *
    call    sub_4B4630
    mov     ecx, dword_512318
    push    ecx                             ; int
    push    offset aActive                  ; char *
    mov     ecx, esi
    call    sub_4B4630
    mov     edx, dword_5122E8
    mov     ecx, esi
    push    edx                             ; int
    push    offset aNextStrikeTime          ; char *
    call    sub_4B4630
    mov     eax, dword_51231C
    mov     ecx, esi
    push    eax                             ; int
    push    offset aTimeStrikeEnds          ; char *
    call    sub_4B4630
    mov     ecx, dword_512330
    push    ecx                             ; int
    push    offset aNextHitTime             ; char *
    mov     ecx, esi
    call    sub_4B4630
    movsx   edx, word ptr dword_512320
    push    edx                             ; int
    push    offset aOriginX                 ; char *
    mov     ecx, esi
    call    sub_4B4630
    movsx   eax, word ptr dword_512320+2
    push    eax                             ; int
    push    offset aOriginZ                 ; char *
    mov     ecx, esi
    call    sub_4B4630
    movsx   ecx, word ptr dword_512334
    push    ecx                             ; int
    push    offset aTargetX                 ; char *
    mov     ecx, esi
    call    sub_4B4630
    movsx   edx, word ptr dword_512334+2
    push    edx                             ; int
    push    offset aTargetZ                 ; char *
    mov     ecx, esi
    call    sub_4B4630
    pop     esi
    retn    4
    sub_438180 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438250 proc near                    ; CODE XREF: sub_432610+68p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    offset aMeteor_0                ; char *
    mov     ecx, esi
    call    sub_4B4560
    push    0                               ; int
    push    offset aEnabled                 ; char *
    mov     ecx, esi
    call    sub_4B4800
    push    0                               ; int
    push    offset aActive                  ; char *
    mov     ecx, esi
    mov     dword_51232C, eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aNextStrikeTime          ; char *
    mov     ecx, esi
    mov     dword_512318, eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aTimeStrikeEnds          ; char *
    mov     ecx, esi
    mov     dword_5122E8, eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aNextHitTime             ; char *
    mov     ecx, esi
    mov     dword_51231C, eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aOriginX                 ; char *
    mov     ecx, esi
    mov     dword_512330, eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aOriginZ                 ; char *
    mov     ecx, esi
    mov     word ptr dword_512320, ax
    call    sub_4B4800
    push    0                               ; int
    push    offset aTargetX                 ; char *
    mov     ecx, esi
    mov     word ptr dword_512320+2, ax
    call    sub_4B4800
    push    0                               ; int
    push    offset aTargetZ                 ; char *
    mov     ecx, esi
    mov     word ptr dword_512334, ax
    call    sub_4B4800
    mov     word ptr dword_512334+2, ax
    pop     esi
    retn    4
    sub_438250 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438320 proc near                    ; CODE XREF: sub_435DA0+A54p
                                            ; sub_435DA0+A69p

    var_110= dword ptr -110h
    var_10C= dword ptr -10Ch
    var_104= dword ptr -104h
    var_100= dword ptr -100h

    sub     esp, 110h
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+114h+var_110]
    call    sub_4C2EA0
    push    offset aTdf                     ; "tdf"
    push    offset aMeteor                  ; "meteor"
    lea     eax, [esp+11Ch+var_100]
    push    offset aGamedata                ; "gamedata"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+114h+var_100]
    push    ecx
    lea     ecx, [esp+118h+var_110]
    call    sub_4C2F60
    test    eax, eax
    jz      loc_438431
    push    offset aDefault_0               ; char *
    lea     ecx, [esp+118h+var_110]
    call    sub_4C3410
    test    eax, eax
    jz      loc_438431
    mov     ecx, [esp+114h+var_10C]
    push    offset Data                     ; int
    push    20h                             ; size_t
    push    offset aMeteorweapon            ; char *
    push    esi                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jz      loc_438427
    mov     ecx, [esp+114h+var_10C]
    push    0                               ; int
    push    offset aMeteorradius            ; char *
    call    sub_4C46C0
    mov     ecx, [esp+114h+var_10C]
    push    0
    push    0                               ; __int64
    push    offset aMeteordensity           ; char *
    mov     [esi+20h], eax
    call    sub_4C4760
    fstp    dword ptr [esi+24h]
    mov     ecx, [esp+114h+var_10C]
    push    0
    push    0                               ; __int64
    push    offset aMeteorduration          ; char *
    call    sub_4C4760
    fstp    dword ptr [esi+28h]
    mov     ecx, [esp+114h+var_10C]
    push    0
    push    0                               ; __int64
    push    offset aMeteorinterval          ; char *
    call    sub_4C4760
    fstp    [esp+114h+var_104]
    mov     eax, [esi+20h]
    mov     edx, [esp+114h+var_104]
    test    eax, eax
    mov     [esi+2Ch], edx
    jz      short loc_438427
    fld     dword ptr [esi+24h]
    fcomp   ds:flt_4FD284
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_438427
    fld     dword ptr [esi+28h]
    fcomp   ds:flt_4FD284
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_438427
    fld     [esp+114h+var_104]
    fcomp   ds:flt_4FD284
    fnstsw  ax
    test    ah, 40h
    jz      short loc_438431

    loc_438427:                             ; CODE XREF: sub_438320+6Fj
                                            ; sub_438320+D4j ...
    push    offset aHeyHoserTheDef          ; lpText
    call    sub_4B6290

    loc_438431:                             ; CODE XREF: sub_438320+3Bj
                                            ; sub_438320+51j ...
    lea     ecx, [esp+114h+var_110]
    call    sub_4C2EB0
    pop     esi
    add     esp, 110h
    retn
    sub_438320 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    mov     al, [esp+3]
    push    offset loc_438480
    mov     byte_512340, al
    xor     eax, eax
    mov     dword_512344, eax
    mov     dword_512348, eax
    mov     dword_51234C, eax
    call    _atexit
    add     esp, 4
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    loc_438480:                             ; DATA XREF: .text:00438455o
    mov     eax, dword_512344
    push    eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     dword_512344, eax
    mov     dword_512348, eax
    mov     dword_51234C, eax
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4384A0 proc near                    ; CODE XREF: sub_48AB70+1AFp

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    mov     eax, [ebx+86h]
    push    edi
    test    eax, eax
    jz      loc_43857F
    add     ebx, 5Ch
    mov     edi, ebx
    mov     ebp, [ebx]
    mov     esi, [edi]
    test    esi, esi
    jz      short loc_4384F8

    loc_4384C3:                             ; CODE XREF: sub_4384A0+56j
    test    byte ptr [esi+42h], 4
    jz      short loc_4384CE
    lea     edi, [esi+4Ah]
    jmp     short loc_4384F2
    ; ---------------------------------------------------------------------------

    loc_4384CE:                             ; CODE XREF: sub_4384A0+27j
    mov     eax, [esi+4Ah]
    cmp     esi, ebp
    mov     [edi], eax
    jz      short loc_4384DE
    or      dword ptr [esi+42h], 10000h

    loc_4384DE:                             ; CODE XREF: sub_4384A0+35j
    test    esi, esi
    jz      short loc_4384F2
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4384F2:                             ; CODE XREF: sub_4384A0+2Cj
                                            ; sub_4384A0+40j
    mov     esi, [edi]
    test    esi, esi
    jnz     short loc_4384C3

    loc_4384F8:                             ; CODE XREF: sub_4384A0+21j
    push    56h                             ; int
    call    sub_4B4F10
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jz      short loc_438531
    mov     edi, [esp+0Ch+arg_0]
    push    0
    push    0
    push    0
    mov     ecx, [edi+86h]
    push    0
    push    ecx
    push    ecx
    mov     ecx, esp
    push    offset aBecarried               ; char *
    call    sub_438760
    mov     ecx, esi
    call    sub_43A0C0
    jmp     short loc_438537
    ; ---------------------------------------------------------------------------

    loc_438531:                             ; CODE XREF: sub_4384A0+66j
    mov     edi, [esp+0Ch+arg_0]
    xor     eax, eax

    loc_438537:                             ; CODE XREF: sub_4384A0+8Fj
    mov     ecx, [eax+42h]
    and     ecx, 40000h
    jz      short loc_438547
    mov     esi, [edi+60h]
    jmp     short loc_438549
    ; ---------------------------------------------------------------------------

    loc_438547:                             ; CODE XREF: sub_4384A0+A0j
    mov     esi, [ebx]

    loc_438549:                             ; CODE XREF: sub_4384A0+A5j
    test    ecx, ecx
    lea     edx, [edi+60h]
    jnz     short loc_438552
    mov     edx, ebx

    loc_438552:                             ; CODE XREF: sub_4384A0+AEj
    mov     ecx, [edx]
    cmp     ecx, esi
    jz      short loc_438562

    loc_438558:                             ; CODE XREF: sub_4384A0+C0j
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, esi
    jnz     short loc_438558

    loc_438562:                             ; CODE XREF: sub_4384A0+B6j
    mov     [edx], eax
    mov     [eax+0Eh], edi
    test    esi, esi
    mov     [eax+4Ah], esi
    jz      short loc_43857F
    mov     edx, [esi+42h]
    mov     ecx, [eax+42h]
    and     edx, 4000h
    or      ecx, edx
    mov     [eax+42h], ecx

    loc_43857F:                             ; CODE XREF: sub_4384A0+10j
                                            ; sub_4384A0+CCj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_4384A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438590 proc near                    ; CODE XREF: .text:00403DE1p
                                            ; .text:004040D4p ...

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h
    arg_8= dword ptr  18h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    push    offset aStartbuilding           ; "StartBuilding"
    mov     ecx, [edi+9Ah]
    call    sub_4B07C0
    mov     ecx, [edi+9Ah]
    push    0
    mov     esi, [esp+4+arg_8]
    push    0
    and     esi, 0FFFFh
    push    0
    push    esi
    push    1
    mov     ebx, eax
    push    0
    push    0
    push    ebx
    call    sub_4B0B00
    push    0
    push    0
    push    0
    push    esi
    push    1
    push    ebx
    push    edi
    call    sub_456290
    pop     edi
    pop     esi
    mov     eax, [esp-8+arg_4]
    pop     ebx
    or      dword ptr [eax+42h], 400000h
    retn    0Ch
    sub_438590 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4385F0 proc near                    ; CODE XREF: .text:00404599p
                                            ; .text:00404A7Fp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_4]
    test    dword ptr [ebx+42h], 400000h
    jz      short loc_438644
    push    edi
    push    esi
    mov     esi, [esp+8+arg_0]
    push    offset aStopbuilding            ; "StopBuilding"
    mov     ecx, [esi+9Ah]
    call    sub_4B07C0
    mov     ecx, [esi+9Ah]
    push    0
    push    0
    push    0
    push    0
    push    0
    mov     edi, eax
    push    0
    push    0
    push    edi
    call    sub_4B0B00
    push    edi
    push    esi
    call    sub_456190
    mov     eax, [ebx+42h]
    pop     esi
    and     eax, 0FFBFFFFFh
    pop     edi
    mov     [ebx+42h], eax

    loc_438644:                             ; CODE XREF: sub_4385F0+Cj
    pop     ebx
    retn    8
    sub_4385F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438650 proc near                    ; CODE XREF: .text:0040483Dp
                                            ; .text:00414C86p

    var_8= qword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    sub     esp, 8
    push    esi
    mov     esi, [eax+92h]
    push    edi
    fld     dword ptr [esi+18Ah]
    fcomp   ds:flt_4FD2A4
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_43867A
    fld     dword ptr [esi+18Ah]
    jmp     short loc_438680
    ; ---------------------------------------------------------------------------

    loc_43867A:                             ; CODE XREF: sub_438650+20j
    fld     ds:flt_4FD2A4

    loc_438680:                             ; CODE XREF: sub_438650+28j
    mov     eax, [esp+10h+arg_0]
    xor     edx, edx
    mov     dword ptr [esp+10h+var_8+4], 0
    mov     ecx, [eax+92h]
    mov     dx, [ecx+1FEh]
    xor     ecx, ecx
    mov     cx, [eax+0B8h]
    mov     eax, 66666667h
    add     ecx, 5
    mov     edi, edx
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    imul    edi, edx
    imul    edi, [esi+1FAh]
    imul    edi, [esp+10h+arg_8]
    mov     dword ptr [esp+10h+var_8], edi
    fild    [esp+10h+var_8]
    fxch    st(1)
    fmul    ds:flt_4FD2A8
    fdivp   st(1), st
    call    __ftol
    cmp     eax, 1
    jg      short loc_4386E9
    mov     eax, 1

    loc_4386E9:                             ; CODE XREF: sub_438650+92j
    pop     edi
    pop     esi
    add     esp, 8
    retn    0Ch
    sub_438650 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438700 proc near                    ; CODE XREF: .text:004027CAp
                                            ; .text:00403DFDp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     eax, 1
    test    [ecx+10Fh], al
    jnz     short locret_438724
    mov     edx, [esp+arg_8]
    mov     eax, [esp+arg_4]
    or      edx, 4
    mov     [eax+6], edx
    mov     eax, 2

    locret_438724:                          ; CODE XREF: sub_438700+Fj
    retn    0Ch
    sub_438700 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438730 proc near                    ; CODE XREF: .text:00406865p
                                            ; .text:004069E6p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     eax, 2
    test    [ecx+10Fh], al
    jz      short loc_438752
    mov     edx, [esp+arg_8]
    mov     ecx, [esp+arg_4]
    or      edx, 4
    mov     [ecx+6], edx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_438752:                             ; CODE XREF: sub_438730+Fj
    mov     eax, 1
    retn    0Ch
    sub_438730 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_438760(char *)
    sub_438760 proc near                    ; CODE XREF: sub_401C20+6Bp
                                            ; .text:004029A0p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    mov     ebp, dword_512344
    push    esi
    mov     esi, ecx
    mov     eax, 51EB851Fh
    mov     ecx, dword_512348
    push    edi
    sub     ecx, ebp
    mov     [esp+14h+var_4], esi
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     edi, edx
    test    edi, edi
    jle     short loc_4387D8

    loc_438790:                             ; CODE XREF: sub_438760+72j
    mov     eax, edi
    cdq
    sub     eax, edx
    mov     edx, [esp+14h+arg_0]
    mov     esi, eax
    push    edx                             ; char *
    sar     esi, 1
    lea     eax, [esi+esi*4]
    lea     ecx, [ebp+eax*4+0]
    add     eax, ecx
    mov     ebx, eax
    mov     eax, [ebx+15h]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    mov     eax, ecx
    test    eax, eax
    jz      short loc_4387CE
    or      edx, 0FFFFFFFFh
    lea     ebp, [ebx+19h]
    sub     edx, esi
    add     edi, edx
    jmp     short loc_4387D0
    ; ---------------------------------------------------------------------------

    loc_4387CE:                             ; CODE XREF: sub_438760+60j
    mov     edi, esi

    loc_4387D0:                             ; CODE XREF: sub_438760+6Cj
    test    edi, edi
    jg      short loc_438790
    mov     esi, [esp+14h+var_4]

    loc_4387D8:                             ; CODE XREF: sub_438760+2Ej
    cmp     ebp, dword_512348
    jz      short loc_438819
    mov     eax, [esp+14h+arg_0]
    mov     ecx, [ebp+15h]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_438819
    mov     eax, dword_512344
    sub     ebp, eax
    mov     eax, 51EB851Fh
    imul    ebp
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, esi
    mov     [esi], dl
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_438819:                             ; CODE XREF: sub_438760+7Ej
                                            ; sub_438760+93j
    mov     byte ptr [esi], 0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_438760 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438830 proc near                    ; CODE XREF: sub_467E50+399p
                                            ; sub_467E50+3BFp ...
    xor     eax, eax
    mov     al, [ecx]
    mov     ecx, dword_512344
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    add     eax, edx
    retn
    sub_438830 endp

    ; ---------------------------------------------------------------------------
    align 10h
    xor     eax, eax
    mov     al, [ecx]
    mov     ecx, dword_512344
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    add     eax, edx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438870 proc near                    ; DATA XREF: .rdata:004FD2C8o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+4Eh]
    or      edx, eax
    mov     [ecx+4Eh], edx
    retn    4
    sub_438870 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438880 proc near                    ; CODE XREF: sub_401C20+7p
                                            ; .text:004021D4p ...

    arg_0= dword ptr  4

    mov     eax, [ecx+42h]
    test    ah, 20h
    jz      short locret_43889E
    and     ah, 0DFh
    mov     [ecx+42h], eax
    mov     eax, [esp+arg_0]
    mov     ecx, [ecx+0Eh]
    push    eax
    push    5
    push    ecx
    call    sub_47F780

    locret_43889E:                          ; CODE XREF: sub_438880+6j
    retn    4
    sub_438880 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4388B0 proc near                    ; CODE XREF: sub_487080+54Bp
    mov     eax, [ecx+52h]
    test    eax, eax
    jz      short locret_4388C4
    mov     ecx, [ecx+0Eh]
    push    eax
    mov     edx, [ecx]
    mov     ecx, [edx]
    mov     edx, [ecx]
    call    dword ptr [edx+4]

    locret_4388C4:                          ; CODE XREF: sub_4388B0+5j
    retn
    sub_4388B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4388D0 proc near                    ; CODE XREF: .text:00402D65p
                                            ; .text:004035B7p ...

    var_4= dword ptr -4

    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+0Eh]
    mov     eax, [eax]
    test    eax, eax
    jz      short loc_438924
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_438901
    mov     ecx, [eax]
    push    0
    mov     edx, [ecx]
    call    dword ptr [edx+4]
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_4388FA
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4388FA:                             ; CODE XREF: sub_4388D0+22j
    mov     dword ptr [esi+52h], 0

    loc_438901:                             ; CODE XREF: sub_4388D0+12j
    mov     edi, [esp+0Ch]
    test    edi, edi
    jz      short loc_438924
    mov     eax, [esi+4Eh]
    mov     ecx, [esi+0Eh]
    and     eax, 0FFFFFC1Fh
    push    edi
    mov     [esi+4Eh], eax
    mov     edx, [ecx]
    mov     ecx, [edx]
    mov     eax, [ecx]
    call    dword ptr [eax+4]
    mov     [esi+52h], edi

    loc_438924:                             ; CODE XREF: sub_4388D0+Bj
                                            ; sub_4388D0+37j
    pop     edi
    pop     esi
    retn    4
    sub_4388D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438930 proc near                    ; CODE XREF: .text:0040323Fp
                                            ; .text:0040337Dp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+0Eh]
    mov     ecx, [eax+92h]
    mov     edx, [ecx+241h]
    test    dh, 8
    jnz     short loc_4389C5
    push    14h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_438972
    mov     edx, [esp+4+arg_4]
    push    edx
    mov     edx, [esp+8+arg_0]
    mov     ecx, [edx+8]
    mov     edx, [edx]
    push    ecx
    push    edx
    push    esi
    mov     ecx, eax
    call    sub_44CF60
    mov     edi, eax
    jmp     short loc_438974
    ; ---------------------------------------------------------------------------

    loc_438972:                             ; CODE XREF: sub_438930+24j
    xor     edi, edi

    loc_438974:                             ; CODE XREF: sub_438930+40j
    mov     eax, [esi+0Eh]
    mov     eax, [eax]
    test    eax, eax
    jz      short loc_4389EF
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_4389A1
    mov     ecx, [eax]
    push    0
    mov     edx, [ecx]
    call    dword ptr [edx+4]
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_43899A
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_43899A:                             ; CODE XREF: sub_438930+62j
    mov     dword ptr [esi+52h], 0

    loc_4389A1:                             ; CODE XREF: sub_438930+52j
    test    edi, edi
    jz      short loc_4389EF
    mov     eax, [esi+4Eh]
    mov     ecx, [esi+0Eh]
    and     eax, 0FFFFFC1Fh
    push    edi
    mov     [esi+4Eh], eax
    mov     edx, [ecx]
    mov     ecx, [edx]
    mov     eax, [ecx]
    call    dword ptr [eax+4]
    mov     [esi+52h], edi
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4389C5:                             ; CODE XREF: sub_438930+16j
    mov     eax, [eax]
    test    eax, eax
    jz      short loc_4389EF
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_4389EF
    mov     ecx, [eax]
    push    0
    mov     edx, [ecx]
    call    dword ptr [edx+4]
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_4389E8
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4389E8:                             ; CODE XREF: sub_438930+B0j
    mov     dword ptr [esi+52h], 0

    loc_4389EF:                             ; CODE XREF: sub_438930+4Bj
                                            ; sub_438930+73j ...
    pop     edi
    pop     esi
    retn    8
    sub_438930 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438A00 proc near                    ; CODE XREF: sub_403621+150p
                                            ; sub_403621+17Ap ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+0Eh]
    mov     ecx, [eax+92h]
    mov     edx, [ecx+241h]
    test    dh, 8
    jnz     loc_438A9E
    push    1Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_438A4B
    mov     edx, [esp+4+arg_8]
    mov     ecx, [esp+4+arg_4]
    push    edx
    mov     edx, [esp+8+arg_0]
    push    ecx
    mov     ecx, [edx+8]
    mov     edx, [edx]
    push    ecx
    push    edx
    push    esi
    mov     ecx, eax
    call    sub_44D3B0
    mov     edi, eax
    jmp     short loc_438A4D
    ; ---------------------------------------------------------------------------

    loc_438A4B:                             ; CODE XREF: sub_438A00+28j
    xor     edi, edi

    loc_438A4D:                             ; CODE XREF: sub_438A00+49j
    mov     eax, [esi+0Eh]
    mov     eax, [eax]
    test    eax, eax
    jz      short loc_438AC8
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_438A7A
    mov     ecx, [eax]
    push    0
    mov     edx, [ecx]
    call    dword ptr [edx+4]
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_438A73
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_438A73:                             ; CODE XREF: sub_438A00+6Bj
    mov     dword ptr [esi+52h], 0

    loc_438A7A:                             ; CODE XREF: sub_438A00+5Bj
    test    edi, edi
    jz      short loc_438AC8
    mov     eax, [esi+4Eh]
    mov     ecx, [esi+0Eh]
    and     eax, 0FFFFFC1Fh
    push    edi
    mov     [esi+4Eh], eax
    mov     edx, [ecx]
    mov     ecx, [edx]
    mov     eax, [ecx]
    call    dword ptr [eax+4]
    mov     [esi+52h], edi
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_438A9E:                             ; CODE XREF: sub_438A00+16j
    mov     eax, [eax]
    test    eax, eax
    jz      short loc_438AC8
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_438AC8
    mov     ecx, [eax]
    push    0
    mov     edx, [ecx]
    call    dword ptr [edx+4]
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_438AC1
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_438AC1:                             ; CODE XREF: sub_438A00+B9j
    mov     dword ptr [esi+52h], 0

    loc_438AC8:                             ; CODE XREF: sub_438A00+54j
                                            ; sub_438A00+7Cj ...
    pop     edi
    pop     esi
    retn    0Ch
    sub_438A00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438AD0 proc near                    ; CODE XREF: .text:00403B2Ap
                                            ; .text:0040441Cp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+0Eh]
    mov     ecx, [eax+92h]
    mov     edx, [ecx+241h]
    test    dh, 8
    jnz     short loc_438B60
    push    18h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_438B0C
    mov     edx, [esp+4+arg_4]
    mov     ecx, [esp+4+arg_0]
    push    edx
    push    ecx
    push    esi
    mov     ecx, eax
    call    sub_44D8A0
    mov     edi, eax
    jmp     short loc_438B0E
    ; ---------------------------------------------------------------------------

    loc_438B0C:                             ; CODE XREF: sub_438AD0+24j
    xor     edi, edi

    loc_438B0E:                             ; CODE XREF: sub_438AD0+3Aj
    mov     edx, [esi+0Eh]
    mov     eax, [edx]
    test    eax, eax
    jz      short loc_438B8A
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_438B3B
    mov     ecx, [eax]
    push    0
    mov     eax, [ecx]
    call    dword ptr [eax+4]
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_438B34
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_438B34:                             ; CODE XREF: sub_438AD0+5Cj
    mov     dword ptr [esi+52h], 0

    loc_438B3B:                             ; CODE XREF: sub_438AD0+4Cj
    test    edi, edi
    jz      short loc_438B8A
    mov     ecx, [esi+4Eh]
    mov     eax, [esi+0Eh]
    and     ecx, 0FFFFFC1Fh
    push    edi
    mov     [esi+4Eh], ecx
    mov     ecx, [eax]
    mov     ecx, [ecx]
    mov     edx, [ecx]
    call    dword ptr [edx+4]
    mov     [esi+52h], edi
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_438B60:                             ; CODE XREF: sub_438AD0+16j
    mov     eax, [eax]
    test    eax, eax
    jz      short loc_438B8A
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_438B8A
    mov     ecx, [eax]
    push    0
    mov     eax, [ecx]
    call    dword ptr [eax+4]
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_438B83
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_438B83:                             ; CODE XREF: sub_438AD0+ABj
    mov     dword ptr [esi+52h], 0

    loc_438B8A:                             ; CODE XREF: sub_438AD0+45j
                                            ; sub_438AD0+6Dj ...
    pop     edi
    pop     esi
    retn    8
    sub_438AD0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438B90 proc near                    ; CODE XREF: .text:004031B1p
                                            ; .text:0040624Cp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     edx, eax
    mov     [ecx+4], al
    mov     esi, dword_512344
    and     edx, 0FFh
    push    edi
    and     eax, 0FFh
    lea     edx, [edx+edx*4]
    lea     eax, [eax+eax*4]
    lea     edi, [esi+edx*4]
    lea     esi, [esi+eax*4]
    mov     edx, [edx+edi+11h]
    mov     edi, [ecx+42h]
    xor     edx, edi
    mov     edi, [eax+esi+11h]
    and     edx, 600h
    xor     edx, edi
    pop     edi
    mov     [ecx+42h], edx
    pop     esi
    retn    4
    sub_438B90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438BE0 proc near                    ; CODE XREF: sub_406F80+231p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    test    eax, eax
    jnz     short loc_438BEB
    retn    4
    ; ---------------------------------------------------------------------------

    loc_438BEB:                             ; CODE XREF: sub_438BE0+6j
    mov     eax, [eax+5Ch]
    test    eax, eax
    jnz     short loc_438BF5
    retn    4
    ; ---------------------------------------------------------------------------

    loc_438BF5:                             ; CODE XREF: sub_438BE0+10j
    mov     eax, [eax+42h]
    retn    4
    sub_438BE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438C00 proc near                    ; CODE XREF: sub_439B30+7Cp

    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     edx, [esp+arg_8]
    sub     esp, 30h
    mov     ax, [edx+36h]
    test    ax, ax
    jz      loc_438E8E
    and     eax, 0FFFFh
    push    edi
    mov     ecx, eax
    push    esi
    shl     eax, 6
    add     eax, ecx
    push    ebp
    mov     ebp, [edx+22h]
    mov     edi, [edx+2Ah]
    lea     ecx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     eax, [eax+1439Bh]
    add     eax, ecx
    lea     ecx, [edx+22h]
    mov     [esp+40h+var_20], ecx
    mov     edx, [eax+15Eh]
    mov     ebx, [eax+162h]
    add     edx, ebp
    mov     esi, [eax+16Ah]
    mov     [esp+40h+var_1C], edx
    mov     edx, [ecx+4]
    add     edx, ebx
    mov     ecx, [esp+40h+arg_4]
    mov     [esp+40h+var_18], edx
    mov     edx, [eax+166h]
    mov     eax, [eax+172h]
    add     edx, edi
    mov     ebx, [ecx+30h]
    mov     [esp+40h+var_14], edx
    mov     edx, ebp
    mov     ebp, edi
    add     edx, esi
    add     eax, ebp
    movsx   ebp, word ptr [esp+40h+var_1C+2]
    movsx   esi, word ptr [esp+40h+var_14+2]
    mov     [esp+40h+var_C], edx
    mov     edx, [ecx+2Ch]
    movsx   ecx, word ptr [esp+40h+var_C+2]
    mov     [esp+40h+var_4], eax
    sub     ebp, edx
    movsx   eax, word ptr [esp+40h+var_18+2]
    movsx   edi, word ptr [esp+40h+var_4+2]
    sub     ecx, edx
    mov     edx, TAdynmemStructPtr
    sar     eax, 1
    sub     esi, eax
    sub     edi, eax
    mov     eax, [edx+38A47h]
    mov     edx, [esp+40h+arg_8]
    sub     esi, ebx
    sub     edi, ebx
    mov     ebx, [edx+46h]
    xor     edx, edx
    sub     eax, ebx
    add     ebp, 80h
    add     esi, 20h
    add     ecx, 80h
    add     edi, 20h
    cmp     edx, eax
    sbb     edx, edx
    mov     [esp+40h+var_14], ecx
    and     edx, eax
    cmp     edx, 0Ah
    jnb     short loc_438CFB
    xor     edx, edx
    cmp     edx, eax
    sbb     edx, edx
    and     edx, eax
    mov     [esp+40h+arg_4], edx
    jmp     short loc_438D07
    ; ---------------------------------------------------------------------------

    loc_438CFB:                             ; CODE XREF: sub_438C00+EBj
    mov     [esp+40h+arg_4], 0Ah
    mov     edx, [esp+40h+arg_4]

    loc_438D07:                             ; CODE XREF: sub_438C00+F9j
    sub     ecx, ebp
    mov     eax, 66666667h
    imul    ecx, edx
    imul    ecx
    mov     ecx, edi
    sub     ecx, esi
    imul    ecx, [esp+40h+arg_4]
    sar     edx, 2
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 66666667h
    mov     ebx, edx
    imul    ecx
    sar     edx, 2
    mov     ecx, edx
    mov     [esp+40h+var_2C], ebx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     [esp+40h+arg_4], edx
    mov     edx, [esp+40h+arg_8]
    mov     eax, [edx+0Eh]
    mov     ecx, [eax+110h]
    mov     eax, TAdynmemStructPtr
    shr     ecx, 4
    test    cl, 1
    jz      short loc_438D71
    mov     dl, [eax+0DCEh]
    mov     al, [eax+0DD5h]
    mov     byte ptr [esp+40h+arg_8], dl
    mov     byte ptr [esp+40h+var_30], al
    jmp     short loc_438D85
    ; ---------------------------------------------------------------------------

    loc_438D71:                             ; CODE XREF: sub_438C00+159j
    mov     cl, [eax+0DCCh]
    mov     dl, [eax+0DD4h]
    mov     byte ptr [esp+40h+arg_8], cl
    mov     byte ptr [esp+40h+var_30], dl

    loc_438D85:                             ; CODE XREF: sub_438C00+16Fj
    mov     eax, [esp+40h+arg_8]
    lea     ecx, [ebx+ebp]
    and     eax, 0FFh
    lea     edx, [edi+1]
    mov     [esp+40h+var_28], ecx
    dec     ecx
    push    eax
    lea     ebx, [esi-1]
    push    edx
    push    ecx
    push    ebx
    mov     ebx, [esp+50h+arg_0]
    push    ecx
    push    ebx
    mov     [esp+58h+arg_8], eax
    call    sub_4BE950
    mov     eax, [esp+40h+var_14]
    mov     ecx, [esp+40h+var_2C]
    sub     eax, ecx
    mov     ecx, [esp+40h+arg_8]
    push    ecx
    lea     ecx, [edi+1]
    mov     [esp+44h+var_2C], eax
    inc     eax
    push    ecx
    lea     ecx, [esi-1]
    push    eax
    push    ecx
    push    eax
    push    ebx
    call    sub_4BE950
    mov     edx, [esp+40h+arg_4]
    mov     ecx, [esp+40h+var_14]
    lea     eax, [edx+esi]
    mov     edx, [esp+40h+arg_8]
    mov     [esp+40h+var_24], eax
    dec     eax
    inc     ecx
    push    edx
    push    eax
    push    ecx
    push    eax
    lea     eax, [ebp-1]
    push    eax
    push    ebx
    mov     [esp+58h+arg_0], ecx
    call    sub_4BE950
    mov     eax, edi
    mov     ecx, [esp+40h+arg_4]
    mov     edx, [esp+40h+arg_0]
    sub     eax, ecx
    mov     ecx, [esp+40h+arg_8]
    mov     [esp+40h+arg_4], eax
    inc     eax
    push    ecx
    push    eax
    push    edx
    push    eax
    lea     eax, [ebp-1]
    push    eax
    push    ebx
    call    sub_4BE950
    mov     eax, [esp+40h+var_30]
    and     eax, 0FFh
    mov     [esp+40h+arg_8], eax
    push    eax
    mov     eax, [esp+44h+var_28]
    push    edi
    push    eax
    push    esi
    push    eax
    push    ebx
    call    sub_4BE950
    mov     eax, [esp+40h+arg_8]
    push    eax
    mov     eax, [esp+44h+var_2C]
    push    edi
    push    eax
    push    esi
    push    eax
    push    ebx
    call    sub_4BE950
    mov     esi, [esp+40h+arg_8]
    mov     eax, [esp+40h+var_24]
    mov     edi, [esp+40h+var_14]
    push    esi
    push    eax
    push    edi
    push    eax
    push    ebp
    push    ebx
    call    sub_4BE950
    push    esi
    mov     eax, [esp+44h+arg_4]
    push    eax
    push    edi
    push    eax
    push    ebp
    push    ebx
    call    sub_4BE950
    pop     ebx
    pop     ebp
    mov     eax, [esp+38h+var_20]
    mov     ecx, [esp+38h+arg_C]
    pop     esi
    pop     edi
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax

    loc_438E8E:                             ; CODE XREF: sub_438C00+Ej
    add     esp, 30h
    retn    14h
    sub_438C00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_438EA0 proc near                    ; CODE XREF: sub_4390A0+66p
                                            ; sub_4390A0+E9p ...

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    sub     esp, 2Ch
    push    ebx
    mov     ebx, [esp+30h+arg_C]
    push    ebp
    xor     ebp, ebp
    push    esi
    cmp     ebx, ebp
    push    edi
    jz      loc_43908F
    fild    [esp+3Ch+arg_C]
    mov     [esp+3Ch+var_28], ebp
    mov     [esp+3Ch+var_2C], ebp
    fmul    ds:dbl_4FD2B0
    fmul    ds:dbl_4FD2B8
    call    __ftol
    mov     ecx, eax
    mov     [esp+3Ch+arg_C], ebp
    cmp     ecx, ebp
    mov     [esp+3Ch+var_1C], ecx
    jl      loc_43904D
    mov     eax, 10000h
    mov     edi, [esp+3Ch+arg_8]
    cdq
    idiv    ecx
    shl     ebx, 10h
    mov     [esp+3Ch+var_24], ebx
    mov     [esp+3Ch+var_20], eax
    mov     eax, [esp+3Ch+arg_18]
    lea     eax, [eax+eax*2]
    mov     [esp+3Ch+arg_18], eax
    jmp     short loc_438F0C
    ; ---------------------------------------------------------------------------

    loc_438F08:                             ; CODE XREF: sub_438EA0+1A5j
    mov     ebx, [esp+3Ch+var_24]

    loc_438F0C:                             ; CODE XREF: sub_438EA0+66j
    push    ebx
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    ebx
    push    ebp
    call    sub_4B7123
    mov     ecx, [edi]
    mov     edx, [edi+8]
    sub     ecx, esi
    mov     esi, [edi+4]
    add     esp, 8
    mov     [esp+3Ch+var_18], ecx
    neg     eax
    lea     ecx, [esp+3Ch+var_18]
    sub     edx, eax
    mov     [esp+3Ch+var_14], esi
    push    ecx
    movsx   esi, word ptr [edi+6]
    mov     [esp+40h+var_10], edx
    call    sub_485070
    cmp     esi, eax
    jle     short loc_438F57
    mov     word ptr [esp+3Ch+var_14+2], si
    jmp     short loc_438F66
    ; ---------------------------------------------------------------------------

    loc_438F57:                             ; CODE XREF: sub_438EA0+AEj
    lea     edx, [esp+3Ch+var_18]
    push    edx
    call    sub_485070
    mov     word ptr [esp+3Ch+var_14+2], ax

    loc_438F66:                             ; CODE XREF: sub_438EA0+B5j
    mov     ecx, [esp+3Ch+var_20]
    push    ebx
    add     ebp, ecx
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    ebx
    push    ebp
    call    sub_4B7123
    mov     ecx, [edi]
    mov     edx, [edi+8]
    neg     eax
    add     esp, 8
    sub     ecx, esi
    mov     esi, [edi+4]
    sub     edx, eax
    lea     eax, [esp+3Ch+var_C]
    mov     [esp+3Ch+var_8], esi
    movsx   esi, word ptr [edi+6]
    push    eax
    mov     [esp+40h+var_C], ecx
    mov     [esp+40h+var_4], edx
    call    sub_485070
    cmp     esi, eax
    jle     short loc_438FB5
    mov     ax, si
    jmp     short loc_438FBF
    ; ---------------------------------------------------------------------------

    loc_438FB5:                             ; CODE XREF: sub_438EA0+10Ej
    lea     ecx, [esp+3Ch+var_C]
    push    ecx
    call    sub_485070

    loc_438FBF:                             ; CODE XREF: sub_438EA0+113j
    mov     edx, [esp+3Ch+arg_4]
    mov     word ptr [esp+3Ch+var_8+2], ax
    movsx   esi, word ptr [esp+3Ch+var_4+2]
    mov     ecx, [edx+2Ch]
    mov     edx, [edx+30h]
    movsx   eax, ax
    sar     eax, 1
    sub     esi, eax
    mov     [esp+3Ch+arg_8], edx
    movsx   eax, word ptr [esp+3Ch+var_14+2]
    sub     esi, edx
    mov     edx, [esp+3Ch+arg_10]
    movsx   ebx, word ptr [esp+3Ch+var_C+2]
    push    edx
    sub     ebx, ecx
    movsx   edx, word ptr [esp+40h+var_10+2]
    sar     eax, 1
    sub     edx, eax
    mov     eax, [esp+40h+arg_8]
    sub     edx, eax
    add     esi, 20h
    movsx   eax, word ptr [esp+40h+var_18+2]
    add     ebx, 80h
    sub     eax, ecx
    mov     ecx, [esp+40h+arg_0]
    push    esi
    add     edx, 20h
    push    ebx
    add     eax, 80h
    push    edx
    push    eax
    push    ecx
    call    sub_4BE950
    mov     eax, [esp+3Ch+arg_C]
    mov     ecx, [esp+3Ch+arg_18]
    cmp     eax, ecx
    jnz     short loc_43903A
    mov     [esp+3Ch+var_28], ebx
    mov     [esp+3Ch+var_2C], esi

    loc_43903A:                             ; CODE XREF: sub_438EA0+190j
    mov     ecx, [esp+3Ch+var_1C]
    inc     eax
    cmp     eax, ecx
    mov     [esp+3Ch+arg_C], eax
    jle     loc_438F08
    jmp     short loc_439055
    ; ---------------------------------------------------------------------------

    loc_43904D:                             ; CODE XREF: sub_438EA0+3Ej
    mov     esi, [esp+3Ch+arg_C]
    mov     ebx, [esp+3Ch+arg_C]

    loc_439055:                             ; CODE XREF: sub_438EA0+1ABj
    mov     eax, [esp+3Ch+arg_14]
    test    eax, eax
    jz      short loc_43908F
    mov     ecx, [esp+3Ch+var_28]
    test    ecx, ecx
    jnz     short loc_439075
    mov     ecx, [esp+3Ch+var_2C]
    test    ecx, ecx
    jnz     short loc_439075
    mov     [esp+3Ch+var_28], ebx
    mov     [esp+3Ch+var_2C], esi

    loc_439075:                             ; CODE XREF: sub_438EA0+1C3j
                                            ; sub_438EA0+1CBj
    mov     edx, [esp+3Ch+var_2C]
    mov     ecx, [esp+3Ch+var_28]
    add     edx, 4
    push    0FFFFFFFFh
    push    edx
    mov     edx, [esp+44h+arg_0]
    push    ecx
    push    eax
    push    edx
    call    PrintGUIText

    loc_43908F:                             ; CODE XREF: sub_438EA0+Fj
                                            ; sub_438EA0+1BBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    1Ch
    sub_438EA0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4390A0 proc near                    ; CODE XREF: sub_439B30+18Ep

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    mov     ecx, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+0Ch+arg_8]
    push    ebp
    push    esi
    push    edi
    mov     edx, [ebx+0Eh]
    mov     edi, [ecx+391BFh]
    xor     esi, esi
    mov     [esp+18h+var_8], edx
    mov     eax, [edx+92h]
    test    edi, edi
    mov     [esp+18h+arg_8], eax
    jnz     loc_439202
    mov     si, [eax+208h]
    mov     edi, [esp+18h+arg_4]
    test    si, si
    jz      short loc_439115
    test    byte ptr [edx+10Eh], 4
    jz      short loc_439115
    xor     eax, eax
    push    0
    mov     al, [ecx+0DDAh]
    push    0
    movsx   ecx, si
    push    eax
    add     edx, 6Ah
    push    ecx
    push    edx
    mov     edx, [esp+2Ch+arg_0]
    push    edi
    push    edx
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+18h+arg_8]

    loc_439115:                             ; CODE XREF: sub_4390A0+40j
                                            ; sub_4390A0+49j
    test    dword ptr [eax+241h], 10000000h
    jz      loc_4394C7
    mov     eax, [eax+220h]
    test    eax, eax
    jz      loc_4394C7
    xor     esi, esi
    xor     edx, edx
    mov     si, [eax+0D6h]
    mov     eax, [ecx+38A47h]
    mov     ebp, 3Ch
    div     ebp
    shr     esi, 1
    mov     eax, 88888889h
    mov     ebp, 8
    imul    edx, esi
    shl     edx, 1
    mul     edx
    shr     edx, 5
    cmp     edx, 8
    jb      short loc_439168
    mov     ebp, edx

    loc_439168:                             ; CODE XREF: sub_4390A0+C4j
    cmp     ebp, esi
    jl      short loc_43916E
    mov     ebp, esi

    loc_43916E:                             ; CODE XREF: sub_4390A0+CAj
    mov     esi, [esp+18h+arg_0]
    xor     eax, eax
    mov     al, [ecx+0DD7h]
    mov     ecx, [ebx+0Eh]
    push    0
    push    0
    push    eax
    add     ecx, 6Ah
    push    ebp
    push    ecx
    push    edi
    push    esi
    call    sub_438EA0
    push    0
    push    0
    mov     edx, [esp+20h+var_8]
    cmp     dword ptr [edx], 0
    jz      short loc_4391D0
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    xor     edx, edx
    mov     al, [ecx+0DD7h]
    mov     ecx, [ebx+0Eh]
    push    eax
    mov     eax, [esp+24h+arg_8]
    add     ecx, 6Ah
    mov     dx, [eax+218h]
    push    edx
    push    ecx
    push    edi
    push    esi
    call    sub_438EA0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4391D0:                             ; CODE XREF: sub_4390A0+F9j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+20h+arg_8]
    xor     edx, edx
    mov     dl, [eax+0DD7h]
    mov     eax, [ebx+0Eh]
    push    edx
    add     eax, 6Ah
    movsx   edx, word ptr [ecx+202h]
    push    edx
    push    eax
    push    edi
    push    esi
    call    sub_438EA0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_439202:                             ; CODE XREF: sub_4390A0+2Cj
    mov     di, [eax+208h]
    mov     ebp, [esp+18h+arg_0]
    mov     [esp+18h+var_4], edi
    test    di, di
    mov     edi, [esp+18h+arg_4]
    jz      short loc_43924A
    xor     eax, eax
    push    0
    mov     al, [ecx+0DD9h]
    push    offset aMincloak                ; "mincloak"
    movsx   ecx, word ptr [esp+20h+var_4]
    push    eax
    add     edx, 6Ah
    push    ecx
    push    edx
    push    edi
    push    ebp
    mov     esi, 1
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+18h+arg_8]

    loc_43924A:                             ; CODE XREF: sub_4390A0+178j
    mov     dx, [eax+202h]
    test    dx, dx
    jz      short loc_439284
    mov     eax, esi
    inc     esi
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DD9h]
    push    offset aSight                   ; "sight"
    movsx   ecx, dx
    mov     edx, [ebx+0Eh]
    push    eax
    add     edx, 6Ah
    push    ecx
    push    edx
    push    edi
    push    ebp
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+18h+arg_8]

    loc_439284:                             ; CODE XREF: sub_4390A0+1B4j
    mov     dx, [eax+204h]
    test    dx, dx
    jz      short loc_4392BE
    mov     eax, esi
    inc     esi
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DD9h]
    push    offset aRadar_0                 ; "radar"
    movsx   ecx, dx
    mov     edx, [ebx+0Eh]
    push    eax
    add     edx, 6Ah
    push    ecx
    push    edx
    push    edi
    push    ebp
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+18h+arg_8]

    loc_4392BE:                             ; CODE XREF: sub_4390A0+1EEj
    mov     dx, [eax+206h]
    test    dx, dx
    jz      short loc_4392F8
    mov     eax, esi
    inc     esi
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DD9h]
    push    offset aSonar                   ; "sonar"
    movsx   ecx, dx
    mov     edx, [ebx+0Eh]
    push    eax
    add     edx, 6Ah
    push    ecx
    push    edx
    push    edi
    push    ebp
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+18h+arg_8]

    loc_4392F8:                             ; CODE XREF: sub_4390A0+228j
    mov     dx, [eax+20Ah]
    test    dx, dx
    jz      short loc_439332
    mov     eax, esi
    inc     esi
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DD9h]
    push    offset aRadarjam                ; "radarjam"
    movsx   ecx, dx
    mov     edx, [ebx+0Eh]
    push    eax
    add     edx, 6Ah
    push    ecx
    push    edx
    push    edi
    push    ebp
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+18h+arg_8]

    loc_439332:                             ; CODE XREF: sub_4390A0+262j
    mov     dx, [eax+20Ch]
    test    dx, dx
    jz      short loc_43936C
    mov     eax, esi
    inc     esi
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DD9h]
    push    offset aSonarjam                ; "sonarjam"
    movsx   ecx, dx
    mov     edx, [ebx+0Eh]
    push    eax
    add     edx, 6Ah
    push    ecx
    push    edx
    push    edi
    push    ebp
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+18h+arg_8]

    loc_43936C:                             ; CODE XREF: sub_4390A0+29Cj
    mov     dx, [eax+212h]
    test    dx, dx
    jz      short loc_4393A9
    mov     eax, esi
    and     edx, 0FFFFh
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DD9h]
    mov     ecx, [ebx+0Eh]
    push    offset aBuildDistance           ; "build distance"
    push    eax
    add     ecx, 6Ah
    push    edx
    push    ecx
    push    edi
    push    ebp
    inc     esi
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+18h+arg_8]

    loc_4393A9:                             ; CODE XREF: sub_4390A0+2D6j
    mov     dx, [eax+214h]
    test    dx, dx
    jz      short loc_4393E6
    mov     eax, esi
    and     edx, 0FFFFh
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DD9h]
    mov     ecx, [ebx+0Eh]
    push    offset aManeuver                ; "maneuver"
    push    eax
    add     ecx, 6Ah
    push    edx
    push    ecx
    push    edi
    push    ebp
    inc     esi
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+18h+arg_8]

    loc_4393E6:                             ; CODE XREF: sub_4390A0+313j
    mov     ax, [eax+218h]
    mov     edx, [esp+18h+var_8]
    test    ax, ax
    jz      short loc_439423
    xor     edx, edx
    push    esi
    mov     dl, [ecx+0DD9h]
    push    offset aKamikazedistan          ; "kamikazedistance"
    and     eax, 0FFFFh
    push    edx
    push    eax
    mov     eax, [ebx+0Eh]
    add     eax, 6Ah
    push    eax
    push    edi
    push    ebp
    call    sub_438EA0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+18h+var_8]

    loc_439423:                             ; CODE XREF: sub_4390A0+354j
    test    byte ptr [ecx+38A47h], 1
    jz      short loc_439436
    xor     eax, eax
    mov     al, [ecx+0DCFh]
    jmp     short loc_43943E
    ; ---------------------------------------------------------------------------

    loc_439436:                             ; CODE XREF: sub_4390A0+38Aj
    xor     eax, eax
    mov     al, [ecx+0DD7h]

    loc_43943E:                             ; CODE XREF: sub_4390A0+394j
    mov     esi, eax
    mov     al, [edx+1Fh]
    test    al, 2
    jz      short loc_43946F
    mov     ecx, [edx+10h]
    mov     eax, [ecx+0DCh]
    test    eax, eax
    jz      short loc_43946F
    mov     edx, [ebx+0Eh]
    push    0
    push    offset aWeapon1Range            ; "weapon1 range"
    push    esi
    add     edx, 6Ah
    push    eax
    push    edx
    push    edi
    push    ebp
    call    sub_438EA0
    mov     edx, [esp+18h+var_8]

    loc_43946F:                             ; CODE XREF: sub_4390A0+3A5j
                                            ; sub_4390A0+3B2j
    test    byte ptr [edx+3Bh], 2
    jz      short loc_43949D
    mov     eax, [edx+2Ch]
    mov     eax, [eax+0DCh]
    test    eax, eax
    jz      short loc_43949D
    mov     ecx, [ebx+0Eh]
    push    1
    push    offset aWeapon2Range            ; "weapon2 range"
    push    esi
    add     ecx, 6Ah
    push    eax
    push    ecx
    push    edi
    push    ebp
    call    sub_438EA0
    mov     edx, [esp+18h+var_8]

    loc_43949D:                             ; CODE XREF: sub_4390A0+3D3j
                                            ; sub_4390A0+3E0j
    test    byte ptr [edx+1Fh], 2
    jz      short loc_4394C7
    mov     edx, [edx+48h]
    mov     eax, [edx+0DCh]
    test    eax, eax
    jz      short loc_4394C7
    push    2
    push    offset aWeapon3Range            ; "weapon3 range"
    push    esi
    push    eax
    mov     eax, [ebx+0Eh]
    add     eax, 6Ah
    push    eax
    push    edi
    push    ebp
    call    sub_438EA0

    loc_4394C7:                             ; CODE XREF: sub_4390A0+7Fj
                                            ; sub_4390A0+8Dj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    14h
    sub_4390A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4394E0 proc near                    ; CODE XREF: sub_439B30+C2p

    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 48h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+54h+arg_C]
    mov     ebp, [esp+54h+arg_10]
    mov     eax, esi
    mov     ebx, [esp+54h+arg_8]
    push    edi
    mov     edi, [eax]
    push    ebp
    push    esi
    push    ebx
    mov     ecx, [eax+4]
    mov     [esp+64h+var_24], edi
    mov     [esp+64h+var_20], ecx
    mov     ecx, [esp+64h+arg_0]
    mov     edx, [eax+8]
    mov     eax, [esp+64h+arg_4]
    push    eax
    push    ecx
    mov     [esp+6Ch+var_1C], edx
    call    sub_439740
    test    ebp, ebp
    jz      loc_43972F
    mov     ebp, TAdynmemStructPtr
    mov     ecx, [esi]
    mov     edx, [esi+4]
    mov     esi, [esi+8]
    mov     eax, [ebp+38A47h]
    sub     eax, [ebx+46h]
    xor     ebx, ebx
    cmp     ebx, eax
    sbb     ebx, ebx
    sub     ecx, edi
    and     ebx, eax
    mov     eax, [esp+58h+var_20]
    mov     edi, ecx
    mov     ecx, [esp+58h+var_1C]
    mov     [esp+58h+var_30], edi
    sub     edx, eax
    fild    [esp+58h+var_30]
    mov     [esp+58h+var_2C], edx
    sub     esi, ecx
    fild    [esp+58h+var_2C]
    mov     [esp+58h+var_28], esi
    fild    [esp+58h+var_28]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    mov     esi, eax
    fstp    st
    cmp     esi, 10000h
    mov     [esp+58h+arg_8], esi
    fstp    st
    jl      loc_43972F
    mov     eax, ebx
    mov     ecx, 1Eh
    cdq
    idiv    ecx
    mov     eax, 88888889h
    mov     ebp, [ebp+148D3h]
    mov     [esp+58h+arg_10], ebp
    lea     ecx, [edx+edx*2]
    shl     ecx, 14h
    imul    ecx
    add     edx, ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ax, [ebp+2Ch]
    cmp     ax, 1
    mov     ecx, edx
    jnb     short loc_4395DC
    mov     [esp+58h+arg_C], 1
    jmp     short loc_4395E5
    ; ---------------------------------------------------------------------------

    loc_4395DC:                             ; CODE XREF: sub_4394E0+F0j
    and     eax, 0FFFFh
    mov     [esp+58h+arg_C], eax

    loc_4395E5:                             ; CODE XREF: sub_4394E0+FAj
    mov     eax, ebx
    xor     ebx, ebx
    cdq
    idiv    [esp+58h+arg_C]
    mov     bx, [ebp+0]
    mov     ebp, ecx
    cdq
    idiv    ebx
    cmp     ecx, esi
    mov     ebx, edx
    jge     loc_43972F
    mov     eax, esi
    cdq
    mov     [esp+58h+var_48], eax
    mov     eax, edi
    mov     [esp+58h+var_44], edx
    cdq
    mov     [esp+58h+var_40], eax
    mov     eax, [esp+58h+var_2C]
    mov     [esp+58h+var_3C], edx
    cdq
    mov     [esp+58h+var_38], eax
    mov     eax, [esp+58h+var_28]
    mov     [esp+58h+var_34], edx
    cdq
    mov     [esp+58h+var_30], eax
    mov     [esp+58h+var_2C], edx

    loc_439631:                             ; CODE XREF: sub_4394E0+249j
    mov     eax, ebp
    mov     ecx, 10h
    cdq
    call    __allshl
    mov     ecx, [esp+58h+var_44]
    push    ecx
    mov     ecx, [esp+5Ch+var_48]
    push    ecx
    push    edx
    push    eax
    call    __alldiv
    cdq
    mov     edi, edx
    mov     edx, [esp+58h+var_3C]
    mov     esi, eax
    mov     eax, [esp+58h+var_40]
    push    edi
    push    esi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ecx, [esp+58h+var_34]
    mov     edx, [esp+58h+var_38]
    push    edi
    push    esi
    push    ecx
    push    edx
    mov     [esp+68h+var_C], eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ecx, [esp+58h+var_30]
    mov     [esp+58h+var_8], eax
    mov     eax, [esp+58h+var_2C]
    push    edi
    push    esi
    push    eax
    push    ecx
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     edx, [esp+58h+var_C]
    mov     ecx, [esp+58h+var_24]
    add     edx, ecx
    mov     ecx, [esp+58h+var_20]
    mov     [esp+58h+var_18], edx
    mov     edx, [esp+58h+var_8]
    add     edx, ecx
    mov     [esp+58h+var_14], edx
    mov     edx, [esp+58h+var_1C]
    add     eax, edx
    mov     [esp+58h+var_10], eax
    movsx   eax, word ptr [esp+58h+var_14+2]
    movsx   ecx, word ptr [esp+58h+var_10+2]
    movsx   edx, word ptr [esp+58h+var_18+2]
    sar     eax, 1
    sub     ecx, eax
    mov     eax, [esp+58h+arg_4]
    mov     esi, [eax+30h]
    sub     ecx, esi
    mov     esi, [eax+2Ch]
    sub     edx, esi
    mov     esi, [esp+58h+arg_10]
    add     ecx, 20h
    add     edx, 80h
    mov     eax, [esi+ebx*8+28h]
    push    ecx
    mov     ecx, [esp+5Ch+arg_0]
    push    edx
    push    eax
    push    ecx
    call    sub_4B7F90
    lea     eax, [ebx+1]
    xor     ecx, ecx
    mov     cx, [esi]
    cdq
    idiv    ecx
    add     ebp, 300000h
    mov     ebx, edx
    cmp     ebp, [esp+58h+arg_8]
    jl      loc_439631

    loc_43972F:                             ; CODE XREF: sub_4394E0+3Dj
                                            ; sub_4394E0+B3j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    14h
    sub_4394E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439740 proc near                    ; CODE XREF: sub_4394E0+36p
                                            ; sub_439B30+14Dp

    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 50h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+5Ch+arg_8]
    push    edi
    mov     eax, [esi+16h]
    mov     ecx, [esi+0Eh]
    test    eax, eax
    mov     [esp+60h+var_50], ecx
    jz      short loc_4397CA
    push    eax                             ; Unit
    mov     eax, [ecx+96h]
    push    eax                             ; Player
    call    PlayerCanSeeUnit
    test    eax, eax
    mov     edx, 200000h
    jnz     short loc_439792
    test    [esi+42h], edx
    jz      short loc_439792
    movsx   eax, word ptr [esi+32h]
    mov     ecx, [esi+16h]
    shl     eax, 10h
    mov     [esp+60h+var_4C], eax
    mov     ebp, [ecx+6Eh]
    movsx   ecx, word ptr [esi+34h]
    mov     [esp+60h+var_48], ebp
    shl     ecx, 10h
    jmp     short loc_4397DE
    ; ---------------------------------------------------------------------------

    loc_439792:                             ; CODE XREF: sub_439740+2Dj
                                            ; sub_439740+32j
    mov     eax, [esi+16h]
    add     eax, 6Ah
    mov     ecx, eax
    mov     eax, [ecx]
    mov     [esp+60h+var_4C], eax
    mov     di, word ptr [esp+60h+var_4C+2]
    mov     ebp, [ecx+4]
    mov     [esp+60h+var_48], ebp
    mov     ecx, [ecx+8]
    mov     [esi+32h], di
    mov     [esp+60h+var_44], ecx
    mov     di, word ptr [esp+60h+var_44+2]
    mov     [esi+34h], di
    mov     edi, [esi+42h]
    or      edi, edx
    mov     [esi+42h], edi
    jmp     short loc_4397E2
    ; ---------------------------------------------------------------------------

    loc_4397CA:                             ; CODE XREF: sub_439740+17j
    lea     edx, [esi+22h]
    mov     eax, [esi+22h]
    mov     [esp+60h+var_4C], eax
    mov     ebp, [edx+4]
    mov     [esp+60h+var_48], ebp
    mov     ecx, [edx+8]

    loc_4397DE:                             ; CODE XREF: sub_439740+50j
    mov     [esp+60h+var_44], ecx

    loc_4397E2:                             ; CODE XREF: sub_439740+88j
    xor     edx, edx
    mov     dl, [esi+4]
    lea     edi, [edx+edx*4]
    mov     edx, dword_512344
    lea     edx, [edx+edi*4]
    mov     dl, [edi+edx+10h]
    test    dl, dl
    jnz     short loc_439811
    mov     edx, [esp+60h+arg_C]
    mov     [edx], eax
    mov     [edx+4], ebp
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 50h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_439811:                             ; CODE XREF: sub_439740+B9j
    mov     edi, TAdynmemStructPtr
    mov     ebp, [esp+60h+arg_4]
    mov     ebx, [esp+60h+arg_0]
    mov     eax, [edi+391BFh]
    test    eax, eax
    jz      loc_439952
    cmp     dl, 1
    jz      short loc_43983B
    cmp     dl, 2
    jnz     loc_439952

    loc_43983B:                             ; CODE XREF: sub_439740+F0j
    test    byte ptr [edi+38A47h], 1
    jz      short loc_439852
    xor     eax, eax
    mov     al, [edi+0DCFh]
    mov     [esp+60h+arg_4], eax
    jmp     short loc_43985E
    ; ---------------------------------------------------------------------------

    loc_439852:                             ; CODE XREF: sub_439740+102j
    xor     ecx, ecx
    mov     cl, [edi+0DD7h]
    mov     [esp+60h+arg_4], ecx

    loc_43985E:                             ; CODE XREF: sub_439740+110j
    mov     edx, [esp+60h+var_50]
    xor     esi, esi
    lea     edi, [edx+10h]

    loc_439867:                             ; CODE XREF: sub_439740+1CEj
    mov     eax, esi
    mov     edx, [esp+60h+var_50]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    test    byte ptr [edx+ecx*4+1Fh], 2
    jz      loc_439907
    mov     eax, [edi]
    cmp     word ptr [eax+0D6h], 0
    jz      short loc_4398C7
    push    esi
    lea     ecx, [esp+64h+var_40]
    push    offset aWeaponDAreaOfE          ; "weapon %d - area of effect"
    push    ecx
    call    _sprintf
    mov     ecx, [edi]
    mov     eax, [esp+6Ch+arg_4]
    add     esp, 0Ch
    lea     edx, [esp+60h+var_40]
    push    0
    push    edx
    xor     edx, edx
    push    eax
    mov     dx, [ecx+0D6h]
    lea     eax, [esp+6Ch+var_4C]
    push    edx
    push    eax
    push    ebp
    push    ebx
    call    sub_438EA0

    loc_4398C7:                             ; CODE XREF: sub_439740+14Ej
    mov     ecx, [edi]
    mov     eax, [ecx+0E0h]
    test    eax, eax
    jz      short loc_439907
    push    esi
    lea     edx, [esp+64h+var_40]
    push    offset aWeaponDCoverag          ; "weapon %d - coverage"
    push    edx
    call    _sprintf
    mov     edx, [edi]
    mov     ecx, [esp+6Ch+arg_4]
    add     esp, 0Ch
    lea     eax, [esp+60h+var_40]
    push    1
    push    eax
    mov     eax, [edx+0E0h]
    push    ecx
    lea     ecx, [esp+6Ch+var_4C]
    push    eax
    push    ecx
    push    ebp
    push    ebx
    call    sub_438EA0

    loc_439907:                             ; CODE XREF: sub_439740+13Ej
                                            ; sub_439740+191j
    inc     esi
    add     edi, 1Ch
    cmp     esi, 3
    jl      loc_439867
    mov     edx, [esp+60h+var_50]
    mov     eax, [edx+92h]
    mov     ax, [eax+216h]
    test    ax, ax
    jz      short loc_439948
    mov     ecx, [esp+60h+arg_4]
    push    2
    push    offset aAttackLength            ; "attack length"
    and     eax, 0FFFFh
    push    ecx
    lea     edx, [esp+6Ch+var_4C]
    push    eax
    push    edx
    push    ebp
    push    ebx
    call    sub_438EA0

    loc_439948:                             ; CODE XREF: sub_439740+1E8j
    mov     esi, [esp+60h+arg_8]
    mov     edi, TAdynmemStructPtr

    loc_439952:                             ; CODE XREF: sub_439740+E7j
                                            ; sub_439740+F5j
    mov     ecx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    xor     ecx, ecx
    mov     cl, [eax+edx+10h]
    movsx   edx, word ptr [esp+60h+var_48+2]
    movsx   eax, word ptr [esp+60h+var_44+2]
    sar     edx, 1
    sub     eax, edx
    mov     edx, [ebp+30h]
    mov     ecx, [edi+ecx*4+1487Fh]
    sub     eax, edx
    movsx   edx, word ptr [esp+60h+var_4C+2]
    add     eax, 20h
    push    eax
    mov     eax, [ebp+2Ch]
    sub     edx, eax
    xor     eax, eax
    mov     ax, [ecx+2Ch]
    add     edx, 80h
    mov     esi, eax
    mov     eax, [edi+38A47h]
    push    edx
    xor     edx, edx
    shl     esi, 1
    div     esi
    xor     esi, esi
    xor     edx, edx
    mov     si, [ecx]
    div     esi
    mov     ecx, [ecx+edx*8+28h]
    push    ecx
    push    ebx
    call    sub_4B8500
    pop     edi
    pop     esi
    mov     edx, [esp+58h+arg_C]
    mov     eax, [esp+58h+var_4C]
    mov     ecx, [esp+58h+var_48]
    pop     ebp
    mov     [edx], eax
    mov     eax, [esp+54h+var_44]
    pop     ebx
    mov     [edx+4], ecx
    mov     [edx+8], eax
    add     esp, 50h
    retn    14h
    sub_439740 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4399F0 proc near                    ; CODE XREF: sub_439B30+107p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     ecx, [esp+arg_8]
    sub     esp, 18h
    mov     eax, [ecx+16h]
    push    ebx
    push    ebp
    push    esi
    test    eax, eax
    push    edi
    jz      short loc_439A2D
    lea     ecx, [eax+6Ah]
    mov     edx, [eax+6Ah]
    mov     [esp+28h+var_C], edx
    mov     edx, [ecx+4]
    mov     [esp+28h+var_8], edx
    mov     edx, [eax+92h]
    mov     ecx, [ecx+8]
    movsx   eax, word ptr [edx+178h]
    mov     [esp+28h+var_4], ecx
    mov     [esp+28h+arg_8], eax
    jmp     short loc_439A4C
    ; ---------------------------------------------------------------------------

    loc_439A2D:                             ; CODE XREF: sub_4399F0+10j
    add     ecx, 22h
    mov     [esp+28h+arg_8], 20h
    mov     edx, [ecx]
    mov     [esp+28h+var_C], edx
    mov     eax, [ecx+4]
    mov     [esp+28h+var_8], eax
    mov     ecx, [ecx+8]
    mov     [esp+28h+var_4], ecx

    loc_439A4C:                             ; CODE XREF: sub_4399F0+3Bj
    fild    [esp+28h+arg_8]
    fmul    ds:dbl_4FD2C0
    call    __ftol
    movsx   edi, word ptr [esp+28h+var_C+2]
    movsx   ebp, word ptr [esp+28h+var_4+2]
    movsx   edx, word ptr [esp+28h+var_8+2]
    mov     [esp+28h+var_10], eax
    mov     eax, [esp+28h+arg_4]
    sar     edx, 1
    mov     ecx, [eax+2Ch]
    mov     ebx, [eax+30h]
    mov     eax, [esp+28h+arg_8]
    sub     edi, ecx
    sub     ebp, ebx
    add     edi, 80h
    sub     ebp, edx
    mov     [esp+28h+var_14], edi
    add     ebp, 20h
    lea     ecx, [edi+eax]
    mov     [esp+28h+arg_4], ecx
    mov     [esp+28h+var_18], ebp
    mov     ebx, 1000h
    jmp     short loc_439AA7
    ; ---------------------------------------------------------------------------

    loc_439AA3:                             ; CODE XREF: sub_4399F0+114j
    mov     edi, [esp+28h+var_14]

    loc_439AA7:                             ; CODE XREF: sub_4399F0+B1j
    mov     edx, [esp+28h+arg_8]
    push    edx
    push    ebx
    call    sub_4B7123
    add     esp, 8
    mov     esi, eax
    mov     eax, [esp+28h+var_10]
    add     esi, edi
    push    eax
    push    ebx
    call    sub_4B70EF
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    add     esp, 8
    mov     edi, eax
    mov     cl, [edx+0DD7h]
    mov     eax, [esp+28h+var_18]
    mov     edx, [esp+28h+arg_0]
    add     edi, ebp
    push    ecx
    mov     ecx, [esp+2Ch+arg_4]
    push    edi
    push    esi
    push    eax
    push    ecx
    push    edx
    call    sub_4BE950
    add     ebx, 1000h
    cmp     ebx, 10000h
    mov     [esp+28h+arg_4], esi
    mov     [esp+28h+var_18], edi
    jle     short loc_439AA3
    mov     eax, [esp+28h+arg_C]
    mov     ecx, [esp+28h+var_C]
    mov     edx, [esp+28h+var_8]
    pop     edi
    mov     [eax], ecx
    mov     ecx, [esp+24h+var_4]
    pop     esi
    pop     ebp
    mov     [eax+4], edx
    pop     ebx
    mov     [eax+8], ecx
    add     esp, 18h
    retn    14h
    sub_4399F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439B30 proc near                    ; CODE XREF: sub_48CC30+121p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 0Ch
    mov     ecx, [esp+0Ch+arg_0]
    push    ebx
    push    ebp
    push    esi
    lea     eax, [ecx+6Ah]
    push    edi
    mov     edx, eax
    mov     esi, [ecx+5Ch]
    test    esi, esi
    mov     edi, [edx]
    mov     byte ptr [esp+1Ch+arg_0], 0
    mov     ebp, [edx+4]
    mov     ebx, [edx+8]
    mov     edx, [eax]
    mov     [esp+1Ch+var_C], edx
    mov     edx, [eax+4]
    mov     eax, [eax+8]
    mov     [esp+1Ch+var_8], edx
    mov     [esp+1Ch+var_4], eax
    jz      loc_439CDF

    loc_439B6C:                             ; CODE XREF: sub_439B30+1A9j
    mov     ecx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    mov     eax, [eax+edx+0Ch]
    mov     edx, [esp+1Ch+arg_4]
    and     eax, edx
    test    al, 1
    jz      short loc_439BB1
    mov     ecx, [esp+1Ch+arg_10]
    mov     eax, [esp+1Ch+arg_C]
    lea     edx, [esp+1Ch+var_C]
    push    ecx
    mov     ecx, [esp+20h+arg_8]
    push    edx
    push    esi
    push    eax
    push    ecx
    mov     [esp+30h+var_C], edi
    mov     [esp+30h+var_8], ebp
    mov     [esp+30h+var_4], ebx
    call    sub_438C00

    loc_439BB1:                             ; CODE XREF: sub_439B30+59j
    mov     edx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    lea     eax, [eax+eax*4]
    lea     ecx, [edx+eax*4]
    mov     edx, [eax+ecx+0Ch]
    mov     ecx, [esp+1Ch+arg_4]
    and     edx, ecx
    test    dl, 2
    jz      short loc_439BF7
    mov     eax, [esp+1Ch+arg_10]
    mov     edx, [esp+1Ch+arg_C]
    lea     ecx, [esp+1Ch+var_C]
    push    eax
    mov     eax, [esp+20h+arg_8]
    push    ecx
    push    esi
    push    edx
    push    eax
    mov     [esp+30h+var_C], edi
    mov     [esp+30h+var_8], ebp
    mov     [esp+30h+var_4], ebx
    call    sub_4394E0

    loc_439BF7:                             ; CODE XREF: sub_439B30+9Fj
    mov     ecx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    mov     eax, [eax+edx+0Ch]
    mov     edx, [esp+1Ch+arg_4]
    and     eax, edx
    test    al, 4
    jz      short loc_439C3C
    mov     ecx, [esp+1Ch+arg_10]
    mov     eax, [esp+1Ch+arg_C]
    lea     edx, [esp+1Ch+var_C]
    push    ecx
    mov     ecx, [esp+20h+arg_8]
    push    edx
    push    esi
    push    eax
    push    ecx
    mov     [esp+30h+var_C], edi
    mov     [esp+30h+var_8], ebp
    mov     [esp+30h+var_4], ebx
    call    sub_4399F0

    loc_439C3C:                             ; CODE XREF: sub_439B30+E4j
    mov     edx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    lea     eax, [eax+eax*4]
    lea     ecx, [edx+eax*4]
    mov     edx, [eax+ecx+0Ch]
    mov     ecx, [esp+1Ch+arg_4]
    and     edx, ecx
    test    dl, 8
    jz      short loc_439C82
    mov     eax, [esp+1Ch+arg_10]
    mov     edx, [esp+1Ch+arg_C]
    lea     ecx, [esp+1Ch+var_C]
    push    eax
    mov     eax, [esp+20h+arg_8]
    push    ecx
    push    esi
    push    edx
    push    eax
    mov     [esp+30h+var_C], edi
    mov     [esp+30h+var_8], ebp
    mov     [esp+30h+var_4], ebx
    call    sub_439740

    loc_439C82:                             ; CODE XREF: sub_439B30+12Aj
    mov     ecx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    mov     eax, [eax+edx+0Ch]
    mov     edx, [esp+1Ch+arg_4]
    and     eax, edx
    test    al, 10h
    jz      short loc_439CC8
    mov     al, byte ptr [esp+1Ch+arg_0]
    test    al, al
    jnz     short loc_439CC8
    mov     ecx, [esp+1Ch+arg_10]
    mov     eax, [esp+1Ch+arg_C]
    lea     edx, [esp+1Ch+var_C]
    push    ecx
    mov     ecx, [esp+20h+arg_8]
    push    edx
    push    esi
    push    eax
    push    ecx
    call    sub_4390A0
    mov     byte ptr [esp+1Ch+arg_0], 1

    loc_439CC8:                             ; CODE XREF: sub_439B30+16Fj
                                            ; sub_439B30+177j
    mov     esi, [esi+4Ah]
    mov     edi, [esp+1Ch+var_C]
    mov     ebp, [esp+1Ch+var_8]
    mov     ebx, [esp+1Ch+var_4]
    test    esi, esi
    jnz     loc_439B6C

    loc_439CDF:                             ; CODE XREF: sub_439B30+36j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    14h
    sub_439B30 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    test    ecx, ecx
    jnz     short loc_439CFC
    xor     eax, eax
    jmp     short loc_439D06
    ; ---------------------------------------------------------------------------

    loc_439CFC:                             ; CODE XREF: .text:00439CF6j
    mov     eax, [ecx+5Ch]
    test    eax, eax
    jz      short loc_439D06
    mov     eax, [eax+42h]

    loc_439D06:                             ; CODE XREF: .text:00439CFAj
                                            ; .text:00439D01j
    test    al, 8
    jz      short loc_439D13
    mov     eax, [ecx+5Ch]
    mov     eax, [eax+16h]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_439D13:                             ; CODE XREF: .text:00439D08j
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439D20 proc near                    ; CODE XREF: LOS_GUIText+BE6p

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    esi
    mov     eax, dword ptr [edx+UnitStruct.UnitState]
    test    eax, eax
    jz      short loc_439D6B
    mov     ecx, 80000h

    loc_439D31:                             ; CODE XREF: sub_439D20+1Bj
    test    [eax+42h], ecx
    jnz     short loc_439D41
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_439D31
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_439D41:                             ; CODE XREF: sub_439D20+14j
    mov     ecx, [eax+36h]
    mov     eax, [eax+3Eh]
    mov     esi, ecx
    shl     esi, 3
    lea     eax, [eax+eax*4]
    sub     esi, ecx
    mov     ecx, [edx+esi*4+10h]
    lea     eax, [eax+eax*4]
    shl     eax, 2
    xor     esi, esi
    mov     si, [ecx+0E4h]
    cdq
    idiv    esi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_439D6B:                             ; CODE XREF: sub_439D20+Aj
    xor     eax, eax
    pop     esi
    retn    4
    sub_439D20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439D80 proc near                    ; CODE XREF: sub_4199B0+64p
                                            ; sub_4199B0+89p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_4]
    mov     ecx, [edx+5Ch]
    xor     eax, eax
    push    edi
    mov     edi, 100h
    test    ecx, ecx
    jz      short loc_439DAC

    loc_439D98:                             ; CODE XREF: sub_439D80+2Aj
    test    [ecx+42h], edi
    jz      short loc_439DA5
    cmp     [ecx+36h], esi
    jnz     short loc_439DA5
    add     eax, [ecx+3Ah]

    loc_439DA5:                             ; CODE XREF: sub_439D80+1Bj
                                            ; sub_439D80+20j
    mov     ecx, [ecx+4Ah]
    test    ecx, ecx
    jnz     short loc_439D98

    loc_439DAC:                             ; CODE XREF: sub_439D80+16j
    mov     ecx, [edx+60h]
    test    ecx, ecx
    jz      short loc_439DC7

    loc_439DB3:                             ; CODE XREF: sub_439D80+45j
    test    [ecx+42h], edi
    jz      short loc_439DC0
    cmp     [ecx+36h], esi
    jnz     short loc_439DC0
    add     eax, [ecx+3Ah]

    loc_439DC0:                             ; CODE XREF: sub_439D80+36j
                                            ; sub_439D80+3Bj
    mov     ecx, [ecx+4Ah]
    test    ecx, ecx
    jnz     short loc_439DB3

    loc_439DC7:                             ; CODE XREF: sub_439D80+31j
    pop     edi
    pop     esi
    retn    8
    sub_439D80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439DD0 proc near                    ; CODE XREF: LOS_GUIText+441p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short loc_439DE5
    mov     eax, [eax+5Ch]
    test    eax, eax
    jz      short loc_439DE5
    mov     eax, [eax+16h]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_439DE5:                             ; CODE XREF: sub_439DD0+6j
                                            ; sub_439DD0+Dj
    xor     eax, eax
    retn    4
    sub_439DD0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439DF0 proc near                    ; CODE XREF: LOS_GUIText+3B9p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short loc_439E19
    mov     eax, [eax+5Ch]
    test    eax, eax
    jz      short loc_439E19
    xor     ecx, ecx
    mov     cl, [eax+4]
    mov     eax, ecx
    mov     ecx, dword_512344
    lea     eax, [eax+eax*4]
    mov     edx, eax
    add     edx, ecx
    mov     eax, [edx+eax*4]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_439E19:                             ; CODE XREF: sub_439DF0+6j
                                            ; sub_439DF0+Dj
    mov     eax, dword_512344
    mov     eax, [eax]
    retn    4
    sub_439DF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439E30 proc near                    ; CODE XREF: .text:0049645Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_4]
    mov     edx, dword_512344
    mov     eax, ecx
    and     eax, 0FFh
    lea     eax, [eax+eax*4]
    lea     edx, [edx+eax*4]
    test    dword ptr [eax+edx+11h], 40000h
    jz      short loc_439E5A
    mov     eax, [esp+arg_0]
    mov     eax, [eax+60h]
    jmp     short loc_439E61
    ; ---------------------------------------------------------------------------

    loc_439E5A:                             ; CODE XREF: sub_439E30+1Fj
    mov     edx, [esp+arg_0]
    mov     eax, [edx+5Ch]

    loc_439E61:                             ; CODE XREF: sub_439E30+28j
    test    eax, eax
    jz      short loc_439E71

    loc_439E65:                             ; CODE XREF: sub_439E30+3Fj
    cmp     [eax+4], cl
    jz      short locret_439E73
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_439E65

    loc_439E71:                             ; CODE XREF: sub_439E30+33j
    xor     eax, eax

    locret_439E73:                          ; CODE XREF: sub_439E30+38j
    retn    8
    sub_439E30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439E80 proc near                    ; CODE XREF: .text:00401D99p
                                            ; .text:00401DE2p ...

    arg_0= dword ptr  4

    mov     edx, [ecx+6]
    or      edx, 1
    mov     [ecx+6], edx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+38A47h]
    mov     eax, [esp+arg_0]
    add     edx, eax
    mov     [ecx+0Ah], edx
    retn    4
    sub_439E80 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439EA0 proc near                    ; DATA XREF: .rdata:004FD28Co
    mov     eax, 5
    retn    0Ch
    sub_439EA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439EB0 proc near                    ; CODE XREF: sub_406F80+71p
                                            ; sub_43B7C0+2D7p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    ebx
    push    ebp
    push    esi
    lea     ecx, [eax+5Ch]
    mov     ebx, [esp+10h+arg_4]
    push    edi
    mov     edi, ecx
    mov     ebp, [ecx]
    mov     [esp+14h+var_4], ecx
    mov     esi, [edi]
    test    esi, esi
    jz      short loc_439F0B

    loc_439ECE:                             ; CODE XREF: sub_439EB0+59j
    test    ebx, ebx
    jnz     short loc_439EDD
    test    byte ptr [esi+42h], 4
    jz      short loc_439EDD
    lea     edi, [esi+4Ah]
    jmp     short loc_439F05
    ; ---------------------------------------------------------------------------

    loc_439EDD:                             ; CODE XREF: sub_439EB0+20j
                                            ; sub_439EB0+26j
    mov     edx, [esi+4Ah]
    cmp     esi, ebp
    mov     [edi], edx
    jz      short loc_439EED
    or      dword ptr [esi+42h], 10000h

    loc_439EED:                             ; CODE XREF: sub_439EB0+34j
    test    esi, esi
    jz      short loc_439F05
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    mov     ecx, [esp+18h+var_4]
    add     esp, 4

    loc_439F05:                             ; CODE XREF: sub_439EB0+2Bj
                                            ; sub_439EB0+3Fj
    mov     esi, [edi]
    test    esi, esi
    jnz     short loc_439ECE

    loc_439F0B:                             ; CODE XREF: sub_439EB0+1Cj
    test    ebx, ebx
    jz      short loc_439F73
    mov     eax, [esp+14h+arg_0]
    mov     esi, [eax+60h]
    lea     edi, [eax+60h]
    test    esi, esi
    jz      short loc_439F73
    mov     ebx, 40000h
    jmp     short loc_439F28
    ; ---------------------------------------------------------------------------

    loc_439F24:                             ; CODE XREF: sub_439EB0+C1j
    mov     ecx, [esp+14h+var_4]

    loc_439F28:                             ; CODE XREF: sub_439EB0+72j
    mov     eax, [esi+42h]
    mov     edx, [ecx]
    test    ebx, eax
    jz      short loc_439F33
    mov     ecx, edi

    loc_439F33:                             ; CODE XREF: sub_439EB0+7Fj
    mov     eax, [ecx]
    test    eax, eax
    jz      short loc_439F6D

    loc_439F39:                             ; CODE XREF: sub_439EB0+95j
    cmp     eax, esi
    jz      short loc_439F49
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_439F39
    jmp     short loc_439F6D
    ; ---------------------------------------------------------------------------

    loc_439F49:                             ; CODE XREF: sub_439EB0+8Bj
    mov     eax, [esi+4Ah]
    cmp     esi, edx
    mov     [ecx], eax
    jz      short loc_439F59
    or      dword ptr [esi+42h], 10000h

    loc_439F59:                             ; CODE XREF: sub_439EB0+A0j
    test    esi, esi
    jz      short loc_439F6D
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_439F6D:                             ; CODE XREF: sub_439EB0+87j
                                            ; sub_439EB0+97j ...
    mov     esi, [edi]
    test    esi, esi
    jnz     short loc_439F24

    loc_439F73:                             ; CODE XREF: sub_439EB0+5Dj
                                            ; sub_439EB0+6Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_439EB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_439F80 proc near                    ; CODE XREF: sub_43B7C0+2BCp
                                            ; .text:0049646Fp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_4]
    mov     edx, [eax+5Ch]
    lea     ecx, [eax+5Ch]
    test    dword ptr [esi+42h], 40000h
    jz      short loc_439F9B
    lea     ecx, [eax+60h]

    loc_439F9B:                             ; CODE XREF: sub_439F80+16j
    mov     eax, [ecx]
    test    eax, eax
    jz      short loc_439FD7

    loc_439FA1:                             ; CODE XREF: sub_439F80+2Dj
    cmp     eax, esi
    jz      short loc_439FB3
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_439FA1
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_439FB3:                             ; CODE XREF: sub_439F80+23j
    mov     eax, [esi+4Ah]
    cmp     esi, edx
    mov     [ecx], eax
    jz      short loc_439FC3
    or      dword ptr [esi+42h], 10000h

    loc_439FC3:                             ; CODE XREF: sub_439F80+3Aj
    test    esi, esi
    jz      short loc_439FD7
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_439FD7:                             ; CODE XREF: sub_439F80+1Fj
                                            ; sub_439F80+45j
    pop     esi
    retn    8
    sub_439F80 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     edx, [esp+8]
    add     eax, 5Ch
    mov     ecx, [eax]
    cmp     ecx, edx
    jz      short loc_439FFB

    loc_439FF1:                             ; CODE XREF: .text:00439FF9j
    lea     eax, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, edx
    jnz     short loc_439FF1

    loc_439FFB:                             ; CODE XREF: .text:00439FEFj
    mov     ecx, [edx+4Ah]
    test    ecx, ecx
    mov     [eax], ecx
    jz      short loc_43A00E

    loc_43A004:                             ; CODE XREF: .text:0043A00Cj
    lea     eax, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    test    ecx, ecx
    jnz     short loc_43A004

    loc_43A00E:                             ; CODE XREF: .text:0043A002j
    mov     [eax], edx
    mov     dword ptr [edx+4Ah], 0
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43A020 proc near                    ; CODE XREF: .text:0040347Ap
                                            ; .text:00405D7Cp ...

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     ecx, 1
    mov     ebp, 8000h
    mov     eax, [edi+5Ch]
    lea     esi, [edi+5Ch]
    test    eax, eax
    jz      short loc_43A04C

    loc_43A03C:                             ; CODE XREF: sub_43A020+26j
    test    [eax+42h], ebp
    jnz     short loc_43A04A
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_43A03C
    jmp     short loc_43A04C
    ; ---------------------------------------------------------------------------

    loc_43A04A:                             ; CODE XREF: sub_43A020+1Fj
    xor     ecx, ecx

    loc_43A04C:                             ; CODE XREF: sub_43A020+1Aj
                                            ; sub_43A020+28j
    mov     ebx, [esp+arg_4]
    test    ecx, ecx
    jz      short loc_43A0A9
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43A07B
    mov     dl, [ebx+4]
    push    0
    push    0
    lea     ecx, [edi+6Ah]
    push    0
    push    ecx
    push    0
    push    edx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43A07D
    ; ---------------------------------------------------------------------------

    loc_43A07B:                             ; CODE XREF: sub_43A020+40j
    xor     eax, eax

    loc_43A07D:                             ; CODE XREF: sub_43A020+59j
    mov     ecx, [eax+42h]
    lea     edx, [edi+60h]
    test    ecx, 40000h
    jnz     short loc_43A08D
    mov     edx, esi

    loc_43A08D:                             ; CODE XREF: sub_43A020+69j
    mov     ecx, [edx]
    test    ecx, ecx
    jz      short loc_43A09D

    loc_43A093:                             ; CODE XREF: sub_43A020+7Bj
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    test    ecx, ecx
    jnz     short loc_43A093

    loc_43A09D:                             ; CODE XREF: sub_43A020+71j
    mov     [edx], eax
    mov     [eax+0Eh], edi
    mov     dword ptr [eax+4Ah], 0

    loc_43A0A9:                             ; CODE XREF: sub_43A020+32j
    mov     eax, [ebx+42h]
    pop     edi
    or      eax, ebp
    pop     esi
    mov     [ebx+42h], eax
    pop     ebp
    pop     ebx
    retn    8
    sub_43A020 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43A0C0 proc near                    ; CODE XREF: sub_401C20+72p
                                            ; .text:00401F52p ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 0Ch
    mov     al, byte ptr [esp+0Ch+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     edi, [esp+1Ch+arg_4]
    xor     ebx, ebx
    lea     ebp, [esi+12h]
    push    ebx
    push    edi
    mov     ecx, ebp
    mov     dword ptr [esi], offset off_4FD2CC
    mov     [esi+4], al
    call    sub_4895C0
    mov     eax, [esp+1Ch+arg_C]
    mov     word ptr [esp+1Ch+arg_4], bx
    mov     word ptr [esp+1Ch+arg_4+2], bx
    mov     ecx, [esp+1Ch+arg_4]
    mov     word ptr [esp+1Ch+arg_4], bx
    mov     word ptr [esp+1Ch+arg_4+2], bx
    mov     edx, [esp+1Ch+arg_4]
    mov     [esi+2Eh], ecx
    mov     ecx, [esp+1Ch+arg_10]
    mov     [esi+32h], edx
    mov     edx, [esp+1Ch+arg_14]
    mov     [esi+36h], eax
    mov     [esi+3Ah], ecx
    mov     [esi+3Eh], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    mov     eax, [esp+1Ch+arg_8]
    mov     [esi+46h], ecx
    mov     dword ptr [esi], offset off_4FD2C8
    mov     [esi+1Eh], esi
    cmp     eax, ebx
    mov     [esi+5], bl
    mov     [esi+6], ebx
    mov     [esi+4Eh], ebx
    mov     dword ptr [esi+0Ah], 0FFFFFFFFh
    jnz     short loc_43A164
    xor     eax, eax
    xor     ecx, ecx
    xor     edx, edx
    mov     [esp+1Ch+var_C], eax
    mov     [esp+1Ch+var_8], ecx
    mov     [esp+1Ch+var_4], edx
    lea     eax, [esp+1Ch+var_C]

    loc_43A164:                             ; CODE XREF: sub_43A0C0+8Cj
    mov     ecx, [eax]
    lea     edx, [esi+22h]
    mov     [esi+22h], ecx
    mov     ecx, [eax+4]
    mov     [edx+4], ecx
    mov     eax, [eax+8]
    mov     [edx+8], eax
    mov     eax, [esp+1Ch+arg_0]
    mov     ecx, dword_512344
    and     eax, 0FFh
    cmp     edi, ebx
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    mov     eax, [eax+edx+11h]
    mov     [esi+0Eh], ebx
    mov     [esi+42h], eax
    mov     [esi+4Ah], ebx
    mov     [esi+52h], ebx
    jnz     short loc_43A1A7
    and     ah, 0FDh
    mov     [esi+42h], eax

    loc_43A1A7:                             ; CODE XREF: sub_43A0C0+DFj
    cmp     [esp+1Ch+arg_8], ebx
    jnz     short loc_43A1B6
    mov     eax, [esi+42h]
    and     ah, 0FBh
    mov     [esi+42h], eax

    loc_43A1B6:                             ; CODE XREF: sub_43A0C0+EBj
    mov     eax, [esi+42h]
    test    ah, 2
    jnz     short loc_43A1C6
    push    ebx
    mov     ecx, ebp
    call    sub_489690

    loc_43A1C6:                             ; CODE XREF: sub_43A0C0+FCj
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    18h
    sub_43A0C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_34. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43A1F0 proc near                    ; CODE XREF: sub_4384A0+44p
                                            ; sub_439EB0+43p ...
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    mov     al, [esi+6]
    mov     dword ptr [esi], offset off_4FD2C8
    test    al, 2
    jz      short loc_43A21E
    mov     ecx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    push    2
    push    esi
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    mov     ecx, [esi+0Eh]
    push    ecx
    call    dword ptr [eax+edx+4]

    loc_43A21E:                             ; CODE XREF: sub_43A1F0+10j
    test    dword ptr [esi+42h], 400000h
    jz      short loc_43A264
    mov     edi, [esi+0Eh]
    push    offset aStopbuilding            ; "StopBuilding"
    mov     ecx, [edi+9Ah]
    call    sub_4B07C0
    mov     ecx, [edi+9Ah]
    push    0
    push    0
    push    0
    push    0
    push    0
    mov     ebx, eax
    push    0
    push    0
    push    ebx
    call    sub_4B0B00
    push    ebx
    push    edi
    call    sub_456190
    and     dword ptr [esi+42h], 0FFBFFFFFh

    loc_43A264:                             ; CODE XREF: sub_43A1F0+35j
    mov     edx, [esi+0Eh]
    mov     eax, [edx]
    test    eax, eax
    jz      short loc_43A2AB
    mov     ecx, [eax]
    mov     eax, [ecx+4]
    test    eax, eax
    jz      short loc_43A297
    mov     edx, [esi+52h]
    cmp     eax, edx
    jnz     short loc_43A297
    test    edx, edx
    jz      short loc_43A2AB
    mov     eax, [ecx]
    push    0
    call    dword ptr [eax+4]
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_43A2A4
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]
    jmp     short loc_43A2A4
    ; ---------------------------------------------------------------------------

    loc_43A297:                             ; CODE XREF: sub_43A1F0+84j
                                            ; sub_43A1F0+8Bj
    mov     ecx, [esi+52h]
    test    ecx, ecx
    jz      short loc_43A2A4
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_43A2A4:                             ; CODE XREF: sub_43A1F0+9Dj
                                            ; sub_43A1F0+A5j ...
    mov     dword ptr [esi+52h], 0

    loc_43A2AB:                             ; CODE XREF: sub_43A1F0+7Bj
                                            ; sub_43A1F0+8Fj
    test    dword ptr [esi+42h], 10000h
    jnz     short loc_43A2BE
    mov     ecx, [esi+0Eh]
    push    3
    call    sub_489800

    loc_43A2BE:                             ; CODE XREF: sub_43A1F0+C2j
    lea     ecx, [esi+12h]
    call    sub_489650
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_43A1F0 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 80h
    lea     eax, [esp+0]
    push    ebx
    mov     ebx, [esp+8Ch]
    push    esi
    mov     esi, ebx
    and     esi, 0FFFFh
    push    edi
    push    esi
    push    offset aUtypename4d             ; "UTYPENAME%4d"
    push    eax
    call    _sprintf
    mov     edi, [esp+9Ch]
    add     esp, 0Ch
    lea     ecx, [esp+0Ch]
    push    ecx
    mov     ecx, edi
    call    sub_4B48F0
    test    eax, eax
    jnz     short loc_43A347
    cmp     bx, 1
    jb      short loc_43A347
    mov     ecx, TAdynmemStructPtr
    cmp     esi, [ecx+1438Fh]
    jge     short loc_43A347
    mov     eax, esi
    shl     eax, 6
    add     eax, esi
    lea     edx, [eax+eax*8]
    mov     eax, [ecx+1439Bh]
    lea     ecx, [eax+edx+20h]
    lea     edx, [esp+0Ch]
    push    ecx
    push    edx
    mov     ecx, edi
    call    sub_4B4750

    loc_43A347:                             ; CODE XREF: .text:0043A310j
                                            ; .text:0043A316j ...
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 80h
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    sub     esp, 80h
    and     eax, 0FFFFh
    lea     ecx, [esp+0]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    eax
    push    offset aUtypename4d             ; "UTYPENAME%4d"
    push    ecx
    call    _sprintf
    mov     esi, [esp+0A0h]
    add     esp, 0Ch
    lea     edx, [esp+10h]
    mov     ecx, esi
    push    edx
    call    sub_4B48F0
    test    eax, eax
    jz      short loc_43A3BE
    lea     eax, [esp+10h]
    push    0
    push    eax
    mov     ecx, esi
    call    sub_4B48A0
    push    eax
    call    sub_488B10
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 80h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_43A3BE:                             ; CODE XREF: .text:0043A39Bj
    mov     ecx, TAdynmemStructPtr
    mov     esi, 1
    xor     eax, eax
    xor     ebp, ebp
    mov     ebx, [ecx+1438Fh]
    cmp     ebx, esi
    jle     short loc_43A40A
    mov     edi, [ecx+1439Bh]

    loc_43A3DD:                             ; CODE XREF: .text:0043A408j
    mov     edx, esi
    and     edx, 0FFFFh
    mov     ecx, edx
    shl     ecx, 6
    add     ecx, edx
    lea     edx, [edi+ecx*8]
    test    byte ptr [ecx+edx+241h], 20h
    jnz     short loc_43A404
    cmp     bp, [esp+98h]
    jz      short loc_43A40D
    inc     ebp

    loc_43A404:                             ; CODE XREF: .text:0043A3F7j
    inc     esi
    inc     eax
    cmp     esi, ebx
    jl      short loc_43A3DD

    loc_43A40A:                             ; CODE XREF: .text:0043A3D5j
    xor     ax, ax

    loc_43A40D:                             ; CODE XREF: .text:0043A401j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 80h
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43A420 proc near                    ; CODE XREF: sub_487080+514p

    var_164= dword ptr -164h
    var_160= dword ptr -160h
    var_15C= dword ptr -15Ch
    var_158= dword ptr -158h
    var_154= dword ptr -154h
    var_14E= dword ptr -14Eh
    var_14A= dword ptr -14Ah
    var_146= dword ptr -146h
    var_142= dword ptr -142h
    var_13E= dword ptr -13Eh
    var_13A= dword ptr -13Ah
    var_136= dword ptr -136h
    var_132= dword ptr -132h
    var_12E= dword ptr -12Eh
    var_12A= dword ptr -12Ah
    var_126= dword ptr -126h
    var_120= dword ptr -120h
    var_100= byte ptr -100h
    var_80= byte ptr -80h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 164h
    push    ebx
    push    ebp
    push    esi
    mov     ebp, ecx
    push    edi
    xor     edi, edi
    lea     esi, [ebp+12h]
    push    edi
    mov     dword ptr [ebp+0], offset off_4FD2CC
    push    edi
    mov     ecx, esi
    mov     byte ptr [ebp+4], 0
    call    sub_4895C0
    mov     dword ptr [ebp+0], offset off_4FD2C8
    push    edi
    mov     ecx, esi
    mov     [ebp+1Eh], ebp
    call    sub_489690
    mov     ebx, [esp+174h+arg_4]
    mov     [ebp+4Ah], edi
    mov     [ebp+52h], edi
    mov     eax, TAdynmemStructPtr
    cmp     ebx, edi
    mov     ecx, [eax+38A47h]
    mov     [ebp+46h], ecx
    jz      loc_43A901
    mov     esi, [esp+174h+arg_8]
    cmp     esi, edi
    jz      loc_43A901
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     ecx, 1Fh
    ja      loc_43A901
    push    esi
    mov     ecx, ebx
    call    sub_4B4BA0
    push    0
    mov     ecx, ebx
    call    sub_4B4C10
    lea     edx, [esp+174h+var_15C]
    push    3Ah
    push    edx
    mov     ecx, ebx
    call    sub_4B4C80
    cmp     eax, 3Ah
    jnz     loc_43A901
    push    offset a_name                   ; "_name"
    push    esi
    lea     eax, [esp+17Ch+var_80]
    push    offset aSS_2                    ; "%s%s"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+174h+var_80]
    push    0                               ; int
    push    ecx                             ; char *
    mov     ecx, ebx
    call    sub_4B48A0
    test    eax, eax
    jz      short loc_43A556
    mov     ecx, dword_512344
    mov     [esp+174h+var_164], eax
    mov     eax, dword_512348
    push    0
    lea     edx, [esp+178h+var_164]
    push    offset loc_43A940
    push    edx
    push    eax
    push    ecx
    call    sub_43C6B0
    mov     esi, eax
    mov     eax, dword_512348
    cmp     esi, eax
    jz      short loc_43A552
    mov     edx, [esp+174h+var_164]
    mov     eax, [esi+15h]
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_43A552
    mov     eax, dword_512344
    sub     esi, eax
    mov     eax, 51EB851Fh
    imul    esi
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    jmp     short loc_43A59A
    ; ---------------------------------------------------------------------------

    loc_43A552:                             ; CODE XREF: sub_43A420+101j
                                            ; sub_43A420+116j
    xor     dl, dl
    jmp     short loc_43A59A
    ; ---------------------------------------------------------------------------

    loc_43A556:                             ; CODE XREF: sub_43A420+D4j
    mov     eax, dword_512344
    mov     esi, dword_512348
    xor     ecx, ecx
    xor     edx, edx
    cmp     eax, esi
    ja      short loc_43A598
    mov     edi, [esp+174h+var_154]

    loc_43A56D:                             ; CODE XREF: sub_43A420+16Dj
    test    byte ptr [eax+14h], 1
    jnz     short loc_43A587
    mov     ebx, edi
    and     ebx, 0FFh
    cmp     edx, ebx
    jz      short loc_43A591
    mov     ebx, [esp+174h+arg_4]
    inc     edx

    loc_43A587:                             ; CODE XREF: sub_43A420+151j
    add     eax, 19h
    inc     ecx
    cmp     eax, esi
    jbe     short loc_43A56D
    jmp     short loc_43A598
    ; ---------------------------------------------------------------------------

    loc_43A591:                             ; CODE XREF: sub_43A420+15Dj
    mov     ebx, [esp+174h+arg_4]

    loc_43A598:                             ; CODE XREF: sub_43A420+147j
                                            ; sub_43A420+16Fj
    mov     dl, cl

    loc_43A59A:                             ; CODE XREF: sub_43A420+130j
                                            ; sub_43A420+134j
    cmp     word ptr [esp+174h+var_15C], 0
    mov     byte ptr [esp+174h+var_154], dl
    jnz     short loc_43A5AA
    xor     ecx, ecx
    jmp     short loc_43A5CD
    ; ---------------------------------------------------------------------------

    loc_43A5AA:                             ; CODE XREF: sub_43A420+184j
    mov     ecx, [esp+174h+var_15C]
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]

    loc_43A5CD:                             ; CODE XREF: sub_43A420+188j
    mov     eax, [esp+174h+arg_0]
    cmp     eax, ecx
    jnz     loc_43A901
    test    dl, dl
    jz      loc_43A901
    mov     edx, [esp+174h+var_15C+2]
    push    ebx
    push    edx
    mov     [ebp+0Eh], eax
    call    sub_487080
    push    eax
    lea     ecx, [ebp+12h]
    call    sub_489690
    mov     cl, byte ptr [esp+174h+var_154+1]
    mov     al, byte ptr [esp+174h+var_154]
    mov     edx, [esp+174h+var_154+2]
    mov     [ebp+5], cl
    mov     [ebp+4], al
    mov     eax, [esp+174h+var_14E]
    mov     [ebp+6], edx
    mov     edx, [esp+174h+var_14A]
    lea     ecx, [ebp+22h]
    mov     [ebp+0Ah], eax
    mov     eax, [esp+174h+var_146]
    mov     esi, offset aMobilebuild_0      ; "MobileBuild"
    mov     [ecx], edx
    mov     edx, [esp+174h+var_142]
    mov     [ecx+4], eax
    mov     eax, [esp+174h+var_13E]
    mov     [ebp+2Eh], eax
    mov     eax, [esp+174h+var_132]
    mov     [ebp+3Ah], eax
    mov     eax, [esp+174h+var_126]
    mov     [ecx+8], edx
    mov     ecx, [esp+174h+var_13A]
    mov     edx, [esp+174h+var_136]
    mov     [ebp+4Eh], eax
    mov     eax, [esp+174h+var_154]
    mov     [ebp+32h], ecx
    mov     ecx, [esp+174h+var_12E]
    mov     [ebp+36h], edx
    mov     edx, [esp+174h+var_12A]
    and     eax, 0FFh
    mov     [ebp+3Eh], ecx
    mov     [ebp+42h], edx
    mov     ecx, dword_512344
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    mov     edi, [eax+edx+15h]
    mov     eax, edi

    loc_43A67F:                             ; CODE XREF: sub_43A420+27Dj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_43A6A3
    test    cl, cl
    jz      short loc_43A69F
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_43A6A3
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_43A67F

    loc_43A69F:                             ; CODE XREF: sub_43A420+269j
    xor     eax, eax
    jmp     short loc_43A6A8
    ; ---------------------------------------------------------------------------

    loc_43A6A3:                             ; CODE XREF: sub_43A420+265j
                                            ; sub_43A420+273j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_43A6A8:                             ; CODE XREF: sub_43A420+281j
    test    eax, eax
    jz      short loc_43A718
    mov     esi, offset aVtol_mobileb_0     ; "VTOL_MobileBuild"
    mov     eax, edi

    loc_43A6B3:                             ; CODE XREF: sub_43A420+2B1j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_43A6D7
    test    cl, cl
    jz      short loc_43A6D3
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_43A6D7
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_43A6B3

    loc_43A6D3:                             ; CODE XREF: sub_43A420+29Dj
    xor     eax, eax
    jmp     short loc_43A6DC
    ; ---------------------------------------------------------------------------

    loc_43A6D7:                             ; CODE XREF: sub_43A420+299j
                                            ; sub_43A420+2A7j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_43A6DC:                             ; CODE XREF: sub_43A420+2B5j
    test    eax, eax
    jz      short loc_43A718
    mov     esi, offset aBuildingbuild      ; "BuildingBuild"
    mov     eax, edi

    loc_43A6E7:                             ; CODE XREF: sub_43A420+2E5j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_43A70B
    test    cl, cl
    jz      short loc_43A707
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_43A70B
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_43A6E7

    loc_43A707:                             ; CODE XREF: sub_43A420+2D1j
    xor     eax, eax
    jmp     short loc_43A710
    ; ---------------------------------------------------------------------------

    loc_43A70B:                             ; CODE XREF: sub_43A420+2CDj
                                            ; sub_43A420+2DBj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_43A710:                             ; CODE XREF: sub_43A420+2E9j
    test    eax, eax
    jnz     loc_43A7C5

    loc_43A718:                             ; CODE XREF: sub_43A420+28Aj
                                            ; sub_43A420+2BEj
    mov     ax, [ebp+36h]
    mov     [esp+174h+var_160], eax
    and     eax, 0FFFFh
    push    eax
    lea     eax, [esp+178h+var_100]
    push    offset aUtypename4d             ; "UTYPENAME%4d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+174h+var_100]
    push    ecx                             ; char *
    mov     ecx, ebx
    call    sub_4B48F0
    test    eax, eax
    jz      short loc_43A75E
    lea     edx, [esp+174h+var_100]
    push    0                               ; int
    push    edx                             ; char *
    mov     ecx, ebx
    call    sub_4B48A0
    push    eax                             ; char *
    call    sub_488B10
    jmp     short loc_43A7BD
    ; ---------------------------------------------------------------------------

    loc_43A75E:                             ; CODE XREF: sub_43A420+326j
    mov     eax, TAdynmemStructPtr
    mov     edx, 1
    xor     ebx, ebx
    mov     edi, [eax+1438Fh]
    mov     [esp+174h+var_164], ebx
    cmp     edi, edx
    jle     short loc_43A7B4
    mov     esi, [eax+1439Bh]

    loc_43A77E:                             ; CODE XREF: sub_43A420+392j
    mov     ecx, edx
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [esi+eax*8]
    test    byte ptr [eax+ecx+241h], 20h
    jnz     short loc_43A7AE
    mov     ax, word ptr [esp+174h+var_164]
    cmp     ax, word ptr [esp+174h+var_160]
    jz      loc_43A910
    inc     [esp+174h+var_164]

    loc_43A7AE:                             ; CODE XREF: sub_43A420+378j
    inc     edx
    inc     ebx
    cmp     edx, edi
    jl      short loc_43A77E

    loc_43A7B4:                             ; CODE XREF: sub_43A420+356j
    xor     eax, eax

    loc_43A7B6:                             ; CODE XREF: sub_43A420+4F2j
    mov     ebx, [esp+174h+arg_4]

    loc_43A7BD:                             ; CODE XREF: sub_43A420+33Cj
    and     eax, 0FFFFh
    mov     [ebp+36h], eax

    loc_43A7C5:                             ; CODE XREF: sub_43A420+2F2j
    mov     ecx, [esp+174h+arg_8]
    push    offset aG                       ; "g"
    push    ecx
    lea     edx, [esp+17Ch+var_120]
    push    offset aSS_2                    ; "%s%s"
    push    edx
    call    _sprintf
    mov     eax, [esp+184h+var_158]
    add     esp, 10h
    cmp     eax, 6                          ; switch 7 cases
    ja      loc_43A8FA                      ; default
    jmp     ds:off_43A918[eax*4]            ; switch jump

    loc_43A7F8:                             ; DATA XREF: .text:0043A918o
    push    36h                             ; case 0x2
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      loc_43A8E6
    lea     ecx, [esp+174h+var_120]
    push    ecx
    push    ebx
    push    ebp
    mov     ecx, eax
    call    sub_44DE80
    mov     [ebp+52h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 164h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43A82A:                             ; CODE XREF: sub_43A420+3D1j
                                            ; DATA XREF: .text:0043A918o
    push    2Ch                             ; case 0x3
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      loc_43A8E6
    lea     edx, [esp+174h+var_120]
    mov     ecx, eax
    push    edx
    push    ebx
    push    ebp
    call    sub_44E7D0
    mov     [ebp+52h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 164h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43A85C:                             ; CODE XREF: sub_43A420+3D1j
                                            ; DATA XREF: .text:0043A918o
    push    14h                             ; case 0x4
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43A8E6
    lea     ecx, [esp+174h+var_120]
    push    ecx
    push    ebx
    push    ebp
    mov     ecx, eax
    call    sub_44D010
    mov     [ebp+52h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 164h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43A88A:                             ; CODE XREF: sub_43A420+3D1j
                                            ; DATA XREF: .text:0043A918o
    push    1Ch                             ; case 0x5
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43A8E6
    lea     edx, [esp+174h+var_120]
    mov     ecx, eax
    push    edx
    push    ebx
    push    ebp
    call    sub_44D470
    mov     [ebp+52h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 164h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43A8B8:                             ; CODE XREF: sub_43A420+3D1j
                                            ; DATA XREF: .text:0043A918o
    push    18h                             ; case 0x6
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43A8E6
    lea     ecx, [esp+174h+var_120]
    push    ecx
    push    ebx
    push    ebp
    mov     ecx, eax
    call    sub_44D930
    mov     [ebp+52h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 164h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43A8E6:                             ; CODE XREF: sub_43A420+3E4j
                                            ; sub_43A420+416j ...
    xor     eax, eax
    mov     [ebp+52h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 164h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43A8FA:                             ; CODE XREF: sub_43A420+3CBj
                                            ; sub_43A420+3D1j
                                            ; DATA XREF: ...
    mov     dword ptr [ebp+52h], 0          ; default

    loc_43A901:                             ; CODE XREF: sub_43A420+54j
                                            ; sub_43A420+63j ...
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 164h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43A910:                             ; CODE XREF: sub_43A420+384j
    mov     eax, ebx
    jmp     loc_43A7B6
    sub_43A420 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_43A918 dd offset loc_43A8FA         ; DATA XREF: sub_43A420+3D1r
    dd offset loc_43A8FA                    ; jump table for switch statement
    dd offset loc_43A7F8
    dd offset loc_43A82A
    dd offset loc_43A85C
    dd offset loc_43A88A
    dd offset loc_43A8B8
    align 10h

    loc_43A940:                             ; DATA XREF: sub_43A420+EBo
    mov     ecx, [esp+4]
    mov     eax, [esp+8]
    push    eax
    mov     edx, [ecx+15h]
    push    edx
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl

    unknown_libname_11:
    mov     eax, ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43A970 proc near                    ; CODE XREF: sub_4876C0+B7p
                                            ; sub_4876C0+F7p

    var_15C= dword ptr -15Ch
    var_158= dword ptr -158h
    var_154= byte ptr -154h
    var_153= byte ptr -153h
    var_152= dword ptr -152h
    var_14E= dword ptr -14Eh
    var_14A= dword ptr -14Ah
    var_146= dword ptr -146h
    var_142= dword ptr -142h
    var_13E= dword ptr -13Eh
    var_13A= dword ptr -13Ah
    var_136= dword ptr -136h
    var_132= dword ptr -132h
    var_12E= dword ptr -12Eh
    var_12A= dword ptr -12Ah
    var_126= dword ptr -126h
    var_120= dword ptr -120h
    var_100= byte ptr -100h
    var_80= byte ptr -80h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 15Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+168h+arg_0]
    push    edi
    mov     edx, [esi+0Eh]
    mov     ax, [edx+0A8h]
    cmp     ax, [ecx+0A8h]
    jnz     loc_43AC45
    mov     ebx, [esp+16Ch+arg_4]
    test    ebx, ebx
    jz      loc_43AC45
    mov     ebp, [esp+16Ch+arg_8]
    test    ebp, ebp
    jz      loc_43AC45
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     ecx, 1Fh
    ja      loc_43AC45
    xor     edi, edi
    cmp     edx, edi
    jnz     short loc_43A9DA
    mov     word ptr [esp+16Ch+var_15C], di
    jmp     short loc_43A9E6
    ; ---------------------------------------------------------------------------

    loc_43A9DA:                             ; CODE XREF: sub_43A970+61j
    mov     dx, [edx+0A8h]
    mov     word ptr [esp+16Ch+var_15C], dx

    loc_43A9E6:                             ; CODE XREF: sub_43A970+68j
    mov     eax, [esi+16h]
    cmp     eax, edi
    jz      short loc_43AA0B
    test    dword ptr [eax+110h], 10000000h
    jz      short loc_43AA0B
    cmp     eax, edi
    jz      short loc_43AA0B
    mov     ax, [eax+0A8h]
    mov     word ptr [esp+16Ch+var_15C+2], ax
    jmp     short loc_43AA10
    ; ---------------------------------------------------------------------------

    loc_43AA0B:                             ; CODE XREF: sub_43A970+7Bj
                                            ; sub_43A970+87j ...
    mov     word ptr [esp+16Ch+var_15C+2], di

    loc_43AA10:                             ; CODE XREF: sub_43A970+99j
    mov     ecx, [esi+52h]
    cmp     ecx, edi
    jz      short loc_43AA22
    mov     edx, [ecx]
    call    dword ptr [edx+8]
    mov     [esp+16Ch+var_158], eax
    jmp     short loc_43AA26
    ; ---------------------------------------------------------------------------

    loc_43AA22:                             ; CODE XREF: sub_43A970+A5j
    mov     [esp+16Ch+var_158], edi

    loc_43AA26:                             ; CODE XREF: sub_43A970+B0j
    mov     cl, [esi+5]
    mov     al, [esi+4]
    mov     edx, [esi+6]
    mov     [esp+16Ch+var_153], cl
    lea     ecx, [esi+22h]
    mov     [esp+16Ch+var_154], al
    mov     eax, [esi+0Ah]
    mov     [esp+16Ch+var_152], edx
    mov     edx, [ecx]
    mov     [esp+16Ch+var_14E], eax
    mov     [esp+16Ch+var_14A], edx
    mov     edx, [esi+2Eh]
    mov     eax, [ecx+4]
    mov     [esp+16Ch+var_13E], edx
    mov     edx, [esi+3Ah]
    mov     [esp+16Ch+var_146], eax
    mov     ecx, [ecx+8]
    mov     eax, [esi+32h]
    mov     [esp+16Ch+var_142], ecx
    mov     ecx, [esi+36h]
    mov     [esp+16Ch+var_136], ecx
    mov     ecx, [esi+42h]
    mov     [esp+16Ch+var_13A], eax
    mov     eax, [esi+3Eh]
    mov     [esp+16Ch+var_132], edx
    mov     edx, [esi+4Eh]
    mov     [esp+16Ch+var_12A], ecx
    push    ebp
    mov     ecx, ebx
    mov     [esp+170h+var_12E], eax
    mov     [esp+170h+var_126], edx
    call    sub_4B4BA0
    push    edi
    mov     ecx, ebx
    call    sub_4B4C10
    lea     eax, [esp+16Ch+var_15C]
    push    3Ah
    push    eax
    mov     ecx, ebx
    call    sub_4B4CF0
    push    offset a_name                   ; "_name"
    push    ebp
    lea     ecx, [esp+174h+var_80]
    push    offset aSS_2                    ; "%s%s"
    push    ecx
    call    _sprintf
    mov     edx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    add     esp, 10h
    lea     eax, [eax+eax*4]
    lea     ecx, [edx+eax*4]
    mov     edx, [eax+ecx+15h]
    lea     eax, [esp+16Ch+var_80]
    push    edx                             ; int
    push    eax                             ; char *
    mov     ecx, ebx
    call    sub_4B4750
    mov     ecx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    mov     edi, offset aMobilebuild_0      ; "MobileBuild"
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    mov     ebp, [eax+edx+15h]
    mov     eax, ebp

    loc_43AB04:                             ; CODE XREF: sub_43A970+1B2j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [edi]
    jnz     short loc_43AB28
    test    cl, cl
    jz      short loc_43AB24
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [edi+1]
    jnz     short loc_43AB28
    add     eax, 2
    add     edi, 2
    test    cl, cl
    jnz     short loc_43AB04

    loc_43AB24:                             ; CODE XREF: sub_43A970+19Ej
    xor     eax, eax
    jmp     short loc_43AB2D
    ; ---------------------------------------------------------------------------

    loc_43AB28:                             ; CODE XREF: sub_43A970+19Aj
                                            ; sub_43A970+1A8j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_43AB2D:                             ; CODE XREF: sub_43A970+1B6j
    test    eax, eax
    jz      short loc_43AB99
    mov     edi, offset aVtol_mobileb_0     ; "VTOL_MobileBuild"
    mov     eax, ebp

    loc_43AB38:                             ; CODE XREF: sub_43A970+1E6j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [edi]
    jnz     short loc_43AB5C
    test    cl, cl
    jz      short loc_43AB58
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [edi+1]
    jnz     short loc_43AB5C
    add     eax, 2
    add     edi, 2
    test    cl, cl
    jnz     short loc_43AB38

    loc_43AB58:                             ; CODE XREF: sub_43A970+1D2j
    xor     eax, eax
    jmp     short loc_43AB61
    ; ---------------------------------------------------------------------------

    loc_43AB5C:                             ; CODE XREF: sub_43A970+1CEj
                                            ; sub_43A970+1DCj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_43AB61:                             ; CODE XREF: sub_43A970+1EAj
    test    eax, eax
    jz      short loc_43AB99
    mov     edi, offset aBuildingbuild      ; "BuildingBuild"
    mov     eax, ebp

    loc_43AB6C:                             ; CODE XREF: sub_43A970+21Aj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [edi]
    jnz     short loc_43AB90
    test    cl, cl
    jz      short loc_43AB8C
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [edi+1]
    jnz     short loc_43AB90
    add     eax, 2
    add     edi, 2
    test    cl, cl
    jnz     short loc_43AB6C

    loc_43AB8C:                             ; CODE XREF: sub_43A970+206j
    xor     eax, eax
    jmp     short loc_43AB95
    ; ---------------------------------------------------------------------------

    loc_43AB90:                             ; CODE XREF: sub_43A970+202j
                                            ; sub_43A970+210j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_43AB95:                             ; CODE XREF: sub_43A970+21Ej
    test    eax, eax
    jnz     short loc_43ABFD

    loc_43AB99:                             ; CODE XREF: sub_43A970+1BFj
                                            ; sub_43A970+1F3j
    mov     bp, [esi+36h]
    lea     eax, [esp+16Ch+var_100]
    mov     edi, ebp
    and     edi, 0FFFFh
    push    edi
    push    offset aUtypename4d             ; "UTYPENAME%4d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+16Ch+var_100]
    push    ecx                             ; char *
    mov     ecx, ebx
    call    sub_4B48F0
    test    eax, eax
    jnz     short loc_43ABFD
    cmp     bp, 1
    jb      short loc_43ABFD
    mov     ecx, TAdynmemStructPtr
    cmp     edi, [ecx+1438Fh]
    jge     short loc_43ABFD
    mov     eax, edi
    shl     eax, 6
    add     eax, edi
    lea     edx, [eax+eax*8]
    mov     eax, [ecx+1439Bh]
    lea     ecx, [eax+edx+20h]
    lea     edx, [esp+16Ch+var_100]
    push    ecx                             ; int
    push    edx                             ; char *
    mov     ecx, ebx
    call    sub_4B4750

    loc_43ABFD:                             ; CODE XREF: sub_43A970+227j
                                            ; sub_43A970+256j ...
    mov     eax, [esp+16Ch+var_158]
    test    eax, eax
    jz      short loc_43AC33
    mov     eax, [esp+16Ch+arg_8]
    push    offset aG                       ; "g"
    push    eax
    lea     ecx, [esp+174h+var_120]
    push    offset aSS_2                    ; "%s%s"
    push    ecx
    call    _sprintf
    mov     ecx, [esi+52h]
    add     esp, 10h
    lea     eax, [esp+16Ch+var_120]
    mov     edx, [ecx]
    push    eax
    push    ebx
    push    esi
    call    dword ptr [edx+4]

    loc_43AC33:                             ; CODE XREF: sub_43A970+293j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 15Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43AC45:                             ; CODE XREF: sub_43A970+24j
                                            ; sub_43A970+33j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 15Ch
    retn    0Ch
    sub_43A970 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43AC60 proc near                    ; CODE XREF: sub_43B7C0+25Ep
                                            ; sub_43B7C0+270p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    esi
    mov     esi, [esp+arg_4]
    push    edi
    mov     edi, [esp+4+arg_0]
    test    dword ptr [esi+42h], 40000h
    lea     ecx, [edi+60h]
    jnz     short loc_43AC79
    lea     ecx, [edi+5Ch]

    loc_43AC79:                             ; CODE XREF: sub_43AC60+14j
    mov     eax, [ecx]
    mov     edx, [esp+4+arg_8]
    cmp     eax, edx
    jz      short loc_43AC8D

    loc_43AC83:                             ; CODE XREF: sub_43AC60+2Bj
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    cmp     eax, edx
    jnz     short loc_43AC83

    loc_43AC8D:                             ; CODE XREF: sub_43AC60+21j
    mov     [ecx], esi
    mov     [esi+0Eh], edi
    test    edx, edx
    mov     [esi+4Ah], edx
    jz      short loc_43ACA9
    mov     eax, [edx+42h]
    mov     ecx, [esi+42h]
    and     eax, 4000h
    or      ecx, eax
    mov     [esi+42h], ecx

    loc_43ACA9:                             ; CODE XREF: sub_43AC60+37j
    pop     edi
    pop     esi
    retn    0Ch
    sub_43AC60 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43ACB0 proc near                    ; CODE XREF: sub_401C20+79p
                                            ; sub_401C20+8Cp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_4]
    push    edi
    mov     edi, [esp+4+arg_0]
    mov     eax, [esi+42h]
    and     eax, 40000h
    jz      short loc_43ACC9
    mov     edx, [edi+60h]
    jmp     short loc_43ACCC
    ; ---------------------------------------------------------------------------

    loc_43ACC9:                             ; CODE XREF: sub_43ACB0+12j
    mov     edx, [edi+5Ch]

    loc_43ACCC:                             ; CODE XREF: sub_43ACB0+17j
    test    eax, eax
    lea     ecx, [edi+60h]
    jnz     short loc_43ACD6
    lea     ecx, [edi+5Ch]

    loc_43ACD6:                             ; CODE XREF: sub_43ACB0+21j
    mov     eax, [ecx]
    cmp     eax, edx
    jz      short loc_43ACE6

    loc_43ACDC:                             ; CODE XREF: sub_43ACB0+34j
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    cmp     eax, edx
    jnz     short loc_43ACDC

    loc_43ACE6:                             ; CODE XREF: sub_43ACB0+2Aj
    mov     [ecx], esi
    mov     [esi+0Eh], edi
    test    edx, edx
    mov     [esi+4Ah], edx
    jz      short loc_43AD02
    mov     eax, [edx+42h]
    mov     ecx, [esi+42h]
    and     eax, 4000h
    or      ecx, eax
    mov     [esi+42h], ecx

    loc_43AD02:                             ; CODE XREF: sub_43ACB0+40j
    pop     edi
    pop     esi
    retn    8
    sub_43ACB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43AD10 proc near                    ; CODE XREF: .text:00410384p
                                            ; .text:00411FBEp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    test    dword ptr [edx+42h], 40000h
    lea     ecx, [esi+60h]
    jnz     short loc_43AD28
    lea     ecx, [esi+5Ch]

    loc_43AD28:                             ; CODE XREF: sub_43AD10+13j
    mov     eax, [ecx]
    test    eax, eax
    jz      short loc_43AD38

    loc_43AD2E:                             ; CODE XREF: sub_43AD10+26j
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_43AD2E

    loc_43AD38:                             ; CODE XREF: sub_43AD10+1Cj
    mov     [ecx], edx
    mov     [edx+0Eh], esi
    mov     dword ptr [edx+4Ah], 0
    pop     esi
    retn    8
    sub_43AD10 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+8]
    push    esi
    mov     esi, [esp+8]
    push    edi
    mov     eax, [edx+42h]
    mov     edi, 1000h
    lea     ecx, [esi+5Ch]
    or      eax, edi
    mov     [edx+0Eh], esi
    mov     [edx+42h], eax
    mov     eax, [ecx]
    test    eax, eax
    jz      short loc_43ADA6

    loc_43AD73:                             ; CODE XREF: .text:0043AD80j
    test    [eax+42h], edi
    jnz     short loc_43AD8C
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_43AD73
    mov     [edx+4Ah], eax
    mov     [ecx], edx
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_43AD8C:                             ; CODE XREF: .text:0043AD76j
    mov     ecx, [eax+42h]
    and     ch, 0EFh
    mov     [eax+42h], ecx
    mov     [edx+0Eh], esi
    mov     ecx, [eax+4Ah]
    mov     [edx+4Ah], ecx
    mov     [eax+4Ah], edx
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_43ADA6:                             ; CODE XREF: .text:0043AD71j
    mov     dword ptr [edx+4Ah], 0
    pop     edi
    mov     [ecx], edx
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43ADC0 proc near                    ; CODE XREF: .text:004029A5p
                                            ; .text:00402E5Ep ...

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h
    arg_8= dword ptr  1Ch
    arg_C= dword ptr  20h
    arg_10= dword ptr  24h
    arg_14= dword ptr  28h
    arg_18= dword ptr  2Ch

    push    ebx
    push    ebp
    push    esi
    push    edi
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43ADFA
    mov     ecx, [esp+arg_18]
    mov     edx, [esp+arg_14]
    push    0
    push    ecx
    mov     ecx, [esp+8+arg_10]
    push    edx
    mov     edx, [esp+0Ch+arg_C]
    push    ecx
    mov     ecx, [esp+10h+arg_0]
    push    edx
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    mov     [esp+arg_18], eax
    jmp     short loc_43AE02
    ; ---------------------------------------------------------------------------

    loc_43ADFA:                             ; CODE XREF: sub_43ADC0+10j
    mov     [esp+arg_18], 0

    loc_43AE02:                             ; CODE XREF: sub_43ADC0+38j
    mov     eax, [esp+arg_4]
    test    eax, eax
    jnz     short loc_43AE5B
    mov     edx, [esp+arg_18]
    test    byte ptr [edx+42h], 40h
    jnz     short loc_43AE5B
    mov     eax, [esp+arg_8]
    mov     esi, [eax+5Ch]
    mov     ebp, [eax+5Ch]
    lea     edi, [eax+5Ch]
    test    esi, esi
    jz      short loc_43AE5B
    mov     bl, 4

    loc_43AE27:                             ; CODE XREF: sub_43ADC0+99j
    test    [esi+42h], bl
    jz      short loc_43AE31
    lea     edi, [esi+4Ah]
    jmp     short loc_43AE55
    ; ---------------------------------------------------------------------------

    loc_43AE31:                             ; CODE XREF: sub_43ADC0+6Aj
    mov     ecx, [esi+4Ah]
    cmp     esi, ebp
    mov     [edi], ecx
    jz      short loc_43AE41
    or      dword ptr [esi+42h], 10000h

    loc_43AE41:                             ; CODE XREF: sub_43ADC0+78j
    test    esi, esi
    jz      short loc_43AE55
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_43AE55:                             ; CODE XREF: sub_43ADC0+6Fj
                                            ; sub_43ADC0+83j
    mov     esi, [edi]
    test    esi, esi
    jnz     short loc_43AE27

    loc_43AE5B:                             ; CODE XREF: sub_43ADC0+48j
                                            ; sub_43ADC0+52j ...
    mov     ecx, [esp+arg_18]
    mov     edx, [esp+arg_8]
    mov     ebx, 40000h
    mov     ebp, 4000h
    test    [ecx+42h], ebx
    jnz     short loc_43AED4
    mov     esi, [edx+5Ch]
    lea     edi, [edx+5Ch]
    test    esi, esi
    jz      short loc_43AED0

    loc_43AE7C:                             ; CODE XREF: sub_43ADC0+10Ej
    mov     eax, [esi+42h]
    test    ebp, eax
    jz      short loc_43AED0
    test    ebx, eax
    lea     ecx, [edx+60h]
    jnz     short loc_43AE8C
    mov     ecx, edi

    loc_43AE8C:                             ; CODE XREF: sub_43ADC0+C8j
    mov     eax, [ecx]
    test    eax, eax
    jz      short loc_43AEC6

    loc_43AE92:                             ; CODE XREF: sub_43ADC0+DEj
    cmp     eax, esi
    jz      short loc_43AEA2
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_43AE92
    jmp     short loc_43AEC6
    ; ---------------------------------------------------------------------------

    loc_43AEA2:                             ; CODE XREF: sub_43ADC0+D4j
    mov     edx, [esi+4Ah]
    cmp     esi, esi
    mov     [ecx], edx
    jz      short loc_43AEB2
    or      dword ptr [esi+42h], 10000h

    loc_43AEB2:                             ; CODE XREF: sub_43ADC0+E9j
    test    esi, esi
    jz      short loc_43AEC6
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_43AEC6:                             ; CODE XREF: sub_43ADC0+D0j
                                            ; sub_43ADC0+E0j ...
    mov     esi, [edi]
    mov     edx, [esp+arg_8]
    test    esi, esi
    jnz     short loc_43AE7C

    loc_43AED0:                             ; CODE XREF: sub_43ADC0+BAj
                                            ; sub_43ADC0+C1j
    mov     ecx, [esp+arg_18]

    loc_43AED4:                             ; CODE XREF: sub_43ADC0+B0j
    mov     edi, [ecx+42h]
    mov     esi, [esp+arg_4]
    or      edi, 1
    test    esi, esi
    mov     [ecx+42h], edi
    mov     eax, edi
    jnz     short loc_43AEED
    or      ah, 20h
    mov     [ecx+42h], eax

    loc_43AEED:                             ; CODE XREF: sub_43ADC0+125j
    mov     eax, [ecx+42h]
    test    eax, 40020h
    jz      short loc_43AF4F
    and     eax, ebx
    jz      short loc_43AF00
    mov     edx, [edx+60h]
    jmp     short loc_43AF03
    ; ---------------------------------------------------------------------------

    loc_43AF00:                             ; CODE XREF: sub_43ADC0+139j
    mov     edx, [edx+5Ch]

    loc_43AF03:                             ; CODE XREF: sub_43ADC0+13Ej
    test    eax, eax
    jz      short loc_43AF10
    mov     eax, [esp+arg_8]
    lea     ecx, [eax+60h]
    jmp     short loc_43AF17
    ; ---------------------------------------------------------------------------

    loc_43AF10:                             ; CODE XREF: sub_43ADC0+145j
    mov     ecx, [esp+arg_8]
    add     ecx, 5Ch

    loc_43AF17:                             ; CODE XREF: sub_43ADC0+14Ej
    mov     eax, [ecx]
    cmp     eax, edx
    jz      short loc_43AF27

    loc_43AF1D:                             ; CODE XREF: sub_43ADC0+165j
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    cmp     eax, edx
    jnz     short loc_43AF1D

    loc_43AF27:                             ; CODE XREF: sub_43ADC0+15Bj
    mov     eax, [esp+arg_18]
    mov     [ecx], eax
    mov     ecx, [esp+arg_8]
    test    edx, edx
    mov     [eax+0Eh], ecx
    mov     [eax+4Ah], edx
    jz      short loc_43AFAD
    mov     edx, [edx+42h]
    mov     ecx, [eax+42h]
    and     edx, ebp
    or      ecx, edx
    mov     [eax+42h], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_43AF4F:                             ; CODE XREF: sub_43ADC0+135j
    mov     esi, [esp+arg_18]
    lea     ecx, [edx+5Ch]
    mov     [esi+0Eh], edx
    mov     edx, 1000h
    or      eax, edx
    mov     [esi+42h], eax
    mov     eax, [ecx]
    test    eax, eax
    jz      short loc_43AFA4

    loc_43AF69:                             ; CODE XREF: sub_43ADC0+1B6j
    test    [eax+42h], edx
    jnz     short loc_43AF84
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_43AF69
    mov     [esi+4Ah], eax
    mov     [ecx], esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_43AF84:                             ; CODE XREF: sub_43ADC0+1ACj
    mov     ecx, [eax+42h]
    and     ch, 0EFh
    mov     [eax+42h], ecx
    mov     ecx, [esp+arg_8]
    mov     [esi+0Eh], ecx
    mov     edx, [eax+4Ah]
    mov     [esi+4Ah], edx
    mov     [eax+4Ah], esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_43AFA4:                             ; CODE XREF: sub_43ADC0+1A7j
    mov     dword ptr [esi+4Ah], 0
    mov     [ecx], esi

    loc_43AFAD:                             ; CODE XREF: sub_43ADC0+179j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    sub_43ADC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43AFC0 proc near                    ; CODE XREF: sub_419670+139p
                                            ; sub_48CF30+2C4p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    mov     eax, [esp+arg_4]
    mov     edx, [esp+arg_C]
    push    ebx
    mov     ebx, [esp+4+arg_0]
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+10h+arg_8]
    test    eax, eax
    mov     eax, [esp+10h+arg_10]
    jz      loc_43B08A
    mov     esi, [edi+5Ch]
    lea     ecx, [edi+5Ch]
    test    esi, esi
    mov     [esp+10h+arg_10], esi
    jz      loc_43B08A

    loc_43AFF2:                             ; CODE XREF: sub_43AFC0+72j
    cmp     bl, [esi+4]
    jnz     short loc_43B02B
    test    edx, edx
    jz      short loc_43B000
    cmp     edx, [esi+16h]
    jnz     short loc_43B02B

    loc_43B000:                             ; CODE XREF: sub_43AFC0+39j
    test    eax, eax
    jz      short loc_43B034
    mov     ebp, [eax]
    sub     ebp, [esi+22h]
    add     ebp, 100000h
    cmp     ebp, 200000h
    ja      short loc_43B02B
    mov     ebp, [eax+8]
    sub     ebp, [esi+2Ah]
    add     ebp, 100000h
    cmp     ebp, 200000h
    jbe     short loc_43B034

    loc_43B02B:                             ; CODE XREF: sub_43AFC0+35j
                                            ; sub_43AFC0+3Ej ...
    mov     esi, [esi+4Ah]
    test    esi, esi
    jz      short loc_43B08A
    jmp     short loc_43AFF2
    ; ---------------------------------------------------------------------------

    loc_43B034:                             ; CODE XREF: sub_43AFC0+42j
                                            ; sub_43AFC0+69j
    test    dword ptr [esi+42h], 40000h
    jz      short loc_43B040
    lea     ecx, [edi+60h]

    loc_43B040:                             ; CODE XREF: sub_43AFC0+7Bj
    mov     eax, [ecx]
    test    eax, eax
    jz      short loc_43B0A2

    loc_43B046:                             ; CODE XREF: sub_43AFC0+92j
    cmp     eax, esi
    jz      short loc_43B05B
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_43B046
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_43B05B:                             ; CODE XREF: sub_43AFC0+88j
    mov     eax, [esi+4Ah]
    mov     [ecx], eax
    mov     eax, [esp+10h+arg_10]
    cmp     esi, eax
    jz      short loc_43B06F
    or      dword ptr [esi+42h], 10000h

    loc_43B06F:                             ; CODE XREF: sub_43AFC0+A6j
    test    esi, esi
    jz      short loc_43B0A2
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_43B08A:                             ; CODE XREF: sub_43AFC0+1Aj
                                            ; sub_43AFC0+2Cj ...
    mov     ecx, [esp+10h+arg_18]
    push    ecx
    mov     ecx, [esp+14h+arg_14]
    push    ecx
    push    eax
    push    edx
    mov     edx, [esp+20h+arg_4]
    push    edi
    push    edx
    push    ebx
    call    sub_43ADC0

    loc_43B0A2:                             ; CODE XREF: sub_43AFC0+84j
                                            ; sub_43AFC0+B1j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    sub_43AFC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43B0B0 proc near                    ; CODE XREF: sub_419B00+8Cp
                                            ; sub_419B00+A8p

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h
    arg_C= dword ptr  18h

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_C]
    push    esi
    test    ebp, ebp
    push    edi
    jle     short loc_43B12C
    mov     edx, [esp+8+arg_0]
    mov     ecx, dword_512344
    mov     eax, edx
    and     eax, 0FFh
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*4]
    test    dword ptr [eax+ecx+11h], 40000h
    mov     esi, [esp+8+arg_4]
    jz      short loc_43B0E6
    mov     eax, [esi+60h]
    jmp     short loc_43B0E9
    ; ---------------------------------------------------------------------------

    loc_43B0E6:                             ; CODE XREF: sub_43B0B0+2Fj
    mov     eax, [esi+5Ch]

    loc_43B0E9:                             ; CODE XREF: sub_43B0B0+34j
    test    eax, eax
    jz      short loc_43B0FC

    loc_43B0ED:                             ; CODE XREF: sub_43B0B0+48j
    mov     ecx, [eax+4Ah]
    test    ecx, ecx
    jz      short loc_43B0FA
    mov     eax, ecx
    test    eax, eax
    jnz     short loc_43B0ED

    loc_43B0FA:                             ; CODE XREF: sub_43B0B0+42j
    test    eax, eax

    loc_43B0FC:                             ; CODE XREF: sub_43B0B0+3Bj
    mov     ecx, [esp+8+arg_8]
    jz      short loc_43B116
    cmp     [eax+4], dl
    jnz     short loc_43B116
    cmp     [eax+36h], ecx
    jnz     short loc_43B116
    add     [eax+3Ah], ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43B116:                             ; CODE XREF: sub_43B0B0+50j
                                            ; sub_43B0B0+55j ...
    push    ebp
    push    ecx
    push    0
    push    0
    push    esi
    push    1
    push    edx
    call    sub_43ADC0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43B12C:                             ; CODE XREF: sub_43B0B0+Aj
    mov     eax, [esp+8+arg_0]
    mov     edi, [esp+8+arg_4]
    and     eax, 0FFh
    mov     ebx, 40000h
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax*4+11h]
    mov     [esp+8+arg_C], edx

    loc_43B149:                             ; CODE XREF: sub_43B0B0+F5j
                                            ; sub_43B0B0+105j ...
    mov     eax, dword_512344
    mov     ecx, [esp+8+arg_C]
    xor     esi, esi
    test    [eax+ecx], ebx
    jz      short loc_43B15E
    mov     eax, [edi+60h]
    jmp     short loc_43B161
    ; ---------------------------------------------------------------------------

    loc_43B15E:                             ; CODE XREF: sub_43B0B0+A7j
    mov     eax, [edi+5Ch]

    loc_43B161:                             ; CODE XREF: sub_43B0B0+ACj
    test    eax, eax
    jz      short loc_43B180
    mov     cl, byte ptr [esp+8+arg_0]

    loc_43B169:                             ; CODE XREF: sub_43B0B0+CEj
    cmp     [eax+4], cl
    jnz     short loc_43B179
    mov     edx, [esp+8+arg_8]
    cmp     [eax+36h], edx
    jnz     short loc_43B179
    mov     esi, eax

    loc_43B179:                             ; CODE XREF: sub_43B0B0+BCj
                                            ; sub_43B0B0+C5j
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_43B169

    loc_43B180:                             ; CODE XREF: sub_43B0B0+B3j
    test    esi, esi
    jz      short loc_43B1DF
    mov     eax, [esi+3Ah]
    mov     ecx, ebp
    neg     ecx
    cmp     eax, ecx
    jg      short loc_43B1DC
    mov     edx, [edi+5Ch]
    add     ebp, eax
    mov     eax, [esi+42h]
    lea     ecx, [edi+5Ch]
    test    ebx, eax
    jz      short loc_43B1A1
    lea     ecx, [edi+60h]

    loc_43B1A1:                             ; CODE XREF: sub_43B0B0+ECj
    mov     eax, [ecx]
    test    eax, eax
    jz      short loc_43B149

    loc_43B1A7:                             ; CODE XREF: sub_43B0B0+103j
    cmp     eax, esi
    jz      short loc_43B1B7
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    test    eax, eax
    jnz     short loc_43B1A7
    jmp     short loc_43B149
    ; ---------------------------------------------------------------------------

    loc_43B1B7:                             ; CODE XREF: sub_43B0B0+F9j
    mov     eax, [esi+4Ah]
    cmp     esi, edx
    mov     [ecx], eax
    jz      short loc_43B1C7
    or      dword ptr [esi+42h], 10000h

    loc_43B1C7:                             ; CODE XREF: sub_43B0B0+10Ej
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4
    jmp     loc_43B149
    ; ---------------------------------------------------------------------------

    loc_43B1DC:                             ; CODE XREF: sub_43B0B0+DDj
    add     [esi+3Ah], ebp

    loc_43B1DF:                             ; CODE XREF: sub_43B0B0+D2j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_43B0B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43B1F0 proc near                    ; CODE XREF: .text:004033EBp
                                            ; sub_405FE0+2Fp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    cmp     esi, ebx
    push    edi
    jnz     short loc_43B207
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43B207:                             ; CODE XREF: sub_43B1F0+Dj
    mov     eax, [esi+110h]
    mov     edi, [esp+8+arg_8]
    test    eax, 0C0000h
    jnz     short loc_43B224
    test    edi, edi
    jnz     short loc_43B224
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43B224:                             ; CODE XREF: sub_43B1F0+26j
                                            ; sub_43B1F0+2Aj
    test    eax, 300000h
    jnz     short loc_43B237
    test    edi, edi
    jnz     short loc_43B237
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43B237:                             ; CODE XREF: sub_43B1F0+39j
                                            ; sub_43B1F0+3Dj
    push    0
    push    ebx
    push    esi
    lea     eax, [esp+14h+arg_0]
    push    3
    push    eax
    call    sub_43F0E0
    mov     al, byte ptr [esp+8+arg_0]
    test    al, al
    jnz     short loc_43B257
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43B257:                             ; CODE XREF: sub_43B1F0+5Dj
    mov     ecx, [esi+110h]
    and     ecx, 0C0000h
    cmp     ecx, 40000h
    jnz     loc_43B37B
    test    edi, edi
    jnz     loc_43B37B
    lea     edi, [esi+6Ah]
    lea     edx, [esp+8+arg_4]
    push    edi
    push    0
    push    esi
    push    2
    push    edx
    call    sub_43F0E0
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43B2AF
    mov     ecx, [esp+8+arg_4]
    push    0
    push    0
    push    0
    push    edi
    push    0
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43B2B1
    ; ---------------------------------------------------------------------------

    loc_43B2AF:                             ; CODE XREF: sub_43B1F0+A6j
    xor     eax, eax

    loc_43B2B1:                             ; CODE XREF: sub_43B1F0+BDj
    mov     ecx, [eax+42h]
    and     ecx, 40000h
    jz      short loc_43B2C1
    mov     edi, [esi+60h]
    jmp     short loc_43B2C4
    ; ---------------------------------------------------------------------------

    loc_43B2C1:                             ; CODE XREF: sub_43B1F0+CAj
    mov     edi, [esi+5Ch]

    loc_43B2C4:                             ; CODE XREF: sub_43B1F0+CFj
    test    ecx, ecx
    lea     edx, [esi+60h]
    jnz     short loc_43B2CE
    lea     edx, [esi+5Ch]

    loc_43B2CE:                             ; CODE XREF: sub_43B1F0+D9j
    mov     ecx, [edx]
    cmp     ecx, edi
    jz      short loc_43B2DE

    loc_43B2D4:                             ; CODE XREF: sub_43B1F0+ECj
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, edi
    jnz     short loc_43B2D4

    loc_43B2DE:                             ; CODE XREF: sub_43B1F0+E2j
    mov     [edx], eax
    mov     [eax+0Eh], esi
    test    edi, edi
    mov     [eax+4Ah], edi
    jz      short loc_43B2FB
    mov     edx, [edi+42h]
    mov     ecx, [eax+42h]
    and     edx, 4000h
    or      ecx, edx
    mov     [eax+42h], ecx

    loc_43B2FB:                             ; CODE XREF: sub_43B1F0+F8j
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43B32E
    mov     ecx, [esi+92h]
    xor     edx, edx
    mov     dx, [ecx+214h]
    mov     ecx, [esp+8+arg_0]
    push    edx
    push    0
    push    0
    push    0
    push    ebx
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43B330
    ; ---------------------------------------------------------------------------

    loc_43B32E:                             ; CODE XREF: sub_43B1F0+117j
    xor     eax, eax

    loc_43B330:                             ; CODE XREF: sub_43B1F0+13Cj
    mov     dx, [esi+6Ch]
    mov     [eax+2Eh], dx
    mov     cx, [esi+74h]
    mov     [eax+30h], cx
    mov     ecx, [eax+42h]
    and     ecx, 40000h
    jz      short loc_43B350
    mov     edi, [esi+60h]
    jmp     short loc_43B353
    ; ---------------------------------------------------------------------------

    loc_43B350:                             ; CODE XREF: sub_43B1F0+159j
    mov     edi, [esi+5Ch]

    loc_43B353:                             ; CODE XREF: sub_43B1F0+15Ej
    test    ecx, ecx
    lea     edx, [esi+60h]
    jnz     short loc_43B35D
    lea     edx, [esi+5Ch]

    loc_43B35D:                             ; CODE XREF: sub_43B1F0+168j
    mov     ecx, [edx]
    cmp     ecx, edi
    jz      short loc_43B36D

    loc_43B363:                             ; CODE XREF: sub_43B1F0+17Bj
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, edi
    jnz     short loc_43B363

    loc_43B36D:                             ; CODE XREF: sub_43B1F0+171j
    mov     [edx], eax
    mov     [eax+0Eh], esi
    test    edi, edi
    mov     [eax+4Ah], edi
    jz      short loc_43B3EC
    jmp     short loc_43B3DB
    ; ---------------------------------------------------------------------------

    loc_43B37B:                             ; CODE XREF: sub_43B1F0+79j
                                            ; sub_43B1F0+81j
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43B3A0
    mov     ecx, [esp+8+arg_0]
    push    0
    push    0
    push    0
    push    0
    push    ebx
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43B3A2
    ; ---------------------------------------------------------------------------

    loc_43B3A0:                             ; CODE XREF: sub_43B1F0+197j
    xor     eax, eax

    loc_43B3A2:                             ; CODE XREF: sub_43B1F0+1AEj
    mov     ecx, [eax+42h]
    and     ecx, 40000h
    jz      short loc_43B3B2
    mov     edi, [esi+60h]
    jmp     short loc_43B3B5
    ; ---------------------------------------------------------------------------

    loc_43B3B2:                             ; CODE XREF: sub_43B1F0+1BBj
    mov     edi, [esi+5Ch]

    loc_43B3B5:                             ; CODE XREF: sub_43B1F0+1C0j
    test    ecx, ecx
    lea     edx, [esi+60h]
    jnz     short loc_43B3BF
    lea     edx, [esi+5Ch]

    loc_43B3BF:                             ; CODE XREF: sub_43B1F0+1CAj
    mov     ecx, [edx]
    cmp     ecx, edi
    jz      short loc_43B3CF

    loc_43B3C5:                             ; CODE XREF: sub_43B1F0+1DDj
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, edi
    jnz     short loc_43B3C5

    loc_43B3CF:                             ; CODE XREF: sub_43B1F0+1D3j
    mov     [edx], eax
    mov     [eax+0Eh], esi
    test    edi, edi
    mov     [eax+4Ah], edi
    jz      short loc_43B3EC

    loc_43B3DB:                             ; CODE XREF: sub_43B1F0+189j
    mov     edx, [edi+42h]
    mov     ecx, [eax+42h]
    and     edx, 4000h
    or      ecx, edx
    mov     [eax+42h], ecx

    loc_43B3EC:                             ; CODE XREF: sub_43B1F0+187j
                                            ; sub_43B1F0+1E9j
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    retn    0Ch
    sub_43B1F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43B400 proc near                    ; CODE XREF: .text:00405ACAp
                                            ; .text:0041554Ep

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    push    edi
    push    0
    push    ebx
    push    esi
    lea     eax, [esp+14h+arg_4]
    push    8
    push    eax
    call    sub_43F0E0
    mov     al, byte ptr [esp+8+arg_4]
    test    al, al
    jz      loc_43B6F8
    mov     eax, [esi+110h]
    mov     ecx, [esp+8+arg_8]
    and     eax, 0C0000h
    jnz     loc_43B563
    test    ecx, ecx
    jnz     loc_43B563
    lea     edi, [esi+6Ah]
    push    edi
    push    ecx
    push    esi
    lea     ecx, [esp+14h+arg_0]
    push    2
    push    ecx
    call    sub_43F0E0
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43B47B
    mov     edx, [esp+8+arg_0]
    push    0
    push    0
    push    0
    push    edi
    push    0
    push    edx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43B47D
    ; ---------------------------------------------------------------------------

    loc_43B47B:                             ; CODE XREF: sub_43B400+62j
    xor     eax, eax

    loc_43B47D:                             ; CODE XREF: sub_43B400+79j
    mov     ecx, [eax+42h]
    and     ecx, 40000h
    jz      short loc_43B48D
    mov     edi, [esi+60h]
    jmp     short loc_43B490
    ; ---------------------------------------------------------------------------

    loc_43B48D:                             ; CODE XREF: sub_43B400+86j
    mov     edi, [esi+5Ch]

    loc_43B490:                             ; CODE XREF: sub_43B400+8Bj
    test    ecx, ecx
    lea     edx, [esi+60h]
    jnz     short loc_43B49A
    lea     edx, [esi+5Ch]

    loc_43B49A:                             ; CODE XREF: sub_43B400+95j
    mov     ecx, [edx]
    cmp     ecx, edi
    jz      short loc_43B4AA

    loc_43B4A0:                             ; CODE XREF: sub_43B400+A8j
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, edi
    jnz     short loc_43B4A0

    loc_43B4AA:                             ; CODE XREF: sub_43B400+9Ej
    mov     [edx], eax
    mov     [eax+0Eh], esi
    test    edi, edi
    mov     [eax+4Ah], edi
    jz      short loc_43B4C7
    mov     ecx, [edi+42h]
    mov     edx, [eax+42h]
    and     ecx, 4000h
    or      edx, ecx
    mov     [eax+42h], edx

    loc_43B4C7:                             ; CODE XREF: sub_43B400+B4j
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43B4F8
    mov     edx, [esi+92h]
    movsx   ecx, word ptr [edx+202h]
    mov     edx, [esp+8+arg_4]
    push    ecx
    push    0
    push    0
    push    0
    push    ebx
    push    edx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43B4FA
    ; ---------------------------------------------------------------------------

    loc_43B4F8:                             ; CODE XREF: sub_43B400+D3j
    xor     eax, eax

    loc_43B4FA:                             ; CODE XREF: sub_43B400+F6j
    mov     cx, [esi+6Ch]
    mov     [eax+2Eh], cx
    mov     ecx, [eax+42h]
    mov     dx, [esi+74h]
    and     ecx, 40000h
    mov     [eax+30h], dx
    jz      short loc_43B51A
    mov     edi, [esi+60h]
    jmp     short loc_43B51D
    ; ---------------------------------------------------------------------------

    loc_43B51A:                             ; CODE XREF: sub_43B400+113j
    mov     edi, [esi+5Ch]

    loc_43B51D:                             ; CODE XREF: sub_43B400+118j
    test    ecx, ecx
    lea     edx, [esi+60h]
    jnz     short loc_43B527
    lea     edx, [esi+5Ch]

    loc_43B527:                             ; CODE XREF: sub_43B400+122j
    mov     ecx, [edx]
    cmp     ecx, edi
    jz      short loc_43B537

    loc_43B52D:                             ; CODE XREF: sub_43B400+135j
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, edi
    jnz     short loc_43B52D

    loc_43B537:                             ; CODE XREF: sub_43B400+12Bj
    mov     [edx], eax
    mov     [eax+0Eh], esi
    test    edi, edi
    mov     [eax+4Ah], edi
    jz      loc_43B6ED
    mov     ecx, [edi+42h]
    mov     edx, [eax+42h]
    and     ecx, 4000h
    or      edx, ecx
    mov     [eax+42h], edx
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43B563:                             ; CODE XREF: sub_43B400+36j
                                            ; sub_43B400+3Ej
    cmp     eax, 40000h
    jnz     loc_43B66D
    test    ecx, ecx
    jnz     loc_43B66D
    lea     edi, [esi+6Ah]
    lea     edx, [esp+8+arg_0]
    push    edi
    push    ecx
    push    esi
    push    2
    push    edx
    call    sub_43F0E0
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43B5AD
    mov     ecx, [esp+8+arg_0]
    push    0
    push    0
    push    0
    push    edi
    push    0
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43B5AF
    ; ---------------------------------------------------------------------------

    loc_43B5AD:                             ; CODE XREF: sub_43B400+194j
    xor     eax, eax

    loc_43B5AF:                             ; CODE XREF: sub_43B400+1ABj
    mov     ecx, [eax+42h]
    and     ecx, 40000h
    jz      short loc_43B5BF
    mov     edi, [esi+60h]
    jmp     short loc_43B5C2
    ; ---------------------------------------------------------------------------

    loc_43B5BF:                             ; CODE XREF: sub_43B400+1B8j
    mov     edi, [esi+5Ch]

    loc_43B5C2:                             ; CODE XREF: sub_43B400+1BDj
    test    ecx, ecx
    lea     edx, [esi+60h]
    jnz     short loc_43B5CC
    lea     edx, [esi+5Ch]

    loc_43B5CC:                             ; CODE XREF: sub_43B400+1C7j
    mov     ecx, [edx]
    cmp     ecx, edi
    jz      short loc_43B5DC

    loc_43B5D2:                             ; CODE XREF: sub_43B400+1DAj
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, edi
    jnz     short loc_43B5D2

    loc_43B5DC:                             ; CODE XREF: sub_43B400+1D0j
    mov     [edx], eax
    mov     [eax+0Eh], esi
    test    edi, edi
    mov     [eax+4Ah], edi
    jz      short loc_43B5F9
    mov     edx, [edi+42h]
    mov     ecx, [eax+42h]
    and     edx, 4000h
    or      ecx, edx
    mov     [eax+42h], ecx

    loc_43B5F9:                             ; CODE XREF: sub_43B400+1E6j
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43B62C
    mov     ecx, [esi+92h]
    xor     edx, edx
    mov     dx, [ecx+214h]
    mov     ecx, [esp+8+arg_4]
    push    edx
    push    0
    push    0
    push    0
    push    ebx
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43B62E
    ; ---------------------------------------------------------------------------

    loc_43B62C:                             ; CODE XREF: sub_43B400+205j
    xor     eax, eax

    loc_43B62E:                             ; CODE XREF: sub_43B400+22Aj
    mov     dx, [esi+6Ch]
    mov     [eax+2Eh], dx
    mov     cx, [esi+74h]
    mov     [eax+30h], cx
    mov     ecx, [eax+42h]
    and     ecx, 40000h
    jz      short loc_43B64E
    mov     edi, [esi+60h]
    jmp     short loc_43B651
    ; ---------------------------------------------------------------------------

    loc_43B64E:                             ; CODE XREF: sub_43B400+247j
    mov     edi, [esi+5Ch]

    loc_43B651:                             ; CODE XREF: sub_43B400+24Cj
    test    ecx, ecx
    lea     edx, [esi+60h]
    jnz     short loc_43B65B
    lea     edx, [esi+5Ch]

    loc_43B65B:                             ; CODE XREF: sub_43B400+256j
    mov     ecx, [edx]
    cmp     ecx, edi
    jz      short loc_43B6D0

    loc_43B661:                             ; CODE XREF: sub_43B400+269j
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, edi
    jnz     short loc_43B661
    jmp     short loc_43B6D0
    ; ---------------------------------------------------------------------------

    loc_43B66D:                             ; CODE XREF: sub_43B400+168j
                                            ; sub_43B400+170j
    cmp     eax, 80000h
    jnz     loc_43B6F8
    test    ecx, ecx
    jnz     short loc_43B6F8
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43B6A1
    mov     ecx, [esp+8+arg_4]
    push    0
    push    0
    push    0
    push    0
    push    ebx
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43B6A3
    ; ---------------------------------------------------------------------------

    loc_43B6A1:                             ; CODE XREF: sub_43B400+288j
    xor     eax, eax

    loc_43B6A3:                             ; CODE XREF: sub_43B400+29Fj
    mov     ecx, [eax+42h]
    and     ecx, 40000h
    jz      short loc_43B6B3
    mov     edi, [esi+60h]
    jmp     short loc_43B6B6
    ; ---------------------------------------------------------------------------

    loc_43B6B3:                             ; CODE XREF: sub_43B400+2ACj
    mov     edi, [esi+5Ch]

    loc_43B6B6:                             ; CODE XREF: sub_43B400+2B1j
    test    ecx, ecx
    lea     edx, [esi+60h]
    jnz     short loc_43B6C0
    lea     edx, [esi+5Ch]

    loc_43B6C0:                             ; CODE XREF: sub_43B400+2BBj
    mov     ecx, [edx]
    cmp     ecx, edi
    jz      short loc_43B6D0

    loc_43B6C6:                             ; CODE XREF: sub_43B400+2CEj
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, edi
    jnz     short loc_43B6C6

    loc_43B6D0:                             ; CODE XREF: sub_43B400+25Fj
                                            ; sub_43B400+26Bj ...
    mov     [edx], eax
    mov     [eax+0Eh], esi
    test    edi, edi
    mov     [eax+4Ah], edi
    jz      short loc_43B6ED
    mov     edx, [edi+42h]
    mov     ecx, [eax+42h]
    and     edx, 4000h
    or      ecx, edx
    mov     [eax+42h], ecx

    loc_43B6ED:                             ; CODE XREF: sub_43B400+141j
                                            ; sub_43B400+2DAj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43B6F8:                             ; CODE XREF: sub_43B400+21j
                                            ; sub_43B400+272j ...
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    0Ch
    sub_43B400 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43B700 proc near                    ; CODE XREF: .text:004033DEp
                                            ; sub_405FE0+22p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+110h]
    and     ecx, 300000h
    cmp     ecx, 200000h
    jnz     short loc_43B725
    push    0
    push    0
    push    eax
    call    sub_40B7B0
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43B725:                             ; CODE XREF: sub_43B700+16j
    xor     eax, eax
    retn    4
    sub_43B700 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    push    edi
    push    56h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43B758
    mov     ecx, [esp+10h]
    push    0
    push    0
    push    0
    push    0
    push    0
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43B75A
    ; ---------------------------------------------------------------------------

    loc_43B758:                             ; CODE XREF: .text:0043B73Ej
    xor     eax, eax

    loc_43B75A:                             ; CODE XREF: .text:0043B756j
    mov     esi, [eax+42h]
    mov     edi, [esp+0Ch]
    or      esi, 4000h
    mov     ecx, esi
    mov     [eax+42h], esi
    and     ecx, 40000h
    jz      short loc_43B779
    mov     esi, [edi+60h]
    jmp     short loc_43B77C
    ; ---------------------------------------------------------------------------

    loc_43B779:                             ; CODE XREF: .text:0043B772j
    mov     esi, [edi+5Ch]

    loc_43B77C:                             ; CODE XREF: .text:0043B777j
    test    ecx, ecx
    lea     edx, [edi+60h]
    jnz     short loc_43B786
    lea     edx, [edi+5Ch]

    loc_43B786:                             ; CODE XREF: .text:0043B781j
    mov     ecx, [edx]
    cmp     ecx, esi
    jz      short loc_43B796

    loc_43B78C:                             ; CODE XREF: .text:0043B794j
    lea     edx, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, esi
    jnz     short loc_43B78C

    loc_43B796:                             ; CODE XREF: .text:0043B78Aj
    mov     [edx], eax
    mov     [eax+0Eh], edi
    test    esi, esi
    mov     [eax+4Ah], esi
    jz      short loc_43B7B3
    mov     edx, [esi+42h]
    mov     ecx, [eax+42h]
    and     edx, 4000h
    or      ecx, edx
    mov     [eax+42h], ecx

    loc_43B7B3:                             ; CODE XREF: .text:0043B7A0j
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43B7C0 proc near                    ; CODE XREF: sub_48AD30+268p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+14h+arg_0]
    xor     ebp, ebp
    mov     esi, [edi+5Ch]
    lea     ebx, [edi+5Ch]
    cmp     esi, ebp
    mov     [esp+14h+var_4], ebx
    jz      loc_43B9AD

    loc_43B7DD:                             ; CODE XREF: sub_43B7C0+1E7j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    mov     eax, [esi+0Ah]
    cmp     ecx, eax
    jb      short loc_43B7FE
    mov     eax, [esi+4Eh]
    mov     dword ptr [esi+0Ah], 0FFFFFFFFh
    or      al, 1
    mov     [esi+4Eh], eax

    loc_43B7FE:                             ; CODE XREF: sub_43B7C0+2Dj
    mov     cx, [edi+0BAh]
    mov     edi, [esi+4Eh]
    mov     eax, [esi+6]
    mov     edx, ecx
    and     edx, 0FFFFh
    or      edi, edx
    and     edi, eax
    cmp     eax, ebp
    jz      short loc_43B823
    cmp     edi, ebp
    jz      loc_43BA9C

    loc_43B823:                             ; CODE XREF: sub_43B7C0+59j
    mov     eax, edi
    mov     edx, edi
    not     eax
    and     eax, ecx
    mov     ecx, [esp+14h+arg_0]
    not     edx
    mov     [ecx+0BAh], ax
    mov     ecx, [esi+4Eh]
    and     ecx, edx
    mov     [esi+6], ebp
    test    edi, 10000h
    mov     [esi+4Eh], ecx
    jz      short loc_43B865
    mov     ebx, 3

    loc_43B850:                             ; CODE XREF: sub_43B7C0+9Dj
    mov     eax, [esp+14h+arg_0]
    push    ebp
    push    eax
    call    sub_48A0F0
    inc     ebp
    dec     ebx
    jnz     short loc_43B850
    mov     ebx, [esp+14h+var_4]
    xor     ebp, ebp

    loc_43B865:                             ; CODE XREF: sub_43B7C0+89j
    mov     ecx, dword_512344
    xor     eax, eax
    mov     al, [esi+4]
    push    edi
    push    esi
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*4]
    mov     ecx, [esi+0Eh]
    push    ecx
    call    dword ptr [eax+edx+4]
    cmp     eax, 9                          ; switch 10 cases
    ja      loc_43BA90                      ; default
    jmp     ds:off_43BAA4[eax*4]            ; switch jump

    loc_43B890:                             ; DATA XREF: .text:0043BAA4o
    push    0Fh                             ; case 0x3
    jmp     loc_43B951
    ; ---------------------------------------------------------------------------

    loc_43B897:                             ; CODE XREF: sub_43B7C0+C9j
                                            ; DATA XREF: .text:0043BAA4o
    inc     byte ptr [esi+5]                ; case 0x1
    jmp     loc_43B99F                      ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43B89F:                             ; CODE XREF: sub_43B7C0+C9j
                                            ; DATA XREF: .text:0043BAA4o
    mov     byte ptr [esi+5], 0             ; case 0x0
    jmp     loc_43B99F                      ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43B8A8:                             ; CODE XREF: sub_43B7C0+C9j
                                            ; DATA XREF: .text:0043BAA4o
    mov     eax, [esi+42h]                  ; case 0x5
    mov     edx, [ebx]
    test    eax, 40000h
    jz      short loc_43B8BD
    mov     eax, [esp+14h+arg_0]
    lea     ecx, [eax+60h]
    jmp     short loc_43B8BF
    ; ---------------------------------------------------------------------------

    loc_43B8BD:                             ; CODE XREF: sub_43B7C0+F2j
    mov     ecx, ebx

    loc_43B8BF:                             ; CODE XREF: sub_43B7C0+FBj
    mov     eax, [ecx]
    cmp     eax, ebp
    jz      loc_43B99F                      ; case 0x2

    loc_43B8C9:                             ; CODE XREF: sub_43B7C0+115j
    cmp     eax, esi
    jz      short loc_43B8DC
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    cmp     eax, ebp
    jnz     short loc_43B8C9
    jmp     loc_43B99F                      ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43B8DC:                             ; CODE XREF: sub_43B7C0+10Bj
    mov     eax, [esi+4Ah]
    cmp     esi, edx
    mov     [ecx], eax
    jmp     short loc_43B92C
    ; ---------------------------------------------------------------------------

    loc_43B8E5:                             ; CODE XREF: sub_43B7C0+C9j
                                            ; DATA XREF: .text:0043BAA4o
    mov     edx, [esi+42h]                  ; case 0x9
    or      edx, 800000h
    mov     [esi+42h], edx
    mov     eax, edx
    mov     edx, [esi+4Ah]
    cmp     edx, ebp
    jz      short loc_43B94B
    mov     edi, [ebx]
    test    eax, 40000h
    jz      short loc_43B90C
    mov     ecx, [esp+14h+arg_0]
    add     ecx, 60h
    jmp     short loc_43B90E
    ; ---------------------------------------------------------------------------

    loc_43B90C:                             ; CODE XREF: sub_43B7C0+141j
    mov     ecx, ebx

    loc_43B90E:                             ; CODE XREF: sub_43B7C0+14Aj
    mov     eax, [ecx]
    cmp     eax, ebp
    jz      loc_43B99F                      ; case 0x2

    loc_43B918:                             ; CODE XREF: sub_43B7C0+164j
    cmp     eax, esi
    jz      short loc_43B928
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    cmp     eax, ebp
    jnz     short loc_43B918
    jmp     short loc_43B99F                ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43B928:                             ; CODE XREF: sub_43B7C0+15Aj
    mov     [ecx], edx
    cmp     esi, edi

    loc_43B92C:                             ; CODE XREF: sub_43B7C0+123j
    jz      short loc_43B935
    or      dword ptr [esi+42h], 10000h

    loc_43B935:                             ; CODE XREF: sub_43B7C0+16Cj
    cmp     esi, ebp
    jz      short loc_43B99F                ; case 0x2
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4
    jmp     short loc_43B99F                ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43B94B:                             ; CODE XREF: sub_43B7C0+138j
    mov     byte ptr [esi+5], 0
    push    1Eh                             ; int

    loc_43B951:                             ; CODE XREF: sub_43B7C0+D2j
    call    GetRandom
    mov     edi, [esi+6]
    add     eax, 1Eh
    or      edi, 1
    mov     [esi+6], edi
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+38A47h]
    add     ecx, eax
    mov     [esi+0Ah], ecx
    jmp     short loc_43B99F                ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43B975:                             ; CODE XREF: sub_43B7C0+C9j
                                            ; DATA XREF: .text:0043BAA4o
    mov     eax, ebx                        ; case 0x6
    mov     ecx, [eax]
    cmp     ecx, esi
    jz      short loc_43B987

    loc_43B97D:                             ; CODE XREF: sub_43B7C0+1C5j
    lea     eax, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, esi
    jnz     short loc_43B97D

    loc_43B987:                             ; CODE XREF: sub_43B7C0+1BBj
    mov     ecx, [esi+4Ah]
    cmp     ecx, ebp
    mov     [eax], ecx
    jz      short loc_43B99A

    loc_43B990:                             ; CODE XREF: sub_43B7C0+1D8j
    lea     eax, [ecx+4Ah]
    mov     ecx, [ecx+4Ah]
    cmp     ecx, ebp
    jnz     short loc_43B990

    loc_43B99A:                             ; CODE XREF: sub_43B7C0+1CEj
    mov     [eax], esi
    mov     [esi+4Ah], ebp

    loc_43B99F:                             ; CODE XREF: sub_43B7C0+C9j
                                            ; sub_43B7C0+DAj ...
    mov     esi, [ebx]                      ; case 0x2
    mov     edi, [esp+14h+arg_0]
    cmp     esi, ebp
    jnz     loc_43B7DD

    loc_43B9AD:                             ; CODE XREF: sub_43B7C0+17j
    mov     eax, [edi+96h]
    cmp     [eax], ebp
    jz      loc_43BA9C
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_43B9CA
    cmp     al, 2
    jnz     loc_43BA9C

    loc_43B9CA:                             ; CODE XREF: sub_43B7C0+200j
    mov     edx, [edi+92h]
    mov     al, [edx+230h]
    test    al, al
    jz      loc_43BA9C
    push    56h                             ; int
    mov     byte ptr [esp+18h+arg_0], al
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_43BA03
    mov     ecx, [esp+14h+arg_0]
    push    ebp
    push    ebp
    push    ebp
    push    ebp
    push    ebp
    push    ecx
    mov     ecx, eax
    call    sub_43A0C0
    jmp     short loc_43BA05
    ; ---------------------------------------------------------------------------

    loc_43BA03:                             ; CODE XREF: sub_43B7C0+22Ej
    xor     eax, eax

    loc_43BA05:                             ; CODE XREF: sub_43B7C0+241j
    mov     edx, [eax+42h]
    or      dh, 40h
    mov     ecx, edx
    mov     [eax+42h], edx
    test    ecx, 40000h
    jz      short loc_43BA2B
    mov     ecx, [edi+60h]
    push    ecx
    push    eax
    push    edi
    call    sub_43AC60
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43BA2B:                             ; CODE XREF: sub_43B7C0+256j
    mov     ecx, [ebx]
    push    ecx
    push    eax
    push    edi
    call    sub_43AC60
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43BA3D:                             ; CODE XREF: sub_43B7C0+C9j
                                            ; DATA XREF: .text:0043BAA4o
    mov     edi, [ebx]                      ; case 0x7
    mov     esi, edi
    cmp     esi, ebp
    jz      short loc_43BA6F

    loc_43BA45:                             ; CODE XREF: sub_43B7C0+2ADj
    mov     edx, [esi+4Ah]
    cmp     esi, edi
    mov     [ebx], edx
    jz      short loc_43BA55
    or      dword ptr [esi+42h], 10000h

    loc_43BA55:                             ; CODE XREF: sub_43B7C0+28Cj
    cmp     esi, ebp
    jz      short loc_43BA69
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_43BA69:                             ; CODE XREF: sub_43B7C0+297j
    mov     esi, [ebx]
    cmp     esi, ebp
    jnz     short loc_43BA45

    loc_43BA6F:                             ; CODE XREF: sub_43B7C0+283j
    mov     esi, [esp+14h+arg_0]
    mov     eax, [esi+60h]
    cmp     eax, ebp
    jz      short loc_43BA9C

    loc_43BA7A:                             ; CODE XREF: sub_43B7C0+2C6j
    push    eax
    push    esi
    call    sub_439F80
    mov     eax, [esi+60h]
    cmp     eax, ebp
    jnz     short loc_43BA7A
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43BA90:                             ; CODE XREF: sub_43B7C0+C3j
    mov     eax, [esp+14h+arg_0]            ; default
    push    1
    push    eax
    call    sub_439EB0

    loc_43BA9C:                             ; CODE XREF: sub_43B7C0+5Dj
                                            ; sub_43B7C0+1F5j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_43B7C0 endp

    ; ---------------------------------------------------------------------------
    off_43BAA4 dd offset loc_43B89F         ; DATA XREF: sub_43B7C0+C9r
    dd offset loc_43B897                    ; jump table for switch statement
    dd offset loc_43B99F
    dd offset loc_43B890
    dd offset loc_43B99F
    dd offset loc_43B8A8
    dd offset loc_43B975
    dd offset loc_43BA3D
    dd offset loc_43B8A8
    dd offset loc_43B8E5
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43BAD0 proc near                    ; CODE XREF: sub_48AD30+26Ep

    arg_0= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    xor     ebx, ebx
    mov     esi, [edi+60h]
    lea     ebp, [edi+60h]
    cmp     esi, ebx
    jz      loc_43BC57

    loc_43BAE8:                             ; CODE XREF: sub_43BAD0+129j
    cmp     [esi+6], ebx
    jz      short loc_43BB07
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    mov     eax, [esi+0Ah]
    cmp     ecx, eax
    jnb     short loc_43BB07
    mov     esi, [esi+4Ah]
    jmp     loc_43BBF7
    ; ---------------------------------------------------------------------------

    loc_43BB07:                             ; CODE XREF: sub_43BAD0+1Bj
                                            ; sub_43BAD0+2Dj
    xor     eax, eax
    mov     [esi+6], ebx
    mov     al, [esi+4]
    mov     edx, dword_512344
    push    ebx
    push    esi
    lea     eax, [eax+eax*4]
    lea     ecx, [edx+eax*4]
    mov     edx, [esi+0Eh]
    push    edx
    call    dword ptr [eax+ecx+4]
    cmp     eax, 9                          ; switch 10 cases
    ja      short loc_43BBA8                ; default
    jmp     ds:off_43BC60[eax*4]            ; switch jump

    loc_43BB31:                             ; DATA XREF: .text:0043BC60o
    push    0Fh                             ; case 0x3
    call    GetRandom
    mov     edx, [esi+6]
    add     eax, 1Eh
    or      edx, 1
    mov     [esi+6], edx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+38A47h]
    add     edx, eax
    mov     [esi+0Ah], edx
    jmp     loc_43BBF4                      ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43BB5A:                             ; CODE XREF: sub_43BAD0+5Aj
                                            ; DATA XREF: .text:0043BC60o
    inc     byte ptr [esi+5]                ; case 0x1
    jmp     loc_43BBF4                      ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43BB62:                             ; CODE XREF: sub_43BAD0+5Aj
                                            ; DATA XREF: .text:0043BC60o
    mov     [esi+5], bl                     ; case 0x0
    jmp     loc_43BBF4                      ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43BB6A:                             ; CODE XREF: sub_43BAD0+5Aj
                                            ; DATA XREF: .text:0043BC60o
    mov     eax, [esi+42h]                  ; case 0x5
    mov     edx, [edi+5Ch]
    lea     ecx, [edi+5Ch]
    test    eax, 40000h
    jz      short loc_43BB7C
    mov     ecx, ebp

    loc_43BB7C:                             ; CODE XREF: sub_43BAD0+A8j
    mov     eax, [ecx]
    cmp     eax, ebx
    jz      short loc_43BBF4                ; case 0x2

    loc_43BB82:                             ; CODE XREF: sub_43BAD0+BEj
    cmp     eax, esi
    jz      short loc_43BB92
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    cmp     eax, ebx
    jnz     short loc_43BB82
    jmp     short loc_43BBF4                ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43BB92:                             ; CODE XREF: sub_43BAD0+B4j
    mov     eax, [esi+4Ah]
    cmp     esi, edx
    mov     [ecx], eax
    jz      short loc_43BBA2
    or      dword ptr [esi+42h], 10000h

    loc_43BBA2:                             ; CODE XREF: sub_43BAD0+C9j
    cmp     esi, ebx
    jz      short loc_43BBF4                ; case 0x2
    jmp     short loc_43BBE4
    ; ---------------------------------------------------------------------------

    loc_43BBA8:                             ; CODE XREF: sub_43BAD0+58j
    mov     eax, [esi+42h]                  ; default
    mov     edx, [edi+5Ch]
    lea     ecx, [edi+5Ch]
    test    eax, 40000h
    jz      short loc_43BBBA
    mov     ecx, ebp

    loc_43BBBA:                             ; CODE XREF: sub_43BAD0+E6j
    mov     eax, [ecx]
    cmp     eax, ebx
    jz      short loc_43BBF4                ; case 0x2

    loc_43BBC0:                             ; CODE XREF: sub_43BAD0+FCj
    cmp     eax, esi
    jz      short loc_43BBD0
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    cmp     eax, ebx
    jnz     short loc_43BBC0
    jmp     short loc_43BBF4                ; case 0x2
    ; ---------------------------------------------------------------------------

    loc_43BBD0:                             ; CODE XREF: sub_43BAD0+F2j
    mov     eax, [esi+4Ah]
    cmp     esi, edx
    mov     [ecx], eax
    jz      short loc_43BBE0
    or      dword ptr [esi+42h], 10000h

    loc_43BBE0:                             ; CODE XREF: sub_43BAD0+107j
    cmp     esi, ebx
    jz      short loc_43BBF4                ; case 0x2

    loc_43BBE4:                             ; CODE XREF: sub_43BAD0+D6j
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_43BBF4:                             ; CODE XREF: sub_43BAD0+5Aj
                                            ; sub_43BAD0+85j ...
    mov     esi, [ebp+0]                    ; case 0x2

    loc_43BBF7:                             ; CODE XREF: sub_43BAD0+32j
    cmp     esi, ebx
    jnz     loc_43BAE8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43BC06:                             ; CODE XREF: sub_43BAD0+5Aj
                                            ; DATA XREF: .text:0043BC60o
    mov     eax, [esi+42h]                  ; case 0x6
    mov     edx, [edi+5Ch]
    lea     ecx, [edi+5Ch]
    test    eax, 40000h
    jz      short loc_43BC18
    mov     ecx, ebp

    loc_43BC18:                             ; CODE XREF: sub_43BAD0+144j
    mov     eax, [ecx]
    cmp     eax, ebx
    jz      short loc_43BC57

    loc_43BC1E:                             ; CODE XREF: sub_43BAD0+15Aj
    cmp     eax, esi
    jz      short loc_43BC33
    lea     ecx, [eax+4Ah]
    mov     eax, [eax+4Ah]
    cmp     eax, ebx
    jnz     short loc_43BC1E
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43BC33:                             ; CODE XREF: sub_43BAD0+150j
    mov     eax, [esi+4Ah]
    cmp     esi, edx
    mov     [ecx], eax
    jz      short loc_43BC43
    or      dword ptr [esi+42h], 10000h

    loc_43BC43:                             ; CODE XREF: sub_43BAD0+16Aj
    cmp     esi, ebx
    jz      short loc_43BC57
    mov     ecx, esi
    call    sub_43A1F0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_43BC57:                             ; CODE XREF: sub_43BAD0+12j
                                            ; sub_43BAD0+14Cj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_43BAD0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 4
    off_43BC60 dd offset loc_43BB62         ; DATA XREF: sub_43BAD0+5Ar
    dd offset loc_43BB5A                    ; jump table for switch statement
    dd offset loc_43BBF4
    dd offset loc_43BB31
    dd offset loc_43BBF4
    dd offset loc_43BB6A
    dd offset loc_43BC06
    dd offset loc_43BC06
    dd offset loc_43BB6A
    dd offset loc_43BB6A
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43BC90 proc near                    ; CODE XREF: sub_403180+7p
                                            ; sub_406BF0+7p ...

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_7= dword ptr -7
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, dword_512344
    sub     esp, 20h
    test    ecx, ecx
    push    ebx
    push    ebp
    mov     ebp, dword_512348
    push    esi
    push    edi
    jnz     short loc_43BCAB
    xor     edx, edx
    jmp     short loc_43BCC0
    ; ---------------------------------------------------------------------------

    loc_43BCAB:                             ; CODE XREF: sub_43BC90+15j
    mov     edx, ebp
    mov     eax, 51EB851Fh
    sub     edx, ecx
    imul    edx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_43BCC0:                             ; CODE XREF: sub_43BC90+19j
    mov     edi, [esp+30h+arg_4]
    test    ecx, ecx
    lea     esi, [edx+edi]
    mov     [esp+30h+var_20], esi
    jnz     short loc_43BCD3
    xor     edx, edx
    jmp     short loc_43BCEC
    ; ---------------------------------------------------------------------------

    loc_43BCD3:                             ; CODE XREF: sub_43BC90+3Dj
    mov     edx, dword_51234C
    mov     eax, 51EB851Fh
    sub     edx, ecx
    imul    edx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_43BCEC:                             ; CODE XREF: sub_43BC90+41j
    cmp     edx, esi
    jnb     loc_43BD93
    test    esi, esi
    mov     eax, esi
    jge     short loc_43BCFC
    xor     eax, eax

    loc_43BCFC:                             ; CODE XREF: sub_43BC90+68j
    lea     eax, [eax+eax*4]
    lea     ecx, [eax+eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     ebp, dword_512348
    mov     ebx, eax
    mov     eax, dword_512344
    add     esp, 4
    cmp     eax, ebp
    mov     edx, ebx
    jz      short loc_43BD47

    loc_43BD1E:                             ; CODE XREF: sub_43BC90+AAj
    test    edx, edx
    jz      short loc_43BD32
    mov     ecx, 6
    mov     esi, eax
    mov     edi, edx
    rep movsd
    movsb
    mov     esi, [esp+30h+var_20]

    loc_43BD32:                             ; CODE XREF: sub_43BC90+90j
    add     eax, 19h
    add     edx, 19h
    cmp     eax, ebp
    jnz     short loc_43BD1E
    mov     ebp, dword_512348
    mov     eax, dword_512344

    loc_43BD47:                             ; CODE XREF: sub_43BC90+8Cj
    push    ebp
    push    eax
    mov     ecx, offset byte_512340
    call    nullsub_10
    mov     edx, dword_512344
    push    edx
    call    sub_4B4F20
    lea     eax, [esi+esi*4]
    add     esp, 4
    lea     ecx, [ebx+eax*4]
    add     eax, ecx
    mov     ecx, offset byte_512340
    mov     dword_51234C, eax
    call    sub_43C360
    mov     edi, [esp+30h+arg_4]
    lea     ebp, [eax+eax*4]
    mov     ecx, ebx
    lea     edx, [ebx+ebp*4]
    mov     dword_512344, ecx
    add     ebp, edx
    mov     dword_512348, ebp

    loc_43BD93:                             ; CODE XREF: sub_43BC90+5Ej
    mov     esi, [esp+30h+arg_0]
    lea     edi, [edi+edi*4]
    lea     eax, [esi+edi*4]
    add     edi, eax
    cmp     esi, edi
    jz      short loc_43BDC4

    loc_43BDA3:                             ; CODE XREF: sub_43BC90+12Cj
    push    esi
    push    1
    push    ebp
    mov     ecx, offset byte_512340
    call    sub_43C3A0
    mov     ebp, dword_512348
    add     esi, 19h
    cmp     esi, edi
    jnz     short loc_43BDA3
    mov     ecx, dword_512344

    loc_43BDC4:                             ; CODE XREF: sub_43BC90+111j
    mov     edx, ebp
    mov     eax, 51EB851Fh
    sub     edx, ecx
    mov     [esp+30h+var_20], ebp
    imul    edx
    sar     edx, 3
    mov     eax, edx
    mov     [esp+30h+arg_4], ecx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 10h
    jg      short loc_43BDFE
    push    0
    push    offset loc_43C020
    push    ebp
    push    ecx
    call    sub_43C990
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_43BDFE:                             ; CODE XREF: sub_43BC90+154j
    cmp     edx, 10h
    mov     ebx, ecx
    jle     loc_43BEF4

    loc_43BE09:                             ; CODE XREF: sub_43BC90+25Aj
    push    offset loc_43C020
    push    offset loc_43C020
    sub     esp, 1Ch
    lea     esi, [ebp-19h]
    mov     ecx, 6
    mov     edi, esp
    rep movsd
    mov     ecx, ebp
    mov     eax, 51EB851Fh
    sub     ecx, ebx
    sub     esp, 1Ch
    imul    ecx
    mov     eax, edx
    sar     eax, 3
    mov     ecx, eax
    shr     ecx, 1Fh
    add     eax, ecx
    mov     ecx, 6
    cdq
    sub     eax, edx
    sar     eax, 1
    movsb
    lea     eax, [eax+eax*4]
    mov     edi, esp
    mov     esi, eax
    sub     esp, 1Ch
    lea     edx, [ebx+eax*4]
    lea     eax, [esp+8Ch+var_1C]
    add     esi, edx
    rep movsd
    movsb
    mov     ecx, 6
    mov     esi, ebx
    mov     edi, esp
    push    eax
    rep movsd
    movsb
    call    sub_43CA70
    sub     esp, 1Ch
    mov     ecx, 6
    mov     esi, eax
    mov     edi, esp
    rep movsd
    push    ebp
    push    ebx
    movsb
    call    sub_43CB20
    mov     esi, eax
    mov     eax, 51EB851Fh
    mov     ecx, esi
    push    0
    sub     ecx, ebx
    push    offset loc_43C020
    imul    ecx
    mov     ecx, edx
    mov     eax, 51EB851Fh
    sar     ecx, 3
    mov     edx, ecx
    shr     edx, 1Fh
    add     ecx, edx
    mov     edx, ebp
    sub     edx, esi
    imul    edx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ecx
    jg      short loc_43BEC9
    push    ebp
    push    esi
    call    sub_43C720
    mov     ebp, esi
    jmp     short loc_43BED2
    ; ---------------------------------------------------------------------------

    loc_43BEC9:                             ; CODE XREF: sub_43BC90+22Cj
    push    esi
    push    ebx
    call    sub_43C720
    mov     ebx, esi

    loc_43BED2:                             ; CODE XREF: sub_43BC90+237j
    mov     ecx, ebp
    mov     eax, 51EB851Fh
    sub     ecx, ebx
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    cmp     edx, 10h
    jg      loc_43BE09
    mov     ecx, [esp+30h+arg_4]

    loc_43BEF4:                             ; CODE XREF: sub_43BC90+173j
    lea     ebp, [ecx+190h]
    cmp     ecx, ebp
    mov     [esp+30h+arg_0], ebp
    jz      loc_43BF98
    lea     ebx, [ecx+19h]
    cmp     ebx, ebp
    jz      loc_43BF98

    loc_43BF11:                             ; CODE XREF: sub_43BC90+300j
    mov     ecx, 6
    mov     esi, ebx
    lea     edi, [esp+30h+var_1C]
    mov     ebp, [esp+30h+arg_4]
    rep movsd
    mov     edx, [ebp+15h]
    movsb
    mov     eax, [esp+30h+var_7]
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    mov     eax, ecx
    test    eax, eax
    jnz     short loc_43BF5F
    push    offset loc_43C020
    mov     ecx, 6
    sub     esp, 1Ch
    lea     esi, [esp+50h+var_1C]
    mov     edi, esp
    rep movsd
    push    ebx
    movsb
    call    sub_43C940
    jmp     short loc_43BF87
    ; ---------------------------------------------------------------------------

    loc_43BF5F:                             ; CODE XREF: sub_43BC90+2AFj
    cmp     ebp, ebx
    mov     eax, ebx
    jz      short loc_43BF79

    loc_43BF65:                             ; CODE XREF: sub_43BC90+2E7j
    sub     eax, 19h
    mov     ecx, 6
    mov     esi, eax
    cmp     eax, ebp
    lea     edi, [eax+19h]
    rep movsd
    movsb
    jnz     short loc_43BF65

    loc_43BF79:                             ; CODE XREF: sub_43BC90+2D3j
    mov     ecx, 6
    lea     esi, [esp+30h+var_1C]
    mov     edi, ebp
    rep movsd
    movsb

    loc_43BF87:                             ; CODE XREF: sub_43BC90+2CDj
    mov     eax, [esp+30h+arg_0]
    add     ebx, 19h
    cmp     ebx, eax
    jnz     loc_43BF11
    mov     ebp, eax

    loc_43BF98:                             ; CODE XREF: sub_43BC90+270j
                                            ; sub_43BC90+27Bj
    cmp     ebp, [esp+30h+var_20]
    jz      short loc_43C013

    loc_43BF9E:                             ; CODE XREF: sub_43BC90+381j
    mov     ecx, 6
    mov     esi, ebp
    lea     edi, [esp+30h+var_1C]
    mov     edx, [ebp-4]
    rep movsd
    lea     ebx, [ebp-19h]
    push    edx                             ; char *
    movsb
    mov     eax, [esp+34h+var_7]
    mov     edi, ebp
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    mov     eax, ecx
    test    eax, eax
    jz      short loc_43BFFC

    loc_43BFCF:                             ; CODE XREF: sub_43BC90+36Aj
    mov     ecx, 6
    mov     esi, ebx
    rep movsd
    mov     eax, [esp+30h+var_7]
    movsb
    mov     edx, [ebx-4]
    mov     edi, ebx
    sub     ebx, 19h
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    mov     eax, ecx
    test    eax, eax
    jnz     short loc_43BFCF

    loc_43BFFC:                             ; CODE XREF: sub_43BC90+33Dj
    mov     ecx, 6
    lea     esi, [esp+30h+var_1C]
    rep movsd
    mov     eax, [esp+30h+var_20]
    add     ebp, 19h
    cmp     ebp, eax
    movsb
    jnz     short loc_43BF9E

    loc_43C013:                             ; CODE XREF: sub_43BC90+30Cj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    sub_43BC90 endp

    ; ---------------------------------------------------------------------------
    align 4

    loc_43C020:                             ; DATA XREF: sub_43BC90+158o
                                            ; sub_43BC90+179o ...
    mov     eax, [esp+8]
    mov     edx, [esp+4]
    mov     ecx, [eax+15h]
    mov     eax, [edx+15h]
    push    ecx
    push    eax
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl

    unknown_libname_12:
    mov     eax, ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43C050 proc near                    ; CODE XREF: sub_491200+16Ep

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_7= dword ptr -7

    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    mov     esi, dword_512344
    test    esi, esi
    push    edi
    jnz     short loc_43C065
    xor     edx, edx
    jmp     short loc_43C07E
    ; ---------------------------------------------------------------------------

    loc_43C065:                             ; CODE XREF: sub_43C050+Fj
    mov     ecx, dword_512348
    mov     eax, 51EB851Fh
    sub     ecx, esi
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_43C07E:                             ; CODE XREF: sub_43C050+13j
    lea     edi, [edx+1]
    test    esi, esi
    mov     [esp+34h+var_24], edi
    jnz     short loc_43C08D
    xor     edx, edx
    jmp     short loc_43C0A6
    ; ---------------------------------------------------------------------------

    loc_43C08D:                             ; CODE XREF: sub_43C050+37j
    mov     ecx, dword_51234C
    mov     eax, 51EB851Fh
    sub     ecx, esi
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_43C0A6:                             ; CODE XREF: sub_43C050+3Bj
    cmp     edx, edi
    jnb     loc_43C145
    test    edi, edi
    mov     eax, edi
    jge     short loc_43C0B6
    xor     eax, eax

    loc_43C0B6:                             ; CODE XREF: sub_43C050+62j
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    mov     ebp, dword_512348
    mov     ebx, eax
    mov     eax, dword_512344
    add     esp, 4
    cmp     eax, ebp
    mov     edx, ebx
    jz      short loc_43C101

    loc_43C0D8:                             ; CODE XREF: sub_43C050+A4j
    test    edx, edx
    jz      short loc_43C0EC
    mov     ecx, 6
    mov     esi, eax
    mov     edi, edx
    rep movsd
    movsb
    mov     edi, [esp+34h+var_24]

    loc_43C0EC:                             ; CODE XREF: sub_43C050+8Aj
    add     eax, 19h
    add     edx, 19h
    cmp     eax, ebp
    jnz     short loc_43C0D8
    mov     ebp, dword_512348
    mov     eax, dword_512344

    loc_43C101:                             ; CODE XREF: sub_43C050+86j
    push    ebp
    push    eax
    mov     ecx, offset byte_512340
    call    nullsub_10
    mov     eax, dword_512344
    push    eax
    call    sub_4B4F20
    lea     eax, [edi+edi*4]
    add     esp, 4
    lea     ecx, [ebx+eax*4]
    add     eax, ecx
    mov     ecx, offset byte_512340
    mov     dword_51234C, eax
    call    sub_43C360
    lea     eax, [eax+eax*4]
    mov     dword_512344, ebx
    lea     edx, [ebx+eax*4]
    add     eax, edx
    mov     dword_512348, eax

    loc_43C145:                             ; CODE XREF: sub_43C050+58j
    mov     esi, offset off_4FD288

    loc_43C14A:                             ; CODE XREF: sub_43C050+116j
    mov     eax, dword_512348
    push    esi
    push    1
    push    eax
    mov     ecx, offset byte_512340
    call    sub_43C3A0
    add     esi, 19h
    cmp     esi, offset byte_4FD2A1
    jnz     short loc_43C14A
    mov     ebp, dword_512348
    mov     ebx, dword_512344
    mov     ecx, ebp
    mov     eax, 51EB851Fh
    sub     ecx, ebx
    mov     esi, ebx
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    mov     [esp+34h+var_24], ebp
    shr     ecx, 1Fh
    add     edx, ecx
    mov     [esp+34h+var_20], esi
    cmp     edx, 10h
    jg      short loc_43C1AB
    push    0
    push    offset loc_43C020
    push    ebp
    push    ebx
    call    sub_43C990
    jmp     loc_43C325
    ; ---------------------------------------------------------------------------

    loc_43C1AB:                             ; CODE XREF: sub_43C050+146j
                                            ; sub_43C050+23Cj
    push    offset loc_43C020
    push    offset loc_43C020
    sub     esp, 1Ch
    lea     esi, [ebp-19h]
    mov     ecx, 6
    mov     edi, esp
    rep movsd
    mov     ecx, ebp
    mov     eax, 51EB851Fh
    sub     ecx, ebx
    sub     esp, 1Ch
    imul    ecx
    mov     eax, edx
    sar     eax, 3
    mov     edx, eax
    shr     edx, 1Fh
    add     eax, edx
    cdq
    sub     eax, edx
    lea     edx, [esp+74h+var_1C]
    sar     eax, 1
    movsb
    lea     eax, [eax+eax*4]
    mov     edi, esp
    mov     esi, eax
    sub     esp, 1Ch
    lea     ecx, [ebx+eax*4]
    add     esi, ecx
    mov     ecx, 6
    rep movsd
    movsb
    mov     ecx, 6
    mov     esi, ebx
    mov     edi, esp
    push    edx
    rep movsd
    movsb
    call    sub_43CA70
    sub     esp, 1Ch
    mov     ecx, 6
    mov     esi, eax
    mov     edi, esp
    rep movsd
    push    ebp
    push    ebx
    movsb
    call    sub_43CB20
    mov     esi, eax
    mov     ecx, ebp
    sub     ecx, esi
    mov     eax, 51EB851Fh
    imul    ecx
    mov     ecx, edx
    mov     edx, esi
    sar     ecx, 3
    mov     eax, ecx
    sub     edx, ebx
    shr     eax, 1Fh
    add     ecx, eax
    mov     eax, 51EB851Fh
    imul    edx
    sar     edx, 3
    mov     eax, edx
    push    0
    shr     eax, 1Fh
    add     edx, eax
    push    offset loc_43C020
    cmp     ecx, edx
    jg      short loc_43C26B
    push    ebp
    push    esi
    call    sub_43C720
    mov     ebp, esi
    jmp     short loc_43C274
    ; ---------------------------------------------------------------------------

    loc_43C26B:                             ; CODE XREF: sub_43C050+20Ej
    push    esi
    push    ebx
    call    sub_43C720
    mov     ebx, esi

    loc_43C274:                             ; CODE XREF: sub_43C050+219j
    mov     ecx, ebp
    mov     eax, 51EB851Fh
    sub     ecx, ebx
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    cmp     edx, 10h
    jg      loc_43C1AB
    mov     esi, [esp+34h+var_20]
    push    0
    push    offset loc_43C020
    lea     ebp, [esi+190h]
    push    ebp
    push    esi
    call    sub_43C990
    cmp     ebp, [esp+34h+var_24]
    jz      short loc_43C325

    loc_43C2B0:                             ; CODE XREF: sub_43C050+2D3j
    mov     ecx, 6
    mov     esi, ebp
    lea     edi, [esp+34h+var_1C]
    mov     edx, [ebp-4]
    rep movsd
    lea     ebx, [ebp-19h]
    push    edx                             ; char *
    movsb
    mov     eax, [esp+38h+var_7]
    mov     edi, ebp
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    mov     eax, ecx
    test    eax, eax
    jz      short loc_43C30E

    loc_43C2E1:                             ; CODE XREF: sub_43C050+2BCj
    mov     ecx, 6
    mov     esi, ebx
    rep movsd
    mov     eax, [esp+34h+var_7]
    movsb
    mov     edx, [ebx-4]
    mov     edi, ebx
    sub     ebx, 19h
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    mov     eax, ecx
    test    eax, eax
    jnz     short loc_43C2E1

    loc_43C30E:                             ; CODE XREF: sub_43C050+28Fj
    mov     ecx, 6
    lea     esi, [esp+34h+var_1C]
    rep movsd
    mov     eax, [esp+34h+var_24]
    add     ebp, 19h
    cmp     ebp, eax
    movsb
    jnz     short loc_43C2B0

    loc_43C325:                             ; CODE XREF: sub_43C050+156j
                                            ; sub_43C050+25Ej
    call    sub_406BF0
    call    sub_415B20
    call    sub_406F00
    call    sub_403180
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn
    sub_43C050 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43C350 proc near                    ; CODE XREF: sub_4916A0+E1p
    mov     eax, dword_512344
    mov     dword_512348, eax
    retn
    sub_43C350 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43C360 proc near                    ; CODE XREF: sub_43BC90+E4p
                                            ; sub_43C050+DDp
    mov     eax, [ecx+4]
    test    eax, eax
    jnz     short loc_43C368
    retn
    ; ---------------------------------------------------------------------------

    loc_43C368:                             ; CODE XREF: sub_43C360+5j
    mov     ecx, [ecx+8]
    sub     ecx, eax
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, edx
    retn
    sub_43C360 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_10. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43C3A0 proc near                    ; CODE XREF: sub_43BC90+11Cp
                                            ; sub_43C050+108p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    mov     eax, 51EB851Fh
    push    esi
    push    edi
    mov     ebx, [ebp+8]
    mov     ecx, [ebp+0Ch]
    sub     ecx, ebx
    mov     edi, [esp+1Ch+arg_4]
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    mov     [esp+1Ch+var_C], ebp
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, edi
    jnb     loc_43C54E
    mov     esi, [ebp+4]
    test    esi, esi
    jnz     short loc_43C3DD
    xor     edx, edx
    jmp     short loc_43C3F2
    ; ---------------------------------------------------------------------------

    loc_43C3DD:                             ; CODE XREF: sub_43C3A0+37j
    mov     ecx, ebx
    mov     eax, 51EB851Fh
    sub     ecx, esi
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_43C3F2:                             ; CODE XREF: sub_43C3A0+3Bj
    cmp     edi, edx
    jnb     short loc_43C417
    test    esi, esi
    jnz     short loc_43C3FE
    xor     ecx, ecx
    jmp     short loc_43C419
    ; ---------------------------------------------------------------------------

    loc_43C3FE:                             ; CODE XREF: sub_43C3A0+58j
    mov     ecx, ebx
    mov     eax, 51EB851Fh
    sub     ecx, esi
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ecx, edx
    jmp     short loc_43C419
    ; ---------------------------------------------------------------------------

    loc_43C417:                             ; CODE XREF: sub_43C3A0+54j
    mov     ecx, edi

    loc_43C419:                             ; CODE XREF: sub_43C3A0+5Cj
                                            ; sub_43C3A0+75j
    test    esi, esi
    jnz     short loc_43C421
    xor     edx, edx
    jmp     short loc_43C434
    ; ---------------------------------------------------------------------------

    loc_43C421:                             ; CODE XREF: sub_43C3A0+7Bj
    sub     ebx, esi
    mov     eax, 51EB851Fh
    imul    ebx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_43C434:                             ; CODE XREF: sub_43C3A0+7Fj
    lea     eax, [edx+ecx]
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_43C441
    xor     eax, eax

    loc_43C441:                             ; CODE XREF: sub_43C3A0+9Dj
    lea     eax, [eax+eax*4]
    lea     ecx, [eax+eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     esi, [esp+20h+arg_0]
    mov     [esp+20h+var_4], eax
    mov     ebx, eax
    mov     eax, [ebp+4]
    add     esp, 4
    cmp     eax, esi
    jz      short loc_43C487

    loc_43C461:                             ; CODE XREF: sub_43C3A0+DDj
    test    ebx, ebx
    jz      short loc_43C471
    mov     ecx, 6
    mov     esi, eax
    mov     edi, ebx
    rep movsd
    movsb

    loc_43C471:                             ; CODE XREF: sub_43C3A0+C3j
    mov     esi, [esp+1Ch+arg_0]
    add     eax, 19h
    add     ebx, 19h
    cmp     eax, esi
    jnz     short loc_43C461
    mov     edi, [esp+1Ch+arg_4]
    mov     ebp, [esp+1Ch+var_C]

    loc_43C487:                             ; CODE XREF: sub_43C3A0+BFj
    test    edi, edi
    mov     eax, ebx
    jbe     short loc_43C4B5
    mov     ebp, [esp+1Ch+arg_8]
    mov     edx, edi

    loc_43C493:                             ; CODE XREF: sub_43C3A0+107j
    test    eax, eax
    jz      short loc_43C4A3
    mov     ecx, 6
    mov     esi, ebp
    mov     edi, eax
    rep movsd
    movsb

    loc_43C4A3:                             ; CODE XREF: sub_43C3A0+F5j
    add     eax, 19h
    dec     edx
    jnz     short loc_43C493
    mov     esi, [esp+1Ch+arg_0]
    mov     edi, [esp+1Ch+arg_4]
    mov     ebp, [esp+1Ch+var_C]

    loc_43C4B5:                             ; CODE XREF: sub_43C3A0+EBj
    mov     ebp, [ebp+8]
    lea     eax, [edi+edi*4]
    cmp     esi, ebp
    lea     ecx, [eax+eax*4]
    lea     edx, [ebx+ecx]
    jz      short loc_43C4EB
    mov     eax, edx
    sub     eax, ebx
    add     eax, esi
    sub     eax, ecx

    loc_43C4CD:                             ; CODE XREF: sub_43C3A0+145j
    test    edx, edx
    jz      short loc_43C4DD
    mov     ecx, 6
    mov     esi, eax
    mov     edi, edx
    rep movsd
    movsb

    loc_43C4DD:                             ; CODE XREF: sub_43C3A0+12Fj
    add     eax, 19h
    add     edx, 19h
    cmp     eax, ebp
    jnz     short loc_43C4CD
    mov     edi, [esp+1Ch+arg_4]

    loc_43C4EB:                             ; CODE XREF: sub_43C3A0+123j
    mov     ebx, [esp+1Ch+var_C]
    mov     eax, [ebx+4]
    push    eax
    mov     [esp+20h+arg_4], eax
    call    sub_4B4F20
    mov     eax, [esp+20h+var_8]
    mov     esi, [esp+20h+var_4]
    add     esp, 4
    lea     eax, [eax+eax*4]
    lea     edx, [esi+eax*4]
    add     eax, edx
    mov     [ebx+0Ch], eax
    mov     eax, [ebx+4]
    test    eax, eax
    jnz     short loc_43C51D
    xor     edx, edx
    jmp     short loc_43C533
    ; ---------------------------------------------------------------------------

    loc_43C51D:                             ; CODE XREF: sub_43C3A0+177j
    mov     ecx, [ebx+8]
    sub     ecx, eax
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_43C533:                             ; CODE XREF: sub_43C3A0+17Bj
    lea     eax, [edi+edx]
    mov     [ebx+4], esi
    lea     eax, [eax+eax*4]
    lea     ecx, [esi+eax*4]
    add     eax, ecx
    mov     [ebx+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43C54E:                             ; CODE XREF: sub_43C3A0+2Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     ecx, ebx
    sub     ecx, ebp
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, edi
    jnb     loc_43C60C
    lea     eax, [edi+edi*4]
    cmp     ebp, ebx
    lea     ecx, [eax+eax*4]
    mov     [esp+1Ch+arg_0], ecx
    lea     edx, [ebp+ecx+0]
    jz      short loc_43C5A3
    mov     eax, edx
    sub     eax, ecx

    loc_43C585:                             ; CODE XREF: sub_43C3A0+1FDj
    test    edx, edx
    jz      short loc_43C595
    mov     ecx, 6
    mov     esi, eax
    mov     edi, edx
    rep movsd
    movsb

    loc_43C595:                             ; CODE XREF: sub_43C3A0+1E7j
    add     eax, 19h
    add     edx, 19h
    cmp     eax, ebx
    jnz     short loc_43C585
    mov     edi, [esp+1Ch+arg_4]

    loc_43C5A3:                             ; CODE XREF: sub_43C3A0+1DFj
    mov     ecx, [esp+1Ch+var_C]
    mov     eax, 51EB851Fh
    mov     ebx, [esp+1Ch+arg_8]
    mov     esi, [ecx+8]
    mov     ecx, esi
    sub     ecx, ebp
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, esi
    sub     edi, edx
    mov     ecx, edi
    jz      short loc_43C5E3
    mov     edx, ecx

    loc_43C5CD:                             ; CODE XREF: sub_43C3A0+241j
    test    eax, eax
    jz      short loc_43C5DD
    mov     ecx, 6
    mov     esi, ebx
    mov     edi, eax
    rep movsd
    movsb

    loc_43C5DD:                             ; CODE XREF: sub_43C3A0+22Fj
    add     eax, 19h
    dec     edx
    jnz     short loc_43C5CD

    loc_43C5E3:                             ; CODE XREF: sub_43C3A0+229j
    mov     ecx, [esp+1Ch+var_C]
    mov     eax, ebp
    mov     edx, [ecx+8]
    cmp     ebp, edx
    jz      loc_43C690

    loc_43C5F4:                             ; CODE XREF: sub_43C3A0+265j
    mov     ecx, 6
    mov     esi, ebx
    mov     edi, eax
    add     eax, 19h
    rep movsd
    cmp     eax, edx
    movsb
    jnz     short loc_43C5F4
    jmp     loc_43C690
    ; ---------------------------------------------------------------------------

    loc_43C60C:                             ; CODE XREF: sub_43C3A0+1C9j
    test    edi, edi
    jbe     loc_43C69B
    lea     eax, [edi+edi*4]
    mov     edx, ebx
    lea     ecx, [eax+eax*4]
    mov     eax, ebx
    sub     eax, ecx
    mov     [esp+1Ch+arg_0], ecx
    cmp     eax, ebx
    jz      short loc_43C646

    loc_43C628:                             ; CODE XREF: sub_43C3A0+2A0j
    test    edx, edx
    jz      short loc_43C638
    mov     ecx, 6
    mov     esi, eax
    mov     edi, edx
    rep movsd
    movsb

    loc_43C638:                             ; CODE XREF: sub_43C3A0+28Aj
    add     eax, 19h
    add     edx, 19h
    cmp     eax, ebx
    jnz     short loc_43C628
    mov     ecx, [esp+1Ch+arg_0]

    loc_43C646:                             ; CODE XREF: sub_43C3A0+286j
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [eax+8]
    mov     eax, edx
    sub     eax, ecx
    cmp     ebp, eax
    jz      short loc_43C66B

    loc_43C655:                             ; CODE XREF: sub_43C3A0+2C9j
    sub     eax, 19h
    sub     edx, 19h
    mov     ecx, 6
    mov     esi, eax
    mov     edi, edx
    cmp     eax, ebp
    rep movsd
    movsb
    jnz     short loc_43C655

    loc_43C66B:                             ; CODE XREF: sub_43C3A0+2B3j
    mov     ecx, [esp+1Ch+arg_0]
    mov     eax, ebp
    lea     edx, [ebp+ecx+0]
    cmp     ebp, edx
    jz      short loc_43C690
    mov     ebx, [esp+1Ch+arg_8]

    loc_43C67D:                             ; CODE XREF: sub_43C3A0+2EEj
    mov     ecx, 6
    mov     esi, ebx
    mov     edi, eax
    add     eax, 19h
    rep movsd
    cmp     eax, edx
    movsb
    jnz     short loc_43C67D

    loc_43C690:                             ; CODE XREF: sub_43C3A0+24Ej
                                            ; sub_43C3A0+267j ...
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]
    add     [eax+8], edx

    loc_43C69B:                             ; CODE XREF: sub_43C3A0+26Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_43C3A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43C6B0 proc near                    ; CODE XREF: sub_43A420+F3p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     ecx, [esp+arg_4]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_0]
    sub     ecx, ebp
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ebx, edx
    test    ebx, ebx
    jle     short loc_43C70D
    push    edi
    push    esi

    loc_43C6D5:                             ; CODE XREF: sub_43C6B0+59j
    mov     eax, ebx
    cdq
    sub     eax, edx
    mov     edx, [esp+10h+arg_8]
    mov     esi, eax
    sar     esi, 1
    lea     eax, [esi+esi*4]
    lea     ecx, [ebp+eax*4+0]
    add     eax, ecx
    mov     edi, eax
    mov     eax, [edx]
    push    eax
    push    edi
    call    [esp+18h+arg_C]
    test    eax, eax
    jz      short loc_43C705
    or      ecx, 0FFFFFFFFh
    lea     ebp, [edi+19h]
    sub     ecx, esi
    add     ebx, ecx
    jmp     short loc_43C707
    ; ---------------------------------------------------------------------------

    loc_43C705:                             ; CODE XREF: sub_43C6B0+47j
    mov     ebx, esi

    loc_43C707:                             ; CODE XREF: sub_43C6B0+53j
    test    ebx, ebx
    jg      short loc_43C6D5
    pop     esi
    pop     edi

    loc_43C70D:                             ; CODE XREF: sub_43C6B0+21j
    mov     eax, ebp
    pop     ebp
    pop     ebx
    retn    14h
    sub_43C6B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43C720 proc near                    ; CODE XREF: sub_43BC90+230p
                                            ; sub_43BC90+23Bp ...

    var_C0= dword ptr -0C0h
    var_B8= dword ptr -0B8h
    var_B0= dword ptr -0B0h
    var_A8= dword ptr -0A8h
    var_A4= dword ptr -0A4h
    var_9C= dword ptr -9Ch
    var_94= dword ptr -94h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0A8h
    mov     eax, 51EB851Fh
    push    ebx
    mov     ebx, [esp+0ACh+arg_0]
    push    ebp
    mov     ebp, [esp+0B0h+arg_4]
    mov     ecx, ebp
    sub     ecx, ebx
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, edx
    cmp     eax, 10h
    jle     loc_43C92B
    push    edi
    push    esi
    jmp     short loc_43C768
    ; ---------------------------------------------------------------------------

    loc_43C75A:                             ; CODE XREF: sub_43C720+203j
    mov     ebp, [esp+0B8h+arg_4]
    mov     ebx, [esp+0B8h+arg_0]

    loc_43C768:                             ; CODE XREF: sub_43C720+38j
    lea     esi, [ebp-19h]
    mov     ecx, 6
    lea     edi, [esp+0B8h+var_A8]
    rep movsd
    cdq
    sub     eax, edx
    lea     edx, [esp+0B8h+var_8C]
    sar     eax, 1
    movsb
    lea     esi, [eax+eax*4]
    lea     edi, [esp+0B8h+var_8C]
    lea     eax, [esp+0B8h+var_70]
    push    edx
    lea     ecx, [ebx+esi*4]
    push    eax
    add     esi, ecx
    mov     ecx, 6
    rep movsd
    movsb
    mov     ecx, 6
    mov     esi, ebx
    lea     edi, [esp+0C0h+var_70]
    rep movsd
    movsb
    mov     esi, [esp+0C0h+arg_8]
    call    esi
    test    eax, eax
    jz      short loc_43C7DF
    lea     ecx, [esp+0B8h+var_A8]
    lea     edx, [esp+0B8h+var_8C]
    push    ecx
    push    edx
    call    esi
    test    eax, eax
    jnz     short loc_43C809
    lea     eax, [esp+0B8h+var_A8]
    lea     ecx, [esp+0B8h+var_70]
    push    eax
    push    ecx
    call    esi
    test    eax, eax
    lea     esi, [esp+0B8h+var_A8]
    jnz     short loc_43C80D
    lea     esi, [esp+0B8h+var_70]
    jmp     short loc_43C80D
    ; ---------------------------------------------------------------------------

    loc_43C7DF:                             ; CODE XREF: sub_43C720+93j
    lea     edx, [esp+0B8h+var_A8]
    lea     eax, [esp+0B8h+var_70]
    push    edx
    push    eax
    call    esi
    test    eax, eax
    jz      short loc_43C7F5
    lea     esi, [esp+0B8h+var_70]
    jmp     short loc_43C80D
    ; ---------------------------------------------------------------------------

    loc_43C7F5:                             ; CODE XREF: sub_43C720+CDj
    lea     ecx, [esp+0B8h+var_A8]
    lea     edx, [esp+0B8h+var_8C]
    push    ecx
    push    edx
    call    esi
    test    eax, eax
    lea     esi, [esp+0B8h+var_A8]
    jnz     short loc_43C80D

    loc_43C809:                             ; CODE XREF: sub_43C720+A3j
    lea     esi, [esp+0B8h+var_8C]

    loc_43C80D:                             ; CODE XREF: sub_43C720+B7j
                                            ; sub_43C720+BDj ...
    mov     ecx, 6
    lea     edi, [esp+80h]
    rep movsd
    movsb
    mov     ecx, 6
    lea     esi, [esp+80h]
    lea     edi, [esp+0B8h+var_54]
    rep movsd
    movsb

    loc_43C82F:                             ; CODE XREF: sub_43C720+184j
    mov     esi, [esp+0B8h+arg_8]
    lea     eax, [esp+0B8h+var_54]
    push    eax
    push    ebx
    call    esi
    test    eax, eax
    jz      short loc_43C851

    loc_43C842:                             ; CODE XREF: sub_43C720+12Fj
    lea     ecx, [esp+0B8h+var_54]
    add     ebx, 19h
    push    ecx
    push    ebx
    call    esi
    test    eax, eax
    jnz     short loc_43C842

    loc_43C851:                             ; CODE XREF: sub_43C720+120j
    sub     ebp, 19h
    lea     edx, [esp+0B8h+var_54]
    push    ebp
    push    edx
    call    esi
    test    eax, eax
    jz      short loc_43C86F

    loc_43C860:                             ; CODE XREF: sub_43C720+14Dj
    sub     ebp, 19h
    lea     eax, [esp+0B8h+var_54]
    push    ebp
    push    eax
    call    esi
    test    eax, eax
    jnz     short loc_43C860

    loc_43C86F:                             ; CODE XREF: sub_43C720+13Ej
    cmp     ebp, ebx
    jbe     short loc_43C8A6
    mov     ecx, 6
    mov     esi, ebx
    lea     edi, [esp+9Ch]
    rep movsd
    movsb
    mov     ecx, 6
    mov     esi, ebp
    mov     edi, ebx
    add     ebx, 19h
    rep movsd
    movsb
    mov     ecx, 6
    lea     esi, [esp+9Ch]
    mov     edi, ebp
    rep movsd
    movsb
    jmp     short loc_43C82F
    ; ---------------------------------------------------------------------------

    loc_43C8A6:                             ; CODE XREF: sub_43C720+151j
    mov     ebp, [esp+0B8h+arg_4]
    mov     eax, 51EB851Fh
    mov     ecx, ebp
    mov     edi, [esp+0B8h+arg_0]
    sub     ecx, ebx
    push    0
    imul    ecx
    mov     ecx, edx
    mov     eax, 51EB851Fh
    sar     ecx, 3
    mov     edx, ecx
    push    esi
    shr     edx, 1Fh
    add     ecx, edx
    mov     edx, ebx
    sub     edx, edi
    imul    edx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     ecx, edx
    jg      short loc_43C8F9
    push    ebp
    push    ebx
    call    sub_43C720
    mov     ebp, ebx
    mov     [esp+0B8h+arg_4], ebx
    jmp     short loc_43C909
    ; ---------------------------------------------------------------------------

    loc_43C8F9:                             ; CODE XREF: sub_43C720+1C5j
    push    ebx
    push    edi
    call    sub_43C720
    mov     edi, ebx
    mov     [esp+0B8h+arg_0], ebx

    loc_43C909:                             ; CODE XREF: sub_43C720+1D7j
    mov     ecx, ebp
    mov     eax, 51EB851Fh
    sub     ecx, edi
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     eax, edx
    cmp     eax, 10h
    jg      loc_43C75A
    pop     esi
    pop     edi

    loc_43C92B:                             ; CODE XREF: sub_43C720+30j
    pop     ebp
    pop     ebx
    add     esp, 0A8h
    retn    10h
    sub_43C720 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43C940 proc near                    ; CODE XREF: sub_43BC90+2C8p

    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_20= dword ptr  28h

    push    ebx
    push    ebp
    push    esi
    mov     ebp, [esp+8+arg_20]
    push    edi
    mov     edi, [esp+0Ch+arg_0]
    lea     eax, [esp+0Ch+arg_4]
    lea     ebx, [edi-19h]
    push    ebx
    push    eax
    call    ebp
    test    eax, eax
    jz      short loc_43C976

    loc_43C95B:                             ; CODE XREF: sub_43C940+34j
    mov     ecx, 6
    mov     esi, ebx
    rep movsd
    movsb
    mov     edi, ebx
    sub     ebx, 19h
    lea     ecx, [esp+0Ch+arg_4]
    push    ebx
    push    ecx
    call    ebp
    test    eax, eax
    jnz     short loc_43C95B

    loc_43C976:                             ; CODE XREF: sub_43C940+19j
    mov     ecx, 6
    lea     esi, [esp+0Ch+arg_4]
    rep movsd
    movsb
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    24h
    sub_43C940 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43C990 proc near                    ; CODE XREF: sub_43BC90+15Fp
                                            ; sub_43C050+151p ...

    var_50= dword ptr -50h
    var_48= dword ptr -48h
    var_40= dword ptr -40h
    var_24= dword ptr -24h
    var_1C= dword ptr -1Ch
    var_14= dword ptr -14h
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    sub     esp, 38h
    push    ebx
    mov     ebx, [esp+3Ch+arg_0]
    cmp     ebx, eax
    push    ebp
    jz      loc_43CA59
    lea     ebp, [ebx+19h]
    cmp     ebp, eax
    jz      loc_43CA59
    push    edi
    push    esi

    loc_43C9B2:                             ; CODE XREF: sub_43C990+C1j
    mov     ecx, 6
    mov     esi, ebp
    lea     edi, [esp+48h+var_1C]
    lea     eax, [esp+48h+var_1C]
    rep movsd
    push    ebx
    push    eax
    movsb
    call    [esp+50h+arg_8]
    test    eax, eax
    jnz     short loc_43CA20
    mov     ecx, 6
    lea     esi, [esp+48h+var_1C]
    lea     edi, [esp+10h]
    lea     ebx, [ebp-19h]
    rep movsd
    lea     ecx, [esp+10h]
    push    ebx
    movsb
    push    ecx
    mov     edi, ebp
    call    [esp+50h+arg_8]
    test    eax, eax
    jz      short loc_43CA0E

    loc_43C9F1:                             ; CODE XREF: sub_43C990+7Cj
    mov     ecx, 6
    mov     esi, ebx
    rep movsd
    movsb
    mov     edi, ebx
    sub     ebx, 19h
    lea     edx, [esp+50h+var_40]
    push    ebx
    push    edx
    call    [esp+58h+arg_0]
    test    eax, eax
    jnz     short loc_43C9F1

    loc_43CA0E:                             ; CODE XREF: sub_43C990+5Fj
    mov     ecx, 6
    lea     esi, [esp+58h+var_48]
    rep movsd
    mov     ebx, [esp+4Ch]
    movsb
    jmp     short loc_43CA48
    ; ---------------------------------------------------------------------------

    loc_43CA20:                             ; CODE XREF: sub_43C990+3Cj
    cmp     ebx, ebp
    mov     eax, ebp
    jz      short loc_43CA3A

    loc_43CA26:                             ; CODE XREF: sub_43C990+A8j
    sub     eax, 19h
    mov     ecx, 6
    mov     esi, eax
    cmp     eax, ebx
    lea     edi, [eax+19h]
    rep movsd
    movsb
    jnz     short loc_43CA26

    loc_43CA3A:                             ; CODE XREF: sub_43C990+94j
    mov     ecx, 6
    lea     esi, [esp+48h+var_1C]
    mov     edi, ebx
    rep movsd
    movsb

    loc_43CA48:                             ; CODE XREF: sub_43C990+8Ej
    mov     eax, [esp+48h+arg_4]
    add     ebp, 19h
    cmp     ebp, eax
    jnz     loc_43C9B2
    pop     esi
    pop     edi

    loc_43CA59:                             ; CODE XREF: sub_43C990+Fj
                                            ; sub_43C990+1Aj
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    10h
    sub_43C990 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43CA70 proc near                    ; CODE XREF: sub_43BC90+1DAp
                                            ; sub_43C050+1BCp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_10= dword ptr  18h
    arg_18= dword ptr  20h
    arg_20= dword ptr  28h
    arg_24= dword ptr  2Ch
    arg_2C= dword ptr  34h
    arg_34= dword ptr  3Ch
    arg_58= dword ptr  60h

    push    esi
    mov     esi, [esp+arg_58]
    lea     eax, [esp+arg_20]
    push    edi
    lea     ecx, [esp+4+arg_4]
    push    eax
    push    ecx
    call    esi
    test    eax, eax
    jz      short loc_43CAC1
    lea     edx, [esp+48h]
    lea     eax, [esp+4+arg_20]
    push    edx
    push    eax
    call    esi
    test    eax, eax
    jnz     short loc_43CAFC
    lea     ecx, [esp+48h]
    lea     edx, [esp+4+arg_4]
    push    ecx
    push    edx
    call    esi
    test    eax, eax
    lea     esi, [esp+48h]
    jnz     short loc_43CB00
    mov     eax, [esp+0Ch]
    lea     esi, [esp+4+arg_4]
    mov     ecx, 6
    mov     edi, eax
    rep movsd
    movsb
    pop     edi
    pop     esi
    retn    5Ch
    ; ---------------------------------------------------------------------------

    loc_43CAC1:                             ; CODE XREF: sub_43CA70+14j
    lea     eax, [esp+48h]
    lea     ecx, [esp+4+arg_4]
    push    eax
    push    ecx
    call    esi
    test    eax, eax
    jz      short loc_43CAE8
    mov     eax, [esp+0Ch]
    lea     esi, [esp+4+arg_4]
    mov     ecx, 6
    mov     edi, eax
    rep movsd
    movsb
    pop     edi
    pop     esi
    retn    5Ch
    ; ---------------------------------------------------------------------------

    loc_43CAE8:                             ; CODE XREF: sub_43CA70+5Fj
    lea     edx, [esp+48h]
    lea     eax, [esp+4+arg_20]
    push    edx
    push    eax
    call    esi
    test    eax, eax
    lea     esi, [esp+48h]
    jnz     short loc_43CB00

    loc_43CAFC:                             ; CODE XREF: sub_43CA70+24j
    lea     esi, [esp+4+arg_20]

    loc_43CB00:                             ; CODE XREF: sub_43CA70+38j
                                            ; sub_43CA70+8Aj
    mov     eax, [esp+0Ch]
    mov     ecx, 6
    mov     edi, eax
    rep movsd
    movsb
    pop     edi
    pop     esi
    retn    5Ch
    sub_43CA70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43CB20 proc near                    ; CODE XREF: sub_43BC90+1F0p
                                            ; sub_43C050+1D2p

    var_3C= dword ptr -3Ch
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_24= dword ptr  28h

    sub     esp, 1Ch
    push    ebx
    mov     ebx, [esp+20h+arg_4]
    push    ebp
    mov     ebp, [esp+24h+arg_0]
    push    esi
    push    edi

    loc_43CB2F:                             ; CODE XREF: sub_43CB20+7Bj
    mov     esi, [esp+2Ch+arg_24]
    lea     eax, [esp+2Ch+arg_8]
    push    eax
    push    ebp
    call    esi
    test    eax, eax
    jz      short loc_43CB4E

    loc_43CB3F:                             ; CODE XREF: sub_43CB20+2Cj
    lea     ecx, [esp+2Ch+arg_8]
    add     ebp, 19h
    push    ecx
    push    ebp
    call    esi
    test    eax, eax
    jnz     short loc_43CB3F

    loc_43CB4E:                             ; CODE XREF: sub_43CB20+1Dj
    sub     ebx, 19h
    lea     edx, [esp+2Ch+arg_8]
    push    ebx
    push    edx
    call    esi
    test    eax, eax
    jz      short loc_43CB6C

    loc_43CB5D:                             ; CODE XREF: sub_43CB20+4Aj
    sub     ebx, 19h
    lea     eax, [esp+2Ch+arg_8]
    push    ebx
    push    eax
    call    esi
    test    eax, eax
    jnz     short loc_43CB5D

    loc_43CB6C:                             ; CODE XREF: sub_43CB20+3Bj
    cmp     ebx, ebp
    jbe     short loc_43CB9D
    mov     ecx, 6
    mov     esi, ebp
    lea     edi, [esp+10h]
    rep movsd
    movsb
    mov     ecx, 6
    mov     esi, ebx
    mov     edi, ebp
    add     ebp, 19h
    rep movsd
    movsb
    mov     ecx, 6
    lea     esi, [esp+10h]
    mov     edi, ebx
    rep movsd
    movsb
    jmp     short loc_43CB2F
    ; ---------------------------------------------------------------------------

    loc_43CB9D:                             ; CODE XREF: sub_43CB20+4Ej
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    28h
    sub_43CB20 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    mov     bx, [esp+0Ch]
    test    bx, bx
    jz      short loc_43CC13
    push    edi
    mov     edi, [esp+0Ch]
    push    esi
    mov     eax, [edi+92h]
    movsx   esi, bx
    mov     dx, [eax+1BAh]
    mov     eax, edx
    and     eax, 0FFFFh
    cmp     esi, eax
    jl      short loc_43CBE2
    mov     [ecx+24h], dx
    jmp     short loc_43CBF4
    ; ---------------------------------------------------------------------------

    loc_43CBE2:                             ; CODE XREF: .text:0043CBDAj
    neg     eax
    cmp     esi, eax
    jg      short loc_43CBF0
    neg     edx
    mov     [ecx+24h], dx
    jmp     short loc_43CBF4
    ; ---------------------------------------------------------------------------

    loc_43CBF0:                             ; CODE XREF: .text:0043CBE6j
    mov     [ecx+24h], bx

    loc_43CBF4:                             ; CODE XREF: .text:0043CBE0j
                                            ; .text:0043CBEEj
    mov     cx, [ecx+24h]
    mov     eax, [edi+110h]
    add     [edi+66h], cx
    or      eax, 10000h
    mov     [edi+110h], eax
    pop     esi
    pop     edi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_43CC13:                             ; CODE XREF: .text:0043CBB9j
    mov     word ptr [ecx+24h], 0
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43CC20 proc near                    ; CODE XREF: sub_43CD20+32p
                                            ; sub_43CD20+3A0p

    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    mov     eax, [esp+0Ch+arg_4]
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     ecx, [ebp+20h]
    add     ecx, eax
    mov     eax, ecx
    mov     [ebp+20h], ecx
    test    eax, eax
    jge     short loc_43CC42
    mov     dword ptr [ebp+20h], 0

    loc_43CC42:                             ; CODE XREF: sub_43CC20+19j
    mov     esi, [esp+1Ch+arg_0]
    movsx   eax, word ptr [esi+68h]
    sar     eax, 0Bh
    cmp     eax, 0FFFFFFFBh
    jge     short loc_43CC57
    mov     eax, 0FFFFFFFBh

    loc_43CC57:                             ; CODE XREF: sub_43CC20+30j
    cmp     eax, 5
    jle     short loc_43CC61
    mov     eax, 5

    loc_43CC61:                             ; CODE XREF: sub_43CC20+3Aj
    movsx   eax, byte_505205[eax]
    mov     edi, [esi+92h]
    mov     ecx, 10h
    shl     eax, 10h
    imul    dword ptr [edi+192h]
    call    __allshr
    cdq
    mov     ecx, 10h
    call    __allshl
    push    0
    push    640000h
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, TAdynmemStructPtr
    movzx   dx, byte ptr [ecx+1427Fh]
    cmp     [esi+70h], dx
    jge     short loc_43CCD3
    test    dword ptr [edi+241h], 81000h
    jnz     short loc_43CCD3
    cdq
    push    0
    push    8000h
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr

    loc_43CCD3:                             ; CODE XREF: sub_43CC20+8Cj
                                            ; sub_43CC20+98j
    cmp     [ebp+20h], eax
    jle     short loc_43CCDB
    mov     [ebp+20h], eax

    loc_43CCDB:                             ; CODE XREF: sub_43CC20+B6j
    mov     edi, [ebp+20h]
    mov     bx, [esi+66h]
    push    edi
    push    ebx
    call    sub_4B70EF
    add     esp, 8
    mov     esi, eax
    neg     esi
    push    edi
    push    ebx
    mov     [esp+24h+var_8], 0
    call    sub_4B7123
    mov     ecx, [esp+24h+var_8]
    add     esp, 8
    neg     eax
    add     ebp, 8
    pop     edi
    mov     [ebp+0], esi
    pop     esi
    mov     [ebp+4], ecx
    mov     [ebp+8], eax
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_43CC20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43CD20 proc near                    ; CODE XREF: sub_43DD20+2Dp

    var_70= qword ptr -70h
    var_68= qword ptr -68h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 44h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     [esp+54h+var_44], esi
    mov     ecx, [esi]
    mov     eax, [ecx]
    call    dword ptr [eax+14h]
    test    eax, eax
    jnz     short loc_43CD61
    mov     ecx, [esp+54h+arg_0]
    mov     [esi+24h], ax
    mov     edx, [ecx+92h]
    mov     eax, [edx+19Ah]
    neg     eax
    push    eax
    push    ecx
    mov     ecx, esi
    call    sub_43CC20
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43CD61:                             ; CODE XREF: sub_43CD20+16j
    mov     ecx, [esi]
    push    3
    lea     edx, [esp+58h+var_24]
    push    0
    mov     eax, [ecx]
    push    edx
    call    dword ptr [eax+0Ch]
    mov     edi, [esp+54h+arg_0]
    mov     eax, [esp+54h+var_18]
    sub     esp, 8
    mov     ecx, [edi+6Ah]
    lea     ebx, [edi+6Ah]
    sub     eax, ecx
    mov     ecx, [esp+5Ch+var_10]
    mov     [esp+5Ch+var_30], eax
    mov     eax, [ebx+8]
    sub     ecx, eax
    sub     esp, 8
    mov     [esp+64h+var_28], ecx
    fild    [esp+64h+var_28]
    fstp    qword ptr [esp+8]
    fild    [esp+64h+var_30]
    fstp    [esp+64h+var_68+4]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, offset aMultibyte          ; "MultiByte"
    mov     [esp+54h+var_38], eax
    jle     loc_43CEB4
    mov     eax, [esp+54h+var_18]
    mov     edx, [esp+54h+var_24]
    mov     ecx, [esp+54h+var_1C]
    sub     eax, edx
    mov     [esp+54h+arg_0], eax
    mov     eax, [esp+54h+var_10]
    sub     eax, ecx
    sub     esp, 8
    mov     [esp+5Ch+var_40], eax
    sub     esp, 8
    fild    [esp+64h+var_40]
    fstp    qword ptr [esp+8]
    fild    [esp+64h+arg_0]
    fstp    [esp+64h+var_68+4]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cmp     eax, 10000h
    mov     [esp+54h+var_30], eax
    jl      loc_43CEB4
    cdq
    mov     esi, eax
    mov     eax, [esp+54h+arg_0]
    mov     ebp, edx
    mov     ecx, 10h
    cdq
    call    __allshl
    push    ebp
    push    esi
    push    edx
    push    eax
    call    __alldiv
    mov     [esp+54h+arg_0], eax
    mov     eax, [esp+54h+var_40]
    cdq
    mov     ecx, 10h
    call    __allshl
    push    ebp
    push    esi
    push    edx
    push    eax
    call    __alldiv
    mov     edx, [esp+54h+var_38]
    mov     ecx, [esp+54h+var_30]
    mov     [esp+54h+var_40], eax
    lea     eax, [edx-500000h]
    cmp     eax, ecx
    jle     short loc_43CE61
    mov     eax, ecx

    loc_43CE61:                             ; CODE XREF: sub_43CD20+13Dj
    cdq
    mov     ebp, eax
    mov     eax, [esp+54h+arg_0]
    mov     ecx, edx
    cdq
    push    ecx
    push    ebp
    push    edx
    push    eax
    mov     [esp+38h], ecx
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     esi, [esp+54h+var_18]
    mov     ecx, [esp+28h]
    sub     esi, eax
    mov     eax, [esp+54h+var_40]
    cdq
    push    ecx
    push    ebp
    push    edx
    push    eax
    mov     [esp+64h+var_18], esi
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ecx, [esp+54h+var_10]
    sub     ecx, eax
    mov     [esp+54h+var_10], ecx
    jmp     short loc_43CEBC
    ; ---------------------------------------------------------------------------

    loc_43CEB4:                             ; CODE XREF: sub_43CD20+9Dj
                                            ; sub_43CD20+EAj
    mov     ecx, [esp+54h+var_10]
    mov     esi, [esp+54h+var_18]

    loc_43CEBC:                             ; CODE XREF: sub_43CD20+192j
    sub     ecx, [edi+72h]
    mov     [esp+54h+arg_0], ecx
    mov     ecx, [ebx]
    sub     esi, ecx
    mov     eax, esi
    cdq
    mov     ebp, eax
    mov     eax, [esp+54h+arg_0]
    mov     ecx, edx
    push    ecx
    push    ebp
    cdq
    push    ecx
    push    ebp
    mov     esi, eax
    mov     [esp+38h], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ebp, eax
    mov     eax, [esp+28h]
    push    eax
    push    esi
    push    eax
    push    esi
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    lea     edx, [esp+54h+var_18]
    add     ebp, eax
    push    edx
    push    ebx
    call    sub_48A980
    sub     ax, [edi+66h]
    mov     ecx, [esp+50h]
    mov     [esp+54h+arg_0], eax
    movsx   eax, ax
    mov     [esp+54h+var_30], eax
    cdq
    mov     esi, eax
    mov     eax, [edi+72h]
    xor     esi, edx
    sub     ecx, eax
    mov     eax, [esp+48h]
    sub     esi, edx
    sub     eax, [ebx]
    cdq
    mov     ebx, eax
    mov     eax, ecx
    mov     [esp+54h+var_3C], edx
    cdq
    mov     [esp+54h+var_38], eax
    mov     eax, [esp+54h+var_3C]
    push    eax
    push    ebx
    push    eax
    push    ebx
    mov     [esp+64h+var_34], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ecx, [esp+54h+var_34]
    mov     ebx, eax
    mov     eax, [esp+54h+var_38]
    push    ecx
    push    eax
    push    ecx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     ebx, eax
    mov     eax, [esp+54h+arg_0]
    test    ax, ax
    mov     [esp+54h+var_38], ebx
    jz      short loc_43CFEC
    mov     ecx, [edi+92h]
    mov     ebx, [esp+54h+var_30]
    mov     dx, [ecx+1BAh]
    mov     ecx, edx
    and     ecx, 0FFFFh
    cmp     ebx, ecx
    jl      short loc_43CFB3
    mov     eax, [esp+54h+var_44]
    mov     [eax+24h], dx
    jmp     short loc_43CFCD
    ; ---------------------------------------------------------------------------

    loc_43CFB3:                             ; CODE XREF: sub_43CD20+287j
    neg     ecx
    cmp     ebx, ecx
    jg      short loc_43CFC5
    mov     ecx, [esp+54h+var_44]
    neg     edx
    mov     [ecx+24h], dx
    jmp     short loc_43CFCD
    ; ---------------------------------------------------------------------------

    loc_43CFC5:                             ; CODE XREF: sub_43CD20+297j
    mov     edx, [esp+54h+var_44]
    mov     [edx+24h], ax

    loc_43CFCD:                             ; CODE XREF: sub_43CD20+291j
                                            ; sub_43CD20+2A3j
    mov     eax, [esp+54h+var_44]
    mov     cx, [eax+24h]
    mov     eax, [edi+110h]
    add     [edi+66h], cx
    or      eax, 10000h
    mov     [edi+110h], eax
    jmp     short loc_43CFF6
    ; ---------------------------------------------------------------------------

    loc_43CFEC:                             ; CODE XREF: sub_43CD20+26Aj
    mov     edx, [esp+54h+var_44]
    mov     word ptr [edx+24h], 0

    loc_43CFF6:                             ; CODE XREF: sub_43CD20+2CAj
    mov     eax, [esp+54h+var_44]
    mov     ebx, [edi+92h]
    mov     ecx, [eax+20h]
    mov     eax, esi
    and     eax, 0FFFFh
    mov     [esp+54h+arg_0], ecx
    imul    ecx
    mov     ecx, eax
    xor     eax, eax
    mov     ax, [ebx+1BAh]
    mov     esi, edx
    cdq
    push    edx
    push    eax
    push    esi
    push    ecx
    call    __alldiv
    mov     [esp+54h+var_30], eax
    mov     eax, [esp+54h+arg_0]
    mov     esi, [ebx+19Ah]
    cdq
    push    edx
    push    eax
    push    edx
    push    eax
    mov     [esp+64h+var_40], esi
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    cdq
    mov     ecx, 10h
    call    __allshl
    mov     ecx, eax
    lea     eax, [esi+esi]
    mov     [esp+54h+arg_0], ecx
    mov     ecx, edx
    cdq
    push    edx
    mov     edx, [esp+58h+arg_0]
    push    eax
    push    ecx
    push    edx
    call    __alldiv
    cdq
    push    edx
    push    eax
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     esi, eax
    mov     eax, [esp+54h+var_30]
    cdq
    push    edx
    push    eax
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    shl     eax, 2
    cmp     ebp, eax
    jle     short loc_43D0B4
    cmp     [esp+54h+var_38], esi
    jle     short loc_43D0B4
    mov     eax, [ebx+19Eh]
    jmp     short loc_43D0BA
    ; ---------------------------------------------------------------------------

    loc_43D0B4:                             ; CODE XREF: sub_43CD20+384j
                                            ; sub_43CD20+38Aj
    mov     eax, [esp+54h+var_40]
    neg     eax

    loc_43D0BA:                             ; CODE XREF: sub_43CD20+392j
    mov     ecx, [esp+54h+var_44]
    push    eax
    push    edi
    call    sub_43CC20
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    4
    sub_43CD20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43D0D0 proc near                    ; CODE XREF: sub_43D210+4Bp
                                            ; sub_43D290+423p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 8
    push    esi
    mov     esi, ecx
    push    edi
    push    0
    mov     eax, [esi+14h]
    push    0F333h
    cdq
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esi+14h], eax
    mov     eax, [esi+18h]
    cdq
    push    0
    push    0F333h
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esi+18h], eax
    mov     eax, [esi+1Ch]
    cdq
    push    0
    push    0F333h
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esi+1Ch], eax
    mov     eax, [esp+10h+arg_4]
    mov     edx, [esi+14h]
    mov     edi, [esi+1Ch]
    mov     ecx, [eax]
    add     edx, ecx
    mov     ecx, [esi+18h]
    mov     [esi+14h], edx
    mov     edx, [eax+4]
    add     ecx, edx
    mov     [esi+18h], ecx
    mov     eax, [eax+8]
    add     edi, eax
    lea     eax, [esp+10h+var_8]
    mov     [esi+1Ch], edi
    mov     ecx, [esi+14h]
    mov     esi, [esp+10h+arg_0]
    mov     [esp+10h+var_8], ecx
    mov     edx, edi
    push    eax
    mov     cx, [esi+66h]
    mov     [esp+14h+var_4], edx
    push    ecx
    call    sub_4B7173
    mov     edx, TAdynmemStructPtr
    add     esp, 8
    mov     ecx, 10h
    mov     eax, [edx+14263h]
    cdq
    call    __allshl
    push    0
    push    0CCDh
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, [esp+10h+var_8]
    mov     edi, eax
    mov     eax, [esi+92h]
    push    edi
    neg     ecx
    mov     eax, [eax+1A2h]
    imul    ecx
    mov     ecx, 10h
    call    __allshr
    push    eax
    call    sub_4B715A
    add     esp, 8
    mov     [esi+64h], ax
    push    edi
    mov     edx, [esi+92h]
    mov     ecx, [esp+14h+var_8]
    neg     ecx
    mov     eax, [edx+1A6h]
    imul    ecx
    mov     ecx, 10h
    call    __allshr
    push    eax
    call    sub_4B715A
    add     esp, 8
    mov     [esi+68h], ax
    pop     edi
    pop     esi
    add     esp, 8
    retn    8
    sub_43D0D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43D210 proc near                    ; CODE XREF: GameUnit_EndTransport+3Fp
                                            ; GameUnit_EndTransport+1EFp ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    push    ebx
    mov     ebx, [esp+10h+arg_4]
    push    esi
    mov     esi, ecx
    mov     al, [esi+2Eh]
    and     eax, 3
    cmp     eax, ebx
    jz      short loc_43D287
    cmp     ebx, 1
    jnz     short loc_43D26D
    push    edi
    lea     edi, [esi+8]
    xor     eax, eax
    xor     ecx, ecx
    mov     [edi], eax
    xor     edx, edx
    mov     [esp+18h+var_8], ecx
    mov     dword ptr [esi+20h], 0
    mov     [edi+4], ecx
    lea     ecx, [esp+18h+var_C]
    push    ecx
    mov     ecx, esi
    mov     [edi+8], edx
    mov     edi, [esp+1Ch+arg_0]
    push    edi
    mov     [esp+20h+var_C], eax
    mov     [esp+20h+var_4], edx
    call    sub_43D0D0
    push    0                               ; int
    push    ebx                             ; idTo
    mov     ecx, edi
    call    sub_48B090
    pop     edi
    jmp     short loc_43D27A
    ; ---------------------------------------------------------------------------

    loc_43D26D:                             ; CODE XREF: sub_43D210+18j
    mov     ecx, [esp+14h+arg_0]
    push    1                               ; int
    push    1                               ; idTo
    call    sub_48B090

    loc_43D27A:                             ; CODE XREF: sub_43D210+5Bj
    mov     al, [esi+2Eh]
    xor     bl, al
    and     bl, 3
    xor     bl, al
    mov     [esi+2Eh], bl

    loc_43D287:                             ; CODE XREF: sub_43D210+13j
    pop     esi
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_43D210 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43D290 proc near                    ; CODE XREF: sub_43DD20+26p

    var_74= qword ptr -74h
    var_6C= qword ptr -6Ch
    var_52= word ptr -52h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_46= dword ptr -46h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8

    sub     esp, 48h
    push    esi
    push    edi
    mov     edi, ecx
    mov     al, [edi+2Eh]
    and     al, 3
    cmp     al, 2
    jz      short loc_43D2C0
    lea     esi, [edi+8]
    xor     eax, eax
    xor     ecx, ecx
    xor     edx, edx
    mov     [esi], eax
    mov     [edi+20h], eax
    mov     [edi+24h], ax
    mov     [esi+4], ecx
    mov     [esi+8], edx
    pop     edi
    pop     esi
    add     esp, 48h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43D2C0:                             ; CODE XREF: sub_43D290+Ej
    lea     esi, [edi+8]
    push    ebp
    mov     ecx, esi
    push    ebx
    mov     edx, [ecx]
    mov     [esp+58h+var_30], edx
    mov     eax, [ecx+4]
    mov     [esp+58h+var_2C], eax
    lea     eax, [esp+58h+var_46]
    mov     ecx, [ecx+8]
    push    eax
    mov     [esp+5Ch+var_28], ecx
    mov     ecx, [edi]
    lea     eax, [esp+5Ch+var_C]
    mov     edx, [ecx]
    push    eax
    lea     eax, [esp+60h+var_24]
    push    eax
    call    dword ptr [edx+10h]
    mov     ecx, [esp+64h+var_8]
    mov     eax, [ecx+92h]
    mov     ecx, [eax+19Eh]
    mov     eax, [eax+192h]
    mov     [esp+64h+var_4C], ecx
    fild    [esp+64h+var_4C]
    cdq
    fmul    ds:flt_4FD2D0
    mov     ebx, eax
    mov     eax, ecx
    mov     ebp, edx
    mov     ecx, 10h
    cdq
    fstp    [esp+64h+var_4C]
    call    __allshl
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, 10000h
    sub     ecx, eax
    mov     eax, ecx
    cdq
    mov     ebx, eax
    mov     eax, [esi]
    mov     ebp, edx
    cdq
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esi], eax
    mov     eax, [esi+4]
    cdq
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esi+4], eax
    mov     eax, [esi+8]
    cdq
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esi+8], eax
    sub     esp, 8
    fild    dword ptr [edi+10h]
    sub     esp, 8
    fstp    [esp+74h+var_6C]
    fild    dword ptr [esi]
    fstp    [esp+74h+var_74]
    call    __hypot
    fmul    ds:flt_4FD2D0
    mov     ebx, [esp+74h+var_8]
    add     esp, 10h
    mov     edx, [ebx+92h]
    fstp    [esp+64h+var_50]
    fild    dword ptr [edx+19Ah]
    fmul    ds:flt_4FD2D0
    fstp    [esp+64h+var_8]
    fld     [esp+64h+var_50]
    fcomp   [esp+64h+var_8]
    fnstsw  ax
    test    ah, 41h
    jnz     loc_43D480
    fld     [esp+64h+var_8]
    fdiv    [esp+64h+var_50]
    fmul    ds:dbl_4FD2D8
    call    __ftol
    cdq
    mov     ebp, eax
    mov     eax, [esi]
    mov     ecx, edx
    cdq
    push    ecx
    push    ebp
    push    edx
    push    eax
    mov     [esp+74h+var_46+2], ecx
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ecx, [esp+64h+var_46+2]
    mov     [esi], eax
    mov     eax, [edi+10h]
    push    ecx
    cdq
    push    ebp
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    fld     [esp+64h+var_50]
    fsub    [esp+64h+var_8]
    mov     [edi+10h], eax
    fmul    ds:dbl_4FD2D8
    call    __ftol
    mov     cx, [ebx+66h]
    push    eax
    push    ecx
    mov     [esp+6Ch+var_8], eax
    mov     [esp+6Ch+var_50], ecx
    call    sub_4B70EF
    mov     edx, [esp+6Ch+var_8]
    add     esp, 8
    mov     ebp, eax
    mov     eax, [esp+64h+var_50]
    push    edx
    push    eax
    neg     ebp
    call    sub_4B7123
    mov     edx, [esi]
    mov     ecx, [esi+8]
    neg     eax
    add     esp, 8
    add     edx, ebp
    add     ecx, eax
    mov     [esi], edx
    mov     [esi+8], ecx

    loc_43D480:                             ; CODE XREF: sub_43D290+149j
    mov     ecx, [ebx+6Ah]
    mov     edx, [esp+64h+var_30]
    mov     ebp, [esp+64h+var_28]
    mov     eax, [ebx+6Eh]
    sub     ecx, edx
    mov     edx, [ebx+72h]
    mov     [esp+1Ch], ecx
    mov     ecx, [esp+64h+var_2C]
    sub     edx, ebp
    sub     eax, ecx
    mov     ecx, [esi]
    mov     [esp+64h+var_40], edx
    mov     edx, [esp+64h+var_18]
    sub     ecx, edx
    mov     edx, [esi+8]
    mov     [esp+64h+var_24], ecx
    mov     ecx, [esp+64h+var_10]
    sub     edx, ecx
    mov     ecx, [ebx+82h]
    mov     [esp+64h+var_1C], edx
    mov     edx, TAdynmemStructPtr
    cmp     ecx, [edx+142B7h]
    jz      short loc_43D505
    mov     ecx, [edi+20h]
    mov     edx, ecx
    and     edx, 0FFFFFFFCh
    cmp     edx, 40000h
    jge     short loc_43D4E7
    mov     ecx, 10000h
    jmp     short loc_43D4EA
    ; ---------------------------------------------------------------------------

    loc_43D4E7:                             ; CODE XREF: sub_43D290+24Ej
    sar     ecx, 2

    loc_43D4EA:                             ; CODE XREF: sub_43D290+255j
    mov     edx, ecx
    neg     edx
    cmp     eax, edx
    jg      short loc_43D4F7
    mov     [edi+0Ch], ecx
    jmp     short loc_43D505
    ; ---------------------------------------------------------------------------

    loc_43D4F7:                             ; CODE XREF: sub_43D290+260j
    cmp     eax, ecx
    jl      short loc_43D500
    mov     [edi+0Ch], edx
    jmp     short loc_43D505
    ; ---------------------------------------------------------------------------

    loc_43D500:                             ; CODE XREF: sub_43D290+269j
    neg     eax
    mov     [edi+0Ch], eax

    loc_43D505:                             ; CODE XREF: sub_43D290+23Ej
                                            ; sub_43D290+265j ...
    fild    [esp+64h+var_40]
    fild    dword ptr [esp+1Ch]
    sub     esp, 8
    fxch    st(1)
    fstp    [esp+6Ch+var_6C]
    sub     esp, 8
    fstp    [esp+74h+var_74]
    call    __hypot
    mov     cx, [esp+74h+var_52]
    xor     eax, eax
    sub     cx, [ebx+66h]
    add     esp, 10h
    fmul    ds:flt_4FD2D0
    cmp     cx, ax
    jz      short loc_43D587
    mov     eax, [ebx+92h]
    movsx   ebp, cx
    mov     dx, [eax+1BAh]
    mov     eax, edx
    and     eax, 0FFFFh
    cmp     ebp, eax
    jl      short loc_43D55A
    mov     [edi+24h], dx
    jmp     short loc_43D56C
    ; ---------------------------------------------------------------------------

    loc_43D55A:                             ; CODE XREF: sub_43D290+2C2j
    neg     eax
    cmp     ebp, eax
    jg      short loc_43D568
    neg     edx
    mov     [edi+24h], dx
    jmp     short loc_43D56C
    ; ---------------------------------------------------------------------------

    loc_43D568:                             ; CODE XREF: sub_43D290+2CEj
    mov     [edi+24h], cx

    loc_43D56C:                             ; CODE XREF: sub_43D290+2C8j
                                            ; sub_43D290+2D6j
    mov     cx, [edi+24h]
    mov     eax, [ebx+110h]
    add     [ebx+66h], cx
    or      eax, 10000h
    mov     [ebx+110h], eax
    jmp     short loc_43D58B
    ; ---------------------------------------------------------------------------

    loc_43D587:                             ; CODE XREF: sub_43D290+2A7j
    mov     [edi+24h], ax

    loc_43D58B:                             ; CODE XREF: sub_43D290+2F5j
    fcom    ds:flt_4FD2E0
    fnstsw  ax
    test    ah, 1
    jz      short loc_43D5A0
    fstp    st
    fld     ds:flt_4FD2E0

    loc_43D5A0:                             ; CODE XREF: sub_43D290+306j
    fld     [esp+64h+var_4C]
    fadd    st, st
    fild    [esp+64h+var_40]
    fild    dword ptr [esp+1Ch]
    fxch    st(2)
    fdivrp  st(3), st
    fxch    st(2)
    sub     esp, 8
    sub     esp, 8
    fsqrt
    fchs
    fxch    st(2)
    fmul    st, st(2)
    fild    [esp+74h+var_1C]
    fxch    st(2)
    fmulp   st(3), st
    fild    [esp+74h+var_24]
    fxch    st(1)
    fmul    ds:flt_4FD2D0
    fxch    st(2)
    fmul    ds:flt_4FD2D0
    fxch    st(3)
    fmul    ds:flt_4FD2D0
    fxch    st(3)
    fsubp   st(2), st
    fmul    ds:flt_4FD2D0
    fxch    st(1)
    fst     [esp+74h+var_8]
    fxch    st(1)
    fsubp   st(2), st
    fstp    [esp+74h+var_6C]
    fst     [esp+74h+var_50]
    fstp    [esp+74h+var_74]
    call    __hypot
    fcom    [esp+74h+var_4C]
    add     esp, 10h
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_43D634
    fdivr   [esp+64h+var_4C]
    fld     [esp+64h+var_8]
    fld     [esp+64h+var_50]
    fmul    st, st(2)
    fxch    st(1)
    fmul    st, st(2)
    fxch    st(1)
    fstp    st(2)
    fstp    [esp+64h+var_8]
    jmp     short loc_43D63A
    ; ---------------------------------------------------------------------------

    loc_43D634:                             ; CODE XREF: sub_43D290+386j
    fstp    st
    fld     [esp+64h+var_50]

    loc_43D63A:                             ; CODE XREF: sub_43D290+3A2j
    fmul    ds:dbl_4FD2D8
    call    __ftol
    fld     [esp+64h+var_8]
    mov     ebp, [esi]
    fmul    ds:dbl_4FD2D8
    add     ebp, eax
    mov     [esi], ebp
    call    __ftol
    add     [edi+10h], eax
    fild    dword ptr [esi]
    fild    dword ptr [esi+4]
    fild    dword ptr [esi+8]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    mov     ecx, [esp+64h+var_3C]
    mov     edx, [esp+64h+var_34]
    mov     ebp, [esp+64h+var_38]
    mov     [edi+20h], eax
    mov     eax, [esi]
    sub     eax, ecx
    mov     ecx, [esi+4]
    mov     esi, [esi+8]
    sub     ecx, ebp
    sub     esi, edx
    lea     edx, [esp+64h+var_24]
    fstp    st
    fstp    st
    mov     [esp+64h+var_20], ecx
    push    edx
    push    ebx
    mov     ecx, edi
    fstp    st
    mov     [esp+6Ch+var_24], eax
    mov     [esp+6Ch+var_1C], esi
    call    sub_43D0D0
    pop     ebx
    pop     ebp
    pop     edi
    pop     esi
    add     esp, 48h
    retn    4
    sub_43D290 endp ; sp = -0Ch

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43D6D0 proc near                    ; CODE XREF: sub_43DD20+35p

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 28h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+34h+arg_0]
    push    edi
    mov     ebp, ecx
    mov     eax, [esi+86h]
    test    eax, eax
    jz      loc_43D7FF
    movsx   ecx, byte ptr [esi+0F9h]
    push    ecx
    lea     edx, [esp+3Ch+var_C]
    push    eax
    push    edx
    call    sub_43E060
    mov     edi, [eax]
    mov     [esp+38h+var_18], edi
    mov     ecx, [eax+4]
    mov     [esp+38h+var_14], ecx
    mov     eax, [eax+8]
    mov     [esp+38h+var_10], eax
    mov     eax, [esi+92h]
    mov     edx, [eax+241h]
    shr     edx, 13h
    test    dl, 1
    jz      short loc_43D75C
    xor     edx, edx
    mov     ebx, TAdynmemStructPtr
    mov     dl, [eax+22Ch]
    mov     eax, edx
    shl     eax, 10h
    sub     eax, edx
    xor     edx, edx
    mov     dl, [ebx+1427Fh]
    add     eax, edx
    shl     eax, 10h
    cmp     ecx, eax
    jle     short loc_43D752
    lea     eax, [esp+38h+var_14]
    jmp     short loc_43D75A
    ; ---------------------------------------------------------------------------

    loc_43D752:                             ; CODE XREF: sub_43D6D0+7Aj
    mov     [esp+38h+arg_0], eax
    lea     eax, [esp+38h+arg_0]

    loc_43D75A:                             ; CODE XREF: sub_43D6D0+80j
    mov     ecx, [eax]

    loc_43D75C:                             ; CODE XREF: sub_43D6D0+54j
    mov     al, [ebp+2Eh]
    and     eax, 3
    push    eax
    mov     eax, [esp+3Ch+var_10]
    sub     esp, 0Ch
    mov     edx, esp
    push    esi
    mov     [edx], edi
    mov     [edx+4], ecx
    mov     [edx+8], eax
    call    sub_48A9F0
    movsx   ecx, byte ptr [esi+0F9h]
    mov     edx, [esi+86h]
    push    ecx
    lea     eax, [esp+3Ch+var_20]
    push    edx
    push    eax
    call    sub_43E180
    mov     edx, [eax]
    lea     ecx, [esi+64h]
    mov     [esi+64h], edx
    mov     ax, [eax+4]
    xor     edx, edx
    mov     [ecx+4], ax
    mov     ecx, [esi+86h]
    mov     eax, [ecx]
    cmp     eax, edx
    jz      short loc_43D7D8
    mov     edx, [eax+20h]
    mov     [ebp+20h], edx
    mov     eax, [esi+86h]
    mov     ecx, [eax]
    add     ecx, 8
    add     ebp, 8
    mov     edx, [ecx]
    mov     [ebp+0], edx
    mov     eax, [ecx+4]
    mov     [ebp+4], eax
    mov     ecx, [ecx+8]
    mov     [ebp+8], ecx
    jmp     short loc_43D7EB
    ; ---------------------------------------------------------------------------

    loc_43D7D8:                             ; CODE XREF: sub_43D6D0+DFj
    mov     [ebp+20h], edx
    xor     eax, eax
    xor     ecx, ecx
    add     ebp, 8
    mov     [ebp+0], eax
    mov     [ebp+4], ecx
    mov     [ebp+8], edx

    loc_43D7EB:                             ; CODE XREF: sub_43D6D0+106j
    and     dword ptr [esi+110h], 0FFFEFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43D7FF:                             ; CODE XREF: sub_43D6D0+15j
    mov     edi, [ebp+8]
    mov     eax, [esi+6Ah]
    mov     ebx, [ebp+0Ch]
    lea     ecx, [ebp+8]
    add     edi, eax
    mov     eax, [esi+6Eh]
    mov     edx, [ecx+8]
    add     eax, ebx
    mov     ebx, [esi+72h]
    mov     [esp+38h+var_20], ecx
    mov     cl, [ebp+2Eh]
    add     ebx, edx
    mov     edx, [esi+6Ah]
    and     ecx, 3
    cmp     edi, edx
    mov     [esp+38h+var_8], eax
    mov     [esp+38h+var_18], edi
    mov     [esp+38h+var_14], eax
    mov     [esp+38h+var_10], ebx
    mov     [esp+38h+var_28], ecx
    jnz     short loc_43D85A
    cmp     ebx, [esi+72h]
    jnz     short loc_43D85A
    cmp     eax, [esi+6Eh]
    jnz     short loc_43D85A
    mov     edx, [esi+110h]
    and     edx, 3
    cmp     ecx, edx
    jz      loc_43DA5E

    loc_43D85A:                             ; CODE XREF: sub_43D6D0+16Dj
                                            ; sub_43D6D0+172j ...
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    mov     [ebp+2Ah], ecx
    mov     eax, [esi+7Eh]
    mov     [esp+38h+var_24], eax
    movsx   ecx, word ptr [esp+38h+var_24+2]
    movsx   edx, ax
    shl     edx, 13h
    mov     eax, edi
    shl     ecx, 13h
    sub     eax, edx
    mov     edx, ecx
    mov     ecx, ebx
    add     eax, 80000h
    sub     ecx, edx
    add     ecx, 80000h
    sar     eax, 14h
    sar     ecx, 14h
    cmp     ax, [esi+76h]
    mov     word ptr [esp+38h+arg_0], ax
    mov     word ptr [esp+38h+arg_0+2], cx
    jnz     short loc_43D8E3
    cmp     cx, [esi+78h]
    jnz     short loc_43D8E3
    mov     eax, [esi+110h]
    mov     edx, [esp+38h+var_28]
    mov     ecx, eax
    and     ecx, 3
    cmp     edx, ecx
    jnz     short loc_43D8E3
    mov     edx, [esp+38h+var_8]
    mov     [esi+6Ah], edi
    or      eax, 10000h
    mov     [esi+6Eh], edx
    mov     [esi+72h], ebx
    mov     [esi+110h], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43D8E3:                             ; CODE XREF: sub_43D6D0+1D6j
                                            ; sub_43D6D0+1DCj ...
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_43D92F
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_43D8F9
    cmp     al, 2
    jnz     short loc_43D92F

    loc_43D8F9:                             ; CODE XREF: sub_43D6D0+223j
    mov     eax, [esp+38h+var_28]
    mov     ecx, [esp+38h+arg_0]
    mov     dx, [esi+0A8h]
    push    eax
    mov     eax, [esi+92h]
    push    ecx
    push    edx
    push    eax
    call    sub_47DB70
    mov     cl, [ebp+2Eh]
    xor     edx, edx
    and     cl, 0FBh
    test    eax, eax
    setz    dl
    and     dl, 1
    shl     dl, 2
    or      cl, dl
    mov     [ebp+2Eh], cl

    loc_43D92F:                             ; CODE XREF: sub_43D6D0+21Cj
                                            ; sub_43D6D0+227j
    test    byte ptr [ebp+2Eh], 4
    jz      loc_43DA0E
    mov     ecx, [esi+76h]
    mov     eax, [esi+7Eh]
    mov     [esp+38h+arg_0], ecx
    mov     [esp+38h+var_24], eax
    movsx   ecx, cx
    movsx   edx, ax
    lea     eax, [edx+ecx*2]
    movsx   ecx, word ptr [esp+38h+arg_0+2]
    movsx   edx, word ptr [esp+38h+var_24+2]
    shl     eax, 13h
    lea     ecx, [edx+ecx*2]
    lea     edx, [eax+7FFFFh]
    shl     ecx, 13h
    cmp     edi, edx
    jle     short loc_43D973
    mov     [esp+38h+var_18], edx
    jmp     short loc_43D980
    ; ---------------------------------------------------------------------------

    loc_43D973:                             ; CODE XREF: sub_43D6D0+29Bj
    add     eax, 0FFF80001h
    cmp     edi, eax
    jge     short loc_43D980
    mov     [esp+38h+var_18], eax

    loc_43D980:                             ; CODE XREF: sub_43D6D0+2A1j
                                            ; sub_43D6D0+2AAj
    mov     edx, [esp+38h+var_10]
    lea     eax, [ecx+7FFFFh]
    cmp     edx, eax
    jg      short loc_43D998
    lea     eax, [ecx-7FFFFh]
    cmp     edx, eax
    jge     short loc_43D99C

    loc_43D998:                             ; CODE XREF: sub_43D6D0+2BCj
    mov     [esp+38h+var_10], eax

    loc_43D99C:                             ; CODE XREF: sub_43D6D0+2C6j
    mov     eax, [esi+92h]
    mov     eax, [eax+192h]
    cdq
    sub     eax, edx
    mov     ebx, eax
    mov     eax, [ebp+20h]
    sar     ebx, 1
    cmp     eax, ebx
    jle     short loc_43D9E5
    mov     [ebp+20h], ebx
    mov     bp, [esi+66h]
    push    ebx
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     edi, eax
    neg     edi
    push    ebx
    push    ebp
    call    sub_4B7123
    mov     ecx, [esp+40h+var_20]
    add     esp, 8
    neg     eax
    xor     edx, edx
    mov     [ecx], edi
    mov     [ecx+4], edx
    mov     [ecx+8], eax

    loc_43D9E5:                             ; CODE XREF: sub_43D6D0+2E4j
    mov     ecx, [esp+38h+var_18]
    mov     edx, [esp+38h+var_14]
    mov     eax, [esp+38h+var_10]
    mov     [esi+6Ah], ecx
    mov     [esi+6Eh], edx
    mov     [esi+72h], eax
    or      dword ptr [esi+110h], 10000h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43DA0E:                             ; CODE XREF: sub_43D6D0+263j
    push    esi
    call    sub_47D0E0
    mov     ecx, [esp+38h+var_8]
    mov     eax, [esp+38h+var_28]
    mov     edx, [esp+38h+arg_0]
    mov     [esi+6Ah], edi
    mov     [esi+6Eh], ecx
    mov     ecx, [esi+110h]
    and     eax, 3
    and     ecx, 0FFFFFFFCh
    or      eax, ecx
    push    esi
    mov     [esi+72h], ebx
    mov     [esi+76h], edx
    mov     [esi+110h], eax
    call    sub_47CC30
    mov     ecx, [esi+110h]
    push    esi
    or      ecx, 10000h
    mov     [esi+110h], ecx
    call    sub_4827B0

    loc_43DA5E:                             ; CODE XREF: sub_43D6D0+184j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    4
    sub_43D6D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43DA70 proc near                    ; CODE XREF: sub_43DD20+3Dp

    arg_0= dword ptr  4

    mov     al, [ecx+2Eh]
    push    esi
    push    edi
    mov     edi, [esp+8+arg_0]
    test    al, 4
    jnz     short loc_43DABD
    mov     eax, [edi+86h]
    test    eax, eax
    jnz     short loc_43DABD
    mov     eax, [ecx+20h]
    test    eax, eax
    jnz     short loc_43DA94
    cmp     [ecx+24h], ax
    jz      short loc_43DABD

    loc_43DA94:                             ; CODE XREF: sub_43DA70+1Cj
    mov     ecx, [edi+92h]
    cmp     eax, [ecx+1AEh]
    jg      short loc_43DAA9
    mov     esi, 1
    jmp     short loc_43DABF
    ; ---------------------------------------------------------------------------

    loc_43DAA9:                             ; CODE XREF: sub_43DA70+30j
    mov     esi, [ecx+1B2h]
    xor     edx, edx
    cmp     eax, esi
    setnle  dl
    add     edx, 2
    mov     esi, edx
    jmp     short loc_43DABF
    ; ---------------------------------------------------------------------------

    loc_43DABD:                             ; CODE XREF: sub_43DA70+Bj
                                            ; sub_43DA70+15j ...
    xor     esi, esi

    loc_43DABF:                             ; CODE XREF: sub_43DA70+37j
                                            ; sub_43DA70+4Bj
    mov     eax, [edi+110h]
    mov     ecx, eax
    shr     ecx, 2
    and     ecx, 3
    cmp     esi, ecx
    jz      short loc_43DB43
    test    esi, esi
    jnz     short loc_43DADF
    push    1
    push    esi
    push    offset aStopmoving              ; "StopMoving"
    jmp     short loc_43DAEC
    ; ---------------------------------------------------------------------------

    loc_43DADF:                             ; CODE XREF: sub_43DA70+63j
    test    al, 0Ch
    jnz     short loc_43DAF7
    push    1                               ; RunNow
    push    0                               ; CompletedScriptMethodCallback
    push    offset aStartmoving             ; FunctionName

    loc_43DAEC:                             ; CODE XREF: sub_43DA70+6Dj
    mov     ecx, [edi+9Ah]
    call    InvokeScript

    loc_43DAF7:                             ; CODE XREF: sub_43DA70+71j
    mov     eax, esi
    dec     eax
    jz      short loc_43DB18
    dec     eax
    jz      short loc_43DB0D
    dec     eax
    jnz     short loc_43DB2C
    push    1
    push    0
    push    offset aMoverate3               ; "MoveRate3"
    jmp     short loc_43DB21
    ; ---------------------------------------------------------------------------

    loc_43DB0D:                             ; CODE XREF: sub_43DA70+8Dj
    push    1
    push    0
    push    offset aMoverate2               ; "MoveRate2"
    jmp     short loc_43DB21
    ; ---------------------------------------------------------------------------

    loc_43DB18:                             ; CODE XREF: sub_43DA70+8Aj
    push    1                               ; RunNow
    push    0                               ; CompletedScriptMethodCallback
    push    offset aMoverate1               ; FunctionName

    loc_43DB21:                             ; CODE XREF: sub_43DA70+9Bj
                                            ; sub_43DA70+A6j
    mov     ecx, [edi+9Ah]
    call    InvokeScript

    loc_43DB2C:                             ; CODE XREF: sub_43DA70+90j
    mov     edx, [edi+110h]
    and     esi, 3
    shl     esi, 2
    and     edx, 0FFFFFFF3h
    or      esi, edx
    mov     [edi+110h], esi

    loc_43DB43:                             ; CODE XREF: sub_43DA70+5Fj
    pop     edi
    pop     esi
    retn    4
    sub_43DA70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43DB50 proc near                    ; CODE XREF: sub_43DD20+45p

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+0Ch+arg_0]
    xor     ecx, ecx
    mov     cl, [eax+1427Fh]
    push    edi
    mov     eax, [esi+110h]
    mov     ebp, [esi+10Ah]
    movsx   edx, word ptr [esi+70h]
    and     eax, 3
    mov     edi, ebp
    cmp     eax, 1
    jz      short loc_43DB88
    cmp     eax, 2
    jz      short loc_43DB88
    xor     edi, edi
    jmp     short loc_43DBCC
    ; ---------------------------------------------------------------------------

    loc_43DB88:                             ; CODE XREF: sub_43DB50+2Dj
                                            ; sub_43DB50+32j
    cmp     edx, ecx
    jle     short loc_43DB93
    mov     edi, 4
    jmp     short loc_43DBCC
    ; ---------------------------------------------------------------------------

    loc_43DB93:                             ; CODE XREF: sub_43DB50+3Aj
    mov     eax, edx
    sub     eax, ecx
    cmp     eax, 0FFFFFFFBh
    jle     short loc_43DBA1
    mov     edi, 1

    loc_43DBA1:                             ; CODE XREF: sub_43DB50+4Aj
    mov     eax, [esi+92h]
    xor     ebx, ebx
    mov     bl, [eax+22Ch]
    add     ebx, edx
    cmp     ebx, ecx
    jnz     short loc_43DBBA
    mov     edi, 2

    loc_43DBBA:                             ; CODE XREF: sub_43DB50+63j
    movsx   eax, word ptr [eax+170h]
    add     eax, edx
    cmp     eax, ecx
    jge     short loc_43DBCC
    mov     edi, 3

    loc_43DBCC:                             ; CODE XREF: sub_43DB50+36j
                                            ; sub_43DB50+41j ...
    cmp     ebp, edi
    jz      short loc_43DBF3
    mov     ecx, [esi+9Ah]
    push    0
    push    0
    push    0
    push    edi
    push    1
    push    1
    push    0
    push    offset aSetsfxoccupy            ; "setSFXoccupy"
    call    sub_4B0A70
    mov     [esi+10Ah], edi

    loc_43DBF3:                             ; CODE XREF: sub_43DB50+7Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_43DB50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43DC00 proc near                    ; CODE XREF: .text:00485E66p
                                            ; sub_485E90+99p ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    push    edi
    xor     eax, eax
    lea     edi, [esi+8]
    xor     ecx, ecx
    xor     edx, edx
    mov     [edi], eax
    mov     [esi+20h], edx
    mov     [esi+24h], dx
    mov     [esi+26h], edx
    mov     [edi+4], ecx
    mov     [edi+8], edx
    lea     edi, [esi+14h]
    mov     [esi+14h], eax
    mov     al, [esi+2Eh]
    and     al, 0F9h
    mov     [edi+4], ecx
    or      al, 1
    mov     [esi+2Eh], al
    mov     [edi+8], edx
    mov     edi, [esp+4+arg_0]
    mov     ecx, [edi+92h]
    mov     edx, [ecx+1B6h]
    mov     [esi+4], edx
    mov     eax, [edi+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_43DCAF
    cmp     byte ptr [eax+73h], 3
    jnz     short loc_43DCAF
    mov     eax, [edi+92h]
    mov     ecx, [eax+241h]
    shr     ecx, 0Bh
    test    cl, 1
    jz      short loc_43DC90
    push    27h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      loc_43DD00
    push    edi
    mov     ecx, eax
    call    sub_490940
    mov     [esi], eax
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43DC90:                             ; CODE XREF: sub_43DC00+6Bj
    push    1Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43DD00
    push    edi
    mov     ecx, eax
    call    sub_44F570
    mov     [esi], eax
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43DCAF:                             ; CODE XREF: sub_43DC00+51j
                                            ; sub_43DC00+57j
    mov     edx, [edi+92h]
    mov     eax, [edx+241h]
    shr     eax, 0Bh
    test    al, 1
    jz      short loc_43DCE1
    push    28h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43DD00
    push    edi
    mov     ecx, eax
    call    sub_4907E0
    mov     [esi], eax
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43DCE1:                             ; CODE XREF: sub_43DC00+C0j
    push    65h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_43DD00
    push    edi
    mov     ecx, eax
    call    sub_44F010
    mov     [esi], eax
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43DD00:                             ; CODE XREF: sub_43DC00+79j
                                            ; sub_43DC00+9Cj ...
    xor     eax, eax
    pop     edi
    mov     [esi], eax
    mov     eax, esi
    pop     esi
    retn    4
    sub_43DC00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43DD10 proc near                    ; CODE XREF: sub_4866D0+6E1p
    mov     ecx, [ecx]
    test    ecx, ecx
    jz      short locret_43DD1C
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    locret_43DD1C:                          ; CODE XREF: sub_43DD10+4j
    retn
    sub_43DD10 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43DD20 proc near                    ; CODE XREF: sub_48AD30+27Ap
                                            ; sub_48B920+126p

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [esi]
    mov     eax, [ecx]
    call    dword ptr [eax+8]
    mov     edi, [esp+4+arg_0]
    push    edi
    mov     ecx, [edi+92h]
    mov     edx, [ecx+241h]
    mov     ecx, esi
    shr     edx, 0Bh
    test    dl, 1
    jz      short loc_43DD4D
    call    sub_43D290
    jmp     short loc_43DD52
    ; ---------------------------------------------------------------------------

    loc_43DD4D:                             ; CODE XREF: sub_43DD20+24j
    call    sub_43CD20

    loc_43DD52:                             ; CODE XREF: sub_43DD20+2Bj
    push    edi
    mov     ecx, esi
    call    sub_43D6D0
    push    edi
    mov     ecx, esi
    call    sub_43DA70
    push    edi
    mov     ecx, esi
    call    sub_43DB50
    pop     edi
    pop     esi
    retn    4
    sub_43DD20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43DD70 proc near                    ; CODE XREF: sub_4876C0+10Dp

    var_44= dword ptr -44h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= word ptr -8
    var_6= dword ptr -6
    var_2= byte ptr -2
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 44h
    lea     eax, [ecx+8]
    push    esi
    mov     edx, [eax]
    mov     [esp+48h+var_24], edx
    mov     edx, [eax+4]
    mov     [esp+48h+var_20], edx
    lea     edx, [ecx+14h]
    mov     eax, [eax+8]
    mov     [esp+48h+var_1C], eax
    mov     eax, [edx]
    mov     [esp+48h+var_18], eax
    mov     eax, [edx+4]
    mov     [esp+48h+var_14], eax
    mov     eax, [ecx+20h]
    mov     edx, [edx+8]
    mov     [esp+48h+var_C], eax
    mov     eax, [ecx+26h]
    mov     [esp+48h+var_10], edx
    mov     dx, [ecx+24h]
    mov     cl, [ecx+2Eh]
    mov     [esp+48h+var_6], eax
    mov     al, [esp+48h+var_2]
    mov     [esp+48h+var_8], dx
    mov     dl, al
    xor     dl, cl
    and     dl, 3
    xor     al, dl
    mov     dl, al
    xor     dl, cl
    mov     ecx, [esp+48h+arg_0]
    and     dl, 4
    xor     al, dl
    lea     edx, [esp+48h+var_44]
    mov     [esp+48h+var_2], al
    xor     eax, eax
    mov     ax, [ecx+0A8h]
    push    eax
    push    offset aU04xmob                 ; "u%04xmob"
    push    edx
    call    _sprintf
    mov     esi, [esp+54h+arg_4]
    add     esp, 0Ch
    lea     eax, [esp+48h+var_44]
    mov     ecx, esi
    push    eax
    call    sub_4B4BA0
    push    0
    mov     ecx, esi
    call    sub_4B4C10
    lea     ecx, [esp+48h+var_24]
    push    23h
    push    ecx
    mov     ecx, esi
    call    sub_4B4CF0
    pop     esi
    add     esp, 44h
    retn    8
    sub_43DD70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43DE30 proc near                    ; CODE XREF: sub_487080+4C1p

    var_44= dword ptr -44h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= word ptr -8
    var_6= dword ptr -6
    var_2= byte ptr -2
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 44h
    xor     eax, eax
    lea     edx, [esp+44h+var_44]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+48h+arg_0]
    push    edi
    mov     ax, [ecx+0A8h]
    push    eax
    push    offset aU04xmob                 ; "u%04xmob"
    push    edx
    call    _sprintf
    mov     edi, [esp+58h+arg_4]
    add     esp, 0Ch
    lea     eax, [esp+4Ch+var_44]
    mov     ecx, edi
    push    eax
    call    sub_4B4BA0
    push    0
    mov     ecx, edi
    call    sub_4B4C10
    lea     ecx, [esp+4Ch+var_24]
    push    23h
    push    ecx
    mov     ecx, edi
    call    sub_4B4C80
    mov     eax, [esp+4Ch+var_24]
    mov     ecx, [esp+4Ch+var_20]
    lea     edx, [esi+8]
    pop     edi
    mov     [edx], eax
    mov     eax, [esp+48h+var_1C]
    mov     [edx+4], ecx
    lea     ecx, [esi+14h]
    mov     [edx+8], eax
    mov     edx, [esp+48h+var_18]
    mov     eax, [esp+48h+var_14]
    mov     [ecx], edx
    mov     edx, [esp+48h+var_10]
    mov     [ecx+4], eax
    mov     eax, [esp+48h+var_C]
    mov     [esi+20h], eax
    mov     [ecx+8], edx
    mov     cx, [esp+48h+var_8]
    mov     edx, [esp+48h+var_6]
    mov     [esi+24h], cx
    mov     cl, [esp+48h+var_2]
    mov     [esi+26h], edx
    mov     dl, [esi+2Eh]
    mov     al, cl
    xor     al, dl
    and     al, 3
    xor     al, dl
    xor     cl, al
    and     cl, 4
    xor     cl, al
    mov     [esi+2Eh], cl
    pop     esi
    add     esp, 44h
    retn    8
    sub_43DE30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43DEF0 proc near                    ; CODE XREF: .text:00411412p
                                            ; sub_43E060+15p ...

    var_14= dword ptr -14h
    var_10= word ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 14h
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+20h+arg_4]
    test    edi, edi
    jz      loc_43E03A
    mov     ecx, [edi+9Eh]
    test    ecx, ecx
    jz      loc_43E03A
    mov     eax, [esp+20h+arg_8]
    test    eax, eax
    jl      loc_43E01D
    cmp     eax, [ecx]
    jge     loc_43E01D
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*8]
    mov     edx, [ecx+eax*2+26h]
    lea     eax, [ecx+eax*2+22h]
    mov     ecx, [eax]
    mov     ecx, [ecx+10h]
    add     ecx, edx
    mov     [esp+20h+var_C], ecx
    mov     edx, [eax]
    mov     esi, [eax+8]
    mov     ecx, [edx+14h]
    add     ecx, esi
    mov     [esp+20h+var_8], ecx
    mov     ecx, [eax]
    mov     edx, [eax+0Ch]
    mov     ecx, [ecx+18h]
    add     ecx, edx
    mov     [esp+20h+var_4], ecx
    mov     esi, [eax+32h]
    test    esi, esi
    jz      loc_43DFFC

    loc_43DF64:                             ; CODE XREF: sub_43DEF0+106j
    mov     ebx, [esi+32h]
    mov     ax, [esi+14h]
    mov     cx, [esi+10h]
    mov     dx, [esi+12h]
    test    ebx, ebx
    mov     word ptr [esp+20h+var_14], ax
    mov     [esp+20h+var_10], cx
    mov     word ptr [esp+20h+var_14+2], dx
    jnz     short loc_43DFA1
    add     ax, [edi+64h]
    add     cx, [edi+68h]
    add     dx, [edi+66h]
    mov     word ptr [esp+20h+var_14], ax
    mov     [esp+20h+var_10], cx
    mov     word ptr [esp+20h+var_14+2], dx

    loc_43DFA1:                             ; CODE XREF: sub_43DEF0+94j
    lea     edx, [esp+20h+var_14]
    lea     eax, [esp+20h+var_C]
    push    edx
    lea     ecx, [esp+24h+var_C]
    push    eax
    push    ecx
    call    sub_4B6CC0
    mov     edx, [esi]
    mov     ecx, [esp+20h+var_C]
    mov     eax, [edx+10h]
    mov     edx, [esi+4]
    add     eax, edx
    add     ecx, eax
    mov     [esp+20h+var_C], ecx
    mov     ecx, [esi]
    mov     ebx, [esi+8]
    mov     edx, [ecx+14h]
    mov     ecx, [esp+20h+var_8]
    add     edx, ebx
    add     ecx, edx
    mov     [esp+20h+var_8], ecx
    mov     eax, [esi]
    mov     ecx, [esp+20h+var_4]
    mov     edx, [eax+18h]
    mov     eax, [esi+0Ch]
    add     edx, eax
    add     ecx, edx
    mov     [esp+20h+var_4], ecx
    mov     esi, [esi+32h]
    test    esi, esi
    jnz     loc_43DF64

    loc_43DFFC:                             ; CODE XREF: sub_43DEF0+6Ej
    mov     eax, [esp+20h+arg_0]
    mov     edx, [esp+20h+var_C]
    mov     esi, [esp+20h+var_8]
    mov     edi, eax
    neg     ecx
    mov     [edi], edx
    mov     [edi+4], esi
    mov     [edi+8], ecx
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43E01D:                             ; CODE XREF: sub_43DEF0+26j
                                            ; sub_43DEF0+2Ej
    mov     eax, [esp+20h+arg_0]
    xor     edx, edx
    mov     edi, eax
    xor     esi, esi
    xor     ecx, ecx
    mov     [edi], edx
    mov     [edi+4], esi
    mov     [edi+8], ecx
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_43E03A:                             ; CODE XREF: sub_43DEF0+Cj
                                            ; sub_43DEF0+1Aj
    mov     eax, [esp+20h+arg_0]
    xor     ecx, ecx
    mov     edi, eax
    xor     edx, edx
    xor     esi, esi
    mov     [edi], ecx
    mov     [edi+4], edx
    mov     [edi+8], esi
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 14h
    retn    0Ch
    sub_43DEF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43E060 proc near                    ; CODE XREF: .text:0040280Bp
                                            ; sub_43D6D0+29p ...

    var_C= dword ptr -0Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    sub     esp, 0Ch
    lea     ecx, [esp+0Ch+var_C]
    push    ebx
    push    esi
    mov     esi, [esp+14h+arg_4]
    push    edi
    push    eax
    push    esi
    push    ecx
    call    sub_43DEF0
    mov     edx, eax
    mov     ecx, [esi+6Ah]
    mov     eax, [edx]
    add     ecx, eax
    mov     eax, [esp+18h+arg_0]
    mov     edi, [edx+4]
    mov     ebx, [edx+8]
    mov     edx, [esi+6Eh]
    mov     esi, [esi+72h]
    add     edx, edi
    mov     edi, eax
    add     esi, ebx
    mov     [edi], ecx
    mov     [edi+4], edx
    mov     [edi+8], esi
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_43E060 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43E0B0 proc near                    ; CODE XREF: sub_43E3C0+34p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    mov     eax, [esp+8+arg_8]
    push    ebx
    push    ebp
    mov     ebp, [esp+10h+arg_0]
    lea     eax, [eax+eax*2]
    push    esi
    mov     ecx, [ebp+9Eh]
    push    edi
    lea     eax, [eax+eax*8]
    xor     edx, edx
    xor     edi, edi
    xor     esi, esi
    lea     eax, [ecx+eax*2+22h]
    xor     ebx, ebx
    mov     [esp+18h+var_8], edx
    mov     [esp+18h+var_4], edx
    mov     ecx, [eax+22h]
    mov     eax, [eax]
    mov     eax, [eax+4]
    test    eax, eax
    jle     short loc_43E135
    mov     [esp+18h+arg_8], eax

    loc_43E0EF:                             ; CODE XREF: sub_43E0B0+7Fj
    mov     eax, [ecx]
    cmp     eax, edx
    jge     short loc_43E0F7
    mov     edx, eax

    loc_43E0F7:                             ; CODE XREF: sub_43E0B0+43j
    cmp     eax, [esp+18h+var_8]
    jle     short loc_43E101
    mov     [esp+18h+var_8], eax

    loc_43E101:                             ; CODE XREF: sub_43E0B0+4Bj
    mov     eax, [ecx+4]
    cmp     eax, edi
    jge     short loc_43E10A
    mov     edi, eax

    loc_43E10A:                             ; CODE XREF: sub_43E0B0+56j
    cmp     eax, [esp+18h+var_4]
    jle     short loc_43E114
    mov     [esp+18h+var_4], eax

    loc_43E114:                             ; CODE XREF: sub_43E0B0+5Ej
    mov     eax, [ecx+8]
    cmp     eax, esi
    jge     short loc_43E11D
    mov     esi, eax

    loc_43E11D:                             ; CODE XREF: sub_43E0B0+69j
    cmp     eax, ebx
    jle     short loc_43E123
    mov     ebx, eax

    loc_43E123:                             ; CODE XREF: sub_43E0B0+6Fj
    mov     eax, [esp+18h+arg_8]
    add     ecx, 0Ch
    dec     eax
    mov     [esp+18h+arg_8], eax
    jnz     short loc_43E0EF
    mov     ebp, [esp+18h+arg_0]

    loc_43E135:                             ; CODE XREF: sub_43E0B0+39j
    mov     ecx, [esp+18h+var_8]
    lea     eax, [ecx+edx]
    mov     ecx, [ebp+6Ah]
    cdq
    sub     eax, edx
    mov     edx, [esp+18h+var_4]
    sar     eax, 1
    add     eax, ecx
    mov     ecx, [esp+18h+arg_4]
    mov     [ecx], eax
    lea     eax, [edx+edi]
    cdq
    sub     eax, edx
    mov     edx, [ebp+6Eh]
    sar     eax, 1
    add     eax, edx
    pop     edi
    mov     [ecx+4], eax
    lea     eax, [ebx+esi]
    cdq
    sub     eax, edx
    mov     edx, [ebp+72h]
    sar     eax, 1
    add     eax, edx
    pop     esi
    pop     ebp
    mov     [ecx+8], eax
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_43E0B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43E180 proc near                    ; CODE XREF: sub_43D6D0+BEp

    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    mov     eax, [esp+8+arg_4]
    push    ebx
    push    esi
    mov     esi, [esp+10h+arg_8]
    mov     edx, [eax+9Eh]
    mov     bx, [eax+66h]
    lea     ecx, [esi+esi*2]
    push    edi
    lea     ecx, [ecx+ecx*8]
    add     bx, [edx+ecx*2+34h]
    lea     edi, [edx+ecx*2]
    mov     cx, [eax+68h]
    add     cx, [edi+32h]
    inc     esi
    mov     word ptr [esp+14h+var_8+2], bx
    pop     edi
    lea     esi, [esi+esi*2]
    lea     esi, [esi+esi*8]
    mov     dx, [edx+esi*2]
    add     dx, [eax+64h]
    mov     eax, [esp+10h+arg_0]
    mov     word ptr [esp+10h+var_8], dx
    mov     esi, [esp+10h+var_8]
    mov     edx, eax
    mov     [edx], esi
    pop     esi
    pop     ebx
    mov     [edx+4], cx
    add     esp, 8
    retn    0Ch
    sub_43E180 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43E1E0 proc near                    ; CODE XREF: sub_49C740+EEp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    mov     ecx, [esp+10h+arg_4]
    push    0                               ; int
    push    0                               ; int
    lea     eax, [esp+18h+var_10]
    push    0                               ; int
    and     ecx, 0FFh
    push    eax                             ; int
    mov     eax, [esp+20h+arg_0]
    mov     [esp+20h+var_C], offset aQueryprimary ; "QueryPrimary"
    mov     [esp+20h+var_8], offset aQuerysecondary ; "QuerySecondary"
    mov     [esp+20h+var_4], offset aQuerytertiary ; "QueryTertiary"
    mov     edx, [esp+ecx*4+20h+var_C]
    mov     ecx, [eax+9Ah]
    push    edx                             ; int
    mov     [esp+24h+var_10], 0
    call    sub_4B0BC0
    mov     eax, [esp+10h+var_10]
    add     esp, 10h
    retn    8
    sub_43E1E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43E240 proc near                    ; CODE XREF: sub_49B720+C1p
                                            ; sub_49D580+12Fp ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_C]
    sub     esp, 0Ch
    test    eax, eax
    push    esi
    mov     esi, [esp+10h+arg_0]
    push    edi
    jge     short loc_43E29A
    mov     ecx, [esp+14h+arg_8]
    push    0                               ; int
    and     ecx, 0FFh
    mov     [esp+18h+var_C], offset aQueryprimary ; "QueryPrimary"
    mov     [esp+18h+var_8], offset aQuerysecondary ; "QuerySecondary"
    mov     [esp+18h+var_4], offset aQuerytertiary ; "QueryTertiary"
    mov     edx, [esp+ecx*4+18h+var_C]
    mov     ecx, [esi+9Ah]
    push    0                               ; int
    lea     eax, [esp+1Ch+arg_C]
    push    0                               ; int
    push    eax                             ; int
    push    edx                             ; int
    mov     [esp+28h+arg_C], 0
    call    sub_4B0BC0
    mov     eax, [esp+14h+arg_C]

    loc_43E29A:                             ; CODE XREF: sub_43E240+Fj
    push    eax
    lea     eax, [esp+18h+var_C]
    push    esi
    push    eax
    call    sub_43DEF0
    mov     ecx, [eax]
    mov     edx, [eax+4]
    mov     edi, [eax+8]
    mov     eax, [esi+6Ah]
    add     eax, ecx
    mov     ecx, [esi+6Eh]
    mov     esi, [esi+72h]
    add     ecx, edx
    mov     edx, [esp+14h+arg_4]
    add     esi, edi
    pop     edi
    mov     [edx], eax
    mov     [edx+4], ecx
    mov     [edx+8], esi
    pop     esi
    add     esp, 0Ch
    retn    10h
    sub_43E240 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43E2E0 proc near                    ; CODE XREF: sub_49D580+45p
                                            ; sub_49D910+14p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 10h
    push    esi
    push    edi
    mov     edi, [esp+18h+arg_8]
    mov     esi, [esp+18h+arg_0]
    and     edi, 0FFh
    push    0                               ; int
    shl     edi, 2
    mov     [esp+1Ch+var_C], offset aAimfromprimary ; "AimFromPrimary"
    mov     [esp+1Ch+var_8], offset aAimfromseconda ; "AimFromSecondary"
    mov     [esp+1Ch+var_4], offset aAimfromtertiar ; "AimFromTertiary"
    mov     ecx, [esp+edi+1Ch+var_C]
    push    0                               ; int
    lea     eax, [esp+20h+var_10]
    push    0                               ; int
    push    eax                             ; int
    push    ecx                             ; int
    mov     ecx, [esi+9Ah]
    mov     [esp+2Ch+var_10], 0FFFFFFFFh
    call    sub_4B0BC0
    mov     eax, [esp+18h+var_10]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_43E382
    mov     ecx, [esi+9Ah]
    push    0                               ; int
    mov     [esp+1Ch+var_C], offset aQueryprimary ; "QueryPrimary"
    mov     [esp+1Ch+var_8], offset aQuerysecondary ; "QuerySecondary"
    mov     [esp+1Ch+var_4], offset aQuerytertiary ; "QueryTertiary"
    mov     eax, [esp+edi+1Ch+var_C]
    push    0                               ; int
    lea     edx, [esp+20h+arg_8]
    push    0                               ; int
    push    edx                             ; int
    push    eax                             ; int
    mov     [esp+2Ch+arg_8], 0
    call    sub_4B0BC0
    lea     edx, [esp+18h+var_C]
    mov     ecx, [esp+18h+arg_8]
    push    ecx
    push    esi
    push    edx
    jmp     short loc_43E389
    ; ---------------------------------------------------------------------------

    loc_43E382:                             ; CODE XREF: sub_43E2E0+58j
    push    eax
    lea     eax, [esp+1Ch+var_C]
    push    esi
    push    eax

    loc_43E389:                             ; CODE XREF: sub_43E2E0+A0j
    call    sub_43DEF0
    mov     ecx, [eax]
    mov     edx, [eax+4]
    mov     edi, [eax+8]
    mov     eax, [esi+6Ah]
    add     eax, ecx
    mov     ecx, [esi+6Eh]
    mov     esi, [esi+72h]
    add     ecx, edx
    mov     edx, [esp+18h+arg_4]
    add     esi, edi
    pop     edi
    mov     [edx], eax
    mov     [edx+4], ecx
    mov     [edx+8], esi
    pop     esi
    add     esp, 10h
    retn    0Ch
    sub_43E2E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43E3C0 proc near                    ; CODE XREF: sub_48A1E0+117p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    esi
    mov     esi, [esp+8+arg_0]
    push    0                               ; int
    push    0                               ; int
    mov     ecx, [esi+9Ah]
    lea     eax, [esp+10h+var_4]
    push    0                               ; int
    push    eax                             ; int
    push    offset aSweetspot               ; int
    mov     [esp+1Ch+var_4], 0
    call    sub_4B0BC0
    mov     ecx, [esp+8+var_4]
    mov     edx, [esp+8+arg_4]
    push    ecx
    push    edx
    push    esi
    call    sub_43E0B0
    pop     esi
    pop     ecx
    retn    8
    sub_43E3C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43E400 proc near                    ; CODE XREF: .text:0040252Ep
                                            ; .text:00402A1Cp ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    esi
    mov     esi, [esp+14h+arg_0]
    push    edi
    push    0                               ; int
    mov     ecx, [esi+9Ah]
    push    0                               ; int
    lea     eax, [esp+20h+var_10]
    push    0                               ; int
    push    eax                             ; int
    push    offset aQuerynanopiece          ; int
    mov     [esp+2Ch+var_10], 0
    call    sub_4B0BC0
    lea     edx, [esp+18h+var_C]
    mov     ecx, [esp+18h+var_10]
    push    ecx
    push    esi
    push    edx
    call    sub_43DEF0
    mov     ecx, [eax]
    mov     edx, [eax+4]
    mov     edi, [eax+8]
    mov     eax, [esi+6Ah]
    add     eax, ecx
    mov     ecx, [esi+6Eh]
    mov     esi, [esi+72h]
    add     ecx, edx
    mov     edx, [esp+18h+arg_4]
    add     esi, edi
    pop     edi
    mov     [edx], eax
    mov     [edx+4], ecx
    mov     [edx+8], esi
    pop     esi
    add     esp, 10h
    retn    8
    sub_43E400 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43E470 proc near                    ; CODE XREF: sub_48CF30+27p

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    cmp     al, 5
    jz      short loc_43E488
    cmp     al, 0Ah
    jz      short loc_43E488
    cmp     al, 0Eh
    jz      short loc_43E488
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_43E488:                             ; CODE XREF: sub_43E470+6j
                                            ; sub_43E470+Aj ...
    xor     eax, eax
    retn    4
    sub_43E470 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_43E490(int,int,int,int)
    sub_43E490 proc near                    ; CODE XREF: sub_48D220+1C4p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    push    ecx
    push    ebx
    mov     ebx, TAdynmemStructPtr
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+14h+arg_8]

    loc_43E49F:                             ; CODE XREF: sub_43E490+95j
                                            ; sub_43E490+B0j
    mov     eax, [esp+14h+arg_4]
    xor     esi, esi
    xor     ebp, ebp
    mov     [esp+14h+var_4], esi
    mov     ecx, [eax+92h]
    test    edi, edi
    mov     [esp+14h+arg_8], ecx
    jz      short loc_43E4EB
    mov     edx, [edi+96h]
    xor     eax, eax
    mov     al, [edx+146h]
    mov     edx, [esp+14h+arg_4]
    mov     edx, [edx+96h]
    cmp     byte ptr [eax+edx+108h], 0
    jz      short loc_43E4E6
    mov     esi, 1
    mov     [esp+14h+var_4], esi
    jmp     short loc_43E4EB
    ; ---------------------------------------------------------------------------

    loc_43E4E6:                             ; CODE XREF: sub_43E490+49j
    mov     ebp, 1

    loc_43E4EB:                             ; CODE XREF: sub_43E490+27j
                                            ; sub_43E490+54j
    mov     eax, [esp+14h+arg_0]
    and     eax, 0FFh
    dec     eax
    cmp     eax, 0Dh                        ; switch 14 cases
    ja      loc_43F098                      ; default
    jmp     ds:off_43F0A8[eax*4]            ; switch jump

    loc_43E505:                             ; DATA XREF: .text:0043F0A8o
    cmp     dword ptr [ebx+37EFAh], 1       ; case 0x0
    jz      loc_43EB02
    mov     eax, [ecx+245h]
    test    al, 10h
    jz      short loc_43E52A
    test    ebp, ebp
    jz      short loc_43E52A
    mov     byte ptr [esp+14h+arg_0], 3
    jmp     loc_43E49F
    ; ---------------------------------------------------------------------------

    loc_43E52A:                             ; CODE XREF: sub_43E490+8Aj
                                            ; sub_43E490+8Ej
    test    ah, 4
    jz      loc_43EDB6
    test    ebp, ebp
    jz      loc_43EDB6
    mov     byte ptr [esp+14h+arg_0], 0Ch
    jmp     loc_43E49F
    ; ---------------------------------------------------------------------------

    loc_43E545:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     eax, [ecx+245h]                 ; case 0x2
    test    al, 10h
    jz      short loc_43E56D
    mov     ecx, [ecx+1EEh]
    mov     edx, [ecx+111h]
    test    dh, 1
    jz      short loc_43E56D
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E56D:                             ; CODE XREF: sub_43E490+BDj
                                            ; sub_43E490+CEj
    shr     eax, 4
    test    al, 1
    jz      loc_43F098                      ; default
    mov     eax, [esp+14h+arg_4]
    mov     ecx, [eax]
    mov     esi, [eax+10h]
    test    ecx, ecx
    jz      short loc_43E592
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E592:                             ; CODE XREF: sub_43E490+F3j
    test    edi, edi
    push    0
    jz      short loc_43E5B4
    mov     edx, [esp+18h+arg_4]
    push    edi
    push    edx
    call    sub_49ABB0
    neg     eax
    sbb     eax, eax
    and     al, 0FEh
    add     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E5B4:                             ; CODE XREF: sub_43E490+106j
    mov     eax, [esp+18h+arg_C]
    push    eax
    mov     eax, [esp+1Ch+arg_4]
    lea     ecx, [eax+6Ah]
    push    ecx
    push    eax
    call    sub_49AA80
    test    eax, eax
    jz      loc_43E8A1
    test    dword ptr [esi+111h], 20000h
    jmp     loc_43E892
    ; ---------------------------------------------------------------------------

    loc_43E5DE:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     eax, [ecx+245h]                 ; case 0x8
    shr     eax, 6
    and     al, 1
    neg     al
    sbb     eax, eax
    and     al, 0F4h
    add     eax, 13h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E5FA:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     ecx, [esp+14h+arg_4]            ; case 0x7
    push    edi
    call    sub_4899B0
    neg     eax
    sbb     eax, eax
    and     al, 0F3h
    add     eax, 13h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E615:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    test    byte ptr [ecx+245h], 20h        ; case 0x6
    jz      loc_43F098                      ; default
    test    esi, esi
    jz      loc_43F098                      ; default
    mov     edx, [ecx+241h]
    mov     eax, 800h
    test    eax, edx
    jnz     loc_43EAE8
    mov     edx, [edi+92h]
    test    [edx+241h], eax
    jnz     loc_43F098                      ; default
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E65C:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     eax, [ecx+245h]                 ; case 0xb
    test    ah, 4
    jz      loc_43E770
    mov     esi, [esp+14h+arg_C]
    mov     eax, [esp+14h+arg_4]
    movsx   ebp, word ptr [esi+6]
    mov     edx, [eax+96h]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    sar     ebp, 1
    sub     eax, ebp
    mov     ebp, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebp
    jnb     loc_43E770
    cmp     eax, [edx+84h]
    jnb     loc_43E770
    mov     edx, [edx+80h]
    xor     ebp, ebp
    imul    edx, eax
    mov     eax, [ebx+TAdynmemStruct.field_14273]
    add     edx, ecx
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    mov     bp, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, ebp
    jz      loc_43E770
    push    esi                             ; int
    call    sub_4815A0
    test    eax, eax
    jz      short loc_43E756
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43E70C
    mov     eax, TAdynmemStructPtr
    and     ecx, 0FFFFh
    cmp     ecx, [eax+14253h]
    jl      short loc_43E701
    xor     eax, eax
    jmp     short loc_43E756
    ; ---------------------------------------------------------------------------

    loc_43E701:                             ; CODE XREF: sub_43E490+26Bj
    mov     eax, [eax+1426Fh]
    shl     ecx, 8
    jmp     short loc_43E754
    ; ---------------------------------------------------------------------------

    loc_43E70C:                             ; CODE XREF: sub_43E490+258j
    cmp     cx, 0FFFEh
    jz      short loc_43E717
    xor     eax, eax
    jmp     short loc_43E756
    ; ---------------------------------------------------------------------------

    loc_43E717:                             ; CODE XREF: sub_43E490+281j
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [eax+0Ah]
    xor     edx, edx
    imul    ecx, [esi+TAdynmemStruct.FeatureMapSizeX]
    mov     dl, [eax+0Bh]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_43E746
    xor     eax, eax
    jmp     short loc_43E756
    ; ---------------------------------------------------------------------------

    loc_43E746:                             ; CODE XREF: sub_43E490+2B0j
    mov     ecx, [esi+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_43E754:                             ; CODE XREF: sub_43E490+27Aj
    add     eax, ecx

    loc_43E756:                             ; CODE XREF: sub_43E490+24Dj
                                            ; sub_43E490+26Fj ...
    test    eax, eax
    jz      short loc_43E770
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_43E770
    mov     eax, 0Bh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E770:                             ; CODE XREF: sub_43E490+1D5j
                                            ; sub_43E490+207j ...
    test    edi, edi
    jz      loc_43F098                      ; default
    mov     ecx, [esp+14h+arg_4]
    push    edi
    call    sub_489960
    test    eax, eax
    jz      loc_43F098                      ; default
    mov     eax, 0Bh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E797:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     eax, [ecx+245h]                 ; case 0xc
    test    ah, 10h
    jz      loc_43F098                      ; default
    test    edi, edi
    jz      loc_43F098                      ; default
    mov     edx, [esp+14h+arg_4]
    mov     ecx, [edi+96h]
    mov     eax, [edx+96h]
    cmp     eax, ecx
    jz      loc_43F098                      ; default
    mov     eax, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E7D3:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    test    edi, edi                        ; case 0x5
    jz      loc_43F098                      ; default
    mov     ecx, [esp+14h+arg_4]
    push    edi
    call    sub_489A90
    test    eax, eax
    jz      loc_43F098                      ; default
    mov     ecx, [esp+14h+arg_8]
    mov     eax, [ecx+241h]
    shr     eax, 0Bh
    not     al
    and     eax, 1
    or      al, 2
    shl     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E80C:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     eax, [ecx+245h]                 ; case 0x4
    shr     eax, 8
    and     al, 1
    neg     al
    sbb     eax, eax
    and     al, 0FAh
    add     eax, 13h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E828:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     eax, [ecx+156h]                 ; case 0xd
    test    eax, eax
    jz      loc_43F098                      ; default
    mov     edx, [esp+14h+arg_4]
    cmp     dword ptr [edx], 0
    jz      loc_43F098                      ; default
    mov     eax, 10h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E850:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     eax, [ecx+245h]                 ; case 0x3
    shr     eax, 0Eh
    test    al, 1
    jz      loc_43F098                      ; default
    mov     eax, [esp+14h+arg_4]
    mov     edx, [eax+0ECh]
    mov     ecx, [eax+48h]
    fld     dword ptr [edx+8Ch]
    fcomp   dword ptr [ecx+0C0h]
    fnstsw  ax
    test    ah, 1
    jnz     short loc_43E8A1
    fld     dword ptr [edx+98h]
    fcomp   dword ptr [ecx+0C4h]
    fnstsw  ax
    test    ah, 1

    loc_43E892:                             ; CODE XREF: sub_43E490+149j
    jnz     short loc_43E8A1
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E8A1:                             ; CODE XREF: sub_43E490+139j
                                            ; sub_43E490+3EFj ...
    mov     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E8AE:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     eax, 9                          ; case 0xa
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E8BB:                             ; CODE XREF: sub_43E490+6Ej
                                            ; DATA XREF: .text:0043F0A8o
    mov     eax, [ecx+245h]                 ; case 0x1
    test    al, 80h
    jz      loc_43F098                      ; default
    test    ah, 8
    jz      loc_43E9E0
    mov     esi, [esp+14h+arg_C]
    mov     ecx, [esp+14h+arg_4]
    movsx   ebx, word ptr [esi+6]
    mov     edx, [ecx+96h]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    sar     ebx, 1
    sub     eax, ebx
    mov     ebx, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebx
    jnb     loc_43E9DC
    cmp     eax, [edx+84h]
    jnb     loc_43E9DC
    mov     edx, [edx+80h]
    xor     ebx, ebx
    imul    edx, eax
    mov     eax, TAdynmemStructPtr
    add     edx, ecx
    mov     ecx, [eax+TAdynmemStruct.field_14273]
    mov     bx, [ecx+edx*2]
    mov     cl, [eax+TAdynmemStruct.LOS_Sight]
    mov     edx, 1
    shl     edx, cl
    test    edx, ebx
    jz      loc_43E9DC
    push    esi                             ; int
    call    sub_4815A0
    test    eax, eax
    jz      short loc_43E9C2
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43E978
    mov     eax, TAdynmemStructPtr
    and     ecx, 0FFFFh
    cmp     ecx, [eax+14253h]
    jl      short loc_43E96D
    xor     eax, eax
    jmp     short loc_43E9C2
    ; ---------------------------------------------------------------------------

    loc_43E96D:                             ; CODE XREF: sub_43E490+4D7j
    mov     eax, [eax+1426Fh]
    shl     ecx, 8
    jmp     short loc_43E9C0
    ; ---------------------------------------------------------------------------

    loc_43E978:                             ; CODE XREF: sub_43E490+4C4j
    cmp     cx, 0FFFEh
    jz      short loc_43E983
    xor     eax, eax
    jmp     short loc_43E9C2
    ; ---------------------------------------------------------------------------

    loc_43E983:                             ; CODE XREF: sub_43E490+4EDj
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [eax+0Ah]
    xor     edx, edx
    imul    ecx, [esi+TAdynmemStruct.FeatureMapSizeX]
    mov     dl, [eax+0Bh]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_43E9B2
    xor     eax, eax
    jmp     short loc_43E9C2
    ; ---------------------------------------------------------------------------

    loc_43E9B2:                             ; CODE XREF: sub_43E490+51Cj
    mov     ecx, [esi+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_43E9C0:                             ; CODE XREF: sub_43E490+4E6j
    add     eax, ecx

    loc_43E9C2:                             ; CODE XREF: sub_43E490+4B9j
                                            ; sub_43E490+4DBj ...
    test    eax, eax
    jz      short loc_43E9DC
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_43E9DC
    mov     eax, 0Ah
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43E9DC:                             ; CODE XREF: sub_43E490+46Ej
                                            ; sub_43E490+47Aj ...
    mov     esi, [esp+14h+var_4]

    loc_43E9E0:                             ; CODE XREF: sub_43E490+43Cj
    test    edi, edi
    jz      loc_43EAF5
    mov     ebx, [esp+14h+arg_4]
    cmp     dword ptr [ebx], 0
    jz      loc_43EAF5
    mov     edx, [esp+14h+arg_8]
    mov     eax, [edx+245h]
    test    ah, 10h
    jz      short loc_43EA15
    test    ebp, ebp
    jz      short loc_43EA32
    mov     eax, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EA15:                             ; CODE XREF: sub_43E490+572j
    test    ebp, ebp
    jz      short loc_43EA32
    push    edi
    mov     ecx, ebx
    call    sub_489960
    test    eax, eax
    jz      short loc_43EA32
    mov     eax, 0Bh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EA32:                             ; CODE XREF: sub_43E490+576j
                                            ; sub_43E490+587j ...
    test    esi, esi
    jz      short loc_43EA7F
    push    edi
    mov     ecx, ebx
    call    sub_4899B0
    test    eax, eax
    jz      short loc_43EA62
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD2E8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_43EA62
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EA62:                             ; CODE XREF: sub_43E490+5B0j
                                            ; sub_43E490+5C3j
    test    esi, esi
    jz      short loc_43EA7F
    push    edi
    mov     ecx, ebx
    call    sub_4899B0
    test    eax, eax
    jz      short loc_43EA7F
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EA7F:                             ; CODE XREF: sub_43E490+5A4j
                                            ; sub_43E490+5D4j ...
    mov     eax, [esp+14h+arg_8]
    mov     ecx, [eax+241h]
    test    ch, 8
    jz      short loc_43EAAC
    mov     ecx, [edi+92h]
    mov     eax, [ecx+241h]
    test    ah, 2
    jz      short loc_43EAAC
    mov     eax, 0Dh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EAAC:                             ; CODE XREF: sub_43E490+5FCj
                                            ; sub_43E490+60Dj
    push    edi
    mov     ecx, ebx
    call    sub_489A90
    test    eax, eax
    jz      short loc_43EAD7
    mov     edx, [esp+14h+arg_8]
    mov     eax, [edx+241h]
    shr     eax, 0Bh
    not     al
    and     eax, 1
    or      al, 2
    shl     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EAD7:                             ; CODE XREF: sub_43E490+626j
    mov     eax, [esp+14h+arg_8]
    test    byte ptr [eax+245h], 20h
    jz      short loc_43EAF5
    test    esi, esi
    jz      short loc_43EAF5

    loc_43EAE8:                             ; CODE XREF: sub_43E490+1A7j
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EAF5:                             ; CODE XREF: sub_43E490+552j
                                            ; sub_43E490+55Fj ...
    mov     eax, 0Eh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EB02:                             ; CODE XREF: sub_43E490+7Cj
    test    edi, edi
    jz      short loc_43EB63
    mov     dl, [edi+0FFh]
    mov     al, [ebx+2A42h]
    cmp     dl, al
    jnz     short loc_43EB63
    test    byte ptr [edi+110h], 20h
    jz      short loc_43EB63
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD2E8
    fnstsw  ax
    test    ah, 40h
    jz      short loc_43EB63
    mov     eax, [edi+0FBh]
    test    eax, eax
    jnz     short loc_43EB63
    mov     eax, [edi+86h]
    test    eax, eax
    jz      loc_43EE42
    test    dword ptr [eax+110h], 40000000h
    jz      short loc_43EB63
    mov     eax, 0Fh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EB63:                             ; CODE XREF: sub_43E490+674j
                                            ; sub_43E490+684j ...
    test    ebp, ebp
    jz      short loc_43EB74
    mov     eax, 11h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EB74:                             ; CODE XREF: sub_43E490+6D5j
    test    esi, esi
    jz      short loc_43EB85
    mov     eax, 12h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EB85:                             ; CODE XREF: sub_43E490+6E6j
    mov     eax, [ecx+245h]
    mov     esi, [esp+14h+arg_C]
    test    ah, 8
    jz      loc_43EC9A
    mov     eax, [esp+14h+arg_4]
    movsx   edi, word ptr [esi+6]
    mov     edx, [eax+96h]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    sar     edi, 1
    sub     eax, edi
    mov     edi, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, edi
    jnb     loc_43EC9A
    cmp     eax, [edx+84h]
    jnb     loc_43EC9A
    mov     edx, [edx+80h]
    xor     edi, edi
    imul    edx, eax
    mov     eax, [ebx+14273h]
    add     edx, ecx
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    mov     di, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, edi
    jz      loc_43EC9A
    push    esi                             ; int
    call    sub_4815A0
    mov     ebx, TAdynmemStructPtr
    test    eax, eax
    jnz     short loc_43EC12
    xor     eax, eax
    jmp     short loc_43EC80
    ; ---------------------------------------------------------------------------

    loc_43EC12:                             ; CODE XREF: sub_43E490+77Cj
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43EC3C
    mov     eax, [ebx+14253h]
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      short loc_43EC31
    xor     eax, eax
    jmp     short loc_43EC80
    ; ---------------------------------------------------------------------------

    loc_43EC31:                             ; CODE XREF: sub_43E490+79Bj
    mov     eax, [ebx+1426Fh]
    shl     ecx, 8
    jmp     short loc_43EC7E
    ; ---------------------------------------------------------------------------

    loc_43EC3C:                             ; CODE XREF: sub_43E490+78Bj
    cmp     cx, 0FFFEh
    jz      short loc_43EC47
    xor     eax, eax
    jmp     short loc_43EC80
    ; ---------------------------------------------------------------------------

    loc_43EC47:                             ; CODE XREF: sub_43E490+7B1j
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+0Ah]
    mov     dl, [eax+0Bh]
    imul    ecx, [ebx+14233h]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_43EC70
    xor     eax, eax
    jmp     short loc_43EC80
    ; ---------------------------------------------------------------------------

    loc_43EC70:                             ; CODE XREF: sub_43E490+7DAj
    mov     ecx, [ebx+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_43EC7E:                             ; CODE XREF: sub_43E490+7AAj
    add     eax, ecx

    loc_43EC80:                             ; CODE XREF: sub_43E490+780j
                                            ; sub_43E490+79Fj ...
    test    eax, eax
    jz      short loc_43EC9A
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_43EC9A
    mov     eax, 12h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EC9A:                             ; CODE XREF: sub_43E490+702j
                                            ; sub_43E490+730j ...
    mov     edx, [esp+14h+arg_8]
    mov     eax, [edx+245h]
    test    ah, 4
    jz      loc_43F098                      ; default
    mov     eax, [esp+14h+arg_4]
    movsx   edi, word ptr [esi+6]
    mov     edx, [eax+96h]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    sar     edi, 1
    sub     eax, edi
    mov     edi, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, edi
    jnb     loc_43F098                      ; default
    cmp     eax, [edx+84h]
    jnb     loc_43F098                      ; default
    mov     edx, [edx+80h]
    xor     edi, edi
    imul    edx, eax
    mov     eax, [ebx+14273h]
    add     edx, ecx
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    mov     di, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, edi
    jz      loc_43F098                      ; default
    push    esi                             ; int
    call    sub_4815A0
    test    eax, eax
    jz      short loc_43ED94
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43ED4A
    mov     eax, TAdynmemStructPtr
    and     ecx, 0FFFFh
    cmp     ecx, [eax+14253h]
    jl      short loc_43ED3F
    xor     eax, eax
    jmp     short loc_43ED94
    ; ---------------------------------------------------------------------------

    loc_43ED3F:                             ; CODE XREF: sub_43E490+8A9j
    mov     eax, [eax+1426Fh]
    shl     ecx, 8
    jmp     short loc_43ED92
    ; ---------------------------------------------------------------------------

    loc_43ED4A:                             ; CODE XREF: sub_43E490+896j
    cmp     cx, 0FFFEh
    jz      short loc_43ED55
    xor     eax, eax
    jmp     short loc_43ED94
    ; ---------------------------------------------------------------------------

    loc_43ED55:                             ; CODE XREF: sub_43E490+8BFj
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [eax+0Ah]
    xor     edx, edx
    imul    ecx, [esi+14233h]
    mov     dl, [eax+0Bh]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_43ED84
    xor     eax, eax
    jmp     short loc_43ED94
    ; ---------------------------------------------------------------------------

    loc_43ED84:                             ; CODE XREF: sub_43E490+8EEj
    mov     ecx, [esi+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_43ED92:                             ; CODE XREF: sub_43E490+8B8j
    add     eax, ecx

    loc_43ED94:                             ; CODE XREF: sub_43E490+88Bj
                                            ; sub_43E490+8ADj ...
    test    eax, eax
    jz      loc_43F098                      ; default
    test    byte ptr [eax+0FEh], 80h
    jz      loc_43F098                      ; default
    mov     eax, 12h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EDB6:                             ; CODE XREF: sub_43E490+9Dj
                                            ; sub_43E490+A5j
    test    edi, edi
    jz      loc_43EE4F
    mov     ecx, [esp+14h+arg_4]
    push    edi
    call    sub_4899B0
    test    eax, eax
    jz      short loc_43EDEC
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD2E8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_43EDEC
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EDEC:                             ; CODE XREF: sub_43E490+93Aj
                                            ; sub_43E490+94Dj
    mov     ebx, TAdynmemStructPtr
    test    edi, edi
    jz      short loc_43EE4F
    mov     dl, [edi+0FFh]
    mov     al, [ebx+2A42h]
    cmp     dl, al
    jnz     short loc_43EE4F
    test    byte ptr [edi+110h], 20h
    jz      short loc_43EE4F
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD2E8
    fnstsw  ax
    test    ah, 40h
    jz      short loc_43EE4F
    mov     eax, [edi+0FBh]
    test    eax, eax
    jnz     short loc_43EE4F
    mov     eax, [edi+86h]
    test    eax, eax
    jz      short loc_43EE42
    test    dword ptr [eax+110h], 40000000h
    jz      short loc_43EE4F

    loc_43EE42:                             ; CODE XREF: sub_43E490+6B4j
                                            ; sub_43E490+9A4j
    mov     eax, 0Fh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EE4F:                             ; CODE XREF: sub_43E490+928j
                                            ; sub_43E490+964j ...
    mov     edi, [esp+14h+arg_8]
    mov     esi, [esp+14h+arg_C]
    mov     eax, [edi+245h]
    test    ah, 8
    jz      loc_43EF6C
    mov     eax, [esp+14h+arg_4]
    movsx   ebp, word ptr [esi+6]
    mov     edx, [eax+96h]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    sar     ebp, 1
    sub     eax, ebp
    mov     ebp, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebp
    jnb     loc_43EF6C
    cmp     eax, [edx+84h]
    jnb     loc_43EF6C
    mov     edx, [edx+80h]
    xor     ebp, ebp
    imul    edx, eax
    mov     eax, [ebx+14273h]
    add     edx, ecx
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    mov     bp, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, ebp
    jz      loc_43EF6C
    push    esi                             ; int
    call    sub_4815A0
    mov     ebx, TAdynmemStructPtr
    test    eax, eax
    jnz     short loc_43EEE0
    xor     eax, eax
    jmp     short loc_43EF4E
    ; ---------------------------------------------------------------------------

    loc_43EEE0:                             ; CODE XREF: sub_43E490+A4Aj
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43EF0A
    mov     eax, [ebx+14253h]
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      short loc_43EEFF
    xor     eax, eax
    jmp     short loc_43EF4E
    ; ---------------------------------------------------------------------------

    loc_43EEFF:                             ; CODE XREF: sub_43E490+A69j
    mov     eax, [ebx+1426Fh]
    shl     ecx, 8
    jmp     short loc_43EF4C
    ; ---------------------------------------------------------------------------

    loc_43EF0A:                             ; CODE XREF: sub_43E490+A59j
    cmp     cx, 0FFFEh
    jz      short loc_43EF15
    xor     eax, eax
    jmp     short loc_43EF4E
    ; ---------------------------------------------------------------------------

    loc_43EF15:                             ; CODE XREF: sub_43E490+A7Fj
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+0Ah]
    mov     dl, [eax+0Bh]
    imul    ecx, [ebx+14233h]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_43EF3E
    xor     eax, eax
    jmp     short loc_43EF4E
    ; ---------------------------------------------------------------------------

    loc_43EF3E:                             ; CODE XREF: sub_43E490+AA8j
    mov     ecx, [ebx+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_43EF4C:                             ; CODE XREF: sub_43E490+A78j
    add     eax, ecx

    loc_43EF4E:                             ; CODE XREF: sub_43E490+A4Ej
                                            ; sub_43E490+A6Dj ...
    test    eax, eax
    jz      short loc_43EF68
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_43EF68
    mov     eax, 0Ah
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43EF68:                             ; CODE XREF: sub_43E490+AC0j
                                            ; sub_43E490+AC9j
    mov     edi, [esp+14h+arg_8]

    loc_43EF6C:                             ; CODE XREF: sub_43E490+9D0j
                                            ; sub_43E490+9FEj ...
    mov     eax, [edi+245h]
    test    ah, 4
    jz      loc_43F07C
    movsx   ebp, word ptr [esi+6]
    mov     edx, [esp+14h+arg_4]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    mov     edx, [edx+96h]
    sar     ebp, 1
    sub     eax, ebp
    mov     ebp, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebp
    jnb     loc_43F07C
    cmp     eax, [edx+84h]
    jnb     loc_43F07C
    mov     edx, [edx+80h]
    xor     ebp, ebp
    imul    edx, eax
    mov     eax, [ebx+14273h]
    add     edx, ecx
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    mov     bp, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, ebp
    jz      loc_43F07C
    push    esi                             ; int
    call    sub_4815A0
    test    eax, eax
    jz      short loc_43F062
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43F018
    mov     eax, TAdynmemStructPtr
    and     ecx, 0FFFFh
    cmp     ecx, [eax+14253h]
    jl      short loc_43F00D
    xor     eax, eax
    jmp     short loc_43F062
    ; ---------------------------------------------------------------------------

    loc_43F00D:                             ; CODE XREF: sub_43E490+B77j
    mov     eax, [eax+1426Fh]
    shl     ecx, 8
    jmp     short loc_43F060
    ; ---------------------------------------------------------------------------

    loc_43F018:                             ; CODE XREF: sub_43E490+B64j
    cmp     cx, 0FFFEh
    jz      short loc_43F023
    xor     eax, eax
    jmp     short loc_43F062
    ; ---------------------------------------------------------------------------

    loc_43F023:                             ; CODE XREF: sub_43E490+B8Dj
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [eax+0Ah]
    xor     edx, edx
    imul    ecx, [esi+14233h]
    mov     dl, [eax+0Bh]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_43F052
    xor     eax, eax
    jmp     short loc_43F062
    ; ---------------------------------------------------------------------------

    loc_43F052:                             ; CODE XREF: sub_43E490+BBCj
    mov     ecx, [esi+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_43F060:                             ; CODE XREF: sub_43E490+B86j
    add     eax, ecx

    loc_43F062:                             ; CODE XREF: sub_43E490+B59j
                                            ; sub_43E490+B7Bj ...
    test    eax, eax
    jz      short loc_43F07C
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_43F07C
    mov     eax, 0Bh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43F07C:                             ; CODE XREF: sub_43E490+AE5j
                                            ; sub_43E490+B13j ...
    mov     eax, [edi+245h]
    shr     eax, 7
    and     al, 1
    neg     al
    sbb     eax, eax
    and     al, 0FBh
    add     eax, 13h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_43F098:                             ; CODE XREF: sub_43E490+68j
                                            ; sub_43E490+6Ej ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 13h
    pop     ebx
    pop     ecx
    retn    10h
    sub_43E490 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_43F0A8 dd offset loc_43E505         ; DATA XREF: sub_43E490+6Er
    dd offset loc_43E8BB                    ; jump table for switch statement
    dd offset loc_43E545
    dd offset loc_43E850
    dd offset loc_43E80C
    dd offset loc_43E7D3
    dd offset loc_43E615
    dd offset loc_43E5FA
    dd offset loc_43E5DE
    dd offset loc_43F098
    dd offset loc_43E8AE
    dd offset loc_43E65C
    dd offset loc_43E797
    dd offset loc_43E828

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_43F0E0 proc near                    ; CODE XREF: .text:00401F2Fp
                                            ; .text:00402E3Dp ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h
    arg_C= dword ptr  18h
    arg_10= dword ptr  1Ch

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_8]
    push    esi
    push    edi
    mov     edi, [esp+8+arg_C]
    xor     ebx, ebx
    xor     eax, eax
    test    edi, edi
    jz      short loc_43F12D
    test    dword ptr [edi+110h], 10000000h
    jz      loc_4401DC                      ; default
    mov     ecx, [edi+96h]
    xor     edx, edx
    mov     dl, [ecx+146h]
    mov     ecx, [ebp+96h]
    cmp     [edx+ecx+108h], al
    jz      short loc_43F128
    mov     ebx, 1
    jmp     short loc_43F12D
    ; ---------------------------------------------------------------------------

    loc_43F128:                             ; CODE XREF: sub_43F0E0+3Fj
    mov     eax, 1

    loc_43F12D:                             ; CODE XREF: sub_43F0E0+12j
                                            ; sub_43F0E0+46j
    mov     edx, [esp+8+arg_4]
    mov     esi, [ebp+92h]
    and     edx, 0FFh
    mov     [esp+8+arg_C], esi
    lea     ecx, [edx-1]                    ; switch 14 cases
    cmp     ecx, 0Dh
    ja      loc_4401DC                      ; default
    jmp     ds:off_4401EC[ecx*4]            ; switch jump

    loc_43F154:                             ; DATA XREF: .text:004401ECo
    test    byte ptr [esi+245h], 10h        ; case 0x3
    jz      loc_4401DC                      ; default
    mov     ecx, [ebp+110h]
    mov     [esp+8+arg_8], ecx
    shr     ecx, 1Fh
    test    cl, 1
    jz      loc_43F38E
    mov     esi, [ebp+10h]
    test    eax, eax
    jnz     short loc_43F1D4
    mov     eax, [esi+111h]
    shr     eax, 11h
    test    al, 1
    jnz     loc_4401DC                      ; default
    mov     eax, [esp+8+arg_C]
    mov     ecx, [eax+241h]
    test    ch, 8
    jnz     short loc_43F1B7
    mov     esi, [esp+8+arg_0]
    push    offset aSuppress                ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F1B7:                             ; CODE XREF: sub_43F0E0+BCj
    mov     ecx, [eax+1EEh]
    mov     edx, [ecx+111h]
    shr     edx, 8
    test    dl, 1
    jz      loc_43F302
    jmp     loc_43F2B2
    ; ---------------------------------------------------------------------------

    loc_43F1D4:                             ; CODE XREF: sub_43F0E0+9Cj
    mov     eax, [edi+110h]
    and     eax, 3
    cmp     al, 2
    jz      short loc_43F1F1
    test    dword ptr [esi+111h], 20000h
    jnz     loc_4401DC                      ; default

    loc_43F1F1:                             ; CODE XREF: sub_43F0E0+FFj
    mov     edx, [edi+92h]
    movsx   ecx, word ptr [edi+70h]
    movsx   eax, word ptr [edx+170h]
    mov     edi, TAdynmemStructPtr
    add     eax, ecx
    xor     ecx, ecx
    mov     cl, [edi+1427Fh]
    mov     edi, 10000h
    cmp     eax, ecx
    jge     short loc_43F240
    test    [esi+111h], edi
    jnz     short loc_43F23C
    test    byte ptr [ebp+3Bh], 2
    jz      loc_4401DC                      ; default
    mov     ebx, [ebp+2Ch]
    test    [ebx+111h], edi
    jz      loc_4401DC                      ; default

    loc_43F23C:                             ; CODE XREF: sub_43F0E0+141j
    cmp     eax, ecx
    jl      short loc_43F27A

    loc_43F240:                             ; CODE XREF: sub_43F0E0+139j
    mov     eax, [esp+8+arg_C]
    mov     ecx, [eax+241h]
    test    ch, 10h
    jz      short loc_43F27E
    test    [esi+111h], edi
    jnz     loc_4401DC                      ; default
    test    byte ptr [ebp+3Bh], 2
    jz      short loc_43F27E
    mov     ecx, [ebp+2Ch]
    test    [ecx+111h], edi
    jz      short loc_43F27E
    mov     eax, [esp+8+arg_0]
    mov     byte ptr [eax], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F27A:                             ; CODE XREF: sub_43F0E0+15Ej
    mov     eax, [esp+8+arg_C]

    loc_43F27E:                             ; CODE XREF: sub_43F0E0+16Dj
                                            ; sub_43F0E0+17Fj ...
    mov     ecx, [eax+241h]
    mov     ebx, ecx
    shr     ebx, 0Bh
    test    bl, 1
    jz      loc_43F348
    mov     eax, [eax+1EEh]
    mov     esi, 800h
    mov     eax, [eax+111h]
    and     eax, 100h
    jz      short loc_43F2CB
    test    [edx+241h], esi
    jnz     short loc_43F2CB

    loc_43F2B2:                             ; CODE XREF: sub_43F0E0+EFj
    mov     esi, [esp+8+arg_0]
    push    offset aAirstrike               ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F2CB:                             ; CODE XREF: sub_43F0E0+1C8j
                                            ; sub_43F0E0+1D0j
    test    eax, eax
    jnz     short loc_43F2F0
    test    [edx+241h], esi
    jz      short loc_43F2F0
    mov     esi, [esp+8+arg_0]
    push    offset aAirtoair                ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F2F0:                             ; CODE XREF: sub_43F0E0+1EDj
                                            ; sub_43F0E0+1F5j
    mov     eax, [edx+241h]
    and     eax, esi
    jnz     short loc_43F31B
    test    ecx, 8000000h
    jnz     short loc_43F31B

    loc_43F302:                             ; CODE XREF: sub_43F0E0+E9j
    mov     esi, [esp+8+arg_0]
    push    offset aAirtoground             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F31B:                             ; CODE XREF: sub_43F0E0+218j
                                            ; sub_43F0E0+220j
    test    eax, eax
    jnz     loc_4401DC                      ; default
    test    ecx, 8000000h
    jz      loc_4401DC                      ; default
    mov     esi, [esp+8+arg_0]
    push    offset aAirtogroundhov          ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F348:                             ; CODE XREF: sub_43F0E0+1ACj
    cmp     dword ptr [ebp+0], 0
    jz      short loc_43F367
    mov     esi, [esp+8+arg_0]
    push    offset aAttack_chase            ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F367:                             ; CODE XREF: sub_43F0E0+26Cj
    test    [esp+8+arg_8], 20000000h
    jz      short loc_43F38A
    mov     esi, [esp+8+arg_0]
    push    offset aAttack_nomove           ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F38A:                             ; CODE XREF: sub_43F0E0+28Fj
    mov     esi, [esp+8+arg_C]

    loc_43F38E:                             ; CODE XREF: sub_43F0E0+91j
    mov     ecx, [esi+241h]
    shr     ecx, 1Ch
    test    cl, 1
    jz      loc_4401DC                      ; default
    mov     esi, [esp+8+arg_0]
    push    offset aAttack_kamikaz          ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F3B9:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     eax, [esi+245h]                 ; case 0x9
    test    al, 40h
    jz      loc_4401DC                      ; default
    cmp     dword ptr [ebp+0], 0
    jnz     short loc_43F3E6
    mov     esi, [esp+8+arg_0]
    push    offset aQpatrol                 ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F3E6:                             ; CODE XREF: sub_43F0E0+2EBj
    shr     eax, 9
    test    al, 1
    jz      short loc_43F42D
    mov     edx, [esi+241h]
    shr     edx, 0Bh
    test    dl, 1
    jz      short loc_43F414
    mov     esi, [esp+8+arg_0]
    push    offset aVtol_repairpat          ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F414:                             ; CODE XREF: sub_43F0E0+319j
    mov     esi, [esp+8+arg_0]
    push    offset aRepairpatrol            ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F42D:                             ; CODE XREF: sub_43F0E0+30Bj
    mov     eax, [esi+241h]
    shr     eax, 0Bh
    test    al, 1
    jz      short loc_43F453
    mov     esi, [esp+8+arg_0]
    push    offset aVtol_patrol             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F453:                             ; CODE XREF: sub_43F0E0+358j
    mov     esi, [esp+8+arg_0]
    push    offset aPatrol                  ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F46C:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    push    edi                             ; case 0x8
    mov     ecx, ebp
    call    sub_4899B0
    test    eax, eax
    jz      loc_4401DC                      ; default
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD2E8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_43F4AB
    mov     ecx, [esi+241h]
    mov     eax, offset aVtol_helpbuild     ; "VTOL_HELPBUILD"
    shr     ecx, 0Bh
    test    cl, 1
    jnz     loc_4401C7
    jmp     loc_43FA8C
    ; ---------------------------------------------------------------------------

    loc_43F4AB:                             ; CODE XREF: sub_43F0E0+3ADj
    mov     edx, [esi+241h]
    mov     eax, offset aVtol_repairuni     ; "VTOL_REPAIRUNIT"
    shr     edx, 0Bh
    test    dl, 1
    jnz     loc_4401C7
    jmp     loc_43FAD5
    ; ---------------------------------------------------------------------------

    loc_43F4C7:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    test    byte ptr [esi+245h], 20h        ; case 0x7
    jz      loc_4401DC                      ; default
    test    ebx, ebx
    jz      loc_4401DC                      ; default
    mov     eax, [esi+241h]
    shr     eax, 0Bh
    test    al, 1
    mov     eax, offset aVtol_follow        ; "VTOL_FOLLOW"
    jnz     loc_4401C7
    jmp     loc_43FBA9
    ; ---------------------------------------------------------------------------

    loc_43F4F7:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     eax, [esi+245h]                 ; case 0xc
    test    ah, 4
    jz      loc_4401DC                      ; default
    mov     esi, [esp+8+arg_10]
    push    esi                             ; int
    call    sub_4815A0
    mov     ebx, TAdynmemStructPtr
    test    eax, eax
    jnz     short loc_43F51E
    xor     eax, eax
    jmp     short loc_43F58C
    ; ---------------------------------------------------------------------------

    loc_43F51E:                             ; CODE XREF: sub_43F0E0+438j
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43F548
    mov     eax, [ebx+14253h]
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      short loc_43F53D
    xor     eax, eax
    jmp     short loc_43F58C
    ; ---------------------------------------------------------------------------

    loc_43F53D:                             ; CODE XREF: sub_43F0E0+457j
    mov     eax, [ebx+1426Fh]
    shl     ecx, 8
    jmp     short loc_43F58A
    ; ---------------------------------------------------------------------------

    loc_43F548:                             ; CODE XREF: sub_43F0E0+447j
    cmp     cx, 0FFFEh
    jz      short loc_43F553
    xor     eax, eax
    jmp     short loc_43F58C
    ; ---------------------------------------------------------------------------

    loc_43F553:                             ; CODE XREF: sub_43F0E0+46Dj
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+0Ah]
    mov     dl, [eax+0Bh]
    imul    ecx, [ebx+14233h]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_43F57C
    xor     eax, eax
    jmp     short loc_43F58C
    ; ---------------------------------------------------------------------------

    loc_43F57C:                             ; CODE XREF: sub_43F0E0+496j
    mov     ecx, [ebx+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_43F58A:                             ; CODE XREF: sub_43F0E0+466j
    add     eax, ecx

    loc_43F58C:                             ; CODE XREF: sub_43F0E0+43Cj
                                            ; sub_43F0E0+45Bj ...
    test    esi, esi
    mov     [esp+8+arg_10], eax
    jz      loc_43F6AA
    mov     edx, [esp+8+arg_C]
    mov     ecx, [edx+245h]
    test    ch, 8
    jz      short loc_43F61B
    mov     eax, [esp+8+arg_8]
    movsx   ecx, word ptr [esi+0Ah]
    mov     ebp, [eax+96h]
    movsx   eax, word ptr [esi+6]
    movsx   edx, word ptr [esi+2]
    sar     eax, 1
    sub     ecx, eax
    mov     eax, [ebp+80h]
    sar     edx, 5
    sar     ecx, 5
    cmp     edx, eax
    jnb     short loc_43F617
    cmp     ecx, [ebp+84h]
    jnb     short loc_43F617
    mov     eax, [ebp+80h]
    imul    eax, ecx
    mov     ecx, [ebx+14273h]
    add     eax, edx
    xor     edx, edx
    mov     dx, [ecx+eax*2]
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    mov     eax, 1
    shl     eax, cl
    test    eax, edx
    jz      short loc_43F617
    mov     eax, [esp+8+arg_10]
    test    eax, eax
    jz      short loc_43F61B
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_43F61B
    jmp     loc_44004C
    ; ---------------------------------------------------------------------------

    loc_43F617:                             ; CODE XREF: sub_43F0E0+4EFj
                                            ; sub_43F0E0+4F7j ...
    mov     eax, [esp+8+arg_10]

    loc_43F61B:                             ; CODE XREF: sub_43F0E0+4C5j
                                            ; sub_43F0E0+527j ...
    test    esi, esi
    jz      loc_43F6AA
    mov     ecx, [esp+8+arg_8]
    movsx   edx, word ptr [esi+2]
    mov     ebp, [ecx+96h]
    movsx   ecx, word ptr [esi+0Ah]
    movsx   esi, word ptr [esi+6]
    sar     esi, 1
    sub     ecx, esi
    mov     esi, [ebp+80h]
    sar     edx, 5
    sar     ecx, 5
    cmp     edx, esi
    jnb     short loc_43F6AA
    cmp     ecx, [ebp+84h]
    jnb     short loc_43F6AA
    mov     esi, [ebp+80h]
    xor     ebp, ebp
    imul    esi, ecx
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    add     esi, edx
    mov     edx, [ebx+14273h]
    mov     bp, [edx+esi*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, ebp
    jz      short loc_43F6AA
    test    eax, eax
    jz      short loc_43F6AA
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_43F6AA
    mov     eax, [esp+8+arg_C]
    mov     ecx, [eax+241h]
    mov     eax, offset aVtol_reclaim       ; "VTOL_RECLAIM"
    shr     ecx, 0Bh
    test    cl, 1
    jnz     loc_4401C7
    jmp     loc_440183
    ; ---------------------------------------------------------------------------

    loc_43F6AA:                             ; CODE XREF: sub_43F0E0+4B2j
                                            ; sub_43F0E0+53Dj ...
    test    edi, edi
    jz      loc_4401DC                      ; default
    mov     edx, [esp+8+arg_C]
    mov     eax, [edx+241h]
    shr     eax, 0Bh
    test    al, 1
    mov     eax, offset aVtol_reclaimun     ; "VTOL_RECLAIMUNIT"
    jnz     loc_4401C7
    jmp     loc_43FA33
    ; ---------------------------------------------------------------------------

    loc_43F6D1:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     eax, [esi+245h]                 ; case 0xd
    test    ah, 10h
    jz      loc_4401DC                      ; default
    test    edi, edi
    jz      loc_4401DC                      ; default
    mov     ecx, [ebp+96h]
    mov     eax, [edi+96h]
    cmp     ecx, eax
    jz      loc_4401DC                      ; default
    jmp     loc_43F89C
    ; ---------------------------------------------------------------------------

    loc_43F701:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    test    edi, edi                        ; case 0x6
    jz      loc_4401DC                      ; default
    push    edi
    mov     ecx, ebp
    call    sub_489A90
    test    eax, eax
    jz      loc_4401DC                      ; default
    mov     edx, [esi+241h]
    mov     eax, offset aVtol_pickup        ; "VTOL_PICKUP"
    shr     edx, 0Bh
    test    dl, 1
    jnz     loc_4401C7
    jmp     loc_43FB61
    ; ---------------------------------------------------------------------------

    loc_43F735:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     eax, [esi+245h]                 ; case 0x5
    test    ah, 1
    jz      short loc_43F764
    mov     ecx, [esi+241h]
    test    ch, 8
    jz      short loc_43F764
    test    edi, edi
    jz      short loc_43F764
    mov     ecx, [edi+92h]
    mov     edx, [ecx+241h]
    test    dh, 2
    jnz     loc_43FB1B

    loc_43F764:                             ; CODE XREF: sub_43F0E0+65Ej
                                            ; sub_43F0E0+669j ...
    shr     eax, 8
    test    al, 1
    jz      loc_4401DC                      ; default
    mov     edx, [esi+241h]
    mov     eax, offset aVtol_unload        ; "VTOL_UNLOAD"
    shr     edx, 0Bh
    test    dl, 1
    jnz     loc_4401C7
    mov     esi, [esp+8+arg_0]
    mov     eax, offset aGround_unload      ; "GROUND_UNLOAD"
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F7A0:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     eax, [esi+156h]                 ; case 0xe
    test    eax, eax
    jz      loc_4401DC                      ; default
    cmp     dword ptr [ebp+0], 0
    jz      loc_4401DC                      ; default
    mov     eax, [esi+241h]
    shr     eax, 0Bh
    test    al, 1
    mov     eax, offset aVtol_mobilebui     ; "VTOL_MOBILEBUILD"
    jnz     loc_4401C7
    mov     esi, [esp+8+arg_0]
    mov     eax, offset aMobilebuild        ; "MOBILEBUILD"
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F7E8:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     ecx, [esi+245h]                 ; case 0x4
    shr     ecx, 0Eh
    test    cl, 1
    jz      loc_4401DC                      ; default
    mov     esi, [esp+8+arg_0]
    push    offset aAttackspecial           ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F813:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     esi, [esp+8+arg_0]              ; case 0xb
    push    offset aTeleport                ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F82C:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     esi, [esp+8+arg_0]              ; case 0xa
    push    offset aStop                    ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F845:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     ecx, [esi+245h]                 ; case 0x2
    test    cl, 80h
    jz      loc_4401DC                      ; default
    cmp     dword ptr [ebp+0], 0
    jnz     short loc_43F873
    mov     esi, [esp+8+arg_0]
    push    offset aQmove                   ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F873:                             ; CODE XREF: sub_43F0E0+778j
    test    edi, edi
    jnz     short loc_43F893
    mov     edx, [esi+241h]
    mov     eax, offset aVtol_move          ; "VTOL_MOVE"
    shr     edx, 0Bh
    test    dl, 1
    jnz     loc_4401C7
    jmp     loc_4401C2
    ; ---------------------------------------------------------------------------

    loc_43F893:                             ; CODE XREF: sub_43F0E0+795j
    test    ch, 10h
    jz      short loc_43F8B5
    test    eax, eax
    jz      short loc_43F8B5

    loc_43F89C:                             ; CODE XREF: sub_43F0E0+61Cj
    mov     esi, [esp+8+arg_0]
    push    offset aCapture                 ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43F8B5:                             ; CODE XREF: sub_43F0E0+7B6j
                                            ; sub_43F0E0+7BAj
    test    ch, 4
    jz      short loc_43F8D9
    test    eax, eax
    jz      short loc_43F8D9
    mov     eax, [esi+241h]
    shr     eax, 0Bh
    test    al, 1
    mov     eax, offset aVtol_reclaimun     ; "VTOL_RECLAIMUNIT"
    jnz     loc_4401C7
    jmp     loc_43FA33
    ; ---------------------------------------------------------------------------

    loc_43F8D9:                             ; CODE XREF: sub_43F0E0+7D8j
                                            ; sub_43F0E0+7DCj
    test    ebx, ebx
    jz      short loc_43F959
    push    edi
    mov     ecx, ebp
    call    sub_4899B0
    test    eax, eax
    jz      short loc_43F918
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD2E8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_43F918
    mov     ecx, [esi+241h]
    mov     eax, offset aVtol_helpbuild     ; "VTOL_HELPBUILD"
    shr     ecx, 0Bh
    test    cl, 1
    jnz     loc_4401C7
    jmp     loc_43FA8C
    ; ---------------------------------------------------------------------------

    loc_43F918:                             ; CODE XREF: sub_43F0E0+807j
                                            ; sub_43F0E0+81Aj
    test    ebx, ebx
    jz      short loc_43F959
    push    edi
    mov     ecx, ebp
    call    sub_4899B0
    test    eax, eax
    jz      short loc_43F959
    mov     edx, [edi+92h]
    movsx   eax, word ptr [edi+108h]
    cmp     eax, [edx+1FAh]
    jnb     short loc_43F959
    mov     ecx, [esi+241h]
    mov     eax, offset aVtol_repairuni     ; "VTOL_REPAIRUNIT"
    shr     ecx, 0Bh
    test    cl, 1
    jnz     loc_4401C7
    jmp     loc_43FAD5
    ; ---------------------------------------------------------------------------

    loc_43F959:                             ; CODE XREF: sub_43F0E0+7FBj
                                            ; sub_43F0E0+83Aj ...
    mov     eax, [esi+241h]
    test    ah, 8
    jz      short loc_43F97D
    test    ebx, ebx
    jz      short loc_43F97D
    mov     edx, [edi+92h]
    mov     eax, [edx+241h]
    test    ah, 2
    jnz     loc_43FB1B

    loc_43F97D:                             ; CODE XREF: sub_43F0E0+882j
                                            ; sub_43F0E0+886j
    push    edi
    mov     ecx, ebp
    call    sub_489A90
    test    eax, eax
    jz      short loc_43F9A4
    mov     eax, [esi+241h]
    shr     eax, 0Bh
    test    al, 1
    mov     eax, offset aVtol_pickup        ; "VTOL_PICKUP"
    jnz     loc_4401C7
    jmp     loc_43FB61
    ; ---------------------------------------------------------------------------

    loc_43F9A4:                             ; CODE XREF: sub_43F0E0+8A7j
    test    byte ptr [esi+245h], 20h
    jz      short loc_43F9CD
    test    ebx, ebx
    jz      short loc_43F9CD
    mov     ecx, [esi+241h]
    mov     eax, offset aVtol_follow        ; "VTOL_FOLLOW"
    shr     ecx, 0Bh
    test    cl, 1
    jnz     loc_4401C7
    jmp     loc_43FBA9
    ; ---------------------------------------------------------------------------

    loc_43F9CD:                             ; CODE XREF: sub_43F0E0+8CBj
                                            ; sub_43F0E0+8CFj
    mov     edx, [esi+241h]
    mov     eax, offset aVtol_move          ; "VTOL_MOVE"
    shr     edx, 0Bh
    test    dl, 1
    jnz     loc_4401C7
    jmp     loc_4401C2
    ; ---------------------------------------------------------------------------

    loc_43F9E9:                             ; CODE XREF: sub_43F0E0+6Dj
                                            ; DATA XREF: .text:004401ECo
    mov     ebp, TAdynmemStructPtr          ; case 0x1
    cmp     dword ptr [ebp+37EFAh], 1
    jnz     loc_43FE35
    mov     esi, [esp+8+arg_C]
    mov     ecx, [esi+245h]
    test    cl, 10h
    jz      short loc_43FA13
    test    eax, eax
    jnz     loc_43FE48

    loc_43FA13:                             ; CODE XREF: sub_43F0E0+929j
    test    ch, 4
    jz      short loc_43FA4D
    test    eax, eax
    jz      short loc_43FA4D
    mov     edx, [esi+241h]
    mov     eax, offset aVtol_reclaimun     ; "VTOL_RECLAIMUNIT"
    shr     edx, 0Bh
    test    dl, 1
    jnz     loc_4401C7

    loc_43FA33:                             ; CODE XREF: sub_43F0E0+5ECj
                                            ; sub_43F0E0+7F4j
    mov     esi, [esp+8+arg_0]
    mov     eax, offset aReclaimunit        ; "RECLAIMUNIT"
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43FA4D:                             ; CODE XREF: sub_43F0E0+936j
                                            ; sub_43F0E0+93Aj
    test    ebx, ebx
    jz      loc_43FAF5
    mov     ecx, [esp+8+arg_8]
    push    edi
    call    sub_4899B0
    test    eax, eax
    jz      short loc_43FAA6
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD2E8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_43FAA6
    mov     eax, [esi+241h]
    shr     eax, 0Bh
    test    al, 1
    mov     eax, offset aVtol_helpbuild     ; "VTOL_HELPBUILD"
    jnz     loc_4401C7

    loc_43FA8C:                             ; CODE XREF: sub_43F0E0+3C6j
                                            ; sub_43F0E0+833j
    mov     esi, [esp+8+arg_0]
    mov     eax, offset aHelpbuild          ; "HELPBUILD"
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43FAA6:                             ; CODE XREF: sub_43F0E0+981j
                                            ; sub_43F0E0+994j
    mov     ebp, TAdynmemStructPtr
    test    ebx, ebx
    jz      short loc_43FAF5
    mov     ecx, [esp+8+arg_8]
    push    edi
    call    sub_4899B0
    test    eax, eax
    jz      short loc_43FAEF
    mov     ecx, [esi+241h]
    mov     eax, offset aVtol_repairuni     ; "VTOL_REPAIRUNIT"
    shr     ecx, 0Bh
    test    cl, 1
    jnz     loc_4401C7

    loc_43FAD5:                             ; CODE XREF: sub_43F0E0+3E2j
                                            ; sub_43F0E0+874j
    mov     esi, [esp+8+arg_0]
    mov     eax, offset aRepairunit         ; "REPAIRUNIT"
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43FAEF:                             ; CODE XREF: sub_43F0E0+9DCj
    mov     ebp, TAdynmemStructPtr

    loc_43FAF5:                             ; CODE XREF: sub_43F0E0+96Fj
                                            ; sub_43F0E0+9CEj
    mov     edx, [esp+8+arg_C]
    mov     esi, 800h
    test    [edx+241h], esi
    jz      short loc_43FB34
    test    ebx, ebx
    jz      short loc_43FB34
    mov     eax, [edi+92h]
    mov     ecx, [eax+241h]
    test    ch, 2
    jz      short loc_43FB34

    loc_43FB1B:                             ; CODE XREF: sub_43F0E0+67Ej
                                            ; sub_43F0E0+897j
    mov     esi, [esp+8+arg_0]
    push    offset aVtol_landing            ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43FB34:                             ; CODE XREF: sub_43F0E0+A24j
                                            ; sub_43F0E0+A28j ...
    test    edi, edi
    jz      short loc_43FB81
    mov     ecx, [esp+8+arg_8]
    push    edi
    call    sub_489A90
    test    eax, eax
    jz      short loc_43FB7B
    mov     ecx, [esp+8+arg_C]
    mov     eax, offset aVtol_pickup        ; "VTOL_PICKUP"
    mov     edx, [ecx+241h]
    shr     edx, 0Bh
    test    dl, 1
    jnz     loc_4401C7

    loc_43FB61:                             ; CODE XREF: sub_43F0E0+650j
                                            ; sub_43F0E0+8BFj
    mov     esi, [esp+8+arg_0]
    mov     eax, offset aGround_pickup      ; "GROUND_PICKUP"
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43FB7B:                             ; CODE XREF: sub_43F0E0+A64j
    mov     ebp, TAdynmemStructPtr

    loc_43FB81:                             ; CODE XREF: sub_43F0E0+A56j
    mov     ecx, [esp+8+arg_C]
    mov     eax, [ecx+245h]
    test    al, 20h
    jz      short loc_43FBC3
    test    ebx, ebx
    jz      short loc_43FBC3
    mov     eax, [ecx+241h]
    shr     eax, 0Bh
    test    al, 1
    mov     eax, offset aVtol_follow        ; "VTOL_FOLLOW"
    jnz     loc_4401C7

    loc_43FBA9:                             ; CODE XREF: sub_43F0E0+412j
                                            ; sub_43F0E0+8E8j
    mov     esi, [esp+8+arg_0]
    mov     eax, offset aFollow_ground      ; "FOLLOW_GROUND"
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43FBC3:                             ; CODE XREF: sub_43F0E0+AADj
                                            ; sub_43F0E0+AB1j
    test    esi, eax
    mov     esi, [esp+8+arg_10]
    jz      loc_43FCD1
    test    esi, esi
    jz      loc_43FCD1
    movsx   ebx, word ptr [esi+6]
    mov     edi, [esp+8+arg_8]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    mov     edx, [edi+96h]
    sar     ebx, 1
    sub     eax, ebx
    mov     ebx, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebx
    jnb     loc_43FCD5
    cmp     eax, [edx+84h]
    jnb     loc_43FCD5
    mov     edx, [edx+80h]
    xor     ebx, ebx
    imul    edx, eax
    mov     eax, [ebp+14273h]
    add     edx, ecx
    mov     cl, [ebp+TAdynmemStruct.LOS_Sight]
    mov     bx, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, ebx
    jz      loc_43FCD5
    push    esi                             ; int
    call    sub_4815A0
    mov     ebp, TAdynmemStructPtr
    test    eax, eax
    jnz     short loc_43FC51
    xor     eax, eax
    jmp     short loc_43FCBF
    ; ---------------------------------------------------------------------------

    loc_43FC51:                             ; CODE XREF: sub_43F0E0+B6Bj
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43FC7B
    mov     eax, [ebp+14253h]
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      short loc_43FC70
    xor     eax, eax
    jmp     short loc_43FCBF
    ; ---------------------------------------------------------------------------

    loc_43FC70:                             ; CODE XREF: sub_43F0E0+B8Aj
    mov     eax, [ebp+1426Fh]
    shl     ecx, 8
    jmp     short loc_43FCBD
    ; ---------------------------------------------------------------------------

    loc_43FC7B:                             ; CODE XREF: sub_43F0E0+B7Aj
    cmp     cx, 0FFFEh
    jz      short loc_43FC86
    xor     eax, eax
    jmp     short loc_43FCBF
    ; ---------------------------------------------------------------------------

    loc_43FC86:                             ; CODE XREF: sub_43F0E0+BA0j
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+0Ah]
    mov     dl, [eax+0Bh]
    imul    ecx, [ebp+14233h]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_43FCAF
    xor     eax, eax
    jmp     short loc_43FCBF
    ; ---------------------------------------------------------------------------

    loc_43FCAF:                             ; CODE XREF: sub_43F0E0+BC9j
    mov     ecx, [ebp+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_43FCBD:                             ; CODE XREF: sub_43F0E0+B99j
    add     eax, ecx

    loc_43FCBF:                             ; CODE XREF: sub_43F0E0+B6Fj
                                            ; sub_43F0E0+B8Ej ...
    test    eax, eax
    jz      short loc_43FCD5
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_43FCD5
    jmp     loc_44004C
    ; ---------------------------------------------------------------------------

    loc_43FCD1:                             ; CODE XREF: sub_43F0E0+AE9j
                                            ; sub_43F0E0+AF1j
    mov     edi, [esp+8+arg_8]

    loc_43FCD5:                             ; CODE XREF: sub_43F0E0+B1Fj
                                            ; sub_43F0E0+B2Bj ...
    mov     edx, [esp+8+arg_C]
    mov     eax, [edx+245h]
    test    ah, 4
    jz      loc_43FDFF
    test    esi, esi
    jz      loc_43FDFF
    movsx   ebx, word ptr [esi+6]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    mov     edx, [edi+96h]
    sar     ebx, 1
    sub     eax, ebx
    mov     ebx, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebx
    jnb     loc_43FDFF
    cmp     eax, [edx+84h]
    jnb     loc_43FDFF
    mov     edx, [edx+80h]
    xor     ebx, ebx
    imul    edx, eax
    mov     eax, [ebp+14273h]
    add     edx, ecx
    mov     cl, [ebp+TAdynmemStruct.LOS_Sight]
    mov     bx, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, ebx
    jz      loc_43FDFF
    push    esi                             ; int
    call    sub_4815A0
    test    eax, eax
    jz      short loc_43FDD3
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43FD89
    mov     eax, TAdynmemStructPtr
    and     ecx, 0FFFFh
    cmp     ecx, [eax+14253h]
    jl      short loc_43FD7E
    xor     eax, eax
    jmp     short loc_43FDD3
    ; ---------------------------------------------------------------------------

    loc_43FD7E:                             ; CODE XREF: sub_43F0E0+C98j
    mov     eax, [eax+1426Fh]
    shl     ecx, 8
    jmp     short loc_43FDD1
    ; ---------------------------------------------------------------------------

    loc_43FD89:                             ; CODE XREF: sub_43F0E0+C85j
    cmp     cx, 0FFFEh
    jz      short loc_43FD94
    xor     eax, eax
    jmp     short loc_43FDD3
    ; ---------------------------------------------------------------------------

    loc_43FD94:                             ; CODE XREF: sub_43F0E0+CAEj
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [eax+0Ah]
    xor     edx, edx
    imul    ecx, [esi+14233h]
    mov     dl, [eax+0Bh]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_43FDC3
    xor     eax, eax
    jmp     short loc_43FDD3
    ; ---------------------------------------------------------------------------

    loc_43FDC3:                             ; CODE XREF: sub_43F0E0+CDDj
    mov     ecx, [esi+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_43FDD1:                             ; CODE XREF: sub_43F0E0+CA7j
    add     eax, ecx

    loc_43FDD3:                             ; CODE XREF: sub_43F0E0+C7Aj
                                            ; sub_43F0E0+C9Cj ...
    test    eax, eax
    jz      short loc_43FDFF
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_43FDFF
    mov     edx, [esp+8+arg_C]
    mov     eax, [edx+241h]
    shr     eax, 0Bh
    test    al, 1
    mov     eax, offset aVtol_reclaim       ; "VTOL_RECLAIM"
    jnz     loc_4401C7
    jmp     loc_440183
    ; ---------------------------------------------------------------------------

    loc_43FDFF:                             ; CODE XREF: sub_43F0E0+C02j
                                            ; sub_43F0E0+C0Aj ...
    mov     eax, [esp+8+arg_C]
    test    byte ptr [eax+245h], 80h
    jz      loc_4401DC                      ; default
    cmp     dword ptr [edi], 0
    jz      loc_4401DC                      ; default
    mov     ecx, [eax+241h]
    mov     eax, offset aVtol_move          ; "VTOL_MOVE"
    shr     ecx, 0Bh
    test    cl, 1
    jnz     loc_4401C7
    jmp     loc_4401C2
    ; ---------------------------------------------------------------------------

    loc_43FE35:                             ; CODE XREF: sub_43F0E0+916j
    mov     edx, [esp+8+arg_C]
    mov     ecx, [edx+245h]
    test    cl, 10h
    jz      short loc_43FE68
    test    eax, eax
    jz      short loc_43FE68

    loc_43FE48:                             ; CODE XREF: sub_43F0E0+92Dj
    mov     eax, [esp+8+arg_10]
    mov     ecx, [esp+8+arg_8]
    mov     esi, [esp+8+arg_0]
    push    eax
    push    edi
    push    ecx
    push    3
    push    esi
    call    sub_43F0E0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43FE68:                             ; CODE XREF: sub_43F0E0+D62j
                                            ; sub_43F0E0+D66j
    test    ch, 4
    jz      short loc_43FE91
    test    eax, eax
    jz      short loc_43FE91
    mov     edx, [esp+8+arg_10]
    mov     eax, [esp+8+arg_8]
    mov     esi, [esp+8+arg_0]
    push    edx
    push    edi
    push    eax
    push    0Ch
    push    esi
    call    sub_43F0E0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43FE91:                             ; CODE XREF: sub_43F0E0+D8Bj
                                            ; sub_43F0E0+D8Fj
    test    edi, edi
    jz      loc_43FF38
    mov     ecx, [esp+8+arg_8]
    push    edi
    call    sub_4899B0
    test    eax, eax
    jz      short loc_43FEDA
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD2E8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_43FEDA
    mov     ecx, [esp+8+arg_10]
    mov     edx, [esp+8+arg_8]
    mov     esi, [esp+8+arg_0]
    push    ecx
    push    edi
    push    edx
    push    8
    push    esi
    call    sub_43F0E0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_43FEDA:                             ; CODE XREF: sub_43F0E0+DC5j
                                            ; sub_43F0E0+DD8j
    mov     ebp, TAdynmemStructPtr
    test    edi, edi
    jz      short loc_43FF38
    mov     al, [edi+0FFh]
    mov     cl, [ebp+2A42h]
    cmp     al, cl
    jnz     short loc_43FF38
    test    byte ptr [edi+110h], 20h
    jz      short loc_43FF38
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD2E8
    fnstsw  ax
    test    ah, 40h
    jz      short loc_43FF38
    mov     eax, [edi+0FBh]
    test    eax, eax
    jnz     short loc_43FF38
    mov     edi, [edi+86h]
    test    edi, edi
    jz      loc_4401DC                      ; default
    test    dword ptr [edi+110h], 40000000h
    jnz     loc_4401DC                      ; default

    loc_43FF38:                             ; CODE XREF: sub_43F0E0+DB3j
                                            ; sub_43F0E0+E02j ...
    mov     edi, [esp+8+arg_C]
    mov     esi, [esp+8+arg_10]
    mov     eax, [edi+245h]
    test    ah, 8
    jz      loc_440065
    test    esi, esi
    jz      loc_440065
    mov     ecx, [esp+8+arg_8]
    movsx   ebx, word ptr [esi+6]
    mov     edx, [ecx+96h]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    sar     ebx, 1
    sub     eax, ebx
    mov     ebx, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebx
    jnb     loc_440065
    cmp     eax, [edx+84h]
    jnb     loc_440065
    mov     edx, [edx+80h]
    xor     ebx, ebx
    imul    edx, eax
    mov     eax, [ebp+14273h]
    add     edx, ecx
    mov     cl, [ebp+TAdynmemStruct.LOS_Sight]
    mov     bx, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, ebx
    jz      loc_440065
    push    esi                             ; int
    call    sub_4815A0
    mov     ebp, TAdynmemStructPtr
    test    eax, eax
    jnz     short loc_43FFD1
    xor     eax, eax
    jmp     short loc_44003F
    ; ---------------------------------------------------------------------------

    loc_43FFD1:                             ; CODE XREF: sub_43F0E0+EEBj
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_43FFFB
    mov     eax, [ebp+14253h]
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      short loc_43FFF0
    xor     eax, eax
    jmp     short loc_44003F
    ; ---------------------------------------------------------------------------

    loc_43FFF0:                             ; CODE XREF: sub_43F0E0+F0Aj
    mov     eax, [ebp+1426Fh]
    shl     ecx, 8
    jmp     short loc_44003D
    ; ---------------------------------------------------------------------------

    loc_43FFFB:                             ; CODE XREF: sub_43F0E0+EFAj
    cmp     cx, 0FFFEh
    jz      short loc_440006
    xor     eax, eax
    jmp     short loc_44003F
    ; ---------------------------------------------------------------------------

    loc_440006:                             ; CODE XREF: sub_43F0E0+F20j
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+0Ah]
    mov     dl, [eax+0Bh]
    imul    ecx, [ebp+14233h]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_44002F
    xor     eax, eax
    jmp     short loc_44003F
    ; ---------------------------------------------------------------------------

    loc_44002F:                             ; CODE XREF: sub_43F0E0+F49j
    mov     ecx, [ebp+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_44003D:                             ; CODE XREF: sub_43F0E0+F19j
    add     eax, ecx

    loc_44003F:                             ; CODE XREF: sub_43F0E0+EEFj
                                            ; sub_43F0E0+F0Ej ...
    test    eax, eax
    jz      short loc_440065
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_440065

    loc_44004C:                             ; CODE XREF: sub_43F0E0+532j
                                            ; sub_43F0E0+BECj
    mov     esi, [esp+8+arg_0]
    push    offset aResurrect               ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_440065:                             ; CODE XREF: sub_43F0E0+E69j
                                            ; sub_43F0E0+E71j ...
    mov     eax, [edi+245h]
    test    ah, 4
    jz      loc_44019D
    test    esi, esi
    jz      loc_44019D
    movsx   ebx, word ptr [esi+6]
    mov     edx, [esp+8+arg_8]
    movsx   eax, word ptr [esi+0Ah]
    movsx   ecx, word ptr [esi+2]
    mov     edx, [edx+96h]
    sar     ebx, 1
    sub     eax, ebx
    mov     ebx, [edx+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebx
    jnb     loc_44019D
    cmp     eax, [edx+84h]
    jnb     loc_44019D
    mov     edx, [edx+80h]
    xor     ebx, ebx
    imul    edx, eax
    mov     eax, [ebp+14273h]
    add     edx, ecx
    mov     cl, [ebp+TAdynmemStruct.LOS_Sight]
    mov     bx, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    test    edx, ebx
    jz      loc_44019D
    push    esi                             ; int
    call    sub_4815A0
    test    eax, eax
    jz      short loc_440163
    mov     cx, [eax+8]
    cmp     cx, 0FFFBh
    jnb     short loc_440119
    mov     eax, TAdynmemStructPtr
    and     ecx, 0FFFFh
    cmp     ecx, [eax+14253h]
    jl      short loc_44010E
    xor     eax, eax
    jmp     short loc_440163
    ; ---------------------------------------------------------------------------

    loc_44010E:                             ; CODE XREF: sub_43F0E0+1028j
    mov     eax, [eax+1426Fh]
    shl     ecx, 8
    jmp     short loc_440161
    ; ---------------------------------------------------------------------------

    loc_440119:                             ; CODE XREF: sub_43F0E0+1015j
    cmp     cx, 0FFFEh
    jz      short loc_440124
    xor     eax, eax
    jmp     short loc_440163
    ; ---------------------------------------------------------------------------

    loc_440124:                             ; CODE XREF: sub_43F0E0+103Ej
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [eax+0Ah]
    xor     edx, edx
    imul    ecx, [esi+14233h]
    mov     dl, [eax+0Bh]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    sub     eax, ecx
    mov     ax, [eax+8]
    cmp     ax, 0FFFBh
    jb      short loc_440153
    xor     eax, eax
    jmp     short loc_440163
    ; ---------------------------------------------------------------------------

    loc_440153:                             ; CODE XREF: sub_43F0E0+106Dj
    mov     ecx, [esi+1426Fh]
    and     eax, 0FFFFh
    shl     eax, 8

    loc_440161:                             ; CODE XREF: sub_43F0E0+1037j
    add     eax, ecx

    loc_440163:                             ; CODE XREF: sub_43F0E0+100Aj
                                            ; sub_43F0E0+102Cj ...
    test    eax, eax
    jz      short loc_44019D
    test    byte ptr [eax+0FEh], 80h
    jz      short loc_44019D
    mov     edx, [edi+241h]
    mov     eax, offset aVtol_reclaim       ; "VTOL_RECLAIM"
    shr     edx, 0Bh
    test    dl, 1
    jnz     short loc_4401C7

    loc_440183:                             ; CODE XREF: sub_43F0E0+5C5j
                                            ; sub_43F0E0+D1Aj
    mov     esi, [esp+8+arg_0]
    mov     eax, offset aReclaim            ; "RECLAIM"
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_44019D:                             ; CODE XREF: sub_43F0E0+F8Ej
                                            ; sub_43F0E0+F96j ...
    test    byte ptr [edi+245h], 80h
    jz      short loc_4401DC                ; default
    mov     eax, [esp+8+arg_8]
    cmp     dword ptr [eax], 0
    jz      short loc_4401DC                ; default
    mov     ecx, [edi+241h]
    mov     eax, offset aVtol_move          ; "VTOL_MOVE"
    shr     ecx, 0Bh
    test    cl, 1
    jnz     short loc_4401C7

    loc_4401C2:                             ; CODE XREF: sub_43F0E0+7AEj
                                            ; sub_43F0E0+904j ...
    mov     eax, offset aMove_ground        ; "MOVE_GROUND"

    loc_4401C7:                             ; CODE XREF: sub_43F0E0+3C0j
                                            ; sub_43F0E0+3DCj ...
    mov     esi, [esp+8+arg_0]
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_438760
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4401DC:                             ; CODE XREF: sub_43F0E0+1Ej
                                            ; sub_43F0E0+67j ...
    mov     eax, [esp+8+arg_0]              ; default
    pop     edi
    pop     esi
    pop     ebp
    mov     byte ptr [eax], 0
    pop     ebx
    retn    14h
    sub_43F0E0 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4401EC dd offset loc_43F9E9         ; DATA XREF: sub_43F0E0+6Dr
    dd offset loc_43F845                    ; jump table for switch statement
    dd offset loc_43F154
    dd offset loc_43F7E8
    dd offset loc_43F735
    dd offset loc_43F701
    dd offset loc_43F4C7
    dd offset loc_43F46C
    dd offset loc_43F3B9
    dd offset loc_43F82C
    dd offset loc_43F813
    dd offset loc_43F4F7
    dd offset loc_43F6D1
    dd offset loc_43F7A0
    align 10h
    push    ebx
    push    esi
    push    edi
    mov     eax, offset dword_51235E
    mov     esi, 20h
    xor     ecx, ecx
    mov     ebx, 2710h
    mov     edi, 0FFFFD8F0h
    mov     dl, 0FFh

    loc_44024B:                             ; CODE XREF: .text:00440279j
    mov     [eax-6], ecx
    mov     [eax-2], cx
    mov     [eax], cx
    mov     [eax+2], bx
    mov     [eax+4], di
    mov     [eax+6], dl
    mov     [eax+8], dl
    mov     [eax+7], dl
    mov     [eax+9], dl
    mov     [eax+0Ah], ecx
    mov     [eax+0Eh], ecx
    mov     [eax+12h], ecx
    mov     [eax+16h], ecx
    add     eax, 20h
    dec     esi
    jnz     short loc_44024B
    push    offset loc_440290
    call    _atexit
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    loc_440290:                             ; DATA XREF: .text:0044027Bo
    mov     cl, byte_512758
    mov     al, 1
    test    al, cl
    jnz     short locret_4402D0
    push    edi
    or      cl, al
    push    esi
    mov     byte_512758, cl
    mov     esi, offset byte_512758
    mov     edi, 20h

    loc_4402B0:                             ; CODE XREF: .text:004402CCj
    mov     eax, [esi-20h]
    sub     esi, 20h
    push    eax
    call    sub_4D85A0
    mov     ecx, [esi+18h]
    add     esp, 4
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    dec     edi
    jnz     short loc_4402B0
    pop     esi
    pop     edi

    locret_4402D0:                          ; CODE XREF: .text:0044029Aj
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4402E0 proc near                    ; CODE XREF: sub_42BF40+DF6p
    mov     eax, ecx
    mov     dl, 0FFh
    xor     ecx, ecx
    mov     [eax], ecx
    mov     [eax+4], cx
    mov     [eax+6], cx
    mov     word ptr [eax+8], 2710h
    mov     word ptr [eax+0Ah], 0D8F0h
    mov     [eax+0Ch], dl
    mov     [eax+0Eh], dl
    mov     [eax+0Dh], dl
    mov     [eax+0Fh], dl
    mov     [eax+10h], ecx
    mov     [eax+14h], ecx
    mov     [eax+18h], ecx
    mov     [eax+1Ch], ecx
    retn
    sub_4402E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440320 proc near                    ; CODE XREF: sub_42BF40+120Fp
    push    esi
    mov     esi, ecx
    mov     eax, [esi]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, [esi+18h]
    add     esp, 4
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    pop     esi
    retn
    sub_440320 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440340 proc near                    ; CODE XREF: sub_42BF40+E11p
                                            ; sub_42D2E0+BBp

    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    0                               ; int
    mov     ecx, [edi+4]
    push    offset aFootprintx_0            ; char *
    call    sub_4C46C0
    mov     [esi+4], ax
    mov     ecx, [edi+4]
    push    0                               ; int
    push    offset aFootprintz_0            ; char *
    call    sub_4C46C0
    mov     [esi+6], ax
    mov     ecx, [edi+4]
    movsx   eax, word ptr [esi+8]
    push    eax                             ; int
    push    offset aMaxwaterdepth           ; char *
    call    sub_4C46C0
    movsx   ecx, word ptr [esi+0Ah]
    mov     [esi+8], ax
    push    ecx                             ; int
    mov     ecx, [edi+4]
    push    offset aMinwaterdepth           ; char *
    call    sub_4C46C0
    xor     edx, edx
    mov     [esi+0Ah], ax
    mov     dl, [esi+0Ch]
    mov     ecx, [edi+4]
    push    edx                             ; int
    push    offset aMaxslope                ; char *
    call    sub_4C46C0
    mov     [esi+0Ch], al
    mov     ecx, [edi+4]
    and     eax, 0FFh
    shr     eax, 1
    push    eax                             ; int
    push    offset aBadslope                ; char *
    call    sub_4C46C0
    mov     [esi+0Dh], al
    mov     ecx, [edi+4]
    xor     eax, eax
    mov     al, [esi+0Eh]
    push    eax                             ; int
    push    offset aMaxwaterslope           ; char *
    call    sub_4C46C0
    mov     [esi+0Eh], al
    mov     ecx, [edi+4]
    and     eax, 0FFh
    shr     eax, 1
    push    eax                             ; int
    push    offset aBadwaterslope           ; char *
    call    sub_4C46C0
    mov     cl, [esi+0Eh]
    mov     dl, [esi+0Ch]
    cmp     dl, cl
    mov     [esi+0Fh], al
    jbe     short loc_440404
    mov     [esi+0Ch], cl

    loc_440404:                             ; CODE XREF: sub_440340+BFj
    mov     dl, [esi+0Ch]
    mov     bl, [esi+0Dh]
    cmp     bl, dl
    jbe     short loc_440411
    mov     [esi+0Dh], dl

    loc_440411:                             ; CODE XREF: sub_440340+CCj
    cmp     al, cl
    jbe     short loc_440418
    mov     [esi+0Fh], cl

    loc_440418:                             ; CODE XREF: sub_440340+D3j
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_440340 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_440420(char *)
    sub_440420 proc near                    ; CODE XREF: sub_42BF40+DE4p

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    push    edi
    xor     edi, edi
    mov     esi, offset dword_512358

    loc_44042E:                             ; CODE XREF: sub_440420+2Cj
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_440442
    push    ebx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_440456

    loc_440442:                             ; CODE XREF: sub_440420+12j
    add     esi, 20h
    inc     edi
    cmp     esi, offset byte_512758
    jl      short loc_44042E
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_440456:                             ; CODE XREF: sub_440420+20j
    mov     eax, edi
    shl     eax, 5
    add     eax, offset dword_512358
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_440420 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    push    edi
    mov     eax, [esp+0Ch]
    mov     edi, ecx
    mov     ecx, [esp+10h]
    mov     [edi+10h], eax
    mov     [edi+14h], ecx
    lea     esi, [ecx+0Fh]
    shr     esi, 4
    imul    esi, eax
    mov     eax, [edi+18h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    test    esi, esi
    jz      short loc_4404B3
    lea     ecx, ds:0[esi*4]
    push    ecx
    call    sub_4B4F10
    add     esp, 4
    mov     [edi+18h], eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4404B3:                             ; CODE XREF: .text:00440499j
    mov     dword ptr [edi+18h], 0
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+8]
    mov     edx, ecx
    mov     ecx, eax
    push    esi
    sar     eax, 4
    imul    eax, [edx+10h]
    mov     esi, [esp+8]
    mov     edx, [edx+18h]
    and     ecx, 0Fh
    add     eax, esi
    shl     ecx, 1
    mov     esi, 3
    lea     eax, [edx+eax*4]
    mov     edx, [esp+10h]
    shl     esi, cl
    shl     edx, cl
    mov     ecx, [eax]
    not     esi
    and     esi, ecx
    or      edx, esi
    pop     esi
    mov     [eax], edx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440500 proc near                    ; CODE XREF: sub_440940+84p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 14h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    movsx   eax, word ptr [esi+6]
    mov     ecx, [esi+14h]
    movsx   edx, word ptr [esi+4]
    add     eax, ecx
    mov     ecx, [esi+10h]
    add     ecx, edx
    cmp     ecx, eax
    jbe     short loc_440521
    mov     eax, ecx

    loc_440521:                             ; CODE XREF: sub_440500+1Dj
    add     eax, 3
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esi+14h]
    mov     [esp+28h+var_4], eax
    lea     edi, [eax+2]
    add     esp, 4
    xor     eax, eax
    test    ecx, ecx
    mov     [esp+24h+var_C], eax
    jbe     loc_4406AA

    loc_440545:                             ; CODE XREF: sub_440500+1A4j
    mov     ecx, [esi+10h]
    xor     ebx, ebx
    imul    eax, ecx
    lea     edx, [eax+eax*2]
    lea     ebp, [eax+edx*4]
    mov     eax, TAdynmemStructPtr
    add     ebp, [eax+14287h]
    test    ecx, ecx
    jbe     short loc_440577

    loc_440562:                             ; CODE XREF: sub_440500+75j
    push    ebp
    push    esi
    call    sub_47DE60
    mov     [edi+ebx], al
    mov     eax, [esi+10h]
    inc     ebx
    add     ebp, 0Dh
    cmp     ebx, eax
    jb      short loc_440562

    loc_440577:                             ; CODE XREF: sub_440500+60j
    xor     eax, eax
    mov     byte ptr [edi-2], 0
    mov     byte ptr [edi-1], 0
    cmp     [esi+4], ax
    jl      short loc_44059A

    loc_440587:                             ; CODE XREF: sub_440500+98j
    mov     edx, [esi+10h]
    lea     ecx, [edi+eax]
    inc     eax
    mov     byte ptr [ecx+edx], 0
    movsx   ecx, word ptr [esi+4]
    cmp     eax, ecx
    jle     short loc_440587

    loc_44059A:                             ; CODE XREF: sub_440500+85j
    mov     eax, [esi+10h]
    xor     bl, bl
    xor     ebp, ebp
    mov     byte ptr [esp+24h+var_14], bl
    test    eax, eax
    jbe     loc_440696
    mov     ecx, 1
    mov     eax, edi
    sub     ecx, edi
    mov     [esp+24h+var_10], eax
    mov     [esp+24h+var_8], ecx
    jmp     short loc_4405C8
    ; ---------------------------------------------------------------------------

    loc_4405C0:                             ; CODE XREF: sub_440500+190j
    mov     bl, byte ptr [esp+24h+var_14]
    mov     eax, [esp+24h+var_10]

    loc_4405C8:                             ; CODE XREF: sub_440500+BEj
    movsx   edx, word ptr [esi+4]
    lea     edx, [ebp+edx-1]
    mov     cl, [edx+edi]
    cmp     cl, bl
    ja      short loc_4405DF
    mov     bl, cl
    mov     byte ptr [esp+24h+var_14], bl
    jmp     short loc_44060A
    ; ---------------------------------------------------------------------------

    loc_4405DF:                             ; CODE XREF: sub_440500+D5j
    cmp     [eax-1], bl
    ja      short loc_44060A
    mov     ecx, [esp+24h+var_8]
    mov     bl, [eax]
    add     eax, ecx
    mov     byte ptr [esp+24h+var_14], bl
    cmp     eax, edx
    jg      short loc_440606

    loc_4405F4:                             ; CODE XREF: sub_440500+104j
    mov     cl, [eax+edi]
    cmp     bl, cl
    jb      short loc_440601
    mov     bl, cl
    mov     byte ptr [esp+24h+var_14], bl

    loc_440601:                             ; CODE XREF: sub_440500+F9j
    inc     eax
    cmp     eax, edx
    jle     short loc_4405F4

    loc_440606:                             ; CODE XREF: sub_440500+F2j
    mov     eax, [esp+24h+var_10]

    loc_44060A:                             ; CODE XREF: sub_440500+DDj
                                            ; sub_440500+E2j
    cmp     bl, 3
    jnz     short loc_44064A
    cmp     [eax-1], bl
    jb      short loc_44061A
    cmp     [edx+edi+1], bl
    jnb     short loc_44064A

    loc_44061A:                             ; CODE XREF: sub_440500+112j
    mov     eax, [esp+24h+var_C]
    mov     edx, [esi+18h]
    mov     ecx, eax
    sar     eax, 4
    imul    eax, [esi+10h]
    add     eax, ebp
    and     ecx, 0Fh
    shl     ecx, 1
    lea     eax, [edx+eax*4]
    mov     edx, 3
    shl     edx, cl
    mov     ebx, [eax]
    not     edx
    and     edx, ebx
    mov     ebx, 1
    shl     ebx, cl
    jmp     short loc_44067D
    ; ---------------------------------------------------------------------------

    loc_44064A:                             ; CODE XREF: sub_440500+10Dj
                                            ; sub_440500+118j
    mov     eax, [esp+24h+var_C]
    mov     edx, [esi+18h]
    mov     ecx, eax
    mov     ebx, 3
    sar     eax, 4
    imul    eax, [esi+10h]
    and     ecx, 0Fh
    add     eax, ebp
    shl     ecx, 1
    lea     eax, [edx+eax*4]
    mov     edx, [esp+24h+var_14]
    shl     ebx, cl
    and     edx, 0FFh
    shl     edx, cl
    mov     ecx, [eax]
    not     ebx
    and     ebx, ecx

    loc_44067D:                             ; CODE XREF: sub_440500+148j
    mov     ecx, [esp+24h+var_10]
    or      edx, ebx
    mov     [eax], edx
    mov     eax, [esi+10h]
    inc     ebp
    inc     ecx
    cmp     ebp, eax
    mov     [esp+24h+var_10], ecx
    jb      loc_4405C0

    loc_440696:                             ; CODE XREF: sub_440500+A7j
    mov     eax, [esp+24h+var_C]
    mov     ecx, [esi+14h]
    inc     eax
    cmp     eax, ecx
    mov     [esp+24h+var_C], eax
    jb      loc_440545

    loc_4406AA:                             ; CODE XREF: sub_440500+3Fj
    mov     eax, [esi+10h]
    xor     ebp, ebp
    test    eax, eax
    mov     [esp+24h+var_C], ebp
    jbe     loc_44081B

    loc_4406BB:                             ; CODE XREF: sub_440500+315j
    mov     ecx, [esi+14h]
    xor     eax, eax
    test    ecx, ecx
    jbe     short loc_4406EC

    loc_4406C4:                             ; CODE XREF: sub_440500+1EAj
    mov     edx, eax
    mov     ebx, [esi+18h]
    sar     edx, 4
    imul    edx, [esi+10h]
    mov     ecx, eax
    add     edx, ebp
    and     ecx, 0Fh
    mov     edx, [ebx+edx*4]
    shl     ecx, 1
    shr     edx, cl
    and     dl, 3
    mov     [edi+eax], dl
    mov     ecx, [esi+14h]
    inc     eax
    cmp     eax, ecx
    jb      short loc_4406C4

    loc_4406EC:                             ; CODE XREF: sub_440500+1C2j
    xor     eax, eax
    mov     byte ptr [edi-2], 0
    mov     byte ptr [edi-1], 0
    cmp     [esi+6], ax
    jl      short loc_44070F

    loc_4406FC:                             ; CODE XREF: sub_440500+20Dj
    mov     edx, [esi+14h]
    lea     ecx, [edi+eax]
    inc     eax
    mov     byte ptr [ecx+edx], 0
    movsx   ecx, word ptr [esi+6]
    cmp     eax, ecx
    jle     short loc_4406FC

    loc_44070F:                             ; CODE XREF: sub_440500+1FAj
    mov     edx, [esi+14h]
    xor     cl, cl
    xor     eax, eax
    mov     byte ptr [esp+24h+var_14], cl
    test    edx, edx
    jbe     loc_44080B
    mov     edx, 1
    sub     edx, edi
    mov     [esp+24h+var_8], edx

    loc_44072D:                             ; CODE XREF: sub_440500+305j
    movsx   edx, word ptr [esi+6]
    lea     ebx, [eax+edx-1]
    mov     dl, [ebx+edi]
    cmp     dl, cl
    ja      short loc_440744
    mov     cl, dl
    mov     byte ptr [esp+24h+var_14], cl
    jmp     short loc_440774
    ; ---------------------------------------------------------------------------

    loc_440744:                             ; CODE XREF: sub_440500+23Aj
    cmp     [edi+eax-1], cl
    lea     edx, [edi+eax]
    ja      short loc_440774
    mov     ebp, [esp+24h+var_8]
    mov     cl, [edx]
    add     ebp, edx
    mov     byte ptr [esp+24h+var_14], cl
    cmp     ebp, ebx
    jg      short loc_440770

    loc_44075D:                             ; CODE XREF: sub_440500+26Ej
    mov     dl, [ebp+edi+0]
    cmp     cl, dl
    jb      short loc_44076B
    mov     cl, dl
    mov     byte ptr [esp+24h+var_14], cl

    loc_44076B:                             ; CODE XREF: sub_440500+263j
    inc     ebp
    cmp     ebp, ebx
    jle     short loc_44075D

    loc_440770:                             ; CODE XREF: sub_440500+25Bj
    mov     ebp, [esp+24h+var_C]

    loc_440774:                             ; CODE XREF: sub_440500+242j
                                            ; sub_440500+24Bj
    cmp     cl, 3
    jnz     short loc_4407C2
    cmp     byte ptr [edi+eax-1], 3
    jb      short loc_440787
    cmp     byte ptr [ebx+edi+1], 3
    jnb     short loc_4407C2

    loc_440787:                             ; CODE XREF: sub_440500+27Ej
    mov     edx, eax
    mov     ebx, [esi+18h]
    sar     edx, 4
    imul    edx, [esi+10h]
    mov     ecx, eax
    add     edx, ebp
    and     ecx, 0Fh
    mov     ebp, [ebx+edx*4]
    lea     edx, [ebx+edx*4]
    mov     ebx, 3
    shl     ecx, 1
    shl     ebx, cl
    not     ebx
    and     ebx, ebp
    mov     ebp, 1
    shl     ebp, cl
    mov     cl, byte ptr [esp+24h+var_14]
    or      ebx, ebp
    mov     ebp, [esp+24h+var_C]
    mov     [edx], ebx
    jmp     short loc_4407FF
    ; ---------------------------------------------------------------------------

    loc_4407C2:                             ; CODE XREF: sub_440500+277j
                                            ; sub_440500+285j
    mov     edx, eax
    mov     ebx, [esi+18h]
    sar     edx, 4
    imul    edx, [esi+10h]
    mov     ecx, eax
    add     edx, ebp
    and     ecx, 0Fh
    mov     ebp, 3
    shl     ecx, 1
    lea     edx, [ebx+edx*4]
    mov     ebx, [esp+24h+var_14]
    shl     ebp, cl
    and     ebx, 0FFh
    shl     ebx, cl
    mov     ecx, [edx]
    not     ebp
    and     ebp, ecx
    mov     cl, byte ptr [esp+24h+var_14]
    or      ebx, ebp
    mov     ebp, [esp+24h+var_C]
    mov     [edx], ebx

    loc_4407FF:                             ; CODE XREF: sub_440500+2C0j
    mov     edx, [esi+14h]
    inc     eax
    cmp     eax, edx
    jb      loc_44072D

    loc_44080B:                             ; CODE XREF: sub_440500+21Cj
    mov     eax, [esi+10h]
    inc     ebp
    cmp     ebp, eax
    mov     [esp+24h+var_C], ebp
    jb      loc_4406BB

    loc_44081B:                             ; CODE XREF: sub_440500+1B5j
    mov     eax, [esp+24h+var_4]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    sub_440500 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440830 proc near                    ; CODE XREF: sub_440A40+19p
                                            ; sub_440A70+33p ...

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    movsx   edx, word ptr [esp+14h+arg_0+2]
    push    ebx
    mov     ebx, ecx
    movsx   ecx, word ptr [esp+18h+arg_0]
    movsx   eax, word ptr [ebx+4]
    push    ebp
    push    esi
    push    edi
    mov     esi, ecx
    movsx   edi, word ptr [ebx+6]
    sub     esi, eax
    mov     eax, edx
    sub     eax, edi
    mov     [esp+24h+var_14], esi
    movsx   edi, word ptr [esp+24h+arg_4]
    test    esi, esi
    lea     ecx, [edi+ecx+1]
    movsx   edi, word ptr [esp+24h+arg_4+2]
    mov     [esp+24h+var_10], ecx
    lea     edx, [edi+edx+1]
    mov     [esp+24h+arg_4], edx
    jge     short loc_44087B
    xor     esi, esi
    mov     [esp+24h+var_14], esi

    loc_44087B:                             ; CODE XREF: sub_440830+43j
    test    eax, eax
    jge     short loc_440881
    xor     eax, eax

    loc_440881:                             ; CODE XREF: sub_440830+4Dj
    mov     edi, [ebx+10h]
    cmp     ecx, edi
    jbe     short loc_44088E
    mov     ecx, edi
    mov     [esp+24h+var_10], ecx

    loc_44088E:                             ; CODE XREF: sub_440830+56j
    mov     edi, [ebx+14h]
    cmp     edx, edi
    jbe     short loc_44089B
    mov     edx, edi
    mov     [esp+24h+arg_4], edx

    loc_44089B:                             ; CODE XREF: sub_440830+63j
    cmp     esi, ecx
    jge     short loc_440918
    cmp     eax, edx
    jge     short loc_440918
    mov     [esp+24h+arg_0], eax
    jmp     short loc_4408AD
    ; ---------------------------------------------------------------------------

    loc_4408A9:                             ; CODE XREF: sub_440830+E6j
    mov     esi, [esp+24h+var_14]

    loc_4408AD:                             ; CODE XREF: sub_440830+77j
    mov     edi, eax
    mov     ecx, eax
    and     edi, 0Fh
    mov     ebp, 3
    sar     ecx, 4
    shl     edi, 1
    mov     [esp+24h+var_8], ecx
    mov     ecx, edi
    shl     ebp, cl
    not     ebp
    mov     [esp+24h+var_C], ebp
    jmp     short loc_4408D2
    ; ---------------------------------------------------------------------------

    loc_4408CE:                             ; CODE XREF: sub_440830+D9j
    mov     ebp, [esp+24h+var_C]

    loc_4408D2:                             ; CODE XREF: sub_440830+9Cj
    push    eax
    push    esi
    push    ebx
    call    sub_47E1F0
    mov     ecx, [ebx+10h]
    mov     edx, [ebx+18h]
    imul    ecx, [esp+24h+var_8]
    add     ecx, esi
    lea     edx, [edx+ecx*4]
    mov     ecx, [edx]
    and     ecx, ebp
    mov     [esp+24h+var_4], ecx
    mov     ecx, edi
    shl     eax, cl
    mov     ecx, [esp+24h+var_4]
    or      ecx, eax
    mov     eax, [esp+24h+var_10]
    inc     esi
    mov     [edx], ecx
    cmp     esi, eax
    mov     eax, [esp+24h+arg_0]
    jl      short loc_4408CE
    mov     ecx, [esp+24h+arg_4]
    inc     eax
    cmp     eax, ecx
    mov     [esp+24h+arg_0], eax
    jl      short loc_4408A9

    loc_440918:                             ; CODE XREF: sub_440830+6Dj
                                            ; sub_440830+71j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    sub_440830 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_11. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440940 proc near                    ; CODE XREF: sub_4917D0+113p

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    xor     ecx, ecx
    push    esi
    push    edi
    mov     [esp+14h+var_4], ecx
    mov     eax, offset dword_512358

    loc_440950:                             ; CODE XREF: sub_440940+1Ej
    cmp     dword ptr [eax], 0
    jz      short loc_440956
    inc     ecx

    loc_440956:                             ; CODE XREF: sub_440940+13j
    add     eax, 20h
    cmp     eax, offset byte_512758
    jl      short loc_440950
    mov     [esp+14h+var_4], ecx
    mov     ebp, 64h
    mov     esi, offset dword_512370

    loc_44096E:                             ; CODE XREF: sub_440940+A8j
    mov     eax, [esi-18h]
    lea     ebx, [esi-18h]
    test    eax, eax
    jz      short loc_4409DF
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esi]
    push    edx
    mov     eax, [ecx+14237h]
    mov     ecx, [ecx+14233h]
    mov     [esi-8], ecx
    mov     [esi-4], eax
    lea     edi, [eax+0Fh]
    shr     edi, 4
    imul    edi, ecx
    call    sub_4B4F20
    add     esp, 4
    test    edi, edi
    jz      short loc_4409BC
    lea     eax, ds:0[edi*4]
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [esi], eax
    jmp     short loc_4409C2
    ; ---------------------------------------------------------------------------

    loc_4409BC:                             ; CODE XREF: sub_440940+66j
    mov     dword ptr [esi], 0

    loc_4409C2:                             ; CODE XREF: sub_440940+7Aj
    mov     ecx, ebx
    call    sub_440500
    add     ebp, 64h
    mov     ecx, TAdynmemStructPtr
    mov     eax, ebp
    cdq
    idiv    [esp+14h+var_4]
    mov     [ecx+38D73h], al

    loc_4409DF:                             ; CODE XREF: sub_440940+36j
    add     esi, 20h
    cmp     esi, offset dword_512770
    jl      short loc_44096E
    mov     edx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     byte ptr [edx+38D73h], 64h
    pop     ebx
    pop     ecx
    retn
    sub_440940 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440A00 proc near                    ; CODE XREF: sub_491B60+D5p
    push    esi
    push    edi
    mov     esi, offset dword_512370
    xor     edi, edi

    loc_440A09:                             ; CODE XREF: sub_440A00+34j
    mov     eax, [esi-18h]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [esi-18h], edi
    mov     ecx, [esi]
    mov     [esi-8], edi
    push    ecx
    mov     [esi-4], edi
    call    sub_4B4F20
    mov     [esi], edi
    add     esi, 20h
    add     esp, 4
    cmp     esi, offset dword_512770
    jl      short loc_440A09
    pop     edi
    pop     esi
    retn
    sub_440A00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440A40 proc near                    ; CODE XREF: sub_423C50+3E1p
                                            ; sub_4246B0+172p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, [esp+8+arg_4]
    mov     esi, offset dword_512358

    loc_440A50:                             ; CODE XREF: sub_440A40+27j
    cmp     dword ptr [esi], 0
    jz      short loc_440A5E
    push    edi
    push    ebx
    mov     ecx, esi
    call    sub_440830

    loc_440A5E:                             ; CODE XREF: sub_440A40+13j
    add     esi, 20h
    cmp     esi, offset byte_512758
    jl      short loc_440A50
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_440A40 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440A70 proc near                    ; CODE XREF: sub_47D0E0+1EAp

    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_440AB9
    mov     ecx, TAdynmemStructPtr
    mov     ebx, [eax+26h]
    mov     esi, offset dword_512358
    mov     edx, [ecx+38A47h]
    mov     [eax+26h], edx

    loc_440A94:                             ; CODE XREF: sub_440A70+41j
    cmp     ebx, [esi+1Ch]
    jnb     short loc_440AA8
    mov     eax, [edi+7Eh]
    mov     ecx, [edi+76h]
    push    eax
    push    ecx
    mov     ecx, esi
    call    sub_440830

    loc_440AA8:                             ; CODE XREF: sub_440A70+27j
    add     esi, 20h
    cmp     esi, offset byte_512758
    jl      short loc_440A94
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_440AB9:                             ; CODE XREF: sub_440A70+Bj
    mov     ebx, [edi+7Eh]
    mov     edi, [edi+76h]
    mov     esi, offset dword_512358

    loc_440AC4:                             ; CODE XREF: sub_440A70+6Bj
    cmp     dword ptr [esi], 0
    jz      short loc_440AD2
    push    ebx
    push    edi
    mov     ecx, esi
    call    sub_440830

    loc_440AD2:                             ; CODE XREF: sub_440A70+57j
    add     esi, 20h
    cmp     esi, offset byte_512758
    jl      short loc_440AC4
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_440A70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440AF0 proc near                    ; CODE XREF: sub_40E630+25p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    sub     esp, 8
    mov     eax, [eax+38A47h]
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    cmp     eax, 1Eh
    mov     ebp, [ebx+1Ch]
    push    edi
    ja      short loc_440B11
    mov     eax, 1Eh

    loc_440B11:                             ; CODE XREF: sub_440AF0+1Aj
    mov     edx, [esp+18h+arg_0]
    lea     esi, [eax-1Eh]
    mov     [ebx+1Ch], esi
    mov     ecx, TAdynmemStructPtr
    mov     eax, [edx]
    mov     [esp+18h+var_8], esi
    mov     ecx, [ecx+38A47h]
    mov     edi, [eax+26h]
    mov     [eax+26h], ecx
    cmp     edi, ebp
    mov     [esp+18h+var_4], edi
    jnb     short loc_440B4E
    mov     eax, [edx+7Eh]
    mov     ecx, [edx+76h]
    push    eax
    push    ecx
    mov     ecx, ebx
    call    sub_440830
    mov     edx, [esp+18h+arg_0]

    loc_440B4E:                             ; CODE XREF: sub_440AF0+49j
    cmp     esi, ebp
    jz      short loc_440BC2
    mov     ecx, TAdynmemStructPtr
    mov     esi, [ecx+14357h]
    mov     eax, [ecx+1435Bh]
    add     esi, 118h
    cmp     esi, eax
    ja      short loc_440BC2
    lea     edi, [esi+7Eh]

    loc_440B71:                             ; CODE XREF: sub_440AF0+C8j
    test    dword ptr [edi+92h], 10000000h
    jz      short loc_440BA4
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_440BA4
    mov     eax, [eax+26h]
    cmp     eax, ebp
    jb      short loc_440BA4
    cmp     eax, [esp+18h+var_8]
    jnb     short loc_440BA4
    mov     edx, [edi]
    mov     eax, [edi-8]
    push    edx
    push    eax
    mov     ecx, ebx
    call    sub_440830
    mov     ecx, TAdynmemStructPtr

    loc_440BA4:                             ; CODE XREF: sub_440AF0+8Bj
                                            ; sub_440AF0+91j ...
    mov     eax, [ecx+1435Bh]
    add     esi, 118h
    add     edi, 118h
    cmp     esi, eax
    jbe     short loc_440B71
    mov     edi, [esp+18h+var_4]
    mov     edx, [esp+18h+arg_0]

    loc_440BC2:                             ; CODE XREF: sub_440AF0+60j
                                            ; sub_440AF0+7Cj
    mov     ecx, [edx]
    mov     [ecx+26h], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_440AF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440BE0 proc near                    ; CODE XREF: sub_40E630+18Bp
                                            ; sub_40E630+363p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, [ecx+1Ch]
    mov     edx, [eax]
    mov     edx, [edx+26h]
    cmp     edx, esi
    jnb     short loc_440BFE
    mov     edx, [eax+7Eh]
    mov     eax, [eax+76h]
    push    edx
    push    eax
    call    sub_440830

    loc_440BFE:                             ; CODE XREF: sub_440BE0+Fj
    pop     esi
    retn    4
    sub_440BE0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 28h
    mov     ecx, 0Ah
    xor     eax, eax
    mov     edx, 0Ah
    push    ebx
    push    edi
    lea     edi, [esp+8]
    mov     ebx, 1
    rep stosd
    mov     eax, TAdynmemStructPtr
    lea     ecx, [eax+1BD6h]

    loc_440C37:                             ; CODE XREF: .text:00440C79j
    mov     eax, [ecx-73h]
    test    eax, eax
    jz      short loc_440C72
    mov     al, [ecx]
    cmp     al, bl
    jz      short loc_440C4C
    cmp     al, 2
    jz      short loc_440C4C
    cmp     al, 3
    jnz     short loc_440C72

    loc_440C4C:                             ; CODE XREF: .text:00440C42j
                                            ; .text:00440C46j
    cmp     byte ptr [ecx+0D3h], 0Ah
    jz      short loc_440C72
    mov     eax, [ecx-4Ch]
    mov     al, [eax+96h]
    cmp     al, 9
    jnb     short loc_440C69
    and     eax, 0FFh
    jmp     short loc_440C6E
    ; ---------------------------------------------------------------------------

    loc_440C69:                             ; CODE XREF: .text:00440C60j
    mov     eax, 9

    loc_440C6E:                             ; CODE XREF: .text:00440C67j
    mov     [esp+eax*4+8], ebx

    loc_440C72:                             ; CODE XREF: .text:00440C3Cj
                                            ; .text:00440C4Aj ...
    add     ecx, 14Bh
    dec     edx
    jnz     short loc_440C37
    xor     eax, eax
    xor     ecx, ecx
    lea     edx, [esp+8]

    loc_440C83:                             ; CODE XREF: .text:00440C8Fj
    cmp     dword ptr [edx], 0
    jz      short loc_440C97
    inc     ecx
    add     edx, 4
    cmp     ecx, 0Ah
    jl      short loc_440C83
    pop     edi
    pop     ebx
    add     esp, 28h
    retn
    ; ---------------------------------------------------------------------------

    loc_440C97:                             ; CODE XREF: .text:00440C86j
    pop     edi
    mov     eax, ecx
    pop     ebx
    add     esp, 28h
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+8]
    mov     ecx, [esp+4]
    add     eax, 4
    add     ecx, 99h
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     edx, [eax+8]
    mov     [ecx+8], edx
    mov     eax, [eax+0Ch]
    mov     [ecx+0Ch], eax
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    push    ecx
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    mov     ecx, [eax+391E9h]
    call    sub_4358F0
    test    eax, eax
    jnz     short loc_440CEB
    pop     edi
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_440CEB:                             ; CODE XREF: .text:00440CE5j
    call    sub_456850
    mov     edi, TAdynmemStructPtr
    xor     esi, esi
    xor     edx, edx
    cmp     al, 0Ah
    mov     [esp+8], al
    jz      short loc_440D3C
    mov     eax, [esp+8]
    mov     esi, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    mov     esi, [esi+ecx*2+1B8Ah]
    mov     al, [esi+0A7h]
    cmp     al, 2
    jnb     short loc_440D37
    cmp     al, 1
    jnz     short loc_440D3C
    cmp     byte ptr [esi+0A8h], 2
    jb      short loc_440D3C

    loc_440D37:                             ; CODE XREF: .text:00440D28j
    mov     edx, 1

    loc_440D3C:                             ; CODE XREF: .text:00440D00j
                                            ; .text:00440D2Cj ...
    test    edx, edx
    jnz     short loc_440D49
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_440D49:                             ; CODE XREF: .text:00440D3Ej
    mov     ecx, [edi+391E9h]
    call    sub_4373A0
    mov     ecx, [esi+0A9h]
    xor     edx, edx
    cmp     eax, ecx
    pop     edi
    setz    dl
    mov     eax, edx
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_440D70 proc near                    ; DATA XREF: sub_441080+25o

    var_CC= dword ptr -0CCh
    var_C8= dword ptr -0C8h
    var_64= dword ptr -64h
    arg_0= dword ptr  4

    sub     esp, 0CCh
    push    ebx
    push    ebp
    mov     ebp, [esp+0D4h+arg_0]
    push    esi
    push    edi
    mov     eax, [ebp+18h]
    mov     ebx, [eax+4]
    mov     eax, [ebp+60h]
    cmp     eax, 0FFFFFFFFh
    jz      loc_44106A
    push    offset aGamename                ; "GAMENAME"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      short loc_440DBF
    push    3
    push    offset aNickname_0              ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    push    eax
    push    ebp
    call    sub_4A7830
    push    3
    push    offset aNickname_0              ; "NICKNAME"
    jmp     short loc_440DE9
    ; ---------------------------------------------------------------------------

    loc_440DBF:                             ; CODE XREF: sub_440D70+30j
    push    offset aNickname_0              ; "NICKNAME"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      short loc_440E0F
    push    3
    push    offset aPassword_0              ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    push    eax
    push    ebp
    call    sub_4A7830
    push    3
    push    offset aPassword_0              ; char *

    loc_440DE9:                             ; CODE XREF: sub_440D70+4Dj
    push    ebx                             ; int
    call    sub_49FDF0
    push    eax
    push    ebp
    call    sub_49FC50
    push    ebp                             ; int
    call    sub_49FA90
    push    ebp
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_440E0F:                             ; CODE XREF: sub_440D70+5Cj
    push    offset aPassword_0              ; "PASSWORD"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      short loc_440E4B
    push    1
    push    offset byte_502AE8              ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    push    eax
    push    ebp
    call    sub_4A7830
    push    ebp                             ; int
    call    sub_49FA90
    push    ebp
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_440E4B:                             ; CODE XREF: sub_440D70+ACj
    push    0Eh
    push    offset byte_502AE8              ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, [ebp+60h]
    jnz     loc_44102E
    push    0                               ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    push    offset aPassword_0              ; char *
    push    ebx                             ; int
    call    sub_4A0010
    mov     ecx, TAdynmemStructPtr
    add     eax, 0B6h
    push    0Bh                             ; iMaxLength
    add     ecx, 2BE3h
    push    eax                             ; lpString2
    push    ecx                             ; lpString1
    call    ds:lstrcpynA
    push    3
    push    offset aGamename                ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     edx, eax
    lea     esi, [esp+14h]
    shl     eax, 3
    sub     eax, edx
    mov     [esp+10h], esi
    lea     eax, [eax+eax*2]
    lea     ecx, [edx+eax*2]
    lea     eax, [edx+ecx*4]
    mov     ecx, ebx
    add     ecx, edx
    lea     edi, [ecx+eax*2+0B6h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+10h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+14h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_440F26
    push    edx
    push    ebp
    call    sub_4A7190
    push    ebp
    call    sub_4AB0A0
    push    1
    push    1
    push    140h
    push    offset aYouMustEnterAG          ; int
    call    sub_4C5740
    push    eax
    push    ebp
    call    sub_4ABD90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_440F26:                             ; CODE XREF: sub_440D70+180j
    push    3
    push    offset aNickname_0              ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     edx, eax
    shl     eax, 3
    sub     eax, edx
    add     ebx, edx
    lea     ecx, [eax+eax*2]
    lea     eax, [edx+ecx*2]
    lea     ecx, [edx+eax*4]
    xor     eax, eax
    lea     edi, [ebx+ecx*2+0B6h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     ebx, [esp+78h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+78h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_440FB1
    push    edx
    push    ebp
    call    sub_4A7190
    push    ebp
    call    sub_4AB0A0
    push    1
    push    1
    push    140h
    push    offset aYouMustEnterYo          ; int
    call    sub_4C5740
    push    eax
    push    ebp
    call    sub_4ABD90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_440FB1:                             ; CODE XREF: sub_440D70+20Bj
    mov     ecx, TAdynmemStructPtr
    lea     edi, [esp+14h]
    xor     eax, eax
    lea     edx, [ecx+2BC1h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     ecx, TAdynmemStructPtr
    lea     edi, [esp+78h]
    lea     edx, [ecx+2BD2h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    call    sub_4436E0
    test    eax, eax
    jnz     short loc_441064
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2BC0h], 11h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44102E:                             ; CODE XREF: sub_440D70+EBj
    push    0Eh
    push    offset aCancel_0                ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, [ebp+60h]
    jnz     short loc_441064
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    push    ebp
    call    sub_4A9660
    call    sub_443CB0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_441064:                             ; CODE XREF: sub_440D70+2A2j
                                            ; sub_440D70+2CEj
    push    ebp
    call    sub_4AB0A0

    loc_44106A:                             ; CODE XREF: sub_440D70+1Dj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    4
    sub_440D70 endp ; sp = -0Ch

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_441080 proc near                    ; CODE XREF: sub_4437C0+244p

    nSize= dword ptr -4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    push    80h
    add     eax, 519h
    push    offset aNewmulti_gui            ; "NEWMULTI.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    push    0
    push    0
    push    0
    mov     dword ptr [esi+8], offset sub_440D70
    mov     ecx, TAdynmemStructPtr
    push    offset aCreatenew               ; "createnew"
    mov     [esi+0Ch], ecx
    call    sub_4288D0
    mov     esi, [esi+4]
    call    sub_45B660
    test    eax, eax
    jz      short loc_4410FB
    mov     al, byte_512D48
    test    al, al
    jz      short loc_4410FB
    mov     edx, TAdynmemStructPtr
    push    10h                             ; size_t
    push    offset byte_512D48              ; char *
    mov     byte ptr [edx+2BD2h], 0
    mov     eax, TAdynmemStructPtr
    add     eax, 2BD2h
    push    eax                             ; char *
    call    _strncat
    add     esp, 0Ch

    loc_4410FB:                             ; CODE XREF: sub_441080+49j
                                            ; sub_441080+52j
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    lea     edx, [ecx+2BD2h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_441129
    lea     eax, [esp+0Ch+nSize]
    mov     [esp+0Ch+nSize], 11h
    push    eax                             ; nSize
    push    edx                             ; lpBuffer
    call    ds:GetUserNameA

    loc_441129:                             ; CODE XREF: sub_441080+93j
    push    offset aGamename                ; char *
    push    esi                             ; int
    call    sub_4A0010
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    push    0
    lea     ecx, [eax+2BC1h]
    add     eax, 519h
    push    ecx
    push    offset aGamename                ; "GAMENAME"
    push    eax
    call    sub_4A0BF0
    push    offset aNickname_0              ; char *
    push    esi                             ; int
    mov     word ptr [edi+138h], 10h
    call    sub_4A0010
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    push    0
    lea     edx, [eax+2BD2h]
    add     eax, 519h
    push    edx
    push    offset aNickname_0              ; "NICKNAME"
    push    eax
    call    sub_4A0BF0
    mov     word ptr [esi+138h], 10h
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edx, esi
    mov     cl, [esi+2A42h]
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    or      ecx, 0FFFFFFFFh
    lea     eax, [eax+eax*4]
    mov     edx, [edx+eax*2+1B8Ah]
    xor     eax, eax
    add     edx, 80h
    mov     edi, edx
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_4411CE
    lea     edx, [esi+2BE3h]

    loc_4411CE:                             ; CODE XREF: sub_441080+146j
    push    0Ah
    push    edx
    add     esi, 519h
    push    offset aPassword_0              ; "PASSWORD"
    push    esi
    call    sub_4A0BF0
    call    sub_428B60
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ecx
    retn
    sub_441080 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_441220 proc near                    ; CODE XREF: sub_441460+73Bp
                                            ; DATA XREF: sub_443CB0+17Co

    var_C0= dword ptr -0C0h
    var_BC= dword ptr -0BCh
    var_23= dword ptr -23h
    var_1F= dword ptr -1Fh
    var_1B= dword ptr -1Bh
    var_17= dword ptr -17h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0C0h
    mov     eax, [esp+0C0h+arg_0]
    mov     edx, [esp+0C0h+arg_4]
    push    ebx
    push    ebp
    mov     ecx, [eax+18h]
    push    esi
    push    edi
    lea     esi, [esp+0D0h+var_BC]
    mov     ebp, [ecx+4]
    push    1
    movsx   ecx, word ptr [edx+0BAh]
    mov     eax, ecx
    push    offset aWatch                   ; char *
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+0D2h]
    push    ebp                             ; int
    lea     eax, [eax+eax*2]
    lea     edx, [ecx+eax*4+4]
    mov     eax, [ecx+eax*4+4]
    mov     [esp+0DCh+var_23], eax
    mov     ecx, [edx+4]
    mov     [esp+0DCh+var_1F], ecx
    mov     eax, [edx+8]
    mov     [esp+0DCh+var_1B], eax
    mov     ecx, [edx+0Ch]
    mov     edx, TAdynmemStructPtr
    mov     [esp+0DCh+var_17], ecx
    mov     ecx, 2Eh
    lea     edi, [edx+2AB1h]
    rep movsd
    movsb
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    mov     esi, [esp+0D4h+var_1B+2]
    mov     bx, [esp+0AFh]
    jz      loc_44134D
    mov     ecx, TAdynmemStructPtr
    mov     edi, esi
    and     edi, 0FFh
    movsx   edx, byte ptr [ecx+1]
    xor     ecx, ecx
    cmp     edi, edx
    setnl   cl
    mov     edi, ecx
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebp
    add     ecx, eax
    mov     al, bl
    and     eax, 10h
    lea     edx, [ecx+edx*2+13Ch]
    mov     cl, bl
    mov     [esp+10h], edx
    xor     edx, edx
    not     cl
    and     ecx, 80h
    mov     dl, bh
    or      cx, dx
    xor     edx, edx
    shr     cx, 3
    or      cx, ax
    mov     eax, [esp+0D4h+arg_0]
    shr     cx, 4
    cmp     [eax+0C0h], dx
    setz    dl
    xor     eax, eax
    test    edi, edi
    setz    al
    or      dl, al
    mov     eax, [esp+10h]
    and     edx, 1
    or      ecx, edx
    mov     dx, [eax]
    and     edx, 0FFFEh
    or      ecx, edx
    mov     [eax], cx

    loc_44134D:                             ; CODE XREF: sub_441220+99j
    push    1
    push    offset aJoingame                ; char *
    push    ebp                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4413D3
    mov     ecx, TAdynmemStructPtr
    and     esi, 0FFh
    movsx   edx, byte ptr [ecx+1]
    xor     ecx, ecx
    cmp     esi, edx
    setnl   cl
    mov     esi, ecx
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    add     ebp, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, [esp+0D8h]
    xor     eax, eax
    cmp     [ecx+0C0h], ax
    lea     ebp, [ebp+edx*2+13Ch]
    mov     cx, bx
    setz    al
    xor     edx, edx
    test    esi, esi
    setz    dl
    shr     cx, 0Bh
    and     ebx, 10h
    or      al, dl
    mov     dx, [ebp+0]
    or      cx, bx
    and     eax, 1
    and     edx, 0FFFEh
    shr     cx, 4
    or      eax, ecx
    or      eax, edx
    mov     [ebp+0], ax

    loc_4413D3:                             ; CODE XREF: sub_441220+13Dj
    mov     esi, [esp+0B1h]
    mov     eax, TAdynmemStructPtr
    and     esi, 1
    add     eax, 519h
    push    esi                             ; int
    push    offset aPasswordtext            ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    esi                             ; int
    add     ecx, 519h
    push    offset aPassword_0              ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     edx, [esp+0D4h]
    push    edx                             ; int
    call    sub_49FA90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0C0h
    retn    8
    sub_441220 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     eax, [ecx+eax*2+1B8Ah]
    add     eax, 80h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_441460 proc near                    ; CODE XREF: sub_4437C0+139p
                                            ; sub_443CB0+1CBp

    var_1B4= dword ptr -1B4h
    var_1B0= dword ptr -1B0h
    var_1AC= dword ptr -1ACh
    var_1A8= dword ptr -1A8h
    var_1A4= dword ptr -1A4h
    var_1A0= dword ptr -1A0h
    var_19C= dword ptr -19Ch
    var_198= dword ptr -198h
    var_194= dword ptr -194h
    var_190= dword ptr -190h
    var_18C= dword ptr -18Ch
    var_188= dword ptr -188h
    var_184= dword ptr -184h
    var_15C= byte ptr -15Ch
    var_14C= byte ptr -14Ch
    MultiByteStr= byte ptr -13Ch
    var_BD= byte ptr -0BDh
    var_23= dword ptr -23h
    var_1F= dword ptr -1Fh
    var_1B= dword ptr -1Bh
    var_17= dword ptr -17h
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    sub     esp, 1B4h
    add     eax, 39201h
    mov     ecx, 10h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, offset dword_4FCDC8
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      short loc_4414C5
    mov     ecx, 10h
    mov     edi, offset dword_4FCDA8
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      short loc_4414C5
    mov     ecx, 10h
    mov     edi, offset dword_4FCD98
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      short loc_44151D
    mov     ecx, 10h
    mov     edi, offset dword_4FCDB8
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      short loc_4414C1
    sbb     edx, edx
    sbb     edx, 0FFFFFFFFh

    loc_4414C1:                             ; CODE XREF: sub_441460+5Aj
    mov     [esp+1C4h+var_1B4], edx

    loc_4414C5:                             ; CODE XREF: sub_441460+24j
                                            ; sub_441460+36j
    mov     ecx, 10h
    mov     edi, offset dword_4FCDC8
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      short loc_441516
    mov     ecx, 10h
    mov     edi, offset dword_4FCDA8
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      short loc_44151D
    mov     ecx, 10h
    mov     edi, offset dword_4FCD98
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      short loc_441516
    mov     esi, eax
    mov     ecx, 10h
    mov     edi, offset dword_4FCDB8
    xor     eax, eax
    repe cmpsb
    jz      short loc_441512
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_441512:                             ; CODE XREF: sub_441460+ABj
    mov     [esp+1C4h+var_1B4], eax

    loc_441516:                             ; CODE XREF: sub_441460+75j
                                            ; sub_441460+99j
    mov     eax, offset aConnectingEscT     ; "Connecting  (ESC to abort)"
    jmp     short loc_441522
    ; ---------------------------------------------------------------------------

    loc_44151D:                             ; CODE XREF: sub_441460+48j
                                            ; sub_441460+87j
    mov     eax, offset aUpdating___        ; "Updating..."

    loc_441522:                             ; CODE XREF: sub_441460+BBj
    push    1
    push    0
    push    96h
    push    eax                             ; int
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+37E1Bh]
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AB170
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C69A0
    call    sub_4C63A0
    call    sub_4C63A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+2AA7h]
    add     eax, 14h
    push    ecx
    push    eax
    call    sub_4C9E50
    mov     edx, TAdynmemStructPtr
    mov     ebx, eax
    add     edx, 519h
    push    edx
    call    sub_4A9660
    test    ebx, ebx
    jge     short loc_4415B5
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1B4h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4415B5:                             ; CODE XREF: sub_441460+144j
    xor     edx, edx

    loc_4415B7:                             ; CODE XREF: sub_441460+176j
    mov     eax, TAdynmemStructPtr
    add     edx, 4
    mov     ecx, 280h
    mov     edi, [eax+edx+2A47h]
    xor     eax, eax
    mov     [esp+edx+1C4h+var_1B0], edi
    cmp     edx, 3Ch
    rep stosd
    jl      short loc_4415B7
    mov     eax, TAdynmemStructPtr
    test    ebx, ebx
    mov     ecx, [eax+2AA7h]
    jle     loc_4419EE
    lea     esi, [ecx+18h]
    mov     [esp+1C4h+var_1B4], ebx
    mov     [esp+1C4h+var_1B0], esi
    jmp     short loc_4415FC
    ; ---------------------------------------------------------------------------

    loc_4415F8:                             ; CODE XREF: sub_441460+583j
    mov     esi, [esp+1C4h+var_1B0]

    loc_4415FC:                             ; CODE XREF: sub_441460+196j
    lea     ecx, [esi-14h]
    lea     edi, [esp+1C4h+var_15C]
    push    10h                             ; size_t
    mov     ebp, [ecx]
    mov     [esp+1C8h+var_23], ebp
    mov     edx, [ecx+4]
    mov     [esp+1C8h+var_1F], edx
    mov     ebx, [ecx+8]
    mov     [esp+1C8h+var_1B], ebx
    mov     eax, [ecx+0Ch]
    mov     ecx, 8
    rep movsd
    mov     esi, [esp+1C8h+var_1AC]
    lea     ecx, [esp+1C8h+var_15C]
    push    ecx                             ; char *
    push    esi                             ; char *
    mov     [esp+1D0h+var_17], eax
    call    _strncpy
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    mov     byte ptr [esi+10h], 0
    repne scasb
    mov     eax, [esp+1C4h+var_1B0]
    not     ecx
    dec     ecx
    lea     edx, [esi+ecx+1]
    mov     ecx, [eax-4]
    mov     esi, [esp+1C4h+var_1A8]
    mov     [esp+1C4h+var_1AC], edx
    mov     edx, [esp+1C4h+var_23+2]
    push    ecx
    and     edx, 0Fh
    push    edx
    push    offset aDD_0                    ; "%d/%d"
    push    esi
    call    _sprintf
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edi, [esp+1C4h+MultiByteStr]
    push    0Fh                             ; size_t
    lea     edx, [esp+1C8h+MultiByteStr]
    lea     eax, [esi+ecx+1]
    mov     ecx, 20h
    mov     [esp+1C8h+var_1A8], eax
    xor     eax, eax
    rep stosd
    lea     ecx, [esp+1C8h+var_14C]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    lea     edi, [esp+1D0h+MultiByteStr]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+1C4h+MultiByteStr]
    lea     ecx, [esp+1C4h+MultiByteStr]
    cmp     eax, ecx
    jz      short loc_4416F7

    loc_4416E0:                             ; CODE XREF: sub_441460+295j
    mov     cl, [eax-1]
    dec     eax
    cmp     cl, 20h
    jnz     short loc_4416F7
    lea     edx, [esp+1C4h+MultiByteStr]
    mov     byte ptr [eax], 0
    cmp     eax, edx
    jnz     short loc_4416E0

    loc_4416F7:                             ; CODE XREF: sub_441460+27Ej
                                            ; sub_441460+287j
    call    sub_49F580
    test    eax, eax
    jz      short loc_441752
    push    offset aEnglish                 ; char *
    call    sub_49F580
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_441752
    lea     eax, [esp+1C4h+MultiByteStr]
    push    eax                             ; lpMultiByteStr
    call    sub_4E8960
    add     esp, 4
    lea     ecx, [esp+1C4h+MultiByteStr]
    push    ecx                             ; int
    call    sub_4C5740
    push    80h                             ; size_t
    lea     edx, [esp+1C8h+MultiByteStr]
    push    eax                             ; char *
    push    edx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     [esp+1C4h+var_BD], 0

    loc_441752:                             ; CODE XREF: sub_441460+29Ej
                                            ; sub_441460+2B5j
    lea     edi, [esp+1C4h+MultiByteStr]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [esp+1C4h+var_1A4]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     ecx, [edx+ecx+1]
    mov     edx, TAdynmemStructPtr
    mov     [esp+1C4h+var_1A4], ecx
    mov     ecx, [esp+1C4h+var_17+2]
    movsx   eax, byte ptr [edx+1]
    and     ecx, 0FFh
    cmp     ecx, eax
    jl      short loc_4417ED
    mov     eax, [esp+1C4h+var_23+2]
    mov     edx, eax
    shr     edx, 0Fh
    test    dl, 1
    jz      short loc_4417C1
    mov     eax, offset aLock_0             ; "Lock"
    jmp     short loc_4417D2
    ; ---------------------------------------------------------------------------

    loc_4417C1:                             ; CODE XREF: sub_441460+358j
    shr     al, 4
    test    al, 1
    mov     eax, offset aPlay               ; "Play"
    jnz     short loc_4417D2
    mov     eax, offset aOpen_0             ; "Open"

    loc_4417D2:                             ; CODE XREF: sub_441460+35Fj
                                            ; sub_441460+36Bj
    push    eax                             ; int
    call    sub_4C5740
    push    eax
    push    offset aS_1                     ; "%s"
    mov     esi, [esp+1CCh+var_1A0]
    push    esi
    call    _sprintf
    add     esp, 0Ch
    jmp     short loc_44180E
    ; ---------------------------------------------------------------------------

    loc_4417ED:                             ; CODE XREF: sub_441460+347j
    push    offset aVer                     ; int
    call    sub_4C5740
    push    eax
    push    offset aS_1                     ; "%s"
    mov     eax, [esp+1CCh+var_1A0]
    push    eax
    call    _sprintf
    mov     esi, [esp+1D0h+var_1A0]
    add     esp, 0Ch

    loc_44180E:                             ; CODE XREF: sub_441460+38Bj
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    and     ebp, 0FFFFh
    repne scasb
    not     ecx
    dec     ecx
    push    ebp
    push    offset aD_0                     ; "%d"
    lea     ecx, [esi+ecx+1]
    mov     esi, [esp+1CCh+var_19C]
    push    esi
    mov     [esp+1D0h+var_1A0], ecx
    call    _sprintf
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     eax, [esp+1C4h+var_1B+2]
    and     eax, 0FFFFh
    not     ecx
    lea     eax, [eax+eax*4]
    dec     ecx
    lea     eax, [eax+eax*4]
    lea     edx, [esi+ecx+1]
    mov     esi, [esp+1C4h+var_198]
    mov     [esp+1C4h+var_19C], edx
    shl     eax, 2
    push    eax
    push    offset aD_0                     ; "%d"
    push    esi
    call    _sprintf
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    and     ebx, 0FFFFh
    mov     eax, ebx
    not     ecx
    lea     eax, [eax+eax*4]
    dec     ecx
    lea     edx, [eax+eax*4]
    lea     ecx, [esi+ecx+1]
    mov     esi, [esp+1C4h+var_194]
    mov     [esp+1C4h+var_198], ecx
    shl     edx, 2
    push    edx
    push    offset aD_0                     ; "%d"
    push    esi
    call    _sprintf
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esi+ecx+1]
    mov     ecx, [esp+1C4h+var_1F+2]
    mov     esi, [esp+1C4h+var_190]
    and     ecx, 0FFFFh
    push    ecx
    push    offset aD_0                     ; "%d"
    push    esi
    mov     [esp+1D0h+var_194], eax
    call    _sprintf
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     ebx, [esp+1C4h+var_23+2]
    not     ecx
    dec     ecx
    mov     eax, ebx
    and     eax, 1800h
    lea     edx, [esi+ecx+1]
    mov     [esp+1C4h+var_190], edx
    test    ax, ax
    jz      short loc_44191E
    cmp     ax, 800h
    jnz     short loc_441917
    mov     eax, offset aYes                ; "Yes"
    jmp     short loc_441923
    ; ---------------------------------------------------------------------------

    loc_441917:                             ; CODE XREF: sub_441460+4AEj
    mov     eax, offset aDm                 ; "DM"
    jmp     short loc_441923
    ; ---------------------------------------------------------------------------

    loc_44191E:                             ; CODE XREF: sub_441460+4A8j
    mov     eax, offset aNo                 ; "No"

    loc_441923:                             ; CODE XREF: sub_441460+4B5j
                                            ; sub_441460+4BCj
    push    eax                             ; int
    call    sub_4C5740
    push    eax
    push    offset aS_1                     ; "%s"
    mov     esi, [esp+1CCh+var_18C]
    push    esi
    call    _sprintf
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esi+ecx+1]
    xor     ecx, ecx
    mov     cl, bh
    mov     [esp+1C4h+var_18C], eax
    test    cl, 1
    mov     eax, offset aBlk                ; "Blk"
    jnz     short loc_441963
    mov     eax, offset aGray               ; "Gray"

    loc_441963:                             ; CODE XREF: sub_441460+4FCj
    push    eax                             ; int
    call    sub_4C5740
    push    eax
    push    offset aS_1                     ; "%s"
    mov     esi, [esp+1CCh+var_188]
    push    esi
    call    _sprintf
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, offset aNo                 ; "No"
    shr     ebx, 9
    lea     edx, [esi+ecx+1]
    test    bl, 1
    mov     [esp+1C4h+var_188], edx
    jnz     short loc_4419A2
    mov     eax, offset aYes                ; "Yes"

    loc_4419A2:                             ; CODE XREF: sub_441460+53Bj
    push    eax                             ; int
    call    sub_4C5740
    push    eax
    push    offset aS_1                     ; "%s"
    mov     esi, [esp+1CCh+var_184]
    push    esi
    call    _sprintf
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esi+ecx+1]
    mov     ecx, [esp+1C4h+var_1B0]
    mov     [esp+1C4h+var_184], eax
    mov     eax, [esp+1C4h+var_1B4]
    add     ecx, 54h
    dec     eax
    mov     [esp+1C4h+var_1B0], ecx
    mov     [esp+1C4h+var_1B4], eax
    jnz     loc_4415F8
    mov     eax, TAdynmemStructPtr

    loc_4419EE:                             ; CODE XREF: sub_441460+185j
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A4Bh]
    push    0
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aGamename                ; "GAMENAME"
    push    eax
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A4Fh]
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aPlayers_0               ; "PLAYERS"
    push    eax
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A53h]
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aMapname                 ; "MAPNAME"
    push    eax
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A57h]
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aStatus_0                ; "STATUS"
    push    eax
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A5Fh]
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aMetal_1                 ; "METAL"
    push    eax
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A63h]
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aEnergy_1                ; "ENERGY"
    push    eax
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A6Bh]
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aCommander_1             ; "COMMANDER"
    push    eax
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A73h]
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aLos_0                   ; "LOS"
    push    eax
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A67h]
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aPing                    ; "PING"
    push    eax
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+4FDh]
    mov     edx, [eax+2A6Fh]
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aFullmap                 ; "FULLMAP"
    push    eax
    call    sub_4A32A0
    push    2
    push    offset aGamename                ; char *
    mov     esi, [esp+1CCh+arg_0]
    mov     eax, [esi+4]
    push    eax                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_441BA0
    mov     ecx, eax
    mov     edi, [esi+4]
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    mov     eax, TAdynmemStructPtr
    add     edx, edi
    add     eax, 519h
    push    edx
    push    eax
    call    sub_441220

    loc_441BA0:                             ; CODE XREF: sub_441460+715j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 1B4h
    retn    4
    sub_441460 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    esi
    add     eax, 39201h
    push    edi
    mov     ecx, 10h
    mov     edi, offset dword_4FCDC8
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jnz     short loc_441BE3
    xor     eax, eax
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_441BE3:                             ; CODE XREF: .text:00441BDCj
    mov     ecx, 10h
    mov     edi, offset dword_4FCDA8
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jnz     short loc_441BFD
    mov     eax, 1
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_441BFD:                             ; CODE XREF: .text:00441BF3j
    mov     ecx, 10h
    mov     edi, offset dword_4FCD98
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jnz     short loc_441C17
    mov     eax, 2
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_441C17:                             ; CODE XREF: .text:00441C0Dj
    mov     esi, eax
    mov     ecx, 10h
    mov     edi, offset dword_4FCDB8
    xor     eax, eax
    repe cmpsb
    setnz   al
    pop     edi
    add     eax, 3
    pop     esi
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_441C30 proc near                    ; CODE XREF: .text:0044201Dp
                                            ; sub_442050+8Ep ...

    var_2B4= dword ptr -2B4h
    var_2B0= dword ptr -2B0h
    var_2AC= dword ptr -2ACh
    var_2A8= dword ptr -2A8h
    var_2A4= dword ptr -2A4h
    var_2A0= dword ptr -2A0h
    var_29C= dword ptr -29Ch
    var_298= dword ptr -298h
    var_294= dword ptr -294h
    var_290= dword ptr -290h
    var_28C= dword ptr -28Ch
    var_288= dword ptr -288h
    var_284= dword ptr -284h
    var_280= dword ptr -280h
    var_27C= dword ptr -27Ch
    var_278= dword ptr -278h
    var_274= dword ptr -274h
    var_270= dword ptr -270h
    var_26C= dword ptr -26Ch
    var_268= dword ptr -268h
    var_264= dword ptr -264h
    var_260= dword ptr -260h
    var_25C= dword ptr -25Ch
    String= byte ptr -258h
    String1= byte ptr -190h
    var_C8= dword ptr -0C8h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 2B4h
    mov     eax, TAdynmemStructPtr
    push    ebx
    xor     ebx, ebx
    add     eax, 39201h
    mov     [esp+2B8h+var_2B4], ebx
    push    esi
    mov     ecx, [eax]
    push    edi
    mov     [esp+2C0h+var_268], ecx
    mov     edi, offset dword_4FCDC8
    mov     edx, [eax+4]
    lea     esi, [esp+2C0h+var_268]
    mov     [esp+2C0h+var_264], edx
    mov     ecx, [eax+8]
    mov     [esp+2C0h+var_260], ecx
    mov     edx, [eax+0Ch]
    mov     eax, 10h
    mov     [esp+2C0h+var_25C], edx
    mov     ecx, eax
    xor     edx, edx
    repe cmpsb
    jnz     loc_441D8A
    mov     ecx, ds:dword_4FCE88
    mov     edx, ds:dword_4FCE8C
    mov     [esp+2C0h+var_2B0], ecx
    mov     ecx, ds:dword_4FCE90
    mov     [esp+2C0h+var_2A8], ecx
    mov     [esp+2C0h+var_2A0], eax
    mov     ecx, 32h
    xor     eax, eax
    lea     edi, [esp+2C0h+String]
    mov     [esp+2C0h+var_2AC], edx
    mov     edx, ds:dword_4FCE94
    mov     [esp+2C0h+var_29C], offset dword_4FCDC8
    rep stosd
    mov     eax, dword_512980
    mov     [esp+2C0h+var_2A4], edx
    test    eax, eax
    jnz     short loc_441CCD
    mov     eax, offset Data

    loc_441CCD:                             ; CODE XREF: sub_441C30+96j
    mov     esi, ds:lstrcpyA
    push    eax                             ; lpString2
    lea     eax, [esp+2C4h+String]
    push    eax                             ; lpString1
    call    esi ; lstrcpyA
    mov     edx, ds:dword_4FCECC
    mov     ecx, ds:dword_4FCEC8
    mov     eax, ds:dword_4FCED0
    mov     edi, ds:lstrlenA
    mov     [esp+2C0h+var_294], edx
    mov     [esp+2C0h+var_298], ecx
    mov     ecx, ds:dword_4FCED4
    lea     edx, [esp+2C0h+String]
    push    edx                             ; lpString
    mov     [esp+2C4h+var_290], eax
    mov     [esp+2C4h+var_28C], ecx
    call    edi ; lstrlenA
    mov     ecx, TAdynmemStructPtr
    inc     eax
    mov     [esp+2C0h+var_288], eax
    push    0                               ; int
    add     ecx, 519h
    lea     eax, [esp+2C4h+String]
    push    offset aNumber                  ; char *
    push    ecx                             ; int
    mov     [esp+2CCh+var_284], eax
    call    sub_4A0D00
    lea     edx, [esp+2C0h+String1]
    push    eax                             ; lpString2
    push    edx                             ; lpString1
    call    esi ; lstrcpyA
    mov     ecx, ds:dword_4FCEAC
    mov     eax, ds:dword_4FCEA8
    mov     edx, ds:dword_4FCEB0
    mov     [esp+2C0h+var_27C], ecx
    mov     [esp+2C0h+var_280], eax
    mov     eax, ds:dword_4FCEB4
    lea     ecx, [esp+2C0h+String1]
    mov     [esp+2C0h+var_278], edx
    push    ecx                             ; lpString
    mov     [esp+2C4h+var_274], eax
    call    edi ; lstrlenA
    inc     eax
    lea     edx, [esp+2C0h+String1]
    mov     [esp+2C0h+var_270], eax
    mov     [esp+2C0h+var_26C], edx
    mov     esi, 3
    jmp     loc_441F48
    ; ---------------------------------------------------------------------------

    loc_441D8A:                             ; CODE XREF: sub_441C30+48j
    mov     ecx, eax
    mov     edi, offset dword_4FCDA8
    lea     esi, [esp+2C0h+var_268]
    xor     edx, edx
    repe cmpsb
    jnz     loc_441E51
    mov     ecx, ds:dword_4FCE88
    mov     edx, ds:dword_4FCE8C
    mov     [esp+2C0h+var_2A0], eax
    mov     eax, TAdynmemStructPtr
    mov     [esp+2C0h+var_2B0], ecx
    mov     ecx, ds:dword_4FCE90
    mov     [esp+2C0h+var_2AC], edx
    mov     edx, ds:dword_4FCE94
    push    0                               ; int
    add     eax, 519h
    push    offset aAddress                 ; char *
    push    eax                             ; int
    mov     [esp+2CCh+var_2A8], ecx
    mov     [esp+2CCh+var_2A4], edx
    mov     [esp+2CCh+var_29C], offset dword_4FCDA8
    call    sub_4A0D00
    test    eax, eax
    jnz     short loc_441DF3
    mov     eax, offset Data

    loc_441DF3:                             ; CODE XREF: sub_441C30+1BCj
    lea     ecx, [esp+2C0h+var_C8]
    push    eax                             ; lpString2
    push    ecx                             ; lpString1
    call    ds:lstrcpyA
    mov     eax, ds:dword_4FCEEC
    mov     edx, ds:dword_4FCEE8
    mov     ecx, ds:dword_4FCEF0
    mov     [esp+2C0h+var_294], eax
    mov     [esp+2C0h+var_298], edx
    mov     edx, ds:dword_4FCEF4
    lea     eax, [esp+2C0h+var_C8]
    mov     [esp+2C0h+var_290], ecx
    push    eax                             ; lpString
    mov     [esp+2C4h+var_28C], edx
    call    ds:lstrlenA
    inc     eax
    lea     ecx, [esp+2C0h+var_C8]
    mov     [esp+2C0h+var_288], eax
    mov     [esp+2C0h+var_284], ecx
    mov     esi, 2
    jmp     loc_441F48
    ; ---------------------------------------------------------------------------

    loc_441E51:                             ; CODE XREF: sub_441C30+169j
    mov     ecx, eax
    mov     edi, offset dword_4FCD98
    lea     esi, [esp+2C0h+var_268]
    xor     edx, edx
    repe cmpsb
    jnz     short loc_441E9B
    mov     ecx, ds:dword_4FCE88
    mov     edx, ds:dword_4FCE8C
    mov     [esp+2C0h+var_2B0], ecx
    mov     ecx, ds:dword_4FCE90
    mov     [esp+2C0h+var_2AC], edx
    mov     edx, ds:dword_4FCE94
    mov     [esp+2C0h+var_2A8], ecx
    mov     [esp+2C0h+var_2A4], edx
    mov     [esp+2C0h+var_2A0], eax
    mov     [esp+2C0h+var_29C], offset dword_4FCD98
    jmp     loc_441F43
    ; ---------------------------------------------------------------------------

    loc_441E9B:                             ; CODE XREF: sub_441C30+230j
    mov     ecx, eax
    mov     edi, offset dword_4FCDB8
    lea     esi, [esp+2C0h+var_268]
    xor     edx, edx
    mov     edx, ds:dword_4FCE8C
    mov     [esp+2C0h+var_2A0], eax
    repe cmpsb
    mov     ecx, ds:dword_4FCE88
    mov     [esp+2C0h+var_2AC], edx
    mov     edx, ds:dword_4FCE94
    mov     [esp+2C0h+var_2B0], ecx
    mov     ecx, ds:dword_4FCE90
    mov     [esp+2C0h+var_2A4], edx
    mov     [esp+2C0h+var_2A8], ecx
    jnz     short loc_441F3B
    mov     eax, ds:dword_4FCF08
    mov     ecx, ds:dword_4FCF0C
    mov     edx, ds:dword_4FCF10
    mov     [esp+2C0h+var_298], eax
    mov     eax, ds:dword_4FCF14
    mov     [esp+2C0h+var_29C], offset dword_4FCDB8
    mov     dword_512778, 0
    mov     dword_51277C, 0
    mov     dword_512780, 3
    mov     [esp+2C0h+var_294], ecx
    mov     [esp+2C0h+var_290], edx
    mov     [esp+2C0h+var_28C], eax
    mov     [esp+2C0h+var_288], 14h
    mov     [esp+2C0h+var_284], offset dword_512770
    mov     esi, 2
    jmp     short loc_441F48
    ; ---------------------------------------------------------------------------

    loc_441F3B:                             ; CODE XREF: sub_441C30+2A6j
    lea     eax, [esp+2C0h+var_268]
    mov     [esp+2C0h+var_29C], eax

    loc_441F43:                             ; CODE XREF: sub_441C30+266j
    mov     esi, 1

    loc_441F48:                             ; CODE XREF: sub_441C30+155j
                                            ; sub_441C30+21Cj ...
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+2C0h+var_2B4]
    push    ecx
    push    0
    lea     edx, [esp+2C8h+var_2B0]
    push    esi
    add     eax, 14h
    push    edx
    push    eax
    call    sub_4CA880
    mov     edi, eax
    cmp     edi, 8877001Eh
    jnz     short loc_441FAD
    mov     ecx, [esp+2C0h+var_2B4]
    push    ecx
    push    offset aCompoundAddr            ; "COMPOUND ADDR"
    call    sub_4D83B0
    mov     ebx, eax
    add     esp, 8
    test    ebx, ebx
    jnz     short loc_441F8C
    mov     edi, 8007000Eh
    jmp     short loc_441FAD
    ; ---------------------------------------------------------------------------

    loc_441F8C:                             ; CODE XREF: sub_441C30+353j
    mov     ecx, TAdynmemStructPtr
    lea     edx, [esp+2C0h+var_2B4]
    push    edx
    push    ebx
    lea     eax, [esp+2C8h+var_2B0]
    push    esi
    add     ecx, 14h
    push    eax
    push    ecx
    call    sub_4CA880
    mov     edi, eax
    test    edi, edi
    jge     short loc_441FD9

    loc_441FAD:                             ; CODE XREF: sub_441C30+33Bj
                                            ; sub_441C30+35Aj
    test    ebx, ebx
    jz      short loc_441FCB
    mov     esi, ds:GlobalHandle
    push    ebx                             ; pMem
    call    esi ; GlobalHandle
    push    eax                             ; hMem
    call    ds:GlobalUnlock
    push    ebx                             ; pMem
    call    esi ; GlobalHandle
    push    eax                             ; hMem
    call    ds:GlobalFree

    loc_441FCB:                             ; CODE XREF: sub_441C30+37Fj
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 2B4h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_441FD9:                             ; CODE XREF: sub_441C30+37Bj
    mov     edx, [esp+2C0h+arg_0]
    mov     eax, [esp+2C0h+arg_4]
    mov     ecx, [esp+2C0h+var_2B4]
    pop     edi
    mov     [edx], ebx
    mov     [eax], ecx
    pop     esi
    xor     eax, eax
    pop     ebx
    add     esp, 2B4h
    retn    8
    sub_441C30 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 8
    lea     eax, [esp+4]
    lea     ecx, [esp+0]
    push    eax
    push    ecx
    mov     dword ptr [esp+8], 0
    mov     dword ptr [esp+0Ch], 0
    call    sub_441C30
    test    eax, eax
    jl      short loc_442048
    mov     edx, TAdynmemStructPtr
    mov     eax, [esp+0]
    mov     [edx+39211h], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+4]
    xor     eax, eax
    mov     [edx+39215h], ecx

    loc_442048:                             ; CODE XREF: .text:00442024j
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_442050 proc near                    ; CODE XREF: .text:004422DBp
                                            ; DATA XREF: .text:00442216o

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    esi
    mov     esi, [esp+0Ch+arg_0]
    push    edi
    xor     ebx, ebx
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     al, byte_512D90
    cmp     al, bl
    jz      short loc_442080
    cmp     dword_512C84, ebx
    jnz     loc_442125
    mov     byte_512D90, bl
    jmp     loc_442125
    ; ---------------------------------------------------------------------------

    loc_442080:                             ; CODE XREF: sub_442050+17j
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      loc_4421E1
    push    0Eh
    push    offset byte_502AE8              ; char *
    push    edi                             ; int
    call    sub_49FDF0
    cmp     eax, [esi+60h]
    jz      loc_442125
    push    0Eh
    push    offset aJoin                    ; char *
    push    edi                             ; int
    call    sub_49FDF0
    cmp     eax, [esi+60h]
    jnz     short loc_442112
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+0Ch]
    lea     edx, [esp+18h+var_4]
    push    ecx
    or      byte ptr [eax+2AAFh], 2
    mov     eax, TAdynmemStructPtr
    push    edx
    mov     [esp+20h+var_4], ebx
    and     word ptr [eax+2AAFh], 0FFFEh
    mov     [esp+14h], ebx
    call    sub_441C30
    cmp     eax, ebx
    jl      short loc_442105
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+18h+var_4]
    mov     [eax+39211h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+0Ch]
    mov     [eax+39215h], edx

    loc_442105:                             ; CODE XREF: sub_442050+95j
    push    ebx                             ; int
    push    offset aSmlbutton_2             ; char *
    call    sub_47F1A0
    jmp     short loc_442186
    ; ---------------------------------------------------------------------------

    loc_442112:                             ; CODE XREF: sub_442050+60j
    push    offset aAddress                 ; "ADDRESS"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_4421A9

    loc_442125:                             ; CODE XREF: sub_442050+1Fj
                                            ; sub_442050+2Bj ...
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+0Ch]
    lea     edx, [esp+18h+var_4]
    push    ecx
    or      byte ptr [eax+2AAFh], 1
    mov     eax, TAdynmemStructPtr
    push    edx
    mov     [esp+20h+var_4], ebx
    or      byte ptr [eax+2AAFh], 2
    mov     [esp+14h], ebx
    call    sub_441C30
    cmp     eax, ebx
    jl      short loc_442176
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+18h+var_4]
    mov     [eax+39211h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+0Ch]
    mov     [eax+39215h], edx

    loc_442176:                             ; CODE XREF: sub_442050+106j
    push    ebx                             ; int
    push    offset aSmlbutton_2             ; char *
    call    sub_47F1A0
    call    sub_4257A0

    loc_442186:                             ; CODE XREF: sub_442050+C0j
    push    80h
    push    ebx                             ; int
    push    offset aAddress                 ; char *
    push    esi                             ; int
    call    sub_4A0D00
    push    eax
    push    offset aTcpaddr                 ; "TCPADDR"
    call    sub_42F960
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4421A9:                             ; CODE XREF: sub_442050+CFj
    push    offset aPrev                    ; "PREV"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4421DB
    push    offset aCCavedogWarg_2          ; "c:\\cavedog\\wargame\\multi.cpp"
    push    305h
    push    0Fh
    call    sub_425860
    push    ebx                             ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4421DB:                             ; CODE XREF: sub_442050+166j
    push    esi
    call    sub_4AB0A0

    loc_4421E1:                             ; CODE XREF: sub_442050+34j
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    sub_442050 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    push    800h
    add     eax, 519h
    push    offset aTcp_gui                 ; "TCP.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    push    0
    push    0
    push    0
    mov     dword ptr [esi+8], offset sub_442050
    mov     ecx, TAdynmemStructPtr
    push    0
    mov     [esi+0Ch], ecx
    mov     dword ptr [esi+1Ch], 0
    call    sub_4288D0
    mov     edx, TAdynmemStructPtr
    add     edx, 14h
    push    edx
    call    sub_4CA490
    mov     eax, [esi+4]
    push    3
    push    offset aAddress                 ; "ADDRESS"
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    0
    add     ecx, 519h
    push    offset aAddress                 ; "ADDRESS"
    push    ecx
    call    sub_4A0D00
    movsx   ebx, byte_512D90
    test    ebx, ebx
    mov     edi, eax
    mov     dword ptr [esp+0Ch], 80h
    jz      short loc_44229A
    mov     byte ptr [edi], 0
    mov     edx, [esp+0Ch]
    dec     edx
    push    edx
    push    offset byte_512D90
    push    edi
    call    _strncat
    add     esp, 0Ch
    jmp     short loc_4422B0
    ; ---------------------------------------------------------------------------

    loc_44229A:                             ; CODE XREF: .text:0044227Fj
    lea     eax, [esp+0Ch]
    push    eax
    push    edi
    push    offset aTcpaddr                 ; "TCPADDR"
    call    sub_42F980
    test    eax, eax
    jnz     short loc_4422B0
    mov     [edi], al

    loc_4422B0:                             ; CODE XREF: .text:00442298j
                                            ; .text:004422ACj
    mov     ecx, TAdynmemStructPtr
    push    0
    push    edi
    add     ecx, 519h
    push    offset aAddress                 ; "ADDRESS"
    push    ecx
    call    sub_4A0BF0
    test    ebx, ebx
    jz      short loc_44230D
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_442050
    mov     esi, dword_512C84
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     ax, [ecx+2AAFh]
    test    esi, esi
    setnz   dl
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [ecx+2AAFh], dx
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_44230D:                             ; CODE XREF: .text:004422CCj
    mov     eax, [esi+4]
    push    3
    push    offset aAddress                 ; "ADDRESS"
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A7830
    mov     edx, [esi+4]
    push    3
    push    offset aAddress                 ; "ADDRESS"
    push    edx
    call    sub_49FDF0
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FC50
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_442380 proc near                    ; CODE XREF: .text:004426B0p
                                            ; DATA XREF: .text:00442698o

    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    movsx   eax, word ptr [eax+0BAh]
    test    eax, eax
    jl      short locret_44239C
    mov     ecx, dword_505490[eax*4]
    mov     dword_512774, ecx

    locret_44239C:                          ; CODE XREF: sub_442380+Dj
    retn    8
    sub_442380 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4423A0 proc near                    ; CODE XREF: .text:00442685p
                                            ; DATA XREF: .text:0044266Do

    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    movsx   eax, word ptr [eax+0BAh]
    test    eax, eax
    jl      short locret_4423B5
    inc     eax
    mov     dword_512770, eax

    locret_4423B5:                          ; CODE XREF: sub_4423A0+Dj
    retn    8
    sub_4423A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4423C0 proc near                    ; DATA XREF: .text:00442586o

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    esi
    mov     esi, [esp+0Ch+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      loc_442558
    push    0Eh
    push    offset aHost                    ; char *
    push    edi                             ; int
    call    sub_49FDF0
    cmp     eax, [esi+60h]
    jnz     short loc_442452
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+8]
    lea     edx, [esp+14h]
    xor     esi, esi
    or      byte ptr [eax+2AAFh], 1
    mov     eax, TAdynmemStructPtr
    push    ecx
    push    edx
    or      byte ptr [eax+2AAFh], 2
    mov     [esp+1Ch], esi
    mov     [esp+10h], esi
    call    sub_441C30
    cmp     eax, esi
    jl      short loc_442440
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+14h]
    mov     [eax+39211h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+8]
    mov     [eax+39215h], edx

    loc_442440:                             ; CODE XREF: sub_4423C0+60j
    push    esi                             ; int
    push    offset aSmlbutton_0             ; char *
    call    sub_47F1A0
    call    sub_4257A0
    jmp     short loc_4424C8
    ; ---------------------------------------------------------------------------

    loc_442452:                             ; CODE XREF: sub_4423C0+2Bj
    push    0Eh
    push    offset aJoin                    ; char *
    push    edi                             ; int
    call    sub_49FDF0
    cmp     eax, [esi+60h]
    jnz     loc_44251E
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+0Ch]
    lea     edx, [esp+8]
    xor     esi, esi
    or      byte ptr [eax+2AAFh], 2
    mov     eax, TAdynmemStructPtr
    push    ecx
    push    edx
    and     word ptr [eax+2AAFh], 0FFFEh
    mov     [esp+10h], esi
    mov     [esp+14h], esi
    call    sub_441C30
    cmp     eax, esi
    jl      short loc_4424BD
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+8]
    mov     [eax+39211h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+0Ch]
    mov     [eax+39215h], edx

    loc_4424BD:                             ; CODE XREF: sub_4423C0+DDj
    push    esi                             ; int
    push    offset aSmlbutton_0             ; char *
    call    sub_47F1A0

    loc_4424C8:                             ; CODE XREF: sub_4423C0+90j
    push    offset aSpeeds                  ; char *
    push    edi                             ; int
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    lea     edx, [esp+18h+var_4]
    push    4
    push    edx
    push    offset aSerbaud                 ; "SERBAUD"
    mov     [esp+24h+var_4], ecx
    call    sub_42F960
    push    offset aPorts                   ; char *
    push    edi                             ; int
    call    sub_49FF90
    movsx   eax, word ptr [eax+0BAh]
    lea     ecx, [esp+18h+var_4]
    push    4
    push    ecx
    push    offset aSerport                 ; "SERPORT"
    mov     [esp+24h+var_4], eax
    call    sub_42F960
    pop     edi
    pop     esi
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44251E:                             ; CODE XREF: sub_4423C0+A2j
    push    offset aPrev                    ; "PREV"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_442552
    push    offset aCCavedogWarg_2          ; "c:\\cavedog\\wargame\\multi.cpp"
    push    395h
    push    0Fh
    call    sub_425860
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_442552:                             ; CODE XREF: sub_4423C0+16Bj
    push    esi
    call    sub_4AB0A0

    loc_442558:                             ; CODE XREF: sub_4423C0+15j
    pop     edi
    pop     esi
    add     esp, 8
    retn    4
    sub_4423C0 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    sub     esp, 8
    mov     eax, TAdynmemStructPtr
    push    esi
    push    800h
    add     eax, 519h
    push    offset aSerial_gui              ; "SERIAL.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    push    0
    push    0
    push    0
    mov     dword ptr [esi+8], offset sub_4423C0
    mov     ecx, TAdynmemStructPtr
    push    0
    mov     [esi+0Ch], ecx
    mov     dword ptr [esi+1Ch], 0
    call    sub_4288D0
    mov     edx, TAdynmemStructPtr
    add     edx, 14h
    push    edx
    call    sub_4CA490
    mov     eax, TAdynmemStructPtr
    push    0
    push    4
    push    offset aCom1                    ; "COM1"
    add     eax, 519h
    push    offset aPorts                   ; "PORTS"
    push    eax
    call    sub_4A32A0
    mov     ecx, TAdynmemStructPtr
    push    0
    push    6
    push    offset a115200                  ; "115200"
    add     ecx, 519h
    push    offset aSpeeds                  ; "SPEEDS"
    push    ecx
    call    sub_4A32A0
    lea     edx, [esp+8]
    lea     eax, [esp+4]
    push    edx
    push    eax
    push    offset aSerbaud                 ; "SERBAUD"
    mov     dword ptr [esp+14h], 4
    call    sub_42F980
    test    eax, eax
    jz      short loc_44262D
    mov     ecx, [esp+4]
    mov     edx, TAdynmemStructPtr
    push    ecx
    add     edx, 519h
    push    offset aSpeeds                  ; "SPEEDS"
    push    edx
    call    sub_4A2E40

    loc_44262D:                             ; CODE XREF: .text:0044260Fj
    lea     eax, [esp+8]
    lea     ecx, [esp+4]
    push    eax
    push    ecx
    push    offset aSerport                 ; "SERPORT"
    call    sub_42F980
    test    eax, eax
    jz      short loc_44265F
    mov     edx, [esp+4]
    mov     eax, TAdynmemStructPtr
    push    edx
    add     eax, 519h
    push    offset aPorts                   ; "PORTS"
    push    eax
    call    sub_4A2E40

    loc_44265F:                             ; CODE XREF: .text:00442643j
    mov     ecx, [esi+4]
    push    offset aPorts                   ; "PORTS"
    push    ecx
    call    sub_49FF90
    mov     dword ptr [eax+0CEh], offset sub_4423A0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    eax
    push    edx
    call    sub_4423A0
    mov     eax, [esi+4]
    push    offset aSpeeds                  ; "SPEEDS"
    push    eax
    call    sub_49FF90
    mov     dword ptr [eax+0CEh], offset sub_442380
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_442380
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    pop     esi
    add     esp, 8
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4426E0 proc near                    ; CODE XREF: sub_442A30+11Ap
                                            ; sub_442A30+1E2p ...
    push    ebx
    mov     ebx, dword_51298C
    push    esi
    push    edi
    mov     byte ptr [ebx], 0
    mov     esi, dword_512988
    xor     edx, edx

    loc_4426F4:                             ; CODE XREF: sub_4426E0+57j
    lea     edi, [esi+edx]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     esi, dword_512988
    or      ecx, 0FFFFFFFFh
    lea     edi, [esi+edx]
    add     edx, 102h
    repne scasb
    not     ecx
    dec     ecx
    cmp     edx, 1428h
    lea     ebx, [ebx+ecx+1]
    jl      short loc_4426F4
    mov     ecx, TAdynmemStructPtr
    push    offset aAccounts                ; char *
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FF90
    mov     ecx, dword_51298C
    mov     edx, TAdynmemStructPtr
    movsx   esi, word ptr [eax+0BAh]
    push    0
    push    14h
    push    ecx
    add     edx, 519h
    push    offset aAccounts                ; "ACCOUNTS"
    push    edx
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    esi
    add     eax, 519h
    push    offset aAccounts                ; "ACCOUNTS"
    push    eax
    call    sub_4A2E40
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_4426E0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    esi
    push    offset aAccounts                ; "ACCOUNTS"
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_49FF90
    mov     esi, eax
    test    esi, esi
    jz      loc_4428E0
    mov     ecx, dword_512988
    test    ecx, ecx
    jz      loc_4428E0
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    push    edi
    shl     edx, 7
    add     edx, eax
    push    ebx
    lea     eax, [ecx+edx*2]
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    offset aName_0                  ; "NAME"
    push    ecx
    call    sub_4A0D00
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    shl     edx, 7
    add     edx, eax
    mov     eax, dword_512988
    lea     ecx, [eax+edx*2+81h]
    mov     edx, TAdynmemStructPtr
    push    ecx
    add     edx, 519h
    push    offset aNumber                  ; "NUMBER"
    push    edx
    call    sub_4A0D00
    mov     ebx, dword_51298C
    xor     edx, edx
    mov     byte ptr [ebx], 0
    mov     esi, dword_512988

    loc_442840:                             ; CODE XREF: .text:00442883j
    lea     edi, [esi+edx]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     esi, dword_512988
    or      ecx, 0FFFFFFFFh
    lea     edi, [esi+edx]
    add     edx, 102h
    repne scasb
    not     ecx
    dec     ecx
    cmp     edx, 1428h
    lea     ebx, [ebx+ecx+1]
    jl      short loc_442840
    mov     ecx, TAdynmemStructPtr
    push    offset aAccounts                ; "ACCOUNTS"
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax
    call    sub_49FF90
    mov     ecx, dword_51298C
    mov     edx, TAdynmemStructPtr
    movsx   esi, word ptr [eax+0BAh]
    push    0
    push    14h
    push    ecx
    add     edx, 519h
    push    offset aAccounts                ; "ACCOUNTS"
    push    edx
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    esi
    add     eax, 519h
    push    offset aAccounts                ; "ACCOUNTS"
    push    eax
    call    sub_4A2E40
    pop     ebx
    pop     edi

    loc_4428E0:                             ; CODE XREF: .text:004427BEj
                                            ; .text:004427CCj
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4428F0 proc near                    ; CODE XREF: .text:0044342Cp
                                            ; DATA XREF: .text:00443416o

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    movsx   eax, word ptr [eax+0BAh]
    test    eax, eax
    jl      short locret_44296A
    push    edi
    mov     ecx, dword_512988
    push    esi
    mov     esi, eax
    shl     esi, 7
    mov     edi, [esp+8+arg_0]
    add     esi, eax
    shl     esi, 1
    add     ecx, esi
    push    0
    push    ecx
    push    offset aName_0                  ; "NAME"
    push    edi
    call    sub_4A0BF0
    mov     edx, dword_512988
    push    0
    lea     eax, [edx+esi+81h]
    push    eax
    push    offset aNumber                  ; "NUMBER"
    push    edi
    call    sub_4A0BF0
    mov     ecx, [edi+18h]
    push    3
    push    offset aName_0                  ; char *
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FDF0
    mov     esi, eax
    push    esi
    push    edi
    call    sub_4A7830
    push    esi
    push    edi
    call    sub_49FC50
    push    edi                             ; int
    call    sub_49FA90
    pop     esi
    pop     edi

    locret_44296A:                          ; CODE XREF: sub_4428F0+Dj
    retn    8
    sub_4428F0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, dword_512988
    sub     esp, 104h
    test    eax, eax
    jz      loc_442A22
    mov     eax, TAdynmemStructPtr
    push    offset aAccounts                ; "ACCOUNTS"
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_49FF90
    mov     ax, [eax+0BAh]
    test    ax, ax
    jle     short loc_442A0C
    movsx   edx, ax
    mov     ecx, dword_512988
    mov     eax, edx
    shl     eax, 7
    add     eax, edx
    push    edi
    push    esi
    lea     edi, [esp+8]
    lea     esi, [ecx+eax*2]
    mov     ecx, 40h
    rep movsd
    test    edx, edx
    movsw
    jle     short loc_4429F7
    mov     eax, edx
    shl     eax, 7
    add     eax, edx
    shl     eax, 1

    loc_4429D7:                             ; CODE XREF: .text:004429F5j
    mov     ecx, dword_512988
    lea     edi, [ecx+eax]
    mov     ecx, 40h
    sub     eax, 102h
    dec     edx
    lea     esi, [edi-102h]
    rep movsd
    movsw
    jnz     short loc_4429D7

    loc_4429F7:                             ; CODE XREF: .text:004429CCj
    mov     edi, dword_512988
    mov     ecx, 40h
    lea     esi, [esp+8]
    rep movsd
    movsw
    pop     esi
    pop     edi

    loc_442A0C:                             ; CODE XREF: .text:004429A6j
    mov     edx, dword_512988
    push    1428h
    push    edx
    push    offset aModemnumbers            ; "MODEMNUMBERS"
    call    sub_42F960

    loc_442A22:                             ; CODE XREF: .text:0044297Dj
    add     esp, 104h
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_442A30 proc near                    ; DATA XREF: .text:00443154o

    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_104= dword ptr -104h
    arg_0= dword ptr  4

    sub     esp, 10Ch
    push    ebx
    mov     ebx, [esp+110h+arg_0]
    push    esi
    push    edi
    mov     eax, [ebx+18h]
    mov     edi, [eax+4]
    mov     eax, [ebx+60h]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_442AB2
    mov     eax, dword_512980
    test    eax, eax
    jz      short loc_442A6A
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword_512980, 0

    loc_442A6A:                             ; CODE XREF: sub_442A30+25j
    mov     eax, dword_51298C
    test    eax, eax
    jz      short loc_442A86
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51298C, 0

    loc_442A86:                             ; CODE XREF: sub_442A30+41j
    mov     eax, dword_512988
    test    eax, eax
    jz      loc_44305E
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword_512988, 0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_442AB2:                             ; CODE XREF: sub_442A30+1Cj
    push    offset aName_0                  ; "NAME"
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      loc_442B7B
    mov     ecx, TAdynmemStructPtr
    push    offset aAccounts                ; char *
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FF90
    mov     esi, eax
    test    esi, esi
    jz      short loc_442B4F
    mov     ecx, dword_512988
    test    ecx, ecx
    jz      short loc_442B4F
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    shl     edx, 7
    add     edx, eax
    lea     eax, [ecx+edx*2]
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; int
    add     ecx, 519h
    push    offset aName_0                  ; char *
    push    ecx                             ; int
    call    sub_4A0D00
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    shl     edx, 7
    add     edx, eax
    mov     eax, dword_512988
    lea     ecx, [eax+edx*2+81h]
    mov     edx, TAdynmemStructPtr
    push    ecx                             ; int
    add     edx, 519h
    push    offset aNumber                  ; char *
    push    edx                             ; int
    call    sub_4A0D00
    call    sub_4426E0

    loc_442B4F:                             ; CODE XREF: sub_442A30+B3j
                                            ; sub_442A30+BDj
    push    3
    push    offset aNumber                  ; char *
    push    edi                             ; int
    call    sub_49FDF0
    push    eax
    push    ebx
    call    sub_49FC50
    push    ebx                             ; int
    call    sub_49FA90
    push    ebx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_442B7B:                             ; CODE XREF: sub_442A30+8Fj
    push    offset aNumber                  ; "NUMBER"
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      loc_442C7F
    mov     eax, TAdynmemStructPtr
    push    offset aAccounts                ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FF90
    mov     esi, eax
    test    esi, esi
    jz      short loc_442C17
    mov     ecx, dword_512988
    test    ecx, ecx
    jz      short loc_442C17
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    shl     edx, 7
    add     edx, eax
    lea     eax, [ecx+edx*2]
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; int
    add     ecx, 519h
    push    offset aName_0                  ; char *
    push    ecx                             ; int
    call    sub_4A0D00
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    shl     edx, 7
    add     edx, eax
    mov     eax, dword_512988
    lea     ecx, [eax+edx*2+81h]
    mov     edx, TAdynmemStructPtr
    push    ecx                             ; int
    add     edx, 519h
    push    offset aNumber                  ; char *
    push    edx                             ; int
    call    sub_4A0D00
    call    sub_4426E0

    loc_442C17:                             ; CODE XREF: sub_442A30+17Bj
                                            ; sub_442A30+185j
    push    1
    push    offset aJoin                    ; char *
    push    edi                             ; int
    call    sub_49FDF0
    push    eax
    push    ebx
    call    sub_4A7830
    push    1
    push    offset aJoin                    ; char *
    push    edi                             ; int
    call    sub_49FDF0
    push    eax
    push    ebx
    call    sub_49FC50
    lea     edx, [edi+0CCh]
    mov     edi, offset aJoin               ; "JOIN"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    push    ebx                             ; int
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    call    sub_49FA90
    push    ebx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_442C7F:                             ; CODE XREF: sub_442A30+158j
    push    0Eh
    push    offset aHost                    ; char *
    push    edi                             ; int
    call    sub_49FDF0
    cmp     eax, [ebx+60h]
    jnz     loc_442E3F
    mov     ecx, TAdynmemStructPtr
    push    offset aAccounts                ; char *
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FF90
    mov     esi, eax
    test    esi, esi
    jz      short loc_442D1F
    mov     ecx, dword_512988
    test    ecx, ecx
    jz      short loc_442D1F
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    shl     edx, 7
    add     edx, eax
    lea     eax, [ecx+edx*2]
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; int
    add     ecx, 519h
    push    offset aName_0                  ; char *
    push    ecx                             ; int
    call    sub_4A0D00
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    shl     edx, 7
    add     edx, eax
    mov     eax, dword_512988
    lea     ecx, [eax+edx*2+81h]
    mov     edx, TAdynmemStructPtr
    push    ecx                             ; int
    add     edx, 519h
    push    offset aNumber                  ; char *
    push    edx                             ; int
    call    sub_4A0D00
    call    sub_4426E0

    loc_442D1F:                             ; CODE XREF: sub_442A30+283j
                                            ; sub_442A30+28Dj
    mov     eax, dword_512988
    test    eax, eax
    jz      loc_442DC7
    mov     eax, TAdynmemStructPtr
    push    offset aAccounts                ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FF90
    mov     ax, [eax+0BAh]
    test    ax, ax
    jle     short loc_442DB1
    movsx   edx, ax
    mov     ecx, dword_512988
    mov     eax, edx
    shl     eax, 7
    add     eax, edx
    lea     edi, [esp+11Ch+var_108]
    test    edx, edx
    lea     esi, [ecx+eax*2]
    mov     ecx, 40h
    rep movsd
    movsw
    jle     short loc_442D9E
    mov     eax, edx
    shl     eax, 7
    add     eax, edx
    shl     eax, 1

    loc_442D7E:                             ; CODE XREF: sub_442A30+36Cj
    mov     ecx, dword_512988
    lea     edi, [ecx+eax]
    mov     ecx, 40h
    sub     eax, 102h
    dec     edx
    lea     esi, [edi-102h]
    rep movsd
    movsw
    jnz     short loc_442D7E

    loc_442D9E:                             ; CODE XREF: sub_442A30+343j
    mov     edi, dword_512988
    mov     ecx, 40h
    lea     esi, [esp+11Ch+var_108]
    rep movsd
    movsw

    loc_442DB1:                             ; CODE XREF: sub_442A30+31Fj
    mov     edx, dword_512988
    push    1428h
    push    edx
    push    offset aModemnumbers            ; "MODEMNUMBERS"
    call    sub_42F960

    loc_442DC7:                             ; CODE XREF: sub_442A30+2F6j
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+11Ch+var_10C]
    mov     [esp+11Ch+var_10C], 0
    mov     dword ptr [esp+0Ch], 0
    or      byte ptr [eax+2AAFh], 1
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2AAFh], 2
    lea     eax, [esp+0Ch]
    push    eax
    push    ecx
    call    sub_441C30
    test    eax, eax
    jl      short loc_442E22
    mov     edx, TAdynmemStructPtr
    mov     eax, [esp+11Ch+var_10C]
    mov     [edx+39211h], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+0Ch]
    mov     [edx+39215h], ecx

    loc_442E22:                             ; CODE XREF: sub_442A30+3D0j
    push    0                               ; int
    push    offset aSmlbutton_0             ; char *
    call    sub_47F1A0
    call    sub_4257A0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_442E3F:                             ; CODE XREF: sub_442A30+25Fj
    push    0Eh
    push    offset aJoin                    ; char *
    push    edi                             ; int
    call    sub_49FDF0
    cmp     eax, [ebx+60h]
    jz      short loc_442EAA
    push    offset aAccounts                ; "ACCOUNTS"
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_442EAA
    push    offset aPrev                    ; "PREV"
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_442E98
    push    offset aCCavedogWarg_2          ; "c:\\cavedog\\wargame\\multi.cpp"
    push    47Fh
    push    0Fh
    call    sub_425860
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_442E98:                             ; CODE XREF: sub_442A30+43Dj
    push    ebx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_442EAA:                             ; CODE XREF: sub_442A30+41Fj
                                            ; sub_442A30+42Ej
    mov     eax, TAdynmemStructPtr
    push    offset aAccounts                ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FF90
    mov     esi, eax
    test    esi, esi
    jz      short loc_442F33
    mov     ecx, dword_512988
    test    ecx, ecx
    jz      short loc_442F33
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    shl     edx, 7
    add     edx, eax
    lea     eax, [ecx+edx*2]
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; int
    add     ecx, 519h
    push    offset aName_0                  ; char *
    push    ecx                             ; int
    call    sub_4A0D00
    movsx   eax, word ptr [esi+0BAh]
    mov     edx, eax
    shl     edx, 7
    add     edx, eax
    mov     eax, dword_512988
    lea     ecx, [eax+edx*2+81h]
    mov     edx, TAdynmemStructPtr
    push    ecx                             ; int
    add     edx, 519h
    push    offset aNumber                  ; char *
    push    edx                             ; int
    call    sub_4A0D00
    call    sub_4426E0

    loc_442F33:                             ; CODE XREF: sub_442A30+497j
                                            ; sub_442A30+4A1j
    mov     eax, dword_512988
    test    eax, eax
    jz      loc_442FDB
    mov     eax, TAdynmemStructPtr
    push    offset aAccounts                ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FF90
    mov     ax, [eax+0BAh]
    test    ax, ax
    jle     short loc_442FC5
    movsx   edx, ax
    mov     ecx, dword_512988
    mov     eax, edx
    shl     eax, 7
    add     eax, edx
    lea     edi, [esp+120h+var_10C]
    test    edx, edx
    lea     esi, [ecx+eax*2]
    mov     ecx, 40h
    rep movsd
    movsw
    jle     short loc_442FB2
    mov     eax, edx
    shl     eax, 7
    add     eax, edx
    shl     eax, 1

    loc_442F92:                             ; CODE XREF: sub_442A30+580j
    mov     ecx, dword_512988
    lea     edi, [ecx+eax]
    mov     ecx, 40h
    sub     eax, 102h
    dec     edx
    lea     esi, [edi-102h]
    rep movsd
    movsw
    jnz     short loc_442F92

    loc_442FB2:                             ; CODE XREF: sub_442A30+557j
    mov     edi, dword_512988
    mov     ecx, 40h
    lea     esi, [esp+120h+var_10C]
    rep movsd
    movsw

    loc_442FC5:                             ; CODE XREF: sub_442A30+533j
    mov     edx, dword_512988
    push    1428h
    push    edx
    push    offset aModemnumbers            ; "MODEMNUMBERS"
    call    sub_42F960

    loc_442FDB:                             ; CODE XREF: sub_442A30+50Aj
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+0Ch]
    mov     dword ptr [esp+0Ch], 0
    mov     dword ptr [esp+10h], 0
    or      byte ptr [eax+2AAFh], 2
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+2AAFh], 0FFFEh
    lea     eax, [esp+10h]
    push    eax
    push    ecx
    call    sub_441C30
    test    eax, eax
    jl      short loc_443038
    mov     edx, TAdynmemStructPtr
    mov     eax, [esp+0Ch]
    mov     [edx+39211h], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+10h]
    mov     [edx+39215h], ecx

    loc_443038:                             ; CODE XREF: sub_442A30+5E6j
    push    0                               ; int
    push    offset aSmlbutton_0             ; char *
    call    sub_47F1A0
    push    1
    push    1
    push    0FAh
    push    offset aConnecting___P          ; int
    call    sub_4C5740
    push    eax
    push    ebx
    call    sub_4ABD90

    loc_44305E:                             ; CODE XREF: sub_442A30+5Dj
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10Ch
    retn    4
    sub_442A30 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_443070(int,int,LPCSTR lpString)
    sub_443070 proc near                    ; DATA XREF: .text:00443223o

    arg_0= dword ptr  8
    lpString= dword ptr  10h

    push    ebx
    mov     ebx, [esp+lpString]
    push    ebp
    push    esi
    mov     esi, [esp+8+arg_0]
    push    edi
    mov     ecx, 10h
    mov     edi, offset dword_4FCEC8
    xor     eax, eax
    repe cmpsb
    jnz     short loc_4430EE
    mov     ebp, ds:lstrlenA
    push    ebx                             ; lpString
    call    ebp ; lstrlenA
    test    eax, eax
    jz      short loc_4430EE

    loc_443099:                             ; CODE XREF: sub_443070+7Cj
    mov     edx, dword_512980
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4430BB
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [ecx+edx+1]

    loc_4430BB:                             ; CODE XREF: sub_443070+3Bj
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    ebx                             ; lpString
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    inc     dword_512984
    call    ebp ; lstrlenA
    lea     ebx, [ebx+eax+1]
    push    ebx                             ; lpString
    call    ebp ; lstrlenA
    test    eax, eax
    jnz     short loc_443099

    loc_4430EE:                             ; CODE XREF: sub_443070+1Aj
                                            ; sub_443070+27j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    10h
    sub_443070 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 28h
    mov     ecx, ds:dword_4FCDCC
    mov     eax, ds:dword_4FCDC8
    mov     edx, ds:dword_4FCDD0
    push    ebx
    push    ebp
    mov     [esp+24h], ecx
    mov     ecx, TAdynmemStructPtr
    push    esi
    push    edi
    mov     [esp+28h], eax
    mov     eax, ds:dword_4FCDD4
    push    800h
    add     ecx, 519h
    xor     ebx, ebx
    push    offset aModem_gui               ; "MODEM.GUI"
    push    ecx
    mov     [esp+20h], ebx
    mov     [esp+1Ch], ebx
    mov     [esp+3Ch], edx
    mov     [esp+40h], eax
    call    sub_4AA8F0
    push    ebx
    mov     dword ptr [eax+8], offset sub_442A30
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    ebx
    push    ebx
    mov     [esp+2Ch], eax
    mov     [eax+0Ch], edx
    call    sub_4288D0
    mov     eax, TAdynmemStructPtr
    add     eax, 14h
    push    eax
    call    sub_4CA490
    lea     ecx, [esp+20h]
    lea     edx, [esp+28h]
    push    ecx
    push    edx
    call    sub_4CA900
    cmp     eax, ebx
    jl      loc_443431
    lea     eax, [esp+10h]
    lea     ecx, [esp+20h]
    push    eax
    push    ebx
    push    ebx
    push    ecx
    call    sub_4CA990
    cmp     eax, 8877001Eh
    jnz     loc_443431
    mov     edx, [esp+10h]
    push    edx
    push    offset aModemaddr               ; "MODEMADDR"
    call    sub_4D83B0
    add     esp, 8
    cmp     eax, ebx
    mov     [esp+14h], eax
    jz      loc_443431
    mov     ecx, [esp+14h]
    lea     eax, [esp+10h]
    push    eax
    push    ecx
    lea     edx, [esp+28h]
    push    ebx
    push    edx
    call    sub_4CA990
    cmp     eax, ebx
    jl      loc_443431
    push    0C8h
    push    offset aModeminfo               ; "MODEMINFO"
    call    sub_4D83B0
    mov     esi, [esp+1Ch]
    mov     edi, eax
    mov     ecx, 32h
    xor     eax, eax
    add     esp, 8
    mov     dword_512980, edi
    rep stosd
    mov     eax, [esp+10h]
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    eax
    push    esi
    add     ecx, 14h
    push    offset sub_443070
    push    ecx
    mov     dword_512984, ebx
    call    sub_4CA8C0
    mov     ecx, dword_512984
    cmp     ecx, ebx
    jnz     short loc_4432A4
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4A9660
    push    offset aUnableToFindAn          ; "Unable to find any modems"
    call    sub_425730
    push    offset aCCavedogWarg_2          ; "c:\\cavedog\\wargame\\multi.cpp"
    push    4E4h
    push    0Fh
    call    sub_425860
    push    offset aCCavedogWarg_2          ; "c:\\cavedog\\wargame\\multi.cpp"
    push    4E5h
    push    ebx
    call    sub_4257E0
    mov     eax, dword_512980
    push    eax
    call    sub_4D85A0
    add     esp, 4
    push    esi
    call    sub_4D85A0
    add     esp, 4
    lea     ecx, [esp+20h]
    push    ecx
    call    sub_4CA940
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn
    ; ---------------------------------------------------------------------------

    loc_4432A4:                             ; CODE XREF: .text:0044323Cj
    cmp     eax, ebx
    jl      loc_443431
    mov     edx, dword_512980
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ecx
    push    edx
    add     eax, 519h
    push    offset aModems                  ; "MODEMS"
    push    eax
    call    sub_4A32A0
    push    1428h
    push    offset aModemaccounts           ; "MODEMACCOUNTS"
    call    sub_4D83B0
    add     esp, 8
    lea     ecx, [esp+18h]
    mov     dword_512988, eax
    mov     dword ptr [esp+18h], 1428h
    push    ecx
    push    eax
    push    offset aModemnumbers            ; "MODEMNUMBERS"
    call    sub_42F980
    cmp     eax, ebx
    jnz     short loc_443344
    xor     edx, edx

    loc_4432FF:                             ; CODE XREF: .text:00443342j
    mov     eax, dword_512988
    mov     edi, offset aUnused             ; "UNUSED"
    or      ecx, 0FFFFFFFFh
    lea     ebp, [eax+edx]
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    add     edx, 102h
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    cmp     edx, 1428h
    rep movsb
    mov     ecx, dword_512988
    mov     [ecx+edx-81h], bl
    jl      short loc_4432FF

    loc_443344:                             ; CODE XREF: .text:004432FBj
    push    0A00h
    push    offset aAccountnames            ; "ACCOUNTNAMES"
    call    sub_4D83B0
    mov     dword_51298C, eax
    add     esp, 8
    mov     [eax], bl
    mov     esi, dword_512988
    mov     ebp, eax
    xor     edx, edx

    loc_443367:                             ; CODE XREF: .text:004433AAj
    lea     edi, [esi+edx]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     esi, dword_512988
    or      ecx, 0FFFFFFFFh
    lea     edi, [esi+edx]
    add     edx, 102h
    repne scasb
    not     ecx
    dec     ecx
    cmp     edx, 1428h
    lea     ebp, [ebp+ecx+1]
    jl      short loc_443367
    mov     ecx, TAdynmemStructPtr
    push    offset aAccounts                ; "ACCOUNTS"
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax
    call    sub_49FF90
    mov     ecx, dword_51298C
    mov     edx, TAdynmemStructPtr
    movsx   esi, word ptr [eax+0BAh]
    push    ebx
    push    14h
    push    ecx
    add     edx, 519h
    push    offset aAccounts                ; "ACCOUNTS"
    push    edx
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    esi
    add     eax, 519h
    push    offset aAccounts                ; "ACCOUNTS"
    push    eax
    call    sub_4A2E40
    push    offset aAccounts                ; "ACCOUNTS"
    mov     ecx, [esp+20h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_49FF90
    mov     dword ptr [eax+0CEh], offset sub_4428F0
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4428F0

    loc_443431:                             ; CODE XREF: .text:0044318Fj
                                            ; .text:004431ABj ...
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    lea     eax, [esp+20h]
    push    eax
    call    sub_4CA940
    mov     ecx, [esp+14h]
    push    ecx
    call    sub_4D85A0
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_443480 proc near                    ; DATA XREF: sub_4435A0+21o

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= byte ptr -14h
    var_10= byte ptr -10h
    arg_0= dword ptr  4

    sub     esp, 1Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+2Ch+arg_0]
    mov     eax, [edi+18h]
    mov     ecx, [eax+4]
    mov     eax, [edi+60h]
    cmp     eax, 0FFFFFFFFh
    mov     [esp+2Ch+var_18], ecx
    jz      loc_44357B
    push    offset byte_502AE8
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      loc_443575
    mov     ebp, ds:wsprintfA
    xor     esi, esi
    mov     [esp+2Ch+arg_0], esi
    mov     [esp+2Ch+var_1C], esi

    loc_4434C4:                             ; CODE XREF: sub_443480+A9j
    push    esi
    lea     edx, [esp+30h+var_10]
    push    offset aChkD                    ; LPCSTR
    push    edx                             ; LPSTR
    call    ebp ; wsprintfA
    mov     ecx, [esp+38h+var_18]
    add     esp, 0Ch
    lea     eax, [esp+2Ch+var_10]
    push    1
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_49FDF0
    lea     edx, [esp+30h+var_14]
    mov     ebx, eax
    push    edx                             ; char *
    push    edi                             ; int
    call    sub_4A04F0
    test    al, al
    jz      short loc_44352B
    push    ebx
    push    edi
    call    sub_4A0F30
    fld     ds:dbl_4FD2F0
    fild    dword ptr [esp+10h]
    mov     [esp+30h+var_18], eax
    call    __CIpow
    fimul   [esp+30h+var_18]
    fiadd   dword ptr [esp+30h]
    call    __ftol
    inc     esi
    mov     [esp+30h], eax
    cmp     esi, 10h
    mov     [esp+10h], esi
    jb      short loc_4434C4

    loc_44352B:                             ; CODE XREF: sub_443480+74j
    push    14h
    call    sub_491C80
    mov     eax, [esp+30h]
    push    eax
    call    RIWrapper_Enable
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2BEEh], 10h
    jnz     short loc_443564
    cmp     byte ptr [eax+2BBFh], 14h
    jz      short loc_443564
    mov     byte ptr [eax+2BC0h], 11h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_443564:                             ; CODE XREF: sub_443480+C8j
                                            ; sub_443480+D1j
    mov     byte ptr [eax+2BC0h], 15h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_443575:                             ; CODE XREF: sub_443480+2Ej
    push    edi
    call    sub_4AB0A0

    loc_44357B:                             ; CODE XREF: sub_443480+1Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    4
    sub_443480 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_443590:                             ; DATA XREF: sub_4435A0+3Ao
    jmp     sub_456310
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4435A0 proc near                    ; CODE XREF: sub_4436E0+5Fp

    var_10= byte ptr -10h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    sub     esp, 10h
    add     eax, 519h
    push    ebp
    push    esi
    push    800h
    push    offset aReport_gui              ; "REPORT.GUI"
    push    eax
    call    sub_4AA8F0
    push    0
    mov     dword ptr [eax+8], offset sub_443480
    mov     ecx, TAdynmemStructPtr
    push    1
    push    0
    push    offset aScorebg                 ; "scorebg"
    mov     [eax+0Ch], ecx
    mov     dword ptr [eax+1Ch], offset loc_443590
    call    sub_4288D0
    xor     esi, esi
    mov     ebp, [esp+18h+arg_0]
    cmp     dword ptr [ebp+0], 0
    jbe     loc_443680
    push    edi
    mov     edi, ds:wsprintfA
    push    ebx
    mov     ebx, [esp+20h+arg_4]

    loc_443602:                             ; CODE XREF: sub_4435A0+DCj
    push    esi
    lea     edx, [esp+24h+var_10]
    push    offset aChkD                    ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+20h+var_10]
    add     ecx, 519h
    push    1                               ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    push    esi
    lea     edx, [esp+24h+var_10]
    push    offset aServiceD                ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+20h+var_10]
    add     ecx, 519h
    push    1                               ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     edx, [ebx]
    mov     ecx, TAdynmemStructPtr
    push    80h
    lea     eax, [esp+24h+var_10]
    push    edx
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_4A0BF0
    mov     eax, [ebp+0]
    inc     esi
    add     ebx, 4
    cmp     esi, eax
    jb      short loc_443602
    pop     ebx
    pop     edi

    loc_443680:                             ; CODE XREF: sub_4435A0+50j
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    mov     eax, TAdynmemStructPtr
    push    141h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    push    13h
    call    sub_491C80
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_49FA90
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FAD0
    pop     esi
    pop     ebp
    add     esp, 10h
    retn    8
    sub_4435A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4436E0 proc near                    ; CODE XREF: sub_440D70+29Bp
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+TAdynmemStruct.MapFile]
    call    sub_435100
    cmp     eax, 3
    jnz     loc_4437BB
    mov     ecx, TAdynmemStructPtr
    push    14h
    movsx   esi, byte ptr [ecx+2CBEh]
    call    sub_491C80
    push    offset dword_512788
    push    offset dword_5054A8             ; int
    call    LoadReporter
    test    eax, eax
    jnz     short loc_443751
    mov     eax, dword_5054A8
    test    eax, eax
    jbe     loc_4437B5
    push    13h
    call    sub_491C80
    push    offset dword_512788
    push    offset dword_5054A8
    call    sub_4435A0
    push    esi
    call    sub_491C80
    mov     eax, 1
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_443751:                             ; CODE XREF: sub_4436E0+3Fj
    cmp     eax, 4
    jz      short loc_4437B5
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C69A0
    push    0
    push    1
    push    190h
    push    offset aUnableToInitia          ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    push    0
    push    1
    push    0
    push    offset aReporterror             ; "ReportError"
    call    sub_4288D0
    mov     edx, TAdynmemStructPtr
    push    offset aMsgbox_gui              ; "MSGBOX.GUI"
    add     edx, 519h
    push    edx
    call    sub_49F9C0

    loc_4437B5:                             ; CODE XREF: sub_4436E0+48j
                                            ; sub_4436E0+74j
    push    esi
    call    sub_491C80

    loc_4437BB:                             ; CODE XREF: sub_4436E0+14j
    xor     eax, eax
    pop     esi
    retn
    sub_4436E0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4437C0 proc near                    ; CODE XREF: sub_443CB0+32Cp
                                            ; DATA XREF: sub_443CB0+2Do

    var_23= dword ptr -23h
    var_1F= dword ptr -1Fh
    var_1B= dword ptr -1Bh
    var_17= dword ptr -17h
    arg_0= dword ptr  4

    sub     esp, 0BCh
    push    ebx
    push    ebp
    mov     ebp, [esp+0C4h+arg_0]
    push    esi
    push    edi
    mov     eax, [ebp+18h]
    mov     ebx, [eax+4]
    mov     al, byte_512D90
    test    al, al
    jz      short loc_4437F8
    mov     eax, dword_512C84
    xor     edi, edi
    cmp     eax, edi
    mov     byte_512D90, 0
    jnz     loc_4439AC
    jmp     short loc_4437FA
    ; ---------------------------------------------------------------------------

    loc_4437F8:                             ; CODE XREF: sub_4437C0+1Ej
    xor     edi, edi

    loc_4437FA:                             ; CODE XREF: sub_4437C0+36j
    cmp     dword ptr [ebp+60h], 0FFFFFFFFh
    jnz     short loc_443879
    xor     esi, esi

    loc_443802:                             ; CODE XREF: sub_4437C0+6Aj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+esi+2A4Bh]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esi, 4
    add     esp, 4
    cmp     esi, 3Ch
    mov     [eax+esi+2A47h], edi
    jl      short loc_443802
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+2AABh]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     ecx, [eax+2AA7h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     [edx+2AABh], edi
    mov     eax, TAdynmemStructPtr
    mov     [eax+2AA7h], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_443879:                             ; CODE XREF: sub_4437C0+3Ej
    push    0Eh
    push    offset aUpdate                  ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, [ebp+60h]
    jnz     loc_443917
    push    offset aPassword_0              ; char *
    push    ebx                             ; int
    call    sub_4A0010
    cmp     eax, edi
    jz      short loc_4438EA
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    lea     edi, [eax+0B6h]
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     edx, [ecx+eax*2+1B8Ah]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     edx, 80h
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    xor     edi, edi

    loc_4438EA:                             ; CODE XREF: sub_4437C0+DCj
    push    edi                             ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     ecx, [ebp+18h]
    push    ecx
    call    sub_441460
    push    ebp                             ; int
    call    sub_49FA90
    push    ebp
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_443917:                             ; CODE XREF: sub_4437C0+C9j
    push    0Eh
    push    offset aPrevmenu                ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, [ebp+60h]
    jnz     short loc_44394E
    mov     edx, TAdynmemStructPtr
    push    edi                             ; int
    push    offset aPrevious                ; char *
    mov     byte ptr [edx+2BC0h], 3
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44394E:                             ; CODE XREF: sub_4437C0+167j
    push    0Eh
    push    offset aWatch                   ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     ecx, [ebp+60h]
    cmp     eax, ecx
    jz      loc_443A1C
    push    0Eh
    push    offset aJoingame                ; char *
    push    ebx                             ; int
    mov     esi, ecx
    call    sub_49FDF0
    cmp     eax, esi
    jz      loc_443A1C
    lea     eax, [esi+esi*4]
    lea     ecx, [esi+eax*4]
    lea     edx, [esi+ecx*2]
    lea     ecx, [ebx+esi]
    lea     eax, [esi+edx*4]
    cmp     byte ptr [ecx+eax*2], 2
    jz      loc_443A1C
    push    0Eh
    push    offset aStartnew                ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, [ebp+60h]
    jnz     loc_443C92

    loc_4439AC:                             ; CODE XREF: sub_4437C0+30j
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    edi                             ; int
    push    offset aBigbutton               ; char *
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    and     word ptr [ecx+9Bh], 0FFBFh
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 2BD2h
    push    ecx                             ; int
    push    offset aNickname_0              ; char *
    push    ebp                             ; int
    call    sub_4A0D00
    call    sub_4257A0
    push    ebp
    call    sub_4A9660
    call    sub_441080
    push    ebp
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_443A1C:                             ; CODE XREF: sub_4437C0+1A0j
                                            ; sub_4437C0+1B7j ...
    push    offset aGamename                ; char *
    push    ebx                             ; int
    call    sub_49FF90
    movsx   eax, word ptr [eax+0BAh]
    lea     edx, [eax+eax*4]
    lea     ecx, [eax+edx*4]
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+2AA7h]
    lea     edi, [eax+2B6Ah]
    lea     esi, [edx+ecx*4]
    mov     ecx, 15h
    rep movsd
    mov     ecx, TAdynmemStructPtr
    lea     eax, [ecx+2B6Eh]
    mov     edx, [ecx+2B6Eh]
    mov     [esp+0A9h], edx
    mov     edx, [eax+4]
    mov     [esp+0ADh], edx
    mov     edx, [eax+8]
    mov     [esp+0B1h], edx
    mov     eax, [eax+0Ch]
    movsx   edx, byte ptr [ecx+1]
    mov     [esp+0D8h+var_23], eax
    mov     eax, [esp+0D8h+var_23+2]
    and     eax, 0FFh
    cmp     eax, edx
    jg      loc_443C88
    jl      loc_443C88
    mov     eax, [esp+0ABh]
    test    ah, 80h
    jnz     loc_443C69
    test    al, 10h
    jnz     loc_443C69
    add     ecx, 2BD2h
    push    ecx                             ; int
    push    offset aNickname_0              ; char *
    push    ebp                             ; int
    call    sub_4A0D00
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    lea     edi, [ecx+2BD2h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_443B27
    push    3
    push    offset aNickname_0              ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    push    eax
    push    ebp
    call    sub_4A7190
    push    ebp
    call    sub_4AB0A0
    push    1
    push    1
    push    0C8h
    push    offset aYouMustEnterYo          ; int
    call    sub_4C5740
    push    eax
    push    ebp
    call    sub_4ABD90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_443B27:                             ; CODE XREF: sub_4437C0+324j
    push    offset aPassword_0              ; char *
    push    ebx                             ; int
    call    sub_4A0010
    mov     edx, TAdynmemStructPtr
    mov     edi, ds:lstrcpynA
    lea     esi, [eax+0B6h]
    push    0Bh                             ; iMaxLength
    add     edx, 2BE3h
    push    esi                             ; lpString2
    push    edx                             ; lpString1
    call    edi ; lstrcpynA
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    0Bh                             ; iMaxLength
    push    esi                             ; lpString2
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    add     ecx, 80h
    push    ecx                             ; lpString1
    call    edi ; lstrcpynA
    call    sub_456850
    and     eax, 0FFh
    cmp     eax, 0Ah
    jz      short loc_443BBC
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    mov     esi, ecx
    add     esi, eax
    mov     eax, [esi+edx*2+1B8Ah]
    mov     dl, [eax+9Bh]
    and     dl, 10h
    cmp     dl, 10h
    jnz     short loc_443BBC
    or      byte ptr [ecx+2A44h], 4

    loc_443BBC:                             ; CODE XREF: sub_4437C0+3CAj
                                            ; sub_4437C0+3F3j
    push    offset aWatch                   ; "WATCH"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      short loc_443C19
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    or      byte ptr [ecx+9Bh], 40h
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2BC0h], 13h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_443C19:                             ; CODE XREF: sub_4437C0+409j
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    0                               ; int
    push    offset aBigbutton               ; char *
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    and     word ptr [ecx+9Bh], 0FFBFh
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2BC0h], 12h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_443C69:                             ; CODE XREF: sub_4437C0+2EEj
                                            ; sub_4437C0+2F6j
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    push    ebp
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_443C88:                             ; CODE XREF: sub_4437C0+2D8j
                                            ; sub_4437C0+2DEj
    push    offset aYouDoNotHaveAC          ; char *
    call    sub_425730

    loc_443C92:                             ; CODE XREF: sub_4437C0+1E6j
    push    ebp
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    4
    sub_4437C0 endp ; sp = -0Ch

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_443CB0 proc near                    ; CODE XREF: sub_440D70+2E2p

    var_14= dword ptr -14h

    sub     esp, 14h
    push    ebx
    push    esi
    push    edi
    call    sub_4257A0
    mov     eax, TAdynmemStructPtr
    push    80h
    add     eax, 519h
    push    offset aSelgame_gui             ; "SELGAME.GUI"
    push    eax
    call    sub_4AA8F0
    mov     edi, eax
    push    0
    push    0
    push    0
    mov     dword ptr [edi+8], offset sub_4437C0
    mov     ecx, TAdynmemStructPtr
    push    offset aSelectgame2x            ; "selectgame2x"
    mov     [edi+0Ch], ecx
    call    sub_4288D0
    push    690h
    push    offset aGameDescriptio          ; "GAME DESCRIPTIONS"
    call    sub_4D83B0
    mov     edx, TAdynmemStructPtr
    add     esp, 8
    push    0E74h
    push    offset aPlayerShared            ; "PLAYER SHARED"
    mov     [edx+2AA7h], eax
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    xor     esi, esi
    mov     [ecx+2AABh], eax

    loc_443D35:                             ; CODE XREF: sub_443CB0+BBj
    push    esi
    lea     edx, [esp+24h+var_14]
    push    offset aDataD                   ; "DATA%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+20h+var_14]
    push    0A00h
    push    eax
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [ecx+esi*4+2A4Bh], eax
    inc     esi
    cmp     esi, 0Fh
    jl      short loc_443D35
    xor     ecx, ecx
    xor     eax, eax
    mov     esi, 0B9h

    loc_443D76:                             ; CODE XREF: sub_443CB0+F8j
    mov     edx, TAdynmemStructPtr
    add     ecx, 54h
    mov     edx, [edx+2AA7h]
    mov     [edx+ecx-8], esi
    mov     edx, TAdynmemStructPtr
    mov     ebx, [edx+2AABh]
    mov     edx, [edx+2AA7h]
    add     ebx, eax
    add     eax, esi
    mov     [edx+ecx-4], ebx
    cmp     eax, 0E74h
    jl      short loc_443D76
    mov     eax, TAdynmemStructPtr
    push    0Ah
    lea     ecx, [eax+2BE3h]
    add     eax, 519h
    push    ecx
    push    offset aPassword_0              ; "PASSWORD"
    push    eax
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    push    0Ah
    lea     edx, [eax+2BD2h]
    add     eax, 519h
    push    edx
    push    offset aNickname_0              ; "NICKNAME"
    push    eax
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    push    1                               ; char
    add     eax, 519h
    push    offset aJoin                    ; char *
    push    eax                             ; int
    call    sub_4A1250
    mov     ecx, TAdynmemStructPtr
    push    1                               ; char
    add     ecx, 519h
    push    offset aWatch                   ; char *
    push    ecx                             ; int
    call    sub_4A1250
    mov     eax, [edi+4]
    mov     edx, 1
    cmp     [eax+0B6h], dx
    jle     short loc_443E66
    mov     ecx, 15Bh
    mov     esi, offset sub_441220

    loc_443E31:                             ; CODE XREF: sub_443CB0+1B4j
    cmp     byte ptr [ecx+eax], 2
    jnz     short loc_443E51
    mov     [ecx+eax+0CEh], esi
    mov     ebx, TAdynmemStructPtr
    mov     ebx, [ebx+2AA7h]
    mov     [ecx+eax+0D2h], ebx

    loc_443E51:                             ; CODE XREF: sub_443CB0+185j
    mov     eax, [edi+4]
    inc     edx
    add     ecx, 15Bh
    movsx   ebx, word ptr [eax+0B6h]
    cmp     edx, ebx
    jl      short loc_443E31

    loc_443E66:                             ; CODE XREF: sub_443CB0+175j
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    push    edi
    call    sub_441460
    test    eax, eax
    jnz     short loc_443ECE
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A9660
    push    1
    push    1
    push    0C8h
    push    offset aInvalidTcpIpAd          ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2BC0h], 3
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_443ECE:                             ; CODE XREF: sub_443CB0+1D2j
    mov     eax, [edi+4]
    push    2
    push    offset aGamename                ; char *
    push    eax                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A7830
    call    sub_428B60
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     esi, [esi+eax*2+1B63h]
    mov     al, [esi+22h]
    test    al, al
    jz      short loc_443FB1
    cmp     al, 2
    jz      short loc_443FB1
    add     edx, 519h
    push    40h
    push    edx
    call    sub_4A81E0
    xor     ecx, ecx
    mov     cl, [esi+22h]
    push    ecx
    call    sub_452C40
    push    1
    push    1
    push    140h
    push    eax                             ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FAD0
    mov     byte ptr [esi+22h], 0
    mov     edx, TAdynmemStructPtr

    loc_443FB1:                             ; CODE XREF: sub_443CB0+294j
                                            ; sub_443CB0+298j
    mov     al, byte_512D90
    test    al, al
    jz      short loc_443FE1
    mov     eax, dword_512C84
    test    eax, eax
    jz      short loc_443FE1
    lea     edi, [edx+2BD2h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_443FE1
    add     edx, 519h
    push    edx
    call    sub_4437C0

    loc_443FE1:                             ; CODE XREF: sub_443CB0+308j
                                            ; sub_443CB0+311j ...
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 14h
    retn
    sub_443CB0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_443FF0 proc near                    ; CODE XREF: sub_4441A0+2F1p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     ecx, [esp+4+arg_0]
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    test    ecx, ecx
    jge     loc_444087
    mov     eax, dword_512C80
    xor     edi, edi
    cmp     eax, 4
    mov     [esp+14h+var_4], edi
    ja      short loc_44403C
    jmp     ds:off_444184[eax*4]

    loc_44401E:                             ; DATA XREF: .text:00444188o
    mov     edi, offset dword_4FCDA8
    jmp     short loc_444038
    ; ---------------------------------------------------------------------------

    loc_444025:                             ; CODE XREF: sub_443FF0+27j
                                            ; DATA XREF: .text:0044418Co
    mov     edi, offset dword_4FCD98
    jmp     short loc_444038
    ; ---------------------------------------------------------------------------

    loc_44402C:                             ; CODE XREF: sub_443FF0+27j
                                            ; DATA XREF: .text:00444190o
    mov     edi, offset dword_4FCDC8
    jmp     short loc_444038
    ; ---------------------------------------------------------------------------

    loc_444033:                             ; CODE XREF: sub_443FF0+27j
                                            ; DATA XREF: .text:00444194o
    mov     edi, offset dword_4FCDB8

    loc_444038:                             ; CODE XREF: sub_443FF0+33j
                                            ; sub_443FF0+3Aj ...
    mov     [esp+14h+var_4], edi

    loc_44403C:                             ; CODE XREF: sub_443FF0+25j
                                            ; sub_443FF0+27j
                                            ; DATA XREF: ...
    test    edi, edi
    mov     dword_512C80, 0
    jz      short loc_444087
    mov     ebp, [edx+4F9h]
    xor     eax, eax
    test    ebp, ebp
    jle     short loc_444081
    mov     edx, [edx+445h]
    jmp     short loc_444062
    ; ---------------------------------------------------------------------------

    loc_44405E:                             ; CODE XREF: sub_443FF0+85j
    mov     edi, [esp+14h+var_4]

    loc_444062:                             ; CODE XREF: sub_443FF0+6Cj
    mov     ecx, 10h
    mov     esi, edx
    xor     ebx, ebx
    repe cmpsb
    jz      short loc_444077
    inc     eax
    add     edx, 10h
    cmp     eax, ebp
    jl      short loc_44405E

    loc_444077:                             ; CODE XREF: sub_443FF0+7Dj
    mov     ecx, [esp+14h+arg_0]
    mov     edx, TAdynmemStructPtr

    loc_444081:                             ; CODE XREF: sub_443FF0+64j
    cmp     eax, ebp
    jge     short loc_444087
    mov     ecx, eax

    loc_444087:                             ; CODE XREF: sub_443FF0+11j
                                            ; sub_443FF0+58j ...
    test    ecx, ecx
    jl      loc_44417A
    mov     esi, [edx+2A9Fh]
    mov     eax, ecx
    shl     eax, 4
    add     esi, eax
    add     edx, 39201h
    mov     eax, [esi]
    mov     [edx], eax
    mov     eax, [esi+4]
    mov     [edx+4], eax
    mov     eax, [esi+8]
    mov     [edx+8], eax
    mov     eax, [esi+0Ch]
    lea     esi, ds:0[ecx*8]
    mov     [edx+0Ch], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+2AA3h]
    mov     edx, [ecx+esi]
    mov     [eax+39211h], edx
    mov     eax, [ecx+esi+4]
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+39215h], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+2AA3h]
    mov     ebp, [eax+esi+4]
    push    ebp
    push    offset aDplayConnectio          ; "DPLAY CONNECTION INFO"
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [ecx+39211h], eax
    mov     eax, TAdynmemStructPtr
    mov     edi, [eax+39211h]
    test    edi, edi
    jz      short loc_444137
    mov     edx, [eax+2AA3h]
    mov     ecx, ebp
    mov     eax, ecx
    mov     esi, [edx+esi]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_444141
    ; ---------------------------------------------------------------------------

    loc_444137:                             ; CODE XREF: sub_443FF0+12Aj
    mov     dword ptr [eax+39215h], 0

    loc_444141:                             ; CODE XREF: sub_443FF0+145j
    call    sub_45B660
    test    eax, eax
    jz      short loc_44416D
    mov     al, String2
    test    al, al
    jz      short loc_44416D
    mov     ecx, TAdynmemStructPtr
    push    0Bh                             ; iMaxLength
    add     ecx, 2BE3h
    push    offset String2                  ; lpString2
    push    ecx                             ; lpString1
    call    ds:lstrcpynA

    loc_44416D:                             ; CODE XREF: sub_443FF0+158j
                                            ; sub_443FF0+161j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44417A:                             ; CODE XREF: sub_443FF0+99j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    4
    sub_443FF0 endp

    ; ---------------------------------------------------------------------------
    off_444184 dd offset loc_44403C         ; DATA XREF: sub_443FF0+27r
    dd offset loc_44401E
    dd offset loc_444025
    dd offset loc_44402C
    dd offset loc_444033
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4441A0 proc near                    ; DATA XREF: .text:0044464Ao

    var_168= dword ptr -168h
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset loc_4FB860
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    push    ecx
    sub     esp, 15Ch
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_10], esp
    mov     edi, [ebp+arg_0]
    mov     eax, [edi+18h]
    mov     esi, [eax+4]
    cmp     dword ptr [edi+60h], 0FFFFFFFFh
    jnz     loc_44428A
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+2A9Fh]
    test    eax, eax
    jz      loc_4444AE
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     esi, esi

    loc_4441F7:                             ; CODE XREF: sub_4441A0+8Cj
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+2AA3h]
    mov     eax, [eax+esi]
    test    eax, eax
    jz      short loc_444226
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+2AA3h]
    mov     dword ptr [edx+esi], 0

    loc_444226:                             ; CODE XREF: sub_4441A0+68j
    add     esi, 8
    cmp     esi, 50h
    jl      short loc_4441F7
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+2AA3h]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+2A4Bh]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+2A9Fh], 0
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+2A4Bh], 0
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44428A:                             ; CODE XREF: sub_4441A0+32j
    push    offset aDplay                   ; "DPLAY"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jnz     loc_44447E
    push    offset aSelect                  ; "SELECT"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jnz     loc_44447E
    push    7                               ; size_t
    push    offset aService                 ; char *
    mov     eax, [edi+60h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    lea     eax, [edx+ecx*2+2]
    push    eax                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     loc_444404
    push    eax                             ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    mov     eax, [edi+60h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    add     esi, eax
    lea     edx, [esi+ecx*2+9]
    push    edx                             ; char *
    call    _atoi
    add     esp, 4
    mov     esi, eax
    mov     [ebp+var_28], esi
    mov     byte ptr [ebp+var_168], 0
    mov     [ebp+var_24], 2
    mov     [ebp+var_4], 0
    push    14h
    call    sub_491C80
    push    140h
    lea     eax, [ebp+var_168]
    push    eax
    lea     ecx, [esi+esi*8]
    mov     edx, dword_5127C8[ecx*4]
    push    edx
    call    sub_45B250
    mov     [ebp+var_24], eax
    push    13h
    call    sub_491C80
    jmp     short loc_44436C
    ; ---------------------------------------------------------------------------

    loc_444359:                             ; DATA XREF: .rdata:004FED80o
    push    13h
    call    sub_491C80
    mov     eax, offset loc_444366
    retn
    ; ---------------------------------------------------------------------------

    loc_444366:                             ; DATA XREF: sub_4441A0+1C0o
    mov     edi, [ebp+arg_0]
    mov     esi, [ebp+var_28]

    loc_44436C:                             ; CODE XREF: sub_4441A0+1B7j
    mov     [ebp+var_4], 0FFFFFFFFh
    mov     eax, [ebp+var_24]
    test    eax, eax
    jnz     short loc_44439C
    call    sub_45B640
    push    0                               ; int
    call    _exit
    ; ---------------------------------------------------------------------------
    add     esp, 4
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44439C:                             ; CODE XREF: sub_4441A0+1D8j
    mov     al, byte ptr [ebp+var_168]
    test    al, al
    jnz     short loc_4443CF
    push    offset asc_505A64               ; "\n\n"
    push    offset asc_505A64               ; "\n\n"
    lea     eax, [esi+esi*8]
    lea     ecx, ds:5127CCh[eax*4]
    push    ecx
    push    offset aTheSServiceFai          ; "The %s service failed or took%stoo long"...
    lea     edx, [ebp+var_168]
    push    edx
    call    _sprintf
    add     esp, 14h

    loc_4443CF:                             ; CODE XREF: sub_4441A0+204j
    lea     eax, [ebp+var_168]
    push    eax                             ; int
    call    sub_4C5740
    push    1
    push    1
    push    140h
    push    eax
    push    edi
    call    sub_4ABD90
    push    edi
    call    sub_4AB0A0
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_444404:                             ; CODE XREF: sub_4441A0+13Dj
    push    0Eh
    push    offset aPrevmenu                ; char *
    push    esi                             ; int
    call    sub_49FDF0
    cmp     eax, [edi+60h]
    jnz     short loc_44442C
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2BC0h], 3
    push    0
    push    offset aPrevious                ; "Previous"
    jmp     short loc_4444A9
    ; ---------------------------------------------------------------------------

    loc_44442C:                             ; CODE XREF: sub_4441A0+274j
    push    offset aSettings                ; "SETTINGS"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_444465
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    edi
    call    sub_4AB0A0
    call    sub_460160
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_444465:                             ; CODE XREF: sub_4441A0+299j
    push    edi
    call    sub_4AB0A0
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44447E:                             ; CODE XREF: sub_4441A0+F7j
                                            ; sub_4441A0+10Aj
    push    offset aDplay                   ; char *
    push    esi                             ; int
    call    sub_49FF90
    movsx   edx, word ptr [eax+0BAh]
    push    edx
    call    sub_443FF0
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2BC0h], 2
    push    0                               ; int
    push    offset aBigbutton               ; char *

    loc_4444A9:                             ; CODE XREF: sub_4441A0+28Aj
    call    sub_47F1A0

    loc_4444AE:                             ; CODE XREF: sub_4441A0+46j
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    sub_4441A0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    ebx
    push    ebp
    push    esi
    inc     word ptr [eax+0B6h]
    push    edi
    movsx   ebx, word ptr [eax+0B6h]
    mov     ecx, ebx
    push    0
    shl     ecx, 3
    sub     ecx, ebx
    lea     ecx, [ecx+ecx*2]
    lea     edx, [ebx+ecx*2]
    lea     ecx, [ebx+edx*4]
    mov     edx, eax
    add     edx, ebx
    lea     ebp, [edx+ecx*2]
    mov     ecx, [esp+1Ch]
    mov     edx, ecx
    add     eax, ecx
    shl     edx, 3
    sub     edx, ecx
    mov     edi, ebp
    lea     edx, [edx+edx*2]
    lea     edx, [ecx+edx*2]
    lea     edx, [ecx+edx*4]
    mov     ecx, 56h
    lea     esi, [eax+edx*2]
    mov     eax, [esp+24h]
    rep movsd
    movsw
    movsb
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ebx
    push    ecx
    call    sub_4A09C0
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edi, [esp+24h]
    lea     edx, [ebp+2]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_444552 proc near                    ; DATA XREF: .data:00509A00o

    arg_18= word ptr  1Ch

    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, ebx
    and     ecx, 3
    rep movsb
    mov     cx, [esp+arg_18]
    pop     edi
    mov     [ebp+15h], cx
    mov     byte ptr [ebp+29h], 1
    mov     dword ptr [ebp+1Fh], 0
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    sub_444552 endp ; sp =  10h

    ; ---------------------------------------------------------------------------
    align 4
    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset loc_4FB870
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    push    ecx
    sub     esp, 44h
    push    ebx
    push    esi
    push    edi
    mov     [ebp-10h], esp
    mov     edi, TAdynmemStructPtr
    mov     eax, [edi+531h]
    xor     ebx, ebx
    cmp     eax, ebx
    jz      short loc_4445FE
    mov     esi, offset aSelprov_gui        ; "SELPROV.GUI"
    mov     eax, [eax+4]
    add     eax, 2

    loc_4445BF:                             ; CODE XREF: .text:004445DDj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4445E3
    test    cl, cl
    jz      short loc_4445DF
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4445E3
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4445BF

    loc_4445DF:                             ; CODE XREF: .text:004445C9j
    xor     eax, eax
    jmp     short loc_4445E8
    ; ---------------------------------------------------------------------------

    loc_4445E3:                             ; CODE XREF: .text:004445C5j
                                            ; .text:004445D3j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4445E8:                             ; CODE XREF: .text:004445E1j
    cmp     eax, ebx
    jnz     short loc_4445FE
    add     edi, 519h
    push    edi
    call    sub_4A9660
    mov     edi, TAdynmemStructPtr

    loc_4445FE:                             ; CODE XREF: .text:004445B2j
                                            ; .text:004445EAj
    push    100h
    push    ebx
    add     edi, 143A7h
    push    edi
    call    sub_4BA200
    mov     eax, TAdynmemStructPtr
    lea     ecx, [eax+5CBh]
    push    ecx
    lea     edx, [eax+143A7h]
    push    edx
    add     eax, 519h
    push    eax
    call    sub_4AC7D0
    push    80h
    push    offset aSelprov_gui             ; "SELPROV.GUI"
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    mov     dword ptr [esi+8], offset sub_4441A0
    mov     ecx, TAdynmemStructPtr
    mov     [esi+0Ch], ecx
    push    ebx
    push    ebx
    push    1
    push    offset aSelconnect2             ; "selconnect2"
    call    sub_4288D0
    push    500h
    push    offset aProviderDescri          ; "PROVIDER DESCRIPTIONS"
    call    sub_4D83B0
    add     esp, 8
    mov     edx, TAdynmemStructPtr
    mov     [edx+2A4Bh], eax
    push    0A0h
    push    offset aProviderGuids           ; "PROVIDER GUIDS"
    call    sub_4D83B0
    add     esp, 8
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2A9Fh], eax
    push    50h
    push    offset aDplayConnect_0          ; "DPLAY CONNECTIONS"
    call    sub_4D83B0
    add     esp, 8
    mov     edx, TAdynmemStructPtr
    mov     [edx+2AA3h], eax
    mov     eax, TAdynmemStructPtr
    mov     edi, [eax+2AA3h]
    cmp     edi, ebx
    jz      short loc_4446D7
    mov     ecx, 14h
    xor     eax, eax
    rep stosd

    loc_4446D7:                             ; CODE XREF: .text:004446CCj
    push    1
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435D30
    mov     edx, TAdynmemStructPtr
    add     edx, 14h
    push    edx
    call    sub_4C9B70
    push    offset dword_4FCFB8
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+2A4Bh]
    push    ecx
    mov     edx, [eax+2AA3h]
    push    edx
    mov     ecx, [eax+2A9Fh]
    push    ecx
    add     eax, 14h
    push    eax
    call    sub_4CA250
    mov     edi, [esi+4]
    mov     [ebp-14h], edi
    push    1
    push    offset aServicex                ; "SERVICEX"
    push    edi
    call    sub_49FDF0
    mov     esi, eax
    mov     [ebp-20h], esi
    mov     [ebp-1Ch], ebx
    mov     [ebp-4], ebx
    push    offset dword_5127C8
    call    sub_45B490
    mov     [ebp-1Ch], eax
    jmp     short loc_44475D

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44474E proc near                    ; DATA XREF: .rdata:004FEDD8o
    mov     eax, offset loc_444754
    retn
    ; ---------------------------------------------------------------------------

    loc_444754:                             ; DATA XREF: sub_44474Eo
    mov     esi, [ebp-20h]
    mov     edi, [ebp-14h]
    mov     eax, [ebp-1Ch]

    loc_44475D:                             ; CODE XREF: .text:0044474Cj
    mov     dword ptr [ebp-4], 0FFFFFFFFh
    test    eax, eax
    jz      loc_444879
    cmp     esi, 0FFFFFFFFh
    jz      loc_444879
    mov     ecx, esi
    shl     ecx, 3
    sub     ecx, esi
    lea     edx, [ecx+ecx*2]
    lea     ecx, [esi+edx*2]
    lea     edx, [esi+ecx*4]
    mov     ecx, edi
    add     ecx, esi
    lea     esi, [ecx+edx*2]
    mov     [ebp-50h], esi
    movsx   edx, word ptr [esi+15h]
    mov     [ebp-24h], edx
    mov     dword ptr [ebp-28h], 0
    xor     ecx, ecx
    test    eax, eax
    jle     loc_444879
    mov     dword ptr [ebp-54h], offset dword_5127CC

    loc_4447AE:                             ; CODE XREF: sub_44474E+125j
    mov     edx, [ebp-54h]
    cmp     dword ptr [edx-4], 0FFFFFFFFh
    jz      loc_44486A
    inc     ecx
    mov     [ebp-2Ch], ecx
    mov     eax, [ebp-28h]
    push    eax
    push    offset aServiceD                ; "SERVICE%d"
    lea     ecx, [ebp-48h]
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    inc     word ptr [edi+0B6h]
    movsx   eax, word ptr [edi+0B6h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    add     edi, eax
    lea     ebx, [edi+edx*2]
    mov     ecx, 56h
    mov     edi, ebx
    rep movsd
    movsw
    movsb
    push    0
    mov     ecx, [ebp-54h]
    push    ecx
    push    eax
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4A09C0
    lea     edi, [ebp-48h]
    lea     edx, [ebx+2]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebp-24h]
    mov     [ebx+15h], ax
    mov     byte ptr [ebx+29h], 1
    mov     dword ptr [ebx+1Fh], 0

    loc_444851:                             ; DATA XREF: .data:00503398o
    mov     ecx, [ebp-50h]
    movsx   edx, word ptr [ecx+19h]
    lea     eax, [eax+edx+1]
    mov     [ebp-24h], eax
    mov     esi, ecx
    mov     edi, [ebp-14h]
    mov     ecx, [ebp-2Ch]
    mov     eax, [ebp-1Ch]

    loc_44486A:                             ; CODE XREF: sub_44474E+67j
    inc     dword ptr [ebp-28h]
    add     dword ptr [ebp-54h], 24h
    cmp     ecx, eax
    jl      loc_4447AE

    loc_444879:                             ; CODE XREF: sub_44474E+18j
                                            ; sub_44474E+21j ...
    lea     edx, [edi+0CCh]
    mov     edi, offset aSelect             ; "SELECT"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    push    0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+4F9h]
    push    ecx
    mov     edx, [eax+2A4Bh]
    push    edx
    push    offset aDplay                   ; "DPLAY"
    add     eax, 519h
    push    eax
    call    sub_4A32A0
    call    sub_428B60
    push    1
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FB10
    push    40h
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    mov     ecx, [ebp-0Ch]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    sub_44474E endp ; sp =  4

    ; ---------------------------------------------------------------------------
    align 10h

    loc_444910:                             ; DATA XREF: .text:0044527Bo
    push    esi
    mov     esi, [esp+8]
    push    2
    push    offset aLogos_0                 ; "LOGOS"
    mov     eax, [esi+18h]
    mov     ecx, [eax+4]
    push    ecx
    call    sub_49FDF0
    mov     [esi+60h], eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_444930 proc near                    ; DATA XREF: .text:0044513Eo

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     ebx, [eax+4]
    mov     edi, [eax+0Ch]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_444979
    mov     eax, [edi+1Ch]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, [edi+18h]
    add     esp, 4
    push    ecx                             ; int

    loc_444956:                             ; DATA XREF: .data:00506A4Co
    call    sub_4D85A0
    add     esp, 4
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_444979:                             ; CODE XREF: sub_444930+14j
    push    offset aLogos_0                 ; "LOGOS"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_4449B2
    push    offset aSelect                  ; "SELECT"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_4449B2
    push    offset aCancel                  ; "Cancel"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_444A0F
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4449B2:                             ; CODE XREF: sub_444930+56j
                                            ; sub_444930+65j
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    offset aLogos_0                 ; char *
    push    ebx                             ; int
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*2+1B63h]
    call    sub_49FF90
    mov     edx, [esi+27h]
    xor     ecx, ecx
    mov     cl, [eax+0BAh]
    mov     al, [ecx+edi]
    mov     [edx+96h], al
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    or      byte ptr [eax+2BEEh], 1
    mov     ecx, [esi+27h]
    mov     dl, [ecx+96h]
    push    edx
    call    sub_4526C0

    loc_444A0F:                             ; CODE XREF: sub_444930+74j
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_444930 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_444A20 proc near                    ; CODE XREF: .text:00444C11p
                                            ; .text:00444C9Dp ...

    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h

    mov     eax, TAdynmemStructPtr
    sub     esp, 6Ch
    mov     ecx, [eax+531h]
    push    esi
    push    5
    push    offset aMapname                 ; char *
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_444A6E
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+391E9h]
    call    sub_435C20
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    offset aMapname                 ; "MAPNAME"
    push    ecx
    call    sub_4A0BF0

    loc_444A6E:                             ; CODE XREF: sub_444A20+22j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391E9h]
    add     eax, 0E44h
    push    eax
    push    offset aPlayers                 ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    lea     eax, [esp+7Ch+var_68]
    mov     edx, [ecx+391E9h]
    add     edx, 0DC4h
    push    edx
    push    offset aSSS_1                   ; "%s  %s: %s"
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 14h
    lea     ecx, [esp+74h+var_68]
    add     edx, 519h
    push    0
    push    ecx
    push    offset aSize                    ; "SIZE"
    push    edx
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    push    offset aMappic                  ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_4A0280
    mov     esi, eax
    mov     eax, [esi+0C2h]
    test    eax, eax
    jz      short loc_444B06
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+0C2h], 0

    loc_444B06:                             ; CODE XREF: sub_444A20+D1j
    mov     edx, TAdynmemStructPtr
    lea     eax, [esp+4]
    lea     ecx, [esp+74h+var_6C]
    push    eax
    push    ecx
    mov     ecx, [edx+391E9h]
    push    1
    call    sub_4356C0
    push    eax
    call    sub_4295B0
    test    eax, eax
    mov     [esi+0C2h], eax
    jz      short loc_444B53
    mov     ecx, [esp+4]
    mov     edx, [esp+74h+var_6C]
    shl     ecx, 4
    shl     edx, 4
    push    ecx
    push    edx
    movsx   ecx, word ptr [esi+19h]
    movsx   edx, word ptr [esi+17h]
    push    ecx
    push    edx
    push    eax
    call    sub_4665D0

    loc_444B53:                             ; CODE XREF: sub_444A20+111j
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+391E9h]
    call    sub_435900
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    offset aDescription_1           ; "DESCRIPTION"
    push    ecx
    call    sub_4A0BF0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx                             ; int
    call    sub_49FA90
    pop     esi
    add     esp, 6Ch
    retn
    sub_444A20 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h

    loc_444BA0:                             ; DATA XREF: .text:00444C05o
                                            ; sub_447B10+1051o
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_444BD0
    push    offset byte_502AE8
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_444BCA
    push    0
    push    offset aMulti_0                 ; "Multi"
    call    sub_47F1A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_444BCA:                             ; CODE XREF: .text:00444BB8j
    push    esi
    call    sub_4AB0A0

    loc_444BD0:                             ; CODE XREF: .text:00444BA9j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    900h
    add     eax, 519h
    push    offset aViewmap_gui             ; "VIEWMAP.GUI"
    push    eax
    call    sub_4AA8F0
    push    0
    push    0
    push    0
    push    offset aDviewmap                ; "DVIEWMAP"
    mov     dword ptr [eax+8], offset loc_444BA0
    call    sub_4288D0
    call    sub_444A20
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_444C40:                             ; DATA XREF: sub_444EA0+169o
    push    esi
    mov     esi, [esp+8]
    push    offset aMapnames                ; "MAPNAMES"
    mov     eax, [esi+18h]

    loc_444C4D:                             ; DATA XREF: .data:005110BCo
    mov     ecx, [eax+4]
    push    ecx
    call    sub_49FF90
    movsx   edx, word ptr [eax+0BAh]
    mov     eax, [eax+0C2h]
    push    edx
    push    eax
    call    sub_4B6AF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    mov     ecx, [ecx+391E9h]
    call    sub_435A20
    test    eax, eax
    jnz     short loc_444C90
    push    eax
    push    offset aMappic                  ; "MAPPIC"
    push    esi
    call    sub_4A0570
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_444C90:                             ; CODE XREF: .text:00444C7Ej
    push    1
    push    offset aMappic                  ; "MAPPIC"
    push    esi
    call    sub_4A0570
    call    sub_444A20
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_444CB0 proc near                    ; DATA XREF: sub_444EA0+100o

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     ebx, [eax+0Ch]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_444D32
    mov     eax, TAdynmemStructPtr
    push    offset aMappic                  ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_4A0280
    mov     esi, eax
    mov     eax, [esi+0C2h]
    test    eax, eax
    jz      short loc_444CFE
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+0C2h], 0

    loc_444CFE:                             ; CODE XREF: sub_444CB0+39j
    mov     eax, [ebx+14h]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    ebx                             ; int
    call    sub_4D85A0
    mov     ecx, dword_512990
    add     esp, 4
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword_512990, 0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_444D32:                             ; CODE XREF: sub_444CB0+14j
    push    offset aMapnames                ; "MAPNAMES"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_444D99
    push    offset aLoad                    ; "LOAD"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_444D99
    push    offset aPrevmenu                ; "PREVMENU"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_444D8D
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     edx, dword_512990
    push    edx
    mov     ecx, [eax+391E9h]
    call    sub_435A20
    call    sub_450F90
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_444D8D:                             ; CODE XREF: sub_444CB0+ADj
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_444D99:                             ; CODE XREF: sub_444CB0+8Fj
                                            ; sub_444CB0+9Ej
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    push    offset aMapnames                ; char *
    push    edi                             ; int
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [eax+0C2h]
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435A20
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    mov     ecx, [edx+391E9h]
    lea     eax, [eax+eax*4]
    lea     ebx, [esi+eax*2+1B63h]
    call    sub_435C30
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, [ebx+27h]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_4373A0
    mov     ecx, [ebx+27h]
    mov     [ecx+0A9h], eax
    call    sub_450F90
    push    5
    call    RIWrapper_Report
    call    sub_451180
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     esi, 0FFDFh

    loc_444E5A:                             ; CODE XREF: sub_444CB0+1E4j
    mov     ecx, [edx+eax+1B63h]
    test    ecx, ecx
    jz      short loc_444E76
    mov     cl, [edx+eax+1BD6h]
    cmp     cl, 1
    jz      short loc_444E8A
    cmp     cl, 2
    jz      short loc_444E8A

    loc_444E76:                             ; CODE XREF: sub_444CB0+1B3j
    mov     ecx, [edx+eax+1B8Ah]
    and     [ecx+9Bh], si
    mov     edx, TAdynmemStructPtr

    loc_444E8A:                             ; CODE XREF: sub_444CB0+1BFj
                                            ; sub_444CB0+1C4j
    add     eax, 14Bh
    cmp     eax, 0CEEh
    jl      short loc_444E5A
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_444CB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_444EA0 proc near                    ; CODE XREF: sub_447B10+DDAp
                                            ; sub_447B10+1023p
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    0C8h
    push    offset aOldmapname              ; "OLDMAPNAME"
    call    sub_4D83B0
    mov     dword_512990, eax
    mov     eax, TAdynmemStructPtr
    add     esp, 8
    mov     ecx, [eax+391E9h]
    call    sub_435C40
    test    al, al
    jnz     short loc_444EFA
    push    1
    push    1
    push    140h
    push    offset aThereAreNoMult          ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_444EFA:                             ; CODE XREF: sub_444EA0+2Dj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435C30
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    0
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, dword_512990
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435D30
    push    0
    push    0
    push    0
    call    sub_434BF0
    mov     ebx, eax
    test    ebx, ebx
    jnz     short loc_444F7D
    push    1
    push    1
    push    140h
    push    offset aThereAreNoMult          ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_444F7D:                             ; CODE XREF: sub_444EA0+B0j
    mov     eax, TAdynmemStructPtr
    push    980h
    add     eax, 519h
    push    offset aSelmap_gui              ; "SELMAP.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    push    20h
    push    offset aSelectMapData           ; "SELECT MAP DATA"
    mov     dword ptr [esi+8], offset sub_444CB0
    call    sub_4D83B0
    add     esp, 8
    mov     edi, eax
    mov     [esi+0Ch], edi
    push    0
    push    0
    push    0
    push    offset aDselectmap2             ; "DSELECTMAP2"
    call    sub_4288D0
    add     edi, 14h
    push    0
    push    0
    push    edi
    call    sub_434BF0
    mov     ecx, [edi]
    push    ebx
    push    0
    push    0
    push    ecx
    call    sub_4AEFA0
    mov     edx, [edi]
    mov     eax, TAdynmemStructPtr
    push    0
    push    ebx
    push    edx
    add     eax, 519h
    push    offset aMapnames                ; "MAPNAMES"
    push    eax
    call    sub_4A32A0
    mov     ecx, [esi+4]
    push    offset aMapnames                ; char *
    push    ecx                             ; int
    call    sub_49FF90
    xor     ebp, ebp
    mov     dword ptr [eax+0CEh], offset loc_444C40
    test    ebx, ebx
    jle     short loc_445072

    loc_445017:                             ; CODE XREF: sub_444EA0+1B8j
    mov     edx, [edi]
    push    ebp
    push    edx
    call    sub_4B6AF0
    mov     ecx, dword_512990
    mov     esi, eax

    loc_445028:                             ; CODE XREF: sub_444EA0+1A6j
    mov     dl, [ecx]
    mov     al, dl
    cmp     dl, [esi]
    jnz     short loc_44504C
    test    al, al
    jz      short loc_445048
    mov     dl, [ecx+1]
    mov     al, dl
    cmp     dl, [esi+1]
    jnz     short loc_44504C
    add     ecx, 2
    add     esi, 2
    test    al, al
    jnz     short loc_445028

    loc_445048:                             ; CODE XREF: sub_444EA0+192j
    xor     eax, eax
    jmp     short loc_445051
    ; ---------------------------------------------------------------------------

    loc_44504C:                             ; CODE XREF: sub_444EA0+18Ej
                                            ; sub_444EA0+19Cj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_445051:                             ; CODE XREF: sub_444EA0+1AAj
    test    eax, eax
    jz      short loc_44505C
    inc     ebp
    cmp     ebp, ebx
    jl      short loc_445017
    jmp     short loc_445072
    ; ---------------------------------------------------------------------------

    loc_44505C:                             ; CODE XREF: sub_444EA0+1B3j
    mov     eax, TAdynmemStructPtr
    push    ebp
    add     eax, 519h
    push    offset aMapnames                ; "MAPNAMES"
    push    eax
    call    sub_4A2E40

    loc_445072:                             ; CODE XREF: sub_444EA0+175j
                                            ; sub_444EA0+1BAj
    mov     ecx, TAdynmemStructPtr
    push    offset aMapnames                ; char *
    mov     edx, [ecx+531h]
    lea     esi, [ecx+519h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [eax+0C2h]
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435A20
    test    eax, eax
    jnz     short loc_4450C9
    push    eax                             ; int
    push    offset aMappic                  ; char *
    push    esi                             ; int
    call    sub_4A0570
    jmp     short loc_4450DB
    ; ---------------------------------------------------------------------------

    loc_4450C9:                             ; CODE XREF: sub_444EA0+219j
    push    1                               ; int
    push    offset aMappic                  ; char *
    push    esi                             ; int
    call    sub_4A0570
    call    sub_444A20

    loc_4450DB:                             ; CODE XREF: sub_444EA0+227j
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_444EA0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 18h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    800h
    add     eax, 519h
    push    offset aLogosel_gui             ; "LOGOSEL.GUI"
    push    eax
    call    sub_4AA8F0
    mov     edi, eax
    push    20h
    push    offset aSelectTeamLogo          ; "SELECT TEAM LOGO"
    mov     [esp+2Ch], edi
    mov     dword ptr [edi+8], offset sub_444930
    call    sub_4D83B0
    mov     ebp, eax
    xor     esi, esi
    mov     [edi+0Ch], ebp
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     edx, [ecx+148DBh]
    mov     si, [edx]
    mov     [esp+20h], esi
    lea     eax, ds:0[esi*4]
    push    eax
    push    offset aAnimseqPtrList          ; "ANIMSEQ PTR LIST"
    call    sub_4D83B0
    lea     ecx, [esi+esi*2]
    add     esp, 8
    shl     ecx, 4
    push    ecx
    push    offset aActualAnimseqs          ; "ACTUAL ANIMSEQS"
    mov     [ebp+18h], eax
    call    sub_4D83B0
    mov     edx, [ebp+18h]
    add     esp, 8
    mov     [esp+1Ch], edx
    xor     edx, edx
    xor     ebx, ebx
    cmp     esi, edx
    mov     [ebp+1Ch], eax
    mov     [esp+18h], edx
    mov     [esp+10h], ebx
    jle     loc_445269
    mov     dword ptr [esp+14h], 28h

    loc_4451B9:                             ; CODE XREF: .text:0044525Fj
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    lea     esi, [ecx+1BD6h]

    loc_4451C7:                             ; CODE XREF: .text:004451EFj
    mov     cl, [esi]
    test    cl, cl
    jz      short loc_4451E5
    cmp     cl, 4
    jz      short loc_4451E5
    mov     edi, [esi-4Ch]
    xor     ecx, ecx
    mov     cl, [edi+96h]
    cmp     ecx, ebx
    mov     ebx, [esp+10h]
    jge     short loc_4451F1

    loc_4451E5:                             ; CODE XREF: .text:004451CBj
                                            ; .text:004451D0j
    inc     eax
    add     esi, 14Bh
    cmp     eax, 0Ah
    jl      short loc_4451C7

    loc_4451F1:                             ; CODE XREF: .text:004451E3j
    mov     esi, TAdynmemStructPtr
    mov     edi, [ebp+1Ch]
    add     edi, edx
    mov     ecx, 0Ch
    mov     esi, [esi+148DBh]
    cmp     eax, 0Ah
    rep movsd
    mov     ecx, TAdynmemStructPtr
    mov     edi, [esp+14h]
    mov     esi, [ebp+1Ch]
    mov     ecx, [ecx+148DBh]
    mov     ecx, [ecx+edi]
    mov     [esi+edx+28h], ecx
    jnz     short loc_445246
    mov     eax, [ebp+1Ch]
    mov     ecx, [esp+1Ch]
    add     eax, edx
    mov     [ecx], eax
    mov     eax, [esp+18h]
    mov     [eax+ebp], bl
    inc     eax
    add     ecx, 4
    mov     [esp+18h], eax
    mov     [esp+1Ch], ecx

    loc_445246:                             ; CODE XREF: .text:00445226j
    mov     esi, [esp+14h]
    mov     eax, [esp+20h]
    inc     ebx
    add     esi, 8
    add     edx, 30h
    cmp     ebx, eax
    mov     [esp+10h], ebx
    mov     [esp+14h], esi
    jl      loc_4451B9
    mov     edi, [esp+24h]

    loc_445269:                             ; CODE XREF: .text:004451ABj
    mov     ecx, [edi+4]
    push    offset aLogos_0                 ; "LOGOS"
    push    ecx
    call    sub_49FF90
    test    eax, eax
    jz      short loc_445285
    mov     dword ptr [eax+0CEh], offset loc_444910

    loc_445285:                             ; CODE XREF: .text:00445279j
    mov     edx, [edi+4]
    push    2
    push    offset aLogos_0                 ; "LOGOS"
    push    edx
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4452BD
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    mov     eax, [edi+4]
    mov     ecx, [edx+eax+1Bh]
    lea     eax, [edx+eax+1Bh]
    or      ecx, 40h
    mov     [eax], ecx

    loc_4452BD:                             ; CODE XREF: .text:00445298j
    mov     ecx, [esp+18h]
    mov     edx, [ebp+18h]
    push    ecx
    push    edx
    push    offset aLogos_0                 ; "LOGOS"
    push    edi
    call    sub_4A36A0
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 140h
    push    ebx
    mov     ebx, [esp+148h]
    cmp     byte ptr [ebx], 1
    jnz     short loc_44538E
    push    edi
    push    esi
    mov     ecx, 4Fh
    mov     esi, ebx
    lea     edi, [esp+0Ch]
    lea     eax, [ebx+2]
    rep movsd
    mov     ecx, TAdynmemStructPtr
    push    0Eh
    push    eax
    mov     edx, [ecx+531h]
    movsw
    mov     eax, [edx+4]
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A5D50
    add     word ptr [ebx+15h], 2
    lea     edi, [esp+0C2h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [ebx+0B6h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     byte ptr [ebx], 5
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebx+1Bh]
    pop     esi
    or      al, 10h
    pop     edi
    mov     [ebx+1Bh], eax

    loc_44538E:                             ; CODE XREF: .text:00445311j
    pop     ebx
    add     esp, 140h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    sub     esp, 14Ch
    mov     ecx, 52h
    push    ebx
    push    esi
    push    edi
    mov     esi, eax
    lea     edi, [esp+0Ch]
    mov     ebx, [esp+15Ch]
    rep movsd
    movsw
    movsb
    mov     ecx, 52h
    mov     esi, ebx
    mov     edi, eax
    push    0
    rep movsd
    movsw
    movsb
    mov     ecx, 52h
    lea     esi, [esp+10h]
    mov     edi, ebx
    rep movsd
    movsw
    mov     ecx, ebx
    movsb
    call    sub_463C60
    mov     dword ptr [ebx], 0
    xor     ebx, ebx
    xor     eax, eax

    loc_4453F5:                             ; CODE XREF: .text:00445442j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+eax+1B63h]
    test    edx, edx
    jz      short loc_44542F
    mov     dl, [ecx+eax+1BD6h]
    cmp     dl, 1
    jz      short loc_44541C
    cmp     dl, 2
    jz      short loc_44541C
    cmp     dl, 3
    jnz     short loc_44542F

    loc_44541C:                             ; CODE XREF: .text:00445410j
                                            ; .text:00445415j
    cmp     byte ptr [ecx+eax+1CA9h], 0Ah
    jz      short loc_44542F
    mov     [ecx+eax+1CA9h], bl
    jmp     short loc_445437
    ; ---------------------------------------------------------------------------

    loc_44542F:                             ; CODE XREF: .text:00445404j
                                            ; .text:0044541Aj ...
    mov     byte ptr [ecx+eax+1CA9h], 0Ah

    loc_445437:                             ; CODE XREF: .text:0044542Dj
    add     eax, 14Bh
    inc     ebx
    cmp     eax, 0CEEh
    jle     short loc_4453F5
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 14Ch
    retn    8
    ; ---------------------------------------------------------------------------
    sub     esp, 154h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    lea     edx, [eax+1B63h]
    lea     ecx, [eax+2851h]
    push    edi
    mov     [esp+10h], edx
    lea     ebp, [eax+1CAEh]
    mov     [esp+14h], ecx

    loc_445479:                             ; CODE XREF: .text:00445595j
    cmp     ebp, ecx
    jb      short loc_445485
    cmp     edx, ecx
    jnb     loc_44559A

    loc_445485:                             ; CODE XREF: .text:0044547Bj
                                            ; .text:004454B2j
    cmp     dword ptr [edx], 0
    jz      short loc_4454A2
    mov     al, [edx+73h]
    cmp     al, 1
    jz      short loc_445499
    cmp     al, 2
    jz      short loc_445499
    cmp     al, 3
    jnz     short loc_4454A2

    loc_445499:                             ; CODE XREF: .text:0044548Fj
                                            ; .text:00445493j
    cmp     byte ptr [edx+146h], 0Ah
    jnz     short loc_4454A8

    loc_4454A2:                             ; CODE XREF: .text:00445488j
                                            ; .text:00445497j
    cmp     byte ptr [edx+73h], 4
    jnz     short loc_4454B4

    loc_4454A8:                             ; CODE XREF: .text:004454A0j
    cmp     edx, ecx
    jnb     short loc_4454B4
    add     edx, 14Bh
    jmp     short loc_445485
    ; ---------------------------------------------------------------------------

    loc_4454B4:                             ; CODE XREF: .text:004454A6j
                                            ; .text:004454AAj
    mov     [esp+10h], edx
    lea     ebp, [edx+14Bh]

    loc_4454BE:                             ; CODE XREF: .text:004454EAj
    cmp     dword ptr [ebp+0], 0
    jz      short loc_4454DC
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_4454D3
    cmp     al, 2
    jz      short loc_4454D3
    cmp     al, 3
    jnz     short loc_4454DC

    loc_4454D3:                             ; CODE XREF: .text:004454C9j
                                            ; .text:004454CDj
    cmp     byte ptr [ebp+146h], 0Ah
    jnz     short loc_4454EC

    loc_4454DC:                             ; CODE XREF: .text:004454C2j
                                            ; .text:004454D1j
    cmp     ebp, ecx
    jnb     loc_44559A
    add     ebp, 14Bh
    jmp     short loc_4454BE
    ; ---------------------------------------------------------------------------

    loc_4454EC:                             ; CODE XREF: .text:004454DAj
    cmp     ebp, ecx
    jnb     loc_44559A
    cmp     edx, ecx
    jnb     loc_44559A
    mov     ecx, 52h
    mov     esi, edx
    lea     edi, [esp+18h]
    push    0
    rep movsd
    movsw
    movsb
    mov     ecx, 52h
    mov     esi, ebp
    mov     edi, edx
    rep movsd
    movsw
    movsb
    mov     ecx, 52h
    lea     esi, [esp+1Ch]
    mov     edi, ebp
    rep movsd
    movsw
    mov     ecx, ebp
    movsb
    call    sub_463C60
    xor     ebx, ebx
    mov     dword ptr [ebp+0], 0
    xor     eax, eax

    loc_44553E:                             ; CODE XREF: .text:0044558Bj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+eax+1B63h]
    test    edx, edx
    jz      short loc_445578
    mov     dl, [ecx+eax+1BD6h]
    cmp     dl, 1
    jz      short loc_445565
    cmp     dl, 2
    jz      short loc_445565
    cmp     dl, 3
    jnz     short loc_445578

    loc_445565:                             ; CODE XREF: .text:00445559j
                                            ; .text:0044555Ej
    cmp     byte ptr [ecx+eax+1CA9h], 0Ah
    jz      short loc_445578
    mov     [ecx+eax+1CA9h], bl
    jmp     short loc_445580
    ; ---------------------------------------------------------------------------

    loc_445578:                             ; CODE XREF: .text:0044554Dj
                                            ; .text:00445563j ...
    mov     byte ptr [ecx+eax+1CA9h], 0Ah

    loc_445580:                             ; CODE XREF: .text:00445576j
    add     eax, 14Bh
    inc     ebx
    cmp     eax, 0CEEh
    jle     short loc_44553E
    mov     edx, [esp+10h]
    mov     ecx, [esp+14h]
    jmp     loc_445479
    ; ---------------------------------------------------------------------------

    loc_44559A:                             ; CODE XREF: .text:0044547Fj
                                            ; .text:004454DEj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 154h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4455B0 proc near                    ; CODE XREF: Battleroom_Unknown1+A0Cp
                                            ; .text:0044A7E2p

    var_40D= byte ptr -40Dh
    var_40C= dword ptr -40Ch
    var_408= dword ptr -408h
    var_404= byte ptr -404h
    var_400= dword ptr -400h
    var_3FC= byte ptr -3FCh
    var_3F8= dword ptr -3F8h
    var_3F4= byte ptr -3F4h
    var_3C0= dword ptr -3C0h
    var_30A= dword ptr -30Ah
    var_280= dword ptr -280h
    var_1CA= dword ptr -1CAh
    var_140= dword ptr -140h
    var_8A= dword ptr -8Ah

    sub     esp, 410h
    mov     eax, TAdynmemStructPtr
    mov     dx, word ptr dword_512764
    push    ebx
    push    ebp
    mov     ecx, [eax+531h]
    xor     eax, eax
    push    esi
    push    edi
    mov     ebx, [ecx+4]
    mov     [esp+420h+var_40C], eax
    mov     dword ptr [esp+420h+var_404], ebx
    mov     [esp+420h+var_408], 1B63h
    mov     [ebx+0B6h], dx

    loc_4455E8:                             ; CODE XREF: sub_4455B0+1FEj
    mov     ecx, dword_5054B0
    mov     [esp+420h+var_400], 0
    test    ecx, ecx
    mov     dword ptr [esp+420h+var_3FC], offset dword_5054B0
    jz      loc_445795
    mov     cl, al
    lea     eax, [eax+eax*4]
    add     cl, 30h
    shl     eax, 2
    mov     [esp+420h+var_40D], cl
    mov     [esp+420h+var_3F8], eax

    loc_445619:                             ; CODE XREF: sub_4455B0+1DBj
    mov     eax, dword ptr [esp+420h+var_3FC]
    push    0Eh
    mov     ecx, [eax]
    push    ecx                             ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebx
    add     ecx, eax
    mov     eax, dword ptr [esp+424h+var_404]
    test    eax, eax
    lea     esi, [ecx+edx*2]
    movsx   edx, word ptr [ecx+edx*2+15h]
    mov     dword_512760, edx
    jnz     short loc_44565B
    movsx   eax, word ptr [esi+19h]
    mov     dword_51276C, eax

    loc_44565B:                             ; CODE XREF: sub_4455B0+A0j
    inc     word ptr [ebx+0B6h]
    movsx   eax, word ptr [ebx+0B6h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    xor     eax, eax
    lea     ebp, [edx+ecx*2]
    mov     ecx, 56h
    mov     edi, ebp
    rep movsd
    movsw
    movsb
    lea     edx, [ebp+2]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    repne scasb
    mov     al, [esp+13h]
    not     ecx
    dec     ecx
    mov     [ecx+ebp+1], al
    mov     cx, word ptr [esp+424h+var_3FC]
    mov     al, [ebp+0]
    add     [ebp+15h], cx
    cmp     al, 5
    mov     byte ptr [ebp+1], 0
    mov     byte ptr [ebp+29h], 1
    jz      loc_445774
    mov     ecx, dword ptr [esp+424h+var_404]
    cmp     ecx, 9                          ; switch 10 cases
    ja      loc_445AC2                      ; default
    jmp     ds:off_445B44[ecx*4]            ; switch jump

    loc_4456D3:                             ; DATA XREF: .text:00445B44o
    mov     esi, TAdynmemStructPtr          ; case 0x0
    xor     ecx, ecx
    mov     cl, [esi+2A42h]
    mov     esi, [esp+14h]
    cmp     esi, ecx
    jnz     loc_445918
    cmp     al, 1
    jnz     short loc_445769
    mov     ecx, 4Fh
    mov     esi, ebp
    lea     edi, [esp+1A0h]
    push    0Eh
    rep movsd
    push    edx                             ; char *
    mov     edx, TAdynmemStructPtr
    movsw
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_49FDF0
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4A5D50
    add     word ptr [ebp+15h], 2
    lea     edi, [esp+256h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [ebp+0B6h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     byte ptr [ebp+0], 5
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebp+1Bh]
    or      al, 10h
    mov     [ebp+1Bh], eax

    loc_445769:                             ; CODE XREF: sub_4455B0+13Fj
    mov     dword ptr [ebp+1Bh], 1

    loc_445770:                             ; CODE XREF: sub_4455B0+371j
                                            ; sub_4455B0+4B9j ...
    mov     ebx, [esp+428h+var_40C]

    loc_445774:                             ; CODE XREF: sub_4455B0+109j
                                            ; sub_4455B0+38Aj ...
    mov     eax, dword ptr [esp+428h+var_404]
    mov     edx, [esp+428h+var_408]
    add     eax, 4
    inc     edx
    mov     dword ptr [esp+428h+var_404], eax
    mov     [esp+428h+var_408], edx
    cmp     dword ptr [eax], 0
    jnz     loc_445619
    mov     eax, [esp+14h]

    loc_445795:                             ; CODE XREF: sub_4455B0+50j
    mov     ecx, [esp+18h]
    inc     eax
    add     ecx, 14Bh
    mov     [esp+14h], eax
    cmp     ecx, 2851h
    mov     [esp+18h], ecx
    jl      loc_4455E8
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    lea     eax, [esp+428h+var_3FC]
    mov     cl, [edx+2A42h]
    push    ecx
    push    offset aPlayerD                 ; "PLAYER%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+428h+var_3FC]
    push    0Eh
    push    ecx                             ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_44587E
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebx
    add     ecx, eax
    mov     al, [ecx+edx*2]
    cmp     al, 1
    lea     ebp, [ecx+edx*2]
    jnz     short loc_44587E
    mov     eax, TAdynmemStructPtr
    mov     ecx, 4Fh
    mov     esi, ebp
    lea     edi, [esp+60h]
    rep movsd
    mov     ecx, [eax+531h]
    lea     edx, [ebp+2]
    push    0Eh
    push    edx                             ; char *
    mov     edx, [ecx+4]
    push    edx                             ; int
    movsw
    call    sub_49FDF0
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A5D50
    add     word ptr [ebp+15h], 2
    lea     edi, [esp+116h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [ebp+0B6h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     byte ptr [ebp+0], 5
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebp+1Bh]
    or      al, 10h
    mov     [ebp+1Bh], eax

    loc_44587E:                             ; CODE XREF: sub_4455B0+235j
                                            ; sub_4455B0+257j
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    lea     eax, [esp+430h+var_404]
    mov     cl, [edx+2A42h]
    push    ecx
    push    offset aReadyD                  ; "READY%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+430h+var_404]
    push    1
    push    ecx                             ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     esi, eax
    cmp     esi, 0FFFFFFFFh
    jz      short loc_445903
    movsx   edx, byte ptr [esp+434h+var_408]
    push    edx                             ; int
    call    _tolower
    mov     ecx, esi
    lea     edi, [esp+438h+var_408]
    shl     ecx, 3
    sub     ecx, esi
    add     esp, 4
    lea     ecx, [ecx+ecx*2]
    lea     edx, [esi+ecx*2]
    lea     ecx, [esi+edx*4]
    mov     edx, ebx
    add     edx, esi
    mov     [edx+ecx*2+13Ah], al
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebx+0CCh]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_445903:                             ; CODE XREF: sub_4455B0+301j
    pop     edi
    pop     esi
    pop     ebp
    mov     dword_512994, 1
    pop     ebx
    add     esp, 410h
    retn
    ; ---------------------------------------------------------------------------

    loc_445918:                             ; CODE XREF: sub_4455B0+137j
    mov     eax, [ebp+1Bh]
    or      ah, 80h
    mov     [ebp+1Bh], eax
    jmp     loc_445770
    ; ---------------------------------------------------------------------------

    loc_445926:                             ; CODE XREF: sub_4455B0+11Cj
                                            ; DATA XREF: .text:00445B44o
    mov     edx, TAdynmemStructPtr          ; case 0x1
    mov     eax, [esp+14h]
    xor     ecx, ecx
    mov     cl, [edx+2A42h]
    cmp     eax, ecx
    jz      loc_445774
    or      byte ptr [ebp+13Ch], 1
    mov     word ptr [ebp+138h], 0
    jmp     loc_445774
    ; ---------------------------------------------------------------------------

    loc_445955:                             ; CODE XREF: sub_4455B0+11Cj
                                            ; DATA XREF: .text:00445B44o
    mov     ecx, TAdynmemStructPtr          ; case 0x2
    mov     eax, [esp+424h+var_40C]
    cmp     dword ptr [ecx+eax], 0
    jz      loc_445A9D
    mov     al, [ecx+eax+73h]
    cmp     al, 1
    jz      loc_445774
    cmp     al, 2
    jz      loc_445774
    mov     byte ptr [ebp+29h], 0
    jmp     loc_445774
    ; ---------------------------------------------------------------------------

    loc_445986:                             ; CODE XREF: sub_4455B0+11Cj
                                            ; DATA XREF: .text:00445B44o
    mov     edi, TAdynmemStructPtr          ; case 0x3
    mov     eax, [esp+424h+var_40C]
    cmp     dword ptr [edi+eax], 0
    jz      short loc_4459A9
    mov     al, [edi+eax+73h]
    cmp     al, 1
    jz      short loc_4459A2
    cmp     al, 2
    jnz     short loc_4459A9

    loc_4459A2:                             ; CODE XREF: sub_4455B0+3ECj
    mov     esi, 1
    jmp     short loc_4459AB
    ; ---------------------------------------------------------------------------

    loc_4459A9:                             ; CODE XREF: sub_4455B0+3E4j
                                            ; sub_4455B0+3F0j
    xor     esi, esi

    loc_4459AB:                             ; CODE XREF: sub_4455B0+3F7j
    xor     eax, eax
    test    esi, esi
    setz    al
    push    eax
    add     edi, 519h
    push    edx
    push    edi
    call    sub_4A1450
    mov     byte ptr [ebp+29h], 0
    jmp     loc_445774
    ; ---------------------------------------------------------------------------

    loc_4459C9:                             ; CODE XREF: sub_4455B0+11Cj
                                            ; DATA XREF: .text:00445B44o
    mov     esi, TAdynmemStructPtr          ; case 0x6
    xor     ecx, ecx
    mov     cl, [esi+2A42h]
    mov     esi, [esp+14h]
    cmp     esi, ecx
    jz      short loc_445A5B
    cmp     al, 1
    jnz     short loc_445A5B
    mov     ecx, 4Fh
    mov     esi, ebp
    lea     edi, [esp+2E0h]
    push    0Eh
    rep movsd
    push    edx                             ; char *
    mov     edx, TAdynmemStructPtr
    movsw
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_49FDF0
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4A5D50
    add     word ptr [ebp+15h], 2
    lea     edi, [esp+396h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [ebp+0B6h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     byte ptr [ebp+0], 5
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebp+1Bh]
    or      al, 10h
    mov     [ebp+1Bh], eax

    loc_445A5B:                             ; CODE XREF: sub_4455B0+42Dj
                                            ; sub_4455B0+431j
    mov     eax, [esp+18h]
    mov     ecx, TAdynmemStructPtr
    cmp     dword ptr [ecx+eax], 0
    jz      loc_445770
    cmp     byte ptr [ecx+eax+73h], 2
    jnz     loc_445770
    mov     byte ptr [ebp+29h], 0
    jmp     loc_445770
    ; ---------------------------------------------------------------------------

    loc_445A83:                             ; CODE XREF: sub_4455B0+11Cj
                                            ; DATA XREF: .text:00445B44o
    mov     edx, TAdynmemStructPtr          ; case 0x7
    mov     eax, [esp+14h]
    xor     ecx, ecx
    mov     cl, [edx+2A42h]
    cmp     eax, ecx
    jnz     loc_445774

    loc_445A9D:                             ; CODE XREF: sub_4455B0+3B3j
    mov     byte ptr [ebp+29h], 0
    jmp     loc_445774
    ; ---------------------------------------------------------------------------

    loc_445AA6:                             ; CODE XREF: sub_4455B0+11Cj
                                            ; DATA XREF: .text:00445B44o
    mov     byte ptr [ebp+29h], 0           ; case 0x9
    mov     eax, TAdynmemStructPtr
    push    0Ah                             ; char
    add     eax, 519h
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A1080
    jmp     loc_445774
    ; ---------------------------------------------------------------------------

    loc_445AC2:                             ; CODE XREF: sub_4455B0+116j
                                            ; sub_4455B0+11Cj
                                            ; DATA XREF: ...
    cmp     al, 1                           ; default
    jnz     loc_445774
    mov     ecx, 4Fh
    mov     esi, ebp
    lea     edi, [esp+60h]
    push    0Eh
    rep movsd
    mov     ecx, TAdynmemStructPtr
    push    edx                             ; char *
    movsw
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A5D50
    add     word ptr [ebp+15h], 2
    lea     edi, [esp+116h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [ebp+0B6h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     byte ptr [ebp+0], 5
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebp+1Bh]
    or      al, 10h
    mov     [ebp+1Bh], eax
    jmp     loc_445774
    sub_4455B0 endp

    ; ---------------------------------------------------------------------------
    off_445B44 dd offset loc_4456D3         ; DATA XREF: sub_4455B0+11Cr
    dd offset loc_445926                    ; jump table for switch statement
    dd offset loc_445955
    dd offset loc_445986
    dd offset loc_445AC2
    dd offset loc_445AC2
    dd offset loc_4459C9
    dd offset loc_445A83
    dd offset loc_445AC2
    dd offset loc_445AA6
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_445B70 proc near                    ; CODE XREF: Battleroom_Unknown1+769p
                                            ; .text:0044AA7Ap
                                            ; DATA XREF: ...

    var_14= byte ptr -14h
    arg_0= dword ptr  4

    sub     esp, 14h
    push    esi
    push    edi
    mov     edi, [esp+1Ch+arg_0]
    push    offset aMaxunits_0              ; char *
    mov     eax, [edi+18h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    mov     esi, eax
    test    esi, esi
    jz      loc_445C61
    call    sub_456850
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    xor     eax, eax
    mov     al, [edx+2A42h]
    cmp     ecx, eax
    jz      short loc_445BD5
    cmp     ecx, 0Ah
    jz      short loc_445BD5
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    xor     esi, esi
    lea     eax, [eax+eax*4]
    mov     ecx, [edx+eax*2+1B8Ah]
    mov     si, [ecx+0A5h]
    jmp     short loc_445BE0
    ; ---------------------------------------------------------------------------

    loc_445BD5:                             ; CODE XREF: sub_445B70+40j
                                            ; sub_445B70+45j
    push    esi
    call    sub_45BA20
    mov     esi, eax
    add     esi, 14h

    loc_445BE0:                             ; CODE XREF: sub_445B70+63j
    lea     edx, [esp+1Ch+var_14]
    push    0Ah                             ; int
    push    edx                             ; char *
    push    esi                             ; int
    call    __itoa
    add     esp, 0Ch
    lea     eax, [esp+1Ch+var_14]
    push    0
    push    eax
    push    offset aMaxunitstext            ; "MAXUNITSTEXT"
    push    edi
    call    sub_4A0BF0
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     [ecx+0A5h], si
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     al, [ecx+97h]
    mov     [ecx+0A5h], si
    test    al, 1
    jz      short loc_445C61
    call    sub_450F90

    loc_445C61:                             ; CODE XREF: sub_445B70+1Ej
                                            ; sub_445B70+EAj
    pop     edi
    pop     esi
    add     esp, 14h
    retn    8
    sub_445B70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_445C70 proc near                    ; CODE XREF: Battleroom_Unknown1+6E8p
                                            ; .text:0044AB46p
                                            ; DATA XREF: ...

    var_14= byte ptr -14h
    arg_0= dword ptr  4

    sub     esp, 14h
    push    esi
    push    edi
    mov     edi, [esp+1Ch+arg_0]
    push    offset aMetal_1                 ; char *
    mov     eax, [edi+18h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    test    eax, eax
    jz      loc_445D4B
    push    eax
    call    sub_45BA20
    mov     ecx, eax
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    lea     ecx, [esp+1Ch+var_14]
    shr     eax, 1Fh
    add     edx, eax
    push    0Ah                             ; int
    push    ecx                             ; char *
    lea     eax, [edx+edx*4]
    lea     esi, [eax+eax*4]
    shl     esi, 2
    push    esi                             ; int
    call    __itoa
    add     esp, 0Ch
    lea     edx, [esp+1Ch+var_14]
    push    0
    push    edx
    push    offset aMetaltext               ; "METALTEXT"
    push    edi
    call    sub_4A0BF0
    mov     eax, 51EB851Fh
    mov     ecx, TAdynmemStructPtr
    imul    esi
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    xor     eax, eax
    mov     al, [ecx+2A42h]
    mov     esi, eax
    shl     eax, 5
    add     eax, esi
    add     ecx, esi
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    xor     eax, eax
    mov     [ecx+0A3h], dx
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+2A42h]
    mov     esi, eax
    shl     eax, 5
    add     eax, esi
    add     ecx, esi
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     al, [ecx+97h]
    mov     [ecx+0A3h], dx
    test    al, 1
    jz      short loc_445D4B
    call    sub_450F90
    call    sub_451180

    loc_445D4B:                             ; CODE XREF: sub_445C70+1Cj
                                            ; sub_445C70+CFj
    pop     edi
    pop     esi
    add     esp, 14h
    retn    8
    sub_445C70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_445D60 proc near                    ; DATA XREF: Battleroom_Unknown1+81Do

    var_14= byte ptr -14h
    arg_0= dword ptr  4

    sub     esp, 14h
    push    esi
    push    edi
    mov     edi, [esp+1Ch+arg_0]
    push    offset aEnergy_1                ; char *
    mov     eax, [edi+18h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    test    eax, eax
    jz      loc_445E13
    push    eax
    call    sub_45BA20
    mov     ecx, eax
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    lea     ecx, [esp+1Ch+var_14]
    shr     eax, 1Fh
    add     edx, eax
    push    0Ah                             ; int
    push    ecx                             ; char *
    lea     eax, [edx+edx*4]
    lea     esi, [eax+eax*4]
    shl     esi, 2
    push    esi                             ; int
    call    __itoa
    add     esp, 0Ch
    lea     edx, [esp+1Ch+var_14]
    push    0
    push    edx
    push    offset aEnergytext              ; "ENERGYTEXT"
    push    edi
    call    sub_4A0BF0
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     eax, 51EB851Fh
    imul    esi
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     al, [ecx+97h]
    test    al, 1
    mov     [ecx+0A1h], dx
    jz      short loc_445E13
    call    sub_450F90
    call    sub_451180

    loc_445E13:                             ; CODE XREF: sub_445D60+1Cj
                                            ; sub_445D60+A7j
    pop     edi
    pop     esi
    add     esp, 14h
    retn    8
    sub_445D60 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    mov     eax, [esp+8]
    push    eax
    mov     edx, [ecx+18h]
    mov     eax, [edx+4]
    push    eax
    call    sub_4A0200
    mov     ecx, [esp+0Ch]
    push    ecx
    push    eax
    call    sub_45B9B0
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch]
    mov     ecx, [eax+531h]
    push    esi
    push    edi
    lea     edi, [eax+519h]
    mov     esi, [ecx+4]
    push    0Eh
    push    ebp
    push    esi
    call    sub_49FDF0
    mov     ebx, eax
    cmp     ebx, 0FFFFFFFFh
    jz      short loc_445EBA
    push    ebp
    push    esi
    call    sub_4A0200
    mov     esi, eax
    mov     eax, [esp+20h]
    mov     edx, [esp+18h]
    mov     [esi+144h], eax
    mov     eax, [esp+1Ch]
    movsx   ecx, ax
    push    ecx
    push    esi
    mov     [esi+13Ch], edx
    mov     [esi+140h], ax
    call    sub_45B9B0
    mov     edx, TAdynmemStructPtr
    mov     [esi+14Ah], edx

    loc_445EBA:                             ; CODE XREF: .text:00445E7Aj
    push    ebx
    push    edi
    call    dword ptr [esp+28h]
    push    edi
    call    sub_49FA90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_445ED0 proc near                    ; CODE XREF: sub_448C70+148p
                                            ; Battleroom_Unknown1+492p
    push    esi
    call    sub_456850
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    cmp     ecx, 0Ah
    jnz     short loc_445EF0
    xor     ecx, ecx
    mov     cl, [edx+2A42h]

    loc_445EF0:                             ; CODE XREF: sub_445ED0+16j
    mov     eax, ecx
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    add     edx, 519h
    lea     eax, [eax+eax*4]
    mov     esi, [esi+eax*2+1B8Ah]
    mov     cx, [esi+9Bh]
    shr     ecx, 0Bh
    and     ecx, 3
    push    ecx                             ; char
    push    offset aCommander_1             ; char *
    push    edx                             ; int
    call    sub_4A1080
    mov     dx, [esi+9Bh]
    mov     eax, TAdynmemStructPtr
    not     dx
    shr     edx, 8
    and     edx, 1
    add     eax, 519h
    push    edx                             ; char
    push    offset aMapping_1               ; char *
    push    eax                             ; int
    call    sub_4A1080
    mov     ax, [esi+9Bh]
    test    ah, 2
    jnz     short loc_445F5D
    mov     eax, 2
    jmp     short loc_445F65
    ; ---------------------------------------------------------------------------

    loc_445F5D:                             ; CODE XREF: sub_445ED0+84j
    not     eax
    shr     eax, 0Ah
    and     eax, 1

    loc_445F65:                             ; CODE XREF: sub_445ED0+8Bj
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char
    add     ecx, 519h
    push    offset aLostype                 ; char *
    push    ecx                             ; int
    call    sub_4A1080
    mov     dl, [esi+9Bh]
    mov     eax, TAdynmemStructPtr
    shr     edx, 7
    and     edx, 1
    add     eax, 519h
    push    edx                             ; char
    push    offset aWatching_0              ; char *
    push    eax                             ; int
    call    sub_4A1080
    mov     cx, [esi+9Bh]
    mov     edx, TAdynmemStructPtr
    shr     ecx, 0Dh
    and     ecx, 1
    add     edx, 519h
    push    ecx                             ; char
    push    offset aCheating_0              ; char *
    push    edx                             ; int
    call    sub_4A1080
    mov     ax, [esi+9Bh]
    mov     ecx, TAdynmemStructPtr
    shr     eax, 0Eh
    and     eax, 1
    add     ecx, 519h
    push    eax                             ; char
    push    offset aFixedloc_0              ; char *
    push    ecx                             ; int
    call    sub_4A1080
    mov     dx, [esi+9Bh]
    mov     eax, TAdynmemStructPtr
    not     dx
    and     edx, 0FFFFh
    add     eax, 519h
    shr     edx, 0Fh
    push    edx                             ; char
    push    offset aGameopen                ; char *
    push    eax                             ; int
    call    sub_4A1080
    pop     esi
    retn
    sub_445ED0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_446020:                             ; DATA XREF: sub_446080+106o
    push    esi
    mov     esi, [esp+8]
    push    edi
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_446076
    push    offset aChoice1                 ; "CHOICE1"
    push    eax
    push    edi
    call    sub_4A0300
    test    eax, eax
    jz      short loc_44605D
    mov     cl, byte ptr dword_505510
    push    1
    push    ecx
    call    PlayerNumberToID
    push    eax
    call    sub_453010
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44605D:                             ; CODE XREF: .text:00446042j
    mov     edx, [esi+60h]
    push    offset aChoice2                 ; "CHOICE2"
    push    edx
    push    edi
    call    sub_4A0300
    test    eax, eax
    jnz     short loc_446076
    push    esi
    call    sub_4AB0A0

    loc_446076:                             ; CODE XREF: .text:00446032j
                                            ; .text:0044606Ej
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_446080 proc near                    ; CODE XREF: .text:0044669Cp
                                            ; sub_447B10+1D8p

    var_64= dword ptr -64h
    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+arg_0]
    sub     esp, 64h
    add     ecx, 519h
    mov     dword_505510, eax
    push    edi
    push    100h
    push    offset aYesorno_gui             ; "YESORNO.GUI"
    push    ecx
    call    sub_4AA8F0
    mov     edi, eax
    test    edi, edi
    jz      loc_4461BD
    mov     edx, TAdynmemStructPtr
    push    esi
    add     edx, 519h
    push    1
    push    edx
    call    sub_49FB10
    mov     esi, [edi+4]
    push    1
    push    offset aChoice1                 ; char *
    push    esi                             ; int
    call    sub_49FDF0
    push    1
    push    offset aChoice2                 ; char *
    push    esi                             ; int
    call    sub_49FDF0
    push    5
    push    offset aTitle                   ; char *
    push    esi                             ; int
    call    sub_49FDF0
    mov     eax, TAdynmemStructPtr
    push    0
    push    offset aYes                     ; "Yes"
    add     eax, 519h
    push    offset aChoice1                 ; "CHOICE1"
    push    eax
    call    sub_4A0BF0
    mov     ecx, TAdynmemStructPtr
    push    0
    push    offset aNo                      ; "No"
    add     ecx, 519h
    push    offset aChoice2                 ; "CHOICE2"
    push    ecx
    call    sub_4A0BF0
    mov     ecx, dword_505510
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    lea     ecx, [eax+edx*2+1B8Eh]
    push    ecx
    push    offset aReject_0                ; int
    call    sub_4C5740
    push    eax
    lea     edx, [esp+10h]
    push    offset aSS?                     ; "%s %s?"
    push    edx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    lea     eax, [esp+8]
    add     ecx, 519h
    push    0
    push    eax
    push    offset aTitle                   ; "TITLE"
    push    ecx
    call    sub_4A0BF0
    mov     dword ptr [edi+8], offset loc_446020
    mov     edx, TAdynmemStructPtr
    mov     [edi+0Ch], edx
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    1
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     esi

    loc_4461BD:                             ; CODE XREF: sub_446080+2Dj
    pop     edi
    add     esp, 64h
    retn    4
    sub_446080 endp ; sp = -0Ch

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    mov     esi, [esp+0Ch]
    push    edi
    mov     eax, [esi+18h]
    mov     ebx, [eax+4]
    mov     edi, [eax+0Ch]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_44620D
    mov     eax, [edi+14h]
    push    eax
    call    sub_4D85A0
    mov     ecx, [edi+4]
    add     esp, 4
    push    ecx
    call    sub_4D85A0
    add     esp, 4
    push    edi
    call    sub_4D85A0
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44620D:                             ; CODE XREF: .text:004461E4j
    push    offset aModes                   ; "MODES"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_446283
    push    offset aSelect                  ; "SELECT"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_446283
    push    offset aCancel_0                ; "CANCEL"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_446251
    push    0
    push    offset aExit_1                  ; "Exit"
    call    sub_47F1A0
    call    WriteRegistrySettings_2
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_446251:                             ; CODE XREF: .text:00446238j
    push    offset byte_502AE8
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_446277
    push    0
    push    offset aSmlbutton_0             ; "SMLBUTTON"
    call    sub_47F1A0
    call    WriteRegistrySettings_2
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_446277:                             ; CODE XREF: .text:0044625Ej
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_446283:                             ; CODE XREF: .text:0044621Aj
                                            ; .text:00446229j
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    offset aModes                   ; "MODES"
    push    ebx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*2+1B63h]
    call    sub_49FF90
    movsx   eax, word ptr [eax+0BAh]
    mov     edx, [edi+4]
    lea     ecx, [eax+eax*2]
    lea     eax, [edx+ecx*4]
    mov     edx, TAdynmemStructPtr
    mov     ecx, [eax]
    mov     [edx+37F1Bh], ecx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [eax+4]
    mov     [edx+37F1Fh], ecx
    mov     ecx, [esi+27h]
    mov     dx, [eax]
    mov     [ecx+8Bh], dx
    mov     ecx, [esi+27h]
    mov     dx, [eax+4]
    mov     [ecx+8Dh], dx
    call    sub_450F90
    call    WriteRegistrySettings_2
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_446310 proc near                    ; CODE XREF: sub_447B10+10AEp

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    20h
    push    offset aSelectVideoMod          ; "SELECT VIDEO MODE"
    call    sub_4D83B0
    add     esp, 8
    mov     esi, eax
    push    4B0h
    push    offset aDisplayModes            ; "DISPLAY MODES"
    mov     dword ptr [esi+14h], 0
    call    sub_4D83B0
    add     esp, 8
    mov     [esi+4], eax
    push    esi
    call    sub_4B5370
    test    eax, eax
    jz      loc_446434
    push    esi
    call    sub_45E4C0
    mov     eax, [esi]
    shl     eax, 8
    push    eax
    push    offset aAvailableModes          ; "AVAILABLE MODES"
    call    sub_4D83B0
    mov     [esi+14h], eax
    mov     byte ptr [eax], 0
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    add     esp, 8
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     edi, [edx+eax*2+1B63h]
    mov     edx, [esi]
    xor     eax, eax
    mov     [esp+14h+var_4], edi
    test    edx, edx
    jle     loc_446434
    mov     ebx, [edi+27h]
    mov     ecx, [esi+4]
    xor     edi, edi
    mov     di, [ebx+8Bh]

    loc_4463AF:                             ; CODE XREF: sub_446310+B7j
    cmp     [ecx], edi
    jnz     short loc_4463C1
    xor     ebp, ebp
    mov     bp, [ebx+8Dh]
    cmp     [ecx+4], ebp
    jz      short loc_4463CB

    loc_4463C1:                             ; CODE XREF: sub_446310+A1j
    inc     eax
    add     ecx, 0Ch
    cmp     eax, edx
    jl      short loc_4463AF
    jmp     short loc_446434
    ; ---------------------------------------------------------------------------

    loc_4463CB:                             ; CODE XREF: sub_446310+AFj
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+531h]
    cmp     dword ptr [ecx+37h], 2
    jnz     short loc_4463E5
    dec     eax
    jns     short loc_4463EC
    lea     eax, [edx-1]
    jmp     short loc_4463EC
    ; ---------------------------------------------------------------------------

    loc_4463E5:                             ; CODE XREF: sub_446310+CBj
    inc     eax
    cmp     eax, edx
    jl      short loc_4463EC
    xor     eax, eax

    loc_4463EC:                             ; CODE XREF: sub_446310+CEj
                                            ; sub_446310+D3j ...
    mov     edi, [esi+4]
    mov     ecx, [esp+14h+var_4]
    lea     edx, [eax+eax*2]
    mov     ax, [edi+edx*4]
    lea     edi, [edi+edx*4]
    mov     [ebx+8Bh], ax
    mov     edx, [ecx+27h]
    mov     ax, [edi+4]
    mov     [edx+8Dh], ax
    call    sub_450F90
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edi]
    mov     [edx+37F1Bh], ecx
    mov     ecx, TAdynmemStructPtr
    mov     eax, [edi+4]
    mov     [ecx+37F1Fh], eax

    loc_446434:                             ; CODE XREF: sub_446310+3Aj
                                            ; sub_446310+8Aj ...
    mov     edx, [esi+4]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_446310 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    esi
    mov     esi, edx
    mov     cl, [edx+2A42h]
    add     edx, 519h
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     esi, [esi+eax*2+1B8Ah]
    mov     cl, [esi+9Bh]
    shr     ecx, 7
    and     ecx, 1
    push    ecx
    push    offset aWatching_0              ; "WATCHING"
    push    edx
    call    sub_4A1080
    mov     dx, [esi+9Bh]
    mov     eax, TAdynmemStructPtr
    not     dx
    and     edx, 0FFFFh
    add     eax, 519h
    shr     edx, 0Fh
    push    edx
    push    offset aGameopen                ; "GAMEOPEN"
    push    eax
    call    sub_4A1080
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA90
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_4464D0:                             ; DATA XREF: sub_4466B0+4Bo
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    sub     esp, 64h
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    push    ebx
    shl     eax, 5
    add     eax, edx
    push    ebp
    mov     ebp, [esp+70h]
    add     ecx, edx
    lea     eax, [eax+eax*4]
    push    esi
    push    edi
    mov     edi, [ecx+eax*2+1B8Ah]
    mov     eax, [ebp+60h]
    cmp     eax, 0FFFFFFFFh
    jz      loc_446691
    xor     esi, esi

    loc_44650A:                             ; CODE XREF: .text:00446534j
    push    esi
    lea     ecx, [esp+14h]
    push    offset aLiveplyrD               ; "LIVEPLYR%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+10h]
    push    edx
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jnz     loc_44669B
    inc     esi
    cmp     esi, 0Ah
    jl      short loc_44650A
    push    offset aWatching_0              ; "WATCHING"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      loc_446604
    mov     ax, [edi+9Bh]
    push    0
    mov     ecx, eax
    mov     dl, al
    not     ecx
    xor     dl, cl
    push    offset aOptions                 ; "Options"
    and     edx, 80h
    xor     edx, eax
    mov     [edi+9Bh], dx
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    add     edx, 519h
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     esi, [esi+eax*2+1B8Ah]
    mov     cl, [esi+9Bh]
    shr     ecx, 7
    and     ecx, 1
    push    ecx
    push    offset aWatching_0              ; "WATCHING"
    push    edx
    call    sub_4A1080
    mov     dx, [esi+9Bh]
    mov     eax, TAdynmemStructPtr
    not     dx
    and     edx, 0FFFFh
    add     eax, 519h
    shr     edx, 0Fh
    push    edx
    push    offset aGameopen                ; "GAMEOPEN"
    push    eax
    call    sub_4A1080
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA90
    call    sub_450F90
    push    ebp
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_446604:                             ; CODE XREF: .text:00446543j
    push    offset byte_502AE8
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      short loc_44668B
    call    sub_451180
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    test    byte ptr [edi+9Bh], 80h
    jnz     short loc_446691
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     bl, 3

    loc_446636:                             ; CODE XREF: .text:0044667Fj
    mov     ecx, [eax+esi+1B63h]
    test    ecx, ecx
    jz      short loc_446673
    cmp     [eax+esi+1BD6h], bl
    jnz     short loc_446673
    mov     edx, [eax+esi+1B8Ah]
    mov     cl, [edx+9Bh]
    shr     cl, 6
    test    cl, 1
    jz      short loc_446673
    mov     edx, [eax+esi+1B67h]
    push    9
    push    edx
    call    sub_453010
    mov     eax, TAdynmemStructPtr

    loc_446673:                             ; CODE XREF: .text:0044663Fj
                                            ; .text:00446648j ...
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_446636
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44668B:                             ; CODE XREF: .text:00446611j
    push    ebp
    call    sub_4AB0A0

    loc_446691:                             ; CODE XREF: .text:00446502j
                                            ; .text:0044662Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44669B:                             ; CODE XREF: .text:0044652Aj
    push    esi
    call    sub_446080
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4466B0 proc near                    ; CODE XREF: .text:004947DEp
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    esi
    mov     esi, ecx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     esi, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     edx, [esi+eax*2+1B8Ah]
    mov     al, [edx+9Bh]
    shr     al, 6
    test    al, 1
    jnz     loc_4467B4
    push    800h
    add     ecx, 519h
    push    offset aControl_gui             ; "CONTROL.GUI"
    push    ecx
    call    sub_4AA8F0
    mov     dword ptr [eax+8], offset loc_4464D0
    mov     ecx, TAdynmemStructPtr
    push    1
    mov     [eax+0Ch], ecx
    call    sub_447380
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    add     edx, 519h
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     esi, [esi+eax*2+1B8Ah]
    mov     cl, [esi+9Bh]
    shr     ecx, 7
    and     ecx, 1
    push    ecx                             ; char
    push    offset aWatching_0              ; char *
    push    edx                             ; int
    call    sub_4A1080
    mov     dx, [esi+9Bh]
    mov     eax, TAdynmemStructPtr
    not     dx
    and     edx, 0FFFFh
    add     eax, 519h
    shr     edx, 0Fh
    push    edx                             ; char
    push    offset aGameopen                ; char *
    push    eax                             ; int
    call    sub_4A1080
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_49FA90
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0

    loc_4467B4:                             ; CODE XREF: sub_4466B0+2Fj
    pop     esi
    retn
    sub_4466B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     al, [eax+13Fh]
    cmp     al, 5
    jnz     short loc_4467D3
    xor     al, al
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4467D3:                             ; CODE XREF: .text:004467CCj
    mov     edx, [esp+8]
    push    ebx
    xor     ecx, ecx
    mov     bl, [edx+13Fh]
    cmp     al, bl
    pop     ebx
    setz    cl
    mov     al, cl
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    push    ebp
    mov     ebp, [esp+8]
    cmp     ebp, 5
    jnz     short loc_446800
    xor     eax, eax
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_446800:                             ; CODE XREF: .text:004467F8j
    mov     ecx, TAdynmemStructPtr
    push    edi
    push    esi
    push    ebx
    mov     bl, [ecx+2A44h]
    mov     eax, 0Ah
    shr     bl, 2
    xor     edi, edi
    and     bl, 1
    add     ecx, 1BD6h
    mov     esi, eax

    loc_446824:                             ; CODE XREF: .text:004468ADj
    test    bl, bl
    jz      short loc_446879
    xor     edx, edx
    mov     dl, [ecx+0CCh]
    cmp     edx, ebp
    jnz     short loc_4468A6
    mov     edx, [ecx-73h]
    test    edx, edx
    jz      short loc_4468A6
    mov     dl, [ecx]
    cmp     dl, 1
    jz      short loc_44684C
    cmp     dl, 2
    jz      short loc_44684C
    cmp     dl, 3
    jnz     short loc_4468A6

    loc_44684C:                             ; CODE XREF: .text:00446840j
                                            ; .text:00446845j
    cmp     [ecx+0D3h], al
    jz      short loc_4468A6
    cmp     dl, 1
    jz      short loc_446863
    cmp     dl, 2
    jz      short loc_446863
    cmp     dl, 3
    jnz     short loc_4468A6

    loc_446863:                             ; CODE XREF: .text:00446857j
                                            ; .text:0044685Cj
    cmp     word ptr [ecx+0D1h], 0
    jnz     short loc_4468A5
    mov     edx, [ecx+0CDh]
    test    edx, edx
    jnz     short loc_4468A6
    jmp     short loc_4468A5
    ; ---------------------------------------------------------------------------

    loc_446879:                             ; CODE XREF: .text:00446826j
    xor     edx, edx
    mov     dl, [ecx+0CCh]
    cmp     edx, ebp
    jnz     short loc_4468A6
    mov     edx, [ecx-73h]
    test    edx, edx
    jz      short loc_4468A6
    mov     dl, [ecx]
    cmp     dl, 1
    jz      short loc_44689D
    cmp     dl, 2
    jz      short loc_44689D
    cmp     dl, 3
    jnz     short loc_4468A6

    loc_44689D:                             ; CODE XREF: .text:00446891j
                                            ; .text:00446896j
    cmp     [ecx+0D3h], al
    jz      short loc_4468A6

    loc_4468A5:                             ; CODE XREF: .text:0044686Bj
                                            ; .text:00446877j
    inc     edi

    loc_4468A6:                             ; CODE XREF: .text:00446832j
                                            ; .text:00446839j ...
    add     ecx, 14Bh
    dec     esi
    jnz     loc_446824
    pop     ebx
    mov     eax, edi
    pop     esi
    pop     edi
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_457B40
    mov     esi, eax
    call    sub_457AF0
    mov     ebp, TAdynmemStructPtr
    xor     ebx, ebx
    add     esi, eax
    cmp     ebx, 5
    mov     [esp+10h], esi
    jnz     short loc_4468EB
    xor     eax, eax
    jmp     loc_44699A
    ; ---------------------------------------------------------------------------

    loc_4468EB:                             ; CODE XREF: .text:004468E2j
                                            ; .text:004469A2j
    mov     dl, [ebp+2A44h]
    xor     edi, edi
    shr     dl, 2
    and     dl, 1
    lea     eax, [ebp+1BD6h]
    mov     esi, 0Ah

    loc_446904:                             ; CODE XREF: .text:0044698Ej
    test    dl, dl
    jz      short loc_44695A
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, ebx
    jnz     short loc_446988
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_446988
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_44692C
    cmp     cl, 2
    jz      short loc_44692C
    cmp     cl, 3
    jnz     short loc_446988

    loc_44692C:                             ; CODE XREF: .text:00446920j
                                            ; .text:00446925j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_446988
    cmp     cl, 1
    jz      short loc_446944
    cmp     cl, 2
    jz      short loc_446944
    cmp     cl, 3
    jnz     short loc_446988

    loc_446944:                             ; CODE XREF: .text:00446938j
                                            ; .text:0044693Dj
    cmp     word ptr [eax+0D1h], 0
    jnz     short loc_446987
    mov     ecx, [eax+0CDh]
    test    ecx, ecx
    jnz     short loc_446988
    jmp     short loc_446987
    ; ---------------------------------------------------------------------------

    loc_44695A:                             ; CODE XREF: .text:00446906j
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, ebx
    jnz     short loc_446988
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_446988
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_44697E
    cmp     cl, 2
    jz      short loc_44697E
    cmp     cl, 3
    jnz     short loc_446988

    loc_44697E:                             ; CODE XREF: .text:00446972j
                                            ; .text:00446977j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_446988

    loc_446987:                             ; CODE XREF: .text:0044694Cj
                                            ; .text:00446958j
    inc     edi

    loc_446988:                             ; CODE XREF: .text:00446912j
                                            ; .text:00446919j ...
    add     eax, 14Bh
    dec     esi
    jnz     loc_446904
    mov     esi, [esp+10h]
    mov     eax, edi

    loc_44699A:                             ; CODE XREF: .text:004468E6j
    cmp     eax, esi
    jz      short loc_4469B0
    inc     ebx
    cmp     ebx, 5
    jl      loc_4468EB
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4469B0:                             ; CODE XREF: .text:0044699Cj
    mov     al, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    lea     edx, [eax+1B63h]
    mov     eax, [esp+14h]
    cmp     eax, 0Ah
    jz      short loc_446A40
    cmp     eax, 0Ah
    mov     esi, eax
    jge     short loc_446A40
    mov     edi, [esp+10h]
    mov     ebx, edx
    mov     ecx, edi
    add     ebx, edi
    shl     ecx, 5
    add     ecx, edi
    lea     ecx, [ecx+ecx*4]
    mov     bl, [ebx+ecx*2+13Fh]
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [edx+ecx*2+13Fh]

    loc_446A0A:                             ; CODE XREF: .text:00446A2Dj
    mov     dl, [ecx]
    cmp     dl, bl
    jnz     short loc_446A1F
    mov     al, [ecx-0CCh]
    test    al, al
    jz      short loc_446A1F
    cmp     dl, 5
    jnz     short loc_446A38

    loc_446A1F:                             ; CODE XREF: .text:00446A0Ej
                                            ; .text:00446A18j
    cmp     esi, edi
    jz      short loc_446A38
    inc     esi
    add     ecx, 14Bh
    cmp     esi, 0Ah
    jl      short loc_446A0A
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_446A38:                             ; CODE XREF: .text:00446A1Dj
                                            ; .text:00446A21j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_446A40:                             ; CODE XREF: .text:004469D5j
                                            ; .text:004469DCj
    pop     edi
    pop     esi
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_446A50 proc near                    ; CODE XREF: .text:00446F9Ep
                                            ; sub_4478B0+F1p ...

    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= byte ptr -40h

    sub     esp, 4Ch
    push    ebx
    push    ebp
    xor     ebx, ebx
    push    esi
    push    edi
    mov     [esp+5Ch+var_4C], 0
    mov     [esp+5Ch+var_48], 0
    mov     [esp+5Ch+var_44], ebx

    loc_446A6D:                             ; CODE XREF: sub_446A50+1FFj
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+ebx+1B63h]
    lea     esi, [ecx+ebx+1B63h]
    test    eax, eax
    jz      loc_446C36
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_446A9C
    cmp     al, 2
    jz      short loc_446A9C
    cmp     al, 3
    jnz     loc_446C36

    loc_446A9C:                             ; CODE XREF: sub_446A50+3Ej
                                            ; sub_446A50+42j
    cmp     byte ptr [esi+146h], 0Ah
    jz      loc_446C36
    cmp     al, 4
    jz      loc_446C36
    mov     dx, [ecx+2A44h]
    mov     ecx, edx
    and     ecx, 4
    test    cx, cx
    jz      short loc_446AFF
    cmp     al, 1
    jz      short loc_446AD2
    cmp     al, 2
    jz      short loc_446AD2
    cmp     al, 3
    jnz     loc_446C36

    loc_446AD2:                             ; CODE XREF: sub_446A50+74j
                                            ; sub_446A50+78j
    cmp     word ptr [esi+144h], 0
    jnz     short loc_446AEA
    mov     eax, [esi+140h]
    test    eax, eax
    jnz     loc_446C36

    loc_446AEA:                             ; CODE XREF: sub_446A50+8Aj
    test    cx, cx
    jz      short loc_446AFF
    mov     eax, [esi+27h]
    cmp     byte ptr [eax+96h], 0FFh
    jz      loc_446C36

    loc_446AFF:                             ; CODE XREF: sub_446A50+70j
                                            ; sub_446A50+9Dj
    shr     dl, 2
    test    dl, 1
    jz      short loc_446B26
    mov     edi, [esp+5Ch+var_48]
    lea     ecx, [esp+5Ch+var_40]
    push    edi
    push    offset aTeamiconsD              ; LPCSTR
    push    ecx                             ; LPSTR
    call    ds:wsprintfA
    add     esp, 0Ch
    inc     edi
    mov     [esp+5Ch+var_48], edi
    jmp     short loc_446B3E
    ; ---------------------------------------------------------------------------

    loc_446B26:                             ; CODE XREF: sub_446A50+B5j
    mov     edx, [esp+5Ch+var_4C]
    lea     eax, [esp+5Ch+var_40]
    push    edx
    push    offset aTeamiconsD              ; LPCSTR
    push    eax                             ; LPSTR
    call    ds:wsprintfA
    add     esp, 0Ch

    loc_446B3E:                             ; CODE XREF: sub_446A50+D4j
    xor     ecx, ecx
    mov     cl, [esi+13Fh]
    mov     esi, TAdynmemStructPtr
    mov     edi, ecx
    cmp     edi, 5
    jnz     short loc_446B5A
    xor     eax, eax
    jmp     loc_446C09
    ; ---------------------------------------------------------------------------

    loc_446B5A:                             ; CODE XREF: sub_446A50+101j
    mov     dl, [esi+2A44h]
    xor     ebx, ebx
    shr     dl, 2
    and     dl, 1
    lea     eax, [esi+1BD6h]
    mov     ebp, 0Ah

    loc_446B73:                             ; CODE XREF: sub_446A50+1ADj
    test    dl, dl
    jz      short loc_446BC9
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, edi
    jnz     short loc_446BF7
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_446BF7
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_446B9B
    cmp     cl, 2
    jz      short loc_446B9B
    cmp     cl, 3
    jnz     short loc_446BF7

    loc_446B9B:                             ; CODE XREF: sub_446A50+13Fj
                                            ; sub_446A50+144j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_446BF7
    cmp     cl, 1
    jz      short loc_446BB3
    cmp     cl, 2
    jz      short loc_446BB3
    cmp     cl, 3
    jnz     short loc_446BF7

    loc_446BB3:                             ; CODE XREF: sub_446A50+157j
                                            ; sub_446A50+15Cj
    cmp     word ptr [eax+0D1h], 0
    jnz     short loc_446BF6
    mov     ecx, [eax+0CDh]
    test    ecx, ecx
    jnz     short loc_446BF7
    jmp     short loc_446BF6
    ; ---------------------------------------------------------------------------

    loc_446BC9:                             ; CODE XREF: sub_446A50+125j
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, edi
    jnz     short loc_446BF7
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_446BF7
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_446BED
    cmp     cl, 2
    jz      short loc_446BED
    cmp     cl, 3
    jnz     short loc_446BF7

    loc_446BED:                             ; CODE XREF: sub_446A50+191j
                                            ; sub_446A50+196j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_446BF7

    loc_446BF6:                             ; CODE XREF: sub_446A50+16Bj
                                            ; sub_446A50+177j
    inc     ebx

    loc_446BF7:                             ; CODE XREF: sub_446A50+131j
                                            ; sub_446A50+138j ...
    add     eax, 14Bh
    dec     ebp
    jnz     loc_446B73
    mov     eax, ebx
    mov     ebx, [esp+5Ch+var_44]

    loc_446C09:                             ; CODE XREF: sub_446A50+105j
    sub     eax, 0
    jz      short loc_446C23
    dec     eax
    jz      short loc_446C17
    lea     edx, [edi+edi]
    push    edx
    jmp     short loc_446C25
    ; ---------------------------------------------------------------------------

    loc_446C17:                             ; CODE XREF: sub_446A50+1BFj
    lea     ecx, [edi+edi+1]
    lea     edx, [esp+5Ch+var_40]
    push    ecx
    push    edx
    jmp     short loc_446C2A
    ; ---------------------------------------------------------------------------

    loc_446C23:                             ; CODE XREF: sub_446A50+1BCj
    push    0Ah                             ; char

    loc_446C25:                             ; CODE XREF: sub_446A50+1C5j
    lea     eax, [esp+60h+var_40]
    push    eax                             ; char *

    loc_446C2A:                             ; CODE XREF: sub_446A50+1D1j
    add     esi, 519h
    push    esi                             ; int
    call    sub_4A1080

    loc_446C36:                             ; CODE XREF: sub_446A50+33j
                                            ; sub_446A50+46j ...
    mov     edx, [esp+5Ch+var_4C]
    add     ebx, 14Bh
    inc     edx
    cmp     ebx, 0CEEh
    mov     [esp+5Ch+var_4C], edx
    mov     [esp+5Ch+var_44], ebx
    jl      loc_446A6D
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    or      byte ptr [eax+2BEEh], 1
    pop     ebx
    add     esp, 4Ch
    retn
    sub_446A50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_446C70 proc near                    ; CODE XREF: .text:00446F99p
                                            ; sub_447B10+4Ap ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebx
    push    ebp
    xor     ecx, ecx
    push    esi
    push    edi
    mov     [esp+18h+var_8], ecx
    mov     [esp+18h+var_4], ecx

    loc_446C81:                             ; CODE XREF: sub_446C70+1FCj
    mov     eax, TAdynmemStructPtr
    lea     ebp, [eax+ecx+1B63h]
    mov     eax, [eax+ecx+1B63h]
    test    eax, eax
    jz      loc_446E4F
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_446CAF
    cmp     al, 2
    jz      short loc_446CAF
    cmp     al, 3
    jnz     loc_446E4F

    loc_446CAF:                             ; CODE XREF: sub_446C70+31j
                                            ; sub_446C70+35j
    cmp     byte ptr [ebp+146h], 0Ah
    jz      loc_446E4F
    cmp     al, 4
    jz      loc_446E4F
    xor     edx, edx

    loc_446CC6:                             ; CODE XREF: sub_446C70+106j
    mov     eax, TAdynmemStructPtr
    cmp     edx, 0Ah
    lea     esi, [eax+1B63h]
    jz      short loc_446D25
    cmp     edx, 0Ah
    mov     edi, edx
    jge     short loc_446D25
    mov     bl, [esi+ecx+13Fh]
    mov     ecx, edx
    shl     ecx, 5
    add     ecx, edx
    add     esi, edx
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [esi+ecx*2+13Fh]

    loc_446CF7:                             ; CODE XREF: sub_446C70+B3j
    mov     al, [ecx]
    cmp     al, bl
    jnz     short loc_446D0F
    mov     dl, [ecx-0CCh]
    test    dl, dl
    jz      short loc_446D0F
    cmp     al, 5
    jnz     loc_446E7A

    loc_446D0F:                             ; CODE XREF: sub_446C70+8Bj
                                            ; sub_446C70+95j
    cmp     edi, [esp+18h+var_8]
    jz      loc_446E7A
    inc     edi
    add     ecx, 14Bh
    cmp     edi, 0Ah
    jl      short loc_446CF7

    loc_446D25:                             ; CODE XREF: sub_446C70+64j
                                            ; sub_446C70+6Bj
    or      eax, 0FFFFFFFFh

    loc_446D28:                             ; CODE XREF: sub_446C70+20Cj
    cmp     eax, 0FFFFFFFFh
    jz      short loc_446D7B
    mov     ecx, eax
    mov     byte ptr [ebp+eax+113h], 1
    shl     ecx, 5
    mov     byte ptr [ebp+eax+108h], 1
    mov     esi, TAdynmemStructPtr
    add     ecx, eax
    add     esi, eax
    lea     edx, [eax+1]
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2+1B63h]
    mov     ecx, 2
    mov     eax, [eax+27h]
    or      [eax+9Dh], cx
    mov     eax, [ebp+27h]
    or      [eax+9Dh], cx
    mov     ecx, [esp+18h+var_4]
    jmp     loc_446CC6
    ; ---------------------------------------------------------------------------

    loc_446D7B:                             ; CODE XREF: sub_446C70+BBj
    xor     ebx, ebx
    mov     bl, [ebp+13Fh]
    cmp     ebx, 5
    jnz     short loc_446D8F
    xor     eax, eax
    jmp     loc_446E3E
    ; ---------------------------------------------------------------------------

    loc_446D8F:                             ; CODE XREF: sub_446C70+116j
    mov     eax, TAdynmemStructPtr
    xor     edi, edi
    mov     esi, 0Ah
    mov     dl, [eax+2A44h]
    shr     dl, 2
    and     dl, 1
    add     eax, 1BD6h

    loc_446DAC:                             ; CODE XREF: sub_446C70+1C6j
    test    dl, dl
    jz      short loc_446E02
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, ebx
    jnz     short loc_446E30
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_446E30
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_446DD4
    cmp     cl, 2
    jz      short loc_446DD4
    cmp     cl, 3
    jnz     short loc_446E30

    loc_446DD4:                             ; CODE XREF: sub_446C70+158j
                                            ; sub_446C70+15Dj
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_446E30
    cmp     cl, 1
    jz      short loc_446DEC
    cmp     cl, 2
    jz      short loc_446DEC
    cmp     cl, 3
    jnz     short loc_446E30

    loc_446DEC:                             ; CODE XREF: sub_446C70+170j
                                            ; sub_446C70+175j
    cmp     word ptr [eax+0D1h], 0
    jnz     short loc_446E2F
    mov     ecx, [eax+0CDh]
    test    ecx, ecx
    jnz     short loc_446E30
    jmp     short loc_446E2F
    ; ---------------------------------------------------------------------------

    loc_446E02:                             ; CODE XREF: sub_446C70+13Ej
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, ebx
    jnz     short loc_446E30
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_446E30
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_446E26
    cmp     cl, 2
    jz      short loc_446E26
    cmp     cl, 3
    jnz     short loc_446E30

    loc_446E26:                             ; CODE XREF: sub_446C70+1AAj
                                            ; sub_446C70+1AFj
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_446E30

    loc_446E2F:                             ; CODE XREF: sub_446C70+184j
                                            ; sub_446C70+190j
    inc     edi

    loc_446E30:                             ; CODE XREF: sub_446C70+14Aj
                                            ; sub_446C70+151j ...
    add     eax, 14Bh
    dec     esi
    jnz     loc_446DAC
    mov     eax, edi

    loc_446E3E:                             ; CODE XREF: sub_446C70+11Aj
    cmp     eax, 2
    jge     short loc_446E4F
    mov     eax, [ebp+27h]
    and     word ptr [eax+9Dh], 0FFFDh

    loc_446E4F:                             ; CODE XREF: sub_446C70+26j
                                            ; sub_446C70+39j ...
    mov     ecx, [esp+18h+var_4]
    mov     esi, [esp+18h+var_8]
    add     ecx, 14Bh
    inc     esi
    cmp     ecx, 0CEEh
    mov     [esp+18h+var_8], esi
    mov     [esp+18h+var_4], ecx
    jl      loc_446C81
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_446E7A:                             ; CODE XREF: sub_446C70+99j
                                            ; sub_446C70+A3j
    mov     eax, edi
    jmp     loc_446D28
    sub_446C70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_446E90 proc near                    ; CODE XREF: .text:00446F7Dp
                                            ; sub_447B10+4A3p ...

    arg_0= dword ptr  8

    push    edi
    mov     edi, [esp+arg_0]
    cmp     byte ptr [edi+13Fh], 5
    jz      loc_446F3D
    mov     edx, TAdynmemStructPtr
    push    esi
    push    ebp
    push    ebx
    xor     ebp, ebp
    xor     esi, esi
    mov     ebx, 0FFFDh

    loc_446EB4:                             ; CODE XREF: sub_446E90+A4j
    mov     ecx, [edx+esi+1B63h]
    lea     eax, [edx+esi+1B63h]
    test    ecx, ecx
    jz      short loc_446F27
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_446ED8
    cmp     cl, 2
    jz      short loc_446ED8
    cmp     cl, 3
    jnz     short loc_446F27

    loc_446ED8:                             ; CODE XREF: sub_446E90+3Cj
                                            ; sub_446E90+41j
    cmp     byte ptr [eax+146h], 0Ah
    jz      short loc_446F27
    cmp     byte ptr [edx+esi+1BD6h], 4
    jz      short loc_446F27
    mov     cl, [edx+esi+1CA2h]
    cmp     cl, [edi+13Fh]
    jnz     short loc_446F27
    xor     ecx, ecx
    mov     cl, [edi+146h]
    cmp     ebp, ecx
    jz      short loc_446F27
    mov     edx, [eax+4]
    mov     eax, [edi+4]
    push    1
    push    0
    push    edx
    push    eax
    call    sub_452960
    mov     eax, [edi+27h]
    and     [eax+9Dh], bx
    mov     edx, TAdynmemStructPtr

    loc_446F27:                             ; CODE XREF: sub_446E90+34j
                                            ; sub_446E90+46j ...
    add     esi, 14Bh
    inc     ebp
    cmp     esi, 0CEEh
    jl      loc_446EB4
    pop     ebx
    pop     ebp
    pop     esi

    loc_446F3D:                             ; CODE XREF: sub_446E90+Cj
    pop     edi
    retn    4
    sub_446E90 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    mov     edx, TAdynmemStructPtr
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    push    esi
    xor     ecx, ecx
    push    edi
    lea     eax, [eax+eax*4]
    mov     cl, [edx+eax*2+1CA2h]
    lea     eax, [edx+eax*2]
    mov     edi, ecx
    lea     esi, [eax+1B63h]
    push    esi
    call    sub_446E90
    lea     eax, [edi+1]
    mov     ecx, 6
    cdq
    idiv    ecx
    push    esi
    mov     [esi+13Fh], dl
    call    sub_452BD0
    call    sub_446C70
    call    sub_446A50
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_446FB0 proc near                    ; CODE XREF: sub_447150+135p
                                            ; sub_4478B0+ECp ...

    var_34= byte ptr -34h

    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    sub     esp, 34h
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    push    ebx
    shl     eax, 5
    push    ebp
    push    esi
    add     eax, ecx
    mov     esi, edx
    add     esi, ecx
    add     edx, 519h
    lea     eax, [eax+eax*4]
    push    offset aAllies_gui              ; char *
    push    edx                             ; int
    lea     eax, [esi+eax*2]
    lea     ebp, [eax+1C6Bh]
    lea     ebx, [eax+1C76h]
    call    sub_4AB060
    test    eax, eax
    jz      loc_447147
    mov     eax, TAdynmemStructPtr
    push    edi
    xor     edi, edi
    xor     esi, esi

    loc_447004:                             ; CODE XREF: sub_446FB0+185j
    mov     ecx, [eax+esi+1B63h]
    test    ecx, ecx
    jz      loc_447126
    mov     edx, [eax+esi+1B8Ah]
    test    byte ptr [edx+9Bh], 40h
    jnz     loc_447126
    test    ecx, ecx
    jz      loc_447126
    mov     cl, [eax+esi+1BD6h]
    cmp     cl, 1
    jz      short loc_447049
    cmp     cl, 2
    jz      short loc_447049
    cmp     cl, 3
    jnz     loc_447126

    loc_447049:                             ; CODE XREF: sub_446FB0+89j
                                            ; sub_446FB0+8Ej
    cmp     byte ptr [eax+esi+1CA9h], 0Ah
    jz      loc_447126
    cmp     cl, 1
    jz      short loc_44706A
    cmp     cl, 2
    jz      short loc_44706A
    cmp     cl, 3
    jnz     loc_447126

    loc_44706A:                             ; CODE XREF: sub_446FB0+AAj
                                            ; sub_446FB0+AFj
    cmp     word ptr [eax+esi+1CA7h], 0
    jnz     short loc_447084
    mov     ecx, [eax+esi+1CA3h]
    test    ecx, ecx
    jnz     loc_447126

    loc_447084:                             ; CODE XREF: sub_446FB0+C3j
    xor     ecx, ecx
    mov     cl, [eax+2A42h]
    cmp     edi, ecx
    jz      loc_447126
    mov     ecx, [eax+esi+1B63h]
    test    ecx, ecx
    jz      loc_447126
    mov     cl, [eax+esi+1BD6h]
    cmp     cl, 1
    jz      short loc_4470B9
    cmp     cl, 2
    jz      short loc_4470B9
    cmp     cl, 3
    jnz     short loc_447126

    loc_4470B9:                             ; CODE XREF: sub_446FB0+FDj
                                            ; sub_446FB0+102j
    cmp     byte ptr [eax+esi+1CA9h], 0Ah
    jz      short loc_447126
    cmp     word ptr [eax+esi+1CA7h], 0
    jnz     short loc_4470D9
    mov     ecx, [eax+esi+1CA3h]
    test    ecx, ecx
    jnz     short loc_447126

    loc_4470D9:                             ; CODE XREF: sub_446FB0+11Cj
    mov     edx, [eax+esi+1B8Ah]
    cmp     byte ptr [edx+96h], 0FFh
    jz      short loc_447126
    push    edi
    lea     eax, [esp+48h+var_34]
    push    offset aLiveallyD               ; "LIVEALLY%d"
    push    eax
    call    _sprintf
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [ebx]
    mov     dl, [ebp+0]
    shl     ecx, 1
    add     esp, 0Ch
    or      ecx, edx
    lea     eax, [esp+44h+var_34]
    push    ecx                             ; char
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A1080
    mov     eax, TAdynmemStructPtr

    loc_447126:                             ; CODE XREF: sub_446FB0+5Dj
                                            ; sub_446FB0+71j ...
    inc     edi
    add     esi, 14Bh
    inc     ebp
    inc     ebx
    cmp     esi, 0CEEh
    jl      loc_447004
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90
    pop     edi

    loc_447147:                             ; CODE XREF: sub_446FB0+44j
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn
    sub_446FB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_447150 proc near                    ; DATA XREF: sub_4478B0+1Eo

    var_68= dword ptr -68h
    var_64= dword ptr -64h
    arg_0= dword ptr  4

    sub     esp, 68h
    mov     eax, [esp+68h+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     edx, [ecx+4]
    mov     ecx, [eax+60h]
    cmp     ecx, 0FFFFFFFFh
    mov     [esp+78h+var_68], edx
    jnz     short loc_447185
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFDFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_447185:                             ; CODE XREF: sub_447150+1Bj
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    xor     edi, edi
    mov     cl, [esi+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    xor     ebx, ebx
    lea     eax, [eax+eax*4]
    lea     esi, [esi+eax*2+1B63h]

    loc_4471AA:                             ; CODE XREF: sub_447150+161j
    push    edi
    lea     ecx, [esp+7Ch+var_64]
    push    offset aLiveallyD               ; "LIVEALLY%d"
    push    ecx
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+84h+arg_0]
    add     esp, 0Ch
    lea     eax, [esp+78h+var_64]
    lea     ebp, [edx+ebx+1B63h]
    push    eax
    push    ecx
    call    sub_49FD60
    test    eax, eax
    jz      loc_4472A4
    cmp     dword ptr [ebp+0], 0
    jz      loc_4472A4
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_447201
    cmp     al, 2
    jz      short loc_447201
    cmp     al, 3
    jnz     loc_4472A4

    loc_447201:                             ; CODE XREF: sub_447150+A3j
                                            ; sub_447150+A7j
    cmp     byte ptr [ebp+146h], 0Ah
    jz      loc_4472A4
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     al, [esi+edi+108h]
    push    0
    xor     al, 1
    mov     [esi+edi+108h], al
    mov     edx, [ebp+4]
    push    eax
    mov     eax, [esi+4]
    push    edx
    push    eax
    call    sub_452960
    mov     al, [esi+edi+108h]
    test    al, al
    mov     eax, offset aAlliedWith         ; "allied with"
    jnz     short loc_44724F
    mov     eax, offset aBrokeAllianceW     ; "broke alliance with"

    loc_44724F:                             ; CODE XREF: sub_447150+F8j
    mov     ecx, TAdynmemStructPtr
    lea     edx, [ecx+ebx+1B8Eh]
    push    edx
    push    eax                             ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esp+80h+var_64]
    push    offset aSS_4                    ; " %s %s"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+78h+var_64]
    push    0
    push    4
    push    ecx
    push    esi
    call    ChatHandling_1
    call    sub_446FB0
    mov     edx, [esp+78h+arg_0]
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    mov     eax, [edx+60h]
    push    eax
    push    ecx
    call    sub_4A5F40

    loc_4472A4:                             ; CODE XREF: sub_447150+8Ej
                                            ; sub_447150+98j ...
    add     ebx, 14Bh
    inc     edi
    cmp     ebx, 0CEEh
    jl      loc_4471AA
    mov     ebx, [esp+78h+arg_0]
    push    offset aVictory                 ; "VICTORY"
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4472E6
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    ebx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4472E6:                             ; CODE XREF: sub_447150+178j
    push    offset byte_502AE8
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_447368
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     edx, [esi+27h]
    push    1
    mov     ecx, [esp+7Ch+var_68]
    push    offset aVictory                 ; char *
    mov     al, [edx+9Dh]
    push    ecx                             ; int
    shr     eax, 1
    and     eax, 1
    mov     edi, eax
    call    sub_49FDF0
    push    eax
    push    ebx
    call    sub_4A0FF0
    mov     ecx, [esi+27h]
    and     eax, 1
    shl     eax, 1
    mov     dx, [ecx+9Dh]
    and     edx, 0FFFDh
    or      edx, eax
    mov     [ecx+9Dh], dx
    mov     eax, [esi+27h]
    mov     cl, [eax+9Dh]
    shr     ecx, 1
    and     ecx, 1
    cmp     edi, ecx
    jz      short loc_44736E
    call    sub_450F90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_447368:                             ; CODE XREF: sub_447150+1A3j
    push    ebx
    call    sub_4AB0A0

    loc_44736E:                             ; CODE XREF: sub_447150+207j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    4
    sub_447150 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_447380 proc near                    ; CODE XREF: sub_4466B0+5Dp
                                            ; sub_4478B0+E7p ...

    var_F8= dword ptr -0F8h
    var_F4= dword ptr -0F4h
    var_F0= dword ptr -0F0h
    var_EC= dword ptr -0ECh
    var_E8= byte ptr -0E8h
    var_E4= byte ptr -0E4h
    var_D0= byte ptr -0D0h
    var_BC= byte ptr -0BCh
    String2= byte ptr -0A8h
    var_94= byte ptr -94h
    String1= byte ptr -80h
    arg_0= dword ptr  4

    sub     esp, 0F8h
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     eax, [ecx+531h]
    push    edi
    xor     esi, esi
    xor     edi, edi
    mov     edx, [eax+4]
    mov     [esp+108h+var_F4], esi
    mov     [esp+108h+var_F8], edx
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     [esp+108h+var_EC], edi
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     ebx, ebx
    mov     [esp+108h+var_F0], ebx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*2+1B63h]
    mov     dword ptr [esp+108h+var_E8], ecx

    loc_4473CE:                             ; CODE XREF: sub_447380+513j
    push    esi
    lea     edx, [esp+10Ch+var_E4]
    push    offset aPlayerD                 ; "PLAYER%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+108h+var_94]
    push    esi
    push    offset aLogoD                   ; "LOGO%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+108h+var_BC]
    push    esi
    push    offset aAllyD                   ; "ALLY%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+108h+var_D0]
    push    esi
    push    offset aTeamiconsD              ; "TEAMICONS%d"
    push    edx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+108h+var_E4]
    add     ecx, 519h
    push    0                               ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+108h+var_94]
    push    0                               ; int
    add     eax, 519h
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+108h+var_BC]
    push    0                               ; int
    add     edx, 519h
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+108h+var_D0]
    push    0                               ; int
    add     ecx, 519h
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+ebx+1B63h]
    lea     ebp, [ecx+ebx+1B63h]
    test    eax, eax
    jz      loc_44787E
    mov     edx, [ebp+27h]
    test    byte ptr [edx+9Bh], 40h
    jnz     loc_44787E
    test    eax, eax
    jz      loc_44787E
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_4474C3
    cmp     al, 2
    jz      short loc_4474C3
    cmp     al, 3
    jnz     loc_44787E

    loc_4474C3:                             ; CODE XREF: sub_447380+135j
                                            ; sub_447380+139j
    cmp     byte ptr [ebp+146h], 0Ah
    jz      loc_44787E
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    cmp     esi, edx
    jnz     short loc_4474EB
    mov     edx, [esp+108h+arg_0]
    test    edx, edx
    jnz     loc_44787E

    loc_4474EB:                             ; CODE XREF: sub_447380+15Aj
    test    byte ptr [ecx+2A44h], 4
    jz      short loc_44751C
    cmp     al, 1
    jz      short loc_447504
    cmp     al, 2
    jz      short loc_447504
    cmp     al, 3
    jnz     loc_44787E

    loc_447504:                             ; CODE XREF: sub_447380+176j
                                            ; sub_447380+17Aj
    cmp     word ptr [ebp+144h], 0
    jnz     short loc_44751C
    mov     eax, [ebp+140h]
    test    eax, eax
    jnz     loc_44787E

    loc_44751C:                             ; CODE XREF: sub_447380+172j
                                            ; sub_447380+18Cj
    mov     eax, [ebp+27h]
    cmp     byte ptr [eax+96h], 0FFh
    jz      loc_44787E
    push    edi
    lea     ecx, [esp+10Ch+var_E4]
    push    offset aPlayerD                 ; "PLAYER%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+108h+var_94]
    push    edi
    push    offset aLogoD                   ; "LOGO%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+108h+var_BC]
    push    edi
    push    offset aAllyD                   ; "ALLY%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+108h+var_D0]
    push    edi
    push    offset aTeamiconsD              ; "TEAMICONS%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     ebx, [ebp+2Bh]
    lea     edx, [esp+108h+String1]
    push    80h                             ; iMaxLength
    push    ebx                             ; lpString2
    push    edx                             ; lpString1
    call    ds:lstrcpynA
    lea     eax, [esp+108h+var_E4]
    push    0Eh
    mov     ecx, [esp+10Ch+var_F8]
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_49FDF0
    lea     edx, [eax+eax*4]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esp+10h]
    add     edx, eax
    cmp     byte ptr [edx+ecx*2], 1
    jnz     loc_44763C
    mov     ecx, [esp+10h]
    lea     eax, [esp+10Ch+var_E8]
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_49FF10
    test    eax, eax
    jz      short loc_44763C
    mov     ecx, [eax+1Bh]
    test    ch, 40h
    jz      short loc_44763C
    mov     edi, offset asc_505CE0          ; "|"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+88h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     edx, [esp+88h]
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb
    mov     edi, [esp+10Ch+var_F0]
    mov     esi, [esp+10Ch+var_F8]

    loc_44763C:                             ; CODE XREF: sub_447380+236j
                                            ; sub_447380+24Dj ...
    mov     edx, TAdynmemStructPtr
    lea     eax, [esp+88h]
    push    80h
    lea     ecx, [esp+110h+var_E8]
    push    eax
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4A0BF0
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+10Ch+var_E8]
    push    1                               ; int
    add     ecx, 519h
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    push    esi
    lea     edx, [esp+64h]
    push    offset aLiveplyrD               ; "LIVEPLYR%d"
    push    edx
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+60h]
    lea     ecx, [esp+10Ch+var_E8]
    push    eax                             ; lpString2
    add     edx, 519h
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_49F930
    cmp     dword ptr [ebp+0], 0
    jz      loc_44777A
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_4476C5
    cmp     al, 2
    jz      short loc_4476C5
    cmp     al, 3
    jnz     loc_44777A

    loc_4476C5:                             ; CODE XREF: sub_447380+337j
                                            ; sub_447380+33Bj
    cmp     byte ptr [ebp+146h], 0Ah
    jz      loc_44777A
    cmp     word ptr [ebp+144h], 0
    jnz     short loc_4476EA
    mov     ecx, [ebp+140h]
    test    ecx, ecx
    jnz     loc_44777A

    loc_4476EA:                             ; CODE XREF: sub_447380+35Aj
    cmp     al, 1
    jz      loc_44777A
    cmp     al, 2
    jz      loc_44777A
    cmp     al, 3
    jnz     short loc_44770A
    mov     eax, [ebp+27h]
    cmp     byte ptr [eax+94h], 2
    jz      short loc_44777A

    loc_44770A:                             ; CODE XREF: sub_447380+37Cj
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     ebx, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     ebx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [ebx+eax*2+1B63h]
    lea     eax, [ebx+eax*2+1B63h]
    test    ecx, ecx
    jz      short loc_44777A
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_44774A
    cmp     cl, 2
    jz      short loc_44774A
    cmp     cl, 3
    jnz     short loc_44777A

    loc_44774A:                             ; CODE XREF: sub_447380+3BEj
                                            ; sub_447380+3C3j
    cmp     byte ptr [eax+146h], 0Ah
    jz      short loc_44777A
    cmp     word ptr [eax+144h], 0
    jnz     short loc_447767
    mov     ecx, [eax+140h]
    test    ecx, ecx
    jnz     short loc_44777A

    loc_447767:                             ; CODE XREF: sub_447380+3DBj
    lea     ecx, [esp+4Ch]
    push    1                               ; int
    add     edx, 519h
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A0570

    loc_44777A:                             ; CODE XREF: sub_447380+32Cj
                                            ; sub_447380+33Fj ...
    push    esi
    lea     edx, [esp+64h]
    push    offset aLiveallyD               ; "LIVEALLY%d"
    push    edx
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+60h]
    lea     ecx, [esp+4Ch]
    push    eax                             ; lpString2
    add     edx, 519h
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_49F930
    mov     al, [ebp+13Fh]
    mov     ecx, [esp+10Ch+var_EC]
    cmp     al, [ecx+13Fh]
    jnz     short loc_4477D6
    cmp     al, 5
    jz      short loc_4477D6
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+60h]
    push    1
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4A1450

    loc_4477D6:                             ; CODE XREF: sub_447380+439j
                                            ; sub_447380+43Dj
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+38h]
    push    1                               ; int
    add     edx, 519h
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A0570
    mov     eax, [ebp+0]
    mov     ecx, TAdynmemStructPtr
    test    eax, eax
    jz      short loc_447814
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_447807
    cmp     al, 2
    jnz     short loc_447814

    loc_447807:                             ; CODE XREF: sub_447380+481j
    test    byte ptr [ecx+2A44h], 4
    jnz     short loc_447814
    xor     eax, eax
    jmp     short loc_447819
    ; ---------------------------------------------------------------------------

    loc_447814:                             ; CODE XREF: sub_447380+47Aj
                                            ; sub_447380+485j ...
    mov     eax, 1

    loc_447819:                             ; CODE XREF: sub_447380+492j
    push    eax
    lea     eax, [esp+3Ch]
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_4A1450
    lea     ecx, [esp+74h]
    mov     edx, [esp+10h]
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A0280
    test    eax, eax
    jz      short loc_447875
    mov     byte ptr [eax+29h], 1
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+148DBh]
    mov     [eax+0BEh], edx
    mov     ecx, [ebp+27h]
    movzx   dx, byte ptr [ecx+96h]
    mov     ecx, [eax+0C8h]
    mov     [eax+0C6h], dx
    and     ecx, 0FFFFFFFEh
    mov     [eax+0C8h], ecx

    loc_447875:                             ; CODE XREF: sub_447380+4BCj
    mov     ebx, [esp+10Ch+var_F4]
    inc     edi
    mov     [esp+10Ch+var_F0], edi

    loc_44787E:                             ; CODE XREF: sub_447380+112j
                                            ; sub_447380+122j ...
    add     ebx, 14Bh
    inc     esi
    cmp     ebx, 0CEEh
    mov     [esp+10Ch+var_F8], esi
    mov     [esp+10Ch+var_F4], ebx
    jl      loc_4473CE
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0F8h
    retn    4
    sub_447380 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4478B0 proc near                    ; CODE XREF: .text:00494808p
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    800h
    add     eax, 519h
    push    offset aAllies_gui              ; "ALLIES.GUI"
    push    eax
    call    sub_4AA8F0
    mov     dword ptr [eax+8], offset sub_447150
    mov     ecx, TAdynmemStructPtr
    mov     [eax+0Ch], ecx
    mov     eax, TAdynmemStructPtr
    push    0Eh
    push    offset aAllyx                   ; char *
    or      byte ptr [eax+37EBEh], 20h
    mov     edx, TAdynmemStructPtr
    xor     edi, edi
    mov     eax, [edx+531h]
    mov     esi, [eax+4]
    push    esi                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_447947

    loc_44790D:                             ; CODE XREF: sub_4478B0+95j
    mov     ecx, eax
    push    edi
    shl     ecx, 3
    sub     ecx, eax
    push    offset aAllyD                   ; "ALLY%d"
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    lea     eax, [edx+ecx*2+2]
    push    eax
    call    _sprintf
    add     esp, 0Ch
    inc     edi
    push    0Eh
    push    offset aAllyx                   ; char *
    push    esi                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_44790D

    loc_447947:                             ; CODE XREF: sub_4478B0+5Bj
    push    0Eh
    push    offset aTeamiconsx              ; char *
    push    esi                             ; int
    xor     edi, edi
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_447995

    loc_44795B:                             ; CODE XREF: sub_4478B0+E3j
    mov     ecx, eax
    push    edi
    shl     ecx, 3
    sub     ecx, eax
    push    offset aTeamiconsD              ; "TEAMICONS%d"
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    lea     eax, [edx+ecx*2+2]
    push    eax
    call    _sprintf
    add     esp, 0Ch
    inc     edi
    push    0Eh
    push    offset aTeamiconsx              ; char *
    push    esi                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_44795B

    loc_447995:                             ; CODE XREF: sub_4478B0+A9j
    push    0
    call    sub_447380
    call    sub_446FB0
    call    sub_446A50
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    add     edx, 519h
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     esi, [esi+eax*2+1B63h]
    mov     eax, [esi+27h]
    mov     cl, [eax+9Dh]
    mov     bl, [eax+9Bh]
    shr     ecx, 1
    and     ecx, 1
    push    ecx                             ; char
    push    offset aVictory                 ; char *
    shr     bl, 6
    push    edx                             ; int
    and     bl, 1
    call    sub_4A1080
    xor     edx, edx
    mov     dl, [esi+13Fh]
    mov     esi, edx
    cmp     esi, 5
    jnz     short loc_447A0B
    xor     eax, eax
    jmp     loc_447ABA
    ; ---------------------------------------------------------------------------

    loc_447A0B:                             ; CODE XREF: sub_4478B0+152j
    mov     eax, TAdynmemStructPtr
    xor     ebp, ebp
    mov     edi, 0Ah
    mov     dl, [eax+2A44h]
    shr     dl, 2
    and     dl, 1
    add     eax, 1BD6h

    loc_447A28:                             ; CODE XREF: sub_4478B0+202j
    test    dl, dl
    jz      short loc_447A7E
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, esi
    jnz     short loc_447AAC
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_447AAC
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_447A50
    cmp     cl, 2
    jz      short loc_447A50
    cmp     cl, 3
    jnz     short loc_447AAC

    loc_447A50:                             ; CODE XREF: sub_4478B0+194j
                                            ; sub_4478B0+199j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_447AAC
    cmp     cl, 1
    jz      short loc_447A68
    cmp     cl, 2
    jz      short loc_447A68
    cmp     cl, 3
    jnz     short loc_447AAC

    loc_447A68:                             ; CODE XREF: sub_4478B0+1ACj
                                            ; sub_4478B0+1B1j
    cmp     word ptr [eax+0D1h], 0
    jnz     short loc_447AAB
    mov     ecx, [eax+0CDh]
    test    ecx, ecx
    jnz     short loc_447AAC
    jmp     short loc_447AAB
    ; ---------------------------------------------------------------------------

    loc_447A7E:                             ; CODE XREF: sub_4478B0+17Aj
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, esi
    jnz     short loc_447AAC
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_447AAC
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_447AA2
    cmp     cl, 2
    jz      short loc_447AA2
    cmp     cl, 3
    jnz     short loc_447AAC

    loc_447AA2:                             ; CODE XREF: sub_4478B0+1E6j
                                            ; sub_4478B0+1EBj
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_447AAC

    loc_447AAB:                             ; CODE XREF: sub_4478B0+1C0j
                                            ; sub_4478B0+1CCj
    inc     ebp

    loc_447AAC:                             ; CODE XREF: sub_4478B0+186j
                                            ; sub_4478B0+18Dj ...
    add     eax, 14Bh
    dec     edi
    jnz     loc_447A28
    mov     eax, ebp

    loc_447ABA:                             ; CODE XREF: sub_4478B0+156j
    cmp     eax, 1
    jg      short loc_447AC7
    test    bl, bl
    jnz     short loc_447AC7
    xor     eax, eax
    jmp     short loc_447ACC
    ; ---------------------------------------------------------------------------

    loc_447AC7:                             ; CODE XREF: sub_4478B0+20Dj
                                            ; sub_4478B0+211j
    mov     eax, 1

    loc_447ACC:                             ; CODE XREF: sub_4478B0+215j
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    offset aVictory                 ; "VICTORY"
    push    edx
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4478B0 endp ; sp = -10h

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_447B10 proc near                    ; DATA XREF: Battleroom_Unknown1+109o

    var_13C= dword ptr -13Ch
    var_138= dword ptr -138h
    var_134= dword ptr -134h
    var_130= dword ptr -130h
    var_12C= dword ptr -12Ch
    var_128= dword ptr -128h
    var_124= byte ptr -124h
    var_28= dword ptr -28h
    arg_0= dword ptr  4

    sub     esp, 13Ch
    mov     eax, [esp+13Ch+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     edx, [ecx+4]
    mov     ecx, [eax+60h]
    cmp     ecx, 0FFFFFFFFh
    mov     [esp+14Ch+var_138], edx
    jnz     short loc_447B6C
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+2A9Bh]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    add     esp, 4
    mov     [edx+2A9Bh], eax
    mov     dword_512994, eax
    call    sub_446C70
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 13Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_447B6C:                             ; CODE XREF: sub_447B10+21j
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [ecx+2A42h]
    mov     edi, eax
    shl     eax, 5
    add     eax, edi
    add     ecx, edi
    mov     [esp+14Ch+var_134], edi
    lea     edx, [eax+eax*4]
    lea     eax, [ecx+edx*2+1B63h]
    mov     [esp+14Ch+var_13C], eax
    call    sub_457A50
    mov     esi, eax
    xor     ebp, ebp
    mov     [esp+14Ch+var_128], esi

    loc_447BA2:                             ; CODE XREF: sub_447B10+7FEj
    mov     eax, ebp
    mov     edx, TAdynmemStructPtr
    shl     eax, 5
    add     eax, ebp
    push    ebp
    push    offset aLogoD                   ; "LOGO%d"
    lea     ecx, [eax+eax*4]
    lea     eax, [ebp+ecx*2+0]
    mov     [esp+154h+var_130], eax
    lea     ebx, [edx+eax+1B63h]
    lea     eax, [esp+154h+var_124]
    push    eax
    call    _sprintf
    mov     edx, [esp+158h+arg_0]
    add     esp, 0Ch
    lea     ecx, [esp+14Ch+var_124]
    push    ecx
    push    edx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_447C29
    cmp     dword ptr [ebx], 0
    jz      short loc_447C29
    mov     al, [ebx+73h]
    cmp     al, 1
    jz      short loc_447BFA
    cmp     al, 2
    jnz     short loc_447C29

    loc_447BFA:                             ; CODE XREF: sub_447B10+E4j
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     eax, [ebx+27h]
    xor     ecx, ecx
    mov     cl, [eax+96h]
    inc     ecx
    push    ecx
    call    sub_4526C0
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2BEEh], 1
    call    sub_450F90

    loc_447C29:                             ; CODE XREF: sub_447B10+D8j
                                            ; sub_447B10+DDj ...
    push    ebp
    lea     edx, [esp+150h+var_124]
    push    offset aPlayerD                 ; "PLAYER%d"
    push    edx
    call    _sprintf
    mov     ecx, [esp+158h+arg_0]
    add     esp, 0Ch
    lea     eax, [esp+14Ch+var_124]
    push    eax
    push    ecx
    call    sub_49FD60
    test    eax, eax
    jz      loc_447E3D
    cmp     ebp, edi
    jz      loc_447E3D
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     al, [ebx+73h]
    test    al, al
    jnz     short loc_447C95
    test    esi, esi
    jz      short loc_447C95
    push    4
    mov     ecx, ebx
    call    sub_463C60
    mov     dword ptr [ebx+4], 0FFFFFFFFh
    mov     eax, TAdynmemStructPtr
    dec     dword ptr [eax+499h]
    jmp     loc_447E27
    ; ---------------------------------------------------------------------------

    loc_447C95:                             ; CODE XREF: sub_447B10+15Fj
                                            ; sub_447B10+163j
    cmp     al, 4
    jz      short loc_447CF6
    test    al, al
    jz      short loc_447CF2
    cmp     dword ptr [ebx], 0
    jz      short loc_447CCC
    cmp     al, 2
    jnz     short loc_447CCC
    call    sub_4B6340
    sub     eax, [ebx+8]
    cmp     eax, 1Eh
    jbe     short loc_447CCC
    mov     edx, [ebx+4]
    push    1
    push    edx
    call    sub_453010
    push    0
    mov     ecx, ebx
    call    sub_463C60
    jmp     loc_447E27
    ; ---------------------------------------------------------------------------

    loc_447CCC:                             ; CODE XREF: sub_447B10+190j
                                            ; sub_447B10+194j ...
    test    esi, esi
    jz      loc_447E27
    cmp     dword ptr [ebx], 0
    jz      loc_447E27
    cmp     byte ptr [ebx+73h], 3
    jnz     loc_447E27
    push    ebp
    call    sub_446080
    jmp     loc_447E27
    ; ---------------------------------------------------------------------------

    loc_447CF2:                             ; CODE XREF: sub_447B10+18Bj
    cmp     al, 4
    jnz     short loc_447D0F

    loc_447CF6:                             ; CODE XREF: sub_447B10+187j
    push    0
    mov     ecx, ebx
    call    sub_463C60
    mov     eax, TAdynmemStructPtr
    inc     dword ptr [eax+499h]
    call    sub_451180

    loc_447D0F:                             ; CODE XREF: sub_447B10+1E4j
    call    sub_456850
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    add     edx, ecx
    lea     eax, [eax+eax*4]
    mov     eax, [edx+eax*2+1B8Ah]
    mov     cx, [eax+9Bh]
    shr     ecx, 0Fh
    test    cl, 1
    jnz     loc_448313
    call    sub_456850
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    mov     ecx, [eax+edx*2+1B8Ah]
    mov     dx, [ecx+9Bh]
    and     edx, 1800h
    cmp     edx, 1000h
    jz      loc_447E27
    call    sub_457B90
    test    eax, eax
    jnz     loc_447E27
    push    2
    push    ebp
    call    sub_451220
    mov     ecx, 0Ah
    xor     eax, eax
    lea     edi, [esp+14Ch+var_28]
    mov     edx, 0Ah
    rep stosd
    mov     eax, TAdynmemStructPtr
    mov     esi, 1
    lea     ecx, [eax+1BD6h]

    loc_447DBA:                             ; CODE XREF: sub_447B10+2EFj
    mov     eax, [ecx-73h]
    test    eax, eax
    jz      short loc_447DF8
    mov     al, [ecx]
    cmp     al, 1
    jz      short loc_447DCF
    cmp     al, 2
    jz      short loc_447DCF
    cmp     al, 3
    jnz     short loc_447DF8

    loc_447DCF:                             ; CODE XREF: sub_447B10+2B5j
                                            ; sub_447B10+2B9j
    cmp     byte ptr [ecx+0D3h], 0Ah
    jz      short loc_447DF8
    mov     eax, [ecx-4Ch]
    mov     al, [eax+96h]
    cmp     al, 9
    jnb     short loc_447DEC
    and     eax, 0FFh
    jmp     short loc_447DF1
    ; ---------------------------------------------------------------------------

    loc_447DEC:                             ; CODE XREF: sub_447B10+2D3j
    mov     eax, 9

    loc_447DF1:                             ; CODE XREF: sub_447B10+2DAj
    mov     [esp+eax*4+14Ch+var_28], esi

    loc_447DF8:                             ; CODE XREF: sub_447B10+2AFj
                                            ; sub_447B10+2BDj ...
    add     ecx, 14Bh
    dec     edx
    jnz     short loc_447DBA
    xor     edx, edx
    xor     eax, eax
    lea     ecx, [esp+14Ch+var_28]

    loc_447E0C:                             ; CODE XREF: sub_447B10+308j
    cmp     dword ptr [ecx], 0
    jz      short loc_447E1C
    inc     eax
    add     ecx, 4
    cmp     eax, 0Ah
    jl      short loc_447E0C
    jmp     short loc_447E1E
    ; ---------------------------------------------------------------------------

    loc_447E1C:                             ; CODE XREF: sub_447B10+2FFj
    mov     edx, eax

    loc_447E1E:                             ; CODE XREF: sub_447B10+30Aj
    mov     ecx, [ebx+27h]
    mov     [ecx+96h], dl

    loc_447E27:                             ; CODE XREF: sub_447B10+180j
                                            ; sub_447B10+1B7j ...
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2BEEh], 1
    call    sub_451180
    call    sub_450F90

    loc_447E3D:                             ; CODE XREF: sub_447B10+140j
                                            ; sub_447B10+148j
    push    ebp
    lea     edx, [esp+150h+var_124]
    push    offset aSideD                   ; "SIDE%d"
    push    edx
    call    _sprintf
    mov     edi, [esp+158h+arg_0]
    add     esp, 0Ch
    lea     eax, [esp+14Ch+var_124]
    push    eax
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      loc_447F46
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    cmp     dword ptr [ebx], 0
    jz      short loc_447EA4
    mov     ecx, [ebx+27h]
    mov     ax, [ecx+9Bh]
    test    al, 40h
    jz      short loc_447EA4
    and     eax, 0FFBFh
    mov     [ecx+9Bh], ax
    mov     ecx, [ebx+27h]
    mov     byte ptr [ecx+95h], 0
    jmp     loc_447F2E
    ; ---------------------------------------------------------------------------

    loc_447EA4:                             ; CODE XREF: sub_447B10+369j
                                            ; sub_447B10+377j
    mov     eax, [ebx+27h]
    xor     edx, edx
    mov     cl, [eax+95h]
    inc     cl
    mov     [eax+95h], cl
    mov     eax, [ebx+27h]
    mov     ecx, TAdynmemStructPtr
    mov     dl, [eax+95h]
    cmp     edx, [ecx+37F39h]
    jl      short loc_447F2E
    mov     byte ptr [eax+95h], 0
    call    sub_456850
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    mov     ecx, [eax+edx*2+1B8Ah]
    test    byte ptr [ecx+9Bh], 80h
    jz      short loc_447F17
    cmp     dword ptr [ebx], 0
    jz      short loc_447F17
    cmp     byte ptr [ebx+73h], 1
    jnz     short loc_447F17
    mov     eax, [ebx+27h]
    or      byte ptr [eax+9Bh], 40h
    jmp     short loc_447F2E
    ; ---------------------------------------------------------------------------

    loc_447F17:                             ; CODE XREF: sub_447B10+3EEj
                                            ; sub_447B10+3F3j ...
    lea     edx, [esp+14Ch+var_124]
    push    0                               ; char
    push    edx                             ; char *
    push    edi                             ; int
    call    sub_4A1080
    mov     eax, [edi+60h]
    push    eax
    push    edi
    call    sub_4A5F40

    loc_447F2E:                             ; CODE XREF: sub_447B10+38Fj
                                            ; sub_447B10+3BCj ...
    mov     eax, TAdynmemStructPtr
    push    4
    or      byte ptr [eax+2BEEh], 1
    call    RIWrapper_Report
    call    sub_450F90

    loc_447F46:                             ; CODE XREF: sub_447B10+354j
    push    ebp
    lea     ecx, [esp+150h+var_124]
    push    offset aAllyD                   ; "ALLY%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+14Ch+var_124]
    push    edx
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      loc_448058
    mov     esi, [esp+14Ch+var_13C]
    push    0
    mov     dl, [ebp+esi+108h]
    xor     dl, 1
    mov     al, dl
    mov     [ebp+esi+108h], dl
    mov     ecx, [esi+4]
    push    eax
    mov     eax, [ebx+4]
    push    eax
    push    ecx
    call    sub_452960
    mov     al, [esi+13Fh]
    cmp     al, 5
    jnz     short loc_447FA1
    xor     cl, cl
    jmp     short loc_447FAE
    ; ---------------------------------------------------------------------------

    loc_447FA1:                             ; CODE XREF: sub_447B10+48Bj
    mov     dl, [ebx+13Fh]
    xor     ecx, ecx
    cmp     al, dl
    setz    cl

    loc_447FAE:                             ; CODE XREF: sub_447B10+48Fj
    test    cl, cl
    jz      short loc_447FC5
    push    esi
    call    sub_446E90
    push    esi
    mov     byte ptr [esi+13Fh], 5
    call    sub_452BD0

    loc_447FC5:                             ; CODE XREF: sub_447B10+4A0j
    xor     edx, edx
    xor     eax, eax
    mov     dl, [ebp+esi+113h]
    push    0                               ; int
    shl     edx, 1
    cmp     edx, 3
    setz    al
    xor     ecx, ecx
    mov     cl, [ebp+esi+108h]
    or      eax, ecx
    jz      short loc_447FEE
    push    offset aAlly                    ; "Ally"
    jmp     short loc_447FF3
    ; ---------------------------------------------------------------------------

    loc_447FEE:                             ; CODE XREF: sub_447B10+4D5j
    push    offset aMulti_0                 ; char *

    loc_447FF3:                             ; CODE XREF: sub_447B10+4DCj
    call    sub_47F1A0
    mov     al, [ebp+esi+108h]
    test    al, al
    mov     eax, offset aAlliedWith         ; "allied with"
    jnz     short loc_44800D
    mov     eax, offset aBrokeAllianceW     ; "broke alliance with"

    loc_44800D:                             ; CODE XREF: sub_447B10+4F6j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+14Ch+var_130]
    lea     edx, [edx+ecx+TAdynmemStruct.Players.Name]
    push    edx
    push    eax                             ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esp+154h+var_124]
    push    offset aSS_4                    ; " %s %s"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+14Ch+var_124]
    push    0
    push    4
    push    ecx
    push    esi
    call    ChatHandling_1
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2BEEh], 1
    call    sub_450F90

    loc_448058:                             ; CODE XREF: sub_447B10+456j
    push    ebp
    lea     edx, [esp+150h+var_124]
    push    offset aTeamiconsD              ; "TEAMICONS%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+14Ch+var_124]
    push    eax
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4480D5
    push    0                               ; int
    push    offset aAlly                    ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edi, [esp+14Ch+var_130]
    mov     cl, [eax+edi+1CA2h]
    lea     esi, [eax+edi+1B63h]
    push    esi
    mov     edi, ecx
    call    sub_446E90
    lea     eax, [edi+1]
    mov     ecx, 6
    cdq
    idiv    ecx
    push    esi
    mov     [esi+13Fh], dl
    call    sub_452BD0
    call    sub_446C70
    call    sub_446A50
    push    ebx
    call    sub_452BD0
    mov     edi, [esp+14Ch+arg_0]

    loc_4480D5:                             ; CODE XREF: sub_447B10+568j
    push    ebp
    lea     edx, [esp+150h+var_124]
    push    offset aResD                    ; "RES%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+14Ch+var_124]
    push    eax
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_448106
    cmp     dword ptr [ebx], 0
    jz      short loc_448106
    cmp     byte ptr [ebx+73h], 1
    jz      loc_448BB2

    loc_448106:                             ; CODE XREF: sub_447B10+5E5j
                                            ; sub_447B10+5EAj
    push    ebp
    lea     ecx, [esp+150h+var_124]
    push    offset aReadyD                  ; "READY%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+14Ch+var_124]
    push    edx
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      loc_448300
    cmp     dword ptr [ebx], 0
    jz      loc_448300
    cmp     byte ptr [ebx+73h], 1
    jnz     loc_448300
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_4358F0
    test    eax, eax
    jz      loc_4482E7
    call    sub_456850
    mov     edi, TAdynmemStructPtr
    xor     esi, esi
    xor     edx, edx
    cmp     al, 0Ah
    mov     byte ptr [esp+14Ch+var_12C], al
    jz      short loc_4481B4
    mov     eax, [esp+14Ch+var_12C]
    mov     esi, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    mov     esi, [esi+ecx*2+1B8Ah]
    mov     al, [esi+0A7h]
    cmp     al, 2
    jnb     short loc_4481AF
    cmp     al, 1
    jnz     short loc_4481B4
    cmp     byte ptr [esi+0A8h], 2
    jb      short loc_4481B4

    loc_4481AF:                             ; CODE XREF: sub_447B10+690j
    mov     edx, 1

    loc_4481B4:                             ; CODE XREF: sub_447B10+668j
                                            ; sub_447B10+694j ...
    test    edx, edx
    jz      short loc_4481CF
    mov     ecx, [edi+391E9h]
    call    sub_4373A0
    cmp     eax, [esi+0A9h]
    jnz     loc_4482E7

    loc_4481CF:                             ; CODE XREF: sub_447B10+6A6j
    mov     eax, [esp+14Ch+var_138]
    lea     edx, [esp+14Ch+var_124]
    push    1
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A0F30
    mov     ecx, [ebx+27h]
    and     eax, 1
    shl     eax, 5
    mov     dx, [ecx+9Bh]
    and     edx, 0FFDFh
    or      edx, eax
    mov     [ecx+9Bh], dx
    mov     eax, [ebx+27h]
    test    byte ptr [eax+97h], 1
    jz      short loc_448266
    mov     edi, offset aStart_0            ; "START"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [esp+150h+var_13C]
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     ebx, [edx+0CCh]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    push    1
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    offset aStart_0                 ; char *
    and     ecx, 3
    push    edx                             ; int
    rep movsb
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+531h]
    mov     [edx+20h], eax

    loc_448266:                             ; CODE XREF: sub_447B10+70Cj
    mov     edx, TAdynmemStructPtr
    xor     edi, edi

    loc_44826E:                             ; CODE XREF: sub_447B10+7C7j
    mov     eax, [edx+edi+1B63h]
    test    eax, eax
    jz      short loc_4482CB
    mov     al, [edx+edi+1BD6h]
    cmp     al, 1
    jz      short loc_448288
    cmp     al, 2
    jnz     short loc_4482CB

    loc_448288:                             ; CODE XREF: sub_447B10+772j
    xor     ecx, ecx
    mov     esi, [edx+edi+1B8Ah]
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    mov     bx, [esi+9Bh]
    shl     eax, 5
    add     eax, ecx
    add     edx, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [edx+eax*2+1B8Ah]
    mov     dl, [ecx+9Bh]
    xor     dl, bl
    and     edx, 20h
    xor     edx, ebx
    mov     [esi+9Bh], dx
    mov     edx, TAdynmemStructPtr

    loc_4482CB:                             ; CODE XREF: sub_447B10+767j
                                            ; sub_447B10+776j
    add     edi, 14Bh
    cmp     edi, 0CEEh
    jl      short loc_44826E
    or      byte ptr [edx+2BEEh], 1
    call    sub_450F90
    jmp     short loc_448300
    ; ---------------------------------------------------------------------------

    loc_4482E7:                             ; CODE XREF: sub_447B10+64Dj
                                            ; sub_447B10+6B9j
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+14Ch+var_124]
    push    0                               ; int
    add     ecx, 519h
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A1110

    loc_448300:                             ; CODE XREF: sub_447B10+616j
                                            ; sub_447B10+61Fj ...
    inc     ebp
    cmp     ebp, 0Ah
    jge     short loc_44834E
    mov     esi, [esp+14Ch+var_128]
    mov     edi, [esp+14Ch+var_134]
    jmp     loc_447BA2
    ; ---------------------------------------------------------------------------

    loc_448313:                             ; CODE XREF: sub_447B10+22Fj
    push    1
    push    1
    push    1F4h
    push    offset aCanTAddAnother          ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90
    push    0
    mov     ecx, ebx
    call    sub_463C60
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2BEEh], 1

    loc_44834E:                             ; CODE XREF: sub_447B10+7F4j
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cx, [eax+TAdynmemStruct.LOS_Radar]
    cmp     ebp, ecx
    mov     ebp, 1
    jz      short loc_44836C
    or      [eax+2BEEh], bp

    loc_44836C:                             ; CODE XREF: sub_447B10+853j
    mov     esi, [esp+14Ch+arg_0]
    push    offset aPrevmenu                ; "PREVMENU"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4483E7
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    xor     esi, esi

    loc_448396:                             ; CODE XREF: sub_447B10+8C1j
    mov     eax, [ecx+esi+TAdynmemStruct.Players.PlayerActive]
    test    eax, eax
    jz      short loc_4483C5
    mov     al, [ecx+esi+TAdynmemStruct.Players.PlayerType]
    cmp     al, 1
    jz      short loc_4483B0
    cmp     al, 2
    jnz     short loc_4483C5

    loc_4483B0:                             ; CODE XREF: sub_447B10+89Aj
    mov     edx, [ecx+esi+TAdynmemStruct.Players.field_4]
    push    2
    push    edx
    call    sub_453010
    mov     ecx, TAdynmemStructPtr

    loc_4483C5:                             ; CODE XREF: sub_447B10+88Fj
                                            ; sub_447B10+89Ej
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_448396
    mov     byte ptr [ecx+2BC0h], 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 13Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4483E7:                             ; CODE XREF: sub_447B10+870j
    push    offset aMessage                 ; "MESSAGE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_4484DB
    mov     eax, [esp+14Ch+var_138]
    push    offset aMessage                 ; char *
    push    eax                             ; int
    call    sub_4A0010
    lea     ebx, [eax+0B6h]
    or      ecx, 0FFFFFFFFh
    mov     edi, ebx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_4484A7
    push    offset aSyncerr                 ; char *
    push    ebx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_448456
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+2A30h]
    call    sub_46DF40
    test    eax, eax
    jz      short loc_448479
    push    0Ah                             ; char
    push    0                               ; __int16
    push    4                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    jmp     short loc_448479
    ; ---------------------------------------------------------------------------

    loc_448456:                             ; CODE XREF: sub_447B10+921j
    mov     edx, [esp+14Ch+var_13C]
    push    0
    push    4
    push    ebx
    push    edx
    call    ChatHandling_1
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_448479
    push    ebp
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_448479:                             ; CODE XREF: sub_447B10+936j
                                            ; sub_447B10+944j ...
    mov     eax, TAdynmemStructPtr
    mov     edi, offset Data
    or      ecx, 0FFFFFFFFh
    or      byte ptr [eax+2BEEh], 1
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4484A7:                             ; CODE XREF: sub_447B10+90Bj
    mov     ecx, TAdynmemStructPtr
    push    3
    push    offset aMessage                 ; char *
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A7190
    jmp     loc_448B98
    ; ---------------------------------------------------------------------------

    loc_4484DB:                             ; CODE XREF: sub_447B10+8E4j
    push    offset aCommander_1             ; "COMMANDER"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_448552
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     edx, [esp+14Ch+var_13C]
    mov     ecx, [edx+27h]
    mov     ax, [ecx+9Bh]
    mov     esi, eax
    and     esi, 0F800h
    add     esi, 800h
    xor     esi, eax
    and     esi, 1800h
    xor     esi, eax
    mov     [ecx+9Bh], si
    mov     ecx, [edx+27h]
    mov     ax, [ecx+9Bh]
    mov     edx, eax
    and     edx, 1800h
    cmp     edx, 1000h
    jbe     loc_448AAF
    and     eax, 0E7FFh
    mov     [ecx+9Bh], ax
    jmp     loc_448AAF
    ; ---------------------------------------------------------------------------

    loc_448552:                             ; CODE XREF: sub_447B10+9D8j
    push    offset aLostype                 ; "LOSTYPE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4485CB
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     edx, [esp+14Ch+var_13C]
    mov     ecx, [edx+27h]
    mov     ax, [ecx+9Bh]
    test    ah, 2
    jnz     short loc_448599
    or      ah, 2
    mov     [ecx+9Bh], ax
    mov     eax, [edx+27h]
    or      byte ptr [eax+9Ch], 4
    jmp     loc_448AAF
    ; ---------------------------------------------------------------------------

    loc_448599:                             ; CODE XREF: sub_447B10+A6Ej
    mov     edx, eax
    and     edx, 400h
    cmp     edx, 400h
    jnz     short loc_4485BA
    and     eax, 0FBFFh
    mov     [ecx+9Bh], ax
    jmp     loc_448AAF
    ; ---------------------------------------------------------------------------

    loc_4485BA:                             ; CODE XREF: sub_447B10+A97j
    and     eax, 0FDFFh
    mov     [ecx+9Bh], ax
    jmp     loc_448AAF
    ; ---------------------------------------------------------------------------

    loc_4485CB:                             ; CODE XREF: sub_447B10+A4Fj
    push    offset aWatching_0              ; "WATCHING"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_44863D
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     esi, [esp+14Ch+var_13C]
    mov     ecx, [esi+27h]
    mov     ax, [ecx+9Bh]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 80h
    xor     edx, eax
    mov     [ecx+9Bh], dx
    mov     ecx, [esi+27h]
    mov     ax, [ecx+9Bh]
    test    al, 80h
    jnz     loc_448AAF
    cmp     dword ptr [esi], 0
    jz      loc_448AAF
    test    al, 40h
    jz      loc_448AAF
    and     eax, 0FFBFh
    mov     [ecx+9Bh], ax
    jmp     loc_448AAF
    ; ---------------------------------------------------------------------------

    loc_44863D:                             ; CODE XREF: sub_447B10+AC8j
    push    offset aCheating_0              ; "CHEATING"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_448674
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     eax, [esp+14Ch+var_13C]
    mov     ecx, [eax+27h]
    mov     ax, [ecx+9Bh]
    mov     edx, eax
    not     edx
    xor     edx, eax
    and     edx, 2000h
    jmp     short loc_4486A9
    ; ---------------------------------------------------------------------------

    loc_448674:                             ; CODE XREF: sub_447B10+B3Aj
    push    offset aFixedloc_0              ; "FIXEDLOC"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4486C8
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     eax, [esp+14Ch+var_13C]
    mov     ecx, [eax+27h]
    mov     ax, [ecx+9Bh]
    mov     edx, eax
    not     edx
    xor     edx, eax
    and     edx, 4000h

    loc_4486A9:                             ; CODE XREF: sub_447B10+B62j
    xor     edx, eax
    mov     [ecx+9Bh], dx
    call    sub_450F90
    mov     eax, TAdynmemStructPtr
    or      [eax+2BEEh], bp
    jmp     loc_448B98
    ; ---------------------------------------------------------------------------

    loc_4486C8:                             ; CODE XREF: sub_447B10+B71j
    push    offset aMapping_1               ; "MAPPING"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_448717
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    push    offset aMapping_1               ; char *
    push    esi                             ; int
    call    sub_4A0F60
    xor     ebx, ebx
    mov     ecx, [esp+14Ch+var_13C]
    mov     ecx, [ecx+27h]
    mov     dx, [ecx+9Bh]
    and     edx, 0FEFFh
    test    eax, eax
    setz    bl
    and     bl, 1
    xor     eax, eax
    mov     ah, bl
    or      edx, eax
    jmp     loc_448AA8
    ; ---------------------------------------------------------------------------

    loc_448717:                             ; CODE XREF: sub_447B10+BC5j
    push    offset aStart_0                 ; "START"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_448A62
    xor     esi, esi
    push    esi                             ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    mov     edx, 0Ah
    lea     eax, [ecx+1B8Ah]

    loc_448748:                             ; CODE XREF: sub_447B10+C6Fj
    mov     ecx, [eax-27h]
    test    ecx, ecx
    jz      short loc_448779
    mov     bl, [eax+4Ch]
    cmp     bl, 1
    jz      short loc_44876D
    test    ecx, ecx
    jz      short loc_448779
    mov     cl, bl
    cmp     cl, 3
    jnz     short loc_448779
    mov     ecx, [eax]
    cmp     byte ptr [ecx+94h], 1
    jnz     short loc_448779

    loc_44876D:                             ; CODE XREF: sub_447B10+C45j
    mov     ecx, [eax]
    test    byte ptr [ecx+9Dh], 4
    jz      short loc_448779
    inc     esi

    loc_448779:                             ; CODE XREF: sub_447B10+C3Dj
                                            ; sub_447B10+C49j ...
    add     eax, 14Bh
    dec     edx
    jnz     short loc_448748
    cmp     esi, 1
    jl      loc_448A22
    cmp     esi, 2
    jge     short loc_44879D
    call    sub_457AF0
    cmp     eax, 3
    jg      loc_448A22

    loc_44879D:                             ; CODE XREF: sub_447B10+C7Dj
    cmp     esi, 3
    jge     short loc_4487B0
    call    sub_457AF0
    cmp     eax, 6
    jg      loc_448A22

    loc_4487B0:                             ; CODE XREF: sub_447B10+C90j
    call    sub_457B40
    mov     esi, eax
    call    sub_457AF0
    mov     ebp, TAdynmemStructPtr
    xor     ebx, ebx
    add     esi, eax
    cmp     ebx, 5
    mov     [esp+14Ch+var_134], esi
    jnz     short loc_4487D6
    xor     eax, eax
    jmp     loc_448885
    ; ---------------------------------------------------------------------------

    loc_4487D6:                             ; CODE XREF: sub_447B10+CBDj
                                            ; sub_447B10+D7Dj
    mov     dl, [ebp+TAdynmemStruct.NetworkLayerEnabled]
    xor     edi, edi
    shr     dl, 2
    and     dl, 1
    lea     eax, [ebp+TAdynmemStruct.Players.PlayerType]
    mov     esi, 0Ah

    loc_4487EF:                             ; CODE XREF: sub_447B10+D69j
    test    dl, dl
    jz      short loc_448845
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, ebx
    jnz     short loc_448873
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_448873
    mov     cl, [eax]
    cmp     cl, Player_LocalHuman
    jz      short loc_448817
    cmp     cl, Player_AI
    jz      short loc_448817
    cmp     cl, Player_RemoteHuman
    jnz     short loc_448873

    loc_448817:                             ; CODE XREF: sub_447B10+CFBj
                                            ; sub_447B10+D00j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_448873
    cmp     cl, Player_LocalHuman
    jz      short loc_44882F
    cmp     cl, Player_AI
    jz      short loc_44882F
    cmp     cl, Player_RemoteHuman
    jnz     short loc_448873

    loc_44882F:                             ; CODE XREF: sub_447B10+D13j
                                            ; sub_447B10+D18j
    cmp     word ptr [eax+0D1h], 0
    jnz     short loc_448872
    mov     ecx, [eax+0CDh]
    test    ecx, ecx
    jnz     short loc_448873
    jmp     short loc_448872
    ; ---------------------------------------------------------------------------

    loc_448845:                             ; CODE XREF: sub_447B10+CE1j
    xor     ecx, ecx
    mov     cl, [eax+0CCh]
    cmp     ecx, ebx
    jnz     short loc_448873
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_448873
    mov     cl, [eax]
    cmp     cl, Player_LocalHuman
    jz      short loc_448869
    cmp     cl, Player_AI
    jz      short loc_448869
    cmp     cl, Player_RemoteHuman
    jnz     short loc_448873

    loc_448869:                             ; CODE XREF: sub_447B10+D4Dj
                                            ; sub_447B10+D52j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_448873

    loc_448872:                             ; CODE XREF: sub_447B10+D27j
                                            ; sub_447B10+D33j
    inc     edi

    loc_448873:                             ; CODE XREF: sub_447B10+CEDj
                                            ; sub_447B10+CF4j ...
    add     eax, 14Bh
    dec     esi
    jnz     loc_4487EF
    mov     esi, [esp+14Ch+var_134]
    mov     eax, edi

    loc_448885:                             ; CODE XREF: sub_447B10+CC1j
    cmp     eax, esi
    jz      short loc_448895
    inc     ebx
    cmp     ebx, 5
    jl      loc_4487D6
    jmp     short loc_4488CF
    ; ---------------------------------------------------------------------------

    loc_448895:                             ; CODE XREF: sub_447B10+D77j
    add     ebp, 519h
    push    ebp
    call    sub_4AB0A0
    push    1
    push    1
    push    0C8h
    push    offset aCanNotStartGam          ; int
    call    sub_4C5740
    push    eax
    mov     edx, [esp+15Ch+arg_0]
    push    edx
    call    sub_4ABD90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 13Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4488CF:                             ; CODE XREF: sub_447B10+D83j
    mov     ecx, [ebp+391E9h]
    call    sub_435C40
    test    al, al
    jnz     short loc_4488F4
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    call    sub_444EA0
    jmp     loc_448B98
    ; ---------------------------------------------------------------------------

    loc_4488F4:                             ; CODE XREF: sub_447B10+DCCj
    mov     edi, [esp+14Ch+var_13C]
    mov     eax, [edi+27h]
    test    byte ptr [eax+9Bh], 80h
    jnz     short loc_448954
    mov     eax, TAdynmemStructPtr
    xor     esi, esi

    loc_44890B:                             ; CODE XREF: sub_447B10+E40j
    mov     ecx, [eax+esi+1B63h]
    test    ecx, ecx
    jz      short loc_448944
    cmp     byte ptr [eax+esi+1BD6h], 3
    jnz     short loc_448944
    mov     ecx, [eax+esi+1B8Ah]
    test    byte ptr [ecx+9Bh], 40h
    jz      short loc_448944
    mov     edx, [eax+esi+1B67h]
    push    9
    push    edx
    call    sub_453010
    mov     eax, TAdynmemStructPtr

    loc_448944:                             ; CODE XREF: sub_447B10+E04j
                                            ; sub_447B10+E0Ej ...
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_44890B
    jmp     short loc_448959
    ; ---------------------------------------------------------------------------

    loc_448954:                             ; CODE XREF: sub_447B10+DF2j
    mov     eax, TAdynmemStructPtr

    loc_448959:                             ; CODE XREF: sub_447B10+E42j
    mov     byte ptr [eax+2BC0h], 11h
    mov     eax, [edi+27h]
    or      byte ptr [eax+9Bh], 10h
    call    sub_451180
    mov     eax, [edi+27h]
    mov     edx, TAdynmemStructPtr
    mov     cx, [eax+9Bh]
    shr     ecx, 9
    and     ecx, 1
    mov     [edx+39231h], ecx
    mov     eax, [edi+27h]
    mov     edx, TAdynmemStructPtr
    mov     cx, [eax+9Bh]
    shr     ecx, 0Ah
    and     ecx, 1
    mov     [edx+TAdynmemStruct.RenderingOptions], ecx
    mov     eax, [edi+27h]
    mov     edx, TAdynmemStructPtr
    mov     cx, [eax+9Bh]
    shr     ecx, 0Bh
    and     ecx, 3
    mov     [edx+39229h], ecx
    mov     eax, [edi+27h]
    mov     edx, TAdynmemStructPtr
    mov     cx, [eax+9Bh]
    mov     eax, [edx+29A0h]
    shr     ecx, 0Eh
    and     ecx, 1
    mov     [eax+118h], ecx
    mov     ecx, [edi+27h]
    mov     eax, TAdynmemStructPtr
    mov     dx, [ecx+9Bh]
    shr     edx, 8
    and     edx, 1
    mov     [eax+3922Dh], edx
    call    WriteRegistrySettings_2
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+37EEEh], 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 13Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_448A22:                             ; CODE XREF: sub_447B10+C74j
                                            ; sub_447B10+C87j ...
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4AB0A0
    push    1
    push    1
    push    0C8h
    push    offset aThereAreNotEno          ; int
    call    sub_4C5740
    push    eax
    mov     eax, [esp+15Ch+arg_0]
    push    eax
    call    sub_4ABD90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 13Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_448A62:                             ; CODE XREF: sub_447B10+C14j
    push    offset aGameopen                ; "GAMEOPEN"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_448ACA
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    push    offset aGameopen                ; char *
    push    esi                             ; int
    call    sub_4A0F60
    xor     ebx, ebx
    mov     ecx, [esp+14Ch+var_13C]
    mov     ecx, [ecx+27h]
    mov     dx, [ecx+9Bh]
    and     edx, 7FFFh
    test    eax, eax
    setz    bl
    shl     ebx, 0Fh
    or      edx, ebx

    loc_448AA8:                             ; CODE XREF: sub_447B10+C02j
    mov     [ecx+9Bh], dx

    loc_448AAF:                             ; CODE XREF: sub_447B10+A2Bj
                                            ; sub_447B10+A3Dj ...
    call    sub_450F90
    call    sub_451180
    mov     eax, TAdynmemStructPtr
    or      [eax+2BEEh], bp
    jmp     loc_448B98
    ; ---------------------------------------------------------------------------

    loc_448ACA:                             ; CODE XREF: sub_447B10+F5Fj
    push    offset aRestrictions            ; "RESTRICTIONS"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_448AF5
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    call    sub_44C7E0
    push    esi
    call    sub_4AB0A0
    jmp     loc_448B98
    ; ---------------------------------------------------------------------------

    loc_448AF5:                             ; CODE XREF: sub_447B10+FC7j
    push    offset off_505CF4
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_448B17
    push    offset aMapname                 ; "MAPNAME"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_448B98

    loc_448B17:                             ; CODE XREF: sub_447B10+FF2j
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    mov     eax, [esp+14Ch+var_13C]
    mov     ecx, [eax+27h]
    test    byte ptr [ecx+97h], 1
    jz      short loc_448B3A
    call    sub_444EA0
    jmp     short loc_448B98
    ; ---------------------------------------------------------------------------

    loc_448B3A:                             ; CODE XREF: sub_447B10+1021j
    mov     edx, TAdynmemStructPtr
    push    900h
    add     edx, 519h
    push    offset aViewmap_gui             ; "VIEWMAP.GUI"
    push    edx
    call    sub_4AA8F0
    push    0
    push    0
    push    0
    push    offset aDviewmap                ; "DVIEWMAP"
    mov     dword ptr [eax+8], offset loc_444BA0
    call    sub_4288D0
    call    sub_444A20
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0

    loc_448B98:                             ; CODE XREF: sub_447B10+9C6j
                                            ; sub_447B10+BB3j ...
    mov     edx, [esp+14Ch+arg_0]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 13Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_448BB2:                             ; CODE XREF: sub_447B10+5F0j
    push    0                               ; int
    push    offset aMulti_0                 ; char *
    call    sub_47F1A0
    call    sub_446310
    push    edi
    call    sub_4AB0A0
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    or      byte ptr [eax+2BEEh], 1
    pop     ebx
    add     esp, 13Ch
    retn    4
    sub_447B10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_448BF0 proc near

    var_14= byte ptr -14h
    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    mov     edx, TAdynmemStructPtr
    mov     eax, ecx
    sub     esp, 14h
    shl     eax, 5
    add     eax, ecx
    add     edx, ecx
    push    esi
    push    ecx
    lea     eax, [eax+eax*4]
    push    offset aSideD                   ; "SIDE%d"
    lea     esi, [edx+eax*2+1B63h]
    lea     eax, [esp+20h+var_14]
    push    eax
    call    _sprintf
    mov     eax, [esi]
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_448C3D
    mov     ecx, [esi+27h]
    test    byte ptr [ecx+9Bh], 40h
    jz      short loc_448C3D
    mov     eax, 2
    jmp     short loc_448C48
    ; ---------------------------------------------------------------------------

    loc_448C3D:                             ; CODE XREF: sub_448BF0+38j
                                            ; sub_448BF0+44j
    mov     edx, [esi+27h]
    xor     eax, eax
    mov     al, [edx+95h]

    loc_448C48:                             ; CODE XREF: sub_448BF0+4Bj
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char
    lea     eax, [esp+1Ch+var_14]
    add     ecx, 519h
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A1080
    pop     esi
    add     esp, 14h
    retn    4
    sub_448BF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_448C70 proc near                    ; CODE XREF: Battleroom_Unknown1+A16p
                                            ; .text:0044AE00p

    var_D4= byte ptr -0D4h
    var_C0= dword ptr -0C0h
    var_BC= dword ptr -0BCh
    var_B8= dword ptr -0B8h
    var_B4= dword ptr -0B4h
    var_B0= dword ptr -0B0h
    var_AC= dword ptr -0ACh
    var_A8= dword ptr -0A8h
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= byte ptr -9Ch
    var_7C= byte ptr -7Ch
    var_68= dword ptr -68h
    var_34= byte ptr -34h

    sub     esp, 0D4h
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    ebx
    push    ebp
    mov     cl, [edx+2A42h]
    push    esi
    mov     eax, ecx
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    push    edi
    push    offset aOutput                  ; char *
    lea     eax, [eax+eax*4]
    mov     [esp+0E8h+var_B0], 0FFFFFFFFh
    xor     ebp, ebp
    mov     ecx, [esi+eax*2+1B8Ah]
    lea     eax, [esi+eax*2+1B63h]
    mov     [esp+0E8h+var_B4], eax
    mov     al, [ecx+9Bh]
    mov     ecx, [edx+531h]
    shr     eax, 5
    mov     edx, [ecx+4]
    and     eax, 1
    push    edx                             ; int
    mov     [esp+0ECh+var_C0], eax
    call    sub_49FF90
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    xor     ebx, ebx
    mov     si, [eax+2A3Eh]
    mov     bx, [eax+2A40h]
    cmp     esi, ebx
    mov     [esp+0E4h+var_BC], edi
    jge     short loc_448CFA
    add     esi, 1Eh

    loc_448CFA:                             ; CODE XREF: sub_448C70+85j
    call    sub_4A50B0
    mov     ecx, eax
    sub     esi, ebx
    movsx   eax, word ptr [edi+19h]
    cdq
    add     ecx, 2
    idiv    ecx
    cmp     esi, eax
    mov     eax, TAdynmemStructPtr
    jle     short loc_448D3A
    inc     word ptr [eax+2A40h]
    mov     eax, TAdynmemStructPtr
    cmp     word ptr [eax+2A40h], 1Eh
    jb      short loc_448D3A
    mov     word ptr [eax+2A40h], 0
    mov     eax, TAdynmemStructPtr

    loc_448D3A:                             ; CODE XREF: sub_448C70+A4j
                                            ; sub_448C70+BAj
    mov     cx, [eax+2A3Eh]
    mov     bx, [eax+2A40h]
    cmp     cx, bx
    jz      short loc_448DB8
    and     ebx, 0FFFFh
    and     ecx, 0FFFFh
    cmp     ecx, ebx
    jz      short loc_448DB8

    loc_448D5D:                             ; CODE XREF: sub_448C70+142j
    mov     edx, [eax+2A9Bh]
    push    ebp
    push    edx
    call    sub_4B6AF0
    mov     ecx, TAdynmemStructPtr
    mov     edx, eax
    lea     eax, [ebx+ebx*8]
    lea     edi, [ecx+eax*8+12EFh]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    inc     ebp
    inc     ebx
    cmp     ebx, 1Eh
    rep movsb
    jnz     short loc_448DA2
    xor     ebx, ebx

    loc_448DA2:                             ; CODE XREF: sub_448C70+12Ej
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cx, [eax+2A3Eh]
    cmp     ecx, ebx
    jnz     short loc_448D5D
    mov     edi, [esp+0E4h+var_BC]

    loc_448DB8:                             ; CODE XREF: sub_448C70+DBj
                                            ; sub_448C70+EBj
    call    sub_445ED0
    mov     [edi+0C0h], bp
    mov     edx, TAdynmemStructPtr
    push    offset aMapname                 ; char *
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0180
    mov     edx, TAdynmemStructPtr
    mov     ebp, eax
    mov     ecx, [edx+391E9h]
    call    sub_435C30
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435C40
    test    al, al
    jnz     short loc_448E31
    mov     dword ptr [ebp+23h], 0Ch
    mov     ecx, TAdynmemStructPtr
    push    0
    push    offset aNotSelected             ; "NOT SELECTED"
    add     ecx, 519h
    push    offset aMapname                 ; "MAPNAME"
    push    ecx
    call    sub_4A0BF0
    jmp     loc_44904E
    ; ---------------------------------------------------------------------------

    loc_448E31:                             ; CODE XREF: sub_448C70+195j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435C20
    lea     ecx, [ebp+0B6h]
    mov     esi, eax
    mov     [esp+0E4h+var_AC], ecx
    mov     eax, ecx

    loc_448E50:                             ; CODE XREF: sub_448C70+202j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_448E78
    test    cl, cl
    jz      short loc_448E74
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_448E78
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_448E50

    loc_448E74:                             ; CODE XREF: sub_448C70+1ECj
    xor     ebx, ebx
    jmp     short loc_448E7D
    ; ---------------------------------------------------------------------------

    loc_448E78:                             ; CODE XREF: sub_448C70+1E8j
                                            ; sub_448C70+1F8j
    sbb     ebx, ebx
    sbb     ebx, 0FFFFFFFFh

    loc_448E7D:                             ; CODE XREF: sub_448C70+206j
    test    ebx, ebx
    jz      short loc_448EB3
    mov     eax, TAdynmemStructPtr
    push    offset aViewmap_gui_0           ; char *
    add     eax, 519h
    push    eax                             ; int
    call    sub_4AB060
    test    eax, eax
    jz      short loc_448EA1
    call    sub_444A20
    jmp     short loc_448EB3
    ; ---------------------------------------------------------------------------

    loc_448EA1:                             ; CODE XREF: sub_448C70+228j
    mov     ecx, TAdynmemStructPtr
    push    edi
    mov     ecx, [ecx+391E9h]
    call    sub_435A20

    loc_448EB3:                             ; CODE XREF: sub_448C70+20Fj
                                            ; sub_448C70+22Fj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_4358F0
    test    eax, eax
    jz      short loc_448F38
    call    sub_456850
    mov     edi, TAdynmemStructPtr
    xor     esi, esi
    xor     edx, edx
    cmp     al, 0Ah
    mov     byte ptr [esp+0E4h+var_BC], al
    jz      short loc_448F19
    mov     eax, [esp+0E4h+var_BC]
    mov     esi, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    mov     esi, [esi+ecx*2+1B8Ah]
    mov     al, [esi+0A7h]
    cmp     al, 2
    jnb     short loc_448F14
    cmp     al, 1
    jnz     short loc_448F19
    cmp     byte ptr [esi+0A8h], 2
    jb      short loc_448F19

    loc_448F14:                             ; CODE XREF: sub_448C70+295j
    mov     edx, 1

    loc_448F19:                             ; CODE XREF: sub_448C70+26Dj
                                            ; sub_448C70+299j ...
    test    edx, edx
    jz      loc_448FFC
    mov     ecx, [edi+391E9h]
    call    sub_4373A0
    cmp     eax, [esi+0A9h]
    jz      loc_448FFC

    loc_448F38:                             ; CODE XREF: sub_448C70+256j
    call    sub_4B6340
    mov     ecx, eax
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    and     dl, 1
    neg     dl
    sbb     edx, edx
    and     edx, 0Ch
    test    ebx, ebx
    mov     [ebp+23h], edx
    jz      short loc_448FC7
    push    0
    push    4
    push    offset aDoesNotHaveThi          ; int
    call    sub_4C5740
    push    eax
    mov     esi, [esp+0F0h+var_B4]
    push    esi
    call    ChatHandling_1
    mov     eax, [esi+27h]
    xor     ecx, ecx
    and     word ptr [eax+9Bh], 0FFDFh
    mov     edx, TAdynmemStructPtr
    lea     eax, [esp+0E4h+var_D4]
    mov     cl, [edx+2A42h]
    push    ecx
    push    offset aReadyD                  ; "READY%d"
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+0E4h+var_D4]
    add     edx, 519h
    push    0                               ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A1110
    call    sub_450F90

    loc_448FC7:                             ; CODE XREF: sub_448C70+2F1j
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B8Ah]
    test    byte ptr [ecx+97h], 1
    jnz     short loc_449022
    push    1
    push    offset off_505CF4
    jmp     short loc_449010
    ; ---------------------------------------------------------------------------

    loc_448FFC:                             ; CODE XREF: sub_448C70+2ABj
                                            ; sub_448C70+2C2j
    mov     dword ptr [ebp+23h], 0
    mov     edx, TAdynmemStructPtr
    push    0
    push    offset off_505CF4

    loc_449010:                             ; CODE XREF: sub_448C70+38Aj
    add     edx, 519h
    push    edx
    call    sub_4A1450
    mov     edx, TAdynmemStructPtr

    loc_449022:                             ; CODE XREF: sub_448C70+381j
    mov     ecx, [edx+391E9h]
    call    sub_435C20
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+0E4h+var_AC]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_44904E:                             ; CODE XREF: sub_448C70+1BCj
    mov     eax, TAdynmemStructPtr
    xor     edi, edi

    loc_449055:                             ; CODE XREF: sub_448C70+44Fj
    mov     ecx, [eax+edi+1B63h]
    test    ecx, ecx
    jz      short loc_4490B3
    mov     cl, [eax+edi+1BD6h]
    cmp     cl, 1
    jz      short loc_449071
    cmp     cl, 2
    jnz     short loc_4490B3

    loc_449071:                             ; CODE XREF: sub_448C70+3FAj
    xor     edx, edx
    mov     esi, [eax+edi+1B8Ah]
    mov     dl, [eax+2A42h]
    mov     ecx, edx
    mov     bx, [esi+9Bh]
    shl     ecx, 5
    add     ecx, edx
    add     eax, edx
    lea     ecx, [ecx+ecx*4]
    mov     edx, [eax+ecx*2+1B8Ah]
    mov     al, [edx+9Bh]
    xor     al, bl
    and     eax, 20h
    xor     eax, ebx
    mov     [esi+9Bh], ax
    mov     eax, TAdynmemStructPtr

    loc_4490B3:                             ; CODE XREF: sub_448C70+3EEj
                                            ; sub_448C70+3FFj
    add     edi, 14Bh
    cmp     edi, 0CEEh
    jl      short loc_449055
    xor     edi, edi
    mov     bl, 80h

    loc_4490C5:                             ; CODE XREF: sub_448C70+534j
    xor     edx, edx
    lea     esi, [eax+edi+1B63h]
    mov     dl, [eax+2A42h]
    mov     ecx, edx
    add     eax, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    mov     edx, [eax+ecx*2+1B8Ah]
    mov     ax, [edx+9Bh]
    and     eax, 1800h
    cmp     eax, 1000h
    jnz     short loc_44912E
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_44912E
    mov     cl, [esi+73h]
    cmp     cl, 2
    jz      short loc_44911E
    test    eax, eax
    jz      short loc_44912E
    mov     al, cl
    cmp     al, 3
    jnz     short loc_44912E
    mov     ecx, [esi+27h]
    cmp     byte ptr [ecx+94h], 2
    jnz     short loc_44912E

    loc_44911E:                             ; CODE XREF: sub_448C70+496j
    mov     edx, [esi+4]
    push    0Bh
    push    edx
    call    sub_453010
    call    sub_450F90

    loc_44912E:                             ; CODE XREF: sub_448C70+488j
                                            ; sub_448C70+48Ej ...
    call    sub_456850
    cmp     al, 0Ah
    jz      short loc_449193
    call    sub_456850
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    mov     ebp, eax
    add     ebp, ecx
    mov     ecx, [ebp+edx*2+1B8Ah]
    test    [ecx+9Bh], bl
    jnz     short loc_449198
    cmp     dword ptr [esi], 0
    jz      short loc_449198
    mov     edx, [esi+27h]
    mov     cx, [edx+9Bh]
    test    cl, 40h
    jz      short loc_449198
    and     ecx, 0FFBFh
    mov     [edx+9Bh], cx
    mov     edx, [esi+27h]
    mov     byte ptr [edx+95h], 0
    call    sub_450F90

    loc_449193:                             ; CODE XREF: sub_448C70+4C5j
    mov     eax, TAdynmemStructPtr

    loc_449198:                             ; CODE XREF: sub_448C70+4F1j
                                            ; sub_448C70+4F6j ...
    add     edi, 14Bh
    cmp     edi, 0CEEh
    jl      loc_4490C5
    call    sub_446C70
    call    sub_446A50
    mov     ebp, TAdynmemStructPtr
    mov     byte ptr [esp+0E4h+var_B8], 0
    mov     eax, [ebp+531h]
    mov     ecx, [eax+4]
    mov     [esp+0E4h+var_BC], ecx
    xor     ecx, ecx
    mov     cl, [ebp+2A42h]
    mov     edi, [esp+0E4h+var_BC]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, ebp
    add     eax, ecx
    lea     ecx, [eax+edx*2+1B63h]
    mov     [esp+0E4h+var_A8], ecx
    jmp     short loc_4491F9
    ; ---------------------------------------------------------------------------

    loc_4491F3:                             ; CODE XREF: sub_448C70+EF0j
    mov     ebp, TAdynmemStructPtr

    loc_4491F9:                             ; CODE XREF: sub_448C70+581j
    mov     ebx, [esp+0E4h+var_B8]
    and     ebx, 0FFh
    mov     eax, ebx
    shl     eax, 5
    add     eax, ebx
    lea     edx, [eax+eax*4]
    lea     eax, [ebx+edx*2]
    mov     [esp+0E4h+var_A0], eax
    lea     ebp, [ebp+eax+1B63h]
    mov     eax, [ebp+0]
    test    eax, eax
    jz      short loc_449255
    mov     cl, [ebp+73h]
    cmp     cl, 1
    jz      short loc_449234
    cmp     cl, 2
    jz      short loc_449234
    cmp     cl, 3
    jnz     short loc_449241

    loc_449234:                             ; CODE XREF: sub_448C70+5B8j
                                            ; sub_448C70+5BDj
    cmp     byte ptr [ebp+146h], 0Ah
    jnz     loc_4494A3

    loc_449241:                             ; CODE XREF: sub_448C70+5C2j
    test    eax, eax
    jz      short loc_449255
    mov     eax, [ebp+27h]
    test    byte ptr [eax+9Bh], 40h
    jnz     loc_4494A3

    loc_449255:                             ; CODE XREF: sub_448C70+5B0j
                                            ; sub_448C70+5D3j
    push    ebx
    lea     ecx, [esp+0E8h+var_D4]
    push    offset aCdD                     ; "CD%d"
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+0E4h+var_D4]
    add     eax, 519h
    push    0                               ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+0E4h+var_D4]
    push    0
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4A1450
    push    ebx
    lea     eax, [esp+0E8h+var_D4]
    push    offset aPlayerD                 ; "PLAYER%d"
    push    eax
    call    _sprintf
    mov     cl, [ebp+73h]
    add     esp, 0Ch
    cmp     cl, 4
    mov     eax, offset aUnused             ; "UNUSED"
    jnz     short loc_4492DF
    push    offset aBlocked                 ; int
    call    sub_4C5740
    push    eax
    lea     ecx, [esp+0E8h+var_34]
    push    offset aS_2                     ; "[%s]"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+0E4h+var_34]

    loc_4492DF:                             ; CODE XREF: sub_448C70+646j
    push    1Eh                             ; size_t
    lea     edx, [esp+0E8h+var_9C]
    push    eax                             ; char *
    push    edx                             ; char *
    call    _strncpy
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+0E4h+var_9C]
    lea     ecx, [esp+0E4h+var_D4]
    push    0
    push    eax
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4A0BF0
    lea     eax, [esp+0E4h+var_D4]
    push    0Eh
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A5D50
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+10h]
    mov     edx, [esp+24h]
    add     ecx, 519h
    push    edx
    push    eax
    push    ecx
    call    sub_4A1450
    push    ebx
    lea     edx, [esp+14h]
    push    offset aLogoD                   ; "LOGO%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+10h]
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_4A0280
    test    eax, eax
    jz      short loc_44936F
    mov     byte ptr [eax+29h], 0

    loc_44936F:                             ; CODE XREF: sub_448C70+6F9j
    push    ebx
    lea     ecx, [esp+14h]
    push    offset aSideD                   ; "SIDE%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+10h]
    push    edx                             ; char *
    push    edi                             ; int
    call    sub_49FF10
    test    eax, eax
    jz      short loc_449395
    mov     byte ptr [eax+29h], 0

    loc_449395:                             ; CODE XREF: sub_448C70+71Fj
    mov     eax, TAdynmemStructPtr
    mov     cl, byte ptr [esp+0E8h+var_BC]
    cmp     cl, [eax+2A42h]
    jz      short loc_4493CC
    push    ebx
    lea     edx, [esp+14h]
    push    offset aAllyD                   ; "ALLY%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+10h]
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_49FF10
    test    eax, eax
    jz      short loc_4493CC
    mov     byte ptr [eax+29h], 0

    loc_4493CC:                             ; CODE XREF: sub_448C70+734j
                                            ; sub_448C70+756j
    push    ebx
    lea     ecx, [esp+14h]
    push    offset aTeamiconsD              ; "TEAMICONS%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+10h]
    push    edx                             ; char *
    push    edi                             ; int
    call    sub_49FF10
    test    eax, eax
    jz      short loc_4493F2
    mov     byte ptr [eax+29h], 0

    loc_4493F2:                             ; CODE XREF: sub_448C70+77Cj
    push    ebx
    lea     eax, [esp+14h]
    push    offset aResD                    ; "RES%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+10h]
    push    ecx                             ; char *
    push    edi                             ; int
    call    sub_4A0180
    test    eax, eax
    jz      short loc_449418
    mov     byte ptr [eax+29h], 0

    loc_449418:                             ; CODE XREF: sub_448C70+7A2j
    push    ebx
    lea     edx, [esp+14h]
    push    offset aPingD                   ; "PING%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+10h]
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_4A0180
    test    eax, eax
    jz      short loc_44943E
    mov     byte ptr [eax+29h], 0

    loc_44943E:                             ; CODE XREF: sub_448C70+7C8j
    push    ebx
    lea     ecx, [esp+14h]
    push    offset aMemD                    ; "MEM%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+10h]
    push    edx                             ; char *
    push    edi                             ; int
    call    sub_4A0180
    test    eax, eax
    jz      short loc_449464
    mov     byte ptr [eax+29h], 0

    loc_449464:                             ; CODE XREF: sub_448C70+7EEj
    push    ebx
    lea     eax, [esp+14h]
    push    offset aReadyD                  ; "READY%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+10h]
    push    ecx                             ; char *
    push    edi                             ; int
    call    sub_49FF10
    test    eax, eax
    jz      loc_449B54
    or      byte ptr [eax+13Ch], 1
    mov     word ptr [eax+138h], 0
    mov     byte ptr [eax+29h], 0
    jmp     loc_449B54
    ; ---------------------------------------------------------------------------

    loc_4494A3:                             ; CODE XREF: sub_448C70+5CBj
                                            ; sub_448C70+5DFj
    push    ebx
    lea     edx, [esp+0E8h+var_D4]
    push    offset aCdD                     ; "CD%d"
    push    edx
    call    _sprintf
    mov     eax, [ebp+0]
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4494EE
    mov     cl, [ebp+73h]
    cmp     cl, 1
    jz      short loc_4494DB
    test    eax, eax
    jz      short loc_4494EE
    mov     al, cl
    cmp     al, 3
    jnz     short loc_4494EE
    mov     eax, [ebp+27h]
    cmp     byte ptr [eax+94h], 1
    jnz     short loc_4494EE

    loc_4494DB:                             ; CODE XREF: sub_448C70+853j
    mov     ecx, [ebp+27h]
    test    byte ptr [ecx+9Dh], 4
    jz      short loc_4494EE
    mov     eax, 1
    jmp     short loc_4494F0
    ; ---------------------------------------------------------------------------

    loc_4494EE:                             ; CODE XREF: sub_448C70+84Bj
                                            ; sub_448C70+857j ...
    xor     eax, eax

    loc_4494F0:                             ; CODE XREF: sub_448C70+87Cj
    push    eax                             ; int
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+0E8h+var_D4]
    add     eax, 519h
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+0E4h+var_D4]
    push    0
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4A1450
    push    ebx
    lea     eax, [esp+0E8h+var_D4]
    push    offset aLogoD                   ; "LOGO%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+0E4h+var_D4]
    push    ecx                             ; char *
    push    edi                             ; int
    call    sub_4A0280
    test    eax, eax
    jz      short loc_4495A4
    mov     edx, [ebp+27h]
    cmp     byte ptr [edx+96h], 0FFh
    jnz     short loc_449559
    mov     ecx, [esp+0E4h+var_C0]
    test    ecx, ecx
    jnz     short loc_449559
    xor     ecx, ecx
    jmp     short loc_44955E
    ; ---------------------------------------------------------------------------

    loc_449559:                             ; CODE XREF: sub_448C70+8DBj
                                            ; sub_448C70+8E3j
    mov     ecx, 1

    loc_44955E:                             ; CODE XREF: sub_448C70+8E7j
    mov     esi, [esp+0E4h+var_C0]
    mov     edx, [eax+0C8h]
    mov     [eax+29h], cl
    xor     ecx, ecx
    test    esi, esi
    setz    cl
    and     ecx, 1
    and     edx, 0FFFFFFFEh
    or      ecx, edx
    mov     [eax+0C8h], ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+148DBh]
    mov     [eax+0BEh], edx
    mov     ecx, [ebp+27h]
    movzx   dx, byte ptr [ecx+96h]
    mov     [eax+0C6h], dx

    loc_4495A4:                             ; CODE XREF: sub_448C70+8CFj
    push    ebx
    lea     eax, [esp+0E8h+var_D4]
    push    offset aPlayerD                 ; "PLAYER%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [ebp+2Bh]
    lea     edx, [esp+0E4h+var_9C]
    push    1Eh                             ; size_t
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+0E4h+var_9C]
    lea     ecx, [esp+0E4h+var_D4]
    push    0
    push    eax
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4A0BF0
    lea     eax, [esp+0E4h+var_D4]
    push    0Eh
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A5D50
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+10h]
    mov     edx, [esp+24h]
    add     ecx, 519h
    push    edx
    push    eax
    push    ecx
    call    sub_4A1450
    push    ebx
    lea     edx, [esp+14h]
    push    offset aSideD                   ; "SIDE%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+10h]
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_49FF10
    mov     esi, eax
    test    esi, esi
    jz      loc_4496F5
    mov     edx, TAdynmemStructPtr
    mov     eax, ebx
    shl     eax, 5
    add     eax, ebx
    add     edx, ebx
    push    ebx
    push    offset aSideD                   ; "SIDE%d"
    lea     ecx, [eax+eax*4]
    lea     eax, [esp+70h]
    push    eax
    lea     edi, [edx+ecx*2+1B63h]
    call    _sprintf
    mov     eax, [edi]
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_449691
    mov     ecx, [edi+27h]
    test    byte ptr [ecx+9Bh], 40h
    jz      short loc_449691
    mov     eax, 2
    jmp     short loc_44969C
    ; ---------------------------------------------------------------------------

    loc_449691:                             ; CODE XREF: sub_448C70+A0Cj
                                            ; sub_448C70+A18j
    mov     edx, [edi+27h]
    xor     eax, eax
    mov     al, [edx+95h]

    loc_44969C:                             ; CODE XREF: sub_448C70+A1Fj
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char
    lea     eax, [esp+6Ch]
    add     ecx, 519h
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A1080
    mov     byte ptr [esi+29h], 1
    mov     eax, [ebp+0]
    test    eax, eax
    jz      short loc_4496D6
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_4496CA
    cmp     al, 2
    jnz     short loc_4496D6

    loc_4496CA:                             ; CODE XREF: sub_448C70+A54j
    mov     eax, [esp+24h]
    test    eax, eax
    jnz     short loc_4496D6
    xor     eax, eax
    jmp     short loc_4496DB
    ; ---------------------------------------------------------------------------

    loc_4496D6:                             ; CODE XREF: sub_448C70+A4Dj
                                            ; sub_448C70+A58j ...
    mov     eax, 1

    loc_4496DB:                             ; CODE XREF: sub_448C70+A64j
    push    eax
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+14h]
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4A1450
    mov     edi, [esp+0E8h+var_C0]

    loc_4496F5:                             ; CODE XREF: sub_448C70+9D6j
    push    ebx
    lea     ecx, [esp+14h]
    push    offset aAllyD                   ; "ALLY%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+10h]
    push    edx                             ; char *
    push    edi                             ; int
    call    sub_49FF10
    mov     esi, eax
    test    esi, esi
    jz      loc_4497CA
    mov     eax, [esp+0E8h+var_B8]
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+ebx+113h]
    mov     dl, [eax+ebx+108h]
    shl     ecx, 1
    or      ecx, edx
    lea     eax, [esp+10h]
    push    ecx                             ; char
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A1080
    mov     eax, [ebp+0]
    test    eax, eax
    jz      short loc_44978D
    cmp     byte ptr [ebp+73h], 1
    jz      short loc_4497A9
    test    eax, eax
    jz      short loc_44978D
    mov     edx, [ebp+27h]
    test    byte ptr [edx+9Bh], 40h
    jnz     short loc_4497A9
    test    eax, eax
    jz      short loc_44978D
    mov     cl, [ebp+73h]
    cmp     cl, 2
    jz      short loc_4497A9
    test    eax, eax
    jz      short loc_44978D
    mov     al, cl
    cmp     al, 3
    jnz     short loc_44978D
    mov     eax, edx
    cmp     byte ptr [eax+94h], 2
    jz      short loc_4497A9

    loc_44978D:                             ; CODE XREF: sub_448C70+AE4j
                                            ; sub_448C70+AEEj ...
    mov     eax, [esp+0E8h+var_AC]
    cmp     dword ptr [eax], 0
    jz      short loc_4497A2
    mov     ecx, [eax+27h]
    test    byte ptr [ecx+9Bh], 40h
    jnz     short loc_4497A9

    loc_4497A2:                             ; CODE XREF: sub_448C70+B24j
    mov     eax, 1
    jmp     short loc_4497AB
    ; ---------------------------------------------------------------------------

    loc_4497A9:                             ; CODE XREF: sub_448C70+AEAj
                                            ; sub_448C70+AFAj ...
    xor     eax, eax

    loc_4497AB:                             ; CODE XREF: sub_448C70+B37j
    mov     edx, [esp+24h]
    mov     [esi+29h], al
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+10h]
    push    edx
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_4A1450

    loc_4497CA:                             ; CODE XREF: sub_448C70+AA7j
    push    ebx
    lea     edx, [esp+14h]
    push    offset aTeamiconsD              ; "TEAMICONS%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+10h]
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_49FF10
    test    eax, eax
    jz      short loc_449843
    cmp     dword ptr [ebp+0], 0
    jz      short loc_4497FE
    mov     ecx, [ebp+27h]
    test    byte ptr [ecx+9Bh], 40h
    jnz     short loc_449805

    loc_4497FE:                             ; CODE XREF: sub_448C70+B80j
    mov     ecx, 1
    jmp     short loc_449807
    ; ---------------------------------------------------------------------------

    loc_449805:                             ; CODE XREF: sub_448C70+B8Cj
    xor     ecx, ecx

    loc_449807:                             ; CODE XREF: sub_448C70+B93j
    mov     [eax+29h], cl
    mov     eax, [ebp+0]
    test    eax, eax
    jz      short loc_449828
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_44981C
    cmp     al, 2
    jnz     short loc_449828

    loc_44981C:                             ; CODE XREF: sub_448C70+BA6j
    mov     eax, [esp+24h]
    test    eax, eax
    jnz     short loc_449828
    xor     eax, eax
    jmp     short loc_44982D
    ; ---------------------------------------------------------------------------

    loc_449828:                             ; CODE XREF: sub_448C70+B9Fj
                                            ; sub_448C70+BAAj ...
    mov     eax, 1

    loc_44982D:                             ; CODE XREF: sub_448C70+BB6j
    push    eax
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+14h]
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4A1450

    loc_449843:                             ; CODE XREF: sub_448C70+B7Aj
    push    ebx
    lea     ecx, [esp+14h]
    push    offset aResD                    ; "RES%d"
    push    ecx
    call    _sprintf
    mov     eax, [ebp+0]
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_44987B
    mov     cl, [ebp+73h]
    cmp     cl, 1
    jz      short loc_449897
    test    eax, eax
    jz      short loc_44987B
    mov     al, cl
    cmp     al, 3
    jnz     short loc_44987B
    mov     edx, [ebp+27h]
    cmp     byte ptr [edx+94h], 1
    jz      short loc_449897

    loc_44987B:                             ; CODE XREF: sub_448C70+BEBj
                                            ; sub_448C70+BF7j ...
    push    offset aNA_0                    ; "n/a"
    lea     eax, [esp+80h]
    push    offset aS_1                     ; "%s"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    jmp     short loc_4498C3
    ; ---------------------------------------------------------------------------

    loc_449897:                             ; CODE XREF: sub_448C70+BF3j
                                            ; sub_448C70+C09j
    mov     eax, [ebp+27h]
    xor     ecx, ecx
    xor     edx, edx
    mov     cx, [eax+8Dh]
    mov     dx, [eax+8Bh]
    push    ecx
    push    edx
    lea     eax, [esp+84h]
    push    offset aDxD                     ; "%dx%d"
    push    eax
    call    _sprintf
    add     esp, 10h

    loc_4498C3:                             ; CODE XREF: sub_448C70+C25j
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+7Ch]
    push    0
    lea     edx, [esp+14h]
    push    ecx
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4A0BF0
    cmp     dword ptr [ebp+0], 0
    jz      short loc_449907
    cmp     byte ptr [ebp+73h], 1
    jnz     short loc_449907
    mov     ecx, [esp+24h]
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+10h]
    push    ecx
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4A1450
    jmp     short loc_44991A
    ; ---------------------------------------------------------------------------

    loc_449907:                             ; CODE XREF: sub_448C70+C73j
                                            ; sub_448C70+C79j
    lea     ecx, [esp+10h]
    push    ecx                             ; char *
    push    edi                             ; int
    call    sub_4A0180
    test    eax, eax
    jz      short loc_44991A
    mov     byte ptr [eax+29h], 1

    loc_44991A:                             ; CODE XREF: sub_448C70+C95j
                                            ; sub_448C70+CA4j
    push    ebx
    lea     edx, [esp+14h]
    push    offset aPingD                   ; "PING%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+10h]
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_4A0180
    mov     esi, eax
    mov     eax, [ebp+0]
    test    eax, eax
    mov     [esp+0E8h+var_A8], esi
    jz      loc_4499F7
    cmp     byte ptr [ebp+73h], 3
    jnz     loc_4499F7
    mov     ecx, [ebp+27h]
    cmp     byte ptr [ecx+94h], 1
    jnz     loc_4499F7
    test    esi, esi
    jz      loc_449A1D
    mov     edx, [ebp+14h]
    lea     eax, [esi+0B6h]
    push    0Ah                             ; int
    push    eax                             ; char *
    push    edx                             ; int
    mov     [esp+0F4h+var_B0], eax
    call    __itoa
    add     esp, 0Ch
    call    sub_457A50
    test    eax, eax
    jz      short loc_4499E6
    mov     eax, [esp+0E8h+var_BC]
    push    eax                             ; int
    call    PlayerNumberToID
    mov     ecx, TAdynmemStructPtr
    push    eax
    mov     ecx, [ecx+2A30h]
    call    sub_46E0B0
    test    eax, eax
    mov     edi, offset aS_3                ; ":s"
    jnz     short loc_4499B7
    mov     edi, offset Data

    loc_4499B7:                             ; CODE XREF: sub_448C70+D40j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, [esp+0E8h+var_B0]
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [esp+0E8h+var_A8]
    mov     edi, [esp+0E8h+var_C0]

    loc_4499E6:                             ; CODE XREF: sub_448C70+D1Bj
    mov     eax, [ebp+14h]
    mov     ecx, [esp+0E8h+var_B4]
    cmp     ecx, eax
    jb      short loc_449A19
    mov     [esp+0E8h+var_B4], eax
    jmp     short loc_449A19
    ; ---------------------------------------------------------------------------

    loc_4499F7:                             ; CODE XREF: sub_448C70+CD3j
                                            ; sub_448C70+CDDj ...
    mov     ecx, TAdynmemStructPtr
    push    0
    lea     eax, [esp+14h]
    push    offset aNA_0                    ; "n/a"
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_4A0BF0
    test    esi, esi
    jz      short loc_449A1D

    loc_449A19:                             ; CODE XREF: sub_448C70+D7Fj
                                            ; sub_448C70+D85j
    mov     byte ptr [esi+29h], 1

    loc_449A1D:                             ; CODE XREF: sub_448C70+CF5j
                                            ; sub_448C70+DA7j
    push    ebx
    lea     edx, [esp+14h]
    push    offset aMemD                    ; "MEM%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+10h]
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_4A0180
    mov     esi, eax
    mov     eax, [ebp+0]
    test    eax, eax
    jz      short loc_449A62
    mov     cl, [ebp+73h]
    cmp     cl, 1
    jz      short loc_449A88
    test    eax, eax
    jz      short loc_449A62
    mov     al, cl
    cmp     al, 3
    jnz     short loc_449A62
    mov     ecx, [ebp+27h]
    cmp     byte ptr [ecx+94h], 1
    jz      short loc_449A88

    loc_449A62:                             ; CODE XREF: sub_448C70+DD2j
                                            ; sub_448C70+DDEj ...
    push    offset aNA_0                    ; "n/a"
    lea     edx, [esi+0B6h]
    push    offset aS_1                     ; "%s"
    push    edx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     ecx, [eax+391E9h]
    jmp     short loc_449AB5
    ; ---------------------------------------------------------------------------

    loc_449A88:                             ; CODE XREF: sub_448C70+DDAj
                                            ; sub_448C70+DF0j
    mov     edx, [ebp+27h]
    xor     eax, eax
    lea     ecx, [esi+0B6h]
    mov     ax, [edx+99h]
    push    eax
    push    offset aD_0                     ; "%d"
    push    ecx
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     ecx, [edx+391E9h]

    loc_449AB5:                             ; CODE XREF: sub_448C70+E16j
    call    sub_435920
    mov     ecx, [ebp+27h]
    xor     edx, edx
    push    ebx
    push    offset aReadyD                  ; "READY%d"
    mov     dx, [ecx+99h]
    xor     ecx, ecx
    cmp     edx, eax
    lea     edx, [esp+18h]
    setnl   cl
    dec     ecx
    push    edx
    and     ecx, 0Ch
    mov     byte ptr [esi+29h], 1
    mov     [esi+23h], ecx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+10h]
    push    eax                             ; char *
    push    edi                             ; int
    call    sub_49FF10
    test    eax, eax
    jz      short loc_449B54
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+0E8h+var_A4]
    mov     ecx, [ecx+edx+1B8Ah]
    mov     dl, [ecx+9Bh]
    mov     byte ptr [eax+29h], 1
    shr     dl, 5
    and     edx, 1
    mov     [eax+138h], dx
    mov     ecx, [ebp+0]
    test    ecx, ecx
    jz      short loc_449B36
    cmp     byte ptr [ebp+73h], 1
    jnz     short loc_449B36
    mov     esi, 1
    jmp     short loc_449B38
    ; ---------------------------------------------------------------------------

    loc_449B36:                             ; CODE XREF: sub_448C70+EB7j
                                            ; sub_448C70+EBDj
    xor     esi, esi

    loc_449B38:                             ; CODE XREF: sub_448C70+EC4j
    mov     cx, [eax+13Ch]
    xor     edx, edx
    test    esi, esi
    setz    dl
    xor     dl, cl
    and     edx, 1
    xor     edx, ecx
    mov     [eax+13Ch], dx

    loc_449B54:                             ; CODE XREF: sub_448C70+814j
                                            ; sub_448C70+82Ej ...
    mov     al, byte ptr [esp+0E8h+var_BC]
    inc     al
    cmp     al, 0Ah
    mov     byte ptr [esp+0E8h+var_BC], al
    jb      loc_4491F3
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90
    mov     ecx, [esp+0E8h+var_B8]
    mov     eax, [ecx+27h]
    test    byte ptr [eax+97h], 1
    jz      short loc_449BA3
    mov     ecx, [esp+0E8h+var_B4]
    xor     edx, edx
    mov     dx, [eax+9Fh]
    cmp     ecx, edx
    jnb     short loc_449BA3
    mov     [eax+9Fh], cx
    call    sub_451180

    loc_449BA3:                             ; CODE XREF: sub_448C70+F14j
                                            ; sub_448C70+F25j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D4h
    retn
    sub_448C70 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    Battleroom_Unknown1 proc near

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= byte ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch

    sub     esp, 28h
    push    ebx
    mov     eax, 3E8h
    push    ebp
    push    esi
    mov     [esp+34h+var_24], eax
    mov     dword ptr [esp+34h+var_28], eax
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     dword_512994, esi
    mov     dword_50550C, 0FFFFFFFFh
    or      byte ptr [eax+2BEEh], 1
    mov     edx, TAdynmemStructPtr
    push    edi
    mov     ecx, 0Bh
    xor     eax, eax
    lea     edi, [edx+2C28h]
    rep stosd
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     edi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ebp, [edi+eax*2+1B8Ah]
    lea     eax, [edi+eax*2]
    mov     [esp+38h+var_1C], eax
    mov     bl, [ebp+97h]
    mov     [edx+37EE8h], si
    and     ebx, 1
    cmp     bx, si
    jz      short loc_449C49
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37EECh]
    mov     [eax+37EEAh], cx

    loc_449C49:                             ; CODE XREF: Battleroom_Unknown1+84j
    mov     edx, TAdynmemStructPtr
    push    1
    mov     ax, [edx+37F1Bh]
    mov     [ebp+8Bh], ax
    mov     ecx, TAdynmemStructPtr
    mov     dx, [ecx+37F1Fh]
    mov     [ebp+8Dh], dx
    call    sub_41D6A0
    mov     cx, [ebp+9Dh]
    xor     edx, edx
    and     ecx, 0FFFBh
    push    esi
    test    al, al
    setnz   dl
    and     edx, 1
    push    offset aLounge2_gui             ; "LOUNGE2.GUI"
    shl     edx, 2
    or      ecx, edx
    mov     [ebp+9Dh], cx
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    push    0
    push    1
    push    0
    mov     dword ptr [esi+8], offset sub_447B10
    mov     ecx, TAdynmemStructPtr
    push    offset aBattleroom              ; "battleroom"
    mov     [esp+48h+var_20], esi
    mov     [esi+0Ch], ecx
    call    sub_4288D0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esi+4]
    push    3
    push    offset aMessage                 ; char *
    mov     eax, [edx+531h]
    movsx   edx, word ptr [ecx+0B6h]
    mov     edi, [eax+4]
    mov     dword_512764, edx
    push    edi                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_449D22
    lea     ecx, [eax+eax*4]
    lea     edx, [eax+ecx*4]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, edi
    add     ecx, eax
    mov     word ptr [ecx+edx*2+138h], 7Fh

    loc_449D22:                             ; CODE XREF: Battleroom_Unknown1+156j
    call    sub_457A50
    test    eax, eax
    jnz     short loc_449D71
    push    1
    push    offset off_505CF4               ; char *
    push    edi                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_449D71
    lea     edx, [eax+eax*4]
    push    0
    push    offset aViewMap                 ; "View Map"
    push    offset off_505CF4
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, edi
    add     edx, eax
    mov     dword ptr [edx+ecx*2+1Bh], 2
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A0BF0

    loc_449D71:                             ; CODE XREF: Battleroom_Unknown1+179j
                                            ; Battleroom_Unknown1+18Bj
    call    sub_45B660
    test    eax, eax
    jz      loc_449F49
    mov     eax, dword_512D6C
    test    eax, eax
    jz      short loc_449DA2
    mov     [ebp+0A5h], ax
    mov     ecx, TAdynmemStructPtr
    mov     dx, word ptr dword_512D6C
    mov     [ecx+37EEAh], dx

    loc_449DA2:                             ; CODE XREF: Battleroom_Unknown1+1D5j
    mov     esi, dword_512D68
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     ax, [ecx+2C74h]
    test    esi, esi
    setnz   dl
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [ecx+2C74h], dx
    mov     eax, dword_512D78
    test    eax, eax
    jz      short loc_449E35
    dec     eax
    test    eax, eax
    jl      short loc_449E35
    cmp     eax, 2
    jg      short loc_449E35
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+39229h], eax
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     [edx+37EF6h], eax
    mov     edx, TAdynmemStructPtr
    and     eax, 3
    mov     cl, [edx+2A42h]
    mov     esi, ecx
    shl     ecx, 5
    add     ecx, esi
    add     edx, esi
    shl     eax, 0Bh
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [edx+ecx*2+1B63h]
    mov     ecx, [ecx+27h]
    mov     dx, [ecx+9Bh]
    and     edx, 0E7FFh
    or      edx, eax
    mov     [ecx+9Bh], dx

    loc_449E35:                             ; CODE XREF: Battleroom_Unknown1+221j
                                            ; Battleroom_Unknown1+226j ...
    mov     eax, dword_512D70
    test    eax, eax
    jz      short loc_449E42
    mov     [esp+40h+var_2C], eax

    loc_449E42:                             ; CODE XREF: Battleroom_Unknown1+28Cj
    mov     eax, dword_512D74
    test    eax, eax
    jz      short loc_449E4F
    mov     [esp+40h+var_30], eax

    loc_449E4F:                             ; CODE XREF: Battleroom_Unknown1+299j
    mov     eax, dword_512D7C
    test    eax, eax
    jz      short loc_449E8B
    dec     eax
    jz      short loc_449E84
    dec     eax
    jz      short loc_449E6C
    dec     eax
    jnz     short loc_449E8B
    and     word ptr [ebp+9Bh], 0FDFFh
    jmp     short loc_449E8B
    ; ---------------------------------------------------------------------------

    loc_449E6C:                             ; CODE XREF: Battleroom_Unknown1+2ACj
    mov     ax, [ebp+9Bh]
    and     eax, 0FBFFh
    or      ah, 2
    mov     [ebp+9Bh], ax
    jmp     short loc_449E8B
    ; ---------------------------------------------------------------------------

    loc_449E84:                             ; CODE XREF: Battleroom_Unknown1+2A9j
    or      byte ptr [ebp+9Ch], 6

    loc_449E8B:                             ; CODE XREF: Battleroom_Unknown1+2A6j
                                            ; Battleroom_Unknown1+2AFj ...
    mov     eax, dword_512D80
    test    eax, eax
    jz      short loc_449EB8
    mov     dx, [ebp+9Bh]
    xor     ecx, ecx
    cmp     eax, 2
    setz    cl
    and     ecx, 1
    and     edx, 0DFFFh
    shl     ecx, 0Dh
    or      ecx, edx
    mov     [ebp+9Bh], cx

    loc_449EB8:                             ; CODE XREF: Battleroom_Unknown1+2E2j
    mov     eax, dword_512D84
    test    eax, eax
    jz      short loc_449EE5
    mov     dx, [ebp+9Bh]
    xor     ecx, ecx
    cmp     eax, 1
    setz    cl
    and     ecx, 1
    and     edx, 0BFFFh
    shl     ecx, 0Eh
    or      ecx, edx
    mov     [ebp+9Bh], cx

    loc_449EE5:                             ; CODE XREF: Battleroom_Unknown1+30Fj
    mov     eax, dword_512D88
    test    eax, eax
    jz      short loc_449F13
    mov     cx, [ebp+9Bh]
    xor     edx, edx
    and     ecx, 0FEFFh
    cmp     eax, 1
    setz    dl
    and     dl, 1
    xor     eax, eax
    mov     ah, dl
    or      ecx, eax
    mov     [ebp+9Bh], cx

    loc_449F13:                             ; CODE XREF: Battleroom_Unknown1+33Cj
    mov     eax, dword_512D8C
    test    eax, eax
    jz      loc_44A002
    mov     cx, [ebp+9Bh]
    xor     edx, edx
    and     ecx, 0FF7Fh
    cmp     eax, 2
    setz    dl
    and     edx, 1
    shl     edx, 7
    or      ecx, edx
    mov     [ebp+9Bh], cx
    jmp     loc_44A002
    ; ---------------------------------------------------------------------------

    loc_449F49:                             ; CODE XREF: Battleroom_Unknown1+1C8j
    test    bx, bx
    jz      loc_44A015
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ebp+9Bh]
    and     eax, 0FEFFh
    mov     dl, [ecx+3922Dh]
    xor     ecx, ecx
    and     dl, 1
    mov     ch, dl
    or      eax, ecx
    mov     [ebp+9Bh], ax
    mov     edx, TAdynmemStructPtr
    and     eax, 0FDFFh
    mov     cl, [edx+39231h]
    and     ecx, 1
    shl     ecx, 9
    or      eax, ecx
    mov     [ebp+9Bh], ax
    mov     edx, TAdynmemStructPtr
    and     eax, 0FBFFh
    mov     dl, byte ptr [edx+TAdynmemStruct.RenderingOptions]
    mov     ecx, eax
    and     edx, 1
    shl     edx, 0Ah
    or      ecx, edx
    mov     [ebp+9Bh], cx
    mov     eax, TAdynmemStructPtr
    and     ecx, 0BFFFh
    mov     edx, [eax+29A0h]
    mov     al, [edx+118h]
    and     eax, 1
    shl     eax, 0Eh
    or      eax, ecx
    mov     [ebp+9Bh], ax
    mov     ecx, TAdynmemStructPtr
    and     eax, 0E7FFh
    mov     dl, [ecx+39229h]
    and     edx, 3
    shl     edx, 0Bh
    or      eax, edx
    mov     [ebp+9Bh], ax

    loc_44A002:                             ; CODE XREF: Battleroom_Unknown1+36Aj
                                            ; Battleroom_Unknown1+394j
    test    bx, bx
    jz      short loc_44A015
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2C74h], 1
    jz      short loc_44A042

    loc_44A015:                             ; CODE XREF: Battleroom_Unknown1+39Cj
                                            ; Battleroom_Unknown1+455j
    mov     eax, off_505518
    mov     esi, offset off_505518
    test    eax, eax
    jz      short loc_44A042

    loc_44A023:                             ; CODE XREF: Battleroom_Unknown1+490j
    mov     ecx, TAdynmemStructPtr
    push    1                               ; char
    add     ecx, 519h
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A1250
    mov     eax, [esi+4]
    add     esi, 4
    test    eax, eax
    jnz     short loc_44A023

    loc_44A042:                             ; CODE XREF: Battleroom_Unknown1+463j
                                            ; Battleroom_Unknown1+471j
    call    sub_445ED0
    push    0A00h
    push    offset aLoungeChatter           ; "LOUNGE CHATTER"
    call    sub_4D83B0
    mov     edx, TAdynmemStructPtr
    add     esp, 8
    mov     [edx+2A9Bh], eax
    mov     eax, TAdynmemStructPtr
    push    offset aMemx                    ; char *
    mov     ecx, [eax+2A9Bh]
    mov     byte ptr [ecx], 0
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0180
    mov     edx, TAdynmemStructPtr
    mov     esi, eax
    mov     ecx, [edx+391E9h]
    call    sub_435920
    mov     ecx, [esp+40h+var_24]
    mov     edx, [ecx+1B8Ah]
    xor     ecx, ecx
    mov     cx, [edx+99h]
    xor     edx, edx
    cmp     ecx, eax
    setnl   dl
    dec     edx
    add     esi, 0B6h
    and     edx, 0Ch
    mov     [esi-93h], edx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     dx, [ecx+99h]
    push    edx
    push    offset aD_0                     ; "%d"
    push    esi
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    add     esp, 0Ch
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     al, [ecx+97h]
    and     eax, 1
    movsx   edx, ax
    push    edx
    mov     [esp+44h+var_20], eax
    call    sub_46C8E0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+2A30h]
    call    sub_46E000
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; int
    add     ecx, 519h
    push    offset aStart_0                 ; char *
    push    ecx                             ; int
    call    sub_4A0570
    test    bx, bx
    jz      short loc_44A189
    call    sub_456760
    test    eax, eax
    jz      short loc_44A189
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+2A30h]
    call    sub_46E000
    test    eax, eax
    jz      short loc_44A189
    xor     eax, eax
    jmp     short loc_44A18E
    ; ---------------------------------------------------------------------------

    loc_44A189:                             ; CODE XREF: Battleroom_Unknown1+5B5j
                                            ; Battleroom_Unknown1+5BEj ...
    mov     eax, 1

    loc_44A18E:                             ; CODE XREF: Battleroom_Unknown1+5D7j
    push    eax                             ; char
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    offset aStart_0                 ; char *
    push    eax                             ; int
    call    sub_4A1250
    mov     ecx, TAdynmemStructPtr
    push    0                               ; char
    add     ecx, 519h
    push    offset aRestrictions            ; char *
    push    ecx                             ; int
    call    sub_4A1250
    mov     eax, TAdynmemStructPtr
    push    0
    push    0
    mov     edx, [eax+2A9Bh]
    add     eax, 519h
    push    edx
    push    offset aOutput                  ; "OUTPUT"
    push    eax
    call    sub_4A32A0
    push    offset aOutput                  ; char *
    push    edi                             ; int
    call    sub_49FF90
    mov     ecx, [eax+1Bh]
    push    0
    or      ch, 1
    push    offset a0                       ; "0"
    mov     [eax+1Bh], ecx
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    offset aMetaltext               ; "METALTEXT"
    push    eax
    call    sub_4A0BF0
    mov     ecx, TAdynmemStructPtr
    push    0
    push    offset a0                       ; "0"
    add     ecx, 519h
    push    offset aEnergytext              ; "ENERGYTEXT"
    push    ecx
    call    sub_4A0BF0
    mov     edx, TAdynmemStructPtr
    push    0Eh
    push    offset aMetal_1                 ; char *
    mov     eax, [edx+531h]
    lea     esi, [edx+519h]
    mov     ebx, [eax+4]
    push    ebx                             ; int
    call    sub_49FDF0
    mov     edi, eax
    cmp     edi, 0FFFFFFFFh
    jz      short loc_44A296
    push    offset aMetal_1                 ; char *
    push    ebx                             ; int
    call    sub_4A0200
    mov     ebx, eax
    mov     eax, [esp+44h+var_34]
    movsx   ecx, ax
    push    ecx
    push    ebx
    mov     dword ptr [ebx+13Ch], 2711h
    mov     dword ptr [ebx+144h], offset sub_445C70
    mov     [ebx+140h], ax
    call    sub_45B9B0
    mov     edx, TAdynmemStructPtr
    mov     [ebx+14Ah], edx

    loc_44A296:                             ; CODE XREF: Battleroom_Unknown1+6A2j
    push    edi
    push    esi
    call    sub_445C70
    push    esi                             ; int
    call    sub_49FA90
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    push    0Eh
    push    offset aMaxunits_0              ; char *
    mov     ax, [ecx+37EEAh]
    lea     esi, [ecx+519h]
    add     eax, 0FFFFFFECh
    mov     dword ptr [esp+4Ch+var_28], eax
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    push    edi                             ; int
    call    sub_49FDF0
    mov     ebx, eax
    cmp     ebx, 0FFFFFFFFh
    jz      short loc_44A317
    push    offset aMaxunits_0              ; char *
    push    edi                             ; int
    call    sub_4A0200
    mov     edi, eax
    mov     eax, [esp+48h+var_2C]
    movsx   ecx, ax
    push    ecx
    push    edi
    mov     [edi+13Ch], eax
    mov     dword ptr [edi+144h], offset sub_445B70
    mov     [edi+140h], ax
    call    sub_45B9B0
    mov     edx, TAdynmemStructPtr
    mov     [edi+14Ah], edx

    loc_44A317:                             ; CODE XREF: Battleroom_Unknown1+727j
    push    ebx
    push    esi
    call    sub_445B70
    push    esi                             ; int
    call    sub_49FA90
    mov     edi, TAdynmemStructPtr
    mov     ebx, dword ptr [esp+48h+var_28]
    test    bx, bx
    jz      short loc_44A33C
    test    byte ptr [edi+2C74h], 1
    jz      short loc_44A385

    loc_44A33C:                             ; CODE XREF: Battleroom_Unknown1+781j
    push    1
    add     edi, 519h
    push    offset aMaxunits_0              ; "MAXUNITS"
    push    edi
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    offset aEnergy_1                ; "ENERGY"
    push    eax
    call    sub_4A1450
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    offset aMetal_1                 ; "METAL"
    push    ecx
    call    sub_4A1450
    mov     edi, TAdynmemStructPtr

    loc_44A385:                             ; CODE XREF: Battleroom_Unknown1+78Aj
    mov     edx, [edi+531h]
    add     edi, 519h
    push    0Eh
    push    offset aEnergy_1                ; char *
    mov     esi, [edx+4]
    push    esi                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_44A3E8
    push    offset aEnergy_1                ; char *
    push    esi                             ; int
    call    sub_4A0200
    mov     esi, eax
    mov     eax, [esp+4Ch+var_38]
    mov     [esi+140h], ax
    mov     dword ptr [esi+13Ch], 2711h
    movsx   eax, ax
    push    eax
    push    esi
    mov     dword ptr [esi+144h], offset sub_445D60
    call    sub_45B9B0
    mov     ecx, TAdynmemStructPtr
    mov     [esi+14Ah], ecx

    loc_44A3E8:                             ; CODE XREF: Battleroom_Unknown1+7F4j
    mov     edx, [edi+18h]
    push    offset aEnergy_1                ; char *
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_4A0200
    test    eax, eax
    jz      loc_44A492
    push    eax
    call    sub_45BA20
    mov     ecx, eax
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 5
    mov     ecx, edx
    push    0Ah                             ; int
    shr     ecx, 1Fh
    add     edx, ecx
    lea     eax, [edx+edx*4]
    lea     edx, [esp+50h+var_28]
    push    edx                             ; char *
    lea     esi, [eax+eax*4]
    shl     esi, 2
    push    esi                             ; int
    call    __itoa
    add     esp, 0Ch
    lea     eax, [esp+4Ch+var_28]
    push    0
    push    eax
    push    offset aEnergytext              ; "ENERGYTEXT"
    push    edi
    call    sub_4A0BF0
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     eax, 51EB851Fh
    imul    esi
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     al, [ecx+97h]
    test    al, 1
    mov     [ecx+0A1h], dx
    jz      short loc_44A492
    call    sub_450F90
    call    sub_451180

    loc_44A492:                             ; CODE XREF: Battleroom_Unknown1+84Bj
                                            ; Battleroom_Unknown1+8D6j
    push    edi                             ; int
    call    sub_49FA90
    mov     ecx, TAdynmemStructPtr
    push    1
    mov     ecx, [ecx+391E9h]
    call    sub_435D30
    test    bx, bx
    jz      short loc_44A4D8
    call    sub_45B660
    test    eax, eax
    jz      short loc_44A4D8
    mov     al, byte_512CE8
    test    al, al
    jz      short loc_44A4D8
    mov     edx, TAdynmemStructPtr
    push    offset byte_512CE8
    mov     ecx, [edx+391E9h]
    call    sub_435A20

    loc_44A4D8:                             ; CODE XREF: Battleroom_Unknown1+8FEj
                                            ; Battleroom_Unknown1+907j ...
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435C40
    test    al, al
    jnz     short loc_44A4F6
    push    offset aCouldNotFindTh          ; lpText
    call    sub_4B6290

    loc_44A4F6:                             ; CODE XREF: Battleroom_Unknown1+93Aj
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435C30
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_4373A0
    mov     [ebp+0A9h], eax
    call    sub_450F90
    mov     ecx, TAdynmemStructPtr
    push    0Eh
    push    offset aMessage                 ; char *
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A7190
    mov     eax, dword_5054B0
    mov     esi, offset dword_5054B0
    test    eax, eax
    jz      short loc_44A5B8

    loc_44A57E:                             ; CODE XREF: Battleroom_Unknown1+A04j
    mov     edi, [esp+50h+var_38]
    mov     edx, [esi]
    push    0Eh
    push    edx                             ; char *
    mov     eax, [edi+4]
    push    eax                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_44A5AC
    lea     ecx, [eax+eax*4]
    lea     edx, [eax+ecx*4]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, [edi+4]
    lea     eax, [eax+edx*2]
    mov     byte ptr [eax+ecx+29h], 0

    loc_44A5AC:                             ; CODE XREF: Battleroom_Unknown1+9E3j
    mov     eax, [esi+4]
    add     esi, 4
    test    eax, eax
    jnz     short loc_44A57E
    jmp     short loc_44A5BC
    ; ---------------------------------------------------------------------------

    loc_44A5B8:                             ; CODE XREF: Battleroom_Unknown1+9CCj
    mov     edi, [esp+50h+var_38]

    loc_44A5BC:                             ; CODE XREF: Battleroom_Unknown1+A06j
    call    sub_4455B0
    call    sub_446A50
    call    sub_448C70
    call    sub_428B60
    mov     edx, TAdynmemStructPtr
    push    offset aLounge2_gui             ; char *
    add     edx, 519h
    push    edx                             ; int
    call    sub_4AB060
    test    eax, eax
    jz      short loc_44A644
    mov     eax, [edi+4]
    push    offset aBattlestart             ; char *
    push    eax                             ; int
    call    sub_4A0280
    mov     ecx, [edi+4]
    push    offset aBattlestart             ; char *
    mov     esi, eax
    mov     edx, [ecx+0C0h]
    push    edx                             ; int
    call    sub_4B8D40
    mov     edi, [esi+0C8h]
    mov     [esi+0BEh], eax
    or      edi, 1
    mov     word ptr [esi+0C6h], 0
    mov     [esi+0C8h], edi
    mov     eax, TAdynmemStructPtr
    push    1                               ; int
    add     eax, 519h
    push    offset aBattlestart             ; char *
    push    eax                             ; int
    call    sub_4A0570

    loc_44A644:                             ; CODE XREF: Battleroom_Unknown1+A39j
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn
    Battleroom_Unknown1 endp ; sp = -18h

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    sub     esp, 180h
    mov     edx, [eax+38A47h]
    push    ebx
    push    ebp
    push    esi
    inc     edx
    push    edi
    mov     [eax+38A47h], edx
    call    Network_Process
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jnz     short loc_44A726
    mov     ecx, [eax+391E9h]
    call    sub_4358F0
    test    eax, eax
    jz      short loc_44A721
    call    sub_456850
    mov     edx, TAdynmemStructPtr
    xor     esi, esi
    xor     edi, edi
    cmp     al, 0Ah
    mov     [esp+14h], al
    jz      short loc_44A70A
    mov     eax, [esp+14h]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    mov     esi, [esi+ecx*2+1B8Ah]
    mov     al, [esi+0A7h]
    cmp     al, 2
    jnb     short loc_44A705
    cmp     al, 1
    jnz     short loc_44A70A
    cmp     byte ptr [esi+0A8h], 2
    jb      short loc_44A70A

    loc_44A705:                             ; CODE XREF: .text:0044A6F6j
    mov     edi, 1

    loc_44A70A:                             ; CODE XREF: .text:0044A6CEj
                                            ; .text:0044A6FAj ...
    test    edi, edi
    jz      short loc_44A733
    mov     ecx, [edx+391E9h]
    call    sub_4373A0
    cmp     eax, [esi+0A9h]
    jz      short loc_44A72D

    loc_44A721:                             ; CODE XREF: .text:0044A6B7j
    mov     eax, TAdynmemStructPtr

    loc_44A726:                             ; CODE XREF: .text:0044A6A8j
    or      byte ptr [eax+2BEEh], 1

    loc_44A72D:                             ; CODE XREF: .text:0044A71Fj
    mov     edx, TAdynmemStructPtr

    loc_44A733:                             ; CODE XREF: .text:0044A70Cj
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ebp, [esi+eax*2+1B63h]
    mov     [esp+14h], ebp
    mov     al, [ebp+22h]
    test    al, al
    jz      short loc_44A77F
    mov     byte ptr [edx+2BC0h], 3
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A9660
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 180h
    retn
    ; ---------------------------------------------------------------------------

    loc_44A77F:                             ; CODE XREF: .text:0044A759j
    mov     eax, [edx+531h]
    add     edx, 519h
    push    offset aLounge2_gui             ; "LOUNGE2.GUI"
    push    edx
    mov     ebx, [eax+4]
    mov     [esp+20h], ebx
    call    sub_4AB060
    test    eax, eax
    jz      short loc_44A7C6
    push    0Eh
    push    offset aPlayer0                 ; "PLAYER0"
    push    ebx
    call    sub_49FDF0
    lea     ecx, [eax+eax*4]
    lea     edx, [eax+ecx*4]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebx
    add     ecx, eax
    mov     dword ptr [ecx+edx*2+1Fh], 18h

    loc_44A7C6:                             ; CODE XREF: .text:0044A79Fj
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+2BEEh], 1
    jz      loc_44AE15
    mov     eax, dword_512994
    test    eax, eax
    jnz     short loc_44A7EC
    call    sub_4455B0
    jmp     loc_44A933
    ; ---------------------------------------------------------------------------

    loc_44A7EC:                             ; CODE XREF: .text:0044A7E0j
    lea     ecx, [edx+1B63h]
    lea     ebp, [edx+1CAEh]
    add     edx, 2851h
    mov     [esp+10h], ecx
    mov     [esp+1Ch], edx

    loc_44A806:                             ; CODE XREF: .text:0044A926j
    cmp     ebp, edx
    jb      short loc_44A812
    cmp     ecx, edx
    jnb     loc_44A92B

    loc_44A812:                             ; CODE XREF: .text:0044A808j
                                            ; .text:0044A83Fj
    cmp     dword ptr [ecx], 0
    jz      short loc_44A82F
    mov     al, [ecx+73h]
    cmp     al, 1
    jz      short loc_44A826
    cmp     al, 2
    jz      short loc_44A826
    cmp     al, 3
    jnz     short loc_44A82F

    loc_44A826:                             ; CODE XREF: .text:0044A81Cj
                                            ; .text:0044A820j
    cmp     byte ptr [ecx+146h], 0Ah
    jnz     short loc_44A835

    loc_44A82F:                             ; CODE XREF: .text:0044A815j
                                            ; .text:0044A824j
    cmp     byte ptr [ecx+73h], 4
    jnz     short loc_44A841

    loc_44A835:                             ; CODE XREF: .text:0044A82Dj
    cmp     ecx, edx
    jnb     short loc_44A841
    add     ecx, 14Bh
    jmp     short loc_44A812
    ; ---------------------------------------------------------------------------

    loc_44A841:                             ; CODE XREF: .text:0044A833j
                                            ; .text:0044A837j
    mov     [esp+10h], ecx
    lea     ebp, [ecx+14Bh]

    loc_44A84B:                             ; CODE XREF: .text:0044A877j
    cmp     dword ptr [ebp+0], 0
    jz      short loc_44A869
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_44A860
    cmp     al, 2
    jz      short loc_44A860
    cmp     al, 3
    jnz     short loc_44A869

    loc_44A860:                             ; CODE XREF: .text:0044A856j
                                            ; .text:0044A85Aj
    cmp     byte ptr [ebp+146h], 0Ah
    jnz     short loc_44A879

    loc_44A869:                             ; CODE XREF: .text:0044A84Fj
                                            ; .text:0044A85Ej
    cmp     ebp, edx
    jnb     loc_44A92B
    add     ebp, 14Bh
    jmp     short loc_44A84B
    ; ---------------------------------------------------------------------------

    loc_44A879:                             ; CODE XREF: .text:0044A867j
    cmp     ebp, edx
    jnb     loc_44A92B
    cmp     ecx, edx
    jnb     loc_44A92B
    mov     eax, [esp+10h]
    mov     ecx, 52h
    mov     esi, eax
    lea     edi, [esp+44h]
    rep movsd
    movsw
    movsb
    mov     ecx, 52h
    mov     esi, ebp
    mov     edi, eax
    push    0
    rep movsd
    movsw
    movsb
    mov     ecx, 52h
    lea     esi, [esp+48h]
    mov     edi, ebp
    rep movsd
    movsw
    mov     ecx, ebp
    movsb
    call    sub_463C60
    xor     ebx, ebx
    mov     dword ptr [ebp+0], 0
    xor     eax, eax

    loc_44A8CF:                             ; CODE XREF: .text:0044A91Cj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+eax+1B63h]
    test    edx, edx
    jz      short loc_44A909
    mov     dl, [ecx+eax+1BD6h]
    cmp     dl, 1
    jz      short loc_44A8F6
    cmp     dl, 2
    jz      short loc_44A8F6
    cmp     dl, 3
    jnz     short loc_44A909

    loc_44A8F6:                             ; CODE XREF: .text:0044A8EAj
                                            ; .text:0044A8EFj
    cmp     byte ptr [ecx+eax+1CA9h], 0Ah
    jz      short loc_44A909
    mov     [ecx+eax+1CA9h], bl
    jmp     short loc_44A911
    ; ---------------------------------------------------------------------------

    loc_44A909:                             ; CODE XREF: .text:0044A8DEj
                                            ; .text:0044A8F4j ...
    mov     byte ptr [ecx+eax+1CA9h], 0Ah

    loc_44A911:                             ; CODE XREF: .text:0044A907j
    add     eax, 14Bh
    inc     ebx
    cmp     eax, 0CEEh
    jle     short loc_44A8CF
    mov     edx, [esp+1Ch]
    mov     ecx, [esp+10h]
    jmp     loc_44A806
    ; ---------------------------------------------------------------------------

    loc_44A92B:                             ; CODE XREF: .text:0044A80Cj
                                            ; .text:0044A86Bj ...
    mov     ebx, [esp+18h]
    mov     ebp, [esp+14h]

    loc_44A933:                             ; CODE XREF: .text:0044A7E7j
    mov     edx, TAdynmemStructPtr
    mov     ecx, dword_50550C
    xor     eax, eax
    mov     ax, [edx+TAdynmemStruct.LOS_Radar]
    cmp     eax, ecx
    jz      short loc_44A956
    mov     dword_50550C, eax
    call    sub_451180

    loc_44A956:                             ; CODE XREF: .text:0044A94Aj
    mov     eax, [ebp+27h]
    test    byte ptr [eax+97h], 1
    jnz     loc_44ABF8
    call    sub_456850
    cmp     al, 0Ah
    mov     [esp+10h], al
    jz      loc_44ABF8
    mov     ecx, TAdynmemStructPtr
    push    offset aLounge2_gui             ; "LOUNGE2.GUI"
    add     ecx, 519h
    push    ecx
    call    sub_4AB060
    test    eax, eax
    jz      loc_44AB50
    mov     eax, [esp+10h]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    lea     esi, [eax+edx*2]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+esi+1B8Ah]
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435A20
    mov     eax, TAdynmemStructPtr
    xor     edi, edi
    push    offset aMaxunits_0              ; "MAXUNITS"
    mov     edx, [eax+esi+1B8Ah]
    mov     eax, [eax+531h]
    mov     ecx, [eax+4]
    mov     di, [edx+0A5h]
    push    ecx
    sub     edi, 14h
    call    sub_4A0200
    push    edi
    push    eax
    call    sub_45B9B0
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    push    offset aMetal_1                 ; "METAL"
    mov     edx, [ecx+esi+1B8Ah]
    mov     ax, [edx+0A3h]
    lea     eax, [eax+eax*4]
    lea     edi, [eax+eax*4]
    mov     eax, [ecx+531h]
    shl     edi, 2
    mov     ecx, [eax+4]
    push    ecx
    call    sub_4A0200
    push    edi
    push    eax
    call    sub_45B9B0
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    push    offset aEnergy_1                ; "ENERGY"
    mov     edx, [ecx+esi+1B8Ah]
    mov     ax, [edx+0A1h]
    lea     eax, [eax+eax*4]
    lea     esi, [eax+eax*4]
    mov     eax, [ecx+531h]
    shl     esi, 2
    mov     ecx, [eax+4]
    push    ecx
    call    sub_4A0200
    push    esi
    push    eax
    call    sub_45B9B0
    mov     edx, TAdynmemStructPtr
    push    0
    add     edx, 519h
    push    edx
    call    sub_445B70
    mov     eax, TAdynmemStructPtr
    push    offset aEnergy_1                ; "ENERGY"
    mov     ecx, [eax+531h]
    lea     edi, [eax+519h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_4A0200
    test    eax, eax
    jz      loc_44AB37
    push    eax
    call    sub_45BA20
    mov     ecx, eax
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    lea     ecx, [esp+20h]
    shr     eax, 1Fh
    add     edx, eax
    push    0Ah
    push    ecx
    lea     eax, [edx+edx*4]
    lea     esi, [eax+eax*4]
    shl     esi, 2
    push    esi
    call    __itoa
    add     esp, 0Ch
    lea     edx, [esp+20h]
    push    0
    push    edx
    push    offset aEnergytext              ; "ENERGYTEXT"
    push    edi
    call    sub_4A0BF0
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    mov     eax, 51EB851Fh
    imul    esi
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     al, [ecx+97h]
    test    al, 1
    mov     [ecx+0A1h], dx
    jz      short loc_44AB37
    call    sub_450F90
    call    sub_451180

    loc_44AB37:                             ; CODE XREF: .text:0044AAA0j
                                            ; .text:0044AB2Bj
    mov     ecx, TAdynmemStructPtr
    push    0
    add     ecx, 519h
    push    ecx
    call    sub_445C70
    jmp     loc_44ABF8
    ; ---------------------------------------------------------------------------

    loc_44AB50:                             ; CODE XREF: .text:0044A990j
    mov     edx, TAdynmemStructPtr
    push    offset aViewmap_gui_0           ; "viewmap.gui"
    add     edx, 519h
    push    edx
    call    sub_4AB060
    test    eax, eax
    jz      loc_44ABF8
    mov     eax, [esp+10h]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     edi, [eax+ecx*2]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    mov     esi, [eax+edi+1B8Ah]
    call    sub_435C30

    loc_44AB9C:                             ; CODE XREF: .text:0044ABBAj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_44ABC0
    test    cl, cl
    jz      short loc_44ABBC
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_44ABC0
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_44AB9C

    loc_44ABBC:                             ; CODE XREF: .text:0044ABA6j
    xor     eax, eax
    jmp     short loc_44ABC5
    ; ---------------------------------------------------------------------------

    loc_44ABC0:                             ; CODE XREF: .text:0044ABA2j
                                            ; .text:0044ABB0j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_44ABC5:                             ; CODE XREF: .text:0044ABBEj
    test    eax, eax
    jz      short loc_44ABF8
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+edi+1B8Ah]
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435A20
    call    sub_444A20
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FAD0

    loc_44ABF8:                             ; CODE XREF: .text:0044A960j
                                            ; .text:0044A971j ...
    mov     eax, TAdynmemStructPtr
    push    offset aLounge2_gui             ; "LOUNGE2.GUI"
    and     word ptr [eax+2BEEh], 0FFFEh
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AB060
    test    eax, eax
    jz      loc_44AE15
    mov     ecx, [ebp+27h]
    test    byte ptr [ecx+97h], 1
    jz      loc_44AE00
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+2A30h]
    call    sub_46E000
    mov     edi, eax
    call    sub_456760
    mov     ebp, eax
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    offset aSynching                ; "SYNCHING"
    push    eax
    call    sub_4A1250
    mov     ecx, TAdynmemStructPtr
    push    offset aBattlestart             ; "battlestart"
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax
    call    sub_4A0280
    mov     esi, eax
    cmp     word ptr [esi+0C6h], 0
    jle     short loc_44ACF2
    call    sub_4B6340
    cmp     dword_5129A4, eax
    jge     short loc_44ACF2
    mov     ax, [esi+0C6h]
    cmp     ax, 8
    jge     short loc_44ACCA
    inc     eax
    mov     [esi+0C6h], ax
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2BEEh], 1

    loc_44ACCA:                             ; CODE XREF: .text:0044ACA2j
    mov     edx, dword_5129A4
    mov     eax, 4
    add     edx, eax
    mov     dword_5129A4, edx
    cmp     [esi+0C6h], ax
    jnz     short loc_44ACF2
    push    0
    push    offset aPanel                   ; "Panel"
    call    sub_47F1A0

    loc_44ACF2:                             ; CODE XREF: .text:0044AC88j
                                            ; .text:0044AC95j ...
    mov     ax, [esi+0C6h]
    test    ax, ax
    jz      short loc_44AD1D
    mov     edx, [esi+0BEh]
    xor     ecx, ecx
    mov     cx, [edx]
    movsx   edx, ax
    dec     ecx
    cmp     edx, ecx
    jge     short loc_44AD1D
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2BEEh], 1

    loc_44AD1D:                             ; CODE XREF: .text:0044ACFCj
                                            ; .text:0044AD0Fj
    test    ebp, ebp
    jz      loc_44ADAC
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2BEEh], 1
    cmp     word ptr [esi+0C6h], 0
    jnz     short loc_44AD5A
    mov     word ptr [esi+0C6h], 1
    call    sub_4B6340
    push    0
    push    offset aOptions                 ; "Options"
    mov     dword_5129A4, eax
    call    sub_47F1A0

    loc_44AD5A:                             ; CODE XREF: .text:0044AD39j
    mov     edx, [esi+0C8h]
    push    1
    and     edx, 0FFFFFFFEh
    push    offset aStart_0                 ; "START"
    push    ebx
    mov     [esi+0C8h], edx
    call    sub_49FDF0
    mov     esi, eax
    call    sub_4B6340
    lea     ecx, [esi+esi*4]
    add     ebx, esi
    and     eax, 1Fh
    lea     edx, [esi+ecx*4]
    lea     ecx, [esi+edx*2]
    lea     edx, [esi+ecx*4]
    lea     ecx, [ebx+edx*2+1Fh]
    mov     edx, [ebx+edx*2+1Fh]
    cmp     eax, edx
    jz      short loc_44ADAC
    mov     [ecx], eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA90

    loc_44ADAC:                             ; CODE XREF: .text:0044AD1Fj
                                            ; .text:0044AD98j
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    test    ebp, ebp
    setz    cl
    push    ecx
    add     edx, 519h
    push    offset aStart_0                 ; "START"
    push    edx
    call    sub_4A1250
    mov     eax, TAdynmemStructPtr
    push    edi
    add     eax, 519h
    push    offset aStart_0                 ; "START"
    push    eax
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    test    edi, edi
    setz    cl
    push    ecx
    add     edx, 519h
    push    offset aSynching                ; "SYNCHING"
    push    edx
    call    sub_4A0570

    loc_44AE00:                             ; CODE XREF: .text:0044AC2Dj
    call    sub_448C70
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA90

    loc_44AE15:                             ; CODE XREF: .text:0044A7D3j
                                            ; .text:0044AC1Dj
    mov     ecx, TAdynmemStructPtr
    push    offset aLounge2_gui             ; "LOUNGE2.GUI"
    add     ecx, 519h
    push    ecx
    call    sub_4AB060
    test    eax, eax
    jz      loc_44AF38
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_4A5D30
    xor     edi, edi
    xor     ebp, ebp
    mov     ebx, 0Ah

    loc_44AE51:                             ; CODE XREF: .text:0044AF1Ej
    mov     eax, TAdynmemStructPtr
    lea     esi, [eax+ebp+1B63h]
    mov     al, [eax+ebp+1BD6h]
    test    al, al
    jz      loc_44AF16
    cmp     al, 4
    jz      loc_44AF16
    push    edi
    lea     ecx, [esp+24h]
    push    offset aLogoI                   ; "LOGO%i"
    push    ecx
    call    _sprintf
    mov     eax, [esp+24h]
    add     esp, 0Ch
    lea     edx, [esp+20h]
    push    0Eh
    push    edx
    push    eax
    call    sub_49FDF0
    lea     ecx, [esp+34h]
    mov     edx, [esp+18h]
    push    ecx
    push    eax
    push    edx
    call    sub_4A15C0
    mov     eax, [esi+27h]
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+0A8h]
    mov     dl, [eax+0A7h]
    push    ecx
    push    edx
    lea     eax, [esp+28h]
    push    offset aI_I                     ; "%i.%i"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+20h]
    push    ecx
    call    sub_4A5030
    mov     esi, eax
    call    sub_4A50B0
    mov     edx, [esp+40h]
    mov     ecx, eax
    mov     eax, [esp+38h]
    push    0
    add     eax, edx
    push    esi
    sub     eax, ecx
    mov     ecx, [esp+3Ch]
    cdq
    sub     eax, edx
    mov     edx, [esp+44h]
    sar     eax, 1
    push    eax
    lea     eax, [ecx+edx]
    sub     eax, esi
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    lea     eax, [esp+30h]
    push    eax
    push    0
    call    sub_4A50E0

    loc_44AF16:                             ; CODE XREF: .text:0044AE66j
                                            ; .text:0044AE6Ej
    inc     edi
    add     ebp, 14Bh
    dec     ebx
    jnz     loc_44AE51
    mov     ecx, TAdynmemStructPtr
    push    0
    add     ecx, 519h
    push    ecx
    call    sub_4A5D30

    loc_44AF38:                             ; CODE XREF: .text:0044AE2Ej
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+2A30h]
    call    sub_46DAD0
    call    sub_4B6340
    cmp     dword_5129A8, eax
    jnb     short loc_44AF99
    call    sub_4B6340
    add     eax, 3Ch
    push    1
    mov     dword_5129A8, eax
    call    sub_41D6A0
    xor     ebx, ebx
    mov     ecx, [esp+14h]
    mov     ecx, [ecx+27h]
    mov     dx, [ecx+9Dh]
    and     edx, 0FFFBh
    test    al, al
    setnz   bl
    and     ebx, 1
    shl     ebx, 2
    or      edx, ebx
    mov     [ecx+9Dh], dx
    call    sub_456310

    loc_44AF99:                             ; CODE XREF: .text:0044AF54j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 180h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    loc_44AFB0:                             ; DATA XREF: .text:0044B093o
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_44AFD7
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2BEEh]
    shr     cl, 4
    test    cl, 1
    jz      short loc_44B014
    call    sub_450E20
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44AFD7:                             ; CODE XREF: .text:0044AFB9j
    push    offset byte_502AE8
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_44B00E
    push    0
    push    offset aBigbutton               ; "BigButton"
    call    sub_47F1A0
    push    offset aCCavedogWarg_2          ; "c:\\cavedog\\wargame\\multi.cpp"
    push    1412h
    push    2
    call    sub_425860
    push    1
    call    sub_490B30
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44B00E:                             ; CODE XREF: .text:0044AFE4j
    push    esi
    call    sub_4AB0A0

    loc_44B014:                             ; CODE XREF: .text:0044AFCCj
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 400h
    push    esi
    call    sub_4257A0
    lea     eax, [esp+4]
    push    eax
    push    offset aMission02winbw          ; "Mission02WinBW"
    call    sub_429290
    push    100h
    lea     ecx, [esp+8]
    push    0
    push    ecx
    mov     esi, eax
    call    sub_4BA200
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C69A0
    push    0
    push    0
    push    esi
    push    0
    call    sub_4C6B70
    push    esi
    call    sub_4C6AC0
    call    sub_4C63A0
    mov     ecx, TAdynmemStructPtr
    push    80h
    add     ecx, 519h
    push    offset aEndmulti_gui            ; "ENDMULTI.GUI"
    push    ecx
    call    sub_4AA8F0
    mov     dword ptr [eax+8], offset loc_44AFB0
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+3923Bh]
    shr     al, 4
    test    al, 1
    mov     eax, offset aVictory_0          ; "Victory"
    jnz     short loc_44B0B7
    mov     eax, offset aFailure            ; "Failure"

    loc_44B0B7:                             ; CODE XREF: .text:0044B0B0j
    push    0
    push    eax
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    offset aResult                  ; "RESULT"
    push    ecx
    call    sub_4A0BF0
    mov     edx, TAdynmemStructPtr
    push    0C0h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    call    sub_4C2870
    pop     esi
    add     esp, 400h
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, dword_5129AC
    test    eax, eax
    jz      short loc_44B112
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_44B112:                             ; CODE XREF: .text:0044B107j
    mov     eax, dword_5129B0
    test    eax, eax
    jz      short loc_44B124
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_44B124:                             ; CODE XREF: .text:0044B119j
    mov     dword_5129B0, 0
    mov     dword_5129AC, 0
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44B140 proc near                    ; CODE XREF: .text:0044B484p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    sub     esp, 8
    push    ebx
    push    ebp
    push    offset aRb                      ; "rb"
    push    eax
    call    _fopen
    add     esp, 8
    mov     ebx, eax
    lea     ecx, [esp+10h+arg_0]
    push    ebx
    push    1
    push    4
    push    ecx
    call    sub_4E5BC0
    mov     eax, [esp+20h+arg_0]
    add     esp, 10h
    xor     ebp, ebp
    test    eax, eax
    jle     loc_44B211
    push    edi
    push    esi

    loc_44B17B:                             ; CODE XREF: sub_44B140+C9j
    push    ebx
    push    1
    lea     edx, [esp+20h+var_8]
    push    4
    push    edx
    call    sub_4E5BC0
    add     esp, 10h
    lea     eax, [esp+18h+var_4]
    push    ebx
    push    1
    push    4
    push    eax
    call    sub_4E5BC0
    mov     ecx, TAdynmemStructPtr
    mov     edx, 1
    add     esp, 10h
    mov     eax, [ecx+1438Fh]
    cmp     eax, edx
    jle     short loc_44B202
    mov     ecx, [ecx+1439Bh]
    mov     esi, [esp+18h+var_8]
    add     ecx, 387h

    loc_44B1C4:                             ; CODE XREF: sub_44B140+91j
    cmp     [ecx], esi
    jz      short loc_44B1D5
    inc     edx
    add     ecx, 249h
    cmp     edx, eax
    jl      short loc_44B1C4
    jmp     short loc_44B202
    ; ---------------------------------------------------------------------------

    loc_44B1D5:                             ; CODE XREF: sub_44B140+86j
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_44B202
    mov     edi, dword_5129B4
    lea     esi, [edi+52h]

    loc_44B1E4:                             ; CODE XREF: sub_44B140+AEj
    cmp     [esi], edx
    jz      short loc_44B1F2
    inc     ecx
    add     esi, 62h
    cmp     ecx, eax
    jl      short loc_44B1E4
    jmp     short loc_44B202
    ; ---------------------------------------------------------------------------

    loc_44B1F2:                             ; CODE XREF: sub_44B140+A6j
    mov     eax, [esp+18h+var_4]
    lea     edx, [ecx+ecx*2]
    shl     edx, 4
    add     edx, ecx
    mov     [edi+edx*2+5Ah], eax

    loc_44B202:                             ; CODE XREF: sub_44B140+72j
                                            ; sub_44B140+93j ...
    mov     eax, [esp+18h+arg_0]
    inc     ebp
    cmp     ebp, eax
    jl      loc_44B17B
    pop     esi
    pop     edi

    loc_44B211:                             ; CODE XREF: sub_44B140+33j
    push    ebx
    call    _fclose
    add     esp, 4
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_44B140 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44B230 proc near                    ; CODE XREF: sub_44B690+2E7p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    ebp
    push    edi
    push    offset aWb_0                    ; "wb+"
    push    eax
    call    _fopen
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     edi, eax
    lea     eax, [esp+0Ch+arg_0]
    mov     edx, [ecx+1438Fh]
    push    edi
    push    1
    dec     edx
    push    4
    push    eax
    mov     [esp+1Ch+arg_0], edx
    call    sub_4E5D40
    mov     eax, [esp+1Ch+arg_0]
    add     esp, 10h
    inc     eax
    mov     ebp, 1
    cmp     eax, ebp
    mov     [esp+0Ch+arg_0], eax
    jle     loc_44B315
    mov     edx, TAdynmemStructPtr
    push    esi
    push    ebx
    mov     ebx, 249h

    loc_44B28D:                             ; CODE XREF: sub_44B230+DDj
    mov     ecx, [edx+1438Fh]
    xor     esi, esi
    test    ecx, ecx
    jle     short loc_44B300
    mov     eax, dword_5129B4
    add     eax, 52h

    loc_44B2A1:                             ; CODE XREF: sub_44B230+7Bj
    cmp     [eax], ebp
    jz      short loc_44B2AF
    inc     esi
    add     eax, 62h
    cmp     esi, ecx
    jl      short loc_44B2A1
    jmp     short loc_44B300
    ; ---------------------------------------------------------------------------

    loc_44B2AF:                             ; CODE XREF: sub_44B230+73j
    mov     ecx, [edx+1439Bh]
    push    edi
    push    1
    lea     eax, [esp+1Ch+var_4]
    mov     edx, [ecx+ebx+13Eh]
    push    4
    push    eax
    mov     [esp+24h+var_4], edx
    call    sub_4E5D40
    mov     edx, dword_5129B4
    lea     ecx, [esi+esi*2]
    shl     ecx, 4
    add     esp, 10h
    add     ecx, esi
    mov     eax, [edx+ecx*2+5Ah]
    push    edi
    push    1
    lea     ecx, [esp+1Ch+var_4]
    push    4
    push    ecx
    mov     [esp+24h+var_4], eax
    call    sub_4E5D40
    mov     edx, TAdynmemStructPtr
    add     esp, 10h

    loc_44B300:                             ; CODE XREF: sub_44B230+67j
                                            ; sub_44B230+7Dj
    mov     eax, [esp+14h+arg_0]
    inc     ebp
    add     ebx, 249h
    cmp     ebp, eax
    jl      loc_44B28D
    pop     ebx
    pop     esi

    loc_44B315:                             ; CODE XREF: sub_44B230+4Aj
    push    edi
    call    _fclose
    add     esp, 4
    pop     edi
    pop     ebp
    pop     ecx
    retn    4
    sub_44B230 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    lea     ebx, [eax+519h]
    mov     eax, [eax+531h]
    push    offset aGames_0                 ; "GAMES"
    mov     esi, [eax+4]
    push    esi
    call    sub_49FF90
    push    3
    push    offset aGamename                ; "GAMENAME"
    push    esi
    mov     edi, eax
    call    sub_49FDF0
    mov     esi, eax
    mov     ax, [edi+0BAh]
    cmp     ax, 0FFFFh
    jle     short loc_44B397
    mov     edx, dword_5129B0
    movsx   ecx, ax
    push    ecx
    push    edx
    call    sub_4B6AF0
    mov     edx, eax
    test    edx, edx
    jz      short loc_44B397
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_44B397
    push    edx
    jmp     short loc_44B39C
    ; ---------------------------------------------------------------------------

    loc_44B397:                             ; CODE XREF: .text:0044B36Ej
                                            ; .text:0044B384j ...
    push    offset Data

    loc_44B39C:                             ; CODE XREF: .text:0044B395j
    push    esi
    push    ebx
    call    sub_4A0880
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA90
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    loc_44B3C0:                             ; DATA XREF: sub_44BC10+26o
    push    esi
    mov     esi, [esp+8]
    push    edi
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      loc_44B4D4
    push    offset aCancel_0                ; "CANCEL"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_44B3F8
    push    0
    push    offset aPrevious                ; "Previous"
    call    sub_47F1A0
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44B3F8:                             ; CODE XREF: .text:0044B3E5j
    push    offset aLoad                    ; "LOAD"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_44B42B
    push    offset aGames_0                 ; "GAMES"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_44B42B
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      loc_44B4D4
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44B42B:                             ; CODE XREF: .text:0044B405j
                                            ; .text:0044B414j
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    push    offset aGames_0                 ; "GAMES"
    push    edi
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, dword_5129AC
    push    ecx
    push    edx
    call    sub_4B6AF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    mov     eax, dword_5091C8
    add     ecx, 38C6Bh
    push    eax
    push    offset aSS                      ; "%s\\%s"
    push    ecx
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    add     edx, 38C6Bh
    push    edx
    call    sub_44B140
    mov     edi, [esi+18h]
    push    0
    push    esi
    mov     eax, [edi]
    mov     [esi+18h], eax
    call    sub_44BFD0
    mov     [esi+18h], edi
    mov     eax, dword_5129AC
    test    eax, eax
    jz      short loc_44B4AE
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_44B4AE:                             ; CODE XREF: .text:0044B4A3j
    mov     eax, dword_5129B0
    test    eax, eax
    jz      short loc_44B4C0
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_44B4C0:                             ; CODE XREF: .text:0044B4B5j
    mov     dword_5129B0, 0
    mov     dword_5129AC, 0

    loc_44B4D4:                             ; CODE XREF: .text:0044B3D2j
                                            ; .text:0044B41Aj
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44B4E0 proc near                    ; CODE XREF: sub_44B690+104p
                                            ; sub_44B990+58p ...

    var_100= dword ptr -100h
    arg_0= dword ptr  4

    mov     eax, dword_5091C8
    sub     esp, 100h
    lea     ecx, [esp+100h+var_100]
    push    esi
    push    offset aLst                     ; "LST"
    push    offset asc_50372C               ; "*"
    push    eax
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+104h+var_100]
    push    0
    push    edx
    call    sub_4BC930
    test    eax, eax
    mov     esi, [esp+104h+arg_0]
    mov     [esi], eax
    jnz     short loc_44B542
    push    eax
    push    eax
    mov     eax, TAdynmemStructPtr
    push    offset Data
    add     eax, 519h
    push    offset aGames_0                 ; "GAMES"
    push    eax
    call    sub_4A32A0
    xor     eax, eax
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44B542:                             ; CODE XREF: sub_44B4E0+38j
    shl     eax, 8
    push    edi
    push    eax
    push    offset aSavegameNames           ; "SAVEGAME NAMES"
    call    sub_4D83B0
    mov     dword_5129AC, eax
    mov     ecx, [esi]
    add     esp, 8
    shl     ecx, 8
    push    ecx
    push    offset aSavegameDescs           ; "SAVEGAME DESCS"
    call    sub_4D83B0
    mov     edi, eax
    xor     eax, eax
    mov     dword_5129B0, edi
    mov     ecx, [esi]
    shl     ecx, 8
    mov     edx, ecx
    add     esp, 8
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    push    1
    and     ecx, 3
    push    0
    rep stosb
    mov     ecx, [esi]
    mov     edi, dword_5129AC
    shl     ecx, 8
    mov     edx, ecx
    xor     eax, eax
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    push    0
    and     ecx, 3
    push    0
    rep stosb
    mov     eax, dword_5129AC
    lea     ecx, [esp+118h+var_100]
    push    eax
    push    ecx
    call    sub_4AF320
    mov     edx, [esi]
    mov     eax, dword_5129AC
    mov     ecx, TAdynmemStructPtr
    push    0
    push    edx
    push    eax
    add     ecx, 519h
    push    offset aGames_0                 ; "GAMES"
    push    ecx
    call    sub_4A32A0
    mov     eax, [esi]
    mov     ecx, dword_5129AC
    neg     eax
    sbb     eax, eax
    pop     edi
    and     eax, ecx
    pop     esi
    add     esp, 100h
    retn    4
    sub_44B4E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_44B600:                             ; DATA XREF: sub_44B990+142o
                                            ; sub_44BC10+168o
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    lea     ebx, [eax+519h]
    mov     eax, [eax+531h]
    push    offset aGames_0                 ; "GAMES"
    mov     esi, [eax+4]
    push    esi
    call    sub_49FF90
    push    3
    push    offset aGamename                ; "GAMENAME"
    push    esi
    mov     edi, eax
    call    sub_49FDF0
    mov     esi, eax
    mov     ax, [edi+0BAh]
    cmp     ax, 0FFFFh
    jle     short loc_44B667
    mov     edx, dword_5129B0
    movsx   ecx, ax
    push    ecx
    push    edx
    call    sub_4B6AF0
    mov     edx, eax
    test    edx, edx
    jz      short loc_44B667
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_44B667
    push    edx
    jmp     short loc_44B66C
    ; ---------------------------------------------------------------------------

    loc_44B667:                             ; CODE XREF: .text:0044B63Ej
                                            ; .text:0044B654j ...
    push    offset Data

    loc_44B66C:                             ; CODE XREF: .text:0044B665j
    push    esi
    push    ebx
    call    sub_4A0880
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA90
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44B690 proc near                    ; DATA XREF: sub_44B990+29o

    var_104= dword ptr -104h
    FileName= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 104h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+114h+arg_0]
    or      ebx, 0FFFFFFFFh
    mov     eax, [edi+18h]
    mov     esi, [eax+4]
    mov     eax, [edi+60h]
    cmp     eax, ebx
    jnz     short loc_44B706
    push    1
    push    edi
    call    sub_4AB190
    mov     eax, dword_5129AC
    xor     esi, esi
    cmp     eax, esi
    jz      short loc_44B6CD
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_44B6CD:                             ; CODE XREF: sub_44B690+32j
    mov     eax, dword_5129B0
    cmp     eax, esi
    jz      short loc_44B6DF
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_44B6DF:                             ; CODE XREF: sub_44B690+44j
    mov     eax, TAdynmemStructPtr
    mov     dword_5129B0, esi
    mov     dword_5129AC, esi
    and     word ptr [eax+38A51h], 0FFFEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44B706:                             ; CODE XREF: sub_44B690+1Fj
    push    offset aCancel_0                ; "CANCEL"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_44B72E
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44B72E:                             ; CODE XREF: sub_44B690+83j
    push    offset aDelete                  ; "DELETE"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      loc_44B8C4
    push    0                               ; int
    push    offset aSmlbutton_0             ; char *
    call    sub_47F1A0
    push    offset aGames_0                 ; char *
    push    esi                             ; int
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, dword_5129AC
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax
    mov     eax, dword_5091C8
    push    eax
    lea     ecx, [esp+11Ch+FileName]
    push    offset aSS                      ; "%s\\%s"
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+114h+FileName]
    push    edx                             ; lpFileName
    call    sub_4BBC30
    lea     eax, [esp+114h+var_104]
    push    eax
    call    sub_44B4E0
    mov     ebx, dword_5129B0
    xor     ebp, ebp
    mov     eax, [esp+114h+var_104]
    test    eax, eax
    jle     short loc_44B810

    loc_44B7A9:                             ; CODE XREF: sub_44B690+177j
    mov     ecx, dword_5129AC
    push    ebp
    push    ecx
    call    sub_4B6AF0
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    ebp
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     eax, dword_5129AC
    push    eax
    call    sub_4B6AF0
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    add     ebx, ecx
    cmp     byte ptr [ebx], 2Eh
    jz      short loc_44B7FC

    loc_44B7F4:                             ; CODE XREF: sub_44B690+16Aj
    mov     al, [ebx-1]
    dec     ebx
    cmp     al, 2Eh
    jnz     short loc_44B7F4

    loc_44B7FC:                             ; CODE XREF: sub_44B690+162j
    mov     byte ptr [ebx], 0
    mov     eax, [esp+114h+var_104]
    inc     ebx
    inc     ebp
    cmp     ebp, eax
    jl      short loc_44B7A9
    mov     edi, [esp+114h+arg_0]

    loc_44B810:                             ; CODE XREF: sub_44B690+117j
    mov     ecx, dword_5129B0
    mov     edx, TAdynmemStructPtr
    push    0
    push    eax
    push    ecx
    add     edx, 519h
    push    offset aGames_0                 ; "GAMES"
    push    edx
    call    sub_4A32A0
    push    edi
    call    sub_4AB0A0
    mov     eax, TAdynmemStructPtr
    push    offset aGames_0                 ; char *
    lea     ebx, [eax+519h]
    mov     eax, [eax+531h]
    mov     esi, [eax+4]
    push    esi                             ; int
    call    sub_49FF90
    push    3
    push    offset aGamename                ; char *
    push    esi                             ; int
    mov     edi, eax
    call    sub_49FDF0
    mov     esi, eax
    mov     ax, [edi+0BAh]
    cmp     ax, 0FFFFh
    jle     short loc_44B89B
    mov     edx, dword_5129B0
    movsx   ecx, ax
    push    ecx
    push    edx
    call    sub_4B6AF0
    mov     edx, eax
    test    edx, edx
    jz      short loc_44B89B
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_44B89B
    push    edx
    jmp     short loc_44B8A0
    ; ---------------------------------------------------------------------------

    loc_44B89B:                             ; CODE XREF: sub_44B690+1E2j
                                            ; sub_44B690+1F8j ...
    push    offset Data

    loc_44B8A0:                             ; CODE XREF: sub_44B690+209j
    push    esi
    push    ebx
    call    sub_4A0880
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44B8C4:                             ; CODE XREF: sub_44B690+ABj
    push    offset aGames_0                 ; "GAMES"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_44B90D
    push    offset aLoad                    ; "LOAD"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_44B90D
    push    offset aGamename                ; "GAMENAME"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_44B90D
    cmp     [edi+60h], ebx
    jz      loc_44B97C
    push    edi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44B90D:                             ; CODE XREF: sub_44B690+241j
                                            ; sub_44B690+250j ...
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    3
    push    offset aGamename                ; char *
    push    esi                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    xor     eax, eax
    lea     edx, [esi+ecx*2+0B6h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_44B97C
    mov     eax, TAdynmemStructPtr
    push    offset aLst                     ; "LST"
    push    edx
    mov     edx, dword_5091C8
    add     eax, 38C6Bh
    push    edx
    push    eax
    call    sub_4290F0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 38C6Bh
    push    ecx
    call    sub_44B230

    loc_44B97C:                             ; CODE XREF: sub_44B690+264j
                                            ; sub_44B690+2BBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    sub_44B690 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44B990 proc near                    ; CODE XREF: sub_44C420+1B9p

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    880h
    add     eax, 519h
    push    offset aSavelist_gui            ; "SAVELIST.GUI"
    push    eax
    call    sub_4AA8F0
    mov     edi, eax
    push    0
    push    0
    push    0
    mov     dword ptr [edi+8], offset sub_44B690
    mov     ecx, TAdynmemStructPtr
    push    offset aDsavelist               ; "DSaveList"
    mov     [esp+28h+var_4], edi
    mov     [edi+0Ch], ecx
    call    sub_4288D0
    mov     edx, dword_5091C8
    push    edx
    call    sub_4BCF00
    lea     eax, [esp+18h+var_8]
    push    eax
    call    sub_44B4E0
    mov     ecx, TAdynmemStructPtr
    push    0
    push    offset aSaveGame                ; "Save Game"
    add     ecx, 519h
    push    offset aTitle                   ; "TITLE"
    push    ecx
    call    sub_4A0BF0
    mov     ebx, dword_5129B0
    xor     ebp, ebp
    mov     eax, [esp+18h+var_8]
    test    eax, eax
    jle     short loc_44BA80

    loc_44BA1B:                             ; CODE XREF: sub_44B990+EAj
    mov     edx, dword_5129AC
    push    ebp
    push    edx
    call    sub_4B6AF0
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    ebp
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, dword_5129AC
    push    ecx
    call    sub_4B6AF0
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    add     ebx, ecx
    cmp     byte ptr [ebx], 2Eh
    jz      short loc_44BA6F

    loc_44BA67:                             ; CODE XREF: sub_44B990+DDj
    mov     al, [ebx-1]
    dec     ebx
    cmp     al, 2Eh
    jnz     short loc_44BA67

    loc_44BA6F:                             ; CODE XREF: sub_44B990+D5j
    mov     byte ptr [ebx], 0
    mov     eax, [esp+18h+var_8]
    inc     ebx
    inc     ebp
    cmp     ebp, eax
    jl      short loc_44BA1B
    mov     edi, [esp+18h+var_4]

    loc_44BA80:                             ; CODE XREF: sub_44B990+89j
    mov     edx, dword_5129B0
    push    0
    push    eax
    mov     eax, TAdynmemStructPtr
    push    edx
    add     eax, 519h
    push    offset aGames_0                 ; "GAMES"
    push    eax
    call    sub_4A32A0
    mov     eax, [esp+18h+var_8]
    test    eax, eax
    jnz     short loc_44BAC0
    mov     ecx, TAdynmemStructPtr
    push    0                               ; int
    add     ecx, 519h
    push    offset aDelete                  ; char *
    push    ecx                             ; int
    call    sub_4A0570

    loc_44BAC0:                             ; CODE XREF: sub_44B990+115j
    mov     edx, [edi+4]
    push    offset aGames_0                 ; char *
    push    edx                             ; int
    call    sub_49FF90
    test    eax, eax
    jz      short loc_44BADC
    mov     dword ptr [eax+0CEh], offset loc_44B600

    loc_44BADC:                             ; CODE XREF: sub_44B990+140j
    mov     eax, [edi+4]
    push    3
    push    offset aGamename                ; char *
    push    eax                             ; int
    call    sub_49FDF0
    mov     esi, eax
    push    offset aGames_0                 ; char *
    shl     eax, 3
    sub     eax, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    lea     eax, [esi+edx*4]
    mov     edx, [edi+4]
    lea     ecx, [esi+eax*2]
    mov     ebp, [ecx+edx+1Bh]
    lea     eax, [ecx+edx+1Bh]
    or      ebp, 2
    mov     [eax], ebp
    mov     eax, TAdynmemStructPtr
    lea     ebp, [eax+519h]
    mov     eax, [eax+531h]
    mov     edi, [eax+4]
    push    edi                             ; int
    call    sub_49FF90
    push    3
    push    offset aGamename                ; char *
    push    edi                             ; int
    mov     ebx, eax
    call    sub_49FDF0
    mov     [esp+14h], eax
    mov     ax, [ebx+0BAh]
    cmp     ax, 0FFFFh
    jle     short loc_44BB7A
    mov     edx, dword_5129B0
    movsx   ecx, ax
    push    ecx
    push    edx
    call    sub_4B6AF0
    mov     edx, eax
    test    edx, edx
    jz      short loc_44BB7A
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_44BB7A
    mov     eax, [esp+14h]
    push    edx
    push    eax
    jmp     short loc_44BB84
    ; ---------------------------------------------------------------------------

    loc_44BB7A:                             ; CODE XREF: sub_44B990+1BCj
                                            ; sub_44B990+1D2j ...
    mov     ecx, [esp+14h]
    push    offset Data
    push    ecx

    loc_44BB84:                             ; CODE XREF: sub_44B990+1E8j
    push    ebp
    call    sub_4A0880
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx                             ; int
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    push    esi
    add     eax, 519h
    push    eax
    call    sub_4A7190
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    call    sub_428B60
    mov     edx, TAdynmemStructPtr
    push    0                               ; int
    add     edx, 519h
    push    offset aLoadgame                ; char *
    push    edx                             ; int
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA50
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    sub_44B990 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44BC10 proc near                    ; CODE XREF: sub_44C420+18Cp

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    mov     eax, TAdynmemStructPtr
    push    esi
    push    981h
    add     eax, 519h
    push    offset aLoadlist_gui            ; "LOADLIST.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    push    0
    push    0
    push    0
    mov     dword ptr [esi+8], offset loc_44B3C0
    mov     ecx, TAdynmemStructPtr
    push    offset aDloadlist               ; "DLoadList"
    mov     [esp+1Ch+var_4], esi
    mov     [esi+0Ch], ecx
    call    sub_4288D0
    lea     edx, [esp+0Ch+var_8]
    push    edx
    call    sub_44B4E0
    test    eax, eax
    jnz     short loc_44BC9D
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A9660
    push    1
    push    1
    push    140h
    push    offset aThereAreNoSa_0          ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_44BC9D:                             ; CODE XREF: sub_44BC10+50j
    mov     eax, [esp+0Ch+var_8]
    push    edi
    push    ebp
    xor     ebp, ebp
    push    ebx
    mov     ebx, dword_5129B0
    test    eax, eax
    jle     short loc_44BD15

    loc_44BCB0:                             ; CODE XREF: sub_44BC10+FFj
    mov     edx, dword_5129AC
    push    ebp
    push    edx
    call    sub_4B6AF0
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    ebp
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, dword_5129AC
    push    ecx
    call    sub_4B6AF0
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    add     ebx, ecx
    cmp     byte ptr [ebx], 2Eh
    jz      short loc_44BD04

    loc_44BCFC:                             ; CODE XREF: sub_44BC10+F2j
    mov     al, [ebx-1]
    dec     ebx
    cmp     al, 2Eh
    jnz     short loc_44BCFC

    loc_44BD04:                             ; CODE XREF: sub_44BC10+EAj
    mov     byte ptr [ebx], 0
    mov     eax, [esp+18h+var_8]
    inc     ebx
    inc     ebp
    cmp     ebp, eax
    jl      short loc_44BCB0
    mov     esi, [esp+18h+var_4]

    loc_44BD15:                             ; CODE XREF: sub_44BC10+9Ej
    mov     edx, dword_5129B0
    push    0
    push    eax
    mov     eax, TAdynmemStructPtr
    push    edx
    add     eax, 519h
    push    offset aGames_0                 ; "GAMES"
    push    eax
    call    sub_4A32A0
    mov     ecx, TAdynmemStructPtr
    push    0                               ; int
    add     ecx, 519h
    push    offset aDelete                  ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    push    0                               ; int
    add     edx, 519h
    push    offset aGamename                ; char *
    push    edx                             ; int
    call    sub_4A0570
    mov     eax, [esi+4]
    push    offset aGames_0                 ; char *
    push    eax                             ; int
    call    sub_49FF90
    test    eax, eax
    jz      short loc_44BD82
    mov     dword ptr [eax+0CEh], offset loc_44B600

    loc_44BD82:                             ; CODE XREF: sub_44BC10+166j
    mov     eax, TAdynmemStructPtr
    push    offset aGames_0                 ; char *
    mov     ecx, [eax+531h]
    lea     ebx, [eax+519h]
    mov     esi, [ecx+4]
    push    esi                             ; int
    call    sub_49FF90
    push    3
    push    offset aGamename                ; char *
    push    esi                             ; int
    mov     edi, eax
    call    sub_49FDF0
    mov     esi, eax
    mov     ax, [edi+0BAh]
    cmp     ax, 0FFFFh
    jle     short loc_44BDE5
    movsx   edx, ax
    mov     eax, dword_5129B0
    push    edx
    push    eax
    call    sub_4B6AF0
    mov     edx, eax
    test    edx, edx
    jz      short loc_44BDE5
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_44BDE5
    push    edx
    jmp     short loc_44BDEA
    ; ---------------------------------------------------------------------------

    loc_44BDE5:                             ; CODE XREF: sub_44BC10+1ADj
                                            ; sub_44BC10+1C2j ...
    push    offset Data

    loc_44BDEA:                             ; CODE XREF: sub_44BC10+1D3j
    push    esi
    push    ebx
    call    sub_4A0880
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_49FA90
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    call    sub_428B60
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    add     eax, 519h
    push    offset aSavegame_0              ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA50
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    mov     eax, TAdynmemStructPtr
    pop     ebx
    pop     ebp
    pop     edi
    or      byte ptr [eax+38A51h], 1
    pop     esi
    add     esp, 8
    retn
    sub_44BC10 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44BE70 proc near                    ; DATA XREF: sub_44C7E0+40Co

    var_28= byte ptr -28h
    var_14= dword ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 28h
    push    ebx
    mov     ebx, [esp+2Ch+arg_4]
    push    ebp
    push    esi
    lea     eax, [ebx+8]
    push    edi
    push    eax                             ; char *
    call    _atoi
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     esi, eax
    mov     edx, [ecx+531h]
    push    offset aDesclist                ; char *
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FF90
    push    esi
    lea     ecx, [esp+3Ch+var_14]
    push    offset aCountD                  ; "COUNT%d"
    push    ecx
    mov     edi, eax
    call    _sprintf
    add     esp, 0Ch
    push    ebx
    call    sub_45BA20
    mov     ebx, eax
    cmp     ebx, 64h
    jle     short loc_44BEE2
    push    offset aNoLimit                 ; int
    call    sub_4C5740
    lea     edx, [esp+38h+var_28]
    push    eax
    push    edx
    call    _sprintf
    add     esp, 8
    or      ebx, 0FFFFFFFFh
    jmp     short loc_44BEF2
    ; ---------------------------------------------------------------------------

    loc_44BEE2:                             ; CODE XREF: sub_44BE70+53j
    lea     eax, [esp+38h+var_28]
    push    0Ah                             ; int
    push    eax                             ; char *
    push    ebx                             ; int
    call    __itoa
    add     esp, 0Ch

    loc_44BEF2:                             ; CODE XREF: sub_44BE70+70j
    movsx   ecx, word ptr [edi+0BCh]
    mov     eax, esi
    push    ebx
    add     eax, ecx
    lea     edx, [eax+eax*2]
    shl     edx, 4
    add     edx, eax
    mov     eax, dword_5129B4
    mov     [eax+edx*2+5Ah], ebx
    mov     eax, esi
    movsx   ecx, word ptr [edi+0BCh]
    add     eax, ecx
    lea     edx, [eax+eax*2]
    shl     edx, 4
    add     edx, eax
    mov     eax, dword_5129B4
    mov     ecx, [eax+edx*2+52h]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    add     ecx, [eax+1439Bh]
    push    ecx
    mov     ecx, [eax+2A30h]
    call    sub_46E550
    movsx   ecx, word ptr [edi+0BCh]
    mov     ebx, dword_5129B4
    push    0
    lea     eax, [esi+ecx]
    lea     edx, [eax+eax*2]
    shl     edx, 4
    add     edx, eax
    xor     eax, eax
    mov     ebp, [ebx+edx*2+5Eh]
    mov     edx, [edi+0D6h]
    test    ebp, ebp
    setz    al
    add     ecx, esi
    mov     [ecx+edx], al
    mov     edx, [edi+0D6h]
    movsx   eax, word ptr [edi+0BCh]
    lea     ecx, [esi+eax]
    add     eax, esi
    add     ecx, edx
    lea     edx, [eax+eax*2]
    shl     edx, 4
    add     edx, eax
    mov     eax, dword_5129B4
    mov     bl, [ecx]
    mov     edx, [eax+edx*2+5Ah]
    lea     eax, [esp+3Ch+var_28]
    neg     edx
    sbb     edx, edx
    push    eax
    and     edx, 0FFFFFFFEh
    add     edx, 2
    or      bl, dl
    mov     edx, [esp+40h+arg_0]
    mov     [ecx], bl
    lea     ecx, [esp+40h+var_14]
    push    ecx
    push    edx
    call    sub_4A0BF0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    8
    sub_44BE70 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44BFD0 proc near                    ; CODE XREF: .text:0044B494p
                                            ; .text:0044C34Ep ...

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= byte ptr -14h
    arg_0= dword ptr  4

    sub     esp, 20h
    mov     eax, [esp+20h+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    push    offset aDesclist                ; char *
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FF90
    mov     esi, eax
    mov     [esp+30h+var_1C], esi
    call    sub_457A50
    mov     [esp+30h+var_20], eax
    xor     edi, edi
    movsx   eax, word ptr [esi+0BCh]
    mov     [esp+30h+var_18], eax
    lea     ebp, [eax+eax*2]
    shl     ebp, 4
    add     ebp, eax
    shl     ebp, 1

    loc_44C012:                             ; CODE XREF: sub_44BFD0+E9j
    push    edi
    lea     eax, [esp+34h+var_14]
    push    offset aSliderD                 ; "SLIDER%d"
    push    eax
    call    _sprintf
    mov     edx, [esp+3Ch+arg_0]
    add     esp, 0Ch
    lea     ecx, [esp+30h+var_14]
    mov     eax, [edx+18h]
    push    ecx                             ; char *
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    mov     esi, eax
    test    esi, esi
    jz      short loc_44C0B2
    mov     eax, [esp+30h+var_20]
    test    eax, eax
    jz      short loc_44C05A
    mov     edx, dword_5129B4
    mov     eax, [edx+ebp+5Eh]
    test    eax, eax
    jz      short loc_44C05A
    xor     ebx, ebx
    jmp     short loc_44C05F
    ; ---------------------------------------------------------------------------

    loc_44C05A:                             ; CODE XREF: sub_44BFD0+76j
                                            ; sub_44BFD0+84j
    mov     ebx, 1

    loc_44C05F:                             ; CODE XREF: sub_44BFD0+88j
    mov     ecx, [esp+30h+var_1C]
    xor     eax, eax
    test    ebx, ebx
    mov     edx, [ecx+0D6h]
    mov     ecx, [esp+30h+var_18]
    setnz   al
    add     edx, ecx
    mov     [edx+edi], al
    mov     eax, dword_5129B4
    mov     eax, [eax+ebp+5Ah]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_44C08D
    mov     eax, [esi+13Ch]

    loc_44C08D:                             ; CODE XREF: sub_44BFD0+B5j
    push    eax
    push    esi
    call    sub_45B9B0
    push    ebx
    mov     ebx, [esp+34h+arg_0]
    lea     ecx, [esp+34h+var_14]
    push    ecx
    push    ebx
    call    sub_4A1450
    mov     edx, [esi+14Ah]
    push    edx
    push    ebx
    call    dword ptr [esi+144h]

    loc_44C0B2:                             ; CODE XREF: sub_44BFD0+6Ej
    inc     edi
    add     ebp, 62h
    cmp     edi, 0Ch
    jl      loc_44C012
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    sub_44BFD0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44C0D0 proc near                    ; CODE XREF: .text:0044C25Ep

    var_118= dword ptr -118h
    var_110= byte ptr -110h
    var_108= dword ptr -108h
    var_100= dword ptr -100h

    mov     eax, TAdynmemStructPtr
    sub     esp, 118h
    mov     ecx, [eax+531h]
    push    esi
    push    edi
    push    offset aPiclist                 ; char *
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FF90
    mov     ecx, dword_512768
    mov     edi, eax
    test    ecx, ecx
    jnz     short loc_44C114
    mov     eax, [edi+0C6h]
    mov     edx, dword_5129B8
    mov     dword_51297C, eax
    mov     dword_512978, edx

    loc_44C114:                             ; CODE XREF: sub_44C0D0+2Bj
    mov     edx, TAdynmemStructPtr
    mov     eax, ecx
    inc     ecx
    mov     dword_512768, ecx
    mov     ecx, [edx+1438Fh]
    cmp     eax, ecx
    jge     loc_44C216
    lea     ecx, [eax+eax*2]
    mov     edx, [edx+1439Bh]
    shl     ecx, 4
    add     ecx, eax
    mov     eax, dword_5129B4
    mov     ecx, [eax+ecx*2+52h]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     esi, [edx+eax*8]
    add     esi, eax
    lea     eax, [esi+20h]
    test    eax, eax
    jz      loc_44C216
    mov     eax, [esi+245h]
    shr     eax, 0Fh
    test    al, 1
    jnz     loc_44C216
    mov     eax, ecx
    push    offset aPcx                     ; "PCX"
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [edx+eax*8]
    lea     edx, [eax+ecx+20h]
    lea     eax, [esp+124h+var_100]
    push    edx
    push    offset aUnitpics                ; "unitpics"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+120h+var_100]
    push    0
    push    ecx
    call    sub_4CAF30
    mov     edx, dword_512978
    mov     [edx], eax
    mov     edx, dword_512978
    add     edx, 4
    test    eax, eax
    mov     dword_512978, edx
    jz      short loc_44C1CC
    push    eax
    lea     eax, [esp+124h+var_118]
    push    eax
    call    sub_4B8AE0
    mov     [esp+120h+var_110], 9
    jmp     short loc_44C1E4
    ; ---------------------------------------------------------------------------

    loc_44C1CC:                             ; CODE XREF: sub_44C0D0+E8j
    mov     cx, [edi+17h]
    mov     word ptr [esp+120h+var_118+2], 20h
    mov     word ptr [esp+120h+var_118], cx
    mov     [esp+120h+var_108], 0

    loc_44C1E4:                             ; CODE XREF: sub_44C0D0+FAj
    mov     edi, dword_51297C
    mov     ecx, 6
    lea     esi, [esp+120h+var_118]
    rep movsd
    mov     edx, TAdynmemStructPtr
    mov     ecx, dword_51297C
    add     edx, 519h
    add     ecx, 18h
    push    edx                             ; int
    mov     dword_51297C, ecx
    call    sub_49FA90

    loc_44C216:                             ; CODE XREF: sub_44C0D0+5Bj
                                            ; sub_44C0D0+89j ...
    pop     edi
    pop     esi
    add     esp, 118h
    retn
    sub_44C0D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    loc_44C220:                             ; DATA XREF: sub_44C7E0+5Eo
    mov     eax, TAdynmemStructPtr
    sub     esp, 10h
    mov     ecx, [eax+531h]
    push    ebx
    push    ebp
    push    esi
    mov     edx, [ecx+4]
    push    edi
    push    offset aPiclist                 ; "PICLIST"
    push    edx
    xor     ebp, ebp
    call    sub_49FF90
    mov     edi, eax
    call    sub_4B6340
    cmp     dword_5129C8, eax
    jge     short loc_44C263
    call    sub_4B6340
    add     eax, 2
    mov     dword_5129C8, eax
    call    sub_44C0D0

    loc_44C263:                             ; CODE XREF: .text:0044C24Fj
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+10h]
    push    eax
    mov     ecx, [ecx+2A30h]
    call    sub_46E280
    test    eax, eax
    jz      loc_44C33D

    loc_44C281:                             ; CODE XREF: .text:0044C337j
    xor     esi, esi
    inc     ebp
    cmp     [edi+0C0h], si
    jle     loc_44C31F
    xor     ecx, ecx

    loc_44C293:                             ; CODE XREF: .text:0044C319j
    mov     edx, dword_5129B4
    mov     ebx, [esp+10h]
    mov     edx, [edx+ecx+52h]
    mov     eax, edx
    shl     eax, 6
    add     eax, edx
    mov     edx, TAdynmemStructPtr
    mov     edx, [edx+1439Bh]
    lea     eax, [eax+eax*8]
    cmp     ebx, [eax+edx+13Eh]
    jnz     short loc_44C30C
    mov     edx, [edi+0D6h]
    xor     eax, eax
    cmp     [esp+1Ah], ax
    setz    al
    mov     [esi+edx], al
    mov     edx, dword_5129B4
    movsx   eax, word ptr [esp+1Ah]
    mov     [edx+ecx+5Eh], eax
    mov     edx, dword_5129B4
    mov     eax, [esp+1Ch]
    mov     [edx+ecx+5Ah], eax
    mov     eax, [edi+0D6h]
    mov     edx, [esp+1Ch]
    add     eax, esi
    neg     edx
    mov     bl, [eax]
    sbb     edx, edx
    and     edx, 0FFFFFFFEh
    add     edx, 2
    or      bl, dl
    mov     [eax], bl

    loc_44C30C:                             ; CODE XREF: .text:0044C2BEj
    movsx   eax, word ptr [edi+0C0h]
    inc     esi
    add     ecx, 62h
    cmp     esi, eax
    jl      loc_44C293

    loc_44C31F:                             ; CODE XREF: .text:0044C28Bj
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+10h]
    push    ecx
    mov     ecx, [edx+2A30h]
    call    sub_46E280
    test    eax, eax
    jnz     loc_44C281

    loc_44C33D:                             ; CODE XREF: .text:0044C27Bj
    test    ebp, ebp
    jz      short loc_44C365
    mov     eax, TAdynmemStructPtr
    push    0
    add     eax, 519h
    push    eax
    call    sub_44BFD0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA90

    loc_44C365:                             ; CODE XREF: .text:0044C33Fj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_44C370:                             ; DATA XREF: sub_44C7E0+ACo
    mov     ecx, [esp+8]
    sub     esp, 14h
    movsx   eax, word ptr [ecx+0BAh]
    push    esi
    push    edi
    lea     edx, [eax+eax*2]
    shl     edx, 4
    add     edx, eax
    mov     eax, [ecx+0D2h]
    mov     ecx, [eax+edx*2+52h]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edi, [ecx+1439Bh]
    lea     esi, [eax+eax*8]
    add     esi, edi
    fld     dword ptr [esi+186h]
    call    __ftol
    push    eax
    lea     edx, [esp+0Ch]
    push    offset aD_0                     ; "%d"
    push    edx
    call    _sprintf
    mov     edi, [esp+2Ch]
    add     esp, 0Ch
    lea     eax, [esp+8]
    push    0
    push    eax
    push    offset aEnergytext              ; "ENERGYTEXT"
    push    edi
    call    sub_4A0BF0
    fld     dword ptr [esi+18Ah]
    call    __ftol
    push    eax
    lea     ecx, [esp+0Ch]
    push    offset aD_0                     ; "%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+8]
    push    0
    push    edx
    push    offset aMetaltext               ; "METALTEXT"
    push    edi
    call    sub_4A0BF0
    pop     edi
    pop     esi
    add     esp, 14h
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44C420 proc near                    ; DATA XREF: sub_44C7E0+54o

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    mov     eax, [ebx+18h]
    push    edi
    push    offset aDesclist                ; char *
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_49FF90
    mov     ebp, eax
    mov     eax, [ebx+60h]
    or      esi, 0FFFFFFFFh
    cmp     eax, esi
    jnz     loc_44C591
    mov     esi, dword_5129B8
    xor     edi, edi
    cmp     [ebp+0C0h], di
    jle     short loc_44C475

    loc_44C45A:                             ; CODE XREF: sub_44C420+53j
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_44C466
    push    eax
    call    sub_4C6AC0

    loc_44C466:                             ; CODE XREF: sub_44C420+3Ej
    movsx   edx, word ptr [ebp+0C0h]
    add     esi, 4
    inc     edi
    cmp     edi, edx
    jl      short loc_44C45A

    loc_44C475:                             ; CODE XREF: sub_44C420+38j
    mov     eax, [ebp+0C6h]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, dword_5129B8
    add     esp, 4
    push    ecx                             ; int
    call    sub_4D85A0
    xor     esi, esi
    add     esp, 4
    mov     dword_5129B8, esi
    mov     edx, [ebp+0C2h]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    1
    push    ebx
    call    sub_4AB190
    call    sub_457A50
    test    eax, eax
    jz      short loc_44C52C
    mov     edx, TAdynmemStructPtr
    xor     edi, edi
    cmp     [edx+1438Fh], esi
    jle     short loc_44C52C

    loc_44C4CB:                             ; CODE XREF: sub_44C420+10Aj
    mov     eax, dword_5129B4
    mov     ecx, [eax+esi+52h]
    test    ecx, ecx
    jz      short loc_44C51E
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    mov     eax, [edx+1439Bh]
    add     eax, ecx
    mov     ecx, [eax+245h]
    shr     ecx, 0Fh
    test    cl, 1
    jnz     short loc_44C51E
    mov     ecx, dword_5129B4
    push    eax
    cmp     dword ptr [ecx+esi+5Ah], 0
    mov     ecx, [edx+2A30h]
    jnz     short loc_44C513
    call    sub_46E450
    jmp     short loc_44C518
    ; ---------------------------------------------------------------------------

    loc_44C513:                             ; CODE XREF: sub_44C420+EAj
    call    sub_46E4D0

    loc_44C518:                             ; CODE XREF: sub_44C420+F1j
    mov     edx, TAdynmemStructPtr

    loc_44C51E:                             ; CODE XREF: sub_44C420+B6j
                                            ; sub_44C420+D6j
    mov     eax, [edx+1438Fh]
    inc     edi
    add     esi, 62h
    cmp     edi, eax
    jl      short loc_44C4CB

    loc_44C52C:                             ; CODE XREF: sub_44C420+99j
                                            ; sub_44C420+A9j
    mov     edx, dword_5129B4
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, dword_5129C4
    add     esp, 4
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, [ebp+0D6h]
    add     esp, 4
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, [ebx+18h]
    add     esp, 4
    mov     eax, [edx+4]
    push    offset aPiclist                 ; char *
    push    eax                             ; int
    call    sub_49FF90
    test    eax, eax
    jz      short loc_44C580
    mov     eax, [eax+0C6h]
    test    eax, eax
    jz      short loc_44C580
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_44C580:                             ; CODE XREF: sub_44C420+14Bj
                                            ; sub_44C420+155j
    mov     dword_5129B4, 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44C591:                             ; CODE XREF: sub_44C420+23j
    push    offset aLoad_0                  ; "Load"
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_44C5BE
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    call    sub_44BC10
    push    ebx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44C5BE:                             ; CODE XREF: sub_44C420+17Ej
    push    offset aSave                    ; "Save"
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_44C5EB
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    call    sub_44B990
    push    ebx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44C5EB:                             ; CODE XREF: sub_44C420+1ABj
    push    offset aReset                   ; "Reset"
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      loc_44C6DA
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    xor     edi, edi
    mov     eax, [ecx+1438Fh]
    test    eax, eax
    jle     loc_44C6BF
    mov     ecx, dword_5129B4
    xor     esi, esi
    mov     ebp, 10000h
    mov     ebx, 64h

    loc_44C632:                             ; CODE XREF: sub_44C420+295j
    mov     edx, [ecx+esi+52h]
    test    edx, edx
    jz      short loc_44C6A6
    mov     eax, edx
    shl     eax, 6
    add     eax, edx
    lea     edx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+1439Bh]
    test    [eax+edx+245h], ebp
    jnz     short loc_44C65E
    mov     [ecx+esi+5Ah], ebx
    jmp     short loc_44C666
    ; ---------------------------------------------------------------------------

    loc_44C65E:                             ; CODE XREF: sub_44C420+236j
    mov     dword ptr [ecx+esi+5Ah], 0

    loc_44C666:                             ; CODE XREF: sub_44C420+23Cj
    mov     ecx, dword_5129B4
    mov     eax, [ecx+esi+5Ah]
    mov     edx, [ecx+esi+56h]
    cmp     eax, edx
    jz      short loc_44C6A6
    mov     ecx, [ecx+esi+52h]
    push    eax
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+1439Bh]
    add     edx, ecx
    mov     ecx, [eax+2A30h]
    push    edx
    call    sub_46E550
    mov     ecx, dword_5129B4

    loc_44C6A6:                             ; CODE XREF: sub_44C420+218j
                                            ; sub_44C420+256j
    mov     eax, TAdynmemStructPtr
    inc     edi
    add     esi, 62h
    cmp     edi, [eax+1438Fh]
    jl      loc_44C632
    mov     ebx, [esp+0Ch+arg_0]

    loc_44C6BF:                             ; CODE XREF: sub_44C420+1FAj
    push    0
    push    ebx
    call    sub_44BFD0
    push    ebx                             ; int
    call    sub_49FA90
    push    ebx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44C6DA:                             ; CODE XREF: sub_44C420+1D8j
    push    offset byte_502AE8
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_44C6FC
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44C6FC:                             ; CODE XREF: sub_44C420+2C7j
    push    offset aCancel                  ; "Cancel"
    push    ebx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_44C787
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    mov     ebp, 1
    cmp     [ecx+1438Fh], ebp
    jle     short loc_44C792
    mov     esi, 249h
    xor     edi, edi

    loc_44C731:                             ; CODE XREF: sub_44C420+35Ej
    mov     edx, [ecx+1439Bh]
    lea     eax, [edx+esi]
    mov     edx, [edx+esi+245h]
    shr     edx, 0Fh
    test    dl, 1
    jnz     short loc_44C76F
    lea     edx, [eax+20h]
    test    edx, edx
    jz      short loc_44C76F
    mov     edx, dword_5129C4
    mov     ecx, [ecx+2A30h]
    mov     edx, [edx+edi]
    push    edx
    push    eax
    call    sub_46E550
    mov     ecx, TAdynmemStructPtr
    add     edi, 4

    loc_44C76F:                             ; CODE XREF: sub_44C420+327j
                                            ; sub_44C420+32Ej
    mov     eax, [ecx+1438Fh]
    inc     ebp
    add     esi, 249h
    cmp     ebp, eax
    jl      short loc_44C731
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44C787:                             ; CODE XREF: sub_44C420+2E9j
    cmp     [ebx+60h], esi
    jz      short loc_44C792
    push    ebx
    call    sub_4AB0A0

    loc_44C792:                             ; CODE XREF: sub_44C420+308j
                                            ; sub_44C420+36Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_44C420 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_44C7A0(const void *,const void *)
    sub_44C7A0 proc near                    ; DATA XREF: sub_44C7E0+383o

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    esi
    mov     esi, [esp+8+arg_4]

    loc_44C7AA:                             ; CODE XREF: sub_44C7A0+2Cj
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_44C7D3
    test    cl, cl
    jz      short loc_44C7CE
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_44C7D3
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_44C7AA

    loc_44C7CE:                             ; CODE XREF: sub_44C7A0+16j
    xor     eax, eax
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_44C7D3:                             ; CODE XREF: sub_44C7A0+12j
                                            ; sub_44C7A0+22j
    sbb     eax, eax
    pop     esi
    sbb     eax, 0FFFFFFFFh
    pop     ebx
    retn
    sub_44C7A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_44C7E0()
    sub_44C7E0 proc near                    ; CODE XREF: sub_447B10+FD5p

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= byte ptr -14h
    var_A= word ptr -0Ah
    var_8= dword ptr -8

    sub     esp, 2Ch
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    ebx
    push    ebp
    mov     cl, [edx+2A42h]
    push    esi
    mov     eax, ecx
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    push    edi
    push    880h
    lea     eax, [eax+eax*4]
    add     edx, 519h
    push    offset aRestrict2_gui           ; "RESTRICT2.GUI"
    push    edx
    mov     ecx, [esi+eax*2+1B8Ah]
    mov     al, [ecx+97h]
    and     eax, 1
    mov     [esp+48h+var_18], eax
    call    sub_4AA8F0
    mov     esi, eax
    xor     eax, eax
    push    eax
    push    eax
    push    eax
    mov     dword ptr [esi+8], offset sub_44C420
    mov     [esi+0Ch], eax
    mov     dword ptr [esi+1Ch], offset loc_44C220
    push    offset aUnitrestrict5x          ; "UnitRestrict5x"
    mov     dword_512768, eax
    call    sub_4288D0
    mov     ecx, TAdynmemStructPtr
    mov     ebp, [esi+4]
    mov     [esp+3Ch+var_24], ebp
    mov     edx, [ecx+1438Fh]
    push    edx
    push    offset aFlags                   ; "FLAGS"
    call    sub_4D83B0
    add     esp, 8
    mov     edi, eax
    push    offset aDesclist                ; char *
    push    ebp                             ; int
    call    sub_49FF90
    mov     ebx, eax
    push    offset aPiclist                 ; char *
    mov     ecx, [ebx+1Bh]
    mov     dword ptr [ebx+0CEh], offset loc_44C370
    or      ch, 1
    mov     [ebx+0D6h], edi
    mov     word ptr [ebx+0DAh], 20h
    mov     [ebx+1Bh], ecx
    mov     eax, [esi+4]
    push    eax                             ; int
    call    sub_49FF90
    mov     ecx, [eax+1Bh]
    mov     [eax+0D6h], edi
    or      ecx, 180h
    mov     [eax+1Bh], ecx
    mov     cx, [ebx+0DAh]
    mov     [eax+0DAh], cx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1438Fh]
    lea     eax, [eax+eax*2]
    shl     eax, 3
    push    eax
    push    offset aUnitpicarray            ; "UNITPICARRAY"
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    mov     edi, eax
    add     esp, 8
    mov     [esp+3Ch+var_1C], edi
    mov     eax, [ecx+1438Fh]
    lea     ecx, [eax+eax*2]
    xor     eax, eax
    shl     ecx, 3
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1438Fh]
    shl     ecx, 5
    push    ecx
    push    offset aUnittextarray           ; "UNITTEXTARRAY"
    call    sub_4D83B0
    mov     esi, eax
    xor     edi, edi
    add     esp, 8
    mov     [esp+3Ch+var_20], esi
    mov     [esi], edi
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1438Fh]
    lea     ecx, [eax+eax*2]
    shl     ecx, 4
    add     ecx, eax
    shl     ecx, 1
    push    ecx
    push    offset aUnitsrestricti          ; "UNITSRESTRICTINFO"
    call    sub_4D83B0
    mov     dword_5129B4, eax
    mov     [ebx+0D2h], eax
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    xor     eax, eax
    cmp     [ecx+1438Fh], edi
    jle     short loc_44C99F
    xor     edx, edx

    loc_44C983:                             ; CODE XREF: sub_44C7E0+1BDj
    mov     ecx, dword_5129B4
    inc     eax
    mov     [ecx+edx+52h], edi
    mov     ecx, TAdynmemStructPtr
    add     edx, 62h
    cmp     eax, [ecx+1438Fh]
    jl      short loc_44C983

    loc_44C99F:                             ; CODE XREF: sub_44C7E0+19Fj
    mov     edx, [ecx+1438Fh]
    shl     edx, 2
    push    edx
    push    offset aUnitspics               ; "UNITSPICS"
    call    sub_4D83B0
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    mov     dword_5129B8, edi
    add     esp, 8
    mov     ecx, [eax+1438Fh]
    xor     eax, eax
    shl     ecx, 2
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     eax, TAdynmemStructPtr
    mov     edi, dword_5129B4
    mov     eax, [eax+1438Fh]
    lea     ecx, [eax+eax*2]
    shl     ecx, 4
    add     ecx, eax
    xor     eax, eax
    shl     ecx, 1
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1438Fh]
    shl     ecx, 2
    push    ecx
    push    offset aOldcounts               ; "OLDCOUNTS"
    call    sub_4D83B0
    mov     dword_5129C4, eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, 1
    add     esp, 8
    mov     edx, [eax+1438Fh]
    mov     [esp+3Ch+var_28], 0
    cmp     edx, ecx
    mov     [esp+3Ch+var_2C], ecx
    jle     loc_44CB59
    xor     ebp, ebp
    mov     edi, 249h

    loc_44CA53:                             ; CODE XREF: sub_44C7E0+36Bj
    mov     edx, [eax+1439Bh]
    mov     ecx, [edx+edi+245h]
    lea     esi, [edx+edi]
    shr     ecx, 0Fh
    test    cl, 1
    jnz     loc_44CB34
    add     esi, 20h
    test    esi, esi
    jz      loc_44CB34
    mov     esi, edx
    add     esi, edi
    fld     dword ptr [esi+186h]
    call    __ftol
    fld     dword ptr [esi+18Ah]
    push    eax
    call    __ftol
    add     esi, 0A0h
    push    eax
    push    esi                             ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    mov     ecx, dword_5129B4
    push    eax
    add     ecx, ebp
    mov     eax, [edx+1439Bh]
    add     eax, edi
    push    eax
    push    offset aSSDmDe                  ; "%s\r%s %dM  %dE"
    push    ecx
    call    _sprintf
    mov     edx, dword_5129B4
    mov     eax, [esp+54h+var_2C]
    add     esp, 18h
    lea     ecx, [esp+3Ch+var_14]
    mov     [edx+ebp+52h], eax
    mov     eax, TAdynmemStructPtr
    push    ecx
    mov     edx, [eax+1439Bh]
    mov     ecx, [eax+2A30h]
    add     edx, edi
    push    edx
    call    sub_46E330
    mov     ecx, [esp+3Ch+var_8]
    cmp     ecx, 0FFFFFFFFh
    jnz     short loc_44CB02
    mov     ecx, 65h

    loc_44CB02:                             ; CODE XREF: sub_44C7E0+31Bj
    mov     eax, dword_5129B4
    mov     [eax+ebp+5Ah], ecx
    mov     edx, dword_5129C4
    mov     eax, [esp+3Ch+var_28]
    mov     [edx+eax*4], ecx
    mov     edx, dword_5129B4
    movsx   ecx, [esp+3Ch+var_A]
    inc     eax
    mov     [edx+ebp+5Eh], ecx
    mov     [esp+3Ch+var_28], eax
    mov     eax, TAdynmemStructPtr
    add     ebp, 62h

    loc_44CB34:                             ; CODE XREF: sub_44C7E0+289j
                                            ; sub_44C7E0+294j
    mov     ecx, [esp+3Ch+var_2C]
    mov     edx, [eax+1438Fh]
    inc     ecx
    add     edi, 249h
    cmp     ecx, edx
    mov     [esp+3Ch+var_2C], ecx
    jl      loc_44CA53
    mov     ebp, [esp+3Ch+var_24]
    mov     esi, [esp+3Ch+var_20]

    loc_44CB59:                             ; CODE XREF: sub_44C7E0+266j
    mov     eax, [esp+3Ch+var_28]
    mov     ecx, dword_5129B4
    push    offset sub_44C7A0               ; int __cdecl (*)(const void *,const void *)
    push    62h                             ; size_t
    push    eax                             ; size_t
    push    ecx                             ; void *
    call    _qsort
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    mov     edx, esi
    mov     [esp+3Ch+var_2C], 0
    mov     ecx, [eax+1438Fh]
    test    ecx, ecx
    jle     short loc_44CBEA
    mov     esi, dword_5129B4
    xor     ebp, ebp

    loc_44CB95:                             ; CODE XREF: sub_44C7E0+404j
    lea     edi, [esi+ebp]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     esi, dword_5129B4
    or      ecx, 0FFFFFFFFh
    lea     edi, [esi+ebp]
    add     ebp, 62h
    repne scasb
    mov     eax, [esp+3Ch+var_2C]
    not     ecx
    dec     ecx
    inc     eax
    mov     [esp+3Ch+var_2C], eax
    lea     edx, [edx+ecx+1]
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+1438Fh]
    jl      short loc_44CB95
    mov     ebp, [esp+3Ch+var_24]

    loc_44CBEA:                             ; CODE XREF: sub_44C7E0+3ABj
    xor     esi, esi
    mov     edi, offset sub_44BE70

    loc_44CBF1:                             ; CODE XREF: sub_44C7E0+449j
    push    esi
    lea     edx, [esp+40h+var_14]
    push    offset aSliderD                 ; "SLIDER%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+3Ch+var_14]
    push    eax                             ; char *
    push    ebp                             ; int
    call    sub_4A0200
    inc     esi
    mov     [eax+14Ah], eax
    cmp     esi, 0Ch
    mov     dword ptr [eax+13Ch], 65h
    mov     [eax+144h], edi
    jl      short loc_44CBF1
    mov     ecx, TAdynmemStructPtr
    push    0Eh
    push    offset aScrollslider            ; char *
    mov     edx, [ecx+531h]
    lea     esi, [ecx+519h]
    mov     ebp, [edx+4]
    push    ebp                             ; int
    call    sub_49FDF0
    mov     edi, eax
    cmp     edi, 0FFFFFFFFh
    jz      short loc_44CC91
    push    offset aScrollslider            ; char *
    push    ebp                             ; int
    call    sub_4A0200
    mov     ebp, eax
    push    0
    push    ebp
    mov     dword ptr [ebp+13Ch], 0D2h
    mov     dword ptr [ebp+144h], offset sub_44BFD0
    mov     word ptr [ebp+140h], 0
    call    sub_45B9B0
    mov     eax, TAdynmemStructPtr
    mov     [ebp+14Ah], eax

    loc_44CC91:                             ; CODE XREF: sub_44C7E0+472j
    push    edi
    push    esi
    call    sub_44BFD0
    push    esi                             ; int
    call    sub_49FA90
    mov     edx, TAdynmemStructPtr
    push    0
    mov     esi, [esp+44h+var_2C]
    mov     ecx, [esp+44h+var_24]
    push    esi
    push    ecx
    add     edx, 519h
    push    offset aDesclist                ; "DESCLIST"
    push    edx
    call    sub_4A32A0
    mov     ecx, TAdynmemStructPtr
    push    esi                             ; int
    mov     eax, [esp+44h+var_20]
    mov     edx, [ecx+531h]
    push    eax                             ; int
    push    offset aPiclist                 ; char *
    push    edx                             ; int
    call    sub_4A35A0
    mov     eax, TAdynmemStructPtr
    push    0
    add     eax, 519h
    push    eax
    call    sub_44BFD0
    movsx   eax, word ptr [ebx+0BAh]
    mov     edx, TAdynmemStructPtr
    lea     ecx, [eax+eax*2]
    shl     ecx, 4
    add     ecx, eax
    mov     eax, [ebx+0D2h]
    mov     ebx, [edx+1439Bh]
    lea     edi, [edx+519h]
    mov     ecx, [eax+ecx*2+52h]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     esi, [eax+eax*8]
    add     esi, ebx
    fld     dword ptr [esi+186h]
    call    __ftol
    push    eax
    lea     ecx, [esp+44h+var_18]
    push    offset aD_0                     ; "%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+40h+var_18]
    push    0
    push    edx
    push    offset aEnergytext              ; "ENERGYTEXT"
    push    edi
    call    sub_4A0BF0
    fld     dword ptr [esi+18Ah]
    call    __ftol
    push    eax
    lea     eax, [esp+44h+var_18]
    push    offset aD_0                     ; "%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+40h+var_18]
    push    0
    push    ecx
    push    offset aMetaltext               ; "METALTEXT"
    push    edi
    call    sub_4A0BF0
    xor     edx, edx
    mov     eax, [esp+40h+var_1C]
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    setz    dl
    mov     esi, edx
    add     eax, 519h
    push    esi                             ; char
    push    offset aLoad_0                  ; char *
    push    eax                             ; int
    call    sub_4A1250
    mov     ecx, TAdynmemStructPtr
    push    esi                             ; char
    add     ecx, 519h
    push    offset aSave                    ; char *
    push    ecx                             ; int
    call    sub_4A1250
    mov     edx, TAdynmemStructPtr
    push    esi                             ; char
    add     edx, 519h
    push    offset aReset                   ; char *
    push    edx                             ; int
    call    sub_4A1250
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    pop     edi
    pop     esi
    pop     ebp
    mov     dword_5129C0, 0
    pop     ebx
    add     esp, 2Ch
    retn
    sub_44C7E0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, ecx
    mov     ecx, [esp+4]
    mov     dword ptr [eax], offset off_4FD2F8
    mov     [eax+4], ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION unknown_libname_13. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44CE50 proc near                    ; DATA XREF: .rdata:004FD2F8o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD2F8
    jz      short loc_44CE6A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44CE6A:                             ; CODE XREF: sub_44CE50+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_44CE50 endp

    ; ---------------------------------------------------------------------------
    mov     eax, ecx
    mov     dword ptr [eax], offset off_4FD2F8
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44CE80 proc near                    ; DATA XREF: .rdata:004FD2FCo
    xor     eax, eax
    retn    0Ch
    sub_44CE80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44CE90 proc near                    ; DATA XREF: .rdata:004FD310o
                                            ; .rdata:004FD3D0o ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    mov     edx, [esi+8]
    mov     ecx, [esi+4]
    cmp     edx, edx
    mov     eax, edx
    jz      short loc_44CEB1
    push    edi

    loc_44CEA2:                             ; CODE XREF: sub_44CE90+1Ej
    mov     edi, [eax]
    add     eax, 4
    mov     [ecx], edi
    add     ecx, 4
    cmp     eax, edx
    jnz     short loc_44CEA2
    pop     edi

    loc_44CEB1:                             ; CODE XREF: sub_44CE90+Fj
    mov     eax, [esi+8]
    mov     [esi+8], ecx
    mov     [esp+arg_0], eax
    pop     esi
    retn    4
    sub_44CE90 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000005 BYTES: COLLAPSED FUNCTION unknown_libname_14. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44CED0 proc near                    ; CODE XREF: sub_40E630+128p
                                            ; sub_40E630+175p ...

    arg_0= dword ptr  4

    mov     eax, [ecx+4]
    test    eax, eax
    jz      short locret_44CEE3
    mov     ecx, [esp+arg_0]
    mov     edx, [eax+4Eh]
    or      edx, ecx
    mov     [eax+4Eh], edx

    locret_44CEE3:                          ; CODE XREF: sub_44CED0+5j
    retn    4
    sub_44CED0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_15. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44CF00 proc near                    ; DATA XREF: .rdata:004FD308o
                                            ; .rdata:004FD398o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, [ecx]
    push    esi
    movsx   esi, word ptr [eax+78h]
    movsx   eax, word ptr [eax+76h]
    push    esi
    push    eax
    call    dword ptr [edx+14h]
    pop     esi
    retn    4
    sub_44CF00 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000005 BYTES: COLLAPSED FUNCTION unknown_libname_16. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION unknown_libname_17. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44CF40 proc near                    ; DATA XREF: .rdata:004FD31Co
                                            ; .rdata:004FD34Co ...
    xor     eax, eax
    retn    4
    sub_44CF40 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_62. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44CF60 proc near                    ; CODE XREF: sub_438930+39p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    push    ecx
    mov     eax, [esp+4+arg_0]
    mov     dword ptr [ecx], offset off_4FD328
    mov     [ecx+4], eax
    mov     eax, [eax+0Eh]
    mov     eax, [eax+7Eh]
    movsx   edx, ax
    mov     [esp+4+var_4], eax
    mov     eax, [esp+4+arg_4]
    shl     edx, 13h
    sub     eax, edx
    movsx   edx, word ptr [esp+4+var_4+2]
    add     eax, 80000h
    sar     eax, 14h
    mov     word ptr [esp+4+arg_0], ax
    mov     eax, [esp+4+arg_8]
    shl     edx, 13h
    sub     eax, edx
    add     eax, 80000h
    sar     eax, 14h
    mov     word ptr [esp+4+arg_0+2], ax
    mov     edx, [esp+4+arg_0]
    mov     eax, [esp+4+arg_C]
    mov     [ecx+8], edx
    mov     [ecx+0Ch], eax
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4
    mov     edx, eax
    imul    edx, eax
    mov     [ecx+10h], edx
    mov     eax, ecx
    pop     ecx
    retn    10h
    sub_44CF60 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION __RTC_NumErrors. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44CFF0 proc near                    ; DATA XREF: .rdata:004FD328o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD2F8
    jz      short loc_44D00A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44D00A:                             ; CODE XREF: sub_44CFF0+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_44CFF0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D010 proc near                    ; CODE XREF: sub_43A420+453p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    sub     esp, 10h
    push    esi
    mov     esi, ecx
    xor     ecx, ecx
    push    edi
    mov     edi, [esp+18h+arg_4]
    mov     [esi+4], eax
    test    eax, eax
    mov     dword ptr [esi], offset off_4FD328
    jz      short loc_44D032
    test    edi, edi
    jnz     short loc_44D037

    loc_44D032:                             ; CODE XREF: sub_44D010+1Cj
    mov     ecx, 1

    loc_44D037:                             ; CODE XREF: sub_44D010+20j
    mov     eax, [esp+18h+arg_8]
    test    eax, eax
    jnz     short loc_44D044
    mov     ecx, 1

    loc_44D044:                             ; CODE XREF: sub_44D010+2Dj
    test    ecx, ecx
    jnz     short loc_44D081
    push    eax
    mov     ecx, edi
    call    sub_4B4BA0
    push    0
    mov     ecx, edi
    call    sub_4B4C10
    lea     eax, [esp+18h+var_10]
    push    10h
    push    eax
    mov     ecx, edi
    call    sub_4B4C80
    cmp     eax, 10h
    jnz     short loc_44D081
    mov     ecx, [esp+18h+var_C]
    mov     edx, [esp+18h+var_8]
    mov     eax, [esp+18h+var_4]
    mov     [esi+8], ecx
    mov     [esi+0Ch], edx
    mov     [esi+10h], eax

    loc_44D081:                             ; CODE XREF: sub_44D010+36j
                                            ; sub_44D010+5Aj
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 10h
    retn    0Ch
    sub_44D010 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D090 proc near                    ; DATA XREF: .rdata:004FD32Co

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 10h
    mov     eax, [ecx+8]
    mov     edx, [ecx+0Ch]
    mov     [esp+10h+var_C], eax
    mov     eax, [ecx+10h]
    mov     ecx, [esp+10h+arg_8]
    push    esi
    mov     esi, [esp+14h+arg_4]
    push    ecx
    mov     ecx, esi
    mov     [esp+18h+var_8], edx
    mov     [esp+18h+var_4], eax
    call    sub_4B4BA0
    push    0
    mov     ecx, esi
    call    sub_4B4C10
    lea     edx, [esp+14h+var_10]
    push    10h
    push    edx
    mov     ecx, esi
    call    sub_4B4CF0
    mov     eax, 1
    pop     esi
    add     esp, 10h
    retn    0Ch
    sub_44D090 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D0E0 proc near                    ; DATA XREF: .rdata:004FD340o

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+14h+arg_0]
    mov     ebp, 4
    mov     edx, [edi+8]
    mov     esi, [edi+4]
    cmp     edx, edx
    mov     eax, edx
    jz      short loc_44D106

    loc_44D0FA:                             ; CODE XREF: sub_44D0E0+24j
    mov     ebx, [eax]
    add     eax, ebp
    mov     [esi], ebx
    add     esi, ebp
    cmp     eax, edx
    jnz     short loc_44D0FA

    loc_44D106:                             ; CODE XREF: sub_44D0E0+18j
    mov     eax, [edi+8]
    lea     ebx, [ecx+8]
    mov     ecx, [edi+0Ch]
    mov     [esp+14h+arg_0], eax
    sub     ecx, esi
    mov     [edi+8], esi
    sar     ecx, 2
    cmp     ecx, 1
    mov     [esp+14h+arg_0], ebx
    jnb     loc_44D1EE
    mov     edx, [edi+4]
    test    edx, edx
    jnz     short loc_44D133
    xor     eax, eax
    jmp     short loc_44D13A
    ; ---------------------------------------------------------------------------

    loc_44D133:                             ; CODE XREF: sub_44D0E0+4Dj
    mov     eax, esi
    sub     eax, edx
    sar     eax, 2

    loc_44D13A:                             ; CODE XREF: sub_44D0E0+51j
    cmp     eax, 1
    jbe     short loc_44D150
    test    edx, edx
    jnz     short loc_44D147
    xor     ecx, ecx
    jmp     short loc_44D155
    ; ---------------------------------------------------------------------------

    loc_44D147:                             ; CODE XREF: sub_44D0E0+61j
    mov     ecx, esi
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_44D155
    ; ---------------------------------------------------------------------------

    loc_44D150:                             ; CODE XREF: sub_44D0E0+5Dj
    mov     ecx, 1

    loc_44D155:                             ; CODE XREF: sub_44D0E0+65j
                                            ; sub_44D0E0+6Ej
    test    edx, edx
    jnz     short loc_44D15D
    xor     eax, eax
    jmp     short loc_44D164
    ; ---------------------------------------------------------------------------

    loc_44D15D:                             ; CODE XREF: sub_44D0E0+77j
    mov     eax, esi
    sub     eax, edx
    sar     eax, 2

    loc_44D164:                             ; CODE XREF: sub_44D0E0+7Bj
    add     eax, ecx
    test    eax, eax
    mov     [esp+14h+var_4], eax
    jge     short loc_44D170
    xor     eax, eax

    loc_44D170:                             ; CODE XREF: sub_44D0E0+8Cj
    lea     edx, ds:0[eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     ebx, eax
    mov     eax, [edi+4]
    mov     ecx, edi
    push    ebx
    push    esi
    push    eax
    call    sub_44EE90
    mov     ecx, [esp+14h+arg_0]
    mov     ebp, eax
    push    ecx
    push    1
    push    ebp
    mov     ecx, edi
    call    sub_44EEC0
    mov     edx, [edi+8]
    add     ebp, 4
    push    ebp
    push    edx
    push    esi
    mov     ecx, edi
    call    sub_44EE90
    mov     eax, [edi+8]
    mov     ecx, [edi+4]
    push    eax
    push    ecx
    mov     ecx, edi
    call    nullsub_47
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+18h+var_4]
    add     esp, 4
    mov     ecx, edi
    lea     eax, [ebx+edx*4]
    mov     [edi+0Ch], eax
    call    sub_44EE70
    lea     ecx, [ebx+eax*4+4]
    mov     [edi+4], ebx
    mov     [edi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44D1EE:                             ; CODE XREF: sub_44D0E0+42j
    xor     dl, dl
    cmp     dl, 1
    jnb     short loc_44D23B
    lea     eax, [esi+4]
    mov     ecx, edi
    push    eax
    push    esi
    push    esi
    call    sub_44EE90
    mov     eax, [edi+8]
    mov     edx, 1
    mov     ecx, eax
    push    ebx
    sub     ecx, esi
    sar     ecx, 2
    sub     edx, ecx
    mov     ecx, edi
    push    edx
    push    eax
    call    sub_44EEC0
    mov     ecx, [edi+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_44D271

    loc_44D226:                             ; CODE XREF: sub_44D0E0+14Ej
    mov     edx, [ebx]
    mov     [eax], edx
    add     eax, ebp
    cmp     eax, ecx
    jnz     short loc_44D226
    add     [edi+8], ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44D23B:                             ; CODE XREF: sub_44D0E0+113j
    push    esi
    lea     eax, [esi-4]
    push    esi
    push    eax
    mov     ecx, edi
    call    sub_44EE90
    mov     ecx, [edi+8]
    lea     eax, [ecx-4]
    cmp     esi, eax
    jz      short loc_44D25E

    loc_44D252:                             ; CODE XREF: sub_44D0E0+17Cj
    sub     eax, ebp
    sub     ecx, ebp
    cmp     eax, esi
    mov     edx, [eax]
    mov     [ecx], edx
    jnz     short loc_44D252

    loc_44D25E:                             ; CODE XREF: sub_44D0E0+170j
    lea     ecx, [esi+4]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_44D271

    loc_44D267:                             ; CODE XREF: sub_44D0E0+18Fj
    mov     edx, [ebx]
    mov     [eax], edx
    add     eax, ebp
    cmp     eax, ecx
    jnz     short loc_44D267

    loc_44D271:                             ; CODE XREF: sub_44D0E0+144j
                                            ; sub_44D0E0+185j
    mov     eax, [edi+8]
    add     eax, ebp
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_44D0E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D290 proc near                    ; DATA XREF: .rdata:004FD33Co

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    movsx   edx, word ptr [ecx+0Ah]
    mov     eax, [esp+arg_4]
    push    esi
    movsx   esi, word ptr [ecx+8]
    sub     eax, edx
    mov     edx, [esp+4+arg_0]
    sub     edx, esi
    mov     esi, edx
    imul    esi, edx
    mov     edx, eax
    imul    edx, eax
    add     esi, edx
    mov     edx, [ecx+10h]
    xor     eax, eax
    cmp     esi, edx
    setle   al
    pop     esi
    retn    8
    sub_44D290 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D2C0 proc near                    ; DATA XREF: .rdata:004FD348o

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    mov     eax, [ecx+4]
    mov     ecx, [ecx+8]
    mov     [esp+8+var_8], ecx
    mov     edx, [eax+0Eh]
    movsx   ecx, cx
    mov     eax, [edx+7Eh]
    movsx   edx, ax
    mov     [esp+8+var_4], eax
    mov     eax, [esp+8+arg_0]
    lea     ecx, [edx+ecx*2]
    movsx   edx, word ptr [esp+8+var_8+2]
    shl     ecx, 13h
    mov     [eax], ecx
    movsx   ecx, word ptr [esp+8+var_4+2]
    lea     edx, [ecx+edx*2]
    shl     edx, 13h
    mov     [eax+8], edx
    mov     eax, 1
    add     esp, 8
    retn    4
    sub_44D2C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D310 proc near                    ; DATA XREF: .rdata:004FD338o

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    esi
    movsx   esi, word ptr [ecx+0Ah]
    movsx   eax, word ptr [edx+78h]
    movsx   edx, word ptr [edx+76h]
    sub     eax, esi
    movsx   esi, word ptr [ecx+8]
    sub     edx, esi
    mov     esi, edx
    imul    esi, edx
    mov     edx, eax
    imul    edx, eax
    add     esi, edx
    mov     edx, [ecx+10h]
    xor     eax, eax
    cmp     esi, edx
    setle   al
    pop     esi
    retn    4
    sub_44D310 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D350 proc near                    ; DATA XREF: .rdata:004FD344o

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    movsx   edx, word ptr [ecx+8]
    mov     eax, [esp+arg_0]
    push    esi
    sub     eax, edx
    cdq
    mov     esi, eax
    mov     eax, [esp+4+arg_4]
    xor     esi, edx
    sub     esi, edx
    movsx   edx, word ptr [ecx+0Ah]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     esi, eax
    jle     short loc_44D384
    lea     edx, [esi+esi*8]
    mov     esi, eax
    shl     esi, 3
    sub     esi, eax
    lea     eax, [esi+edx*2]
    jmp     short loc_44D391
    ; ---------------------------------------------------------------------------

    loc_44D384:                             ; CODE XREF: sub_44D350+23j
    mov     edx, esi
    lea     eax, [eax+eax*8]
    shl     edx, 3
    sub     edx, esi
    lea     eax, [edx+eax*2]

    loc_44D391:                             ; CODE XREF: sub_44D350+32j
    mov     ecx, [ecx+0Ch]
    cmp     eax, ecx
    jge     short loc_44D39E
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44D39E:                             ; CODE XREF: sub_44D350+46j
    sub     eax, ecx
    pop     esi
    retn    8
    sub_44D350 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D3B0 proc near                    ; CODE XREF: sub_438A00+42p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    push    ecx
    mov     eax, [esp+4+arg_0]
    mov     dword ptr [ecx], offset off_4FD358
    mov     [ecx+4], eax
    push    esi
    mov     eax, [eax+0Eh]
    mov     esi, [esp+8+arg_10]
    mov     eax, [eax+7Eh]
    mov     [ecx+0Ch], esi
    movsx   edx, ax
    mov     [esp+8+var_4], eax
    mov     eax, [esp+8+arg_4]
    shl     edx, 13h
    sub     eax, edx
    movsx   edx, word ptr [esp+8+var_4+2]
    add     eax, 80000h
    sar     eax, 14h
    mov     word ptr [esp+8+arg_0], ax
    mov     eax, [esp+8+arg_8]
    shl     edx, 13h
    sub     eax, edx
    add     eax, 80000h
    sar     eax, 14h
    mov     word ptr [esp+8+arg_0+2], ax
    mov     edx, [esp+8+arg_0]
    mov     eax, [esp+8+arg_C]
    mov     [ecx+8], edx
    mov     [ecx+10h], eax
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4
    mov     edx, eax
    imul    edx, eax
    mov     eax, esi
    mov     [ecx+18h], edx
    cdq
    and     edx, 0Fh
    pop     esi
    add     eax, edx
    sar     eax, 4
    mov     edx, eax
    imul    edx, eax
    mov     [ecx+14h], edx
    mov     eax, ecx
    pop     ecx
    retn    14h
    sub_44D3B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D440 proc near                    ; DATA XREF: .rdata:004FD360o
    mov     eax, 5
    retn
    sub_44D440 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D450 proc near                    ; DATA XREF: .rdata:004FD358o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD2F8
    jz      short loc_44D46A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44D46A:                             ; CODE XREF: sub_44D450+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_44D450 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D470 proc near                    ; CODE XREF: sub_43A420+481p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    sub     esp, 18h
    push    esi
    mov     esi, ecx
    xor     ecx, ecx
    push    edi
    mov     edi, [esp+20h+arg_4]
    mov     [esi+4], eax
    test    eax, eax
    mov     dword ptr [esi], offset off_4FD358
    jz      short loc_44D492
    test    edi, edi
    jnz     short loc_44D497

    loc_44D492:                             ; CODE XREF: sub_44D470+1Cj
    mov     ecx, 1

    loc_44D497:                             ; CODE XREF: sub_44D470+20j
    mov     eax, [esp+20h+arg_8]
    test    eax, eax
    jnz     short loc_44D4A4
    mov     ecx, 1

    loc_44D4A4:                             ; CODE XREF: sub_44D470+2Dj
    test    ecx, ecx
    jnz     short loc_44D4EF
    push    eax
    mov     ecx, edi
    call    sub_4B4BA0
    push    0
    mov     ecx, edi
    call    sub_4B4C10
    lea     eax, [esp+20h+var_18]
    push    18h
    push    eax
    mov     ecx, edi
    call    sub_4B4C80
    cmp     eax, 18h
    jnz     short loc_44D4EF
    mov     ecx, [esp+20h+var_14]
    mov     edx, [esp+20h+var_10]
    mov     eax, [esp+20h+var_C]
    mov     [esi+8], ecx
    mov     ecx, [esp+20h+var_8]
    mov     [esi+0Ch], edx
    mov     edx, [esp+20h+var_4]
    mov     [esi+10h], eax
    mov     [esi+14h], ecx
    mov     [esi+18h], edx

    loc_44D4EF:                             ; CODE XREF: sub_44D470+36j
                                            ; sub_44D470+5Aj
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 18h
    retn    0Ch
    sub_44D470 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D500 proc near                    ; DATA XREF: .rdata:004FD35Co

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 18h
    mov     eax, [ecx+8]
    mov     edx, [ecx+0Ch]
    mov     [esp+18h+var_14], eax
    mov     eax, [ecx+10h]
    mov     [esp+18h+var_10], edx
    mov     edx, [ecx+14h]
    mov     [esp+18h+var_C], eax
    mov     eax, [ecx+18h]
    mov     ecx, [esp+18h+arg_8]
    push    esi
    mov     esi, [esp+1Ch+arg_4]
    push    ecx
    mov     ecx, esi
    mov     [esp+20h+var_8], edx
    mov     [esp+20h+var_4], eax
    call    sub_4B4BA0
    push    0
    mov     ecx, esi
    call    sub_4B4C10
    lea     edx, [esp+1Ch+var_18]
    push    18h
    push    edx
    mov     ecx, esi
    call    sub_4B4CF0
    mov     eax, 1
    pop     esi
    add     esp, 18h
    retn    0Ch
    sub_44D500 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D560 proc near                    ; DATA XREF: .rdata:004FD370o

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+14h+arg_0]
    mov     ebx, 4
    mov     edx, [edi+8]
    mov     esi, [edi+4]
    cmp     edx, edx
    mov     eax, edx
    jz      short loc_44D586

    loc_44D57A:                             ; CODE XREF: sub_44D560+24j
    mov     ebp, [eax]
    add     eax, ebx
    mov     [esi], ebp
    add     esi, ebx
    cmp     eax, edx
    jnz     short loc_44D57A

    loc_44D586:                             ; CODE XREF: sub_44D560+18j
    mov     eax, [edi+8]
    mov     [edi+8], esi
    mov     edx, [ecx+8]
    mov     [esp+14h+arg_0], eax
    mov     eax, [ecx+10h]
    mov     [esp+14h+arg_0], edx
    add     eax, [ecx+0Ch]
    cdq
    and     edx, 1Fh
    add     eax, edx
    sar     eax, 5
    add     word ptr [esp+14h+arg_0+2], ax
    mov     eax, [edi+0Ch]
    sub     eax, esi
    sar     eax, 2
    cmp     eax, 1
    jnb     loc_44D682
    mov     edx, [edi+4]
    test    edx, edx
    jnz     short loc_44D5C7
    xor     eax, eax
    jmp     short loc_44D5CE
    ; ---------------------------------------------------------------------------

    loc_44D5C7:                             ; CODE XREF: sub_44D560+61j
    mov     eax, esi
    sub     eax, edx
    sar     eax, 2

    loc_44D5CE:                             ; CODE XREF: sub_44D560+65j
    cmp     eax, 1
    jbe     short loc_44D5E4
    test    edx, edx
    jnz     short loc_44D5DB
    xor     ecx, ecx
    jmp     short loc_44D5E9
    ; ---------------------------------------------------------------------------

    loc_44D5DB:                             ; CODE XREF: sub_44D560+75j
    mov     ecx, esi
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_44D5E9
    ; ---------------------------------------------------------------------------

    loc_44D5E4:                             ; CODE XREF: sub_44D560+71j
    mov     ecx, 1

    loc_44D5E9:                             ; CODE XREF: sub_44D560+79j
                                            ; sub_44D560+82j
    test    edx, edx
    jnz     short loc_44D5F1
    xor     eax, eax
    jmp     short loc_44D5F8
    ; ---------------------------------------------------------------------------

    loc_44D5F1:                             ; CODE XREF: sub_44D560+8Bj
    mov     eax, esi
    sub     eax, edx
    sar     eax, 2

    loc_44D5F8:                             ; CODE XREF: sub_44D560+8Fj
    add     eax, ecx
    test    eax, eax
    mov     [esp+14h+var_4], eax
    jge     short loc_44D604
    xor     eax, eax

    loc_44D604:                             ; CODE XREF: sub_44D560+A0j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     edx, [edi+4]
    add     esp, 4
    mov     ebx, eax
    mov     ecx, edi
    push    ebx
    push    esi
    push    edx
    call    sub_44EE90
    mov     ebp, eax
    lea     eax, [esp+14h+arg_0]
    push    eax
    push    1
    push    ebp
    mov     ecx, edi
    call    sub_44EEC0
    mov     ecx, [edi+8]
    add     ebp, 4
    push    ebp
    push    ecx
    push    esi
    mov     ecx, edi
    call    sub_44EE90
    mov     edx, [edi+8]
    mov     eax, [edi+4]
    push    edx
    push    eax
    mov     ecx, edi
    call    nullsub_47
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     ecx, [esp+18h+var_4]
    add     esp, 4
    lea     edx, [ebx+ecx*4]
    mov     ecx, edi
    mov     [edi+0Ch], edx
    call    sub_44EE70
    lea     eax, [ebx+eax*4+4]
    mov     [edi+4], ebx
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44D682:                             ; CODE XREF: sub_44D560+56j
    xor     cl, cl
    cmp     cl, 1
    jnb     short loc_44D6D5
    lea     edx, [esi+4]
    mov     ecx, edi
    push    edx
    push    esi
    push    esi
    call    sub_44EE90
    mov     eax, [edi+8]
    lea     ecx, [esp+14h+arg_0]
    mov     edx, eax
    push    ecx
    sub     edx, esi
    mov     ecx, 1
    sar     edx, 2
    sub     ecx, edx
    push    ecx
    push    eax
    mov     ecx, edi
    call    sub_44EEC0
    mov     ecx, [edi+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_44D70D

    loc_44D6BE:                             ; CODE XREF: sub_44D560+168j
    mov     edx, [esp+14h+arg_0]
    mov     [eax], edx
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_44D6BE
    add     [edi+8], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44D6D5:                             ; CODE XREF: sub_44D560+127j
    push    esi
    lea     eax, [esi-4]
    push    esi
    push    eax
    mov     ecx, edi
    call    sub_44EE90
    mov     ecx, [edi+8]
    lea     eax, [ecx-4]
    cmp     esi, eax
    jz      short loc_44D6F8

    loc_44D6EC:                             ; CODE XREF: sub_44D560+196j
    sub     eax, ebx
    sub     ecx, ebx
    cmp     eax, esi
    mov     edx, [eax]
    mov     [ecx], edx
    jnz     short loc_44D6EC

    loc_44D6F8:                             ; CODE XREF: sub_44D560+18Aj
    lea     ecx, [esi+4]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_44D70D

    loc_44D701:                             ; CODE XREF: sub_44D560+1ABj
    mov     edx, [esp+14h+arg_0]
    mov     [eax], edx
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_44D701

    loc_44D70D:                             ; CODE XREF: sub_44D560+15Cj
                                            ; sub_44D560+19Fj
    mov     eax, [edi+8]
    add     eax, ebx
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_44D560 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D720 proc near                    ; DATA XREF: .rdata:004FD378o

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     esi, [esp+18h+arg_0]
    push    esi
    mov     eax, [edi+4]
    mov     edx, [edi+8]
    mov     [esp+1Ch+var_8], edx
    mov     eax, [eax+0Eh]
    movsx   edx, dx
    mov     ecx, [eax+7Eh]
    add     eax, 6Ah
    mov     [esp+1Ch+var_4], ecx
    push    eax
    movsx   ecx, cx
    lea     edx, [ecx+edx*2]
    movsx   ecx, word ptr [esp+20h+var_8+2]
    shl     edx, 13h
    mov     [esi], edx
    movsx   edx, word ptr [esp+20h+var_4+2]
    lea     ecx, [edx+ecx*2]
    shl     ecx, 13h
    mov     [esi+8], ecx
    call    sub_48A980
    mov     edx, [edi+0Ch]
    mov     ebp, eax
    mov     eax, [edi+10h]
    add     eax, edx
    cdq
    sub     eax, edx
    mov     edi, eax
    sar     edi, 1
    shl     edi, 10h
    push    edi
    push    ebp
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    edi
    push    ebp
    call    sub_4B7123
    mov     edx, [esi]
    mov     ecx, [esi+8]
    sub     edx, ebx
    add     esp, 8
    neg     eax
    mov     [esi], edx
    mov     edx, [esi+4]
    sub     ecx, eax
    mov     [esi+4], edx
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 8
    retn    4
    sub_44D720 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D7C0 proc near                    ; DATA XREF: .rdata:004FD36Co

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    movsx   eax, word ptr [ecx+0Ah]
    mov     edx, [esp+arg_4]
    push    esi
    movsx   esi, word ptr [ecx+8]
    sub     edx, eax
    mov     eax, [esp+4+arg_0]
    sub     eax, esi
    mov     esi, edx
    imul    eax, eax
    imul    esi, edx
    mov     edx, [ecx+18h]
    add     eax, esi
    cmp     eax, edx
    jg      short loc_44D7F4
    cmp     eax, [ecx+14h]
    jl      short loc_44D7F4
    mov     eax, 1
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44D7F4:                             ; CODE XREF: sub_44D7C0+24j
                                            ; sub_44D7C0+29j
    xor     eax, eax
    pop     esi
    retn    8
    sub_44D7C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D800 proc near                    ; DATA XREF: .rdata:004FD368o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    movsx   esi, word ptr [ecx+0Ah]
    movsx   edx, word ptr [eax+78h]
    movsx   eax, word ptr [eax+76h]
    sub     edx, esi
    movsx   esi, word ptr [ecx+8]
    sub     eax, esi
    mov     esi, edx
    imul    eax, eax
    imul    esi, edx
    mov     edx, [ecx+18h]
    add     eax, esi
    cmp     eax, edx
    jg      short loc_44D838
    cmp     eax, [ecx+14h]
    jl      short loc_44D838
    mov     eax, 1
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44D838:                             ; CODE XREF: sub_44D800+28j
                                            ; sub_44D800+2Dj
    xor     eax, eax
    pop     esi
    retn    4
    sub_44D800 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D840 proc near                    ; DATA XREF: .rdata:004FD374o

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    movsx   edx, word ptr [ecx+8]
    mov     eax, [esp+arg_0]
    push    esi
    sub     eax, edx
    cdq
    mov     esi, eax
    mov     eax, [esp+4+arg_4]
    xor     esi, edx
    sub     esi, edx
    movsx   edx, word ptr [ecx+0Ah]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     esi, eax
    jle     short loc_44D871
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    lea     eax, [esi+esi*8]
    jmp     short loc_44D87B
    ; ---------------------------------------------------------------------------

    loc_44D871:                             ; CODE XREF: sub_44D840+23j
    mov     edx, esi
    lea     eax, [eax+eax*8]
    shl     edx, 3
    sub     edx, esi

    loc_44D87B:                             ; CODE XREF: sub_44D840+2Fj
    mov     esi, [ecx+10h]
    lea     edx, [edx+eax*2]
    cmp     edx, esi
    jle     short loc_44D88D
    mov     eax, edx
    sub     eax, esi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44D88D:                             ; CODE XREF: sub_44D840+43j
    mov     eax, [ecx+0Ch]
    cmp     edx, eax
    jge     short loc_44D89A
    sub     eax, edx
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44D89A:                             ; CODE XREF: sub_44D840+52j
    xor     eax, eax
    pop     esi
    retn    8
    sub_44D840 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D8A0 proc near                    ; CODE XREF: sub_438AD0+33p

    arg_0= dword ptr  4
    arg_4= word ptr  8
    arg_6= word ptr  0Ah
    arg_8= word ptr  0Ch
    arg_A= word ptr  0Eh

    movsx   edx, [esp+arg_4]
    mov     eax, ecx
    push    esi
    mov     ecx, [esp+4+arg_0]
    push    edi
    mov     [eax+4], ecx
    mov     dword ptr [eax], offset off_4FD388
    mov     esi, [ecx+0Eh]
    mov     edi, edx
    movsx   esi, word ptr [esi+7Eh]
    sub     edi, esi
    movsx   esi, [esp+8+arg_6]
    mov     [eax+8], edi
    mov     ecx, [ecx+0Eh]
    mov     edi, esi
    movsx   ecx, word ptr [ecx+80h]
    sub     edi, ecx
    movsx   ecx, [esp+8+arg_8]
    add     ecx, edx
    mov     [eax+10h], edi
    movsx   edx, [esp+8+arg_A]
    add     edx, esi
    pop     edi
    mov     [eax+0Ch], ecx
    mov     [eax+14h], edx
    pop     esi
    retn    0Ch
    sub_44D8A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D900 proc near                    ; DATA XREF: .rdata:004FD390o
    mov     eax, 6
    retn
    sub_44D900 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D910 proc near                    ; DATA XREF: .rdata:004FD388o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD2F8
    jz      short loc_44D92A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44D92A:                             ; CODE XREF: sub_44D910+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_44D910 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D930 proc near                    ; CODE XREF: sub_43A420+4AFp

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 14h
    mov     eax, [esp+14h+arg_0]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+18h+arg_8]
    push    edi
    mov     edi, [esp+1Ch+arg_4]
    push    ecx
    mov     ecx, edi
    mov     [esi+4], eax
    mov     dword ptr [esi], offset off_4FD388
    call    sub_4B4BA0
    push    0
    mov     ecx, edi
    call    sub_4B4C10
    lea     edx, [esp+1Ch+var_14]
    push    14h
    push    edx
    mov     ecx, edi
    call    sub_4B4C80
    cmp     eax, 14h
    jnz     short loc_44D98C
    mov     eax, [esp+1Ch+var_10]
    mov     ecx, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+var_8]
    mov     [esi+8], eax
    mov     eax, [esp+1Ch+var_4]
    mov     [esi+0Ch], ecx
    mov     [esi+10h], edx
    mov     [esi+14h], eax

    loc_44D98C:                             ; CODE XREF: sub_44D930+3Ej
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 14h
    retn    0Ch
    sub_44D930 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44D9A0 proc near                    ; DATA XREF: .rdata:004FD38Co

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 14h
    mov     eax, [ecx+8]
    mov     edx, [ecx+0Ch]
    mov     [esp+14h+var_10], eax
    mov     eax, [ecx+10h]
    mov     ecx, [ecx+14h]
    push    esi
    mov     esi, [esp+18h+arg_4]
    mov     [esp+18h+var_C], edx
    mov     edx, [esp+18h+arg_8]
    mov     [esp+18h+var_4], ecx
    push    edx
    mov     ecx, esi
    mov     [esp+1Ch+var_8], eax
    call    sub_4B4BA0
    push    0
    mov     ecx, esi
    call    sub_4B4C10
    lea     eax, [esp+18h+var_14]
    push    14h
    push    eax
    mov     ecx, esi
    call    sub_4B4CF0
    mov     eax, 1
    pop     esi
    add     esp, 14h
    retn    0Ch
    sub_44D9A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44DA00 proc near                    ; DATA XREF: .rdata:004FD3A0o

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 14h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+20h+arg_0]
    mov     ebx, ecx
    push    edi
    mov     ecx, [esi+4]
    mov     eax, [esi+8]
    push    ecx
    push    eax
    push    eax
    mov     [esp+30h+var_4], ebx
    call    sub_44EEF0
    mov     edi, eax
    mov     eax, [esi+8]
    push    eax
    push    edi
    mov     ecx, esi
    call    nullsub_47
    mov     [esi+8], edi
    mov     edi, [ebx+8]
    cmp     edi, [ebx+0Ch]
    jg      short loc_44DA90

    loc_44DA38:                             ; CODE XREF: sub_44DA00+8Ej
    mov     cx, [ebx+10h]
    lea     eax, [esp+24h+var_C]
    mov     word ptr [esp+24h+arg_0+2], cx
    mov     ecx, [esi+8]
    push    eax
    mov     word ptr [esp+28h+arg_0], di
    mov     edx, [esp+28h+arg_0]
    push    1
    push    ecx
    mov     ecx, esi
    mov     [esp+30h+var_C], edx
    call    sub_44EC30
    mov     dx, [ebx+14h]
    lea     ecx, [esp+24h+var_C]
    mov     word ptr [esp+24h+var_14+2], dx
    mov     edx, [esi+8]
    mov     word ptr [esp+24h+var_14], di
    mov     eax, [esp+24h+var_14]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    mov     [esp+30h+var_C], eax
    call    sub_44EC30
    mov     eax, [ebx+0Ch]
    inc     edi
    cmp     edi, eax
    jle     short loc_44DA38

    loc_44DA90:                             ; CODE XREF: sub_44DA00+36j
    mov     ebp, [ebx+10h]
    mov     eax, [ebx+14h]
    inc     ebp
    dec     eax
    cmp     ebp, eax
    mov     [esp+24h+var_C], ebp
    jg      loc_44DC54

    loc_44DAA4:                             ; CODE XREF: sub_44DA00+24Ej
    mov     cx, [ebx+8]
    lea     eax, [esp+24h+arg_0]
    mov     word ptr [esp+24h+var_14], cx
    mov     ecx, [esi+8]
    push    eax
    mov     word ptr [esp+28h+var_14+2], bp
    mov     edx, [esp+28h+var_14]
    push    1
    push    ecx
    mov     ecx, esi
    mov     [esp+30h+arg_0], edx
    call    sub_44EC30
    mov     dx, [ebx+0Ch]
    mov     ecx, [esi+0Ch]
    mov     word ptr [esp+24h+var_10], dx
    mov     word ptr [esp+24h+var_10+2], bp
    mov     eax, [esp+24h+var_10]
    mov     [esp+24h+arg_0], eax
    mov     eax, [esi+8]
    sub     ecx, eax
    mov     edi, eax
    sar     ecx, 2
    cmp     ecx, 1
    jnb     loc_44DBB1
    mov     ecx, [esi+4]
    test    ecx, ecx
    jnz     short loc_44DB03
    xor     eax, eax
    jmp     short loc_44DB08
    ; ---------------------------------------------------------------------------

    loc_44DB03:                             ; CODE XREF: sub_44DA00+FDj
    sub     eax, ecx
    sar     eax, 2

    loc_44DB08:                             ; CODE XREF: sub_44DA00+101j
    cmp     eax, 1
    jbe     short loc_44DB18
    mov     ecx, esi
    call    sub_44EE70
    mov     ebx, eax
    jmp     short loc_44DB1D
    ; ---------------------------------------------------------------------------

    loc_44DB18:                             ; CODE XREF: sub_44DA00+10Bj
    mov     ebx, 1

    loc_44DB1D:                             ; CODE XREF: sub_44DA00+116j
    mov     ecx, esi
    call    sub_44EE70
    add     eax, ebx
    mov     [esp+24h+var_8], eax
    jns     short loc_44DB2E
    xor     eax, eax

    loc_44DB2E:                             ; CODE XREF: sub_44DA00+12Aj
    lea     edx, ds:0[eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     ebx, eax
    mov     eax, [esi+4]
    mov     ecx, esi
    push    ebx
    push    edi
    push    eax
    call    sub_44EE90
    lea     ecx, [esp+24h+arg_0]
    mov     ebp, eax
    push    ecx
    push    1
    push    ebp
    mov     ecx, esi
    call    sub_44EEC0
    mov     edx, [esi+8]
    add     ebp, 4
    push    ebp
    push    edx
    push    edi
    mov     ecx, esi
    call    sub_44EE90
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    eax
    push    ecx
    mov     ecx, esi
    call    nullsub_47
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+28h+var_8]
    add     esp, 4
    mov     ecx, esi
    lea     eax, [ebx+edx*4]
    mov     [esi+0Ch], eax
    call    sub_44EE70
    mov     ebp, [esp+24h+var_C]
    lea     ecx, [ebx+eax*4+4]
    mov     [esi+4], ebx
    mov     ebx, [esp+24h+var_4]
    mov     [esi+8], ecx
    jmp     loc_44DC43
    ; ---------------------------------------------------------------------------

    loc_44DBB1:                             ; CODE XREF: sub_44DA00+F2j
    mov     ecx, eax
    sub     ecx, edi
    sar     ecx, 2
    cmp     ecx, 1
    jnb     short loc_44DC01
    lea     edx, [edi+4]
    mov     ecx, esi
    push    edx
    push    eax
    push    edi
    call    sub_44EE90
    mov     eax, [esi+8]
    lea     ecx, [esp+24h+arg_0]
    mov     edx, eax
    push    ecx
    sub     edx, edi
    mov     ecx, 1
    sar     edx, 2
    sub     ecx, edx
    push    ecx
    push    eax
    mov     ecx, esi
    call    sub_44EEC0
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_44DC3F

    loc_44DBF2:                             ; CODE XREF: sub_44DA00+1FDj
    mov     edx, [esp+24h+arg_0]
    mov     [eax], edx
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_44DBF2
    jmp     short loc_44DC3F
    ; ---------------------------------------------------------------------------

    loc_44DC01:                             ; CODE XREF: sub_44DA00+1BBj
    lea     ecx, [eax-4]
    push    eax
    push    eax
    mov     [esp+2Ch+var_8], ecx
    push    ecx
    mov     ecx, esi
    call    sub_44EE90
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_44DC2B

    loc_44DC1C:                             ; CODE XREF: sub_44DA00+229j
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_44DC1C

    loc_44DC2B:                             ; CODE XREF: sub_44DA00+21Aj
    lea     eax, [edi+4]
    cmp     edi, eax
    jz      short loc_44DC3F

    loc_44DC32:                             ; CODE XREF: sub_44DA00+23Dj
    mov     ecx, [esp+24h+arg_0]
    mov     [edi], ecx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_44DC32

    loc_44DC3F:                             ; CODE XREF: sub_44DA00+1F0j
                                            ; sub_44DA00+1FFj ...
    add     dword ptr [esi+8], 4

    loc_44DC43:                             ; CODE XREF: sub_44DA00+1ACj
    mov     edx, [ebx+14h]
    inc     ebp
    dec     edx
    mov     [esp+24h+var_C], ebp
    cmp     ebp, edx
    jle     loc_44DAA4

    loc_44DC54:                             ; CODE XREF: sub_44DA00+9Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    4
    sub_44DA00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44DC60 proc near                    ; DATA XREF: .rdata:004FD3A8o

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     eax, [ecx+8]
    mov     edx, [ecx+0Ch]
    add     eax, edx
    cdq
    sub     eax, edx
    mov     dx, [ecx+14h]
    mov     ecx, [ecx+4]
    sar     eax, 1
    mov     ecx, [ecx+0Eh]
    movsx   eax, ax
    mov     ecx, [ecx+7Eh]
    mov     [esp+4+var_4], ecx
    movsx   ecx, cx
    movsx   edx, dx
    lea     ecx, [ecx+eax*2]
    mov     eax, [esp+4+arg_0]
    shl     ecx, 13h
    mov     [eax], ecx
    movsx   ecx, word ptr [esp+4+var_4+2]
    lea     edx, [ecx+edx*2]
    shl     edx, 13h
    mov     [eax+8], edx
    mov     eax, 1
    pop     ecx
    retn    4
    sub_44DC60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44DCB0 proc near                    ; DATA XREF: .rdata:004FD39Co

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_0]
    mov     eax, [esp+arg_4]
    push    esi
    mov     esi, [ecx+8]
    cmp     edx, esi
    jz      short loc_44DCC5
    cmp     edx, [ecx+0Ch]
    jnz     short loc_44DCD8

    loc_44DCC5:                             ; CODE XREF: sub_44DCB0+Ej
    cmp     eax, [ecx+10h]
    jl      short loc_44DCDD
    cmp     eax, [ecx+14h]
    jg      short loc_44DCD8
    mov     eax, 1
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44DCD8:                             ; CODE XREF: sub_44DCB0+13j
                                            ; sub_44DCB0+1Dj
    cmp     eax, [ecx+10h]
    jz      short loc_44DCE2

    loc_44DCDD:                             ; CODE XREF: sub_44DCB0+18j
    cmp     eax, [ecx+14h]
    jnz     short loc_44DCF4

    loc_44DCE2:                             ; CODE XREF: sub_44DCB0+2Bj
    cmp     edx, esi
    jl      short loc_44DCF4
    cmp     edx, [ecx+0Ch]
    jg      short loc_44DCF4
    mov     eax, 1
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44DCF4:                             ; CODE XREF: sub_44DCB0+30j
                                            ; sub_44DCB0+34j ...
    xor     eax, eax
    pop     esi
    retn    8
    sub_44DCB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44DD00 proc near                    ; DATA XREF: .rdata:004FD3A4o

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_0]
    push    ebx
    push    ebp
    mov     ebp, [ecx+8]
    push    esi
    cmp     edx, ebp
    push    edi
    jge     short loc_44DD15
    sub     ebp, edx
    mov     eax, ebp
    jmp     short loc_44DD20
    ; ---------------------------------------------------------------------------

    loc_44DD15:                             ; CODE XREF: sub_44DD00+Dj
    mov     edi, [ecx+0Ch]
    cmp     edx, edi
    jle     short loc_44DD60
    sub     edx, edi
    mov     eax, edx

    loc_44DD20:                             ; CODE XREF: sub_44DD00+13j
    mov     edi, [ecx+10h]
    mov     esi, [esp+10h+arg_4]
    cmp     esi, edi
    jge     short loc_44DD31
    sub     edi, esi
    mov     ecx, edi
    jmp     short loc_44DD3C
    ; ---------------------------------------------------------------------------

    loc_44DD31:                             ; CODE XREF: sub_44DD00+29j
    mov     ecx, [ecx+14h]
    cmp     esi, ecx
    jle     short loc_44DDAC
    sub     esi, ecx
    mov     ecx, esi

    loc_44DD3C:                             ; CODE XREF: sub_44DD00+2Fj
    cmp     eax, ecx
    jle     short loc_44DD50
    lea     ecx, [ecx+ecx*2]
    shl     eax, 4
    lea     eax, [eax+ecx*2]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44DD50:                             ; CODE XREF: sub_44DD00+3Ej
    lea     edx, [eax+eax*2]
    shl     ecx, 4
    lea     eax, [ecx+edx*2]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44DD60:                             ; CODE XREF: sub_44DD00+1Aj
    mov     eax, [ecx+10h]
    mov     ebx, [esp+10h+arg_4]
    cmp     ebx, eax
    jge     short loc_44DD77
    sub     eax, ebx
    shl     eax, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44DD77:                             ; CODE XREF: sub_44DD00+69j
    mov     ecx, [ecx+14h]
    cmp     ebx, ecx
    jle     short loc_44DD8C
    mov     eax, ebx
    sub     eax, ecx
    shl     eax, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44DD8C:                             ; CODE XREF: sub_44DD00+7Cj
    mov     esi, edx
    sub     edi, edx
    sub     esi, ebp
    cmp     esi, edi
    jl      short loc_44DD98
    mov     esi, edi

    loc_44DD98:                             ; CODE XREF: sub_44DD00+94j
    mov     edx, ebx
    sub     edx, eax
    mov     eax, ecx
    sub     eax, ebx
    cmp     edx, eax
    jge     short loc_44DDA6
    mov     eax, edx

    loc_44DDA6:                             ; CODE XREF: sub_44DD00+A2j
    cmp     esi, eax
    jge     short loc_44DDAC
    mov     eax, esi

    loc_44DDAC:                             ; CODE XREF: sub_44DD00+36j
                                            ; sub_44DD00+A8j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    shl     eax, 4
    retn    8
    sub_44DD00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44DDC0 proc near                    ; DATA XREF: .rdata:004FD3E0o

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    xor     eax, eax
    push    edi
    mov     ax, [esi+8]
    mov     edi, [esp+4+arg_0]
    push    8
    push    eax
    mov     ecx, edi
    call    sub_415C10
    test    byte ptr [esi+8], 1
    jz      short loc_44DE0F
    movsx   ecx, word ptr [esi+10h]
    push    10h
    push    ecx
    mov     ecx, edi
    call    sub_415C10
    mov     ecx, [esi+1Ah]
    test    ecx, ecx
    jnz     short loc_44DDF7
    xor     eax, eax
    jmp     short loc_44DE00
    ; ---------------------------------------------------------------------------

    loc_44DDF7:                             ; CODE XREF: sub_44DDC0+31j
    xor     eax, eax
    mov     ax, [ecx+0A8h]

    loc_44DE00:                             ; CODE XREF: sub_44DDC0+35j
    and     eax, 0FFFFh
    push    10h
    push    eax
    mov     ecx, edi
    call    sub_415C10

    loc_44DE0F:                             ; CODE XREF: sub_44DDC0+1Cj
    test    byte ptr [esi+8], 10h
    jz      short loc_44DE23
    movsx   edx, word ptr [esi+0Ah]
    push    10h
    push    edx
    mov     ecx, edi
    call    sub_415C10

    loc_44DE23:                             ; CODE XREF: sub_44DDC0+53j
    test    byte ptr [esi+8], 8
    jz      short loc_44DE37
    movsx   eax, word ptr [esi+0Ch]
    push    10h
    push    eax
    mov     ecx, edi
    call    sub_415C10

    loc_44DE37:                             ; CODE XREF: sub_44DDC0+67j
    test    byte ptr [esi+8], 40h
    jz      short loc_44DE4B
    movsx   ecx, word ptr [esi+0Eh]
    push    10h
    push    ecx
    mov     ecx, edi
    call    sub_415C10

    loc_44DE4B:                             ; CODE XREF: sub_44DDC0+7Bj
    test    byte ptr [esi+8], 20h
    jz      short loc_44DE78
    mov     edx, [esi+26h]
    push    20h
    push    edx
    mov     ecx, edi
    call    sub_415C10
    mov     eax, [esi+2Ah]
    push    20h
    push    eax
    mov     ecx, edi
    call    sub_415C10
    mov     ecx, [esi+2Eh]
    push    20h
    push    ecx
    mov     ecx, edi
    call    sub_415C10

    loc_44DE78:                             ; CODE XREF: sub_44DDC0+8Fj
    pop     edi
    pop     esi
    retn    4
    sub_44DDC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44DE80 proc near                    ; CODE XREF: sub_43A420+3F3p

    var_38= dword ptr -38h
    var_2E= dword ptr -2Eh
    var_1E= dword ptr -1Eh
    var_1A= word ptr -1Ah
    var_18= word ptr -18h
    var_16= word ptr -16h
    var_14= word ptr -14h
    var_12= dword ptr -12h
    var_E= dword ptr -0Eh
    var_A= dword ptr -0Ah
    var_6= dword ptr -6
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 38h
    mov     eax, [esp+38h+arg_0]
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    push    0
    push    0
    lea     ebx, [esi+16h]
    mov     dword ptr [esi], offset off_4FD2F8
    mov     ecx, ebx
    mov     [esi+4], eax
    call    sub_4895C0
    push    0
    push    0
    lea     ecx, [esp+4Ch+var_2E]
    mov     dword ptr [esi], offset off_4FD3B8
    call    sub_4895C0
    mov     ecx, [esp+44h+arg_8]
    mov     edi, [esp+44h+arg_4]
    push    ecx
    mov     ecx, edi
    call    sub_4B4BA0
    push    0
    mov     ecx, edi
    call    sub_4B4C10
    lea     edx, [esp+44h+var_38]
    push    36h
    push    edx
    mov     ecx, edi
    call    sub_4B4C80
    cmp     eax, 36h
    jnz     short loc_44DF4E
    mov     eax, [esp+14h]
    push    edi
    push    eax
    call    sub_487080
    mov     ecx, [esp+44h+var_1E]
    push    edi
    push    ecx
    mov     [esi+12h], eax
    call    sub_487080
    push    eax
    mov     ecx, ebx
    call    sub_489690
    mov     dx, word ptr [esp+44h+var_1E+2]
    mov     cx, [esp+44h+var_18]
    mov     ax, [esp+44h+var_1A]
    mov     [esi+8], dx
    mov     dx, [esp+44h+var_16]
    mov     [esi+0Ch], cx
    mov     [esi+0Ah], ax
    mov     ax, [esp+44h+var_14]
    mov     [esi+0Eh], dx
    mov     edx, [esp+44h+var_12]
    lea     ecx, [esi+26h]
    mov     [esi+10h], ax
    mov     eax, [esp+44h+var_E]
    mov     [ecx], edx
    mov     edx, [esp+44h+var_A]
    mov     [ecx+4], eax
    mov     eax, [esp+44h+var_6]
    mov     [esi+32h], eax
    mov     [ecx+8], edx

    loc_44DF4E:                             ; CODE XREF: sub_44DE80+60j
    lea     ecx, [esp+44h+var_2E]
    call    sub_489650
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 38h
    retn    0Ch
    sub_44DE80 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION unknown_libname_18. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44DF80 proc near                    ; DATA XREF: .rdata:004FD3B8o

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    lea     ecx, [esi+16h]
    call    sub_489650
    mov     al, [esp+arg_0]
    mov     dword ptr [esi], offset off_4FD2F8
    test    al, 1
    jz      short loc_44DFA2
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44DFA2:                             ; CODE XREF: sub_44DF80+17j
    mov     eax, esi
    pop     esi
    retn    4
    sub_44DF80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44DFB0 proc near                    ; DATA XREF: .rdata:004FD3BCo

    var_38= dword ptr -38h
    var_30= word ptr -30h
    var_2E= dword ptr -2Eh
    var_1E= word ptr -1Eh
    var_1C= word ptr -1Ch
    var_1A= word ptr -1Ah
    var_18= word ptr -18h
    var_16= word ptr -16h
    var_14= word ptr -14h
    var_12= dword ptr -12h
    var_E= dword ptr -0Eh
    var_A= dword ptr -0Ah
    var_6= dword ptr -6
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 38h
    push    esi
    mov     esi, ecx
    push    0
    push    0
    lea     ecx, [esp+44h+var_2E]
    call    sub_4895C0
    mov     eax, [esi+12h]
    test    eax, eax
    jnz     short loc_44DFD1
    mov     [esp+3Ch+var_30], ax
    jmp     short loc_44DFDD
    ; ---------------------------------------------------------------------------

    loc_44DFD1:                             ; CODE XREF: sub_44DFB0+18j
    mov     ax, [eax+0A8h]
    mov     [esp+3Ch+var_30], ax

    loc_44DFDD:                             ; CODE XREF: sub_44DFB0+1Fj
    mov     eax, [esi+1Ah]
    test    eax, eax
    jnz     short loc_44DFEB
    mov     [esp+3Ch+var_1E], ax
    jmp     short loc_44DFF7
    ; ---------------------------------------------------------------------------

    loc_44DFEB:                             ; CODE XREF: sub_44DFB0+32j
    mov     cx, [eax+0A8h]
    mov     [esp+3Ch+var_1E], cx

    loc_44DFF7:                             ; CODE XREF: sub_44DFB0+39j
    mov     dx, [esi+8]
    mov     cx, [esi+0Ch]
    mov     ax, [esi+0Ah]
    mov     [esp+3Ch+var_1C], dx
    mov     dx, [esi+0Eh]
    mov     [esp+3Ch+var_18], cx
    lea     ecx, [esi+26h]
    mov     [esp+3Ch+var_1A], ax
    mov     ax, [esi+10h]
    mov     [esp+3Ch+var_16], dx
    mov     edx, [ecx]
    mov     [esp+3Ch+var_14], ax
    mov     [esp+3Ch+var_12], edx
    mov     edx, [esi+32h]
    mov     eax, [ecx+4]
    mov     esi, [esp+3Ch+arg_4]
    mov     [esp+3Ch+var_E], eax
    mov     eax, [esp+3Ch+arg_8]
    mov     ecx, [ecx+8]
    push    eax
    mov     [esp+40h+var_A], ecx
    mov     ecx, esi
    mov     [esp+40h+var_6], edx
    call    sub_4B4BA0
    push    0
    mov     ecx, esi
    call    sub_4B4C10
    lea     ecx, [esp+3Ch+var_38]
    push    36h
    push    ecx
    mov     ecx, esi
    call    sub_4B4CF0
    lea     ecx, [esp+3Ch+var_2E]
    call    sub_489650
    mov     eax, 1
    pop     esi
    add     esp, 38h
    retn    0Ch
    sub_44DFB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E080 proc near                    ; CODE XREF: sub_490A10+3Fp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    xor     ebp, ebp
    push    edi
    push    ebp
    lea     ebx, [esi+16h]
    push    ebp
    mov     ecx, ebx
    mov     dword ptr [esi], offset off_4FD2F8
    mov     [esi+4], ebp
    mov     [esi+12h], eax
    call    sub_4895C0
    mov     edi, [esp+10h+arg_4]
    push    8
    mov     ecx, edi
    mov     dword ptr [esi], offset off_4FD3B8
    call    sub_415DC0
    test    al, 1
    mov     [esi+8], ax
    jz      short loc_44E104
    push    10h
    mov     ecx, edi
    call    sub_415DC0
    push    10h
    mov     ecx, edi
    mov     [esi+10h], ax
    call    sub_415DC0
    cmp     ax, bp
    jnz     short loc_44E0DE
    xor     eax, eax
    jmp     short loc_44E0FC
    ; ---------------------------------------------------------------------------

    loc_44E0DE:                             ; CODE XREF: sub_44E080+58j
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, [edx+14357h]
    lea     eax, [eax+ecx*8]

    loc_44E0FC:                             ; CODE XREF: sub_44E080+5Cj
    push    eax
    mov     ecx, ebx
    call    sub_489690

    loc_44E104:                             ; CODE XREF: sub_44E080+3Dj
    test    byte ptr [esi+8], 10h
    jz      short loc_44E119
    push    10h
    mov     ecx, edi
    call    sub_415DC0
    mov     [esi+0Ah], ax
    jmp     short loc_44E11D
    ; ---------------------------------------------------------------------------

    loc_44E119:                             ; CODE XREF: sub_44E080+88j
    mov     [esi+0Ah], bp

    loc_44E11D:                             ; CODE XREF: sub_44E080+97j
    test    byte ptr [esi+8], 8
    jz      short loc_44E132
    push    10h
    mov     ecx, edi
    call    sub_415DC0
    mov     [esi+0Ch], ax
    jmp     short loc_44E136
    ; ---------------------------------------------------------------------------

    loc_44E132:                             ; CODE XREF: sub_44E080+A1j
    mov     [esi+0Ch], bp

    loc_44E136:                             ; CODE XREF: sub_44E080+B0j
    test    byte ptr [esi+8], 40h
    jz      short loc_44E14B
    push    10h
    mov     ecx, edi
    call    sub_415DC0
    mov     [esi+0Eh], ax
    jmp     short loc_44E14F
    ; ---------------------------------------------------------------------------

    loc_44E14B:                             ; CODE XREF: sub_44E080+BAj
    mov     [esi+0Eh], bp

    loc_44E14F:                             ; CODE XREF: sub_44E080+C9j
    test    byte ptr [esi+8], 20h
    jz      short loc_44E179
    push    20h
    mov     ecx, edi
    call    sub_415DC0
    push    20h
    mov     ecx, edi
    mov     [esi+26h], eax
    call    sub_415DC0
    push    20h
    mov     ecx, edi
    mov     [esi+2Ah], eax
    call    sub_415DC0
    mov     [esi+2Eh], eax

    loc_44E179:                             ; CODE XREF: sub_44E080+D3j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_44E080 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E190 proc near                    ; CODE XREF: .text:00411344p
                                            ; .text:00412425p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    edi
    push    0
    lea     edi, [esi+16h]
    push    0
    mov     ecx, edi
    mov     dword ptr [esi], offset off_4FD2F8
    mov     [esi+4], ebx
    call    sub_4895C0
    mov     eax, [esp+8+arg_4]
    mov     ecx, edi
    push    eax
    mov     dword ptr [esi], offset off_4FD3B8
    call    sub_489690
    mov     word ptr [esi+0Ah], 0
    mov     word ptr [esi+0Ch], 0
    mov     eax, [ebx+0Eh]
    lea     ecx, [esi+26h]
    mov     [esi+12h], eax
    add     eax, 6Ah
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     word ptr [esi+10h], 0FFFFh
    mov     [ecx+8], eax
    mov     ecx, [esi+1Ah]
    mov     edx, [ecx+92h]
    mov     eax, [edx+241h]
    shr     eax, 0Bh
    test    al, 1
    jz      short loc_44E239
    mov     ecx, [esi+12h]
    mov     word ptr [esi+8], 7
    mov     edx, [ecx+10h]
    mov     eax, [edx+0DCh]
    test    eax, eax
    jz      short loc_44E22A
    shl     eax, 10h
    mov     [esi+32h], eax
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44E22A:                             ; CODE XREF: sub_44E190+8Aj
    mov     dword ptr [esi+32h], 640000h
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44E239:                             ; CODE XREF: sub_44E190+74j
    mov     word ptr [esi+8], 1
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_44E190 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E250 proc near                    ; CODE XREF: .text:00411442p
                                            ; .text:00411BA6p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= word ptr  0Ch

    mov     ax, [esp+arg_8]
    push    ebx
    mov     ebx, [esp+4+arg_0]
    push    esi
    mov     esi, ecx
    push    edi
    push    0
    push    0
    lea     edi, [esi+16h]
    mov     dword ptr [esi], offset off_4FD2F8
    mov     ecx, edi
    mov     [esi+4], ebx
    mov     [esi+10h], ax
    call    sub_4895C0
    mov     dword ptr [esi], offset off_4FD3B8
    mov     word ptr [esi+0Ah], 0
    mov     word ptr [esi+0Ch], 0
    mov     word ptr [esi+8], 5
    mov     eax, [ebx+0Eh]
    lea     ecx, [esi+26h]
    mov     [esi+12h], eax
    add     eax, 6Ah
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    mov     ecx, [esp+0Ch+arg_4]
    push    ecx
    mov     ecx, edi
    call    sub_489690
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_44E250 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E2D0 proc near                    ; CODE XREF: GameUnit_EndTransport+5Dp
                                            ; GameUnit_EndTransport+195p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, ecx
    push    edi
    mov     edi, [esp+4+arg_0]
    push    0
    push    0
    lea     ecx, [esi+16h]
    mov     dword ptr [esi], offset off_4FD2F8
    mov     [esi+4], edi
    call    sub_4895C0
    mov     ecx, [esp+4+arg_4]
    lea     eax, [esi+26h]
    mov     edx, [ecx]
    mov     [eax], edx
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     ecx, [ecx+8]
    mov     dword ptr [esi], offset off_4FD3B8
    mov     [eax+8], ecx
    mov     word ptr [esi+0Ah], 0
    mov     word ptr [esi+0Ch], 0
    mov     word ptr [esi+10h], 0FFFFh
    mov     word ptr [esi+8], 20h
    mov     edx, [edi+0Eh]
    mov     [esi+12h], edx
    mov     eax, esi
    pop     edi
    pop     esi
    retn    8
    sub_44E2D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E330 proc near                    ; CODE XREF: .text:00413A52p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    edi
    push    0
    lea     edi, [esi+16h]
    push    0
    mov     ecx, edi
    mov     dword ptr [esi], offset off_4FD2F8
    mov     [esi+4], ebx
    call    sub_4895C0
    mov     eax, [esp+8+arg_4]
    mov     ecx, edi
    push    eax
    mov     dword ptr [esi], offset off_4FD3B8
    call    sub_489690
    mov     edx, [esp+8+arg_8]
    lea     ecx, [esi+26h]
    pop     edi
    mov     eax, [edx]
    mov     [ecx], eax
    mov     eax, [edx+4]
    mov     [ecx+4], eax
    mov     edx, [edx+8]
    mov     word ptr [esi+0Ah], 0
    mov     [ecx+8], edx
    mov     word ptr [esi+0Ch], 0
    mov     word ptr [esi+10h], 0FFFFh
    mov     eax, [ebx+0Eh]
    mov     [esi+12h], eax
    mov     word ptr [esi+8], 0A3h
    mov     eax, esi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_44E330 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E3A0 proc near                    ; DATA XREF: .rdata:004FD3E4o
    mov     dl, [ecx+8]
    mov     eax, 1
    test    al, dl
    jz      short loc_44E3B3
    mov     edx, [ecx+1Ah]
    test    edx, edx
    jnz     short locret_44E3B5

    loc_44E3B3:                             ; CODE XREF: sub_44E3A0+Aj
    xor     eax, eax

    locret_44E3B5:                          ; CODE XREF: sub_44E3A0+11j
    retn
    sub_44E3A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E3C0 proc near                    ; DATA XREF: .rdata:004FD3D8o

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4

    sub     esp, 10h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     ax, [esi+8]
    test    al, 1
    jz      loc_44E49A
    test    al, 80h
    jnz     loc_44E49A
    mov     eax, [esi+1Ah]
    test    eax, eax
    jz      loc_44E48E
    mov     edx, TAdynmemStructPtr
    mov     ecx, [eax+82h]
    cmp     ecx, [edx+142B7h]
    jz      loc_44E48E
    movsx   ecx, word ptr [esi+10h]
    push    ecx
    lea     edx, [esp+24h+var_C]
    push    eax
    push    edx
    lea     edi, [esi+26h]
    call    sub_43E060
    mov     edx, [eax]
    mov     ecx, edi
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    mov     cx, [esi+8]
    test    cl, 2
    jz      short loc_44E47D
    mov     edx, [esi+1Ah]
    test    cl, 40h
    mov     ax, [edx+66h]
    mov     [esp+20h+var_10], eax
    jz      short loc_44E448
    mov     cx, [esi+0Eh]
    add     eax, ecx
    mov     [esp+20h+var_10], eax

    loc_44E448:                             ; CODE XREF: sub_44E3C0+7Cj
    mov     ebp, [esi+32h]
    push    ebp
    push    eax
    call    sub_4B70EF
    mov     edx, [esp+28h+var_10]
    add     esp, 8
    mov     ebx, eax
    push    ebp
    push    edx
    neg     ebx
    call    sub_4B7123
    mov     ecx, [edi+4]
    mov     edx, [edi]
    mov     [edi+4], ecx
    mov     ecx, [edi+8]
    neg     eax
    add     esp, 8
    sub     edx, ebx
    sub     ecx, eax
    mov     [edi], edx
    mov     [edi+8], ecx

    loc_44E47D:                             ; CODE XREF: sub_44E3C0+6Cj
    movsx   edx, word ptr [esi+0Ch]
    mov     eax, [esi+2Ah]
    shl     edx, 10h
    add     eax, edx
    mov     [esi+2Ah], eax
    jmp     short loc_44E4EE
    ; ---------------------------------------------------------------------------

    loc_44E48E:                             ; CODE XREF: sub_44E3C0+22j
                                            ; sub_44E3C0+3Aj
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E49A:                             ; CODE XREF: sub_44E3C0+Fj
                                            ; sub_44E3C0+17j
    test    al, 8
    jnz     short loc_44E4EE
    mov     ecx, [esi+12h]
    mov     eax, [ecx+92h]
    mov     edx, [eax+241h]
    shr     edx, 16h
    test    dl, 1
    jz      short loc_44E4D4
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    movsx   eax, word ptr [eax+21Ch]
    mov     cl, [edx+1427Fh]
    add     ecx, eax
    shl     ecx, 10h
    mov     [esi+2Ah], ecx
    jmp     short loc_44E4EE
    ; ---------------------------------------------------------------------------

    loc_44E4D4:                             ; CODE XREF: sub_44E3C0+F3j
    movsx   edx, word ptr [eax+21Ch]
    mov     eax, [ecx+82h]
    xor     ecx, ecx
    mov     cl, [eax+1]
    add     edx, ecx
    shl     edx, 10h
    mov     [esi+2Ah], edx

    loc_44E4EE:                             ; CODE XREF: sub_44E3C0+CCj
                                            ; sub_44E3C0+DCj ...
    mov     ecx, [esi+2Ah]
    mov     eax, 1FF0000h
    cmp     ecx, eax
    jle     short loc_44E4FD
    mov     [esi+2Ah], eax

    loc_44E4FD:                             ; CODE XREF: sub_44E3C0+138j
    mov     edx, [esp+20h+arg_0]
    add     esi, 26h
    pop     edi
    mov     eax, [esi]
    mov     [edx], eax
    mov     ecx, [esi+4]
    mov     [edx+4], ecx
    mov     eax, [esi+8]
    pop     esi
    mov     [edx+8], eax
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 10h
    retn    4
    sub_44E3C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E530 proc near                    ; DATA XREF: .rdata:004FD3DCo

    arg_0= dword ptr  4

    mov     dx, [ecx+8]
    test    dl, 84h
    jz      short loc_44E58F
    mov     eax, [ecx+1Ah]
    test    eax, eax
    jz      short loc_44E58F
    test    dl, 2
    jz      short loc_44E564
    add     eax, 6Ah
    push    eax
    mov     eax, [ecx+12h]
    add     eax, 6Ah
    push    eax
    call    sub_48A980
    mov     ecx, [esp+arg_0]
    mov     [ecx], ax
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E564:                             ; CODE XREF: sub_44E530+13j
    test    dl, 40h
    jz      short loc_44E57C
    mov     eax, [esp+arg_0]
    mov     dx, [ecx+0Eh]
    mov     [eax], dx
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E57C:                             ; CODE XREF: sub_44E530+37j
    mov     edx, [esp+arg_0]
    mov     cx, [eax+66h]
    mov     eax, 1
    mov     [edx], cx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E58F:                             ; CODE XREF: sub_44E530+7j
                                            ; sub_44E530+Ej
    test    dl, 40h
    jz      short loc_44E5A7
    mov     ax, [ecx+0Eh]
    mov     ecx, [esp+arg_0]
    mov     [ecx], ax
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E5A7:                             ; CODE XREF: sub_44E530+62j
    xor     eax, eax
    retn    4
    sub_44E530 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E5B0 proc near                    ; DATA XREF: .rdata:004FD3C8o

    var_28= qword ptr -28h
    var_20= qword ptr -20h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8

    sub     esp, 0Ch
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+10h+var_C]
    push    edi
    mov     eax, [esi]
    push    ecx
    mov     ecx, esi
    call    dword ptr [eax+20h]
    mov     edi, [esp+18h]
    mov     eax, [esp+10h]
    mov     ecx, [esp+14h+var_C]
    sub     esp, 8
    mov     edx, [edi+72h]
    sub     esp, 8
    sub     edx, eax
    mov     eax, [edi+6Ah]
    mov     [esp+28h], edx
    sub     eax, ecx
    fild    dword ptr [esp+28h]
    mov     [esp+28h], eax
    fstp    [esp+24h+var_20+4]
    fild    dword ptr [esp+28h]
    fstp    [esp+24h+var_28+4]
    call    __hypot
    mov     cx, [esi+8]
    add     esp, 10h
    fmul    ds:flt_4FD3E8
    test    cl, 10h
    jz      short loc_44E631
    movsx   ecx, word ptr [esi+0Ah]
    mov     [esp+18h], ecx
    fild    dword ptr [esp+18h]
    fxch    st(1)
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 1
    jz      short loc_44E694
    mov     eax, 1
    pop     edi
    pop     esi
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E631:                             ; CODE XREF: sub_44E5B0+5Bj
    fcomp   ds:flt_4FD3EC
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_44E648
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E648:                             ; CODE XREF: sub_44E5B0+8Cj
    test    cl, 1
    jz      short loc_44E65E
    mov     eax, [esi+1Ah]
    test    eax, eax
    jnz     short loc_44E65E
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E65E:                             ; CODE XREF: sub_44E5B0+9Bj
                                            ; sub_44E5B0+A2j
    test    cl, 4
    jz      short loc_44E67A
    mov     edx, [esi+1Ah]
    mov     ax, [edi+66h]
    cmp     ax, [edx+66h]
    jz      short loc_44E67A
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E67A:                             ; CODE XREF: sub_44E5B0+B1j
                                            ; sub_44E5B0+BEj
    test    cl, 8
    jz      short loc_44E69E
    mov     eax, [edi+6Eh]
    mov     ecx, [esp+14h+var_8]
    sub     eax, ecx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 10000h
    jle     short loc_44E69E

    loc_44E694:                             ; CODE XREF: sub_44E5B0+72j
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44E69E:                             ; CODE XREF: sub_44E5B0+CDj
                                            ; sub_44E5B0+E2j
    pop     edi
    mov     eax, 1
    pop     esi
    add     esp, 0Ch
    retn    4
    sub_44E5B0 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_19. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E6C0 proc near                    ; CODE XREF: GameUnit_EndTransport+7Dp
                                            ; GameUnit_EndTransport+2ADp ...

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    edi
    or      byte ptr [esi+8], 8
    mov     al, [esi+8]
    test    al, 20h
    mov     [esi+0Ch], bp
    jz      short loc_44E713
    mov     eax, TAdynmemStructPtr
    lea     edi, [esi+26h]
    xor     ebx, ebx
    push    edi
    mov     bl, [eax+1427Fh]
    call    sub_485070
    cmp     eax, ebx
    jle     short loc_44E6FB
    push    edi
    call    sub_485070
    jmp     short loc_44E6FD
    ; ---------------------------------------------------------------------------

    loc_44E6FB:                             ; CODE XREF: sub_44E6C0+31j
    mov     eax, ebx

    loc_44E6FD:                             ; CODE XREF: sub_44E6C0+39j
    add     eax, ebp
    shl     eax, 10h
    cmp     eax, 1FF0000h
    mov     [esi+2Ah], eax
    jle     short loc_44E713
    mov     dword ptr [esi+2Ah], 1FF0000h

    loc_44E713:                             ; CODE XREF: sub_44E6C0+17j
                                            ; sub_44E6C0+4Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_44E6C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E720 proc near                    ; CODE XREF: .text:004141F1p
                                            ; .text:00414612p

    arg_0= word ptr  4

    mov     ax, [esp+arg_0]
    or      byte ptr [ecx+8], 40h
    mov     [ecx+0Eh], ax
    retn    4
    sub_44E720 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E730 proc near                    ; CODE XREF: GameUnit_EndTransport+1A7p
                                            ; GameUnit_EndTransport+41Fp ...

    arg_0= word ptr  4

    mov     ax, [esp+arg_0]
    or      byte ptr [ecx+8], 10h
    mov     [ecx+0Ah], ax
    retn    4
    sub_44E730 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E740 proc near                    ; CODE XREF: .text:00413109p
                                            ; .text:004132FBp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, ecx
    push    esi
    mov     ecx, [esp+4+arg_0]
    mov     [eax+4], ecx
    mov     dword ptr [eax], offset off_4FD3F8
    mov     ecx, [ecx+0Eh]
    lea     edx, [eax+0Ah]
    mov     [eax+28h], ecx
    xor     ecx, ecx
    mov     [eax+8], cx
    mov     [eax+22h], cx
    mov     ecx, [esp+4+arg_4]
    mov     esi, [ecx]
    mov     [edx], esi
    mov     esi, [ecx+4]
    mov     [edx+4], esi
    mov     ecx, [ecx+8]
    mov     [edx+8], ecx
    mov     ecx, [esp+4+arg_8]
    lea     edx, [eax+16h]
    mov     esi, [ecx]
    mov     [edx], esi
    mov     esi, [ecx+4]
    mov     [edx+4], esi
    pop     esi
    mov     ecx, [ecx+8]
    mov     [edx+8], ecx
    retn    0Ch
    sub_44E740 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E7A0 proc near                    ; DATA XREF: .rdata:004FD400o
    mov     eax, 3
    retn
    sub_44E7A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E7B0 proc near                    ; DATA XREF: .rdata:004FD3F8o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD2F8
    jz      short loc_44E7CA
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44E7CA:                             ; CODE XREF: sub_44E7B0+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_44E7B0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E7D0 proc near                    ; CODE XREF: sub_43A420+425p

    var_2C= dword ptr -2Ch
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= word ptr -8
    var_6= word ptr -6
    var_4= word ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 2Ch
    mov     eax, [esp+2Ch+arg_0]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+30h+arg_8]
    push    edi
    mov     edi, [esp+34h+arg_4]
    push    ecx
    mov     ecx, edi
    mov     [esi+4], eax
    mov     dword ptr [esi], offset off_4FD3F8
    call    sub_4B4BA0
    push    0
    mov     ecx, edi
    call    sub_4B4C10
    lea     edx, [esp+34h+var_2C]
    push    2Ah
    push    edx
    mov     ecx, edi
    call    sub_4B4C80
    cmp     eax, 2Ah
    jnz     short loc_44E870
    mov     eax, [esp+34h+var_24]
    push    edi
    push    eax
    call    sub_487080
    mov     cx, word ptr [esp+34h+var_24+2]
    mov     [esi+28h], eax
    mov     eax, [esp+34h+var_20]
    lea     edx, [esi+0Ah]
    mov     [esi+8], cx
    mov     ecx, [esp+34h+var_1C]
    mov     [edx], eax
    mov     eax, [esp+34h+var_18]
    mov     [edx+4], ecx
    lea     ecx, [esi+16h]
    mov     [edx+8], eax
    mov     edx, [esp+34h+var_14]
    mov     eax, [esp+34h+var_10]
    mov     [ecx], edx
    mov     edx, [esp+34h+var_C]
    mov     [ecx+4], eax
    mov     ax, [esp+34h+var_8]
    mov     [esi+22h], ax
    mov     [ecx+8], edx
    mov     cx, [esp+34h+var_6]
    mov     dx, [esp+34h+var_4]
    mov     [esi+24h], cx
    mov     [esi+26h], dx

    loc_44E870:                             ; CODE XREF: sub_44E7D0+3Ej
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 2Ch
    retn    0Ch
    sub_44E7D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E880 proc near                    ; DATA XREF: .rdata:004FD3FCo

    var_2C= dword ptr -2Ch
    var_24= word ptr -24h
    var_22= word ptr -22h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= word ptr -8
    var_6= word ptr -6
    var_4= word ptr -4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [ecx+28h]
    sub     esp, 2Ch
    test    eax, eax
    push    esi
    jnz     short loc_44E892
    mov     [esp+30h+var_24], ax
    jmp     short loc_44E89E
    ; ---------------------------------------------------------------------------

    loc_44E892:                             ; CODE XREF: sub_44E880+9j
    mov     ax, [eax+0A8h]
    mov     [esp+30h+var_24], ax

    loc_44E89E:                             ; CODE XREF: sub_44E880+10j
    mov     dx, [ecx+8]
    lea     eax, [ecx+0Ah]
    mov     [esp+30h+var_22], dx
    mov     esi, [esp+30h+arg_4]
    mov     edx, [eax]
    mov     [esp+30h+var_20], edx
    mov     edx, [eax+4]
    mov     [esp+30h+var_1C], edx
    lea     edx, [ecx+16h]
    mov     eax, [eax+8]
    mov     [esp+30h+var_18], eax
    mov     eax, [edx]
    mov     [esp+30h+var_14], eax
    mov     eax, [edx+4]
    mov     [esp+30h+var_10], eax
    mov     ax, [ecx+22h]
    mov     edx, [edx+8]
    mov     [esp+30h+var_8], ax
    mov     ax, [ecx+26h]
    mov     [esp+30h+var_C], edx
    mov     dx, [ecx+24h]
    mov     ecx, [esp+30h+arg_8]
    push    ecx
    mov     ecx, esi
    mov     [esp+34h+var_6], dx
    mov     [esp+34h+var_4], ax
    call    sub_4B4BA0
    push    0
    mov     ecx, esi
    call    sub_4B4C10
    lea     edx, [esp+30h+var_2C]
    push    2Ah
    push    edx
    mov     ecx, esi
    call    sub_4B4CF0
    mov     eax, 1
    pop     esi
    add     esp, 2Ch
    retn    0Ch
    sub_44E880 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E930 proc near                    ; DATA XREF: .rdata:004FD420o

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    xor     eax, eax
    push    edi
    mov     ax, [esi+8]
    mov     edi, [esp+4+arg_0]
    push    1
    push    eax
    mov     ecx, edi
    call    sub_415C10
    mov     ecx, [esi+0Ah]
    push    20h
    push    ecx
    mov     ecx, edi
    call    sub_415C10
    mov     edx, [esi+0Eh]
    push    20h
    push    edx
    mov     ecx, edi
    call    sub_415C10
    mov     eax, [esi+12h]
    push    20h
    push    eax
    mov     ecx, edi
    call    sub_415C10
    mov     ecx, [esi+16h]
    push    20h
    push    ecx
    mov     ecx, edi
    call    sub_415C10
    mov     edx, [esi+1Ah]
    push    20h
    push    edx
    mov     ecx, edi
    call    sub_415C10
    mov     eax, [esi+1Eh]
    push    20h
    push    eax
    mov     ecx, edi
    call    sub_415C10
    test    byte ptr [esi+8], 1
    jz      short loc_44E9AC
    xor     ecx, ecx
    push    10h
    mov     cx, [esi+24h]
    push    ecx
    mov     ecx, edi
    call    sub_415C10

    loc_44E9AC:                             ; CODE XREF: sub_44E930+6Aj
    pop     edi
    pop     esi
    retn    4
    sub_44E930 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44E9C0 proc near                    ; CODE XREF: sub_490A10+60p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, [esp+8+arg_4]
    mov     esi, ecx
    push    1
    mov     ecx, edi
    mov     dword ptr [esi+4], 0
    mov     [esi+28h], eax
    mov     dword ptr [esi], offset off_4FD3F8
    call    sub_415DC0
    push    20h
    mov     ecx, edi
    mov     [esi+8], ax
    call    sub_415DC0
    push    20h
    mov     ecx, edi
    mov     [esi+0Ah], eax
    call    sub_415DC0
    push    20h
    mov     ecx, edi
    mov     [esi+0Eh], eax
    call    sub_415DC0
    push    20h
    mov     ecx, edi
    mov     [esi+12h], eax
    call    sub_415DC0
    push    20h
    mov     ecx, edi
    mov     [esi+16h], eax
    call    sub_415DC0
    push    20h
    mov     ecx, edi
    mov     [esi+1Ah], eax
    call    sub_415DC0
    mov     [esi+1Eh], eax
    mov     al, [esi+8]
    test    al, 1
    jz      short loc_44EA45
    push    10h
    mov     ecx, edi
    call    sub_415DC0
    mov     [esi+24h], ax

    loc_44EA45:                             ; CODE XREF: sub_44E9C0+76j
    mov     eax, esi
    pop     edi
    pop     esi
    retn    8
    sub_44E9C0 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_20. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EA60 proc near                    ; DATA XREF: .rdata:004FD418o

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 0Ch
    push    ebx
    push    esi
    mov     edx, [esp+14h+arg_0]
    mov     esi, ecx
    push    edi
    lea     eax, [esi+0Ah]
    mov     ecx, eax
    mov     edi, [ecx]
    mov     [edx], edi
    mov     edi, [ecx+4]
    mov     [edx+4], edi
    lea     edi, [esi+16h]
    mov     ecx, [ecx+8]
    push    edi
    mov     [edx+8], ecx
    mov     edx, [edi]
    mov     ebx, [eax]
    mov     ecx, [esi+12h]
    add     ebx, edx
    xor     edx, edx
    mov     [eax], ebx
    mov     eax, [esi+1Eh]
    add     ecx, eax
    xor     eax, eax
    mov     [esi+12h], ecx
    xor     ecx, ecx
    mov     [esp+1Ch+var_8], ecx
    lea     ecx, [esp+1Ch+var_C]
    push    ecx
    mov     [esp+20h+var_C], eax
    mov     [esp+20h+var_4], edx
    call    sub_48A980
    test    byte ptr [esi+8], 1
    jz      short loc_44EB2B
    mov     cx, [esi+24h]
    cmp     ax, cx
    jz      short loc_44EB2B
    mov     edx, [edi]
    sub     ecx, eax
    mov     eax, [esi+28h]
    mov     [esp+18h+var_C], edx
    mov     edx, [esi+1Eh]
    mov     [esp+18h+var_8], edx
    mov     edx, [eax+92h]
    movsx   ebx, cx
    mov     dx, [edx+1BAh]
    mov     eax, edx
    and     eax, 0FFFFh
    shr     eax, 3
    cmp     ebx, eax
    jl      short loc_44EAF9
    shr     dx, 3
    jmp     short loc_44EB05
    ; ---------------------------------------------------------------------------

    loc_44EAF9:                             ; CODE XREF: sub_44EA60+91j
    neg     eax
    cmp     ebx, eax
    jg      short loc_44EB07
    shr     dx, 3
    neg     edx

    loc_44EB05:                             ; CODE XREF: sub_44EA60+97j
    mov     ecx, edx

    loc_44EB07:                             ; CODE XREF: sub_44EA60+9Dj
    lea     eax, [esp+18h+var_C]
    neg     ecx
    push    eax
    push    ecx
    call    sub_4B7173
    mov     ecx, [esp+20h+var_C]
    mov     edx, [esp+20h+var_8]
    add     esp, 8
    mov     [edi], ecx
    mov     [esi+1Eh], edx
    mov     dword ptr [esi+1Ah], 0

    loc_44EB2B:                             ; CODE XREF: sub_44EA60+58j
                                            ; sub_44EA60+61j
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    add     esp, 0Ch
    retn    4
    sub_44EA60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EB40 proc near                    ; DATA XREF: .rdata:004FD41Co

    arg_0= dword ptr  4

    lea     eax, [ecx+0Ah]
    mov     ecx, [ecx+28h]
    add     ecx, 6Ah
    push    eax
    push    ecx
    call    sub_48A980
    mov     edx, [esp+arg_0]
    mov     [edx], ax
    mov     eax, 1
    retn    4
    sub_44EB40 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EB60 proc near                    ; DATA XREF: .rdata:004FD408o

    var_20= qword ptr -20h
    var_18= qword ptr -18h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 0Ch
    mov     eax, [esp+0Ch+arg_0]
    push    esi
    mov     esi, ecx
    sub     esp, 8
    mov     ecx, [eax+72h]
    sub     esp, 8
    mov     edx, [esi+12h]
    sub     ecx, edx
    mov     edx, [eax+6Ah]
    mov     eax, [esi+0Ah]
    mov     [esp+20h+arg_0], ecx
    fild    [esp+20h+arg_0]
    sub     edx, eax
    mov     [esp+20h+arg_0], edx
    fstp    [esp+20h+var_18]
    fild    [esp+20h+arg_0]
    fstp    [esp+20h+var_20]
    call    __hypot
    fmul    ds:flt_4FD3E8
    add     esp, 10h
    fcomp   ds:flt_4FD3F0
    fnstsw  ax
    test    ah, 1
    jz      short loc_44EBBE
    mov     eax, 1
    pop     esi
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44EBBE:                             ; CODE XREF: sub_44EB60+50j
    test    byte ptr [esi+8], 1
    jz      short loc_44EBF6
    xor     eax, eax
    xor     ecx, ecx
    mov     [esp+10h+var_C], eax
    mov     [esp+10h+var_8], ecx
    lea     eax, [esi+16h]
    lea     ecx, [esp+10h+var_C]
    xor     edx, edx
    push    eax
    push    ecx
    mov     [esp+18h+var_4], edx
    call    sub_48A980
    cmp     ax, [esi+24h]
    jnz     short loc_44EBF6
    mov     eax, 1
    pop     esi
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44EBF6:                             ; CODE XREF: sub_44EB60+62j
                                            ; sub_44EB60+88j
    xor     eax, eax
    pop     esi
    add     esp, 0Ch
    retn    4
    sub_44EB60 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_21. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_40. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     ax, [esp+4]
    or      byte ptr [ecx+8], 1
    mov     [ecx+24h], ax
    retn    4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EC30 proc near                    ; CODE XREF: sub_44DA00+5Bp
                                            ; sub_44DA00+83p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ebp, [esp+10h+arg_4]
    mov     ecx, [ebx+8]
    mov     eax, [ebx+0Ch]
    sub     eax, ecx
    push    esi
    sar     eax, 2
    cmp     eax, ebp
    push    edi
    mov     [esp+18h+var_8], ebx
    jnb     loc_44ED72
    mov     edx, [ebx+4]
    test    edx, edx
    jnz     short loc_44EC5F
    xor     eax, eax
    jmp     short loc_44EC66
    ; ---------------------------------------------------------------------------

    loc_44EC5F:                             ; CODE XREF: sub_44EC30+29j
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2

    loc_44EC66:                             ; CODE XREF: sub_44EC30+2Dj
    cmp     ebp, eax
    jnb     short loc_44EC7B
    test    edx, edx
    jnz     short loc_44EC72
    xor     eax, eax
    jmp     short loc_44EC7D
    ; ---------------------------------------------------------------------------

    loc_44EC72:                             ; CODE XREF: sub_44EC30+3Cj
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2
    jmp     short loc_44EC7D
    ; ---------------------------------------------------------------------------

    loc_44EC7B:                             ; CODE XREF: sub_44EC30+38j
    mov     eax, ebp

    loc_44EC7D:                             ; CODE XREF: sub_44EC30+40j
                                            ; sub_44EC30+49j
    test    edx, edx
    jnz     short loc_44EC85
    xor     ecx, ecx
    jmp     short loc_44EC8A
    ; ---------------------------------------------------------------------------

    loc_44EC85:                             ; CODE XREF: sub_44EC30+4Fj
    sub     ecx, edx
    sar     ecx, 2

    loc_44EC8A:                             ; CODE XREF: sub_44EC30+53j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_44EC96
    xor     eax, eax

    loc_44EC96:                             ; CODE XREF: sub_44EC30+62j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebx+4]
    mov     ebx, [esp+1Ch+arg_0]
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_44ECC9

    loc_44ECB7:                             ; CODE XREF: sub_44EC30+97j
    test    edx, edx
    jz      short loc_44ECBF
    mov     ecx, [eax]
    mov     [edx], ecx

    loc_44ECBF:                             ; CODE XREF: sub_44EC30+89j
    add     eax, 4
    add     edx, 4
    cmp     eax, ebx
    jnz     short loc_44ECB7

    loc_44ECC9:                             ; CODE XREF: sub_44EC30+85j
    test    ebp, ebp
    mov     eax, edx
    jbe     short loc_44ECE3
    mov     esi, [esp+18h+arg_8]
    mov     ecx, ebp

    loc_44ECD5:                             ; CODE XREF: sub_44EC30+B1j
    test    eax, eax
    jz      short loc_44ECDD
    mov     edi, [esi]
    mov     [eax], edi

    loc_44ECDD:                             ; CODE XREF: sub_44EC30+A7j
    add     eax, 4
    dec     ecx
    jnz     short loc_44ECD5

    loc_44ECE3:                             ; CODE XREF: sub_44EC30+9Dj
    mov     eax, [esp+18h+var_8]
    lea     edi, ds:0[ebp*4]
    mov     esi, [eax+8]
    lea     ecx, [edx+edi]
    cmp     ebx, esi
    jz      short loc_44ED11
    lea     eax, [ebx+ecx]
    sub     eax, edx
    sub     eax, edi

    loc_44ECFF:                             ; CODE XREF: sub_44EC30+DFj
    test    ecx, ecx
    jz      short loc_44ED07
    mov     edx, [eax]
    mov     [ecx], edx

    loc_44ED07:                             ; CODE XREF: sub_44EC30+D1j
    add     eax, 4
    add     ecx, 4
    cmp     eax, esi
    jnz     short loc_44ECFF

    loc_44ED11:                             ; CODE XREF: sub_44EC30+C6j
    mov     eax, [esp+18h+var_8]
    mov     eax, [eax+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     esi, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+var_4]
    mov     edx, [esp+1Ch+var_8]
    add     esp, 4
    lea     eax, [esi+ecx*4]
    mov     ecx, [edx+4]
    mov     [edx+0Ch], eax
    test    ecx, ecx
    jnz     short loc_44ED55
    xor     eax, eax
    mov     [edx+4], esi
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44ED55:                             ; CODE XREF: sub_44EC30+10Cj
    mov     eax, [edx+8]
    mov     [edx+4], esi
    sub     eax, ecx
    sar     eax, 2
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44ED72:                             ; CODE XREF: sub_44EC30+1Ej
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, esi
    sar     edx, 2
    cmp     edx, ebp
    jnb     short loc_44EDEC
    lea     edi, ds:0[ebp*4]
    cmp     esi, ecx
    lea     edx, [esi+edi]
    jz      short loc_44EDA9
    mov     eax, edx
    sub     eax, edi

    loc_44ED93:                             ; CODE XREF: sub_44EC30+177j
    test    edx, edx
    jz      short loc_44ED9F
    mov     ebx, [eax]
    mov     [edx], ebx
    mov     ebx, [esp+18h+var_8]

    loc_44ED9F:                             ; CODE XREF: sub_44EC30+165j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_44ED93

    loc_44EDA9:                             ; CODE XREF: sub_44EC30+15Dj
    mov     eax, [ebx+8]
    mov     edx, [esp+18h+arg_8]
    mov     ecx, eax
    sub     ecx, esi
    sar     ecx, 2
    sub     ebp, ecx
    mov     ecx, ebp
    jz      short loc_44EDCB

    loc_44EDBD:                             ; CODE XREF: sub_44EC30+199j
    test    eax, eax
    jz      short loc_44EDC5
    mov     ebp, [edx]
    mov     [eax], ebp

    loc_44EDC5:                             ; CODE XREF: sub_44EC30+18Fj
    add     eax, 4
    dec     ecx
    jnz     short loc_44EDBD

    loc_44EDCB:                             ; CODE XREF: sub_44EC30+18Bj
    mov     ecx, [ebx+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_44EE45

    loc_44EDD4:                             ; CODE XREF: sub_44EC30+1ADj
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_44EDD4
    add     [ebx+8], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44EDEC:                             ; CODE XREF: sub_44EC30+14Fj
    test    ebp, ebp
    jbe     short loc_44EE48
    lea     edi, ds:0[ebp*4]
    mov     eax, ecx
    sub     eax, edi
    mov     edx, ecx
    cmp     eax, ecx
    jz      short loc_44EE13

    loc_44EE01:                             ; CODE XREF: sub_44EC30+1E1j
    test    edx, edx
    jz      short loc_44EE09
    mov     ebp, [eax]
    mov     [edx], ebp

    loc_44EE09:                             ; CODE XREF: sub_44EC30+1D3j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_44EE01

    loc_44EE13:                             ; CODE XREF: sub_44EC30+1CFj
    mov     ecx, [ebx+8]
    mov     eax, ecx
    sub     eax, edi
    cmp     esi, eax
    jz      short loc_44EE2D

    loc_44EE1E:                             ; CODE XREF: sub_44EC30+1FBj
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, esi
    mov     [ecx], edx
    jnz     short loc_44EE1E

    loc_44EE2D:                             ; CODE XREF: sub_44EC30+1ECj
    lea     ecx, [esi+edi]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_44EE45
    mov     edx, [esp+18h+arg_8]

    loc_44EE3A:                             ; CODE XREF: sub_44EC30+213j
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_44EE3A

    loc_44EE45:                             ; CODE XREF: sub_44EC30+1A2j
                                            ; sub_44EC30+204j
    add     [ebx+8], edi

    loc_44EE48:                             ; CODE XREF: sub_44EC30+1BEj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_44EC30 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_47. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EE70 proc near                    ; CODE XREF: sub_44D0E0+F7p
                                            ; sub_44D560+10Bp ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_44EE7A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_44EE7A:                             ; CODE XREF: sub_44EE70+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_44EE70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EE90 proc near                    ; CODE XREF: sub_44D0E0+AAp
                                            ; sub_44D0E0+CBp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_44EEB7
    mov     eax, [esp+arg_8]
    push    esi

    loc_44EEA1:                             ; CODE XREF: sub_44EE90+21j
    test    eax, eax
    jz      short loc_44EEA9
    mov     esi, [ecx]
    mov     [eax], esi

    loc_44EEA9:                             ; CODE XREF: sub_44EE90+13j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_44EEA1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44EEB7:                             ; CODE XREF: sub_44EE90+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_44EE90 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EEC0 proc near                    ; CODE XREF: sub_44D0E0+BBp
                                            ; sub_44D0E0+138p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_4]
    test    ecx, ecx
    jbe     short locret_44EEE0
    mov     edx, [esp+arg_8]
    mov     eax, [esp+arg_0]
    push    esi

    loc_44EED1:                             ; CODE XREF: sub_44EEC0+1Dj
    test    eax, eax
    jz      short loc_44EED9
    mov     esi, [edx]
    mov     [eax], esi

    loc_44EED9:                             ; CODE XREF: sub_44EEC0+13j
    add     eax, 4
    dec     ecx
    jnz     short loc_44EED1
    pop     esi

    locret_44EEE0:                          ; CODE XREF: sub_44EEC0+6j
    retn    0Ch
    sub_44EEC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EEF0 proc near                    ; CODE XREF: sub_44DA00+1Ap

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_44EF13
    mov     eax, [esp+arg_8]
    push    esi

    loc_44EF01:                             ; CODE XREF: sub_44EEF0+1Dj
    mov     esi, [ecx]
    add     ecx, 4
    mov     [eax], esi
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_44EF01
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44EF13:                             ; CODE XREF: sub_44EEF0+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_44EEF0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EF20 proc near                    ; CODE XREF: .text:004905EAp
                                            ; sub_4907E0+Ap ...

    arg_0= dword ptr  4

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     dword ptr [eax], offset off_4FD428
    mov     [eax+8], ecx
    mov     dword ptr [eax+4], 0
    retn    4
    sub_44EF20 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_64. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_68. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EF60 proc near                    ; DATA XREF: .rdata:004FD428o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD428
    jz      short loc_44EF7A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44EF7A:                             ; CODE XREF: sub_44EF60+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_44EF60 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EF80 proc near                    ; DATA XREF: .rdata:004FD43Co
                                            ; .rdata:004FD994o ...
    mov     edx, [ecx+4]
    xor     eax, eax
    test    edx, edx
    setnz   al
    retn
    sub_44EF80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44EF90 proc near                    ; CODE XREF: sub_490860+8p
                                            ; DATA XREF: .rdata:004FD42Co ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    mov     ecx, [esi+4]
    test    ecx, ecx
    jz      short loc_44EFA4
    push    80h
    call    sub_44CED0

    loc_44EFA4:                             ; CODE XREF: sub_44EF90+8j
    mov     eax, [esp+arg_0]
    mov     [esi+4], eax
    pop     esi
    retn    4
    sub_44EF90 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_63. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_66. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_67. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_22. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_23. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_65. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F010 proc near                    ; CODE XREF: sub_43DC00+F2p

    arg_0= dword ptr  4

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     dl, [eax+64h]
    mov     [eax+8], ecx
    and     dl, 0FCh
    xor     ecx, ecx
    or      dl, 8
    mov     [eax+4], ecx
    mov     dword ptr [eax], offset off_4FD458
    mov     [eax+5Ch], ecx
    mov     [eax+64h], dl
    mov     [eax+60h], ecx
    retn    4
    sub_44F010 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F040 proc near                    ; DATA XREF: .rdata:004FD458o

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    push    esi
    mov     dword ptr [esi], offset off_4FD458
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14207h]
    call    sub_40E9C0
    mov     al, [esp+arg_0]
    mov     dword ptr [esi], offset off_4FD428
    test    al, 1
    jz      short loc_44F071
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44F071:                             ; CODE XREF: sub_44F040+26j
    mov     eax, esi
    pop     esi
    retn    4
    sub_44F040 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F080 proc near                    ; CODE XREF: sub_40E050+FEp
                                            ; sub_40E630+17Fp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, ecx
    mov     ecx, [esp+arg_4]
    test    ecx, ecx
    jnz     short loc_44F0BC
    mov     ecx, [esi+4]
    test    ecx, ecx
    jz      short loc_44F0A9
    mov     edx, [esi+8]
    mov     eax, [ecx]
    push    edx
    call    dword ptr [eax+10h]
    test    eax, eax
    jnz     short loc_44F0A9
    mov     ecx, [esi+4]
    push    40h
    call    sub_44CED0

    loc_44F0A9:                             ; CODE XREF: sub_44F080+10j
                                            ; sub_44F080+1Dj
    mov     al, [esi+64h]
    and     al, 0FEh
    mov     [esi+64h], al
    and     al, 0FDh
    or      al, 8
    mov     [esi+64h], al
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_44F0BC:                             ; CODE XREF: sub_44F080+9j
    cmp     ecx, 14h
    push    edi
    jl      short loc_44F0C7
    mov     ecx, 14h

    loc_44F0C7:                             ; CODE XREF: sub_44F080+40j
    mov     eax, [esp+4+arg_0]
    mov     [esi+5Ch], ecx
    lea     edx, [esi+0Ch]
    lea     ecx, [eax+ecx*4]
    cmp     eax, ecx
    jz      short loc_44F0E6
    sub     edx, eax

    loc_44F0DA:                             ; CODE XREF: sub_44F080+64j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_44F0DA

    loc_44F0E6:                             ; CODE XREF: sub_44F080+56j
    mov     al, [esi+64h]
    pop     edi
    or      al, 1
    mov     [esi+64h], al
    and     al, 0FDh
    or      al, 8
    mov     [esi+64h], al
    pop     esi
    retn    8
    sub_44F080 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    edi
    mov     edi, [esp+8]
    test    edi, edi
    jz      short loc_44F148
    mov     eax, [ecx+5Ch]
    push    esi
    push    ebx
    lea     esi, [ecx+0Ch]
    lea     edx, [ecx+eax*4+0Ch]
    lea     eax, [ecx+edi*4+0Ch]
    cmp     eax, edx
    jz      short loc_44F12B
    sub     esi, eax

    loc_44F11F:                             ; CODE XREF: .text:0044F129j
    mov     ebx, [eax]
    mov     [eax+esi], ebx
    add     eax, 4
    cmp     eax, edx
    jnz     short loc_44F11F

    loc_44F12B:                             ; CODE XREF: .text:0044F11Bj
    mov     edx, [ecx+5Ch]
    sub     edx, edi
    mov     eax, edx
    mov     [ecx+5Ch], edx
    cmp     eax, 2
    jge     short loc_44F13E
    and     byte ptr [ecx+64h], 0FEh

    loc_44F13E:                             ; CODE XREF: .text:0044F138j
    mov     al, [ecx+64h]
    pop     ebx
    or      al, 8
    pop     esi
    mov     [ecx+64h], al

    loc_44F148:                             ; CODE XREF: .text:0044F107j
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F150 proc near                    ; DATA XREF: .rdata:004FD464o

    arg_0= dword ptr  0Ch
    arg_8= dword ptr  14h

    push    ebx
    push    edi
    mov     edi, [esp+arg_8]
    xor     ebx, ebx
    xor     edx, edx
    cmp     edi, ebx
    jle     short loc_44F195
    mov     eax, [esp+arg_0]
    push    esi
    push    ebp
    add     eax, 8

    loc_44F167:                             ; CODE XREF: sub_44F150+41j
    mov     esi, [ecx+5Ch]
    cmp     edx, esi
    jge     short loc_44F172
    mov     esi, edx
    jmp     short loc_44F173
    ; ---------------------------------------------------------------------------

    loc_44F172:                             ; CODE XREF: sub_44F150+1Cj
    dec     esi

    loc_44F173:                             ; CODE XREF: sub_44F150+20j
    movsx   ebp, word ptr [ecx+esi*4+0Ch]
    shl     ebp, 10h
    mov     [eax-8], ebp
    mov     [eax-4], ebx
    movsx   esi, word ptr [ecx+esi*4+0Eh]
    shl     esi, 10h
    mov     [eax], esi
    inc     edx
    add     eax, 0Ch
    cmp     edx, edi
    jl      short loc_44F167
    pop     ebp
    pop     esi

    loc_44F195:                             ; CODE XREF: sub_44F150+Cj
    pop     edi
    pop     ebx
    retn    0Ch
    sub_44F150 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F1A0 proc near                    ; DATA XREF: .rdata:004FD460o
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [esi+4]
    test    ecx, ecx
    jz      short loc_44F1D7
    mov     edx, [esi+8]
    mov     eax, [ecx]
    push    edx
    call    dword ptr [eax+10h]
    test    eax, eax
    jz      short loc_44F1D7
    mov     ecx, [esi+4]
    push    20h
    call    sub_44CED0
    mov     ecx, [esi+4]
    mov     eax, [ecx]
    call    dword ptr [eax+2Ch]
    test    eax, eax
    jnz     short loc_44F1D7
    mov     edx, [esi]
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+4]

    loc_44F1D7:                             ; CODE XREF: sub_44F1A0+Aj
                                            ; sub_44F1A0+17j ...
    mov     edi, [esi+5Ch]
    cmp     edi, 2
    jl      short loc_44F239
    mov     edx, [esi+8]
    movsx   eax, word ptr [esi+12h]
    movsx   ecx, word ptr [edx+74h]
    movsx   edx, word ptr [edx+6Ch]
    movsx   ebp, word ptr [esi+10h]
    sub     ecx, eax
    lea     eax, [esi+10h]
    sub     edx, ebp
    mov     ebp, edx
    imul    ebp, edx
    mov     edx, ecx
    imul    edx, ecx
    add     ebp, edx
    cmp     ebp, 19h
    jg      short loc_44F239
    lea     ecx, [esi+edi*4+0Ch]
    lea     edx, [esi+0Ch]
    cmp     eax, ecx
    jz      short loc_44F223
    sub     edx, eax

    loc_44F217:                             ; CODE XREF: sub_44F1A0+81j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_44F217

    loc_44F223:                             ; CODE XREF: sub_44F1A0+73j
    mov     ecx, [esi+5Ch]
    dec     ecx
    mov     eax, ecx
    mov     [esi+5Ch], ecx
    cmp     eax, 2
    jge     short loc_44F235
    and     byte ptr [esi+64h], 0FEh

    loc_44F235:                             ; CODE XREF: sub_44F1A0+8Fj
    or      byte ptr [esi+64h], 8

    loc_44F239:                             ; CODE XREF: sub_44F1A0+3Dj
                                            ; sub_44F1A0+68j
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_44F255
    mov     eax, [esi+8]
    mov     ecx, [eax]
    test    byte ptr [ecx+2Eh], 4
    jnz     short loc_44F251
    cmp     dword ptr [esi+5Ch], 2
    jge     short loc_44F255

    loc_44F251:                             ; CODE XREF: sub_44F1A0+A9j
    or      byte ptr [esi+64h], 2

    loc_44F255:                             ; CODE XREF: sub_44F1A0+9Ej
                                            ; sub_44F1A0+AFj
    pop     edi
    pop     esi
    pop     ebp
    retn
    sub_44F1A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F260 proc near                    ; DATA XREF: .rdata:004FD470o
    mov     eax, ecx
    test    byte ptr [eax+64h], 2
    jz      short loc_44F282
    mov     ecx, TAdynmemStructPtr
    mov     edx, [eax+60h]
    add     edx, 3Ch
    mov     ecx, [ecx+38A47h]
    cmp     ecx, edx
    jb      short loc_44F282
    mov     [eax+60h], ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_44F282:                             ; CODE XREF: sub_44F260+6j
                                            ; sub_44F260+1Cj
    xor     eax, eax
    retn
    sub_44F260 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F290 proc near                    ; DATA XREF: .rdata:004FD46Co
    mov     al, [ecx+64h]
    and     eax, 1
    retn
    sub_44F290 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F2A0 proc near                    ; DATA XREF: .rdata:004FD45Co

    var_38= qword ptr -38h
    var_30= qword ptr -30h
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_8= dword ptr -8
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    mov     ecx, [eax+14207h]
    push    edi
    push    esi
    call    sub_40E9C0
    mov     ecx, [esi+4]
    test    ecx, ecx
    jz      short loc_44F2CB
    push    80h
    call    sub_44CED0

    loc_44F2CB:                             ; CODE XREF: sub_44F2A0+1Fj
    mov     bl, [esi+64h]
    mov     ecx, [esp+1Ch+arg_0]
    and     bl, 0FEh
    mov     [esi+4], ecx
    test    ecx, ecx
    mov     [esi+64h], bl
    mov     al, bl
    jnz     short loc_44F2E8
    and     al, 0FDh
    jmp     loc_44F41D
    ; ---------------------------------------------------------------------------

    loc_44F2E8:                             ; CODE XREF: sub_44F2A0+3Fj
    or      al, 2
    mov     [esi+64h], al
    mov     eax, [esi+5Ch]
    cmp     eax, 3
    jl      short loc_44F31C
    movsx   edi, word ptr [esi+eax*4+0Ah]
    movsx   eax, word ptr [esi+eax*4+8]
    mov     edx, [ecx]
    sar     edi, 4
    sar     eax, 4
    push    edi
    push    eax
    call    dword ptr [edx+14h]
    test    eax, eax
    jz      short loc_44F31C
    mov     cl, [esi+64h]
    and     cl, 0FDh
    or      cl, 1
    mov     [esi+64h], cl

    loc_44F31C:                             ; CODE XREF: sub_44F2A0+53j
                                            ; sub_44F2A0+6Ej
    test    byte ptr [esi+64h], 1
    jnz     loc_44F420
    mov     ecx, [esi+4]
    lea     eax, [esp+10h]
    push    eax
    mov     edx, [ecx]
    call    dword ptr [edx+20h]
    test    eax, eax
    jz      loc_44F420
    mov     eax, [esi+5Ch]
    cmp     eax, 3
    jl      loc_44F3D8
    movsx   edi, word ptr [esi+eax*4+8]
    movsx   ebp, word ptr [esi+eax*4+0Ah]
    mov     eax, [esi+8]
    mov     edx, [esp+18h]
    sub     esp, 8
    mov     ecx, [eax+72h]
    sub     esp, 8
    sub     ecx, edx
    mov     edx, [eax+6Ah]
    mov     eax, [esp+20h]
    mov     [esp+2Ch+arg_0], ecx
    fild    [esp+2Ch+arg_0]
    sub     edx, eax
    mov     [esp+2Ch+arg_0], edx
    fstp    qword ptr [esp+8]
    fild    [esp+2Ch+arg_0]
    shl     edi, 10h
    shl     ebp, 10h
    fstp    [esp+2Ch+var_30+4]
    call    __hypot
    add     esp, 10h
    call    __ftol
    mov     ecx, [esp+18h]
    sub     esp, 8
    sub     ebp, ecx
    sub     esp, 8
    mov     [esp+2Ch+arg_0], ebp
    mov     ebp, [esp+20h]
    fild    [esp+2Ch+arg_0]
    sub     edi, ebp
    mov     ebx, eax
    mov     [esp+2Ch+arg_0], edi
    fstp    qword ptr [esp+8]
    fild    [esp+2Ch+arg_0]
    fstp    [esp+2Ch+var_30+4]
    call    __hypot
    add     esp, 10h
    call    __ftol
    add     eax, eax
    cmp     eax, ebx
    jge     short loc_44F3D8
    or      byte ptr [esi+64h], 1

    loc_44F3D8:                             ; CODE XREF: sub_44F2A0+A1j
                                            ; sub_44F2A0+132j
    mov     al, [esi+64h]
    test    al, 1
    jnz     short loc_44F420
    mov     ecx, [esi+8]
    mov     edx, [ecx+5Ch]
    test    edx, edx
    jz      short loc_44F420
    test    dword ptr [edx+42h], 800000h
    jnz     short loc_44F420
    mov     dword ptr [esi+5Ch], 2
    mov     dx, [ecx+6Ch]
    mov     [esi+0Ch], dx
    mov     cx, [ecx+74h]
    mov     dx, [esp+12h]
    mov     [esi+0Eh], cx
    mov     cx, [esp+1Ah]
    mov     [esi+10h], dx
    mov     [esi+12h], cx
    or      al, 1

    loc_44F41D:                             ; CODE XREF: sub_44F2A0+43j
    mov     [esi+64h], al

    loc_44F420:                             ; CODE XREF: sub_44F2A0+80j
                                            ; sub_44F2A0+95j ...
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esi+60h]
    mov     eax, [edx+38A47h]
    sub     eax, 0Ah
    cmp     ecx, eax
    ja      short loc_44F43D
    mov     dword ptr [esi+60h], 0

    loc_44F43D:                             ; CODE XREF: sub_44F2A0+194j
    mov     al, [esi+64h]
    pop     edi
    or      al, 8
    mov     [esi+64h], al
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    4
    sub_44F2A0 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, ecx
    push    esi
    mov     dword ptr [esi], offset off_4FD458
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14207h]
    call    sub_40E9C0
    mov     dword ptr [esi], offset off_4FD428
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F480 proc near                    ; DATA XREF: .rdata:004FD474o
    mov     al, [ecx+64h]
    test    al, 8
    jnz     short unknown_libname_24
    mov     ecx, [ecx+8]
    mov     edx, [ecx]
    mov     cl, [edx+2Eh]
    xor     cl, al
    test    cl, 4
    jnz     short unknown_libname_24
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_24:                     ; CODE XREF: sub_44F480+5j
                                            ; sub_44F480+14j
    mov     eax, 1
    retn
    sub_44F480 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F4A0 proc near                    ; DATA XREF: .rdata:004FD478o

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    test    byte ptr [ebp+64h], 1
    jz      short loc_44F4BB
    mov     ebx, [ebp+5Ch]
    cmp     ebx, 3
    jl      short loc_44F4BD
    mov     ebx, 3
    jmp     short loc_44F4BD
    ; ---------------------------------------------------------------------------

    loc_44F4BB:                             ; CODE XREF: sub_44F4A0+Aj
    xor     ebx, ebx

    loc_44F4BD:                             ; CODE XREF: sub_44F4A0+12j
                                            ; sub_44F4A0+19j
    mov     eax, [ebp+8]
    mov     esi, [esp+8+arg_0]
    mov     ecx, [eax]
    test    byte ptr [ecx+2Eh], 4
    jz      short loc_44F4E0
    mov     edx, [esi]
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+4]
    lea     eax, [eax+edx*4]
    mov     edx, 1
    shl     edx, cl
    or      [eax], edx

    loc_44F4E0:                             ; CODE XREF: sub_44F4A0+2Aj
    mov     ecx, [esi+4]
    inc     ecx
    mov     eax, ecx
    mov     [esi+4], ecx
    cmp     eax, 20h
    jnz     short loc_44F516
    mov     edx, [esi]
    mov     ecx, [esi+8]
    inc     edx
    mov     dword ptr [esi+4], 0
    mov     eax, edx
    mov     [esi], edx
    cmp     eax, ecx
    jnz     short loc_44F50A
    mov     ecx, esi
    call    sub_415BB0

    loc_44F50A:                             ; CODE XREF: sub_44F4A0+61j
    mov     eax, [esi]
    mov     ecx, [esi+0Ch]
    mov     dword ptr [ecx+eax*4], 0

    loc_44F516:                             ; CODE XREF: sub_44F4A0+4Cj
    push    2
    push    ebx
    mov     ecx, esi
    call    sub_415C10
    test    ebx, ebx
    jle     short loc_44F548
    lea     edi, [ebp+0Eh]

    loc_44F527:                             ; CODE XREF: sub_44F4A0+A6j
    movsx   edx, word ptr [edi-2]
    push    10h
    push    edx
    mov     ecx, esi
    call    sub_415C10
    movsx   eax, word ptr [edi]
    push    10h
    push    eax
    mov     ecx, esi
    call    sub_415C10
    add     edi, 4
    dec     ebx
    jnz     short loc_44F527

    loc_44F548:                             ; CODE XREF: sub_44F4A0+82j
    mov     ecx, [ebp+8]
    mov     al, [ebp+64h]
    and     al, 0F3h
    pop     edi
    mov     edx, [ecx]
    pop     esi
    mov     cl, [edx+2Eh]
    and     cl, 4
    xor     al, cl
    mov     [ebp+64h], al
    pop     ebp
    pop     ebx
    retn    4
    sub_44F4A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F570 proc near                    ; CODE XREF: sub_43DC00+A1p

    arg_0= dword ptr  4

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     [eax+8], ecx
    xor     ecx, ecx
    mov     [eax+4], ecx
    mov     dword ptr [eax], offset off_4FD488
    mov     [eax+18h], ecx
    retn    4
    sub_44F570 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F590 proc near                    ; DATA XREF: .rdata:004FD488o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD428
    jz      short loc_44F5AA
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44F5AA:                             ; CODE XREF: sub_44F590+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_44F590 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F5B0 proc near                    ; DATA XREF: .rdata:004FD49Co
    mov     edx, [ecx+18h]
    xor     eax, eax
    cmp     edx, 2
    setnl   al
    retn
    sub_44F5B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F5C0 proc near                    ; DATA XREF: .rdata:004FD4ACo

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    mov     ebp, ecx
    push    edi
    mov     ecx, [esi+8]
    mov     edx, [esi+4]
    mov     eax, [esi]
    mov     edi, 1
    shl     edi, cl
    mov     eax, [eax+edx*4]
    and     eax, edi
    neg     eax
    sbb     eax, eax
    xor     ebx, ebx
    neg     eax
    inc     ecx
    cmp     ecx, 20h
    mov     [esi+8], ecx
    jnz     short loc_44F5F6
    inc     edx
    mov     [esi+8], ebx
    mov     [esi+4], edx

    loc_44F5F6:                             ; CODE XREF: sub_44F5C0+2Dj
    mov     ecx, [ebp+8]
    and     al, 1
    shl     al, 2
    mov     ecx, [ecx]
    push    2
    mov     dl, [ecx+2Eh]
    and     dl, 0FBh
    or      al, dl
    mov     [ecx+2Eh], al
    mov     ecx, esi
    call    sub_415DC0
    cmp     eax, ebx
    mov     [ebp+18h], eax
    jle     short loc_44F642
    lea     edi, [ebp+0Eh]

    loc_44F61E:                             ; CODE XREF: sub_44F5C0+80j
    push    10h
    mov     ecx, esi
    call    sub_415DC0
    push    10h
    mov     ecx, esi
    mov     [edi-2], ax
    call    sub_415DC0
    mov     [edi], ax
    mov     eax, [ebp+18h]
    inc     ebx
    add     edi, 4
    cmp     ebx, eax
    jl      short loc_44F61E

    loc_44F642:                             ; CODE XREF: sub_44F5C0+59j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_44F5C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F650 proc near                    ; DATA XREF: .rdata:004FD494o

    arg_0= dword ptr  0Ch
    arg_8= dword ptr  14h

    push    ebx
    push    edi
    mov     edi, [esp+arg_8]
    xor     ebx, ebx
    xor     edx, edx
    cmp     edi, ebx
    jle     short loc_44F695
    mov     eax, [esp+arg_0]
    push    esi
    push    ebp
    add     eax, 8

    loc_44F667:                             ; CODE XREF: sub_44F650+41j
    mov     esi, [ecx+18h]
    cmp     edx, esi
    jge     short loc_44F672
    mov     esi, edx
    jmp     short loc_44F673
    ; ---------------------------------------------------------------------------

    loc_44F672:                             ; CODE XREF: sub_44F650+1Cj
    dec     esi

    loc_44F673:                             ; CODE XREF: sub_44F650+20j
    movsx   ebp, word ptr [ecx+esi*4+0Ch]
    shl     ebp, 10h
    mov     [eax-8], ebp
    mov     [eax-4], ebx
    movsx   esi, word ptr [ecx+esi*4+0Eh]
    shl     esi, 10h
    mov     [eax], esi
    inc     edx
    add     eax, 0Ch
    cmp     edx, edi
    jl      short loc_44F667
    pop     ebp
    pop     esi

    loc_44F695:                             ; CODE XREF: sub_44F650+Cj
    pop     edi
    pop     ebx
    retn    0Ch
    sub_44F650 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F6A0 proc near                    ; CODE XREF: sub_4917D0+1FDp
    push    0C9h                            ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_44F6C5
    mov     ecx, eax
    call    sub_40E9E0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+14207h], eax
    retn
    ; ---------------------------------------------------------------------------

    loc_44F6C5:                             ; CODE XREF: sub_44F6A0+Fj
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     [ecx+14207h], eax
    retn
    sub_44F6A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F6E0 proc near                    ; CODE XREF: sub_491B60+44p
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     esi, [eax+14207h]
    test    esi, esi
    jz      short loc_44F700
    mov     ecx, esi
    call    sub_40EB30
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_44F700:                             ; CODE XREF: sub_44F6E0+Ej
    mov     ecx, TAdynmemStructPtr
    pop     esi
    mov     dword ptr [ecx+14207h], 0
    retn
    sub_44F6E0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    6D60h
    call    sub_4B4F10
    add     esp, 4
    xor     ebx, ebx
    mov     dword_5129F8, eax
    mov     dword_5129FC, ebx
    push    0AF0h
    mov     dword_512A00, ebx
    mov     dword_512A04, ebx
    call    sub_4B4F10
    add     esp, 4
    mov     dword_512A08, eax
    push    0AF0h
    call    sub_4B4F10
    add     esp, 4
    mov     dword_512A10, eax
    push    0AF0h
    call    sub_4B4F10
    add     esp, 4
    mov     dword_512A0C, eax
    mov     byte_512A14, bl
    mov     dword_512A15, ebx
    push    offset loc_44F7A0
    mov     dword_512A19, ebx
    call    _atexit
    add     esp, 4
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_44F7A0:                             ; DATA XREF: .text:0044F789o
    mov     eax, dword_5129F8
    push    eax
    call    sub_4B4F20
    mov     eax, dword_512A08
    add     esp, 4
    push    eax
    call    sub_4B4F20
    mov     eax, dword_512A10
    add     esp, 4
    push    eax
    call    sub_4B4F20
    mov     eax, dword_512A0C
    add     esp, 4
    push    eax
    call    sub_4B4F20
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    push    6D60h
    call    sub_4B4F10
    add     esp, 4
    xor     ebx, ebx
    mov     dword_5129D0, eax
    mov     dword_5129D4, ebx
    push    0AF0h
    mov     dword_5129D8, ebx
    mov     dword_5129DC, ebx
    call    sub_4B4F10
    add     esp, 4
    mov     dword_5129E0, eax
    push    0AF0h
    call    sub_4B4F10
    add     esp, 4
    mov     dword_5129E8, eax
    push    0AF0h
    call    sub_4B4F10
    add     esp, 4
    mov     dword_5129E4, eax
    mov     byte_5129EC, bl
    mov     dword_5129ED, ebx
    push    offset loc_44F860
    mov     dword_5129F1, ebx
    call    _atexit
    add     esp, 4
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_44F860:                             ; DATA XREF: .text:0044F849o
    mov     eax, dword_5129D0
    push    eax
    call    sub_4B4F20
    mov     eax, dword_5129E0
    add     esp, 4
    push    eax
    call    sub_4B4F20
    mov     eax, dword_5129E8
    add     esp, 4
    push    eax
    call    sub_4B4F20
    mov     eax, dword_5129E4
    add     esp, 4
    push    eax
    call    sub_4B4F20
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    push    esi
    mov     esi, ecx
    push    6D60h
    call    sub_4B4F10
    add     esp, 4
    xor     ebx, ebx
    mov     [esi], eax
    mov     [esi+4], ebx
    push    0AF0h
    mov     [esi+8], ebx
    mov     [esi+0Ch], ebx
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+10h], eax
    push    0AF0h
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+18h], eax
    push    0AF0h
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+14h], eax
    mov     [esi+1Ch], bl
    mov     [esi+1Dh], ebx
    mov     [esi+21h], ebx
    mov     eax, esi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, ecx
    mov     eax, [esi]
    push    eax
    call    sub_4B4F20
    mov     ecx, [esi+10h]
    add     esp, 4
    push    ecx
    call    sub_4B4F20
    mov     edx, [esi+18h]
    add     esp, 4
    push    edx
    call    sub_4B4F20
    mov     eax, [esi+14h]
    add     esp, 4
    push    eax
    call    sub_4B4F20
    add     esp, 4
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44F940 proc near                    ; CODE XREF: .text:004611B3p
                                            ; .text:00461958p ...

    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 100h
    push    ebx
    push    ebp
    mov     ebp, [esp+108h+arg_4]
    push    esi
    cmp     ebp, 0AF0h
    push    edi
    mov     ebx, ecx
    jle     short loc_44F98B
    mov     eax, [ebx+10h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    push    ebp                             ; int
    call    sub_4B4F10
    add     esp, 4
    lea     ecx, [esp+110h+var_100]
    mov     [ebx+10h], eax
    push    ebp
    push    0AF0h
    push    offset aNetcondenserBu          ; "netCondenser: BUFFER_ACC_SIZE = %ld, re"...
    push    ecx
    call    _sprintf
    add     esp, 10h

    loc_44F98B:                             ; CODE XREF: sub_44F940+19j
    mov     esi, [esp+110h+arg_0]
    mov     edi, [ebx+10h]
    mov     ecx, ebp
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     al, [ebx+1Ch]
    pop     edi
    inc     al
    mov     [ebx+1Dh], ebp
    pop     esi
    mov     [ebx+1Ch], al
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    8
    sub_44F940 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_44F9C0(int HAPINET_this,int lpidTo,int lpidFrom)
    sub_44F9C0 proc near                    ; CODE XREF: sub_462F30+1AEp
                                            ; sub_462F30+21Dp

    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= dword ptr -100h
    HAPINET_this= dword ptr  4
    lpidTo= dword ptr  8
    lpidFrom= dword ptr  0Ch

    sub     esp, 108h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+118h+lpidFrom]
    mov     ebx, ecx
    mov     ecx, [ebx+8]
    mov     eax, [edi]
    test    ecx, ecx
    mov     [esp+118h+var_108], eax
    jz      short loc_44FA52
    mov     ecx, [ebx+0Ch]
    cmp     ecx, eax
    jle     short loc_44FA19
    push    eax
    push    ecx
    lea     eax, [esp+120h+var_100]
    push    offset aNetcondenser1R          ; "netCondenser[1]: r_unpackedSize = %ld, "...
    push    eax
    call    _sprintf
    mov     ecx, [ebx+0Ch]
    mov     dword ptr [ebx+8], 1
    add     esp, 10h
    mov     [edi], ecx
    mov     eax, 8877001Eh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44FA19:                             ; CODE XREF: sub_44F9C0+25j
    mov     esi, [ebx]
    mov     edi, [esp+118h+lpidTo]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+118h+lpidFrom]
    mov     eax, [ebx+0Ch]
    mov     [ecx], eax
    mov     dword ptr [ebx+8], 0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44FA52:                             ; CODE XREF: sub_44F9C0+1Ej
    mov     ebp, [esp+118h+lpidTo]
    mov     edx, [esp+118h+HAPINET_this]
    push    edi                             ; lpidFrom
    push    ebp                             ; lpidTo
    push    edx                             ; HAPINET_this
    call    HAPINET_ReceivePacket
    mov     esi, eax
    mov     eax, [esp+118h+HAPINET_this]
    mov     ecx, [eax+HAPINET.DataSize]
    test    ecx, ecx
    jz      loc_44FBFA
    test    esi, esi
    jnz     loc_44FBB9
    mov     ecx, [edi]
    push    esi                             ; arg8
    push    esi                             ; arg4
    push    ecx                             ; DataSize
    call    HAPINET_PacketStatistics
    mov     al, [ebp+0]
    cmp     al, 3
    jz      short loc_44FAAB
    cmp     al, 4
    jz      short loc_44FAAB
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44FAAB:                             ; CODE XREF: sub_44F9C0+D6j
                                            ; sub_44F9C0+DAj
    mov     eax, [edi]
    cmp     eax, 4
    jge     short loc_44FAC4
    mov     eax, 887700BEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44FAC4:                             ; CODE XREF: sub_44F9C0+F0j
    lea     edx, [eax-3]
    mov     eax, 3
    xor     esi, esi
    cmp     edx, eax
    mov     [esp+118h+var_104], edx
    jbe     short loc_44FAF7

    loc_44FAD6:                             ; CODE XREF: sub_44F9C0+12Ej
    mov     cl, [eax+ebp]
    xor     dx, dx
    mov     dl, cl
    add     esi, edx
    mov     dl, al
    xor     dl, cl
    mov     [eax+ebp], dl
    mov     edx, [esp+118h+var_104]
    inc     eax
    cmp     eax, edx
    jb      short loc_44FAD6
    mov     edi, [esp+118h+lpidFrom]

    loc_44FAF7:                             ; CODE XREF: sub_44F9C0+114j
    cmp     [ebp+1], si
    jz      short loc_44FB0F
    mov     eax, 887700BEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44FB0F:                             ; CODE XREF: sub_44F9C0+13Bj
    cmp     byte ptr [ebp+0], 4
    jnz     short loc_44FB30
    call    Network_StartCompression
    mov     ecx, [ebx]
    lea     eax, [ebp+3]
    push    eax
    push    ecx
    call    sub_4D1480
    mov     [ebx+0Ch], eax
    call    Network_StopCompression
    jmp     short loc_44FB4F
    ; ---------------------------------------------------------------------------

    loc_44FB30:                             ; CODE XREF: sub_44F9C0+153j
    mov     edi, [ebx]
    mov     ecx, edx
    mov     eax, ecx
    lea     esi, [ebp+3]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+118h+lpidFrom]
    mov     [ebx+0Ch], edx

    loc_44FB4F:                             ; CODE XREF: sub_44F9C0+16Ej
    mov     ecx, [ebx+0Ch]
    mov     eax, [esp+118h+var_108]
    cmp     ecx, eax
    jle     short loc_44FB8C
    push    eax
    push    ecx
    lea     ecx, [esp+120h+var_100]
    push    offset aNetcondenser2R          ; "netCondenser[2]: r_unpackedSize = %ld, "...
    push    ecx
    call    _sprintf
    mov     edx, [ebx+0Ch]
    mov     dword ptr [ebx+8], 1
    add     esp, 10h
    mov     [edi], edx
    mov     eax, 8877001Eh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44FB8C:                             ; CODE XREF: sub_44F9C0+198j
    mov     esi, [ebx]
    mov     eax, ecx
    mov     edi, ebp
    mov     edx, [esp+118h+lpidFrom]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    xor     eax, eax
    rep movsb
    mov     ecx, [ebx+0Ch]
    mov     [edx], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44FBB9:                             ; CODE XREF: sub_44F9C0+C1j
    cmp     esi, 887700BEh
    jz      short loc_44FBD8
    cmp     esi, 8877001Eh
    jz      short loc_44FBE0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_44FBD8:                             ; CODE XREF: sub_44F9C0+1FFj
    cmp     esi, 8877001Eh
    jnz     short loc_44FBFA

    loc_44FBE0:                             ; CODE XREF: sub_44F9C0+207j
    mov     eax, [edi]
    mov     ecx, [esp+118h+var_108]
    push    eax
    push    ecx
    lea     edx, [esp+120h+var_100]
    push    offset aNetcondenser3N          ; "netCondenser[3]: needed %ld, had client"...
    push    edx
    call    _sprintf
    add     esp, 10h

    loc_44FBFA:                             ; CODE XREF: sub_44F9C0+B9j
                                            ; sub_44F9C0+21Ej
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    0Ch
    sub_44F9C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall Network_SendNetMessage(int HAPINET_this,int dwDataSize)
    Network_SendNetMessage proc near        ; CODE XREF: .text:004611C3p
                                            ; .text:0046196Cp ...

    PacketID= byte ptr -1
    HAPINET_this= dword ptr  4
    dwDataSize= dword ptr  8

    push    ecx
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    cmp     dword ptr [ebp+1Dh], 0Ch        ; Only bother compressing if packet is more than 12 bytes
    jle     short loc_44FC3F
    call    Network_StartCompression
    mov     eax, [ebp+1Dh]
    mov     edx, [ebp+18h]
    mov     ecx, [ebp+10h]
    push    eax
    add     edx, 3
    push    ecx
    push    edx
    call    DoNetworkCompression
    mov     esi, eax
    call    Network_StopCompression
    jmp     short loc_44FC44
    ; ---------------------------------------------------------------------------

    loc_44FC3F:                             ; CODE XREF: Network_SendNetMessage+Bj
    mov     esi, 0FFFFh

    loc_44FC44:                             ; CODE XREF: Network_SendNetMessage+2Dj
    mov     ecx, [ebp+1Dh]
    lea     eax, [esi+3]
    cmp     eax, ecx
    jnb     short loc_44FC67
    mov     edx, TAdynmemStructPtr
    mov     esi, [edx+4EDh]
    test    esi, esi
    jnz     short loc_44FC67
    mov     [esp+14h+PacketID], PacketID_Compressed
    mov     ebx, eax
    jmp     short loc_44FC86
    ; ---------------------------------------------------------------------------

    loc_44FC67:                             ; CODE XREF: Network_SendNetMessage+3Cj
                                            ; Network_SendNetMessage+4Cj
    mov     edi, [ebp+18h]
    mov     esi, [ebp+10h]
    lea     ebx, [ecx+3]
    mov     eax, ecx
    add     edi, 3
    mov     [esp+14h+PacketID], PacketID_Encypted
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_44FC86:                             ; CODE XREF: Network_SendNetMessage+55j
    mov     eax, 3                          ; Enypt outgoing data!
    lea     edx, [ebx-3]
    xor     esi, esi
    cmp     edx, eax
    jle     short loc_44FCA9
    mov     ecx, [ebp+18h]

    loc_44FC97:                             ; CODE XREF: Network_SendNetMessage+97j
    xor     [eax+ecx], al
    mov     ecx, [ebp+18h]
    movzx   di, byte ptr [eax+ecx]
    add     esi, edi
    inc     eax
    cmp     eax, edx
    jl      short loc_44FC97

    loc_44FCA9:                             ; CODE XREF: Network_SendNetMessage+82j
    mov     ecx, [ebp+18h]
    mov     dl, [esp+14h+PacketID]
    mov     [ecx], dl
    mov     eax, [ebp+18h]
    mov     [eax+1], si
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+37F35h]
    test    eax, eax
    jz      short loc_44FCFA
    call    _rand
    cdq
    push    0
    push    65h
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+37F35h]
    jg      short loc_44FCFA
    xor     esi, esi
    jmp     short loc_44FD14
    ; ---------------------------------------------------------------------------

    loc_44FCFA:                             ; CODE XREF: Network_SendNetMessage+B7j
                                            ; Network_SendNetMessage+E4j
    mov     eax, [ebp+18h]
    mov     ecx, [ebp+21h]
    mov     edx, [esp+14h+dwDataSize]
    push    ebx                             ; idFrom
    push    eax                             ; idTo
    mov     eax, [esp+1Ch+HAPINET_this]
    push    ecx                             ; lpData
    push    edx                             ; dwDataSize
    push    eax                             ; HAPINET_this
    call    HAPINET_SendPacket
    mov     esi, eax

    loc_44FD14:                             ; CODE XREF: Network_SendNetMessage+E8j
    test    esi, esi
    jnz     short loc_44FD27
    mov     ecx, [ebp+1Dh]
    push    1                               ; arg8
    add     ecx, 3
    push    ebx                             ; arg4
    push    ecx                             ; DataSize
    call    HAPINET_PacketStatistics

    loc_44FD27:                             ; CODE XREF: Network_SendNetMessage+106j
    mov     eax, esi
    pop     edi
    mov     dword ptr [ebp+1Dh], 0
    mov     byte ptr [ebp+1Ch], 0
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    Network_SendNetMessage endp

    ; ---------------------------------------------------------------------------
    align 8

    unknown_libname_25:                     ; DATA XREF: sub_451FD0+75o
    or      eax, 0FFFFFFFFh
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_26:                     ; DATA XREF: sub_451FD0+98o
    or      eax, 0FFFFFFFFh
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_27:                     ; DATA XREF: sub_451FD0+B2o
    or      eax, 0FFFFFFFFh
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_28:                     ; DATA XREF: sub_451FD0+C8o
    or      eax, 0FFFFFFFFh
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_29:                     ; DATA XREF: sub_451FD0+DEo
    or      eax, 0FFFFFFFFh
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_30:                     ; DATA XREF: sub_451FD0+F4o
    or      eax, 0FFFFFFFFh
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    xor     eax, eax
    push    ecx
    mov     al, [ecx]
    call    dword_512A20[eax*4]
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44FDB0 proc near                    ; CODE XREF: sub_4233A0+191p
                                            ; sub_4244B0+BFp ...
    push    esi
    mov     esi, TAdynmemStructPtr
    xor     edx, edx
    lea     eax, [esi+1BD6h]

    loc_44FDBF:                             ; CODE XREF: sub_44FDB0+2Dj
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_44FDD2
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_44FDDF
    cmp     cl, 2
    jz      short loc_44FDDF

    loc_44FDD2:                             ; CODE XREF: sub_44FDB0+14j
    inc     edx
    add     eax, 14Bh
    cmp     edx, 0Ah
    jge     short loc_44FDF5
    jmp     short loc_44FDBF
    ; ---------------------------------------------------------------------------

    loc_44FDDF:                             ; CODE XREF: sub_44FDB0+1Bj
                                            ; sub_44FDB0+20j
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     ecx, [esi+eax*2]
    mov     eax, [ecx+edx+1B67h]
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_44FDF5:                             ; CODE XREF: sub_44FDB0+2Bj
    or      eax, 0FFFFFFFFh
    pop     esi
    retn
    sub_44FDB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44FE00 proc near                    ; CODE XREF: .text:0046CEA1p
                                            ; sub_46CEC0+13p ...
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    lea     ecx, [edx+1BD6h]

    loc_44FE0E:                             ; CODE XREF: sub_44FE00+1Dj
    cmp     byte ptr [ecx], 1
    jz      short loc_44FE23
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_44FE0E
    or      eax, 0FFFFFFFFh
    retn
    ; ---------------------------------------------------------------------------

    loc_44FE23:                             ; CODE XREF: sub_44FE00+11j
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     edx, [edx+ecx*2]
    mov     eax, [edx+eax+1B67h]
    retn
    sub_44FE00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_44FE40(int)
    sub_44FE40 proc near                    ; CODE XREF: Network_BroadcastMessage+3Fp
                                            ; Network_BroadcastMessage+A2p ...

    PlayerNumber= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+PlayerNumber]
    cmp     edi, 0FFFFFFFFh
    jz      short loc_44FE9B
    mov     esi, TAdynmemStructPtr
    xor     al, al
    cmp     al, 0Ah
    mov     byte ptr [esp+PlayerNumber], al
    jz      short loc_44FE8A

    loc_44FE5C:                             ; CODE XREF: sub_44FE40+59j
    mov     ecx, [esp+PlayerNumber]
    mov     ebx, esi
    and     ecx, 0FFh
    mov     edx, ecx
    add     ebx, ecx
    shl     edx, 5
    add     edx, ecx
    lea     edx, [edx+edx*4]
    lea     ecx, [ebx+edx*2]
    mov     dl, [ebx+edx*2+TAdynmemStruct.Players.PlayerType]
    test    dl, dl
    jz      short loc_44FE8A
    mov     ecx, [ecx+TAdynmemStruct.Players.field_4]
    jmp     short loc_44FE8D
    ; ---------------------------------------------------------------------------

    loc_44FE8A:                             ; CODE XREF: sub_44FE40+1Aj
                                            ; sub_44FE40+40j
    or      ecx, 0FFFFFFFFh

    loc_44FE8D:                             ; CODE XREF: sub_44FE40+48j
    cmp     ecx, edi
    jz      short loc_44FE9D
    inc     al
    cmp     al, 0Ah
    mov     byte ptr [esp+PlayerNumber], al
    jb      short loc_44FE5C

    loc_44FE9B:                             ; CODE XREF: sub_44FE40+Aj
    mov     al, 0Ah

    loc_44FE9D:                             ; CODE XREF: sub_44FE40+4Fj
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_44FE40 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    test    eax, eax
    jnz     short loc_44FEBD
    mov     al, 0Ah
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44FEBD:                             ; CODE XREF: .text:0044FEB6j
    mov     al, [eax+146h]
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_44FED0 proc near                    ; CODE XREF: sub_46D970+C7p
                                            ; sub_46E000+2Ep ...

    arg_0= dword ptr  4

    mov     edx, TAdynmemStructPtr
    push    ebx
    push    esi
    mov     esi, [esp+8+arg_0]
    cmp     esi, 0FFFFFFFFh
    push    edi
    jz      short loc_44FF30
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+0Ch+arg_0], bl
    jz      short loc_44FF1A

    loc_44FEED:                             ; CODE XREF: sub_44FED0+5Ej
    mov     eax, [esp+0Ch+arg_0]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_44FF1A
    mov     eax, [eax+1B67h]
    jmp     short loc_44FF1D
    ; ---------------------------------------------------------------------------

    loc_44FF1A:                             ; CODE XREF: sub_44FED0+1Bj
                                            ; sub_44FED0+40j
    or      eax, 0FFFFFFFFh

    loc_44FF1D:                             ; CODE XREF: sub_44FED0+48j
    cmp     eax, esi
    jz      loc_44FFBC
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+0Ch+arg_0], bl
    jb      short loc_44FEED

    loc_44FF30:                             ; CODE XREF: sub_44FED0+10j
    mov     al, 0Ah

    loc_44FF32:                             ; CODE XREF: sub_44FED0+EEj
    cmp     al, 0Ah
    jnz     short loc_44FF3E
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44FF3E:                             ; CODE XREF: sub_44FED0+64j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_44FF95
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+0Ch+arg_0], bl
    jz      short loc_44FF7B

    loc_44FF4E:                             ; CODE XREF: sub_44FED0+BBj
    mov     eax, [esp+0Ch+arg_0]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_44FF7B
    mov     eax, [eax+1B67h]
    jmp     short loc_44FF7E
    ; ---------------------------------------------------------------------------

    loc_44FF7B:                             ; CODE XREF: sub_44FED0+7Cj
                                            ; sub_44FED0+A1j
    or      eax, 0FFFFFFFFh

    loc_44FF7E:                             ; CODE XREF: sub_44FED0+A9j
    cmp     eax, esi
    jz      short loc_44FF8F
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+0Ch+arg_0], bl
    jb      short loc_44FF4E
    jmp     short loc_44FF95
    ; ---------------------------------------------------------------------------

    loc_44FF8F:                             ; CODE XREF: sub_44FED0+B0j
    mov     byte ptr [esp+0Ch+arg_0], bl
    jmp     short loc_44FF9A
    ; ---------------------------------------------------------------------------

    loc_44FF95:                             ; CODE XREF: sub_44FED0+71j
                                            ; sub_44FED0+BDj
    mov     byte ptr [esp+0Ch+arg_0], 0Ah

    loc_44FF9A:                             ; CODE XREF: sub_44FED0+C3j
    mov     eax, [esp+0Ch+arg_0]
    pop     edi
    and     eax, 0FFh
    pop     esi
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    pop     ebx
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+1B63h]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_44FFBC:                             ; CODE XREF: sub_44FED0+4Fj
    mov     al, bl
    jmp     loc_44FF32
    sub_44FED0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall PlayerNumberToID(int)
    PlayerNumberToID proc near              ; CODE XREF: .text:0044604Dp
                                            ; sub_448C70+D22p ...

    PlayerNumber= dword ptr  4

    mov     ecx, [esp+PlayerNumber]         ; arg_0 is a byte value expanded to a double word. 3/4s of it is ignored
    cmp     cl, 0Ah                         ; if (arg_0 != 10) {
    jz      short loc_450007
    and     ecx, 0FFh
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*2]
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+eax+TAdynmemStruct.Players.PlayerType]
    test    dl, dl
    jz      short loc_450007
    mov     eax, [ecx+eax+TAdynmemStruct.Players.field_4]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_450007:                             ; CODE XREF: PlayerNumberToID+7j
                                            ; PlayerNumberToID+2Bj
    or      eax, 0FFFFFFFFh
    retn    4
    PlayerNumberToID endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_450010 proc near                    ; CODE XREF: sub_488570+98p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short loc_450025
    mov     cl, [eax+73h]
    test    cl, cl
    jz      short loc_450025
    mov     eax, [eax+4]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_450025:                             ; CODE XREF: sub_450010+6j
                                            ; sub_450010+Dj
    or      eax, 0FFFFFFFFh
    retn    4
    sub_450010 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_450030 proc near                    ; CODE XREF: sub_4244B0+B9p
                                            ; sub_46D4C0+Fp ...
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    esi
    xor     eax, eax
    lea     ecx, [edx+1B8Ah]
    mov     bl, 1

    loc_450042:                             ; CODE XREF: sub_450030+26j
    mov     esi, [ecx]
    test    [esi+97h], bl
    jnz     short loc_45005E
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_450042
    or      eax, 0FFFFFFFFh
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_45005E:                             ; CODE XREF: sub_450030+1Aj
    cmp     al, 0Ah
    jz      short loc_45008A
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2]
    mov     cl, [edx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_45008A
    mov     eax, [eax+1B67h]
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_45008A:                             ; CODE XREF: sub_450030+30j
                                            ; sub_450030+4Fj
    pop     esi
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn
    sub_450030 endp

    ; ---------------------------------------------------------------------------
    sub     esp, 10h
    mov     eax, [esp+14h]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    push    ebx
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    push    esi
    push    edi
    mov     edi, [esp+28h]
    lea     ecx, [ecx+ecx*4]
    push    1Eh
    push    edi
    lea     esi, [edx+ecx*2+1B63h]
    lea     eax, [esi+2Bh]
    push    eax
    call    _strncpy
    mov     ebx, [esp+30h]
    add     esp, 0Ch
    lea     ecx, [esi+49h]
    push    1Eh
    push    ebx
    push    ecx
    call    _strncpy
    add     esp, 0Ch
    mov     dword ptr [esp+0Ch], 10h
    test    esi, esi
    mov     dword ptr [esp+10h], 0
    mov     [esp+14h], ebx
    mov     [esp+18h], edi
    jz      short loc_450106
    mov     al, [esi+73h]
    test    al, al
    jz      short loc_450106
    mov     esi, [esi+4]
    jmp     short loc_450109
    ; ---------------------------------------------------------------------------

    loc_450106:                             ; CODE XREF: .text:004500F8j
                                            ; .text:004500FFj
    or      esi, 0FFFFFFFFh

    loc_450109:                             ; CODE XREF: .text:00450104j
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+0Ch]
    push    2
    push    edx
    add     eax, 14h
    push    esi
    push    eax
    call    sub_4CA800
    xor     ecx, ecx
    pop     edi
    test    eax, eax
    setz    cl
    pop     esi
    mov     eax, ecx
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    sub     esp, 404h
    cmp     eax, 0FFFFFFFFh
    push    esi
    push    edi
    jz      loc_4501DC
    lea     ecx, [esp+8]
    lea     edx, [esp+0Ch]
    push    ecx
    push    edx
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 14h
    mov     dword ptr [esp+14h], 400h
    push    eax
    call    sub_4CA7C0
    mov     edx, eax
    test    edx, edx
    jnz     loc_45022A
    mov     edi, [esp+14h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+414h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+18h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+418h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    test    edx, edx
    rep movsb
    setz    al
    pop     edi
    pop     esi
    add     esp, 404h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4501DC:                             ; CODE XREF: .text:0045014Fj
    mov     edi, offset aComputer           ; "COMPUTER"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, [esp+414h]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, offset aComputer           ; "COMPUTER"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+418h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    xor     edx, edx
    rep movsb

    loc_45022A:                             ; CODE XREF: .text:0045017Aj
    xor     eax, eax
    pop     edi
    test    edx, edx
    setz    al
    pop     esi
    add     esp, 404h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    mov     eax, 0Ah
    xor     ebp, ebp
    mov     esi, eax
    lea     ecx, [edi+1B63h]
    mov     bl, 3

    loc_45025C:                             ; CODE XREF: .text:00450281j
    mov     edx, [ecx]
    test    edx, edx
    jz      short loc_45027A
    cmp     [ecx+73h], bl
    jz      short loc_450271
    test    edx, edx
    jz      short loc_45027A
    cmp     byte ptr [ecx+73h], 1
    jnz     short loc_45027A

    loc_450271:                             ; CODE XREF: .text:00450265j
    mov     edx, [ecx+4]
    cmp     edx, ebp
    jbe     short loc_45027A
    mov     ebp, edx

    loc_45027A:                             ; CODE XREF: .text:00450260j
                                            ; .text:00450269j ...
    add     ecx, 14Bh
    dec     esi
    jnz     short loc_45025C
    cmp     ebp, 0FFFFFFFFh
    jz      short loc_4502D5
    xor     bl, bl
    cmp     bl, al
    mov     [esp+10h], bl
    jz      short loc_4502C0

    loc_450292:                             ; CODE XREF: .text:004502D3j
    mov     ecx, [esp+10h]
    mov     esi, edi
    and     ecx, 0FFh
    mov     edx, ecx
    add     esi, ecx
    shl     edx, 5
    add     edx, ecx
    lea     edx, [edx+edx*4]
    lea     ecx, [esi+edx*2]
    mov     dl, [esi+edx*2+1BD6h]
    test    dl, dl
    jz      short loc_4502C0
    mov     ecx, [ecx+1B67h]
    jmp     short loc_4502C3
    ; ---------------------------------------------------------------------------

    loc_4502C0:                             ; CODE XREF: .text:00450290j
                                            ; .text:004502B6j
    or      ecx, 0FFFFFFFFh

    loc_4502C3:                             ; CODE XREF: .text:004502BEj
    cmp     ecx, ebp
    jz      loc_45036A
    inc     bl
    cmp     bl, al
    mov     [esp+10h], bl
    jb      short loc_450292

    loc_4502D5:                             ; CODE XREF: .text:00450286j
    mov     cl, al

    loc_4502D7:                             ; CODE XREF: .text:0045036Cj
    cmp     cl, al
    jnz     short loc_4502DF
    xor     ecx, ecx
    jmp     short loc_450356
    ; ---------------------------------------------------------------------------

    loc_4502DF:                             ; CODE XREF: .text:004502D9j
    cmp     ebp, 0FFFFFFFFh
    jz      short loc_450335
    xor     bl, bl
    cmp     bl, al
    mov     [esp+10h], bl
    jz      short loc_45031C

    loc_4502EE:                             ; CODE XREF: .text:0045032Bj
    mov     ecx, [esp+10h]
    mov     esi, edi
    and     ecx, 0FFh
    mov     edx, ecx
    add     esi, ecx
    shl     edx, 5
    add     edx, ecx
    lea     edx, [edx+edx*4]
    lea     ecx, [esi+edx*2]
    mov     dl, [esi+edx*2+1BD6h]
    test    dl, dl
    jz      short loc_45031C
    mov     ecx, [ecx+1B67h]
    jmp     short loc_45031F
    ; ---------------------------------------------------------------------------

    loc_45031C:                             ; CODE XREF: .text:004502ECj
                                            ; .text:00450312j
    or      ecx, 0FFFFFFFFh

    loc_45031F:                             ; CODE XREF: .text:0045031Aj
    cmp     ecx, ebp
    jz      short loc_45032F
    inc     bl
    cmp     bl, al
    mov     [esp+10h], bl
    jb      short loc_4502EE
    jmp     short loc_450335
    ; ---------------------------------------------------------------------------

    loc_45032F:                             ; CODE XREF: .text:00450321j
    mov     [esp+10h], bl
    jmp     short loc_450339
    ; ---------------------------------------------------------------------------

    loc_450335:                             ; CODE XREF: .text:004502E2j
                                            ; .text:0045032Dj
    mov     [esp+10h], al

    loc_450339:                             ; CODE XREF: .text:00450333j
    mov     ecx, [esp+10h]
    and     ecx, 0FFh
    mov     edx, ecx
    shl     edx, 5
    add     edx, ecx
    add     edi, ecx
    lea     edx, [edx+edx*4]
    lea     ecx, [edi+edx*2+1B63h]

    loc_450356:                             ; CODE XREF: .text:004502DDj
    test    ecx, ecx
    jz      short loc_450364
    mov     ecx, [ecx+27h]
    or      byte ptr [ecx+97h], 1

    loc_450364:                             ; CODE XREF: .text:00450358j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_45036A:                             ; CODE XREF: .text:004502C5j
    mov     cl, bl
    jmp     loc_4502D7
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_450380 proc near                    ; CODE XREF: sub_4866D0+762p

    var_CC= dword ptr -0CCh
    var_C8= byte ptr -0C8h
    arg_0= dword ptr  4

    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    sub     esp, 0CCh
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    push    ebx
    shl     eax, 5
    push    esi
    add     eax, ecx
    mov     esi, edx
    push    edi
    lea     eax, [eax+eax*4]
    add     esi, ecx
    cmp     byte ptr [esi+eax*2+1B85h], 1
    jz      loc_4504D4
    mov     esi, [esp+0D8h+arg_0]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_45040D
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+0D8h+var_CC], bl
    jz      short loc_4503F7

    loc_4503CA:                             ; CODE XREF: sub_450380+8Bj
    mov     eax, [esp+0D8h+var_CC]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4503F7
    mov     eax, [eax+1B67h]
    jmp     short loc_4503FA
    ; ---------------------------------------------------------------------------

    loc_4503F7:                             ; CODE XREF: sub_450380+48j
                                            ; sub_450380+6Dj
    or      eax, 0FFFFFFFFh

    loc_4503FA:                             ; CODE XREF: sub_450380+75j
    cmp     eax, esi
    jz      loc_4504E0
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+0D8h+var_CC], bl
    jb      short loc_4503CA

    loc_45040D:                             ; CODE XREF: sub_450380+3Dj
    mov     al, 0Ah

    loc_45040F:                             ; CODE XREF: sub_450380+162j
    cmp     al, 0Ah
    jnz     short loc_450417
    xor     esi, esi
    jmp     short loc_45048F
    ; ---------------------------------------------------------------------------

    loc_450417:                             ; CODE XREF: sub_450380+91j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_45046E
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+0D8h+var_CC], bl
    jz      short loc_450454

    loc_450427:                             ; CODE XREF: sub_450380+E4j
    mov     eax, [esp+0D8h+var_CC]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_450454
    mov     eax, [eax+1B67h]
    jmp     short loc_450457
    ; ---------------------------------------------------------------------------

    loc_450454:                             ; CODE XREF: sub_450380+A5j
                                            ; sub_450380+CAj
    or      eax, 0FFFFFFFFh

    loc_450457:                             ; CODE XREF: sub_450380+D2j
    cmp     eax, esi
    jz      short loc_450468
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+0D8h+var_CC], bl
    jb      short loc_450427
    jmp     short loc_45046E
    ; ---------------------------------------------------------------------------

    loc_450468:                             ; CODE XREF: sub_450380+D9j
    mov     byte ptr [esp+0D8h+var_CC], bl
    jmp     short loc_450473
    ; ---------------------------------------------------------------------------

    loc_45046E:                             ; CODE XREF: sub_450380+9Aj
                                            ; sub_450380+E6j
    mov     byte ptr [esp+0D8h+var_CC], 0Ah

    loc_450473:                             ; CODE XREF: sub_450380+ECj
    mov     eax, [esp+0D8h+var_CC]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    lea     esi, [edx+ecx*2+1B63h]

    loc_45048F:                             ; CODE XREF: sub_450380+95j
    test    esi, esi
    jz      short loc_4504D4
    call    _rand
    and     eax, 7
    mov     edx, dword_5061B8[eax*4]
    push    edx                             ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esi+2Bh]
    push    eax
    lea     ecx, [esp+0E0h+var_C8]
    push    offset aSS_0                    ; "%s %s"
    push    ecx
    call    _sprintf
    mov     dl, [esi+146h]
    add     esp, 10h
    lea     eax, [esp+0D8h+var_C8]
    push    edx                             ; char
    push    0                               ; __int16
    push    4                               ; char
    push    eax                             ; char *
    call    sub_463CA0

    loc_4504D4:                             ; CODE XREF: sub_450380+2Dj
                                            ; sub_450380+111j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0CCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4504E0:                             ; CODE XREF: sub_450380+7Cj
    mov     al, bl
    jmp     loc_45040F
    sub_450380 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    push    esi
    xor     esi, esi
    xor     eax, eax
    add     ecx, 1B63h
    mov     dl, 4

    loc_450503:                             ; CODE XREF: .text:00450517j
    cmp     dword ptr [ecx], 0
    jnz     short loc_45050D
    cmp     [ecx+73h], dl
    jnz     short loc_45051B

    loc_45050D:                             ; CODE XREF: .text:00450506j
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_450503
    jmp     short loc_450520
    ; ---------------------------------------------------------------------------

    loc_45051B:                             ; CODE XREF: .text:0045050Bj
    mov     esi, 1

    loc_450520:                             ; CODE XREF: .text:00450519j
    test    esi, esi
    jnz     short loc_450529
    mov     eax, 0Ah

    loc_450529:                             ; CODE XREF: .text:00450522j
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_450530 proc near                    ; CODE XREF: sub_450A10+312p
                                            ; sub_450F90+DCp ...

    var_10= dword ptr -10h
    idTo= dword ptr -0Ch
    var_6= dword ptr -6

    sub     esp, 10h
    push    edi
    mov     edi, TAdynmemStructPtr
    cmp     dword ptr [edi+391F1h], 6
    jz      loc_4508C0
    push    esi
    push    ebp
    push    ebx
    xor     ebp, ebp
    mov     ebx, 1

    loc_450551:                             ; CODE XREF: sub_450530+387j
    mov     eax, ebp
    mov     ecx, edi
    shl     eax, 5
    add     eax, ebp
    add     ecx, ebp
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*2+1B63h]
    mov     eax, [ecx+eax*2+1B63h]
    test    eax, eax
    jz      loc_4508B3
    mov     al, [esi+73h]
    cmp     al, bl
    jz      short loc_450588
    cmp     al, 2
    jz      short loc_450588
    cmp     al, 3
    jnz     loc_4508B3

    loc_450588:                             ; CODE XREF: sub_450530+4Aj
                                            ; sub_450530+4Ej
    cmp     byte ptr [esi+146h], 0Ah
    jz      loc_4508B3
    mov     ecx, [esi+0Ch]
    test    ecx, ecx
    jnz     loc_4508B3
    cmp     al, bl
    jz      short loc_4505B4
    cmp     al, 2
    jnz     loc_4506A7
    cmp     al, bl
    jnz     loc_4506AB

    loc_4505B4:                             ; CODE XREF: sub_450530+72j
    call    sub_456850
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    mov     ecx, [eax+edx*2+1B63h]
    lea     eax, [eax+edx*2+1B63h]
    test    ecx, ecx
    jz      short loc_4505F8
    mov     al, [eax+73h]
    cmp     al, bl
    jz      loc_4506F6
    cmp     al, 2
    jnz     short loc_4505F8
    mov     [esi+0Ch], ebx
    jmp     loc_4508AD
    ; ---------------------------------------------------------------------------

    loc_4505F8:                             ; CODE XREF: sub_450530+AFj
                                            ; sub_450530+BEj
    mov     byte ptr [esp+20h+idTo], 21h
    mov     byte ptr [esp+20h+idTo+1], bl
    mov     ecx, [esi+4]
    or      edi, 0FFFFFFFFh
    mov     [esp+20h+idTo+2], ecx
    mov     [esp+20h+var_6], edi
    call    sub_456850
    cmp     al, 0Ah
    jz      loc_4508AD
    mov     esi, TAdynmemStructPtr
    xor     eax, eax
    lea     ecx, [esi+1B8Ah]

    loc_45062A:                             ; CODE XREF: sub_450530+10Ej
    mov     edx, [ecx]
    test    [edx+97h], bl
    jnz     short loc_450642
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_45062A
    jmp     short loc_450650
    ; ---------------------------------------------------------------------------

    loc_450642:                             ; CODE XREF: sub_450530+102j
    push    eax                             ; int
    call    PlayerNumberToID
    mov     esi, TAdynmemStructPtr
    mov     edi, eax

    loc_450650:                             ; CODE XREF: sub_450530+110j
    xor     ecx, ecx
    lea     edx, [esi+1BD6h]

    loc_450658:                             ; CODE XREF: sub_450530+145j
    mov     eax, [edx-73h]
    test    eax, eax
    jz      short loc_450669
    mov     al, [edx]
    cmp     al, bl
    jz      short loc_450677
    cmp     al, 2
    jz      short loc_450677

    loc_450669:                             ; CODE XREF: sub_450530+12Dj
    inc     ecx
    add     edx, 14Bh
    cmp     ecx, 0Ah
    jge     short loc_450697
    jmp     short loc_450658
    ; ---------------------------------------------------------------------------

    loc_450677:                             ; CODE XREF: sub_450530+133j
                                            ; sub_450530+137j
    mov     edx, ecx
    push    0Ah
    shl     edx, 5
    add     edx, ecx
    add     esi, ecx
    lea     ecx, [esp+24h+idTo]
    lea     eax, [edx+edx*4]
    push    ecx
    push    edi
    mov     eax, [esi+eax*2+1B67h]
    jmp     loc_4508A7
    ; ---------------------------------------------------------------------------

    loc_450697:                             ; CODE XREF: sub_450530+143j
    lea     ecx, [esp+20h+idTo]
    push    0Ah
    push    ecx
    or      eax, 0FFFFFFFFh
    push    edi
    jmp     loc_4508A7
    ; ---------------------------------------------------------------------------

    loc_4506A7:                             ; CODE XREF: sub_450530+76j
    cmp     al, bl
    jz      short loc_4506B3

    loc_4506AB:                             ; CODE XREF: sub_450530+7Ej
    cmp     al, 2
    jnz     loc_4507BD

    loc_4506B3:                             ; CODE XREF: sub_450530+179j
    cmp     al, 2
    jnz     loc_4507BD
    call    sub_456850
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     edx, eax
    mov     edi, ecx
    shl     eax, 5
    add     eax, edx
    add     edi, edx
    lea     eax, [eax+eax*4]
    mov     edx, [edi+eax*2+1B63h]
    lea     eax, [edi+eax*2+1B63h]
    test    edx, edx
    jz      short loc_4506FE
    mov     al, [eax+73h]
    cmp     al, bl
    jz      short loc_4506F6
    cmp     al, 2
    jnz     short loc_4506FE

    loc_4506F6:                             ; CODE XREF: sub_450530+B6j
                                            ; sub_450530+1C0j
    mov     [esi+0Ch], ebx
    jmp     loc_4508AD
    ; ---------------------------------------------------------------------------

    loc_4506FE:                             ; CODE XREF: sub_450530+1B9j
                                            ; sub_450530+1C4j
    mov     byte ptr [esp+20h+idTo], 21h
    mov     byte ptr [esp+20h+idTo+1], bl
    mov     edx, [esi+4]
    mov     [esp+20h+idTo+2], edx
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B67h]
    mov     [esp+20h+var_6], ecx
    call    sub_456850
    cmp     al, 0Ah
    jz      loc_4508AD
    mov     esi, TAdynmemStructPtr
    xor     eax, eax
    lea     ecx, [esi+1B8Ah]

    loc_450748:                             ; CODE XREF: sub_450530+230j
    mov     edx, [ecx]
    test    [edx+97h], bl
    jnz     loc_4508C5
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_450748
    or      edi, 0FFFFFFFFh

    loc_450765:                             ; CODE XREF: sub_450530+3C2j
                                            ; sub_450530+3CCj
    xor     eax, eax
    lea     ecx, [esi+1BD6h]

    loc_45076D:                             ; CODE XREF: sub_450530+25Bj
    mov     edx, [ecx-73h]
    test    edx, edx
    jz      short loc_45077F
    mov     dl, [ecx]
    cmp     dl, bl
    jz      short loc_45078D
    cmp     dl, 2
    jz      short loc_45078D

    loc_45077F:                             ; CODE XREF: sub_450530+242j
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jge     short loc_4507AD
    jmp     short loc_45076D
    ; ---------------------------------------------------------------------------

    loc_45078D:                             ; CODE XREF: sub_450530+248j
                                            ; sub_450530+24Dj
    mov     ecx, eax
    lea     edx, [esp+20h+idTo]
    shl     ecx, 5
    add     ecx, eax
    add     esi, eax
    push    0Ah
    push    edx
    lea     ecx, [ecx+ecx*4]
    push    edi
    mov     eax, [esi+ecx*2+1B67h]
    jmp     loc_4508A7
    ; ---------------------------------------------------------------------------

    loc_4507AD:                             ; CODE XREF: sub_450530+259j
    lea     edx, [esp+20h+idTo]
    push    0Ah
    push    edx
    or      eax, 0FFFFFFFFh
    push    edi
    jmp     loc_4508A7
    ; ---------------------------------------------------------------------------

    loc_4507BD:                             ; CODE XREF: sub_450530+17Dj
                                            ; sub_450530+185j
    cmp     al, 3
    jnz     loc_4508B3
    mov     byte ptr [esp+20h+idTo], 21h
    mov     byte ptr [esp+20h+idTo+1], 0
    mov     eax, [esi+4]
    xor     dl, dl
    mov     [esp+20h+idTo+2], eax
    mov     [esp+20h+var_6], 0FFFFFFFFh
    mov     byte ptr [esp+20h+var_10], dl

    loc_4507E4:                             ; CODE XREF: sub_450530+2F0j
    mov     eax, [esp+20h+var_10]
    mov     esi, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_450817
    mov     eax, [eax+1B8Ah]
    test    [eax+97h], bl
    jnz     short loc_450824

    loc_450817:                             ; CODE XREF: sub_450530+2D7j
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+20h+var_10], dl
    jb      short loc_4507E4
    mov     dl, 0Ah

    loc_450824:                             ; CODE XREF: sub_450530+2E5j
    cmp     dl, 0Ah
    jz      loc_4508B3
    xor     eax, eax
    lea     ecx, [edi+1B8Ah]

    loc_450835:                             ; CODE XREF: sub_450530+319j
    mov     edx, [ecx]
    test    [edx+97h], bl
    jnz     short loc_45084D
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_450835
    jmp     short loc_45085D
    ; ---------------------------------------------------------------------------

    loc_45084D:                             ; CODE XREF: sub_450530+30Dj
    push    eax                             ; int
    call    PlayerNumberToID
    mov     edi, TAdynmemStructPtr
    mov     esi, eax
    jmp     short loc_450860
    ; ---------------------------------------------------------------------------

    loc_45085D:                             ; CODE XREF: sub_450530+31Bj
    or      esi, 0FFFFFFFFh

    loc_450860:                             ; CODE XREF: sub_450530+32Bj
    xor     ecx, ecx
    lea     edx, [edi+1BD6h]

    loc_450868:                             ; CODE XREF: sub_450530+355j
    mov     eax, [edx-73h]
    test    eax, eax
    jz      short loc_450879
    mov     al, [edx]
    cmp     al, bl
    jz      short loc_450887
    cmp     al, 2
    jz      short loc_450887

    loc_450879:                             ; CODE XREF: sub_450530+33Dj
    inc     ecx
    add     edx, 14Bh
    cmp     ecx, 0Ah
    jge     short loc_45089C
    jmp     short loc_450868
    ; ---------------------------------------------------------------------------

    loc_450887:                             ; CODE XREF: sub_450530+343j
                                            ; sub_450530+347j
    mov     edx, ecx
    shl     edx, 5
    add     edx, ecx
    add     edi, ecx
    lea     eax, [edx+edx*4]
    mov     eax, [edi+eax*2+1B67h]
    jmp     short loc_45089F
    ; ---------------------------------------------------------------------------

    loc_45089C:                             ; CODE XREF: sub_450530+353j
    or      eax, 0FFFFFFFFh

    loc_45089F:                             ; CODE XREF: sub_450530+36Aj
    lea     ecx, [esp+20h+idTo]
    push    0Ah                             ; idFrom
    push    ecx                             ; idTo
    push    esi                             ; PlayersToSendTo

    loc_4508A7:                             ; CODE XREF: sub_450530+162j
                                            ; sub_450530+172j ...
    push    eax                             ; dwDataSize
    call    Network_BroadcastMessage

    loc_4508AD:                             ; CODE XREF: sub_450530+C3j
                                            ; sub_450530+E6j ...
    mov     edi, TAdynmemStructPtr

    loc_4508B3:                             ; CODE XREF: sub_450530+3Fj
                                            ; sub_450530+52j ...
    inc     ebp
    cmp     ebp, 0Ah
    jl      loc_450551
    pop     ebx
    pop     ebp
    pop     esi

    loc_4508C0:                             ; CODE XREF: sub_450530+11j
    pop     edi
    add     esp, 10h
    retn
    ; ---------------------------------------------------------------------------

    loc_4508C5:                             ; CODE XREF: sub_450530+220j
    cmp     al, 0Ah
    jz      short loc_4508F7
    and     eax, 0FFh
    mov     edx, esi
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    add     edx, ecx
    lea     eax, [eax+eax*4]
    mov     cl, [edx+eax*2+1BD6h]
    lea     eax, [edx+eax*2]
    test    cl, cl
    jz      short loc_4508F7
    mov     eax, [eax+1B67h]
    mov     edi, eax
    jmp     loc_450765
    ; ---------------------------------------------------------------------------

    loc_4508F7:                             ; CODE XREF: sub_450530+397j
                                            ; sub_450530+3B8j
    or      eax, 0FFFFFFFFh
    mov     edi, eax
    jmp     loc_450765
    sub_450530 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    ebp
    mov     ebp, TAdynmemStructPtr
    push    esi
    push    edi
    mov     eax, 1
    mov     ebx, 0Ah

    loc_450924:                             ; CODE XREF: .text:00450968j
    xor     edi, edi
    lea     ecx, [ebp+1BD6h]
    mov     esi, ebx

    loc_45092E:                             ; CODE XREF: .text:0045095Fj
    mov     edx, [ecx-73h]
    test    edx, edx
    jz      short loc_450958
    mov     dl, [ecx]
    cmp     dl, 1
    jz      short loc_450946
    cmp     dl, 2
    jz      short loc_450946
    cmp     dl, 3
    jnz     short loc_450958

    loc_450946:                             ; CODE XREF: .text:0045093Aj
                                            ; .text:0045093Fj
    cmp     [ecx+0D3h], bl
    jz      short loc_450958
    cmp     [ecx-67h], eax
    jnz     short loc_450958
    mov     edi, 1

    loc_450958:                             ; CODE XREF: .text:00450933j
                                            ; .text:00450944j ...
    add     ecx, 14Bh
    dec     esi
    jnz     short loc_45092E
    test    edi, edi
    jz      short loc_45096C
    inc     eax
    cmp     eax, ebx
    jle     short loc_450924
    xor     al, al

    loc_45096C:                             ; CODE XREF: .text:00450963j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_450980 proc near                    ; CODE XREF: Network_Process+BFCp
                                            ; Network_Process+221Fp

    var_2C= dword ptr -2Ch

    sub     esp, 2Ch
    mov     ecx, 0Bh
    xor     eax, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    lea     edi, [esp+3Ch+var_2C]
    xor     esi, esi
    rep stosd
    mov     edi, TAdynmemStructPtr
    xor     edx, edx
    mov     ebx, 0Ah
    lea     ecx, [edi+1BD6h]

    loc_4509A9:                             ; CODE XREF: sub_450980+6Aj
    mov     eax, [ecx-73h]
    test    eax, eax
    jz      short loc_4509E1
    mov     al, [ecx]
    cmp     al, 1
    jz      short loc_4509BE
    cmp     al, 2
    jz      short loc_4509BE
    cmp     al, 3
    jnz     short loc_4509E1

    loc_4509BE:                             ; CODE XREF: sub_450980+34j
                                            ; sub_450980+38j
    cmp     [ecx+0D3h], bl
    jz      short loc_4509E1
    mov     eax, [ecx-67h]
    test    eax, eax
    jle     short loc_4509E1
    cmp     eax, ebx
    jg      short loc_4509E1
    mov     ebp, [esp+eax*4+3Ch+var_2C]
    lea     eax, [esp+eax*4+3Ch+var_2C]
    inc     ebp
    cmp     ebp, 1
    mov     [eax], ebp
    jg      short loc_4509FA

    loc_4509E1:                             ; CODE XREF: sub_450980+2Ej
                                            ; sub_450980+3Cj ...
    inc     edx
    add     ecx, 14Bh
    cmp     edx, ebx
    jl      short loc_4509A9
    mov     [edi+299Ch], esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4509FA:                             ; CODE XREF: sub_450980+5Fj
    mov     esi, 1
    mov     [edi+299Ch], esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn
    sub_450980 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_450A10 proc near                    ; CODE XREF: sub_4515D0+5Dp
                                            ; Network_Process+403p

    var_4C4= dword ptr -4C4h
    var_4C0= dword ptr -4C0h
    idTo= dword ptr -4BCh
    var_42B= dword ptr -42Bh
    var_400= dword ptr -400h
    var_3F8= dword ptr -3F8h
    var_3F4= dword ptr -3F4h
    arg_0= dword ptr  4

    sub     esp, 4C4h
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    push    edi
    mov     edi, [esp+4D4h+arg_0]
    cmp     edi, 0FFFFFFFFh
    jz      short loc_450A7A
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+4D4h+var_4C4], dl
    jz      short loc_450A64

    loc_450A37:                             ; CODE XREF: sub_450A10+68j
    mov     eax, [esp+4D4h+var_4C4]
    mov     ebx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_450A64
    mov     eax, [eax+1B67h]
    jmp     short loc_450A67
    ; ---------------------------------------------------------------------------

    loc_450A64:                             ; CODE XREF: sub_450A10+25j
                                            ; sub_450A10+4Aj
    or      eax, 0FFFFFFFFh

    loc_450A67:                             ; CODE XREF: sub_450A10+52j
    cmp     eax, edi
    jz      loc_450D71
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+4D4h+var_4C4], dl
    jb      short loc_450A37

    loc_450A7A:                             ; CODE XREF: sub_450A10+1Aj
    mov     al, 0Ah

    loc_450A7C:                             ; CODE XREF: sub_450A10+363j
    xor     edi, edi
    cmp     al, 0Ah
    mov     byte ptr [esp+4D4h+var_4C4], al
    jz      short loc_450AC3
    mov     eax, [esp+4D4h+var_4C4]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, esi
    add     ecx, eax
    mov     al, [ecx+edx*2+1BD6h]
    lea     ecx, [ecx+edx*2]
    cmp     al, 1
    jz      short loc_450AB4
    cmp     al, 2
    jz      short loc_450AB4
    mov     edi, 1

    loc_450AB4:                             ; CODE XREF: sub_450A10+99j
                                            ; sub_450A10+9Dj
    mov     eax, [ecx+1B63h]
    test    eax, eax
    jz      short loc_450B24
    or      edi, 1
    jmp     short loc_450B24
    ; ---------------------------------------------------------------------------

    loc_450AC3:                             ; CODE XREF: sub_450A10+74j
    xor     edx, edx
    xor     ecx, ecx
    lea     eax, [esi+1B63h]
    mov     bl, 4

    loc_450ACF:                             ; CODE XREF: sub_450A10+D2j
    cmp     dword ptr [eax], 0
    jnz     short loc_450AD9
    cmp     [eax+73h], bl
    jnz     short loc_450AE6

    loc_450AD9:                             ; CODE XREF: sub_450A10+C2j
    inc     ecx
    add     eax, 14Bh
    cmp     ecx, 0Ah
    jl      short loc_450ACF
    jmp     short loc_450AEB
    ; ---------------------------------------------------------------------------

    loc_450AE6:                             ; CODE XREF: sub_450A10+C7j
    mov     edx, 1

    loc_450AEB:                             ; CODE XREF: sub_450A10+D4j
    test    edx, edx
    mov     eax, ecx
    jnz     short loc_450AF6
    mov     eax, 0Ah

    loc_450AF6:                             ; CODE XREF: sub_450A10+DFj
    cmp     al, 0Ah
    mov     byte ptr [esp+4D4h+var_4C4], al
    jnz     short loc_450B05
    mov     edi, 1
    jmp     short loc_450B24
    ; ---------------------------------------------------------------------------

    loc_450B05:                             ; CODE XREF: sub_450A10+ECj
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    lea     edx, [eax+eax*4]
    mov     byte ptr [esi+edx*2+1BD6h], 3
    mov     esi, TAdynmemStructPtr

    loc_450B24:                             ; CODE XREF: sub_450A10+ACj
                                            ; sub_450A10+B1j ...
    mov     eax, [esp+4D4h+var_4C4]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    test    edi, edi
    lea     ecx, [ecx+ecx*4]
    lea     ebp, [eax+ecx*2]
    lea     ebx, [esi+ebp+1B63h]
    jnz     loc_450D5F
    mov     eax, [esp+4D4h+arg_0]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_450BC8
    lea     edx, [esp+4D4h+var_4C0]
    lea     ecx, [esp+4D4h+var_400]
    push    edx
    push    ecx
    add     esi, 14h
    push    eax
    push    esi
    mov     [esp+4E4h+var_4C0], 400h
    call    sub_4CA7C0
    mov     edx, eax
    test    edx, edx
    jnz     loc_450D5F
    mov     edi, [esp+4D4h+var_3F8]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    lea     edi, [ebx+49h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+4D4h+var_3F4]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    lea     edi, [ebx+2Bh]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_450C0E
    ; ---------------------------------------------------------------------------

    loc_450BC8:                             ; CODE XREF: sub_450A10+143j
    mov     edi, offset aComputer           ; "COMPUTER"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    lea     edi, [ebx+49h]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, offset aComputer           ; "COMPUTER"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    lea     edi, [ebx+2Bh]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    xor     edx, edx
    rep movsb

    loc_450C0E:                             ; CODE XREF: sub_450A10+1B6j
    test    edx, edx
    jnz     loc_450D5F
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+4D4h+var_4C4]
    mov     dl, [ecx+ebp+1BD6h]
    push    edx
    push    eax
    call    sub_464290
    mov     byte ptr [ebx+22h], 0
    mov     ecx, [esp+4D4h+arg_0]
    mov     [ebx+4], ecx
    call    sub_4B6340
    mov     [ebx+1Ch], eax
    mov     eax, TAdynmemStructPtr
    inc     [eax+TAdynmemStruct.LOS_Radar]
    mov     edx, TAdynmemStructPtr
    test    [edx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_450D33
    xor     ebx, ebx

    loc_450C65:                             ; CODE XREF: sub_450A10+30Cj
    mov     eax, TAdynmemStructPtr
    lea     ebp, [eax+ebx+TAdynmemStruct.Players]
    mov     eax, [eax+ebx+TAdynmemStruct.Players.PlayerActive]
    test    eax, eax
    jz      loc_450D10
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_450C8F
    cmp     al, 2
    jnz     loc_450D10

    loc_450C8F:                             ; CODE XREF: sub_450A10+275j
    mov     esi, [ebp+27h]
    mov     ecx, 2Eh
    lea     edi, [esp+4D4h+idTo+1]
    lea     edx, [esp+4D4h+idTo]
    rep movsd
    movsb
    mov     ecx, [ebp+4]
    mov     byte ptr [esp+4D4h+idTo], 20h
    mov     [esp+4D4h+var_42B], ecx
    mov     eax, [ebp+4]
    push    0BAh                            ; idFrom
    push    edx                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    cmp     dword ptr [ebp+0], 0
    jz      short loc_450D10
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_450CD1
    cmp     al, 2
    jnz     short loc_450D10

    loc_450CD1:                             ; CODE XREF: sub_450A10+2BBj
    mov     ecx, TAdynmemStructPtr
    push    6                               ; idFrom
    mov     eax, [ecx+2A38h]
    push    eax                             ; idTo
    mov     byte ptr [eax], 24h
    mov     edx, [ebp+4]
    mov     [eax+1], edx
    mov     cl, [ebp+13Fh]
    mov     [eax+5], cl
    mov     edx, [ebp+4]
    push    edx                             ; PlayerID
    call    sub_451DF0
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_450D10
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_450D10:                             ; CODE XREF: sub_450A10+26Aj
                                            ; sub_450A10+279j ...
    add     ebx, 14Bh
    cmp     ebx, 0CEEh
    jl      loc_450C65
    call    sub_450530
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_450D33:                             ; CODE XREF: sub_450A10+24Dj
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_450D5F
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+TAdynmemStruct.LOS_Radar], 1
    jbe     short loc_450D5F
    push    2
    call    RIWrapper_Report

    loc_450D5F:                             ; CODE XREF: sub_450A10+133j
                                            ; sub_450A10+168j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 4C4h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_450D71:                             ; CODE XREF: sub_450A10+59j
    mov     al, dl
    jmp     loc_450A7C
    sub_450A10 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    add     eax, 14h
    push    eax
    call    sub_4C9C20
    mov     ecx, TAdynmemStructPtr
    push    64h
    push    2
    mov     dword ptr [ecx+4F1h], 0Ah
    call    sub_461020
    test    eax, eax
    jz      short locret_450DC0
    mov     eax, TAdynmemStructPtr
    lea     edx, [eax+39211h]
    add     eax, 14h
    push    edx
    push    eax
    call    sub_4CA590

    locret_450DC0:                          ; CODE XREF: .text:00450DA9j
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    loc_450DD0:                             ; CODE XREF: sub_491B60+F4j
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 1
    jz      short locret_450E19
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_450DF3
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_450DF3:                             ; CODE XREF: .text:00450DE5j
    call    IsReporterDLLLoaded
    test    al, al
    jnz     short loc_450E0B
    mov     ecx, TAdynmemStructPtr
    add     ecx, 14h
    push    ecx
    call    sub_4C9B70

    loc_450E0B:                             ; CODE XREF: .text:00450DFAj
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+TAdynmemStruct.NetworkLayerEnabled], 0FFFEh

    locret_450E19:                          ; CODE XREF: .text:00450DDCj
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_450E20 proc near                    ; CODE XREF: sub_41EC50+11Fp
                                            ; .text:0044AFCEp
    mov     eax, dword_506DBC
    push    esi
    test    eax, eax
    jz      short loc_450E36
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_450E36:                             ; CODE XREF: sub_450E20+8j
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+2A44h], 1
    jz      short loc_450E8D
    xor     esi, esi

    loc_450E47:                             ; CODE XREF: sub_450E20+60j
    mov     eax, [ecx+esi+1B63h]
    test    eax, eax
    jz      short loc_450E74
    mov     al, [ecx+esi+1BD6h]
    cmp     al, 1
    jz      short loc_450E61
    cmp     al, 2
    jnz     short loc_450E74

    loc_450E61:                             ; CODE XREF: sub_450E20+3Bj
    mov     eax, [ecx+esi+1B67h]
    push    eax
    call    sub_452CC0
    mov     ecx, TAdynmemStructPtr

    loc_450E74:                             ; CODE XREF: sub_450E20+30j
                                            ; sub_450E20+3Fj
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_450E47
    call    UnloadReporter
    mov     ecx, TAdynmemStructPtr

    loc_450E8D:                             ; CODE XREF: sub_450E20+23j
    add     ecx, 14h
    push    ecx
    call    sub_4C9F90
    push    0
    push    0
    call    sub_4B4FD0
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    or      byte ptr [eax+3923Bh], 4
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    mov     dl, [ecx+eax*2+1B85h]
    mov     eax, edx
    test    eax, eax
    jz      loc_450F5C
    add     eax, 0FFFFFFFDh                 ; switch 8 cases
    cmp     eax, 7
    ja      short loc_450F4F                ; default
    jmp     ds:off_450F68[eax*4]            ; switch jump

    loc_450EE7:                             ; DATA XREF: .text:00450F68o
    mov     eax, offset aYouDidNotHaveT     ; case 0x4
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_450EF4:                             ; CODE XREF: sub_450E20+C0j
                                            ; DATA XREF: .text:00450F68o
    mov     eax, offset aTheGameIsClose     ; case 0x3
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_450F01:                             ; CODE XREF: sub_450E20+C0j
                                            ; DATA XREF: .text:00450F68o
    mov     eax, offset aTheGameIsFull      ; case 0x5
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_450F0E:                             ; CODE XREF: sub_450E20+C0j
                                            ; DATA XREF: .text:00450F68o
    mov     eax, offset aYouHaveLostCon     ; case 0x6
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_450F1B:                             ; CODE XREF: sub_450E20+C0j
                                            ; DATA XREF: .text:00450F68o
    mov     eax, offset aYouNeedAUnitYo     ; case 0x7
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_450F28:                             ; CODE XREF: sub_450E20+C0j
                                            ; DATA XREF: .text:00450F68o
    mov     eax, offset aYouNeedANewerV     ; case 0x8
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_450F35:                             ; CODE XREF: sub_450E20+C0j
                                            ; DATA XREF: .text:00450F68o
    mov     eax, offset aNoWatchingIsAl     ; case 0x9
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_450F42:                             ; CODE XREF: sub_450E20+C0j
                                            ; DATA XREF: .text:00450F68o
    mov     eax, offset aTheCreatorHasL     ; case 0xa
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_450F4F:                             ; CODE XREF: sub_450E20+BEj
    mov     eax, offset aYouWereRejecte     ; default
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_450F5C:                             ; CODE XREF: sub_450E20+B2j
    xor     eax, eax
    push    eax                             ; lpText
    call    sub_4B6230
    pop     esi
    retn
    sub_450E20 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_450F68 dd offset loc_450EF4         ; DATA XREF: sub_450E20+C0r
    dd offset loc_450EE7                    ; jump table for switch statement
    dd offset loc_450F01
    dd offset loc_450F0E
    dd offset loc_450F1B
    dd offset loc_450F28
    dd offset loc_450F35
    dd offset loc_450F42
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_450F90 proc near                    ; CODE XREF: TextCommand_ShareMetal+A4p
                                            ; TextCommand_ShareEnergy+A4p ...

    idTo= dword ptr -0BCh
    var_2B= dword ptr -2Bh

    mov     eax, TAdynmemStructPtr
    sub     esp, 0BCh
    test    byte ptr [eax+2A44h], 1
    jz      loc_451081
    push    edi
    push    esi
    push    ebp
    push    ebx
    xor     ebx, ebx

    loc_450FAE:                             ; CODE XREF: sub_450F90+D6j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+ebx+1B63h]
    lea     ebp, [ecx+ebx+1B63h]
    test    eax, eax
    jz      loc_45105A
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_450FD9
    cmp     al, 2
    jnz     loc_45105A

    loc_450FD9:                             ; CODE XREF: sub_450F90+3Fj
    mov     esi, [ebp+27h]
    mov     ecx, 2Eh
    lea     edi, [esp+0CCh+idTo+1]
    lea     eax, [esp+0CCh+idTo]
    rep movsd
    movsb
    mov     edx, [ebp+4]
    mov     byte ptr [esp+0CCh+idTo], 20h
    mov     [esp+0CCh+var_2B], edx
    mov     ecx, [ebp+4]
    push    0BAh                            ; idFrom
    push    eax                             ; idTo
    push    ecx                             ; PlayerID
    call    sub_451DF0
    cmp     dword ptr [ebp+0], 0
    jz      short loc_45105A
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_45101B
    cmp     al, 2
    jnz     short loc_45105A

    loc_45101B:                             ; CODE XREF: sub_450F90+85j
    mov     edx, TAdynmemStructPtr
    push    6                               ; idFrom
    mov     eax, [edx+2A38h]
    push    eax                             ; idTo
    mov     byte ptr [eax], 24h
    mov     ecx, [ebp+4]
    mov     [eax+1], ecx
    mov     dl, [ebp+13Fh]
    mov     [eax+5], dl
    mov     eax, [ebp+4]
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_45105A
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_45105A:                             ; CODE XREF: sub_450F90+34j
                                            ; sub_450F90+43j ...
    add     ebx, 14Bh
    cmp     ebx, 0CEEh
    jl      loc_450FAE
    call    sub_450530
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_451081:                             ; CODE XREF: sub_450F90+12j
    add     esp, 0BCh
    retn
    sub_450F90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_451090 proc near                    ; CODE XREF: sub_451180+1Dp
                                            ; .text:00451584p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    esi
    mov     esi, edx
    mov     cl, [edx+2A42h]
    push    edi
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    mov     cl, [edx+1]
    push    10h                             ; size_t
    lea     eax, [eax+eax*4]
    mov     eax, [esi+eax*2+1B8Ah]
    mov     esi, [esp+0Ch+arg_0]
    mov     edi, esi
    mov     [eax+0A7h], cl
    mov     edx, TAdynmemStructPtr
    add     eax, 99h
    mov     cl, [edx+2]
    mov     [eax+0Fh], cl
    mov     edx, TAdynmemStructPtr
    mov     cx, [eax+2]
    add     eax, 4
    mov     dl, [edx+2A3Ch]
    add     eax, 4
    xor     dl, cl
    and     edx, 0Fh
    xor     edx, ecx
    mov     [eax-6], dx
    mov     edx, [esp+0Ch+arg_4]
    mov     ecx, [eax-8]
    mov     [edx], ecx
    mov     edx, [esp+0Ch+arg_8]
    mov     ecx, [eax-4]
    mov     [edx], ecx
    mov     edx, [esp+0Ch+arg_C]
    mov     ecx, [eax]
    mov     [edx], ecx
    mov     ecx, [esp+0Ch+arg_10]
    mov     eax, [eax+4]
    mov     [ecx], eax
    mov     ecx, 8
    mov     eax, 20202020h
    rep stosd
    mov     byte ptr [esi+1Fh], 0
    mov     edx, TAdynmemStructPtr
    add     edx, 2BC1h
    push    edx                             ; char *
    push    esi                             ; char *
    call    _strncpy
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     ecx, [eax+391E9h]
    call    sub_435C30
    push    0Fh                             ; size_t
    lea     ecx, [esi+10h]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     eax, esi
    mov     ecx, 20h

    loc_451167:                             ; CODE XREF: sub_451090+E1j
    cmp     byte ptr [eax], 0
    jnz     short loc_45116F
    mov     byte ptr [eax], 20h

    loc_45116F:                             ; CODE XREF: sub_451090+DAj
    inc     eax
    dec     ecx
    jnz     short loc_451167
    mov     byte ptr [esi+1Fh], 0
    pop     edi
    pop     esi
    retn    14h
    sub_451090 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_451180 proc near                    ; CODE XREF: sub_444CB0+198p
                                            ; sub_445C70+D6p ...

    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h

    sub     esp, 30h
    lea     eax, [esp+30h+var_30]
    lea     ecx, [esp+30h+var_2C]
    lea     edx, [esp+30h+var_28]
    push    esi
    push    eax
    push    ecx
    lea     eax, [esp+3Ch+var_24]
    push    edx
    lea     ecx, [esp+40h+var_20]
    push    eax
    push    ecx
    call    sub_451090
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B8Ah]
    mov     al, [ecx+9Bh]
    shr     al, 4
    test    al, 1
    jz      short loc_4511E6
    mov     eax, [edx+475h]
    or      al, 20h
    mov     [edx+475h], eax
    mov     edx, TAdynmemStructPtr

    loc_4511E6:                             ; CODE XREF: sub_451180+50j
    mov     ecx, [esp+34h+var_30]
    mov     eax, [esp+34h+var_2C]
    push    ecx
    mov     ecx, [esp+38h+var_28]
    push    eax
    mov     eax, [esp+3Ch+var_24]
    push    ecx
    push    eax
    lea     ecx, [esp+44h+var_20]
    push    offset Data
    add     edx, 14h
    push    ecx
    push    edx
    call    sub_4C9890
    pop     esi
    add     esp, 30h
    retn
    sub_451180 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_451220 proc near                    ; CODE XREF: sub_447B10+280p
                                            ; sub_4517B0+280p

    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= dword ptr -100h
    var_F0= byte ptr -0F0h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 108h
    mov     eax, [esp+108h+arg_0]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    push    ebx
    mov     ecx, eax
    push    ebp
    shl     ecx, 5
    add     ecx, eax
    push    esi
    push    edi
    mov     edi, [esp+118h+arg_4]
    lea     ecx, [ecx+ecx*4]
    push    edi
    lea     eax, [eax+ecx*2]
    mov     [esp+11Ch+var_104], eax
    lea     ebp, [edx+eax+1B63h]
    mov     ecx, ebp
    call    sub_463C60
    mov     edx, TAdynmemStructPtr
    xor     bl, bl
    mov     byte ptr [esp+118h+var_108], bl

    loc_45126F:                             ; CODE XREF: sub_451220+90j
    mov     eax, [esp+118h+var_108]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4512A7
    mov     eax, [eax+1B8Ah]
    test    byte ptr [eax+97h], 1
    jnz     loc_451539

    loc_4512A7:                             ; CODE XREF: sub_451220+72j
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+118h+var_108], bl
    jb      short loc_45126F
    mov     al, 0Ah

    loc_4512B4:                             ; CODE XREF: sub_451220+31Bj
    mov     cl, byte ptr [esp+118h+arg_0]
    xor     ebx, ebx
    cmp     cl, al
    setz    bl
    cmp     edi, 1
    jnz     short loc_4512F0
    lea     edi, [edx+2BD2h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+118h+var_100]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_451323
    ; ---------------------------------------------------------------------------

    loc_4512F0:                             ; CODE XREF: sub_451220+A5j
    xor     ecx, ecx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [edx+eax*2+1B8Eh]
    lea     edx, [esp+118h+var_100]
    push    ecx
    push    offset aAiS                     ; "AI:%s"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    mov     [esp+118h+var_F0], 0

    loc_451323:                             ; CODE XREF: sub_451220+CEj
    mov     eax, [ebp+27h]
    mov     cx, [eax+97h]
    xor     bl, cl
    and     ebx, 1
    xor     ebx, ecx
    mov     [eax+97h], bx
    mov     eax, [ebp+27h]
    mov     byte ptr [eax+96h], 0FFh
    mov     bl, [ebp+21h]
    and     bl, 0FDh
    mov     [ebp+21h], bl
    call    sub_4B6340
    mov     edx, [ebp+27h]
    mov     [ebp+8], eax
    mov     ecx, TAdynmemStructPtr
    push    50h
    mov     ax, [edx+9Bh]
    mov     bx, [edx+9Dh]
    mov     cl, [ecx+2A3Ch]
    push    0
    xor     cl, al
    and     ecx, 0Fh
    xor     ecx, eax
    and     ecx, 7FFFh
    mov     [edx+9Bh], cx
    mov     eax, TAdynmemStructPtr
    or      ecx, 0FFFFFFFFh
    lea     edi, [eax+2BE3h]
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     word ptr [edx+0A5h], 64h
    neg     ecx
    sbb     ecx, ecx
    add     ebp, 4
    neg     ecx
    xor     cl, bl
    and     ecx, 1
    xor     ecx, ebx
    mov     [edx+9Dh], cx
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F1Bh]
    mov     [edx+8Bh], ax
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F1Fh]
    mov     [edx+8Dh], ax
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+1]
    mov     [edx+0A7h], al
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+2]
    mov     [edx+0A8h], al
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+120h+var_100]
    lea     ecx, [eax+2BE3h]
    add     eax, 14h
    push    ecx
    lea     ecx, [esp+124h+var_100]
    push    edx
    push    ecx
    push    ebp
    push    eax
    call    sub_4CA6A0
    mov     edi, eax
    test    edi, edi
    jnz     loc_45152A
    mov     edx, TAdynmemStructPtr
    push    eax
    mov     eax, [esp+11Ch+var_104]
    lea     ecx, [edx+eax+1B63h]
    call    sub_463C60
    mov     edx, TAdynmemStructPtr
    xor     bl, bl
    mov     byte ptr [esp+118h+var_108], bl

    loc_451453:                             ; CODE XREF: sub_451220+270j
    mov     eax, [esp+118h+var_108]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_451487
    mov     eax, [eax+1B8Ah]
    test    byte ptr [eax+97h], 1
    jnz     short loc_451494

    loc_451487:                             ; CODE XREF: sub_451220+256j
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+118h+var_108], bl
    jb      short loc_451453
    jmp     short loc_45149A
    ; ---------------------------------------------------------------------------

    loc_451494:                             ; CODE XREF: sub_451220+265j
    mov     byte ptr [esp+118h+var_108], bl
    jmp     short loc_45149F
    ; ---------------------------------------------------------------------------

    loc_45149A:                             ; CODE XREF: sub_451220+272j
    mov     byte ptr [esp+118h+var_108], 0Ah

    loc_45149F:                             ; CODE XREF: sub_451220+278j
    mov     eax, [esp+118h+var_108]
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+1B63h]
    mov     ecx, [edx+ecx*2+1B63h]
    test    ecx, ecx
    jz      short loc_451506
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_4514D1
    cmp     al, 2
    jnz     short loc_451506

    loc_4514D1:                             ; CODE XREF: sub_451220+2ABj
    push    1
    push    1
    push    1F4h
    push    offset aDirectPlayFail          ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_451506:                             ; CODE XREF: sub_451220+2A4j
                                            ; sub_451220+2AFj
    push    1
    push    1
    push    1F4h
    push    offset aDirectPlayFa_0          ; int
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90

    loc_45152A:                             ; CODE XREF: sub_451220+20Aj
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 108h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_451539:                             ; CODE XREF: sub_451220+81j
    mov     al, bl
    jmp     loc_4512B4
    sub_451220 endp

    ; ---------------------------------------------------------------------------
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    sub     esp, 30h
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     edx, [esp+4]
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    lea     eax, [esp+8]
    or      byte ptr [ecx+97h], 1
    lea     ecx, [esp+0]
    push    ecx
    push    edx
    lea     ecx, [esp+14h]
    push    eax
    lea     edx, [esp+1Ch]
    push    ecx
    push    edx
    call    sub_451090
    mov     eax, TAdynmemStructPtr
    mov     word ptr [eax+2A3Ch], 0
    mov     ecx, [esp+0]
    mov     edx, [esp+4]
    mov     eax, [esp+8]
    push    ecx
    mov     ecx, [esp+10h]
    push    edx
    push    eax
    mov     eax, TAdynmemStructPtr
    push    ecx
    lea     edx, [esp+20h]
    push    offset Data
    add     eax, 14h
    push    edx
    push    eax
    call    sub_4C9920
    add     esp, 30h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4515D0 proc near                    ; DATA XREF: sub_4517B0+28Eo

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    cmp     esi, 0FFFFFFFFh
    jz      short loc_45162C
    mov     edx, TAdynmemStructPtr
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+4+arg_0], bl
    jz      short loc_45161A

    loc_4515ED:                             ; CODE XREF: sub_4515D0+5Aj
    mov     eax, [esp+4+arg_0]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_45161A
    mov     eax, [eax+1B67h]
    jmp     short loc_45161D
    ; ---------------------------------------------------------------------------

    loc_45161A:                             ; CODE XREF: sub_4515D0+1Bj
                                            ; sub_4515D0+40j
    or      eax, 0FFFFFFFFh

    loc_45161D:                             ; CODE XREF: sub_4515D0+48j
    cmp     eax, esi
    jz      short loc_45162C
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+4+arg_0], bl
    jb      short loc_4515ED

    loc_45162C:                             ; CODE XREF: sub_4515D0+Aj
                                            ; sub_4515D0+4Fj
    push    esi
    call    sub_450A10
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_4515D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_451640 proc near                    ; CODE XREF: sub_4517B0+1FFp

    var_18= dword ptr -18h
    var_4= dword ptr -4
    ThreadId= dword ptr  4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    add     eax, 14h
    push    edi
    xor     ebp, ebp
    push    eax
    mov     [esp+18h+var_4], ebp
    call    sub_4CA450
    test    eax, eax
    jz      short loc_45166D
    mov     ecx, [esp+14h+ThreadId]
    mov     eax, [ecx+27h]
    add     eax, 80h
    mov     [esp+14h+var_4], eax

    loc_45166D:                             ; CODE XREF: sub_451640+1Bj
    mov     ebx, 0Ah
    call    sub_45B660
    test    eax, eax
    jz      short loc_45169C
    mov     eax, dword_512C8C
    cmp     eax, 1
    jle     short loc_45169C
    cmp     eax, ebx
    mov     ebx, eax
    jb      short loc_451690
    mov     ebx, 0Ah

    loc_451690:                             ; CODE XREF: sub_451640+49j
    mov     edx, TAdynmemStructPtr
    mov     [edx+4F1h], ebx

    loc_45169C:                             ; CODE XREF: sub_451640+39j
                                            ; sub_451640+43j
    push    1Ch
    push    offset aLobbyJoinInfo           ; "LOBBY JOIN INFO"
    call    sub_4D83B0
    mov     esi, eax
    add     esp, 8
    cmp     esi, ebp
    jz      loc_451762
    mov     ecx, 7
    xor     eax, eax
    mov     edi, esi
    push    14h
    rep stosd
    mov     eax, [esp+18h+var_4]
    mov     [esi+4], ebx
    mov     [esi], eax
    mov     [esi+8], ebp
    mov     [esi+0Ch], ebp
    mov     [esi+10h], ebp
    mov     [esi+14h], ebp
    mov     [esi+18h], ebp
    mov     [esp+18h+ThreadId], ebp
    call    sub_491C80
    lea     ecx, [esp+14h+ThreadId]
    push    ecx                             ; lpThreadId
    push    ebp                             ; dwCreationFlags
    push    esi                             ; lpParameter
    push    offset loc_451770               ; int
    push    8000h                           ; dwStackSize
    push    ebp                             ; lpThreadAttributes
    call    __beginthreadex
    add     esp, 18h
    cmp     eax, ebp
    jz      short loc_451752
    push    9C40h                           ; dwMilliseconds
    push    eax                             ; hHandle
    call    ds:WaitForSingleObject
    cmp     eax, 102h
    jnz     short loc_45174F
    push    13h
    call    sub_491C80
    call    sub_4B6220
    mov     dl, [eax+0F0h]
    shr     dl, 1
    test    dl, 1
    jz      short loc_45173D
    call    sub_4B5910
    push    1F4h                            ; dwMilliseconds
    call    ds:Sleep

    loc_45173D:                             ; CODE XREF: sub_451640+EBj
    push    offset aTimedOutWhileC          ; int
    call    sub_4C5740
    push    eax                             ; lpText
    call    sub_4B6290
    jmp     short loc_451752
    ; ---------------------------------------------------------------------------

    loc_45174F:                             ; CODE XREF: sub_451640+D2j
    mov     ebp, [esi+18h]

    loc_451752:                             ; CODE XREF: sub_451640+BFj
                                            ; sub_451640+10Dj
    push    13h
    call    sub_491C80
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_451762:                             ; CODE XREF: sub_451640+6Fj
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    loc_451770:                             ; DATA XREF: sub_451640+AAo
    push    esi
    mov     esi, [esp+20h+var_18]
    mov     eax, [esi+14h]
    mov     ecx, [esi+10h]
    mov     edx, [esi+0Ch]
    push    eax
    mov     eax, [esi+8]
    push    ecx
    mov     ecx, [esi+4]
    push    edx
    mov     edx, [esi]
    push    eax
    mov     eax, TAdynmemStructPtr
    push    ecx
    add     eax, 14h
    push    edx
    push    eax
    call    sub_4C9A70
    mov     [esi+18h], eax
    pop     esi
    retn    4
    sub_451640 endp ; sp = -1Ch

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4517B0 proc near

    var_1C4= dword ptr -1C4h
    nSize= dword ptr -1C0h
    idTo= dword ptr -1BCh
    var_12B= dword ptr -12Bh
    Buffer= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     edx, TAdynmemStructPtr
    sub     esp, 1C4h
    xor     eax, eax
    mov     al, [edx+TAdynmemStruct.SharedBits]
    push    ebx
    mov     ebx, [esp+1C8h+arg_10]
    push    ebp
    push    esi
    cmp     ebx, eax
    push    edi
    jnz     loc_451B4A
    mov     eax, ebx
    mov     esi, [edx+4E5h]
    shl     eax, 5
    add     eax, ebx
    lea     ecx, [eax+eax*4]
    mov     eax, edx
    add     eax, ebx
    test    esi, esi
    lea     ebp, [eax+ecx*2+1B63h]
    jz      loc_4518B7
    call    sub_45B660
    mov     edi, eax
    mov     ecx, offset byte_512D48
    test    edi, edi
    jnz     short loc_45180F
    mov     ecx, offset Data

    loc_45180F:                             ; CODE XREF: sub_4517B0+58j
    mov     esi, [esi+0Ch]
    test    esi, esi
    jz      short loc_451834
    mov     eax, [esi+8]
    test    eax, eax
    jz      short loc_451826
    cmp     byte ptr [eax], 0
    jz      short loc_451826
    mov     ecx, eax
    jmp     short loc_451834
    ; ---------------------------------------------------------------------------

    loc_451826:                             ; CODE XREF: sub_4517B0+6Bj
                                            ; sub_4517B0+70j
    mov     esi, [esi+0Ch]
    test    esi, esi
    jz      short loc_451834
    cmp     byte ptr [esi], 0
    jz      short loc_451834
    mov     ecx, esi

    loc_451834:                             ; CODE XREF: sub_4517B0+64j
                                            ; sub_4517B0+74j ...
    cmp     byte ptr [ecx], 0
    jz      short loc_45185C
    mov     edx, TAdynmemStructPtr
    push    10h                             ; size_t
    push    ecx                             ; char *
    mov     byte ptr [edx+2BD2h], 0
    mov     eax, TAdynmemStructPtr
    add     eax, 2BD2h
    push    eax                             ; char *
    call    _strncat
    add     esp, 0Ch

    loc_45185C:                             ; CODE XREF: sub_4517B0+87j
    test    edi, edi
    jz      short loc_4518AC
    mov     al, String2
    test    al, al
    jz      short loc_4518AC
    mov     ecx, [ebp+27h]
    mov     esi, ds:lstrcpynA
    push    0Bh                             ; iMaxLength
    add     ecx, 80h
    push    offset String2                  ; lpString2
    push    ecx                             ; lpString1
    call    esi ; lstrcpynA
    mov     eax, [ebp+27h]
    or      byte ptr [eax+9Dh], 1
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+4E5h]
    test    byte ptr [edx+4], 2
    jz      short loc_4518AC
    push    0Bh                             ; iMaxLength
    add     eax, 2BE3h
    push    offset String2                  ; lpString2
    push    eax                             ; lpString1
    call    esi ; lstrcpynA

    loc_4518AC:                             ; CODE XREF: sub_4517B0+AEj
                                            ; sub_4517B0+B7j ...
    call    sub_4644D0
    mov     edx, TAdynmemStructPtr

    loc_4518B7:                             ; CODE XREF: sub_4517B0+44j
    lea     esi, [edx+2BD2h]
    or      ecx, 0FFFFFFFFh
    mov     edi, esi
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_4518EE
    lea     eax, [esp+1D4h+nSize]
    lea     ecx, [esp+1D4h+Buffer]
    push    eax                             ; nSize
    push    ecx                             ; lpBuffer
    mov     [esp+1DCh+nSize], 100h
    call    ds:GetUserNameA
    mov     edx, TAdynmemStructPtr
    jmp     short loc_45191A
    ; ---------------------------------------------------------------------------

    loc_4518EE:                             ; CODE XREF: sub_4517B0+119j
    lea     eax, [esp+1D4h+Buffer]
    mov     edi, esi
    mov     [esp+1D4h+var_1C4], eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+1D4h+var_1C4]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_45191A:                             ; CODE XREF: sub_4517B0+13Cj
    mov     esi, [edx+4E5h]
    mov     eax, [ebp+27h]
    test    esi, esi
    jz      short loc_451943
    mov     edx, [esi+4]
    mov     cx, [eax+97h]
    shr     edx, 1
    xor     dl, cl
    and     edx, 1
    xor     edx, ecx
    mov     [eax+97h], dx
    jmp     short loc_45194C
    ; ---------------------------------------------------------------------------

    loc_451943:                             ; CODE XREF: sub_4517B0+175j
    and     word ptr [eax+97h], 0FFFEh

    loc_45194C:                             ; CODE XREF: sub_4517B0+191j
    mov     eax, [ebp+27h]
    mov     byte ptr [eax+96h], 0FFh
    mov     eax, [ebp+27h]
    and     word ptr [eax+9Bh], 0FFDFh
    mov     edx, TAdynmemStructPtr
    mov     ecx, [ebp+27h]
    mov     ax, [edx+37F1Bh]
    mov     [ecx+8Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [ebp+27h]
    mov     ax, [edx+37F1Fh]
    mov     [ecx+8Dh], ax
    mov     ecx, TAdynmemStructPtr
    mov     word ptr [ecx+2A3Ch], 0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+4E5h]
    test    ecx, ecx
    jz      short loc_4519EE
    push    ebp
    call    sub_451640
    mov     esi, eax
    test    esi, esi
    jnz     short loc_451A2D
    call    sub_4B6220
    mov     dl, [eax+0F0h]
    shr     dl, 1
    test    dl, 1
    jz      short loc_4519DC
    call    sub_4B5910
    push    1F4h                            ; dwMilliseconds
    call    ds:Sleep

    loc_4519DC:                             ; CODE XREF: sub_4517B0+21Aj
    push    offset aUnableToConnec          ; int
    call    sub_4C5740
    push    eax                             ; lpText
    call    sub_4B6290
    jmp     short loc_451A25
    ; ---------------------------------------------------------------------------

    loc_4519EE:                             ; CODE XREF: sub_4517B0+1FCj
    mov     edx, [esp+1D4h+arg_0]
    sub     esp, 10h
    mov     ecx, esp
    add     eax, 14h
    push    eax
    mov     [ecx], edx
    mov     edx, [esp+1E8h+arg_4]
    mov     [ecx+4], edx
    mov     edx, [esp+1E8h+arg_8]
    mov     [ecx+8], edx
    mov     edx, [esp+1E8h+arg_C]
    mov     [ecx+0Ch], edx
    call    sub_4C9FD0
    mov     esi, eax

    loc_451A25:                             ; CODE XREF: sub_4517B0+23Cj
    test    esi, esi
    jz      loc_451B4A

    loc_451A2D:                             ; CODE XREF: sub_4517B0+208j
    push    1
    push    ebx
    call    sub_451220
    mov     eax, TAdynmemStructPtr
    push    0
    push    0
    push    offset sub_4515D0
    add     eax, 14h
    push    0
    push    eax
    call    sub_4CA840
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+2A44h], 1
    jz      loc_451B31
    xor     ebx, ebx

    loc_451A63:                             ; CODE XREF: sub_4517B0+36Aj
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+ebx+1B63h]
    lea     ebp, [edx+ebx+1B63h]
    test    eax, eax
    jz      loc_451B0E
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_451A8E
    cmp     al, 2
    jnz     loc_451B0E

    loc_451A8E:                             ; CODE XREF: sub_4517B0+2D4j
    mov     esi, [ebp+27h]
    mov     ecx, 2Eh
    lea     edi, [esp+1D4h+idTo+1]
    push    0BAh                            ; idFrom
    rep movsd
    movsb
    mov     eax, [ebp+4]
    mov     byte ptr [esp+1D8h+idTo], 20h
    mov     [esp+1D8h+var_12B], eax
    mov     edx, [ebp+4]
    lea     ecx, [esp+1D8h+idTo]
    push    ecx                             ; idTo
    push    edx                             ; PlayerID
    call    sub_451DF0
    cmp     dword ptr [ebp+0], 0
    jz      short loc_451B0E
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_451AD0
    cmp     al, 2
    jnz     short loc_451B0E

    loc_451AD0:                             ; CODE XREF: sub_4517B0+31Aj
    mov     eax, TAdynmemStructPtr
    push    6                               ; idFrom
    mov     eax, [eax+2A38h]
    push    eax                             ; idTo
    mov     byte ptr [eax], 24h
    mov     ecx, [ebp+4]
    mov     [eax+1], ecx
    mov     dl, [ebp+13Fh]
    mov     [eax+5], dl
    mov     eax, [ebp+4]
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_451B0E
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_451B0E:                             ; CODE XREF: sub_4517B0+2C9j
                                            ; sub_4517B0+2D8j ...
    add     ebx, 14Bh
    cmp     ebx, 0CEEh
    jl      loc_451A63
    call    sub_450530
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_451B31:                             ; CODE XREF: sub_4517B0+2ABj
    push    0
    call    sub_4526C0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1C4h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_451B4A:                             ; CODE XREF: sub_4517B0+21j
                                            ; sub_4517B0+277j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 1C4h
    retn    14h
    sub_4517B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_451B60 proc near                    ; CODE XREF: sub_491C60+5p
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+2A44h], 1
    jz      short locret_451BB3
    push    esi
    xor     esi, esi

    loc_451B72:                             ; CODE XREF: sub_451B60+4Bj
    mov     eax, [ecx+esi+1B63h]
    test    eax, eax
    jz      short loc_451B9F
    mov     al, [ecx+esi+1BD6h]
    cmp     al, 1
    jz      short loc_451B8C
    cmp     al, 2
    jnz     short loc_451B9F

    loc_451B8C:                             ; CODE XREF: sub_451B60+26j
    mov     eax, [ecx+esi+1B67h]
    push    eax
    call    sub_452CC0
    mov     ecx, TAdynmemStructPtr

    loc_451B9F:                             ; CODE XREF: sub_451B60+1Bj
                                            ; sub_451B60+2Aj
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_451B72
    call    UnloadReporter
    pop     esi

    locret_451BB3:                          ; CODE XREF: sub_451B60+Dj
    retn
    sub_451B60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall Network_BroadcastMessage(int dwDataSize,int PlayersToSendTo,int idTo,int idFrom)
    Network_BroadcastMessage proc near      ; CODE XREF: sub_4244B0+C5p
                                            ; sub_450530+378p ...

    var_1= dword ptr -1
    dwDataSize= dword ptr  7
    PlayersToSendTo= dword ptr  0Bh
    idTo= dword ptr  0Fh
    idFrom= dword ptr  13h

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+11h+dwDataSize]
    cmp     edi, 0FFFFFFFFh
    jz      short loc_451BED
    xor     bl, bl
    mov     byte ptr [esp+11h+var_1], bl

    loc_451BD4:                             ; CODE XREF: Network_BroadcastMessage+2Bj
    mov     eax, [esp+11h+var_1]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, edi
    jz      short loc_451BEF
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+11h+var_1], bl
    jb      short loc_451BD4

    loc_451BED:                             ; CODE XREF: Network_BroadcastMessage+Cj
    mov     bl, 0Ah

    loc_451BEF:                             ; CODE XREF: Network_BroadcastMessage+20j
    cmp     bl, 0Ah
    jnz     short loc_451BFE
    mov     edx, TAdynmemStructPtr
    xor     esi, esi
    jmp     short loc_451C24
    ; ---------------------------------------------------------------------------

    loc_451BFE:                             ; CODE XREF: Network_BroadcastMessage+32j
    push    edi                             ; int
    call    sub_44FE40
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    lea     eax, [eax+eax*4]
    lea     esi, [esi+eax*2+TAdynmemStruct.Players]

    loc_451C24:                             ; CODE XREF: Network_BroadcastMessage+3Cj
    mov     ebp, [esp+11h+PlayersToSendTo]
    cmp     ebp, 0FFFFFFFFh
    jnz     short loc_451C31
    mov     bl, 0Ah
    jmp     short loc_451C58
    ; ---------------------------------------------------------------------------

    loc_451C31:                             ; CODE XREF: Network_BroadcastMessage+6Bj
    xor     bl, bl
    mov     byte ptr [esp+11h+PlayersToSendTo], bl

    loc_451C37:                             ; CODE XREF: Network_BroadcastMessage+8Ej
    mov     ecx, [esp+11h+PlayersToSendTo]
    push    ecx                             ; int
    call    PlayerNumberToID
    cmp     eax, ebp
    jz      short loc_451C52
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+11h+PlayersToSendTo], bl
    jb      short loc_451C37
    mov     bl, 0Ah

    loc_451C52:                             ; CODE XREF: Network_BroadcastMessage+83j
    mov     edx, TAdynmemStructPtr

    loc_451C58:                             ; CODE XREF: Network_BroadcastMessage+6Fj
    cmp     bl, 0Ah
    jnz     short loc_451C61
    xor     ecx, ecx
    jmp     short loc_451C87
    ; ---------------------------------------------------------------------------

    loc_451C61:                             ; CODE XREF: Network_BroadcastMessage+9Bj
    push    ebp                             ; int
    call    sub_44FE40
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    mov     ebx, edx
    shl     eax, 5
    add     eax, ecx
    add     ebx, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ebx+eax*2+TAdynmemStruct.Players]

    loc_451C87:                             ; CODE XREF: Network_BroadcastMessage+9Fj
    test    [edx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_451DD7
    test    esi, esi
    jz      loc_451DD7
    cmp     [esi+PlayerStruct.PlayerActive], 0
    jz      loc_451DD7
    mov     al, [esi+PlayerStruct.PlayerType]
    cmp     al, Player_LocalHuman
    jz      short loc_451CB4
    cmp     al, Player_AI
    jnz     loc_451DD7

    loc_451CB4:                             ; CODE XREF: Network_BroadcastMessage+EAj
    mov     al, [esi+PlayerStruct.field_22]
    test    al, al
    jnz     loc_451DD7
    test    ecx, ecx
    jz      loc_451DD7
    cmp     [ecx+PlayerStruct.PlayerActive], 0
    jz      loc_451DD7
    cmp     [ecx+PlayerStruct.PlayerType], 3
    jnz     loc_451DD7
    mov     al, [ecx+PlayerStruct.field_22]
    test    al, al
    jnz     loc_451DD7
    cmp     ebp, 0FFFFFFFFh
    jz      short loc_451D38
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+11h+PlayersToSendTo], bl
    jz      short loc_451D22

    loc_451CF5:                             ; CODE XREF: Network_BroadcastMessage+176j
    mov     eax, [esp+11h+PlayersToSendTo]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+TAdynmemStruct.Players.PlayerType]
    test    cl, cl
    jz      short loc_451D22
    mov     eax, [eax+TAdynmemStruct.Players.field_4]
    jmp     short loc_451D25
    ; ---------------------------------------------------------------------------

    loc_451D22:                             ; CODE XREF: Network_BroadcastMessage+133j
                                            ; Network_BroadcastMessage+158j
    or      eax, 0FFFFFFFFh

    loc_451D25:                             ; CODE XREF: Network_BroadcastMessage+160j
    cmp     eax, ebp
    jz      loc_451DE1
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+11h+PlayersToSendTo], bl
    jb      short loc_451CF5

    loc_451D38:                             ; CODE XREF: Network_BroadcastMessage+128j
    mov     byte ptr [esp+11h+PlayersToSendTo], 0Ah

    loc_451D3D:                             ; CODE XREF: Network_BroadcastMessage+225j
    mov     eax, [esp+11h+PlayersToSendTo]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2+TAdynmemStruct.Players]
    mov     ecx, [esi+ecx*2+TAdynmemStruct.Players.PlayerActive]
    test    ecx, ecx
    jz      short loc_451D71
    mov     al, [eax+PlayerStruct.PlayerType]
    cmp     al, Player_LocalHuman
    jz      short loc_451DCA
    cmp     al, Player_AI
    jz      short loc_451DCA

    loc_451D71:                             ; CODE XREF: Network_BroadcastMessage+1A4j
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_451D98
    mov     edx, [esp+11h+idFrom]
    mov     eax, [esp+11h+idTo]
    push    edx                             ; int
    push    eax                             ; int
    push    ebp                             ; int
    push    edi                             ; int
    mov     ecx, offset dword_513000
    call    sub_4619B0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_451D98:                             ; CODE XREF: Network_BroadcastMessage+1B8j
    mov     esi, [esp+11h+idFrom]
    mov     edi, [esp+11h+idTo]
    mov     ecx, [esp+11h+dwDataSize]
    push    esi                             ; idFrom
    push    edi                             ; idTo
    push    ebp                             ; lpData
    add     edx, 14h
    push    ecx                             ; dwDataSize
    push    edx                             ; HAPINET_this
    call    HAPINET_SendPacket
    test    eax, eax
    jnz     short loc_451DD7
    mov     dl, [edi]
    push    1
    push    esi
    push    edx
    call    sub_415EF0
    push    1                               ; arg8
    push    0                               ; arg4
    push    esi                             ; DataSize
    call    HAPINET_PacketStatistics

    loc_451DCA:                             ; CODE XREF: Network_BroadcastMessage+1ABj
                                            ; Network_BroadcastMessage+1AFj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_451DD7:                             ; CODE XREF: Network_BroadcastMessage+CEj
                                            ; Network_BroadcastMessage+D6j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_451DE1:                             ; CODE XREF: Network_BroadcastMessage+167j
    mov     byte ptr [esp+11h+PlayersToSendTo], bl
    jmp     loc_451D3D
    Network_BroadcastMessage endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_451DF0(char PlayerID,int idTo,int idFrom)
    sub_451DF0 proc near                    ; CODE XREF: .text:00405210p
                                            ; sub_4233A0+197p ...

    PlayerID= dword ptr  0Ch
    idTo= dword ptr  10h
    idFrom= dword ptr  14h

    push    ebx
    push    ebp
    mov     ebp, [esp+PlayerID]
    push    esi
    cmp     ebp, 0FFFFFFFFh
    push    edi
    jz      short loc_451E1C
    xor     bl, bl
    mov     byte ptr [esp+8+PlayerID], bl

    loc_451E03:                             ; CODE XREF: sub_451DF0+2Aj
    mov     eax, [esp+8+PlayerID]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, ebp
    jz      short loc_451E1E
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+8+PlayerID], bl
    jb      short loc_451E03

    loc_451E1C:                             ; CODE XREF: sub_451DF0+Bj
    mov     bl, 0Ah

    loc_451E1E:                             ; CODE XREF: sub_451DF0+1Fj
    cmp     bl, 0Ah
    jnz     short loc_451E2D
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    jmp     short loc_451E7E
    ; ---------------------------------------------------------------------------

    loc_451E2D:                             ; CODE XREF: sub_451DF0+31j
    cmp     ebp, 0FFFFFFFFh
    jz      short loc_451E55
    xor     bl, bl
    mov     byte ptr [esp+8+PlayerID], bl

    loc_451E38:                             ; CODE XREF: sub_451DF0+63j
    mov     ecx, [esp+8+PlayerID]
    push    ecx                             ; int
    call    PlayerNumberToID
    cmp     eax, ebp
    jz      loc_451FBE
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+8+PlayerID], bl
    jb      short loc_451E38

    loc_451E55:                             ; CODE XREF: sub_451DF0+40j
    mov     byte ptr [esp+8+PlayerID], 0Ah

    loc_451E5A:                             ; CODE XREF: sub_451DF0+1D2j
    mov     eax, [esp+8+PlayerID]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     esi, edx
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     esi, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2+TAdynmemStruct.Players]

    loc_451E7E:                             ; CODE XREF: sub_451DF0+3Bj
    test    eax, eax
    jz      loc_451FB5
    cmp     [eax+PlayerStruct.PlayerActive], 0
    jz      loc_451FB5
    mov     cl, [eax+PlayerStruct.PlayerType]
    cmp     cl, Player_LocalHuman
    jz      short loc_451EA0
    cmp     cl, Player_AI
    jnz     loc_451FB5

    loc_451EA0:                             ; CODE XREF: sub_451DF0+A5j
    mov     cl, [eax+PlayerStruct.field_22]
    test    cl, cl
    jnz     loc_451FB5
    test    [edx+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_451FA9
    mov     eax, [edx+TAdynmemStruct.field_299C]
    test    eax, eax
    jnz     short loc_451F2B
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_451EEC
    mov     edx, [esp+8+idFrom]
    mov     eax, [esp+8+idTo]
    push    edx
    push    eax
    push    offset dword_513008
    push    ebp
    mov     ecx, offset dword_513000
    call    sub_461990
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_451EEC:                             ; CODE XREF: sub_451DF0+D9j
    mov     esi, [esp+8+idFrom]
    mov     edi, [esp+8+idTo]
    push    esi                             ; idFrom
    push    edi                             ; idTo
    push    0                               ; lpData
    add     edx, 14h
    push    ebp                             ; dwDataSize
    push    edx                             ; HAPINET_this
    call    HAPINET_SendPacket
    test    eax, eax
    jnz     loc_451FB5
    mov     cl, [edi]
    push    1
    push    esi
    push    ecx
    call    sub_415EF0
    push    1                               ; arg8
    push    0                               ; arg4
    push    esi                             ; DataSize
    call    HAPINET_PacketStatistics
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_451F2B:                             ; CODE XREF: sub_451DF0+D0j
    mov     ebx, [esp+8+idTo]
    mov     ecx, 0Bh
    xor     eax, eax
    mov     edi, offset dword_512B90
    rep stosd
    mov     edi, [esp+8+idFrom]
    xor     esi, esi

    loc_451F43:                             ; CODE XREF: sub_451DF0+1B7j
    mov     eax, [edx+esi+1B63h]
    test    eax, eax
    jz      short loc_451F9B
    cmp     byte ptr [edx+esi+1BD6h], 3
    jnz     short loc_451F9B
    mov     eax, [edx+esi+1B6Fh]
    mov     ecx, dword_512B90[eax*4]
    test    ecx, ecx
    jnz     short loc_451F9B
    mov     ecx, [edx+esi+1B67h]
    push    edi                             ; idFrom
    push    ebx                             ; idTo
    push    ecx                             ; PlayersToSendTo
    push    ebp                             ; dwDataSize
    call    Network_BroadcastMessage
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+esi+1B6Fh]
    test    eax, eax
    jl      short loc_451F9B
    cmp     eax, 0Ah
    jge     short loc_451F9B
    mov     dword_512B90[eax*4], 1

    loc_451F9B:                             ; CODE XREF: sub_451DF0+15Cj
                                            ; sub_451DF0+166j ...
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_451F43

    loc_451FA9:                             ; CODE XREF: sub_451DF0+C2j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_451FB5:                             ; CODE XREF: sub_451DF0+90j
                                            ; sub_451DF0+99j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_451FBE:                             ; CODE XREF: sub_451DF0+54j
    mov     byte ptr [esp+8+PlayerID], bl
    jmp     loc_451E5A
    sub_451DF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_451FD0 proc near                    ; CODE XREF: sub_491200+169p

    arg_0= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     ecx, 2Ch
    xor     eax, eax
    mov     edi, offset dword_512ADC
    mov     edx, 4
    rep stosd
    mov     dword_512BE4, edx
    mov     dword_512C70, edx
    mov     dword_512BE8, edx
    mov     dword_512BEC, edx
    mov     dword_512BF0, edx
    mov     dword_512BF4, edx
    mov     dword_512BF8, edx
    mov     dword_512BFC, edx
    mov     dword_512C00, edx
    mov     dword_512B1C, edx
    mov     dword_512C04, edx
    mov     dword_512C08, edx
    mov     dword_512C10, edx
    mov     dword_512C18, edx
    mov     ecx, 7
    mov     esi, 1
    mov     eax, offset unknown_libname_25
    mov     ebp, 3
    mov     edi, 6
    mov     ebx, 5
    mov     edx, 2
    mov     dword_512AE0, 0Dh
    mov     dword_512A28, offset unknown_libname_26
    mov     dword_512BC8, ecx
    mov     dword_512AEC, 41h
    mov     dword_512A34, offset unknown_libname_27
    mov     dword_512BD4, ecx
    mov     dword_512AF0, esi
    mov     dword_512A38, offset unknown_libname_28
    mov     dword_512BD8, ecx
    mov     dword_512AF4, esi
    mov     dword_512A3C, offset unknown_libname_29
    mov     dword_512BDC, ecx
    mov     dword_512AF8, esi
    mov     dword_512A40, offset unknown_libname_30
    mov     dword_512BE0, ecx
    mov     dword_512AFC, 17h
    mov     dword_512A44, eax
    mov     dword_512B88, ebp
    mov     dword_512AD0, eax
    mov     dword_512B00, ecx
    mov     dword_512A48, eax
    mov     dword_512B04, 9
    mov     dword_512A4C, eax
    mov     dword_512B08, 0Bh
    mov     dword_512A50, eax
    mov     dword_512B0C, 24h
    mov     dword_512A54, eax
    mov     dword_512B10, 0Eh
    mov     dword_512A58, eax
    mov     dword_512B14, edi
    mov     dword_512A5C, eax
    mov     dword_512B18, 16h
    mov     dword_512A60, eax
    mov     dword_512A64, eax
    mov     dword_512B20, ebx
    mov     dword_512A68, eax
    mov     dword_512B24, 12h
    mov     dword_512A6C, eax
    mov     dword_512C0C, ecx
    mov     dword_512B28, 18h
    mov     dword_512A70, eax
    mov     dword_512B2C, esi
    mov     dword_512A74, eax
    mov     dword_512C14, edi
    mov     dword_512B30, 11h
    mov     dword_512A78, eax
    mov     dword_512B34, edx
    mov     dword_512A7C, eax
    mov     dword_512C1C, ecx
    mov     dword_512B38, edx
    mov     dword_512A80, eax
    mov     dword_512C20, ecx
    mov     dword_512B3C, ebp
    mov     dword_512A84, eax
    mov     dword_512C24, ecx
    mov     dword_512B44, edi
    mov     dword_512A8C, eax
    mov     dword_512C2C, ecx
    mov     dword_512B48, ebx
    mov     dword_512A90, eax
    mov     dword_512C30, ecx
    mov     dword_512B40, 0Eh
    mov     dword_512A88, eax
    mov     dword_512C28, esi
    mov     dword_512B4C, 9
    mov     dword_512A94, eax
    mov     dword_512B6C, ebx
    mov     dword_512AB4, eax
    mov     dword_512C54, esi
    mov     dword_512B70, 29h
    mov     dword_512AB8, eax
    mov     dword_512C58, ecx
    mov     dword_512B64, 0Eh
    mov     dword_512AAC, eax
    mov     dword_512C4C, ecx
    mov     dword_512B68, edi
    mov     dword_512AB0, eax
    mov     dword_512C50, ecx
    mov     dword_512B50, edx
    mov     dword_512A98, eax
    mov     dword_512C38, edi
    mov     dword_512B54, ebx
    mov     dword_512A9C, eax
    mov     dword_512C3C, edi
    mov     dword_512B58, 0BAh
    mov     dword_512AA0, eax
    mov     dword_512C40, ecx
    mov     dword_512B5C, 0Ah
    mov     dword_512AA4, eax
    mov     dword_512C44, esi
    mov     dword_512B60, edi
    mov     dword_512AA8, eax
    mov     dword_512C48, esi
    mov     dword_512B74, 11h
    mov     dword_512ABC, eax
    mov     dword_512C5C, ecx
    mov     dword_512B78, 3Ah
    mov     dword_512AC0, eax
    mov     dword_512C60, ecx
    mov     dword_512B7C, ebp
    mov     dword_512AC4, eax
    mov     dword_512C64, ecx
    mov     dword_512AE4, ebp
    mov     dword_512A2C, eax
    mov     dword_512BCC, ecx
    mov     dword_512B80, edx
    mov     dword_512AC8, eax
    mov     dword_512C68, ecx
    call    sub_4B6340
    mov     esi, [esp+arg_0]
    push    2000h
    push    offset aPacketData              ; "PACKET DATA"
    mov     [esi+870h], eax
    mov     dword ptr [esi+1745h], 2000h
    call    sub_4D83B0
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    mov     [esi+1749h], eax
    pop     edi
    setnz   cl
    pop     esi
    pop     ebp
    mov     eax, ecx
    pop     ebx
    retn    4
    sub_451FD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_452370 proc near                    ; CODE XREF: sub_4916A0+11Ap

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    mov     eax, [esi+1749h]
    test    eax, eax
    jz      short loc_452392
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+1749h], 0

    loc_452392:                             ; CODE XREF: sub_452370+Dj
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 1
    jz      short loc_4523DB
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_4523B5
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_4523B5:                             ; CODE XREF: sub_452370+37j
    call    IsReporterDLLLoaded
    test    al, al
    jnz     short loc_4523CD
    mov     ecx, TAdynmemStructPtr
    add     ecx, 14h
    push    ecx
    call    sub_4C9B70

    loc_4523CD:                             ; CODE XREF: sub_452370+4Cj
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+TAdynmemStruct.NetworkLayerEnabled], 0FFFEh

    loc_4523DB:                             ; CODE XREF: sub_452370+2Ej
    pop     esi
    retn    4
    sub_452370 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4523E0 proc near                    ; CODE XREF: sub_4526C0+9Bp
                                            ; Network_Process+C95p

    idTo= dword ptr -2
    dwDataSize= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    xor     ebp, ebp

    loc_4523ED:                             ; CODE XREF: sub_4523E0+68j
    mov     ebx, [esp+14h+arg_8]
    cmp     ebx, 0Ah
    jl      short loc_452402
    mov     [esp+14h+arg_8], 0
    mov     ebx, [esp+14h+arg_8]

    loc_452402:                             ; CODE XREF: sub_4523E0+14j
    xor     esi, esi
    lea     eax, [edi+1BD6h]

    loc_45240A:                             ; CODE XREF: sub_4523E0+58j
    mov     cl, [eax]
    test    cl, cl
    jz      short loc_45242F
    cmp     cl, 4
    jz      short loc_45242F
    mov     ecx, [esp+14h+arg_4]
    mov     edx, [eax-6Fh]
    cmp     edx, ecx
    jz      short loc_45242F
    mov     edx, [eax-4Ch]
    xor     ecx, ecx
    mov     cl, [edx+96h]
    cmp     ecx, ebx
    jz      short loc_45243A

    loc_45242F:                             ; CODE XREF: sub_4523E0+2Ej
                                            ; sub_4523E0+33j ...
    inc     esi
    add     eax, 14Bh
    cmp     esi, 0Ah
    jl      short loc_45240A

    loc_45243A:                             ; CODE XREF: sub_4523E0+4Dj
    cmp     esi, 0Ah
    jz      short loc_45244C
    inc     ebp
    inc     ebx
    cmp     ebp, 0Ah
    mov     [esp+14h+arg_8], ebx
    jl      short loc_4523ED
    jmp     short loc_452450
    ; ---------------------------------------------------------------------------

    loc_45244C:                             ; CODE XREF: sub_4523E0+5Dj
    mov     byte ptr [esp+14h+idTo+1], bl

    loc_452450:                             ; CODE XREF: sub_4523E0+6Aj
    xor     ecx, ecx
    mov     cl, [edi+2A42h]
    mov     eax, ecx
    add     edi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     ecx, [edi+edx*2+1B67h]
    lea     eax, [edi+edx*2]
    mov     edi, [esp+14h+arg_4]
    cmp     edi, ecx
    jnz     short loc_45248F
    mov     eax, [eax+1B8Ah]
    mov     [eax+96h], bl
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_45248F:                             ; CODE XREF: sub_4523E0+94j
    mov     edx, [esp+14h+dwDataSize]
    lea     ecx, [esp+14h+idTo]
    push    2                               ; idFrom
    push    ecx                             ; idTo
    push    edi                             ; PlayersToSendTo
    push    edx                             ; dwDataSize
    mov     byte ptr [esp+24h+idTo], 18h
    call    Network_BroadcastMessage
    mov     esi, eax
    test    esi, esi
    jz      loc_452551
    mov     eax, dword_506DBC
    test    eax, eax
    jz      loc_452551
    mov     edx, TAdynmemStructPtr
    cmp     edi, 0FFFFFFFFh
    jnz     short loc_4524CF
    mov     byte ptr [esp+14h+arg_4], 0Ah
    jmp     short loc_452523
    ; ---------------------------------------------------------------------------

    loc_4524CF:                             ; CODE XREF: sub_4523E0+E6j
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+14h+arg_4], bl
    jz      short loc_452508

    loc_4524DA:                             ; CODE XREF: sub_4523E0+138j
    mov     eax, [esp+14h+arg_4]
    mov     ebp, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     cl, [ebp+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_452508
    mov     eax, [eax+1B67h]
    jmp     short loc_45250B
    ; ---------------------------------------------------------------------------

    loc_452508:                             ; CODE XREF: sub_4523E0+F8j
                                            ; sub_4523E0+11Ej
    or      eax, 0FFFFFFFFh

    loc_45250B:                             ; CODE XREF: sub_4523E0+126j
    cmp     eax, edi
    jz      short loc_45255B
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+14h+arg_4], bl
    jb      short loc_4524DA
    mov     byte ptr [esp+14h+arg_4], 0Ah

    loc_45251F:                             ; CODE XREF: sub_4523E0+17Fj
    mov     ebx, [esp+14h+arg_8]

    loc_452523:                             ; CODE XREF: sub_4523E0+EDj
    mov     eax, [esp+14h+arg_4]
    push    1
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    mov     edx, [edx+ecx*2+1B8Ah]
    mov     ecx, offset dword_513000
    mov     [edx+96h], bl
    call    sub_4618A0

    loc_452551:                             ; CODE XREF: sub_4523E0+CAj
                                            ; sub_4523E0+D7j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_45255B:                             ; CODE XREF: sub_4523E0+12Dj
    mov     byte ptr [esp+14h+arg_4], bl
    jmp     short loc_45251F
    sub_4523E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_452570 proc near                    ; CODE XREF: sub_4526C0+8Cp
                                            ; Network_Process+C46p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= word ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    push    ebx
    mov     ebx, [esp+10h+arg_4]
    push    ebp
    push    esi
    cmp     ebx, 0FFh
    push    edi
    jz      loc_4526A7
    test    ebx, ebx
    jl      loc_4526A7
    cmp     ebx, 0Ah
    jge     loc_4526A7
    mov     edi, [esp+1Ch+arg_0]
    mov     esi, TAdynmemStructPtr
    or      eax, 0FFFFFFFFh
    cmp     edi, 0FFFFFFFFh
    mov     [esp+1Ch+var_C], eax
    mov     [esp+1Ch+var_8], eax
    mov     [esp+1Ch+var_4], ax
    jz      short loc_452606
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+1Ch+arg_4], dl
    jz      short loc_4525F0

    loc_4525C2:                             ; CODE XREF: sub_452570+94j
    mov     eax, [esp+1Ch+arg_4]
    mov     ebp, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     cl, [ebp+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4525F0
    mov     eax, [eax+1B67h]
    jmp     short loc_4525F3
    ; ---------------------------------------------------------------------------

    loc_4525F0:                             ; CODE XREF: sub_452570+50j
                                            ; sub_452570+76j
    or      eax, 0FFFFFFFFh

    loc_4525F3:                             ; CODE XREF: sub_452570+7Ej
    cmp     eax, edi
    jz      loc_4526B3
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+1Ch+arg_4], dl
    jb      short loc_4525C2

    loc_452606:                             ; CODE XREF: sub_452570+45j
    mov     al, 0Ah

    loc_452608:                             ; CODE XREF: sub_452570+145j
    cmp     al, 0Ah
    jz      short loc_45265C
    cmp     edi, 0FFFFFFFFh
    jz      short loc_45265C
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+1Ch+arg_4], dl
    jz      short loc_45264A

    loc_45261C:                             ; CODE XREF: sub_452570+EAj
    mov     eax, [esp+1Ch+arg_4]
    mov     ebp, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     cl, [ebp+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_45264A
    mov     eax, [eax+1B67h]
    jmp     short loc_45264D
    ; ---------------------------------------------------------------------------

    loc_45264A:                             ; CODE XREF: sub_452570+AAj
                                            ; sub_452570+D0j
    or      eax, 0FFFFFFFFh

    loc_45264D:                             ; CODE XREF: sub_452570+D8j
    cmp     eax, edi
    jz      short loc_45265C
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+1Ch+arg_4], dl
    jb      short loc_45261C

    loc_45265C:                             ; CODE XREF: sub_452570+9Aj
                                            ; sub_452570+9Fj ...
    xor     edx, edx
    lea     ecx, [esi+1B8Ah]

    loc_452664:                             ; CODE XREF: sub_452570+11Fj
    mov     al, [ecx+4Ch]
    test    al, al
    jz      short loc_452685
    cmp     [ecx-23h], edi
    jz      short loc_452685
    mov     eax, [ecx]
    mov     al, [eax+96h]
    cmp     al, 0FFh
    jz      short loc_452685
    and     eax, 0FFh
    mov     byte ptr [esp+eax+1Ch+var_C], dl

    loc_452685:                             ; CODE XREF: sub_452570+F9j
                                            ; sub_452570+FEj ...
    inc     edx
    add     ecx, 14Bh
    cmp     edx, 0Ah
    jl      short loc_452664
    mov     cl, byte ptr [esp+ebx+1Ch+var_C]
    xor     eax, eax
    cmp     cl, 0FFh
    setz    al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4526A7:                             ; CODE XREF: sub_452570+11j
                                            ; sub_452570+19j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4526B3:                             ; CODE XREF: sub_452570+85j
    mov     al, dl
    jmp     loc_452608
    sub_452570 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4526C0 proc near                    ; CODE XREF: sub_444930+DAp
                                            ; sub_447B10+103p ...

    var_1= dword ptr -1
    idTo= dword ptr  7

    push    ecx
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    push    ebx
    push    ebp
    mov     al, [edx+2A42h]
    push    esi
    mov     esi, eax
    push    edi
    shl     eax, 5
    add     eax, esi
    xor     bl, bl
    mov     byte ptr [esp+11h+var_1], bl
    lea     ecx, [eax+eax*4]
    lea     eax, [edx+esi]
    lea     edi, [eax+ecx*2+1B63h]

    loc_4526ED:                             ; CODE XREF: sub_4526C0+6Fj
    mov     eax, [esp+11h+var_1]
    mov     ebp, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     cl, [ebp+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_452726
    mov     eax, [eax+1B8Ah]
    test    byte ptr [eax+97h], 1
    jnz     loc_4527EA

    loc_452726:                             ; CODE XREF: sub_4526C0+51j
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+11h+var_1], bl
    jb      short loc_4526ED
    mov     byte ptr [esp+11h+var_1], 0Ah

    loc_452736:                             ; CODE XREF: sub_4526C0+12Ej
    mov     eax, [esp+11h+var_1]
    and     eax, 0FFh
    cmp     eax, esi
    jnz     short loc_452783
    mov     ebx, [esp+11h+idTo]
    mov     ecx, [edi+4]
    push    ebx
    push    ecx
    call    sub_452570
    test    eax, eax
    jnz     short loc_45276D
    mov     eax, [edi+4]
    push    ebx
    push    eax
    push    eax
    call    sub_4523E0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45276D:                             ; CODE XREF: sub_4526C0+93j
    mov     edx, [edi+27h]
    mov     eax, 1
    mov     [edx+96h], bl
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452783:                             ; CODE XREF: sub_4526C0+81j
    mov     edx, [edx+2A38h]
    mov     cl, byte ptr [esp+11h+idTo]
    cmp     eax, 0Ah
    push    2                               ; idFrom
    mov     byte ptr [edx], 17h
    mov     [edx+1], cl
    push    edx                             ; idTo
    jnz     short loc_4527A6
    mov     edx, [edi+4]
    push    edx                             ; PlayerID
    call    sub_451DF0
    jmp     short loc_4527C9                ; idTo
    ; ---------------------------------------------------------------------------

    loc_4527A6:                             ; CODE XREF: sub_4526C0+D9j
    mov     edx, TAdynmemStructPtr
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edx+ecx*2+1B67h]
    mov     ecx, [edi+4]
    push    eax                             ; PlayersToSendTo
    push    ecx                             ; dwDataSize
    call    Network_BroadcastMessage

    loc_4527C9:                             ; CODE XREF: sub_4526C0+E4j
    mov     esi, eax
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_4527E0
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_4527E0:                             ; CODE XREF: sub_4526C0+112j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4527EA:                             ; CODE XREF: sub_4526C0+60j
    mov     byte ptr [esp+11h+var_1], bl
    jmp     loc_452736
    sub_4526C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    push    edi
    mov     edi, [esp+14h]
    cmp     edi, 0FFFFFFFFh
    jz      short loc_452861
    xor     dl, dl
    cmp     dl, 0Ah
    mov     [esp+14h], dl
    jz      short loc_45284B

    loc_45281E:                             ; CODE XREF: .text:0045285Fj
    mov     eax, [esp+14h]
    mov     ebx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_45284B
    mov     eax, [eax+1B67h]
    jmp     short loc_45284E
    ; ---------------------------------------------------------------------------

    loc_45284B:                             ; CODE XREF: .text:0045281Cj
                                            ; .text:00452841j
    or      eax, 0FFFFFFFFh

    loc_45284E:                             ; CODE XREF: .text:00452849j
    cmp     eax, edi
    jz      loc_452957
    inc     dl
    cmp     dl, 0Ah
    mov     [esp+14h], dl
    jb      short loc_45281E

    loc_452861:                             ; CODE XREF: .text:00452811j
    mov     al, 0Ah

    loc_452863:                             ; CODE XREF: .text:00452959j
    cmp     al, 0Ah
    jnz     short loc_452870
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452870:                             ; CODE XREF: .text:00452865j
    mov     esi, [esi+2A38h]
    cmp     edi, 0FFFFFFFFh
    mov     byte ptr [esi], 1Ch
    mov     [esi+1], edi
    mov     edx, TAdynmemStructPtr
    jz      short loc_4528DA
    xor     bl, bl
    cmp     bl, 0Ah
    mov     [esp+14h], bl
    jz      short loc_4528C0

    loc_452892:                             ; CODE XREF: .text:004528D0j
    mov     eax, [esp+14h]
    mov     ebp, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     cl, [ebp+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4528C0
    mov     eax, [eax+1B67h]
    jmp     short loc_4528C3
    ; ---------------------------------------------------------------------------

    loc_4528C0:                             ; CODE XREF: .text:00452890j
                                            ; .text:004528B6j
    or      eax, 0FFFFFFFFh

    loc_4528C3:                             ; CODE XREF: .text:004528BEj
    cmp     eax, edi
    jz      short loc_4528D4
    inc     bl
    cmp     bl, 0Ah
    mov     [esp+14h], bl
    jb      short loc_452892
    jmp     short loc_4528DA
    ; ---------------------------------------------------------------------------

    loc_4528D4:                             ; CODE XREF: .text:004528C5j
    mov     [esp+14h], bl
    jmp     short loc_4528DF
    ; ---------------------------------------------------------------------------

    loc_4528DA:                             ; CODE XREF: .text:00452885j
                                            ; .text:004528D2j
    mov     byte ptr [esp+14h], 0Ah

    loc_4528DF:                             ; CODE XREF: .text:004528D8j
    mov     eax, [esp+14h]
    mov     ebx, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2+1B63h]
    mov     ecx, [ebx+ecx*2+1B63h]
    test    ecx, ecx
    jz      short loc_45290E
    cmp     byte ptr [eax+73h], 3
    jz      short loc_452920

    loc_45290E:                             ; CODE XREF: .text:00452906j
    test    byte ptr [edx+38D75h], 1
    jz      short loc_452920
    test    byte ptr [edx+38D75h], 2
    jz      short loc_45292C

    loc_452920:                             ; CODE XREF: .text:0045290Cj
                                            ; .text:00452915j
    push    edi
    call    sub_452CC0
    mov     edx, TAdynmemStructPtr

    loc_45292C:                             ; CODE XREF: .text:0045291Ej
    xor     ecx, ecx
    push    5
    mov     cl, [edx+2A42h]
    push    esi
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [edx+eax*2+1B67h]
    push    ecx
    call    sub_451DF0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452957:                             ; CODE XREF: .text:00452850j
    mov     al, dl
    jmp     loc_452863
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_452960 proc near                    ; CODE XREF: sub_446E90+82p
                                            ; sub_447150+E5p ...

    var_1= dword ptr -1
    dwDataSize= dword ptr  7
    arg_4= dword ptr  0Bh
    arg_8= dword ptr  0Fh
    arg_C= dword ptr  13h

    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+0Dh+dwDataSize]
    cmp     esi, 0FFFFFFFFh
    push    edi
    jz      short loc_45298D
    xor     bl, bl
    mov     byte ptr [esp+11h+var_1], bl

    loc_452974:                             ; CODE XREF: sub_452960+2Bj
    mov     eax, [esp+11h+var_1]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_45298F
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+11h+var_1], bl
    jb      short loc_452974

    loc_45298D:                             ; CODE XREF: sub_452960+Cj
    mov     bl, 0Ah

    loc_45298F:                             ; CODE XREF: sub_452960+20j
    cmp     bl, 0Ah
    jnz     short loc_452998
    xor     esi, esi
    jmp     short loc_4529BB
    ; ---------------------------------------------------------------------------

    loc_452998:                             ; CODE XREF: sub_452960+32j
    push    esi                             ; int
    call    sub_44FE40
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    lea     esi, [eax+edx*2+1B63h]

    loc_4529BB:                             ; CODE XREF: sub_452960+36j
    mov     ebp, [esp+11h+arg_4]
    push    ebp                             ; int
    call    sub_44FE40
    cmp     al, 0Ah
    jnz     short loc_4529CD
    xor     eax, eax
    jmp     short loc_4529F0
    ; ---------------------------------------------------------------------------

    loc_4529CD:                             ; CODE XREF: sub_452960+67j
    push    ebp                             ; int
    call    sub_44FE40
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    lea     eax, [eax+edx*2+1B63h]

    loc_4529F0:                             ; CODE XREF: sub_452960+6Bj
    xor     ebx, ebx
    test    esi, esi
    jz      loc_452B5E
    test    eax, eax
    jz      loc_452B5E
    mov     ecx, [esi]
    mov     dl, byte ptr [esp+11h+arg_8]
    test    ecx, ecx
    jz      short loc_452A81
    mov     cl, [esi+73h]
    cmp     cl, 1
    jz      short loc_452A19
    cmp     cl, 2
    jnz     short loc_452A81

    loc_452A19:                             ; CODE XREF: sub_452960+B2j
    mov     cl, [eax+146h]
    mov     byte ptr [esp+11h+arg_8], cl
    mov     ecx, [esp+11h+arg_8]
    and     ecx, 0FFh
    mov     [ecx+esi+108h], dl
    mov     ecx, [eax]
    test    ecx, ecx
    jz      short loc_452A59
    mov     bl, [eax+73h]
    cmp     bl, 2
    jz      short loc_452A61
    test    ecx, ecx
    jz      short loc_452A59
    mov     cl, bl
    cmp     cl, 3
    jnz     short loc_452A59
    mov     ecx, [eax+27h]
    cmp     byte ptr [ecx+94h], 2
    jz      short loc_452A61

    loc_452A59:                             ; CODE XREF: sub_452960+D8j
                                            ; sub_452960+E4j ...
    mov     ecx, [esp+11h+arg_C]
    test    ecx, ecx
    jz      short loc_452A7C

    loc_452A61:                             ; CODE XREF: sub_452960+E0j
                                            ; sub_452960+F7j
    mov     cl, [eax+146h]
    mov     byte ptr [esp+11h+arg_8], cl
    mov     ecx, [esp+11h+arg_8]
    and     ecx, 0FFh
    mov     [ecx+esi+113h], dl

    loc_452A7C:                             ; CODE XREF: sub_452960+FFj
    mov     ebx, 1

    loc_452A81:                             ; CODE XREF: sub_452960+AAj
                                            ; sub_452960+B7j
    mov     edi, [eax]
    test    edi, edi
    jz      loc_452B38
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_452A98
    cmp     cl, 2
    jnz     short loc_452AE9

    loc_452A98:                             ; CODE XREF: sub_452960+131j
    mov     cl, [esi+146h]
    mov     byte ptr [esp+11h+arg_8], cl
    mov     ecx, [esp+11h+arg_8]
    and     ecx, 0FFh
    mov     [ecx+eax+113h], dl
    mov     ecx, [eax]
    test    ecx, ecx
    jz      short loc_452ABF
    cmp     byte ptr [eax+73h], 2
    jz      short loc_452AC7

    loc_452ABF:                             ; CODE XREF: sub_452960+157j
    mov     ecx, [esp+11h+arg_C]
    test    ecx, ecx
    jz      short loc_452AE2

    loc_452AC7:                             ; CODE XREF: sub_452960+15Dj
    mov     cl, [esi+146h]
    mov     byte ptr [esp+11h+arg_8], cl
    mov     ecx, [esp+11h+arg_8]
    and     ecx, 0FFh
    mov     [ecx+eax+108h], dl

    loc_452AE2:                             ; CODE XREF: sub_452960+165j
    mov     ebx, 1
    jmp     short loc_452B38
    ; ---------------------------------------------------------------------------

    loc_452AE9:                             ; CODE XREF: sub_452960+136j
    test    edi, edi
    jz      short loc_452B38
    cmp     byte ptr [eax+73h], 3
    jnz     short loc_452B38
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+11h+dwDataSize]
    push    0Eh                             ; idFrom
    mov     eax, [eax+2A38h]
    push    eax                             ; idTo
    push    ebp                             ; PlayersToSendTo
    mov     [eax+9], dl
    mov     edx, [esp+1Dh+arg_C]
    push    ecx                             ; dwDataSize
    mov     byte ptr [eax], 23h
    mov     [eax+1], ecx
    mov     [eax+5], ebp
    mov     [eax+0Ah], edx
    call    Network_BroadcastMessage
    mov     esi, eax
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_452B36
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_452B36:                             ; CODE XREF: sub_452960+1C8j
    mov     ebx, esi

    loc_452B38:                             ; CODE XREF: sub_452960+125j
                                            ; sub_452960+187j ...
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_452B54
    push    4
    call    RIWrapper_Report

    loc_452B54:                             ; CODE XREF: sub_452960+1EBj
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_452B5E:                             ; CODE XREF: sub_452960+94j
                                            ; sub_452960+9Cj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    10h
    sub_452960 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     cl, [esp+0Ch]
    mov     edx, [esp+8]
    push    esi
    mov     eax, [eax+2A38h]
    mov     esi, [esp+14h]
    push    0Eh
    push    eax
    mov     [eax+9], cl
    mov     ecx, [esp+10h]
    push    edx
    push    ecx
    mov     byte ptr [eax], 23h
    mov     [eax+1], ecx
    mov     [eax+5], edx
    mov     [eax+0Ah], esi
    call    Network_BroadcastMessage
    mov     esi, eax
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_452BBC
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_452BBC:                             ; CODE XREF: .text:00452BAEj
    mov     eax, esi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_452BD0 proc near                    ; CODE XREF: .text:00446F94p
                                            ; sub_447B10+4B0p ...

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    push    esi
    cmp     dword ptr [ecx], 0
    jz      short loc_452BE5
    mov     al, [ecx+73h]
    cmp     al, 1
    jz      short loc_452BEB
    cmp     al, 2
    jz      short loc_452BEB

    loc_452BE5:                             ; CODE XREF: sub_452BD0+8j
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452BEB:                             ; CODE XREF: sub_452BD0+Fj
                                            ; sub_452BD0+13j
    mov     eax, TAdynmemStructPtr
    push    6                               ; idFrom
    mov     eax, [eax+2A38h]
    push    eax                             ; idTo
    mov     byte ptr [eax], 24h
    mov     edx, [ecx+4]
    mov     [eax+1], edx
    mov     dl, [ecx+13Fh]
    mov     [eax+5], dl
    mov     eax, [ecx+4]
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     esi, eax
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_452C2B
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_452C2B:                             ; CODE XREF: sub_452BD0+4Dj
    mov     eax, esi
    pop     esi
    retn    4
    sub_452BD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_452C40 proc near                    ; CODE XREF: .text:0041F8E9p
                                            ; sub_443CB0+2AEp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    add     eax, 0FFFFFFFDh                 ; switch 8 cases
    cmp     eax, 7
    ja      short loc_452C93                ; default
    jmp     ds:off_452C9C[eax*4]            ; switch jump

    loc_452C53:                             ; DATA XREF: .text:00452C9Co
    mov     eax, offset aYouDidNotHaveT     ; case 0x4
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452C5B:                             ; CODE XREF: sub_452C40+Cj
                                            ; DATA XREF: .text:00452C9Co
    mov     eax, offset aTheGameIsClose     ; case 0x3
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452C63:                             ; CODE XREF: sub_452C40+Cj
                                            ; DATA XREF: .text:00452C9Co
    mov     eax, offset aTheGameIsFull      ; case 0x5
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452C6B:                             ; CODE XREF: sub_452C40+Cj
                                            ; DATA XREF: .text:00452C9Co
    mov     eax, offset aYouHaveLostCon     ; case 0x6
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452C73:                             ; CODE XREF: sub_452C40+Cj
                                            ; DATA XREF: .text:00452C9Co
    mov     eax, offset aYouNeedAUnitYo     ; case 0x7
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452C7B:                             ; CODE XREF: sub_452C40+Cj
                                            ; DATA XREF: .text:00452C9Co
    mov     eax, offset aYouNeedANewerV     ; case 0x8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452C83:                             ; CODE XREF: sub_452C40+Cj
                                            ; DATA XREF: .text:00452C9Co
    mov     eax, offset aNoWatchingIsAl     ; case 0x9
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452C8B:                             ; CODE XREF: sub_452C40+Cj
                                            ; DATA XREF: .text:00452C9Co
    mov     eax, offset aTheCreatorHasL     ; case 0xa
    retn    4
    ; ---------------------------------------------------------------------------

    loc_452C93:                             ; CODE XREF: sub_452C40+Aj
    mov     eax, offset aYouWereRejecte     ; default
    retn    4
    sub_452C40 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_452C9C dd offset loc_452C5B         ; DATA XREF: sub_452C40+Cr
    dd offset loc_452C53                    ; jump table for switch statement
    dd offset loc_452C63
    dd offset loc_452C6B
    dd offset loc_452C73
    dd offset loc_452C7B
    dd offset loc_452C83
    dd offset loc_452C8B
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_452CC0 proc near                    ; CODE XREF: sub_450E20+49p
                                            ; sub_451B60+34p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch+arg_0]
    push    esi
    cmp     ebp, 0FFFFFFFFh
    push    edi
    jz      short loc_452CED
    xor     bl, bl
    mov     byte ptr [esp+14h+arg_0], bl

    loc_452CD4:                             ; CODE XREF: sub_452CC0+2Bj
    mov     eax, [esp+14h+arg_0]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, ebp
    jz      short loc_452CEF
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+14h+arg_0], bl
    jb      short loc_452CD4

    loc_452CED:                             ; CODE XREF: sub_452CC0+Cj
    mov     bl, 0Ah

    loc_452CEF:                             ; CODE XREF: sub_452CC0+20j
    cmp     bl, 0Ah
    jnz     short loc_452CFE
    mov     ebx, TAdynmemStructPtr
    xor     esi, esi
    jmp     short loc_452D24
    ; ---------------------------------------------------------------------------

    loc_452CFE:                             ; CODE XREF: sub_452CC0+32j
    push    ebp                             ; int
    call    sub_44FE40
    mov     ebx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, ebx
    add     eax, ecx
    lea     esi, [eax+edx*2+1B63h]

    loc_452D24:                             ; CODE XREF: sub_452CC0+3Cj
    test    esi, esi
    jz      loc_452FFF
    cmp     dword ptr [esi], 0
    jz      loc_452FFF
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_452D48
    cmp     al, 2
    jz      short loc_452D48
    cmp     al, 3
    jnz     loc_452FFF

    loc_452D48:                             ; CODE XREF: sub_452CC0+7Aj
                                            ; sub_452CC0+7Ej
    mov     al, [esi+146h]
    cmp     al, 0Ah
    jz      loc_452FFF
    mov     ecx, [esi+27h]
    mov     byte ptr [esp+14h+arg_0], al
    mov     edi, [esp+14h+arg_0]
    xor     eax, eax
    mov     al, [ecx+97h]
    and     eax, 1
    xor     edx, edx
    mov     [esp+14h+var_4], eax

    loc_452D72:                             ; CODE XREF: sub_452CC0+F8j
    mov     eax, [ebx+edx+1B63h]
    lea     ecx, [ebx+edx+1B63h]
    test    eax, eax
    jz      short loc_452DAC
    mov     al, [ecx+73h]
    cmp     al, 1
    jz      short loc_452D8F
    cmp     al, 2
    jnz     short loc_452DAC

    loc_452D8F:                             ; CODE XREF: sub_452CC0+C9j
    mov     eax, edi
    and     eax, 0FFh
    mov     byte ptr [ecx+eax+113h], 0
    mov     byte ptr [ecx+eax+108h], 0
    mov     ebx, TAdynmemStructPtr

    loc_452DAC:                             ; CODE XREF: sub_452CC0+C2j
                                            ; sub_452CC0+CDj
    add     edx, 14Bh
    cmp     edx, 0CEEh
    jl      short loc_452D72
    cmp     ebp, 0FFFFFFFFh
    jz      short loc_452E0D
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+14h+arg_0], dl
    jz      short loc_452DF7

    loc_452DCA:                             ; CODE XREF: sub_452CC0+14Bj
    mov     eax, [esp+14h+arg_0]
    mov     edi, ebx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_452DF7
    mov     eax, [eax+1B67h]
    jmp     short loc_452DFA
    ; ---------------------------------------------------------------------------

    loc_452DF7:                             ; CODE XREF: sub_452CC0+108j
                                            ; sub_452CC0+12Dj
    or      eax, 0FFFFFFFFh

    loc_452DFA:                             ; CODE XREF: sub_452CC0+135j
    cmp     eax, ebp
    jz      loc_453007
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+14h+arg_0], dl
    jb      short loc_452DCA

    loc_452E0D:                             ; CODE XREF: sub_452CC0+FDj
    mov     byte ptr [esp+14h+arg_0], 0Ah

    loc_452E12:                             ; CODE XREF: sub_452CC0+34Bj
    mov     edx, [esp+14h+arg_0]
    push    edx
    call    sub_486F10
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+2A44h]
    shr     al, 2
    test    al, 1
    mov     eax, [esi]
    jz      short loc_452E42
    test    eax, eax
    jz      short loc_452E5E
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_452E81
    cmp     al, 2
    jz      short loc_452E81
    jmp     short loc_452E5E
    ; ---------------------------------------------------------------------------

    loc_452E42:                             ; CODE XREF: sub_452CC0+16Fj
    test    eax, eax
    jz      short loc_452E5E
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_452E51
    cmp     al, 2
    jnz     short loc_452E5E

    loc_452E51:                             ; CODE XREF: sub_452CC0+18Bj
    mov     edx, [esi+4]
    add     ecx, 14h
    push    edx
    push    ecx
    call    sub_4CA780

    loc_452E5E:                             ; CODE XREF: sub_452CC0+173j
                                            ; sub_452CC0+180j ...
    push    0
    mov     ecx, esi
    call    sub_463C60
    mov     dword ptr [esi], 0
    mov     dword ptr [esi+4], 0FFFFFFFFh
    mov     dword ptr [esi+0Ch], 0
    mov     ecx, TAdynmemStructPtr

    loc_452E81:                             ; CODE XREF: sub_452CC0+17Aj
                                            ; sub_452CC0+17Ej
    dec     word ptr [ecx+2A3Ch]
    mov     eax, [esi+27h]
    add     esi, 108h
    and     word ptr [eax+9Dh], 0FFFBh
    xor     eax, eax
    mov     [esi], eax
    mov     [esi+4], eax
    mov     [esi+8], ax
    mov     [esi+0Ah], al
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_452EC4
    push    eax
    call    RIWrapper_Report

    loc_452EC4:                             ; CODE XREF: sub_452CC0+1FCj
    mov     esi, TAdynmemStructPtr
    test    byte ptr [esi+2A44h], 4
    jz      loc_452FFF
    mov     eax, [esp+14h+var_4]
    test    eax, eax
    jz      loc_452FFF
    xor     edi, edi
    lea     eax, [esi+1B63h]
    mov     edx, 0Ah

    loc_452EF0:                             ; CODE XREF: sub_452CC0+258j
    mov     ecx, [eax]
    test    ecx, ecx
    jz      short loc_452F12
    mov     bl, [eax+73h]
    cmp     bl, 3
    jz      short loc_452F09
    test    ecx, ecx
    jz      short loc_452F12
    mov     cl, bl
    cmp     cl, 1
    jnz     short loc_452F12

    loc_452F09:                             ; CODE XREF: sub_452CC0+23Cj
    mov     ecx, [eax+4]
    cmp     ecx, edi
    jbe     short loc_452F12
    mov     edi, ecx

    loc_452F12:                             ; CODE XREF: sub_452CC0+234j
                                            ; sub_452CC0+240j ...
    add     eax, 14Bh
    dec     edx
    jnz     short loc_452EF0
    cmp     edi, 0FFFFFFFFh
    jz      short loc_452F6F
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+14h+arg_0], dl
    jz      short loc_452F57

    loc_452F2A:                             ; CODE XREF: sub_452CC0+2A7j
    mov     eax, [esp+14h+arg_0]
    mov     ebx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_452F57
    mov     eax, [eax+1B67h]
    jmp     short loc_452F5A
    ; ---------------------------------------------------------------------------

    loc_452F57:                             ; CODE XREF: sub_452CC0+268j
                                            ; sub_452CC0+28Dj
    or      eax, 0FFFFFFFFh

    loc_452F5A:                             ; CODE XREF: sub_452CC0+295j
    cmp     eax, edi
    jz      short loc_452F6B
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+14h+arg_0], dl
    jb      short loc_452F2A
    jmp     short loc_452F6F
    ; ---------------------------------------------------------------------------

    loc_452F6B:                             ; CODE XREF: sub_452CC0+29Cj
    mov     al, dl
    jmp     short loc_452F71
    ; ---------------------------------------------------------------------------

    loc_452F6F:                             ; CODE XREF: sub_452CC0+25Dj
                                            ; sub_452CC0+2A9j
    mov     al, 0Ah

    loc_452F71:                             ; CODE XREF: sub_452CC0+2ADj
    cmp     al, 0Ah
    jnz     short loc_452F79
    xor     eax, eax
    jmp     short loc_452FF1
    ; ---------------------------------------------------------------------------

    loc_452F79:                             ; CODE XREF: sub_452CC0+2B3j
    cmp     edi, 0FFFFFFFFh
    jz      short loc_452FD0
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+14h+arg_0], dl
    jz      short loc_452FB6

    loc_452F89:                             ; CODE XREF: sub_452CC0+306j
    mov     eax, [esp+14h+arg_0]
    mov     ebx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_452FB6
    mov     eax, [eax+1B67h]
    jmp     short loc_452FB9
    ; ---------------------------------------------------------------------------

    loc_452FB6:                             ; CODE XREF: sub_452CC0+2C7j
                                            ; sub_452CC0+2ECj
    or      eax, 0FFFFFFFFh

    loc_452FB9:                             ; CODE XREF: sub_452CC0+2F4j
    cmp     eax, edi
    jz      short loc_452FCA
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+14h+arg_0], dl
    jb      short loc_452F89
    jmp     short loc_452FD0
    ; ---------------------------------------------------------------------------

    loc_452FCA:                             ; CODE XREF: sub_452CC0+2FBj
    mov     byte ptr [esp+14h+arg_0], dl
    jmp     short loc_452FD5
    ; ---------------------------------------------------------------------------

    loc_452FD0:                             ; CODE XREF: sub_452CC0+2BCj
                                            ; sub_452CC0+308j
    mov     byte ptr [esp+14h+arg_0], 0Ah

    loc_452FD5:                             ; CODE XREF: sub_452CC0+30Ej
    mov     eax, [esp+14h+arg_0]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     esi, eax
    lea     edx, [ecx+ecx*4]
    lea     eax, [esi+edx*2+1B63h]

    loc_452FF1:                             ; CODE XREF: sub_452CC0+2B7j
    test    eax, eax
    jz      short loc_452FFF
    mov     eax, [eax+27h]
    or      byte ptr [eax+97h], 1

    loc_452FFF:                             ; CODE XREF: sub_452CC0+66j
                                            ; sub_452CC0+6Fj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_453007:                             ; CODE XREF: sub_452CC0+13Cj
    mov     byte ptr [esp+14h+arg_0], dl
    jmp     loc_452E12
    sub_452CC0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_453010 proc near                    ; CODE XREF: .text:00446053p
                                            ; .text:00446669p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= byte ptr  8

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+14h+arg_0]
    cmp     esi, 0FFFFFFFFh
    push    edi
    mov     [esp+18h+var_8], 0
    jz      short loc_453047
    xor     bl, bl
    mov     byte ptr [esp+18h+arg_0], bl

    loc_45302E:                             ; CODE XREF: sub_453010+35j
    mov     eax, [esp+18h+arg_0]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_453049
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+18h+arg_0], bl
    jb      short loc_45302E

    loc_453047:                             ; CODE XREF: sub_453010+16j
    mov     bl, 0Ah

    loc_453049:                             ; CODE XREF: sub_453010+2Aj
    cmp     bl, 0Ah
    jnz     short loc_453056
    xor     edi, edi
    mov     [esp+18h+arg_0], edi
    jmp     short loc_45307F
    ; ---------------------------------------------------------------------------

    loc_453056:                             ; CODE XREF: sub_453010+3Cj
    push    esi                             ; int
    call    sub_44FE40
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    lea     ecx, [eax+edx*2+1B63h]
    mov     [esp+18h+arg_0], ecx
    mov     edi, ecx

    loc_45307F:                             ; CODE XREF: sub_453010+44j
    test    edi, edi
    jnz     short loc_45308F
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_45308F:                             ; CODE XREF: sub_453010+71j
    mov     edx, TAdynmemStructPtr
    mov     al, [esp+18h+arg_4]
    mov     ebp, [edx+2A38h]
    mov     byte ptr [ebp+0], 1Bh
    mov     dword ptr [ebp+1], 0FFFFFFFFh
    mov     [ebp+5], al
    mov     eax, [edi]
    test    eax, eax
    jz      loc_4532FF
    mov     cl, [edi+73h]
    cmp     cl, 1
    jz      short loc_4530C8
    cmp     cl, 2
    jnz     loc_453212

    loc_4530C8:                             ; CODE XREF: sub_453010+ADj
    mov     dl, [edi+22h]
    test    dl, dl
    jnz     loc_453212
    cmp     cl, 1
    jnz     loc_4531A7
    mov     eax, TAdynmemStructPtr
    xor     esi, esi

    loc_4530E3:                             ; CODE XREF: sub_453010+184j
    mov     ecx, [eax+esi+1B63h]
    test    ecx, ecx
    jz      loc_453188
    mov     cl, [eax+esi+1BD6h]
    cmp     cl, 1
    jz      short loc_453107
    cmp     cl, 2
    jnz     loc_453188

    loc_453107:                             ; CODE XREF: sub_453010+ECj
    mov     ecx, [eax+esi+1B67h]
    xor     eax, eax
    mov     [ebp+1], ecx
    mov     edi, TAdynmemStructPtr
    lea     ecx, [edi+1BD6h]

    loc_45311F:                             ; CODE XREF: sub_453010+12Ej
    mov     edx, [ecx-73h]
    test    edx, edx
    jz      short loc_453132
    mov     dl, [ecx]
    cmp     dl, 1
    jz      short loc_453140
    cmp     dl, 2
    jz      short loc_453140

    loc_453132:                             ; CODE XREF: sub_453010+114j
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jge     short loc_453155
    jmp     short loc_45311F
    ; ---------------------------------------------------------------------------

    loc_453140:                             ; CODE XREF: sub_453010+11Bj
                                            ; sub_453010+120j
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edi, eax
    lea     edx, [ecx+ecx*4]
    mov     eax, [edi+edx*2+1B67h]
    jmp     short loc_453158
    ; ---------------------------------------------------------------------------

    loc_453155:                             ; CODE XREF: sub_453010+12Cj
    or      eax, 0FFFFFFFFh

    loc_453158:                             ; CODE XREF: sub_453010+143j
    push    6                               ; idFrom
    push    ebp                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     eax, [esp+18h+arg_0]
    mov     ecx, [eax+4]
    push    ecx
    call    sub_452CC0
    mov     edx, TAdynmemStructPtr
    mov     al, [esp+18h+arg_4]
    mov     edi, [esp+18h+arg_0]
    mov     [edx+esi+1B85h], al
    mov     eax, TAdynmemStructPtr

    loc_453188:                             ; CODE XREF: sub_453010+DCj
                                            ; sub_453010+F1j
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      loc_4530E3
    mov     [esp+18h+var_8], 1
    jmp     loc_4532FF
    ; ---------------------------------------------------------------------------

    loc_4531A7:                             ; CODE XREF: sub_453010+C6j
    mov     ecx, [edi+4]
    mov     [ebp+1], ecx
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    lea     eax, [esi+1BD6h]

    loc_4531BB:                             ; CODE XREF: sub_453010+1C9j
    mov     edx, [eax-73h]
    test    edx, edx
    jz      short loc_4531CE
    mov     dl, [eax]
    cmp     dl, 1
    jz      short loc_4531DB
    cmp     dl, 2
    jz      short loc_4531DB

    loc_4531CE:                             ; CODE XREF: sub_453010+1B0j
    inc     ecx
    add     eax, 14Bh
    cmp     ecx, 0Ah
    jge     short loc_4531F0
    jmp     short loc_4531BB
    ; ---------------------------------------------------------------------------

    loc_4531DB:                             ; CODE XREF: sub_453010+1B7j
                                            ; sub_453010+1BCj
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    lea     edx, [eax+eax*4]
    mov     eax, [esi+edx*2+1B67h]
    jmp     short loc_4531F3
    ; ---------------------------------------------------------------------------

    loc_4531F0:                             ; CODE XREF: sub_453010+1C7j
    or      eax, 0FFFFFFFFh

    loc_4531F3:                             ; CODE XREF: sub_453010+1DEj
    push    6                               ; idFrom
    push    ebp                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     eax, [edi+4]
    push    eax
    call    sub_452CC0
    mov     [esp+18h+var_8], 1
    jmp     loc_4532FF
    ; ---------------------------------------------------------------------------

    loc_453212:                             ; CODE XREF: sub_453010+B2j
                                            ; sub_453010+BDj
    test    eax, eax
    jz      loc_4532FF
    mov     al, [edi+73h]
    mov     bl, 3
    cmp     al, bl
    jnz     loc_4532FF
    mov     al, [edi+22h]
    test    al, al
    jnz     loc_4532FF
    mov     [ebp+1], esi
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    lea     eax, [esi+1BD6h]

    loc_453243:                             ; CODE XREF: sub_453010+251j
    mov     edx, [eax-73h]
    test    edx, edx
    jz      short loc_453256
    mov     dl, [eax]
    cmp     dl, 1
    jz      short loc_453263
    cmp     dl, 2
    jz      short loc_453263

    loc_453256:                             ; CODE XREF: sub_453010+238j
    inc     ecx
    add     eax, 14Bh
    cmp     ecx, 0Ah
    jge     short loc_453278
    jmp     short loc_453243
    ; ---------------------------------------------------------------------------

    loc_453263:                             ; CODE XREF: sub_453010+23Fj
                                            ; sub_453010+244j
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    lea     edx, [eax+eax*4]
    mov     eax, [esi+edx*2+1B67h]
    jmp     short loc_45327B
    ; ---------------------------------------------------------------------------

    loc_453278:                             ; CODE XREF: sub_453010+24Fj
    or      eax, 0FFFFFFFFh

    loc_45327B:                             ; CODE XREF: sub_453010+266j
    push    6                               ; idFrom
    push    ebp                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     [esp+18h+var_8], eax
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_4532F6
    cmp     [edi+73h], bl
    jnz     short loc_4532F6
    mov     eax, [edi+27h]
    cmp     byte ptr [eax+94h], 1
    jnz     short loc_4532F6
    mov     cl, [edi+0Ch]
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [esp+18h+var_4], cl
    mov     edi, [esp+18h+var_4]
    and     edi, 0FFh
    xor     esi, esi

    loc_4532B7:                             ; CODE XREF: sub_453010+2DEj
    cmp     [eax+esi+1B6Fh], edi
    jnz     short loc_4532E2
    mov     edx, [eax+esi+1B67h]
    push    edx
    call    sub_452CC0
    mov     eax, TAdynmemStructPtr
    mov     cl, [esp+18h+arg_4]
    mov     [eax+esi+1B85h], cl
    mov     eax, TAdynmemStructPtr

    loc_4532E2:                             ; CODE XREF: sub_453010+2AEj
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_4532B7
    mov     edi, [esp+18h+arg_0]
    jmp     short loc_4532FF
    ; ---------------------------------------------------------------------------

    loc_4532F6:                             ; CODE XREF: sub_453010+27Cj
                                            ; sub_453010+281j ...
    mov     edx, [edi+4]
    push    edx
    call    sub_452CC0

    loc_4532FF:                             ; CODE XREF: sub_453010+A1j
                                            ; sub_453010+192j ...
    mov     al, [esp+18h+arg_4]
    mov     [edi+22h], al
    mov     eax, [esp+18h+var_8]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    sub_453010 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_453320 proc near                    ; CODE XREF: sub_496790+162p
                                            ; sub_497F40+5C2p

    dwDataSize= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+arg_4]
    test    ecx, ecx
    mov     eax, [eax+2A38h]
    push    1                               ; idFrom
    push    eax                             ; idTo
    mov     byte ptr [eax], 6
    jnz     short loc_453346
    mov     ecx, [esp+8+dwDataSize]
    push    ecx                             ; PlayerID
    call    sub_451DF0
    retn    8                               ; idTo
    ; ---------------------------------------------------------------------------

    loc_453346:                             ; CODE XREF: sub_453320+17j
    mov     edx, [esp+8+dwDataSize]
    push    ecx                             ; PlayersToSendTo
    push    edx                             ; dwDataSize
    call    Network_BroadcastMessage
    retn    8
    sub_453320 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_453360(char *)
    sub_453360 proc near                    ; CODE XREF: ChatHandling_1+4Fp

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+2A38h]
    mov     esi, [esp+0Ch+arg_0]
    push    edi
    push    40h                             ; size_t
    mov     byte ptr [ecx], 5
    mov     edx, TAdynmemStructPtr
    push    esi                             ; char *
    mov     eax, [edx+2A38h]
    inc     eax
    push    eax                             ; char *
    call    _strncpy
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    xor     eax, eax
    lea     edx, [ecx+1BD6h]

    loc_45339D:                             ; CODE XREF: sub_453360+50j
    cmp     byte ptr [edx], 1
    jz      loc_4534C2
    inc     eax
    add     edx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_45339D
    or      ebx, 0FFFFFFFFh

    loc_4533B5:                             ; CODE XREF: sub_453360+177j
    cmp     byte ptr [esi], 2Bh
    jz      loc_4534AC
    mov     al, [ecx+2BF0h]
    test    al, al
    jz      loc_4534AC
    cmp     al, 3
    jnz     short loc_45341A
    mov     eax, [esp+10h+arg_0]
    xor     edi, edi
    xor     esi, esi

    loc_4533D8:                             ; CODE XREF: sub_453360+B1j
    mov     dl, [ecx+edi+2BF1h]
    test    dl, dl
    jz      short loc_453404
    mov     edx, [ecx+esi+1B67h]
    test    edx, edx
    jz      short loc_453404
    mov     eax, [ecx+2A38h]
    push    41h                             ; idFrom
    push    eax                             ; idTo
    push    edx                             ; PlayersToSendTo
    push    ebx                             ; dwDataSize
    call    Network_BroadcastMessage
    mov     ecx, TAdynmemStructPtr

    loc_453404:                             ; CODE XREF: sub_453360+81j
                                            ; sub_453360+8Cj
    add     esi, 14Bh
    inc     edi
    cmp     esi, 0CEEh
    jl      short loc_4533D8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45341A:                             ; CODE XREF: sub_453360+6Ej
    xor     edx, edx
    mov     esi, ecx
    mov     dl, [ecx+2A42h]
    xor     edi, edi
    mov     eax, edx
    add     esi, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     ebp, [esi+eax*2+1B63h]
    mov     eax, [esp+10h+arg_0]
    xor     esi, esi

    loc_45343F:                             ; CODE XREF: sub_453360+143j
    mov     edx, [ecx+esi+1B63h]
    test    edx, edx
    jz      short loc_453496
    cmp     byte ptr [ecx+esi+1BD6h], 3
    jnz     short loc_453496
    mov     dl, [ecx+2BF0h]
    cmp     dl, 1
    jnz     short loc_453469
    cmp     byte ptr [edi+ebp+108h], 0
    jnz     short loc_453479

    loc_453469:                             ; CODE XREF: sub_453360+FDj
    cmp     dl, 2
    jnz     short loc_453496
    mov     dl, [edi+ebp+108h]
    test    dl, dl
    jnz     short loc_453496

    loc_453479:                             ; CODE XREF: sub_453360+107j
    mov     edx, [ecx+2A38h]
    mov     eax, [ecx+esi+1B67h]
    push    41h                             ; idFrom
    push    edx                             ; idTo
    push    eax                             ; PlayersToSendTo
    push    ebx                             ; dwDataSize
    call    Network_BroadcastMessage
    mov     ecx, TAdynmemStructPtr

    loc_453496:                             ; CODE XREF: sub_453360+E8j
                                            ; sub_453360+F2j ...
    add     esi, 14Bh
    inc     edi
    cmp     esi, 0CEEh
    jl      short loc_45343F
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4534AC:                             ; CODE XREF: sub_453360+58j
                                            ; sub_453360+66j
    mov     ecx, [ecx+2A38h]
    push    41h                             ; idFrom
    push    ecx                             ; idTo
    push    ebx                             ; PlayerID
    call    sub_451DF0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4534C2:                             ; CODE XREF: sub_453360+40j
    mov     edx, eax
    mov     edi, ecx
    shl     edx, 5
    add     edx, eax
    add     edi, eax
    lea     edx, [edx+edx*4]
    mov     ebx, [edi+edx*2+1B67h]
    jmp     loc_4533B5
    sub_453360 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl HAPINET_GetPacket()
    HAPINET_GetPacket proc near             ; CODE XREF: Network_Process+54p

    DataSize= dword ptr -4

    push    ecx
    mov     eax, TAdynmemStructPtr
    test    [eax+TAdynmemStruct.NetworkLayerEnabled], 1
    jz      loc_453639
    mov     ecx, [eax+TAdynmemStruct.PacketBufferSize]
    mov     [esp+4+DataSize], ecx
    mov     ecx, dword_506DBC
    test    ecx, ecx
    jz      loc_4535A1

    loc_45350B:                             ; CODE XREF: HAPINET_GetPacket+9Ej
    mov     ecx, [eax+TAdynmemStruct.PacketBuffer]
    lea     edx, [esp+4+DataSize]
    push    edx                             ; BufferSize
    add     eax, TAdynmemStruct.HAPINET_Object
    push    ecx                             ; PacketBuffer
    push    eax                             ; TAdynmemStruct
    mov     ecx, offset Global_UnknownFunctionPtr_1
    call    sub_462F30
    test    eax, eax
    jz      short loc_453580
    cmp     eax, 887700BEh
    jz      loc_453639
    cmp     eax, 8877001Eh
    jnz     loc_453639
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+4+DataSize]
    mov     [eax+TAdynmemStruct.PacketBufferSize], edx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+4+DataSize]
    mov     eax, [edx+TAdynmemStruct.PacketBuffer]
    push    ecx                             ; int
    push    offset aPacketDataAgai          ; int
    push    eax                             ; int
    call    Network_ReAllocPacketBuffer
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     [ecx+TAdynmemStruct.PacketBuffer], eax
    mov     eax, TAdynmemStructPtr
    jmp     short loc_45350B
    ; ---------------------------------------------------------------------------

    loc_453580:                             ; CODE XREF: HAPINET_GetPacket+47j
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+4+DataSize]
    push    0
    push    edx
    mov     ecx, [eax+2A38h]
    mov     dl, [ecx]
    push    edx
    call    sub_415EF0
    mov     eax, 1
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4535A1:                             ; CODE XREF: HAPINET_GetPacket+25j
                                            ; HAPINET_GetPacket+127j
    mov     edx, [eax+2A38h]
    lea     ecx, [esp+4+DataSize]
    push    ecx                             ; lpidFrom
    add     eax, 14h
    push    edx                             ; lpidTo
    push    eax                             ; HAPINET_this
    call    HAPINET_ReceivePacket
    test    eax, eax
    jz      short loc_453609
    cmp     eax, 887700BEh
    jz      short loc_453639
    cmp     eax, 8877001Eh
    jnz     short loc_453639
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+4+DataSize]
    mov     [ecx+2A34h], eax
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+4+DataSize]
    mov     ecx, [eax+2A38h]
    push    edx                             ; int
    push    offset aPacketDataAgai          ; int
    push    ecx                             ; int
    call    Network_ReAllocPacketBuffer
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    mov     [edx+2A38h], eax
    mov     eax, TAdynmemStructPtr
    jmp     short loc_4535A1
    ; ---------------------------------------------------------------------------

    loc_453609:                             ; CODE XREF: HAPINET_GetPacket+D8j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+4+DataSize]
    push    0
    push    eax
    mov     edx, [ecx+2A38h]
    mov     al, [edx]
    push    eax
    call    sub_415EF0
    push    0                               ; arg8
    push    0                               ; arg4
    mov     ecx, [esp+0Ch+DataSize]
    push    ecx                             ; DataSize
    call    HAPINET_PacketStatistics
    mov     eax, 1
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_453639:                             ; CODE XREF: HAPINET_GetPacket+Dj
                                            ; HAPINET_GetPacket+4Ej ...
    xor     eax, eax
    pop     ecx
    retn
    HAPINET_GetPacket endp

    ; ---------------------------------------------------------------------------
    align 4

    loc_453640:                             ; DATA XREF: sub_453A50+14Ao
    mov     eax, TAdynmemStructPtr
    sub     esp, 0CCh
    mov     ecx, [eax+531h]
    push    ebx
    push    ebp
    push    esi
    mov     edx, [ecx+4]
    push    edi
    push    offset aOutput                  ; "OUTPUT"
    push    edx
    call    sub_49FF90
    mov     ebx, eax
    call    sub_4B6340
    cmp     dword_512C78, eax
    jge     short loc_45368F
    call    sub_4B6340
    add     eax, 2
    mov     dword_512C78, eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA90

    loc_45368F:                             ; CODE XREF: .text:00453670j
    mov     edi, dword_512C74
    mov     ecx, 280h
    xor     eax, eax
    rep stosd
    movsx   ecx, word ptr [ebx+0C0h]
    mov     esi, TAdynmemStructPtr
    mov     edi, 1
    dec     ecx
    mov     ax, [esi+2A3Eh]
    cmp     ecx, edi
    mov     edx, eax
    jle     short loc_4536D8
    xor     ebx, ebx
    mov     bx, [esi+2A40h]

    loc_4536C7:                             ; CODE XREF: .text:004536D6j
    cmp     edx, ebx
    jz      short loc_4536D8
    dec     edx
    jns     short loc_4536D3
    mov     edx, 1Dh

    loc_4536D3:                             ; CODE XREF: .text:004536CCj
    inc     edi
    cmp     edi, ecx
    jl      short loc_4536C7

    loc_4536D8:                             ; CODE XREF: .text:004536BCj
                                            ; .text:004536C9j
    mov     ebp, dword_512C74
    cmp     edx, eax
    jz      short loc_45373C

    loc_4536E2:                             ; CODE XREF: .text:0045373Aj
    lea     ebx, [edx+edx*8]
    or      ecx, 0FFFFFFFFh
    shl     ebx, 3
    xor     eax, eax
    lea     edi, [esi+ebx+12EFh]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     esi, TAdynmemStructPtr
    or      ecx, 0FFFFFFFFh
    lea     edi, [esi+ebx+12EFh]
    repne scasb
    not     ecx
    dec     ecx
    inc     edx
    cmp     edx, 1Eh
    lea     ebp, [ebp+ecx+1]
    jl      short loc_45372F
    xor     edx, edx

    loc_45372F:                             ; CODE XREF: .text:0045372Bj
    xor     ecx, ecx
    mov     cx, [esi+2A3Eh]
    cmp     edx, ecx
    jnz     short loc_4536E2

    loc_45373C:                             ; CODE XREF: .text:004536E0j
    mov     edi, dword_5061D8
    cmp     edi, 0FFFFFFFFh
    jz      short loc_453795
    xor     dl, dl
    cmp     dl, 0Ah
    mov     [esp+10h], dl
    jz      short loc_45377F

    loc_453752:                             ; CODE XREF: .text:00453793j
    mov     eax, [esp+10h]
    mov     ebx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_45377F
    mov     eax, [eax+1B67h]
    jmp     short loc_453782
    ; ---------------------------------------------------------------------------

    loc_45377F:                             ; CODE XREF: .text:00453750j
                                            ; .text:00453775j
    or      eax, 0FFFFFFFFh

    loc_453782:                             ; CODE XREF: .text:0045377Dj
    cmp     eax, edi
    jz      loc_4538E8
    inc     dl
    cmp     dl, 0Ah
    mov     [esp+10h], dl
    jb      short loc_453752

    loc_453795:                             ; CODE XREF: .text:00453745j
    mov     al, 0Ah

    loc_453797:                             ; CODE XREF: .text:004538EAj
    cmp     al, 0Ah
    jnz     short loc_45379F
    xor     esi, esi
    jmp     short loc_453817
    ; ---------------------------------------------------------------------------

    loc_45379F:                             ; CODE XREF: .text:00453799j
    cmp     edi, 0FFFFFFFFh
    jz      short loc_4537F6
    xor     dl, dl
    cmp     dl, 0Ah
    mov     [esp+10h], dl
    jz      short loc_4537DC

    loc_4537AF:                             ; CODE XREF: .text:004537ECj
    mov     eax, [esp+10h]
    mov     ebx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4537DC
    mov     eax, [eax+1B67h]
    jmp     short loc_4537DF
    ; ---------------------------------------------------------------------------

    loc_4537DC:                             ; CODE XREF: .text:004537ADj
                                            ; .text:004537D2j
    or      eax, 0FFFFFFFFh

    loc_4537DF:                             ; CODE XREF: .text:004537DAj
    cmp     eax, edi
    jz      short loc_4537F0
    inc     dl
    cmp     dl, 0Ah
    mov     [esp+10h], dl
    jb      short loc_4537AF
    jmp     short loc_4537F6
    ; ---------------------------------------------------------------------------

    loc_4537F0:                             ; CODE XREF: .text:004537E1j
    mov     [esp+10h], dl
    jmp     short loc_4537FB
    ; ---------------------------------------------------------------------------

    loc_4537F6:                             ; CODE XREF: .text:004537A2j
                                            ; .text:004537EEj
    mov     byte ptr [esp+10h], 0Ah

    loc_4537FB:                             ; CODE XREF: .text:004537F4j
    mov     eax, [esp+10h]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     esi, eax
    lea     edx, [ecx+ecx*4]
    lea     esi, [esi+edx*2+1B63h]

    loc_453817:                             ; CODE XREF: .text:0045379Dj
    test    esi, esi
    jz      loc_4538DD
    cmp     dword ptr [esi], 0
    jz      loc_4538DD
    cmp     byte ptr [esi+73h], 3
    jnz     loc_4538DD
    call    sub_4B6340
    mov     ecx, eax
    mov     eax, [esi+1Ch]
    sub     ecx, eax
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    mov     ecx, TAdynmemStructPtr
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     esi, edx
    mov     edx, [ecx+37F31h]
    sub     edx, esi
    add     edx, 78h
    push    edx
    push    offset aWillBeRejected          ; "will be rejected in %d seconds"
    call    sub_4C5740
    push    eax
    lea     eax, [esp+1Ch]
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+14h]
    add     edx, 519h
    push    0
    push    ecx
    push    offset aTimetext                ; "TIMETEXT"
    push    edx
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA90
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37F31h]
    add     edx, 78h
    cmp     esi, edx
    jb      short loc_4538DD
    mov     eax, dword_5061D8
    push    6
    push    eax
    call    sub_453010
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A9660

    loc_4538DD:                             ; CODE XREF: .text:00453819j
                                            ; .text:00453822j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn
    ; ---------------------------------------------------------------------------

    loc_4538E8:                             ; CODE XREF: .text:00453784j
    mov     al, dl
    jmp     loc_453797
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4538F0 proc near                    ; DATA XREF: sub_453A50+DFo

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_453933
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    mov     eax, dword_512C74
    test    eax, eax
    jz      short loc_453923
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_453923:                             ; CODE XREF: sub_4538F0+28j
    mov     dword_512C74, 0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_453933:                             ; CODE XREF: sub_4538F0+13j
    push    offset aTalk                    ; "TALK"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_453A14
    push    offset aTalk                    ; char *
    push    edi                             ; int
    call    sub_4A0010
    lea     ebx, [eax+0B6h]
    or      ecx, 0FFFFFFFFh
    mov     edi, ebx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4539BE
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    eax
    push    4
    mov     dl, [ecx+2A42h]
    push    ebx
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*2+1B63h]
    push    ecx
    call    ChatHandling_1
    mov     eax, TAdynmemStructPtr
    mov     edi, offset Data
    or      ecx, 0FFFFFFFFh
    or      byte ptr [eax+2BEEh], 1
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4539BE:                             ; CODE XREF: sub_4538F0+73j
    mov     eax, TAdynmemStructPtr
    push    3
    push    offset aTalk                    ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FDF0
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A7190
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4AB0A0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx                             ; int
    call    sub_49FA90
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_453A14:                             ; CODE XREF: sub_4538F0+50j
    push    offset aReject                  ; "REJECT"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_453A36
    mov     eax, dword_5061D8
    push    6
    push    eax
    call    sub_453010
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_453A36:                             ; CODE XREF: sub_4538F0+131j
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_4538F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_453A50 proc near                    ; CODE XREF: sub_453C20+F1p
                                            ; sub_453C20+100p

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    add     eax, 519h
    push    offset aTimeout_gui             ; char *
    push    eax                             ; int
    call    sub_4AB060
    test    eax, eax
    jz      short loc_453A91
    cmp     [esp+10h+arg_0], 0FFFFFFFFh
    jnz     loc_453C0C
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A9660
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_453A91:                             ; CODE XREF: sub_453A50+1Bj
    mov     edi, [esp+10h+arg_0]
    cmp     edi, 0FFFFFFFFh
    jz      loc_453C0C
    mov     edx, TAdynmemStructPtr
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+10h+arg_0], bl
    jz      short loc_453ADC

    loc_453AAF:                             ; CODE XREF: sub_453A50+A0j
    mov     eax, [esp+10h+arg_0]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_453ADC
    mov     eax, [eax+1B67h]
    jmp     short loc_453ADF
    ; ---------------------------------------------------------------------------

    loc_453ADC:                             ; CODE XREF: sub_453A50+5Dj
                                            ; sub_453A50+82j
    or      eax, 0FFFFFFFFh

    loc_453ADF:                             ; CODE XREF: sub_453A50+8Aj
    cmp     eax, edi
    jz      loc_453C13
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+10h+arg_0], bl
    jb      short loc_453AAF
    mov     byte ptr [esp+10h+arg_0], 0Ah

    loc_453AF7:                             ; CODE XREF: sub_453A50+1C7j
    mov     ebx, [esp+10h+arg_0]
    and     ebx, 0FFh
    cmp     ebx, 0Ah
    jz      loc_453C0C
    push    800h
    add     edx, 519h
    push    offset aTimeout_gui             ; "TIMEOUT.GUI"
    push    edx
    call    sub_4AA8F0
    mov     esi, eax
    push    0A00h
    push    offset aLoungeChatter           ; "LOUNGE CHATTER"
    mov     ebp, [esi+4]
    mov     dword ptr [esi+8], offset sub_4538F0
    mov     dword_5061D8, edi
    call    sub_4D83B0
    add     esp, 8
    mov     edi, eax
    mov     ecx, 1E0h
    xor     eax, eax
    mov     dword_512C74, edi
    push    offset aOutput                  ; char *
    rep stosd
    push    ebp                             ; int
    call    sub_49FF90
    push    0
    mov     edi, eax
    call    sub_4A50B0
    mov     ecx, eax
    movsx   eax, word ptr [edi+19h]
    cdq
    add     ecx, 2
    idiv    ecx
    mov     edx, dword_512C74
    push    eax
    mov     eax, TAdynmemStructPtr
    push    edx
    add     eax, 519h
    push    offset aOutput                  ; "OUTPUT"
    push    eax
    call    sub_4A32A0
    push    3
    push    offset aTalk                    ; char *
    push    ebp                             ; int
    mov     dword ptr [esi+1Ch], offset loc_453640
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A7190
    mov     eax, ebx
    push    0
    shl     eax, 5
    add     eax, ebx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    mov     ecx, eax
    add     eax, 519h
    add     ecx, ebx
    lea     edx, [ecx+edx*2+1B8Eh]
    push    edx
    push    offset aName_0                  ; "NAME"
    push    eax
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0

    loc_453C0C:                             ; CODE XREF: sub_453A50+22j
                                            ; sub_453A50+48j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_453C13:                             ; CODE XREF: sub_453A50+91j
    mov     byte ptr [esp+10h+arg_0], bl
    jmp     loc_453AF7
    sub_453A50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_453C20 proc near                    ; CODE XREF: Network_Process+2224p

    var_4= dword ptr -4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     cl, 1
    push    ebp
    mov     dl, [eax+37F2Fh]
    push    esi
    test    cl, dl
    push    edi
    jnz     loc_453D2B
    test    [eax+38A51h], cl
    jz      short loc_453C52
    call    sub_4B6340
    mov     dword_512C7C, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_453C52:                             ; CODE XREF: sub_453C20+20j
    call    sub_4B6340
    mov     ebp, TAdynmemStructPtr
    mov     [esp+14h+var_4], 0
    or      esi, 0FFFFFFFFh
    mov     edi, 0Ah
    lea     edx, [ebp+1B63h]

    loc_453C73:                             ; CODE XREF: sub_453C20+A1j
    mov     ecx, [edx]
    mov     ebx, dword_512C7C
    test    ecx, ecx
    jz      short loc_453CBA
    cmp     byte ptr [edx+73h], 3
    jnz     short loc_453CBA
    mov     ecx, [edx+1Ch]
    cmp     ebx, ecx
    jbe     short loc_453C8E
    mov     ecx, ebx

    loc_453C8E:                             ; CODE XREF: sub_453C20+6Aj
    mov     ebx, eax
    sub     ebx, ecx
    mov     ecx, [ebp+37F31h]
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [ecx+ecx*4]
    shl     ecx, 1
    cmp     ebx, ecx
    jbe     short loc_453CBA
    test    esi, esi
    jge     short loc_453CAD
    mov     esi, [edx+0Ch]
    jmp     short loc_453CBA
    ; ---------------------------------------------------------------------------

    loc_453CAD:                             ; CODE XREF: sub_453C20+86j
    cmp     esi, [edx+0Ch]
    jz      short loc_453CBA
    mov     [esp+14h+var_4], 1

    loc_453CBA:                             ; CODE XREF: sub_453C20+5Dj
                                            ; sub_453C20+63j ...
    add     edx, 14Bh
    dec     edi
    jnz     short loc_453C73
    mov     edi, dword_512C7C
    xor     esi, esi
    lea     edx, [ebp+1B63h]

    loc_453CD1:                             ; CODE XREF: sub_453C20+EDj
    cmp     dword ptr [edx], 0
    jz      short loc_453D03
    cmp     byte ptr [edx+73h], 3
    jnz     short loc_453D03
    mov     ecx, [edx+1Ch]
    cmp     edi, ecx
    jbe     short loc_453CE5
    mov     ecx, edi

    loc_453CE5:                             ; CODE XREF: sub_453C20+C1j
    mov     ebx, eax
    sub     ebx, ecx
    mov     ecx, [ebp+37F31h]
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [ecx+ecx*4]
    shl     ecx, 1
    cmp     ebx, ecx
    jbe     short loc_453D03
    mov     ecx, [esp+14h+var_4]
    test    ecx, ecx
    jz      short loc_453D1C

    loc_453D03:                             ; CODE XREF: sub_453C20+B4j
                                            ; sub_453C20+BAj ...
    inc     esi
    add     edx, 14Bh
    cmp     esi, 0Ah
    jl      short loc_453CD1
    push    0FFFFFFFFh
    call    sub_453A50
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_453D1C:                             ; CODE XREF: sub_453C20+E1j
    mov     edx, [edx+4]
    push    edx
    call    sub_453A50
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_453D2B:                             ; CODE XREF: sub_453C20+14j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_453C20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl Network_Process()
    Network_Process proc near               ; CODE XREF: .text:0041F80Bp
                                            ; sub_434BF0+2BFp ...

    PacketBuffer= dword ptr -51Ch
    var_518= byte ptr -518h
    var_511= dword ptr -511h
    var_50C= dword ptr -50Ch
    var_508= dword ptr -508h
    idTo= dword ptr -502h
    var_4FB= dword ptr -4FBh
    var_4F4= dword ptr -4F4h
    var_4F0= dword ptr -4F0h
    var_4EC= dword ptr -4ECh
    var_4E8= dword ptr -4E8h
    var_4E4= dword ptr -4E4h
    var_4E0= dword ptr -4E0h
    var_4DC= dword ptr -4DCh
    var_4D8= dword ptr -4D8h
    var_4D4= dword ptr -4D4h
    var_4D0= dword ptr -4D0h
    var_4CC= dword ptr -4CCh
    var_4C8= dword ptr -4C8h
    var_4C4= dword ptr -4C4h
    var_4C0= dword ptr -4C0h
    var_4BC= dword ptr -4BCh
    var_4B8= dword ptr -4B8h
    var_4B4= dword ptr -4B4h
    var_4B0= dword ptr -4B0h
    var_4AC= dword ptr -4ACh
    var_4A8= dword ptr -4A8h
    var_4A4= dword ptr -4A4h
    var_4A0= dword ptr -4A0h
    var_49C= dword ptr -49Ch
    var_498= dword ptr -498h
    var_494= dword ptr -494h
    var_490= dword ptr -490h
    var_48C= dword ptr -48Ch
    var_488= dword ptr -488h
    var_484= dword ptr -484h
    var_480= dword ptr -480h
    var_47C= dword ptr -47Ch
    var_478= dword ptr -478h
    var_474= dword ptr -474h
    var_470= dword ptr -470h
    var_46C= dword ptr -46Ch
    var_468= dword ptr -468h
    var_464= dword ptr -464h
    var_460= dword ptr -460h
    var_45C= dword ptr -45Ch
    var_458= dword ptr -458h
    var_454= dword ptr -454h
    var_450= dword ptr -450h
    var_44C= dword ptr -44Ch
    var_448= dword ptr -448h
    var_444= dword ptr -444h
    var_440= dword ptr -440h
    var_43C= dword ptr -43Ch
    var_438= dword ptr -438h
    var_434= dword ptr -434h
    var_430= dword ptr -430h
    var_42C= dword ptr -42Ch
    var_428= dword ptr -428h
    var_424= dword ptr -424h
    var_420= dword ptr -420h
    var_41C= dword ptr -41Ch
    var_418= dword ptr -418h
    var_414= dword ptr -414h
    var_410= dword ptr -410h
    var_40C= dword ptr -40Ch
    var_408= dword ptr -408h
    var_400= dword ptr -400h
    var_3FC= dword ptr -3FCh
    var_3F8= dword ptr -3F8h
    var_3F4= dword ptr -3F4h
    var_3F0= dword ptr -3F0h
    var_3D0= dword ptr -3D0h
    var_33F= dword ptr -33Fh
    var_314= byte ptr -314h
    var_24C= dword ptr -24Ch
    var_100= byte ptr -100h

    mov     eax, TAdynmemStructPtr
    sub     esp, 51Ch
    test    [eax+TAdynmemStruct.NetworkLayerEnabled], 1
    jnz     short loc_453D5D
    xor     eax, eax
    add     esp, 51Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_453D5D:                             ; CODE XREF: Network_Process+12j
    push    edi
    push    esi
    xor     eax, eax
    push    ebp
    push    ebx
    mov     [esp+52Ch+var_4BC], eax
    mov     ecx, 0Ah

    loc_453D6C:                             ; CODE XREF: Network_Process+43j
    mov     edx, TAdynmemStructPtr
    add     eax, 14Bh                       ; sizeof(playerStuct)
    dec     ecx
    mov     [edx+eax+TAdynmemStruct.field_1A28], 0
    jnz     short loc_453D6C
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+TAdynmemStruct.PacketBuffer]
    mov     [esp+52Ch+PacketBuffer], ecx

    loc_453D94:                             ; CODE XREF: Network_Process+2219j
    call    HAPINET_GetPacket
    test    eax, eax
    mov     [esp+52Ch+var_43C], eax
    jz      loc_455F50                      ; default
    mov     edx, TAdynmemStructPtr
    mov     esi, [edx+TAdynmemStruct.field_4C9]
    cmp     esi, 0FFFFFFFFh
    mov     [esp+52Ch+var_511+1], esi
    jz      short loc_453E14
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_478], bl
    jz      short loc_453DFB

    loc_453DCB:                             ; CODE XREF: Network_Process+D2j
    mov     eax, [esp+52Ch+var_478]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+TAdynmemStruct.Players.PlayerType]
    test    cl, cl
    jz      short loc_453DFB
    mov     eax, [eax+TAdynmemStruct.Players.field_4]
    jmp     short loc_453DFE
    ; ---------------------------------------------------------------------------

    loc_453DFB:                             ; CODE XREF: Network_Process+89j
                                            ; Network_Process+B1j
    or      eax, 0FFFFFFFFh

    loc_453DFE:                             ; CODE XREF: Network_Process+B9j
    cmp     eax, esi
    jz      loc_455F78
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_478], bl
    jb      short loc_453DCB

    loc_453E14:                             ; CODE XREF: Network_Process+7Bj
    mov     [esp+52Ch+var_518], 0Ah

    loc_453E19:                             ; CODE XREF: Network_Process+223Cj
    mov     esi, [edx+TAdynmemStruct.field_4CD]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_453E7F
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_41C], bl
    jz      short loc_453E62

    loc_453E32:                             ; CODE XREF: Network_Process+135j
    mov     eax, [esp+52Ch+var_41C]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+TAdynmemStruct.Players.PlayerType]
    test    cl, cl
    jz      short loc_453E62
    mov     eax, [eax+TAdynmemStruct.Players.field_4]
    jmp     short loc_453E65
    ; ---------------------------------------------------------------------------

    loc_453E62:                             ; CODE XREF: Network_Process+F0j
                                            ; Network_Process+118j
    or      eax, 0FFFFFFFFh

    loc_453E65:                             ; CODE XREF: Network_Process+120j
    cmp     eax, esi
    jz      short loc_453E79
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_41C], bl
    jb      short loc_453E32
    jmp     short loc_453E7F
    ; ---------------------------------------------------------------------------

    loc_453E79:                             ; CODE XREF: Network_Process+127j
    mov     byte ptr [esp+52Ch+var_4F4], bl
    jmp     short loc_453E84
    ; ---------------------------------------------------------------------------

    loc_453E7F:                             ; CODE XREF: Network_Process+E2j
                                            ; Network_Process+137j
    mov     byte ptr [esp+52Ch+var_4F4], 0Ah

    loc_453E84:                             ; CODE XREF: Network_Process+13Dj
    mov     esi, dword ptr [esp+52Ch+var_518]
    and     esi, 0FFh
    mov     eax, esi
    shl     eax, 5
    add     eax, esi
    lea     ecx, [edx+esi]
    lea     eax, [eax+eax*4]
    lea     edi, [ecx+eax*2+TAdynmemStruct.Players]
    mov     eax, [esp+52Ch+var_4F4]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     ebp, [eax+ecx*2]
    mov     ecx, [esp+52Ch+var_4BC]
    mov     eax, [esp+52Ch+var_511+1]
    inc     ecx
    test    eax, eax
    lea     ebx, [edx+ebp+TAdynmemStruct.Players]
    mov     [esp+52Ch+var_4BC], ecx
    jnz     loc_45473F
    cmp     [ebx+PlayerStruct.PlayerActive], 0
    jz      loc_455F50                      ; default
    mov     bl, [ebx+PlayerStruct.PlayerType]
    cmp     bl, Player_LocalHuman
    jz      short loc_453EF7
    cmp     bl, Player_AI
    jnz     loc_455F50                      ; default
    cmp     bl, 1
    jnz     loc_455F50                      ; default

    loc_453EF7:                             ; CODE XREF: Network_Process+1A3j
    mov     ecx, [esp+52Ch+PacketBuffer]
    mov     eax, [ecx]
    cmp     eax, 102h
    ja      loc_454611
    jz      loc_454425
    sub     eax, 3
    jz      loc_45413F
    sub     eax, 2
    jnz     loc_455F50                      ; default
    mov     eax, ecx
    cmp     dword ptr [eax+4], 1
    jnz     loc_455F50                      ; default
    mov     ecx, eax
    mov     esi, [ecx+8]
    cmp     esi, 0FFFFFFFFh
    jnz     short loc_453F3A
    mov     bl, 0Ah
    jmp     short loc_453F6A
    ; ---------------------------------------------------------------------------

    loc_453F3A:                             ; CODE XREF: Network_Process+1F4j
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_4A8], bl

    loc_453F43:                             ; CODE XREF: Network_Process+220j
    mov     edx, [esp+52Ch+var_4A8]
    push    edx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_453F64
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_4A8], bl
    jb      short loc_453F43
    mov     bl, 0Ah

    loc_453F64:                             ; CODE XREF: Network_Process+212j
    mov     edx, TAdynmemStructPtr

    loc_453F6A:                             ; CODE XREF: Network_Process+1F8j
    cmp     bl, 0Ah
    jnz     short loc_453F73
    xor     esi, esi
    jmp     short loc_453F99
    ; ---------------------------------------------------------------------------

    loc_453F73:                             ; CODE XREF: Network_Process+22Dj
    push    esi                             ; int
    call    sub_44FE40
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    lea     eax, [eax+eax*4]
    lea     esi, [esi+eax*2+TAdynmemStruct.Players]

    loc_453F99:                             ; CODE XREF: Network_Process+231j
    test    esi, esi
    jz      loc_455F50                      ; default
    cmp     dword ptr [esi], 0
    jz      loc_455F50                      ; default
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_453FBD
    cmp     al, 2
    jz      short loc_453FBD
    cmp     al, 3
    jnz     loc_455F50                      ; default

    loc_453FBD:                             ; CODE XREF: Network_Process+26Fj
                                            ; Network_Process+273j
    cmp     byte ptr [esi+146h], 0Ah
    jz      loc_455F50                      ; default
    test    byte ptr [edx+2A44h], 4
    jnz     short loc_454045
    mov     ecx, [esi+27h]
    test    byte ptr [ecx+97h], 1
    jz      short loc_454045
    cmp     al, 3
    jnz     short loc_454045
    mov     edx, [esi+4]
    push    1
    push    edx
    call    sub_453010
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    0Ah
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B67h]
    push    ecx
    call    sub_453010
    push    0
    mov     ecx, esi
    call    sub_463C60
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    0
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    add     ecx, edx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*2+1B63h]
    jmp     short loc_454054
    ; ---------------------------------------------------------------------------

    loc_454045:                             ; CODE XREF: Network_Process+291j
                                            ; Network_Process+29Dj ...
    mov     ecx, [esi+4]
    push    1
    push    ecx
    call    sub_453010
    push    0
    mov     ecx, esi

    loc_454054:                             ; CODE XREF: Network_Process+303j
    call    sub_463C60
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    or      byte ptr [eax+2BEEh], 1
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B8Ah]
    test    byte ptr [ecx+97h], 1
    jz      loc_455F50                      ; default
    lea     edx, [esp+52Ch+var_400]
    lea     eax, [esp+52Ch+var_3FC]
    push    edx
    lea     ecx, [esp+530h+var_3F4]
    push    eax
    lea     edx, [esp+534h+var_3F8]
    push    ecx
    lea     eax, [esp+538h+var_3F0]
    push    edx
    push    eax
    call    sub_451090
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B8Ah]
    mov     al, [ecx+9Bh]
    shr     al, 4
    test    al, 1
    jz      short loc_454104
    mov     eax, [edx+475h]
    or      al, 20h
    mov     [edx+475h], eax
    mov     edx, TAdynmemStructPtr

    loc_454104:                             ; CODE XREF: Network_Process+3AEj
    mov     ecx, [esp+52Ch+var_400]
    mov     eax, [esp+52Ch+var_3FC]
    push    ecx
    mov     ecx, [esp+530h+var_3F4]
    push    eax
    mov     eax, [esp+534h+var_3F8]
    push    ecx
    push    eax
    lea     ecx, [esp+53Ch+var_3F0]
    push    offset Data
    add     edx, 14h
    push    ecx
    push    edx
    call    sub_4C9890
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45413F:                             ; CODE XREF: Network_Process+1D1j
    mov     edx, [ecx+8]
    push    edx
    call    sub_450A10
    test    eax, eax
    jz      loc_455F50                      ; default
    mov     edi, [esp+52Ch+PacketBuffer]
    mov     esi, [edi+8]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454184
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_428], bl

    loc_454165:                             ; CODE XREF: Network_Process+442j
    mov     eax, [esp+52Ch+var_428]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454186
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_428], bl
    jb      short loc_454165

    loc_454184:                             ; CODE XREF: Network_Process+41Aj
    mov     bl, 0Ah

    loc_454186:                             ; CODE XREF: Network_Process+434j
    cmp     bl, 0Ah
    jz      short loc_454191
    push    esi                             ; int
    call    sub_44FE40

    loc_454191:                             ; CODE XREF: Network_Process+449j
    mov     edi, [edi+8]
    mov     esi, TAdynmemStructPtr
    cmp     edi, 0FFFFFFFFh
    jz      short loc_4541FA
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_4A0], dl
    jz      short loc_4541DD

    loc_4541AD:                             ; CODE XREF: Network_Process+4B0j
    mov     eax, [esp+52Ch+var_4A0]
    mov     ebx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+TAdynmemStruct.Players.PlayerType]
    test    cl, cl
    jz      short loc_4541DD
    mov     eax, [eax+TAdynmemStruct.Players.field_4]
    jmp     short loc_4541E0
    ; ---------------------------------------------------------------------------

    loc_4541DD:                             ; CODE XREF: Network_Process+46Bj
                                            ; Network_Process+493j
    or      eax, 0FFFFFFFFh

    loc_4541E0:                             ; CODE XREF: Network_Process+49Bj
    cmp     eax, edi
    jz      short loc_4541F4
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_4A0], dl
    jb      short loc_4541AD
    jmp     short loc_4541FA
    ; ---------------------------------------------------------------------------

    loc_4541F4:                             ; CODE XREF: Network_Process+4A2j
    mov     byte ptr [esp+52Ch+var_4B4], dl
    jmp     short loc_4541FF
    ; ---------------------------------------------------------------------------

    loc_4541FA:                             ; CODE XREF: Network_Process+45Dj
                                            ; Network_Process+4B2j
    mov     byte ptr [esp+52Ch+var_4B4], 0Ah

    loc_4541FF:                             ; CODE XREF: Network_Process+4B8j
    mov     ebx, [esp+52Ch+var_4B4]
    and     ebx, 0FFh
    xor     dl, dl
    mov     byte ptr [esp+52Ch+var_440], dl

    loc_454212:                             ; CODE XREF: Network_Process+515j
    mov     eax, [esp+52Ch+var_440]
    mov     edi, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_454249
    mov     eax, [eax+1B8Ah]
    test    byte ptr [eax+97h], 1
    jnz     short loc_454259

    loc_454249:                             ; CODE XREF: Network_Process+4F8j
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_440], dl
    jb      short loc_454212
    jmp     short loc_454262
    ; ---------------------------------------------------------------------------

    loc_454259:                             ; CODE XREF: Network_Process+507j
    mov     byte ptr [esp+52Ch+var_498], dl
    jmp     short loc_45426A
    ; ---------------------------------------------------------------------------

    loc_454262:                             ; CODE XREF: Network_Process+517j
    mov     byte ptr [esp+52Ch+var_498], 0Ah

    loc_45426A:                             ; CODE XREF: Network_Process+520j
    mov     eax, [esp+52Ch+var_498]
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [esi+ecx*2+1B63h]
    call    sub_456030
    test    eax, eax
    jz      loc_455F50                      ; default
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     esi, eax
    mov     ebp, [esp+52Ch+PacketBuffer]
    mov     dl, [eax+2A42h]
    mov     ecx, edx
    add     esi, edx
    shl     ecx, 5
    add     ecx, edx
    mov     edi, [ebp+10h]
    lea     ecx, [ecx+ecx*4]
    mov     esi, [esi+ecx*2+1B8Ah]
    mov     dx, [esi+9Bh]
    shr     edx, 0Fh
    test    dl, 1
    jz      short loc_454315
    cmp     bl, 0Ah
    jz      short loc_454305
    and     ebx, 0FFh
    mov     ecx, ebx
    add     eax, ebx
    shl     ecx, 5
    add     ecx, ebx
    lea     ecx, [ecx+ecx*4]
    lea     eax, [eax+ecx*2]
    mov     cl, [eax+1BD6h]
    test    cl, cl
    jz      short loc_454305
    mov     eax, [eax+1B67h]
    push    3
    push    eax
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454305:                             ; CODE XREF: Network_Process+591j
                                            ; Network_Process+5B0j
    or      eax, 0FFFFFFFFh
    push    3
    push    eax
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454315:                             ; CODE XREF: Network_Process+58Cj
    cmp     dword ptr [ebp+14h], 15h
    jz      short loc_45435B
    cmp     bl, 0Ah
    jz      loc_454415
    and     ebx, 0FFh
    mov     ecx, ebx
    add     eax, ebx
    shl     ecx, 5
    add     ecx, ebx
    lea     edx, [ecx+ecx*4]
    mov     cl, [eax+edx*2+1BD6h]
    test    cl, cl
    lea     eax, [eax+edx*2]
    jz      loc_454415
    mov     eax, [eax+1B67h]
    push    8
    push    eax
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45435B:                             ; CODE XREF: Network_Process+5D9j
    cmp     word ptr [edi+11h], 0
    jnz     short loc_4543DD
    cmp     word ptr [edi+13h], 50h
    jnz     short loc_4543DD
    test    byte ptr [esi+9Dh], 1
    jz      loc_455F50                      ; default
    test    edi, edi
    jz      short loc_454396
    add     eax, 2BE3h
    push    edi                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_455F50                      ; default
    mov     eax, TAdynmemStructPtr

    loc_454396:                             ; CODE XREF: Network_Process+638j
    cmp     bl, 0Ah
    jz      short loc_4543CD
    and     ebx, 0FFh
    mov     ecx, ebx
    add     eax, ebx
    shl     ecx, 5
    add     ecx, ebx
    lea     ecx, [ecx+ecx*4]
    lea     eax, [eax+ecx*2]
    mov     cl, [eax+1BD6h]
    test    cl, cl
    jz      short loc_4543CD
    mov     eax, [eax+1B67h]
    push    4
    push    eax
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4543CD:                             ; CODE XREF: Network_Process+659j
                                            ; Network_Process+678j
    or      eax, 0FFFFFFFFh
    push    4
    push    eax
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4543DD:                             ; CODE XREF: Network_Process+620j
                                            ; Network_Process+627j
    cmp     bl, 0Ah
    jz      short loc_454415
    and     ebx, 0FFh
    mov     ecx, ebx
    add     eax, ebx
    shl     ecx, 5
    add     ecx, ebx
    lea     edx, [ecx+ecx*4]
    mov     cl, [eax+edx*2+1BD6h]
    test    cl, cl
    lea     eax, [eax+edx*2]
    jz      short loc_454415
    mov     eax, [eax+1B67h]
    push    8
    push    eax
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454415:                             ; CODE XREF: Network_Process+5DEj
                                            ; Network_Process+602j ...
    or      eax, 0FFFFFFFFh
    push    8
    push    eax
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454425:                             ; CODE XREF: Network_Process+1C8j
    cmp     dword ptr [ecx+4], 1
    jnz     loc_455F50                      ; default
    lea     ecx, [esp+52Ch+var_24C]
    call    sub_463BE0
    mov     eax, [esp+52Ch+PacketBuffer]
    mov     esi, [eax+8]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_45446F
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_420], bl

    loc_454450:                             ; CODE XREF: Network_Process+72Dj
    mov     ecx, [esp+52Ch+var_420]
    push    ecx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454471
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_420], bl
    jb      short loc_454450

    loc_45446F:                             ; CODE XREF: Network_Process+705j
    mov     bl, 0Ah

    loc_454471:                             ; CODE XREF: Network_Process+71Fj
    cmp     bl, 0Ah
    jnz     short loc_454484
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     [esp+52Ch+var_511+1], eax
    jmp     short loc_4544AE
    ; ---------------------------------------------------------------------------

    loc_454484:                             ; CODE XREF: Network_Process+734j
    push    esi                             ; int
    call    sub_44FE40
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    lea     eax, [eax+eax*4]
    lea     eax, [esi+eax*2+1B63h]
    mov     [esp+52Ch+var_511+1], eax

    loc_4544AE:                             ; CODE XREF: Network_Process+742j
    test    eax, eax
    jz      loc_454600
    mov     ecx, [esp+52Ch+PacketBuffer]
    mov     esi, [ecx+8]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_45451D
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_490], bl
    jz      short loc_454500

    loc_4544D0:                             ; CODE XREF: Network_Process+7D3j
    mov     eax, [esp+52Ch+var_490]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_454500
    mov     eax, [eax+1B67h]
    jmp     short loc_454503
    ; ---------------------------------------------------------------------------

    loc_454500:                             ; CODE XREF: Network_Process+78Ej
                                            ; Network_Process+7B6j
    or      eax, 0FFFFFFFFh

    loc_454503:                             ; CODE XREF: Network_Process+7BEj
    cmp     eax, esi
    jz      short loc_454517
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_490], bl
    jb      short loc_4544D0
    jmp     short loc_45451D
    ; ---------------------------------------------------------------------------

    loc_454517:                             ; CODE XREF: Network_Process+7C5j
    mov     byte ptr [esp+52Ch+var_4E0], bl
    jmp     short loc_454522
    ; ---------------------------------------------------------------------------

    loc_45451D:                             ; CODE XREF: Network_Process+780j
                                            ; Network_Process+7D5j
    mov     byte ptr [esp+52Ch+var_4E0], 0Ah

    loc_454522:                             ; CODE XREF: Network_Process+7DBj
    mov     ecx, [esp+52Ch+var_4E0]
    and     ecx, 0FFh
    cmp     ecx, 0Ah
    jnz     short loc_454542
    lea     ecx, [esp+52Ch+var_24C]
    call    sub_463C40
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454542:                             ; CODE XREF: Network_Process+7EFj
    mov     eax, [esp+52Ch+PacketBuffer]
    add     edx, ecx
    mov     ebp, [eax+0Ch]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    mov     ecx, 2Eh
    mov     esi, ebp
    xor     bl, bl
    lea     eax, [eax+eax*4]
    mov     byte ptr [esp+52Ch+var_438], bl
    mov     edi, [edx+eax*2+1B8Ah]
    rep movsd
    movsb
    mov     edx, TAdynmemStructPtr

    loc_454575:                             ; CODE XREF: Network_Process+878j
    mov     eax, [esp+52Ch+var_438]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4545AC
    mov     eax, [eax+1B8Ah]
    test    byte ptr [eax+97h], 1
    jnz     short loc_4545BC

    loc_4545AC:                             ; CODE XREF: Network_Process+85Bj
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_438], bl
    jb      short loc_454575
    mov     bl, 0Ah

    loc_4545BC:                             ; CODE XREF: Network_Process+86Aj
    mov     cl, [edx+2A42h]
    cmp     bl, cl
    jnz     short loc_454600
    and     ecx, 0FFh
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [edx+eax*2+1B8Ah]
    test    byte ptr [ecx+9Bh], 80h
    jnz     short loc_454600
    test    byte ptr [ebp+9Bh], 40h
    jz      short loc_454600
    mov     edx, [esp+52Ch+var_511+1]
    push    9
    mov     eax, [edx+4]
    push    eax
    call    sub_453010

    loc_454600:                             ; CODE XREF: Network_Process+770j
                                            ; Network_Process+884j ...
    lea     ecx, [esp+52Ch+var_24C]
    call    sub_463C40
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454611:                             ; CODE XREF: Network_Process+1C2j
    sub     eax, 103h
    jz      loc_45469E
    dec     eax
    jnz     loc_455F50                      ; default
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_488], bl

    loc_45462C:                             ; CODE XREF: Network_Process+92Fj
    mov     eax, [esp+52Ch+var_488]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_454663
    mov     eax, [eax+1B8Ah]
    test    byte ptr [eax+97h], 1
    jnz     short loc_454673

    loc_454663:                             ; CODE XREF: Network_Process+912j
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_488], bl
    jb      short loc_45462C
    jmp     short loc_454677
    ; ---------------------------------------------------------------------------

    loc_454673:                             ; CODE XREF: Network_Process+921j
    mov     al, bl
    jmp     short loc_454679
    ; ---------------------------------------------------------------------------

    loc_454677:                             ; CODE XREF: Network_Process+931j
    mov     al, 0Ah

    loc_454679:                             ; CODE XREF: Network_Process+935j
    cmp     al, [edx+2A42h]
    jz      loc_455F50                      ; default
    mov     ecx, [esp+52Ch+PacketBuffer]
    lea     edi, [edx+471h]
    lea     esi, [ecx+4]
    mov     ecx, 14h
    rep movsd
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45469E:                             ; CODE XREF: Network_Process+8D6j
    cmp     dword ptr [ecx+4], 1
    jnz     loc_455F50                      ; default
    mov     edx, [esp+52Ch+PacketBuffer]
    mov     esi, [edx+8]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4546DC
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_418], bl

    loc_4546BD:                             ; CODE XREF: Network_Process+99Aj
    mov     eax, [esp+52Ch+var_418]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_4546DE
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_418], bl
    jb      short loc_4546BD

    loc_4546DC:                             ; CODE XREF: Network_Process+972j
    mov     bl, 0Ah

    loc_4546DE:                             ; CODE XREF: Network_Process+98Cj
    cmp     bl, 0Ah
    jnz     short loc_4546E7
    xor     esi, esi
    jmp     short loc_45470A
    ; ---------------------------------------------------------------------------

    loc_4546E7:                             ; CODE XREF: Network_Process+9A1j
    push    esi                             ; int
    call    sub_44FE40
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    lea     esi, [eax+edx*2+1B63h]

    loc_45470A:                             ; CODE XREF: Network_Process+9A5j
    test    esi, esi
    jz      loc_455F50                      ; default
    mov     edi, [esp+52Ch+PacketBuffer]
    push    1Eh                             ; size_t
    lea     edx, [esi+2Bh]
    mov     ecx, [edi+18h]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    mov     eax, [edi+14h]
    add     esp, 0Ch
    add     esi, 49h
    push    1Eh                             ; size_t
    push    eax                             ; char *
    push    esi                             ; char *
    call    _strncpy
    add     esp, 0Ch
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45473F:                             ; CODE XREF: Network_Process+18Ej
    mov     edx, [edx+391F1h]
    cmp     edx, 5
    jnz     short loc_454762
    mov     ecx, [esp+52Ch+PacketBuffer]
    mov     al, [ecx]
    mov     ecx, eax
    and     ecx, 0FFh
    test    byte_512BC0[ecx*4], 2
    jnz     short loc_4547AD

    loc_454762:                             ; CODE XREF: Network_Process+A08j
    cmp     edx, 6
    jnz     short loc_45477F
    mov     eax, [esp+52Ch+PacketBuffer]
    mov     al, [eax]
    mov     ecx, eax
    and     ecx, 0FFh
    test    byte_512BC0[ecx*4], 4
    jnz     short loc_4547AD

    loc_45477F:                             ; CODE XREF: Network_Process+A25j
    cmp     edx, 5
    jz      loc_455F50                      ; default
    cmp     edx, 6
    jz      loc_455F50                      ; default
    mov     edx, [esp+52Ch+PacketBuffer]
    mov     al, [edx]
    mov     ecx, eax
    and     ecx, 0FFh
    test    byte_512BC0[ecx*4], 1
    jz      loc_455F50                      ; default

    loc_4547AD:                             ; CODE XREF: Network_Process+A20j
                                            ; Network_Process+A3Dj
    mov     edx, [edi]
    test    edx, edx
    jz      short loc_4547E4
    mov     cl, [edi+73h]
    cmp     cl, 1
    jz      loc_455F50                      ; default
    cmp     cl, 2
    jz      loc_455F50                      ; default
    test    edx, edx
    jz      short loc_4547E4
    cmp     cl, 1
    jz      short loc_4547DB
    cmp     cl, 2
    jz      short loc_4547DB
    cmp     cl, 3
    jnz     short loc_4547E4

    loc_4547DB:                             ; CODE XREF: Network_Process+A8Fj
                                            ; Network_Process+A94j
    cmp     byte ptr [edi+146h], 0Ah
    jnz     short loc_4547F5

    loc_4547E4:                             ; CODE XREF: Network_Process+A71j
                                            ; Network_Process+A8Aj ...
    mov     edx, [esp+52Ch+var_511+1]
    push    6
    push    edx
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4547F5:                             ; CODE XREF: Network_Process+AA2j
    cmp     al, 1
    ja      short loc_45480E
    cmp     al, 2Dh
    jb      short loc_45480E
    mov     eax, [esp+52Ch+var_511+1]
    push    6
    push    eax
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45480E:                             ; CODE XREF: Network_Process+AB7j
                                            ; Network_Process+ABBj
    cmp     cl, 1
    jz      short loc_454821
    cmp     cl, 2
    jz      short loc_454821
    cmp     cl, 3
    jnz     loc_455F50                      ; default

    loc_454821:                             ; CODE XREF: Network_Process+AD1j
                                            ; Network_Process+AD6j
    cmp     dword ptr [ebx], 0
    jz      loc_455F50                      ; default
    mov     al, [ebx+73h]
    cmp     al, 1
    jz      short loc_45483D
    cmp     al, 2
    jz      short loc_45483D
    cmp     al, 3
    jnz     loc_455F50                      ; default

    loc_45483D:                             ; CODE XREF: Network_Process+AEFj
                                            ; Network_Process+AF3j
    cmp     byte ptr [ebx+146h], 0Ah
    jz      loc_455F50                      ; default
    call    sub_4B6340
    mov     edx, [edi+10h]
    mov     ecx, [esp+52Ch+PacketBuffer]
    mov     [edi+1Ch], eax
    inc     edx
    xor     eax, eax
    mov     [edi+10h], edx
    mov     al, [ecx]
    add     eax, 0FFFFFFFEh                 ; switch 43 cases
    cmp     eax, 2Ah
    ja      loc_455F50                      ; default
    jmp     ds:off_455F84[eax*4]            ; switch jump

    loc_454874:                             ; DATA XREF: .text:00455F84o
    mov     edx, [esp+52Ch+PacketBuffer]    ; case 0x20
    mov     esi, [edx+91h]
    mov     edx, TAdynmemStructPtr
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4548E4
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_480], bl
    jz      short loc_4548C7

    loc_454897:                             ; CODE XREF: Network_Process+B9Aj
    mov     eax, [esp+52Ch+var_480]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4548C7
    mov     eax, [eax+1B67h]
    jmp     short loc_4548CA
    ; ---------------------------------------------------------------------------

    loc_4548C7:                             ; CODE XREF: Network_Process+B55j
                                            ; Network_Process+B7Dj
    or      eax, 0FFFFFFFFh

    loc_4548CA:                             ; CODE XREF: Network_Process+B85j
    cmp     eax, esi
    jz      short loc_4548DE
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_480], bl
    jb      short loc_454897
    jmp     short loc_4548E4
    ; ---------------------------------------------------------------------------

    loc_4548DE:                             ; CODE XREF: Network_Process+B8Cj
    mov     byte ptr [esp+52Ch+var_4E8], bl
    jmp     short loc_4548E9
    ; ---------------------------------------------------------------------------

    loc_4548E4:                             ; CODE XREF: Network_Process+B47j
                                            ; Network_Process+B9Cj
    mov     byte ptr [esp+52Ch+var_4E8], 0Ah

    loc_4548E9:                             ; CODE XREF: Network_Process+BA2j
    mov     ecx, [esp+52Ch+var_4E8]
    and     ecx, 0FFh
    cmp     ecx, 0Ah
    jz      loc_455F50                      ; default
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [edx+eax*2+1B63h]
    lea     eax, [edx+eax*2]
    test    ecx, ecx
    jz      loc_455F50                      ; default
    cmp     byte ptr [eax+1BD6h], 3
    jnz     loc_455F50                      ; default
    mov     ecx, [esp+52Ch+PacketBuffer]
    mov     edi, [eax+1B8Ah]
    lea     esi, [ecx+1]
    mov     ecx, 2Eh
    rep movsd
    movsb
    call    sub_450980
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454946:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, TAdynmemStructPtr          ; case 0x17
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B8Ah]
    test    byte ptr [ecx+97h], 1
    jz      loc_455F50                      ; default
    mov     esi, [esp+52Ch+PacketBuffer]
    mov     ecx, [edx+4C9h]
    movsx   eax, byte ptr [esi+1]
    push    eax
    push    ecx
    call    sub_452570
    test    eax, eax
    jnz     short loc_4549DF
    mov     edx, TAdynmemStructPtr
    lea     ecx, [edx+1BD6h]

    loc_45499B:                             ; CODE XREF: Network_Process+C6Aj
    cmp     byte ptr [ecx], 1
    jz      short loc_4549AE
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_45499B
    jmp     short loc_4549C5
    ; ---------------------------------------------------------------------------

    loc_4549AE:                             ; CODE XREF: Network_Process+C5Ej
    mov     ecx, eax
    mov     edi, edx
    shl     ecx, 5
    add     ecx, eax
    add     edi, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edi+ecx*2+1B67h]
    jmp     short loc_4549C8
    ; ---------------------------------------------------------------------------

    loc_4549C5:                             ; CODE XREF: Network_Process+C6Cj
    or      eax, 0FFFFFFFFh

    loc_4549C8:                             ; CODE XREF: Network_Process+C83j
    movsx   ecx, byte ptr [esi+1]
    mov     edx, [edx+4C9h]
    push    ecx
    push    edx
    push    eax
    call    sub_4523E0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4549DF:                             ; CODE XREF: Network_Process+C4Dj
    mov     al, [esi+1]
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [esp+52Ch+idTo+1], al
    mov     byte ptr [esp+52Ch+idTo], 18h
    xor     eax, eax
    lea     ecx, [edx+1BD6h]

    loc_4549F9:                             ; CODE XREF: Network_Process+CC8j
    cmp     byte ptr [ecx], 1
    jz      short loc_454A0C
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_4549F9
    jmp     short loc_454A23
    ; ---------------------------------------------------------------------------

    loc_454A0C:                             ; CODE XREF: Network_Process+CBCj
    mov     ecx, eax
    mov     esi, edx
    shl     ecx, 5
    add     ecx, eax
    add     esi, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, [esi+ecx*2+1B67h]
    jmp     short loc_454A26
    ; ---------------------------------------------------------------------------

    loc_454A23:                             ; CODE XREF: Network_Process+CCAj
    or      eax, 0FFFFFFFFh

    loc_454A26:                             ; CODE XREF: Network_Process+CE1j
    mov     edx, [edx+4C9h]
    lea     ecx, [esp+52Ch+idTo]
    push    2                               ; idFrom
    push    ecx                             ; idTo
    push    edx                             ; PlayersToSendTo
    push    eax                             ; dwDataSize
    call    Network_BroadcastMessage
    mov     eax, dword_506DBC
    test    eax, eax
    jz      loc_455F50                      ; default
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454A58:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, TAdynmemStructPtr          ; case 0x18
    mov     edx, [esp+52Ch+PacketBuffer]
    mov     ecx, [eax+ebp+1B8Ah]
    mov     al, [edx+1]
    mov     dl, byte ptr [esp+52Ch+var_4F4]
    mov     [ecx+96h], al
    mov     ecx, TAdynmemStructPtr
    cmp     dl, [ecx+2A42h]
    jnz     loc_454DFD
    test    byte ptr [ecx+2A44h], 1
    jz      loc_454DFD
    xor     ebp, ebp

    loc_454A96:                             ; CODE XREF: Network_Process+DC5j
    mov     eax, [ecx+ebp+1B63h]
    lea     ebx, [ecx+ebp+1B63h]
    test    eax, eax
    jz      short loc_454AF9
    mov     al, [ebx+73h]
    cmp     al, 1
    jz      short loc_454AB3
    cmp     al, 2
    jnz     short loc_454AF9

    loc_454AB3:                             ; CODE XREF: Network_Process+D6Dj
    mov     esi, [ebx+27h]
    mov     ecx, 2Eh
    lea     edi, [esp+52Ch+var_3D0+1]
    push    0BAh                            ; idFrom
    rep movsd
    movsb
    mov     eax, [ebx+4]
    mov     byte ptr [esp+530h+var_3D0], 20h
    mov     [esp+530h+var_33F], eax
    mov     edx, [ebx+4]
    lea     ecx, [esp+530h+var_3D0]
    push    ecx                             ; idTo
    push    edx                             ; PlayerID
    call    sub_451DF0
    push    ebx
    call    sub_452BD0
    mov     ecx, TAdynmemStructPtr

    loc_454AF9:                             ; CODE XREF: Network_Process+D66j
                                            ; Network_Process+D71j
    add     ebp, 14Bh
    cmp     ebp, 0CEEh
    jl      short loc_454A96
    call    sub_450530
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0
    mov     ecx, TAdynmemStructPtr
    or      byte ptr [ecx+2BEEh], 1
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454B2A:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0x2
    push    eax
    call    sub_4565A0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454B39:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     ecx, [esp+52Ch+PacketBuffer]    ; case 0x26
    mov     edx, TAdynmemStructPtr
    lea     esi, [ecx+1]
    lea     edi, [edx+2C28h]
    mov     ecx, 0Ah
    rep movsd
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2BEEh], 1
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454B64:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0x23
    mov     esi, [eax+1]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454B98
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_410], bl

    loc_454B79:                             ; CODE XREF: Network_Process+E56j
    mov     ecx, [esp+52Ch+var_410]
    push    ecx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454B9A
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_410], bl
    jb      short loc_454B79

    loc_454B98:                             ; CODE XREF: Network_Process+E2Ej
    mov     bl, 0Ah

    loc_454B9A:                             ; CODE XREF: Network_Process+E48j
    cmp     bl, 0Ah
    jnz     short loc_454BA3
    xor     edi, edi
    jmp     short loc_454BF6
    ; ---------------------------------------------------------------------------

    loc_454BA3:                             ; CODE XREF: Network_Process+E5Dj
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454BCF
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_4B0], bl

    loc_454BAE:                             ; CODE XREF: Network_Process+E85j
    mov     edx, [esp+52Ch+var_4B0]
    push    edx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454BC9
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_4B0], bl
    jb      short loc_454BAE
    jmp     short loc_454BCF
    ; ---------------------------------------------------------------------------

    loc_454BC9:                             ; CODE XREF: Network_Process+E7Aj
    mov     byte ptr [esp+52Ch+var_4C0], bl
    jmp     short loc_454BD4
    ; ---------------------------------------------------------------------------

    loc_454BCF:                             ; CODE XREF: Network_Process+E66j
                                            ; Network_Process+E87j
    mov     byte ptr [esp+52Ch+var_4C0], 0Ah

    loc_454BD4:                             ; CODE XREF: Network_Process+E8Dj
    mov     eax, [esp+52Ch+var_4C0]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    lea     edi, [edx+ecx*2+1B63h]

    loc_454BF6:                             ; CODE XREF: Network_Process+E61j
    mov     eax, [esp+52Ch+PacketBuffer]
    mov     esi, [eax+5]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454C2A
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_42C], bl

    loc_454C0B:                             ; CODE XREF: Network_Process+EE8j
    mov     ecx, [esp+52Ch+var_42C]
    push    ecx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454C2C
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_42C], bl
    jb      short loc_454C0B

    loc_454C2A:                             ; CODE XREF: Network_Process+EC0j
    mov     bl, 0Ah

    loc_454C2C:                             ; CODE XREF: Network_Process+EDAj
    cmp     bl, 0Ah
    jnz     short loc_454C35
    xor     esi, esi
    jmp     short loc_454C91
    ; ---------------------------------------------------------------------------

    loc_454C35:                             ; CODE XREF: Network_Process+EEFj
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454C6A
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_470], bl

    loc_454C43:                             ; CODE XREF: Network_Process+F20j
    mov     edx, [esp+52Ch+var_470]
    push    edx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454C64
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_470], bl
    jb      short loc_454C43
    jmp     short loc_454C6A
    ; ---------------------------------------------------------------------------

    loc_454C64:                             ; CODE XREF: Network_Process+F12j
    mov     byte ptr [esp+52Ch+var_4F0], bl
    jmp     short loc_454C6F
    ; ---------------------------------------------------------------------------

    loc_454C6A:                             ; CODE XREF: Network_Process+EF8j
                                            ; Network_Process+F22j
    mov     byte ptr [esp+52Ch+var_4F0], 0Ah

    loc_454C6F:                             ; CODE XREF: Network_Process+F28j
    mov     eax, [esp+52Ch+var_4F0]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    lea     esi, [edx+ecx*2+1B63h]

    loc_454C91:                             ; CODE XREF: Network_Process+EF3j
    test    edi, edi
    jz      loc_455F50                      ; default
    test    esi, esi
    jz      loc_455F50                      ; default
    mov     eax, [esp+52Ch+PacketBuffer]
    mov     cl, [eax+9]
    test    cl, cl
    jz      short loc_454CB8
    push    0                               ; int
    push    offset aAlly                    ; char *
    call    sub_47F1A0

    loc_454CB8:                             ; CODE XREF: Network_Process+F6Aj
    cmp     dword ptr [esi], 0
    jz      short loc_454CFD
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_454CC8
    cmp     al, 2
    jnz     short loc_454CFD

    loc_454CC8:                             ; CODE XREF: Network_Process+F82j
    mov     eax, [esp+52Ch+PacketBuffer]
    mov     ecx, [eax+0Ah]
    mov     dl, [eax+9]
    push    ecx
    mov     ecx, [eax+5]
    push    edx
    mov     edx, [eax+1]
    push    ecx
    push    edx
    call    sub_452960
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 4
    jnz     short loc_454CF8
    or      byte ptr [eax+2BEEh], 1
    jmp     short loc_454CFD
    ; ---------------------------------------------------------------------------

    loc_454CF8:                             ; CODE XREF: Network_Process+FADj
    call    sub_446FB0

    loc_454CFD:                             ; CODE XREF: Network_Process+F7Bj
                                            ; Network_Process+F86j ...
    xor     eax, eax
    xor     ecx, ecx
    mov     al, [esi+146h]
    mov     cl, [edi+146h]
    mov     edx, eax
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*2]
    mov     eax, TAdynmemStructPtr
    add     eax, edx
    mov     edx, [esp+52Ch+PacketBuffer]
    mov     dl, [edx+9]
    mov     [ecx+eax+1C6Bh], dl
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454D36:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0x24
    mov     esi, [eax+1]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454D6A
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_40C], bl

    loc_454D4B:                             ; CODE XREF: Network_Process+1028j
    mov     ecx, [esp+52Ch+var_40C]
    push    ecx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454D6C
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_40C], bl
    jb      short loc_454D4B

    loc_454D6A:                             ; CODE XREF: Network_Process+1000j
    mov     bl, 0Ah

    loc_454D6C:                             ; CODE XREF: Network_Process+101Aj
    cmp     bl, 0Ah
    jnz     short loc_454D7B
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    jmp     short loc_454DD9
    ; ---------------------------------------------------------------------------

    loc_454D7B:                             ; CODE XREF: Network_Process+102Fj
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454DB0
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_468], bl

    loc_454D89:                             ; CODE XREF: Network_Process+1066j
    mov     edx, [esp+52Ch+var_468]
    push    edx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454DAA
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_468], bl
    jb      short loc_454D89
    jmp     short loc_454DB0
    ; ---------------------------------------------------------------------------

    loc_454DAA:                             ; CODE XREF: Network_Process+1058j
    mov     byte ptr [esp+52Ch+var_4C8], bl
    jmp     short loc_454DB5
    ; ---------------------------------------------------------------------------

    loc_454DB0:                             ; CODE XREF: Network_Process+103Ej
                                            ; Network_Process+1068j
    mov     byte ptr [esp+52Ch+var_4C8], 0Ah

    loc_454DB5:                             ; CODE XREF: Network_Process+106Ej
    mov     eax, [esp+52Ch+var_4C8]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    mov     esi, ecx
    add     esi, eax
    lea     eax, [esi+edx*2+1B63h]

    loc_454DD9:                             ; CODE XREF: Network_Process+1039j
    test    eax, eax
    jz      short loc_454DF0
    mov     ecx, [esp+52Ch+PacketBuffer]
    mov     dl, [ecx+5]
    mov     [eax+13Fh], dl
    mov     ecx, TAdynmemStructPtr

    loc_454DF0:                             ; CODE XREF: Network_Process+109Bj
    test    byte ptr [ecx+2A44h], 4
    jnz     loc_455F50                      ; default

    loc_454DFD:                             ; CODE XREF: Network_Process+D41j
                                            ; Network_Process+D4Ej
    or      byte ptr [ecx+2BEEh], 1
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454E09:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0x1b
    mov     esi, [eax+1]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454E3D
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_424], bl

    loc_454E1E:                             ; CODE XREF: Network_Process+10FBj
    mov     ecx, [esp+52Ch+var_424]
    push    ecx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454E3F
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_424], bl
    jb      short loc_454E1E

    loc_454E3D:                             ; CODE XREF: Network_Process+10D3j
    mov     bl, 0Ah

    loc_454E3F:                             ; CODE XREF: Network_Process+10EDj
    cmp     bl, 0Ah
    jnz     short loc_454E48
    xor     eax, eax
    jmp     short loc_454EA4
    ; ---------------------------------------------------------------------------

    loc_454E48:                             ; CODE XREF: Network_Process+1102j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454E7D
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_460], bl

    loc_454E56:                             ; CODE XREF: Network_Process+1133j
    mov     edx, [esp+52Ch+var_460]
    push    edx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454E77
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_460], bl
    jb      short loc_454E56
    jmp     short loc_454E7D
    ; ---------------------------------------------------------------------------

    loc_454E77:                             ; CODE XREF: Network_Process+1125j
    mov     byte ptr [esp+52Ch+var_4D8], bl
    jmp     short loc_454E82
    ; ---------------------------------------------------------------------------

    loc_454E7D:                             ; CODE XREF: Network_Process+110Bj
                                            ; Network_Process+1135j
    mov     byte ptr [esp+52Ch+var_4D8], 0Ah

    loc_454E82:                             ; CODE XREF: Network_Process+113Bj
    mov     eax, [esp+52Ch+var_4D8]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+1B63h]

    loc_454EA4:                             ; CODE XREF: Network_Process+1106j
    test    eax, eax
    jz      loc_455F50                      ; default
    mov     edx, [esp+52Ch+PacketBuffer]
    mov     eax, [eax+4]
    xor     ecx, ecx
    mov     cl, [edx+5]
    push    ecx
    push    eax
    call    sub_453010
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_454EC4:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     ecx, [esp+52Ch+PacketBuffer]    ; case 0x1c
    mov     edi, TAdynmemStructPtr
    mov     esi, [ecx+1]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454F2F
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_414], dl
    jz      short loc_454F14

    loc_454EE4:                             ; CODE XREF: Network_Process+11E7j
    mov     eax, [esp+52Ch+var_414]
    mov     ebx, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_454F14
    mov     eax, [eax+1B67h]
    jmp     short loc_454F17
    ; ---------------------------------------------------------------------------

    loc_454F14:                             ; CODE XREF: Network_Process+11A2j
                                            ; Network_Process+11CAj
    or      eax, 0FFFFFFFFh

    loc_454F17:                             ; CODE XREF: Network_Process+11D2j
    cmp     eax, esi
    jz      short loc_454F2B
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_414], dl
    jb      short loc_454EE4
    jmp     short loc_454F2F
    ; ---------------------------------------------------------------------------

    loc_454F2B:                             ; CODE XREF: Network_Process+11D9j
    mov     al, dl
    jmp     short loc_454F31
    ; ---------------------------------------------------------------------------

    loc_454F2F:                             ; CODE XREF: Network_Process+1194j
                                            ; Network_Process+11E9j
    mov     al, 0Ah

    loc_454F31:                             ; CODE XREF: Network_Process+11EDj
    cmp     al, 0Ah
    jz      loc_455F50                      ; default
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454F66
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_458], bl

    loc_454F47:                             ; CODE XREF: Network_Process+1224j
    mov     edx, [esp+52Ch+var_458]
    push    edx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454F68
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_458], bl
    jb      short loc_454F47

    loc_454F66:                             ; CODE XREF: Network_Process+11FCj
    mov     bl, 0Ah

    loc_454F68:                             ; CODE XREF: Network_Process+1216j
    cmp     bl, 0Ah
    jnz     short loc_454F71
    xor     eax, eax
    jmp     short loc_454FCD
    ; ---------------------------------------------------------------------------

    loc_454F71:                             ; CODE XREF: Network_Process+122Bj
    cmp     esi, 0FFFFFFFFh
    jz      short loc_454FA6
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_434], bl

    loc_454F7F:                             ; CODE XREF: Network_Process+125Cj
    mov     eax, [esp+52Ch+var_434]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_454FA0
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_434], bl
    jb      short loc_454F7F
    jmp     short loc_454FA6
    ; ---------------------------------------------------------------------------

    loc_454FA0:                             ; CODE XREF: Network_Process+124Ej
    mov     byte ptr [esp+52Ch+var_4B8], bl
    jmp     short loc_454FAB
    ; ---------------------------------------------------------------------------

    loc_454FA6:                             ; CODE XREF: Network_Process+1234j
                                            ; Network_Process+125Ej
    mov     byte ptr [esp+52Ch+var_4B8], 0Ah

    loc_454FAB:                             ; CODE XREF: Network_Process+1264j
    mov     eax, [esp+52Ch+var_4B8]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    add     ecx, eax
    lea     eax, [ecx+edx*2+1B63h]

    loc_454FCD:                             ; CODE XREF: Network_Process+122Fj
    add     eax, 2Bh
    push    eax
    push    offset aPlayerSHasDisc          ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esp+534h+var_314]
    push    eax
    call    _sprintf
    mov     ecx, dword ptr [esp+538h+var_518]
    add     esp, 0Ch
    lea     edx, [esp+52Ch+var_314]
    push    ecx                             ; char
    push    0                               ; __int16
    push    4                               ; char
    push    edx                             ; char *
    call    sub_463CA0
    mov     ebp, [esp+52Ch+PacketBuffer]
    mov     esi, [ebp+1]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_455036
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_450], bl

    loc_455017:                             ; CODE XREF: Network_Process+12F4j
    mov     eax, [esp+52Ch+var_450]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_455038
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_450], bl
    jb      short loc_455017

    loc_455036:                             ; CODE XREF: Network_Process+12CCj
    mov     bl, 0Ah

    loc_455038:                             ; CODE XREF: Network_Process+12E6j
    cmp     bl, 0Ah
    jz      loc_455104
    mov     ecx, TAdynmemStructPtr
    cmp     esi, 0FFFFFFFFh
    mov     edi, [ecx+2A38h]
    mov     byte ptr [edi], 1Ch
    mov     [edi+1], esi
    jz      short loc_455088
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_430], bl

    loc_455061:                             ; CODE XREF: Network_Process+133Ej
    mov     edx, [esp+52Ch+var_430]
    push    edx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_455082
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_430], bl
    jb      short loc_455061
    jmp     short loc_455088
    ; ---------------------------------------------------------------------------

    loc_455082:                             ; CODE XREF: Network_Process+1330j
    mov     byte ptr [esp+52Ch+var_4D0], bl
    jmp     short loc_45508D
    ; ---------------------------------------------------------------------------

    loc_455088:                             ; CODE XREF: Network_Process+1316j
                                            ; Network_Process+1340j
    mov     byte ptr [esp+52Ch+var_4D0], 0Ah

    loc_45508D:                             ; CODE XREF: Network_Process+1346j
    mov     eax, [esp+52Ch+var_4D0]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    mov     ebx, ecx
    add     ebx, eax
    lea     eax, [ebx+edx*2+1B63h]
    mov     edx, [ebx+edx*2+1B63h]
    test    edx, edx
    jz      short loc_4550C2
    cmp     byte ptr [eax+73h], 3
    jz      short loc_4550D4

    loc_4550C2:                             ; CODE XREF: Network_Process+137Aj
    test    byte ptr [ecx+38D75h], 1
    jz      short loc_4550D4
    test    byte ptr [ecx+38D75h], 2
    jz      short loc_4550E0

    loc_4550D4:                             ; CODE XREF: Network_Process+1380j
                                            ; Network_Process+1389j
    push    esi
    call    sub_452CC0
    mov     ecx, TAdynmemStructPtr

    loc_4550E0:                             ; CODE XREF: Network_Process+1392j
    xor     edx, edx
    push    5                               ; idFrom
    mov     dl, [ecx+2A42h]
    push    edi                             ; idTo
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1B67h]
    push    ecx                             ; PlayerID
    call    sub_451DF0

    loc_455104:                             ; CODE XREF: Network_Process+12FBj
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    lea     ecx, [edx+1BD6h]

    loc_455112:                             ; CODE XREF: Network_Process+13E1j
    cmp     byte ptr [ecx], 1
    jz      short loc_455125
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_455112
    jmp     short loc_45513C
    ; ---------------------------------------------------------------------------

    loc_455125:                             ; CODE XREF: Network_Process+13D5j
    mov     ecx, eax
    mov     esi, edx
    shl     ecx, 5
    add     ecx, eax
    add     esi, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, [esi+ecx*2+1B67h]
    jmp     short loc_45513F
    ; ---------------------------------------------------------------------------

    loc_45513C:                             ; CODE XREF: Network_Process+13E3j
    or      eax, 0FFFFFFFFh

    loc_45513F:                             ; CODE XREF: Network_Process+13FAj
    cmp     [ebp+1], eax
    jnz     loc_455F50                      ; default
    or      byte ptr [edx+3923Bh], 4
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_455162:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, [esp+52Ch+PacketBuffer]    ; case 0x1e
    lea     ecx, [esp+52Ch+var_408]
    push    5                               ; idFrom
    push    ecx                             ; idTo
    mov     al, [edx+1]
    mov     byte ptr [esp+534h+var_408], 1Fh
    mov     [ebx+147h], al
    mov     edx, [edi+4]
    mov     ebx, [ebx+4]
    push    edx                             ; PlayersToSendTo
    push    ebx                             ; dwDataSize
    mov     [esp+53Ch+var_408+1], ebx
    call    Network_BroadcastMessage
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45519A:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0x1f
    mov     esi, TAdynmemStructPtr
    mov     edi, [eax+1]
    cmp     edi, 0FFFFFFFFh
    jz      short loc_455207
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_448], dl
    jz      short loc_4551EA

    loc_4551BA:                             ; CODE XREF: Network_Process+14BDj
    mov     eax, [esp+52Ch+var_448]
    mov     ebx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4551EA
    mov     eax, [eax+1B67h]
    jmp     short loc_4551ED
    ; ---------------------------------------------------------------------------

    loc_4551EA:                             ; CODE XREF: Network_Process+1478j
                                            ; Network_Process+14A0j
    or      eax, 0FFFFFFFFh

    loc_4551ED:                             ; CODE XREF: Network_Process+14A8j
    cmp     eax, edi
    jz      short loc_455201
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_448], dl
    jb      short loc_4551BA
    jmp     short loc_455207
    ; ---------------------------------------------------------------------------

    loc_455201:                             ; CODE XREF: Network_Process+14AFj
    mov     byte ptr [esp+52Ch+var_4EC], dl
    jmp     short loc_45520C
    ; ---------------------------------------------------------------------------

    loc_455207:                             ; CODE XREF: Network_Process+146Aj
                                            ; Network_Process+14BFj
    mov     byte ptr [esp+52Ch+var_4EC], 0Ah

    loc_45520C:                             ; CODE XREF: Network_Process+14C5j
    mov     eax, [esp+52Ch+var_4EC]
    and     eax, 0FFh
    cmp     eax, 0Ah
    jz      loc_455F50                      ; default
    mov     dword ptr [esi+eax*4+29D0h], 1
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45522E:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    cmp     dword ptr [ebx], 0              ; case 0x5
    jz      loc_455F50                      ; default
    cmp     byte ptr [ebx+73h], 1
    jnz     loc_455F50                      ; default
    mov     edx, dword ptr [esp+52Ch+var_518]
    mov     eax, [esp+52Ch+PacketBuffer]
    push    edx                             ; char
    push    0                               ; __int16
    inc     eax
    push    8                               ; char
    push    eax                             ; char *
    call    sub_463CA0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45525A:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     ecx, [esp+52Ch+PacketBuffer]    ; case 0x27
    mov     esi, [ecx+1]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_45528E
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_4AC], bl

    loc_45526F:                             ; CODE XREF: Network_Process+154Cj
    mov     edx, [esp+52Ch+var_4AC]
    push    edx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_455290
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_4AC], bl
    jb      short loc_45526F

    loc_45528E:                             ; CODE XREF: Network_Process+1524j
    mov     bl, 0Ah

    loc_455290:                             ; CODE XREF: Network_Process+153Ej
    cmp     bl, 0Ah
    jnz     short loc_455299
    xor     esi, esi
    jmp     short loc_4552F5
    ; ---------------------------------------------------------------------------

    loc_455299:                             ; CODE XREF: Network_Process+1553j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4552CE
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_4A4], bl

    loc_4552A7:                             ; CODE XREF: Network_Process+1584j
    mov     eax, [esp+52Ch+var_4A4]
    push    eax                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_4552C8
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_4A4], bl
    jb      short loc_4552A7
    jmp     short loc_4552CE
    ; ---------------------------------------------------------------------------

    loc_4552C8:                             ; CODE XREF: Network_Process+1576j
    mov     byte ptr [esp+52Ch+var_4E4], bl
    jmp     short loc_4552D3
    ; ---------------------------------------------------------------------------

    loc_4552CE:                             ; CODE XREF: Network_Process+155Cj
                                            ; Network_Process+1586j
    mov     byte ptr [esp+52Ch+var_4E4], 0Ah

    loc_4552D3:                             ; CODE XREF: Network_Process+158Cj
    mov     eax, [esp+52Ch+var_4E4]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    lea     esi, [edx+ecx*2+1B63h]

    loc_4552F5:                             ; CODE XREF: Network_Process+1557j
    test    esi, esi
    jz      loc_455F50                      ; default
    mov     al, [esi+146h]
    push    offset aHasModifiedHis          ; int
    mov     [esp+530h+var_518], al
    call    sub_4C5740
    add     esi, 2Bh
    push    eax
    push    esi
    lea     ecx, [esp+534h+var_100]
    push    offset aSS_0                    ; "%s %s"
    push    ecx
    call    _sprintf
    mov     edi, dword ptr [esp+53Ch+var_518]
    add     esp, 10h
    mov     esi, 0Ch

    loc_455334:                             ; CODE XREF: Network_Process+1607j
    push    edi                             ; char
    push    0                               ; __int16
    lea     edx, [esp+534h+var_100]
    push    8                               ; char
    push    edx                             ; char *
    call    sub_463CA0
    dec     esi
    jnz     short loc_455334
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45534E:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     esi, TAdynmemStructPtr          ; case 0x6
    mov     byte ptr [esp+52Ch+var_511], 7
    xor     eax, eax
    lea     ecx, [esi+1BD6h]

    loc_455361:                             ; CODE XREF: Network_Process+1640j
    mov     edx, [ecx-73h]
    test    edx, edx
    jz      short loc_455374
    mov     dl, [ecx]
    cmp     dl, 1
    jz      short loc_455382
    cmp     dl, 2
    jz      short loc_455382

    loc_455374:                             ; CODE XREF: Network_Process+1626j
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jge     short loc_455399
    jmp     short loc_455361
    ; ---------------------------------------------------------------------------

    loc_455382:                             ; CODE XREF: Network_Process+162Dj
                                            ; Network_Process+1632j
    mov     ecx, eax
    mov     edx, esi
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edx+ecx*2+1B67h]
    jmp     short loc_45539C
    ; ---------------------------------------------------------------------------

    loc_455399:                             ; CODE XREF: Network_Process+163Ej
    or      eax, 0FFFFFFFFh

    loc_45539C:                             ; CODE XREF: Network_Process+1657j
    mov     edx, [esi+4C9h]
    lea     ecx, [esp+52Ch+var_511]
    push    1                               ; idFrom
    push    ecx                             ; idTo
    push    edx                             ; PlayersToSendTo
    push    eax                             ; dwDataSize
    call    Network_BroadcastMessage
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4553B5:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    or      byte ptr [edi+21h], 1           ; case 0x7
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4553BE:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, TAdynmemStructPtr          ; case 0x8
    mov     [esp+52Ch+var_43C], 0
    or      byte ptr [eax+2A44h], 4
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4553DA:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0x9
    mov     ecx, dword ptr [esp+52Ch+var_518]
    push    eax
    push    ecx
    call    sub_4861D0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4553EE:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, [esp+52Ch+PacketBuffer]    ; case 0x2c
    push    edx
    push    edi
    call    sub_48B920
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4553FE:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0xa
    push    eax
    call    sub_48AB70
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45540D:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     ecx, [esp+52Ch+PacketBuffer]    ; case 0xb
    push    ecx
    call    sub_489CE0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45541C:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, [esp+52Ch+PacketBuffer]    ; case 0xc
    push    0
    push    edx
    call    sub_4866D0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45542D:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0xd
    push    eax
    push    edi
    call    sub_49D270
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45543D:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     ecx, [esp+52Ch+PacketBuffer]    ; case 0xe
    push    ecx
    push    edi
    call    sub_49AF90
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45544D:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edi, [esp+52Ch+PacketBuffer]    ; case 0xf
    xor     ecx, ecx
    mov     cl, [edi+1]
    mov     eax, ecx
    sub     eax, 0FDh
    jz      short loc_4554D4
    dec     eax
    jz      short loc_4554BA
    dec     eax
    jz      short loc_4554A0
    lea     eax, [ecx+ecx*2]
    xor     edx, edx
    mov     dx, [edi+4]
    xor     esi, esi
    mov     si, [edi+2]
    mov     edi, TAdynmemStructPtr
    shl     eax, 3
    sub     eax, ecx
    add     edi, ecx
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*4+TAdynmemStruct.Weapons]
    push    ecx                             ; int
    push    edx                             ; int
    push    esi                             ; int
    push    edx
    push    esi
    call    sub_481550
    push    eax                             ; int
    call    sub_4244B0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4554A0:                             ; CODE XREF: Network_Process+1723j
    xor     edx, edx
    xor     eax, eax
    mov     dx, [edi+4]
    mov     ax, [edi+2]
    push    1
    push    edx
    push    eax
    call    sub_423550
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4554BA:                             ; CODE XREF: Network_Process+1720j
    xor     ecx, ecx
    xor     edx, edx
    mov     cx, [edi+4]
    mov     dx, [edi+2]
    push    1
    push    ecx
    push    edx
    call    sub_4233A0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4554D4:                             ; CODE XREF: Network_Process+171Dj
    xor     eax, eax
    xor     ecx, ecx
    mov     ax, [edi+4]
    mov     cx, [edi+2]
    push    0
    push    eax
    push    ecx
    call    sub_423550
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4554EE:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, [esp+52Ch+PacketBuffer]    ; case 0x10
    mov     ax, [edx+1]
    test    ax, ax
    jnz     short loc_4554FF
    xor     ecx, ecx
    jmp     short loc_455518
    ; ---------------------------------------------------------------------------

    loc_4554FF:                             ; CODE XREF: Network_Process+17B9j
    and     eax, 0FFFFh
    mov     ecx, TAdynmemStructPtr
    imul    eax, 118h
    mov     ecx, [ecx+14357h]
    add     ecx, eax

    loc_455518:                             ; CODE XREF: Network_Process+17BDj
    test    dword ptr [ecx+110h], 10000000h
    jz      loc_455F50                      ; default
    mov     eax, [esp+52Ch+PacketBuffer]
    mov     ecx, [ecx+9Ah]
    mov     edx, [eax+12h]
    push    edx
    mov     edx, [eax+0Eh]
    push    edx
    mov     edx, [eax+0Ah]
    push    edx
    mov     edx, [eax+6]
    push    edx
    xor     edx, edx
    mov     dl, [eax+5]
    movsx   eax, word ptr [eax+3]
    push    edx
    push    0
    push    0
    push    eax
    call    sub_4B0B00
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45555B:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     ecx, [esp+52Ch+PacketBuffer]    ; case 0x11
    mov     ax, [ecx+1]
    test    ax, ax
    jnz     short loc_45556C
    xor     esi, esi
    jmp     short loc_455585
    ; ---------------------------------------------------------------------------

    loc_45556C:                             ; CODE XREF: Network_Process+1826j
    and     eax, 0FFFFh
    mov     edx, TAdynmemStructPtr
    imul    eax, 118h
    mov     esi, [edx+14357h]
    add     esi, eax

    loc_455585:                             ; CODE XREF: Network_Process+182Aj
    test    dword ptr [esi+110h], 10000000h
    jz      loc_455F50                      ; default
    mov     edi, [esp+52Ch+PacketBuffer]
    push    1                               ; int
    mov     ecx, esi
    mov     al, [edi+3]
    push    eax                             ; idTo
    call    sub_48B090
    mov     cl, [edi+3]
    push    0                               ; int
    not     cl
    push    ecx                             ; idTo
    mov     ecx, esi
    call    sub_48B090
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4555BA:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     esi, [esp+52Ch+PacketBuffer]    ; case 0x12
    mov     ecx, TAdynmemStructPtr
    mov     ax, [esi+1]
    test    ax, ax
    jnz     short loc_4555D1
    xor     edx, edx
    jmp     short loc_4555E4
    ; ---------------------------------------------------------------------------

    loc_4555D1:                             ; CODE XREF: Network_Process+188Bj
    and     eax, 0FFFFh
    mov     edx, [ecx+14357h]
    imul    eax, 118h
    add     edx, eax

    loc_4555E4:                             ; CODE XREF: Network_Process+188Fj
    mov     ax, [esi+3]
    test    ax, ax
    jnz     short loc_4555FB
    xor     ecx, ecx
    push    edx
    push    ecx
    call    sub_41B8D0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4555FB:                             ; CODE XREF: Network_Process+18ABj
    and     eax, 0FFFFh
    mov     ecx, [ecx+14357h]
    imul    eax, 118h
    add     ecx, eax
    push    edx
    push    ecx
    call    sub_41B8D0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45561A:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, [esp+52Ch+PacketBuffer]    ; case 0x13
    push    0
    mov     al, [edx+1]
    test    al, al
    mov     eax, edx
    jz      short loc_455637
    mov     ecx, [eax+2]
    push    ecx
    call    sub_47F0C0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_455637:                             ; CODE XREF: Network_Process+18E7j
    lea     edx, [eax+6]
    mov     eax, [eax+2]
    push    edx
    push    eax
    call    sub_47F300
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_455649:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     ecx, [esp+52Ch+PacketBuffer]    ; case 0x14
    mov     edx, TAdynmemStructPtr
    mov     ax, [ecx+1]
    test    ax, ax
    jnz     short loc_455660
    xor     edi, edi
    jmp     short loc_455673
    ; ---------------------------------------------------------------------------

    loc_455660:                             ; CODE XREF: Network_Process+191Aj
    and     eax, 0FFFFh
    mov     edi, [edx+14357h]
    imul    eax, 118h
    add     edi, eax

    loc_455673:                             ; CODE XREF: Network_Process+191Ej
    test    edi, edi
    jz      loc_455F50                      ; default
    test    dword ptr [edi+110h], 10000000h
    jz      loc_455F50                      ; default
    mov     esi, [ecx+3]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4556ED
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_49C], bl
    jz      short loc_4556D2

    loc_4556A1:                             ; CODE XREF: Network_Process+19A5j
    mov     eax, [esp+52Ch+var_49C]
    mov     ebp, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     cl, [ebp+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4556D2
    mov     eax, [eax+1B67h]
    jmp     short loc_4556D5
    ; ---------------------------------------------------------------------------

    loc_4556D2:                             ; CODE XREF: Network_Process+195Fj
                                            ; Network_Process+1988j
    or      eax, 0FFFFFFFFh

    loc_4556D5:                             ; CODE XREF: Network_Process+1990j
    cmp     eax, esi
    jz      short loc_4556E9
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_49C], bl
    jb      short loc_4556A1
    jmp     short loc_4556ED
    ; ---------------------------------------------------------------------------

    loc_4556E9:                             ; CODE XREF: Network_Process+1997j
    mov     al, bl
    jmp     short loc_4556EF
    ; ---------------------------------------------------------------------------

    loc_4556ED:                             ; CODE XREF: Network_Process+1951j
                                            ; Network_Process+19A7j
    mov     al, 0Ah

    loc_4556EF:                             ; CODE XREF: Network_Process+19ABj
    cmp     al, 0Ah
    jnz     short loc_4556F7
    xor     eax, eax
    jmp     short loc_45575A
    ; ---------------------------------------------------------------------------

    loc_4556F7:                             ; CODE XREF: Network_Process+19B1j
    cmp     esi, 0FFFFFFFFh
    jnz     short loc_455703
    mov     byte ptr [esp+52Ch+var_4DC], 0Ah
    jmp     short loc_45573E
    ; ---------------------------------------------------------------------------

    loc_455703:                             ; CODE XREF: Network_Process+19BAj
    xor     bl, bl
    mov     byte ptr [esp+52Ch+var_494], bl

    loc_45570C:                             ; CODE XREF: Network_Process+19E9j
    mov     edx, [esp+52Ch+var_494]
    push    edx                             ; int
    call    PlayerNumberToID
    cmp     eax, esi
    jz      short loc_45572D
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_494], bl
    jb      short loc_45570C
    jmp     short loc_455733
    ; ---------------------------------------------------------------------------

    loc_45572D:                             ; CODE XREF: Network_Process+19DBj
    mov     byte ptr [esp+52Ch+var_4DC], bl
    jmp     short loc_455738
    ; ---------------------------------------------------------------------------

    loc_455733:                             ; CODE XREF: Network_Process+19EBj
    mov     byte ptr [esp+52Ch+var_4DC], 0Ah

    loc_455738:                             ; CODE XREF: Network_Process+19F1j
    mov     edx, TAdynmemStructPtr

    loc_45573E:                             ; CODE XREF: Network_Process+19C1j
    mov     eax, [esp+52Ch+var_4DC]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+1B63h]

    loc_45575A:                             ; CODE XREF: Network_Process+19B5j
    cmp     dword ptr [eax], 0
    jz      loc_455F50                      ; default
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_455774
    cmp     cl, 2
    jnz     loc_455F50                      ; default

    loc_455774:                             ; CODE XREF: Network_Process+1A29j
    mov     edx, [esp+52Ch+PacketBuffer]
    push    edx
    push    eax
    push    edi
    call    sub_488570
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_455785:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, TAdynmemStructPtr          ; case 0x15
    mov     cl, [eax+38D75h]
    shr     cl, 2
    test    cl, 1
    jz      loc_455F50                      ; default
    mov     dword ptr [eax+esi*4+29A4h], 1
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4557AC:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, [esp+52Ch+PacketBuffer]    ; case 0x16
    mov     esi, TAdynmemStructPtr
    mov     edi, [edx+5]
    cmp     edi, 0FFFFFFFFh
    jz      short loc_455817
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_48C], dl
    jz      short loc_4557FC

    loc_4557CC:                             ; CODE XREF: Network_Process+1ACFj
    mov     eax, [esp+52Ch+var_48C]
    mov     ebx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4557FC
    mov     eax, [eax+1B67h]
    jmp     short loc_4557FF
    ; ---------------------------------------------------------------------------

    loc_4557FC:                             ; CODE XREF: Network_Process+1A8Aj
                                            ; Network_Process+1AB2j
    or      eax, 0FFFFFFFFh

    loc_4557FF:                             ; CODE XREF: Network_Process+1ABAj
    cmp     eax, edi
    jz      short loc_455813
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_48C], dl
    jb      short loc_4557CC
    jmp     short loc_455817
    ; ---------------------------------------------------------------------------

    loc_455813:                             ; CODE XREF: Network_Process+1AC1j
    mov     bl, dl
    jmp     short loc_455819
    ; ---------------------------------------------------------------------------

    loc_455817:                             ; CODE XREF: Network_Process+1A7Cj
                                            ; Network_Process+1AD1j
    mov     bl, 0Ah

    loc_455819:                             ; CODE XREF: Network_Process+1AD5j
    mov     edx, [esp+52Ch+PacketBuffer]
    mov     byte ptr [esp+52Ch+var_508], bl
    mov     edi, [edx+9]
    cmp     edi, 0FFFFFFFFh
    jz      short loc_455883
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_484], dl
    jz      short loc_455868

    loc_455837:                             ; CODE XREF: Network_Process+1B3Bj
    mov     eax, [esp+52Ch+var_484]
    mov     ebp, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     cl, [ebp+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_455868
    mov     eax, [eax+1B67h]
    jmp     short loc_45586B
    ; ---------------------------------------------------------------------------

    loc_455868:                             ; CODE XREF: Network_Process+1AF5j
                                            ; Network_Process+1B1Ej
    or      eax, 0FFFFFFFFh

    loc_45586B:                             ; CODE XREF: Network_Process+1B26j
    cmp     eax, edi
    jz      short loc_45587F
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_484], dl
    jb      short loc_455837
    jmp     short loc_455883
    ; ---------------------------------------------------------------------------

    loc_45587F:                             ; CODE XREF: Network_Process+1B2Dj
    mov     al, dl
    jmp     short loc_455885
    ; ---------------------------------------------------------------------------

    loc_455883:                             ; CODE XREF: Network_Process+1AE7j
                                            ; Network_Process+1B3Dj
    mov     al, 0Ah

    loc_455885:                             ; CODE XREF: Network_Process+1B41j
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_50C], al
    jz      loc_455F50                      ; default
    cmp     al, 0Ah
    jz      loc_455F50                      ; default
    mov     edx, [esp+52Ch+PacketBuffer]
    mov     eax, [edx+1]
    dec     eax
    jz      short loc_4558E0
    dec     eax
    jz      short loc_4558C2
    dec     eax
    jnz     loc_455F50                      ; default
    mov     eax, [esp+52Ch+var_50C]
    mov     ecx, [esp+52Ch+var_508]
    push    eax
    push    ecx
    call    sub_485420
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4558C2:                             ; CODE XREF: Network_Process+1B65j
    mov     edx, [esp+52Ch+PacketBuffer]
    mov     ecx, [esp+52Ch+var_50C]
    push    0
    mov     eax, [edx+0Dh]
    mov     edx, [esp+530h+var_508]
    push    eax
    push    ecx
    push    edx
    call    sub_464C60
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4558E0:                             ; CODE XREF: Network_Process+1B62j
    mov     eax, [esp+52Ch+PacketBuffer]
    mov     edx, [esp+52Ch+var_50C]
    push    0
    mov     ecx, [eax+0Dh]
    mov     eax, [esp+530h+var_508]
    push    ecx
    push    edx
    push    eax
    call    sub_464B30
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4558FE:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     ecx, [esp+52Ch+PacketBuffer]    ; case 0x28
    push    edi
    push    ecx
    call    sub_457540
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45590E:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0x29
    mov     cl, [eax+1]
    test    cl, cl
    jz      loc_455F50                      ; default
    mov     byte ptr [ebx+esi+11Eh], 1
    mov     cl, [eax+2]
    test    cl, cl
    jz      loc_455F50                      ; default
    mov     byte ptr [ebx+esi+134h], 1
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45593D:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     ecx, [esp+52Ch+PacketBuffer]    ; case 0x19
    mov     al, [ecx+1]
    test    al, al
    jz      short loc_45595C
    mov     eax, ecx
    xor     edx, edx
    push    0
    mov     dl, [eax+2]
    push    edx
    call    sub_490DF0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_45595C:                             ; CODE XREF: Network_Process+1C06j
    mov     cl, [ecx+2]
    mov     eax, TAdynmemStructPtr
    and     cl, 1
    mov     dx, [eax+38A51h]
    movzx   cx, cl
    and     edx, 0FFFEh
    or      edx, ecx
    mov     [eax+38A51h], dx
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_455986:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, TAdynmemStructPtr          ; case 0x1a
    mov     ecx, [edx+2A30h]
    test    ecx, ecx
    jz      loc_455F50                      ; default
    cmp     dword ptr [ebx], 0
    jz      loc_455F50                      ; default
    cmp     byte ptr [ebx+73h], 1
    jnz     loc_455F50                      ; default
    mov     eax, dword ptr [esp+52Ch+var_518]
    mov     edx, [esp+52Ch+PacketBuffer]
    push    eax
    push    edx
    call    sub_46D500
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4559C1:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, dword_506DBC               ; case 0x1d
    test    eax, eax
    jz      loc_455F50                      ; default
    mov     eax, [esp+52Ch+PacketBuffer]
    mov     ecx, [eax+5]
    mov     edx, [eax+1]
    mov     eax, TAdynmemStructPtr
    push    ecx
    push    edx
    mov     ecx, [eax+4C9h]
    push    ecx
    mov     ecx, offset dword_513000
    call    nullsub_14
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_4559F5:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, [esp+52Ch+PacketBuffer]    ; case 0x21
    mov     edi, TAdynmemStructPtr
    mov     esi, [edx+2]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_455A60
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_47C], dl
    jz      short loc_455A45

    loc_455A15:                             ; CODE XREF: Network_Process+1D18j
    mov     eax, [esp+52Ch+var_47C]
    mov     ebx, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_455A45
    mov     eax, [eax+1B67h]

    loc_455A43:                             ; DATA XREF: .data:005110A4o
    jmp     short loc_455A48
    ; ---------------------------------------------------------------------------

    loc_455A45:                             ; CODE XREF: Network_Process+1CD3j
                                            ; Network_Process+1CFBj
    or      eax, 0FFFFFFFFh

    loc_455A48:                             ; CODE XREF: Network_Process+1D03j
    cmp     eax, esi
    jz      short loc_455A5C
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_47C], dl
    jb      short loc_455A15
    jmp     short loc_455A60
    ; ---------------------------------------------------------------------------

    loc_455A5C:                             ; CODE XREF: Network_Process+1D0Aj
    mov     al, dl
    jmp     short loc_455A62
    ; ---------------------------------------------------------------------------

    loc_455A60:                             ; CODE XREF: Network_Process+1CC5j
                                            ; Network_Process+1D1Aj
    mov     al, 0Ah

    loc_455A62:                             ; CODE XREF: Network_Process+1D1Ej
    cmp     al, 0Ah
    jnz     short loc_455A6D
    xor     ebp, ebp
    jmp     loc_455AF0
    ; ---------------------------------------------------------------------------

    loc_455A6D:                             ; CODE XREF: Network_Process+1D24j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_455ACD
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_474], dl
    jz      short loc_455AB0

    loc_455A80:                             ; CODE XREF: Network_Process+1D83j
    mov     eax, [esp+52Ch+var_474]
    mov     ebx, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_455AB0
    mov     eax, [eax+1B67h]
    jmp     short loc_455AB3
    ; ---------------------------------------------------------------------------

    loc_455AB0:                             ; CODE XREF: Network_Process+1D3Ej
                                            ; Network_Process+1D66j
    or      eax, 0FFFFFFFFh

    loc_455AB3:                             ; CODE XREF: Network_Process+1D6Ej
    cmp     eax, esi
    jz      short loc_455AC7
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_474], dl
    jb      short loc_455A80
    jmp     short loc_455ACD
    ; ---------------------------------------------------------------------------

    loc_455AC7:                             ; CODE XREF: Network_Process+1D75j
    mov     byte ptr [esp+52Ch+var_4D4], dl
    jmp     short loc_455AD2
    ; ---------------------------------------------------------------------------

    loc_455ACD:                             ; CODE XREF: Network_Process+1D30j
                                            ; Network_Process+1D85j
    mov     byte ptr [esp+52Ch+var_4D4], 0Ah

    loc_455AD2:                             ; CODE XREF: Network_Process+1D8Bj
    mov     eax, [esp+52Ch+var_4D4]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, edi
    add     ecx, eax
    lea     ebp, [ecx+edx*2+1B63h]

    loc_455AF0:                             ; CODE XREF: Network_Process+1D28j
    mov     edx, [esp+52Ch+PacketBuffer]
    mov     esi, [edx+6]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_455B55
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_46C], dl
    jz      short loc_455B3A

    loc_455B0A:                             ; CODE XREF: Network_Process+1E0Dj
    mov     eax, [esp+52Ch+var_46C]
    mov     ebx, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_455B3A
    mov     eax, [eax+1B67h]
    jmp     short loc_455B3D
    ; ---------------------------------------------------------------------------

    loc_455B3A:                             ; CODE XREF: Network_Process+1DC8j
                                            ; Network_Process+1DF0j
    or      eax, 0FFFFFFFFh

    loc_455B3D:                             ; CODE XREF: Network_Process+1DF8j
    cmp     eax, esi
    jz      short loc_455B51
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_46C], dl
    jb      short loc_455B0A
    jmp     short loc_455B55
    ; ---------------------------------------------------------------------------

    loc_455B51:                             ; CODE XREF: Network_Process+1DFFj
    mov     al, dl
    jmp     short loc_455B57
    ; ---------------------------------------------------------------------------

    loc_455B55:                             ; CODE XREF: Network_Process+1DBAj
                                            ; Network_Process+1E0Fj
    mov     al, 0Ah

    loc_455B57:                             ; CODE XREF: Network_Process+1E13j
    cmp     al, 0Ah
    jnz     short loc_455B62
    xor     esi, esi
    jmp     loc_455BE5
    ; ---------------------------------------------------------------------------

    loc_455B62:                             ; CODE XREF: Network_Process+1E19j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_455BC2
    xor     dl, dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_464], dl
    jz      short loc_455BA5

    loc_455B75:                             ; CODE XREF: Network_Process+1E78j
    mov     eax, [esp+52Ch+var_464]
    mov     ebx, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_455BA5
    mov     eax, [eax+1B67h]
    jmp     short loc_455BA8
    ; ---------------------------------------------------------------------------

    loc_455BA5:                             ; CODE XREF: Network_Process+1E33j
                                            ; Network_Process+1E5Bj
    or      eax, 0FFFFFFFFh

    loc_455BA8:                             ; CODE XREF: Network_Process+1E63j
    cmp     eax, esi
    jz      short loc_455BBC
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_464], dl
    jb      short loc_455B75
    jmp     short loc_455BC2
    ; ---------------------------------------------------------------------------

    loc_455BBC:                             ; CODE XREF: Network_Process+1E6Aj
    mov     byte ptr [esp+52Ch+var_4CC], dl
    jmp     short loc_455BC7
    ; ---------------------------------------------------------------------------

    loc_455BC2:                             ; CODE XREF: Network_Process+1E25j
                                            ; Network_Process+1E7Aj
    mov     byte ptr [esp+52Ch+var_4CC], 0Ah

    loc_455BC7:                             ; CODE XREF: Network_Process+1E80j
    mov     eax, [esp+52Ch+var_4CC]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, edi
    add     ecx, eax
    lea     esi, [ecx+edx*2+1B63h]

    loc_455BE5:                             ; CODE XREF: Network_Process+1E1Dj
    xor     dl, dl
    mov     byte ptr [esp+52Ch+var_45C], dl

    loc_455BEE:                             ; CODE XREF: Network_Process+1EF1j
    mov     eax, [esp+52Ch+var_45C]
    mov     ebx, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebx+ecx*2]
    mov     cl, [ebx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_455C25
    mov     eax, [eax+1B8Ah]
    test    byte ptr [eax+97h], 1
    jnz     short loc_455C35

    loc_455C25:                             ; CODE XREF: Network_Process+1ED4j
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+52Ch+var_45C], dl
    jb      short loc_455BEE
    jmp     short loc_455C3E
    ; ---------------------------------------------------------------------------

    loc_455C35:                             ; CODE XREF: Network_Process+1EE3j
    mov     byte ptr [esp+52Ch+var_454], dl
    jmp     short loc_455C46
    ; ---------------------------------------------------------------------------

    loc_455C3E:                             ; CODE XREF: Network_Process+1EF3j
    mov     byte ptr [esp+52Ch+var_454], 0Ah

    loc_455C46:                             ; CODE XREF: Network_Process+1EFCj
    mov     eax, [esp+52Ch+var_454]
    mov     edx, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+1B63h]
    mov     ecx, [edx+ecx*2+1B63h]
    test    ecx, ecx
    jz      loc_455F50                      ; default
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_455C85
    cmp     al, 2
    jnz     loc_455F50                      ; default

    loc_455C85:                             ; CODE XREF: Network_Process+1F3Bj
    test    ebp, ebp
    jz      loc_455F50                      ; default
    mov     eax, [esp+52Ch+PacketBuffer]
    xor     cl, cl
    mov     byte ptr [esp+52Ch+idTo+2], 22h
    mov     [esp+52Ch+idTo+3], 0FFFFFFFFh
    mov     dl, [eax+1]
    mov     byte ptr [esp+52Ch+var_4FB], cl
    test    dl, dl
    jnz     short loc_455D22
    mov     ecx, [ebp+4]
    mov     [esp+52Ch+idTo+3], ecx
    mov     al, [ebp+0Ch]
    test    al, al
    mov     byte ptr [esp+52Ch+var_4FB], al
    jz      loc_455F50                      ; default
    xor     eax, eax
    lea     ecx, [edi+1B8Ah]

    loc_455CC9:                             ; CODE XREF: Network_Process+1F9Ej
    mov     edx, [ecx]
    test    byte ptr [edx+97h], 1
    jnz     short loc_455CE2
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_455CC9
    jmp     short loc_455D0D
    ; ---------------------------------------------------------------------------

    loc_455CE2:                             ; CODE XREF: Network_Process+1F92j
    cmp     al, 0Ah
    jz      short loc_455D0D
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    add     edi, ecx
    lea     eax, [eax+eax*4]
    mov     cl, [edi+eax*2+1BD6h]
    lea     eax, [edi+eax*2]
    test    cl, cl
    jz      short loc_455D0D
    mov     eax, [eax+1B67h]
    jmp     short loc_455D10
    ; ---------------------------------------------------------------------------

    loc_455D0D:                             ; CODE XREF: Network_Process+1FA0j
                                            ; Network_Process+1FA4j ...
    or      eax, 0FFFFFFFFh

    loc_455D10:                             ; CODE XREF: Network_Process+1FCBj
    lea     ecx, [esp+52Ch+idTo+2]
    push    6                               ; idFrom
    push    ecx                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_455D22:                             ; CODE XREF: Network_Process+1F69j
    test    esi, esi
    jz      short loc_455D54
    mov     edx, [ebp+4]
    mov     [esp+52Ch+idTo+3], edx
    mov     eax, [esi]
    test    eax, eax
    jz      loc_455DBF
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_455D46
    cmp     al, 2
    jz      short loc_455D46
    cmp     al, 3
    jnz     short loc_455DBF

    loc_455D46:                             ; CODE XREF: Network_Process+1FFCj
                                            ; Network_Process+2000j
    cmp     byte ptr [esi+146h], 0Ah
    jz      short loc_455DBF
    mov     cl, [esi+0Ch]
    jmp     short loc_455DBB
    ; ---------------------------------------------------------------------------

    loc_455D54:                             ; CODE XREF: Network_Process+1FE4j
    mov     eax, [ebp+4]
    mov     [esp+52Ch+idTo+3], eax
    mov     eax, [ebp+0Ch]
    test    eax, eax
    jnz     short loc_455DBF
    mov     ebx, 1

    loc_455D67:                             ; CODE XREF: Network_Process+206Fj
    xor     esi, esi
    lea     eax, [edi+1BD6h]
    mov     edx, 0Ah

    loc_455D74:                             ; CODE XREF: Network_Process+2065j
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_455D9F
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_455D8C
    cmp     cl, 2
    jz      short loc_455D8C
    cmp     cl, 3
    jnz     short loc_455D9F

    loc_455D8C:                             ; CODE XREF: Network_Process+2040j
                                            ; Network_Process+2045j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_455D9F
    cmp     [eax-67h], ebx
    jnz     short loc_455D9F
    mov     esi, 1

    loc_455D9F:                             ; CODE XREF: Network_Process+2039j
                                            ; Network_Process+204Aj ...
    add     eax, 14Bh
    dec     edx
    jnz     short loc_455D74
    test    esi, esi
    jz      short loc_455DB3
    inc     ebx
    cmp     ebx, 0Ah
    jle     short loc_455D67
    jmp     short loc_455DB7
    ; ---------------------------------------------------------------------------

    loc_455DB3:                             ; CODE XREF: Network_Process+2069j
    mov     al, bl
    jmp     short loc_455DB9
    ; ---------------------------------------------------------------------------

    loc_455DB7:                             ; CODE XREF: Network_Process+2071j
    xor     al, al

    loc_455DB9:                             ; CODE XREF: Network_Process+2075j
    mov     cl, al

    loc_455DBB:                             ; CODE XREF: Network_Process+2012j
    mov     byte ptr [esp+52Ch+var_4FB], cl

    loc_455DBF:                             ; CODE XREF: Network_Process+1FF1j
                                            ; Network_Process+2004j ...
    test    cl, cl
    jz      loc_455F50                      ; default
    mov     ecx, [esp+52Ch+var_4FB]
    and     ecx, 0FFh
    xor     eax, eax
    mov     [ebp+0Ch], ecx
    mov     edx, TAdynmemStructPtr
    lea     ecx, [edx+1B8Ah]

    loc_455DE2:                             ; CODE XREF: Network_Process+20B7j
    mov     esi, [ecx]
    test    byte ptr [esi+97h], 1
    jnz     short loc_455DFB
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_455DE2
    jmp     short loc_455E26
    ; ---------------------------------------------------------------------------

    loc_455DFB:                             ; CODE XREF: Network_Process+20ABj
    cmp     al, 0Ah
    jz      short loc_455E26
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2]
    mov     cl, [edx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_455E26
    mov     eax, [eax+1B67h]
    jmp     short loc_455E29
    ; ---------------------------------------------------------------------------

    loc_455E26:                             ; CODE XREF: Network_Process+20B9j
                                            ; Network_Process+20BDj ...
    or      eax, 0FFFFFFFFh

    loc_455E29:                             ; CODE XREF: Network_Process+20E4j
    lea     edx, [esp+52Ch+idTo+2]
    push    6                               ; idFrom
    push    edx                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    jmp     loc_455F50                      ; default
    ; ---------------------------------------------------------------------------

    loc_455E3B:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     eax, [esp+52Ch+PacketBuffer]    ; case 0x22
    mov     edx, TAdynmemStructPtr
    mov     esi, [eax+1]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_455EA6
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_44C], bl
    jz      short loc_455E8B

    loc_455E5B:                             ; CODE XREF: Network_Process+215Ej
    mov     eax, [esp+52Ch+var_44C]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_455E8B
    mov     eax, [eax+1B67h]
    jmp     short loc_455E8E
    ; ---------------------------------------------------------------------------

    loc_455E8B:                             ; CODE XREF: Network_Process+2119j
                                            ; Network_Process+2141j
    or      eax, 0FFFFFFFFh

    loc_455E8E:                             ; CODE XREF: Network_Process+2149j
    cmp     eax, esi
    jz      short loc_455EA2
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_44C], bl
    jb      short loc_455E5B
    jmp     short loc_455EA6
    ; ---------------------------------------------------------------------------

    loc_455EA2:                             ; CODE XREF: Network_Process+2150j
    mov     al, bl
    jmp     short loc_455EA8
    ; ---------------------------------------------------------------------------

    loc_455EA6:                             ; CODE XREF: Network_Process+210Bj
                                            ; Network_Process+2160j
    mov     al, 0Ah

    loc_455EA8:                             ; CODE XREF: Network_Process+2164j
    cmp     al, 0Ah
    jnz     short loc_455EB3
    xor     eax, eax
    jmp     loc_455F34
    ; ---------------------------------------------------------------------------

    loc_455EB3:                             ; CODE XREF: Network_Process+216Aj
    cmp     esi, 0FFFFFFFFh
    jz      short loc_455F13
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_444], bl
    jz      short loc_455EF6

    loc_455EC6:                             ; CODE XREF: Network_Process+21C9j
    mov     eax, [esp+52Ch+var_444]
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_455EF6
    mov     eax, [eax+1B67h]
    jmp     short loc_455EF9
    ; ---------------------------------------------------------------------------

    loc_455EF6:                             ; CODE XREF: Network_Process+2184j
                                            ; Network_Process+21ACj
    or      eax, 0FFFFFFFFh

    loc_455EF9:                             ; CODE XREF: Network_Process+21B4j
    cmp     eax, esi
    jz      short loc_455F0D
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+52Ch+var_444], bl
    jb      short loc_455EC6
    jmp     short loc_455F13
    ; ---------------------------------------------------------------------------

    loc_455F0D:                             ; CODE XREF: Network_Process+21BBj
    mov     byte ptr [esp+52Ch+var_4C4], bl
    jmp     short loc_455F18
    ; ---------------------------------------------------------------------------

    loc_455F13:                             ; CODE XREF: Network_Process+2176j
                                            ; Network_Process+21CBj
    mov     byte ptr [esp+52Ch+var_4C4], 0Ah

    loc_455F18:                             ; CODE XREF: Network_Process+21D1j
    mov     eax, [esp+52Ch+var_4C4]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+1B63h]

    loc_455F34:                             ; CODE XREF: Network_Process+216Ej
    test    eax, eax
    jz      short loc_455F50                ; default
    mov     ecx, [esp+52Ch+PacketBuffer]
    xor     edx, edx
    mov     dl, [ecx+5]
    mov     [eax+0Ch], edx
    jmp     short loc_455F50                ; default
    ; ---------------------------------------------------------------------------

    loc_455F46:                             ; CODE XREF: Network_Process+B2Dj
                                            ; DATA XREF: .text:00455F84o
    mov     edx, [esp+52Ch+PacketBuffer]    ; case 0x2a
    mov     al, [edx+1]
    mov     [edi+20h], al

    loc_455F50:                             ; CODE XREF: Network_Process+62j
                                            ; Network_Process+197j ...
    mov     eax, [esp+52Ch+var_43C]         ; default
    test    eax, eax
    jnz     loc_453D94
    call    sub_450980
    call    sub_453C20
    mov     eax, [esp+52Ch+var_4BC]
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi
    add     esp, 51Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_455F78:                             ; CODE XREF: Network_Process+C0j
    mov     [esp+52Ch+var_518], bl
    jmp     loc_453E19
    Network_Process endp

    ; ---------------------------------------------------------------------------
    align 4
    off_455F84 dd offset loc_454B2A         ; DATA XREF: Network_Process+B2Dr
    dd offset loc_455F50                    ; jump table for switch statement
    dd offset loc_455F50
    dd offset loc_45522E
    dd offset loc_45534E
    dd offset loc_4553B5
    dd offset loc_4553BE
    dd offset loc_4553DA
    dd offset loc_4553FE
    dd offset loc_45540D
    dd offset loc_45541C
    dd offset loc_45542D
    dd offset loc_45543D
    dd offset loc_45544D
    dd offset loc_4554EE
    dd offset loc_45555B
    dd offset loc_4555BA
    dd offset loc_45561A
    dd offset loc_455649
    dd offset loc_455785
    dd offset loc_4557AC
    dd offset loc_454946
    dd offset loc_454A58
    dd offset loc_45593D
    dd offset loc_455986
    dd offset loc_454E09
    dd offset loc_454EC4
    dd offset loc_4559C1
    dd offset loc_455162
    dd offset loc_45519A
    dd offset loc_454874
    dd offset loc_4559F5
    dd offset loc_455E3B
    dd offset loc_454B64
    dd offset loc_454D36
    dd offset loc_455F50
    dd offset loc_454B39
    dd offset loc_45525A
    dd offset loc_4558FE
    dd offset loc_45590E
    dd offset loc_455F46
    dd offset loc_455F50
    dd offset loc_4553EE

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_456030 proc near                    ; CODE XREF: Network_Process+549p
                                            ; sub_4568C0+77p
    cmp     dword ptr [ecx], 0
    jz      short loc_456046
    mov     al, [ecx+73h]
    cmp     al, 1
    jz      short loc_456040
    cmp     al, 2
    jnz     short loc_456046

    loc_456040:                             ; CODE XREF: sub_456030+Aj
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_456046:                             ; CODE XREF: sub_456030+3j
                                            ; sub_456030+Ej
    xor     eax, eax
    retn
    sub_456030 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_456050 proc near                    ; CODE XREF: sub_485F50+1C5p

    idTo= dword ptr -18h
    var_13= dword ptr -13h
    var_F= dword ptr -0Fh
    var_B= dword ptr -0Bh
    var_7= dword ptr -7
    var_3= word ptr -3
    arg_0= dword ptr  4

    sub     esp, 18h
    mov     eax, [esp+18h+arg_0]
    mov     byte ptr [esp+18h+idTo], 9
    push    17h                             ; idFrom
    mov     cx, [eax+0A6h]
    mov     dx, [eax+0A8h]
    mov     word ptr [esp+1Ch+idTo+1], cx
    lea     ecx, [eax+6Ah]
    mov     word ptr [esp+1Ch+idTo+3], dx
    mov     edx, [ecx]
    mov     [esp+1Ch+var_13], edx
    mov     edx, [ecx+4]
    mov     [esp+1Ch+var_F], edx
    lea     edx, [eax+64h]
    mov     ecx, [ecx+8]
    mov     [esp+1Ch+var_B], ecx
    mov     ecx, [edx]
    mov     [esp+1Ch+var_7], ecx
    lea     ecx, [esp+1Ch+idTo]
    mov     dx, [edx+4]
    push    ecx                             ; idTo
    mov     [esp+20h+var_3], dx
    mov     edx, [eax+96h]
    mov     eax, [edx+4]
    push    eax                             ; PlayerID
    call    sub_451DF0
    add     esp, 18h
    retn    4
    sub_456050 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4560C0 proc near                    ; CODE XREF: sub_41B8D0+156p
                                            ; sub_485F50+1DAp

    idTo= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 8
    mov     eax, [esp+8+arg_4]
    mov     byte ptr [esp+8+idTo], 12h
    push    5                               ; idFrom
    mov     cx, [eax+0A8h]
    mov     eax, [esp+0Ch+arg_0]
    mov     word ptr [esp+0Ch+idTo+1], cx
    lea     ecx, [esp+0Ch+idTo]
    mov     dx, [eax+0A8h]
    push    ecx                             ; idTo
    mov     word ptr [esp+10h+idTo+3], dx
    mov     edx, [eax+96h]
    mov     eax, [edx+4]
    push    eax                             ; PlayerID
    call    sub_451DF0
    add     esp, 8
    retn    8
    sub_4560C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    sub     esp, 18h
    push    esi
    mov     esi, [esp+20h]
    push    eax
    mov     ecx, [esi+9Ah]
    call    sub_4B07C0
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+2A44h], 1
    jnz     short loc_456140
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_456140:                             ; CODE XREF: .text:00456135j
    mov     dx, [esi+0A8h]
    mov     ecx, [esi+96h]
    mov     [esp+7], ax
    xor     eax, eax
    mov     [esp+9], al
    mov     [esp+0Ah], eax
    mov     [esp+0Eh], eax
    mov     [esp+12h], eax
    mov     [esp+16h], eax
    mov     byte ptr [esp+4], 10h
    mov     [esp+5], dx
    mov     edx, [ecx+4]
    lea     eax, [esp+4]
    push    16h
    push    eax
    push    edx
    call    sub_451DF0
    pop     esi
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_456190 proc near                    ; CODE XREF: sub_4385F0+42p
                                            ; sub_43A1F0+68p

    idTo= dword ptr -18h
    var_13= byte ptr -13h
    var_12= dword ptr -12h
    var_E= dword ptr -0Eh
    var_A= dword ptr -0Ah
    var_6= dword ptr -6
    arg_0= dword ptr  4
    arg_4= word ptr  8

    mov     eax, TAdynmemStructPtr
    sub     esp, 18h
    test    byte ptr [eax+2A44h], 1
    jnz     short loc_4561A9
    xor     eax, eax
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4561A9:                             ; CODE XREF: sub_456190+Fj
    mov     ax, [esp+18h+arg_4]
    mov     ecx, [esp+18h+arg_0]
    mov     word ptr [esp+18h+idTo+3], ax
    xor     eax, eax
    mov     dx, [ecx+0A8h]
    mov     [esp+18h+var_13], al
    mov     [esp+18h+var_12], eax
    mov     [esp+18h+var_E], eax
    mov     [esp+18h+var_A], eax
    mov     [esp+18h+var_6], eax
    mov     eax, [ecx+96h]
    mov     word ptr [esp+18h+idTo+1], dx
    mov     byte ptr [esp+18h+idTo], 10h
    lea     edx, [esp+18h+idTo]
    mov     ecx, [eax+4]
    push    16h                             ; idFrom
    push    edx                             ; idTo
    push    ecx                             ; PlayerID
    call    sub_451DF0
    add     esp, 18h
    retn    8
    sub_456190 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_456200 proc near                    ; CODE XREF: .text:00411403p
                                            ; sub_49E1A0+206p

    idTo= dword ptr -18h
    var_13= byte ptr -13h
    var_12= dword ptr -12h
    var_E= dword ptr -0Eh
    var_A= dword ptr -0Ah
    var_6= dword ptr -6
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    mov     eax, [esp+arg_4]
    sub     esp, 18h
    push    esi
    mov     esi, [esp+1Ch+arg_0]
    push    eax
    mov     ecx, [esi+9Ah]
    call    sub_4B07C0
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+2A44h], 1
    jnz     short loc_456230
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_456230:                             ; CODE XREF: sub_456200+25j
    mov     dx, [esi+0A8h]
    mov     ecx, [esp+1Ch+arg_C]
    mov     word ptr [esp+1Ch+idTo+3], ax
    mov     al, [esp+1Ch+arg_8]
    mov     [esp+1Ch+var_13], al
    mov     eax, [esp+1Ch+arg_14]
    mov     word ptr [esp+1Ch+idTo+1], dx
    mov     edx, [esp+1Ch+arg_10]
    mov     [esp+1Ch+var_12], ecx
    mov     ecx, [esp+1Ch+arg_18]
    mov     [esp+1Ch+var_A], eax
    mov     eax, [esi+96h]
    mov     [esp+1Ch+var_E], edx
    mov     byte ptr [esp+1Ch+idTo], 10h
    mov     [esp+1Ch+var_6], ecx
    mov     ecx, [eax+4]
    lea     edx, [esp+1Ch+idTo]
    push    16h                             ; idFrom
    push    edx                             ; idTo
    push    ecx                             ; PlayerID
    call    sub_451DF0
    pop     esi
    add     esp, 18h
    retn    1Ch
    sub_456200 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_456290 proc near                    ; CODE XREF: sub_438590+47p

    idTo= dword ptr -18h
    var_13= byte ptr -13h
    var_12= dword ptr -12h
    var_E= dword ptr -0Eh
    var_A= dword ptr -0Ah
    var_6= dword ptr -6
    arg_0= dword ptr  4
    arg_4= word ptr  8
    arg_8= byte ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    mov     eax, TAdynmemStructPtr
    sub     esp, 18h
    test    byte ptr [eax+2A44h], 1
    jnz     short loc_4562A9
    xor     eax, eax
    add     esp, 18h
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4562A9:                             ; CODE XREF: sub_456290+Fj
    mov     eax, [esp+18h+arg_0]
    mov     dx, [esp+18h+arg_4]
    mov     word ptr [esp+18h+idTo+3], dx
    mov     edx, [esp+18h+arg_C]
    mov     cx, [eax+0A8h]
    mov     eax, [eax+96h]
    mov     word ptr [esp+18h+idTo+1], cx
    mov     cl, [esp+18h+arg_8]
    mov     [esp+18h+var_13], cl
    mov     ecx, [esp+18h+arg_10]
    mov     [esp+18h+var_12], edx
    mov     edx, [esp+18h+arg_14]
    mov     [esp+18h+var_E], ecx
    mov     ecx, [esp+18h+arg_18]
    mov     [esp+18h+var_A], edx
    mov     byte ptr [esp+18h+idTo], 10h
    mov     [esp+18h+var_6], ecx
    mov     ecx, [eax+4]
    lea     edx, [esp+18h+idTo]
    push    16h                             ; idFrom
    push    edx                             ; idTo
    push    ecx                             ; PlayerID
    call    sub_451DF0
    add     esp, 18h
    retn    1Ch
    sub_456290 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_456310 proc near                    ; CODE XREF: .text:00443590j
                                            ; .text:0044AF94p ...

    idTo= dword ptr -0F8h
    var_F3= dword ptr -0F3h
    var_EF= dword ptr -0EFh
    var_E8= dword ptr -0E8h
    var_BC= dword ptr -0BCh
    var_2B= dword ptr -2Bh

    sub     esp, 0F8h
    call    sub_4B6340
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+1B5Fh]
    sub     eax, ecx
    cmp     eax, 3Ch
    jle     loc_45658A
    push    edi
    push    esi
    push    ebp
    add     ecx, 3Ch
    push    ebx
    mov     [edx+1B5Fh], ecx
    xor     ebx, ebx

    loc_456341:                             ; CODE XREF: sub_456310+181j
    mov     eax, TAdynmemStructPtr
    lea     ebp, [eax+ebx+1B63h]
    mov     eax, [eax+ebx+1B63h]
    test    eax, eax
    jz      loc_456485
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_45636B
    cmp     al, 2
    jnz     loc_456485

    loc_45636B:                             ; CODE XREF: sub_456310+51j
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_456380
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_456380:                             ; CODE XREF: sub_456310+62j
    mov     byte ptr [esp+108h+idTo], 2
    call    ds:__imp_GetTickCount
    mov     ecx, [ebp+4]
    push    0                               ; GuaranteePackets
    mov     [esp+10Ch+idTo+1], eax
    mov     [esp+10Ch+var_F3], 0
    mov     [esp+10Ch+var_EF], ecx
    call    HAPINET_GuaranteePackets
    mov     esi, eax
    mov     eax, [ebp+4]
    lea     edx, [esp+108h+idTo]
    push    0Dh                             ; idFrom
    push    edx                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_4563CC
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_4563CC:                             ; CODE XREF: sub_456310+AEj
    test    esi, esi
    jz      short loc_4563D7
    push    1                               ; GuaranteePackets
    call    HAPINET_GuaranteePackets

    loc_4563D7:                             ; CODE XREF: sub_456310+BEj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [ebp+4]
    push    1                               ; idFrom
    mov     eax, [edx+2A38h]
    push    eax                             ; idTo
    push    ecx                             ; PlayerID
    mov     byte ptr [eax], 6
    call    sub_451DF0
    mov     eax, [ebp+27h]
    cmp     byte ptr [eax+96h], 0FFh
    jnz     short loc_456405
    push    0
    call    sub_4526C0

    loc_456405:                             ; CODE XREF: sub_456310+ECj
    mov     ecx, [ebp+27h]
    test    byte ptr [ecx+97h], 1
    jz      short loc_456485
    xor     esi, esi
    mov     eax, 2C28h

    loc_456418:                             ; CODE XREF: sub_456310+148j
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+esi+1BD6h]
    cmp     dl, 4
    jnz     short loc_456433
    mov     dword ptr [ecx+eax], 0FFFFFFFFh
    jmp     short loc_45644A
    ; ---------------------------------------------------------------------------

    loc_456433:                             ; CODE XREF: sub_456310+118j
    test    dl, dl
    jnz     short loc_456440
    mov     dword ptr [ecx+eax], 0
    jmp     short loc_45644A
    ; ---------------------------------------------------------------------------

    loc_456440:                             ; CODE XREF: sub_456310+125j
    mov     edx, [ecx+esi+1B67h]
    mov     [ecx+eax], edx

    loc_45644A:                             ; CODE XREF: sub_456310+121j
                                            ; sub_456310+12Ej
    add     eax, 4
    add     esi, 14Bh
    cmp     eax, 2C50h
    jl      short loc_456418
    mov     eax, TAdynmemStructPtr
    mov     edx, [ebp+4]
    mov     ecx, 0Ah
    lea     edi, [esp+108h+var_E8+1]
    lea     esi, [eax+2C28h]
    push    29h                             ; idFrom
    rep movsd
    lea     ecx, [esp+10Ch+var_E8]
    mov     byte ptr [esp+10Ch+var_E8], 26h
    push    ecx                             ; idTo
    push    edx                             ; PlayerID
    call    sub_451DF0

    loc_456485:                             ; CODE XREF: sub_456310+46j
                                            ; sub_456310+55j ...
    add     ebx, 14Bh
    cmp     ebx, 0CEEh
    jl      loc_456341
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 1
    jz      loc_45657A
    xor     ebx, ebx

    loc_4564AB:                             ; CODE XREF: sub_456310+253j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+ebx+1B63h]
    lea     ebp, [ecx+ebx+1B63h]
    test    eax, eax
    jz      loc_456557
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_4564D6
    cmp     al, 2
    jnz     loc_456557

    loc_4564D6:                             ; CODE XREF: sub_456310+1BCj
    mov     esi, [ebp+27h]
    mov     ecx, 2Eh
    lea     edi, [esp+108h+var_BC+1]
    lea     eax, [esp+108h+var_BC]
    rep movsd
    movsb
    mov     edx, [ebp+4]
    mov     byte ptr [esp+108h+var_BC], 20h
    mov     [esp+108h+var_2B], edx
    mov     ecx, [ebp+4]
    push    0BAh                            ; idFrom
    push    eax                             ; idTo
    push    ecx                             ; PlayerID
    call    sub_451DF0
    cmp     dword ptr [ebp+0], 0
    jz      short loc_456557
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_456518
    cmp     al, 2
    jnz     short loc_456557

    loc_456518:                             ; CODE XREF: sub_456310+202j
    mov     edx, TAdynmemStructPtr
    push    6                               ; idFrom
    mov     eax, [edx+2A38h]
    push    eax                             ; idTo
    mov     byte ptr [eax], 24h
    mov     ecx, [ebp+4]
    mov     [eax+1], ecx
    mov     dl, [ebp+13Fh]
    mov     [eax+5], dl
    mov     eax, [ebp+4]
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_456557
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_456557:                             ; CODE XREF: sub_456310+1B1j
                                            ; sub_456310+1C0j ...
    add     ebx, 14Bh
    cmp     ebx, 0CEEh
    jl      loc_4564AB
    call    sub_450530
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_45657A:                             ; CODE XREF: sub_456310+193j
    mov     eax, TAdynmemStructPtr
    pop     ebx
    pop     ebp
    pop     esi
    or      byte ptr [eax+2BEEh], 1
    pop     edi

    loc_45658A:                             ; CODE XREF: sub_456310+1Cj
    add     esp, 0F8h
    retn
    sub_456310 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4565A0 proc near                    ; CODE XREF: Network_Process+DEFp

    arg_0= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     eax, [edi+5]
    test    eax, eax
    jnz     short loc_45661A
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_4565C4
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_4565C4:                             ; CODE XREF: sub_4565A0+16j
    call    ds:__imp_GetTickCount
    push    0                               ; GuaranteePackets
    mov     [edi+5], eax
    call    HAPINET_GuaranteePackets
    mov     ecx, TAdynmemStructPtr
    mov     esi, eax
    mov     eax, [edi+9]
    push    0Dh                             ; idFrom
    mov     edx, [ecx+4CDh]
    push    edi                             ; idTo
    push    eax                             ; PlayersToSendTo
    push    edx                             ; dwDataSize
    call    Network_BroadcastMessage
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_456604
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_456604:                             ; CODE XREF: sub_4565A0+56j
    test    esi, esi
    jz      loc_45674A
    push    1                               ; GuaranteePackets
    call    HAPINET_GuaranteePackets
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45661A:                             ; CODE XREF: sub_4565A0+Dj
    mov     esi, [edi+9]
    mov     edx, TAdynmemStructPtr
    cmp     esi, 0FFFFFFFFh
    jz      short loc_456677
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+arg_0], bl
    jz      short loc_456661

    loc_456633:                             ; CODE XREF: sub_4565A0+D5j
    mov     eax, [esp+arg_0]
    mov     ebp, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     cl, [ebp+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_456661
    mov     eax, [eax+1B67h]
    jmp     short loc_456664
    ; ---------------------------------------------------------------------------

    loc_456661:                             ; CODE XREF: sub_4565A0+91j
                                            ; sub_4565A0+B7j
    or      eax, 0FFFFFFFFh

    loc_456664:                             ; CODE XREF: sub_4565A0+BFj
    cmp     eax, esi
    jz      loc_456751
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+arg_0], bl
    jb      short loc_456633

    loc_456677:                             ; CODE XREF: sub_4565A0+86j
    mov     byte ptr [esp+arg_0], 0Ah

    loc_45667C:                             ; CODE XREF: sub_4565A0+1B5j
    mov     eax, [esp+arg_0]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2+1B63h]
    mov     ecx, [esi+ecx*2+1B63h]
    test    ecx, ecx
    jz      loc_45674A
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_4566B8
    cmp     al, 2
    jnz     loc_45674A

    loc_4566B8:                             ; CODE XREF: sub_4565A0+10Ej
    mov     esi, [edx+4C9h]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_456716
    xor     bl, bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+arg_0], bl
    jz      short loc_4566FC

    loc_4566CE:                             ; CODE XREF: sub_4565A0+16Cj
    mov     eax, [esp+arg_0]
    mov     ebp, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     cl, [ebp+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4566FC
    mov     eax, [eax+1B67h]
    jmp     short loc_4566FF
    ; ---------------------------------------------------------------------------

    loc_4566FC:                             ; CODE XREF: sub_4565A0+12Cj
                                            ; sub_4565A0+152j
    or      eax, 0FFFFFFFFh

    loc_4566FF:                             ; CODE XREF: sub_4565A0+15Aj
    cmp     eax, esi
    jz      short loc_456710
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+arg_0], bl
    jb      short loc_4566CE
    jmp     short loc_456716
    ; ---------------------------------------------------------------------------

    loc_456710:                             ; CODE XREF: sub_4565A0+161j
    mov     byte ptr [esp+arg_0], bl
    jmp     short loc_45671B
    ; ---------------------------------------------------------------------------

    loc_456716:                             ; CODE XREF: sub_4565A0+121j
                                            ; sub_4565A0+16Ej
    mov     byte ptr [esp+arg_0], 0Ah

    loc_45671B:                             ; CODE XREF: sub_4565A0+174j
    call    ds:__imp_GetTickCount
    mov     esi, [edi+1]
    mov     edx, eax
    mov     eax, [esp+arg_0]
    sub     edx, esi
    mov     esi, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     esi, eax
    lea     ecx, [ecx+ecx*4]
    mov     [esi+ecx*2+1B77h], edx

    loc_45674A:                             ; CODE XREF: sub_4565A0+66j
                                            ; sub_4565A0+103j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_456751:                             ; CODE XREF: sub_4565A0+C6j
    mov     byte ptr [esp+arg_0], bl
    jmp     loc_45667C
    sub_4565A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_456760 proc near                    ; CODE XREF: Battleroom_Unknown1+5B7p
                                            ; .text:0044AC46p

    var_1= dword ptr -1

    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    push    edi
    xor     edx, edx
    lea     eax, [esi+1B63h]
    mov     ecx, 0Ah

    loc_456778:                             ; CODE XREF: sub_456760+2Aj
    cmp     dword ptr [eax], 0
    jz      short loc_456784
    cmp     byte ptr [eax+73h], 3
    jnz     short loc_456784
    inc     edx

    loc_456784:                             ; CODE XREF: sub_456760+1Bj
                                            ; sub_456760+21j
    add     eax, 14Bh
    dec     ecx
    jnz     short loc_456778
    test    edx, edx
    jnz     short loc_456798
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_456798:                             ; CODE XREF: sub_456760+2Ej
    xor     dl, dl
    mov     edi, 1
    mov     byte ptr [esp+11h+var_1], dl
    mov     bl, 40h

    loc_4567A5:                             ; CODE XREF: sub_456760+C0j
    mov     eax, [esp+11h+var_1]
    mov     ebp, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+0]
    mov     ecx, [ebp+ecx*2+1B63h]
    test    ecx, ecx
    jz      short loc_456815
    mov     cl, [eax+1BD6h]
    cmp     cl, 1
    jz      short loc_4567EE
    cmp     cl, 2
    jz      short loc_4567EE
    mov     ecx, [eax+1B63h]
    test    ecx, ecx
    jz      short loc_456815
    cmp     byte ptr [eax+1BD6h], 3
    jnz     short loc_4567FD

    loc_4567EE:                             ; CODE XREF: sub_456760+74j
                                            ; sub_456760+79j
    mov     ecx, [eax+1B8Ah]
    test    byte ptr [ecx+9Bh], 20h
    jz      short loc_45682C

    loc_4567FD:                             ; CODE XREF: sub_456760+8Cj
    mov     ecx, [eax+1B63h]
    test    ecx, ecx
    jz      short loc_456815
    mov     eax, [eax+1B8Ah]
    test    [eax+9Bh], bl
    jnz     short loc_456817

    loc_456815:                             ; CODE XREF: sub_456760+69j
                                            ; sub_456760+83j ...
    xor     edi, edi

    loc_456817:                             ; CODE XREF: sub_456760+B3j
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+11h+var_1], dl
    jb      short loc_4567A5
    cmp     word ptr [esi+2A3Ch], 1
    jnz     short loc_456834

    loc_45682C:                             ; CODE XREF: sub_456760+9Bj
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_456834:                             ; CODE XREF: sub_456760+CAj
    xor     eax, eax
    test    edi, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    setz    al
    pop     ecx
    retn
    sub_456760 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_456850()
    sub_456850 proc near                    ; CODE XREF: .text:00440CEBp
                                            ; sub_4437C0+3BDp ...

    PlayerIndex= dword ptr -1

    push    ecx
    push    ebx
    xor     al, al
    push    esi
    mov     esi, TAdynmemStructPtr
    push    edi
    mov     byte ptr [esp+0Dh+PlayerIndex], al
    mov     bl, 1

    loc_456862:                             ; CODE XREF: sub_456850+4Ej
    mov     ecx, [esp+0Dh+PlayerIndex]
    mov     edi, esi
    and     ecx, 0FFh
    mov     edx, ecx
    add     edi, ecx
    shl     edx, 5
    add     edx, ecx
    lea     edx, [edx+edx*4]
    lea     ecx, [edi+edx*2]
    mov     dl, [edi+edx*2+TAdynmemStruct.Players.PlayerType]
    test    dl, dl
    jz      short loc_456896
    mov     ecx, [ecx+TAdynmemStruct.Players.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], bl
    jnz     short loc_4568A2

    loc_456896:                             ; CODE XREF: sub_456850+36j
    inc     al
    cmp     al, 10
    mov     byte ptr [esp+0Dh+PlayerIndex], al
    jb      short loc_456862
    mov     al, 10

    loc_4568A2:                             ; CODE XREF: sub_456850+44j
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    sub_456850 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_12. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4568C0 proc near                    ; CODE XREF: sub_496790+C3p
                                            ; sub_497F40+607p

    idTo= dword ptr -33h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h

    sub     esp, 34h
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    ebp
    xor     bl, bl
    push    esi
    push    edi
    mov     byte ptr [esp+44h+idTo+3], bl

    loc_4568D3:                             ; CODE XREF: sub_4568C0+54j
    mov     eax, [esp+44h+idTo+3]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_45690B
    mov     eax, [eax+1B8Ah]
    test    byte ptr [eax+97h], 1
    jnz     loc_456DD5

    loc_45690B:                             ; CODE XREF: sub_4568C0+36j
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+44h+idTo+3], bl
    jb      short loc_4568D3
    mov     byte ptr [esp+44h+idTo+3], 0Ah

    loc_45691B:                             ; CODE XREF: sub_4568C0+519j
    mov     eax, [esp+44h+idTo+3]
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [edx+ecx*2+1B63h]
    call    sub_456030
    mov     edx, TAdynmemStructPtr
    mov     edi, eax
    test    edi, edi
    mov     [esp+44h+var_2C], edi
    jz      loc_456B79
    mov     eax, [edx+2A28h]
    test    eax, eax
    jnz     loc_456B79
    xor     ecx, ecx
    mov     edi, edx
    mov     cl, [edx+2A42h]
    lea     esi, [edx+29FCh]
    mov     eax, ecx
    add     edi, ecx
    shl     eax, 5
    add     eax, ecx
    mov     [esp+44h+idTo+3], esi
    lea     eax, [eax+eax*4]
    mov     ecx, [edi+eax*2+1B8Ah]
    mov     ax, [ecx+9Bh]
    shr     eax, 0Eh
    test    al, 1
    jz      short loc_4569F9
    xor     edi, edi
    xor     eax, eax
    jmp     short loc_45699F
    ; ---------------------------------------------------------------------------

    loc_456999:                             ; CODE XREF: sub_4568C0+132j
    mov     edx, TAdynmemStructPtr

    loc_45699F:                             ; CODE XREF: sub_4568C0+D7j
    mov     ecx, [edx+eax+1B63h]
    test    ecx, ecx
    jz      short loc_4569DF
    mov     cl, [edx+eax+1BD6h]
    cmp     cl, 1
    jz      short loc_4569C0
    cmp     cl, 2
    jz      short loc_4569C0
    cmp     cl, 3
    jnz     short loc_4569DF

    loc_4569C0:                             ; CODE XREF: sub_4568C0+F4j
                                            ; sub_4568C0+F9j
    cmp     byte ptr [edx+eax+1CA9h], 0Ah
    jz      short loc_4569DF
    mov     ecx, [edx+eax+1B8Ah]
    test    byte ptr [ecx+9Bh], 40h
    jnz     short loc_4569DF
    mov     [esi], edi
    inc     edi
    jmp     short loc_4569E5
    ; ---------------------------------------------------------------------------

    loc_4569DF:                             ; CODE XREF: sub_4568C0+E8j
                                            ; sub_4568C0+FEj ...
    mov     dword ptr [esi], 0FFFFFFFFh

    loc_4569E5:                             ; CODE XREF: sub_4568C0+11Dj
    add     eax, 14Bh
    add     esi, 4
    cmp     eax, 0CEEh
    jl      short loc_456999
    jmp     loc_456B60
    ; ---------------------------------------------------------------------------

    loc_4569F9:                             ; CODE XREF: sub_4568C0+D1j
    mov     ecx, 0Ah
    or      eax, 0FFFFFFFFh
    lea     edi, [esp+44h+var_28]
    xor     esi, esi
    rep stosd
    lea     edi, [esp+44h+var_28]
    lea     eax, [edx+1BD6h]
    mov     ebx, 0Ah

    loc_456A18:                             ; CODE XREF: sub_4568C0+191j
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_456A4B
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_456A30
    cmp     cl, 2
    jz      short loc_456A30
    cmp     cl, 3
    jnz     short loc_456A4B

    loc_456A30:                             ; CODE XREF: sub_4568C0+164j
                                            ; sub_4568C0+169j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_456A4B
    mov     ecx, [eax-4Ch]
    test    byte ptr [ecx+9Bh], 40h
    jnz     short loc_456A4B
    mov     [edi], esi
    inc     esi
    add     edi, 4

    loc_456A4B:                             ; CODE XREF: sub_4568C0+15Dj
                                            ; sub_4568C0+16Ej ...
    add     eax, 14Bh
    dec     ebx
    jnz     short loc_456A18
    cmp     esi, 2
    jg      short loc_456A81
    call    _rand
    cdq
    push    0
    push    2
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    test    eax, eax
    jz      short loc_456AE4
    mov     edx, TAdynmemStructPtr

    loc_456A81:                             ; CODE XREF: sub_4568C0+196j
    lea     ebx, [esp+esi*4+44h+var_28]
    lea     eax, [esp+44h+var_28]
    cmp     eax, ebx
    jz      short loc_456AEA
    lea     ecx, [esp+44h+var_24]
    mov     edi, 1
    cmp     ecx, ebx
    lea     ebp, [esp+44h+var_24]
    jz      short loc_456AEA

    loc_456A9E:                             ; CODE XREF: sub_4568C0+222j
    mov     esi, 7FFFh
    call    _rand
    and     eax, esi
    cmp     edi, esi
    jbe     short loc_456AC8

    loc_456AAE:                             ; CODE XREF: sub_4568C0+206j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_456AC8
    shl     esi, 0Fh
    shl     eax, 0Fh
    or      esi, 7FFFh
    or      eax, 7FFFh
    cmp     esi, edi
    jb      short loc_456AAE

    loc_456AC8:                             ; CODE XREF: sub_4568C0+1ECj
                                            ; sub_4568C0+1F1j
    xor     edx, edx
    mov     ecx, [ebp+0]
    div     edi
    add     ebp, 4
    inc     edi
    cmp     ebp, ebx
    lea     eax, [esp+edx*4+44h+var_28]
    mov     edx, [esp+edx*4+44h+var_28]
    mov     [ebp-4], edx
    mov     [eax], ecx
    jnz     short loc_456A9E

    loc_456AE4:                             ; CODE XREF: sub_4568C0+1B9j
    mov     edx, TAdynmemStructPtr

    loc_456AEA:                             ; CODE XREF: sub_4568C0+1CBj
                                            ; sub_4568C0+1DCj
    mov     esi, [esp+44h+idTo+3]
    xor     eax, eax
    lea     edi, [esp+44h+var_28]
    jmp     short loc_456AFC
    ; ---------------------------------------------------------------------------

    loc_456AF6:                             ; CODE XREF: sub_4568C0+29Ej
    mov     edx, TAdynmemStructPtr

    loc_456AFC:                             ; CODE XREF: sub_4568C0+234j
    mov     ecx, [edx+eax+1B63h]
    test    ecx, ecx
    jz      short loc_456B4B
    mov     cl, [edx+eax+1BD6h]
    cmp     cl, 1
    jz      short loc_456B1D
    cmp     cl, 2
    jz      short loc_456B1D
    cmp     cl, 3
    jnz     short loc_456B4B

    loc_456B1D:                             ; CODE XREF: sub_4568C0+251j
                                            ; sub_4568C0+256j
    cmp     byte ptr [edx+eax+1CA9h], 0Ah
    jz      short loc_456B4B
    mov     ecx, [edx+eax+1B63h]
    test    ecx, ecx
    jz      short loc_456B42
    mov     ecx, [edx+eax+1B8Ah]
    test    byte ptr [ecx+9Bh], 40h
    jnz     short loc_456B4B

    loc_456B42:                             ; CODE XREF: sub_4568C0+270j
    mov     edx, [edi]
    add     edi, 4
    mov     [esi], edx
    jmp     short loc_456B51
    ; ---------------------------------------------------------------------------

    loc_456B4B:                             ; CODE XREF: sub_4568C0+245j
                                            ; sub_4568C0+25Bj ...
    mov     dword ptr [esi], 0FFFFFFFFh

    loc_456B51:                             ; CODE XREF: sub_4568C0+289j
    add     eax, 14Bh
    add     esi, 4
    cmp     eax, 0CEEh
    jl      short loc_456AF6

    loc_456B60:                             ; CODE XREF: sub_4568C0+134j
    mov     eax, TAdynmemStructPtr
    mov     edi, [esp+44h+var_2C]
    mov     dword ptr [eax+2A28h], 1
    mov     edx, TAdynmemStructPtr

    loc_456B79:                             ; CODE XREF: sub_4568C0+8Aj
                                            ; sub_4568C0+98j
    xor     ebx, ebx
    mov     [esp+44h+idTo+3], 1
    xor     ecx, ecx
    lea     eax, [edx+29A4h]
    lea     esi, [edx+1B63h]

    loc_456B91:                             ; CODE XREF: sub_4568C0+2FDj
    cmp     [esi], ebx
    jz      short loc_456BB0
    cmp     byte ptr [esi+73h], 3
    jnz     short loc_456BB0
    cmp     edi, ebx
    jz      short loc_456BAC
    cmp     [eax], ebx
    jz      short loc_456BC1
    cmp     [eax+2Ch], ebx
    jz      short loc_456BC1
    cmp     edi, ebx
    jnz     short loc_456BB0

    loc_456BAC:                             ; CODE XREF: sub_4568C0+2DDj
    cmp     [eax], ebx
    jz      short loc_456BC1

    loc_456BB0:                             ; CODE XREF: sub_4568C0+2D3j
                                            ; sub_4568C0+2D9j ...
    inc     ecx
    add     eax, 4
    add     esi, 14Bh
    cmp     ecx, 0Ah
    jl      short loc_456B91
    jmp     short loc_456BC5
    ; ---------------------------------------------------------------------------

    loc_456BC1:                             ; CODE XREF: sub_4568C0+2E1j
                                            ; sub_4568C0+2E6j ...
    mov     [esp+44h+idTo+3], ebx

    loc_456BC5:                             ; CODE XREF: sub_4568C0+2FFj
    cmp     edi, ebx
    jz      loc_456CC6
    xor     ebx, ebx
    xor     ebp, ebp
    mov     esi, 29D0h

    loc_456BD6:                             ; CODE XREF: sub_4568C0+400j
    cmp     dword ptr [edx+esi], 0
    jnz     loc_456CB0
    mov     byte ptr [esp+44h+idTo+1], 1Eh
    mov     cl, [edx+esi+2Ch]
    mov     byte ptr [esp+44h+idTo+2], cl
    mov     eax, [edx+ebp+1B63h]
    test    eax, eax
    jz      loc_456CB0
    cmp     byte ptr [edx+ebp+1BD6h], 3
    jnz     short loc_456C7C
    cmp     bl, 0Ah
    jz      short loc_456C36
    mov     eax, ebx
    mov     edi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2]
    mov     cl, [edi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_456C36
    mov     edi, [eax+1B67h]
    jmp     short loc_456C39
    ; ---------------------------------------------------------------------------

    loc_456C36:                             ; CODE XREF: sub_4568C0+349j
                                            ; sub_4568C0+36Cj
    or      edi, 0FFFFFFFFh

    loc_456C39:                             ; CODE XREF: sub_4568C0+374j
    xor     eax, eax
    lea     ecx, [edx+1BD6h]

    loc_456C41:                             ; CODE XREF: sub_4568C0+390j
    cmp     byte ptr [ecx], 1
    jz      short loc_456C54
    inc     eax
    add     ecx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_456C41
    jmp     short loc_456C69
    ; ---------------------------------------------------------------------------

    loc_456C54:                             ; CODE XREF: sub_4568C0+384j
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*4]
    mov     edx, [edx+ecx*2+1B67h]
    jmp     short loc_456C6C
    ; ---------------------------------------------------------------------------

    loc_456C69:                             ; CODE XREF: sub_4568C0+392j
    or      edx, 0FFFFFFFFh

    loc_456C6C:                             ; CODE XREF: sub_4568C0+3A7j
    lea     eax, [esp+44h+idTo+1]
    push    2                               ; idFrom
    push    eax                             ; idTo
    push    edi                             ; PlayersToSendTo
    push    edx                             ; dwDataSize
    call    Network_BroadcastMessage
    jmp     short loc_456CAA
    ; ---------------------------------------------------------------------------

    loc_456C7C:                             ; CODE XREF: sub_4568C0+344j
    mov     eax, [edx+ebp+1B63h]
    test    eax, eax
    jz      short loc_456CB0
    mov     al, [edx+ebp+1BD6h]
    cmp     al, 1
    jz      short loc_456C96
    cmp     al, 2
    jnz     short loc_456CB0

    loc_456C96:                             ; CODE XREF: sub_4568C0+3D0j
    mov     [edx+ebp+1CAAh], cl
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+esi], 1

    loc_456CAA:                             ; CODE XREF: sub_4568C0+3BAj
    mov     edx, TAdynmemStructPtr

    loc_456CB0:                             ; CODE XREF: sub_4568C0+31Aj
                                            ; sub_4568C0+336j ...
    add     esi, 4
    inc     ebx
    add     ebp, 14Bh
    cmp     esi, 29F8h
    jl      loc_456BD6

    loc_456CC6:                             ; CODE XREF: sub_4568C0+307j
    mov     eax, [esp+44h+var_2C]
    mov     byte ptr [esp+44h+idTo], 15h
    test    eax, eax
    jnz     short loc_456D50
    xor     ebx, ebx
    xor     esi, esi

    loc_456CD7:                             ; CODE XREF: sub_4568C0+482j
    mov     eax, [edx+esi+1B63h]
    test    eax, eax
    jz      short loc_456D35
    mov     al, [edx+esi+1BD6h]
    cmp     al, 1
    jz      short loc_456CF1
    cmp     al, 2
    jnz     short loc_456D35

    loc_456CF1:                             ; CODE XREF: sub_4568C0+42Bj
    cmp     bl, 0Ah
    jz      short loc_456D1F
    mov     eax, ebx
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2]
    mov     cl, [edx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_456D1F
    mov     eax, [eax+1B67h]
    jmp     short loc_456D22
    ; ---------------------------------------------------------------------------

    loc_456D1F:                             ; CODE XREF: sub_4568C0+434j
                                            ; sub_4568C0+455j
    or      eax, 0FFFFFFFFh

    loc_456D22:                             ; CODE XREF: sub_4568C0+45Dj
    lea     edx, [esp+44h+idTo]
    push    1                               ; idFrom
    push    edx                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     edx, TAdynmemStructPtr

    loc_456D35:                             ; CODE XREF: sub_4568C0+420j
                                            ; sub_4568C0+42Fj
    add     esi, 14Bh
    inc     ebx
    cmp     esi, 0CEEh
    jl      short loc_456CD7
    mov     eax, [esp+44h+idTo+3]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------

    loc_456D50:                             ; CODE XREF: sub_4568C0+411j
    mov     eax, [esp+44h+idTo+3]
    test    eax, eax
    jz      short loc_456DC9
    xor     ebx, ebx
    xor     esi, esi

    loc_456D5C:                             ; CODE XREF: sub_4568C0+507j
    mov     eax, [edx+esi+1B63h]
    test    eax, eax
    jz      short loc_456DBA
    mov     al, [edx+esi+1BD6h]
    cmp     al, 1
    jz      short loc_456D76
    cmp     al, 2
    jnz     short loc_456DBA

    loc_456D76:                             ; CODE XREF: sub_4568C0+4B0j
    cmp     bl, 0Ah
    jz      short loc_456DA4
    mov     eax, ebx
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2]
    mov     cl, [edx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_456DA4
    mov     eax, [eax+1B67h]
    jmp     short loc_456DA7
    ; ---------------------------------------------------------------------------

    loc_456DA4:                             ; CODE XREF: sub_4568C0+4B9j
                                            ; sub_4568C0+4DAj
    or      eax, 0FFFFFFFFh

    loc_456DA7:                             ; CODE XREF: sub_4568C0+4E2j
    lea     edx, [esp+44h+idTo]
    push    1                               ; idFrom
    push    edx                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     edx, TAdynmemStructPtr

    loc_456DBA:                             ; CODE XREF: sub_4568C0+4A5j
                                            ; sub_4568C0+4B4j
    add     esi, 14Bh
    inc     ebx
    cmp     esi, 0CEEh
    jl      short loc_456D5C

    loc_456DC9:                             ; CODE XREF: sub_4568C0+496j
    mov     eax, [esp+44h+idTo+3]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------

    loc_456DD5:                             ; CODE XREF: sub_4568C0+45j
    mov     byte ptr [esp+44h+idTo+3], bl
    jmp     loc_45691B
    sub_4568C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_456DE0 proc near                    ; CODE XREF: sub_497F40+D5Ep

    var_1= byte ptr -1

    push    ecx
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [esp+2], 2Ah
    push    ebx
    push    esi
    mov     dl, [ecx+38D6Fh]
    mov     al, [ecx+38D74h]
    and     edx, 0FFh
    and     eax, 0FFh
    add     edx, eax
    mov     al, [ecx+38D73h]
    and     eax, 0FFh
    xor     ebx, ebx
    add     edx, eax
    mov     al, [ecx+38D72h]
    and     eax, 0FFh
    add     edx, eax
    mov     al, [ecx+38D71h]
    and     eax, 0FFh
    add     edx, eax
    mov     al, [ecx+38D70h]
    and     eax, 0FFh
    add     edx, eax
    mov     eax, 2AAAAAABh
    imul    edx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    xor     esi, esi
    mov     [esp+0Ch+var_1], dl

    loc_456E51:                             ; CODE XREF: sub_456DE0+EDj
    mov     eax, [ecx+esi+1B63h]
    test    eax, eax
    jz      short loc_456EC0
    mov     al, [ecx+esi+1BD6h]
    cmp     al, 1
    jz      short loc_456E6B
    cmp     al, 2
    jnz     short loc_456EC0

    loc_456E6B:                             ; CODE XREF: sub_456DE0+85j
    cmp     bl, 0Ah
    mov     [ecx+esi+1B83h], dl
    jz      short loc_456EA6
    mov     eax, ebx
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2]
    mov     cl, [edx+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_456EA6
    mov     eax, [eax+1B67h]
    jmp     short loc_456EA9
    ; ---------------------------------------------------------------------------

    loc_456EA6:                             ; CODE XREF: sub_456DE0+95j
                                            ; sub_456DE0+BCj
    or      eax, 0FFFFFFFFh

    loc_456EA9:                             ; CODE XREF: sub_456DE0+C4j
    lea     ecx, [esp+0Ah]
    push    2                               ; idFrom
    push    ecx                             ; idTo
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     ecx, TAdynmemStructPtr
    mov     dl, [esp+0Ch+var_1]

    loc_456EC0:                             ; CODE XREF: sub_456DE0+7Aj
                                            ; sub_456DE0+89j
    add     esi, 14Bh
    inc     ebx
    cmp     esi, 0CEEh
    jl      short loc_456E51
    pop     esi
    pop     ebx
    pop     ecx
    retn
    sub_456DE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_456EE0 proc near                    ; CODE XREF: sub_464B30+121p

    idTo= dword ptr -14h
    var_F= dword ptr -0Fh
    var_B= dword ptr -0Bh
    var_7= dword ptr -7
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    sub     esp, 14h
    mov     ecx, eax
    push    ebx
    mov     ebx, [esp+18h+arg_4]
    shl     ecx, 5
    push    esi
    add     ecx, eax
    mov     esi, edx
    add     esi, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, ebx
    and     eax, 0FFh
    lea     esi, [esi+ecx*2]
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    mov     eax, [esi+1B63h]
    test    eax, eax
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [edx+ecx*2]
    jz      loc_457048
    mov     al, [esi+1BD6h]
    cmp     al, 1
    jz      short loc_456F43
    cmp     al, 2
    jz      short loc_456F43
    cmp     al, 3
    jnz     loc_457048

    loc_456F43:                             ; CODE XREF: sub_456EE0+55j
                                            ; sub_456EE0+59j
    cmp     byte ptr [esi+1CA9h], 0Ah
    jz      loc_457048
    cmp     word ptr [esi+1CA7h], 0
    jnz     short loc_456F68
    mov     eax, [esi+1CA3h]
    test    eax, eax
    jnz     loc_457048

    loc_456F68:                             ; CODE XREF: sub_456EE0+78j
    mov     eax, [ecx+1B63h]
    test    eax, eax
    jz      loc_457048
    mov     al, [ecx+1BD6h]
    cmp     al, 1
    jz      short loc_456F8C
    cmp     al, 2
    jz      short loc_456F8C
    cmp     al, 3
    jnz     loc_457048

    loc_456F8C:                             ; CODE XREF: sub_456EE0+9Ej
                                            ; sub_456EE0+A2j
    cmp     byte ptr [ecx+1CA9h], 0Ah
    jz      loc_457048
    cmp     word ptr [ecx+1CA7h], 0
    jnz     short loc_456FB1
    mov     eax, [ecx+1CA3h]
    test    eax, eax
    jnz     loc_457048

    loc_456FB1:                             ; CODE XREF: sub_456EE0+C1j
    mov     dl, byte ptr [esp+1Ch+arg_0]
    mov     byte ptr [esp+1Ch+idTo], 16h
    cmp     dl, 0Ah
    mov     [esp+1Ch+idTo+1], 1
    jz      short loc_456FD9
    mov     al, [esi+1BD6h]
    test    al, al
    jz      short loc_456FD9
    mov     eax, [esi+1B67h]
    jmp     short loc_456FDC
    ; ---------------------------------------------------------------------------

    loc_456FD9:                             ; CODE XREF: sub_456EE0+E5j
                                            ; sub_456EE0+EFj
    or      eax, 0FFFFFFFFh

    loc_456FDC:                             ; CODE XREF: sub_456EE0+F7j
    cmp     bl, 0Ah
    mov     [esp+1Ch+var_F], eax
    jz      short loc_456FF7
    mov     al, [ecx+1BD6h]
    test    al, al
    jz      short loc_456FF7
    mov     eax, [ecx+1B67h]
    jmp     short loc_456FFA
    ; ---------------------------------------------------------------------------

    loc_456FF7:                             ; CODE XREF: sub_456EE0+103j
                                            ; sub_456EE0+10Dj
    or      eax, 0FFFFFFFFh

    loc_456FFA:                             ; CODE XREF: sub_456EE0+115j
    mov     [esp+1Ch+var_B], eax
    mov     eax, [esp+1Ch+arg_8]
    cmp     bl, 0Ah
    mov     [esp+1Ch+var_7], eax
    jz      short loc_45701D
    mov     al, [ecx+1BD6h]
    test    al, al
    jz      short loc_45701D
    mov     ecx, [ecx+1B67h]
    jmp     short loc_457020
    ; ---------------------------------------------------------------------------

    loc_45701D:                             ; CODE XREF: sub_456EE0+129j
                                            ; sub_456EE0+133j
    or      ecx, 0FFFFFFFFh

    loc_457020:                             ; CODE XREF: sub_456EE0+13Bj
    cmp     dl, 0Ah
    jz      short loc_457037
    mov     al, [esi+1BD6h]
    test    al, al
    jz      short loc_457037
    mov     esi, [esi+1B67h]
    jmp     short loc_45703A
    ; ---------------------------------------------------------------------------

    loc_457037:                             ; CODE XREF: sub_456EE0+143j
                                            ; sub_456EE0+14Dj
    or      esi, 0FFFFFFFFh

    loc_45703A:                             ; CODE XREF: sub_456EE0+155j
    lea     edx, [esp+1Ch+idTo]
    push    11h                             ; idFrom
    push    edx                             ; idTo
    push    ecx                             ; PlayersToSendTo
    push    esi                             ; dwDataSize
    call    Network_BroadcastMessage

    loc_457048:                             ; CODE XREF: sub_456EE0+47j
                                            ; sub_456EE0+5Dj ...
    pop     esi
    pop     ebx
    add     esp, 14h
    retn    0Ch
    sub_456EE0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_457050 proc near                    ; CODE XREF: sub_464C60+125p

    idTo= dword ptr -14h
    var_F= dword ptr -0Fh
    var_B= dword ptr -0Bh
    var_7= dword ptr -7
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    sub     esp, 14h
    mov     ecx, eax
    push    ebx
    mov     ebx, [esp+18h+arg_4]
    shl     ecx, 5
    push    esi
    add     ecx, eax
    mov     esi, edx
    add     esi, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, ebx
    and     eax, 0FFh
    lea     esi, [esi+ecx*2]
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    mov     eax, [esi+1B63h]
    test    eax, eax
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [edx+ecx*2]
    jz      loc_4571B8
    mov     al, [esi+1BD6h]
    cmp     al, 1
    jz      short loc_4570B3
    cmp     al, 2
    jz      short loc_4570B3
    cmp     al, 3
    jnz     loc_4571B8

    loc_4570B3:                             ; CODE XREF: sub_457050+55j
                                            ; sub_457050+59j
    cmp     byte ptr [esi+1CA9h], 0Ah
    jz      loc_4571B8
    cmp     word ptr [esi+1CA7h], 0
    jnz     short loc_4570D8
    mov     eax, [esi+1CA3h]
    test    eax, eax
    jnz     loc_4571B8

    loc_4570D8:                             ; CODE XREF: sub_457050+78j
    mov     eax, [ecx+1B63h]
    test    eax, eax
    jz      loc_4571B8
    mov     al, [ecx+1BD6h]
    cmp     al, 1
    jz      short loc_4570FC
    cmp     al, 2
    jz      short loc_4570FC
    cmp     al, 3
    jnz     loc_4571B8

    loc_4570FC:                             ; CODE XREF: sub_457050+9Ej
                                            ; sub_457050+A2j
    cmp     byte ptr [ecx+1CA9h], 0Ah
    jz      loc_4571B8
    cmp     word ptr [ecx+1CA7h], 0
    jnz     short loc_457121
    mov     eax, [ecx+1CA3h]
    test    eax, eax
    jnz     loc_4571B8

    loc_457121:                             ; CODE XREF: sub_457050+C1j
    mov     dl, byte ptr [esp+1Ch+arg_0]
    mov     byte ptr [esp+1Ch+idTo], 16h
    cmp     dl, 0Ah
    mov     [esp+1Ch+idTo+1], 2
    jz      short loc_457149
    mov     al, [esi+1BD6h]
    test    al, al
    jz      short loc_457149
    mov     eax, [esi+1B67h]
    jmp     short loc_45714C
    ; ---------------------------------------------------------------------------

    loc_457149:                             ; CODE XREF: sub_457050+E5j
                                            ; sub_457050+EFj
    or      eax, 0FFFFFFFFh

    loc_45714C:                             ; CODE XREF: sub_457050+F7j
    cmp     bl, 0Ah
    mov     [esp+1Ch+var_F], eax
    jz      short loc_457167
    mov     al, [ecx+1BD6h]
    test    al, al
    jz      short loc_457167
    mov     eax, [ecx+1B67h]
    jmp     short loc_45716A
    ; ---------------------------------------------------------------------------

    loc_457167:                             ; CODE XREF: sub_457050+103j
                                            ; sub_457050+10Dj
    or      eax, 0FFFFFFFFh

    loc_45716A:                             ; CODE XREF: sub_457050+115j
    mov     [esp+1Ch+var_B], eax
    mov     eax, [esp+1Ch+arg_8]
    cmp     bl, 0Ah
    mov     [esp+1Ch+var_7], eax
    jz      short loc_45718D
    mov     al, [ecx+1BD6h]
    test    al, al
    jz      short loc_45718D
    mov     ecx, [ecx+1B67h]
    jmp     short loc_457190
    ; ---------------------------------------------------------------------------

    loc_45718D:                             ; CODE XREF: sub_457050+129j
                                            ; sub_457050+133j
    or      ecx, 0FFFFFFFFh

    loc_457190:                             ; CODE XREF: sub_457050+13Bj
    cmp     dl, 0Ah
    jz      short loc_4571A7
    mov     al, [esi+1BD6h]
    test    al, al
    jz      short loc_4571A7
    mov     esi, [esi+1B67h]
    jmp     short loc_4571AA
    ; ---------------------------------------------------------------------------

    loc_4571A7:                             ; CODE XREF: sub_457050+143j
                                            ; sub_457050+14Dj
    or      esi, 0FFFFFFFFh

    loc_4571AA:                             ; CODE XREF: sub_457050+155j
    lea     edx, [esp+1Ch+idTo]
    push    11h                             ; idFrom
    push    edx                             ; idTo
    push    ecx                             ; PlayersToSendTo
    push    esi                             ; dwDataSize
    call    Network_BroadcastMessage

    loc_4571B8:                             ; CODE XREF: sub_457050+47j
                                            ; sub_457050+5Dj ...
    pop     esi
    pop     ebx
    add     esp, 14h
    retn    0Ch
    sub_457050 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4571C0 proc near                    ; CODE XREF: sub_4934B0+1F7p

    idTo= dword ptr -14h
    var_F= dword ptr -0Fh
    var_B= dword ptr -0Bh
    var_7= dword ptr -7
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_0]
    sub     esp, 14h
    cmp     dl, 0Ah
    jz      loc_457294
    mov     ecx, [esp+14h+arg_4]
    cmp     cl, 0Ah
    jz      loc_457294
    and     edx, 0FFh
    push    edi
    mov     eax, edx
    push    esi
    mov     esi, TAdynmemStructPtr
    mov     byte ptr [esp+1Ch+idTo], 16h
    shl     eax, 5
    add     eax, edx
    mov     edi, esi
    add     edi, edx
    mov     [esp+1Ch+idTo+1], 3
    lea     eax, [eax+eax*4]
    lea     edx, [edi+eax*2]
    mov     al, [edi+eax*2+1BD6h]
    test    al, al
    jz      short loc_45721C
    mov     eax, [edx+1B67h]
    jmp     short loc_45721F
    ; ---------------------------------------------------------------------------

    loc_45721C:                             ; CODE XREF: sub_4571C0+52j
    or      eax, 0FFFFFFFFh

    loc_45721F:                             ; CODE XREF: sub_4571C0+5Aj
    and     ecx, 0FFh
    mov     [esp+1Ch+var_F], eax
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     cl, [esi+eax*2+1BD6h]
    lea     eax, [esi+eax*2]
    test    cl, cl
    jz      short loc_45724B
    mov     ecx, [eax+1B67h]
    jmp     short loc_45724E
    ; ---------------------------------------------------------------------------

    loc_45724B:                             ; CODE XREF: sub_4571C0+81j
    or      ecx, 0FFFFFFFFh

    loc_45724E:                             ; CODE XREF: sub_4571C0+89j
    mov     [esp+1Ch+var_B], ecx
    mov     [esp+1Ch+var_7], 0
    mov     cl, [eax+1BD6h]
    test    cl, cl
    jz      short loc_45726C
    mov     eax, [eax+1B67h]
    jmp     short loc_45726F
    ; ---------------------------------------------------------------------------

    loc_45726C:                             ; CODE XREF: sub_4571C0+A2j
    or      eax, 0FFFFFFFFh

    loc_45726F:                             ; CODE XREF: sub_4571C0+AAj
    mov     cl, [edx+1BD6h]
    test    cl, cl
    jz      short loc_457281
    mov     edx, [edx+1B67h]
    jmp     short loc_457284
    ; ---------------------------------------------------------------------------

    loc_457281:                             ; CODE XREF: sub_4571C0+B7j
    or      edx, 0FFFFFFFFh

    loc_457284:                             ; CODE XREF: sub_4571C0+BFj
    lea     ecx, [esp+1Ch+idTo]
    push    11h                             ; idFrom
    push    ecx                             ; idTo
    push    eax                             ; PlayersToSendTo
    push    edx                             ; dwDataSize
    call    Network_BroadcastMessage
    pop     esi
    pop     edi

    loc_457294:                             ; CODE XREF: sub_4571C0+Aj
                                            ; sub_4571C0+17j
    add     esp, 14h
    retn    8
    sub_4571C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4572A0 proc near                    ; CODE XREF: .text:00499639p

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    mov     ebx, 1
    xor     ecx, ecx
    push    esi
    push    edi
    mov     ebp, ebx
    mov     [esp+14h+var_4], ecx

    loc_4572B2:                             ; CODE XREF: sub_4572A0+10Dj
    mov     eax, TAdynmemStructPtr
    lea     esi, [eax+ecx+1B63h]
    mov     eax, [eax+ecx+1B63h]
    test    eax, eax
    jz      loc_45739D
    mov     al, [esi+73h]
    cmp     al, bl
    jz      short loc_4572DC
    cmp     al, 2
    jnz     loc_45739D

    loc_4572DC:                             ; CODE XREF: sub_4572A0+32j
    mov     eax, [esi+140h]
    test    eax, eax
    jz      loc_45739D
    mov     al, [esi+22h]
    test    al, al
    jnz     loc_45739D
    xor     edi, edi

    loc_4572F7:                             ; CODE XREF: sub_4572A0+F3j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+edi+1B63h]
    lea     eax, [ecx+edi+1B63h]
    test    edx, edx
    jz      short loc_457315
    cmp     byte ptr [eax+73h], 3
    jz      short loc_457326

    loc_457315:                             ; CODE XREF: sub_4572A0+6Dj
    mov     ecx, [eax+140h]
    test    ecx, ecx
    jz      short loc_457326
    mov     cl, [eax+22h]
    test    cl, cl
    jz      short loc_457387

    loc_457326:                             ; CODE XREF: sub_4572A0+73j
                                            ; sub_4572A0+7Dj
    test    edx, edx
    jz      short loc_457387
    cmp     byte ptr [eax+73h], 3
    jnz     short loc_457360
    mov     ecx, [eax+27h]
    cmp     [ecx+94h], bl
    jnz     short loc_457360
    xor     ecx, ecx
    mov     cl, [eax+146h]
    add     ecx, esi
    cmp     byte ptr [ecx+11Eh], 0
    jz      short loc_45737D
    cmp     byte ptr [ecx+134h], 0
    jz      short loc_45737D
    cmp     byte ptr [ecx+129h], 0
    jz      short loc_45737D

    loc_457360:                             ; CODE XREF: sub_4572A0+8Ej
                                            ; sub_4572A0+99j
    test    edx, edx
    jz      short loc_457387
    cmp     byte ptr [eax+73h], 3
    jnz     short loc_457387
    xor     edx, edx
    mov     dl, [eax+146h]
    mov     cl, [edx+esi+129h]
    test    cl, cl
    jnz     short loc_457387

    loc_45737D:                             ; CODE XREF: sub_4572A0+ACj
                                            ; sub_4572A0+B5j ...
    push    ebx
    push    eax
    push    esi
    call    sub_4573D0
    xor     ebp, ebp

    loc_457387:                             ; CODE XREF: sub_4572A0+84j
                                            ; sub_4572A0+88j ...
    add     edi, 14Bh
    cmp     edi, 0CEEh
    jl      loc_4572F7
    mov     ecx, [esp+14h+var_4]

    loc_45739D:                             ; CODE XREF: sub_4572A0+27j
                                            ; sub_4572A0+36j ...
    add     ecx, 14Bh
    cmp     ecx, 0CEEh
    mov     [esp+14h+var_4], ecx
    jl      loc_4572B2
    push    0FAh                            ; dwMilliseconds
    call    sub_4B6B50
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_4572A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4573D0 proc near                    ; CODE XREF: .text:00420524p
                                            ; sub_4572A0+E0p ...

    idTo= dword ptr -3Ch
    var_36= dword ptr -36h
    var_32= dword ptr -32h
    var_2E= dword ptr -2Eh
    var_2A= dword ptr -2Ah
    var_26= dword ptr -26h
    var_22= dword ptr -22h
    var_1E= dword ptr -1Eh
    var_1A= dword ptr -1Ah
    var_16= dword ptr -16h
    var_12= dword ptr -12h
    var_E= dword ptr -0Eh
    var_A= dword ptr -0Ah
    var_6= dword ptr -6
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    sub     esp, 3Ch
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+48h+arg_0]
    cmp     dword ptr [edi], 0
    jz      loc_45752D
    mov     al, [edi+73h]
    cmp     al, 1
    jz      short loc_4573F2
    cmp     al, 2
    jnz     loc_45752D

    loc_4573F2:                             ; CODE XREF: sub_4573D0+18j
    mov     al, [edi+22h]
    test    al, al
    jnz     loc_45752D
    fld     qword ptr [edi+0ACh]
    mov     al, [esp+48h+arg_8]
    mov     byte ptr [esp+48h+idTo], 28h
    fstp    [esp+48h+var_1A]
    fld     qword ptr [edi+0BCh]
    movsx   ecx, word ptr [edi+0FCh]
    fstp    [esp+48h+var_16]
    fld     qword ptr [edi+0CCh]
    movsx   edx, word ptr [edi+0FEh]
    fstp    [esp+48h+var_12]
    fld     qword ptr [edi+0B4h]
    mov     byte ptr [esp+48h+idTo+1], al
    mov     [esp+48h+idTo+2], ecx
    movsx   eax, word ptr [edi+104h]
    fstp    [esp+48h+var_E]
    fld     qword ptr [edi+0C4h]
    movsx   ecx, word ptr [edi+106h]
    fstp    [esp+48h+var_A]
    fld     qword ptr [edi+0D4h]
    mov     [esp+48h+var_32], eax
    mov     eax, [edi+8Ch]
    fstp    [esp+48h+var_6]
    mov     [esp+48h+var_36], edx
    mov     edx, [edi+98h]
    mov     [esp+48h+var_26], eax
    mov     eax, [esp+48h+arg_4]
    mov     [esp+48h+var_2E], ecx
    mov     ecx, [edi+0A8h]
    mov     [esp+48h+var_2A], edx
    mov     edx, [edi+0A4h]
    test    eax, eax
    mov     [esp+48h+var_22], ecx
    mov     [esp+48h+var_1E], edx
    jz      short loc_4574CA
    mov     cl, [eax+22h]
    test    cl, cl
    jnz     loc_45752D
    mov     edx, [eax+4]
    mov     eax, [edi+4]
    lea     ecx, [esp+48h+idTo]
    push    3Ah                             ; idFrom
    push    ecx                             ; idTo
    push    edx                             ; PlayersToSendTo
    push    eax                             ; dwDataSize
    call    Network_BroadcastMessage
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 3Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4574CA:                             ; CODE XREF: sub_4573D0+D0j
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     bl, 3

    loc_4574D3:                             ; CODE XREF: sub_4573D0+15Bj
    mov     ecx, [eax+esi+1B63h]
    test    ecx, ecx
    jz      short loc_45751F
    cmp     [eax+esi+1BD6h], bl
    jnz     short loc_45751F
    mov     ecx, [eax+esi+1B8Ah]
    cmp     byte ptr [ecx+94h], 1
    jnz     short loc_45751F
    mov     cl, [eax+esi+1B85h]
    test    cl, cl
    jnz     short loc_45751F
    mov     eax, [eax+esi+1B67h]
    mov     ecx, [edi+4]
    lea     edx, [esp+48h+idTo]
    push    3Ah                             ; idFrom
    push    edx                             ; idTo
    push    eax                             ; PlayersToSendTo
    push    ecx                             ; dwDataSize
    call    Network_BroadcastMessage
    mov     eax, TAdynmemStructPtr

    loc_45751F:                             ; CODE XREF: sub_4573D0+10Cj
                                            ; sub_4573D0+115j ...
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_4574D3

    loc_45752D:                             ; CODE XREF: sub_4573D0+Dj
                                            ; sub_4573D0+1Cj ...
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 3Ch
    retn    0Ch
    sub_4573D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_457540 proc near                    ; CODE XREF: Network_Process+1BC4p

    arg_0= dword ptr  14h
    idTo= dword ptr  18h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+idTo]
    test    edi, edi
    jz      loc_4576FC
    mov     al, [edi+22h]
    test    al, al
    jnz     loc_4576FC
    mov     ebx, TAdynmemStructPtr
    mov     edx, 0FFFFE42Ah
    xor     ebp, ebp
    sub     edx, ebx
    lea     eax, [ebx+1BD6h]
    mov     esi, 0Ah

    loc_457575:                             ; CODE XREF: sub_457540+69j
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_4575A3
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_457588
    cmp     cl, 2
    jnz     short loc_4575A3

    loc_457588:                             ; CODE XREF: sub_457540+41j
    xor     ecx, ecx
    mov     cl, [edi+146h]
    add     ecx, ebx
    add     ecx, edx
    cmp     byte ptr [ecx+eax+1C8Ch], 0
    jz      short loc_4575A3
    mov     ebp, 1

    loc_4575A3:                             ; CODE XREF: sub_457540+3Aj
                                            ; sub_457540+46j ...
    add     eax, 14Bh
    dec     esi
    jnz     short loc_457575
    mov     eax, [esp+arg_0]
    test    ebp, ebp
    jnz     loc_45763D
    mov     dx, [eax+2]
    mov     [edi+0FCh], dx
    mov     cx, [eax+6]
    mov     [edi+0FEh], cx
    mov     dx, [eax+0Ah]
    mov     [edi+104h], dx
    mov     cx, [eax+0Eh]
    mov     [edi+106h], cx
    mov     edx, [eax+12h]
    mov     [edi+98h], edx
    mov     ecx, [eax+16h]
    mov     [edi+8Ch], ecx
    mov     edx, [eax+1Ah]
    mov     [edi+0A8h], edx
    mov     ecx, [eax+1Eh]
    mov     [edi+0A4h], ecx
    fld     dword ptr [eax+22h]
    fstp    qword ptr [edi+0ACh]
    fld     dword ptr [eax+26h]
    fstp    qword ptr [edi+0BCh]
    fld     dword ptr [eax+2Ah]
    fstp    qword ptr [edi+0CCh]
    fld     dword ptr [eax+2Eh]
    fstp    qword ptr [edi+0B4h]
    fld     dword ptr [eax+32h]
    fstp    qword ptr [edi+0C4h]
    fld     dword ptr [eax+36h]
    fstp    qword ptr [edi+0D4h]

    loc_45763D:                             ; CODE XREF: sub_457540+71j
    mov     cl, [eax+1]
    test    cl, cl
    jz      loc_4576FC
    mov     byte ptr [esp+idTo], 29h
    mov     byte ptr [esp+idTo+1], 1
    xor     ebp, ebp

    loc_457654:                             ; CODE XREF: sub_457540+1B6j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+ebp+1B63h]
    lea     esi, [edx+ebp+1B63h]
    test    eax, eax
    jz      short loc_4576EA
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_457677
    cmp     al, 2
    jnz     short loc_4576EA

    loc_457677:                             ; CODE XREF: sub_457540+131j
    mov     al, [esi+22h]
    test    al, al
    jnz     short loc_4576EA
    xor     eax, eax
    xor     ecx, ecx
    mov     al, [edi+146h]
    push    3                               ; idFrom
    mov     byte ptr [esi+eax+129h], 1
    mov     cl, [edi+146h]
    lea     eax, [esp+4+idTo]
    mov     bl, [esi+ecx+11Eh]
    mov     ecx, [edi+4]
    test    bl, bl
    setnz   dl
    mov     byte ptr [esp+4+idTo+2], dl
    mov     edx, [esi+4]
    push    eax                             ; idTo
    push    ecx                             ; PlayersToSendTo
    push    edx                             ; dwDataSize
    call    Network_BroadcastMessage
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391EDh]
    call    sub_490230
    test    eax, eax
    jnz     short loc_4576EA
    xor     ecx, ecx
    mov     cl, [edi+146h]
    mov     al, [esi+ecx+11Eh]
    test    al, al
    jnz     short loc_4576EA
    push    1
    push    edi
    push    esi
    call    sub_4573D0

    loc_4576EA:                             ; CODE XREF: sub_457540+12Aj
                                            ; sub_457540+135j ...
    add     ebp, 14Bh
    cmp     ebp, 0CEEh
    jl      loc_457654

    loc_4576FC:                             ; CODE XREF: sub_457540+Aj
                                            ; sub_457540+15j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_457540 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    sub     esp, 18h
    mov     ecx, [eax+4E5h]
    push    esi
    test    ecx, ecx
    push    edi
    jz      short loc_45772F
    mov     eax, 1
    pop     edi
    pop     esi
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------

    loc_45772F:                             ; CODE XREF: .text:00457722j
    add     eax, 14h
    push    eax
    call    sub_4CA490
    test    eax, eax
    jz      loc_4578BF
    mov     eax, TAdynmemStructPtr
    add     eax, 14h
    push    eax
    call    sub_4C9C20
    mov     ecx, TAdynmemStructPtr
    push    64h
    push    2
    mov     dword ptr [ecx+4F1h], 0Ah
    call    sub_461020
    test    eax, eax
    jz      loc_4578BF
    push    3
    call    sub_434AB0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+4E5h]
    mov     eax, [edx+8]
    mov     eax, [eax+30h]
    test    eax, eax
    jz      short loc_4577A6
    push    10h
    add     ecx, 14h
    push    eax
    push    ecx
    call    _strncpy
    add     esp, 0Ch
    mov     eax, 1
    pop     edi
    pop     esi
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------

    loc_4577A6:                             ; CODE XREF: .text:0045778Aj
    mov     al, byte_512CA8
    mov     byte ptr [esp+10h], 0
    test    al, al
    jz      short loc_4577CA
    push    10h
    lea     ecx, [esp+14h]
    push    offset byte_512CA8
    push    ecx
    call    _strncat
    add     esp, 0Ch
    jmp     short loc_457836
    ; ---------------------------------------------------------------------------

    loc_4577CA:                             ; CODE XREF: .text:004577B2j
    mov     al, byte_512C98
    test    al, al
    jz      short loc_4577E9
    push    10h
    lea     edx, [esp+14h]
    push    offset byte_512C98
    push    edx
    call    _strncat
    add     esp, 0Ch
    jmp     short loc_457836
    ; ---------------------------------------------------------------------------

    loc_4577E9:                             ; CODE XREF: .text:004577D1j
    lea     eax, [esp+8]
    lea     ecx, [esp+10h]
    push    eax
    push    ecx
    mov     dword ptr [esp+10h], 0Fh
    call    ds:GetUserNameA
    test    eax, eax
    jz      short loc_457810
    mov     edx, [esp+8]
    mov     byte ptr [esp+edx+10h], 0
    jmp     short loc_457836
    ; ---------------------------------------------------------------------------

    loc_457810:                             ; CODE XREF: .text:00457803j
    mov     edi, offset aTotala             ; "TotalA"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+10h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_457836:                             ; CODE XREF: .text:004577C8j
                                            ; .text:004577E7j ...
    push    0
    call    _time
    add     esp, 4
    lea     ecx, [esp+0Ch]
    mov     [esp+0Ch], eax
    push    ecx
    call    _localtime
    mov     edx, eax
    lea     edi, [esp+14h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 4
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, 0Fh
    sub     eax, ecx
    cmp     eax, 7
    jl      short loc_45788A
    mov     eax, [edx]
    push    eax
    mov     eax, [edx+4]
    mov     edx, [edx+8]
    push    eax
    push    edx
    lea     eax, [esp+ecx+1Ch]
    push    offset a_02d02d02d              ; "_%02d%02d%02d"
    push    eax
    call    _sprintf
    add     esp, 14h

    loc_45788A:                             ; CODE XREF: .text:0045786Bj
    mov     ecx, TAdynmemStructPtr
    lea     edi, [esp+10h]
    xor     eax, eax
    lea     edx, [ecx+14h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, 1
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------

    loc_4578BF:                             ; CODE XREF: .text:0045773Aj
                                            ; .text:00457769j
    pop     edi
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4578D0 proc near                    ; CODE XREF: sub_49EE30+40Fp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, offset dword_513000
    push    eax
    call    sub_4619E0
    retn    4
    sub_4578D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_4578F0:                             ; DATA XREF: sub_490B30+D7o
                                            ; sub_491200+3B5o ...
    mov     ecx, TAdynmemStructPtr
    push    esi
    test    byte ptr [ecx+2A44h], 1
    jz      short loc_457948
    xor     esi, esi

    loc_457902:                             ; CODE XREF: .text:0045793Bj
    mov     eax, [ecx+esi+1B63h]
    test    eax, eax
    jz      short loc_45792F
    mov     al, [ecx+esi+1BD6h]
    cmp     al, 1
    jz      short loc_45791C
    cmp     al, 2
    jnz     short loc_45792F

    loc_45791C:                             ; CODE XREF: .text:00457916j
    mov     eax, [ecx+esi+1B67h]
    push    eax
    call    sub_452CC0
    mov     ecx, TAdynmemStructPtr

    loc_45792F:                             ; CODE XREF: .text:0045790Bj
                                            ; .text:0045791Aj
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_457902
    call    UnloadReporter
    mov     ecx, TAdynmemStructPtr

    loc_457948:                             ; CODE XREF: .text:004578FEj
    add     ecx, 14h
    push    ecx
    call    sub_4C9F90
    push    0
    push    0
    call    sub_4B4FD0
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    or      byte ptr [eax+3923Bh], 4
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    mov     dl, [ecx+eax*2+1B85h]
    mov     eax, edx
    test    eax, eax
    jz      loc_457A17
    add     eax, 0FFFFFFFDh                 ; switch 8 cases
    cmp     eax, 7
    ja      short loc_457A0A                ; default
    jmp     ds:off_457A24[eax*4]            ; switch jump

    loc_4579A2:                             ; DATA XREF: .text:00457A24o
    mov     eax, offset aYouDidNotHaveT     ; case 0x4
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4579AF:                             ; CODE XREF: .text:0045799Bj
                                            ; DATA XREF: .text:00457A24o
    mov     eax, offset aTheGameIsClose     ; case 0x3
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4579BC:                             ; CODE XREF: .text:0045799Bj
                                            ; DATA XREF: .text:00457A24o
    mov     eax, offset aTheGameIsFull      ; case 0x5
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4579C9:                             ; CODE XREF: .text:0045799Bj
                                            ; DATA XREF: .text:00457A24o
    mov     eax, offset aYouHaveLostCon     ; case 0x6
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4579D6:                             ; CODE XREF: .text:0045799Bj
                                            ; DATA XREF: .text:00457A24o
    mov     eax, offset aYouNeedAUnitYo     ; case 0x7
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4579E3:                             ; CODE XREF: .text:0045799Bj
                                            ; DATA XREF: .text:00457A24o
    mov     eax, offset aYouNeedANewerV     ; case 0x8
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4579F0:                             ; CODE XREF: .text:0045799Bj
                                            ; DATA XREF: .text:00457A24o
    mov     eax, offset aNoWatchingIsAl     ; case 0x9
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4579FD:                             ; CODE XREF: .text:0045799Bj
                                            ; DATA XREF: .text:00457A24o
    mov     eax, offset aTheCreatorHasL     ; case 0xa
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_457A0A:                             ; CODE XREF: .text:00457999j
    mov     eax, offset aYouWereRejecte     ; default
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_457A17:                             ; CODE XREF: .text:0045798Dj
    xor     eax, eax
    push    eax
    call    sub_4B6230
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4
    off_457A24 dd offset loc_4579AF         ; DATA XREF: .text:0045799Br
    dd offset loc_4579A2                    ; jump table for switch statement
    dd offset loc_4579BC
    dd offset loc_4579C9
    dd offset loc_4579D6
    dd offset loc_4579E3
    dd offset loc_4579F0
    dd offset loc_4579FD
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_457A50 proc near                    ; CODE XREF: sub_447B10+85p
                                            ; sub_448C70+D14p ...

    var_1= dword ptr -1

    push    ecx
    mov     edx, TAdynmemStructPtr
    push    ebx
    xor     bl, bl
    push    esi
    mov     byte ptr [esp+9+var_1], bl

    loc_457A5F:                             ; CODE XREF: sub_457A50+4Cj
    mov     eax, [esp+9+var_1]
    mov     esi, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_457A93
    mov     eax, [eax+1B8Ah]
    test    byte ptr [eax+97h], 1
    jnz     short loc_457AE4

    loc_457A93:                             ; CODE XREF: sub_457A50+32j
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+9+var_1], bl
    jb      short loc_457A5F
    mov     byte ptr [esp+9+var_1], 0Ah

    loc_457AA3:                             ; CODE XREF: sub_457A50+98j
    mov     eax, [esp+9+var_1]
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+1B63h]
    mov     ecx, [edx+ecx*2+1B63h]
    test    ecx, ecx
    jz      short loc_457ADE
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_457AD5
    cmp     al, 2
    jnz     short loc_457ADE

    loc_457AD5:                             ; CODE XREF: sub_457A50+7Fj
    mov     eax, 1
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_457ADE:                             ; CODE XREF: sub_457A50+78j
                                            ; sub_457A50+83j
    pop     esi
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_457AE4:                             ; CODE XREF: sub_457A50+41j
    mov     byte ptr [esp+9+var_1], bl
    jmp     short loc_457AA3
    sub_457A50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_457AF0 proc near                    ; CODE XREF: .text:004468CCp
                                            ; sub_447B10+C7Fp ...
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    esi
    xor     eax, eax
    add     ecx, 1BD6h
    mov     esi, 0Ah
    mov     bl, 1

    loc_457B07:                             ; CODE XREF: sub_457AF0+3Ej
    mov     edx, [ecx-73h]
    test    edx, edx
    jz      short loc_457B27
    cmp     [ecx], bl
    jz      short loc_457B26
    test    edx, edx
    jz      short loc_457B27
    cmp     byte ptr [ecx], 3
    jnz     short loc_457B27
    mov     edx, [ecx-4Ch]
    cmp     [edx+94h], bl
    jnz     short loc_457B27

    loc_457B26:                             ; CODE XREF: sub_457AF0+20j
    inc     eax

    loc_457B27:                             ; CODE XREF: sub_457AF0+1Cj
                                            ; sub_457AF0+24j ...
    add     ecx, 14Bh
    dec     esi
    jnz     short loc_457B07
    pop     esi
    pop     ebx
    retn
    sub_457AF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_457B40 proc near                    ; CODE XREF: .text:004468C5p
                                            ; sub_447B10+CA0p
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    esi
    xor     eax, eax
    add     ecx, 1BD6h
    mov     esi, 0Ah
    mov     bl, 2

    loc_457B57:                             ; CODE XREF: sub_457B40+3Ej
    mov     edx, [ecx-73h]
    test    edx, edx
    jz      short loc_457B77
    cmp     [ecx], bl
    jz      short loc_457B76
    test    edx, edx
    jz      short loc_457B77
    cmp     byte ptr [ecx], 3
    jnz     short loc_457B77
    mov     edx, [ecx-4Ch]
    cmp     [edx+94h], bl
    jnz     short loc_457B77

    loc_457B76:                             ; CODE XREF: sub_457B40+20j
    inc     eax

    loc_457B77:                             ; CODE XREF: sub_457B40+1Cj
                                            ; sub_457B40+24j ...
    add     ecx, 14Bh
    dec     esi
    jnz     short loc_457B57
    pop     esi
    pop     ebx
    retn
    sub_457B40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_457B90 proc near                    ; CODE XREF: sub_447B10+270p
    mov     ecx, TAdynmemStructPtr
    push    ebx
    xor     eax, eax
    add     ecx, 1B63h
    mov     edx, 0Ah
    mov     bl, 2

    loc_457BA6:                             ; CODE XREF: sub_457B90+28j
    cmp     dword ptr [ecx], 0
    jz      short loc_457BB1
    cmp     [ecx+73h], bl
    jnz     short loc_457BB1
    inc     eax

    loc_457BB1:                             ; CODE XREF: sub_457B90+19j
                                            ; sub_457B90+1Ej
    add     ecx, 14Bh
    dec     edx
    jnz     short loc_457BA6
    pop     ebx
    retn
    sub_457B90 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_457BC0 proc near                    ; CODE XREF: UpdateDatePlayers+70Dp
                                            ; UpdateDatePlayers+758p
    mov     ecx, TAdynmemStructPtr
    push    ebx
    mov     ebx, 0Ah
    xor     eax, eax
    push    esi
    add     ecx, 1BD6h
    mov     edx, ebx

    loc_457BD7:                             ; CODE XREF: sub_457BC0+47j
    mov     esi, [ecx-73h]
    test    esi, esi
    jz      short loc_457C00
    cmp     byte ptr [ecx], 2
    jnz     short loc_457C00
    cmp     [ecx+0D3h], bl
    jz      short loc_457C00
    cmp     word ptr [ecx+0D1h], 0
    jnz     short loc_457BFF
    mov     esi, [ecx+0CDh]
    test    esi, esi
    jnz     short loc_457C00

    loc_457BFF:                             ; CODE XREF: sub_457BC0+33j
    inc     eax

    loc_457C00:                             ; CODE XREF: sub_457BC0+1Cj
                                            ; sub_457BC0+21j ...
    add     ecx, 14Bh
    dec     edx
    jnz     short loc_457BD7
    pop     esi
    pop     ebx
    retn
    sub_457BC0 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, TAdynmemStructPtr
    push    ebx
    mov     ebx, 0Ah
    push    esi
    xor     eax, eax
    lea     edx, [ecx+1BD6h]
    mov     esi, ebx

    loc_457C27:                             ; CODE XREF: .text:00457C6Cj
    mov     ecx, [edx-73h]
    test    ecx, ecx
    jz      short loc_457C65
    mov     cl, [edx]
    cmp     cl, 1
    jz      short loc_457C48
    cmp     cl, 2
    jnz     short loc_457C65
    cmp     cl, 1
    jz      short loc_457C48
    cmp     cl, cl
    jz      short loc_457C48
    cmp     cl, 3
    jnz     short loc_457C65

    loc_457C48:                             ; CODE XREF: .text:00457C33j
                                            ; .text:00457C3Dj ...
    cmp     [edx+0D3h], bl
    jz      short loc_457C65
    cmp     word ptr [edx+0D1h], 0
    jnz     short loc_457C64
    mov     ecx, [edx+0CDh]
    test    ecx, ecx
    jnz     short loc_457C65

    loc_457C64:                             ; CODE XREF: .text:00457C58j
    inc     eax

    loc_457C65:                             ; CODE XREF: .text:00457C2Cj
                                            ; .text:00457C38j ...
    add     edx, 14Bh
    dec     esi
    jnz     short loc_457C27
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    push    ebx
    xor     eax, eax
    add     ecx, 1B63h
    mov     edx, 0Ah
    mov     bl, 3

    loc_457C96:                             ; CODE XREF: .text:00457CA8j
    cmp     dword ptr [ecx], 0
    jz      short loc_457CA1
    cmp     [ecx+73h], bl
    jnz     short loc_457CA1
    inc     eax

    loc_457CA1:                             ; CODE XREF: .text:00457C99j
                                            ; .text:00457C9Ej
    add     ecx, 14Bh
    dec     edx
    jnz     short loc_457C96
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_457CB0 proc near                    ; CODE XREF: UpdateDatePlayers+659p
                                            ; UpdateDatePlayers+868p
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    lea     ecx, [eax+1BD6h]
    xor     edi, edi
    mov     esi, 0Ah
    mov     bl, 1
    mov     al, 40h

    loc_457CCA:                             ; CODE XREF: sub_457CB0+75j
    mov     edx, [ecx-73h]
    test    edx, edx
    jz      short loc_457D1E
    mov     dl, [ecx]
    cmp     dl, bl
    jz      short loc_457CE1
    cmp     dl, 2
    jz      short loc_457CE1
    cmp     dl, 3
    jnz     short loc_457D1E

    loc_457CE1:                             ; CODE XREF: sub_457CB0+25j
                                            ; sub_457CB0+2Aj
    cmp     byte ptr [ecx+0D3h], 0Ah
    jz      short loc_457D1E
    cmp     word ptr [ecx+0D1h], 0
    jnz     short loc_457CFE
    mov     ebp, [ecx+0CDh]
    test    ebp, ebp
    jnz     short loc_457D1E

    loc_457CFE:                             ; CODE XREF: sub_457CB0+42j
    cmp     dl, bl
    jz      short loc_457D12
    cmp     dl, 3
    jnz     short loc_457D1E
    mov     edx, [ecx-4Ch]
    cmp     [edx+94h], bl
    jnz     short loc_457D1E

    loc_457D12:                             ; CODE XREF: sub_457CB0+50j
    mov     edx, [ecx-4Ch]
    test    [edx+9Bh], al
    jnz     short loc_457D1E
    inc     edi

    loc_457D1E:                             ; CODE XREF: sub_457CB0+1Fj
                                            ; sub_457CB0+2Fj ...
    add     ecx, 14Bh
    dec     esi
    jnz     short loc_457CCA
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_457CB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_457D30 proc near                    ; CODE XREF: sub_49562A+10p

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    idTo= dword ptr -14h
    var_F= dword ptr -0Fh
    var_B= dword ptr -0Bh
    var_7= dword ptr -7
    arg_0= dword ptr  4

    sub     esp, 1Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    push    edi
    test    byte ptr [esi+2A44h], 1
    jz      loc_45814B
    mov     eax, [esi+38A47h]
    xor     edx, edx
    mov     ecx, 3Ch
    mov     ebx, [esp+2Ch+arg_0]
    div     ecx
    test    edx, edx
    jnz     loc_457FA1
    mov     edx, [ebx+27h]
    mov     ebp, ebx
    test    byte ptr [edx+97h], 2
    jz      loc_457E0F
    fld     dword ptr [ebx+98h]
    fcomp   dword ptr [ebx+0E4h]
    fnstsw  ax
    test    ah, 41h
    jnz     loc_457E0F
    xor     edx, edx
    lea     ecx, [esi+1BD6h]

    loc_457D96:                             ; CODE XREF: sub_457D30+DDj
    mov     eax, [ecx-73h]
    lea     edi, [ecx-73h]
    test    eax, eax
    jz      short loc_457E03
    mov     al, [ecx]
    cmp     al, 1
    jz      short loc_457DAE
    cmp     al, 2
    jz      short loc_457DAE
    cmp     al, 3
    jnz     short loc_457E03

    loc_457DAE:                             ; CODE XREF: sub_457D30+74j
                                            ; sub_457D30+78j
    cmp     byte ptr [ecx+0D3h], 0Ah
    jz      short loc_457E03
    cmp     al, 1
    jz      short loc_457DC3
    cmp     al, 2
    jz      short loc_457DC3
    cmp     al, 3
    jnz     short loc_457E03

    loc_457DC3:                             ; CODE XREF: sub_457D30+89j
                                            ; sub_457D30+8Dj
    cmp     word ptr [ecx+0D1h], 0
    jnz     short loc_457DD6
    cmp     dword ptr [ecx+0CDh], 0
    jnz     short loc_457E03

    loc_457DD6:                             ; CODE XREF: sub_457D30+9Bj
    cmp     al, 3
    jnz     short loc_457E03
    mov     eax, [ecx-4Ch]
    cmp     byte ptr [eax+94h], 1
    jnz     short loc_457E03
    mov     al, [edx+ebx+108h]
    test    al, al
    jz      short loc_457E03
    fld     dword ptr [ecx+25h]
    fcomp   dword ptr [ebx+98h]
    fnstsw  ax
    test    ah, 1
    jz      short loc_457E03
    mov     ebp, edi

    loc_457E03:                             ; CODE XREF: sub_457D30+6Ej
                                            ; sub_457D30+7Cj ...
    inc     edx
    add     ecx, 14Bh
    cmp     edx, 0Ah
    jl      short loc_457D96

    loc_457E0F:                             ; CODE XREF: sub_457D30+41j
                                            ; sub_457D30+58j
    cmp     ebp, ebx
    jz      short loc_457E83
    fld     dword ptr [ebx+98h]
    fcomp   dword ptr [ebx+0E4h]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_457E83
    fld     dword ptr [ebx+98h]
    fsub    dword ptr [ebx+0E4h]
    fld     dword ptr [ebp+0A8h]
    fsub    dword ptr [ebp+98h]
    fxch    st(1)
    fmul    ds:flt_4FD4B8
    fst     [esp+2Ch+var_1C]
    fcomp   st(1)
    fnstsw  ax
    test    ah, 1
    jz      short loc_457E5F
    mov     ecx, [esp+2Ch+var_1C]
    fstp    st
    mov     [esp+2Ch+var_1C], ecx
    jmp     short loc_457E63
    ; ---------------------------------------------------------------------------

    loc_457E5F:                             ; CODE XREF: sub_457D30+121j
    fstp    [esp+2Ch+var_1C]

    loc_457E63:                             ; CODE XREF: sub_457D30+12Dj
    mov     edx, [esp+2Ch+var_1C]
    mov     al, [ebp+146h]
    mov     cl, [ebx+146h]
    push    1
    push    edx
    push    eax
    push    ecx
    call    sub_464C60
    mov     esi, TAdynmemStructPtr

    loc_457E83:                             ; CODE XREF: sub_457D30+E1j
                                            ; sub_457D30+F4j
    mov     edx, [ebx+27h]
    mov     ebp, ebx
    test    byte ptr [edx+97h], 4
    jz      loc_457F2D
    fld     dword ptr [ebx+8Ch]
    fcomp   dword ptr [ebx+0E8h]
    fnstsw  ax
    test    ah, 41h
    jnz     loc_457F2D
    xor     edx, edx
    lea     ecx, [esi+1BD6h]

    loc_457EB4:                             ; CODE XREF: sub_457D30+1FBj
    mov     eax, [ecx-73h]
    lea     edi, [ecx-73h]
    test    eax, eax
    jz      short loc_457F21
    mov     al, [ecx]
    cmp     al, 1
    jz      short loc_457ECC
    cmp     al, 2
    jz      short loc_457ECC
    cmp     al, 3
    jnz     short loc_457F21

    loc_457ECC:                             ; CODE XREF: sub_457D30+192j
                                            ; sub_457D30+196j
    cmp     byte ptr [ecx+0D3h], 0Ah
    jz      short loc_457F21
    cmp     al, 1
    jz      short loc_457EE1
    cmp     al, 2
    jz      short loc_457EE1
    cmp     al, 3
    jnz     short loc_457F21

    loc_457EE1:                             ; CODE XREF: sub_457D30+1A7j
                                            ; sub_457D30+1ABj
    cmp     word ptr [ecx+0D1h], 0
    jnz     short loc_457EF4
    cmp     dword ptr [ecx+0CDh], 0
    jnz     short loc_457F21

    loc_457EF4:                             ; CODE XREF: sub_457D30+1B9j
    cmp     al, 3
    jnz     short loc_457F21
    mov     eax, [ecx-4Ch]
    cmp     byte ptr [eax+94h], 1
    jnz     short loc_457F21
    mov     al, [edx+ebx+108h]
    test    al, al
    jz      short loc_457F21
    fld     dword ptr [ecx+19h]
    fcomp   dword ptr [ebx+8Ch]
    fnstsw  ax
    test    ah, 1
    jz      short loc_457F21
    mov     ebp, edi

    loc_457F21:                             ; CODE XREF: sub_457D30+18Cj
                                            ; sub_457D30+19Aj ...
    inc     edx
    add     ecx, 14Bh
    cmp     edx, 0Ah
    jl      short loc_457EB4

    loc_457F2D:                             ; CODE XREF: sub_457D30+15Fj
                                            ; sub_457D30+176j
    cmp     ebp, ebx
    jz      short loc_457FA1
    fld     dword ptr [ebx+8Ch]
    fcomp   dword ptr [ebx+0E8h]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_457FA1
    fld     dword ptr [ebx+8Ch]
    fsub    dword ptr [ebx+0E8h]
    fld     dword ptr [ebp+0A4h]
    fsub    dword ptr [ebp+8Ch]
    fxch    st(1)
    fmul    ds:flt_4FD4BC
    fst     [esp+2Ch+var_1C]
    fcomp   st(1)
    fnstsw  ax
    test    ah, 1
    jz      short loc_457F7D
    mov     ecx, [esp+2Ch+var_1C]
    fstp    st
    mov     [esp+2Ch+var_1C], ecx
    jmp     short loc_457F81
    ; ---------------------------------------------------------------------------

    loc_457F7D:                             ; CODE XREF: sub_457D30+23Fj
    fstp    [esp+2Ch+var_1C]

    loc_457F81:                             ; CODE XREF: sub_457D30+24Bj
    mov     edx, [esp+2Ch+var_1C]
    mov     al, [ebp+146h]
    mov     cl, [ebx+146h]
    push    1
    push    edx
    push    eax
    push    ecx
    call    sub_464B30
    mov     esi, TAdynmemStructPtr

    loc_457FA1:                             ; CODE XREF: sub_457D30+2Fj
                                            ; sub_457D30+1FFj ...
    mov     eax, [esi+38A47h]
    xor     edx, edx
    mov     ecx, 1C2h
    div     ecx
    test    edx, edx
    jnz     loc_45814B
    mov     edx, [ebx+27h]
    mov     al, [edx+97h]
    shr     al, 5
    test    al, 1
    jz      loc_45814B
    xor     ebp, ebp
    xor     edi, edi
    mov     bl, 16h

    loc_457FD2:                             ; CODE XREF: sub_457D30+415j
    mov     eax, [esi+edi+1B63h]
    test    eax, eax
    jz      loc_458138
    mov     al, [esi+edi+1BD6h]
    cmp     al, 1
    jz      short loc_457FF8
    cmp     al, 2
    jz      short loc_457FF8
    cmp     al, 3
    jnz     loc_458138

    loc_457FF8:                             ; CODE XREF: sub_457D30+2BAj
                                            ; sub_457D30+2BEj
    mov     cl, [esi+edi+1CA9h]
    cmp     cl, 0Ah
    jz      loc_458138
    cmp     al, 1
    jz      short loc_458018
    cmp     al, 2
    jz      short loc_458018
    cmp     al, 3
    jnz     loc_458138

    loc_458018:                             ; CODE XREF: sub_457D30+2DAj
                                            ; sub_457D30+2DEj
    cmp     word ptr [esi+edi+1CA7h], 0
    jnz     short loc_458032
    mov     edx, [esi+edi+1CA3h]
    test    edx, edx
    jnz     loc_458138

    loc_458032:                             ; CODE XREF: sub_457D30+2F1j
    cmp     al, 3
    jnz     loc_458138
    mov     edx, [esi+edi+1B8Ah]
    cmp     byte ptr [edx+94h], 1
    jnz     loc_458138
    mov     eax, [esp+2Ch+arg_0]
    mov     dl, [ebp+eax+108h]
    test    dl, dl
    jz      loc_458138
    mov     al, [eax+146h]
    mov     byte ptr [esp+2Ch+var_18], cl
    cmp     al, 0Ah
    mov     byte ptr [esp+2Ch+var_1C], al
    jz      loc_458138
    cmp     cl, 0Ah
    jz      loc_458138
    mov     eax, [esp+2Ch+var_1C]
    mov     edx, esi
    and     eax, 0FFh
    mov     byte ptr [esp+2Ch+idTo], bl
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    mov     [esp+2Ch+idTo+1], 3
    lea     ecx, [ecx+ecx*4]
    mov     al, [edx+ecx*2+1BD6h]
    lea     edx, [edx+ecx*2]
    test    al, al
    jz      short loc_4580B9
    mov     eax, [edx+1B67h]
    jmp     short loc_4580BC
    ; ---------------------------------------------------------------------------

    loc_4580B9:                             ; CODE XREF: sub_457D30+37Fj
    or      eax, 0FFFFFFFFh

    loc_4580BC:                             ; CODE XREF: sub_457D30+387j
    mov     [esp+2Ch+var_F], eax
    mov     eax, [esp+2Ch+var_18]
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1BD6h]
    test    cl, cl
    jz      short loc_4580EB
    mov     ecx, [eax+1B67h]
    jmp     short loc_4580EE
    ; ---------------------------------------------------------------------------

    loc_4580EB:                             ; CODE XREF: sub_457D30+3B1j
    or      ecx, 0FFFFFFFFh

    loc_4580EE:                             ; CODE XREF: sub_457D30+3B9j
    mov     [esp+2Ch+var_B], ecx
    mov     [esp+2Ch+var_7], 0
    mov     cl, [eax+1BD6h]
    test    cl, cl
    jz      short loc_45810C
    mov     eax, [eax+1B67h]
    jmp     short loc_45810F
    ; ---------------------------------------------------------------------------

    loc_45810C:                             ; CODE XREF: sub_457D30+3D2j
    or      eax, 0FFFFFFFFh

    loc_45810F:                             ; CODE XREF: sub_457D30+3DAj
    mov     cl, [edx+1BD6h]
    test    cl, cl
    jz      short loc_458121
    mov     edx, [edx+1B67h]
    jmp     short loc_458124
    ; ---------------------------------------------------------------------------

    loc_458121:                             ; CODE XREF: sub_457D30+3E7j
    or      edx, 0FFFFFFFFh

    loc_458124:                             ; CODE XREF: sub_457D30+3EFj
    lea     ecx, [esp+2Ch+idTo]
    push    11h                             ; idFrom
    push    ecx                             ; idTo
    push    eax                             ; PlayersToSendTo
    push    edx                             ; dwDataSize
    call    Network_BroadcastMessage
    mov     esi, TAdynmemStructPtr

    loc_458138:                             ; CODE XREF: sub_457D30+2ABj
                                            ; sub_457D30+2C2j ...
    add     edi, 14Bh
    inc     ebp
    cmp     edi, 0CEEh
    jl      loc_457FD2

    loc_45814B:                             ; CODE XREF: sub_457D30+14j
                                            ; sub_457D30+282j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    4
    sub_457D30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_458160 proc near                    ; CODE XREF: sub_42D2E0+EEp
    push    esi
    mov     esi, ecx
    call    sub_4379A0
    mov     dword ptr [esi+10h], 0
    mov     eax, esi
    pop     esi
    retn
    sub_458160 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_458180 proc near                    ; CODE XREF: sub_42D2E0+193p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    eax
    call    sub_4379B0
    test    eax, eax
    jnz     short loc_458195
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_458195:                             ; CODE XREF: sub_458180+Fj
    push    258h
    push    258h
    push    offset aCompositebuffe          ; "CompositeBuffer"
    call    sub_4B8E00
    xor     ecx, ecx
    mov     [esi+10h], eax
    test    eax, eax
    setnz   cl
    mov     eax, ecx
    pop     esi
    retn    4
    sub_458180 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4581C0 proc near                    ; CODE XREF: sub_42DB90+FFp
    push    esi
    mov     esi, ecx
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4581D3
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4581D3:                             ; CODE XREF: sub_4581C0+8j
    mov     ecx, esi
    call    sub_437A20
    pop     esi
    retn
    sub_4581C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4581E0 proc near                    ; CODE XREF: sub_4586A0+29p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 10h
    mov     edx, [esp+10h+arg_10]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [edx]
    xor     ecx, ecx
    xor     ebx, ebx
    xor     esi, esi
    xor     ebp, ebp
    dec     eax
    mov     [esp+1Ch+var_10], ecx
    mov     [esp+1Ch+var_C], esi
    js      loc_4582CC
    lea     ecx, [eax+eax*2]
    inc     eax
    push    edi
    mov     edi, [esp+20h+arg_14]
    lea     ecx, [ecx+ecx*8]
    mov     [esp+20h+var_4], eax
    lea     ecx, [edx+ecx*2+22h]
    mov     [esp+20h+var_8], ecx

    loc_45821B:                             ; CODE XREF: sub_4581E0+DDj
    test    byte ptr [ecx+28h], 1
    jz      loc_4582AD
    mov     eax, [ecx]
    mov     edx, [ecx+22h]
    mov     eax, [eax+4]
    test    eax, eax
    jle     short loc_4582AD
    mov     [esp+20h+arg_10], eax

    loc_458235:                             ; CODE XREF: sub_4581E0+C7j
    test    edi, edi
    jz      short loc_45825B
    mov     ecx, [edx]
    mov     eax, [edi]
    add     ecx, eax
    mov     eax, [edi+4]
    sar     ecx, 10h
    movsx   esi, cx
    mov     ecx, [edx+4]
    add     eax, ecx
    mov     ecx, [edi+8]
    sar     eax, 10h
    sub     ecx, [edx+8]
    movsx   eax, ax
    jmp     short loc_458271
    ; ---------------------------------------------------------------------------

    loc_45825B:                             ; CODE XREF: sub_4581E0+57j
    mov     eax, [edx]
    mov     ecx, [edx+4]
    sar     eax, 10h
    sar     ecx, 10h
    movsx   esi, ax
    movsx   eax, cx
    mov     ecx, [edx+8]
    neg     ecx

    loc_458271:                             ; CODE XREF: sub_4581E0+79j
    sar     ecx, 10h
    movsx   ecx, cx
    sar     eax, 1
    sub     ecx, eax
    cmp     esi, ebp
    jge     short loc_458281
    mov     ebp, esi

    loc_458281:                             ; CODE XREF: sub_4581E0+9Dj
    cmp     esi, [esp+20h+var_C]
    jle     short loc_45828B
    mov     [esp+20h+var_C], esi

    loc_45828B:                             ; CODE XREF: sub_4581E0+A5j
    cmp     ecx, ebx
    jge     short loc_458291
    mov     ebx, ecx

    loc_458291:                             ; CODE XREF: sub_4581E0+ADj
    cmp     ecx, [esp+20h+var_10]
    jle     short loc_45829B
    mov     [esp+20h+var_10], ecx

    loc_45829B:                             ; CODE XREF: sub_4581E0+B5j
    mov     eax, [esp+20h+arg_10]
    add     edx, 0Ch
    dec     eax
    mov     [esp+20h+arg_10], eax
    jnz     short loc_458235
    mov     ecx, [esp+20h+var_8]

    loc_4582AD:                             ; CODE XREF: sub_4581E0+3Fj
                                            ; sub_4581E0+4Fj
    mov     eax, [esp+20h+var_4]
    sub     ecx, 36h
    dec     eax
    mov     [esp+20h+var_8], ecx
    mov     [esp+20h+var_4], eax
    jnz     loc_45821B
    mov     ecx, [esp+20h+var_10]
    mov     esi, [esp+20h+var_C]
    pop     edi

    loc_4582CC:                             ; CODE XREF: sub_4581E0+1Dj
    mov     edx, [esp+1Ch+arg_0]
    mov     eax, [esp+1Ch+arg_4]
    sub     ebp, 2
    sub     ebx, 2
    sub     esi, ebp
    sub     ecx, ebx
    add     esi, 2
    add     ecx, 2
    mov     [edx], esi
    mov     edx, [esp+1Ch+arg_C]
    mov     [eax], ecx
    mov     ecx, [esp+1Ch+arg_8]
    neg     ebp
    neg     ebx
    mov     [ecx], ebp
    pop     esi
    mov     [edx], ebx
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    18h
    sub_4581E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_458310 proc near                    ; CODE XREF: sub_4589C0+4Cp
                                            ; sub_4589C0+B7p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    sub     esp, 14h
    mov     edx, [esp+14h+arg_10]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [edx]
    push    edi
    xor     ebp, ebp
    xor     ecx, ecx
    xor     edi, edi
    xor     esi, esi
    dec     eax
    mov     [esp+24h+var_C], ebp
    mov     [esp+24h+var_14], ecx
    mov     [esp+24h+var_10], edi
    js      loc_4583E9
    lea     ecx, [eax+eax*2]
    mov     edi, [esp+24h+arg_1C]
    mov     ebx, [esp+24h+arg_14]
    inc     eax
    lea     ecx, [ecx+ecx*8]
    mov     [esp+24h+var_4], eax
    lea     ecx, [edx+ecx*2+22h]
    mov     [esp+24h+var_8], ecx

    loc_458353:                             ; CODE XREF: sub_458310+CBj
    test    byte ptr [ecx+28h], 1
    jz      short loc_4583CB
    mov     eax, [ecx]
    mov     edx, [ecx+22h]
    mov     eax, [eax+4]
    test    eax, eax
    jle     short loc_4583CB
    mov     [esp+24h+arg_10], eax

    loc_458369:                             ; CODE XREF: sub_458310+B5j
    mov     ebp, [edx+8]
    mov     ecx, [edx]
    mov     eax, edi
    add     ecx, ebx
    sub     eax, ebp
    mov     ebp, [edx+4]
    add     ebp, [esp+24h+arg_18]
    sar     eax, 10h
    sar     ebp, 10h
    movsx   ebp, bp
    sar     ecx, 10h
    movsx   eax, ax
    movsx   ecx, cx
    sar     ebp, 1
    sub     eax, ebp
    cmp     ecx, esi
    jge     short loc_458397
    mov     esi, ecx

    loc_458397:                             ; CODE XREF: sub_458310+83j
    cmp     ecx, [esp+24h+var_10]
    jle     short loc_4583A1
    mov     [esp+24h+var_10], ecx

    loc_4583A1:                             ; CODE XREF: sub_458310+8Bj
    cmp     eax, [esp+24h+var_14]
    jge     short loc_4583AB
    mov     [esp+24h+var_14], eax

    loc_4583AB:                             ; CODE XREF: sub_458310+95j
    mov     ebp, [esp+24h+var_C]
    cmp     eax, ebp
    jle     short loc_4583B9
    mov     ebp, eax
    mov     [esp+24h+var_C], ebp

    loc_4583B9:                             ; CODE XREF: sub_458310+A1j
    mov     eax, [esp+24h+arg_10]
    add     edx, 0Ch
    dec     eax
    mov     [esp+24h+arg_10], eax
    jnz     short loc_458369
    mov     ecx, [esp+24h+var_8]

    loc_4583CB:                             ; CODE XREF: sub_458310+47j
                                            ; sub_458310+53j
    mov     eax, [esp+24h+var_4]
    sub     ecx, 36h
    dec     eax
    mov     [esp+24h+var_8], ecx
    mov     [esp+24h+var_4], eax
    jnz     loc_458353
    mov     ecx, [esp+24h+var_14]
    mov     edi, [esp+24h+var_10]

    loc_4583E9:                             ; CODE XREF: sub_458310+22j
    mov     eax, [esp+24h+arg_0]
    sub     esi, 2
    add     edi, 2
    sub     ecx, 2
    mov     edx, [eax]
    add     ebp, 2
    cmp     esi, edx
    jge     short loc_458401
    mov     [eax], esi

    loc_458401:                             ; CODE XREF: sub_458310+EDj
    mov     eax, [esp+24h+arg_8]
    cmp     ecx, [eax]
    jge     short loc_45840B
    mov     [eax], ecx

    loc_45840B:                             ; CODE XREF: sub_458310+F7j
    mov     eax, [esp+24h+arg_4]
    cmp     edi, [eax]
    jle     short loc_458415
    mov     [eax], edi

    loc_458415:                             ; CODE XREF: sub_458310+101j
    mov     eax, [esp+24h+arg_C]
    cmp     ebp, [eax]
    jle     short loc_45841F
    mov     [eax], ebp

    loc_45841F:                             ; CODE XREF: sub_458310+10Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    20h
    sub_458310 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+1Ch]
    mov     [esp+10h], ecx
    mov     eax, [edi+10h]
    test    eax, eax
    jz      short loc_458475
    mov     eax, [esp+2Ch]
    push    eax
    mov     eax, [esp+24h]
    sub     esp, 0Ch
    mov     edx, esp
    push    edi
    mov     [edx], eax
    mov     eax, [esp+38h]
    mov     [edx+4], eax
    mov     eax, [esp+3Ch]
    mov     [edx+8], eax
    mov     edx, [esp+2Ch]
    push    edx
    call    sub_459200
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_458475:                             ; CODE XREF: .text:00458442j
    mov     eax, [edi]
    dec     eax
    js      short loc_4584C7
    mov     ebp, [esp+2Ch]
    mov     ebx, [esp+18h]
    lea     ecx, [eax+eax*2]
    inc     eax
    mov     [esp+1Ch], eax
    lea     ecx, [ecx+ecx*8]
    lea     esi, [edi+ecx*2+44h]

    loc_458491:                             ; CODE XREF: .text:004584C5j
    test    byte ptr [esi+6], 1
    jz      short loc_4584B9
    mov     edx, [edi+0Ch]
    mov     ecx, [esi]
    push    ebp
    mov     al, [edx+0FFh]
    mov     edx, [esi-22h]
    push    eax
    push    ecx
    mov     ecx, [esp+1Ch]
    lea     eax, [esp+2Ch]
    push    edx
    push    eax
    push    ebx
    push    edi
    call    sub_4584D0

    loc_4584B9:                             ; CODE XREF: .text:00458495j
    mov     eax, [esp+1Ch]
    sub     esi, 36h
    dec     eax
    mov     [esp+1Ch], eax
    jnz     short loc_458491

    loc_4584C7:                             ; CODE XREF: .text:00458478j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    18h
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4584D0 proc near                    ; CODE XREF: .text:004584B4p
                                            ; sub_458810+187p ...

    var_3F58= dword ptr -3F58h
    var_3F50= dword ptr -3F50h
    var_3F48= dword ptr -3F48h
    var_3E80= dword ptr -3E80h
    var_3E7C= dword ptr -3E7Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    mov     eax, 3F58h
    call    __alloca_probe
    mov     eax, [esp+3F58h+arg_0]
    mov     ecx, [esp+3F58h+arg_8]
    push    ebx
    push    ebp
    mov     eax, [eax+0Ch]
    mov     ebx, [ecx]
    push    esi
    push    edi
    mov     edx, [eax+6Ah]
    mov     esi, [eax+6Eh]
    mov     edi, [ecx+8]
    sub     edx, ebx
    mov     ebx, [esp+3F68h+arg_C]
    mov     [esp+3F68h+var_3F50], esi
    mov     esi, [eax+72h]
    sub     esi, edi
    mov     edi, [ebx+4]
    test    edi, edi
    jle     short loc_458568
    mov     eax, [esp+3F68h+arg_10]
    lea     ecx, [esp+3F68h+var_3E7C]

    loc_458521:                             ; CODE XREF: sub_4584D0+8Fj
    mov     ebx, [eax]
    mov     ebp, [eax+8]
    add     ebx, edx
    add     ecx, 8
    sar     ebx, 10h
    movsx   ebx, bx
    add     ebx, 80h
    add     eax, 0Ch
    mov     [ecx-0Ch], ebx
    mov     ebx, esi
    sub     ebx, ebp
    mov     ebp, [eax-8]
    add     ebp, [esp+3F68h+var_3F50]
    sar     ebx, 10h
    sar     ebp, 10h
    movsx   ebp, bp
    movsx   ebx, bx
    sar     ebp, 1
    sub     ebx, ebp
    add     ebx, 20h
    dec     edi
    mov     [ecx-8], ebx
    jnz     short loc_458521
    mov     ebx, [esp+3F68h+arg_C]

    loc_458568:                             ; CODE XREF: sub_4584D0+41j
    mov     eax, [ebx+0Ch]
    mov     esi, [ebx+28h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_45857D
    add     esi, 20h
    mov     edi, 1
    jmp     short loc_45857F
    ; ---------------------------------------------------------------------------

    loc_45857D:                             ; CODE XREF: sub_4584D0+A1j
    xor     edi, edi

    loc_45857F:                             ; CODE XREF: sub_4584D0+ABj
    mov     eax, [ebx+8]
    mov     [esp+3F68h+var_3F58], edi
    cmp     edi, eax
    jge     loc_458690
    mov     ebp, [esp+3F68h+arg_4]

    loc_458595:                             ; CODE XREF: sub_4584D0+1BAj
    mov     eax, [esi+4]
    mov     edx, [esi+0Ch]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_4585D7
    lea     eax, [esp+3F68h+var_3F48]

    loc_4585A5:                             ; CODE XREF: sub_4584D0+FAj
    xor     edi, edi
    inc     ecx
    mov     di, [edx]
    add     eax, 8
    add     edx, 2
    mov     ebp, [esp+edi*8+3F68h+var_3E80]
    mov     [eax-8], ebp
    mov     edi, [esp+edi*8+3F68h+var_3E7C]
    mov     [eax-4], edi
    mov     edi, [esi+4]
    cmp     ecx, edi
    jl      short loc_4585A5
    mov     ebp, [esp+3F68h+arg_4]
    mov     edi, [esp+3F68h+var_3F58]

    loc_4585D7:                             ; CODE XREF: sub_4584D0+CFj
    mov     eax, [esi+1Ch]
    test    al, 1
    jnz     loc_45866B
    cmp     dword ptr [esi+4], 4
    jnz     loc_45867D
    mov     ecx, eax
    shr     ecx, 1
    test    cl, 1
    jz      short loc_458658
    shr     eax, 2
    test    al, 1
    jz      short loc_458635
    mov     eax, [esp+3F68h+arg_14]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    add     ecx, eax
    xor     eax, eax
    mov     edx, [ecx+edx*2+1B8Ah]
    mov     ecx, [esi+18h]
    mov     al, [edx+96h]
    push    eax
    push    ecx
    call    sub_4B7F30
    jmp     short loc_45865B
    ; ---------------------------------------------------------------------------

    loc_458635:                             ; CODE XREF: sub_4584D0+12Aj
    mov     eax, [esp+3F68h+arg_18]
    test    eax, eax
    jz      short loc_45864D
    mov     edx, [esi+18h]
    push    0
    push    edx
    call    sub_4B7F30
    jmp     short loc_45865B
    ; ---------------------------------------------------------------------------

    loc_45864D:                             ; CODE XREF: sub_4584D0+16Ej
    lea     eax, [esi+10h]
    push    eax
    call    sub_4B7EE0
    jmp     short loc_45865B
    ; ---------------------------------------------------------------------------

    loc_458658:                             ; CODE XREF: sub_4584D0+123j
    mov     eax, [esi+10h]

    loc_45865B:                             ; CODE XREF: sub_4584D0+163j
                                            ; sub_4584D0+17Bj ...
    lea     ecx, [esp+3F68h+var_3F48]
    push    0
    push    ecx
    push    eax
    push    ebp
    call    sub_4C7580
    jmp     short loc_45867D
    ; ---------------------------------------------------------------------------

    loc_45866B:                             ; CODE XREF: sub_4584D0+10Cj
    mov     edx, [esi]
    mov     eax, [esi+4]
    push    edx
    lea     ecx, [esp+3F6Ch+var_3F48]
    push    eax
    push    ecx
    push    ebp
    call    sub_4C0310

    loc_45867D:                             ; CODE XREF: sub_4584D0+116j
                                            ; sub_4584D0+199j
    mov     eax, [ebx+8]
    inc     edi
    add     esi, 20h
    cmp     edi, eax
    mov     [esp+3F68h+var_3F58], edi
    jl      loc_458595

    loc_458690:                             ; CODE XREF: sub_4584D0+B8j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3F58h
    retn    1Ch
    sub_4584D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4586A0 proc near                    ; CODE XREF: sub_458810+FCp
                                            ; sub_459200+16Ep ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    lea     eax, [esp+0Ch+var_4]
    lea     edx, [esp+0Ch+arg_0]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+1Ch+arg_0]
    mov     esi, ecx
    push    0
    push    edi
    mov     ebp, [edi+0Ch]
    lea     ecx, [esp+24h+var_8]
    push    eax
    push    ecx
    lea     eax, [esp+2Ch+var_C]
    push    edx
    push    eax
    mov     ecx, esi
    call    sub_4581E0
    mov     eax, [esp+1Ch+arg_4]
    test    eax, eax
    jnz     short loc_458709
    test    byte ptr [ebp+114h], 1
    jnz     short loc_458709
    fld     dword ptr [ebp+104h]
    fcomp   ds:flt_4FD4C0
    fnstsw  ax
    test    ah, 40h
    jz      short loc_458709
    mov     ecx, [esp+1Ch+arg_0]
    mov     edx, [esp+1Ch+var_C]
    lea     ebx, [edi+10h]
    push    ecx
    push    edx
    push    ebx
    mov     ecx, esi
    call    sub_437B50
    jmp     short loc_45871E
    ; ---------------------------------------------------------------------------

    loc_458709:                             ; CODE XREF: sub_4586A0+34j
                                            ; sub_4586A0+3Dj ...
    mov     eax, [esp+1Ch+arg_0]
    mov     ecx, [esp+1Ch+var_C]
    lea     ebx, [edi+10h]
    push    eax
    push    ecx
    push    ebx
    mov     ecx, esi
    call    sub_437BE0

    loc_45871E:                             ; CODE XREF: sub_4586A0+67j
    mov     eax, [ebx]
    test    eax, eax
    jz      short loc_45879F
    mov     dx, word ptr [esp+1Ch+var_8]
    mov     [eax+4], dx
    mov     cx, word ptr [esp+1Ch+var_4]
    mov     [eax+6], cx
    mov     ecx, [ebp+110h]
    test    ecx, 20000000h
    jz      short loc_458779
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+37F06h], 20h
    jz      short loc_458779
    mov     ecx, [esp+1Ch+arg_8]
    xor     edx, edx
    mov     dl, [ebp+0FFh]
    push    ecx
    push    edx
    push    edi
    push    eax
    mov     ecx, esi
    call    sub_459C70
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_458779:                             ; CODE XREF: sub_4586A0+A2j
                                            ; sub_4586A0+B1j
    mov     ecx, [esp+1Ch+arg_8]
    xor     edx, edx
    mov     dl, [ebp+0FFh]
    push    ecx
    push    edx
    push    edi
    push    eax
    mov     ecx, esi
    call    sub_459830
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_45879F:                             ; CODE XREF: sub_4586A0+82j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_4586A0 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    mov     ebx, [esp+0Ch]
    push    ebp
    push    edi
    mov     edx, [ebx+14h]
    test    edx, edx
    jz      short loc_4587FF
    mov     ebp, [esp+10h]
    xor     edi, edi
    cmp     [ebx+2], di
    mov     ecx, [ebp+14h]
    jbe     short loc_4587FF
    push    esi

    loc_4587CE:                             ; CODE XREF: .text:004587FCj
    xor     eax, eax
    mov     ax, [ebx]
    mov     esi, eax
    dec     eax
    test    esi, esi
    jz      short loc_4587EB
    lea     esi, [eax+1]

    loc_4587DD:                             ; CODE XREF: .text:004587E9j
    xor     eax, eax
    inc     edx
    mov     al, [ecx]
    add     ecx, 2
    mov     [edx-1], al
    dec     esi
    jnz     short loc_4587DD

    loc_4587EB:                             ; CODE XREF: .text:004587D8j
    xor     eax, eax
    mov     ax, [ebp+0]
    add     ecx, eax
    xor     eax, eax
    mov     ax, [ebx+2]
    inc     edi
    cmp     edi, eax
    jl      short loc_4587CE
    pop     esi

    loc_4587FF:                             ; CODE XREF: .text:004587BCj
                                            ; .text:004587CBj
    pop     edi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_458810 proc near                    ; CODE XREF: sub_45AC20+253p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     esi, [eax+1431Fh]
    mov     ebp, [eax+14323h]
    push    edi
    mov     edi, [esp+28h+arg_0]
    mov     [esp+28h+var_14], ecx
    xor     edx, edx
    mov     ecx, [edi+0Ch]
    mov     [esp+28h+var_18], edx
    shl     esi, 10h
    mov     eax, [ecx+110h]
    shl     ebp, 10h
    test    eax, 20000000h
    jz      short loc_458862
    mov     al, [ecx+10Eh]
    not     al
    and     eax, 0FFh
    and     eax, 1
    mov     [esp+28h+arg_0], eax
    jmp     short loc_458870
    ; ---------------------------------------------------------------------------

    loc_458862:                             ; CODE XREF: sub_458810+3Aj
    mov     eax, [ecx]
    xor     ebx, ebx
    cmp     [eax+20h], edx
    setz    bl
    mov     [esp+28h+arg_0], ebx

    loc_458870:                             ; CODE XREF: sub_458810+50j
    cmp     [edi+4], edx
    jnz     short loc_45887D
    mov     [esp+28h+var_18], 1

    loc_45887D:                             ; CODE XREF: sub_458810+63j
    mov     ebx, [edi+10h]
    cmp     ebx, edx
    jnz     short loc_458887
    mov     [edi+14h], edx

    loc_458887:                             ; CODE XREF: sub_458810+72j
    mov     edx, [ecx+110h]
    mov     eax, edx
    and     eax, 20000000h
    mov     [esp+28h+var_10], eax
    jz      short loc_4588C9
    test    ebx, ebx
    jz      short loc_4588C1
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FD4C0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_4588C9
    test    dh, 20h
    jz      short loc_4588C9
    mov     eax, [ebx+14h]
    test    eax, eax
    jnz     short loc_4588C9
    test    eax, eax
    jnz     short loc_4588C9

    loc_4588C1:                             ; CODE XREF: sub_458810+8Cj
    mov     [esp+28h+var_18], 1

    loc_4588C9:                             ; CODE XREF: sub_458810+88j
                                            ; sub_458810+9Fj ...
    test    ebx, ebx
    jnz     short loc_4588DD
    mov     eax, [esp+28h+var_10]
    test    eax, eax
    jz      short loc_4588DD
    mov     [esp+28h+var_18], 1

    loc_4588DD:                             ; CODE XREF: sub_458810+BBj
                                            ; sub_458810+C3j
    test    byte ptr [ecx+114h], 1
    jz      short loc_4588F2
    test    ebx, ebx
    jnz     short loc_4588F2
    mov     [esp+28h+var_18], 1

    loc_4588F2:                             ; CODE XREF: sub_458810+D4j
                                            ; sub_458810+D8j
    mov     eax, [esp+28h+var_18]
    test    eax, eax
    jz      short loc_458913
    mov     ebx, [esp+28h+var_14]
    push    1
    push    0
    push    edi
    mov     ecx, ebx
    mov     dword ptr [edi+14h], 0
    call    sub_4586A0
    jmp     short loc_458917
    ; ---------------------------------------------------------------------------

    loc_458913:                             ; CODE XREF: sub_458810+E8j
    mov     ebx, [esp+28h+var_14]

    loc_458917:                             ; CODE XREF: sub_458810+101j
    mov     ecx, [edi+10h]
    mov     eax, [esp+28h+var_8]
    test    ecx, ecx
    mov     [esp+28h+var_C], esi
    mov     [esp+28h+var_8], eax
    mov     [esp+28h+var_4], ebp
    jz      short loc_45895A
    mov     ecx, [esp+28h+arg_0]
    push    ecx
    mov     ecx, ebx
    sub     esp, 0Ch
    mov     edx, esp
    push    edi
    mov     [edx], esi
    mov     [edx+4], eax
    mov     eax, [esp+3Ch+arg_4]
    push    eax
    mov     [edx+8], ebp
    call    sub_459200
    inc     dword ptr [edi+4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_45895A:                             ; CODE XREF: sub_458810+11Cj
    mov     eax, [edi]
    dec     eax
    js      short loc_4589AA
    mov     ebp, [esp+28h+arg_4]
    lea     ecx, [eax+eax*2]
    inc     eax
    lea     ecx, [ecx+ecx*8]
    mov     [esp+28h+var_14], eax
    lea     esi, [edi+ecx*2+44h]

    loc_458972:                             ; CODE XREF: sub_458810+198j
    test    byte ptr [esi+6], 1
    jz      short loc_45899C
    mov     eax, [edi+0Ch]
    mov     edx, [esp+28h+arg_0]
    push    edx
    mov     edx, [esi]
    mov     cl, [eax+0FFh]
    mov     eax, [esi-22h]
    push    ecx
    push    edx
    lea     ecx, [esp+34h+var_C]
    push    eax
    push    ecx
    push    ebp
    push    edi
    mov     ecx, ebx
    call    sub_4584D0

    loc_45899C:                             ; CODE XREF: sub_458810+166j
    mov     eax, [esp+28h+var_14]
    sub     esi, 36h
    dec     eax
    mov     [esp+28h+var_14], eax
    jnz     short loc_458972

    loc_4589AA:                             ; CODE XREF: sub_458810+14Dj
    mov     eax, [edi+4]
    inc     eax
    mov     [edi+4], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    sub_458810 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4589C0 proc near                    ; CODE XREF: sub_459200+408p

    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_24= dword ptr -24h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 68h
    push    ebx
    push    ebp
    push    esi
    push    edi
    sub     esp, 0Ch
    mov     ebp, [esp+84h+arg_4]
    mov     esi, esp
    xor     eax, eax
    mov     ebx, ecx
    xor     edx, edx
    mov     [esi], eax
    xor     ecx, ecx
    lea     eax, [esp+84h+var_60]
    push    ebp
    mov     [esi+4], ecx
    lea     ecx, [esp+88h+var_64]
    push    eax
    push    ecx
    mov     [esi+8], edx
    lea     edx, [esp+90h+var_68]
    lea     eax, [esp+90h+var_5C]
    xor     edi, edi
    push    edx
    push    eax
    mov     ecx, ebx
    mov     [esp+98h+var_5C], edi
    mov     [esp+98h+var_68], edi
    mov     [esp+98h+var_64], edi
    mov     [esp+98h+var_60], edi
    call    sub_458310
    mov     ecx, [ebp+0Ch]
    mov     esi, [ecx+8Ah]
    cmp     esi, edi
    jz      loc_458B29
    jmp     short loc_458A2B
    ; ---------------------------------------------------------------------------

    loc_458A24:                             ; CODE XREF: sub_4589C0+163j
    mov     ebp, [esp+78h+arg_4]

    loc_458A2B:                             ; CODE XREF: sub_4589C0+62j
    test    dword ptr [esi+110h], 20000h
    jnz     loc_458B1B
    sub     esp, 0Ch
    xor     eax, eax
    mov     edx, esp
    lea     ecx, [esp+84h+var_4C]
    mov     [esp+84h+var_58], edi
    mov     [esp+84h+var_54], edi
    mov     [edx], eax
    mov     [esp+84h+var_50], edi
    mov     [esp+84h+var_4C], edi
    mov     [edx+4], eax
    mov     [edx+8], eax
    mov     eax, [esi+9Eh]
    push    eax
    lea     edx, [esp+88h+var_54]
    push    ecx
    lea     eax, [esp+8Ch+var_50]
    push    edx
    lea     ecx, [esp+90h+var_58]
    push    eax
    push    ecx
    mov     ecx, ebx
    call    sub_458310
    mov     eax, [ebp+0Ch]
    mov     edx, [esi+6Eh]
    add     eax, 6Ah
    mov     ecx, [esi+6Ah]
    mov     edi, [eax+4]
    mov     ebp, [eax]
    sub     edx, edi
    mov     edi, [esi+72h]
    mov     [esp+78h+var_38], edx
    mov     [esp+78h+var_44], edx
    mov     dx, word ptr [esp+78h+var_38+2]
    sub     ecx, ebp
    mov     ebp, [eax+8]
    mov     [esp+78h+var_48], ecx
    sar     dx, 1
    movsx   eax, dx
    sub     edi, ebp
    mov     ecx, eax
    mov     [esp+78h+var_34], edi
    mov     ebp, [esp+78h+var_54]
    movsx   edx, word ptr [esp+78h+var_34+2]
    shl     ecx, 10h
    sub     ecx, eax
    mov     [esp+78h+var_40], edi
    movsx   eax, word ptr [esp+78h+var_48+2]
    mov     edi, [esp+78h+var_50]
    add     ecx, edx
    mov     edx, [esp+78h+var_58]
    add     edi, eax
    shl     ecx, 10h
    mov     [esp+78h+var_44], ecx
    add     edx, eax
    movsx   ecx, word ptr [esp+78h+var_44+2]
    mov     eax, [esp+78h+var_4C]
    add     ebp, ecx
    add     eax, ecx
    mov     ecx, [esp+78h+var_5C]
    cmp     edx, ecx
    jge     short loc_458AFB
    mov     [esp+78h+var_5C], edx

    loc_458AFB:                             ; CODE XREF: sub_4589C0+135j
    cmp     edi, [esp+78h+var_68]
    jle     short loc_458B05
    mov     [esp+78h+var_68], edi

    loc_458B05:                             ; CODE XREF: sub_4589C0+13Fj
    cmp     ebp, [esp+78h+var_64]
    jge     short loc_458B0F
    mov     [esp+78h+var_64], ebp

    loc_458B0F:                             ; CODE XREF: sub_4589C0+149j
    cmp     eax, [esp+78h+var_60]
    jle     short loc_458B19
    mov     [esp+78h+var_60], eax

    loc_458B19:                             ; CODE XREF: sub_4589C0+153j
    xor     edi, edi

    loc_458B1B:                             ; CODE XREF: sub_4589C0+75j
    mov     esi, [esi+8Eh]
    cmp     esi, edi
    jnz     loc_458A24

    loc_458B29:                             ; CODE XREF: sub_4589C0+5Cj
    mov     ebp, [esp+78h+arg_0]
    xor     ecx, ecx
    movsx   edx, word ptr [ebp+4]
    mov     cx, [ebp+0]
    mov     eax, edx
    movsx   esi, word ptr [ebp+6]
    sub     ecx, edx
    xor     edx, edx
    mov     dx, [ebp+2]
    mov     [esp+78h+arg_0], ecx
    mov     ecx, esi
    sub     edx, esi
    mov     esi, [esp+78h+var_5C]
    neg     eax
    neg     ecx
    cmp     esi, eax
    jge     short loc_458B5B
    mov     eax, esi

    loc_458B5B:                             ; CODE XREF: sub_4589C0+197j
    mov     esi, [esp+78h+arg_0]
    cmp     [esp+78h+var_68], esi
    jle     short loc_458B69
    mov     esi, [esp+78h+var_68]

    loc_458B69:                             ; CODE XREF: sub_4589C0+1A3j
    cmp     [esp+78h+var_64], ecx
    jge     short loc_458B73
    mov     ecx, [esp+78h+var_64]

    loc_458B73:                             ; CODE XREF: sub_4589C0+1ADj
    cmp     [esp+78h+var_60], edx
    jle     short loc_458B7D
    mov     edx, [esp+78h+var_60]

    loc_458B7D:                             ; CODE XREF: sub_4589C0+1B7j
    sub     edx, ecx
    sub     esi, eax
    neg     ecx
    mov     [esp+78h+arg_0], ecx
    mov     ecx, [ebx+10h]
    neg     eax
    mov     [ecx], si
    mov     ecx, [ebx+10h]
    mov     [ecx+2], dx
    mov     ecx, [ebx+10h]
    mov     [ecx+4], ax
    mov     eax, [ebx+10h]
    mov     cx, word ptr [esp+78h+arg_0]
    mov     [eax+6], cx
    mov     eax, [ebx+10h]
    mov     cl, [ebp+8]
    mov     [eax+8], cl
    xor     eax, eax
    mov     ax, [ebp+0]
    cmp     esi, eax
    jnz     short loc_458C0B
    xor     ecx, ecx
    mov     cx, [ebp+2]
    cmp     edx, ecx
    jnz     short loc_458C0B
    imul    ecx, eax
    mov     edx, [ebx+10h]
    mov     esi, [ebp+10h]
    mov     eax, ecx
    mov     edi, [edx+10h]
    xor     edx, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     dx, [ebp+2]
    xor     ecx, ecx
    mov     cx, [ebp+0]
    mov     eax, [ebx+10h]
    imul    ecx, edx
    mov     esi, [ebp+14h]
    mov     edi, [eax+14h]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    jmp     loc_458D00
    ; ---------------------------------------------------------------------------

    loc_458C0B:                             ; CODE XREF: sub_4589C0+1FAj
                                            ; sub_4589C0+204j
    mov     ax, [ebp+4]
    mov     [ebp+4], di
    mov     cx, [ebp+6]
    mov     [ebp+6], di
    mov     edx, [ebx+10h]
    mov     word ptr [esp+78h+arg_0], ax
    lea     eax, [esp+78h+var_30]
    push    edx                             ; int
    push    eax                             ; int
    mov     word ptr [esp+80h+var_4C], cx
    call    sub_4B8A80
    mov     esi, [ebx+10h]
    xor     ecx, ecx
    xor     edx, edx
    xor     eax, eax
    mov     cx, [esi+2]
    mov     dx, [esi]
    mov     al, [esi+8]
    imul    ecx, edx
    mov     edi, [esi+10h]
    mov     dl, al
    mov     dh, dl
    mov     esi, ecx
    mov     eax, edx
    shl     eax, 10h
    mov     ax, dx
    shr     ecx, 2
    rep stosd
    mov     ecx, esi
    and     ecx, 3
    rep stosb
    mov     edx, [ebx+10h]
    xor     ecx, ecx
    xor     eax, eax
    mov     cx, [edx+2]
    mov     ax, [edx]
    imul    ecx, eax
    mov     edi, [edx+14h]
    mov     edx, ecx
    xor     eax, eax
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    movsx   esi, word ptr [esp+78h+var_4C]
    and     ecx, 3
    rep stosb
    mov     eax, [ebx+10h]
    movsx   edi, word ptr [esp+78h+arg_0]
    movsx   ecx, word ptr [eax+6]
    movsx   edx, word ptr [eax+4]
    sub     ecx, esi
    sub     edx, edi
    push    ecx
    push    edx
    lea     eax, [esp+80h+var_30]
    push    ebp
    push    eax
    call    sub_4B7F90
    mov     ecx, [ebx+10h]
    mov     eax, [ebp+10h]
    mov     edx, [ecx+14h]
    mov     ecx, [ebp+14h]
    mov     [ebp+10h], ecx
    mov     [ebp+14h], eax
    mov     eax, [ebx+10h]
    mov     [esp+78h+var_24], edx
    lea     ecx, [esp+78h+var_30]
    movsx   edx, word ptr [eax+6]
    movsx   eax, word ptr [eax+4]
    sub     edx, esi
    sub     eax, edi
    push    edx
    push    eax
    push    ebp
    push    ecx
    call    sub_4B7F90
    mov     edx, [ebp+14h]
    mov     eax, [ebp+10h]
    mov     [ebp+10h], edx
    mov     [ebp+14h], eax
    mov     ax, word ptr [esp+78h+arg_0]
    mov     cx, word ptr [esp+78h+var_4C]
    mov     [ebp+4], ax
    mov     [ebp+6], cx

    loc_458D00:                             ; CODE XREF: sub_4589C0+246j
    mov     edx, [esp+78h+arg_4]
    mov     eax, [ebx+10h]
    push    edx
    push    eax
    mov     ecx, ebx
    call    sub_458DD0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    8
    sub_4589C0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+8]
    mov     ecx, [eax]
    dec     ecx
    mov     [esp+8], ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_458D30 proc near                    ; CODE XREF: sub_458DD0+1A2p

    var_1= byte ptr -1
    arg_0= dword ptr  4
    arg_4= byte ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    push    ecx
    mov     al, [esp+4+arg_4]
    push    ebx
    push    ebp
    push    esi
    cmp     al, 4
    push    edi
    jnb     short loc_458D41
    xor     bl, bl
    jmp     short loc_458D46
    ; ---------------------------------------------------------------------------

    loc_458D41:                             ; CODE XREF: sub_458D30+Bj
    mov     bl, al
    sub     bl, 4

    loc_458D46:                             ; CODE XREF: sub_458D30+Fj
    mov     ecx, [esp+14h+arg_0]
    xor     eax, eax
    xor     edx, edx
    xor     esi, esi
    mov     ax, [ecx]
    mov     dx, [ecx+2]
    imul    eax, edx
    test    eax, eax
    mov     [esp+14h+var_1], bl
    jle     short loc_458DBD
    mov     ebp, [esp+14h+arg_10]
    jmp     short loc_458D6C
    ; ---------------------------------------------------------------------------

    loc_458D68:                             ; CODE XREF: sub_458D30+8Bj
    mov     bl, [esp+14h+var_1]

    loc_458D6C:                             ; CODE XREF: sub_458D30+36j
    mov     eax, [ecx+10h]
    mov     dl, [ecx+8]
    lea     edi, [esi+eax]
    mov     al, [esi+eax]
    cmp     al, dl
    jz      short loc_458DAA
    mov     eax, [ecx+14h]
    mov     al, [eax+esi]
    cmp     al, bl
    jnb     short loc_458D8C
    mov     eax, [esp+14h+arg_C]
    jmp     short loc_458D9A
    ; ---------------------------------------------------------------------------

    loc_458D8C:                             ; CODE XREF: sub_458D30+54j
    mov     bl, [esp+14h+arg_4]
    cmp     al, bl
    mov     eax, [esp+14h+arg_8]
    jnb     short loc_458D9A
    mov     eax, ebp

    loc_458D9A:                             ; CODE XREF: sub_458D30+5Aj
                                            ; sub_458D30+66j
    cmp     eax, 0FFFFFFFEh
    jz      short loc_458DA8
    cmp     eax, 0FFFFFFFFh
    jz      short loc_458DAA
    mov     [edi], al
    jmp     short loc_458DAA
    ; ---------------------------------------------------------------------------

    loc_458DA8:                             ; CODE XREF: sub_458D30+6Dj
    mov     [edi], dl

    loc_458DAA:                             ; CODE XREF: sub_458D30+4Aj
                                            ; sub_458D30+72j ...
    xor     edx, edx
    xor     eax, eax
    mov     dx, [ecx]
    mov     ax, [ecx+2]
    imul    edx, eax
    inc     esi
    cmp     esi, edx
    jl      short loc_458D68

    loc_458DBD:                             ; CODE XREF: sub_458D30+30j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    14h
    sub_458D30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_458DD0 proc near                    ; CODE XREF: sub_4589C0+34Ep
                                            ; sub_459200+486p

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, ecx
    mov     eax, [ebp+14h]
    test    eax, eax
    jnz     short loc_458DEA
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_458DEA:                             ; CODE XREF: sub_458DD0+Fj
    mov     eax, [esp+8+arg_4]
    mov     edx, [eax+0Ch]
    mov     [esp+8+arg_0], edx
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FD4C0
    fnstsw  ax
    test    ah, 40h
    jz      short loc_458E11
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_458E11:                             ; CODE XREF: sub_458DD0+36j
    xor     ecx, ecx
    mov     eax, 88888889h
    mov     cx, [edx+0A8h]
    mov     edx, TAdynmemStructPtr
    mov     ebx, ecx
    xor     ecx, 9
    mov     esi, [edx+38A47h]
    xor     ebx, 5
    mov     edx, esi
    shl     edx, 5
    add     edx, esi
    mul     edx
    lea     eax, [esi+esi*8]
    shr     edx, 4
    lea     eax, [esi+eax*2]
    add     ebx, edx
    lea     edx, [eax+eax*2]
    mov     eax, 88888889h
    mul     edx
    shr     edx, 4
    add     ecx, edx
    test    bl, 10h
    jz      short loc_458E67
    and     ebx, 0Fh
    mov     esi, 0AFh
    sub     esi, ebx
    jmp     short loc_458E72
    ; ---------------------------------------------------------------------------

    loc_458E67:                             ; CODE XREF: sub_458DD0+89j
    and     ebx, 0Fh
    add     ebx, 0A0h
    mov     esi, ebx

    loc_458E72:                             ; CODE XREF: sub_458DD0+95j
    test    cl, 10h
    jz      short loc_458E83
    and     ecx, 0Fh
    mov     ebx, 0AFh
    sub     ebx, ecx
    jmp     short loc_458E8E
    ; ---------------------------------------------------------------------------

    loc_458E83:                             ; CODE XREF: sub_458DD0+A5j
    and     ecx, 0Fh
    add     ecx, 0A0h
    mov     ebx, ecx

    loc_458E8E:                             ; CODE XREF: sub_458DD0+B1j
    mov     eax, [esp+8+arg_0]
    fld     dword ptr [eax+104h]
    fmul    ds:flt_4FD4C4
    call    __ftol
    cmp     eax, 0EBh
    jle     short loc_458ECA
    add     eax, 0FFFFFF15h
    push    esi
    mov     ecx, eax
    push    0FFFFFFFEh
    shl     ecx, 8
    sub     ecx, eax
    mov     eax, 66666667h
    imul    ecx
    push    0FFFFFFFEh
    sar     edx, 3
    jmp     loc_458F67
    ; ---------------------------------------------------------------------------

    loc_458ECA:                             ; CODE XREF: sub_458DD0+D8j
    cmp     eax, 0C8h
    jle     short loc_458EF7
    add     eax, 0FFFFFF38h
    push    esi
    mov     ecx, eax
    push    0FFFFFFFEh
    shl     ecx, 8
    sub     ecx, eax
    mov     eax, 0EA0EA0EBh
    imul    ecx
    add     edx, ecx
    push    0FFFFFFFEh
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    jmp     short loc_458F6E
    ; ---------------------------------------------------------------------------

    loc_458EF7:                             ; CODE XREF: sub_458DD0+FFj
    cmp     eax, 73h
    jle     short loc_458F23
    mov     ecx, 73h
    push    ebx
    sub     ecx, eax
    mov     eax, 60606061h
    mov     edx, ecx
    push    esi
    shl     edx, 8
    sub     edx, ecx
    push    0FFFFFFFEh
    imul    edx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    dec     dl
    jmp     short loc_458F6E
    ; ---------------------------------------------------------------------------

    loc_458F23:                             ; CODE XREF: sub_458DD0+12Aj
    cmp     eax, 1Eh
    jle     short loc_458F4F
    mov     ecx, 1Eh
    push    ebx
    sub     ecx, eax
    mov     eax, 60606061h
    mov     edx, ecx
    push    0FFFFFFFFh
    shl     edx, 8
    sub     edx, ecx
    push    esi
    imul    edx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    dec     dl
    jmp     short loc_458F6E
    ; ---------------------------------------------------------------------------

    loc_458F4F:                             ; CODE XREF: sub_458DD0+156j
    mov     ecx, eax
    push    esi
    shl     ecx, 8
    sub     ecx, eax
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    push    0FFFFFFFFh
    push    0FFFFFFFFh
    sar     edx, 4

    loc_458F67:                             ; CODE XREF: sub_458DD0+F5j
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_458F6E:                             ; CODE XREF: sub_458DD0+125j
                                            ; sub_458DD0+151j ...
    push    edx
    push    ebp
    mov     ecx, edi
    call    sub_458D30
    mov     edx, [esp+8+arg_4]
    push    ebx
    push    edx
    push    ebp
    mov     ecx, edi
    call    sub_458FA0
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    8
    sub_458DD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_458FA0 proc near                    ; CODE XREF: sub_458DD0+1B0p

    var_5EFC= dword ptr -5EFCh
    var_5EF8= dword ptr -5EF8h
    var_5EF4= dword ptr -5EF4h
    var_5EF0= dword ptr -5EF0h
    var_5EEC= dword ptr -5EECh
    var_5EE8= dword ptr -5EE8h
    var_5EE4= dword ptr -5EE4h
    var_5DC0= dword ptr -5DC0h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, 5EFCh
    call    __alloca_probe
    mov     edx, [esp+5EFCh+arg_4]
    mov     ecx, [edx]
    dec     ecx
    js      loc_45915E
    lea     eax, [ecx+ecx*2]
    push    edi
    push    esi
    inc     ecx
    lea     eax, [eax+eax*8]
    push    ebp
    mov     ebp, [esp+5F08h+arg_0]
    push    ebx
    lea     eax, [edx+eax*2+22h]
    mov     [esp+5F0Ch+var_5EF0], ecx
    mov     [esp+5F0Ch+var_5EF8], eax
    jmp     short loc_458FE1
    ; ---------------------------------------------------------------------------

    loc_458FDA:                             ; CODE XREF: sub_458FA0+1B4j
    mov     edx, [esp+5F0Ch+arg_4]

    loc_458FE1:                             ; CODE XREF: sub_458FA0+38j
    test    byte ptr [eax+28h], 1
    jz      loc_459144
    mov     ebx, [eax]
    mov     ecx, [eax+22h]
    mov     [esp+5F0Ch+var_5EF4], ebx
    mov     esi, [ebx+4]
    test    esi, esi
    jle     loc_459084
    mov     edx, [edx+0Ch]
    mov     eax, [edx+92h]
    mov     edx, [eax+241h]
    lea     eax, [esp+5F0Ch+var_5DC0]
    shr     edx, 1Eh
    and     dl, 1
    neg     dl
    sbb     edx, edx
    and     edx, 4Bh
    add     edx, 32h
    mov     edi, edx

    loc_459027:                             ; CODE XREF: sub_458FA0+DAj
    mov     ebx, [ecx]
    mov     edx, [ecx+4]
    mov     ebp, [ecx+8]
    add     eax, 0Ch
    sar     ebx, 10h
    sar     edx, 10h
    movsx   ebx, bx
    movsx   edx, dx
    neg     ebp
    sar     ebp, 10h
    mov     [eax-0Ch], ebx
    mov     ebx, edx
    movsx   ebp, bp
    sar     ebx, 1
    sub     ebp, ebx
    add     edx, edi
    mov     [eax-8], ebp
    mov     ebp, [esp+5F0Ch+arg_0]
    mov     [eax-4], edx
    mov     ebx, [eax-0Ch]
    movsx   edx, word ptr [ebp+4]
    add     ebx, edx
    add     ecx, 0Ch
    movsx   edx, word ptr [ebp+6]
    mov     [eax-0Ch], ebx
    mov     ebx, [eax-8]
    add     ebx, edx
    dec     esi
    mov     [eax-8], ebx
    jnz     short loc_459027
    mov     ebx, [esp+5F0Ch+var_5EF4]
    mov     eax, [esp+5F0Ch+var_5EF8]

    loc_459084:                             ; CODE XREF: sub_458FA0+59j
    mov     ecx, [ebx+0Ch]
    mov     esi, [ebx+28h]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_459099
    add     esi, 20h
    mov     edi, 1
    jmp     short loc_45909B
    ; ---------------------------------------------------------------------------

    loc_459099:                             ; CODE XREF: sub_458FA0+EDj
    xor     edi, edi

    loc_45909B:                             ; CODE XREF: sub_458FA0+F7j
    mov     ecx, [ebx+8]
    mov     [esp+5F0Ch+var_5EFC], edi
    cmp     edi, ecx
    jge     loc_459144
    add     esi, 4

    loc_4590AD:                             ; CODE XREF: sub_458FA0+19Aj
    mov     eax, [esi]
    mov     edx, [esi+8]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_4590F9
    lea     edi, [esp+5F0Ch+var_5EEC]

    loc_4590BC:                             ; CODE XREF: sub_458FA0+148j
    xor     eax, eax
    mov     ebx, edi
    mov     ax, [edx]
    inc     ecx
    add     edi, 0Ch
    add     edx, 2
    lea     eax, [eax+eax*2]
    lea     eax, [esp+eax*4+5F0Ch+var_5DC0]
    mov     ebp, [eax]
    mov     [ebx], ebp
    mov     ebp, [eax+4]
    mov     [ebx+4], ebp
    mov     eax, [eax+8]
    mov     [ebx+8], eax
    mov     eax, [esi]
    cmp     ecx, eax
    jl      short loc_4590BC
    mov     edi, [esp+5F0Ch+var_5EFC]
    mov     ebp, [esp+5F0Ch+arg_0]
    mov     ebx, [esp+5F0Ch+var_5EF4]

    loc_4590F9:                             ; CODE XREF: sub_458FA0+116j
    mov     eax, [esp+5F0Ch+var_5EEC]
    lea     ecx, [ecx+ecx*2]
    lea     edx, [esp+ecx*4+5F0Ch+var_5EEC]
    mov     [esp+ecx*4+5F0Ch+var_5EEC], eax
    mov     ecx, [esp+5F0Ch+var_5EE8]
    mov     [edx+4], ecx
    mov     eax, [esp+5F0Ch+var_5EE4]
    mov     ecx, [esp+5F0Ch+arg_8]
    mov     [edx+8], eax
    mov     edx, [esi]
    inc     edx
    push    ecx
    lea     eax, [esp+5F10h+var_5EEC]
    push    edx
    push    eax
    push    ebp
    call    sub_4C0820
    mov     eax, [ebx+8]
    inc     edi
    add     esi, 20h
    cmp     edi, eax
    mov     [esp+5F0Ch+var_5EFC], edi
    jl      loc_4590AD
    mov     eax, [esp+5F0Ch+var_5EF8]

    loc_459144:                             ; CODE XREF: sub_458FA0+45j
                                            ; sub_458FA0+104j
    mov     ecx, [esp+5F0Ch+var_5EF0]
    sub     eax, 36h
    dec     ecx
    mov     [esp+5F0Ch+var_5EF8], eax
    mov     [esp+5F0Ch+var_5EF0], ecx
    jnz     loc_458FDA
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_45915E:                             ; CODE XREF: sub_458FA0+14j
    add     esp, 5EFCh
    retn    0Ch
    sub_458FA0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     edx, ecx
    push    ebx
    push    esi
    mov     ecx, [edx+10h]
    mov     si, [eax]
    push    edi
    mov     [ecx], si
    mov     ecx, [edx+10h]
    mov     si, [eax+2]
    mov     [ecx+2], si
    mov     ecx, [edx+10h]
    mov     si, [eax+4]
    mov     [ecx+4], si
    mov     ecx, [edx+10h]
    mov     si, [eax+6]
    mov     [ecx+6], si
    mov     ecx, [edx+10h]
    mov     bl, [eax+8]
    xor     esi, esi
    mov     [ecx+8], bl
    mov     si, [eax+2]
    xor     ecx, ecx
    mov     edi, [edx+10h]
    mov     cx, [eax]
    imul    ecx, esi
    mov     esi, [eax+10h]
    mov     edi, [edi+10h]
    mov     ebx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb
    mov     esi, [eax+14h]
    test    esi, esi
    jz      short loc_4591FA
    xor     ecx, ecx
    xor     edi, edi
    mov     cx, [eax]
    mov     di, [eax+2]
    imul    ecx, edi
    mov     edx, [edx+10h]
    mov     eax, ecx
    shr     ecx, 2
    mov     edi, [edx+14h]
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4591FA:                             ; CODE XREF: .text:004591D6j
    pop     edi
    pop     esi
    pop     ebx
    retn    4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_459200 proc near                    ; CODE XREF: .text:00458468p
                                            ; sub_458810+138p

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 20h
    push    ebx
    push    ebp
    mov     ebp, [esp+28h+arg_4]
    push    esi
    push    edi
    mov     edi, ecx
    mov     esi, [ebp+10h]
    test    esi, esi
    jz      loc_4597D8
    mov     eax, [esp+30h+arg_8]
    mov     ecx, [esp+30h+arg_C]
    mov     edx, [esp+30h+arg_10]
    mov     [esp+30h+var_C], eax
    mov     eax, [ebp+0Ch]
    mov     [esp+30h+var_8], ecx
    mov     [esp+30h+var_4], edx
    mov     ebx, [eax+6Ah]
    lea     ecx, [eax+6Ah]
    sub     ebx, [esp+30h+arg_8]
    push    ecx
    mov     [esp+34h+arg_8], ebx
    mov     ebx, [eax+6Eh]
    mov     eax, [eax+72h]
    mov     [esp+34h+arg_C], ebx
    sub     eax, edx
    mov     [esp+34h+arg_10], eax
    call    sub_485070
    movsx   edx, word ptr [esp+30h+arg_C+2]
    movsx   ecx, word ptr [esp+30h+arg_10+2]
    mov     ebx, edx
    mov     [esp+30h+var_1C], edx
    sar     ebx, 1
    mov     edx, ecx
    sar     eax, 1
    sub     edx, ebx
    sub     ecx, eax
    mov     eax, [esi+14h]
    add     edx, 20h
    add     ecx, 20h
    mov     [esp+30h+arg_4], edx
    test    eax, eax
    mov     ebx, ecx
    jnz     loc_45949D
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    test    al, 4
    jz      loc_45935C
    mov     ecx, [ebp+0Ch]
    mov     ecx, [ecx+92h]
    mov     ecx, [ecx+241h]
    test    ecx, 2000000h
    mov     [esp+30h+var_20], ecx
    jnz     loc_45935C
    mov     ecx, [ebp+0Ch]
    test    byte ptr [ecx+113h], 20h
    jz      short loc_459324
    test    [esp+30h+var_20], 40000000h
    jnz     short loc_459324
    mov     eax, [ebp+0Ch]
    cmp     word ptr [eax+0A6h], 0
    jnz     short loc_4592F3
    mov     eax, TAdynmemStructPtr
    movzx   cx, byte ptr [eax+1427Fh]
    cmp     word ptr [esp+30h+arg_C+2], cx
    jl      short loc_45935C

    loc_4592F3:                             ; CODE XREF: sub_459200+DDj
    mov     eax, [ebp+14h]
    test    eax, eax
    jnz     short loc_459303
    push    esi
    push    ebp
    mov     ecx, edi
    call    sub_45A790

    loc_459303:                             ; CODE XREF: sub_459200+F8j
    movsx   edx, word ptr [esp+30h+arg_8+2]
    mov     eax, [ebp+14h]
    add     edx, 85h
    push    ebx
    mov     ebx, [esp+34h+arg_0]
    push    edx
    push    eax
    push    ebx
    call    sub_4B8500
    mov     edx, [esp+30h+arg_4]
    jmp     short loc_459360
    ; ---------------------------------------------------------------------------

    loc_459324:                             ; CODE XREF: sub_459200+C6j
                                            ; sub_459200+D0j
    shr     al, 3
    test    al, 1
    jz      short loc_45935C
    test    [esp+30h+var_20], 81000h
    jnz     short loc_45935C
    push    esi
    mov     ecx, edi
    call    sub_45A470
    movsx   ecx, word ptr [esp+30h+arg_8+2]
    mov     edx, [edi+10h]
    mov     eax, [esp+30h+arg_0]
    add     ecx, 85h
    push    ebx
    push    ecx
    push    edx
    push    eax
    call    sub_4B8500
    mov     edx, [esp+30h+arg_4]

    loc_45935C:                             ; CODE XREF: sub_459200+97j
                                            ; sub_459200+B6j ...
    mov     ebx, [esp+30h+arg_0]

    loc_459360:                             ; CODE XREF: sub_459200+122j
    mov     eax, [ebp+10h]
    test    eax, eax
    jnz     short loc_45937A
    push    1
    push    0
    push    ebp
    mov     ecx, edi
    call    sub_4586A0
    mov     esi, [ebp+10h]
    mov     edx, [esp+30h+arg_4]

    loc_45937A:                             ; CODE XREF: sub_459200+165j
    mov     ecx, [ebp+0Ch]
    test    byte ptr [ecx+10Eh], 4
    jnz     short loc_4593AB
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+14280h]
    test    cl, cl
    jnz     short loc_4593AB
    movsx   ecx, word ptr [esp+30h+arg_8+2]
    add     ecx, 80h
    push    edx
    push    ecx
    push    esi
    push    ebx
    call    sub_4B7F90
    jmp     short loc_4593BF
    ; ---------------------------------------------------------------------------

    loc_4593AB:                             ; CODE XREF: sub_459200+184j
                                            ; sub_459200+193j
    push    edx
    movsx   edx, word ptr [esp+34h+arg_8+2]
    add     edx, 80h
    push    edx
    push    esi
    push    ebx
    call    sub_4B8500

    loc_4593BF:                             ; CODE XREF: sub_459200+1A9j
    mov     eax, [ebp+0]
    dec     eax
    js      short loc_459412
    lea     ecx, [eax+eax*2]
    inc     eax
    mov     [esp+30h+arg_0], eax
    lea     ecx, [ecx+ecx*8]
    lea     esi, [ebp+ecx*2+4Ah]

    loc_4593D4:                             ; CODE XREF: sub_459200+210j
    mov     ax, [esi]
    test    al, 1
    jz      short loc_459404
    test    al, 2
    jnz     short loc_459404
    mov     eax, [ebp+0Ch]
    mov     edx, [esp+30h+arg_14]
    push    edx
    mov     edx, [esi-6]
    mov     cl, [eax+0FFh]
    mov     eax, [esi-28h]
    push    ecx
    push    edx
    lea     ecx, [esp+3Ch+var_C]
    push    eax
    push    ecx
    push    ebx
    push    ebp
    mov     ecx, edi
    call    sub_4584D0

    loc_459404:                             ; CODE XREF: sub_459200+1D9j
                                            ; sub_459200+1DDj
    mov     eax, [esp+30h+arg_0]
    sub     esi, 36h
    dec     eax
    mov     [esp+30h+arg_0], eax
    jnz     short loc_4593D4

    loc_459412:                             ; CODE XREF: sub_459200+1C3j
    mov     edx, [ebp+0Ch]
    mov     ebp, [edx+8Ah]
    test    ebp, ebp
    jz      loc_4597D8

    loc_459423:                             ; CODE XREF: sub_459200+291j
    test    dword ptr [ebp+110h], 20000h
    jnz     short loc_459489
    mov     eax, [ebp+9Eh]
    mov     eax, [eax]
    dec     eax
    js      short loc_459489
    lea     ecx, [eax+eax*2]
    lea     esi, [ecx+ecx*8]
    shl     esi, 1
    inc     eax
    mov     [esp+30h+arg_0], eax

    loc_459447:                             ; CODE XREF: sub_459200+287j
    mov     eax, [ebp+9Eh]
    test    byte ptr [esi+eax+4Ah], 1
    jz      short loc_45947B
    mov     ecx, [esp+30h+arg_14]
    mov     edx, [eax+0Ch]
    push    ecx
    mov     cl, [edx+0FFh]
    mov     edx, [esi+eax+44h]
    push    ecx
    mov     ecx, [esi+eax+22h]
    push    edx
    lea     edx, [esp+3Ch+var_C]
    push    ecx
    push    edx
    push    ebx
    push    eax
    mov     ecx, edi
    call    sub_4584D0

    loc_45947B:                             ; CODE XREF: sub_459200+252j
    mov     eax, [esp+30h+arg_0]
    sub     esi, 36h
    dec     eax
    mov     [esp+30h+arg_0], eax
    jnz     short loc_459447

    loc_459489:                             ; CODE XREF: sub_459200+22Dj
                                            ; sub_459200+238j
    mov     ebp, [ebp+8Eh]
    test    ebp, ebp
    jnz     short loc_459423
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_45949D:                             ; CODE XREF: sub_459200+82j
    mov     eax, TAdynmemStructPtr
    mov     ax, [eax+37F06h]
    test    al, 4
    jz      loc_4595EE
    mov     ecx, [ebp+0Ch]
    mov     edx, [ecx+92h]
    mov     edx, [edx+241h]
    test    edx, 2000000h
    mov     [esp+30h+var_20], edx
    jnz     loc_4595EE
    shr     edx, 1Eh
    test    dl, 1
    jz      short loc_459522
    push    esi
    mov     ecx, edi
    call    sub_45A470
    mov     eax, [ebp+0Ch]
    mov     edx, [edi+10h]
    mov     ecx, [eax+92h]
    mov     eax, [ecx+241h]
    shr     eax, 1Eh
    and     al, 1
    neg     al
    sbb     eax, eax
    and     eax, 4Bh
    add     eax, 32h
    push    eax                             ; char
    push    edx                             ; int
    call    sub_4BA1B0
    movsx   eax, word ptr [esp+30h+arg_8+2]
    mov     ecx, [edi+10h]
    mov     edx, [esp+30h+arg_0]
    add     eax, 85h
    push    ebx
    push    eax
    push    ecx
    push    edx
    jmp     loc_4595E9
    ; ---------------------------------------------------------------------------

    loc_459522:                             ; CODE XREF: sub_459200+2D6j
    test    dword ptr [ecx+110h], 20000000h
    jz      short loc_459578
    cmp     word ptr [ecx+0A6h], 0
    jnz     short loc_459550
    mov     eax, TAdynmemStructPtr
    movzx   cx, byte ptr [eax+1427Fh]
    cmp     word ptr [esp+30h+arg_C+2], cx
    jl      loc_4595EE

    loc_459550:                             ; CODE XREF: sub_459200+336j
    mov     eax, [ebp+14h]
    test    eax, eax
    jnz     short loc_459560
    push    esi
    push    ebp
    mov     ecx, edi
    call    sub_45A790

    loc_459560:                             ; CODE XREF: sub_459200+355j
    movsx   edx, word ptr [esp+30h+arg_8+2]
    mov     eax, [ebp+14h]
    mov     ecx, [esp+30h+arg_0]
    add     edx, 85h
    push    ebx
    push    edx
    push    eax
    push    ecx
    jmp     short loc_4595E9
    ; ---------------------------------------------------------------------------

    loc_459578:                             ; CODE XREF: sub_459200+32Cj
    shr     al, 3
    test    al, 1
    jz      short loc_4595EE
    test    [esp+30h+var_20], 81000h
    jnz     short loc_4595EE
    push    esi
    mov     ecx, edi
    call    sub_45A470
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [edx+1427Fh]
    mov     edx, [esp+30h+var_1C]
    sub     eax, edx
    test    eax, eax
    jle     short loc_4595D4
    mov     ecx, [ebp+0Ch]
    mov     edx, [ecx+92h]
    mov     ecx, [edx+241h]
    mov     edx, [edi+10h]
    shr     ecx, 1Eh
    and     cl, 1
    neg     cl
    sbb     ecx, ecx
    and     ecx, 4Bh
    add     ecx, 32h
    add     eax, ecx
    push    eax                             ; char
    push    edx                             ; int
    call    sub_4BA1B0

    loc_4595D4:                             ; CODE XREF: sub_459200+3A7j
    movsx   eax, word ptr [esp+30h+arg_8+2]
    mov     ecx, [edi+10h]
    mov     edx, [esp+30h+arg_0]
    add     eax, 85h
    push    ebx
    push    eax
    push    ecx
    push    edx

    loc_4595E9:                             ; CODE XREF: sub_459200+31Dj
                                            ; sub_459200+376j
    call    sub_4B8500

    loc_4595EE:                             ; CODE XREF: sub_459200+2ABj
                                            ; sub_459200+2CAj ...
    mov     eax, [ebp+10h]
    test    eax, eax
    jnz     short loc_459604
    push    1
    push    0
    push    ebp
    mov     ecx, edi
    call    sub_4586A0
    mov     esi, [ebp+10h]

    loc_459604:                             ; CODE XREF: sub_459200+3F3j
    push    ebp
    push    esi
    mov     ecx, edi
    call    sub_4589C0
    mov     ecx, [ebp+0Ch]
    test    dword ptr [ecx+110h], 20000000h
    jz      short loc_45962F
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FD4C0
    fnstsw  ax
    test    ah, 40h
    jz      short loc_459646

    loc_45962F:                             ; CODE XREF: sub_459200+41Aj
    xor     eax, eax
    push    0
    mov     al, [ecx+0FFh]
    mov     ecx, [edi+10h]
    push    eax
    push    ebp
    push    ecx
    mov     ecx, edi
    call    sub_459830

    loc_459646:                             ; CODE XREF: sub_459200+42Dj
    mov     edx, [ebp+0Ch]
    mov     esi, [edx+8Ah]
    test    esi, esi
    jz      loc_4596EB

    loc_459657:                             ; CODE XREF: sub_459200+4E5j
    test    dword ptr [esi+110h], 20000h
    jnz     short loc_4596DD
    mov     eax, [esi+9Eh]
    push    0FFFFFFFFh
    push    1
    push    eax
    mov     ecx, edi
    call    sub_4586A0
    mov     eax, [esi+9Eh]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jz      short loc_4596DD
    push    eax
    push    ecx
    mov     ecx, edi
    call    sub_458DD0
    mov     eax, [ebp+0Ch]
    mov     ecx, [esi+6Ah]
    add     eax, 6Ah
    mov     edx, [eax]
    mov     ebx, [eax+4]
    sub     ecx, edx
    mov     edx, [esi+6Eh]
    sub     edx, ebx
    mov     [esp+30h+var_18], ecx
    mov     ecx, [esi+72h]
    mov     [esp+30h+var_14], edx
    mov     edx, [eax+8]
    movsx   eax, word ptr [esp+30h+var_14+2]
    sub     ecx, edx
    push    eax
    mov     [esp+34h+var_10], ecx
    mov     ecx, [edi+10h]
    movsx   edx, word ptr [esp+34h+var_10+2]
    sar     eax, 1
    sub     edx, eax
    movsx   eax, word ptr [esp+34h+var_18+2]
    push    edx
    mov     edx, [esi+9Eh]
    push    eax
    push    ecx
    mov     eax, [edx+10h]
    push    eax
    call    sub_4B90A0

    loc_4596DD:                             ; CODE XREF: sub_459200+461j
                                            ; sub_459200+480j
    mov     esi, [esi+8Eh]
    test    esi, esi
    jnz     loc_459657

    loc_4596EB:                             ; CODE XREF: sub_459200+451j
    mov     esi, TAdynmemStructPtr
    mov     edx, [esp+30h+var_1C]
    xor     eax, eax
    mov     al, [esi+1427Fh]
    sub     eax, edx
    test    eax, eax
    jle     short loc_459755
    mov     ecx, [ebp+0Ch]
    mov     edx, [ecx+92h]
    mov     edx, [edx+241h]
    shr     edx, 1Eh
    and     dl, 1
    neg     dl
    sbb     edx, edx
    and     edx, 4Bh
    add     edx, 32h
    add     eax, edx
    mov     edx, [ecx+110h]
    test    dh, 2
    jnz     short loc_45974B
    mov     cl, [ecx+0FFh]
    mov     dl, [esi+TAdynmemStruct.LOS_Sight]
    cmp     cl, dl
    jz      short loc_45974B
    mov     edx, [edi+10h]
    push    eax                             ; char
    push    edx                             ; int
    call    sub_4BA1B0
    jmp     short loc_459755
    ; ---------------------------------------------------------------------------

    loc_45974B:                             ; CODE XREF: sub_459200+52Dj
                                            ; sub_459200+53Dj
    push    eax
    mov     eax, [edi+10h]
    push    eax
    call    sub_4B96E0

    loc_459755:                             ; CODE XREF: sub_459200+501j
                                            ; sub_459200+549j
    mov     ecx, [ebp+0Ch]
    mov     edx, [ecx+92h]
    mov     eax, [edx+241h]
    shr     eax, 1Eh
    test    al, 1
    jz      short loc_459776
    mov     ecx, [edi+10h]
    push    7Dh                             ; char
    push    ecx                             ; int
    call    sub_4BA1B0

    loc_459776:                             ; CODE XREF: sub_459200+569j
    mov     edx, [ebp+0Ch]
    test    byte ptr [edx+10Eh], 4
    jnz     short loc_4597BA
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+14280h]
    test    cl, cl
    jnz     short loc_4597BA
    movsx   edx, word ptr [esp+30h+arg_8+2]
    mov     ecx, [esp+30h+arg_4]
    mov     eax, [edi+10h]
    add     edx, 80h
    push    ecx
    mov     ecx, [esp+34h+arg_0]
    push    edx
    push    eax
    push    ecx
    call    sub_4B7F90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4597BA:                             ; CODE XREF: sub_459200+580j
                                            ; sub_459200+58Fj
    movsx   eax, word ptr [esp+30h+arg_8+2]
    mov     edx, [esp+30h+arg_4]
    mov     ecx, [edi+10h]
    add     eax, 80h
    push    edx
    mov     edx, [esp+34h+arg_0]
    push    eax
    push    ecx
    push    edx
    call    sub_4B8500

    loc_4597D8:                             ; CODE XREF: sub_459200+12j
                                            ; sub_459200+21Dj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    18h
    sub_459200 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4597F0 proc near                    ; CODE XREF: .text:004166E9p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    fild    [esp+arg_0]
    fild    [esp+arg_4]
    fild    [esp+arg_8]
    fxch    st(2)
    fmul    ds:flt_4FD4C8
    fxch    st(1)
    fmul    ds:flt_4FD4C8
    fxch    st(2)
    fmul    ds:flt_4FD4C8
    fxch    st(1)
    fstp    flt_5065F8
    fxch    st(1)
    fstp    flt_5065FC
    fstp    flt_506600
    retn    0Ch
    sub_4597F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_459830 proc near                    ; CODE XREF: sub_4586A0+EBp
                                            ; sub_459200+441p

    var_5F04= dword ptr -5F04h
    var_5F00= dword ptr -5F00h
    var_5EFC= dword ptr -5EFCh
    var_5EF8= dword ptr -5EF8h
    var_5EF4= dword ptr -5EF4h
    var_5EF0= dword ptr -5EF0h
    var_5EEC= dword ptr -5EECh
    var_5DC0= dword ptr -5DC0h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, 5F04h
    call    __alloca_probe
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     dl, [eax+37F06h]
    push    edi
    shr     dl, 1
    test    dl, 1
    jz      loc_45991D
    mov     eax, [esp+5F14h+arg_4]
    mov     ebx, [esp+5F14h+arg_C]
    mov     edx, [eax+0Ch]
    test    dword ptr [edx+110h], 20000000h
    jz      loc_459913
    test    ebx, ebx
    jz      loc_459913
    mov     esi, [esp+5F14h+arg_0]
    mov     edx, [ecx+10h]
    mov     [esp+5F14h+var_5F00], 1
    mov     [esp+5F14h+var_5EF4], esi
    mov     ax, [esi]
    mov     edi, [edx+14h]
    shl     ax, 1
    mov     [edx], ax
    mov     cx, [esi+2]
    shl     cx, 1
    mov     [edx+2], cx
    mov     byte ptr [edx+9], 0
    mov     byte ptr [edx+8], 1
    mov     ax, [esi+4]
    shl     ax, 1
    mov     [edx+4], ax
    mov     cx, [esi+6]
    shl     cx, 1
    mov     [edx+6], cx
    xor     ecx, ecx
    mov     cx, [edx]
    xor     eax, eax
    mov     ax, [edx+2]
    mov     [esp+5F14h+arg_0], edx
    imul    ecx, eax
    mov     ebp, ecx
    xor     eax, eax
    shr     ecx, 2
    rep stosd
    mov     ecx, ebp
    and     ecx, 3
    rep stosb
    xor     ecx, ecx
    xor     eax, eax
    mov     cx, [edx]
    mov     ax, [edx+2]
    imul    ecx, eax
    mov     edi, [edx+10h]
    mov     ebp, ecx
    mov     eax, 1010101h
    shr     ecx, 2
    rep stosd
    mov     ecx, ebp
    and     ecx, 3
    rep stosb
    jmp     short loc_45992C
    ; ---------------------------------------------------------------------------

    loc_459913:                             ; CODE XREF: sub_459830+3Fj
                                            ; sub_459830+47j
    mov     [esp+5F14h+var_5F00], 0
    jmp     short loc_45992C
    ; ---------------------------------------------------------------------------

    loc_45991D:                             ; CODE XREF: sub_459830+1Ej
    mov     ebx, [esp+5F14h+arg_C]
    mov     [esp+5F14h+var_5F00], 0

    loc_45992C:                             ; CODE XREF: sub_459830+E1j
                                            ; sub_459830+EBj
    mov     esi, [esp+5F14h+arg_4]
    mov     eax, [esi]
    dec     eax
    js      loc_459BE5
    lea     ecx, [eax+eax*2]
    inc     eax
    mov     [esp+5F14h+var_5EF0], eax
    lea     ecx, [ecx+ecx*8]
    lea     edx, [esi+ecx*2+22h]
    mov     [esp+5F14h+var_5EFC], edx
    jmp     short loc_459958
    ; ---------------------------------------------------------------------------

    loc_459951:                             ; CODE XREF: sub_459830+3AFj
    mov     esi, [esp+5F14h+arg_4]

    loc_459958:                             ; CODE XREF: sub_459830+11Fj
    mov     al, [edx+28h]
    test    al, 1
    jz      loc_459BCF
    cmp     ebx, 0FFFFFFFFh
    jz      short loc_45998B
    shr     eax, 1
    and     eax, 1
    cmp     ebx, eax
    jz      short loc_45998B
    mov     ecx, [esi+0Ch]
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FD4C0
    fnstsw  ax
    test    ah, 40h
    jnz     loc_459BCF

    loc_45998B:                             ; CODE XREF: sub_459830+136j
                                            ; sub_459830+13Fj
    mov     ecx, [edx]
    mov     edi, [edx+22h]
    mov     [esp+5F14h+var_5EF8], ecx
    mov     eax, [ecx+4]
    test    eax, eax
    jle     loc_459A9F
    mov     ecx, [esp+5F14h+arg_0]
    mov     ebp, eax
    movsx   edx, word ptr [ecx+6]
    movsx   ebx, word ptr [ecx+4]
    mov     [esp+5F14h+var_5F04], edx
    lea     ecx, [esp+5F14h+var_5DC0]

    loc_4599BB:                             ; CODE XREF: sub_459830+25Aj
    mov     eax, [esp+5F14h+var_5F00]
    test    eax, eax
    mov     eax, [edi]
    jz      short loc_4599E7
    mov     edx, [edi+4]
    sar     eax, 10h
    sar     edx, 10h
    movsx   esi, ax
    movsx   eax, dx
    mov     edx, [edi+8]
    neg     edx
    sar     edx, 10h
    movsx   edx, dx
    shl     esi, 1
    shl     eax, 1
    shl     edx, 1
    jmp     short loc_459A01
    ; ---------------------------------------------------------------------------

    loc_4599E7:                             ; CODE XREF: sub_459830+193j
    mov     edx, [edi+4]
    sar     eax, 10h
    sar     edx, 10h
    movsx   esi, ax
    movsx   eax, dx
    mov     edx, [edi+8]
    neg     edx
    sar     edx, 10h
    movsx   edx, dx

    loc_459A01:                             ; CODE XREF: sub_459830+1B5j
    mov     [ecx], esi
    mov     esi, eax
    sar     esi, 1
    sub     edx, esi
    mov     [ecx+4], edx
    mov     edx, [esp+5F14h+var_5F00]
    test    edx, edx
    jz      short loc_459A46
    cdq
    sub     eax, edx
    mov     edx, [esp+5F14h+arg_4]
    sar     eax, 1
    mov     edx, [edx+0Ch]
    mov     edx, [edx+92h]
    mov     edx, [edx+241h]
    shr     edx, 1Eh
    and     dl, 1
    neg     dl
    sbb     edx, edx
    and     edx, 4Bh
    add     edx, 32h
    add     eax, edx
    mov     [ecx+8], eax
    jmp     short loc_459A71
    ; ---------------------------------------------------------------------------

    loc_459A46:                             ; CODE XREF: sub_459830+1E2j
    mov     edx, [esp+5F14h+arg_4]
    mov     edx, [edx+0Ch]
    mov     edx, [edx+92h]
    mov     edx, [edx+241h]
    shr     edx, 1Eh
    and     dl, 1
    neg     dl
    sbb     edx, edx
    and     edx, 4Bh
    add     edx, 32h
    add     edx, eax
    mov     [ecx+8], edx

    loc_459A71:                             ; CODE XREF: sub_459830+214j
    mov     esi, [ecx]
    mov     eax, [esp+5F14h+var_5F04]
    add     esi, ebx
    add     edi, 0Ch
    mov     [ecx], esi
    mov     edx, [ecx+4]
    add     edx, eax
    mov     [ecx+4], edx
    add     ecx, 0Ch
    dec     ebp
    jnz     loc_4599BB
    mov     ecx, [esp+5F14h+var_5EF8]
    mov     edx, [esp+5F14h+var_5EFC]
    mov     ebx, [esp+5F14h+arg_C]

    loc_459A9F:                             ; CODE XREF: sub_459830+169j
    mov     eax, [ecx+0Ch]
    mov     esi, [ecx+28h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_459AB4
    add     esi, 20h
    mov     edi, 1
    jmp     short loc_459AB6
    ; ---------------------------------------------------------------------------

    loc_459AB4:                             ; CODE XREF: sub_459830+278j
    xor     edi, edi

    loc_459AB6:                             ; CODE XREF: sub_459830+282j
    mov     eax, [ecx+8]
    mov     [esp+5F14h+var_5F04], edi
    cmp     edi, eax
    jge     loc_459BCF

    loc_459AC5:                             ; CODE XREF: sub_459830+395j
    mov     eax, [esi+4]
    mov     edx, [esi+0Ch]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_459B0F
    lea     edi, [esp+5F14h+var_5EEC]

    loc_459AD5:                             ; CODE XREF: sub_459830+2D2j
    xor     eax, eax
    mov     ebx, edi
    mov     ax, [edx]
    inc     ecx
    add     edi, 0Ch
    add     edx, 2
    lea     eax, [eax+eax*2]
    lea     eax, [esp+eax*4+5F14h+var_5DC0]
    mov     ebp, [eax]
    mov     [ebx], ebp
    mov     ebp, [eax+4]
    mov     [ebx+4], ebp
    mov     eax, [eax+8]
    mov     [ebx+8], eax
    mov     eax, [esi+4]
    cmp     ecx, eax
    jl      short loc_459AD5
    mov     edi, [esp+5F14h+var_5F04]
    mov     ebx, [esp+5F14h+arg_C]

    loc_459B0F:                             ; CODE XREF: sub_459830+29Fj
    mov     eax, [esi+1Ch]
    test    al, 1
    jnz     loc_459B9D
    cmp     dword ptr [esi+4], 4
    jnz     loc_459BB6
    mov     ecx, eax
    shr     ecx, 1
    test    cl, 1
    jz      short loc_459B83
    shr     eax, 2
    test    al, 1
    jz      short loc_459B67
    mov     ecx, [esp+5F14h+arg_8]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    xor     ecx, ecx
    mov     eax, [eax+edx*2+1B8Ah]
    mov     edx, [esi+18h]
    mov     cl, [eax+96h]
    push    ecx
    push    edx
    call    sub_4B7F30
    jmp     short loc_459B86
    ; ---------------------------------------------------------------------------

    loc_459B67:                             ; CODE XREF: sub_459830+302j
    test    ebx, ebx
    jz      short loc_459B78
    mov     eax, [esi+18h]
    push    0
    push    eax
    call    sub_4B7F30
    jmp     short loc_459B86
    ; ---------------------------------------------------------------------------

    loc_459B78:                             ; CODE XREF: sub_459830+339j
    lea     ecx, [esi+10h]
    push    ecx
    call    sub_4B7EE0
    jmp     short loc_459B86
    ; ---------------------------------------------------------------------------

    loc_459B83:                             ; CODE XREF: sub_459830+2FBj
    mov     eax, [esi+10h]

    loc_459B86:                             ; CODE XREF: sub_459830+335j
                                            ; sub_459830+346j ...
    lea     edx, [esp+5F14h+var_5EEC]
    push    0
    push    edx
    push    eax
    mov     eax, [esp+5F20h+arg_0]
    push    eax
    call    sub_4C8760
    jmp     short loc_459BB6
    ; ---------------------------------------------------------------------------

    loc_459B9D:                             ; CODE XREF: sub_459830+2E4j
    mov     ecx, [esi]
    mov     edx, [esi+4]
    push    ecx
    mov     ecx, [esp+5F18h+arg_0]
    lea     eax, [esp+5F18h+var_5EEC]
    push    edx
    push    eax
    push    ecx
    call    sub_4C1000

    loc_459BB6:                             ; CODE XREF: sub_459830+2EEj
                                            ; sub_459830+36Bj
    mov     edx, [esp+5F14h+var_5EF8]
    inc     edi
    add     esi, 20h
    mov     [esp+5F14h+var_5F04], edi
    cmp     edi, [edx+8]
    jl      loc_459AC5
    mov     edx, [esp+5F14h+var_5EFC]

    loc_459BCF:                             ; CODE XREF: sub_459830+12Dj
                                            ; sub_459830+155j ...
    mov     eax, [esp+5F14h+var_5EF0]
    sub     edx, 36h
    dec     eax
    mov     [esp+5F14h+var_5EFC], edx
    mov     [esp+5F14h+var_5EF0], eax
    jnz     loc_459951

    loc_459BE5:                             ; CODE XREF: sub_459830+106j
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     cl, 1
    test    cl, 1
    jz      short loc_459C5D
    mov     eax, [esp+5F14h+var_5F00]
    test    eax, eax
    jz      short loc_459C5D
    mov     esi, [esp+5F14h+var_5EF4]
    mov     edi, [esp+5F14h+arg_0]
    push    esi
    push    edi
    call    sub_4B95A0
    mov     edx, [esi+14h]
    test    edx, edx
    jz      short loc_459C5D
    mov     ecx, [edi+14h]
    xor     edi, edi
    cmp     [esi+2], di
    jbe     short loc_459C5D

    loc_459C23:                             ; CODE XREF: sub_459830+42Bj
    xor     eax, eax
    mov     ax, [esi]
    mov     esi, eax
    dec     eax
    test    esi, esi
    jz      short loc_459C40
    lea     esi, [eax+1]

    loc_459C32:                             ; CODE XREF: sub_459830+40Ej
    xor     eax, eax
    inc     edx
    mov     al, [ecx]
    add     ecx, 2
    mov     [edx-1], al
    dec     esi
    jnz     short loc_459C32

    loc_459C40:                             ; CODE XREF: sub_459830+3FDj
    mov     esi, [esp+5F14h+arg_0]
    xor     eax, eax
    mov     ax, [esi]
    mov     esi, [esp+5F14h+var_5EF4]
    add     ecx, eax
    xor     eax, eax
    mov     ax, [esi+2]
    inc     edi
    cmp     edi, eax
    jl      short loc_459C23

    loc_459C5D:                             ; CODE XREF: sub_459830+3C5j
                                            ; sub_459830+3CDj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 5F04h
    retn    10h
    sub_459830 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_459C70 proc near                    ; CODE XREF: sub_4586A0+C5p

    var_159D4= dword ptr -159D4h
    var_159D0= dword ptr -159D0h
    var_159CC= dword ptr -159CCh
    var_159C8= dword ptr -159C8h
    var_159C4= dword ptr -159C4h
    var_159C0= dword ptr -159C0h
    var_159BC= dword ptr -159BCh
    var_159B8= dword ptr -159B8h
    var_159B4= dword ptr -159B4h
    var_159B0= dword ptr -159B0h
    var_159AC= dword ptr -159ACh
    var_159A8= dword ptr -159A8h
    var_159A4= dword ptr -159A4h
    var_159A0= dword ptr -159A0h
    var_1599C= dword ptr -1599Ch
    var_15994= dword ptr -15994h
    var_15990= dword ptr -15990h
    var_15988= dword ptr -15988h
    var_15984= dword ptr -15984h
    var_15980= dword ptr -15980h
    var_15974= dword ptr -15974h
    var_15968= dword ptr -15968h
    var_1595C= dword ptr -1595Ch
    var_15950= dword ptr -15950h
    var_15944= dword ptr -15944h
    var_157C0= dword ptr -157C0h
    var_157BC= dword ptr -157BCh
    var_157B8= dword ptr -157B8h
    var_FA00= dword ptr -0FA00h
    var_F9FC= dword ptr -0F9FCh
    var_9C40= dword ptr -9C40h
    var_7D00= dword ptr -7D00h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, 159D4h
    call    __alloca_probe
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     dl, [eax+37F06h]
    push    edi
    shr     dl, 1
    test    dl, 1
    jz      loc_459D57
    mov     eax, [esp+159E4h+arg_4]
    mov     edx, [eax+0Ch]
    test    dword ptr [edx+110h], 20000000h
    jz      loc_459D57
    mov     eax, [esp+159E4h+arg_C]
    test    eax, eax
    jz      loc_459D57
    mov     esi, [esp+159E4h+arg_0]
    mov     edx, [ecx+10h]
    mov     ebp, esi
    mov     [esp+159E4h+var_159C4], 1
    mov     ax, [esi]
    mov     edi, [edx+14h]
    shl     ax, 1
    mov     [edx], ax
    mov     cx, [esi+2]
    shl     cx, 1
    mov     [edx+2], cx
    mov     byte ptr [edx+9], 0
    mov     byte ptr [edx+8], 1
    mov     ax, [esi+4]
    shl     ax, 1
    mov     [edx+4], ax
    mov     cx, [esi+6]
    shl     cx, 1
    mov     [edx+6], cx
    xor     ecx, ecx
    mov     cx, [edx]
    xor     eax, eax
    mov     ax, [edx+2]
    mov     esi, edx
    imul    ecx, eax
    mov     ebx, ecx
    xor     eax, eax
    shr     ecx, 2
    rep stosd
    mov     ecx, ebx
    mov     [esp+159E4h+var_159BC], ebp
    and     ecx, 3
    mov     [esp+159E4h+arg_0], esi
    rep stosb
    xor     ecx, ecx
    xor     eax, eax
    mov     cx, [edx]
    mov     ax, [edx+2]
    imul    ecx, eax
    mov     edi, [edx+10h]
    mov     ebx, ecx
    mov     eax, 1010101h
    shr     ecx, 2
    rep stosd
    mov     ecx, ebx
    and     ecx, 3
    rep stosb
    jmp     short loc_459D6A
    ; ---------------------------------------------------------------------------

    loc_459D57:                             ; CODE XREF: sub_459C70+1Ej
                                            ; sub_459C70+38j ...
    mov     esi, [esp+159E4h+arg_0]
    mov     ebp, [esp+159E4h+var_159BC]
    mov     [esp+159E4h+var_159C4], 0

    loc_459D6A:                             ; CODE XREF: sub_459C70+E5j
    mov     edi, [esp+159E4h+arg_4]
    mov     eax, [edi]
    dec     eax
    js      loc_45A3FF
    lea     ecx, [eax+eax*2]
    inc     eax
    mov     [esp+159E4h+var_159AC], eax
    lea     ecx, [ecx+ecx*8]
    lea     ecx, [edi+ecx*2+22h]
    mov     [esp+159E4h+var_159C8], ecx
    jmp     short loc_459D96
    ; ---------------------------------------------------------------------------

    loc_459D8F:                             ; CODE XREF: sub_459C70+789j
    mov     edi, [esp+159E4h+arg_4]

    loc_459D96:                             ; CODE XREF: sub_459C70+11Dj
    test    byte ptr [ecx+28h], 1
    jz      loc_45A3E9
    mov     eax, [esp+159E4h+arg_C]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_459DD2
    mov     dl, [ecx+28h]
    shr     edx, 1
    and     edx, 1
    cmp     eax, edx
    jz      short loc_459DD2
    mov     eax, [edi+0Ch]
    fld     dword ptr [eax+104h]
    fcomp   ds:flt_4FD4C0
    fnstsw  ax
    test    ah, 40h
    jnz     loc_45A3E9

    loc_459DD2:                             ; CODE XREF: sub_459C70+13Aj
                                            ; sub_459C70+146j
    mov     ebx, [ecx]
    mov     ebp, [ecx+22h]
    mov     edx, ebp
    mov     [esp+159E4h+var_159CC], ebp
    mov     eax, [ebx+4]
    mov     [esp+159E4h+var_159D0], edx
    test    eax, eax
    mov     [esp+159E4h+var_159C0], ebx
    jle     loc_459F42
    movsx   ecx, word ptr [esi+4]
    mov     [esp+159E4h+var_159A8], ecx
    mov     [esp+159E4h+var_159B4], eax
    movsx   ecx, word ptr [esi+6]
    mov     [esp+159E4h+var_159B8], ecx
    mov     ecx, eax
    xor     eax, eax
    lea     edi, [esp+159E4h+var_9C40]
    mov     [esp+159E4h+var_159D4], 0
    lea     ebx, [esp+159E4h+var_157BC]
    lea     esi, [esp+159E4h+var_7D00]
    rep stosd

    loc_459E27:                             ; CODE XREF: sub_459C70+2C8j
    mov     eax, [esp+159E4h+var_159C4]
    test    eax, eax
    mov     eax, [edx]
    jz      short loc_459E57
    mov     ecx, [edx+4]
    mov     edx, [edx+8]
    sar     eax, 10h
    movsx   eax, ax
    shl     eax, 1
    neg     edx
    sar     ecx, 10h
    mov     [esp+159E4h+var_159B0], eax
    sar     edx, 10h
    movsx   eax, cx
    movsx   ecx, dx
    shl     eax, 1
    shl     ecx, 1
    jmp     short loc_459E75
    ; ---------------------------------------------------------------------------

    loc_459E57:                             ; CODE XREF: sub_459C70+1BFj
    sar     eax, 10h
    movsx   ecx, ax
    mov     eax, [edx+4]
    mov     [esp+159E4h+var_159B0], ecx
    mov     ecx, [edx+8]
    neg     ecx
    sar     eax, 10h
    sar     ecx, 10h
    movsx   eax, ax
    movsx   ecx, cx

    loc_459E75:                             ; CODE XREF: sub_459C70+1E5j
    mov     edx, [esp+159E4h+var_159B0]
    mov     edi, [esp+159E4h+var_159D4]
    mov     [esi], edx
    mov     edx, eax
    sar     edx, 1
    sub     ecx, edx
    mov     edx, [esp+159E4h+var_159C4]
    mov     [esi+4], ecx
    xor     ecx, ecx
    and     edi, 1Fh
    cmp     edx, ecx
    jz      short loc_459EC7
    cdq
    sub     eax, edx
    mov     edx, [esp+159E4h+arg_4]
    sar     eax, 1
    mov     edx, [edx+0Ch]
    mov     edx, [edx+92h]
    mov     edx, [edx+241h]
    shr     edx, 1Eh
    and     dl, 1
    neg     dl
    sbb     edx, edx
    and     edx, 4Bh
    add     edx, 32h
    add     eax, edx
    mov     [esi+8], eax
    jmp     short loc_459EF2
    ; ---------------------------------------------------------------------------

    loc_459EC7:                             ; CODE XREF: sub_459C70+223j
    mov     edx, [esp+159E4h+arg_4]
    mov     edx, [edx+0Ch]
    mov     edx, [edx+92h]
    mov     edx, [edx+241h]
    shr     edx, 1Eh
    and     dl, 1
    neg     dl
    sbb     edx, edx
    and     edx, 4Bh
    add     edx, 32h
    add     edx, eax
    mov     [esi+8], edx

    loc_459EF2:                             ; CODE XREF: sub_459C70+255j
    mov     eax, [esp+159E4h+var_159A8]
    mov     [esi+0Ch], edi
    mov     edi, [esi]
    mov     edx, [esp+159E4h+var_159D0]
    add     edi, eax
    mov     eax, [esp+159E4h+var_159B8]
    mov     [esi], edi
    mov     edi, [esi+4]
    mov     [ebx+4], ecx
    mov     [ebx], ecx
    add     edi, eax
    mov     eax, [esp+159E4h+var_159B4]
    mov     [ebx-4], ecx
    mov     ecx, [esp+159E4h+var_159D4]
    mov     [esi+4], edi
    add     ecx, 3
    add     esi, 10h
    add     ebx, 0Ch
    add     edx, 0Ch
    dec     eax
    mov     [esp+159E4h+var_159D4], ecx
    mov     [esp+159E4h+var_159D0], edx
    mov     [esp+159E4h+var_159B4], eax
    jnz     loc_459E27
    mov     ebx, [esp+159E4h+var_159C0]

    loc_459F42:                             ; CODE XREF: sub_459C70+17Aj
    mov     eax, [ebx+0Ch]
    cmp     eax, 0FFFFFFFFh
    mov     eax, [ebx+28h]
    jz      short loc_459F57
    add     eax, 20h
    mov     edi, 1
    jmp     short loc_459F59
    ; ---------------------------------------------------------------------------

    loc_459F57:                             ; CODE XREF: sub_459C70+2DBj
    xor     edi, edi

    loc_459F59:                             ; CODE XREF: sub_459C70+2E5j
    mov     ecx, [ebx+8]
    mov     [esp+159E4h+var_159D4], edi
    cmp     edi, ecx
    jge     loc_45A133
    lea     ecx, [edi+edi*2]
    add     eax, 0Ch
    mov     [esp+159E4h+var_159D0], eax
    lea     esi, [esp+ecx*4+159E4h+var_FA00]

    loc_459F79:                             ; CODE XREF: sub_459C70+4BDj
    mov     edx, [esp+159E4h+var_159D0]
    mov     edx, [edx]
    mov     cx, [edx]
    mov     ax, [edx+2]
    cmp     cx, ax
    jz      loc_45A101
    mov     dx, [edx+4]
    cmp     ax, dx
    jz      loc_45A0FD
    cmp     dx, cx
    jz      loc_45A0FD
    and     eax, 0FFFFh
    and     edx, 0FFFFh
    and     ecx, 0FFFFh
    sub     esp, 0Ch
    lea     eax, [eax+eax*2]
    lea     edx, [edx+edx*2]
    lea     ecx, [ecx+ecx*2]
    lea     eax, [ebp+eax*4+0]
    mov     ebx, eax
    mov     edi, [ebx]
    mov     ebp, [ebx+4]
    mov     [esp+159F0h+var_15994], ebp
    mov     ebp, [esp+159F0h+var_159CC]
    mov     ebx, [ebx+8]
    lea     edx, [ebp+edx*4+0]
    mov     [esp+159F0h+var_15990], ebx
    mov     ebx, [edx]
    mov     [esp+159F0h+var_159A4], ebx
    mov     ebx, [edx+4]
    mov     [esp+159F0h+var_159A0], ebx
    mov     edx, [edx+8]
    mov     [esp+159F0h+var_1599C], edx
    lea     edx, [ebp+ecx*4+0]
    mov     ecx, esp
    sub     esp, 0Ch
    mov     ebx, [edx]
    mov     [ecx], ebx
    mov     ebx, [edx+4]
    mov     [ecx+4], ebx
    mov     edx, [edx+8]
    mov     [ecx+8], edx
    mov     edx, [eax]
    mov     ecx, esp
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     eax, [eax+8]
    mov     [ecx+4], edx
    mov     [ecx+8], eax
    lea     ecx, [esp+159FCh+var_1595C]
    push    ecx
    call    sub_4B6F00
    mov     ebx, [eax]
    sub     esp, 0Ch
    mov     ecx, esp
    sub     esp, 0Ch
    mov     edx, [eax+4]
    mov     [esp+159FCh+var_15988], edx
    mov     edx, [esp+159FCh+var_159A4]
    mov     eax, [eax+8]
    mov     [ecx], edx
    mov     edx, [esp+159FCh+var_1599C]
    mov     [esp+159FCh+var_15984], eax
    mov     eax, [esp+159FCh+var_159A0]
    mov     [ecx+4], eax
    mov     eax, esp
    mov     [ecx+8], edx
    mov     ecx, [esp+159FCh+var_15994]
    mov     edx, [esp+159FCh+var_15990]
    mov     [eax], edi
    mov     [eax+4], ecx
    mov     [eax+8], edx
    lea     eax, [esp+159FCh+var_15968]
    push    eax
    call    sub_4B6F00
    mov     edx, [eax]
    sub     esp, 0Ch
    mov     ecx, esp
    sub     esp, 0Ch
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     eax, [eax+8]
    mov     [ecx+4], edx
    mov     edx, [esp+159FCh+var_15988]
    mov     [ecx+8], eax
    mov     eax, [esp+159FCh+var_15984]
    mov     ecx, esp
    mov     [ecx], ebx
    mov     [ecx+4], edx
    mov     [ecx+8], eax
    lea     ecx, [esp+159FCh+var_15974]
    push    ecx
    call    sub_4B6F70
    mov     edx, eax
    mov     ecx, esi
    sub     esp, 0Ch
    mov     edi, [edx]
    mov     [ecx], edi
    mov     edi, [edx+4]
    mov     [ecx+4], edi
    mov     edx, [edx+8]
    mov     [ecx+8], edx
    mov     edx, [eax]
    mov     ecx, esp
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     eax, [eax+8]
    mov     [ecx+4], edx
    mov     [ecx+8], eax
    lea     ecx, [esp+159F0h+var_15980]
    push    ecx
    call    sub_4B6FF0
    mov     ecx, [eax]
    mov     edx, esi
    mov     edi, [esp+159E4h+var_159D4]
    mov     ebx, [esp+159E4h+var_159C0]
    mov     [edx], ecx
    mov     ecx, [eax+4]
    mov     eax, [eax+8]
    mov     [edx+4], ecx
    mov     [edx+8], eax
    jmp     short loc_45A115
    ; ---------------------------------------------------------------------------

    loc_45A0FD:                             ; CODE XREF: sub_459C70+326j
                                            ; sub_459C70+32Fj
    mov     ebx, [esp+159E4h+var_159C0]

    loc_45A101:                             ; CODE XREF: sub_459C70+319j
    mov     dword ptr [esi], 0
    mov     dword ptr [esi+4], 3F800000h
    mov     dword ptr [esi+8], 0

    loc_45A115:                             ; CODE XREF: sub_459C70+48Bj
    mov     ecx, [esp+159E4h+var_159D0]
    mov     eax, [ebx+8]
    inc     edi
    add     esi, 0Ch
    add     ecx, 20h
    cmp     edi, eax
    mov     [esp+159E4h+var_159D4], edi
    mov     [esp+159E4h+var_159D0], ecx
    jl      loc_459F79

    loc_45A133:                             ; CODE XREF: sub_459C70+2F2j
    mov     ebp, [ebx+0Ch]
    cmp     ebp, 0FFFFFFFFh
    mov     [esp+159E4h+var_159CC], ebp
    jz      short loc_45A150
    mov     edi, [ebx+28h]
    mov     eax, 1
    mov     [esp+159E4h+var_159D0], edi
    lea     ecx, [edi+20h]
    jmp     short loc_45A15B
    ; ---------------------------------------------------------------------------

    loc_45A150:                             ; CODE XREF: sub_459C70+4CDj
    mov     ecx, [ebx+28h]
    xor     eax, eax
    mov     [esp+159E4h+var_159D0], ecx
    mov     edi, ecx

    loc_45A15B:                             ; CODE XREF: sub_459C70+4DEj
    mov     esi, [ebx+8]
    cmp     eax, esi
    mov     [esp+159E4h+var_159B8], esi
    jge     short loc_45A1E2
    lea     ebx, [ecx+4]
    lea     ecx, [eax+eax*2]
    mov     edi, esi
    lea     edx, [esp+ecx*4+159E4h+var_F9FC]
    sub     edi, eax

    loc_45A177:                             ; CODE XREF: sub_459C70+568j
    mov     ebp, [ebx]
    mov     esi, [ebx+8]
    test    ebp, ebp
    jle     short loc_45A1D1

    loc_45A180:                             ; CODE XREF: sub_459C70+55Fj
    xor     eax, eax
    mov     ax, [esi]
    add     esi, 2
    lea     ecx, [eax+eax*2]
    lea     eax, [esp+eax*4+159E4h+var_9C40]
    shl     ecx, 2
    fld     [esp+ecx+159E4h+var_157C0]
    fadd    dword ptr [edx-4]
    fstp    [esp+ecx+159E4h+var_157C0]
    fld     dword ptr [edx]
    fadd    [esp+ecx+159E4h+var_157BC]
    fstp    [esp+ecx+159E4h+var_157BC]
    fld     [esp+ecx+159E4h+var_157B8]
    fadd    dword ptr [edx+4]
    lea     ecx, [esp+ecx+159E4h+var_157B8]
    fstp    dword ptr [ecx]
    mov     ecx, [eax]
    inc     ecx
    dec     ebp
    mov     [eax], ecx
    jnz     short loc_45A180

    loc_45A1D1:                             ; CODE XREF: sub_459C70+50Ej
    add     edx, 0Ch
    add     ebx, 20h
    dec     edi
    jnz     short loc_45A177
    mov     edi, [esp+159E4h+var_159D0]
    mov     ebp, [esp+159E4h+var_159CC]

    loc_45A1E2:                             ; CODE XREF: sub_459C70+4F4j
    mov     edx, [esp+159E4h+var_159C8]
    mov     eax, [edx]
    mov     esi, [eax+4]
    test    esi, esi
    jle     short loc_45A22C
    lea     ecx, [esp+159E4h+var_9C40]
    lea     eax, [esp+159E4h+var_157BC]

    loc_45A1FD:                             ; CODE XREF: sub_459C70+5BAj
    mov     edx, [ecx]
    test    edx, edx
    mov     [esp+159E4h+var_159CC], edx
    jz      short loc_45A223
    fild    [esp+159E4h+var_159CC]
    fld     dword ptr [eax-4]
    fdiv    st, st(1)
    fstp    dword ptr [eax-4]
    fld     dword ptr [eax]
    fdiv    st, st(1)
    fstp    dword ptr [eax]
    fld     dword ptr [eax+4]
    fdiv    st, st(1)
    fstp    dword ptr [eax+4]
    fstp    st

    loc_45A223:                             ; CODE XREF: sub_459C70+595j
    add     ecx, 4
    add     eax, 0Ch
    dec     esi
    jnz     short loc_45A1FD

    loc_45A22C:                             ; CODE XREF: sub_459C70+57Dj
    cmp     ebp, 0FFFFFFFFh
    jz      short loc_45A23E
    add     edi, 20h
    mov     [esp+159E4h+var_159D4], 1
    jmp     short loc_45A246
    ; ---------------------------------------------------------------------------

    loc_45A23E:                             ; CODE XREF: sub_459C70+5BFj
    mov     [esp+159E4h+var_159D4], 0

    loc_45A246:                             ; CODE XREF: sub_459C70+5CCj
    mov     ecx, [esp+159E4h+var_159D4]
    mov     eax, [esp+159E4h+var_159B8]
    cmp     ecx, eax
    jge     loc_45A3DA

    loc_45A256:                             ; CODE XREF: sub_459C70+764j
    mov     eax, [edi+4]
    mov     ebp, [edi+0Ch]
    xor     ebx, ebx
    test    eax, eax
    jle     loc_45A30B
    lea     esi, [esp+159E4h+var_15944]

    loc_45A26D:                             ; CODE XREF: sub_459C70+695j
    xor     edx, edx
    lea     ecx, [esi-0Ch]
    mov     dx, [ebp+0]
    shl     edx, 4
    lea     eax, [esp+edx+159E4h+var_7D00]
    mov     edx, [esp+edx+159E4h+var_7D00]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     edx, [eax+8]
    mov     [ecx+8], edx
    mov     eax, [eax+0Ch]
    mov     [ecx+0Ch], eax
    mov     ecx, [esp+159E4h+var_159C8]
    mov     dl, [ecx+28h]
    shr     dl, 2
    test    dl, 1
    jz      short loc_45A2F3
    xor     eax, eax
    mov     ax, [ebp+0]
    lea     eax, [eax+eax*2]
    shl     eax, 2
    fld     [esp+eax+159E4h+var_157C0]
    fmul    flt_5065F8
    fld     [esp+eax+159E4h+var_157BC]
    fmul    flt_5065FC
    faddp   st(1), st
    fld     [esp+eax+159E4h+var_157B8]
    fmul    flt_506600
    faddp   st(1), st
    fmul    ds:flt_4FD4CC
    call    __ftol
    and     eax, 1Fh
    mov     [esi], eax
    jmp     short loc_45A2F9
    ; ---------------------------------------------------------------------------

    loc_45A2F3:                             ; CODE XREF: sub_459C70+638j
    mov     dword ptr [esi], 0Fh

    loc_45A2F9:                             ; CODE XREF: sub_459C70+681j
    mov     eax, [edi+4]
    inc     ebx
    add     esi, 10h
    add     ebp, 2
    cmp     ebx, eax
    jl      loc_45A26D

    loc_45A30B:                             ; CODE XREF: sub_459C70+5F0j
    mov     eax, [edi+1Ch]
    test    al, 1
    jnz     loc_45A3A3
    cmp     dword ptr [edi+4], 4
    jnz     loc_45A3BF
    mov     ecx, eax
    shr     ecx, 1
    test    cl, 1
    jz      short loc_45A386
    shr     eax, 2
    test    al, 1
    jz      short loc_45A363
    mov     ecx, [esp+159E4h+arg_8]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    xor     ecx, ecx
    mov     eax, [eax+edx*2+1B8Ah]
    mov     edx, [edi+18h]
    mov     cl, [eax+96h]
    push    ecx
    push    edx
    call    sub_4B7F30
    jmp     short loc_45A389
    ; ---------------------------------------------------------------------------

    loc_45A363:                             ; CODE XREF: sub_459C70+6BEj
    mov     eax, [esp+159E4h+arg_C]
    test    eax, eax
    jz      short loc_45A37B
    mov     eax, [edi+18h]
    push    0
    push    eax
    call    sub_4B7F30
    jmp     short loc_45A389
    ; ---------------------------------------------------------------------------

    loc_45A37B:                             ; CODE XREF: sub_459C70+6FCj
    lea     ecx, [edi+10h]
    push    ecx
    call    sub_4B7EE0
    jmp     short loc_45A389
    ; ---------------------------------------------------------------------------

    loc_45A386:                             ; CODE XREF: sub_459C70+6B7j
    mov     eax, [edi+10h]

    loc_45A389:                             ; CODE XREF: sub_459C70+6F1j
                                            ; sub_459C70+709j ...
    lea     edx, [esp+159E4h+var_15950]
    push    0
    push    edx
    push    eax
    mov     eax, [esp+159F0h+arg_0]
    push    eax
    call    sub_4C8BB0
    jmp     short loc_45A3BF
    ; ---------------------------------------------------------------------------

    loc_45A3A3:                             ; CODE XREF: sub_459C70+6A0j
    mov     ecx, [edi]
    mov     edx, [edi+4]
    push    ecx
    mov     ecx, [esp+159E8h+arg_0]
    lea     eax, [esp+159E8h+var_15950]
    push    edx
    push    eax
    push    ecx
    call    sub_4C0C70

    loc_45A3BF:                             ; CODE XREF: sub_459C70+6AAj
                                            ; sub_459C70+731j
    mov     edx, [esp+159E4h+var_159C0]
    mov     eax, [esp+159E4h+var_159D4]
    inc     eax
    add     edi, 20h
    mov     ecx, [edx+8]
    mov     [esp+159E4h+var_159D4], eax
    cmp     eax, ecx
    jl      loc_45A256

    loc_45A3DA:                             ; CODE XREF: sub_459C70+5E0j
    mov     esi, [esp+159E4h+arg_0]
    mov     ebp, [esp+159E4h+var_159BC]
    mov     ecx, [esp+159E4h+var_159C8]

    loc_45A3E9:                             ; CODE XREF: sub_459C70+12Aj
                                            ; sub_459C70+15Cj
    mov     eax, [esp+159E4h+var_159AC]
    sub     ecx, 36h
    dec     eax
    mov     [esp+159E4h+var_159C8], ecx
    mov     [esp+159E4h+var_159AC], eax
    jnz     loc_459D8F

    loc_45A3FF:                             ; CODE XREF: sub_459C70+104j
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F06h]
    shr     cl, 1
    test    cl, 1
    jz      short loc_45A462
    mov     eax, [esp+159E4h+var_159C4]
    test    eax, eax
    jz      short loc_45A462
    push    ebp
    push    esi
    call    sub_4B95A0
    mov     edx, [ebp+14h]
    test    edx, edx
    jz      short loc_45A462
    mov     ecx, [esi+14h]
    xor     ebx, ebx
    cmp     [ebp+2], bx
    jbe     short loc_45A462

    loc_45A432:                             ; CODE XREF: sub_459C70+7F0j
    xor     eax, eax
    mov     ax, [ebp+0]
    mov     edi, eax
    dec     eax
    test    edi, edi
    jz      short loc_45A450
    lea     edi, [eax+1]

    loc_45A442:                             ; CODE XREF: sub_459C70+7DEj
    xor     eax, eax
    inc     edx
    mov     al, [ecx]
    add     ecx, 2
    mov     [edx-1], al
    dec     edi
    jnz     short loc_45A442

    loc_45A450:                             ; CODE XREF: sub_459C70+7CDj
    xor     eax, eax
    mov     ax, [esi]
    add     ecx, eax
    xor     eax, eax
    mov     ax, [ebp+2]
    inc     ebx
    cmp     ebx, eax
    jl      short loc_45A432

    loc_45A462:                             ; CODE XREF: sub_459C70+79Fj
                                            ; sub_459C70+7A7j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 159D4h
    retn    10h
    sub_459C70 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45A470 proc near                    ; CODE XREF: sub_459200+138p
                                            ; sub_459200+2DBp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    ebx
    mov     ebx, ecx
    push    esi
    mov     dx, [eax]
    push    edi
    mov     ecx, [ebx+10h]
    mov     [ecx], dx
    mov     ecx, [ebx+10h]
    mov     dx, [eax+2]
    mov     [ecx+2], dx
    mov     ecx, [ebx+10h]
    mov     dx, [eax+4]
    mov     [ecx+4], dx
    mov     ecx, [ebx+10h]
    mov     dx, [eax+6]
    mov     [ecx+6], dx
    mov     ecx, [ebx+10h]
    mov     dl, [eax+8]
    mov     [ecx+8], dl
    xor     ecx, ecx
    mov     cx, [eax]
    xor     edx, edx
    mov     dx, [eax+2]
    mov     esi, [eax+10h]
    imul    ecx, edx
    mov     edx, [ebx+10h]
    mov     edi, [edx+10h]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [eax+14h]
    test    esi, esi
    jz      short loc_45A4FA
    xor     ecx, ecx
    xor     edx, edx
    mov     cx, [eax]
    mov     dx, [eax+2]
    imul    ecx, edx
    mov     eax, [ebx+10h]
    mov     edx, ecx
    shr     ecx, 2
    mov     edi, [eax+14h]
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_45A4FA:                             ; CODE XREF: sub_45A470+66j
    mov     eax, [ebx+10h]
    push    eax
    call    sub_4B96A0
    mov     eax, [ebx+10h]
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_45A470 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45A510 proc near                    ; CODE XREF: sub_45A790+24p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 0Ch
    mov     eax, [esp+0Ch+arg_C]
    mov     ecx, [esp+0Ch+arg_8]
    push    ebx
    push    ebp
    push    edi
    xor     edi, edi
    mov     [eax], edi
    mov     eax, [esp+18h+arg_4]
    mov     [ecx], edi
    mov     ecx, [esp+18h+arg_0]
    mov     [eax], edi
    xor     ebx, ebx
    mov     [ecx], edi
    mov     ecx, [esp+18h+arg_10]
    xor     ebp, ebp
    xor     edx, edx
    mov     eax, [ecx]
    mov     [esp+18h+var_C], edx
    dec     eax
    js      loc_45A5D9
    lea     edx, [eax+eax*2]
    inc     eax
    push    esi
    mov     [esp+1Ch+var_4], eax
    lea     edx, [edx+edx*8]
    lea     ecx, [ecx+edx*2+22h]
    mov     [esp+1Ch+var_8], ecx

    loc_45A55B:                             ; CODE XREF: sub_45A510+C2j
    test    byte ptr [ecx+28h], 1
    jz      short loc_45A5C2
    mov     eax, [ecx]
    mov     esi, [ecx+22h]
    mov     eax, [eax+4]
    test    eax, eax
    jle     short loc_45A5C2
    mov     [esp+1Ch+arg_10], eax

    loc_45A571:                             ; CODE XREF: sub_45A510+ACj
    mov     edx, [esi]
    mov     ecx, [esi+4]
    sar     edx, 10h
    movsx   eax, dx
    mov     edx, [esi+8]
    sar     ecx, 10h
    neg     edx
    movsx   ecx, cx
    sar     edx, 10h
    movsx   edx, dx
    sar     ecx, 2
    add     eax, ecx
    sub     edx, ecx
    cmp     eax, edi
    jge     short loc_45A59A
    mov     edi, eax

    loc_45A59A:                             ; CODE XREF: sub_45A510+86j
    cmp     eax, [esp+1Ch+var_C]
    jle     short loc_45A5A4
    mov     [esp+1Ch+var_C], eax

    loc_45A5A4:                             ; CODE XREF: sub_45A510+8Ej
    cmp     edx, ebp
    jge     short loc_45A5AA
    mov     ebp, edx

    loc_45A5AA:                             ; CODE XREF: sub_45A510+96j
    cmp     edx, ebx
    jle     short loc_45A5B0
    mov     ebx, edx

    loc_45A5B0:                             ; CODE XREF: sub_45A510+9Cj
    mov     eax, [esp+1Ch+arg_10]
    add     esi, 0Ch
    dec     eax
    mov     [esp+1Ch+arg_10], eax
    jnz     short loc_45A571
    mov     ecx, [esp+1Ch+var_8]

    loc_45A5C2:                             ; CODE XREF: sub_45A510+4Fj
                                            ; sub_45A510+5Bj
    mov     eax, [esp+1Ch+var_4]
    sub     ecx, 36h
    dec     eax
    mov     [esp+1Ch+var_8], ecx
    mov     [esp+1Ch+var_4], eax
    jnz     short loc_45A55B
    mov     edx, [esp+1Ch+var_C]
    pop     esi

    loc_45A5D9:                             ; CODE XREF: sub_45A510+31j
    mov     eax, [esp+18h+arg_0]
    mov     ecx, [esp+18h+arg_4]
    sub     edi, 2
    sub     ebp, 2
    sub     edx, edi
    sub     ebx, ebp
    add     edx, 2
    add     ebx, 2
    mov     [eax], edx
    mov     edx, [esp+18h+arg_8]
    mov     eax, [esp+18h+arg_C]
    mov     [ecx], ebx
    neg     edi
    neg     ebp
    mov     [edx], edi
    mov     [eax], ebp
    pop     edi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    14h
    sub_45A510 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45A610 proc near                    ; CODE XREF: sub_45A790+ACp

    var_5EFC= dword ptr -5EFCh
    var_5EF8= dword ptr -5EF8h
    var_5EF4= dword ptr -5EF4h
    var_5EF0= dword ptr -5EF0h
    var_5EEC= dword ptr -5EECh
    var_5DC0= dword ptr -5DC0h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, 5EFCh
    call    __alloca_probe
    mov     edx, [esp+5EFCh+arg_4]
    mov     ecx, [edx]
    dec     ecx
    js      loc_45A782
    lea     eax, [ecx+ecx*2]
    push    edi
    push    esi
    inc     ecx
    lea     eax, [eax+eax*8]
    push    ebp
    mov     ebp, [esp+5F08h+arg_0]
    push    ebx
    lea     eax, [edx+eax*2+22h]
    mov     [esp+5F0Ch+var_5EF0], ecx
    mov     [esp+5F0Ch+var_5EF8], eax

    loc_45A648:                             ; CODE XREF: sub_45A610+168j
    mov     cx, [eax+28h]
    test    cl, 1
    jz      loc_45A768
    test    cl, 2
    jz      loc_45A768
    mov     ebx, [eax]
    mov     ecx, [eax+22h]
    mov     [esp+5F0Ch+var_5EF4], ebx
    mov     edi, [ebx+4]
    test    edi, edi
    jle     short loc_45A6D4
    movsx   ebx, word ptr [ebp+4]
    lea     eax, [esp+5F0Ch+var_5DC0]

    loc_45A679:                             ; CODE XREF: sub_45A610+BAj
    mov     edx, [ecx+4]
    mov     ebp, [ecx]
    sar     edx, 10h
    movsx   esi, dx
    sar     ebp, 10h
    mov     edx, esi
    add     esi, 19h
    movsx   ebp, bp
    sar     edx, 2
    add     ebp, edx
    add     ecx, 0Ch
    mov     [eax], ebp
    mov     ebp, [ecx-4]
    neg     ebp
    sar     ebp, 10h
    movsx   ebp, bp
    sub     ebp, edx
    mov     [eax+4], ebp
    mov     [eax+8], esi
    mov     ebp, [eax]
    add     eax, 0Ch
    add     ebp, ebx
    mov     [eax-0Ch], ebp
    mov     ebp, [esp+5F0Ch+arg_0]
    mov     esi, [eax-8]
    movsx   edx, word ptr [ebp+6]
    add     esi, edx
    dec     edi
    mov     [eax-8], esi
    jnz     short loc_45A679
    mov     ebx, [esp+5F0Ch+var_5EF4]
    mov     eax, [esp+5F0Ch+var_5EF8]

    loc_45A6D4:                             ; CODE XREF: sub_45A610+5Cj
    mov     ecx, [ebx+0Ch]
    mov     esi, [ebx+28h]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_45A6E9
    add     esi, 20h
    mov     edi, 1
    jmp     short loc_45A6EB
    ; ---------------------------------------------------------------------------

    loc_45A6E9:                             ; CODE XREF: sub_45A610+CDj
    xor     edi, edi

    loc_45A6EB:                             ; CODE XREF: sub_45A610+D7j
    mov     ecx, [ebx+8]
    mov     [esp+5F0Ch+var_5EFC], edi
    cmp     edi, ecx
    jge     short loc_45A768
    add     esi, 4

    loc_45A6F9:                             ; CODE XREF: sub_45A610+152j
    mov     eax, [esi]
    mov     edx, [esi+8]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_45A745
    lea     edi, [esp+5F0Ch+var_5EEC]

    loc_45A708:                             ; CODE XREF: sub_45A610+124j
    xor     eax, eax
    mov     ebx, edi
    mov     ax, [edx]
    inc     ecx
    add     edi, 0Ch
    add     edx, 2
    lea     eax, [eax+eax*2]
    lea     eax, [esp+eax*4+5F0Ch+var_5DC0]
    mov     ebp, [eax]
    mov     [ebx], ebp
    mov     ebp, [eax+4]
    mov     [ebx+4], ebp
    mov     eax, [eax+8]
    mov     [ebx+8], eax
    mov     eax, [esi]
    cmp     ecx, eax
    jl      short loc_45A708
    mov     ebp, [esp+5F0Ch+arg_0]
    mov     edi, [esp+5F0Ch+var_5EFC]
    mov     ebx, [esp+5F0Ch+var_5EF4]

    loc_45A745:                             ; CODE XREF: sub_45A610+F2j
    mov     ecx, [esi]
    push    0
    lea     edx, [esp+5F10h+var_5EEC]
    push    ecx
    push    edx
    push    ebp
    call    sub_4C1000
    mov     eax, [ebx+8]
    inc     edi
    add     esi, 20h
    cmp     edi, eax
    mov     [esp+5F0Ch+var_5EFC], edi
    jl      short loc_45A6F9
    mov     eax, [esp+5F0Ch+var_5EF8]

    loc_45A768:                             ; CODE XREF: sub_45A610+3Fj
                                            ; sub_45A610+48j ...
    mov     ecx, [esp+5F0Ch+var_5EF0]
    sub     eax, 36h
    dec     ecx
    mov     [esp+5F0Ch+var_5EF8], eax
    mov     [esp+5F0Ch+var_5EF0], ecx
    jnz     loc_45A648
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_45A782:                             ; CODE XREF: sub_45A610+14j
    add     esp, 5EFCh
    retn    8
    sub_45A610 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45A790 proc near                    ; CODE XREF: sub_459200+FEp
                                            ; sub_459200+35Bp

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    lea     eax, [esp+0Ch+var_4]
    lea     edx, [esp+0Ch+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+18h+arg_0]
    mov     ebp, ecx
    push    edi
    push    esi
    lea     ecx, [esp+20h+var_8]
    push    eax
    push    ecx
    lea     eax, [esp+28h+var_C]
    push    edx
    push    eax
    mov     ecx, ebp
    call    sub_45A510
    mov     ecx, [ebp+10h]
    mov     dx, word ptr [esp+1Ch+var_C]
    push    esi
    mov     [ecx], dx
    mov     eax, [ebp+10h]
    mov     cx, word ptr [esp+20h+arg_0]
    mov     [eax+2], cx
    mov     edx, [ebp+10h]
    mov     ax, word ptr [esp+20h+var_8]
    mov     [edx+4], ax
    mov     ecx, [ebp+10h]
    mov     dx, word ptr [esp+20h+var_4]
    xor     eax, eax
    mov     [ecx+6], dx
    mov     ecx, [esp+20h+arg_0]
    mov     edx, [ebp+10h]
    imul    ecx, [esp+20h+var_C]
    mov     al, [edx+8]
    mov     edi, [edx+10h]
    mov     bl, al
    mov     edx, ecx
    mov     bh, bl
    mov     eax, ebx
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     ecx, [esp+20h+arg_0]
    mov     edx, [ebp+10h]
    imul    ecx, [esp+20h+var_C]
    mov     edi, [edx+14h]
    mov     edx, ecx
    xor     eax, eax
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     eax, [ebp+10h]
    mov     ecx, ebp
    push    eax
    call    sub_45A610
    mov     ecx, [ebp+10h]
    mov     edx, [esp+1Ch+arg_4]
    push    0
    push    5
    push    ecx
    push    edx
    call    sub_4B9D70
    mov     eax, [ebp+10h]
    push    eax
    mov     eax, [eax+14h]
    push    eax
    call    sub_4B9E60
    mov     edi, eax
    add     esi, 14h
    push    1
    push    edi
    push    esi
    mov     ecx, ebp
    call    sub_437B50
    mov     edx, [ebp+10h]
    mov     eax, [esi]
    mov     ecx, edi
    mov     esi, [edx+14h]
    mov     edi, [eax+10h]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     ecx, [ebp+10h]
    pop     edi
    pop     esi
    mov     dx, [ecx]
    mov     [eax], dx
    mov     ecx, [ebp+10h]
    mov     dx, [ecx+2]
    mov     [eax+2], dx
    mov     ecx, [ebp+10h]
    mov     dx, [ecx+4]
    mov     [eax+4], dx
    mov     ecx, [ebp+10h]
    pop     ebp
    pop     ebx
    mov     dx, [ecx+6]
    mov     byte ptr [eax+9], 1
    mov     [eax+6], dx
    add     esp, 0Ch
    retn    8
    sub_45A790 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45A8D0 proc near                    ; CODE XREF: sub_423C50+272p
                                            ; sub_485D40+C9p

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    push    edi
    mov     eax, [ebx+30h]
    mov     esi, 1
    test    eax, eax
    jz      short loc_45A8EC
    push    eax
    call    sub_45AE80
    mov     esi, eax
    inc     esi

    loc_45A8EC:                             ; CODE XREF: sub_45A8D0+11j
    mov     eax, [ebx+2Ch]
    test    eax, eax
    jz      short loc_45A8FB
    push    eax
    call    sub_45AE80
    add     esi, eax

    loc_45A8FB:                             ; CODE XREF: sub_45A8D0+21j
    lea     eax, [esi+esi*2]
    lea     eax, [eax+eax*8]
    lea     edi, [eax+eax+22h]
    push    edi
    push    offset aObjectState             ; "Object State"
    call    sub_4D83B0
    mov     ecx, edi
    mov     esi, eax
    mov     edx, ecx
    xor     eax, eax
    mov     edi, esi
    add     esp, 8
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    push    0
    and     ecx, 3
    push    ebx
    rep stosb
    push    esi
    call    sub_45AEC0
    mov     [esi+1Eh], eax
    mov     dword ptr [esi+8], 1
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_45A8D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45A950 proc near                    ; CODE XREF: sub_485D40+80p

    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 3Ch
    push    ebx
    mov     ebx, [esp+40h+arg_0]
    push    ebp
    push    esi
    mov     eax, [ebx+30h]
    push    edi
    test    eax, eax
    mov     esi, 1
    jz      short loc_45A970
    push    eax
    call    sub_45AE80
    mov     esi, eax
    inc     esi

    loc_45A970:                             ; CODE XREF: sub_45A950+15j
    mov     eax, [ebx+2Ch]
    test    eax, eax
    jz      short loc_45A97F
    push    eax
    call    sub_45AE80
    add     esi, eax

    loc_45A97F:                             ; CODE XREF: sub_45A950+25j
    lea     eax, [esi+esi*2]
    lea     eax, [eax+eax*8]
    lea     esi, [eax+eax+22h]
    push    esi
    push    offset aObjectState             ; "Object State"
    call    sub_4D83B0
    mov     ecx, esi
    mov     ebp, eax
    mov     edx, ecx
    xor     eax, eax
    mov     edi, ebp
    add     esp, 8
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    push    0
    and     ecx, 3
    push    ebx
    rep stosb
    push    ebp
    call    sub_45AEC0
    mov     [ebp+1Eh], eax
    mov     dword ptr [ebp+8], 1
    mov     eax, [esp+4Ch+arg_8]
    mov     ecx, [esp+4Ch+arg_4]
    mov     [ebp+0Ch], eax
    xor     esi, esi
    mov     eax, [ecx+8]
    mov     [esp+4Ch+var_3C], esi
    test    eax, eax
    jle     loc_45AA7A
    lea     edi, [ebp+22h]
    mov     [esp+4Ch+arg_8], edi

    loc_45A9E3:                             ; CODE XREF: sub_45A950+120j
    mov     eax, [ebp+0]
    mov     ebx, esi
    cmp     esi, eax
    jge     short loc_45AA57

    loc_45A9EC:                             ; CODE XREF: sub_45A950+C2j
    mov     edx, [edi]
    mov     ecx, [esp+4Ch+arg_4]
    mov     eax, [edx+1Ch]
    mov     edx, [ecx+20h]
    push    eax                             ; char *
    mov     eax, [edx+esi*4]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_45AA16
    mov     eax, [ebp+0]
    inc     ebx
    add     edi, 36h
    cmp     ebx, eax
    jl      short loc_45A9EC
    jmp     short loc_45AA57
    ; ---------------------------------------------------------------------------

    loc_45AA16:                             ; CODE XREF: sub_45A950+B7j
    cmp     esi, ebx
    jz      short loc_45AA57
    mov     esi, [esp+4Ch+arg_8]
    mov     ecx, 0Dh
    lea     edi, [esp+4Ch+var_38]
    lea     ebx, [ebx+ebx*2]
    rep movsd
    lea     ecx, [ebx+ebx*8]
    movsw
    mov     edi, [esp+4Ch+arg_8]
    lea     eax, [ebp+ecx*2+22h]
    mov     ecx, 0Dh
    mov     esi, eax
    rep movsd
    movsw
    mov     ecx, 0Dh
    lea     esi, [esp+4Ch+var_38]
    mov     edi, eax
    rep movsd
    movsw
    mov     esi, [esp+4Ch+var_3C]

    loc_45AA57:                             ; CODE XREF: sub_45A950+9Aj
                                            ; sub_45A950+C4j ...
    mov     edx, [esp+4Ch+arg_4]
    mov     edi, [esp+4Ch+arg_8]
    inc     esi
    add     edi, 36h
    mov     eax, [edx+8]
    mov     [esp+4Ch+var_3C], esi
    cmp     esi, eax
    mov     [esp+4Ch+arg_8], edi
    jl      loc_45A9E3
    mov     ebx, [esp+4Ch+arg_0]

    loc_45AA7A:                             ; CODE XREF: sub_45A950+86j
    push    0
    push    ebx
    push    ebp
    call    sub_45AF90
    mov     [ebp+1Eh], eax
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3Ch
    retn    0Ch
    sub_45A950 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45AAA0 proc near                    ; CODE XREF: sub_422170+54p
                                            ; sub_4246B0+9Fp ...

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    xor     esi, esi
    mov     eax, [ebx]
    push    edi
    test    eax, eax
    jle     short loc_45AAC7
    lea     edi, [ebx+44h]

    loc_45AAB2:                             ; CODE XREF: sub_45AAA0+25j
    mov     eax, [edi]
    push    eax                             ; int
    call    sub_4D85A0
    mov     eax, [ebx]
    add     esp, 4
    inc     esi
    add     edi, 36h
    cmp     esi, eax
    jl      short loc_45AAB2

    loc_45AAC7:                             ; CODE XREF: sub_45AAA0+Dj
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+1437Bh]
    test    ecx, ecx
    jz      short loc_45AAF5
    lea     edx, [ebx+10h]
    push    edx
    call    sub_437C90
    mov     ecx, TAdynmemStructPtr
    lea     eax, [ebx+14h]
    push    eax
    mov     ecx, [ecx+1437Bh]
    call    sub_437C90

    loc_45AAF5:                             ; CODE XREF: sub_45AAA0+35j
    push    ebx                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_45AAA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45AB10 proc near                    ; CODE XREF: sub_480EB0+4Cp

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    xor     ebp, ebp
    push    edi
    mov     ecx, [esi+9Eh]
    mov     ax, [ecx+1Ch]
    sub     ax, [esi+68h]
    movsx   eax, ax
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 8
    jge     short loc_45AB5F
    mov     dx, [ecx+1Ah]
    sub     dx, [esi+66h]
    movsx   eax, dx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 8
    jge     short loc_45AB5F
    mov     ax, [ecx+18h]
    sub     ax, [esi+64h]
    movsx   eax, ax
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 8
    jl      short loc_45AB8E

    loc_45AB5F:                             ; CODE XREF: sub_45AB10+23j
                                            ; sub_45AB10+38j
    mov     eax, [esi+64h]
    lea     edx, [ecx+18h]
    mov     [ecx+18h], eax
    mov     ax, [esi+68h]
    mov     dword ptr [ecx+8], 1
    mov     [edx+4], ax
    mov     edx, [ecx+1Eh]
    mov     [edx+26h], bp
    mov     eax, [ecx+1Eh]
    mov     dl, [eax+28h]
    shr     dl, 1
    test    dl, 1
    jz      short loc_45AB8E
    mov     [ecx+4], ebp

    loc_45AB8E:                             ; CODE XREF: sub_45AB10+4Dj
                                            ; sub_45AB10+79j
    mov     eax, [esi+9Eh]
    cmp     [eax+8], ebp
    jz      short loc_45AC0D
    mov     ebx, [eax+1Eh]
    xor     edx, edx
    cmp     [ebx+26h], bp
    jnz     short loc_45ABD9
    mov     eax, [ebx]
    mov     edi, [ebx+22h]
    mov     edx, 1
    mov     ecx, [eax+4]
    mov     esi, [eax+24h]
    lea     ecx, [ecx+ecx*2]
    shl     ecx, 2
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     esi, [esp+4+arg_0]
    mov     [ebx+16h], ebp
    mov     [ebx+1Ah], ebp
    mov     [ebx+1Eh], ebp
    mov     [ebx+26h], bp

    loc_45ABD9:                             ; CODE XREF: sub_45AB10+92j
    mov     ecx, [ebx+2Eh]
    cmp     ecx, ebp
    jz      short loc_45ABE5
    call    sub_45B030

    loc_45ABE5:                             ; CODE XREF: sub_45AB10+CEj
    mov     ebx, [ebx+2Ah]
    cmp     ebx, ebp
    jz      short loc_45ABF5
    xor     edx, edx
    mov     ecx, ebx
    call    sub_45B030

    loc_45ABF5:                             ; CODE XREF: sub_45AB10+DAj
    mov     ecx, [esi+9Eh]
    push    ebp
    mov     edx, [ecx+1Eh]
    call    sub_45B0A0
    mov     ecx, [esi+9Eh]
    mov     [ecx+8], ebp

    loc_45AC0D:                             ; CODE XREF: sub_45AB10+87j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_45AB10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45AC20 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+D10p
                                            ; GameUnit_LOS_Unknown1+EB3p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    push    edi
    mov     edi, [esp+0Ch+arg_4]
    xor     ebx, ebx
    cmp     [edi+86h], ebx
    jnz     loc_45AE7A
    mov     ecx, [edi+9Eh]
    push    esi
    push    ebp
    mov     ax, [ecx+1Ch]
    sub     ax, [edi+68h]
    movsx   eax, ax
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 8
    jge     short loc_45AC7C
    mov     dx, [ecx+1Ah]
    sub     dx, [edi+66h]
    movsx   eax, dx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 8
    jge     short loc_45AC7C
    mov     ax, [ecx+18h]
    sub     ax, [edi+64h]
    movsx   eax, ax
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 8
    jl      short loc_45ACAB

    loc_45AC7C:                             ; CODE XREF: sub_45AC20+30j
                                            ; sub_45AC20+45j
    mov     eax, [edi+64h]
    lea     edx, [ecx+18h]
    mov     [ecx+18h], eax
    mov     ax, [edi+68h]
    mov     dword ptr [ecx+8], 1
    mov     [edx+4], ax
    mov     edx, [ecx+1Eh]
    mov     [edx+26h], bx
    mov     eax, [ecx+1Eh]
    mov     dl, [eax+28h]
    shr     dl, 1
    test    dl, 1
    jz      short loc_45ACAB
    mov     [ecx+4], ebx

    loc_45ACAB:                             ; CODE XREF: sub_45AC20+5Aj
                                            ; sub_45AC20+86j
    mov     eax, [edi+9Eh]
    cmp     [eax+8], ebx
    jz      short loc_45AD2B
    mov     ebp, [eax+1Eh]
    xor     edx, edx
    cmp     [ebp+26h], bx
    jnz     short loc_45ACF7
    mov     eax, [ebp+0]
    mov     edi, [ebp+22h]
    mov     edx, 1
    mov     ecx, [eax+4]
    mov     esi, [eax+24h]
    lea     ecx, [ecx+ecx*2]
    shl     ecx, 2
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+14h+arg_4]
    mov     [ebp+16h], ebx
    mov     [ebp+1Ah], ebx
    mov     [ebp+1Eh], ebx
    mov     [ebp+26h], bx

    loc_45ACF7:                             ; CODE XREF: sub_45AC20+9Fj
    mov     ecx, [ebp+2Eh]
    cmp     ecx, ebx
    jz      short loc_45AD03
    call    sub_45B030

    loc_45AD03:                             ; CODE XREF: sub_45AC20+DCj
    mov     ebp, [ebp+2Ah]
    cmp     ebp, ebx
    jz      short loc_45AD13
    xor     edx, edx
    mov     ecx, ebp
    call    sub_45B030

    loc_45AD13:                             ; CODE XREF: sub_45AC20+E8j
    mov     ecx, [edi+9Eh]
    push    ebx
    mov     edx, [ecx+1Eh]
    call    sub_45B0A0
    mov     ecx, [edi+9Eh]
    mov     [ecx+8], ebx

    loc_45AD2B:                             ; CODE XREF: sub_45AC20+94j
    mov     esi, [edi+8Ah]
    cmp     esi, ebx
    mov     [esp+14h+var_4], esi
    jz      loc_45AE5C
    jmp     short loc_45AD43
    ; ---------------------------------------------------------------------------

    loc_45AD3F:                             ; CODE XREF: sub_45AC20+236j
    mov     esi, [esp+14h+var_4]

    loc_45AD43:                             ; CODE XREF: sub_45AC20+11Dj
    test    dword ptr [esi+110h], 20000h
    jnz     loc_45AE4A
    mov     ecx, [esi+9Eh]
    mov     dx, [ecx+1Ch]
    sub     dx, [esi+68h]
    movsx   eax, dx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 8
    jge     short loc_45AD98
    mov     ax, [ecx+1Ah]
    sub     ax, [esi+66h]
    movsx   eax, ax
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 8
    jge     short loc_45AD98
    mov     dx, [ecx+18h]
    sub     dx, [esi+64h]
    movsx   eax, dx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 8
    jl      short loc_45ADC6

    loc_45AD98:                             ; CODE XREF: sub_45AC20+14Cj
                                            ; sub_45AC20+161j
    mov     edx, [esi+64h]
    lea     eax, [ecx+18h]
    mov     [ecx+18h], edx
    mov     dx, [esi+68h]
    mov     dword ptr [ecx+8], 1
    mov     [eax+4], dx
    mov     eax, [ecx+1Eh]
    mov     [eax+26h], bx
    mov     edx, [ecx+1Eh]
    mov     al, [edx+28h]
    shr     al, 1
    test    al, 1
    jz      short loc_45ADC6
    mov     [ecx+4], ebx

    loc_45ADC6:                             ; CODE XREF: sub_45AC20+176j
                                            ; sub_45AC20+1A1j
    mov     eax, [esi+9Eh]
    cmp     [eax+8], ebx
    jz      short loc_45AE4A
    mov     ebp, [eax+1Eh]
    xor     edx, edx
    cmp     [ebp+26h], bx
    jnz     short loc_45AE16
    mov     eax, [ebp+0]
    mov     edi, [ebp+22h]
    mov     ecx, [eax+4]
    mov     esi, [eax+24h]
    lea     ecx, [ecx+ecx*2]
    shl     ecx, 2
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     edx, 1
    and     ecx, 3
    rep movsb
    mov     esi, [esp+14h+var_4]
    mov     edi, [esp+14h+arg_4]
    mov     [ebp+16h], ebx
    mov     [ebp+1Ah], ebx
    mov     [ebp+1Eh], ebx
    mov     [ebp+26h], bx

    loc_45AE16:                             ; CODE XREF: sub_45AC20+1BAj
    mov     ecx, [ebp+2Eh]
    cmp     ecx, ebx
    jz      short loc_45AE22
    call    sub_45B030

    loc_45AE22:                             ; CODE XREF: sub_45AC20+1FBj
    mov     ebp, [ebp+2Ah]
    cmp     ebp, ebx
    jz      short loc_45AE32
    xor     edx, edx
    mov     ecx, ebp
    call    sub_45B030

    loc_45AE32:                             ; CODE XREF: sub_45AC20+207j
    mov     ecx, [esi+9Eh]
    push    ebx
    mov     edx, [ecx+1Eh]
    call    sub_45B0A0
    mov     eax, [esi+9Eh]
    mov     [eax+8], ebx

    loc_45AE4A:                             ; CODE XREF: sub_45AC20+12Dj
                                            ; sub_45AC20+1AFj
    mov     esi, [esi+8Eh]
    cmp     esi, ebx
    mov     [esp+14h+var_4], esi
    jnz     loc_45AD3F

    loc_45AE5C:                             ; CODE XREF: sub_45AC20+117j
    mov     ecx, [esp+14h+arg_0]
    mov     eax, TAdynmemStructPtr
    mov     edx, [edi+9Eh]
    push    ecx
    mov     ecx, [eax+1437Bh]
    push    edx
    call    sub_458810
    pop     ebp
    pop     esi

    loc_45AE7A:                             ; CODE XREF: sub_45AC20+Fj
    pop     edi
    pop     ebx
    pop     ecx
    retn    8
    sub_45AC20 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45AE80 proc near                    ; CODE XREF: sub_45A8D0+14p
                                            ; sub_45A8D0+24p ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, 1
    mov     eax, [edi+30h]
    test    eax, eax
    jz      short loc_45AE9B
    push    eax
    call    sub_45AE80
    mov     esi, eax
    inc     esi

    loc_45AE9B:                             ; CODE XREF: sub_45AE80+10j
    mov     eax, [edi+2Ch]
    test    eax, eax
    jz      short loc_45AEAA
    push    eax
    call    sub_45AE80
    add     esi, eax

    loc_45AEAA:                             ; CODE XREF: sub_45AE80+20j
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    sub_45AE80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45AEC0 proc near                    ; CODE XREF: sub_45A8D0+5Dp
                                            ; sub_45A950+61p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    mov     ebp, [esp+4+arg_4]
    mov     eax, [ebx]
    push    esi
    push    edi
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*8]
    or      byte ptr [ebx+eax*2+4Ah], 2
    lea     ebx, [ebx+eax*2+22h]
    mov     [ebx], ebp
    mov     word ptr [ebx+26h], 0
    mov     eax, [ebp+4]
    lea     ecx, [eax+eax*2]
    shl     ecx, 2
    push    ecx
    push    offset aPointList               ; "Point List"
    call    sub_4D83B0
    mov     [ebx+22h], eax
    mov     ecx, [ebp+4]
    mov     esi, [ebp+24h]
    mov     edi, eax
    lea     ecx, [ecx+ecx*2]
    add     esp, 8
    shl     ecx, 2
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    cmp     dword ptr [ebp+4], 3
    jl      short loc_45AF27
    or      byte ptr [ebx+28h], 1
    jmp     short loc_45AF2D
    ; ---------------------------------------------------------------------------

    loc_45AF27:                             ; CODE XREF: sub_45AEC0+5Fj
    and     word ptr [ebx+28h], 0FFFEh

    loc_45AF2D:                             ; CODE XREF: sub_45AEC0+65j
    mov     esi, [esp+0Ch+arg_0]
    or      byte ptr [ebx+28h], 4
    mov     edx, [esi]
    inc     edx
    mov     [esi], edx
    mov     eax, [ebp+30h]
    test    eax, eax
    jz      short loc_45AF4E
    push    ebx
    push    eax
    push    esi
    call    sub_45AEC0
    mov     [ebx+2Eh], eax
    jmp     short loc_45AF55
    ; ---------------------------------------------------------------------------

    loc_45AF4E:                             ; CODE XREF: sub_45AEC0+7Fj
    mov     dword ptr [ebx+2Eh], 0

    loc_45AF55:                             ; CODE XREF: sub_45AEC0+8Cj
    mov     ebp, [ebp+2Ch]
    mov     edi, [esp+0Ch+arg_8]
    test    ebp, ebp
    jz      short loc_45AF77
    push    edi
    push    ebp
    push    esi
    call    sub_45AEC0
    mov     [ebx+2Ah], eax
    mov     [ebx+32h], edi
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_45AF77:                             ; CODE XREF: sub_45AEC0+9Ej
    mov     [ebx+32h], edi
    pop     edi
    pop     esi
    mov     dword ptr [ebx+2Ah], 0
    mov     eax, ebx
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_45AEC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45AF90 proc near                    ; CODE XREF: sub_45A950+12Ep
                                            ; sub_45AF90+4Ep ...

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h
    arg_8= dword ptr  18h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     eax, [edi]
    dec     eax
    js      loc_45B020
    mov     edx, [esp+arg_4]
    lea     ecx, [eax+eax*2]
    lea     ecx, [ecx+ecx*8]
    lea     ecx, [edi+ecx*2+22h]

    loc_45AFAE:                             ; CODE XREF: sub_45AF90+28j
    cmp     [ecx], edx
    jz      short loc_45AFC2
    dec     eax
    sub     ecx, 36h
    test    eax, eax
    jge     short loc_45AFAE
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_45AFC2:                             ; CODE XREF: sub_45AF90+20j
    lea     eax, [eax+eax*2]
    mov     ebx, [esp+arg_8]
    lea     edx, [eax+eax*8]
    mov     eax, [edi+edx*2+22h]
    mov     eax, [eax+2Ch]
    lea     esi, [edi+edx*2+22h]
    test    eax, eax
    jz      short loc_45AFE8
    push    ebx
    push    eax
    push    edi
    call    sub_45AF90
    mov     [esi+2Ah], eax
    jmp     short loc_45AFEF
    ; ---------------------------------------------------------------------------

    loc_45AFE8:                             ; CODE XREF: sub_45AF90+49j
    mov     dword ptr [esi+2Ah], 0

    loc_45AFEF:                             ; CODE XREF: sub_45AF90+56j
    mov     ecx, [esi]
    mov     eax, [ecx+30h]
    test    eax, eax
    jz      short loc_45B00E
    push    esi
    push    eax
    push    edi
    call    sub_45AF90
    mov     [esi+2Eh], eax
    mov     [esi+32h], ebx
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_45B00E:                             ; CODE XREF: sub_45AF90+66j
    mov     dword ptr [esi+2Eh], 0
    mov     [esi+32h], ebx
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_45B020:                             ; CODE XREF: sub_45AF90+Aj
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    0Ch
    sub_45AF90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B030 proc near                    ; CODE XREF: sub_45AB10+D0p
                                            ; sub_45AB10+E0p ...

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     [esp+14h+var_4], edx
    mov     ebx, ecx
    xor     ebp, ebp

    loc_45B03D:                             ; CODE XREF: sub_45B030+61j
    cmp     [ebx+26h], bp
    mov     eax, edx
    jz      short loc_45B049
    cmp     edx, ebp
    jz      short loc_45B07A

    loc_45B049:                             ; CODE XREF: sub_45B030+13j
    mov     eax, [ebx]
    mov     edi, [ebx+22h]
    mov     ecx, [eax+4]
    mov     esi, [eax+24h]
    lea     ecx, [ecx+ecx*2]
    shl     ecx, 2
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, 1
    and     ecx, 3
    rep movsb
    mov     [ebx+16h], ebp
    mov     [ebx+1Ah], ebp
    mov     [ebx+1Eh], ebp
    mov     [ebx+26h], bp

    loc_45B07A:                             ; CODE XREF: sub_45B030+17j
    mov     ecx, [ebx+2Eh]
    cmp     ecx, ebp
    jz      short loc_45B08C
    mov     edx, eax
    call    sub_45B030
    mov     edx, [esp+14h+var_4]

    loc_45B08C:                             ; CODE XREF: sub_45B030+4Fj
    mov     ebx, [ebx+2Ah]
    cmp     ebx, ebp
    jnz     short loc_45B03D
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_45B030 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B0A0 proc near                    ; CODE XREF: sub_45AB10+EFp
                                            ; sub_45AC20+FDp ...

    var_14= dword ptr -14h
    var_10= word ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 14h
    push    ebx
    push    esi
    mov     esi, edx
    push    edi
    mov     edi, ecx
    mov     edx, [esi+2Eh]
    test    edx, edx
    jz      short loc_45B0B8
    push    1
    call    sub_45B0A0

    loc_45B0B8:                             ; CODE XREF: sub_45B0A0+Fj
    mov     ebx, [esp+20h+arg_0]
    mov     ax, [esi+14h]
    mov     cx, [esi+10h]
    mov     dx, [esi+12h]
    test    ebx, ebx
    mov     word ptr [esp+20h+var_14], ax
    mov     [esp+20h+var_10], cx
    mov     word ptr [esp+20h+var_14+2], dx
    jnz     short loc_45B0F6
    add     ax, [edi+18h]
    add     cx, [edi+1Ch]
    add     dx, [edi+1Ah]
    mov     word ptr [esp+20h+var_14], ax
    mov     [esp+20h+var_10], cx
    mov     word ptr [esp+20h+var_14+2], dx

    loc_45B0F6:                             ; CODE XREF: sub_45B0A0+39j
    mov     eax, [esi]
    mov     ecx, [esi+4]
    push    0
    mov     edx, [eax+10h]
    add     ecx, edx
    mov     edx, [esi+8]
    mov     [esp+24h+var_C], ecx
    mov     ecx, [eax+14h]
    add     edx, ecx
    mov     ecx, [esi+0Ch]
    mov     [esp+24h+var_8], edx
    mov     edx, [eax+18h]
    add     ecx, edx
    lea     edx, [esp+24h+var_C]
    lea     eax, [esp+24h+var_14]
    mov     [esp+24h+var_4], ecx
    push    edx
    push    eax
    mov     edx, esi
    mov     ecx, edi
    call    sub_45B150
    test    ebx, ebx
    jz      short loc_45B145
    mov     edx, [esi+2Ah]
    test    edx, edx
    jz      short loc_45B145
    push    1
    mov     ecx, edi
    call    sub_45B0A0

    loc_45B145:                             ; CODE XREF: sub_45B0A0+93j
                                            ; sub_45B0A0+9Aj
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 14h
    retn    4
    sub_45B0A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B150 proc near                    ; CODE XREF: sub_45B0A0+8Cp
                                            ; sub_45B150+C9p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+14h+arg_4]
    mov     esi, edx
    mov     [esp+14h+var_4], ecx

    loc_45B15F:                             ; CODE XREF: sub_45B150+E5j
    cmp     word ptr [esi+26h], 0
    jnz     loc_45B206
    mov     eax, [esp+14h+arg_0]
    lea     ebp, [esi+16h]
    push    eax
    push    ebp
    push    ebp
    call    sub_4B6CC0
    mov     ecx, [esi]
    mov     eax, [ecx+4]
    dec     eax
    js      short loc_45B1AC
    lea     ebx, [eax+eax*2]
    shl     ebx, 2
    inc     eax
    mov     [esp+14h+arg_4], eax

    loc_45B18C:                             ; CODE XREF: sub_45B150+5Aj
    mov     edx, [esi+22h]
    mov     ecx, [esp+14h+arg_0]
    push    ecx
    lea     eax, [edx+ebx]
    push    eax
    push    eax
    call    sub_4B6CC0
    sub     ebx, 0Ch
    mov     eax, [esp+14h+arg_4]
    dec     eax
    mov     [esp+14h+arg_4], eax
    jnz     short loc_45B18C

    loc_45B1AC:                             ; CODE XREF: sub_45B150+2Fj
    mov     edx, [edi]
    mov     eax, [ebp+0]
    mov     ebx, [ebp+4]
    add     eax, edx
    mov     edx, [ebp+8]
    mov     [ebp+0], eax
    mov     eax, [edi+4]
    add     ebx, eax
    mov     [ebp+4], ebx
    mov     ecx, [edi+8]
    add     edx, ecx
    mov     [ebp+8], edx
    mov     edx, [esi]
    mov     eax, [edx+4]
    dec     eax
    js      short loc_45B206
    lea     ecx, [eax+eax*2]
    lea     edx, [eax+1]
    shl     ecx, 2

    loc_45B1DD:                             ; CODE XREF: sub_45B150+B4j
    mov     eax, [esi+22h]
    mov     ebx, [edi]
    add     eax, ecx
    sub     ecx, 0Ch
    mov     ebp, [eax]
    add     ebp, ebx
    mov     [eax], ebp
    mov     ebx, [edi+4]
    mov     ebp, [eax+4]
    add     ebp, ebx
    mov     [eax+4], ebp
    mov     ebx, [edi+8]
    mov     ebp, [eax+8]
    add     ebp, ebx
    dec     edx
    mov     [eax+8], ebp
    jnz     short loc_45B1DD

    loc_45B206:                             ; CODE XREF: sub_45B150+14j
                                            ; sub_45B150+82j
    mov     edx, [esi+2Eh]
    test    edx, edx
    jz      short loc_45B21E
    mov     eax, [esp+14h+arg_0]
    mov     ecx, [esp+14h+var_4]
    push    1
    push    edi
    push    eax
    call    sub_45B150

    loc_45B21E:                             ; CODE XREF: sub_45B150+BBj
    mov     eax, [esp+14h+arg_8]
    test    eax, eax
    jz      short loc_45B23A
    mov     esi, [esi+2Ah]
    test    esi, esi
    jz      short loc_45B23A
    mov     [esp+14h+arg_8], 1
    jmp     loc_45B15F
    ; ---------------------------------------------------------------------------

    loc_45B23A:                             ; CODE XREF: sub_45B150+D4j
                                            ; sub_45B150+DBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    sub_45B150 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_45B250 proc near                    ; CODE XREF: sub_4441A0+1A8p

    var_AC= dword ptr -0ACh
    var_A8= dword ptr -0A8h
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= byte ptr -90h
    var_19= byte ptr -19h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset loc_4FB880
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    push    ecx
    sub     esp, 9Ch
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_10], esp
    mov     [ebp+var_14], 2
    mov     [ebp+var_4], 0
    cmp     [ebp+arg_0], 0FFFFFFFFh
    jz      loc_45B354
    mov     al, Filename
    test    al, al
    jnz     loc_45B32D
    push    104h                            ; nSize
    push    offset Filename                 ; lpFilename
    push    0                               ; hModule
    call    ds:GetModuleFileNameA
    mov     esi, eax
    mov     [ebp+var_98], esi
    mov     byte_512ED4, 0
    mov     edi, offset Filename
    mov     [ebp+var_94], edi
    test    esi, esi
    jle     short loc_45B2FF
    lea     edi, byte_512DCF[esi]
    mov     [ebp+var_94], edi

    loc_45B2D6:                             ; CODE XREF: sub_45B250+ADj
    test    esi, esi
    jle     short loc_45B2FF
    movsx   eax, byte ptr [edi]
    push    eax                             ; int
    push    offset asc_5066CC               ; char *
    call    _strchr
    add     esp, 8
    test    eax, eax
    jnz     short loc_45B2FF
    dec     edi
    mov     [ebp+var_94], edi
    dec     esi
    mov     [ebp+var_98], esi
    jmp     short loc_45B2D6
    ; ---------------------------------------------------------------------------

    loc_45B2FF:                             ; CODE XREF: sub_45B250+78j
                                            ; sub_45B250+88j ...
    xor     edx, edx
    test    esi, esi
    setnle  dl
    and     edx, 1
    add     edx, edi
    mov     edi, offset aOnline_dll         ; "online.dll"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_45B32D:                             ; CODE XREF: sub_45B250+44j
    mov     eax, hModule
    test    eax, eax
    jnz     loc_45B3BD
    push    offset Filename                 ; lpLibFileName
    call    ds:LoadLibraryA
    mov     hModule, eax
    test    eax, eax
    jnz     short loc_45B3BD
    mov     [ebp+var_9C], eax

    loc_45B354:                             ; CODE XREF: sub_45B250+37j
                                            ; sub_45B250+1AEj ...
    mov     [ebp+var_4], 0FFFFFFFFh
    mov     edi, [ebp+var_14]
    cmp     edi, 1
    jnz     short loc_45B3A8
    push    offset aPleaseInsertTh          ; int
    call    sub_4C5740
    mov     esi, [ebp+arg_4]
    push    esi
    push    offset asc_505A64               ; "\n\n"
    push    eax
    push    78h
    lea     edx, [ebp+var_90]
    push    edx
    call    __snprintf
    add     esp, 14h
    test    eax, eax
    jge     short loc_45B390
    mov     [ebp+var_19], 0

    loc_45B390:                             ; CODE XREF: sub_45B250+13Aj
    mov     byte ptr [esi], 0
    mov     eax, [ebp+arg_8]
    dec     eax
    push    eax                             ; size_t
    lea     ecx, [ebp+var_90]
    push    ecx                             ; char *
    push    esi                             ; char *
    call    _strncat
    add     esp, 0Ch

    loc_45B3A8:                             ; CODE XREF: sub_45B250+111j
    mov     eax, edi
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_45B3BD:                             ; CODE XREF: sub_45B250+E4j
                                            ; sub_45B250+FCj
    mov     [ebp+var_9C], 1
    xor     esi, esi
    mov     [ebp+var_A0], esi
    test    eax, eax
    jz      short loc_45B3FC
    push    offset aOnlgetversion           ; lpProcName
    push    eax                             ; hModule
    call    ds:GetProcAddress
    mov     [ebp+var_A4], eax
    test    eax, eax
    jz      short loc_45B3F7
    call    eax
    cmp     eax, 3
    sbb     esi, esi
    inc     esi
    mov     [ebp+var_A0], esi

    loc_45B3F7:                             ; CODE XREF: sub_45B250+197j
    mov     eax, hModule

    loc_45B3FC:                             ; CODE XREF: sub_45B250+181j
    test    esi, esi
    jz      loc_45B354
    mov     esi, 2
    mov     [ebp+var_A8], esi
    test    eax, eax
    jz      short loc_45B444
    push    offset aOnlprocessbutt          ; lpProcName
    push    eax                             ; hModule
    call    ds:GetProcAddress
    mov     [ebp+var_AC], eax
    test    eax, eax
    jz      short loc_45B444
    push    offset loc_45B480
    mov     ecx, [ebp+arg_8]
    push    ecx
    mov     edx, [ebp+arg_4]
    push    edx
    mov     ecx, [ebp+arg_0]
    push    ecx
    call    eax
    mov     esi, eax
    mov     [ebp+var_A8], esi

    loc_45B444:                             ; CODE XREF: sub_45B250+1C1j
                                            ; sub_45B250+1D7j
    mov     [ebp+var_14], esi
    jmp     loc_45B354
    sub_45B250 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B44C proc near                    ; DATA XREF: .rdata:004FEE30o
    mov     esi, [ebp+0Ch]
    test    esi, esi
    jz      short loc_45B473
    mov     eax, [ebp+10h]
    test    eax, eax
    jbe     short loc_45B473
    mov     byte ptr [esi], 0
    dec     eax
    push    eax                             ; size_t
    push    offset aFaultWhileTryi          ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    esi                             ; char *
    call    _strncat
    add     esp, 0Ch

    loc_45B473:                             ; CODE XREF: sub_45B44C+5j
                                            ; sub_45B44C+Cj
    mov     dword ptr [ebp-14h], 2
    mov     eax, offset loc_45B354
    retn
    sub_45B44C endp

    ; ---------------------------------------------------------------------------

    loc_45B480:                             ; DATA XREF: sub_45B250+1D9o
    mov     eax, [esp+4]
    push    eax
    call    sub_4C5740
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_45B490 proc near                    ; CODE XREF: .text:00444744p

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    hModule= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset loc_4FB890
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    push    ecx
    sub     esp, 28h
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_10], esp
    xor     ebx, ebx
    mov     [ebp+hModule], ebx
    mov     [ebp+var_4], ebx
    mov     al, Filename
    test    al, al
    jnz     loc_45B549
    push    104h                            ; nSize
    push    offset Filename                 ; lpFilename
    push    ebx                             ; hModule
    call    ds:GetModuleFileNameA
    mov     esi, eax
    mov     [ebp+var_24], esi
    mov     byte_512ED4, bl
    mov     edi, offset Filename
    mov     [ebp+var_20], edi
    cmp     esi, ebx
    jle     short loc_45B51B
    lea     edi, byte_512DCF[esi]
    mov     [ebp+var_20], edi

    loc_45B4F8:                             ; CODE XREF: sub_45B490+89j
    cmp     esi, ebx
    jle     short loc_45B51B
    movsx   eax, byte ptr [edi]
    push    eax                             ; int
    push    offset asc_5066CC               ; char *
    call    _strchr
    add     esp, 8
    test    eax, eax
    jnz     short loc_45B51B
    dec     edi
    mov     [ebp+var_20], edi
    dec     esi
    mov     [ebp+var_24], esi
    jmp     short loc_45B4F8
    ; ---------------------------------------------------------------------------

    loc_45B51B:                             ; CODE XREF: sub_45B490+5Dj
                                            ; sub_45B490+6Aj ...
    xor     edx, edx
    cmp     esi, ebx
    setnle  dl
    and     edx, 1
    add     edx, edi
    mov     edi, offset aOnline_dll         ; "online.dll"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_45B549:                             ; CODE XREF: sub_45B490+31j
    mov     eax, hModule
    cmp     eax, ebx
    jnz     short loc_45B586
    push    offset Filename                 ; lpLibFileName
    call    ds:LoadLibraryA
    mov     hModule, eax
    cmp     eax, ebx
    jnz     short loc_45B586
    mov     [ebp+var_28], ebx

    loc_45B569:                             ; CODE XREF: sub_45B490+12Bj
                                            ; sub_45B490+15Dj
                                            ; DATA XREF: ...
    mov     [ebp+var_4], 0FFFFFFFFh
    mov     eax, [ebp+hModule]
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45B586:                             ; CODE XREF: sub_45B490+C0j
                                            ; sub_45B490+D4j
    mov     [ebp+var_28], 1
    xor     esi, esi
    mov     [ebp+var_2C], esi
    cmp     eax, ebx
    jz      short loc_45B5B9
    push    offset aOnlgetversion           ; lpProcName
    push    eax                             ; hModule
    call    ds:GetProcAddress
    mov     [ebp+var_30], eax
    cmp     eax, ebx
    jz      short loc_45B5B4
    call    eax
    cmp     eax, 3
    sbb     esi, esi
    inc     esi
    mov     [ebp+var_2C], esi

    loc_45B5B4:                             ; CODE XREF: sub_45B490+117j
    mov     eax, hModule

    loc_45B5B9:                             ; CODE XREF: sub_45B490+104j
    cmp     esi, ebx
    jz      short loc_45B569
    xor     esi, esi
    mov     [ebp+var_34], esi
    cmp     eax, ebx
    jz      short loc_45B5E4
    push    offset aOnlgetlinkinfo          ; lpProcName
    push    eax                             ; hModule
    call    ds:GetProcAddress
    mov     [ebp+var_38], eax
    cmp     eax, ebx
    jz      short loc_45B5E4
    mov     ecx, [ebp+arg_0]
    push    ecx
    call    eax
    mov     esi, eax
    mov     [ebp+var_34], esi

    loc_45B5E4:                             ; CODE XREF: sub_45B490+134j
                                            ; sub_45B490+147j
    mov     [ebp+hModule], esi

    loc_45B5E7:                             ; CODE XREF: sub_45B490+192j
    mov     [ebp+var_18], ebx
    cmp     ebx, [ebp+hModule]
    jnb     loc_45B569
    lea     edx, [ebx+ebx*8]
    mov     eax, [ebp+arg_0]
    lea     esi, [eax+edx*4]
    cmp     dword ptr [esi], 0FFFFFFFFh
    jz      short loc_45B621
    lea     edi, [esi+4]
    push    edi                             ; int
    call    sub_4C5740
    mov     [ebp+var_1C], eax
    cmp     eax, edi
    jz      short loc_45B621
    push    20h                             ; size_t
    push    eax                             ; char *
    push    edi                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [esi+23h], 0

    loc_45B621:                             ; CODE XREF: sub_45B490+16Fj
                                            ; sub_45B490+17Fj
    inc     ebx
    jmp     short loc_45B5E7
    sub_45B490 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B624 proc near                    ; DATA XREF: .rdata:004FEE88o
    mov     dword ptr [ebp-14h], 0
    mov     eax, offset loc_45B569
    retn
    sub_45B624 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B640 proc near                    ; CODE XREF: sub_4441A0+1DAp
                                            ; sub_497F40+3F4p
    mov     eax, hModule
    test    eax, eax
    jz      short locret_45B65A
    push    eax                             ; hLibModule
    call    ds:FreeLibrary
    mov     hModule, 0

    locret_45B65A:                          ; CODE XREF: sub_45B640+7j
    retn
    sub_45B640 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B660 proc near                    ; CODE XREF: WriteRegistrySettings_1+90Bp
                                            ; sub_441080+42p ...
    mov     eax, dword_512EE8
    retn
    sub_45B660 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_45B670 proc near                    ; CODE XREF: sub_49EE30+25Fp

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset loc_4FB8A0
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    push    ecx
    sub     esp, 1Ch
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_10], esp
    xor     ebx, ebx
    mov     dword_512EE8, ebx
    mov     ecx, 54h
    xor     eax, eax
    mov     edi, offset dword_512C80
    rep stosd
    mov     [ebp+var_4], ebx
    cmp     Filename, bl
    jnz     loc_45B739
    push    104h                            ; nSize
    push    offset Filename                 ; lpFilename
    push    ebx                             ; hModule
    call    ds:GetModuleFileNameA
    mov     esi, eax
    mov     [ebp+var_18], esi
    mov     byte_512ED4, bl
    mov     edi, offset Filename
    mov     [ebp+var_14], edi
    cmp     esi, ebx
    jle     short loc_45B70B
    lea     edi, byte_512DCF[esi]
    mov     [ebp+var_14], edi

    loc_45B6E8:                             ; CODE XREF: sub_45B670+99j
    cmp     esi, ebx
    jle     short loc_45B70B
    movsx   eax, byte ptr [edi]
    push    eax                             ; int
    push    offset asc_5066CC               ; char *
    call    _strchr
    add     esp, 8
    test    eax, eax
    jnz     short loc_45B70B
    dec     edi
    mov     [ebp+var_14], edi
    dec     esi
    mov     [ebp+var_18], esi
    jmp     short loc_45B6E8
    ; ---------------------------------------------------------------------------

    loc_45B70B:                             ; CODE XREF: sub_45B670+6Dj
                                            ; sub_45B670+7Aj ...
    xor     edx, edx
    cmp     esi, ebx
    setnle  dl
    and     edx, 1
    add     edx, edi
    mov     edi, offset aOnline_dll         ; "online.dll"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_45B739:                             ; CODE XREF: sub_45B670+41j
    mov     eax, hModule
    cmp     eax, ebx
    jnz     short loc_45B778
    push    offset Filename                 ; lpLibFileName
    call    ds:LoadLibraryA
    mov     hModule, eax
    cmp     eax, ebx
    jnz     short loc_45B778
    mov     [ebp+var_1C], ebx

    loc_45B759:                             ; CODE XREF: sub_45B670+13Dj
                                            ; sub_45B670+176j
                                            ; DATA XREF: ...
    mov     [ebp+var_4], 0FFFFFFFFh
    mov     eax, dword_512EE8
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45B778:                             ; CODE XREF: sub_45B670+D0j
                                            ; sub_45B670+E4j
    mov     [ebp+var_1C], 1
    xor     esi, esi
    mov     [ebp+var_20], esi
    cmp     eax, ebx
    jz      short loc_45B7AB
    push    offset aOnlgetversion           ; lpProcName
    push    eax                             ; hModule
    call    ds:GetProcAddress
    mov     [ebp+var_24], eax
    cmp     eax, ebx
    jz      short loc_45B7A6
    call    eax
    cmp     eax, 3
    sbb     esi, esi
    inc     esi
    mov     [ebp+var_20], esi

    loc_45B7A6:                             ; CODE XREF: sub_45B670+129j
    mov     eax, hModule

    loc_45B7AB:                             ; CODE XREF: sub_45B670+116j
    cmp     esi, ebx
    jz      short loc_45B759
    xor     esi, esi
    mov     [ebp+var_28], esi
    cmp     eax, ebx
    jz      short loc_45B7E0
    push    offset aOnlloadconfigf          ; lpProcName
    push    eax                             ; hModule
    call    ds:GetProcAddress
    mov     [ebp+var_2C], eax
    cmp     eax, ebx
    jz      short loc_45B7E0
    push    150h
    push    offset dword_512C80
    mov     ecx, [ebp+arg_0]
    push    ecx
    call    eax
    mov     esi, eax
    mov     [ebp+var_28], esi

    loc_45B7E0:                             ; CODE XREF: sub_45B670+146j
                                            ; sub_45B670+159j
    mov     dword_512EE8, esi
    jmp     loc_45B759
    sub_45B670 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B7EB proc near                    ; DATA XREF: .rdata:004FEEE0o
    mov     dword_512EE8, 0
    mov     eax, offset loc_45B759
    retn
    sub_45B7EB endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_45B800(char *)
    sub_45B800 proc near                    ; CODE XREF: sub_49EE30+3B1p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    3Fh                             ; size_t
    push    eax                             ; char *
    push    offset byte_512D90              ; char *
    mov     byte_512D90, 0
    call    _strncat
    add     esp, 0Ch
    retn    4
    sub_45B800 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_45B820(int,char *)
    sub_45B820 proc near                    ; CODE XREF: sub_49EE30+31Bp
                                            ; sub_49EE30+351p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_0]
    xor     eax, eax
    test    edx, edx
    setnz   al
    mov     dword_512C84, eax
    mov     eax, [esp+arg_4]
    test    eax, eax
    jz      short locret_45B84F
    push    3Fh                             ; size_t
    push    eax                             ; char *
    push    offset byte_512CA8              ; char *
    mov     byte_512CA8, 0
    call    _strncat
    add     esp, 0Ch

    locret_45B84F:                          ; CODE XREF: sub_45B820+16j
    retn    8
    sub_45B820 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B860 proc near                    ; CODE XREF: sub_49EE30+3B7p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    cmp     eax, 1
    jz      short loc_45B878
    cmp     eax, 2
    jz      short loc_45B878
    cmp     eax, 3
    jz      short loc_45B878
    cmp     eax, 4
    jnz     short locret_45B87D

    loc_45B878:                             ; CODE XREF: sub_45B860+7j
                                            ; sub_45B860+Cj ...
    mov     dword_512C80, eax

    locret_45B87D:                          ; CODE XREF: sub_45B860+16j
    retn    4
    sub_45B860 endp

    ; ---------------------------------------------------------------------------
    mov     eax, TAdynmemStructPtr
    push    ebx
    xor     ebx, ebx
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    cmp     [edx+0B6h], bx
    jl      short loc_45B90A
    push    edi
    push    esi
    push    ebp
    mov     ebp, [esp+14h]
    xor     esi, esi

    loc_45B8A3:                             ; CODE XREF: .text:0045B905j
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esi+edx+2]
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    push    ebp
    push    edx
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jnz     short loc_45B8EC
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    cmp     byte ptr [edx+esi], 1
    jnz     short loc_45B8EC
    mov     ecx, [esp+18h]
    add     eax, 519h
    push    ecx
    push    ebx
    push    eax
    call    sub_4A1200
    mov     eax, TAdynmemStructPtr

    loc_45B8EC:                             ; CODE XREF: .text:0045B8C5j
                                            ; .text:0045B8D4j
    mov     edx, [eax+531h]
    inc     ebx
    add     esi, 15Bh
    mov     edx, [edx+4]
    movsx   ecx, word ptr [edx+0B6h]
    cmp     ebx, ecx
    jle     short loc_45B8A3
    pop     ebp
    pop     esi
    pop     edi

    loc_45B90A:                             ; CODE XREF: .text:0045B898j
    add     eax, 519h
    push    eax
    call    sub_49FA90
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    ebx
    xor     ebx, ebx
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    cmp     [edx+0B6h], bx
    jl      short loc_45B9A5
    push    edi
    push    esi
    push    ebp
    mov     ebp, [esp+14h]
    xor     esi, esi

    loc_45B943:                             ; CODE XREF: .text:0045B9A0j
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esi+edx+2]
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    push    ebp
    push    edx
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_45B981
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    add     eax, 519h
    mov     edx, [ecx+4]
    lea     ecx, [edx+esi+2]
    push    ecx
    push    eax
    call    sub_4A0570

    loc_45B981:                             ; CODE XREF: .text:0045B960j
    mov     edx, TAdynmemStructPtr
    inc     ebx
    add     esi, 15Bh
    mov     eax, [edx+531h]
    mov     edx, [eax+4]
    movsx   ecx, word ptr [edx+0B6h]
    cmp     ebx, ecx
    jle     short loc_45B943
    pop     ebp
    pop     esi
    pop     edi

    loc_45B9A5:                             ; CODE XREF: .text:0045B938j
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45B9B0 proc near                    ; CODE XREF: .text:00445E3Bp
                                            ; .text:00445EA9p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    mov     eax, [esi+13Ch]
    cmp     ecx, eax
    mov     [esp+4+arg_0], eax
    jle     short loc_45B9CB
    mov     [esp+4+arg_4], eax

    loc_45B9CB:                             ; CODE XREF: sub_45B9B0+15j
    fild    [esp+4+arg_4]
    fild    [esp+4+arg_0]
    movsx   eax, word ptr [esi+136h]
    fdivp   st(1), st
    dec     eax
    mov     [esp+4+arg_4], eax
    fimul   [esp+4+arg_4]
    fld     st
    call    __ftol
    mov     [esp+4+arg_4], eax
    fild    [esp+4+arg_4]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45BA09
    fsub    ds:dbl_4FD4E8

    loc_45BA09:                             ; CODE XREF: sub_45B9B0+51j
    call    __ftol
    mov     [esi+140h], ax
    pop     esi
    retn    8
    sub_45B9B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45BA20 proc near                    ; CODE XREF: sub_445B70+66p
                                            ; sub_445C70+23p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     cx, [eax+136h]
    cmp     cx, 1
    jg      short loc_45BA36
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45BA36:                             ; CODE XREF: sub_45BA20+Fj
    movsx   edx, word ptr [eax+140h]
    movsx   ecx, cx
    mov     [esp+arg_0], edx
    dec     ecx
    fild    [esp+arg_0]
    mov     [esp+arg_0], ecx
    fidiv   [esp+arg_0]
    fimul   dword ptr [eax+13Ch]
    call    __ftol
    retn    4
    sub_45BA20 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    sub     esp, 80h
    mov     ecx, [eax+531h]
    push    ebx
    mov     ebx, [esp+88h]
    push    esi
    mov     esi, [ecx+4]
    push    edi
    mov     edi, [esp+94h]
    add     eax, 519h
    push    edi
    push    ebx
    push    eax
    call    sub_4A11C0
    lea     edx, [esp+0Ch]
    push    ebx
    push    edx
    push    esi
    call    sub_49FED0
    lea     eax, [esp+0Ch]
    push    eax
    push    esi
    call    sub_49FF10
    test    edi, edi
    mov     edi, [esp+98h]
    lea     edx, [eax+0B6h]
    jz      short loc_45BAC1
    mov     edi, [esp+9Ch]

    loc_45BAC1:                             ; CODE XREF: .text:0045BAB8j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 80h
    retn    10h
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     byte ptr [eax+0B6h], 0
    retn    8
    ; ---------------------------------------------------------------------------
    align 4
    push    ecx
    push    ebx
    push    ebp
    mov     ebp, [esp+14h]
    xor     eax, eax
    push    esi
    push    edi
    mov     edx, [ebp+14Ah]
    mov     ecx, [edx]
    test    ecx, ecx
    jle     loc_45BBDC
    mov     edi, TAdynmemStructPtr
    mov     esi, [edx+4]
    mov     ebx, [edi+37F1Bh]

    loc_45BB2A:                             ; CODE XREF: .text:0045BB3Fj
    cmp     ebx, [esi]
    jnz     short loc_45BB39
    mov     edx, [edi+37F1Fh]
    cmp     edx, [esi+4]
    jz      short loc_45BB49

    loc_45BB39:                             ; CODE XREF: .text:0045BB2Cj
    inc     eax
    add     esi, 0Ch
    cmp     eax, ecx
    jl      short loc_45BB2A
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_45BB49:                             ; CODE XREF: .text:0045BB37j
    mov     ecx, [ebp+13Ch]
    mov     [esp+1Ch], eax
    cmp     eax, ecx
    mov     [esp+10h], ecx
    jle     short loc_45BB5F
    mov     [esp+1Ch], ecx

    loc_45BB5F:                             ; CODE XREF: .text:0045BB59j
    fild    dword ptr [esp+1Ch]
    fild    dword ptr [esp+10h]
    movsx   eax, word ptr [ebp+136h]
    fdivp   st(1), st
    dec     eax
    mov     [esp+1Ch], eax
    fimul   dword ptr [esp+1Ch]
    fld     st
    call    __ftol
    mov     [esp+1Ch], eax
    fild    dword ptr [esp+1Ch]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45BB9D
    fsub    ds:dbl_4FD4E8

    loc_45BB9D:                             ; CODE XREF: .text:0045BB95j
    call    __ftol
    mov     ecx, [esp+18h]
    mov     [ebp+140h], ax
    push    offset aVidval                  ; "VIDVAL"
    mov     edx, [ecx+18h]
    mov     eax, [edx+4]
    push    eax
    call    sub_4A0180
    test    eax, eax
    jz      short loc_45BBDC
    mov     ecx, [esi+4]
    mov     edx, [esi]
    push    ecx
    push    edx
    add     eax, 0B6h
    push    offset aDXD                     ; "%d X %d"
    push    eax
    call    _sprintf
    add     esp, 10h

    loc_45BBDC:                             ; CODE XREF: .text:0045BB15j
                                            ; .text:0045BBC0j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    loc_45BBF0:                             ; DATA XREF: sub_45E5E0+14Co
    push    esi
    push    edi
    mov     edi, [esp+0Ch]
    push    offset aVidsldr                 ; "VIDSLDR"
    mov     eax, [edi+18h]
    mov     ecx, [eax+4]
    push    ecx
    call    sub_4A0200
    mov     esi, [eax+14Ah]
    test    eax, eax
    jz      loc_45BC9D
    mov     cx, [eax+136h]
    cmp     cx, 1
    jg      short loc_45BC26
    xor     eax, eax
    jmp     short loc_45BC4C
    ; ---------------------------------------------------------------------------

    loc_45BC26:                             ; CODE XREF: .text:0045BC20j
    movsx   edx, word ptr [eax+140h]
    movsx   ecx, cx
    mov     [esp+0Ch], edx
    dec     ecx
    fild    dword ptr [esp+0Ch]
    mov     [esp+0Ch], ecx
    fidiv   dword ptr [esp+0Ch]
    fimul   dword ptr [eax+13Ch]
    call    __ftol

    loc_45BC4C:                             ; CODE XREF: .text:0045BC24j
    lea     edx, [eax+eax*2]
    mov     eax, [esi+4]
    mov     ecx, [eax+edx*4+4]
    lea     esi, [eax+edx*4]
    mov     eax, [edi+18h]
    push    ecx
    mov     edx, [esi]
    mov     ecx, [eax+4]
    push    edx
    push    offset aDXD                     ; "%d X %d"
    push    offset aVidval                  ; "VIDVAL"
    push    ecx
    call    sub_4A0180
    add     eax, 0B6h
    push    eax
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    mov     edx, [esi]
    add     esp, 10h
    mov     [eax+37F1Bh], edx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esi+4]
    mov     [edx+37F1Fh], ecx

    loc_45BC9D:                             ; CODE XREF: .text:0045BC0Fj
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA90
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45BCC0 proc near                    ; CODE XREF: sub_491200+27Cp

    var_4= dword ptr -4

    mov     eax, TAdynmemStructPtr
    push    ecx
    fild    dword ptr [eax+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    [esp+4+var_4]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F0Ch]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     edx, [eax+37F10h]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D00D0
    retn
    sub_45BCC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_45BD20:                             ; DATA XREF: sub_45E5E0+449o
    mov     eax, [esp+4]
    push    offset aGamma_0                 ; "GAMMA"
    mov     ecx, [eax+18h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_4A0200
    test    eax, eax
    jz      locret_45BDD0
    mov     cx, [eax+136h]
    cmp     cx, 1
    jg      short loc_45BD4E
    xor     eax, eax
    jmp     short loc_45BD74
    ; ---------------------------------------------------------------------------

    loc_45BD4E:                             ; CODE XREF: .text:0045BD48j
    movsx   edx, word ptr [eax+140h]
    movsx   ecx, cx
    mov     [esp+4], edx
    dec     ecx
    fild    dword ptr [esp+4]
    mov     [esp+4], ecx
    fidiv   dword ptr [esp+4]
    fimul   dword ptr [eax+13Ch]
    call    __ftol

    loc_45BD74:                             ; CODE XREF: .text:0045BD4Cj
    mov     edx, TAdynmemStructPtr
    push    ecx
    mov     [edx+37F08h], eax
    mov     eax, TAdynmemStructPtr
    fild    dword ptr [eax+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    dword ptr [esp]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F0Ch]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     edx, [eax+37F10h]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D00D0

    locret_45BDD0:                          ; CODE XREF: .text:0045BD37j
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    loc_45BDE0:                             ; DATA XREF: sub_45DE30+CCo
    mov     eax, [esp+4]
    push    offset aFxvol_0                 ; "FXVOL"
    mov     ecx, [eax+18h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_4A0200
    test    eax, eax
    jz      locret_45BE90
    mov     cx, [eax+136h]
    cmp     cx, 1
    jg      short loc_45BE0E
    xor     eax, eax
    jmp     short loc_45BE34
    ; ---------------------------------------------------------------------------

    loc_45BE0E:                             ; CODE XREF: .text:0045BE08j
    movsx   edx, word ptr [eax+140h]
    movsx   ecx, cx
    mov     [esp+4], edx
    dec     ecx
    fild    dword ptr [esp+4]
    mov     [esp+4], ecx
    fidiv   dword ptr [esp+4]
    fimul   dword ptr [eax+13Ch]
    call    __ftol

    loc_45BE34:                             ; CODE XREF: .text:0045BE0Cj
    mov     edx, TAdynmemStructPtr
    push    ecx
    mov     [edx+37F0Ch], eax
    mov     eax, TAdynmemStructPtr
    fild    dword ptr [eax+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    dword ptr [esp]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F0Ch]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     edx, [eax+37F10h]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D00D0

    locret_45BE90:                          ; CODE XREF: .text:0045BDF7j
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    loc_45BEA0:                             ; DATA XREF: sub_45D7C0+D6o
    mov     eax, [esp+4]
    push    offset aMusicvol_0              ; "MUSICVOL"
    mov     ecx, [eax+18h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_4A0200
    test    eax, eax
    jz      locret_45BF50
    mov     cx, [eax+136h]
    cmp     cx, 1
    jg      short loc_45BECE
    xor     eax, eax
    jmp     short loc_45BEF4
    ; ---------------------------------------------------------------------------

    loc_45BECE:                             ; CODE XREF: .text:0045BEC8j
    movsx   edx, word ptr [eax+140h]
    movsx   ecx, cx
    mov     [esp+4], edx
    dec     ecx
    fild    dword ptr [esp+4]
    mov     [esp+4], ecx
    fidiv   dword ptr [esp+4]
    fimul   dword ptr [eax+13Ch]
    call    __ftol

    loc_45BEF4:                             ; CODE XREF: .text:0045BECCj
    mov     edx, TAdynmemStructPtr
    push    ecx
    mov     [edx+37F10h], eax
    mov     eax, TAdynmemStructPtr
    fild    dword ptr [eax+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    dword ptr [esp]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F0Ch]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     edx, [eax+37F10h]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D00D0

    locret_45BF50:                          ; CODE XREF: .text:0045BEB7j
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+10h]
    sub     esp, 0C8h
    push    esi
    mov     esi, [esp+0D8h]
    cmp     esi, ecx
    jnz     short loc_45BF7D
    mov     eax, offset aNormal             ; "Normal"
    jmp     short loc_45BFBF
    ; ---------------------------------------------------------------------------

    loc_45BF7D:                             ; CODE XREF: .text:0045BF74j
    mov     eax, ecx
    cdq
    and     edx, 3
    add     eax, edx
    sar     eax, 2
    cmp     esi, eax
    jge     short loc_45BF93
    mov     eax, offset aSlow               ; "Slow"
    jmp     short loc_45BFBF
    ; ---------------------------------------------------------------------------

    loc_45BF93:                             ; CODE XREF: .text:0045BF8Aj
    mov     eax, ecx
    cdq
    sub     eax, edx
    sar     eax, 1
    cmp     esi, eax
    jge     short loc_45BFA5
    mov     eax, offset aSlower             ; "Slower"
    jmp     short loc_45BFBF
    ; ---------------------------------------------------------------------------

    loc_45BFA5:                             ; CODE XREF: .text:0045BF9Cj
    lea     eax, [ecx+ecx*2]
    cdq
    and     edx, 3
    add     eax, edx
    sar     eax, 2
    cmp     esi, eax
    mov     eax, offset aFast               ; "Fast"
    jg      short loc_45BFBF
    mov     eax, offset aFaster             ; "Faster"

    loc_45BFBF:                             ; CODE XREF: .text:0045BF7Bj
                                            ; .text:0045BF91j ...
    mov     esi, [esp+0D4h]
    push    eax
    push    esi
    lea     eax, [esp+0Ch]
    push    offset aSS_5                    ; "%s (%s)"
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+0E0h]
    add     esp, 10h
    add     edx, 519h
    push    0
    push    esi
    push    ecx
    push    edx
    call    sub_4A0BF0
    pop     esi
    add     esp, 0C8h
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    sub     esp, 64h
    cmp     dword ptr [eax], 0
    jz      short loc_45C064
    mov     ecx, [esp+70h]

    loc_45C020:                             ; CODE XREF: .text:0045C02Dj
    cmp     ecx, [eax+4]
    jle     short loc_45C035
    mov     edx, [eax+8]
    add     eax, 8
    test    edx, edx
    jnz     short loc_45C020
    add     esp, 64h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_45C035:                             ; CODE XREF: .text:0045C023j
    mov     eax, [eax]
    push    ecx
    lea     ecx, [esp+4]
    push    eax
    push    ecx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+78h]
    add     esp, 0Ch
    lea     edx, [esp+0]
    add     ecx, 519h
    push    0
    push    edx
    push    eax
    push    ecx
    call    sub_4A0BF0

    loc_45C064:                             ; CODE XREF: .text:0045C01Aj
    add     esp, 64h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    loc_45C070:                             ; DATA XREF: sub_45ED50+D1o
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    ebx
    push    esi
    mov     dl, [ecx+2A42h]
    push    edi
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*2+1B63h]
    cmp     dword ptr [eax], 0
    jz      short loc_45C0A9
    mov     ecx, [eax+27h]
    test    byte ptr [ecx+9Bh], 40h
    jnz     loc_45C165

    loc_45C0A9:                             ; CODE XREF: .text:0045C097j
    mov     ebx, [esp+10h]
    push    offset aGame                    ; "GAME"
    mov     edx, [ebx+18h]
    mov     eax, [edx+4]
    push    eax
    call    sub_4A0200
    mov     esi, eax
    test    esi, esi
    jz      loc_45C165
    mov     di, [esi+136h]
    cmp     di, 1
    jg      short loc_45C0D9
    xor     eax, eax
    jmp     short loc_45C0FF
    ; ---------------------------------------------------------------------------

    loc_45C0D9:                             ; CODE XREF: .text:0045C0D3j
    movsx   ecx, word ptr [esi+140h]
    movsx   edx, di
    mov     [esp+10h], ecx
    dec     edx
    fild    dword ptr [esp+10h]
    mov     [esp+10h], edx
    fidiv   dword ptr [esp+10h]
    fimul   dword ptr [esi+13Ch]
    call    __ftol

    loc_45C0FF:                             ; CODE XREF: .text:0045C0D7j
    cmp     eax, 1
    jge     short loc_45C10B
    mov     eax, 1
    jmp     short loc_45C13B
    ; ---------------------------------------------------------------------------

    loc_45C10B:                             ; CODE XREF: .text:0045C102j
    cmp     di, 1
    jg      short loc_45C115
    xor     eax, eax
    jmp     short loc_45C13B
    ; ---------------------------------------------------------------------------

    loc_45C115:                             ; CODE XREF: .text:0045C10Fj
    movsx   eax, word ptr [esi+140h]
    movsx   ecx, di
    mov     [esp+10h], eax
    dec     ecx
    fild    dword ptr [esp+10h]
    mov     [esp+10h], ecx
    fidiv   dword ptr [esp+10h]
    fimul   dword ptr [esi+13Ch]
    call    __ftol

    loc_45C13B:                             ; CODE XREF: .text:0045C109j
                                            ; .text:0045C113j
    mov     edx, TAdynmemStructPtr
    push    1
    mov     [edx+38A4Bh], ax
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     ax, [ecx+38A4Bh]
    push    eax
    call    sub_490DF0
    push    ebx
    call    sub_49FA90

    loc_45C165:                             ; CODE XREF: .text:0045C0A3j
                                            ; .text:0045C0C2j
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45C170 proc near                    ; DATA XREF: sub_45ED50+1DEo

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    push    offset aScreen                  ; char *
    mov     eax, [ebx+18h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    mov     esi, eax
    test    esi, esi
    jz      loc_45C218
    push    edi
    mov     di, [esi+136h]
    cmp     di, 1
    jg      short loc_45C1A3
    xor     eax, eax
    jmp     short loc_45C1C9
    ; ---------------------------------------------------------------------------

    loc_45C1A3:                             ; CODE XREF: sub_45C170+2Dj
    movsx   edx, word ptr [esi+140h]
    movsx   eax, di
    mov     [esp+8+arg_0], edx
    dec     eax
    fild    [esp+8+arg_0]
    mov     [esp+8+arg_0], eax
    fidiv   [esp+8+arg_0]
    fimul   dword ptr [esi+13Ch]
    call    __ftol

    loc_45C1C9:                             ; CODE XREF: sub_45C170+31j
    cmp     eax, 1
    jle     short loc_45C200
    cmp     di, 1
    jg      short loc_45C1D8
    xor     eax, eax
    jmp     short loc_45C205
    ; ---------------------------------------------------------------------------

    loc_45C1D8:                             ; CODE XREF: sub_45C170+62j
    movsx   ecx, word ptr [esi+140h]
    movsx   edx, di
    mov     [esp+8+arg_0], ecx
    dec     edx
    fild    [esp+8+arg_0]
    mov     [esp+8+arg_0], edx
    fidiv   [esp+8+arg_0]
    fimul   dword ptr [esi+13Ch]
    call    __ftol
    jmp     short loc_45C205
    ; ---------------------------------------------------------------------------

    loc_45C200:                             ; CODE XREF: sub_45C170+5Cj
    mov     eax, 1

    loc_45C205:                             ; CODE XREF: sub_45C170+66j
                                            ; sub_45C170+8Ej
    mov     ecx, TAdynmemStructPtr
    push    ebx                             ; int
    mov     [ecx+1434Dh], al
    call    sub_49FA90
    pop     edi

    loc_45C218:                             ; CODE XREF: sub_45C170+1Bj
    pop     esi
    pop     ebx
    retn    8
    sub_45C170 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45C220 proc near                    ; DATA XREF: sub_45ED50+315o

    var_14= dword ptr -14h
    arg_0= dword ptr  4

    sub     esp, 14h
    push    ebx
    mov     ebx, [esp+18h+arg_0]
    push    esi
    push    edi
    mov     eax, [ebx+18h]
    push    offset aMaxlines                ; char *
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    mov     esi, eax
    test    esi, esi
    jz      loc_45C2C6
    mov     di, [esi+136h]
    cmp     di, 1
    jg      short loc_45C256
    xor     eax, eax
    jmp     short loc_45C27C
    ; ---------------------------------------------------------------------------

    loc_45C256:                             ; CODE XREF: sub_45C220+30j
    movsx   edx, word ptr [esi+140h]
    movsx   eax, di
    mov     [esp+20h+arg_0], edx
    dec     eax
    fild    [esp+20h+arg_0]
    mov     [esp+20h+arg_0], eax
    fidiv   [esp+20h+arg_0]
    fimul   dword ptr [esi+13Ch]
    call    __ftol

    loc_45C27C:                             ; CODE XREF: sub_45C220+34j
    test    eax, eax
    jge     short loc_45C284
    xor     eax, eax
    jmp     short loc_45C2B4
    ; ---------------------------------------------------------------------------

    loc_45C284:                             ; CODE XREF: sub_45C220+5Ej
    cmp     di, 1
    jg      short loc_45C28E
    xor     eax, eax
    jmp     short loc_45C2B4
    ; ---------------------------------------------------------------------------

    loc_45C28E:                             ; CODE XREF: sub_45C220+68j
    movsx   ecx, word ptr [esi+140h]
    movsx   edx, di
    mov     [esp+20h+arg_0], ecx
    dec     edx
    fild    [esp+20h+arg_0]
    mov     [esp+20h+arg_0], edx
    fidiv   [esp+20h+arg_0]
    fimul   dword ptr [esi+13Ch]
    call    __ftol

    loc_45C2B4:                             ; CODE XREF: sub_45C220+62j
                                            ; sub_45C220+6Cj
    mov     ecx, TAdynmemStructPtr
    push    ebx                             ; int
    mov     [ecx+37F27h], eax
    call    sub_49FA90

    loc_45C2C6:                             ; CODE XREF: sub_45C220+1Fj
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37F27h]
    test    eax, eax
    jz      short loc_45C2EB
    push    eax
    lea     eax, [esp+24h+var_14]
    push    offset aD_0                     ; "%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    jmp     short loc_45C311
    ; ---------------------------------------------------------------------------

    loc_45C2EB:                             ; CODE XREF: sub_45C220+B4j
    mov     edi, offset aNone               ; "None"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+20h+var_14]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_45C311:                             ; CODE XREF: sub_45C220+C9j
    lea     ecx, [esp+20h+var_14]
    push    0
    push    ecx
    push    offset aMaxlinestext            ; "MAXLINESTEXT"
    push    ebx
    call    sub_4A0BF0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 14h
    retn    8
    sub_45C220 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45C330 proc near                    ; DATA XREF: sub_45ED50+3B8o

    var_14= dword ptr -14h
    arg_0= dword ptr  4

    sub     esp, 14h
    push    esi
    mov     esi, [esp+18h+arg_0]
    push    offset aTxtscrol                ; char *
    mov     eax, [esi+18h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    test    eax, eax
    jz      short loc_45C3C6
    mov     cx, [eax+136h]
    cmp     cx, 1
    jg      short loc_45C35E
    xor     eax, eax
    jmp     short loc_45C384
    ; ---------------------------------------------------------------------------

    loc_45C35E:                             ; CODE XREF: sub_45C330+28j
    movsx   edx, word ptr [eax+140h]
    movsx   ecx, cx
    mov     [esp+18h+arg_0], edx
    dec     ecx
    fild    [esp+18h+arg_0]
    mov     [esp+18h+arg_0], ecx
    fidiv   [esp+18h+arg_0]
    fimul   dword ptr [eax+13Ch]
    call    __ftol

    loc_45C384:                             ; CODE XREF: sub_45C330+2Cj
    mov     edx, TAdynmemStructPtr
    mov     [edx+37F23h], eax
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+18h+var_14]
    mov     ecx, [eax+37F23h]
    push    ecx
    push    offset aDSecs                   ; "%d secs"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+18h+var_14]
    push    0
    push    eax
    push    offset aTextscrolltext          ; "TEXTSCROLLTEXT"
    push    esi
    call    sub_4A0BF0
    push    esi                             ; int
    call    sub_49FA90

    loc_45C3C6:                             ; CODE XREF: sub_45C330+1Bj
    pop     esi
    add     esp, 14h
    retn    8
    sub_45C330 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+4]
    push    eax
    mov     ecx, [ecx+10h]
    call    sub_4CE580
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45C3F0 proc near                    ; CODE XREF: .text:0045D113p
                                            ; sub_45D280+1E5p ...

    var_C= dword ptr -0Ch

    mov     eax, TAdynmemStructPtr
    sub     esp, 0Ch
    mov     ecx, [eax+531h]
    push    ebx
    lea     ebx, [eax+519h]
    push    esi
    mov     edx, [ecx+4]
    push    edi
    push    1
    push    offset aTracktype               ; char *
    push    edx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_45C4C2
    mov     eax, TAdynmemStructPtr
    mov     esi, dword_512FE0
    test    byte ptr [eax+37F14h], 1
    jz      short loc_45C441
    cmp     byte ptr [eax+37F16h], 4
    jnz     short loc_45C441
    xor     eax, eax
    jmp     short loc_45C446
    ; ---------------------------------------------------------------------------

    loc_45C441:                             ; CODE XREF: sub_45C3F0+42j
                                            ; sub_45C3F0+4Bj
    mov     eax, 1

    loc_45C446:                             ; CODE XREF: sub_45C3F0+4Fj
    push    eax                             ; char
    push    offset aTracktype               ; char *
    push    ebx                             ; int
    call    sub_4A1250
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+10h]
    call    sub_4CE7E0
    and     eax, 0FFh
    push    eax                             ; char
    push    offset aTracktype               ; char *
    push    ebx                             ; int
    call    sub_4A1080
    test    esi, esi
    jnz     short loc_45C49D
    mov     edi, offset aNoDisc             ; "NO DISC"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0Ch]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_45C4B0
    ; ---------------------------------------------------------------------------

    loc_45C49D:                             ; CODE XREF: sub_45C3F0+83j
    push    esi
    lea     ecx, [esp+10h]
    push    offset aD_0                     ; "%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch

    loc_45C4B0:                             ; CODE XREF: sub_45C3F0+ABj
    lea     edx, [esp+0Ch]
    push    0
    push    edx
    push    offset aTracknum                ; "TRACKNUM"
    push    ebx
    call    sub_4A0BF0

    loc_45C4C2:                             ; CODE XREF: sub_45C3F0+2Aj
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    not     cl
    and     ecx, 1
    push    ecx
    push    offset aTracknum                ; "TRACKNUM"
    push    ebx
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    cmp     byte ptr [eax+37F16h], 3
    jnz     short loc_45C4FB
    mov     ecx, dword_512FE0
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4CE580

    loc_45C4FB:                             ; CODE XREF: sub_45C3F0+FAj
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0Ch
    retn
    sub_45C3F0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+531h]
    mov     esi, [ecx+4]
    mov     cl, [eax+37F16h]
    cmp     cl, 4
    jnz     short loc_45C566
    push    1
    push    offset aTracktype               ; "TRACKTYPE"
    push    esi
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, dword_512FE0
    mov     al, [esi+edx*2+137h]
    mov     edx, TAdynmemStructPtr
    push    eax
    push    ecx
    mov     ecx, [edx+10h]
    call    sub_4CE7C0

    loc_45C566:                             ; CODE XREF: .text:0045C528j
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37F0Ch], 1Bh
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F19h], 10h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F19h], 20h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F19h], 40h
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CFE90
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+37F19h]
    and     edx, 0FFF9h
    or      edx, 1
    mov     [eax+37F19h], dx
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+37F17h], 0Ah
    mov     ecx, TAdynmemStructPtr
    push    ecx
    fild    dword ptr [ecx+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    dword ptr [esp]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F0Ch]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+37F10h]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D00D0
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37F10h], 20h
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+37F16h], 4
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F14h]
    test    al, 1
    jnz     short loc_45C67A
    or      al, 1
    mov     [ecx+37F14h], ax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CDB40
    mov     ecx, TAdynmemStructPtr

    loc_45C67A:                             ; CODE XREF: .text:0045C65Bj
    fild    dword ptr [ecx+37F08h]
    push    ecx
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    dword ptr [esp]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F0Ch]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     edx, [eax+37F10h]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D00D0
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     eax, 0Ah
    mov     [ecx+37F23h], eax
    mov     edx, TAdynmemStructPtr
    mov     [edx+37F27h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38A4Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+38A4Dh], ax
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+1434Dh], 20h
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37EFAh], 0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F17h], al
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+37F18h], 5
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    mov     ecx, 4
    or      byte ptr [eax+37F06h], 2
    mov     eax, TAdynmemStructPtr
    or      [eax+37F06h], cx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F06h], 8
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F06h], 10h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F06h], 20h
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37F08h], 0Ch
    mov     eax, TAdynmemStructPtr
    test    [eax+2A44h], cl
    jnz     short loc_45C7CA
    mov     dword ptr [eax+37F1Bh], 280h
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+37F1Fh], 1E0h
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F06h], 0FFBFh
    mov     eax, TAdynmemStructPtr

    loc_45C7CA:                             ; CODE XREF: .text:0045C79Bj
    fild    dword ptr [eax+37F08h]
    push    ecx
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    dword ptr [esp]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F0Ch]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+37F10h]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D00D0
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45C820 proc near                    ; CODE XREF: .text:0045CC51p
                                            ; sub_45DA90+DBp ...

    var_8= dword ptr -8

    mov     eax, TAdynmemStructPtr
    mov     ecx, dword_512F3E
    push    ebx
    mov     [eax+37F0Ch], ecx
    mov     ecx, TAdynmemStructPtr
    mov     bl, byte_512F4B
    mov     ax, [ecx+37F19h]
    mov     dl, al
    xor     dl, bl
    and     edx, 10h
    xor     edx, eax
    mov     [ecx+37F19h], dx
    mov     ecx, TAdynmemStructPtr
    mov     bl, byte_512F4B
    mov     ax, [ecx+37F19h]
    mov     dl, al
    xor     dl, bl
    and     edx, 20h
    xor     edx, eax
    mov     [ecx+37F19h], dx
    mov     eax, TAdynmemStructPtr
    mov     dl, byte_512F4B
    mov     cx, [eax+37F19h]
    and     edx, 20h
    and     ecx, 0FFBFh
    shl     edx, 1
    or      ecx, edx
    mov     [eax+37F19h], cx
    mov     al, byte_512F4B
    and     al, 7
    cmp     al, 2
    jnz     short loc_45C8B9
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CFE80
    jmp     short loc_45C8C7
    ; ---------------------------------------------------------------------------

    loc_45C8B9:                             ; CODE XREF: sub_45C820+87j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CFE90

    loc_45C8C7:                             ; CODE XREF: sub_45C820+97j
    mov     ecx, TAdynmemStructPtr
    mov     bl, byte_512F4B
    mov     ax, [ecx+37F19h]
    mov     dl, al
    xor     dl, bl
    and     edx, 7
    xor     edx, eax
    mov     [ecx+37F19h], dx
    mov     eax, TAdynmemStructPtr
    mov     cl, byte_512F49
    mov     [eax+37F17h], cl
    mov     edx, TAdynmemStructPtr
    push    ecx
    fild    dword ptr [edx+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    [esp+8+var_8]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F0Ch]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     edx, [eax+37F10h]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D00D0
    pop     ebx
    retn
    sub_45C820 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    mov     ecx, dword_512F42
    push    esi
    push    offset byte_512F75
    mov     [eax+37F10h], ecx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CE3E0
    mov     eax, TAdynmemStructPtr
    mov     cl, byte_512F48
    xor     edx, edx
    mov     [eax+37F16h], cl
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F16h]
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE7A0
    mov     esi, TAdynmemStructPtr
    mov     dl, byte_512F46
    mov     al, [esi+37F14h]
    xor     al, dl
    test    al, 1
    jz      short loc_45C9C2
    mov     ecx, [esi+10h]
    call    sub_4CDB40
    mov     esi, TAdynmemStructPtr

    loc_45C9C2:                             ; CODE XREF: .text:0045C9B2j
    mov     ax, [esi+37F14h]
    mov     dl, byte_512F46
    mov     cl, al
    xor     cl, dl
    and     ecx, 1
    xor     ecx, eax
    mov     [esi+37F14h], cx
    mov     eax, TAdynmemStructPtr
    mov     edx, dword_512FD9
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE580
    mov     ecx, TAdynmemStructPtr
    push    ecx
    fild    dword ptr [ecx+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    dword ptr [esp]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F0Ch]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+37F10h]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D00D0
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     ecx, dword_512F55
    mov     [eax+37F23h], ecx
    mov     eax, TAdynmemStructPtr
    mov     dx, word ptr dword_512F6D
    mov     [eax+38A4Bh], dx
    mov     ecx, TAdynmemStructPtr
    mov     dx, word ptr dword_512F6D
    mov     [ecx+38A4Dh], dx
    mov     eax, TAdynmemStructPtr
    mov     cl, byte ptr dword_512F71
    mov     [eax+1434Dh], cl
    mov     edx, TAdynmemStructPtr
    mov     eax, dword_512F2C
    mov     [edx+37EFAh], eax
    mov     ecx, TAdynmemStructPtr
    mov     dl, byte_512F49
    mov     [ecx+37F17h], dl
    mov     eax, TAdynmemStructPtr
    mov     cl, byte_512F4A
    mov     [eax+37F18h], cl
    mov     edx, TAdynmemStructPtr
    mov     eax, dword_512F59
    mov     [edx+37F27h], eax
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45CAE0 proc near                    ; CODE XREF: .text:0045CDD8p
                                            ; sub_45E100+218p ...

    var_8= dword ptr -8

    mov     ecx, TAdynmemStructPtr
    push    ebx
    mov     bl, byte_512F38
    mov     ax, [ecx+37F06h]
    mov     dl, al
    xor     dl, bl
    and     edx, 2
    xor     edx, eax
    mov     [ecx+37F06h], dx
    mov     ecx, TAdynmemStructPtr
    mov     bl, byte_512F38
    mov     ax, [ecx+37F06h]
    mov     dl, al
    xor     dl, bl
    and     edx, 4
    xor     edx, eax
    mov     [ecx+37F06h], dx
    mov     ecx, TAdynmemStructPtr
    mov     bl, byte_512F38
    mov     ax, [ecx+37F06h]
    mov     dl, al
    xor     dl, bl
    and     edx, 8
    xor     edx, eax
    mov     [ecx+37F06h], dx
    mov     ecx, TAdynmemStructPtr
    mov     bl, byte_512F38
    mov     ax, [ecx+37F06h]
    mov     dl, al
    xor     dl, bl
    and     edx, 10h
    xor     edx, eax
    mov     [ecx+37F06h], dx
    mov     ecx, TAdynmemStructPtr
    mov     bl, byte_512F38
    mov     ax, [ecx+37F06h]
    mov     dl, al
    xor     dl, bl
    and     edx, 20h
    xor     edx, eax
    mov     [ecx+37F06h], dx
    mov     ecx, TAdynmemStructPtr
    mov     bl, byte_512F38
    mov     ax, [ecx+37F06h]
    mov     dl, al
    xor     dl, bl
    and     edx, 40h
    xor     edx, eax
    mov     [ecx+37F06h], dx
    mov     eax, TAdynmemStructPtr
    mov     ecx, dword_512F3A
    mov     [eax+37F08h], ecx
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 4
    jnz     short loc_45CBF4
    mov     edx, dword_512F4D
    mov     [eax+37F1Bh], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, dword_512F51
    mov     [eax+37F1Fh], ecx
    mov     eax, TAdynmemStructPtr

    loc_45CBF4:                             ; CODE XREF: sub_45CAE0+F0j
    fild    dword ptr [eax+37F08h]
    push    ecx
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    [esp+8+var_8]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F0Ch]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+37F10h]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D00D0
    pop     ebx
    retn
    sub_45CAE0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    call    sub_45C820
    mov     eax, TAdynmemStructPtr
    mov     ecx, dword_512F42
    push    offset byte_512F75
    mov     [eax+37F10h], ecx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CE3E0
    mov     eax, TAdynmemStructPtr
    mov     cl, byte_512F48
    xor     edx, edx
    mov     [eax+37F16h], cl
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F16h]
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE7A0
    mov     esi, TAdynmemStructPtr
    mov     dl, byte_512F46
    mov     al, [esi+37F14h]
    xor     al, dl
    test    al, 1
    jz      short loc_45CCC7
    mov     ecx, [esi+10h]
    call    sub_4CDB40
    mov     esi, TAdynmemStructPtr

    loc_45CCC7:                             ; CODE XREF: .text:0045CCB7j
    mov     ax, [esi+37F14h]
    mov     dl, byte_512F46
    mov     cl, al
    xor     cl, dl
    and     ecx, 1
    xor     ecx, eax
    mov     [esi+37F14h], cx
    mov     eax, TAdynmemStructPtr
    mov     edx, dword_512FD9
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE580
    mov     ecx, TAdynmemStructPtr
    push    ecx
    fild    dword ptr [ecx+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    dword ptr [esp]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F0Ch]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+37F10h]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D00D0
    mov     edx, TAdynmemStructPtr
    mov     eax, dword_512F55
    mov     [edx+37F23h], eax
    mov     edx, TAdynmemStructPtr
    mov     cx, word ptr dword_512F6D
    mov     [edx+38A4Bh], cx
    mov     eax, TAdynmemStructPtr
    mov     cx, word ptr dword_512F6D
    mov     [eax+38A4Dh], cx
    mov     edx, TAdynmemStructPtr
    mov     al, byte ptr dword_512F71
    mov     [edx+1434Dh], al
    mov     ecx, TAdynmemStructPtr
    mov     edx, dword_512F2C
    mov     [ecx+37EFAh], edx
    mov     eax, TAdynmemStructPtr
    mov     cl, byte_512F49
    mov     [eax+37F17h], cl
    mov     edx, TAdynmemStructPtr
    mov     al, byte_512F4A
    mov     [edx+37F18h], al
    mov     ecx, TAdynmemStructPtr
    mov     edx, dword_512F59
    mov     [ecx+37F27h], edx
    call    sub_45CAE0
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    mov     ecx, 14h
    lea     esi, [eax+37EE6h]
    mov     edi, offset dword_512F18
    rep movsd
    movsw
    movsb
    mov     dl, [eax+14281h]
    mov     cx, word_512F6B
    shr     dl, 1
    and     ecx, 0FFFEh
    and     edx, 1
    or      ecx, edx
    mov     word_512F6B, cx
    mov     dl, [eax+14281h]
    shr     dl, 1
    and     ecx, 0FFFDh
    and     edx, 2
    or      ecx, edx
    xor     edx, edx
    mov     word_512F6B, cx
    xor     ecx, ecx
    mov     cx, [eax+38A4Bh]
    mov     dword_512F6D, ecx
    mov     dl, [eax+1434Dh]
    mov     dword_512F71, edx
    mov     ecx, [eax+10h]
    call    sub_4CE5A0
    mov     dword_512FD9, eax
    xor     esi, esi

    loc_45CE63:                             ; CODE XREF: .text:0045CE7Bj
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+10h]
    call    sub_4CE7E0
    mov     byte_512F75[esi], al
    inc     esi
    cmp     esi, 64h
    jl      short loc_45CE63
    pop     edi
    pop     esi
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45CE80 proc near                    ; CODE XREF: sub_45D7C0+1Bp
                                            ; sub_45DE30+1Dp ...

    var_4= dword ptr -4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebp
    push    0Eh
    push    offset aPanel_0                 ; char *
    mov     ecx, [eax+531h]
    mov     ebp, [ecx+4]
    push    ebp                             ; int
    call    sub_49FDF0
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+37EBEh], 1
    jz      loc_45CF5D
    add     word ptr [ebp+17h], 96h
    cmp     eax, 0FFFFFFFFh
    jnz     loc_45CF5D
    mov     cx, [ebp+0B6h]
    push    edi
    movsx   eax, cx
    inc     eax
    inc     ecx
    mov     [ebp+0B6h], cx
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    push    esi
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebp
    add     edx, eax
    xor     eax, eax
    lea     edx, [edx+ecx*2]
    mov     ecx, 56h
    mov     edi, edx
    rep stosd
    stosw
    stosb
    mov     byte ptr [edx], 0Bh
    mov     word ptr [edx+13h], 80h
    mov     ax, [ebp+17h]
    mov     edi, offset aPanel_0            ; "PANEL"
    mov     [edx+17h], ax
    mov     word ptr [edx+15h], 0
    mov     cx, [edx+13h]
    lea     esi, [edx+2]
    sub     [edx+17h], cx
    mov     ax, [ebp+19h]
    mov     [edx+19h], ax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esp+0Ch], esi
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+0Ch]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     byte ptr [edx+29h], 1
    mov     ecx, [ebp+0C4h]
    pop     esi
    mov     [edx+0C4h], ecx
    pop     edi

    loc_45CF5D:                             ; CODE XREF: sub_45CE80+2Aj
                                            ; sub_45CE80+39j
    pop     ebp
    pop     ecx
    retn
    sub_45CE80 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2A44h]
    shr     cl, 2
    test    cl, 1
    jnz     short locret_45CFBD
    add     eax, 519h
    push    40h
    push    eax
    call    sub_4A81E0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    push    0
    add     eax, 519h
    push    0
    push    eax
    call    sub_4AB170
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37E1Bh]
    push    edx
    call    sub_4C69A0
    jmp     sub_4C63A0
    ; ---------------------------------------------------------------------------

    locret_45CFBD:                          ; CODE XREF: .text:0045CF71j
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45CFC0 proc near                    ; CODE XREF: sub_45D7C0+2p
                                            ; sub_45DE30+4p ...

    var_100= dword ptr -100h

    mov     edx, TAdynmemStructPtr
    sub     esp, 100h
    mov     al, [edx+2A44h]
    push    ebp
    shr     al, 2
    push    esi
    push    edi
    test    al, 1
    lea     ebp, [esp+10Ch+var_100]
    jz      short loc_45D011
    mov     edi, offset aPrefs_gui          ; "PREFS.GUI"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    or      byte ptr [edx+37EBEh], 1
    mov     edx, TAdynmemStructPtr
    jmp     short loc_45D033
    ; ---------------------------------------------------------------------------

    loc_45D011:                             ; CODE XREF: sub_45CFC0+1Ej
    mov     edi, offset aStartopt_gui       ; "STARTOPT.GUI"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_45D033:                             ; CODE XREF: sub_45CFC0+4Fj
    lea     ecx, [esp+10Ch+var_100]
    push    80h
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AA8F0
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edx, [eax+10h]
    cmp     dword ptr [edx], 0
    setz    cl
    push    ecx                             ; char
    add     eax, 519h
    push    offset aMusic                   ; char *
    push    eax                             ; int
    call    sub_4A1250
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA50
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 4
    jz      short loc_45D0A8
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jz      short loc_45D0A8
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+38A51h], 1

    loc_45D0A8:                             ; CODE XREF: sub_45CFC0+CAj
                                            ; sub_45CFC0+DAj
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 100h
    retn
    sub_45CFC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_45D0C0:                             ; DATA XREF: sub_45D7C0+83o
    mov     ecx, TAdynmemStructPtr
    sub     esp, 14h
    lea     eax, [esp+0]
    add     ecx, 519h
    push    esi
    push    eax
    push    offset aTracknum                ; "TRACKNUM"
    push    ecx
    call    sub_4A0D00
    lea     edx, [esp+4]
    push    edx
    call    _atoi
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     ecx, [eax+10h]
    call    sub_4CE7F0
    cmp     esi, eax
    jz      short loc_45D12A
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CE7F0
    mov     dword_512FE0, eax
    call    sub_45C3F0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90

    loc_45D12A:                             ; CODE XREF: .text:0045D0FEj
    pop     esi
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45D130 proc near                    ; CODE XREF: sub_45D280+C5p
                                            ; sub_45D7C0+156p
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    add     eax, 519h
    and     ecx, 1
    push    ecx                             ; char
    push    offset aNotrak                  ; char *
    push    eax                             ; int
    call    sub_4A1080
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [eax+37F16h]
    add     eax, 519h
    dec     edx
    push    edx                             ; char
    push    offset aTrackmode               ; char *
    push    eax                             ; int
    call    sub_4A1080
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    add     eax, 519h
    not     cl
    and     ecx, 1
    push    ecx
    push    offset aMusicvol_0              ; "MUSICVOL"
    push    eax
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F14h]
    add     eax, 519h
    not     dl
    and     edx, 1
    push    edx                             ; char
    push    offset aCdprev                  ; char *
    push    eax                             ; int
    call    sub_4A1250
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    add     eax, 519h
    not     cl
    and     ecx, 1
    push    ecx                             ; char
    push    offset aCdstop                  ; char *
    push    eax                             ; int
    call    sub_4A1250
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F14h]
    add     eax, 519h
    not     dl
    and     edx, 1
    push    edx                             ; char
    push    offset aCdplay                  ; char *
    push    eax                             ; int
    call    sub_4A1250
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    add     eax, 519h
    not     cl
    and     ecx, 1
    push    ecx                             ; char
    push    offset aCdnext                  ; char *
    push    eax                             ; int
    call    sub_4A1250
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F14h]
    add     eax, 519h
    not     dl
    and     edx, 1
    push    edx                             ; char
    push    offset aTrackmode               ; char *
    push    eax                             ; int
    call    sub_4A1250
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37F14h], 1
    jz      short loc_45D25F
    cmp     byte ptr [eax+37F16h], 4
    jnz     short loc_45D25F
    xor     ecx, ecx
    add     eax, 519h
    push    ecx                             ; char
    push    offset aTracktype               ; char *
    push    eax                             ; int
    call    sub_4A1250
    retn
    ; ---------------------------------------------------------------------------

    loc_45D25F:                             ; CODE XREF: sub_45D130+110j
                                            ; sub_45D130+119j
    mov     ecx, 1
    add     eax, 519h
    push    ecx                             ; char
    push    offset aTracktype               ; char *
    push    eax                             ; int
    call    sub_4A1250
    retn
    sub_45D130 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45D280 proc near                    ; DATA XREF: sub_45D7C0+6Ao

    var_8= dword ptr -8
    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     ebp, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_45D2DB
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 4
    mov     ecx, [eax+10h]
    jnz     short loc_45D2C1
    call    sub_4CED40
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFFEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45D2C1:                             ; CODE XREF: sub_45D280+25j
    call    sub_4CDB40
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFFEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45D2DB:                             ; CODE XREF: sub_45D280+14j
    push    esi                             ; int
    call    sub_49FA90
    push    offset aNotrak                  ; "NOTRAK"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45D64B
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    offset aNotrak                  ; char *
    push    esi                             ; int
    call    sub_4A0F60
    mov     edi, TAdynmemStructPtr
    mov     cx, [edi+37F14h]
    mov     dl, cl
    xor     dl, al
    and     edx, 1
    xor     edx, ecx
    mov     [edi+37F14h], dx
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    and     ecx, 1
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4CEDC0
    push    esi
    call    sub_4AB0A0
    call    sub_45D130

    loc_45D34A:                             ; CODE XREF: sub_45D280+4E0j
    push    offset aCdplay                  ; "CDPLAY"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45D388
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     edx, dword_512FE0
    push    1
    push    edx
    mov     ecx, [eax+10h]
    call    sub_4CEB60
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45D388:                             ; CODE XREF: sub_45D280+D7j
    push    offset aCdnext                  ; "CDNEXT"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45D3DF
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     edi, dword_512FE0
    mov     ecx, TAdynmemStructPtr
    inc     edi
    mov     dword_512FE0, edi
    mov     ecx, [ecx+10h]
    call    sub_4CE450
    mov     ecx, dword_512FE0
    cmp     ecx, eax
    jle     short loc_45D3D3
    mov     ecx, 1
    mov     dword_512FE0, ecx

    loc_45D3D3:                             ; CODE XREF: sub_45D280+146j
    mov     edx, TAdynmemStructPtr
    push    ecx
    mov     ecx, [edx+10h]
    jmp     short loc_45D45B
    ; ---------------------------------------------------------------------------

    loc_45D3DF:                             ; CODE XREF: sub_45D280+115j
    push    offset aCdprev                  ; "CDPREV"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45D428
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     eax, dword_512FE0
    dec     eax
    cmp     eax, 1
    mov     dword_512FE0, eax
    jge     short loc_45D41C
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CE450
    mov     dword_512FE0, eax

    loc_45D41C:                             ; CODE XREF: sub_45D280+188j
    mov     ecx, TAdynmemStructPtr
    push    eax
    mov     ecx, [ecx+10h]
    jmp     short loc_45D45B
    ; ---------------------------------------------------------------------------

    loc_45D428:                             ; CODE XREF: sub_45D280+16Cj
    push    offset aCdstop                  ; "CDSTOP"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45D477
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CED40
    mov     eax, TAdynmemStructPtr
    push    1
    mov     ecx, [eax+10h]

    loc_45D45B:                             ; CODE XREF: sub_45D280+15Dj
                                            ; sub_45D280+1A6j
    call    sub_4CE8C0
    mov     dword_512FE0, eax
    call    sub_45C3F0
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45D477:                             ; CODE XREF: sub_45D280+1B5j
    push    offset aUndo                    ; "UNDO"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45D53C
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    mov     edx, dword_512F42
    push    offset byte_512F75
    mov     [ecx+37F10h], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CE3E0
    mov     ecx, TAdynmemStructPtr
    mov     dl, byte_512F48
    mov     [ecx+37F16h], dl
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [eax+37F16h]
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4CE7A0
    mov     edi, TAdynmemStructPtr
    mov     cl, byte_512F46
    mov     dl, [edi+37F14h]
    xor     dl, cl
    test    dl, 1
    jz      short loc_45D509
    mov     ecx, [edi+10h]
    call    sub_4CDB40
    mov     edi, TAdynmemStructPtr

    loc_45D509:                             ; CODE XREF: sub_45D280+279j
    mov     ax, [edi+37F14h]
    mov     dl, byte_512F46
    mov     cl, al
    xor     cl, dl
    and     ecx, 1
    xor     ecx, eax
    mov     [edi+37F14h], cx
    mov     eax, TAdynmemStructPtr
    mov     edx, dword_512FD9
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE580
    jmp     short loc_45D59F
    ; ---------------------------------------------------------------------------

    loc_45D53C:                             ; CODE XREF: sub_45D280+204j
    push    offset aRestore                 ; "RESTORE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45D602
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37F10h], 20h
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+37F16h], 4
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F14h]
    test    al, 1
    jnz     short loc_45D5A5
    or      al, 1
    mov     [ecx+37F14h], ax
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CDB40

    loc_45D59F:                             ; CODE XREF: sub_45D280+2BAj
    mov     ecx, TAdynmemStructPtr

    loc_45D5A5:                             ; CODE XREF: sub_45D280+306j
    fild    dword ptr [ecx+37F08h]
    push    ecx
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    [esp+8+var_8]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F0Ch]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+37F10h]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D00D0
    push    esi
    call    sub_4A9660
    call    sub_45D7C0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45D602:                             ; CODE XREF: sub_45D280+2C9j
    mov     edi, [esi+60h]
    cmp     edi, 0FFFFFFFFh
    jz      short loc_45D644
    lea     eax, ds:0[edi*8]
    add     ebp, edi
    sub     eax, edi
    lea     edx, [eax+eax*2]
    lea     eax, [edi+edx*2]
    lea     ecx, [edi+eax*4]
    cmp     byte ptr [ebp+ecx*2+0], 1
    jz      short loc_45D632
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45D632:                             ; CODE XREF: sub_45D280+3A3j
    mov     edx, [esi+18h]
    push    esi
    mov     ebx, [edx]
    call    sub_4A9660
    push    esi
    mov     [esi+60h], edi
    call    dword ptr [ebx+8]

    loc_45D644:                             ; CODE XREF: sub_45D280+388j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45D64B:                             ; CODE XREF: sub_45D280+6Ej
    push    offset aTrackmode               ; "TRACKMODE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45D753
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    offset aTrackmode               ; char *
    push    esi                             ; int
    call    sub_4A0F60
    mov     edx, TAdynmemStructPtr
    inc     al
    xor     ecx, ecx
    mov     [edx+37F16h], al
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F16h]
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4CE7A0
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+37F16h]
    cmp     al, 3
    jnz     short loc_45D6C8
    mov     ecx, [ecx+10h]
    call    sub_4CE5A0
    push    esi
    mov     dword_512FE0, eax
    call    sub_4AB0A0
    call    sub_45C3F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45D6C8:                             ; CODE XREF: sub_45D280+427j
    cmp     al, 4
    jnz     short loc_45D741
    mov     edx, dword_512FE0
    mov     ecx, [ecx+10h]
    push    edx
    call    sub_4CE7E0
    and     eax, 0FFh
    push    eax                             ; char
    push    offset aTracktype               ; char *
    push    esi                             ; int
    call    sub_4A1080
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    mov     edi, [ecx+4]
    mov     cl, [eax+37F16h]
    cmp     cl, 4
    jnz     short loc_45D741
    push    1
    push    offset aTracktype               ; char *
    push    edi                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, dword_512FE0
    mov     al, [edi+edx*2+137h]
    mov     edx, TAdynmemStructPtr
    push    eax
    push    ecx
    mov     ecx, [edx+10h]
    call    sub_4CE7C0

    loc_45D741:                             ; CODE XREF: sub_45D280+44Aj
                                            ; sub_45D280+483j
    push    esi
    call    sub_4AB0A0
    call    sub_45C3F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45D753:                             ; CODE XREF: sub_45D280+3D8j
    push    offset aTracktype               ; "TRACKTYPE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45D34A
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     eax, [esi+60h]
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     eax, dword_512FE0
    mov     dl, [ebp+ecx*2+137h]
    mov     ecx, TAdynmemStructPtr
    push    edx
    push    eax
    mov     ecx, [ecx+10h]
    call    sub_4CE7C0
    call    sub_45C3F0
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_45D280 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45D7C0 proc near                    ; CODE XREF: sub_45D280+376p
                                            ; .text:0045FD3Bp

    var_4= dword ptr -4

    push    ecx
    push    esi
    call    sub_45CFC0
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    2
    push    eax
    call    sub_4A81E0
    call    sub_45CE80
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EBEh], 1
    jz      short loc_45D805
    push    280h
    add     eax, 519h
    push    offset aMusicrt_gui             ; "MUSICRT.GUI"
    push    eax
    call    sub_4AA8F0
    jmp     short loc_45D82A
    ; ---------------------------------------------------------------------------

    loc_45D805:                             ; CODE XREF: sub_45D7C0+2Cj
    push    200h
    add     eax, 519h
    push    offset aMusic                   ; "MUSIC"
    push    eax
    call    sub_4AA8F0
    push    0
    push    0
    push    0
    push    offset aOptmusic4x              ; "optmusic4x"
    call    sub_4288D0

    loc_45D82A:                             ; CODE XREF: sub_45D7C0+43j
    mov     dword ptr [esi+8], offset sub_45D280
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA50
    mov     dword ptr [esi+1Ch], offset loc_45D0C0
    mov     edx, TAdynmemStructPtr
    push    1                               ; int
    add     edx, 519h
    push    offset aMusic                   ; char *
    push    edx                             ; int
    call    sub_4A1110
    mov     eax, [esi+4]
    push    0Eh
    push    offset aMusicvol_0              ; char *
    push    eax                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_45D916
    mov     ecx, [esi+4]
    push    offset aMusicvol_0              ; char *
    push    ecx                             ; int
    call    sub_4A0200
    mov     esi, eax
    mov     dword ptr [esi+13Ch], 40h
    mov     dword ptr [esi+144h], offset loc_45BEA0
    mov     edx, TAdynmemStructPtr
    mov     ax, [edx+37F10h]
    mov     [esi+140h], ax
    movsx   eax, ax
    cmp     eax, 40h
    mov     [esp+4], eax
    jle     short loc_45D8C8
    mov     dword ptr [esp+4], 40h

    loc_45D8C8:                             ; CODE XREF: sub_45D7C0+FEj
    movsx   eax, word ptr [esi+136h]
    fild    dword ptr [esp+4]
    dec     eax
    mov     [esp+4], eax
    fild    dword ptr [esp+4]
    fxch    st(1)
    fmulp   st(1), st
    fmul    ds:flt_4FD500
    fld     st
    call    __ftol
    mov     [esp+4], eax
    fild    dword ptr [esp+4]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45D90A
    fsub    ds:dbl_4FD4E8

    loc_45D90A:                             ; CODE XREF: sub_45D7C0+142j
    call    __ftol
    mov     [esi+140h], ax

    loc_45D916:                             ; CODE XREF: sub_45D7C0+B6j
    call    sub_45D130
    mov     eax, TAdynmemStructPtr
    cmp     byte ptr [eax+37F16h], 3
    jnz     short loc_45D936
    mov     ecx, [eax+10h]
    call    sub_4CE5A0
    mov     dword_512FE0, eax

    loc_45D936:                             ; CODE XREF: sub_45D7C0+167j
    call    sub_45C3F0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    mov     esi, [ecx+4]
    mov     cl, [eax+37F16h]
    cmp     cl, 4
    jnz     short loc_45D995
    push    1
    push    offset aTracktype               ; char *
    push    esi                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, dword_512FE0
    mov     al, [esi+edx*2+137h]
    mov     edx, TAdynmemStructPtr
    push    eax
    push    ecx
    mov     ecx, [edx+10h]
    call    sub_4CE7C0
    mov     eax, TAdynmemStructPtr

    loc_45D995:                             ; CODE XREF: sub_45D7C0+192j
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    call    sub_428B60
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     esi
    pop     ecx
    retn
    sub_45D7C0 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    add     eax, 519h
    and     ecx, 7
    push    ecx
    push    offset aMode                    ; "MODE"
    push    eax
    call    sub_4A1080
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F19h]
    and     dl, 7
    neg     dl
    sbb     edx, edx
    add     eax, 519h
    neg     edx
    push    edx
    push    offset aVoltext                 ; "VOLTEXT"
    push    eax
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    and     cl, 7
    neg     cl
    sbb     ecx, ecx
    add     eax, 519h
    inc     ecx
    push    ecx
    push    offset aFxvol_0                 ; "FXVOL"
    push    eax
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F19h]
    and     dl, 7
    neg     dl
    sbb     edx, edx
    add     eax, 519h
    inc     edx
    push    edx
    push    offset aTest                    ; "TEST"
    push    eax
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    and     cl, 7
    neg     cl
    sbb     ecx, ecx
    add     eax, 519h
    inc     ecx
    push    ecx
    push    offset aSpeech                  ; "SPEECH"
    push    eax
    call    sub_4A1450
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45DA90 proc near                    ; DATA XREF: sub_45DE30+6Ao

    var_8= dword ptr -8
    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_45DABB
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFFEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45DABB:                             ; CODE XREF: sub_45DA90+14j
    push    esi                             ; int
    call    sub_49FA90
    mov     ebx, [esi+60h]
    push    offset aSpeech                  ; "SPEECH"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45DCCA
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     eax, [esi+60h]
    mov     edx, TAdynmemStructPtr
    mov     ecx, eax
    mov     ebp, edi
    shl     ecx, 3
    sub     ecx, eax
    add     ebp, eax
    push    esi
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    xor     eax, eax
    cmp     [ebp+ecx*2+137h], al
    mov     cx, [edx+37F19h]
    setnz   al
    and     eax, 1
    and     ecx, 0FFBFh
    shl     eax, 6
    or      eax, ecx
    mov     [edx+37F19h], ax
    mov     eax, [esi+60h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, edi
    add     ecx, eax
    mov     al, [ecx+edx*2+137h]
    mov     dl, 5
    imul    dl
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F17h], al
    call    sub_4AB0A0

    loc_45DB5C:                             ; CODE XREF: sub_45DA90+247j
    push    offset aUndo                    ; "UNDO"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45DB75
    call    sub_45C820
    jmp     loc_45DC42
    ; ---------------------------------------------------------------------------

    loc_45DB75:                             ; CODE XREF: sub_45DA90+D9j
    push    offset aRestore                 ; "RESTORE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45DC60
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37F0Ch], 1Bh
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F19h], 10h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F19h], 20h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F19h], 40h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CFE90
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37F19h]
    and     ecx, 0FFF9h
    or      ecx, 1
    mov     [eax+37F19h], cx
    mov     edx, TAdynmemStructPtr
    push    ecx
    mov     byte ptr [edx+37F17h], 0Ah
    mov     eax, TAdynmemStructPtr
    fild    dword ptr [eax+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    [esp+8+var_8]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F0Ch]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     edx, [eax+37F10h]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D00D0

    loc_45DC42:                             ; CODE XREF: sub_45DA90+E0j
    push    esi
    call    sub_4A9660
    call    sub_45DE30
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45DC60:                             ; CODE XREF: sub_45DA90+F2j
    push    offset aTest                    ; "TEST"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45DC86
    push    offset aSoundsExplode_          ; "sounds\\explode.wav"
    call    sub_47F290
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45DC86:                             ; CODE XREF: sub_45DA90+1DDj
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_45DCC3
    mov     eax, ebx
    add     edi, ebx
    shl     eax, 3
    sub     eax, ebx
    lea     eax, [eax+eax*2]
    lea     ecx, [ebx+eax*2]
    lea     edx, [ebx+ecx*4]
    cmp     byte ptr [edi+edx*2], 1
    jz      short loc_45DCB1
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45DCB1:                             ; CODE XREF: sub_45DA90+212j
    mov     eax, [esi+18h]
    push    esi
    mov     edi, [eax]
    call    sub_4A9660
    push    esi
    mov     [esi+60h], ebx
    call    dword ptr [edi+8]

    loc_45DCC3:                             ; CODE XREF: sub_45DA90+1FAj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45DCCA:                             ; CODE XREF: sub_45DA90+41j
    push    offset aMode                    ; "MODE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45DB5C
    push    offset aMode                    ; char *
    push    esi                             ; int
    call    sub_4A0F60
    mov     edi, TAdynmemStructPtr
    mov     cx, [edi+37F19h]
    mov     dl, cl
    xor     dl, al
    and     edx, 7
    xor     edx, ecx
    mov     [edi+37F19h], dx
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37F19h], 7
    jnz     short loc_45DD1D
    call    sub_47F750
    mov     eax, TAdynmemStructPtr

    loc_45DD1D:                             ; CODE XREF: sub_45DA90+281j
    mov     cl, [eax+37F19h]
    and     cl, 7
    cmp     cl, 2
    mov     ecx, [eax+10h]
    jnz     short loc_45DD35
    call    sub_4CFE80
    jmp     short loc_45DD3A
    ; ---------------------------------------------------------------------------

    loc_45DD35:                             ; CODE XREF: sub_45DA90+29Cj
    call    sub_4CFE90

    loc_45DD3A:                             ; CODE XREF: sub_45DA90+2A3j
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F19h]
    and     dl, 7
    cmp     dl, 1
    jnz     short loc_45DD67
    test    byte ptr [eax+2A44h], 4
    jnz     short loc_45DD67
    push    0                               ; int
    push    offset off_5031D4               ; char *
    call    sub_47F210
    mov     eax, TAdynmemStructPtr

    loc_45DD67:                             ; CODE XREF: sub_45DA90+2BBj
                                            ; sub_45DA90+2C4j
    mov     cl, [eax+37F19h]
    add     eax, 519h
    and     ecx, 7
    push    ecx                             ; char
    push    offset aMode                    ; char *
    push    eax                             ; int
    call    sub_4A1080
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F19h]
    and     dl, 7
    neg     dl
    sbb     edx, edx
    add     eax, 519h
    neg     edx
    push    edx                             ; int
    push    offset aVoltext                 ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    and     cl, 7
    neg     cl
    sbb     ecx, ecx
    add     eax, 519h
    inc     ecx
    push    ecx
    push    offset aFxvol_0                 ; "FXVOL"
    push    eax
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F19h]
    and     dl, 7
    neg     dl
    sbb     edx, edx
    add     eax, 519h
    inc     edx
    push    edx
    push    offset aTest                    ; "TEST"
    push    eax
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    and     cl, 7
    neg     cl
    sbb     ecx, ecx
    add     eax, 519h
    inc     ecx
    push    ecx
    push    offset aSpeech                  ; "SPEECH"
    push    eax
    call    sub_4A1450
    push    esi
    call    sub_4AB0A0
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_45DA90 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45DE30 proc near                    ; CODE XREF: sub_45DA90+1B8p
                                            ; .text:0045FF45p

    var_4= dword ptr -4

    push    ecx
    push    ebp
    push    esi
    push    edi
    call    sub_45CFC0
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    2
    push    eax
    call    sub_4A81E0
    call    sub_45CE80
    mov     eax, TAdynmemStructPtr
    push    200h
    test    byte ptr [eax+37EBEh], 1
    jz      short loc_45DE77
    add     eax, 519h
    push    offset aSoundsrt_gui            ; "SOUNDSRT.GUI"
    push    eax
    call    sub_4AA8F0
    jmp     short loc_45DE97
    ; ---------------------------------------------------------------------------

    loc_45DE77:                             ; CODE XREF: sub_45DE30+33j
    add     eax, 519h
    push    offset aSounds_0                ; "SOUNDS"
    push    eax
    call    sub_4AA8F0
    push    0
    push    0
    push    0
    push    offset aOptsound4x              ; "optsound4x"
    call    sub_4288D0

    loc_45DE97:                             ; CODE XREF: sub_45DE30+45j
    mov     esi, [edi+4]
    mov     dword ptr [edi+8], offset sub_45DA90
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA50
    mov     edx, TAdynmemStructPtr
    push    1                               ; int
    add     edx, 519h
    push    offset aSound_0                 ; char *
    push    edx                             ; int
    call    sub_4A1110
    mov     eax, [edi+4]
    push    0Eh
    push    offset aFxvol_0                 ; char *
    push    eax                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_45DF7C
    push    offset aFxvol_0                 ; char *
    push    esi                             ; int
    call    sub_4A0200
    mov     esi, eax
    mov     dword ptr [esi+13Ch], 40h
    mov     dword ptr [esi+144h], offset loc_45BDE0
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F0Ch]
    mov     [esi+140h], ax
    movsx   eax, ax
    cmp     eax, 40h
    mov     [esp+0Ch], eax
    jle     short loc_45DF2E
    mov     dword ptr [esp+0Ch], 40h

    loc_45DF2E:                             ; CODE XREF: sub_45DE30+F4j
    movsx   edx, word ptr [esi+136h]
    fild    dword ptr [esp+0Ch]
    dec     edx
    mov     [esp+0Ch], edx
    fild    dword ptr [esp+0Ch]
    fxch    st(1)
    fmulp   st(1), st
    fmul    ds:flt_4FD500
    fld     st
    call    __ftol
    mov     [esp+0Ch], eax
    fild    dword ptr [esp+0Ch]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45DF70
    fsub    ds:dbl_4FD4E8

    loc_45DF70:                             ; CODE XREF: sub_45DE30+138j
    call    __ftol
    mov     [esi+140h], ax

    loc_45DF7C:                             ; CODE XREF: sub_45DE30+AFj
    mov     eax, [edi+4]
    mov     ebp, 1
    cmp     [eax+0B6h], bp
    jl      short loc_45DFC3
    mov     esi, 15Bh

    loc_45DF92:                             ; CODE XREF: sub_45DE30+191j
    cmp     byte ptr [esi+eax], 4
    jnz     short loc_45DFAE
    mov     ecx, TAdynmemStructPtr
    push    0
    add     ecx, 519h
    push    ecx
    call    dword ptr [esi+eax+144h]

    loc_45DFAE:                             ; CODE XREF: sub_45DE30+166j
    mov     eax, [edi+4]
    inc     ebp
    add     esi, 15Bh
    movsx   edx, word ptr [eax+0B6h]
    cmp     ebp, edx
    jle     short loc_45DF92

    loc_45DFC3:                             ; CODE XREF: sub_45DE30+15Bj
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+37F19h]
    shr     al, 6
    test    al, 1
    jz      short loc_45DFF0
    xor     edx, edx
    mov     eax, 66666667h
    mov     dl, [ecx+37F17h]
    imul    edx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    jmp     short loc_45DFF2
    ; ---------------------------------------------------------------------------

    loc_45DFF0:                             ; CODE XREF: sub_45DE30+1A4j
    xor     edx, edx

    loc_45DFF2:                             ; CODE XREF: sub_45DE30+1BEj
    push    edx                             ; char
    add     ecx, 519h
    push    offset aSpeech                  ; char *
    push    ecx                             ; int
    call    sub_4A1080
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    add     eax, 519h
    and     ecx, 7
    push    ecx                             ; char
    push    offset aMode                    ; char *
    push    eax                             ; int
    call    sub_4A1080
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F19h]
    and     dl, 7
    neg     dl
    sbb     edx, edx
    add     eax, 519h
    neg     edx
    push    edx                             ; int
    push    offset aVoltext                 ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    and     cl, 7
    neg     cl
    sbb     ecx, ecx
    add     eax, 519h
    inc     ecx
    push    ecx
    push    offset aFxvol_0                 ; "FXVOL"
    push    eax
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F19h]
    and     dl, 7
    neg     dl
    sbb     edx, edx
    add     eax, 519h
    inc     edx
    push    edx
    push    offset aTest                    ; "TEST"
    push    eax
    call    sub_4A1450
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F19h]
    and     cl, 7
    neg     cl
    sbb     ecx, ecx
    add     eax, 519h
    inc     ecx
    push    ecx
    push    offset aSpeech                  ; "SPEECH"
    push    eax
    call    sub_4A1450
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx                             ; int
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    call    sub_428B60
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ecx
    retn
    sub_45DE30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45E100 proc near                    ; DATA XREF: sub_45E5E0+ABo

    var_8= dword ptr -8
    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+60h]
    mov     ecx, [esi+18h]
    cmp     eax, 0FFFFFFFFh
    mov     ebp, eax
    mov     ebx, [ecx+4]
    mov     edi, [ecx+0Ch]
    jnz     short loc_45E16D
    test    edi, edi
    jz      short loc_45E158
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EBEh], 1
    jnz     short loc_45E145
    mov     ecx, [edi+14h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, [edi+4]
    add     esp, 4
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_45E145:                             ; CODE XREF: sub_45E100+2Bj
    push    edi                             ; int
    call    sub_4D85A0
    mov     eax, [esi+18h]
    add     esp, 4
    mov     dword ptr [eax+0Ch], 0

    loc_45E158:                             ; CODE XREF: sub_45E100+1Dj
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFFEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45E16D:                             ; CODE XREF: sub_45E100+19j
    push    offset aAnti                    ; "ANTI"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45E1CB
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    offset aAnti                    ; char *
    push    esi                             ; int
    call    sub_4A0F60
    mov     ecx, TAdynmemStructPtr
    and     eax, 1
    shl     eax, 1
    mov     dx, [ecx+37F06h]
    and     edx, 0FFFDh
    or      edx, eax
    mov     [ecx+37F06h], dx
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EBEh], 1
    jz      loc_45E2EA
    jmp     loc_45E2DF
    ; ---------------------------------------------------------------------------

    loc_45E1CB:                             ; CODE XREF: sub_45E100+7Aj
    push    offset aBshadows                ; "BSHADOWS"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45E289
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    offset aBshadows                ; char *
    push    esi                             ; int
    call    sub_4A0F60
    mov     ecx, TAdynmemStructPtr
    and     eax, 1
    shl     eax, 4
    mov     dx, [ecx+37F06h]
    and     edx, 0FFEFh
    or      edx, eax
    mov     [ecx+37F06h], dx
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    shr     al, 1
    and     edx, 0FFF7h
    and     eax, 8
    or      edx, eax
    mov     [ecx+37F06h], dx
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    shr     al, 1
    and     edx, 0FFFBh
    and     eax, 4
    or      edx, eax
    mov     [ecx+37F06h], dx
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EBEh], 1
    jz      short loc_45E2EA
    mov     ecx, [eax+1437Bh]
    call    sub_437C80
    push    esi                             ; int
    call    sub_49FA90
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45E289:                             ; CODE XREF: sub_45E100+D8j
    push    offset aShading_0               ; "SHADING"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45E2FD
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    offset aShading_0               ; char *
    push    esi                             ; int
    call    sub_4A0F60
    mov     ecx, TAdynmemStructPtr
    and     eax, 1
    shl     eax, 5
    mov     dx, [ecx+37F06h]
    and     edx, 0FFDFh
    or      edx, eax
    mov     [ecx+37F06h], dx
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EBEh], 1
    jz      short loc_45E2EA

    loc_45E2DF:                             ; CODE XREF: sub_45E100+C6j
    mov     ecx, [eax+1437Bh]
    call    sub_437C80

    loc_45E2EA:                             ; CODE XREF: sub_45E100+C0j
                                            ; sub_45E100+169j ...
    push    esi                             ; int
    call    sub_49FA90
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45E2FD:                             ; CODE XREF: sub_45E100+196j
    push    offset aUndo                    ; "UNDO"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45E331
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    call    sub_45CAE0
    push    esi
    call    sub_4A9660
    push    0
    call    sub_45E5E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45E331:                             ; CODE XREF: sub_45E100+20Aj
    push    offset aRestore                 ; "RESTORE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45E439
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     ecx, 4
    or      byte ptr [eax+37F06h], 2
    mov     eax, TAdynmemStructPtr
    or      [eax+37F06h], cx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F06h], 8
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F06h], 10h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37F06h], 20h
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37F08h], 0Ch
    mov     eax, TAdynmemStructPtr
    test    [eax+2A44h], cl
    jnz     short loc_45E3DA
    mov     dword ptr [eax+37F1Bh], 280h
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+37F1Fh], 1E0h
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F06h], 0FFBFh
    mov     eax, TAdynmemStructPtr

    loc_45E3DA:                             ; CODE XREF: sub_45E100+2ABj
    fild    dword ptr [eax+37F08h]
    push    ecx
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    [esp+8+var_8]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F0Ch]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+37F10h]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D00D0
    push    esi
    call    sub_4A9660
    push    0
    call    sub_45E5E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45E439:                             ; CODE XREF: sub_45E100+23Ej
    push    offset byte_502AE8
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45E46A
    push    offset aSelvmode_gui            ; char *
    push    esi                             ; int
    call    sub_4AB060
    test    eax, eax
    jz      short loc_45E46A
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45E46A:                             ; CODE XREF: sub_45E100+346j
                                            ; sub_45E100+355j
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_45E4AB
    lea     ecx, ds:0[eax*8]
    add     ebx, eax
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    cmp     byte ptr [ebx+edx*2], 1
    jz      short loc_45E499
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45E499:                             ; CODE XREF: sub_45E100+38Aj
    mov     eax, [esi+18h]
    push    esi
    mov     edi, [eax]
    call    sub_4A9660
    push    esi
    mov     [esi+60h], ebp
    call    dword ptr [edi+8]

    loc_45E4AB:                             ; CODE XREF: sub_45E100+370j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_45E100 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45E4C0 proc near                    ; CODE XREF: sub_446310+41p
                                            ; sub_45E5E0+FCp

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 14h
    mov     edx, [esp+14h+arg_0]
    push    ebx
    push    ebp
    xor     ebp, ebp
    mov     eax, [edx]
    push    esi
    cmp     eax, ebp
    push    edi
    mov     [esp+24h+var_10], ebp
    jle     loc_45E56B
    mov     [esp+24h+arg_0], ebp

    loc_45E4DF:                             ; CODE XREF: sub_45E4C0+A5j
    dec     eax
    cmp     eax, ebp
    jle     short loc_45E551
    lea     esi, [eax+eax*2]
    shl     esi, 2
    sub     eax, ebp
    mov     [esp+24h+var_14], eax

    loc_45E4F0:                             ; CODE XREF: sub_45E4C0+8Fj
    mov     ecx, [edx+4]
    mov     eax, [esp+24h+arg_0]
    add     eax, ecx
    add     ecx, esi
    mov     edi, [ecx]
    mov     ebx, [eax]
    cmp     edi, ebx
    jl      short loc_45E50F
    jnz     short loc_45E543
    mov     edi, [ecx+4]
    mov     ebx, [eax+4]
    cmp     edi, ebx
    jge     short loc_45E543

    loc_45E50F:                             ; CODE XREF: sub_45E4C0+41j
    mov     ebp, eax
    mov     edi, [ebp+0]
    mov     ebx, [ebp+4]
    mov     ebp, [ebp+8]
    mov     [esp+24h+var_4], ebp
    mov     ebp, [ecx]
    mov     [eax], ebp
    mov     ebp, [ecx+4]
    mov     [eax+4], ebp
    mov     ecx, [ecx+8]
    mov     [eax+8], ecx
    mov     eax, [edx+4]
    mov     ecx, [esp+24h+var_4]
    add     eax, esi
    mov     ebp, [esp+24h+var_10]
    mov     [eax], edi
    mov     [eax+4], ebx
    mov     [eax+8], ecx

    loc_45E543:                             ; CODE XREF: sub_45E4C0+43j
                                            ; sub_45E4C0+4Dj
    mov     eax, [esp+24h+var_14]
    sub     esi, 0Ch
    dec     eax
    mov     [esp+24h+var_14], eax
    jnz     short loc_45E4F0

    loc_45E551:                             ; CODE XREF: sub_45E4C0+22j
    mov     esi, [esp+24h+arg_0]
    mov     eax, [edx]
    inc     ebp
    add     esi, 0Ch
    cmp     ebp, eax
    mov     [esp+24h+var_10], ebp
    mov     [esp+24h+arg_0], esi
    jl      loc_45E4DF

    loc_45E56B:                             ; CODE XREF: sub_45E4C0+15j
    mov     ecx, [edx]
    xor     edi, edi
    test    ecx, ecx
    jle     short loc_45E5D5
    xor     eax, eax
    mov     [esp+24h+arg_0], eax

    loc_45E579:                             ; CODE XREF: sub_45E4C0+113j
    mov     esi, [edx+4]
    add     esi, eax
    cmp     dword ptr [esi], 280h
    jl      short loc_45E58F
    cmp     dword ptr [esi+4], 1E0h
    jge     short loc_45E5C7

    loc_45E58F:                             ; CODE XREF: sub_45E4C0+C4j
    dec     ecx
    cmp     edi, ecx
    jge     short loc_45E5BE
    mov     esi, edi

    loc_45E596:                             ; CODE XREF: sub_45E4C0+F8j
    mov     ecx, [edx+4]
    lea     ebx, [eax+ecx+0Ch]
    add     ecx, eax
    inc     esi
    add     eax, 0Ch
    mov     ebp, [ebx]
    mov     [ecx], ebp
    mov     ebp, [ebx+4]
    mov     [ecx+4], ebp
    mov     ebx, [ebx+8]
    mov     [ecx+8], ebx
    mov     ecx, [edx]
    dec     ecx
    cmp     esi, ecx
    jl      short loc_45E596
    mov     eax, [esp+24h+arg_0]

    loc_45E5BE:                             ; CODE XREF: sub_45E4C0+D2j
    mov     ecx, [edx]
    dec     edi
    sub     eax, 0Ch
    dec     ecx
    mov     [edx], ecx

    loc_45E5C7:                             ; CODE XREF: sub_45E4C0+CDj
    mov     ecx, [edx]
    inc     edi
    add     eax, 0Ch
    cmp     edi, ecx
    mov     [esp+24h+arg_0], eax
    jl      short loc_45E579

    loc_45E5D5:                             ; CODE XREF: sub_45E4C0+B1j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    4
    sub_45E4C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45E5E0 proc near                    ; CODE XREF: sub_45E100+225p
                                            ; sub_45E100+32Dp ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    sub     esp, 10h
    push    ebx
    push    ebp
    push    esi
    xor     esi, esi
    cmp     eax, esi
    push    edi
    jz      short loc_45E613
    mov     eax, TAdynmemStructPtr
    push    800h
    add     eax, 519h
    push    offset aSelvmode_gui_0          ; "SELVMODE.GUI"
    push    eax
    call    sub_4AA8F0
    mov     ebx, eax
    mov     [esp+20h+var_10], ebx
    jmp     short loc_45E679
    ; ---------------------------------------------------------------------------

    loc_45E613:                             ; CODE XREF: sub_45E5E0+Fj
    call    sub_45CFC0
    mov     ecx, TAdynmemStructPtr
    mov     ebx, eax
    add     ecx, 519h
    push    2
    push    ecx
    mov     [esp+28h+var_10], ebx
    call    sub_4A81E0
    call    sub_45CE80
    mov     eax, TAdynmemStructPtr
    push    200h
    test    byte ptr [eax+37EBEh], 1
    jz      short loc_45E65C
    add     eax, 519h
    push    offset aVisualrt_gui            ; "VISUALRT.GUI"
    push    eax
    call    sub_4AA8F0
    jmp     short loc_45E679
    ; ---------------------------------------------------------------------------

    loc_45E65C:                             ; CODE XREF: sub_45E5E0+68j
    add     eax, 519h
    push    offset aVisuals_gui             ; "VISUALS.GUI"
    push    eax
    call    sub_4AA8F0
    push    esi
    push    esi
    push    esi
    push    offset aOptvisual4x             ; "optvisual4x"
    call    sub_4288D0

    loc_45E679:                             ; CODE XREF: sub_45E5E0+31j
                                            ; sub_45E5E0+7Aj
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA50
    mov     dword ptr [ebx+8], offset sub_45E100
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EBEh], 1
    jnz     loc_45E825
    push    20h
    push    offset aSelectVideoMod          ; "SELECT VIDEO MODE"
    call    sub_4D83B0
    add     esp, 8
    mov     esi, eax
    mov     [ebx+0Ch], esi
    push    4B0h
    push    offset aDisplayModes            ; "DISPLAY MODES"
    call    sub_4D83B0
    add     esp, 8
    mov     [esi+4], eax
    push    esi
    call    sub_4B5370
    test    eax, eax
    jz      loc_45E934
    push    esi
    call    sub_45E4C0
    mov     ecx, [esi]
    shl     ecx, 8
    push    ecx
    push    offset aAvailableModes          ; "AVAILABLE MODES"
    call    sub_4D83B0
    add     esp, 8
    mov     [esi+14h], eax
    mov     byte ptr [eax], 0
    mov     edx, [ebx+4]
    push    0Eh
    push    offset aVidsldr                 ; char *
    push    edx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_45E934
    mov     eax, [ebx+4]
    push    offset aVidsldr                 ; char *
    push    eax                             ; int
    call    sub_4A0200
    mov     ecx, [esi]
    mov     edi, eax
    dec     ecx
    mov     [edi+13Ch], ecx
    mov     dword ptr [edi+144h], offset loc_45BBF0
    mov     [edi+14Ah], esi
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    lea     edx, [eax+519h]
    mov     [esp+24h+var_8], edx
    mov     edx, [esi]
    test    edx, edx
    jle     loc_45E939
    mov     ebp, [eax+37F1Bh]
    mov     esi, [esi+4]

    loc_45E760:                             ; CODE XREF: sub_45E5E0+199j
    cmp     ebp, [esi]
    jnz     short loc_45E773
    mov     ebx, [eax+37F1Fh]
    cmp     ebx, [esi+4]
    jz      short loc_45E780
    mov     ebx, [esp+10h]

    loc_45E773:                             ; CODE XREF: sub_45E5E0+182j
    inc     ecx
    add     esi, 0Ch
    cmp     ecx, edx
    jl      short loc_45E760
    jmp     loc_45E939
    ; ---------------------------------------------------------------------------

    loc_45E780:                             ; CODE XREF: sub_45E5E0+18Dj
    mov     eax, [edi+13Ch]
    mov     [esp+24h+var_10], ecx
    cmp     ecx, eax
    mov     [esp+24h+var_C], eax
    jle     short loc_45E796
    mov     [esp+24h+var_10], eax

    loc_45E796:                             ; CODE XREF: sub_45E5E0+1B0j
    fild    [esp+24h+var_10]
    fild    [esp+24h+var_C]
    movsx   eax, word ptr [edi+136h]
    fdivp   st(1), st
    dec     eax
    mov     [esp+24h+var_C], eax
    fimul   [esp+24h+var_C]
    fld     st
    call    __ftol
    mov     [esp+24h+var_C], eax
    fild    [esp+24h+var_C]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45E7D4
    fsub    ds:dbl_4FD4E8

    loc_45E7D4:                             ; CODE XREF: sub_45E5E0+1ECj
    call    __ftol
    mov     ecx, [esp+24h+var_8]
    mov     [edi+140h], ax
    push    offset aVidval                  ; char *
    mov     edx, [ecx+18h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_4A0180
    test    eax, eax
    jz      loc_45E930
    mov     ecx, [esi+4]
    mov     edx, [esi]
    push    ecx
    push    edx
    add     eax, 0B6h
    push    offset aDXD                     ; "%d X %d"
    push    eax
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    mov     ebx, [esp+20h]
    add     esp, 10h
    jmp     loc_45E939
    ; ---------------------------------------------------------------------------

    loc_45E825:                             ; CODE XREF: sub_45E5E0+BEj
    mov     [ebx+0Ch], esi
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EBEh], 1
    jz      loc_45E939
    mov     ecx, [eax+531h]
    xor     ebp, ebp
    mov     edx, [ecx+4]
    cmp     [edx+0B6h], si
    jl      short loc_45E8B3

    loc_45E84E:                             ; CODE XREF: sub_45E5E0+2D1j
    mov     edi, offset off_505CF4
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esi+edx+2]
    repne scasb
    not     ecx
    dec     ecx
    push    ecx                             ; size_t
    push    offset off_505CF4               ; char *
    push    edx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_45E893
    push    eax                             ; int
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    add     eax, 519h
    mov     edx, [ecx+4]
    lea     ecx, [edx+esi+2]
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4A0570

    loc_45E893:                             ; CODE XREF: sub_45E5E0+292j
    mov     eax, TAdynmemStructPtr
    inc     ebp
    add     esi, 15Bh
    mov     edx, [eax+531h]
    mov     edx, [edx+4]
    movsx   ecx, word ptr [edx+0B6h]
    cmp     ebp, ecx
    jle     short loc_45E84E

    loc_45E8B3:                             ; CODE XREF: sub_45E5E0+26Cj
    mov     edx, [eax+531h]
    xor     ebp, ebp
    mov     edx, [edx+4]
    cmp     [edx+0B6h], bp
    jl      short loc_45E939
    xor     esi, esi

    loc_45E8C9:                             ; CODE XREF: sub_45E5E0+34Cj
    mov     edi, offset off_506A4C
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esi+edx+2]
    push    ecx                             ; size_t
    push    offset off_506A4C               ; char *
    push    eax                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_45E90E
    push    eax                             ; int
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    add     eax, 519h
    mov     edx, [ecx+4]
    lea     ecx, [edx+esi+2]
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4A0570

    loc_45E90E:                             ; CODE XREF: sub_45E5E0+30Dj
    mov     eax, TAdynmemStructPtr
    inc     ebp
    add     esi, 15Bh
    mov     edx, [eax+531h]
    mov     edx, [edx+4]
    movsx   ecx, word ptr [edx+0B6h]
    cmp     ebp, ecx
    jle     short loc_45E8C9
    jmp     short loc_45E939
    ; ---------------------------------------------------------------------------

    loc_45E930:                             ; CODE XREF: sub_45E5E0+217j
    mov     ebx, [esp+10h]

    loc_45E934:                             ; CODE XREF: sub_45E5E0+F5j
                                            ; sub_45E5E0+12Dj
    mov     eax, TAdynmemStructPtr

    loc_45E939:                             ; CODE XREF: sub_45E5E0+171j
                                            ; sub_45E5E0+19Bj ...
    mov     ecx, [esp+24h]
    test    ecx, ecx
    jnz     loc_45EA9E
    push    1                               ; int
    add     eax, 519h
    push    offset aVisuals                 ; char *
    push    eax                             ; int
    call    sub_4A1110
    mov     edx, [ebx+4]
    push    1
    push    offset aAnti                    ; char *
    push    edx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_45E98B
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+37F06h]
    add     ecx, 519h
    shr     edx, 1
    and     edx, 1
    push    edx
    push    eax
    push    ecx
    call    sub_4A1030

    loc_45E98B:                             ; CODE XREF: sub_45E5E0+38Aj
    mov     eax, [ebx+4]
    push    1
    push    offset aBshadows                ; char *
    push    eax                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_45E9C0
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+37F06h]
    add     ecx, 519h
    shr     edx, 4
    and     edx, 1
    push    edx
    push    eax
    push    ecx
    call    sub_4A1030

    loc_45E9C0:                             ; CODE XREF: sub_45E5E0+3BEj
    mov     eax, [ebx+4]
    push    1
    push    offset aShading_0               ; char *
    push    eax                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_45E9F5
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+37F06h]
    add     ecx, 519h
    shr     edx, 5
    and     edx, 1
    push    edx
    push    eax
    push    ecx
    call    sub_4A1030

    loc_45E9F5:                             ; CODE XREF: sub_45E5E0+3F3j
    mov     eax, [ebx+4]
    push    0Eh
    push    offset aGamma_0                 ; char *
    push    eax                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_45EA99
    mov     ecx, [ebx+4]
    push    offset aGamma_0                 ; char *
    push    ecx                             ; int
    call    sub_4A0200
    mov     esi, eax
    mov     ecx, 14h
    mov     [esi+13Ch], ecx
    mov     dword ptr [esi+144h], offset loc_45BD20
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37F08h]
    cmp     eax, ecx
    mov     [esp+34h+var_10], eax
    jle     short loc_45EA4B
    mov     [esp+34h+var_10], ecx

    loc_45EA4B:                             ; CODE XREF: sub_45E5E0+465j
    movsx   eax, word ptr [esi+136h]
    fild    [esp+34h+var_10]
    dec     eax
    mov     [esp+34h+var_10], eax
    fild    [esp+34h+var_10]
    fxch    st(1)
    fmulp   st(1), st
    fmul    ds:flt_4FD504
    fld     st
    call    __ftol
    mov     [esp+34h+var_10], eax
    fild    [esp+34h+var_10]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45EA8D
    fsub    ds:dbl_4FD4E8

    loc_45EA8D:                             ; CODE XREF: sub_45E5E0+4A5j
    call    __ftol
    mov     [esi+140h], ax

    loc_45EA99:                             ; CODE XREF: sub_45E5E0+428j
    mov     eax, TAdynmemStructPtr

    loc_45EA9E:                             ; CODE XREF: sub_45E5E0+35Fj
    add     eax, 519h
    push    1
    push    eax
    call    sub_49FB10
    call    sub_428B60
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    4
    sub_45E5E0 endp ; sp = -14h

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45EAD0 proc near                    ; DATA XREF: sub_45ED50+69o

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     ebx, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_45EAF9
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFFEh
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45EAF9:                             ; CODE XREF: sub_45EAD0+13j
    mov     ecx, TAdynmemStructPtr
    push    offset aLeftclick               ; "LEFTCLICK"
    add     ecx, 519h
    push    ecx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45EB4F
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    push    offset aLeftclick               ; char *
    add     edx, 519h
    push    edx                             ; int
    call    sub_4A0F60
    mov     ecx, TAdynmemStructPtr
    push    esi
    mov     [ecx+37EFAh], eax
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45EB4F:                             ; CODE XREF: sub_45EAD0+42j
    mov     edx, TAdynmemStructPtr
    push    offset aUnitchat_0              ; "UNITCHAT"
    add     edx, 519h
    push    edx
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45EBA7
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    esi
    call    sub_4AB0A0
    mov     eax, TAdynmemStructPtr
    push    offset aUnitchat_0              ; char *
    add     eax, 519h
    push    eax                             ; int
    call    sub_4A0F60
    mov     cl, 5
    mov     edx, TAdynmemStructPtr
    imul    cl
    mov     [edx+37F18h], al
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45EBA7:                             ; CODE XREF: sub_45EAD0+98j
    push    offset aUndo                    ; "UNDO"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45EC65
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     ecx, dword_512F55
    push    esi
    mov     [eax+37F23h], ecx
    mov     eax, TAdynmemStructPtr
    mov     dx, word ptr dword_512F6D
    mov     [eax+38A4Bh], dx
    mov     ecx, TAdynmemStructPtr
    mov     dx, word ptr dword_512F6D
    mov     [ecx+38A4Dh], dx
    mov     eax, TAdynmemStructPtr
    mov     cl, byte ptr dword_512F71
    mov     [eax+1434Dh], cl
    mov     edx, TAdynmemStructPtr
    mov     eax, dword_512F2C
    mov     [edx+37EFAh], eax
    mov     ecx, TAdynmemStructPtr
    mov     dl, byte_512F49
    mov     [ecx+37F17h], dl
    mov     eax, TAdynmemStructPtr
    mov     cl, byte_512F4A
    mov     [eax+37F18h], cl
    mov     edx, TAdynmemStructPtr
    mov     eax, dword_512F59
    mov     [edx+37F27h], eax
    call    sub_4A9660
    call    sub_45ED50
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45EC65:                             ; CODE XREF: sub_45EAD0+E4j
    push    offset aRestore                 ; "RESTORE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45ED02
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    mov     eax, 0Ah
    push    esi
    mov     [ecx+37F23h], eax
    mov     edx, TAdynmemStructPtr
    mov     [edx+37F27h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38A4Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+38A4Dh], ax
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+1434Dh], 20h
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37EFAh], 0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F17h], al
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+37F18h], 5
    call    sub_4A9660
    call    sub_45ED50
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45ED02:                             ; CODE XREF: sub_45EAD0+1A2j
    mov     edi, [esi+60h]
    add     ebx, edi
    lea     eax, ds:0[edi*8]
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    lea     edx, [edi+ecx*4]
    cmp     byte ptr [ebx+edx*2], 1
    jz      short loc_45ED2B
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45ED2B:                             ; CODE XREF: sub_45EAD0+24Dj
    cmp     edi, 0FFFFFFFFh
    jz      short loc_45ED42
    mov     eax, [esi+18h]
    push    esi
    mov     ebx, [eax]
    call    sub_4A9660
    push    esi
    mov     [esi+60h], edi
    call    dword ptr [ebx+8]

    loc_45ED42:                             ; CODE XREF: sub_45EAD0+25Ej
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_45EAD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45ED50 proc near                    ; CODE XREF: sub_45EAD0+18Ap
                                            ; sub_45EAD0+227p ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h

    sub     esp, 18h
    push    ebp
    push    esi
    push    edi
    call    sub_45CFC0
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    2
    push    eax
    call    sub_4A81E0
    call    sub_45CE80
    mov     eax, TAdynmemStructPtr
    push    200h
    test    byte ptr [eax+37EBEh], 1
    jz      short loc_45ED99
    add     eax, 519h
    push    offset aSpeedsrt_gui            ; "SPEEDSRT.GUI"
    push    eax
    call    sub_4AA8F0
    jmp     short loc_45EDB9
    ; ---------------------------------------------------------------------------

    loc_45ED99:                             ; CODE XREF: sub_45ED50+35j
    add     eax, 519h
    push    offset aSpeeds_gui              ; "SPEEDS.GUI"
    push    eax
    call    sub_4AA8F0
    push    0
    push    0
    push    0
    push    offset aOptinterface4x          ; "optinterface4x"
    call    sub_4288D0

    loc_45EDB9:                             ; CODE XREF: sub_45ED50+47j
    mov     dword ptr [esi+8], offset sub_45EAD0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA50
    mov     edx, [esi+4]
    push    0Eh
    push    offset aGame                    ; char *
    push    edx                             ; int
    call    sub_49FDF0
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    push    1                               ; int
    add     eax, 519h
    push    offset aSpeeds                  ; char *
    push    eax                             ; int
    call    sub_4A1110
    cmp     edi, 0FFFFFFFFh
    jz      loc_45EE92
    mov     ecx, [esi+4]
    push    offset aGame                    ; char *
    push    ecx                             ; int
    call    sub_4A0200
    mov     edi, eax
    mov     ecx, 15h
    xor     eax, eax
    mov     [edi+13Ch], ecx
    mov     dword ptr [edi+144h], offset loc_45C070
    mov     edx, TAdynmemStructPtr
    mov     ax, [edx+38A4Bh]
    cmp     eax, ecx
    mov     [esp+0Ch], eax
    jle     short loc_45EE44
    mov     [esp+0Ch], ecx

    loc_45EE44:                             ; CODE XREF: sub_45ED50+EEj
    movsx   eax, word ptr [edi+136h]
    fild    dword ptr [esp+0Ch]
    dec     eax
    mov     [esp+0Ch], eax
    fild    dword ptr [esp+0Ch]
    fxch    st(1)
    fmulp   st(1), st
    fmul    ds:flt_4FD508
    fld     st
    call    __ftol
    mov     [esp+0Ch], eax
    fild    dword ptr [esp+0Ch]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45EE86
    fsub    ds:dbl_4FD4E8

    loc_45EE86:                             ; CODE XREF: sub_45ED50+12Ej
    call    __ftol
    mov     [edi+140h], ax

    loc_45EE92:                             ; CODE XREF: sub_45ED50+AEj
    mov     ecx, [esi+4]
    push    0Eh
    push    offset aScreen                  ; char *
    push    ecx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_45EF38
    mov     edx, [esi+4]
    push    offset aScreen                  ; char *
    push    edx                             ; int
    call    sub_4A0200
    mov     edi, eax
    mov     ecx, 41h
    xor     eax, eax
    mov     [edi+13Ch], ecx
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+1434Dh]
    cmp     eax, ecx
    mov     [esp+0Ch], eax
    jle     short loc_45EEE0
    mov     [esp+0Ch], ecx

    loc_45EEE0:                             ; CODE XREF: sub_45ED50+18Aj
    movsx   eax, word ptr [edi+136h]
    fild    dword ptr [esp+0Ch]
    dec     eax
    mov     [esp+0Ch], eax
    fild    dword ptr [esp+0Ch]
    fxch    st(1)
    fmulp   st(1), st
    fmul    ds:flt_4FD50C
    fld     st
    call    __ftol
    mov     [esp+0Ch], eax
    fild    dword ptr [esp+0Ch]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45EF22
    fsub    ds:dbl_4FD4E8

    loc_45EF22:                             ; CODE XREF: sub_45ED50+1CAj
    call    __ftol
    mov     [edi+140h], ax
    mov     dword ptr [edi+144h], offset sub_45C170

    loc_45EF38:                             ; CODE XREF: sub_45ED50+155j
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     eax, 66666667h
    mov     dl, [ecx+37F18h]
    add     ecx, 519h
    imul    edx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    push    edx                             ; char
    push    offset aUnitchat_0              ; char *
    push    ecx                             ; int
    call    sub_4A1080
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EFAh]
    add     eax, 519h
    push    ecx                             ; char
    push    offset aLeftclick               ; char *
    push    eax                             ; int
    call    sub_4A1080
    mov     edx, TAdynmemStructPtr
    mov     ecx, offset aD_0                ; "%d"
    mov     eax, [edx+37F27h]
    test    eax, eax
    jnz     short loc_45EF9E
    mov     ecx, offset aNone               ; "None"

    loc_45EF9E:                             ; CODE XREF: sub_45ED50+247j
    push    eax
    lea     eax, [esp+14h]
    push    ecx
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+10h]
    add     edx, 519h
    push    0
    push    ecx
    push    offset aMaxlinestext            ; "MAXLINESTEXT"
    push    edx
    call    sub_4A0BF0
    mov     eax, [esi+4]
    push    4
    push    offset aMaxlines                ; char *
    push    eax                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_45F06F
    mov     ecx, [esi+4]
    push    offset aMaxlines                ; char *
    push    ecx                             ; int
    call    sub_4A0200
    mov     edi, eax
    mov     ecx, 1Eh
    mov     [edi+13Ch], ecx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37F27h]
    cmp     eax, ecx
    mov     [esp+0Ch], eax
    jle     short loc_45F017
    mov     [esp+0Ch], ecx

    loc_45F017:                             ; CODE XREF: sub_45ED50+2C1j
    movsx   eax, word ptr [edi+136h]
    fild    dword ptr [esp+0Ch]
    dec     eax
    mov     [esp+0Ch], eax
    fild    dword ptr [esp+0Ch]
    fxch    st(1)
    fmulp   st(1), st
    fmul    ds:flt_4FD510
    fld     st
    call    __ftol
    mov     [esp+0Ch], eax
    fild    dword ptr [esp+0Ch]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45F059
    fsub    ds:dbl_4FD4E8

    loc_45F059:                             ; CODE XREF: sub_45ED50+301j
    call    __ftol
    mov     [edi+140h], ax
    mov     dword ptr [edi+144h], offset sub_45C220

    loc_45F06F:                             ; CODE XREF: sub_45ED50+28Ej
    mov     ecx, [esi+4]
    push    0Eh
    push    offset aTxtscrol                ; char *
    push    ecx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_45F112
    mov     edx, [esi+4]
    push    offset aTxtscrol                ; char *
    push    edx                             ; int
    call    sub_4A0200
    mov     edi, eax
    mov     ecx, 14h
    mov     [edi+13Ch], ecx
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+37F23h]
    cmp     eax, ecx
    mov     [esp+0Ch], eax
    jle     short loc_45F0BA
    mov     [esp+0Ch], ecx

    loc_45F0BA:                             ; CODE XREF: sub_45ED50+364j
    movsx   ecx, word ptr [edi+136h]
    fild    dword ptr [esp+0Ch]
    dec     ecx
    mov     [esp+0Ch], ecx
    fild    dword ptr [esp+0Ch]
    fxch    st(1)
    fmulp   st(1), st
    fmul    ds:flt_4FD504
    fld     st
    call    __ftol
    mov     [esp+0Ch], eax
    fild    dword ptr [esp+0Ch]
    fsubr   st, st(1)
    fcomp   ds:flt_4FD4E0
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_45F0FC
    fsub    ds:dbl_4FD4E8

    loc_45F0FC:                             ; CODE XREF: sub_45ED50+3A4j
    call    __ftol
    mov     [edi+140h], ax
    mov     dword ptr [edi+144h], offset sub_45C330

    loc_45F112:                             ; CODE XREF: sub_45ED50+332j
    mov     eax, [esi+4]
    mov     ebp, 1
    cmp     [eax+0B6h], bp
    jl      short loc_45F159
    mov     edi, 15Bh

    loc_45F128:                             ; CODE XREF: sub_45ED50+407j
    cmp     byte ptr [edi+eax], 4
    jnz     short loc_45F144
    mov     edx, TAdynmemStructPtr
    push    0
    add     edx, 519h
    push    edx
    call    dword ptr [edi+eax+144h]

    loc_45F144:                             ; CODE XREF: sub_45ED50+3DCj
    mov     eax, [esi+4]
    inc     ebp
    add     edi, 15Bh
    movsx   ecx, word ptr [eax+0B6h]
    cmp     ebp, ecx
    jle     short loc_45F128

    loc_45F159:                             ; CODE XREF: sub_45ED50+3D1j
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    call    sub_428B60
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 18h
    retn
    sub_45ED50 endp

    ; ---------------------------------------------------------------------------
    align 8

    loc_45F190:                             ; DATA XREF: sub_45F1D0+38o
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_45F1C0
    push    offset byte_502AE8
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45F1BA
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45F1BA:                             ; CODE XREF: .text:0045F1A8j
    push    esi
    call    sub_4AB0A0

    loc_45F1C0:                             ; CODE XREF: .text:0045F199j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45F1D0 proc near                    ; CODE XREF: sub_4609B0+2ADp

    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= byte ptr -40h

    sub     esp, 8Ch
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    1881h
    add     eax, 519h
    push    offset aGameoptions_gu          ; "GAMEOPTIONS.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    push    0
    push    0
    push    0
    mov     ecx, [esi+4]
    push    offset aGamesettings            ; "GameSettings"
    mov     [esp+0ACh+var_8C], ecx
    mov     dword ptr [esi+8], offset loc_45F190
    call    sub_4288D0
    mov     edx, [esi+4]
    movsx   eax, word ptr [edx+0B6h]
    mov     [esp+9Ch+var_88], eax
    call    sub_456850
    and     eax, 0FFh
    push    2                               ; int
    mov     ecx, eax
    push    6Eh                             ; int
    shl     eax, 5
    add     eax, ecx
    push    5Ah                             ; __int16
    push    12h                             ; int
    push    offset aCommanderDeath          ; int
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    mov     edi, eax
    mov     [esp+0B0h+var_64], offset aGameContinues ; "Game Continues"
    add     edi, ecx
    xor     ecx, ecx
    mov     cl, [eax+2A42h]
    mov     [esp+0B0h+var_60], offset aGameEnds ; "Game Ends"
    mov     ebx, [edi+edx*2+1B8Ah]
    mov     edx, [eax+29A0h]
    lea     ecx, [ecx+ecx*2]
    mov     eax, offset aAllowed            ; "Allowed"
    mov     [esp+0B0h+var_5C], offset aDeathmatch_0 ; "Deathmatch"
    mov     [esp+0B0h+var_84], offset aRandom ; "Random"
    lea     ebp, [edx+ecx*8]
    mov     ecx, offset aDisallowed         ; "Disallowed"
    mov     [esp+0B0h+var_80], offset aFixed ; "Fixed"
    mov     [esp+0B0h+var_74], offset aMapped ; "Mapped"
    mov     [esp+0B0h+var_70], offset aUnmapped ; "Unmapped"
    mov     [esp+0B0h+var_4C], offset aTrue ; "True"
    mov     [esp+0B0h+var_48], offset aCircular ; "Circular"
    mov     [esp+0B0h+var_44], offset aPermanent ; "Permanent"
    mov     [esp+0B0h+var_7C], ecx
    mov     [esp+0B0h+var_78], eax
    mov     [esp+0B0h+var_6C], ecx
    mov     [esp+0B0h+var_68], eax
    mov     [esp+0B0h+var_58], offset aEasy ; "Easy"
    mov     [esp+0B0h+var_54], offset aMedium ; "Medium"
    mov     [esp+0B0h+var_50], offset aHard ; "Hard"
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     eax, TAdynmemStructPtr
    push    2                               ; int
    push    78h                             ; int
    push    5Ah                             ; __int16
    mov     ecx, [eax+37EF6h]
    push    8Ch                             ; int
    mov     edx, [esp+ecx*4+0ACh+var_64]
    push    edx                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    push    2                               ; int
    push    6Eh                             ; int
    push    6Ch                             ; __int16
    push    12h                             ; int
    push    offset aStartingLocati          ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    push    2                               ; int
    push    78h                             ; int
    cmp     eax, 2
    push    6Ch                             ; __int16
    push    8Ch                             ; int
    jnz     short loc_45F37D
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     eax, [edx+118h]
    mov     ecx, [esp+eax*4+0ACh+var_84]
    push    ecx
    jmp     short loc_45F38F
    ; ---------------------------------------------------------------------------

    loc_45F37D:                             ; CODE XREF: sub_45F1D0+192j
    mov     dx, [ebx+9Bh]
    shr     edx, 0Eh
    and     edx, 1
    mov     eax, [esp+edx*4+0ACh+var_84]
    push    eax                             ; int

    loc_45F38F:                             ; CODE XREF: sub_45F1D0+1ABj
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    push    2                               ; int
    push    6Eh                             ; int
    push    7Eh                             ; __int16
    push    12h                             ; int
    push    offset aMappingMode             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     ecx, TAdynmemStructPtr
    push    2                               ; int
    push    78h                             ; int
    push    7Eh                             ; __int16
    mov     dl, [ecx+14281h]
    push    8Ch                             ; int
    and     edx, 1
    mov     eax, [esp+edx*4+0ACh+var_74]
    push    eax                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    push    2                               ; int
    push    6Eh                             ; int
    push    90h                             ; __int16
    push    12h                             ; int
    push    offset aLineOfSight             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+14281h]
    test    al, 2
    jnz     short loc_45F427
    mov     eax, 2
    jmp     short loc_45F42F
    ; ---------------------------------------------------------------------------

    loc_45F427:                             ; CODE XREF: sub_45F1D0+24Ej
    not     al
    shr     eax, 2
    and     eax, 1

    loc_45F42F:                             ; CODE XREF: sub_45F1D0+255j
    mov     edx, [esp+eax*4+9Ch+var_4C]
    push    2                               ; int
    push    78h                             ; int
    push    90h                             ; __int16
    push    8Ch                             ; int
    push    edx                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    push    2                               ; int
    push    6Eh                             ; int
    cmp     eax, 3
    push    0A2h                            ; __int16
    push    12h                             ; int
    jnz     loc_45F516
    push    offset aCheatCodes              ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     cx, [ebx+9Bh]
    push    2                               ; int
    shr     ecx, 0Dh
    and     ecx, 1
    push    78h                             ; int
    push    0A2h                            ; __int16
    push    8Ch                             ; int
    mov     edx, [esp+ecx*4+0ACh+var_7C]
    push    edx                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    push    2                               ; int
    push    6Eh                             ; int
    push    0B4h                            ; __int16
    push    12h                             ; int
    push    offset aWatching_1              ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     al, [ebx+9Bh]
    push    2                               ; int
    shr     eax, 7
    and     eax, 1
    push    78h                             ; int
    push    0B4h                            ; __int16
    push    8Ch                             ; int
    mov     ecx, [esp+eax*4+0ACh+var_6C]
    push    ecx                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     edi, 0C6h
    jmp     short loc_45F561                ; int
    ; ---------------------------------------------------------------------------

    loc_45F516:                             ; CODE XREF: sub_45F1D0+2A1j
    push    offset aDifficulty_0            ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     edx, TAdynmemStructPtr
    push    2                               ; int
    push    78h                             ; int
    push    0A2h                            ; __int16
    mov     eax, [edx+37EEEh]
    push    8Ch                             ; int
    mov     ecx, [esp+eax*4+0ACh+var_58]
    push    ecx                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     edi, 0B4h

    loc_45F561:                             ; CODE XREF: sub_45F1D0+344j
    push    2                               ; int
    push    6Eh                             ; int
    push    edi                             ; __int16
    push    12h                             ; int
    push    offset aMap_0                   ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     edx, TAdynmemStructPtr
    push    2                               ; int
    push    78h                             ; int
    push    edi                             ; __int16
    mov     ecx, [edx+391E9h]
    push    8Ch                             ; int
    call    sub_435C30
    push    eax                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    add     edi, 12h
    push    2                               ; int
    push    6Eh                             ; int
    push    edi                             ; __int16
    push    12h                             ; int
    push    offset aStartingMetal           ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    push    2                               ; int
    push    78h                             ; int
    push    edi                             ; __int16
    cmp     eax, 3
    push    8Ch                             ; int
    push    0Ah                             ; int
    jnz     short loc_45F606
    xor     eax, eax
    lea     ecx, [esp+0B0h+var_40]
    mov     ax, [ebx+0A3h]
    push    ecx
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax*4]
    shl     edx, 2
    push    edx
    jmp     short loc_45F60F
    ; ---------------------------------------------------------------------------

    loc_45F606:                             ; CODE XREF: sub_45F1D0+41Aj
    mov     ecx, [ebp+0Ch]
    lea     eax, [esp+0B0h+var_40]
    push    eax                             ; char *
    push    ecx                             ; int

    loc_45F60F:                             ; CODE XREF: sub_45F1D0+434j
    call    __itoa
    add     esp, 0Ch
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    add     edi, 12h
    push    2                               ; int
    push    6Eh                             ; int
    push    edi                             ; __int16
    push    12h                             ; int
    push    offset aStartingEnergy          ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    push    2                               ; int
    push    78h                             ; int
    push    edi                             ; __int16
    cmp     eax, 3
    push    8Ch                             ; int
    push    0Ah                             ; int
    jnz     short loc_45F67F
    lea     eax, [esp+0B0h+var_40]
    push    eax
    xor     eax, eax
    mov     ax, [ebx+0A1h]
    lea     eax, [eax+eax*4]
    lea     ecx, [eax+eax*4]
    shl     ecx, 2
    push    ecx
    jmp     short loc_45F688
    ; ---------------------------------------------------------------------------

    loc_45F67F:                             ; CODE XREF: sub_45F1D0+493j
    mov     eax, [ebp+10h]
    lea     edx, [esp+0B0h+var_40]
    push    edx                             ; char *
    push    eax                             ; int

    loc_45F688:                             ; CODE XREF: sub_45F1D0+4ADj
    call    __itoa
    add     esp, 0Ch
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    add     edi, 12h
    push    2                               ; int
    push    6Eh                             ; int
    push    edi                             ; __int16
    push    12h                             ; int
    push    offset aMaxUnits                ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     eax, TAdynmemStructPtr
    push    2                               ; int
    push    78h                             ; int
    push    edi                             ; __int16
    xor     edx, edx
    push    8Ch                             ; int
    mov     dx, [eax+37EE6h]
    lea     ecx, [esp+0ACh+var_40]
    push    0Ah                             ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    esi                             ; int
    call    sub_4AB1B0
    mov     edx, [esi+4]
    mov     ecx, [esp+9Ch+var_88]
    lea     eax, [ecx+1]
    movsx   ecx, word ptr [edx+0B6h]
    cmp     eax, ecx
    jg      short loc_45F736
    lea     edx, [eax+eax*4]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    mov     ecx, [esp+9Ch+var_8C]
    add     ecx, eax
    lea     edx, [eax+edx*4]
    lea     ecx, [ecx+edx*2+1Bh]

    loc_45F71B:                             ; CODE XREF: sub_45F1D0+564j
    mov     dword ptr [ecx], 1
    mov     edx, [esi+4]
    inc     eax
    add     ecx, 15Bh
    movsx   edx, word ptr [edx+0B6h]
    cmp     eax, edx
    jle     short loc_45F71B

    loc_45F736:                             ; CODE XREF: sub_45F1D0+533j
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8Ch
    retn
    sub_45F1D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_45F770:                             ; DATA XREF: .text:0045F823o
                                            ; sub_4609B0+215o
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_45F78F
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AFCF0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45F78F:                             ; CODE XREF: .text:0045F779j
    push    offset byte_502AE8
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45F7AE
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45F7AE:                             ; CODE XREF: .text:0045F79Cj
    push    offset aTextregion              ; "TextRegion"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_45F7CC
    push    offset aMorebar                 ; "MOREBAR"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45F7E9

    loc_45F7CC:                             ; CODE XREF: .text:0045F7BBj
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    call    sub_476EF0
    push    esi
    call    sub_49FA90
    push    esi
    call    sub_4AB0A0

    loc_45F7E9:                             ; CODE XREF: .text:0045F7CAj
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_45F7F5
    push    esi
    call    sub_4AB0A0

    loc_45F7F5:                             ; CODE XREF: .text:0045F7EDj
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    esi
    push    0
    add     eax, 519h
    push    offset aBriefing_gui            ; "BRIEFING.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, [eax+4]
    push    0Eh
    push    offset aMorebar                 ; "MOREBAR"
    push    esi
    mov     dword ptr [eax+8], offset loc_45F770
    call    sub_49FDF0
    mov     ecx, eax
    push    0Eh
    shl     ecx, 3
    sub     ecx, eax
    push    offset aTextregion              ; "TextRegion"
    push    esi
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    lea     eax, [edx+ecx*2+1Bh]
    mov     ecx, [edx+ecx*2+1Bh]
    and     ecx, 0FFFFFFEFh
    mov     [eax], ecx
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    push    0
    push    0
    push    0
    lea     ecx, [ecx+ecx*2]
    push    offset aIgmbrief                ; "igmbrief"
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     eax, [esi+ecx*2+1Bh]
    mov     ecx, [esi+ecx*2+1Bh]
    and     ecx, 0FFFFFFEFh
    mov     [eax], ecx
    call    sub_4288D0
    mov     edx, TAdynmemStructPtr
    push    0Fh
    add     edx, 519h
    push    edx
    call    sub_4AFC60
    call    sub_476D80
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45F8C0 proc near                    ; CODE XREF: .text:0045FB14p
                                            ; .text:0045FB83p ...

    var_1A4= byte ptr -1A4h
    var_1A2= byte ptr -1A2h
    var_1A1= byte ptr -1A1h
    var_1A0= dword ptr -1A0h
    var_19C= dword ptr -19Ch
    var_198= dword ptr -198h
    var_194= dword ptr -194h
    var_18C= byte ptr -18Ch
    var_180= byte ptr -180h
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    sub     esp, 1A4h
    mov     dx, word ptr dword_512EF0
    push    ebx
    push    ebp
    mov     ebp, [eax+18h]
    mov     ecx, [ebp+4]
    mov     [ecx+0B6h], dx
    lea     ecx, [esp+1ACh+var_198]
    call    sub_4C2EA0
    push    offset off_50341C
    push    offset aHelp                    ; "help"
    lea     eax, [esp+1B4h+var_100]
    push    offset aGamedata                ; "gamedata"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+1ACh+var_100]
    push    ecx
    lea     ecx, [esp+1B0h+var_198]
    call    sub_4C2F60
    test    eax, eax
    jz      loc_45FA97
    push    offset aHelp_0                  ; char *
    lea     ecx, [esp+1B0h+var_198]
    mov     ebx, 32h
    call    sub_4C3410
    test    eax, eax
    jz      loc_45FA97
    mov     eax, [esp+1ACh+arg_4]
    mov     ecx, [esp+1ACh+arg_8]
    imul    eax, ecx
    push    edi
    push    esi
    lea     esi, [eax+ecx]
    mov     dl, 20h
    mov     edi, eax
    cmp     eax, esi
    mov     [esp+1B4h+var_1A4], dl
    mov     byte ptr [esp+11h], 0
    mov     [esp+1B4h+var_1A2], dl
    mov     [esp+1B4h+var_1A1], 0
    mov     [esp+1B4h+var_1A0], edi
    mov     [esp+1B4h+var_19C], esi
    jge     loc_45FA95

    loc_45F975:                             ; CODE XREF: sub_45F8C0+1CFj
    push    edi
    lea     edx, [esp+1B8h+var_18C]
    push    offset aLineD_0                 ; LPCSTR
    push    edx                             ; LPSTR
    call    ds:wsprintfA
    add     esp, 0Ch
    lea     eax, [esp+1B4h+var_18C]
    lea     ecx, [esp+1B4h+var_180]
    push    offset Data                     ; int
    push    80h                             ; size_t
    push    eax                             ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+1C4h+var_194]
    call    sub_4C48C0
    test    eax, eax
    jz      loc_45FA88
    cmp     [esp+1B4h+var_180], 7Ch
    jnz     short loc_45F9E0
    lea     edi, [esp+1B4h+var_1A4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+1B4h+var_180]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+1B4h+var_1A0]
    jmp     short loc_45F9F0
    ; ---------------------------------------------------------------------------

    loc_45F9E0:                             ; CODE XREF: sub_45F8C0+F3j
    lea     eax, [esp+35h]

    loc_45F9E4:                             ; CODE XREF: sub_45F8C0+12Aj
    mov     cl, [eax]
    inc     eax
    cmp     cl, 7Ch
    jnz     short loc_45F9E4
    mov     byte ptr [eax-1], 0

    loc_45F9F0:                             ; CODE XREF: sub_45F8C0+11Ej
    push    2                               ; int
    push    4Eh                             ; int
    push    ebx                             ; __int16
    push    28h                             ; int
    lea     edx, [esp+1C4h+var_180]
    push    0
    push    edx
    call    sub_4B6AF0
    push    eax                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    ebp                             ; int
    call    sub_4AB1B0
    mov     edx, [ebp+4]
    mov     esi, 1
    push    2                               ; int
    push    12Ch                            ; int
    movsx   eax, word ptr [edx+0B6h]
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 3
    sub     ecx, eax
    push    ebx                             ; __int16
    push    7Dh                             ; int
    push    esi
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    mov     [edx+ecx*2+1Bh], esi
    lea     edx, [esp+1C8h+var_180]
    push    edx
    call    sub_4B6AF0
    push    eax                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    ebp                             ; int
    call    sub_4AB1B0
    mov     edx, [ebp+4]
    movsx   eax, word ptr [edx+0B6h]
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 3
    sub     ecx, eax
    add     ebx, 12h
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    mov     [edx+ecx*2+1Bh], esi
    mov     esi, [esp+1B4h+var_19C]

    loc_45FA88:                             ; CODE XREF: sub_45F8C0+E8j
    inc     edi
    cmp     edi, esi
    mov     [esp+1B4h+var_1A0], edi
    jl      loc_45F975

    loc_45FA95:                             ; CODE XREF: sub_45F8C0+AFj
    pop     esi
    pop     edi

    loc_45FA97:                             ; CODE XREF: sub_45F8C0+58j
                                            ; sub_45F8C0+73j
    mov     edx, [esp+1ACh+arg_0]
    push    edx                             ; int
    call    sub_49FA90
    lea     ecx, [esp+1ACh+var_198]
    call    sub_4C2EB0
    pop     ebp
    pop     ebx
    add     esp, 1A4h
    retn    0Ch
    sub_45F8C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_45FAC0:                             ; DATA XREF: .text:0045FB58o
                                            ; sub_4609B0+15Eo
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_45FB1F
    push    offset byte_502AE8
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45FAEA
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45FAEA:                             ; CODE XREF: .text:0045FAD8j
    push    offset aPage                    ; "Page"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45FB19
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    push    11h
    push    offset aPage                    ; "Page"
    push    esi
    call    sub_4A0F60
    push    eax
    push    esi
    call    sub_45F8C0

    loc_45FB19:                             ; CODE XREF: .text:0045FAF7j
    push    esi
    call    sub_4AB0A0

    loc_45FB1F:                             ; CODE XREF: .text:0045FAC9j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    esi
    push    1881h
    add     eax, 519h
    push    offset aHelp_gui                ; "HELP.GUI"
    push    eax
    call    sub_4AA8F0
    push    0
    mov     esi, eax
    push    0
    push    0
    push    offset aDhelp                   ; "dhelp"
    mov     dword ptr [esi+8], offset loc_45FAC0
    call    sub_4288D0
    mov     ecx, [esi+4]
    mov     eax, TAdynmemStructPtr
    push    11h
    add     eax, 519h
    movsx   edx, word ptr [ecx+0B6h]
    push    0
    push    eax
    mov     dword_512EF0, edx
    call    sub_45F8C0
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 430h
    mov     ecx, 100h
    xor     eax, eax
    push    edi
    lea     edi, [esp+34h]
    push    100h
    push    eax
    rep stosd
    lea     eax, [esp+3Ch]
    push    eax
    call    sub_4BA200
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37E1Bh]
    push    edx
    call    sub_4C69A0
    lea     eax, [esp+4]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      short loc_45FC2C
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    lea     eax, [esp+4]
    mov     cl, [edx+0DCBh]
    push    ecx
    push    eax
    call    sub_4C6890
    lea     ecx, [esp+4]
    push    ecx
    call    sub_4C5FA0
    call    sub_4C63A0

    loc_45FC2C:                             ; CODE XREF: .text:0045FC02j
    pop     edi
    add     esp, 430h
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFFEh
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2BC0h], 3
    retn
    ; ---------------------------------------------------------------------------
    align 8

    loc_45FC60:                             ; DATA XREF: sub_460160+E9o
    push    esi
    mov     esi, [esp+8]
    push    edi
    xor     edi, edi
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      loc_45FF50
    push    1
    push    eax
    push    esi
    call    sub_4A11C0
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2A44h]
    shr     cl, 2
    test    cl, 1
    jnz     short loc_45FCD8
    add     eax, 519h
    push    40h
    push    eax
    call    sub_4A81E0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    push    edi
    add     eax, 519h
    push    edi
    push    eax
    call    sub_4AB170
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37E1Bh]
    push    edx
    call    sub_4C69A0
    call    sub_4C63A0

    loc_45FCD8:                             ; CODE XREF: .text:0045FC8Ej
    push    offset aSpeeds                  ; "SPEEDS"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45FCFC
    push    edi
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    call    sub_45ED50
    jmp     loc_45FF4A
    ; ---------------------------------------------------------------------------

    loc_45FCFC:                             ; CODE XREF: .text:0045FCE5j
    push    offset aVisuals                 ; "VISUALS"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45FD21
    push    edi
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    push    edi
    call    sub_45E5E0
    jmp     loc_45FF4A
    ; ---------------------------------------------------------------------------

    loc_45FD21:                             ; CODE XREF: .text:0045FD09j
    push    offset aMusic                   ; "MUSIC"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45FD45
    push    edi
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    call    sub_45D7C0
    jmp     loc_45FF4A
    ; ---------------------------------------------------------------------------

    loc_45FD45:                             ; CODE XREF: .text:0045FD2Ej
    push    offset aPrev                    ; "PREV"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45FD73
    push    edi
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    call    WriteRegistrySettings_2
    mov     dword_506788, 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45FD73:                             ; CODE XREF: .text:0045FD52j
    push    offset aCancel_0                ; "CANCEL"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_45FF2B
    push    edi
    push    offset aPrevious                ; "Previous"
    call    sub_47F1A0
    call    sub_45C820
    mov     eax, TAdynmemStructPtr
    mov     ecx, dword_512F42
    push    offset byte_512F75
    mov     [eax+37F10h], ecx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CE3E0
    mov     eax, TAdynmemStructPtr
    mov     cl, byte_512F48
    xor     edx, edx
    mov     [eax+37F16h], cl
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+37F16h]
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE7A0
    mov     esi, TAdynmemStructPtr
    mov     dl, byte_512F46
    mov     al, [esi+37F14h]
    xor     al, dl
    test    al, 1
    jz      short loc_45FE07
    mov     ecx, [esi+10h]
    call    sub_4CDB40
    mov     esi, TAdynmemStructPtr

    loc_45FE07:                             ; CODE XREF: .text:0045FDF7j
    mov     ax, [esi+37F14h]
    mov     dl, byte_512F46
    mov     cl, al
    xor     cl, dl
    and     ecx, 1
    xor     ecx, eax
    mov     [esi+37F14h], cx
    mov     eax, TAdynmemStructPtr
    mov     edx, dword_512FD9
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE580
    mov     ecx, TAdynmemStructPtr
    push    ecx
    fild    dword ptr [ecx+37F08h]
    fmul    ds:flt_4FD4F0
    fsubr   ds:dbl_4FD4F8
    fstp    dword ptr [esp]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F0Ch]
    mov     ecx, [eax+10h]
    shl     edx, 0Ah
    push    edx
    call    sub_4D0070
    mov     eax, TAdynmemStructPtr
    push    edi
    mov     ecx, [eax+37F10h]
    shl     ecx, 0Ah
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4D00D0
    mov     edx, TAdynmemStructPtr
    mov     eax, dword_512F55
    mov     [edx+37F23h], eax
    mov     edx, TAdynmemStructPtr
    mov     cx, word ptr dword_512F6D
    mov     [edx+38A4Bh], cx
    mov     eax, TAdynmemStructPtr
    mov     cx, word ptr dword_512F6D
    mov     [eax+38A4Dh], cx
    mov     edx, TAdynmemStructPtr
    mov     al, byte ptr dword_512F71
    mov     [edx+1434Dh], al
    mov     ecx, TAdynmemStructPtr
    mov     edx, dword_512F2C
    mov     [ecx+37EFAh], edx
    mov     eax, TAdynmemStructPtr
    mov     cl, byte_512F49
    mov     [eax+37F17h], cl
    mov     edx, TAdynmemStructPtr
    mov     al, byte_512F4A
    mov     [edx+37F18h], al
    mov     ecx, TAdynmemStructPtr
    mov     edx, dword_512F59
    mov     [ecx+37F27h], edx
    call    sub_45CAE0
    mov     dword_506788, 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45FF2B:                             ; CODE XREF: .text:0045FD80j
    push    offset aSound_0                 ; "SOUND"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_45FF93
    push    edi
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    call    sub_45DE30

    loc_45FF4A:                             ; CODE XREF: .text:0045FCF7j
                                            ; .text:0045FD1Cj ...
    mov     dword_506788, edi

    loc_45FF50:                             ; CODE XREF: .text:0045FC6Ej
    mov     eax, dword_512FF4
    cmp     eax, edi
    jz      short loc_45FF73
    push    edi
    push    edi
    push    eax
    push    edi
    call    sub_4C6B70
    mov     eax, dword_512FF4
    push    eax
    call    sub_4C6AC0
    mov     dword_512FF4, edi

    loc_45FF73:                             ; CODE XREF: .text:0045FF57j
    mov     eax, dword_512FE8
    cmp     eax, edi
    jz      short loc_45FF88
    push    eax
    call    sub_4C6AC0
    mov     dword_512FE8, edi

    loc_45FF88:                             ; CODE XREF: .text:0045FF7Aj
    mov     dword_512FE4, edi
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_45FF93:                             ; CODE XREF: .text:0045FF38j
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_45FF9F
    push    esi
    call    sub_4AB0A0

    loc_45FF9F:                             ; CODE XREF: .text:0045FF97j
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_45FFB0 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+16D2p

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     eax, dword_512FE4
    sub     esp, 40h
    test    eax, eax
    jz      loc_460158
    mov     eax, dword_512FEC
    push    esi
    cmp     eax, 115h
    jge     short loc_46003C
    mov     esi, eax
    add     eax, 15h
    cmp     eax, 115h
    mov     dword_512FEC, eax
    jl      short loc_45FFF4
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     eax, 115h
    mov     dword_512FEC, eax

    loc_45FFF4:                             ; CODE XREF: sub_45FFB0+2Cj
    mov     ecx, dword_512F14
    cmp     eax, ecx
    jle     short loc_460044
    cmp     esi, ecx
    jge     short loc_460042
    mov     eax, TAdynmemStructPtr
    push    offset aLightbar                ; char *
    mov     ecx, [eax+51Dh]
    push    ecx                             ; int
    call    sub_4B8D40
    push    2
    push    eax
    call    sub_4B7F30
    movsx   edx, word ptr [eax+6]
    movsx   ecx, word ptr [eax+4]
    push    edx
    mov     edx, dword_512FE8
    push    ecx
    push    eax
    push    edx
    call    sub_4B7F90
    mov     eax, dword_512FEC

    loc_46003C:                             ; CODE XREF: sub_45FFB0+1Bj
    mov     ecx, dword_512F14

    loc_460042:                             ; CODE XREF: sub_45FFB0+50j
    cmp     eax, ecx

    loc_460044:                             ; CODE XREF: sub_45FFB0+4Cj
    mov     edx, dword_512FF0
    jge     short loc_460057
    add     edx, 6
    mov     dword_512FF0, edx
    jmp     short loc_46006C
    ; ---------------------------------------------------------------------------

    loc_460057:                             ; CODE XREF: sub_45FFB0+9Aj
    sub     edx, 6
    mov     dword_512FF0, edx
    jns     short loc_46006C
    mov     dword_512FF0, 0

    loc_46006C:                             ; CODE XREF: sub_45FFB0+A5j
                                            ; sub_45FFB0+B0j
    mov     esi, 1
    cmp     eax, ecx
    mov     [esp+44h+var_20], esi
    mov     [esp+44h+var_1C], esi
    mov     [esp+44h+var_8], esi
    mov     [esp+44h+var_14], esi
    jle     short loc_4600B5
    cmp     eax, 115h
    jge     short loc_460092
    inc     eax
    mov     dword_512FEC, eax

    loc_460092:                             ; CODE XREF: sub_45FFB0+DAj
    mov     [esp+44h+var_38], eax
    mov     [esp+44h+var_30], eax
    mov     eax, dword_512F10
    mov     [esp+44h+var_28], ecx
    mov     [esp+44h+var_40], ecx
    mov     ecx, dword_512FF0
    mov     [esp+44h+var_3C], eax
    sub     eax, ecx
    jmp     short loc_4600DD
    ; ---------------------------------------------------------------------------

    loc_4600B5:                             ; CODE XREF: sub_45FFB0+D3j
    mov     edx, dword_512FF0
    mov     [esp+44h+var_28], eax
    mov     [esp+44h+var_40], eax
    mov     eax, 7Fh
    mov     [esp+44h+var_38], eax
    mov     [esp+44h+var_30], eax
    mov     eax, dword_512F10
    mov     ecx, eax
    sub     ecx, edx
    mov     [esp+44h+var_3C], ecx

    loc_4600DD:                             ; CODE XREF: sub_45FFB0+103j
    mov     edx, dword_512EF8
    mov     [esp+44h+var_34], eax
    mov     eax, 1DFh
    and     edx, 0FFFFh
    mov     [esp+44h+var_2C], eax
    mov     [esp+44h+var_24], eax
    lea     eax, [edx-1]
    mov     edx, [esp+44h+arg_0]
    mov     [esp+44h+var_18], eax
    mov     [esp+44h+var_10], eax
    xor     eax, eax
    lea     ecx, [esp+44h+var_40]
    mov     ax, word ptr dword_512EF8+2
    dec     eax
    mov     [esp+44h+var_C], eax
    mov     [esp+44h+var_4], eax
    lea     eax, [esp+44h+var_20]
    push    eax
    push    ecx
    push    offset dword_512EF8
    push    edx
    call    sub_4C7580
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 2
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E98h], esi
    pop     esi

    loc_460158:                             ; CODE XREF: sub_45FFB0+Aj
    add     esp, 40h
    retn    4
    sub_45FFB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_460160 proc near                    ; CODE XREF: sub_4441A0+2ADp
                                            ; sub_4609B0+10Dp ...
    mov     eax, TAdynmemStructPtr
    push    ebp
    push    esi
    push    edi
    mov     cl, [eax+2A44h]
    mov     ebp, [eax+531h]
    test    cl, 4
    jnz     short loc_46017E
    call    sub_4257A0

    loc_46017E:                             ; CODE XREF: sub_460160+17j
    mov     eax, [ebp+4]
    movsx   ecx, word ptr [eax+19h]
    movsx   edx, word ptr [eax+17h]
    push    ecx                             ; int
    push    edx                             ; int
    push    offset aFlipsurface             ; int
    call    sub_4C69F0
    mov     dword_512FE8, eax
    mov     edx, [ebp+4]
    mov     edi, [eax+0Ch]
    movsx   ecx, word ptr [edx+17h]
    movsx   esi, word ptr [edx+19h]
    imul    ecx, esi
    mov     edx, [edx+0BCh]
    mov     eax, ecx
    shr     ecx, 2
    mov     esi, [edx+0Ch]
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, dword_512FE8
    push    ecx
    push    offset dword_512EF8
    call    sub_4B8AE0
    xor     edi, edi
    push    1E0h                            ; int
    mov     dword_512FEC, edi
    mov     edx, [ebp+4]
    push    12Ch                            ; int
    push    offset aBkupsurface             ; int
    movsx   eax, word ptr [edx+17h]
    dec     eax
    mov     dword_512F14, eax
    mov     ecx, [ebp+4]
    movsx   edx, word ptr [ecx+15h]
    mov     dword_512F10, edx
    mov     dword_512FE4, 1
    call    sub_4C69F0
    push    edi
    push    edi
    push    edi
    push    eax
    mov     dword_512FF4, eax
    call    sub_4C6B70
    mov     dword_512FF0, edi
    call    sub_45CFC0
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 4
    jnz     short loc_460249
    push    edi
    push    edi
    push    edi
    push    offset aOptions4x               ; "options4x"
    call    sub_4288D0

    loc_460249:                             ; CODE XREF: sub_460160+DAj
    mov     dword ptr [esi+8], offset loc_45FC60
    mov     eax, TAdynmemStructPtr
    mov     ecx, 14h
    mov     edi, offset dword_512F18
    lea     esi, [eax+37EE6h]
    rep movsd
    movsw
    movsb
    mov     dl, [eax+14281h]
    mov     cx, word_512F6B
    shr     dl, 1
    and     ecx, 0FFFEh
    and     edx, 1
    or      ecx, edx
    mov     word_512F6B, cx
    mov     dl, [eax+14281h]
    shr     dl, 1
    and     ecx, 0FFFDh
    and     edx, 2
    or      ecx, edx
    xor     edx, edx
    mov     word_512F6B, cx
    xor     ecx, ecx
    mov     cx, [eax+38A4Bh]
    mov     dword_512F6D, ecx
    mov     dl, [eax+1434Dh]
    mov     dword_512F71, edx
    mov     ecx, [eax+10h]
    call    sub_4CE5A0
    mov     dword_512FD9, eax
    xor     esi, esi

    loc_4602D1:                             ; CODE XREF: sub_460160+189j
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+10h]
    call    sub_4CE7E0
    mov     byte_512F75[esi], al
    inc     esi
    cmp     esi, 64h
    jl      short loc_4602D1
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    0C0h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2A44h]
    shr     cl, 2
    test    cl, 1
    jz      short loc_460335
    push    0                               ; int
    push    offset aPanel                   ; char *
    call    sub_47F1A0

    loc_460335:                             ; CODE XREF: sub_460160+1C7j
    pop     edi
    pop     esi
    pop     ebp
    retn
    sub_460160 endp

    ; ---------------------------------------------------------------------------
    align 8

    loc_460340:                             ; DATA XREF: sub_4604A0+2Bo
    push    esi
    push    edi
    mov     edi, [esp+0Ch]
    or      esi, 0FFFFFFFFh
    cmp     [edi+60h], esi
    jz      loc_460498
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    push    offset aRestart                 ; "RESTART"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      loc_460458
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    mov     ecx, [eax+391E9h]
    call    sub_435100
    dec     eax
    jz      short loc_4603D9
    dec     eax
    jnz     loc_460424
    push    1
    call    sub_41D6A0
    test    al, al
    jnz     loc_46041F
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_1          ; "Please insert the Multiplayer CD (Disc "...
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4603D9:                             ; CODE XREF: .text:00460384j
    push    0
    call    sub_41D6A0
    test    al, al
    jnz     short loc_46041F
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_0          ; "Please insert the Campaign CD (Disc 2) "...
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46041F:                             ; CODE XREF: .text:00460396j
                                            ; .text:004603E2j
    mov     esi, 1

    loc_460424:                             ; CODE XREF: .text:00460387j
    test    esi, esi
    jz      short loc_460498
    call    sub_41D4C0
    push    offset aDifficulty              ; "Difficulty"
    push    edi
    call    sub_4A0F60
    mov     edx, TAdynmemStructPtr
    mov     [edx+37EEEh], eax
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+39249h], 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460458:                             ; CODE XREF: .text:0046036Bj
    push    offset aDifficulty              ; "Difficulty"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_46047E
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    push    edi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46047E:                             ; CODE XREF: .text:00460465j
    push    offset aCancel_0                ; "CANCEL"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_460498
    cmp     [edi+60h], esi
    jz      short loc_460498
    push    edi
    call    sub_4AB0A0

    loc_460498:                             ; CODE XREF: .text:0046034Cj
                                            ; .text:00460426j ...
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4604A0 proc near                    ; CODE XREF: sub_460800+8Fp
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    push    1000h
    lea     esi, [eax+519h]
    push    offset aRestart_gui             ; "RESTART.GUI"
    push    esi
    call    sub_4AA8F0
    mov     edi, [eax+4]
    push    0
    push    0
    push    0
    push    offset aDrestart                ; "drestart"
    mov     dword ptr [eax+8], offset loc_460340
    call    sub_4288D0
    push    5
    push    offset aMissionname_0           ; char *
    push    edi                             ; int
    call    sub_49FDF0
    mov     ecx, [esi+0Ch]
    add     edi, eax
    mov     [esi+14h], ecx
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    push    0FFFFFFFFh
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, TAdynmemStructPtr
    movsx   eax, word ptr [edi+edx*2+17h]
    mov     ecx, [ecx+391E9h]
    push    eax
    call    sub_435C30
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4AC4C0
    mov     ecx, [esi+8]
    push    offset byte_50319C              ; char *
    push    eax                             ; char *
    mov     [esi+14h], ecx
    call    _strtok
    mov     edx, TAdynmemStructPtr
    add     esp, 8
    add     edx, 519h
    push    80h
    push    eax
    push    offset aMissionname_0           ; "MISSIONNAME"
    push    edx
    call    sub_4A0BF0
    push    offset byte_50319C              ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    test    eax, eax
    jz      short loc_460587
    push    80h
    push    eax
    mov     eax, TAdynmemStructPtr
    push    offset aMissionname1            ; "MISSIONNAME1"
    add     eax, 519h
    push    eax
    call    sub_4A0BF0

    loc_460587:                             ; CODE XREF: sub_4604A0+CAj
    call    sub_477410
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    push    13h
    call    sub_491C80
    pop     edi
    pop     esi
    retn
    sub_4604A0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 4

    loc_4605C0:                             ; DATA XREF: sub_460680+152o
    push    esi
    mov     esi, [esp+8]
    push    edi
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      loc_460676
    push    0
    push    offset aExit_1                  ; "Exit"
    call    sub_47F1A0
    mov     ecx, [esi+60h]
    push    offset aChoice1                 ; "CHOICE1"
    push    ecx
    push    edi
    call    sub_4A0300
    test    eax, eax
    jz      short loc_46065D
    mov     edx, TAdynmemStructPtr
    push    4
    mov     ecx, [edx+10h]
    call    sub_4CE690
    mov     eax, dword_512FF8
    test    eax, eax
    jl      short loc_460676
    cmp     eax, 1
    jle     short loc_460630
    cmp     eax, 2
    jnz     short loc_460676
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 4
    call    sub_491C60
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460630:                             ; CODE XREF: .text:00460613j
    call    sub_491B60
    push    1
    call    sub_491D70
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A9660
    call    sub_4257A0
    push    1
    call    sub_490B30
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46065D:                             ; CODE XREF: .text:004605F5j
    mov     ecx, [esi+60h]
    push    offset aChoice2                 ; "CHOICE2"
    push    ecx
    push    edi
    call    sub_4A0300
    test    eax, eax
    jnz     short loc_460676
    push    esi
    call    sub_4AB0A0

    loc_460676:                             ; CODE XREF: .text:004605D2j
                                            ; .text:0046060Ej ...
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_460680 proc near                    ; CODE XREF: sub_460800+3Ap
                                            ; sub_460800+62p ...
    mov     eax, TAdynmemStructPtr
    push    ebp
    push    1000h
    add     eax, 519h
    push    offset aYesorno_gui             ; "YESORNO.GUI"
    push    eax
    call    sub_4AA8F0
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_4607F0
    mov     ecx, TAdynmemStructPtr
    push    edi
    push    esi
    push    ebx
    add     ecx, 519h
    push    1
    push    ecx
    call    sub_49FB10
    mov     ebx, [ebp+4]
    push    1
    push    offset aChoice1                 ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    push    1
    push    offset aChoice2                 ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     edi, offset aChoice2            ; "CHOICE2"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebx+0CCh]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [ebx+0DCh]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    push    offset aYes                     ; "Yes"
    rep movsb
    mov     edi, offset aChoice2            ; "CHOICE2"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    push    offset aChoice1                 ; "CHOICE1"
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A0BF0
    mov     edx, TAdynmemStructPtr
    push    0
    push    offset aNo                      ; "No"
    add     edx, 519h
    push    offset aChoice2                 ; "CHOICE2"
    push    edx
    call    sub_4A0BF0
    mov     eax, dword_512FF8
    test    eax, eax
    jnz     short loc_460786
    push    eax
    mov     eax, TAdynmemStructPtr
    push    offset aSurrenderThisB          ; "Surrender this battle and return to mai"...
    add     eax, 519h
    push    offset aTitle                   ; "TITLE"
    push    eax
    jmp     short loc_4607B8
    ; ---------------------------------------------------------------------------

    loc_460786:                             ; CODE XREF: sub_460680+ECj
    cmp     eax, 2
    jnz     short loc_4607BD
    mov     ecx, TAdynmemStructPtr
    mov     eax, offset aExitTheBattle      ; "Exit the Battle"
    mov     dl, [ecx+2BEEh]
    shr     dl, 4
    test    dl, 1
    jnz     short loc_4607A9
    mov     eax, offset aSurrenderThi_0     ; "Surrender this battle and exit to Windo"...

    loc_4607A9:                             ; CODE XREF: sub_460680+122j
    push    0
    push    eax
    add     ecx, 519h
    push    offset aTitle                   ; "TITLE"
    push    ecx

    loc_4607B8:                             ; CODE XREF: sub_460680+104j
    call    sub_4A0BF0

    loc_4607BD:                             ; CODE XREF: sub_460680+109j
    mov     eax, TAdynmemStructPtr
    push    offset aChoice2                 ; "CHOICE2"
    add     eax, 519h
    push    eax
    call    sub_4A76B0
    mov     dword ptr [ebp+8], offset loc_4605C0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    40h
    push    ecx
    call    sub_4A81E0
    pop     ebx
    pop     esi
    pop     edi

    loc_4607F0:                             ; CODE XREF: sub_460680+1Fj
    pop     ebp
    retn
    sub_460680 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_460800 proc near                    ; DATA XREF: sub_4608B0+25o

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      loc_4608A4
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    offset aMainmenu_0              ; "MAINMENU"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_460843
    push    esi
    mov     dword_512FF8, 0
    call    sub_4A9660
    call    sub_460680
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460843:                             ; CODE XREF: sub_460800+28j
    push    offset aExitgame                ; "EXITGAME"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_46086B
    push    esi
    mov     dword_512FF8, 2
    call    sub_4A9660
    call    sub_460680
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46086B:                             ; CODE XREF: sub_460800+50j
    push    offset aCancel_0                ; "CANCEL"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_4608A4
    push    offset aRestart                 ; "RESTART"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_460898
    push    esi
    call    sub_4A9660
    call    sub_4604A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460898:                             ; CODE XREF: sub_460800+87j
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_4608A4
    push    esi
    call    sub_4AB0A0

    loc_4608A4:                             ; CODE XREF: sub_460800+9j
                                            ; sub_460800+78j ...
    pop     esi
    retn    4
    sub_460800 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4608B0 proc near                    ; CODE XREF: sub_4609B0+2D1p
    mov     eax, TAdynmemStructPtr
    push    1800h
    add     eax, 519h
    push    offset aExitmenu_gui            ; "EXITMENU.GUI"
    push    eax
    call    sub_4AA8F0
    mov     ecx, [eax+4]
    push    1
    push    offset aRestart                 ; char *
    push    ecx                             ; int
    mov     dword ptr [eax+8], offset sub_460800
    call    sub_49FDF0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 1
    jz      short loc_46090D
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 2
    jnz     short loc_46094D

    loc_46090D:                             ; CODE XREF: sub_4608B0+45j
    mov     eax, TAdynmemStructPtr
    push    1                               ; int
    add     eax, 519h
    push    offset aRestart                 ; char *
    push    eax                             ; int
    call    sub_4A0570
    push    80h
    push    offset aRestart_0               ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    offset aRestart                 ; "RESTART"
    push    ecx
    call    sub_4A0BF0
    jmp     short loc_460972
    ; ---------------------------------------------------------------------------

    loc_46094D:                             ; CODE XREF: sub_4608B0+5Bj
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+2BEEh]
    shr     dl, 4
    test    dl, 1
    jz      short loc_460972
    push    0                               ; int
    add     eax, 519h
    push    offset aMainmenu_0              ; char *
    push    eax                             ; int
    call    sub_4A0570

    loc_460972:                             ; CODE XREF: sub_4608B0+9Bj
                                            ; sub_4608B0+AEj
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    retn
    sub_4608B0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4609A0 proc near                    ; DATA XREF: sub_490B30+CAo
                                            ; sub_497F40+500o
    mov     dword_512FF8, 2
    jmp     sub_460680
    sub_4609A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4609B0 proc near                    ; DATA XREF: sub_460CC0+1Do

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     loc_460A5A
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA70
    mov     eax, dword_512FE8
    mov     dword_512FE4, 0
    test    eax, eax
    jz      short loc_4609F2
    push    eax
    call    sub_4C6AC0
    mov     dword_512FE8, 0

    loc_4609F2:                             ; CODE XREF: sub_4609B0+30j
    mov     eax, dword_512FF4
    test    eax, eax
    jz      short loc_460A0B
    push    eax
    call    sub_4C6AC0
    mov     dword_512FF4, 0

    loc_460A0B:                             ; CODE XREF: sub_4609B0+49j
    mov     eax, TAdynmemStructPtr
    mov     esi, 0FFFEh
    test    byte ptr [eax+2A44h], 4
    jz      short loc_460A3F
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    mov     eax, TAdynmemStructPtr
    jz      short loc_460A3F
    and     [eax+38A51h], si
    mov     eax, TAdynmemStructPtr

    loc_460A3F:                             ; CODE XREF: sub_4609B0+6Cj
                                            ; sub_4609B0+81j
    and     [eax+37EBEh], si
    mov     ecx, TAdynmemStructPtr
    push    0
    mov     ecx, [ecx+10h]
    call    sub_4CE910
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460A5A:                             ; CODE XREF: sub_4609B0+9j
    push    offset aLoadgame_0              ; "LOADGAME"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_460A7E
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    call    sub_4931D0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460A7E:                             ; CODE XREF: sub_4609B0+B7j
    push    offset aSavegame_1              ; "SAVEGAME"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_460AA2
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    call    sub_493060
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460AA2:                             ; CODE XREF: sub_4609B0+DBj
    push    offset aPrefs                   ; "PREFS"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_460AC6
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    call    sub_460160
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460AC6:                             ; CODE XREF: sub_4609B0+FFj
    push    offset aHelp_1                  ; "HELP"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_460B6A
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    push    1881h
    add     edx, 519h
    push    offset aHelp_gui                ; "HELP.GUI"
    push    edx
    call    sub_4AA8F0
    push    0
    mov     esi, eax
    push    0
    push    0
    push    offset aDhelp                   ; "dhelp"
    mov     dword ptr [esi+8], offset loc_45FAC0
    call    sub_4288D0
    mov     eax, [esi+4]
    mov     edx, TAdynmemStructPtr
    push    11h
    add     edx, 519h
    movsx   ecx, word ptr [eax+0B6h]
    push    0
    push    edx
    mov     dword_512EF0, ecx
    call    sub_45F8C0
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460B6A:                             ; CODE XREF: sub_4609B0+123j
    push    offset aMission_0               ; "MISSION"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_460C66
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     loc_460C5D
    mov     eax, TAdynmemStructPtr
    push    0
    add     eax, 519h
    push    offset aBriefing_gui            ; "BRIEFING.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, [eax+4]
    push    0Eh
    push    offset aMorebar                 ; char *
    push    esi                             ; int
    mov     dword ptr [eax+8], offset loc_45F770
    call    sub_49FDF0
    mov     ecx, eax
    push    0Eh
    shl     ecx, 3
    sub     ecx, eax
    push    offset aTextregion              ; char *
    push    esi                             ; int
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    lea     eax, [edx+ecx*2+1Bh]
    mov     ecx, [edx+ecx*2+1Bh]
    and     ecx, 0FFFFFFEFh
    mov     [eax], ecx
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    push    0
    push    0
    push    0
    lea     ecx, [ecx+ecx*2]
    push    offset aIgmbrief                ; "igmbrief"
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     eax, [esi+ecx*2+1Bh]
    mov     ecx, [esi+ecx*2+1Bh]
    and     ecx, 0FFFFFFEFh
    mov     [eax], ecx
    call    sub_4288D0
    mov     edx, TAdynmemStructPtr
    push    0Fh
    add     edx, 519h
    push    edx
    call    sub_4AFC60
    call    sub_476D80
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460C5D:                             ; CODE XREF: sub_4609B0+1EDj
    call    sub_45F1D0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460C66:                             ; CODE XREF: sub_4609B0+1C7j
    push    offset aExit                    ; "EXIT"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_460C8A
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    call    sub_4608B0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460C8A:                             ; CODE XREF: sub_4609B0+2C3j
    push    offset byte_502AE8
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_460CA9
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_460CA9:                             ; CODE XREF: sub_4609B0+2E7j
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_460CB5
    push    esi
    call    sub_4AB0A0

    loc_460CB5:                             ; CODE XREF: sub_4609B0+2FDj
    pop     esi
    retn    4
    sub_4609B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_460CC0 proc near                    ; CODE XREF: .text:0049478Ap
                                            ; .text:004961B7p
    mov     eax, TAdynmemStructPtr
    push    esi
    push    800h
    add     eax, 519h
    push    offset aArmopt_gui              ; "ARMOPT.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    mov     dword ptr [esi+8], offset sub_4609B0
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    xor     edx, edx
    cmp     eax, 3
    mov     eax, [esi+4]
    setz    dl
    push    edx
    push    1
    push    offset aSavegame_1              ; char *
    push    eax                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A1200
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    mov     edx, [esi+4]
    xor     ecx, ecx
    cmp     eax, 3
    setz    cl
    push    ecx
    push    1
    push    offset aLoadgame_0              ; char *
    push    edx                             ; int
    call    sub_49FDF0
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A1200
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jz      short loc_460D88
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 2
    jnz     short loc_460DAD

    loc_460D88:                             ; CODE XREF: sub_460CC0+B0j
    push    80h
    push    offset aSettings_0              ; int
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    offset aMission_0               ; "MISSION"
    push    eax
    call    sub_4A0BF0

    loc_460DAD:                             ; CODE XREF: sub_460CC0+C6j
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA50
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jz      short loc_460E07
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+38A51h], 1

    loc_460E07:                             ; CODE XREF: sub_460CC0+139j
    mov     edx, TAdynmemStructPtr
    push    1
    mov     ecx, [edx+10h]
    call    sub_4CE910
    pop     esi
    retn
    sub_460CC0 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_460E20 proc near

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    or      ebp, 0FFFFFFFFh
    mov     dword_513004, 0C8h
    mov     esi, offset dword_513010
    mov     [esp+14h+var_4], 0Bh
    xor     edi, edi

    loc_460E41:                             ; CODE XREF: sub_460E20+7Fj
    lea     ebx, [esi-8]
    lea     ecx, [esi+30h]
    mov     [esi-4], edi
    mov     [esi], edi
    mov     [ebx], ebp
    mov     [esi+4], edi
    mov     dword ptr [esi+8], 0FFFFFFFEh
    mov     [esi+0Ch], ebp
    mov     [esi+10h], edi
    mov     [esi+14h], ebp
    mov     [esi+18h], edi
    mov     [esi+1Ch], edi
    mov     [esi+20h], edi
    mov     [esi+24h], edi
    mov     [esi+28h], edi
    mov     [esi+2Ch], edi
    call    sub_460F40
    push    0FA0h
    mov     ecx, ebx
    call    sub_462860
    push    0C8h
    mov     ecx, ebx
    call    sub_4628A0
    mov     eax, [esp+14h+var_4]
    add     esi, 1044h
    dec     eax
    mov     [esp+14h+var_4], eax
    jnz     short loc_460E41
    push    offset sub_4635B0
    push    0Ah
    push    34h
    push    (offset Global_UnknownFunctionPtr_1.field_18+8)
    mov     dword_51E2F4, edi
    mov     dword_51E2F8, edi
    mov     dword_51E2FC, edi
    mov     dword ptr Global_UnknownFunctionPtr_1.field_4, edi
    mov     dword ptr Global_UnknownFunctionPtr_1.field_4+4, offset dword_513000
    mov     dword ptr Global_UnknownFunctionPtr_1.field_4+8, ebp
    mov     dword ptr Global_UnknownFunctionPtr_1.field_4+0Ch, ebp
    mov     Global_UnknownFunctionPtr_1.field_14, edi
    mov     dword ptr Global_UnknownFunctionPtr_1.field_18, edi
    mov     dword ptr Global_UnknownFunctionPtr_1.field_18+4, edi
    call    sub_401000
    push    offset sub_460F60               ; void (*)(void)
    mov     dword ptr Global_UnknownFunctionPtr_1.field_4C+1DCh, edi
    mov     Global_UnknownFunctionPtr_1.field_22C, edi
    mov     Global_UnknownFunctionPtr_1.field_230, edi
    mov     Global_UnknownFunctionPtr_1.field_234, ebp
    mov     Global_UnknownFunctionPtr_1.field_238, ebp
    mov     Global_UnknownFunctionPtr_1.FunctionPtr, offset off_4FD518
    mov     dword_513000, offset off_4FD514
    call    _atexit
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_460E20 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_460F40 proc near                    ; CODE XREF: sub_460E20+53p
    mov     eax, ecx
    mov     dword ptr [eax], 0
    mov     dword ptr [eax+4], 0
    mov     dword ptr [eax+8], 0FFFFFFFFh
    retn
    sub_460F40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; void sub_460F60(void)
    sub_460F60 proc near                    ; DATA XREF: sub_460E20+D4o
    mov     eax, dword ptr Global_UnknownFunctionPtr_1.field_18+4
    push    ebx
    push    esi
    push    edi
    test    eax, eax
    mov     dword_513000, offset off_4FD514
    mov     Global_UnknownFunctionPtr_1.FunctionPtr, offset off_4FD518
    jnz     short loc_460F85
    mov     eax, dword ptr Global_UnknownFunctionPtr_1.field_18

    loc_460F85:                             ; CODE XREF: sub_460F60+1Ej
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     esi, offset _RIInitializeEx
    mov     edi, 0Ah

    loc_460F98:                             ; CODE XREF: sub_460F60+5Fj
    mov     eax, [esi-44h]
    sub     esi, 34h
    push    eax
    call    sub_4B4F20
    mov     ecx, [esi+4]
    add     esp, 4
    push    ecx
    call    sub_4B4F20
    mov     edx, [esi]
    add     esp, 4
    push    edx
    call    sub_4B4F20
    add     esp, 4
    dec     edi
    jnz     short loc_460F98
    mov     esi, offset dword_51E2FC
    mov     ebx, 0Bh

    loc_460FCB:                             ; CODE XREF: sub_460F60+B2j
    mov     eax, [esi-1044h]
    sub     esi, 1044h
    test    eax, eax
    jz      short loc_461005
    mov     eax, [esi+4]
    xor     edi, edi
    test    eax, eax
    jbe     short loc_460FFA

    loc_460FE4:                             ; CODE XREF: sub_460F60+98j
    mov     eax, [esi]
    mov     ecx, [eax+edi*4]
    push    ecx
    call    sub_4B4F20
    mov     eax, [esi+4]
    add     esp, 4
    inc     edi
    cmp     edi, eax
    jb      short loc_460FE4

    loc_460FFA:                             ; CODE XREF: sub_460F60+82j
    mov     edx, [esi]
    push    edx
    call    sub_4B4F20
    add     esp, 4

    loc_461005:                             ; CODE XREF: sub_460F60+79j
    mov     eax, [esi+20h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    dec     ebx
    jnz     short loc_460FCB
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_460F60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_461020 proc near                    ; CODE XREF: .text:00450DA2p
                                            ; .text:00457762p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, dword_512C94
    push    esi
    push    edi
    xor     edi, edi
    cmp     ecx, edi
    jz      short loc_4610A9
    jge     short loc_461038
    mov     dword_506DBC, edi
    jmp     short loc_4610A9
    ; ---------------------------------------------------------------------------

    loc_461038:                             ; CODE XREF: sub_461020+Ej
    cmp     ecx, edi
    jnz     short loc_461043
    mov     eax, 0C8h
    jmp     short loc_461061
    ; ---------------------------------------------------------------------------

    loc_461043:                             ; CODE XREF: sub_461020+1Aj
    cmp     ecx, 2
    jge     short loc_46104F
    mov     ecx, 2
    jmp     short loc_461059
    ; ---------------------------------------------------------------------------

    loc_46104F:                             ; CODE XREF: sub_461020+26j
    cmp     ecx, 1Eh
    jle     short loc_461059
    mov     ecx, 1Eh

    loc_461059:                             ; CODE XREF: sub_461020+2Dj
                                            ; sub_461020+32j
    mov     eax, 3E8h
    cdq
    idiv    ecx

    loc_461061:                             ; CODE XREF: sub_461020+21j
    push    eax
    push    offset aSettingM_defau          ; "setting m_defaultSendPacingMs to: %lums"...
    mov     dword_513004, eax
    call    nullsub_13
    add     esp, 8
    mov     ecx, offset dword_51300C
    mov     esi, 0Bh

    loc_46107E:                             ; CODE XREF: sub_461020+87j
    mov     eax, dword_513004
    add     ecx, 1044h
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax+3E7h]
    mov     eax, 10624DD3h
    mul     edx
    shr     edx, 6
    mov     [ecx-1044h], edx
    dec     esi
    jnz     short loc_46107E

    loc_4610A9:                             ; CODE XREF: sub_461020+Cj
                                            ; sub_461020+16j
    cmp     dword_506DBC, edi
    jz      loc_46115C
    cmp     dword ptr Global_UnknownFunctionPtr_1.field_18, edi
    jnz     short loc_4610F3
    mov     eax, dword ptr Global_UnknownFunctionPtr_1.field_18+4
    cmp     eax, edi
    jz      short loc_4610D3
    mov     dword ptr Global_UnknownFunctionPtr_1.field_18, eax
    mov     dword ptr Global_UnknownFunctionPtr_1.field_18+4, edi
    jmp     short loc_4610F3
    ; ---------------------------------------------------------------------------

    loc_4610D3:                             ; CODE XREF: sub_461020+A4j
    push    42Ah                            ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    mov     dword ptr Global_UnknownFunctionPtr_1.field_18, eax
    jz      short loc_461166
    mov     dword ptr Global_UnknownFunctionPtr_1.field_4C+1DCh, 42Ah

    loc_4610F3:                             ; CODE XREF: sub_461020+9Bj
                                            ; sub_461020+B1j
    mov     eax, Global_UnknownFunctionPtr_1.field_14
    mov     Global_UnknownFunctionPtr_1.field_22C, edi
    cmp     eax, edi
    jz      short loc_46110B
    mov     [eax+0Ch], edi
    mov     Global_UnknownFunctionPtr_1.field_14, edi

    loc_46110B:                             ; CODE XREF: sub_461020+E0j
    mov     eax, [esp+8+arg_4]
    mov     ecx, [esp+8+arg_0]
    mov     edx, dword_513004
    push    eax
    push    ecx
    push    edx
    push    edi
    mov     ecx, offset dword_513008
    call    sub_461DB0
    mov     esi, offset dword_51404C
    mov     edi, 0Ah

    loc_461131:                             ; CODE XREF: sub_461020+12Bj
    mov     eax, dword_513004
    push    64h
    push    2
    push    eax
    push    0FFFFFFFFh
    mov     ecx, esi
    call    sub_461DB0
    add     esi, 1044h
    dec     edi
    jnz     short loc_461131
    push    0FFFFFFFEh                      ; nPriority
    call    ds:GetCurrentThread
    push    eax                             ; hThread
    call    ds:SetThreadPriority

    loc_46115C:                             ; CODE XREF: sub_461020+8Fj
    mov     eax, 1
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_461166:                             ; CODE XREF: sub_461020+C7j
    pop     edi
    xor     eax, eax
    pop     esi
    retn    8
    sub_461020 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_13. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    push    ebx
    push    esi
    mov     esi, [esp+18h]
    push    edi
    mov     edi, [esp+14h]
    push    esi
    push    edi
    push    offset aBytesToSendToD          ; "bytes to send to (DPID)(%ld): %ld\n"
    call    nullsub_13
    mov     ecx, [esp+24h]
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     dword_5129F1, edi
    lea     ebx, [eax+14h]
    push    esi
    push    ecx
    mov     ecx, offset dword_5129D0
    call    sub_44F940
    mov     ecx, offset dword_5129D0
    mov     edx, [esp+10h]
    push    edx
    push    ebx
    call    Network_SendNetMessage
    xor     ecx, ecx
    pop     edi
    test    eax, eax
    setz    cl
    pop     esi
    mov     eax, ecx
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    mov     edx, 0Bh
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    or      ebx, 0FFFFFFFFh
    lea     ecx, [ebp+8]
    mov     dword ptr [ebp+4], 0C8h
    xor     edi, edi
    mov     esi, 6
    lea     eax, [ecx+40h]

    loc_461205:                             ; CODE XREF: .text:00461250j
    mov     [ecx], ebx
    mov     [eax-3Ch], edi
    mov     [eax-38h], edi
    mov     [eax-34h], edi
    mov     dword ptr [eax-30h], 0FFFFFFFEh
    mov     [eax-2Ch], ebx
    mov     [eax-28h], edi
    mov     [eax-24h], ebx
    mov     [eax-20h], edi
    mov     [eax-1Ch], edi
    mov     [eax-18h], edi
    mov     [eax-14h], edi
    mov     [eax-10h], edi
    mov     [eax-0Ch], edi
    mov     [eax-8], edi
    mov     [eax-4], edi
    mov     [eax], ebx
    mov     dword ptr [eax-28h], 78h
    mov     [eax-3Ch], esi
    add     ecx, 1044h
    add     eax, 1044h
    dec     edx
    jnz     short loc_461205
    lea     eax, [ebp+0B320h]
    mov     [ebp+0B2F4h], edi
    mov     [ebp+0B2F8h], edi
    mov     [ebp+0B2FCh], edi
    mov     [ebp+0B304h], edi
    mov     [ebp+0B308h], ebp
    mov     [ebp+0B30Ch], ebx
    mov     [ebp+0B310h], ebx
    mov     [ebp+0B314h], edi
    mov     [ebp+0B318h], edi
    mov     [ebp+0B31Ch], edi
    mov     [esp+10h], eax
    lea     esi, [eax+20h]
    mov     dword ptr [esp+14h], 0Ah
    jmp     short loc_4612A9
    ; ---------------------------------------------------------------------------

    loc_4612A5:                             ; CODE XREF: .text:00461305j
    mov     eax, [esp+10h]

    loc_4612A9:                             ; CODE XREF: .text:004612A3j
    mov     [eax], ebx
    mov     [esi-1Ch], ebx
    mov     [esi-18h], ebx
    mov     [esi-14h], edi
    mov     [esi-10h], ebx
    mov     [esi-0Ch], edi
    push    180Ch
    mov     [esi+8], edi
    mov     [esi-8], edi
    mov     [esi-4], edi
    mov     [esi], edi
    mov     [esi+4], edi
    mov     [esi+0Ch], ebx
    mov     [esi+10h], ebx
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    jz      short loc_4612E9
    mov     [eax], edi
    mov     [eax+4], edi
    mov     [eax+8], ebx
    jmp     short loc_4612EB
    ; ---------------------------------------------------------------------------

    loc_4612E9:                             ; CODE XREF: .text:004612DDj
    xor     eax, eax

    loc_4612EB:                             ; CODE XREF: .text:004612E7j
    mov     edx, [esp+10h]
    mov     [esi+8], eax
    mov     eax, [esp+14h]
    add     edx, 34h
    add     esi, 34h
    dec     eax
    mov     [esp+10h], edx
    mov     [esp+14h], eax
    jnz     short loc_4612A5
    mov     [ebp+0B528h], edi
    mov     [ebp+0B52Ch], edi
    mov     [ebp+0B530h], edi
    mov     [ebp+0B534h], ebx
    mov     [ebp+0B538h], ebx
    mov     dword ptr [ebp+0B300h], offset off_4FD518
    pop     edi
    mov     dword ptr [ebp+0], offset off_4FD514
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_461340 proc near                    ; DATA XREF: .rdata:004FD514o

    arg_0= byte ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     dword ptr [ebp+0], offset off_4FD514
    mov     eax, [ebp+0B31Ch]
    test    eax, eax
    mov     dword ptr [ebp+0B300h], offset off_4FD518
    jnz     short loc_461367
    mov     eax, [ebp+0B318h]

    loc_461367:                             ; CODE XREF: sub_461340+1Fj
    push    eax
    call    sub_4B4F20
    add     esp, 4
    lea     esi, [ebp+0B54Ch]
    mov     edi, 0Ah

    loc_46137B:                             ; CODE XREF: sub_461340+62j
    mov     ecx, [esi-44h]
    sub     esi, 34h
    push    ecx
    call    sub_4B4F20
    mov     edx, [esi+4]
    add     esp, 4
    push    edx
    call    sub_4B4F20
    mov     eax, [esi]
    add     esp, 4
    push    eax
    call    sub_4B4F20
    add     esp, 4
    dec     edi
    jnz     short loc_46137B
    lea     esi, [ebp+0B2FCh]
    mov     ebx, 0Bh

    loc_4613AF:                             ; CODE XREF: sub_461340+B6j
    mov     eax, [esi-1044h]
    sub     esi, 1044h
    test    eax, eax
    jz      short loc_4613E9
    mov     eax, [esi+4]
    xor     edi, edi
    test    eax, eax
    jbe     short loc_4613DE

    loc_4613C8:                             ; CODE XREF: sub_461340+9Cj
    mov     ecx, [esi]
    mov     edx, [ecx+edi*4]
    push    edx
    call    sub_4B4F20
    mov     eax, [esi+4]
    add     esp, 4
    inc     edi
    cmp     edi, eax
    jb      short loc_4613C8

    loc_4613DE:                             ; CODE XREF: sub_461340+86j
    mov     eax, [esi]
    push    eax
    call    sub_4B4F20
    add     esp, 4

    loc_4613E9:                             ; CODE XREF: sub_461340+7Dj
    mov     ecx, [esi+20h]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    dec     ebx
    jnz     short loc_4613AF
    test    [esp+8+arg_0], 1
    jz      short loc_461408
    push    ebp
    call    sub_4B4F20
    add     esp, 4

    loc_461408:                             ; CODE XREF: sub_461340+BDj
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_461340 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    mov     dword ptr [ebx], offset off_4FD514
    mov     eax, [ebx+0B31Ch]
    test    eax, eax
    mov     dword ptr [ebx+0B300h], offset off_4FD518
    jnz     short loc_461445
    mov     eax, [ebx+0B318h]

    loc_461445:                             ; CODE XREF: .text:0046143Dj
    push    eax
    call    sub_4B4F20
    add     esp, 4
    lea     esi, [ebx+0B54Ch]
    mov     edi, 0Ah

    loc_461459:                             ; CODE XREF: .text:00461480j
    mov     ecx, [esi-44h]
    sub     esi, 34h
    push    ecx
    call    sub_4B4F20
    mov     edx, [esi+4]
    add     esp, 4
    push    edx
    call    sub_4B4F20
    mov     eax, [esi]
    add     esp, 4
    push    eax
    call    sub_4B4F20
    add     esp, 4
    dec     edi
    jnz     short loc_461459
    lea     esi, [ebx+0B2FCh]
    mov     ebx, 0Bh

    loc_46148D:                             ; CODE XREF: .text:004614D4j
    mov     eax, [esi-1044h]
    sub     esi, 1044h
    test    eax, eax
    jz      short loc_4614C7
    mov     eax, [esi+4]
    xor     edi, edi
    test    eax, eax
    jbe     short loc_4614BC

    loc_4614A6:                             ; CODE XREF: .text:004614BAj
    mov     ecx, [esi]
    mov     edx, [ecx+edi*4]
    push    edx
    call    sub_4B4F20
    mov     eax, [esi+4]
    add     esp, 4
    inc     edi
    cmp     edi, eax
    jb      short loc_4614A6

    loc_4614BC:                             ; CODE XREF: .text:004614A4j
    mov     eax, [esi]
    push    eax
    call    sub_4B4F20
    add     esp, 4

    loc_4614C7:                             ; CODE XREF: .text:0046149Bj
    mov     ecx, [esi+20h]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    dec     ebx
    jnz     short loc_46148D
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4614E0 proc near                    ; CODE XREF: sub_4624A0+11Bp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     eax, [esp+4+arg_4]
    push    ebx
    push    ebp
    mov     ebx, ecx
    push    esi
    push    edi
    mov     edi, [ebx+0B2F8h]
    mov     ecx, [ebx+0B2FCh]
    mov     edx, eax
    add     edx, edi
    cmp     edx, ecx
    jbe     loc_461590
    cmp     eax, 200h
    ja      short loc_46150F
    mov     eax, 200h

    loc_46150F:                             ; CODE XREF: sub_4614E0+28j
    lea     edi, [ecx+eax]
    mov     eax, [ebx+0B2F4h]
    test    eax, eax
    mov     [esp+14h+var_4], edi
    jnz     short loc_461527
    add     edi, 4
    mov     [esp+14h+var_4], edi

    loc_461527:                             ; CODE XREF: sub_4614E0+3Ej
    push    edi                             ; int
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jz      loc_4615DA
    mov     esi, [ebx+0B2F4h]
    test    esi, esi
    jz      short loc_461560
    mov     ecx, [ebx+0B2F8h]
    mov     edi, ebp
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+14h+var_4]
    jmp     short loc_461571
    ; ---------------------------------------------------------------------------

    loc_461560:                             ; CODE XREF: sub_4614E0+62j
    mov     dword ptr [ebx+0B2F8h], 4
    mov     dword ptr [ebp+0], 0FFFFFFFEh

    loc_461571:                             ; CODE XREF: sub_4614E0+7Ej
    mov     eax, [ebx+0B2F4h]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+18h+arg_4]
    add     esp, 4
    mov     [ebx+0B2F4h], ebp
    mov     [ebx+0B2FCh], edi

    loc_461590:                             ; CODE XREF: sub_4614E0+1Dj
    mov     edi, [ebx+0B2F4h]
    mov     ebp, [ebx+0B2F8h]
    mov     edx, [esp+14h+arg_0]
    mov     ecx, eax
    add     edi, ebp
    mov     ebp, ecx
    mov     esi, edx
    push    1
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    push    eax
    and     ecx, 3
    rep movsb
    mov     edi, [ebx+0B2F8h]
    add     edi, eax
    mov     [ebx+0B2F8h], edi
    mov     cl, [edx]
    push    ecx
    call    sub_415EF0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4615DA:                             ; CODE XREF: sub_4614E0+54j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    8
    sub_4614E0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx+0B2F4h]
    neg     eax
    sbb     eax, eax
    and     eax, 4
    mov     [ecx+0B2F8h], eax
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_41. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_14. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_461630 proc near                    ; CODE XREF: .text:00461828p
                                            ; sub_4619B0+7p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    lea     edx, [ebx+1Ch]
    push    edi
    mov     [esp+14h+var_4], ebx
    xor     eax, eax
    mov     esi, edx

    loc_461642:                             ; CODE XREF: sub_461630+2Aj
    mov     ecx, [esp+14h+arg_0]
    mov     edi, [esi]
    cmp     edi, ecx
    jz      loc_461731
    inc     eax
    add     esi, 1044h
    cmp     eax, 0Ah
    jbe     short loc_461642
    mov     eax, [esp+14h+arg_4]
    test    eax, eax
    jz      loc_461727
    xor     eax, eax

    loc_46166A:                             ; CODE XREF: sub_461630+49j
    cmp     dword ptr [edx], 0FFFFFFFFh
    jz      short loc_46167D
    inc     eax
    add     edx, 1044h
    cmp     eax, 0Ah
    jbe     short loc_46166A
    jmp     short loc_4616A7
    ; ---------------------------------------------------------------------------

    loc_46167D:                             ; CODE XREF: sub_461630+3Dj
    mov     edx, eax
    push    64h
    shl     edx, 6
    add     edx, eax
    push    2
    shl     edx, 4
    add     edx, eax
    mov     eax, [ebx+4]
    push    eax
    push    ecx
    lea     esi, [ebx+edx*4+8]
    mov     ecx, esi
    call    sub_461DB0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4616A7:                             ; CODE XREF: sub_461630+4Bj
    mov     ecx, TAdynmemStructPtr
    mov     ebp, 1
    add     ebx, 1060h

    loc_4616B8:                             ; CODE XREF: sub_461630+B9j
    mov     esi, [ebx]
    xor     edi, edi
    xor     eax, eax
    lea     edx, [ecx+1B67h]

    loc_4616C4:                             ; CODE XREF: sub_461630+A2j
    cmp     [edx], esi
    jz      short loc_4616D6
    inc     eax
    add     edx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_4616C4
    jmp     short loc_4616DB
    ; ---------------------------------------------------------------------------

    loc_4616D6:                             ; CODE XREF: sub_461630+96j
    mov     edi, 1

    loc_4616DB:                             ; CODE XREF: sub_461630+A4j
    test    edi, edi
    jz      short loc_4616F5
    inc     ebp
    add     ebx, 1044h
    cmp     ebp, 0Ah
    jbe     short loc_4616B8
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4616F5:                             ; CODE XREF: sub_461630+ADj
    mov     ecx, ebp
    mov     eax, [esp+14h+var_4]
    shl     ecx, 6
    mov     edx, [eax+4]
    add     ecx, ebp
    shl     ecx, 4
    add     ecx, ebp
    push    64h
    push    2
    push    edx
    lea     esi, [eax+ecx*4+8]
    mov     eax, [esp+20h+arg_0]
    push    eax
    mov     ecx, esi
    call    sub_461DB0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_461727:                             ; CODE XREF: sub_461630+32j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_461731:                             ; CODE XREF: sub_461630+1Aj
    mov     ecx, eax
    pop     edi
    shl     ecx, 6
    add     ecx, eax
    pop     esi
    shl     ecx, 4
    add     ecx, eax
    pop     ebp
    lea     eax, [ebx+ecx*4+8]
    pop     ebx
    pop     ecx
    retn    8
    sub_461630 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, dword_506DBC
    push    ebx
    push    esi
    push    edi
    xor     edi, edi
    mov     esi, ecx
    cmp     eax, edi
    jnz     short loc_461768
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_461768:                             ; CODE XREF: .text:0046175Ej
    cmp     [esi+0B318h], edi
    jnz     short loc_4617A9
    mov     eax, [esi+0B31Ch]
    cmp     eax, edi
    jz      short loc_461788
    mov     [esi+0B318h], eax
    mov     [esi+0B31Ch], edi
    jmp     short loc_4617A9
    ; ---------------------------------------------------------------------------

    loc_461788:                             ; CODE XREF: .text:00461778j
    push    42Ah
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    mov     [esi+0B318h], eax
    jz      short loc_461818
    mov     dword ptr [esi+0B528h], 42Ah

    loc_4617A9:                             ; CODE XREF: .text:0046176Ej
                                            ; .text:00461786j
    mov     eax, [esi+0B314h]
    mov     [esi+0B52Ch], edi
    cmp     eax, edi
    jz      short loc_4617C2
    mov     [eax+0Ch], edi
    mov     [esi+0B314h], edi

    loc_4617C2:                             ; CODE XREF: .text:004617B7j
    mov     eax, [esp+14h]
    mov     ecx, [esp+10h]
    mov     edx, [esi+4]
    push    eax
    push    ecx
    push    edx
    push    edi
    lea     ecx, [esi+8]
    call    sub_461DB0
    lea     edi, [esi+104Ch]
    mov     ebx, 0Ah

    loc_4617E4:                             ; CODE XREF: .text:004617FCj
    mov     eax, [esi+4]
    push    64h
    push    2
    push    eax
    push    0FFFFFFFFh
    mov     ecx, edi
    call    sub_461DB0
    add     edi, 1044h
    dec     ebx
    jnz     short loc_4617E4
    push    0FFFFFFFEh
    call    ds:GetCurrentThread
    push    eax
    call    ds:SetThreadPriority
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_461818:                             ; CODE XREF: .text:0046179Dj
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    mov     eax, [esp+4]
    push    esi
    push    0
    push    eax
    call    sub_461630
    mov     esi, eax
    test    esi, esi
    jz      short loc_461859
    push    64h
    push    2
    push    0C8h
    push    0FFFFFFFFh
    mov     ecx, esi
    call    sub_461DB0
    mov     dword ptr [esi], 0FFFFFFFFh
    mov     dword ptr [esi+1Ch], 0FFFFFFFFh
    mov     dword ptr [esi+24h], 0

    loc_461859:                             ; CODE XREF: .text:00461831j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    push    ebx
    push    ebp
    push    esi
    push    edi
    or      ebp, 0FFFFFFFFh
    lea     esi, [ecx+8]
    mov     edi, 0Bh
    xor     ebx, ebx

    loc_461871:                             ; CODE XREF: .text:00461891j
    push    64h
    push    2
    push    0C8h
    push    ebp
    mov     ecx, esi
    call    sub_461DB0
    mov     [esi], ebp
    mov     [esi+1Ch], ebp
    mov     [esi+24h], ebx
    add     esi, 1044h
    dec     edi
    jnz     short loc_461871
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4618A0 proc near                    ; CODE XREF: sub_434BF0+2D2p
                                            ; sub_447B10+964p ...

    arg_0= dword ptr  4

    mov     eax, dword_506DBC
    push    ebx
    push    ebp
    push    esi
    test    eax, eax
    push    edi
    jnz     short loc_4618B6
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4618B6:                             ; CODE XREF: sub_4618A0+Bj
    mov     ebx, [esp+10h+arg_0]
    xor     edi, edi
    lea     esi, [ecx+8]
    or      ebp, 0FFFFFFFFh

    loc_4618C2:                             ; CODE XREF: sub_4618A0+3Dj
    cmp     [esi+14h], ebp
    jz      short loc_4618D3
    push    ebx
    mov     ecx, esi
    call    sub_4624A0
    test    eax, eax
    jz      short loc_4618EB

    loc_4618D3:                             ; CODE XREF: sub_4618A0+25j
    inc     edi
    add     esi, 1044h
    cmp     edi, 0Ah
    jbe     short loc_4618C2
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4618EB:                             ; CODE XREF: sub_4618A0+31j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_4618A0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jz      short loc_461916
    or      ecx, 0FFFFFFFFh
    jmp     short loc_461919
    ; ---------------------------------------------------------------------------

    loc_461916:                             ; CODE XREF: .text:0046190Fj
    mov     ecx, [eax+10h]

    loc_461919:                             ; CODE XREF: .text:00461914j
    mov     edx, [esi+0B2F4h]
    mov     [edx], ecx
    mov     edi, [esi+0B2F8h]
    mov     ebx, [eax+14h]
    mov     ebp, [esi+0B2F4h]
    push    edi
    push    ebx
    push    offset aBytesToSendToD          ; "bytes to send to (DPID)(%ld): %ld\n"
    call    nullsub_13
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    add     eax, 14h
    mov     ecx, offset dword_5129D0
    push    edi
    push    ebp
    mov     [esp+20h], eax
    mov     dword_5129F1, ebx
    call    sub_44F940
    mov     ecx, [esp+14h]
    mov     edx, [esp+18h]
    push    ecx
    push    edx
    mov     ecx, offset dword_5129D0
    call    Network_SendNetMessage
    mov     eax, [esi+0B2F4h]
    pop     edi
    neg     eax
    sbb     eax, eax
    and     eax, 4
    mov     [esi+0B2F8h], eax
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_461990 proc near                    ; CODE XREF: sub_451DF0+F0p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_C]
    mov     ecx, [esp+arg_8]
    mov     edx, [esp+arg_0]
    push    eax
    push    ecx
    mov     ecx, [esp+8+arg_4]
    push    edx
    call    sub_462710
    retn    10h
    sub_461990 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4619B0(int,int,int,int)
    sub_4619B0 proc near                    ; CODE XREF: Network_BroadcastMessage+1CBp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_4]
    push    1
    push    eax
    call    sub_461630
    test    eax, eax
    jz      short loc_4619D9
    mov     ecx, [esp+arg_C]
    mov     edx, [esp+arg_8]
    push    ecx
    mov     ecx, [esp+4+arg_0]
    push    edx
    push    ecx
    mov     ecx, eax
    call    sub_462710
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4619D9:                             ; CODE XREF: sub_4619B0+Ej
    xor     eax, eax
    retn    10h
    sub_4619B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4619E0 proc near                    ; CODE XREF: sub_4578D0+Ap

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    mov     ecx, [esp+arg_0]
    test    ecx, ecx
    jge     short loc_4619F9
    mov     dword_506DBC, 0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4619F9:                             ; CODE XREF: sub_4619E0+9j
    test    ecx, ecx
    push    edi
    jnz     short loc_461A07
    mov     dword ptr [esi+4], 0C8h
    jmp     short loc_461A28
    ; ---------------------------------------------------------------------------

    loc_461A07:                             ; CODE XREF: sub_4619E0+1Cj
    cmp     ecx, 2
    jge     short loc_461A13
    mov     ecx, 2
    jmp     short loc_461A1D
    ; ---------------------------------------------------------------------------

    loc_461A13:                             ; CODE XREF: sub_4619E0+2Aj
    cmp     ecx, 1Eh
    jle     short loc_461A1D
    mov     ecx, 1Eh

    loc_461A1D:                             ; CODE XREF: sub_4619E0+31j
                                            ; sub_4619E0+36j
    mov     eax, 3E8h
    cdq
    idiv    ecx
    mov     [esi+4], eax

    loc_461A28:                             ; CODE XREF: sub_4619E0+25j
    mov     eax, [esi+4]
    push    eax
    push    offset aSettingM_defau          ; "setting m_defaultSendPacingMs to: %lums"...
    call    nullsub_13
    add     esp, 8
    lea     ecx, [esi+0Ch]
    mov     edi, 0Bh

    loc_461A41:                             ; CODE XREF: sub_4619E0+88j
    mov     eax, [esi+4]
    add     ecx, 1044h
    lea     eax, [eax+eax*2]
    lea     edx, [eax+eax*4]
    mov     eax, 10624DD3h
    lea     edx, [edx+edx+3E7h]
    mul     edx
    shr     edx, 6
    mov     [ecx-1044h], edx
    dec     edi
    jnz     short loc_461A41
    pop     edi
    pop     esi
    retn    4
    sub_4619E0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, ecx
    or      edx, 0FFFFFFFFh
    xor     ecx, ecx
    mov     [eax], edx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ecx
    mov     dword ptr [eax+10h], 0FFFFFFFEh
    mov     [eax+14h], edx
    mov     [eax+1Ch], edx
    mov     [eax+20h], ecx
    mov     [eax+24h], ecx
    mov     [eax+28h], ecx
    mov     [eax+2Ch], ecx
    mov     [eax+30h], ecx
    mov     [eax+34h], ecx
    mov     [eax+38h], ecx
    mov     [eax+3Ch], ecx
    mov     [eax+40h], edx
    mov     dword ptr [eax+18h], 78h
    mov     dword ptr [eax+4], 6
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    edi
    mov     edi, ecx
    mov     eax, [edi+8]
    test    eax, eax
    jz      short loc_461AF8
    mov     eax, [edi+0Ch]
    push    esi
    xor     esi, esi
    test    eax, eax
    jbe     short loc_461AEB

    loc_461AD4:                             ; CODE XREF: .text:00461AE9j
    mov     eax, [edi+8]
    mov     ecx, [eax+esi*4]
    push    ecx
    call    sub_4B4F20
    mov     eax, [edi+0Ch]
    add     esp, 4
    inc     esi
    cmp     esi, eax
    jb      short loc_461AD4

    loc_461AEB:                             ; CODE XREF: .text:00461AD2j
    mov     edx, [edi+8]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    pop     esi

    loc_461AF8:                             ; CODE XREF: .text:00461AC8j
    mov     eax, [edi+28h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_461B10 proc near                    ; CODE XREF: sub_462710+40p
                                            ; sub_462710+8Ep

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     [esp+1Ch+var_8], esi

    loc_461B1D:                             ; CODE XREF: sub_461B10+ABj
    mov     eax, [esi+0Ch]
    test    eax, eax
    jbe     loc_461BA9
    mov     edi, [esi]
    inc     edi
    cmp     edi, eax
    mov     [esp+1Ch+var_C], edi
    jb      short loc_461B3F
    mov     [esp+1Ch+var_C], 0
    mov     edi, [esp+1Ch+var_C]

    loc_461B3F:                             ; CODE XREF: sub_461B10+21j
    mov     eax, [esi+8]
    mov     ecx, [esi+18h]
    mov     [esp+1Ch+var_4], ecx
    mov     ebp, [eax+edi*4]
    mov     eax, [ebp+8]
    test    eax, eax
    jz      loc_461BDA
    mov     esi, [ebp+10h]
    call    sub_4B6340
    mov     ebx, eax
    mov     eax, [esp+1Ch+var_4]
    mov     edi, ebx
    sub     edi, eax
    push    edi
    push    eax
    push    ebx
    push    offset aCurGameTimeLdM          ; "cur game time: %ld, min retain=%ld, mus"...
    call    nullsub_13
    add     esp, 10h
    test    esi, esi
    jz      short loc_461BC0

    loc_461B7D:                             ; CODE XREF: sub_461B10+8Bj
    cmp     [esi+0Ch], ebp
    jnz     short loc_461BC0
    mov     eax, [esi+10h]
    test    eax, eax
    jge     short loc_461B9D
    mov     eax, [esi+14h]
    cmp     eax, edi
    jle     short loc_461B94
    cmp     eax, ebx
    jbe     short loc_461B9D

    loc_461B94:                             ; CODE XREF: sub_461B10+7Ej
    mov     esi, [esi+1Ch]
    test    esi, esi
    jz      short loc_461BC0
    jmp     short loc_461B7D
    ; ---------------------------------------------------------------------------

    loc_461B9D:                             ; CODE XREF: sub_461B10+77j
                                            ; sub_461B10+82j
    mov     edx, [esp+1Ch+var_8]
    cmp     dword ptr [edx+0Ch], 22h
    jnb     short loc_461BED
    mov     esi, edx

    loc_461BA9:                             ; CODE XREF: sub_461B10+12j
    push    320h
    push    10h
    mov     ecx, esi
    call    sub_461FD0
    test    eax, eax
    jz      short loc_461C16
    jmp     loc_461B1D
    ; ---------------------------------------------------------------------------

    loc_461BC0:                             ; CODE XREF: sub_461B10+6Bj
                                            ; sub_461B10+70j ...
    mov     eax, [esp+1Ch+var_4]
    push    eax
    push    offset aBufferEligible          ; "buffer eligible for reuse:  all packets"...
    call    nullsub_13
    mov     esi, [esp+24h+var_8]
    mov     edi, [esp+24h+var_C]
    add     esp, 8

    loc_461BDA:                             ; CODE XREF: sub_461B10+41j
    mov     ecx, ebp
    call    sub_4629B0
    mov     [esi], edi
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_461BED:                             ; CODE XREF: sub_461B10+95j
    mov     ecx, ebp
    call    sub_4629B0
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, [esp+1Ch+var_8]
    push    eax
    push    offset aForceAllocated          ; "force-allocated a previously-used buffe"...
    mov     [ecx], eax
    call    nullsub_13
    add     esp, 8
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_461C16:                             ; CODE XREF: sub_461B10+A9j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 0Ch
    retn
    sub_461B10 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_461C20 proc near                    ; CODE XREF: sub_462710+56p
                                            ; sub_462710+A0p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 10h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     [esp+20h+var_C], edi

    loc_461C2D:                             ; CODE XREF: sub_461C20+C7j
    mov     eax, [edi+1Ch]
    push    eax
    push    offset aCurrentPacke_0          ; "current packet pool index: %ld\n"
    call    nullsub_13
    mov     ebx, [edi+1Ch]
    mov     eax, [edi+2Ch]
    add     esp, 8
    inc     ebx
    cmp     ebx, eax
    mov     [esp+20h+var_10], ebx
    jb      short loc_461C59
    mov     [esp+20h+var_10], 0
    mov     ebx, [esp+20h+var_10]

    loc_461C59:                             ; CODE XREF: sub_461C20+2Bj
    mov     ecx, [edi+28h]
    mov     esi, ebx
    shl     esi, 5
    add     esi, ecx
    mov     [esp+20h+var_4], esi
    mov     ebp, [esi+0Ch]
    test    ebp, ebp
    jz      loc_461D33
    mov     eax, [ebp+8]
    mov     ecx, [edi+18h]
    test    eax, eax
    mov     [esp+20h+var_8], ecx
    jz      loc_461D0A
    mov     esi, [ebp+10h]
    call    sub_4B6340
    mov     ebx, eax
    mov     eax, [esp+20h+var_8]
    mov     edi, ebx
    sub     edi, eax
    push    edi
    push    eax
    push    ebx
    push    offset aCurGameTimeLdM          ; "cur game time: %ld, min retain=%ld, mus"...
    call    nullsub_13
    add     esp, 10h
    test    esi, esi
    jz      short loc_461CEC

    loc_461CAA:                             ; CODE XREF: sub_461C20+A8j
    cmp     [esi+0Ch], ebp
    jnz     short loc_461CEC
    mov     eax, [esi+10h]
    test    eax, eax
    jge     short loc_461CCA
    mov     eax, [esi+14h]
    cmp     eax, edi
    jle     short loc_461CC1
    cmp     eax, ebx
    jbe     short loc_461CCA

    loc_461CC1:                             ; CODE XREF: sub_461C20+9Bj
    mov     esi, [esi+1Ch]
    test    esi, esi
    jz      short loc_461CEC
    jmp     short loc_461CAA
    ; ---------------------------------------------------------------------------

    loc_461CCA:                             ; CODE XREF: sub_461C20+94j
                                            ; sub_461C20+9Fj
    mov     ecx, [esp+20h+var_C]
    cmp     dword ptr [ecx+2Ch], 6A4h
    jnb     short loc_461D13
    push    320h
    push    0
    call    sub_461FD0
    mov     edi, [esp+20h+var_C]
    jmp     loc_461C2D
    ; ---------------------------------------------------------------------------

    loc_461CEC:                             ; CODE XREF: sub_461C20+88j
                                            ; sub_461C20+8Dj ...
    mov     edx, [esp+20h+var_8]
    push    edx
    push    offset aBufferEligible          ; "buffer eligible for reuse:  all packets"...
    call    nullsub_13
    mov     ebx, [esp+28h+var_10]
    mov     esi, [esp+28h+var_4]
    mov     edi, [esp+28h+var_C]
    add     esp, 8

    loc_461D0A:                             ; CODE XREF: sub_461C20+5Ej
    mov     ecx, ebp
    call    sub_4629B0
    jmp     short loc_461D33
    ; ---------------------------------------------------------------------------

    loc_461D13:                             ; CODE XREF: sub_461C20+B5j
    push    offset aForceInitializ          ; "force-initializing a in-use buffer whic"...
    call    nullsub_13
    add     esp, 4
    mov     ecx, ebp
    call    sub_4629B0
    mov     ebx, [esp+20h+var_10]
    mov     esi, [esp+20h+var_4]
    mov     edi, [esp+20h+var_C]

    loc_461D33:                             ; CODE XREF: sub_461C20+4Cj
                                            ; sub_461C20+F1j
    push    ebx
    push    offset aCurrentPacketP          ; "current packet pool index set to: %ld\n"
    mov     [edi+1Ch], ebx
    call    nullsub_13
    mov     eax, [esp+28h+arg_0]
    add     esp, 8
    mov     [esi], eax
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    4
    sub_461C20 endp

    ; ---------------------------------------------------------------------------
    align 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [ecx]
    xor     eax, eax
    test    edx, edx
    jl      short locret_461D7E
    mov     eax, [ecx+8]
    mov     eax, [eax+edx*4]

    locret_461D7E:                          ; CODE XREF: .text:00461D76j
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, 88888889h
    mul     dword ptr [ecx+18h]
    shr     edx, 4
    lea     eax, [edx+edx*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 3
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     edx, [ecx+28h]
    shl     eax, 5
    add     eax, edx
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_461DB0 proc near                    ; CODE XREF: sub_461020+102p
                                            ; sub_461020+11Fp ...

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    sub     esp, 20h
    push    ebx
    mov     ebx, ecx
    push    ebp
    xor     ebp, ebp
    mov     [ebx+14h], eax
    mov     eax, [esp+28h+arg_4]
    push    esi
    push    edi
    lea     eax, [eax+eax*2]
    lea     ecx, [eax+eax*4]
    mov     eax, 10624DD3h
    lea     edx, [ecx+ecx+3E7h]
    mul     edx
    mov     eax, [ebx+28h]
    shr     edx, 6
    cmp     eax, ebp
    mov     [ebx+4], edx
    jnz     short loc_461E41
    mov     esi, [esp+30h+arg_C]
    cmp     esi, ebp
    jnz     short loc_461DF4
    mov     esi, 64h

    loc_461DF4:                             ; CODE XREF: sub_461DB0+3Dj
    mov     eax, esi
    shl     eax, 5
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_461E31
    lea     edx, [esi-1]
    cmp     edx, ebp
    jl      short loc_461E33
    lea     ecx, [eax+8]
    inc     edx

    loc_461E11:                             ; CODE XREF: sub_461DB0+7Dj
    mov     [ecx-4], ebp
    mov     [ecx], ebp
    mov     [ecx+4], ebp
    mov     dword ptr [ecx+8], 0FFFFFFFFh
    mov     [ecx+0Ch], ebp
    mov     [ecx+10h], ebp
    mov     [ecx+14h], ebp
    add     ecx, 20h
    dec     edx
    jnz     short loc_461E11
    jmp     short loc_461E33
    ; ---------------------------------------------------------------------------

    loc_461E31:                             ; CODE XREF: sub_461DB0+54j
    xor     eax, eax

    loc_461E33:                             ; CODE XREF: sub_461DB0+5Bj
                                            ; sub_461DB0+7Fj
    cmp     eax, ebp
    mov     [ebx+28h], eax
    jz      loc_461F78
    mov     [ebx+2Ch], esi

    loc_461E41:                             ; CODE XREF: sub_461DB0+35j
    cmp     [ebx+8], ebp
    jnz     short loc_461EBC
    mov     esi, [esp+30h+arg_8]
    cmp     esi, ebp
    jnz     short loc_461E53
    mov     esi, 2

    loc_461E53:                             ; CODE XREF: sub_461DB0+9Cj
    lea     ecx, ds:0[esi*4]
    push    ecx                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    mov     [ebx+8], eax
    jz      loc_461F78
    cmp     esi, ebp
    mov     [ebx+0Ch], ebp
    jbe     short loc_461EBC

    loc_461E75:                             ; CODE XREF: sub_461DB0+10Aj
    push    43Eh                            ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_461E9A
    mov     [eax], ebx
    mov     dword ptr [eax+4], 0FFFFFFFFh
    mov     [eax+8], ebp
    mov     [eax+0Ch], ebp
    mov     [eax+10h], ebp
    jmp     short loc_461E9C
    ; ---------------------------------------------------------------------------

    loc_461E9A:                             ; CODE XREF: sub_461DB0+D4j
    xor     eax, eax

    loc_461E9C:                             ; CODE XREF: sub_461DB0+E8j
    mov     edx, [ebx+0Ch]
    mov     ecx, [ebx+8]
    mov     [ecx+edx*4], eax
    mov     eax, [ebx+0Ch]
    mov     edx, [ebx+8]
    cmp     [edx+eax*4], ebp
    jz      loc_461F78
    inc     eax
    cmp     eax, esi
    mov     [ebx+0Ch], eax
    jb      short loc_461E75

    loc_461EBC:                             ; CODE XREF: sub_461DB0+94j
                                            ; sub_461DB0+C3j
    mov     eax, [ebx+0Ch]
    xor     esi, esi
    cmp     eax, ebp
    jbe     short loc_461EE1

    loc_461EC5:                             ; CODE XREF: sub_461DB0+12Fj
    mov     eax, [ebx+8]
    mov     eax, [eax+esi*4]
    mov     [eax+8], ebp
    mov     ecx, [ebx+8]
    mov     ecx, [ecx+esi*4]
    call    sub_4629B0
    mov     eax, [ebx+0Ch]
    inc     esi
    cmp     esi, eax
    jb      short loc_461EC5

    loc_461EE1:                             ; CODE XREF: sub_461DB0+113j
    mov     ecx, [ebx+2Ch]
    xor     eax, eax
    cmp     ecx, ebp
    mov     [esp+30h+var_1C], ebp
    mov     [esp+30h+var_18], ebp
    mov     [esp+30h+var_14], ebp
    mov     [esp+30h+var_10], 0FFFFFFFFh
    mov     [esp+30h+var_C], ebp
    mov     [esp+30h+var_8], ebp
    mov     [esp+30h+var_4], ebp
    jbe     short loc_461F29
    xor     edx, edx

    loc_461F0C:                             ; CODE XREF: sub_461DB0+177j
    mov     ecx, [ebx+28h]
    mov     edi, edx
    add     edi, ecx
    mov     ecx, 8
    lea     esi, [esp+30h+var_20]
    inc     eax
    rep movsd
    mov     ecx, [ebx+2Ch]
    add     edx, 20h
    cmp     eax, ecx
    jb      short loc_461F0C

    loc_461F29:                             ; CODE XREF: sub_461DB0+158j
    mov     eax, [ebx+38h]
    mov     dword ptr [ebx], 0FFFFFFFFh
    cmp     eax, ebp
    mov     dword ptr [ebx+1Ch], 0FFFFFFFFh
    mov     [ebx+30h], ebp
    mov     [ebx+34h], ebp
    jz      short loc_461F66

    loc_461F43:                             ; CODE XREF: sub_461DB0+1B4j
    mov     eax, [ebx+38h]
    cmp     eax, ebp
    jle     short loc_461F61
    mov     ecx, [ebx+3Ch]
    dec     eax
    inc     ecx
    mov     [ebx+38h], eax
    mov     eax, ecx
    mov     [ebx+3Ch], ecx
    cmp     eax, 400h
    jl      short loc_461F61
    mov     [ebx+3Ch], ebp

    loc_461F61:                             ; CODE XREF: sub_461DB0+198j
                                            ; sub_461DB0+1ACj
    cmp     [ebx+38h], ebp
    jnz     short loc_461F43

    loc_461F66:                             ; CODE XREF: sub_461DB0+191j
    mov     [ebx+20h], ebp
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_461F78:                             ; CODE XREF: sub_461DB0+88j
                                            ; sub_461DB0+B8j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 20h
    retn    10h
    sub_461DB0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx+38h]
    xor     edx, edx
    cmp     eax, 400h
    mov     eax, [esp+4]
    jge     short loc_461FC2
    push    esi
    mov     esi, [ecx+40h]
    inc     esi
    cmp     esi, 400h
    mov     [ecx+40h], esi
    jl      short loc_461FB3
    mov     [ecx+40h], edx

    loc_461FB3:                             ; CODE XREF: .text:00461FAEj
    mov     esi, [ecx+40h]
    mov     [ecx+esi*4+44h], eax
    mov     esi, [ecx+38h]
    inc     esi
    mov     [ecx+38h], esi
    pop     esi

    loc_461FC2:                             ; CODE XREF: .text:00461F9Ej
    mov     [eax+10h], edx
    mov     eax, [eax+8]
    add     [ecx+20h], eax
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_461FD0 proc near                    ; CODE XREF: sub_461B10+A2p
                                            ; sub_461C20+BEp

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     eax, [ebx+2Ch]
    mov     ecx, [ebx+0Ch]
    push    edi
    push    eax
    push    ecx
    push    offset aCurrentBufferP          ; "current buffer pool count: %d, current "...
    call    nullsub_13
    mov     edx, [esp+34h+arg_4]
    mov     esi, [esp+34h+arg_0]
    add     esp, 0Ch
    push    edx
    push    esi
    push    offset aBufsToGrowByDP          ; "bufs to grow by: %d, packets to grow by"...
    call    nullsub_13
    mov     eax, [ebx+1Ch]
    mov     ecx, [ebx]
    add     esp, 0Ch
    push    eax
    push    ecx
    push    offset aCurrentBuffe_0          ; "current buffer pool ix: %d, current pac"...
    call    nullsub_13
    mov     eax, [ebx+0Ch]
    add     esp, 0Ch
    test    eax, eax
    jbe     loc_462358
    mov     ecx, [ebx+2Ch]
    test    ecx, ecx
    jbe     loc_462358
    add     eax, esi
    mov     [esp+28h+arg_0], eax
    lea     esi, ds:0[eax*4]
    push    esi                             ; int
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jz      loc_46234C
    mov     ecx, esi
    xor     eax, eax
    mov     edx, ecx
    mov     edi, ebp
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     ecx, [ebx]
    test    ecx, ecx
    jl      short loc_462091
    mov     eax, [ebx+0Ch]
    xor     edx, edx
    test    eax, eax
    jbe     short loc_4620AA
    mov     esi, ebp

    loc_462074:                             ; CODE XREF: sub_461FD0+BDj
    inc     ecx
    cmp     ecx, eax
    jb      short loc_46207B
    xor     ecx, ecx

    loc_46207B:                             ; CODE XREF: sub_461FD0+A7j
    mov     eax, [ebx+8]
    inc     edx
    add     esi, 4
    mov     eax, [eax+ecx*4]
    mov     [esi-4], eax
    mov     eax, [ebx+0Ch]
    cmp     edx, eax
    jb      short loc_462074
    jmp     short loc_4620AA
    ; ---------------------------------------------------------------------------

    loc_462091:                             ; CODE XREF: sub_461FD0+97j
    mov     ecx, [ebx+0Ch]
    mov     esi, [ebx+8]
    shl     ecx, 2
    mov     edx, ecx
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4620AA:                             ; CODE XREF: sub_461FD0+A0j
                                            ; sub_461FD0+BFj
    mov     eax, [ebx+0Ch]
    mov     esi, 1
    dec     eax
    mov     [ebx], eax

    loc_4620B5:                             ; CODE XREF: sub_461FD0+134j
    mov     ecx, [esp+28h+arg_0]
    mov     eax, [ebx+0Ch]
    cmp     eax, ecx
    jnb     short loc_462106
    push    43Eh                            ; int
    call    sub_4B4F10
    xor     edi, edi
    add     esp, 4
    cmp     eax, edi
    jz      short loc_4620E7
    mov     [eax], ebx
    mov     dword ptr [eax+4], 0FFFFFFFFh
    mov     [eax+8], edi
    mov     [eax+0Ch], edi
    mov     [eax+10h], edi
    jmp     short loc_4620E9
    ; ---------------------------------------------------------------------------

    loc_4620E7:                             ; CODE XREF: sub_461FD0+101j
    xor     eax, eax

    loc_4620E9:                             ; CODE XREF: sub_461FD0+115j
    mov     edx, [ebx+0Ch]
    xor     ecx, ecx
    mov     [ebp+edx*4+0], eax
    mov     eax, [ebx+0Ch]
    cmp     [ebp+eax*4+0], edi
    setnz   cl
    mov     esi, ecx
    inc     eax
    cmp     esi, edi
    mov     [ebx+0Ch], eax
    jnz     short loc_4620B5

    loc_462106:                             ; CODE XREF: sub_461FD0+EEj
    mov     edx, [ebx+8]
    push    edx
    call    sub_4B4F20
    xor     edi, edi
    add     esp, 4
    cmp     esi, edi
    mov     [ebx+8], ebp
    jz      loc_46234C
    mov     eax, [esp+28h+arg_4]
    mov     edx, [ebx+2Ch]
    add     eax, edx
    mov     esi, eax
    shl     eax, 5
    push    eax                             ; int
    mov     [esp+2Ch+var_4], esi
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    jz      short loc_46216D
    lea     edx, [esi-1]
    cmp     edx, edi
    jl      short loc_462167
    lea     ecx, [eax+8]
    inc     edx

    loc_462149:                             ; CODE XREF: sub_461FD0+195j
    mov     [ecx-4], edi
    mov     [ecx], edi
    mov     [ecx+4], edi
    mov     dword ptr [ecx+8], 0FFFFFFFFh
    mov     [ecx+0Ch], edi
    mov     [ecx+10h], edi
    mov     [ecx+14h], edi
    add     ecx, 20h
    dec     edx
    jnz     short loc_462149

    loc_462167:                             ; CODE XREF: sub_461FD0+173j
    mov     [esp+28h+var_18], eax
    jmp     short loc_462171
    ; ---------------------------------------------------------------------------

    loc_46216D:                             ; CODE XREF: sub_461FD0+16Cj
    mov     [esp+28h+var_18], edi

    loc_462171:                             ; CODE XREF: sub_461FD0+19Bj
    mov     ebp, [esp+28h+var_18]
    cmp     ebp, edi
    jz      loc_46234C
    mov     eax, [ebx]
    xor     esi, esi
    cmp     eax, edi
    mov     [esp+28h+var_14], esi
    jl      loc_462313
    mov     eax, [ebx+0Ch]
    xor     ecx, ecx
    cmp     eax, edi
    mov     [ebx+34h], edi
    mov     [ebx+30h], edi
    mov     [esp+28h+var_10], ecx
    jbe     loc_462313

    loc_4621A4:                             ; CODE XREF: sub_461FD0+33Dj
    mov     edx, [ebx+8]
    mov     edx, [edx+ecx*4]
    mov     [esp+28h+var_8], edx
    cmp     [edx+8], edi
    jle     loc_462303
    mov     eax, [edx+10h]
    cmp     eax, edi
    mov     [esp+28h+arg_4], eax
    jz      loc_4622F9
    mov     [edx+4], esi
    mov     [esp+28h+arg_0], edi
    shl     esi, 5
    lea     ecx, [esi+ebp]
    mov     [edx+10h], ecx
    jmp     short loc_4621E2
    ; ---------------------------------------------------------------------------

    loc_4621D8:                             ; CODE XREF: sub_461FD0+30Cj
    mov     eax, [esp+28h+arg_4]
    mov     ecx, [esp+28h+var_C]
    xor     edi, edi

    loc_4621E2:                             ; CODE XREF: sub_461FD0+206j
    cmp     [eax+0Ch], edx
    jnz     loc_4622E4
    mov     edi, [esp+28h+var_14]
    mov     ebp, ecx
    inc     edi
    add     ecx, 20h
    mov     [esp+28h+var_14], edi
    mov     [esp+28h+var_C], ecx
    mov     ecx, 8
    mov     esi, eax
    mov     edi, ebp
    rep movsd
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jl      loc_4622A3
    mov     dword ptr [eax+10h], 0FFFFFFFFh
    call    sub_4B6340
    mov     ecx, [esp+28h+arg_4]
    lea     esi, [ebx+38h]
    mov     [ecx+14h], eax
    mov     edi, [esi]
    mov     edx, edi
    dec     edi
    test    edx, edx
    jle     short loc_46224E

    loc_462232:                             ; CODE XREF: sub_461FD0+27Cj
    mov     ecx, esi
    call    sub_4623B0
    cmp     eax, [esp+28h+arg_4]
    jz      short loc_46224E
    push    eax
    mov     ecx, esi
    call    sub_462370
    mov     eax, edi
    dec     edi
    test    eax, eax
    jg      short loc_462232

    loc_46224E:                             ; CODE XREF: sub_461FD0+260j
                                            ; sub_461FD0+26Dj
    mov     ecx, [esp+28h+arg_4]
    mov     edx, [ecx+8]
    mov     ecx, [ebx+20h]
    sub     ecx, edx
    mov     [ebx+20h], ecx
    mov     eax, [esi]
    cmp     eax, 400h
    jge     short loc_462289
    mov     ecx, [esi+8]
    inc     ecx
    mov     eax, ecx
    mov     [esi+8], ecx
    cmp     eax, 400h
    jl      short loc_46227D
    mov     dword ptr [esi+8], 0

    loc_46227D:                             ; CODE XREF: sub_461FD0+2A4j
    mov     eax, [esi+8]
    mov     [esi+eax*4+0Ch], ebp
    mov     eax, [esi]
    inc     eax
    mov     [esi], eax

    loc_462289:                             ; CODE XREF: sub_461FD0+294j
    mov     ecx, [ebp+8]
    mov     edx, [esp+28h+var_8]
    mov     dword ptr [ebp+10h], 0
    mov     eax, [ebx+20h]
    add     eax, ecx
    mov     [ebx+20h], eax
    mov     eax, [esp+28h+arg_4]

    loc_4622A3:                             ; CODE XREF: sub_461FD0+23Dj
    mov     ecx, [ebx+34h]
    mov     [ebp+0Ch], edx
    mov     [ebp+18h], ecx
    mov     dword ptr [ebp+1Ch], 0
    mov     ecx, [ebx+34h]
    test    ecx, ecx
    jz      short loc_4622BD
    mov     [ecx+1Ch], ebp

    loc_4622BD:                             ; CODE XREF: sub_461FD0+2E8j
    mov     ecx, [ebx+30h]
    mov     [ebx+34h], ebp
    test    ecx, ecx
    jnz     short loc_4622CA
    mov     [ebx+30h], ebp

    loc_4622CA:                             ; CODE XREF: sub_461FD0+2F5j
    mov     esi, [esp+28h+arg_0]
    mov     eax, [eax+1Ch]
    inc     esi
    mov     [esp+28h+arg_4], eax
    test    eax, eax
    mov     [esp+28h+arg_0], esi
    jnz     loc_4621D8
    xor     edi, edi

    loc_4622E4:                             ; CODE XREF: sub_461FD0+215j
    mov     eax, [esp+28h+arg_0]
    mov     ebp, [esp+28h+var_18]
    mov     esi, [esp+28h+var_14]
    mov     ecx, [esp+28h+var_10]
    mov     [edx+8], eax
    jmp     short loc_462303
    ; ---------------------------------------------------------------------------

    loc_4622F9:                             ; CODE XREF: sub_461FD0+1F0j
    mov     dword ptr [edx+4], 0FFFFFFFFh
    mov     [edx+8], edi

    loc_462303:                             ; CODE XREF: sub_461FD0+1E1j
                                            ; sub_461FD0+327j
    mov     eax, [ebx+0Ch]
    inc     ecx
    cmp     ecx, eax
    mov     [esp+28h+var_10], ecx
    jb      loc_4621A4

    loc_462313:                             ; CODE XREF: sub_461FD0+1B7j
                                            ; sub_461FD0+1CEj
    mov     ecx, [ebx+28h]
    push    ecx
    call    sub_4B4F20
    mov     edx, [esp+2Ch+var_4]
    add     esp, 4
    lea     eax, [esi-1]
    mov     [ebx+28h], ebp
    push    eax
    push    offset aCurrentPacketP          ; "current packet pool index set to: %ld\n"
    mov     [ebx+2Ch], edx
    mov     [ebx+1Ch], eax
    call    nullsub_13
    add     esp, 8
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46234C:                             ; CODE XREF: sub_461FD0+79j
                                            ; sub_461FD0+149j ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_462358:                             ; CODE XREF: sub_461FD0+4Ej
                                            ; sub_461FD0+59j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 18h
    retn    8
    sub_461FD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_462370 proc near                    ; CODE XREF: sub_461FD0+272p
                                            ; sub_462AE0+73p

    arg_0= dword ptr  4

    cmp     dword ptr [ecx], 400h
    jge     short loc_4623A7
    mov     edx, [ecx+8]
    inc     edx
    mov     eax, edx
    mov     [ecx+8], edx
    cmp     eax, 400h
    jl      short loc_46238F
    mov     dword ptr [ecx+8], 0

    loc_46238F:                             ; CODE XREF: sub_462370+16j
    mov     eax, [ecx+8]
    mov     edx, [esp+arg_0]
    mov     [ecx+eax*4+0Ch], edx
    mov     eax, [ecx]
    inc     eax
    mov     [ecx], eax
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4623A7:                             ; CODE XREF: sub_462370+6j
    xor     eax, eax
    retn    4
    sub_462370 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4623B0 proc near                    ; CODE XREF: sub_461FD0+264p
                                            ; sub_462AE0+67p
    mov     eax, [ecx]
    test    eax, eax
    jle     short loc_4623D4
    mov     edx, [ecx+4]
    dec     eax
    mov     [ecx], eax
    mov     eax, [ecx+edx*4+0Ch]
    inc     edx
    cmp     edx, 400h
    mov     [ecx+4], edx
    jl      short locret_4623D6
    mov     dword ptr [ecx+4], 0
    retn
    ; ---------------------------------------------------------------------------

    loc_4623D4:                             ; CODE XREF: sub_4623B0+4j
    xor     eax, eax

    locret_4623D6:                          ; CODE XREF: sub_4623B0+1Aj
    retn
    sub_4623B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    mov     ebx, [esp+8]
    push    ebp
    push    esi
    push    edi
    mov     esi, ecx
    mov     dword ptr [ebx+10h], 0FFFFFFFFh
    call    sub_4B6340
    mov     [ebx+14h], eax
    mov     ebp, [esi+38h]
    mov     eax, ebp
    dec     ebp
    test    eax, eax
    jle     short loc_462457
    xor     edi, edi
    mov     edx, 400h

    loc_46240A:                             ; CODE XREF: .text:00462455j
    mov     eax, [esi+38h]
    cmp     eax, edi
    jle     short loc_462429
    dec     eax
    mov     [esi+38h], eax
    mov     eax, [esi+3Ch]
    mov     ecx, [esi+eax*4+44h]
    inc     eax
    cmp     eax, edx
    mov     [esi+3Ch], eax
    jl      short loc_46242B
    mov     [esi+3Ch], edi
    jmp     short loc_46242B
    ; ---------------------------------------------------------------------------

    loc_462429:                             ; CODE XREF: .text:0046240Fj
    xor     ecx, ecx

    loc_46242B:                             ; CODE XREF: .text:00462422j
                                            ; .text:00462427j
    cmp     ecx, ebx
    jz      short loc_462457
    cmp     [esi+38h], edx
    jge     short loc_462450
    mov     eax, [esi+40h]
    inc     eax
    cmp     eax, edx
    mov     [esi+40h], eax
    jl      short loc_462442
    mov     [esi+40h], edi

    loc_462442:                             ; CODE XREF: .text:0046243Dj
    mov     eax, [esi+40h]
    mov     [esi+eax*4+44h], ecx
    mov     eax, [esi+38h]
    inc     eax
    mov     [esi+38h], eax

    loc_462450:                             ; CODE XREF: .text:00462432j
    mov     ecx, ebp
    dec     ebp
    test    ecx, ecx
    jg      short loc_46240A

    loc_462457:                             ; CODE XREF: .text:00462401j
                                            ; .text:0046242Dj
    mov     edx, [ebx+8]
    mov     eax, [esi+20h]
    sub     eax, edx
    pop     edi
    mov     [esi+20h], eax
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    push    64h
    push    2
    push    0C8h
    mov     esi, ecx
    push    0FFFFFFFFh
    call    sub_461DB0
    mov     dword ptr [esi], 0FFFFFFFFh
    mov     dword ptr [esi+1Ch], 0FFFFFFFFh
    mov     dword ptr [esi+24h], 0
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4624A0 proc near                    ; CODE XREF: sub_4618A0+2Ap
                                            ; sub_462710+1Cp

    var_8= dword ptr -8
    dwDataSize= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     esi, ecx
    call    sub_4B6340
    mov     ecx, [esi+4]
    mov     edx, [esi+14h]
    mov     edi, eax
    mov     eax, [esi+24h]
    push    edi
    push    eax
    push    ecx
    push    edx
    push    offset aPlayerLdTicksB          ; "player: %ld, ticks betw sends=%lu, next"...
    call    nullsub_13
    mov     eax, [esi+24h]
    add     esp, 14h
    cmp     edi, eax
    jnb     short loc_4624E1
    mov     eax, [esp+18h+arg_0]
    xor     ebx, ebx
    cmp     eax, ebx
    jz      loc_4626CB
    jmp     short loc_4624E3
    ; ---------------------------------------------------------------------------

    loc_4624E1:                             ; CODE XREF: sub_4624A0+2Fj
    xor     ebx, ebx

    loc_4624E3:                             ; CODE XREF: sub_4624A0+3Fj
    mov     edx, [esi+4]
    mov     eax, [esi+38h]
    add     edi, edx
    cmp     eax, ebx
    mov     [esi+24h], edi
    mov     [esp+18h+var_8], eax
    jz      loc_4626CB

    loc_4624FA:                             ; CODE XREF: sub_4624A0+20Aj
    cmp     [esi+38h], ebx
    jle     short loc_462508
    mov     eax, [esi+3Ch]
    mov     eax, [esi+eax*4+44h]
    jmp     short loc_46250A
    ; ---------------------------------------------------------------------------

    loc_462508:                             ; CODE XREF: sub_4624A0+5Dj
    xor     eax, eax

    loc_46250A:                             ; CODE XREF: sub_4624A0+66j
    mov     edx, [esi+10h]
    mov     ecx, [eax]
    xor     edi, edi
    push    edx
    push    offset aAssigningPacke          ; "assigning packets to frame number: %ld\n"...
    mov     [esp+20h+dwDataSize], ecx
    mov     [esp+20h+arg_0], edi
    call    nullsub_13
    mov     eax, [esp+20h+var_8]
    add     esp, 8
    xor     ebp, ebp
    cmp     eax, ebx
    jle     loc_462602

    loc_462535:                             ; CODE XREF: sub_4624A0+158j
    cmp     [esi+38h], ebx
    jle     short loc_462543
    mov     eax, [esi+3Ch]
    mov     edi, [esi+eax*4+44h]
    jmp     short loc_462545
    ; ---------------------------------------------------------------------------

    loc_462543:                             ; CODE XREF: sub_4624A0+98j
    xor     edi, edi

    loc_462545:                             ; CODE XREF: sub_4624A0+A1j
    mov     eax, [esi+38h]
    cmp     eax, ebx
    jle     short loc_462567
    mov     edx, [esi+3Ch]
    dec     eax
    inc     edx
    mov     [esi+38h], eax
    mov     eax, 400h
    mov     ecx, edx
    cmp     ecx, eax
    mov     [esi+3Ch], edx
    jl      short loc_46256C
    mov     [esi+3Ch], ebx
    jmp     short loc_46256C
    ; ---------------------------------------------------------------------------

    loc_462567:                             ; CODE XREF: sub_4624A0+AAj
    mov     eax, 400h

    loc_46256C:                             ; CODE XREF: sub_4624A0+C0j
                                            ; sub_4624A0+C5j
    mov     ecx, [esp+18h+dwDataSize]
    mov     edx, [edi]
    cmp     edx, ecx
    jnz     short loc_4625CE
    mov     edx, [edi+4]
    mov     eax, [edi+0Ch]
    add     eax, edx
    xor     edx, edx
    mov     dl, [eax+14h]
    lea     ecx, [eax+15h]
    mov     eax, [edi+8]
    push    ecx
    push    edx
    push    eax
    push    offset aExtractedPacke          ; "extracted packet (len=%ld, type=%d, dat"...
    call    nullsub_13
    mov     ecx, [esi+10h]
    add     esp, 10h
    mov     [edi+10h], ecx
    call    sub_4B6340
    mov     edx, [edi+8]
    mov     ecx, [edi+0Ch]
    mov     [edi+14h], eax
    mov     eax, [edi+4]
    push    edx
    lea     edx, [eax+ecx+14h]
    mov     ecx, offset dword_513000
    push    edx
    call    sub_4614E0
    test    eax, eax
    jz      loc_4626BF
    inc     [esp+18h+arg_0]
    jmp     short loc_4625F1
    ; ---------------------------------------------------------------------------

    loc_4625CE:                             ; CODE XREF: sub_4624A0+D4j
    cmp     [esi+38h], eax
    jge     short loc_4625F1
    mov     edx, [esi+40h]
    inc     edx
    mov     ecx, edx
    mov     [esi+40h], edx
    cmp     ecx, eax
    jl      short loc_4625E3
    mov     [esi+40h], ebx

    loc_4625E3:                             ; CODE XREF: sub_4624A0+13Ej
    mov     eax, [esi+40h]
    mov     [esi+eax*4+44h], edi
    mov     eax, [esi+38h]
    inc     eax
    mov     [esi+38h], eax

    loc_4625F1:                             ; CODE XREF: sub_4624A0+12Cj
                                            ; sub_4624A0+131j
    mov     eax, [esp+18h+var_8]
    inc     ebp
    cmp     ebp, eax
    jl      loc_462535
    mov     edi, [esp+18h+arg_0]

    loc_462602:                             ; CODE XREF: sub_4624A0+8Fj
    cmp     edi, ebx
    mov     [esi+20h], ebx
    jle     loc_4626A1
    mov     ecx, [esi+10h]
    push    ecx
    push    edi
    push    offset aSendingLdPacke          ; "sending %ld packets in frame: %ld\n"
    call    nullsub_13
    mov     eax, [esi+14h]
    add     esp, 0Ch
    cmp     eax, ebx
    jz      short loc_46262B
    or      eax, 0FFFFFFFFh
    jmp     short loc_46262E
    ; ---------------------------------------------------------------------------

    loc_46262B:                             ; CODE XREF: sub_4624A0+184j
    mov     eax, [esi+10h]

    loc_46262E:                             ; CODE XREF: sub_4624A0+189j
    mov     edx, dword_51E2F4
    mov     [edx], eax
    mov     edi, dword_51E2F8
    mov     ebx, [esi+14h]
    mov     ebp, dword_51E2F4
    push    edi
    push    ebx
    push    offset aBytesToSendToD          ; "bytes to send to (DPID)(%ld): %ld\n"
    call    nullsub_13
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+24h+dwDataSize]
    add     esp, 0Ch
    add     ecx, 14h
    push    edi                             ; int
    push    ebp                             ; int
    push    ebx                             ; int
    push    eax                             ; dwDataSize
    push    ecx                             ; HAPINET_this
    mov     ecx, offset dword_5129D0
    call    sub_4626E0
    mov     edx, dword_51E2F4
    neg     edx
    sbb     edx, edx
    and     edx, 4
    mov     dword_51E2F8, edx
    mov     ecx, [esi+10h]
    dec     ecx
    mov     eax, ecx
    mov     [esi+10h], ecx
    cmp     eax, 0FFFFFFFFh
    jl      short loc_462698
    mov     dword ptr [esi+10h], 0FFFFFFFEh

    loc_462698:                             ; CODE XREF: sub_4624A0+1EFj
    mov     eax, [esi+38h]
    test    eax, eax
    jz      short loc_4626CB
    xor     ebx, ebx

    loc_4626A1:                             ; CODE XREF: sub_4624A0+167j
    mov     eax, [esi+38h]
    cmp     eax, ebx
    mov     [esp+18h+var_8], eax
    jnz     loc_4624FA
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4626BF:                             ; CODE XREF: sub_4624A0+122j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4626CB:                             ; CODE XREF: sub_4624A0+39j
                                            ; sub_4624A0+54j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 8
    retn    4
    sub_4624A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4626E0(int HAPINET_this,int dwDataSize,int,int,int)
    sub_4626E0 proc near                    ; CODE XREF: sub_4624A0+1CBp

    HAPINET_this= dword ptr  4
    dwDataSize= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     edx, [esp+arg_C]
    mov     eax, [esp+arg_8]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+4+arg_10]
    push    ecx
    push    edx
    mov     ecx, esi
    mov     [esi+21h], eax
    call    sub_44F940
    mov     eax, [esp+4+dwDataSize]
    mov     ecx, [esp+4+HAPINET_this]
    push    eax                             ; dwDataSize
    push    ecx                             ; HAPINET_this
    mov     ecx, esi
    call    Network_SendNetMessage
    pop     esi
    retn    14h
    sub_4626E0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_462710 proc near                    ; CODE XREF: sub_461990+13p
                                            ; sub_4619B0+21p

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h
    arg_8= dword ptr  18h

    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    cmp     dword ptr [esi+20h], 42Ah
    jnb     short loc_462728
    cmp     dword ptr [esi+38h], 400h
    jnz     short loc_46273C

    loc_462728:                             ; CODE XREF: sub_462710+Dj
    push    1
    mov     ecx, esi
    call    sub_4624A0
    mov     eax, [esi+38h]
    test    eax, eax
    jnz     loc_46284B

    loc_46273C:                             ; CODE XREF: sub_462710+16j
    mov     eax, [esi]
    xor     ebx, ebx
    test    eax, eax
    jl      short loc_46274A
    mov     ecx, [esi+8]
    mov     ebx, [ecx+eax*4]

    loc_46274A:                             ; CODE XREF: sub_462710+32j
    test    ebx, ebx
    jnz     short loc_46275F
    mov     ecx, esi
    call    sub_461B10
    mov     ebx, eax
    test    ebx, ebx
    jz      loc_46284B

    loc_46275F:                             ; CODE XREF: sub_462710+3Cj
    mov     edx, [esp+4+arg_0]
    mov     ecx, esi
    push    edx
    call    sub_461C20
    mov     edi, eax
    test    edi, edi
    jz      loc_46284B
    mov     eax, [esi+34h]
    mov     ecx, [esp+4+arg_8]
    mov     edx, [esp+4+arg_4]
    push    eax
    mov     eax, [esi+1Ch]
    push    ecx
    push    edx
    push    eax
    push    edi
    mov     ecx, ebx
    call    sub_4628D0
    mov     ebp, eax
    test    ebp, ebp
    jnz     short loc_4627DB
    mov     ecx, [esi+1Ch]
    dec     ecx
    mov     [esi+1Ch], ecx
    mov     ecx, esi
    call    sub_461B10
    mov     ebx, eax
    test    ebx, ebx
    jz      short loc_4627DB
    mov     ecx, [esp+4+arg_0]
    push    ecx
    mov     ecx, esi
    call    sub_461C20
    mov     edi, eax
    test    edi, edi
    jz      short loc_4627D9
    mov     edx, [esi+34h]
    mov     eax, [esp+4+arg_8]
    mov     ecx, [esp+4+arg_4]
    push    edx
    mov     edx, [esi+1Ch]
    push    eax
    push    ecx
    push    edx
    push    edi
    mov     ecx, ebx
    call    sub_4628D0
    mov     ebp, eax
    jmp     short loc_4627DB
    ; ---------------------------------------------------------------------------

    loc_4627D9:                             ; CODE XREF: sub_462710+A9j
    xor     ebp, ebp

    loc_4627DB:                             ; CODE XREF: sub_462710+83j
                                            ; sub_462710+97j ...
    xor     ecx, ecx
    cmp     ebp, ecx
    jz      short loc_46283A
    cmp     [esi+30h], ecx
    jnz     short loc_4627E9
    mov     [esi+30h], edi

    loc_4627E9:                             ; CODE XREF: sub_462710+D4j
    mov     eax, [esi+34h]
    cmp     eax, ecx
    jz      short loc_4627F3
    mov     [eax+1Ch], edi

    loc_4627F3:                             ; CODE XREF: sub_462710+DEj
    mov     [esi+34h], edi
    mov     edx, [esi+38h]
    mov     eax, 400h
    cmp     edx, eax
    jge     short loc_462820
    mov     ebx, [esi+40h]
    inc     ebx
    mov     edx, ebx
    mov     [esi+40h], ebx
    cmp     edx, eax
    jl      short loc_462812
    mov     [esi+40h], ecx

    loc_462812:                             ; CODE XREF: sub_462710+FDj
    mov     eax, [esi+40h]
    mov     [esi+eax*4+44h], edi
    mov     eax, [esi+38h]
    inc     eax
    mov     [esi+38h], eax

    loc_462820:                             ; CODE XREF: sub_462710+F0j
    mov     [edi+10h], ecx
    mov     ecx, [edi+8]
    mov     eax, [esi+20h]
    add     eax, ecx
    mov     [esi+20h], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46283A:                             ; CODE XREF: sub_462710+CFj
    cmp     ebx, ecx
    jz      short loc_46284B
    cmp     [edi+0Ch], ebx
    jnz     short loc_46284B
    push    edi
    mov     ecx, ebx
    call    sub_462AE0

    loc_46284B:                             ; CODE XREF: sub_462710+26j
                                            ; sub_462710+49j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    0Ch
    sub_462710 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_462860 proc near                    ; CODE XREF: sub_460E20+5Fp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    cmp     eax, 0EA60h
    jbe     short loc_462872
    mov     eax, 0EA60h
    jmp     short loc_46287E
    ; ---------------------------------------------------------------------------

    loc_462872:                             ; CODE XREF: sub_462860+9j
    cmp     eax, 0FA0h
    jnb     short loc_46287E
    mov     eax, 0FA0h

    loc_46287E:                             ; CODE XREF: sub_462860+10j
                                            ; sub_462860+17j
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax+3E7h]
    mov     eax, 10624DD3h
    mul     edx
    shr     edx, 6
    mov     [ecx+18h], edx
    retn    4
    sub_462860 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4628A0 proc near                    ; CODE XREF: sub_460E20+6Bp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax+3E7h]
    mov     eax, 10624DD3h
    mul     edx
    shr     edx, 6
    mov     [ecx+4], edx
    retn    4
    sub_4628A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4628D0 proc near                    ; CODE XREF: sub_462710+7Ap
                                            ; sub_462710+C0p

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h
    arg_8= dword ptr  18h
    arg_C= dword ptr  1Ch
    arg_10= dword ptr  20h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_8]
    mov     ebx, ecx
    mov     ecx, [esp+arg_4]
    lea     eax, [esi+1]
    push    eax
    push    ecx
    push    offset aAddingPacketLd          ; "adding packet %ld (data=\"%s\")\n"
    call    nullsub_13
    mov     ebp, [esp+0Ch+arg_C]
    mov     edx, [ebx+0Ch]
    add     esp, 0Ch
    push    42Ah
    push    ebp
    push    edx
    push    offset aCurrentBufferL          ; "current buffer length: %ld, toadd=%ld, "...
    call    nullsub_13
    mov     eax, [ebx+0Ch]
    add     esp, 10h
    lea     ecx, [ebp+eax+0]
    cmp     ecx, 42Ah
    ja      short loc_462996
    mov     ecx, ebp
    push    edi
    mov     edx, ecx
    lea     edi, [ebx+eax+14h]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [esp+4+arg_0]
    mov     eax, [ebx+0Ch]
    mov     [esi+4], eax
    mov     eax, [esp+4+arg_10]
    mov     [esi+0Ch], ebx
    mov     [esi+8], ebp
    mov     [esi+18h], eax
    mov     dword ptr [esi+1Ch], 0
    mov     eax, [ebx+8]
    mov     edx, [ebx+0Ch]
    add     edx, ebp
    lea     ecx, [eax+1]
    mov     [ebx+0Ch], edx
    test    eax, eax
    mov     [ebx+8], ecx
    jnz     short loc_462979
    mov     eax, [esp+4+arg_4]
    push    eax
    push    offset aSetFirstPacket          ; "set first packet ix to: %ld\n"
    mov     [ebx+4], eax
    call    nullsub_13
    add     esp, 8
    mov     [ebx+10h], esi

    loc_462979:                             ; CODE XREF: sub_4628D0+8Fj
    mov     edx, [ebx+8]
    push    edx
    push    offset aAssignedPacket          ; "assigned packet count this buf: %ld\n"
    call    nullsub_13
    add     esp, 8
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_462996:                             ; CODE XREF: sub_4628D0+47j
    push    offset aOutOfSpaceInBu          ; "out of space in buffer!\n"
    call    nullsub_13
    add     esp, 4
    xor     eax, eax
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    sub_4628D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4629B0 proc near                    ; CODE XREF: sub_461B10+CCp
                                            ; sub_461B10+DFp ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebp
    mov     ebp, ecx
    push    esi
    xor     eax, eax
    mov     esi, [ebp+8]
    mov     [esp+10h+var_4], ebp
    cmp     esi, eax
    jle     short loc_462A2A
    mov     ecx, [ebp+4]
    mov     eax, [ebp+0]
    push    edi
    push    ebx
    mov     ebx, [eax+2Ch]
    push    esi
    push    ecx
    push    offset aFreeingPackets          ; "freeing packets assigned. range: %ld fo"...
    call    nullsub_13
    mov     edx, [ebp+0]
    mov     edi, [ebp+4]
    add     esp, 0Ch
    mov     [esp+18h+var_8], esi
    mov     ebp, [edx+28h]

    loc_4629EB:                             ; CODE XREF: sub_4629B0+70j
    push    edi
    push    offset aInitializeFree          ; "initialize freeing packet %ld\n"
    call    nullsub_13
    mov     esi, edi
    add     esp, 8
    shl     esi, 5
    add     esi, ebp
    inc     edi
    push    esi
    mov     ecx, [esi+0Ch]
    call    sub_462AE0
    cmp     edi, ebx
    mov     dword ptr [esi+0Ch], 0
    jb      short loc_462A17
    xor     edi, edi

    loc_462A17:                             ; CODE XREF: sub_4629B0+63j
    mov     eax, [esp+18h+var_8]
    dec     eax
    mov     [esp+18h+var_8], eax
    jnz     short loc_4629EB
    mov     ebp, [esp+18h+var_4]
    pop     ebx
    xor     eax, eax
    pop     edi

    loc_462A2A:                             ; CODE XREF: sub_4629B0+12j
    mov     [ebp+0Ch], eax
    mov     [ebp+8], eax
    mov     dword ptr [ebp+4], 0FFFFFFFFh
    mov     [ebp+10h], eax
    pop     esi
    pop     ebp
    add     esp, 8
    retn
    sub_4629B0 endp

    ; ---------------------------------------------------------------------------
    mov     eax, [ecx+8]
    test    eax, eax
    jz      short locret_462A5A
    mov     eax, [ecx+10h]
    test    eax, eax
    jz      short locret_462A5A

    loc_462A4E:                             ; CODE XREF: .text:00462A58j
    cmp     [eax+0Ch], ecx
    jnz     short locret_462A5A
    mov     eax, [eax+1Ch]
    test    eax, eax
    jnz     short loc_462A4E

    locret_462A5A:                          ; CODE XREF: .text:00462A45j
                                            ; .text:00462A4Cj ...
    retn
    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     eax, [ebp+8]
    test    eax, eax
    jz      short loc_462AC3
    mov     esi, [ebp+10h]
    call    sub_4B6340
    mov     ebx, eax
    mov     eax, [esp+14h]
    mov     edi, ebx
    sub     edi, eax
    push    edi
    push    eax
    push    ebx
    push    offset aCurGameTimeLdM          ; "cur game time: %ld, min retain=%ld, mus"...
    call    nullsub_13
    add     esp, 10h
    test    esi, esi
    jz      short loc_462AB1

    loc_462A93:                             ; CODE XREF: .text:00462AAFj
    cmp     [esi+0Ch], ebp
    jnz     short loc_462AB1
    mov     eax, [esi+10h]
    test    eax, eax
    jge     short loc_462ACF
    mov     eax, [esi+14h]
    cmp     eax, edi
    jle     short loc_462AAA
    cmp     eax, ebx
    jbe     short loc_462ACF

    loc_462AAA:                             ; CODE XREF: .text:00462AA4j
    mov     esi, [esi+1Ch]
    test    esi, esi
    jnz     short loc_462A93

    loc_462AB1:                             ; CODE XREF: .text:00462A91j
                                            ; .text:00462A96j
    mov     eax, [esp+14h]
    push    eax
    push    offset aBufferEligible          ; "buffer eligible for reuse:  all packets"...
    call    nullsub_13
    add     esp, 8

    loc_462AC3:                             ; CODE XREF: .text:00462A6Bj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_462ACF:                             ; CODE XREF: .text:00462A9Dj
                                            ; .text:00462AA8j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_462AE0 proc near                    ; CODE XREF: sub_462710+136p
                                            ; sub_4629B0+55p ...

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    mov     ebp, ecx
    push    edi
    mov     eax, [esi+4]
    mov     ecx, [esi+0Ch]
    add     eax, ecx
    xor     ecx, ecx
    mov     cl, [eax+14h]
    lea     edx, [eax+15h]
    push    edx
    mov     edx, [esi+8]
    push    ecx
    push    edx
    push    offset aRemovingPacket          ; "removing packet (len=%ld, type=%d, data"...
    call    nullsub_13
    mov     eax, [esi+10h]
    xor     ecx, ecx
    add     esp, 10h
    cmp     eax, ecx
    jl      short loc_462B70
    push    offset aWarningRemovep          ; "Warning! RemovePacket called for packet"...
    call    nullsub_13
    mov     edi, [ebp+0]
    add     esp, 4
    mov     [esp+4+arg_0], edi
    mov     dword ptr [esi+10h], 0FFFFFFFFh
    call    sub_4B6340
    add     edi, 38h
    mov     [esi+14h], eax
    mov     ebx, [edi]
    mov     eax, ebx
    dec     ebx
    test    eax, eax
    jle     short loc_462B5F

    loc_462B45:                             ; CODE XREF: sub_462AE0+7Dj
    mov     ecx, edi
    call    sub_4623B0
    cmp     eax, esi
    jz      short loc_462B5F
    push    eax
    mov     ecx, edi
    call    sub_462370
    mov     ecx, ebx
    dec     ebx
    test    ecx, ecx
    jg      short loc_462B45

    loc_462B5F:                             ; CODE XREF: sub_462AE0+63j
                                            ; sub_462AE0+6Ej
    mov     eax, [esp+4+arg_0]
    mov     edx, [esi+8]
    mov     ecx, [eax+20h]
    sub     ecx, edx
    mov     [eax+20h], ecx
    xor     ecx, ecx

    loc_462B70:                             ; CODE XREF: sub_462AE0+34j
    cmp     [ebp+10h], esi
    jnz     short loc_462B89
    mov     eax, [esi+1Ch]
    cmp     eax, ecx
    jz      short loc_462B86
    cmp     [eax+0Ch], ebp
    jnz     short loc_462B86
    mov     [ebp+10h], eax
    jmp     short loc_462B89
    ; ---------------------------------------------------------------------------

    loc_462B86:                             ; CODE XREF: sub_462AE0+9Aj
                                            ; sub_462AE0+9Fj
    mov     [ebp+10h], ecx

    loc_462B89:                             ; CODE XREF: sub_462AE0+93j
                                            ; sub_462AE0+A4j
    mov     eax, [ebp+0]
    cmp     [eax+34h], esi
    jnz     short loc_462B97
    mov     edx, [esi+18h]
    mov     [eax+34h], edx

    loc_462B97:                             ; CODE XREF: sub_462AE0+AFj
    cmp     [eax+30h], esi
    jnz     short loc_462BA2
    mov     edx, [esi+1Ch]
    mov     [eax+30h], edx

    loc_462BA2:                             ; CODE XREF: sub_462AE0+BAj
    mov     eax, [esi+18h]
    cmp     eax, ecx
    jz      short loc_462BAF
    mov     edx, [esi+1Ch]
    mov     [eax+1Ch], edx

    loc_462BAF:                             ; CODE XREF: sub_462AE0+C7j
    mov     eax, [esi+1Ch]
    cmp     eax, ecx
    jz      short loc_462BBF
    mov     edx, [esi+18h]
    mov     [eax+18h], edx
    mov     [esi+1Ch], ecx

    loc_462BBF:                             ; CODE XREF: sub_462AE0+D4j
    mov     [esi+18h], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_462AE0 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, ecx
    push    esi
    mov     ecx, [esi+0Ch]
    call    sub_462AE0
    mov     dword ptr [esi+0Ch], 0
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx+4]
    mov     ecx, [ecx+0Ch]
    lea     eax, [eax+ecx+14h]
    retn
    ; ---------------------------------------------------------------------------
    align 8
    push    ecx
    mov     eax, [esp+8]
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     edi, edi
    lea     ebp, [ecx+20h]
    or      ebx, 0FFFFFFFFh
    mov     [esp+10h], ecx
    mov     [ecx+4], edi
    mov     [ecx+8], eax
    mov     [ecx+0Ch], ebx
    mov     [ecx+10h], ebx
    mov     [ecx+14h], edi
    mov     [ecx+18h], edi
    mov     [ecx+1Ch], edi
    lea     esi, [ebp+20h]
    mov     dword ptr [esp+18h], 0Ah

    loc_462C35:                             ; CODE XREF: .text:00462C8Aj
    mov     [ebp+0], ebx
    mov     [esi-1Ch], ebx
    mov     [esi-18h], ebx
    mov     [esi-14h], edi
    mov     [esi-10h], ebx
    mov     [esi-0Ch], edi
    push    180Ch
    mov     [esi+8], edi
    mov     [esi-8], edi
    mov     [esi-4], edi
    mov     [esi], edi
    mov     [esi+4], edi
    mov     [esi+0Ch], ebx
    mov     [esi+10h], ebx
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    jz      short loc_462C76
    mov     [eax], edi
    mov     [eax+4], edi
    mov     [eax+8], ebx
    jmp     short loc_462C78
    ; ---------------------------------------------------------------------------

    loc_462C76:                             ; CODE XREF: .text:00462C6Aj
    xor     eax, eax

    loc_462C78:                             ; CODE XREF: .text:00462C74j
    mov     [esi+8], eax
    mov     eax, [esp+18h]
    add     ebp, 34h
    add     esi, 34h
    dec     eax
    mov     [esp+18h], eax
    jnz     short loc_462C35
    mov     eax, [esp+10h]
    mov     [eax+228h], edi
    mov     [eax+22Ch], edi
    mov     [eax+230h], edi
    pop     edi
    pop     esi
    mov     [eax+234h], ebx
    mov     [eax+238h], ebx
    pop     ebp
    mov     dword ptr [eax], offset off_4FD518
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_462CC0(char)
    sub_462CC0 proc near                    ; DATA XREF: .rdata:004FD518o

    arg_0= byte ptr  8

    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    mov     eax, [ebx+1Ch]
    mov     dword ptr [ebx], offset off_4FD518
    test    eax, eax
    jnz     short loc_462CD5
    mov     eax, [ebx+18h]

    loc_462CD5:                             ; CODE XREF: sub_462CC0+10j
    push    eax
    call    sub_4B4F20
    add     esp, 4
    lea     esi, [ebx+24Ch]
    mov     edi, 0Ah

    loc_462CE9:                             ; CODE XREF: sub_462CC0+50j
    mov     ecx, [esi-44h]
    sub     esi, 34h
    push    ecx
    call    sub_4B4F20
    mov     edx, [esi+4]
    add     esp, 4
    push    edx
    call    sub_4B4F20
    mov     eax, [esi]
    add     esp, 4
    push    eax
    call    sub_4B4F20
    add     esp, 4
    dec     edi
    jnz     short loc_462CE9
    test    [esp+8+arg_0], 1
    jz      short loc_462D22
    push    ebx
    call    sub_4B4F20
    add     esp, 4

    loc_462D22:                             ; CODE XREF: sub_462CC0+57j
    pop     edi
    mov     eax, ebx
    pop     esi
    pop     ebx
    retn    4
    sub_462CC0 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+1Ch]
    mov     dword ptr [esi], offset off_4FD518
    test    eax, eax
    jnz     short loc_462D44
    mov     eax, [esi+18h]

    loc_462D44:                             ; CODE XREF: .text:00462D3Fj
    push    eax
    call    sub_4B4F20
    add     esp, 4
    add     esi, 24Ch
    mov     edi, 0Ah

    loc_462D58:                             ; CODE XREF: .text:00462D7Fj
    mov     ecx, [esi-44h]
    sub     esi, 34h
    push    ecx
    call    sub_4B4F20
    mov     edx, [esi+4]
    add     esp, 4
    push    edx
    call    sub_4B4F20
    mov     eax, [esi]
    add     esp, 4
    push    eax
    call    sub_4B4F20
    add     esp, 4
    dec     edi
    jnz     short loc_462D58
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_462D90 proc near                    ; CODE XREF: sub_462F30+296p
                                            ; sub_462F30+52Dp

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    lea     ebx, [ecx+20h]
    xor     edi, edi
    mov     [esp+14h+var_4], ecx
    xor     edx, edx
    mov     eax, ebx

    loc_462DA2:                             ; CODE XREF: sub_462D90+2Cj
    mov     esi, [eax]
    mov     ebp, [esp+14h+arg_0]
    cmp     esi, ebp
    jz      loc_462EC2
    cmp     esi, 0FFFFFFFFh
    jz      short loc_462DBE
    inc     edx
    add     eax, 34h
    cmp     edx, 0Ah
    jb      short loc_462DA2

    loc_462DBE:                             ; CODE XREF: sub_462D90+23j
    cmp     edx, 0Ah
    jnb     short loc_462DDB
    lea     eax, [edx+edx*2]
    lea     eax, [edx+eax*4]
    lea     eax, [ecx+eax*4+20h]

    loc_462DCD:                             ; CODE XREF: sub_462D90+49j
    cmp     dword ptr [eax], 0FFFFFFFFh
    jz      short loc_462DE5
    inc     edx
    add     eax, 34h
    cmp     edx, 0Ah
    jb      short loc_462DCD

    loc_462DDB:                             ; CODE XREF: sub_462D90+31j
    mov     ebp, TAdynmemStructPtr
    xor     ecx, ecx
    jmp     short loc_462E0C
    ; ---------------------------------------------------------------------------

    loc_462DE5:                             ; CODE XREF: sub_462D90+40j
    lea     eax, [edx+edx*2]
    push    ebp
    push    offset aPlayerframeinf          ; "PlayerFrameInfo::Initialize: %ld"
    lea     edx, [edx+eax*4]
    lea     esi, [ecx+edx*4+20h]
    call    nullsub_13
    add     esp, 8
    or      ebx, 0FFFFFFFFh
    mov     [esi], ebp
    mov     [esi+4], ebx
    mov     [esi+8], ebx
    jmp     short loc_462E71
    ; ---------------------------------------------------------------------------

    loc_462E0A:                             ; CODE XREF: sub_462D90+A8j
    xor     edi, edi

    loc_462E0C:                             ; CODE XREF: sub_462D90+53j
    mov     esi, [ebx]
    xor     eax, eax
    lea     edx, [ebp+1B67h]

    loc_462E16:                             ; CODE XREF: sub_462D90+94j
    cmp     [edx], esi
    jz      short loc_462E28
    inc     eax
    add     edx, 14Bh
    cmp     eax, 0Ah
    jl      short loc_462E16
    jmp     short loc_462E2D
    ; ---------------------------------------------------------------------------

    loc_462E28:                             ; CODE XREF: sub_462D90+88j
    mov     edi, 1

    loc_462E2D:                             ; CODE XREF: sub_462D90+96j
    test    edi, edi
    jz      short loc_462E44
    inc     ecx
    add     ebx, 34h
    cmp     ecx, 0Ah
    jb      short loc_462E0A
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_462E44:                             ; CODE XREF: sub_462D90+9Fj
    mov     edi, [esp+14h+arg_0]
    mov     edx, [esp+14h+var_4]
    lea     eax, [ecx+ecx*2]
    push    edi
    push    offset aPlayerframeinf          ; "PlayerFrameInfo::Initialize: %ld"
    lea     ecx, [ecx+eax*4]
    lea     esi, [edx+ecx*4+20h]
    call    nullsub_13
    or      ebx, 0FFFFFFFFh
    add     esp, 8
    mov     [esi], edi
    mov     [esi+4], ebx
    mov     [esi+8], ebx
    xor     edi, edi

    loc_462E71:                             ; CODE XREF: sub_462D90+78j
    mov     [esi+0Ch], edi
    mov     eax, [esi+28h]
    cmp     eax, edi
    mov     [esi+18h], edi
    mov     [esi+1Ch], edi
    mov     [esi+20h], edi
    mov     [esi+24h], edi
    mov     [esi+2Ch], ebx
    mov     [esi+30h], ebx
    jnz     short loc_462EB8
    push    180Ch                           ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    jz      short loc_462EB3
    mov     [eax], edi
    mov     [eax+4], edi
    mov     [eax+8], ebx
    mov     [esi+28h], eax
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_462EB3:                             ; CODE XREF: sub_462D90+10Cj
    xor     eax, eax
    mov     [esi+28h], eax

    loc_462EB8:                             ; CODE XREF: sub_462D90+FBj
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_462EC2:                             ; CODE XREF: sub_462D90+1Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_462D90 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, ecx
    push    edi
    xor     edi, edi
    cmp     [esi+18h], edi
    jnz     short loc_462F0D
    mov     eax, [esi+1Ch]
    cmp     eax, edi
    jz      short loc_462EEA
    mov     [esi+18h], eax
    mov     [esi+1Ch], edi
    jmp     short loc_462F0D
    ; ---------------------------------------------------------------------------

    loc_462EEA:                             ; CODE XREF: .text:00462EE0j
    push    42Ah
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    mov     [esi+18h], eax
    jnz     short loc_462F03
    xor     eax, eax
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_462F03:                             ; CODE XREF: .text:00462EFCj
    mov     dword ptr [esi+228h], 42Ah

    loc_462F0D:                             ; CODE XREF: .text:00462ED9j
                                            ; .text:00462EE8j
    mov     eax, [esi+14h]
    mov     [esi+22Ch], edi
    cmp     eax, edi
    jz      short loc_462F20
    mov     [eax+0Ch], edi
    mov     [esi+14h], edi

    loc_462F20:                             ; CODE XREF: .text:00462F18j
    pop     edi
    mov     eax, 1
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_462F30(int TAdynmemStruct,int PacketBuffer,int BufferSize)
    sub_462F30 proc near                    ; CODE XREF: HAPINET_GetPacket+40p

    var_10= dword ptr -10h
    GameTime= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    TAdynmemStruct= dword ptr  4
    PacketBuffer= dword ptr  8
    BufferSize= dword ptr  0Ch

    sub     esp, 10h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ebp, [eax+TAdynmemStruct.GameTime]
    push    edi
    mov     ebx, ecx
    xor     edi, edi
    mov     [esp+20h+GameTime], ebp
    mov     [esp+20h+var_10], edi
    lea     esi, [ebx+StaticVarStuct_1.field_48]

    loc_462F51:                             ; CODE XREF: sub_462F30+A8j
    cmp     dword ptr [esi-28h], 0FFFFFFFFh
    jz      loc_462FDE
    mov     eax, [esi]
    xor     edx, edx
    cmp     eax, edi
    jz      short loc_462F73
    cmp     [eax], edi
    jle     short loc_462F73
    mov     ecx, [eax+4]
    inc     ecx
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*4]
    jmp     short loc_462F75
    ; ---------------------------------------------------------------------------

    loc_462F73:                             ; CODE XREF: sub_462F30+31j
                                            ; sub_462F30+35j
    xor     ecx, ecx

    loc_462F75:                             ; CODE XREF: sub_462F30+41j
    cmp     ecx, edi
    jz      short loc_462FBF
    mov     ecx, [ecx]
    sub     ecx, ebp
    cmp     ebp, edi
    jz      short loc_462F8A
    cmp     ecx, edi
    jle     short loc_462F8A
    cmp     ecx, 1Eh
    jle     short loc_462FBF

    loc_462F8A:                             ; CODE XREF: sub_462F30+4Fj
                                            ; sub_462F30+53j
    mov     ecx, [eax]
    cmp     ecx, edi
    jle     short loc_462FB5
    dec     ecx
    mov     [eax], ecx
    mov     ecx, [eax+4]
    inc     ecx
    cmp     ecx, 200h
    mov     [eax+4], ecx
    lea     edx, [ecx+ecx*2]
    lea     edx, [eax+edx*4]
    jl      short loc_462FAB
    mov     [eax+4], edi

    loc_462FAB:                             ; CODE XREF: sub_462F30+76j
    mov     eax, edx
    mov     edx, [eax+8]
    mov     eax, [eax+4]
    jmp     short loc_462FC1
    ; ---------------------------------------------------------------------------

    loc_462FB5:                             ; CODE XREF: sub_462F30+5Ej
    xor     eax, eax
    mov     edx, [eax+8]
    mov     eax, [eax+4]
    jmp     short loc_462FC1
    ; ---------------------------------------------------------------------------

    loc_462FBF:                             ; CODE XREF: sub_462F30+47j
                                            ; sub_462F30+58j
    xor     eax, eax

    loc_462FC1:                             ; CODE XREF: sub_462F30+83j
                                            ; sub_462F30+8Dj
    cmp     eax, edi
    jnz     loc_463589
    mov     eax, [esp+20h+var_10]
    add     esi, 34h
    inc     eax
    cmp     eax, 0Ah
    mov     [esp+20h+var_10], eax
    jb      loc_462F51

    loc_462FDE:                             ; CODE XREF: sub_462F30+25j
    mov     eax, [ebx+StaticVarStuct_1.field_22C]
    lea     ebp, [ebx+StaticVarStuct_1.field_22C]
    xor     edi, edi
    test    eax, eax
    mov     [esp+20h+var_10], edi
    jnz     loc_463453
    mov     edx, [ebx+StaticVarStuct_1.field_14]
    xor     ecx, ecx
    test    edx, edx
    jz      loc_4630B9
    mov     esi, [ebx+1Ch]
    test    esi, esi
    jz      short loc_463061
    mov     eax, [ebx+StaticVarStuct_1.field_230]
    mov     [ebx+18h], esi
    test    eax, eax
    jle     short loc_46304A
    mov     ecx, [ebx+StaticVarStuct_1.field_234]
    mov     [ebp+0], eax
    mov     [ebx+0Ch], ecx
    mov     ecx, [ebx+StaticVarStuct_1.field_238]
    mov     [ebx+10h], ecx
    lea     ecx, [eax-4]
    test    ecx, ecx
    jle     short loc_463051
    mov     eax, [esi]
    mov     [edx+8], eax
    mov     edx, [ebx+StaticVarStuct_1.field_14]
    xor     eax, eax
    mov     [ebx+1Ch], eax
    mov     [edx+0Ch], eax
    mov     [ebx+StaticVarStuct_1.field_14], eax
    jmp     short loc_4630B9
    ; ---------------------------------------------------------------------------

    loc_46304A:                             ; CODE XREF: sub_462F30+E7j
    mov     dword ptr [ebp+0], 0

    loc_463051:                             ; CODE XREF: sub_462F30+103j
    mov     edx, [ebx+StaticVarStuct_1.field_14]
    xor     eax, eax
    mov     [ebx+1Ch], eax
    mov     [edx+0Ch], eax
    mov     [ebx+ScriptSlot.field_14], eax
    jmp     short loc_4630B9
    ; ---------------------------------------------------------------------------

    loc_463061:                             ; CODE XREF: sub_462F30+DAj
    mov     eax, [edx+0Ch]
    test    eax, eax
    jle     short loc_4630B2
    mov     eax, [ebx+18h]
    mov     ecx, [ebx+0Ch]
    mov     [ebx+1Ch], eax
    mov     eax, [ebx+10h]
    xor     esi, esi
    mov     [ebx+234h], ecx
    mov     [ebx+230h], esi
    mov     [ebx+238h], eax
    mov     eax, [edx+14h]
    mov     [ebx+18h], eax
    mov     ecx, [eax]
    mov     [edx+8], ecx
    mov     eax, [ebx+14h]
    mov     edx, [eax+0Ch]
    mov     [ebp+0], edx
    mov     ecx, [eax]
    mov     [ebx+0Ch], ecx
    mov     edx, [eax+4]
    mov     ecx, [ebp+0]
    mov     [ebx+10h], edx
    sub     ecx, 4
    mov     [eax+0Ch], esi
    jmp     short loc_4630B9
    ; ---------------------------------------------------------------------------

    loc_4630B2:                             ; CODE XREF: sub_462F30+136j
    mov     dword ptr [ebx+14h], 0

    loc_4630B9:                             ; CODE XREF: sub_462F30+CFj
                                            ; sub_462F30+118j ...
    test    ecx, ecx
    jnz     loc_463453
    mov     eax, [ebx+228h]
    mov     ecx, [ebx+18h]
    mov     [ebp+0], eax
    mov     edx, TAdynmemStructPtr
    push    ebp                             ; lpidFrom
    add     edx, TAdynmemStruct.HAPINET_Object
    push    ecx                             ; lpidTo
    push    edx                             ; HAPINET_this
    mov     ecx, offset dword_5129F8
    call    sub_44F9C0
    mov     esi, eax
    test    esi, esi
    jz      loc_463173

    loc_4630ED:                             ; CODE XREF: sub_462F30+226j
    cmp     esi, 887700BEh
    jz      loc_463573
    cmp     esi, 8877001Eh
    jnz     loc_46342C
    mov     eax, [ebx+18h]
    push    eax
    call    sub_4B4F20
    mov     eax, [ebp+0]
    add     esp, 4
    mov     ecx, eax
    mov     [ebx+228h], eax
    push    ecx                             ; int
    mov     dword ptr [ebp+0], 0
    call    sub_4B4F10
    add     esp, 4
    mov     [ebx+18h], eax
    test    eax, eax
    jz      short loc_46315A
    mov     edx, [ebx+228h]
    push    ebp                             ; lpidFrom
    mov     [ebp+0], edx
    mov     ecx, TAdynmemStructPtr
    add     ecx, 14h
    push    eax                             ; lpidTo
    push    ecx                             ; HAPINET_this
    mov     ecx, offset dword_5129F8
    call    sub_44F9C0
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4630ED
    jmp     short loc_463173
    ; ---------------------------------------------------------------------------

    loc_46315A:                             ; CODE XREF: sub_462F30+201j
    mov     dword ptr [ebx+228h], 0
    mov     eax, 8007000Eh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_463173:                             ; CODE XREF: sub_462F30+1B7j
                                            ; sub_462F30+228j
    mov     eax, [esp+20h+TAdynmemStruct]
    mov     edx, [eax+4B5h]
    mov     [ebx+0Ch], edx
    mov     ecx, [eax+4B9h]
    mov     [ebx+10h], ecx
    mov     ecx, [eax+4B5h]
    test    ecx, ecx
    jz      loc_4633E3
    mov     eax, [ebp+0]
    cmp     eax, 4
    jb      loc_4633D4
    jnz     short loc_4631B4
    mov     eax, 80004005h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4631B4:                             ; CODE XREF: sub_462F30+273j
    mov     edx, [ebx+18h]
    cmp     dword ptr [edx], 0FFFFFFFFh
    jz      loc_463453
    mov     eax, [ebx+0Ch]
    mov     ecx, ebx
    push    eax
    call    sub_462D90
    test    eax, eax
    mov     [esp+20h+var_10], eax
    jz      loc_4633D4
    mov     eax, [eax+8]
    cmp     eax, 0FFFFFFFFh
    jz      loc_4633C4
    dec     eax
    cmp     eax, 0FFFFFFFFh
    mov     [esp+20h+var_4], eax
    jl      short loc_4631F9
    mov     ecx, [ebx+18h]
    mov     eax, 0FFFFFFFEh
    mov     esi, [ecx]
    jmp     short loc_4631FE
    ; ---------------------------------------------------------------------------

    loc_4631F9:                             ; CODE XREF: sub_462F30+2BBj
    mov     edx, [ebx+18h]
    mov     esi, [edx]

    loc_4631FE:                             ; CODE XREF: sub_462F30+2C7j
    mov     ecx, [esp+20h+var_10]
    sub     eax, esi
    xor     edx, edx
    mov     edi, [ecx+0Ch]
    test    edi, edi
    setnle  dl
    test    eax, eax
    mov     [esp+20h+var_8], edx
    jle     loc_463373
    test    edi, edi
    jg      loc_4632A7
    mov     eax, [ebp+0]
    mov     edx, [ecx+10h]
    cmp     eax, edx
    jle     short loc_463276
    mov     esi, ecx
    mov     eax, [esi+14h]
    push    eax
    call    sub_4B4F20
    mov     ecx, [ebp+0]
    add     esp, 4
    push    ecx                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+14h], eax
    test    eax, eax
    jnz     short loc_463270
    push    offset aNoMemoryForAll          ; "no memory for allocating saved receive "...
    call    nullsub_13
    add     esp, 4
    mov     dword ptr [esi+10h], 0FFFFFFFFh
    mov     eax, 8007000Eh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_463270:                             ; CODE XREF: sub_462F30+31Bj
    mov     edx, [ebp+0]
    mov     [esi+10h], edx

    loc_463276:                             ; CODE XREF: sub_462F30+2FAj
    mov     ecx, [ebp+0]
    mov     eax, [esp+20h+var_10]
    mov     esi, [ebx+18h]
    mov     edx, ecx
    mov     edi, [eax+14h]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     ecx, [ebx+10h]
    mov     [eax+4], ecx
    mov     edx, [ebx+0Ch]
    mov     [eax], edx
    mov     ecx, [ebp+0]
    mov     [eax+0Ch], ecx
    jmp     loc_463573
    ; ---------------------------------------------------------------------------

    loc_4632A7:                             ; CODE XREF: sub_462F30+2ECj
    mov     eax, [esp+20h+var_4]
    cmp     eax, 0FFFFFFFFh
    jl      short loc_4632B5
    mov     eax, 0FFFFFFFEh

    loc_4632B5:                             ; CODE XREF: sub_462F30+37Ej
    mov     edx, [ecx+14h]
    mov     edx, [edx]
    cmp     edx, esi
    jg      short loc_46331E
    cmp     eax, esi
    jz      short loc_4632DC
    inc     esi
    cmp     esi, 0FFFFFFFFh
    jl      short loc_4632CD
    mov     esi, 0FFFFFFFEh

    loc_4632CD:                             ; CODE XREF: sub_462F30+396j
    push    esi
    push    eax
    mov     eax, [ebx+0Ch]
    push    eax
    call    nullsub_12
    mov     ecx, [esp+20h+var_10]

    loc_4632DC:                             ; CODE XREF: sub_462F30+390j
    mov     edx, [ebx+18h]
    mov     eax, [edx]
    dec     eax
    cmp     eax, 0FFFFFFFFh
    jl      short loc_4632EC
    mov     eax, 0FFFFFFFEh

    loc_4632EC:                             ; CODE XREF: sub_462F30+3B5j
    mov     edx, [ecx+14h]
    mov     edx, [edx]
    cmp     eax, edx
    jz      short loc_463311
    lea     ecx, [edx+1]
    cmp     ecx, 0FFFFFFFFh
    jl      short loc_463302
    mov     ecx, 0FFFFFFFEh

    loc_463302:                             ; CODE XREF: sub_462F30+3CBj
    push    ecx
    push    eax
    mov     eax, [ebx+0Ch]
    push    eax
    call    nullsub_12
    mov     ecx, [esp+20h+var_10]

    loc_463311:                             ; CODE XREF: sub_462F30+3C3j
    mov     [esp+20h+var_8], 0
    mov     [ebx+14h], ecx
    jmp     short loc_463373
    ; ---------------------------------------------------------------------------

    loc_46331E:                             ; CODE XREF: sub_462F30+38Cj
    cmp     eax, edx
    jz      short loc_46333E
    lea     ecx, [edx+1]
    cmp     ecx, 0FFFFFFFFh
    jl      short loc_46332F
    mov     ecx, 0FFFFFFFEh

    loc_46332F:                             ; CODE XREF: sub_462F30+3F8j
    push    ecx
    mov     ecx, [ebx+0Ch]
    push    eax
    push    ecx
    call    nullsub_12
    mov     ecx, [esp+20h+var_10]

    loc_46333E:                             ; CODE XREF: sub_462F30+3F0j
    mov     edx, [ecx+14h]
    mov     eax, [edx]
    dec     eax
    cmp     eax, 0FFFFFFFFh
    jl      short loc_46334E
    mov     eax, 0FFFFFFFEh

    loc_46334E:                             ; CODE XREF: sub_462F30+417j
    mov     edx, [ebx+18h]
    mov     edx, [edx]
    cmp     eax, edx
    jz      short loc_463373
    lea     ecx, [edx+1]
    cmp     ecx, 0FFFFFFFFh
    jl      short loc_463364
    mov     ecx, 0FFFFFFFEh

    loc_463364:                             ; CODE XREF: sub_462F30+42Dj
    push    ecx
    push    eax
    mov     eax, [ebx+0Ch]
    push    eax
    call    nullsub_12
    mov     ecx, [esp+20h+var_10]

    loc_463373:                             ; CODE XREF: sub_462F30+2E4j
                                            ; sub_462F30+3ECj ...
    mov     eax, [esp+20h+var_8]
    test    eax, eax
    jz      short loc_4633C4
    mov     eax, [ecx+0Ch]
    test    eax, eax
    jle     short loc_4633C4
    mov     edx, [ebx+18h]
    mov     eax, [ebp+0]
    mov     [ebx+1Ch], edx
    mov     edx, [ebx+0Ch]
    mov     [ebx+230h], eax
    mov     eax, [ebx+10h]
    mov     [ebx+234h], edx
    mov     [ebx+238h], eax
    mov     edx, [ecx+14h]
    mov     [ebx+18h], edx
    mov     eax, [ecx+0Ch]
    mov     [ebp+0], eax
    mov     edx, [ecx]
    mov     [ebx+0Ch], edx
    mov     eax, [ecx+4]
    mov     [ebx+10h], eax
    mov     [ebx+14h], ecx
    mov     dword ptr [ecx+0Ch], 0

    loc_4633C4:                             ; CODE XREF: sub_462F30+2ADj
                                            ; sub_462F30+449j ...
    mov     ecx, [ebx+18h]
    mov     eax, [esp+20h+var_10]
    mov     edi, eax
    mov     edx, [ecx]
    mov     [eax+8], edx
    jmp     short loc_463453
    ; ---------------------------------------------------------------------------

    loc_4633D4:                             ; CODE XREF: sub_462F30+26Dj
                                            ; sub_462F30+2A1j
    mov     eax, 80004005h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4633E3:                             ; CODE XREF: sub_462F30+261j
    mov     eax, [esp+20h+BufferSize]
    mov     ecx, [ebp+0]
    cmp     [eax], ecx
    jl      short loc_46341B
    mov     esi, [ebx+18h]
    mov     edi, [esp+20h+PacketBuffer]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     ecx, [ebp+0]
    mov     [eax], ecx
    mov     dword ptr [ebp+0], 0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46341B:                             ; CODE XREF: sub_462F30+4BCj
    mov     [eax], ecx
    mov     eax, 8877001Eh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46342C:                             ; CODE XREF: sub_462F30+1CFj
    push    esi
    call    sub_4C9530
    push    eax
    push    offset aHapinet_receiv          ; "HAPINET_receivepacket failed (%s)\n"
    call    nullsub_13
    add     esp, 8
    mov     dword ptr [ebp+0], 0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_463453:                             ; CODE XREF: sub_462F30+C2j
                                            ; sub_462F30+18Bj ...
    test    edi, edi
    jnz     short loc_463470
    mov     edx, [ebx+0Ch]
    mov     ecx, ebx
    push    edx
    call    sub_462D90
    mov     edi, eax
    test    edi, edi
    mov     [esp+20h+var_10], edi
    jz      loc_463573

    loc_463470:                             ; CODE XREF: sub_462F30+525j
    mov     edx, [ebx+14h]
    mov     ecx, [ebx+10h]
    xor     eax, eax
    lea     esi, [edi+18h]
    test    edx, edx
    mov     edx, [ebx+0Ch]
    setz    al
    push    eax
    mov     eax, [esp+24h+GameTime]
    push    ecx
    mov     ecx, [ebp+0]
    push    edx
    mov     edx, [ebx+18h]
    push    eax
    push    ecx
    push    edx
    mov     ecx, esi
    call    sub_463790
    test    eax, eax
    jz      short loc_4634BF
    mov     dword ptr [ebp+0], 0
    mov     eax, [esi+10h]
    xor     edx, edx
    test    eax, eax
    jz      short loc_4634D9
    cmp     dword ptr [eax], 0
    jle     short loc_4634D9
    mov     ecx, [eax+4]
    inc     ecx
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*4]
    jmp     short loc_4634DB
    ; ---------------------------------------------------------------------------

    loc_4634BF:                             ; CODE XREF: sub_462F30+56Cj
    mov     eax, [esi+10h]
    xor     edx, edx
    test    eax, eax
    jz      short loc_4634D9
    cmp     dword ptr [eax], 0
    jle     short loc_4634D9
    mov     ecx, [eax+4]
    inc     ecx
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*4]
    jmp     short loc_4634DB
    ; ---------------------------------------------------------------------------

    loc_4634D9:                             ; CODE XREF: sub_462F30+57Cj
                                            ; sub_462F30+581j ...
    xor     ecx, ecx

    loc_4634DB:                             ; CODE XREF: sub_462F30+58Dj
                                            ; sub_462F30+5A7j
    test    ecx, ecx
    jz      short loc_46352D
    mov     ecx, [ecx]
    mov     esi, [esp+20h+GameTime]
    sub     ecx, esi
    test    esi, esi
    jz      short loc_4634F4
    test    ecx, ecx
    jle     short loc_4634F4
    cmp     ecx, 1Eh
    jle     short loc_46352D

    loc_4634F4:                             ; CODE XREF: sub_462F30+5B9j
                                            ; sub_462F30+5BDj
    mov     ecx, [eax]
    test    ecx, ecx
    jle     short loc_463523
    dec     ecx
    mov     [eax], ecx
    mov     ecx, [eax+4]
    inc     ecx
    cmp     ecx, 200h
    mov     [eax+4], ecx
    lea     edx, [ecx+ecx*2]
    lea     edx, [eax+edx*4]
    jl      short loc_463519
    mov     dword ptr [eax+4], 0

    loc_463519:                             ; CODE XREF: sub_462F30+5E0j
    mov     eax, edx
    mov     edx, [eax+8]
    mov     esi, [eax+4]
    jmp     short loc_46352F
    ; ---------------------------------------------------------------------------

    loc_463523:                             ; CODE XREF: sub_462F30+5C8j
    xor     eax, eax
    mov     edx, [eax+8]
    mov     esi, [eax+4]
    jmp     short loc_46352F
    ; ---------------------------------------------------------------------------

    loc_46352D:                             ; CODE XREF: sub_462F30+5ADj
                                            ; sub_462F30+5C2j
    xor     esi, esi

    loc_46352F:                             ; CODE XREF: sub_462F30+5F1j
                                            ; sub_462F30+5FBj
    test    esi, esi
    jz      short loc_463573
    mov     eax, [esp+20h+var_10]
    mov     ecx, [esp+20h+TAdynmemStruct]
    mov     edi, [eax+2Ch]
    mov     [ecx+4B5h], edi
    mov     eax, [eax+30h]
    mov     [ecx+4B9h], eax
    mov     ecx, edx

    loc_46354F:                             ; CODE XREF: sub_462F30+673j
    mov     edi, [esp+20h+PacketBuffer]
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    xor     eax, eax
    rep movsb
    mov     ecx, [esp+20h+BufferSize]
    mov     [ecx], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_463573:                             ; CODE XREF: sub_462F30+1C3j
                                            ; sub_462F30+372j ...
    pop     edi
    mov     dword ptr [ebp+0], 0
    pop     esi
    pop     ebp
    mov     eax, 887700BEh
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_463589:                             ; CODE XREF: sub_462F30+93j
    mov     ecx, [esp+20h+TAdynmemStruct]
    mov     edi, [esi+4]
    mov     [ecx+4B5h], edi
    mov     esi, [esi+8]
    mov     [ecx+4B9h], esi
    mov     ecx, edx
    mov     esi, eax
    jmp     short loc_46354F
    sub_462F30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4635B0 proc near                    ; DATA XREF: sub_460E20+81o
    push    ebx
    push    esi
    push    edi
    mov     esi, ecx
    or      ebx, 0FFFFFFFFh
    xor     edi, edi
    mov     [esi], ebx
    mov     [esi+4], ebx
    mov     [esi+8], ebx
    mov     [esi+0Ch], edi
    mov     [esi+10h], ebx
    mov     [esi+14h], edi
    push    180Ch                           ; int
    mov     [esi+28h], edi
    mov     [esi+18h], edi
    mov     [esi+1Ch], edi
    mov     [esi+20h], edi
    mov     [esi+24h], edi
    mov     [esi+2Ch], ebx
    mov     [esi+30h], ebx
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    jz      short loc_463602
    mov     [eax], edi
    mov     [eax+4], edi
    mov     [eax+8], ebx
    mov     [esi+28h], eax
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_463602:                             ; CODE XREF: sub_4635B0+3Fj
    xor     eax, eax
    pop     edi
    mov     [esi+28h], eax
    mov     eax, esi
    pop     esi
    pop     ebx
    retn
    sub_4635B0 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+10h]
    push    edi
    mov     esi, ecx
    push    offset aPlayerframeinf          ; "PlayerFrameInfo::Initialize: %ld"
    call    nullsub_13
    mov     [esi], edi
    or      ebx, 0FFFFFFFFh
    xor     edi, edi
    mov     [esi+4], ebx
    mov     [esi+8], ebx
    mov     [esi+0Ch], edi
    mov     eax, [esi+28h]
    add     esp, 8
    cmp     eax, edi
    mov     [esi+18h], edi
    mov     [esi+1Ch], edi
    mov     [esi+20h], edi
    mov     [esi+24h], edi
    mov     [esi+2Ch], ebx
    mov     [esi+30h], ebx
    jnz     short loc_463677
    push    180Ch
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    jz      short loc_463672
    mov     [eax], edi
    mov     [eax+4], edi
    mov     [eax+8], ebx
    mov     [esi+28h], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_463672:                             ; CODE XREF: .text:0046365Fj
    xor     eax, eax
    mov     [esi+28h], eax

    loc_463677:                             ; CODE XREF: .text:0046364Ej
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, ecx
    mov     eax, [esi+14h]
    push    eax
    call    sub_4B4F20
    mov     ecx, [esi+28h]
    add     esp, 4
    push    ecx
    call    sub_4B4F20
    mov     edx, [esi+24h]
    add     esp, 4
    push    edx
    call    sub_4B4F20
    add     esp, 4
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    push    edi
    mov     esi, ecx
    xor     edi, edi
    push    180Ch
    mov     [esi+10h], edi
    mov     [esi], edi
    mov     [esi+4], edi
    mov     [esi+8], edi
    mov     [esi+0Ch], edi
    mov     dword ptr [esi+14h], 0FFFFFFFFh
    mov     dword ptr [esi+18h], 0FFFFFFFFh
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    jz      short loc_4636F7
    mov     [eax], edi
    mov     [eax+4], edi
    mov     dword ptr [eax+8], 0FFFFFFFFh
    mov     [esi+10h], eax
    mov     eax, esi
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4636F7:                             ; CODE XREF: .text:004636E1j
    xor     eax, eax
    pop     edi
    mov     [esi+10h], eax
    mov     eax, esi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, ecx
    mov     eax, [esi+10h]
    push    eax
    call    sub_4B4F20
    mov     ecx, [esi+0Ch]
    add     esp, 4
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, ecx
    push    edi
    xor     edi, edi
    mov     eax, [esi+10h]
    mov     [esi], edi
    cmp     eax, edi
    mov     [esi+4], edi
    mov     [esi+8], edi
    mov     [esi+0Ch], edi
    mov     dword ptr [esi+14h], 0FFFFFFFFh
    mov     dword ptr [esi+18h], 0FFFFFFFFh
    jnz     short loc_463783
    push    180Ch
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    jz      short loc_46377B
    mov     [eax], edi
    mov     [eax+4], edi
    mov     dword ptr [eax+8], 0FFFFFFFFh
    mov     [esi+10h], eax
    xor     eax, eax
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_46377B:                             ; CODE XREF: .text:00463765j
    xor     eax, eax
    mov     [esi+10h], eax
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_463783:                             ; CODE XREF: .text:00463754j
    pop     edi
    mov     eax, 1
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_463790 proc near                    ; CODE XREF: sub_462F30+565p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 10h
    push    ebx
    mov     ebx, [esp+14h+arg_4]
    push    ebp
    push    esi
    push    edi
    xor     edi, edi
    mov     ebp, ecx
    cmp     ebx, edi
    mov     [esp+20h+var_10], ebp
    jbe     loc_463B91
    mov     eax, [ebp+10h]
    cmp     eax, edi
    jz      short loc_4637B6
    mov     ecx, [eax]
    jmp     short loc_4637B8
    ; ---------------------------------------------------------------------------

    loc_4637B6:                             ; CODE XREF: sub_463790+20j
    xor     ecx, ecx

    loc_4637B8:                             ; CODE XREF: sub_463790+24j
    cmp     ecx, edi
    jz      loc_46386B
    mov     edi, [ebp+8]
    inc     edi
    mov     [ebp+8], edi
    mov     eax, [eax]
    mov     ecx, eax
    dec     eax
    test    ecx, ecx
    jz      loc_46385F
    mov     ebx, [esp+20h+arg_8]
    inc     eax
    mov     [esp+20h+arg_4], eax
    mov     edi, 200h

    loc_4637E2:                             ; CODE XREF: sub_463790+CDj
    mov     eax, [ebp+10h]
    mov     ecx, [eax]
    test    ecx, ecx
    jle     short loc_46380A
    dec     ecx
    mov     [eax], ecx
    mov     ecx, [eax+4]
    inc     ecx
    cmp     ecx, edi
    mov     [eax+4], ecx
    lea     edx, [ecx+ecx*2]
    lea     edx, [eax+edx*4]
    jl      short loc_463806
    mov     dword ptr [eax+4], 0

    loc_463806:                             ; CODE XREF: sub_463790+6Dj
    mov     eax, edx
    jmp     short loc_46380C
    ; ---------------------------------------------------------------------------

    loc_46380A:                             ; CODE XREF: sub_463790+59j
    xor     eax, eax

    loc_46380C:                             ; CODE XREF: sub_463790+78j
    mov     ecx, [eax]
    mov     edx, [eax+4]
    mov     esi, [eax+8]
    mov     eax, [ebp+10h]
    mov     [esp+20h+var_C], ecx
    cmp     [eax], edi
    jge     short loc_463854
    mov     ecx, [eax+8]
    inc     ecx
    cmp     ecx, edi
    mov     [eax+8], ecx
    jl      short loc_463831
    mov     dword ptr [eax+8], 0

    loc_463831:                             ; CODE XREF: sub_463790+98j
    mov     ecx, [eax+8]
    lea     ecx, [ecx+ecx*2]
    mov     [eax+ecx*4+10h], edx
    mov     ecx, [eax+8]
    inc     ecx
    lea     edx, [ecx+ecx*2]
    mov     [eax+edx*4], ebx
    mov     ecx, [eax+8]
    lea     ecx, [ecx+ecx*2]
    mov     [eax+ecx*4+14h], esi
    mov     ecx, [eax]
    inc     ecx
    mov     [eax], ecx

    loc_463854:                             ; CODE XREF: sub_463790+8Dj
    mov     eax, [esp+20h+arg_4]
    dec     eax
    mov     [esp+20h+arg_4], eax
    jnz     short loc_4637E2

    loc_46385F:                             ; CODE XREF: sub_463790+3Ej
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_46386B:                             ; CODE XREF: sub_463790+2Aj
    mov     eax, [ebp+4]
    mov     [ebp+8], edi
    cmp     ebx, eax
    jbe     short loc_4638AC
    mov     eax, [ebp+0Ch]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    lea     esi, [ebx+100h]
    push    esi                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, edi
    mov     [ebp+0Ch], eax
    jnz     short loc_4638A9
    mov     [ebp+4], edi
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4638A9:                             ; CODE XREF: sub_463790+105j
    mov     [ebp+4], esi

    loc_4638AC:                             ; CODE XREF: sub_463790+E3j
    mov     esi, [esp+20h+arg_0]
    mov     edi, [ebp+0Ch]
    mov     ecx, ebx
    mov     eax, [esp+20h+arg_C]
    mov     edx, ecx
    sub     ebx, 4
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     edx, [esp+20h+var_10]
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+20h+arg_10]
    mov     esi, [edx+0Ch]
    mov     [ebp+14h], eax
    mov     [ebp+18h], ecx
    xor     edx, edx
    xor     ebp, ebp
    mov     edi, ebx
    add     esi, 4
    cmp     ebx, edx
    mov     [esp+20h+arg_0], ebp
    mov     [esp+20h+arg_4], edi
    jle     short loc_463951

    loc_4638F0:                             ; CODE XREF: sub_463790+1B7j
    mov     al, [esi]
    cmp     al, 1
    mov     byte ptr [esp+20h+arg_4], al
    jbe     short loc_463949
    cmp     al, 2Dh
    jnb     short loc_463949
    cmp     al, 2Ch
    jnz     short loc_463928
    push    8
    lea     ecx, [esp+24h+var_C]
    mov     [esp+24h+var_C], esi
    mov     [esp+24h+var_8], edx
    mov     [esp+24h+var_4], edx
    call    sub_415DC0
    push    10h
    lea     ecx, [esp+24h+var_C]
    call    sub_415DC0
    xor     edx, edx
    jmp     short loc_463939
    ; ---------------------------------------------------------------------------

    loc_463928:                             ; CODE XREF: sub_463790+170j
    mov     eax, [esp+20h+arg_4]
    and     eax, 0FFh
    mov     ax, word_512AD8[eax*4]

    loc_463939:                             ; CODE XREF: sub_463790+196j
    and     eax, 0FFFFh
    sub     edi, eax
    js      short loc_463949
    add     esi, eax
    inc     ebp
    cmp     edi, edx
    jg      short loc_4638F0

    loc_463949:                             ; CODE XREF: sub_463790+168j
                                            ; sub_463790+16Cj ...
    mov     [esp+20h+arg_0], ebp
    mov     [esp+20h+arg_4], edi

    loc_463951:                             ; CODE XREF: sub_463790+15Ej
    cmp     ebp, edx
    jle     loc_463B91
    mov     eax, [esp+20h+arg_14]
    lea     edi, [ebp-200h]
    cmp     eax, edx
    mov     [esp+20h+arg_C], edi
    jz      loc_463ABB
    mov     eax, [esp+20h+var_10]
    mov     esi, [esp+20h+arg_8]
    mov     ecx, esi
    sub     ecx, [eax]
    cmp     ecx, 1Eh
    jle     short loc_463987
    mov     ecx, 1Eh
    jmp     short loc_463990
    ; ---------------------------------------------------------------------------

    loc_463987:                             ; CODE XREF: sub_463790+1EEj
    cmp     ecx, edx
    jg      short loc_463990
    mov     ecx, 1

    loc_463990:                             ; CODE XREF: sub_463790+1F5j
                                            ; sub_463790+1F9j
    cmp     ebp, ecx
    mov     [esp+20h+arg_10], 10h
    jle     short loc_4639AA
    mov     eax, ebp
    shl     eax, 4
    cdq
    idiv    ecx
    xor     edx, edx
    mov     [esp+20h+arg_10], eax

    loc_4639AA:                             ; CODE XREF: sub_463790+20Aj
    mov     ecx, [esp+20h+var_10]
    mov     [esp+20h+arg_8], esi
    xor     ebx, ebx
    xor     edi, edi
    mov     esi, [ecx+0Ch]
    add     esi, 4

    loc_4639BC:                             ; CODE XREF: sub_463790+316j
    mov     al, [esi]
    cmp     al, 2Ch
    mov     byte ptr [esp+20h+arg_14], al
    jnz     short loc_463A0F
    xor     eax, eax
    push    8
    lea     ecx, [esp+24h+var_C]
    mov     [esp+24h+var_C], esi
    mov     [esp+24h+var_8], eax
    mov     [esp+24h+var_4], eax
    call    sub_415DC0
    push    10h
    lea     ecx, [esp+24h+var_C]
    call    sub_415DC0
    mov     ecx, [esp+20h+arg_C]
    test    ecx, ecx
    jle     short loc_463A21
    mov     edx, ecx
    and     eax, 0FFFFh
    dec     edx
    mov     [esp+20h+arg_C], edx
    mov     edx, [esp+20h+arg_4]
    sub     edx, eax
    add     esi, eax
    mov     [esp+20h+arg_4], edx
    jmp     loc_463A9F
    ; ---------------------------------------------------------------------------

    loc_463A0F:                             ; CODE XREF: sub_463790+234j
    mov     edx, [esp+20h+arg_14]
    and     edx, 0FFh
    mov     ax, word_512AD8[edx*4]

    loc_463A21:                             ; CODE XREF: sub_463790+260j
    mov     ecx, [esp+20h+var_10]
    mov     ecx, [ecx+10h]
    cmp     dword ptr [ecx], 200h
    jge     loc_463B91
    mov     ebp, [ecx+8]
    inc     ebp
    mov     edx, ebp
    mov     [ecx+8], ebp
    cmp     edx, 200h
    jl      short loc_463A4C
    mov     dword ptr [ecx+8], 0

    loc_463A4C:                             ; CODE XREF: sub_463790+2B3j
    mov     edx, [ecx+8]
    mov     ebp, [esp+20h+arg_8]
    and     eax, 0FFFFh
    lea     edx, [edx+edx*2]
    mov     [ecx+edx*4+10h], esi
    mov     edx, [ecx+8]
    inc     edx
    lea     edx, [edx+edx*2]
    mov     [ecx+edx*4], ebp
    mov     edx, [ecx+8]
    lea     edx, [edx+edx*2]
    mov     [ecx+edx*4+14h], eax
    mov     edx, [ecx]
    inc     edx
    inc     edi
    mov     [ecx], edx
    mov     ecx, edi
    shl     ecx, 4
    cmp     ecx, ebx
    jb      short loc_463A8F
    mov     edx, [esp+20h+arg_10]
    mov     ecx, ebp
    add     ebx, edx
    inc     ecx
    mov     [esp+20h+arg_8], ecx

    loc_463A8F:                             ; CODE XREF: sub_463790+2F0j
    mov     edx, [esp+20h+arg_4]
    mov     ebp, [esp+20h+arg_0]
    sub     edx, eax
    add     esi, eax
    mov     [esp+20h+arg_4], edx

    loc_463A9F:                             ; CODE XREF: sub_463790+27Aj
    dec     ebp
    test    ebp, ebp
    mov     [esp+20h+arg_0], ebp
    jg      loc_4639BC
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_463ABB:                             ; CODE XREF: sub_463790+1D9j
    mov     eax, [esp+20h+var_10]
    mov     esi, [eax+0Ch]
    add     esi, 4
    cmp     ebx, edx
    jle     loc_463B91
    mov     ebp, [esp+20h+arg_8]
    jmp     short loc_463AD5
    ; ---------------------------------------------------------------------------

    loc_463AD3:                             ; CODE XREF: sub_463790+3FBj
    xor     edx, edx

    loc_463AD5:                             ; CODE XREF: sub_463790+341j
    mov     al, [esi]
    cmp     al, 1
    mov     byte ptr [esp+20h+arg_8], al
    jbe     loc_463B91
    cmp     al, 2Dh
    jnb     loc_463B91
    cmp     al, 2Ch
    jnz     short loc_463B21
    push    8
    lea     ecx, [esp+24h+var_C]
    mov     [esp+24h+var_C], esi
    mov     [esp+24h+var_8], edx
    mov     [esp+24h+var_4], edx
    call    sub_415DC0
    push    10h
    lea     ecx, [esp+24h+var_C]
    call    sub_415DC0
    test    edi, edi
    jle     short loc_463B33
    and     eax, 0FFFFh
    dec     edi
    sub     ebx, eax
    add     esi, eax
    jmp     short loc_463B89
    ; ---------------------------------------------------------------------------

    loc_463B21:                             ; CODE XREF: sub_463790+35Dj
    mov     ecx, [esp+20h+arg_8]
    and     ecx, 0FFh
    mov     ax, word_512AD8[ecx*4]

    loc_463B33:                             ; CODE XREF: sub_463790+383j
    mov     edx, eax
    and     edx, 0FFFFh
    sub     ebx, edx
    js      short loc_463B91
    mov     eax, [esp+20h+var_10]
    mov     eax, [eax+10h]
    cmp     dword ptr [eax], 200h
    jge     short loc_463B91
    mov     ecx, [eax+8]
    inc     ecx
    cmp     ecx, 200h
    mov     [eax+8], ecx
    jl      short loc_463B64
    mov     dword ptr [eax+8], 0

    loc_463B64:                             ; CODE XREF: sub_463790+3CBj
    mov     ecx, [eax+8]
    lea     ecx, [ecx+ecx*2]
    mov     [eax+ecx*4+10h], esi
    mov     ecx, [eax+8]
    inc     ecx
    lea     ecx, [ecx+ecx*2]
    mov     [eax+ecx*4], ebp
    mov     ecx, [eax+8]
    lea     ecx, [ecx+ecx*2]
    mov     [eax+ecx*4+14h], edx
    mov     ecx, [eax]
    inc     ecx
    add     esi, edx
    mov     [eax], ecx

    loc_463B89:                             ; CODE XREF: sub_463790+38Fj
    test    ebx, ebx
    jg      loc_463AD3

    loc_463B91:                             ; CODE XREF: sub_463790+15j
                                            ; sub_463790+1C3j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 10h
    retn    18h
    sub_463790 endp

    ; ---------------------------------------------------------------------------
    mov     cl, byte_52A4E4
    mov     al, 1
    test    al, cl
    jnz     short loc_463BB4
    or      cl, al
    mov     byte_52A4E4, cl

    loc_463BB4:                             ; CODE XREF: .text:00463BAAj
    push    offset nullsub_48
    call    _atexit
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_48. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_463BE0 proc near                    ; CODE XREF: sub_41D920+6Bp
                                            ; Network_Process+6F6p
    push    esi
    mov     esi, ecx
    xor     eax, eax
    push    edi
    mov     [esi], eax
    mov     [esi+73h], al
    mov     [esi+80h], eax
    mov     [esi+84h], eax
    mov     [esi+88h], eax
    mov     [esi+7Ch], eax
    push    0B9h                            ; int
    mov     byte ptr [esi+146h], 0Ah
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+27h], eax
    push    eax
    call    nullsub_23
    mov     edi, [esi+27h]
    mov     ecx, 2Eh
    xor     eax, eax
    add     esp, 4
    rep stosd
    stosb
    mov     eax, esi
    pop     edi
    pop     esi
    retn
    sub_463BE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_463C40 proc near                    ; CODE XREF: Network_Process+7F8p
                                            ; Network_Process+8C7p
    push    esi
    mov     esi, ecx
    mov     eax, [esi+27h]
    push    eax
    call    sub_4B4F20
    mov     ecx, [esi+7Ch]
    add     esp, 4
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    pop     esi
    retn
    sub_463C40 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_463C60 proc near                    ; CODE XREF: sub_416280+74p
                                            ; sub_416280+7Ep ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    cmp     eax, 3
    mov     [ecx+73h], al
    jz      short locret_463C75
    mov     ecx, [ecx+27h]
    mov     [ecx+94h], al

    locret_463C75:                          ; CODE XREF: sub_463C60+Aj
    retn    4
    sub_463C60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_463C80 proc near                    ; CODE XREF: sub_4917D0+2p
                                            ; .text:004963C4p ...
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     [ecx+2A3Eh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+2A40h], ax
    retn
    sub_463C80 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_463CA0(char *,char,__int16,char)
    sub_463CA0 proc near                    ; CODE XREF: TextCommand_Logo+F3p
                                            ; TextCommand_ShareMetal+9Fp ...

    arg_0= dword ptr  0Ch
    arg_4= byte ptr  10h
    arg_8= word ptr  14h
    arg_C= byte ptr  18h

    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    cmp     byte ptr [esi], 0
    jz      loc_463E3B
    mov     ecx, TAdynmemStructPtr
    mov     ebp, [ecx+37F27h]
    test    ebp, ebp
    jz      loc_463E3B
    xor     eax, eax
    mov     di, [ecx+2A40h]
    mov     ax, [ecx+2A3Eh]
    inc     eax
    cdq
    idiv    ebp
    mov     eax, edi
    mov     ebp, 1Eh
    and     eax, 0FFFFh
    cmp     edx, eax
    jnz     short loc_463D0E
    inc     edi
    mov     [ecx+2A40h], di
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+2A40h], bp
    jnz     short loc_463D0E
    mov     word ptr [ecx+2A40h], 0
    mov     ecx, TAdynmemStructPtr

    loc_463D0E:                             ; CODE XREF: sub_463CA0+46j
                                            ; sub_463CA0+5Dj
    xor     eax, eax
    push    40h                             ; size_t
    mov     ax, [ecx+2A3Eh]
    push    esi                             ; char *
    lea     edx, [eax+eax*8]
    lea     eax, [ecx+edx*8+12EFh]
    push    eax                             ; char *
    call    _strncpy
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    add     esp, 0Ch
    mov     ax, [ecx+2A3Eh]
    lea     edx, [eax+eax*8]
    xor     eax, eax
    mov     byte ptr [ecx+edx*8+132Eh], 0
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+2A3Eh]
    mov     edx, [ecx+38A47h]
    lea     eax, [eax+eax*8]
    mov     [ecx+eax*8+132Fh], edx
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     ax, [ecx+2A3Eh]
    lea     eax, [eax+eax*8]
    lea     eax, [ecx+eax*8+1336h]
    mov     cl, [eax]
    mov     dl, cl
    xor     dl, [esp+4+arg_4]
    and     dl, 0Fh
    xor     dl, cl
    mov     [eax], dl
    mov     ecx, TAdynmemStructPtr
    mov     dx, [esp+4+arg_8]
    xor     eax, eax
    mov     ax, [ecx+2A3Eh]
    lea     eax, [eax+eax*8]
    mov     [ecx+eax*8+1333h], dx
    mov     ecx, TAdynmemStructPtr
    mov     dl, [esp+4+arg_C]
    xor     eax, eax
    mov     ax, [ecx+2A3Eh]
    lea     eax, [eax+eax*8]
    mov     [ecx+eax*8+1335h], dl
    mov     eax, TAdynmemStructPtr
    inc     word ptr [eax+2A3Eh]
    mov     eax, TAdynmemStructPtr
    cmp     [eax+2A3Eh], bp
    jnz     short loc_463DED
    mov     word ptr [eax+2A3Eh], 0

    loc_463DED:                             ; CODE XREF: sub_463CA0+142j
    cmp     dl, 0Ah
    jz      short loc_463DFE
    push    0                               ; int
    push    offset aMessagearrived          ; char *
    call    sub_47F1A0

    loc_463DFE:                             ; CODE XREF: sub_463CA0+150j
    mov     ecx, TAdynmemStructPtr
    push    offset aTimeout_gui             ; char *
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_4AB060
    test    eax, eax
    jz      short loc_463E3B
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx                             ; int
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FAD0

    loc_463E3B:                             ; CODE XREF: sub_463CA0+Aj
                                            ; sub_463CA0+1Ej ...
    pop     edi
    pop     esi
    pop     ebp
    retn    10h
    sub_463CA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ChatHandling_1 proc near                ; CODE XREF: sub_447150+130p
                                            ; sub_447B10+532p ...

    var_C8= byte ptr -0C8h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_C]
    sub     esp, 0C8h
    test    eax, eax
    mov     ecx, eax
    jnz     short loc_463E65
    mov     ecx, offset Data

    loc_463E65:                             ; CODE XREF: ChatHandling_1+Ej
    test    eax, eax
    mov     eax, offset asc_5072D4          ; "->"
    jnz     short loc_463E73
    mov     eax, offset Data

    loc_463E73:                             ; CODE XREF: ChatHandling_1+1Cj
    mov     edx, [esp+0C8h+arg_4]
    push    edx
    push    ecx
    push    eax
    mov     eax, [esp+0D4h+arg_0]
    add     eax, 49h
    lea     ecx, [esp+0D4h+var_C8]
    push    eax
    push    offset aSSSS                    ; "<%s%s%s> %s"
    push    ecx
    call    _sprintf
    add     esp, 18h
    lea     edx, [esp+0C8h+var_C8]
    push    edx                             ; char *
    call    sub_453360
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+TAdynmemStruct.MapFile]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_463EC3
    lea     ecx, [esp+0C8h+var_C8]
    push    ecx                             ; int
    call    RIWrapper_ReportGameChat

    loc_463EC3:                             ; CODE XREF: ChatHandling_1+67j
    mov     edx, dword ptr [esp+0C8h+arg_8]
    push    0Ah                             ; char
    push    0                               ; __int16
    lea     eax, [esp+0D0h+var_C8]
    push    edx                             ; char
    push    eax                             ; char *
    call    sub_463CA0
    add     esp, 0C8h
    retn    10h
    ChatHandling_1 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_463EF0 proc near                    ; CODE XREF: sub_49562A+59p
    mov     ecx, TAdynmemStructPtr
    push    esi
    xor     eax, eax
    push    edi
    mov     si, [ecx+2A40h]
    cmp     [ecx+2A3Eh], si
    jz      short loc_463F5C
    mov     edx, esi
    and     edx, 0FFFFh
    lea     edi, [edx+edx*8]
    mov     edx, [ecx+37F23h]
    inc     edx
    mov     edi, [ecx+edi*8+132Fh]
    lea     edx, [edx+edx*2]
    lea     edx, [edx+edx*4]
    lea     edx, [edi+edx*2]
    mov     edi, [ecx+38A47h]
    cmp     edx, edi
    jnb     short loc_463F5C
    inc     esi
    mov     eax, 1
    mov     [ecx+2A40h], si
    mov     ecx, TAdynmemStructPtr
    cmp     word ptr [ecx+2A40h], 1Eh
    jnz     short loc_463F5C
    mov     word ptr [ecx+2A40h], 0

    loc_463F5C:                             ; CODE XREF: sub_463EF0+18j
                                            ; sub_463EF0+44j ...
    pop     edi
    pop     esi
    retn
    sub_463EF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_463F60 proc near                    ; CODE XREF: sub_464000+25p
                                            ; sub_464000+50p
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    xor     edx, edx
    xor     ebx, ebx
    mov     dx, [edi+2A40h]
    mov     bx, [edi+2A3Eh]
    cmp     ebx, edx
    jz      short loc_463FF9
    mov     ebp, 10000000h

    loc_463F85:                             ; CODE XREF: sub_463F60+6Cj
    lea     eax, [edx+edx*8]
    lea     esi, [edi+eax*8+12EFh]
    mov     ax, [edi+eax*8+1333h]
    test    ax, ax
    jz      short loc_463FC2
    test    byte ptr [esi+47h], 10h
    jnz     short loc_463FC2
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, [edi+14357h]
    lea     eax, [eax+ecx*8]
    test    [eax+110h], ebp
    jnz     short loc_463FD5

    loc_463FC2:                             ; CODE XREF: sub_463F60+3Aj
                                            ; sub_463F60+40j
    inc     edx
    cmp     edx, 1Eh
    jnz     short loc_463FCA
    xor     edx, edx

    loc_463FCA:                             ; CODE XREF: sub_463F60+66j
    cmp     ebx, edx
    jnz     short loc_463F85
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_463FD5:                             ; CODE XREF: sub_463F60+60j
    mov     bl, [esi+47h]
    push    1
    or      bl, 30h
    mov     [esi+47h], bl
    movsx   ecx, word ptr [eax+74h]
    movsx   edx, word ptr [eax+6Ch]
    push    ecx
    push    edx
    call    sub_41C7C0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_463FF9:                             ; CODE XREF: sub_463F60+1Ej
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn
    sub_463F60 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464000 proc near                    ; CODE XREF: .text:004961CDp
    push    ebx
    xor     eax, eax
    mov     dl, 0DFh

    loc_464005:                             ; CODE XREF: sub_464000+23j
    mov     ecx, TAdynmemStructPtr
    add     eax, 48h
    mov     bl, [ecx+eax+12EEh]
    and     bl, dl
    cmp     eax, 870h
    mov     [ecx+eax+12EEh], bl
    jl      short loc_464005
    call    sub_463F60
    test    eax, eax
    jnz     short loc_464055
    mov     dl, 0EFh

    loc_464030:                             ; CODE XREF: sub_464000+4Ej
    mov     ecx, TAdynmemStructPtr
    add     eax, 48h
    mov     bl, [ecx+eax+12EEh]
    and     bl, dl
    cmp     eax, 870h
    mov     [ecx+eax+12EEh], bl
    jl      short loc_464030
    call    sub_463F60

    loc_464055:                             ; CODE XREF: sub_464000+2Cj
    pop     ebx
    retn
    sub_464000 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464060 proc near                    ; CODE XREF: .text:0041F7A5p
                                            ; .text:0041F9D8p ...

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 20h
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    xor     ebp, ebp
    push    edi
    mov     ecx, [esi+37F27h]
    cmp     ecx, ebp
    jz      loc_464264
    mov     ebx, 1
    xor     edi, edi
    mov     di, [esi+2A3Eh]
    cmp     ecx, ebx
    mov     eax, ebx
    jle     short loc_4640AB
    xor     edx, edx
    mov     dx, [esi+2A40h]

    loc_46409A:                             ; CODE XREF: sub_464060+49j
    cmp     edi, edx
    jz      short loc_4640AB
    dec     edi
    jns     short loc_4640A6
    mov     edi, 1Dh

    loc_4640A6:                             ; CODE XREF: sub_464060+3Fj
    inc     eax
    cmp     eax, ecx
    jl      short loc_46409A

    loc_4640AB:                             ; CODE XREF: sub_464060+2Fj
                                            ; sub_464060+3Cj
    mov     eax, [esi+391F9h]
    push    eax
    call    sub_4C1420
    call    sub_4C1450
    mov     [esp+30h+var_14], eax
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cx, [eax+2A3Eh]
    cmp     ecx, edi
    jz      loc_464264
    mov     [esp+30h+var_1C], 34h

    loc_4640DE:                             ; CODE XREF: sub_464060+1FEj
    mov     ecx, [eax+37EFEh]
    dec     ecx
    jz      short loc_464130
    dec     ecx
    jz      short loc_464115
    dec     ecx
    jnz     short loc_464142                ; default
    cmp     [eax+37F02h], ebp
    jnz     short loc_46410F                ; case 0x0
    lea     edx, [edi+edi*8]
    mov     cl, [eax+edx*8+1336h]
    and     ecx, 0Fh
    dec     ecx
    cmp     ecx, 7                          ; switch 8 cases
    ja      short loc_464142                ; default
    jmp     ds:off_464270[ecx*4]            ; switch jump

    loc_46410F:                             ; CODE XREF: sub_464060+93j
                                            ; DATA XREF: .text:00464270o
    mov     [esp+30h+var_20], ebx           ; case 0x0
    jmp     short loc_464146
    ; ---------------------------------------------------------------------------

    loc_464115:                             ; CODE XREF: sub_464060+88j
    lea     edx, [edi+edi*8]
    mov     cl, [eax+edx*8+1336h]
    xor     edx, edx
    and     cl, 0Fh
    cmp     cl, 8
    setnz   dl
    mov     [esp+30h+var_20], edx
    jmp     short loc_464146
    ; ---------------------------------------------------------------------------

    loc_464130:                             ; CODE XREF: sub_464060+85j
    lea     ecx, [edi+edi*8]
    mov     dl, [eax+ecx*8+1336h]
    and     dl, 0Fh
    cmp     dl, 2
    jz      short loc_464146

    loc_464142:                             ; CODE XREF: sub_464060+8Bj
                                            ; sub_464060+A6j ...
    mov     [esp+30h+var_20], ebp           ; default

    loc_464146:                             ; CODE XREF: sub_464060+B3j
                                            ; sub_464060+CEj ...
    cmp     [esp+30h+var_20], ebp
    jz      loc_46424B
    lea     ebp, [edi+edi*8]
    push    0FEh

    loc_464158:                             ; DATA XREF: .data:005110FCo
                                            ; .data:0051110Co
    shl     ebp, 3
    test    byte ptr [eax+ebp+1336h], 20h
    jz      short loc_464170
    xor     ecx, ecx
    mov     cl, [eax+0DD5h]
    push    ecx
    jmp     short loc_464179
    ; ---------------------------------------------------------------------------

    loc_464170:                             ; CODE XREF: sub_464060+103j
    xor     edx, edx
    mov     dl, [eax+0DDAh]
    push    edx

    loc_464179:                             ; CODE XREF: sub_464060+10Ej
    call    sub_4C13A0
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     ebx, 8Ah
    mov     al, [ecx+ebp+1335h]
    mov     esi, eax
    cmp     esi, 0Ah
    jz      short loc_464213
    call    sub_4C1450
    mov     [esp+30h+var_18], eax
    fild    [esp+30h+var_18]
    fmul    ds:dbl_4FD520
    call    __ftol
    mov     [esp+30h+var_18], eax
    mov     ecx, [esp+30h+var_1C]
    fild    [esp+30h+var_18]
    mov     [esp+30h+var_C], ecx
    lea     edx, [eax+8Ah]
    add     ecx, eax
    mov     [esp+30h+var_10], ebx
    fmul    ds:dbl_4FD528
    mov     [esp+30h+var_8], edx
    mov     [esp+30h+var_4], ecx
    fsubr   ds:dbl_4FD530
    call    __ftol
    mov     ebx, eax
    lea     eax, [esp+30h+var_10]
    mov     edx, TAdynmemStructPtr
    push    0
    push    eax
    mov     eax, esi
    shl     eax, 5
    add     eax, esi
    add     edx, esi
    lea     ecx, [eax+eax*4]
    lea     eax, [edx+ecx*2+1B63h]
    mov     ecx, [esp+38h+arg_0]
    push    eax
    push    ecx
    call    sub_467C00

    loc_464213:                             ; CODE XREF: sub_464060+137j
    mov     edx, TAdynmemStructPtr
    mov     esi, [esp+30h+var_1C]
    mov     ecx, [esp+30h+arg_0]
    push    0
    push    0FFFFFFFFh
    push    esi
    lea     eax, [edx+ebp+12EFh]
    push    ebx
    push    eax
    push    ecx
    call    sub_4A50E0
    mov     ebx, 1
    mov     eax, [esp+30h+var_14]
    add     esi, eax
    mov     eax, TAdynmemStructPtr
    mov     [esp+30h+var_1C], esi
    xor     ebp, ebp

    loc_46424B:                             ; CODE XREF: sub_464060+EAj
    inc     edi
    cmp     edi, 1Eh
    jnz     short loc_464253
    xor     edi, edi

    loc_464253:                             ; CODE XREF: sub_464060+1EFj
    xor     edx, edx
    mov     dx, [eax+2A3Eh]
    cmp     edx, edi
    jnz     loc_4640DE

    loc_464264:                             ; CODE XREF: sub_464060+17j
                                            ; sub_464060+70j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    4
    sub_464060 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_464270 dd offset loc_46410F         ; DATA XREF: sub_464060+A8r
    dd offset loc_464142                    ; jump table for switch statement
    dd offset loc_464142
    dd offset loc_46410F
    dd offset loc_464142
    dd offset loc_464142
    dd offset loc_464142
    dd offset loc_46410F

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464290 proc near                    ; CODE XREF: sub_450A10+219p
                                            ; sub_47A760+67p ...

    arg_0= dword ptr  4
    arg_4= byte ptr  8

    mov     edx, [esp+arg_0]
    push    ebx
    mov     eax, edx
    push    ebp
    and     eax, 0FFh
    push    esi
    mov     esi, TAdynmemStructPtr
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     esi, eax
    mov     bl, [esp+0Ch+arg_4]
    push    edi
    lea     ecx, [ecx+ecx*4]
    lea     ebp, [esi+ecx*2+TAdynmemStruct.Players]
    xor     ecx, ecx
    lea     esi, [ebp+108h]
    mov     [ebp+108h], ecx
    mov     [esi+4], ecx
    mov     [esi+8], cx
    mov     [esi+0Ah], cl
    lea     esi, [ebp+113h]
    mov     [ebp+113h], ecx
    mov     [esi+4], ecx
    mov     [esi+8], cx
    mov     [esi+0Ah], cl
    lea     esi, [ebp+11Eh]
    mov     [ebp+11Eh], ecx
    mov     [esi+4], ecx
    mov     [esi+8], cx
    mov     [esi+0Ah], cl
    lea     esi, [ebp+129h]
    mov     [ebp+129h], ecx
    mov     [esi+4], ecx
    mov     [esi+8], cx
    mov     [esi+0Ah], cl
    lea     esi, [ebp+134h]
    mov     [ebp+134h], ecx
    mov     [esi+4], ecx
    mov     [esi+8], cx
    mov     [esi+0Ah], cl
    movsx   ecx, bl
    cmp     ecx, 3
    mov     [ebp+73h], cl
    jz      short loc_464340
    mov     esi, [ebp+27h]
    mov     [esi+94h], cl

    loc_464340:                             ; CODE XREF: sub_464290+A5j
    xor     esi, esi
    mov     byte ptr [eax+ebp+113h], 1
    mov     [ebp+74h], esi
    mov     [ebp+146h], dl
    mov     [ebp+148h], dl
    mov     byte ptr [eax+ebp+108h], 1
    mov     ecx, [ebp+27h]
    mov     dword ptr [ebp+0], 1
    mov     [ebp+147h], dl
    mov     byte ptr [ebp+13Fh], 5
    and     word ptr [ecx+9Bh], 0FFDFh
    mov     [ebp+4], eax
    mov     eax, [ebp+0]
    mov     [ebp+0Ch], esi
    cmp     eax, esi
    mov     byte ptr [ebp+22h], 0
    jz      short loc_4643C3
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_46439D
    cmp     al, 2
    jnz     short loc_4643C3

    loc_46439D:                             ; CODE XREF: sub_464290+107j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [ebp+27h]
    mov     eax, [edx+0Ch]
    mov     eax, [eax+620h]
    cdq
    and     edx, 0FFFFFh
    add     eax, edx
    sar     eax, 14h
    inc     eax
    mov     [ecx+99h], ax

    loc_4643C3:                             ; CODE XREF: sub_464290+100j
                                            ; sub_464290+10Bj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_46443B
    cmp     bl, al
    jnz     short loc_4643EA
    push    offset aPlayer                  ; int
    call    sub_4C5740
    push    eax
    jmp     short loc_46440C
    ; ---------------------------------------------------------------------------

    loc_4643EA:                             ; CODE XREF: sub_464290+14Bj
    cmp     bl, 2
    jnz     short loc_464418
    mov     ecx, [ebp+27h]
    mov     al, [ecx+95h]
    test    al, al
    jnz     short loc_464407
    lea     edx, [ebp+2Bh]
    push    offset aArm                     ; "Arm"
    push    edx
    jmp     short loc_464410
    ; ---------------------------------------------------------------------------

    loc_464407:                             ; CODE XREF: sub_464290+16Aj
    push    offset aCore                    ; "Core"

    loc_46440C:                             ; CODE XREF: sub_464290+158j
    lea     eax, [ebp+2Bh]
    push    eax

    loc_464410:                             ; CODE XREF: sub_464290+175j
    call    _sprintf
    add     esp, 8

    loc_464418:                             ; CODE XREF: sub_464290+15Dj
    lea     edi, [ebp+2Bh]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp+49h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_46443B:                             ; CODE XREF: sub_464290+147j
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 2
    jnz     short loc_4644BA
    cmp     bl, 1

    loc_464454:                             ; DATA XREF: .data:0050341Co
    jnz     short loc_46445D
    push    offset aPlayer                  ; "Player"
    jmp     short loc_464485
    ; ---------------------------------------------------------------------------

    loc_46445D:                             ; CODE XREF: sub_464290+1C4j
    cmp     bl, 2
    jnz     short loc_464497
    mov     eax, [ebp+27h]
    mov     cl, [eax+95h]
    test    cl, cl
    jnz     short loc_464480
    push    offset aArm                     ; int
    call    sub_4C5740
    lea     ecx, [ebp+2Bh]
    push    eax
    push    ecx
    jmp     short loc_46448F
    ; ---------------------------------------------------------------------------

    loc_464480:                             ; CODE XREF: sub_464290+1DDj
    push    offset aCore                    ; int

    loc_464485:                             ; CODE XREF: sub_464290+1CBj
    call    sub_4C5740
    lea     edx, [ebp+2Bh]
    push    eax
    push    edx

    loc_46448F:                             ; CODE XREF: sub_464290+1EEj
    call    _sprintf
    add     esp, 8

    loc_464497:                             ; CODE XREF: sub_464290+1D0j
    lea     edi, [ebp+2Bh]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp+49h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4644BA:                             ; CODE XREF: sub_464290+1BFj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_464290 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4644D0 proc near                    ; CODE XREF: sub_4517B0+FCp

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     edx, edx

    loc_4644D7:                             ; CODE XREF: sub_4644D0+3Fj
    mov     esi, TAdynmemStructPtr
    mov     ecx, 52h
    xor     eax, eax
    mov     ebx, [esi+edx+TAdynmemStruct.Players.PlayerInfo]
    lea     edi, [esi+edx+TAdynmemStruct.Players]
    rep stosd
    stosw
    stosb
    mov     eax, TAdynmemStructPtr
    add     edx, 14Bh
    cmp     edx, 0CEEh
    mov     [eax+edx+1A3Fh], ebx
    jle     short loc_4644D7
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    xor     ebx, ebx
    mov     byte ptr [ecx+2A42h], 0
    mov     edx, TAdynmemStructPtr
    mov     ecx, 0Bh
    mov     [edx+TAdynmemStruct.LOS_Sight], 0
    mov     edx, TAdynmemStructPtr
    lea     edi, [edx+2C28h]
    rep stosd
    mov     eax, TAdynmemStructPtr
    lea     esi, [eax+1B63h]
    mov     [esp+14h+var_4], esi
    lea     ebp, [esi+113h]
    jmp     short loc_46455D
    ; ---------------------------------------------------------------------------

    loc_464559:                             ; CODE XREF: sub_4644D0+203j
    mov     esi, [esp+14h+var_4]

    loc_46455D:                             ; CODE XREF: sub_4644D0+87j
    lea     edx, [ebp-0Bh]
    xor     ecx, ecx
    xor     eax, eax
    push    ebx
    mov     [edx], ecx
    push    offset aPlayerDFirst            ; "Player %d First"
    mov     [edx+4], ecx
    mov     [edx+8], cx
    mov     [edx+0Ah], cl
    mov     ecx, ebp
    lea     edx, [ebp-0E8h]
    mov     [ecx], eax
    push    edx
    mov     [ecx+4], eax
    mov     [ecx+8], ax
    mov     [ecx+0Ah], al
    mov     edi, [ebp-0ECh]
    mov     ecx, 2Eh
    rep stosd
    stosb
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [ebp-0CAh]
    push    ebx
    push    offset aPlayerDSecond           ; "Player %d Second"
    push    eax
    call    _sprintf
    mov     byte ptr [ebx+esi+108h], 1
    mov     byte ptr [ebx+esi+113h], 1
    mov     dword ptr [esi], 0
    mov     byte ptr [ebp-0A0h], 0
    mov     ecx, [ebp-0ECh]
    mov     edi, offset Data
    add     esp, 0Ch
    add     ebp, 14Bh
    mov     byte ptr [ecx+94h], 0
    mov     edx, [ebp-237h]
    mov     word ptr [edx+99h], 0
    mov     eax, [ebp-237h]
    and     word ptr [eax+9Bh], 0FFEFh
    mov     eax, [ebp-237h]
    and     word ptr [eax+97h], 0FFFEh
    mov     eax, [ebp-237h]
    mov     [eax+96h], bl
    mov     ecx, [ebp-237h]
    xor     eax, eax
    mov     byte ptr [ecx+95h], 0
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, [ebp-237h]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx

    loc_46464D:
    mov     edx, [esp+14h+var_4]
    and     ecx, 3
    add     edx, 14Bh
    rep movsb
    mov     cl, [ebp-23Dh]
    mov     [ebp-1EAh], eax
    mov     [ebp-252h], eax
    mov     [ebp-246h], eax
    mov     [ebp-1F7h], eax
    mov     [ebp-1F3h], eax
    mov     [ebp-1EFh], ax
    mov     [ebp-1EDh], ax
    mov     [ebp-11Ah], ax
    mov     [ebp-11Eh], eax
    mov     eax, [ebp-237h]
    and     cl, 0FEh
    mov     [ebp-23Dh], cl
    mov     dword ptr [ebp-25Ah], 0FFFFFFFFh
    mov     byte ptr [ebp-118h], 0Ah
    mov     byte ptr [ebp-11Fh], 5
    and     word ptr [eax+9Bh], 0FFDFh
    inc     ebx
    mov     [esp+14h+var_4], edx
    cmp     ebx, 0Ah
    jle     loc_464559
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    pop     edi
    pop     esi
    mov     [ecx+2A3Eh], ax
    mov     edx, TAdynmemStructPtr
    pop     ebp
    pop     ebx
    mov     [edx+2A40h], ax
    pop     ecx
    retn
    sub_4644D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464700 proc near                    ; CODE XREF: sub_464990+21p

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+0Ch+arg_0]
    mov     ecx, [eax+38A47h]
    xor     ebp, ebp
    push    edi
    mov     [esi+0F0h], ecx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+38A47h]
    mov     [esi+0F4h], eax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esi+0ECh]
    mov     edx, [ecx+38A47h]
    mov     [esi+0ACh], ebp
    mov     [esi+0B4h], ebp
    mov     [esi+0BCh], ebp
    mov     [esi+0C4h], ebp
    mov     [esi+0CCh], ebp
    mov     [esi+0D4h], ebp
    cmp     eax, ebp
    mov     [esi+0F8h], edx
    mov     [esi+8Ch], ebp
    mov     [esi+90h], ebp
    mov     [esi+94h], ebp
    mov     [esi+98h], ebp
    mov     [esi+9Ch], ebp
    mov     [esi+0A0h], ebp
    mov     [esi+0A4h], ebp
    mov     [esi+0A8h], ebp
    mov     [esi+0B0h], ebp
    mov     [esi+0B8h], ebp
    mov     [esi+0C0h], ebp
    mov     [esi+0C8h], ebp
    mov     [esi+0E8h], ebp
    mov     [esi+0E4h], ebp
    mov     [esi+0D0h], ebp
    mov     [esi+0D8h], ebp
    jnz     short loc_4647DD
    push    34h                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+0ECh], eax

    loc_4647DD:                             ; CODE XREF: sub_464700+CBj
    mov     al, [esi+146h]
    mov     ecx, [esi+0ECh]
    push    eax
    call    sub_401070
    and     word ptr [esi+149h], 0FFFEh
    or      eax, 0FFFFFFFFh
    mov     [esi+0FCh], bp
    mov     [esi+0FEh], bp
    mov     [esi+104h], bp
    mov     [esi+106h], bp
    mov     [esi+100h], ax
    mov     [esi+102h], ax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14237h]
    cdq
    sub     eax, edx
    mov     edi, eax
    mov     eax, [ecx+14233h]
    mov     ecx, [esi+7Ch]
    cdq
    sub     eax, edx
    push    ecx
    mov     ebx, eax
    sar     edi, 1
    sar     ebx, 1
    mov     [esi+80h], ebx
    mov     [esi+84h], edi
    call    sub_4B4F20
    imul    edi, ebx
    add     edi, 7
    add     esp, 4
    and     edi, 0FFFFFFF8h
    mov     [esi+88h], edi
    jz      short loc_464879
    push    edi                             ; int
    call    sub_4B4F10
    add     esp, 4
    jmp     short loc_46487B
    ; ---------------------------------------------------------------------------

    loc_464879:                             ; CODE XREF: sub_464700+16Cj
    xor     eax, eax

    loc_46487B:                             ; CODE XREF: sub_464700+177j
    mov     [esi+7Ch], eax
    mov     ecx, [esi+88h]
    mov     edi, [esi+7Ch]
    mov     edx, ecx
    xor     eax, eax
    push    esi
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    call    sub_480190
    cmp     [esi], ebp
    jz      short loc_4648A7
    cmp     byte ptr [esi+73h], 3
    jz      short loc_4648D2

    loc_4648A7:                             ; CODE XREF: sub_464700+19Fj
    push    3Dh                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_4648BF
    push    esi
    mov     ecx, eax
    call    sub_408CB0
    jmp     short loc_4648C1
    ; ---------------------------------------------------------------------------

    loc_4648BF:                             ; CODE XREF: sub_464700+1B3j
    xor     eax, eax

    loc_4648C1:                             ; CODE XREF: sub_464700+1BDj
    mov     [esi+74h], eax
    xor     eax, eax
    mov     al, [esi+146h]
    push    eax
    call    sub_40B320

    loc_4648D2:                             ; CODE XREF: sub_464700+1A5j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_464700 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4648E0 proc near                    ; CODE XREF: sub_40A100+42p
                                            ; sub_464990+2Fp

    var_D8= dword ptr -0D8h
    var_D4= dword ptr -0D4h

    mov     eax, TAdynmemStructPtr
    sub     esp, 0D8h
    mov     ecx, [eax+391E9h]
    push    ebx
    push    esi
    push    edi
    push    7
    call    sub_4356C0
    lea     ecx, [esp+0E4h+var_D8]
    push    ecx
    push    eax
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_464921
    lea     edx, [esp+0E4h+var_D8]
    push    edx
    push    offset aAiDefault_txt           ; "ai\\default.txt"
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jz      short loc_464945

    loc_464921:                             ; CODE XREF: sub_4648E0+2Aj
    lea     ecx, [esp+0E4h+var_D4]
    call    sub_4B73B0
    mov     ecx, [esp+0E4h+var_D8]
    lea     eax, [esp+0E4h+var_D4]
    push    0FFFFFFFFh
    push    eax
    push    ecx
    push    esi
    call    sub_4B7A30
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_464945:                             ; CODE XREF: sub_4648E0+3Fj
    mov     eax, TAdynmemStructPtr
    xor     edi, edi
    xor     esi, esi
    mov     bl, 2

    loc_464950:                             ; CODE XREF: sub_4648E0+A2j
    mov     ecx, [eax+esi+1B63h]
    test    ecx, ecx
    jz      short loc_464975
    cmp     [eax+esi+1BD6h], bl
    jnz     short loc_464975
    push    edi
    call    sub_409F80
    push    edi
    call    sub_40A040
    mov     eax, TAdynmemStructPtr

    loc_464975:                             ; CODE XREF: sub_4648E0+79j
                                            ; sub_4648E0+82j
    add     esi, 14Bh
    inc     edi
    cmp     esi, 0CEEh
    jl      short loc_464950
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0D8h
    retn
    sub_4648E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464990 proc near                    ; CODE XREF: sub_4917D0+1F8p
    push    esi
    push    edi
    xor     esi, esi
    mov     edi, 0Ah

    loc_464999:                             ; CODE XREF: sub_464990+2Dj
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+esi+1BD6h]
    lea     eax, [eax+esi+1B63h]
    test    cl, cl
    jz      short loc_4649B6
    push    eax
    call    sub_464700

    loc_4649B6:                             ; CODE XREF: sub_464990+1Ej
    add     esi, 14Bh
    dec     edi
    jnz     short loc_464999
    call    sub_4648E0
    pop     edi
    pop     esi
    retn
    sub_464990 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4649D0 proc near                    ; CODE XREF: sub_497180+ACAp
    push    ebx
    push    esi
    push    edi
    xor     edi, edi
    xor     esi, esi
    mov     ebx, 0Ah

    loc_4649DC:                             ; CODE XREF: sub_4649D0+2Aj
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+esi+1BD7h]
    test    ecx, ecx
    jz      short loc_4649F2
    push    edi
    call    sub_40B370

    loc_4649F2:                             ; CODE XREF: sub_4649D0+1Aj
    inc     edi
    add     esi, 14Bh
    dec     ebx
    jnz     short loc_4649DC
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_4649D0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464A00 proc near                    ; CODE XREF: sub_491B60+49p
    mov     eax, TAdynmemStructPtr
    push    ebx
    lea     ebx, [eax+1B63h]
    add     eax, 2851h
    cmp     ebx, eax
    ja      loc_464AA0
    push    edi
    push    esi
    push    ebp
    lea     esi, [ebx+84h]
    xor     ebp, ebp

    loc_464A24:                             ; CODE XREF: sub_464A00+9Bj
    mov     eax, [esi-8]
    mov     [esi-4], ebp
    push    eax
    mov     [esi], ebp
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+4], ebp
    mov     [esi-8], ebp
    push    ebx
    call    sub_4801F0
    cmp     [esi-10h], ebp
    jz      short loc_464A6E
    xor     ecx, ecx
    mov     cl, [esi+0C2h]
    push    ecx
    call    sub_40B390
    mov     edi, [esi-10h]
    cmp     edi, ebp
    jz      short loc_464A6B
    mov     ecx, edi
    call    sub_408F10
    push    edi
    call    sub_4B4F20
    add     esp, 4

    loc_464A6B:                             ; CODE XREF: sub_464A00+59j
    mov     [esi-10h], ebp

    loc_464A6E:                             ; CODE XREF: sub_464A00+44j
    mov     eax, [esi+68h]
    cmp     eax, ebp
    jz      short loc_464A81
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+68h], ebp

    loc_464A81:                             ; CODE XREF: sub_464A00+73j
    mov     edx, TAdynmemStructPtr
    add     ebx, 14Bh
    add     edx, 2851h
    add     esi, 14Bh
    cmp     ebx, edx
    jbe     short loc_464A24
    pop     ebp
    pop     esi
    pop     edi

    loc_464AA0:                             ; CODE XREF: sub_464A00+13j
    pop     ebx
    retn
    sub_464A00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464AB0 proc near                    ; CODE XREF: sub_40BB00+17Fp
                                            ; sub_40BB00+197p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    fld     dword ptr [eax+90h]
    retn    4
    sub_464AB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464AC0 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+2AAp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    fld     dword ptr [eax+94h]
    retn    4
    sub_464AC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464AD0 proc near                    ; CODE XREF: sub_408670+21p
                                            ; sub_4086D0+7Ap ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    fld     dword ptr [eax+90h]
    fsub    dword ptr [eax+94h]
    retn    4
    sub_464AD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464AF0 proc near                    ; CODE XREF: sub_40BB00+1ADp
                                            ; sub_40BB00+1C5p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    fld     dword ptr [eax+9Ch]
    retn    4
    sub_464AF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464B00 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+2C4p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    fld     dword ptr [eax+0A0h]
    retn    4
    sub_464B00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464B10 proc near                    ; CODE XREF: sub_40BB00+169p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    fld     dword ptr [eax+9Ch]
    fsub    dword ptr [eax+0A0h]
    retn    4
    sub_464B10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464B30 proc near                    ; CODE XREF: .text:00416CE3p
                                            ; Network_Process+1BB4p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    cmp     al, 0Ah
    push    edi
    jz      loc_464C56
    mov     ebx, [esp+10h+arg_4]
    cmp     bl, 0Ah
    jz      loc_464C56
    mov     edi, [esp+10h+arg_C]
    mov     edx, TAdynmemStructPtr
    test    edi, edi
    jz      short loc_464B8A
    and     eax, 0FFh
    mov     esi, edx
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    fld     dword ptr [esi+ecx*2+1BEFh]
    fld     [esp+10h+arg_8]
    fcomp   st(1)
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_464B88
    fstp    [esp+10h+arg_8]
    jmp     short loc_464B8A
    ; ---------------------------------------------------------------------------

    loc_464B88:                             ; CODE XREF: sub_464B30+50j
    fstp    st

    loc_464B8A:                             ; CODE XREF: sub_464B30+29j
                                            ; sub_464B30+56j
    fld     [esp+10h+arg_8]
    fcomp   ds:flt_4FD538
    fnstsw  ax
    test    ah, 40h
    jnz     loc_464C56
    mov     esi, [esp+10h+arg_8]
    test    edi, edi
    jz      short loc_464BE2
    mov     eax, [esp+10h+arg_0]
    push    esi
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    mov     ecx, [edx+ecx*2+1C4Fh]
    call    sub_401220
    mov     eax, ebx
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    jmp     short loc_464BF3
    ; ---------------------------------------------------------------------------

    loc_464BE2:                             ; CODE XREF: sub_464B30+75j
    mov     eax, ebx
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]

    loc_464BF3:                             ; CODE XREF: sub_464B30+B0j
    mov     ebp, edx
    add     ebp, eax
    mov     eax, [ebp+ecx*2+1C4Fh]
    mov     ecx, [eax+30h]
    cmp     dword ptr [ecx], 0
    jz      short loc_464C3E
    cmp     byte ptr [ecx+73h], 2
    jnz     short loc_464C3E
    mov     edx, [edx+37EEEh]
    sub     edx, 0
    jz      short loc_464C2C
    dec     edx
    jnz     short loc_464C3E
    fld     [esp+10h+arg_8]
    fmul    ds:dbl_4FD540
    fld     dword ptr [eax]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_464C44
    ; ---------------------------------------------------------------------------

    loc_464C2C:                             ; CODE XREF: sub_464B30+E5j
    fld     [esp+10h+arg_8]
    fmul    ds:dbl_4FD548
    fld     dword ptr [eax]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_464C44
    ; ---------------------------------------------------------------------------

    loc_464C3E:                             ; CODE XREF: sub_464B30+D4j
                                            ; sub_464B30+DAj ...
    fld     dword ptr [eax]
    fadd    [esp+10h+arg_8]

    loc_464C44:                             ; CODE XREF: sub_464B30+FAj
                                            ; sub_464B30+10Cj
    fstp    dword ptr [eax]
    test    edi, edi
    jz      short loc_464C56
    mov     edx, [esp+10h+arg_0]
    push    esi
    push    ebx
    push    edx
    call    sub_456EE0

    loc_464C56:                             ; CODE XREF: sub_464B30+Aj
                                            ; sub_464B30+17j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_464B30 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464C60 proc near                    ; CODE XREF: .text:00416C8Dp
                                            ; Network_Process+1B96p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    cmp     al, 0Ah
    push    edi
    jz      loc_464D8A
    mov     ebx, [esp+10h+arg_4]
    cmp     bl, 0Ah
    jz      loc_464D8A
    mov     edi, [esp+10h+arg_C]
    mov     edx, TAdynmemStructPtr
    test    edi, edi
    jz      short loc_464CBA
    and     eax, 0FFh
    mov     esi, edx
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    fld     dword ptr [esi+ecx*2+1BFBh]
    fld     [esp+10h+arg_8]
    fcomp   st(1)
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_464CB8
    fstp    [esp+10h+arg_8]
    jmp     short loc_464CBA
    ; ---------------------------------------------------------------------------

    loc_464CB8:                             ; CODE XREF: sub_464C60+50j
    fstp    st

    loc_464CBA:                             ; CODE XREF: sub_464C60+29j
                                            ; sub_464C60+56j
    fld     [esp+10h+arg_8]
    fcomp   ds:flt_4FD538
    fnstsw  ax
    test    ah, 40h
    jnz     loc_464D8A
    mov     esi, [esp+10h+arg_8]
    test    edi, edi
    jz      short loc_464D12
    mov     eax, [esp+10h+arg_0]
    push    esi
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    mov     ecx, [edx+ecx*2+1C4Fh]
    call    sub_401260
    mov     eax, ebx
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    jmp     short loc_464D23
    ; ---------------------------------------------------------------------------

    loc_464D12:                             ; CODE XREF: sub_464C60+75j
    mov     eax, ebx
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]

    loc_464D23:                             ; CODE XREF: sub_464C60+B0j
    mov     ebp, edx
    add     ebp, eax
    mov     eax, [ebp+ecx*2+1C4Fh]
    mov     ecx, [eax+30h]
    cmp     dword ptr [ecx], 0
    jz      short loc_464D70
    cmp     byte ptr [ecx+73h], 2
    jnz     short loc_464D70
    mov     edx, [edx+37EEEh]
    sub     edx, 0
    jz      short loc_464D5D
    dec     edx
    jnz     short loc_464D70
    fld     [esp+10h+arg_8]
    fmul    ds:dbl_4FD540
    fld     dword ptr [eax+18h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_464D77
    ; ---------------------------------------------------------------------------

    loc_464D5D:                             ; CODE XREF: sub_464C60+E5j
    fld     [esp+10h+arg_8]
    fmul    ds:dbl_4FD548
    fld     dword ptr [eax+18h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_464D77
    ; ---------------------------------------------------------------------------

    loc_464D70:                             ; CODE XREF: sub_464C60+D4j
                                            ; sub_464C60+DAj ...
    fld     [esp+10h+arg_8]
    fadd    dword ptr [eax+18h]

    loc_464D77:                             ; CODE XREF: sub_464C60+FBj
                                            ; sub_464C60+10Ej
    fstp    dword ptr [eax+18h]
    test    edi, edi
    jz      short loc_464D8A
    mov     edx, [esp+10h+arg_0]
    push    esi
    push    ebx
    push    edx
    call    sub_457050

    loc_464D8A:                             ; CODE XREF: sub_464C60+Aj
                                            ; sub_464C60+17j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_464C60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464DA0 proc near

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, [edi+67h]
    mov     eax, [edi+6Bh]
    cmp     esi, eax
    ja      short loc_464DD2
    push    ebx
    mov     ebx, 10000000h

    loc_464DB6:                             ; CODE XREF: sub_464DA0+2Fj
    test    [esi+110h], ebx
    jz      short loc_464DC4
    push    esi
    call    sub_4827B0

    loc_464DC4:                             ; CODE XREF: sub_464DA0+1Cj
    mov     eax, [edi+6Bh]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_464DB6
    pop     ebx

    loc_464DD2:                             ; CODE XREF: sub_464DA0+Ej
    pop     edi
    pop     esi
    retn    4
    sub_464DA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464DE0 proc near                    ; DATA XREF: sub_464E70+E9o
                                            ; UpdateDatePlayers+84Ao

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     edi, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_464E6A
    push    0                               ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    mov     ecx, [esi+60h]
    push    offset aChoice1                 ; char *
    push    ecx                             ; int
    push    edi                             ; int
    call    sub_4A0300
    test    eax, eax
    jz      short loc_464E32
    call    sub_450F90
    mov     eax, TAdynmemStructPtr
    push    4
    and     word ptr [eax+3923Bh], 0FFEFh
    call    RIWrapper_Report
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_464E32:                             ; CODE XREF: sub_464DE0+31j
    mov     edx, [esi+60h]
    push    offset aChoice2                 ; char *
    push    edx                             ; int
    push    edi                             ; int
    call    sub_4A0300
    test    eax, eax
    jnz     short loc_464E50
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_464E50:                             ; CODE XREF: sub_464DE0+63j
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 4
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh

    loc_464E6A:                             ; CODE XREF: sub_464DE0+12j
    pop     edi
    pop     esi
    retn    4
    sub_464DE0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_464E70 proc near
    mov     eax, TAdynmemStructPtr
    push    ebp
    push    900h
    add     eax, 519h
    push    offset aYesorno_gui             ; "YESORNO.GUI"
    push    eax
    call    sub_4AA8F0
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_464F75
    mov     ecx, TAdynmemStructPtr
    push    edi
    push    esi
    push    ebx
    add     ecx, 519h
    push    1
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    mov     ebx, [ebp+4]
    push    0
    push    offset aYes                     ; "Yes"
    add     edx, 519h
    push    offset aChoice1                 ; "CHOICE1"
    push    edx
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    push    0
    push    offset aNo                      ; "No"
    add     eax, 519h
    push    offset aChoice2                 ; "CHOICE2"
    push    eax
    call    sub_4A0BF0
    mov     ecx, TAdynmemStructPtr
    push    0
    push    offset aYouReOutContin          ; "You're out!  Continue Watching?"
    add     ecx, 519h
    push    offset aTitle                   ; "TITLE"
    push    ecx
    call    sub_4A0BF0
    mov     edi, offset aChoice1            ; "CHOICE1"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebx+0CCh]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    40h
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [ebx+0DCh]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, offset aChoice2            ; "CHOICE2"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     dword ptr [ebp+8], offset sub_464DE0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    pop     ebx
    pop     esi
    pop     edi

    loc_464F75:                             ; CODE XREF: sub_464E70+1Fj
    pop     ebp
    retn
    sub_464E70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl UpdateDatePlayers()
    UpdateDatePlayers proc near             ; CODE XREF: .text:0049555Fp
                                            ; sub_497180+A90p

    PlayerIndex= dword ptr -34h
    PlayerStructPtr= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    PlayerInfoPtr= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 34h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+14207h]
    push    edi
    call    sub_40EB70
    xor     bl, bl
    mov     ebp, 4
    cmp     bl, 10
    mov     byte ptr [esp+44h+PlayerIndex], bl
    jnb     loc_4655A6

    loc_464FAB:                             ; CODE XREF: UpdateDatePlayers+62Fj
    mov     esi, [esp+44h+PlayerIndex]
    mov     edx, TAdynmemStructPtr
    and     esi, 0FFh
    mov     eax, esi
    add     edx, esi
    shl     eax, 5
    add     eax, esi
    lea     ecx, [eax+eax*4]
    mov     eax, [edx+ecx*2+TAdynmemStruct.Players.PlayerActive]
    test    eax, eax
    lea     edi, [edx+ecx*2+TAdynmemStruct.Players]
    mov     [esp+44h+PlayerStructPtr], edi
    jz      loc_4655A6
    mov     al, [edi+PlayerStruct.PlayerType]
    cmp     al, Player_LocalHuman
    jz      short loc_464FF4
    cmp     al, Player_AI
    jz      short loc_464FF4
    cmp     al, Player_RemoteHuman
    jnz     loc_4655A6

    loc_464FF4:                             ; CODE XREF: UpdateDatePlayers+66j
                                            ; UpdateDatePlayers+6Aj
    cmp     [edi+PlayerStruct.PlayerNumber], 10
    jz      loc_4655A6
    cmp     [edi+PlayerStruct.PlayerActive], 0
    jz      loc_4655A6
    mov     al, [edi+PlayerStruct.PlayerType]
    cmp     al, Player_LocalHuman
    jz      short loc_46501D
    cmp     al, Player_AI
    jz      short loc_46501D
    cmp     al, Player_RemoteHuman
    jnz     loc_4655A6

    loc_46501D:                             ; CODE XREF: UpdateDatePlayers+8Fj
                                            ; UpdateDatePlayers+93j
    cmp     [edi+PlayerStruct.PlayerNumber], 10
    jz      loc_4655A6
    mov     ecx, [edi+PlayerStruct.field_74]
    test    ecx, ecx
    jz      short loc_465036
    call    sub_408C40

    loc_465036:                             ; CODE XREF: UpdateDatePlayers+AFj
    push    esi                             ; int
    call    sub_40B2C0
    mov     esi, [edi+PlayerStruct.Units]
    mov     eax, [edi+PlayerStruct.Units_End]
    cmp     esi, eax
    ja      short loc_465065

    loc_465046:                             ; CODE XREF: UpdateDatePlayers+E3j
    test    dword ptr [esi+110h], 10000000h
    jz      short loc_465058
    push    esi
    call    sub_4827B0

    loc_465058:                             ; CODE XREF: UpdateDatePlayers+D0j
    mov     eax, [edi+PlayerStruct.Units_End]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_465046

    loc_465065:                             ; CODE XREF: UpdateDatePlayers+C4j
    mov     eax, TAdynmemStructPtr
    cmp     bl, [eax+TAdynmemStruct.LOS_Sight]
    jnz     short loc_465077
    call    GameUnit_LOS_Minimap_UnitsProjectiles

    loc_465077:                             ; CODE XREF: UpdateDatePlayers+F0j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [edi+UnitStruct.pAttacker]
    cmp     eax, [ecx+TAdynmemStruct.GameTime]
    ja      loc_4655A6
    add     eax, 1Eh
    mov     [edi+UnitStruct.pAttacker], eax
    mov     eax, TAdynmemStructPtr
    cmp     bl, [eax+TAdynmemStruct.SharedBits]
    jnz     loc_465508
    mov     ecx, [eax+TAdynmemStruct.MapFile]
    call    sub_435100
    cmp     eax, 1
    jnz     loc_46514C
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391EDh]
    call    sub_490230
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jnz     loc_465881
    mov     ecx, [eax+391EDh]
    call    sub_490360
    test    eax, eax
    jz      loc_465508
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+39239h]
    test    cx, cx
    jge     short loc_46510B
    mov     [eax+39239h], bp
    jmp     loc_465508
    ; ---------------------------------------------------------------------------

    loc_46510B:                             ; CODE XREF: UpdateDatePlayers+17Dj
    dec     ecx
    mov     [eax+39239h], cx
    mov     eax, TAdynmemStructPtr
    cmp     word ptr [eax+39239h], 0
    jge     loc_465508
    or      [eax+3923Bh], bp
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 40h
    jmp     loc_465508
    ; ---------------------------------------------------------------------------

    loc_46514C:                             ; CODE XREF: UpdateDatePlayers+137j
    cmp     [edi+PlayerStruct.PlayerActive], 0
    jz      short loc_465161
    mov     ecx, [edi+PlayerStruct.PlayerInfo]
    test    byte ptr [ecx+9Bh], 40h
    jnz     loc_465864

    loc_465161:                             ; CODE XREF: UpdateDatePlayers+1CFj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391EDh]
    call    sub_490360
    test    eax, eax
    jz      loc_465864
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+39239h]
    test    cx, cx
    jge     short loc_465197
    mov     [eax+39239h], bp
    jmp     loc_465508
    ; ---------------------------------------------------------------------------

    loc_465197:                             ; CODE XREF: UpdateDatePlayers+209j
    dec     ecx
    mov     [eax+39239h], cx
    mov     eax, TAdynmemStructPtr
    cmp     word ptr [eax+39239h], 0
    jge     loc_465508
    cmp     dword ptr [eax+37EF6h], 2
    jnz     loc_465643
    call    sub_456850
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+TAdynmemStruct.Players.PlayerInfo]
    mov     esi, edx
    mov     [esp+44h+PlayerInfoPtr], ecx
    xor     ecx, ecx
    mov     cl, [edx+TAdynmemStruct.SharedBits]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+TAdynmemStruct.Players.PlayerInfo]
    xor     eax, eax
    mov     al, [ecx+95h]
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    lea     edx, [edx+ecx*2+37F5Fh]
    push    edx                             ; char *
    call    sub_488B10
    mov     cx, ax
    mov     edi, TAdynmemStructPtr
    and     ecx, 0FFFFh
    mov     [esp+44h+var_1C], 270Fh
    mov     eax, ecx
    mov     [esp+44h+var_14], ecx
    shl     eax, 6
    add     eax, ecx
    lea     eax, [eax+eax*8]
    mov     [esp+44h+var_18], eax

    loc_465250:                             ; CODE XREF: UpdateDatePlayers+428j
    mov     ecx, [edi+14223h]
    mov     eax, 66666667h
    imul    ecx
    mov     edi, [edi+14227h]
    sar     edx, 2
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 66666667h
    mov     esi, edx
    imul    edi
    sar     edx, 2
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     edi, edx
    lea     edx, [esi+esi]
    sub     ecx, edx
    push    ecx                             ; int
    call    GetRandom
    mov     ecx, TAdynmemStructPtr
    add     eax, esi
    shl     eax, 10h
    xor     esi, esi
    mov     [esp+44h+var_C], eax
    mov     [esp+44h+var_8], esi
    mov     edx, [ecx+14227h]
    lea     eax, [edi+edi]
    sub     edx, eax
    push    edx                             ; int
    call    GetRandom
    mov     ecx, TAdynmemStructPtr
    add     eax, edi
    shl     eax, 10h
    mov     [esp+44h+var_4], eax
    mov     ebp, [ecx+TAdynmemStruct.FeatureMapSizeY]
    mov     edi, [ecx+TAdynmemStruct.FeatureMapSizeX]
    mov     [esp+44h+var_2C], esi
    shl     ebp, 10h
    sub     eax, ebp
    mov     [esp+44h+var_20], 3
    mov     ebx, eax
    shl     edi, 10h

    loc_4652E4:                             ; CODE XREF: UpdateDatePlayers+3C6j
    mov     esi, [esp+44h+var_C]
    mov     eax, ebx
    sub     esi, edi
    mov     [esp+44h+var_24], 3
    shr     eax, 14h
    mov     word ptr [esp+44h+var_28+2], ax

    loc_4652FC:                             ; CODE XREF: UpdateDatePlayers+3B9j
    mov     eax, TAdynmemStructPtr
    mov     ecx, esi
    shr     ecx, 14h
    mov     word ptr [esp+44h+var_28], cx
    mov     ecx, [eax+TAdynmemStruct.UnitDef]
    mov     edx, [esp+44h+var_28]
    mov     eax, [esp+44h+var_18]
    push    1
    push    edx
    add     ecx, eax
    push    0
    push    ecx
    call    sub_47DB70
    test    eax, eax
    jz      short loc_46532E
    inc     [esp+44h+var_2C]

    loc_46532E:                             ; CODE XREF: UpdateDatePlayers+3A8j
    mov     eax, [esp+44h+var_24]
    add     esi, edi
    dec     eax
    mov     [esp+44h+var_24], eax
    jnz     short loc_4652FC
    mov     eax, [esp+44h+var_20]
    add     ebx, ebp
    dec     eax
    mov     [esp+44h+var_20], eax
    jnz     short loc_4652E4
    cmp     [esp+44h+var_2C], 9
    jl      short loc_465397
    push    0                               ; int
    lea     edx, [esp+48h+var_C]
    push    0                               ; int
    push    edx                             ; int
    call    sub_421DA0
    cmp     ax, 0FFFFh
    jnz     short loc_465397
    mov     edi, TAdynmemStructPtr
    mov     eax, [edi+TAdynmemStruct.MapFile]
    mov     ecx, [eax+0D44h]
    test    ecx, ecx
    jz      short loc_4653AE
    lea     ecx, [esp+44h+var_C]
    push    ecx
    call    sub_485140
    mov     edi, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [edi+1427Fh]
    cmp     eax, edx
    jg      short loc_4653AE
    jmp     short loc_46539D
    ; ---------------------------------------------------------------------------

    loc_465397:                             ; CODE XREF: UpdateDatePlayers+3CDj
                                            ; UpdateDatePlayers+3E1j
    mov     edi, TAdynmemStructPtr

    loc_46539D:                             ; CODE XREF: UpdateDatePlayers+415j
    mov     eax, [esp+44h+var_1C]
    dec     eax
    test    eax, eax
    mov     [esp+44h+var_1C], eax
    jg      loc_465250

    loc_4653AE:                             ; CODE XREF: UpdateDatePlayers+3F7j
                                            ; UpdateDatePlayers+413j
    mov     ecx, [esp+44h+var_C]
    push    0                               ; int
    push    1                               ; int
    push    1                               ; int
    mov     edx, [esp+50h+var_8]
    sub     esp, 0Ch                        ; int
    mov     eax, esp
    mov     [eax], ecx
    mov     ecx, [esp+5Ch+var_4]
    mov     [eax+4], edx
    mov     edx, [esp+5Ch+var_14]
    push    edx                             ; int
    mov     [eax+8], ecx
    mov     al, [edi+TAdynmemStruct.SharedBits]
    push    eax                             ; int
    call    sub_485F50
    mov     esi, eax
    xor     eax, eax
    mov     edi, [esp+44h+PlayerInfoPtr]
    mov     ax, [edi+0A1h]
    lea     ecx, [eax+eax*2]
    lea     edx, [eax+ecx*8]
    xor     eax, eax
    mov     ax, [edi+0A3h]
    shl     edx, 2
    lea     ecx, [eax+eax*2]
    push    edx
    lea     edx, [eax+ecx*8]
    mov     eax, [esp+48h+PlayerStructPtr]
    shl     edx, 2
    push    edx
    push    eax
    call    sub_496E90
    mov     eax, [esi+0ECh]
    xor     ecx, ecx
    mov     cx, [edi+0A1h]
    mov     [esp+44h+PlayerInfoPtr], ecx
    mov     ecx, [eax]
    fild    [esp+44h+PlayerInfoPtr]
    test    ecx, ecx
    fmul    ds:flt_4FD550
    jz      short loc_465475
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_465475
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+TAdynmemStruct.CurrentAIProfile]
    sub     eax, 0
    jz      short loc_465463
    dec     eax
    jnz     short loc_465475
    fmul    ds:dbl_4FD540
    fld     dword ptr [esi+0BCh]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_46547B
    ; ---------------------------------------------------------------------------

    loc_465463:                             ; CODE XREF: UpdateDatePlayers+4CCj
    fmul    ds:dbl_4FD548
    fld     dword ptr [esi+0BCh]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_46547B
    ; ---------------------------------------------------------------------------

    loc_465475:                             ; CODE XREF: UpdateDatePlayers+4B5j
                                            ; UpdateDatePlayers+4BBj ...
    fadd    dword ptr [esi+0BCh]

    loc_46547B:                             ; CODE XREF: UpdateDatePlayers+4E1j
                                            ; UpdateDatePlayers+4F3j
    fstp    dword ptr [esi+0BCh]
    xor     eax, eax
    mov     ax, [edi+0A3h]
    mov     [esp+44h+PlayerInfoPtr], eax
    mov     eax, [esi+0ECh]
    fild    [esp+44h+PlayerInfoPtr]
    cmp     dword ptr [eax], 0
    fmul    ds:flt_4FD550
    jz      short loc_4654E1
    cmp     byte ptr [eax+73h], 2
    jnz     short loc_4654E1
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+37EEEh]
    sub     eax, 0
    jz      short loc_4654CF
    dec     eax
    jnz     short loc_4654E1
    fmul    ds:dbl_4FD540
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_4654E7
    ; ---------------------------------------------------------------------------

    loc_4654CF:                             ; CODE XREF: UpdateDatePlayers+538j
    fmul    ds:dbl_4FD548
    fld     dword ptr [esi+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_4654E7
    ; ---------------------------------------------------------------------------

    loc_4654E1:                             ; CODE XREF: UpdateDatePlayers+521j
                                            ; UpdateDatePlayers+527j ...
    fadd    dword ptr [esi+0D4h]

    loc_4654E7:                             ; CODE XREF: UpdateDatePlayers+54Dj
                                            ; UpdateDatePlayers+55Fj
    fstp    dword ptr [esi+0D4h]
    push    1                               ; int
    call    Set_LOS_State
    push    1
    call    sub_48D630

    loc_4654FB:                             ; CODE XREF: UpdateDatePlayers+785j
                                            ; UpdateDatePlayers+863j
    mov     edi, [esp+44h+PlayerStructPtr]
    mov     bl, byte ptr [esp+44h+PlayerIndex]
    mov     ebp, 4

    loc_465508:                             ; CODE XREF: UpdateDatePlayers+123j
                                            ; UpdateDatePlayers+168j ...
    cmp     dword ptr [edi], 0
    jz      short loc_46555F
    mov     al, [edi+73h]
    cmp     al, 1
    jz      short loc_46551C
    cmp     al, 2
    jz      short loc_46551C
    cmp     al, 3
    jnz     short loc_46555F

    loc_46551C:                             ; CODE XREF: UpdateDatePlayers+592j
                                            ; UpdateDatePlayers+596j
    cmp     byte ptr [edi+146h], 0Ah
    jz      short loc_46555F
    cmp     word ptr [edi+144h], 0
    jnz     short loc_465539
    mov     ecx, [edi+140h]
    test    ecx, ecx
    jnz     short loc_46555F

    loc_465539:                             ; CODE XREF: UpdateDatePlayers+5ADj
    cmp     al, 1
    jz      short loc_465541
    cmp     al, 2
    jnz     short loc_46555F

    loc_465541:                             ; CODE XREF: UpdateDatePlayers+5BBj
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+3923Bh], 4
    jnz     short loc_46555F
    cmp     word ptr [eax+39239h], 0
    jge     short loc_46555F
    push    edi                             ; int
    call    sub_401360

    loc_46555F:                             ; CODE XREF: UpdateDatePlayers+58Bj
                                            ; UpdateDatePlayers+59Aj ...
    mov     ecx, TAdynmemStructPtr
    cmp     bl, [ecx+TAdynmemStruct.LOS_Sight]
    jnz     short loc_4655A6
    call    GameUnit_LOS_Radar
    call    GameUnit_LOS_MiniMap
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+TAdynmemStruct.MapFile]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_4655A6
    mov     eax, dword_51E53C
    inc     eax
    test    al, 3
    mov     dword_51E53C, eax
    jnz     short loc_4655A6
    push    0
    push    0
    push    edi
    call    sub_4573D0

    loc_4655A6:                             ; CODE XREF: UpdateDatePlayers+25j
                                            ; UpdateDatePlayers+5Bj ...
    inc     bl
    cmp     bl, 10
    mov     byte ptr [esp+44h+PlayerIndex], bl
    jb      loc_464FAB
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+TAdynmemStruct.MapFile]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_46563B
    mov     ecx, TAdynmemStructPtr
    cmp     dword ptr [ecx+37EF6h], 2
    jz      short loc_46563B
    call    sub_457CB0
    test    eax, eax
    jnz     short loc_46563B
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+39239h]
    test    ax, ax
    jge     short loc_465603
    mov     [ecx+39239h], bp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------

    loc_465603:                             ; CODE XREF: UpdateDatePlayers+672j
    dec     eax
    mov     [ecx+39239h], ax
    mov     eax, TAdynmemStructPtr
    cmp     word ptr [eax+39239h], 0
    jge     short loc_46563B
    or      [eax+3923Bh], bp
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 40h

    loc_46563B:                             ; CODE XREF: UpdateDatePlayers+648j
                                            ; UpdateDatePlayers+657j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------

    loc_465643:                             ; CODE XREF: UpdateDatePlayers+239j
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     loc_46582E
    mov     al, [edi+22h]
    test    al, al
    jnz     loc_46582E
    call    sub_456850
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    mov     ecx, [eax+edx*2+1B8Ah]
    test    byte ptr [ecx+9Bh], 80h
    jnz     short loc_46569A
    call    sub_457BC0
    test    eax, eax
    jle     loc_46582E

    loc_46569A:                             ; CODE XREF: UpdateDatePlayers+70Bj
    mov     eax, [edi+27h]
    or      byte ptr [eax+9Bh], 40h
    mov     eax, TAdynmemStructPtr
    cmp     bl, [eax+2A42h]
    jnz     loc_465508
    and     word ptr [eax+14281h], 0FFFEh
    mov     eax, TAdynmemStructPtr
    push    1                               ; int
    and     word ptr [eax+14281h], 0FFFDh
    call    Set_LOS_State
    call    sub_450F90
    call    sub_457BC0
    test    eax, eax
    jnz     loc_4657E8
    mov     edx, TAdynmemStructPtr
    push    900h
    add     edx, 519h
    push    offset aYesorno_gui             ; "YESORNO.GUI"
    push    edx
    call    sub_4AA8F0
    mov     ebx, eax
    test    ebx, ebx
    jz      loc_4654FB
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    mov     ebp, [ebx+4]
    push    0
    push    offset aYes                     ; "Yes"
    add     ecx, 519h
    push    offset aChoice1                 ; "CHOICE1"
    push    ecx
    call    sub_4A0BF0
    mov     edx, TAdynmemStructPtr
    push    0
    push    offset aNo                      ; "No"
    add     edx, 519h
    push    offset aChoice2                 ; "CHOICE2"
    push    edx
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    push    0
    push    offset aYouReOutContin          ; "You're out!  Continue Watching?"
    add     eax, 519h
    push    offset aTitle                   ; "TITLE"
    push    eax
    call    sub_4A0BF0
    mov     edi, offset aChoice1            ; "CHOICE1"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp+0CCh]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    40h
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [ebp+0DCh]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, offset aChoice2            ; "CHOICE2"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     dword ptr [ebx+8], offset sub_464DE0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    jmp     loc_4654FB
    ; ---------------------------------------------------------------------------

    loc_4657E8:                             ; CODE XREF: UpdateDatePlayers+75Fj
    call    sub_457CB0
    test    eax, eax
    jle     loc_465508
    push    1
    push    1
    push    1F4h
    push    offset aYouArePlacedIn          ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh
    jmp     loc_465508
    ; ---------------------------------------------------------------------------

    loc_46582E:                             ; CODE XREF: UpdateDatePlayers+6D1j
                                            ; UpdateDatePlayers+6DCj ...
    mov     eax, TAdynmemStructPtr
    or      [eax+3923Bh], bp
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh
    mov     al, [edi+22h]
    test    al, al
    jnz     loc_465508
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 40h
    jmp     loc_465508
    ; ---------------------------------------------------------------------------

    loc_465864:                             ; CODE XREF: UpdateDatePlayers+1DBj
                                            ; UpdateDatePlayers+1F4j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391EDh]
    call    sub_490230
    test    eax, eax
    jz      loc_465508
    mov     eax, TAdynmemStructPtr

    loc_465881:                             ; CODE XREF: UpdateDatePlayers+155j
    mov     cx, [eax+39239h]
    test    cx, cx
    jge     short loc_465899
    mov     [eax+39239h], bp
    jmp     loc_465508
    ; ---------------------------------------------------------------------------

    loc_465899:                             ; CODE XREF: UpdateDatePlayers+90Bj
    dec     ecx
    mov     [eax+39239h], cx
    mov     eax, TAdynmemStructPtr
    cmp     word ptr [eax+39239h], 0
    jge     loc_465508
    or      [eax+3923Bh], bp
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 10h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+3923Bh], 20h
    jmp     loc_465508
    UpdateDatePlayers endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4658E0(int Player,int a2,int a3,int a4,int a5,__int16)
    sub_4658E0 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+C1Fp
                                            ; GameUnit_LOS_Unknown1+DACp

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    Player= dword ptr  4
    a2= dword ptr  8
    a3= dword ptr  0Ch
    a4= dword ptr  10h
    a5= dword ptr  14h
    arg_14= word ptr  18h

    sub     esp, 0Ch
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     [esp+0Ch+var_C], eax
    push    ebx
    mov     ebx, [esp+10h+a3]
    mov     [esp+10h+var_8], eax
    push    ebp
    push    esi
    mov     [esp+18h+var_4], eax
    mov     ax, [ecx+14281h]
    push    edi
    mov     edi, [esp+1Ch+a2]
    and     ax, 2
    shl     edi, 4
    shl     ebx, 4
    cmp     ax, 2
    mov     word ptr [esp+1Ch+a2], ax
    movsx   edx, di
    jnz     short loc_46596A
    movsx   esi, [esp+1Ch+arg_14]
    mov     eax, [esp+1Ch+Player]
    movsx   ecx, bx
    mov     ebp, [eax+80h]
    sar     esi, 1
    sub     ecx, esi
    sar     edx, 5
    sar     ecx, 5
    cmp     edx, ebp
    jnb     short loc_465966
    cmp     ecx, [eax+84h]
    jnb     short loc_465966
    mov     ebp, [eax+80h]
    imul    ebp, ecx
    add     ebp, edx
    mov     edx, [eax+7Ch]
    cmp     byte ptr [ebp+edx+0], 0
    jz      short loc_465966
    mov     edx, 1
    jmp     short loc_4659D0
    ; ---------------------------------------------------------------------------

    loc_465966:                             ; CODE XREF: sub_4658E0+60j
                                            ; sub_4658E0+68j ...
    xor     edx, edx
    jmp     short loc_4659D0
    ; ---------------------------------------------------------------------------

    loc_46596A:                             ; CODE XREF: sub_4658E0+40j
    movsx   esi, [esp+1Ch+arg_14]
    mov     eax, [esp+1Ch+Player]
    movsx   ecx, bx
    mov     ebp, [eax+80h]
    sar     esi, 1
    sub     ecx, esi
    sar     edx, 5
    sar     ecx, 5
    cmp     edx, ebp
    jnb     short loc_465992
    cmp     ecx, [eax+84h]
    jb      short loc_465996

    loc_465992:                             ; CODE XREF: sub_4658E0+A8j
    xor     edx, edx
    jmp     short loc_4659D0
    ; ---------------------------------------------------------------------------

    loc_465996:                             ; CODE XREF: sub_4658E0+B0j
    mov     ebp, [eax+80h]
    imul    ebp, ecx
    mov     ecx, TAdynmemStructPtr
    add     ebp, edx
    mov     edx, [ecx+14273h]
    xor     ecx, ecx
    mov     cx, [edx+ebp*2]
    mov     ebp, 1
    mov     edx, ecx
    mov     ecx, TAdynmemStructPtr
    mov     cl, [ecx+TAdynmemStruct.LOS_Sight]
    shl     ebp, cl
    and     edx, ebp
    neg     edx
    sbb     edx, edx
    neg     edx

    loc_4659D0:                             ; CODE XREF: sub_4658E0+84j
                                            ; sub_4658E0+88j ...
    test    edx, edx
    jz      short loc_4659E3
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4659E3:                             ; CODE XREF: sub_4658E0+F2j
    mov     edx, [esp+1Ch+a4]
    mov     ecx, [esp+1Ch+a5]
    shl     edx, 4
    shl     ecx, 4
    add     di, dx
    add     bx, cx
    cmp     word ptr [esp+1Ch+a2], 2
    movsx   edx, di
    jnz     short loc_465A4E
    movsx   ecx, bx
    sub     ecx, esi
    mov     esi, [eax+80h]
    sar     edx, 5
    sar     ecx, 5
    cmp     edx, esi
    jnb     short loc_465A42
    cmp     ecx, [eax+84h]
    jnb     short loc_465A42
    mov     esi, [eax+80h]
    imul    esi, ecx
    add     esi, edx
    mov     edx, [eax+7Ch]
    cmp     byte ptr [esi+edx], 0
    jz      short loc_465A42
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_465A42:                             ; CODE XREF: sub_4658E0+135j
                                            ; sub_4658E0+13Dj ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_465A4E:                             ; CODE XREF: sub_4658E0+120j
    movsx   ecx, bx
    sub     ecx, esi
    mov     esi, [eax+80h]
    sar     edx, 5
    sar     ecx, 5
    cmp     edx, esi
    jnb     short loc_465A6B
    cmp     ecx, [eax+84h]
    jb      short loc_465A77

    loc_465A6B:                             ; CODE XREF: sub_4658E0+181j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_465A77:                             ; CODE XREF: sub_4658E0+189j
    mov     eax, [eax+80h]
    xor     esi, esi
    imul    eax, ecx
    mov     ecx, TAdynmemStructPtr
    add     eax, edx
    pop     edi
    mov     edx, [ecx+14273h]
    mov     cl, [ecx+TAdynmemStruct.LOS_Sight]
    mov     si, [edx+eax*2]
    mov     edx, 1
    shl     edx, cl
    mov     eax, esi
    pop     esi
    pop     ebp
    pop     ebx
    and     eax, edx
    neg     eax
    sbb     eax, eax
    neg     eax
    add     esp, 0Ch
    retn    18h
    sub_4658E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall PlayerCanSeeUnit(PlayerStruct *Player,UnitStruct *Unit)
    PlayerCanSeeUnit proc near              ; CODE XREF: sub_40AA40+D1p
                                            ; sub_439740+21p ...

    XWidth= dword ptr -0Ch
    ZWidth= dword ptr -8
    YWidth= dword ptr -4
    Player= dword ptr  4
    Unit= dword ptr  8

    sub     esp, 0Ch
    push    ebx
    mov     ebx, [esp+10h+Unit]
    push    ebp
    push    esi
    mov     esi, [esp+18h+Player]
    mov     eax, [ebx+UnitStruct.Owner]
    cmp     eax, esi
    push    edi
    jnz     short loc_465AE8
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_465AE8:                             ; CODE XREF: PlayerCanSeeUnit+17j
    test    [ebx+UnitStruct.cIsCloaked], 4
    jz      short loc_465AFD
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_465AFD:                             ; CODE XREF: PlayerCanSeeUnit+2Fj
    mov     eax, [ebx+UnitStruct.UnitType]

    loc_465B03:
    mov     ebp, [ebx+UnitStruct.XPos]
    mov     edi, [ebx+UnitStruct.ZPos]
    mov     ecx, [eax+UnitDefStruct.XWidth]
    add     ecx, ebp
    mov     ebp, TAdynmemStructPtr
    mov     [esp+1Ch+XWidth], ecx
    mov     edx, [eax+UnitDefStruct.ZWidth]
    mov     ecx, [ebx+UnitStruct.YPos]
    add     edx, edi
    mov     [esp+1Ch+ZWidth], edx
    mov     edi, [eax+UnitDefStruct.YWidth]
    mov     eax, dword ptr [ebx+UnitStruct.UnitSelected]
    add     edi, ecx
    test    ah, 2
    mov     [esp+1Ch+YWidth], edi
    jnz     short loc_465B5C
    xor     eax, eax
    mov     al, [ebp+TAdynmemStruct.data12]
    shl     eax, 10h
    cmp     edx, eax
    jge     short loc_465B5C
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_465B5C:                             ; CODE XREF: PlayerCanSeeUnit+7Fj
                                            ; PlayerCanSeeUnit+8Ej
    mov     cl, [ebp+14281h]
    and     cl, 2
    cmp     cl, 2
    jnz     short loc_465BB5
    movsx   ebp, word ptr [esp+1Ch+ZWidth+2]
    movsx   eax, word ptr [esp+1Ch+YWidth+2]
    movsx   ecx, word ptr [esp+1Ch+XWidth+2]
    sar     ebp, 1
    sub     eax, ebp
    mov     ebp, [esi+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebp
    jnb     short loc_465BB1
    cmp     eax, [esi+84h]
    jnb     short loc_465BB1
    mov     ebp, [esi+80h]
    imul    ebp, eax
    mov     eax, [esi+7Ch]
    add     ebp, ecx
    cmp     byte ptr [ebp+eax+0], 0
    jz      short loc_465BB1
    mov     eax, 1
    jmp     short loc_465BC8
    ; ---------------------------------------------------------------------------

    loc_465BB1:                             ; CODE XREF: PlayerCanSeeUnit+CBj
                                            ; PlayerCanSeeUnit+D3j ...
    xor     eax, eax
    jmp     short loc_465BC8
    ; ---------------------------------------------------------------------------

    loc_465BB5:                             ; CODE XREF: PlayerCanSeeUnit+A8j
    lea     ecx, [esp+1Ch+XWidth]
    push    ecx                             ; int
    push    esi                             ; int
    call    sub_408090
    mov     edi, [esp+1Ch+YWidth]
    mov     edx, [esp+1Ch+ZWidth]

    loc_465BC8:                             ; CODE XREF: PlayerCanSeeUnit+EFj
                                            ; PlayerCanSeeUnit+F3j
    test    eax, eax
    jz      short loc_465BDB
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_465BDB:                             ; CODE XREF: PlayerCanSeeUnit+10Aj
    mov     eax, [ebx+92h]
    mov     ecx, [eax+176h]
    mov     eax, [esp+1Ch+XWidth]
    add     eax, ecx
    mov     [esp+1Ch+XWidth], eax
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+14281h]
    and     cl, 2
    cmp     cl, 2
    jnz     short loc_465C4D
    movsx   ebp, word ptr [esp+1Ch+ZWidth+2]
    movsx   eax, word ptr [esp+1Ch+YWidth+2]
    movsx   ecx, word ptr [esp+1Ch+XWidth+2]
    sar     ebp, 1
    sub     eax, ebp
    mov     ebp, [esi+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebp
    jnb     short loc_465C49
    cmp     eax, [esi+84h]
    jnb     short loc_465C49
    mov     ebp, [esi+80h]
    imul    ebp, eax
    add     ebp, [esi+7Ch]
    cmp     byte ptr [ebp+ecx+0], 0
    jz      short loc_465C49
    mov     eax, 1
    jmp     short loc_465C60
    ; ---------------------------------------------------------------------------

    loc_465C49:                             ; CODE XREF: PlayerCanSeeUnit+165j
                                            ; PlayerCanSeeUnit+16Dj ...
    xor     eax, eax
    jmp     short loc_465C60
    ; ---------------------------------------------------------------------------

    loc_465C4D:                             ; CODE XREF: PlayerCanSeeUnit+142j
    lea     edx, [esp+1Ch+XWidth]
    push    edx                             ; int
    push    esi                             ; int
    call    sub_408090
    mov     edi, [esp+1Ch+YWidth]
    mov     edx, [esp+1Ch+ZWidth]

    loc_465C60:                             ; CODE XREF: PlayerCanSeeUnit+187j
                                            ; PlayerCanSeeUnit+18Bj
    test    eax, eax
    jz      short loc_465C73
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_465C73:                             ; CODE XREF: PlayerCanSeeUnit+1A2j
    mov     eax, [ebx+92h]
    add     edi, [eax+17Eh]
    mov     [esp+1Ch+YWidth], edi
    mov     edi, [eax+17Ah]
    mov     eax, TAdynmemStructPtr
    sub     edx, edi
    mov     [esp+1Ch+ZWidth], edx
    mov     cl, [eax+14281h]
    and     cl, 2
    cmp     cl, 2
    jnz     short loc_465CF1
    mov     dx, word ptr [esp+1Ch+ZWidth+2]
    mov     di, word ptr [esp+1Ch+YWidth+2]
    movsx   ecx, word ptr [esp+1Ch+XWidth+2]
    movsx   ebp, dx
    movsx   eax, di
    sar     ebp, 1
    sub     eax, ebp
    mov     ebp, [esi+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebp
    jnb     short loc_465CED
    cmp     eax, [esi+84h]
    jnb     short loc_465CED
    mov     ebp, [esi+80h]
    imul    ebp, eax
    add     ebp, [esi+7Ch]
    cmp     byte ptr [ebp+ecx+0], 0
    jz      short loc_465CED
    mov     eax, 1
    jmp     short loc_465D06
    ; ---------------------------------------------------------------------------

    loc_465CED:                             ; CODE XREF: PlayerCanSeeUnit+209j
                                            ; PlayerCanSeeUnit+211j ...
    xor     eax, eax
    jmp     short loc_465D06
    ; ---------------------------------------------------------------------------

    loc_465CF1:                             ; CODE XREF: PlayerCanSeeUnit+1E0j
    lea     edx, [esp+1Ch+XWidth]
    push    edx                             ; int
    push    esi                             ; int
    call    sub_408090
    mov     di, word ptr [esp+1Ch+YWidth+2]
    mov     dx, word ptr [esp+1Ch+ZWidth+2]

    loc_465D06:                             ; CODE XREF: PlayerCanSeeUnit+22Bj
                                            ; PlayerCanSeeUnit+22Fj
    test    eax, eax
    jz      short loc_465D19
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_465D19:                             ; CODE XREF: PlayerCanSeeUnit+248j
    mov     eax, [ebx+92h]
    mov     ebx, TAdynmemStructPtr
    mov     ecx, [eax+176h]
    mov     eax, [esp+1Ch+XWidth]
    sub     eax, ecx
    mov     [esp+1Ch+XWidth], eax
    mov     al, [ebx+14281h]
    movsx   ecx, word ptr [esp+1Ch+XWidth+2]
    and     al, 2
    cmp     al, 2
    jnz     short loc_465DA9
    movsx   edx, dx
    movsx   eax, di
    sar     edx, 1
    sub     eax, edx
    mov     edx, [esi+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, edx
    jnb     short loc_465D94
    cmp     eax, [esi+84h]
    jnb     short loc_465D94
    mov     edx, [esi+80h]
    mov     edi, [esi+7Ch]
    imul    edx, eax
    add     edx, edi
    cmp     byte ptr [edx+ecx], 0
    jz      short loc_465D94
    mov     eax, 1
    xor     ecx, ecx
    test    eax, eax
    setnz   cl
    mov     eax, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_465D94:                             ; CODE XREF: PlayerCanSeeUnit+29Ej
                                            ; PlayerCanSeeUnit+2A6j ...
    xor     eax, eax
    xor     ecx, ecx
    test    eax, eax
    setnz   cl
    mov     eax, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_465DA9:                             ; CODE XREF: PlayerCanSeeUnit+284j
    movsx   edx, dx
    movsx   eax, di
    sar     edx, 1
    sub     eax, edx
    mov     edx, [esi+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, edx
    jnb     short loc_465DCB
    cmp     eax, [esi+84h]
    jb      short loc_465DE0

    loc_465DCB:                             ; CODE XREF: PlayerCanSeeUnit+301j
    xor     eax, eax
    xor     ecx, ecx
    test    eax, eax
    setnz   cl
    mov     eax, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_465DE0:                             ; CODE XREF: PlayerCanSeeUnit+309j
    mov     edx, [esi+80h]
    pop     edi
    imul    edx, eax
    mov     eax, [ebx+TAdynmemStruct.field_14273]
    add     edx, ecx
    xor     ecx, ecx
    pop     esi
    mov     cx, [eax+edx*2]
    mov     edx, 1
    mov     eax, ecx
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    shl     edx, cl
    pop     ebp
    pop     ebx
    and     eax, edx
    neg     eax
    sbb     eax, eax
    xor     ecx, ecx
    neg     eax
    test    eax, eax
    setnz   cl
    mov     eax, ecx
    add     esp, 0Ch
    retn    8
    PlayerCanSeeUnit endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_465E30 proc near                    ; CODE XREF: sub_497180+95Ep
                                            ; sub_497180+A95p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    xor     ebp, ebp
    push    edi
    mov     [esp+1Ch+var_C], ebp
    mov     [esp+1Ch+var_8], ebp
    mov     edi, 0D5Ch

    loc_465E46:                             ; CODE XREF: sub_465E30+165j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+1Ch+var_8]
    lea     esi, [eax+ecx+1B63h]
    mov     ecx, [eax+38D6Bh]
    test    ecx, ecx
    jnz     loc_465F72
    mov     ecx, [eax+391E9h]
    call    sub_435100
    dec     eax
    jz      loc_465F22
    dec     eax
    jz      short loc_465EF5
    dec     eax
    jnz     loc_465F72
    call    sub_456850
    and     eax, 0FFh
    mov     ecx, eax
    cmp     ecx, 0Ah
    jnz     short loc_465E95
    mov     ecx, [esp+1Ch+var_C]

    loc_465E95:                             ; CODE XREF: sub_465E30+5Fj
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    lea     ecx, [eax+edx*2+1B63h]
    xor     eax, eax
    mov     edx, [ecx+27h]
    mov     ax, [edx+0A1h]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 2
    mov     [esp+1Ch+var_4], eax
    xor     eax, eax
    fild    [esp+1Ch+var_4]
    fstp    dword ptr [esi+8Ch]
    mov     ecx, [ecx+27h]
    mov     ax, [ecx+0A3h]
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax*4]
    shl     edx, 2
    mov     [esp+1Ch+var_4], edx
    fild    [esp+1Ch+var_4]
    fstp    dword ptr [esi+98h]
    jmp     short loc_465F72
    ; ---------------------------------------------------------------------------

    loc_465EF5:                             ; CODE XREF: sub_465E30+47j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    fild    dword ptr [ecx+ebp+10h]
    fstp    dword ptr [esi+8Ch]
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    fild    dword ptr [eax+ebp+0Ch]
    fstp    dword ptr [esi+98h]
    jmp     short loc_465F72
    ; ---------------------------------------------------------------------------

    loc_465F22:                             ; CODE XREF: sub_465E30+40j
    mov     ecx, TAdynmemStructPtr
    mov     ebx, [ecx+391E9h]
    fld     dword ptr [edi+ebx+28h]
    call    __ftol
    fld     dword ptr [edi+ebx]
    push    eax
    call    __ftol
    push    eax
    push    esi
    call    sub_496E90
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391E9h]
    mov     ecx, [eax+edi+28h]
    mov     [esi+8Ch], ecx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391E9h]
    mov     ecx, [eax+edi]
    mov     [esi+98h], ecx

    loc_465F72:                             ; CODE XREF: sub_465E30+2Ej
                                            ; sub_465E30+4Aj ...
    mov     ebx, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+var_8]
    add     edi, 4
    inc     ebx
    add     edx, 14Bh
    add     ebp, 18h
    cmp     edi, 0D84h
    mov     [esp+1Ch+var_C], ebx
    mov     [esp+1Ch+var_8], edx
    jl      loc_465E46
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_465E30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_465FB0 proc near                    ; CODE XREF: sub_497180+3A7p

    var_14= dword ptr -14h
    var_10= byte ptr -10h
    arg_0= dword ptr  4

    sub     esp, 14h
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     edi, edi
    xor     ebx, ebx
    mov     [esp+24h+var_14], edi

    loc_465FBF:                             ; CODE XREF: sub_465FB0+87j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [esp+24h+var_14]
    push    ebx
    push    offset aPlayerI                 ; "Player%i"
    mov     esi, [eax+29A0h]
    lea     ebp, [eax+edi+1B63h]
    lea     eax, [esp+2Ch+var_10]
    add     esi, ecx
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+24h+var_10]
    push    ecx                             ; char *
    mov     ecx, [esp+28h+arg_0]
    call    sub_4B4560
    test    eax, eax
    jz      short loc_466015
    mov     ecx, [esp+24h+arg_0]
    push    0                               ; int
    push    offset aController              ; char *
    call    sub_4B4800
    mov     [esi], eax
    mov     dl, [esi]
    mov     [ebp+73h], dl
    jmp     short loc_46601F
    ; ---------------------------------------------------------------------------

    loc_466015:                             ; CODE XREF: sub_465FB0+4Aj
    mov     dword ptr [esi], 0
    mov     byte ptr [ebp+73h], 0

    loc_46601F:                             ; CODE XREF: sub_465FB0+63j
    mov     ecx, [esp+24h+var_14]
    add     edi, 14Bh
    inc     ebx
    add     ecx, 18h
    cmp     edi, 0CEEh
    mov     [esp+24h+var_14], ecx
    jl      short loc_465FBF
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    4
    sub_465FB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    ; int __stdcall sub_466050(int)
    sub_466050 proc near                    ; CODE XREF: sub_432610+3Ep

    var_14= dword ptr -14h
    var_10= byte ptr -10h
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    and     esp, 0FFFFFFF8h
    sub     esp, 14h
    push    ebx
    push    esi
    mov     esi, [ebp+arg_0]
    push    edi
    push    offset aPlayers                 ; char *
    mov     ecx, esi
    call    sub_4B4560
    push    0Ah                             ; int
    push    offset aHumanPlayer             ; char *
    mov     ecx, esi
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    push    offset aGametime                ; "GameTime"
    mov     [ecx+TAdynmemStruct.SharedBits], al
    mov     eax, TAdynmemStructPtr
    mov     ecx, esi
    mov     dl, [eax+TAdynmemStruct.SharedBits]
    mov     [eax+TAdynmemStruct.LOS_Sight], dl
    call    sub_4B4BA0
    mov     eax, TAdynmemStructPtr
    push    1Ch
    add     eax, 38A37h
    mov     ecx, esi
    push    eax
    call    sub_4B4C80
    cmp     eax, 1Ch
    jnz     loc_4662E0
    xor     ebx, ebx
    mov     [esp+20h+var_14], ebx

    loc_4660C5:                             ; CODE XREF: sub_466050+28Aj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+20h+var_14]
    push    ebx
    lea     eax, [esp+24h+var_10]
    push    offset aPlayerI                 ; "Player%i"
    push    eax
    lea     edi, [ecx+edx+1B63h]
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+20h+var_10]
    push    ecx                             ; char *
    mov     ecx, esi
    call    sub_4B4560
    test    eax, eax
    jz      loc_4662C3
    push    0
    push    0                               ; __int64
    push    offset aEnergy                  ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    dword ptr [edi+8Ch]
    push    0
    push    0                               ; __int64
    push    offset aMetal                   ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    dword ptr [edi+98h]
    push    0
    push    0                               ; __int64
    push    offset aTotalenergypro          ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    qword ptr [edi+0ACh]
    push    0
    push    0                               ; __int64
    push    offset aTotalmetalprod          ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    qword ptr [edi+0B4h]
    push    0
    push    0                               ; __int64
    push    offset aTotalenergycon          ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    qword ptr [edi+0BCh]
    push    0
    push    0                               ; __int64
    push    offset aTotalmetalcons          ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    qword ptr [edi+0C4h]
    push    0
    push    0                               ; __int64
    push    offset aEnergywasted            ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    qword ptr [edi+0CCh]
    push    0
    push    0                               ; __int64
    push    offset aMetalwasted             ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    qword ptr [edi+0D4h]
    push    0
    push    0                               ; __int64
    push    offset aPlayerenergyst          ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    dword ptr [edi+0DCh]
    push    0
    push    0                               ; __int64
    push    offset aPlayermetalsto          ; char *
    mov     ecx, esi
    call    sub_4B4850
    fstp    dword ptr [edi+0E0h]
    push    0                               ; int
    push    offset aAddplayerstora          ; char *
    mov     ecx, esi
    call    sub_4B4800
    mov     cx, [edi+149h]
    push    0                               ; int
    mov     dl, cl
    push    offset aKills                   ; char *
    xor     dl, al
    and     edx, 1
    xor     edx, ecx
    mov     ecx, esi
    mov     [edi+149h], dx
    call    sub_4B4800
    push    0                               ; int
    push    offset aLosses                  ; char *
    mov     ecx, esi
    mov     [edi+0FCh], ax
    call    sub_4B4800
    mov     [edi+0FEh], ax
    push    0                               ; int
    push    offset aUpdatetime              ; char *
    mov     ecx, esi
    call    sub_4B4800
    push    0                               ; int
    push    offset aWinlosetime             ; char *
    mov     ecx, esi
    mov     [edi+0F0h], eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aDisplaytimer            ; char *
    mov     ecx, esi
    mov     [edi+0F4h], eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aLogo                    ; char *
    mov     ecx, esi
    mov     [edi+0F8h], eax
    call    sub_4B4800
    mov     ecx, [edi+27h]
    push    0                               ; int
    push    offset aSide_0                  ; char *
    mov     [ecx+96h], al
    mov     ecx, esi
    call    sub_4B4800
    mov     edx, [edi+27h]
    push    offset aAlliances               ; "Alliances"
    mov     ecx, esi
    mov     [edx+95h], al
    call    sub_4B4BA0
    mov     ecx, esi
    call    sub_4B4BF0
    cmp     eax, 0Bh
    jnz     short loc_4662B9
    push    eax
    lea     eax, [edi+108h]
    push    eax
    mov     ecx, esi
    call    sub_4B4C80

    loc_4662B9:                             ; CODE XREF: sub_466050+258j
    mov     byte ptr [edi+ebx+108h], 1
    jmp     short loc_4662C7
    ; ---------------------------------------------------------------------------

    loc_4662C3:                             ; CODE XREF: sub_466050+A7j
    mov     byte ptr [edi+73h], 0

    loc_4662C7:                             ; CODE XREF: sub_466050+271j
    mov     eax, [esp+20h+var_14]
    inc     ebx
    add     eax, 14Bh
    cmp     eax, 0CEEh
    mov     [esp+20h+var_14], eax
    jl      loc_4660C5

    loc_4662E0:                             ; CODE XREF: sub_466050+69j
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    sub_466050 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4662F0 proc near                    ; CODE XREF: sub_4326B0+347p

    var_28= qword ptr -28h
    var_14= dword ptr -14h
    var_10= byte ptr -10h
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    and     esp, 0FFFFFFF8h
    sub     esp, 14h
    push    ebx
    push    esi
    push    edi
    mov     edi, [ebp+arg_0]
    push    offset aPlayers                 ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [ecx+2A42h]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aHumanPlayer             ; char *
    call    sub_4B4630
    push    offset aGametime                ; "GameTime"
    mov     ecx, edi
    call    sub_4B4BA0
    mov     edx, TAdynmemStructPtr
    push    1Ch
    add     edx, 38A37h
    mov     ecx, edi
    push    edx
    call    sub_4B4CF0
    xor     ebx, ebx
    xor     eax, eax
    mov     [esp+20h+var_14], eax

    loc_466350:                             ; CODE XREF: sub_4662F0+27Fj
    mov     ecx, TAdynmemStructPtr
    lea     esi, [ecx+eax+1B63h]
    mov     cl, [ecx+eax+1BD6h]
    test    cl, cl
    jz      loc_466560
    push    ebx
    lea     edx, [esp+24h+var_10]
    push    offset aPlayerI                 ; "Player%i"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+20h+var_10]
    mov     ecx, edi
    push    eax                             ; char *
    call    sub_4B4560
    fld     dword ptr [esi+8Ch]
    sub     esp, 8                          ; __int64
    mov     ecx, edi
    fstp    [esp+28h+var_28]
    push    offset aEnergy                  ; char *
    call    sub_4B46C0
    fld     dword ptr [esi+98h]
    sub     esp, 8                          ; __int64
    mov     ecx, edi
    fstp    [esp+28h+var_28]
    push    offset aMetal                   ; char *
    call    sub_4B46C0
    mov     ecx, [esi+0B0h]
    mov     edx, [esi+0ACh]
    push    ecx
    push    edx                             ; __int64
    push    offset aTotalenergypro          ; char *
    mov     ecx, edi
    call    sub_4B46C0
    mov     eax, [esi+0B8h]
    mov     ecx, [esi+0B4h]
    push    eax
    push    ecx                             ; __int64
    push    offset aTotalmetalprod          ; char *
    mov     ecx, edi
    call    sub_4B46C0
    mov     edx, [esi+0C0h]
    mov     eax, [esi+0BCh]
    push    edx
    push    eax                             ; __int64
    push    offset aTotalenergycon          ; char *
    mov     ecx, edi
    call    sub_4B46C0
    mov     ecx, [esi+0C8h]
    mov     edx, [esi+0C4h]
    push    ecx
    push    edx                             ; __int64
    push    offset aTotalmetalcons          ; char *
    mov     ecx, edi
    call    sub_4B46C0
    mov     eax, [esi+0D0h]
    mov     ecx, [esi+0CCh]
    push    eax
    push    ecx                             ; __int64
    push    offset aEnergywasted            ; char *
    mov     ecx, edi
    call    sub_4B46C0
    mov     edx, [esi+0D8h]
    mov     eax, [esi+0D4h]
    push    edx
    push    eax                             ; __int64
    push    offset aMetalwasted             ; char *
    mov     ecx, edi
    call    sub_4B46C0
    fld     dword ptr [esi+0DCh]
    sub     esp, 8                          ; __int64
    mov     ecx, edi
    fstp    [esp+28h+var_28]
    push    offset aPlayerenergyst          ; char *
    call    sub_4B46C0
    fld     dword ptr [esi+0E0h]
    sub     esp, 8                          ; __int64
    mov     ecx, edi
    fstp    [esp+28h+var_28]
    push    offset aPlayermetalsto          ; char *
    call    sub_4B46C0
    mov     cl, [esi+149h]
    and     ecx, 1
    push    ecx                             ; int
    push    offset aAddplayerstora          ; char *
    mov     ecx, edi
    call    sub_4B4630
    movsx   edx, word ptr [esi+0FCh]
    push    edx                             ; int
    push    offset aKills                   ; char *
    mov     ecx, edi
    call    sub_4B4630
    movsx   eax, word ptr [esi+0FEh]
    push    eax                             ; int
    push    offset aLosses                  ; char *
    mov     ecx, edi
    call    sub_4B4630
    mov     ecx, [esi+0F0h]
    push    ecx                             ; int
    push    offset aUpdatetime              ; char *
    mov     ecx, edi
    call    sub_4B4630
    mov     edx, [esi+0F4h]
    mov     ecx, edi
    push    edx                             ; int
    push    offset aWinlosetime             ; char *
    call    sub_4B4630
    mov     eax, [esi+0F8h]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aDisplaytimer            ; char *
    call    sub_4B4630
    xor     ecx, ecx
    mov     cl, [esi+73h]
    push    ecx                             ; int
    push    offset aController              ; char *
    mov     ecx, edi
    call    sub_4B4630
    mov     edx, [esi+27h]
    xor     eax, eax
    mov     ecx, edi
    mov     al, [edx+96h]
    push    eax                             ; int
    push    offset aLogo                    ; char *
    call    sub_4B4630
    mov     ecx, [esi+27h]
    xor     edx, edx
    mov     dl, [ecx+95h]
    mov     ecx, edi
    push    edx                             ; int
    push    offset aSide_0                  ; char *
    call    sub_4B4630
    push    offset aAlliances               ; "Alliances"
    mov     ecx, edi
    call    sub_4B4BA0
    add     esi, 108h
    push    0Bh
    push    esi
    mov     ecx, edi
    call    sub_4B4CF0
    mov     eax, [esp+20h+var_14]

    loc_466560:                             ; CODE XREF: sub_4662F0+76j
    add     eax, 14Bh
    inc     ebx
    cmp     eax, 0CEEh
    mov     [esp+20h+var_14], eax
    jl      loc_466350
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    sub_4662F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_466580 proc near                    ; CODE XREF: .text:004955E5p
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+142EFh]
    test    cx, cx
    jle     short loc_46659A
    dec     ecx
    mov     [eax+142EFh], cx
    retn
    ; ---------------------------------------------------------------------------

    loc_46659A:                             ; CODE XREF: sub_466580+Fj
    mov     word ptr [eax+142EFh], 7
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+142F1h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [ecx+142F1h], dx
    retn
    sub_466580 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4665D0 proc near                    ; CODE XREF: sub_444A20+12Ep

    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 80h
    push    edi
    mov     edi, [esp+84h+arg_0]
    test    edi, edi
    jz      loc_46676F
    mov     eax, [esp+84h+arg_C]
    mov     ecx, [esp+84h+arg_10]
    push    esi
    push    ebp
    push    ebx
    lea     ebx, [eax-20h]
    lea     ebp, [ecx-80h]
    cmp     ebx, ebp
    jl      short loc_466650
    mov     eax, ebp
    mov     edx, [esp+90h+arg_4]
    imul    eax, [esp+90h+arg_8]
    mov     [esp+90h+var_80], edx
    xor     esi, esi
    cdq
    idiv    ebx
    mov     si, [edi+2]
    xor     ecx, ecx
    mov     cx, [edi]
    mov     [esp+90h+var_78], ecx
    mov     [esp+90h+var_7C], eax
    mov     eax, ebp
    imul    eax, esi
    cdq
    idiv    ebx
    mov     edx, [esp+90h+var_7C]
    xor     ebx, ebx
    mov     [esp+90h+var_74], eax
    mov     eax, [esp+90h+arg_8]
    sub     eax, edx
    cdq
    sub     eax, edx
    mov     ebp, eax
    sar     ebp, 1
    jmp     short loc_46669D
    ; ---------------------------------------------------------------------------

    loc_466650:                             ; CODE XREF: sub_4665D0+2Fj
    mov     eax, ebx
    xor     ecx, ecx
    imul    eax, [esp+90h+arg_4]
    cdq
    idiv    ebp
    mov     cx, [edi]
    xor     esi, esi
    mov     si, [edi+2]
    mov     [esp+90h+var_74], esi
    mov     [esp+90h+var_80], eax
    mov     eax, [esp+90h+arg_8]
    mov     [esp+90h+var_7C], eax
    mov     eax, ebx
    imul    eax, ecx
    cdq
    idiv    ebp
    mov     ebp, [esp+90h+var_80]
    mov     [esp+90h+var_78], eax
    mov     eax, [esp+90h+arg_4]
    sub     eax, ebp
    cdq
    sub     eax, edx
    mov     ebx, eax
    sar     ebx, 1
    xor     ebp, ebp

    loc_46669D:                             ; CODE XREF: sub_4665D0+7Ej
    push    esi
    push    ecx
    push    offset aTempRadarPic            ; "TEMP RADAR PIC"
    call    sub_4B8DA0
    mov     esi, eax
    lea     ecx, [esp+90h+var_30]
    push    esi                             ; int
    push    ecx                             ; int
    call    sub_4B8A80
    push    0
    push    0
    lea     edx, [esp+98h+var_30]
    push    edi
    push    edx
    call    sub_4B7F90
    lea     edx, [esp+90h+var_30]
    push    edi                             ; int
    mov     ax, word ptr [esp+94h+arg_4]
    mov     cx, word ptr [esp+94h+arg_8]
    push    edx                             ; int
    mov     [edi], ax
    mov     [edi+2], cx
    call    sub_4B8A80
    xor     edi, edi
    lea     eax, [esp+90h+var_30]
    push    edi
    push    eax
    call    sub_4C6890
    mov     [esp+90h+var_4C], ebp
    mov     [esp+90h+var_44], ebp
    mov     ecx, [esp+90h+var_78]
    mov     edx, [esp+90h+var_74]
    mov     [esp+90h+var_70], edi
    mov     [esp+90h+var_6C], edi
    lea     eax, [ecx-1]
    mov     ecx, [esp+90h+var_7C]
    mov     [esp+90h+var_68], eax
    mov     [esp+90h+var_60], eax
    lea     eax, [edx-1]
    lea     edx, [esp+90h+var_70]
    mov     [esp+90h+var_5C], eax
    mov     [esp+90h+var_54], eax
    mov     eax, [esp+90h+var_80]
    add     ebp, ecx
    add     eax, ebx
    push    edx
    mov     [esp+94h+var_48], eax
    mov     [esp+94h+var_40], eax
    lea     eax, [esp+94h+var_50]
    lea     ecx, [esp+94h+var_30]
    push    eax
    push    esi
    push    ecx
    mov     [esp+0A0h+var_64], edi
    mov     [esp+0A0h+var_58], edi
    mov     [esp+0A0h+var_50], ebx
    mov     [esp+0A0h+var_3C], ebp
    mov     [esp+0A0h+var_38], ebx
    mov     [esp+0A0h+var_34], ebp
    call    sub_4C7580
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     ebx
    pop     ebp
    pop     esi

    loc_46676F:                             ; CODE XREF: sub_4665D0+10j
    pop     edi
    add     esp, 80h
    retn    14h
    sub_4665D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_466780 proc near                    ; CODE XREF: sub_4669B0p

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_18= dword ptr -18h

    sub     esp, 40h
    push    ebx
    mov     ebx, TAdynmemStructPtr
    push    ebp
    push    esi
    mov     ecx, [ebx+1422Bh]
    push    edi
    mov     edi, [ebx+1422Fh]
    cmp     ecx, edi
    jl      short loc_4667D1
    mov     eax, edi
    mov     esi, 7Eh
    shl     eax, 6
    sub     eax, edi
    mov     word ptr [ebx+142E7h], 0
    shl     eax, 1
    cdq
    idiv    ecx
    mov     ecx, TAdynmemStructPtr
    mov     edi, eax
    mov     eax, esi
    sub     eax, edi
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ecx+142E9h], ax
    jmp     short loc_466803
    ; ---------------------------------------------------------------------------

    loc_4667D1:                             ; CODE XREF: sub_466780+1Bj
    mov     eax, ecx
    shl     eax, 6
    sub     eax, ecx
    shl     eax, 1
    cdq
    idiv    edi
    mov     edi, 7Eh
    mov     esi, eax
    mov     eax, edi
    sub     eax, esi
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebx+142E7h], ax
    mov     edx, TAdynmemStructPtr
    mov     word ptr [edx+142E9h], 0

    loc_466803:                             ; CODE XREF: sub_466780+4Fj
    mov     eax, TAdynmemStructPtr
    push    edi                             ; int
    push    esi                             ; int
    push    offset aRadarPicture            ; int
    mov     [eax+142EBh], si
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142EDh], di
    call    sub_4C69F0
    mov     edx, TAdynmemStructPtr
    mov     [edx+142E3h], eax
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+50h+var_30]
    mov     ecx, [eax+142E3h]
    push    ecx
    push    edx
    call    sub_4B8AE0
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+1426Bh]
    test    eax, eax
    jz      short loc_46686C
    lea     ecx, [esp+50h+var_30]
    push    ecx
    push    eax
    call    sub_4B95A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn
    ; ---------------------------------------------------------------------------

    loc_46686C:                             ; CODE XREF: sub_466780+D7j
    lea     ebp, [edi+edi]
    lea     ebx, [esi+esi]
    push    ebp                             ; int
    push    ebx                             ; int
    push    offset aRadarpicTemp            ; int
    mov     [esp+5Ch+var_38], ebp
    mov     [esp+5Ch+var_3C], ebx
    call    sub_4C69F0
    mov     esi, eax
    test    ebp, ebp
    mov     [esp+50h+var_34], esi
    mov     [esp+50h+var_40], 0
    jle     loc_46697C

    loc_46689C:                             ; CODE XREF: sub_466780+1F2j
    xor     edi, edi
    test    ebx, ebx
    jle     loc_466967

    loc_4668A6:                             ; CODE XREF: sub_466780+1E1j
    mov     esi, TAdynmemStructPtr
    mov     eax, [esi+1422Bh]
    imul    eax, edi
    cdq
    idiv    ebx
    mov     ebx, eax
    mov     eax, [esi+1422Fh]
    imul    eax, [esp+50h+var_40]
    cdq
    idiv    ebp
    mov     ebp, eax
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     ecx, eax
    mov     eax, [esi+14233h]
    cdq
    sub     eax, edx
    sar     ecx, 5
    sar     eax, 1
    imul    ecx, eax
    mov     eax, ebx
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     edx, [esi+1428Bh]
    mov     esi, [esi+14283h]
    sar     eax, 5
    add     ecx, eax
    mov     cx, [edx+ecx*2]
    mov     edx, [esi]
    mov     eax, ecx
    and     eax, 0FFFFh
    cmp     eax, edx
    jl      short loc_46690F
    xor     ecx, ecx

    loc_46690F:                             ; CODE XREF: sub_466780+18Bj
    mov     eax, ebp
    and     ecx, 0FFFFh
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 1Fh
    xor     eax, edx
    shl     ecx, 5
    sub     eax, edx
    add     ecx, eax
    mov     eax, ebx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 1Fh
    xor     eax, edx
    shl     ecx, 5
    sub     eax, edx
    mov     edx, [esi+4]
    add     ecx, eax
    xor     eax, eax
    mov     al, [ecx+edx]
    mov     ecx, [esp+50h+var_40]
    mov     edx, [esp+50h+var_34]
    push    eax
    push    ecx
    push    edi
    push    edx
    call    sub_4BEE60
    inc     edi
    mov     eax, [esp+50h+var_3C]
    mov     ebp, [esp+50h+var_38]
    cmp     edi, eax
    mov     ebx, eax
    jl      loc_4668A6

    loc_466967:                             ; CODE XREF: sub_466780+120j
    mov     eax, [esp+50h+var_40]
    inc     eax
    cmp     eax, ebp
    mov     [esp+50h+var_40], eax
    jl      loc_46689C
    mov     esi, [esp+50h+var_34]

    loc_46697C:                             ; CODE XREF: sub_466780+116j
    lea     eax, [esp+50h+var_18]
    push    esi
    push    eax
    call    sub_4B8AE0
    lea     ecx, [esp+50h+var_30]
    lea     edx, [esp+50h+var_18]
    push    ecx
    push    edx
    call    sub_4B95A0
    push    esi
    call    sub_4C6AC0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn
    sub_466780 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4669B0 proc near                    ; CODE XREF: sub_4917D0+1F3p
    call    sub_466780
    mov     eax, TAdynmemStructPtr
    movsx   ecx, [eax+TAdynmemStruct.RadarPicSizeY]
    movsx   edx, [eax+TAdynmemStruct.RadarPicSizeX]
    push    ecx                             ; int
    push    edx                             ; int
    push    offset aRadarFinal              ; int
    call    sub_4C69F0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142DBh], eax
    mov     eax, TAdynmemStructPtr
    movsx   edx, [eax+TAdynmemStruct.RadarPicSizeY]
    movsx   eax, [eax+TAdynmemStruct.RadarPicSizeX]
    push    edx                             ; int
    push    eax                             ; int
    push    offset aRadarMapped             ; int
    call    sub_4C69F0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+TAdynmemStruct.RadarMapped], eax
    mov     eax, TAdynmemStructPtr
    movsx   edx, word ptr [eax+142E7h]
    mov     [eax+142BBh], edx
    mov     eax, TAdynmemStructPtr
    movsx   ecx, word ptr [eax+142E9h]
    mov     [eax+142BFh], ecx
    mov     eax, TAdynmemStructPtr
    movsx   edx, word ptr [eax+142EBh]
    movsx   ecx, word ptr [eax+142E7h]
    lea     edx, [edx+ecx-1]
    mov     [eax+142C3h], edx
    mov     eax, TAdynmemStructPtr
    movsx   ecx, word ptr [eax+142EDh]
    movsx   edx, word ptr [eax+142E9h]
    lea     ecx, [ecx+edx-1]
    mov     [eax+142C7h], ecx
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 4
    mov     edx, TAdynmemStructPtr
    mov     word ptr [edx+142EFh], 7
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+142F1h], 0FFFEh
    retn
    sub_4669B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_466AA0 proc near                    ; CODE XREF: sub_491B60+4Ep
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+TAdynmemStruct.RadarPicture]
    push    ecx
    call    sub_4C6AC0
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+TAdynmemStruct.RadarMapped]
    push    eax
    call    sub_4C6AC0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+TAdynmemStruct.RadarFinal]
    push    edx
    call    sub_4C6AC0
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     [ecx+TAdynmemStruct.RadarPicture], eax
    mov     edx, TAdynmemStructPtr
    mov     [edx+TAdynmemStruct.RadarMapped], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+TAdynmemStruct.RadarFinal], eax
    retn
    sub_466AA0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_466B00 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+92Fp

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+142F1h]
    mov     dl, al
    shr     dl, 1
    test    dl, 1
    jz      short locret_466B64
    and     eax, 0FFFDh
    push    esi
    mov     [ecx+142F1h], ax
    mov     eax, TAdynmemStructPtr
    mov     esi, [esp+4+arg_0]
    movsx   ecx, word ptr [eax+142E9h]
    movsx   edx, word ptr [eax+142E7h]
    mov     eax, [eax+142DBh]
    push    ecx
    push    edx
    push    eax
    push    esi
    call    sub_4C6B70
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [eax+0DD9h]
    add     eax, TAdynmemStruct.MinimapRect
    push    ecx
    push    eax
    push    esi
    call    sub_4BF8C0
    pop     esi

    locret_466B64:                          ; CODE XREF: sub_466B00+14j
    retn    4
    sub_466B00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall MiniMapUpdate_1(int)
    MiniMapUpdate_1 proc near               ; CODE XREF: sub_41C3C0+66p
                                            ; sub_41C3C0+82p

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    push    esi
    movsx   eax, [ecx+TAdynmemStruct.RadarPicSizeX]
    imul    eax, [ecx+TAdynmemStruct.MapX]
    cdq
    idiv    dword ptr [ecx+1422Bh]
    movsx   ecx, word ptr [ecx+142E7h]
    add     eax, ecx
    mov     ecx, [esp+4+arg_0]
    mov     [ecx], eax
    mov     esi, TAdynmemStructPtr
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeY]
    imul    eax, [esi+TAdynmemStruct.MapY]
    cdq
    idiv    dword ptr [esi+1422Fh]
    movsx   edx, word ptr [esi+142E9h]
    add     eax, edx
    mov     [ecx+4], eax
    mov     esi, TAdynmemStructPtr
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeX]
    imul    eax, [esi+1423Bh]
    shl     eax, 4
    cdq
    idiv    dword ptr [esi+1422Bh]
    mov     edx, [ecx]
    lea     eax, [eax+edx-1]
    mov     [ecx+8], eax
    mov     esi, TAdynmemStructPtr
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeY]
    imul    eax, [esi+1423Fh]
    shl     eax, 4
    cdq
    idiv    dword ptr [esi+1422Fh]
    mov     edx, [ecx+4]
    pop     esi
    lea     eax, [eax+edx-1]
    mov     [ecx+0Ch], eax
    retn    4
    MiniMapUpdate_1 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl GameUnit_LOS_MiniMap()
    GameUnit_LOS_MiniMap proc near          ; CODE XREF: UpdateDatePlayers+5F2p
                                            ; Set_LOS_State+27Ap

    var_21= byte ptr -21h
    RadarMapped_PixelPtr= dword ptr -20h
    RadarPicture_PixelPtr= dword ptr -1Ch
    var_18= dword ptr -18h
    ProjectileNumber= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    CurrentPlayer= dword ptr -8
    var_4= dword ptr -4

    mov     ecx, TAdynmemStructPtr
    sub     esp, 24h
    mov     ax, [ecx+142F1h]
    mov     dl, al
    shr     dl, 2
    test    dl, 1
    jz      loc_466DAE
    and     eax, 0FFFBh
    push    esi
    mov     [ecx+142F1h], ax
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    push    ebp
    mov     al, [esi+0DCBh]
    mov     cl, [esi+TAdynmemStruct.LOS_Sight]
    mov     [esp+2Ch+var_21], al
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    push    ebx
    xor     ebx, ebx
    lea     edx, [eax+eax*4]
    lea     eax, [esi+ecx]
    mov     [esp+30h+var_10], ebx
    lea     edx, [eax+edx*2+TAdynmemStruct.Players]
    mov     eax, 1
    shl     eax, cl
    mov     [esp+30h+CurrentPlayer], edx
    mov     edx, [esi+TAdynmemStruct.RadarPicture]
    mov     [esp+30h+var_C], eax
    mov     eax, [esi+TAdynmemStruct.RadarMapped]
    mov     ecx, [eax+RadarPicStruc.PixelPTR]
    mov     eax, [edx+RadarPicStruc.PixelPTR]
    mov     [esp+30h+RadarPicture_PixelPtr], eax
    mov     eax, [esi+TAdynmemStruct.FeatureMapSizeX]
    cdq
    sub     eax, edx
    mov     [esp+30h+RadarMapped_PixelPtr], ecx
    mov     ebp, eax
    mov     eax, [esi+TAdynmemStruct.FeatureMapSizeY]
    cdq
    sub     eax, edx
    sar     ebp, 1
    sar     eax, 1
    cmp     [esi+TAdynmemStruct.RadarPicSizeY], bx
    mov     [esp+30h+var_4], eax
    jle     loc_466DA4
    push    edi
    mov     [esp+34h+var_18], ebx

    loc_466CD6:                             ; CODE XREF: GameUnit_LOS_MiniMap+17Dj
    movsx   edi, [esi+TAdynmemStruct.RadarPicSizeX]
    cmp     edi, ebx
    mov     [esp+34h+ProjectileNumber], ebx
    jle     loc_466D81

    loc_466CE9:                             ; CODE XREF: GameUnit_LOS_MiniMap+155j
    mov     eax, [esp+34h+var_18]
    movsx   ecx, [esi+TAdynmemStruct.RadarPicSizeY]
    cdq
    idiv    ecx
    mov     ecx, eax
    mov     eax, ebx
    cdq
    imul    ecx, ebp
    idiv    edi
    mov     edx, [esi+TAdynmemStruct.field_14273]
    mov     edi, [esp+34h+var_C]
    add     ecx, eax
    mov     ax, [edx+ecx*2]
    and     eax, edi
    test    ax, ax
    jnz     short loc_466D1E
    mov     cl, [esp+34h+var_21]
    jmp     short loc_466D47
    ; ---------------------------------------------------------------------------

    loc_466D1E:                             ; CODE XREF: GameUnit_LOS_MiniMap+F6j
    mov     eax, [esp+34h+CurrentPlayer]
    mov     edx, [eax+PlayerStruct.field_7C]
    cmp     byte ptr [edx+ecx], 0
    jz      short loc_466D33
    mov     eax, [esp+34h+RadarPicture_PixelPtr]
    mov     cl, [eax]
    jmp     short loc_466D47
    ; ---------------------------------------------------------------------------

    loc_466D33:                             ; CODE XREF: GameUnit_LOS_MiniMap+109j
    mov     eax, [esi+0Ch]
    mov     edx, [esp+34h+RadarPicture_PixelPtr]
    xor     ecx, ecx
    mov     cl, [edx]
    mov     eax, [eax+0CCh]
    mov     cl, [eax+ecx]

    loc_466D47:                             ; CODE XREF: GameUnit_LOS_MiniMap+FCj
                                            ; GameUnit_LOS_MiniMap+111j
    mov     eax, [esp+34h+ProjectileNumber]
    mov     esi, [esp+34h+RadarPicture_PixelPtr]
    mov     edx, [esp+34h+RadarMapped_PixelPtr]
    inc     eax
    add     ebx, ebp
    inc     esi
    mov     [edx], cl
    mov     [esp+34h+RadarPicture_PixelPtr], esi
    mov     esi, TAdynmemStructPtr
    inc     edx
    mov     [esp+34h+ProjectileNumber], eax
    mov     [esp+34h+RadarMapped_PixelPtr], edx
    movsx   edi, [esi+TAdynmemStruct.RadarPicSizeX]
    cmp     eax, edi
    jl      loc_466CE9
    mov     eax, [esp+34h+var_4]
    xor     ebx, ebx

    loc_466D81:                             ; CODE XREF: GameUnit_LOS_MiniMap+C3j
    mov     edx, [esp+34h+var_18]
    mov     ecx, [esp+34h+var_10]
    add     edx, eax
    inc     ecx
    mov     [esp+34h+var_18], edx
    mov     [esp+34h+var_10], ecx
    movsx   edx, [esi+TAdynmemStruct.RadarPicSizeY]
    cmp     ecx, edx
    jl      loc_466CD6
    pop     edi

    loc_466DA4:                             ; CODE XREF: GameUnit_LOS_MiniMap+ABj
    or      byte ptr [esi+142F1h], 2
    pop     ebx
    pop     ebp
    pop     esi

    loc_466DAE:                             ; CODE XREF: GameUnit_LOS_MiniMap+18j
    add     esp, 24h
    retn
    GameUnit_LOS_MiniMap endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl GameUnit_LOS_Minimap_UnitsProjectiles()
    GameUnit_LOS_Minimap_UnitsProjectiles proc near ; CODE XREF: UpdateDatePlayers+F2p
                                            ; Set_LOS_State+27Fp

    RadarFinal= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    Projectiles= dword ptr -10h
    var_C= dword ptr -0Ch
    HotRadarUnits= dword ptr -8
    NumProjectiles= dword ptr -4

    sub     esp, 1Ch
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     edx, [eax+TAdynmemStruct.HotRadarUnits]
    push    edi
    xor     edi, edi
    lea     ecx, [eax+0DCBh]
    mov     [eax+TAdynmemStruct.NumHotRadarUnits], edi
    mov     eax, TAdynmemStructPtr
    mov     [esp+2Ch+var_18], ecx
    push    edi
    mov     ecx, [eax+TAdynmemStruct.RadarFinal]
    mov     eax, [eax+TAdynmemStruct.RadarMapped]
    push    edi
    push    eax
    push    ecx
    mov     [esp+3Ch+HotRadarUnits], edx
    mov     [esp+3Ch+RadarFinal], ecx
    call    sub_4C6B70
    mov     esi, TAdynmemStructPtr
    mov     [esp+2Ch+Projectiles], 1
    mov     ax, [esi+14281h]
    test    al, 3
    jz      short loc_466E23
    mov     [esp+2Ch+Projectiles], edi

    loc_466E23:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+5Dj
    mov     cx, [esi+37F2Fh]
    shr     ecx, 9
    test    cl, 1
    jz      short loc_466E3A
    mov     [esp+2Ch+Projectiles], 1

    loc_466E3A:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+70j
    mov     ebx, [esi+TAdynmemStruct.Units]
    mov     eax, [esi+TAdynmemStruct.Units_EndMarker]
    cmp     ebx, eax
    ja      loc_4671A0

    loc_466E4E:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+3DAj
    cmp     word ptr [ebx+0A6h], 0
    jz      NextUnit
    mov     eax, [esp+2Ch+Projectiles]
    test    eax, eax
    jnz     short CanSeeUnit
    mov     eax, dword ptr [ebx+UnitStruct.UnitSelected]
    test    ah, 3
    jnz     short CanSeeUnit
    mov     dl, [ebx+UnitStruct.OwnerIndex]
    mov     al, [esi+TAdynmemStruct.LOS_Sight]
    cmp     dl, al
    jnz     NextUnit

    CanSeeUnit:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+A2j
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+ADj
    movsx   eax, word ptr [ebx+6Ch]
    movsx   ecx, [esi+TAdynmemStruct.RadarPicSizeX]
    imul    eax, ecx
    cdq
    idiv    dword ptr [esi+1422Bh]
    movsx   edx, word ptr [ebx+70h]
    movsx   ecx, [esi+TAdynmemStruct.RadarPicSizeY]
    sar     edx, 1
    mov     edi, eax
    movsx   eax, word ptr [ebx+74h]
    sub     eax, edx
    imul    eax, ecx
    cdq
    idiv    dword ptr [esi+1422Fh]
    mov     ebp, eax
    mov     al, [ebx+UnitStruct.RecentDamage]
    test    al, al
    jz      short loc_466ECC
    test    byte ptr [esi+142F1h], 1
    jz      short loc_466F11

    loc_466ECC:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+101j
    xor     ecx, ecx
    push    ebp
    mov     cl, [ebx+UnitStruct.OwnerIndex]
    push    edi
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, esi
    add     eax, ecx
    mov     ecx, [eax+edx*2+TAdynmemStruct.Players.PlayerInfo]
    mov     eax, [esi+147DFh]
    xor     edx, edx
    mov     dl, [ecx+96h]
    push    edx
    push    eax
    call    sub_4B7F30
    push    eax
    mov     ecx, [esp+38h+RadarFinal]
    push    ecx
    call    sub_4B7F90
    mov     esi, TAdynmemStructPtr

    loc_466F11:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+10Aj
    mov     dx, [ebx+0A8h]
    cmp     dx, [esi+TAdynmemStruct.MouseOverUnit]
    jnz     short loc_466F42
    mov     eax, [esi+147E3h]
    push    ebp
    push    edi
    push    0
    push    eax
    call    sub_4B7F30
    push    eax
    mov     ecx, [esp+38h+RadarFinal]
    push    ecx
    call    sub_4B7F90
    mov     esi, TAdynmemStructPtr

    loc_466F42:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+15Fj
    mov     edx, [ebx+110h]
    shr     edx, 4
    test    dl, 1
    jz      loc_46713B
    test    [ebx+UnitStruct.cIsCloaked], 1
    jnz     short loc_466F70
    mov     eax, [ebx+UnitStruct.UnitType]
    test    byte ptr [eax+245h], 4
    jnz     loc_46707C

    loc_466F70:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+19Bj
    mov     ecx, [ebx+UnitStruct.UnitType]
    mov     cx, [ecx+204h]
    test    cx, cx
    jz      short loc_466FB3
    mov     eax, [esp+2Ch+var_18]
    xor     edx, edx
    movsx   ecx, cx
    mov     dl, [eax+0Ah]
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeX]
    imul    eax, ecx
    push    edx
    cdq
    idiv    dword ptr [esi+1422Bh]
    mov     edx, [esp+30h+RadarFinal]
    push    eax
    push    ebp
    push    edi
    push    edx
    call    sub_4C0070
    mov     esi, TAdynmemStructPtr

    loc_466FB3:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+1C0j
    mov     eax, [ebx+92h]
    mov     cx, [eax+206h]
    test    cx, cx
    jz      short loc_466FF6
    mov     eax, [esp+2Ch+var_18]
    xor     edx, edx
    movsx   ecx, cx
    mov     dl, [eax+0Ah]
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeX]
    imul    eax, ecx
    push    edx
    cdq
    idiv    dword ptr [esi+1422Bh]
    mov     edx, [esp+30h+RadarFinal]
    push    eax
    push    ebp
    push    edi
    push    edx
    call    sub_4C0070
    mov     esi, TAdynmemStructPtr

    loc_466FF6:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+203j
    mov     eax, [ebx+UnitStruct.UnitType]
    mov     cx, [eax+20Ah]
    test    cx, cx
    jz      short loc_467039
    mov     eax, [esp+2Ch+var_18]
    xor     edx, edx
    movsx   ecx, cx
    mov     dl, [eax+0Ch]
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeX]
    imul    eax, ecx
    push    edx
    cdq
    idiv    dword ptr [esi+1422Bh]
    mov     edx, [esp+30h+RadarFinal]
    push    eax
    push    ebp
    push    edi
    push    edx
    call    sub_4C0070
    mov     esi, TAdynmemStructPtr

    loc_467039:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+246j
    mov     eax, [ebx+92h]
    mov     cx, [eax+20Ch]
    test    cx, cx
    jz      short loc_46707C
    mov     eax, [esp+2Ch+var_18]
    xor     edx, edx
    movsx   ecx, cx
    mov     dl, [eax+0Ch]
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeX]
    imul    eax, ecx
    push    edx
    cdq
    idiv    dword ptr [esi+1422Bh]
    mov     edx, [esp+30h+RadarFinal]
    push    eax
    push    ebp
    push    edi
    push    edx
    call    sub_4C0070
    mov     esi, TAdynmemStructPtr

    loc_46707C:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+1AAj
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+289j
    mov     eax, [ebx+92h]
    mov     ecx, [eax+241h]
    shr     ecx, 1Dh
    test    cl, 1
    jz      loc_46713B
    lea     edx, [ebx+10h]
    mov     [esp+2Ch+var_C], 3
    mov     [esp+2Ch+var_14], edx

    loc_4670A3:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+375j
    mov     eax, [esp+2Ch+var_14]
    mov     ecx, [eax]
    mov     edx, [ecx+111h]
    shr     edx, 1Eh
    test    dl, 1
    jz      short loc_467121
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeX]
    mov     ecx, [ecx+0E0h]
    sub     ecx, 200h
    imul    eax, ecx
    cdq
    idiv    dword ptr [esi+1422Bh]
    mov     edx, [esp+2Ch+var_14]
    mov     cl, [edx+0Eh]
    test    cl, cl
    jz      short loc_467104
    mov     cl, [esi+142F1h]
    xor     edx, edx
    and     ecx, 1
    push    ecx
    mov     ecx, [esp+30h+var_18]
    push    20h
    mov     dl, [ecx+0Fh]
    push    edx
    mov     edx, [esp+38h+RadarFinal]
    push    eax
    push    ebp
    push    edi
    push    edx
    call    sub_4C01A0
    jmp     short loc_46711B
    ; ---------------------------------------------------------------------------

    loc_467104:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+31Dj
    mov     edx, [esp+2Ch+var_18]
    xor     ecx, ecx
    mov     cl, [edx+0Fh]
    push    ecx
    push    eax
    mov     eax, [esp+34h+RadarFinal]
    push    ebp
    push    edi
    push    eax
    call    sub_4C0070

    loc_46711B:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+342j
    mov     esi, TAdynmemStructPtr

    loc_467121:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+2F5j
    mov     ecx, [esp+2Ch+var_14]
    mov     eax, [esp+2Ch+var_C]
    add     ecx, 1Ch
    dec     eax
    mov     [esp+2Ch+var_14], ecx
    mov     [esp+2Ch+var_C], eax
    jnz     loc_4670A3

    loc_46713B:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+18Ej
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+2CEj
    mov     eax, [esp+2Ch+HotRadarUnits]
    mov     cx, [ebx+0A8h]
    mov     [eax], cx
    mov     edx, TAdynmemStructPtr
    add     eax, 0Ah
    movsx   ecx, word ptr [edx+142E7h]
    add     ecx, edi
    mov     [esp+2Ch+HotRadarUnits], eax
    mov     [eax-8], ecx
    mov     edx, TAdynmemStructPtr
    movsx   ecx, word ptr [edx+142E9h]
    add     ecx, ebp
    mov     [eax-4], ecx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+TAdynmemStruct.NumHotRadarUnits]
    inc     ecx
    mov     [eax+TAdynmemStruct.NumHotRadarUnits], ecx
    mov     esi, TAdynmemStructPtr

    NextUnit:                               ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+96j
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+BDj
    mov     eax, [esi+TAdynmemStruct.Units_EndMarker]
    add     ebx, 118h
    cmp     ebx, eax
    jbe     loc_466E4E

    loc_4671A0:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+88j
    mov     eax, [esi+TAdynmemStruct.NumProjectiles]
    mov     ecx, [esi+TAdynmemStruct.Projectiles]
    test    eax, eax
    mov     [esp+2Ch+Projectiles], ecx
    mov     [esp+2Ch+NumProjectiles], 0
    jle     loc_46742F
    lea     ebx, [ecx+0Ah]
    mov     [esp+2Ch+var_14], ebx
    jmp     short loc_4671CD
    ; ---------------------------------------------------------------------------

    loc_4671C9:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+669j
    mov     ecx, [esp+2Ch+Projectiles]

    loc_4671CD:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+407j
    movsx   ebp, word ptr [ebx-4]
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeX]
    imul    eax, ebp
    cdq
    idiv    dword ptr [esi+1422Bh]
    movsx   edx, word ptr [ebx]
    movsx   edi, word ptr [ebx+4]
    sar     edx, 1
    sub     edi, edx
    mov     [esp+2Ch+var_C], eax
    movsx   eax, [esi+TAdynmemStruct.RadarPicSizeY]
    imul    eax, edi
    cdq
    idiv    dword ptr [esi+1422Fh]
    mov     [esp+2Ch+HotRadarUnits], eax
    mov     eax, [ecx]
    mov     ecx, [eax+111h]
    test    ecx, 60000000h
    jnz     loc_467300
    test    cl, 40h
    jnz     NextProjectile
    mov     cl, [esi+TAdynmemStruct.LOS_Sight]
    and     ecx, 0FFh
    mov     edx, ecx
    shl     edx, 5
    add     edx, ecx
    lea     eax, [esi+ecx]
    lea     edx, [edx+edx*4]
    lea     edx, [eax+edx*2+TAdynmemStruct.Players]
    mov     al, [esi+14281h]
    and     al, 2
    cmp     al, 2
    jnz     short loc_467284
    mov     eax, [edx+80h]
    sar     ebp, 5
    sar     edi, 5
    cmp     ebp, eax
    jnb     short loc_467280
    cmp     edi, [edx+84h]
    jnb     short loc_467280
    mov     ecx, [edx+80h]
    imul    ecx, edi
    add     ecx, [edx+7Ch]
    cmp     byte ptr [ecx+ebp], 0
    jz      short loc_467280
    mov     edx, 1
    jmp     short loc_4672C8
    ; ---------------------------------------------------------------------------

    loc_467280:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+49Dj
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+4A5j ...
    xor     edx, edx
    jmp     short loc_4672C8
    ; ---------------------------------------------------------------------------

    loc_467284:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+48Dj
    mov     eax, [edx+80h]
    sar     ebp, 5
    sar     edi, 5
    cmp     ebp, eax
    jnb     short loc_46729C
    cmp     edi, [edx+84h]
    jb      short loc_4672A0

    loc_46729C:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+4D2j
    xor     edx, edx
    jmp     short loc_4672C8
    ; ---------------------------------------------------------------------------

    loc_4672A0:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+4DAj
    mov     edx, [edx+80h]
    mov     eax, [esi+14273h]
    imul    edx, edi
    add     edx, ebp
    xor     edi, edi
    mov     di, [eax+edx*2]
    mov     eax, 1
    shl     eax, cl
    mov     edx, edi
    and     edx, eax
    neg     edx
    sbb     edx, edx
    neg     edx

    loc_4672C8:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+4BEj
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+4C2j ...
    test    edx, edx
    jnz     short CanSeeProjectile
    mov     al, [esi+TAdynmemStruct.LOS_Sight]
    mov     cl, [ebx+5Ch]
    cmp     cl, al
    jnz     NextProjectile

    CanSeeProjectile:                       ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+50Aj
    mov     edx, [esp+2Ch+var_18]
    mov     eax, [esp+2Ch+HotRadarUnits]
    xor     ecx, ecx
    mov     cl, [edx+0Eh]
    mov     edx, [esp+2Ch+RadarFinal]
    push    ecx
    mov     ecx, [esp+30h+var_C]
    push    eax
    push    ecx
    push    edx
    call    sub_4BEE60
    jmp     loc_467400
    ; ---------------------------------------------------------------------------

    loc_467300:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+454j
    mov     al, [esi+TAdynmemStruct.LOS_Sight]
    mov     ecx, eax
    and     ecx, 0FFh
    mov     edx, ecx
    shl     edx, 5
    add     edx, ecx
    lea     ebx, [esi+ecx]
    lea     edx, [edx+edx*4]
    lea     edx, [ebx+edx*2+TAdynmemStruct.Players]
    mov     bl, [esi+14281h]
    and     bl, 2
    cmp     bl, 2
    jnz     short loc_467365
    mov     ecx, [edx+80h]
    sar     ebp, 5
    sar     edi, 5
    cmp     ebp, ecx
    jnb     short loc_467361
    cmp     edi, [edx+84h]
    jnb     short loc_467361
    mov     ecx, [edx+80h]
    imul    ecx, edi
    add     ecx, [edx+7Ch]
    cmp     byte ptr [ecx+ebp], 0
    jz      short loc_467361
    mov     edx, 1
    jmp     short loc_4673A9
    ; ---------------------------------------------------------------------------

    loc_467361:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+57Ej
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+586j ...
    xor     edx, edx
    jmp     short loc_4673A9
    ; ---------------------------------------------------------------------------

    loc_467365:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+56Ej
    mov     ebx, [edx+80h]
    sar     ebp, 5
    sar     edi, 5
    cmp     ebp, ebx
    jnb     short loc_46737D
    cmp     edi, [edx+84h]
    jb      short loc_467381

    loc_46737D:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+5B3j
    xor     edx, edx
    jmp     short loc_4673A9
    ; ---------------------------------------------------------------------------

    loc_467381:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+5BBj
    mov     edx, [edx+80h]
    xor     ebx, ebx
    imul    edx, edi
    mov     edi, [esi+TAdynmemStruct.field_14273]
    add     edx, ebp
    mov     bx, [edi+edx*2]
    mov     edi, 1
    shl     edi, cl
    mov     edx, ebx
    and     edx, edi
    neg     edx
    sbb     edx, edx
    neg     edx

    loc_4673A9:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+59Fj
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+5A3j ...
    mov     ebx, [esp+2Ch+var_14]
    test    edx, edx
    jnz     short loc_4673BC
    mov     ecx, [ebx+48h]
    cmp     [ecx+0FFh], al
    jnz     short NextProjectile

    loc_4673BC:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+5EFj
    mov     edx, [esp+2Ch+HotRadarUnits]
    mov     eax, [esp+2Ch+var_C]
    xor     ecx, ecx
    push    edx
    mov     cl, [ebx+5Ch]
    push    eax
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, esi
    add     eax, ecx
    mov     ecx, [eax+edx*2+TAdynmemStruct.Players.PlayerInfo]
    mov     eax, [esi+147E7h]
    xor     edx, edx
    mov     dl, [ecx+96h]
    push    edx
    push    eax
    call    sub_4B7F30
    push    eax
    mov     ecx, [esp+38h+RadarFinal]
    push    ecx
    call    sub_4B7F90

    loc_467400:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+53Bj
    mov     esi, TAdynmemStructPtr

    NextProjectile:                         ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+45Dj
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+517j ...
    mov     eax, [esp+2Ch+NumProjectiles]
    mov     edi, [esp+2Ch+Projectiles]
    mov     ecx, [esi+TAdynmemStruct.NumProjectiles]
    inc     eax
    add     edi, 6Bh
    add     ebx, 6Bh
    cmp     eax, ecx
    mov     [esp+2Ch+NumProjectiles], eax
    mov     [esp+2Ch+Projectiles], edi
    mov     [esp+2Ch+var_14], ebx
    jl      loc_4671C9

    loc_46742F:                             ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+3FAj
    or      byte ptr [esi+142F1h], 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    GameUnit_LOS_Minimap_UnitsProjectiles endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl GameUnit_LOS_Radar()
    GameUnit_LOS_Radar proc near            ; CODE XREF: UpdateDatePlayers+5EDp

    Units_end= dword ptr -28h
    Units= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 28h
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr          ; Initial hookpoint (jmp @GameUnit_LOS_Radar_Start)
    push    edi
    cmp     [esi+TAdynmemStruct.LOS_Radar], 2
    jb      loc_46782F
    mov     dl, [esi+TAdynmemStruct.LOS_Sight]
    mov     edi, [esi+TAdynmemStruct.Units]
    mov     eax, edx
    mov     ebx, [esi+TAdynmemStruct.Units_EndMarker]
    and     eax, 0FFh
    add     edi, 118h
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    cmp     edi, ebx
    mov     [esp+38h+Units], edi
    mov     [esp+38h+Units_end], ebx
    lea     ecx, [ecx+ecx*4]
    lea     ebp, [esi+ecx*2+TAdynmemStruct.Players]
    ja      short loc_46750E
    lea     eax, [edi+UnitStruct.UnitSelected]

    loc_46749F:                             ; CODE XREF: GameUnit_LOS_Radar+CCj
    mov     ecx, [eax]
    test    ecx, 10000000h
    jz      short loc_4674FB
    mov     esi, ecx
    mov     cl, [eax-11h]                   ; UnitStruct.OwnerIndex (hookpoint for "jmp @GameUnit_LOS_Radar_CanSeeUnit")
    and     esi, 0FFFFEFFFh
    cmp     cl, dl
    mov     [eax], esi
    jz      short loc_4674F4
    mov     ecx, [eax-7Ah]                  ; UnitStruct.Owner
    xor     ebx, ebx
    mov     bl, [ebp+PlayerStruct.PlayerNumber]
    cmp     [ebx+ecx+PlayerStruct.field_108], 0
    jz      short loc_4674DB
    mov     ecx, [ecx+PlayerStruct.PlayerInfo]
    test    [ecx+PlayerData.field_0.SharedBits], SharedRadar
    jnz     short loc_4674F4

    loc_4674DB:                             ; CODE XREF: GameUnit_LOS_Radar+8Dj
    cmp     [ebp+PlayerStruct.PlayerActive], 0
    jz      short loc_4674ED
    mov     ecx, [ebp+PlayerStruct.PlayerInfo]
    test    [ecx+PlayerInfoStruct.field_9B], SharedRadar
    jnz     short loc_4674F4

    loc_4674ED:                             ; CODE XREF: GameUnit_LOS_Radar+9Fj
    mov     ecx, [eax]
    and     ch, 0F8h                        ; Can not see on radar
    jmp     short loc_4674F9
    ; ---------------------------------------------------------------------------

    loc_4674F4:                             ; CODE XREF: GameUnit_LOS_Radar+78j
                                            ; GameUnit_LOS_Radar+99j ...
    mov     ecx, [eax]
    or      ch, 3                           ; Can see on radar

    loc_4674F9:                             ; CODE XREF: GameUnit_LOS_Radar+B2j
    mov     [eax], ecx

    loc_4674FB:                             ; CODE XREF: GameUnit_LOS_Radar+67j
    mov     esi, [esp+38h+Units_end]
    add     eax, 118h
    lea     ecx, [eax-110h]
    cmp     ecx, esi
    jbe     short loc_46749F

    loc_46750E:                             ; CODE XREF: GameUnit_LOS_Radar+57j
    mov     esi, [ebp+PlayerStruct.Units]
    mov     eax, [ebp+PlayerStruct.Units_End]
    cmp     esi, eax
    ja      loc_4675D2
    mov     ebx, offset off_4FD55C

    loc_467521:                             ; CODE XREF: GameUnit_LOS_Radar+18Cj
    mov     eax, dword ptr [esi+UnitStruct.UnitSelected]
    test    eax, 10000000h
    jz      loc_4675C1
    test    ah, 40h
    jnz     loc_4675C1
    test    [esi+UnitStruct.cIsCloaked], 1
    jz      short loc_4675C1
    mov     edx, [esi+UnitStruct.UnitType]
    cmp     word ptr [edx+204h], 0
    jnz     short loc_46755E
    cmp     word ptr [edx+206h], 0
    jz      short loc_4675C1

    loc_46755E:                             ; CODE XREF: GameUnit_LOS_Radar+112j
    mov     ax, [edx+204h]
    movsx   ecx, word ptr [esi+70h]
    movsx   edi, ax
    lea     ecx, [edi+ecx*2]
    mov     di, [edx+206h]
    movsx   edx, di
    imul    ecx, ecx
    imul    edx, edx
    cmp     ax, di
    jg      short loc_467586
    mov     eax, edi

    loc_467586:                             ; CODE XREF: GameUnit_LOS_Radar+142j
    mov     [esp+38h+var_14], ecx
    lea     ecx, [esi+UnitStruct.XPos]
    mov     [esp+38h+var_10], edx
    mov     edx, ecx
    movsx   eax, ax
    mov     edi, [edx]
    mov     [esp+38h+var_18], ebx
    mov     [esp+38h+var_C], edi
    mov     edi, [edx+4]
    shl     eax, 10h
    mov     edx, [edx+8]
    mov     [esp+38h+var_8], edi
    mov     [esp+38h+var_4], edx
    lea     edx, [esp+38h+var_18]
    push    edx
    push    eax
    push    ecx
    call    sub_47E890
    mov     edi, [esp+38h+Units]

    loc_4675C1:                             ; CODE XREF: GameUnit_LOS_Radar+ECj
                                            ; GameUnit_LOS_Radar+F5j ...
    mov     eax, [ebp+6Bh]
    add     esi, 118h
    cmp     esi, eax
    jbe     loc_467521

    loc_4675D2:                             ; CODE XREF: GameUnit_LOS_Radar+D6j
    cmp     edi, [esp+38h+Units_end]
    ja      loc_46782F
    lea     esi, [edi+92h]
    mov     ebx, offset off_4FD558
    mov     edi, offset off_4FD554

    loc_4675EC:                             ; CODE XREF: GameUnit_LOS_Radar+22Cj
    test    dword ptr [esi+7Eh], 10000000h
    jz      short loc_46765A
    mov     al, [esi+6Dh]
    mov     cl, [ebp+146h]
    cmp     al, cl
    jz      short loc_46765A
    test    byte ptr [esi+7Ch], 1
    jz      short loc_46765A
    mov     eax, [esi]
    cmp     word ptr [eax+20Ah], 0
    jz      short loc_467631
    movsx   eax, word ptr [eax+20Ah]
    lea     ecx, [esp+38h+var_20]
    lea     edx, [esi-28h]
    shl     eax, 10h
    push    ecx
    push    eax
    push    edx
    mov     [esp+44h+var_20], ebx
    call    sub_47E890

    loc_467631:                             ; CODE XREF: GameUnit_LOS_Radar+1D2j
    mov     eax, [esi]
    cmp     word ptr [eax+20Ch], 0
    jz      short loc_46765A
    movsx   eax, word ptr [eax+20Ch]
    lea     ecx, [esp+38h+var_1C]
    lea     edx, [esi-28h]
    shl     eax, 10h
    push    ecx
    push    eax
    push    edx
    mov     [esp+44h+var_1C], edi
    call    sub_47E890

    loc_46765A:                             ; CODE XREF: GameUnit_LOS_Radar+1B3j
                                            ; GameUnit_LOS_Radar+1C0j ...
    mov     ecx, [esp+38h+Units_end]
    add     esi, 118h
    lea     eax, [esi-92h]
    cmp     eax, ecx
    jbe     loc_4675EC
    mov     edi, [esp+38h+Units]
    mov     eax, ecx
    cmp     edi, eax
    ja      loc_46782F
    lea     esi, [edi+92h]
    mov     ebx, 2000h
    mov     edi, 1000h

    loc_467690:                             ; CODE XREF: GameUnit_LOS_Radar+2BDj
    test    dword ptr [esi+7Eh], 10000000h
    jz      short loc_4676EB
    mov     eax, [esi+4]
    cmp     [eax+PlayerStruct.PlayerActive], 0
    jz      short loc_4676EB
    mov     al, [eax+PlayerStruct.PlayerType]
    cmp     al, Player_LocalHuman
    jz      short loc_4676AC
    cmp     al, Player_AI
    jnz     short loc_4676EB

    loc_4676AC:                             ; CODE XREF: GameUnit_LOS_Radar+266j
    mov     eax, [esi]
    test    [eax+245h], ebx
    jz      short loc_4676EB
    movsx   ecx, word ptr [eax+208h]
    xor     eax, eax
    lea     edx, [esi-28h]
    mov     al, [esi+6Dh]
    push    ecx                             ; int
    push    edx                             ; int
    push    eax                             ; int
    call    sub_40B0D0
    test    al, al
    jz      short loc_4676EB
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+TAdynmemStruct.GameTime]
    add     edx, 5Ah
    mov     [esi+1Eh], edx
    mov     eax, [esi+7Eh]
    or      eax, edi
    mov     [esi+7Eh], eax

    loc_4676EB:                             ; CODE XREF: GameUnit_LOS_Radar+257j
                                            ; GameUnit_LOS_Radar+25Fj ...
    mov     ecx, [esp+38h+Units_end]
    add     esi, 118h
    lea     eax, [esi-92h]
    cmp     eax, ecx
    jbe     short loc_467690
    mov     edi, [esp+38h+Units]
    mov     eax, ecx
    cmp     edi, eax
    ja      loc_46782F
    lea     esi, [edi+74h]

    loc_467710:                             ; CODE XREF: GameUnit_LOS_Radar+3E9j
    mov     ebp, [esi+9Ch]
    test    ebp, 10000000h
    jz      loc_46781A
    test    ebp, 100h
    jnz     loc_46781A
    test    byte ptr [esi+9Ah], 4
    jnz     loc_46781A
    mov     edi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [edi+TAdynmemStruct.LOS_Sight]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    lea     eax, [edi+ecx]
    lea     eax, [eax+edx*2+TAdynmemStruct.Players]
    mov     dl, [edi+14281h]
    and     dl, 2
    cmp     dl, 2
    jnz     short loc_4677B1
    movsx   edi, word ptr [esi-4]
    movsx   ecx, word ptr [esi]
    movsx   edx, word ptr [esi-8]
    sar     edi, 1
    sub     ecx, edi
    mov     edi, [eax+80h]
    sar     edx, 5
    sar     ecx, 5
    cmp     edx, edi
    jnb     short loc_4677AD
    cmp     ecx, [eax+84h]
    jnb     short loc_4677AD
    mov     edi, [eax+80h]
    mov     eax, [eax+PlayerStruct.field_7C]
    imul    edi, ecx
    add     edi, edx
    cmp     byte ptr [edi+eax], 0
    jz      short loc_4677AD
    mov     eax, 1
    jmp     short loc_46780A
    ; ---------------------------------------------------------------------------

    loc_4677AD:                             ; CODE XREF: GameUnit_LOS_Radar+348j
                                            ; GameUnit_LOS_Radar+350j ...
    xor     eax, eax
    jmp     short loc_46780A
    ; ---------------------------------------------------------------------------

    loc_4677B1:                             ; CODE XREF: GameUnit_LOS_Radar+329j
    movsx   ebx, word ptr [esi-4]
    movsx   edx, word ptr [esi]
    movsx   edi, word ptr [esi-8]
    sar     ebx, 1
    sub     edx, ebx
    mov     ebx, [eax+80h]
    sar     edi, 5
    sar     edx, 5
    cmp     edi, ebx
    jnb     short loc_4677D8
    cmp     edx, [eax+84h]
    jb      short loc_4677DC

    loc_4677D8:                             ; CODE XREF: GameUnit_LOS_Radar+38Ej
    xor     eax, eax
    jmp     short loc_46780A
    ; ---------------------------------------------------------------------------

    loc_4677DC:                             ; CODE XREF: GameUnit_LOS_Radar+396j
    mov     eax, [eax+80h]
    imul    eax, edx
    mov     edx, TAdynmemStructPtr
    add     eax, edi
    xor     edi, edi
    mov     edx, [edx+TAdynmemStruct.field_14273]
    mov     di, [edx+eax*2]
    mov     edx, 1
    shl     edx, cl
    mov     eax, edi
    and     eax, edx
    neg     eax
    sbb     eax, eax
    neg     eax

    loc_46780A:                             ; CODE XREF: GameUnit_LOS_Radar+36Bj
                                            ; GameUnit_LOS_Radar+36Fj ...
    test    eax, eax
    jz      short loc_46781A
    or      ebp, 100h
    mov     [esi+9Ch], ebp

    loc_46781A:                             ; CODE XREF: GameUnit_LOS_Radar+2DCj
                                            ; GameUnit_LOS_Radar+2E8j ...
    mov     ecx, [esp+38h+Units_end]
    add     esi, 118h
    lea     eax, [esi-74h]
    cmp     eax, ecx
    jbe     loc_467710

    loc_46782F:                             ; CODE XREF: GameUnit_LOS_Radar+15j
                                            ; GameUnit_LOS_Radar+196j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn
    GameUnit_LOS_Radar endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467840 proc near                    ; DATA XREF: .rdata:004FD55Co

    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    push    edi
    cmp     word ptr [esi+0A6h], 0
    mov     [esp+1Ch+var_C], edx
    jz      loc_467946
    mov     ecx, TAdynmemStructPtr
    mov     al, [esi+0FFh]
    cmp     al, [ecx+TAdynmemStruct.LOS_Sight]
    jz      loc_467946
    mov     eax, [esi+92h]
    mov     [esp+1Ch+arg_0], eax
    mov     eax, [eax+241h]
    shr     eax, 8
    test    al, 1
    jnz     loc_467946
    mov     eax, [esi+6Ah]
    mov     edi, [edx+0Ch]
    mov     ebx, [edx+14h]
    mov     ecx, [esi+72h]
    sub     eax, edi
    sub     ecx, ebx
    cdq
    mov     edi, eax
    mov     ebx, edx
    mov     eax, ecx
    push    ebx
    cdq
    push    edi
    push    ebx
    push    edi
    mov     ebp, eax
    mov     [esp+2Ch+var_4], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edi, eax
    mov     eax, [esp+1Ch+var_4]
    push    eax
    push    ebp
    push    eax
    push    ebp
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    add     edi, eax
    mov     eax, [esi+6Eh]
    mov     cl, [edx+1427Fh]
    shl     ecx, 10h
    cmp     eax, ecx
    jg      short loc_46790E
    mov     ecx, [esp+1Ch+var_C]
    cmp     edi, [ecx+8]
    jge     short loc_46790E
    mov     ecx, [esi+110h]
    or      ch, 2
    mov     [esi+110h], ecx

    loc_46790E:                             ; CODE XREF: sub_467840+B4j
                                            ; sub_467840+BDj
    mov     edx, [esp+1Ch+arg_0]
    mov     ecx, [edx+16Eh]
    xor     edx, edx
    add     ecx, eax
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+1427Fh]
    shl     edx, 10h
    cmp     ecx, edx
    jl      short loc_467946
    mov     ecx, [esp+1Ch+var_C]
    cmp     edi, [ecx+4]
    jge     short loc_467946
    mov     eax, [esi+110h]
    or      ah, 1
    mov     [esi+110h], eax

    loc_467946:                             ; CODE XREF: sub_467840+19j
                                            ; sub_467840+31j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    4
    sub_467840 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467950 proc near                    ; CODE XREF: sub_489CE0+AEp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     byte ptr [eax+0FAh], 0F0h
    retn    4
    sub_467950 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467960 proc near                    ; DATA XREF: .rdata:004FD558o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+110h]
    and     ch, 0FEh
    or      ch, 4
    mov     [eax+110h], ecx
    retn    4
    sub_467960 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467980 proc near                    ; DATA XREF: .rdata:004FD554o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+110h]
    and     ch, 0FDh
    or      ch, 4
    mov     [eax+110h], ecx
    retn    4
    sub_467980 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4679A0 proc near                    ; CODE XREF: sub_4917D0+C3p
    mov     eax, TAdynmemStructPtr
    push    esi
    add     eax, 37E3Fh
    xor     esi, esi
    push    offset aLightbar                ; char *
    mov     [eax+1Dh], esi
    mov     [eax+19h], esi
    mov     [eax+0Dh], esi
    mov     [eax+1], esi
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E90h], esi
    mov     [ecx+37E94h], esi
    mov     edx, TAdynmemStructPtr
    lea     eax, [ecx+37E60h]
    mov     eax, [edx+51Dh]
    push    eax                             ; int
    call    sub_4B8D40
    push    1
    push    eax
    call    sub_4B7F30
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E94h], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E94h]
    mov     [eax+6], si
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37E94h]
    mov     [edx+4], si
    pop     esi
    retn
    sub_4679A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467A20 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+393p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_4]
    mov     edx, [esp+arg_C]
    movsx   ecx, word ptr [eax+6]
    add     ecx, edx
    movsx   edx, word ptr [eax+4]
    push    ecx
    mov     ecx, [esp+4+arg_8]
    add     edx, ecx
    push    edx
    push    eax
    mov     eax, [esp+0Ch+arg_0]
    push    eax
    call    sub_4B7F90
    retn    10h
    sub_467A20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467A50 proc near                    ; CODE XREF: sub_46A530+CBp

    var_1= dword ptr -1
    arg_0= dword ptr  7
    arg_4= dword ptr  0Bh
    arg_8= dword ptr  0Fh
    arg_C= dword ptr  13h

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+5+arg_4]
    push    ebp
    mov     ebp, [esp+9+arg_8]
    push    esi
    mov     esi, [eax+14383h]
    push    edi
    mov     edi, [eax+14387h]
    mov     al, [eax+0DD5h]
    mov     byte ptr [esp+11h+var_1], al
    mov     [esp+11h+arg_8], 4

    loc_467A80:                             ; CODE XREF: sub_467A50+86j
    mov     ecx, [esp+11h+arg_C]
    push    ecx
    push    esi
    push    ebp
    call    sub_4B6CC0
    mov     edx, [esi+4]
    mov     ecx, [ebx+4]
    mov     eax, [ebx+8]
    add     edx, ecx
    sar     edx, 10h
    movsx   ecx, dx
    mov     edx, [esi+8]
    add     ebp, 0Ch
    sub     eax, edx
    mov     edx, [esi]
    add     edx, [ebx]
    add     esi, 0Ch
    sar     eax, 10h
    movsx   eax, ax
    sar     edx, 10h
    sar     ecx, 1
    movsx   edx, dx
    sub     eax, ecx
    add     edx, 80h
    add     eax, 20h
    mov     [edi], edx
    mov     [edi+4], eax
    mov     eax, [esp+11h+arg_8]
    add     edi, 8
    dec     eax
    mov     [esp+11h+arg_8], eax
    jnz     short loc_467A80
    mov     eax, TAdynmemStructPtr
    mov     edi, [esp+11h+var_1]
    mov     ebx, [esp+11h+arg_0]
    and     edi, 0FFh
    mov     esi, [eax+14387h]
    push    edi
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+8]
    mov     eax, [esi+4]
    push    ecx
    mov     ecx, [esi]
    push    edx
    push    eax
    push    ecx
    push    ebx
    call    sub_4BE950
    mov     edx, [esi+14h]
    mov     eax, [esi+10h]
    mov     ecx, [esi+0Ch]
    push    edi
    push    edx
    mov     edx, [esi+8]
    push    eax
    push    ecx
    push    edx
    push    ebx
    call    sub_4BE950
    mov     eax, [esi+1Ch]
    mov     ecx, [esi+18h]
    mov     edx, [esi+14h]
    push    edi
    push    eax
    mov     eax, [esi+10h]
    push    ecx
    push    edx
    push    eax
    push    ebx
    call    sub_4BE950
    mov     ecx, [esi+4]
    mov     edx, [esi]
    mov     eax, [esi+1Ch]
    push    edi
    push    ecx
    mov     ecx, [esi+18h]
    push    edx
    push    eax
    push    ecx
    push    ebx
    call    sub_4BE950
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    sub_467A50 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 10h
    push    ebx
    push    esi
    mov     esi, [esp+28h]
    push    edi
    mov     ecx, esi
    mov     ebx, [ecx]
    mov     [esp+0Ch], ebx
    mov     eax, [ecx+4]
    mov     edx, [ecx+8]
    mov     [esp+14h], edx
    mov     edx, [esp+34h]
    mov     ecx, [ecx+0Ch]
    add     eax, edx
    add     ecx, edx
    mov     [esp+10h], eax
    mov     [esp+18h], ecx
    mov     ecx, [esp+24h]
    test    ecx, ecx
    jge     short loc_467B99
    xor     ecx, ecx

    loc_467B99:                             ; CODE XREF: .text:00467B95j
    mov     edi, [esp+28h]
    cmp     ecx, edi
    jle     short loc_467BA3
    mov     ecx, edi

    loc_467BA3:                             ; CODE XREF: .text:00467B9Fj
    mov     eax, [esi+8]
    mov     edx, [esi]
    sub     eax, edx
    imul    eax, ecx
    cdq
    idiv    edi
    mov     edi, [esp+30h]
    lea     ecx, [esp+0Ch]
    add     eax, ebx
    mov     ebx, [esp+20h]
    mov     [esp+14h], eax
    xor     eax, eax
    mov     al, [edi+0Ah]
    push    eax
    push    ecx
    push    ebx
    call    sub_4BF6F0
    mov     esi, [esi+8]
    mov     eax, [esp+14h]
    cmp     eax, esi
    jz      short loc_467BF4
    inc     eax
    xor     edx, edx
    mov     dl, [edi+4]
    mov     [esp+0Ch], eax
    lea     eax, [esp+0Ch]
    push    edx
    push    eax
    push    ebx
    mov     [esp+20h], esi
    call    sub_4BF6F0

    loc_467BF4:                             ; CODE XREF: .text:00467BD8j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10h
    retn    18h
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467C00 proc near                    ; CODE XREF: sub_464060+1AEp
                                            ; GameUnit_LOS_Unknown1+3BBp ...

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 40h
    mov     eax, [esp+40h+arg_4]
    xor     edx, edx
    push    ebx
    mov     ebx, [esp+44h+arg_C]
    mov     ecx, [eax+27h]
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    mov     dl, [ecx+96h]
    mov     ecx, [eax+148DBh]
    mov     eax, [ecx+edx*8+28h]
    xor     ecx, ecx
    xor     edx, edx
    mov     [esp+4Ch+var_40], ecx
    mov     [esp+4Ch+var_3C], ecx
    mov     dx, [eax]
    mov     [esp+4Ch+var_38], edx
    xor     edx, edx
    mov     [esp+4Ch+var_34], ecx
    mov     dx, [eax]
    mov     [esp+4Ch+var_30], edx
    xor     edx, edx
    mov     dx, [eax+2]
    mov     [esp+4Ch+var_28], ecx
    mov     [esp+4Ch+var_2C], edx
    mov     cx, [eax+2]
    mov     [esp+4Ch+var_24], ecx
    mov     ecx, [esp+4Ch+arg_8]
    mov     edx, [ecx]
    mov     esi, [ecx+4]
    mov     edi, [ecx+8]
    mov     ecx, [ecx+0Ch]
    add     ecx, ebx
    mov     [esp+4Ch+var_20], edx
    mov     [esp+4Ch+var_8], edx
    mov     [esp+4Ch+var_C], ecx
    mov     [esp+4Ch+var_4], ecx
    lea     edx, [esp+4Ch+var_40]
    lea     ecx, [esp+4Ch+var_20]
    push    edx
    mov     edx, [esp+50h+arg_0]
    push    ecx
    add     esi, ebx
    push    eax
    push    edx
    mov     [esp+5Ch+var_1C], esi
    mov     [esp+5Ch+var_18], edi
    mov     [esp+5Ch+var_14], esi
    mov     [esp+5Ch+var_10], edi
    call    sub_4C7580
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 40h
    retn    10h
    sub_467C00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467CB0 proc near

    var_64= dword ptr -64h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 64h
    push    esi
    push    edi
    push    offset aKills_0                 ; int
    call    sub_4C5740
    push    offset aKill                    ; int
    mov     esi, eax
    call    sub_4C5740
    mov     edi, [esp+6Ch+arg_4]
    mov     cx, [edi+0B8h]
    cmp     cx, 4
    jbe     short loc_467D0E
    cmp     cx, 1
    jnz     short loc_467CE4
    mov     esi, eax

    loc_467CE4:                             ; CODE XREF: sub_467CB0+30j
    push    offset aVeteran                 ; int
    call    sub_4C5740
    push    eax
    xor     eax, eax
    mov     ax, [edi+0B8h]
    push    esi
    push    eax
    lea     ecx, [esp+78h+var_64]
    push    offset aDSS                     ; "%d %s - %s"
    push    ecx
    call    _sprintf
    add     esp, 14h
    jmp     short loc_467D30
    ; ---------------------------------------------------------------------------

    loc_467D0E:                             ; CODE XREF: sub_467CB0+2Aj
    cmp     cx, 1
    jz      short loc_467D16
    mov     eax, esi

    loc_467D16:                             ; CODE XREF: sub_467CB0+62j
    and     ecx, 0FFFFh
    push    eax
    push    ecx
    lea     edx, [esp+74h+var_64]
    push    offset aDS                      ; "%d %s"
    push    edx
    call    _sprintf
    add     esp, 10h

    loc_467D30:                             ; CODE XREF: sub_467CB0+5Cj
    call    sub_4C13F0
    mov     ecx, TAdynmemStructPtr
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DDAh]
    push    eax
    call    sub_4C13A0
    push    0FFFFFFFFh
    lea     ecx, [esp+70h+var_64]
    mov     edx, [esp+70h+arg_C]
    mov     eax, [esp+70h+arg_8]
    push    edx
    mov     edx, [esp+74h+arg_0]
    push    eax
    push    ecx
    push    edx
    call    PrintGUIText
    pop     edi
    pop     esi
    add     esp, 64h
    retn    10h
    sub_467CB0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467D70 proc near                    ; CODE XREF: sub_497F40+4EAp
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     esi, [eax+37E1Bh]
    push    esi
    call    sub_4C69A0
    push    0
    push    esi
    call    sub_4C6890
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edi, edx
    push    0
    mov     cl, [edx+TAdynmemStruct.LOS_Sight]
    mov     eax, ecx
    add     edi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [edi+eax*2+TAdynmemStruct.Players.PlayerInfo]
    xor     eax, eax
    mov     al, [ecx+95h]
    mov     edx, [edx+eax*4+1481Fh]
    lea     edi, ds:0[eax*4]
    push    edx
    call    sub_4B7F30
    movsx   edx, word ptr [eax+4]
    movsx   ecx, word ptr [eax+6]
    add     edx, 81h
    push    ecx
    push    edx
    push    eax
    push    esi
    call    sub_4B7F90
    call    sub_4B6710
    mov     ebx, eax
    mov     eax, TAdynmemStructPtr
    push    0
    sub     ebx, 20h
    mov     ecx, [eax+edi+14833h]
    push    ecx
    call    sub_4B7F30
    movsx   edx, word ptr [eax+6]
    movsx   ecx, word ptr [eax+4]
    add     edx, ebx
    add     ecx, 81h
    push    edx
    push    ecx
    push    eax
    push    esi
    call    sub_4B7F90
    mov     edx, TAdynmemStructPtr
    push    0
    mov     eax, [edx+edi+14847h]
    push    eax
    call    sub_4B7F30
    movsx   ecx, word ptr [eax+6]
    movsx   edx, word ptr [eax+4]
    push    ecx
    push    edx
    push    eax
    push    esi
    call    sub_4B7F90
    call    sub_4C63A0
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_467D70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_467E50 proc near

    var_BC= qword ptr -0BCh
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    sub     esp, 0A4h
    mov     eax, [ecx+391B3h]
    push    ebx
    push    ebp
    xor     ebp, ebp
    push    esi
    cmp     eax, ebp
    push    edi
    jz      loc_4682FD
    mov     ax, [ecx+391B7h]
    cmp     ax, bp
    jz      loc_4682FD
    and     eax, 0FFFFh
    mov     edx, eax
    shl     eax, 3
    sub     eax, edx
    mov     edx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    lea     ebx, [edx+eax*8]
    mov     [esp+0B4h+var_94], ebx
    mov     eax, [ebx+110h]
    test    eax, 10000000h
    jz      short loc_467EAE
    test    ah, 40h
    jz      short loc_467EC6

    loc_467EAE:                             ; CODE XREF: sub_467E50+57j
    mov     [ecx+391B3h], ebp
    mov     eax, TAdynmemStructPtr
    mov     [eax+391B7h], bp
    mov     ecx, TAdynmemStructPtr

    loc_467EC6:                             ; CODE XREF: sub_467E50+5Cj
    lea     esi, [ecx+0DCBh]
    mov     [esp+0B4h+var_90], esi
    call    sub_4C13F0
    xor     ecx, ecx
    push    eax
    mov     cl, [esi+0Fh]
    push    ecx
    call    sub_4C13A0
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391F9h]
    push    eax
    call    sub_4C1420
    call    sub_4C1450
    mov     edi, eax
    add     edi, 3
    mov     esi, edi
    shl     esi, 3
    sub     esi, edi
    call    sub_4C6B60
    mov     eax, dword_51E540
    mov     [esp+0B4h+var_A4], 83h
    cmp     eax, ebp
    mov     [esp+0B4h+var_9C], 191h
    mov     [esp+0B4h+var_A0], esi
    jnz     short loc_467F32
    lea     ecx, [edi+edi*4]
    shl     ecx, 2
    mov     [esp+0B4h+var_98], ecx
    jmp     short loc_467F36
    ; ---------------------------------------------------------------------------

    loc_467F32:                             ; CODE XREF: sub_467E50+D4j
    mov     [esp+0B4h+var_98], eax

    loc_467F36:                             ; CODE XREF: sub_467E50+E0j
    mov     ebp, [esp+0B4h+arg_0]
    lea     edx, [esp+0B4h+var_A4]
    push    0FFFFFFE8h
    push    edx
    push    ebp
    call    sub_4BF4D0
    mov     eax, [esp+0B4h+var_9C]
    mov     edx, [esp+0B4h+var_98]
    mov     ecx, [esp+0B4h+var_90]
    inc     eax
    mov     [esp+0B4h+var_9C], eax
    inc     edx
    xor     eax, eax
    mov     [esp+0B4h+var_98], edx
    mov     al, [ecx+5]
    lea     edx, [esp+0B4h+var_A4]
    push    eax
    push    edx
    push    ebp
    call    sub_4BF8C0
    add     esi, 3
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    offset aUnitStateProbe          ; "Unit State Probe"
    push    ebp
    call    PrintGUIText
    add     esi, edi
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    offset asc_50767C               ; "================"
    push    ebp
    call    PrintGUIText
    mov     ecx, [ebx+UnitStruct.UnitType]
    xor     eax, eax
    mov     ax, [ebx+0A8h]
    push    ecx
    push    eax
    push    eax
    lea     edx, [esp+0C0h+var_80]
    push    offset aUid03d04xS              ; "uid: %03d/%04x '%s'\n"
    push    edx
    add     esi, edi
    call    _sprintf
    add     esp, 14h
    lea     eax, [esp+0B4h+var_80]
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    eax
    push    ebp
    call    PrintGUIText
    mov     ecx, [ebx+UnitStruct.UnitType]
    add     esi, edi
    mov     edx, offset aMobile             ; "MOBILE"
    mov     al, [ecx+22Fh]
    test    al, al
    jnz     short loc_467FF1
    mov     edx, offset aBuilding_0         ; "BUILDING"

    loc_467FF1:                             ; CODE XREF: sub_467E50+19Aj
    mov     eax, [ebx+UnitStruct.Owner]
    cmp     [eax+PlayerStruct.PlayerActive], 0
    jz      short loc_468010
    mov     cl, [eax+PlayerStruct.PlayerType]
    cmp     cl, Player_LocalHuman
    jz      short loc_468009
    cmp     cl, Player_AI
    jnz     short loc_468010

    loc_468009:                             ; CODE XREF: sub_467E50+1B2j
    mov     ecx, offset aLocal              ; "LOCAL"
    jmp     short loc_468015
    ; ---------------------------------------------------------------------------

    loc_468010:                             ; CODE XREF: sub_467E50+1AAj
                                            ; sub_467E50+1B7j
    mov     ecx, offset aRemote             ; "REMOTE"

    loc_468015:                             ; CODE XREF: sub_467E50+1BEj
    push    edx
    push    ecx
    xor     ecx, ecx
    lea     edx, [eax+PlayerStruct.Name]
    mov     cl, [eax+PlayerStruct.PlayerNumber]
    push    edx
    push    ecx
    lea     edx, [esp+0C4h+var_80]
    push    offset aPlayernoDSSS            ; "playerno: %d '%s' %s - %s\n"
    push    edx
    call    _sprintf
    add     esp, 18h
    lea     eax, [esp+0B4h+var_80]
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    eax
    push    ebp
    call    PrintGUIText
    mov     ecx, [ebx+96h]
    xor     edx, edx
    lea     eax, [esp+0B4h+var_80]
    add     esi, edi
    mov     dl, [ecx+73h]
    push    edx
    push    offset aControllerD             ; "controller: %d\n"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+0B4h+var_80]
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    ecx
    push    ebp
    call    PrintGUIText
    fld     dword ptr [ebx+104h]
    sub     esp, 8
    lea     edx, [esp+0BCh+var_80]
    add     esi, edi
    fstp    [esp+0BCh+var_BC]
    push    offset aBuildtimeleft1          ; "buildtimeleft: %1.3f\n"
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+0B4h+var_80]
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    eax
    push    ebp
    call    PrintGUIText
    movsx   ecx, word ptr [ebx+108h]
    push    ecx
    lea     edx, [esp+0B8h+var_80]
    push    offset aDamageD                 ; "damage: %d\n"
    push    edx
    add     esi, edi
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+0B4h+var_80]
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    eax
    push    ebp
    call    PrintGUIText
    mov     ecx, dword ptr [ebx+UnitStruct.UnitSelected]
    lea     eax, [esp+0B4h+var_80]
    and     ecx, 3
    mov     [esp+0B4h+var_8C], offset aNone_1 ; "NONE"
    mov     [esp+0B4h+var_88], offset aGround ; "GROUND"
    mov     [esp+0B4h+var_84], offset off_5075DC
    mov     edx, [esp+ecx*4+0B4h+var_8C]
    add     esi, edi
    push    edx
    push    offset aOccupyS                 ; "occupy: %s\n"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    push    0FFFFFFFFh
    push    esi
    lea     ecx, [esp+0BCh+var_80]
    push    86h
    push    ecx
    push    ebp
    call    PrintGUIText
    mov     eax, [ebx+96h]
    add     esi, edi
    cmp     dword ptr [eax], 0
    jz      loc_4682E5
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_46814B
    cmp     al, 2
    jnz     loc_4682E5

    loc_46814B:                             ; CODE XREF: sub_467E50+2F1j
    mov     dl, [ebx+57h]
    mov     cl, [ebx+3Bh]
    and     dl, 10h
    neg     dl
    sbb     dl, dl
    and     cl, 10h
    and     dl, 2Bh
    add     dl, 2Dh
    movsx   eax, dl
    neg     cl
    push    eax
    mov     al, [ebx+1Fh]
    sbb     cl, cl
    and     al, 10h
    and     cl, 2Bh
    add     cl, 2Dh
    neg     al
    sbb     al, al
    and     al, 2Bh
    add     al, 2Dh
    movsx   edx, cl
    movsx   ecx, al
    push    edx
    push    ecx
    lea     edx, [esp+0C0h+var_80]
    push    offset aAutotargetWPri          ; "autotarget w[pri:sec:spe]: w[%c:%c:%c]\n"...
    push    edx
    call    _sprintf
    add     esp, 14h
    lea     eax, [esp+0B4h+var_80]
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    eax
    push    ebp
    call    PrintGUIText
    mov     eax, [ebx+5Ch]
    add     esi, edi
    test    eax, eax
    jz      loc_46824A
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    offset aMissionQ                ; "Mission Q:"
    push    ebp
    call    PrintGUIText
    mov     ebx, [ebx+5Ch]
    add     esi, edi
    test    ebx, ebx
    jz      short loc_468246

    loc_4681D2:                             ; CODE XREF: sub_467E50+3F4j
    mov     eax, [ebx+16h]
    test    eax, eax
    jz      short loc_468206
    mov     ecx, [eax+92h]
    xor     edx, edx
    mov     dl, [ebx+5]
    push    ecx
    push    edx
    lea     ecx, [ebx+4]
    call    sub_438830
    mov     eax, [eax+15h]
    lea     ecx, [esp+0BCh+var_80]
    push    eax
    push    offset aSStateDTgtS             ; "    '%s' state: %d  tgt: '%s'\n"
    push    ecx
    call    _sprintf
    add     esp, 14h
    jmp     short loc_46822A
    ; ---------------------------------------------------------------------------

    loc_468206:                             ; CODE XREF: sub_467E50+387j
    xor     edx, edx
    lea     ecx, [ebx+4]
    mov     dl, [ebx+5]
    push    edx
    call    sub_438830
    mov     eax, [eax+15h]
    lea     ecx, [esp+0B8h+var_80]
    push    eax
    push    offset aSStateD                 ; "    '%s' state: %d\n"
    push    ecx
    call    _sprintf
    add     esp, 10h

    loc_46822A:                             ; CODE XREF: sub_467E50+3B4j
    push    0FFFFFFFFh
    push    esi
    lea     edx, [esp+0BCh+var_80]
    push    86h
    push    edx
    push    ebp
    call    PrintGUIText
    mov     ebx, [ebx+4Ah]
    add     esi, edi
    test    ebx, ebx
    jnz     short loc_4681D2

    loc_468246:                             ; CODE XREF: sub_467E50+380j
    mov     ebx, [esp+0B4h+var_94]

    loc_46824A:                             ; CODE XREF: sub_467E50+360j
    mov     eax, [ebx+60h]
    test    eax, eax
    jz      loc_4682E5
    push    0FFFFFFFFh
    push    esi
    push    86h
    push    offset aBackgroundMiss          ; "Background Mission Q:"
    push    ebp
    call    PrintGUIText
    mov     ebx, [ebx+60h]
    add     esi, edi
    test    ebx, ebx
    jz      short loc_4682E5

    loc_468271:                             ; CODE XREF: sub_467E50+493j
    mov     eax, [ebx+16h]
    test    eax, eax
    jz      short loc_4682A5
    mov     eax, [eax+92h]
    xor     ecx, ecx
    mov     cl, [ebx+5]
    push    eax
    push    ecx
    lea     ecx, [ebx+4]
    call    sub_438830
    mov     edx, [eax+15h]
    lea     eax, [esp+0BCh+var_80]
    push    edx
    push    offset aSStateDTgtS             ; "    '%s' state: %d  tgt: '%s'\n"
    push    eax
    call    _sprintf
    add     esp, 14h
    jmp     short loc_4682C9
    ; ---------------------------------------------------------------------------

    loc_4682A5:                             ; CODE XREF: sub_467E50+426j
    xor     ecx, ecx
    mov     cl, [ebx+5]
    push    ecx
    lea     ecx, [ebx+4]
    call    sub_438830
    mov     edx, [eax+15h]
    lea     eax, [esp+0B8h+var_80]
    push    edx
    push    offset aSStateD                 ; "    '%s' state: %d\n"
    push    eax
    call    _sprintf
    add     esp, 10h

    loc_4682C9:                             ; CODE XREF: sub_467E50+453j
    push    0FFFFFFFFh
    push    esi
    lea     ecx, [esp+0BCh+var_80]
    push    86h
    push    ecx
    push    ebp
    call    PrintGUIText
    mov     ebx, [ebx+4Ah]
    add     esi, edi
    test    ebx, ebx
    jnz     short loc_468271

    loc_4682E5:                             ; CODE XREF: sub_467E50+2E6j
                                            ; sub_467E50+2F5j ...
    mov     dword_51E540, esi
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0A4h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4682FD:                             ; CODE XREF: sub_467E50+1Aj
                                            ; sub_467E50+2Aj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 0A4h
    retn    4
    sub_467E50 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    ebx
    xor     ecx, ecx
    push    ebp
    mov     cl, [eax+0DDAh]
    mov     ebp, [esp+0Ch]
    lea     ebx, [eax+0DDAh]
    push    esi
    mov     esi, [esp+14h]
    push    edi
    push    ecx
    push    esi
    push    ebp
    call    sub_4BF8C0
    mov     eax, [esp+1Ch]
    cmp     eax, 64h
    jl      short loc_468345
    mov     eax, 64h

    loc_468345:                             ; CODE XREF: .text:0046833Ej
    test    eax, eax
    jle     short loc_468375
    mov     edi, [esi]
    mov     ecx, [esi+8]
    sub     ecx, edi
    imul    ecx, eax
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    xor     ecx, ecx
    shr     eax, 1Fh
    add     edx, eax
    add     edx, edi
    mov     [esi+8], edx
    mov     cl, [ebx]
    push    ecx
    push    esi
    push    ebp
    call    sub_4BF6F0

    loc_468375:                             ; CODE XREF: .text:00468347j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_468380 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+12C8p

    var_58= qword ptr -58h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= qword ptr -38h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    arg_0= dword ptr  4

    sub     esp, 40h
    mov     eax, TAdynmemStructPtr
    mov     [esp+40h+var_30], 81h
    mov     [esp+40h+var_28], 0C1h
    push    ebx
    mov     eax, [eax+37E23h]
    push    ebp
    sub     eax, 5Fh
    push    esi
    mov     [esp+4Ch+var_2C], eax
    add     eax, 8
    push    edi
    mov     [esp+50h+var_24], eax
    call    sub_4C1450
    lea     ecx, [esp+50h+var_3C]
    lea     edx, [esp+50h+var_40]
    push    ecx
    push    edx
    mov     ebx, eax
    call    sub_416150
    sub     esp, 8
    lea     ecx, [esp+58h+var_20]
    mov     eax, [esp+58h+var_40]
    mov     dword ptr [esp+58h+var_38+4], 0
    mov     dword ptr [esp+58h+var_38], eax
    fild    [esp+58h+var_38]
    fmul    ds:dbl_4FD560
    fstp    [esp+58h+var_58]
    push    offset aSend1_1fKS              ; "Send - %1.1f K/s"
    push    ecx
    call    _sprintf
    mov     edx, [esp+60h+var_2C]
    mov     eax, [esp+60h+var_30]
    mov     edi, [esp+60h+arg_0]
    add     esp, 10h
    lea     ecx, [esp+50h+var_20]
    push    0FFFFFFFFh
    push    edx
    push    eax
    push    ecx
    push    edi
    call    PrintGUIText
    xor     ecx, ecx
    mov     eax, [esp+50h+var_2C]
    add     eax, ebx
    mov     [esp+50h+var_2C], eax
    add     eax, 8
    mov     [esp+50h+var_24], eax
    mov     eax, [esp+50h+var_40]
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax*4]
    mov     eax, 5D9F7391h
    shl     edx, 2
    mul     edx
    mov     eax, TAdynmemStructPtr
    mov     esi, edx
    lea     edx, [esp+50h+var_30]
    mov     cl, [eax+0DDAh]
    lea     ebp, [eax+0DDAh]
    push    ecx
    push    edx
    push    edi
    shr     esi, 0Bh
    call    sub_4BF8C0
    cmp     esi, 64h
    jl      short loc_468466
    mov     esi, 64h

    loc_468466:                             ; CODE XREF: sub_468380+DFj
    test    esi, esi
    jle     short loc_4684A3
    mov     ecx, [esp+50h+var_28]
    mov     edx, [esp+50h+var_30]
    sub     ecx, edx
    mov     eax, 51EB851Fh
    imul    ecx, esi
    imul    ecx
    mov     esi, [esp+50h+var_30]
    xor     ecx, ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    add     edx, esi
    mov     [esp+50h+var_28], edx
    mov     cl, [ebp+0]
    lea     edx, [esp+50h+var_30]
    push    ecx
    push    edx
    push    edi
    call    sub_4BF6F0

    loc_4684A3:                             ; CODE XREF: sub_468380+E8j
    mov     ecx, [esp+50h+var_3C]
    mov     dword ptr [esp+50h+var_38+4], 0
    mov     dword ptr [esp+50h+var_38], ecx
    mov     eax, [esp+50h+var_24]
    fild    [esp+50h+var_38]
    sub     esp, 8
    lea     edx, [esp+58h+var_20]
    inc     eax
    mov     [esp+58h+var_30], 81h
    fmul    ds:dbl_4FD560
    mov     [esp+58h+var_28], 0C1h
    mov     [esp+58h+var_2C], eax
    fstp    [esp+58h+var_58]
    push    offset aReceive1_1fKS           ; "Receive - %1.1f K/s"
    push    edx
    call    _sprintf
    mov     eax, [esp+60h+var_2C]
    mov     ecx, [esp+60h+var_30]
    add     esp, 10h
    lea     edx, [esp+50h+var_20]
    push    0FFFFFFFFh
    push    eax
    push    ecx
    push    edx
    push    edi
    call    PrintGUIText
    mov     eax, [esp+50h+var_2C]
    add     eax, ebx
    mov     [esp+50h+var_2C], eax
    add     eax, 8
    mov     [esp+50h+var_24], eax
    mov     eax, [esp+50h+var_3C]
    lea     eax, [eax+eax*4]
    lea     ecx, [eax+eax*4]
    mov     eax, 5D9F7391h
    shl     ecx, 2
    mul     ecx
    mov     esi, edx
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    lea     ecx, [esp+50h+var_30]
    mov     al, [edx+0DDAh]
    lea     ebx, [edx+0DDAh]
    push    eax
    push    ecx
    push    edi
    shr     esi, 0Bh
    call    sub_4BF8C0
    cmp     esi, 64h
    jl      short loc_468559
    mov     esi, 64h

    loc_468559:                             ; CODE XREF: sub_468380+1D2j
    test    esi, esi
    jle     short loc_468591
    mov     ecx, [esp+50h+var_28]
    mov     ebp, [esp+50h+var_30]
    sub     ecx, ebp
    mov     eax, 51EB851Fh
    imul    ecx, esi
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    xor     ecx, ecx
    shr     eax, 1Fh
    add     edx, eax
    add     edx, ebp
    mov     [esp+50h+var_28], edx
    mov     cl, [ebx]
    lea     edx, [esp+50h+var_30]
    push    ecx
    push    edx
    push    edi
    call    sub_4BF6F0

    loc_468591:                             ; CODE XREF: sub_468380+1DBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    4
    sub_468380 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     edx, TAdynmemStructPtr
    sub     esp, 0B4h
    mov     eax, [edx+391B9h]
    push    ebx
    xor     ebx, ebx
    push    ebp
    push    esi
    cmp     eax, ebx
    push    edi
    jz      loc_4689A6
    mov     ax, [edx+391BDh]
    cmp     ax, bx
    jz      loc_4689A6
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     ebp, [ecx+eax*8]
    mov     [esp+14h], ebp
    mov     eax, [ebp+110h]
    test    eax, 10000000h
    jz      short loc_46860C
    test    ah, 40h
    jnz     short loc_46860C
    mov     eax, [ebp+92h]
    cmp     [eax+156h], ebx
    jnz     short loc_468625

    loc_46860C:                             ; CODE XREF: .text:004685F7j
                                            ; .text:004685FCj
    mov     [edx+391B3h], ebx
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+391B7h], bx
    mov     edx, TAdynmemStructPtr

    loc_468625:                             ; CODE XREF: .text:0046860Aj
    lea     esi, [edx+0DCBh]
    mov     [esp+10h], esi
    call    sub_4C13F0
    xor     edx, edx
    push    eax
    mov     dl, [esi+0Fh]
    push    edx
    call    sub_4C13A0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391F9h]
    push    ecx
    call    sub_4C1420
    call    sub_4C1450
    mov     esi, eax
    add     esi, 3
    mov     [esp+18h], esi
    lea     edi, [esi+esi*2]
    call    sub_4C6B60
    mov     eax, dword_51E540
    mov     dword ptr [esp+1Ch], 83h
    cmp     eax, ebx
    mov     dword ptr [esp+24h], 191h
    mov     [esp+20h], edi
    jnz     short loc_468690
    lea     edx, [esi+esi*4]
    shl     edx, 2
    mov     [esp+28h], edx
    jmp     short loc_468694
    ; ---------------------------------------------------------------------------

    loc_468690:                             ; CODE XREF: .text:00468682j
    mov     [esp+28h], eax

    loc_468694:                             ; CODE XREF: .text:0046868Ej
    mov     ebx, [esp+0C8h]
    lea     eax, [esp+1Ch]
    push    0FFFFFFE8h
    push    eax
    push    ebx
    call    sub_4BF4D0
    lea     eax, [esp+1Ch]
    mov     edx, [esp+24h]
    mov     ecx, [esp+28h]
    inc     edx
    inc     ecx
    mov     [esp+24h], edx
    mov     edx, [esp+10h]
    mov     [esp+28h], ecx
    xor     ecx, ecx
    mov     cl, [edx+5]
    push    ecx
    push    eax
    push    ebx
    call    sub_4BF8C0
    add     edi, 3
    push    0FFFFFFFFh
    push    edi
    push    86h
    push    offset aUnitBuilderPro          ; "Unit Builder Probe"
    push    ebx
    call    PrintGUIText
    add     edi, esi
    push    0FFFFFFFFh
    push    edi
    push    86h
    push    offset asc_507734               ; "=================="
    push    ebx
    call    PrintGUIText
    mov     ecx, [ebp+92h]
    xor     edx, edx
    mov     dx, [ebp+0A8h]
    push    ecx
    push    edx
    lea     eax, [esp+4Ch]
    push    offset aUid03dS                 ; "uid: %03d '%s'\n"
    push    eax
    add     edi, esi
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+44h]
    push    0FFFFFFFFh
    push    edi
    push    86h
    push    ecx
    push    ebx
    call    PrintGUIText
    mov     edx, [ebp+92h]
    add     edi, esi
    mov     al, [edx+22Fh]
    mov     edx, offset aMobile             ; "MOBILE"
    test    al, al
    jnz     short loc_46874E
    mov     edx, offset aBuilding_0         ; "BUILDING"

    loc_46874E:                             ; CODE XREF: .text:00468747j
    mov     eax, [ebp+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_46876D
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_468766
    cmp     cl, 2
    jnz     short loc_46876D

    loc_468766:                             ; CODE XREF: .text:0046875Fj
    mov     ecx, offset aLocal              ; "LOCAL"
    jmp     short loc_468772
    ; ---------------------------------------------------------------------------

    loc_46876D:                             ; CODE XREF: .text:00468757j
                                            ; .text:00468764j
    mov     ecx, offset aRemote             ; "REMOTE"

    loc_468772:                             ; CODE XREF: .text:0046876Bj
    push    edx
    push    ecx
    xor     edx, edx
    lea     ecx, [eax+2Bh]
    mov     dl, [eax+146h]
    push    ecx
    push    edx
    lea     eax, [esp+54h]
    push    offset aPlayernoDSSS            ; "playerno: %d '%s' %s - %s\n"
    push    eax
    call    _sprintf
    add     esp, 18h
    lea     ecx, [esp+44h]
    push    0FFFFFFFFh
    push    edi
    push    86h
    push    ecx
    push    ebx
    call    PrintGUIText
    mov     edx, [ebp+96h]
    xor     eax, eax
    lea     ecx, [esp+44h]
    add     edi, esi
    mov     al, [edx+73h]
    push    eax
    push    offset aControllerD_0           ; "controller: %d\n\n"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+44h]
    push    0FFFFFFFFh
    push    edi
    push    86h
    push    edx
    push    ebx
    call    PrintGUIText
    mov     eax, [ebp+96h]
    add     edi, esi
    cmp     dword ptr [eax], 0
    jz      loc_46898E
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_4687F9
    cmp     al, 2
    jnz     loc_46898E

    loc_4687F9:                             ; CODE XREF: .text:004687EFj
    mov     al, [ebp+57h]
    mov     dl, [ebp+3Bh]
    and     al, 10h
    neg     al
    sbb     al, al
    and     dl, 10h
    and     al, 2Bh
    add     al, 2Dh
    movsx   ecx, al
    neg     dl
    push    ecx
    mov     cl, [ebp+1Fh]
    sbb     dl, dl
    and     cl, 10h
    and     dl, 2Bh
    add     dl, 2Dh
    neg     cl
    sbb     cl, cl
    and     cl, 2Bh
    add     cl, 2Dh
    movsx   eax, dl
    movsx   edx, cl
    push    eax
    push    edx
    lea     eax, [esp+50h]
    push    offset aUnitsICanBuild          ; "Units I can build, and the probabilitie"...
    push    eax
    call    _sprintf
    add     esp, 14h
    lea     ecx, [esp+44h]
    push    0FFFFFFFFh
    push    edi
    push    86h
    push    ecx
    push    ebx
    call    PrintGUIText
    mov     eax, [ebp+92h]
    add     edi, esi
    mov     dword ptr [esp+10h], 0
    mov     ecx, [eax+152h]
    test    ecx, ecx
    jle     loc_46898E
    jmp     short loc_46887B
    ; ---------------------------------------------------------------------------

    loc_468877:                             ; CODE XREF: .text:00468988j
    mov     ebp, [esp+14h]

    loc_46887B:                             ; CODE XREF: .text:00468875j
    mov     edx, [eax+156h]
    mov     eax, [esp+10h]
    xor     ecx, ecx
    mov     si, [edx+eax*2]
    mov     cl, [ebp+0FFh]
    push    esi
    push    ecx
    call    sub_40BB00
    and     esi, 0FFFFh
    mov     ebp, eax
    mov     eax, esi
    mov     edx, [esp+18h]
    shl     eax, 6
    add     eax, esi
    mov     [esp+3Ch], ebp
    lea     esi, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1439Bh]
    add     eax, 0DDAh
    add     esi, ecx
    lea     ecx, [edi+1]
    mov     [esp+30h], ecx
    mov     dword ptr [esp+2Ch], 88h
    lea     ecx, [ecx+edx-6]
    xor     edx, edx
    mov     dword ptr [esp+34h], 0A2h
    mov     [esp+38h], ecx
    mov     dl, [eax]
    mov     [esp+40h], eax
    lea     eax, [esp+2Ch]
    push    edx
    push    eax
    push    ebx
    call    sub_4BF8C0
    cmp     ebp, 64h
    mov     eax, 64h
    jge     short loc_468903
    mov     eax, ebp

    loc_468903:                             ; CODE XREF: .text:004688FFj
    test    eax, eax
    jle     short loc_46893F
    mov     edx, [esp+34h]
    mov     ecx, [esp+2Ch]
    sub     edx, ecx
    imul    edx, eax
    mov     eax, 51EB851Fh
    imul    edx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    lea     eax, [esp+2Ch]
    add     edx, ecx
    xor     ecx, ecx
    mov     [esp+34h], edx
    mov     edx, [esp+40h]
    mov     cl, [edx]
    push    ecx
    push    eax
    push    ebx
    call    sub_4BF6F0

    loc_46893F:                             ; CODE XREF: .text:00468905j
    add     esi, 20h
    lea     ecx, [esp+44h]
    push    esi
    push    ebp
    push    offset a3dS                     ; "       %3d %% - '%s'\n"
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+44h]
    push    0FFFFFFFFh
    push    edi
    push    86h
    push    edx
    push    ebx
    call    PrintGUIText
    mov     eax, [esp+14h]
    mov     ebp, [esp+18h]
    mov     ecx, [esp+10h]
    add     edi, ebp
    mov     eax, [eax+92h]
    inc     ecx
    mov     [esp+10h], ecx
    cmp     ecx, [eax+152h]
    jl      loc_468877

    loc_46898E:                             ; CODE XREF: .text:004687E4j
                                            ; .text:004687F3j ...
    mov     dword_51E540, edi
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0B4h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4689A6:                             ; CODE XREF: .text:004685BAj
                                            ; .text:004685CAj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 0B4h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    PlayerStatusMenu proc near              ; CODE XREF: GameUnit_LOS_Unknown1+12AFp

    var_148= dword ptr -148h
    var_144= dword ptr -144h
    var_138= dword ptr -138h
    var_134= dword ptr -134h
    var_100= dword ptr -100h
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    sub     esp, 148h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [eax+37E90h]
    push    edi
    call    GetTickCount
    cmp     dword_51E544, eax
    jge     loc_468AB8
    call    GetTickCount
    add     eax, 0Fh
    push    20h
    mov     dword_51E544, eax
    call    sub_4C1B80
    mov     ecx, TAdynmemStructPtr
    test    eax, eax
    jz      short loc_468A6B
    mov     eax, [ecx+57Dh]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_468A33
    mov     edx, [ecx+531h]
    lea     ecx, ds:0[eax*8]
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [eax+ecx*2]
    mov     ecx, [edx+4]
    cmp     byte ptr [ecx+eax], 3
    jz      short loc_468A6B

    loc_468A33:                             ; CODE XREF: PlayerStatusMenu+4Dj
    cmp     esi, 0FFFFFFE1h
    jle     short loc_468AAC
    test    esi, esi
    jnz     short loc_468A47
    push    esi                             ; int
    push    offset aPanel                   ; char *
    call    sub_47F1A0

    loc_468A47:                             ; CODE XREF: PlayerStatusMenu+7Aj
    lea     ecx, [esi+1Fh]
    mov     eax, 55555556h
    imul    ecx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 1
    jg      short loc_468A62
    mov     edx, 1

    loc_468A62:                             ; CODE XREF: PlayerStatusMenu+9Bj
    sub     esi, edx
    cmp     esi, 0FFFFFFE1h
    jnz     short loc_468AAC
    jmp     short loc_468AA0
    ; ---------------------------------------------------------------------------

    loc_468A6B:                             ; CODE XREF: PlayerStatusMenu+42j
                                            ; PlayerStatusMenu+71j
    test    esi, esi
    jge     short loc_468ABA
    cmp     esi, 0FFFFFFE1h
    jnz     short loc_468A80
    push    0                               ; int
    push    offset aPanel                   ; char *
    call    sub_47F1A0

    loc_468A80:                             ; CODE XREF: PlayerStatusMenu+B2j
    mov     eax, 55555555h
    imul    esi
    sub     edx, esi
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 1
    jg      short loc_468A9C
    mov     edx, 1

    loc_468A9C:                             ; CODE XREF: PlayerStatusMenu+D5j
    add     esi, edx
    jnz     short loc_468AAC

    loc_468AA0:                             ; CODE XREF: PlayerStatusMenu+A9j
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0

    loc_468AAC:                             ; CODE XREF: PlayerStatusMenu+76j
                                            ; PlayerStatusMenu+A7j ...
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E90h], esi

    loc_468AB8:                             ; CODE XREF: PlayerStatusMenu+20j
    test    esi, esi

    loc_468ABA:                             ; CODE XREF: PlayerStatusMenu+ADj
    jz      loc_468CD6
    mov     eax, TAdynmemStructPtr
    mov     ebx, [esp+158h+arg_0]
    mov     ecx, ebx
    mov     edx, [eax+525h]
    mov     [eax+52Dh], edx
    lea     eax, [esp+158h+var_144]
    push    eax
    call    sub_4C6AE0
    mov     edx, TAdynmemStructPtr
    mov     ebp, [esp+158h+var_144]
    mov     ecx, [esp+158h+var_138]
    mov     eax, [edx+37E94h]
    lea     edi, [ecx+esi]
    push    edi
    push    ebp
    push    eax
    push    ebx
    call    sub_4B7F90
    mov     ecx, TAdynmemStructPtr
    mov     eax, 36B06E71h
    mov     esi, [ecx+38A47h]
    mul     esi
    mov     ecx, esi
    sub     ecx, edx
    shr     ecx, 1
    add     ecx, edx
    shr     ecx, 10h
    lea     eax, [ecx+ecx*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax*8]
    mov     eax, 91A2B3C5h
    shl     edx, 5
    sub     esi, edx
    imul    esi
    add     edx, esi
    sar     edx, 0Ah
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 88888889h
    mov     [esp+158h+var_148], edx
    imul    edx, 708h
    sub     esi, edx
    imul    esi
    add     edx, esi
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    push    edx
    mov     edx, [esp+15Ch+var_148]
    push    edx
    push    ecx
    push    offset aGameTime                ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esp+168h+var_100]
    push    offset aS02d02d02d              ; "%s : %02d:%02d:%02d"
    push    eax
    call    _sprintf
    add     esp, 18h
    lea     esi, [edi+0Ah]
    lea     ecx, [ebp+19h]
    lea     edx, [esp+158h+var_100]
    push    0
    push    0FFFFFFFFh
    push    esi
    push    ecx
    push    edx
    push    ebx
    call    sub_4A50E0
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    xor     edx, edx
    mov     ax, [ecx+37EE6h]
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    push    eax
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    add     ecx, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    mov     dx, [ecx+eax*2+TAdynmemStruct.Players.NumUnits]
    push    edx
    push    offset aTotalUnits              ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esp+164h+var_100]
    push    offset aSDMaxD                  ; "%s : %d  (Max %d)"
    push    eax
    call    _sprintf
    add     esp, 14h
    lea     ecx, [ebp+0BEh]
    lea     edx, [esp+158h+var_100]
    push    0
    push    0FFFFFFFFh
    push    esi
    push    ecx
    push    edx
    push    ebx
    call    sub_4A50E0
    mov     eax, TAdynmemStructPtr
    mov     ax, [eax+38A4Dh]
    cmp     ax, 0Ah
    jnz     short loc_468C32
    push    offset aNormal                  ; int
    call    sub_4C5740
    lea     ecx, [esp+158h+var_134]
    push    eax
    push    ecx
    call    _sprintf
    add     esp, 8
    jmp     short loc_468C4D
    ; ---------------------------------------------------------------------------

    loc_468C32:                             ; CODE XREF: PlayerStatusMenu+256j
    and     eax, 0FFFFh
    lea     edx, [esp+158h+var_134]
    sub     eax, 0Ah
    push    eax
    push    offset aD_5                     ; "%+d"
    push    edx
    call    _sprintf
    add     esp, 0Ch

    loc_468C4D:                             ; CODE XREF: PlayerStatusMenu+270j
    lea     eax, [esp+158h+var_134]
    push    eax
    push    offset aGameSpeed               ; int
    call    sub_4C5740
    push    eax
    lea     ecx, [esp+160h+var_100]
    push    offset aSS_0                    ; "%s %s"
    push    ecx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 10h
    mov     ax, [ecx+38A4Bh]
    cmp     [ecx+38A4Dh], ax
    jz      short loc_468CAE
    and     eax, 0FFFFh
    lea     edi, [esp+158h+var_100]
    sub     eax, 0Ah
    or      ecx, 0FFFFFFFFh
    push    eax
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    offset aD_6                     ; " (%+d)"
    lea     edx, [esp+ecx+160h+var_100]
    push    edx
    call    _sprintf
    add     esp, 0Ch

    loc_468CAE:                             ; CODE XREF: PlayerStatusMenu+2C3j
    push    0
    push    0FFFFFFFFh
    add     ebp, 17Ch
    push    esi
    lea     eax, [esp+164h+var_100]
    push    ebp
    push    eax
    push    ebx
    call    sub_4A50E0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+521h]
    mov     [eax+52Dh], ecx

    loc_468CD6:                             ; CODE XREF: PlayerStatusMenu+FAj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 148h
    retn    4
    PlayerStatusMenu endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall GameUnit_LOS_Unknown1(int,int)
    GameUnit_LOS_Unknown1 proc near         ; CODE XREF: sub_495A30+246p
                                            ; sub_495A30+436p ...

    var_22C= qword ptr -22Ch
    Player= dword ptr -214h
    var_210= dword ptr -210h
    NumHotUnits= dword ptr -20Ch
    a2= dword ptr -208h
    var_204= dword ptr -204h
    var_200= dword ptr -200h
    var_1FC= dword ptr -1FCh
    var_1F8= dword ptr -1F8h
    var_1F4= dword ptr -1F4h
    var_1F0= dword ptr -1F0h
    var_1C0= dword ptr -1C0h
    var_1BC= dword ptr -1BCh
    a3= dword ptr -1B8h
    PlayerIndex= dword ptr -1B4h
    var_1B0= dword ptr -1B0h
    PlayerNumber= dword ptr -1ACh
    var_1A7= dword ptr -1A7h
    var_1A3= dword ptr -1A3h
    var_19F= dword ptr -19Fh
    var_19B= dword ptr -19Bh
    var_197= dword ptr -197h
    var_193= dword ptr -193h
    var_18F= dword ptr -18Fh
    var_188= dword ptr -188h
    var_184= dword ptr -184h
    var_180= dword ptr -180h
    var_17C= dword ptr -17Ch
    var_178= dword ptr -178h
    var_174= dword ptr -174h
    var_170= dword ptr -170h
    var_150= dword ptr -150h
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 214h
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     eax, [ecx+37E1Fh]
    push    edi
    add     eax, 80h
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+224h+var_178], eax
    mov     eax, [ecx+37E23h]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+224h+var_174], eax
    mov     eax, [ecx+37E1Bh]
    push    eax
    call    sub_4C69A0
    mov     eax, TAdynmemStructPtr
    mov     ecx, 0Ch
    lea     edi, [esp+224h+var_1F0]
    mov     esi, [eax+37E1Bh]
    lea     ebx, [eax+0DCBh]
    rep movsd
    mov     [esp+224h+var_1B0], ebx
    call    sub_4C2470
    mov     ecx, TAdynmemStructPtr
    sub     esp, 10h
    add     ecx, 37E27h
    mov     edx, esp
    mov     eax, [ecx]
    mov     [edx], eax
    mov     eax, [ecx+4]
    mov     [edx+4], eax
    mov     eax, [ecx+8]
    mov     [edx+8], eax
    mov     ecx, [ecx+0Ch]
    mov     [edx+0Ch], ecx
    lea     ecx, [esp+234h+var_1F0]
    call    sub_4C6B10
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ebp, [esi+4Ch]
    mov     ecx, eax
    sub     ecx, edx
    lea     edx, [esp+224h+var_1F0]
    add     ebp, ecx
    push    edx
    mov     [esi+4Ch], ebp
    mov     [esi], eax
    call    sub_483FA0
    lea     eax, [esp+224h+var_1F0]
    push    eax
    call    sub_418310
    mov     eax, TAdynmemStructPtr
    movsx   ecx, [eax+TAdynmemStruct.field_2CB0]
    movsx   esi, [eax+TAdynmemStruct.MouseMapPosY]
    movsx   edi, [eax+TAdynmemStruct.MouseMapPosX]
    mov     edx, [eax+TAdynmemStruct.MapX]
    mov     ebp, [eax+TAdynmemStruct.MapY]
    sar     ecx, 1
    sub     esi, ecx
    mov     cl, [eax+14280h]
    sub     edi, edx
    sub     esi, ebp
    add     edi, 80h
    add     esi, 20h
    cmp     cl, 2
    jnz     short loc_468E35
    xor     edx, edx
    lea     eax, [edi+2]
    mov     dl, [ebx+0Fh]
    lea     ecx, [edi-2]
    push    edx
    push    esi
    push    eax
    push    esi
    lea     edx, [esp+234h+var_1F0]
    push    ecx
    push    edx
    call    sub_4BE950
    xor     eax, eax
    lea     ecx, [esi+2]
    mov     al, [ebx+0Fh]
    add     esi, 0FFFFFFFEh
    push    eax
    push    ecx
    push    edi
    push    esi
    lea     edx, [esp+234h+var_1F0]
    push    edi
    push    edx
    call    sub_4BE950

    loc_468E35:                             ; CODE XREF: GameUnit_LOS_Unknown1+10Fj
    lea     eax, [esp+224h+var_1F0]
    push    eax
    call    sub_4C69C0
    mov     ebx, TAdynmemStructPtr
    xor     ecx, ecx
    lea     edi, [esp+224h+PlayerNumber]
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    lea     esi, [ebx+37E3Fh]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, ebx
    add     eax, ecx
    mov     ecx, 8
    rep movsd
    mov     cl, [eax+edx*2+TAdynmemStruct.Players.PlayerNumber]
    lea     ebp, [eax+edx*2+TAdynmemStruct.Players]
    movsb
    fld     [esp+224h+PlayerNumber+1]
    mov     byte ptr [esp+224h+PlayerNumber], cl
    call    __ftol
    fld     dword ptr [ebp+8Ch]
    mov     esi, eax
    call    __ftol
    sub     eax, esi
    jns     short loc_468EA9
    cdq
    and     edx, 7
    add     eax, edx
    sar     eax, 3
    jnz     short loc_468EC1
    or      eax, 0FFFFFFFFh
    jmp     short loc_468EC1
    ; ---------------------------------------------------------------------------

    loc_468EA9:                             ; CODE XREF: GameUnit_LOS_Unknown1+1A7j
    test    eax, eax
    jle     short loc_468EBF
    cdq
    and     edx, 7
    add     eax, edx
    sar     eax, 3
    jnz     short loc_468EC1
    mov     eax, 1
    jmp     short loc_468EC1
    ; ---------------------------------------------------------------------------

    loc_468EBF:                             ; CODE XREF: GameUnit_LOS_Unknown1+1BBj
    xor     eax, eax

    loc_468EC1:                             ; CODE XREF: GameUnit_LOS_Unknown1+1B2j
                                            ; GameUnit_LOS_Unknown1+1B7j ...
    add     eax, esi
    mov     [esp+224h+Player], eax
    fild    [esp+224h+Player]
    fstp    [esp+224h+PlayerNumber+1]
    fld     [esp+224h+var_19F]
    call    __ftol
    fld     dword ptr [ebp+98h]
    mov     esi, eax
    call    __ftol
    sub     eax, esi
    jns     short loc_468EFC
    cdq
    and     edx, 7
    add     eax, edx
    sar     eax, 3
    jnz     short loc_468F14
    or      eax, 0FFFFFFFFh
    jmp     short loc_468F14
    ; ---------------------------------------------------------------------------

    loc_468EFC:                             ; CODE XREF: GameUnit_LOS_Unknown1+1FAj
    test    eax, eax
    jle     short loc_468F12
    cdq
    and     edx, 7
    add     eax, edx
    sar     eax, 3
    jnz     short loc_468F14
    mov     eax, 1
    jmp     short loc_468F14
    ; ---------------------------------------------------------------------------

    loc_468F12:                             ; CODE XREF: GameUnit_LOS_Unknown1+20Ej
    xor     eax, eax

    loc_468F14:                             ; CODE XREF: GameUnit_LOS_Unknown1+205j
                                            ; GameUnit_LOS_Unknown1+20Aj ...
    mov     edx, [ebp+0A4h]
    add     eax, esi
    fld     [esp+224h+PlayerNumber+1]
    mov     [esp+224h+var_193], edx
    mov     [esp+224h+Player], eax
    fcomp   [esp+224h+var_193]
    mov     eax, [ebp+0A8h]
    fild    [esp+224h+Player]
    mov     [esp+224h+var_18F], eax
    fnstsw  ax
    fst     [esp+224h+var_19F]
    test    ah, 41h
    jnz     short loc_468F57
    mov     ecx, edx
    mov     [esp+224h+PlayerNumber+1], ecx

    loc_468F57:                             ; CODE XREF: GameUnit_LOS_Unknown1+25Fj
    fcomp   [esp+224h+var_18F]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_468F73
    mov     edx, [esp+224h+var_18F]
    mov     [esp+224h+var_19F], edx

    loc_468F73:                             ; CODE XREF: GameUnit_LOS_Unknown1+273j
    mov     eax, [ebp+0F8h]
    mov     ecx, [ebx+TAdynmemStruct.GameTime]
    cmp     eax, ecx
    jnb     short loc_468FC6
    add     eax, 1Eh
    push    ebp
    mov     [ebp+0F8h], eax
    call    sub_464AB0
    push    ebp
    fstp    [esp+228h+var_1A7]
    call    sub_464AC0
    push    ebp
    fstp    [esp+228h+var_1A3]
    call    sub_464AF0
    push    ebp
    fstp    [esp+228h+var_19B]
    call    sub_464B00
    mov     ebx, TAdynmemStructPtr
    fstp    [esp+224h+var_197]

    loc_468FC6:                             ; CODE XREF: GameUnit_LOS_Unknown1+291j
    lea     eax, [ebx+37E3Fh]
    mov     ecx, 21h
    lea     edi, [esp+224h+PlayerNumber]
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      loc_469610
    mov     ecx, 8
    lea     esi, [esp+224h+PlayerNumber]
    mov     edi, eax
    rep movsd
    movsb
    mov     eax, [ebp+27h]
    xor     ecx, ecx
    mov     cl, [eax+95h]
    mov     eax, ecx
    mov     [esp+224h+Player], ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*4]
    lea     eax, [ecx+edx*8]
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+eax*2+3816Bh]
    lea     esi, [ecx+eax*2+37F3Dh]
    push    edx
    call    sub_4C1420
    call    sub_4C1450
    mov     eax, TAdynmemStructPtr
    lea     edi, [eax+0DCBh]
    mov     [esp+224h+a2], edi
    call    sub_4C13F0
    xor     ecx, ecx
    push    eax
    mov     cl, [edi+0Fh]
    push    ecx
    call    sub_4C13A0
    mov     ecx, TAdynmemStructPtr
    mov     edi, 81h

    loc_469055:                             ; CODE XREF: GameUnit_LOS_Unknown1+3ADj
    mov     edx, [esp+224h+Player]
    xor     eax, eax
    cmp     edi, 81h
    push    0
    setnle  al
    lea     edx, [edx+eax*4]
    add     eax, edx
    mov     eax, [ecx+eax*4+1481Fh]
    push    eax
    call    sub_4B7F30
    mov     ebx, eax
    push    0
    push    edi
    lea     ecx, [esp+22Ch+var_1F0]
    push    ebx
    push    ecx
    call    sub_467A20
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [ebx]
    mov     eax, [ecx+37E1Fh]
    add     edi, edx
    cmp     edi, eax
    jl      short loc_469055
    lea     eax, [esi+42h]
    push    0
    push    eax
    lea     ecx, [esp+22Ch+var_1F0]
    push    ebp
    push    ecx
    call    sub_467C00
    lea     edi, [esi+52h]
    mov     eax, edi
    fld     dword ptr [ebp+0A4h]
    mov     edx, [eax]
    fcomp   ds:flt_4FD568
    mov     [esp+224h+var_188], edx
    mov     ecx, [eax+4]
    mov     [esp+224h+var_184], ecx
    mov     ecx, [eax+8]
    mov     [esp+224h+var_180], ecx
    mov     eax, [eax+0Ch]
    mov     [esp+224h+var_17C], eax
    fnstsw  ax
    test    ah, 41h
    jnz     loc_4691B9
    sub     ecx, edx
    mov     [esp+224h+Player], ecx
    fild    [esp+224h+Player]
    fmul    [esp+224h+PlayerNumber+1]
    fdiv    dword ptr [ebp+0A4h]
    fiadd   [esp+224h+var_188]
    call    __ftol
    mov     [esp+224h+var_180], eax
    mov     ecx, [esi+222h]
    lea     edx, [esp+224h+var_188]
    push    ecx
    lea     eax, [esp+228h+var_1F0]
    push    edx
    push    eax
    call    sub_4BF6F0
    fld     dword ptr [ebp+0E8h]
    fcomp   ds:flt_4FD568
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4691B9
    fld     dword ptr [ebp+8Ch]
    fcomp   dword ptr [ebp+0E8h]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4691B9
    mov     ecx, [edi]
    mov     [esp+224h+var_200], ecx
    mov     edx, [edi+4]
    mov     [esp+224h+var_1FC], edx
    mov     eax, [edi+8]
    mov     [esp+224h+var_1F8], eax
    sub     eax, ecx
    mov     [esp+224h+Player], eax
    mov     edx, [edi+0Ch]
    fild    [esp+224h+Player]
    mov     [esp+224h+var_1F4], edx
    fmul    dword ptr [ebp+0E8h]
    fdiv    dword ptr [ebp+0A4h]
    fiadd   [esp+224h+var_200]
    call    __ftol
    mov     edi, [esp+224h+a2]
    mov     [esp+224h+var_200], eax
    add     eax, 2
    lea     ecx, [esp+224h+var_200]
    mov     [esp+224h+var_1F8], eax
    xor     eax, eax
    mov     al, [edi+0Ch]
    lea     edx, [esp+224h+var_1F0]
    push    eax
    push    ecx
    push    edx
    call    sub_4BF6F0
    jmp     short loc_4691BD
    ; ---------------------------------------------------------------------------

    loc_4691B9:                             ; CODE XREF: GameUnit_LOS_Unknown1+3FDj
                                            ; GameUnit_LOS_Unknown1+454j ...
    mov     edi, [esp+224h+a2]

    loc_4691BD:                             ; CODE XREF: GameUnit_LOS_Unknown1+4C7j
    fld     [esp+224h+PlayerNumber+1]
    call    __ftol
    push    eax
    lea     eax, [esp+228h+var_170]
    push    offset aD_0                     ; "%d"
    push    eax
    call    _sprintf
    mov     ecx, [esi+66h]
    mov     edx, [esi+62h]
    add     esp, 0Ch
    lea     eax, [esp+224h+var_170]
    push    0FFFFFFFFh
    push    ecx
    push    edx
    lea     ecx, [esp+230h+var_1F0]
    push    eax
    push    ecx
    call    PrintGUIText
    mov     edx, [esi+0D6h]
    mov     eax, [esi+0D2h]
    push    0FFFFFFFFh
    push    edx
    push    eax
    lea     ecx, [esp+230h+var_1F0]
    push    offset a0                       ; "0"
    push    ecx
    call    PrintGUIText
    fld     dword ptr [ebp+0A4h]
    call    __ftol
    push    eax
    lea     edx, [esp+228h+var_170]
    push    offset aD_0                     ; "%d"
    push    edx
    call    _sprintf
    mov     ecx, [esi+22Eh]
    add     esp, 0Ch
    lea     eax, [esp+224h+var_170]
    push    eax
    push    ecx
    call    sub_4C1480
    mov     edx, [esi+0B6h]
    mov     ecx, [esi+0B2h]
    push    0FFFFFFFFh
    push    edx
    sub     ecx, eax
    lea     edx, [esp+22Ch+var_170]
    push    ecx
    lea     eax, [esp+230h+var_1F0]
    push    edx
    push    eax
    call    PrintGUIText
    fld     [esp+224h+var_1A7]
    fcomp   ds:flt_4FD56C
    fld     [esp+224h+var_1A7]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4692AD
    call    __ftol
    mov     ecx, eax
    mov     eax, 10624DD3h
    imul    ecx
    sar     edx, 6
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    push    edx
    lea     edx, [esp+228h+var_170]
    push    offset off_50783C
    push    edx
    jmp     short loc_4692C0
    ; ---------------------------------------------------------------------------

    loc_4692AD:                             ; CODE XREF: GameUnit_LOS_Unknown1+593j
    call    __ftol
    push    eax
    lea     eax, [esp+228h+var_170]
    push    offset aD_0                     ; "%d"
    push    eax

    loc_4692C0:                             ; CODE XREF: GameUnit_LOS_Unknown1+5BBj
    call    _sprintf
    add     esp, 0Ch
    call    sub_4C13F0
    xor     ecx, ecx
    push    eax
    mov     cl, [edi+0Ah]
    push    ecx
    call    sub_4C13A0
    mov     edx, [esi+0F6h]
    mov     eax, [esi+0F2h]
    push    0FFFFFFFFh
    push    edx
    lea     ecx, [esp+22Ch+var_170]
    push    eax
    lea     edx, [esp+230h+var_1F0]
    push    ecx
    push    edx
    call    PrintGUIText
    fld     [esp+224h+var_1A3]
    fcomp   ds:flt_4FD570
    fld     [esp+224h+var_1A3]
    fnstsw  ax
    test    ah, 1
    jz      short loc_46933E
    call    __ftol
    mov     ecx, eax
    mov     eax, 10624DD3h
    imul    ecx
    sar     edx, 6
    mov     eax, edx
    lea     ecx, [esp+224h+var_170]
    shr     eax, 1Fh
    add     edx, eax
    push    edx
    push    offset off_50783C
    push    ecx
    jmp     short loc_469356
    ; ---------------------------------------------------------------------------

    loc_46933E:                             ; CODE XREF: GameUnit_LOS_Unknown1+624j
    call    __ftol
    cdq
    xor     eax, edx
    sub     eax, edx
    lea     edx, [esp+224h+var_170]
    push    eax
    push    offset aD_0                     ; "%d"
    push    edx

    loc_469356:                             ; CODE XREF: GameUnit_LOS_Unknown1+64Cj
    call    _sprintf
    add     esp, 0Ch
    call    sub_4C13F0
    push    eax
    xor     eax, eax
    mov     al, [edi+0Ch]
    push    eax
    call    sub_4C13A0
    mov     ecx, [esi+106h]
    mov     edx, [esi+102h]
    push    0FFFFFFFFh
    push    ecx
    lea     eax, [esp+22Ch+var_170]
    push    edx
    lea     ecx, [esp+230h+var_1F0]
    push    eax
    push    ecx
    call    PrintGUIText
    lea     ebx, [esi+72h]
    mov     eax, ebx
    fld     dword ptr [ebp+0A8h]
    mov     edx, [eax]
    fcomp   ds:flt_4FD568
    mov     [esp+224h+var_188], edx
    mov     ecx, [eax+4]
    mov     [esp+224h+var_184], ecx
    mov     ecx, [eax+8]
    mov     [esp+224h+var_180], ecx
    mov     eax, [eax+0Ch]
    mov     [esp+224h+var_17C], eax
    fnstsw  ax
    test    ah, 41h
    jnz     loc_469497
    sub     ecx, edx
    mov     [esp+224h+Player], ecx
    fild    [esp+224h+Player]
    fmul    [esp+224h+var_19F]
    fdiv    dword ptr [ebp+0A8h]
    fiadd   [esp+224h+var_188]
    call    __ftol
    mov     [esp+224h+var_180], eax
    mov     ecx, [esi+226h]
    lea     edx, [esp+224h+var_188]
    push    ecx
    lea     eax, [esp+228h+var_1F0]
    push    edx
    push    eax
    call    sub_4BF6F0
    fld     dword ptr [ebp+0E4h]
    fcomp   ds:flt_4FD568
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_469497
    fld     dword ptr [ebp+98h]
    fcomp   dword ptr [ebp+0E4h]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_469497
    mov     ecx, [ebx]
    mov     [esp+224h+var_200], ecx
    mov     edx, [ebx+4]
    mov     [esp+224h+var_1FC], edx
    mov     eax, [ebx+8]
    mov     [esp+224h+var_1F8], eax
    sub     eax, ecx
    mov     [esp+224h+Player], eax
    mov     edx, [ebx+0Ch]
    fild    [esp+224h+Player]
    mov     [esp+224h+var_1F4], edx
    fmul    dword ptr [ebp+0E4h]
    fdiv    dword ptr [ebp+0A8h]
    fiadd   [esp+224h+var_200]
    call    __ftol
    mov     [esp+224h+var_200], eax
    add     eax, 2
    mov     [esp+224h+var_1F8], eax
    xor     eax, eax
    mov     al, [edi+0Ch]
    lea     ecx, [esp+224h+var_200]
    push    eax
    lea     edx, [esp+228h+var_1F0]
    push    ecx
    push    edx
    call    sub_4BF6F0

    loc_469497:                             ; CODE XREF: GameUnit_LOS_Unknown1+6DEj
                                            ; GameUnit_LOS_Unknown1+738j ...
    call    sub_4C13F0
    push    eax
    xor     eax, eax
    mov     al, [edi+0Fh]
    push    eax
    call    sub_4C13A0
    fld     [esp+224h+var_19F]
    call    __ftol
    push    eax
    lea     ecx, [esp+228h+var_170]
    push    offset aD_0                     ; "%d"
    push    ecx
    call    _sprintf
    mov     edx, [esi+86h]
    mov     eax, [esi+82h]
    add     esp, 0Ch
    lea     ecx, [esp+224h+var_170]
    push    0FFFFFFFFh
    push    edx
    push    eax
    lea     edx, [esp+230h+var_1F0]
    push    ecx
    push    edx
    call    PrintGUIText
    mov     eax, [esi+0E6h]
    mov     ecx, [esi+0E2h]
    push    0FFFFFFFFh
    push    eax
    push    ecx
    lea     edx, [esp+230h+var_1F0]
    push    offset a0                       ; "0"
    push    edx
    call    PrintGUIText
    fld     dword ptr [ebp+0A8h]
    call    __ftol
    push    eax
    lea     eax, [esp+228h+var_170]
    push    offset aD_0                     ; "%d"
    push    eax
    call    _sprintf
    mov     edx, [esi+22Eh]
    add     esp, 0Ch
    lea     ecx, [esp+224h+var_170]
    push    ecx
    push    edx
    call    sub_4C1480
    mov     edx, [esi+0C2h]
    mov     ecx, [esi+0C6h]
    push    0FFFFFFFFh
    sub     edx, eax
    push    ecx
    lea     eax, [esp+22Ch+var_170]
    push    edx
    lea     ecx, [esp+230h+var_1F0]
    push    eax
    push    ecx
    call    PrintGUIText
    sub     esp, 8
    lea     edx, [esp+22Ch+var_170]
    fld     [esp+22Ch+var_19B]
    fstp    [esp+22Ch+var_22C]
    push    offset a_1f                     ; "%.1f"
    push    edx
    call    _sprintf
    add     esp, 10h
    call    sub_4C13F0
    push    eax
    xor     eax, eax
    mov     al, [edi+0Ah]
    push    eax
    call    sub_4C13A0
    mov     ecx, [esi+116h]
    mov     edx, [esi+112h]
    push    0FFFFFFFFh
    push    ecx
    lea     eax, [esp+22Ch+var_170]
    push    edx
    lea     ecx, [esp+230h+var_1F0]
    push    eax
    push    ecx
    call    PrintGUIText
    fld     [esp+224h+var_197]
    sub     esp, 8
    lea     edx, [esp+22Ch+var_170]
    fabs
    fstp    [esp+22Ch+var_22C]
    push    offset a_1f                     ; "%.1f"
    push    edx
    call    _sprintf
    add     esp, 10h
    call    sub_4C13F0
    push    eax
    xor     eax, eax
    mov     al, [edi+0Ch]
    push    eax
    call    sub_4C13A0
    mov     ecx, [esi+126h]
    mov     edx, [esi+122h]
    push    0FFFFFFFFh
    push    ecx
    lea     eax, [esp+22Ch+var_170]
    push    edx
    lea     ecx, [esp+230h+var_1F0]
    push    eax
    push    ecx
    call    PrintGUIText

    loc_469610:                             ; CODE XREF: GameUnit_LOS_Unknown1+2EBj
    lea     edx, [esp+224h+var_1F0]
    push    edx
    call    LOS_GUIText
    lea     eax, [esp+224h+var_1F0]
    push    eax
    call    sub_466B00
    mov     ecx, TAdynmemStructPtr
    sub     esp, 10h
    add     ecx, 37E27h
    mov     edx, esp
    mov     eax, [ecx]
    mov     [edx], eax
    mov     eax, [ecx+4]
    mov     [edx+4], eax
    mov     eax, [ecx+8]
    mov     [edx+8], eax
    mov     ecx, [ecx+0Ch]
    mov     [edx+0Ch], ecx
    lea     ecx, [esp+234h+var_1F0]
    call    sub_4C6B10
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ebp, [esi+38h]
    mov     ecx, eax
    sub     ecx, edx
    add     ebp, ecx
    mov     [esi+38h], ebp
    mov     [esi], eax
    mov     edx, TAdynmemStructPtr
    mov     esi, edx
    mov     al, [edx+TAdynmemStruct.LOS_Sight]
    lea     edi, [edx+141FBh]
    mov     byte ptr [esp+224h+PlayerIndex], al
    mov     eax, [esp+224h+PlayerIndex]
    and     eax, 0FFh
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [esi+ecx*2+TAdynmemStruct.Players]
    xor     ecx, ecx
    mov     [esp+224h+Player], eax
    mov     eax, [eax+PlayerStruct.PlayerInfo]
    mov     cl, [eax+95h]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    mov     edx, [edx+ecx*2+3816Bh]
    push    edx
    call    sub_4C1420
    call    sub_4C13F0
    mov     ecx, TAdynmemStructPtr
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DDAh]
    push    eax
    call    sub_4C13A0
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     eax, [esi+1431Fh]
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     ebx, eax
    mov     eax, [esi+14323h]
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     edx, [edi+54h]
    sar     ebx, 4
    sar     eax, 4
    test    edx, edx
    jle     short loc_469745

    loc_46971B:                             ; CODE XREF: GameUnit_LOS_Unknown1+A4Dj
    mov     edx, [edi+50h]
    mov     esi, [edi]
    imul    edx, ecx
    inc     ecx
    lea     edx, [esi+edx*4]
    mov     esi, [edi+4]
    mov     [esi+ecx*4-4], edx
    mov     edx, [edi+8]
    mov     word ptr [edx+ecx*2-2], 0
    mov     edx, [edi+54h]
    cmp     ecx, edx
    jl      short loc_46971B
    mov     esi, TAdynmemStructPtr

    loc_469745:                             ; CODE XREF: GameUnit_LOS_Unknown1+A29j
    mov     edx, [edi+54h]
    add     eax, 0FFFFFFF0h
    test    eax, eax
    mov     [esp+224h+a3], eax
    mov     [esp+224h+var_210], edx
    jge     short loc_46976B
    neg     eax
    mov     [esp+224h+var_1BC], eax
    sub     edx, eax
    xor     eax, eax
    mov     [esp+224h+var_210], edx
    mov     [esp+224h+a3], eax
    jmp     short loc_469773
    ; ---------------------------------------------------------------------------

    loc_46976B:                             ; CODE XREF: GameUnit_LOS_Unknown1+A65j
    mov     [esp+224h+var_1BC], 0

    loc_469773:                             ; CODE XREF: GameUnit_LOS_Unknown1+A79j
    mov     ecx, [edi+3Ch]
    add     edx, eax
    lea     ebp, [ecx-1]
    cmp     edx, ebp
    jle     short loc_469786
    sub     ecx, eax
    dec     ecx
    mov     [esp+224h+var_210], ecx

    loc_469786:                             ; CODE XREF: GameUnit_LOS_Unknown1+A8Dj
    mov     ecx, [edi+50h]
    add     ebx, 0FFFFFFF6h
    test    ebx, ebx
    mov     [esp+224h+a2], ebx
    mov     [esp+224h+var_204], ecx
    jge     short loc_4697A4
    add     ecx, ebx
    xor     ebx, ebx
    mov     [esp+224h+var_204], ecx
    mov     [esp+224h+a2], ebx

    loc_4697A4:                             ; CODE XREF: GameUnit_LOS_Unknown1+AA6j
    mov     eax, [edi+38h]
    add     ecx, ebx
    lea     edx, [eax-1]
    cmp     ecx, edx
    jle     short loc_4697B7
    sub     eax, ebx
    dec     eax
    mov     [esp+224h+var_204], eax

    loc_4697B7:                             ; CODE XREF: GameUnit_LOS_Unknown1+ABEj
    mov     eax, [esi+14367h]
    mov     ebx, [esi+1435Fh]
    test    eax, eax
    mov     [esp+224h+NumHotUnits], 0
    jle     short loc_469842

    loc_4697CF:                             ; CODE XREF: GameUnit_LOS_Unknown1+B50j
    xor     ecx, ecx
    mov     edx, [esi+TAdynmemStruct.MapY]
    mov     cx, [ebx]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [esi+TAdynmemStruct.Units]
    lea     eax, [eax+eax*4]
    lea     ebp, [ecx+eax*8]
    movsx   eax, word ptr [ecx+eax*8+74h]
    sub     eax, edx
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4
    add     eax, 10h
    js      short loc_46982C
    cmp     eax, [edi+54h]
    jge     short loc_46982C
    mov     edx, [edi+4]
    lea     ecx, [edx+eax*4]
    mov     edx, [edi+8]
    inc     word ptr [edx+eax*2]
    lea     eax, [edx+eax*2]
    mov     eax, [ecx]
    test    eax, eax
    jz      short loc_469826
    mov     [eax], ebp
    mov     eax, [ecx]
    add     eax, 4
    mov     [ecx], eax

    loc_469826:                             ; CODE XREF: GameUnit_LOS_Unknown1+B2Bj
    mov     esi, TAdynmemStructPtr

    loc_46982C:                             ; CODE XREF: GameUnit_LOS_Unknown1+B10j
                                            ; GameUnit_LOS_Unknown1+B15j
    mov     eax, [esp+224h+NumHotUnits]
    mov     ecx, [esi+TAdynmemStruct.NumHotUnits]
    inc     eax
    add     ebx, 2
    cmp     eax, ecx
    mov     [esp+224h+NumHotUnits], eax
    jl      short loc_4697CF

    loc_469842:                             ; CODE XREF: GameUnit_LOS_Unknown1+ADDj
    lea     eax, [esp+224h+var_1F0]
    push    0
    push    eax
    call    sub_471F90
    lea     ecx, [esp+224h+var_1F0]
    push    1
    push    ecx
    call    sub_471F90
    lea     edx, [esp+224h+var_1F0]
    push    2
    push    edx
    call    sub_471F90
    mov     eax, [esp+224h+var_210]
    mov     ebx, [esp+224h+a3]
    test    eax, eax
    jle     loc_46995D
    mov     [esp+224h+var_1C0], eax

    loc_46987A:                             ; CODE XREF: GameUnit_LOS_Unknown1+C67j
    mov     eax, [edi+38h]
    mov     ebp, [esp+224h+a2]
    imul    eax, ebx
    mov     edx, [edi+8Ch]
    add     eax, ebp
    lea     ecx, [eax+eax*2]
    lea     esi, [eax+ecx*4]
    mov     eax, [esp+224h+var_204]
    add     esi, edx
    test    eax, eax
    jle     loc_46994D
    mov     [esp+224h+NumHotUnits], eax

    loc_4698A4:                             ; CODE XREF: GameUnit_LOS_Unknown1+C57j
    mov     cl, [esi+0Ch]
    and     cl, 0FBh
    cmp     word ptr [esi+8], 0FFFBh
    mov     [esi+0Ch], cl
    jnb     loc_46993A
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [esi+8]
    mov     eax, [eax+TAdynmemStruct.FeatureDef]
    shl     edx, 8
    add     eax, edx
    cmp     byte ptr [eax+0FAh], 0Ah
    jnb     short loc_469936
    test    byte ptr [eax+0FFh], 8
    jz      short loc_469927
    mov     cl, [esi+0Ch]
    mov     dl, byte ptr [esp+224h+PlayerIndex]
    shr     cl, 3
    and     cl, 0Fh
    cmp     cl, dl
    jz      short loc_469927
    movsx   ecx, word ptr [eax+96h]
    xor     edx, edx
    mov     dl, [esi+4]
    push    edx                             ; __int16
    push    ecx                             ; a5
    movsx   edx, word ptr [eax+94h]
    mov     eax, [esp+22Ch+Player]
    push    edx                             ; a4
    push    ebx                             ; a3
    push    ebp                             ; a2
    push    eax                             ; Player
    call    sub_4658E0
    test    eax, eax
    jz      short loc_46993A
    push    ebx                             ; int
    push    ebp                             ; int
    lea     ecx, [esp+22Ch+var_1F0]
    push    esi                             ; int
    push    ecx                             ; int
    call    sub_46A610
    jmp     short loc_46993A
    ; ---------------------------------------------------------------------------

    loc_469927:                             ; CODE XREF: GameUnit_LOS_Unknown1+BEFj
                                            ; GameUnit_LOS_Unknown1+C00j
    push    ebx                             ; int
    push    ebp                             ; int
    lea     edx, [esp+22Ch+var_1F0]
    push    esi                             ; int
    push    edx                             ; int
    call    sub_46A610
    jmp     short loc_46993A
    ; ---------------------------------------------------------------------------

    loc_469936:                             ; CODE XREF: GameUnit_LOS_Unknown1+BE6j
    or      byte ptr [esi+0Ch], 4

    loc_46993A:                             ; CODE XREF: GameUnit_LOS_Unknown1+BC3j
                                            ; GameUnit_LOS_Unknown1+C26j ...
    mov     eax, [esp+224h+NumHotUnits]
    inc     ebp
    add     esi, 0Dh
    dec     eax
    mov     [esp+224h+NumHotUnits], eax
    jnz     loc_4698A4

    loc_46994D:                             ; CODE XREF: GameUnit_LOS_Unknown1+BAAj
    mov     eax, [esp+224h+var_1C0]
    inc     ebx
    dec     eax
    mov     [esp+224h+var_1C0], eax
    jnz     loc_46987A

    loc_46995D:                             ; CODE XREF: GameUnit_LOS_Unknown1+B80j
    lea     eax, [esp+224h+var_1F0]
    push    3
    push    eax
    call    sub_471F90
    lea     ecx, [esp+224h+var_1F0]
    push    4
    push    ecx
    call    sub_471F90
    mov     edx, [esp+224h+var_210]
    test    edx, edx
    jle     loc_469AF6
    mov     eax, [esp+224h+var_1BC]
    mov     ecx, [esp+224h+a3]
    mov     [esp+224h+var_210], ecx
    mov     [esp+224h+var_1C0], edx
    lea     esi, [eax+eax]
    sub     eax, ecx
    mov     [esp+224h+NumHotUnits], esi
    mov     [esp+224h+a3], eax

    loc_46999E:                             ; CODE XREF: GameUnit_LOS_Unknown1+E00j
    mov     edx, [esp+224h+a3]
    mov     eax, [esp+224h+var_210]
    add     edx, eax
    mov     ecx, [edi]
    imul    edx, [edi+50h]
    mov     eax, [esp+224h+NumHotUnits]
    xor     ebx, ebx
    lea     ebp, [ecx+edx*4]
    mov     edx, [edi+8]
    cmp     [eax+edx], bx
    jbe     short loc_469A1A

    loc_4699C0:                             ; CODE XREF: GameUnit_LOS_Unknown1+D28j
    mov     esi, [ebp+0]
    mov     eax, [esi+110h]
    mov     ecx, eax
    and     ecx, 3
    cmp     cl, 1
    jnz     short loc_469A05
    mov     ecx, [esp+224h+arg_0]
    test    ecx, ecx
    jz      short loc_469A05
    shr     eax, 4
    test    al, 1
    jz      short loc_4699F0
    lea     edx, [esp+224h+var_1F0]
    push    esi
    push    edx
    call    sub_46A530

    loc_4699F0:                             ; CODE XREF: GameUnit_LOS_Unknown1+CF3j
    mov     eax, [esi+9Ah]
    test    eax, eax
    jz      short loc_469A05
    lea     eax, [esp+224h+var_1F0]
    push    esi
    push    eax
    call    sub_45AC20

    loc_469A05:                             ; CODE XREF: GameUnit_LOS_Unknown1+CE1j
                                            ; GameUnit_LOS_Unknown1+CECj ...
    mov     ecx, [edi+8]
    mov     eax, [esp+224h+NumHotUnits]
    xor     edx, edx
    inc     ebx
    mov     dx, [eax+ecx]
    add     ebp, 4
    cmp     ebx, edx
    jl      short loc_4699C0

    loc_469A1A:                             ; CODE XREF: GameUnit_LOS_Unknown1+CCEj
    mov     eax, [esp+224h+var_210]
    mov     ebp, [esp+224h+a2]
    imul    eax, [edi+38h]
    mov     edx, [edi+8Ch]
    add     eax, ebp
    lea     ecx, [eax+eax*2]
    lea     esi, [eax+ecx*4]
    mov     eax, [esp+224h+var_204]
    add     esi, edx
    test    eax, eax
    jle     loc_469AD3
    mov     [esp+224h+var_1BC], eax

    loc_469A46:                             ; CODE XREF: GameUnit_LOS_Unknown1+DDDj
    mov     cl, [esi+0Ch]
    test    cl, 4
    jz      short loc_469AC0
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [esi+8]
    mov     eax, [eax+TAdynmemStruct.FeatureDef]
    shl     edx, 8
    add     eax, edx
    test    byte ptr [eax+0FFh], 8
    jz      short loc_469AAF
    mov     dl, byte ptr [esp+224h+PlayerIndex]
    shr     cl, 3
    and     cl, 0Fh
    cmp     cl, dl
    jz      short loc_469AAF
    movsx   edx, word ptr [eax+96h]
    movsx   eax, word ptr [eax+94h]
    mov     ebx, [esp+224h+var_210]
    xor     ecx, ecx
    mov     cl, [esi+4]
    push    ecx                             ; __int16
    mov     ecx, [esp+228h+Player]
    push    edx                             ; a5
    push    eax                             ; a4
    push    ebx                             ; a3
    push    ebp                             ; a2
    push    ecx                             ; Player
    call    sub_4658E0
    test    eax, eax
    jz      short loc_469AC0
    push    ebx
    push    ebp
    lea     edx, [esp+22Ch+var_1F0]
    push    esi
    push    edx
    jmp     short loc_469ABB
    ; ---------------------------------------------------------------------------

    loc_469AAF:                             ; CODE XREF: GameUnit_LOS_Unknown1+D7Bj
                                            ; GameUnit_LOS_Unknown1+D89j
    mov     eax, [esp+224h+var_210]
    lea     ecx, [esp+224h+var_1F0]
    push    eax                             ; int
    push    ebp                             ; int
    push    esi                             ; int
    push    ecx                             ; int

    loc_469ABB:                             ; CODE XREF: GameUnit_LOS_Unknown1+DBDj
    call    sub_46A610

    loc_469AC0:                             ; CODE XREF: GameUnit_LOS_Unknown1+D5Cj
                                            ; GameUnit_LOS_Unknown1+DB3j
    mov     eax, [esp+224h+var_1BC]
    inc     ebp
    add     esi, 0Dh
    dec     eax
    mov     [esp+224h+var_1BC], eax
    jnz     loc_469A46

    loc_469AD3:                             ; CODE XREF: GameUnit_LOS_Unknown1+D4Cj
    mov     edx, [esp+224h+NumHotUnits]
    mov     ecx, [esp+224h+var_210]
    mov     eax, [esp+224h+var_1C0]
    add     edx, 2
    inc     ecx
    dec     eax
    mov     [esp+224h+NumHotUnits], edx
    mov     [esp+224h+var_210], ecx
    mov     [esp+224h+var_1C0], eax
    jnz     loc_46999E

    loc_469AF6:                             ; CODE XREF: GameUnit_LOS_Unknown1+C8Bj
    lea     edx, [esp+224h+var_1F0]
    push    5
    push    edx
    call    sub_471F90
    mov     ebx, [esp+224h+arg_0]
    test    ebx, ebx
    jz      loc_469BD0
    lea     eax, [esp+224h+var_1F0]
    push    6
    push    eax
    call    sub_471F90
    lea     ecx, [esp+224h+var_1F0]
    push    ecx
    call    sub_49BE60
    lea     edx, [esp+224h+var_1F0]
    push    edx
    call    sub_420B00
    lea     eax, [esp+224h+var_1F0]
    push    7
    push    eax
    call    sub_471F90
    mov     eax, [edi+54h]
    test    eax, eax
    mov     [esp+224h+var_204], 0
    jle     loc_469BD0
    mov     ecx, [esp+224h+var_204]

    loc_469B54:                             ; CODE XREF: GameUnit_LOS_Unknown1+ED7j
    mov     edx, [edi+50h]
    mov     eax, [edi]
    imul    edx, ecx
    xor     ebx, ebx
    lea     ebp, [eax+edx*4]
    mov     edx, [edi+8]
    cmp     [edx+ecx*2], bx
    jbe     short loc_469BBD

    loc_469B6A:                             ; CODE XREF: GameUnit_LOS_Unknown1+ECBj
    mov     esi, [ebp+0]
    mov     eax, [esi+110h]
    mov     edx, eax
    and     edx, 3
    cmp     dl, 1
    jz      short loc_469BAC
    shr     eax, 4
    test    al, 1
    jz      short loc_469B93
    lea     eax, [esp+224h+var_1F0]
    push    esi
    push    eax
    call    sub_46A530
    mov     ecx, [esp+224h+var_204]

    loc_469B93:                             ; CODE XREF: GameUnit_LOS_Unknown1+E92j
    mov     eax, [esi+9Ah]
    test    eax, eax
    jz      short loc_469BAC
    lea     ecx, [esp+224h+var_1F0]
    push    esi
    push    ecx
    call    sub_45AC20
    mov     ecx, [esp+224h+var_204]

    loc_469BAC:                             ; CODE XREF: GameUnit_LOS_Unknown1+E8Bj
                                            ; GameUnit_LOS_Unknown1+EABj
    mov     edx, [edi+8]
    xor     eax, eax
    inc     ebx
    add     ebp, 4
    mov     ax, [edx+ecx*2]
    cmp     ebx, eax
    jl      short loc_469B6A

    loc_469BBD:                             ; CODE XREF: GameUnit_LOS_Unknown1+E78j
    mov     eax, [edi+54h]
    inc     ecx
    cmp     ecx, eax
    mov     [esp+224h+var_204], ecx
    jl      short loc_469B54
    mov     ebx, [esp+224h+arg_0]

    loc_469BD0:                             ; CODE XREF: GameUnit_LOS_Unknown1+E1Bj
                                            ; GameUnit_LOS_Unknown1+E5Aj
    lea     ecx, [esp+224h+var_1F0]
    push    8
    push    ecx
    call    sub_471F90
    push    0F9h
    call    sub_4C1B80
    test    eax, eax
    jz      short loc_469C01
    mov     edx, TAdynmemStructPtr
    lea     eax, [esp+224h+var_1F0]
    add     edx, TAdynmemStruct.CirclePointer
    push    edx
    push    eax
    call    sub_48CC30

    loc_469C01:                             ; CODE XREF: GameUnit_LOS_Unknown1+EF8j
    test    ebx, ebx
    jz      loc_469D38
    mov     eax, TAdynmemStructPtr
    mov     [esp+224h+NumHotUnits], 0
    mov     ecx, [eax+TAdynmemStruct.HotUnits]
    mov     [esp+224h+a2], ecx
    mov     ecx, [eax+TAdynmemStruct.NumHotUnits]
    test    ecx, ecx
    jle     loc_469D25

    loc_469C2E:                             ; CODE XREF: GameUnit_LOS_Unknown1+102Fj
    mov     ecx, [esp+224h+a2]
    xor     edx, edx
    mov     dx, [ecx]
    mov     ecx, edx
    shl     ecx, 3
    sub     ecx, edx
    lea     edx, [ecx+ecx*4]
    mov     ecx, [eax+TAdynmemStruct.Units]
    lea     edi, [ecx+edx*8]
    mov     cl, [eax+37F06h]
    test    cl, 1
    jnz     short loc_469C63
    mov     ecx, [edi+0ACh]
    test    ecx, ecx
    jz      loc_469D03

    loc_469C63:                             ; CODE XREF: GameUnit_LOS_Unknown1+F63j
    movsx   esi, word ptr [edi+74h]
    movsx   ebp, word ptr [edi+6Ch]
    mov     byte ptr [esp+224h+var_210+1], 0
    mov     edx, [eax+TAdynmemStruct.MapY]
    mov     ebx, [eax+TAdynmemStruct.MapX]
    sub     esi, edx
    movsx   edx, word ptr [edi+70h]
    mov     cl, [eax+37F06h]
    sub     ebp, ebx
    sar     edx, 1
    sub     esi, edx
    add     ebp, 80h
    add     esi, 20h
    test    cl, 1
    jz      short loc_469D03
    mov     ecx, [edi+96h]
    mov     bl, byte ptr [esp+224h+PlayerIndex]
    cmp     [ecx+146h], bl
    jnz     short loc_469CC3
    lea     edx, [esi+0Ah]
    lea     eax, [esp+224h+var_1F0]
    push    edx
    push    ebp
    push    edi
    push    eax
    call    sub_46A430
    mov     eax, TAdynmemStructPtr

    loc_469CC3:                             ; CODE XREF: GameUnit_LOS_Unknown1+FBCj
    mov     ecx, [edi+96h]
    cmp     [ecx+146h], bl
    jnz     short loc_469D03
    mov     ecx, [edi+0ACh]
    test    ecx, ecx
    jz      short loc_469D03
    mov     dl, [edi+0ACh]
    add     esi, 0Eh
    push    0FFFFFFFFh
    push    esi
    lea     eax, [esp+22Ch+var_210]
    push    ebp
    lea     ecx, [esp+230h+var_1F0]
    add     dl, 30h
    push    eax
    push    ecx
    mov     byte ptr [esp+238h+var_210], dl
    call    PrintGUIText
    mov     eax, TAdynmemStructPtr

    loc_469D03:                             ; CODE XREF: GameUnit_LOS_Unknown1+F6Dj
                                            ; GameUnit_LOS_Unknown1+FAAj ...
    mov     ecx, [esp+224h+NumHotUnits]
    mov     esi, [esp+224h+a2]
    mov     edx, [eax+14367h]
    inc     ecx
    add     esi, 2
    cmp     ecx, edx
    mov     [esp+224h+NumHotUnits], ecx
    mov     [esp+224h+a2], esi
    jl      loc_469C2E

    loc_469D25:                             ; CODE XREF: GameUnit_LOS_Unknown1+F38j
    lea     edx, [esp+224h+var_1F0]
    push    9
    push    edx
    call    sub_471F90
    mov     ebx, [esp+224h+arg_0]

    loc_469D38:                             ; CODE XREF: GameUnit_LOS_Unknown1+F13j
    mov     eax, TAdynmemStructPtr
    lea     esi, [eax+38D85h]
    call    GetTickCount
    mov     edi, [esi]
    mov     edx, [esi+3Ch]
    mov     ecx, eax
    sub     ecx, edi
    add     edx, ecx
    mov     [esi+3Ch], edx
    mov     [esi], eax
    mov     edx, TAdynmemStructPtr
    mov     ax, [edx+3923Bh]
    test    al, 1
    jz      short loc_469D85
    test    al, 2
    jz      short loc_469D85
    test    ebx, ebx
    jz      short loc_469D93
    push    0                               ; int
    push    0                               ; int
    call    sub_48C190
    push    eax
    lea     eax, [esp+228h+var_1F0]
    push    eax
    call    sub_417F30

    loc_469D85:                             ; CODE XREF: GameUnit_LOS_Unknown1+1077j
                                            ; GameUnit_LOS_Unknown1+107Bj
    test    ebx, ebx
    jz      short loc_469D93
    lea     ecx, [esp+224h+var_1F0]
    push    ecx
    call    sub_4848E0

    loc_469D93:                             ; CODE XREF: GameUnit_LOS_Unknown1+107Fj
                                            ; GameUnit_LOS_Unknown1+1097j
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edi, [esi]
    mov     edx, [esi+40h]
    mov     ecx, eax
    sub     ecx, edi
    add     edx, ecx
    mov     [esi+40h], edx
    mov     [esi], eax
    test    ebx, ebx
    jnz     short loc_469DC2
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    jmp     short loc_469E0B
    ; ---------------------------------------------------------------------------

    loc_469DC2:                             ; CODE XREF: GameUnit_LOS_Unknown1+10C6j
    mov     ecx, TAdynmemStructPtr
    test    [ecx+TAdynmemStruct.BuildSpotState], 8
    jz      short loc_469DD8
    mov     eax, 1
    jmp     short loc_469E0B
    ; ---------------------------------------------------------------------------

    loc_469DD8:                             ; CODE XREF: GameUnit_LOS_Unknown1+10DFj
    cmp     byte ptr [ecx+2CC3h], 0Eh
    jnz     short loc_469E09
    mov     edx, [ecx+2C7Ah]
    mov     eax, [ecx+2C76h]
    push    edx
    add     ecx, 37E27h
    push    eax
    push    ecx
    call    sub_4B6720
    mov     ecx, TAdynmemStructPtr
    neg     eax
    sbb     eax, eax
    neg     eax
    jmp     short loc_469E0B
    ; ---------------------------------------------------------------------------

    loc_469E09:                             ; CODE XREF: GameUnit_LOS_Unknown1+10EFj
    xor     eax, eax

    loc_469E0B:                             ; CODE XREF: GameUnit_LOS_Unknown1+10D0j
                                            ; GameUnit_LOS_Unknown1+10E6j ...
    test    eax, eax
    jz      loc_469F30
    mov     edi, [ecx+TAdynmemStruct.Height]
    mov     eax, [ecx+TAdynmemStruct.BuildPosRealY]
    mov     edx, [ecx+TAdynmemStruct.MapX]
    mov     esi, [ecx+TAdynmemStruct.BuildPosRealX]
    mov     ebx, [ecx+TAdynmemStruct.Height2]
    mov     ebp, [ecx+TAdynmemStruct.MapY]
    sar     edi, 1
    sub     eax, edi
    mov     edi, [ecx+TAdynmemStruct.unk1]
    sub     esi, edx
    sub     edi, edx
    mov     edx, [ecx+2CA6h]
    sub     eax, ebp
    sar     ebx, 1
    sub     edx, ebx
    mov     bl, [ecx+2CC3h]
    sub     edx, ebp
    add     esi, 80h
    add     eax, 20h
    add     edi, 80h
    add     edx, 20h
    cmp     bl, 0Eh
    jnz     short loc_469E87
    mov     cl, [ecx+2CC6h]
    and     cl, 40h
    neg     cl
    sbb     ecx, ecx
    and     ecx, 6
    add     ecx, 4
    mov     ebp, ecx
    jmp     short loc_469E8C
    ; ---------------------------------------------------------------------------

    loc_469E87:                             ; CODE XREF: GameUnit_LOS_Unknown1+117Ej
    mov     ebp, 0Fh

    loc_469E8C:                             ; CODE XREF: GameUnit_LOS_Unknown1+1195j
    mov     ecx, [esp+224h+var_1B0]
    xor     ebx, ebx
    cmp     edi, esi
    mov     bl, [ebp+ecx+0]
    jge     short loc_469EA0
    mov     ecx, esi
    mov     esi, edi
    mov     edi, ecx

    loc_469EA0:                             ; CODE XREF: GameUnit_LOS_Unknown1+11A8j
    cmp     edx, eax
    jge     short loc_469EAA
    mov     ecx, eax
    mov     eax, edx
    mov     edx, ecx

    loc_469EAA:                             ; CODE XREF: GameUnit_LOS_Unknown1+11B2j
    mov     [esp+224h+var_1F4], edx
    mov     [esp+224h+var_1FC], eax
    lea     edx, [esp+224h+var_200]
    push    ebx
    lea     eax, [esp+228h+var_1F0]
    push    edx
    push    eax
    mov     [esp+230h+var_200], esi
    mov     [esp+230h+var_1F8], edi
    call    sub_4BF8C0
    mov     edi, [esp+224h+var_200]
    mov     esi, [esp+224h+var_1FC]
    mov     edx, [esp+224h+var_1F8]
    mov     ecx, [esp+224h+var_1F4]
    inc     edi
    inc     esi
    dec     edx
    dec     ecx
    mov     [esp+224h+var_1F4], ecx
    mov     ecx, TAdynmemStructPtr
    mov     [esp+224h+var_200], edi
    mov     [esp+224h+var_1FC], esi
    mov     [esp+224h+var_1F8], edx
    mov     al, [ecx+2CC3h]
    cmp     al, 0Eh
    jnz     short loc_469F0B
    lea     edx, [esp+224h+var_200]
    push    ebx
    lea     eax, [esp+228h+var_1F0]
    push    edx
    push    eax
    jmp     short loc_469F1E
    ; ---------------------------------------------------------------------------

    loc_469F0B:                             ; CODE XREF: GameUnit_LOS_Unknown1+120Cj
    mov     edx, [esp+224h+var_1B0]
    xor     ecx, ecx
    lea     eax, [esp+224h+var_200]
    mov     cl, [edx]
    push    ecx
    lea     ecx, [esp+228h+var_1F0]
    push    eax
    push    ecx

    loc_469F1E:                             ; CODE XREF: GameUnit_LOS_Unknown1+1219j
    call    sub_4BF8C0
    mov     ecx, TAdynmemStructPtr
    mov     ebx, [esp+224h+arg_0]

    loc_469F30:                             ; CODE XREF: GameUnit_LOS_Unknown1+111Dj
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jz      short loc_469F56
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 2
    jnz     short loc_469F9A

    loc_469F56:                             ; CODE XREF: GameUnit_LOS_Unknown1+124Ej
    lea     eax, [esp+224h+var_1F0]
    push    eax
    call    sub_4C69C0
    lea     ecx, [esp+224h+var_1F0]
    push    ecx
    call    sub_4948E0
    mov     edx, TAdynmemStructPtr
    sub     esp, 10h
    add     edx, 37E27h
    mov     eax, esp
    mov     ecx, [edx]
    mov     [eax], ecx
    mov     ecx, [edx+4]
    mov     [eax+4], ecx
    mov     ecx, [edx+8]
    mov     [eax+8], ecx
    lea     ecx, [esp+234h+var_1F0]
    mov     edx, [edx+0Ch]
    mov     [eax+0Ch], edx
    call    sub_4C6B10

    loc_469F9A:                             ; CODE XREF: GameUnit_LOS_Unknown1+1264j
    lea     eax, [esp+224h+var_1F0]
    push    eax
    call    PlayerStatusMenu
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391C3h]
    test    ecx, ecx
    jz      short loc_469FC2
    lea     ecx, [esp+224h+var_1F0]
    push    ecx
    call    sub_468380
    mov     eax, TAdynmemStructPtr

    loc_469FC2:                             ; CODE XREF: GameUnit_LOS_Unknown1+12C1j
    test    ebx, ebx
    jz      short loc_469FD5
    lea     edx, [esp+224h+var_1F0]
    push    edx
    call    sub_464060
    mov     eax, TAdynmemStructPtr

    loc_469FD5:                             ; CODE XREF: GameUnit_LOS_Unknown1+12D4j
    test    byte ptr [eax+3923Bh], 2
    jz      loc_46A107
    test    ebx, ebx
    jz      loc_46A107
    call    sub_4C13F0
    mov     ecx, [esp+224h+var_1B0]
    push    eax
    xor     eax, eax
    mov     al, [ecx+0Fh]
    push    eax
    call    sub_4C13A0
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391F9h]
    push    eax
    call    sub_4C1420
    call    sub_4C1450
    lea     esi, [eax+eax*2-0Ah]
    call    sub_4B66A0
    push    eax
    lea     ecx, [esp+228h+var_150]
    push    offset aFrateD                  ; "FRATE: %d\n"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+224h+var_150]
    lea     eax, [esp+224h+var_1F0]
    push    0FFFFFFFFh
    push    esi
    push    83h
    push    edx
    push    eax
    call    PrintGUIText
    push    0FFFFFFFFh
    push    esi
    push    0BCh
    lea     ecx, [esp+230h+var_1F0]
    push    offset aRelease                 ; "[Release]"
    push    ecx
    call    PrintGUIText
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+3923Bh], 1
    mov     ecx, offset aOn                 ; "ON"
    jnz     short loc_46A07E
    mov     ecx, offset aOff                ; "OFF"

    loc_46A07E:                             ; CODE XREF: GameUnit_LOS_Unknown1+1387j
    mov     dl, [eax+3923Bh]
    mov     eax, offset aDebug              ; "DEBUG"
    shr     dl, 1
    test    dl, 1
    jnz     short loc_46A095
    mov     eax, offset aNormal_0           ; "NORMAL"

    loc_46A095:                             ; CODE XREF: GameUnit_LOS_Unknown1+139Ej
    push    ecx
    push    eax
    lea     eax, [esp+22Ch+var_150]
    push    offset aModeSInfoS              ; "MODE %s INFO %s"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+224h+var_150]
    lea     edx, [esp+224h+var_1F0]
    push    0FFFFFFFFh
    push    esi
    push    1EEh
    push    ecx
    push    edx
    call    PrintGUIText
    call    sub_4C1450
    add     esi, eax
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 1
    jz      short loc_46A107
    lea     eax, [esp+224h+var_150]
    push    eax
    call    sub_415FA0
    push    0FFFFFFFFh
    push    esi
    lea     ecx, [esp+22Ch+var_150]
    push    0BCh
    lea     edx, [esp+230h+var_1F0]
    push    ecx
    push    edx
    call    PrintGUIText
    mov     eax, TAdynmemStructPtr

    loc_46A107:                             ; CODE XREF: GameUnit_LOS_Unknown1+12ECj
                                            ; GameUnit_LOS_Unknown1+12F4j ...
    test    byte ptr [eax+38A51h], 1
    jz      short loc_46A140
    mov     edi, [esp+224h+var_174]
    mov     esi, [esp+224h+var_178]
    mov     eax, [eax+1481Bh]
    push    edi
    push    esi
    push    0
    push    eax
    call    sub_4B7F30
    lea     ecx, [esp+22Ch+var_1F0]
    push    eax
    push    ecx
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr
    jmp     short loc_46A14E
    ; ---------------------------------------------------------------------------

    loc_46A140:                             ; CODE XREF: GameUnit_LOS_Unknown1+141Ej
    mov     esi, [esp+224h+var_178]
    mov     edi, [esp+224h+var_174]

    loc_46A14E:                             ; CODE XREF: GameUnit_LOS_Unknown1+144Ej
    xor     edx, edx
    mov     ebp, eax
    mov     dl, [eax+2A42h]
    mov     ecx, edx
    add     ebp, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    mov     edx, [ebp+ecx*2+1B8Ah]
    test    byte ptr [edx+9Bh], 40h
    jnz     short loc_46A1D0
    mov     cl, [eax+3923Bh]
    shr     cl, 5
    test    cl, 1
    jz      short loc_46A1A2
    mov     edx, [eax+14813h]
    push    edi
    push    esi
    push    0
    push    edx
    call    sub_4B7F30
    push    eax
    lea     eax, [esp+230h+var_1F0]
    push    eax
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr

    loc_46A1A2:                             ; CODE XREF: GameUnit_LOS_Unknown1+1490j
    mov     cl, [eax+3923Bh]
    shr     cl, 6
    test    cl, 1
    jz      short loc_46A1D0
    mov     edx, [eax+14817h]
    push    edi
    push    esi
    push    0
    push    edx
    call    sub_4B7F30
    push    eax
    lea     eax, [esp+230h+var_1F0]
    push    eax
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr

    loc_46A1D0:                             ; CODE XREF: GameUnit_LOS_Unknown1+1482j
                                            ; GameUnit_LOS_Unknown1+14BEj
    mov     cl, [eax+37F2Fh]
    shr     cl, 6
    test    cl, 1
    jz      loc_46A2A8
    mov     esi, [eax+38A47h]
    mov     eax, 36B06E71h
    mul     esi
    mov     ecx, esi
    sub     ecx, edx
    shr     ecx, 1
    add     ecx, edx
    shr     ecx, 10h
    lea     eax, [ecx+ecx*2]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax*8]
    mov     eax, 91A2B3C5h
    shl     edx, 5
    sub     esi, edx
    imul    esi
    add     edx, esi
    sar     edx, 0Ah
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 88888889h
    mov     edi, edx
    imul    edx, 708h
    sub     esi, edx
    imul    esi
    add     edx, esi
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    push    edx
    push    edi
    push    ecx
    push    offset aGameTime                ; int
    call    sub_4C5740
    push    eax
    lea     ecx, [esp+234h+var_100]
    push    offset aS02d02d02d              ; "%s : %02d:%02d:%02d"
    push    ecx
    call    _sprintf
    add     esp, 18h
    call    sub_4C13F0
    push    eax
    mov     eax, [esp+228h+var_1B0]
    xor     edx, edx
    mov     dl, [eax+0Fh]
    push    edx
    call    sub_4C13A0
    push    0FFFFFFFFh
    call    sub_4C1450
    mov     esi, 0FFFFFFDEh
    sub     esi, eax
    call    sub_4B6710
    add     esi, eax
    lea     ecx, [esp+228h+var_100]
    push    esi
    push    82h
    lea     edx, [esp+230h+var_1F0]
    push    ecx
    push    edx
    call    PrintGUIText
    mov     eax, TAdynmemStructPtr

    loc_46A2A8:                             ; CODE XREF: GameUnit_LOS_Unknown1+14ECj
    mov     cl, [eax+38A51h]
    shr     cl, 1
    test    cl, 1
    jz      short loc_46A2E2
    mov     edx, [eax+37E23h]
    mov     ecx, [eax+37E1Fh]
    sub     edx, 50h
    sub     ecx, 10h
    push    edx
    mov     edx, [eax+148CFh]
    push    ecx
    push    0
    push    edx
    call    sub_4B7F30
    push    eax
    lea     eax, [esp+230h+var_1F0]
    push    eax
    call    sub_4B7F90

    loc_46A2E2:                             ; CODE XREF: GameUnit_LOS_Unknown1+15C3j
    lea     ecx, [esp+224h+var_1F0]
    push    ecx
    call    sub_4C69C0
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+224h+var_1F0]
    lea     edx, [eax+37E27h]
    add     eax, 519h
    push    edx
    push    ecx
    push    eax
    call    sub_4AB170
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+38DD5h]
    test    eax, eax
    jz      loc_46A3BD
    test    ebx, ebx
    jz      loc_46A3BD
    push    0
    lea     eax, [esp+228h+var_1F0]
    push    offset aNetwork                 ; "Network"
    push    eax
    call    sub_46B900
    push    1
    lea     ecx, [esp+228h+var_1F0]
    push    offset aUnits_0                 ; "Units"
    push    ecx
    call    sub_46B900
    push    2
    lea     edx, [esp+228h+var_1F0]
    push    offset aLogic                   ; "Logic"
    push    edx
    call    sub_46B900
    push    3
    lea     eax, [esp+228h+var_1F0]
    push    offset aRenderStatic            ; "Render Static"
    push    eax
    call    sub_46B900
    push    4
    lea     ecx, [esp+228h+var_1F0]
    push    offset aRenderStuff             ; "Render Stuff"
    push    ecx
    call    sub_46B900
    push    5
    lea     edx, [esp+228h+var_1F0]
    push    offset aRenderFog               ; "Render Fog"
    push    edx
    call    sub_46B900
    push    6
    lea     eax, [esp+228h+var_1F0]
    push    offset aSfx                     ; "SFX"
    push    eax
    call    sub_46B900
    push    7
    lea     ecx, [esp+228h+var_1F0]
    push    offset aWeapon                  ; "Weapon"
    push    ecx
    call    sub_46B900
    push    8
    lea     edx, [esp+228h+var_1F0]
    push    offset aMisc                    ; "Misc"
    push    edx
    call    sub_46B900

    loc_46A3BD:                             ; CODE XREF: GameUnit_LOS_Unknown1+1626j
                                            ; GameUnit_LOS_Unknown1+162Ej
    lea     eax, [esp+224h+var_1F0]
    push    eax
    call    sub_45FFB0
    call    sub_4C2870
    test    ebx, ebx
    jz      short loc_46A3E0
    mov     eax, [esp+224h+arg_4]
    test    eax, eax
    jz      short loc_46A3E0
    call    sub_4C63A0

    loc_46A3E0:                             ; CODE XREF: GameUnit_LOS_Unknown1+16DEj
                                            ; GameUnit_LOS_Unknown1+16E9j
    mov     ecx, TAdynmemStructPtr
    push    3
    add     ecx, 38D85h
    call    sub_46A400
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 214h
    retn    8
    GameUnit_LOS_Unknown1 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46A400 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+16FEp

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     esi, ecx
    call    GetTickCount
    mov     ecx, [esp+arg_0]
    mov     edi, [esi]
    mov     edx, eax
    sub     edx, edi
    mov     edi, [esi+ecx*4+2Ch]
    add     edi, edx
    mov     [esi+ecx*4+2Ch], edi
    mov     [esi], eax
    pop     edi
    pop     esi
    retn    4
    sub_46A400 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46A430 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+FC9p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 10h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+1Ch+arg_4]
    push    edi
    cmp     word ptr [esi+108h], 0
    jle     loc_46A526
    mov     eax, TAdynmemStructPtr
    mov     ebp, [esp+20h+arg_0]
    lea     edi, [eax+0DCBh]
    mov     eax, [esp+20h+arg_8]
    lea     ecx, [eax-11h]
    add     eax, 11h
    mov     [esp+20h+var_10], ecx
    mov     ecx, [esp+20h+arg_C]
    mov     [esp+20h+var_8], eax
    xor     eax, eax
    lea     edx, [ecx-2]
    add     ecx, 2
    mov     [esp+20h+var_C], edx
    mov     [esp+20h+var_4], ecx
    mov     al, [edi]
    lea     ecx, [esp+20h+var_10]
    push    eax
    push    ecx
    push    ebp
    call    sub_4BF6F0
    mov     ebx, [esp+20h+var_10]
    xor     edx, edx
    mov     ecx, [esp+20h+var_C]
    mov     eax, [esp+20h+var_4]
    inc     ebx
    inc     ecx
    mov     [esp+20h+var_C], ecx
    dec     eax
    movsx   ecx, word ptr [esi+108h]
    mov     esi, [esi+92h]
    mov     [esp+20h+var_4], eax
    mov     eax, ecx
    mov     [esp+20h+var_10], ebx
    shl     eax, 5
    div     dword ptr [esi+1FAh]
    add     eax, ebx
    mov     [esp+20h+var_8], eax
    mov     eax, 0AAAAAAABh
    mul     dword ptr [esi+1FAh]
    shr     edx, 1
    lea     eax, [edx+edx]
    cmp     ecx, eax
    jle     short loc_46A4F6
    xor     ecx, ecx
    lea     edx, [esp+20h+var_10]
    mov     cl, [edi+0Ah]
    push    ecx
    push    edx
    push    ebp
    call    sub_4BF6F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_46A4F6:                             ; CODE XREF: sub_46A430+A9j
    cmp     ecx, edx
    jle     short loc_46A515
    xor     eax, eax
    lea     ecx, [esp+20h+var_10]
    mov     al, [edi+0Eh]
    push    eax
    push    ecx
    push    ebp
    call    sub_4BF6F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_46A515:                             ; CODE XREF: sub_46A430+C8j
    xor     edx, edx
    lea     eax, [esp+20h+var_10]
    mov     dl, [edi+0Ch]
    push    edx
    push    eax
    push    ebp
    call    sub_4BF6F0

    loc_46A526:                             ; CODE XREF: sub_46A430+13j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    sub_46A430 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46A530 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+CFBp
                                            ; GameUnit_LOS_Unknown1+E9Ap

    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    sub     esp, 54h
    mov     cl, [eax+37F2Fh]
    shr     cl, 2
    test    cl, 1
    jz      loc_46A602
    mov     eax, [eax+14377h]
    push    edi
    push    esi
    mov     esi, [esp+5Ch+arg_4]
    lea     edx, [esp+5Ch+var_3C]
    push    0
    push    edx
    xor     edx, edx
    mov     dx, [esi+0A6h]
    lea     ecx, [esp+64h+var_54]
    push    ecx
    mov     ecx, [eax+edx*4]
    push    ecx
    call    sub_4CB650
    mov     edi, [esp+5Ch+var_3C]
    add     esi, 64h
    mov     eax, [esp+5Ch+var_50]
    mov     edx, [esp+5Ch+var_4C]
    mov     ecx, [esp+5Ch+var_54]
    mov     [esp+5Ch+var_2C], eax
    mov     [esp+5Ch+var_28], edx
    mov     [esp+5Ch+var_20], eax
    mov     [esp+5Ch+var_1C], edx
    mov     edx, [esp+5Ch+var_34]
    mov     [esp+5Ch+var_14], eax
    mov     [esp+5Ch+var_8], eax
    mov     eax, TAdynmemStructPtr
    mov     [esp+5Ch+var_30], ecx
    mov     [esp+5Ch+var_24], edi
    mov     [esp+5Ch+var_18], edi
    mov     [esp+5Ch+var_10], edx
    mov     [esp+5Ch+var_C], ecx
    mov     ecx, [esi+6]
    mov     [esp+5Ch+var_4], edx
    mov     edx, [eax+1431Fh]
    push    esi
    shl     edx, 10h
    sub     ecx, edx
    mov     edx, [esi+0Ah]
    mov     [esp+60h+var_48], ecx
    mov     ecx, [esi+0Eh]
    mov     [esp+60h+var_44], edx
    mov     eax, [eax+14323h]
    shl     eax, 10h
    sub     ecx, eax
    lea     edx, [esp+60h+var_30]
    mov     [esp+60h+var_40], ecx
    mov     ecx, [esp+60h+arg_0]
    lea     eax, [esp+60h+var_48]
    push    edx
    push    eax
    push    ecx
    call    sub_467A50
    pop     esi
    pop     edi

    loc_46A602:                             ; CODE XREF: sub_46A530+14j
    add     esp, 54h
    retn    8
    sub_46A530 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_46A610(int,int,int,int)
    sub_46A610 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+C30p
                                            ; GameUnit_LOS_Unknown1+C3Fp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     ecx, [esp+arg_4]
    push    ebx
    mov     ebx, TAdynmemStructPtr
    push    ebp
    push    esi
    xor     esi, esi
    mov     si, [ecx+8]
    push    edi
    mov     edi, [ebx+TAdynmemStruct.FeatureDef]
    shl     esi, 8
    add     esi, edi
    mov     edi, ecx
    movsx   eax, word ptr [esi+94h]
    shl     eax, 4
    cdq
    sub     eax, edx
    mov     edx, [ebx+TAdynmemStruct.MapX]
    mov     ebp, eax
    mov     eax, [esp+10h+arg_8]
    add     eax, 8
    sar     ebp, 1
    shl     eax, 4
    add     ebp, eax
    mov     eax, [ebx+TAdynmemStruct.FeatureMapSizeX]
    sub     ebp, edx
    add     edi, eax
    lea     edx, [eax+eax*2]
    lea     eax, [edi+edx*4]
    xor     edx, edx
    mov     dl, [ecx+4]
    mov     edi, edx
    xor     edx, edx
    mov     dl, [ecx+11h]
    add     edi, edx
    xor     edx, edx
    mov     dl, [eax+4]
    add     edi, edx
    xor     edx, edx
    mov     dl, [eax+11h]
    movsx   eax, word ptr [esi+96h]
    shl     eax, 4
    add     edi, edx
    cdq
    sar     edi, 3
    sub     eax, edx
    mov     edx, [esp+10h+arg_C]
    mov     [esp+10h+arg_4], edi
    mov     edi, eax
    mov     eax, [esp+10h+arg_4]
    add     edx, 2
    sar     edi, 1
    sub     edi, eax
    mov     al, [ecx+0Ch]
    shl     edx, 4
    add     edi, edx
    mov     edx, [ebx+14323h]
    sub     edi, edx
    test    al, 1
    jz      loc_46A76E
    mov     eax, TAdynmemStructPtr
    xor     ebx, ebx
    mov     bx, [ecx+0Ah]
    mov     cl, [esi+0FEh]
    mov     edx, [eax+1420Bh]
    lea     ebx, [ebx+ebx*2]
    shl     ebx, 4
    add     ebx, edx
    test    cl, 1
    jz      short loc_46A721
    mov     cl, [ebx+2Fh]
    mov     esi, [esp+10h+arg_0]
    test    cl, 4
    jz      short loc_46A708
    test    byte ptr [eax+37F06h], 10h
    jz      short loc_46A708
    lea     eax, [ebx+10h]
    push    eax
    call    sub_4B7EE0
    push    edi
    push    ebp
    push    eax
    push    esi
    call    sub_4B7F90

    loc_46A708:                             ; CODE XREF: sub_46A610+DBj
                                            ; sub_46A610+E4j
    add     ebx, 4
    push    ebx
    call    sub_4B7EE0
    push    edi
    push    ebp
    push    eax
    push    esi
    call    sub_4B7F90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_46A721:                             ; CODE XREF: sub_46A610+CFj
    mov     eax, [eax+1420Fh]
    mov     ecx, [ebx+4]
    push    eax
    mov     [eax+9Eh], ecx
    mov     [ecx+0Ch], eax
    lea     ecx, [ebx+20h]
    lea     edx, [eax+64h]
    add     ebx, 8
    mov     esi, [ecx]
    mov     [edx], esi
    mov     cx, [ecx+4]
    mov     [edx+4], cx
    mov     ecx, [ebx]
    lea     edx, [eax+6Ah]
    mov     [eax+6Ah], ecx
    mov     ecx, [ebx+4]
    mov     [edx+4], ecx
    mov     ecx, [ebx+8]
    mov     [edx+8], ecx
    mov     edx, [esp+14h+arg_0]
    push    edx
    call    sub_45AC20
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_46A76E:                             ; CODE XREF: sub_46A610+A7j
    mov     al, [esi+0FEh]
    shr     al, 1
    test    al, 1
    mov     eax, [esi+0B0h]
    jz      short loc_46A7DC
    test    eax, eax
    jz      short loc_46A7C0
    test    byte ptr [ebx+37F06h], 10h
    jz      short loc_46A7C0
    lea     ecx, [esi+0D8h]
    push    ecx
    call    sub_4B7EE0
    mov     dl, [esi+0FEh]
    push    edi
    shr     dl, 3
    test    dl, 1
    push    ebp
    push    eax
    jz      short loc_46A7B6
    mov     eax, [esp+1Ch+arg_0]
    push    eax
    call    sub_4B8500
    jmp     short loc_46A7C0
    ; ---------------------------------------------------------------------------

    loc_46A7B6:                             ; CODE XREF: sub_46A610+198j
    mov     ecx, [esp+1Ch+arg_0]
    push    ecx
    call    sub_4B7F90

    loc_46A7C0:                             ; CODE XREF: sub_46A610+172j
                                            ; sub_46A610+17Bj ...
    mov     eax, [esi+0ACh]
    test    eax, eax
    jz      loc_46A856
    lea     edx, [esi+0CCh]
    push    edx
    call    sub_4B7EE0
    jmp     short loc_46A82A
    ; ---------------------------------------------------------------------------

    loc_46A7DC:                             ; CODE XREF: sub_46A610+16Ej
    test    eax, eax
    jz      short loc_46A818
    test    byte ptr [ebx+37F06h], 10h
    jz      short loc_46A818
    push    0
    push    eax
    call    sub_4B7F30
    mov     cl, [esi+0FEh]
    push    edi
    shr     cl, 3
    test    cl, 1
    push    ebp
    push    eax
    jz      short loc_46A80E
    mov     edx, [esp+1Ch+arg_0]
    push    edx
    call    sub_4B8500
    jmp     short loc_46A818
    ; ---------------------------------------------------------------------------

    loc_46A80E:                             ; CODE XREF: sub_46A610+1F0j
    mov     eax, [esp+1Ch+arg_0]
    push    eax
    call    sub_4B7F90

    loc_46A818:                             ; CODE XREF: sub_46A610+1CEj
                                            ; sub_46A610+1D7j ...
    mov     eax, [esi+0ACh]
    test    eax, eax
    jz      short loc_46A856
    push    0
    push    eax
    call    sub_4B7F30

    loc_46A82A:                             ; CODE XREF: sub_46A610+1CAj
    mov     cl, [esi+0FEh]
    push    edi
    shr     cl, 2
    test    cl, 1
    push    ebp
    push    eax
    jz      short loc_46A84C
    mov     edx, [esp+1Ch+arg_0]
    push    edx
    call    sub_4B8500
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_46A84C:                             ; CODE XREF: sub_46A610+229j
    mov     eax, [esp+1Ch+arg_0]
    push    eax
    call    sub_4B7F90

    loc_46A856:                             ; CODE XREF: sub_46A610+1B8j
                                            ; sub_46A610+210j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_46A610 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    LOS_GUIText proc near                   ; CODE XREF: GameUnit_LOS_Unknown1+925p

    var_254= qword ptr -254h
    var_23C= dword ptr -23Ch
    var_238= dword ptr -238h
    var_234= dword ptr -234h
    var_230= dword ptr -230h
    var_22C= dword ptr -22Ch
    PlayerOrUnit= dword ptr -228h
    var_224= dword ptr -224h
    Player= dword ptr -220h
    var_21C= dword ptr -21Ch
    var_218= dword ptr -218h
    var_214= dword ptr -214h
    var_210= word ptr -210h
    var_20E= dword ptr -20Eh
    var_202= dword ptr -202h
    var_1FE= dword ptr -1FEh
    var_1FA= dword ptr -1FAh
    var_1F6= dword ptr -1F6h
    var_1F2= dword ptr -1F2h
    var_1EE= dword ptr -1EEh
    var_1E8= dword ptr -1E8h
    var_1E4= dword ptr -1E4h
    var_1DC= dword ptr -1DCh
    var_1D8= dword ptr -1D8h
    StringBuffer= byte ptr -1C8h
    var_1B8= byte ptr -1B8h
    var_C8= dword ptr -0C8h
    var_64= dword ptr -64h
    arg_0= dword ptr  4

    sub     esp, 23Ch
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     eax, [edx+37E23h]
    mov     esi, [edx+147A7h]
    sub     eax, esi
    push    edi
    mov     [esp+24Ch+var_23C], eax
    mov     ecx, 0Fh
    xor     eax, eax
    lea     edi, [esp+24Ch+var_218]
    rep stosd
    mov     ax, [edx+3923Bh]
    test    al, 1
    jz      loc_46ABA3
    test    al, 2
    jz      loc_46ABA3
    xor     ecx, ecx
    mov     edi, [esp+24Ch+arg_0]
    mov     cl, [edx+TAdynmemStruct.LOS_Sight]
    mov     ebx, 81h
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [edx+eax*2+TAdynmemStruct.Players.PlayerInfo]
    xor     eax, eax
    mov     al, [ecx+95h]
    lea     edx, ds:14833h[eax*4]
    mov     [esp+24Ch+var_23C], edx

    loc_46A8E0:                             ; CODE XREF: LOS_GUIText+C9j
    call    sub_4B6710
    mov     ecx, [esp+24Ch+var_23C]
    mov     ebp, eax
    mov     eax, TAdynmemStructPtr
    push    0
    sub     ebp, 20h
    mov     edx, [eax+ecx]
    push    edx
    call    sub_4B7F30
    mov     esi, eax
    movsx   eax, word ptr [esi+6]
    movsx   ecx, word ptr [esi+4]
    add     eax, ebp
    add     ecx, ebx
    push    eax
    push    ecx
    push    esi
    push    edi
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [esi]
    mov     ecx, [eax+37E1Fh]
    add     ebx, edx
    cmp     ebx, ecx
    jl      short loc_46A8E0
    mov     eax, [eax+391F9h]
    push    eax
    call    sub_4C1420
    call    sub_4C13F0
    push    eax
    push    53h
    call    sub_4C13A0
    call    sub_4C1450
    mov     ecx, eax
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+37E23h]
    mov     eax, [eax+0Ch]
    sub     esi, ecx
    lea     ecx, [esp+24Ch+StringBuffer]
    mov     edx, [eax+9Ch]
    mov     al, [eax+0F0h]
    and     eax, 1
    push    edx
    push    eax
    push    offset aPfstateDPfable          ; "PFSTATE %d, PFABLE %d\n"
    push    ecx
    dec     esi
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+24Ch+StringBuffer]
    push    0FFFFFFFFh
    push    esi
    push    82h
    push    edx
    push    edi
    call    PrintGUIText
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+2CBAh]
    test    ax, ax
    jz      short loc_46AA09
    and     eax, 0FFFFh
    mov     ecx, [ecx+14357h]
    mov     edx, eax
    shl     eax, 3
    sub     eax, edx
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]
    mov     eax, [eax+110h]
    mov     edx, eax
    shr     edx, 14h
    shr     eax, 12h
    and     edx, 3
    and     eax, 3
    push    edx
    push    eax
    lea     eax, [esp+254h+StringBuffer]
    push    offset aMoveordDFireor          ; "MOVEORD: %d FIREORD: %d\n"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+24Ch+StringBuffer]
    push    0FFFFFFFFh
    push    esi
    push    108h
    push    ecx
    push    edi
    call    PrintGUIText
    mov     ecx, TAdynmemStructPtr

    loc_46AA09:                             ; CODE XREF: LOS_GUIText+148j
    mov     edx, [ecx+38A3Bh]
    lea     eax, [esp+24Ch+StringBuffer]
    push    edx
    push    offset aDeltatimeD              ; "DELTATIME: %d\n"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+24Ch+StringBuffer]
    push    0FFFFFFFFh
    push    esi
    push    190h
    push    ecx
    push    edi
    call    PrintGUIText
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+24Ch+StringBuffer]
    mov     eax, [edx+TAdynmemStruct.GameTime]
    push    eax
    push    offset aGametimeD               ; "GAMETIME: %d\n"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+24Ch+StringBuffer]
    push    0FFFFFFFFh
    push    esi
    push    208h
    push    edx
    push    edi
    call    PrintGUIText
    mov     eax, TAdynmemStructPtr
    sub     esi, 10h
    mov     ecx, [eax+TAdynmemStruct.MapY]
    mov     edx, [eax+TAdynmemStruct.MapX]
    push    ecx
    push    edx
    lea     eax, [esp+254h+StringBuffer]
    push    offset aXDYD                    ; "X: %d  Y: %d\n"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+24Ch+StringBuffer]
    push    0FFFFFFFFh
    push    esi
    push    82h
    push    ecx
    push    edi
    call    PrintGUIText
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+24Ch+StringBuffer]
    mov     edx, [eax+TAdynmemStruct.NumHotUnits]
    mov     eax, [eax+TAdynmemStruct.UnitCount_Unk]
    push    edx
    push    eax
    push    offset aUnitsDD                 ; "UNITS %d\\%d\n"
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+24Ch+StringBuffer]
    push    0FFFFFFFFh
    push    esi
    push    108h
    push    edx
    push    edi
    call    PrintGUIText
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1F54h]
    mov     edx, [eax+1E09h]
    mov     eax, [eax+1CBEh]
    push    ecx
    push    edx
    push    eax
    lea     ecx, [esp+258h+StringBuffer]
    push    offset aPacketsDDD              ; "PACKETS: %d %d %d\n"
    push    ecx
    call    _sprintf
    add     esp, 14h
    lea     edx, [esp+24Ch+StringBuffer]
    push    0FFFFFFFFh
    push    esi
    push    190h
    push    edx
    push    edi
    call    PrintGUIText
    mov     ecx, TAdynmemStructPtr
    movsx   ebx, [ecx+TAdynmemStruct.BuildPosY]
    mov     eax, [ecx+TAdynmemStruct.FeatureMapSizeX]
    movsx   edx, [ecx+TAdynmemStruct.BuildPosX]
    imul    eax, ebx
    mov     ecx, [ecx+TAdynmemStruct.Features]
    add     eax, edx
    lea     ebp, [eax+eax*2]
    lea     ebp, [eax+ebp*4]
    xor     eax, eax
    mov     al, [ebp+ecx+4]
    push    eax
    push    ebx
    push    edx
    lea     edx, [esp+258h+StringBuffer]
    push    offset aXyhDDD                  ; "XYH: %d %d %d\n"
    push    edx
    call    _sprintf
    add     esp, 14h
    lea     eax, [esp+24Ch+StringBuffer]
    push    0FFFFFFFFh
    push    esi
    push    208h
    push    eax
    push    edi
    call    PrintGUIText
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 23Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46ABA3:                             ; CODE XREF: LOS_GUIText+38j
                                            ; LOS_GUIText+40j
    mov     ecx, [edx+581h]
    mov     ax, [edx+TAdynmemStruct.MouseOverUnit]
    mov     [esp+24Ch+var_1EE+2], ecx
    mov     cx, [edx+2CBCh]
    mov     word ptr [esp+24Ch+var_1EE], cx
    mov     ecx, [edx+37E94h]
    mov     [esp+24Ch+var_1E4], ecx
    mov     ecx, [edx+37E90h]
    test    ax, ax
    mov     word ptr [esp+24Ch+var_214], ax
    mov     [esp+24Ch+var_1E8], ecx
    jz      loc_46ACC8
    mov     ecx, [esp+24Ch+var_214]
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    mov     dx, [ecx+eax*8+108h]
    lea     esi, [ecx+eax*8]
    push    esi
    mov     word ptr [esp+250h+var_214+2], dx
    mov     ax, [esi+0B8h]
    mov     [esp+250h+var_210], ax
    call    sub_439DF0
    fld     dword ptr [esi+0D0h]
    fstp    [esp+24Ch+var_202]
    fld     dword ptr [esi+0CCh]
    fstp    [esp+24Ch+var_1FE]
    fld     dword ptr [esi+0E8h]
    fstp    [esp+24Ch+var_1FA]
    fld     dword ptr [esi+0E4h]
    mov     [esp+24Ch+var_218], eax
    lea     ecx, [esi+1Fh]
    fstp    [esp+24Ch+var_1F6]
    lea     eax, [esp+24Ch+var_20E]
    mov     edx, 3
    mov     edi, 1Eh

    loc_46AC5B:                             ; CODE XREF: LOS_GUIText+423j
    mov     ebx, [ecx-0Fh]
    cmp     [ebx+0E4h], di
    jbe     short loc_46AC76
    test    byte ptr [ecx], 2
    jz      short loc_46AC76
    xor     ebx, ebx
    mov     bx, [ecx-7]
    mov     [eax], ebx
    jmp     short loc_46AC7C
    ; ---------------------------------------------------------------------------

    loc_46AC76:                             ; CODE XREF: LOS_GUIText+405j
                                            ; LOS_GUIText+40Aj
    mov     dword ptr [eax], 0FFFFFFFFh

    loc_46AC7C:                             ; CODE XREF: LOS_GUIText+414j
    add     eax, 4
    add     ecx, 1Ch
    dec     edx
    jnz     short loc_46AC5B
    mov     edx, TAdynmemStructPtr
    mov     cl, [esi+UnitStruct.OwnerIndex]
    mov     word ptr [esp+24Ch+var_1F2], 0
    cmp     cl, [edx+TAdynmemStruct.LOS_Sight]
    jnz     short loc_46ACC8
    push    esi
    call    sub_439DD0
    test    eax, eax
    jz      short loc_46ACC2
    mov     dx, [eax+0A8h]
    mov     ax, [eax+108h]
    mov     word ptr [esp+24Ch+var_1F2], dx
    mov     word ptr [esp+24Ch+var_1F2+2], ax

    loc_46ACC2:                             ; CODE XREF: LOS_GUIText+448j
    mov     edx, TAdynmemStructPtr

    loc_46ACC8:                             ; CODE XREF: LOS_GUIText+37Cj
                                            ; LOS_GUIText+43Ej
    lea     eax, [edx+37E60h]
    mov     ecx, 3Ch
    lea     edi, [esp+24Ch+var_218]
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      loc_46B8EA
    mov     ecx, 0Fh
    lea     esi, [esp+24Ch+var_218]
    mov     edi, eax
    rep movsd
    mov     eax, TAdynmemStructPtr
    add     eax, 0DCBh
    mov     [esp+24Ch+var_224], eax
    call    sub_4C13F0
    push    eax
    push    53h
    call    sub_4C13A0
    mov     ebp, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [ebp+TAdynmemStruct.LOS_Sight]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, ebp
    add     eax, ecx
    mov     ecx, [eax+edx*2+TAdynmemStruct.Players.PlayerInfo]
    lea     eax, [eax+edx*2+TAdynmemStruct.Players]
    xor     edx, edx
    mov     dl, [ecx+95h]
    mov     [esp+24Ch+PlayerOrUnit], eax
    mov     ecx, edx
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    mov     edx, [ebp+ecx*2+3816Bh]
    lea     ebp, [ebp+ecx*2+37F3Dh]
    push    edx
    call    sub_4C1420
    mov     ebx, 81h

    loc_46AD69:                             ; CODE XREF: LOS_GUIText+569j
    call    sub_4B6710
    mov     edi, eax
    mov     eax, [esp+24Ch+PlayerOrUnit]
    xor     edx, edx
    push    0
    mov     ecx, [eax+PlayerStruct.PlayerInfo]
    mov     eax, TAdynmemStructPtr
    sub     edi, 20h
    mov     dl, [ecx+95h]
    mov     ecx, [eax+edx*4+14833h]
    push    ecx
    call    sub_4B7F30
    mov     esi, eax
    mov     ecx, [esp+24Ch+arg_0]
    movsx   edx, word ptr [esi+6]
    movsx   eax, word ptr [esi+4]
    add     edx, edi
    add     eax, ebx
    push    edx
    push    eax
    push    esi
    push    ecx
    call    sub_4B7F90
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [esi]
    mov     eax, [ecx+37E1Fh]
    add     ebx, edx
    cmp     ebx, eax
    jl      short loc_46AD69
    mov     eax, [esp+24Ch+var_1EE+2]
    cmp     eax, 0FFFFFFFFh
    jz      NotInGameMenus
    lea     edx, [eax+eax*4]
    mov     ecx, [ecx+531h]
    push    10h                             ; size_t
    lea     edx, [eax+edx*4]
    lea     edx, [eax+edx*2]
    lea     edx, [eax+edx*4]
    lea     eax, [eax+edx*2]
    mov     edx, [ecx+4]
    lea     ecx, [esp+250h+StringBuffer]
    lea     eax, [eax+edx+2]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    lea     edx, [esp+24Ch+StringBuffer]
    mov     [esp+24Ch+var_1B8], 0
    push    edx                             ; char *
    call    sub_488B10
    test    ax, ax
    jz      loc_46B8EA
    and     eax, 0FFFFh
    push    offset aCorbuild                ; char *
    mov     ecx, eax
    shl     eax, 6
    add     eax, ecx
    lea     esi, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1439Bh]
    add     esi, ecx
    lea     ecx, [esp+250h+StringBuffer]
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_46B8EA
    fld     dword ptr [esi+186h]
    call    __ftol
    fld     dword ptr [esi+18Ah]
    push    eax
    call    __ftol
    push    eax
    push    esi
    lea     edx, [esp+258h+StringBuffer]
    push    offset aSMDED                   ; "%s  M:%d E:%d"
    push    edx
    call    _sprintf
    mov     eax, [ebp+1D6h]
    mov     ebx, [esp+260h+var_23C]
    mov     ecx, [ebp+1D2h]
    mov     edi, [esp+260h+arg_0]
    add     esp, 14h
    add     eax, ebx
    lea     edx, [esp+24Ch+StringBuffer]
    push    0FFFFFFFFh
    push    eax
    push    ecx
    push    edx
    push    edi
    call    PrintGUIText
    mov     eax, [ebp+1E6h]
    mov     ecx, [ebp+1E2h]
    add     eax, ebx
    push    0FFFFFFFFh
    push    eax
    add     esi, 40h
    push    ecx
    push    esi
    push    edi
    call    PrintGUIText
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 23Ch
    retn    4
    ; ---------------------------------------------------------------------------

    NotInGameMenus:                         ; CODE XREF: LOS_GUIText+572j
    cmp     word ptr [esp+24Ch+var_214], 0
    jz      loc_46B78C
    mov     edx, [esp+24Ch+var_214]
    and     edx, 0FFFFh
    mov     eax, edx
    shl     eax, 3
    sub     eax, edx
    lea     edx, [eax+eax*4]
    mov     eax, [ecx+14357h]
    cmp     word ptr [eax+edx*8+0A6h], 0
    lea     edi, [eax+edx*8]
    mov     [esp+24Ch+PlayerOrUnit], edi
    jz      loc_46B8EA
    xor     edx, edx
    push    edi                             ; Unit
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*2+TAdynmemStruct.Players]
    push    eax                             ; Player
    mov     [esp+254h+Player], eax
    call    PlayerCanSeeUnit
    test    eax, eax
    jz      loc_46B6F3
    mov     ecx, [edi+UnitStruct.UnitType]
    mov     edx, TAdynmemStructPtr
    mov     eax, [ecx+245h]
    mov     ecx, [edx+TAdynmemStruct.MapFile]
    mov     esi, eax
    and     eax, 20000h
    shr     esi, 1
    and     esi, 20000h
    or      esi, eax
    shr     esi, 11h
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_46AF96
    test    esi, esi
    jz      short loc_46AF96
    mov     edi, [edi+96h]
    lea     edx, [esp+24Ch+StringBuffer]
    add     edi, 2Bh
    jmp     short loc_46AFA3
    ; ---------------------------------------------------------------------------

    loc_46AF96:                             ; CODE XREF: LOS_GUIText+71Ej
                                            ; LOS_GUIText+722j
    mov     edi, [edi+92h]
    lea     edx, [esp+24Ch+StringBuffer]

    loc_46AFA3:                             ; CODE XREF: LOS_GUIText+734j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edx, [ebp+22Eh]
    lea     ecx, [esp+24Ch+StringBuffer]
    push    ecx
    push    edx
    call    sub_4C1480
    mov     esi, [ebp+142h]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     esi, eax
    call    sub_4C13F0
    push    eax
    push    53h
    call    sub_4C13A0
    mov     eax, [ebp+146h]
    push    0FFFFFFFFh
    mov     ebx, [esp+250h+var_23C]
    mov     edi, [esp+250h+arg_0]
    add     eax, ebx
    lea     ecx, [esp+250h+StringBuffer]
    push    eax
    push    esi
    push    ecx
    push    edi
    call    PrintGUIText
    mov     ecx, TAdynmemStructPtr
    mov     esi, [esp+24Ch+PlayerOrUnit]
    mov     edx, [esi+96h]
    mov     al, [edx+146h]
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    cmp     al, dl
    jz      short loc_46B048
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    test    ah, 40h
    jnz     loc_46B0F9

    loc_46B048:                             ; CODE XREF: LOS_GUIText+7D1j
    mov     eax, [esp+24Ch+PlayerOrUnit]
    lea     esi, [ebp+152h]
    mov     ecx, [eax+UnitStruct.UnitType]
    mov     edx, [ecx+1FAh]
    mov     [esp+24Ch+var_23C], edx
    movsx   edx, word ptr [eax+PlayerStruct.field_108]
    mov     eax, esi
    mov     ecx, [eax]
    mov     [esp+24Ch+var_238], ecx
    mov     ecx, [eax+4]
    mov     [esp+24Ch+var_234], ecx
    mov     ecx, [eax+8]
    mov     [esp+24Ch+var_230], ecx
    mov     ecx, [esp+24Ch+var_234]
    mov     eax, [eax+0Ch]
    add     ecx, ebx
    add     eax, ebx
    mov     [esp+24Ch+var_234], ecx
    test    edx, edx
    mov     [esp+24Ch+var_22C], eax
    jge     short loc_46B098
    xor     edx, edx

    loc_46B098:                             ; CODE XREF: LOS_GUIText+834j
    mov     ecx, [esp+24Ch+var_23C]
    cmp     edx, ecx
    jle     short loc_46B0A2
    mov     edx, ecx

    loc_46B0A2:                             ; CODE XREF: LOS_GUIText+83Ej
    mov     eax, [esi+8]
    sub     eax, [esi]
    imul    eax, edx
    cdq
    idiv    ecx
    mov     edx, [esp+24Ch+var_238]
    lea     ecx, [esp+24Ch+var_238]
    add     eax, edx
    xor     edx, edx
    mov     [esp+24Ch+var_230], eax
    mov     eax, [esp+24Ch+var_224]
    mov     dl, [eax+0Ah]
    push    edx
    push    ecx
    push    edi
    call    sub_4BF6F0
    mov     esi, [esi+8]
    mov     eax, [esp+24Ch+var_230]
    cmp     eax, esi
    jz      short loc_46B0F5
    inc     eax
    xor     edx, edx
    mov     [esp+24Ch+var_238], eax
    mov     eax, [esp+24Ch+var_224]
    lea     ecx, [esp+24Ch+var_238]
    mov     [esp+24Ch+var_230], esi
    mov     dl, [eax+4]
    push    edx
    push    ecx
    push    edi
    call    sub_4BF6F0

    loc_46B0F5:                             ; CODE XREF: LOS_GUIText+875j
    mov     esi, [esp+24Ch+PlayerOrUnit]

    loc_46B0F9:                             ; CODE XREF: LOS_GUIText+7E2j
    mov     eax, [esi+96h]
    lea     edx, [ebp+132h]
    push    ebx
    push    edx
    push    eax
    push    edi
    call    sub_467C00
    mov     eax, TAdynmemStructPtr
    mov     cl, [esi+UnitStruct.OwnerIndex]
    cmp     cl, [eax+TAdynmemStruct.LOS_Sight]
    jz      short loc_46B12E
    test    byte ptr [eax+3923Bh], 2
    jz      loc_46B445

    loc_46B12E:                             ; CODE XREF: LOS_GUIText+8BFj
    call    sub_4C13F0
    push    eax
    mov     eax, [esp+250h+var_224]
    xor     edx, edx
    mov     dl, [eax+0Ah]
    push    edx
    call    sub_4C13A0
    fld     [esp+24Ch+var_1F6]
    fcomp   ds:flt_4FD568
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_46B15A
    fld     [esp+24Ch+var_1F6]
    jmp     short loc_46B160
    ; ---------------------------------------------------------------------------

    loc_46B15A:                             ; CODE XREF: LOS_GUIText+8F2j
    fld     ds:flt_4FD568

    loc_46B160:                             ; CODE XREF: LOS_GUIText+8F8j
    sub     esp, 8
    lea     ecx, [esp+254h+var_C8]
    fstp    [esp+254h+var_254]
    push    offset a_1f_0                   ; "+%.1f"
    push    ecx
    call    _sprintf
    mov     edx, [ebp+186h]
    mov     eax, [ebp+182h]
    add     esp, 10h
    add     edx, ebx
    lea     ecx, [esp+24Ch+var_C8]
    push    0FFFFFFFFh
    push    edx
    push    eax
    push    ecx
    push    edi
    call    PrintGUIText
    fld     [esp+24Ch+var_1FE]
    fcomp   ds:flt_4FD568
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_46B1B2
    fld     [esp+24Ch+var_1FE]
    jmp     short loc_46B1B8
    ; ---------------------------------------------------------------------------

    loc_46B1B2:                             ; CODE XREF: LOS_GUIText+94Aj
    fld     ds:flt_4FD568

    loc_46B1B8:                             ; CODE XREF: LOS_GUIText+950j
    sub     esp, 8
    lea     edx, [esp+254h+var_C8]
    fstp    [esp+254h+var_254]
    push    offset a_0f                     ; "+%.0f"
    push    edx
    call    _sprintf
    mov     eax, [ebp+166h]
    mov     ecx, [ebp+162h]
    add     esp, 10h
    add     eax, ebx
    lea     edx, [esp+24Ch+var_C8]
    push    0FFFFFFFFh
    push    eax
    push    ecx
    push    edx
    push    edi
    call    PrintGUIText
    call    sub_4C13F0
    mov     ecx, [esp+24Ch+var_224]
    push    eax
    xor     eax, eax
    mov     al, [ecx+0Ch]
    push    eax
    call    sub_4C13A0
    fld     [esp+24Ch+var_1FA]
    fcomp   ds:flt_4FD568
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_46B21F
    fld     [esp+24Ch+var_1FA]
    jmp     short loc_46B225
    ; ---------------------------------------------------------------------------

    loc_46B21F:                             ; CODE XREF: LOS_GUIText+9B7j
    fld     ds:flt_4FD568

    loc_46B225:                             ; CODE XREF: LOS_GUIText+9BDj
    sub     esp, 8
    lea     edx, [esp+254h+var_C8]
    fstp    [esp+254h+var_254]
    push    offset a_1f_1                   ; "-%.1f"
    push    edx
    call    _sprintf
    mov     eax, [ebp+196h]
    mov     ecx, [ebp+192h]
    add     esp, 10h
    add     eax, ebx
    lea     edx, [esp+24Ch+var_C8]
    push    0FFFFFFFFh
    push    eax
    push    ecx
    push    edx
    push    edi
    call    PrintGUIText
    fld     [esp+24Ch+var_202]
    fcomp   ds:flt_4FD568
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_46B277
    fld     [esp+24Ch+var_202]
    jmp     short loc_46B27D
    ; ---------------------------------------------------------------------------

    loc_46B277:                             ; CODE XREF: LOS_GUIText+A0Fj
    fld     ds:flt_4FD568

    loc_46B27D:                             ; CODE XREF: LOS_GUIText+A15j
    sub     esp, 8
    lea     eax, [esp+254h+var_C8]
    fstp    [esp+254h+var_254]
    push    offset a_0f_0                   ; "-%.0f"
    push    eax
    call    _sprintf
    mov     ecx, [ebp+176h]
    mov     edx, [ebp+172h]
    add     esp, 10h
    add     ecx, ebx
    lea     eax, [esp+24Ch+var_C8]
    push    0FFFFFFFFh
    push    ecx
    push    edx
    push    eax
    push    edi
    call    PrintGUIText
    test    dword ptr [esi+UnitStruct.UnitSelected], 80000000h
    jz      loc_46B3B3
    cmp     [esi+UnitStruct.Kills], 0
    jz      loc_46B3B3
    mov     ecx, [ebp+15Eh]
    mov     eax, [ebp+152h]
    push    offset aKills_0                 ; int
    mov     [esp+250h+var_21C], eax
    lea     edx, [ecx+ebx+2]
    mov     [esp+250h+var_1DC], edx
    call    sub_4C5740
    push    offset aKill                    ; int
    mov     [esp+250h+var_23C], eax
    call    sub_4C5740
    mov     cx, [esi+0B8h]
    cmp     cx, 4
    jbe     short loc_46B358
    cmp     cx, 1
    jnz     short loc_46B31F
    mov     [esp+24Ch+var_23C], eax
    jmp     short loc_46B327
    ; ---------------------------------------------------------------------------

    loc_46B31F:                             ; CODE XREF: LOS_GUIText+AB7j
    mov     ecx, [esp+24Ch+var_23C]
    mov     [esp+24Ch+var_23C], ecx

    loc_46B327:                             ; CODE XREF: LOS_GUIText+ABDj
    push    offset aVeteran                 ; int
    call    sub_4C5740
    push    eax
    xor     eax, eax
    mov     edx, [esp+250h+var_23C]
    mov     ax, [esi+0B8h]
    push    edx
    push    eax
    lea     ecx, [esp+258h+var_64]
    push    offset aDSS                     ; "%d %s - %s"
    push    ecx
    call    _sprintf
    add     esp, 14h
    jmp     short loc_46B37F
    ; ---------------------------------------------------------------------------

    loc_46B358:                             ; CODE XREF: LOS_GUIText+AB1j
    cmp     cx, 1
    jz      short loc_46B362
    mov     eax, [esp+24Ch+var_23C]

    loc_46B362:                             ; CODE XREF: LOS_GUIText+AFCj
    and     ecx, 0FFFFh
    push    eax
    push    ecx
    lea     edx, [esp+254h+var_64]
    push    offset aDS                      ; "%d %s"
    push    edx
    call    _sprintf
    add     esp, 10h

    loc_46B37F:                             ; CODE XREF: LOS_GUIText+AF6j
    call    sub_4C13F0
    mov     ecx, TAdynmemStructPtr
    push    eax
    xor     eax, eax
    mov     al, [ecx+0DDAh]
    push    eax
    call    sub_4C13A0
    push    0FFFFFFFFh
    lea     ecx, [esp+250h+var_64]
    mov     edx, [esp+250h+var_1DC]
    mov     eax, [esp+250h+var_21C]
    push    edx
    push    eax
    push    ecx
    push    edi
    call    PrintGUIText

    loc_46B3B3:                             ; CODE XREF: LOS_GUIText+A62j
                                            ; LOS_GUIText+A70j
    mov     eax, [esp+24Ch+var_218]
    test    eax, eax
    jz      loc_46B445
    push    eax                             ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+24Ch+var_C8]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, [ebp+22Eh]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+24Ch+var_C8]
    push    ecx
    push    edx
    call    sub_4C1480
    mov     esi, [ebp+1A2h]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     esi, eax
    call    sub_4C13F0
    push    eax
    push    53h
    call    sub_4C13A0
    mov     eax, [ebp+1A6h]
    push    0FFFFFFFFh
    mov     edx, [esp+250h+arg_0]
    add     eax, ebx
    push    eax
    lea     ecx, [esp+254h+var_C8]
    push    esi
    push    ecx
    push    edx
    call    PrintGUIText
    mov     edi, [esp+24Ch+arg_0]
    mov     esi, [esp+24Ch+PlayerOrUnit]

    loc_46B445:                             ; CODE XREF: LOS_GUIText+8C8j
                                            ; LOS_GUIText+B59j
    push    esi
    call    sub_439D20
    test    eax, eax
    mov     [esp+24Ch+var_23C], eax
    jz      loc_46B571
    mov     eax, [esi+UnitStruct.Owner]
    mov     edx, TAdynmemStructPtr
    mov     cl, [eax+PlayerStruct.PlayerNumber]
    mov     al, [edx+TAdynmemStruct.LOS_Sight]
    cmp     cl, al
    jnz     loc_46B8EA
    push    offset aWeapon                  ; int
    call    sub_4C5740
    push    eax
    mov     [esp+250h+var_21C], eax
    mov     eax, [ebp+22Eh]
    push    eax
    call    sub_4C1480
    mov     esi, [ebp+1B2h]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     esi, eax
    call    sub_4C13F0
    push    eax
    push    53h
    call    sub_4C13A0
    mov     ecx, [ebp+1B6h]
    push    0FFFFFFFFh
    mov     edx, [esp+250h+var_21C]
    add     ecx, ebx
    push    ecx
    push    esi
    push    edx
    push    edi
    call    PrintGUIText
    add     ebp, 1C2h
    mov     edx, ebp
    mov     eax, [esp+24Ch+var_23C]
    mov     ecx, [edx]
    mov     [esp+24Ch+var_238], ecx
    mov     ecx, [edx+4]
    add     ecx, ebx
    mov     esi, [edx+8]
    mov     [esp+24Ch+var_234], ecx
    mov     ecx, eax
    mov     [esp+24Ch+var_230], esi
    mov     edx, [edx+0Ch]
    add     edx, ebx
    test    ecx, ecx
    mov     [esp+24Ch+var_22C], edx
    jge     short loc_46B4F6
    xor     eax, eax

    loc_46B4F6:                             ; CODE XREF: LOS_GUIText+C92j
    cmp     eax, 64h
    jle     short loc_46B500
    mov     eax, 64h

    loc_46B500:                             ; CODE XREF: LOS_GUIText+C99j
    mov     ecx, [ebp+8]
    mov     edx, [ebp+0]
    sub     ecx, edx
    mov     esi, [esp+24Ch+var_224]
    imul    ecx, eax
    mov     eax, 51EB851Fh
    imul    ecx
    mov     ecx, [esp+24Ch+var_238]
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    add     edx, ecx
    xor     ecx, ecx
    mov     cl, [esi+0Ah]
    mov     [esp+24Ch+var_230], edx
    lea     edx, [esp+24Ch+var_238]
    push    ecx
    push    edx
    push    edi
    call    sub_4BF6F0
    mov     ebp, [ebp+8]
    mov     eax, [esp+24Ch+var_230]
    cmp     eax, ebp
    jz      loc_46B8EA
    inc     eax
    lea     ecx, [esp+24Ch+var_238]
    mov     [esp+24Ch+var_238], eax
    xor     eax, eax
    mov     al, [esi+4]
    mov     [esp+24Ch+var_230], ebp
    push    eax
    push    ecx
    push    edi
    call    sub_4BF6F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 23Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46B571:                             ; CODE XREF: LOS_GUIText+BF1j
    cmp     word ptr [esp+24Ch+var_1F2], 0
    jz      loc_46B8EA
    mov     ecx, [esp+24Ch+var_1F2]
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14357h]
    cmp     word ptr [ecx+edx*8+0A6h], 0
    lea     esi, [ecx+edx*8]
    jz      loc_46B8EA
    mov     edx, [esp+24Ch+Player]
    push    esi                             ; Unit
    push    edx                             ; Player
    call    PlayerCanSeeUnit
    test    eax, eax
    jz      loc_46B8EA
    mov     eax, [esi+92h]
    mov     ecx, [ebp+22Eh]
    push    eax
    push    ecx
    call    sub_4C1480
    cdq
    sub     eax, edx
    mov     edx, eax
    mov     eax, [ebp+1B2h]
    sar     edx, 1
    sub     eax, edx
    mov     [esp+24Ch+Player], eax
    call    sub_4C13F0
    push    eax
    push    53h
    call    sub_4C13A0
    mov     eax, [ebp+1B6h]
    mov     edx, [esi+UnitStruct.UnitType]
    mov     ecx, [esp+24Ch+Player]
    add     eax, ebx
    push    0FFFFFFFFh
    push    eax
    push    ecx
    push    edx
    push    edi
    call    PrintGUIText
    mov     eax, [esi+UnitStruct.Owner]
    mov     edx, TAdynmemStructPtr
    mov     cl, [eax+PlayerStruct.PlayerNumber]
    mov     al, [edx+TAdynmemStruct.LOS_Sight]
    cmp     cl, al
    jz      short loc_46B642
    mov     eax, [esi+92h]
    mov     ecx, [eax+241h]
    test    ch, 40h
    jnz     loc_46B8EA

    loc_46B642:                             ; CODE XREF: LOS_GUIText+DCBj
    mov     ecx, [esi+92h]
    add     ebp, 1C2h
    movsx   edx, word ptr [esi+108h]
    mov     eax, ebp
    mov     ecx, [ecx+1FAh]
    mov     esi, [eax]
    mov     [esp+24Ch+var_238], esi
    mov     esi, [eax+4]
    mov     [esp+24Ch+var_234], esi
    mov     esi, [eax+8]
    mov     [esp+24Ch+var_230], esi
    mov     esi, [esp+24Ch+var_234]
    mov     eax, [eax+0Ch]
    add     esi, ebx
    add     eax, ebx
    mov     [esp+24Ch+var_234], esi
    test    edx, edx
    mov     [esp+24Ch+var_22C], eax
    jge     short loc_46B68A
    xor     edx, edx

    loc_46B68A:                             ; CODE XREF: LOS_GUIText+E26j
    cmp     edx, ecx
    jle     short loc_46B690
    mov     edx, ecx

    loc_46B690:                             ; CODE XREF: LOS_GUIText+E2Cj
    mov     eax, [ebp+8]
    mov     esi, [ebp+0]
    sub     eax, esi
    mov     esi, [esp+24Ch+var_224]
    imul    eax, edx
    cdq
    idiv    ecx
    mov     ecx, [esp+24Ch+var_238]
    lea     edx, [esp+24Ch+var_238]
    add     eax, ecx
    xor     ecx, ecx
    mov     cl, [esi+0Ah]
    mov     [esp+24Ch+var_230], eax
    push    ecx
    push    edx
    push    edi
    call    sub_4BF6F0
    mov     ebp, [ebp+8]
    mov     eax, [esp+24Ch+var_230]
    cmp     eax, ebp
    jz      loc_46B8EA
    inc     eax
    lea     ecx, [esp+24Ch+var_238]
    mov     [esp+24Ch+var_238], eax
    xor     eax, eax
    mov     al, [esi+4]
    mov     [esp+24Ch+var_230], ebp
    push    eax
    push    ecx
    push    edi
    call    sub_4BF6F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 23Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46B6F3:                             ; CODE XREF: LOS_GUIText+6E4j
    mov     edx, [edi+110h]
    mov     esi, offset aS_4                ; "S: "
    shr     edx, 9
    test    dl, 1
    jnz     short loc_46B70B
    mov     esi, offset aR                  ; "R: "

    loc_46B70B:                             ; CODE XREF: LOS_GUIText+EA4j
    push    offset aUnidentifiedOb          ; int
    call    sub_4C5740
    push    eax
    push    esi
    lea     eax, [esp+254h+StringBuffer]
    push    offset aSS_2                    ; "%s%s"
    push    eax
    call    _sprintf
    mov     edx, [ebp+22Eh]
    add     esp, 10h
    lea     ecx, [esp+24Ch+StringBuffer]
    push    ecx
    push    edx
    call    sub_4C1480
    mov     esi, [ebp+142h]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     esi, eax
    call    sub_4C13F0
    push    eax
    push    53h
    call    sub_4C13A0
    mov     eax, [ebp+146h]
    mov     ebp, [esp+24Ch+var_23C]
    mov     edx, [esp+24Ch+arg_0]
    add     eax, ebp
    push    0FFFFFFFFh
    push    eax
    lea     ecx, [esp+254h+StringBuffer]
    push    esi
    push    ecx
    push    edx
    call    PrintGUIText
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 23Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46B78C:                             ; CODE XREF: LOS_GUIText+686j
    cmp     word ptr [esp+24Ch+var_1EE], 0FFFFh
    jz      loc_46B8EA
    mov     esi, [esp+24Ch+var_1EE]
    mov     edx, [ecx+1426Fh]
    and     esi, 0FFFFh
    shl     esi, 8
    add     esi, edx
    test    byte ptr [esi+0FFh], 4
    jz      short loc_46B7C4
    test    byte ptr [ecx+3923Bh], 2
    jz      loc_46B8EA

    loc_46B7C4:                             ; CODE XREF: LOS_GUIText+F55j
    fld     dword ptr [esi+0F0h]
    fcomp   ds:flt_4FD568
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_46B7FD
    fld     dword ptr [esi+0F0h]
    call    __ftol
    push    eax
    lea     eax, [esp+250h+var_1D8]
    push    offset aMD                      ; " M:%d"
    push    eax
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    jmp     short loc_46B802
    ; ---------------------------------------------------------------------------

    loc_46B7FD:                             ; CODE XREF: LOS_GUIText+F75j
    mov     byte ptr [esp+24Ch+var_1D8], 0

    loc_46B802:                             ; CODE XREF: LOS_GUIText+F9Bj
    fld     dword ptr [esi+0ECh]
    fcomp   ds:flt_4FD568
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_46B83B
    fld     dword ptr [esi+0ECh]
    call    __ftol
    push    eax
    lea     ecx, [esp+250h+var_238]
    push    offset aED                      ; " E:%d"
    push    ecx
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    jmp     short loc_46B840
    ; ---------------------------------------------------------------------------

    loc_46B83B:                             ; CODE XREF: LOS_GUIText+FB3j
    mov     byte ptr [esp+24Ch+var_238], 0

    loc_46B840:                             ; CODE XREF: LOS_GUIText+FD9j
    mov     dl, [ecx+3923Bh]
    mov     eax, esi
    shr     dl, 1
    test    dl, 1
    jnz     short loc_46B855
    lea     eax, [esi+80h]

    loc_46B855:                             ; CODE XREF: LOS_GUIText+FEDj
    test    byte ptr [esi+0FFh], 2
    jnz     short loc_46B886
    lea     ecx, [esp+24Ch+var_238]
    lea     edx, [esp+24Ch+var_1D8]
    push    ecx
    push    edx
    push    eax                             ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esp+258h+StringBuffer]
    push    offset aSSS_0                   ; "%s %s%s"
    push    eax
    call    _sprintf
    add     esp, 14h
    jmp     short loc_46B8B2
    ; ---------------------------------------------------------------------------

    loc_46B886:                             ; CODE XREF: LOS_GUIText+FFCj
    push    eax                             ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+24Ch+StringBuffer]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_46B8B2:                             ; CODE XREF: LOS_GUIText+1024j
    call    sub_4C13F0
    push    eax
    push    53h
    call    sub_4C13A0
    mov     ecx, [ebp+1D6h]
    mov     edx, [ebp+1D2h]
    mov     ebx, [esp+24Ch+var_23C]
    push    0FFFFFFFFh
    add     ecx, ebx
    lea     eax, [esp+250h+StringBuffer]
    push    ecx
    mov     ecx, [esp+254h+arg_0]
    push    edx
    push    eax
    push    ecx
    call    PrintGUIText

    loc_46B8EA:                             ; CODE XREF: LOS_GUIText+47Dj
                                            ; LOS_GUIText+5BFj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 23Ch
    retn    4
    LOS_GUIText endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46B900 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+1640p
                                            ; GameUnit_LOS_Unknown1+1651p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 10h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     esi, [eax+37E1Fh]
    push    edi
    sub     esi, 5Ah
    call    sub_4C1450
    mov     ebx, [esp+20h+arg_0]
    mov     edi, eax
    lea     eax, [esp+20h+var_10]
    push    0FFh
    lea     ecx, [esi-0C8h]
    lea     edx, [edi+edi*8+29h]
    push    eax
    push    ebx
    mov     [esp+2Ch+var_10], ecx
    mov     [esp+2Ch+var_8], 27Fh
    mov     [esp+2Ch+var_C], 26h
    mov     [esp+2Ch+var_4], edx
    call    sub_4BF8C0
    mov     ecx, edi
    push    0FFFFFFFFh
    mov     ebp, [esp+24h+arg_8]
    lea     edx, [esi+5]
    imul    ecx, ebp
    lea     eax, [ecx+28h]
    mov     [esp+24h+arg_0], eax
    push    eax
    mov     eax, [esp+28h+arg_4]
    push    edx
    push    eax
    push    ebx
    call    PrintGUIText
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+ebp*4+38D8Dh]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 2
    cdq
    idiv    dword ptr [ecx+38D89h]
    mov     ecx, esi
    lea     edx, [esp+20h+var_10]
    mov     [esp+20h+var_8], esi
    shl     eax, 1
    sub     ecx, eax
    mov     eax, [esp+20h+arg_0]
    mov     [esp+20h+var_C], eax
    add     eax, edi
    inc     ebp
    mov     [esp+20h+var_10], ecx
    push    ebp
    push    edx
    push    ebx
    mov     [esp+2Ch+var_4], eax
    call    sub_4BF6F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    sub_46B900 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46B9D0 proc near                    ; CODE XREF: sub_417E00+1Dp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= word ptr  0Ch
    arg_A= word ptr  0Eh
    arg_C= dword ptr  10h

    sub     esp, 10h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    mov     esi, [esp+18h+arg_4]
    push    edi
    push    esi
    lea     ebx, [eax+0DCBh]
    call    sub_485010
    movsx   ecx, word ptr [esi+2]
    mov     edi, TAdynmemStructPtr
    shl     ecx, 4
    sub     ecx, [edi+14323h]
    movsx   edx, word ptr [esi]
    mov     esi, [edi+1431Fh]
    add     edx, 8
    shl     edx, 4
    sar     eax, 1
    mov     edi, [esp+1Ch+arg_C]
    sub     edx, esi
    movsx   esi, [esp+1Ch+arg_A]
    sub     ecx, eax
    mov     [esp+1Ch+var_10], edx
    movsx   eax, [esp+1Ch+arg_8]
    add     ecx, 20h
    shl     eax, 4
    shl     esi, 4
    add     eax, edx
    add     esi, ecx
    cmp     edi, 4
    mov     [esp+1Ch+var_C], ecx
    mov     [esp+1Ch+var_8], eax
    mov     [esp+1Ch+var_4], esi
    jnz     short loc_46BA57
    inc     edx
    inc     ecx
    dec     eax
    dec     esi
    mov     [esp+1Ch+var_10], edx
    mov     [esp+1Ch+var_C], ecx
    mov     [esp+1Ch+var_8], eax
    mov     [esp+1Ch+var_4], esi

    loc_46BA57:                             ; CODE XREF: sub_46B9D0+71j
    mov     eax, [esp+1Ch+arg_0]
    xor     ecx, ecx
    mov     cl, [ebx+edi]
    lea     edx, [esp+1Ch+var_10]
    push    ecx
    push    edx
    push    eax
    call    sub_4BF8C0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10h
    retn    10h
    sub_46B9D0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+0Ch]
    mov     eax, [esp+8]
    push    ebx
    mov     ebx, [esp+8]
    push    ebp
    lea     ebp, [ecx-1]
    push    esi
    push    edi
    mov     edi, [esp+20h]
    mov     esi, eax
    test    ebp, ebp
    jle     short loc_46BABD

    loc_46BA9D:                             ; CODE XREF: .text:0046BAB7j
    mov     edx, [esi+0Ch]
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    edi
    push    edx
    mov     edx, [esi]
    push    eax
    push    ecx
    push    edx
    push    ebx
    call    sub_4BE950
    add     esi, 8
    dec     ebp
    jnz     short loc_46BA9D
    mov     eax, [esp+18h]

    loc_46BABD:                             ; CODE XREF: .text:0046BA9Bj
    mov     ecx, [esi+4]
    mov     edx, [esi]
    push    edi
    push    ecx
    mov     ecx, [eax+4]
    push    edx
    mov     edx, [eax]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BE950
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46BAE0 proc near                    ; CODE XREF: sub_420B00+168p
                                            ; sub_49BE60+2C7p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    push    ecx
    mov     eax, [esp+4+arg_8]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+24h]
    push    edi
    mov     [esp+14h+var_4], ecx
    mov     ecx, TAdynmemStructPtr
    xor     ebp, ebp
    mov     esi, [ecx+14383h]
    mov     edi, [ecx+14387h]
    mov     ecx, [eax+4]
    test    ecx, ecx
    jle     short loc_46BB76
    mov     ebx, [esp+14h+arg_4]

    loc_46BB0F:                             ; CODE XREF: sub_46BAE0+94j
    mov     edx, [esp+14h+arg_C]
    mov     eax, [esp+14h+var_4]
    push    edx
    push    esi
    push    eax
    call    sub_4B6CC0
    mov     ecx, [esi+4]
    mov     eax, [ebx+4]
    mov     edx, [ebx+8]
    add     ecx, eax
    mov     eax, [esi+8]
    add     esi, 0Ch
    sub     edx, eax
    add     edi, 8
    sar     edx, 10h
    sar     ecx, 10h
    movsx   eax, dx
    mov     edx, [esi-0Ch]
    add     edx, [ebx]
    movsx   ecx, cx
    sar     ecx, 1
    sar     edx, 10h
    sub     eax, ecx
    mov     ecx, [esp+14h+var_4]
    movsx   edx, dx
    add     eax, 20h
    add     edx, 80h
    mov     [edi-4], eax
    mov     eax, [esp+14h+arg_8]
    add     ecx, 0Ch
    mov     [edi-8], edx
    mov     [esp+14h+var_4], ecx
    mov     ecx, [eax+4]
    inc     ebp
    cmp     ebp, ecx
    jl      short loc_46BB0F

    loc_46BB76:                             ; CODE XREF: sub_46BAE0+29j
    mov     ecx, [eax+0Ch]
    mov     esi, [eax+28h]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_46BB8B
    add     esi, 20h
    mov     edi, 1
    jmp     short loc_46BB8D
    ; ---------------------------------------------------------------------------

    loc_46BB8B:                             ; CODE XREF: sub_46BAE0+9Fj
    xor     edi, edi

    loc_46BB8D:                             ; CODE XREF: sub_46BAE0+A9j
    mov     ecx, [eax+8]
    mov     [esp+14h+arg_4], edi
    cmp     edi, ecx
    jge     loc_46BC54
    mov     ebx, [esp+14h+arg_0]

    loc_46BBA0:                             ; CODE XREF: sub_46BAE0+16Ej
    mov     ecx, TAdynmemStructPtr
    mov     ebp, [esi+4]
    mov     edx, [esi+0Ch]
    mov     eax, [ecx+1438Bh]
    xor     ecx, ecx
    test    ebp, ebp
    jle     short loc_46BBEC

    loc_46BBB8:                             ; CODE XREF: sub_46BAE0+102j
    mov     ebx, TAdynmemStructPtr
    xor     edi, edi
    mov     di, [edx]
    inc     ecx
    mov     ebx, [ebx+14387h]
    add     edx, 2
    add     eax, 8
    mov     ebp, [ebx+edi*8]
    mov     [eax-8], ebp
    mov     edi, [ebx+edi*8+4]
    mov     [eax-4], edi
    mov     edi, [esi+4]
    cmp     ecx, edi
    jl      short loc_46BBB8
    mov     ebx, [esp+14h+arg_0]
    mov     edi, [esp+14h+arg_4]

    loc_46BBEC:                             ; CODE XREF: sub_46BAE0+D6j
    mov     eax, [esi+1Ch]
    test    al, 1
    jnz     short loc_46BC25
    cmp     dword ptr [esi+4], 4
    jnz     short loc_46BC3F
    shr     eax, 1
    test    al, 1
    jz      short loc_46BC0A
    lea     edx, [esi+10h]
    push    edx
    call    sub_4B7EE0
    jmp     short loc_46BC0D
    ; ---------------------------------------------------------------------------

    loc_46BC0A:                             ; CODE XREF: sub_46BAE0+11Dj
    mov     eax, [esi+10h]

    loc_46BC0D:                             ; CODE XREF: sub_46BAE0+128j
    mov     ecx, TAdynmemStructPtr
    push    0
    mov     edx, [ecx+1438Bh]
    push    edx
    push    eax
    push    ebx
    call    sub_4C7580
    jmp     short loc_46BC3F
    ; ---------------------------------------------------------------------------

    loc_46BC25:                             ; CODE XREF: sub_46BAE0+111j
    mov     eax, [esi]
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esi+4]
    push    eax
    mov     eax, [edx+1438Bh]
    push    ecx
    push    eax
    push    ebx
    call    sub_4C0310

    loc_46BC3F:                             ; CODE XREF: sub_46BAE0+117j
                                            ; sub_46BAE0+143j
    mov     ecx, [esp+14h+arg_8]
    inc     edi
    add     esi, 20h
    mov     [esp+14h+arg_4], edi
    cmp     edi, [ecx+8]
    jl      loc_46BBA0

    loc_46BC54:                             ; CODE XREF: sub_46BAE0+B6j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    sub_46BAE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46BC60 proc near                    ; DATA XREF: LoadReporter+B1o
                                            ; LoadReporter+200o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax
    call    RIWrapper_Report
    retn    4
    sub_46BC60 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46BC70 proc near                    ; DATA XREF: LoadReporter+ACo
                                            ; LoadReporter+1FBo

    arg_0= dword ptr  4
    arg_4= word ptr  8

    mov     ecx, dword ptr [esp+arg_4]
    mov     eax, 1
    test    ecx, ecx
    jnz     short loc_46BCA0
    mov     eax, [esp+arg_0]
    push    0Ah                             ; char
    push    ecx                             ; __int16
    push    10h                             ; char
    push    eax                             ; char *
    call    sub_463CA0
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2BEEh], 1
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46BCA0:                             ; CODE XREF: sub_46BC70+Bj
    cmp     ecx, 1
    jnz     short locret_46BCD9
    call    sub_4B6700
    mov     dword ptr [esp+arg_4], eax
    push    1
    fild    dword ptr [esp+4+arg_4]
    push    1
    fmul    ds:dbl_4FD578
    call    __ftol
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+8+arg_0]
    push    eax
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4ABD90

    locret_46BCD9:                          ; CODE XREF: sub_46BC70+33j
    retn    8
    sub_46BC70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46BCE0 proc near                    ; CODE XREF: LoadReporter+93p

    var_40= byte ptr -40h

    sub     esp, 40h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    28h
    push    offset aPlayersarray            ; "PlayersArray"
    call    sub_4D83B0
    add     esp, 8
    mov     dword_51E574, eax
    push    28h
    push    offset aScoreboardsarr          ; "ScoreBoardsArray"
    call    sub_4D83B0
    add     esp, 8
    mov     dword_51E57C, eax
    push    28h
    push    offset aScoresarray             ; "ScoresArray"
    call    sub_4D83B0
    mov     edi, dword_51E574
    add     esp, 8
    test    edi, edi
    mov     dword_51E550, eax
    jz      loc_46BEEC
    mov     ecx, dword_51E57C
    test    ecx, ecx
    jz      loc_46BEEC
    test    eax, eax
    jz      loc_46BEEC
    mov     ecx, 0Ah
    xor     eax, eax
    rep stosd
    mov     edi, dword_51E57C
    mov     ebx, ds:wsprintfA
    mov     ecx, 0Ah
    xor     ebp, ebp
    rep stosd
    mov     edi, dword_51E550
    mov     ecx, 0Ah
    rep stosd
    xor     esi, esi

    loc_46BD74:                             ; CODE XREF: sub_46BCE0+1F4j
    cmp     esi, 0Ah
    jge     loc_46BEDE
    push    esi
    lea     eax, [esp+54h+var_40]
    push    offset aPlayerinfoD             ; LPCSTR
    push    eax                             ; LPSTR
    call    ebx ; wsprintfA
    add     esp, 0Ch
    lea     ecx, [esp+50h+var_40]
    push    18h
    push    ecx
    call    sub_4D83B0
    mov     edx, dword_51E574
    add     esp, 8
    mov     [edx+esi*4], eax
    mov     eax, dword_51E574
    cmp     dword ptr [eax+esi*4], 0
    jz      loc_46BED9
    push    esi
    lea     ecx, [esp+54h+var_40]
    push    offset aAlliesD                 ; LPCSTR
    push    ecx                             ; LPSTR
    call    ebx ; wsprintfA
    add     esp, 0Ch
    lea     edx, [esp+50h+var_40]
    push    28h
    push    edx
    call    sub_4D83B0
    mov     ecx, dword_51E574
    add     esp, 8
    mov     edx, [ecx+esi*4]
    mov     [edx+14h], eax
    mov     eax, dword_51E574
    mov     ecx, [eax+esi*4]
    mov     eax, [ecx+14h]
    test    eax, eax
    jz      loc_46BED9
    push    esi
    lea     edx, [esp+54h+var_40]
    push    offset aScoreboardD             ; LPCSTR
    push    edx                             ; LPSTR
    call    ebx ; wsprintfA
    add     esp, 0Ch
    lea     eax, [esp+50h+var_40]
    push    0Ch
    push    eax
    call    sub_4D83B0
    mov     ecx, dword_51E57C
    add     esp, 8
    mov     [ecx+esi*4], eax
    mov     edx, dword_51E57C
    cmp     dword ptr [edx+esi*4], 0
    jz      loc_46BED9
    push    esi
    lea     eax, [esp+54h+var_40]
    push    offset aPpscoresD               ; LPCSTR
    push    eax                             ; LPSTR
    call    ebx ; wsprintfA
    add     esp, 0Ch
    lea     ecx, [esp+50h+var_40]
    push    24h
    push    ecx
    call    sub_4D83B0
    mov     edx, dword_51E57C
    add     esp, 8
    mov     ecx, [edx+esi*4]
    mov     [ecx+8], eax
    mov     edx, dword_51E57C
    mov     eax, [edx+esi*4]
    mov     edi, [eax+8]
    test    edi, edi
    jz      short loc_46BED9
    mov     ecx, 9
    xor     eax, eax
    rep stosd
    push    esi
    lea     ecx, [esp+54h+var_40]
    push    offset aScoresD                 ; LPCSTR
    push    ecx                             ; LPSTR
    call    ebx ; wsprintfA
    add     esp, 0Ch
    lea     edx, [esp+50h+var_40]
    push    48h
    push    edx
    call    sub_4D83B0
    mov     ecx, dword_51E550
    add     esp, 8
    mov     [ecx+esi*4], eax
    mov     edx, dword_51E550
    mov     edi, [edx+esi*4]
    test    edi, edi
    jz      short loc_46BED9
    mov     ecx, 12h
    xor     eax, eax
    rep stosd
    mov     eax, dword_51E57C
    mov     ecx, [eax+esi*4]
    xor     eax, eax
    mov     ecx, [ecx+8]

    loc_46BEB9:                             ; CODE XREF: sub_46BCE0+1F1j
    cmp     eax, 48h
    jge     short loc_46BED3
    mov     edx, dword_51E550
    mov     edx, [edx+esi*4]
    add     edx, eax
    add     eax, 8
    mov     [ecx], edx
    add     ecx, 4
    jmp     short loc_46BEB9
    ; ---------------------------------------------------------------------------

    loc_46BED3:                             ; CODE XREF: sub_46BCE0+1DCj
    inc     esi
    jmp     loc_46BD74
    ; ---------------------------------------------------------------------------

    loc_46BED9:                             ; CODE XREF: sub_46BCE0+CEj
                                            ; sub_46BCE0+10Cj ...
    mov     ebp, 1

    loc_46BEDE:                             ; CODE XREF: sub_46BCE0+97j
    test    ebp, ebp
    jnz     short loc_46BEEC
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn
    ; ---------------------------------------------------------------------------

    loc_46BEEC:                             ; CODE XREF: sub_46BCE0+4Bj
                                            ; sub_46BCE0+59j ...
    call    UnloadReporter
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 40h
    retn
    sub_46BCE0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    RIWrapper_Enable proc near              ; CODE XREF: sub_443480+B7p

    arg_0= dword ptr  4

    mov     eax, _RIEnable
    test    eax, eax
    jz      short loc_46BF13
    mov     ecx, [esp+arg_0]
    push    ecx
    call    eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46BF13:                             ; CODE XREF: RIWrapper_Enable+7j
    mov     eax, 1
    retn    4
    RIWrapper_Enable endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    IsReporterDLLLoaded proc near           ; CODE XREF: .text:00450DF3p
                                            ; sub_452370+45p
    mov     ecx, ReporterDLLHandle
    xor     eax, eax
    test    ecx, ecx
    setnz   al
    retn
    IsReporterDLLLoaded endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall LoadReporter(int)
    LoadReporter proc near                  ; CODE XREF: sub_4436E0+38p

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    call    UnloadReporter
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+4E5h]
    test    eax, eax
    jz      short loc_46BF6C
    add     eax, 10h
    add     ecx, 39201h
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     edx, [eax+8]
    mov     [ecx+8], edx
    mov     eax, [eax+0Ch]
    mov     [ecx+0Ch], eax
    mov     ecx, TAdynmemStructPtr

    loc_46BF6C:                             ; CODE XREF: LoadReporter+15j
    mov     al, byte_512C98
    test    al, al
    jnz     short loc_46BFC3
    lea     eax, [ecx+39201h]
    mov     ecx, 10h
    mov     edi, offset dword_4FCD98
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      loc_46C179
    mov     ecx, 10h
    mov     edi, offset dword_4FCDB8
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      loc_46C179
    mov     esi, eax
    mov     ecx, 10h
    mov     edi, offset dword_4FCDC8
    xor     eax, eax
    repe cmpsb
    jnz     short loc_46BFC3
    mov     eax, 4
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46BFC3:                             ; CODE XREF: LoadReporter+43j
                                            ; LoadReporter+87j
    call    sub_46BCE0
    cmp     eax, 2
    jnz     short loc_46BFDC
    call    UnloadReporter
    mov     eax, 2
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46BFDC:                             ; CODE XREF: LoadReporter+9Bj
    push    offset sub_46BC70
    push    offset sub_46BC60
    mov     ReporterInterfaceStarted, 1
    call    sub_4CAA20
    mov     eax, ReporterDLLHandle
    test    eax, eax
    jnz     loc_46C183
    push    offset aReporter_dll            ; lpLibFileName
    call    ds:LoadLibraryA
    test    eax, eax
    mov     ReporterDLLHandle, eax
    jz      loc_46C15D
    mov     esi, ds:GetProcAddress
    push    offset a_rienable@4             ; lpProcName
    push    eax                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     _RIEnable, eax
    jz      loc_46C13D
    mov     ecx, ReporterDLLHandle
    push    offset a_rigetversion@          ; lpProcName
    push    ecx                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     _RIGetVersion, eax
    jz      loc_46C13D
    mov     edx, ReporterDLLHandle
    push    offset a_riinitializee          ; lpProcName
    push    edx                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     _RIInitializeEx, eax
    jz      loc_46C13D
    mov     eax, ReporterDLLHandle
    push    offset a_rireport@40            ; lpProcName
    push    eax                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     _RIReport, eax
    jz      loc_46C13D
    mov     ecx, ReporterDLLHandle
    push    offset a_rireportgamec          ; lpProcName
    push    ecx                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     _RIReportGameChat, eax
    jz      loc_46C13D
    mov     edx, ReporterDLLHandle
    push    offset a_risetcallback          ; lpProcName
    push    edx                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     _RISetCallbacks, eax
    jz      loc_46C13D
    mov     eax, ReporterDLLHandle
    push    offset a_riintervaltim          ; lpProcName
    push    eax                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     _RIIntervalTimer, eax
    jz      short loc_46C13D
    mov     ecx, ReporterDLLHandle
    push    offset a_riterminate@0          ; lpProcName
    push    ecx                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     _RITerminate, eax
    jz      short loc_46C13D
    push    offset aTotalAnnihilat          ; "Total Annihilation"
    call    _RIGetVersion
    test    eax, eax
    jnz     short loc_46C10C
    mov     eax, [esp+4+arg_0]
    mov     ecx, [esp+0Ch]
    push    eax
    push    ecx
    call    _RIInitializeEx
    cmp     eax, 4
    jnz     short loc_46C12B

    loc_46C10C:                             ; CODE XREF: LoadReporter+1C5j
    call    _RITerminate
    mov     edx, ReporterDLLHandle
    push    edx                             ; hLibModule
    call    ds:FreeLibrary
    mov     ReporterDLLHandle, 0
    jmp     short loc_46C167
    ; ---------------------------------------------------------------------------

    loc_46C12B:                             ; CODE XREF: LoadReporter+1DAj
    push    offset sub_46BC70
    push    offset sub_46BC60
    call    _RISetCallbacks
    jmp     short loc_46C167
    ; ---------------------------------------------------------------------------

    loc_46C13D:                             ; CODE XREF: LoadReporter+FFj
                                            ; LoadReporter+11Aj ...
    mov     eax, ReporterDLLHandle
    push    eax                             ; hLibModule
    call    ds:FreeLibrary
    mov     ReporterDLLHandle, 0
    mov     eax, 2
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46C15D:                             ; CODE XREF: LoadReporter+E4j
    mov     ecx, [esp+arg_0]
    mov     dword ptr [ecx], 0

    loc_46C167:                             ; CODE XREF: LoadReporter+1F9j
                                            ; LoadReporter+20Bj
    mov     eax, ReporterDLLHandle
    test    eax, eax
    jnz     short loc_46C183
    mov     eax, ReporterInterfaceStarted
    test    eax, eax
    jnz     short loc_46C183

    loc_46C179:                             ; CODE XREF: LoadReporter+5Bj
                                            ; LoadReporter+71j
    mov     eax, 4
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46C183:                             ; CODE XREF: LoadReporter+CCj
                                            ; LoadReporter+23Ej ...
    pop     edi
    xor     eax, eax
    pop     esi
    retn    8
    LoadReporter endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl UnloadReporter()
    UnloadReporter proc near                ; CODE XREF: sub_450E20+62p
                                            ; sub_451B60+4Dp ...
    push    esi
    push    edi
    xor     edi, edi
    push    edi
    push    edi
    mov     ReporterInterfaceStarted, edi
    call    sub_4CAA20
    cmp     ReporterDLLHandle, edi
    jz      short loc_46C1D5
    mov     eax, TAdynmemStructPtr
    add     eax, 14h
    push    eax
    call    sub_4C9B70
    mov     eax, _RITerminate
    cmp     eax, edi
    jz      short loc_46C1C2
    call    eax

    loc_46C1C2:                             ; CODE XREF: UnloadReporter+2Ej
    mov     ecx, ReporterDLLHandle
    push    ecx                             ; hLibModule
    call    ds:FreeLibrary
    mov     ReporterDLLHandle, edi

    loc_46C1D5:                             ; CODE XREF: UnloadReporter+17j
    xor     esi, esi

    loc_46C1D7:                             ; CODE XREF: UnloadReporter+B6j
    mov     eax, dword_51E574
    cmp     eax, edi
    jz      short loc_46C201
    mov     edx, [eax+esi]
    mov     eax, [edx+14h]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, dword_51E574
    add     esp, 4
    mov     edx, [ecx+esi]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_46C201:                             ; CODE XREF: UnloadReporter+4Ej
    mov     eax, dword_51E57C
    cmp     eax, edi
    jz      short loc_46C22B
    mov     eax, [eax+esi]
    mov     ecx, [eax+8]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, dword_51E57C
    add     esp, 4
    mov     eax, [edx+esi]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_46C22B:                             ; CODE XREF: UnloadReporter+78j
    mov     eax, dword_51E550
    cmp     eax, edi
    jz      short loc_46C240
    mov     ecx, [eax+esi]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_46C240:                             ; CODE XREF: UnloadReporter+A2j
    add     esi, 4
    cmp     esi, 28h
    jl      short loc_46C1D7
    mov     eax, dword_51E574
    cmp     eax, edi
    jz      short loc_46C260
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E574, edi

    loc_46C260:                             ; CODE XREF: UnloadReporter+BFj
    mov     eax, dword_51E57C
    cmp     eax, edi
    jz      short loc_46C278
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E57C, edi

    loc_46C278:                             ; CODE XREF: UnloadReporter+D7j
    mov     eax, dword_51E550
    cmp     eax, edi
    jz      short loc_46C290
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E550, edi

    loc_46C290:                             ; CODE XREF: UnloadReporter+EFj
    pop     edi
    pop     esi
    retn
    UnloadReporter endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_46C2A0 proc near                    ; CODE XREF: RIWrapper_Report+D7p
                                            ; RIWrapper_ReportGameChat+1Cp

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= qword ptr -8

    push    ebp
    mov     ebp, esp
    and     esp, 0FFFFFFF8h
    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     ebx, ebx
    xor     edi, edi
    mov     [esp+28h+var_14], ebx
    mov     [esp+28h+var_18], edi
    mov     [esp+28h+var_10], ebx
    mov     edx, 2

    loc_46C2C2:                             ; CODE XREF: sub_46C2A0+360j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+ebx+TAdynmemStruct.Players.PlayerActive]
    lea     esi, [eax+ebx+TAdynmemStruct.Players]
    test    ecx, ecx
    jz      short loc_46C2F1
    mov     al, [esi+PlayerStruct.PlayerType]
    cmp     al, Player_LocalHuman
    jz      short loc_46C2E8
    cmp     al, dl
    jz      short loc_46C2E8
    cmp     al, Player_RemoteHuman
    jnz     short loc_46C2F1

    loc_46C2E8:                             ; CODE XREF: sub_46C2A0+3Ej
                                            ; sub_46C2A0+42j
    cmp     [esi+PlayerStruct.PlayerNumber], 0Ah
    jnz     short loc_46C303

    loc_46C2F1:                             ; CODE XREF: sub_46C2A0+37j
                                            ; sub_46C2A0+46j
    mov     eax, [esi+140h]
    test    eax, eax
    jnz     short loc_46C303
    test    ecx, ecx
    jz      loc_46C5EB

    loc_46C303:                             ; CODE XREF: sub_46C2A0+4Fj
                                            ; sub_46C2A0+59j
    mov     ebx, [esp+28h+var_14]
    mov     eax, dword_51E574
    inc     ebx
    lea     ecx, [esi+2Bh]
    mov     eax, [eax+edi*4]
    mov     [esp+28h+var_14], ebx
    lea     ebx, ds:0[edi*4]
    mov     [eax], ecx
    mov     ecx, dword_51E574
    mov     eax, [ecx+ebx]
    mov     ecx, [esi+4]
    mov     [eax+4], ecx
    mov     eax, dword_51E574
    mov     ecx, [eax+ebx]
    mov     dword ptr [ecx+8], 1
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_46C36C
    mov     cl, [esi+73h]
    cmp     cl, dl
    jz      short loc_46C360
    test    eax, eax
    jz      short loc_46C36C
    mov     al, cl
    cmp     al, 3
    jnz     short loc_46C36C
    mov     eax, [esi+27h]
    cmp     [eax+94h], dl
    jnz     short loc_46C36C

    loc_46C360:                             ; CODE XREF: sub_46C2A0+A9j
    mov     ecx, dword_51E574
    mov     eax, [ecx+ebx]
    or      [eax+8], edx

    loc_46C36C:                             ; CODE XREF: sub_46C2A0+A2j
                                            ; sub_46C2A0+ADj ...
    cmp     dword ptr [esi], 0
    jz      short loc_46C3A7
    mov     edx, [esi+27h]
    test    byte ptr [edx+9Bh], 40h
    jz      short loc_46C389
    mov     eax, dword_51E574
    mov     eax, [eax+ebx]
    or      dword ptr [eax+8], 4

    loc_46C389:                             ; CODE XREF: sub_46C2A0+DBj
    cmp     dword ptr [esi], 0
    jz      short loc_46C3A7
    mov     ecx, [esi+27h]
    test    byte ptr [ecx+97h], 1
    jz      short loc_46C3A7
    mov     edx, dword_51E574
    mov     eax, [edx+ebx]
    or      dword ptr [eax+8], 8

    loc_46C3A7:                             ; CODE XREF: sub_46C2A0+CFj
                                            ; sub_46C2A0+ECj ...
    mov     eax, [esi+27h]
    mov     edx, dword_51E574
    xor     ecx, ecx
    mov     cl, [eax+95h]
    mov     eax, [edx+ebx]
    xor     edx, edx
    mov     ecx, dword_507948[ecx*4]
    mov     [eax+0Ch], ecx
    mov     edi, dword_51E574
    mov     eax, [edi+ebx]
    mov     ebp, [eax+14h]
    xor     eax, eax
    mov     ecx, ebp

    loc_46C3D7:                             ; CODE XREF: sub_46C2A0+15Aj
    cmp     eax, [esp+28h+var_18]
    jz      short loc_46C3F6
    cmp     byte ptr [esi+eax+108h], 0
    jz      short loc_46C3F6
    mov     edi, [edi+eax*4]
    inc     edx
    mov     [ecx], edi
    mov     edi, dword_51E574
    add     ecx, 4

    loc_46C3F6:                             ; CODE XREF: sub_46C2A0+13Bj
                                            ; sub_46C2A0+145j
    inc     eax
    cmp     eax, 0Ah
    jl      short loc_46C3D7
    mov     ecx, [edi+ebx]
    cmp     edx, 0Ah
    mov     [ecx+10h], edx
    jge     short loc_46C416
    mov     ecx, 0Ah
    lea     edi, [ebp+edx*4+0]
    sub     ecx, edx
    xor     eax, eax
    rep stosd

    loc_46C416:                             ; CODE XREF: sub_46C2A0+165j
    mov     ecx, TAdynmemStructPtr
    mov     eax, 88888889h
    mov     dword ptr [esp+28h+var_8+4], 0
    mul     [ecx+TAdynmemStruct.GameTime]
    mov     edi, [ecx+TAdynmemStruct.MapFile]
    shr     edx, 5
    mov     dword ptr [esp+28h+var_8], edx
    fild    [esp+28h+var_8]
    fmul    dword ptr [edi+0D58h]
    call    __ftol
    movsx   edx, word ptr [esi+0FCh]
    mov     [esp+28h+var_C], edx
    mov     ebp, eax
    fild    [esp+28h+var_C]
    fmul    dword ptr [edi+0D54h]
    call    __ftol
    add     ebp, eax
    mov     eax, dword_51E57C
    mov     ecx, [eax+ebx]
    mov     [ecx], ebp
    mov     edx, dword_51E57C
    mov     eax, [edx+ebx]
    mov     dword ptr [eax+4], 9
    mov     ecx, dword_51E57C
    mov     edx, [ecx+ebx]
    mov     ecx, dword_507950
    mov     eax, [edx+8]
    mov     eax, [eax]
    mov     [eax], ecx
    movsx   edx, word ptr [esi+0FCh]
    mov     [eax+4], edx
    mov     eax, dword_51E57C
    mov     ecx, [eax+ebx]
    mov     edx, [ecx+8]
    mov     ecx, dword_507954
    mov     eax, [edx+4]
    mov     [eax], ecx
    movsx   edx, word ptr [esi+0FEh]
    mov     [eax+4], edx
    mov     eax, dword_51E57C
    mov     ecx, [eax+ebx]
    mov     eax, dword_507958
    mov     edx, [ecx+8]
    mov     edi, [edx+8]
    mov     [edi], eax
    fld     qword ptr [esi+0ACh]
    call    __ftol
    mov     [edi+4], eax
    mov     ecx, dword_51E57C
    mov     edx, [ecx+ebx]
    mov     ecx, dword_50795C
    mov     eax, [edx+8]
    mov     edi, [eax+0Ch]
    mov     [edi], ecx
    fld     qword ptr [esi+0B4h]
    call    __ftol
    mov     [edi+4], eax
    mov     edx, dword_51E57C
    mov     eax, [edx+ebx]
    mov     edx, dword_507960
    mov     ecx, [eax+8]
    mov     edi, [ecx+10h]
    mov     [edi], edx
    fld     qword ptr [esi+0CCh]
    call    __ftol
    mov     [edi+4], eax
    mov     eax, dword_51E57C
    mov     ecx, [eax+ebx]
    mov     eax, dword_507964
    mov     edx, [ecx+8]
    mov     edi, [edx+14h]
    mov     [edi], eax
    fld     qword ptr [esi+0D4h]
    call    __ftol
    mov     [edi+4], eax
    mov     ecx, dword_51E57C
    mov     edx, [ecx+ebx]
    mov     ecx, dword_507968
    mov     eax, [edx+8]
    mov     eax, [eax+18h]
    mov     [eax], ecx
    movsx   edx, word ptr [esi+104h]
    mov     [eax+4], edx
    mov     eax, dword_51E57C
    mov     edi, [esp+28h+var_18]
    mov     ecx, [eax+ebx]
    mov     edx, [ecx+8]
    mov     ecx, dword_50796C
    mov     eax, [edx+1Ch]
    mov     [eax], ecx
    movsx   edx, word ptr [esi+106h]
    mov     [eax+4], edx
    mov     eax, dword_51E57C
    mov     ecx, [eax+ebx]
    mov     edx, [ecx+8]
    mov     ecx, dword_507970
    mov     eax, [edx+20h]
    xor     edx, edx
    mov     [eax], ecx
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+2A42h]
    cmp     edi, edx
    jz      short loc_46C5D3
    cmp     dword ptr [esi], 0
    mov     edx, 2
    jz      short loc_46C5CF
    cmp     [esi+73h], dl
    jz      short loc_46C5D8

    loc_46C5CF:                             ; CODE XREF: sub_46C2A0+328j
    xor     ecx, ecx
    jmp     short loc_46C5E4
    ; ---------------------------------------------------------------------------

    loc_46C5D3:                             ; CODE XREF: sub_46C2A0+31Ej
    mov     edx, 2

    loc_46C5D8:                             ; CODE XREF: sub_46C2A0+32Dj
    mov     cl, [ecx+3923Bh]
    shr     ecx, 4
    and     ecx, 1

    loc_46C5E4:                             ; CODE XREF: sub_46C2A0+331j
    mov     ebx, [esp+28h+var_10]
    mov     [eax+4], ecx

    loc_46C5EB:                             ; CODE XREF: sub_46C2A0+5Dj
    add     ebx, 14Bh
    inc     edi
    cmp     ebx, 0CEEh
    mov     [esp+28h+var_18], edi
    mov     [esp+28h+var_10], ebx
    jl      loc_46C2C2
    mov     eax, [esp+28h+var_14]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    sub_46C2A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    RIWrapper_Report proc near              ; CODE XREF: .text:0041F897p
                                            ; sub_444CB0+193p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     eax, ReporterInterfaceStarted
    sub     esp, 10h
    test    eax, eax
    push    ebp
    push    esi
    push    edi
    jnz     short loc_46C646
    mov     eax, ReporterDLLHandle
    test    eax, eax
    jnz     short loc_46C646
    mov     eax, 4
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 10h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46C646:                             ; CODE XREF: RIWrapper_Report+Dj
                                            ; RIWrapper_Report+16j
    mov     eax, dword_51E574
    test    eax, eax
    jz      loc_46C7F8
    mov     eax, dword_51E57C
    test    eax, eax
    jz      loc_46C7F8
    mov     eax, dword_51E550
    test    eax, eax
    jz      loc_46C7F8
    mov     eax, TAdynmemStructPtr
    add     eax, TAdynmemStruct.HAPINET_Object
    push    eax
    call    sub_4CA9E0
    mov     ecx, [eax]
    mov     [esp+1Ch+var_10], ecx
    mov     edx, [eax+4]
    mov     [esp+1Ch+var_C], edx
    mov     ecx, [eax+8]
    mov     [esp+1Ch+var_8], ecx
    mov     edx, [eax+0Ch]
    mov     eax, TAdynmemStructPtr
    add     eax, 14h
    mov     [esp+1Ch+var_4], edx
    push    eax
    call    sub_4CA9D0
    mov     ebp, eax
    mov     esi, [esp+1Ch+arg_0]
    cmp     esi, 1
    jnz     short loc_46C6F7
    mov     ecx, TAdynmemStructPtr
    add     ecx, 14h
    mov     edx, [ecx]
    mov     dword_51E560, edx
    mov     eax, [ecx+4]
    mov     dword_51E564, eax
    mov     edx, [ecx+8]
    mov     dword_51E568, edx
    mov     eax, [ecx+0Ch]
    mov     dword_51E56C, eax
    mov     eax, 51E56Fh
    mov     cl, [ecx+10h]
    mov     byte_51E570, cl

    loc_46C6E7:                             ; CODE XREF: RIWrapper_Report+D5j
    cmp     byte ptr [eax], 20h
    jnz     short loc_46C6F7
    mov     byte ptr [eax], 0
    dec     eax
    cmp     eax, offset dword_51E560
    ja      short loc_46C6E7

    loc_46C6F7:                             ; CODE XREF: RIWrapper_Report+8Dj
                                            ; RIWrapper_Report+CAj
    call    sub_46C2A0
    mov     edi, eax
    mov     eax, ReporterInterfaceStarted
    test    eax, eax
    jz      loc_46C79B
    cmp     esi, 1
    jz      short loc_46C71F
    cmp     esi, 6
    jz      short loc_46C71A
    cmp     esi, 7
    jnz     short loc_46C73C

    loc_46C71A:                             ; CODE XREF: RIWrapper_Report+F3j
    cmp     esi, 1
    jnz     short loc_46C726

    loc_46C71F:                             ; CODE XREF: RIWrapper_Report+EEj
    mov     eax, 1
    jmp     short loc_46C731
    ; ---------------------------------------------------------------------------

    loc_46C726:                             ; CODE XREF: RIWrapper_Report+FDj
    xor     eax, eax
    cmp     esi, 6
    setnz   al
    add     eax, 2

    loc_46C731:                             ; CODE XREF: RIWrapper_Report+104j
    push    eax
    call    sub_4CA9F0
    mov     dword_51E594, eax

    loc_46C73C:                             ; CODE XREF: RIWrapper_Report+F8j
    test    byte ptr dword_51E594, 3
    jz      short loc_46C79B
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+TAdynmemStruct.MapFile]
    call    sub_435C30
    mov     ecx, dword_51E57C
    mov     edx, dword_51E574
    push    ecx
    mov     ecx, TAdynmemStructPtr
    push    edx
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    push    edi
    push    edx
    push    eax
    push    offset dword_51E560
    add     ecx, 39201h
    push    ebp
    lea     eax, [esp+38h+var_10]
    push    ecx
    push    eax
    push    esi
    call    sub_4CAA10
    test    eax, eax
    jz      short loc_46C79B
    mov     ReporterInterfaceStarted, 0

    loc_46C79B:                             ; CODE XREF: RIWrapper_Report+E5j
                                            ; RIWrapper_Report+123j ...
    mov     eax, ReporterDLLHandle
    test    eax, eax
    jz      short loc_46C7ED
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+TAdynmemStruct.MapFile]
    call    sub_435C30
    mov     edx, dword_51E57C
    mov     ecx, dword_51E574
    push    edx
    push    ecx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    edi
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    add     ecx, 39201h
    push    edx
    push    eax
    push    offset dword_51E560
    push    ebp
    lea     eax, [esp+38h+var_10]
    push    ecx
    push    eax
    push    esi
    call    _RIReport

    loc_46C7ED:                             ; CODE XREF: RIWrapper_Report+182j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 10h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46C7F8:                             ; CODE XREF: RIWrapper_Report+2Dj
                                            ; RIWrapper_Report+3Aj ...
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebp
    add     esp, 10h
    retn    4
    RIWrapper_Report endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall RIWrapper_ReportGameChat(int)
    RIWrapper_ReportGameChat proc near      ; CODE XREF: ChatHandling_1+6Ep

    arg_0= dword ptr  4

    mov     eax, ReporterInterfaceStarted
    push    esi
    test    eax, eax
    jz      short loc_46C823
    test    byte ptr dword_51E594, 8
    jnz     short loc_46C82C

    loc_46C823:                             ; CODE XREF: RIWrapper_ReportGameChat+8j
    mov     eax, ReporterDLLHandle
    test    eax, eax
    jz      short loc_46C8A4

    loc_46C82C:                             ; CODE XREF: RIWrapper_ReportGameChat+11j
    call    sub_46C2A0
    mov     eax, ReporterInterfaceStarted
    mov     esi, [esp+4+arg_0]
    test    eax, eax
    jz      short loc_46C873
    test    byte ptr dword_51E594, 8
    jz      short loc_46C873
    mov     ecx, TAdynmemStructPtr
    mov     edx, dword_51E574
    xor     eax, eax
    push    esi
    mov     al, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, [edx+eax*4]
    push    eax
    call    sub_4CAA00
    test    eax, eax
    jz      short loc_46C873
    mov     ReporterInterfaceStarted, 0

    loc_46C873:                             ; CODE XREF: RIWrapper_ReportGameChat+2Cj
                                            ; RIWrapper_ReportGameChat+35j ...
    mov     eax, ReporterDLLHandle
    test    eax, eax
    jz      short loc_46C89E
    mov     edx, TAdynmemStructPtr
    mov     eax, dword_51E574
    xor     ecx, ecx
    push    esi
    mov     cl, [edx+TAdynmemStruct.SharedBits]
    mov     ecx, [eax+ecx*4]
    push    ecx
    call    _RIReportGameChat
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46C89E:                             ; CODE XREF: RIWrapper_ReportGameChat+6Aj
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46C8A4:                             ; CODE XREF: RIWrapper_ReportGameChat+1Aj
    mov     eax, 4
    pop     esi
    retn    4
    RIWrapper_ReportGameChat endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    RIWrapper_IntervalTimer proc near       ; CODE XREF: sub_494E70+15Cp
    mov     eax, ReporterDLLHandle
    test    eax, eax
    jz      short locret_46C8BF
    jmp     _RIIntervalTimer
    ; ---------------------------------------------------------------------------

    locret_46C8BF:                          ; CODE XREF: RIWrapper_IntervalTimer+7j
    retn
    RIWrapper_IntervalTimer endp

    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_83. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_82. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46C8E0 proc near                    ; CODE XREF: Battleroom_Unknown1+585p

    arg_0= dword ptr  4

    push    68h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_46C909
    mov     ecx, [esp+arg_0]
    push    ecx
    mov     ecx, eax
    call    sub_46D040
    mov     edx, TAdynmemStructPtr
    mov     [edx+2A30h], eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46C909:                             ; CODE XREF: sub_46C8E0+Cj
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     [edx+2A30h], eax
    retn    4
    sub_46C8E0 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    sub     esp, 14h
    push    ebp
    push    esi
    mov     esi, [eax+2A30h]
    xor     ebp, ebp
    cmp     esi, ebp
    jz      loc_46CA4B
    mov     eax, [esi+4Ch]
    push    edi
    push    ebx
    push    eax
    mov     [esp+18h], eax
    call    sub_4B4F20
    add     esp, 4
    lea     ecx, [esi+38h]
    mov     [esi+4Ch], ebp
    mov     [esi+50h], ebp
    mov     [esi+54h], ebp
    call    sub_46E610
    mov     ebx, [esi+24h]
    lea     edi, [esi+20h]
    xor     ecx, ecx
    mov     eax, [ebx]
    cmp     eax, ebx
    mov     [esp+10h], eax
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jz      short loc_46C9A9

    loc_46C979:                             ; CODE XREF: .text:0046C9A7j
    lea     edx, [esp+18h]
    push    ebp
    push    edx
    lea     ecx, [esp+18h]
    call    sub_46FAC0
    mov     eax, [eax]
    lea     ecx, [esp+1Ch]
    push    eax
    push    ecx
    mov     ecx, edi
    call    sub_46EB60
    xor     edx, edx
    cmp     [esp+10h], ebx
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     short loc_46C979

    loc_46C9A9:                             ; CODE XREF: .text:0046C977j
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     [edi+4], ebp
    mov     [edi+8], ebp
    mov     ebx, [esi+18h]
    mov     edi, [esi+14h]
    add     esp, 4
    cmp     edi, ebx
    jz      short loc_46C9D3

    loc_46C9C5:                             ; CODE XREF: .text:0046C9D1j
    mov     ecx, edi
    call    sub_46DED0
    add     edi, 5Ch
    cmp     edi, ebx
    jnz     short loc_46C9C5

    loc_46C9D3:                             ; CODE XREF: .text:0046C9C3j
    mov     ecx, [esi+14h]
    push    ecx
    call    sub_4B4F20
    mov     [esi+14h], ebp
    mov     [esi+18h], ebp
    mov     [esi+1Ch], ebp
    mov     eax, [esi+4]
    add     esp, 4
    lea     edx, [esp+20h]
    mov     ecx, [eax]
    push    eax
    push    ecx
    push    edx
    mov     ecx, esi
    call    sub_46E890
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    lea     ecx, [esp+14h]
    mov     [esi+4], ebp
    mov     [esi+0Ch], ebp
    call    sub_4E39B0
    mov     eax, dword_51E59C
    dec     eax
    mov     dword_51E59C, eax
    jnz     short loc_46CA37
    mov     eax, dword_51E598
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     dword_51E598, ebp

    loc_46CA37:                             ; CODE XREF: .text:0046CA21j
    lea     ecx, [esp+14h]
    call    sub_4E3A70
    push    esi
    call    sub_4B4F20
    add     esp, 4
    pop     ebx
    pop     edi

    loc_46CA4B:                             ; CODE XREF: .text:0046C934j
    mov     ecx, TAdynmemStructPtr
    pop     esi
    mov     [ecx+2A30h], ebp
    pop     ebp
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    sub     esp, 14h
    mov     ecx, [eax+2A30h]
    push    ebx
    push    esi
    call    sub_46E160
    mov     ecx, TAdynmemStructPtr
    xor     ebx, ebx
    mov     esi, [ecx+2A30h]
    cmp     esi, ebx
    jz      loc_46CBCB
    mov     edx, [esi+50h]
    mov     eax, [esi+4Ch]
    push    edi
    lea     edi, [esi+48h]
    push    ebp
    push    edx
    push    eax
    mov     ecx, edi
    call    nullsub_44
    mov     ecx, [edi+4]
    push    ecx
    call    sub_4B4F20
    mov     [edi+4], ebx
    mov     [edi+8], ebx
    mov     [edi+0Ch], ebx
    mov     edx, [esi+40h]
    mov     eax, [esi+3Ch]
    lea     edi, [esi+38h]
    add     esp, 4
    mov     ecx, edi
    push    edx
    push    eax
    call    nullsub_44
    mov     ecx, [edi+4]
    push    ecx
    call    sub_4B4F20
    mov     [edi+4], ebx
    mov     [edi+8], ebx
    mov     [edi+0Ch], ebx
    mov     ebp, [esi+24h]
    lea     edi, [esi+20h]
    add     esp, 4
    mov     eax, [ebp+0]
    xor     edx, edx
    cmp     eax, ebp
    mov     [esp+10h], eax
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      short loc_46CB28

    loc_46CAF8:                             ; CODE XREF: .text:0046CB26j
    lea     eax, [esp+18h]
    push    ebx
    push    eax
    lea     ecx, [esp+18h]
    call    sub_46FAC0
    mov     ecx, [eax]
    lea     edx, [esp+1Ch]
    push    ecx
    push    edx
    mov     ecx, edi
    call    sub_46EB60
    xor     eax, eax
    cmp     [esp+10h], ebp
    setz    al
    neg     al
    sbb     eax, eax
    inc     eax
    test    al, al
    jnz     short loc_46CAF8

    loc_46CB28:                             ; CODE XREF: .text:0046CAF6j
    mov     ecx, [edi+4]
    push    ecx
    call    sub_4B4F20
    mov     [edi+4], ebx
    mov     [edi+8], ebx
    mov     ebp, [esi+18h]
    mov     edi, [esi+14h]
    add     esp, 4
    cmp     edi, ebp
    jz      short loc_46CB53

    loc_46CB44:                             ; CODE XREF: .text:0046CB51j
    push    ebx
    mov     ecx, edi
    call    sub_470300
    add     edi, 5Ch
    cmp     edi, ebp
    jnz     short loc_46CB44

    loc_46CB53:                             ; CODE XREF: .text:0046CB42j
    mov     edx, [esi+14h]
    push    edx
    call    sub_4B4F20
    mov     [esi+14h], ebx
    mov     [esi+18h], ebx
    mov     [esi+1Ch], ebx
    mov     eax, [esi+4]
    add     esp, 4
    mov     ecx, [eax]
    push    eax
    lea     eax, [esp+24h]
    push    ecx
    push    eax
    mov     ecx, esi
    call    sub_46E890
    mov     ecx, [esi+4]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    lea     ecx, [esp+14h]
    mov     [esi+4], ebx
    mov     [esi+0Ch], ebx
    call    sub_4E39B0
    mov     eax, dword_51E59C
    dec     eax
    mov     dword_51E59C, eax
    jnz     short loc_46CBB7
    mov     eax, dword_51E598
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     dword_51E598, ebx

    loc_46CBB7:                             ; CODE XREF: .text:0046CBA1j
    lea     ecx, [esp+14h]
    call    sub_4E3A70
    push    esi
    call    sub_4B4F20
    add     esp, 4
    pop     ebp
    pop     edi

    loc_46CBCB:                             ; CODE XREF: .text:0046CA85j
    mov     edx, TAdynmemStructPtr
    pop     esi
    mov     [edx+2A30h], ebx
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46CBE0 proc near                    ; CODE XREF: sub_46DAD0+187p

    var_1= byte ptr -1

    push    ecx
    mov     dl, [esp+4+var_1]
    mov     eax, ecx
    mov     cl, [esp+4+var_1]
    mov     [eax+0Ch], cl
    xor     ecx, ecx
    mov     [eax+10h], ecx
    mov     [eax+14h], ecx
    mov     [eax+18h], ecx
    mov     [eax+1Ch], dl
    mov     [eax+20h], ecx
    mov     [eax+24h], ecx
    mov     [eax+28h], ecx
    mov     [eax], ecx
    mov     [eax+4], ecx
    mov     [eax+8], ecx
    pop     ecx
    retn
    sub_46CBE0 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 8
    push    ebx
    push    ebp
    mov     ebp, [esp+18h]
    push    esi
    mov     esi, [ecx]
    push    edi
    inc     esi
    mov     [ecx], esi
    mov     eax, esi
    lea     esi, [ecx+0Ch]
    mov     [ebp+2], eax
    mov     eax, 92492493h
    mov     ecx, [esi+8]
    mov     ebx, [esi+0Ch]
    sub     ebx, ecx
    mov     edi, ecx
    imul    ebx
    add     edx, ebx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 1
    jnb     loc_46CDA2
    mov     ebp, [esi+4]
    test    ebp, ebp
    jnz     short loc_46CC59
    xor     edx, edx
    jmp     short loc_46CC70
    ; ---------------------------------------------------------------------------

    loc_46CC59:                             ; CODE XREF: .text:0046CC53j
    mov     ebx, ecx
    mov     eax, 92492493h
    sub     ebx, ebp
    imul    ebx
    add     edx, ebx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_46CC70:                             ; CODE XREF: .text:0046CC57j
    cmp     edx, 1
    jbe     short loc_46CC98
    test    ebp, ebp
    jnz     short loc_46CC7D
    xor     ebx, ebx
    jmp     short loc_46CC9D
    ; ---------------------------------------------------------------------------

    loc_46CC7D:                             ; CODE XREF: .text:0046CC77j
    mov     ebx, ecx
    mov     eax, 92492493h
    sub     ebx, ebp
    imul    ebx
    add     edx, ebx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ebx, edx
    jmp     short loc_46CC9D
    ; ---------------------------------------------------------------------------

    loc_46CC98:                             ; CODE XREF: .text:0046CC73j
    mov     ebx, 1

    loc_46CC9D:                             ; CODE XREF: .text:0046CC7Bj
                                            ; .text:0046CC96j
    test    ebp, ebp
    jnz     short loc_46CCA5
    xor     edx, edx
    jmp     short loc_46CCBA
    ; ---------------------------------------------------------------------------

    loc_46CCA5:                             ; CODE XREF: .text:0046CC9Fj
    sub     ecx, ebp
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_46CCBA:                             ; CODE XREF: .text:0046CCA3j
    lea     eax, [edx+ebx]
    test    eax, eax
    mov     [esp+14h], eax
    jge     short loc_46CCC7
    xor     eax, eax

    loc_46CCC7:                             ; CODE XREF: .text:0046CCC3j
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    shl     edx, 1
    push    edx
    call    sub_4B4F10
    mov     ebp, eax
    mov     eax, [esi+4]
    add     esp, 4
    cmp     eax, edi
    mov     [esp+10h], ebp
    mov     ebx, ebp
    jz      short loc_46CD16

    loc_46CCE8:                             ; CODE XREF: .text:0046CD10j
    test    ebx, ebx
    jz      short loc_46CD08
    mov     ecx, eax
    mov     edx, ebx
    mov     ebp, [ecx]
    mov     [edx], ebp
    mov     ebp, [ecx+4]
    mov     [edx+4], ebp
    mov     ebp, [ecx+8]
    mov     [edx+8], ebp
    mov     cx, [ecx+0Ch]
    mov     [edx+0Ch], cx

    loc_46CD08:                             ; CODE XREF: .text:0046CCEAj
    add     eax, 0Eh
    add     ebx, 0Eh
    cmp     eax, edi
    jnz     short loc_46CCE8
    mov     ebp, [esp+10h]

    loc_46CD16:                             ; CODE XREF: .text:0046CCE6j
    mov     edx, [esp+20h]
    mov     ecx, esi
    push    edx
    push    1
    push    ebx
    call    sub_46FB40
    mov     eax, [esi+8]
    add     ebx, 0Eh
    push    ebx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_46FAF0
    mov     ecx, [esi+8]
    mov     edx, [esi+4]
    push    ecx
    push    edx
    mov     ecx, esi
    call    nullsub_44
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+18h]
    add     esp, 4
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     eax, [esi+4]
    test    eax, eax
    lea     edx, [ebp+ecx*2+0]
    mov     [esi+0Ch], edx
    jnz     short loc_46CD6D
    xor     edx, edx
    jmp     short loc_46CD85
    ; ---------------------------------------------------------------------------

    loc_46CD6D:                             ; CODE XREF: .text:0046CD67j
    mov     ecx, [esi+8]
    sub     ecx, eax
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_46CD85:                             ; CODE XREF: .text:0046CD6Bj
    lea     eax, [edx+1]
    mov     [esi+4], ebp
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ebp+ecx*2+0]
    mov     ebp, [esp+20h]
    mov     [esi+8], edx
    jmp     loc_46CE99
    ; ---------------------------------------------------------------------------

    loc_46CDA2:                             ; CODE XREF: .text:0046CC48j
    mov     ebx, ecx
    mov     eax, 92492493h
    sub     ebx, edi
    imul    ebx
    add     edx, ebx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 1
    jnb     short loc_46CE28
    lea     edx, [edi+0Eh]
    push    edx
    push    ecx
    push    edi
    mov     ecx, esi
    call    sub_46FAF0
    mov     ebx, [esi+8]
    mov     eax, 92492493h
    mov     ecx, ebx
    push    ebp
    sub     ecx, edi
    imul    ecx
    add     edx, ecx
    mov     ecx, 1
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    sub     ecx, edx
    push    ecx
    push    ebx
    mov     ecx, esi
    call    sub_46FB40
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      loc_46CE95

    loc_46CE03:                             ; CODE XREF: .text:0046CE24j
    mov     edx, ebp
    mov     edi, eax
    add     eax, 0Eh
    mov     ebx, [edx]
    cmp     eax, ecx
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     ebx, [edx+8]
    mov     [edi+8], ebx
    mov     dx, [edx+0Ch]
    mov     [edi+0Ch], dx
    jnz     short loc_46CE03
    jmp     short loc_46CE95
    ; ---------------------------------------------------------------------------

    loc_46CE28:                             ; CODE XREF: .text:0046CDBCj
    push    ecx
    push    ecx
    add     ecx, 0FFFFFFF2h
    push    ecx
    mov     ecx, esi
    call    sub_46FAF0
    mov     ecx, [esi+8]
    lea     eax, [ecx-0Eh]
    cmp     edi, eax
    jz      short loc_46CE69

    loc_46CE3F:                             ; CODE XREF: .text:0046CE63j
    sub     eax, 0Eh
    sub     ecx, 0Eh
    mov     edx, eax
    mov     ebx, ecx
    cmp     eax, edi
    mov     ebp, [edx]
    mov     [ebx], ebp
    mov     ebp, [edx+4]
    mov     [ebx+4], ebp
    mov     ebp, [edx+8]
    mov     [ebx+8], ebp
    mov     dx, [edx+0Ch]
    mov     [ebx+0Ch], dx
    jnz     short loc_46CE3F
    mov     ebp, [esp+20h]

    loc_46CE69:                             ; CODE XREF: .text:0046CE3Dj
    lea     ecx, [edi+0Eh]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_46CE95

    loc_46CE72:                             ; CODE XREF: .text:0046CE93j
    mov     edx, ebp
    mov     edi, eax
    add     eax, 0Eh
    mov     ebx, [edx]
    cmp     eax, ecx
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     ebx, [edx+8]
    mov     [edi+8], ebx
    mov     dx, [edx+0Ch]
    mov     [edi+0Ch], dx
    jnz     short loc_46CE72

    loc_46CE95:                             ; CODE XREF: .text:0046CDFDj
                                            ; .text:0046CE26j ...
    add     dword ptr [esi+8], 0Eh

    loc_46CE99:                             ; CODE XREF: .text:0046CD9Dj
    mov     eax, [esp+1Ch]
    push    0Eh
    push    ebp
    push    eax
    call    sub_44FE00
    push    eax
    call    Network_BroadcastMessage
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46CEC0 proc near                    ; CODE XREF: sub_46DAD0+2F4p
                                            ; sub_46DAD0+316p ...

    PlayersToSendTo= dword ptr  4
    idTo= dword ptr  8

    mov     eax, [esp+idTo]
    push    0Eh                             ; idFrom
    push    eax                             ; idTo
    mov     dword ptr [eax+2], 0
    mov     eax, [esp+8+PlayersToSendTo]
    push    eax                             ; PlayersToSendTo
    call    sub_44FE00
    push    eax                             ; dwDataSize
    call    Network_BroadcastMessage
    retn    8
    sub_46CEC0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+4]
    sub     esp, 10h
    mov     al, [edx+1]
    push    ebx
    push    ebp
    push    esi
    cmp     al, 65h
    push    edi
    mov     esi, ecx
    jnz     short loc_46CF48
    mov     eax, [esi+10h]
    mov     esi, [esi+14h]
    cmp     eax, esi
    jz      loc_46D02B
    mov     edx, [edx+2]

    loc_46CF15:                             ; CODE XREF: .text:0046CF1Fj
    cmp     [eax+2], edx
    jz      short loc_46CF2B
    add     eax, 0Eh
    cmp     eax, esi
    jnz     short loc_46CF15
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_46CF2B:                             ; CODE XREF: .text:0046CF18j
    push    0Eh
    push    eax
    mov     eax, [esp+38h]
    push    eax
    call    sub_44FE00
    push    eax
    call    Network_BroadcastMessage
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_46CF48:                             ; CODE XREF: .text:0046CF02j
    mov     eax, [edx+2]
    mov     ecx, [esi+8]
    cmp     eax, ecx
    jbe     short loc_46CF55
    mov     [esi+8], eax

    loc_46CF55:                             ; CODE XREF: .text:0046CF50j
    mov     ecx, [esi+4]
    mov     eax, [edx+2]
    lea     edi, [ecx+1]
    cmp     eax, edi
    jnz     short loc_46CFC5
    mov     ebx, [esp+28h]
    mov     ebp, [esp+2Ch]
    push    ebx
    push    edx
    mov     ecx, ebp
    mov     [esi+4], eax
    call    sub_46D6C0
    mov     edi, [esi+4]
    mov     eax, [esi+8]
    inc     edi
    cmp     edi, eax
    ja      loc_46D02B

    loc_46CF85:                             ; CODE XREF: .text:0046CFB9j
    mov     eax, [esi+20h]
    mov     ecx, [esi+24h]
    cmp     eax, ecx
    jz      loc_46D02B

    loc_46CF93:                             ; CODE XREF: .text:0046CF9Dj
    cmp     [eax+2], edi
    jz      short loc_46CF9F
    add     eax, 0Eh
    cmp     eax, ecx
    jnz     short loc_46CF93

    loc_46CF9F:                             ; CODE XREF: .text:0046CF96j
    cmp     eax, ecx
    jz      loc_46D02B
    push    ebx
    push    eax
    mov     ecx, ebp
    mov     [esi+4], edi
    call    sub_46D6C0
    mov     eax, [esi+8]
    inc     edi
    cmp     edi, eax
    jbe     short loc_46CF85
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_46CFC5:                             ; CODE XREF: .text:0046CF60j
    cmp     eax, ecx
    jbe     short loc_46D02B
    lea     ecx, [esi+1Ch]
    push    edx
    push    1
    mov     edx, [ecx+8]
    push    edx
    call    sub_46EBA0
    mov     edi, [esi+4]
    mov     eax, [esi+8]
    inc     edi
    cmp     edi, eax
    ja      short loc_46D02B
    mov     ebp, [esp+30h]
    mov     bl, 1Ah

    loc_46CFE9:                             ; CODE XREF: .text:0046D029j
    mov     eax, [esi+20h]
    mov     ecx, [esi+24h]
    cmp     eax, ecx
    jz      short loc_46D003

    loc_46CFF3:                             ; CODE XREF: .text:0046CFFDj
    cmp     [eax+2], edi
    jz      short loc_46CFFF
    add     eax, 0Eh
    cmp     eax, ecx
    jnz     short loc_46CFF3

    loc_46CFFF:                             ; CODE XREF: .text:0046CFF6j
    cmp     eax, ecx
    jnz     short loc_46D023

    loc_46D003:                             ; CODE XREF: .text:0046CFF1j
    lea     eax, [esp+10h]
    push    0Eh
    push    eax
    push    ebp
    mov     [esp+1Ch], bl
    mov     byte ptr [esp+1Dh], 65h
    mov     [esp+1Eh], edi
    call    sub_44FE00
    push    eax
    call    Network_BroadcastMessage

    loc_46D023:                             ; CODE XREF: .text:0046D001j
    mov     eax, [esi+8]
    inc     edi
    cmp     edi, eax
    jbe     short loc_46CFE9

    loc_46D02B:                             ; CODE XREF: .text:0046CF0Cj
                                            ; .text:0046CF7Fj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46D040 proc near                    ; CODE XREF: sub_46C8E0+15p

    var_2C= dword ptr -2Ch
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= byte ptr  4

    sub     esp, 2Ch
    mov     al, [esp+2Ch+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    mov     cl, [esp+38h+arg_0]
    xor     ebx, ebx
    mov     [esi+1], cl
    mov     ecx, esi
    mov     [esi], al
    mov     [esi+8], bl
    call    sub_46F720
    mov     dl, [esp+38h+arg_0]
    mov     al, [esp+38h+arg_0]
    mov     [esi+10h], dl
    mov     [esi+14h], ebx
    mov     [esi+18h], ebx
    mov     [esi+1Ch], ebx
    push    0Ch                             ; int
    mov     [esi+20h], al
    call    sub_4B4F10
    mov     cl, [esp+3Ch+arg_0]
    mov     dl, [esp+3Ch+arg_0]
    mov     [eax], eax
    mov     [eax+4], eax
    mov     [esi+24h], eax
    mov     eax, dword ptr [esp+3Ch+arg_0]
    mov     [esi+28h], ebx
    mov     [esi+38h], cl
    mov     [esi+3Ch], ebx
    mov     [esi+40h], ebx
    mov     [esi+44h], ebx
    mov     [esi+48h], dl
    mov     [esi+4Ch], ebx
    mov     [esi+50h], ebx
    mov     [esi+54h], ebx
    mov     [esi+2Ch], ebx
    mov     [esi+30h], ebx
    mov     [esi+34h], ebx
    mov     [esi+64h], ebx
    mov     [esi+58h], eax
    mov     [esi+5Ch], ebx
    mov     [esi+60h], ebx
    mov     edx, TAdynmemStructPtr
    mov     ecx, 1
    add     esp, 4
    mov     ebp, ecx
    cmp     [edx+1438Fh], ecx
    jle     loc_46D18B
    push    edi
    mov     [esp+3Ch+var_20], ebx
    mov     word ptr [esp+3Ch+var_1C], cx

    loc_46D0E9:                             ; CODE XREF: sub_46D040+144j
    mov     edx, [edx+1439Bh]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [eax+eax*8]
    mov     ebx, [edx+ecx+245h]
    mov     edi, [edx+ecx+13Eh]
    lea     eax, [edx+ecx]
    mov     cx, [esi+58h]
    mov     eax, [esp+3Ch+var_20]
    mov     edx, [esp+3Ch+var_24]
    shr     ebx, 10h
    mov     word ptr [esp+3Ch+var_1C+2], cx
    mov     ecx, [esp+3Ch+var_1C]
    and     bl, 1
    mov     [esp+3Ch+var_C], eax
    neg     bl
    mov     [esp+3Ch+var_8], ecx
    lea     eax, [esp+3Ch+var_14]
    sbb     ebx, ebx
    lea     ecx, [esp+3Ch+var_2C]
    mov     [esp+3Ch+var_10], edx
    mov     edx, [esp+3Ch+var_18]
    push    eax
    push    ecx
    neg     ebx
    mov     ecx, esi
    dec     ebx
    mov     [esp+44h+var_14], edi
    mov     [esp+44h+var_4], edx
    call    sub_46EF50
    mov     edx, [esp+3Ch+var_2C]
    mov     eax, [esp+3Ch+var_20]
    mov     ecx, [esp+3Ch+var_1C]
    add     edx, 10h
    inc     ebp
    mov     [edx], edi
    mov     [edx+4], eax
    mov     [edx+8], ecx
    mov     ecx, ebp
    and     ecx, 0FFFFh
    mov     [edx+0Ch], ebx
    mov     edx, TAdynmemStructPtr
    cmp     ecx, [edx+1438Fh]
    jl      loc_46D0E9
    pop     edi

    loc_46D18B:                             ; CODE XREF: sub_46D040+99j
    mov     eax, esi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    4
    sub_46D040 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+4Ch]
    push    eax
    mov     [esp+14h], eax
    call    sub_4B4F20
    xor     ebp, ebp
    lea     edi, [esi+38h]
    add     esp, 4
    mov     [esi+4Ch], ebp
    mov     [esi+50h], ebp
    mov     [esi+54h], ebp
    mov     eax, [edi+8]
    mov     ecx, [edi+4]
    push    eax
    push    ecx
    mov     ecx, edi
    call    nullsub_44
    mov     edx, [edi+4]
    push    edx
    call    sub_4B4F20
    mov     [edi+4], ebp
    mov     [edi+8], ebp
    mov     [edi+0Ch], ebp
    mov     ebx, [esi+24h]
    lea     edi, [esi+20h]
    add     esp, 4
    mov     eax, [ebx]
    xor     ecx, ecx
    cmp     eax, ebx
    mov     [esp+10h], eax
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jz      short loc_46D239

    loc_46D207:                             ; CODE XREF: .text:0046D237j
    lea     edx, [esp+14h]
    push    ebp
    push    edx
    lea     ecx, [esp+18h]
    call    sub_46FAC0
    mov     eax, [eax]
    lea     ecx, [esp+18h]
    push    eax
    push    ecx
    mov     ecx, edi
    call    sub_46EB60
    mov     ecx, [esp+10h]
    xor     edx, edx
    cmp     ecx, ebx
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     short loc_46D207

    loc_46D239:                             ; CODE XREF: .text:0046D205j
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     [edi+4], ebp
    mov     [edi+8], ebp
    mov     ebx, [esi+18h]
    mov     edi, [esi+14h]
    add     esp, 4
    cmp     edi, ebx
    jz      short loc_46D263

    loc_46D255:                             ; CODE XREF: .text:0046D261j
    mov     ecx, edi
    call    sub_46DED0
    add     edi, 5Ch
    cmp     edi, ebx
    jnz     short loc_46D255

    loc_46D263:                             ; CODE XREF: .text:0046D253j
    mov     ecx, [esi+14h]
    push    ecx
    call    sub_4B4F20
    mov     [esi+14h], ebp
    mov     [esi+18h], ebp
    mov     [esi+1Ch], ebp
    mov     eax, [esi+4]
    add     esp, 4
    lea     edx, [esp+18h]
    mov     ecx, [eax]
    push    eax
    push    ecx
    push    edx
    mov     ecx, esi
    call    sub_46E890
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    lea     ecx, [esp+10h]
    mov     [esi+4], ebp
    mov     [esi+0Ch], ebp
    call    sub_4E39B0
    mov     eax, dword_51E59C
    dec     eax
    mov     dword_51E59C, eax
    jnz     short loc_46D2C7
    mov     eax, dword_51E598
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     dword_51E598, ebp

    loc_46D2C7:                             ; CODE XREF: .text:0046D2B1j
    lea     ecx, [esp+10h]
    call    sub_4E3A70
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 4Ch
    mov     edx, TAdynmemStructPtr
    push    ebp
    mov     ebp, ecx
    mov     eax, [edx+1438Fh]
    mov     ecx, 1
    cmp     eax, ecx
    mov     [esp+0Ch], ecx
    jle     loc_46D4B6
    push    edi
    push    esi
    push    ebx
    mov     [esp+40h], cx

    loc_46D30B:                             ; CODE XREF: .text:0046D4ADj
    mov     eax, ecx
    mov     bl, 1
    shl     eax, 6
    add     eax, ecx
    mov     ecx, [edx+1439Bh]
    mov     dx, [ebp+58h]
    lea     eax, [eax+eax*8]
    mov     [esp+42h], dx
    add     eax, ecx
    mov     edx, [esp+3Ch]
    mov     [esp+50h], edx
    mov     ecx, [eax+13Eh]
    mov     eax, [eax+245h]
    shr     eax, 10h
    and     al, 1
    mov     [esp+38h], ecx
    neg     al
    sbb     eax, eax
    mov     [esp+48h], ecx
    mov     ecx, [esp+38h]
    neg     eax
    dec     eax
    mov     [esp+4Ch], ecx
    mov     [esp+44h], eax
    mov     eax, [esp+40h]
    mov     ecx, [esp+44h]
    mov     [esp+54h], eax
    mov     eax, [ebp+4]
    mov     [esp+58h], ecx
    lea     ecx, [esp+1Ch]
    mov     edi, eax
    mov     esi, [eax+4]
    call    sub_4E39B0
    mov     eax, dword_51E598
    cmp     esi, eax
    jz      short loc_46D3A4
    mov     ecx, [esp+48h]

    loc_46D38A:                             ; CODE XREF: .text:0046D3A2j
    mov     ebx, [esi+0Ch]
    mov     edi, esi
    cmp     ecx, ebx
    sbb     ebx, ebx
    neg     ebx
    test    bl, bl
    jz      short loc_46D39D
    mov     esi, [esi]
    jmp     short loc_46D3A0
    ; ---------------------------------------------------------------------------

    loc_46D39D:                             ; CODE XREF: .text:0046D397j
    mov     esi, [esi+8]

    loc_46D3A0:                             ; CODE XREF: .text:0046D39Bj
    cmp     esi, eax
    jnz     short loc_46D38A

    loc_46D3A4:                             ; CODE XREF: .text:0046D384j
    lea     ecx, [esp+1Ch]
    call    sub_4E3A70
    mov     al, [ebp+8]
    test    al, al
    jz      short loc_46D3D7
    lea     edx, [esp+10h]
    lea     eax, [esp+48h]
    push    edx
    push    eax
    push    edi
    lea     ecx, [esp+2Ch]
    push    esi
    push    ecx
    mov     ecx, ebp
    mov     byte ptr [esp+24h], 1
    call    sub_46FB80
    push    eax
    jmp     loc_46D469
    ; ---------------------------------------------------------------------------

    loc_46D3D7:                             ; CODE XREF: .text:0046D3B2j
    test    bl, bl
    mov     [esp+14h], edi
    jz      short loc_46D425
    lea     edx, [esp+24h]
    mov     ecx, ebp
    push    edx
    call    sub_46E880
    mov     edx, [esp+14h]
    mov     ecx, eax
    xor     eax, eax
    cmp     edx, [ecx]
    setz    al
    test    al, al
    jz      short loc_46D41C
    lea     eax, [esp+11h]
    lea     ecx, [esp+48h]
    push    eax
    push    ecx
    push    edi
    lea     edx, [esp+34h]
    push    esi
    push    edx
    mov     ecx, ebp
    mov     byte ptr [esp+25h], 1
    call    sub_46FB80
    push    eax
    jmp     short loc_46D469
    ; ---------------------------------------------------------------------------

    loc_46D41C:                             ; CODE XREF: .text:0046D3FAj
    lea     ecx, [esp+14h]
    call    sub_46FF90

    loc_46D425:                             ; CODE XREF: .text:0046D3DDj
    mov     eax, [esp+14h]
    mov     edx, [esp+48h]
    mov     ecx, [eax+0Ch]
    cmp     ecx, edx
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_46D45A
    lea     eax, [esp+12h]
    lea     ecx, [esp+48h]
    push    eax
    push    ecx
    push    edi
    lea     edx, [esp+38h]
    push    esi
    push    edx
    mov     ecx, ebp
    mov     byte ptr [esp+26h], 1
    call    sub_46FB80
    push    eax
    jmp     short loc_46D469
    ; ---------------------------------------------------------------------------

    loc_46D45A:                             ; CODE XREF: .text:0046D438j
    lea     eax, [esp+13h]
    lea     ecx, [esp+14h]
    push    eax
    mov     byte ptr [esp+17h], 0
    push    ecx

    loc_46D469:                             ; CODE XREF: .text:0046D3D2j
                                            ; .text:0046D41Aj ...
    lea     ecx, [esp+38h]
    call    sub_46FAD0
    mov     edx, [esp+30h]
    mov     eax, [esp+38h]
    mov     ecx, [esp+40h]
    add     edx, 10h
    mov     [edx], eax
    xor     eax, eax
    mov     [edx+4], eax
    mov     eax, [esp+44h]
    mov     [edx+8], ecx
    mov     ecx, [esp+18h]
    inc     ecx
    mov     [edx+0Ch], eax
    mov     edx, TAdynmemStructPtr
    mov     [esp+18h], ecx
    and     ecx, 0FFFFh
    cmp     ecx, [edx+1438Fh]
    jl      loc_46D30B
    pop     ebx
    pop     esi
    pop     edi

    loc_46D4B6:                             ; CODE XREF: .text:0046D2FDj
    pop     ebp
    add     esp, 4Ch
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46D4C0 proc near                    ; CODE XREF: sub_46D860+73p
                                            ; sub_46DAD0+1DBp

    arg_0= dword ptr  4
    idTo= dword ptr  8

    mov     eax, [ecx+58h]
    test    eax, eax
    jz      short loc_46D4CF
    mov     eax, [esp+arg_0]
    mov     eax, [eax]
    jmp     short loc_46D4D4
    ; ---------------------------------------------------------------------------

    loc_46D4CF:                             ; CODE XREF: sub_46D4C0+5j
    call    sub_450030

    loc_46D4D4:                             ; CODE XREF: sub_46D4C0+Dj
    mov     ecx, [esp+idTo]
    push    0Eh                             ; idFrom
    push    ecx                             ; idTo
    push    eax                             ; PlayersToSendTo
    mov     dword ptr [ecx+2], 0
    call    sub_44FE00
    push    eax                             ; dwDataSize
    call    Network_BroadcastMessage
    retn    0Ch
    sub_46D4C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46D500 proc near                    ; CODE XREF: Network_Process+1C77p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     dl, [eax+1]
    mov     dword ptr [eax+2], 0
    cmp     dl, 64h
    jnb     short locret_46D51E
    mov     edx, [esp+arg_4]
    push    edx
    push    eax
    call    sub_46D6C0

    locret_46D51E:                          ; CODE XREF: sub_46D500+11j
    retn    8
    sub_46D500 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx+64h]
    sub     esp, 10h
    test    eax, eax
    jnz     short loc_46D5A4
    mov     al, [esp+14h]
    mov     edx, [esp+18h]
    mov     [esp+1], al
    mov     eax, [esp+1Ch]
    mov     [esp+0Ah], eax
    mov     eax, [ecx+58h]
    test    eax, eax
    mov     byte ptr [esp+0], 1Ah
    mov     [esp+6], edx
    jz      short loc_46D584
    mov     eax, large ds:0
    lea     ecx, [esp+0]
    push    0Eh
    push    ecx
    push    eax
    mov     dword ptr [esp+0Eh], 0
    call    sub_44FE00
    push    eax
    call    Network_BroadcastMessage
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_46D584:                             ; CODE XREF: .text:0046D55Cj
    call    sub_450030
    lea     edx, [esp+0]
    push    0Eh
    push    edx
    push    eax
    mov     dword ptr [esp+0Eh], 0
    call    sub_44FE00
    push    eax
    call    Network_BroadcastMessage

    loc_46D5A4:                             ; CODE XREF: .text:0046D538j
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [ecx+64h]
    sub     esp, 10h
    test    eax, eax
    jnz     short loc_46D61F
    mov     al, [esp+18h]
    mov     edx, [esp+1Ch]
    mov     [esp+1], al
    mov     eax, [esp+20h]
    mov     [esp+0Ah], eax
    mov     eax, [ecx+58h]
    push    esi
    mov     esi, [esp+18h]
    test    eax, eax
    mov     byte ptr [esp+4], 1Ah
    mov     [esp+0Ah], edx
    jz      short loc_46D5F7
    mov     edx, [esi]
    lea     ecx, [esp+4]
    push    0Eh
    push    ecx
    mov     dword ptr [esp+0Eh], 0
    push    edx
    jmp     short loc_46D60C
    ; ---------------------------------------------------------------------------

    loc_46D5F7:                             ; CODE XREF: .text:0046D5E1j
    call    sub_450030
    lea     ecx, [esp+4]
    push    0Eh
    push    ecx
    mov     dword ptr [esp+0Eh], 0
    push    eax

    loc_46D60C:                             ; CODE XREF: .text:0046D5F5j
    call    sub_44FE00
    push    eax
    call    Network_BroadcastMessage
    mov     eax, [esi+28h]
    inc     eax
    mov     [esi+28h], eax
    pop     esi

    loc_46D61F:                             ; CODE XREF: .text:0046D5B8j
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx+64h]
    sub     esp, 10h
    test    eax, eax
    jnz     short loc_46D6B0
    mov     al, [esp+18h]
    push    esi
    mov     [esp+5], al
    mov     eax, [esp+20h]
    mov     esi, [esp+18h]
    mov     byte ptr [esp+4], 1Ah
    mov     edx, [eax]
    mov     [esp+0Ah], edx
    mov     dl, [eax+8]
    mov     [esp+0Eh], dl
    mov     dl, [eax+0Ah]
    mov     ax, [eax+0Ch]
    mov     [esp+0Fh], dl
    mov     [esp+10h], ax
    mov     eax, [ecx+58h]
    test    eax, eax
    jz      short loc_46D688
    mov     edx, [esi]
    lea     ecx, [esp+4]
    push    0Eh
    push    ecx
    mov     dword ptr [esp+0Eh], 0
    push    edx
    jmp     short loc_46D69D
    ; ---------------------------------------------------------------------------

    loc_46D688:                             ; CODE XREF: .text:0046D672j
    call    sub_450030
    lea     ecx, [esp+4]
    push    0Eh
    push    ecx
    mov     dword ptr [esp+0Eh], 0
    push    eax

    loc_46D69D:                             ; CODE XREF: .text:0046D686j
    call    sub_44FE00
    push    eax
    call    Network_BroadcastMessage
    mov     eax, [esi+28h]
    inc     eax
    mov     [esi+28h], eax
    pop     esi

    loc_46D6B0:                             ; CODE XREF: .text:0046D638j
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46D6C0 proc near                    ; CODE XREF: .text:0046CF71p
                                            ; .text:0046CFAEp ...

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_1C= dword ptr -1Ch
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 38h
    mov     eax, [ecx+64h]
    push    ebx
    push    ebp
    push    esi
    test    eax, eax
    push    edi
    mov     [esp+48h+var_38], ecx
    jnz     loc_46D842                      ; default
    mov     edx, [ecx+5Ch]
    mov     eax, [ecx+58h]
    inc     edx
    test    eax, eax
    mov     [ecx+5Ch], edx
    jz      loc_46D7C0
    mov     esi, [ecx+14h]
    mov     edx, [ecx+18h]
    cmp     esi, edx
    jz      short loc_46D71F
    mov     eax, [esp+48h+arg_4]
    mov     edi, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    add     edi, eax
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edi+ecx*2+1B67h]

    loc_46D714:                             ; CODE XREF: sub_46D6C0+5Dj
    cmp     [esi], eax
    jz      short loc_46D71F
    add     esi, 5Ch
    cmp     esi, edx
    jnz     short loc_46D714

    loc_46D71F:                             ; CODE XREF: sub_46D6C0+30j
                                            ; sub_46D6C0+56j
    mov     ebx, [esp+48h+arg_0]
    xor     eax, eax
    mov     al, [ebx+1]
    cmp     eax, 4                          ; switch 5 cases
    ja      loc_46D842                      ; default
    jmp     ds:off_46D84C[eax*4]            ; switch jump

    loc_46D738:                             ; DATA XREF: .text:0046D84Co
    mov     edx, [ebx+0Ah]                  ; case 0x1
    mov     [esi+24h], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46D748:                             ; CODE XREF: sub_46D6C0+71j
                                            ; DATA XREF: .text:0046D84Co
    mov     eax, [esi+8]                    ; case 0x2
    mov     ecx, [esi+0Ch]
    cmp     eax, ecx
    jz      short loc_46D768
    mov     edx, [ebx+6]

    loc_46D755:                             ; CODE XREF: sub_46D6C0+9Ej
    cmp     [eax], edx
    jz      short loc_46D760
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_46D755

    loc_46D760:                             ; CODE XREF: sub_46D6C0+97j
    cmp     eax, ecx
    jnz     loc_46D842                      ; default

    loc_46D768:                             ; CODE XREF: sub_46D6C0+90j
    mov     eax, [esi+0Ch]
    lea     ecx, [esi+4]
    lea     edi, [ebx+6]
    push    edi
    push    1
    push    eax
    call    sub_46E640
    mov     edx, [esi+1Ch]
    lea     ecx, [esi+14h]
    lea     esi, [ebx+0Ah]
    push    esi
    push    1
    push    edx
    call    sub_46E640
    mov     eax, [esi]
    mov     ecx, [edi]
    push    eax
    push    ecx
    mov     ecx, [esp+50h+var_38]
    call    sub_46D970
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46D7A5:                             ; CODE XREF: sub_46D6C0+71j
                                            ; DATA XREF: .text:0046D84Co
    mov     ebx, [ebx+0Ah]                  ; case 0x4
    mov     eax, [esi+2Ch]
    cmp     eax, ebx
    jnb     loc_46D842                      ; default
    mov     [esi+2Ch], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46D7C0:                             ; CODE XREF: sub_46D6C0+22j
    mov     esi, [esp+48h+arg_0]
    mov     al, [esi+1]
    test    al, al
    jz      short loc_46D842                ; default
    cmp     al, 3
    jnz     short loc_46D842                ; default
    movzx   dx, byte ptr [esi+0Ah]
    movzx   ax, byte ptr [esi+0Bh]
    mov     word ptr [esp+48h+var_1C], dx
    mov     edx, [esp+48h+var_34]
    mov     edi, [esi+6]
    mov     word ptr [esp+48h+var_1C+2], ax
    mov     eax, [esp+48h+var_30]
    mov     [esp+48h+var_10], edx
    mov     edx, [esp+48h+var_2C]
    mov     [esp+48h+var_C], eax
    mov     eax, [esp+48h+var_28]
    mov     [esp+48h+var_8], edx
    movsx   ebp, word ptr [esi+0Ch]
    mov     [esp+48h+var_4], eax
    lea     edx, [esp+48h+var_14]
    lea     eax, [esp+48h+var_34]
    push    edx
    push    eax
    xor     ebx, ebx
    mov     [esp+50h+var_14], edi
    call    sub_46EF50
    mov     ecx, [esp+48h+var_34]
    mov     edx, [esp+48h+var_1C]
    add     ecx, 10h
    mov     [ecx], edi
    mov     [ecx+4], ebx
    mov     [ecx+8], edx
    mov     [ecx+0Ch], ebp
    mov     eax, [esi+6]
    mov     ecx, [esp+48h+var_38]
    push    eax
    call    sub_46D860

    loc_46D842:                             ; CODE XREF: sub_46D6C0+10j
                                            ; sub_46D6C0+6Bj ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    8
    sub_46D6C0 endp

    ; ---------------------------------------------------------------------------
    off_46D84C dd offset loc_46D842         ; DATA XREF: sub_46D6C0+71r
    dd offset loc_46D738                    ; jump table for switch statement
    dd offset loc_46D748
    dd offset loc_46D842
    dd offset loc_46D7A5

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46D860 proc near                    ; CODE XREF: sub_46D6C0+17Dp
                                            ; sub_46D970+150p ...

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_A= dword ptr -0Ah
    var_6= byte ptr -6
    var_5= byte ptr -5
    var_4= word ptr -4
    arg_0= dword ptr  4

    sub     esp, 14h
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    mov     eax, [edi+64h]
    test    eax, eax
    jnz     loc_46D95A
    mov     eax, [edi+58h]
    test    eax, eax
    jz      short loc_46D8ED
    lea     eax, [esp+20h+arg_0]
    lea     ecx, [esp+20h+var_14]
    push    eax
    push    ecx
    mov     ecx, edi
    call    sub_46E9B0
    mov     esi, [edi+14h]
    mov     eax, [edi+18h]
    cmp     esi, eax
    jz      short loc_46D8ED
    mov     eax, [esp+20h+var_14]
    mov     bl, 3

    loc_46D89B:                             ; CODE XREF: sub_46D860+8Bj
    mov     ecx, [edi+64h]
    test    ecx, ecx
    jnz     short loc_46D8E3
    mov     cl, [eax+18h]
    mov     edx, [eax+10h]
    mov     [esp+20h+var_6], cl
    mov     [esp+20h+var_A], edx
    mov     dl, [eax+1Ah]
    mov     ax, [eax+1Ch]
    lea     ecx, [esp+20h+var_10]
    push    1
    push    ecx
    push    esi
    mov     ecx, edi
    mov     byte ptr [esp+2Ch+var_10], 1Ah
    mov     byte ptr [esp+2Ch+var_10+1], bl
    mov     [esp+2Ch+var_5], dl
    mov     [esp+2Ch+var_4], ax
    call    sub_46D4C0
    mov     eax, [esi+28h]
    inc     eax
    mov     [esi+28h], eax
    mov     eax, [esp+20h+var_14]

    loc_46D8E3:                             ; CODE XREF: sub_46D860+40j
    mov     ecx, [edi+18h]
    add     esi, 5Ch
    cmp     esi, ecx
    jnz     short loc_46D89B

    loc_46D8ED:                             ; CODE XREF: sub_46D860+18j
                                            ; sub_46D860+33j
    mov     ecx, [edi+24h]
    xor     edx, edx
    mov     eax, [ecx]
    cmp     eax, ecx
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      short loc_46D91D
    mov     esi, [esp+20h+arg_0]

    loc_46D906:                             ; CODE XREF: sub_46D860+BBj
    cmp     [eax+8], esi
    jz      short loc_46D95A
    mov     eax, [eax]
    xor     edx, edx
    cmp     eax, ecx
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     short loc_46D906

    loc_46D91D:                             ; CODE XREF: sub_46D860+A0j
    mov     esi, [edi+24h]
    push    0Ch                             ; int
    mov     ebx, [esi+4]
    call    sub_4B4F10
    add     esp, 4
    mov     ecx, esi
    test    esi, esi
    jnz     short loc_46D935
    mov     ecx, eax

    loc_46D935:                             ; CODE XREF: sub_46D860+D1j
    mov     [eax], ecx
    mov     ecx, ebx
    test    ebx, ebx
    jnz     short loc_46D93F
    mov     ecx, eax

    loc_46D93F:                             ; CODE XREF: sub_46D860+DBj
    mov     [eax+4], ecx
    mov     [esi+4], eax
    mov     ecx, [eax+4]
    mov     [ecx], eax
    add     eax, 8
    test    eax, eax
    jz      short loc_46D957
    mov     edx, [esp+20h+arg_0]
    mov     [eax], edx

    loc_46D957:                             ; CODE XREF: sub_46D860+EFj
    inc     dword ptr [edi+28h]

    loc_46D95A:                             ; CODE XREF: sub_46D860+Dj
                                            ; sub_46D860+A9j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 14h
    retn    4
    sub_46D860 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46D970 proc near                    ; CODE XREF: sub_46D6C0+D6p
                                            ; sub_46DAD0+255p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    push    ebx
    mov     ebx, ecx
    push    edi
    mov     [esp+14h+var_C], ebx
    mov     eax, [ebx+64h]
    test    eax, eax
    jnz     loc_46DAC7
    lea     eax, [esp+14h+arg_0]
    lea     ecx, [esp+14h+var_8]
    push    eax
    push    ecx
    mov     ecx, ebx
    call    sub_46E9B0
    mov     edi, [esp+14h+var_8]
    mov     ecx, [ebx+4]
    xor     edx, edx
    cmp     edi, ecx
    setz    dl
    test    dl, dl
    jnz     loc_46DAC7
    push    esi
    push    ebp
    mov     ebp, [esp+1Ch+arg_4]
    mov     eax, 1
    test    ebp, ebp
    mov     [esp+1Ch+var_4], eax
    jz      short loc_46DA24
    mov     ecx, [edi+14h]
    test    ecx, ecx
    jnz     short loc_46DA13
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+1438Fh]
    cmp     ecx, eax
    jle     short loc_46DA13
    mov     esi, [edx+1439Bh]
    add     esi, 249h

    loc_46D9E3:                             ; CODE XREF: sub_46D970+88j
    mov     edx, [esp+1Ch+arg_0]
    cmp     [esi+13Eh], edx
    jz      short loc_46D9FC
    inc     eax
    add     esi, 249h
    cmp     eax, ecx
    jl      short loc_46D9E3
    jmp     short loc_46DA13
    ; ---------------------------------------------------------------------------

    loc_46D9FC:                             ; CODE XREF: sub_46D970+7Dj
    push    esi
    call    sub_42A610
    mov     ecx, [esp+1Ch+var_8]
    mov     eax, [esi+142h]
    mov     [ecx+14h], eax
    mov     edi, [esp+1Ch+var_8]

    loc_46DA13:                             ; CODE XREF: sub_46D970+55j
                                            ; sub_46D970+65j ...
    test    ebp, ebp
    jz      short loc_46DA24
    cmp     ebp, [edi+14h]
    jz      short loc_46DA24
    mov     [esp+1Ch+var_4], 0

    loc_46DA24:                             ; CODE XREF: sub_46D970+4Ej
                                            ; sub_46D970+A5j ...
    mov     edi, [ebx+14h]
    mov     eax, [ebx+18h]
    cmp     edi, eax
    jz      short loc_46DAAC
    mov     bl, 2

    loc_46DA30:                             ; CODE XREF: sub_46D970+12Cj
    test    ebp, ebp
    jz      short loc_46DA67
    mov     edx, [edi]
    push    edx
    call    sub_44FED0
    test    eax, eax
    jz      short loc_46DAA8
    mov     ecx, [eax+27h]
    mov     al, [ecx+0A7h]
    cmp     al, bl
    jb      short loc_46DA54
    mov     edx, 1
    jmp     short loc_46DA69
    ; ---------------------------------------------------------------------------

    loc_46DA54:                             ; CODE XREF: sub_46D970+DBj
    cmp     al, 1
    jnz     short loc_46DA67
    cmp     [ecx+0A8h], bl
    jb      short loc_46DA67
    mov     edx, 1
    jmp     short loc_46DA69
    ; ---------------------------------------------------------------------------

    loc_46DA67:                             ; CODE XREF: sub_46D970+C2j
                                            ; sub_46D970+E6j ...
    xor     edx, edx

    loc_46DA69:                             ; CODE XREF: sub_46D970+E2j
                                            ; sub_46D970+F5j
    mov     ecx, [edi+18h]
    mov     eax, [edi+8]
    mov     esi, [edi+0Ch]

    loc_46DA72:                             ; CODE XREF: sub_46D970+114j
    cmp     eax, esi
    jz      short loc_46DAA0
    mov     ebp, [esp+1Ch+arg_0]
    cmp     [eax], ebp
    jz      short loc_46DA86
    add     eax, 4
    add     ecx, 4
    jmp     short loc_46DA72
    ; ---------------------------------------------------------------------------

    loc_46DA86:                             ; CODE XREF: sub_46D970+10Cj
    mov     ebp, [esp+1Ch+arg_4]
    test    edx, edx
    jz      short loc_46DA92
    cmp     [ecx], ebp
    jnz     short loc_46DAA0

    loc_46DA92:                             ; CODE XREF: sub_46D970+11Cj
    mov     eax, [esp+1Ch+var_C]
    add     edi, 5Ch
    cmp     edi, [eax+18h]
    jnz     short loc_46DA30
    jmp     short loc_46DAA8
    ; ---------------------------------------------------------------------------

    loc_46DAA0:                             ; CODE XREF: sub_46D970+104j
                                            ; sub_46D970+120j
    mov     [esp+1Ch+var_4], 0

    loc_46DAA8:                             ; CODE XREF: sub_46D970+CEj
                                            ; sub_46D970+12Ej
    mov     ebx, [esp+1Ch+var_C]

    loc_46DAAC:                             ; CODE XREF: sub_46D970+BCj
    mov     edx, [esp+1Ch+var_8]
    mov     cx, word ptr [esp+1Ch+var_4]
    mov     [edx+1Ah], cx
    mov     eax, [esp+1Ch+arg_0]
    push    eax
    mov     ecx, ebx
    call    sub_46D860
    pop     ebp
    pop     esi

    loc_46DAC7:                             ; CODE XREF: sub_46D970+10j
                                            ; sub_46D970+37j
    pop     edi
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_46D970 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46DAD0 proc near                    ; CODE XREF: .text:0044AF44p

    var_79= dword ptr -79h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    idTo= dword ptr -6Ch
    var_66= dword ptr -66h
    var_62= dword ptr -62h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_20= dword ptr -20h
    var_10= dword ptr -10h

    sub     esp, 7Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebx, ebx
    cmp     [edi+64h], ebx
    jnz     loc_46DEC8
    cmp     [edi+58h], ebx
    jz      loc_46DD52
    mov     edx, [edi+14h]
    mov     eax, [edi+18h]
    cmp     edx, eax
    mov     [esp+8Ch+var_70], ebx
    mov     [esp+8Ch+var_79+1], edx
    jz      loc_46DBCC
    lea     ebp, [edx+5Ch]
    mov     [esp+8Ch+var_74], ebp

    loc_46DB0A:                             ; CODE XREF: sub_46DAD0+F6j
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    xor     ecx, ecx
    add     eax, 1B8Ah

    loc_46DB18:                             ; CODE XREF: sub_46DAD0+70j
    cmp     [eax-27h], ebx
    jz      short loc_46DB37
    cmp     byte ptr [eax+4Ch], 3
    jnz     short loc_46DB37
    mov     ebx, [eax]
    cmp     byte ptr [ebx+94h], 1
    jnz     short loc_46DB35
    mov     ebx, [edx]
    cmp     ebx, [eax-23h]
    jz      short loc_46DB44

    loc_46DB35:                             ; CODE XREF: sub_46DAD0+5Cj
    xor     ebx, ebx

    loc_46DB37:                             ; CODE XREF: sub_46DAD0+4Bj
                                            ; sub_46DAD0+51j
    inc     ecx
    add     eax, 14Bh
    cmp     ecx, 0Ah
    jl      short loc_46DB18
    jmp     short loc_46DB4B
    ; ---------------------------------------------------------------------------

    loc_46DB44:                             ; CODE XREF: sub_46DAD0+63j
    mov     esi, 1
    xor     ebx, ebx

    loc_46DB4B:                             ; CODE XREF: sub_46DAD0+72j
    cmp     esi, ebx
    jnz     short loc_46DBB3
    mov     eax, [edi+18h]
    lea     esi, [edi+10h]
    cmp     ebp, eax
    mov     [esp+8Ch+var_70], eax
    jz      short loc_46DB78
    lea     ebx, [ebp-5Ch]

    loc_46DB60:                             ; CODE XREF: sub_46DAD0+A4j
    push    ebp
    mov     ecx, ebx
    call    sub_470040
    mov     eax, [esp+8Ch+var_70]
    add     ebp, 5Ch
    add     ebx, 5Ch
    cmp     ebp, eax
    jnz     short loc_46DB60
    xor     ebx, ebx

    loc_46DB78:                             ; CODE XREF: sub_46DAD0+8Bj
    mov     eax, [esi+8]
    mov     ecx, esi
    push    eax
    add     eax, 0FFFFFFA4h
    push    eax
    call    sub_46EAA0
    mov     ebp, [esi+8]
    mov     edx, [esp+8Ch+var_79+1]
    mov     ecx, [esp+8Ch+var_74]
    mov     eax, 5Ch
    add     ebp, 0FFFFFFA4h
    sub     edx, eax
    sub     ecx, eax
    mov     [esi+8], ebp
    mov     [esp+8Ch+var_79+1], edx
    mov     [esp+8Ch+var_74], ecx
    mov     [esp+8Ch+var_70], 1
    mov     ebp, ecx

    loc_46DBB3:                             ; CODE XREF: sub_46DAD0+7Dj
    mov     eax, [edi+18h]
    add     edx, 5Ch
    add     ebp, 5Ch
    cmp     edx, eax
    mov     [esp+8Ch+var_79+1], edx
    mov     [esp+8Ch+var_74], ebp
    jnz     loc_46DB0A

    loc_46DBCC:                             ; CODE XREF: sub_46DAD0+2Dj
    xor     eax, eax
    mov     [esp+8Ch+var_74], eax

    loc_46DBD2:                             ; CODE XREF: sub_46DAD0+221j
    mov     ecx, TAdynmemStructPtr
    lea     esi, [ecx+eax+1B63h]
    mov     eax, [ecx+eax+1B63h]
    cmp     eax, ebx
    jz      loc_46DCDF
    cmp     byte ptr [esi+73h], 3
    jnz     loc_46DCDF
    mov     edx, [esi+27h]
    cmp     byte ptr [edx+94h], 1
    jnz     loc_46DCDF
    mov     eax, [edi+14h]
    mov     ecx, [edi+18h]
    xor     edx, edx
    cmp     eax, ecx
    jz      short loc_46DC29
    mov     ebp, [esi+4]

    loc_46DC17:                             ; CODE XREF: sub_46DAD0+150j
    cmp     [eax], ebp
    jz      short loc_46DC24
    add     eax, 5Ch
    cmp     eax, ecx
    jnz     short loc_46DC17
    jmp     short loc_46DC29
    ; ---------------------------------------------------------------------------

    loc_46DC24:                             ; CODE XREF: sub_46DAD0+149j
    mov     edx, 1

    loc_46DC29:                             ; CODE XREF: sub_46DAD0+142j
                                            ; sub_46DAD0+152j
    cmp     edx, ebx
    jnz     loc_46DCDF
    mov     al, byte ptr [esp+8Ch+var_79]
    lea     ecx, [esp+8Ch+var_79]
    push    ecx
    lea     ecx, [esp+90h+var_48]
    mov     byte ptr [esp+90h+var_58], al
    mov     [esp+90h+var_54], ebx
    mov     [esp+90h+var_50], ebx
    mov     [esp+90h+var_4C], ebx
    call    sub_46E5C0
    lea     ecx, [esp+8Ch+var_2C]
    call    sub_46CBE0
    mov     edx, [esi+4]
    lea     ecx, [edi+10h]
    lea     eax, [esp+8Ch+var_5C]
    mov     [esp+8Ch+var_5C], edx
    mov     edx, [ecx+8]
    push    eax
    push    1
    push    edx
    mov     [esp+98h+var_38], ebx
    mov     [esp+98h+var_34], ebx
    mov     [esp+98h+var_30], ebx
    call    sub_46F7A0
    mov     esi, [edi+18h]
    mov     eax, [edi+64h]
    sub     esi, 5Ch
    cmp     eax, ebx
    jnz     short loc_46DCB3
    lea     eax, [esp+8Ch+idTo]
    push    1
    push    eax
    push    esi
    mov     ecx, edi
    mov     byte ptr [esp+98h+idTo], 1Ah
    mov     byte ptr [esp+98h+idTo+1], 0
    mov     [esp+98h+var_66], ebx
    mov     [esp+98h+var_62], ebx
    call    sub_46D4C0
    inc     dword ptr [esi+28h]

    loc_46DCB3:                             ; CODE XREF: sub_46DAD0+1BDj
    lea     ecx, [esp+8Ch+var_10]
    mov     [esp+8Ch+var_70], 1
    call    sub_46E610
    lea     ecx, [esp+8Ch+var_20]
    call    sub_46E610
    lea     ecx, [esp+8Ch+var_48]
    call    sub_46E5E0
    lea     ecx, [esp+8Ch+var_58]
    call    sub_46E5E0

    loc_46DCDF:                             ; CODE XREF: sub_46DAD0+118j
                                            ; sub_46DAD0+122j ...
    mov     eax, [esp+8Ch+var_74]
    add     eax, 14Bh
    cmp     eax, 0CEEh
    mov     [esp+8Ch+var_74], eax
    jl      loc_46DBD2
    cmp     [esp+8Ch+var_70], ebx
    jz      loc_46DEC8
    mov     ecx, [edi+4]
    xor     edx, edx
    mov     eax, [ecx]
    cmp     eax, ecx
    mov     [esp+8Ch+var_70], eax
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      loc_46DEC8

    loc_46DD1E:                             ; CODE XREF: sub_46DAD0+278j
    mov     eax, [eax+10h]
    push    ebx
    push    eax
    mov     ecx, edi
    call    sub_46D970
    lea     ecx, [esp+8Ch+var_70]
    call    sub_46EA10
    mov     eax, [esp+8Ch+var_70]
    mov     edx, [edi+4]
    xor     ecx, ecx
    cmp     eax, edx
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_46DD1E
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_46DD52:                             ; CODE XREF: sub_46DAD0+17j
    mov     eax, [edi+5Ch]
    cmp     eax, ebx
    jle     loc_46DEC8
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edi+60h]
    cmp     ecx, [edx+1438Fh]
    jge     loc_46DEA3
    cmp     ecx, ebx
    jnz     loc_46DDFA
    call    sub_450030
    cmp     eax, 0FFFFFFFFh
    jz      loc_46DEC8
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edi+64h]
    mov     eax, [edx+1438Fh]
    dec     eax
    cmp     ecx, ebx
    jnz     short loc_46DDEB
    mov     [esp+8Ch+var_62], eax
    mov     eax, [edi+58h]
    cmp     eax, ebx
    mov     byte ptr [esp+8Ch+idTo], 1Ah
    mov     byte ptr [esp+8Ch+idTo+1], 1
    mov     [esp+8Ch+var_66], ebx
    jz      short loc_46DDD8
    mov     ecx, large ds:0
    lea     eax, [esp+8Ch+idTo]
    push    eax
    push    ecx
    lea     ecx, [edi+2Ch]
    call    sub_46CEC0
    mov     dword ptr [edi+60h], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_46DDD8:                             ; CODE XREF: sub_46DAD0+2E3j
    call    sub_450030
    lea     edx, [esp+8Ch+idTo]
    lea     ecx, [edi+2Ch]
    push    edx
    push    eax
    call    sub_46CEC0

    loc_46DDEB:                             ; CODE XREF: sub_46DAD0+2CAj
    mov     dword ptr [edi+60h], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_46DDFA:                             ; CODE XREF: sub_46DAD0+2A4j
    xor     ebp, ebp
    jmp     short loc_46DE04
    ; ---------------------------------------------------------------------------

    loc_46DDFE:                             ; CODE XREF: sub_46DAD0+3C5j
    mov     edx, TAdynmemStructPtr

    loc_46DE04:                             ; CODE XREF: sub_46DAD0+32Cj
    mov     ecx, [edi+60h]
    mov     eax, [edx+1438Fh]
    cmp     ecx, eax
    jge     loc_46DEC8
    mov     esi, [edx+1439Bh]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     eax, [eax+eax*8]
    add     esi, eax
    push    esi
    call    sub_42A610
    mov     ecx, [edi+64h]
    mov     eax, [esi+142h]
    mov     esi, [esi+13Eh]
    cmp     ecx, ebx
    jnz     short loc_46DE8A
    mov     [esp+8Ch+var_62], eax
    mov     eax, [edi+58h]
    cmp     eax, ebx
    mov     byte ptr [esp+8Ch+idTo], 1Ah
    mov     byte ptr [esp+8Ch+idTo+1], 2
    mov     [esp+8Ch+var_66], esi
    jz      short loc_46DE77
    mov     eax, large ds:0
    lea     ecx, [esp+8Ch+idTo]
    push    0Eh                             ; idFrom
    push    ecx                             ; idTo
    push    eax                             ; PlayersToSendTo
    mov     [esp+98h+idTo+2], ebx
    call    sub_44FE00
    push    eax                             ; dwDataSize
    call    Network_BroadcastMessage
    jmp     short loc_46DE8A
    ; ---------------------------------------------------------------------------

    loc_46DE77:                             ; CODE XREF: sub_46DAD0+387j
    call    sub_450030
    lea     edx, [esp+8Ch+idTo]
    lea     ecx, [edi+2Ch]
    push    edx
    push    eax
    call    sub_46CEC0

    loc_46DE8A:                             ; CODE XREF: sub_46DAD0+36Ej
                                            ; sub_46DAD0+3A5j
    mov     ecx, [edi+60h]
    inc     ebp
    inc     ecx
    cmp     ebp, 4
    mov     [edi+60h], ecx
    jl      loc_46DDFE
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_46DEA3:                             ; CODE XREF: sub_46DAD0+29Cj
    mov     byte ptr [esp+8Ch+idTo], 1Ah
    mov     byte ptr [esp+8Ch+idTo+1], 4
    mov     [esp+8Ch+var_66], ebx
    mov     [esp+8Ch+var_62], eax
    call    sub_450030
    lea     ecx, [esp+8Ch+idTo]
    push    ecx
    push    eax
    lea     ecx, [edi+2Ch]
    call    sub_46CEC0

    loc_46DEC8:                             ; CODE XREF: sub_46DAD0+Ej
                                            ; sub_46DAD0+22Bj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7Ch
    retn
    sub_46DAD0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46DED0 proc near                    ; CODE XREF: .text:0046C9C7p
                                            ; .text:0046D257p ...

    var_4= dword ptr -4

    push    ecx
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+50h]
    push    eax
    mov     [esp+10h+var_4], eax
    call    sub_4B4F20
    xor     edi, edi
    add     esp, 4
    mov     [esi+50h], edi
    mov     [esi+54h], edi
    mov     [esi+58h], edi
    mov     eax, [esi+40h]
    push    eax
    mov     [esp+10h+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+40h], edi
    mov     [esi+44h], edi
    mov     [esi+48h], edi
    mov     eax, [esi+18h]
    push    eax
    mov     [esp+10h+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+18h], edi
    mov     [esi+1Ch], edi
    mov     [esi+20h], edi
    mov     eax, [esi+8]
    push    eax
    mov     [esp+10h+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+8], edi
    mov     [esi+0Ch], edi
    mov     [esi+10h], edi
    pop     edi
    pop     esi
    pop     ecx
    retn
    sub_46DED0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46DF40 proc near                    ; CODE XREF: sub_447B10+92Fp
    mov     eax, [ecx+58h]
    push    ebx
    push    esi
    push    edi
    test    eax, eax
    jnz     short loc_46DF50
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_46DF50:                             ; CODE XREF: sub_46DF40+8j
    mov     esi, [ecx+14h]
    mov     ebx, [ecx+18h]
    cmp     esi, ebx
    jz      loc_46DFF0
    lea     ecx, [esi+8]

    loc_46DF61:                             ; CODE XREF: sub_46DF40+50j
    mov     edi, [ecx+1Ch]
    test    edi, edi
    jz      short loc_46DF9B
    mov     edx, [ecx]
    test    edx, edx
    jnz     short loc_46DF72
    xor     eax, eax
    jmp     short loc_46DF7A
    ; ---------------------------------------------------------------------------

    loc_46DF72:                             ; CODE XREF: sub_46DF40+2Cj
    mov     eax, [ecx+4]
    sub     eax, edx
    sar     eax, 2

    loc_46DF7A:                             ; CODE XREF: sub_46DF40+30j
    cmp     eax, edi
    jnz     short loc_46DFA4
    mov     eax, [ecx+20h]
    mov     edx, [ecx+24h]
    cmp     eax, edx
    jnz     short loc_46DFCD
    add     esi, 5Ch
    add     ecx, 5Ch
    cmp     esi, ebx
    jnz     short loc_46DF61
    mov     eax, offset byte_502AE8
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_46DF9B:                             ; CODE XREF: sub_46DF40+26j
    mov     eax, offset aNoUnits_expect     ; "No units_expected sent from player"
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_46DFA4:                             ; CODE XREF: sub_46DF40+3Cj
    mov     ecx, [esi+8]
    test    ecx, ecx
    jnz     short loc_46DFB9
    mov     ecx, [esi+24h]
    xor     eax, eax
    push    eax
    push    ecx
    push    offset aExpectedDUnits          ; "expected %d units, got %d"
    jmp     short loc_46DFDA
    ; ---------------------------------------------------------------------------

    loc_46DFB9:                             ; CODE XREF: sub_46DF40+69j
    mov     eax, [esi+0Ch]
    sub     eax, ecx
    mov     ecx, [esi+24h]
    sar     eax, 2
    push    eax
    push    ecx
    push    offset aExpectedDUnits          ; "expected %d units, got %d"
    jmp     short loc_46DFDA
    ; ---------------------------------------------------------------------------

    loc_46DFCD:                             ; CODE XREF: sub_46DF40+46j
    mov     edx, [esi+2Ch]
    mov     eax, [esi+28h]
    push    edx
    push    eax
    push    offset aPacketsSentDAc          ; "packets sent=%d  ackd=%d"

    loc_46DFDA:                             ; CODE XREF: sub_46DF40+77j
                                            ; sub_46DF40+8Bj
    push    offset dword_51E5A0
    call    _sprintf
    add     esp, 10h
    mov     eax, offset dword_51E5A0
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_46DFF0:                             ; CODE XREF: sub_46DF40+18j
    pop     edi
    pop     esi
    mov     eax, offset byte_502AE8
    pop     ebx
    retn
    sub_46DF40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E000 proc near                    ; CODE XREF: Battleroom_Unknown1+595p
                                            ; Battleroom_Unknown1+5CCp ...
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     eax, [ebp+64h]
    test    eax, eax
    jnz     loc_46E09C
    mov     eax, [ebp+58h]
    test    eax, eax
    jz      loc_46E09C
    mov     edi, [ebp+14h]
    mov     eax, [ebp+18h]
    cmp     edi, eax
    jz      short loc_46E09C
    lea     esi, [edi+8]
    mov     bl, 2

    loc_46E02B:                             ; CODE XREF: sub_46E000+89j
    mov     eax, [edi]
    push    eax
    call    sub_44FED0
    test    eax, eax
    jz      short loc_46E07E
    mov     ecx, [eax]
    test    ecx, ecx
    jz      short loc_46E057
    cmp     byte ptr [eax+73h], 3
    jnz     short loc_46E04E
    mov     edx, [eax+27h]
    cmp     [edx+94h], bl
    jz      short loc_46E07E

    loc_46E04E:                             ; CODE XREF: sub_46E000+41j
    test    ecx, ecx
    jz      short loc_46E057
    cmp     [eax+73h], bl
    jz      short loc_46E07E

    loc_46E057:                             ; CODE XREF: sub_46E000+3Bj
                                            ; sub_46E000+50j
    mov     edx, [esi+1Ch]
    test    edx, edx
    jz      short loc_46E095
    mov     ecx, [esi]
    test    ecx, ecx
    jnz     short loc_46E068
    xor     eax, eax
    jmp     short loc_46E070
    ; ---------------------------------------------------------------------------

    loc_46E068:                             ; CODE XREF: sub_46E000+62j
    mov     eax, [esi+4]
    sub     eax, ecx
    sar     eax, 2

    loc_46E070:                             ; CODE XREF: sub_46E000+66j
    cmp     eax, edx
    jnz     short loc_46E095
    mov     eax, [esi+20h]
    mov     ecx, [esi+24h]
    cmp     eax, ecx
    jnz     short loc_46E095

    loc_46E07E:                             ; CODE XREF: sub_46E000+35j
                                            ; sub_46E000+4Cj ...
    mov     eax, [ebp+18h]
    add     edi, 5Ch
    add     esi, 5Ch
    cmp     edi, eax
    jnz     short loc_46E02B
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_46E095:                             ; CODE XREF: sub_46E000+5Cj
                                            ; sub_46E000+72j ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_46E09C:                             ; CODE XREF: sub_46E000+Bj
                                            ; sub_46E000+16j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn
    sub_46E000 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E0B0 proc near                    ; CODE XREF: sub_448C70+D34p

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+58h]
    test    eax, eax
    jnz     short loc_46E0C4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46E0C4:                             ; CODE XREF: sub_46E0B0+Aj
    mov     eax, [esi+64h]
    test    eax, eax
    jnz     short loc_46E148
    mov     edi, [esp+4+arg_0]
    push    edi
    call    sub_44FED0
    test    eax, eax
    jz      short loc_46E148
    mov     ecx, [eax]
    mov     dl, 2
    test    ecx, ecx
    jz      short loc_46E0FB
    cmp     byte ptr [eax+73h], 3
    jnz     short loc_46E0F2
    mov     ebx, [eax+27h]
    cmp     [ebx+94h], dl
    jz      short loc_46E148

    loc_46E0F2:                             ; CODE XREF: sub_46E0B0+35j
    test    ecx, ecx
    jz      short loc_46E0FB
    cmp     [eax+73h], dl
    jz      short loc_46E148

    loc_46E0FB:                             ; CODE XREF: sub_46E0B0+2Fj
                                            ; sub_46E0B0+44j
    mov     eax, [esi+14h]
    mov     ecx, [esi+18h]
    cmp     eax, ecx
    jz      short loc_46E140

    loc_46E105:                             ; CODE XREF: sub_46E0B0+5Ej
    cmp     [eax], edi
    jz      short loc_46E118
    add     eax, 5Ch
    cmp     eax, ecx
    jnz     short loc_46E105
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46E118:                             ; CODE XREF: sub_46E0B0+57j
    mov     esi, [eax+24h]
    test    esi, esi
    jz      short loc_46E140
    mov     edx, [eax+8]
    test    edx, edx
    jnz     short loc_46E12A
    xor     ecx, ecx
    jmp     short loc_46E132
    ; ---------------------------------------------------------------------------

    loc_46E12A:                             ; CODE XREF: sub_46E0B0+74j
    mov     ecx, [eax+0Ch]
    sub     ecx, edx
    sar     ecx, 2

    loc_46E132:                             ; CODE XREF: sub_46E0B0+78j
    cmp     ecx, esi
    jnz     short loc_46E140
    mov     ecx, [eax+28h]
    mov     edx, [eax+2Ch]
    cmp     ecx, edx
    jz      short loc_46E148

    loc_46E140:                             ; CODE XREF: sub_46E0B0+53j
                                            ; sub_46E0B0+6Dj ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46E148:                             ; CODE XREF: sub_46E0B0+19j
                                            ; sub_46E0B0+27j ...
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    retn    4
    sub_46E0B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E160 proc near                    ; CODE XREF: .text:0046CA70p

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebx
    push    ebp
    mov     ebp, ecx
    mov     eax, [ebp+64h]
    test    eax, eax
    jnz     loc_46E26E
    mov     edx, TAdynmemStructPtr
    mov     ecx, 1
    mov     ebx, ecx
    cmp     [edx+1438Fh], ecx
    jle     loc_46E26E
    push    edi
    push    esi

    loc_46E18D:                             ; CODE XREF: sub_46E160+106j
    mov     esi, [edx+1439Bh]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, ebp
    lea     eax, [eax+eax*8]
    add     esi, eax
    lea     edi, [esi+13Eh]
    push    edi
    call    sub_46FE60
    mov     ecx, [ebp+4]
    xor     edx, edx
    cmp     eax, ecx
    mov     [esp+18h+var_8], eax
    setz    dl
    test    dl, dl
    jnz     short loc_46E1D4
    mov     edx, [edi]
    mov     edi, [eax+0Ch]
    cmp     edx, edi
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_46E1D4
    lea     eax, [esp+18h+var_8]
    jmp     short loc_46E1DC
    ; ---------------------------------------------------------------------------

    loc_46E1D4:                             ; CODE XREF: sub_46E160+5Dj
                                            ; sub_46E160+6Cj
    mov     [esp+18h+var_4], ecx
    lea     eax, [esp+18h+var_4]

    loc_46E1DC:                             ; CODE XREF: sub_46E160+72j
    mov     edi, [eax]
    xor     edx, edx
    cmp     edi, ecx
    setz    dl
    test    dl, dl
    jz      short loc_46E20B
    call    sub_428FE0
    mov     eax, [esi+241h]
    mov     dword ptr [esi+15Ah], 0
    and     eax, 0FF7FFFFFh
    mov     [esi+241h], eax
    jmp     short loc_46E24A
    ; ---------------------------------------------------------------------------

    loc_46E20B:                             ; CODE XREF: sub_46E160+87j
    call    sub_428FE0
    cmp     word ptr [edi+18h], 0
    jz      short loc_46E225
    cmp     word ptr [edi+1Ah], 0
    jz      short loc_46E225
    mov     eax, 1
    jmp     short loc_46E227
    ; ---------------------------------------------------------------------------

    loc_46E225:                             ; CODE XREF: sub_46E160+B5j
                                            ; sub_46E160+BCj
    xor     eax, eax

    loc_46E227:                             ; CODE XREF: sub_46E160+C3j
    mov     ecx, [esi+241h]
    and     eax, 1
    shl     eax, 17h
    and     ecx, 0FF7FFFFFh
    or      eax, ecx
    mov     [esi+241h], eax
    mov     edx, [edi+1Ch]
    mov     [esi+15Ah], edx

    loc_46E24A:                             ; CODE XREF: sub_46E160+A9j
    call    sub_428FC0
    mov     edx, TAdynmemStructPtr
    inc     ebx
    mov     ecx, ebx
    mov     eax, [edx+1438Fh]
    and     ecx, 0FFFFh
    cmp     ecx, eax
    jl      loc_46E18D
    pop     esi
    pop     edi

    loc_46E26E:                             ; CODE XREF: sub_46E160+Cj
                                            ; sub_46E160+25j
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    sub_46E160 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E280 proc near                    ; CODE XREF: .text:0044C274p
                                            ; .text:0044C330p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    xor     eax, eax
    push    esi
    mov     esi, ecx
    mov     edx, [esi+28h]
    test    edx, edx
    setz    al
    test    al, al
    jz      short loc_46E29D
    xor     eax, eax
    pop     esi
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46E29D:                             ; CODE XREF: sub_46E280+12j
    mov     ecx, [esi+24h]
    push    edi
    mov     edi, [ecx]
    mov     ecx, esi
    add     edi, 8
    push    edi
    call    sub_46FE60
    mov     ecx, [esi+4]
    xor     edx, edx
    cmp     eax, ecx
    mov     [esp+10h+var_8], eax
    setz    dl
    test    dl, dl
    jnz     short loc_46E2D5
    mov     edx, [edi]
    mov     edi, [eax+0Ch]
    cmp     edx, edi
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_46E2D5
    lea     eax, [esp+10h+var_8]
    jmp     short loc_46E2DD
    ; ---------------------------------------------------------------------------

    loc_46E2D5:                             ; CODE XREF: sub_46E280+3Ej
                                            ; sub_46E280+4Dj
    mov     [esp+10h+var_4], ecx
    lea     eax, [esp+10h+var_4]

    loc_46E2DD:                             ; CODE XREF: sub_46E280+53j
    mov     ecx, [eax]
    mov     edx, [esp+10h+arg_0]
    add     ecx, 10h
    mov     eax, [ecx]
    mov     [edx], eax
    mov     eax, [ecx+4]
    mov     [edx+4], eax
    mov     eax, [ecx+8]
    mov     [edx+8], eax
    mov     ecx, [ecx+0Ch]
    mov     [edx+0Ch], ecx
    mov     edx, [esi+24h]
    mov     eax, [edx]
    push    eax
    mov     ecx, [eax+4]
    mov     edx, [eax]
    mov     [ecx], edx
    mov     ecx, [eax]
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    call    sub_4B4F20
    mov     eax, [esi+28h]
    add     esp, 4
    dec     eax
    mov     [esi+28h], eax
    pop     edi
    mov     eax, 1
    pop     esi
    add     esp, 8
    retn    4
    sub_46E280 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E330 proc near                    ; CODE XREF: sub_44C7E0+30Fp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    esi
    push    edi
    mov     esi, ecx
    lea     edi, [eax+13Eh]
    push    edi
    call    sub_46FE60
    mov     esi, [esi+4]
    xor     ecx, ecx
    cmp     eax, esi
    mov     [esp+0Ch+arg_0], eax
    setz    cl
    test    cl, cl
    jnz     short loc_46E36C
    mov     edx, [edi]
    mov     edi, [eax+0Ch]
    cmp     edx, edi
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_46E36C
    lea     eax, [esp+0Ch+arg_0]
    jmp     short loc_46E374
    ; ---------------------------------------------------------------------------

    loc_46E36C:                             ; CODE XREF: sub_46E330+25j
                                            ; sub_46E330+34j
    mov     [esp+0Ch+var_4], esi
    lea     eax, [esp+0Ch+var_4]

    loc_46E374:                             ; CODE XREF: sub_46E330+3Aj
    mov     ecx, [eax]
    mov     eax, [esp+0Ch+arg_4]
    add     ecx, 10h
    mov     edx, eax
    mov     esi, [ecx]
    mov     [edx], esi
    mov     esi, [ecx+4]
    mov     [edx+4], esi
    mov     esi, [ecx+8]
    mov     [edx+8], esi
    mov     ecx, [ecx+0Ch]
    mov     [edx+0Ch], ecx
    cmp     word ptr [eax+8], 0
    jz      short loc_46E3AE
    cmp     word ptr [eax+0Ah], 0
    jz      short loc_46E3AE
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46E3AE:                             ; CODE XREF: sub_46E330+6Aj
                                            ; sub_46E330+71j
    pop     edi
    xor     eax, eax
    pop     esi
    pop     ecx
    retn    8
    sub_46E330 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    mov     eax, [esp+8]
    push    ebx
    push    esi
    push    edi
    lea     ebx, [eax+13Eh]
    mov     edi, ecx
    push    ebx
    call    sub_46FE60
    mov     esi, [edi+4]
    xor     ecx, ecx
    cmp     eax, esi
    mov     [esp+14h], eax
    setz    cl
    test    cl, cl
    jnz     short loc_46E3FD
    mov     edx, [ebx]
    mov     ecx, [eax+0Ch]
    cmp     edx, ecx
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_46E3FD
    lea     eax, [esp+14h]
    jmp     short loc_46E405
    ; ---------------------------------------------------------------------------

    loc_46E3FD:                             ; CODE XREF: .text:0046E3E6j
                                            ; .text:0046E3F5j
    mov     [esp+0Ch], esi
    lea     eax, [esp+0Ch]

    loc_46E405:                             ; CODE XREF: .text:0046E3FBj
    mov     esi, [eax]
    xor     ecx, ecx
    cmp     [esi+18h], cx
    setz    cl
    mov     [esi+18h], cx
    mov     edx, [ebx]
    push    edx
    mov     ecx, edi
    call    sub_46D860
    cmp     word ptr [esi+18h], 0
    jz      short loc_46E438
    cmp     word ptr [esi+1Ah], 0
    jz      short loc_46E438
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46E438:                             ; CODE XREF: .text:0046E423j
                                            ; .text:0046E42Aj
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E450 proc near                    ; CODE XREF: sub_44C420+ECp

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    ebx
    push    esi
    push    edi
    lea     ebx, [eax+13Eh]
    mov     esi, ecx
    push    ebx
    call    sub_46FE60
    mov     edi, [esi+4]
    xor     ecx, ecx
    cmp     eax, edi
    mov     [esp+10h+arg_0], eax
    setz    cl
    test    cl, cl
    jnz     short loc_46E48D
    mov     edx, [ebx]
    mov     ecx, [eax+0Ch]
    cmp     edx, ecx
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_46E48D
    lea     eax, [esp+10h+arg_0]
    jmp     short loc_46E495
    ; ---------------------------------------------------------------------------

    loc_46E48D:                             ; CODE XREF: sub_46E450+26j
                                            ; sub_46E450+35j
    mov     [esp+10h+var_4], edi
    lea     eax, [esp+10h+var_4]

    loc_46E495:                             ; CODE XREF: sub_46E450+3Bj
    mov     edi, [eax]
    mov     word ptr [edi+18h], 0
    mov     ecx, [ebx]
    push    ecx
    mov     ecx, esi
    call    sub_46D860
    cmp     word ptr [edi+18h], 0
    jz      short loc_46E4C1
    cmp     word ptr [edi+1Ah], 0
    jz      short loc_46E4C1
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46E4C1:                             ; CODE XREF: sub_46E450+5Cj
                                            ; sub_46E450+63j
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    4
    sub_46E450 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E4D0 proc near                    ; CODE XREF: sub_44C420+F3p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    ebx
    push    esi
    push    edi
    lea     ebx, [eax+13Eh]
    mov     edi, ecx
    push    ebx
    call    sub_46FE60
    mov     esi, [edi+4]
    xor     ecx, ecx
    cmp     eax, esi
    mov     [esp+10h+arg_0], eax
    setz    cl
    test    cl, cl
    jnz     short loc_46E50D
    mov     edx, [ebx]
    mov     ecx, [eax+0Ch]
    cmp     edx, ecx
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_46E50D
    lea     eax, [esp+10h+arg_0]
    jmp     short loc_46E515
    ; ---------------------------------------------------------------------------

    loc_46E50D:                             ; CODE XREF: sub_46E4D0+26j
                                            ; sub_46E4D0+35j
    mov     [esp+10h+var_4], esi
    lea     eax, [esp+10h+var_4]

    loc_46E515:                             ; CODE XREF: sub_46E4D0+3Bj
    mov     esi, [eax]
    mov     word ptr [esi+18h], 1
    mov     ecx, [ebx]
    push    ecx
    mov     ecx, edi
    call    sub_46D860
    cmp     word ptr [esi+18h], 0
    jz      short loc_46E541
    cmp     word ptr [esi+1Ah], 0
    jz      short loc_46E541
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_46E541:                             ; CODE XREF: sub_46E4D0+5Cj
                                            ; sub_46E4D0+63j
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    4
    sub_46E4D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E550 proc near                    ; CODE XREF: sub_44BE70+D7p
                                            ; sub_44C420+27Bp ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    ebx
    push    esi
    push    edi
    lea     edi, [eax+13Eh]
    mov     esi, ecx
    push    edi
    call    sub_46FE60
    mov     ecx, [esi+4]
    xor     edx, edx
    cmp     eax, ecx
    mov     [esp+10h+arg_0], eax
    setz    dl
    test    dl, dl
    jnz     short loc_46E58D
    mov     edx, [edi]
    mov     ebx, [eax+0Ch]
    cmp     edx, ebx
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_46E58D
    lea     eax, [esp+10h+arg_0]
    jmp     short loc_46E595
    ; ---------------------------------------------------------------------------

    loc_46E58D:                             ; CODE XREF: sub_46E550+26j
                                            ; sub_46E550+35j
    mov     [esp+10h+var_4], ecx
    lea     eax, [esp+10h+var_4]

    loc_46E595:                             ; CODE XREF: sub_46E550+3Bj
    mov     eax, [eax]
    xor     edx, edx
    cmp     eax, ecx
    setz    dl
    test    dl, dl
    jnz     short loc_46E5B3
    mov     ecx, [esp+10h+arg_4]
    mov     [eax+1Ch], ecx
    mov     edx, [edi]
    push    edx
    mov     ecx, esi
    call    sub_46D860

    loc_46E5B3:                             ; CODE XREF: sub_46E550+50j
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    8
    sub_46E550 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E5C0 proc near                    ; CODE XREF: sub_46DAD0+17Ep

    arg_0= dword ptr  4

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     dl, [ecx]
    xor     ecx, ecx
    mov     [eax], dl
    mov     [eax+4], ecx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ecx
    retn    4
    sub_46E5C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E5E0 proc near                    ; CODE XREF: sub_46DAD0+201p
                                            ; sub_46DAD0+20Ap

    var_4= dword ptr -4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+4]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    pop     esi
    pop     ecx
    retn
    sub_46E5E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E610 proc near                    ; CODE XREF: .text:0046C958p
                                            ; sub_46DAD0+1EFp ...

    var_4= dword ptr -4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+4]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    pop     esi
    pop     ecx
    retn
    sub_46E610 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E640 proc near                    ; CODE XREF: sub_46D6C0+B5p
                                            ; sub_46D6C0+C7p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ebp, [esp+10h+arg_4]
    mov     ecx, [ebx+8]
    mov     eax, [ebx+0Ch]
    sub     eax, ecx
    push    esi
    sar     eax, 2
    cmp     eax, ebp
    push    edi
    mov     [esp+18h+var_8], ebx
    jnb     loc_46E782
    mov     edx, [ebx+4]
    test    edx, edx
    jnz     short loc_46E66F
    xor     eax, eax
    jmp     short loc_46E676
    ; ---------------------------------------------------------------------------

    loc_46E66F:                             ; CODE XREF: sub_46E640+29j
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2

    loc_46E676:                             ; CODE XREF: sub_46E640+2Dj
    cmp     ebp, eax
    jnb     short loc_46E68B
    test    edx, edx
    jnz     short loc_46E682
    xor     eax, eax
    jmp     short loc_46E68D
    ; ---------------------------------------------------------------------------

    loc_46E682:                             ; CODE XREF: sub_46E640+3Cj
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2
    jmp     short loc_46E68D
    ; ---------------------------------------------------------------------------

    loc_46E68B:                             ; CODE XREF: sub_46E640+38j
    mov     eax, ebp

    loc_46E68D:                             ; CODE XREF: sub_46E640+40j
                                            ; sub_46E640+49j
    test    edx, edx
    jnz     short loc_46E695
    xor     ecx, ecx
    jmp     short loc_46E69A
    ; ---------------------------------------------------------------------------

    loc_46E695:                             ; CODE XREF: sub_46E640+4Fj
    sub     ecx, edx
    sar     ecx, 2

    loc_46E69A:                             ; CODE XREF: sub_46E640+53j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_46E6A6
    xor     eax, eax

    loc_46E6A6:                             ; CODE XREF: sub_46E640+62j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebx+4]
    mov     ebx, [esp+1Ch+arg_0]
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_46E6D9

    loc_46E6C7:                             ; CODE XREF: sub_46E640+97j
    test    edx, edx
    jz      short loc_46E6CF
    mov     ecx, [eax]
    mov     [edx], ecx

    loc_46E6CF:                             ; CODE XREF: sub_46E640+89j
    add     eax, 4
    add     edx, 4
    cmp     eax, ebx
    jnz     short loc_46E6C7

    loc_46E6D9:                             ; CODE XREF: sub_46E640+85j
    test    ebp, ebp
    mov     eax, edx
    jbe     short loc_46E6F3
    mov     esi, [esp+18h+arg_8]
    mov     ecx, ebp

    loc_46E6E5:                             ; CODE XREF: sub_46E640+B1j
    test    eax, eax
    jz      short loc_46E6ED
    mov     edi, [esi]
    mov     [eax], edi

    loc_46E6ED:                             ; CODE XREF: sub_46E640+A7j
    add     eax, 4
    dec     ecx
    jnz     short loc_46E6E5

    loc_46E6F3:                             ; CODE XREF: sub_46E640+9Dj
    mov     eax, [esp+18h+var_8]
    lea     edi, ds:0[ebp*4]
    mov     esi, [eax+8]
    lea     ecx, [edx+edi]
    cmp     ebx, esi
    jz      short loc_46E721
    lea     eax, [ebx+ecx]
    sub     eax, edx
    sub     eax, edi

    loc_46E70F:                             ; CODE XREF: sub_46E640+DFj
    test    ecx, ecx
    jz      short loc_46E717
    mov     edx, [eax]
    mov     [ecx], edx

    loc_46E717:                             ; CODE XREF: sub_46E640+D1j
    add     eax, 4
    add     ecx, 4
    cmp     eax, esi
    jnz     short loc_46E70F

    loc_46E721:                             ; CODE XREF: sub_46E640+C6j
    mov     eax, [esp+18h+var_8]
    mov     eax, [eax+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     esi, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+var_4]
    mov     edx, [esp+1Ch+var_8]
    add     esp, 4
    lea     eax, [esi+ecx*4]
    mov     ecx, [edx+4]
    mov     [edx+0Ch], eax
    test    ecx, ecx
    jnz     short loc_46E765
    xor     eax, eax
    mov     [edx+4], esi
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46E765:                             ; CODE XREF: sub_46E640+10Cj
    mov     eax, [edx+8]
    mov     [edx+4], esi
    sub     eax, ecx
    sar     eax, 2
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46E782:                             ; CODE XREF: sub_46E640+1Ej
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, esi
    sar     edx, 2
    cmp     edx, ebp
    jnb     short loc_46E7FC
    lea     edi, ds:0[ebp*4]
    cmp     esi, ecx
    lea     edx, [esi+edi]
    jz      short loc_46E7B9
    mov     eax, edx
    sub     eax, edi

    loc_46E7A3:                             ; CODE XREF: sub_46E640+177j
    test    edx, edx
    jz      short loc_46E7AF
    mov     ebx, [eax]
    mov     [edx], ebx
    mov     ebx, [esp+18h+var_8]

    loc_46E7AF:                             ; CODE XREF: sub_46E640+165j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_46E7A3

    loc_46E7B9:                             ; CODE XREF: sub_46E640+15Dj
    mov     eax, [ebx+8]
    mov     edx, [esp+18h+arg_8]
    mov     ecx, eax
    sub     ecx, esi
    sar     ecx, 2
    sub     ebp, ecx
    mov     ecx, ebp
    jz      short loc_46E7DB

    loc_46E7CD:                             ; CODE XREF: sub_46E640+199j
    test    eax, eax
    jz      short loc_46E7D5
    mov     ebp, [edx]
    mov     [eax], ebp

    loc_46E7D5:                             ; CODE XREF: sub_46E640+18Fj
    add     eax, 4
    dec     ecx
    jnz     short loc_46E7CD

    loc_46E7DB:                             ; CODE XREF: sub_46E640+18Bj
    mov     ecx, [ebx+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_46E855

    loc_46E7E4:                             ; CODE XREF: sub_46E640+1ADj
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_46E7E4
    add     [ebx+8], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46E7FC:                             ; CODE XREF: sub_46E640+14Fj
    test    ebp, ebp
    jbe     short loc_46E858
    lea     edi, ds:0[ebp*4]
    mov     eax, ecx
    sub     eax, edi
    mov     edx, ecx
    cmp     eax, ecx
    jz      short loc_46E823

    loc_46E811:                             ; CODE XREF: sub_46E640+1E1j
    test    edx, edx
    jz      short loc_46E819
    mov     ebp, [eax]
    mov     [edx], ebp

    loc_46E819:                             ; CODE XREF: sub_46E640+1D3j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_46E811

    loc_46E823:                             ; CODE XREF: sub_46E640+1CFj
    mov     ecx, [ebx+8]
    mov     eax, ecx
    sub     eax, edi
    cmp     esi, eax
    jz      short loc_46E83D

    loc_46E82E:                             ; CODE XREF: sub_46E640+1FBj
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, esi
    mov     [ecx], edx
    jnz     short loc_46E82E

    loc_46E83D:                             ; CODE XREF: sub_46E640+1ECj
    lea     ecx, [esi+edi]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_46E855
    mov     edx, [esp+18h+arg_8]

    loc_46E84A:                             ; CODE XREF: sub_46E640+213j
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_46E84A

    loc_46E855:                             ; CODE XREF: sub_46E640+1A2j
                                            ; sub_46E640+204j
    add     [ebx+8], edi

    loc_46E858:                             ; CODE XREF: sub_46E640+1BEj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_46E640 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_44. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E880 proc near                    ; CODE XREF: .text:0046D3E6p

    arg_0= dword ptr  4

    mov     eax, [ecx+4]
    mov     ecx, [eax]
    mov     eax, [esp+arg_0]
    mov     [eax], ecx
    retn    4
    sub_46E880 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E890 proc near                    ; CODE XREF: .text:0046C9F6p
                                            ; .text:0046CB76p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    push    ebx
    mov     ebx, [esp+8+arg_8]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+0Ch+arg_4]
    push    edi
    mov     eax, [esi+0Ch]
    test    eax, eax
    jz      loc_46E95B
    mov     edi, [esi+4]
    xor     eax, eax
    cmp     ecx, [edi]
    setz    al
    neg     al
    sbb     eax, eax
    inc     eax
    test    al, al
    jnz     loc_46E95B
    xor     edx, edx
    cmp     ebx, edi
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     loc_46E95B
    lea     ecx, [esp+10h+var_4]
    call    sub_4E39B0
    mov     eax, [esi+4]
    lea     ecx, [esp+10h+arg_8]
    mov     ebx, [eax+4]
    call    sub_4E39B0
    mov     eax, dword_51E598
    mov     edi, ebx
    cmp     ebx, eax
    jz      short loc_46E918

    loc_46E8F7:                             ; CODE XREF: sub_46E890+86j
    mov     ecx, [edi+8]
    push    ecx
    mov     ecx, esi
    call    sub_46F6D0
    mov     edi, [edi]
    push    ebx
    call    sub_4B4F20
    mov     eax, dword_51E598
    add     esp, 4
    cmp     edi, eax
    mov     ebx, edi
    jnz     short loc_46E8F7

    loc_46E918:                             ; CODE XREF: sub_46E890+65j
    lea     ecx, [esp+10h+arg_8]
    call    sub_4E3A70
    mov     edx, [esi+4]
    mov     eax, dword_51E598
    mov     [edx+4], eax
    mov     eax, [esi+4]
    mov     dword ptr [esi+0Ch], 0
    mov     [eax], eax
    mov     eax, [esi+4]
    mov     [eax+8], eax
    mov     ecx, [esi+4]
    mov     esi, [esp+10h+arg_0]
    mov     edx, [ecx]
    lea     ecx, [esp+10h+var_4]
    mov     [esi], edx
    call    sub_4E3A70
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46E95B:                             ; CODE XREF: sub_46E890+13j
                                            ; sub_46E890+2Aj ...
    xor     eax, eax
    cmp     ecx, ebx
    setz    al
    neg     al
    sbb     eax, eax
    inc     eax
    test    al, al
    jz      short loc_46E997

    loc_46E96B:                             ; CODE XREF: sub_46E890+105j
    mov     edi, ecx
    lea     ecx, [esp+10h+arg_4]
    call    sub_46EA10
    lea     ecx, [esp+10h+arg_8]
    push    edi
    push    ecx
    mov     ecx, esi
    call    sub_46F1E0
    mov     ecx, [esp+10h+arg_4]
    xor     edx, edx
    cmp     ecx, ebx
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     short loc_46E96B

    loc_46E997:                             ; CODE XREF: sub_46E890+D9j
    mov     eax, [esp+10h+arg_0]
    pop     edi
    pop     esi
    pop     ebx
    mov     [eax], ecx
    pop     ecx
    retn    0Ch
    sub_46E890 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46E9B0 proc near                    ; CODE XREF: sub_46D860+26p
                                            ; sub_46D970+22p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    esi
    push    edi
    mov     edi, [esp+0Ch+arg_4]
    mov     esi, ecx
    push    edi
    call    sub_46FE60
    mov     esi, [esi+4]
    xor     ecx, ecx
    cmp     eax, esi
    mov     [esp+0Ch+arg_4], eax
    setz    cl
    test    cl, cl
    jnz     short loc_46E9F2
    mov     edx, [edi]
    mov     edi, [eax+0Ch]
    cmp     edx, edi
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_46E9F2
    lea     eax, [esp+0Ch+arg_4]
    mov     ecx, [eax]
    mov     eax, [esp+0Ch+arg_0]
    mov     [eax], ecx
    pop     edi
    pop     esi
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46E9F2:                             ; CODE XREF: sub_46E9B0+1Fj
                                            ; sub_46E9B0+2Ej
    lea     eax, [esp+0Ch+var_4]
    mov     [esp+0Ch+var_4], esi
    pop     edi
    pop     esi
    mov     ecx, [eax]
    mov     eax, [esp+4+arg_0]
    mov     [eax], ecx
    pop     ecx
    retn    8
    sub_46E9B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46EA10 proc near                    ; CODE XREF: sub_46DAD0+25Ep
                                            ; sub_46E890+E1p ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, dword_51E598
    mov     esi, [eax+8]
    cmp     esi, ecx
    jz      short loc_46EA66
    lea     ecx, [esp+10h+var_8]
    call    sub_4E39B0
    mov     eax, [esi]
    mov     ecx, dword_51E598
    cmp     eax, ecx
    jz      short loc_46EA4C

    loc_46EA44:                             ; CODE XREF: sub_46EA10+3Aj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_46EA44

    loc_46EA4C:                             ; CODE XREF: sub_46EA10+32j
    lea     ecx, [esp+10h+var_8]
    call    sub_4E3A70
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_46EA66:                             ; CODE XREF: sub_46EA10+1Dj
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax+8]
    jnz     short loc_46EA7C

    loc_46EA70:                             ; CODE XREF: sub_46EA10+6Aj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax+8]
    jz      short loc_46EA70

    loc_46EA7C:                             ; CODE XREF: sub_46EA10+5Ej
    mov     ecx, [edi]
    cmp     [ecx+8], eax
    jz      short loc_46EA85
    mov     [edi], eax

    loc_46EA85:                             ; CODE XREF: sub_46EA10+71j
    lea     ecx, [esp+10h+var_4]
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_46EA10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46EAA0 proc near                    ; CODE XREF: sub_46DAD0+B2p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    ebp
    mov     ebp, [esp+4+arg_0]
    cmp     ebp, eax
    jz      loc_46EB59
    push    edi
    push    esi
    push    ebx
    lea     esi, [ebp+18h]
    xor     ebx, ebx

    loc_46EAB9:                             ; CODE XREF: sub_46EAA0+B0j
    mov     eax, [esi+3Ch]
    mov     edi, [esi+38h]
    cmp     edi, eax
    mov     [esp+10h+arg_0], eax
    jz      short loc_46EAD8

    loc_46EAC7:                             ; CODE XREF: sub_46EAA0+36j
    push    edi
    call    nullsub_45
    mov     eax, [esp+10h+arg_0]
    add     edi, 0Eh
    cmp     edi, eax
    jnz     short loc_46EAC7

    loc_46EAD8:                             ; CODE XREF: sub_46EAA0+25j
    mov     eax, [esi+38h]
    push    eax
    call    sub_4B4F20
    lea     edi, [esi+24h]
    add     esp, 4
    mov     [esi+38h], ebx
    mov     [esi+3Ch], ebx
    mov     [esi+40h], ebx
    mov     ecx, [edi+8]
    mov     edx, [edi+4]
    push    ecx
    push    edx
    mov     ecx, edi
    call    nullsub_44
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     [edi+4], ebx
    mov     [edi+8], ebx
    mov     [edi+0Ch], ebx
    mov     eax, [esi]
    push    eax
    mov     [esp+14h+arg_0], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi], ebx
    mov     [esi+4], ebx
    mov     [esi+8], ebx
    mov     eax, [esi-10h]
    push    eax
    mov     [esp+14h+arg_0], eax
    call    sub_4B4F20
    mov     eax, [esp+14h+arg_4]
    mov     [esi-10h], ebx
    mov     [esi-0Ch], ebx
    mov     [esi-8], ebx
    add     ebp, 5Ch
    add     esp, 4
    add     esi, 5Ch
    cmp     ebp, eax
    jnz     loc_46EAB9
    pop     ebx
    pop     esi
    pop     edi

    loc_46EB59:                             ; CODE XREF: sub_46EAA0+Bj
    pop     ebp
    retn    8
    sub_46EAA0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46EB60 proc near                    ; CODE XREF: .text:0046C992p
                                            ; .text:0046CB11p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [eax+4]
    mov     edx, [eax]
    mov     edi, [eax]
    push    eax
    mov     [ecx], edx
    mov     ecx, [eax]
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    call    sub_4B4F20
    mov     eax, [esi+8]
    add     esp, 4
    dec     eax
    mov     [esi+8], eax
    mov     eax, [esp+8+arg_0]
    mov     [eax], edi
    pop     edi
    pop     esi
    retn    8
    sub_46EB60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46EBA0 proc near                    ; CODE XREF: .text:0046CFD3p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    mov     eax, 92492493h
    mov     ebx, [esp+14h+arg_4]
    mov     ecx, [ebp+8]
    mov     esi, [ebp+0Ch]
    sub     esi, ecx
    push    edi
    imul    esi
    add     edx, esi
    mov     [esp+18h+var_8], ebp
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ebx
    jnb     loc_46ED86
    mov     edi, [ebp+4]
    test    edi, edi
    jnz     short loc_46EBDF
    xor     edx, edx
    jmp     short loc_46EBF6
    ; ---------------------------------------------------------------------------

    loc_46EBDF:                             ; CODE XREF: sub_46EBA0+39j
    mov     esi, ecx
    mov     eax, 92492493h
    sub     esi, edi
    imul    esi
    add     edx, esi
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_46EBF6:                             ; CODE XREF: sub_46EBA0+3Dj
    cmp     ebx, edx
    jnb     short loc_46EC1D
    test    edi, edi
    jnz     short loc_46EC02
    xor     esi, esi
    jmp     short loc_46EC1F
    ; ---------------------------------------------------------------------------

    loc_46EC02:                             ; CODE XREF: sub_46EBA0+5Cj
    mov     esi, ecx
    mov     eax, 92492493h
    sub     esi, edi
    imul    esi
    add     edx, esi
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     esi, edx
    jmp     short loc_46EC1F
    ; ---------------------------------------------------------------------------

    loc_46EC1D:                             ; CODE XREF: sub_46EBA0+58j
    mov     esi, ebx

    loc_46EC1F:                             ; CODE XREF: sub_46EBA0+60j
                                            ; sub_46EBA0+7Bj
    test    edi, edi
    jnz     short loc_46EC27
    xor     edx, edx
    jmp     short loc_46EC3C
    ; ---------------------------------------------------------------------------

    loc_46EC27:                             ; CODE XREF: sub_46EBA0+81j
    sub     ecx, edi
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_46EC3C:                             ; CODE XREF: sub_46EBA0+85j
    lea     eax, [edx+esi]
    test    eax, eax
    mov     [esp+18h+arg_4], eax
    jge     short loc_46EC49
    xor     eax, eax

    loc_46EC49:                             ; CODE XREF: sub_46EBA0+A5j
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    shl     edx, 1
    push    edx                             ; int
    call    sub_4B4F10
    mov     esi, [esp+1Ch+arg_0]
    mov     [esp+1Ch+var_4], eax
    mov     edx, eax
    mov     eax, [ebp+4]
    add     esp, 4
    cmp     eax, esi
    jz      short loc_46EC9A

    loc_46EC6C:                             ; CODE XREF: sub_46EBA0+F4j
    test    edx, edx
    jz      short loc_46EC8C
    mov     ecx, eax
    mov     edi, edx
    mov     ebp, [ecx]
    mov     [edi], ebp
    mov     ebp, [ecx+4]
    mov     [edi+4], ebp
    mov     ebp, [ecx+8]
    mov     [edi+8], ebp
    mov     cx, [ecx+0Ch]
    mov     [edi+0Ch], cx

    loc_46EC8C:                             ; CODE XREF: sub_46EBA0+CEj
    add     eax, 0Eh
    add     edx, 0Eh
    cmp     eax, esi
    jnz     short loc_46EC6C
    mov     ebp, [esp+18h+var_8]

    loc_46EC9A:                             ; CODE XREF: sub_46EBA0+CAj
    test    ebx, ebx
    mov     eax, edx
    jbe     short loc_46ECD8
    mov     [esp+18h+arg_0], ebx

    loc_46ECA4:                             ; CODE XREF: sub_46EBA0+132j
    test    eax, eax
    jz      short loc_46ECC6
    mov     ecx, [esp+18h+arg_8]
    mov     edi, eax
    mov     ebp, [ecx]
    mov     [edi], ebp
    mov     ebp, [ecx+4]
    mov     [edi+4], ebp
    mov     ebp, [ecx+8]
    mov     [edi+8], ebp
    mov     cx, [ecx+0Ch]
    mov     [edi+0Ch], cx

    loc_46ECC6:                             ; CODE XREF: sub_46EBA0+106j
    mov     ecx, [esp+18h+arg_0]
    add     eax, 0Eh
    dec     ecx
    mov     [esp+18h+arg_0], ecx
    jnz     short loc_46ECA4
    mov     ebp, [esp+18h+var_8]

    loc_46ECD8:                             ; CODE XREF: sub_46EBA0+FEj
    mov     edi, [ebp+8]
    mov     eax, ebx
    shl     eax, 3
    sub     eax, ebx
    shl     eax, 1
    cmp     esi, edi
    lea     ecx, [edx+eax]
    jz      short loc_46ED21
    sub     esi, edx
    add     esi, ecx
    sub     esi, eax
    mov     eax, esi

    loc_46ECF3:                             ; CODE XREF: sub_46EBA0+17Bj
    test    ecx, ecx
    jz      short loc_46ED13
    mov     edx, eax
    mov     esi, ecx
    mov     ebp, [edx]
    mov     [esi], ebp
    mov     ebp, [edx+4]
    mov     [esi+4], ebp
    mov     ebp, [edx+8]
    mov     [esi+8], ebp
    mov     dx, [edx+0Ch]
    mov     [esi+0Ch], dx

    loc_46ED13:                             ; CODE XREF: sub_46EBA0+155j
    add     eax, 0Eh
    add     ecx, 0Eh
    cmp     eax, edi
    jnz     short loc_46ECF3
    mov     ebp, [esp+18h+var_8]

    loc_46ED21:                             ; CODE XREF: sub_46EBA0+149j
    mov     eax, [ebp+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     eax, [esp+1Ch+arg_4]
    mov     esi, [esp+1Ch+var_4]
    mov     ecx, eax
    add     esp, 4
    shl     ecx, 3
    sub     ecx, eax
    mov     eax, [ebp+4]
    test    eax, eax
    lea     edx, [esi+ecx*2]
    mov     [ebp+0Ch], edx
    jnz     short loc_46ED51
    xor     edx, edx
    jmp     short loc_46ED69
    ; ---------------------------------------------------------------------------

    loc_46ED51:                             ; CODE XREF: sub_46EBA0+1ABj
    mov     ecx, [ebp+8]
    sub     ecx, eax
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_46ED69:                             ; CODE XREF: sub_46EBA0+1AFj
    lea     eax, [ebx+edx]
    mov     [ebp+4], esi
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [esi+ecx*2]
    mov     [ebp+8], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46ED86:                             ; CODE XREF: sub_46EBA0+2Ej
    mov     edi, [esp+18h+arg_0]
    mov     esi, ecx
    sub     esi, edi
    mov     eax, 92492493h
    imul    esi
    add     edx, esi
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ebx
    jnb     loc_46EE85
    mov     esi, ebx
    shl     esi, 3
    sub     esi, ebx
    shl     esi, 1
    cmp     edi, ecx
    mov     [esp+18h+arg_0], esi
    lea     edx, [edi+esi]
    jz      short loc_46EDF3
    mov     eax, edx
    sub     eax, esi

    loc_46EDC1:                             ; CODE XREF: sub_46EBA0+24Dj
    test    edx, edx
    jz      short loc_46EDE5
    mov     esi, eax
    mov     ebx, edx
    mov     ebp, [esi]
    mov     [ebx], ebp
    mov     ebp, [esi+4]
    mov     [ebx+4], ebp
    mov     ebp, [esi+8]
    mov     [ebx+8], ebp
    mov     si, [esi+0Ch]
    mov     [ebx+0Ch], si
    mov     ebx, [esp+18h+arg_4]

    loc_46EDE5:                             ; CODE XREF: sub_46EBA0+223j
    add     eax, 0Eh
    add     edx, 0Eh
    cmp     eax, ecx
    jnz     short loc_46EDC1
    mov     ebp, [esp+18h+var_8]

    loc_46EDF3:                             ; CODE XREF: sub_46EBA0+21Bj
    mov     esi, [ebp+8]
    mov     eax, 92492493h
    mov     ecx, esi
    sub     ecx, edi
    imul    ecx
    add     edx, ecx
    mov     eax, esi
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    sub     ebx, edx
    mov     edx, [esp+18h+arg_8]
    mov     ecx, ebx
    jz      short loc_46EE43

    loc_46EE19:                             ; CODE XREF: sub_46EBA0+29Dj
    test    eax, eax
    jz      short loc_46EE39
    mov     esi, edx
    mov     ebx, eax
    mov     ebp, [esi]
    mov     [ebx], ebp
    mov     ebp, [esi+4]
    mov     [ebx+4], ebp
    mov     ebp, [esi+8]
    mov     [ebx+8], ebp
    mov     si, [esi+0Ch]
    mov     [ebx+0Ch], si

    loc_46EE39:                             ; CODE XREF: sub_46EBA0+27Bj
    add     eax, 0Eh
    dec     ecx
    jnz     short loc_46EE19
    mov     ebp, [esp+18h+var_8]

    loc_46EE43:                             ; CODE XREF: sub_46EBA0+277j
    mov     ecx, [ebp+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_46EE6F

    loc_46EE4C:                             ; CODE XREF: sub_46EBA0+2CDj
    mov     esi, edx
    mov     edi, eax
    add     eax, 0Eh
    mov     ebx, [esi]
    cmp     eax, ecx
    mov     [edi], ebx
    mov     ebx, [esi+4]
    mov     [edi+4], ebx
    mov     ebx, [esi+8]
    mov     [edi+8], ebx
    mov     si, [esi+0Ch]
    mov     [edi+0Ch], si
    jnz     short loc_46EE4C

    loc_46EE6F:                             ; CODE XREF: sub_46EBA0+2AAj
    mov     edx, [esp+18h+arg_0]
    mov     eax, [ebp+8]
    add     eax, edx
    mov     [ebp+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46EE85:                             ; CODE XREF: sub_46EBA0+203j
    test    ebx, ebx
    jbe     loc_46EF3E
    mov     esi, ebx
    mov     eax, ecx
    shl     esi, 3
    sub     esi, ebx
    mov     edx, ecx
    shl     esi, 1
    sub     eax, esi
    mov     [esp+18h+arg_0], esi
    cmp     eax, ecx
    jz      short loc_46EED6

    loc_46EEA4:                             ; CODE XREF: sub_46EBA0+330j
    test    edx, edx
    jz      short loc_46EEC8
    mov     esi, eax
    mov     ebx, edx
    mov     ebp, [esi]
    mov     [ebx], ebp
    mov     ebp, [esi+4]
    mov     [ebx+4], ebp
    mov     ebp, [esi+8]
    mov     [ebx+8], ebp
    mov     si, [esi+0Ch]
    mov     [ebx+0Ch], si
    mov     esi, [esp+18h+arg_0]

    loc_46EEC8:                             ; CODE XREF: sub_46EBA0+306j
    add     eax, 0Eh
    add     edx, 0Eh
    cmp     eax, ecx
    jnz     short loc_46EEA4
    mov     ebp, [esp+18h+var_8]

    loc_46EED6:                             ; CODE XREF: sub_46EBA0+302j
    mov     ecx, [ebp+8]
    mov     eax, ecx
    sub     eax, esi
    cmp     edi, eax
    jz      short loc_46EF07

    loc_46EEE1:                             ; CODE XREF: sub_46EBA0+365j
    sub     eax, 0Eh
    sub     ecx, 0Eh
    mov     edx, eax
    mov     ebx, ecx
    cmp     eax, edi
    mov     ebp, [edx]
    mov     [ebx], ebp
    mov     ebp, [edx+4]
    mov     [ebx+4], ebp
    mov     ebp, [edx+8]
    mov     [ebx+8], ebp
    mov     dx, [edx+0Ch]
    mov     [ebx+0Ch], dx
    jnz     short loc_46EEE1

    loc_46EF07:                             ; CODE XREF: sub_46EBA0+33Fj
    lea     ecx, [edi+esi]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_46EF37
    mov     edx, [esp+18h+arg_8]

    loc_46EF14:                             ; CODE XREF: sub_46EBA0+395j
    mov     edi, edx
    mov     ebx, eax
    add     eax, 0Eh
    mov     ebp, [edi]
    cmp     eax, ecx
    mov     [ebx], ebp
    mov     ebp, [edi+4]
    mov     [ebx+4], ebp
    mov     ebp, [edi+8]
    mov     [ebx+8], ebp
    mov     di, [edi+0Ch]
    mov     [ebx+0Ch], di
    jnz     short loc_46EF14

    loc_46EF37:                             ; CODE XREF: sub_46EBA0+36Ej
    mov     eax, [esp+18h+var_8]
    add     [eax+8], esi

    loc_46EF3E:                             ; CODE XREF: sub_46EBA0+2E7j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_46EBA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46EF50 proc near                    ; CODE XREF: sub_46D040+110p
                                            ; sub_46D6C0+15Ap

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     bl, 1
    lea     ecx, [esp+28h+var_10]
    mov     [esp+28h+var_C], edi
    mov     esi, [edi+4]
    mov     [esp+28h+var_18], esi
    mov     ebp, [esi+4]
    call    sub_4E39B0
    mov     ecx, dword_51E598
    cmp     ebp, ecx
    jz      short loc_46EFA3
    mov     eax, [esp+28h+arg_4]
    mov     eax, [eax]

    loc_46EF82:                             ; CODE XREF: sub_46EF50+4Dj
    mov     ebx, [ebp+0Ch]
    mov     [esp+28h+var_18], ebp
    cmp     eax, ebx
    sbb     ebx, ebx
    neg     ebx
    test    bl, bl
    jz      short loc_46EF98
    mov     ebp, [ebp+0]
    jmp     short loc_46EF9B
    ; ---------------------------------------------------------------------------

    loc_46EF98:                             ; CODE XREF: sub_46EF50+41j
    mov     ebp, [ebp+8]

    loc_46EF9B:                             ; CODE XREF: sub_46EF50+46j
    cmp     ebp, ecx
    jnz     short loc_46EF82
    mov     esi, [esp+28h+var_18]

    loc_46EFA3:                             ; CODE XREF: sub_46EF50+2Aj
    lea     ecx, [esp+28h+var_10]
    call    sub_4E3A70
    mov     al, [edi+8]
    test    al, al
    jz      loc_46F156
    lea     ecx, [esp+28h+var_8]
    call    sub_4E39B0
    xor     ebx, ebx
    mov     ecx, edi
    push    ebx
    push    esi
    call    sub_46FF70
    mov     ecx, dword_51E598
    mov     edx, eax
    mov     [esp+28h+var_4], edx
    mov     [edx], ecx
    mov     eax, dword_51E598
    mov     [edx+8], eax
    lea     eax, [edx+0Ch]
    cmp     eax, ebx
    jz      short loc_46EFFD
    mov     esi, [esp+28h+arg_4]
    mov     ecx, 5
    mov     edi, eax
    rep movsd
    mov     esi, [esp+28h+var_18]
    mov     edi, [esp+28h+var_C]

    loc_46EFFD:                             ; CODE XREF: sub_46EF50+96j
    mov     ecx, [edi+0Ch]
    mov     eax, [edi+4]
    inc     ecx
    cmp     esi, eax
    mov     [edi+0Ch], ecx
    jz      short loc_46F036
    cmp     ebp, dword_51E598
    jnz     short loc_46F036
    mov     ecx, [esp+28h+arg_4]
    mov     eax, [ecx]
    mov     ecx, [esi+0Ch]
    cmp     eax, ecx
    sbb     ecx, ecx
    neg     ecx
    test    cl, cl
    jnz     short loc_46F036
    mov     [esi+8], edx
    mov     eax, [edi+4]
    cmp     esi, [eax+8]
    jnz     short loc_46F050
    mov     [eax+8], edx
    jmp     short loc_46F050
    ; ---------------------------------------------------------------------------

    loc_46F036:                             ; CODE XREF: sub_46EF50+B9j
                                            ; sub_46EF50+C1j ...
    mov     [esi], edx
    mov     eax, [edi+4]
    cmp     esi, eax
    jnz     short loc_46F04A
    mov     [eax+4], edx
    mov     eax, [edi+4]
    mov     [eax+8], edx
    jmp     short loc_46F050
    ; ---------------------------------------------------------------------------

    loc_46F04A:                             ; CODE XREF: sub_46EF50+EDj
    cmp     esi, [eax]
    jnz     short loc_46F050
    mov     [eax], edx

    loc_46F050:                             ; CODE XREF: sub_46EF50+DFj
                                            ; sub_46EF50+E4j ...
    mov     ecx, [edi+4]
    mov     esi, edx
    cmp     edx, [ecx+4]
    jz      loc_46F128

    loc_46F05E:                             ; CODE XREF: sub_46EF50+1D2j
    mov     eax, [esi+4]
    cmp     [eax+20h], ebx
    jnz     loc_46F128
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     short loc_46F0CC
    mov     ecx, [edx+8]
    cmp     [ecx+20h], ebx
    jnz     short loc_46F09A
    mov     edx, 1
    mov     [eax+20h], edx
    mov     [ecx+20h], edx
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+20h], ebx
    mov     ecx, [esi+4]
    mov     esi, [ecx+4]
    jmp     loc_46F11C
    ; ---------------------------------------------------------------------------

    loc_46F09A:                             ; CODE XREF: sub_46EF50+129j
    cmp     esi, [eax+8]
    jnz     short loc_46F0A9
    mov     esi, eax
    mov     ecx, edi
    push    esi
    call    sub_46FEB0

    loc_46F0A9:                             ; CODE XREF: sub_46EF50+14Dj
    mov     edx, [esi+4]
    mov     dword ptr [edx+20h], 1
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+20h], ebx
    mov     edx, [esi+4]
    mov     ecx, edi
    mov     eax, [edx+4]
    push    eax
    call    sub_46FF10
    jmp     short loc_46F11C
    ; ---------------------------------------------------------------------------

    loc_46F0CC:                             ; CODE XREF: sub_46EF50+121j
    cmp     [ecx+20h], ebx
    jnz     short loc_46F0ED
    mov     edx, 1
    mov     [eax+20h], edx
    mov     [ecx+20h], edx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     [edx+20h], ebx
    mov     eax, [esi+4]
    mov     esi, [eax+4]
    jmp     short loc_46F11C
    ; ---------------------------------------------------------------------------

    loc_46F0ED:                             ; CODE XREF: sub_46EF50+17Fj
    cmp     esi, [eax]
    jnz     short loc_46F0FB
    mov     esi, eax
    mov     ecx, edi
    push    esi
    call    sub_46FF10

    loc_46F0FB:                             ; CODE XREF: sub_46EF50+19Fj
    mov     ecx, [esi+4]
    mov     dword ptr [ecx+20h], 1
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+20h], ebx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     ecx, edi
    push    edx
    call    sub_46FEB0

    loc_46F11C:                             ; CODE XREF: sub_46EF50+145j
                                            ; sub_46EF50+17Aj ...
    mov     eax, [edi+4]
    cmp     esi, [eax+4]
    jnz     loc_46F05E

    loc_46F128:                             ; CODE XREF: sub_46EF50+108j
                                            ; sub_46EF50+114j
    mov     ecx, [edi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+28h+var_8]
    mov     dword ptr [edx+20h], 1
    call    sub_4E3A70
    mov     eax, [esp+28h+arg_0]
    mov     ecx, [esp+28h+var_4]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46F156:                             ; CODE XREF: sub_46EF50+61j
    mov     ecx, esi
    test    bl, bl
    mov     [esp+28h+var_14], ecx
    jz      short loc_46F189
    mov     edx, [edi+4]
    xor     eax, eax
    cmp     esi, [edx]
    setz    al
    test    al, al
    jz      short loc_46F17C
    mov     ecx, [esp+28h+arg_4]
    lea     edx, [esp+28h+arg_4]
    push    ecx
    push    esi
    push    ebp
    push    edx
    jmp     short loc_46F1A2
    ; ---------------------------------------------------------------------------

    loc_46F17C:                             ; CODE XREF: sub_46EF50+21Cj
    lea     ecx, [esp+28h+var_14]
    call    sub_46FF90
    mov     ecx, [esp+28h+var_14]

    loc_46F189:                             ; CODE XREF: sub_46EF50+20Ej
    mov     eax, [esp+28h+arg_4]
    mov     edx, [ecx+0Ch]
    cmp     edx, [eax]
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_46F1BF
    push    eax
    push    esi
    lea     eax, [esp+30h+arg_4]
    push    ebp
    push    eax

    loc_46F1A2:                             ; CODE XREF: sub_46EF50+22Aj
    mov     ecx, edi
    call    sub_46FB80
    mov     ecx, [eax]
    mov     eax, [esp+28h+arg_0]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_46F1BF:                             ; CODE XREF: sub_46EF50+248j
    mov     eax, [esp+28h+arg_0]
    pop     edi
    pop     esi
    pop     ebp
    mov     [eax], ecx
    mov     byte ptr [eax+4], 0
    pop     ebx
    add     esp, 18h
    retn    8
    sub_46EF50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46F1E0 proc near                    ; CODE XREF: sub_46E890+EEp

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    push    ebx
    push    ebp
    mov     [esp+1Ch+var_14], ecx
    push    esi
    push    edi
    mov     edi, [esp+24h+arg_4]
    lea     ecx, [esp+24h+arg_4]
    call    sub_46EA10
    mov     ebp, edi
    lea     ecx, [esp+24h+var_4]
    mov     [esp+24h+var_10], ebp
    call    sub_4E39B0
    mov     esi, [edi]
    mov     edx, dword_51E598
    lea     ebx, [edi+8]
    cmp     esi, edx
    mov     eax, ebx
    jnz     short loc_46F21C
    mov     esi, [ebx]
    jmp     short loc_46F257
    ; ---------------------------------------------------------------------------

    loc_46F21C:                             ; CODE XREF: sub_46F1E0+36j
    mov     ecx, [ebx]
    cmp     ecx, edx
    jz      short loc_46F257
    mov     esi, ecx
    lea     ecx, [esp+24h+var_C]
    call    sub_4E39B0
    mov     eax, [esi]
    mov     ecx, dword_51E598
    cmp     eax, ecx
    jz      short loc_46F241

    loc_46F239:                             ; CODE XREF: sub_46F1E0+5Fj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_46F239

    loc_46F241:                             ; CODE XREF: sub_46F1E0+57j
    lea     ecx, [esp+24h+var_C]
    call    sub_4E3A70
    lea     eax, [esi+8]
    mov     [esp+24h+var_10], esi
    mov     ebp, [esp+24h+var_10]
    mov     esi, [eax]

    loc_46F257:                             ; CODE XREF: sub_46F1E0+3Aj
                                            ; sub_46F1E0+40j
    cmp     ebp, edi
    jz      short loc_46F2BE
    mov     ecx, [edi]
    mov     [ecx+4], ebp
    mov     edx, [edi]
    mov     [ebp+0], edx
    mov     ecx, [ebx]
    cmp     ebp, ecx
    jnz     short loc_46F270
    mov     [esi+4], ebp
    jmp     short loc_46F284
    ; ---------------------------------------------------------------------------

    loc_46F270:                             ; CODE XREF: sub_46F1E0+89j
    mov     ecx, [ebp+4]
    mov     [esi+4], ecx
    mov     edx, [ebp+4]
    mov     [edx], esi
    mov     ecx, [ebx]
    mov     [eax], ecx
    mov     edx, [ebx]
    mov     [edx+4], ebp

    loc_46F284:                             ; CODE XREF: sub_46F1E0+8Ej
    mov     eax, [esp+24h+var_14]
    mov     eax, [eax+4]
    cmp     [eax+4], edi
    jnz     short loc_46F295
    mov     [eax+4], ebp
    jmp     short loc_46F2A3
    ; ---------------------------------------------------------------------------

    loc_46F295:                             ; CODE XREF: sub_46F1E0+AEj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_46F2A0
    mov     [eax], ebp
    jmp     short loc_46F2A3
    ; ---------------------------------------------------------------------------

    loc_46F2A0:                             ; CODE XREF: sub_46F1E0+BAj
    mov     [eax+8], ebp

    loc_46F2A3:                             ; CODE XREF: sub_46F1E0+B3j
                                            ; sub_46F1E0+BEj
    mov     ecx, [edi+4]
    mov     [esp+24h+var_10], edi
    mov     [ebp+4], ecx
    mov     edx, [edi+20h]
    mov     eax, [ebp+20h]
    mov     [ebp+20h], edx
    mov     [edi+20h], eax
    jmp     loc_46F376
    ; ---------------------------------------------------------------------------

    loc_46F2BE:                             ; CODE XREF: sub_46F1E0+79j
    mov     eax, [ebp+4]
    mov     ebp, [esp+24h+var_14]
    mov     [esi+4], eax
    mov     eax, [ebp+4]
    cmp     [eax+4], edi
    jnz     short loc_46F2D5
    mov     [eax+4], esi
    jmp     short loc_46F2E3
    ; ---------------------------------------------------------------------------

    loc_46F2D5:                             ; CODE XREF: sub_46F1E0+EEj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_46F2E0
    mov     [eax], esi
    jmp     short loc_46F2E3
    ; ---------------------------------------------------------------------------

    loc_46F2E0:                             ; CODE XREF: sub_46F1E0+FAj
    mov     [eax+8], esi

    loc_46F2E3:                             ; CODE XREF: sub_46F1E0+F3j
                                            ; sub_46F1E0+FEj
    mov     eax, [ebp+4]
    cmp     [eax], edi
    jnz     short loc_46F32A
    mov     ecx, [ebx]
    mov     edx, dword_51E598
    cmp     ecx, edx
    jnz     short loc_46F2FD
    mov     edx, [edi+4]
    mov     [eax], edx
    jmp     short loc_46F32A
    ; ---------------------------------------------------------------------------

    loc_46F2FD:                             ; CODE XREF: sub_46F1E0+114j
    lea     ecx, [esp+24h+var_8]
    mov     ebx, esi
    call    sub_4E39B0
    mov     eax, [esi]
    mov     ecx, dword_51E598
    cmp     eax, ecx
    jz      short loc_46F31C

    loc_46F314:                             ; CODE XREF: sub_46F1E0+13Aj
    mov     ebx, eax
    mov     eax, [ebx]
    cmp     eax, ecx
    jnz     short loc_46F314

    loc_46F31C:                             ; CODE XREF: sub_46F1E0+132j
    lea     ecx, [esp+24h+var_8]
    call    sub_4E3A70
    mov     eax, [ebp+4]
    mov     [eax], ebx

    loc_46F32A:                             ; CODE XREF: sub_46F1E0+108j
                                            ; sub_46F1E0+11Bj
    mov     eax, [ebp+4]
    cmp     [eax+8], edi
    jnz     short loc_46F376
    mov     ecx, [edi]
    mov     edx, dword_51E598
    cmp     ecx, edx
    jnz     short loc_46F346
    mov     edx, [edi+4]
    mov     [eax+8], edx
    jmp     short loc_46F376
    ; ---------------------------------------------------------------------------

    loc_46F346:                             ; CODE XREF: sub_46F1E0+15Cj
    lea     ecx, [esp+24h+var_8]
    mov     edi, esi
    call    sub_4E39B0
    mov     eax, [esi+8]
    mov     ecx, dword_51E598
    cmp     eax, ecx
    jz      short loc_46F367

    loc_46F35E:                             ; CODE XREF: sub_46F1E0+185j
    mov     edi, eax
    mov     eax, [edi+8]
    cmp     eax, ecx
    jnz     short loc_46F35E

    loc_46F367:                             ; CODE XREF: sub_46F1E0+17Cj
    lea     ecx, [esp+24h+var_8]
    call    sub_4E3A70
    mov     eax, [ebp+4]
    mov     [eax+8], edi

    loc_46F376:                             ; CODE XREF: sub_46F1E0+D9j
                                            ; sub_46F1E0+150j ...
    mov     ecx, [esp+24h+var_10]
    mov     ebp, 1
    cmp     [ecx+20h], ebp
    jnz     loc_46F68F
    mov     edx, [esp+24h+var_14]
    mov     eax, [edx+4]
    cmp     esi, [eax+4]
    jz      loc_46F68C
    xor     ebx, ebx

    loc_46F39A:                             ; CODE XREF: sub_46F1E0+2E7j
    cmp     [esi+20h], ebp
    jnz     loc_46F68C
    mov     eax, [esi+4]
    mov     edi, [eax]
    cmp     esi, edi
    jnz     loc_46F437
    mov     edi, [eax+8]
    cmp     [edi+20h], ebx
    jnz     short loc_46F41B
    mov     [edi+20h], ebp
    mov     ecx, [esi+4]
    mov     [ecx+20h], ebx
    mov     edi, [esi+4]
    lea     ecx, [esp+24h+var_8]
    call    sub_4E39B0
    mov     eax, [edi+8]
    mov     edx, [eax]
    mov     [edi+8], edx
    mov     ecx, [eax]
    cmp     ecx, dword_51E598
    jz      short loc_46F3E2
    mov     [ecx+4], edi

    loc_46F3E2:                             ; CODE XREF: sub_46F1E0+1FDj
    mov     ecx, [edi+4]
    mov     edx, [esp+24h+var_14]
    mov     [eax+4], ecx
    mov     ecx, [edx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_46F3F9
    mov     [ecx+4], eax
    jmp     short loc_46F407
    ; ---------------------------------------------------------------------------

    loc_46F3F9:                             ; CODE XREF: sub_46F1E0+212j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_46F404
    mov     [ecx], eax
    jmp     short loc_46F407
    ; ---------------------------------------------------------------------------

    loc_46F404:                             ; CODE XREF: sub_46F1E0+21Ej
    mov     [ecx+8], eax

    loc_46F407:                             ; CODE XREF: sub_46F1E0+217j
                                            ; sub_46F1E0+222j
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    sub_4E3A70
    mov     eax, [esi+4]
    mov     edi, [eax+8]

    loc_46F41B:                             ; CODE XREF: sub_46F1E0+1D6j
    mov     ecx, [edi]
    cmp     [ecx+20h], ebp
    jnz     loc_46F4D2
    mov     edx, [edi+8]
    cmp     [edx+20h], ebp
    jnz     loc_46F4D2
    jmp     loc_46F4B7
    ; ---------------------------------------------------------------------------

    loc_46F437:                             ; CODE XREF: sub_46F1E0+1CAj
    cmp     [edi+20h], ebx
    jnz     short loc_46F4A0
    mov     [edi+20h], ebp
    mov     eax, [esi+4]
    lea     ecx, [esp+24h+var_C]
    mov     [eax+20h], ebx
    mov     edi, [esi+4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51E598
    jz      short loc_46F466
    mov     [ecx+4], edi

    loc_46F466:                             ; CODE XREF: sub_46F1E0+281j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_46F47D
    mov     [ecx+4], eax
    jmp     short loc_46F48C
    ; ---------------------------------------------------------------------------

    loc_46F47D:                             ; CODE XREF: sub_46F1E0+296j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_46F48A
    mov     [ecx+8], eax
    jmp     short loc_46F48C
    ; ---------------------------------------------------------------------------

    loc_46F48A:                             ; CODE XREF: sub_46F1E0+2A3j
    mov     [ecx], eax

    loc_46F48C:                             ; CODE XREF: sub_46F1E0+29Bj
                                            ; sub_46F1E0+2A8j
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_C]
    mov     [edi+4], eax
    call    sub_4E3A70
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_46F4A0:                             ; CODE XREF: sub_46F1E0+25Aj
    mov     eax, [edi+8]
    cmp     [eax+20h], ebp
    jnz     loc_46F5BC
    mov     ecx, [edi]
    cmp     [ecx+20h], ebp
    jnz     loc_46F5BC

    loc_46F4B7:                             ; CODE XREF: sub_46F1E0+252j
    mov     edx, [esp+24h+var_14]
    mov     [edi+20h], ebx
    mov     esi, [esi+4]
    mov     eax, [edx+4]
    cmp     esi, [eax+4]
    jnz     loc_46F39A
    jmp     loc_46F68C
    ; ---------------------------------------------------------------------------

    loc_46F4D2:                             ; CODE XREF: sub_46F1E0+240j
                                            ; sub_46F1E0+24Cj
    mov     ecx, [edi+8]
    cmp     [ecx+20h], ebp
    jnz     short loc_46F53B
    mov     edx, [edi]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+20h], ebp
    mov     [edi+20h], ebx
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51E598
    jz      short loc_46F500
    mov     [ecx+4], edi

    loc_46F500:                             ; CODE XREF: sub_46F1E0+31Bj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_46F517
    mov     [ecx+4], eax
    jmp     short loc_46F526
    ; ---------------------------------------------------------------------------

    loc_46F517:                             ; CODE XREF: sub_46F1E0+330j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_46F524
    mov     [ecx+8], eax
    jmp     short loc_46F526
    ; ---------------------------------------------------------------------------

    loc_46F524:                             ; CODE XREF: sub_46F1E0+33Dj
    mov     [ecx], eax

    loc_46F526:                             ; CODE XREF: sub_46F1E0+335j
                                            ; sub_46F1E0+342j
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    sub_4E3A70
    mov     edx, [esi+4]
    mov     edi, [edx+8]

    loc_46F53B:                             ; CODE XREF: sub_46F1E0+2F8j
    mov     eax, [esi+4]
    mov     ecx, [eax+20h]
    mov     [edi+20h], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+20h], ebp
    mov     eax, [edi+8]
    mov     [eax+20h], ebp
    mov     edi, [esi+4]
    call    sub_4E39B0
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_51E598
    jz      short loc_46F571
    mov     [ecx+4], edi

    loc_46F571:                             ; CODE XREF: sub_46F1E0+38Cj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_46F594
    mov     [ecx+4], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_46F687
    ; ---------------------------------------------------------------------------

    loc_46F594:                             ; CODE XREF: sub_46F1E0+3A1j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_46F5AB
    mov     [ecx], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_46F687
    ; ---------------------------------------------------------------------------

    loc_46F5AB:                             ; CODE XREF: sub_46F1E0+3B9j
    mov     [ecx+8], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_46F687
    ; ---------------------------------------------------------------------------

    loc_46F5BC:                             ; CODE XREF: sub_46F1E0+2C6j
                                            ; sub_46F1E0+2D1j
    mov     edx, [edi]
    cmp     [edx+20h], ebp
    jnz     short loc_46F622
    mov     eax, [edi+8]
    lea     ecx, [esp+24h+var_8]
    mov     [eax+20h], ebp
    mov     [edi+20h], ebx
    call    sub_4E39B0
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_51E598
    jz      short loc_46F5EA
    mov     [ecx+4], edi

    loc_46F5EA:                             ; CODE XREF: sub_46F1E0+405j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_46F601
    mov     [ecx+4], eax
    jmp     short loc_46F60F
    ; ---------------------------------------------------------------------------

    loc_46F601:                             ; CODE XREF: sub_46F1E0+41Aj
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_46F60C
    mov     [ecx], eax
    jmp     short loc_46F60F
    ; ---------------------------------------------------------------------------

    loc_46F60C:                             ; CODE XREF: sub_46F1E0+426j
    mov     [ecx+8], eax

    loc_46F60F:                             ; CODE XREF: sub_46F1E0+41Fj
                                            ; sub_46F1E0+42Aj
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    sub_4E3A70
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_46F622:                             ; CODE XREF: sub_46F1E0+3E1j
    mov     eax, [esi+4]
    mov     ecx, [eax+20h]
    mov     [edi+20h], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+20h], ebp
    mov     eax, [edi]
    mov     [eax+20h], ebp
    mov     edi, [esi+4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51E598
    jz      short loc_46F657
    mov     [ecx+4], edi

    loc_46F657:                             ; CODE XREF: sub_46F1E0+472j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_46F66E
    mov     [ecx+4], eax
    jmp     short loc_46F67D
    ; ---------------------------------------------------------------------------

    loc_46F66E:                             ; CODE XREF: sub_46F1E0+487j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_46F67B
    mov     [ecx+8], eax
    jmp     short loc_46F67D
    ; ---------------------------------------------------------------------------

    loc_46F67B:                             ; CODE XREF: sub_46F1E0+494j
    mov     [ecx], eax

    loc_46F67D:                             ; CODE XREF: sub_46F1E0+48Cj
                                            ; sub_46F1E0+499j
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]

    loc_46F687:                             ; CODE XREF: sub_46F1E0+3AFj
                                            ; sub_46F1E0+3C6j ...
    call    sub_4E3A70

    loc_46F68C:                             ; CODE XREF: sub_46F1E0+1B2j
                                            ; sub_46F1E0+1BDj ...
    mov     [esi+20h], ebp

    loc_46F68F:                             ; CODE XREF: sub_46F1E0+1A2j
    mov     edx, [esp+24h+var_10]
    push    edx
    call    sub_4B4F20
    mov     eax, [esp+28h+var_14]
    mov     esi, [esp+28h+arg_0]
    add     esp, 4
    mov     ecx, [eax+0Ch]
    dec     ecx
    mov     [eax+0Ch], ecx
    mov     eax, [esp+24h+arg_4]
    lea     ecx, [esp+24h+var_4]
    mov     [esi], eax
    call    sub_4E3A70
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    sub_46F1E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46F6D0 proc near                    ; CODE XREF: sub_46E890+6Dp
                                            ; sub_46F6D0+24p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    lea     ecx, [esp+10h+var_4]
    call    sub_4E39B0
    mov     edi, [esp+10h+arg_0]
    mov     eax, dword_51E598
    cmp     edi, eax
    mov     esi, edi
    jz      short loc_46F70F

    loc_46F6EE:                             ; CODE XREF: sub_46F6D0+3Dj
    mov     eax, [esi+8]
    mov     ecx, ebx
    push    eax
    call    sub_46F6D0
    mov     esi, [esi]
    push    edi
    call    sub_4B4F20
    mov     eax, dword_51E598
    add     esp, 4
    cmp     esi, eax
    mov     edi, esi
    jnz     short loc_46F6EE

    loc_46F70F:                             ; CODE XREF: sub_46F6D0+1Cj
    lea     ecx, [esp+10h+var_4]
    call    sub_4E3A70
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    sub_46F6D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46F720 proc near                    ; CODE XREF: sub_46D040+1Cp

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    lea     ecx, [esp+10h+var_4]
    call    sub_4E39B0
    mov     eax, dword_51E598
    xor     ebx, ebx
    cmp     eax, ebx
    jnz     short loc_46F75D
    push    24h                             ; int
    call    sub_4B4F10
    mov     [eax+4], ebx
    mov     dword ptr [eax+20h], 1
    mov     dword_51E598, eax
    mov     [eax], ebx
    mov     eax, dword_51E598
    add     esp, 4
    mov     [eax+8], ebx

    loc_46F75D:                             ; CODE XREF: sub_46F720+18j
    mov     edi, dword_51E59C
    push    24h                             ; int
    inc     edi
    mov     dword_51E59C, edi
    mov     edi, dword_51E598
    call    sub_4B4F10
    mov     [eax+4], edi
    mov     [eax+20h], ebx
    mov     [esi+4], eax
    mov     [esi+0Ch], ebx
    mov     [eax], eax
    mov     esi, [esi+4]
    add     esp, 4
    lea     ecx, [esp+10h+var_4]
    mov     [esi+8], esi
    call    sub_4E3A70
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    sub_46F720 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46F7A0 proc near                    ; CODE XREF: sub_46DAD0+1ADp

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     eax, 0B21642C9h
    mov     ebp, [esp+1Ch+arg_4]
    mov     [esp+1Ch+var_C], edi
    mov     esi, [edi+8]
    mov     ecx, [edi+0Ch]
    sub     ecx, esi
    imul    ecx
    add     edx, ecx
    sar     edx, 6
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ebp
    jnb     loc_46F968
    mov     edi, [edi+4]
    test    edi, edi
    jnz     short loc_46F7DF
    xor     edx, edx
    jmp     short loc_46F7F6
    ; ---------------------------------------------------------------------------

    loc_46F7DF:                             ; CODE XREF: sub_46F7A0+39j
    mov     ecx, esi
    mov     eax, 0B21642C9h
    sub     ecx, edi
    imul    ecx
    add     edx, ecx
    sar     edx, 6
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_46F7F6:                             ; CODE XREF: sub_46F7A0+3Dj
    cmp     ebp, edx
    jnb     short loc_46F81D
    test    edi, edi
    jnz     short loc_46F802
    xor     ecx, ecx
    jmp     short loc_46F81F
    ; ---------------------------------------------------------------------------

    loc_46F802:                             ; CODE XREF: sub_46F7A0+5Cj
    mov     ecx, esi
    mov     eax, 0B21642C9h
    sub     ecx, edi
    imul    ecx
    add     edx, ecx
    sar     edx, 6
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ecx, edx
    jmp     short loc_46F81F
    ; ---------------------------------------------------------------------------

    loc_46F81D:                             ; CODE XREF: sub_46F7A0+58j
    mov     ecx, ebp

    loc_46F81F:                             ; CODE XREF: sub_46F7A0+60j
                                            ; sub_46F7A0+7Bj
    test    edi, edi
    jnz     short loc_46F827
    xor     edx, edx
    jmp     short loc_46F83C
    ; ---------------------------------------------------------------------------

    loc_46F827:                             ; CODE XREF: sub_46F7A0+81j
    sub     esi, edi
    mov     eax, 0B21642C9h
    imul    esi
    add     edx, esi
    sar     edx, 6
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_46F83C:                             ; CODE XREF: sub_46F7A0+85j
    lea     eax, [edx+ecx]
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_46F849
    xor     eax, eax

    loc_46F849:                             ; CODE XREF: sub_46F7A0+A5j
    lea     ecx, [eax+eax*2]
    shl     ecx, 3
    sub     ecx, eax
    shl     ecx, 2
    push    ecx                             ; int
    call    sub_4B4F10
    mov     edx, [esp+20h+var_C]
    mov     edi, [esp+20h+arg_0]
    add     esp, 4
    mov     [esp+1Ch+var_4], eax
    mov     esi, [edx+4]
    mov     ebx, eax
    cmp     esi, edi
    jz      short loc_46F888

    loc_46F872:                             ; CODE XREF: sub_46F7A0+E6j
    test    ebx, ebx
    jz      short loc_46F87E
    push    esi
    mov     ecx, ebx
    call    sub_470390

    loc_46F87E:                             ; CODE XREF: sub_46F7A0+D4j
    add     esi, 5Ch
    add     ebx, 5Ch
    cmp     esi, edi
    jnz     short loc_46F872

    loc_46F888:                             ; CODE XREF: sub_46F7A0+D0j
    test    ebp, ebp
    mov     esi, ebx
    jbe     short loc_46F8B0
    mov     [esp+1Ch+arg_0], ebp

    loc_46F892:                             ; CODE XREF: sub_46F7A0+10Ej
    test    esi, esi
    jz      short loc_46F8A2
    mov     eax, [esp+1Ch+arg_8]
    mov     ecx, esi
    push    eax
    call    sub_470390

    loc_46F8A2:                             ; CODE XREF: sub_46F7A0+F4j
    mov     eax, [esp+1Ch+arg_0]
    add     esi, 5Ch
    dec     eax
    mov     [esp+1Ch+arg_0], eax
    jnz     short loc_46F892

    loc_46F8B0:                             ; CODE XREF: sub_46F7A0+ECj
    mov     ecx, [esp+1Ch+var_C]
    lea     eax, [ebp+ebp*2+0]
    shl     eax, 3
    sub     eax, ebp
    mov     ebp, [ecx+8]
    shl     eax, 2
    cmp     edi, ebp
    lea     esi, [ebx+eax]
    jz      short loc_46F8E6
    sub     edi, ebx
    add     edi, esi
    sub     edi, eax

    loc_46F8D0:                             ; CODE XREF: sub_46F7A0+144j
    test    esi, esi
    jz      short loc_46F8DC
    push    edi
    mov     ecx, esi
    call    sub_470390

    loc_46F8DC:                             ; CODE XREF: sub_46F7A0+132j
    add     edi, 5Ch
    add     esi, 5Ch
    cmp     edi, ebp
    jnz     short loc_46F8D0

    loc_46F8E6:                             ; CODE XREF: sub_46F7A0+128j
    mov     edi, [esp+1Ch+var_C]
    mov     ebx, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, ebx
    jz      short loc_46F902

    loc_46F8F4:                             ; CODE XREF: sub_46F7A0+160j
    mov     ecx, esi
    call    sub_46DED0
    add     esi, 5Ch
    cmp     esi, ebx
    jnz     short loc_46F8F4

    loc_46F902:                             ; CODE XREF: sub_46F7A0+152j
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+20h+var_8]
    mov     esi, [esp+20h+var_4]
    add     esp, 4
    lea     edx, [eax+eax*2]
    shl     edx, 3
    sub     edx, eax
    lea     eax, [esi+edx*4]
    mov     [edi+0Ch], eax
    mov     eax, [edi+4]
    test    eax, eax
    jnz     short loc_46F92F
    xor     edx, edx
    jmp     short loc_46F947
    ; ---------------------------------------------------------------------------

    loc_46F92F:                             ; CODE XREF: sub_46F7A0+189j
    mov     ecx, [edi+8]
    sub     ecx, eax
    mov     eax, 0B21642C9h
    imul    ecx
    add     edx, ecx
    sar     edx, 6
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_46F947:                             ; CODE XREF: sub_46F7A0+18Dj
    mov     eax, [esp+1Ch+arg_4]
    mov     [edi+4], esi
    add     eax, edx
    lea     ecx, [eax+eax*2]
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [esi+ecx*4]
    mov     [edi+8], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46F968:                             ; CODE XREF: sub_46F7A0+2Ej
    mov     edi, [esp+1Ch+arg_0]
    mov     ecx, esi
    sub     ecx, edi
    mov     eax, 0B21642C9h
    imul    ecx
    add     edx, ecx
    sar     edx, 6
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ebp
    jnb     loc_46FA2C
    lea     eax, [ebp+ebp*2+0]
    shl     eax, 3
    sub     eax, ebp
    shl     eax, 2
    cmp     edi, esi
    mov     [esp+1Ch+arg_4], eax
    lea     ebx, [edi+eax]
    jz      short loc_46F9C0
    mov     edi, ebx
    sub     edi, eax

    loc_46F9A6:                             ; CODE XREF: sub_46F7A0+21Aj
    test    ebx, ebx
    jz      short loc_46F9B2
    push    edi
    mov     ecx, ebx
    call    sub_470390

    loc_46F9B2:                             ; CODE XREF: sub_46F7A0+208j
    add     edi, 5Ch
    add     ebx, 5Ch
    cmp     edi, esi
    jnz     short loc_46F9A6
    mov     edi, [esp+1Ch+arg_0]

    loc_46F9C0:                             ; CODE XREF: sub_46F7A0+200j
    mov     ecx, [esp+1Ch+var_C]
    mov     eax, 0B21642C9h
    mov     ebx, [esp+1Ch+arg_8]
    mov     esi, [ecx+8]
    mov     ecx, esi
    sub     ecx, edi
    imul    ecx
    add     edx, ecx
    sar     edx, 6
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    sub     ebp, edx
    jz      short loc_46F9F8

    loc_46F9E6:                             ; CODE XREF: sub_46F7A0+256j
    test    esi, esi
    jz      short loc_46F9F2
    push    ebx
    mov     ecx, esi
    call    sub_470390

    loc_46F9F2:                             ; CODE XREF: sub_46F7A0+248j
    add     esi, 5Ch
    dec     ebp
    jnz     short loc_46F9E6

    loc_46F9F8:                             ; CODE XREF: sub_46F7A0+244j
    mov     ebp, [esp+1Ch+var_C]
    mov     esi, [esp+1Ch+arg_0]
    mov     edi, [ebp+8]
    cmp     esi, edi
    jz      short loc_46FA16

    loc_46FA07:                             ; CODE XREF: sub_46F7A0+274j
    push    ebx
    mov     ecx, esi
    call    sub_470040
    add     esi, 5Ch
    cmp     esi, edi
    jnz     short loc_46FA07

    loc_46FA16:                             ; CODE XREF: sub_46F7A0+265j
    mov     ecx, [esp+1Ch+arg_4]
    mov     eax, [ebp+8]
    add     eax, ecx
    mov     [ebp+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46FA2C:                             ; CODE XREF: sub_46F7A0+1E5j
    test    ebp, ebp
    jbe     loc_46FAB4
    lea     eax, [ebp+ebp*2+0]
    mov     edi, esi
    shl     eax, 3
    sub     eax, ebp
    mov     ebx, esi
    shl     eax, 2
    sub     edi, eax
    mov     [esp+1Ch+arg_4], eax
    cmp     edi, esi
    jz      short loc_46FA68

    loc_46FA4E:                             ; CODE XREF: sub_46F7A0+2C6j
    test    ebx, ebx
    jz      short loc_46FA5E
    push    edi
    mov     ecx, ebx
    call    sub_470390
    mov     eax, [esp+1Ch+arg_4]

    loc_46FA5E:                             ; CODE XREF: sub_46F7A0+2B0j
    add     edi, 5Ch
    add     ebx, 5Ch
    cmp     edi, esi
    jnz     short loc_46FA4E

    loc_46FA68:                             ; CODE XREF: sub_46F7A0+2ACj
    mov     ebp, [esp+1Ch+var_C]
    mov     ebx, [esp+1Ch+arg_0]
    mov     edi, [ebp+8]
    mov     esi, edi
    sub     esi, eax
    cmp     ebx, esi
    jz      short loc_46FA91

    loc_46FA7B:                             ; CODE XREF: sub_46F7A0+2EBj
    sub     esi, 5Ch
    sub     edi, 5Ch
    push    esi
    mov     ecx, edi
    call    sub_470040
    cmp     esi, ebx
    jnz     short loc_46FA7B
    mov     eax, [esp+1Ch+arg_4]

    loc_46FA91:                             ; CODE XREF: sub_46F7A0+2D9j
    lea     edi, [ebx+eax]
    mov     esi, ebx
    cmp     ebx, edi
    jz      short loc_46FAB1
    mov     ebx, [esp+1Ch+arg_8]

    loc_46FA9E:                             ; CODE XREF: sub_46F7A0+30Bj
    push    ebx
    mov     ecx, esi
    call    sub_470040
    add     esi, 5Ch
    cmp     esi, edi
    jnz     short loc_46FA9E
    mov     eax, [esp+1Ch+arg_4]

    loc_46FAB1:                             ; CODE XREF: sub_46F7A0+2F8j
    add     [ebp+8], eax

    loc_46FAB4:                             ; CODE XREF: sub_46F7A0+28Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_46F7A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FAC0 proc near                    ; CODE XREF: .text:0046C983p
                                            ; .text:0046CB02p ...

    arg_0= dword ptr  4

    mov     edx, [ecx]
    mov     eax, [edx]
    mov     [ecx], eax
    mov     eax, [esp+arg_0]
    mov     [eax], edx
    retn    8
    sub_46FAC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FAD0 proc near                    ; CODE XREF: .text:0046D46Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     edx, [ecx]
    mov     ecx, [esp+arg_4]
    mov     [eax], edx
    mov     dl, [ecx]
    mov     [eax+4], dl
    retn    8
    sub_46FAD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FAF0 proc near                    ; CODE XREF: .text:0046CD30p
                                            ; .text:0046CDC6p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_46FB33
    mov     eax, [esp+arg_8]
    push    edi
    push    esi
    push    ebx

    loc_46FB03:                             ; CODE XREF: sub_46FAF0+3Bj
    test    eax, eax
    jz      short loc_46FB23
    mov     esi, ecx
    mov     edi, eax
    mov     ebx, [esi]
    mov     [edi], ebx
    mov     ebx, [esi+4]
    mov     [edi+4], ebx
    mov     ebx, [esi+8]
    mov     [edi+8], ebx
    mov     si, [esi+0Ch]
    mov     [edi+0Ch], si

    loc_46FB23:                             ; CODE XREF: sub_46FAF0+15j
    add     ecx, 0Eh
    add     eax, 0Eh
    cmp     ecx, edx
    jnz     short loc_46FB03
    pop     ebx
    pop     esi
    pop     edi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_46FB33:                             ; CODE XREF: sub_46FAF0+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_46FAF0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FB40 proc near                    ; CODE XREF: .text:0046CD20p
                                            ; .text:0046CDF1p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_4]
    test    ecx, ecx
    jbe     short locret_46FB7C
    mov     edx, [esp+arg_8]
    mov     eax, [esp+arg_0]
    push    edi
    push    esi
    push    ebx

    loc_46FB53:                             ; CODE XREF: sub_46FB40+37j
    test    eax, eax
    jz      short loc_46FB73
    mov     esi, edx
    mov     edi, eax
    mov     ebx, [esi]
    mov     [edi], ebx
    mov     ebx, [esi+4]
    mov     [edi+4], ebx
    mov     ebx, [esi+8]
    mov     [edi+8], ebx
    mov     si, [esi+0Ch]
    mov     [edi+0Ch], si

    loc_46FB73:                             ; CODE XREF: sub_46FB40+15j
    add     eax, 0Eh
    dec     ecx
    jnz     short loc_46FB53
    pop     ebx
    pop     esi
    pop     edi

    locret_46FB7C:                          ; CODE XREF: sub_46FB40+6j
    retn    0Ch
    sub_46FB40 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FB80 proc near                    ; CODE XREF: .text:0046D3CCp
                                            ; .text:0046D414p ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebx, ecx
    push    esi
    push    edi
    lea     ecx, [esp+1Ch+var_4]
    call    sub_4E39B0
    push    24h                             ; int
    call    sub_4B4F10
    mov     ebp, eax
    mov     eax, [esp+20h+arg_8]
    add     esp, 4
    mov     [esp+1Ch+var_C], ebp
    mov     [ebp+4], eax
    mov     dword ptr [ebp+20h], 0
    mov     ecx, dword_51E598
    lea     edi, [ebp+0Ch]
    mov     [ebp+0], ecx
    mov     edx, dword_51E598
    mov     [ebp+8], edx
    mov     edx, [esp+1Ch+arg_C]
    test    edi, edi
    jz      short loc_46FBD6
    mov     ecx, 5
    mov     esi, edx
    rep movsd

    loc_46FBD6:                             ; CODE XREF: sub_46FB80+4Bj
    mov     esi, [ebx+0Ch]
    mov     ecx, [ebx+4]
    inc     esi
    cmp     eax, ecx
    mov     [ebx+0Ch], esi
    jz      short loc_46FC11
    mov     ecx, [esp+1Ch+arg_4]
    mov     esi, dword_51E598
    cmp     ecx, esi
    jnz     short loc_46FC11
    mov     edx, [edx]
    mov     edi, [eax+0Ch]
    cmp     edx, edi
    sbb     ecx, ecx
    neg     ecx
    test    cl, cl
    jnz     short loc_46FC11
    mov     [eax+8], ebp
    mov     ecx, [ebx+4]
    cmp     eax, [ecx+8]
    jnz     short loc_46FC2B
    mov     [ecx+8], ebp
    jmp     short loc_46FC2B
    ; ---------------------------------------------------------------------------

    loc_46FC11:                             ; CODE XREF: sub_46FB80+62j
                                            ; sub_46FB80+70j ...
    mov     [eax], ebp
    mov     ecx, [ebx+4]
    cmp     eax, ecx
    jnz     short loc_46FC25
    mov     [ecx+4], ebp
    mov     edx, [ebx+4]
    mov     [edx+8], ebp
    jmp     short loc_46FC2B
    ; ---------------------------------------------------------------------------

    loc_46FC25:                             ; CODE XREF: sub_46FB80+98j
    cmp     eax, [ecx]
    jnz     short loc_46FC2B
    mov     [ecx], ebp

    loc_46FC2B:                             ; CODE XREF: sub_46FB80+8Aj
                                            ; sub_46FB80+8Fj ...
    mov     eax, [ebx+4]
    mov     ecx, [esp+1Ch+var_C]
    mov     esi, ebp
    mov     ebp, 1
    cmp     ecx, [eax+4]
    jz      loc_46FE33

    loc_46FC42:                             ; CODE XREF: sub_46FB80+2ADj
    mov     eax, [esi+4]
    xor     edi, edi
    cmp     [eax+20h], edi
    jnz     loc_46FE33
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     loc_46FD51
    mov     ecx, [edx+8]
    cmp     [ecx+20h], edi
    jnz     short loc_46FC7F
    mov     [eax+20h], ebp
    mov     [ecx+20h], ebp
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+20h], edi
    mov     ecx, [esi+4]
    mov     esi, [ecx+4]
    jmp     loc_46FE27
    ; ---------------------------------------------------------------------------

    loc_46FC7F:                             ; CODE XREF: sub_46FB80+E3j
    cmp     esi, [eax+8]
    jnz     short loc_46FCD3
    lea     ecx, [esp+1Ch+arg_8]
    mov     esi, eax
    call    sub_4E39B0
    mov     eax, [esi+8]
    mov     edx, [eax]
    mov     [esi+8], edx
    mov     ecx, [eax]
    cmp     ecx, dword_51E598
    jz      short loc_46FCA4
    mov     [ecx+4], esi

    loc_46FCA4:                             ; CODE XREF: sub_46FB80+11Fj
    mov     ecx, [esi+4]
    mov     [eax+4], ecx
    mov     ecx, [ebx+4]
    cmp     esi, [ecx+4]
    jnz     short loc_46FCB7
    mov     [ecx+4], eax
    jmp     short loc_46FCC5
    ; ---------------------------------------------------------------------------

    loc_46FCB7:                             ; CODE XREF: sub_46FB80+130j
    mov     ecx, [esi+4]
    cmp     esi, [ecx]
    jnz     short loc_46FCC2
    mov     [ecx], eax
    jmp     short loc_46FCC5
    ; ---------------------------------------------------------------------------

    loc_46FCC2:                             ; CODE XREF: sub_46FB80+13Cj
    mov     [ecx+8], eax

    loc_46FCC5:                             ; CODE XREF: sub_46FB80+135j
                                            ; sub_46FB80+140j
    mov     [eax], esi
    lea     ecx, [esp+1Ch+arg_8]
    mov     [esi+4], eax
    call    sub_4E3A70

    loc_46FCD3:                             ; CODE XREF: sub_46FB80+102j
    mov     edx, [esi+4]
    mov     [edx+20h], ebp
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+20h], edi
    mov     edx, [esi+4]
    lea     ecx, [esp+1Ch+arg_C]
    mov     edi, [edx+4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51E598
    jz      short loc_46FD06
    mov     [ecx+4], edi

    loc_46FD06:                             ; CODE XREF: sub_46FB80+181j
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_46FD26
    mov     [ecx+4], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_46FE22
    ; ---------------------------------------------------------------------------

    loc_46FD26:                             ; CODE XREF: sub_46FB80+192j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_46FD40
    mov     [ecx+8], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_46FE22
    ; ---------------------------------------------------------------------------

    loc_46FD40:                             ; CODE XREF: sub_46FB80+1ACj
    mov     [ecx], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_46FE22
    ; ---------------------------------------------------------------------------

    loc_46FD51:                             ; CODE XREF: sub_46FB80+D7j
    cmp     [ecx+20h], edi
    jnz     short loc_46FD70
    mov     [eax+20h], ebp
    mov     [ecx+20h], ebp
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+20h], edi
    mov     edx, [esi+4]
    mov     esi, [edx+4]
    jmp     loc_46FE27
    ; ---------------------------------------------------------------------------

    loc_46FD70:                             ; CODE XREF: sub_46FB80+1D4j
    cmp     esi, [eax]
    jnz     short loc_46FDC5
    lea     ecx, [esp+1Ch+arg_4]
    mov     esi, eax
    call    sub_4E39B0
    mov     eax, [esi]
    mov     ecx, [eax+8]
    mov     [esi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51E598
    jz      short loc_46FD94
    mov     [ecx+4], esi

    loc_46FD94:                             ; CODE XREF: sub_46FB80+20Fj
    mov     edx, [esi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     esi, [ecx+4]
    jnz     short loc_46FDA7
    mov     [ecx+4], eax
    jmp     short loc_46FDB6
    ; ---------------------------------------------------------------------------

    loc_46FDA7:                             ; CODE XREF: sub_46FB80+220j
    mov     ecx, [esi+4]
    cmp     esi, [ecx+8]
    jnz     short loc_46FDB4
    mov     [ecx+8], eax
    jmp     short loc_46FDB6
    ; ---------------------------------------------------------------------------

    loc_46FDB4:                             ; CODE XREF: sub_46FB80+22Dj
    mov     [ecx], eax

    loc_46FDB6:                             ; CODE XREF: sub_46FB80+225j
                                            ; sub_46FB80+232j
    mov     [eax+8], esi
    lea     ecx, [esp+1Ch+arg_4]
    mov     [esi+4], eax
    call    sub_4E3A70

    loc_46FDC5:                             ; CODE XREF: sub_46FB80+1F2j
    mov     eax, [esi+4]
    mov     [eax+20h], ebp
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+var_8]
    mov     [edx+20h], edi
    mov     eax, [esi+4]
    mov     edi, [eax+4]
    call    sub_4E39B0
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_51E598
    jz      short loc_46FDF8
    mov     [ecx+4], edi

    loc_46FDF8:                             ; CODE XREF: sub_46FB80+273j
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_46FE0B
    mov     [ecx+4], eax
    jmp     short loc_46FE19
    ; ---------------------------------------------------------------------------

    loc_46FE0B:                             ; CODE XREF: sub_46FB80+284j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_46FE16
    mov     [ecx], eax
    jmp     short loc_46FE19
    ; ---------------------------------------------------------------------------

    loc_46FE16:                             ; CODE XREF: sub_46FB80+290j
    mov     [ecx+8], eax

    loc_46FE19:                             ; CODE XREF: sub_46FB80+289j
                                            ; sub_46FB80+294j
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+var_8]

    loc_46FE22:                             ; CODE XREF: sub_46FB80+1A1j
                                            ; sub_46FB80+1BBj ...
    call    sub_4E3A70

    loc_46FE27:                             ; CODE XREF: sub_46FB80+FAj
                                            ; sub_46FB80+1EBj
    mov     eax, [ebx+4]
    cmp     esi, [eax+4]
    jnz     loc_46FC42

    loc_46FE33:                             ; CODE XREF: sub_46FB80+BCj
                                            ; sub_46FB80+CAj
    mov     ecx, [ebx+4]
    mov     esi, [esp+1Ch+arg_0]
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+var_4]
    mov     [edx+20h], ebp
    mov     [esi], eax
    call    sub_4E3A70
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    10h
    sub_46FB80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FE60 proc near                    ; CODE XREF: sub_46E160+48p
                                            ; sub_46E280+29p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    sub_4E39B0
    mov     ecx, [esi+4]
    mov     esi, ecx
    mov     eax, [ecx+4]
    mov     ecx, dword_51E598
    cmp     eax, ecx
    jz      short loc_46FE9F
    mov     edx, [esp+8+arg_0]
    push    edi
    mov     edi, [edx]

    loc_46FE86:                             ; CODE XREF: sub_46FE60+3Cj
    cmp     [eax+0Ch], edi
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_46FE96
    mov     eax, [eax+8]
    jmp     short loc_46FE9A
    ; ---------------------------------------------------------------------------

    loc_46FE96:                             ; CODE XREF: sub_46FE60+2Fj
    mov     esi, eax
    mov     eax, [eax]

    loc_46FE9A:                             ; CODE XREF: sub_46FE60+34j
    cmp     eax, ecx
    jnz     short loc_46FE86
    pop     edi

    loc_46FE9F:                             ; CODE XREF: sub_46FE60+1Dj
    lea     ecx, [esp+8+var_4]
    call    sub_4E3A70
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_46FE60 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FEB0 proc near                    ; CODE XREF: sub_46EF50+154p
                                            ; sub_46EF50+1C7p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    sub_4E39B0
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx+8]
    mov     edx, [eax]
    mov     [ecx+8], edx
    mov     edx, [eax]
    cmp     edx, dword_51E598
    jz      short loc_46FED6
    mov     [edx+4], ecx

    loc_46FED6:                             ; CODE XREF: sub_46FEB0+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_46FEE9
    mov     [edx+4], eax
    jmp     short loc_46FEF7
    ; ---------------------------------------------------------------------------

    loc_46FEE9:                             ; CODE XREF: sub_46FEB0+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx]
    jnz     short loc_46FEF4
    mov     [edx], eax
    jmp     short loc_46FEF7
    ; ---------------------------------------------------------------------------

    loc_46FEF4:                             ; CODE XREF: sub_46FEB0+3Ej
    mov     [edx+8], eax

    loc_46FEF7:                             ; CODE XREF: sub_46FEB0+37j
                                            ; sub_46FEB0+42j
    mov     [eax], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    sub_4E3A70
    pop     esi
    pop     ecx
    retn    4
    sub_46FEB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FF10 proc near                    ; CODE XREF: sub_46EF50+175p
                                            ; sub_46EF50+1A6p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    sub_4E39B0
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx]
    mov     edx, [eax+8]
    mov     [ecx], edx
    mov     edx, [eax+8]
    cmp     edx, dword_51E598
    jz      short loc_46FF36
    mov     [edx+4], ecx

    loc_46FF36:                             ; CODE XREF: sub_46FF10+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_46FF49
    mov     [edx+4], eax
    jmp     short loc_46FF58
    ; ---------------------------------------------------------------------------

    loc_46FF49:                             ; CODE XREF: sub_46FF10+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx+8]
    jnz     short loc_46FF56
    mov     [edx+8], eax
    jmp     short loc_46FF58
    ; ---------------------------------------------------------------------------

    loc_46FF56:                             ; CODE XREF: sub_46FF10+3Fj
    mov     [edx], eax

    loc_46FF58:                             ; CODE XREF: sub_46FF10+37j
                                            ; sub_46FF10+44j
    mov     [eax+8], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    sub_4E3A70
    pop     esi
    pop     ecx
    retn    4
    sub_46FF10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FF70 proc near                    ; CODE XREF: sub_46EF50+76p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    24h                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+4+arg_0]
    mov     edx, [esp+4+arg_4]
    add     esp, 4
    mov     [eax+4], ecx
    mov     [eax+20h], edx
    retn    8
    sub_46FF70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_46FF90 proc near                    ; CODE XREF: .text:0046D420p
                                            ; sub_46EF50+230p

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+20h]
    test    ecx, ecx
    jnz     short loc_46FFC5
    mov     ecx, [eax+4]
    cmp     [ecx+4], eax
    jnz     short loc_46FFC5
    mov     edx, [eax+8]
    lea     ecx, [esp+10h+var_4]
    mov     [edi], edx
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_46FFC5:                             ; CODE XREF: sub_46FF90+17j
                                            ; sub_46FF90+1Fj
    mov     esi, [eax]
    mov     ecx, dword_51E598
    cmp     esi, ecx
    jz      short loc_47000A
    lea     ecx, [esp+10h+var_8]
    call    sub_4E39B0
    mov     eax, [esi+8]
    mov     ecx, dword_51E598
    cmp     eax, ecx
    jz      short loc_46FFF0

    loc_46FFE7:                             ; CODE XREF: sub_46FF90+5Ej
    mov     esi, eax
    mov     eax, [esi+8]
    cmp     eax, ecx
    jnz     short loc_46FFE7

    loc_46FFF0:                             ; CODE XREF: sub_46FF90+55j
    lea     ecx, [esp+10h+var_8]
    call    sub_4E3A70
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_47000A:                             ; CODE XREF: sub_46FF90+3Fj
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax]
    jnz     short loc_47001E

    loc_470013:                             ; CODE XREF: sub_46FF90+8Cj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax]
    jz      short loc_470013

    loc_47001E:                             ; CODE XREF: sub_46FF90+81j
    lea     ecx, [esp+10h+var_4]
    mov     [edi], eax
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_46FF90 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_45. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470040 proc near                    ; CODE XREF: sub_46DAD0+93p
                                            ; sub_46F7A0+26Ap ...

    arg_0= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     ebp, ecx
    mov     eax, [edi]
    add     edi, 4
    lea     esi, [ebp+4]
    mov     [ebp+0], eax
    cmp     esi, edi
    jz      loc_470140
    mov     eax, [edi+4]
    test    eax, eax
    jnz     short loc_470068
    xor     ebx, ebx
    jmp     short loc_470070
    ; ---------------------------------------------------------------------------

    loc_470068:                             ; CODE XREF: sub_470040+22j
    mov     ebx, [edi+8]
    sub     ebx, eax
    sar     ebx, 2

    loc_470070:                             ; CODE XREF: sub_470040+26j
    mov     ecx, [esi+4]
    test    ecx, ecx
    jnz     short loc_47007B
    xor     edx, edx
    jmp     short loc_470083
    ; ---------------------------------------------------------------------------

    loc_47007B:                             ; CODE XREF: sub_470040+35j
    mov     edx, [esi+8]
    sub     edx, ecx
    sar     edx, 2

    loc_470083:                             ; CODE XREF: sub_470040+39j
    cmp     ebx, edx
    ja      short loc_47009E
    mov     edx, [edi+8]
    cmp     eax, edx
    jz      short loc_4700DD

    loc_47008E:                             ; CODE XREF: sub_470040+5Aj
    mov     ebx, [eax]
    add     eax, 4
    mov     [ecx], ebx
    add     ecx, 4
    cmp     eax, edx
    jnz     short loc_47008E
    jmp     short loc_4700DD
    ; ---------------------------------------------------------------------------

    loc_47009E:                             ; CODE XREF: sub_470040+45j
    mov     ecx, esi
    call    sub_470250
    mov     ecx, edi
    mov     ebx, eax
    call    sub_470270
    cmp     eax, ebx
    ja      short loc_4700EF
    mov     ebx, [edi+4]
    mov     ecx, esi
    call    sub_470270
    mov     ecx, [esi+4]
    lea     ebx, [ebx+eax*4]
    mov     eax, [edi+4]
    push    ecx
    push    ebx
    push    eax
    call    sub_4702D0
    mov     edx, [esi+8]
    mov     eax, [edi+8]
    push    edx
    push    eax
    push    ebx
    mov     ecx, esi
    call    sub_4702A0

    loc_4700DD:                             ; CODE XREF: sub_470040+4Cj
                                            ; sub_470040+5Cj
    mov     ecx, edi
    call    sub_470270
    mov     ecx, [esi+4]
    lea     edx, [ecx+eax*4]
    mov     [esi+8], edx
    jmp     short loc_470140
    ; ---------------------------------------------------------------------------

    loc_4700EF:                             ; CODE XREF: sub_470040+70j
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    eax
    push    ecx
    mov     ecx, esi
    call    nullsub_46
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     ecx, edi
    call    sub_470270
    test    eax, eax
    jge     short loc_470117
    xor     eax, eax

    loc_470117:                             ; CODE XREF: sub_470040+D3j
    lea     edx, ds:0[eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+4], eax
    mov     ecx, [edi+4]
    push    eax
    mov     eax, [edi+8]
    push    eax
    push    ecx
    mov     ecx, esi
    call    sub_4702A0
    mov     [esi+8], eax
    mov     [esi+0Ch], eax

    loc_470140:                             ; CODE XREF: sub_470040+17j
                                            ; sub_470040+ADj
    mov     ecx, [esp+arg_0]
    lea     esi, [ebp+14h]
    lea     edi, [ecx+14h]
    cmp     esi, edi
    jz      loc_470223
    mov     ecx, esi
    call    sub_470270
    mov     ecx, edi
    mov     ebx, eax
    call    sub_470270
    cmp     eax, ebx
    ja      short loc_470185
    mov     edx, [esi+4]
    mov     eax, [edi+8]
    mov     ecx, [edi+4]
    push    edx
    push    eax
    push    ecx
    call    sub_4702D0
    mov     edx, [esi+8]
    mov     ecx, esi
    push    edx
    push    eax
    call    nullsub_46
    jmp     short loc_4701C4
    ; ---------------------------------------------------------------------------

    loc_470185:                             ; CODE XREF: sub_470040+124j
    mov     ecx, esi
    call    sub_470250
    mov     ecx, edi
    mov     ebx, eax
    call    sub_470270
    cmp     eax, ebx
    ja      short loc_4701D6
    mov     ebx, [edi+4]
    mov     ecx, esi
    call    sub_470270
    mov     ecx, [edi+4]
    lea     ebx, [ebx+eax*4]
    mov     eax, [esi+4]
    push    eax
    push    ebx
    push    ecx
    call    sub_4702D0
    mov     edx, [esi+8]
    mov     eax, [edi+8]
    push    edx
    push    eax
    push    ebx
    mov     ecx, esi
    call    sub_4702A0

    loc_4701C4:                             ; CODE XREF: sub_470040+143j
    mov     ecx, edi
    call    sub_470270
    mov     ecx, [esi+4]
    lea     edx, [ecx+eax*4]
    mov     [esi+8], edx
    jmp     short loc_470223
    ; ---------------------------------------------------------------------------

    loc_4701D6:                             ; CODE XREF: sub_470040+157j
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    eax
    push    ecx
    mov     ecx, esi
    call    nullsub_46
    mov     edx, [esi+4]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    mov     ecx, edi
    call    sub_470270
    test    eax, eax
    jge     short loc_4701FE
    xor     eax, eax

    loc_4701FE:                             ; CODE XREF: sub_470040+1BAj
    shl     eax, 2
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+4], eax
    mov     ecx, [edi+8]
    mov     edx, [edi+4]
    push    eax
    push    ecx
    push    edx
    mov     ecx, esi
    call    sub_4702A0
    mov     [esi+8], eax
    mov     [esi+0Ch], eax

    loc_470223:                             ; CODE XREF: sub_470040+10Cj
                                            ; sub_470040+194j
    mov     eax, [esp+arg_0]
    mov     ecx, [eax+24h]
    add     eax, 30h
    mov     [ebp+24h], ecx
    mov     edx, [eax-8]
    mov     [ebp+28h], edx
    mov     ecx, [eax-4]
    mov     [ebp+2Ch], ecx
    push    eax
    lea     ecx, [ebp+30h]
    call    sub_470560
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_470040 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470250 proc near                    ; CODE XREF: sub_470040+60p
                                            ; sub_470040+147p
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_47025A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_47025A:                             ; CODE XREF: sub_470250+5j
    mov     eax, [ecx+0Ch]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_470250 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470270 proc near                    ; CODE XREF: sub_470040+69p
                                            ; sub_470040+77p ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_47027A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_47027A:                             ; CODE XREF: sub_470270+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_470270 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_46. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4702A0 proc near                    ; CODE XREF: sub_470040+98p
                                            ; sub_470040+F5p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_4702C7
    mov     eax, [esp+arg_8]
    push    esi

    loc_4702B1:                             ; CODE XREF: sub_4702A0+21j
    test    eax, eax
    jz      short loc_4702B9
    mov     esi, [ecx]
    mov     [eax], esi

    loc_4702B9:                             ; CODE XREF: sub_4702A0+13j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_4702B1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4702C7:                             ; CODE XREF: sub_4702A0+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_4702A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4702D0 proc near                    ; CODE XREF: sub_470040+88p
                                            ; sub_470040+132p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_4702F3
    mov     eax, [esp+arg_8]
    push    esi

    loc_4702E1:                             ; CODE XREF: sub_4702D0+1Dj
    mov     esi, [ecx]
    add     ecx, 4
    mov     [eax], esi
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_4702E1
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4702F3:                             ; CODE XREF: sub_4702D0+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_4702D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470300 proc near                    ; CODE XREF: .text:0046CB47p

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+50h]
    push    eax
    mov     [esp+10h+var_4], eax
    call    sub_4B4F20
    xor     edi, edi
    add     esp, 4
    mov     [esi+50h], edi
    mov     [esi+54h], edi
    mov     [esi+58h], edi
    mov     eax, [esi+40h]
    push    eax
    mov     [esp+10h+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+40h], edi
    mov     [esi+44h], edi
    mov     [esi+48h], edi
    mov     eax, [esi+18h]
    push    eax
    mov     [esp+10h+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+18h], edi
    mov     [esi+1Ch], edi
    mov     [esi+20h], edi
    mov     eax, [esi+8]
    push    eax
    mov     [esp+10h+var_4], eax
    call    sub_4B4F20
    mov     al, [esp+10h+arg_0]
    add     esp, 4
    test    al, 1
    mov     [esi+8], edi
    mov     [esi+0Ch], edi
    mov     [esi+10h], edi
    jz      short loc_47037C
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_47037C:                             ; CODE XREF: sub_470300+71j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ecx
    retn    4
    sub_470300 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470390 proc near                    ; CODE XREF: sub_46F7A0+D9p
                                            ; sub_46F7A0+FDp ...

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, ecx
    mov     eax, [esi]
    mov     [edi], eax
    mov     cl, [esi+4]
    mov     [edi+4], cl
    mov     ecx, [esi+8]
    test    ecx, ecx
    jnz     short loc_4703AF
    xor     eax, eax
    jmp     short loc_4703B7
    ; ---------------------------------------------------------------------------

    loc_4703AF:                             ; CODE XREF: sub_470390+19j
    mov     eax, [esi+0Ch]
    sub     eax, ecx
    sar     eax, 2

    loc_4703B7:                             ; CODE XREF: sub_470390+1Dj
    test    eax, eax
    jge     short loc_4703BD
    xor     eax, eax

    loc_4703BD:                             ; CODE XREF: sub_470390+29j
    lea     edx, ds:0[eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    mov     [edi+8], eax
    mov     edx, [esi+0Ch]
    mov     ecx, [esi+8]
    add     esp, 4
    cmp     ecx, edx
    jz      short loc_4703EC

    loc_4703DA:                             ; CODE XREF: sub_470390+5Aj
    test    eax, eax
    jz      short loc_4703E2
    mov     ebx, [ecx]
    mov     [eax], ebx

    loc_4703E2:                             ; CODE XREF: sub_470390+4Cj
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_4703DA

    loc_4703EC:                             ; CODE XREF: sub_470390+48j
    mov     [edi+0Ch], eax
    mov     [edi+10h], eax
    mov     al, [esi+14h]
    mov     [edi+14h], al
    mov     ecx, [esi+18h]
    test    ecx, ecx
    jnz     short loc_470403
    xor     eax, eax
    jmp     short loc_47040B
    ; ---------------------------------------------------------------------------

    loc_470403:                             ; CODE XREF: sub_470390+6Dj
    mov     eax, [esi+1Ch]
    sub     eax, ecx
    sar     eax, 2

    loc_47040B:                             ; CODE XREF: sub_470390+71j
    test    eax, eax
    jge     short loc_470411
    xor     eax, eax

    loc_470411:                             ; CODE XREF: sub_470390+7Dj
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [edi+18h], eax
    mov     edx, [esi+1Ch]
    mov     ecx, [esi+18h]
    add     esp, 4
    cmp     ecx, edx
    jz      short loc_470440

    loc_47042E:                             ; CODE XREF: sub_470390+AEj
    test    eax, eax
    jz      short loc_470436
    mov     ebx, [ecx]
    mov     [eax], ebx

    loc_470436:                             ; CODE XREF: sub_470390+A0j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_47042E

    loc_470440:                             ; CODE XREF: sub_470390+9Cj
    mov     [edi+1Ch], eax
    mov     [edi+20h], eax
    mov     edx, [esi+24h]
    mov     [edi+24h], edx
    mov     eax, [esi+28h]
    mov     [edi+28h], eax
    mov     ecx, [esi+2Ch]
    mov     [edi+2Ch], ecx
    mov     edx, [esi+30h]
    mov     [edi+30h], edx
    mov     eax, [esi+34h]
    mov     [edi+34h], eax
    mov     ecx, [esi+38h]
    mov     [edi+38h], ecx
    mov     dl, [esi+3Ch]
    mov     [edi+3Ch], dl
    mov     eax, [esi+40h]
    test    eax, eax
    jnz     short loc_47047B
    xor     edx, edx
    jmp     short loc_470493
    ; ---------------------------------------------------------------------------

    loc_47047B:                             ; CODE XREF: sub_470390+E5j
    mov     ecx, [esi+44h]
    sub     ecx, eax
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_470493:                             ; CODE XREF: sub_470390+E9j
    test    edx, edx
    mov     eax, edx
    jge     short loc_47049B
    xor     eax, eax

    loc_47049B:                             ; CODE XREF: sub_470390+107j
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    shl     ecx, 1
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [edi+40h], eax
    mov     edx, [esi+44h]
    mov     ecx, [esi+40h]
    add     esp, 4
    cmp     ecx, edx
    mov     [esp+4+arg_0], edx
    jz      short loc_4704EC

    loc_4704BE:                             ; CODE XREF: sub_470390+15Aj
    test    eax, eax
    jz      short loc_4704E2
    mov     edx, ecx
    mov     ebx, eax
    mov     ebp, [edx]
    mov     [ebx], ebp
    mov     ebp, [edx+4]
    mov     [ebx+4], ebp
    mov     ebp, [edx+8]
    mov     [ebx+8], ebp
    mov     dx, [edx+0Ch]
    mov     [ebx+0Ch], dx
    mov     edx, [esp+4+arg_0]

    loc_4704E2:                             ; CODE XREF: sub_470390+130j
    add     ecx, 0Eh
    add     eax, 0Eh
    cmp     ecx, edx
    jnz     short loc_4704BE

    loc_4704EC:                             ; CODE XREF: sub_470390+12Cj
    mov     [edi+44h], eax
    mov     [edi+48h], eax
    mov     al, [esi+4Ch]
    lea     ebx, [edi+4Ch]
    mov     [ebx], al
    mov     eax, [esi+50h]
    test    eax, eax
    jnz     short loc_470505
    xor     edx, edx
    jmp     short loc_47051D
    ; ---------------------------------------------------------------------------

    loc_470505:                             ; CODE XREF: sub_470390+16Fj
    mov     ecx, [esi+54h]
    sub     ecx, eax
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_47051D:                             ; CODE XREF: sub_470390+173j
    test    edx, edx
    mov     eax, edx
    jge     short loc_470525
    xor     eax, eax

    loc_470525:                             ; CODE XREF: sub_470390+191j
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    shl     edx, 1
    push    edx                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [ebx+4], eax
    mov     ecx, [esi+50h]
    push    eax
    mov     eax, [esi+54h]
    push    eax
    push    ecx
    mov     ecx, ebx
    call    sub_46FAF0
    mov     [ebx+8], eax
    mov     [ebx+0Ch], eax
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_470390 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470560 proc near                    ; CODE XREF: sub_470040+200p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    mov     eax, [esp+8+arg_0]
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ecx, [eax]
    push    esi
    mov     [ebx], ecx
    mov     edx, [eax+4]
    push    edi
    mov     [ebx+4], edx
    mov     ecx, [eax+8]
    lea     edi, [eax+0Ch]
    lea     esi, [ebx+0Ch]
    mov     [esp+18h+var_8], ebx
    cmp     esi, edi
    mov     [ebx+8], ecx
    jz      loc_47074B
    mov     ebp, [edi+4]
    test    ebp, ebp
    jnz     short loc_47059C
    mov     [esp+18h+var_4], ebp
    jmp     short loc_4705B8
    ; ---------------------------------------------------------------------------

    loc_47059C:                             ; CODE XREF: sub_470560+34j
    mov     ecx, [edi+8]
    mov     eax, 92492493h
    sub     ecx, ebp
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+18h+var_4], edx

    loc_4705B8:                             ; CODE XREF: sub_470560+3Aj
    mov     ecx, [esi+4]
    test    ecx, ecx
    jnz     short loc_4705C3
    xor     edx, edx
    jmp     short loc_4705DF
    ; ---------------------------------------------------------------------------

    loc_4705C3:                             ; CODE XREF: sub_470560+5Dj
    mov     ebx, [esi+8]
    mov     eax, 92492493h
    sub     ebx, ecx
    imul    ebx
    add     edx, ebx
    mov     ebx, [esp+18h+var_8]
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4705DF:                             ; CODE XREF: sub_470560+61j
    cmp     [esp+18h+var_4], edx
    ja      short loc_47065A
    mov     edx, [edi+8]
    mov     eax, ebp
    cmp     ebp, edx
    mov     [esp+18h+var_4], edx
    jz      short loc_470620

    loc_4705F2:                             ; CODE XREF: sub_470560+BAj
    mov     edx, eax
    mov     ebx, ecx
    add     eax, 0Eh
    add     ecx, 0Eh
    mov     ebp, [edx]
    mov     [ebx], ebp
    mov     ebp, [edx+4]
    mov     [ebx+4], ebp
    mov     ebp, [edx+8]
    mov     [ebx+8], ebp
    mov     dx, [edx+0Ch]
    mov     [ebx+0Ch], dx
    mov     edx, [esp+18h+var_4]
    cmp     eax, edx
    jnz     short loc_4705F2
    mov     ebx, [esp+18h+var_8]

    loc_470620:                             ; CODE XREF: sub_470560+90j
    mov     eax, [edi+4]
    test    eax, eax
    jnz     short loc_47062B
    xor     edx, edx
    jmp     short loc_470643
    ; ---------------------------------------------------------------------------

    loc_47062B:                             ; CODE XREF: sub_470560+C5j
    mov     edi, [edi+8]
    sub     edi, eax
    mov     eax, 92492493h
    imul    edi
    add     edx, edi
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_470643:                             ; CODE XREF: sub_470560+C9j
    lea     ecx, ds:0[edx*8]
    sub     ecx, edx
    mov     edx, [esi+4]
    lea     eax, [edx+ecx*2]
    mov     [esi+8], eax
    jmp     loc_470747
    ; ---------------------------------------------------------------------------

    loc_47065A:                             ; CODE XREF: sub_470560+83j
    test    ebp, ebp
    jnz     short loc_470664
    mov     [esp+18h+var_4], ebp
    jmp     short loc_470684
    ; ---------------------------------------------------------------------------

    loc_470664:                             ; CODE XREF: sub_470560+FCj
    mov     ebx, [edi+8]
    mov     eax, 92492493h
    sub     ebx, ebp
    imul    ebx
    add     edx, ebx
    mov     ebx, [esp+18h+var_8]
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+18h+var_4], edx

    loc_470684:                             ; CODE XREF: sub_470560+102j
    test    ecx, ecx
    jnz     short loc_47068C
    xor     edx, edx
    jmp     short loc_4706A8
    ; ---------------------------------------------------------------------------

    loc_47068C:                             ; CODE XREF: sub_470560+126j
    mov     ebx, [esi+0Ch]
    mov     eax, 92492493h
    sub     ebx, ecx
    imul    ebx
    add     edx, ebx
    mov     ebx, [esp+18h+var_8]
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4706A8:                             ; CODE XREF: sub_470560+12Aj
    cmp     [esp+18h+var_4], edx
    ja      short loc_4706F7
    mov     ecx, esi
    call    sub_470770
    mov     edx, [esi+4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     eax, [edi+4]
    push    edx
    lea     ebp, [ebp+ecx*2+0]
    push    ebp
    push    eax
    call    sub_470A40
    mov     eax, [esi+8]
    mov     ecx, [edi+8]
    push    eax
    push    ecx
    push    ebp
    mov     ecx, esi
    call    sub_46FAF0
    mov     ecx, edi
    call    sub_470770
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    mov     eax, [esi+4]
    lea     ecx, [eax+edx*2]
    mov     [esi+8], ecx
    jmp     short loc_470747
    ; ---------------------------------------------------------------------------

    loc_4706F7:                             ; CODE XREF: sub_470560+14Cj
    mov     edx, [esi+8]
    push    edx
    push    ecx
    mov     ecx, esi
    call    nullsub_44
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     ecx, edi
    call    sub_470770
    test    eax, eax
    jge     short loc_47071C
    xor     eax, eax

    loc_47071C:                             ; CODE XREF: sub_470560+1B8j
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    shl     ecx, 1
    push    ecx                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [esi+4], eax
    mov     edx, [edi+8]
    mov     ecx, [edi+4]
    push    eax
    push    edx
    push    ecx
    mov     ecx, esi
    call    sub_46FAF0
    mov     [esi+8], eax
    mov     [esi+0Ch], eax

    loc_470747:                             ; CODE XREF: sub_470560+F5j
                                            ; sub_470560+195j
    mov     eax, [esp+18h+arg_0]

    loc_47074B:                             ; CODE XREF: sub_470560+29j
    add     eax, 1Ch
    lea     ecx, [ebx+1Ch]
    push    eax
    call    sub_4707A0
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_470560 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470770 proc near                    ; CODE XREF: sub_470560+150p
                                            ; sub_470560+180p ...
    mov     eax, [ecx+4]
    test    eax, eax
    jnz     short loc_470778
    retn
    ; ---------------------------------------------------------------------------

    loc_470778:                             ; CODE XREF: sub_470770+5j
    mov     ecx, [ecx+8]
    sub     ecx, eax
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, edx
    retn
    sub_470770 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4707A0 proc near                    ; CODE XREF: sub_470560+1F2p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    mov     ebx, [esp+8+arg_0]
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    cmp     esi, ebx
    mov     [esp+14h+var_4], esi
    jz      loc_470A29
    mov     edi, [ebx+4]
    test    edi, edi
    jnz     short loc_4707C2
    xor     ebp, ebp
    jmp     short loc_4707DC
    ; ---------------------------------------------------------------------------

    loc_4707C2:                             ; CODE XREF: sub_4707A0+1Cj
    mov     ecx, [ebx+8]
    mov     eax, 92492493h
    sub     ecx, edi
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ebp, edx

    loc_4707DC:                             ; CODE XREF: sub_4707A0+20j
    mov     esi, [esi+4]
    test    esi, esi
    jnz     short loc_4707E7
    xor     edx, edx
    jmp     short loc_470803
    ; ---------------------------------------------------------------------------

    loc_4707E7:                             ; CODE XREF: sub_4707A0+41j
    mov     ecx, [esp+14h+var_4]
    mov     eax, 92492493h
    mov     ecx, [ecx+8]
    sub     ecx, esi
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_470803:                             ; CODE XREF: sub_4707A0+45j
    cmp     ebp, edx
    ja      short loc_470877
    mov     ecx, [ebx+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_470836

    loc_470810:                             ; CODE XREF: sub_4707A0+94j
    mov     edx, eax
    mov     edi, esi
    add     eax, 0Eh
    add     esi, 0Eh
    mov     ebp, [edx]
    cmp     eax, ecx
    mov     [edi], ebp
    mov     ebp, [edx+4]
    mov     [edi+4], ebp
    mov     ebp, [edx+8]
    mov     [edi+8], ebp
    mov     dx, [edx+0Ch]
    mov     [edi+0Ch], dx
    jnz     short loc_470810

    loc_470836:                             ; CODE XREF: sub_4707A0+6Ej
    mov     eax, [ebx+4]
    test    eax, eax
    jnz     short loc_470841
    xor     edx, edx
    jmp     short loc_470859
    ; ---------------------------------------------------------------------------

    loc_470841:                             ; CODE XREF: sub_4707A0+9Bj
    mov     ecx, [ebx+8]
    sub     ecx, eax
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_470859:                             ; CODE XREF: sub_4707A0+9Fj
    mov     eax, [esp+14h+var_4]
    lea     ecx, ds:0[edx*8]
    sub     ecx, edx
    mov     edx, [eax+4]
    lea     ecx, [edx+ecx*2]
    mov     [eax+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_470877:                             ; CODE XREF: sub_4707A0+65j
    test    edi, edi
    jnz     short loc_47087F
    xor     ebp, ebp
    jmp     short loc_470899
    ; ---------------------------------------------------------------------------

    loc_47087F:                             ; CODE XREF: sub_4707A0+D9j
    mov     ecx, [ebx+8]
    mov     eax, 92492493h
    sub     ecx, edi
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ebp, edx

    loc_470899:                             ; CODE XREF: sub_4707A0+DDj
    test    esi, esi
    jnz     short loc_4708A1
    xor     edx, edx
    jmp     short loc_4708BD
    ; ---------------------------------------------------------------------------

    loc_4708A1:                             ; CODE XREF: sub_4707A0+FBj
    mov     ecx, [esp+14h+var_4]
    mov     eax, 92492493h
    mov     ecx, [ecx+0Ch]
    sub     ecx, esi
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4708BD:                             ; CODE XREF: sub_4707A0+FFj
    cmp     ebp, edx
    ja      loc_4709A2
    test    esi, esi
    jnz     short loc_4708CD
    xor     edx, edx
    jmp     short loc_4708E9
    ; ---------------------------------------------------------------------------

    loc_4708CD:                             ; CODE XREF: sub_4707A0+127j
    mov     ecx, [esp+14h+var_4]
    mov     eax, 92492493h
    mov     ecx, [ecx+8]
    sub     ecx, esi
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4708E9:                             ; CODE XREF: sub_4707A0+12Bj
    lea     ecx, ds:0[edx*8]
    mov     eax, edi
    sub     ecx, edx
    mov     edx, esi
    lea     ecx, [edi+ecx*2]
    cmp     edi, ecx
    jz      short loc_470923

    loc_4708FD:                             ; CODE XREF: sub_4707A0+181j
    mov     esi, eax
    mov     edi, edx
    add     eax, 0Eh
    add     edx, 0Eh
    mov     ebp, [esi]
    cmp     eax, ecx
    mov     [edi], ebp
    mov     ebp, [esi+4]
    mov     [edi+4], ebp
    mov     ebp, [esi+8]
    mov     [edi+8], ebp
    mov     si, [esi+0Ch]
    mov     [edi+0Ch], si
    jnz     short loc_4708FD

    loc_470923:                             ; CODE XREF: sub_4707A0+15Bj
    mov     esi, [ebx+8]
    mov     edi, [esp+14h+var_4]
    cmp     ecx, esi
    mov     eax, ecx
    mov     edx, [edi+8]
    jz      short loc_470961

    loc_470933:                             ; CODE XREF: sub_4707A0+1BBj
    test    edx, edx
    jz      short loc_470953
    mov     ecx, eax
    mov     edi, edx
    mov     ebp, [ecx]
    mov     [edi], ebp
    mov     ebp, [ecx+4]
    mov     [edi+4], ebp
    mov     ebp, [ecx+8]
    mov     [edi+8], ebp
    mov     cx, [ecx+0Ch]
    mov     [edi+0Ch], cx

    loc_470953:                             ; CODE XREF: sub_4707A0+195j
    add     eax, 0Eh
    add     edx, 0Eh
    cmp     eax, esi
    jnz     short loc_470933
    mov     edi, [esp+14h+var_4]

    loc_470961:                             ; CODE XREF: sub_4707A0+191j
    mov     eax, [ebx+4]
    test    eax, eax
    jnz     short loc_47096C
    xor     edx, edx
    jmp     short loc_470984
    ; ---------------------------------------------------------------------------

    loc_47096C:                             ; CODE XREF: sub_4707A0+1C6j
    mov     ecx, [ebx+8]
    sub     ecx, eax
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_470984:                             ; CODE XREF: sub_4707A0+1CAj
    lea     ecx, ds:0[edx*8]
    sub     ecx, edx
    mov     edx, [edi+4]
    lea     eax, [edx+ecx*2]
    mov     [edi+8], eax
    mov     eax, [esp+14h+var_4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4709A2:                             ; CODE XREF: sub_4707A0+11Fj
    push    esi
    mov     [esp+18h+arg_0], esi
    call    sub_4B4F20
    mov     eax, [ebx+4]
    add     esp, 4
    test    eax, eax
    jz      short loc_4709D0
    mov     ecx, [ebx+8]
    sub     ecx, eax
    mov     eax, 92492493h
    imul    ecx
    add     edx, ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     eax, edx

    loc_4709D0:                             ; CODE XREF: sub_4707A0+214j
    test    eax, eax
    jge     short loc_4709D6
    xor     eax, eax

    loc_4709D6:                             ; CODE XREF: sub_4707A0+232j
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    shl     edx, 1
    push    edx                             ; int
    call    sub_4B4F10
    mov     esi, [esp+18h+var_4]
    add     esp, 4
    mov     [esi+4], eax
    mov     edx, [ebx+8]
    mov     ecx, [ebx+4]
    cmp     ecx, edx
    jz      short loc_470A23

    loc_4709F9:                             ; CODE XREF: sub_4707A0+281j
    test    eax, eax
    jz      short loc_470A19
    mov     edi, ecx
    mov     ebx, eax
    mov     ebp, [edi]
    mov     [ebx], ebp
    mov     ebp, [edi+4]
    mov     [ebx+4], ebp
    mov     ebp, [edi+8]
    mov     [ebx+8], ebp
    mov     di, [edi+0Ch]
    mov     [ebx+0Ch], di

    loc_470A19:                             ; CODE XREF: sub_4707A0+25Bj
    add     ecx, 0Eh
    add     eax, 0Eh
    cmp     ecx, edx
    jnz     short loc_4709F9

    loc_470A23:                             ; CODE XREF: sub_4707A0+257j
    mov     [esi+8], eax
    mov     [esi+0Ch], eax

    loc_470A29:                             ; CODE XREF: sub_4707A0+11j
    mov     eax, [esp+14h+var_4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_4707A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470A40 proc near                    ; CODE XREF: sub_470560+169p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_470A7F
    mov     eax, [esp+arg_8]
    push    edi
    push    esi
    push    ebx

    loc_470A53:                             ; CODE XREF: sub_470A40+37j
    mov     esi, ecx
    mov     edi, eax
    add     ecx, 0Eh
    add     eax, 0Eh
    mov     ebx, [esi]
    cmp     ecx, edx
    mov     [edi], ebx
    mov     ebx, [esi+4]
    mov     [edi+4], ebx
    mov     ebx, [esi+8]
    mov     [edi+8], ebx
    mov     si, [esi+0Ch]
    mov     [edi+0Ch], si
    jnz     short loc_470A53
    pop     ebx
    pop     esi
    pop     edi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_470A7F:                             ; CODE XREF: sub_470A40+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_470A40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470A90 proc near                    ; CODE XREF: .text:00471C8Cp

    arg_0= byte ptr  4
    arg_4= dword ptr  8

    mov     al, [esp+arg_0]
    mov     edx, dword ptr [esp+arg_0]
    push    esi
    mov     esi, ecx
    mov     [esi+4], al
    xor     eax, eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    mov     [esi+10h], eax
    cmp     edx, eax
    mov     dword ptr [esi], offset off_4FD580
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    mov     [esi+1Ch], eax
    mov     [esi+20h], eax
    jz      short loc_470AD0
    mov     ecx, [esp+4+arg_4]
    cmp     ecx, eax
    jz      short loc_470AD0
    push    ecx
    push    edx
    mov     ecx, esi
    call    sub_470C10

    loc_470AD0:                             ; CODE XREF: sub_470A90+2Dj
                                            ; sub_470A90+35j
    mov     eax, esi
    pop     esi
    retn    8
    sub_470A90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470AE0 proc near                    ; DATA XREF: .rdata:004FD580o

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    xor     ebx, ebx
    push    edi
    mov     eax, [esi+14h]
    mov     dword ptr [esi], offset off_4FD580
    cmp     eax, ebx
    jz      short loc_470AFF
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_470AFF:                             ; CODE XREF: sub_470AE0+14j
    mov     edi, [esi+8]
    mov     eax, [esi+0Ch]
    cmp     edi, eax
    jz      short loc_470B43
    lea     ebx, [edi+4]

    loc_470B0C:                             ; CODE XREF: sub_470AE0+5Fj
    mov     eax, [edi]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, [esi+0Ch]
    mov     eax, ebx
    add     esp, 4
    cmp     eax, ecx
    jz      short loc_470B30
    mov     edx, edi
    sub     edx, ebx

    loc_470B24:                             ; CODE XREF: sub_470AE0+4Ej
    mov     ebp, [eax]
    mov     [eax+edx], ebp
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_470B24

    loc_470B30:                             ; CODE XREF: sub_470AE0+3Ej
    mov     eax, [esi+0Ch]
    add     eax, 0FFFFFFFCh
    cmp     edi, eax
    mov     [esp+14h+var_4], eax
    mov     [esi+0Ch], eax
    jnz     short loc_470B0C
    xor     ebx, ebx

    loc_470B43:                             ; CODE XREF: sub_470AE0+27j
    mov     eax, [esi+8]
    push    eax
    mov     [esp+18h+var_4], eax
    call    sub_4B4F20
    mov     al, [esp+18h+arg_0]
    add     esp, 4
    test    al, 1
    mov     [esi+8], ebx
    mov     [esi+0Ch], ebx
    mov     [esi+10h], ebx
    jz      short loc_470B6D
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_470B6D:                             ; CODE XREF: sub_470AE0+82j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_470AE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_470B80:                             ; CODE XREF: .text:00471CB9j
    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    xor     ebx, ebx
    push    edi
    mov     eax, [esi+14h]
    mov     dword ptr [esi], offset off_4FD580
    cmp     eax, ebx
    jz      short loc_470B9F
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_470B9F:                             ; CODE XREF: .text:00470B94j
    mov     edi, [esi+8]
    mov     eax, [esi+0Ch]
    cmp     edi, eax
    jz      short loc_470BE3
    lea     ebx, [edi+4]

    loc_470BAC:                             ; CODE XREF: .text:00470BDFj
    mov     eax, [edi]
    push    eax
    call    sub_4D85A0
    mov     ecx, [esi+0Ch]
    mov     eax, ebx
    add     esp, 4
    cmp     eax, ecx
    jz      short loc_470BD0
    mov     edx, edi
    sub     edx, ebx

    loc_470BC4:                             ; CODE XREF: .text:00470BCEj
    mov     ebp, [eax]
    mov     [eax+edx], ebp
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_470BC4

    loc_470BD0:                             ; CODE XREF: .text:00470BBEj
    mov     eax, [esi+0Ch]
    add     eax, 0FFFFFFFCh
    cmp     edi, eax
    mov     [esp+10h], eax
    mov     [esi+0Ch], eax
    jnz     short loc_470BAC
    xor     ebx, ebx

    loc_470BE3:                             ; CODE XREF: .text:00470BA7j
    mov     eax, [esi+8]
    push    eax
    mov     [esp+14h], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+8], ebx
    mov     [esi+0Ch], ebx
    mov     [esi+10h], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470C10 proc near                    ; CODE XREF: sub_470A90+3Bp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ebp, [esp+18h+arg_0]
    mov     eax, [ebx+1Ch]
    push    esi
    cmp     ebp, eax
    push    edi
    mov     [esp+20h+var_4], ebx
    mov     [esp+20h+var_C], 0
    jle     loc_470E2B
    mov     ecx, [ebx+14h]
    lea     eax, ds:0[ebp*4]
    push    eax
    push    ecx
    call    sub_4D8580
    mov     edi, eax
    add     esp, 8
    test    edi, edi
    jz      loc_470E33
    mov     ecx, [ebx+1Ch]
    mov     esi, [esp+20h+arg_4]
    mov     edx, ebp
    sub     edx, ecx
    imul    edx, esi
    push    edx
    call    sub_4D8450
    add     esp, 4
    mov     [esp+20h+var_10], eax
    test    eax, eax
    mov     [ebx+14h], edi
    jz      loc_470E33
    mov     ecx, [ebx+1Ch]
    cmp     ecx, ebp
    jge     short loc_470C96
    xor     edx, edx
    jmp     short loc_470C87
    ; ---------------------------------------------------------------------------

    loc_470C83:                             ; CODE XREF: sub_470C10+84j
    mov     eax, [esp+20h+var_10]

    loc_470C87:                             ; CODE XREF: sub_470C10+71j
    mov     edi, [ebx+14h]
    add     eax, edx
    add     edx, esi
    mov     [edi+ecx*4], eax
    inc     ecx
    cmp     ecx, ebp
    jl      short loc_470C83

    loc_470C96:                             ; CODE XREF: sub_470C10+6Dj
    mov     eax, [ebx+0Ch]
    mov     ecx, [ebx+10h]
    lea     esi, [ebx+4]
    sub     ecx, eax
    sar     ecx, 2
    cmp     ecx, 1
    mov     edi, eax
    jnb     loc_470D95
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_470CBA
    xor     ecx, ecx
    jmp     short loc_470CC1
    ; ---------------------------------------------------------------------------

    loc_470CBA:                             ; CODE XREF: sub_470C10+A4j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2

    loc_470CC1:                             ; CODE XREF: sub_470C10+A8j
    cmp     ecx, 1
    jbe     short loc_470CD7
    test    edx, edx
    jnz     short loc_470CCE
    xor     ecx, ecx
    jmp     short loc_470CDC
    ; ---------------------------------------------------------------------------

    loc_470CCE:                             ; CODE XREF: sub_470C10+B8j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_470CDC
    ; ---------------------------------------------------------------------------

    loc_470CD7:                             ; CODE XREF: sub_470C10+B4j
    mov     ecx, 1

    loc_470CDC:                             ; CODE XREF: sub_470C10+BCj
                                            ; sub_470C10+C5j
    test    edx, edx
    jnz     short loc_470CE4
    xor     eax, eax
    jmp     short loc_470CE9
    ; ---------------------------------------------------------------------------

    loc_470CE4:                             ; CODE XREF: sub_470C10+CEj
    sub     eax, edx
    sar     eax, 2

    loc_470CE9:                             ; CODE XREF: sub_470C10+D2j
    add     eax, ecx
    test    eax, eax
    mov     [esp+20h+var_8], eax
    jge     short loc_470CF5
    xor     eax, eax

    loc_470CF5:                             ; CODE XREF: sub_470C10+E1j
    lea     edx, ds:0[eax*4]
    push    edx                             ; int
    call    sub_4B4F10
    mov     ebx, [esi+4]
    add     esp, 4
    cmp     ebx, edi
    mov     [esp+20h+var_C], eax
    mov     ebp, eax
    jz      short loc_470D23

    loc_470D12:                             ; CODE XREF: sub_470C10+111j
    push    ebx
    push    ebp
    call    sub_470F60
    add     ebx, 4
    add     ebp, 4
    cmp     ebx, edi
    jnz     short loc_470D12

    loc_470D23:                             ; CODE XREF: sub_470C10+100j
    lea     eax, [esp+20h+var_10]
    mov     ecx, esi
    push    eax
    push    1
    push    ebp
    call    sub_470F30
    mov     ecx, [esi+8]
    add     ebp, 4
    push    ebp
    push    ecx
    push    edi
    mov     ecx, esi
    call    sub_470F00
    mov     edx, [esi+8]
    mov     eax, [esi+4]
    push    edx
    push    eax
    mov     ecx, esi
    call    nullsub_49
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     ecx, [esp+24h+var_C]
    mov     edx, [esp+24h+var_8]
    add     esp, 4
    lea     eax, [ecx+edx*4]
    mov     [esi+0Ch], eax
    mov     eax, [esi+4]
    test    eax, eax
    jnz     short loc_470D76
    xor     edx, edx
    jmp     short loc_470D7E
    ; ---------------------------------------------------------------------------

    loc_470D76:                             ; CODE XREF: sub_470C10+160j
    mov     edx, [esi+8]
    sub     edx, eax
    sar     edx, 2

    loc_470D7E:                             ; CODE XREF: sub_470C10+164j
    mov     ebx, [esp+20h+var_4]
    mov     ebp, [esp+20h+arg_0]
    lea     edx, [ecx+edx*4+4]
    mov     [esi+4], ecx
    mov     [esi+8], edx
    jmp     loc_470E21
    ; ---------------------------------------------------------------------------

    loc_470D95:                             ; CODE XREF: sub_470C10+99j
    mov     ecx, eax
    sub     ecx, edi
    sar     ecx, 2
    cmp     ecx, 1
    jnb     short loc_470DE3
    lea     edx, [edi+4]
    mov     ecx, esi
    push    edx
    push    eax
    push    edi
    call    sub_470F00
    mov     eax, [esi+8]
    lea     ecx, [esp+20h+var_10]
    mov     edx, eax
    push    ecx
    sub     edx, edi
    mov     ecx, 1
    sar     edx, 2
    sub     ecx, edx
    push    ecx
    push    eax
    mov     ecx, esi
    call    sub_470F30
    mov     eax, [esi+8]
    cmp     edi, eax
    jz      short loc_470E1D

    loc_470DD4:                             ; CODE XREF: sub_470C10+1CFj
    mov     edx, [esp+20h+var_10]
    mov     [edi], edx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_470DD4
    jmp     short loc_470E1D
    ; ---------------------------------------------------------------------------

    loc_470DE3:                             ; CODE XREF: sub_470C10+18Fj
    push    eax
    push    eax
    add     eax, 0FFFFFFFCh
    mov     ecx, esi
    push    eax
    call    sub_470F00
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_470E09

    loc_470DFA:                             ; CODE XREF: sub_470C10+1F7j
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_470DFA

    loc_470E09:                             ; CODE XREF: sub_470C10+1E8j
    lea     eax, [edi+4]
    cmp     edi, eax
    jz      short loc_470E1D

    loc_470E10:                             ; CODE XREF: sub_470C10+20Bj
    mov     ecx, [esp+20h+var_10]
    mov     [edi], ecx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_470E10

    loc_470E1D:                             ; CODE XREF: sub_470C10+1C2j
                                            ; sub_470C10+1D1j ...
    add     dword ptr [esi+8], 4

    loc_470E21:                             ; CODE XREF: sub_470C10+180j
    mov     edx, [esp+20h+arg_4]
    mov     [ebx+1Ch], ebp
    mov     [ebx+18h], edx

    loc_470E2B:                             ; CODE XREF: sub_470C10+1Ej
    mov     [esp+20h+var_C], 1

    loc_470E33:                             ; CODE XREF: sub_470C10+3Cj
                                            ; sub_470C10+62j
    mov     eax, [esp+20h+var_C]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    sub_470C10 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+14h]
    test    eax, eax
    jz      short loc_470E67
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_470E67:                             ; CODE XREF: .text:00470E5Cj
    mov     edi, [esi+8]
    mov     eax, [esi+0Ch]
    cmp     edi, eax
    jz      short loc_470EA9
    lea     ebx, [edi+4]

    loc_470E74:                             ; CODE XREF: .text:00470EA7j
    mov     eax, [edi]
    push    eax
    call    sub_4D85A0
    mov     ecx, [esi+0Ch]
    mov     eax, ebx
    add     esp, 4
    cmp     eax, ecx
    jz      short loc_470E98
    mov     edx, edi
    sub     edx, ebx

    loc_470E8C:                             ; CODE XREF: .text:00470E96j
    mov     ebp, [eax]
    mov     [eax+edx], ebp
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_470E8C

    loc_470E98:                             ; CODE XREF: .text:00470E86j
    mov     eax, [esi+0Ch]
    add     eax, 0FFFFFFFCh
    cmp     edi, eax
    mov     [esp+10h], eax
    mov     [esi+0Ch], eax
    jnz     short loc_470E74

    loc_470EA9:                             ; CODE XREF: .text:00470E6Fj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470EB0 proc near                    ; CODE XREF: .text:0047135Cp
                                            ; .text:0047148Cp ...
    mov     edx, [ecx+20h]
    push    esi
    mov     esi, [ecx+1Ch]
    xor     eax, eax
    cmp     edx, esi
    jge     short loc_470EC8
    mov     eax, [ecx+14h]
    inc     edx
    mov     eax, [eax+edx*4-4]
    mov     [ecx+20h], edx

    loc_470EC8:                             ; CODE XREF: sub_470EB0+Bj
    pop     esi
    retn    4
    sub_470EB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470ED0 proc near                    ; CODE XREF: sub_471430+33p
                                            ; sub_471560+33p ...

    arg_0= dword ptr  4

    mov     eax, [ecx+20h]
    mov     edx, [esp+arg_0]
    dec     eax
    mov     [ecx+20h], eax
    mov     ecx, [ecx+14h]
    mov     [ecx+eax*4], edx
    retn    4
    sub_470ED0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_49. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470F00 proc near                    ; CODE XREF: sub_470C10+12Dp
                                            ; sub_470C10+199p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_470F27
    mov     eax, [esp+arg_8]
    push    esi

    loc_470F11:                             ; CODE XREF: sub_470F00+21j
    test    eax, eax
    jz      short loc_470F19
    mov     esi, [ecx]
    mov     [eax], esi

    loc_470F19:                             ; CODE XREF: sub_470F00+13j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_470F11
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_470F27:                             ; CODE XREF: sub_470F00+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_470F00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470F30 proc near                    ; CODE XREF: sub_470C10+11Dp
                                            ; sub_470C10+1B8p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_4]
    test    ecx, ecx
    jbe     short locret_470F50
    mov     edx, [esp+arg_8]
    mov     eax, [esp+arg_0]
    push    esi

    loc_470F41:                             ; CODE XREF: sub_470F30+1Dj
    test    eax, eax
    jz      short loc_470F49
    mov     esi, [edx]
    mov     [eax], esi

    loc_470F49:                             ; CODE XREF: sub_470F30+13j
    add     eax, 4
    dec     ecx
    jnz     short loc_470F41
    pop     esi

    locret_470F50:                          ; CODE XREF: sub_470F30+6j
    retn    0Ch
    sub_470F30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_470F60 proc near                    ; CODE XREF: sub_470C10+104p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short locret_470F70
    mov     ecx, [esp+arg_4]
    mov     edx, [ecx]
    mov     [eax], edx

    locret_470F70:                          ; CODE XREF: sub_470F60+6j
    retn    8
    sub_470F60 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    push    ebx
    mov     bl, [esp+7]
    mov     eax, ecx
    push    esi
    push    edi
    mov     esi, 0Ah
    lea     edx, [eax+8]
    xor     edi, edi

    loc_470F94:                             ; CODE XREF: .text:00470FA3j
    mov     [edx-8], bl
    mov     [edx-4], edi
    mov     [edx], edi
    mov     [edx+4], edi
    add     edx, 10h
    dec     esi
    jnz     short loc_470F94
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     [esp+14h], ecx
    lea     esi, [ecx+8]
    mov     dword ptr [esp+10h], 0Ah

    loc_470FC6:                             ; CODE XREF: .text:00471011j
    mov     edi, [esi-4]
    mov     eax, [esi]
    cmp     edi, eax
    jz      short loc_471005
    lea     ebx, [edi+4]

    loc_470FD2:                             ; CODE XREF: .text:00471003j
    mov     ecx, [edi]
    test    ecx, ecx
    jz      short loc_470FDE
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_470FDE:                             ; CODE XREF: .text:00470FD6j
    mov     ecx, [esi]
    mov     eax, ebx
    cmp     eax, ecx
    jz      short loc_470FF6
    mov     edx, edi
    sub     edx, ebx

    loc_470FEA:                             ; CODE XREF: .text:00470FF4j
    mov     ebp, [eax]
    mov     [eax+edx], ebp
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_470FEA

    loc_470FF6:                             ; CODE XREF: .text:00470FE4j
    mov     eax, [esi]
    add     eax, 0FFFFFFFCh
    cmp     edi, eax
    mov     [esp+18h], eax
    mov     [esi], eax
    jnz     short loc_470FD2

    loc_471005:                             ; CODE XREF: .text:00470FCDj
    mov     eax, [esp+10h]
    add     esi, 10h
    dec     eax
    mov     [esp+10h], eax
    jnz     short loc_470FC6
    mov     ecx, [esp+14h]
    mov     edi, 0Ah
    xor     ebx, ebx
    lea     esi, [ecx+0A4h]

    loc_471024:                             ; CODE XREF: .text:00471040j
    mov     eax, [esi-10h]
    sub     esi, 10h
    push    eax
    mov     [esp+1Ch], eax
    call    sub_4B4F20
    add     esp, 4
    dec     edi
    mov     [esi], ebx
    mov     [esi+4], ebx
    mov     [esi+8], ebx
    jnz     short loc_471024
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    lea     ebx, [ecx+8]
    mov     dword ptr [esp+10h], 0Ah

    loc_471062:                             ; CODE XREF: .text:004710CAj
    mov     ebp, [ebx-4]
    mov     eax, [ebx]
    cmp     ebp, eax
    jz      short loc_4710BE
    lea     edi, [ebp+4]

    loc_47106E:                             ; CODE XREF: .text:004710BCj
    mov     esi, [ebp+0]
    mov     ecx, esi
    mov     eax, [esi]
    call    dword ptr [eax+0Ch]
    test    eax, eax
    jz      short loc_4710AD
    test    esi, esi
    jz      short loc_471088
    mov     edx, [esi]
    push    1
    mov     ecx, esi
    call    dword ptr [edx]

    loc_471088:                             ; CODE XREF: .text:0047107Ej
    mov     ecx, [ebx]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_4710A0
    mov     edx, ebp
    sub     edx, edi

    loc_471094:                             ; CODE XREF: .text:0047109Ej
    mov     esi, [eax]
    mov     [eax+edx], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_471094

    loc_4710A0:                             ; CODE XREF: .text:0047108Ej
    mov     eax, [ebx]
    add     eax, 0FFFFFFFCh
    mov     [esp+14h], eax
    mov     [ebx], eax
    jmp     short loc_4710BA
    ; ---------------------------------------------------------------------------

    loc_4710AD:                             ; CODE XREF: .text:0047107Aj
    mov     eax, [esi]
    mov     ecx, esi
    call    dword ptr [eax+4]
    add     ebp, 4
    add     edi, 4

    loc_4710BA:                             ; CODE XREF: .text:004710ABj
    cmp     ebp, [ebx]
    jnz     short loc_47106E

    loc_4710BE:                             ; CODE XREF: .text:00471069j
    mov     eax, [esp+10h]
    add     ebx, 10h
    dec     eax
    mov     [esp+10h], eax
    jnz     short loc_471062
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    mov     ebx, [esp+8]
    push    ebp
    push    esi
    push    edi
    lea     edi, [ecx+8]
    mov     ebp, 0Ah

    loc_4710F0:                             ; CODE XREF: .text:0047110Ej
    mov     esi, [edi-4]
    mov     eax, [edi]
    cmp     esi, eax
    jz      short loc_47110A

    loc_4710F9:                             ; CODE XREF: .text:00471108j
    mov     ecx, [esi]
    push    ebx
    mov     eax, [ecx]
    call    dword ptr [eax+8]
    mov     eax, [edi]
    add     esi, 4
    cmp     esi, eax
    jnz     short loc_4710F9

    loc_47110A:                             ; CODE XREF: .text:004710F7j
    add     edi, 10h
    dec     ebp
    jnz     short loc_4710F0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    push    edi
    movsx   edi, word ptr [esp+10h]
    shl     edi, 4
    add     edi, ecx
    mov     esi, [edi+4]
    mov     eax, [edi+8]
    cmp     esi, eax
    jz      short loc_47114E
    push    ebx
    mov     ebx, [esp+10h]

    loc_47113B:                             ; CODE XREF: .text:0047114Bj
    mov     ecx, [esi]
    push    ebx
    mov     eax, [ecx]
    call    dword ptr [eax+8]
    mov     eax, [edi+8]
    add     esi, 4
    cmp     esi, eax
    jnz     short loc_47113B
    pop     ebx

    loc_47114E:                             ; CODE XREF: .text:00471134j
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    movsx   eax, word ptr [esp+8]
    push    ebx
    push    ebp
    shl     eax, 4
    push    esi
    push    edi
    lea     esi, [eax+ecx]
    mov     ecx, [eax+ecx+4]
    test    ecx, ecx
    jnz     short loc_47117B
    xor     eax, eax
    jmp     short loc_471183
    ; ---------------------------------------------------------------------------

    loc_47117B:                             ; CODE XREF: .text:00471175j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_471183:                             ; CODE XREF: .text:00471179j
    cmp     eax, 190h
    mov     ebx, 4
    jbe     short loc_4711C5
    mov     ecx, [esi+4]
    mov     ecx, [ecx]
    test    ecx, ecx
    jz      short loc_47119E
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_47119E:                             ; CODE XREF: .text:00471196j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4711B8
    sub     edx, eax

    loc_4711AD:                             ; CODE XREF: .text:004711B6j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_4711AD

    loc_4711B8:                             ; CODE XREF: .text:004711A9j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+18h], eax
    mov     [esi+8], eax

    loc_4711C5:                             ; CODE XREF: .text:0047118Dj
    mov     eax, [esi+8]
    mov     ecx, [esi+0Ch]
    sub     ecx, eax
    mov     edi, eax
    sar     ecx, 2
    cmp     ecx, 1
    jnb     loc_47129E
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_4711E6
    xor     ecx, ecx
    jmp     short loc_4711ED
    ; ---------------------------------------------------------------------------

    loc_4711E6:                             ; CODE XREF: .text:004711E0j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2

    loc_4711ED:                             ; CODE XREF: .text:004711E4j
    cmp     ecx, 1
    jbe     short loc_471203
    test    edx, edx
    jnz     short loc_4711FA
    xor     ecx, ecx
    jmp     short loc_471208
    ; ---------------------------------------------------------------------------

    loc_4711FA:                             ; CODE XREF: .text:004711F4j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_471208
    ; ---------------------------------------------------------------------------

    loc_471203:                             ; CODE XREF: .text:004711F0j
    mov     ecx, 1

    loc_471208:                             ; CODE XREF: .text:004711F8j
                                            ; .text:00471201j
    test    edx, edx
    jnz     short loc_471210
    xor     eax, eax
    jmp     short loc_471215
    ; ---------------------------------------------------------------------------

    loc_471210:                             ; CODE XREF: .text:0047120Aj
    sub     eax, edx
    sar     eax, 2

    loc_471215:                             ; CODE XREF: .text:0047120Ej
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h], eax
    jge     short loc_471221
    xor     eax, eax

    loc_471221:                             ; CODE XREF: .text:0047121Dj
    lea     edx, ds:0[eax*4]
    push    edx
    call    sub_4B4F10
    add     esp, 4
    mov     ebx, eax
    mov     eax, [esi+4]
    mov     ecx, esi
    push    ebx
    push    edi
    push    eax
    call    sub_473500
    lea     ecx, [esp+14h]
    mov     ebp, eax
    push    ecx
    push    1
    push    ebp
    mov     ecx, esi
    call    sub_473530
    mov     edx, [esi+8]
    add     ebp, 4
    push    ebp
    push    edx
    push    edi
    mov     ecx, esi
    call    sub_473500
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    eax
    push    ecx
    mov     ecx, esi
    call    nullsub_50
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+1Ch]
    add     esp, 4
    mov     ecx, esi
    lea     eax, [ebx+edx*4]
    mov     [esi+0Ch], eax
    call    sub_472D30
    lea     ecx, [ebx+eax*4+4]
    mov     [esi+4], ebx
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47129E:                             ; CODE XREF: .text:004711D5j
    mov     edx, eax
    sub     edx, edi
    sar     edx, 2
    cmp     edx, 1
    jnb     short loc_4712F5
    lea     ecx, [edi+4]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_473500
    mov     eax, [esi+8]
    lea     edx, [esp+14h]
    mov     ecx, eax
    push    edx
    sub     ecx, edi
    mov     edx, 1
    sar     ecx, 2
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_473530
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_47132D

    loc_4712DF:                             ; CODE XREF: .text:004712E9j
    mov     edx, [esp+14h]
    mov     [eax], edx
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_4712DF
    add     [esi+8], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4712F5:                             ; CODE XREF: .text:004712A8j
    push    eax
    push    eax
    add     eax, 0FFFFFFFCh
    mov     ecx, esi
    push    eax
    call    sub_473500
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_471318

    loc_47130C:                             ; CODE XREF: .text:00471316j
    sub     eax, ebx
    sub     ecx, ebx
    cmp     eax, edi
    mov     edx, [eax]
    mov     [ecx], edx
    jnz     short loc_47130C

    loc_471318:                             ; CODE XREF: .text:0047130Aj
    lea     ecx, [edi+4]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_47132D

    loc_471321:                             ; CODE XREF: .text:0047132Bj
    mov     edx, [esp+14h]
    mov     [eax], edx
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_471321

    loc_47132D:                             ; CODE XREF: .text:004712DDj
                                            ; .text:0047131Fj
    mov     eax, [esi+8]
    pop     edi
    add     eax, ebx
    mov     [esi+8], eax
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    mov     al, byte_51E608
    push    ebx
    xor     ebx, ebx
    push    ebp
    push    esi
    cmp     al, bl
    push    edi
    mov     ebp, ecx
    jz      short loc_471355
    xor     eax, eax
    jmp     short loc_471374
    ; ---------------------------------------------------------------------------

    loc_471355:                             ; CODE XREF: .text:0047134Fj
    push    44h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_471372
    mov     ecx, 11h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_471372:                             ; CODE XREF: .text:00471365j
    mov     eax, edx

    loc_471374:                             ; CODE XREF: .text:00471353j
    cmp     eax, ebx
    jz      short loc_471395
    mov     cl, [esp+20h]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD588
    mov     esi, eax
    jmp     short loc_471397
    ; ---------------------------------------------------------------------------

    loc_471395:                             ; CODE XREF: .text:00471376j
    xor     esi, esi

    loc_471397:                             ; CODE XREF: .text:00471393j
    cmp     esi, ebx
    jz      loc_471428
    mov     eax, [esp+1Ch]
    mov     ecx, [esp+18h]
    mov     edx, [esi]
    push    eax
    mov     eax, [esp+18h]
    push    ecx
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+20h]
    shl     ecx, 4
    mov     [esp+1Ch], esi
    lea     esi, [ecx+ebp]
    mov     ecx, [ecx+ebp+4]
    cmp     ecx, ebx
    jnz     short loc_4713D0
    xor     eax, eax
    jmp     short loc_4713D8
    ; ---------------------------------------------------------------------------

    loc_4713D0:                             ; CODE XREF: .text:004713CAj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_4713D8:                             ; CODE XREF: .text:004713CEj
    cmp     eax, 190h
    jbe     short loc_471416
    mov     edx, [esi+4]
    mov     ecx, [edx]
    cmp     ecx, ebx
    jz      short loc_4713EE
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4713EE:                             ; CODE XREF: .text:004713E6j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_471409
    sub     edx, eax

    loc_4713FD:                             ; CODE XREF: .text:00471407j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4713FD

    loc_471409:                             ; CODE XREF: .text:004713F9j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+20h], eax
    mov     [esi+8], eax

    loc_471416:                             ; CODE XREF: .text:004713DDj
    mov     edx, [esi+8]
    lea     ecx, [esp+1Ch]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_471428:                             ; CODE XREF: .text:00471399j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471430 proc near                    ; DATA XREF: .rdata:004FD588o

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+10h]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     [esi+10h], eax
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    mov     al, [esp+8+arg_0]
    test    al, 1
    mov     dword ptr [esi], offset off_4FD5A8
    jz      short loc_471468
    push    esi
    mov     ecx, offset dword_51E610
    call    sub_470ED0

    loc_471468:                             ; CODE XREF: sub_471430+2Bj
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_471430 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     al, byte_51E608
    push    ebx
    xor     ebx, ebx
    push    ebp
    push    esi
    cmp     al, bl
    push    edi
    mov     ebp, ecx
    jz      short loc_471485
    xor     eax, eax
    jmp     short loc_4714A4
    ; ---------------------------------------------------------------------------

    loc_471485:                             ; CODE XREF: .text:0047147Fj
    push    4Ch
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_4714A2
    mov     ecx, 13h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_4714A2:                             ; CODE XREF: .text:00471495j
    mov     eax, edx

    loc_4714A4:                             ; CODE XREF: .text:00471483j
    cmp     eax, ebx
    jz      short loc_4714C5
    mov     cl, [esp+20h]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD5B8
    mov     esi, eax
    jmp     short loc_4714C7
    ; ---------------------------------------------------------------------------

    loc_4714C5:                             ; CODE XREF: .text:004714A6j
    xor     esi, esi

    loc_4714C7:                             ; CODE XREF: .text:004714C3j
    cmp     esi, ebx
    jz      loc_471558
    mov     eax, [esp+1Ch]
    mov     ecx, [esp+18h]
    mov     edx, [esi]
    push    eax
    mov     eax, [esp+18h]
    push    ecx
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+20h]
    shl     ecx, 4
    mov     [esp+1Ch], esi
    lea     esi, [ecx+ebp]
    mov     ecx, [ecx+ebp+4]
    cmp     ecx, ebx
    jnz     short loc_471500
    xor     eax, eax
    jmp     short loc_471508
    ; ---------------------------------------------------------------------------

    loc_471500:                             ; CODE XREF: .text:004714FAj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_471508:                             ; CODE XREF: .text:004714FEj
    cmp     eax, 190h
    jbe     short loc_471546
    mov     edx, [esi+4]
    mov     ecx, [edx]
    cmp     ecx, ebx
    jz      short loc_47151E
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_47151E:                             ; CODE XREF: .text:00471516j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_471539
    sub     edx, eax

    loc_47152D:                             ; CODE XREF: .text:00471537j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_47152D

    loc_471539:                             ; CODE XREF: .text:00471529j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+20h], eax
    mov     [esi+8], eax

    loc_471546:                             ; CODE XREF: .text:0047150Dj
    mov     edx, [esi+8]
    lea     ecx, [esp+1Ch]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_471558:                             ; CODE XREF: .text:004714C9j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471560 proc near                    ; DATA XREF: .rdata:004FD5B8o

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+10h]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     [esi+10h], eax
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    mov     al, [esp+8+arg_0]
    test    al, 1
    mov     dword ptr [esi], offset off_4FD5A8
    jz      short loc_471598
    push    esi
    mov     ecx, offset dword_51E610
    call    sub_470ED0

    loc_471598:                             ; CODE XREF: sub_471560+2Bj
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_471560 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     al, byte_51E608
    push    ebx
    xor     ebx, ebx
    push    ebp
    push    esi
    cmp     al, bl
    push    edi
    mov     ebp, ecx
    jz      short loc_4715B5
    xor     eax, eax
    jmp     short loc_4715D4
    ; ---------------------------------------------------------------------------

    loc_4715B5:                             ; CODE XREF: .text:004715AFj
    push    44h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_4715D2
    mov     ecx, 11h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_4715D2:                             ; CODE XREF: .text:004715C5j
    mov     eax, edx

    loc_4715D4:                             ; CODE XREF: .text:004715B3j
    cmp     eax, ebx
    jz      short loc_4715F5
    mov     cl, [esp+24h]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD5D8
    mov     esi, eax
    jmp     short loc_4715F7
    ; ---------------------------------------------------------------------------

    loc_4715F5:                             ; CODE XREF: .text:004715D6j
    xor     esi, esi

    loc_4715F7:                             ; CODE XREF: .text:004715F3j
    cmp     esi, ebx
    jz      loc_47168D
    mov     eax, [esp+20h]
    mov     ecx, [esp+1Ch]
    mov     edx, [esi]
    push    eax
    mov     eax, [esp+1Ch]
    push    ecx
    mov     ecx, [esp+1Ch]
    push    eax
    push    ecx
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   edx, word ptr [esp+24h]
    shl     edx, 4
    mov     [esp+20h], esi
    mov     ecx, [edx+ebp+4]
    lea     esi, [edx+ebp]
    cmp     ecx, ebx
    jnz     short loc_471635
    xor     eax, eax
    jmp     short loc_47163D
    ; ---------------------------------------------------------------------------

    loc_471635:                             ; CODE XREF: .text:0047162Fj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_47163D:                             ; CODE XREF: .text:00471633j
    cmp     eax, 190h
    jbe     short loc_47167B
    mov     eax, [esi+4]
    mov     ecx, [eax]
    cmp     ecx, ebx
    jz      short loc_471653
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_471653:                             ; CODE XREF: .text:0047164Bj
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_47166E
    sub     edx, eax

    loc_471662:                             ; CODE XREF: .text:0047166Cj
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_471662

    loc_47166E:                             ; CODE XREF: .text:0047165Ej
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+24h], eax
    mov     [esi+8], eax

    loc_47167B:                             ; CODE XREF: .text:00471642j
    mov     ecx, [esi+8]
    lea     eax, [esp+20h]
    push    eax
    push    1
    push    ecx
    mov     ecx, esi
    call    sub_4732E0

    loc_47168D:                             ; CODE XREF: .text:004715F9j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4716A0 proc near                    ; DATA XREF: .rdata:004FD5D8o

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+10h]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     [esi+10h], eax
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    mov     al, [esp+8+arg_0]
    test    al, 1
    mov     dword ptr [esi], offset off_4FD5A8
    jz      short loc_4716D8
    push    esi
    mov     ecx, offset dword_51E610
    call    sub_470ED0

    loc_4716D8:                             ; CODE XREF: sub_4716A0+2Bj
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_4716A0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     al, byte_51E608
    push    ebx
    xor     ebx, ebx
    push    ebp
    push    esi
    cmp     al, bl
    push    edi
    mov     ebp, ecx
    jz      short loc_4716F5
    xor     eax, eax
    jmp     short loc_471714
    ; ---------------------------------------------------------------------------

    loc_4716F5:                             ; CODE XREF: .text:004716EFj
    push    48h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_471712
    mov     ecx, 12h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_471712:                             ; CODE XREF: .text:00471705j
    mov     eax, edx

    loc_471714:                             ; CODE XREF: .text:004716F3j
    cmp     eax, ebx
    jz      short loc_471735
    mov     cl, [esp+24h]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD5F8
    mov     esi, eax
    jmp     short loc_471737
    ; ---------------------------------------------------------------------------

    loc_471735:                             ; CODE XREF: .text:00471716j
    xor     esi, esi

    loc_471737:                             ; CODE XREF: .text:00471733j
    cmp     esi, ebx
    jz      loc_4717D2
    mov     eax, [esp+28h]
    mov     ecx, [esp+20h]
    mov     edx, [esi]
    push    eax
    mov     eax, [esp+20h]
    push    ecx
    mov     ecx, [esp+20h]
    push    eax
    mov     eax, [esp+20h]
    push    ecx
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+24h]
    shl     ecx, 4
    mov     [esp+28h], esi
    lea     esi, [ecx+ebp]
    mov     ecx, [ecx+ebp+4]
    cmp     ecx, ebx
    jnz     short loc_47177A
    xor     eax, eax
    jmp     short loc_471782
    ; ---------------------------------------------------------------------------

    loc_47177A:                             ; CODE XREF: .text:00471774j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_471782:                             ; CODE XREF: .text:00471778j
    cmp     eax, 190h
    jbe     short loc_4717C0
    mov     edx, [esi+4]
    mov     ecx, [edx]
    cmp     ecx, ebx
    jz      short loc_471798
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_471798:                             ; CODE XREF: .text:00471790j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4717B3
    sub     edx, eax

    loc_4717A7:                             ; CODE XREF: .text:004717B1j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4717A7

    loc_4717B3:                             ; CODE XREF: .text:004717A3j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+24h], eax
    mov     [esi+8], eax

    loc_4717C0:                             ; CODE XREF: .text:00471787j
    mov     edx, [esi+8]
    lea     ecx, [esp+28h]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_4717D2:                             ; CODE XREF: .text:00471739j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    18h
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4717E0 proc near                    ; DATA XREF: .rdata:004FD5F8o

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+10h]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     [esi+10h], eax
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    mov     al, [esp+8+arg_0]
    test    al, 1
    mov     dword ptr [esi], offset off_4FD5A8
    jz      short loc_471818
    push    esi
    mov     ecx, offset dword_51E610
    call    sub_470ED0

    loc_471818:                             ; CODE XREF: sub_4717E0+2Bj
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_4717E0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     al, byte_51E608
    push    ebx
    push    ebp
    push    esi
    test    al, al
    push    edi
    mov     ebx, ecx
    jz      short loc_471833
    xor     ecx, ecx
    jmp     short loc_471852
    ; ---------------------------------------------------------------------------

    loc_471833:                             ; CODE XREF: .text:0047182Dj
    push    38h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    test    edx, edx
    jz      short loc_471850
    mov     ecx, 0Eh
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_471850:                             ; CODE XREF: .text:00471843j
    mov     ecx, edx

    loc_471852:                             ; CODE XREF: .text:00471831j
    test    ecx, ecx
    jz      short loc_47185F
    call    sub_474CD0
    mov     esi, eax
    jmp     short loc_471861
    ; ---------------------------------------------------------------------------

    loc_47185F:                             ; CODE XREF: .text:00471854j
    xor     esi, esi

    loc_471861:                             ; CODE XREF: .text:0047185Dj
    test    esi, esi
    jz      loc_471A45
    mov     ecx, [esp+2Ch]
    mov     edx, [esp+24h]
    mov     eax, [esi]
    push    ecx
    mov     ecx, [esp+24h]
    push    edx
    mov     edx, [esp+24h]
    push    ecx
    mov     ecx, [esp+24h]
    push    edx
    mov     edx, [esp+24h]
    push    ecx
    push    edx
    mov     ecx, esi
    call    dword ptr [eax+18h]
    movsx   eax, word ptr [esp+28h]
    shl     eax, 4
    mov     [esp+2Ch], esi
    mov     ecx, [eax+ebx+4]
    lea     esi, [eax+ebx]
    test    ecx, ecx
    jnz     short loc_4718A9
    xor     eax, eax
    jmp     short loc_4718B1
    ; ---------------------------------------------------------------------------

    loc_4718A9:                             ; CODE XREF: .text:004718A3j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_4718B1:                             ; CODE XREF: .text:004718A7j
    cmp     eax, 190h
    mov     ebx, 4
    jbe     short loc_4718F3
    mov     ecx, [esi+4]
    mov     ecx, [ecx]
    test    ecx, ecx
    jz      short loc_4718CC
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_4718CC:                             ; CODE XREF: .text:004718C4j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4718E6
    sub     edx, eax

    loc_4718DB:                             ; CODE XREF: .text:004718E4j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_4718DB

    loc_4718E6:                             ; CODE XREF: .text:004718D7j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+28h], eax
    mov     [esi+8], eax

    loc_4718F3:                             ; CODE XREF: .text:004718BBj
    mov     edi, [esi+8]
    mov     eax, [esi+0Ch]
    sub     eax, edi
    sar     eax, 2
    cmp     eax, 1
    jnb     loc_4719B3
    mov     ecx, esi
    call    sub_472D30
    cmp     eax, 1
    jbe     short loc_47191E
    mov     ecx, esi
    call    sub_472D30
    mov     ebx, eax
    jmp     short loc_471923
    ; ---------------------------------------------------------------------------

    loc_47191E:                             ; CODE XREF: .text:00471911j
    mov     ebx, 1

    loc_471923:                             ; CODE XREF: .text:0047191Cj
    mov     ecx, esi
    call    sub_472D30
    mov     ebp, eax
    add     ebp, ebx
    mov     eax, ebp
    jns     short loc_471934
    xor     eax, eax

    loc_471934:                             ; CODE XREF: .text:00471930j
    lea     ecx, ds:0[eax*4]
    push    ecx
    call    sub_4B4F10
    mov     edx, [esi+4]
    add     esp, 4
    mov     ebx, eax
    mov     ecx, esi
    push    ebx
    push    edi
    push    edx
    call    sub_473500
    lea     ecx, [esp+2Ch]
    mov     [esp+28h], eax
    push    ecx
    push    1
    push    eax
    mov     ecx, esi
    call    sub_473530
    mov     edx, [esp+28h]
    mov     eax, [esi+8]
    add     edx, 4
    mov     ecx, esi
    push    edx
    push    eax
    push    edi
    call    sub_473500
    mov     ecx, [esi+8]
    mov     edx, [esi+4]
    push    ecx
    push    edx
    mov     ecx, esi
    call    nullsub_50
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    lea     ecx, [ebx+ebp*4]
    add     esp, 4
    mov     [esi+0Ch], ecx
    mov     ecx, esi
    call    sub_472D30
    lea     edx, [ebx+eax*4+4]
    mov     [esi+4], ebx
    mov     [esi+8], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4719B3:                             ; CODE XREF: .text:00471901j
    mov     eax, edi
    sub     eax, edi
    sar     eax, 2
    cmp     eax, 1
    jnb     short loc_471A0A
    lea     ecx, [edi+4]
    push    ecx
    push    edi
    push    edi
    mov     ecx, esi
    call    sub_473500
    mov     eax, [esi+8]
    lea     edx, [esp+2Ch]
    mov     ecx, eax
    push    edx
    sub     ecx, edi
    mov     edx, 1
    sar     ecx, 2
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_473530
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_471A42

    loc_4719F4:                             ; CODE XREF: .text:004719FEj
    mov     edx, [esp+2Ch]
    mov     [eax], edx
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_4719F4
    add     [esi+8], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_471A0A:                             ; CODE XREF: .text:004719BDj
    push    edi
    lea     eax, [edi-4]
    push    edi
    push    eax
    mov     ecx, esi
    call    sub_473500
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_471A2D

    loc_471A21:                             ; CODE XREF: .text:00471A2Bj
    sub     eax, ebx
    sub     ecx, ebx
    cmp     eax, edi
    mov     edx, [eax]
    mov     [ecx], edx
    jnz     short loc_471A21

    loc_471A2D:                             ; CODE XREF: .text:00471A1Fj
    lea     ecx, [edi+4]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_471A42

    loc_471A36:                             ; CODE XREF: .text:00471A40j
    mov     edx, [esp+2Ch]
    mov     [eax], edx
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_471A36

    loc_471A42:                             ; CODE XREF: .text:004719F2j
                                            ; .text:00471A34j
    add     [esi+8], ebx

    loc_471A45:                             ; CODE XREF: .text:00471863j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     al, byte_51E608
    push    ebx
    push    ebp
    push    esi
    test    al, al
    push    edi
    mov     ebx, ecx
    jz      short loc_471A63
    xor     ecx, ecx
    jmp     short loc_471A82
    ; ---------------------------------------------------------------------------

    loc_471A63:                             ; CODE XREF: .text:00471A5Dj
    push    34h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    test    edx, edx
    jz      short loc_471A80
    mov     ecx, 0Dh
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_471A80:                             ; CODE XREF: .text:00471A73j
    mov     ecx, edx

    loc_471A82:                             ; CODE XREF: .text:00471A61j
    test    ecx, ecx
    jz      short loc_471A8F
    call    sub_4750B0
    mov     esi, eax
    jmp     short loc_471A91
    ; ---------------------------------------------------------------------------

    loc_471A8F:                             ; CODE XREF: .text:00471A84j
    xor     esi, esi

    loc_471A91:                             ; CODE XREF: .text:00471A8Dj
    test    esi, esi
    jz      loc_471C6B
    mov     ecx, [esp+20h]
    mov     edx, [esp+1Ch]
    mov     eax, [esi]
    push    ecx
    mov     ecx, [esp+1Ch]
    push    edx
    mov     edx, [esp+1Ch]
    push    ecx
    push    edx
    mov     ecx, esi
    call    dword ptr [eax+18h]
    movsx   eax, word ptr [esp+24h]
    shl     eax, 4
    mov     [esp+20h], esi
    mov     ecx, [eax+ebx+4]
    lea     esi, [eax+ebx]
    test    ecx, ecx
    jnz     short loc_471ACF
    xor     eax, eax
    jmp     short loc_471AD7
    ; ---------------------------------------------------------------------------

    loc_471ACF:                             ; CODE XREF: .text:00471AC9j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_471AD7:                             ; CODE XREF: .text:00471ACDj
    cmp     eax, 190h
    mov     ebx, 4
    jbe     short loc_471B19
    mov     ecx, [esi+4]
    mov     ecx, [ecx]
    test    ecx, ecx
    jz      short loc_471AF2
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_471AF2:                             ; CODE XREF: .text:00471AEAj
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_471B0C
    sub     edx, eax

    loc_471B01:                             ; CODE XREF: .text:00471B0Aj
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_471B01

    loc_471B0C:                             ; CODE XREF: .text:00471AFDj
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+24h], eax
    mov     [esi+8], eax

    loc_471B19:                             ; CODE XREF: .text:00471AE1j
    mov     edi, [esi+8]
    mov     eax, [esi+0Ch]
    sub     eax, edi
    sar     eax, 2
    cmp     eax, 1
    jnb     loc_471BD9
    mov     ecx, esi
    call    sub_472D30
    cmp     eax, 1
    jbe     short loc_471B44
    mov     ecx, esi
    call    sub_472D30
    mov     ebx, eax
    jmp     short loc_471B49
    ; ---------------------------------------------------------------------------

    loc_471B44:                             ; CODE XREF: .text:00471B37j
    mov     ebx, 1

    loc_471B49:                             ; CODE XREF: .text:00471B42j
    mov     ecx, esi
    call    sub_472D30
    mov     ebp, eax
    add     ebp, ebx
    mov     eax, ebp
    jns     short loc_471B5A
    xor     eax, eax

    loc_471B5A:                             ; CODE XREF: .text:00471B56j
    lea     ecx, ds:0[eax*4]
    push    ecx
    call    sub_4B4F10
    mov     edx, [esi+4]
    add     esp, 4
    mov     ebx, eax
    mov     ecx, esi
    push    ebx
    push    edi
    push    edx
    call    sub_473500
    lea     ecx, [esp+20h]
    mov     [esp+24h], eax
    push    ecx
    push    1
    push    eax
    mov     ecx, esi
    call    sub_473530
    mov     edx, [esp+24h]
    mov     eax, [esi+8]
    add     edx, 4
    mov     ecx, esi
    push    edx
    push    eax
    push    edi
    call    sub_473500
    mov     ecx, [esi+8]
    mov     edx, [esi+4]
    push    ecx
    push    edx
    mov     ecx, esi
    call    nullsub_50
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    lea     ecx, [ebx+ebp*4]
    add     esp, 4
    mov     [esi+0Ch], ecx
    mov     ecx, esi
    call    sub_472D30
    lea     edx, [ebx+eax*4+4]
    mov     [esi+4], ebx
    mov     [esi+8], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_471BD9:                             ; CODE XREF: .text:00471B27j
    mov     eax, edi
    sub     eax, edi
    sar     eax, 2
    cmp     eax, 1
    jnb     short loc_471C30
    lea     ecx, [edi+4]
    push    ecx
    push    edi
    push    edi
    mov     ecx, esi
    call    sub_473500
    mov     eax, [esi+8]
    lea     edx, [esp+20h]
    mov     ecx, eax
    push    edx
    sub     ecx, edi
    mov     edx, 1
    sar     ecx, 2
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_473530
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_471C68

    loc_471C1A:                             ; CODE XREF: .text:00471C24j
    mov     edx, [esp+20h]
    mov     [eax], edx
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_471C1A
    add     [esi+8], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_471C30:                             ; CODE XREF: .text:00471BE3j
    push    edi
    lea     eax, [edi-4]
    push    edi
    push    eax
    mov     ecx, esi
    call    sub_473500
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_471C53

    loc_471C47:                             ; CODE XREF: .text:00471C51j
    sub     eax, ebx
    sub     ecx, ebx
    cmp     eax, edi
    mov     edx, [eax]
    mov     [ecx], edx
    jnz     short loc_471C47

    loc_471C53:                             ; CODE XREF: .text:00471C45j
    lea     ecx, [edi+4]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_471C68

    loc_471C5C:                             ; CODE XREF: .text:00471C66j
    mov     edx, [esp+20h]
    mov     [eax], edx
    add     eax, ebx
    cmp     eax, ecx
    jnz     short loc_471C5C

    loc_471C68:                             ; CODE XREF: .text:00471C18j
                                            ; .text:00471C5Aj
    add     [esi+8], ebx

    loc_471C6B:                             ; CODE XREF: .text:00471A93j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h
    push    4Ch
    push    3E8h
    mov     ecx, offset dword_51E610
    call    sub_470A90
    push    offset loc_471CA0
    call    _atexit
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_471CA0:                             ; DATA XREF: .text:00471C91o
    mov     cl, byte_51E634
    mov     al, 1
    test    al, cl
    jnz     short locret_471CBE
    or      cl, al
    mov     byte_51E634, cl
    mov     ecx, offset dword_51E610
    jmp     loc_470B80
    ; ---------------------------------------------------------------------------

    locret_471CBE:                          ; CODE XREF: .text:00471CAAj
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [00000010 BYTES: COLLAPSED FUNCTION DNameNode::DNameNode(void). PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471CD0 proc near                    ; DATA XREF: .rdata:004FD5A8o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD5A8
    jz      short loc_471CEC
    push    esi
    mov     ecx, offset dword_51E610
    call    sub_470ED0

    loc_471CEC:                             ; CODE XREF: sub_471CD0+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_471CD0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000007 BYTES: COLLAPSED FUNCTION unknown_libname_31. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     al, byte_51E608
    test    al, al
    jz      short loc_471D1E
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_471D1E:                             ; CODE XREF: .text:00471D17j
    push    esi
    mov     esi, [esp+8]
    push    esi
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    test    edx, edx
    jz      short loc_471D48
    mov     ecx, esi
    push    edi
    xor     eax, eax
    mov     edi, edx
    shr     ecx, 2
    rep stosd
    mov     ecx, esi
    and     ecx, 3
    rep stosb
    pop     edi

    loc_471D48:                             ; CODE XREF: .text:00471D32j
    mov     eax, edx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471D50 proc near                    ; CODE XREF: sub_474D10+2Ep
                                            ; sub_475110+2Ep

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, offset dword_51E610
    push    eax
    call    sub_470ED0
    retn    4
    sub_471D50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471D70 proc near                    ; CODE XREF: sub_4736E0+Ap
                                            ; sub_473B50+Bp ...

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+38A47h]
    mov     eax, [esp+arg_0]
    add     edx, eax
    mov     [ecx+4], edx
    retn    4
    sub_471D70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471D90 proc near                    ; CODE XREF: sub_4917D0+E1p

    var_1= byte ptr -1

    push    ecx
    push    esi
    push    0A0h                            ; int
    call    sub_4B4F10
    xor     esi, esi
    add     esp, 4
    cmp     eax, esi
    jz      short loc_471DC6
    push    ebx
    mov     bl, [esp+0Ch+var_1]
    lea     ecx, [eax+8]
    mov     edx, 0Ah

    loc_471DB2:                             ; CODE XREF: sub_471D90+31j
    mov     [ecx-8], bl
    mov     [ecx-4], esi
    mov     [ecx], esi
    mov     [ecx+4], esi
    add     ecx, 10h
    dec     edx
    jnz     short loc_471DB2
    mov     esi, eax
    pop     ebx

    loc_471DC6:                             ; CODE XREF: sub_471D90+13j
    mov     eax, TAdynmemStructPtr
    mov     [eax+38D77h], esi
    pop     esi
    pop     ecx
    retn
    sub_471D90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471DE0 proc near                    ; CODE XREF: sub_491B60+3Ap

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8

    sub     esp, 0Ch
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    xor     ebp, ebp
    mov     ebx, [eax+38D77h]
    cmp     ebx, ebp
    mov     [esp+14h+var_8], ebx
    jz      loc_471E9D
    push    edi
    push    esi
    lea     esi, [ebx+8]
    mov     [esp+1Ch+var_C], 0Ah

    loc_471E0B:                             ; CODE XREF: sub_471DE0+7Aj
    mov     edi, [esi-4]
    mov     eax, [esi]
    cmp     edi, eax
    jz      short loc_471E4E
    lea     ebx, [edi+4]

    loc_471E17:                             ; CODE XREF: sub_471DE0+68j
    mov     ecx, [edi]
    test    ecx, ecx
    jz      short loc_471E23
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_471E23:                             ; CODE XREF: sub_471DE0+3Bj
    mov     ecx, [esi]
    mov     eax, ebx
    cmp     eax, ecx
    jz      short loc_471E3B
    mov     edx, edi
    sub     edx, ebx

    loc_471E2F:                             ; CODE XREF: sub_471DE0+59j
    mov     ebp, [eax]
    mov     [edx+eax], ebp
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_471E2F

    loc_471E3B:                             ; CODE XREF: sub_471DE0+49j
    mov     eax, [esi]
    add     eax, 0FFFFFFFCh
    cmp     edi, eax
    mov     [esp+20h+var_8], eax
    mov     [esi], eax
    jnz     short loc_471E17
    mov     ebx, [esp+20h+var_C]

    loc_471E4E:                             ; CODE XREF: sub_471DE0+32j
    mov     eax, [esp+20h+var_10]
    add     esi, 10h
    dec     eax
    mov     [esp+20h+var_10], eax
    jnz     short loc_471E0B
    lea     esi, [ebx+0A4h]
    mov     edi, 0Ah
    xor     ebp, ebp

    loc_471E69:                             ; CODE XREF: sub_471DE0+A5j
    mov     eax, [esi-10h]
    sub     esi, 10h
    push    eax
    mov     [esp+24h+var_8], eax
    call    sub_4B4F20
    add     esp, 4
    dec     edi
    mov     [esi], ebp
    mov     [esi+4], ebp
    mov     [esi+8], ebp
    jnz     short loc_471E69
    push    ebx
    call    sub_4B4F20
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    pop     esi
    pop     edi
    mov     [eax+38D77h], ebp

    loc_471E9D:                             ; CODE XREF: sub_471DE0+18j
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_471DE0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471EB0 proc near                    ; CODE XREF: .text:004955BFp

    var_8= dword ptr -8

    sub     esp, 8
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ebx, [eax+38D77h]
    push    edi
    add     ebx, 8
    mov     [esp+18h+var_8], 0Ah

    loc_471ECD:                             ; CODE XREF: sub_471EB0+85j
    mov     ebp, [ebx-4]
    mov     eax, [ebx]
    cmp     ebp, eax
    jz      short loc_471F29
    lea     edi, [ebp+4]

    loc_471ED9:                             ; CODE XREF: sub_471EB0+77j
    mov     esi, [ebp+0]
    mov     ecx, esi
    mov     edx, [esi]
    call    dword ptr [edx+0Ch]
    test    eax, eax
    jz      short loc_471F18
    test    esi, esi
    jz      short loc_471EF3
    mov     eax, [esi]
    push    1
    mov     ecx, esi
    call    dword ptr [eax]

    loc_471EF3:                             ; CODE XREF: sub_471EB0+39j
    mov     ecx, [ebx]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_471F0B
    mov     edx, ebp
    sub     edx, edi

    loc_471EFF:                             ; CODE XREF: sub_471EB0+59j
    mov     esi, [eax]
    mov     [eax+edx], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_471EFF

    loc_471F0B:                             ; CODE XREF: sub_471EB0+49j
    mov     eax, [ebx]
    add     eax, 0FFFFFFFCh
    mov     [esp+1Ch+var_8], eax
    mov     [ebx], eax
    jmp     short loc_471F25
    ; ---------------------------------------------------------------------------

    loc_471F18:                             ; CODE XREF: sub_471EB0+35j
    mov     edx, [esi]
    mov     ecx, esi
    call    dword ptr [edx+4]
    add     ebp, 4
    add     edi, 4

    loc_471F25:                             ; CODE XREF: sub_471EB0+66j
    cmp     ebp, [ebx]
    jnz     short loc_471ED9

    loc_471F29:                             ; CODE XREF: sub_471EB0+24j
    mov     eax, [esp+18h+var_8]
    add     ebx, 10h
    dec     eax
    mov     [esp+18h+var_8], eax
    jnz     short loc_471ECD
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    sub_471EB0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+8]
    push    ebp
    mov     eax, [eax+38D77h]
    push    esi
    push    edi
    mov     ebp, 0Ah
    lea     edi, [eax+8]

    loc_471F5B:                             ; CODE XREF: .text:00471F79j
    mov     esi, [edi-4]
    mov     eax, [edi]
    cmp     esi, eax
    jz      short loc_471F75

    loc_471F64:                             ; CODE XREF: .text:00471F73j
    mov     ecx, [esi]
    push    ebx
    mov     edx, [ecx]
    call    dword ptr [edx+8]
    mov     eax, [edi]
    add     esi, 4
    cmp     esi, eax
    jnz     short loc_471F64

    loc_471F75:                             ; CODE XREF: .text:00471F62j
    add     edi, 10h
    dec     ebp
    jnz     short loc_471F5B
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471F90 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+B59p
                                            ; GameUnit_LOS_Unknown1+B65p ...

    arg_0= dword ptr  4
    arg_4= word ptr  8

    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    movsx   edi, [esp+8+arg_4]
    mov     ecx, [eax+38D77h]
    shl     edi, 4
    add     edi, ecx
    mov     esi, [edi+4]
    mov     eax, [edi+8]
    cmp     esi, eax
    jz      short loc_471FC9
    push    ebx
    mov     ebx, [esp+0Ch+arg_0]

    loc_471FB6:                             ; CODE XREF: sub_471F90+36j
    mov     ecx, [esi]
    push    ebx
    mov     edx, [ecx]
    call    dword ptr [edx+8]
    mov     eax, [edi+8]
    add     esi, 4
    cmp     esi, eax
    jnz     short loc_471FB6
    pop     ebx

    loc_471FC9:                             ; CODE XREF: sub_471F90+1Fj
    pop     edi
    pop     esi
    retn    8
    sub_471F90 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_471FD0 proc near                    ; CODE XREF: .text:00406B9Fp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= byte ptr  10h

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    xor     ebx, ebx
    mov     ebp, [eax+38D77h]
    mov     al, byte_51E608
    push    esi
    cmp     al, bl
    push    edi
    jz      short loc_471FEE
    xor     eax, eax
    jmp     short loc_47200D
    ; ---------------------------------------------------------------------------

    loc_471FEE:                             ; CODE XREF: sub_471FD0+18j
    push    44h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_47200B
    mov     ecx, 11h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_47200B:                             ; CODE XREF: sub_471FD0+2Ej
    mov     eax, edx

    loc_47200D:                             ; CODE XREF: sub_471FD0+1Cj
    cmp     eax, ebx
    jz      short loc_47202E
    mov     cl, [esp+10h+arg_C]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD588
    mov     esi, eax
    jmp     short loc_472030
    ; ---------------------------------------------------------------------------

    loc_47202E:                             ; CODE XREF: sub_471FD0+3Fj
    xor     esi, esi

    loc_472030:                             ; CODE XREF: sub_471FD0+5Cj
    cmp     esi, ebx
    jz      loc_4720C1
    mov     eax, [esp+10h+arg_8]
    mov     ecx, [esp+10h+arg_4]
    mov     edx, [esi]
    push    eax
    mov     eax, [esp+14h+arg_0]
    push    ecx
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+10h+arg_C]
    shl     ecx, 4
    mov     [esp+10h+arg_8], esi
    lea     esi, [ecx+ebp]
    mov     ecx, [ecx+ebp+4]
    cmp     ecx, ebx
    jnz     short loc_472069
    xor     eax, eax
    jmp     short loc_472071
    ; ---------------------------------------------------------------------------

    loc_472069:                             ; CODE XREF: sub_471FD0+93j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_472071:                             ; CODE XREF: sub_471FD0+97j
    cmp     eax, 190h
    jbe     short loc_4720AF
    mov     edx, [esi+4]
    mov     ecx, [edx]
    cmp     ecx, ebx
    jz      short loc_472087
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_472087:                             ; CODE XREF: sub_471FD0+AFj
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4720A2
    sub     edx, eax

    loc_472096:                             ; CODE XREF: sub_471FD0+D0j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_472096

    loc_4720A2:                             ; CODE XREF: sub_471FD0+C2j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     dword ptr [esp+10h+arg_C], eax
    mov     [esi+8], eax

    loc_4720AF:                             ; CODE XREF: sub_471FD0+A6j
    mov     edx, [esi+8]
    lea     ecx, [esp+10h+arg_8]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_4720C1:                             ; CODE XREF: sub_471FD0+62j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_471FD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4720D0 proc near                    ; CODE XREF: .text:004025AEp
                                            ; .text:00402ABDp ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    sub     esp, 18h
    mov     eax, [esp+18h+arg_0]
    push    ebx
    mov     ecx, eax
    push    ebp
    xor     ebx, ebx
    push    esi
    mov     edx, [ecx]
    push    edi
    mov     [esp+28h+var_18], edx
    mov     edx, [ecx+4]
    mov     [esp+28h+var_14], edx
    mov     edx, [eax]
    mov     ecx, [ecx+8]
    mov     [esp+28h+var_C], edx
    mov     edx, [eax+8]
    mov     [esp+28h+var_10], ecx
    mov     ecx, [eax+4]
    mov     eax, TAdynmemStructPtr
    mov     [esp+28h+var_8], ecx
    mov     [esp+28h+var_4], edx
    mov     ebp, [eax+38D77h]
    mov     al, byte_51E608
    cmp     al, bl
    jz      short loc_47211F
    xor     eax, eax
    jmp     short loc_47213E
    ; ---------------------------------------------------------------------------

    loc_47211F:                             ; CODE XREF: sub_4720D0+49j
    push    4Ch
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_47213C
    mov     ecx, 13h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_47213C:                             ; CODE XREF: sub_4720D0+5Fj
    mov     eax, edx

    loc_47213E:                             ; CODE XREF: sub_4720D0+4Dj
    cmp     eax, ebx
    jz      short loc_47215F
    mov     cl, [esp+28h+arg_8]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD5B8
    mov     esi, eax
    jmp     short loc_472161
    ; ---------------------------------------------------------------------------

    loc_47215F:                             ; CODE XREF: sub_4720D0+70j
    xor     esi, esi

    loc_472161:                             ; CODE XREF: sub_4720D0+8Dj
    cmp     esi, ebx
    jz      loc_4721EF
    mov     eax, [esp+28h+arg_4]
    mov     edx, [esi]
    push    1
    lea     ecx, [esp+2Ch+var_18]
    push    eax
    push    ecx
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   edx, word ptr [esp+28h+arg_8]
    shl     edx, 4
    mov     [esp+28h+arg_0], esi
    mov     ecx, [edx+ebp+4]
    lea     esi, [edx+ebp]
    cmp     ecx, ebx
    jnz     short loc_472197
    xor     eax, eax
    jmp     short loc_47219F
    ; ---------------------------------------------------------------------------

    loc_472197:                             ; CODE XREF: sub_4720D0+C1j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_47219F:                             ; CODE XREF: sub_4720D0+C5j
    cmp     eax, 190h
    jbe     short loc_4721DD
    mov     eax, [esi+4]
    mov     ecx, [eax]
    cmp     ecx, ebx
    jz      short loc_4721B5
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_4721B5:                             ; CODE XREF: sub_4720D0+DDj
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4721D0
    sub     edx, eax

    loc_4721C4:                             ; CODE XREF: sub_4720D0+FEj
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4721C4

    loc_4721D0:                             ; CODE XREF: sub_4720D0+F0j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     dword ptr [esp+28h+arg_8], eax
    mov     [esi+8], eax

    loc_4721DD:                             ; CODE XREF: sub_4720D0+D4j
    mov     ecx, [esi+8]
    lea     eax, [esp+28h+arg_0]
    push    eax
    push    1
    push    ecx
    mov     ecx, esi
    call    sub_4732E0

    loc_4721EF:                             ; CODE XREF: sub_4720D0+93j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    sub_4720D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472200 proc near                    ; CODE XREF: .text:00404676p
                                            ; .text:00404A4Ep ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    sub     esp, 18h
    mov     eax, [esp+18h+arg_4]
    push    ebx
    mov     ecx, eax
    push    ebp
    xor     ebx, ebx
    push    esi
    mov     edx, [ecx]
    push    edi
    mov     [esp+28h+var_18], edx
    mov     edx, [ecx+4]
    mov     [esp+28h+var_14], edx
    mov     edx, [eax]
    mov     ecx, [ecx+8]
    mov     [esp+28h+var_C], edx
    mov     edx, [eax+8]
    mov     [esp+28h+var_10], ecx
    mov     ecx, [eax+4]
    mov     eax, TAdynmemStructPtr
    mov     [esp+28h+var_8], ecx
    mov     [esp+28h+var_4], edx
    mov     ebp, [eax+38D77h]
    mov     al, byte_51E608
    cmp     al, bl
    jz      short loc_47224F
    xor     eax, eax
    jmp     short loc_47226E
    ; ---------------------------------------------------------------------------

    loc_47224F:                             ; CODE XREF: sub_472200+49j
    push    4Ch
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_47226C
    mov     ecx, 13h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_47226C:                             ; CODE XREF: sub_472200+5Fj
    mov     eax, edx

    loc_47226E:                             ; CODE XREF: sub_472200+4Dj
    cmp     eax, ebx
    jz      short loc_47228F
    mov     cl, [esp+28h+arg_8]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD5B8
    mov     esi, eax
    jmp     short loc_472291
    ; ---------------------------------------------------------------------------

    loc_47228F:                             ; CODE XREF: sub_472200+70j
    xor     esi, esi

    loc_472291:                             ; CODE XREF: sub_472200+8Dj
    cmp     esi, ebx
    jz      loc_47231F
    mov     ecx, [esp+28h+arg_0]
    mov     edx, [esi]
    lea     eax, [esp+28h+var_18]
    push    1
    push    eax
    push    ecx
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   edx, word ptr [esp+28h+arg_8]
    shl     edx, 4
    mov     [esp+28h+arg_4], esi
    mov     ecx, [edx+ebp+4]
    lea     esi, [edx+ebp]
    cmp     ecx, ebx
    jnz     short loc_4722C7
    xor     eax, eax
    jmp     short loc_4722CF
    ; ---------------------------------------------------------------------------

    loc_4722C7:                             ; CODE XREF: sub_472200+C1j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_4722CF:                             ; CODE XREF: sub_472200+C5j
    cmp     eax, 190h
    jbe     short loc_47230D
    mov     eax, [esi+4]
    mov     ecx, [eax]
    cmp     ecx, ebx
    jz      short loc_4722E5
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_4722E5:                             ; CODE XREF: sub_472200+DDj
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_472300
    sub     edx, eax

    loc_4722F4:                             ; CODE XREF: sub_472200+FEj
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4722F4

    loc_472300:                             ; CODE XREF: sub_472200+F0j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     dword ptr [esp+28h+arg_8], eax
    mov     [esi+8], eax

    loc_47230D:                             ; CODE XREF: sub_472200+D4j
    mov     ecx, [esi+8]
    lea     eax, [esp+28h+arg_4]
    push    eax
    push    1
    push    ecx
    mov     ecx, esi
    call    sub_4732E0

    loc_47231F:                             ; CODE XREF: sub_472200+93j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    sub_472200 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472330 proc near                    ; CODE XREF: sub_480EB0+160p
                                            ; sub_480EB0+17Fp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= byte ptr  14h

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    xor     ebx, ebx
    mov     ebp, [eax+38D77h]
    mov     al, byte_51E608
    push    esi
    cmp     al, bl
    push    edi
    jz      short loc_47234E
    xor     eax, eax
    jmp     short loc_47236D
    ; ---------------------------------------------------------------------------

    loc_47234E:                             ; CODE XREF: sub_472330+18j
    push    44h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_47236B
    mov     ecx, 11h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_47236B:                             ; CODE XREF: sub_472330+2Ej
    mov     eax, edx

    loc_47236D:                             ; CODE XREF: sub_472330+1Cj
    cmp     eax, ebx
    jz      short loc_47238E
    mov     cl, [esp+10h+arg_10]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD5D8
    mov     esi, eax
    jmp     short loc_472390
    ; ---------------------------------------------------------------------------

    loc_47238E:                             ; CODE XREF: sub_472330+3Fj
    xor     esi, esi

    loc_472390:                             ; CODE XREF: sub_472330+5Cj
    cmp     esi, ebx
    jz      loc_472426
    mov     eax, [esp+10h+arg_C]
    mov     ecx, [esp+10h+arg_8]
    mov     edx, [esi]
    push    eax
    mov     eax, [esp+14h+arg_4]
    push    ecx
    mov     ecx, [esp+18h+arg_0]
    push    eax
    push    ecx
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   edx, word ptr [esp+10h+arg_10]
    shl     edx, 4
    mov     [esp+10h+arg_C], esi
    mov     ecx, [edx+ebp+4]
    lea     esi, [edx+ebp]
    cmp     ecx, ebx
    jnz     short loc_4723CE
    xor     eax, eax
    jmp     short loc_4723D6
    ; ---------------------------------------------------------------------------

    loc_4723CE:                             ; CODE XREF: sub_472330+98j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_4723D6:                             ; CODE XREF: sub_472330+9Cj
    cmp     eax, 190h
    jbe     short loc_472414
    mov     eax, [esi+4]
    mov     ecx, [eax]
    cmp     ecx, ebx
    jz      short loc_4723EC
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_4723EC:                             ; CODE XREF: sub_472330+B4j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_472407
    sub     edx, eax

    loc_4723FB:                             ; CODE XREF: sub_472330+D5j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4723FB

    loc_472407:                             ; CODE XREF: sub_472330+C7j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     dword ptr [esp+10h+arg_10], eax
    mov     [esi+8], eax

    loc_472414:                             ; CODE XREF: sub_472330+ABj
    mov     ecx, [esi+8]
    lea     eax, [esp+10h+arg_C]
    push    eax
    push    1
    push    ecx
    mov     ecx, esi
    call    sub_4732E0

    loc_472426:                             ; CODE XREF: sub_472330+62j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    sub_472330 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472430 proc near                    ; CODE XREF: sub_480EB0+19Cp
                                            ; sub_480EB0+1B9p ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= word ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= byte ptr  10h

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    xor     ebx, ebx
    mov     ebp, [eax+38D77h]
    mov     al, byte_51E608
    push    esi
    cmp     al, bl
    push    edi
    jz      short loc_47244E
    xor     eax, eax
    jmp     short loc_47246D
    ; ---------------------------------------------------------------------------

    loc_47244E:                             ; CODE XREF: sub_472430+18j
    push    48h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_47246B
    mov     ecx, 12h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_47246B:                             ; CODE XREF: sub_472430+2Ej
    mov     eax, edx

    loc_47246D:                             ; CODE XREF: sub_472430+1Cj
    cmp     eax, ebx
    jz      short loc_47248E
    mov     cl, [esp+10h+arg_C]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD5F8
    mov     esi, eax
    jmp     short loc_472490
    ; ---------------------------------------------------------------------------

    loc_47248E:                             ; CODE XREF: sub_472430+3Fj
    xor     esi, esi

    loc_472490:                             ; CODE XREF: sub_472430+5Cj
    cmp     esi, ebx
    jz      loc_472525
    mov     eax, [esp+10h+arg_8]
    mov     ecx, [esp+10h+arg_4]
    mov     edx, [esi]
    push    1
    push    1
    push    eax
    mov     eax, [esp+1Ch+arg_0]
    push    ecx
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+10h+arg_C]
    shl     ecx, 4
    mov     [esp+10h+arg_8], esi
    lea     esi, [ecx+ebp]
    mov     ecx, [ecx+ebp+4]
    cmp     ecx, ebx
    jnz     short loc_4724CD
    xor     eax, eax
    jmp     short loc_4724D5
    ; ---------------------------------------------------------------------------

    loc_4724CD:                             ; CODE XREF: sub_472430+97j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_4724D5:                             ; CODE XREF: sub_472430+9Bj
    cmp     eax, 190h
    jbe     short loc_472513
    mov     edx, [esi+4]
    mov     ecx, [edx]
    cmp     ecx, ebx
    jz      short loc_4724EB
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4724EB:                             ; CODE XREF: sub_472430+B3j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_472506
    sub     edx, eax

    loc_4724FA:                             ; CODE XREF: sub_472430+D4j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4724FA

    loc_472506:                             ; CODE XREF: sub_472430+C6j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     dword ptr [esp+10h+arg_C], eax
    mov     [esi+8], eax

    loc_472513:                             ; CODE XREF: sub_472430+AAj
    mov     edx, [esi+8]
    lea     ecx, [esp+10h+arg_8]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_472525:                             ; CODE XREF: sub_472430+62j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_472430 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472530 proc near                    ; CODE XREF: sub_480EB0+252p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= word ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= byte ptr  10h

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    xor     ebx, ebx
    mov     ebp, [eax+38D77h]
    mov     al, byte_51E608
    push    esi
    cmp     al, bl
    push    edi
    jz      short loc_47254E
    xor     eax, eax
    jmp     short loc_47256D
    ; ---------------------------------------------------------------------------

    loc_47254E:                             ; CODE XREF: sub_472530+18j
    push    48h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    cmp     edx, ebx
    jz      short loc_47256B
    mov     ecx, 12h
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_47256B:                             ; CODE XREF: sub_472530+2Ej
    mov     eax, edx

    loc_47256D:                             ; CODE XREF: sub_472530+1Cj
    cmp     eax, ebx
    jz      short loc_47258E
    mov     cl, [esp+10h+arg_C]
    mov     [eax+4], ebx
    mov     [eax+0Ch], cl
    mov     [eax+10h], ebx
    mov     [eax+14h], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax], offset off_4FD5F8
    mov     esi, eax
    jmp     short loc_472590
    ; ---------------------------------------------------------------------------

    loc_47258E:                             ; CODE XREF: sub_472530+3Fj
    xor     esi, esi

    loc_472590:                             ; CODE XREF: sub_472530+5Cj
    cmp     esi, ebx
    jz      loc_472624
    mov     eax, [esp+10h+arg_8]
    mov     ecx, [esp+10h+arg_4]
    mov     edx, [esi]
    push    ebx
    push    1
    push    eax
    mov     eax, [esp+1Ch+arg_0]
    push    ecx
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+10h+arg_C]
    shl     ecx, 4
    mov     [esp+10h+arg_8], esi
    lea     esi, [ecx+ebp]
    mov     ecx, [ecx+ebp+4]
    cmp     ecx, ebx
    jnz     short loc_4725CC
    xor     eax, eax
    jmp     short loc_4725D4
    ; ---------------------------------------------------------------------------

    loc_4725CC:                             ; CODE XREF: sub_472530+96j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_4725D4:                             ; CODE XREF: sub_472530+9Aj
    cmp     eax, 190h
    jbe     short loc_472612
    mov     edx, [esi+4]
    mov     ecx, [edx]
    cmp     ecx, ebx
    jz      short loc_4725EA
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4725EA:                             ; CODE XREF: sub_472530+B2j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_472605
    sub     edx, eax

    loc_4725F9:                             ; CODE XREF: sub_472530+D3j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4725F9

    loc_472605:                             ; CODE XREF: sub_472530+C5j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     dword ptr [esp+10h+arg_C], eax
    mov     [esi+8], eax

    loc_472612:                             ; CODE XREF: sub_472530+A9j
    mov     edx, [esi+8]
    lea     ecx, [esp+10h+arg_8]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_472624:                             ; CODE XREF: sub_472530+62j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_472530 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472630 proc near                    ; CODE XREF: sub_420A30+B1p
                                            ; sub_486360+EBp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= word ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     ebx, [eax+38D77h]
    mov     al, byte_51E608
    test    al, al
    jz      short loc_47264B
    xor     ecx, ecx
    jmp     short loc_47266A
    ; ---------------------------------------------------------------------------

    loc_47264B:                             ; CODE XREF: sub_472630+15j
    push    38h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    test    edx, edx
    jz      short loc_472668
    mov     ecx, 0Eh
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_472668:                             ; CODE XREF: sub_472630+2Bj
    mov     ecx, edx

    loc_47266A:                             ; CODE XREF: sub_472630+19j
    test    ecx, ecx
    jz      short loc_472677
    call    sub_474CD0
    mov     esi, eax
    jmp     short loc_472679
    ; ---------------------------------------------------------------------------

    loc_472677:                             ; CODE XREF: sub_472630+3Cj
    xor     esi, esi

    loc_472679:                             ; CODE XREF: sub_472630+45j
    test    esi, esi
    jz      loc_472710
    mov     eax, [esp+0Ch+arg_8]
    mov     ecx, [esp+0Ch+arg_4]
    mov     edx, [esi]
    push    0
    push    eax
    mov     eax, [esp+14h+arg_0]
    push    0
    push    ecx
    push    0
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+1Ch]
    shl     ecx, 4
    mov     [esp+0Ch+arg_8], esi
    lea     esi, [ecx+ebx]
    mov     ecx, [ecx+ebx+4]
    test    ecx, ecx
    jnz     short loc_4726B8
    xor     eax, eax
    jmp     short loc_4726C0
    ; ---------------------------------------------------------------------------

    loc_4726B8:                             ; CODE XREF: sub_472630+82j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_4726C0:                             ; CODE XREF: sub_472630+86j
    cmp     eax, 190h
    jbe     short loc_4726FE
    mov     edx, [esi+4]
    mov     ecx, [edx]
    test    ecx, ecx
    jz      short loc_4726D6
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4726D6:                             ; CODE XREF: sub_472630+9Ej
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4726F1
    sub     edx, eax

    loc_4726E5:                             ; CODE XREF: sub_472630+BFj
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4726E5

    loc_4726F1:                             ; CODE XREF: sub_472630+B1j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+1Ch], eax
    mov     [esi+8], eax

    loc_4726FE:                             ; CODE XREF: sub_472630+95j
    mov     edx, [esi+8]
    lea     ecx, [esp+0Ch+arg_8]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_472710:                             ; CODE XREF: sub_472630+4Bj
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    sub_472630 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     ebx, [eax+38D77h]
    mov     al, byte_51E608
    test    al, al
    jz      short loc_47273B
    xor     ecx, ecx
    jmp     short loc_47275A
    ; ---------------------------------------------------------------------------

    loc_47273B:                             ; CODE XREF: .text:00472735j
    push    38h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    test    edx, edx
    jz      short loc_472758
    mov     ecx, 0Eh
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_472758:                             ; CODE XREF: .text:0047274Bj
    mov     ecx, edx

    loc_47275A:                             ; CODE XREF: .text:00472739j
    test    ecx, ecx
    jz      short loc_472767
    call    sub_474CD0
    mov     esi, eax
    jmp     short loc_472769
    ; ---------------------------------------------------------------------------

    loc_472767:                             ; CODE XREF: .text:0047275Cj
    xor     esi, esi

    loc_472769:                             ; CODE XREF: .text:00472765j
    test    esi, esi
    jz      loc_472800
    mov     eax, [esp+18h]
    mov     ecx, [esp+14h]
    mov     edx, [esi]
    push    1
    push    eax
    mov     eax, [esp+18h]
    push    0
    push    ecx
    push    0
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+1Ch]
    shl     ecx, 4
    mov     [esp+18h], esi
    lea     esi, [ecx+ebx]
    mov     ecx, [ecx+ebx+4]
    test    ecx, ecx
    jnz     short loc_4727A8
    xor     eax, eax
    jmp     short loc_4727B0
    ; ---------------------------------------------------------------------------

    loc_4727A8:                             ; CODE XREF: .text:004727A2j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_4727B0:                             ; CODE XREF: .text:004727A6j
    cmp     eax, 190h
    jbe     short loc_4727EE
    mov     edx, [esi+4]
    mov     ecx, [edx]
    test    ecx, ecx
    jz      short loc_4727C6
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4727C6:                             ; CODE XREF: .text:004727BEj
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4727E1
    sub     edx, eax

    loc_4727D5:                             ; CODE XREF: .text:004727DFj
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4727D5

    loc_4727E1:                             ; CODE XREF: .text:004727D1j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+1Ch], eax
    mov     [esi+8], eax

    loc_4727EE:                             ; CODE XREF: .text:004727B5j
    mov     edx, [esi+8]
    lea     ecx, [esp+18h]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_472800:                             ; CODE XREF: .text:0047276Bj
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472810 proc near                    ; CODE XREF: sub_421550+33p
                                            ; sub_424050+37Fp ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= word ptr -10h
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     ebx, [eax+38D77h]
    mov     al, byte_51E608
    test    al, al
    jz      short loc_47282B
    xor     ecx, ecx
    jmp     short loc_47284A
    ; ---------------------------------------------------------------------------

    loc_47282B:                             ; CODE XREF: sub_472810+15j
    push    38h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    test    edx, edx
    jz      short loc_472848
    mov     ecx, 0Eh
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_472848:                             ; CODE XREF: sub_472810+2Bj
    mov     ecx, edx

    loc_47284A:                             ; CODE XREF: sub_472810+19j
    test    ecx, ecx
    jz      short loc_472857
    call    sub_474CD0
    mov     esi, eax
    jmp     short loc_472859
    ; ---------------------------------------------------------------------------

    loc_472857:                             ; CODE XREF: sub_472810+3Cj
    xor     esi, esi

    loc_472859:                             ; CODE XREF: sub_472810+45j
    test    esi, esi
    jz      loc_4728EA
    mov     eax, [esp+0Ch+arg_0]
    mov     edx, [esi]
    push    0
    push    0
    push    0
    push    1
    push    0
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+14h]
    shl     ecx, 4
    mov     [esp+0Ch+arg_0], esi
    lea     esi, [ecx+ebx]
    mov     ecx, [ecx+ebx+4]
    test    ecx, ecx
    jnz     short loc_472892
    xor     eax, eax
    jmp     short loc_47289A
    ; ---------------------------------------------------------------------------

    loc_472892:                             ; CODE XREF: sub_472810+7Cj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_47289A:                             ; CODE XREF: sub_472810+80j
    cmp     eax, 190h
    jbe     short loc_4728D8
    mov     edx, [esi+4]
    mov     ecx, [edx]
    test    ecx, ecx
    jz      short loc_4728B0
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4728B0:                             ; CODE XREF: sub_472810+98j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4728CB
    sub     edx, eax

    loc_4728BF:                             ; CODE XREF: sub_472810+B9j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4728BF

    loc_4728CB:                             ; CODE XREF: sub_472810+ABj
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+14h], eax
    mov     [esi+8], eax

    loc_4728D8:                             ; CODE XREF: sub_472810+8Fj
    mov     edx, [esi+8]
    lea     ecx, [esp+0Ch+arg_0]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_4728EA:                             ; CODE XREF: sub_472810+4Bj
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_472810 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4728F0 proc near                    ; CODE XREF: sub_480EB0+268p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= word ptr -10h
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     ebx, [eax+38D77h]
    mov     al, byte_51E608
    test    al, al
    jz      short loc_47290B
    xor     ecx, ecx
    jmp     short loc_47292A
    ; ---------------------------------------------------------------------------

    loc_47290B:                             ; CODE XREF: sub_4728F0+15j
    push    38h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    test    edx, edx
    jz      short loc_472928
    mov     ecx, 0Eh
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_472928:                             ; CODE XREF: sub_4728F0+2Bj
    mov     ecx, edx

    loc_47292A:                             ; CODE XREF: sub_4728F0+19j
    test    ecx, ecx
    jz      short loc_472937
    call    sub_474CD0
    mov     esi, eax
    jmp     short loc_472939
    ; ---------------------------------------------------------------------------

    loc_472937:                             ; CODE XREF: sub_4728F0+3Cj
    xor     esi, esi

    loc_472939:                             ; CODE XREF: sub_4728F0+45j
    test    esi, esi
    jz      loc_4729CA
    mov     eax, [esp+0Ch+arg_0]
    mov     edx, [esi]
    push    1
    push    0
    push    0
    push    1
    push    0
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+14h]
    shl     ecx, 4
    mov     [esp+0Ch+arg_0], esi
    lea     esi, [ecx+ebx]
    mov     ecx, [ecx+ebx+4]
    test    ecx, ecx
    jnz     short loc_472972
    xor     eax, eax
    jmp     short loc_47297A
    ; ---------------------------------------------------------------------------

    loc_472972:                             ; CODE XREF: sub_4728F0+7Cj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_47297A:                             ; CODE XREF: sub_4728F0+80j
    cmp     eax, 190h
    jbe     short loc_4729B8
    mov     edx, [esi+4]
    mov     ecx, [edx]
    test    ecx, ecx
    jz      short loc_472990
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_472990:                             ; CODE XREF: sub_4728F0+98j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4729AB
    sub     edx, eax

    loc_47299F:                             ; CODE XREF: sub_4728F0+B9j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_47299F

    loc_4729AB:                             ; CODE XREF: sub_4728F0+ABj
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+14h], eax
    mov     [esi+8], eax

    loc_4729B8:                             ; CODE XREF: sub_4728F0+8Fj
    mov     edx, [esi+8]
    lea     ecx, [esp+0Ch+arg_0]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_4729CA:                             ; CODE XREF: sub_4728F0+4Bj
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_4728F0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4729D0 proc near                    ; CODE XREF: sub_49C9C0+247p
                                            ; sub_49CC20+1A3p ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= word ptr -10h
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     ebx, [eax+38D77h]
    mov     al, byte_51E608
    test    al, al
    jz      short loc_4729EB
    xor     ecx, ecx
    jmp     short loc_472A0A
    ; ---------------------------------------------------------------------------

    loc_4729EB:                             ; CODE XREF: sub_4729D0+15j
    push    38h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    test    edx, edx
    jz      short loc_472A08
    mov     ecx, 0Eh
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_472A08:                             ; CODE XREF: sub_4729D0+2Bj
    mov     ecx, edx

    loc_472A0A:                             ; CODE XREF: sub_4729D0+19j
    test    ecx, ecx
    jz      short loc_472A17
    call    sub_474CD0
    mov     esi, eax
    jmp     short loc_472A19
    ; ---------------------------------------------------------------------------

    loc_472A17:                             ; CODE XREF: sub_4729D0+3Cj
    xor     esi, esi

    loc_472A19:                             ; CODE XREF: sub_4729D0+45j
    test    esi, esi
    jz      loc_472AAA
    mov     eax, [esp+0Ch+arg_0]
    mov     edx, [esi]
    push    0
    push    0
    push    1Eh
    push    1
    push    3
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+14h]
    shl     ecx, 4
    mov     [esp+0Ch+arg_0], esi
    lea     esi, [ecx+ebx]
    mov     ecx, [ecx+ebx+4]
    test    ecx, ecx
    jnz     short loc_472A52
    xor     eax, eax
    jmp     short loc_472A5A
    ; ---------------------------------------------------------------------------

    loc_472A52:                             ; CODE XREF: sub_4729D0+7Cj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_472A5A:                             ; CODE XREF: sub_4729D0+80j
    cmp     eax, 190h
    jbe     short loc_472A98
    mov     edx, [esi+4]
    mov     ecx, [edx]
    test    ecx, ecx
    jz      short loc_472A70
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_472A70:                             ; CODE XREF: sub_4729D0+98j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_472A8B
    sub     edx, eax

    loc_472A7F:                             ; CODE XREF: sub_4729D0+B9j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_472A7F

    loc_472A8B:                             ; CODE XREF: sub_4729D0+ABj
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+14h], eax
    mov     [esi+8], eax

    loc_472A98:                             ; CODE XREF: sub_4729D0+8Fj
    mov     edx, [esi+8]
    lea     ecx, [esp+0Ch+arg_0]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_472AAA:                             ; CODE XREF: sub_4729D0+4Bj
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_4729D0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472AB0 proc near                    ; CODE XREF: sub_421550+5Ap

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= byte ptr  8

    sub     esp, 0Ch
    mov     eax, [esp+0Ch+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax]
    push    edi
    mov     [esp+1Ch+var_C], ecx
    mov     edx, [eax+4]
    mov     [esp+1Ch+var_8], edx
    mov     eax, [eax+8]
    mov     [esp+1Ch+var_4], eax
    call    _rand
    xor     edi, edi
    cdq
    push    edi
    push    3
    push    edx
    push    eax
    call    __allmul
    push    edi
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    dec     eax
    add     word ptr [esp+1Ch+var_C+2], ax
    call    _rand
    cdq
    push    edi
    push    3
    push    edx
    push    eax
    call    __allmul
    push    edi
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    dec     eax
    add     word ptr [esp+1Ch+var_8+2], ax
    call    _rand
    cdq
    push    edi
    push    3
    push    edx
    push    eax
    call    __allmul
    push    edi
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    dec     eax
    add     word ptr [esp+1Ch+var_4+2], ax
    call    _rand
    cdq
    push    edi
    push    3
    push    edx
    push    eax
    call    __allmul
    push    edi
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, TAdynmemStructPtr
    mov     ebp, eax
    mov     al, byte_51E608
    inc     ebp
    mov     ebx, [ecx+38D77h]
    test    al, al
    jz      short loc_472B73
    xor     esi, esi
    jmp     short loc_472B92
    ; ---------------------------------------------------------------------------

    loc_472B73:                             ; CODE XREF: sub_472AB0+BDj
    push    44h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     esi, eax
    cmp     esi, edi
    jz      short loc_472BB1
    mov     ecx, 11h
    xor     eax, eax
    mov     edi, esi
    rep stosd
    xor     edi, edi

    loc_472B92:                             ; CODE XREF: sub_472AB0+C1j
    cmp     esi, edi
    jz      short loc_472BB1
    mov     dl, [esp+1Ch+arg_4]
    mov     [esi+4], edi
    mov     [esi+0Ch], dl
    mov     [esi+10h], edi
    mov     [esi+14h], edi
    mov     [esi+18h], edi
    mov     dword ptr [esi], offset off_4FD5D8
    jmp     short loc_472BB3
    ; ---------------------------------------------------------------------------

    loc_472BB1:                             ; CODE XREF: sub_472AB0+D3j
                                            ; sub_472AB0+E4j
    xor     esi, esi

    loc_472BB3:                             ; CODE XREF: sub_472AB0+FFj
    cmp     esi, edi
    jz      loc_472C43
    mov     eax, [esi]
    push    ebp
    lea     ecx, [esp+20h+var_C]
    push    1
    lea     edx, [esp+24h+var_C]
    push    ecx
    push    edx
    mov     ecx, esi
    call    dword ptr [eax+18h]
    movsx   eax, word ptr [esp+1Ch+arg_4]
    shl     eax, 4
    mov     [esp+1Ch+arg_0], esi
    lea     esi, [eax+ebx]
    mov     eax, [eax+ebx+4]
    cmp     eax, edi
    jnz     short loc_472BEA
    xor     ecx, ecx
    jmp     short loc_472BF2
    ; ---------------------------------------------------------------------------

    loc_472BEA:                             ; CODE XREF: sub_472AB0+134j
    mov     ecx, [esi+8]
    sub     ecx, eax
    sar     ecx, 2

    loc_472BF2:                             ; CODE XREF: sub_472AB0+138j
    cmp     ecx, 190h
    jbe     short loc_472C31
    mov     ecx, [esi+4]
    mov     ecx, [ecx]
    cmp     ecx, edi
    jz      short loc_472C09
    mov     edx, [ecx]
    push    1
    call    dword ptr [edx]

    loc_472C09:                             ; CODE XREF: sub_472AB0+151j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_472C24
    sub     edx, eax

    loc_472C18:                             ; CODE XREF: sub_472AB0+172j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_472C18

    loc_472C24:                             ; CODE XREF: sub_472AB0+164j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     dword ptr [esp+1Ch+arg_4], eax
    mov     [esi+8], eax

    loc_472C31:                             ; CODE XREF: sub_472AB0+148j
    mov     ecx, [esi+8]
    lea     eax, [esp+1Ch+arg_0]
    push    eax
    push    1
    push    ecx
    mov     ecx, esi
    call    sub_4732E0

    loc_472C43:                             ; CODE XREF: sub_472AB0+105j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_472AB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472C50 proc near                    ; CODE XREF: sub_423C50+393p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= word ptr -8
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     ebx, [eax+38D77h]
    mov     al, byte_51E608
    test    al, al
    jz      short loc_472C6B
    xor     ecx, ecx
    jmp     short loc_472C8A
    ; ---------------------------------------------------------------------------

    loc_472C6B:                             ; CODE XREF: sub_472C50+15j
    push    34h
    mov     ecx, offset dword_51E610
    call    sub_470EB0
    mov     edx, eax
    test    edx, edx
    jz      short loc_472C88
    mov     ecx, 0Dh
    xor     eax, eax
    mov     edi, edx
    rep stosd

    loc_472C88:                             ; CODE XREF: sub_472C50+2Bj
    mov     ecx, edx

    loc_472C8A:                             ; CODE XREF: sub_472C50+19j
    test    ecx, ecx
    jz      short loc_472C97
    call    sub_4750B0
    mov     esi, eax
    jmp     short loc_472C99
    ; ---------------------------------------------------------------------------

    loc_472C97:                             ; CODE XREF: sub_472C50+3Cj
    xor     esi, esi

    loc_472C99:                             ; CODE XREF: sub_472C50+45j
    test    esi, esi
    jz      loc_472D29
    mov     eax, [esp+0Ch+arg_0]
    mov     edx, [esi]
    push    96h
    push    0
    push    5
    push    eax
    mov     ecx, esi
    call    dword ptr [edx+18h]
    movsx   ecx, word ptr [esp+14h]
    shl     ecx, 4
    mov     [esp+0Ch+arg_0], esi
    lea     esi, [ecx+ebx]
    mov     ecx, [ecx+ebx+4]
    test    ecx, ecx
    jnz     short loc_472CD1
    xor     eax, eax
    jmp     short loc_472CD9
    ; ---------------------------------------------------------------------------

    loc_472CD1:                             ; CODE XREF: sub_472C50+7Bj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 2

    loc_472CD9:                             ; CODE XREF: sub_472C50+7Fj
    cmp     eax, 190h
    jbe     short loc_472D17
    mov     edx, [esi+4]
    mov     ecx, [edx]
    test    ecx, ecx
    jz      short loc_472CEF
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_472CEF:                             ; CODE XREF: sub_472C50+97j
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_472D0A
    sub     edx, eax

    loc_472CFE:                             ; CODE XREF: sub_472C50+B8j
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_472CFE

    loc_472D0A:                             ; CODE XREF: sub_472C50+AAj
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esp+14h], eax
    mov     [esi+8], eax

    loc_472D17:                             ; CODE XREF: sub_472C50+8Ej
    mov     edx, [esi+8]
    lea     ecx, [esp+0Ch+arg_0]
    push    ecx
    push    1
    push    edx
    mov     ecx, esi
    call    sub_4732E0

    loc_472D29:                             ; CODE XREF: sub_472C50+4Bj
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_472C50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472D30 proc near                    ; CODE XREF: .text:00471288p
                                            ; .text:00471909p ...
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_472D3A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_472D3A:                             ; CODE XREF: sub_472D30+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_472D30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472D50 proc near                    ; DATA XREF: .rdata:004FD58Co

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     edi, [ebp+10h]
    mov     eax, [ebp+14h]
    cmp     edi, eax
    mov     [esp+1Ch+var_C], edi
    jz      short loc_472DD7
    lea     esi, [edi+34h]
    mov     [esp+1Ch+var_8], esi

    loc_472D6E:                             ; CODE XREF: sub_472D50+85j
    mov     ecx, edi
    call    sub_473560
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    push    ecx
    mov     ecx, edi
    call    sub_4736C0
    test    eax, eax
    jz      short loc_472DC4
    mov     ebx, [ebp+14h]
    mov     eax, esi
    cmp     esi, ebx
    jz      short loc_472DB5
    lea     edx, [esi-34h]

    loc_472D98:                             ; CODE XREF: sub_472D50+5Bj
    mov     esi, eax
    mov     edi, edx
    add     eax, 34h
    mov     ecx, 0Dh
    add     edx, 34h
    cmp     eax, ebx
    rep movsd
    jnz     short loc_472D98
    mov     edi, [esp+1Ch+var_C]
    mov     esi, [esp+1Ch+var_8]

    loc_472DB5:                             ; CODE XREF: sub_472D50+43j
    mov     eax, [ebp+14h]
    add     eax, 0FFFFFFCCh
    mov     [esp+1Ch+var_4], eax
    mov     [ebp+14h], eax
    jmp     short loc_472DD2
    ; ---------------------------------------------------------------------------

    loc_472DC4:                             ; CODE XREF: sub_472D50+3Aj
    add     edi, 34h
    add     esi, 34h
    mov     [esp+1Ch+var_C], edi
    mov     [esp+1Ch+var_8], esi

    loc_472DD2:                             ; CODE XREF: sub_472D50+72j
    cmp     edi, [ebp+14h]
    jnz     short loc_472D6E

    loc_472DD7:                             ; CODE XREF: sub_472D50+15j
    mov     edx, [ebp+0]
    mov     ecx, ebp
    call    dword ptr [edx+14h]
    test    eax, eax
    jz      short loc_472DEB
    mov     eax, [ebp+0]
    mov     ecx, ebp
    call    dword ptr [eax+10h]

    loc_472DEB:                             ; CODE XREF: sub_472D50+91j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_472D50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472E00 proc near                    ; DATA XREF: .rdata:004FD59Co
    mov     eax, [ecx+8]
    mov     edx, [ecx+4]
    cmp     eax, edx
    jg      short unknown_libname_33
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+38A47h]
    ja      short unknown_libname_33

    unknown_libname_32:
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_33:                     ; CODE XREF: sub_472E00+8j
                                            ; sub_472E00+16j
    xor     eax, eax
    retn
    sub_472E00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472E30 proc near                    ; DATA XREF: .rdata:004FD590o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, ecx
    mov     esi, [edi+10h]
    mov     eax, [edi+14h]
    cmp     esi, eax
    jz      short loc_472E6B
    push    ebx
    mov     ebx, [esp+4+arg_0]

    loc_472E43:                             ; CODE XREF: sub_472E30+38j
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+14323h]
    mov     dx, [eax+1431Fh]
    push    ecx
    push    edx
    push    ebx
    mov     ecx, esi
    call    sub_473590
    mov     eax, [edi+14h]
    add     esi, 34h
    cmp     esi, eax
    jnz     short loc_472E43
    pop     ebx

    loc_472E6B:                             ; CODE XREF: sub_472E30+Cj
    pop     edi
    pop     esi
    retn    4
    sub_472E30 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472E70 proc near                    ; DATA XREF: .rdata:004FD594o
    mov     eax, [ecx+10h]
    test    eax, eax
    jnz     short loc_472E84
    xor     edx, edx
    test    edx, edx
    setz    al
    and     eax, 0FFh
    retn
    ; ---------------------------------------------------------------------------

    loc_472E84:                             ; CODE XREF: sub_472E70+5j
    mov     ecx, [ecx+14h]
    sub     ecx, eax
    mov     eax, 4EC4EC4Fh
    imul    ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    xor     eax, eax
    test    edx, edx
    setz    al
    and     eax, 0FFh
    retn
    sub_472E70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472EB0 proc near                    ; DATA XREF: .rdata:004FD5BCo

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     edi, [ebp+10h]
    mov     eax, [ebp+14h]
    cmp     edi, eax
    mov     [esp+1Ch+var_C], edi
    jz      short loc_472F37
    lea     esi, [edi+30h]
    mov     [esp+1Ch+var_8], esi

    loc_472ECE:                             ; CODE XREF: sub_472EB0+85j
    mov     ecx, edi
    call    sub_4739B0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    push    ecx
    mov     ecx, edi
    call    sub_473B30
    test    eax, eax
    jz      short loc_472F24
    mov     ebx, [ebp+14h]
    mov     eax, esi
    cmp     esi, ebx
    jz      short loc_472F15
    lea     edx, [esi-30h]

    loc_472EF8:                             ; CODE XREF: sub_472EB0+5Bj
    mov     esi, eax
    mov     edi, edx
    add     eax, 30h
    mov     ecx, 0Ch
    add     edx, 30h
    cmp     eax, ebx
    rep movsd
    jnz     short loc_472EF8
    mov     edi, [esp+1Ch+var_C]
    mov     esi, [esp+1Ch+var_8]

    loc_472F15:                             ; CODE XREF: sub_472EB0+43j
    mov     eax, [ebp+14h]
    add     eax, 0FFFFFFD0h
    mov     [esp+1Ch+var_4], eax
    mov     [ebp+14h], eax
    jmp     short loc_472F32
    ; ---------------------------------------------------------------------------

    loc_472F24:                             ; CODE XREF: sub_472EB0+3Aj
    add     edi, 30h
    add     esi, 30h
    mov     [esp+1Ch+var_C], edi
    mov     [esp+1Ch+var_8], esi

    loc_472F32:                             ; CODE XREF: sub_472EB0+72j
    cmp     edi, [ebp+14h]
    jnz     short loc_472ECE

    loc_472F37:                             ; CODE XREF: sub_472EB0+15j
    mov     edx, [ebp+0]
    mov     ecx, ebp
    call    dword ptr [edx+14h]
    test    eax, eax
    jz      short loc_472F4B
    mov     eax, [ebp+0]
    mov     ecx, ebp
    call    dword ptr [eax+10h]

    loc_472F4B:                             ; CODE XREF: sub_472EB0+91j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_472EB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472F60 proc near                    ; DATA XREF: .rdata:004FD5CCo
    mov     eax, [ecx+8]
    mov     edx, [ecx+4]
    cmp     eax, edx
    jg      short unknown_libname_35
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+38A47h]
    ja      short unknown_libname_35

    unknown_libname_34:
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_35:                     ; CODE XREF: sub_472F60+8j
                                            ; sub_472F60+16j
    xor     eax, eax
    retn
    sub_472F60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_472F90(int)
    sub_472F90 proc near                    ; DATA XREF: .rdata:004FD5C0o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, ecx
    mov     esi, [edi+10h]
    mov     eax, [edi+14h]
    cmp     esi, eax
    jz      short loc_472FCB
    push    ebx
    mov     ebx, [esp+4+arg_0]

    loc_472FA3:                             ; CODE XREF: sub_472F90+38j
    mov     eax, TAdynmemStructPtr
    mov     cx, word ptr [eax+TAdynmemStruct.MapY]
    mov     dx, word ptr [eax+TAdynmemStruct.MapX]
    push    ecx                             ; int
    push    edx                             ; int
    push    ebx                             ; int
    mov     ecx, esi
    call    sub_473A00
    mov     eax, [edi+14h]
    add     esi, 30h
    cmp     esi, eax
    jnz     short loc_472FA3
    pop     ebx

    loc_472FCB:                             ; CODE XREF: sub_472F90+Cj
    pop     edi
    pop     esi
    retn    4
    sub_472F90 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_472FD0 proc near                    ; DATA XREF: .rdata:004FD5C4o
    mov     eax, [ecx+10h]
    test    eax, eax
    jnz     short loc_472FE4
    xor     edx, edx
    test    edx, edx
    setz    al
    and     eax, 0FFh
    retn
    ; ---------------------------------------------------------------------------

    loc_472FE4:                             ; CODE XREF: sub_472FD0+5j
    mov     ecx, [ecx+14h]
    sub     ecx, eax
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    xor     eax, eax
    test    edx, edx
    setz    al
    and     eax, 0FFh
    retn
    sub_472FD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473010 proc near                    ; DATA XREF: .rdata:004FD5DCo

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     edi, [ebp+10h]
    mov     eax, [ebp+14h]
    cmp     edi, eax
    mov     [esp+1Ch+var_C], edi
    jz      short loc_473097
    lea     esi, [edi+3Ch]
    mov     [esp+1Ch+var_8], esi

    loc_47302E:                             ; CODE XREF: sub_473010+85j
    mov     ecx, edi
    call    sub_474130
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    push    ecx
    mov     ecx, edi
    call    sub_4742A0
    test    eax, eax
    jz      short loc_473084
    mov     ebx, [ebp+14h]
    mov     eax, esi
    cmp     esi, ebx
    jz      short loc_473075
    lea     edx, [esi-3Ch]

    loc_473058:                             ; CODE XREF: sub_473010+5Bj
    mov     esi, eax
    mov     edi, edx
    add     eax, 3Ch
    mov     ecx, 0Fh
    add     edx, 3Ch
    cmp     eax, ebx
    rep movsd
    jnz     short loc_473058
    mov     edi, [esp+1Ch+var_C]
    mov     esi, [esp+1Ch+var_8]

    loc_473075:                             ; CODE XREF: sub_473010+43j
    mov     eax, [ebp+14h]
    add     eax, 0FFFFFFC4h
    mov     [esp+1Ch+var_4], eax
    mov     [ebp+14h], eax
    jmp     short loc_473092
    ; ---------------------------------------------------------------------------

    loc_473084:                             ; CODE XREF: sub_473010+3Aj
    add     edi, 3Ch
    add     esi, 3Ch
    mov     [esp+1Ch+var_C], edi
    mov     [esp+1Ch+var_8], esi

    loc_473092:                             ; CODE XREF: sub_473010+72j
    cmp     edi, [ebp+14h]
    jnz     short loc_47302E

    loc_473097:                             ; CODE XREF: sub_473010+15j
    mov     edx, [ebp+0]
    mov     ecx, ebp
    call    dword ptr [edx+14h]
    test    eax, eax
    jz      short loc_4730AB
    mov     eax, [ebp+0]
    mov     ecx, ebp
    call    dword ptr [eax+10h]

    loc_4730AB:                             ; CODE XREF: sub_473010+91j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_473010 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4730C0 proc near                    ; DATA XREF: .rdata:004FD5ECo
    mov     eax, [ecx+8]
    mov     edx, [ecx+4]
    cmp     eax, edx
    jg      short unknown_libname_37
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+38A47h]
    ja      short unknown_libname_37

    unknown_libname_36:
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_37:                     ; CODE XREF: sub_4730C0+8j
                                            ; sub_4730C0+16j
    xor     eax, eax
    retn
    sub_4730C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4730F0 proc near                    ; DATA XREF: .rdata:004FD5E0o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, ecx
    mov     esi, [edi+10h]
    mov     eax, [edi+14h]
    cmp     esi, eax
    jz      short loc_47312B
    push    ebx
    mov     ebx, [esp+4+arg_0]

    loc_473103:                             ; CODE XREF: sub_4730F0+38j
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+14323h]
    mov     dx, [eax+1431Fh]
    push    ecx
    push    edx
    push    ebx
    mov     ecx, esi
    call    sub_474170
    mov     eax, [edi+14h]
    add     esi, 3Ch
    cmp     esi, eax
    jnz     short loc_473103
    pop     ebx

    loc_47312B:                             ; CODE XREF: sub_4730F0+Cj
    pop     edi
    pop     esi
    retn    4
    sub_4730F0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473130 proc near                    ; DATA XREF: .rdata:004FD5E4o
    mov     eax, [ecx+10h]
    test    eax, eax
    jnz     short loc_473144
    xor     edx, edx
    test    edx, edx
    setz    al
    and     eax, 0FFh
    retn
    ; ---------------------------------------------------------------------------

    loc_473144:                             ; CODE XREF: sub_473130+5j
    mov     ecx, [ecx+14h]
    sub     ecx, eax
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    xor     eax, eax
    test    edx, edx
    setz    al
    and     eax, 0FFh
    retn
    sub_473130 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473170 proc near                    ; DATA XREF: .rdata:004FD5FCo

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     edi, [ebp+10h]
    mov     eax, [ebp+14h]
    cmp     edi, eax
    mov     [esp+1Ch+var_C], edi
    jz      short loc_4731F7
    lea     esi, [edi+44h]
    mov     [esp+1Ch+var_8], esi

    loc_47318E:                             ; CODE XREF: sub_473170+85j
    mov     ecx, edi
    call    sub_474580
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    push    ecx
    mov     ecx, edi
    call    sub_474720
    test    eax, eax
    jz      short loc_4731E4
    mov     ebx, [ebp+14h]
    mov     eax, esi
    cmp     esi, ebx
    jz      short loc_4731D5
    lea     edx, [esi-44h]

    loc_4731B8:                             ; CODE XREF: sub_473170+5Bj
    mov     esi, eax
    mov     edi, edx
    add     eax, 44h
    mov     ecx, 11h
    add     edx, 44h
    cmp     eax, ebx
    rep movsd
    jnz     short loc_4731B8
    mov     edi, [esp+1Ch+var_C]
    mov     esi, [esp+1Ch+var_8]

    loc_4731D5:                             ; CODE XREF: sub_473170+43j
    mov     eax, [ebp+14h]
    add     eax, 0FFFFFFBCh
    mov     [esp+1Ch+var_4], eax
    mov     [ebp+14h], eax
    jmp     short loc_4731F2
    ; ---------------------------------------------------------------------------

    loc_4731E4:                             ; CODE XREF: sub_473170+3Aj
    add     edi, 44h
    add     esi, 44h
    mov     [esp+1Ch+var_C], edi
    mov     [esp+1Ch+var_8], esi

    loc_4731F2:                             ; CODE XREF: sub_473170+72j
    cmp     edi, [ebp+14h]
    jnz     short loc_47318E

    loc_4731F7:                             ; CODE XREF: sub_473170+15j
    mov     edx, [ebp+0]
    mov     ecx, ebp
    call    dword ptr [edx+14h]
    test    eax, eax
    jz      short loc_47320B
    mov     eax, [ebp+0]
    mov     ecx, ebp
    call    dword ptr [eax+10h]

    loc_47320B:                             ; CODE XREF: sub_473170+91j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_473170 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473220 proc near                    ; DATA XREF: .rdata:004FD60Co
    mov     eax, [ecx+8]
    mov     edx, [ecx+4]
    cmp     eax, edx
    jg      short unknown_libname_39
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+38A47h]
    ja      short unknown_libname_39

    unknown_libname_38:
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_39:                     ; CODE XREF: sub_473220+8j
                                            ; sub_473220+16j
    xor     eax, eax
    retn
    sub_473220 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473250 proc near                    ; DATA XREF: .rdata:004FD600o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, ecx
    mov     esi, [edi+10h]
    mov     eax, [edi+14h]
    cmp     esi, eax
    jz      short loc_47328B
    push    ebx
    mov     ebx, [esp+4+arg_0]

    loc_473263:                             ; CODE XREF: sub_473250+38j
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+14323h]
    mov     dx, [eax+1431Fh]
    push    ecx
    push    edx
    push    ebx
    mov     ecx, esi
    call    sub_4745E0
    mov     eax, [edi+14h]
    add     esi, 44h
    cmp     esi, eax
    jnz     short loc_473263
    pop     ebx

    loc_47328B:                             ; CODE XREF: sub_473250+Cj
    pop     edi
    pop     esi
    retn    4
    sub_473250 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473290 proc near                    ; DATA XREF: .rdata:004FD604o
    mov     eax, [ecx+10h]
    test    eax, eax
    jnz     short loc_4732A4
    xor     edx, edx
    test    edx, edx
    setz    al
    and     eax, 0FFh
    retn
    ; ---------------------------------------------------------------------------

    loc_4732A4:                             ; CODE XREF: sub_473290+5j
    mov     ecx, [ecx+14h]
    sub     ecx, eax
    mov     eax, 78787879h
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    xor     eax, eax
    test    edx, edx
    setz    al
    and     eax, 0FFh
    retn
    sub_473290 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_50. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4732E0 proc near                    ; CODE XREF: .text:00471423p
                                            ; .text:00471553p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    push    ebp
    mov     ebx, [esp+10h+arg_4]
    mov     ebp, ecx
    push    esi
    push    edi
    mov     ecx, [ebp+8]
    mov     eax, [ebp+0Ch]
    sub     eax, ecx
    mov     [esp+18h+var_8], ebp
    sar     eax, 2
    cmp     eax, ebx
    jnb     loc_473419
    mov     edx, [ebp+4]
    test    edx, edx
    jnz     short loc_47330F
    xor     eax, eax
    jmp     short loc_473316
    ; ---------------------------------------------------------------------------

    loc_47330F:                             ; CODE XREF: sub_4732E0+29j
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2

    loc_473316:                             ; CODE XREF: sub_4732E0+2Dj
    cmp     ebx, eax
    jnb     short loc_47332B
    test    edx, edx
    jnz     short loc_473322
    xor     eax, eax
    jmp     short loc_47332D
    ; ---------------------------------------------------------------------------

    loc_473322:                             ; CODE XREF: sub_4732E0+3Cj
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2
    jmp     short loc_47332D
    ; ---------------------------------------------------------------------------

    loc_47332B:                             ; CODE XREF: sub_4732E0+38j
    mov     eax, ebx

    loc_47332D:                             ; CODE XREF: sub_4732E0+40j
                                            ; sub_4732E0+49j
    test    edx, edx
    jnz     short loc_473335
    xor     ecx, ecx
    jmp     short loc_47333A
    ; ---------------------------------------------------------------------------

    loc_473335:                             ; CODE XREF: sub_4732E0+4Fj
    sub     ecx, edx
    sar     ecx, 2

    loc_47333A:                             ; CODE XREF: sub_4732E0+53j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_473346
    xor     eax, eax

    loc_473346:                             ; CODE XREF: sub_4732E0+62j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+1Ch+arg_0]
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebp+4]
    add     esp, 4
    cmp     eax, ecx
    jz      short loc_473379

    loc_473367:                             ; CODE XREF: sub_4732E0+97j
    test    edx, edx
    jz      short loc_47336F
    mov     esi, [eax]
    mov     [edx], esi

    loc_47336F:                             ; CODE XREF: sub_4732E0+89j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_473367

    loc_473379:                             ; CODE XREF: sub_4732E0+85j
    test    ebx, ebx
    mov     eax, edx
    jbe     short loc_473397
    mov     edi, [esp+18h+arg_8]
    mov     esi, ebx

    loc_473385:                             ; CODE XREF: sub_4732E0+B5j
    test    eax, eax
    jz      short loc_473391
    mov     ebp, [edi]
    mov     [eax], ebp
    mov     ebp, [esp+18h+var_8]

    loc_473391:                             ; CODE XREF: sub_4732E0+A7j
    add     eax, 4
    dec     esi
    jnz     short loc_473385

    loc_473397:                             ; CODE XREF: sub_4732E0+9Dj
    mov     esi, [ebp+8]
    lea     edi, ds:0[ebx*4]
    cmp     ecx, esi
    lea     eax, [edx+edi]
    jz      short loc_4733C0
    sub     ecx, edx
    add     ecx, eax
    sub     ecx, edi

    loc_4733AE:                             ; CODE XREF: sub_4732E0+DEj
    test    eax, eax
    jz      short loc_4733B6
    mov     edx, [ecx]
    mov     [eax], edx

    loc_4733B6:                             ; CODE XREF: sub_4732E0+D0j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, esi
    jnz     short loc_4733AE

    loc_4733C0:                             ; CODE XREF: sub_4732E0+C6j
    mov     eax, [ebp+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     edx, [esp+1Ch+arg_4]
    mov     eax, [esp+1Ch+var_4]
    add     esp, 4
    lea     ecx, [edx+eax*4]
    mov     [ebp+0Ch], ecx
    mov     ecx, [ebp+4]
    test    ecx, ecx
    jnz     short loc_4733FC
    xor     eax, eax
    mov     [ebp+4], edx
    add     ebx, eax
    lea     eax, [edx+ebx*4]
    mov     [ebp+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4733FC:                             ; CODE XREF: sub_4732E0+103j
    mov     eax, [ebp+8]
    mov     [ebp+4], edx
    sub     eax, ecx
    sar     eax, 2
    add     ebx, eax
    lea     eax, [edx+ebx*4]
    mov     [ebp+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_473419:                             ; CODE XREF: sub_4732E0+1Ej
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, esi
    sar     edx, 2
    cmp     edx, ebx
    jnb     short loc_473493
    lea     edi, ds:0[ebx*4]
    cmp     esi, ecx
    lea     edx, [esi+edi]
    jz      short loc_473450
    mov     eax, edx
    sub     eax, edi

    loc_47343A:                             ; CODE XREF: sub_4732E0+16Ej
    test    edx, edx
    jz      short loc_473446
    mov     ebp, [eax]
    mov     [edx], ebp
    mov     ebp, [esp+18h+var_8]

    loc_473446:                             ; CODE XREF: sub_4732E0+15Cj
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_47343A

    loc_473450:                             ; CODE XREF: sub_4732E0+154j
    mov     eax, [ebp+8]
    mov     edx, [esp+18h+arg_8]
    mov     ecx, eax
    sub     ecx, esi
    sar     ecx, 2
    sub     ebx, ecx
    mov     ecx, ebx
    jz      short loc_473472

    loc_473464:                             ; CODE XREF: sub_4732E0+190j
    test    eax, eax
    jz      short loc_47346C
    mov     ebx, [edx]
    mov     [eax], ebx

    loc_47346C:                             ; CODE XREF: sub_4732E0+186j
    add     eax, 4
    dec     ecx
    jnz     short loc_473464

    loc_473472:                             ; CODE XREF: sub_4732E0+182j
    mov     ecx, [ebp+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_4734EC

    loc_47347B:                             ; CODE XREF: sub_4732E0+1A4j
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_47347B
    add     [ebp+8], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_473493:                             ; CODE XREF: sub_4732E0+146j
    test    ebx, ebx
    jbe     short loc_4734EF
    lea     edi, ds:0[ebx*4]
    mov     eax, ecx
    sub     eax, edi
    mov     edx, ecx
    cmp     eax, ecx
    jz      short loc_4734BA

    loc_4734A8:                             ; CODE XREF: sub_4732E0+1D8j
    test    edx, edx
    jz      short loc_4734B0
    mov     ebx, [eax]
    mov     [edx], ebx

    loc_4734B0:                             ; CODE XREF: sub_4732E0+1CAj
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_4734A8

    loc_4734BA:                             ; CODE XREF: sub_4732E0+1C6j
    mov     ecx, [ebp+8]
    mov     eax, ecx
    sub     eax, edi
    cmp     esi, eax
    jz      short loc_4734D4

    loc_4734C5:                             ; CODE XREF: sub_4732E0+1F2j
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, esi
    mov     [ecx], edx
    jnz     short loc_4734C5

    loc_4734D4:                             ; CODE XREF: sub_4732E0+1E3j
    lea     ecx, [esi+edi]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_4734EC
    mov     edx, [esp+18h+arg_8]

    loc_4734E1:                             ; CODE XREF: sub_4732E0+20Aj
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4734E1

    loc_4734EC:                             ; CODE XREF: sub_4732E0+199j
                                            ; sub_4732E0+1FBj
    add     [ebp+8], edi

    loc_4734EF:                             ; CODE XREF: sub_4732E0+1B5j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_4732E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473500 proc near                    ; CODE XREF: .text:0047123Bp
                                            ; .text:0047125Cp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    mov     edx, [esp+arg_4]
    cmp     ecx, edx
    jz      short loc_473527
    mov     eax, [esp+arg_8]
    push    esi

    loc_473511:                             ; CODE XREF: sub_473500+21j
    test    eax, eax
    jz      short loc_473519
    mov     esi, [ecx]
    mov     [eax], esi

    loc_473519:                             ; CODE XREF: sub_473500+13j
    add     ecx, 4
    add     eax, 4
    cmp     ecx, edx
    jnz     short loc_473511
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_473527:                             ; CODE XREF: sub_473500+Aj
    mov     eax, [esp+arg_8]
    retn    0Ch
    sub_473500 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473530 proc near                    ; CODE XREF: .text:0047124Cp
                                            ; .text:004712D1p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_4]
    test    ecx, ecx
    jbe     short locret_473550
    mov     edx, [esp+arg_8]
    mov     eax, [esp+arg_0]
    push    esi

    loc_473541:                             ; CODE XREF: sub_473530+1Dj
    test    eax, eax
    jz      short loc_473549
    mov     esi, [edx]
    mov     [eax], esi

    loc_473549:                             ; CODE XREF: sub_473530+13j
    add     eax, 4
    dec     ecx
    jnz     short loc_473541
    pop     esi

    locret_473550:                          ; CODE XREF: sub_473530+6j
    retn    0Ch
    sub_473530 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473560 proc near                    ; CODE XREF: sub_472D50+20p
    mov     eax, [ecx+1Ch]
    mov     edx, [ecx+4]
    add     edx, eax
    mov     eax, [ecx+8]
    mov     [ecx+4], edx
    mov     edx, [ecx+20h]
    add     eax, edx
    mov     edx, [ecx+0Ch]
    mov     [ecx+8], eax
    mov     eax, [ecx+24h]
    add     edx, eax
    mov     [ecx+0Ch], edx
    mov     eax, [ecx+2Ch]
    inc     eax
    cdq
    idiv    dword ptr [ecx+28h]
    mov     [ecx+2Ch], edx
    retn
    sub_473560 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473590 proc near                    ; CODE XREF: sub_472E30+2Bp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     edx, [esp+arg_8]
    mov     eax, ecx
    push    ebx
    push    ebp
    mov     cx, [eax+0Ah]
    push    esi
    mov     si, [eax+0Eh]
    mov     bp, [eax+6]
    sar     cx, 1
    sub     si, cx
    mov     ecx, TAdynmemStructPtr
    sub     esi, edx
    sub     bp, word ptr [esp+0Ch+arg_4]
    xor     edx, edx
    push    edi
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    add     ebp, 80h
    mov     edi, edx
    add     esi, 20h
    shl     edx, 5
    add     edx, edi
    lea     ebx, [ecx+edi]
    mov     cl, [ecx+14281h]
    lea     edx, [edx+edx*4]
    and     cl, 2
    cmp     cl, 2
    lea     edx, [ebx+edx*2+1B63h]
    jnz     short loc_473631
    movsx   ebx, word ptr [eax+0Ah]
    movsx   ecx, word ptr [eax+0Eh]
    movsx   edi, word ptr [eax+6]
    sar     ebx, 1
    sub     ecx, ebx
    mov     ebx, [edx+80h]
    sar     edi, 5
    sar     ecx, 5
    cmp     edi, ebx
    jnb     short loc_47362D
    cmp     ecx, [edx+84h]
    jnb     short loc_47362D
    mov     ebx, [edx+80h]
    imul    ebx, ecx
    add     ebx, [edx+7Ch]
    cmp     byte ptr [ebx+edi], 0
    jz      short loc_47362D
    mov     edx, 1
    jmp     short loc_473693
    ; ---------------------------------------------------------------------------

    loc_47362D:                             ; CODE XREF: sub_473590+7Aj
                                            ; sub_473590+82j ...
    xor     edx, edx
    jmp     short loc_473693
    ; ---------------------------------------------------------------------------

    loc_473631:                             ; CODE XREF: sub_473590+5Aj
    movsx   ecx, word ptr [eax+6]
    movsx   ebx, word ptr [eax+0Ah]
    sar     ecx, 5
    mov     [esp+10h+arg_4], ecx
    movsx   ecx, word ptr [eax+0Eh]
    sar     ebx, 1
    sub     ecx, ebx
    mov     ebx, [esp+10h+arg_4]
    sar     ecx, 5
    cmp     ebx, [edx+80h]
    jnb     short loc_47365F
    cmp     ecx, [edx+84h]
    jb      short loc_473663

    loc_47365F:                             ; CODE XREF: sub_473590+C5j
    xor     edx, edx
    jmp     short loc_473693
    ; ---------------------------------------------------------------------------

    loc_473663:                             ; CODE XREF: sub_473590+CDj
    mov     edx, [edx+80h]
    imul    edx, ecx
    mov     ecx, TAdynmemStructPtr
    add     edx, ebx
    xor     ebx, ebx
    mov     ecx, [ecx+14273h]
    mov     bx, [ecx+edx*2]
    mov     ecx, edi
    mov     edx, ebx
    mov     ebx, 1
    shl     ebx, cl
    and     edx, ebx
    neg     edx
    sbb     edx, edx
    neg     edx

    loc_473693:                             ; CODE XREF: sub_473590+9Bj
                                            ; sub_473590+9Fj ...
    test    edx, edx
    jz      short loc_4736B6
    movsx   edx, si
    movsx   ecx, bp
    push    edx
    mov     edx, [eax+2Ch]
    mov     eax, [eax]
    push    ecx
    push    edx
    push    eax
    call    sub_4B7F30
    mov     ecx, [esp+18h+arg_0]
    push    eax
    push    ecx
    call    sub_4B8500

    loc_4736B6:                             ; CODE XREF: sub_473590+105j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_473590 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4736C0 proc near                    ; CODE XREF: sub_472D50+33p

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    esi
    mov     esi, [ecx+30h]
    xor     eax, eax
    cmp     edx, esi
    pop     esi
    setnle  al
    retn    4
    sub_4736C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4736E0 proc near                    ; DATA XREF: .rdata:004FD5A0o

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    push    ebx
    push    esi
    push    edi
    mov     esi, ecx
    push    eax
    call    sub_471D70
    mov     ecx, [esp+0Ch+arg_0]
    lea     eax, [esi+20h]
    mov     edx, eax
    mov     edi, [ecx]
    mov     [edx], edi
    mov     edi, [ecx+4]
    mov     [edx+4], edi
    mov     ecx, [ecx+8]
    mov     [edx+8], ecx
    mov     edx, [esp+0Ch+arg_4]
    lea     ecx, [esi+2Ch]
    mov     ebx, [edx]
    mov     edi, ecx
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     edx, [edx+8]
    mov     [edi+8], edx
    mov     edx, [ecx]
    mov     ebx, [eax]
    mov     edi, [eax+4]
    sub     edx, ebx
    mov     ebx, [ecx+4]
    mov     ecx, [ecx+8]
    sub     ebx, edi
    mov     edi, [eax+8]
    sub     ecx, edi
    lea     edi, [esi+38h]
    mov     eax, edi
    mov     [eax], edx
    mov     [eax+4], ebx
    mov     [eax+8], ecx
    fild    dword ptr [edi]
    fild    dword ptr [edi+4]
    fild    dword ptr [edi+8]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    cdq
    fstp    st
    mov     ecx, 10h
    call    __allshl
    push    0
    push    50000h
    push    edx
    push    eax
    call    __alldiv
    mov     [esp+0Ch+arg_8], eax
    mov     eax, [edi]
    movsx   ecx, word ptr [esp+0Ch+arg_8+2]
    cdq
    idiv    ecx
    mov     [esi+1Ch], ecx
    mov     [edi], eax
    mov     eax, [esi+3Ch]
    cdq
    idiv    ecx
    mov     [esi+3Ch], eax
    mov     eax, [esi+40h]
    cdq
    idiv    ecx
    mov     edx, [esi]
    mov     ecx, esi
    mov     [esi+40h], eax
    call    dword ptr [edx+10h]
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_4736E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4737C0 proc near                    ; DATA XREF: .rdata:004FD598o

    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 3Ch
    mov     eax, 66666667h
    push    ebx
    mov     ebx, ecx
    mov     ecx, TAdynmemStructPtr
    push    ebp
    mov     edx, [ebx+4]
    push    esi
    mov     esi, [ecx+38A47h]
    push    edi
    sub     edx, esi
    add     edx, 0Ah
    imul    edx
    sar     edx, 2
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     esi, edx
    test    esi, esi
    jle     loc_4738E7
    mov     eax, [ebx+10h]
    test    eax, eax
    jnz     short loc_473803
    xor     edx, edx
    jmp     short loc_473819
    ; ---------------------------------------------------------------------------

    loc_473803:                             ; CODE XREF: sub_4737C0+3Dj
    mov     edx, [ebx+14h]
    sub     edx, eax
    mov     eax, 4EC4EC4Fh
    imul    edx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_473819:                             ; CODE XREF: sub_4737C0+41j
    mov     eax, [ebx+10h]
    add     esi, edx
    test    eax, eax
    mov     [esp+4Ch+var_3C], esi
    jnz     short loc_47382A
    xor     edx, edx
    jmp     short loc_473840
    ; ---------------------------------------------------------------------------

    loc_47382A:                             ; CODE XREF: sub_4737C0+64j
    mov     edx, [ebx+18h]
    sub     edx, eax
    mov     eax, 4EC4EC4Fh
    imul    edx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_473840:                             ; CODE XREF: sub_4737C0+68j
    cmp     edx, esi
    jnb     loc_4738E7
    test    esi, esi
    mov     eax, esi
    jge     short loc_473850
    xor     eax, eax

    loc_473850:                             ; CODE XREF: sub_4737C0+8Cj
    lea     ecx, [eax+eax*2]
    lea     edx, [eax+ecx*4]
    shl     edx, 2
    push    edx                             ; int
    call    sub_4B4F10
    mov     ebp, [ebx+14h]
    mov     edi, eax
    mov     eax, [ebx+10h]
    add     esp, 4
    cmp     eax, ebp
    mov     [esp+4Ch+var_38], edi
    mov     edx, edi
    jz      short loc_473895

    loc_473874:                             ; CODE XREF: sub_4737C0+CFj
    test    edx, edx
    jz      short loc_473887
    mov     ecx, 0Dh
    mov     esi, eax
    mov     edi, edx
    rep movsd
    mov     esi, [esp+4Ch+var_3C]

    loc_473887:                             ; CODE XREF: sub_4737C0+B6j
    add     eax, 34h
    add     edx, 34h
    cmp     eax, ebp
    jnz     short loc_473874
    mov     edi, [esp+4Ch+var_38]

    loc_473895:                             ; CODE XREF: sub_4737C0+B2j
    mov     eax, [ebx+10h]
    push    eax
    mov     [esp+50h+var_38], eax
    call    sub_4B4F20
    lea     eax, [esi+esi*2]
    add     esp, 4
    lea     ecx, [esi+eax*4]
    mov     eax, [ebx+10h]
    test    eax, eax
    lea     edx, [edi+ecx*4]
    mov     [ebx+18h], edx
    jnz     short loc_4738BC
    xor     edx, edx
    jmp     short loc_4738D2
    ; ---------------------------------------------------------------------------

    loc_4738BC:                             ; CODE XREF: sub_4737C0+F6j
    mov     ecx, [ebx+14h]
    sub     ecx, eax
    mov     eax, 4EC4EC4Fh
    imul    ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4738D2:                             ; CODE XREF: sub_4737C0+FAj
    lea     ecx, [edx+edx*2]
    mov     [ebx+10h], edi
    lea     edx, [edx+ecx*4]
    lea     eax, [edi+edx*4]
    mov     [ebx+14h], eax
    mov     ecx, TAdynmemStructPtr

    loc_4738E7:                             ; CODE XREF: sub_4737C0+32j
                                            ; sub_4737C0+82j
    lea     ebp, [ebx+20h]
    lea     esi, [ebx+0Ch]
    mov     edi, 1

    loc_4738F2:                             ; CODE XREF: sub_4737C0+1D3j
    mov     edx, ebp
    mov     eax, [edx]
    mov     [esp+4Ch+var_30], eax
    mov     eax, [edx+4]
    mov     [esp+4Ch+var_2C], eax
    lea     eax, [ebx+2Ch]
    mov     edx, [edx+8]
    mov     [esp+4Ch+var_28], edx
    mov     edx, [eax]
    mov     [esp+4Ch+var_24], edx
    mov     edx, [eax+4]
    mov     [esp+4Ch+var_20], edx
    mov     eax, [eax+8]
    mov     [esp+4Ch+var_1C], eax
    lea     eax, [ebx+38h]
    mov     edx, [ebx+38h]
    mov     [esp+4Ch+var_18], edx
    mov     edx, [eax+4]
    mov     [esp+4Ch+var_14], edx
    mov     eax, [eax+8]
    mov     [esp+4Ch+var_10], eax
    mov     edx, [ecx+38A47h]
    add     edx, [ebx+1Ch]
    mov     [esp+4Ch+var_4], edx
    mov     eax, [ecx+147F3h]
    mov     [esp+4Ch+var_34], eax
    mov     ecx, [ecx+147F3h]
    push    ecx
    call    sub_4B7F60
    dec     eax
    mov     [esp+4Ch+var_C], eax
    call    _rand
    imul    [esp+4Ch+var_C]
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    lea     edx, [esp+4Ch+var_34]
    mov     [esp+4Ch+var_8], eax
    mov     eax, [esi+8]
    push    edx
    push    1
    push    eax
    mov     ecx, esi
    call    sub_4758C0
    mov     ecx, TAdynmemStructPtr
    dec     edi
    jnz     loc_4738F2
    mov     edx, [ecx+38A47h]
    pop     edi
    add     edx, 0Ah
    pop     esi
    mov     [ebx+8], edx
    pop     ebp
    pop     ebx
    add     esp, 3Ch
    retn
    sub_4737C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4739B0 proc near                    ; CODE XREF: sub_472EB0+20p
    mov     edx, [ecx+18h]
    push    esi
    mov     esi, [ecx]
    mov     al, [ecx+28h]
    add     esi, edx
    and     eax, 0Fh
    mov     [ecx], esi
    mov     edx, [ecx+1Ch]
    mov     esi, [ecx+4]
    inc     eax
    add     esi, edx
    mov     [ecx+4], esi
    mov     edx, [ecx+20h]
    mov     esi, [ecx+8]
    add     esi, edx
    cmp     ax, 7
    mov     [ecx+8], esi
    jle     short loc_4739E2
    mov     eax, 1

    loc_4739E2:                             ; CODE XREF: sub_4739B0+2Bj
    mov     edx, [ecx+28h]
    pop     esi
    movsx   eax, ax
    and     edx, 0FFF0h
    add     edx, eax
    mov     [ecx+28h], edx
    retn
    sub_4739B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_473A00(int,int,int)
    sub_473A00 proc near                    ; CODE XREF: sub_472F90+2Bp

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 14h
    push    ebx
    mov     ebx, [esp+18h+arg_8]
    push    ebp
    mov     eax, ecx
    push    esi
    mov     esi, [esp+20h+arg_4]
    mov     bp, [eax+0Ah]
    push    edi
    mov     di, [eax+2]
    mov     [esp+24h+var_14], eax
    movsx   edx, word ptr [eax+6]
    mov     ecx, edi
    mov     eax, ebp
    sub     ecx, esi
    sub     eax, ebx
    movsx   ecx, cx
    movsx   eax, ax
    mov     ebx, TAdynmemStructPtr
    add     ecx, 80h
    sar     edx, 1
    sub     eax, edx
    mov     [esp+24h+var_10], ecx
    add     eax, 20h
    inc     ecx
    mov     [esp+24h+var_C], eax
    mov     [esp+24h+var_8], ecx
    inc     eax
    xor     ecx, ecx
    mov     [esp+24h+var_4], eax
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     esi, [ebx+ecx]
    lea     eax, [eax+eax*4]
    lea     esi, [esi+eax*2+TAdynmemStruct.Players]
    mov     al, [ebx+14281h]
    and     al, 2
    cmp     al, 2
    jnz     short loc_473ABB
    movsx   eax, bp
    movsx   ecx, di
    sub     eax, edx
    mov     edx, [esi+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, edx
    jnb     short loc_473AB7
    cmp     eax, [esi+84h]
    jnb     short loc_473AB7
    mov     edx, [esi+80h]
    imul    edx, eax
    mov     eax, [esi+7Ch]
    add     edx, ecx
    cmp     byte ptr [edx+eax], 0
    jz      short loc_473AB7
    mov     eax, 1
    jmp     short loc_473B07
    ; ---------------------------------------------------------------------------

    loc_473AB7:                             ; CODE XREF: sub_473A00+92j
                                            ; sub_473A00+9Aj ...
    xor     eax, eax
    jmp     short loc_473B07
    ; ---------------------------------------------------------------------------

    loc_473ABB:                             ; CODE XREF: sub_473A00+7Aj
    movsx   eax, bp
    movsx   edi, di
    sub     eax, edx
    mov     edx, [esi+80h]
    sar     edi, 5
    sar     eax, 5
    cmp     edi, edx
    jnb     short loc_473ADB
    cmp     eax, [esi+84h]
    jb      short loc_473ADF

    loc_473ADB:                             ; CODE XREF: sub_473A00+D1j
    xor     eax, eax
    jmp     short loc_473B07
    ; ---------------------------------------------------------------------------

    loc_473ADF:                             ; CODE XREF: sub_473A00+D9j
    mov     edx, [esi+80h]
    xor     esi, esi
    imul    edx, eax
    mov     eax, [ebx+14273h]
    add     edx, edi
    mov     si, [eax+edx*2]
    mov     edx, 1
    shl     edx, cl
    mov     eax, esi
    and     eax, edx
    neg     eax
    sbb     eax, eax
    neg     eax

    loc_473B07:                             ; CODE XREF: sub_473A00+B5j
                                            ; sub_473A00+B9j ...
    test    eax, eax
    jz      short loc_473B22
    mov     eax, [esp+24h+var_14]
    lea     edx, [esp+24h+var_10]
    mov     ecx, [eax+28h]
    mov     eax, [esp+24h+arg_0]
    push    ecx
    push    edx
    push    eax
    call    sub_4BF6F0

    loc_473B22:                             ; CODE XREF: sub_473A00+109j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    sub_473A00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473B30 proc near                    ; CODE XREF: sub_472EB0+33p

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    esi
    mov     esi, [ecx+2Ch]
    xor     eax, eax
    cmp     edx, esi
    pop     esi
    setnle  al
    retn    4
    sub_473B30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473B50 proc near                    ; DATA XREF: .rdata:004FD5D0o

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     ebx, ecx
    push    eax
    call    sub_471D70
    mov     esi, [esp+10h+arg_0]
    lea     ebp, [ebx+1Ch]
    mov     ecx, 6
    mov     edi, ebp
    rep movsd
    mov     esi, [esp+10h+arg_4]
    lea     eax, [ebx+34h]
    mov     ecx, 6
    mov     edi, eax
    rep movsd
    mov     esi, [eax]
    mov     ecx, [ebx+40h]
    sub     ecx, esi
    mov     eax, 2E8BA2E9h
    lea     edx, ds:0[ecx*4]
    imul    edx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 2E8BA2E9h
    add     edx, esi
    mov     [ebx+34h], edx
    mov     edx, ecx
    shl     edx, 3
    sub     edx, ecx
    imul    edx
    sar     edx, 1
    mov     ecx, edx
    mov     eax, 2E8BA2E9h
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, [ebx+44h]
    add     edx, esi
    mov     esi, [ebx+38h]
    sub     ecx, esi
    mov     [ebx+40h], edx
    lea     edx, ds:0[ecx*4]
    imul    edx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 2E8BA2E9h
    add     edx, esi
    mov     [ebx+38h], edx
    mov     edx, ecx
    shl     edx, 3
    sub     edx, ecx
    imul    edx
    sar     edx, 1
    mov     ecx, edx
    mov     eax, 2E8BA2E9h
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, [ebx+48h]
    add     edx, esi
    mov     esi, [ebx+3Ch]
    mov     [ebx+44h], edx
    mov     edx, esi
    sub     ecx, edx
    lea     edx, ds:0[ecx*4]
    imul    edx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, [ebx+40h]
    lea     edi, [edx+esi]
    mov     edx, [ebx+34h]
    sub     eax, edx
    mov     [ebx+3Ch], edi
    mov     [ebx+40h], eax
    mov     eax, [ebx+38h]
    mov     edx, [ebx+44h]
    sub     edx, eax
    mov     eax, 2E8BA2E9h
    mov     [ebx+44h], edx
    mov     edx, ecx
    shl     edx, 3
    sub     edx, ecx
    imul    edx
    sar     edx, 1
    mov     ecx, edx
    mov     eax, 2E8BA2E9h
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, [ebx+28h]
    add     edx, esi
    mov     esi, [ebp+0]
    sub     edx, edi
    sub     ecx, esi
    mov     [ebx+48h], edx
    lea     edx, ds:0[ecx*4]
    imul    edx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 2E8BA2E9h
    add     edx, esi
    mov     [ebp+0], edx
    mov     edx, ecx
    shl     edx, 3
    sub     edx, ecx
    imul    edx
    sar     edx, 1
    mov     ecx, edx
    mov     eax, 2E8BA2E9h
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, [ebx+2Ch]
    add     edx, esi
    mov     esi, [ebx+20h]
    sub     ecx, esi
    mov     [ebx+28h], edx
    lea     edx, ds:0[ecx*4]
    imul    edx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 2E8BA2E9h
    add     edx, esi
    mov     [ebx+20h], edx
    mov     edx, ecx
    shl     edx, 3
    sub     edx, ecx
    imul    edx
    sar     edx, 1
    mov     ecx, edx
    mov     eax, 2E8BA2E9h
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, [ebx+30h]
    add     edx, esi
    mov     esi, [ebx+24h]
    mov     [ebx+2Ch], edx
    mov     edx, esi
    sub     ecx, edx
    lea     edx, ds:0[ecx*4]
    imul    edx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, [ebx+20h]
    lea     edi, [edx+esi]
    mov     edx, [ebp+0]
    mov     ebp, [ebx+28h]
    mov     [ebx+24h], edi
    sub     ebp, edx
    mov     edx, [ebx+2Ch]
    mov     [ebx+28h], ebp
    sub     edx, eax
    mov     eax, 2E8BA2E9h
    mov     [ebx+2Ch], edx
    mov     edx, ecx
    shl     edx, 3
    sub     edx, ecx
    imul    edx
    sar     edx, 1
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, ebx
    add     edx, esi
    sub     edx, edi
    mov     [ebx+30h], edx
    mov     edx, [ebx]
    call    dword ptr [edx+10h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_473B50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_473D50 proc near                    ; DATA XREF: .rdata:004FD5C8o

    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     eax, TAdynmemStructPtr
    sub     esp, 4Ch
    mov     edx, [eax+38A47h]
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     esi, [ebp+4]
    sub     esi, edx
    inc     esi
    test    esi, esi
    jle     short loc_473D9D
    mov     eax, [ebp+10h]
    lea     ecx, [ebp+0Ch]
    test    eax, eax
    jnz     short loc_473D7C
    xor     edx, edx
    jmp     short loc_473D92
    ; ---------------------------------------------------------------------------

    loc_473D7C:                             ; CODE XREF: sub_473D50+26j
    mov     edx, [ecx+8]
    sub     edx, eax
    mov     eax, 2AAAAAABh
    imul    edx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_473D92:                             ; CODE XREF: sub_473D50+2Aj
    lea     edx, [edx+esi*4]
    add     esi, edx
    push    esi
    call    sub_475770

    loc_473D9D:                             ; CODE XREF: sub_473D50+1Cj
    mov     [esp+5Ch+var_4C], 0
    mov     [esp+5Ch+var_44], 5

    loc_473DAD:                             ; CODE XREF: sub_473D50+3B9j
    call    _rand
    imul    dword ptr [ebp+28h]
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, [ebp+1Ch]
    mov     [esp+5Ch+var_30], eax
    call    _rand
    imul    dword ptr [ebp+2Ch]
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, [ebp+20h]
    mov     [esp+5Ch+var_2C], eax
    call    _rand
    imul    dword ptr [ebp+30h]
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, [ebp+24h]
    mov     [esp+5Ch+var_28], eax
    call    _rand
    imul    dword ptr [ebp+40h]
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, [ebp+34h]
    mov     [esp+5Ch+var_24], eax
    call    _rand
    imul    dword ptr [ebp+44h]
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, [ebp+38h]
    mov     [esp+5Ch+var_20], eax
    call    _rand
    imul    dword ptr [ebp+48h]
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, [ebp+3Ch]
    mov     esi, [esp+5Ch+var_24]
    mov     ebx, [esp+5Ch+var_30]
    mov     edi, [esp+5Ch+var_2C]
    mov     edx, [esp+5Ch+var_28]
    add     eax, ecx
    mov     ecx, [esp+5Ch+var_20]
    sub     esi, ebx
    mov     [esp+5Ch+var_3C], esi
    sub     ecx, edi
    fild    [esp+5Ch+var_3C]
    mov     [esp+5Ch+var_1C], eax
    mov     [esp+5Ch+var_38], ecx
    fild    [esp+5Ch+var_38]
    sub     eax, edx
    mov     edi, ecx
    mov     [esp+5Ch+var_34], eax
    mov     ebx, eax
    fild    [esp+5Ch+var_34]
    fld     st(2)
    mov     [esp+5Ch+var_18], esi
    mov     [esp+5Ch+var_14], edi
    mov     [esp+5Ch+var_10], ebx
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    cdq
    fstp    st
    mov     ecx, 10h
    call    __allshl
    push    0
    push    40000h
    push    edx
    push    eax
    call    __alldiv
    mov     [esp+5Ch+var_48], eax
    mov     ax, word ptr [esp+5Ch+var_48+2]
    test    ax, ax
    jz      loc_4740F7
    movsx   ecx, ax
    mov     eax, esi
    cdq
    idiv    ecx
    mov     [esp+5Ch+var_18], eax
    mov     eax, edi
    cdq
    idiv    ecx
    mov     [esp+5Ch+var_14], eax
    mov     eax, ebx
    cdq
    idiv    ecx
    lea     ebx, [ebp+0Ch]
    mov     [esp+5Ch+var_10], eax
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+38A47h]
    mov     eax, [esp+5Ch+var_4C]
    add     edx, ecx
    mov     ecx, 7
    mov     [esp+5Ch+var_4], edx
    mov     [esp+5Ch+var_C], 100h
    cdq
    idiv    ecx
    mov     ecx, [ebx+8]
    mov     eax, 2AAAAAABh
    mov     esi, ecx
    mov     [esp+5Ch+var_48], esi
    add     edx, 0A1h
    mov     [esp+5Ch+var_8], edx
    mov     edx, [ebx+0Ch]
    sub     edx, ecx
    imul    edx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 1
    jnb     loc_47402D
    mov     eax, [ebx+4]
    test    eax, eax
    jnz     short loc_473F6A
    xor     edx, edx
    jmp     short loc_473F7D
    ; ---------------------------------------------------------------------------

    loc_473F6A:                             ; CODE XREF: sub_473D50+214j
    sub     ecx, eax
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_473F7D:                             ; CODE XREF: sub_473D50+218j
    cmp     edx, 1
    jbe     short loc_473F8D
    mov     ecx, ebx
    call    sub_475840
    mov     edi, eax
    jmp     short loc_473F92
    ; ---------------------------------------------------------------------------

    loc_473F8D:                             ; CODE XREF: sub_473D50+230j
    mov     edi, 1

    loc_473F92:                             ; CODE XREF: sub_473D50+23Bj
    mov     ecx, ebx
    call    sub_475840
    add     eax, edi
    mov     [esp+5Ch+var_40], eax
    jns     short loc_473FA3
    xor     eax, eax

    loc_473FA3:                             ; CODE XREF: sub_473D50+24Fj
    lea     edx, [eax+eax*2]
    shl     edx, 4
    push    edx                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     edi, eax
    mov     eax, [ebx+4]
    mov     ecx, ebx
    push    edi
    push    esi
    push    eax
    call    sub_475880
    lea     ecx, [esp+5Ch+var_30]
    mov     [esp+5Ch+var_48], eax
    push    ecx
    push    1
    push    eax
    mov     ecx, ebx
    call    sub_476710
    mov     edx, [esp+5Ch+var_48]
    mov     eax, [ebx+8]
    add     edx, 30h
    mov     ecx, ebx
    push    edx
    push    eax
    push    esi
    call    sub_475880
    mov     ecx, [ebx+8]
    mov     edx, [ebx+4]
    push    ecx
    push    edx
    mov     ecx, ebx
    call    nullsub_51
    mov     eax, [ebx+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+60h+var_40]
    add     esp, 4
    mov     ecx, ebx
    lea     eax, [eax+eax*2]
    shl     eax, 4
    add     eax, edi
    mov     [ebx+0Ch], eax
    call    sub_475840
    inc     eax
    mov     [ebx+4], edi
    lea     ecx, [eax+eax*2]
    shl     ecx, 4
    add     ecx, edi
    mov     [ebx+8], ecx
    jmp     loc_4740F7
    ; ---------------------------------------------------------------------------

    loc_47402D:                             ; CODE XREF: sub_473D50+209j
    mov     edx, ecx
    mov     eax, 2AAAAAABh
    sub     edx, esi
    imul    edx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 1
    jnb     short loc_4740A0
    lea     edx, [esi+30h]
    push    edx
    push    ecx
    push    esi
    mov     ecx, ebx
    call    sub_475880
    mov     edi, [ebx+8]
    lea     eax, [esp+5Ch+var_30]
    mov     ecx, edi
    push    eax
    sub     ecx, esi
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    mov     eax, 1
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, ebx
    sub     eax, edx
    push    eax
    push    edi
    call    sub_476710
    mov     edx, [ebx+8]
    mov     eax, esi
    cmp     esi, edx
    jz      short loc_4740F3

    loc_47408A:                             ; CODE XREF: sub_473D50+34Cj
    mov     edi, eax
    add     eax, 30h
    mov     ecx, 0Ch
    lea     esi, [esp+5Ch+var_30]
    cmp     eax, edx
    rep movsd
    jnz     short loc_47408A
    jmp     short loc_4740F3
    ; ---------------------------------------------------------------------------

    loc_4740A0:                             ; CODE XREF: sub_473D50+2F5j
    lea     eax, [ecx-30h]
    push    ecx
    push    ecx
    push    eax
    mov     ecx, ebx
    mov     [esp+68h+var_40], eax
    call    sub_475880
    mov     edx, [ebx+8]
    lea     eax, [edx-30h]
    cmp     esi, eax
    jz      short loc_4740D6

    loc_4740BB:                             ; CODE XREF: sub_473D50+382j
    sub     eax, 30h
    sub     edx, 30h
    mov     ecx, 0Ch
    mov     esi, eax
    mov     edi, edx
    rep movsd
    mov     ecx, [esp+5Ch+var_48]
    cmp     eax, ecx
    jnz     short loc_4740BB
    mov     esi, ecx

    loc_4740D6:                             ; CODE XREF: sub_473D50+369j
    lea     edx, [esi+30h]
    mov     eax, esi
    cmp     esi, edx
    jz      short loc_4740F3

    loc_4740DF:                             ; CODE XREF: sub_473D50+3A1j
    mov     edi, eax
    add     eax, 30h
    mov     ecx, 0Ch
    lea     esi, [esp+5Ch+var_30]
    cmp     eax, edx
    rep movsd
    jnz     short loc_4740DF

    loc_4740F3:                             ; CODE XREF: sub_473D50+338j
                                            ; sub_473D50+34Ej ...
    add     dword ptr [ebx+8], 30h

    loc_4740F7:                             ; CODE XREF: sub_473D50+191j
                                            ; sub_473D50+2D8j
    mov     ecx, [esp+5Ch+var_4C]
    mov     eax, [esp+5Ch+var_44]
    inc     ecx
    dec     eax
    mov     [esp+5Ch+var_4C], ecx
    mov     [esp+5Ch+var_44], eax
    jnz     loc_473DAD
    mov     ecx, TAdynmemStructPtr
    pop     edi
    pop     esi
    mov     edx, [ecx+38A47h]
    inc     edx
    mov     [ebp+8], edx
    pop     ebp
    pop     ebx
    add     esp, 4Ch
    retn
    sub_473D50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474130 proc near                    ; CODE XREF: sub_473010+20p
    mov     eax, [ecx+1Ch]
    mov     edx, [ecx+4]
    add     edx, eax
    mov     eax, [ecx+8]
    mov     [ecx+4], edx
    mov     edx, [ecx+20h]
    add     eax, edx
    mov     edx, [ecx+0Ch]
    mov     [ecx+8], eax
    mov     eax, [ecx+24h]
    add     edx, eax
    mov     [ecx+0Ch], edx
    mov     eax, [ecx+30h]
    inc     eax
    cdq
    idiv    dword ptr [ecx+34h]
    test    edx, edx
    mov     [ecx+30h], edx
    jnz     short locret_47416B
    mov     eax, [ecx+2Ch]
    inc     eax
    cdq
    idiv    dword ptr [ecx+28h]
    mov     [ecx+2Ch], edx

    locret_47416B:                          ; CODE XREF: sub_474130+2Ej
    retn
    sub_474130 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474170 proc near                    ; CODE XREF: sub_4730F0+2Bp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     edx, [esp+arg_8]
    mov     eax, ecx
    push    ebx
    push    ebp
    mov     cx, [eax+0Ah]
    push    esi
    mov     si, [eax+0Eh]
    mov     bp, [eax+6]
    sar     cx, 1
    sub     si, cx
    mov     ecx, TAdynmemStructPtr
    sub     esi, edx
    sub     bp, word ptr [esp+0Ch+arg_4]
    xor     edx, edx
    push    edi
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    add     ebp, 80h
    mov     edi, edx
    add     esi, 20h
    shl     edx, 5
    add     edx, edi
    lea     ebx, [ecx+edi]
    mov     cl, [ecx+14281h]
    lea     edx, [edx+edx*4]
    and     cl, 2
    cmp     cl, 2
    lea     edx, [ebx+edx*2+TAdynmemStruct.Players]
    jnz     short loc_474211
    movsx   ebx, word ptr [eax+0Ah]
    movsx   ecx, word ptr [eax+0Eh]
    movsx   edi, word ptr [eax+6]
    sar     ebx, 1
    sub     ecx, ebx
    mov     ebx, [edx+80h]
    sar     edi, 5
    sar     ecx, 5
    cmp     edi, ebx
    jnb     short loc_47420D
    cmp     ecx, [edx+84h]
    jnb     short loc_47420D
    mov     ebx, [edx+80h]
    imul    ebx, ecx
    add     ebx, [edx+7Ch]
    cmp     byte ptr [ebx+edi], 0
    jz      short loc_47420D
    mov     edx, 1
    jmp     short loc_474273
    ; ---------------------------------------------------------------------------

    loc_47420D:                             ; CODE XREF: sub_474170+7Aj
                                            ; sub_474170+82j ...
    xor     edx, edx
    jmp     short loc_474273
    ; ---------------------------------------------------------------------------

    loc_474211:                             ; CODE XREF: sub_474170+5Aj
    movsx   ecx, word ptr [eax+6]
    movsx   ebx, word ptr [eax+0Ah]
    sar     ecx, 5
    mov     [esp+10h+arg_4], ecx
    movsx   ecx, word ptr [eax+0Eh]
    sar     ebx, 1
    sub     ecx, ebx
    mov     ebx, [esp+10h+arg_4]
    sar     ecx, 5
    cmp     ebx, [edx+80h]
    jnb     short loc_47423F
    cmp     ecx, [edx+84h]
    jb      short loc_474243

    loc_47423F:                             ; CODE XREF: sub_474170+C5j
    xor     edx, edx
    jmp     short loc_474273
    ; ---------------------------------------------------------------------------

    loc_474243:                             ; CODE XREF: sub_474170+CDj
    mov     edx, [edx+80h]
    imul    edx, ecx
    mov     ecx, TAdynmemStructPtr
    add     edx, ebx
    xor     ebx, ebx
    mov     ecx, [ecx+14273h]
    mov     bx, [ecx+edx*2]
    mov     ecx, edi
    mov     edx, ebx
    mov     ebx, 1
    shl     ebx, cl
    and     edx, ebx
    neg     edx
    sbb     edx, edx
    neg     edx

    loc_474273:                             ; CODE XREF: sub_474170+9Bj
                                            ; sub_474170+9Fj ...
    test    edx, edx
    jz      short loc_474296
    movsx   edx, si
    movsx   ecx, bp
    push    edx
    mov     edx, [eax+2Ch]
    mov     eax, [eax]
    push    ecx
    push    edx
    push    eax
    call    sub_4B7F30
    mov     ecx, [esp+18h+arg_0]
    push    eax
    push    ecx
    call    sub_4B8500

    loc_474296:                             ; CODE XREF: sub_474170+105j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_474170 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4742A0 proc near                    ; CODE XREF: sub_473010+33p

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    esi
    mov     esi, [ecx+38h]
    xor     eax, eax
    cmp     edx, esi
    pop     esi
    setnle  al
    retn    4
    sub_4742A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4742C0 proc near                    ; DATA XREF: .rdata:004FD5F0o

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h
    arg_C= dword ptr  18h

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_C]
    push    esi
    push    edi
    mov     esi, ecx
    push    ebp
    call    sub_471D70
    mov     eax, [esp+8+arg_8]
    mov     ecx, [esp+8+arg_0]
    mov     [esi+1Ch], eax
    lea     eax, [esi+20h]
    mov     edi, [ecx]
    mov     edx, eax
    mov     [edx], edi
    mov     edi, [ecx+4]
    mov     [edx+4], edi
    mov     ecx, [ecx+8]
    mov     [edx+8], ecx
    mov     edx, [esp+8+arg_4]
    lea     ecx, [esi+2Ch]
    mov     ebx, [edx]
    mov     edi, ecx
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     edx, [edx+8]
    mov     [edi+8], edx
    mov     edx, [ecx]
    mov     ebx, [eax]
    mov     edi, [eax+4]
    sub     edx, ebx
    mov     ebx, [ecx+4]
    mov     ecx, [ecx+8]
    sub     ebx, edi
    mov     edi, [eax+8]
    sub     ecx, edi
    lea     edi, [esi+38h]
    mov     eax, edi
    mov     [eax], edx
    mov     [eax+4], ebx
    mov     [eax+8], ecx
    mov     eax, ebp
    shl     eax, 10h
    cdq
    push    edx
    push    eax
    push    1
    push    0
    call    __alldiv
    cdq
    mov     ebx, eax
    mov     eax, [edi]
    mov     ebp, edx
    cdq
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [edi], eax
    mov     eax, [edi+4]
    cdq
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [edi+4], eax
    mov     eax, [edi+8]
    cdq
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [edi+8], eax
    mov     edx, [esi]
    mov     ecx, esi
    call    dword ptr [edx+10h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_4742C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4743A0 proc near                    ; DATA XREF: .rdata:004FD5E8o

    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 44h
    push    ebx
    mov     ebx, ecx
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    esi
    push    edi
    mov     edi, [ebx+4]
    mov     esi, [ecx+38A47h]
    sub     edi, esi
    inc     edi
    test    edi, edi
    jle     loc_4744B8
    mov     eax, [ebx+10h]
    test    eax, eax
    jnz     short loc_4743CE
    xor     edx, edx
    jmp     short loc_4743E6
    ; ---------------------------------------------------------------------------

    loc_4743CE:                             ; CODE XREF: sub_4743A0+28j
    mov     esi, [ebx+14h]
    sub     esi, eax
    mov     eax, 88888889h
    imul    esi
    add     edx, esi
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4743E6:                             ; CODE XREF: sub_4743A0+2Cj
    mov     eax, [ebx+10h]
    add     edi, edx
    test    eax, eax
    mov     [esp+54h+var_44], edi
    jnz     short loc_4743F7
    xor     edx, edx
    jmp     short loc_47440F
    ; ---------------------------------------------------------------------------

    loc_4743F7:                             ; CODE XREF: sub_4743A0+51j
    mov     esi, [ebx+18h]
    sub     esi, eax
    mov     eax, 88888889h
    imul    esi
    add     edx, esi
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_47440F:                             ; CODE XREF: sub_4743A0+55j
    cmp     edx, edi
    jnb     loc_4744B8
    test    edi, edi
    mov     eax, edi
    jge     short loc_47441F
    xor     eax, eax

    loc_47441F:                             ; CODE XREF: sub_4743A0+7Bj
    lea     eax, [eax+eax*2]
    lea     ecx, [eax+eax*4]
    shl     ecx, 2
    push    ecx                             ; int
    call    sub_4B4F10
    mov     ebp, [ebx+14h]
    mov     esi, eax
    mov     eax, [ebx+10h]
    add     esp, 4
    cmp     eax, ebp
    mov     [esp+54h+var_40], esi
    mov     edx, esi
    jz      short loc_474464

    loc_474443:                             ; CODE XREF: sub_4743A0+BEj
    test    edx, edx
    jz      short loc_474456
    mov     ecx, 0Fh
    mov     esi, eax
    mov     edi, edx
    rep movsd
    mov     edi, [esp+54h+var_44]

    loc_474456:                             ; CODE XREF: sub_4743A0+A5j
    add     eax, 3Ch
    add     edx, 3Ch
    cmp     eax, ebp
    jnz     short loc_474443
    mov     esi, [esp+54h+var_40]

    loc_474464:                             ; CODE XREF: sub_4743A0+A1j
    mov     eax, [ebx+10h]
    push    eax
    mov     [esp+58h+var_40], eax
    call    sub_4B4F20
    lea     eax, [edi+edi*2]
    add     esp, 4
    lea     edx, [eax+eax*4]
    lea     eax, [esi+edx*4]
    mov     [ebx+18h], eax
    mov     eax, [ebx+10h]
    test    eax, eax
    jnz     short loc_47448B
    xor     edx, edx
    jmp     short loc_4744A3
    ; ---------------------------------------------------------------------------

    loc_47448B:                             ; CODE XREF: sub_4743A0+E5j
    mov     ecx, [ebx+14h]
    sub     ecx, eax
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_4744A3:                             ; CODE XREF: sub_4743A0+E9j
    lea     eax, [edx+edx*2]
    mov     [ebx+10h], esi
    lea     edx, [eax+eax*4]
    lea     eax, [esi+edx*4]
    mov     [ebx+14h], eax
    mov     ecx, TAdynmemStructPtr

    loc_4744B8:                             ; CODE XREF: sub_4743A0+1Dj
                                            ; sub_4743A0+71j
    lea     ebp, [ebx+20h]
    lea     esi, [ebx+0Ch]
    mov     edi, 1
    jmp     short loc_4744CB
    ; ---------------------------------------------------------------------------

    loc_4744C5:                             ; CODE XREF: sub_4743A0+1BCj
    mov     ecx, TAdynmemStructPtr

    loc_4744CB:                             ; CODE XREF: sub_4743A0+123j
    mov     edx, [ebx+1Ch]
    mov     eax, [ebx+4]
    mov     [esp+54h+var_8], edx
    mov     edx, ebp
    mov     [esp+54h+var_4], eax
    mov     [esp+54h+var_C], 0
    mov     eax, [edx]
    mov     [esp+54h+var_38], eax
    mov     eax, [edx+4]
    mov     [esp+54h+var_34], eax
    lea     eax, [ebx+2Ch]
    mov     edx, [edx+8]
    mov     [esp+54h+var_30], edx
    mov     edx, [eax]
    mov     [esp+54h+var_2C], edx
    mov     edx, [eax+4]
    mov     [esp+54h+var_28], edx
    mov     eax, [eax+8]
    mov     [esp+54h+var_24], eax
    lea     eax, [ebx+38h]
    mov     edx, [ebx+38h]
    mov     [esp+54h+var_20], edx
    mov     edx, [eax+4]
    mov     [esp+54h+var_1C], edx
    mov     eax, [eax+8]
    mov     [esp+54h+var_18], eax
    mov     edx, [ecx+147F3h]
    mov     [esp+54h+var_3C], edx
    mov     eax, [ecx+147F3h]
    push    eax
    call    sub_4B7F60
    mov     edx, [esi+8]
    lea     ecx, [esp+54h+var_3C]
    push    ecx
    dec     eax
    push    1
    push    edx
    mov     ecx, esi
    mov     [esp+60h+var_14], eax
    mov     [esp+60h+var_10], 0
    call    sub_475BD0
    dec     edi
    jnz     loc_4744C5
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     ecx, [eax+38A47h]
    inc     ecx
    mov     [ebx+8], ecx
    pop     ebx
    add     esp, 44h
    retn
    sub_4743A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474580 proc near                    ; CODE XREF: sub_473170+20p
    mov     eax, [ecx+1Ch]
    mov     edx, [ecx+4]
    add     edx, eax
    mov     eax, [ecx+8]
    mov     [ecx+4], edx
    mov     edx, [ecx+20h]
    add     eax, edx
    mov     edx, [ecx+0Ch]
    mov     [ecx+8], eax
    mov     eax, [ecx+24h]
    add     edx, eax
    push    esi
    mov     [ecx+0Ch], edx
    mov     eax, [ecx+38h]
    inc     eax
    cdq
    idiv    dword ptr [ecx+3Ch]
    test    edx, edx
    mov     [ecx+38h], edx
    jnz     short loc_4745D8
    mov     edx, [ecx+34h]
    mov     eax, [ecx+30h]
    add     eax, edx
    mov     [ecx+30h], eax
    mov     edx, eax
    mov     eax, [ecx+2Ch]
    cmp     edx, eax
    jle     short loc_4745CB
    mov     edx, [ecx+28h]
    mov     [ecx+30h], edx

    loc_4745CB:                             ; CODE XREF: sub_474580+43j
    mov     edx, [ecx+30h]
    mov     esi, [ecx+28h]
    cmp     edx, esi
    jge     short loc_4745D8
    mov     [ecx+30h], eax

    loc_4745D8:                             ; CODE XREF: sub_474580+2Fj
                                            ; sub_474580+53j
    pop     esi
    retn
    sub_474580 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4745E0 proc near                    ; CODE XREF: sub_473250+2Bp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= word ptr  8
    arg_8= word ptr  0Ch

    sub     esp, 10h
    mov     eax, ecx
    push    ebx
    push    ebp
    push    esi
    mov     cx, [eax+6]
    push    edi
    sub     cx, [esp+20h+arg_4]
    mov     edi, TAdynmemStructPtr
    movsx   esi, word ptr [eax+0Ah]
    movsx   edx, cx
    mov     cx, [eax+0Eh]
    add     edx, 80h
    sub     cx, [esp+20h+arg_8]
    mov     [esp+20h+var_10], edx
    sar     esi, 1
    movsx   ecx, cx
    sub     ecx, esi
    add     ecx, 20h
    inc     edx
    mov     [esp+20h+var_C], ecx
    mov     [esp+20h+var_8], edx
    inc     ecx
    xor     edx, edx
    mov     [esp+20h+var_4], ecx
    mov     dl, [edi+TAdynmemStruct.LOS_Sight]
    mov     esi, edx
    shl     edx, 5
    add     edx, esi
    lea     ecx, [edx+edx*4]
    lea     edx, [edi+esi]
    lea     edx, [edx+ecx*2+TAdynmemStruct.Players]
    mov     cl, [edi+14281h]
    and     cl, 2
    cmp     cl, 2
    jnz     short loc_47469B
    movsx   edi, word ptr [eax+0Ah]
    movsx   ecx, word ptr [eax+0Eh]
    movsx   esi, word ptr [eax+6]
    sar     edi, 1
    sub     ecx, edi
    mov     edi, [edx+80h]
    sar     esi, 5
    sar     ecx, 5
    cmp     esi, edi
    jnb     short loc_474697
    cmp     ecx, [edx+84h]
    jnb     short loc_474697
    mov     edi, [edx+80h]
    mov     edx, [edx+7Ch]
    imul    edi, ecx
    add     edi, esi
    cmp     byte ptr [edi+edx], 0
    jz      short loc_474697
    mov     edx, 1
    jmp     short loc_4746F1
    ; ---------------------------------------------------------------------------

    loc_474697:                             ; CODE XREF: sub_4745E0+92j
                                            ; sub_4745E0+9Aj ...
    xor     edx, edx
    jmp     short loc_4746F1
    ; ---------------------------------------------------------------------------

    loc_47469B:                             ; CODE XREF: sub_4745E0+72j
    movsx   ebp, word ptr [eax+0Ah]
    movsx   ecx, word ptr [eax+0Eh]
    movsx   ebx, word ptr [eax+6]
    sar     ebp, 1
    sub     ecx, ebp
    mov     ebp, [edx+80h]
    sar     ebx, 5
    sar     ecx, 5
    cmp     ebx, ebp
    jnb     short loc_4746C3
    cmp     ecx, [edx+84h]
    jb      short loc_4746C7

    loc_4746C3:                             ; CODE XREF: sub_4745E0+D9j
    xor     edx, edx
    jmp     short loc_4746F1
    ; ---------------------------------------------------------------------------

    loc_4746C7:                             ; CODE XREF: sub_4745E0+E1j
    mov     edx, [edx+80h]
    imul    edx, ecx
    mov     ecx, [edi+14273h]
    add     edx, ebx
    xor     edi, edi
    mov     di, [ecx+edx*2]
    mov     ecx, esi
    mov     edx, edi
    mov     edi, 1
    shl     edi, cl
    and     edx, edi
    neg     edx
    sbb     edx, edx
    neg     edx

    loc_4746F1:                             ; CODE XREF: sub_4745E0+B5j
                                            ; sub_4745E0+B9j ...
    test    edx, edx
    jz      short loc_474708
    mov     edx, [eax+30h]
    mov     ecx, [esp+20h+arg_0]
    lea     eax, [esp+20h+var_10]
    push    edx
    push    eax
    push    ecx
    call    sub_4BF6F0

    loc_474708:                             ; CODE XREF: sub_4745E0+113j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    sub_4745E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474720 proc near                    ; CODE XREF: sub_473170+33p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+40h]
    cmp     eax, edx
    jg      short loc_47474B
    add     ecx, 4
    push    ecx
    call    sub_485070
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [edx+1427Fh]
    cmp     eax, ecx
    jge     short loc_47474B
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47474B:                             ; CODE XREF: sub_474720+9j
                                            ; sub_474720+24j
    mov     eax, 1
    retn    4
    sub_474720 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474760 proc near                    ; DATA XREF: .rdata:004FD610o

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     eax, [esp+arg_C]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    push    eax
    call    sub_471D70
    mov     ecx, [esp+10h+arg_8]
    mov     edx, [esp+10h+arg_0]
    lea     eax, [edi+20h]
    mov     [edi+1Ch], ecx
    mov     esi, [edx]
    mov     ecx, eax
    mov     [ecx], esi
    mov     esi, [edx+4]
    mov     [ecx+4], esi
    mov     edx, [edx+8]
    mov     [ecx+8], edx
    mov     edx, [esp+10h+arg_4]
    lea     ecx, [edi+2Ch]
    mov     ebx, [edx]
    mov     esi, ecx
    mov     [esi], ebx
    mov     ebx, [edx+4]
    mov     [esi+4], ebx
    mov     edx, [edx+8]
    mov     [esi+8], edx
    mov     edx, [ecx]
    mov     esi, [eax]
    mov     ebx, [ecx+4]
    mov     ecx, [ecx+8]
    mov     ebp, [eax+4]
    sub     edx, esi
    mov     esi, [eax+8]
    sub     ecx, esi
    lea     esi, [edi+38h]
    mov     eax, esi
    sub     ebx, ebp
    mov     [eax], edx
    mov     [eax+4], ebx
    mov     [eax+8], ecx
    fild    dword ptr [esi]
    fild    dword ptr [esi+4]
    fild    dword ptr [esi+8]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    cdq
    fstp    st
    push    0
    push    20000h
    fstp    st
    push    edx
    push    eax
    fstp    st
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    cdq
    push    edx
    push    eax
    push    1
    push    0
    call    __alldiv
    cdq
    mov     ebx, eax
    mov     eax, [esi]
    mov     ebp, edx
    cdq
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esi], eax
    mov     eax, [esi+4]
    cdq
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esi+4], eax
    mov     eax, [esi+8]
    cdq
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ecx, [esp+10h+arg_10]
    mov     [esi+8], eax
    mov     edx, [edi]
    mov     [edi+44h], ecx
    mov     ecx, edi
    call    dword ptr [edx+10h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    sub_474760 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474880 proc near                    ; DATA XREF: .rdata:004FD608o

    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     eax, TAdynmemStructPtr
    sub     esp, 4Ch
    mov     edx, [eax+38A47h]
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    push    edi
    mov     esi, [ebx+4]
    sub     esi, edx
    inc     esi
    test    esi, esi
    jle     loc_47498E
    mov     eax, [ebx+10h]
    test    eax, eax
    jnz     short loc_4748AD
    xor     edx, edx
    jmp     short loc_4748C3
    ; ---------------------------------------------------------------------------

    loc_4748AD:                             ; CODE XREF: sub_474880+27j
    mov     ecx, [ebx+14h]
    sub     ecx, eax
    mov     eax, 78787879h
    imul    ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_4748C3:                             ; CODE XREF: sub_474880+2Bj
    mov     eax, [ebx+10h]
    add     esi, edx
    test    eax, eax
    mov     [esp+5Ch+var_4C], esi
    jnz     short loc_4748D4
    xor     edx, edx
    jmp     short loc_4748EA
    ; ---------------------------------------------------------------------------

    loc_4748D4:                             ; CODE XREF: sub_474880+4Ej
    mov     ecx, [ebx+18h]
    sub     ecx, eax
    mov     eax, 78787879h
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4748EA:                             ; CODE XREF: sub_474880+52j
    cmp     edx, esi
    jnb     loc_47498E
    test    esi, esi
    mov     eax, esi
    jge     short loc_4748FA
    xor     eax, eax

    loc_4748FA:                             ; CODE XREF: sub_474880+76j
    mov     ecx, eax
    shl     ecx, 4
    add     ecx, eax
    shl     ecx, 2
    push    ecx                             ; int
    call    sub_4B4F10
    mov     ebp, [ebx+14h]
    mov     edi, eax
    mov     eax, [ebx+10h]
    add     esp, 4
    cmp     eax, ebp
    mov     [esp+5Ch+var_48], edi
    mov     edx, edi
    jz      short loc_474940

    loc_47491F:                             ; CODE XREF: sub_474880+BAj
    test    edx, edx
    jz      short loc_474932
    mov     ecx, 11h
    mov     esi, eax
    mov     edi, edx
    rep movsd
    mov     esi, [esp+5Ch+var_4C]

    loc_474932:                             ; CODE XREF: sub_474880+A1j
    add     eax, 44h
    add     edx, 44h
    cmp     eax, ebp
    jnz     short loc_47491F
    mov     edi, [esp+5Ch+var_48]

    loc_474940:                             ; CODE XREF: sub_474880+9Dj
    mov     eax, [ebx+10h]
    push    eax
    mov     [esp+60h+var_48], eax
    call    sub_4B4F20
    mov     edx, esi
    add     esp, 4
    shl     edx, 4
    add     edx, esi
    lea     eax, [edi+edx*4]
    mov     [ebx+18h], eax
    mov     eax, [ebx+10h]
    test    eax, eax
    jnz     short loc_474968
    xor     edx, edx
    jmp     short loc_47497E
    ; ---------------------------------------------------------------------------

    loc_474968:                             ; CODE XREF: sub_474880+E2j
    mov     ecx, [ebx+14h]
    sub     ecx, eax
    mov     eax, 78787879h
    imul    ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_47497E:                             ; CODE XREF: sub_474880+E6j
    mov     eax, edx
    mov     [ebx+10h], edi
    shl     eax, 4
    add     eax, edx
    lea     ecx, [edi+eax*4]
    mov     [ebx+14h], ecx

    loc_47498E:                             ; CODE XREF: sub_474880+1Cj
                                            ; sub_474880+6Cj
    lea     esi, [ebx+20h]
    lea     edi, [ebx+2Ch]
    lea     ebp, [ebx+38h]
    mov     [esp+5Ch+var_4C], 1

    loc_47499F:                             ; CODE XREF: sub_474880+258j
    mov     eax, [ebx+1Ch]
    mov     [esp+5Ch+var_C], 0
    mov     [esp+5Ch+var_8], eax
    lea     edx, [eax+eax*2]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    mov     eax, esi
    lea     edx, [ecx+edx*2]
    mov     ecx, [eax]
    mov     [esp+5Ch+var_4], edx
    mov     [esp+5Ch+var_40], ecx
    mov     edx, [eax+4]
    mov     [esp+5Ch+var_3C], edx
    mov     eax, [eax+8]
    mov     [esp+5Ch+var_38], eax
    call    _rand
    cdq
    push    0
    push    7
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    sub     eax, 3
    add     word ptr [esp+5Ch+var_40+2], ax
    call    _rand
    cdq
    push    0
    push    7
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    sub     eax, 3
    add     word ptr [esp+5Ch+var_3C+2], ax
    call    _rand
    cdq
    push    0
    push    7
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, edi
    sub     eax, 3
    add     word ptr [esp+5Ch+var_38+2], ax
    mov     edx, [ecx]
    mov     [esp+5Ch+var_34], edx
    mov     edx, ebp
    mov     eax, [ecx+4]
    mov     [esp+5Ch+var_30], eax
    mov     eax, [edx]
    mov     ecx, [ecx+8]
    mov     [esp+5Ch+var_28], eax
    mov     eax, TAdynmemStructPtr
    mov     [esp+5Ch+var_2C], ecx
    mov     ecx, [edx+4]
    mov     [esp+5Ch+var_24], ecx
    mov     edx, [edx+8]
    mov     [esp+5Ch+var_20], edx
    mov     ecx, [eax+147CFh]
    mov     edx, [ebx+44h]
    mov     [esp+5Ch+var_44], ecx
    mov     eax, 61h
    mov     ecx, 67h
    test    edx, edx
    mov     [esp+5Ch+var_1C], eax
    mov     [esp+5Ch+var_18], ecx
    jz      short loc_474AB0
    mov     [esp+5Ch+var_14], eax
    mov     [esp+5Ch+var_10], 1
    jmp     short loc_474ABC
    ; ---------------------------------------------------------------------------

    loc_474AB0:                             ; CODE XREF: sub_474880+220j
    mov     [esp+5Ch+var_14], ecx
    mov     [esp+5Ch+var_10], 0FFFFFFFFh

    loc_474ABC:                             ; CODE XREF: sub_474880+22Ej
    mov     eax, [ebx+14h]
    lea     ecx, [ebx+0Ch]
    lea     edx, [esp+5Ch+var_44]
    push    edx
    push    1
    push    eax
    call    sub_475EF0
    mov     eax, [esp+5Ch+var_4C]
    dec     eax
    mov     [esp+5Ch+var_4C], eax
    jnz     loc_47499F
    mov     ecx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     edx, [ecx+38A47h]
    inc     edx
    mov     [ebx+8], edx
    pop     ebx
    add     esp, 4Ch
    retn
    sub_474880 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [eax+37ECCh]
    mov     edi, [esi+4]
    shl     ecx, 3
    add     edi, ecx
    mov     ecx, [esi+8]
    mov     [esi+4], edi
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14263h]
    shl     eax, 2
    add     ecx, eax
    mov     eax, [esi+1Ch]
    mov     [esi+8], ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37ED4h]
    mov     ecx, [esi+0Ch]
    shl     edx, 3
    add     ecx, edx

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474B48 proc near                    ; DATA XREF: .data:005110C4o
    dec     eax
    mov     [esi+0Ch], ecx
    mov     [esi+1Ch], eax
    jnz     short loc_474B7C
    mov     eax, [esi+14h]
    inc     eax
    mov     [esi+14h], eax
    mov     eax, [esi+18h]
    cdq
    sub     eax, edx
    mov     edi, eax
    sar     edi, 1
    call    _rand
    imul    edi
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, edi
    mov     [esi+1Ch], eax

    loc_474B7C:                             ; CODE XREF: sub_474B48+7j
    pop     edi
    pop     esi
    retn
    sub_474B48 endp ; sp =  8

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474B80 proc near

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     edx, [esp+arg_8]
    mov     eax, ecx
    push    ebx
    push    ebp
    mov     cx, [eax+0Ah]
    push    esi
    mov     si, [eax+0Eh]
    mov     bp, [eax+6]
    sar     cx, 1
    sub     si, cx
    mov     ecx, TAdynmemStructPtr
    sub     esi, edx
    sub     bp, word ptr [esp+0Ch+arg_4]
    xor     edx, edx
    push    edi
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    add     ebp, 80h
    mov     edi, edx
    add     esi, 20h
    shl     edx, 5
    add     edx, edi
    lea     ebx, [ecx+edi]
    mov     cl, [ecx+14281h]
    lea     edx, [edx+edx*4]
    and     cl, 2
    cmp     cl, 2
    lea     edx, [ebx+edx*2+TAdynmemStruct.Players]
    jnz     short loc_474C23
    movsx   ebx, word ptr [eax+0Ah]
    movsx   ecx, word ptr [eax+0Eh]
    movsx   edi, word ptr [eax+6]
    sar     ebx, 1
    sub     ecx, ebx
    mov     ebx, [edx+80h]
    sar     edi, 5
    sar     ecx, 5
    cmp     edi, ebx
    jnb     short loc_474C1F
    cmp     ecx, [edx+84h]
    jnb     short loc_474C1F
    mov     ebx, [edx+80h]
    mov     edx, [edx+7Ch]
    imul    ebx, ecx
    add     ebx, edi
    cmp     byte ptr [ebx+edx], 0
    jz      short loc_474C1F
    mov     edx, 1
    jmp     short loc_474C85
    ; ---------------------------------------------------------------------------

    loc_474C1F:                             ; CODE XREF: sub_474B80+7Aj
                                            ; sub_474B80+82j ...
    xor     edx, edx
    jmp     short loc_474C85
    ; ---------------------------------------------------------------------------

    loc_474C23:                             ; CODE XREF: sub_474B80+5Aj
    movsx   ecx, word ptr [eax+6]
    movsx   ebx, word ptr [eax+0Ah]
    sar     ecx, 5
    mov     [esp+10h+arg_4], ecx
    movsx   ecx, word ptr [eax+0Eh]
    sar     ebx, 1
    sub     ecx, ebx
    mov     ebx, [esp+10h+arg_4]
    sar     ecx, 5
    cmp     ebx, [edx+80h]
    jnb     short loc_474C51
    cmp     ecx, [edx+84h]
    jb      short loc_474C55

    loc_474C51:                             ; CODE XREF: sub_474B80+C7j
    xor     edx, edx
    jmp     short loc_474C85
    ; ---------------------------------------------------------------------------

    loc_474C55:                             ; CODE XREF: sub_474B80+CFj
    mov     edx, [edx+80h]
    imul    edx, ecx
    mov     ecx, TAdynmemStructPtr
    add     edx, ebx
    xor     ebx, ebx
    mov     ecx, [ecx+14273h]
    mov     bx, [ecx+edx*2]
    mov     ecx, edi
    mov     edx, ebx
    mov     ebx, 1
    shl     ebx, cl
    and     edx, ebx
    neg     edx
    sbb     edx, edx
    neg     edx

    loc_474C85:                             ; CODE XREF: sub_474B80+9Dj
                                            ; sub_474B80+A1j ...
    test    edx, edx
    jz      short loc_474CA8
    movsx   edx, si
    movsx   ecx, bp
    push    edx
    mov     edx, [eax+14h]
    mov     eax, [eax]
    push    ecx
    push    edx
    push    eax
    call    sub_4B7F30
    mov     ecx, [esp+18h+arg_0]
    push    eax
    push    ecx
    call    sub_4B8500

    loc_474CA8:                             ; CODE XREF: sub_474B80+107j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_474B80 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474CB0 proc near
    mov     eax, [ecx+14h]
    push    esi
    mov     esi, [ecx+10h]
    xor     edx, edx
    cmp     eax, esi
    pop     esi
    setnl   dl
    mov     eax, edx
    retn    4
    sub_474CB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474CD0 proc near                    ; CODE XREF: .text:00471856p
                                            ; sub_472630+3Ep ...

    var_1= byte ptr -1

    push    ecx
    push    esi
    mov     esi, ecx
    call    ??0DNameNode@@IAE@XZ            ; DNameNode::DNameNode(void)
    mov     al, [esp+8+var_1]
    mov     [esi+0Ch], al
    xor     eax, eax
    mov     [esi+10h], eax
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    mov     dword ptr [esi], offset off_4FD618
    mov     ecx, TAdynmemStructPtr
    mov     eax, esi
    mov     edx, [ecx+38A47h]
    mov     [esi+8], edx
    pop     esi
    pop     ecx
    retn
    sub_474CD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474D10 proc near                    ; DATA XREF: .rdata:004FD618o

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+10h]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     ecx, esi
    mov     [esi+10h], eax
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    call    unknown_libname_31
    test    [esp+8+arg_0], 1
    jz      short loc_474D43
    push    esi
    call    sub_471D50

    loc_474D43:                             ; CODE XREF: sub_474D10+2Bj
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_474D10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474D50 proc near                    ; DATA XREF: .rdata:004FD630o

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    mov     eax, [esp+arg_10]
    push    esi
    mov     esi, ecx
    push    eax
    call    sub_471D70
    mov     edx, [esp+4+arg_0]
    lea     ecx, [esi+2Ch]
    mov     eax, [edx]
    mov     [ecx], eax
    mov     eax, [edx+4]
    mov     [ecx+4], eax
    mov     eax, [esp+4+arg_8]
    mov     edx, [edx+8]
    mov     [esi+1Ch], eax
    mov     eax, [esp+4+arg_14]
    mov     [ecx+8], edx
    test    eax, eax
    mov     [esi+28h], eax
    jz      short loc_474D95
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+147D3h]
    push    edx
    jmp     short loc_474DA1
    ; ---------------------------------------------------------------------------

    loc_474D95:                             ; CODE XREF: sub_474D50+34j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+147CFh]
    push    ecx

    loc_474DA1:                             ; CODE XREF: sub_474D50+43j
    call    sub_4B7F60
    mov     ecx, [esp+4+arg_4]
    dec     eax
    test    ecx, ecx
    mov     [esi+24h], eax
    jz      short loc_474DBB
    cmp     ecx, eax
    jge     short loc_474DB8
    mov     eax, ecx

    loc_474DB8:                             ; CODE XREF: sub_474D50+64j
    mov     [esi+24h], eax

    loc_474DBB:                             ; CODE XREF: sub_474D50+60j
    mov     eax, [esp+4+arg_C]
    test    eax, eax
    jz      short loc_474DD1
    mov     edx, [esi]
    mov     ecx, esi
    mov     [esi+20h], eax
    call    dword ptr [edx+10h]
    pop     esi
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_474DD1:                             ; CODE XREF: sub_474D50+71j
    mov     edx, [esi]
    mov     ecx, esi
    mov     dword ptr [esi+20h], 7
    call    dword ptr [edx+10h]
    pop     esi
    retn    18h
    sub_474D50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474DF0 proc near                    ; DATA XREF: .rdata:004FD628o

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     edx, TAdynmemStructPtr
    sub     esp, 28h
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     eax, [ebx+4]
    mov     esi, [edx+38A47h]
    mov     ecx, [ebx+1Ch]
    sub     eax, esi
    add     eax, ecx
    push    edi
    cdq
    idiv    ecx
    test    eax, eax
    jle     loc_474EC8
    mov     edx, [ebx+10h]
    test    edx, edx
    jnz     short loc_474E25
    xor     ecx, ecx
    jmp     short loc_474E2D
    ; ---------------------------------------------------------------------------

    loc_474E25:                             ; CODE XREF: sub_474DF0+2Fj
    mov     ecx, [ebx+14h]
    sub     ecx, edx
    sar     ecx, 5

    loc_474E2D:                             ; CODE XREF: sub_474DF0+33j
    lea     esi, [eax+ecx]
    mov     ecx, [ebx+10h]
    test    ecx, ecx
    mov     [esp+38h+var_28], esi
    jnz     short loc_474E3F
    xor     eax, eax
    jmp     short loc_474E47
    ; ---------------------------------------------------------------------------

    loc_474E3F:                             ; CODE XREF: sub_474DF0+49j
    mov     eax, [ebx+18h]
    sub     eax, ecx
    sar     eax, 5

    loc_474E47:                             ; CODE XREF: sub_474DF0+4Dj
    cmp     eax, esi
    jnb     short loc_474EC8
    test    esi, esi
    mov     eax, esi
    jge     short loc_474E53
    xor     eax, eax

    loc_474E53:                             ; CODE XREF: sub_474DF0+5Fj
    shl     eax, 5
    push    eax                             ; int
    call    sub_4B4F10
    mov     ebp, [ebx+14h]
    mov     edi, eax
    mov     eax, [ebx+10h]
    add     esp, 4
    cmp     eax, ebp
    mov     [esp+38h+var_24], edi
    mov     edx, edi
    jz      short loc_474E92

    loc_474E71:                             ; CODE XREF: sub_474DF0+9Cj
    test    edx, edx
    jz      short loc_474E84
    mov     ecx, 8
    mov     esi, eax
    mov     edi, edx
    rep movsd
    mov     esi, [esp+38h+var_28]

    loc_474E84:                             ; CODE XREF: sub_474DF0+83j
    add     eax, 20h
    add     edx, 20h
    cmp     eax, ebp
    jnz     short loc_474E71
    mov     edi, [esp+38h+var_24]

    loc_474E92:                             ; CODE XREF: sub_474DF0+7Fj
    mov     eax, [ebx+10h]
    push    eax
    mov     [esp+3Ch+var_24], eax
    call    sub_4B4F20
    mov     ecx, [ebx+10h]
    add     esp, 4
    shl     esi, 5
    add     esi, edi
    test    ecx, ecx
    mov     [ebx+18h], esi
    jnz     short loc_474EB5
    xor     eax, eax
    jmp     short loc_474EBD
    ; ---------------------------------------------------------------------------

    loc_474EB5:                             ; CODE XREF: sub_474DF0+BFj
    mov     eax, [ebx+14h]
    sub     eax, ecx
    sar     eax, 5

    loc_474EBD:                             ; CODE XREF: sub_474DF0+C3j
    shl     eax, 5
    add     eax, edi
    mov     [ebx+10h], edi
    mov     [ebx+14h], eax

    loc_474EC8:                             ; CODE XREF: sub_474DF0+24j
                                            ; sub_474DF0+59j
    lea     ebp, [ebx+2Ch]
    lea     esi, [ebx+0Ch]
    mov     edi, 1

    loc_474ED3:                             ; CODE XREF: sub_474DF0+169j
    mov     eax, ebp
    mov     ecx, [eax]
    mov     [esp+38h+var_1C], ecx
    mov     edx, [eax+4]
    mov     [esp+38h+var_18], edx
    mov     eax, [eax+8]
    mov     [esp+38h+var_14], eax
    mov     eax, [ebx+20h]
    mov     [esp+38h+var_8], eax
    mov     [esp+38h+var_4], eax
    mov     eax, [ebx+28h]
    test    eax, eax
    jz      short loc_474F0D
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+147D3h]
    mov     [esp+38h+var_20], edx
    jmp     short loc_474F1C
    ; ---------------------------------------------------------------------------

    loc_474F0D:                             ; CODE XREF: sub_474DF0+109j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+147CFh]
    mov     [esp+38h+var_20], ecx

    loc_474F1C:                             ; CODE XREF: sub_474DF0+11Bj
    call    _rand
    mov     edx, [ebx+24h]
    push    0
    sub     edx, 2
    push    8000h
    imul    edx
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, [esi+8]
    add     eax, 2
    mov     [esp+38h+var_10], eax
    lea     eax, [esp+38h+var_20]
    push    eax
    push    1
    push    ecx
    mov     ecx, esi
    mov     [esp+44h+var_C], 0
    call    sub_476210
    dec     edi
    jnz     loc_474ED3
    mov     edx, TAdynmemStructPtr
    mov     ecx, [ebx+1Ch]
    pop     edi
    pop     esi
    mov     eax, [edx+38A47h]
    pop     ebp
    add     eax, ecx
    mov     [ebx+8], eax
    pop     ebx
    add     esp, 28h
    retn
    sub_474DF0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_474F80 proc near                    ; DATA XREF: .rdata:004FD624o
    mov     edx, [ecx+10h]
    test    edx, edx
    jnz     short loc_474F8B
    xor     eax, eax
    jmp     short loc_474F93
    ; ---------------------------------------------------------------------------

    loc_474F8B:                             ; CODE XREF: sub_474F80+5j
    mov     eax, [ecx+14h]
    sub     eax, edx
    sar     eax, 5

    loc_474F93:                             ; CODE XREF: sub_474F80+9j
    xor     edx, edx
    test    eax, eax
    setz    dl
    test    dl, dl
    jz      short loc_474FB5
    mov     eax, [ecx+4]
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+38A47h]
    jnb     short loc_474FB5

    unknown_libname_40:
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_474FB5:                             ; CODE XREF: sub_474F80+1Cj
                                            ; sub_474F80+2Dj
    xor     eax, eax
    retn
    sub_474F80 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [eax+37ECCh]
    mov     edi, [esi+4]
    shl     ecx, 3
    add     edi, ecx
    mov     ecx, [esi+8]
    mov     [esi+4], edi
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14263h]
    shl     eax, 4
    add     ecx, eax
    mov     eax, [esi+1Ch]
    mov     [esi+8], ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37ED4h]
    mov     ecx, [esi+0Ch]
    shl     edx, 3
    add     ecx, edx
    dec     eax
    mov     [esi+0Ch], ecx
    mov     [esi+1Ch], eax
    jnz     short loc_47503C
    mov     eax, [esi+14h]
    inc     eax
    mov     [esi+14h], eax
    mov     eax, [esi+18h]
    cdq
    sub     eax, edx
    mov     edi, eax
    sar     edi, 1
    call    _rand
    imul    edi
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, edi
    mov     [esi+1Ch], eax

    loc_47503C:                             ; CODE XREF: .text:0047500Fj
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     ax, [ecx+0Ah]
    mov     dx, [ecx+0Eh]
    sar     ax, 1
    sub     dx, ax
    mov     eax, [esp+0Ch]
    sub     edx, eax
    add     edx, 20h
    movsx   eax, dx
    mov     dx, [ecx+6]
    push    eax
    sub     dx, [esp+0Ch]
    add     edx, 80h
    movsx   eax, dx
    mov     edx, [ecx+14h]
    push    eax
    mov     eax, [ecx]
    push    edx
    push    eax
    call    sub_4B7F30
    mov     ecx, [esp+0Ch]
    push    eax
    push    ecx
    call    sub_4B8500
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx+14h]
    push    esi
    mov     esi, [ecx+10h]
    xor     edx, edx
    cmp     eax, esi
    pop     esi
    setnl   dl
    mov     eax, edx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4750B0 proc near                    ; CODE XREF: .text:00471A86p
                                            ; sub_472C50+3Ep

    var_1= byte ptr -1

    push    ecx
    push    esi
    mov     esi, ecx
    call    ??0DNameNode@@IAE@XZ            ; DNameNode::DNameNode(void)
    mov     al, [esp+8+var_1]
    mov     [esi+0Ch], al
    xor     eax, eax
    mov     [esi+10h], eax
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    mov     dword ptr [esi], offset off_4FD638
    mov     ecx, TAdynmemStructPtr
    mov     eax, esi
    mov     edx, [ecx+38A47h]
    mov     [esi+8], edx
    pop     esi
    pop     ecx
    retn
    sub_4750B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4750F0 proc near                    ; DATA XREF: .rdata:004FD64Co
    mov     eax, [ecx+8]
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+38A47h], eax
    sbb     eax, eax
    inc     eax
    retn
    sub_4750F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475110 proc near                    ; DATA XREF: .rdata:004FD638o

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    mov     eax, [esi+10h]
    push    eax
    mov     [esp+0Ch+var_4], eax
    call    sub_4B4F20
    xor     eax, eax
    add     esp, 4
    mov     ecx, esi
    mov     [esi+10h], eax
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    call    unknown_libname_31
    test    [esp+8+arg_0], 1
    jz      short loc_475143
    push    esi
    call    sub_471D50

    loc_475143:                             ; CODE XREF: sub_475110+2Bj
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_475110 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475150 proc near                    ; DATA XREF: .rdata:004FD650o

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_C]
    push    esi
    mov     esi, ecx
    push    eax
    call    sub_471D70
    mov     edx, [esp+4+arg_0]
    lea     ecx, [esi+28h]
    mov     eax, [edx]
    mov     [ecx], eax
    mov     eax, [edx+4]
    mov     [ecx+4], eax
    mov     eax, [esp+4+arg_4]
    mov     edx, [edx+8]
    mov     [esi+1Ch], eax
    mov     [ecx+8], edx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+147CFh]
    push    edx
    call    sub_4B7F60
    dec     eax
    mov     [esi+24h], eax
    mov     eax, [esp+4+arg_8]
    test    eax, eax
    jz      short loc_4751A7
    mov     [esi+20h], eax
    mov     eax, [esi]
    mov     ecx, esi
    call    dword ptr [eax+10h]
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4751A7:                             ; CODE XREF: sub_475150+47j
    mov     eax, [esi]
    mov     ecx, esi
    mov     dword ptr [esi+20h], 7
    call    dword ptr [eax+10h]
    pop     esi
    retn    10h
    sub_475150 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4751C0 proc near                    ; DATA XREF: .rdata:004FD648o

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     edx, TAdynmemStructPtr
    sub     esp, 28h
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     eax, [ebx+4]
    mov     esi, [edx+38A47h]
    mov     ecx, [ebx+1Ch]
    sub     eax, esi
    add     eax, ecx
    push    edi
    cdq
    idiv    ecx
    test    eax, eax
    jle     loc_475298
    mov     edx, [ebx+10h]
    test    edx, edx
    jnz     short loc_4751F5
    xor     ecx, ecx
    jmp     short loc_4751FD
    ; ---------------------------------------------------------------------------

    loc_4751F5:                             ; CODE XREF: sub_4751C0+2Fj
    mov     ecx, [ebx+14h]
    sub     ecx, edx
    sar     ecx, 5

    loc_4751FD:                             ; CODE XREF: sub_4751C0+33j
    lea     esi, [eax+ecx]
    mov     ecx, [ebx+10h]
    test    ecx, ecx
    mov     [esp+38h+var_28], esi
    jnz     short loc_47520F
    xor     eax, eax
    jmp     short loc_475217
    ; ---------------------------------------------------------------------------

    loc_47520F:                             ; CODE XREF: sub_4751C0+49j
    mov     eax, [ebx+18h]
    sub     eax, ecx
    sar     eax, 5

    loc_475217:                             ; CODE XREF: sub_4751C0+4Dj
    cmp     eax, esi
    jnb     short loc_475298
    test    esi, esi
    mov     eax, esi
    jge     short loc_475223
    xor     eax, eax

    loc_475223:                             ; CODE XREF: sub_4751C0+5Fj
    shl     eax, 5
    push    eax                             ; int
    call    sub_4B4F10
    mov     ebp, [ebx+14h]
    mov     edi, eax
    mov     eax, [ebx+10h]
    add     esp, 4
    cmp     eax, ebp
    mov     [esp+38h+var_24], edi
    mov     edx, edi
    jz      short loc_475262

    loc_475241:                             ; CODE XREF: sub_4751C0+9Cj
    test    edx, edx
    jz      short loc_475254
    mov     ecx, 8
    mov     esi, eax
    mov     edi, edx
    rep movsd
    mov     esi, [esp+38h+var_28]

    loc_475254:                             ; CODE XREF: sub_4751C0+83j
    add     eax, 20h
    add     edx, 20h
    cmp     eax, ebp
    jnz     short loc_475241
    mov     edi, [esp+38h+var_24]

    loc_475262:                             ; CODE XREF: sub_4751C0+7Fj
    mov     eax, [ebx+10h]
    push    eax
    mov     [esp+3Ch+var_24], eax
    call    sub_4B4F20
    mov     ecx, [ebx+10h]
    add     esp, 4
    shl     esi, 5
    add     esi, edi
    test    ecx, ecx
    mov     [ebx+18h], esi
    jnz     short loc_475285
    xor     eax, eax
    jmp     short loc_47528D
    ; ---------------------------------------------------------------------------

    loc_475285:                             ; CODE XREF: sub_4751C0+BFj
    mov     eax, [ebx+14h]
    sub     eax, ecx
    sar     eax, 5

    loc_47528D:                             ; CODE XREF: sub_4751C0+C3j
    shl     eax, 5
    add     eax, edi
    mov     [ebx+10h], edi
    mov     [ebx+14h], eax

    loc_475298:                             ; CODE XREF: sub_4751C0+24j
                                            ; sub_4751C0+59j
    lea     ebp, [ebx+28h]
    lea     esi, [ebx+0Ch]
    mov     edi, 1

    loc_4752A3:                             ; CODE XREF: sub_4751C0+151j
    mov     eax, ebp
    mov     ecx, [eax]
    mov     [esp+38h+var_1C], ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [eax+4]
    mov     [esp+38h+var_18], edx
    mov     eax, [eax+8]
    mov     [esp+38h+var_14], eax
    mov     eax, [ebx+20h]
    mov     [esp+38h+var_8], eax
    mov     [esp+38h+var_4], eax
    mov     edx, [ecx+147CFh]
    mov     [esp+38h+var_20], edx
    call    _rand
    mov     ecx, [ebx+24h]
    push    0
    sub     ecx, 2
    push    8000h
    imul    ecx
    push    edx
    push    eax
    call    __alldiv
    add     eax, 2
    lea     edx, [esp+38h+var_20]
    mov     [esp+38h+var_10], eax
    mov     eax, [esi+8]
    push    edx
    push    1
    push    eax
    mov     ecx, esi
    mov     [esp+44h+var_C], 0
    call    sub_476490
    dec     edi
    jnz     short loc_4752A3
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ebx+1Ch]
    pop     edi
    pop     esi
    mov     edx, [ecx+38A47h]
    pop     ebp
    add     edx, eax
    mov     [ebx+8], edx
    pop     ebx
    add     esp, 28h
    retn
    sub_4751C0 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_41. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475340 proc near                    ; DATA XREF: .rdata:004FD61Co

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     [esp+18h+var_8], edi
    mov     ebx, [edi+10h]
    mov     eax, [edi+14h]
    cmp     ebx, eax
    jz      loc_47541E

    loc_47535B:                             ; CODE XREF: sub_475340+D8j
    mov     eax, TAdynmemStructPtr
    mov     edx, [ebx+4]
    mov     ebp, [ebx+8]
    mov     ecx, [eax+37ECCh]
    shl     ecx, 3
    add     edx, ecx
    mov     [ebx+4], edx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14263h]
    shl     eax, 2
    add     ebp, eax
    mov     eax, [ebx+1Ch]
    mov     [ebx+8], ebp
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37ED4h]
    mov     ecx, [ebx+0Ch]
    shl     edx, 3
    add     ecx, edx
    dec     eax
    mov     [ebx+0Ch], ecx
    mov     [ebx+1Ch], eax
    jnz     short loc_4753D3
    mov     edx, [ebx+14h]
    mov     eax, [ebx+18h]
    inc     edx
    mov     [ebx+14h], edx
    cdq
    sub     eax, edx
    mov     esi, eax
    sar     esi, 1
    call    _rand
    imul    esi
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, esi
    mov     [ebx+1Ch], eax

    loc_4753D3:                             ; CODE XREF: sub_475340+66j
    mov     eax, [ebx+14h]
    mov     ecx, [ebx+10h]
    cmp     eax, ecx
    jl      short loc_475412
    mov     ebp, [edi+14h]
    lea     eax, [ebx+20h]
    cmp     eax, ebp
    jz      short loc_475403
    lea     edx, [eax-20h]

    loc_4753EA:                             ; CODE XREF: sub_475340+BDj
    mov     esi, eax
    mov     edi, edx
    add     eax, 20h
    mov     ecx, 8
    add     edx, 20h
    cmp     eax, ebp
    rep movsd
    jnz     short loc_4753EA
    mov     edi, [esp+18h+var_8]

    loc_475403:                             ; CODE XREF: sub_475340+A5j
    mov     eax, [edi+14h]
    add     eax, 0FFFFFFE0h
    mov     [esp+18h+var_4], eax
    mov     [edi+14h], eax
    jmp     short loc_475415
    ; ---------------------------------------------------------------------------

    loc_475412:                             ; CODE XREF: sub_475340+9Bj
    add     ebx, 20h

    loc_475415:                             ; CODE XREF: sub_475340+D0j
    cmp     ebx, [edi+14h]
    jnz     loc_47535B

    loc_47541E:                             ; CODE XREF: sub_475340+15j
    mov     edx, [edi]
    mov     ecx, edi
    call    dword ptr [edx+14h]
    test    eax, eax
    jz      short loc_475430
    mov     eax, [edi]
    mov     ecx, edi
    call    dword ptr [eax+10h]

    loc_475430:                             ; CODE XREF: sub_475340+E7j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    sub_475340 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475440 proc near                    ; DATA XREF: .rdata:004FD62Co
    mov     eax, [ecx+8]
    mov     edx, [ecx+4]
    cmp     eax, edx
    jg      short unknown_libname_43
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+38A47h]
    ja      short unknown_libname_43

    unknown_libname_42:
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_43:                     ; CODE XREF: sub_475440+8j
                                            ; sub_475440+16j
    xor     eax, eax
    retn
    sub_475440 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475470 proc near                    ; DATA XREF: .rdata:004FD620o

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 18h
    mov     eax, [ecx+10h]
    mov     edx, [ecx+14h]
    cmp     eax, edx
    mov     [esp+18h+var_4], ecx
    mov     [esp+18h+var_14], eax
    jz      loc_4755F8
    push    edi
    push    esi
    mov     esi, TAdynmemStructPtr
    add     eax, 0Eh
    push    ebp
    push    ebx
    mov     [esp+28h+var_18], eax
    jmp     short loc_4754A0
    ; ---------------------------------------------------------------------------

    loc_47549C:                             ; CODE XREF: sub_475470+17Ej
    mov     eax, [esp+28h+var_18]

    loc_4754A0:                             ; CODE XREF: sub_475470+2Aj
    mov     bx, [eax-8]
    mov     cx, [eax-4]
    mov     ax, [eax]
    mov     [esp+28h+var_10], ecx
    mov     dx, ax
    mov     [esp+28h+var_C], eax
    sub     dx, word ptr [esi+TAdynmemStruct.MapY]
    mov     di, bx
    sar     cx, 1
    sub     edx, ecx
    xor     ecx, ecx
    mov     cl, [esi+TAdynmemStruct.LOS_Sight]
    sub     di, word ptr [esi+TAdynmemStruct.MapX]
    mov     eax, ecx
    add     edx, 20h
    shl     eax, 5
    add     eax, ecx
    lea     ebp, [esi+ecx]
    add     edi, 80h
    lea     eax, [eax+eax*4]
    lea     ebp, [ebp+eax*2+1B63h]
    mov     al, [esi+14281h]
    and     al, 2
    cmp     al, 2
    jnz     short loc_475545
    movsx   eax, word ptr [esp+28h+var_C]
    movsx   ecx, bx
    movsx   ebx, word ptr [esp+28h+var_10]
    sar     ebx, 1
    sub     eax, ebx
    mov     ebx, [ebp+80h]
    sar     ecx, 5
    sar     eax, 5
    cmp     ecx, ebx
    jnb     short loc_475541
    cmp     eax, [ebp+84h]
    jnb     short loc_475541
    mov     ebx, [ebp+80h]
    imul    ebx, eax
    add     ebx, ecx
    mov     ecx, [ebp+7Ch]
    cmp     byte ptr [ebx+ecx], 0
    jz      short loc_475541
    mov     eax, 1
    jmp     short loc_4755A0
    ; ---------------------------------------------------------------------------

    loc_475541:                             ; CODE XREF: sub_475470+ACj
                                            ; sub_475470+B4j ...
    xor     eax, eax
    jmp     short loc_4755A0
    ; ---------------------------------------------------------------------------

    loc_475545:                             ; CODE XREF: sub_475470+8Bj
    movsx   eax, bx
    movsx   ebx, word ptr [esp+28h+var_10]
    sar     eax, 5
    mov     [esp+28h+var_8], eax
    movsx   eax, word ptr [esp+28h+var_C]
    sar     ebx, 1
    sub     eax, ebx
    mov     ebx, [esp+28h+var_8]
    sar     eax, 5
    cmp     ebx, [ebp+80h]
    jnb     short loc_475574
    cmp     eax, [ebp+84h]
    jb      short loc_475578

    loc_475574:                             ; CODE XREF: sub_475470+FAj
    xor     eax, eax
    jmp     short loc_4755A0
    ; ---------------------------------------------------------------------------

    loc_475578:                             ; CODE XREF: sub_475470+102j
    mov     ebp, [ebp+80h]
    imul    ebp, eax
    mov     eax, [esi+14273h]
    add     ebp, ebx
    xor     ebx, ebx
    mov     bx, [eax+ebp*2]
    mov     eax, ebx
    mov     ebx, 1
    shl     ebx, cl
    and     eax, ebx
    neg     eax
    sbb     eax, eax
    neg     eax

    loc_4755A0:                             ; CODE XREF: sub_475470+CFj
                                            ; sub_475470+D3j ...
    test    eax, eax
    jz      short loc_4755D1
    mov     eax, [esp+28h+var_18]
    movsx   ecx, dx
    movsx   edx, di
    push    ecx
    mov     ecx, [eax+6]
    push    edx
    mov     edx, [esp+30h+var_14]
    push    ecx
    mov     eax, [edx]
    push    eax
    call    sub_4B7F30
    mov     ecx, [esp+30h+arg_0]
    push    eax
    push    ecx
    call    sub_4B8500
    mov     esi, TAdynmemStructPtr

    loc_4755D1:                             ; CODE XREF: sub_475470+132j
    mov     edx, [esp+28h+var_18]
    mov     eax, [esp+28h+var_14]
    add     edx, 20h
    add     eax, 20h
    mov     [esp+28h+var_18], edx
    mov     edx, [esp+28h+var_4]
    mov     [esp+28h+var_14], eax
    cmp     eax, [edx+14h]
    jnz     loc_47549C
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_4755F8:                             ; CODE XREF: sub_475470+13j
    add     esp, 18h
    retn    4
    sub_475470 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475600 proc near                    ; DATA XREF: .rdata:004FD63Co

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     [esp+18h+var_8], edi
    mov     ebx, [edi+10h]
    mov     eax, [edi+14h]
    cmp     ebx, eax
    jz      loc_4756DE

    loc_47561B:                             ; CODE XREF: sub_475600+D8j
    mov     eax, TAdynmemStructPtr
    mov     edx, [ebx+4]
    mov     ebp, [ebx+8]
    mov     ecx, [eax+37ECCh]
    shl     ecx, 3
    add     edx, ecx
    mov     [ebx+4], edx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14263h]
    shl     eax, 4
    add     ebp, eax
    mov     eax, [ebx+1Ch]
    mov     [ebx+8], ebp
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37ED4h]
    mov     ecx, [ebx+0Ch]
    shl     edx, 3
    add     ecx, edx
    dec     eax
    mov     [ebx+0Ch], ecx
    mov     [ebx+1Ch], eax
    jnz     short loc_475693
    mov     edx, [ebx+14h]
    mov     eax, [ebx+18h]
    inc     edx
    mov     [ebx+14h], edx
    cdq
    sub     eax, edx
    mov     esi, eax
    sar     esi, 1
    call    _rand
    imul    esi
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, esi
    mov     [ebx+1Ch], eax

    loc_475693:                             ; CODE XREF: sub_475600+66j
    mov     eax, [ebx+14h]
    mov     ecx, [ebx+10h]
    cmp     eax, ecx
    jl      short loc_4756D2
    mov     ebp, [edi+14h]
    lea     eax, [ebx+20h]
    cmp     eax, ebp
    jz      short loc_4756C3
    lea     edx, [eax-20h]

    loc_4756AA:                             ; CODE XREF: sub_475600+BDj
    mov     esi, eax
    mov     edi, edx
    add     eax, 20h
    mov     ecx, 8
    add     edx, 20h
    cmp     eax, ebp
    rep movsd
    jnz     short loc_4756AA
    mov     edi, [esp+18h+var_8]

    loc_4756C3:                             ; CODE XREF: sub_475600+A5j
    mov     eax, [edi+14h]
    add     eax, 0FFFFFFE0h
    mov     [esp+18h+var_4], eax
    mov     [edi+14h], eax
    jmp     short loc_4756D5
    ; ---------------------------------------------------------------------------

    loc_4756D2:                             ; CODE XREF: sub_475600+9Bj
    add     ebx, 20h

    loc_4756D5:                             ; CODE XREF: sub_475600+D0j
    cmp     ebx, [edi+14h]
    jnz     loc_47561B

    loc_4756DE:                             ; CODE XREF: sub_475600+15j
    mov     edx, [edi]
    mov     ecx, edi
    call    dword ptr [edx+14h]
    test    eax, eax
    jz      short loc_4756F0
    mov     eax, [edi]
    mov     ecx, edi
    call    dword ptr [eax+10h]

    loc_4756F0:                             ; CODE XREF: sub_475600+E7j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    sub_475600 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475700 proc near                    ; DATA XREF: .rdata:004FD640o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, ecx
    mov     esi, [edi+10h]
    mov     eax, [edi+14h]
    cmp     esi, eax
    jz      short loc_475767
    push    ebx
    mov     ebx, [esp+4+arg_0]

    loc_475713:                             ; CODE XREF: sub_475700+64j
    mov     ax, [esi+0Ah]
    mov     cx, [esi+0Eh]
    sar     ax, 1
    sub     cx, ax
    mov     eax, TAdynmemStructPtr
    sub     cx, [eax+14323h]
    add     ecx, 20h
    movsx   edx, cx
    mov     cx, [esi+6]
    push    edx
    sub     cx, [eax+1431Fh]
    mov     eax, [esi+14h]
    add     ecx, 80h
    movsx   edx, cx
    mov     ecx, [esi]
    push    edx
    push    eax
    push    ecx
    call    sub_4B7F30
    push    eax
    push    ebx
    call    sub_4B8500
    mov     eax, [edi+14h]
    add     esi, 20h
    cmp     esi, eax
    jnz     short loc_475713
    pop     ebx

    loc_475767:                             ; CODE XREF: sub_475700+Cj
    pop     edi
    pop     esi
    retn    4
    sub_475700 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475770 proc near                    ; CODE XREF: sub_473D50+48p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     eax, [ebx+4]
    push    edi
    test    eax, eax
    jnz     short loc_475782
    xor     edx, edx
    jmp     short loc_475798
    ; ---------------------------------------------------------------------------

    loc_475782:                             ; CODE XREF: sub_475770+Cj
    mov     ecx, [ebx+0Ch]
    sub     ecx, eax
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_475798:                             ; CODE XREF: sub_475770+10j
    mov     edi, [esp+14h+arg_0]
    cmp     edx, edi
    jnb     loc_475838
    test    edi, edi
    mov     eax, edi
    jge     short loc_4757AC
    xor     eax, eax

    loc_4757AC:                             ; CODE XREF: sub_475770+38j
    lea     ecx, [eax+eax*2]
    shl     ecx, 4
    push    ecx                             ; int
    call    sub_4B4F10
    mov     ebp, [ebx+8]
    mov     esi, eax
    mov     eax, [ebx+4]
    add     esp, 4
    cmp     eax, ebp
    mov     [esp+14h+var_4], esi
    mov     edx, esi
    jz      short loc_4757EE

    loc_4757CD:                             ; CODE XREF: sub_475770+74j
    test    edx, edx
    jz      short loc_4757DC
    mov     ecx, 0Ch
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_4757DC:                             ; CODE XREF: sub_475770+5Fj
    add     eax, 30h
    add     edx, 30h
    cmp     eax, ebp
    jnz     short loc_4757CD
    mov     esi, [esp+14h+var_4]
    mov     edi, [esp+14h+arg_0]

    loc_4757EE:                             ; CODE XREF: sub_475770+5Bj
    mov     eax, [ebx+4]
    push    eax
    mov     [esp+18h+arg_0], eax
    call    sub_4B4F20
    mov     eax, [ebx+4]
    lea     edx, [edi+edi*2]
    shl     edx, 4
    add     esp, 4
    add     edx, esi
    test    eax, eax
    mov     [ebx+0Ch], edx
    jnz     short loc_475814
    xor     edx, edx
    jmp     short loc_47582A
    ; ---------------------------------------------------------------------------

    loc_475814:                             ; CODE XREF: sub_475770+9Ej
    mov     ecx, [ebx+8]
    sub     ecx, eax
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_47582A:                             ; CODE XREF: sub_475770+A2j
    lea     ecx, [edx+edx*2]
    mov     [ebx+4], esi
    shl     ecx, 4
    add     ecx, esi
    mov     [ebx+8], ecx

    loc_475838:                             ; CODE XREF: sub_475770+2Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_475770 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475840 proc near                    ; CODE XREF: sub_473D50+234p
                                            ; sub_473D50+244p ...
    mov     eax, [ecx+4]
    test    eax, eax
    jnz     short loc_475848
    retn
    ; ---------------------------------------------------------------------------

    loc_475848:                             ; CODE XREF: sub_475840+5j
    mov     ecx, [ecx+8]
    sub     ecx, eax
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, edx
    retn
    sub_475840 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_51. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475880 proc near                    ; CODE XREF: sub_473D50+26Cp
                                            ; sub_473D50+293p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     edx, [esp+arg_0]
    push    ebx
    mov     ebx, [esp+4+arg_4]
    cmp     edx, ebx
    jz      short loc_4758B2
    mov     eax, [esp+4+arg_8]
    push    edi
    push    esi

    loc_475893:                             ; CODE XREF: sub_475880+2Aj
    test    eax, eax
    jz      short loc_4758A2
    mov     ecx, 0Ch
    mov     esi, edx
    mov     edi, eax
    rep movsd

    loc_4758A2:                             ; CODE XREF: sub_475880+15j
    add     edx, 30h
    add     eax, 30h
    cmp     edx, ebx
    jnz     short loc_475893
    pop     esi
    pop     edi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4758B2:                             ; CODE XREF: sub_475880+Bj
    mov     eax, [esp+4+arg_8]
    pop     ebx
    retn    0Ch
    sub_475880 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4758C0 proc near                    ; CODE XREF: sub_4737C0+1C7p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     eax, 4EC4EC4Fh
    mov     ebp, [esp+18h+arg_4]
    mov     [esp+18h+var_8], edi
    mov     ebx, [edi+8]
    mov     ecx, [edi+0Ch]
    sub     ecx, ebx
    imul    ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ebp
    jnb     loc_475A70
    mov     esi, [edi+4]
    test    esi, esi
    jnz     short loc_4758FD
    xor     edx, edx
    jmp     short loc_475912
    ; ---------------------------------------------------------------------------

    loc_4758FD:                             ; CODE XREF: sub_4758C0+37j
    mov     ecx, ebx
    mov     eax, 4EC4EC4Fh
    sub     ecx, esi
    imul    ecx
    sar     edx, 4
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_475912:                             ; CODE XREF: sub_4758C0+3Bj
    cmp     ebp, edx
    jnb     short loc_475937
    test    esi, esi
    jnz     short loc_47591E
    xor     ecx, ecx
    jmp     short loc_475939
    ; ---------------------------------------------------------------------------

    loc_47591E:                             ; CODE XREF: sub_4758C0+58j
    mov     ecx, ebx
    mov     eax, 4EC4EC4Fh
    sub     ecx, esi
    imul    ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ecx, edx
    jmp     short loc_475939
    ; ---------------------------------------------------------------------------

    loc_475937:                             ; CODE XREF: sub_4758C0+54j
    mov     ecx, ebp

    loc_475939:                             ; CODE XREF: sub_4758C0+5Cj
                                            ; sub_4758C0+75j
    test    esi, esi
    jnz     short loc_475941
    xor     edx, edx
    jmp     short loc_475954
    ; ---------------------------------------------------------------------------

    loc_475941:                             ; CODE XREF: sub_4758C0+7Bj
    sub     ebx, esi
    mov     eax, 4EC4EC4Fh
    imul    ebx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_475954:                             ; CODE XREF: sub_4758C0+7Fj
    lea     eax, [edx+ecx]
    test    eax, eax
    mov     [esp+18h+arg_4], eax
    jge     short loc_475961
    xor     eax, eax

    loc_475961:                             ; CODE XREF: sub_4758C0+9Dj
    lea     ecx, [eax+eax*2]
    lea     edx, [eax+ecx*4]
    shl     edx, 2
    push    edx                             ; int
    call    sub_4B4F10
    mov     edx, [esp+1Ch+arg_0]
    mov     [esp+1Ch+var_4], eax
    mov     ebx, eax
    mov     eax, [edi+4]
    add     esp, 4
    cmp     eax, edx
    jz      short loc_4759A1

    loc_475984:                             ; CODE XREF: sub_4758C0+DBj
    test    ebx, ebx
    jz      short loc_475993
    mov     ecx, 0Dh
    mov     esi, eax
    mov     edi, ebx
    rep movsd

    loc_475993:                             ; CODE XREF: sub_4758C0+C6j
    add     eax, 34h
    add     ebx, 34h
    cmp     eax, edx
    jnz     short loc_475984
    mov     edi, [esp+18h+var_8]

    loc_4759A1:                             ; CODE XREF: sub_4758C0+C2j
    test    ebp, ebp
    mov     eax, ebx
    jbe     short loc_4759CE
    mov     [esp+18h+arg_0], ebp

    loc_4759AB:                             ; CODE XREF: sub_4758C0+108j
    test    eax, eax
    jz      short loc_4759BC
    mov     esi, [esp+18h+arg_8]
    mov     ecx, 0Dh
    mov     edi, eax
    rep movsd

    loc_4759BC:                             ; CODE XREF: sub_4758C0+EDj
    mov     ecx, [esp+18h+arg_0]
    add     eax, 34h
    dec     ecx
    mov     [esp+18h+arg_0], ecx
    jnz     short loc_4759AB
    mov     edi, [esp+18h+var_8]

    loc_4759CE:                             ; CODE XREF: sub_4758C0+E5j
    mov     esi, [edi+8]
    lea     eax, [ebp+ebp*2+0]
    mov     [esp+18h+arg_0], esi
    lea     ecx, [ebp+eax*4+0]
    shl     ecx, 2
    cmp     edx, esi
    lea     eax, [ebx+ecx]
    jz      short loc_475A0E
    sub     edx, ebx
    add     edx, eax
    sub     edx, ecx

    loc_4759ED:                             ; CODE XREF: sub_4758C0+148j
    test    eax, eax
    jz      short loc_475A00
    mov     ecx, 0Dh
    mov     esi, edx
    mov     edi, eax
    rep movsd
    mov     esi, [esp+18h+arg_0]

    loc_475A00:                             ; CODE XREF: sub_4758C0+12Fj
    add     edx, 34h
    add     eax, 34h
    cmp     edx, esi
    jnz     short loc_4759ED
    mov     edi, [esp+18h+var_8]

    loc_475A0E:                             ; CODE XREF: sub_4758C0+125j
    mov     eax, [edi+4]
    push    eax
    mov     [esp+1Ch+arg_0], eax
    call    sub_4B4F20
    mov     eax, [esp+1Ch+arg_4]
    mov     esi, [esp+1Ch+var_4]
    add     esp, 4
    lea     ecx, [eax+eax*2]
    lea     edx, [eax+ecx*4]
    lea     eax, [esi+edx*4]
    mov     [edi+0Ch], eax
    mov     eax, [edi+4]
    test    eax, eax
    jnz     short loc_475A3D
    xor     edx, edx
    jmp     short loc_475A53
    ; ---------------------------------------------------------------------------

    loc_475A3D:                             ; CODE XREF: sub_4758C0+177j
    mov     ecx, [edi+8]
    sub     ecx, eax
    mov     eax, 4EC4EC4Fh
    imul    ecx
    sar     edx, 4
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_475A53:                             ; CODE XREF: sub_4758C0+17Bj
    add     ebp, edx
    mov     [edi+4], esi
    lea     edx, [ebp+ebp*2+0]
    lea     eax, [ebp+edx*4+0]
    lea     ecx, [esi+eax*4]
    mov     [edi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_475A70:                             ; CODE XREF: sub_4758C0+2Cj
    mov     esi, [esp+18h+arg_0]
    mov     ecx, ebx
    sub     ecx, esi
    mov     eax, 4EC4EC4Fh
    imul    ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ebp
    jnb     loc_475B39
    lea     ecx, [ebp+ebp*2+0]
    lea     ecx, [ebp+ecx*4+0]
    shl     ecx, 2
    cmp     esi, ebx
    mov     [esp+18h+arg_4], ecx
    lea     edx, [esi+ecx]
    jz      short loc_475AC8
    mov     eax, edx
    sub     eax, ecx

    loc_475AAB:                             ; CODE XREF: sub_4758C0+202j
    test    edx, edx
    jz      short loc_475ABA
    mov     ecx, 0Dh
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_475ABA:                             ; CODE XREF: sub_4758C0+1EDj
    add     eax, 34h
    add     edx, 34h
    cmp     eax, ebx
    jnz     short loc_475AAB
    mov     edi, [esp+18h+var_8]

    loc_475AC8:                             ; CODE XREF: sub_4758C0+1E5j
    mov     esi, [edi+8]
    mov     edx, [esp+18h+arg_0]
    mov     ecx, esi
    mov     eax, 4EC4EC4Fh
    sub     ecx, edx
    mov     ebx, [esp+18h+arg_8]
    imul    ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, esi
    sub     ebp, edx
    jz      short loc_475B07

    loc_475AEE:                             ; CODE XREF: sub_4758C0+241j
    test    eax, eax
    jz      short loc_475AFD
    mov     ecx, 0Dh
    mov     esi, ebx
    mov     edi, eax
    rep movsd

    loc_475AFD:                             ; CODE XREF: sub_4758C0+230j
    add     eax, 34h
    dec     ebp
    jnz     short loc_475AEE
    mov     edi, [esp+18h+var_8]

    loc_475B07:                             ; CODE XREF: sub_4758C0+22Cj
    mov     edx, [edi+8]
    mov     eax, [esp+18h+arg_0]
    cmp     eax, edx
    jz      short loc_475B24

    loc_475B12:                             ; CODE XREF: sub_4758C0+262j
    mov     edi, eax
    add     eax, 34h
    mov     ecx, 0Dh
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_475B12

    loc_475B24:                             ; CODE XREF: sub_4758C0+250j
    mov     eax, [esp+18h+var_8]
    mov     ecx, [esp+18h+arg_4]
    add     [eax+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_475B39:                             ; CODE XREF: sub_4758C0+1CBj
    test    ebp, ebp
    jbe     loc_475BC1
    lea     eax, [ebp+ebp*2+0]
    mov     edx, ebx
    lea     ebp, [ebp+eax*4+0]
    mov     eax, ebx
    shl     ebp, 2
    sub     eax, ebp
    cmp     eax, ebx
    jz      short loc_475B77

    loc_475B56:                             ; CODE XREF: sub_4758C0+2ADj
    test    edx, edx
    jz      short loc_475B65
    mov     ecx, 0Dh
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_475B65:                             ; CODE XREF: sub_4758C0+298j
    add     eax, 34h
    add     edx, 34h
    cmp     eax, ebx
    jnz     short loc_475B56
    mov     edi, [esp+18h+var_8]
    mov     esi, [esp+18h+arg_0]

    loc_475B77:                             ; CODE XREF: sub_4758C0+294j
    mov     edx, [edi+8]
    mov     eax, edx
    sub     eax, ebp
    cmp     esi, eax
    jz      short loc_475B99

    loc_475B82:                             ; CODE XREF: sub_4758C0+2D7j
    sub     eax, 34h
    sub     edx, 34h
    mov     ecx, 0Dh
    mov     esi, eax
    mov     edi, edx
    rep movsd
    cmp     eax, [esp+18h+arg_0]
    jnz     short loc_475B82

    loc_475B99:                             ; CODE XREF: sub_4758C0+2C0j
    mov     eax, [esp+18h+arg_0]
    lea     edx, [eax+ebp]
    cmp     eax, edx
    jz      short loc_475BBA
    mov     ebx, [esp+18h+arg_8]

    loc_475BA8:                             ; CODE XREF: sub_4758C0+2F8j
    mov     edi, eax
    add     eax, 34h
    mov     ecx, 0Dh
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_475BA8

    loc_475BBA:                             ; CODE XREF: sub_4758C0+2E2j
    mov     eax, [esp+18h+var_8]
    add     [eax+8], ebp

    loc_475BC1:                             ; CODE XREF: sub_4758C0+27Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_4758C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475BD0 proc near                    ; CODE XREF: sub_4743A0+1B6p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    mov     eax, 88888889h
    push    esi
    push    edi
    mov     ebx, [ebp+8]
    mov     ecx, [ebp+0Ch]
    sub     ecx, ebx
    mov     edi, [esp+1Ch+arg_4]
    imul    ecx
    add     edx, ecx
    mov     [esp+1Ch+var_C], ebp
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, edi
    jnb     loc_475D8C
    mov     esi, [ebp+4]
    test    esi, esi
    jnz     short loc_475C0F
    xor     edx, edx
    jmp     short loc_475C26
    ; ---------------------------------------------------------------------------

    loc_475C0F:                             ; CODE XREF: sub_475BD0+39j
    mov     ecx, ebx
    mov     eax, 88888889h
    sub     ecx, esi
    imul    ecx
    add     edx, ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_475C26:                             ; CODE XREF: sub_475BD0+3Dj
    cmp     edi, edx
    jnb     short loc_475C4D
    test    esi, esi
    jnz     short loc_475C32
    xor     ecx, ecx
    jmp     short loc_475C4F
    ; ---------------------------------------------------------------------------

    loc_475C32:                             ; CODE XREF: sub_475BD0+5Cj
    mov     ecx, ebx
    mov     eax, 88888889h
    sub     ecx, esi
    imul    ecx
    add     edx, ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ecx, edx
    jmp     short loc_475C4F
    ; ---------------------------------------------------------------------------

    loc_475C4D:                             ; CODE XREF: sub_475BD0+58j
    mov     ecx, edi

    loc_475C4F:                             ; CODE XREF: sub_475BD0+60j
                                            ; sub_475BD0+7Bj
    test    esi, esi
    jnz     short loc_475C57
    xor     edx, edx
    jmp     short loc_475C6C
    ; ---------------------------------------------------------------------------

    loc_475C57:                             ; CODE XREF: sub_475BD0+81j
    sub     ebx, esi
    mov     eax, 88888889h
    imul    ebx
    add     edx, ebx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_475C6C:                             ; CODE XREF: sub_475BD0+85j
    lea     eax, [edx+ecx]
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_475C79
    xor     eax, eax

    loc_475C79:                             ; CODE XREF: sub_475BD0+A5j
    lea     eax, [eax+eax*2]
    lea     ecx, [eax+eax*4]
    shl     ecx, 2
    push    ecx                             ; int
    call    sub_4B4F10
    mov     esi, [esp+20h+arg_0]
    mov     [esp+20h+var_4], eax
    mov     ebx, eax
    mov     eax, [ebp+4]
    add     esp, 4
    cmp     eax, esi
    jz      short loc_475CC1

    loc_475C9C:                             ; CODE XREF: sub_475BD0+E7j
    test    ebx, ebx
    jz      short loc_475CAB
    mov     ecx, 0Fh
    mov     esi, eax
    mov     edi, ebx
    rep movsd

    loc_475CAB:                             ; CODE XREF: sub_475BD0+CEj
    mov     esi, [esp+1Ch+arg_0]
    add     eax, 3Ch
    add     ebx, 3Ch
    cmp     eax, esi
    jnz     short loc_475C9C
    mov     edi, [esp+1Ch+arg_4]
    mov     ebp, [esp+1Ch+var_C]

    loc_475CC1:                             ; CODE XREF: sub_475BD0+CAj
    test    edi, edi
    mov     eax, ebx
    jbe     short loc_475CEE
    mov     ebp, [esp+1Ch+arg_8]
    mov     edx, edi

    loc_475CCD:                             ; CODE XREF: sub_475BD0+110j
    test    eax, eax
    jz      short loc_475CDC
    mov     ecx, 0Fh
    mov     esi, ebp
    mov     edi, eax
    rep movsd

    loc_475CDC:                             ; CODE XREF: sub_475BD0+FFj
    add     eax, 3Ch
    dec     edx
    jnz     short loc_475CCD
    mov     esi, [esp+1Ch+arg_0]
    mov     edi, [esp+1Ch+arg_4]
    mov     ebp, [esp+1Ch+var_C]

    loc_475CEE:                             ; CODE XREF: sub_475BD0+F5j
    mov     ebp, [ebp+8]
    lea     eax, [edi+edi*2]
    lea     ecx, [eax+eax*4]
    shl     ecx, 2
    cmp     esi, ebp
    lea     edx, [ebx+ecx]
    jz      short loc_475D25
    lea     eax, [esi+edx]
    sub     eax, ebx
    sub     eax, ecx

    loc_475D08:                             ; CODE XREF: sub_475BD0+14Fj
    test    edx, edx
    jz      short loc_475D17
    mov     ecx, 0Fh
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_475D17:                             ; CODE XREF: sub_475BD0+13Aj
    add     eax, 3Ch
    add     edx, 3Ch
    cmp     eax, ebp
    jnz     short loc_475D08
    mov     edi, [esp+1Ch+arg_4]

    loc_475D25:                             ; CODE XREF: sub_475BD0+12Fj
    mov     ebx, [esp+1Ch+var_C]
    mov     eax, [ebx+4]
    push    eax
    mov     [esp+20h+arg_4], eax
    call    sub_4B4F20
    mov     eax, [esp+20h+var_8]
    mov     esi, [esp+20h+var_4]
    add     esp, 4
    lea     eax, [eax+eax*2]
    lea     edx, [eax+eax*4]
    lea     eax, [esi+edx*4]
    mov     [ebx+0Ch], eax
    mov     eax, [ebx+4]
    test    eax, eax
    jnz     short loc_475D58
    xor     edx, edx
    jmp     short loc_475D70
    ; ---------------------------------------------------------------------------

    loc_475D58:                             ; CODE XREF: sub_475BD0+182j
    mov     ecx, [ebx+8]
    sub     ecx, eax
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_475D70:                             ; CODE XREF: sub_475BD0+186j
    lea     eax, [edi+edx]
    mov     [ebx+4], esi
    lea     eax, [eax+eax*2]
    lea     edx, [eax+eax*4]
    lea     eax, [esi+edx*4]
    mov     [ebx+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_475D8C:                             ; CODE XREF: sub_475BD0+2Ej
    mov     ebp, [esp+1Ch+arg_0]
    mov     ecx, ebx
    sub     ecx, ebp
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    cmp     edx, edi
    jnb     loc_475E4E
    lea     eax, [edi+edi*2]
    lea     ecx, [eax+eax*4]
    shl     ecx, 2
    cmp     ebp, ebx
    mov     [esp+1Ch+arg_0], ecx
    lea     edx, [ebp+ecx+0]
    jz      short loc_475DE5
    mov     eax, edx
    sub     eax, ecx

    loc_475DC8:                             ; CODE XREF: sub_475BD0+20Fj
    test    edx, edx
    jz      short loc_475DD7
    mov     ecx, 0Fh
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_475DD7:                             ; CODE XREF: sub_475BD0+1FAj
    add     eax, 3Ch
    add     edx, 3Ch
    cmp     eax, ebx
    jnz     short loc_475DC8
    mov     edi, [esp+1Ch+arg_4]

    loc_475DE5:                             ; CODE XREF: sub_475BD0+1F2j
    mov     edx, [esp+1Ch+var_C]
    mov     eax, 88888889h
    mov     ebx, [esp+1Ch+arg_8]
    mov     esi, [edx+8]
    mov     ecx, esi
    sub     ecx, ebp
    imul    ecx
    add     edx, ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, esi
    sub     edi, edx
    mov     ecx, edi
    jz      short loc_475E26
    mov     edx, ecx

    loc_475E11:                             ; CODE XREF: sub_475BD0+254j
    test    eax, eax
    jz      short loc_475E20
    mov     ecx, 0Fh
    mov     esi, ebx
    mov     edi, eax
    rep movsd

    loc_475E20:                             ; CODE XREF: sub_475BD0+243j
    add     eax, 3Ch
    dec     edx
    jnz     short loc_475E11

    loc_475E26:                             ; CODE XREF: sub_475BD0+23Dj
    mov     ecx, [esp+1Ch+var_C]
    mov     eax, ebp
    mov     edx, [ecx+8]
    cmp     ebp, edx
    jz      loc_475ED2

    loc_475E37:                             ; CODE XREF: sub_475BD0+277j
    mov     edi, eax
    add     eax, 3Ch
    mov     ecx, 0Fh
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_475E37
    jmp     loc_475ED2
    ; ---------------------------------------------------------------------------

    loc_475E4E:                             ; CODE XREF: sub_475BD0+1D9j
    test    edi, edi
    jbe     loc_475EDD
    lea     eax, [edi+edi*2]
    mov     edx, ebx
    lea     ecx, [eax+eax*4]
    mov     eax, ebx
    shl     ecx, 2
    sub     eax, ecx
    mov     [esp+1Ch+arg_0], ecx
    cmp     eax, ebx
    jz      short loc_475E8A

    loc_475E6D:                             ; CODE XREF: sub_475BD0+2B4j
    test    edx, edx
    jz      short loc_475E7C
    mov     ecx, 0Fh
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_475E7C:                             ; CODE XREF: sub_475BD0+29Fj
    add     eax, 3Ch
    add     edx, 3Ch
    cmp     eax, ebx
    jnz     short loc_475E6D
    mov     ecx, [esp+1Ch+arg_0]

    loc_475E8A:                             ; CODE XREF: sub_475BD0+29Bj
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [eax+8]
    mov     eax, edx
    sub     eax, ecx
    cmp     ebp, eax
    jz      short loc_475EAE

    loc_475E99:                             ; CODE XREF: sub_475BD0+2DCj
    sub     eax, 3Ch
    sub     edx, 3Ch
    mov     ecx, 0Fh
    mov     esi, eax
    mov     edi, edx
    cmp     eax, ebp
    rep movsd
    jnz     short loc_475E99

    loc_475EAE:                             ; CODE XREF: sub_475BD0+2C7j
    mov     ecx, [esp+1Ch+arg_0]
    mov     eax, ebp
    lea     edx, [ebp+ecx+0]
    cmp     ebp, edx
    jz      short loc_475ED2
    mov     ebx, [esp+1Ch+arg_8]

    loc_475EC0:                             ; CODE XREF: sub_475BD0+300j
    mov     edi, eax
    add     eax, 3Ch
    mov     ecx, 0Fh
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_475EC0

    loc_475ED2:                             ; CODE XREF: sub_475BD0+261j
                                            ; sub_475BD0+279j ...
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]
    add     [eax+8], edx

    loc_475EDD:                             ; CODE XREF: sub_475BD0+280j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_475BD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_475EF0 proc near                    ; CODE XREF: sub_474880+24Ap

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    mov     eax, 78787879h
    push    esi
    push    edi
    mov     ebx, [ebp+8]
    mov     ecx, [ebp+0Ch]
    sub     ecx, ebx
    mov     edi, [esp+1Ch+arg_4]
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    mov     [esp+1Ch+var_C], ebp
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, edi
    jnb     loc_4760A5
    mov     esi, [ebp+4]
    test    esi, esi
    jnz     short loc_475F2D
    xor     edx, edx
    jmp     short loc_475F42
    ; ---------------------------------------------------------------------------

    loc_475F2D:                             ; CODE XREF: sub_475EF0+37j
    mov     ecx, ebx
    mov     eax, 78787879h
    sub     ecx, esi
    imul    ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_475F42:                             ; CODE XREF: sub_475EF0+3Bj
    cmp     edi, edx
    jnb     short loc_475F67
    test    esi, esi
    jnz     short loc_475F4E
    xor     ecx, ecx
    jmp     short loc_475F69
    ; ---------------------------------------------------------------------------

    loc_475F4E:                             ; CODE XREF: sub_475EF0+58j
    mov     ecx, ebx
    mov     eax, 78787879h
    sub     ecx, esi
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ecx, edx
    jmp     short loc_475F69
    ; ---------------------------------------------------------------------------

    loc_475F67:                             ; CODE XREF: sub_475EF0+54j
    mov     ecx, edi

    loc_475F69:                             ; CODE XREF: sub_475EF0+5Cj
                                            ; sub_475EF0+75j
    test    esi, esi
    jnz     short loc_475F71
    xor     edx, edx
    jmp     short loc_475F84
    ; ---------------------------------------------------------------------------

    loc_475F71:                             ; CODE XREF: sub_475EF0+7Bj
    sub     ebx, esi
    mov     eax, 78787879h
    imul    ebx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_475F84:                             ; CODE XREF: sub_475EF0+7Fj
    lea     eax, [edx+ecx]
    test    eax, eax
    mov     [esp+1Ch+var_4], eax
    jge     short loc_475F91
    xor     eax, eax

    loc_475F91:                             ; CODE XREF: sub_475EF0+9Dj
    mov     ecx, eax
    shl     ecx, 4
    add     ecx, eax
    shl     ecx, 2
    push    ecx                             ; int
    call    sub_4B4F10
    mov     edx, [esp+20h+arg_0]
    mov     esi, eax
    mov     eax, [ebp+4]
    add     esp, 4
    cmp     eax, edx
    mov     [esp+1Ch+var_8], esi
    mov     ebx, esi
    jz      short loc_475FDC

    loc_475FB7:                             ; CODE XREF: sub_475EF0+DEj
    test    ebx, ebx
    jz      short loc_475FC6
    mov     ecx, 11h
    mov     esi, eax
    mov     edi, ebx
    rep movsd

    loc_475FC6:                             ; CODE XREF: sub_475EF0+C9j
    add     eax, 44h
    add     ebx, 44h
    cmp     eax, edx
    jnz     short loc_475FB7
    mov     edi, [esp+1Ch+arg_4]
    mov     esi, [esp+1Ch+var_8]
    mov     ebp, [esp+1Ch+var_C]

    loc_475FDC:                             ; CODE XREF: sub_475EF0+C5j
    test    edi, edi
    mov     eax, ebx
    jbe     short loc_476007
    mov     ebp, edi

    loc_475FE4:                             ; CODE XREF: sub_475EF0+109j
    test    eax, eax
    jz      short loc_475FF5
    mov     esi, [esp+1Ch+arg_8]
    mov     ecx, 11h
    mov     edi, eax
    rep movsd

    loc_475FF5:                             ; CODE XREF: sub_475EF0+F6j
    add     eax, 44h
    dec     ebp
    jnz     short loc_475FE4
    mov     edi, [esp+1Ch+arg_4]
    mov     esi, [esp+1Ch+var_8]
    mov     ebp, [esp+1Ch+var_C]

    loc_476007:                             ; CODE XREF: sub_475EF0+F0j
    mov     ebp, [ebp+8]
    mov     ecx, edi
    shl     ecx, 4
    add     ecx, edi
    shl     ecx, 2
    cmp     edx, ebp
    lea     eax, [ebx+ecx]
    jz      short loc_476042
    sub     edx, ebx
    add     edx, eax
    sub     edx, ecx

    loc_476021:                             ; CODE XREF: sub_475EF0+148j
    test    eax, eax
    jz      short loc_476030
    mov     ecx, 11h
    mov     esi, edx
    mov     edi, eax
    rep movsd

    loc_476030:                             ; CODE XREF: sub_475EF0+133j
    add     edx, 44h
    add     eax, 44h
    cmp     edx, ebp
    jnz     short loc_476021
    mov     edi, [esp+1Ch+arg_4]
    mov     esi, [esp+1Ch+var_8]

    loc_476042:                             ; CODE XREF: sub_475EF0+129j
    mov     ebx, [esp+1Ch+var_C]
    mov     eax, [ebx+4]
    push    eax
    mov     [esp+20h+arg_4], eax
    call    sub_4B4F20
    mov     eax, [esp+20h+var_4]
    add     esp, 4
    mov     edx, eax
    shl     edx, 4
    add     edx, eax
    lea     eax, [esi+edx*4]
    mov     [ebx+0Ch], eax
    mov     eax, [ebx+4]
    test    eax, eax
    jnz     short loc_476072
    xor     edx, edx
    jmp     short loc_476088
    ; ---------------------------------------------------------------------------

    loc_476072:                             ; CODE XREF: sub_475EF0+17Cj
    mov     ecx, [ebx+8]
    sub     ecx, eax
    mov     eax, 78787879h
    imul    ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_476088:                             ; CODE XREF: sub_475EF0+180j
    lea     eax, [edi+edx]
    mov     [ebx+4], esi
    mov     edx, eax
    shl     edx, 4
    add     edx, eax
    lea     eax, [esi+edx*4]
    mov     [ebx+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4760A5:                             ; CODE XREF: sub_475EF0+2Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     ecx, ebx
    sub     ecx, ebp
    mov     eax, 78787879h
    imul    ecx
    sar     edx, 5
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    cmp     edx, edi
    jnb     loc_476170
    mov     ecx, edi
    shl     ecx, 4
    add     ecx, edi
    shl     ecx, 2
    cmp     ebp, ebx
    mov     [esp+1Ch+arg_0], ecx
    lea     edx, [ebp+ecx+0]
    jz      short loc_4760FD
    mov     eax, edx
    sub     eax, ecx

    loc_4760E0:                             ; CODE XREF: sub_475EF0+207j
    test    edx, edx
    jz      short loc_4760EF
    mov     ecx, 11h
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_4760EF:                             ; CODE XREF: sub_475EF0+1F2j
    add     eax, 44h
    add     edx, 44h
    cmp     eax, ebx
    jnz     short loc_4760E0
    mov     edi, [esp+1Ch+arg_4]

    loc_4760FD:                             ; CODE XREF: sub_475EF0+1EAj
    mov     edx, [esp+1Ch+var_C]
    mov     eax, 78787879h
    mov     ebx, [esp+1Ch+arg_8]
    mov     esi, [edx+8]
    mov     ecx, esi
    sub     ecx, ebp
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, esi
    sub     edi, edx
    mov     ecx, edi
    jz      short loc_47613C
    mov     edx, ecx

    loc_476127:                             ; CODE XREF: sub_475EF0+24Aj
    test    eax, eax
    jz      short loc_476136
    mov     ecx, 11h
    mov     esi, ebx
    mov     edi, eax
    rep movsd

    loc_476136:                             ; CODE XREF: sub_475EF0+239j
    add     eax, 44h
    dec     edx
    jnz     short loc_476127

    loc_47613C:                             ; CODE XREF: sub_475EF0+233j
    mov     ecx, [esp+1Ch+var_C]
    mov     eax, ebp
    mov     edx, [ecx+8]
    cmp     ebp, edx
    jz      short loc_47615B

    loc_476149:                             ; CODE XREF: sub_475EF0+269j
    mov     edi, eax
    add     eax, 44h
    mov     ecx, 11h
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_476149

    loc_47615B:                             ; CODE XREF: sub_475EF0+257j
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]
    add     [eax+8], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_476170:                             ; CODE XREF: sub_475EF0+1D0j
    test    edi, edi
    jbe     loc_476200
    mov     ecx, edi
    mov     eax, ebx
    shl     ecx, 4
    add     ecx, edi
    mov     edx, ebx
    shl     ecx, 2
    sub     eax, ecx
    mov     [esp+1Ch+arg_0], ecx
    cmp     eax, ebx
    jz      short loc_4761AD

    loc_476190:                             ; CODE XREF: sub_475EF0+2BBj
    test    edx, edx
    jz      short loc_4761A3
    mov     ecx, 11h
    mov     esi, eax
    mov     edi, edx
    rep movsd
    mov     ecx, [esp+1Ch+arg_0]

    loc_4761A3:                             ; CODE XREF: sub_475EF0+2A2j
    add     eax, 44h
    add     edx, 44h
    cmp     eax, ebx
    jnz     short loc_476190

    loc_4761AD:                             ; CODE XREF: sub_475EF0+29Ej
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [eax+8]
    mov     eax, edx
    sub     eax, ecx
    cmp     ebp, eax
    jz      short loc_4761D5

    loc_4761BC:                             ; CODE XREF: sub_475EF0+2DFj
    sub     eax, 44h
    sub     edx, 44h
    mov     ecx, 11h
    mov     esi, eax
    mov     edi, edx
    cmp     eax, ebp
    rep movsd
    jnz     short loc_4761BC
    mov     ecx, [esp+1Ch+arg_0]

    loc_4761D5:                             ; CODE XREF: sub_475EF0+2CAj
    lea     edx, [ebp+ecx+0]
    mov     eax, ebp
    cmp     ebp, edx
    jz      short loc_4761F9
    mov     ebx, [esp+1Ch+arg_8]

    loc_4761E3:                             ; CODE XREF: sub_475EF0+303j
    mov     edi, eax
    add     eax, 44h
    mov     ecx, 11h
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_4761E3
    mov     ecx, [esp+1Ch+arg_0]

    loc_4761F9:                             ; CODE XREF: sub_475EF0+2EDj
    mov     eax, [esp+1Ch+var_C]
    add     [eax+8], ecx

    loc_476200:                             ; CODE XREF: sub_475EF0+282j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_475EF0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_476210 proc near                    ; CODE XREF: sub_474DF0+163p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     esi, [esp+1Ch+arg_4]
    mov     edi, ecx
    mov     [esp+1Ch+var_C], edi
    mov     edx, [edi+8]
    mov     eax, [edi+0Ch]
    sub     eax, edx
    sar     eax, 5
    cmp     eax, esi
    jnb     loc_476362
    mov     ecx, [edi+4]
    test    ecx, ecx
    jnz     short loc_47623F
    xor     eax, eax
    jmp     short loc_476246
    ; ---------------------------------------------------------------------------

    loc_47623F:                             ; CODE XREF: sub_476210+29j
    mov     eax, edx
    sub     eax, ecx
    sar     eax, 5

    loc_476246:                             ; CODE XREF: sub_476210+2Dj
    cmp     esi, eax
    jnb     short loc_47625B
    test    ecx, ecx
    jnz     short loc_476252
    xor     eax, eax
    jmp     short loc_47625D
    ; ---------------------------------------------------------------------------

    loc_476252:                             ; CODE XREF: sub_476210+3Cj
    mov     eax, edx
    sub     eax, ecx
    sar     eax, 5
    jmp     short loc_47625D
    ; ---------------------------------------------------------------------------

    loc_47625B:                             ; CODE XREF: sub_476210+38j
    mov     eax, esi

    loc_47625D:                             ; CODE XREF: sub_476210+40j
                                            ; sub_476210+49j
    test    ecx, ecx
    jnz     short loc_476265
    xor     edx, edx
    jmp     short loc_47626A
    ; ---------------------------------------------------------------------------

    loc_476265:                             ; CODE XREF: sub_476210+4Fj
    sub     edx, ecx
    sar     edx, 5

    loc_47626A:                             ; CODE XREF: sub_476210+53j
    add     eax, edx
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_476276
    xor     eax, eax

    loc_476276:                             ; CODE XREF: sub_476210+62j
    shl     eax, 5
    push    eax                             ; int
    call    sub_4B4F10
    mov     [esp+20h+var_4], eax
    mov     ebx, eax
    mov     eax, [edi+4]
    mov     edi, [esp+20h+arg_0]
    add     esp, 4
    cmp     eax, edi
    jz      short loc_4762B4

    loc_476293:                             ; CODE XREF: sub_476210+A2j
    test    ebx, ebx
    jz      short loc_4762A6
    mov     ecx, 8
    mov     esi, eax
    mov     edi, ebx
    rep movsd
    mov     esi, [esp+1Ch+arg_4]

    loc_4762A6:                             ; CODE XREF: sub_476210+85j
    mov     edi, [esp+1Ch+arg_0]
    add     eax, 20h
    add     ebx, 20h
    cmp     eax, edi
    jnz     short loc_476293

    loc_4762B4:                             ; CODE XREF: sub_476210+81j
    test    esi, esi
    mov     eax, ebx
    jbe     short loc_4762DD
    mov     ebp, [esp+1Ch+arg_8]
    mov     edx, esi

    loc_4762C0:                             ; CODE XREF: sub_476210+C7j
    test    eax, eax
    jz      short loc_4762D3
    mov     ecx, 8
    mov     esi, ebp
    mov     edi, eax
    rep movsd
    mov     esi, [esp+1Ch+arg_4]

    loc_4762D3:                             ; CODE XREF: sub_476210+B2j
    add     eax, 20h
    dec     edx
    jnz     short loc_4762C0
    mov     edi, [esp+1Ch+arg_0]

    loc_4762DD:                             ; CODE XREF: sub_476210+A8j
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, esi
    shl     ecx, 5
    mov     ebp, [eax+8]
    cmp     edi, ebp
    lea     edx, [ebx+ecx]
    jz      short loc_476310
    lea     eax, [edi+edx]
    sub     eax, ebx
    sub     eax, ecx

    loc_4762F7:                             ; CODE XREF: sub_476210+FEj
    test    edx, edx
    jz      short loc_476306
    mov     ecx, 8
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_476306:                             ; CODE XREF: sub_476210+E9j
    add     eax, 20h
    add     edx, 20h
    cmp     eax, ebp
    jnz     short loc_4762F7

    loc_476310:                             ; CODE XREF: sub_476210+DEj
    mov     esi, [esp+1Ch+var_C]
    mov     eax, [esi+4]
    push    eax
    mov     [esp+20h+arg_0], eax
    call    sub_4B4F20
    mov     eax, [esp+20h+var_8]
    mov     edx, [esp+20h+var_4]
    mov     ecx, [esi+4]
    add     esp, 4
    shl     eax, 5
    add     eax, edx
    test    ecx, ecx
    mov     [esi+0Ch], eax
    jnz     short loc_47633F
    xor     eax, eax
    jmp     short loc_476347
    ; ---------------------------------------------------------------------------

    loc_47633F:                             ; CODE XREF: sub_476210+129j
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 5

    loc_476347:                             ; CODE XREF: sub_476210+12Dj
    mov     ecx, [esp+1Ch+arg_4]
    mov     [esi+4], edx
    add     ecx, eax
    shl     ecx, 5
    add     ecx, edx
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_476362:                             ; CODE XREF: sub_476210+1Ej
    mov     ebp, [esp+1Ch+arg_0]
    mov     eax, edx
    sub     eax, ebp
    sar     eax, 5
    cmp     eax, esi
    jnb     loc_4763F9
    mov     ecx, esi
    shl     ecx, 5
    cmp     ebp, edx
    mov     [esp+1Ch+arg_0], ecx
    lea     ebx, [ebp+ecx+0]
    jz      short loc_4763AB
    mov     eax, ebx
    sub     eax, ecx

    loc_47638A:                             ; CODE XREF: sub_476210+195j
    test    ebx, ebx
    jz      short loc_47639D
    mov     ecx, 8
    mov     esi, eax
    mov     edi, ebx
    rep movsd
    mov     esi, [esp+1Ch+arg_4]

    loc_47639D:                             ; CODE XREF: sub_476210+17Cj
    add     eax, 20h
    add     ebx, 20h
    cmp     eax, edx
    jnz     short loc_47638A
    mov     edi, [esp+1Ch+var_C]

    loc_4763AB:                             ; CODE XREF: sub_476210+174j
    mov     eax, [edi+8]
    mov     ebx, [esp+1Ch+arg_8]
    mov     ecx, eax
    sub     ecx, ebp
    sar     ecx, 5
    sub     esi, ecx
    jz      short loc_4763D8
    mov     edx, esi

    loc_4763BF:                             ; CODE XREF: sub_476210+1C2j
    test    eax, eax
    jz      short loc_4763CE
    mov     ecx, 8
    mov     esi, ebx
    mov     edi, eax
    rep movsd

    loc_4763CE:                             ; CODE XREF: sub_476210+1B1j
    add     eax, 20h
    dec     edx
    jnz     short loc_4763BF
    mov     edi, [esp+1Ch+var_C]

    loc_4763D8:                             ; CODE XREF: sub_476210+1ABj
    mov     edx, [edi+8]
    mov     eax, ebp
    cmp     ebp, edx
    jz      loc_476477

    loc_4763E5:                             ; CODE XREF: sub_476210+1E5j
    mov     edi, eax
    add     eax, 20h
    mov     ecx, 8
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_4763E5
    jmp     short loc_476477
    ; ---------------------------------------------------------------------------

    loc_4763F9:                             ; CODE XREF: sub_476210+15Fj
    test    esi, esi
    jbe     loc_476482
    shl     esi, 5
    mov     eax, edx
    mov     ebx, edx
    sub     eax, esi
    mov     [esp+1Ch+arg_0], esi
    cmp     eax, edx
    jz      short loc_476433

    loc_476412:                             ; CODE XREF: sub_476210+219j
    test    ebx, ebx
    jz      short loc_476421
    mov     ecx, 8
    mov     esi, eax
    mov     edi, ebx
    rep movsd

    loc_476421:                             ; CODE XREF: sub_476210+204j
    add     eax, 20h
    add     ebx, 20h
    cmp     eax, edx
    jnz     short loc_476412
    mov     esi, [esp+1Ch+arg_0]
    mov     edi, [esp+1Ch+var_C]

    loc_476433:                             ; CODE XREF: sub_476210+200j
    mov     edx, [edi+8]
    mov     eax, edx
    sub     eax, esi
    cmp     ebp, eax
    jz      short loc_476453

    loc_47643E:                             ; CODE XREF: sub_476210+241j
    sub     eax, 20h
    sub     edx, 20h
    mov     ecx, 8
    mov     esi, eax
    mov     edi, edx
    cmp     eax, ebp
    rep movsd
    jnz     short loc_47643E

    loc_476453:                             ; CODE XREF: sub_476210+22Cj
    mov     ecx, [esp+1Ch+arg_0]
    mov     eax, ebp
    lea     edx, [ebp+ecx+0]
    cmp     ebp, edx
    jz      short loc_476477
    mov     ebx, [esp+1Ch+arg_8]

    loc_476465:                             ; CODE XREF: sub_476210+265j
    mov     edi, eax
    add     eax, 20h
    mov     ecx, 8
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_476465

    loc_476477:                             ; CODE XREF: sub_476210+1CFj
                                            ; sub_476210+1E7j ...
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]
    add     [eax+8], edx

    loc_476482:                             ; CODE XREF: sub_476210+1EBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_476210 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_476490 proc near                    ; CODE XREF: sub_4751C0+14Bp

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    mov     edx, [ecx+8]
    mov     eax, [ecx+0Ch]
    push    ebx
    push    ebp
    sub     eax, edx
    push    esi
    mov     esi, [esp+18h+arg_4]
    push    edi
    sar     eax, 5
    cmp     eax, esi
    mov     [esp+1Ch+var_C], ecx
    jnb     loc_4765E4
    mov     ecx, [ecx+4]
    test    ecx, ecx
    jnz     short loc_4764BD
    xor     eax, eax
    jmp     short loc_4764C4
    ; ---------------------------------------------------------------------------

    loc_4764BD:                             ; CODE XREF: sub_476490+27j
    mov     eax, edx
    sub     eax, ecx
    sar     eax, 5

    loc_4764C4:                             ; CODE XREF: sub_476490+2Bj
    cmp     esi, eax
    jnb     short loc_4764D9
    test    ecx, ecx
    jnz     short loc_4764D0
    xor     eax, eax
    jmp     short loc_4764DB
    ; ---------------------------------------------------------------------------

    loc_4764D0:                             ; CODE XREF: sub_476490+3Aj
    mov     eax, edx
    sub     eax, ecx
    sar     eax, 5
    jmp     short loc_4764DB
    ; ---------------------------------------------------------------------------

    loc_4764D9:                             ; CODE XREF: sub_476490+36j
    mov     eax, esi

    loc_4764DB:                             ; CODE XREF: sub_476490+3Ej
                                            ; sub_476490+47j
    test    ecx, ecx
    jnz     short loc_4764E3
    xor     edx, edx
    jmp     short loc_4764E8
    ; ---------------------------------------------------------------------------

    loc_4764E3:                             ; CODE XREF: sub_476490+4Dj
    sub     edx, ecx
    sar     edx, 5

    loc_4764E8:                             ; CODE XREF: sub_476490+51j
    lea     edi, [edx+eax]
    test    edi, edi
    mov     [esp+1Ch+var_8], edi
    mov     eax, edi
    jge     short loc_4764F7
    xor     eax, eax

    loc_4764F7:                             ; CODE XREF: sub_476490+63j
    shl     eax, 5
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+20h+var_C]
    mov     edx, [esp+20h+arg_0]
    mov     [esp+20h+var_4], eax
    mov     ebx, eax
    mov     eax, [ecx+4]
    add     esp, 4
    cmp     eax, edx
    jz      short loc_476539

    loc_476518:                             ; CODE XREF: sub_476490+A3j
    test    ebx, ebx
    jz      short loc_47652B
    mov     ecx, 8
    mov     esi, eax
    mov     edi, ebx
    rep movsd
    mov     esi, [esp+1Ch+arg_4]

    loc_47652B:                             ; CODE XREF: sub_476490+8Aj
    add     eax, 20h
    add     ebx, 20h
    cmp     eax, edx
    jnz     short loc_476518
    mov     edi, [esp+1Ch+var_8]

    loc_476539:                             ; CODE XREF: sub_476490+86j
    test    esi, esi
    mov     eax, ebx
    jbe     short loc_476560
    mov     ebp, esi

    loc_476541:                             ; CODE XREF: sub_476490+CAj
    test    eax, eax
    jz      short loc_476556
    mov     esi, [esp+1Ch+arg_8]
    mov     ecx, 8
    mov     edi, eax
    rep movsd
    mov     esi, [esp+1Ch+arg_4]

    loc_476556:                             ; CODE XREF: sub_476490+B3j
    add     eax, 20h
    dec     ebp
    jnz     short loc_476541
    mov     edi, [esp+1Ch+var_8]

    loc_476560:                             ; CODE XREF: sub_476490+ADj
    mov     ecx, esi
    mov     esi, [esp+1Ch+var_C]
    shl     ecx, 5
    mov     ebp, [esi+8]
    cmp     edx, ebp
    lea     eax, [ebx+ecx]
    jz      short loc_476596
    sub     edx, ebx
    add     edx, eax
    sub     edx, ecx

    loc_476579:                             ; CODE XREF: sub_476490+100j
    test    eax, eax
    jz      short loc_476588
    mov     ecx, 8
    mov     esi, edx
    mov     edi, eax
    rep movsd

    loc_476588:                             ; CODE XREF: sub_476490+EBj
    add     edx, 20h
    add     eax, 20h
    cmp     edx, ebp
    jnz     short loc_476579
    mov     edi, [esp+1Ch+var_8]

    loc_476596:                             ; CODE XREF: sub_476490+E1j
    mov     esi, [esp+1Ch+var_C]
    mov     eax, [esi+4]
    push    eax
    mov     [esp+20h+arg_8], eax
    call    sub_4B4F20
    mov     edx, [esp+20h+var_4]
    mov     ecx, [esi+4]
    shl     edi, 5
    add     esp, 4
    add     edi, edx
    test    ecx, ecx
    mov     [esi+0Ch], edi
    jnz     short loc_4765C1
    xor     eax, eax
    jmp     short loc_4765C9
    ; ---------------------------------------------------------------------------

    loc_4765C1:                             ; CODE XREF: sub_476490+12Bj
    mov     eax, [esi+8]
    sub     eax, ecx
    sar     eax, 5

    loc_4765C9:                             ; CODE XREF: sub_476490+12Fj
    mov     ecx, [esp+1Ch+arg_4]
    mov     [esi+4], edx
    add     ecx, eax
    shl     ecx, 5
    add     ecx, edx
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4765E4:                             ; CODE XREF: sub_476490+1Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     eax, edx
    sub     eax, ebp
    sar     eax, 5
    cmp     eax, esi
    jnb     loc_47667B
    mov     edi, esi
    shl     edi, 5
    cmp     ebp, edx
    mov     [esp+1Ch+arg_0], edi
    lea     ebx, [ebp+edi+0]
    jz      short loc_47662D
    mov     eax, ebx
    sub     eax, edi

    loc_47660C:                             ; CODE XREF: sub_476490+197j
    test    ebx, ebx
    jz      short loc_47661F
    mov     ecx, 8
    mov     esi, eax
    mov     edi, ebx
    rep movsd
    mov     esi, [esp+1Ch+arg_4]

    loc_47661F:                             ; CODE XREF: sub_476490+17Ej
    add     eax, 20h
    add     ebx, 20h
    cmp     eax, edx
    jnz     short loc_47660C
    mov     ecx, [esp+1Ch+var_C]

    loc_47662D:                             ; CODE XREF: sub_476490+176j
    mov     eax, [ecx+8]
    mov     ebx, [esp+1Ch+arg_8]
    mov     edx, eax
    sub     edx, ebp
    sar     edx, 5
    sub     esi, edx
    jz      short loc_47665A
    mov     edx, esi

    loc_476641:                             ; CODE XREF: sub_476490+1C4j
    test    eax, eax
    jz      short loc_476650
    mov     ecx, 8
    mov     esi, ebx
    mov     edi, eax
    rep movsd

    loc_476650:                             ; CODE XREF: sub_476490+1B3j
    add     eax, 20h
    dec     edx
    jnz     short loc_476641
    mov     ecx, [esp+1Ch+var_C]

    loc_47665A:                             ; CODE XREF: sub_476490+1ADj
    mov     edx, [ecx+8]
    mov     eax, ebp
    cmp     ebp, edx
    jz      loc_4766F3

    loc_476667:                             ; CODE XREF: sub_476490+1E7j
    mov     edi, eax
    add     eax, 20h
    mov     ecx, 8
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_476667
    jmp     short loc_4766F3
    ; ---------------------------------------------------------------------------

    loc_47667B:                             ; CODE XREF: sub_476490+161j
    test    esi, esi
    jbe     short loc_4766FE
    shl     esi, 5
    mov     eax, edx
    mov     ebx, edx
    sub     eax, esi
    mov     [esp+1Ch+arg_0], esi
    cmp     eax, edx
    jz      short loc_4766B1

    loc_476690:                             ; CODE XREF: sub_476490+217j
    test    ebx, ebx
    jz      short loc_47669F
    mov     ecx, 8
    mov     esi, eax
    mov     edi, ebx
    rep movsd

    loc_47669F:                             ; CODE XREF: sub_476490+202j
    add     eax, 20h
    add     ebx, 20h
    cmp     eax, edx
    jnz     short loc_476690
    mov     esi, [esp+1Ch+arg_0]
    mov     ecx, [esp+1Ch+var_C]

    loc_4766B1:                             ; CODE XREF: sub_476490+1FEj
    mov     edx, [ecx+8]
    mov     eax, edx
    sub     eax, esi
    cmp     ebp, eax
    jz      short loc_4766D1

    loc_4766BC:                             ; CODE XREF: sub_476490+23Fj
    sub     eax, 20h
    sub     edx, 20h
    mov     ecx, 8
    mov     esi, eax
    mov     edi, edx
    cmp     eax, ebp
    rep movsd
    jnz     short loc_4766BC

    loc_4766D1:                             ; CODE XREF: sub_476490+22Aj
    mov     edx, [esp+1Ch+arg_0]
    mov     eax, ebp
    add     edx, ebp
    cmp     ebp, edx
    jz      short loc_4766F3
    mov     ebx, [esp+1Ch+arg_8]

    loc_4766E1:                             ; CODE XREF: sub_476490+261j
    mov     edi, eax
    add     eax, 20h
    mov     ecx, 8
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_4766E1

    loc_4766F3:                             ; CODE XREF: sub_476490+1D1j
                                            ; sub_476490+1E9j ...
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, [esp+1Ch+arg_0]
    add     [eax+8], ecx

    loc_4766FE:                             ; CODE XREF: sub_476490+1EDj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_476490 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_476710 proc near                    ; CODE XREF: sub_473D50+27Fp
                                            ; sub_473D50+32Cp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    test    eax, eax
    jbe     short locret_47673D
    push    edi
    push    esi
    push    ebx
    mov     ebx, [esp+0Ch+arg_8]
    mov     edx, eax
    mov     eax, [esp+0Ch+arg_0]

    loc_476725:                             ; CODE XREF: sub_476710+28j
    test    eax, eax
    jz      short loc_476734
    mov     ecx, 0Ch
    mov     esi, ebx
    mov     edi, eax
    rep movsd

    loc_476734:                             ; CODE XREF: sub_476710+17j
    add     eax, 30h
    dec     edx
    jnz     short loc_476725
    pop     ebx
    pop     esi
    pop     edi

    locret_47673D:                          ; CODE XREF: sub_476710+6j
    retn    0Ch
    sub_476710 endp

    ; ---------------------------------------------------------------------------
    sub     esp, 500h
    push    esi
    push    edi
    mov     edi, [esp+510h]
    test    edi, edi
    jz      short loc_47675D
    call    sub_4C2470
    call    sub_4257A0

    loc_47675D:                             ; CODE XREF: .text:00476751j
    mov     esi, [esp+50Ch]
    push    offset aPcx                     ; "PCX"
    push    esi
    lea     eax, [esp+10h]
    push    offset aBitmaps                 ; "bitmaps"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+108h]
    push    ecx
    push    esi
    call    sub_429290
    push    100h
    lea     edx, [esp+10Ch]
    push    0
    push    edx
    mov     esi, eax
    call    sub_4BA200
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    push    0
    push    0
    push    esi
    push    0
    call    sub_4C6B70
    push    esi
    call    sub_4C6AC0
    test    edi, edi
    jz      short loc_4767C9
    call    sub_4C2870

    loc_4767C9:                             ; CODE XREF: .text:004767C2j
    pop     edi
    pop     esi
    add     esp, 500h
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+37F39h]
    retn
    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 100h
    lea     eax, [esp+0]
    push    offset off_50341C
    push    offset asc_50372C               ; "*"
    push    offset aCamps                   ; "camps"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+0]
    push    0
    push    ecx
    call    sub_4BC930
    add     esp, 100h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_476830 proc near                    ; CODE XREF: sub_493060+EFp
                                            ; sub_4931D0+85p

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+37F39h]
    push    edi
    lea     eax, [eax+eax*2]
    lea     ecx, [eax+eax*4]
    shl     ecx, 1
    push    ecx
    push    offset aSidelist                ; "SideList"
    call    sub_4D83B0
    mov     edx, eax
    xor     ebx, ebx
    add     esp, 8
    mov     [esp+18h+var_4], edx
    mov     byte ptr [edx], 0
    mov     esi, TAdynmemStructPtr
    cmp     [esi+37F39h], ebx
    jle     short loc_4768D6
    mov     [esp+18h+var_8], ebx

    loc_476875:                             ; CODE XREF: sub_476830+A0j
    mov     eax, [esp+18h+var_8]
    or      ecx, 0FFFFFFFFh
    lea     edi, [esi+eax+37F3Dh]
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    inc     ebx
    lea     edx, [edx+ecx+1]
    mov     ecx, [esp+18h+var_8]
    add     ecx, 232h
    mov     [edx], al
    mov     esi, TAdynmemStructPtr
    mov     [esp+18h+var_8], ecx
    cmp     ebx, [esi+37F39h]
    jl      short loc_476875
    mov     edx, [esp+18h+var_4]

    loc_4768D6:                             ; CODE XREF: sub_476830+3Fj
    mov     ecx, [esi+37F39h]
    xor     edi, edi
    test    ecx, ecx
    mov     eax, edx
    jle     short loc_47690B

    loc_4768E4:                             ; CODE XREF: sub_476830+D9j
    mov     cl, [eax+1]
    inc     eax
    test    cl, cl
    jz      short loc_4768FF

    loc_4768EC:                             ; CODE XREF: sub_476830+C7j
    add     cl, 20h
    mov     [eax], cl
    mov     cl, [eax+1]
    inc     eax
    test    cl, cl
    jnz     short loc_4768EC
    mov     esi, TAdynmemStructPtr

    loc_4768FF:                             ; CODE XREF: sub_476830+BAj
    mov     ecx, [esi+37F39h]
    inc     eax
    inc     edi
    cmp     edi, ecx
    jl      short loc_4768E4

    loc_47690B:                             ; CODE XREF: sub_476830+B2j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, edx
    pop     ebx
    add     esp, 8
    retn
    sub_476830 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 104h
    push    ebx
    push    ebp
    push    edi
    push    offset off_50341C
    push    offset asc_50372C               ; "*"
    lea     eax, [esp+18h]
    push    offset aCamps                   ; "camps"
    push    eax
    call    sub_4290F0
    xor     edi, edi
    lea     ecx, [esp+10h]
    push    edi
    push    ecx
    call    sub_4BC930
    mov     ebx, eax
    mov     edx, ebx
    shl     edx, 8
    push    edx
    push    offset aCampaignNames           ; "CAMPAIGN NAMES"
    call    sub_4D83B0
    add     esp, 8
    mov     ebp, eax
    lea     eax, [esp+10h]
    push    2
    push    1
    push    edi
    push    edi
    push    ebp
    push    eax
    call    sub_4AF320
    cmp     ebx, edi
    mov     [esp+0Ch], edi
    jle     short loc_4769CB
    push    esi

    loc_476980:                             ; CODE XREF: .text:004769C8j
    push    edi
    push    ebp
    call    sub_4B6AF0
    mov     esi, eax
    mov     ecx, [esp+118h]

    loc_476990:                             ; CODE XREF: .text:004769AEj
    mov     dl, [ecx]
    mov     al, dl
    cmp     dl, [esi]
    jnz     short loc_4769B4
    test    al, al
    jz      short loc_4769B0
    mov     dl, [ecx+1]
    mov     al, dl
    cmp     dl, [esi+1]
    jnz     short loc_4769B4
    add     ecx, 2
    add     esi, 2
    test    al, al
    jnz     short loc_476990

    loc_4769B0:                             ; CODE XREF: .text:0047699Aj
    xor     eax, eax
    jmp     short loc_4769B9
    ; ---------------------------------------------------------------------------

    loc_4769B4:                             ; CODE XREF: .text:00476996j
                                            ; .text:004769A4j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4769B9:                             ; CODE XREF: .text:004769B2j
    test    eax, eax
    jnz     short loc_4769C5
    mov     dword ptr [esp+10h], 1

    loc_4769C5:                             ; CODE XREF: .text:004769BBj
    inc     edi
    cmp     edi, ebx
    jl      short loc_476980
    pop     esi

    loc_4769CB:                             ; CODE XREF: .text:0047697Dj
    push    ebp
    call    sub_4D85A0
    mov     eax, [esp+10h]
    add     esp, 4
    pop     edi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 100h
    lea     eax, [esp+0]
    push    esi
    push    offset off_50341C
    push    offset asc_50372C               ; "*"
    push    offset aCamps                   ; "camps"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+4]
    push    0
    push    ecx
    call    sub_4BC930
    mov     esi, eax
    mov     edx, esi
    shl     edx, 8
    push    edx
    push    offset aCampaignNames           ; "CAMPAIGN NAMES"
    call    sub_4D83B0
    mov     ecx, [esp+110h]
    add     esp, 8
    lea     edx, [esp+4]
    push    2
    push    1
    push    0
    push    0
    push    eax
    push    edx
    mov     [ecx], eax
    call    sub_4AF320
    mov     eax, esi
    pop     esi
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_476A60 proc near                    ; CODE XREF: .text:0047797Ep
                                            ; .text:00477EB0p ...

    var_15C= dword ptr -15Ch
    var_158= dword ptr -158h
    var_154= dword ptr -154h
    var_150= dword ptr -150h
    var_14C= dword ptr -14Ch
    var_148= dword ptr -148h
    var_140= byte ptr -140h
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 15Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    lea     ecx, [esp+16Ch+var_14C]
    mov     [esp+16Ch+var_158], 0
    call    sub_4C2EA0
    push    offset off_50341C
    push    offset asc_50372C               ; "*"
    lea     eax, [esp+174h+var_100]
    push    offset aCamps                   ; "camps"
    push    eax
    mov     [esp+17Ch+var_140], 30h
    call    sub_4290F0
    lea     ecx, [esp+16Ch+var_100]
    push    0
    push    ecx
    call    sub_4BC930
    mov     edi, eax
    mov     esi, edi
    shl     esi, 8
    push    esi
    push    offset aCampaignNames1          ; "CAMPAIGN NAMES1"
    call    sub_4D83B0
    add     esp, 8
    mov     ebp, eax
    mov     [esp+16Ch+var_150], ebp
    push    esi
    push    offset aCampaignNames2          ; "CAMPAIGN NAMES2"
    call    sub_4D83B0
    mov     esi, [esp+174h+arg_0]
    add     esp, 8
    lea     edx, [esp+16Ch+var_100]
    push    2
    push    1
    push    0
    push    0
    push    ebp
    push    edx
    mov     [esi], eax
    call    sub_4AF320
    mov     ebx, [esi]
    test    edi, edi
    mov     [esp+16Ch+var_15C], ebp
    jle     loc_476C4C
    mov     ebp, [esp+16Ch+arg_4]
    mov     [esp+16Ch+var_154], edi

    loc_476B03:                             ; CODE XREF: sub_476A60+1E2j
    mov     eax, [esp+16Ch+var_15C]
    push    offset aTdf                     ; "tdf"
    push    eax
    lea     ecx, [esp+174h+var_100]
    push    offset aCamps                   ; "camps"
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+16Ch+var_100]
    lea     ecx, [esp+16Ch+var_14C]
    push    edx
    call    sub_4C2F60
    test    eax, eax
    jz      loc_476C39
    push    offset aHeader                  ; char *
    lea     ecx, [esp+170h+var_14C]
    call    sub_4C3410
    test    eax, eax
    jz      loc_476C21
    mov     ecx, [esp+16Ch+var_148]
    push    offset Data                     ; int
    push    40h                             ; size_t
    lea     eax, [esp+174h+var_140]
    push    offset aCampaignside            ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    mov     eax, ebp
    lea     esi, [esp+16Ch+var_140]
    shl     eax, 3
    sub     eax, ebp
    lea     ecx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    lea     edx, [ebp+ecx*8+0]
    lea     eax, [eax+edx*2+37F3Dh]

    loc_476B80:                             ; CODE XREF: sub_476A60+13Ej
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_476BA4
    test    cl, cl
    jz      short loc_476BA0
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_476BA4
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_476B80

    loc_476BA0:                             ; CODE XREF: sub_476A60+12Aj
    xor     eax, eax
    jmp     short loc_476BA9
    ; ---------------------------------------------------------------------------

    loc_476BA4:                             ; CODE XREF: sub_476A60+126j
                                            ; sub_476A60+134j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_476BA9:                             ; CODE XREF: sub_476A60+142j
    test    eax, eax
    jz      short loc_476BE3
    lea     esi, [esp+16Ch+var_140]
    mov     eax, offset off_507C14

    loc_476BB6:                             ; CODE XREF: sub_476A60+174j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_476BDA
    test    cl, cl
    jz      short loc_476BD6
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_476BDA
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_476BB6

    loc_476BD6:                             ; CODE XREF: sub_476A60+160j
    xor     eax, eax
    jmp     short loc_476BDF
    ; ---------------------------------------------------------------------------

    loc_476BDA:                             ; CODE XREF: sub_476A60+15Cj
                                            ; sub_476A60+16Aj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_476BDF:                             ; CODE XREF: sub_476A60+178j
    test    eax, eax
    jnz     short loc_476C21

    loc_476BE3:                             ; CODE XREF: sub_476A60+14Bj
    mov     ecx, [esp+16Ch+var_158]
    mov     edx, [esp+16Ch+var_15C]
    inc     ecx
    mov     edi, edx
    mov     [esp+16Ch+var_158], ecx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     ebx, [ebx+ecx+1]
    jmp     short loc_476C25
    ; ---------------------------------------------------------------------------

    loc_476C21:                             ; CODE XREF: sub_476A60+E2j
                                            ; sub_476A60+181j
    mov     edx, [esp+16Ch+var_15C]

    loc_476C25:                             ; CODE XREF: sub_476A60+1BFj
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     ecx, [edx+ecx+1]
    mov     [esp+16Ch+var_15C], ecx

    loc_476C39:                             ; CODE XREF: sub_476A60+CCj
    mov     eax, [esp+16Ch+var_154]
    dec     eax
    mov     [esp+16Ch+var_154], eax
    jnz     loc_476B03
    mov     ebp, [esp+16Ch+var_150]

    loc_476C4C:                             ; CODE XREF: sub_476A60+92j
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    lea     ecx, [esp+16Ch+var_14C]
    call    sub_4C2EB0
    mov     eax, [esp+16Ch+var_158]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 15Ch
    retn    8
    sub_476A60 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    cmp     dword ptr [eax+391F1h], 6
    jz      short locret_476C99
    mov     ecx, [eax+391E9h]
    push    3
    call    sub_4356C0
    test    eax, eax
    jz      short locret_476C99
    push    3Ch
    push    0
    push    eax
    call    sub_47F090

    locret_476C99:                          ; CODE XREF: .text:00476C7Cj
                                            ; .text:00476C8Dj
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_476CA0 proc near                    ; CODE XREF: .text:0041FE43p
    mov     eax, TAdynmemStructPtr
    cmp     dword ptr [eax+391F1h], 6
    jz      short locret_476CC9
    mov     ecx, [eax+391E9h]
    push    8
    call    sub_4356C0
    test    eax, eax
    jz      short locret_476CC9
    push    3Ch
    push    0
    push    eax
    call    sub_47F090

    locret_476CC9:                          ; CODE XREF: sub_476CA0+Cj
                                            ; sub_476CA0+1Dj
    retn
    sub_476CA0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_476CD0 proc near                    ; CODE XREF: sub_476D80+C7p

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    add     ecx, 31h
    push    ecx
    push    offset aTempstorage             ; "TempStorage"
    call    sub_4D83B0
    mov     ebx, eax
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    xor     esi, esi
    repne scasb
    not     ecx
    add     ecx, 31h
    mov     edi, ebx
    mov     edx, ecx
    mov     [esp+8+arg_0], ebx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     al, [ebp+0]
    mov     ecx, ebp
    test    al, al
    jz      short loc_476D67
    mov     eax, ebx
    mov     bl, byte ptr [esp+8+arg_0]

    loc_476D29:                             ; CODE XREF: sub_476CD0+91j
    mov     dl, [ecx]
    cmp     dl, 0FFh
    jz      short loc_476D63
    mov     [eax], dl
    mov     dl, [ecx]
    cmp     dl, 26h
    jnz     short loc_476D3F
    mov     bl, [ecx+1]
    xor     esi, 1

    loc_476D3F:                             ; CODE XREF: sub_476CD0+67j
    cmp     dl, 0Ah
    jnz     short loc_476D5A
    cmp     esi, 1
    jnz     short loc_476D5A
    mov     byte ptr [eax-1], 26h
    mov     byte ptr [eax], 0Dh
    inc     eax
    mov     [eax], dl
    inc     eax
    mov     byte ptr [eax], 26h
    inc     eax
    mov     [eax], bl

    loc_476D5A:                             ; CODE XREF: sub_476CD0+72j
                                            ; sub_476CD0+77j
    mov     dl, [ecx+1]
    inc     eax
    inc     ecx
    test    dl, dl
    jnz     short loc_476D29

    loc_476D63:                             ; CODE XREF: sub_476CD0+5Ej
    mov     ebx, [esp+8+arg_0]

    loc_476D67:                             ; CODE XREF: sub_476CD0+51j
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_476CD0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_476D80 proc near                    ; CODE XREF: .text:0045F8A0p
                                            ; sub_4609B0+292p ...
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+391E9h]
    push    edi
    call    sub_4353A0
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_476E56
    mov     ecx, TAdynmemStructPtr
    push    0Eh
    push    offset aSolarsystem             ; char *
    mov     edx, [ecx+531h]
    mov     edi, [edx+4]
    push    edi                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_476DE5
    mov     ecx, TAdynmemStructPtr
    mov     esi, edi
    mov     dl, [ecx+37EF2h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    inc     dl
    add     esi, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    mov     [esi+ecx*2+28h], dl

    loc_476DE5:                             ; CODE XREF: sub_476D80+3Dj
    push    0Eh
    push    offset aTextregion              ; char *
    push    edi                             ; int
    call    sub_49FDF0
    mov     esi, eax
    shl     eax, 3
    sub     eax, esi
    push    esi
    push    edi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    mov     edx, edi
    add     edx, esi
    lea     ecx, [esi+eax*4]
    mov     eax, TAdynmemStructPtr
    lea     ebx, [edx+ecx*2]
    mov     cl, [eax+37EF2h]
    inc     cl
    mov     [ebx+28h], cl
    call    sub_4A1810
    mov     eax, TAdynmemStructPtr
    mov     dword_51E650, 1
    movsx   edx, word ptr [ebx+17h]
    push    esi
    push    edx
    add     eax, 519h
    push    ebp
    push    eax
    call    sub_4AC4C0
    push    eax
    mov     dword_51E63C, eax
    call    sub_476CD0
    mov     dword_51E63C, eax
    call    sub_476EF0

    loc_476E56:                             ; CODE XREF: sub_476D80+18j
    mov     eax, TAdynmemStructPtr
    cmp     dword ptr [eax+391F1h], 6
    jz      short loc_476E7F
    mov     ecx, [eax+391E9h]
    push    3
    call    sub_4356C0
    test    eax, eax
    jz      short loc_476E7F
    push    3Ch
    push    0
    push    eax
    call    sub_47F090

    loc_476E7F:                             ; CODE XREF: sub_476D80+E2j
                                            ; sub_476D80+F3j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_476D80 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    mov     ebx, [esp+10h]
    test    ebx, ebx
    jnz     short loc_476EA1
    mov     eax, [esp+8]
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_476EA1:                             ; CODE XREF: .text:00476E97j
    mov     edx, [esp+8]
    push    edi
    push    esi
    xor     eax, eax
    mov     cl, [edx]
    xor     esi, esi
    test    cl, cl
    jz      short loc_476EDA
    mov     edi, [esp+14h]

    loc_476EB5:                             ; CODE XREF: .text:00476ED8j
    mov     cl, [edx]
    cmp     cl, 0FFh
    jz      short loc_476EDA
    test    eax, eax
    jnz     short loc_476EDA
    inc     edx
    cmp     cl, 0Ah
    jnz     short loc_476ED5
    mov     ecx, ebx
    inc     esi
    imul    ecx, edi
    cmp     esi, ecx
    jnz     short loc_476ED5
    mov     eax, 1

    loc_476ED5:                             ; CODE XREF: .text:00476EC4j
                                            ; .text:00476ECEj
    cmp     byte ptr [edx], 0
    jnz     short loc_476EB5

    loc_476EDA:                             ; CODE XREF: .text:00476EAFj
                                            ; .text:00476EBAj ...
    neg     eax
    sbb     eax, eax
    pop     esi
    pop     edi
    and     eax, edx
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_476EF0 proc near                    ; CODE XREF: .text:0045F7D8p
                                            ; sub_476D80+D1p ...

    var_AC= dword ptr -0ACh
    var_A8= dword ptr -0A8h
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= byte ptr -88h
    var_84= dword ptr -84h
    var_80= byte ptr -80h

    sub     esp, 0ACh
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+531h]
    xor     ebp, ebp
    mov     [esp+0B8h+var_94], eax
    push    edi
    mov     esi, [eax+4]
    mov     eax, dword_51E63C
    cmp     eax, ebp
    mov     [esp+0BCh+var_9C], 1
    jz      loc_477349
    cmp     dword_51E650, ebp
    jz      short loc_476F4A
    movsx   ecx, word ptr [esi+0B6h]
    mov     dword_51E66C, ecx
    mov     dword_51E64C, 0FFFFFFFFh
    mov     dword_51E650, ebp
    jmp     short loc_476F58
    ; ---------------------------------------------------------------------------

    loc_476F4A:                             ; CODE XREF: sub_476EF0+39j
    mov     dx, word ptr dword_51E66C
    mov     [esi+0B6h], dx

    loc_476F58:                             ; CODE XREF: sub_476EF0+58j
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AFEC0
    push    5
    push    offset aTextregion              ; char *
    push    esi                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4AFD20
    push    0Eh
    push    offset aTextregion              ; char *
    push    esi                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    push    eax
    shl     ecx, 3
    sub     ecx, eax
    push    esi
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, esi
    add     ecx, eax
    lea     edi, [ecx+edx*2]
    mov     edx, TAdynmemStructPtr
    mov     [esp+0CCh+var_94], edi
    mov     cl, [edx+37EF2h]
    inc     cl
    mov     [edi+28h], cl
    call    sub_4A1810
    call    sub_4C1440
    push    eax
    call    sub_4C1470
    mov     ecx, eax
    movsx   eax, word ptr [edi+19h]
    cdq
    add     ecx, 2
    idiv    ecx
    mov     [esp+0C4h+var_8C], ecx
    mov     [esp+0C4h+var_AC], eax
    movsx   eax, word ptr [edi+13h]
    add     eax, 5
    mov     [esp+0C4h+var_A0], eax
    mov     eax, ecx
    cdq
    sub     eax, edx
    movsx   edx, word ptr [edi+15h]
    mov     ebx, eax
    movsx   eax, word ptr [esi+0B6h]
    sar     ebx, 1
    mov     [esp+0C4h+var_A8], eax
    mov     eax, dword_51E64C
    add     ebx, edx
    inc     eax
    mov     dword_51E64C, eax
    jnz     short loc_477023
    mov     ecx, dword_51E63C
    mov     ebp, ecx
    jmp     short loc_477069
    ; ---------------------------------------------------------------------------

    loc_477023:                             ; CODE XREF: sub_476EF0+127j
    mov     edx, dword_51E63C
    xor     ecx, ecx
    cmp     byte ptr [edx], 0
    jz      short loc_47705D

    loc_477030:                             ; CODE XREF: sub_476EF0+16Bj
    mov     al, [edx]
    cmp     al, 0FFh
    jz      short loc_47705D
    test    ebp, ebp
    jnz     short loc_47705D
    inc     edx
    cmp     al, 0Ah
    jnz     short loc_477058
    mov     eax, [esp+0C4h+var_AC]
    inc     ecx
    imul    eax, dword_51E64C
    cmp     ecx, eax
    mov     [esp+10h], ecx
    jnz     short loc_477058
    mov     ebp, 1

    loc_477058:                             ; CODE XREF: sub_476EF0+14Dj
                                            ; sub_476EF0+161j
    cmp     byte ptr [edx], 0
    jnz     short loc_477030

    loc_47705D:                             ; CODE XREF: sub_476EF0+13Ej
                                            ; sub_476EF0+144j ...
    mov     ecx, dword_51E63C
    neg     ebp
    sbb     ebp, ebp
    and     ebp, edx

    loc_477069:                             ; CODE XREF: sub_476EF0+131j
    xor     edx, edx
    cmp     ebp, edx
    jnz     short loc_477077
    mov     dword_51E64C, edx
    mov     ebp, ecx

    loc_477077:                             ; CODE XREF: sub_476EF0+17Dj
    mov     eax, dword_51E64C
    inc     eax
    cmp     eax, edx
    jnz     short loc_477085
    mov     edx, ecx
    jmp     short loc_4770E1
    ; ---------------------------------------------------------------------------

    loc_477085:                             ; CODE XREF: sub_476EF0+18Fj
    mov     eax, dword_51E63C
    mov     [esp+10h], edx
    mov     dword ptr [esp+14h], 0
    cmp     byte ptr [eax], 0
    jz      short loc_4770DB

    loc_47709B:                             ; CODE XREF: sub_476EF0+1E9j
    mov     al, [ecx]
    cmp     al, 0FFh
    jz      short loc_4770DB
    test    edx, edx
    jnz     short loc_4770DB
    inc     ecx
    cmp     al, 0Ah
    jnz     short loc_4770D6
    mov     eax, [esp+14h]
    mov     edx, dword_51E64C
    inc     eax
    mov     [esp+14h], eax
    lea     eax, [edx+1]
    imul    eax, [esp+0C4h+var_AC]
    cmp     [esp+14h], eax
    jnz     short loc_4770D2
    mov     edx, 1
    mov     [esp+10h], edx
    jmp     short loc_4770D6
    ; ---------------------------------------------------------------------------

    loc_4770D2:                             ; CODE XREF: sub_476EF0+1D5j
    mov     edx, [esp+10h]

    loc_4770D6:                             ; CODE XREF: sub_476EF0+1B8j
                                            ; sub_476EF0+1E0j
    cmp     byte ptr [ecx], 0
    jnz     short loc_47709B

    loc_4770DB:                             ; CODE XREF: sub_476EF0+1A9j
                                            ; sub_476EF0+1AFj ...
    neg     edx
    sbb     edx, edx
    and     edx, ecx

    loc_4770E1:                             ; CODE XREF: sub_476EF0+193j
    test    edx, edx
    jnz     short loc_477125
    mov     eax, dword_51E64C
    push    edx
    test    eax, eax
    jnz     short loc_477106
    mov     eax, TAdynmemStructPtr
    push    offset Data
    add     eax, 519h
    push    offset aMorebar                 ; "MOREBAR"
    push    eax
    jmp     short loc_477144
    ; ---------------------------------------------------------------------------

    loc_477106:                             ; CODE XREF: sub_476EF0+1FDj
    push    offset aBackToStart             ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    offset aMorebar                 ; "MOREBAR"
    push    ecx
    jmp     short loc_477144
    ; ---------------------------------------------------------------------------

    loc_477125:                             ; CODE XREF: sub_476EF0+1F3j
    push    0
    push    offset aMore___                 ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    offset aMorebar                 ; "MOREBAR"
    push    edx

    loc_477144:                             ; CODE XREF: sub_476EF0+214j
                                            ; sub_476EF0+233j
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     ecx, [eax+37EF2h]
    add     eax, 519h
    mov     dl, byte_507B71[ecx*4]
    push    edx                             ; int
    push    offset aMorebar                 ; char *
    push    eax                             ; int
    call    sub_4A0C70
    mov     ecx, dword_51E64C
    mov     edx, [esp+0C4h+var_AC]
    mov     eax, edx
    imul    eax, ecx
    inc     ecx
    mov     [esp+14h], eax
    imul    ecx, edx
    cmp     eax, ecx
    jge     loc_477349
    mov     ecx, [esp+0C4h+var_A8]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    add     esi, ecx
    lea     eax, [eax+eax*2]
    lea     edx, [ecx+eax*2]
    lea     eax, [ecx+edx*4]
    lea     esi, [esi+eax*2+0B6h]
    jmp     short loc_4771B0
    ; ---------------------------------------------------------------------------

    loc_4771AC:                             ; CODE XREF: sub_476EF0+453j
    mov     edi, [esp+0C4h+var_94]

    loc_4771B0:                             ; CODE XREF: sub_476EF0+2BAj
    mov     ecx, [esp+0C4h+var_A0]
    mov     edx, [esp+0C4h+var_9C]
    push    2                               ; int
    push    0FFFFFFFFh                      ; int
    push    ebx                             ; __int16
    push    ecx                             ; int
    push    offset Data                     ; char *
    push    offset aTextregion              ; int
    push    edx                             ; int
    call    sub_4AB1B0
    add     esi, 15Bh
    mov     [esp+10h], esi
    mov     dword ptr [esi-9Bh], 411h
    mov     al, [edi+28h]
    mov     [esi-8Eh], al
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     edi, esi
    mov     edx, [ecx+37EF2h]
    mov     ecx, 20h
    mov     al, byte_507B70[edx*4]
    mov     edx, [esp+0C4h+var_8C]
    mov     [esi-97h], eax
    xor     eax, eax
    rep stosd
    mov     al, [ebp+0]
    add     ebx, edx
    cmp     al, 0Ah
    mov     [esp+0C4h+var_90], ebx
    jz      loc_47732B
    lea     ebx, [esp+0C4h+var_88]
    sub     ebx, ebp

    loc_47722C:                             ; CODE XREF: sub_476EF0+431j
    test    al, al
    jz      loc_477327
    cmp     al, 0FFh
    jz      loc_477327
    cmp     al, 26h
    jnz     loc_47730C
    mov     ecx, [esp+0C4h+var_A4]
    test    ecx, ecx
    jz      loc_4772FE
    mov     al, [ebp+1]
    inc     ebp
    dec     ebx
    cmp     al, 52h
    mov     [esp+0C4h+var_A4], 0
    jnz     short loc_477268
    mov     eax, 3
    jmp     short loc_47727D
    ; ---------------------------------------------------------------------------

    loc_477268:                             ; CODE XREF: sub_476EF0+36Fj
    cmp     al, 59h
    jnz     short loc_477273
    mov     eax, 2
    jmp     short loc_47727D
    ; ---------------------------------------------------------------------------

    loc_477273:                             ; CODE XREF: sub_476EF0+37Aj
    sub     al, 47h
    neg     al
    sbb     eax, eax
    and     eax, 2
    inc     eax

    loc_47727D:                             ; CODE XREF: sub_476EF0+376j
                                            ; sub_476EF0+381j
    mov     ecx, TAdynmemStructPtr
    inc     ebp
    push    esi
    dec     ebx
    mov     edx, [ecx+37EF2h]
    xor     ecx, ecx
    mov     cl, byte_507B70[eax+edx*4]
    mov     [esp+0C8h+var_A8], ecx
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    movsx   edx, word ptr [esi-0A1h]
    mov     edi, eax
    mov     eax, [esp+0C4h+var_A0]
    add     edi, eax
    mov     [esp+0C4h+var_98], edx
    xor     ecx, ecx
    mov     edx, ebp

    loc_4772BB:                             ; CODE XREF: sub_476EF0+3D9j
    mov     al, [edx]
    cmp     al, 26h
    jz      short loc_4772CB
    mov     [ebx+edx], al
    inc     ecx
    inc     edx
    cmp     ecx, 7Fh
    jl      short loc_4772BB

    loc_4772CB:                             ; CODE XREF: sub_476EF0+3CFj
    mov     eax, [esp+0C4h+var_A8]
    push    3E800000h                       ; int
    push    3F800000h                       ; int
    mov     [esp+ecx+0CCh+var_88], 0
    mov     ecx, [esp+0CCh+var_98]
    push    5Eh                             ; int
    push    eax                             ; int
    mov     eax, TAdynmemStructPtr
    push    ecx                             ; int
    lea     edx, [esp+0D8h+var_88]
    push    edi                             ; int
    add     eax, 519h
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4AFD80
    jmp     short loc_47730C
    ; ---------------------------------------------------------------------------

    loc_4772FE:                             ; CODE XREF: sub_476EF0+35Aj
    cmp     al, 26h
    jnz     short loc_47730C
    inc     ebp
    mov     [esp+0C4h+var_A4], 1
    dec     ebx

    loc_47730C:                             ; CODE XREF: sub_476EF0+34Ej
                                            ; sub_476EF0+40Cj ...
    mov     eax, [esp+10h]
    mov     cl, [ebp+0]
    mov     [eax], cl
    inc     eax
    inc     ebp
    mov     [esp+10h], eax
    dec     ebx
    mov     al, [ebp+0]
    cmp     al, 0Ah
    jnz     loc_47722C

    loc_477327:                             ; CODE XREF: sub_476EF0+33Ej
                                            ; sub_476EF0+346j
    mov     ebx, [esp+0C4h+var_90]

    loc_47732B:                             ; CODE XREF: sub_476EF0+330j
    mov     eax, [esp+14h]
    mov     edx, dword_51E64C
    inc     ebp
    inc     eax
    inc     edx
    mov     [esp+14h], eax
    imul    edx, [esp+0C4h+var_AC]
    cmp     eax, edx
    jl      loc_4771AC

    loc_477349:                             ; CODE XREF: sub_476EF0+2Dj
                                            ; sub_476EF0+297j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0ACh
    retn
    sub_476EF0 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_477360 proc near                    ; CODE XREF: .text:0047840Ep
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    cmp     [eax+37EF2h], ecx
    jnz     short loc_4773BF
    mov     eax, [eax+1B8Ah]
    push    1                               ; int
    push    offset aArm                     ; char *
    mov     [eax+95h], cl
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1CD5h]
    mov     byte ptr [edx+95h], 1
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_4A1110
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    add     ecx, 519h
    push    offset aSide0                   ; char *
    push    ecx                             ; int
    call    sub_4A1110
    retn
    ; ---------------------------------------------------------------------------

    loc_4773BF:                             ; CODE XREF: sub_477360+Dj
    mov     edx, [eax+1B8Ah]
    push    1                               ; int
    push    offset aCore                    ; char *
    mov     byte ptr [edx+95h], 1
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+1CD5h]
    mov     [edx+95h], cl
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_4A1110
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    add     ecx, 519h
    push    offset aSide1                   ; char *
    push    ecx                             ; int
    call    sub_4A1110
    retn
    sub_477360 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_477410 proc near                    ; CODE XREF: sub_41F0A0+276p
                                            ; sub_4604A0+E7p
    mov     eax, TAdynmemStructPtr
    push    esi
    push    offset aDifficulty              ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FF10
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EEEh]
    test    ecx, ecx
    jnz     short loc_47745B
    mov     byte ptr [esi+137h], 0
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    add     ecx, 519h
    push    offset aEasy                    ; char *
    push    ecx                             ; int
    call    sub_4A1110

    loc_47745B:                             ; CODE XREF: sub_477410+29j
    mov     edx, TAdynmemStructPtr
    cmp     dword ptr [edx+37EEEh], 1
    jnz     short loc_477488
    mov     byte ptr [esi+137h], 1
    mov     eax, TAdynmemStructPtr
    push    1                               ; int
    add     eax, 519h
    push    offset aMedium                  ; char *
    push    eax                             ; int
    call    sub_4A1110

    loc_477488:                             ; CODE XREF: sub_477410+58j
    mov     ecx, TAdynmemStructPtr
    mov     eax, 2
    cmp     [ecx+37EEEh], eax
    jnz     short loc_4774BA
    mov     [esi+137h], al
    mov     edx, TAdynmemStructPtr
    push    1                               ; int
    add     edx, 519h
    push    offset aHard                    ; char *
    push    edx                             ; int
    call    sub_4A1110

    loc_4774BA:                             ; CODE XREF: sub_477410+89j
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90
    pop     esi
    retn
    sub_477410 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 100h
    lea     eax, [esp+0]
    push    offset off_50341C
    push    offset asc_50372C               ; "*"
    push    offset aCamps                   ; "camps"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+0]
    push    0
    push    ecx
    call    sub_4BC930
    xor     edx, edx
    cmp     eax, 2
    setle   dl
    mov     eax, edx
    add     esp, 100h
    retn
    ; ---------------------------------------------------------------------------
    align 8

    loc_477510:                             ; DATA XREF: .text:004778C8o
    mov     eax, [esp+4]
    push    7
    push    offset aDrdeath                 ; "DRDEATH"
    mov     ecx, [eax+18h]
    add     ecx, 30h
    push    ecx
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short locret_477593
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+38D7Fh], 1
    jnz     short loc_47755C
    push    1
    add     eax, 519h
    push    offset aAnymsn                  ; "AnyMsn"
    push    eax
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+38D7Fh], 1
    jmp     short loc_47757C
    ; ---------------------------------------------------------------------------

    loc_47755C:                             ; CODE XREF: .text:0047753Aj
    push    0
    add     eax, 519h
    push    offset aAnymsn                  ; "AnyMsn"
    push    eax
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+38D7Fh], 0FFFEh

    loc_47757C:                             ; CODE XREF: .text:0047755Aj
    call    sub_432B60
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90

    locret_477593:                          ; CODE XREF: .text:0047752Cj
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    loc_4775A0:                             ; DATA XREF: .text:004777B8o
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      loc_477796
    push    offset aNewcamp                 ; "NewCamp"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_477601
    push    0
    call    sub_41D6A0
    test    al, al
    jz      short loc_4775F1
    call    sub_41D4C0
    push    0
    push    offset aBigbutton               ; "BigButton"
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    push    14h
    mov     byte ptr [eax+2BC0h], 0Ah
    call    sub_491C80
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4775F1:                             ; CODE XREF: .text:004775C7j
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_0          ; "Please insert the Campaign CD (Disc 2) "...
    jmp     short loc_477651
    ; ---------------------------------------------------------------------------

    loc_477601:                             ; CODE XREF: .text:004775BCj
    push    offset aSkirmish_0              ; "Skirmish"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_47767F
    push    1
    call    sub_41D6A0
    test    al, al
    jz      short loc_477643
    call    sub_41D4C0
    push    0
    push    offset aSkirmish_1              ; "skirmish"
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    push    14h
    mov     byte ptr [eax+2BC0h], 0Bh
    call    sub_491C80
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477643:                             ; CODE XREF: .text:00477619j
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_1          ; "Please insert the Multiplayer CD (Disc "...

    loc_477651:                             ; CODE XREF: .text:004775FFj
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47767F:                             ; CODE XREF: .text:0047760Ej
    push    offset aLoadgame                ; "LoadGame"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4776B0
    push    0
    push    offset aBigbutton               ; "BigButton"
    call    sub_47F1A0
    push    14h
    call    sub_491C80
    call    sub_4931D0
    push    esi
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4776B0:                             ; CODE XREF: .text:0047768Cj
    push    offset aOptions                 ; "Options"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4776E1
    push    0
    push    offset aOptions_0               ; "options"
    call    sub_47F1A0
    push    esi
    call    sub_4AB0A0
    push    14h
    call    sub_491C80
    call    sub_460160
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4776E1:                             ; CODE XREF: .text:004776BDj
    push    offset aPrevmenu_0              ; "PrevMenu"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_477713
    push    0
    push    offset aPrevious                ; "Previous"
    call    sub_47F1A0
    push    14h
    call    sub_491C80
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2BC0h], 3
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477713:                             ; CODE XREF: .text:004776EEj
    push    offset aAnymsn                  ; "AnyMsn"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_477790
    push    0
    call    sub_41D6A0
    test    al, al
    jz      short loc_477756
    call    sub_41D4C0
    push    0
    push    offset aBigbutton_0             ; "bigButton"
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    push    14h
    mov     byte ptr [ecx+2BC0h], 0Eh
    call    sub_491C80
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477756:                             ; CODE XREF: .text:0047772Bj
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_0          ; "Please insert the Campaign CD (Disc 2) "...
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477790:                             ; CODE XREF: .text:00477720j
    push    esi
    call    sub_4AB0A0

    loc_477796:                             ; CODE XREF: .text:004775A9j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    0
    add     eax, 519h
    push    offset aSingle_gui              ; "SINGLE.GUI"
    push    eax
    call    sub_4AA8F0
    mov     dword ptr [eax+8], offset loc_4775A0
    mov     ecx, TAdynmemStructPtr
    mov     [eax+0Ch], ecx
    call    sub_4257A0
    push    0
    push    0
    push    0
    push    offset aSinglebg                ; "singlebg"
    call    sub_4288D0
    mov     eax, TAdynmemStructPtr
    mov     ebx, 1
    mov     ecx, [eax+37EF2h]
    sub     ecx, 0
    jz      short loc_477844
    dec     ecx
    jnz     loc_47788D
    xor     edx, edx
    mov     dl, [eax+2A42h]
    mov     ecx, edx
    add     eax, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    mov     edx, [eax+ecx*2+1B8Ah]
    mov     [edx+95h], bl
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    add     ecx, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1CD5h]
    mov     byte ptr [ecx+95h], 0
    jmp     short loc_47788D
    ; ---------------------------------------------------------------------------

    loc_477844:                             ; CODE XREF: .text:004777F0j
    xor     edx, edx
    mov     dl, [eax+2A42h]
    mov     ecx, edx
    add     eax, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    mov     edx, [eax+ecx*2+1B8Ah]
    mov     byte ptr [edx+95h], 0
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    add     ecx, edx
    lea     eax, [eax+eax*4]
    mov     ecx, [ecx+eax*2+1CD5h]
    mov     [ecx+95h], bl

    loc_47788D:                             ; CODE XREF: .text:004777F3j
                                            ; .text:00477842j
    push    ebx
    call    sub_434AB0
    mov     eax, TAdynmemStructPtr
    test    [eax+38D7Fh], bl
    jz      short loc_4778C2
    push    ebx
    add     eax, 519h
    push    offset aAnymsn                  ; "AnyMsn"
    push    eax
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    or      [eax+38D7Fh], bx
    mov     eax, TAdynmemStructPtr

    loc_4778C2:                             ; CODE XREF: .text:0047789Ej
    mov     edx, [eax+531h]
    mov     dword ptr [edx+3Bh], offset loc_477510
    call    sub_49F580
    test    eax, eax
    jz      short loc_477906
    push    offset aSpanish                 ; "spanish"
    call    sub_49F580
    push    eax
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_477906
    mov     eax, TAdynmemStructPtr
    push    73h
    add     eax, 519h
    push    offset aSkirmish_0              ; "Skirmish"
    push    eax
    call    sub_4A1530

    loc_477906:                             ; CODE XREF: .text:004778D6j
                                            ; .text:004778EDj
    mov     ecx, TAdynmemStructPtr
    push    ebx
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    push    13h
    call    sub_491C80
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     esi, [eax+531h]
    mov     eax, dword_51E65C
    test    eax, eax
    jz      short loc_477968
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E65C, 0

    loc_477968:                             ; CODE XREF: .text:00477953j
    push    0
    push    offset aSmlbutton               ; "smlbutton"
    call    sub_47F1A0
    mov     ecx, [esp+8]
    push    ecx
    push    offset dword_51E65C
    call    sub_476A60
    mov     edx, dword_51E65C
    push    0
    push    eax
    mov     eax, TAdynmemStructPtr
    push    edx
    add     eax, 519h
    push    offset aCampaign                ; "Campaign"
    push    eax
    call    sub_4A32A0
    mov     ecx, [esi+4]
    push    2
    push    offset aCampaign                ; "Campaign"
    push    ecx
    call    sub_49FDF0
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4A2BE0
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA90
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    loc_4779E0:                             ; DATA XREF: .text:00478525o
    mov     eax, dword_51E660
    push    esi
    mov     esi, [esp+8]
    push    edi
    test    eax, eax
    mov     edi, [esi+18h]
    jz      short loc_477A05
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E660, 0

    loc_477A05:                             ; CODE XREF: .text:004779F0j
    mov     eax, TAdynmemStructPtr
    push    offset aCampaign                ; "Campaign"
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [eax+0C2h]
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435110
    mov     ecx, TAdynmemStructPtr
    push    offset dword_51E660
    mov     ecx, [ecx+391E9h]
    call    sub_435760
    mov     edx, dword_51E660
    push    0
    push    eax
    push    edx
    push    offset aMissions                ; "Missions"
    push    esi
    call    sub_4A32A0
    mov     eax, [edi+4]
    push    2
    push    offset aMissions                ; "Missions"
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A2BE0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    loc_477AB0:                             ; DATA XREF: .text:00478279o
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch]
    xor     edx, edx
    push    esi
    mov     eax, [ebp+18h]
    mov     dl, [ecx+2A42h]
    add     ecx, edx
    push    edi
    mov     esi, [eax+4]
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     edi, [ecx+eax*2]
    mov     eax, [ebp+60h]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_477B16
    mov     ecx, dword_51E65C
    push    ecx
    call    sub_4D85A0
    mov     edx, dword_51E660
    add     esp, 4
    push    edx
    call    sub_4D85A0
    add     esp, 4
    xor     ebx, ebx
    mov     dword_51E65C, ebx
    mov     dword_51E660, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477B16:                             ; CODE XREF: .text:00477AE1j
    mov     eax, dword_51E668
    xor     ebx, ebx
    cmp     eax, ebx
    jz      short loc_477B4B
    push    offset aMissions                ; "Missions"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_477B6D
    push    offset aStart                   ; "Start"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_477B6D
    cmp     dword_51E668, ebx
    jnz     loc_477CC7

    loc_477B4B:                             ; CODE XREF: .text:00477B1Fj
    push    offset aCampaign                ; "Campaign"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_477B6D
    push    offset aStart                   ; "Start"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      loc_477CC7

    loc_477B6D:                             ; CODE XREF: .text:00477B2Ej
                                            ; .text:00477B3Dj ...
    push    ebx
    push    offset aBigbutton_0             ; "bigButton"
    mov     [esp+1Ch], ebx
    call    sub_47F1A0
    push    ebx
    call    sub_41D6A0
    test    al, al
    jnz     short loc_477BC3
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_0          ; "Please insert the Campaign CD (Disc 2) "...
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477BC3:                             ; CODE XREF: .text:00477B84j
    call    sub_41D4C0
    call    sub_41DA30
    cmp     dword_507B6C, ebx
    jnz     short loc_477BF7
    push    offset aCampaign                ; "Campaign"
    push    esi
    call    sub_49FF90
    movsx   edx, word ptr [eax+0BAh]
    mov     eax, [eax+0C2h]
    push    edx
    push    eax
    call    sub_4B6AF0
    push    eax
    jmp     short loc_477C1C
    ; ---------------------------------------------------------------------------

    loc_477BF7:                             ; CODE XREF: .text:00477BD3j
    mov     edx, [edi+1B8Ah]
    cmp     [edx+95h], bl
    jnz     short loc_477C17
    mov     eax, TAdynmemStructPtr
    push    offset aArmCampaign             ; "Arm Campaign"
    mov     ecx, [eax+391E9h]
    jmp     short loc_477C28
    ; ---------------------------------------------------------------------------

    loc_477C17:                             ; CODE XREF: .text:00477C03j
    push    offset aCoreCampaign            ; "Core Campaign"

    loc_477C1C:                             ; CODE XREF: .text:00477BF5j
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]

    loc_477C28:                             ; CODE XREF: .text:00477C15j
    call    sub_435110
    cmp     dword_51E668, ebx
    jz      short loc_477C49
    push    offset aMissions                ; "Missions"
    push    esi
    call    sub_49FF90
    movsx   eax, word ptr [eax+0BAh]
    jmp     short loc_477C4D
    ; ---------------------------------------------------------------------------

    loc_477C49:                             ; CODE XREF: .text:00477C33j
    mov     eax, [esp+14h]

    loc_477C4D:                             ; CODE XREF: .text:00477C47j
    mov     edx, TAdynmemStructPtr
    push    eax
    mov     ecx, [edx+391E9h]
    call    sub_435C00
    test    eax, eax
    jz      loc_478232
    push    14h
    call    sub_491C80
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1B8Ah]
    mov     [ecx+96h], bl
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1CD5h]
    mov     byte ptr [eax+96h], 1
    call    WriteRegistrySettings_2
    cmp     dword_51E668, ebx
    jz      short loc_477CB3
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2BC0h], 10h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477CB3:                             ; CODE XREF: .text:00477C9Dj
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2BC0h], 0Fh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477CC7:                             ; CODE XREF: .text:00477B45j
                                            ; .text:00477B67j
    push    offset aPrevmenu_0              ; "PrevMenu"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      short loc_477CFB
    push    ebx
    push    offset aPrevious                ; "Previous"
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    push    14h
    mov     byte ptr [eax+2BC0h], 3
    call    sub_491C80
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477CFB:                             ; CODE XREF: .text:00477CD4j
    push    offset aDifficulty              ; "Difficulty"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      short loc_477D74
    push    ebx
    push    offset aSmlbutton_3             ; "SmlButton"
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+37EEEh]
    cmp     eax, ebx
    jnz     short loc_477D3C
    push    ebp
    mov     dword ptr [ecx+37EEEh], 1
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477D3C:                             ; CODE XREF: .text:00477D23j
    cmp     eax, 1
    jnz     short loc_477D58
    push    ebp
    mov     dword ptr [ecx+37EEEh], 2
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477D58:                             ; CODE XREF: .text:00477D3Fj
    cmp     eax, 2
    jnz     loc_478232
    push    ebp
    mov     [ecx+37EEEh], ebx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477D74:                             ; CODE XREF: .text:00477D08j
    push    offset aSide0                   ; "Side0"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jnz     loc_477FF9
    push    offset aArm                     ; "Arm"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jnz     loc_477FF9
    push    offset aSide1                   ; "Side1"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_477DBC
    push    offset aCore                    ; "Core"
    push    ebp
    call    sub_49FD60
    test    eax, eax
    jz      loc_478232

    loc_477DBC:                             ; CODE XREF: .text:00477DA7j
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    offset aCore                    ; "Core"
    push    ecx
    call    sub_4A1110
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    offset aSide1                   ; "Side1"
    push    edx
    call    sub_4A1110
    push    ebx
    push    offset aSideselect2             ; "SideSelect2"
    call    sub_47F1A0
    push    1
    push    offset aSide1                   ; "Side1"
    push    esi
    call    sub_49FDF0
    lea     ecx, [eax+eax*4]
    lea     edx, [eax+ecx*4]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, esi
    add     ecx, eax
    mov     dword ptr [ecx+edx*2+1Fh], 1Fh
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37EF2h], 1
    mov     eax, [edi+1B8Ah]
    mov     byte ptr [eax+95h], 1
    mov     ecx, [edi+1CD5h]
    mov     [ecx+95h], bl
    mov     eax, dword_507B6C
    cmp     eax, ebx
    jnz     loc_477F0E
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edi, edx
    mov     cl, [edx+2A42h]
    mov     ebp, [edx+531h]
    mov     eax, ecx
    add     edi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [edi+eax*2+1B8Ah]
    xor     eax, eax
    mov     al, [ecx+95h]
    mov     edi, eax
    mov     eax, dword_51E65C
    cmp     eax, ebx
    jz      short loc_477E9F
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E65C, ebx

    loc_477E9F:                             ; CODE XREF: .text:00477E8Ej
    push    ebx
    push    offset aSmlbutton               ; "smlbutton"
    call    sub_47F1A0
    push    edi
    push    offset dword_51E65C
    call    sub_476A60
    mov     ecx, dword_51E65C
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    eax
    push    ecx
    add     edx, 519h
    push    offset aCampaign                ; "Campaign"
    push    edx
    call    sub_4A32A0
    mov     eax, [ebp+4]
    push    2
    push    offset aCampaign                ; "Campaign"
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A2BE0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    mov     ebp, [esp+14h]

    loc_477F0E:                             ; CODE XREF: .text:00477E4Ej
    cmp     dword_51E668, ebx
    jz      loc_478232
    push    offset aCampaign                ; "Campaign"
    push    esi
    call    sub_49FF90
    mov     eax, TAdynmemStructPtr
    mov     edi, [eax+531h]
    lea     esi, [eax+519h]
    mov     eax, dword_51E660
    cmp     eax, ebx
    jz      short loc_477F4E
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E660, ebx

    loc_477F4E:                             ; CODE XREF: .text:00477F3Dj
    mov     ecx, TAdynmemStructPtr
    push    offset aCampaign                ; "Campaign"
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [eax+0C2h]
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435110
    mov     ecx, TAdynmemStructPtr
    push    offset dword_51E660
    mov     ecx, [ecx+391E9h]
    call    sub_435760
    mov     edx, dword_51E660
    push    ebx
    push    eax
    push    edx
    push    offset aMissions                ; "Missions"
    push    esi
    call    sub_4A32A0
    mov     eax, [edi+4]
    push    2
    push    offset aMissions                ; "Missions"
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A2BE0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    push    ebp
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_477FF9:                             ; CODE XREF: .text:00477D81j
                                            ; .text:00477D94j
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    offset aArm                     ; "Arm"
    push    eax
    call    sub_4A1110
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    offset aSide0                   ; "Side0"
    push    ecx
    call    sub_4A1110
    push    ebx
    push    offset aSideselect              ; "SideSelect"
    call    sub_47F1A0
    push    1
    push    offset aSide0                   ; "Side0"
    push    esi
    call    sub_49FDF0
    lea     edx, [eax+eax*4]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    mov     dword ptr [edx+ecx*2+1Fh], 1Fh
    mov     eax, TAdynmemStructPtr
    mov     [eax+37EF2h], ebx
    mov     ecx, [edi+1B8Ah]
    mov     [ecx+95h], bl
    mov     edx, [edi+1CD5h]
    xor     ecx, ecx
    mov     byte ptr [edx+95h], 1
    mov     edx, TAdynmemStructPtr
    mov     edi, edx
    mov     cl, [edx+2A42h]
    mov     ebp, [edx+531h]
    mov     eax, ecx
    add     edi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [edi+eax*2+1B8Ah]
    xor     eax, eax
    mov     al, [ecx+95h]
    mov     edi, eax
    mov     eax, dword_51E65C
    cmp     eax, ebx
    jz      short loc_4780C8
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E65C, ebx

    loc_4780C8:                             ; CODE XREF: .text:004780B7j
    push    ebx
    push    offset aSmlbutton               ; "smlbutton"
    call    sub_47F1A0
    push    edi
    push    offset dword_51E65C
    call    sub_476A60
    mov     ecx, dword_51E65C
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    eax
    push    ecx
    add     edx, 519h
    push    offset aCampaign                ; "Campaign"
    push    edx
    call    sub_4A32A0
    mov     eax, [ebp+4]
    push    2
    push    offset aCampaign                ; "Campaign"
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A2BE0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    mov     ecx, dword_507B6C
    xor     eax, eax
    cmp     ecx, ebx
    mov     ecx, [esp+14h]
    setz    al
    push    eax
    push    offset aCampaign                ; "Campaign"
    push    ecx
    call    sub_4A0570
    cmp     dword_51E668, ebx
    jz      loc_47822E
    push    offset aCampaign                ; "Campaign"
    push    esi
    call    sub_49FF90
    mov     edx, TAdynmemStructPtr
    mov     eax, dword_51E660
    cmp     eax, ebx
    mov     edi, [edx+531h]
    lea     esi, [edx+519h]
    jz      short loc_478191
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E660, ebx

    loc_478191:                             ; CODE XREF: .text:00478180j
    mov     eax, TAdynmemStructPtr
    push    offset aCampaign                ; "Campaign"
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [eax+0C2h]
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435110
    mov     ecx, TAdynmemStructPtr
    push    offset dword_51E660
    mov     ecx, [ecx+391E9h]
    call    sub_435760
    mov     edx, dword_51E660
    push    ebx
    push    eax
    push    edx
    push    offset aMissions                ; "Missions"
    push    esi
    call    sub_4A32A0
    mov     eax, [edi+4]
    push    2
    push    offset aMissions                ; "Missions"
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A2BE0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90

    loc_47822E:                             ; CODE XREF: .text:00478156j
    mov     ebp, [esp+14h]

    loc_478232:                             ; CODE XREF: .text:00477C61j
                                            ; .text:00477D5Bj ...
    push    ebp
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 100h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4257A0
    mov     eax, TAdynmemStructPtr
    mov     esi, [esp+114h]
    push    400h
    add     eax, 519h
    push    offset aNewgame_gui             ; "NEWGAME.GUI"
    push    eax
    mov     dword_51E668, esi
    call    sub_4AA8F0
    mov     ebp, [eax+4]
    mov     dword ptr [eax+8], offset loc_477AB0
    mov     ecx, TAdynmemStructPtr
    xor     ebx, ebx
    cmp     esi, ebx
    mov     [eax+0Ch], ecx
    jz      short loc_478299
    push    ebx
    push    ebx
    push    ebx
    push    offset aPlayanygame4            ; "playanygame4"
    jmp     short loc_4782E0
    ; ---------------------------------------------------------------------------

    loc_478299:                             ; CODE XREF: .text:0047828Dj
    push    offset off_50341C
    push    offset asc_50372C               ; "*"
    lea     edx, [esp+18h]
    push    offset aCamps                   ; "camps"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+10h]
    push    ebx
    push    eax
    call    sub_4BC930
    push    ebx
    cmp     eax, 2
    push    ebx
    push    ebx
    jg      short loc_4782DB
    push    offset aNewcampaign4x           ; "newcampaign4x"
    call    sub_4288D0
    mov     dword_507B6C, 1
    jmp     short loc_4782EB
    ; ---------------------------------------------------------------------------

    loc_4782DB:                             ; CODE XREF: .text:004782C3j
    push    offset aNewcampaign4            ; "newcampaign4"

    loc_4782E0:                             ; CODE XREF: .text:00478297j
    call    sub_4288D0
    mov     dword_507B6C, ebx

    loc_4782EB:                             ; CODE XREF: .text:004782D9j
    cmp     esi, ebx
    jz      loc_47838C
    push    2
    push    offset aCampaign                ; "Campaign"
    push    ebp
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    mov     edi, 134h
    mov     esi, 30h
    jz      short loc_47832E
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebp
    add     edx, eax
    lea     eax, [edx+ecx*2]
    mov     [eax+15h], di
    mov     [eax+19h], si

    loc_47832E:                             ; CODE XREF: .text:0047830Dj
    push    4
    push    offset aCampaignknob            ; "CampaignKnob"
    push    ebp
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_47835F
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebp
    add     edx, eax
    lea     eax, [edx+ecx*2]
    mov     [eax+15h], di
    mov     [eax+19h], si

    loc_47835F:                             ; CODE XREF: .text:0047833Ej
    push    2
    push    offset aMissions                ; "Missions"
    push    ebp
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_47838C
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebp
    add     edx, eax
    mov     word ptr [edx+ecx*2+19h], 3Eh

    loc_47838C:                             ; CODE XREF: .text:004782EDj
                                            ; .text:0047836Fj
    call    sub_4C2470
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    call    sub_4C2870
    mov     ecx, [ebp+0C0h]
    push    offset aSide0                   ; "Side0"
    push    ecx
    call    sub_4B8D40
    mov     esi, eax
    xor     edi, edi
    cmp     [esi], bx
    jbe     short loc_4783DB

    loc_4783C2:                             ; CODE XREF: .text:004783D9j
    push    ebx
    push    esi
    call    sub_4B7F30
    xor     edx, edx
    mov     [eax+6], bx
    mov     [eax+4], bx
    mov     dx, [esi]
    inc     edi
    cmp     edi, edx
    jl      short loc_4783C2

    loc_4783DB:                             ; CODE XREF: .text:004783C0j
    mov     eax, [ebp+0C0h]
    push    offset aSide1                   ; "Side1"
    push    eax
    call    sub_4B8D40
    mov     esi, eax
    xor     edi, edi
    cmp     [esi], bx
    jbe     short loc_47840E

    loc_4783F5:                             ; CODE XREF: .text:0047840Cj
    push    ebx
    push    esi
    call    sub_4B7F30
    xor     ecx, ecx
    mov     [eax+6], bx
    mov     [eax+4], bx
    mov     cx, [esi]
    inc     edi
    cmp     edi, ecx
    jl      short loc_4783F5

    loc_47840E:                             ; CODE XREF: .text:004783F3j
    call    sub_477360
    mov     edx, TAdynmemStructPtr
    push    offset aDifficulty              ; "Difficulty"
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx
    call    sub_49FF10
    mov     edx, TAdynmemStructPtr
    mov     esi, eax
    cmp     [edx+37EEEh], ebx
    jnz     short loc_47845A
    mov     [esi+137h], bl
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    offset aEasy                    ; "Easy"
    push    eax
    call    sub_4A1110

    loc_47845A:                             ; CODE XREF: .text:0047843Bj
    mov     ecx, TAdynmemStructPtr
    cmp     dword ptr [ecx+37EEEh], 1
    jnz     short loc_478489
    mov     byte ptr [esi+137h], 1
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    offset aMedium                  ; "Medium"
    push    edx
    call    sub_4A1110

    loc_478489:                             ; CODE XREF: .text:00478467j
    mov     eax, TAdynmemStructPtr
    cmp     dword ptr [eax+37EEEh], 2
    jnz     short loc_4784B7
    mov     byte ptr [esi+137h], 2
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    offset aHard                    ; "Hard"
    push    ecx
    call    sub_4A1110

    loc_4784B7:                             ; CODE XREF: .text:00478495j
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    cmp     dword_507B6C, ebx
    jz      short loc_4784DE
    cmp     [esp+114h], ebx
    jz      loc_478717

    loc_4784DE:                             ; CODE XREF: .text:004784CFj
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    offset aCampaign                ; "Campaign"
    push    eax
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    offset aCampaignknob            ; "CampaignKnob"
    push    ecx
    call    sub_4A0570
    push    offset aCampaign                ; "Campaign"
    push    ebp
    call    sub_49FF90
    cmp     eax, ebx
    jz      short loc_478531
    cmp     dword_51E668, ebx
    jz      short loc_478531
    mov     dword ptr [eax+0CEh], offset loc_4779E0
    jmp     short loc_478537
    ; ---------------------------------------------------------------------------

    loc_478531:                             ; CODE XREF: .text:0047851Bj
                                            ; .text:00478523j
    mov     [eax+0CEh], ebx

    loc_478537:                             ; CODE XREF: .text:0047852Fj
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     edi, [edx+531h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B8Ah]
    xor     eax, eax
    mov     al, [ecx+95h]
    mov     esi, eax
    mov     eax, dword_51E65C
    cmp     eax, ebx
    jz      short loc_478582
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E65C, ebx

    loc_478582:                             ; CODE XREF: .text:00478571j
    push    ebx
    push    offset aSmlbutton               ; "smlbutton"
    call    sub_47F1A0
    push    esi
    push    offset dword_51E65C
    call    sub_476A60
    mov     ecx, dword_51E65C
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    eax
    push    ecx
    add     edx, 519h
    push    offset aCampaign                ; "Campaign"
    push    edx
    call    sub_4A32A0
    mov     eax, [edi+4]
    push    2
    push    offset aCampaign                ; "Campaign"
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A2BE0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    cmp     [esp+114h], ebx
    jz      loc_478717
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    offset aMissions                ; "Missions"
    push    eax
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    offset aMissionsknob            ; "MissionsKnob"
    push    ecx
    call    sub_4A0570
    push    offset aMissions                ; "Missions"
    push    ebp
    call    sub_49FF90
    mov     edx, TAdynmemStructPtr
    mov     eax, dword_51E660
    cmp     eax, ebx
    mov     edi, [edx+531h]
    lea     esi, [edx+519h]
    jz      short loc_47865F
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E660, ebx

    loc_47865F:                             ; CODE XREF: .text:0047864Ej
    mov     eax, TAdynmemStructPtr
    push    offset aCampaign                ; "Campaign"
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [eax+0C2h]
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435110
    mov     ecx, TAdynmemStructPtr
    push    offset dword_51E660
    mov     ecx, [ecx+391E9h]
    call    sub_435760
    mov     edx, dword_51E660
    push    ebx
    push    eax
    push    edx
    push    offset aMissions                ; "Missions"
    push    esi
    call    sub_4A32A0
    mov     eax, [edi+4]
    push    2
    push    offset aMissions                ; "Missions"
    push    eax
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A2BE0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FA90
    cmp     [esp+114h], ebx
    jz      short loc_478717
    mov     eax, TAdynmemStructPtr
    push    offset aMissions                ; "Missions"
    add     eax, 519h
    push    eax
    jmp     short loc_478745
    ; ---------------------------------------------------------------------------

    loc_478717:                             ; CODE XREF: .text:004784D8j
                                            ; .text:004785F4j ...
    cmp     dword_507B6C, ebx
    jz      short loc_478733
    mov     ecx, TAdynmemStructPtr
    push    offset aDifficulty              ; "Difficulty"
    add     ecx, 519h
    push    ecx
    jmp     short loc_478745
    ; ---------------------------------------------------------------------------

    loc_478733:                             ; CODE XREF: .text:0047871Dj
    mov     edx, TAdynmemStructPtr
    push    offset aCampaign                ; "Campaign"
    add     edx, 519h
    push    edx

    loc_478745:                             ; CODE XREF: .text:00478715j
                                            ; .text:00478731j
    call    sub_4A76B0
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    push    13h
    call    sub_491C80
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    loc_478790:                             ; DATA XREF: .text:004793F6o
    mov     eax, TAdynmemStructPtr
    sub     esp, 58h
    mov     eax, [eax+391E9h]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+68h]
    mov     ebx, [eax+0D34h]
    mov     ebp, [eax+0D38h]
    mov     eax, dword_51E670
    mov     ecx, [esi+18h]
    dec     eax
    push    edi
    mov     edx, [ecx+4]
    test    eax, eax
    mov     edi, [edx+0BCh]
    mov     dword_51E670, eax
    jg      short loc_478810
    call    _rand
    cdq
    mov     ecx, 5
    idiv    ecx
    mov     eax, dword_51E654
    lea     eax, [eax+edx-2]
    cmp     eax, ebx
    mov     dword_51E654, eax
    jge     short loc_4787F3
    mov     eax, ebx
    mov     dword_51E654, eax

    loc_4787F3:                             ; CODE XREF: .text:004787EAj
    cmp     eax, ebp
    jle     short loc_4787FD
    mov     dword_51E654, ebp

    loc_4787FD:                             ; CODE XREF: .text:004787F5j
    call    _rand
    cdq
    mov     ecx, 3Fh
    idiv    ecx
    mov     dword_51E670, edx

    loc_478810:                             ; CODE XREF: .text:004787CBj
    mov     edx, [esi+18h]
    push    0Eh
    push    offset aSolarsystem             ; "SOLARSYSTEM"
    mov     eax, [edx+4]
    push    eax
    call    sub_49FDF0
    mov     ecx, [esi+18h]
    push    offset aSolarsystem             ; "SOLARSYSTEM"
    mov     ebx, eax
    mov     edx, [ecx+4]
    push    edx
    call    sub_4A0280
    movsx   ecx, word ptr [eax+13h]
    mov     [esp+14h], ecx
    movsx   edx, word ptr [eax+15h]
    mov     [esp+18h], edx
    movsx   ebp, word ptr [eax+17h]
    lea     ecx, [ebp+ecx-1]
    mov     [esp+1Ch], ecx
    movsx   eax, word ptr [eax+19h]
    lea     ecx, [eax+edx-1]
    xor     edx, edx
    mov     dl, [esi+8B2h]
    lea     eax, [esp+14h]
    push    edx
    push    eax
    push    edi
    mov     [esp+2Ch], ecx
    call    sub_4BF6F0
    mov     ecx, [esi+18h]
    push    ebx
    mov     edx, [ecx+4]
    push    edx
    call    sub_4A1810
    mov     eax, dword_51E654
    push    eax
    push    offset aWindSpeed               ; "Wind Speed"
    call    sub_4C5740
    push    eax
    lea     ecx, [esp+3Ch]
    push    offset aSD_0                    ; "%s : %d"
    push    ecx
    call    _sprintf
    add     esp, 10h
    call    sub_4C13F0
    mov     edx, TAdynmemStructPtr
    push    eax
    xor     ecx, ecx
    mov     eax, [edx+37EF2h]
    mov     cl, byte_507B70[eax*4]
    push    ecx
    call    sub_4C13A0
    mov     edx, [esp+1Ch]
    mov     eax, [esp+14h]
    mov     ecx, [esp+18h]
    sub     edx, eax
    sub     edx, 50h
    add     ecx, 14h
    push    edx
    add     eax, 50h
    push    ecx
    lea     edx, [esp+3Ch]
    push    eax
    push    edx
    push    edi
    call    PrintGUIText
    mov     eax, TAdynmemStructPtr
    sub     esp, 8
    mov     ecx, [eax+391E9h]
    fild    dword ptr [ecx+0D3Ch]
    fmul    ds:dbl_4FD658
    fstp    qword ptr [esp]
    push    offset aGravity_0               ; "Gravity"
    call    sub_4C5740
    push    eax
    lea     edx, [esp+40h]
    push    offset aS_1f                    ; "%s : %.1f"
    push    edx
    call    _sprintf
    mov     ecx, [esp+30h]
    add     esp, 14h
    mov     eax, [esp+14h]
    mov     edx, [esp+18h]
    sub     ecx, eax
    add     edx, 28h
    sub     ecx, 50h
    add     eax, 50h
    push    ecx
    push    edx
    push    eax
    lea     eax, [esp+40h]
    push    eax
    push    edi
    call    PrintGUIText
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4AFF00
    mov     edi, [esp+70h]
    mov     eax, [edi+0BEh]
    test    eax, eax
    jz      loc_478B30
    xor     ebx, ebx
    xor     ebp, ebp
    cmp     [eax], bx
    jbe     short loc_478992

    loc_478974:                             ; CODE XREF: .text:00478990j
    push    ebx
    push    eax
    call    sub_4B7F30
    xor     edx, edx
    xor     ecx, ecx
    mov     dx, [eax]
    mov     eax, [edi+0BEh]
    add     ebp, edx
    inc     ebx
    mov     cx, [eax]
    cmp     ebx, ecx
    jl      short loc_478974

    loc_478992:                             ; CODE XREF: .text:00478972j
    call    sub_4B6340
    cmp     dword_51E678, eax
    jge     short loc_4789CA
    mov     ax, word_51E674
    inc     ax
    movsx   edx, ax
    cmp     edx, ebp
    mov     word_51E674, ax
    jl      short loc_4789BD
    mov     word_51E674, 0

    loc_4789BD:                             ; CODE XREF: .text:004789B2j
    call    sub_4B6340
    add     eax, 2
    mov     dword_51E678, eax

    loc_4789CA:                             ; CODE XREF: .text:0047899Dj
    push    esi
    call    sub_49FAD0
    movsx   eax, word ptr [edi+13h]
    movsx   edx, word ptr [edi+17h]
    movsx   ecx, word ptr [edi+15h]
    mov     [esp+24h], eax
    lea     eax, [edx+eax-1]
    movsx   edx, word ptr [edi+19h]
    mov     [esp+2Ch], eax
    mov     [esp+28h], ecx
    lea     eax, [edx+ecx-1]
    mov     ecx, [esi+18h]
    mov     ebx, [edi+0BEh]
    mov     [esp+30h], eax
    mov     edx, [ecx+4]
    mov     ebp, [edx+0BCh]
    mov     [esp+70h], ebp
    call    sub_4B6340
    mov     ecx, eax
    mov     eax, 55555556h
    imul    ecx
    mov     ecx, edx
    mov     eax, edx
    shr     ecx, 1Fh
    add     eax, ecx
    xor     ecx, ecx
    mov     cx, [ebx]
    cdq
    idiv    ecx
    mov     [edi+0C6h], dx
    movsx   edx, dx
    push    edx
    push    ebx
    call    sub_4B7F30
    test    eax, eax
    jz      loc_478B36
    mov     eax, [edi+23h]
    xor     ecx, ecx
    lea     edx, [esp+24h]
    mov     cl, [eax+esi+8B2h]
    push    ecx
    push    edx
    push    ebp
    call    sub_4BF6F0
    movsx   ecx, word ptr [edi+15h]
    movsx   eax, word_51E674
    movsx   ebp, word ptr [edi+13h]
    mov     esi, [edi+0BEh]
    mov     [esp+10h], ecx
    xor     ecx, ecx
    sub     ebp, eax
    mov     cx, [esi]
    xor     ebx, ebx
    test    ecx, ecx
    jl      short loc_478AC4

    loc_478A84:                             ; CODE XREF: .text:00478AC2j
    mov     eax, ebx
    cdq
    idiv    ecx
    push    edx
    push    esi
    call    sub_4B7F30
    mov     esi, eax
    xor     eax, eax
    mov     edx, [esp+10h]
    mov     [esi+4], ax
    mov     [esi+6], ax
    mov     eax, [esp+70h]
    push    edx
    push    ebp
    push    esi
    push    eax
    call    sub_4B7F90
    xor     ecx, ecx
    mov     cx, [esi]
    mov     esi, [edi+0BEh]
    add     ebp, ecx
    xor     ecx, ecx
    mov     cx, [esi]
    inc     ebx
    cmp     ebx, ecx
    jle     short loc_478A84

    loc_478AC4:                             ; CODE XREF: .text:00478A82j
    mov     edx, [esp+6Ch]
    push    offset aPanmask                 ; "Panmask"
    mov     eax, [edx+18h]
    mov     ecx, [eax+4]
    mov     edx, [ecx+0C0h]
    push    edx
    call    sub_4B8D40
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [edx+2A42h]
    mov     esi, ecx
    shl     ecx, 5
    add     ecx, esi
    add     edx, esi
    lea     ecx, [ecx+ecx*4]
    mov     edx, [edx+ecx*2+1B8Ah]
    xor     ecx, ecx
    mov     cl, [edx+95h]
    push    ecx
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     edx, [esp+70h]
    push    ecx
    push    ecx
    push    eax
    push    edx
    mov     [eax+6], cx
    mov     [eax+4], cx
    call    sub_4B7F90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 58h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_478B30:                             ; CODE XREF: .text:00478965j
    push    esi
    call    sub_49FA90

    loc_478B36:                             ; CODE XREF: .text:00478A40j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 58h
    retn    8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_478B40 proc near                    ; DATA XREF: .text:00479459o

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+24h+arg_0]
    mov     esi, ds:__imp_GetTickCount
    mov     eax, [edi+18h]
    mov     ecx, [eax+4]
    mov     edx, [ecx+0BCh]
    mov     [esp+24h+var_14], edx
    call    esi ; __imp_GetTickCount
    cmp     dword_51E680, eax
    ja      loc_478CA2
    call    esi ; __imp_GetTickCount
    add     eax, 19h
    mov     dword_51E680, eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CFBA0
    xor     ebx, ebx
    test    eax, eax
    jnz     short loc_478BAD
    push    offset aShutup                  ; char *
    push    edi                             ; int
    call    sub_4A0F60
    test    eax, eax
    jz      short loc_478BAD
    push    ebx                             ; char
    push    offset aShutup                  ; char *
    push    edi                             ; int
    call    sub_4A1080
    push    edi                             ; int
    call    sub_49FA90

    loc_478BAD:                             ; CODE XREF: sub_478B40+4Aj
                                            ; sub_478B40+59j
    mov     esi, [esp+24h+arg_4]
    push    edi
    cmp     [esi+0BEh], ebx
    jz      loc_478C9D
    call    sub_49FAD0
    movsx   eax, word ptr [esi+13h]
    movsx   edx, word ptr [esi+17h]
    movsx   ecx, word ptr [esi+15h]
    mov     [esp+24h+var_10], eax
    lea     eax, [eax+edx-1]
    movsx   edx, word ptr [esi+19h]
    mov     [esp+24h+var_8], eax
    mov     [esp+24h+var_C], ecx
    lea     eax, [ecx+edx-1]
    mov     [esp+24h+var_4], eax
    call    sub_4B6340
    cmp     eax, dword_51E67C
    jz      short loc_478C10
    push    offset word_51E640
    call    sub_4B8B90
    mov     cx, word_51E640
    mov     [esi+0C6h], cx

    loc_478C10:                             ; CODE XREF: sub_478B40+B6j
    movsx   edx, word ptr [esi+0C6h]
    mov     eax, [esi+0BEh]
    push    edx
    push    eax
    call    sub_4B7F30
    mov     ebp, eax
    cmp     ebp, ebx
    jz      short loc_478CA2
    mov     [ebp+4], bx
    xor     ecx, ecx
    movsx   eax, word ptr [esi+17h]
    mov     cx, [ebp+0]
    cdq
    sub     eax, edx
    movsx   edx, word ptr [esi+13h]
    mov     edi, eax
    xor     eax, eax
    mov     ax, [ebp+2]
    mov     [ebp+6], bx
    shr     ecx, 1
    sar     edi, 1
    sub     edi, ecx
    mov     ecx, eax
    movsx   eax, word ptr [esi+19h]
    add     edi, edx
    cdq
    sub     eax, edx
    movsx   edx, word ptr [esi+15h]
    mov     ebx, eax
    mov     eax, [esi+23h]
    shr     ecx, 1
    sar     ebx, 1
    sub     ebx, ecx
    mov     esi, [esp+24h+var_14]
    add     ebx, edx
    mov     edx, [esp+24h+arg_0]
    xor     ecx, ecx
    mov     cl, [eax+edx+8B2h]
    lea     eax, [esp+24h+var_10]
    push    ecx
    push    eax
    push    esi
    call    sub_4BF6F0
    push    ebx
    push    edi
    push    ebp
    push    esi
    call    sub_4B7F90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8                               ; int
    ; ---------------------------------------------------------------------------

    loc_478C9D:                             ; CODE XREF: sub_478B40+78j
    call    sub_49FA90

    loc_478CA2:                             ; CODE XREF: sub_478B40+29j
                                            ; sub_478B40+E8j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    sub_478B40 endp

    ; ---------------------------------------------------------------------------
    align 8

    loc_478CB0:                             ; DATA XREF: .text:00478EFBo
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_478CE8
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AFCF0
    mov     ecx, dword_51E63C
    push    ecx
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51E63C, 0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_478CE8:                             ; CODE XREF: .text:00478CB9j
    push    offset aStart                   ; "Start"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_478D7D
    push    0
    push    offset aBigbutton               ; "BigButton"
    call    sub_47F1A0
    push    0
    call    sub_41D6A0
    test    al, al
    jz      short loc_478D41
    call    sub_41D4C0
    push    14h
    call    sub_491C80
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CFB40
    call    sub_4257A0
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2BC0h], 2
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_478D41:                             ; CODE XREF: .text:00478D10j
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_0          ; "Please insert the Campaign CD (Disc 2) "...
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_478D7D:                             ; CODE XREF: .text:00478CF5j
    push    offset aShutup                  ; "SHUTUP"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_478DF0
    push    0
    push    offset aOptions                 ; "Options"
    call    sub_47F1A0
    push    offset aShutup                  ; "SHUTUP"
    push    esi
    call    sub_4A0F60
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jnz     short loc_478DB6
    mov     ecx, [eax+10h]
    call    sub_4CFB40
    jmp     short loc_478DDA
    ; ---------------------------------------------------------------------------

    loc_478DB6:                             ; CODE XREF: .text:00478DAAj
    cmp     dword ptr [eax+391F1h], 6
    jz      short loc_478DDA
    mov     ecx, [eax+391E9h]
    push    3
    call    sub_4356C0
    test    eax, eax
    jz      short loc_478DDA
    push    3Ch
    push    0
    push    eax
    call    sub_47F090

    loc_478DDA:                             ; CODE XREF: .text:00478DB4j
                                            ; .text:00478DBDj ...
    push    esi
    call    sub_4AB0A0
    push    0
    push    offset aSmallbutton             ; "SmallButton"
    call    sub_47F1A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_478DF0:                             ; CODE XREF: .text:00478D8Aj
    push    offset aPrevmenu_0              ; "PrevMenu"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_478E36
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CFB40
    push    0
    push    offset aPrevious                ; "Previous"
    call    sub_47F1A0
    call    sub_4257A0
    mov     edx, TAdynmemStructPtr
    push    14h
    mov     byte ptr [edx+2BC0h], 3
    call    sub_491C80
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_478E36:                             ; CODE XREF: .text:00478DFDj
    push    offset aTextregion              ; "TextRegion"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_478E54
    push    offset aMorebar                 ; "MOREBAR"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_478E74

    loc_478E54:                             ; CODE XREF: .text:00478E43j
    mov     eax, dword_51E63C
    test    eax, eax
    jz      short loc_478E74
    push    0
    push    offset aMore                    ; "More"
    call    sub_47F1A0
    call    sub_476EF0
    push    esi
    call    sub_49FA90

    loc_478E74:                             ; CODE XREF: .text:00478E52j
                                            ; .text:00478E5Bj
    push    esi
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    sub     esp, 114h
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    push    ebx
    shl     eax, 5
    push    ebp
    push    esi
    add     eax, ecx
    mov     esi, edx
    add     esi, ecx
    push    edi
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B8Ah]
    xor     eax, eax
    mov     al, [ecx+95h]
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    lea     eax, [esp+110h]
    lea     edx, [edx+ecx*2+37F5Bh]
    push    edx
    push    offset aMbriefS                 ; "mbrief%s"
    push    eax
    call    _sprintf
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    add     ecx, 519h
    push    80h
    push    offset aMsnbrief_gui            ; "MSNBRIEF.GUI"
    push    ecx
    call    sub_4AA8F0
    mov     dword ptr [eax+8], offset loc_478CB0
    mov     edx, TAdynmemStructPtr
    mov     [eax+0Ch], edx
    push    0
    push    1
    lea     eax, [esp+118h]
    push    1
    push    eax
    call    sub_4288D0
    mov     eax, TAdynmemStructPtr
    lea     ecx, [eax+5CBh]
    lea     edx, [eax+143A7h]
    push    ecx
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4AC7D0
    mov     eax, TAdynmemStructPtr
    mov     edi, offset aStart              ; "Start"
    mov     ecx, [eax+531h]
    xor     eax, eax
    mov     ebp, [ecx+4]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [ebp+0CCh]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [ebp+0DCh]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, offset aPrevmenu_0         ; "PrevMenu"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    0Eh
    and     ecx, 3
    push    offset aMorebar                 ; "MOREBAR"
    rep movsb
    push    ebp
    call    sub_49FDF0
    lea     ecx, [eax+eax*4]
    push    0Eh
    push    offset aTextregion              ; "TextRegion"
    push    ebp
    lea     edx, [eax+ecx*4]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebp
    add     ecx, eax
    mov     esi, [ecx+edx*2+1Bh]
    lea     eax, [ecx+edx*2+1Bh]
    and     esi, 0FFFFFFEFh
    mov     [eax], esi
    call    sub_49FDF0
    lea     edx, [eax+eax*4]
    push    0
    push    offset aSolarsystem             ; "SOLARSYSTEM"
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebp
    add     edx, eax
    mov     edi, [edx+ecx*2+1Bh]
    lea     eax, [edx+ecx*2+1Bh]
    and     edi, 0FFFFFFEFh
    mov     [eax], edi
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    offset aShutup                  ; "SHUTUP"
    push    ecx
    call    sub_4A1080
    mov     edx, TAdynmemStructPtr
    mov     esi, [edx+391E9h]
    mov     edi, [esi+0D34h]
    call    _rand
    mov     ecx, [esi+0D38h]
    sub     ecx, edi
    cdq
    inc     ecx
    idiv    ecx
    add     edx, edi
    mov     dword_51E654, edx
    call    _rand
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 3Fh
    xor     eax, edx
    sub     eax, edx
    mov     edx, TAdynmemStructPtr
    mov     dword_51E670, eax
    mov     ecx, [edx+391E9h]
    call    sub_435910
    mov     edx, eax
    mov     esi, offset aLunar              ; "Lunar"

    loc_479077:                             ; CODE XREF: .text:00479095j
    mov     bl, [eax]
    mov     cl, bl
    cmp     bl, [esi]
    jnz     short loc_47909B
    test    cl, cl
    jz      short loc_479097
    mov     bl, [eax+1]
    mov     cl, bl
    cmp     bl, [esi+1]
    jnz     short loc_47909B
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_479077

    loc_479097:                             ; CODE XREF: .text:00479081j
    xor     eax, eax
    jmp     short loc_4790A0
    ; ---------------------------------------------------------------------------

    loc_47909B:                             ; CODE XREF: .text:0047907Dj
                                            ; .text:0047908Bj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4790A0:                             ; CODE XREF: .text:00479099j
    test    eax, eax
    jnz     short loc_4790DD
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EF2h]
    test    ecx, ecx
    jz      short loc_4790DD
    mov     edi, offset a2                  ; "2"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb

    loc_4790DD:                             ; CODE XREF: .text:004790A2j
                                            ; .text:004790B1j
    mov     ecx, offset aGreenbrief         ; "Greenbrief"
    xor     ebx, ebx
    xor     edi, edi
    mov     dword ptr [esp+50h], offset aGreenPlanet ; "Green planet"
    test    ecx, ecx
    mov     dword ptr [esp+54h], offset aArchipelago ; "Archipelago"
    mov     dword ptr [esp+58h], offset aWetDesert ; "Wet Desert"
    mov     dword ptr [esp+5Ch], offset aDesert ; "Desert"
    mov     dword ptr [esp+60h], offset aLava ; "Lava"
    mov     dword ptr [esp+64h], offset aRedPlanet ; "Red Planet"
    mov     dword ptr [esp+68h], offset aLunar ; "Lunar"
    mov     dword ptr [esp+6Ch], offset aMetal ; "Metal"
    mov     dword ptr [esp+70h], offset aLunar2 ; "Lunar2"
    mov     dword ptr [esp+74h], offset aIce ; "Ice"
    mov     dword ptr [esp+78h], offset aLush ; "Lush"
    mov     dword ptr [esp+7Ch], offset aSlate ; "Slate"
    mov     dword ptr [esp+80h], offset aWaterWorld ; "Water World"
    mov     dword ptr [esp+84h], offset aAcid ; "Acid"
    mov     dword ptr [esp+88h], offset aCrystal ; "Crystal"
    mov     [esp+8Ch], ebx
    mov     dword ptr [esp+10h], offset aGreenbrief ; "Greenbrief"
    mov     dword ptr [esp+14h], offset aArchibrief ; "Archibrief"
    mov     dword ptr [esp+18h], offset aWdesertbrief ; "WDesertbrief"
    mov     dword ptr [esp+1Ch], offset aDesertbrief ; "Desertbrief"
    mov     dword ptr [esp+20h], offset aLavabrief ; "Lavabrief"
    mov     dword ptr [esp+24h], offset aMarsbrief ; "Marsbrief"
    mov     dword ptr [esp+28h], offset aLunarbrief ; "Lunarbrief"
    mov     dword ptr [esp+2Ch], offset aMetalbrief ; "Metalbrief"
    mov     dword ptr [esp+30h], offset aLunar2brief ; "Lunar2brief"
    mov     dword ptr [esp+34h], offset aIcebrief ; "Icebrief"
    mov     dword ptr [esp+38h], offset aLushbrief ; "Lushbrief"
    mov     dword ptr [esp+3Ch], offset aSlatebrief ; "Slatebrief"
    mov     dword ptr [esp+40h], offset aWaterbrief ; "Waterbrief"
    mov     dword ptr [esp+44h], offset aAcidbrief ; "Acidbrief"
    mov     dword ptr [esp+48h], offset aCrystalbrief ; "Crystalbrief"
    mov     [esp+4Ch], ebx
    mov     dword ptr [esp+90h], offset aGreenpan ; "GreenPan"
    mov     dword ptr [esp+94h], offset aArchipan ; "ArchiPan"
    mov     dword ptr [esp+98h], offset aWdespan ; "WDesPan"
    mov     dword ptr [esp+9Ch], offset aDdespan ; "DDesPan"
    mov     dword ptr [esp+0A0h], offset aLavapan ; "LavaPan"
    mov     dword ptr [esp+0A4h], offset aMarspan ; "MarsPan"
    mov     dword ptr [esp+0A8h], offset aLunarpan ; "LunarPan"
    mov     dword ptr [esp+0ACh], offset aMetalpan ; "MetalPan"
    mov     dword ptr [esp+0B0h], offset aLunar2pan ; "Lunar2Pan"
    mov     dword ptr [esp+0B4h], offset aIcepan ; "IcePan"
    mov     dword ptr [esp+0B8h], offset aLushpan ; "LushPan"
    mov     dword ptr [esp+0BCh], offset aSlatepan ; "SlatePan"
    mov     dword ptr [esp+0C0h], offset aWaterpan ; "WaterPan"
    mov     dword ptr [esp+0C4h], offset aAcidpan ; "AcidPan"
    mov     dword ptr [esp+0C8h], offset aCrystpan ; "CrystPan"
    mov     [esp+0CCh], ebx
    mov     dword ptr [esp+0D0h], offset aGreenrotate ; "GreenRotate"
    mov     dword ptr [esp+0D4h], offset aArchirotate ; "ArchiRotate"
    mov     dword ptr [esp+0D8h], offset aWdesertrotate ; "WDesertRotate"
    mov     dword ptr [esp+0DCh], offset aDdesrotate ; "DDesRotate"
    mov     dword ptr [esp+0E0h], offset aLavarotate ; "LavaRotate"
    mov     dword ptr [esp+0E4h], offset aMarsrotate ; "MarsRotate"
    mov     dword ptr [esp+0E8h], offset aLunarrotate ; "LunarRotate"
    mov     dword ptr [esp+0ECh], offset aMetalrotate ; "MetalRotate"
    mov     dword ptr [esp+0F0h], offset aLunar2rotate ; "Lunar2Rotate"
    mov     dword ptr [esp+0F4h], offset aIcerotate ; "IceRotate"
    mov     dword ptr [esp+0F8h], offset aLushrotate ; "LushRotate"
    mov     dword ptr [esp+0FCh], offset aSlaterotate ; "SlateRotate"
    mov     dword ptr [esp+100h], offset aWaterrotate ; "WaterRotate"
    mov     dword ptr [esp+104h], offset aAcidrotate ; "AcidRotate"
    mov     dword ptr [esp+108h], offset aCrystalrotate ; "CrystalRotate"
    mov     [esp+10Ch], ebx
    jz      short loc_479384

    loc_479346:                             ; CODE XREF: .text:00479382j
    mov     esi, [esp+edi*4+50h]
    mov     eax, edx

    loc_47934C:                             ; CODE XREF: .text:0047936Aj
    mov     bl, [eax]
    mov     cl, bl
    cmp     bl, [esi]
    jnz     short loc_479370
    test    cl, cl
    jz      short loc_47936C
    mov     bl, [eax+1]
    mov     cl, bl
    cmp     bl, [esi+1]
    jnz     short loc_479370
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_47934C

    loc_47936C:                             ; CODE XREF: .text:00479356j
    xor     eax, eax
    jmp     short loc_479375
    ; ---------------------------------------------------------------------------

    loc_479370:                             ; CODE XREF: .text:00479352j
                                            ; .text:00479360j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_479375:                             ; CODE XREF: .text:0047936Ej
    xor     ebx, ebx
    cmp     eax, ebx
    jz      short loc_479384
    mov     eax, [esp+edi*4+14h]
    inc     edi
    cmp     eax, ebx
    jnz     short loc_479346

    loc_479384:                             ; CODE XREF: .text:00479344j
                                            ; .text:00479379j
    cmp     [esp+edi*4+10h], ebx
    jnz     short loc_47938C
    xor     edi, edi

    loc_47938C:                             ; CODE XREF: .text:00479388j
    mov     eax, TAdynmemStructPtr
    shl     edi, 2
    add     eax, 519h
    mov     edx, [esp+edi+10h]
    push    edx
    push    eax
    call    sub_4A75D0
    test    eax, eax
    jz      loc_479463
    push    6
    push    offset aPanorama                ; "PANORAMA"
    push    ebp
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_479400
    lea     ecx, [eax+eax*4]
    lea     edx, [eax+ecx*4]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebp
    add     ecx, eax
    lea     esi, [ecx+edx*2]
    mov     edx, [esp+edi+90h]
    push    edx
    mov     [esi+0C6h], bx
    mov     eax, [ebp+0C0h]
    push    eax
    call    sub_4B8D40
    cmp     eax, ebx
    jz      short loc_479400
    mov     [esi+0BEh], eax
    mov     dword ptr [esi+0B6h], offset loc_478790

    loc_479400:                             ; CODE XREF: .text:004793BCj
                                            ; .text:004793EEj
    push    6
    push    offset aPlanet_0                ; "PLANET"
    push    ebp
    call    sub_49FDF0
    mov     esi, eax
    cmp     esi, 0FFFFFFFFh
    jz      short loc_479463
    mov     ecx, [esp+edi+0D0h]
    mov     edx, [ebp+0C0h]
    push    ecx
    push    edx
    call    sub_4B8D40
    mov     edi, eax
    cmp     edi, ebx
    jz      short loc_479463
    push    ebx
    push    edi
    push    offset word_51E640
    call    sub_4B8B30
    lea     eax, [esi+esi*4]
    add     ebp, esi
    lea     ecx, [esi+eax*4]
    lea     edx, [esi+ecx*2]
    lea     eax, [esi+edx*4]
    lea     eax, [ebp+eax*2+0]
    mov     [eax+0C6h], bx
    mov     [eax+0BEh], edi
    mov     dword ptr [eax+0B6h], offset sub_478B40

    loc_479463:                             ; CODE XREF: .text:004793A6j
                                            ; .text:00479412j ...
    mov     ecx, TAdynmemStructPtr
    push    ebx
    add     ecx, 519h
    push    offset aSolarsystem             ; "SOLARSYSTEM"
    push    ecx
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    push    0Fh
    add     edx, 519h
    push    edx
    call    sub_4AFC60
    call    sub_476D80
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_49FB10
    mov     ecx, TAdynmemStructPtr
    push    0C0h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    push    13h
    call    sub_491C80
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 114h
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     edx, [ecx+38D81h]
    test    edx, edx
    jle     short locret_4794F4
    mov     ecx, [ecx+29A0h]

    loc_4794E8:                             ; CODE XREF: .text:004794F2j
    cmp     dword ptr [ecx], 2
    jnz     short loc_4794EE
    inc     eax

    loc_4794EE:                             ; CODE XREF: .text:004794EBj
    add     ecx, 18h
    dec     edx
    jnz     short loc_4794E8

    locret_4794F4:                          ; CODE XREF: .text:004794E0j
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     edx, [ecx+38D81h]
    test    edx, edx
    jle     short locret_479524
    mov     ecx, [ecx+29A0h]

    loc_479518:                             ; CODE XREF: .text:00479522j
    cmp     dword ptr [ecx], 1
    jnz     short loc_47951E
    inc     eax

    loc_47951E:                             ; CODE XREF: .text:0047951Bj
    add     ecx, 18h
    dec     edx
    jnz     short loc_479518

    locret_479524:                          ; CODE XREF: .text:00479510j
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     edx, [ecx+38D81h]
    test    edx, edx
    jle     short loc_479555
    mov     ecx, [ecx+29A0h]

    loc_479548:                             ; CODE XREF: .text:00479553j
    cmp     dword ptr [ecx], 0
    jz      short locret_479558
    inc     eax
    add     ecx, 18h
    cmp     eax, edx
    jl      short loc_479548

    loc_479555:                             ; CODE XREF: .text:00479540j
    or      eax, 0FFFFFFFFh

    locret_479558:                          ; CODE XREF: .text:0047954Bj
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, TAdynmemStructPtr
    mov     eax, 1
    mov     edx, [ecx+38D81h]
    test    edx, edx
    jle     short locret_479588
    mov     ecx, [ecx+29A0h]

    loc_47957B:                             ; CODE XREF: .text:00479586j
    cmp     dword ptr [ecx], 0
    jz      short loc_479582
    xor     eax, eax

    loc_479582:                             ; CODE XREF: .text:0047957Ej
    add     ecx, 18h
    dec     edx
    jnz     short loc_47957B

    locret_479588:                          ; CODE XREF: .text:00479573j
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    push    esi
    mov     edx, [ecx+38D81h]
    push    edi
    test    edx, edx
    jle     short loc_4795D9
    mov     ecx, [ecx+29A0h]
    mov     esi, [esp+10h]
    mov     edi, [esp+0Ch]

    loc_4795B2:                             ; CODE XREF: .text:004795C6j
    cmp     [ecx+14h], edi
    jnz     short loc_4795C0
    cmp     dword ptr [ecx], 0
    jz      short loc_4795C0
    cmp     eax, esi
    jnz     short loc_4795CF

    loc_4795C0:                             ; CODE XREF: .text:004795B5j
                                            ; .text:004795BAj
    inc     eax
    add     ecx, 18h
    cmp     eax, edx
    jl      short loc_4795B2
    xor     eax, eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4795CF:                             ; CODE XREF: .text:004795BEj
    mov     eax, 1
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4795D9:                             ; CODE XREF: .text:004795A2j
    pop     edi
    pop     esi
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    xor     eax, eax
    mov     esi, [edi+38D81h]

    loc_4795F0:                             ; CODE XREF: .text:00479613j
    xor     edx, edx
    test    esi, esi
    jle     short loc_47960B
    mov     ecx, [edi+29A0h]
    add     ecx, 14h

    loc_4795FF:                             ; CODE XREF: .text:00479609j
    cmp     [ecx], eax
    jz      short loc_47960B
    inc     edx
    add     ecx, 18h
    cmp     edx, esi
    jl      short loc_4795FF

    loc_47960B:                             ; CODE XREF: .text:004795F4j
                                            ; .text:00479601j
    cmp     edx, esi
    jz      short loc_479618
    inc     eax
    cmp     eax, 0Ah
    jl      short loc_4795F0
    or      eax, 0FFFFFFFFh

    loc_479618:                             ; CODE XREF: .text:0047960Dj
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     edx, [ecx+38D81h]
    test    edx, edx
    jle     short locret_47964F
    mov     ecx, [ecx+29A0h]
    push    esi
    mov     esi, [esp+8]

    loc_47963D:                             ; CODE XREF: .text:0047964Cj
    cmp     [ecx+8], esi
    jnz     short loc_479648
    cmp     dword ptr [ecx], 0
    jz      short loc_479648
    inc     eax

    loc_479648:                             ; CODE XREF: .text:00479640j
                                            ; .text:00479645j
    add     ecx, 18h
    dec     edx
    jnz     short loc_47963D
    pop     esi

    locret_47964F:                          ; CODE XREF: .text:00479630j
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_479660 proc near                    ; CODE XREF: sub_4797E0+3F8p
                                            ; sub_47A0E0+3D7p ...

    var_44= dword ptr -44h
    var_40= byte ptr -40h

    mov     eax, TAdynmemStructPtr
    sub     esp, 44h
    mov     ecx, [eax+531h]
    push    ebx
    push    ebp
    xor     ebx, ebx
    mov     ebp, [ecx+4]
    mov     ecx, [eax+38D81h]
    cmp     ecx, ebx
    jle     loc_479748
    push    edi
    push    esi
    mov     [esp+54h+var_44], ebx

    loc_479689:                             ; CODE XREF: sub_479660+E0j
    push    ebx
    lea     edx, [esp+58h+var_40]
    push    offset aAlliesD                 ; LPCSTR
    push    edx                             ; LPSTR
    call    ds:wsprintfA
    add     esp, 0Ch
    lea     eax, [esp+54h+var_40]
    push    6
    push    eax                             ; char *
    push    ebp                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_479727
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebp
    add     edx, eax
    lea     edi, [edx+ecx*2]
    test    edi, edi
    jz      short loc_479727
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+10h]
    xor     esi, esi
    mov     eax, [ecx+29A0h]
    mov     ecx, [ecx+38D81h]
    test    ecx, ecx
    mov     edx, [edx+eax+8]
    jle     short loc_4796FB

    loc_4796EA:                             ; CODE XREF: sub_479660+99j
    cmp     [eax+8], edx
    jnz     short loc_4796F5
    cmp     dword ptr [eax], 0
    jz      short loc_4796F5
    inc     esi

    loc_4796F5:                             ; CODE XREF: sub_479660+8Dj
                                            ; sub_479660+92j
    add     eax, 18h
    dec     ecx
    jnz     short loc_4796EA

    loc_4796FB:                             ; CODE XREF: sub_479660+88j
    mov     eax, esi
    sub     eax, 0
    jz      short loc_47971E
    dec     eax
    jz      short loc_479711
    lea     eax, [edx+edx]
    mov     [edi+0C6h], ax
    jmp     short loc_479727
    ; ---------------------------------------------------------------------------

    loc_479711:                             ; CODE XREF: sub_479660+A3j
    lea     ecx, [edx+edx+1]
    mov     [edi+0C6h], cx
    jmp     short loc_479727
    ; ---------------------------------------------------------------------------

    loc_47971E:                             ; CODE XREF: sub_479660+A0j
    mov     word ptr [edi+0C6h], 0Ah

    loc_479727:                             ; CODE XREF: sub_479660+4Dj
                                            ; sub_479660+68j ...
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+10h]
    inc     ebx
    add     edx, 18h
    mov     ecx, [eax+38D81h]
    mov     [esp+10h], edx
    cmp     ebx, ecx
    jl      loc_479689
    pop     esi
    pop     edi

    loc_479748:                             ; CODE XREF: sub_479660+1Dj
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn
    sub_479660 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_479760 proc near                    ; CODE XREF: sub_47AE60+1D5p

    var_4= dword ptr -4

    push    ecx
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edx, [edi+38D81h]
    test    edx, edx
    jle     short loc_479796
    mov     eax, [edi+29A0h]
    mov     esi, [esp+0Ch+var_4]

    loc_47977F:                             ; CODE XREF: sub_479760+32j
    cmp     dword ptr [eax], 0
    jz      short loc_47978C
    mov     esi, [eax+8]
    cmp     esi, 5
    jnz     short loc_47979A

    loc_47978C:                             ; CODE XREF: sub_479760+22j
    inc     ecx
    add     eax, 18h
    cmp     ecx, edx
    jl      short loc_47977F
    jmp     short loc_47979A
    ; ---------------------------------------------------------------------------

    loc_479796:                             ; CODE XREF: sub_479760+13j
    mov     esi, [esp+0Ch+var_4]

    loc_47979A:                             ; CODE XREF: sub_479760+2Aj
                                            ; sub_479760+34j
    cmp     ecx, edx
    jnz     short loc_4797A4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4797A4:                             ; CODE XREF: sub_479760+3Cj
    xor     ecx, ecx
    test    edx, edx
    jle     short loc_4797D1
    mov     eax, [edi+29A0h]

    loc_4797B0:                             ; CODE XREF: sub_479760+60j
    cmp     [eax+8], esi
    jz      short loc_4797BA
    cmp     dword ptr [eax], 0
    jnz     short loc_4797CB

    loc_4797BA:                             ; CODE XREF: sub_479760+53j
    inc     ecx
    add     eax, 18h
    cmp     ecx, edx
    jl      short loc_4797B0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4797CB:                             ; CODE XREF: sub_479760+58j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4797D1:                             ; CODE XREF: sub_479760+48j
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ecx
    retn
    sub_479760 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4797E0 proc near                    ; CODE XREF: sub_47AE60+318p

    var_88= dword ptr -88h
    var_84= byte ptr -84h
    var_80= byte ptr -80h
    var_40= byte ptr -40h
    arg_0= dword ptr  4

    sub     esp, 88h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+94h+arg_0]
    push    edi
    mov     edi, ds:wsprintfA
    push    esi
    lea     eax, [esp+9Ch+var_80]
    push    offset aPlayerD_0               ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     ebp, TAdynmemStructPtr
    lea     ebx, [esi+esi*2]
    shl     ebx, 3
    mov     eax, [ebp+29A0h]
    add     esp, 0Ch
    mov     [esp+98h+var_88], ebx
    mov     ecx, [eax+ebx]
    sub     ecx, 0
    jz      loc_4798C2
    dec     ecx
    jz      short loc_47989A
    dec     ecx
    jnz     loc_4798F3
    mov     edx, [ebp+38D81h]
    xor     ebx, ebx
    test    edx, edx
    jle     short loc_47984D
    mov     ecx, eax

    loc_479841:                             ; CODE XREF: sub_4797E0+6Bj
    cmp     dword ptr [ecx], 1
    jnz     short loc_479847
    inc     ebx

    loc_479847:                             ; CODE XREF: sub_4797E0+64j
    add     ecx, 18h
    dec     edx
    jnz     short loc_479841

    loc_47984D:                             ; CODE XREF: sub_4797E0+5Dj
    mov     ecx, [esp+98h+var_88]
    test    ebx, ebx
    jnz     short loc_479865
    push    0
    mov     dword ptr [eax+ecx], 1
    push    offset aPlayer                  ; "Player"
    jmp     short loc_479873
    ; ---------------------------------------------------------------------------

    loc_479865:                             ; CODE XREF: sub_4797E0+73j
    push    0
    mov     dword ptr [eax+ecx], 0
    push    offset aOpen_0                  ; int

    loc_479873:                             ; CODE XREF: sub_4797E0+83j
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+0A0h+var_80]
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4A0BF0
    mov     ebp, TAdynmemStructPtr
    mov     ebx, [esp+98h+var_88]
    jmp     short loc_4798F3
    ; ---------------------------------------------------------------------------

    loc_47989A:                             ; CODE XREF: sub_4797E0+4Aj
    push    0
    push    offset aOpen_0                  ; int
    mov     dword ptr [eax+ebx], 0
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+9Ch+var_80]
    push    eax
    add     edx, 519h
    push    ecx
    push    edx
    jmp     short loc_4798E8
    ; ---------------------------------------------------------------------------

    loc_4798C2:                             ; CODE XREF: sub_4797E0+43j
    push    0
    push    offset aComputer_0              ; int
    mov     dword ptr [eax+ebx], 2
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    lea     eax, [esp+0A0h+var_80]
    add     ecx, 519h
    push    eax
    push    ecx

    loc_4798E8:                             ; CODE XREF: sub_4797E0+E0j
    call    sub_4A0BF0
    mov     ebp, TAdynmemStructPtr

    loc_4798F3:                             ; CODE XREF: sub_4797E0+4Dj
                                            ; sub_4797E0+B8j
    mov     ecx, [ebp+29A0h]
    cmp     dword ptr [ecx+ebx], 0
    jnz     loc_4799F9
    push    esi
    lea     edx, [esp+9Ch+var_80]
    push    offset aPlayerD_0               ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+98h+var_80]
    add     ecx, 519h
    push    1                               ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    push    esi
    lea     edx, [esp+9Ch+var_80]
    push    offset aSideD_0                 ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+98h+var_80]
    add     ecx, 519h
    push    0                               ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    push    esi
    lea     edx, [esp+9Ch+var_80]
    push    offset aAlliesD                 ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+98h+var_80]
    add     ecx, 519h
    push    0                               ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    push    esi
    lea     edx, [esp+9Ch+var_80]
    push    offset aMetalD                  ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+98h+var_80]
    add     ecx, 519h
    push    0                               ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    push    esi
    lea     edx, [esp+9Ch+var_80]
    push    offset aEnergyD                 ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+98h+var_80]
    add     ecx, 519h
    push    0                               ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    sub_4A0570
    push    esi
    lea     edx, [esp+9Ch+var_80]
    push    offset aColorD                  ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+98h+var_80]
    add     ecx, 519h
    push    0
    push    eax
    push    ecx
    jmp     loc_479BD3
    ; ---------------------------------------------------------------------------

    loc_4799F9:                             ; CODE XREF: sub_4797E0+11Dj
    mov     edx, [ebp+38D81h]
    xor     eax, eax
    test    edx, edx
    jle     loc_479AE2
    mov     ebx, [ecx+ebx+14h]

    loc_479A0D:                             ; CODE XREF: sub_4797E0+241j
    cmp     [ecx+14h], ebx
    jnz     short loc_479A1B
    cmp     dword ptr [ecx], 0
    jz      short loc_479A1B
    cmp     eax, esi
    jnz     short loc_479A28

    loc_479A1B:                             ; CODE XREF: sub_4797E0+230j
                                            ; sub_4797E0+235j
    inc     eax
    add     ecx, 18h
    cmp     eax, edx
    jl      short loc_479A0D
    jmp     loc_479AE2
    ; ---------------------------------------------------------------------------

    loc_479A28:                             ; CODE XREF: sub_4797E0+239j
    mov     edx, [ebp+531h]
    xor     ebx, ebx
    mov     eax, [edx+4]
    mov     edx, [ebp+38D81h]
    mov     dword ptr [esp+98h+var_84], eax

    loc_479A3D:                             ; CODE XREF: sub_4797E0+282j
    xor     ecx, ecx
    test    edx, edx
    jle     short loc_479A58
    mov     eax, [ebp+29A0h]
    add     eax, 14h

    loc_479A4C:                             ; CODE XREF: sub_4797E0+276j
    cmp     [eax], ebx
    jz      short loc_479A58
    inc     ecx
    add     eax, 18h
    cmp     ecx, edx
    jl      short loc_479A4C

    loc_479A58:                             ; CODE XREF: sub_4797E0+261j
                                            ; sub_4797E0+26Ej
    cmp     ecx, edx
    jz      short loc_479A64
    inc     ebx
    cmp     ebx, 0Ah
    jge     short loc_479A68
    jmp     short loc_479A3D
    ; ---------------------------------------------------------------------------

    loc_479A64:                             ; CODE XREF: sub_4797E0+27Aj
    mov     eax, ebx
    jmp     short loc_479A6B
    ; ---------------------------------------------------------------------------

    loc_479A68:                             ; CODE XREF: sub_4797E0+280j
    or      eax, 0FFFFFFFFh

    loc_479A6B:                             ; CODE XREF: sub_4797E0+286j
    mov     ecx, [ebp+29A0h]
    mov     ebp, [esp+98h+var_88]
    push    esi
    lea     edx, [esp+9Ch+var_40]
    push    offset aColorD                  ; LPCSTR
    push    edx                             ; LPSTR
    mov     [ebp+ecx+14h], eax
    call    edi ; wsprintfA
    mov     ebx, dword ptr [esp+0A4h+var_84]
    add     esp, 0Ch
    lea     eax, [esp+98h+var_40]
    push    6
    push    eax                             ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_479AE2
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     eax, [ebx+ecx*2]
    test    eax, eax
    jz      short loc_479AE2
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+148DBh]
    mov     [eax+0BEh], ecx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+29A0h]
    mov     dx, [ecx+ebp+14h]
    mov     [eax+0C6h], dx

    loc_479AE2:                             ; CODE XREF: sub_4797E0+223j
                                            ; sub_4797E0+243j ...
    push    esi
    lea     eax, [esp+0A0h+var_84]
    push    offset aPlayerD_0               ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+9Ch+var_84]
    add     edx, 519h
    push    1                               ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A0570
    push    esi
    lea     eax, [esp+0A0h+var_84]
    push    offset aSideD_0                 ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+9Ch+var_84]
    add     edx, 519h
    push    1                               ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A0570
    push    esi
    lea     eax, [esp+0A0h+var_84]
    push    offset aAlliesD                 ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+9Ch+var_84]
    add     edx, 519h
    push    1                               ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A0570
    push    esi
    lea     eax, [esp+0A0h+var_84]
    push    offset aMetalD                  ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+9Ch+var_84]
    add     edx, 519h
    push    1                               ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A0570
    push    esi
    lea     eax, [esp+0A0h+var_84]
    push    offset aEnergyD                 ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+9Ch+var_84]
    add     edx, 519h
    push    1                               ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A0570
    push    esi
    lea     eax, [esp+0A0h+var_84]
    push    offset aColorD                  ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+9Ch+var_84]
    add     edx, 519h
    push    1                               ; int
    push    ecx                             ; char *
    push    edx                             ; int

    loc_479BD3:                             ; CODE XREF: sub_4797E0+214j
    call    sub_4A0570
    call    sub_479660
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 88h
    retn    4
    sub_4797E0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     esi, [esp+8]
    mov     ecx, [eax+531h]
    mov     eax, [ecx+4]
    mov     dword ptr [esi+2Fh], 0
    mov     eax, [eax+0C0h]
    test    eax, eax
    jz      short loc_479C48
    mov     edx, [esp+0Ch]
    push    edx
    push    eax
    call    sub_4B8D40
    test    eax, eax
    jz      short loc_479C48
    xor     ecx, ecx
    mov     [esi+2Fh], eax
    mov     cl, [esi+13Bh]
    push    ecx
    push    eax
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_479C48
    mov     dx, [eax]
    mov     [esi+17h], dx
    mov     ax, [eax+2]
    mov     [esi+19h], ax

    loc_479C48:                             ; CODE XREF: .text:00479C12j
                                            ; .text:00479C21j ...
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_479C50 proc near                    ; CODE XREF: sub_47A0E0+2Bp

    var_214= dword ptr -214h
    var_210= dword ptr -210h
    var_20C= byte ptr -20Ch
    var_1F9= word ptr -1F9h
    var_1F7= word ptr -1F7h
    var_1F5= word ptr -1F5h
    var_1F3= word ptr -1F3h
    var_1F1= dword ptr -1F1h
    var_1E3= byte ptr -1E3h
    var_1DD= dword ptr -1DDh
    var_1D9= dword ptr -1D9h
    var_D6= byte ptr -0D6h
    var_D4= word ptr -0D4h
    var_D1= dword ptr -0D1h
    var_CC= byte ptr -0CCh
    var_B9= word ptr -0B9h
    var_B7= word ptr -0B7h
    var_B5= word ptr -0B5h
    var_B3= word ptr -0B3h
    var_A3= byte ptr -0A3h
    var_99= dword ptr -99h
    var_4= dword ptr -4

    sub     esp, 214h
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    mov     eax, 0C8h
    push    edi
    mov     ecx, [esi+38D81h]
    lea     edi, [esp+224h+var_20C]
    cdq
    idiv    ecx
    dec     ecx
    xor     ebx, ebx
    xor     ebp, ebp
    imul    ecx, eax
    mov     [esp+224h+var_210], eax
    mov     eax, 0B4h
    sub     eax, ecx
    mov     ecx, 4Fh
    cdq
    sub     eax, edx
    mov     edx, eax
    xor     eax, eax
    rep stosd
    stosw
    mov     ecx, 33h
    xor     eax, eax
    lea     edi, [esp+224h+var_CC]
    rep stosd
    mov     ecx, [esp+224h+var_4]
    mov     eax, 1
    or      ecx, eax
    mov     [esp+224h+var_1E3], al
    sar     edx, 1
    mov     [esp+224h+var_A3], al
    mov     [esp+224h+var_4], ecx
    mov     eax, [esi+38D81h]
    add     edx, 4Fh
    cmp     eax, ebx
    mov     [esp+224h+var_214], edx
    jle     loc_47A0C9
    jmp     short loc_479CE2
    ; ---------------------------------------------------------------------------

    loc_479CDE:                             ; CODE XREF: sub_479C50+473j
    mov     edx, [esp+224h+var_214]

    loc_479CE2:                             ; CODE XREF: sub_479C50+8Cj
    mov     esi, ds:wsprintfA
    push    ebp
    lea     eax, [esp+1Eh]
    push    offset aPlayerD_0               ; LPCSTR
    push    eax                             ; LPSTR
    mov     [esp+230h+var_1F7], dx
    mov     [esp+230h+var_B7], dx
    call    esi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    mov     edi, 2Dh
    mov     [esp+230h+var_1F9], di
    mov     [esp+230h+var_1F5], 70h
    mov     [esp+230h+var_1F3], 14h
    mov     [esp+230h+var_1F1], 2
    mov     byte ptr [esp+230h+var_1D9], bl
    mov     edx, [ecx+531h]
    add     esp, 0Ch
    mov     eax, [edx+4]
    mov     [esp+224h+var_1DD], ebx
    mov     eax, [eax+0C0h]
    cmp     eax, ebx
    jz      short loc_479D82
    push    offset aSkirmname               ; char *
    push    eax                             ; int
    call    sub_4B8D40
    cmp     eax, ebx
    jz      short loc_479D82
    mov     ecx, [esp+224h+var_D1]
    mov     [esp+224h+var_1DD], eax
    and     ecx, 0FFh
    push    ecx
    push    eax
    call    sub_4B7F30
    cmp     eax, ebx
    jz      short loc_479D82
    mov     dx, [eax]
    mov     [esp+224h+var_1F5], dx
    mov     ax, [eax+2]
    mov     [esp+224h+var_1F3], ax

    loc_479D82:                             ; CODE XREF: sub_479C50+F4j
                                            ; sub_479C50+103j ...
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+224h+var_20C]
    add     edx, 519h
    push    ecx
    push    edx
    call    sub_4AB2B0
    push    ebp
    lea     eax, [esp+1Eh]
    push    offset aSideD_0                 ; LPCSTR
    push    eax                             ; LPSTR
    call    esi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    mov     [esp+230h+var_1F9], 0A3h
    mov     [esp+230h+var_1F5], di
    add     esp, 0Ch
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    mov     [esp+224h+var_1DD], ebx
    mov     eax, [eax+0C0h]
    cmp     eax, ebx
    jz      short loc_479E0E
    push    offset aSidex                   ; char *
    push    eax                             ; int
    call    sub_4B8D40
    cmp     eax, ebx
    jz      short loc_479E0E
    mov     ecx, [esp+224h+var_D1]
    mov     [esp+224h+var_1DD], eax
    and     ecx, 0FFh
    push    ecx
    push    eax
    call    sub_4B7F30
    cmp     eax, ebx
    jz      short loc_479E0E
    mov     dx, [eax]
    mov     [esp+224h+var_1F5], dx
    mov     ax, [eax+2]
    mov     [esp+224h+var_1F3], ax

    loc_479E0E:                             ; CODE XREF: sub_479C50+180j
                                            ; sub_479C50+18Fj ...
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+224h+var_20C]
    add     edx, 519h
    push    ecx
    push    edx
    mov     byte ptr [esp+22Ch+var_D1], bl
    mov     [esp+22Ch+var_D6], 2
    call    sub_4AB2B0
    push    ebp
    lea     eax, [esp+15Eh]
    push    offset aColorD                  ; LPCSTR
    push    eax                             ; LPSTR
    call    esi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+224h+var_CC]
    add     edx, 519h
    mov     edi, 14h
    push    ecx
    push    edx
    mov     [esp+22Ch+var_B9], 0D6h
    mov     [esp+22Ch+var_B5], di
    mov     [esp+22Ch+var_B3], di
    mov     byte ptr [esp+22Ch+var_99], bl
    call    sub_4AB310
    push    ebp
    lea     eax, [esp+15Eh]
    push    offset aAlliesD                 ; LPCSTR
    push    eax                             ; LPSTR
    call    esi ; wsprintfA
    add     esp, 0Ch
    mov     [esp+224h+var_B9], 0F1h
    mov     [esp+224h+var_B5], 28h
    mov     [esp+224h+var_B3], di
    push    offset aClickToSelectA          ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+224h+var_99]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, TAdynmemStructPtr
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    add     edx, 519h
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+224h+var_CC]
    push    ecx
    push    edx
    call    sub_4AB310
    push    ebp
    lea     eax, [esp+1Eh]
    push    offset aMetalD                  ; LPCSTR
    push    eax                             ; LPSTR
    call    ds:wsprintfA
    mov     edx, [esp+230h+var_1F1]
    mov     ecx, TAdynmemStructPtr
    or      edx, 10000h
    mov     [esp+230h+var_1F9], 11Eh
    mov     [esp+230h+var_1F5], 2Dh
    mov     [esp+230h+var_1F3], 14h
    mov     [esp+230h+var_1F1], edx
    mov     [esp+230h+var_D6], bl
    mov     [esp+230h+var_D4], bx
    mov     [esp+230h+var_1DD], ebx
    mov     edx, [ecx+531h]
    add     esp, 0Ch
    mov     eax, [edx+4]
    mov     [esp+224h+var_1DD], ebx
    mov     eax, [eax+0C0h]
    cmp     eax, ebx
    jz      short loc_479FA3
    push    offset aSkirmmet                ; char *
    push    eax                             ; int
    call    sub_4B8D40
    cmp     eax, ebx
    jz      short loc_479FA3
    mov     ecx, [esp+224h+var_D1]
    mov     [esp+224h+var_1DD], eax
    and     ecx, 0FFh
    push    ecx
    push    eax
    call    sub_4B7F30
    cmp     eax, ebx
    jz      short loc_479FA3
    mov     dx, [eax]
    mov     [esp+224h+var_1F5], dx
    mov     ax, [eax+2]
    mov     [esp+224h+var_1F3], ax

    loc_479FA3:                             ; CODE XREF: sub_479C50+315j
                                            ; sub_479C50+324j ...
    push    offset aLeftClickToInc          ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+224h+var_1D9]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, TAdynmemStructPtr
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    add     edx, 519h
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+224h+var_20C]
    push    ecx
    push    edx
    call    sub_4AB2B0
    push    ebp
    lea     eax, [esp+1Eh]
    push    offset aEnergyD                 ; LPCSTR
    push    eax                             ; LPSTR
    call    ds:wsprintfA
    mov     ecx, TAdynmemStructPtr
    mov     [esp+230h+var_1F9], 151h
    mov     [esp+230h+var_1F5], 2Dh
    add     esp, 0Ch
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    mov     [esp+224h+var_1DD], ebx
    mov     eax, [eax+0C0h]
    cmp     eax, ebx
    jz      short loc_47A062
    push    offset aSkirmmet                ; char *
    push    eax                             ; int
    call    sub_4B8D40
    cmp     eax, ebx
    jz      short loc_47A062
    mov     ecx, [esp+224h+var_D1]
    mov     [esp+224h+var_1DD], eax
    and     ecx, 0FFh
    push    ecx
    push    eax
    call    sub_4B7F30
    cmp     eax, ebx
    jz      short loc_47A062
    mov     dx, [eax]
    mov     [esp+224h+var_1F5], dx
    mov     ax, [eax+2]
    mov     [esp+224h+var_1F3], ax

    loc_47A062:                             ; CODE XREF: sub_479C50+3D4j
                                            ; sub_479C50+3E3j ...
    push    offset aLeftClickToI_0          ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+224h+var_1D9]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, TAdynmemStructPtr
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    add     edx, 519h
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+224h+var_20C]
    push    ecx
    push    edx
    call    sub_4AB2B0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+224h+var_210]
    mov     edx, [esp+224h+var_214]
    add     edx, eax
    mov     eax, [ecx+38D81h]
    inc     ebp
    mov     [esp+224h+var_214], edx
    cmp     ebp, eax
    jl      loc_479CDE

    loc_47A0C9:                             ; CODE XREF: sub_479C50+86j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 214h
    retn
    sub_479C50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47A0E0 proc near                    ; CODE XREF: sub_47B9F0+187p
                                            ; .text:0047BD23p

    var_84= byte ptr -84h
    var_80= byte ptr -80h
    var_40= byte ptr -40h

    mov     eax, TAdynmemStructPtr
    sub     esp, 84h
    mov     ecx, [eax+531h]
    mov     eax, [eax+29A0h]
    push    ebx
    push    ebp
    mov     ebx, [ecx+4]
    push    esi
    push    edi
    movsx   edx, word ptr [ebx+0B6h]
    mov     [eax+220h], edx
    call    sub_479C50
    mov     esi, TAdynmemStructPtr
    xor     ebp, ebp
    mov     edx, 1
    mov     ecx, [esi+38D81h]
    cmp     ecx, ebp
    jle     short loc_47A139
    mov     eax, [esi+29A0h]

    loc_47A12D:                             ; CODE XREF: sub_47A0E0+57j
    cmp     [eax], ebp
    jz      short loc_47A133
    xor     edx, edx

    loc_47A133:                             ; CODE XREF: sub_47A0E0+4Fj
    add     eax, 18h
    dec     ecx
    jnz     short loc_47A12D

    loc_47A139:                             ; CODE XREF: sub_47A0E0+45j
    cmp     edx, ebp
    jz      short loc_47A15C
    mov     ecx, [esi+29A0h]
    mov     dword ptr [ecx], 1
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    mov     dword ptr [eax+18h], 2

    loc_47A15C:                             ; CODE XREF: sub_47A0E0+5Bj
    mov     ecx, [ebx+0C0h]
    push    offset aTeamiconsx              ; char *
    push    ecx                             ; int
    call    sub_4B8D40
    mov     edi, eax
    cmp     edi, ebp
    mov     dword ptr [esp+94h+var_84], edi
    jz      short loc_47A197
    xor     esi, esi
    cmp     [edi], bp
    jbe     short loc_47A197

    loc_47A17E:                             ; CODE XREF: sub_47A0E0+B5j
    push    ebp
    push    edi
    call    sub_4B7F30
    xor     edx, edx
    mov     [eax+6], bp
    mov     [eax+4], bp
    mov     dx, [edi]
    inc     esi
    cmp     esi, edx
    jl      short loc_47A17E

    loc_47A197:                             ; CODE XREF: sub_47A0E0+95j
                                            ; sub_47A0E0+9Cj
    mov     eax, TAdynmemStructPtr
    xor     esi, esi
    cmp     [eax+38D81h], ebp
    jle     loc_47A4B7
    mov     edi, ds:wsprintfA

    loc_47A1B0:                             ; CODE XREF: sub_47A0E0+3CFj
    push    esi
    lea     ecx, [esp+98h+var_80]
    push    offset aPlayerD_0               ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     edx, [eax+29A0h]
    mov     ecx, [edx+ebp]
    sub     ecx, 0
    jz      short loc_47A22D
    dec     ecx
    jz      short loc_47A206
    dec     ecx
    jnz     loc_47A31E
    push    0
    push    offset aComputer_0              ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    lea     eax, [esp+9Ch+var_80]
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_4A0BF0
    jmp     loc_47A31E
    ; ---------------------------------------------------------------------------

    loc_47A206:                             ; CODE XREF: sub_47A0E0+F4j
    push    0
    push    offset aPlayer                  ; int
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+9Ch+var_80]
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4A0BF0
    jmp     loc_47A31E
    ; ---------------------------------------------------------------------------

    loc_47A22D:                             ; CODE XREF: sub_47A0E0+F1j
    push    0
    lea     ecx, [esp+98h+var_80]
    push    offset aOpen_0                  ; "Open"
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+94h+var_80]
    push    1                               ; int
    add     eax, 519h
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    push    esi
    lea     ecx, [esp+98h+var_80]
    push    offset aSideD_0                 ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+94h+var_80]
    add     eax, 519h
    push    0                               ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    push    esi
    lea     ecx, [esp+98h+var_80]
    push    offset aAlliesD                 ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+94h+var_80]
    add     eax, 519h
    push    0                               ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    push    esi
    lea     ecx, [esp+98h+var_80]
    push    offset aMetalD                  ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+94h+var_80]
    add     eax, 519h
    push    0                               ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    push    esi
    lea     ecx, [esp+98h+var_80]
    push    offset aEnergyD                 ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+94h+var_80]
    add     eax, 519h
    push    0                               ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    push    esi
    lea     ecx, [esp+98h+var_80]
    push    offset aColorD                  ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+94h+var_80]
    add     eax, 519h
    push    0                               ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570

    loc_47A31E:                             ; CODE XREF: sub_47A0E0+F7j
                                            ; sub_47A0E0+121j ...
    push    esi
    lea     ecx, [esp+98h+var_80]
    push    offset aSideD_0                 ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     edx, [eax+29A0h]
    add     eax, 519h
    mov     ecx, [edx+ebp+4]
    lea     edx, [esp+94h+var_80]
    push    ecx                             ; char
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A1080
    push    esi
    lea     eax, [esp+98h+var_80]
    push    offset aMetalD                  ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+94h+var_40]
    mov     eax, [edx+29A0h]
    push    0Ah                             ; int
    push    ecx                             ; char *
    mov     ecx, [eax+ebp+0Ch]
    push    ecx                             ; int
    call    __itoa
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+94h+var_40]
    lea     eax, [esp+94h+var_80]
    push    0
    push    edx
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_4A0BF0
    push    esi
    lea     edx, [esp+98h+var_80]
    push    offset aEnergyD                 ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+94h+var_40]
    mov     edx, [ecx+29A0h]
    push    0Ah                             ; int
    push    eax                             ; char *
    mov     eax, [edx+ebp+10h]
    push    eax                             ; int
    call    __itoa
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+94h+var_40]
    lea     edx, [esp+94h+var_80]
    push    0
    push    ecx
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4A0BF0
    push    esi
    lea     ecx, [esp+98h+var_80]
    push    offset aColorD                  ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     edx, [esp+94h+var_80]
    push    6
    push    edx                             ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_47A44F
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    lea     eax, [edx+ecx*2]
    test    eax, eax
    jz      short loc_47A44F
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+148DBh]
    mov     [eax+0BEh], edx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     cx, [edx+ebp+14h]
    mov     [eax+0C6h], cx

    loc_47A44F:                             ; CODE XREF: sub_47A0E0+328j
                                            ; sub_47A0E0+343j
    push    esi
    lea     edx, [esp+9Ch+var_84]
    push    offset aAlliesD                 ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    add     esp, 0Ch
    lea     eax, [esp+98h+var_84]
    push    6
    push    eax                             ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_47A49F
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    lea     eax, [edx+ecx*2]
    test    eax, eax
    jz      short loc_47A49F
    mov     ecx, [esp+10h]
    mov     word ptr [eax+0C6h], 0Ah
    mov     [eax+0BEh], ecx

    loc_47A49F:                             ; CODE XREF: sub_47A0E0+38Fj
                                            ; sub_47A0E0+3AAj
    mov     edx, TAdynmemStructPtr
    inc     esi
    add     ebp, 18h
    cmp     esi, [edx+38D81h]
    jl      loc_47A1B0
    xor     ebp, ebp

    loc_47A4B7:                             ; CODE XREF: sub_47A0E0+C4j
    call    sub_479660
    push    1
    push    offset aStartlocation           ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    mov     eax, TAdynmemStructPtr
    lea     esi, [edx+ecx*2]
    mov     ecx, [eax+29A0h]
    cmp     [ecx+118h], ebp
    jz      short loc_47A501
    mov     byte ptr [esi+137h], 0
    push    offset aCommandersAreP          ; "Commanders are placed at pre-determined"...
    jmp     short loc_47A50D
    ; ---------------------------------------------------------------------------

    loc_47A501:                             ; CODE XREF: sub_47A0E0+411j
    mov     byte ptr [esi+137h], 1
    push    offset aCommandersAreR          ; int

    loc_47A50D:                             ; CODE XREF: sub_47A0E0+41Fj
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esi+33h]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    1
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    push    offset aCommanderdeath          ; char *
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    ebx                             ; int
    and     ecx, 3
    rep movsb
    call    sub_49FDF0
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    mov     eax, TAdynmemStructPtr
    lea     esi, [edx+ecx*2]
    mov     ecx, [eax+29A0h]
    mov     eax, [ecx+108h]
    test    eax, eax
    jz      short loc_47A57B
    mov     byte ptr [esi+137h], 0
    push    offset aGameEndsWhenCo          ; "Game ends when commander is destroyed."
    jmp     short loc_47A587
    ; ---------------------------------------------------------------------------

    loc_47A57B:                             ; CODE XREF: sub_47A0E0+48Bj
    mov     byte ptr [esi+137h], 1
    push    offset aGameContinuesA          ; int

    loc_47A587:                             ; CODE XREF: sub_47A0E0+499j
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esi+33h]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    1
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    push    offset aMapping_0               ; char *
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    ebx                             ; int
    and     ecx, 3
    rep movsb
    call    sub_49FDF0
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    mov     eax, TAdynmemStructPtr
    lea     esi, [edx+ecx*2]
    mov     ecx, [eax+29A0h]
    mov     eax, [ecx+10Ch]
    test    eax, eax
    jz      short loc_47A5F5
    mov     byte ptr [esi+137h], 0
    push    offset aTerrainIsBlack          ; "Terrain is blacked out until explored."
    jmp     short loc_47A601
    ; ---------------------------------------------------------------------------

    loc_47A5F5:                             ; CODE XREF: sub_47A0E0+505j
    mov     byte ptr [esi+137h], 1
    push    offset aTerrainIsVisib          ; int

    loc_47A601:                             ; CODE XREF: sub_47A0E0+513j
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esi+33h]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    1
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    push    offset aLineofsight_0           ; char *
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    ebx                             ; int
    and     ecx, 3
    rep movsb
    call    sub_49FDF0
    mov     ecx, eax
    add     ebx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    lea     ebx, [ebx+ecx*2]
    mov     ecx, [eax+110h]
    test    ecx, ecx
    jnz     short loc_47A66E
    mov     byte ptr [ebx+137h], 0
    push    offset aAllMappedTerra          ; "All mapped terrain is visible."
    jmp     short loc_47A691
    ; ---------------------------------------------------------------------------

    loc_47A66E:                             ; CODE XREF: sub_47A0E0+57Ej
    cmp     dword ptr [eax+114h], 1
    jnz     short loc_47A685
    mov     byte ptr [ebx+137h], 1
    push    offset aTerrainElevati          ; "Terrain elevations affect a unit's view"...
    jmp     short loc_47A691
    ; ---------------------------------------------------------------------------

    loc_47A685:                             ; CODE XREF: sub_47A0E0+595j
    mov     byte ptr [ebx+137h], 2
    push    offset aTerrainEleva_0          ; int

    loc_47A691:                             ; CODE XREF: sub_47A0E0+58Cj
                                            ; sub_47A0E0+5A3j
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebx+33h]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    add     eax, 519h
    add     ecx, 11Ch
    push    ecx
    push    offset aMapname_0               ; "MapName"
    push    eax
    call    sub_4A0BF0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx                             ; int
    call    sub_49FA90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 84h
    retn
    sub_47A0E0 endp ; sp = -18h

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+29A0h]
    mov     esi, [eax+38D81h]
    mov     eax, [esp+14h]
    push    edi
    cmp     eax, esi
    jz      short loc_47A74F
    jge     short loc_47A74F
    mov     ebx, [esp+14h]
    lea     edx, [ebx+ebx*2]
    mov     edi, [ecx+edx*8+8]
    lea     edx, [eax+eax*2]
    lea     ecx, [ecx+edx*8+8]

    loc_47A731:                             ; CODE XREF: .text:0047A74Dj
    mov     edx, [ecx]
    cmp     edx, edi
    jnz     short loc_47A743
    mov     ebp, [ecx-8]
    test    ebp, ebp
    jz      short loc_47A743
    cmp     edx, 5
    jnz     short loc_47A752

    loc_47A743:                             ; CODE XREF: .text:0047A735j
                                            ; .text:0047A73Cj
    cmp     eax, ebx
    jz      short loc_47A752
    inc     eax
    add     ecx, 18h
    cmp     eax, esi
    jl      short loc_47A731

    loc_47A74F:                             ; CODE XREF: .text:0047A71Bj
                                            ; .text:0047A71Dj
    or      eax, 0FFFFFFFFh

    loc_47A752:                             ; CODE XREF: .text:0047A741j
                                            ; .text:0047A745j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47A760 proc near                    ; CODE XREF: sub_47AE60+232p
                                            ; sub_497180+3FCp ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebx
    push    edi
    mov     edi, TAdynmemStructPtr
    xor     ebx, ebx
    mov     eax, [edi+38D81h]
    test    eax, eax
    jle     loc_47A8C6
    push    esi
    push    ebp
    xor     ebp, ebp
    xor     esi, esi
    mov     [esp+18h+var_4], ebp
    mov     [esp+18h+var_8], esi

    loc_47A789:                             ; CODE XREF: sub_47A760+15Ej
    mov     eax, [edi+29A0h]
    add     eax, esi
    mov     ecx, [eax]
    cmp     ecx, 1
    jnz     short loc_47A7E6
    mov     ecx, [edi+ebp+TAdynmemStruct.Players.PlayerInfo]
    mov     dl, [eax+14h]
    push    1
    push    ebx
    mov     [ecx+96h], dl
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    mov     edx, [eax+ebp+TAdynmemStruct.Players.PlayerInfo]
    mov     al, [ecx+esi+4]
    mov     [edx+95h], al
    call    sub_464290
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+TAdynmemStruct.LOS_Sight], bl
    mov     edx, TAdynmemStructPtr
    mov     [edx+TAdynmemStruct.SharedBits], bl
    jmp     short loc_47A823
    ; ---------------------------------------------------------------------------

    loc_47A7E6:                             ; CODE XREF: sub_47A760+36j
    cmp     ecx, 2
    jnz     short loc_47A81B
    mov     ecx, [edi+ebp+1B8Ah]
    mov     dl, [eax+14h]
    push    2
    mov     [ecx+96h], dl
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    mov     edx, [eax+ebp+1B8Ah]
    mov     al, [ecx+esi+4]
    mov     [edx+95h], al
    jmp     short loc_47A81D
    ; ---------------------------------------------------------------------------

    loc_47A81B:                             ; CODE XREF: sub_47A760+89j
    push    0

    loc_47A81D:                             ; CODE XREF: sub_47A760+B9j
    push    ebx
    call    sub_464290

    loc_47A823:                             ; CODE XREF: sub_47A760+84j
    mov     edi, TAdynmemStructPtr
    mov     ecx, [edi+29A0h]
    mov     eax, [ecx+esi]
    cmp     eax, 1
    jz      short loc_47A83C
    cmp     eax, 2
    jnz     short loc_47A8A4

    loc_47A83C:                             ; CODE XREF: sub_47A760+D5j
    xor     eax, eax

    loc_47A83E:                             ; CODE XREF: sub_47A760+13Ej
    mov     esi, [edi+38D81h]
    mov     edx, [edi+29A0h]
    cmp     eax, esi
    jz      short loc_47A884
    cmp     eax, esi
    mov     ecx, eax
    jge     short loc_47A884
    mov     ebp, [esp+18h+var_8]
    lea     eax, [eax+eax*2]
    mov     ebp, [edx+ebp+8]
    lea     eax, [edx+eax*8+8]

    loc_47A863:                             ; CODE XREF: sub_47A760+11Ej
    mov     edx, [eax]
    cmp     edx, ebp
    jnz     short loc_47A874
    cmp     dword ptr [eax-8], 0
    jz      short loc_47A874
    cmp     edx, 5
    jnz     short loc_47A8CC

    loc_47A874:                             ; CODE XREF: sub_47A760+107j
                                            ; sub_47A760+10Dj
    cmp     ecx, ebx
    jz      short loc_47A8CC
    inc     ecx
    add     eax, 18h
    cmp     ecx, esi
    jl      short loc_47A863
    mov     ebp, [esp+18h+var_4]

    loc_47A884:                             ; CODE XREF: sub_47A760+ECj
                                            ; sub_47A760+F2j
    or      eax, 0FFFFFFFFh

    loc_47A887:                             ; CODE XREF: sub_47A760+172j
    cmp     eax, 0FFFFFFFFh
    jz      short loc_47A8A0
    lea     ecx, [eax+edi]
    inc     eax
    mov     byte ptr [ecx+ebp+1C6Bh], 1
    mov     edi, TAdynmemStructPtr
    jmp     short loc_47A83E
    ; ---------------------------------------------------------------------------

    loc_47A8A0:                             ; CODE XREF: sub_47A760+12Aj
    mov     esi, [esp+18h+var_8]

    loc_47A8A4:                             ; CODE XREF: sub_47A760+DAj
    mov     eax, [edi+38D81h]
    inc     ebx
    add     esi, 18h
    add     ebp, 14Bh
    cmp     ebx, eax
    mov     [esp+18h+var_8], esi
    mov     [esp+18h+var_4], ebp
    jl      loc_47A789
    pop     ebp
    pop     esi

    loc_47A8C6:                             ; CODE XREF: sub_47A760+15j
    pop     edi
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_47A8CC:                             ; CODE XREF: sub_47A760+112j
                                            ; sub_47A760+116j
    mov     ebp, [esp+18h+var_4]
    mov     eax, ecx
    jmp     short loc_47A887
    sub_47A760 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, TAdynmemStructPtr
    mov     eax, [esi+29A0h]
    mov     ecx, [eax+224h]
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*8+4]
    mov     eax, [ecx]
    inc     eax
    cdq
    idiv    dword ptr [esi+37F39h]
    pop     esi
    mov     [ecx], edx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47A910 proc near                    ; DATA XREF: sub_47AAF0+60o

    var_100= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 100h
    push    ebx
    push    esi
    mov     esi, [esp+108h+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     ebx, [eax+0Ch]
    mov     edi, [eax+4]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_47A988
    mov     eax, TAdynmemStructPtr
    push    offset aMappic                  ; char *
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_4A0280
    mov     esi, eax
    mov     eax, [esi+0C2h]
    test    eax, eax
    jz      short loc_47A967
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+0C2h], 0

    loc_47A967:                             ; CODE XREF: sub_47A910+42j
    mov     eax, [ebx+14h]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    ebx                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47A988:                             ; CODE XREF: sub_47A910+1Dj
    push    offset aMapnames                ; "MAPNAMES"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_47A9DF
    push    offset aLoad                    ; "LOAD"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_47A9DF
    push    offset aPrevmenu                ; "PREVMENU"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_47A9CD
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47A9CD:                             ; CODE XREF: sub_47A910+A3j
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47A9DF:                             ; CODE XREF: sub_47A910+85j
                                            ; sub_47A910+94j
    push    offset aLoad                    ; "LOAD"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_47A9FA
    push    0                               ; int
    push    offset aSmallbutton             ; char *
    call    sub_47F1A0

    loc_47A9FA:                             ; CODE XREF: sub_47A910+DCj
    push    offset aMapnames                ; char *
    push    edi                             ; int
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [eax+0C2h]
    push    100h                            ; size_t
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax                             ; char *
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    add     ecx, 11Ch
    push    ecx                             ; char *
    call    _strncpy
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    mov     edx, [eax+29A0h]
    mov     ecx, [eax+391E9h]
    add     edx, 11Ch
    push    edx
    call    sub_435A20
    mov     eax, TAdynmemStructPtr
    push    100h                            ; size_t
    lea     edx, [esp+110h+var_100]
    mov     ecx, [eax+29A0h]
    add     ecx, 11Ch
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    lea     eax, [esp+10Ch+var_100]
    push    eax                             ; char *
    push    offset aMapname_0               ; char *
    push    esi                             ; int
    call    sub_4A0E00
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 100h
    retn    4
    sub_47A910 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_47AAA0:                             ; DATA XREF: sub_47AAF0+CBo
    mov     eax, [esp+4]
    push    offset aMapnames                ; "MAPNAMES"
    mov     ecx, [eax+18h]
    mov     edx, [ecx+4]
    push    edx
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [eax+0C2h]
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435A20
    test    eax, eax
    jz      short locret_47AAE3
    call    sub_444A20

    locret_47AAE3:                          ; CODE XREF: .text:0047AADCj
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47AAF0 proc near                    ; CODE XREF: sub_47AE60+A9Dp
    push    ebx
    push    0
    push    0
    push    0
    call    sub_434BF0
    mov     ebx, eax
    test    ebx, ebx
    jnz     short loc_47AB28
    push    1
    push    1
    push    140h
    push    offset aThereAreNoSkir          ; int
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_47AB28:                             ; CODE XREF: sub_47AAF0+10j
    mov     ecx, TAdynmemStructPtr
    push    edi
    push    esi
    push    ebp
    push    880h
    add     ecx, 519h
    push    offset aSelmap_gui              ; "SELMAP.GUI"
    push    ecx
    call    sub_4AA8F0
    mov     esi, eax
    push    20h
    push    offset aSelectMapData           ; "SELECT MAP DATA"
    mov     dword ptr [esi+8], offset sub_47A910
    call    sub_4D83B0
    add     esp, 8
    mov     edi, eax
    mov     [esi+0Ch], edi
    push    0
    push    0
    push    0
    push    offset aDselectmap2             ; "DSELECTMAP2"
    call    sub_4288D0
    add     edi, 14h
    push    0
    push    0
    push    edi
    call    sub_434BF0
    mov     edx, [edi]
    push    ebx
    push    0
    push    0
    push    edx
    call    sub_4AEFA0
    mov     eax, [edi]
    mov     ecx, TAdynmemStructPtr
    push    0
    push    ebx
    push    eax
    add     ecx, 519h
    push    offset aMapnames                ; "MAPNAMES"
    push    ecx
    call    sub_4A32A0
    mov     edx, [esi+4]
    push    offset aMapnames                ; char *
    push    edx                             ; int
    call    sub_49FF90
    xor     ebp, ebp
    mov     dword ptr [eax+0CEh], offset loc_47AAA0
    test    ebx, ebx
    jle     short loc_47AC30

    loc_47ABC9:                             ; CODE XREF: sub_47AAF0+126j
    mov     eax, [edi]
    push    ebp
    push    eax
    call    sub_4B6AF0
    mov     ecx, TAdynmemStructPtr
    mov     esi, eax
    mov     ecx, [ecx+29A0h]
    add     ecx, 11Ch

    loc_47ABE6:                             ; CODE XREF: sub_47AAF0+114j
    mov     dl, [ecx]
    mov     al, dl
    cmp     dl, [esi]
    jnz     short loc_47AC0A
    test    al, al
    jz      short loc_47AC06
    mov     dl, [ecx+1]
    mov     al, dl
    cmp     dl, [esi+1]
    jnz     short loc_47AC0A
    add     ecx, 2
    add     esi, 2
    test    al, al
    jnz     short loc_47ABE6

    loc_47AC06:                             ; CODE XREF: sub_47AAF0+100j
    xor     eax, eax
    jmp     short loc_47AC0F
    ; ---------------------------------------------------------------------------

    loc_47AC0A:                             ; CODE XREF: sub_47AAF0+FCj
                                            ; sub_47AAF0+10Aj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_47AC0F:                             ; CODE XREF: sub_47AAF0+118j
    test    eax, eax
    jz      short loc_47AC1A
    inc     ebp
    cmp     ebp, ebx
    jl      short loc_47ABC9
    jmp     short loc_47AC30
    ; ---------------------------------------------------------------------------

    loc_47AC1A:                             ; CODE XREF: sub_47AAF0+121j
    mov     eax, TAdynmemStructPtr
    push    ebp
    add     eax, 519h
    push    offset aMapnames                ; "MAPNAMES"
    push    eax
    call    sub_4A2E40

    loc_47AC30:                             ; CODE XREF: sub_47AAF0+D7j
                                            ; sub_47AAF0+128j
    mov     ecx, TAdynmemStructPtr
    push    offset aMapnames                ; char *
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [eax+0C2h]
    push    ecx
    push    edx
    call    sub_4B6AF0
    push    eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435A20
    test    eax, eax
    jz      short loc_47AC78
    call    sub_444A20

    loc_47AC78:                             ; CODE XREF: sub_47AAF0+181j
    mov     ecx, TAdynmemStructPtr
    push    1
    add     ecx, 519h
    push    ecx
    call    sub_49FB10
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    push    13h
    call    sub_491C80
    pop     ebp
    pop     esi
    pop     edi
    pop     ebx
    retn
    sub_47AAF0 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+8]
    push    2
    push    offset aLogos_0                 ; "LOGOS"
    mov     eax, [esi+18h]
    mov     ecx, [eax+4]
    push    ecx
    call    sub_49FDF0
    mov     [esi+60h], eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47ACD0 proc near                    ; CODE XREF: sub_47AE60+48Ep
                                            ; sub_47AE60+4A0p

    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= byte ptr -40h
    arg_0= dword ptr  4

    sub     esp, 48h
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    mov     ebp, [esp+50h+arg_0]
    mov     eax, [ecx+531h]
    push    esi
    neg     ebp
    mov     edx, [eax+4]
    mov     eax, [ecx+29A0h]
    push    edi
    mov     [esp+58h+var_44], edx
    mov     edi, [eax+224h]
    sbb     ebp, ebp
    mov     [esp+58h+var_48], edi
    and     ebp, 0FFFFFFFEh
    lea     edi, [edi+edi*2]
    inc     ebp
    shl     edi, 3

    loc_47AD0C:                             ; CODE XREF: sub_47ACD0+BFj
    mov     edx, [ecx+29A0h]
    mov     ecx, [ecx+148DBh]
    xor     ebx, ebx
    mov     eax, [edx+edi+14h]
    lea     esi, [edx+edi+14h]
    mov     bx, [ecx]
    add     eax, ebp
    cdq
    idiv    ebx
    mov     [esi], edx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    lea     eax, [edx+edi+14h]
    mov     edx, [edx+edi+14h]
    cmp     edx, 0FFFFFFFFh
    jnz     short loc_47AD59
    mov     ecx, [ecx+148DBh]
    xor     edx, edx
    mov     dx, [ecx]
    dec     edx
    mov     [eax], edx
    mov     ecx, TAdynmemStructPtr

    loc_47AD59:                             ; CODE XREF: sub_47ACD0+73j
    mov     esi, [ecx+38D81h]
    xor     edx, edx
    test    esi, esi
    jle     short loc_47AD8B
    mov     eax, [ecx+29A0h]
    mov     ebx, [edi+eax+14h]

    loc_47AD6F:                             ; CODE XREF: sub_47ACD0+B9j
    cmp     [eax+14h], ebx
    jnz     short loc_47AD83
    cmp     dword ptr [eax], 0
    jz      short loc_47AD83
    cmp     edx, [esp+58h+var_48]
    jnz     loc_47AE20

    loc_47AD83:                             ; CODE XREF: sub_47ACD0+A2j
                                            ; sub_47ACD0+A7j
    inc     edx
    add     eax, 18h
    cmp     edx, esi
    jl      short loc_47AD6F

    loc_47AD8B:                             ; CODE XREF: sub_47ACD0+93j
    xor     eax, eax

    loc_47AD8D:                             ; CODE XREF: sub_47ACD0+155j
    test    eax, eax
    jnz     loc_47AD0C
    mov     eax, [esp+58h+var_48]
    lea     ecx, [esp+58h+var_40]
    push    eax
    push    offset aColorD                  ; LPCSTR
    push    ecx                             ; LPSTR
    call    ds:wsprintfA
    mov     esi, [esp+64h+var_44]
    add     esp, 0Ch
    lea     edx, [esp+58h+var_40]
    push    6
    push    edx                             ; char *
    push    esi                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      short loc_47AE06
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     eax, [esi+ecx*2]
    test    eax, eax
    jz      short loc_47AE06
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+148DBh]
    mov     [eax+0BEh], ecx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+29A0h]
    mov     dx, [ecx+edi+14h]
    mov     [eax+0C6h], dx

    loc_47AE06:                             ; CODE XREF: sub_47ACD0+F1j
                                            ; sub_47ACD0+10Aj
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FA90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47AE20:                             ; CODE XREF: sub_47ACD0+ADj
    mov     eax, 1
    jmp     loc_47AD8D
    sub_47ACD0 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     esi, 6
    mov     eax, [eax+29A0h]
    mov     ecx, [eax+224h]
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*8+8]
    mov     eax, [ecx]
    inc     eax
    cdq
    idiv    esi
    mov     [ecx], edx
    call    sub_479660
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47AE60 proc near                    ; DATA XREF: .text:0047BBCFo

    var_70= byte ptr -70h
    var_64= byte ptr -64h
    var_58= dword ptr -58h
    var_41= byte ptr -41h
    arg_0= dword ptr  4

    sub     esp, 70h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+7Ch+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     ebp, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, 0FFFFFFFFh
    jz      loc_47B9D9
    lea     ecx, [esp+40h]
    push    eax                             ; int
    push    ecx                             ; char *
    push    ebp                             ; int
    call    sub_49FED0
    lea     edi, [esp+40h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+ecx+80h+var_41]
    push    edx                             ; char *
    call    _atoi
    mov     ebx, eax
    mov     eax, TAdynmemStructPtr
    lea     edi, [esp+44h]
    add     esp, 4
    mov     ecx, [eax+29A0h]
    xor     eax, eax
    push    offset aStart                   ; "Start"
    push    esi
    mov     [ecx+224h], ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     [esp+ecx+88h+var_41], al
    call    sub_49FD60
    test    eax, eax
    jz      loc_47B0FA
    push    0                               ; int
    push    offset aBigbutton               ; char *
    call    sub_47F1A0
    mov     ebx, 1
    push    ebx
    call    sub_41D6A0
    test    al, al
    jnz     short loc_47AF2E
    push    ebx
    push    ebx
    push    0C8h
    push    offset aPleaseInsert_1          ; int
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AB0A0

    loc_47AF2E:                             ; CODE XREF: sub_47AE60+98j
    call    sub_41D4C0
    mov     esi, TAdynmemStructPtr
    xor     edx, edx
    mov     ecx, [esi+38D81h]
    test    ecx, ecx
    jle     short loc_47AF57
    mov     eax, [esi+29A0h]

    loc_47AF4B:                             ; CODE XREF: sub_47AE60+F5j
    cmp     dword ptr [eax], 2
    jnz     short loc_47AF51
    inc     edx

    loc_47AF51:                             ; CODE XREF: sub_47AE60+EEj
    add     eax, 18h
    dec     ecx
    jnz     short loc_47AF4B

    loc_47AF57:                             ; CODE XREF: sub_47AE60+E3j
    inc     edx
    mov     [esi+2A3Ch], dx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    add     ecx, 11Ch
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435A20
    test    eax, eax
    jnz     short loc_47AF91
    push    ebx
    push    ebx
    push    1E0h
    push    offset aTheTerrainForT          ; "The terrain for the selected map does n"...
    jmp     loc_47B0CB
    ; ---------------------------------------------------------------------------

    loc_47AF91:                             ; CODE XREF: sub_47AE60+11Ej
    mov     edi, TAdynmemStructPtr
    xor     esi, esi
    mov     ecx, [edi+38D81h]
    test    ecx, ecx
    jle     short loc_47AFB7
    mov     eax, [edi+29A0h]
    mov     edx, ecx

    loc_47AFAB:                             ; CODE XREF: sub_47AE60+155j
    cmp     dword ptr [eax], 2
    jnz     short loc_47AFB1
    inc     esi

    loc_47AFB1:                             ; CODE XREF: sub_47AE60+14Ej
    add     eax, 18h
    dec     edx
    jnz     short loc_47AFAB

    loc_47AFB7:                             ; CODE XREF: sub_47AE60+141j
    cmp     esi, ebx
    jl      loc_47B0BF
    xor     edx, edx
    test    ecx, ecx
    jle     short loc_47AFD6
    mov     eax, [edi+29A0h]

    loc_47AFCB:                             ; CODE XREF: sub_47AE60+174j
    cmp     [eax], ebx
    jnz     short loc_47AFD0
    inc     edx

    loc_47AFD0:                             ; CODE XREF: sub_47AE60+16Dj
    add     eax, 18h
    dec     ecx
    jnz     short loc_47AFCB

    loc_47AFD6:                             ; CODE XREF: sub_47AE60+163j
    cmp     edx, ebx
    jl      loc_47B0BF
    mov     ecx, [edi+391E9h]
    call    sub_437300
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cx, [edx+2A3Ch]
    cmp     ecx, eax
    jle     short loc_47B035
    push    ebx
    push    ebx
    push    1E0h
    push    offset aThereAreTooMan          ; int
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90
    mov     ecx, [esp+80h+arg_0]
    push    ecx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B035:                             ; CODE XREF: sub_47AE60+19Aj
    call    sub_479760
    test    eax, eax
    jz      short loc_47B04C
    push    ebx
    push    ebx
    push    1E0h
    push    offset aAllPlayersMayN          ; "All players may not be in the same alli"...
    jmp     short loc_47B0CB
    ; ---------------------------------------------------------------------------

    loc_47B04C:                             ; CODE XREF: sub_47AE60+1DCj
    mov     esi, TAdynmemStructPtr
    xor     edi, edi
    mov     ecx, [esi+38D81h]
    test    ecx, ecx
    jle     short loc_47B072
    mov     eax, [esi+29A0h]
    mov     edx, ecx

    loc_47B066:                             ; CODE XREF: sub_47AE60+210j
    cmp     dword ptr [eax], 2
    jnz     short loc_47B06C
    inc     edi

    loc_47B06C:                             ; CODE XREF: sub_47AE60+209j
    add     eax, 18h
    dec     edx
    jnz     short loc_47B066

    loc_47B072:                             ; CODE XREF: sub_47AE60+1FCj
    xor     edx, edx
    test    ecx, ecx
    jle     short loc_47B089
    mov     eax, [esi+29A0h]

    loc_47B07E:                             ; CODE XREF: sub_47AE60+227j
    cmp     [eax], ebx
    jnz     short loc_47B083
    inc     edx

    loc_47B083:                             ; CODE XREF: sub_47AE60+220j
    add     eax, 18h
    dec     ecx
    jnz     short loc_47B07E

    loc_47B089:                             ; CODE XREF: sub_47AE60+216j
    add     edx, edi
    mov     [esi+2A3Ch], dx
    call    sub_47A760
    call    sub_41DA30
    call    WriteRegistrySettings_2
    mov     ecx, TAdynmemStructPtr
    push    14h
    mov     byte ptr [ecx+2BC0h], 2
    call    sub_491C80
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B0BF:                             ; CODE XREF: sub_47AE60+159j
                                            ; sub_47AE60+178j
    push    ebx
    push    ebx
    push    1E0h
    push    offset aThereMustBeAtL          ; int

    loc_47B0CB:                             ; CODE XREF: sub_47AE60+12Cj
                                            ; sub_47AE60+1EAj
    call    sub_4C5740
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4ABD90
    mov     eax, [esp+80h+arg_0]
    push    eax
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B0FA:                             ; CODE XREF: sub_47AE60+79j
    push    offset aPrevmenu_0              ; "PrevMenu"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_47B133
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    push    14h
    call    sub_491C80
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [ecx+2BC0h], 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B133:                             ; CODE XREF: sub_47AE60+2A7j
    mov     esi, offset aPlayer             ; "Player"
    lea     eax, [esp+40h]
    mov     edi, 2

    loc_47B141:                             ; CODE XREF: sub_47AE60+2FDj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_47B163
    test    cl, cl
    jz      short loc_47B15F
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_47B163
    add     eax, edi
    add     esi, edi
    test    cl, cl
    jnz     short loc_47B141

    loc_47B15F:                             ; CODE XREF: sub_47AE60+2EBj
    xor     eax, eax
    jmp     short loc_47B168
    ; ---------------------------------------------------------------------------

    loc_47B163:                             ; CODE XREF: sub_47AE60+2E7j
                                            ; sub_47AE60+2F5j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_47B168:                             ; CODE XREF: sub_47AE60+301j
    test    eax, eax
    jnz     short loc_47B194
    push    eax                             ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    push    ebx
    call    sub_4797E0
    mov     edx, [esp+80h+arg_0]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B194:                             ; CODE XREF: sub_47AE60+30Aj
    mov     esi, offset aSide_0             ; "Side"
    lea     eax, [esp+40h]

    loc_47B19D:                             ; CODE XREF: sub_47AE60+359j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_47B1BF
    test    cl, cl
    jz      short loc_47B1BB
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_47B1BF
    add     eax, edi
    add     esi, edi
    test    cl, cl
    jnz     short loc_47B19D

    loc_47B1BB:                             ; CODE XREF: sub_47AE60+347j
    xor     eax, eax
    jmp     short loc_47B1C4
    ; ---------------------------------------------------------------------------

    loc_47B1BF:                             ; CODE XREF: sub_47AE60+343j
                                            ; sub_47AE60+351j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_47B1C4:                             ; CODE XREF: sub_47AE60+35Dj
    test    eax, eax
    jnz     short loc_47B20F
    push    eax                             ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     esi, TAdynmemStructPtr
    mov     eax, [esi+29A0h]
    mov     ecx, [eax+224h]
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*8+4]
    mov     eax, [ecx]
    inc     eax
    cdq
    idiv    dword ptr [esi+37F39h]
    mov     [ecx], edx
    mov     edx, [esp+80h+arg_0]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B20F:                             ; CODE XREF: sub_47AE60+366j
    mov     esi, offset aAllies             ; "Allies"
    lea     eax, [esp+40h]

    loc_47B218:                             ; CODE XREF: sub_47AE60+3D4j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_47B23A
    test    cl, cl
    jz      short loc_47B236
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_47B23A
    add     eax, edi
    add     esi, edi
    test    cl, cl
    jnz     short loc_47B218

    loc_47B236:                             ; CODE XREF: sub_47AE60+3C2j
    xor     eax, eax
    jmp     short loc_47B23F
    ; ---------------------------------------------------------------------------

    loc_47B23A:                             ; CODE XREF: sub_47AE60+3BEj
                                            ; sub_47AE60+3CCj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_47B23F:                             ; CODE XREF: sub_47AE60+3D8j
    test    eax, eax
    jnz     short loc_47B28F
    push    eax                             ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     eax, TAdynmemStructPtr
    mov     esi, 6
    mov     eax, [eax+29A0h]
    mov     ecx, [eax+224h]
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*8+8]
    mov     eax, [ecx]
    inc     eax
    cdq
    idiv    esi
    mov     [ecx], edx
    call    sub_479660
    mov     edx, [esp+80h+arg_0]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B28F:                             ; CODE XREF: sub_47AE60+3E1j
    mov     esi, offset aColor_0            ; "Color"
    lea     eax, [esp+40h]

    loc_47B298:                             ; CODE XREF: sub_47AE60+454j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_47B2BA
    test    cl, cl
    jz      short loc_47B2B6
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_47B2BA
    add     eax, edi
    add     esi, edi
    test    cl, cl
    jnz     short loc_47B298

    loc_47B2B6:                             ; CODE XREF: sub_47AE60+442j
    xor     eax, eax
    jmp     short loc_47B2BF
    ; ---------------------------------------------------------------------------

    loc_47B2BA:                             ; CODE XREF: sub_47AE60+43Ej
                                            ; sub_47AE60+44Cj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_47B2BF:                             ; CODE XREF: sub_47AE60+458j
    test    eax, eax
    jnz     short loc_47B31C
    push    eax                             ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    lea     eax, [esp+80h+var_58]
    push    eax
    call    sub_4C2340
    mov     ebx, 1
    mov     esi, [esp+80h+arg_0]
    mov     ecx, [esi+18h]
    cmp     [ecx+37h], ebx
    jnz     short loc_47B2F3
    push    0
    call    sub_47ACD0

    loc_47B2F3:                             ; CODE XREF: sub_47AE60+48Aj
    mov     edx, [esi+18h]
    cmp     [edx+37h], edi
    jnz     loc_47B9CC
    push    ebx
    call    sub_47ACD0
    mov     edx, [esp+80h+arg_0]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B31C:                             ; CODE XREF: sub_47AE60+461j
    mov     esi, offset aEnergy             ; "Energy"
    lea     eax, [esp+40h]

    loc_47B325:                             ; CODE XREF: sub_47AE60+4E1j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_47B347
    test    cl, cl
    jz      short loc_47B343
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_47B347
    add     eax, edi
    add     esi, edi
    test    cl, cl
    jnz     short loc_47B325

    loc_47B343:                             ; CODE XREF: sub_47AE60+4CFj
    xor     eax, eax
    jmp     short loc_47B34C
    ; ---------------------------------------------------------------------------

    loc_47B347:                             ; CODE XREF: sub_47AE60+4CBj
                                            ; sub_47AE60+4D9j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_47B34C:                             ; CODE XREF: sub_47AE60+4E5j
    test    eax, eax
    jnz     loc_47B4BE
    lea     eax, [esp+80h+var_58]
    push    eax
    call    sub_4C2340
    mov     edi, ds:wsprintfA
    mov     ebp, [esp+80h+arg_0]
    mov     ecx, [ebp+18h]
    cmp     dword ptr [ecx+37h], 1
    jnz     loc_47B417
    push    0                               ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    lea     esi, [ebx+ebx*2]
    shl     esi, 3
    mov     eax, [edx+29A0h]
    mov     ecx, [eax+esi+10h]
    lea     eax, [eax+esi+10h]
    add     ecx, 1F4h
    cmp     ecx, 2710h
    jl      short loc_47B3B1
    mov     ecx, 2710h

    loc_47B3B1:                             ; CODE XREF: sub_47AE60+54Aj
    mov     [eax], ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     ecx, [edx+esi+10h]
    cmp     ecx, 2BCh
    lea     eax, [edx+esi+10h]
    jnz     short loc_47B3D5
    mov     dword ptr [eax], 1F4h

    loc_47B3D5:                             ; CODE XREF: sub_47AE60+56Dj
    push    ebx
    lea     eax, [esp+84h+var_64]
    push    offset aEnergyD                 ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+80h+var_70]
    mov     eax, [edx+29A0h]
    push    0Ah                             ; int
    push    ecx                             ; char *
    mov     ecx, [eax+esi+10h]
    push    ecx                             ; int
    call    __itoa
    add     esp, 0Ch
    lea     edx, [esp+80h+var_70]
    lea     eax, [esp+80h+var_64]
    push    0Ah
    push    edx
    push    eax
    push    ebp
    call    sub_4A0BF0

    loc_47B417:                             ; CODE XREF: sub_47AE60+512j
    mov     ecx, [ebp+18h]
    cmp     dword ptr [ecx+37h], 2
    jnz     loc_47B9CC
    push    0                               ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    lea     esi, [ebx+ebx*2]
    shl     esi, 3
    mov     eax, [edx+29A0h]
    mov     ecx, [eax+esi+10h]
    lea     eax, [eax+esi+10h]
    add     ecx, 0FFFFFE0Ch
    cmp     ecx, 0C8h
    jg      short loc_47B45D
    mov     ecx, 0C8h

    loc_47B45D:                             ; CODE XREF: sub_47AE60+5F6j
    mov     [eax], ecx
    push    ebx
    lea     ecx, [esp+84h+var_64]
    push    offset aEnergyD                 ; LPCSTR
    push    ecx                             ; LPSTR
    call    edi ; wsprintfA
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+80h+var_70]
    mov     ecx, [eax+29A0h]
    push    0Ah                             ; int
    push    edx                             ; char *
    mov     edx, [ecx+esi+10h]
    push    edx                             ; int
    call    __itoa
    mov     edx, [esp+8Ch+arg_0]
    add     esp, 0Ch
    lea     eax, [esp+80h+var_70]
    lea     ecx, [esp+80h+var_64]
    push    0Ah
    push    eax
    push    ecx
    push    edx
    call    sub_4A0BF0
    mov     edx, [esp+80h+arg_0]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B4BE:                             ; CODE XREF: sub_47AE60+4EEj
    mov     esi, offset aMetal              ; "Metal"
    lea     eax, [esp+40h]

    loc_47B4C7:                             ; CODE XREF: sub_47AE60+683j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_47B4E9
    test    cl, cl
    jz      short loc_47B4E5
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_47B4E9
    add     eax, edi
    add     esi, edi
    test    cl, cl
    jnz     short loc_47B4C7

    loc_47B4E5:                             ; CODE XREF: sub_47AE60+671j
    xor     eax, eax
    jmp     short loc_47B4EE
    ; ---------------------------------------------------------------------------

    loc_47B4E9:                             ; CODE XREF: sub_47AE60+66Dj
                                            ; sub_47AE60+67Bj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_47B4EE:                             ; CODE XREF: sub_47AE60+687j
    test    eax, eax
    jnz     loc_47B656
    mov     ebp, [esp+80h+arg_0]
    mov     edi, ds:wsprintfA
    mov     eax, [ebp+18h]
    cmp     dword ptr [eax+37h], 1
    jnz     loc_47B5AE
    push    0                               ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    lea     esi, [ebx+ebx*2]
    shl     esi, 3
    mov     edx, [ecx+29A0h]
    mov     ecx, [edx+esi+0Ch]
    lea     eax, [edx+esi+0Ch]
    add     ecx, 1F4h
    cmp     ecx, 2710h
    jl      short loc_47B549
    mov     ecx, 2710h

    loc_47B549:                             ; CODE XREF: sub_47AE60+6E2j
    mov     [eax], ecx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    lea     eax, [ecx+esi+0Ch]
    mov     ecx, [ecx+esi+0Ch]
    cmp     ecx, 2BCh
    jnz     short loc_47B56C
    mov     dword ptr [eax], 1F4h

    loc_47B56C:                             ; CODE XREF: sub_47AE60+704j
    push    ebx
    lea     edx, [esp+84h+var_70]
    push    offset aMetalD                  ; LPCSTR
    push    edx                             ; LPSTR
    call    edi ; wsprintfA
    mov     ecx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     eax, [esp+80h+var_64]
    mov     edx, [ecx+29A0h]
    push    0Ah                             ; int
    push    eax                             ; char *
    mov     eax, [edx+esi+0Ch]
    push    eax                             ; int
    call    __itoa
    add     esp, 0Ch
    lea     ecx, [esp+80h+var_64]
    lea     edx, [esp+80h+var_70]
    push    0Ah
    push    ecx
    push    edx
    push    ebp
    call    sub_4A0BF0

    loc_47B5AE:                             ; CODE XREF: sub_47AE60+6AAj
    mov     eax, [ebp+18h]
    cmp     dword ptr [eax+37h], 2
    jnz     loc_47B9CC
    push    0                               ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    lea     esi, [ebx+ebx*2]
    shl     esi, 3
    mov     edx, [ecx+29A0h]
    mov     ecx, [edx+esi+0Ch]
    lea     eax, [edx+esi+0Ch]
    add     ecx, 0FFFFFE0Ch
    cmp     ecx, 0C8h
    jg      short loc_47B5F4
    mov     ecx, 0C8h

    loc_47B5F4:                             ; CODE XREF: sub_47AE60+78Dj
    mov     [eax], ecx
    push    ebx
    lea     eax, [esp+84h+var_70]
    push    offset aMetalD                  ; LPCSTR
    push    eax                             ; LPSTR
    call    edi ; wsprintfA
    mov     edx, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [esp+80h+var_64]
    mov     eax, [edx+29A0h]
    push    0Ah                             ; int
    push    ecx                             ; char *
    mov     ecx, [eax+esi+0Ch]
    push    ecx                             ; int
    call    __itoa
    mov     ecx, [esp+8Ch+arg_0]
    add     esp, 0Ch
    lea     edx, [esp+80h+var_64]
    lea     eax, [esp+80h+var_70]
    push    0Ah
    push    edx
    push    eax
    push    ecx
    call    sub_4A0BF0
    mov     edx, [esp+80h+arg_0]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B656:                             ; CODE XREF: sub_47AE60+690j
    mov     esi, [esp+80h+arg_0]
    push    offset aCommanderdeath          ; "CommanderDeath"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_47B6DB
    push    0                               ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    mov     ebx, 1
    push    ebx
    push    offset aCommanderdeath          ; char *
    mov     eax, [edx+29A0h]
    push    ebp                             ; int
    xor     [eax+108h], ebx
    call    sub_49FDF0
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    lea     esi, [ebp+ecx*2+0]
    mov     ecx, [eax+108h]
    test    ecx, ecx
    jz      short loc_47B6D1
    push    offset aGameEndsWhenCo          ; "Game ends when commander is destroyed."
    jmp     loc_47B88B
    ; ---------------------------------------------------------------------------

    loc_47B6D1:                             ; CODE XREF: sub_47AE60+865j
    push    offset aGameContinuesA          ; "Game continues after Commander is destr"...
    jmp     loc_47B88B
    ; ---------------------------------------------------------------------------

    loc_47B6DB:                             ; CODE XREF: sub_47AE60+80Aj
    push    offset aStartlocation           ; "StartLocation"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_47B759
    push    0                               ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    mov     ebx, 1
    push    ebx
    push    offset aStartlocation           ; char *
    mov     eax, [edx+29A0h]
    push    ebp                             ; int
    xor     [eax+118h], ebx
    call    sub_49FDF0
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    lea     esi, [ebp+ecx*2+0]
    mov     ecx, [eax+118h]
    test    ecx, ecx
    jz      short loc_47B74F
    push    offset aCommandersAreP          ; "Commanders are placed at pre-determined"...
    jmp     loc_47B88B
    ; ---------------------------------------------------------------------------

    loc_47B74F:                             ; CODE XREF: sub_47AE60+8E3j
    push    offset aCommandersAreR          ; "Commanders are randomly placed on the b"...
    jmp     loc_47B88B
    ; ---------------------------------------------------------------------------

    loc_47B759:                             ; CODE XREF: sub_47AE60+888j
    push    offset aMapping_0               ; "Mapping"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_47B7D7
    push    0                               ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     edx, TAdynmemStructPtr
    mov     ebx, 1
    push    ebx
    push    offset aMapping_0               ; char *
    mov     eax, [edx+29A0h]
    push    ebp                             ; int
    xor     [eax+10Ch], ebx
    call    sub_49FDF0
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+29A0h]
    lea     esi, [ebp+ecx*2+0]
    mov     ecx, [eax+10Ch]
    test    ecx, ecx
    jz      short loc_47B7CD
    push    offset aTerrainIsBlack          ; "Terrain is blacked out until explored."
    jmp     loc_47B88B
    ; ---------------------------------------------------------------------------

    loc_47B7CD:                             ; CODE XREF: sub_47AE60+961j
    push    offset aTerrainIsVisib          ; "Terrain is visible."
    jmp     loc_47B88B
    ; ---------------------------------------------------------------------------

    loc_47B7D7:                             ; CODE XREF: sub_47AE60+906j
    push    offset aLineofsight_0           ; "LineOfSight"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_47B8DB
    push    0                               ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    mov     ebx, 1
    push    ebx
    push    offset aLineofsight_0           ; char *
    push    ebp                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+29A0h]
    lea     esi, [ebp+edx*2+0]
    mov     ecx, [eax+110h]
    test    ecx, ecx
    jnz     short loc_47B851
    mov     [eax+110h], ebx
    mov     ecx, TAdynmemStructPtr
    push    offset aTerrainElevati          ; "Terrain elevations affect a unit's view"...
    mov     edx, [ecx+29A0h]
    mov     [edx+114h], ebx
    jmp     short loc_47B88B
    ; ---------------------------------------------------------------------------

    loc_47B851:                             ; CODE XREF: sub_47AE60+9D0j
    cmp     [eax+114h], ebx
    jnz     short loc_47B86A
    mov     dword ptr [eax+114h], 0
    push    offset aTerrainEleva_0          ; "Terrain elevations do not affect a unit"...
    jmp     short loc_47B88B
    ; ---------------------------------------------------------------------------

    loc_47B86A:                             ; CODE XREF: sub_47AE60+9F7j
    mov     dword ptr [eax+110h], 0
    mov     ecx, TAdynmemStructPtr
    push    offset aAllMappedTerra          ; int
    mov     edx, [ecx+29A0h]
    mov     [edx+114h], ebx

    loc_47B88B:                             ; CODE XREF: sub_47AE60+86Cj
                                            ; sub_47AE60+876j ...
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esi+33h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A0090
    mov     edx, [esp+84h]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B8DB:                             ; CODE XREF: sub_47AE60+984j
    push    offset aSelectmap               ; "SelectMap"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_47B919
    push    0                               ; int
    push    offset aSkirmish_0              ; char *
    call    sub_47F1A0
    push    14h
    call    sub_491C80
    call    sub_47AAF0
    mov     edx, [esp+80h+arg_0]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B919:                             ; CODE XREF: sub_47AE60+A88j
    push    offset aDifficulty              ; "Difficulty"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      loc_47B9CC
    xor     esi, esi
    push    esi                             ; int
    push    offset aSkirmish                ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+37EEEh]
    cmp     eax, esi
    jnz     short loc_47B97C
    mov     edx, [ecx+29A0h]
    mov     ebx, 1
    mov     [edx+228h], ebx
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+80h+arg_0]
    push    edx
    mov     [eax+37EEEh], ebx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B97C:                             ; CODE XREF: sub_47AE60+AE7j
    cmp     eax, 1
    jnz     short loc_47B9B0
    mov     ecx, [ecx+29A0h]
    mov     [ecx+228h], edi
    mov     edx, TAdynmemStructPtr
    mov     [edx+37EEEh], edi
    mov     edx, [esp+80h+arg_0]
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47B9B0:                             ; CODE XREF: sub_47AE60+B1Fj
    cmp     eax, edi
    jnz     short loc_47B9CC
    mov     eax, [ecx+29A0h]
    mov     [eax+228h], esi
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37EEEh], esi

    loc_47B9CC:                             ; CODE XREF: sub_47AE60+499j
                                            ; sub_47AE60+5BEj ...
    mov     edx, [esp+80h+arg_0]
    push    edx
    call    sub_4AB0A0

    loc_47B9D9:                             ; CODE XREF: sub_47AE60+1Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn    4
    sub_47AE60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47B9F0 proc near                    ; DATA XREF: .text:0047BD35o

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    push    3                               ; size_t
    push    offset byte_508498              ; char *
    mov     eax, [esi+18h]
    xor     ebx, ebx
    add     eax, 34h
    xor     edi, edi
    push    eax                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_47BA1F
    mov     edi, 4
    jmp     loc_47BB0D
    ; ---------------------------------------------------------------------------

    loc_47BA1F:                             ; CODE XREF: sub_47B9F0+23j
    mov     ecx, [esi+18h]
    push    2                               ; size_t
    add     ecx, 35h
    push    offset byte_508494              ; char *
    push    ecx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_47BA43
    mov     edi, 5
    jmp     loc_47BB0D
    ; ---------------------------------------------------------------------------

    loc_47BA43:                             ; CODE XREF: sub_47B9F0+47j
    mov     edx, [esi+18h]
    push    3                               ; size_t
    add     edx, 34h
    push    offset off_508490               ; char *
    push    edx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_47BA67
    mov     edi, 6
    jmp     loc_47BB0D
    ; ---------------------------------------------------------------------------

    loc_47BA67:                             ; CODE XREF: sub_47B9F0+6Bj
    mov     eax, [esi+18h]
    push    4                               ; size_t
    add     eax, 33h
    push    offset aVii                     ; char *
    push    eax                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_47BA8B
    mov     edi, 7
    jmp     loc_47BB0D
    ; ---------------------------------------------------------------------------

    loc_47BA8B:                             ; CODE XREF: sub_47B9F0+8Fj
    mov     ecx, [esi+18h]
    push    5                               ; size_t
    add     ecx, 32h
    push    offset aViii                    ; char *
    push    ecx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_47BAAC
    mov     edi, 8
    jmp     short loc_47BB0D
    ; ---------------------------------------------------------------------------

    loc_47BAAC:                             ; CODE XREF: sub_47B9F0+B3j
    mov     edx, [esi+18h]
    push    4                               ; size_t
    add     edx, 33h
    push    offset aIii                     ; char *
    push    edx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_47BACD
    mov     edi, 3
    jmp     short loc_47BB0D
    ; ---------------------------------------------------------------------------

    loc_47BACD:                             ; CODE XREF: sub_47B9F0+D4j
    mov     eax, [esi+18h]
    push    3                               ; size_t
    add     eax, 34h
    push    offset aIx                      ; char *
    push    eax                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_47BAEE
    mov     edi, 9
    jmp     short loc_47BB0D
    ; ---------------------------------------------------------------------------

    loc_47BAEE:                             ; CODE XREF: sub_47B9F0+F5j
    mov     ecx, [esi+18h]
    push    2                               ; size_t
    add     ecx, 35h
    push    offset asc_508470               ; char *
    push    ecx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_47BB0D
    mov     edi, 0Ah

    loc_47BB0D:                             ; CODE XREF: sub_47B9F0+2Aj
                                            ; sub_47B9F0+4Ej ...
    cmp     edi, ebx
    jz      loc_47BB9F
    cmp     edi, 3
    jz      short loc_47BB2E
    cmp     edi, 4
    jz      short loc_47BB2E
    cmp     edi, 8
    jz      short loc_47BB2E
    cmp     edi, 9
    jz      short loc_47BB2E
    cmp     edi, 0Ah
    jnz     short loc_47BB3D

    loc_47BB2E:                             ; CODE XREF: sub_47B9F0+128j
                                            ; sub_47B9F0+12Dj ...
    xor     eax, eax

    loc_47BB30:                             ; CODE XREF: sub_47B9F0+14Bj
    mov     edx, [esi+18h]
    inc     eax
    cmp     eax, 0Fh
    mov     [eax+edx+27h], bl
    jl      short loc_47BB30

    loc_47BB3D:                             ; CODE XREF: sub_47B9F0+13Cj
    call    WriteRegistrySettings_2
    mov     eax, TAdynmemStructPtr
    mov     [eax+38D81h], edi
    call    sub_432B80
    call    WriteRegistrySettings_1
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esi+18h]
    mov     edx, [ecx+29A0h]
    mov     ecx, [eax+4]
    mov     dx, [edx+220h]
    mov     [ecx+0B6h], dx
    call    sub_47A0E0
    push    ebx                             ; int
    push    offset aSkirmishcheat           ; char *
    call    sub_47F1A0
    push    1
    push    esi
    call    sub_4A7960
    mov     eax, TAdynmemStructPtr
    add     eax, TAdynmemStruct.field_519
    push    eax                             ; int
    call    sub_49FA90

    loc_47BB9F:                             ; CODE XREF: sub_47B9F0+11Fj
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_47B9F0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    call    sub_4257A0
    mov     eax, TAdynmemStructPtr
    push    0
    add     eax, 519h
    push    offset aSkirmish_gui            ; "SKIRMISH.GUI"
    push    eax
    call    sub_4AA8F0
    push    0
    mov     dword ptr [eax+8], offset sub_47AE60
    mov     ecx, TAdynmemStructPtr
    push    0
    push    0
    push    offset aSkirmsetup4x            ; "Skirmsetup4x"
    mov     [eax+0Ch], ecx
    call    sub_4288D0
    mov     eax, TAdynmemStructPtr
    push    offset aDifficulty              ; "Difficulty"
    mov     edx, [eax+29A0h]
    mov     ecx, [edx+228h]
    mov     [eax+37EEEh], ecx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx
    call    sub_49FF10
    mov     edx, TAdynmemStructPtr
    mov     esi, eax
    mov     eax, [edx+37EEEh]
    test    eax, eax
    jnz     short loc_47BC4E
    mov     byte ptr [esi+137h], 0
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    offset aEasy                    ; "Easy"
    push    eax
    call    sub_4A1110

    loc_47BC4E:                             ; CODE XREF: .text:0047BC2Ej
    mov     ecx, TAdynmemStructPtr
    cmp     dword ptr [ecx+37EEEh], 1
    jnz     short loc_47BC7D
    mov     byte ptr [esi+137h], 1
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    offset aMedium                  ; "Medium"
    push    edx
    call    sub_4A1110

    loc_47BC7D:                             ; CODE XREF: .text:0047BC5Bj
    mov     ecx, TAdynmemStructPtr
    mov     eax, 2
    cmp     [ecx+37EEEh], eax
    jnz     short loc_47BCAF
    mov     [esi+137h], al
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    offset aHard                    ; "Hard"
    push    edx
    call    sub_4A1110

    loc_47BCAF:                             ; CODE XREF: .text:0047BC8Ej
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA90
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    add     ecx, 11Ch
    push    ecx
    mov     ecx, [eax+391E9h]
    call    sub_435A20
    test    eax, eax
    jnz     short loc_47BD23
    mov     edx, TAdynmemStructPtr
    push    eax
    mov     ecx, [edx+391E9h]
    call    sub_435D30
    mov     eax, TAdynmemStructPtr
    push    100h
    mov     ecx, [eax+391E9h]
    call    sub_435C30
    mov     ecx, TAdynmemStructPtr
    push    eax
    mov     edx, [ecx+29A0h]
    add     edx, 11Ch
    push    edx
    call    _strncpy
    add     esp, 0Ch

    loc_47BD23:                             ; CODE XREF: .text:0047BCDEj
    call    sub_47A0E0
    mov     eax, TAdynmemStructPtr
    push    1
    mov     ecx, [eax+531h]
    mov     dword ptr [ecx+3Bh], offset sub_47B9F0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_49FB10
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0
    push    13h
    call    sub_491C80
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47BD70 proc near                    ; CODE XREF: sub_4866D0+784p

    var_C8= byte ptr -0C8h
    arg_0= dword ptr  4

    sub     esp, 0C8h
    push    esi
    push    edi
    mov     edi, [esp+0D0h+arg_0]
    mov     esi, offset aCore               ; "Core"
    mov     eax, [edi+27h]
    mov     cl, [eax+95h]
    test    cl, cl
    jnz     short loc_47BD96
    mov     esi, offset aArm                ; "Arm"

    loc_47BD96:                             ; CODE XREF: sub_47BD70+1Fj
    call    _rand
    xor     edx, edx
    mov     ecx, 3
    div     ecx
    mov     edx, dword_507B88[edx*4]
    push    edx                             ; int
    call    sub_4C5740
    push    eax
    push    esi
    lea     eax, [esp+0D8h+var_C8]
    push    offset aSS_0                    ; "%s %s"
    push    eax
    call    _sprintf
    mov     cl, [edi+146h]
    add     esp, 10h
    lea     edx, [esp+0D0h+var_C8]
    push    ecx                             ; char
    push    0                               ; __int16
    push    4                               ; char
    push    edx                             ; char *
    call    sub_463CA0
    pop     edi
    pop     esi
    add     esp, 0C8h
    retn    4
    sub_47BD70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47BDF0 proc near                    ; CODE XREF: .text:00426808p

    var_80= dword ptr -80h
    var_30= dword ptr -30h
    var_4= dword ptr -4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    sub     esp, 64h
    push    ebx
    push    esi
    mov     esi, ecx
    xor     ebx, ebx
    cmp     eax, ebx
    push    edi
    mov     [esi+8], ebx
    mov     [esi+4], ebx
    jz      short loc_47BE13
    mov     eax, [esp+70h+arg_8]
    push    eax
    call    ds:_SmackSimulate@4             ; SmackSimulate(x)

    loc_47BE13:                             ; CODE XREF: sub_47BDF0+16j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+10h]
    mov     edi, [edx+24h]
    push    edi
    call    ds:_SmackSoundUseDirectSound@4  ; SmackSoundUseDirectSound(x)
    mov     eax, [esp+74h]
    push    0FFFFFFFFh
    push    0FE100h
    push    eax
    call    ds:_SmackOpen@12                ; SmackOpen(x,x,x)
    cmp     eax, ebx
    mov     [esi], eax
    jnz     short loc_47BE48
    push    offset aCouldNotOpenMo          ; lpText
    call    sub_4B6290

    loc_47BE48:                             ; CODE XREF: sub_47BDF0+4Cj
    mov     edx, [esi]
    xor     ecx, ecx
    cmp     edi, ebx
    setnz   cl
    push    ecx
    push    edx
    call    ds:_SmackSoundOnOff@8           ; SmackSoundOnOff(x,x)
    call    sub_4B6220
    mov     ecx, [eax+40h]
    mov     [esi+0Ch], ecx
    mov     cx, [eax+0F0h]
    and     cx, 2
    jz      short loc_47BE8F
    mov     edi, [eax+84h]
    lea     edx, [eax+84h]
    cmp     edi, ebx
    jz      short loc_47BE8F
    mov     [esi+544h], edx
    mov     [esi+414h], ebx
    jmp     short loc_47BEED
    ; ---------------------------------------------------------------------------

    loc_47BE8F:                             ; CODE XREF: sub_47BDF0+7Fj
                                            ; sub_47BDF0+8Fj
    cmp     cx, bx
    jnz     short loc_47BEED
    cmp     [eax+84h], ebx
    jnz     short loc_47BEED
    lea     eax, [esi+528h]
    mov     [esi+544h], eax
    mov     [eax], ebx
    mov     edx, [esi+544h]
    mov     [edx+4], ebx
    mov     eax, [esi+544h]
    mov     [eax+8], ebx
    mov     ecx, [esi+544h]
    mov     [ecx+10h], ebx
    mov     edx, [esi+544h]
    mov     ecx, esi
    mov     [edx+0Ch], ebx
    call    sub_47BF70
    test    eax, eax
    jnz     short loc_47BEE3
    push    offset aCouldNotSetupD          ; lpText
    call    sub_4B6290

    loc_47BEE3:                             ; CODE XREF: sub_47BDF0+E7j
    mov     dword ptr [esi+414h], 1

    loc_47BEED:                             ; CODE XREF: sub_47BDF0+9Dj
                                            ; sub_47BDF0+A2j ...
    mov     eax, [esi+544h]
    lea     edx, [esp+0Ch]
    mov     dword ptr [esp+0Ch], 64h
    mov     [esp+5Ch], ebx
    mov     eax, [eax+4]
    push    edx
    push    1000400h
    push    ebx
    mov     ecx, [eax]
    push    ebx
    push    ebx
    push    eax
    call    dword ptr [ecx+14h]
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 64h
    retn    18h
    sub_47BDF0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47BF20 proc near                    ; CODE XREF: .text:0042683Fp
    push    esi
    mov     esi, ecx
    mov     eax, [esi]
    push    eax
    call    ds:_SmackClose@4                ; SmackClose(x)
    mov     eax, [esi+414h]
    test    eax, eax
    jz      short loc_47BF6E
    mov     ecx, [esi+544h]
    mov     eax, [ecx+10h]
    test    eax, eax
    jz      short loc_47BF49
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+8]

    loc_47BF49:                             ; CODE XREF: sub_47BF20+21j
    mov     eax, [esi+544h]
    mov     eax, [eax+4]
    test    eax, eax
    jz      short loc_47BF5C
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+8]

    loc_47BF5C:                             ; CODE XREF: sub_47BF20+34j
    mov     edx, [esi+544h]
    mov     eax, [edx]
    test    eax, eax
    jz      short loc_47BF6E
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+8]

    loc_47BF6E:                             ; CODE XREF: sub_47BF20+14j
                                            ; sub_47BF20+46j
    pop     esi
    retn
    sub_47BF20 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47BF70 proc near                    ; CODE XREF: sub_47BDF0+E0p

    Point= tagPOINT ptr -8

    sub     esp, 8
    push    ebp
    push    esi
    mov     esi, ecx
    lea     eax, [esp+10h+Point]
    push    edi
    push    eax                             ; lpPoint
    mov     ecx, [esi+0Ch]
    mov     [esp+18h+Point.x], 0
    push    ecx                             ; hWnd
    mov     [esp+1Ch+Point.y], 0
    call    ds:ClientToScreen               ; Convert the client coordinates of a
                                            ; specified point to screen coordinates.
    mov     edx, [esi+544h]
    push    0                               ; pUnkOuter
    push    edx                             ; lplpDD
    push    0                               ; lpGUID
    call    DirectDrawCreate
    test    eax, eax
    jnz     short loc_47BFD1
    mov     eax, [esi+544h]
    mov     edx, [esi+0Ch]
    push    8
    push    edx
    mov     eax, [eax]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+50h]
    test    eax, eax
    jz      short loc_47BFDA
    mov     eax, [esi+544h]
    mov     eax, [eax]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+8]

    loc_47BFD1:                             ; CODE XREF: sub_47BF70+39j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_47BFDA:                             ; CODE XREF: sub_47BF70+51j
    lea     edx, [esi+548h]
    mov     ecx, 1Bh
    xor     eax, eax
    mov     edi, edx
    rep stosd
    mov     eax, [esi+544h]
    mov     dword ptr [edx], 6Ch
    mov     dword ptr [esi+54Ch], 1
    mov     dword ptr [esi+5B0h], 200h
    mov     ecx, [eax]
    add     eax, 4
    push    0
    push    eax
    mov     edi, [ecx]
    push    edx
    push    ecx
    call    dword ptr [edi+18h]
    test    eax, eax
    jnz     loc_47C0EA
    mov     edx, [esi+544h]
    mov     ecx, esi
    mov     eax, [edx+4]
    push    eax
    call    sub_47C150
    test    eax, eax
    mov     [esi+410h], eax
    jnz     loc_47C0CE
    mov     ecx, [esi+0Ch]
    push    ecx                             ; hWnd
    call    ds:GetDC
    lea     ebp, [esi+10h]
    mov     edi, eax
    push    ebp                             ; LPPALETTEENTRY
    push    100h                            ; UINT
    push    0                               ; UINT
    push    edi                             ; HDC
    call    ds:GetSystemPaletteEntries
    lea     eax, [esi+13h]
    mov     ecx, 0Ah

    loc_47C067:                             ; CODE XREF: sub_47BF70+FEj
    mov     byte ptr [eax], 0
    add     eax, 4
    dec     ecx
    jnz     short loc_47C067
    lea     eax, [esi+3Bh]
    mov     ecx, 0ECh

    loc_47C078:                             ; CODE XREF: sub_47BF70+10Fj
    mov     byte ptr [eax], 4
    add     eax, 4
    dec     ecx
    jnz     short loc_47C078
    lea     eax, [esi+3EBh]
    mov     ecx, 0Ah

    loc_47C08C:                             ; CODE XREF: sub_47BF70+123j
    mov     byte ptr [eax], 0
    add     eax, 4
    dec     ecx
    jnz     short loc_47C08C
    mov     edx, [esi+0Ch]
    push    edi                             ; hDC
    push    edx                             ; hWnd
    call    ds:ReleaseDC
    mov     eax, [esi+544h]
    push    0
    mov     ecx, [eax]
    add     eax, 10h
    push    eax
    push    ebp
    mov     edx, [ecx]
    push    4
    push    ecx
    call    dword ptr [edx+14h]
    test    eax, eax
    jnz     short loc_47C0CE
    mov     eax, [esi+544h]
    mov     ecx, [eax+4]
    mov     eax, [eax+10h]
    push    eax
    push    ecx
    mov     edx, [ecx]
    call    dword ptr [edx+7Ch]

    loc_47C0CE:                             ; CODE XREF: sub_47BF70+CBj
                                            ; sub_47BF70+149j
    mov     eax, [esi]
    push    2                               ; uFlags
    mov     ecx, [eax+8]
    mov     edx, [eax+4]
    mov     eax, [esi+0Ch]
    push    ecx                             ; cy
    push    edx                             ; cx
    push    0                               ; Y
    push    0                               ; X
    push    0                               ; hWndInsertAfter
    push    eax                             ; hWnd
    call    ds:SetWindowPos

    loc_47C0EA:                             ; CODE XREF: sub_47BF70+ACj
    mov     ecx, [esi]
    mov     eax, [ecx+68h]
    test    eax, eax
    jz      short loc_47C13C
    mov     edx, [esi+0Ch]
    push    0
    push    0
    push    1E0h
    push    280h
    push    0
    push    edx
    call    ds:_SmackBufferOpen@24          ; SmackBufferOpen(x,x,x,x,x,x)
    mov     edi, eax
    mov     eax, [esi]
    mov     cx, [eax+370h]
    add     eax, 6Ch
    push    ecx
    push    eax
    push    edi
    call    ds:_SmackBufferNewPalette@12    ; SmackBufferNewPalette(x,x,x)
    mov     edx, [edi+43Ch]
    mov     eax, [edi+2Ch]
    mov     ecx, [esi]
    push    edx
    add     edi, 3Ch
    push    eax
    push    edi
    push    ecx
    call    ds:_SmackColorRemap@16          ; SmackColorRemap(x,x,x,x)

    loc_47C13C:                             ; CODE XREF: sub_47BF70+181j
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebp
    add     esp, 8
    retn
    sub_47BF70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47C150 proc near                    ; CODE XREF: sub_47BF70+BEp

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h

    sub     esp, 20h
    mov     eax, [ecx+544h]
    mov     [esp+20h+var_20], 20h
    mov     [esp+20h+var_1C], 40h
    lea     edx, [esp+20h+var_20]
    mov     eax, [eax+4]
    push    edx
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+54h]
    cmp     [esp+20h+var_14], 8
    jz      loc_47C21E
    mov     eax, [esp+20h+var_10]
    mov     ecx, [esp+18h]
    mov     edx, [esp+14h]
    cmp     eax, 0F800h
    jnz     short loc_47C1AD
    cmp     edx, 7E0h
    jnz     short loc_47C1AD
    cmp     ecx, 1Fh
    jnz     short loc_47C1AD
    mov     eax, 0C0000000h
    add     esp, 20h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47C1AD:                             ; CODE XREF: sub_47C150+43j
                                            ; sub_47C150+4Bj ...
    cmp     eax, 7C00h
    jnz     short loc_47C1CC
    cmp     edx, 3E0h
    jnz     short loc_47C1CC
    cmp     ecx, 1Fh
    jnz     short loc_47C1CC
    mov     eax, 80000000h
    add     esp, 20h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47C1CC:                             ; CODE XREF: sub_47C150+62j
                                            ; sub_47C150+6Aj ...
    cmp     eax, 0F800h
    jnz     short loc_47C1EB
    cmp     edx, 7C0h
    jnz     short loc_47C1EB
    cmp     ecx, 3Fh
    jnz     short loc_47C1EB
    mov     eax, 0A0000000h
    add     esp, 20h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47C1EB:                             ; CODE XREF: sub_47C150+81j
                                            ; sub_47C150+89j ...
    cmp     eax, 0FC00h
    jnz     short loc_47C20A
    cmp     edx, 3E0h
    jnz     short loc_47C20A
    cmp     ecx, 1Fh
    jnz     short loc_47C20A
    mov     eax, 0E0000000h
    add     esp, 20h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47C20A:                             ; CODE XREF: sub_47C150+A0j
                                            ; sub_47C150+A8j ...
    push    0                               ; uType
    push    offset aSmackerError            ; lpCaption
    push    offset aUnsupportedPix          ; lpText
    push    0                               ; hWnd
    call    ds:MessageBoxA

    loc_47C21E:                             ; CODE XREF: sub_47C150+2Cj
    xor     eax, eax
    add     esp, 20h
    retn    4
    sub_47C150 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+0Ch]
    push    eax
    call    ds:GetDC
    lea     ecx, [esi+10h]
    mov     edi, eax
    push    ecx
    push    100h
    push    0
    push    edi
    call    ds:GetSystemPaletteEntries
    lea     eax, [esi+13h]
    mov     ecx, 0Ah

    loc_47C25A:                             ; CODE XREF: .text:0047C261j
    mov     byte ptr [eax], 0
    add     eax, 4
    dec     ecx
    jnz     short loc_47C25A
    lea     eax, [esi+3Bh]
    mov     ecx, 0ECh

    loc_47C26B:                             ; CODE XREF: .text:0047C272j
    mov     byte ptr [eax], 4
    add     eax, 4
    dec     ecx
    jnz     short loc_47C26B
    lea     eax, [esi+3EBh]
    mov     ecx, 0Ah

    loc_47C27F:                             ; CODE XREF: .text:0047C286j
    mov     byte ptr [eax], 0
    add     eax, 4
    dec     ecx
    jnz     short loc_47C27F
    mov     edx, [esi+0Ch]
    push    edi
    push    edx
    call    ds:ReleaseDC
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    push    edi
    mov     edi, ecx
    mov     esi, 100h
    mov     eax, [edi]
    lea     edx, [edi+11h]
    add     eax, 6Ch

    loc_47C2B1:                             ; CODE XREF: .text:0047C2C7j
    mov     cl, [eax]
    inc     eax
    mov     [edx-1], cl
    add     edx, 4
    mov     cl, [eax]
    inc     eax
    mov     [edx-4], cl
    mov     cl, [eax]
    inc     eax
    mov     [edx-3], cl
    dec     esi
    jnz     short loc_47C2B1
    mov     edx, [edi+544h]
    add     edi, 10h
    push    edi
    push    100h
    mov     eax, [edx+10h]
    push    0
    push    0
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+18h]
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 64h
    mov     eax, [ecx+544h]
    lea     edx, [esp+0]
    mov     dword ptr [esp+0], 64h
    mov     dword ptr [esp+50h], 0
    mov     eax, [eax+4]
    push    edx
    push    1000400h
    push    0
    mov     ecx, [eax]
    push    0
    push    0
    push    eax
    call    dword ptr [ecx+14h]
    add     esp, 64h
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 40h
    lea     eax, [esp+0]
    push    esi
    push    edi
    mov     edi, [esp+4Ch]
    push    eax
    mov     esi, ecx
    push    edi
    call    ds:BeginPaint
    mov     ecx, [esi]
    push    42h
    mov     edx, [ecx+8]
    mov     ecx, [ecx+4]
    push    edx
    push    ecx
    push    0
    push    0
    push    eax
    call    ds:PatBlt
    lea     edx, [esp+8]
    push    edx
    push    edi
    call    ds:EndPaint
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_47C392
    mov     eax, [esi]
    mov     edi, ds:_SmackSoundOnOff@8      ; SmackSoundOnOff(x,x)
    push    0
    push    eax
    call    edi ; SmackSoundOnOff(x,x)      ; SmackSoundOnOff(x,x)
    mov     ecx, [esi+4]
    mov     edx, [esi]
    push    ecx
    push    edx
    call    ds:_SmackGoto@8                 ; SmackGoto(x,x)
    mov     eax, [esi]
    push    1
    push    eax
    call    edi ; SmackSoundOnOff(x,x)      ; SmackSoundOnOff(x,x)

    loc_47C392:                             ; CODE XREF: .text:0047C36Fj
    pop     edi
    pop     esi
    add     esp, 40h
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47C3A0 proc near                    ; CODE XREF: sub_47C6C0+81p

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     esi, ecx
    call    ds:GetFocus
    cmp     eax, [esp+arg_0]
    jnz     loc_47C4C1
    mov     eax, [esi+8]
    test    eax, eax
    jnz     loc_47C4C1
    mov     eax, [esi]
    mov     ecx, [eax+68h]
    test    ecx, ecx
    jz      short loc_47C407
    add     eax, 6Ch
    lea     ecx, [esi+11h]
    mov     edi, 100h

    loc_47C3D3:                             ; CODE XREF: sub_47C3A0+49j
    mov     dl, [eax]
    inc     eax
    mov     [ecx-1], dl
    add     ecx, 4
    mov     dl, [eax]
    inc     eax
    mov     [ecx-4], dl
    mov     dl, [eax]
    inc     eax
    mov     [ecx-3], dl
    dec     edi
    jnz     short loc_47C3D3
    mov     eax, [esi+544h]
    lea     edx, [esi+10h]
    push    edx
    push    100h
    mov     eax, [eax+10h]
    push    0
    push    0
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+18h]

    loc_47C407:                             ; CODE XREF: sub_47C3A0+26j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esi]
    push    0
    mov     eax, [edx+37E1Bh]
    mov     edx, [ecx+8]
    mov     edi, [eax+0Ch]
    mov     eax, [eax+8]
    push    edi
    push    edx
    push    eax
    mov     eax, 1E0h
    sub     eax, edx
    shr     eax, 1
    push    eax
    push    0
    push    ecx
    call    ds:_SmackToBuffer@28            ; SmackToBuffer(x,x,x,x,x,x,x)
    mov     ecx, [esi]
    push    ecx
    call    ds:_SmackDoFrame@4              ; SmackDoFrame(x)
    call    sub_4C63A0
    mov     edx, [esi]
    push    1
    push    edx
    call    ds:_SmackToBufferRect@8         ; SmackToBufferRect(x,x)
    test    eax, eax
    jz      short loc_47C49E
    mov     eax, [esi]
    mov     ecx, [eax+380h]
    test    ecx, ecx
    jnz     short loc_47C49E
    mov     ecx, [eax+384h]
    test    ecx, ecx
    jnz     short loc_47C49E
    mov     ecx, [eax+388h]
    mov     edx, [eax+4]
    cmp     ecx, edx
    jnz     short loc_47C49E
    mov     edx, [eax+38Ch]
    mov     ecx, [eax+8]
    cmp     edx, ecx
    jnz     short loc_47C49E
    mov     eax, [eax+374h]
    inc     eax
    mov     [esi+4], eax

    loc_47C49E:                             ; CODE XREF: sub_47C3A0+C2j
                                            ; sub_47C3A0+CEj ...
    mov     eax, [esi]
    mov     ecx, [eax+0Ch]
    mov     edx, [eax+374h]
    dec     ecx
    cmp     edx, ecx
    jnz     short loc_47C4BA
    mov     dword ptr [esi+8], 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47C4BA:                             ; CODE XREF: sub_47C3A0+10Cj
    push    eax
    call    ds:_SmackNextFrame@4            ; SmackNextFrame(x)

    loc_47C4C1:                             ; CODE XREF: sub_47C3A0+Ej
                                            ; sub_47C3A0+19j
    pop     edi
    pop     esi
    retn    4
    sub_47C3A0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 400h
    mov     ecx, 100h
    xor     eax, eax
    push    edi
    lea     edi, [esp+4]
    push    offset aR_0                     ; "r"
    push    offset aStats_txt               ; "stats.txt"
    rep stosd
    call    _fopen
    add     esp, 8
    test    eax, eax
    jz      short loc_47C526
    push    eax
    push    1
    lea     eax, [esp+0Ch]
    push    400h
    push    eax
    call    sub_4E5BC0
    add     esp, 10h
    lea     ecx, [esp+4]
    push    40000h
    push    offset aSummary_0               ; "Summary"
    push    ecx
    push    0
    call    ds:MessageBoxA

    loc_47C526:                             ; CODE XREF: .text:0047C4F8j
    pop     edi
    add     esp, 400h
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, [ecx]
    sub     esp, 54h
    lea     eax, [esp+0]
    push    esi
    push    eax
    push    ecx
    call    ds:_SmackSummary@8              ; SmackSummary(x,x)
    push    offset aW                       ; "w"
    push    offset aStats_txt               ; "stats.txt"
    call    _fopen
    mov     esi, eax
    add     esp, 8
    test    esi, esi
    jz      loc_47C6B9
    mov     eax, [esp+10h]
    xor     edx, edx
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 3
    div     dword ptr [esp+4]
    push    eax
    push    offset aFramesPerSecD           ; "Frames Per Sec\t%d\n"
    push    esi
    call    sub_4E4510
    mov     ecx, [esp+10h]
    xor     edx, edx
    add     esp, 0Ch
    lea     eax, [ecx+ecx*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 3
    div     ecx
    push    eax
    push    offset aTotalPlaybackT          ; "Total Playback Time\t%d\n"
    push    esi
    call    sub_4E4510
    mov     edx, [esp+18h]
    add     esp, 0Ch
    push    edx
    push    offset aTimeToOpenFile          ; "Time to Open File\t%d\n"
    push    esi
    call    sub_4E4510
    mov     eax, [esp+1Ch]
    add     esp, 0Ch
    push    eax
    push    offset aTotalFramesPla          ; "Total Frames Played\t%d\n"
    push    esi
    call    sub_4E4510
    mov     ecx, [esp+20h]
    add     esp, 0Ch
    push    ecx
    push    offset aSkippedframesD          ; "SkippedFrames\t%d\n"
    push    esi
    call    sub_4E4510
    mov     edx, [esp+28h]
    add     esp, 0Ch
    push    edx
    push    offset aTotalblittimeD          ; "TotalBlitTime\t%d\n"
    push    esi
    call    sub_4E4510
    mov     eax, [esp+2Ch]
    add     esp, 0Ch
    push    eax
    push    offset aTotalreadtimeD          ; "TotalReadTime\t%d\n"
    push    esi
    call    sub_4E4510
    mov     ecx, [esp+30h]
    add     esp, 0Ch
    push    ecx
    push    offset aTotaldecomptim          ; "TotalDecompTime\t%d\n"
    push    esi
    call    sub_4E4510
    mov     edx, [esp+38h]
    add     esp, 0Ch
    push    edx
    push    offset aTotalreadspeed          ; "TotalReadSpeed\t%d bytes/sec\n"
    push    esi
    call    sub_4E4510
    mov     eax, [esp+3Ch]
    add     esp, 0Ch
    push    eax
    push    offset aSlowestframeti          ; "SlowestFrameTime\t%d\n"
    push    esi
    call    sub_4E4510
    mov     ecx, [esp+40h]
    add     esp, 0Ch
    push    ecx
    push    offset aSlowest2framet          ; "Slowest2FrameTime\t%d\n"
    push    esi
    call    sub_4E4510
    mov     edx, [esp+4Ch]
    add     esp, 0Ch
    push    edx
    push    offset aAverageframesi          ; "AverageFrameSize\t%d\n"
    push    esi
    call    sub_4E4510
    mov     eax, [esp+50h]
    add     esp, 0Ch
    push    eax
    push    offset aHighest1secrat          ; "Highest1SecRate\t%d\n"
    push    esi
    call    sub_4E4510
    mov     ecx, [esp+58h]
    add     esp, 0Ch
    push    ecx
    push    offset aHighestmemamou          ; "HighestMemAmount\t%d\n"
    push    esi
    call    sub_4E4510
    mov     edx, [esp+5Ch]
    add     esp, 0Ch
    push    edx
    push    offset aTotalextramemo          ; "TotalExtraMemory\t%d\n"
    push    esi
    call    sub_4E4510
    mov     eax, [esp+60h]
    add     esp, 0Ch
    push    eax
    push    offset aHighestextraus          ; "HighestExtraUsed\t%d\n"
    push    esi
    call    sub_4E4510
    add     esp, 0Ch
    push    esi
    call    _fclose
    add     esp, 4

    loc_47C6B9:                             ; CODE XREF: .text:0047C558j
    pop     esi
    add     esp, 54h
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47C6C0 proc near                    ; CODE XREF: .text:00426829p

    Msg= MSG ptr -1Ch

    sub     esp, 1Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    xor     ebx, ebx
    push    edi
    cmp     [esi+8], ebx
    jnz     loc_47C768
    mov     ebp, ds:PeekMessageA
    mov     edi, 1

    loc_47C6DF:                             ; CODE XREF: sub_47C6C0+89j
    push    edi                             ; wRemoveMsg
    push    ebx                             ; wMsgFilterMax
    push    ebx                             ; wMsgFilterMin
    lea     eax, [esp+38h+Msg]
    push    ebx                             ; hWnd
    push    eax                             ; lpMsg
    call    ebp ; PeekMessageA
    test    eax, eax
    jz      short loc_47C72E
    mov     eax, [esp+2Ch+Msg.message]
    cmp     eax, 104h
    jnz     short loc_47C700
    cmp     [esp+2Ch+Msg.wParam], 73h
    jz      short loc_47C753

    loc_47C700:                             ; CODE XREF: sub_47C6C0+37j
    cmp     eax, 102h
    jnz     short loc_47C716
    mov     [esi+8], edi
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+39241h], ebx

    loc_47C716:                             ; CODE XREF: sub_47C6C0+45j
    lea     edx, [esp+2Ch+Msg]
    push    edx                             ; lpMsg
    call    ds:TranslateMessage
    lea     eax, [esp+2Ch+Msg]
    push    eax                             ; lpMsg
    call    ds:DispatchMessageA
    jmp     short loc_47C746
    ; ---------------------------------------------------------------------------

    loc_47C72E:                             ; CODE XREF: sub_47C6C0+2Cj
    mov     ecx, [esi]
    push    ecx
    call    ds:_SmackWait@4                 ; SmackWait(x)
    test    eax, eax
    jnz     short loc_47C746
    mov     edx, [esi+0Ch]
    mov     ecx, esi
    push    edx
    call    sub_47C3A0

    loc_47C746:                             ; CODE XREF: sub_47C6C0+6Cj
                                            ; sub_47C6C0+79j
    cmp     [esi+8], ebx
    jz      short loc_47C6DF
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_47C753:                             ; CODE XREF: sub_47C6C0+3Ej
    mov     [esi+8], edi
    mov     eax, TAdynmemStructPtr
    push    ebx                             ; nExitCode
    mov     [eax+39241h], ebx
    call    ds:PostQuitMessage

    loc_47C768:                             ; CODE XREF: sub_47C6C0+Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    sub_47C6C0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47C770 proc near                    ; CODE XREF: sub_40A260+276p
                                            ; sub_40A260+285p ...
    mov     eax, dword_51E688
    retn
    sub_47C770 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47C780 proc near                    ; CODE XREF: sub_4197D0+125p
    mov     eax, dword_51E684
    retn
    sub_47C780 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47C790 proc near                    ; CODE XREF: sub_47DAC0+3Dp
                                            ; sub_47ED30+5p

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+110h]
    mov     ecx, eax
    shr     ecx, 1Bh
    test    cl, 1
    jz      loc_47CAB9
    mov     edi, [esi+7Eh]
    and     eax, 0F7FFFFFFh
    test    eax, 20000000h
    mov     [esi+110h], eax
    mov     [esp+4+arg_0], edi
    jz      loc_47C8F3
    movsx   edx, word ptr [esi+78h]
    movsx   eax, word ptr [esi+76h]
    push    edx
    push    eax
    call    sub_481550
    xor     ebp, ebp
    movsx   ecx, word ptr [esp+4+arg_0+2]
    test    ecx, ecx
    jle     loc_47CAB9
    movsx   ebx, di
    mov     [esp+4+arg_0], ecx

    loc_47C7EE:                             ; CODE XREF: sub_47C790+156j
    test    ebx, ebx
    jle     loc_47C8C7
    mov     edi, ebx

    loc_47C7F8:                             ; CODE XREF: sub_47C790+131j
    mov     ecx, [esi+92h]
    mov     edx, [ecx+14Eh]
    mov     cl, [esi+10Fh]
    and     cl, 4
    neg     cl
    sbb     ecx, ecx
    and     ecx, 0FFFFFFFEh
    add     ecx, 4
    test    [edx+ebp], cl
    mov     cx, [eax]
    jz      loc_47C8AE
    test    cx, cx
    jz      short loc_47C8A2
    and     ecx, 0FFFFh
    mov     edx, ecx
    shl     ecx, 3
    sub     ecx, edx
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+14357h]
    lea     ecx, [ecx+edx*8]
    mov     edx, [ecx+96h]
    cmp     dword ptr [edx], 0
    jz      short loc_47C858
    cmp     byte ptr [edx+73h], 3
    jz      short loc_47C87E

    loc_47C858:                             ; CODE XREF: sub_47C790+C0j
    mov     edx, [ecx+110h]
    or      edx, 4000000h
    mov     [ecx+110h], edx
    mov     ecx, [esi+110h]
    or      ecx, 8000000h
    mov     [esi+110h], ecx
    jmp     short loc_47C8BC
    ; ---------------------------------------------------------------------------

    loc_47C87E:                             ; CODE XREF: sub_47C790+C6j
    mov     edx, [ecx+110h]
    or      edx, 8000000h
    mov     [ecx+110h], edx
    mov     ecx, [esi+110h]
    or      ecx, 4000000h
    mov     [esi+110h], ecx

    loc_47C8A2:                             ; CODE XREF: sub_47C790+96j
    mov     dx, [esi+0A8h]
    mov     [eax], dx
    jmp     short loc_47C8BC
    ; ---------------------------------------------------------------------------

    loc_47C8AE:                             ; CODE XREF: sub_47C790+8Dj
    cmp     cx, [esi+0A8h]
    jnz     short loc_47C8BC
    mov     word ptr [eax], 0

    loc_47C8BC:                             ; CODE XREF: sub_47C790+ECj
                                            ; sub_47C790+11Cj ...
    inc     ebp
    add     eax, 0Dh
    dec     edi
    jnz     loc_47C7F8

    loc_47C8C7:                             ; CODE XREF: sub_47C790+60j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+14233h]
    sub     ecx, ebx
    lea     edx, [ecx+ecx*2]
    lea     eax, [eax+edx*4]
    add     eax, ecx
    mov     ecx, [esp+4+arg_0]
    dec     ecx
    mov     [esp+4+arg_0], ecx
    jnz     loc_47C7EE
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47C8F3:                             ; CODE XREF: sub_47C790+33j
    movsx   ecx, word ptr [esi+78h]
    movsx   edx, word ptr [esi+76h]
    and     eax, 3
    push    ecx
    cmp     al, 1
    push    edx
    jnz     loc_47C9E3
    call    sub_481550
    movsx   ecx, word ptr [esp+4+arg_0+2]
    test    ecx, ecx
    jle     loc_47CAB9
    movsx   ebp, di
    mov     ebx, ecx

    loc_47C91F:                             ; CODE XREF: sub_47C790+246j
    test    ebp, ebp
    jle     loc_47C9BF
    mov     edi, ebp

    loc_47C929:                             ; CODE XREF: sub_47C790+229j
    mov     cx, [eax]
    test    cx, cx
    jz      short loc_47C9AB
    and     ecx, 0FFFFh
    mov     edx, ecx
    shl     ecx, 3
    sub     ecx, edx
    mov     edx, TAdynmemStructPtr
    mov     edx, [edx+14357h]
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [edx+ecx*8]
    mov     edx, [ecx+96h]
    cmp     dword ptr [edx], 0
    jz      short loc_47C961
    cmp     byte ptr [edx+73h], 3
    jz      short loc_47C987

    loc_47C961:                             ; CODE XREF: sub_47C790+1C9j
    mov     edx, [ecx+110h]
    or      edx, 4000000h
    mov     [ecx+110h], edx
    mov     ecx, [esi+110h]
    or      ecx, 8000000h
    mov     [esi+110h], ecx
    jmp     short loc_47C9B5
    ; ---------------------------------------------------------------------------

    loc_47C987:                             ; CODE XREF: sub_47C790+1CFj
    mov     edx, [ecx+110h]
    or      edx, 8000000h
    mov     [ecx+110h], edx
    mov     ecx, [esi+110h]
    or      ecx, 4000000h
    mov     [esi+110h], ecx

    loc_47C9AB:                             ; CODE XREF: sub_47C790+19Fj
    mov     cx, [esi+0A8h]
    mov     [eax], cx

    loc_47C9B5:                             ; CODE XREF: sub_47C790+1F5j
    add     eax, 0Dh
    dec     edi
    jnz     loc_47C929

    loc_47C9BF:                             ; CODE XREF: sub_47C790+191j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+14233h]
    sub     ecx, ebp
    lea     edx, [ecx+ecx*2]
    lea     eax, [eax+edx*4]
    add     eax, ecx
    dec     ebx
    jnz     loc_47C91F
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47C9E3:                             ; CODE XREF: sub_47C790+172j
    call    sub_481550
    movsx   ecx, word ptr [esp+4+arg_0+2]
    test    ecx, ecx
    jle     loc_47CAB9
    movsx   ebp, di
    mov     ebx, ecx

    loc_47C9FA:                             ; CODE XREF: sub_47C790+323j
    test    ebp, ebp
    jle     loc_47CA9C
    mov     edi, ebp

    loc_47CA04:                             ; CODE XREF: sub_47C790+306j
    mov     cx, [eax+2]
    test    cx, cx
    jz      short loc_47CA87
    and     ecx, 0FFFFh
    mov     edx, ecx
    shl     ecx, 3
    sub     ecx, edx
    mov     edx, TAdynmemStructPtr
    mov     edx, [edx+14357h]
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [edx+ecx*8]
    mov     edx, [ecx+96h]
    cmp     dword ptr [edx], 0
    jz      short loc_47CA3D
    cmp     byte ptr [edx+73h], 3
    jz      short loc_47CA63

    loc_47CA3D:                             ; CODE XREF: sub_47C790+2A5j
    mov     edx, [ecx+110h]
    or      edx, 4000000h
    mov     [ecx+110h], edx
    mov     ecx, [esi+110h]
    or      ecx, 8000000h
    mov     [esi+110h], ecx
    jmp     short loc_47CA92
    ; ---------------------------------------------------------------------------

    loc_47CA63:                             ; CODE XREF: sub_47C790+2ABj
    mov     edx, [ecx+110h]
    or      edx, 8000000h
    mov     [ecx+110h], edx
    mov     ecx, [esi+110h]
    or      ecx, 4000000h
    mov     [esi+110h], ecx

    loc_47CA87:                             ; CODE XREF: sub_47C790+27Bj
    mov     cx, [esi+0A8h]
    mov     [eax+2], cx

    loc_47CA92:                             ; CODE XREF: sub_47C790+2D1j
    add     eax, 0Dh
    dec     edi
    jnz     loc_47CA04

    loc_47CA9C:                             ; CODE XREF: sub_47C790+26Cj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+14233h]
    sub     ecx, ebp
    lea     edx, [ecx+ecx*2]
    lea     eax, [eax+edx*4]
    add     eax, ecx
    dec     ebx
    jnz     loc_47C9FA

    loc_47CAB9:                             ; CODE XREF: sub_47C790+16j
                                            ; sub_47C790+51j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_47C790 endp

    ; ---------------------------------------------------------------------------
    push    ecx
    mov     ecx, [esp+0Ch]
    mov     edx, [esp+8]
    lea     eax, [esp+0]
    mov     dword ptr [esp+0], offset off_4FD660
    push    eax
    push    ecx
    push    edx
    call    sub_47E5C0
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47CB00 proc near                    ; CODE XREF: sub_48AB70+EEp

    arg_0= dword ptr  4

    mov     eax, [ecx+6]
    mov     edx, [esp+arg_0]
    add     ecx, 6
    cmp     eax, edx
    jz      short loc_47CB1E

    loc_47CB0E:                             ; CODE XREF: sub_47CB00+1Cj
    lea     ecx, [eax+8Eh]
    mov     eax, [eax+8Eh]
    cmp     eax, edx
    jnz     short loc_47CB0E

    loc_47CB1E:                             ; CODE XREF: sub_47CB00+Cj
    mov     eax, [edx+8Eh]
    mov     [ecx], eax
    mov     dword ptr [edx+8Eh], 0
    retn    4
    sub_47CB00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47CB40 proc near                    ; CODE XREF: sub_48AB70+16Cp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+6]
    mov     [eax+8Eh], edx
    mov     [ecx+6], eax
    retn    4
    sub_47CB40 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+4]
    push    esi
    mov     esi, [esp+0Ch]
    mov     eax, [edx+82h]
    cmp     esi, eax
    jz      short loc_47CBBF
    mov     ecx, [edx+86h]
    test    ecx, ecx
    jnz     short loc_47CBB9
    test    eax, eax
    jz      short loc_47CBAD
    lea     ecx, [eax+6]
    mov     eax, [eax+6]
    cmp     eax, edx
    jz      short loc_47CB9B

    loc_47CB8B:                             ; CODE XREF: .text:0047CB99j
    lea     ecx, [eax+8Eh]
    mov     eax, [eax+8Eh]
    cmp     eax, edx
    jnz     short loc_47CB8B

    loc_47CB9B:                             ; CODE XREF: .text:0047CB89j
    mov     eax, [edx+8Eh]
    mov     [ecx], eax
    mov     dword ptr [edx+8Eh], 0

    loc_47CBAD:                             ; CODE XREF: .text:0047CB7Fj
    mov     ecx, [esi+6]
    mov     [edx+8Eh], ecx
    mov     [esi+6], edx

    loc_47CBB9:                             ; CODE XREF: .text:0047CB7Bj
    mov     [edx+82h], esi

    loc_47CBBF:                             ; CODE XREF: .text:0047CB71j
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47CBD0 proc near                    ; CODE XREF: sub_4866D0+15Dp

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    esi
    call    sub_47D0E0
    mov     eax, [esi+86h]
    xor     edx, edx
    cmp     eax, edx
    jnz     short loc_47CC19
    mov     eax, [esi+82h]
    cmp     eax, edx
    jz      short loc_47CC19
    lea     ecx, [eax+6]
    mov     eax, [eax+6]
    cmp     eax, esi
    jz      short loc_47CC0B

    loc_47CBFB:                             ; CODE XREF: sub_47CBD0+39j
    lea     ecx, [eax+8Eh]
    mov     eax, [eax+8Eh]
    cmp     eax, esi
    jnz     short loc_47CBFB

    loc_47CC0B:                             ; CODE XREF: sub_47CBD0+29j
    mov     eax, [esi+8Eh]
    mov     [ecx], eax
    mov     [esi+8Eh], edx

    loc_47CC19:                             ; CODE XREF: sub_47CBD0+15j
                                            ; sub_47CBD0+1Fj
    mov     [esi+82h], edx
    pop     esi
    retn    4
    sub_47CBD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47CC30 proc near                    ; CODE XREF: sub_43D6D0+371p
                                            ; sub_485F50+1BFp ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+24h+arg_0]
    push    edi
    mov     eax, [esi]
    mov     edx, [esi+7Eh]
    test    eax, eax
    mov     [esp+28h+var_14], edx
    jz      short loc_47CC57
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+38A47h]
    mov     [eax+26h], ecx

    loc_47CC57:                             ; CODE XREF: sub_47CC30+16j
    mov     ax, [esi+76h]
    test    ax, ax
    jl      loc_47D073
    mov     cx, [esi+78h]
    test    cx, cx
    jl      loc_47D073
    mov     ebp, TAdynmemStructPtr
    movsx   ebx, dx
    movsx   edx, ax
    mov     eax, [ebp+14233h]
    add     edx, ebx
    cmp     edx, eax
    mov     [esp+28h+arg_0], ebx
    jge     loc_47D079
    movsx   edi, word ptr [esp+28h+var_14+2]
    movsx   eax, cx
    mov     ecx, [ebp+14237h]
    add     eax, edi
    cmp     eax, ecx
    jge     loc_47D079
    lea     ecx, [esi+6Ah]
    mov     edx, ecx
    mov     ecx, [edx]
    sar     ecx, 17h
    mov     eax, [edx+4]
    mov     [esp+28h+var_8], eax
    mov     eax, [edx+8]
    mov     edx, [ebp+1429Fh]
    sar     eax, 17h
    imul    eax, [ebp+142A3h]
    add     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, [esi+82h]
    lea     edx, [edx+ecx*2]
    cmp     edx, eax
    jz      short loc_47CD31
    mov     ecx, [esi+86h]
    test    ecx, ecx
    jnz     short loc_47CD25
    test    eax, eax
    jz      short loc_47CD19
    lea     ecx, [eax+6]
    mov     eax, [eax+6]
    cmp     eax, esi
    jz      short loc_47CD07

    loc_47CCF7:                             ; CODE XREF: sub_47CC30+D5j
    lea     ecx, [eax+8Eh]
    mov     eax, [eax+8Eh]
    cmp     eax, esi
    jnz     short loc_47CCF7

    loc_47CD07:                             ; CODE XREF: sub_47CC30+C5j
    mov     eax, [esi+8Eh]
    mov     [ecx], eax
    mov     dword ptr [esi+8Eh], 0

    loc_47CD19:                             ; CODE XREF: sub_47CC30+BBj
    mov     ecx, [edx+6]
    mov     [esi+8Eh], ecx
    mov     [edx+6], esi

    loc_47CD25:                             ; CODE XREF: sub_47CC30+B7j
    mov     [esi+82h], edx
    mov     ebp, TAdynmemStructPtr

    loc_47CD31:                             ; CODE XREF: sub_47CC30+ADj
    movsx   edx, word ptr [esi+78h]
    mov     eax, [ebp+14233h]
    movsx   ecx, word ptr [esi+76h]
    imul    eax, edx
    add     eax, ecx
    lea     edx, [eax+eax*2]
    lea     edx, [eax+edx*4]
    mov     eax, [ebp+14287h]
    add     edx, eax
    mov     eax, [esi+110h]
    xor     ebp, ebp
    test    eax, 20000000h
    jz      loc_47CEBC
    test    edi, edi
    jle     loc_47CE68
    mov     [esp+28h+var_18], edi

    loc_47CD71:                             ; CODE XREF: sub_47CC30+232j
    test    ebx, ebx
    jle     loc_47CE44
    mov     edi, ebx

    loc_47CD7B:                             ; CODE XREF: sub_47CC30+20Aj
    mov     eax, [esi+92h]
    inc     ebp
    mov     ecx, [eax+14Eh]
    mov     al, [esi+10Fh]
    and     al, 4
    mov     bl, [ecx+ebp-1]
    neg     al
    sbb     eax, eax
    and     al, 0FEh
    add     eax, 4
    test    bl, al
    jz      loc_47CE2D
    mov     ax, [edx]
    test    ax, ax
    jz      short loc_47CE23
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+14357h]
    lea     eax, [eax+ecx*8]
    mov     ecx, [eax+96h]
    cmp     dword ptr [ecx], 0
    jz      short loc_47CDDB
    cmp     byte ptr [ecx+73h], 3
    jz      short loc_47CE00

    loc_47CDDB:                             ; CODE XREF: sub_47CC30+1A3j
    mov     ecx, [eax+110h]
    or      ecx, 4000000h
    mov     [eax+110h], ecx
    mov     eax, [esi+110h]
    or      eax, 8000000h
    mov     [esi+110h], eax
    jmp     short loc_47CE2D
    ; ---------------------------------------------------------------------------

    loc_47CE00:                             ; CODE XREF: sub_47CC30+1A9j
    mov     ecx, [eax+110h]
    or      ecx, 8000000h
    mov     [eax+110h], ecx
    mov     eax, [esi+110h]
    or      eax, 4000000h
    mov     [esi+110h], eax

    loc_47CE23:                             ; CODE XREF: sub_47CC30+17Bj
    mov     cx, [esi+0A8h]
    mov     [edx], cx

    loc_47CE2D:                             ; CODE XREF: sub_47CC30+16Fj
                                            ; sub_47CC30+1CEj
    test    bl, 1
    jz      short loc_47CE36
    or      byte ptr [edx+0Ch], 2

    loc_47CE36:                             ; CODE XREF: sub_47CC30+200j
    add     edx, 0Dh
    dec     edi
    jnz     loc_47CD7B
    mov     ebx, [esp+28h+arg_0]

    loc_47CE44:                             ; CODE XREF: sub_47CC30+143j
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+14233h]
    sub     eax, ebx
    lea     ecx, [eax+eax*2]
    lea     edx, [edx+ecx*4]
    add     edx, eax
    mov     eax, [esp+28h+var_18]
    dec     eax
    mov     [esp+28h+var_18], eax
    jnz     loc_47CD71

    loc_47CE68:                             ; CODE XREF: sub_47CC30+137j
    mov     eax, [esp+28h+var_14]
    mov     ecx, [esp+28h+var_14+2]
    mov     dx, [esi+76h]
    add     eax, 2
    mov     word ptr [esp+28h+arg_0], ax
    mov     ax, [esi+78h]
    add     ecx, 2
    dec     dx
    dec     ax
    mov     word ptr [esp+28h+arg_0+2], cx
    mov     ecx, [esp+28h+arg_0]
    mov     word ptr [esp+28h+var_18], dx
    mov     word ptr [esp+28h+var_18+2], ax
    mov     edx, [esp+28h+var_18]
    push    ecx
    push    edx
    call    sub_483210
    mov     eax, [esi+7Eh]
    mov     ecx, [esi+76h]
    push    eax
    push    ecx
    call    sub_440A40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47CEBC:                             ; CODE XREF: sub_47CC30+12Fj
    and     eax, 3
    cmp     eax, 1
    jnz     loc_47CF98
    test    edi, edi
    jle     loc_47D0D5
    mov     ebp, edi

    loc_47CED2:                             ; CODE XREF: sub_47CC30+358j
    test    ebx, ebx
    jle     loc_47CF71

    loc_47CEDA:                             ; CODE XREF: sub_47CC30+337j
    mov     ax, [edx]
    test    ax, ax
    jz      short loc_47CF59
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]
    mov     ecx, [eax+96h]
    cmp     dword ptr [ecx], 0
    jz      short loc_47CF11
    cmp     byte ptr [ecx+73h], 3
    jz      short loc_47CF36

    loc_47CF11:                             ; CODE XREF: sub_47CC30+2D9j
    mov     ecx, [eax+110h]
    or      ecx, 4000000h
    mov     [eax+110h], ecx
    mov     eax, [esi+110h]
    or      eax, 8000000h
    mov     [esi+110h], eax
    jmp     short loc_47CF63
    ; ---------------------------------------------------------------------------

    loc_47CF36:                             ; CODE XREF: sub_47CC30+2DFj
    mov     ecx, [eax+110h]
    or      ecx, 8000000h
    mov     [eax+110h], ecx
    mov     eax, [esi+110h]
    or      eax, 4000000h
    mov     [esi+110h], eax

    loc_47CF59:                             ; CODE XREF: sub_47CC30+2B0j
    mov     ax, [esi+0A8h]
    mov     [edx], ax

    loc_47CF63:                             ; CODE XREF: sub_47CC30+304j
    add     edx, 0Dh
    dec     ebx
    jnz     loc_47CEDA
    mov     ebx, [esp+28h+arg_0]

    loc_47CF71:                             ; CODE XREF: sub_47CC30+2A4j
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14233h]
    sub     eax, ebx
    lea     ecx, [eax+eax*2]
    lea     edx, [edx+ecx*4]
    add     edx, eax
    dec     ebp
    jnz     loc_47CED2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47CF98:                             ; CODE XREF: sub_47CC30+292j
    cmp     eax, 2
    jnz     loc_47D0D5
    test    edi, edi
    jle     loc_47D0D5
    mov     ebp, edi

    loc_47CFAB:                             ; CODE XREF: sub_47CC30+433j
    test    ebx, ebx
    jle     loc_47D04C

    loc_47CFB3:                             ; CODE XREF: sub_47CC30+412j
    mov     ax, [edx+2]
    test    ax, ax
    jz      short loc_47D033
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]
    mov     ecx, [eax+96h]
    cmp     dword ptr [ecx], 0
    jz      short loc_47CFEB
    cmp     byte ptr [ecx+73h], 3
    jz      short loc_47D010

    loc_47CFEB:                             ; CODE XREF: sub_47CC30+3B3j
    mov     ecx, [eax+110h]
    or      ecx, 4000000h
    mov     [eax+110h], ecx
    mov     eax, [esi+110h]
    or      eax, 8000000h
    mov     [esi+110h], eax
    jmp     short loc_47D03E
    ; ---------------------------------------------------------------------------

    loc_47D010:                             ; CODE XREF: sub_47CC30+3B9j
    mov     ecx, [eax+110h]
    or      ecx, 8000000h
    mov     [eax+110h], ecx
    mov     eax, [esi+110h]
    or      eax, 4000000h
    mov     [esi+110h], eax

    loc_47D033:                             ; CODE XREF: sub_47CC30+38Aj
    mov     ax, [esi+0A8h]
    mov     [edx+2], ax

    loc_47D03E:                             ; CODE XREF: sub_47CC30+3DEj
    add     edx, 0Dh
    dec     ebx
    jnz     loc_47CFB3
    mov     ebx, [esp+28h+arg_0]

    loc_47D04C:                             ; CODE XREF: sub_47CC30+37Dj
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14233h]
    sub     eax, ebx
    lea     ecx, [eax+eax*2]
    lea     edx, [edx+ecx*4]
    add     edx, eax
    dec     ebp
    jnz     loc_47CFAB
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47D073:                             ; CODE XREF: sub_47CC30+2Ej
                                            ; sub_47CC30+3Bj
    mov     ebp, TAdynmemStructPtr

    loc_47D079:                             ; CODE XREF: sub_47CC30+5Bj
                                            ; sub_47CC30+73j
    mov     edx, [ebp+142B7h]
    mov     eax, [esi+82h]
    cmp     edx, eax
    jz      short loc_47D0D5
    mov     ecx, [esi+86h]
    test    ecx, ecx
    jnz     short loc_47D0CF
    test    eax, eax
    jz      short loc_47D0C3
    lea     ecx, [eax+6]
    mov     eax, [eax+6]
    cmp     eax, esi
    jz      short loc_47D0B1

    loc_47D0A1:                             ; CODE XREF: sub_47CC30+47Fj
    lea     ecx, [eax+8Eh]
    mov     eax, [eax+8Eh]
    cmp     eax, esi
    jnz     short loc_47D0A1

    loc_47D0B1:                             ; CODE XREF: sub_47CC30+46Fj
    mov     eax, [esi+8Eh]
    mov     [ecx], eax
    mov     dword ptr [esi+8Eh], 0

    loc_47D0C3:                             ; CODE XREF: sub_47CC30+465j
    mov     ecx, [edx+6]
    mov     [esi+8Eh], ecx
    mov     [edx+6], esi

    loc_47D0CF:                             ; CODE XREF: sub_47CC30+461j
    mov     [esi+82h], edx

    loc_47D0D5:                             ; CODE XREF: sub_47CC30+29Aj
                                            ; sub_47CC30+36Bj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    4
    sub_47CC30 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47D0E0 proc near                    ; CODE XREF: sub_43D6D0+33Fp
                                            ; sub_47CBD0+6p ...

    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    mov     ebx, TAdynmemStructPtr
    push    ebp
    push    esi
    mov     esi, [esp+14h+arg_0]
    mov     ecx, [ebx+142B7h]
    push    edi
    mov     eax, [esi+82h]
    cmp     eax, ecx
    jz      loc_47D286
    movsx   eax, word ptr [esi+78h]
    imul    eax, [ebx+14233h]
    movsx   ecx, word ptr [esi+76h]
    add     eax, ecx
    mov     ecx, [ebx+14287h]
    mov     edi, [esi+7Eh]
    lea     edx, [eax+eax*2]
    mov     [esp+18h+var_8], edi
    lea     eax, [eax+edx*4]
    xor     edx, edx
    add     eax, ecx
    mov     ecx, [esi+110h]
    test    ecx, 20000000h
    jz      loc_47D1E9
    movsx   ecx, word ptr [esp+18h+var_8+2]
    test    ecx, ecx
    jle     short loc_47D1AB
    movsx   ebp, di
    mov     [esp+18h+arg_0], ecx

    loc_47D14F:                             ; CODE XREF: sub_47D0E0+C5j
    test    ebp, ebp
    jle     short loc_47D18C
    mov     edi, ebp

    loc_47D155:                             ; CODE XREF: sub_47D0E0+A4j
    mov     ecx, [esi+92h]
    mov     bx, [eax]
    inc     edx
    cmp     bx, [esi+0A8h]
    mov     ecx, [ecx+14Eh]
    mov     cl, [ecx+edx-1]
    jnz     short loc_47D177
    mov     word ptr [eax], 0

    loc_47D177:                             ; CODE XREF: sub_47D0E0+90j
    test    cl, 1
    jz      short loc_47D180
    and     byte ptr [eax+0Ch], 0FDh

    loc_47D180:                             ; CODE XREF: sub_47D0E0+9Aj
    add     eax, 0Dh
    dec     edi
    jnz     short loc_47D155
    mov     ebx, TAdynmemStructPtr

    loc_47D18C:                             ; CODE XREF: sub_47D0E0+71j
    mov     ecx, [ebx+14233h]
    sub     ecx, ebp
    lea     edi, [ecx+ecx*2]
    lea     eax, [eax+edi*4]
    add     eax, ecx
    mov     ecx, [esp+18h+arg_0]
    dec     ecx
    mov     [esp+18h+arg_0], ecx
    jnz     short loc_47D14F
    mov     edi, [esp+18h+var_8]

    loc_47D1AB:                             ; CODE XREF: sub_47D0E0+66j
    mov     ecx, [esp+18h+var_8+2]
    mov     dx, [esi+76h]
    mov     ax, [esi+78h]
    add     edi, 2
    add     ecx, 2
    dec     dx
    dec     ax
    mov     word ptr [esp+18h+arg_0], di
    mov     word ptr [esp+18h+arg_0+2], cx
    mov     ecx, [esp+18h+arg_0]
    mov     word ptr [esp+18h+var_8], dx
    mov     word ptr [esp+18h+var_8+2], ax
    mov     edx, [esp+18h+var_8]
    push    ecx
    push    edx
    call    sub_483210
    jmp     loc_47D286
    ; ---------------------------------------------------------------------------

    loc_47D1E9:                             ; CODE XREF: sub_47D0E0+59j
    and     ecx, 3
    cmp     ecx, 1
    jnz     short loc_47D23B
    movsx   ecx, word ptr [esp+18h+var_8+2]
    test    ecx, ecx
    jle     loc_47D286
    movsx   edx, di
    mov     edi, ecx

    loc_47D203:                             ; CODE XREF: sub_47D0E0+157j
    test    edx, edx
    jle     short loc_47D226
    mov     ecx, edx

    loc_47D209:                             ; CODE XREF: sub_47D0E0+13Ej
    mov     bx, [eax]
    cmp     bx, [esi+0A8h]
    jnz     short loc_47D21A
    mov     word ptr [eax], 0

    loc_47D21A:                             ; CODE XREF: sub_47D0E0+133j
    add     eax, 0Dh
    dec     ecx
    jnz     short loc_47D209
    mov     ebx, TAdynmemStructPtr

    loc_47D226:                             ; CODE XREF: sub_47D0E0+125j
    mov     ecx, [ebx+14233h]
    sub     ecx, edx
    lea     ebp, [ecx+ecx*2]
    lea     eax, [eax+ebp*4]
    add     eax, ecx
    dec     edi
    jnz     short loc_47D203
    jmp     short loc_47D286
    ; ---------------------------------------------------------------------------

    loc_47D23B:                             ; CODE XREF: sub_47D0E0+10Fj
    cmp     ecx, 2
    jnz     short loc_47D286
    movsx   ecx, word ptr [esp+18h+var_8+2]
    test    ecx, ecx
    jle     short loc_47D286
    movsx   edx, di
    mov     edi, ecx

    loc_47D24E:                             ; CODE XREF: sub_47D0E0+1A4j
    xor     ebp, ebp
    cmp     edx, ebp
    jle     short loc_47D273
    mov     ecx, edx

    loc_47D256:                             ; CODE XREF: sub_47D0E0+18Bj
    mov     bx, [eax+2]
    cmp     bx, [esi+0A8h]
    jnz     short loc_47D267
    mov     [eax+2], bp

    loc_47D267:                             ; CODE XREF: sub_47D0E0+181j
    add     eax, 0Dh
    dec     ecx
    jnz     short loc_47D256
    mov     ebx, TAdynmemStructPtr

    loc_47D273:                             ; CODE XREF: sub_47D0E0+172j
    mov     ecx, [ebx+14233h]
    sub     ecx, edx
    lea     ebp, [ecx+ecx*2]
    lea     eax, [eax+ebp*4]
    add     eax, ecx
    dec     edi
    jnz     short loc_47D24E

    loc_47D286:                             ; CODE XREF: sub_47D0E0+1Fj
                                            ; sub_47D0E0+104j ...
    mov     ebx, [esi+110h]
    and     ebx, 0F7FFFFFFh
    mov     eax, ebx
    mov     [esi+110h], ebx
    mov     ecx, eax
    shr     ecx, 1Ah
    test    cl, 1
    jz      short loc_47D2C9
    mov     ecx, [esi+76h]
    and     eax, 0FBFFFFFFh
    mov     [esi+110h], eax
    mov     eax, [esi+7Eh]
    lea     edx, [esp+18h+arg_0]
    mov     [esp+18h+arg_0], offset off_4FD660
    push    edx
    push    eax
    push    ecx
    call    sub_47E5C0

    loc_47D2C9:                             ; CODE XREF: sub_47D0E0+1C2j
    push    esi
    call    sub_440A70
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_47D0E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47D2E0 proc near                    ; CODE XREF: sub_40A260+26Dp
                                            ; sub_4197D0+F6p ...

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 2Ch
    mov     eax, [esp+2Ch+arg_0]
    mov     ecx, [esp+2Ch+arg_4]
    push    ebx
    xor     ebx, ebx
    mov     dword_51E684, ebx
    mov     dword_51E688, ebx
    mov     eax, [eax+14Ah]
    push    ebp
    push    esi
    cmp     cx, 1
    push    edi
    mov     [esp+3Ch+var_20], eax
    jl      loc_47D80F
    mov     di, word ptr [esp+3Ch+arg_4+2]
    cmp     di, 1
    jl      loc_47D80F
    mov     ebp, TAdynmemStructPtr
    movsx   edx, cx
    movsx   esi, ax
    mov     eax, [ebp+14233h]
    mov     [esp+3Ch+var_24], esi
    lea     ecx, [esi+edx]
    cmp     ecx, eax
    jge     loc_47D80F
    movsx   ecx, word ptr [esp+3Ch+var_20+2]
    movsx   eax, di
    lea     edi, [ecx+eax]
    cmp     edi, [ebp+14237h]
    jge     loc_47D80F
    mov     edi, [esp+3Ch+arg_C]
    mov     [esp+3Ch+var_2C], 1
    cmp     edi, ebx
    jz      loc_47D479
    lea     edx, [esi+edx*2]
    lea     eax, [ecx+eax*2]
    lea     ecx, [esp+3Ch+arg_4]
    shl     edx, 13h
    shl     eax, 13h
    push    ecx
    mov     [esp+40h+var_C], edx
    mov     [esp+40h+var_4], eax
    call    sub_485010
    shl     eax, 10h
    movsx   edx, word ptr [esp+3Ch+var_C+2]
    mov     [esp+3Ch+arg_C], eax
    movsx   ecx, word ptr [esp+3Ch+arg_C+2]
    movsx   eax, word ptr [esp+3Ch+var_4+2]
    sar     ecx, 1
    sub     eax, ecx
    mov     ecx, [edi+80h]
    sar     edx, 5
    sar     eax, 5
    cmp     edx, ecx
    jnb     loc_47D80F
    cmp     eax, [edi+84h]
    jnb     loc_47D80F
    mov     ebx, TAdynmemStructPtr
    mov     esi, 1
    xor     ebp, ebp
    mov     cl, [ebx+TAdynmemStruct.LOS_Sight]
    shl     esi, cl
    mov     ecx, [ebx+14273h]
    mov     [esp+3Ch+arg_C], esi
    mov     esi, [edi+80h]
    mov     ebx, esi
    imul    ebx, eax
    add     ebx, edx
    mov     bp, [ecx+ebx*2]
    mov     ebx, [esp+3Ch+arg_C]
    test    ebp, ebx
    jz      loc_47D80F
    mov     ebp, TAdynmemStructPtr
    mov     bl, [ebp+14281h]
    and     bl, 2
    cmp     bl, 2
    jnz     short loc_47D446
    mov     ecx, esi
    cmp     edx, ecx
    jnb     short loc_47D43C
    cmp     eax, [edi+84h]
    jnb     short loc_47D43C
    mov     ecx, esi
    imul    ecx, eax
    add     ecx, edx
    mov     edx, [edi+7Ch]
    cmp     byte ptr [ecx+edx], 0
    jz      short loc_47D43C
    mov     [esp+3Ch+var_2C], 1
    jmp     short loc_47D475
    ; ---------------------------------------------------------------------------

    loc_47D43C:                             ; CODE XREF: sub_47D2E0+138j
                                            ; sub_47D2E0+140j ...
    mov     [esp+3Ch+var_2C], 0
    jmp     short loc_47D475
    ; ---------------------------------------------------------------------------

    loc_47D446:                             ; CODE XREF: sub_47D2E0+132j
    cmp     edx, [edi+80h]
    jnb     short loc_47D456
    cmp     eax, [edi+84h]
    jb      short loc_47D45A

    loc_47D456:                             ; CODE XREF: sub_47D2E0+16Cj
    xor     eax, eax
    jmp     short loc_47D471
    ; ---------------------------------------------------------------------------

    loc_47D45A:                             ; CODE XREF: sub_47D2E0+174j
    imul    esi, eax
    add     esi, edx
    xor     eax, eax
    mov     ax, [ecx+esi*2]
    mov     esi, [esp+3Ch+arg_C]
    and     eax, esi
    neg     eax
    sbb     eax, eax
    neg     eax

    loc_47D471:                             ; CODE XREF: sub_47D2E0+178j
    mov     [esp+3Ch+var_2C], eax

    loc_47D475:                             ; CODE XREF: sub_47D2E0+15Aj
                                            ; sub_47D2E0+164j
    mov     esi, [esp+3Ch+var_24]

    loc_47D479:                             ; CODE XREF: sub_47D2E0+86j
    movsx   eax, word ptr [esp+3Ch+arg_4+2]
    imul    eax, [ebp+14233h]
    movsx   ecx, word ptr [esp+3Ch+arg_4]
    add     eax, ecx
    mov     ecx, [ebp+14287h]
    xor     bl, bl
    xor     edi, edi
    lea     edx, [eax+eax*2]
    mov     byte ptr [esp+3Ch+var_24], bl
    mov     byte ptr [esp+3Ch+arg_C], bl
    mov     [esp+3Ch+var_14], edi
    lea     eax, [eax+edx*4]
    or      dl, 0FFh
    add     eax, ecx
    mov     byte ptr [esp+3Ch+var_28], dl
    movsx   ecx, word ptr [esp+3Ch+var_20+2]
    test    ecx, ecx
    mov     [esp+3Ch+var_10], edi
    mov     [esp+3Ch+var_18], edi
    jle     loc_47D75B

    loc_47D4C6:                             ; CODE XREF: sub_47D2E0+46Dj
    test    esi, esi
    mov     [esp+3Ch+var_1C], 0
    jle     loc_47D72D

    loc_47D4D6:                             ; CODE XREF: sub_47D2E0+447j
    mov     ebx, dword_51E688
    mov     edx, [esp+3Ch+arg_0]
    xor     ecx, ecx
    mov     cl, [eax+7]
    add     ebx, ecx
    mov     dword_51E688, ebx
    mov     ecx, [edx+14Eh]
    xor     ebx, ebx
    mov     bl, [edi+ecx]
    inc     edi
    test    bl, 8
    jz      short loc_47D51C
    mov     cl, [eax+6]
    mov     dl, byte ptr [esp+3Ch+var_28]
    cmp     cl, dl
    jnb     short loc_47D50D
    mov     byte ptr [esp+3Ch+var_28], cl

    loc_47D50D:                             ; CODE XREF: sub_47D2E0+227j
    mov     cl, [eax+5]
    mov     dl, byte ptr [esp+3Ch+var_24]
    cmp     cl, dl
    jbe     short loc_47D51C
    mov     byte ptr [esp+3Ch+var_24], cl

    loc_47D51C:                             ; CODE XREF: sub_47D2E0+21Cj
                                            ; sub_47D2E0+236j
    test    bl, 10h
    jz      short loc_47D530
    mov     cl, [eax+5]
    mov     dl, byte ptr [esp+3Ch+arg_C]
    cmp     cl, dl
    jbe     short loc_47D530
    mov     byte ptr [esp+3Ch+arg_C], cl

    loc_47D530:                             ; CODE XREF: sub_47D2E0+23Fj
                                            ; sub_47D2E0+24Aj
    test    bl, 1
    jz      short loc_47D547
    test    byte ptr [eax+0Ch], 2
    jz      short loc_47D547
    mov     ecx, [esp+3Ch+var_2C]
    test    ecx, ecx
    jnz     loc_47D80F

    loc_47D547:                             ; CODE XREF: sub_47D2E0+253j
                                            ; sub_47D2E0+259j
    test    bl, 6
    jz      short loc_47D567
    mov     cx, [eax]
    test    cx, cx
    jz      short loc_47D567
    cmp     cx, word ptr [esp+3Ch+arg_8]
    jz      short loc_47D567
    mov     ecx, [esp+3Ch+var_2C]
    test    ecx, ecx
    jnz     loc_47D80F

    loc_47D567:                             ; CODE XREF: sub_47D2E0+26Aj
                                            ; sub_47D2E0+272j ...
    test    bl, 20h
    jz      loc_47D5FB
    mov     cx, [eax+8]
    cmp     cx, 0FFFFh
    jnz     short loc_47D57F
    xor     ecx, ecx
    jmp     short loc_47D5F3
    ; ---------------------------------------------------------------------------

    loc_47D57F:                             ; CODE XREF: sub_47D2E0+299j
    cmp     cx, 0FFFBh
    jnb     short loc_47D59D
    mov     edx, [ebp+14253h]
    and     ecx, 0FFFFh
    cmp     ecx, edx
    jl      short loc_47D5DD
    mov     ecx, 1
    jmp     short loc_47D5F3
    ; ---------------------------------------------------------------------------

    loc_47D59D:                             ; CODE XREF: sub_47D2E0+2A4j
    cmp     cx, 0FFFEh
    jz      short loc_47D5AB
    mov     ecx, 1
    jmp     short loc_47D5F3
    ; ---------------------------------------------------------------------------

    loc_47D5AB:                             ; CODE XREF: sub_47D2E0+2C2j
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+0Ah]
    mov     dl, [eax+0Bh]
    imul    ecx, [ebp+14233h]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    mov     edx, eax
    sub     edx, ecx
    mov     cx, [edx+8]
    cmp     cx, 0FFFBh
    jb      short loc_47D5D7
    xor     ecx, ecx
    jmp     short loc_47D5F3
    ; ---------------------------------------------------------------------------

    loc_47D5D7:                             ; CODE XREF: sub_47D2E0+2F1j
    and     ecx, 0FFFFh

    loc_47D5DD:                             ; CODE XREF: sub_47D2E0+2B4j
    mov     edx, [ebp+1426Fh]
    shl     ecx, 8
    mov     cl, [edx+ecx+0FEh]
    shr     ecx, 6
    and     ecx, 1

    loc_47D5F3:                             ; CODE XREF: sub_47D2E0+29Dj
                                            ; sub_47D2E0+2BBj ...
    test    ecx, ecx
    jnz     loc_47D80F

    loc_47D5FB:                             ; CODE XREF: sub_47D2E0+28Aj
    test    bl, 40h
    jz      loc_47D684
    test    eax, eax
    jnz     short loc_47D60C
    xor     ecx, ecx
    jmp     short loc_47D673
    ; ---------------------------------------------------------------------------

    loc_47D60C:                             ; CODE XREF: sub_47D2E0+326j
    mov     dx, [eax+8]
    cmp     dx, 0FFFBh
    jnb     short loc_47D62B
    mov     ecx, [ebp+14253h]
    and     edx, 0FFFFh
    cmp     edx, ecx
    jl      short loc_47D668
    xor     ecx, ecx
    jmp     short loc_47D673
    ; ---------------------------------------------------------------------------

    loc_47D62B:                             ; CODE XREF: sub_47D2E0+335j
    cmp     dx, 0FFFEh
    jz      short loc_47D636
    xor     ecx, ecx
    jmp     short loc_47D673
    ; ---------------------------------------------------------------------------

    loc_47D636:                             ; CODE XREF: sub_47D2E0+350j
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+0Ah]
    mov     dl, [eax+0Bh]
    imul    ecx, [ebp+14233h]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    mov     edx, eax
    sub     edx, ecx
    mov     dx, [edx+8]
    cmp     dx, 0FFFBh
    jb      short loc_47D662
    xor     ecx, ecx
    jmp     short loc_47D673
    ; ---------------------------------------------------------------------------

    loc_47D662:                             ; CODE XREF: sub_47D2E0+37Cj
    and     edx, 0FFFFh

    loc_47D668:                             ; CODE XREF: sub_47D2E0+345j
    mov     ecx, [ebp+1426Fh]
    shl     edx, 8
    add     ecx, edx

    loc_47D673:                             ; CODE XREF: sub_47D2E0+32Aj
                                            ; sub_47D2E0+349j ...
    test    ecx, ecx
    jz      short loc_47D684
    test    byte ptr [ecx+0FFh], 2
    jnz     loc_47D80F

    loc_47D684:                             ; CODE XREF: sub_47D2E0+31Ej
                                            ; sub_47D2E0+395j
    test    bl, 80h
    jz      loc_47D719
    test    eax, eax
    mov     [esp+3Ch+var_14], 1
    jnz     short loc_47D69D
    xor     ecx, ecx
    jmp     short loc_47D704
    ; ---------------------------------------------------------------------------

    loc_47D69D:                             ; CODE XREF: sub_47D2E0+3B7j
    mov     dx, [eax+8]
    cmp     dx, 0FFFBh
    jnb     short loc_47D6BC
    mov     ecx, [ebp+14253h]
    and     edx, 0FFFFh
    cmp     edx, ecx
    jl      short loc_47D6F9
    xor     ecx, ecx
    jmp     short loc_47D704
    ; ---------------------------------------------------------------------------

    loc_47D6BC:                             ; CODE XREF: sub_47D2E0+3C6j
    cmp     dx, 0FFFEh
    jz      short loc_47D6C7
    xor     ecx, ecx
    jmp     short loc_47D704
    ; ---------------------------------------------------------------------------

    loc_47D6C7:                             ; CODE XREF: sub_47D2E0+3E1j
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+0Ah]
    mov     dl, [eax+0Bh]
    imul    ecx, [ebp+14233h]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    mov     edx, eax
    sub     edx, ecx
    mov     dx, [edx+8]
    cmp     dx, 0FFFBh
    jb      short loc_47D6F3
    xor     ecx, ecx
    jmp     short loc_47D704
    ; ---------------------------------------------------------------------------

    loc_47D6F3:                             ; CODE XREF: sub_47D2E0+40Dj
    and     edx, 0FFFFh

    loc_47D6F9:                             ; CODE XREF: sub_47D2E0+3D6j
    mov     ecx, [ebp+1426Fh]
    shl     edx, 8
    add     ecx, edx

    loc_47D704:                             ; CODE XREF: sub_47D2E0+3BBj
                                            ; sub_47D2E0+3DAj ...
    test    ecx, ecx
    jz      short loc_47D719
    test    byte ptr [ecx+0FEh], 20h
    jz      short loc_47D719
    mov     [esp+3Ch+var_10], 1

    loc_47D719:                             ; CODE XREF: sub_47D2E0+3A7j
                                            ; sub_47D2E0+426j ...
    mov     ecx, [esp+3Ch+var_1C]
    add     eax, 0Dh
    inc     ecx
    cmp     ecx, esi
    mov     [esp+3Ch+var_1C], ecx
    jl      loc_47D4D6

    loc_47D72D:                             ; CODE XREF: sub_47D2E0+1F0j
    mov     ecx, [ebp+14233h]
    mov     edx, [esp+3Ch+var_18]
    sub     ecx, esi
    inc     edx
    mov     [esp+3Ch+var_18], edx
    lea     ebx, [ecx+ecx*2]
    lea     eax, [eax+ebx*4]
    add     eax, ecx
    movsx   ecx, word ptr [esp+3Ch+var_20+2]
    cmp     edx, ecx
    jl      loc_47D4C6
    mov     bl, byte ptr [esp+3Ch+var_24]
    mov     dl, byte ptr [esp+3Ch+var_28]

    loc_47D75B:                             ; CODE XREF: sub_47D2E0+1E0j
    mov     eax, [esp+3Ch+var_14]
    test    eax, eax
    jz      short loc_47D76F
    mov     eax, [esp+3Ch+var_10]
    test    eax, eax
    jz      loc_47D80F

    loc_47D76F:                             ; CODE XREF: sub_47D2E0+481j
    mov     ecx, [esp+3Ch+var_28]
    cmp     bl, dl
    jnb     short loc_47D789
    mov     esi, [esp+3Ch+arg_0]
    mov     al, [ebp+1427Fh]
    sub     al, [esi+22Ch]
    jmp     short loc_47D7AE
    ; ---------------------------------------------------------------------------

    loc_47D789:                             ; CODE XREF: sub_47D2E0+495j
    mov     edi, [esp+3Ch+var_24]
    mov     esi, [esp+3Ch+arg_0]
    mov     eax, ecx
    and     edi, 0FFh
    and     eax, 0FFh
    sub     edi, eax
    xor     eax, eax
    mov     al, [esi+228h]
    cmp     edi, eax
    jg      short loc_47D80F
    mov     al, dl

    loc_47D7AE:                             ; CODE XREF: sub_47D2E0+4A7j
    mov     dl, byte ptr [esp+3Ch+arg_C]
    mov     byte ptr [esp+3Ch+arg_8], al
    cmp     dl, al
    ja      short loc_47D80F
    movsx   edi, word ptr [esi+1BEh]
    xor     eax, eax
    and     ecx, 0FFh
    mov     al, [ebp+1427Fh]
    mov     ebp, eax
    sub     ebp, edi
    cmp     ecx, ebp
    jl      short loc_47D80F
    cmp     bl, dl
    mov     cl, bl
    ja      short loc_47D7DF
    mov     cl, dl

    loc_47D7DF:                             ; CODE XREF: sub_47D2E0+4FBj
    movsx   edx, word ptr [esi+1C0h]
    sub     eax, edx
    and     ecx, 0FFh
    cmp     ecx, eax
    jg      short loc_47D80F
    mov     eax, [esp+3Ch+arg_8]
    and     eax, 0FFh
    mov     dword_51E684, eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_47D80F:                             ; CODE XREF: sub_47D2E0+2Bj
                                            ; sub_47D2E0+3Aj ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 2Ch
    retn    10h
    sub_47D2E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47D820 proc near                    ; CODE XREF: sub_4197D0+12Ep
                                            ; sub_47DDC0+8Ap

    var_E= byte ptr -0Eh
    var_D= byte ptr -0Dh
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    mov     eax, [esp+10h+arg_0]
    mov     ecx, [esp+10h+arg_4]
    push    ebx
    push    ebp
    mov     eax, [eax+14Ah]
    push    esi
    cmp     cx, 1
    push    edi
    mov     [esp+20h+var_C], eax
    jl      loc_47D961
    mov     si, word ptr [esp+20h+arg_4+2]
    cmp     si, 1
    jl      loc_47D961
    mov     ebx, TAdynmemStructPtr
    movsx   ebp, ax
    mov     edi, [ebx+14233h]
    mov     [esp+20h+var_4], ebp
    movsx   ecx, cx
    mov     [esp+20h+var_8], edi
    lea     edx, [ecx+ebp]
    cmp     edx, edi
    jge     loc_47D961
    movsx   edx, word ptr [esp+20h+var_C+2]
    movsx   eax, si
    lea     esi, [eax+edx]
    cmp     esi, [ebx+14237h]
    jge     loc_47D961
    imul    eax, edi
    mov     esi, [ebx+14287h]
    add     eax, ecx
    xor     bl, bl
    mov     byte ptr [esp+20h+arg_4], 0FFh
    lea     ecx, [eax+eax*2]
    mov     [esp+20h+var_E], bl
    mov     [esp+20h+var_D], bl
    lea     ecx, [eax+ecx*4]
    add     ecx, esi
    xor     esi, esi
    test    edx, edx
    jle     short loc_47D92A
    mov     [esp+20h+var_C], edx

    loc_47D8BA:                             ; CODE XREF: sub_47D820+108j
    test    ebp, ebp
    jle     short loc_47D913
    mov     edx, [esp+20h+arg_0]
    mov     edi, [edx+14Eh]

    loc_47D8C8:                             ; CODE XREF: sub_47D820+E9j
    xor     eax, eax
    mov     al, [esi+edi]
    inc     esi
    test    al, 8
    jz      short loc_47D8F2
    mov     dl, [ecx+6]
    mov     bl, byte ptr [esp+20h+arg_4]
    cmp     dl, bl
    jnb     short loc_47D8E1
    mov     byte ptr [esp+20h+arg_4], dl

    loc_47D8E1:                             ; CODE XREF: sub_47D820+BBj
    mov     dl, [ecx+5]
    mov     bl, [esp+20h+var_E]
    cmp     dl, bl
    jbe     short loc_47D8F2
    mov     bl, dl
    mov     [esp+20h+var_E], bl

    loc_47D8F2:                             ; CODE XREF: sub_47D820+B0j
                                            ; sub_47D820+CAj
    test    al, 10h
    jz      short loc_47D905
    mov     al, [ecx+5]
    mov     dl, [esp+20h+var_D]
    cmp     al, dl
    jbe     short loc_47D905
    mov     [esp+20h+var_D], al

    loc_47D905:                             ; CODE XREF: sub_47D820+D4j
                                            ; sub_47D820+DFj
    add     ecx, 0Dh
    dec     ebp
    jnz     short loc_47D8C8
    mov     edi, [esp+20h+var_8]
    mov     ebp, [esp+20h+var_4]

    loc_47D913:                             ; CODE XREF: sub_47D820+9Cj
    mov     eax, edi
    sub     eax, ebp
    lea     edx, [eax+eax*2]
    lea     ecx, [ecx+edx*4]
    add     ecx, eax
    mov     eax, [esp+20h+var_C]
    dec     eax
    mov     [esp+20h+var_C], eax
    jnz     short loc_47D8BA

    loc_47D92A:                             ; CODE XREF: sub_47D820+94j
    mov     al, byte ptr [esp+20h+arg_4]
    cmp     bl, al
    jnb     short loc_47D94A
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+20h+arg_0]
    mov     al, [edx+1427Fh]
    mov     dl, [ecx+22Ch]
    sub     al, dl

    loc_47D94A:                             ; CODE XREF: sub_47D820+110j
    mov     byte ptr [esp+20h+arg_0], al
    mov     eax, [esp+20h+arg_0]
    and     eax, 0FFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47D961:                             ; CODE XREF: sub_47D820+1Dj
                                            ; sub_47D820+2Cj ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 10h
    retn    8
    sub_47D820 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47D970 proc near                    ; CODE XREF: sub_47DAC0+Cp

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    mov     ecx, [esp+14h+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ax, [ecx+76h]
    mov     dx, [ecx+80h]
    add     ax, [ecx+7Eh]
    add     dx, [ecx+78h]
    push    edi
    mov     edi, [ecx+76h]
    cmp     di, 1
    mov     [esp+24h+var_10], edi
    jl      loc_47DAA6
    mov     bp, word ptr [esp+24h+var_10+2]
    cmp     bp, 1
    jl      loc_47DAA6
    mov     esi, TAdynmemStructPtr
    movsx   eax, ax
    mov     ecx, [esi+14233h]
    mov     [esp+24h+var_14], eax
    cmp     eax, ecx
    jge     loc_47DAA6
    movsx   eax, dx
    mov     edx, [esi+14237h]
    mov     [esp+24h+var_4], eax
    cmp     eax, edx
    jge     loc_47DAA6
    mov     edx, [esp+24h+arg_4]
    mov     [esp+24h+arg_4], 0
    neg     edx
    sbb     edx, edx
    movsx   ebx, bp
    and     edx, 0FFFFFFFEh
    mov     [esp+24h+var_10], ebx
    add     edx, 4
    cmp     ebx, eax
    jge     loc_47DA97
    movsx   eax, di
    mov     [esp+24h+var_C], eax
    lea     eax, [ecx+ecx*2]
    lea     eax, [ecx+eax*4]
    mov     [esp+24h+var_8], eax
    mov     eax, ebx
    imul    eax, ecx
    lea     ecx, [eax+eax*2]
    lea     ebp, [eax+ecx*4]
    mov     eax, [esi+14287h]
    add     ebp, eax

    loc_47DA27:                             ; CODE XREF: sub_47D970+125j
    mov     eax, [esp+24h+var_C]
    mov     ecx, [esp+24h+var_14]
    cmp     eax, ecx
    jge     short loc_47DA84
    mov     esi, ebp
    lea     ecx, [eax+eax*2]
    add     esi, eax
    lea     esi, [esi+ecx*4]
    mov     ecx, [esp+24h+arg_0]
    mov     ecx, [ecx+92h]
    mov     edi, [ecx+14Eh]

    loc_47DA4D:                             ; CODE XREF: sub_47D970+10Ej
    mov     ecx, [esp+24h+arg_4]
    mov     bl, [ecx+edi]
    and     bl, dl
    inc     ecx
    test    bl, bl
    mov     [esp+24h+arg_4], ecx
    jz      short loc_47DA74
    mov     cx, [esi]
    test    cx, cx
    jz      short loc_47DA74
    mov     ebx, [esp+24h+arg_0]
    cmp     cx, [ebx+0A8h]
    jnz     short loc_47DAA6

    loc_47DA74:                             ; CODE XREF: sub_47D970+EDj
                                            ; sub_47D970+F5j
    mov     ecx, [esp+24h+var_14]
    inc     eax
    add     esi, 0Dh
    cmp     eax, ecx
    jl      short loc_47DA4D
    mov     ebx, [esp+24h+var_10]

    loc_47DA84:                             ; CODE XREF: sub_47D970+C1j
    mov     ecx, [esp+24h+var_8]
    mov     eax, [esp+24h+var_4]
    inc     ebx
    add     ebp, ecx
    cmp     ebx, eax
    mov     [esp+24h+var_10], ebx
    jl      short loc_47DA27

    loc_47DA97:                             ; CODE XREF: sub_47D970+8Dj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47DAA6:                             ; CODE XREF: sub_47D970+29j
                                            ; sub_47D970+38j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 14h
    retn    8
    sub_47D970 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47DAC0 proc near                    ; CODE XREF: sub_480B20+8Ep

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    push    ebx
    push    esi
    call    sub_47D970
    test    eax, eax
    jz      short loc_47DB0F
    mov     al, [esi+10Fh]
    and     bl, 1
    shl     bl, 2
    and     al, 0FBh
    push    esi
    or      bl, al
    mov     eax, [esi+110h]
    or      eax, 8000000h
    mov     [esi+10Fh], bl
    mov     [esi+110h], eax
    call    sub_47C790
    mov     ecx, [esi+7Eh]
    mov     edx, [esi+76h]
    push    ecx
    push    edx
    call    sub_440A40

    loc_47DB0F:                             ; CODE XREF: sub_47DAC0+13j
    pop     esi
    pop     ebx
    retn    8
    sub_47DAC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47DB20 proc near                    ; CODE XREF: sub_487080+618p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    lea     edx, [esp+arg_0]
    mov     [esp+arg_0], offset off_4FD660
    mov     eax, [esi+110h]
    mov     ecx, [esi+76h]
    or      eax, 8000000h
    push    edx
    mov     [esi+110h], eax
    mov     eax, [esi+7Eh]
    push    eax
    push    ecx
    call    sub_47E5C0
    mov     eax, [esi+7Eh]
    mov     ecx, [esi+76h]
    push    eax
    push    ecx
    call    sub_440A40
    pop     esi
    retn    4
    sub_47DB20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47DB70 proc near                    ; CODE XREF: .text:00402899p
                                            ; .text:00403CC7p ...

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= word ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 14h
    mov     edx, [esp+14h+arg_8]
    push    ebx
    push    ebp
    mov     ebp, [esp+1Ch+arg_0]
    push    esi
    push    edi
    mov     eax, [ebp+14Ah]
    test    dx, dx
    mov     [esp+24h+var_14], eax
    jl      loc_47DDA5
    mov     si, word ptr [esp+24h+arg_8+2]
    test    si, si
    jl      loc_47DDA5
    mov     edi, TAdynmemStructPtr
    movsx   eax, ax
    mov     ebx, [edi+TAdynmemStruct.FeatureMapSizeX]
    mov     [esp+24h+arg_8], eax
    movsx   ecx, dx
    add     eax, ecx
    cmp     eax, ebx
    jge     loc_47DDA5
    movsx   eax, si
    movsx   esi, word ptr [esp+24h+var_14+2]
    add     esi, eax
    cmp     esi, [edi+TAdynmemStruct.FeatureMapSizeY]
    jge     loc_47DDA5
    cmp     byte ptr [ebp+22Fh], 0
    jnz     short loc_47DBF4
    push    0
    push    0
    push    edx
    push    ebp
    call    sub_47D2E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_47DBF4:                             ; CODE XREF: sub_47DB70+6Dj
    imul    eax, ebx
    add     eax, ecx
    mov     edx, ebx
    mov     ebx, [esp+24h+arg_8]
    lea     ecx, [eax+eax*2]
    sub     edx, ebx
    movsx   ebx, word ptr [ebp+1BEh]
    lea     ecx, [eax+ecx*4]
    mov     eax, [edi+TAdynmemStruct.Features]
    add     ecx, eax
    mov     al, [ebp+228h]
    mov     byte ptr [esp+24h+var_8], al
    mov     al, [edi+1427Fh]
    and     eax, 0FFh
    mov     [esp+24h+var_4], edx
    mov     esi, eax
    sub     esi, ebx
    mov     [esp+24h+var_10], esi
    movsx   esi, word ptr [ebp+1C0h]
    sub     eax, esi
    mov     esi, [esp+24h+arg_C]
    mov     [esp+24h+var_C], eax
    mov     eax, 1
    cmp     esi, eax
    jnz     loc_47DDB1
    movsx   eax, word ptr [esp+24h+var_14+2]
    test    eax, eax
    mov     [esp+24h+arg_C], 0
    jle     loc_47DD8A

    loc_47DC6A:                             ; CODE XREF: sub_47DB70+214j
    mov     eax, [esp+24h+arg_8]
    xor     ebp, ebp
    test    eax, eax
    jle     loc_47DD6C

    loc_47DC78:                             ; CODE XREF: sub_47DB70+1F2j
    mov     ax, [ecx+8]
    cmp     ax, 0FFFFh
    jnz     short loc_47DC86
    xor     eax, eax
    jmp     short loc_47DCF5
    ; ---------------------------------------------------------------------------

    loc_47DC86:                             ; CODE XREF: sub_47DB70+110j
    cmp     ax, 0FFFBh
    jnb     short loc_47DCA2
    mov     edx, [edi+TAdynmemStruct.NumFeatureDefs]
    and     eax, 0FFFFh
    cmp     eax, edx
    jl      short loc_47DCDF
    mov     eax, 1
    jmp     short loc_47DCF5
    ; ---------------------------------------------------------------------------

    loc_47DCA2:                             ; CODE XREF: sub_47DB70+11Aj
    cmp     ax, 0FFFEh
    jz      short loc_47DCAF
    mov     eax, 1
    jmp     short loc_47DCF5
    ; ---------------------------------------------------------------------------

    loc_47DCAF:                             ; CODE XREF: sub_47DB70+136j
    xor     eax, eax
    xor     edx, edx
    mov     al, [ecx+0Ah]
    mov     dl, [ecx+0Bh]
    imul    eax, [edi+TAdynmemStruct.FeatureMapSizeX]
    add     eax, edx
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    mov     edx, ecx
    sub     edx, eax
    mov     ax, [edx+8]
    cmp     ax, 0FFFBh
    jb      short loc_47DCDA
    xor     eax, eax
    jmp     short loc_47DCF5
    ; ---------------------------------------------------------------------------

    loc_47DCDA:                             ; CODE XREF: sub_47DB70+164j
    and     eax, 0FFFFh

    loc_47DCDF:                             ; CODE XREF: sub_47DB70+129j
    mov     edx, [edi+TAdynmemStruct.FeatureDef]
    shl     eax, 8
    mov     al, [edx+eax+0FEh]
    shr     eax, 6
    and     eax, 1

    loc_47DCF5:                             ; CODE XREF: sub_47DB70+114j
                                            ; sub_47DB70+130j ...
    test    eax, eax
    jnz     loc_47DD99
    mov     ax, [ecx]
    test    ax, ax
    jz      short loc_47DD10
    cmp     ax, [esp+24h+arg_4]
    jnz     loc_47DD99

    loc_47DD10:                             ; CODE XREF: sub_47DB70+193j
    mov     dl, [ecx+6]
    mov     esi, [esp+24h+var_10]
    mov     eax, edx
    and     eax, 0FFh
    cmp     eax, esi
    jl      short loc_47DD99
    xor     ebx, ebx
    mov     bl, [ecx+5]
    mov     esi, ebx
    mov     ebx, [esp+24h+var_C]
    cmp     esi, ebx
    jg      short loc_47DD99
    sub     esi, eax
    mov     eax, [esp+24h+var_8]
    and     eax, 0FFh
    cmp     esi, eax
    jle     short loc_47DD58
    cmp     dl, [edi+1427Fh]
    jnb     short loc_47DD99
    mov     eax, [esp+24h+arg_0]
    xor     edx, edx
    mov     dl, [eax+229h]
    cmp     esi, edx
    jg      short loc_47DD99

    loc_47DD58:                             ; CODE XREF: sub_47DB70+1CEj
    mov     eax, [esp+24h+arg_8]
    inc     ebp
    add     ecx, 0Dh
    cmp     ebp, eax
    jl      loc_47DC78
    mov     edx, [esp+24h+var_4]

    loc_47DD6C:                             ; CODE XREF: sub_47DB70+102j
    mov     esi, [esp+24h+arg_C]
    lea     eax, [edx+edx*2]
    inc     esi
    lea     ecx, [ecx+eax*4]
    mov     [esp+24h+arg_C], esi
    movsx   eax, word ptr [esp+24h+var_14+2]
    add     ecx, edx
    cmp     esi, eax
    jl      loc_47DC6A

    loc_47DD8A:                             ; CODE XREF: sub_47DB70+F4j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_47DD99:                             ; CODE XREF: sub_47DB70+187j
                                            ; sub_47DB70+19Aj ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_47DDA5:                             ; CODE XREF: sub_47DB70+1Cj
                                            ; sub_47DB70+2Aj ...
    mov     ecx, [esp+24h+arg_C]
    xor     eax, eax
    cmp     ecx, 2
    setz    al

    loc_47DDB1:                             ; CODE XREF: sub_47DB70+DFj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    10h
    sub_47DB70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47DDC0 proc near                    ; CODE XREF: .text:00403D2Fp
                                            ; .text:0041406Bp ...

    var_10= dword ptr -10h
    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    edi
    mov     edi, [esp+14h+arg_0]
    mov     al, [edi+22Fh]
    test    al, al
    jnz     loc_47DE57
    push    esi
    mov     esi, [esp+18h+arg_4]
    mov     edx, [edi+14Ah]
    mov     ecx, esi
    push    ebx
    mov     [esp+1Ch+var_10], edx
    mov     eax, [ecx]
    mov     [esp+1Ch+arg_4], edx
    mov     ebx, [ecx+4]
    mov     [esp+1Ch+var_8], ebx
    movsx   ebx, dx
    mov     ecx, [ecx+8]
    shl     ebx, 13h
    sub     eax, ebx
    movsx   ebx, word ptr [esp+1Ch+var_10+2]
    add     eax, 80000h
    sar     eax, 14h
    shl     ebx, 13h
    mov     word ptr [esp+1Ch+arg_0], ax
    sub     ecx, ebx
    movsx   eax, ax
    movsx   edx, dx
    add     ecx, 80000h
    sar     ecx, 14h
    mov     word ptr [esp+1Ch+arg_0+2], cx
    lea     eax, [edx+eax*2]
    movsx   edx, word ptr [esp+1Ch+arg_4+2]
    movsx   ecx, cx
    shl     eax, 13h
    mov     [esi], eax
    lea     eax, [edx+ecx*2]
    mov     ecx, [esp+1Ch+arg_0]
    shl     eax, 13h
    push    ecx
    push    edi
    mov     [esi+8], eax
    call    sub_47D820
    shl     eax, 10h
    mov     [esi+4], eax
    pop     ebx
    pop     esi

    loc_47DE57:                             ; CODE XREF: sub_47DDC0+10j
    pop     edi
    add     esp, 10h
    retn    8
    sub_47DDC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47DE60 proc near                    ; CODE XREF: sub_440500+64p

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    ebp
    mov     edx, TAdynmemStructPtr
    push    esi
    mov     esi, [esp+4+arg_4]
    push    edi
    mov     ax, [esi+8]
    cmp     ax, 0FFFFh
    jnz     short loc_47DE7C
    xor     eax, eax
    jmp     short loc_47DEEB
    ; ---------------------------------------------------------------------------

    loc_47DE7C:                             ; CODE XREF: sub_47DE60+16j
    cmp     ax, 0FFFBh
    jnb     short loc_47DE98
    mov     ecx, [edx+14253h]
    and     eax, 0FFFFh
    cmp     eax, ecx
    jl      short loc_47DED5
    mov     eax, 1
    jmp     short loc_47DEEB
    ; ---------------------------------------------------------------------------

    loc_47DE98:                             ; CODE XREF: sub_47DE60+20j
    cmp     ax, 0FFFEh
    jz      short loc_47DEA5
    mov     eax, 1
    jmp     short loc_47DEEB
    ; ---------------------------------------------------------------------------

    loc_47DEA5:                             ; CODE XREF: sub_47DE60+3Cj
    xor     eax, eax
    xor     ecx, ecx
    mov     al, [esi+0Ah]
    mov     cl, [esi+0Bh]
    imul    eax, [edx+14233h]
    add     eax, ecx
    lea     ecx, [eax+eax*2]
    lea     eax, [eax+ecx*4]
    mov     ecx, esi
    sub     ecx, eax
    mov     ax, [ecx+8]
    cmp     ax, 0FFFBh
    jb      short loc_47DED0
    xor     eax, eax
    jmp     short loc_47DEEB
    ; ---------------------------------------------------------------------------

    loc_47DED0:                             ; CODE XREF: sub_47DE60+6Aj
    and     eax, 0FFFFh

    loc_47DED5:                             ; CODE XREF: sub_47DE60+2Fj
    mov     ecx, [edx+1426Fh]
    shl     eax, 8
    mov     al, [ecx+eax+0FEh]
    shr     eax, 6
    and     eax, 1

    loc_47DEEB:                             ; CODE XREF: sub_47DE60+1Aj
                                            ; sub_47DE60+36j ...
    test    eax, eax
    jz      short loc_47DEF8
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47DEF8:                             ; CODE XREF: sub_47DE60+8Dj
    mov     ax, [esi]
    mov     edi, [esp+8+arg_0]
    test    ax, ax
    jz      short loc_47DF35
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]
    mov     eax, [eax]
    test    eax, eax
    jz      short loc_47DF77
    mov     eax, [eax+26h]
    mov     ecx, [edi+1Ch]
    cmp     eax, ecx
    jnb     short loc_47DF35
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47DF35:                             ; CODE XREF: sub_47DE60+A2j
                                            ; sub_47DE60+CAj
    mov     dl, [edx+1427Fh]
    mov     bl, [esi+6]
    movsx   ecx, word ptr [edi+8]
    mov     eax, edx
    and     eax, 0FFh
    mov     ebp, eax
    sub     ebp, ecx
    mov     ecx, ebx
    and     ecx, 0FFh
    cmp     ecx, ebp
    jge     short loc_47DF62
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47DF62:                             ; CODE XREF: sub_47DE60+F7j
    mov     cl, [esi+5]
    movsx   esi, word ptr [edi+0Ah]
    sub     eax, esi
    mov     esi, ecx
    and     esi, 0FFh
    cmp     esi, eax
    jle     short loc_47DF80

    loc_47DF77:                             ; CODE XREF: sub_47DE60+C0j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47DF80:                             ; CODE XREF: sub_47DE60+115j
    sub     cl, bl
    cmp     bl, dl
    jnb     short loc_47DF98
    cmp     cl, [edi+0Fh]
    jbe     short loc_47DFAA
    cmp     [edi+0Eh], cl
    sbb     eax, eax
    inc     eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47DF98:                             ; CODE XREF: sub_47DE60+124j
    cmp     cl, [edi+0Dh]
    jbe     short loc_47DFAA
    cmp     [edi+0Ch], cl
    sbb     eax, eax
    inc     eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47DFAA:                             ; CODE XREF: sub_47DE60+129j
                                            ; sub_47DE60+13Bj
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 3
    pop     ebx
    retn    8
    sub_47DE60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47DFC0 proc near                    ; CODE XREF: sub_47E1F0+24p
                                            ; sub_47E1F0+47p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     edx, [esp+arg_4]
    sub     esp, 8
    test    edx, edx
    push    ebx
    push    ebp
    push    esi
    push    edi
    jl      loc_47E1E3
    mov     ecx, [esp+18h+arg_8]
    test    ecx, ecx
    jl      loc_47E1E3
    mov     edi, TAdynmemStructPtr
    mov     ebp, [esp+18h+arg_C]
    mov     ebx, [edi+14233h]
    lea     eax, [ebp+edx+0]
    cmp     eax, ebx
    jge     loc_47E1E3
    mov     eax, [esp+18h+arg_10]
    mov     esi, [edi+14237h]
    add     eax, ecx
    cmp     eax, esi
    jge     loc_47E1E3
    imul    ecx, ebx
    add     ecx, edx
    mov     eax, 3
    mov     [esp+18h+arg_4], 0
    lea     edx, [ecx+ecx*2]
    lea     esi, [ecx+edx*4]
    mov     ecx, [edi+14287h]
    add     esi, ecx
    mov     ecx, ebx
    sub     ecx, ebp
    mov     ebp, [esp+18h+arg_0]
    mov     [esp+18h+var_8], ecx
    mov     cl, [edi+1427Fh]
    movsx   ebx, word ptr [ebp+8]
    and     ecx, 0FFh
    mov     edx, ecx
    sub     edx, ebx
    mov     [esp+18h+arg_0], edx
    movsx   edx, word ptr [ebp+0Ah]
    sub     ecx, edx
    mov     [esp+18h+var_4], ecx
    mov     ecx, [esp+18h+arg_10]
    test    ecx, ecx
    jle     loc_47E1E5
    mov     edx, [esp+18h+arg_C]
    mov     ecx, [esp+18h+var_8]

    loc_47E071:                             ; CODE XREF: sub_47DFC0+213j
    test    edx, edx
    mov     [esp+18h+arg_8], 0
    jle     loc_47E1BA

    loc_47E081:                             ; CODE XREF: sub_47DFC0+1F0j
    mov     cx, [esi+8]
    cmp     cx, 0FFFFh
    jnz     short loc_47E090
    xor     ecx, ecx
    jmp     short loc_47E104
    ; ---------------------------------------------------------------------------

    loc_47E090:                             ; CODE XREF: sub_47DFC0+CAj
    cmp     cx, 0FFFBh
    jnb     short loc_47E0AE
    mov     edx, [edi+14253h]
    and     ecx, 0FFFFh
    cmp     ecx, edx
    jl      short loc_47E0EE
    mov     ecx, 1
    jmp     short loc_47E104
    ; ---------------------------------------------------------------------------

    loc_47E0AE:                             ; CODE XREF: sub_47DFC0+D5j
    cmp     cx, 0FFFEh
    jz      short loc_47E0BC
    mov     ecx, 1
    jmp     short loc_47E104
    ; ---------------------------------------------------------------------------

    loc_47E0BC:                             ; CODE XREF: sub_47DFC0+F3j
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [esi+0Ah]
    mov     dl, [esi+0Bh]
    imul    ecx, [edi+14233h]
    add     ecx, edx
    lea     edx, [ecx+ecx*2]
    lea     ecx, [ecx+edx*4]
    mov     edx, esi
    sub     edx, ecx
    mov     cx, [edx+8]
    cmp     cx, 0FFFBh
    jb      short loc_47E0E8
    xor     ecx, ecx
    jmp     short loc_47E104
    ; ---------------------------------------------------------------------------

    loc_47E0E8:                             ; CODE XREF: sub_47DFC0+122j
    and     ecx, 0FFFFh

    loc_47E0EE:                             ; CODE XREF: sub_47DFC0+E5j
    mov     edx, [edi+1426Fh]
    shl     ecx, 8
    mov     cl, [edx+ecx+0FEh]
    shr     ecx, 6
    and     ecx, 1

    loc_47E104:                             ; CODE XREF: sub_47DFC0+CEj
                                            ; sub_47DFC0+ECj ...
    test    ecx, ecx
    jnz     loc_47E1E3
    mov     cx, [esi]
    test    cx, cx
    jz      short loc_47E145
    and     ecx, 0FFFFh
    mov     edx, ecx
    shl     ecx, 3
    sub     ecx, edx
    mov     edx, [edi+14357h]
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [edx+ecx*8]
    mov     ecx, [ecx]
    test    ecx, ecx
    jz      loc_47E1E3
    mov     ecx, [ecx+26h]
    mov     edx, [ebp+1Ch]
    cmp     ecx, edx
    jb      loc_47E1E3

    loc_47E145:                             ; CODE XREF: sub_47DFC0+152j
    mov     dl, [esi+6]
    mov     ebx, [esp+18h+arg_0]
    mov     ecx, edx
    and     ecx, 0FFh
    cmp     ecx, ebx
    jl      loc_47E1E3
    mov     cl, [esi+5]
    mov     ebx, ecx
    and     ebx, 0FFh
    cmp     ebx, [esp+18h+var_4]
    jg      short loc_47E1E3
    mov     bl, [edi+1427Fh]
    sub     cl, dl
    cmp     dl, bl
    jnb     short loc_47E18A
    cmp     cl, [ebp+0Fh]
    jbe     short loc_47E19E
    cmp     cl, [ebp+0Eh]
    ja      short loc_47E1E3
    cmp     eax, 1
    jbe     short loc_47E19E
    jmp     short loc_47E199
    ; ---------------------------------------------------------------------------

    loc_47E18A:                             ; CODE XREF: sub_47DFC0+1B7j
    cmp     cl, [ebp+0Dh]
    jbe     short loc_47E19E
    cmp     cl, [ebp+0Ch]
    ja      short loc_47E1E3
    cmp     eax, 1
    jbe     short loc_47E19E

    loc_47E199:                             ; CODE XREF: sub_47DFC0+1C8j
    mov     eax, 1

    loc_47E19E:                             ; CODE XREF: sub_47DFC0+1BCj
                                            ; sub_47DFC0+1C6j ...
    mov     ecx, [esp+18h+arg_8]
    mov     edx, [esp+18h+arg_C]
    inc     ecx
    add     esi, 0Dh
    cmp     ecx, edx
    mov     [esp+18h+arg_8], ecx
    jl      loc_47E081
    mov     ecx, [esp+18h+var_8]

    loc_47E1BA:                             ; CODE XREF: sub_47DFC0+BBj
    mov     ebx, [esp+18h+arg_4]
    inc     ebx
    mov     [esp+18h+arg_4], ebx
    lea     ebx, [ecx+ecx*2]
    lea     esi, [esi+ebx*4]
    mov     ebx, [esp+18h+arg_10]
    add     esi, ecx
    cmp     [esp+18h+arg_4], ebx
    jl      loc_47E071
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_47E1E3:                             ; CODE XREF: sub_47DFC0+Dj
                                            ; sub_47DFC0+19j ...
    xor     eax, eax

    loc_47E1E5:                             ; CODE XREF: sub_47DFC0+A3j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    14h
    sub_47DFC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47E1F0 proc near                    ; CODE XREF: sub_440830+A5p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+14h+arg_0]
    mov     ebp, [esp+14h+arg_8]
    mov     ebx, [esp+14h+arg_4]
    movsx   eax, word ptr [esi+6]
    push    edi
    push    eax
    movsx   edi, word ptr [esi+4]
    push    edi
    push    ebp
    push    ebx
    push    esi
    mov     [esp+2Ch+arg_0], eax
    call    sub_47DFC0
    cmp     eax, 1
    jbe     loc_47E2C6
    lea     eax, [edi+1]
    dec     ebp
    push    1
    lea     ecx, [ebx-1]
    push    eax
    push    ebp
    push    ecx
    push    esi
    mov     [esp+2Ch+arg_4], eax
    mov     [esp+2Ch+var_4], ecx
    call    sub_47DFC0
    cmp     eax, 3
    jz      short loc_47E250
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_47E250:                             ; CODE XREF: sub_47E1F0+4Fj
    mov     eax, [esp+18h+arg_0]
    add     edi, ebx
    inc     eax
    push    eax
    push    1
    push    ebp
    push    edi
    push    esi
    mov     [esp+2Ch+var_8], eax
    call    sub_47DFC0
    cmp     eax, 3
    jz      short loc_47E27A
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_47E27A:                             ; CODE XREF: sub_47E1F0+79j
    mov     edx, [esp+18h+arg_0]
    mov     edi, [esp+18h+arg_8]
    mov     ecx, [esp+18h+arg_4]
    push    1
    add     edx, edi
    push    ecx
    push    edx
    push    ebx
    push    esi
    call    sub_47DFC0
    cmp     eax, 3
    jz      short loc_47E2A7
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_47E2A7:                             ; CODE XREF: sub_47E1F0+A6j
    mov     eax, [esp+18h+var_8]
    mov     ecx, [esp+18h+var_4]
    push    eax
    push    1
    push    edi
    push    ecx
    push    esi
    call    sub_47DFC0
    sub     eax, 3
    neg     eax
    sbb     eax, eax
    and     al, 0FEh
    add     eax, 3

    loc_47E2C6:                             ; CODE XREF: sub_47E1F0+2Cj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_47E1F0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47E2D0 proc near                    ; CODE XREF: GameUnit_EndTransport+217p
                                            ; GameUnit_EndTransport+37Cp

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 1Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+28h+arg_0]
    mov     ecx, [esp+28h+arg_4]
    push    edi
    mov     edx, [esi+7Eh]
    mov     esi, [esi+92h]
    mov     eax, [ecx]
    mov     [esp+2Ch+var_1C], edx
    movsx   ebx, dx
    mov     edi, [ecx+4]
    mov     edx, ebx
    shl     edx, 13h
    mov     ecx, [ecx+8]
    sub     eax, edx
    movsx   edx, word ptr [esp+2Ch+var_1C+2]
    shl     edx, 13h
    sub     ecx, edx
    add     eax, 80000h
    add     ecx, 80000h
    mov     [esp+2Ch+var_8], edi
    sar     eax, 14h
    sar     ecx, 14h
    test    ax, ax
    mov     [esp+2Ch+var_18], ebx
    jl      loc_47E556
    test    cx, cx
    jl      loc_47E556
    mov     edi, TAdynmemStructPtr
    movsx   edx, ax
    mov     ebp, [edi+14233h]
    lea     eax, [edx+ebx]
    cmp     eax, ebp
    jge     loc_47E556
    movsx   eax, cx
    movsx   ecx, word ptr [esp+2Ch+var_1C+2]
    add     ecx, eax
    cmp     ecx, [edi+14237h]
    jge     loc_47E556
    mov     ecx, ebx
    mov     ebx, eax
    sar     ecx, 2
    sar     ebx, 1
    add     ebx, ecx
    sar     ebp, 1
    imul    ebx, ebp
    mov     ebp, edx
    add     ecx, ebx
    sar     ebp, 1
    add     ebp, ecx
    mov     ecx, [edi+14273h]
    xor     ebx, ebx
    mov     bx, [ecx+ebp*2]
    mov     ecx, [esp+2Ch+arg_0]
    mov     ebp, 1
    mov     cl, [ecx+0FFh]
    shl     ebp, cl
    test    ebp, ebx
    jnz     short loc_47E3AB
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47E3AB:                             ; CODE XREF: sub_47E2D0+CAj
    mov     cl, [esi+228h]
    movsx   ebp, word ptr [esi+1BEh]
    mov     byte ptr [esp+2Ch+var_10], cl
    xor     ecx, ecx
    mov     cl, [edi+1427Fh]
    mov     ebx, ecx
    sub     ebx, ebp
    movsx   ebp, word ptr [esi+1C0h]
    mov     [esp+2Ch+arg_4], ebx
    mov     ebx, ecx
    sub     ebx, ebp
    mov     [esp+2Ch+var_14], ebx
    mov     ebx, [esp+2Ch+arg_4]
    cmp     ebx, ecx
    jge     short loc_47E3FD
    mov     esi, [esi+241h]
    test    esi, 800h
    jz      short loc_47E3FD
    test    esi, 200000h
    jnz     short loc_47E3FD
    mov     [esp+2Ch+arg_4], ecx

    loc_47E3FD:                             ; CODE XREF: sub_47E2D0+111j
                                            ; sub_47E2D0+11Fj ...
    mov     esi, [edi+14233h]
    mov     ebx, [esp+2Ch+var_18]
    imul    eax, esi
    add     eax, edx
    sub     esi, ebx
    mov     [esp+2Ch+var_18], 0
    lea     edx, [eax+eax*2]
    lea     ecx, [eax+edx*4]
    mov     eax, [edi+14287h]
    add     ecx, eax
    movsx   eax, word ptr [esp+2Ch+var_1C+2]
    test    eax, eax
    jle     loc_47E547

    loc_47E431:                             ; CODE XREF: sub_47E2D0+271j
    xor     ebp, ebp
    test    ebx, ebx
    jle     loc_47E529

    loc_47E43B:                             ; CODE XREF: sub_47E2D0+253j
    mov     ax, [ecx+8]
    cmp     ax, 0FFFFh
    jnz     short loc_47E449
    xor     eax, eax
    jmp     short loc_47E4B8
    ; ---------------------------------------------------------------------------

    loc_47E449:                             ; CODE XREF: sub_47E2D0+173j
    cmp     ax, 0FFFBh
    jnb     short loc_47E465
    mov     edx, [edi+14253h]
    and     eax, 0FFFFh
    cmp     eax, edx
    jl      short loc_47E4A2
    mov     eax, 1
    jmp     short loc_47E4B8
    ; ---------------------------------------------------------------------------

    loc_47E465:                             ; CODE XREF: sub_47E2D0+17Dj
    cmp     ax, 0FFFEh
    jz      short loc_47E472
    mov     eax, 1
    jmp     short loc_47E4B8
    ; ---------------------------------------------------------------------------

    loc_47E472:                             ; CODE XREF: sub_47E2D0+199j
    xor     eax, eax
    xor     edx, edx
    mov     al, [ecx+0Ah]
    mov     dl, [ecx+0Bh]
    imul    eax, [edi+14233h]
    add     eax, edx
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    mov     edx, ecx
    sub     edx, eax
    mov     ax, [edx+8]
    cmp     ax, 0FFFBh
    jb      short loc_47E49D
    xor     eax, eax
    jmp     short loc_47E4B8
    ; ---------------------------------------------------------------------------

    loc_47E49D:                             ; CODE XREF: sub_47E2D0+1C7j
    and     eax, 0FFFFh

    loc_47E4A2:                             ; CODE XREF: sub_47E2D0+18Cj
    mov     edx, [edi+1426Fh]
    shl     eax, 8
    mov     al, [edx+eax+0FEh]
    shr     eax, 6
    and     eax, 1

    loc_47E4B8:                             ; CODE XREF: sub_47E2D0+177j
                                            ; sub_47E2D0+193j ...
    test    eax, eax
    jnz     loc_47E556
    test    byte ptr [ecx+0Ch], 2
    jnz     loc_47E556
    mov     ax, [ecx]
    test    ax, ax
    jz      short loc_47E4DF
    mov     edx, [esp+2Ch+arg_0]
    cmp     ax, [edx+0A8h]
    jnz     short loc_47E556

    loc_47E4DF:                             ; CODE XREF: sub_47E2D0+200j
    mov     ax, [ecx+2]
    test    ax, ax
    jz      short loc_47E4F5
    mov     edx, [esp+2Ch+arg_0]
    cmp     ax, [edx+0A8h]
    jnz     short loc_47E556

    loc_47E4F5:                             ; CODE XREF: sub_47E2D0+216j
    mov     eax, [esp+2Ch+arg_4]
    xor     edx, edx
    mov     dl, [ecx+6]
    cmp     edx, eax
    jl      short loc_47E556
    xor     eax, eax
    mov     al, [ecx+5]
    cmp     eax, [esp+2Ch+var_14]
    jg      short loc_47E556
    sub     eax, edx
    mov     edx, [esp+2Ch+var_10]
    and     edx, 0FFh
    cmp     eax, edx
    jg      short loc_47E556
    inc     ebp
    add     ecx, 0Dh
    cmp     ebp, ebx
    jl      loc_47E43B

    loc_47E529:                             ; CODE XREF: sub_47E2D0+165j
    mov     edx, [esp+2Ch+var_18]
    lea     eax, [esi+esi*2]
    inc     edx
    lea     ecx, [ecx+eax*4]
    mov     [esp+2Ch+var_18], edx
    movsx   eax, word ptr [esp+2Ch+var_1C+2]
    add     ecx, esi
    cmp     edx, eax
    jl      loc_47E431

    loc_47E547:                             ; CODE XREF: sub_47E2D0+15Bj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47E556:                             ; CODE XREF: sub_47E2D0+54j
                                            ; sub_47E2D0+5Dj ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 1Ch
    retn    8
    sub_47E2D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47E570 proc near                    ; CODE XREF: .text:00411858p
                                            ; .text:004118AFp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+86h]
    test    ecx, ecx
    jz      short loc_47E583
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47E583:                             ; CODE XREF: sub_47E570+Cj
    mov     eax, [eax+8Ah]
    test    eax, eax
    jz      short loc_47E5B3
    mov     ecx, [esp+arg_4]

    loc_47E591:                             ; CODE XREF: sub_47E570+34j
    movsx   edx, byte ptr [eax+0F9h]
    cmp     edx, ecx
    jz      short loc_47E5AE
    mov     eax, [eax+8Eh]
    test    eax, eax
    jnz     short loc_47E591
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47E5AE:                             ; CODE XREF: sub_47E570+2Aj
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47E5B3:                             ; CODE XREF: sub_47E570+1Bj
    mov     eax, 1
    retn    8
    sub_47E570 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47E5C0 proc near                    ; CODE XREF: .text:0047CAD8p
                                            ; sub_47D0E0+1E4p ...

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 20h
    mov     eax, TAdynmemStructPtr
    push    ebx
    movsx   ebx, word ptr [esp+24h+arg_0]
    movsx   ecx, word ptr [esp+24h+arg_4]
    movsx   edx, word ptr [esp+24h+arg_4+2]
    push    esi
    push    edi
    lea     edi, [eax+1429Fh]
    add     ecx, ebx
    movsx   eax, word ptr [esp+2Ch+arg_0+2]
    mov     esi, eax
    add     eax, edx
    sar     esi, 3
    mov     [esp+2Ch+var_20], ecx
    mov     [esp+2Ch+arg_4], eax
    sar     ecx, 3
    mov     edx, ebx
    dec     esi
    sar     eax, 3
    inc     ecx
    inc     eax
    sar     edx, 3
    dec     edx
    mov     [esp+2Ch+var_1C], edi
    cmp     edx, ecx
    mov     [esp+2Ch+var_8], esi
    mov     [esp+2Ch+var_4], ecx
    mov     [esp+2Ch+var_C], eax
    mov     [esp+2Ch+var_18], edx
    jg      loc_47E739
    push    ebp
    mov     ebp, [esp+30h+arg_8]

    loc_47E626:                             ; CODE XREF: sub_47E5C0+172j
    cmp     esi, eax
    mov     [esp+30h+arg_8], esi
    jg      loc_47E727

    loc_47E632:                             ; CODE XREF: sub_47E5C0+15Dj
    mov     ecx, [edi+4]
    cmp     edx, ecx
    jnb     loc_47E712
    cmp     esi, [edi+8]
    jnb     loc_47E712
    mov     eax, esi
    imul    eax, ecx
    mov     ecx, [edi]
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     edi, [ecx+eax*2+6]
    test    edi, edi
    jz      loc_47E70E

    loc_47E65E:                             ; CODE XREF: sub_47E5C0+140j
    mov     eax, [edi+76h]
    mov     ecx, [edi+7Eh]
    mov     [esp+30h+var_14], eax
    mov     [esp+30h+var_10], ecx
    movsx   eax, ax
    movsx   edx, cx
    add     edx, eax
    cmp     ebx, edx
    jge     short loc_47E6A1
    cmp     [esp+30h+var_20], eax
    jle     short loc_47E6A1
    movsx   eax, word ptr [esp+30h+var_14+2]
    movsx   edx, word ptr [esp+30h+var_10+2]
    movsx   ecx, word ptr [esp+30h+arg_0+2]
    add     edx, eax
    cmp     ecx, edx
    jge     short loc_47E6A1
    cmp     [esp+30h+arg_4], eax
    jle     short loc_47E6A1
    mov     eax, [ebp+0]
    push    edi
    mov     ecx, ebp
    call    dword ptr [eax]

    loc_47E6A1:                             ; CODE XREF: sub_47E5C0+B6j
                                            ; sub_47E5C0+BCj ...
    mov     esi, [edi+8Ah]
    test    esi, esi
    jz      short loc_47E6F8

    loc_47E6AB:                             ; CODE XREF: sub_47E5C0+136j
    mov     ecx, [esi+7Eh]
    mov     eax, [esi+76h]
    mov     [esp+30h+var_14], ecx
    mov     [esp+30h+var_10], eax
    movsx   eax, ax
    movsx   ecx, cx
    add     ecx, eax
    cmp     ebx, ecx
    jge     short loc_47E6EE
    cmp     [esp+30h+var_20], eax
    jle     short loc_47E6EE
    movsx   eax, word ptr [esp+30h+var_10+2]
    movsx   edx, word ptr [esp+30h+var_14+2]
    movsx   ecx, word ptr [esp+30h+arg_0+2]
    add     edx, eax
    cmp     ecx, edx
    jge     short loc_47E6EE
    cmp     [esp+30h+arg_4], eax
    jle     short loc_47E6EE
    mov     eax, [ebp+0]
    push    esi
    mov     ecx, ebp
    call    dword ptr [eax]

    loc_47E6EE:                             ; CODE XREF: sub_47E5C0+103j
                                            ; sub_47E5C0+109j ...
    mov     esi, [esi+8Eh]
    test    esi, esi
    jnz     short loc_47E6AB

    loc_47E6F8:                             ; CODE XREF: sub_47E5C0+E9j
    mov     edi, [edi+8Eh]
    test    edi, edi
    jnz     loc_47E65E
    mov     esi, [esp+30h+arg_8]
    mov     edx, [esp+30h+var_18]

    loc_47E70E:                             ; CODE XREF: sub_47E5C0+98j
    mov     edi, [esp+30h+var_1C]

    loc_47E712:                             ; CODE XREF: sub_47E5C0+77j
                                            ; sub_47E5C0+80j
    mov     eax, [esp+30h+var_C]
    inc     esi
    cmp     esi, eax
    mov     [esp+30h+arg_8], esi
    jle     loc_47E632
    mov     esi, [esp+30h+var_8]

    loc_47E727:                             ; CODE XREF: sub_47E5C0+6Cj
    mov     ecx, [esp+30h+var_4]
    inc     edx
    cmp     edx, ecx
    mov     [esp+30h+var_18], edx
    jle     loc_47E626
    pop     ebp

    loc_47E739:                             ; CODE XREF: sub_47E5C0+5Bj
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 20h
    retn    0Ch
    sub_47E5C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    sub     esp, 10h
    sar     eax, 17h
    push    ebx
    mov     ebx, TAdynmemStructPtr
    push    ebp
    push    esi
    mov     edx, [ebx+142A3h]
    push    edi
    cmp     eax, edx
    jnb     short loc_47E776
    mov     [esp+10h], eax
    xor     edi, edi
    jmp     short loc_47E789
    ; ---------------------------------------------------------------------------

    loc_47E776:                             ; CODE XREF: .text:0047E76Cj
    xor     edi, edi
    cmp     eax, edi
    jge     short loc_47E782
    mov     [esp+10h], edi
    jmp     short loc_47E789
    ; ---------------------------------------------------------------------------

    loc_47E782:                             ; CODE XREF: .text:0047E77Aj
    lea     eax, [edx-1]
    mov     [esp+10h], eax

    loc_47E789:                             ; CODE XREF: .text:0047E774j
                                            ; .text:0047E780j
    mov     eax, [esp+28h]
    mov     esi, [ebx+142A7h]
    sar     eax, 17h
    cmp     eax, esi
    jb      short loc_47E7A5
    cmp     eax, edi
    jge     short loc_47E7A2
    xor     eax, eax
    jmp     short loc_47E7A5
    ; ---------------------------------------------------------------------------

    loc_47E7A2:                             ; CODE XREF: .text:0047E79Cj
    lea     eax, [esi-1]

    loc_47E7A5:                             ; CODE XREF: .text:0047E798j
                                            ; .text:0047E7A0j
    mov     ecx, [esp+2Ch]
    sar     ecx, 17h
    cmp     ecx, edx
    jnb     short loc_47E7B6
    mov     [esp+14h], ecx
    jmp     short loc_47E7C5
    ; ---------------------------------------------------------------------------

    loc_47E7B6:                             ; CODE XREF: .text:0047E7AEj
    cmp     ecx, edi
    jge     short loc_47E7C0
    mov     [esp+14h], edi
    jmp     short loc_47E7C5
    ; ---------------------------------------------------------------------------

    loc_47E7C0:                             ; CODE XREF: .text:0047E7B8j
    dec     edx
    mov     [esp+14h], edx

    loc_47E7C5:                             ; CODE XREF: .text:0047E7B4j
                                            ; .text:0047E7BEj
    mov     ecx, [esp+30h]
    sar     ecx, 17h
    cmp     ecx, esi
    jnb     short loc_47E7D6
    mov     [esp+18h], ecx
    jmp     short loc_47E7E5
    ; ---------------------------------------------------------------------------

    loc_47E7D6:                             ; CODE XREF: .text:0047E7CEj
    cmp     ecx, edi
    jge     short loc_47E7E0
    mov     [esp+18h], edi
    jmp     short loc_47E7E5
    ; ---------------------------------------------------------------------------

    loc_47E7E0:                             ; CODE XREF: .text:0047E7D8j
    dec     esi
    mov     [esp+18h], esi

    loc_47E7E5:                             ; CODE XREF: .text:0047E7D4j
                                            ; .text:0047E7DEj
    mov     edx, [esp+18h]
    mov     ecx, eax
    cmp     eax, edx
    mov     [esp+1Ch], ecx
    jg      loc_47E879
    mov     ebp, [esp+34h]
    mov     edx, [esp+14h]

    loc_47E7FF:                             ; CODE XREF: .text:0047E877j
    mov     edi, [esp+10h]
    mov     eax, edi
    cmp     eax, edx
    jg      short loc_47E86C

    loc_47E809:                             ; CODE XREF: .text:0047E86Aj
    mov     eax, [ebx+142A3h]
    mov     esi, [ebx+1429Fh]
    imul    eax, ecx
    add     eax, edi
    lea     eax, [eax+eax*4]
    mov     esi, [esi+eax*2+6]
    test    esi, esi
    jz      short loc_47E867

    loc_47E825:                             ; CODE XREF: .text:0047E85Dj
    mov     eax, [esi+6Ah]
    mov     ecx, [esp+24h]
    cmp     eax, ecx
    jl      short loc_47E855
    cmp     eax, [esp+2Ch]
    jg      short loc_47E855
    mov     eax, [esi+72h]
    mov     ecx, [esp+28h]
    cmp     eax, ecx
    jl      short loc_47E855
    cmp     eax, [esp+30h]
    jg      short loc_47E855
    mov     edx, [ebp+0]
    push    esi
    mov     ecx, ebp
    call    dword ptr [edx]
    mov     ebx, TAdynmemStructPtr

    loc_47E855:                             ; CODE XREF: .text:0047E82Ej
                                            ; .text:0047E834j ...
    mov     esi, [esi+8Eh]
    test    esi, esi
    jnz     short loc_47E825
    mov     ecx, [esp+1Ch]
    mov     edx, [esp+14h]

    loc_47E867:                             ; CODE XREF: .text:0047E823j
    inc     edi
    cmp     edi, edx
    jle     short loc_47E809

    loc_47E86C:                             ; CODE XREF: .text:0047E807j
    mov     eax, [esp+18h]
    inc     ecx
    cmp     ecx, eax
    mov     [esp+1Ch], ecx
    jle     short loc_47E7FF

    loc_47E879:                             ; CODE XREF: .text:0047E7F1j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47E890 proc near                    ; CODE XREF: .text:00405A4Fp
                                            ; .text:00410A9Ap ...

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 1Ch
    mov     eax, [esp+1Ch+arg_4]
    push    ebx
    mov     ebx, TAdynmemStructPtr
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+2Ch+arg_0]
    mov     edx, [ebx+142A3h]
    mov     ecx, [edi]
    sub     ecx, eax
    sar     ecx, 17h
    cmp     ecx, edx
    jb      short loc_47E8C7
    test    ecx, ecx
    jge     short loc_47E8C4
    mov     [esp+2Ch+var_18], 0
    jmp     short loc_47E8CB
    ; ---------------------------------------------------------------------------

    loc_47E8C4:                             ; CODE XREF: sub_47E890+28j
    lea     ecx, [edx-1]

    loc_47E8C7:                             ; CODE XREF: sub_47E890+24j
    mov     [esp+2Ch+var_18], ecx

    loc_47E8CB:                             ; CODE XREF: sub_47E890+32j
    mov     ecx, [edi+8]
    mov     ebp, [ebx+142A7h]
    sub     ecx, eax
    sar     ecx, 17h
    cmp     ecx, ebp
    jnb     short loc_47E8E1
    mov     esi, ecx
    jmp     short loc_47E8EC
    ; ---------------------------------------------------------------------------

    loc_47E8E1:                             ; CODE XREF: sub_47E890+4Bj
    test    ecx, ecx
    jge     short loc_47E8E9
    xor     esi, esi
    jmp     short loc_47E8EC
    ; ---------------------------------------------------------------------------

    loc_47E8E9:                             ; CODE XREF: sub_47E890+53j
    lea     esi, [ebp-1]

    loc_47E8EC:                             ; CODE XREF: sub_47E890+4Fj
                                            ; sub_47E890+57j
    mov     ecx, [edi]
    add     ecx, eax
    sar     ecx, 17h
    cmp     ecx, edx
    jnb     short loc_47E8FD
    mov     [esp+2Ch+arg_4], ecx
    jmp     short loc_47E910
    ; ---------------------------------------------------------------------------

    loc_47E8FD:                             ; CODE XREF: sub_47E890+65j
    test    ecx, ecx
    jge     short loc_47E90B
    mov     [esp+2Ch+arg_4], 0
    jmp     short loc_47E910
    ; ---------------------------------------------------------------------------

    loc_47E90B:                             ; CODE XREF: sub_47E890+6Fj
    dec     edx
    mov     [esp+2Ch+arg_4], edx

    loc_47E910:                             ; CODE XREF: sub_47E890+6Bj
                                            ; sub_47E890+79j
    mov     ecx, [edi+8]
    add     ecx, eax
    sar     ecx, 17h
    cmp     ecx, ebp
    jnb     short loc_47E922
    mov     [esp+2Ch+var_1C], ecx
    jmp     short loc_47E935
    ; ---------------------------------------------------------------------------

    loc_47E922:                             ; CODE XREF: sub_47E890+8Aj
    test    ecx, ecx
    jge     short loc_47E930
    mov     [esp+2Ch+var_1C], 0
    jmp     short loc_47E935
    ; ---------------------------------------------------------------------------

    loc_47E930:                             ; CODE XREF: sub_47E890+94j
    dec     ebp
    mov     [esp+2Ch+var_1C], ebp

    loc_47E935:                             ; CODE XREF: sub_47E890+90j
                                            ; sub_47E890+9Ej
    cdq
    push    edx
    push    eax
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     [esp+2Ch+var_C], eax
    mov     eax, [esp+2Ch+var_1C]
    mov     edx, esi
    cmp     esi, eax
    mov     [esp+2Ch+var_10], edx
    jg      loc_47EA2F

    loc_47E95F:                             ; CODE XREF: sub_47E890+199j
    mov     ecx, [esp+2Ch+var_18]
    mov     eax, [esp+2Ch+arg_4]
    cmp     ecx, eax
    mov     [esp+2Ch+var_14], ecx
    jg      loc_47EA1E

    loc_47E973:                             ; CODE XREF: sub_47E890+188j
    mov     eax, [ebx+142A3h]
    mov     esi, [ebx+1429Fh]
    imul    eax, edx
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     esi, [esi+eax*2+6]
    test    esi, esi
    jz      short loc_47EA0D
    jmp     short loc_47E995
    ; ---------------------------------------------------------------------------

    loc_47E991:                             ; CODE XREF: sub_47E890+169j
    mov     edi, [esp+2Ch+arg_0]

    loc_47E995:                             ; CODE XREF: sub_47E890+FFj
    mov     eax, [esi+6Ah]
    mov     ebx, [edi]
    mov     ecx, [esi+72h]
    mov     ebp, [edi+8]
    sub     eax, ebx
    sub     ecx, ebp
    cdq
    mov     edi, eax
    mov     ebx, edx
    mov     eax, ecx
    push    ebx
    cdq
    push    edi
    push    ebx
    push    edi
    mov     ebp, eax
    mov     [esp+3Ch+var_4], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edi, eax
    mov     eax, [esp+2Ch+var_4]
    push    eax
    push    ebp
    push    eax
    push    ebp
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     edi, eax
    mov     eax, [esp+2Ch+var_C]
    cmp     edi, eax
    jg      short loc_47E9F1
    mov     ecx, [esp+2Ch+arg_8]
    push    esi
    mov     edx, [ecx]
    call    dword ptr [edx]

    loc_47E9F1:                             ; CODE XREF: sub_47E890+156j
    mov     esi, [esi+8Eh]
    test    esi, esi
    jnz     short loc_47E991
    mov     edx, [esp+2Ch+var_10]
    mov     ecx, [esp+2Ch+var_14]
    mov     edi, [esp+2Ch+arg_0]
    mov     ebx, TAdynmemStructPtr

    loc_47EA0D:                             ; CODE XREF: sub_47E890+FDj
    mov     eax, [esp+2Ch+arg_4]
    inc     ecx
    cmp     ecx, eax
    mov     [esp+2Ch+var_14], ecx
    jle     loc_47E973

    loc_47EA1E:                             ; CODE XREF: sub_47E890+DDj
    mov     eax, [esp+2Ch+var_1C]
    inc     edx
    cmp     edx, eax
    mov     [esp+2Ch+var_10], edx
    jle     loc_47E95F

    loc_47EA2F:                             ; CODE XREF: sub_47E890+C9j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    sub_47E890 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47EA40 proc near                    ; CODE XREF: .text:00405B93p
                                            ; .text:0041564Fp

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_6= word ptr  0Ah
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 18h
    movsx   eax, [esp+18h+arg_6]
    imul    eax, eax
    cdq
    and     edx, 0FFh
    push    ebx
    add     eax, edx
    push    ebp
    sar     eax, 8
    shl     eax, 4
    push    esi
    mov     esi, eax
    push    edi
    xor     ebp, ebp
    push    esi                             ; int
    mov     [esp+2Ch+var_18], ebp
    call    sub_4B4F10
    add     esp, 4
    mov     [esp+28h+var_10], eax
    push    esi                             ; int
    call    sub_4B4F10
    mov     esi, [esp+2Ch+arg_0]
    mov     [esp+2Ch+var_14], eax
    mov     eax, [esp+34h]
    add     esp, 4
    mov     ecx, [esi+8]
    cdq
    sub     eax, edx
    mov     ebx, eax
    mov     eax, ecx
    sar     ebx, 1
    sub     eax, ebx
    add     ecx, ebx
    cmp     eax, ecx
    mov     [esp+28h+var_4], eax
    jg      loc_47EBF8

    loc_47EAA4:                             ; CODE XREF: sub_47EA40+1B2j
    mov     edx, [esi]
    mov     ecx, edx
    add     edx, ebx
    sub     ecx, ebx
    cmp     ecx, edx
    mov     [esp+28h+var_C], ecx
    jg      loc_47EBE0
    mov     edi, [esp+28h+var_18]
    mov     edx, [esp+28h+var_10]
    mov     eax, [esp+28h+var_14]
    mov     esi, ebp
    shl     edi, 4
    shl     esi, 4
    add     edi, edx
    add     esi, eax

    loc_47EAD0:                             ; CODE XREF: sub_47EA40+194j
    lea     eax, [esp+28h+var_C]
    push    eax                             ; int
    call    sub_4815A0
    test    eax, eax
    jz      loc_47EBBD
    push    eax
    call    sub_421E60
    cmp     ax, 0FFFBh
    jnb     loc_47EBBD
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFFFh
    shl     eax, 8
    mov     ecx, eax
    mov     eax, [edx+1426Fh]
    lea     edx, [eax+ecx]
    mov     ax, [eax+ecx+0FEh]
    test    al, 80h
    jz      loc_47EBBD
    test    ah, 1
    jz      loc_47EBBD
    fld     dword ptr [edx+0ECh]
    fcomp   ds:flt_4FD664
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_47EB67
    mov     eax, [esp+28h+var_C]
    mov     edx, esi
    inc     ebp
    add     esi, 10h
    mov     [edx], eax
    mov     eax, [esp+28h+var_8]
    mov     [edx+4], eax
    mov     eax, [esp+28h+var_4]
    mov     [edx+8], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1426Fh]
    mov     edx, [eax+ecx+0ECh]
    mov     [esi-4], edx

    loc_47EB67:                             ; CODE XREF: sub_47EA40+F5j
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+1426Fh]
    fld     dword ptr [edx+ecx+0F0h]
    fcomp   ds:flt_4FD664
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_47EBBD
    mov     edx, [esp+28h+var_C]
    mov     eax, edi
    mov     [eax], edx
    mov     edx, [esp+28h+var_8]
    mov     [eax+4], edx
    mov     edx, [esp+28h+var_4]
    mov     [eax+8], edx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+1426Fh]
    mov     eax, [edx+ecx+0F0h]
    mov     ecx, [esp+28h+var_18]
    inc     ecx
    mov     [edi+0Ch], eax
    mov     [esp+28h+var_18], ecx
    add     edi, 10h

    loc_47EBBD:                             ; CODE XREF: sub_47EA40+9Cj
                                            ; sub_47EA40+ACj ...
    mov     ecx, [esp+28h+arg_0]
    mov     eax, [esp+28h+var_C]
    add     eax, 300000h
    mov     edx, [ecx]
    mov     [esp+28h+var_C], eax
    add     edx, ebx
    cmp     eax, edx
    jle     loc_47EAD0
    mov     eax, [esp+28h+var_4]
    mov     esi, ecx

    loc_47EBE0:                             ; CODE XREF: sub_47EA40+72j
    mov     edi, [esi+8]
    mov     ecx, ebx
    add     eax, 300000h
    add     ecx, edi
    cmp     eax, ecx
    mov     [esp+28h+var_4], eax
    jle     loc_47EAA4

    loc_47EBF8:                             ; CODE XREF: sub_47EA40+5Ej
    xor     esi, esi
    test    ebp, ebp
    jz      short loc_47EC64
    mov     [esp+28h+arg_0], esi
    mov     edi, 3

    loc_47EC07:                             ; CODE XREF: sub_47EA40+1F4j
    push    ebp                             ; int
    call    GetRandom
    mov     ecx, eax
    mov     ebx, [esp+28h+var_14]
    mov     edx, ecx
    fld     [esp+28h+arg_0]
    shl     edx, 4
    fcomp   dword ptr [edx+ebx+0Ch]
    lea     edx, [edx+ebx+0Ch]
    fnstsw  ax
    test    ah, 1
    jz      short loc_47EC33
    mov     eax, [edx]
    mov     esi, ecx
    mov     [esp+28h+arg_0], eax

    loc_47EC33:                             ; CODE XREF: sub_47EA40+1E9j
    dec     edi
    jnz     short loc_47EC07
    mov     edx, [esp+28h+arg_8]
    shl     esi, 4
    mov     edx, [edx]
    lea     eax, [esi+ebx]
    mov     ecx, eax
    mov     esi, [ecx]
    mov     [edx], esi
    mov     esi, [ecx+4]
    mov     [edx+4], esi
    mov     esi, 1
    mov     ecx, [ecx+8]
    mov     [edx+8], ecx
    mov     edx, [eax+0Ch]
    mov     eax, [esp+28h+arg_C]
    mov     [eax], edx
    jmp     short loc_47EC78
    ; ---------------------------------------------------------------------------

    loc_47EC64:                             ; CODE XREF: sub_47EA40+1BCj
    mov     ecx, [esp+28h+arg_8]
    mov     edx, [esp+28h+arg_C]
    mov     dword ptr [ecx], 0
    mov     dword ptr [edx], 0

    loc_47EC78:                             ; CODE XREF: sub_47EA40+222j
    mov     eax, [esp+28h+var_18]
    test    eax, eax
    jz      short loc_47ECF0
    mov     [esp+28h+arg_0], 0
    xor     esi, esi
    mov     edi, 3

    loc_47EC8F:                             ; CODE XREF: sub_47EA40+280j
    mov     eax, [esp+28h+var_18]
    push    eax                             ; int
    call    GetRandom
    mov     ecx, eax
    mov     ebx, [esp+28h+var_10]
    mov     edx, ecx
    fld     [esp+28h+arg_0]
    shl     edx, 4
    fcomp   dword ptr [edx+ebx+0Ch]
    lea     edx, [edx+ebx+0Ch]
    fnstsw  ax
    test    ah, 1
    jz      short loc_47ECBF
    mov     eax, [edx]
    mov     esi, ecx
    mov     [esp+28h+arg_0], eax

    loc_47ECBF:                             ; CODE XREF: sub_47EA40+275j
    dec     edi
    jnz     short loc_47EC8F
    mov     edx, [esp+28h+arg_10]
    shl     esi, 4
    mov     edx, [edx]
    lea     eax, [esi+ebx]
    mov     ecx, eax
    mov     esi, [ecx]
    mov     [edx], esi
    mov     esi, [ecx+4]
    mov     [edx+4], esi
    mov     esi, 1
    mov     ecx, [ecx+8]
    mov     [edx+8], ecx
    mov     edx, [eax+0Ch]
    mov     eax, [esp+28h+arg_14]
    mov     [eax], edx
    jmp     short loc_47ED04
    ; ---------------------------------------------------------------------------

    loc_47ECF0:                             ; CODE XREF: sub_47EA40+23Ej
    mov     ecx, [esp+28h+arg_10]
    mov     edx, [esp+28h+arg_14]
    mov     dword ptr [ecx], 0
    mov     dword ptr [edx], 0

    loc_47ED04:                             ; CODE XREF: sub_47EA40+2AEj
    mov     eax, [esp+28h+var_14]
    push    eax
    call    sub_4B4F20
    mov     ecx, [esp+2Ch+var_10]
    add     esp, 4
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    18h
    sub_47EA40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47ED30 proc near                    ; DATA XREF: .rdata:004FD660o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax
    call    sub_47C790
    retn    4
    sub_47ED30 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47ED40 proc near                    ; CODE XREF: sub_491200+152p
    push    esi
    xor     esi, esi
    push    edi
    push    esi                             ; nDefault
    push    offset aNodirectsound           ; lpKeyName
    call    ReadIniFileValue
    test    eax, eax
    mov     edi, 1
    jz      short loc_47ED5E
    mov     dword_51E690, edi

    loc_47ED5E:                             ; CODE XREF: sub_47ED40+16j
    push    esi                             ; nDefault
    push    offset aUsewindowssoun          ; lpKeyName
    call    ReadIniFileValue
    test    eax, eax
    jz      short loc_47ED73
    mov     dword_51E694, edi

    loc_47ED73:                             ; CODE XREF: sub_47ED40+2Bj
    cmp     dword_51E694, esi
    jz      short loc_47ED90
    call    unknown_libname_47
    test    eax, eax
    jnz     short loc_47ED8A
    mov     dword_51E694, esi

    loc_47ED8A:                             ; CODE XREF: sub_47ED40+42j
    mov     dword_51E690, edi

    loc_47ED90:                             ; CODE XREF: sub_47ED40+39j
    cmp     dword_51E690, esi
    jnz     short loc_47EDDC
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+0Ch]
    mov     edx, [ecx+40h]
    mov     ecx, [eax+10h]
    push    edx
    push    2
    push    10h
    push    2B11h
    call    sub_4CEF90
    cmp     eax, esi
    jnz     short loc_47EDDC
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CFF20
    test    eax, eax
    jz      short loc_47EDD2
    mov     dword_51E690, edi
    jmp     short loc_47EDDC
    ; ---------------------------------------------------------------------------

    loc_47EDD2:                             ; CODE XREF: sub_47ED40+88j
    push    offset aErrorSoundSyst          ; lpText
    call    sub_4B6290

    loc_47EDDC:                             ; CODE XREF: sub_47ED40+56j
                                            ; sub_47ED40+77j ...
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CE260
    push    0A9h                            ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, esi
    jz      short loc_47EE23
    mov     [eax+99h], esi
    mov     [eax+9Dh], esi
    mov     dword ptr [eax+0A1h], 1Eh
    mov     dword ptr [eax+0A5h], 96h
    mov     dword_51E68C, eax
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_47EE23:                             ; CODE XREF: sub_47ED40+B9j
    mov     dword_51E68C, esi
    pop     edi
    pop     esi
    retn
    sub_47ED40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47EE30 proc near                    ; CODE XREF: sub_4917D0+C8p
    push    ebx
    push    ebp
    mov     ebp, dword_51E68C
    push    esi
    push    edi
    mov     eax, [ebp+99h]
    lea     edi, [ebp+99h]
    test    eax, eax
    jle     short loc_47EEB7

    loc_47EE4A:                             ; CODE XREF: sub_47EE30+85j
    mov     esi, [edi]
    mov     ecx, ebp
    dec     esi
    mov     eax, esi
    shl     eax, 4
    add     ecx, eax
    mov     eax, [esi+ecx+0Ch]
    test    eax, eax
    lea     ebx, [esi+ecx]
    jz      short loc_47EE71
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [ebx+0Ch], 0

    loc_47EE71:                             ; CODE XREF: sub_47EE30+2Fj
    mov     eax, [edi]
    mov     ecx, esi
    cmp     esi, eax
    jge     short loc_47EEAC
    lea     edi, [ebp+99h]
    mov     eax, ebx

    loc_47EE81:                             ; CODE XREF: sub_47EE30+7Aj
    lea     edx, [eax+11h]
    mov     esi, eax
    inc     ecx
    add     eax, 11h
    mov     ebx, [edx]
    mov     [esi], ebx
    mov     ebx, [edx+4]
    mov     [esi+4], ebx
    mov     ebx, [edx+8]
    mov     [esi+8], ebx
    mov     ebx, [edx+0Ch]
    mov     [esi+0Ch], ebx
    mov     dl, [edx+10h]
    mov     [esi+10h], dl
    mov     edx, [edi]
    cmp     ecx, edx
    jl      short loc_47EE81

    loc_47EEAC:                             ; CODE XREF: sub_47EE30+47j
    mov     ecx, [edi]
    dec     ecx
    mov     eax, ecx
    mov     [edi], ecx
    test    eax, eax
    jg      short loc_47EE4A

    loc_47EEB7:                             ; CODE XREF: sub_47EE30+18j
    mov     dword ptr [ebp+9Dh], 0
    mov     eax, offset dword_5086EC

    loc_47EEC6:                             ; CODE XREF: sub_47EE30+A4j
    mov     dword ptr [eax], 0
    add     eax, 18h
    cmp     eax, offset aAted               ; "ated"
    jl      short loc_47EEC6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_47EE30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47EEE0 proc near                    ; CODE XREF: sub_4916A0+A7p
    push    ebx
    push    ebp
    mov     ebp, dword_51E68C
    xor     ebx, ebx
    push    esi
    cmp     ebp, ebx
    push    edi
    jz      loc_47EF88
    mov     eax, [ebp+99h]
    lea     edi, [ebp+99h]
    cmp     eax, ebx
    jle     short loc_47EF73

    loc_47EF04:                             ; CODE XREF: sub_47EEE0+8Fj
    mov     esi, [edi]
    mov     ecx, ebp
    dec     esi
    mov     eax, esi
    shl     eax, 4
    add     ecx, eax
    mov     eax, [esi+ecx+0Ch]
    test    eax, eax
    lea     ebx, [esi+ecx]
    jz      short loc_47EF2B
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [ebx+0Ch], 0

    loc_47EF2B:                             ; CODE XREF: sub_47EEE0+39j
    mov     eax, [edi]
    mov     ecx, esi
    cmp     esi, eax
    jge     short loc_47EF66
    lea     edi, [ebp+99h]
    mov     eax, ebx

    loc_47EF3B:                             ; CODE XREF: sub_47EEE0+84j
    lea     edx, [eax+11h]
    mov     esi, eax
    inc     ecx
    add     eax, 11h
    mov     ebx, [edx]
    mov     [esi], ebx
    mov     ebx, [edx+4]
    mov     [esi+4], ebx
    mov     ebx, [edx+8]
    mov     [esi+8], ebx
    mov     ebx, [edx+0Ch]
    mov     [esi+0Ch], ebx
    mov     dl, [edx+10h]
    mov     [esi+10h], dl
    mov     edx, [edi]
    cmp     ecx, edx
    jl      short loc_47EF3B

    loc_47EF66:                             ; CODE XREF: sub_47EEE0+51j
    mov     ecx, [edi]
    dec     ecx
    mov     eax, ecx
    mov     [edi], ecx
    test    eax, eax
    jg      short loc_47EF04
    xor     ebx, ebx

    loc_47EF73:                             ; CODE XREF: sub_47EEE0+22j
    push    ebp
    mov     [ebp+9Dh], ebx
    call    sub_4B4F20
    add     esp, 4
    mov     dword_51E68C, ebx

    loc_47EF88:                             ; CODE XREF: sub_47EEE0+Ej
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4D0130
    mov     ecx, TAdynmemStructPtr
    mov     esi, [ecx+10h]
    cmp     esi, ebx
    jz      short loc_47EFB2
    mov     ecx, esi
    call    sub_4CEEE0
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_47EFB2:                             ; CODE XREF: sub_47EEE0+C0j
    mov     edx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     [edx+10h], ebx
    pop     ebx
    retn
    sub_47EEE0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47EFC0 proc near                    ; CODE XREF: sub_49EE30+5D2p
    mov     dword_51E690, 1
    retn
    sub_47EFC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47EFD0 proc near                    ; CODE XREF: sub_49EE30+62Cp
    mov     eax, 1
    mov     dword_51E694, eax
    mov     dword_51E690, eax
    retn
    sub_47EFD0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47EFE0 proc near                    ; CODE XREF: sub_429470+92p

    var_100= dword ptr -100h
    arg_0= dword ptr  4

    mov     eax, dword_51E690
    sub     esp, 100h
    test    eax, eax
    jz      short loc_47F003
    mov     eax, dword_51E694
    test    eax, eax
    jnz     short loc_47F003
    xor     eax, eax
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47F003:                             ; CODE XREF: sub_47EFE0+Dj
                                            ; sub_47EFE0+16j
    mov     eax, [esp+100h+arg_0]
    push    offset aWav                     ; "WAV"
    push    eax
    lea     ecx, [esp+108h+var_100]
    push    offset aSounds                  ; "sounds"
    push    ecx
    call    sub_4290F0
    mov     eax, dword_51E694
    test    eax, eax
    jz      short loc_47F03D
    lea     edx, [esp+100h+var_100]
    push    0
    push    edx
    call    sub_4BBE50
    add     esp, 100h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47F03D:                             ; CODE XREF: sub_47EFE0+46j
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+100h+var_100]
    push    eax
    mov     ecx, [ecx+10h]
    call    sub_4D0620
    add     esp, 100h
    retn    4
    sub_47EFE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47F060 proc near                    ; CODE XREF: sub_42F8C0+1Fp

    arg_0= dword ptr  4

    mov     eax, dword_51E694
    test    eax, eax
    jz      short loc_47F079
    mov     eax, [esp+arg_0]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47F079:                             ; CODE XREF: sub_47F060+7j
    mov     ecx, [esp+arg_0]
    mov     edx, TAdynmemStructPtr
    push    ecx
    mov     ecx, [edx+10h]
    call    sub_4CF4D0
    retn    4
    sub_47F060 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47F090 proc near                    ; CODE XREF: .text:00476C94p
                                            ; sub_476CA0+24p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, dword_51E690
    test    eax, eax
    jnz     short locret_47F0B5
    mov     eax, [esp+arg_8]
    mov     ecx, [esp+arg_4]
    mov     edx, [esp+arg_0]
    push    eax
    mov     eax, TAdynmemStructPtr
    push    ecx
    push    edx
    mov     ecx, [eax+10h]
    call    sub_4D06C0

    locret_47F0B5:                          ; CODE XREF: sub_47F090+7j
    retn    0Ch
    sub_47F090 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47F0C0 proc near                    ; CODE XREF: Network_Process+18EDp
                                            ; sub_47F1A0+5Ap ...

    idTo= dword ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_0]
    sub     esp, 14h
    cmp     ecx, 0FFFFh
    push    esi
    jz      loc_47F18C
    mov     eax, TAdynmemStructPtr
    mov     edx, dword_51E694
    test    edx, edx
    mov     esi, [eax+ecx*4+33A13h]
    jz      short loc_47F10C
    mov     eax, dword_51E69C
    push    esi                             ; pszSound
    test    eax, eax
    jz      short loc_47F100
    call    sub_49F6A0
    pop     esi
    add     esp, 14h
    retn    8                               ; pszSound
    ; ---------------------------------------------------------------------------

    loc_47F100:                             ; CODE XREF: sub_47F0C0+32j
    call    sub_49F680
    pop     esi
    add     esp, 14h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47F10C:                             ; CODE XREF: sub_47F0C0+28j
    mov     edx, [eax+37F0Ch]
    test    edx, edx
    jz      short loc_47F18C
    test    byte ptr [eax+37F19h], 7
    jz      short loc_47F18C
    mov     edx, dword_51E690
    test    edx, edx
    jnz     short loc_47F18C
    mov     edx, [esp+18h+arg_4]
    test    edx, edx
    jz      short loc_47F156
    lea     eax, [esp+18h+idTo]
    push    12h                             ; idFrom
    push    eax                             ; idTo
    mov     byte ptr [esp+20h+idTo], 13h
    mov     byte ptr [esp+20h+idTo+1], 1
    mov     [esp+20h+idTo+2], ecx
    call    sub_44FDB0
    push    eax                             ; PlayerID
    call    sub_451DF0
    mov     eax, TAdynmemStructPtr

    loc_47F156:                             ; CODE XREF: sub_47F0C0+6Fj
    mov     ecx, dword_51E69C
    test    ecx, ecx
    jz      short loc_47F175
    mov     ecx, [eax+10h]
    push    0FFFFFDB7h
    push    esi
    call    sub_4CF540
    pop     esi
    add     esp, 14h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47F175:                             ; CODE XREF: sub_47F0C0+9Ej
    mov     ecx, [eax+10h]
    push    0
    push    0FFFFFDB7h
    push    esi
    call    sub_4CF570
    pop     esi
    add     esp, 14h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_47F18C:                             ; CODE XREF: sub_47F0C0+Ej
                                            ; sub_47F0C0+54j ...
    xor     eax, eax
    pop     esi
    add     esp, 14h
    retn    8
    sub_47F0C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_47F1A0(char *,int)
    sub_47F1A0 proc near                    ; CODE XREF: sub_419B00+33p
                                            ; sub_419BE0+9Dp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     eax, [ecx+33A0Fh]
    xor     edi, edi
    test    eax, eax
    jle     short loc_47F1EF
    mov     ebx, [esp+0Ch+arg_0]
    xor     esi, esi

    loc_47F1BB:                             ; CODE XREF: sub_47F1A0+4Dj
    mov     dl, [ecx+esi+33E13h]
    lea     eax, [ecx+esi+33E13h]
    test    dl, dl
    jz      short loc_47F1E1
    push    ebx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_47F1F4
    mov     ecx, TAdynmemStructPtr

    loc_47F1E1:                             ; CODE XREF: sub_47F1A0+2Bj
    mov     eax, [ecx+33A0Fh]
    inc     edi
    add     esi, 20h
    cmp     edi, eax
    jl      short loc_47F1BB

    loc_47F1EF:                             ; CODE XREF: sub_47F1A0+13j
    mov     edi, 0FFFFh

    loc_47F1F4:                             ; CODE XREF: sub_47F1A0+39j
    mov     eax, [esp+0Ch+arg_4]
    push    eax
    push    edi
    call    sub_47F0C0
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_47F1A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_47F210(char *,int)
    sub_47F210 proc near                    ; CODE XREF: .text:00426453p
                                            ; sub_45DA90+2CDp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    esi
    mov     dword_51E69C, 1
    mov     eax, [ecx+33A0Fh]
    push    edi
    xor     edi, edi
    test    eax, eax
    jle     short loc_47F269
    mov     ebx, [esp+0Ch+arg_0]
    xor     esi, esi

    loc_47F235:                             ; CODE XREF: sub_47F210+57j
    mov     dl, [ecx+esi+33E13h]
    lea     eax, [ecx+esi+33E13h]
    test    dl, dl
    jz      short loc_47F25B
    push    ebx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_47F26E
    mov     ecx, TAdynmemStructPtr

    loc_47F25B:                             ; CODE XREF: sub_47F210+35j
    mov     eax, [ecx+33A0Fh]
    inc     edi
    add     esi, 20h
    cmp     edi, eax
    jl      short loc_47F235

    loc_47F269:                             ; CODE XREF: sub_47F210+1Dj
    mov     edi, 0FFFFh

    loc_47F26E:                             ; CODE XREF: sub_47F210+43j
    mov     eax, [esp+0Ch+arg_4]
    push    eax
    push    edi
    call    sub_47F0C0
    pop     edi
    pop     esi
    mov     dword_51E69C, 0
    pop     ebx
    retn    8
    sub_47F210 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47F290 proc near                    ; CODE XREF: sub_45DA90+1E4p

    arg_0= dword ptr  4

    mov     eax, dword_51E694
    push    edi
    test    eax, eax
    jz      short loc_47F2A8
    mov     eax, [esp+4+arg_0]
    push    eax
    call    sub_49F6C0
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47F2A8:                             ; CODE XREF: sub_47F290+8j
    mov     edx, [esp+4+arg_0]
    test    edx, edx
    jz      short loc_47F2F4
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_47F2F4
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F0Ch]
    test    ecx, ecx
    jz      short loc_47F2F4
    test    byte ptr [eax+37F19h], 7
    jz      short loc_47F2F4
    mov     ecx, dword_51E690
    test    ecx, ecx
    jnz     short loc_47F2F4
    mov     ecx, [eax+10h]
    push    0
    push    0FFFFFDB7h
    push    edx
    call    sub_4D0640
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_47F2F4:                             ; CODE XREF: sub_47F290+1Ej
                                            ; sub_47F290+2Cj ...
    xor     eax, eax
    pop     edi
    retn    4
    sub_47F290 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47F300 proc near                    ; CODE XREF: Network_Process+18FFp
                                            ; sub_47F610+5Fp ...

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    idTo= dword ptr -14h
    var_E= dword ptr -0Eh
    var_A= dword ptr -0Ah
    var_6= dword ptr -6
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, dword_51E694
    sub     esp, 14h
    test    eax, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      short loc_47F329
    mov     eax, [esp+24h+arg_8]
    mov     ecx, [esp+24h+arg_0]
    push    eax
    push    ecx
    call    sub_47F0C0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_47F329:                             ; CODE XREF: sub_47F300+Ej
    mov     ecx, [esp+24h+arg_0]
    cmp     ecx, 0FFFFh
    jz      loc_47F5FB
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F0Ch]
    test    edx, edx
    jz      loc_47F5FB
    test    byte ptr [eax+37F19h], 7
    jz      loc_47F5FB
    mov     edx, dword_51E690
    test    edx, edx
    jnz     loc_47F5FB
    mov     ebx, [eax+ecx*4+33A13h]
    mov     eax, [esp+24h+arg_8]
    mov     esi, [esp+24h+arg_4]
    mov     [esp+24h+arg_0], ebx
    test    eax, eax
    jz      short loc_47F3B4
    mov     edx, esi
    mov     [esp+24h+idTo+2], ecx
    push    12h                             ; idFrom
    mov     byte ptr [esp+28h+idTo], 13h
    mov     eax, [edx]
    mov     byte ptr [esp+28h+idTo+1], 1
    mov     [esp+28h+var_E], eax
    lea     eax, [esp+28h+idTo]
    mov     ecx, [edx+4]
    push    eax                             ; idTo
    mov     [esp+2Ch+var_A], ecx
    mov     edx, [edx+8]
    mov     [esp+2Ch+var_6], edx
    call    sub_44FDB0
    push    eax                             ; PlayerID
    call    sub_451DF0

    loc_47F3B4:                             ; CODE XREF: sub_47F300+7Cj
    mov     eax, [esi+8]
    cdq
    and     edx, 0FFFFFh
    add     eax, edx
    sar     eax, 14h
    push    eax
    mov     eax, [esi]
    cdq
    and     edx, 0FFFFFh
    add     eax, edx
    sar     eax, 14h
    push    eax
    call    sub_481550
    test    eax, eax
    jz      loc_47F5FB
    mov     ebp, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [ebp+TAdynmemStruct.LOS_Sight]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    lea     eax, [ebp+ecx+0]
    lea     eax, [eax+edx*2+1B63h]
    mov     dl, [ebp+14281h]
    and     dl, 2
    cmp     dl, 2
    jnz     short loc_47F456
    movsx   edi, word ptr [esi+6]
    movsx   ecx, word ptr [esi+0Ah]
    movsx   edx, word ptr [esi+2]
    sar     edi, 1
    sub     ecx, edi
    mov     edi, [eax+80h]
    sar     edx, 5
    sar     ecx, 5
    cmp     edx, edi
    jnb     short loc_47F452
    cmp     ecx, [eax+84h]
    jnb     short loc_47F452
    mov     edi, [eax+80h]
    imul    edi, ecx
    add     edi, [eax+7Ch]
    cmp     byte ptr [edi+edx], 0
    jz      short loc_47F452
    mov     eax, 1
    jmp     short loc_47F4AE
    ; ---------------------------------------------------------------------------

    loc_47F452:                             ; CODE XREF: sub_47F300+12Fj
                                            ; sub_47F300+137j ...
    xor     eax, eax
    jmp     short loc_47F4AE
    ; ---------------------------------------------------------------------------

    loc_47F456:                             ; CODE XREF: sub_47F300+10Fj
    movsx   ebx, word ptr [esi+6]
    movsx   edx, word ptr [esi+0Ah]
    movsx   edi, word ptr [esi+2]
    sar     ebx, 1
    sub     edx, ebx
    mov     ebx, [eax+80h]
    sar     edi, 5
    sar     edx, 5
    cmp     edi, ebx
    jnb     short loc_47F47E
    cmp     edx, [eax+84h]
    jb      short loc_47F482

    loc_47F47E:                             ; CODE XREF: sub_47F300+174j
    xor     eax, eax
    jmp     short loc_47F4AA
    ; ---------------------------------------------------------------------------

    loc_47F482:                             ; CODE XREF: sub_47F300+17Cj
    mov     eax, [eax+80h]
    imul    eax, edx
    mov     edx, [ebp+14273h]
    add     eax, edi
    xor     edi, edi
    mov     di, [edx+eax*2]
    mov     edx, 1
    shl     edx, cl
    mov     eax, edi
    and     eax, edx
    neg     eax
    sbb     eax, eax
    neg     eax

    loc_47F4AA:                             ; CODE XREF: sub_47F300+180j
    mov     ebx, [esp+24h+arg_0]

    loc_47F4AE:                             ; CODE XREF: sub_47F300+150j
                                            ; sub_47F300+154j
    test    eax, eax
    jz      loc_47F5FB
    mov     ecx, [ebp+10h]
    call    sub_4CFEA0
    test    eax, eax
    jz      loc_47F588
    mov     ecx, TAdynmemStructPtr
    push    ecx
    mov     eax, [ecx+1423Bh]
    mov     ebp, [ecx+1431Fh]
    cdq
    sub     eax, edx
    movsx   edx, word ptr [esi+2]
    sar     eax, 1
    neg     eax
    shl     eax, 4
    sub     eax, ebp
    add     eax, edx
    mov     [esp+28h+idTo], eax
    mov     eax, [ecx+1423Fh]
    cdq
    sub     eax, edx
    mov     edx, [ecx+14323h]
    sar     eax, 1
    shl     eax, 4
    add     edx, eax
    mov     dword ptr [esp+18h], 0
    movsx   eax, word ptr [esi+6]
    sar     eax, 1
    add     edx, eax
    movsx   eax, word ptr [esi+0Ah]
    sub     edx, eax
    mov     [esp+28h+var_E+2], edx
    mov     edx, [ecx+14233h]
    mov     esi, [ecx+14237h]
    mov     eax, [ecx+1423Fh]
    mov     edi, [ecx+1423Bh]
    add     edx, esi
    shl     edx, 4
    add     eax, edi
    mov     [esp+28h+arg_0], edx
    fild    [esp+28h+arg_0]
    cdq
    fstp    [esp+28h+var_28]
    sub     eax, edx
    push    ecx
    sar     eax, 1
    mov     ecx, [ecx+10h]
    shl     eax, 4
    mov     [esp+2Ch+arg_0], eax
    fild    [esp+2Ch+arg_0]
    fstp    [esp+2Ch+var_2C]
    call    sub_4CFEB0
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+24h+idTo]
    push    eax
    push    0FFFFFDB7h
    mov     ecx, [ecx+10h]
    push    ebx
    call    sub_4CF570
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_47F588:                             ; CODE XREF: sub_47F300+1C0j
    mov     eax, TAdynmemStructPtr
    movsx   edi, word ptr [esi+2]
    mov     ebp, [eax+1431Fh]
    cmp     ebp, edi
    jg      short loc_47F5E1
    movsx   ecx, word ptr [esi+0Ah]
    mov     edx, [eax+14323h]
    cmp     edx, ecx
    jg      short loc_47F5E1
    mov     esi, [eax+1423Bh]
    shl     esi, 4
    add     esi, ebp
    cmp     esi, edi
    jl      short loc_47F5E1
    mov     esi, [eax+1423Fh]
    shl     esi, 4
    add     esi, edx
    cmp     esi, ecx
    jl      short loc_47F5E1
    mov     ecx, [eax+10h]
    push    0
    push    0FFFFFDB7h
    push    ebx
    call    sub_4CF570
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_47F5E1:                             ; CODE XREF: sub_47F300+299j
                                            ; sub_47F300+2A7j ...
    mov     ecx, [eax+10h]
    push    0
    push    0FFFFF9CFh
    push    ebx
    call    sub_4CF570
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_47F5FB:                             ; CODE XREF: sub_47F300+33j
                                            ; sub_47F300+46j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 14h
    retn    0Ch
    sub_47F300 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_47F610(char *,int,int)
    sub_47F610 proc near                    ; CODE XREF: sub_4233A0+16Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     eax, [ecx+33A0Fh]
    xor     edi, edi
    test    eax, eax
    jle     short loc_47F65F
    mov     ebx, [esp+0Ch+arg_0]
    xor     esi, esi

    loc_47F62B:                             ; CODE XREF: sub_47F610+4Dj
    mov     dl, [ecx+esi+33E13h]
    lea     eax, [ecx+esi+33E13h]
    test    dl, dl
    jz      short loc_47F651
    push    ebx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_47F664
    mov     ecx, TAdynmemStructPtr

    loc_47F651:                             ; CODE XREF: sub_47F610+2Bj
    mov     eax, [ecx+33A0Fh]
    inc     edi
    add     esi, 20h
    cmp     edi, eax
    jl      short loc_47F62B

    loc_47F65F:                             ; CODE XREF: sub_47F610+13j
    mov     edi, 0FFFFh

    loc_47F664:                             ; CODE XREF: sub_47F610+39j
    mov     eax, [esp+0Ch+arg_8]
    mov     ecx, [esp+0Ch+arg_4]
    push    eax
    push    ecx
    push    edi
    call    sub_47F300
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_47F610 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47F680 proc near                    ; CODE XREF: sub_499890+116p
    mov     ecx, dword_51E68C
    push    ebx
    push    esi
    mov     eax, [ecx+99h]
    lea     esi, [ecx+99h]
    test    eax, eax
    push    edi
    mov     ebx, ecx
    jz      loc_47F732
    mov     eax, [ecx+0A1h]
    mov     edx, [ecx+9Dh]
    lea     edi, [ecx+9Dh]
    add     eax, edx
    mov     edx, TAdynmemStructPtr
    push    1
    cmp     [edx+38A47h], eax
    jb      short loc_47F6DB
    push    1
    push    0
    call    sub_47FD70
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    mov     [edi], ecx
    jmp     short loc_47F6E4
    ; ---------------------------------------------------------------------------

    loc_47F6DB:                             ; CODE XREF: sub_47F680+41j
    push    0
    push    0
    call    sub_47FD70

    loc_47F6E4:                             ; CODE XREF: sub_47F680+59j
    mov     eax, [ebx+0Ch]
    test    eax, eax
    jz      short loc_47F6FB
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [ebx+0Ch], 0

    loc_47F6FB:                             ; CODE XREF: sub_47F680+69j
    mov     eax, [esi]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_47F730
    mov     eax, ebx

    loc_47F705:                             ; CODE XREF: sub_47F680+AEj
    lea     edx, [eax+11h]
    mov     edi, eax
    inc     ecx
    add     eax, 11h
    mov     ebx, [edx]
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     ebx, [edx+8]
    mov     [edi+8], ebx
    mov     ebx, [edx+0Ch]
    mov     [edi+0Ch], ebx
    mov     dl, [edx+10h]
    mov     [edi+10h], dl
    mov     edx, [esi]
    cmp     ecx, edx
    jl      short loc_47F705

    loc_47F730:                             ; CODE XREF: sub_47F680+81j
    dec     dword ptr [esi]

    loc_47F732:                             ; CODE XREF: sub_47F680+19j
    mov     eax, dword_51E694
    test    eax, eax
    jz      short loc_47F740
    call    sub_49F620

    loc_47F740:                             ; CODE XREF: sub_47F680+B9j
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_47F680 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47F750 proc near                    ; CODE XREF: .text:00426786p
                                            ; sub_45DA90+283p ...
    mov     eax, dword_51E690
    test    eax, eax
    jnz     short loc_47F766
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CF150

    loc_47F766:                             ; CODE XREF: sub_47F750+7j
    mov     eax, dword_51E694
    test    eax, eax
    jz      short locret_47F774
    jmp     loc_49F640
    ; ---------------------------------------------------------------------------

    locret_47F774:                          ; CODE XREF: sub_47F750+1Dj
    retn
    sub_47F750 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47F780 proc near                    ; CODE XREF: .text:004020AFp
                                            ; .text:004020EDp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, TAdynmemStructPtr
    push    edi
    mov     edi, [esp+4+arg_0]
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    mov     al, [edi+0FFh]
    cmp     al, dl
    jnz     short loc_47F7D9
    mov     eax, [edi+110h]
    test    eax, 10000000h
    jz      short loc_47F7D9
    test    ah, 40h
    jnz     short loc_47F7D9
    mov     eax, [esp+4+arg_8]
    push    esi
    mov     esi, [esp+8+arg_4]
    test    eax, eax
    jnz     short loc_47F7C4
    lea     edx, [esi+esi*2]
    mov     eax, dword_5086E8[edx*8]

    loc_47F7C4:                             ; CODE XREF: sub_47F780+38j
    push    eax                             ; int
    call    sub_4C5740
    mov     ecx, dword_51E68C
    push    eax
    push    esi
    push    edi
    call    sub_47FAD0
    pop     esi

    loc_47F7D9:                             ; CODE XREF: sub_47F780+19j
                                            ; sub_47F780+26j ...
    pop     edi
    retn    0Ch
    sub_47F780 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_47F7E0(int,int,int)
    sub_47F7E0 proc near

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    edi
    mov     edi, [esp+arg_0]
    push    edi                             ; int
    call    sub_48BCB0
    test    eax, eax
    jz      short loc_47F842
    mov     edx, TAdynmemStructPtr
    mov     cl, [edi+0FFh]
    mov     eax, [esp+arg_8]
    cmp     cl, [edx+TAdynmemStruct.LOS_Sight]
    jnz     short loc_47F842
    mov     ecx, [edi+110h]
    test    ecx, 10000000h
    jz      short loc_47F842
    test    ch, 40h
    jnz     short loc_47F842
    push    esi
    mov     esi, [esp+4+arg_4]
    test    eax, eax
    jnz     short loc_47F82D
    lea     eax, [esi+esi*2]
    mov     eax, dword_5086E8[eax*8]

    loc_47F82D:                             ; CODE XREF: sub_47F7E0+41j
    push    eax                             ; int
    call    sub_4C5740
    mov     ecx, dword_51E68C
    push    eax
    push    esi
    push    edi
    call    sub_47FAD0
    pop     esi

    loc_47F842:                             ; CODE XREF: sub_47F7E0+Dj
                                            ; sub_47F7E0+25j ...
    pop     edi
    retn    0Ch
    sub_47F7E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_47F850(UnitStruct *Unit,int,int)
    sub_47F850 proc near                    ; CODE XREF: sub_406F80+258p

    Unit= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    edi
    mov     edi, [esp+Unit]
    push    edi                             ; int
    call    sub_48BCB0
    test    eax, eax
    jnz     short loc_47F8B2
    mov     edx, TAdynmemStructPtr
    mov     cl, [edi+0FFh]
    mov     eax, [esp+arg_8]
    cmp     cl, [edx+TAdynmemStruct.LOS_Sight]
    jnz     short loc_47F8B2
    mov     ecx, dword ptr [edi+UnitStruct.UnitSelected]
    test    ecx, 10000000h
    jz      short loc_47F8B2
    test    ch, 40h
    jnz     short loc_47F8B2
    push    esi
    mov     esi, [esp+4+arg_4]
    test    eax, eax
    jnz     short loc_47F89D
    lea     eax, [esi+esi*2]
    mov     eax, dword_5086E8[eax*8]

    loc_47F89D:                             ; CODE XREF: sub_47F850+41j
    push    eax                             ; int
    call    sub_4C5740
    mov     ecx, dword_51E68C
    push    eax
    push    esi
    push    edi
    call    sub_47FAD0
    pop     esi

    loc_47F8B2:                             ; CODE XREF: sub_47F850+Dj
                                            ; sub_47F850+25j ...
    pop     edi
    retn    0Ch
    sub_47F850 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47F8C0 proc near                    ; CODE XREF: sub_4866D0+D7p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    esi
    push    edi
    mov     edi, dword_51E68C
    xor     ebx, ebx
    mov     eax, [edi+99h]
    lea     esi, [edi+99h]
    test    eax, eax
    mov     [esp+10h+var_4], ebx
    jle     short loc_47F94F
    push    ebp
    add     edi, 0Ch

    loc_47F8E4:                             ; CODE XREF: sub_47F8C0+8Cj
    mov     eax, [edi-4]
    mov     ecx, [esp+14h+arg_0]
    cmp     eax, ecx
    jnz     short loc_47F942
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_47F904
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [edi], 0

    loc_47F904:                             ; CODE XREF: sub_47F8C0+33j
    mov     eax, [esi]
    mov     ecx, ebx
    cmp     ebx, eax
    jge     short loc_47F93E
    lea     eax, [edi-0Ch]

    loc_47F90F:                             ; CODE XREF: sub_47F8C0+78j
    lea     edx, [eax+11h]
    mov     ebx, eax
    inc     ecx
    add     eax, 11h
    mov     ebp, [edx]
    mov     [ebx], ebp
    mov     ebp, [edx+4]
    mov     [ebx+4], ebp
    mov     ebp, [edx+8]
    mov     [ebx+8], ebp
    mov     ebp, [edx+0Ch]
    mov     [ebx+0Ch], ebp
    mov     dl, [edx+10h]
    mov     [ebx+10h], dl
    mov     edx, [esi]
    cmp     ecx, edx
    jl      short loc_47F90F
    mov     ebx, [esp+14h+var_4]

    loc_47F93E:                             ; CODE XREF: sub_47F8C0+4Aj
    dec     dword ptr [esi]
    jmp     short loc_47F94A
    ; ---------------------------------------------------------------------------

    loc_47F942:                             ; CODE XREF: sub_47F8C0+2Dj
    inc     ebx
    add     edi, 11h
    mov     [esp+14h+var_4], ebx

    loc_47F94A:                             ; CODE XREF: sub_47F8C0+80j
    cmp     ebx, [esi]
    jl      short loc_47F8E4
    pop     ebp

    loc_47F94F:                             ; CODE XREF: sub_47F8C0+1Ej
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    sub_47F8C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+8]
    mov     eax, ecx
    xor     ecx, ecx
    mov     [eax+99h], ecx
    mov     [eax+9Dh], ecx
    mov     ecx, [esp+4]
    mov     [eax+0A5h], edx
    mov     [eax+0A1h], ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebp
    push    edi
    mov     edi, ecx
    xor     ebp, ebp
    cmp     [edi+99h], ebp
    jle     short loc_47FA19
    push    esi
    push    ebx

    loc_47F9A0:                             ; CODE XREF: .text:0047FA15j
    mov     esi, [edi+99h]
    mov     ecx, edi
    dec     esi
    mov     eax, esi
    shl     eax, 4
    add     ecx, eax
    mov     eax, [esi+ecx+0Ch]
    cmp     eax, ebp
    lea     ebx, [esi+ecx]
    jz      short loc_47F9C7
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     [ebx+0Ch], ebp

    loc_47F9C7:                             ; CODE XREF: .text:0047F9B9j
    mov     eax, [edi+99h]
    mov     ecx, esi
    cmp     esi, eax
    jge     short loc_47FA04
    mov     eax, ebx

    loc_47F9D5:                             ; CODE XREF: .text:0047FA02j
    lea     edx, [eax+11h]
    mov     esi, eax
    inc     ecx
    add     eax, 11h
    mov     ebx, [edx]
    mov     [esi], ebx
    mov     ebx, [edx+4]
    mov     [esi+4], ebx
    mov     ebx, [edx+8]
    mov     [esi+8], ebx
    mov     ebx, [edx+0Ch]
    mov     [esi+0Ch], ebx
    mov     dl, [edx+10h]
    mov     [esi+10h], dl
    mov     edx, [edi+99h]
    cmp     ecx, edx
    jl      short loc_47F9D5

    loc_47FA04:                             ; CODE XREF: .text:0047F9D1j
    mov     ecx, [edi+99h]
    dec     ecx
    mov     eax, ecx
    mov     [edi+99h], ecx
    cmp     eax, ebp
    jg      short loc_47F9A0
    pop     ebx
    pop     esi

    loc_47FA19:                             ; CODE XREF: .text:0047F99Cj
    mov     [edi+9Dh], ebp
    pop     edi
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebp
    push    edi
    mov     edi, ecx
    xor     ebp, ebp
    cmp     [edi+99h], ebp
    jle     short loc_47FAB9
    push    esi
    push    ebx

    loc_47FA40:                             ; CODE XREF: .text:0047FAB5j
    mov     esi, [edi+99h]
    mov     ecx, edi
    dec     esi
    mov     eax, esi
    shl     eax, 4
    add     ecx, eax
    mov     eax, [esi+ecx+0Ch]
    cmp     eax, ebp
    lea     ebx, [esi+ecx]
    jz      short loc_47FA67
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     [ebx+0Ch], ebp

    loc_47FA67:                             ; CODE XREF: .text:0047FA59j
    mov     eax, [edi+99h]
    mov     ecx, esi
    cmp     esi, eax
    jge     short loc_47FAA4
    mov     eax, ebx

    loc_47FA75:                             ; CODE XREF: .text:0047FAA2j
    lea     edx, [eax+11h]
    mov     esi, eax
    inc     ecx
    add     eax, 11h
    mov     ebx, [edx]
    mov     [esi], ebx
    mov     ebx, [edx+4]
    mov     [esi+4], ebx
    mov     ebx, [edx+8]
    mov     [esi+8], ebx
    mov     ebx, [edx+0Ch]
    mov     [esi+0Ch], ebx
    mov     dl, [edx+10h]
    mov     [esi+10h], dl
    mov     edx, [edi+99h]
    cmp     ecx, edx
    jl      short loc_47FA75

    loc_47FAA4:                             ; CODE XREF: .text:0047FA71j
    mov     ecx, [edi+99h]
    dec     ecx
    mov     eax, ecx
    mov     [edi+99h], ecx
    cmp     eax, ebp
    jg      short loc_47FA40
    pop     ebx
    pop     esi

    loc_47FAB9:                             ; CODE XREF: .text:0047FA3Cj
    mov     [edi+9Dh], ebp
    pop     edi
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47FAD0 proc near                    ; CODE XREF: sub_47F780+53p
                                            ; sub_47F7E0+5Cp ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+8+arg_4]
    push    ebp
    push    esi
    push    edi
    lea     edi, [ebx+ebx*2]
    mov     ebp, ecx
    mov     ecx, [eax+TAdynmemStruct.GameTime]
    shl     edi, 3
    mov     [esp+14h+var_4], edi
    cmp     ecx, dword_5086EC[edi]
    jb      loc_47FC8C
    mov     edx, [ebp+99h]
    xor     eax, eax
    test    edx, edx
    jle     short loc_47FB1A
    mov     ecx, ebp

    loc_47FB0A:                             ; CODE XREF: sub_47FAD0+48j
    cmp     [ecx], ebx
    jz      loc_47FC8C
    inc     eax
    add     ecx, 11h
    cmp     eax, edx
    jl      short loc_47FB0A

    loc_47FB1A:                             ; CODE XREF: sub_47FAD0+36j
    cmp     edx, 8
    jnz     short loc_47FB94
    push    1
    push    0
    push    7
    mov     ecx, ebp
    call    sub_47FD70
    mov     eax, [ebp+83h]
    test    eax, eax
    jz      short loc_47FB49
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [ebp+83h], 0

    loc_47FB49:                             ; CODE XREF: sub_47FAD0+64j
    mov     eax, [ebp+99h]
    mov     ecx, 7
    cmp     eax, ecx
    jle     short loc_47FB8E
    lea     eax, [ebp+77h]

    loc_47FB5B:                             ; CODE XREF: sub_47FAD0+B8j
    lea     edx, [eax+11h]
    mov     esi, eax
    inc     ecx
    add     eax, 11h
    mov     edi, [edx]
    mov     [esi], edi
    mov     edi, [edx+4]
    mov     [esi+4], edi
    mov     edi, [edx+8]
    mov     [esi+8], edi
    mov     edi, [edx+0Ch]
    mov     [esi+0Ch], edi
    mov     dl, [edx+10h]
    mov     [esi+10h], dl
    mov     edx, [ebp+99h]
    cmp     ecx, edx
    jl      short loc_47FB5B
    mov     edi, [esp+14h+var_4]

    loc_47FB8E:                             ; CODE XREF: sub_47FAD0+86j
    dec     dword ptr [ebp+99h]

    loc_47FB94:                             ; CODE XREF: sub_47FAD0+4Dj
    mov     edx, [ebp+99h]
    test    edx, edx
    jz      short loc_47FC09
    xor     ecx, ecx
    test    edx, edx
    jle     short loc_47FBC6
    mov     edi, dword_5086DC[edi]
    mov     esi, ebp

    loc_47FBAC:                             ; CODE XREF: sub_47FAD0+F0j
    mov     eax, [esi]
    lea     eax, [eax+eax*2]
    cmp     dword_5086DC[eax*8], edi
    jl      short loc_47FBC2
    inc     ecx
    add     esi, 11h
    cmp     ecx, edx
    jl      short loc_47FBAC

    loc_47FBC2:                             ; CODE XREF: sub_47FAD0+E8j
    mov     edi, [esp+14h+var_4]

    loc_47FBC6:                             ; CODE XREF: sub_47FAD0+D2j
    cmp     edx, ecx
    jle     short loc_47FC0B
    mov     eax, edx
    mov     esi, ebp
    shl     eax, 4
    add     esi, eax
    mov     eax, edx
    add     eax, esi
    sub     edx, ecx

    loc_47FBD9:                             ; CODE XREF: sub_47FAD0+12Dj
    lea     esi, [eax-11h]
    dec     edx
    mov     edi, esi
    mov     ebx, [edi]
    mov     [eax], ebx
    mov     ebx, [edi+4]
    mov     [eax+4], ebx
    mov     ebx, [edi+8]
    mov     [eax+8], ebx
    mov     ebx, [edi+0Ch]
    mov     [eax+0Ch], ebx
    mov     bl, [edi+10h]
    mov     [eax+10h], bl
    mov     eax, esi
    jnz     short loc_47FBD9
    mov     ebx, [esp+14h+arg_4]
    mov     edi, [esp+14h+var_4]
    jmp     short loc_47FC0B
    ; ---------------------------------------------------------------------------

    loc_47FC09:                             ; CODE XREF: sub_47FAD0+CCj
    xor     ecx, ecx

    loc_47FC0B:                             ; CODE XREF: sub_47FAD0+F8j
                                            ; sub_47FAD0+137j
    mov     edx, ecx
    mov     eax, ebp
    shl     edx, 4
    add     eax, edx
    lea     esi, [ecx+eax]
    mov     eax, [esp+14h+arg_0]
    mov     [esi], ebx
    mov     ecx, TAdynmemStructPtr
    mov     ebx, [esp+14h+arg_8]
    mov     edx, [ecx+38A47h]
    mov     [esi+4], edx
    mov     [esi+8], eax
    mov     cl, byte ptr dword_5086DC[edi]
    test    ebx, ebx
    mov     [esi+10h], cl
    jz      short loc_47FC7F
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    push    ecx
    push    offset aSpeechText              ; "Speech Text"
    call    sub_4D83B0
    mov     edx, eax
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    mov     [esi+0Ch], edx
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_47FC86
    ; ---------------------------------------------------------------------------

    loc_47FC7F:                             ; CODE XREF: sub_47FAD0+16Ej
    mov     dword ptr [esi+0Ch], 0

    loc_47FC86:                             ; CODE XREF: sub_47FAD0+1ADj
    inc     dword ptr [ebp+99h]

    loc_47FC8C:                             ; CODE XREF: sub_47FAD0+26j
                                            ; sub_47FAD0+3Cj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    sub_47FAD0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, ecx
    mov     eax, [esi+99h]
    test    eax, eax
    jz      loc_47FD60
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esi+0A1h]
    push    edi
    mov     edi, [esi+9Dh]
    mov     edx, [ecx+38A47h]
    add     eax, edi
    push    ebx
    cmp     edx, eax
    push    1
    jb      short loc_47FCF2
    push    1
    push    0
    mov     ecx, esi
    call    sub_47FD70
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+38A47h]
    mov     [esi+9Dh], eax
    jmp     short loc_47FCFD
    ; ---------------------------------------------------------------------------

    loc_47FCF2:                             ; CODE XREF: .text:0047FCD1j
    push    0
    push    0
    mov     ecx, esi
    call    sub_47FD70

    loc_47FCFD:                             ; CODE XREF: .text:0047FCF0j
    mov     eax, [esi+0Ch]
    test    eax, eax
    jz      short loc_47FD14
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+0Ch], 0

    loc_47FD14:                             ; CODE XREF: .text:0047FD02j
    mov     eax, [esi+99h]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_47FD51
    mov     eax, esi

    loc_47FD22:                             ; CODE XREF: .text:0047FD4Fj
    lea     edx, [eax+11h]
    mov     edi, eax
    inc     ecx
    add     eax, 11h
    mov     ebx, [edx]
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     ebx, [edx+8]
    mov     [edi+8], ebx
    mov     ebx, [edx+0Ch]
    mov     [edi+0Ch], ebx
    mov     dl, [edx+10h]
    mov     [edi+10h], dl
    mov     edx, [esi+99h]
    cmp     ecx, edx
    jl      short loc_47FD22

    loc_47FD51:                             ; CODE XREF: .text:0047FD1Ej
    mov     eax, [esi+99h]
    pop     ebx
    dec     eax
    pop     edi
    mov     [esi+99h], eax

    loc_47FD60:                             ; CODE XREF: .text:0047FCABj
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_47FD70 proc near                    ; CODE XREF: sub_47F680+47p
                                            ; sub_47F680+5Fp ...

    var_16C= dword ptr -16Ch
    var_168= dword ptr -168h
    var_164= byte ptr -164h
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 16Ch
    mov     eax, [esp+16Ch+arg_0]
    push    ebx
    mov     edx, eax
    push    ebp
    shl     edx, 4
    add     ecx, edx
    push    esi
    push    edi
    lea     esi, [eax+ecx]
    mov     eax, [eax+ecx+8]
    mov     ebp, [esi]
    mov     ecx, [eax+92h]
    xor     eax, eax
    mov     ax, [ecx+20Eh]
    mov     ecx, TAdynmemStructPtr
    mov     ebx, [ecx+37E13h]
    lea     edx, [eax+eax*4]
    lea     eax, [eax+edx*2]
    lea     edx, [ebp+ebp*2+0]
    shl     eax, 5
    add     ebx, eax
    mov     edi, [ebx+edx*4+40h]
    lea     eax, [ebx+edx*4]
    mov     [esp+17Ch+var_168], eax
    call    _rand
    imul    edi
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, TAdynmemStructPtr
    mov     [esp+17Ch+var_16C], eax
    xor     eax, eax
    mov     edx, 0Ah
    mov     al, [ecx+37F17h]
    sub     edx, eax
    xor     eax, eax
    mov     al, [esi+10h]
    cmp     eax, edx
    jle     loc_47FF03
    test    edi, edi
    jle     loc_47FF03
    mov     eax, [esp+17Ch+arg_4]
    test    eax, eax
    jz      loc_47FF03
    test    byte ptr [ecx+37F19h], 40h
    jz      loc_47FF03
    mov     eax, dword_51E698
    test    eax, eax
    jz      short loc_47FE4F
    mov     eax, 88888889h
    mul     dword ptr [ecx+38A47h]
    shr     edx, 4
    test    dl, 7
    jz      short loc_47FE48
    mov     eax, offset aSing               ; "sing"
    jmp     short loc_47FE5D
    ; ---------------------------------------------------------------------------

    loc_47FE48:                             ; CODE XREF: sub_47FD70+CFj
    mov     eax, offset aHonk               ; "honk"
    jmp     short loc_47FE5D
    ; ---------------------------------------------------------------------------

    loc_47FE4F:                             ; CODE XREF: sub_47FD70+BCj
    mov     ecx, [esp+17Ch+var_168]
    mov     eax, [esp+17Ch+var_16C]
    shl     eax, 6
    add     eax, [ecx+44h]

    loc_47FE5D:                             ; CODE XREF: sub_47FD70+D6j
                                            ; sub_47FD70+DDj
    push    offset aWav                     ; "WAV"
    push    eax
    lea     edx, [esp+184h+var_100]
    push    offset aSounds                  ; "sounds"
    push    edx
    call    sub_4290F0
    mov     eax, dword_51E694
    test    eax, eax
    jz      short loc_47FE8A
    lea     eax, [esp+17Ch+var_100]
    push    eax
    call    sub_49F6C0
    jmp     short loc_47FEDB
    ; ---------------------------------------------------------------------------

    loc_47FE8A:                             ; CODE XREF: sub_47FD70+10Cj
    lea     ecx, [esp+17Ch+var_100]
    test    ecx, ecx
    jz      short loc_47FEDB
    lea     edi, [esp+17Ch+var_100]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_47FEDB
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+37F0Ch]
    test    eax, eax
    jz      short loc_47FEE1
    test    byte ptr [ecx+37F19h], 7
    jz      short loc_47FEE1
    mov     eax, dword_51E690
    test    eax, eax
    jnz     short loc_47FEE1
    mov     ecx, [ecx+10h]
    push    0
    lea     edx, [esp+180h+var_100]
    push    0FFFFFDB7h
    push    edx
    call    sub_4D0640

    loc_47FEDB:                             ; CODE XREF: sub_47FD70+118j
                                            ; sub_47FD70+120j ...
    mov     ecx, TAdynmemStructPtr

    loc_47FEE1:                             ; CODE XREF: sub_47FD70+140j
                                            ; sub_47FD70+149j ...
    lea     eax, [ebp+ebp*2+0]
    mov     edi, [ecx+38A47h]
    shl     eax, 3
    mov     edx, dword_5086E0[eax]
    lea     edx, [edx+edx*2]
    lea     edx, [edx+edx*4]
    lea     edx, [edi+edx*2]
    mov     dword_5086EC[eax], edx

    loc_47FF03:                             ; CODE XREF: sub_47FD70+8Bj
                                            ; sub_47FD70+93j ...
    mov     eax, [esp+17Ch+arg_8]
    mov     edi, [esp+17Ch+var_16C]
    test    eax, eax
    jz      short loc_47FF90
    xor     eax, eax
    xor     edx, edx
    mov     al, [ecx+37F18h]
    mov     dl, [esi+10h]
    mov     ecx, 0Ah
    sub     ecx, eax
    cmp     edx, ecx
    jle     short loc_47FF90
    mov     ecx, [esi+0Ch]
    test    ecx, ecx
    jnz     short loc_47FF49
    cmp     edi, 0FFFFFFFFh
    jz      short loc_47FF45
    add     ebp, 6
    shl     edi, 6
    lea     eax, [ebp+ebp*2+0]
    mov     ecx, [ebx+eax*4]
    add     ecx, edi

    loc_47FF45:                             ; CODE XREF: sub_47FD70+1C4j
    test    ecx, ecx
    jz      short loc_47FF90

    loc_47FF49:                             ; CODE XREF: sub_47FD70+1BFj
    cmp     byte ptr [ecx], 0
    jz      short loc_47FF90
    mov     eax, [esi+8]
    test    dword ptr [eax+110h], 10000000h
    jz      short loc_47FF90
    push    ecx
    mov     ecx, [eax+92h]
    push    ecx
    lea     edx, [esp+184h+var_164]
    push    offset aSS_1                    ; "%s: %s"
    push    edx
    call    _sprintf
    mov     eax, [esi+8]
    add     esp, 10h
    lea     edx, [esp+17Ch+var_164]
    mov     cx, [eax+0A8h]
    push    0Ah                             ; char
    push    ecx                             ; __int16
    push    1                               ; char
    push    edx                             ; char *
    call    sub_463CA0

    loc_47FF90:                             ; CODE XREF: sub_47FD70+1A0j
                                            ; sub_47FD70+1B8j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 16Ch
    retn    0Ch
    sub_47FD70 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+10h]
    mov     eax, edi
    mov     esi, ecx
    shl     eax, 4
    add     ecx, eax
    mov     eax, [edi+ecx+0Ch]
    test    eax, eax
    lea     ebx, [edi+ecx]
    jz      short loc_47FFCB
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [ebx+0Ch], 0

    loc_47FFCB:                             ; CODE XREF: .text:0047FFB9j
    mov     eax, [esi+99h]
    mov     ecx, edi
    cmp     edi, eax
    jge     short loc_480008
    mov     eax, ebx

    loc_47FFD9:                             ; CODE XREF: .text:00480006j
    lea     edx, [eax+11h]
    mov     edi, eax
    inc     ecx
    add     eax, 11h
    mov     ebx, [edx]
    mov     [edi], ebx
    mov     ebx, [edx+4]
    mov     [edi+4], ebx
    mov     ebx, [edx+8]
    mov     [edi+8], ebx
    mov     ebx, [edx+0Ch]
    mov     [edi+0Ch], ebx
    mov     dl, [edx+10h]
    mov     [edi+10h], dl
    mov     edx, [esi+99h]
    cmp     ecx, edx
    jl      short loc_47FFD9

    loc_480008:                             ; CODE XREF: .text:0047FFD5j
    mov     eax, [esi+99h]
    pop     edi
    dec     eax
    mov     [esi+99h], eax
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    push    ecx
    push    ebx
    push    esi
    mov     esi, ecx
    xor     ebx, ebx
    mov     [esp+8], ebx
    mov     eax, [esi+99h]
    test    eax, eax
    jle     loc_4800BA
    push    edi
    push    ebp
    lea     edi, [esi+0Ch]

    loc_48003E:                             ; CODE XREF: .text:004800B6j
    mov     eax, [edi-4]
    mov     ecx, [esp+18h]
    cmp     eax, ecx
    jnz     short loc_4800A8
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_48005E
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [edi], 0

    loc_48005E:                             ; CODE XREF: .text:0048004Dj
    mov     eax, [esi+99h]
    mov     ecx, ebx
    cmp     ebx, eax
    jge     short loc_4800A0
    lea     eax, [edi-0Ch]

    loc_48006D:                             ; CODE XREF: .text:0048009Aj
    lea     edx, [eax+11h]
    mov     ebx, eax
    inc     ecx
    add     eax, 11h
    mov     ebp, [edx]
    mov     [ebx], ebp
    mov     ebp, [edx+4]
    mov     [ebx+4], ebp
    mov     ebp, [edx+8]
    mov     [ebx+8], ebp
    mov     ebp, [edx+0Ch]
    mov     [ebx+0Ch], ebp
    mov     dl, [edx+10h]
    mov     [ebx+10h], dl
    mov     edx, [esi+99h]
    cmp     ecx, edx
    jl      short loc_48006D
    mov     ebx, [esp+10h]

    loc_4800A0:                             ; CODE XREF: .text:00480068j
    dec     dword ptr [esi+99h]
    jmp     short loc_4800B0
    ; ---------------------------------------------------------------------------

    loc_4800A8:                             ; CODE XREF: .text:00480047j
    inc     ebx
    add     edi, 11h
    mov     [esp+10h], ebx

    loc_4800B0:                             ; CODE XREF: .text:004800A6j
    cmp     ebx, [esi+99h]
    jl      short loc_48003E
    pop     ebp
    pop     edi

    loc_4800BA:                             ; CODE XREF: .text:00480033j
    pop     esi
    pop     ebx
    pop     ecx
    retn    4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4800C0 proc near                    ; CODE XREF: sub_40B7B0+102p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, [ecx+8]
    push    edi
    sub     esi, 4
    mov     edx, [esi]
    mov     [eax], edx
    mov     edi, [ecx+8]
    lea     edx, [esi+4]
    cmp     edx, edi
    jz      short loc_4800EA
    push    ebx
    sub     esi, edx

    loc_4800DD:                             ; CODE XREF: sub_4800C0+27j
    mov     ebx, [edx]
    mov     [edx+esi], ebx
    add     edx, 4
    cmp     edx, edi
    jnz     short loc_4800DD
    pop     ebx

    loc_4800EA:                             ; CODE XREF: sub_4800C0+18j
    mov     edx, [ecx+8]
    pop     edi
    add     edx, 0FFFFFFFCh
    pop     esi
    mov     [esp+arg_0], edx
    mov     [ecx+8], edx
    retn    4
    sub_4800C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480100 proc near                    ; CODE XREF: sub_48D220+CBp

    arg_0= dword ptr  4

    mov     edx, [ecx+8]
    mov     eax, [ecx+4]
    push    esi
    cmp     eax, edx
    push    edi
    jz      short loc_48011F
    mov     esi, [esp+8+arg_0]

    loc_480110:                             ; CODE XREF: sub_480100+19j
    cmp     [eax], esi
    jz      short loc_48011B
    add     eax, 4
    cmp     eax, edx
    jnz     short loc_480110

    loc_48011B:                             ; CODE XREF: sub_480100+12j
    cmp     eax, edx
    jnz     short loc_480126

    loc_48011F:                             ; CODE XREF: sub_480100+Aj
    xor     eax, eax
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_480126:                             ; CODE XREF: sub_480100+1Dj
    lea     esi, [edx-4]
    mov     edx, [edx-4]
    mov     [eax], edx
    mov     edx, [ecx+8]
    lea     eax, [esi+4]
    cmp     eax, edx
    jz      short loc_480146
    sub     esi, eax

    loc_48013A:                             ; CODE XREF: sub_480100+44j
    mov     edi, [eax]
    mov     [eax+esi], edi
    add     eax, 4
    cmp     eax, edx
    jnz     short loc_48013A

    loc_480146:                             ; CODE XREF: sub_480100+36j
    mov     eax, [ecx+8]
    pop     edi
    add     eax, 0FFFFFFFCh
    pop     esi
    mov     [esp+arg_0], eax
    mov     [ecx+8], eax
    mov     eax, 1
    retn    4
    sub_480100 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, [esp+8]
    mov     eax, ecx
    mov     ecx, [esp+4]
    mov     [eax], ecx
    mov     [eax+4], edx
    mov     dl, [esp+4]
    xor     ecx, ecx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ecx
    mov     [eax+10h], dl
    mov     [eax+14h], ecx
    mov     [eax+18h], ecx
    mov     [eax+1Ch], ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480190 proc near                    ; CODE XREF: sub_464700+198p

    arg_0= dword ptr  8

    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    push    edi
    push    140h
    push    offset aSquads                  ; "SQUADS"
    call    sub_4D83B0
    mov     dl, byte ptr [esp+10h+arg_0]
    add     esp, 8
    xor     esi, esi
    xor     edi, edi
    mov     [ebp+78h], eax
    xor     ecx, ecx

    loc_4801B6:                             ; CODE XREF: sub_480190+4Ej
    mov     eax, [ebp+78h]
    add     eax, ecx
    jz      short loc_4801D4
    mov     [eax], ebp
    mov     [eax+4], edi
    mov     [eax+8], esi
    mov     [eax+0Ch], esi
    mov     [eax+10h], dl
    mov     [eax+14h], esi
    mov     [eax+18h], esi
    mov     [eax+1Ch], esi

    loc_4801D4:                             ; CODE XREF: sub_480190+2Bj
    add     ecx, 20h
    inc     edi
    cmp     ecx, 140h
    jl      short loc_4801B6
    pop     edi
    pop     esi
    pop     ebp
    retn    4
    sub_480190 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4801F0 proc near                    ; CODE XREF: sub_464A00+3Cp

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    xor     ebx, ebx
    cmp     [ebp+78h], ebx
    jz      short loc_48023E
    push    edi
    push    esi
    xor     edi, edi

    loc_480201:                             ; CODE XREF: sub_4801F0+3Bj
    mov     eax, [ebp+78h]
    lea     esi, [eax+edi+10h]
    mov     eax, [eax+edi+14h]
    push    eax
    mov     [esp+0Ch+arg_0], eax
    call    sub_4B4F20
    add     edi, 20h
    add     esp, 4
    cmp     edi, 140h
    mov     [esi+4], ebx
    mov     [esi+8], ebx
    mov     [esi+0Ch], ebx
    jl      short loc_480201
    mov     ecx, [ebp+78h]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [ebp+78h], ebx
    pop     esi
    pop     edi

    loc_48023E:                             ; CODE XREF: sub_4801F0+Bj
    pop     ebp
    pop     ebx
    retn    4
    sub_4801F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480250 proc near                    ; CODE XREF: sub_407560+74p
                                            ; sub_407560+179p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     edx, [esp+4+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [edx+0ACh]
    push    edi
    cmp     eax, 0FFFFFFFFh
    mov     ebp, 4
    jz      short loc_4802C2
    mov     ecx, [edx+96h]
    shl     eax, 5
    mov     ecx, [ecx+78h]
    lea     esi, [ecx+eax+10h]
    mov     ecx, [ecx+eax+18h]
    mov     eax, [esi+4]
    cmp     eax, ecx
    jz      short loc_4802C2

    loc_480284:                             ; CODE XREF: sub_480250+3Cj
    cmp     [eax], edx
    jz      short loc_48028E
    add     eax, ebp
    cmp     eax, ecx
    jnz     short loc_480284

    loc_48028E:                             ; CODE XREF: sub_480250+36j
    cmp     eax, ecx
    jz      short loc_4802C2
    lea     edx, [ecx-4]
    mov     ecx, [ecx-4]
    mov     [eax], ecx
    mov     ecx, [esi+8]
    lea     eax, [edx+4]
    cmp     eax, ecx
    jz      short loc_4802B1
    sub     edx, eax

    loc_4802A6:                             ; CODE XREF: sub_480250+5Fj
    mov     edi, [eax]
    mov     [eax+edx], edi
    add     eax, ebp
    cmp     eax, ecx
    jnz     short loc_4802A6

    loc_4802B1:                             ; CODE XREF: sub_480250+52j
    mov     eax, [esi+8]
    add     eax, 0FFFFFFFCh
    mov     [esi+8], eax
    mov     edx, [esp+14h+arg_0]
    mov     [esp+14h+var_4], eax

    loc_4802C2:                             ; CODE XREF: sub_480250+17j
                                            ; sub_480250+32j ...
    mov     ebx, [esp+14h+arg_4]
    cmp     ebx, 0FFFFFFFFh
    jz      loc_48044A
    mov     edx, [edx+96h]
    mov     eax, ebx
    shl     eax, 5
    mov     ecx, [edx+78h]
    mov     edx, [ecx+eax+1Ch]
    lea     esi, [ecx+eax+10h]
    mov     eax, [ecx+eax+18h]
    sub     edx, eax
    mov     edi, eax
    sar     edx, 2
    cmp     edx, 1
    jnb     loc_4803B7
    mov     ecx, [esi+4]
    test    ecx, ecx
    jnz     short loc_480304
    xor     eax, eax
    jmp     short loc_480309
    ; ---------------------------------------------------------------------------

    loc_480304:                             ; CODE XREF: sub_480250+AEj
    sub     eax, ecx
    sar     eax, 2

    loc_480309:                             ; CODE XREF: sub_480250+B2j
    cmp     eax, 1
    jbe     short loc_480319
    mov     ecx, esi
    call    sub_40C560
    mov     ebx, eax
    jmp     short loc_48031E
    ; ---------------------------------------------------------------------------

    loc_480319:                             ; CODE XREF: sub_480250+BCj
    mov     ebx, 1

    loc_48031E:                             ; CODE XREF: sub_480250+C7j
    mov     ecx, esi
    call    sub_40C560
    add     eax, ebx
    mov     [esp+14h+var_4], eax
    jns     short loc_48032F
    xor     eax, eax

    loc_48032F:                             ; CODE XREF: sub_480250+DBj
    shl     eax, 2
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esi+4]
    add     esp, 4
    mov     ebx, eax
    push    ebx
    push    edi
    push    ecx
    mov     ecx, esi
    call    sub_406C10
    lea     edx, [esp+14h+arg_0]
    mov     ebp, eax
    push    edx
    push    1
    push    ebp
    mov     ecx, esi
    call    sub_406C40
    mov     eax, [esi+8]
    add     ebp, 4
    push    ebp
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     ecx, [esi+8]
    mov     edx, [esi+4]
    push    ecx
    push    edx
    mov     ecx, esi
    call    nullsub_1
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+18h+var_4]
    add     esp, 4
    lea     ecx, [ebx+eax*4]
    mov     [esi+0Ch], ecx
    mov     ecx, esi
    call    sub_40C560
    lea     edx, [ebx+eax*4+4]
    mov     [esi+4], ebx
    mov     ebx, [esp+14h+arg_4]
    mov     [esi+8], edx
    mov     edx, [esp+14h+arg_0]
    mov     [edx+0ACh], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4803B7:                             ; CODE XREF: sub_480250+A3j
    mov     ecx, eax
    sub     ecx, edi
    sar     ecx, 2
    cmp     ecx, 1
    jnb     short loc_480406
    lea     edx, [edi+4]
    mov     ecx, esi
    push    edx
    push    eax
    push    edi
    call    sub_406C10
    mov     eax, [esi+8]
    lea     ecx, [esp+14h+arg_0]
    mov     edx, eax
    push    ecx
    sub     edx, edi
    mov     ecx, 1
    sar     edx, 2
    sub     ecx, edx
    push    ecx
    push    eax
    mov     ecx, esi
    call    sub_406C40
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_48043E

    loc_4803F8:                             ; CODE XREF: sub_480250+1B2j
    mov     edx, [esp+14h+arg_0]
    mov     [eax], edx
    add     eax, ebp
    cmp     eax, ecx
    jnz     short loc_4803F8
    jmp     short loc_48043E
    ; ---------------------------------------------------------------------------

    loc_480406:                             ; CODE XREF: sub_480250+171j
    push    eax
    push    eax
    add     eax, 0FFFFFFFCh
    mov     ecx, esi
    push    eax
    call    sub_406C10
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_480429

    loc_48041D:                             ; CODE XREF: sub_480250+1D7j
    sub     eax, ebp
    sub     ecx, ebp
    cmp     eax, edi
    mov     edx, [eax]
    mov     [ecx], edx
    jnz     short loc_48041D

    loc_480429:                             ; CODE XREF: sub_480250+1CBj
    lea     ecx, [edi+4]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_48043E

    loc_480432:                             ; CODE XREF: sub_480250+1ECj
    mov     edx, [esp+14h+arg_0]
    mov     [eax], edx
    add     eax, ebp
    cmp     eax, ecx
    jnz     short loc_480432

    loc_48043E:                             ; CODE XREF: sub_480250+1A6j
                                            ; sub_480250+1B4j ...
    mov     eax, [esi+8]
    add     eax, ebp
    mov     [esi+8], eax
    mov     edx, [esp+14h+arg_0]

    loc_48044A:                             ; CODE XREF: sub_480250+79j
    pop     edi
    pop     esi
    mov     [edx+0ACh], ebx
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_480250 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480460 proc near                    ; CODE XREF: sub_4077E0+E8p
                                            ; sub_4077E0+13Fp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, [eax+67h]
    mov     ecx, [eax+6Bh]
    cmp     esi, ecx
    ja      short loc_4804D4
    push    edi
    mov     edi, [esp+8+arg_14]
    push    ebp
    mov     ebp, [esp+0Ch+arg_1C]
    push    ebx
    mov     ebx, [esp+10h+arg_10]

    loc_48047E:                             ; CODE XREF: sub_480460+6Fj
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_4804C4
    mov     ecx, [esp+10h+arg_4]
    mov     edx, [esi+0ACh]
    cmp     edx, ecx
    jnz     short loc_4804C4
    mov     edx, [esp+10h+arg_8]
    push    edi
    push    ebx
    push    esi
    lea     eax, [esp+1Ch+arg_1C]
    push    edx
    push    eax
    call    sub_43F0E0
    push    ebp
    mov     ecx, [esp+14h+arg_18]
    mov     edx, [esp+14h+arg_C]
    mov     eax, [esp+14h+arg_1C]
    push    ecx
    push    edi
    push    ebx
    push    esi
    push    edx
    push    eax
    call    sub_43ADC0
    mov     eax, [esp+10h+arg_0]

    loc_4804C4:                             ; CODE XREF: sub_480460+26j
                                            ; sub_480460+34j
    mov     ecx, [eax+6Bh]
    add     esi, 118h
    cmp     esi, ecx
    jbe     short loc_48047E
    pop     ebx
    pop     ebp
    pop     edi

    loc_4804D4:                             ; CODE XREF: sub_480460+Dj
    pop     esi
    retn    20h
    sub_480460 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     ecx, [esp+8]
    cmp     eax, ecx
    jge     short loc_4804F9
    add     eax, [esp+0Ch]
    cmp     eax, ecx
    jl      short locret_480505
    mov     eax, ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4804F9:                             ; CODE XREF: .text:004804EAj
    jle     short locret_480505
    sub     eax, [esp+0Ch]
    cmp     eax, ecx
    jg      short locret_480505
    mov     eax, ecx

    locret_480505:                          ; CODE XREF: .text:004804F2j
                                            ; .text:004804F9j ...
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+8]
    mov     ax, [esp+4]
    mov     edx, [esp+0Ch]
    cmp     cx, ax
    jge     short loc_480527
    sub     ax, dx
    jmp     short loc_48052F
    ; ---------------------------------------------------------------------------

    loc_480527:                             ; CODE XREF: .text:00480520j
    cmp     cx, ax
    jle     short loc_480534
    add     ax, dx

    loc_48052F:                             ; CODE XREF: .text:00480525j
    mov     [esp+4], ax

    loc_480534:                             ; CODE XREF: .text:0048052Aj
    mov     cx, [esp+0Ah]
    mov     ax, [esp+6]
    cmp     cx, ax
    jge     short loc_480552
    sub     ax, dx
    mov     [esp+6], ax
    mov     eax, [esp+4]
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_480552:                             ; CODE XREF: .text:00480541j
    jle     short loc_48055C
    add     ax, dx
    mov     [esp+6], ax

    loc_48055C:                             ; CODE XREF: .text:00480552j
    mov     eax, [esp+4]
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    movsx   ecx, word ptr [esp+8]
    movsx   eax, word ptr [esp+4]
    movsx   edx, word ptr [esp+0Ah]
    push    esi
    sub     eax, ecx
    movsx   esi, word ptr [esp+0Ah]
    sub     esi, edx
    cdq
    mov     ecx, eax
    mov     eax, esi
    xor     ecx, edx
    sub     ecx, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     ecx, eax
    jle     short loc_48059D
    mov     eax, ecx

    loc_48059D:                             ; CODE XREF: .text:00480599j
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 0Ch
    mov     eax, [esp+10h]
    push    ebx
    push    ebp
    push    esi
    movsx   ebx, word ptr [esp+20h]
    push    edi
    mov     edi, [eax]
    mov     eax, edi
    movsx   ebp, word ptr [esp+26h]
    mov     [esp+10h], eax
    movsx   esi, word ptr [esp+12h]
    movsx   eax, ax
    sub     eax, ebx
    sub     esi, ebp
    cdq
    mov     ecx, eax
    mov     eax, esi
    xor     ecx, edx
    sub     ecx, edx
    cdq
    xor     eax, edx
    mov     [esp+10h], ecx
    sub     eax, edx
    cmp     ecx, eax
    jg      short loc_4805F3
    mov     [esp+10h], eax

    loc_4805F3:                             ; CODE XREF: .text:004805EDj
    movsx   ecx, word ptr [esp+28h]
    movsx   edx, word ptr [esp+2Ah]
    mov     [esp+14h], edi
    mov     [esp+18h], edx
    movsx   eax, di
    movsx   edi, word ptr [esp+16h]
    sub     eax, ecx
    sub     edi, edx
    cdq
    mov     esi, eax
    mov     eax, edi
    xor     esi, edx
    sub     esi, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     esi, eax
    jg      short loc_480625
    mov     esi, eax

    loc_480625:                             ; CODE XREF: .text:00480621j
    mov     edx, [esp+18h]
    sub     ebx, ecx
    mov     eax, ebx
    sub     ebp, edx
    cdq
    mov     edi, eax
    mov     eax, ebp
    xor     edi, edx
    sub     edi, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     edi, eax
    jle     short loc_480643
    mov     eax, edi

    loc_480643:                             ; CODE XREF: .text:0048063Fj
    mov     ecx, [esp+10h]
    cmp     ecx, esi
    jle     short loc_4806C2
    cmp     ecx, eax
    jle     short loc_480655
    mov     [esp+10h], eax
    mov     ecx, eax

    loc_480655:                             ; CODE XREF: .text:0048064Dj
    mov     eax, [esp+24h]
    mov     edx, [esp+28h]
    cmp     dx, ax
    mov     [esp+24h], eax
    jge     short loc_48066F
    sub     eax, ecx
    mov     [esp+24h], ax
    jmp     short loc_480679
    ; ---------------------------------------------------------------------------

    loc_48066F:                             ; CODE XREF: .text:00480664j
    jle     short loc_480679
    lea     edx, [ecx+eax]
    mov     [esp+24h], dx

    loc_480679:                             ; CODE XREF: .text:0048066Dj
                                            ; .text:0048066Fj
    mov     ax, [esp+26h]
    mov     dx, [esp+2Ah]
    cmp     dx, ax
    jge     short loc_4806A4
    sub     ax, cx
    mov     [esp+26h], ax
    mov     eax, [esp+20h]
    mov     ecx, [esp+24h]
    mov     [eax], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4806A4:                             ; CODE XREF: .text:00480686j
    jle     short loc_4806AE
    add     ax, cx
    mov     [esp+26h], ax

    loc_4806AE:                             ; CODE XREF: .text:004806A4j
    mov     eax, [esp+20h]
    mov     ecx, [esp+24h]
    mov     [eax], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4806C2:                             ; CODE XREF: .text:00480649j
    cmp     esi, eax
    jle     short loc_4806C8
    mov     esi, eax

    loc_4806C8:                             ; CODE XREF: .text:004806C4j
    mov     eax, [esp+28h]
    mov     ecx, [esp+24h]
    cmp     cx, ax
    mov     [esp+28h], eax
    jge     short loc_4806E2
    sub     eax, esi
    mov     [esp+28h], ax
    jmp     short loc_4806EC
    ; ---------------------------------------------------------------------------

    loc_4806E2:                             ; CODE XREF: .text:004806D7j
    jle     short loc_4806EC
    lea     edx, [esi+eax]
    mov     [esp+28h], dx

    loc_4806EC:                             ; CODE XREF: .text:004806E0j
                                            ; .text:004806E2j
    mov     ax, [esp+2Ah]
    mov     cx, [esp+26h]
    cmp     cx, ax
    jge     short loc_480700
    sub     ax, si
    jmp     short loc_480705
    ; ---------------------------------------------------------------------------

    loc_480700:                             ; CODE XREF: .text:004806F9j
    jle     short loc_48070A
    add     ax, si

    loc_480705:                             ; CODE XREF: .text:004806FEj
    mov     [esp+2Ah], ax

    loc_48070A:                             ; CODE XREF: .text:00480700j
    mov     eax, [esp+20h]
    mov     ecx, [esp+28h]
    pop     edi
    pop     esi
    pop     ebp
    mov     [eax], ecx
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    movsx   ecx, word ptr [esp+8]
    movsx   eax, word ptr [esp+4]
    movsx   edx, word ptr [esp+6]
    sub     ecx, eax
    movsx   eax, word ptr [esp+0Ah]
    sub     eax, edx
    test    ecx, ecx
    jle     short loc_48074E
    test    eax, eax
    jle     short loc_480745
    mov     al, 5
    retn    8
    ; ---------------------------------------------------------------------------

    loc_480745:                             ; CODE XREF: .text:0048073Ej
    setl    al
    add     eax, 6
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48074E:                             ; CODE XREF: .text:0048073Aj
    jge     short loc_480760
    test    eax, eax
    jle     short loc_480759
    mov     al, 3
    retn    8
    ; ---------------------------------------------------------------------------

    loc_480759:                             ; CODE XREF: .text:00480752j
    setnl   al
    inc     eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_480760:                             ; CODE XREF: .text:0048074Ej
    test    eax, eax
    jle     short loc_480769
    mov     al, 4
    retn    8
    ; ---------------------------------------------------------------------------

    loc_480769:                             ; CODE XREF: .text:00480762j
    xor     al, al
    retn    8
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480770 proc near                    ; DATA XREF: .rdata:004FD6DCo

    var_38= qword ptr -38h
    var_30= qword ptr -30h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [ecx+540h]
    mov     ecx, [esp+arg_0]
    sub     esp, 24h
    push    esi
    mov     esi, [eax+0Ch]
    lea     eax, [ecx-1]                    ; switch 20 cases
    cmp     eax, 13h
    ja      loc_480ABB                      ; default
    jmp     ds:off_480AC4[eax*4]            ; switch jump

    loc_480794:                             ; DATA XREF: .text:00480AC4o
    mov     al, [esi+10Eh]                  ; case 0x1
    and     eax, 1
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4807A4:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     eax, [esi+110h]                 ; case 0x2
    shr     eax, 12h
    and     eax, 3
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4807B7:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     eax, [esi+110h]                 ; case 0x3
    shr     eax, 14h
    and     eax, 3
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4807CA:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    movsx   eax, word ptr [esi+108h]        ; case 0x4
    mov     ecx, [esi+92h]
    xor     edx, edx
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 2
    div     dword ptr [ecx+1FAh]
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4807EF:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     al, [esi+10Fh]                  ; case 0x5
    and     eax, 1
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4807FF:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     al, [esi+10Fh]                  ; case 0x6
    shr     eax, 1
    and     eax, 1
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480811:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     edx, [esp+28h+arg_4]            ; case 0x7
    lea     eax, [esp+28h+var_18]
    push    edx
    push    esi
    push    eax
    call    sub_43E060
    mov     ecx, [eax]
    and     ecx, 0FFFF0000h
    mov     edx, [eax+4]
    mov     [esp+28h+var_20], edx
    mov     eax, [eax+8]
    sar     eax, 10h
    add     eax, ecx
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_48083F:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     eax, [esp+28h+arg_4]            ; case 0x8
    lea     ecx, [esp+28h+var_C]
    push    eax
    push    esi
    push    ecx
    call    sub_43E060
    mov     edx, eax
    mov     eax, [edx]
    mov     [esp+28h+var_24], eax
    mov     eax, [edx+4]
    mov     ecx, [edx+8]
    mov     [esp+28h+var_1C], ecx
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480868:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     eax, [esp+28h+arg_4]            ; case 0x9
    test    ax, ax
    jnz     short loc_480875
    xor     ecx, ecx
    jmp     short loc_480892
    ; ---------------------------------------------------------------------------

    loc_480875:                             ; CODE XREF: sub_480770+FFj
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14357h]
    lea     ecx, [ecx+edx*8]

    loc_480892:                             ; CODE XREF: sub_480770+103j
    test    ecx, ecx
    jz      loc_480ABB                      ; default
    test    dword ptr [ecx+110h], 10000000h
    jz      loc_480ABB                      ; default
    mov     eax, [ecx+72h]
    mov     edx, [ecx+6Ah]
    sar     eax, 10h
    and     edx, 0FFFF0000h
    add     eax, edx
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4808C2:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     eax, [esp+28h+arg_4]            ; case 0xa
    test    ax, ax
    jnz     short loc_4808CF
    xor     eax, eax
    jmp     short loc_4808ED
    ; ---------------------------------------------------------------------------

    loc_4808CF:                             ; CODE XREF: sub_480770+159j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [edx+eax*8]

    loc_4808ED:                             ; CODE XREF: sub_480770+15Dj
    test    eax, eax
    jz      loc_480ABB                      ; default
    test    dword ptr [eax+110h], 10000000h
    jz      loc_480ABB                      ; default
    mov     eax, [eax+6Eh]
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_48090F:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     eax, [esp+28h+arg_4]            ; case 0xb
    test    ax, ax
    jnz     short loc_48091C
    xor     eax, eax
    jmp     short loc_48093A
    ; ---------------------------------------------------------------------------

    loc_48091C:                             ; CODE XREF: sub_480770+1A6j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [edx+eax*8]

    loc_48093A:                             ; CODE XREF: sub_480770+1AAj
    test    eax, eax
    jz      loc_480ABB                      ; default
    test    dword ptr [eax+110h], 10000000h
    jz      loc_480ABB                      ; default
    mov     eax, [eax+92h]
    mov     eax, [eax+16Eh]
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480965:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     ecx, [esp+28h+arg_4]            ; case 0xc
    mov     eax, ecx
    and     eax, 0FFFF0000h
    shl     ecx, 10h
    jns     short loc_48097A
    add     eax, 10000h

    loc_48097A:                             ; CODE XREF: sub_480770+203j
    push    ecx
    push    eax
    call    sub_4B715A
    sub     ax, [esi+66h]
    add     esp, 8
    and     eax, 0FFFFh
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480994:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     eax, [esp+28h+arg_4]            ; case 0xd
    mov     ecx, eax
    and     ecx, 0FFFF0000h
    shl     eax, 10h
    mov     [esp+28h+arg_4], ecx
    mov     [esp+28h+arg_8], eax
    jns     short loc_4809B7
    add     ecx, 10000h
    mov     [esp+28h+arg_4], ecx

    loc_4809B7:                             ; CODE XREF: sub_480770+23Bj
    fild    [esp+28h+arg_8]
    sub     esp, 8
    fstp    [esp+30h+var_30]
    fild    [esp+30h+arg_4]
    jmp     short loc_4809F3
    ; ---------------------------------------------------------------------------

    loc_4809C7:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     ecx, [esp+28h+arg_8]            ; case 0xe
    mov     edx, [esp+28h+arg_4]
    push    ecx
    push    edx
    call    sub_4B715A
    add     esp, 8
    and     eax, 0FFFFh
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4809E5:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    fild    [esp+28h+arg_8]                 ; case 0xf
    sub     esp, 8
    fstp    [esp+30h+var_30]
    fild    [esp+30h+arg_4]

    loc_4809F3:                             ; CODE XREF: sub_480770+255j
    sub     esp, 8
    fstp    [esp+38h+var_38]
    call    __hypot
    add     esp, 10h
    call    __ftol
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480A0D:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     eax, [esp+28h+arg_4]            ; case 0x10
    mov     ecx, eax
    and     ecx, 0FFFF0000h
    shl     eax, 10h
    mov     [esp+28h+var_24], ecx
    mov     [esp+28h+var_1C], eax
    jns     short loc_480A30
    add     ecx, 10000h
    mov     [esp+28h+var_24], ecx

    loc_480A30:                             ; CODE XREF: sub_480770+2B4j
    lea     eax, [esp+28h+var_24]
    push    eax
    call    sub_485070
    shl     eax, 10h
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480A44:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    fld     dword ptr [esi+104h]            ; case 0x11
    fcomp   ds:flt_4FD668
    fnstsw  ax
    test    ah, 40h
    jz      short loc_480A62
    xor     ecx, ecx
    mov     eax, ecx
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480A62:                             ; CODE XREF: sub_480770+2E5j
    fld     dword ptr [esi+104h]
    fmul    ds:flt_4FD66C
    call    __ftol
    mov     ecx, 1
    sub     ecx, eax
    mov     eax, ecx
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480A83:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     al, [esi+10Fh]                  ; case 0x12
    shr     eax, 2
    and     eax, 1
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480A96:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     al, [esi+10Fh]                  ; case 0x13
    shr     eax, 3
    and     eax, 1
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480AA9:                             ; CODE XREF: sub_480770+1Dj
                                            ; DATA XREF: .text:00480AC4o
    mov     al, [esi+10Eh]                  ; case 0x14
    shr     eax, 1
    and     eax, 1
    pop     esi
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_480ABB:                             ; CODE XREF: sub_480770+17j
                                            ; sub_480770+124j ...
    xor     eax, eax                        ; default
    pop     esi
    add     esp, 24h
    retn    14h
    sub_480770 endp

    ; ---------------------------------------------------------------------------
    off_480AC4 dd offset loc_480794         ; DATA XREF: sub_480770+1Dr
    dd offset loc_4807A4                    ; jump table for switch statement
    dd offset loc_4807B7
    dd offset loc_4807CA
    dd offset loc_4807EF
    dd offset loc_4807FF
    dd offset loc_480811
    dd offset loc_48083F
    dd offset loc_480868
    dd offset loc_4808C2
    dd offset loc_48090F
    dd offset loc_480965
    dd offset loc_480994
    dd offset loc_4809C7
    dd offset loc_4809E5
    dd offset loc_480A0D
    dd offset loc_480A44
    dd offset loc_480A83
    dd offset loc_480A96
    dd offset loc_480AA9
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480B20 proc near                    ; DATA XREF: .rdata:004FD6D8o

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [ecx+540h]
    mov     ecx, [esp+arg_0]
    push    esi
    mov     esi, [eax+0Ch]
    lea     eax, [ecx-1]
    cmp     eax, 13h
    ja      loc_480BF1
    xor     edx, edx
    mov     dl, ds:byte_480C18[eax]
    jmp     ds:off_480BFC[edx*4]

    loc_480B49:                             ; DATA XREF: .text:00480BFCo
    mov     eax, [esp+4+arg_4]
    mov     ecx, esi
    push    eax                             ; int
    push    1                               ; idTo
    call    sub_48B090
    or      byte ptr [esi+0BAh], 4
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_480B62:                             ; CODE XREF: sub_480B20+22j
                                            ; DATA XREF: .text:00480C00o
    mov     al, [esi+10Fh]
    mov     cl, byte ptr [esp+4+arg_4]
    xor     cl, al
    and     cl, 1
    xor     cl, al
    or      byte ptr [esi+0BAh], 4
    mov     [esi+10Fh], cl
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_480B84:                             ; CODE XREF: sub_480B20+22j
                                            ; DATA XREF: .text:00480C04o
    mov     dl, byte ptr [esp+4+arg_4]
    mov     al, [esi+10Fh]
    and     dl, 1
    and     al, 0FDh
    shl     dl, 1
    or      dl, al
    or      byte ptr [esi+0BAh], 4
    mov     [esi+10Fh], dl
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_480BA8:                             ; CODE XREF: sub_480B20+22j
                                            ; DATA XREF: .text:00480C08o
    mov     ecx, [esp+4+arg_4]
    push    ecx
    push    esi
    call    sub_47DAC0
    or      byte ptr [esi+0BAh], 4
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_480BBE:                             ; CODE XREF: sub_480B20+22j
                                            ; DATA XREF: .text:00480C0Co
    mov     dl, byte ptr [esp+4+arg_4]
    mov     al, [esi+10Fh]
    and     dl, 1
    and     al, 0F7h
    shl     dl, 3
    or      dl, al
    or      byte ptr [esi+0BAh], 4
    mov     [esi+10Fh], dl
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_480BE3:                             ; CODE XREF: sub_480B20+22j
                                            ; DATA XREF: .text:00480C10o
    mov     ecx, [esp+4+arg_4]
    push    ecx                             ; int
    push    2                               ; idTo
    mov     ecx, esi
    call    sub_48B090

    loc_480BF1:                             ; CODE XREF: sub_480B20+14j
                                            ; sub_480B20+22j
                                            ; DATA XREF: ...
    or      byte ptr [esi+0BAh], 4
    pop     esi
    retn    8
    sub_480B20 endp

    ; ---------------------------------------------------------------------------
    off_480BFC dd offset loc_480B49         ; DATA XREF: sub_480B20+22r
    dd offset loc_480B62
    dd offset loc_480B84
    dd offset loc_480BA8
    dd offset loc_480BBE
    dd offset loc_480BE3
    dd offset loc_480BF1
    byte_480C18 db 0                        ; DATA XREF: sub_480B20+1Cr
    ; ---------------------------------------------------------------------------
    push    es
    push    es
    push    es
    add     [edx], eax
    push    es
    push    es
    push    es
    push    es
    push    es
    push    es
    push    es
    push    es
    push    es
    push    es
    push    es
    add     eax, ds:90909090h[eax]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480C30 proc near                    ; DATA XREF: .rdata:004FD6ACo

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [ecx+540h]
    lea     eax, [eax+eax*2]
    lea     edx, [eax+eax*8]
    lea     eax, [ecx+edx*2+22h]
    mov     ecx, [esp+arg_4]
    mov     eax, [eax+ecx*4+4]
    retn    8
    sub_480C30 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480C50 proc near                    ; DATA XREF: .rdata:004FD698o

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+540h]
    push    esi
    mov     esi, [esp+4+arg_4]
    lea     eax, [eax+eax*2]
    push    edi
    lea     edx, [edx+esi*4]
    mov     esi, [esp+8+arg_8]
    lea     eax, [eax+eax*8]
    shl     eax, 1
    mov     edi, [edx+eax+26h]
    lea     edx, [edx+eax+26h]
    cmp     edi, esi
    jz      short loc_480CAA
    mov     [edx], esi
    mov     esi, [ecx+540h]
    xor     edx, edx
    mov     [esi+eax+48h], dx
    mov     esi, [ecx+540h]
    mov     dword ptr [esi+8], 1
    mov     ecx, [ecx+540h]
    mov     al, [ecx+eax+4Ah]
    shr     al, 1
    test    al, 1
    jz      short loc_480CAA
    mov     [ecx+4], edx

    loc_480CAA:                             ; CODE XREF: sub_480C50+29j
                                            ; sub_480C50+55j
    pop     edi
    pop     esi
    retn    0Ch
    sub_480C50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480CB0 proc near                    ; DATA XREF: .rdata:004FD6B0o

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     edx, [esp+arg_4]
    mov     ecx, [ecx+540h]
    lea     eax, [eax+eax*2]
    lea     edx, [edx+eax*8]
    add     eax, edx
    xor     edx, edx
    mov     dx, [ecx+eax*2+32h]
    mov     eax, edx
    retn    8
    sub_480CB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480CE0 proc near                    ; DATA XREF: .rdata:004FD69Co

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_4]
    lea     edx, [eax+eax*2]
    lea     esi, [esi+edx*8]
    add     edx, esi
    mov     esi, [ecx+540h]
    lea     edx, [esi+edx*2+32h]
    mov     esi, [esp+4+arg_8]
    cmp     [edx], si
    jz      short loc_480D3C
    lea     eax, [eax+eax*2]
    mov     [edx], si
    mov     esi, [ecx+540h]
    xor     edx, edx
    lea     eax, [eax+eax*8]
    shl     eax, 1
    mov     [esi+eax+48h], dx
    mov     esi, [ecx+540h]
    mov     dword ptr [esi+8], 1
    mov     ecx, [ecx+540h]
    mov     al, [eax+ecx+4Ah]
    shr     al, 1
    test    al, 1
    jz      short loc_480D3C
    mov     [ecx+4], edx

    loc_480D3C:                             ; CODE XREF: sub_480CE0+22j
                                            ; sub_480CE0+57j
    pop     esi
    retn    0Ch
    sub_480CE0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480D40 proc near                    ; CODE XREF: sub_485D40+92p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     [ecx+540h], eax
    retn    4
    sub_480D40 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480D50 proc near                    ; DATA XREF: .rdata:004FD6A0o

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    esi
    mov     esi, ecx
    lea     eax, [eax+eax*2]
    push    edi
    mov     ecx, [esi+540h]
    mov     edx, [esp+0Ch+arg_4]
    lea     eax, [eax+eax*8]
    shl     eax, 1
    lea     edi, [ecx+eax+4Ah]
    mov     cx, [ecx+eax+4Ah]
    mov     ebx, ecx
    and     ebx, 1
    cmp     ebx, edx
    jz      short loc_480DA7
    xor     dl, cl
    and     edx, 1
    xor     edx, ecx
    xor     ecx, ecx
    mov     [edi], dx
    mov     edx, [esi+540h]
    mov     [edx+eax+48h], cx
    mov     esi, [esi+540h]
    mov     al, [esi+eax+4Ah]
    shr     al, 1
    test    al, 1
    jz      short loc_480DA7
    mov     [esi+4], ecx

    loc_480DA7:                             ; CODE XREF: sub_480D50+2Bj
                                            ; sub_480D50+52j
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_480D50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480DB0 proc near                    ; DATA XREF: .rdata:004FD6A4o

    arg_0= dword ptr  4
    arg_4= byte ptr  8

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+540h]
    push    ebx
    mov     bl, [esp+4+arg_4]
    lea     eax, [eax+eax*2]
    and     ebx, 1
    shl     ebx, 1
    lea     eax, [eax+eax*8]
    lea     eax, [edx+eax*2+4Ah]
    mov     dx, [eax]
    and     edx, 0FFFDh
    or      edx, ebx
    pop     ebx
    mov     [eax], dx
    mov     eax, [ecx+540h]
    mov     dword ptr [eax+10h], 0
    retn    8
    sub_480DB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480DF0 proc near                    ; DATA XREF: .rdata:004FD6A8o

    arg_0= dword ptr  4
    arg_4= byte ptr  8

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+540h]
    push    ebx
    mov     bl, [esp+4+arg_4]
    lea     eax, [eax+eax*2]
    and     ebx, 1
    shl     ebx, 2
    lea     eax, [eax+eax*8]
    lea     eax, [edx+eax*2+4Ah]
    mov     dx, [eax]
    and     edx, 0FFFBh
    or      edx, ebx
    pop     ebx
    mov     [eax], dx
    mov     eax, [ecx+540h]
    mov     dword ptr [eax+10h], 0
    retn    8
    sub_480DF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480E30 proc near                    ; DATA XREF: .rdata:004FD6B4o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [ecx+540h]
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*8]
    mov     al, [ecx+eax*2+4Ah]
    and     eax, 1
    retn    4
    sub_480E30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480E50 proc near                    ; DATA XREF: .rdata:004FD6B8o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [ecx+540h]
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*8]
    mov     al, [ecx+eax*2+4Ah]
    shr     eax, 1
    and     eax, 1
    retn    4
    sub_480E50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480E70 proc near                    ; DATA XREF: .rdata:004FD6BCo

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [ecx+540h]
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*8]
    mov     al, [ecx+eax*2+4Ah]
    shr     eax, 2
    and     eax, 1
    retn    4
    sub_480E70 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_69. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_70. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_480EB0 proc near                    ; DATA XREF: .rdata:004FD6C8o

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    xor     edx, edx
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+540h]
    mov     ecx, [eax+0Ch]
    push    ecx                             ; Unit
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*2+TAdynmemStruct.Players]
    push    ecx                             ; Player
    call    PlayerCanSeeUnit
    test    eax, eax
    jz      loc_48111D                      ; default
    mov     edx, [esi+540h]
    mov     eax, [edx+0Ch]
    push    eax
    call    sub_45AB10
    mov     ebx, [esp+28h+arg_4]
    test    bh, 1
    jz      short loc_480F59
    mov     eax, [esi+540h]
    mov     edi, [esp+28h+arg_0]
    mov     ecx, [eax+0Ch]
    lea     edi, [edi+edi*2]
    add     ecx, 6Ah
    mov     esi, ecx
    lea     edi, [edi+edi*8]
    mov     ecx, [esi]
    lea     eax, [eax+edi*2]
    mov     [esp+28h+var_18], ecx
    mov     edx, [esi+4]
    mov     [esp+28h+var_14], edx
    mov     esi, [esi+8]
    mov     [esp+28h+var_10], esi
    mov     edi, [eax+38h]
    add     ecx, edi
    mov     [esp+28h+var_18], ecx
    mov     ebp, [eax+3Ch]
    add     edx, ebp
    mov     [esp+28h+var_14], edx
    mov     edi, [eax+40h]
    sub     esi, edi
    mov     [esp+28h+var_10], esi
    jmp     loc_480FDE
    ; ---------------------------------------------------------------------------

    loc_480F59:                             ; CODE XREF: sub_480EB0+58j
    mov     edi, [esi+540h]
    mov     eax, [edi+0Ch]
    add     eax, 6Ah
    mov     edx, eax
    mov     ebx, [edx]
    mov     [esp+28h+var_C], ebx
    mov     ebp, [edx+4]
    mov     [esp+28h+var_8], ebp
    mov     ecx, [edx+8]
    mov     [esp+28h+var_4], ecx
    mov     ecx, [eax]
    mov     [esp+28h+var_18], ecx
    mov     edx, [eax+4]
    mov     [esp+28h+var_14], edx
    mov     esi, [eax+8]
    mov     eax, [esp+28h+arg_0]
    mov     [esp+28h+var_10], esi
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*8]
    lea     eax, [edi+eax*2+44h]
    mov     edi, [eax]
    add     ecx, [edi]
    mov     [esp+28h+var_18], ecx
    mov     edi, [eax]
    add     edx, [edi+4]
    mov     [esp+28h+var_14], edx
    mov     edi, [eax]
    sub     esi, [edi+8]
    mov     [esp+28h+var_10], esi
    mov     edi, [eax]
    add     ebx, [edi+0Ch]
    mov     [esp+28h+var_C], ebx
    mov     edi, [eax]
    mov     ebx, [edi+10h]
    mov     edi, [esp+28h+var_4]
    add     ebp, ebx
    mov     ebx, [esp+28h+arg_4]
    mov     [esp+28h+var_8], ebp
    mov     eax, [eax]
    mov     eax, [eax+14h]
    sub     edi, eax
    mov     [esp+28h+var_4], edi

    loc_480FDE:                             ; CODE XREF: sub_480EB0+A4j
    cmp     ebx, 101h
    jg      loc_4810C8
    jz      loc_4810B2
    cmp     ebx, 5                          ; switch 6 cases
    ja      loc_48111D                      ; default
    jmp     ds:off_481128[ebx*4]            ; switch jump

    loc_481000:                             ; DATA XREF: .text:00481128o
    push    7                               ; case 0x0
    push    6
    lea     ecx, [esp+30h+var_C]
    push    1
    lea     edx, [esp+34h+var_18]
    push    ecx
    push    edx
    call    sub_472330
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48101F:                             ; CODE XREF: sub_480EB0+149j
                                            ; DATA XREF: .text:00481128o
    push    7                               ; case 0x1
    push    7
    lea     eax, [esp+30h+var_C]
    push    1
    lea     ecx, [esp+34h+var_18]
    push    eax
    push    ecx
    call    sub_472330
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48103E:                             ; CODE XREF: sub_480EB0+149j
                                            ; DATA XREF: .text:00481128o
    push    2                               ; case 0x2
    lea     edx, [esp+2Ch+var_C]
    push    10h
    lea     eax, [esp+30h+var_18]
    push    edx
    push    eax
    call    sub_472430
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48105B:                             ; CODE XREF: sub_480EB0+149j
                                            ; DATA XREF: .text:00481128o
    push    2                               ; case 0x3
    lea     ecx, [esp+2Ch+var_C]
    push    8
    lea     edx, [esp+30h+var_18]
    push    ecx
    push    edx
    call    sub_472430
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_481078:                             ; CODE XREF: sub_480EB0+149j
                                            ; DATA XREF: .text:00481128o
    push    2                               ; case 0x4
    lea     eax, [esp+2Ch+var_18]
    push    10h
    lea     ecx, [esp+30h+var_C]
    push    eax
    push    ecx
    call    sub_472430
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_481095:                             ; CODE XREF: sub_480EB0+149j
                                            ; DATA XREF: .text:00481128o
    push    2                               ; case 0x5
    lea     edx, [esp+2Ch+var_18]
    push    8
    lea     eax, [esp+30h+var_C]
    push    edx
    push    eax
    call    sub_472430
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4810B2:                             ; CODE XREF: sub_480EB0+13Aj
    lea     ecx, [esp+28h+var_18]
    push    9
    push    ecx
    call    sub_472810
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4810C8:                             ; CODE XREF: sub_480EB0+134j
    mov     eax, ebx
    sub     eax, 102h
    jz      short loc_481111
    dec     eax
    jnz     short loc_48111D                ; default
    mov     eax, TAdynmemStructPtr
    mov     [esp+28h+var_8], edx
    xor     edx, edx
    mov     [esp+28h+var_C], ecx
    mov     [esp+28h+var_4], esi
    mov     dl, [eax+1427Fh]
    shl     edx, 10h
    mov     [esp+28h+var_8], edx
    push    7
    lea     ecx, [esp+2Ch+var_C]
    push    8
    lea     edx, [esp+30h+var_18]
    push    ecx
    push    edx
    call    sub_472530
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_481111:                             ; CODE XREF: sub_480EB0+21Fj
    lea     eax, [esp+28h+var_18]
    push    9
    push    eax
    call    sub_4728F0

    loc_48111D:                             ; CODE XREF: sub_480EB0+3Cj
                                            ; sub_480EB0+143j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    sub_480EB0 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_481128 dd offset loc_481000         ; DATA XREF: sub_480EB0+149r
    dd offset loc_48101F                    ; jump table for switch statement
    dd offset loc_48103E
    dd offset loc_48105B
    dd offset loc_481078
    dd offset loc_481095

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_481140 proc near                    ; DATA XREF: .rdata:004FD6CCo

    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 48h
    push    ebx
    mov     ebx, [esp+4Ch+arg_4]
    push    esi
    push    edi
    mov     edi, [esp+54h+arg_0]
    mov     esi, ecx
    test    bl, 20h
    jnz     loc_481241
    mov     eax, [esi+540h]
    push    0BB8h                           ; int
    mov     ecx, [eax+0Ch]
    mov     [esp+58h+var_2C], edi
    mov     [esp+58h+var_30], ecx
    call    GetRandom
    push    0BB8h                           ; int
    mov     [esp+58h+var_28], eax
    call    GetRandom
    push    0BB8h                           ; int
    mov     [esp+58h+var_24], eax
    call    GetRandom
    push    28h                             ; int
    mov     [esp+58h+var_20], eax
    call    GetRandom
    mov     edx, 14h
    push    0Ah                             ; int
    sub     edx, eax
    shl     edx, 0Eh
    mov     [esp+58h+var_1C], edx
    call    GetRandom
    shl     eax, 10h
    push    28h                             ; int
    mov     [esp+58h+var_18], eax
    call    GetRandom
    mov     ecx, 14h
    mov     [esp+54h+var_10], 384h
    sub     ecx, eax
    shl     ecx, 0Eh
    test    bl, 1
    mov     [esp+54h+var_14], ecx
    jz      short loc_4811F6
    mov     edx, [esp+54h+var_8]
    mov     eax, ebx
    and     eax, 2
    and     edx, 0FFFFFFCFh
    shl     eax, 4
    or      eax, edx
    mov     [esp+54h+var_C], 1
    or      al, 4
    jmp     short loc_48120F
    ; ---------------------------------------------------------------------------

    loc_4811F6:                             ; CODE XREF: sub_481140+97j
    mov     ecx, [esp+54h+var_8]
    mov     eax, ebx
    and     eax, 2
    and     ecx, 0FFFFFFCBh
    shl     eax, 3
    mov     [esp+54h+var_C], 0
    or      eax, ecx

    loc_48120F:                             ; CODE XREF: sub_481140+B4j
    mov     ecx, ebx
    and     al, 0FDh
    shr     ecx, 2
    and     ecx, 2
    mov     edx, ebx
    or      ecx, eax
    mov     eax, ebx
    shr     eax, 4
    and     eax, 1
    and     ecx, 0FFFFFFFEh
    or      eax, ecx
    and     edx, 4
    shl     edx, 1
    and     al, 0F7h
    or      edx, eax
    lea     eax, [esp+54h+var_30]
    push    eax
    mov     [esp+58h+var_8], edx
    call    sub_421620

    loc_481241:                             ; CODE XREF: sub_481140+13j
    test    bh, 3Fh
    jz      loc_481333
    mov     ecx, [esi+540h]
    push    edi
    lea     eax, [esp+58h+var_3C]
    mov     edx, [ecx+0Ch]
    push    edx
    push    eax
    call    sub_43E060
    mov     ecx, [eax]
    mov     [esp+54h+var_48], ecx
    mov     edx, [eax+4]
    mov     [esp+54h+var_44], edx
    mov     eax, [eax+8]
    test    bh, 1
    mov     [esp+54h+var_40], eax
    jz      short loc_481293
    mov     ecx, TAdynmemStructPtr
    push    0
    push    2
    lea     eax, [esp+5Ch+var_48]
    mov     edx, [ecx+147F7h]
    push    edx
    push    eax
    call    sub_420A30

    loc_481293:                             ; CODE XREF: sub_481140+136j
    test    bh, 2
    jz      short loc_4812B3
    mov     ecx, TAdynmemStructPtr
    push    0
    push    2
    lea     eax, [esp+5Ch+var_48]
    mov     edx, [ecx+147FBh]
    push    edx
    push    eax
    call    sub_420A30

    loc_4812B3:                             ; CODE XREF: sub_481140+156j
    test    bh, 4
    jz      short loc_4812D3
    mov     ecx, TAdynmemStructPtr
    push    0
    push    2
    lea     eax, [esp+5Ch+var_48]
    mov     edx, [ecx+147FFh]
    push    edx
    push    eax
    call    sub_420A30

    loc_4812D3:                             ; CODE XREF: sub_481140+176j
    test    bh, 8
    jz      short loc_4812F3
    mov     ecx, TAdynmemStructPtr
    push    0
    push    2
    lea     eax, [esp+5Ch+var_48]
    mov     edx, [ecx+14803h]
    push    edx
    push    eax
    call    sub_420A30

    loc_4812F3:                             ; CODE XREF: sub_481140+196j
    test    bh, 10h
    jz      short loc_481313
    mov     ecx, TAdynmemStructPtr
    push    0
    push    2
    lea     eax, [esp+5Ch+var_48]
    mov     edx, [ecx+14807h]
    push    edx
    push    eax
    call    sub_420A30

    loc_481313:                             ; CODE XREF: sub_481140+1B6j
    test    bh, 20h
    jz      short loc_481333
    mov     ecx, TAdynmemStructPtr
    push    0
    push    2
    lea     eax, [esp+5Ch+var_48]
    mov     edx, [ecx+1480Bh]
    push    edx
    push    eax
    call    sub_420A30

    loc_481333:                             ; CODE XREF: sub_481140+104j
                                            ; sub_481140+1D6j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 48h
    retn    8
    sub_481140 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_481340 proc near                    ; DATA XREF: .rdata:004FD6D0o

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    esi
    test    ax, ax
    jnz     short loc_48134E
    xor     eax, eax
    jmp     short loc_48136C
    ; ---------------------------------------------------------------------------

    loc_48134E:                             ; CODE XREF: sub_481340+8j
    and     eax, 0FFFFh
    mov     edx, eax
    shl     eax, 3
    sub     eax, edx
    mov     edx, TAdynmemStructPtr
    mov     edx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [edx+eax*8]

    loc_48136C:                             ; CODE XREF: sub_481340+Cj
    test    eax, eax
    jz      short loc_4813AB
    test    dword ptr [eax+110h], 10000000h
    jz      short loc_4813AB
    mov     edx, [eax+86h]
    test    edx, edx
    jz      short loc_481391
    mov     esi, [ecx+540h]
    cmp     edx, [esi+0Ch]
    jnz     short loc_4813AB

    loc_481391:                             ; CODE XREF: sub_481340+44j
    mov     edx, [esp+4+arg_8]
    mov     ecx, [ecx+540h]
    push    edx
    mov     edx, [esp+8+arg_4]
    push    edx
    mov     edx, [ecx+0Ch]
    push    edx
    push    eax
    call    sub_48AAC0

    loc_4813AB:                             ; CODE XREF: sub_481340+2Ej
                                            ; sub_481340+3Aj ...
    pop     esi
    retn    0Ch
    sub_481340 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __thiscall UnitScriptingData_DropUnit(int)
    UnitScriptingData_DropUnit proc near    ; DATA XREF: .rdata:004FD6D4o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    test    ax, ax
    jnz     short loc_4813BE
    xor     esi, esi
    jmp     short loc_4813DC
    ; ---------------------------------------------------------------------------

    loc_4813BE:                             ; CODE XREF: UnitScriptingData_DropUnit+8j
    and     eax, 0FFFFh
    mov     edx, eax
    shl     eax, 3
    sub     eax, edx
    mov     edx, TAdynmemStructPtr
    mov     edx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     esi, [edx+eax*8]

    loc_4813DC:                             ; CODE XREF: UnitScriptingData_DropUnit+Cj
    test    esi, esi
    jz      short loc_481427
    test    dword ptr [esi+110h], 10000000h
    jz      short loc_481427
    mov     eax, [ecx+540h]
    mov     ecx, [esi+86h]
    cmp     ecx, [eax+0Ch]
    jnz     short loc_481427
    mov     edx, [esi+76h]
    mov     ax, [esi+0A8h]
    mov     ecx, [esi+92h]
    push    1
    push    edx
    push    eax
    push    ecx
    call    sub_47DB70
    test    eax, eax
    jz      short loc_481427
    push    1
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_481427:                             ; CODE XREF: UnitScriptingData_DropUnit+2Ej
                                            ; UnitScriptingData_DropUnit+3Aj ...
    pop     esi
    retn    4
    UnitScriptingData_DropUnit endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_481430 proc near                    ; DATA XREF: .rdata:004FD6E0o

    arg_0= dword ptr  4

    mov     eax, [ecx+540h]
    mov     ecx, [eax+0Ch]
    mov     eax, [ecx+8Ah]
    test    eax, eax
    jz      short loc_481469
    mov     ecx, [esp+arg_0]

    loc_481447:                             ; CODE XREF: sub_481430+2Cj
    xor     edx, edx
    mov     dx, [eax+0A8h]
    cmp     edx, ecx
    jz      short loc_481461
    mov     eax, [eax+8Eh]
    test    eax, eax
    jnz     short loc_481447
    retn    4
    ; ---------------------------------------------------------------------------

    loc_481461:                             ; CODE XREF: sub_481430+22j
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_481469:                             ; CODE XREF: sub_481430+11j
    xor     eax, eax
    retn    4
    sub_481430 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_481470 proc near                    ; DATA XREF: .rdata:004FD6E4o
    mov     eax, [ecx+540h]
    mov     ecx, [eax+0Ch]
    mov     ecx, [ecx+86h]
    test    ecx, ecx
    jz      short loc_48148D
    xor     eax, eax
    mov     ax, [ecx+0A8h]
    retn
    ; ---------------------------------------------------------------------------

    loc_48148D:                             ; CODE XREF: sub_481470+11j
    xor     eax, eax
    retn
    sub_481470 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_481490 proc near                    ; DATA XREF: .rdata:004FD6F0o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short locret_48149F
    mov     dword ptr [ecx+4], 1

    locret_48149F:                          ; CODE XREF: sub_481490+6j
    retn    4
    sub_481490 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4814B0 proc near                    ; DATA XREF: .rdata:004FD6F4o
    xor     eax, eax
    retn    10h
    sub_4814B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    mov     al, [esp+3]
    push    offset unknown_libname_44
    mov     byte_51E6A0, al
    xor     eax, eax
    mov     dword_51E6A4, eax
    mov     dword_51E6A8, eax
    mov     dword_51E6AC, eax
    call    _atexit
    add     esp, 4
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    unknown_libname_44:                     ; DATA XREF: .text:004814C5o
    mov     ecx, offset byte_51E6A0
    jmp     loc_4330B0
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    push    2D0h
    push    offset aEyeballMemory           ; "EYEBALL MEMORY"
    mov     dword ptr [eax+14277h], 0
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [ecx+1427Bh], eax
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1427Bh]
    push    ecx
    call    sub_4D85A0
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_481550 proc near                    ; CODE XREF: sub_40A7B0+5Ap
                                            ; .text:004163C0p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jl      short loc_481590
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+TAdynmemStruct.FeatureMapSizeX]
    cmp     esi, edx
    jge     short loc_481590
    mov     eax, [esp+arg_4]
    test    eax, eax
    jl      short loc_481590
    cmp     eax, [ecx+TAdynmemStruct.FeatureMapSizeY]
    jge     short loc_481590
    imul    eax, edx
    add     eax, esi
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    mov     edx, [ecx+TAdynmemStruct.Features]
    add     eax, edx
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_481590:                             ; CODE XREF: sub_481550+7j
                                            ; sub_481550+17j ...
    xor     eax, eax
    pop     esi
    retn    8
    sub_481550 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4815A0(int)
    sub_4815A0 proc near                    ; CODE XREF: .text:00405198p
                                            ; sub_43E490+246p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     ecx, [eax]
    mov     eax, [eax+8]
    sar     ecx, 14h
    sar     eax, 14h
    test    ecx, ecx
    jl      short loc_4815E7
    mov     edx, TAdynmemStructPtr
    mov     esi, [edx+TAdynmemStruct.FeatureMapSizeX]
    cmp     ecx, esi
    jge     short loc_4815E7
    test    eax, eax
    jl      short loc_4815E7
    cmp     eax, [edx+TAdynmemStruct.FeatureMapSizeY]
    jge     short loc_4815E7
    imul    eax, esi
    add     eax, ecx
    lea     ecx, [eax+eax*2]
    lea     eax, [eax+ecx*4]
    mov     ecx, [edx+TAdynmemStruct.Features]
    add     eax, ecx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4815E7:                             ; CODE XREF: sub_4815A0+12j
                                            ; sub_4815A0+22j ...
    xor     eax, eax
    pop     esi
    retn    4
    sub_4815A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4815F0 proc near                    ; CODE XREF: .text:00405142p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     edx, [eax]
    mov     ecx, [eax+8]
    sar     edx, 14h
    sar     ecx, 14h
    test    edx, edx
    push    edi
    jl      loc_48168D
    mov     eax, TAdynmemStructPtr
    mov     ebp, [eax+14233h]
    cmp     edx, ebp
    jge     short loc_48168D
    test    ecx, ecx
    jl      short loc_48168D
    mov     esi, [eax+14237h]
    cmp     ecx, esi
    mov     [esp+10h+arg_0], esi
    jge     short loc_48168D
    mov     edi, [eax+14287h]
    mov     eax, ecx
    imul    eax, ebp
    add     eax, edx
    mov     ebx, edi
    add     ebx, eax
    lea     esi, [eax+eax*2]
    cmp     word ptr [ebx+esi*4+8], 0FFFEh
    lea     esi, [ebx+esi*4]
    jnz     short loc_481684
    xor     eax, eax
    mov     al, [esi+0Bh]
    sub     edx, eax
    xor     eax, eax
    mov     al, [esi+0Ah]
    sub     ecx, eax
    test    edx, edx
    jl      short loc_481682
    cmp     edx, ebp
    jge     short loc_481682
    test    ecx, ecx
    jl      short loc_481682
    cmp     ecx, [esp+10h+arg_0]
    jge     short loc_481682
    imul    ecx, ebp
    add     ecx, edx
    add     edi, ecx
    lea     edx, [ecx+ecx*2]
    lea     esi, [edi+edx*4]
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_481682:                             ; CODE XREF: sub_4815F0+6Cj
                                            ; sub_4815F0+70j ...
    xor     esi, esi

    loc_481684:                             ; CODE XREF: sub_4815F0+5Aj
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48168D:                             ; CODE XREF: sub_4815F0+15j
                                            ; sub_4815F0+28j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    4
    sub_4815F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall Set_LOS_State(int)
    Set_LOS_State proc near                 ; CODE XREF: .text:004166B1p
                                            ; TextCommand_LOS+26p ...

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= word ptr -1Ch
    var_1A= byte ptr -1Ah
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    Visibility= dword ptr  4

    mov     eax, [esp+Visibility]
    sub     esp, 24h
    test    eax, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      short loc_4816FD
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+TAdynmemStruct.FeatureMapSizeX]
    mov     al, [edx+14281h]
    imul    ecx, [edx+TAdynmemStruct.FeatureMapSizeY]
    shl     ecx, 1
    and     al, 1
    mov     edi, [edx+TAdynmemStruct.field_14273]
    shr     ecx, 2
    neg     al
    sbb     eax, eax
    mov     edx, ecx
    and     eax, 0FFFF0001h
    add     eax, 0FFFFh
    mov     bl, al
    mov     bh, bl
    mov     eax, ebx
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb

    loc_4816FD:                             ; CODE XREF: Set_LOS_State+Dj
    mov     edx, TAdynmemStructPtr
    xor     bl, bl
    xor     esi, esi
    cmp     bl, 10                          ; Loop over all the active players
    jnb     short loc_48176F

    loc_48170C:                             ; CODE XREF: Set_LOS_State+DAj
    mov     eax, [edx+esi+TAdynmemStruct.Players.PlayerActive]
    test    eax, eax
    jz      short loc_48176F
    mov     al, [edx+esi+TAdynmemStruct.Players.PlayerType]
    cmp     al, Player_LocalHuman
    jz      short loc_48172A
    cmp     al, Player_AI
    jz      short loc_48172A
    cmp     al, Player_RemoteHuman
    jnz     short loc_48176F

    loc_48172A:                             ; CODE XREF: Set_LOS_State+80j
                                            ; Set_LOS_State+84j
    cmp     [edx+esi+TAdynmemStruct.Players.PlayerNumber], 10
    jz      short loc_48176F
    mov     al, [edx+14281h]
    mov     ecx, [edx+esi+TAdynmemStruct.Players.field_88]
    mov     edi, [edx+esi+TAdynmemStruct.Players.field_7C]
    mov     ebp, ecx
    shr     al, 1
    not     al
    and     eax, 1
    mov     dl, al
    mov     dh, dl
    mov     eax, edx
    shl     eax, 10h
    mov     ax, dx
    shr     ecx, 2
    rep stosd
    mov     ecx, ebp
    and     ecx, 3
    rep stosb
    mov     edx, TAdynmemStructPtr

    loc_48176F:                             ; CODE XREF: Set_LOS_State+6Aj
                                            ; Set_LOS_State+75j ...
    inc     bl
    add     esi, 14Bh                       ; size of player data
    cmp     bl, 10
    jb      short loc_48170C
    mov     ebp, [edx+TAdynmemStruct.Units]
    mov     eax, [edx+TAdynmemStruct.Units_EndMarker]
    add     ebp, 118h
    cmp     ebp, eax
    ja      loc_481905

    loc_481796:                             ; CODE XREF: Set_LOS_State+25Fj
    cmp     word ptr [ebp+0A6h], 0
    jz      loc_4818F1
    mov     eax, [ebp+96h]
    lea     ecx, [ebp+7Ah]
    mov     [esp+34h+var_24], eax
    mov     eax, [ebp+92h]
    mov     [esp+34h+var_20], ecx
    lea     esi, [ebp+0F8h]
    mov     cx, [eax+202h]
    mov     [esp+34h+var_18], esi
    mov     [esp+34h+var_1C], cx
    lea     ecx, [ebp+6Ah]
    mov     edi, ecx
    mov     ecx, [edi]
    mov     [esp+34h+var_14], ecx
    mov     ecx, [edi+4]
    mov     [esp+34h+var_10], ecx
    mov     edi, [edi+8]
    mov     [esp+34h+var_C], edi
    mov     al, [eax+170h]
    mov     [esp+34h+var_1A], al
    xor     eax, eax
    mov     al, [edx+TAdynmemStruct.data12]
    inc     eax
    shl     eax, 10h
    cmp     ecx, eax
    jge     short loc_481808
    mov     [esp+34h+var_10], eax

    loc_481808:                             ; CODE XREF: Set_LOS_State+162j
    mov     cl, [edx+14281h]
    and     cl, 2
    cmp     cl, 2
    jnz     loc_4818F1
    mov     byte ptr [esi], 0
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+14281h]
    and     dl, 4
    cmp     dl, 4
    jnz     short loc_481840
    lea     eax, [esp+34h+var_24]
    push    eax
    call    sub_4825B0
    jmp     loc_4818EB
    ; ---------------------------------------------------------------------------

    loc_481840:                             ; CODE XREF: Set_LOS_State+18Fj
    movsx   eax, [esp+34h+var_1C]
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     ebx, eax
    sar     ebx, 5
    sub     ebx, 5
    jns     short loc_481859
    xor     ebx, ebx
    jmp     short loc_48186B
    ; ---------------------------------------------------------------------------

    loc_481859:                             ; CODE XREF: Set_LOS_State+1B3j
    mov     edx, [ecx+1485Bh]
    xor     eax, eax
    mov     ax, [edx]
    cmp     ebx, eax
    jl      short loc_48186B
    lea     ebx, [eax-1]

    loc_48186B:                             ; CODE XREF: Set_LOS_State+1B7j
                                            ; Set_LOS_State+1C6j
    mov     eax, [esp+34h+var_14]
    mov     ecx, [ecx+1485Bh]
    cdq
    and     edx, 1FFFFFh
    push    ebx
    add     eax, edx
    push    ecx
    mov     edi, eax
    movsx   eax, word ptr [esp+3Ch+var_10+2]
    cdq
    and     edx, 3Fh
    add     eax, edx
    mov     esi, eax
    mov     eax, [esp+3Ch+var_C]
    cdq
    and     edx, 1FFFFFh
    sar     esi, 6
    add     eax, edx
    mov     [esp+3Ch+Visibility], esi
    mov     esi, eax
    mov     eax, [esp+3Ch+Visibility]
    sar     esi, 15h
    sar     edi, 15h
    sub     esi, eax
    call    sub_4B7F30
    movsx   edx, word ptr [eax+4]
    mov     ecx, [esp+34h+var_20]
    sub     edi, edx
    movsx   eax, word ptr [eax+6]
    mov     [ecx], di
    mov     edx, [esp+34h+var_20]
    sub     esi, eax
    lea     ecx, [esp+34h+var_24]
    mov     [edx+2], si
    mov     eax, [esp+34h+var_18]
    push    ecx
    mov     [eax], bl
    call    sub_482270
    lea     edx, [esp+34h+var_24]
    push    edx
    call    sub_481930

    loc_4818EB:                             ; CODE XREF: Set_LOS_State+19Bj
    mov     edx, TAdynmemStructPtr

    loc_4818F1:                             ; CODE XREF: Set_LOS_State+FEj
                                            ; Set_LOS_State+174j
    mov     eax, [edx+1435Bh]
    add     ebp, 118h
    cmp     ebp, eax
    jbe     loc_481796

    loc_481905:                             ; CODE XREF: Set_LOS_State+F0j
    or      byte ptr [edx+142F1h], 4
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFF7h
    call    GameUnit_LOS_MiniMap
    call    GameUnit_LOS_Minimap_UnitsProjectiles
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    4
    Set_LOS_State endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_481930 proc near                    ; CODE XREF: Set_LOS_State+246p
                                            ; sub_4825B0+ECp ...

    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 44h
    push    ebx
    push    ebp
    mov     ebp, [esp+4Ch+arg_0]
    mov     ebx, 1
    push    esi
    push    edi
    mov     eax, [ebp+0]
    mov     [esp+54h+var_3C], 0
    mov     cl, [eax+146h]
    shl     ebx, cl
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14233h]
    cdq
    sub     eax, edx
    mov     [esp+54h+var_C], ebx
    mov     edi, eax
    mov     eax, [ecx+14237h]
    cdq
    sub     eax, edx
    mov     dl, [ecx+14281h]
    mov     esi, eax
    mov     eax, [ebp+4]
    and     dl, 4
    movsx   ebp, word ptr [eax]
    movsx   eax, word ptr [eax+2]
    sar     edi, 1
    sar     esi, 1
    cmp     dl, 4
    mov     [esp+54h+var_10], edi
    mov     [esp+54h+var_40], ebp
    mov     [esp+54h+var_44], eax
    jnz     loc_481BC3
    mov     edx, [ecx+14293h]
    lea     esi, [ecx+1428Fh]
    cmp     ebp, edx
    mov     [esp+54h+var_30], esi
    jnb     loc_481D0F
    cmp     eax, [esi+8]
    jnb     loc_481D0F
    mov     eax, [esp+54h+arg_0]
    mov     ecx, 0
    movsx   eax, word ptr [eax+8]
    cdq
    and     edx, 1Fh
    add     eax, edx
    sar     eax, 5
    sets    cl
    dec     ecx
    and     ecx, eax
    mov     ebp, ecx
    mov     ecx, offset byte_51E6A0
    call    sub_433520
    movsx   edx, ax
    dec     edx
    cmp     ebp, edx
    jge     short loc_481A0E
    mov     eax, [esp+54h+arg_0]
    mov     ecx, 0
    movsx   eax, word ptr [eax+8]
    cdq
    and     edx, 1Fh
    add     eax, edx
    sar     eax, 5
    sets    cl
    dec     ecx
    and     eax, ecx
    jmp     short loc_481A1C
    ; ---------------------------------------------------------------------------

    loc_481A0E:                             ; CODE XREF: sub_481930+BEj
    mov     ecx, offset byte_51E6A0
    call    sub_433520
    movsx   eax, ax
    dec     eax

    loc_481A1C:                             ; CODE XREF: sub_481930+DCj
    push    eax
    mov     ecx, offset byte_51E6A0
    call    sub_433500
    mov     ecx, eax
    mov     [esp+54h+var_18], eax
    call    sub_4335C0
    imul    edi, [esp+54h+var_44]
    mov     edx, eax
    mov     eax, [esp+54h+var_40]
    add     edi, eax
    mov     eax, TAdynmemStructPtr
    mov     [esp+54h+var_4], edx
    mov     ecx, [eax+14273h]
    lea     eax, [ecx+edi*2]
    mov     edi, ebx
    mov     cx, [eax]
    and     edi, ecx
    test    di, di
    jnz     short loc_481A6A
    xor     ebx, ecx
    mov     [esp+54h+var_3C], 1
    mov     [eax], bx

    loc_481A6A:                             ; CODE XREF: sub_481930+12Bj
    mov     eax, [esp+54h+arg_0]
    xor     ebp, ebp
    mov     [esp+54h+var_1C], ebp
    mov     ecx, [eax+0Ch]
    xor     eax, eax
    test    dx, dx
    mov     al, [ecx]
    mov     [esp+54h+var_28], eax
    jle     loc_481D09

    loc_481A88:                             ; CODE XREF: sub_481930+288j
    mov     ecx, [esp+54h+var_18]
    push    ebp
    call    sub_4335E0
    mov     edi, eax
    mov     ecx, edi
    mov     [esp+54h+var_14], edi
    call    sub_4339C0
    xor     ebx, ebx
    xor     ecx, ecx
    test    ax, ax
    mov     [esp+54h+var_8], eax
    mov     [esp+54h+var_24], 0FFFFFFFFh
    mov     [esp+54h+var_20], ecx
    jle     loc_481BAE
    mov     [esp+54h+var_38], 1
    jmp     short loc_481ACA
    ; ---------------------------------------------------------------------------

    loc_481AC6:                             ; CODE XREF: sub_481930+274j
    mov     edi, [esp+54h+var_14]

    loc_481ACA:                             ; CODE XREF: sub_481930+194j
    lea     edx, [esp+54h+var_34]
    lea     eax, [esp+54h+var_2C]
    push    edx
    push    eax
    push    ecx
    mov     ecx, edi
    call    sub_4339E0
    mov     edi, [esp+54h+var_34]
    mov     eax, [esp+54h+var_2C]
    mov     ebp, [esp+54h+var_40]
    mov     ecx, [esp+54h+var_44]
    add     eax, ebp
    add     edi, ecx
    mov     [esp+54h+var_2C], eax
    movsx   ecx, ax
    mov     eax, [esi+4]
    mov     [esp+54h+var_34], edi
    cmp     ecx, eax
    jnb     loc_481B8D
    movsx   ebp, word ptr [esp+54h+var_34]
    cmp     ebp, [esi+8]
    jnb     short loc_481B8D
    mov     edx, ebp
    imul    edx, eax
    mov     eax, [esi]
    add     edx, ecx
    lea     edi, [eax+edx*2]
    mov     eax, [esp+54h+var_28]
    xor     edx, edx
    mov     dl, [edi+1]
    mov     esi, edx
    xor     edx, edx
    mov     dl, [edi]
    mov     edi, [esp+54h+var_28]
    sub     esi, eax
    mov     eax, [esp+54h+var_24]
    imul    eax, [esp+54h+var_38]
    sub     edx, edi
    imul    edx, ebx
    cmp     edx, eax
    jle     short loc_481B89
    mov     edx, [esp+54h+var_10]
    mov     edi, [esp+54h+var_C]
    imul    edx, ebp
    add     edx, ecx
    mov     ecx, TAdynmemStructPtr
    mov     ebp, edi
    mov     ecx, [ecx+14273h]
    lea     ecx, [ecx+edx*2]
    mov     dx, [ecx]
    and     ebp, edx
    test    bp, bp
    jnz     short loc_481B78
    xor     edi, edx
    mov     [esp+54h+var_3C], 1
    mov     [ecx], di

    loc_481B78:                             ; CODE XREF: sub_481930+239j
    mov     edx, esi
    imul    edx, ebx
    cmp     edx, eax
    jle     short loc_481B89
    mov     ebx, [esp+54h+var_38]
    mov     [esp+54h+var_24], esi

    loc_481B89:                             ; CODE XREF: sub_481930+211j
                                            ; sub_481930+24Fj
    mov     esi, [esp+54h+var_30]

    loc_481B8D:                             ; CODE XREF: sub_481930+1D0j
                                            ; sub_481930+1DEj
    mov     ecx, [esp+54h+var_20]
    mov     edx, [esp+54h+var_38]
    inc     ecx
    inc     edx
    cmp     cx, word ptr [esp+54h+var_8]
    mov     [esp+54h+var_20], ecx
    mov     [esp+54h+var_38], edx
    jl      loc_481AC6
    mov     ebp, [esp+54h+var_1C]

    loc_481BAE:                             ; CODE XREF: sub_481930+186j
    inc     ebp
    cmp     bp, word ptr [esp+54h+var_4]
    mov     [esp+54h+var_1C], ebp
    jl      loc_481A88
    jmp     loc_481D09
    ; ---------------------------------------------------------------------------

    loc_481BC3:                             ; CODE XREF: sub_481930+69j
    mov     eax, [esp+54h+arg_0]
    movsx   eax, word ptr [eax+8]
    cdq
    and     edx, 1Fh
    add     eax, edx
    sar     eax, 5
    sub     eax, 5
    jns     short loc_481BDD
    xor     eax, eax
    jmp     short loc_481BF4
    ; ---------------------------------------------------------------------------

    loc_481BDD:                             ; CODE XREF: sub_481930+2A7j
    mov     ebp, [ecx+1485Bh]
    xor     edx, edx
    mov     dx, [ebp+0]
    cmp     eax, edx
    jl      short loc_481BF0
    lea     eax, [edx-1]

    loc_481BF0:                             ; CODE XREF: sub_481930+2BBj
    mov     ebp, [esp+54h+var_40]

    loc_481BF4:                             ; CODE XREF: sub_481930+2ABj
    mov     ecx, [ecx+1485Bh]
    push    eax
    push    ecx
    call    sub_4B7F30
    mov     ecx, eax
    xor     eax, eax
    mov     [esp+54h+var_30], ecx
    mov     ax, [ecx]
    lea     edx, [ebp+eax+0]
    cmp     edx, edi
    jl      short loc_481C18
    mov     eax, edi
    sub     eax, ebp

    loc_481C18:                             ; CODE XREF: sub_481930+2E2j
    mov     edx, [esp+54h+var_44]
    mov     [esp+54h+var_1C], eax
    xor     eax, eax
    mov     ax, [ecx+2]
    add     edx, eax
    cmp     edx, esi
    jl      short loc_481C38
    mov     eax, [esp+54h+var_44]
    sub     esi, eax
    mov     [esp+54h+var_34], esi
    jmp     short loc_481C40
    ; ---------------------------------------------------------------------------

    loc_481C38:                             ; CODE XREF: sub_481930+2FAj
    mov     [esp+54h+var_34], eax
    mov     eax, [esp+54h+var_44]

    loc_481C40:                             ; CODE XREF: sub_481930+306j
    test    ebp, ebp
    jge     short loc_481C4A
    mov     esi, ebp
    neg     esi
    jmp     short loc_481C4C
    ; ---------------------------------------------------------------------------

    loc_481C4A:                             ; CODE XREF: sub_481930+312j
    xor     esi, esi

    loc_481C4C:                             ; CODE XREF: sub_481930+318j
    test    eax, eax
    mov     [esp+54h+var_20], esi
    jge     short loc_481C5A
    mov     ebp, eax
    neg     ebp
    jmp     short loc_481C5C
    ; ---------------------------------------------------------------------------

    loc_481C5A:                             ; CODE XREF: sub_481930+322j
    xor     ebp, ebp

    loc_481C5C:                             ; CODE XREF: sub_481930+328j
    mov     edx, [esp+54h+var_34]
    mov     eax, ebp
    cmp     ebp, edx
    mov     [esp+54h+var_3C], 0
    mov     [esp+54h+var_24], eax
    jge     loc_481D09
    lea     edx, [edi+edi]
    mov     [esp+54h+var_4], edx
    mov     edx, [esp+54h+var_44]
    add     ebp, edx
    imul    ebp, edi
    mov     edi, [esp+54h+var_40]
    add     ebp, esi
    add     ebp, edi
    shl     ebp, 1
    jmp     short loc_481C96
    ; ---------------------------------------------------------------------------

    loc_481C92:                             ; CODE XREF: sub_481930+3D7j
    mov     ecx, [esp+54h+var_30]

    loc_481C96:                             ; CODE XREF: sub_481930+360j
    xor     edi, edi
    mov     edx, TAdynmemStructPtr
    mov     di, [ecx]
    mov     ecx, eax
    imul    ecx, edi
    mov     edi, [esp+54h+var_30]
    mov     edx, [edx+14273h]
    add     ecx, esi
    add     edx, ebp
    add     ecx, [edi+10h]
    mov     edi, [esp+54h+var_1C]
    cmp     esi, edi
    jge     short loc_481CF6
    sub     edi, esi

    loc_481CC1:                             ; CODE XREF: sub_481930+3BCj
    mov     esi, [esp+54h+var_30]
    mov     al, [ecx]
    cmp     al, [esi+8]
    jz      short loc_481CE7
    mov     si, [edx]
    mov     eax, ebx
    and     eax, esi
    test    ax, ax
    jnz     short loc_481CE7
    mov     eax, ebx
    mov     [esp+54h+var_3C], 1
    xor     eax, esi
    mov     [edx], ax

    loc_481CE7:                             ; CODE XREF: sub_481930+39Aj
                                            ; sub_481930+3A6j
    add     edx, 2
    inc     ecx
    dec     edi
    jnz     short loc_481CC1
    mov     eax, [esp+54h+var_24]
    mov     esi, [esp+54h+var_20]

    loc_481CF6:                             ; CODE XREF: sub_481930+38Dj
    mov     edx, [esp+54h+var_4]
    mov     ecx, [esp+54h+var_34]
    inc     eax
    add     ebp, edx
    cmp     eax, ecx
    mov     [esp+54h+var_24], eax
    jl      short loc_481C92

    loc_481D09:                             ; CODE XREF: sub_481930+152j
                                            ; sub_481930+28Ej ...
    mov     ecx, TAdynmemStructPtr

    loc_481D0F:                             ; CODE XREF: sub_481930+81j
                                            ; sub_481930+8Aj
    mov     eax, [esp+54h+var_3C]
    test    eax, eax
    jz      short loc_481D42
    mov     edx, [esp+54h+arg_0]
    mov     eax, [edx]
    mov     dl, [eax+PlayerStruct.PlayerNumber]
    mov     al, [ecx+TAdynmemStruct.LOS_Sight]
    cmp     dl, al
    jnz     short loc_481D42
    and     word ptr [ecx+14281h], 0FFF7h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 4

    loc_481D42:                             ; CODE XREF: sub_481930+3E5j
                                            ; sub_481930+3FBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    4
    sub_481930 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_481D50 proc near                    ; CODE XREF: sub_482090+74p
                                            ; sub_482130+31p ...

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 38h
    mov     ecx, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+3Ch+arg_0]
    push    ebp
    push    esi
    mov     eax, [ebx]
    push    edi
    mov     dl, [eax+PlayerStruct.PlayerNumber]
    mov     al, [ecx+TAdynmemStruct.LOS_Sight]
    cmp     dl, al
    jnz     short loc_481D8E
    and     word ptr [ecx+14281h], 0FFF7h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 4
    mov     ecx, TAdynmemStructPtr

    loc_481D8E:                             ; CODE XREF: sub_481D50+21j
    mov     eax, [ecx+TAdynmemStruct.FeatureMapSizeX]
    cdq
    sub     eax, edx
    mov     edi, eax
    mov     eax, [ecx+TAdynmemStruct.FeatureMapSizeY]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+48h+var_4], eax
    mov     eax, [ebx+4]
    sar     edi, 1
    movsx   esi, word ptr [eax]
    movsx   ebp, word ptr [eax+2]
    mov     al, [ecx+14281h]
    mov     [esp+48h+var_2C], esi
    and     al, 4
    mov     [esp+48h+var_28], ebp
    cmp     al, 4
    jnz     loc_481FB9
    mov     eax, [ecx+14293h]
    lea     edi, [ecx+1428Fh]
    cmp     esi, eax
    mov     [esp+48h+var_18], edi
    jnb     loc_48207B
    cmp     ebp, [edi+8]
    jnb     loc_48207B
    movsx   eax, word ptr [ebx+8]
    cdq
    and     edx, 1Fh
    mov     ecx, 0
    add     eax, edx
    sar     eax, 5
    sets    cl
    dec     ecx
    and     ecx, eax
    mov     [esp+48h+var_14], ecx
    mov     ecx, offset byte_51E6A0
    call    sub_433520
    movsx   edx, ax
    mov     eax, [esp+48h+var_14]
    dec     edx
    cmp     eax, edx
    jge     short loc_481E39
    movsx   eax, word ptr [ebx+8]
    cdq
    and     edx, 1Fh
    mov     ecx, 0
    add     eax, edx
    sar     eax, 5
    sets    cl
    dec     ecx
    and     eax, ecx
    jmp     short loc_481E47
    ; ---------------------------------------------------------------------------

    loc_481E39:                             ; CODE XREF: sub_481D50+CDj
    mov     ecx, offset byte_51E6A0
    call    sub_433520
    movsx   eax, ax
    dec     eax

    loc_481E47:                             ; CODE XREF: sub_481D50+E7j
    push    eax
    mov     ecx, offset byte_51E6A0
    call    sub_433500
    mov     ecx, eax
    mov     [esp+48h+var_10], eax
    call    sub_4335C0
    mov     ecx, eax
    mov     eax, [ebx]
    add     eax, 7Ch
    mov     [esp+48h+var_4], ecx
    mov     [esp+48h+var_30], 0
    mov     edx, [eax+4]
    mov     eax, [eax]
    imul    edx, ebp
    add     edx, esi
    add     eax, edx
    mov     dl, [eax]
    dec     dl
    mov     [eax], dl
    mov     edx, [ebx+0Ch]
    xor     eax, eax
    mov     al, [edx]
    test    cx, cx
    mov     [esp+48h+var_20], eax
    jle     loc_48207B

    loc_481E96:                             ; CODE XREF: sub_481D50+259j
    mov     ecx, [esp+48h+var_30]
    push    ecx
    mov     ecx, [esp+4Ch+var_10]
    call    sub_4335E0
    mov     ebp, eax
    mov     ecx, ebp
    mov     [esp+48h+var_C], ebp
    call    sub_4339C0
    xor     ebx, ebx
    xor     ecx, ecx
    test    ax, ax
    mov     [esp+48h+var_8], eax
    mov     [esp+48h+var_1C], 0FFFFFFFFh
    mov     [esp+48h+var_14], ecx
    jle     loc_481F9B
    mov     [esp+48h+var_38], 1
    jmp     short loc_481EDC
    ; ---------------------------------------------------------------------------

    loc_481ED8:                             ; CODE XREF: sub_481D50+245j
    mov     ebp, [esp+48h+var_C]

    loc_481EDC:                             ; CODE XREF: sub_481D50+186j
    lea     edx, [esp+48h+var_34]
    lea     eax, [esp+48h+var_24]
    push    edx
    push    eax
    push    ecx
    mov     ecx, ebp
    call    sub_4339E0
    mov     eax, [esp+48h+var_24]
    mov     ecx, [esp+48h+var_28]
    mov     edx, [esp+48h+var_34]
    add     eax, esi
    movsx   esi, ax
    mov     [esp+48h+var_24], eax
    mov     eax, [edi+4]
    add     edx, ecx
    cmp     esi, eax
    mov     [esp+48h+var_34], edx
    jnb     short loc_481F7A
    movsx   ebp, word ptr [esp+48h+var_34]
    cmp     ebp, [edi+8]
    jnb     short loc_481F7A
    mov     edx, ebp
    xor     ecx, ecx
    imul    edx, eax
    mov     eax, [edi]
    add     edx, esi
    mov     cl, [eax+edx*2+1]
    lea     edi, [eax+edx*2]
    mov     eax, [esp+48h+var_20]
    xor     edx, edx
    mov     dl, [edi]
    mov     edi, [esp+48h+var_20]
    sub     ecx, eax
    mov     eax, [esp+48h+var_1C]
    imul    eax, [esp+48h+var_38]
    sub     edx, edi
    imul    edx, ebx
    cmp     edx, eax
    jle     short loc_481F76
    mov     edx, [esp+48h+arg_0]
    mov     edx, [edx]
    add     edx, 7Ch
    mov     edi, [edx+4]
    imul    edi, ebp
    mov     ebp, [edx]
    add     edi, ebp
    dec     byte ptr [edi+esi]
    lea     edx, [edi+esi]
    mov     edx, ecx
    imul    edx, ebx
    cmp     edx, eax
    jle     short loc_481F76
    mov     ebx, [esp+48h+var_38]
    mov     [esp+48h+var_1C], ecx

    loc_481F76:                             ; CODE XREF: sub_481D50+1FAj
                                            ; sub_481D50+21Cj
    mov     edi, [esp+48h+var_18]

    loc_481F7A:                             ; CODE XREF: sub_481D50+1BEj
                                            ; sub_481D50+1C8j
    mov     ecx, [esp+48h+var_14]
    mov     edx, [esp+48h+var_38]
    mov     esi, [esp+48h+var_2C]
    inc     ecx
    inc     edx
    cmp     cx, word ptr [esp+48h+var_8]
    mov     [esp+48h+var_14], ecx
    mov     [esp+48h+var_38], edx
    jl      loc_481ED8

    loc_481F9B:                             ; CODE XREF: sub_481D50+178j
    mov     eax, [esp+48h+var_30]
    inc     eax
    cmp     ax, word ptr [esp+48h+var_4]
    mov     [esp+48h+var_30], eax
    jl      loc_481E96
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_481FB9:                             ; CODE XREF: sub_481D50+76j
    mov     eax, [ebx+0Ch]
    xor     edx, edx
    mov     dl, [eax]
    mov     eax, [ecx+1485Bh]
    push    edx
    push    eax
    call    sub_4B7F30
    mov     ebp, eax
    xor     eax, eax
    mov     ax, [ebp+0]
    lea     ecx, [esi+eax]
    cmp     ecx, edi
    jl      short loc_481FE4
    sub     edi, esi
    mov     [esp+48h+var_30], edi
    jmp     short loc_481FE8
    ; ---------------------------------------------------------------------------

    loc_481FE4:                             ; CODE XREF: sub_481D50+28Aj
    mov     [esp+48h+var_30], eax

    loc_481FE8:                             ; CODE XREF: sub_481D50+292j
    mov     ecx, [esp+48h+var_28]
    mov     edx, [esp+48h+var_4]
    xor     eax, eax
    mov     ax, [ebp+2]
    lea     edi, [ecx+eax]
    cmp     edi, edx
    jl      short loc_482001
    sub     edx, ecx
    jmp     short loc_482003
    ; ---------------------------------------------------------------------------

    loc_482001:                             ; CODE XREF: sub_481D50+2ABj
    mov     edx, eax

    loc_482003:                             ; CODE XREF: sub_481D50+2AFj
    test    esi, esi
    mov     [esp+48h+var_14], edx
    jge     short loc_482011
    mov     edi, esi
    neg     edi
    jmp     short loc_482013
    ; ---------------------------------------------------------------------------

    loc_482011:                             ; CODE XREF: sub_481D50+2B9j
    xor     edi, edi

    loc_482013:                             ; CODE XREF: sub_481D50+2BFj
    test    ecx, ecx
    jge     short loc_48201D
    mov     eax, ecx
    neg     eax
    jmp     short loc_48201F
    ; ---------------------------------------------------------------------------

    loc_48201D:                             ; CODE XREF: sub_481D50+2C5j
    xor     eax, eax

    loc_48201F:                             ; CODE XREF: sub_481D50+2CBj
    cmp     eax, edx
    jge     short loc_48207B
    cmp     edi, [esp+48h+var_30]
    jge     short loc_48207B
    jmp     short loc_482037
    ; ---------------------------------------------------------------------------

    loc_48202B:                             ; CODE XREF: sub_481D50+329j
    mov     esi, [esp+48h+var_2C]
    mov     ebx, [esp+48h+arg_0]
    mov     ecx, [esp+48h+var_28]

    loc_482037:                             ; CODE XREF: sub_481D50+2D9j
    mov     edx, [ebx]
    add     ecx, eax
    add     edx, 7Ch
    imul    ecx, [edx+4]
    add     ecx, edi
    add     ecx, esi
    mov     esi, [edx]
    xor     edx, edx
    add     ecx, esi
    mov     dx, [ebp+0]
    mov     esi, edx
    mov     edx, eax
    imul    edx, esi
    mov     esi, [ebp+10h]
    add     edx, edi
    add     edx, esi
    mov     esi, [esp+48h+var_30]
    sub     esi, edi

    loc_482064:                             ; CODE XREF: sub_481D50+320j
    mov     bl, [edx]
    cmp     bl, [ebp+8]
    jz      short loc_48206D
    dec     byte ptr [ecx]

    loc_48206D:                             ; CODE XREF: sub_481D50+319j
    inc     ecx
    inc     edx
    dec     esi
    jnz     short loc_482064
    mov     ecx, [esp+48h+var_14]
    inc     eax
    cmp     eax, ecx
    jl      short loc_48202B

    loc_48207B:                             ; CODE XREF: sub_481D50+8Ej
                                            ; sub_481D50+97j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    4
    sub_481D50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_482090 proc near                    ; CODE XREF: sub_4866D0+175p

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= word ptr -1Ch
    var_1A= byte ptr -1Ah
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4

    sub     esp, 24h
    mov     eax, [esp+24h+arg_0]
    mov     ecx, [eax+96h]
    lea     edx, [eax+7Ah]
    mov     [esp+24h+var_24], ecx
    mov     ecx, [eax+92h]
    mov     [esp+24h+var_20], edx
    mov     dx, [ecx+202h]
    mov     [esp+24h+var_1C], dx
    lea     edx, [eax+0F8h]
    add     eax, 6Ah
    mov     [esp+24h+var_18], edx
    mov     edx, [eax]
    mov     [esp+24h+var_14], edx
    mov     edx, [eax+4]
    mov     [esp+24h+var_10], edx
    mov     eax, [eax+8]
    mov     [esp+24h+var_C], eax
    mov     cl, [ecx+170h]
    mov     [esp+24h+var_1A], cl
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [ecx+1427Fh]
    inc     eax
    shl     eax, 10h
    cmp     edx, eax
    jge     short loc_4820FF
    mov     [esp+24h+var_10], eax

    loc_4820FF:                             ; CODE XREF: sub_482090+69j
    lea     edx, [esp+24h+var_24]
    push    edx
    call    sub_481D50
    add     esp, 24h
    retn    4
    sub_482090 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    mov     edx, TAdynmemStructPtr
    mov     ecx, [eax+1Ch]
    mov     eax, [edx+38A47h]
    cmp     ecx, eax
    sbb     eax, eax
    neg     eax
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_482130 proc near                    ; CODE XREF: sub_49562A+5Ep

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    xor     ebx, ebx
    mov     eax, [edi+14277h]
    mov     esi, [edi+1427Bh]
    test    eax, eax
    mov     eax, [esp+1Ch+var_C]
    jle     short loc_48217F

    loc_482153:                             ; CODE XREF: sub_482130+4Dj
    mov     ecx, [esi+1Ch]
    mov     edx, [edi+38A47h]
    cmp     ecx, edx
    jnb     short loc_482171
    push    esi
    call    sub_481D50
    mov     edi, TAdynmemStructPtr
    mov     eax, 1

    loc_482171:                             ; CODE XREF: sub_482130+2Ej
    mov     ecx, [edi+14277h]
    inc     ebx
    add     esi, 24h
    cmp     ebx, ecx
    jl      short loc_482153

    loc_48217F:                             ; CODE XREF: sub_482130+21j
    test    eax, eax
    jz      loc_482266
    mov     eax, [edi+14277h]
    mov     esi, [edi+1427Bh]
    lea     edx, [eax+eax*8]
    lea     eax, [esi+edx*4]
    cmp     esi, eax
    mov     [esp+1Ch+var_8], eax
    jz      loc_482247
    mov     ecx, [edi+38A47h]

    loc_4821AB:                             ; CODE XREF: sub_482130+85j
    cmp     [esi+1Ch], ecx
    jb      short loc_4821B7
    add     esi, 24h
    cmp     esi, eax
    jnz     short loc_4821AB

    loc_4821B7:                             ; CODE XREF: sub_482130+7Ej
    cmp     esi, eax
    jz      loc_482247
    lea     edx, [esi+24h]
    cmp     edx, eax
    mov     [esp+1Ch+var_C], edx
    jz      short loc_482247
    lea     ecx, [edx+10h]

    loc_4821CD:                             ; CODE XREF: sub_482130+115j
    mov     ebx, [ecx+0Ch]
    mov     ebp, [edi+38A47h]
    cmp     ebx, ebp
    jb      short loc_482239
    mov     edx, [edx]
    mov     eax, esi
    add     esi, 24h
    mov     ebx, ecx
    mov     [esp+1Ch+var_4], esi
    lea     esi, [eax+20h]
    mov     [eax], edx
    mov     [eax+4], esi
    mov     dx, [ecx-8]
    lea     edi, [eax+0Bh]
    mov     [eax+8], dx
    mov     [eax+0Ch], edi
    mov     ebp, [ebx]
    lea     edx, [eax+10h]
    mov     [eax+10h], ebp
    mov     ebp, [ebx+4]
    mov     [edx+4], ebp
    mov     ebx, [ebx+8]
    mov     [edx+8], ebx
    mov     dl, [ecx-6]
    mov     [eax+0Ah], dl
    mov     edx, [ecx+0Ch]
    mov     [eax+1Ch], edx
    mov     eax, [ecx+10h]
    mov     [esi], eax
    mov     dl, [ecx-5]
    mov     eax, [esp+1Ch+var_8]
    mov     esi, [esp+1Ch+var_4]
    mov     [edi], dl
    mov     edi, TAdynmemStructPtr
    mov     edx, [esp+1Ch+var_C]

    loc_482239:                             ; CODE XREF: sub_482130+A8j
    add     edx, 24h
    add     ecx, 24h
    cmp     edx, eax
    mov     [esp+1Ch+var_C], edx
    jnz     short loc_4821CD

    loc_482247:                             ; CODE XREF: sub_482130+6Fj
                                            ; sub_482130+89j ...
    mov     ebp, [edi+1427Bh]
    mov     eax, 38E38E39h
    sub     esi, ebp
    imul    esi
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [edi+14277h], edx

    loc_482266:                             ; CODE XREF: sub_482130+51j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_482130 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_482270 proc near                    ; CODE XREF: Set_LOS_State+23Cp
                                            ; sub_4825B0+D3p ...

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 38h
    mov     ecx, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+3Ch+arg_0]
    push    ebp
    push    esi
    mov     eax, [ebx]
    push    edi
    mov     dl, [eax+PlayerStruct.PlayerNumber]
    mov     al, [ecx+TAdynmemStruct.LOS_Sight]
    cmp     dl, al
    jnz     short loc_4822AE
    and     word ptr [ecx+14281h], 0FFF7h
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+142F1h], 4
    mov     ecx, TAdynmemStructPtr

    loc_4822AE:                             ; CODE XREF: sub_482270+21j
    mov     eax, [ecx+TAdynmemStruct.FeatureMapSizeX]
    cdq
    sub     eax, edx
    mov     edi, eax
    mov     eax, [ecx+TAdynmemStruct.FeatureMapSizeY]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+48h+var_4], eax
    mov     eax, [ebx+4]
    sar     edi, 1
    movsx   esi, word ptr [eax]
    movsx   ebp, word ptr [eax+2]
    mov     al, [ecx+14281h]
    mov     [esp+48h+var_2C], esi
    and     al, 4
    mov     [esp+48h+var_28], ebp
    cmp     al, 4
    jnz     loc_4824D9
    mov     eax, [ecx+14293h]
    lea     edi, [ecx+1428Fh]
    cmp     esi, eax
    mov     [esp+48h+var_18], edi
    jnb     loc_482597
    cmp     ebp, [edi+8]
    jnb     loc_482597
    movsx   eax, word ptr [ebx+8]
    cdq
    and     edx, 1Fh
    mov     ecx, 0
    add     eax, edx
    sar     eax, 5
    sets    cl
    dec     ecx
    and     ecx, eax
    mov     [esp+48h+var_14], ecx
    mov     ecx, offset byte_51E6A0
    call    sub_433520
    movsx   edx, ax
    mov     eax, [esp+48h+var_14]
    dec     edx
    cmp     eax, edx
    jge     short loc_482359
    movsx   eax, word ptr [ebx+8]
    cdq
    and     edx, 1Fh
    mov     ecx, 0
    add     eax, edx
    sar     eax, 5
    sets    cl
    dec     ecx
    and     eax, ecx
    jmp     short loc_482367
    ; ---------------------------------------------------------------------------

    loc_482359:                             ; CODE XREF: sub_482270+CDj
    mov     ecx, offset byte_51E6A0
    call    sub_433520
    movsx   eax, ax
    dec     eax

    loc_482367:                             ; CODE XREF: sub_482270+E7j
    push    eax
    mov     ecx, offset byte_51E6A0
    call    sub_433500
    mov     ecx, eax
    mov     [esp+48h+var_10], eax
    call    sub_4335C0
    mov     ecx, eax
    mov     eax, [ebx]
    add     eax, 7Ch
    mov     [esp+48h+var_4], ecx
    mov     [esp+48h+var_30], 0
    mov     edx, [eax+4]
    mov     eax, [eax]
    imul    edx, ebp
    add     edx, esi
    add     eax, edx
    mov     dl, [eax]
    inc     dl
    mov     [eax], dl
    mov     edx, [ebx+0Ch]
    xor     eax, eax
    mov     al, [edx]
    test    cx, cx
    mov     [esp+48h+var_20], eax
    jle     loc_482597

    loc_4823B6:                             ; CODE XREF: sub_482270+259j
    mov     ecx, [esp+48h+var_30]
    push    ecx
    mov     ecx, [esp+4Ch+var_10]
    call    sub_4335E0
    mov     ebp, eax
    mov     ecx, ebp
    mov     [esp+48h+var_C], ebp
    call    sub_4339C0
    xor     ebx, ebx
    xor     ecx, ecx
    test    ax, ax
    mov     [esp+48h+var_8], eax
    mov     [esp+48h+var_1C], 0FFFFFFFFh
    mov     [esp+48h+var_14], ecx
    jle     loc_4824BB
    mov     [esp+48h+var_38], 1
    jmp     short loc_4823FC
    ; ---------------------------------------------------------------------------

    loc_4823F8:                             ; CODE XREF: sub_482270+245j
    mov     ebp, [esp+48h+var_C]

    loc_4823FC:                             ; CODE XREF: sub_482270+186j
    lea     edx, [esp+48h+var_34]
    lea     eax, [esp+48h+var_24]
    push    edx
    push    eax
    push    ecx
    mov     ecx, ebp
    call    sub_4339E0
    mov     eax, [esp+48h+var_24]
    mov     ecx, [esp+48h+var_28]
    mov     edx, [esp+48h+var_34]
    add     eax, esi
    movsx   esi, ax
    mov     [esp+48h+var_24], eax
    mov     eax, [edi+4]
    add     edx, ecx
    cmp     esi, eax
    mov     [esp+48h+var_34], edx
    jnb     short loc_48249A
    movsx   ebp, word ptr [esp+48h+var_34]
    cmp     ebp, [edi+8]
    jnb     short loc_48249A
    mov     edx, ebp
    xor     ecx, ecx
    imul    edx, eax
    mov     eax, [edi]
    add     edx, esi
    mov     cl, [eax+edx*2+1]
    lea     edi, [eax+edx*2]
    mov     eax, [esp+48h+var_20]
    xor     edx, edx
    mov     dl, [edi]
    mov     edi, [esp+48h+var_20]
    sub     ecx, eax
    mov     eax, [esp+48h+var_1C]
    imul    eax, [esp+48h+var_38]
    sub     edx, edi
    imul    edx, ebx
    cmp     edx, eax
    jle     short loc_482496
    mov     edx, [esp+48h+arg_0]
    mov     edx, [edx]
    add     edx, 7Ch
    mov     edi, [edx+4]
    imul    edi, ebp
    mov     ebp, [edx]
    add     edi, ebp
    inc     byte ptr [edi+esi]
    lea     edx, [edi+esi]
    mov     edx, ecx
    imul    edx, ebx
    cmp     edx, eax
    jle     short loc_482496
    mov     ebx, [esp+48h+var_38]
    mov     [esp+48h+var_1C], ecx

    loc_482496:                             ; CODE XREF: sub_482270+1FAj
                                            ; sub_482270+21Cj
    mov     edi, [esp+48h+var_18]

    loc_48249A:                             ; CODE XREF: sub_482270+1BEj
                                            ; sub_482270+1C8j
    mov     ecx, [esp+48h+var_14]
    mov     edx, [esp+48h+var_38]
    mov     esi, [esp+48h+var_2C]
    inc     ecx
    inc     edx
    cmp     cx, word ptr [esp+48h+var_8]
    mov     [esp+48h+var_14], ecx
    mov     [esp+48h+var_38], edx
    jl      loc_4823F8

    loc_4824BB:                             ; CODE XREF: sub_482270+178j
    mov     eax, [esp+48h+var_30]
    inc     eax
    cmp     ax, word ptr [esp+48h+var_4]
    mov     [esp+48h+var_30], eax
    jl      loc_4823B6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4824D9:                             ; CODE XREF: sub_482270+76j
    mov     eax, [ebx+0Ch]
    xor     edx, edx
    mov     dl, [eax]
    mov     eax, [ecx+1485Bh]
    push    edx
    push    eax
    call    sub_4B7F30
    mov     ebp, eax
    xor     eax, eax
    mov     ax, [ebp+0]
    lea     ecx, [esi+eax]
    cmp     ecx, edi
    jl      short loc_482504
    sub     edi, esi
    mov     [esp+48h+var_30], edi
    jmp     short loc_482508
    ; ---------------------------------------------------------------------------

    loc_482504:                             ; CODE XREF: sub_482270+28Aj
    mov     [esp+48h+var_30], eax

    loc_482508:                             ; CODE XREF: sub_482270+292j
    mov     ecx, [esp+48h+var_28]
    mov     edx, [esp+48h+var_4]
    xor     eax, eax
    mov     ax, [ebp+2]
    lea     edi, [ecx+eax]
    cmp     edi, edx
    jl      short loc_482521
    sub     edx, ecx
    jmp     short loc_482523
    ; ---------------------------------------------------------------------------

    loc_482521:                             ; CODE XREF: sub_482270+2ABj
    mov     edx, eax

    loc_482523:                             ; CODE XREF: sub_482270+2AFj
    test    esi, esi
    mov     [esp+48h+var_14], edx
    jge     short loc_482531
    mov     edi, esi
    neg     edi
    jmp     short loc_482533
    ; ---------------------------------------------------------------------------

    loc_482531:                             ; CODE XREF: sub_482270+2B9j
    xor     edi, edi

    loc_482533:                             ; CODE XREF: sub_482270+2BFj
    test    ecx, ecx
    jge     short loc_48253D
    mov     eax, ecx
    neg     eax
    jmp     short loc_48253F
    ; ---------------------------------------------------------------------------

    loc_48253D:                             ; CODE XREF: sub_482270+2C5j
    xor     eax, eax

    loc_48253F:                             ; CODE XREF: sub_482270+2CBj
    cmp     eax, edx
    jge     short loc_482597
    cmp     edi, [esp+48h+var_30]
    jge     short loc_482597
    jmp     short loc_482557
    ; ---------------------------------------------------------------------------

    loc_48254B:                             ; CODE XREF: sub_482270+325j
    mov     esi, [esp+48h+var_2C]
    mov     ebx, [esp+48h+arg_0]
    mov     ecx, [esp+48h+var_28]

    loc_482557:                             ; CODE XREF: sub_482270+2D9j
    mov     edx, [ebx]
    add     ecx, eax
    add     edx, 7Ch
    imul    ecx, [edx+4]
    add     ecx, edi
    add     ecx, esi
    mov     esi, [edx]
    xor     edx, edx
    add     ecx, esi
    mov     dx, [ebp+0]
    mov     esi, [ebp+10h]
    imul    edx, eax
    add     edx, edi
    add     edx, esi
    mov     esi, [esp+48h+var_30]
    sub     esi, edi

    loc_482580:                             ; CODE XREF: sub_482270+31Cj
    mov     bl, [edx]
    cmp     bl, [ebp+8]
    jz      short loc_482589
    inc     byte ptr [ecx]

    loc_482589:                             ; CODE XREF: sub_482270+315j
    inc     ecx
    inc     edx
    dec     esi
    jnz     short loc_482580
    mov     ecx, [esp+48h+var_14]
    inc     eax
    cmp     eax, ecx
    jl      short loc_48254B

    loc_482597:                             ; CODE XREF: sub_482270+8Ej
                                            ; sub_482270+97j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    4
    sub_482270 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4825B0 proc near                    ; CODE XREF: Set_LOS_State+196p
                                            ; sub_4827B0+74p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ax, [ecx+14281h]
    mov     esi, [esp+10h+arg_0]
    mov     [esp+10h+var_4], eax
    and     al, 4
    cmp     al, 4
    push    edi
    jnz     loc_4826B7
    movsx   ebp, word ptr [esi+12h]
    movsx   eax, word ptr [esi+16h]
    xor     ebx, ebx
    mov     bl, [esi+0Ah]
    sar     ebp, 5
    add     ebx, eax
    jns     short loc_4825EA
    xor     ebx, ebx

    loc_4825EA:                             ; CODE XREF: sub_4825B0+36j
    cmp     ebx, 0FFh
    jle     short loc_4825F7
    mov     ebx, 0FFh

    loc_4825F7:                             ; CODE XREF: sub_4825B0+40j
    mov     edx, [esi+0Ch]
    mov     ecx, ebx
    movsx   edi, word ptr [esi+1Ah]
    mov     al, [edx]
    mov     byte ptr [esp+14h+arg_0], al
    and     eax, 0FFh
    sub     eax, ebx
    cdq
    xor     eax, edx
    sub     eax, edx
    mov     edx, [esi+4]
    sar     ecx, 1
    sub     edi, ecx
    movsx   ecx, word ptr [edx]
    sar     edi, 5
    cmp     ecx, ebp
    jnz     short loc_482634
    movsx   edx, word ptr [edx+2]
    cmp     edx, edi
    jnz     short loc_482634
    cmp     eax, 5
    jle     loc_4827A0

    loc_482634:                             ; CODE XREF: sub_4825B0+71j
                                            ; sub_4825B0+79j
    mov     al, byte ptr [esp+14h+arg_0]
    test    al, al
    jz      short loc_482649
    test    byte ptr [esp+14h+var_4], 2
    jz      short loc_482649
    push    esi
    call    sub_481D50

    loc_482649:                             ; CODE XREF: sub_4825B0+8Aj
                                            ; sub_4825B0+91j
    mov     eax, [esi+4]
    mov     [eax], bp
    mov     ecx, [esi+4]
    mov     [ecx+2], di
    mov     eax, TAdynmemStructPtr
    cmp     ebp, [eax+14293h]
    jnb     short loc_4826A9
    cmp     edi, [eax+14297h]
    jnb     short loc_4826A9
    mov     edx, [esi+0Ch]
    mov     [edx], bl
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+14281h]
    shr     cl, 1
    test    cl, 1
    jz      short loc_482688
    push    esi
    call    sub_482270

    loc_482688:                             ; CODE XREF: sub_4825B0+D0j
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+14281h], 1
    jz      loc_4827A0
    push    esi
    call    sub_481930
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4826A9:                             ; CODE XREF: sub_4825B0+B1j
                                            ; sub_4825B0+B9j
    mov     eax, [esi+0Ch]
    mov     byte ptr [eax], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4826B7:                             ; CODE XREF: sub_4825B0+1Ej
    movsx   eax, word ptr [esi+8]
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     ebx, eax
    sar     ebx, 5
    sub     ebx, 5
    jns     short loc_4826CF
    xor     ebx, ebx
    jmp     short loc_4826E1
    ; ---------------------------------------------------------------------------

    loc_4826CF:                             ; CODE XREF: sub_4825B0+119j
    mov     edx, [ecx+1485Bh]
    xor     eax, eax
    mov     ax, [edx]
    cmp     ebx, eax
    jl      short loc_4826E1
    lea     ebx, [eax-1]

    loc_4826E1:                             ; CODE XREF: sub_4825B0+11Dj
                                            ; sub_4825B0+12Cj
    mov     eax, [esi+10h]
    push    ebx
    cdq
    and     edx, 1FFFFFh
    add     eax, edx
    mov     ebp, eax
    mov     eax, [esi+18h]
    cdq
    and     edx, 1FFFFFh
    add     eax, edx
    mov     edi, eax
    movsx   eax, word ptr [esi+16h]
    cdq
    and     edx, 3Fh
    add     eax, edx
    sar     edi, 15h
    sar     eax, 6
    sub     edi, eax
    mov     eax, [ecx+1485Bh]
    push    eax
    sar     ebp, 15h
    call    sub_4B7F30
    movsx   ecx, word ptr [eax+4]
    movsx   edx, word ptr [eax+6]
    mov     eax, [esi+4]
    sub     ebp, ecx
    sub     edi, edx
    movsx   ecx, word ptr [eax]
    cmp     ecx, ebp
    jnz     short loc_482748
    movsx   edx, word ptr [eax+2]
    cmp     edx, edi
    jnz     short loc_482748
    mov     ecx, [esi+0Ch]
    xor     edx, edx
    mov     dl, [ecx]
    cmp     edx, ebx
    jz      short loc_4827A0

    loc_482748:                             ; CODE XREF: sub_4825B0+183j
                                            ; sub_4825B0+18Bj
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+14281h]
    and     dl, 2
    cmp     dl, 2
    jnz     short loc_48277C
    push    esi
    call    sub_481D50
    mov     eax, [esi+4]
    push    esi
    mov     [eax], bp
    mov     ecx, [esi+4]
    mov     [ecx+2], di
    mov     edx, [esi+0Ch]
    mov     [edx], bl
    call    sub_482270
    jmp     short loc_48278B
    ; ---------------------------------------------------------------------------

    loc_48277C:                             ; CODE XREF: sub_4825B0+1AAj
    mov     [eax], bp
    mov     eax, [esi+4]
    mov     [eax+2], di
    mov     ecx, [esi+0Ch]
    mov     [ecx], bl

    loc_48278B:                             ; CODE XREF: sub_4825B0+1CAj
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+14281h], 1
    jz      short loc_4827A0
    push    esi
    call    sub_481930

    loc_4827A0:                             ; CODE XREF: sub_4825B0+7Ej
                                            ; sub_4825B0+E5j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_4825B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4827B0 proc near                    ; CODE XREF: sub_43D6D0+389p
                                            ; sub_464DA0+1Fp ...

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= word ptr -1Ch
    var_1A= byte ptr -1Ah
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4

    sub     esp, 24h
    mov     eax, [esp+24h+arg_0]
    mov     ecx, [eax+96h]
    lea     edx, [eax+7Ah]
    mov     [esp+24h+var_24], ecx
    mov     ecx, [eax+92h]
    mov     [esp+24h+var_20], edx
    mov     dx, [ecx+202h]
    mov     [esp+24h+var_1C], dx
    lea     edx, [eax+0F8h]
    add     eax, 6Ah
    mov     [esp+24h+var_18], edx
    mov     edx, [eax]
    mov     [esp+24h+var_14], edx
    mov     edx, [eax+4]
    mov     [esp+24h+var_10], edx
    mov     eax, [eax+8]
    mov     [esp+24h+var_C], eax
    mov     cl, [ecx+170h]
    mov     [esp+24h+var_1A], cl
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [ecx+TAdynmemStruct.data12]
    inc     eax
    shl     eax, 10h
    cmp     edx, eax
    jge     short loc_48281F
    mov     [esp+24h+var_10], eax

    loc_48281F:                             ; CODE XREF: sub_4827B0+69j
    lea     edx, [esp+24h+var_24]
    push    edx
    call    sub_4825B0
    add     esp, 24h
    retn    4
    sub_4827B0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     cl, [eax+14281h]
    push    edi
    and     cl, 2
    cmp     cl, 2
    jnz     loc_482906
    mov     esi, [esp+14h]
    mov     edx, [esi+0Ch]
    mov     byte ptr [edx], 0
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+14281h]
    and     al, 4
    cmp     al, 4
    jnz     short loc_482874
    push    esi
    call    sub_4825B0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_482874:                             ; CODE XREF: .text:00482865j
    movsx   eax, word ptr [esi+8]
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     ebx, eax
    sar     ebx, 5
    sub     ebx, 5
    jns     short loc_48288C
    xor     ebx, ebx
    jmp     short loc_48289E
    ; ---------------------------------------------------------------------------

    loc_48288C:                             ; CODE XREF: .text:00482886j
    mov     edx, [ecx+1485Bh]
    xor     eax, eax
    mov     ax, [edx]
    cmp     ebx, eax
    jl      short loc_48289E
    lea     ebx, [eax-1]

    loc_48289E:                             ; CODE XREF: .text:0048288Aj
                                            ; .text:00482899j
    mov     eax, [esi+10h]
    push    ebx
    cdq
    and     edx, 1FFFFFh
    add     eax, edx
    mov     ebp, eax
    mov     eax, [esi+18h]
    cdq
    and     edx, 1FFFFFh
    add     eax, edx
    mov     edi, eax
    movsx   eax, word ptr [esi+16h]
    cdq
    and     edx, 3Fh
    add     eax, edx
    sar     edi, 15h
    sar     eax, 6
    sub     edi, eax
    mov     eax, [ecx+1485Bh]
    push    eax
    sar     ebp, 15h
    call    sub_4B7F30
    movsx   ecx, word ptr [eax+4]
    movsx   edx, word ptr [eax+6]
    mov     eax, [esi+4]
    sub     ebp, ecx
    sub     edi, edx
    push    esi
    mov     [eax], bp
    mov     ecx, [esi+4]
    mov     [ecx+2], di
    mov     edx, [esi+0Ch]
    mov     [edx], bl
    call    sub_482270
    push    esi
    call    sub_481930

    loc_482906:                             ; CODE XREF: .text:00482845j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_482910 proc near                    ; CODE XREF: sub_4866D0+78p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch
    arg_C= dword ptr  10h

    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+14281h]
    and     al, 2
    cmp     al, 2
    jnz     locret_482AAF
    mov     eax, [ecx+TAdynmemStruct.field_14277]
    cmp     eax, 14h
    jge     locret_482AAF
    lea     edx, [eax+eax*8]
    mov     eax, [ecx+TAdynmemStruct.EyeBallMemory]
    push    edi
    push    esi
    lea     esi, [eax+edx*4]
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    push    ebp
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     edx, [esi+20h]
    mov     [esi+4], edx
    mov     edx, [esp+0Ch+arg_0]
    lea     eax, [eax+eax*4]
    lea     edi, [esi+10h]
    push    ebx
    lea     ecx, [ecx+eax*2+TAdynmemStruct.Players]
    mov     ax, word ptr [esp+10h+arg_4]
    mov     [esi], ecx
    lea     ecx, [esi+0Bh]
    mov     [esi+8], ax
    mov     [esi+0Ch], ecx
    mov     ebx, [edx]
    mov     eax, edi
    mov     [eax], ebx
    mov     ebx, [edx+4]
    mov     [eax+4], ebx
    mov     edx, [edx+8]
    mov     [eax+8], edx
    mov     al, [esp+10h+arg_8]
    mov     [esi+0Ah], al
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [edx+1427Fh]
    mov     edx, [esi+14h]
    inc     eax
    shl     eax, 10h
    cmp     edx, eax
    jge     short loc_4829B3
    mov     [esi+14h], eax

    loc_4829B3:                             ; CODE XREF: sub_482910+9Ej
    mov     eax, TAdynmemStructPtr
    mov     ebp, [esp+10h+arg_C]
    mov     edx, [eax+38A47h]
    add     edx, ebp
    mov     [esi+1Ch], edx
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+14281h]
    and     dl, 2
    cmp     dl, 2
    jnz     loc_482A99
    mov     byte ptr [ecx], 0
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+14281h]
    and     al, 4
    cmp     al, 4
    jnz     short loc_4829FE
    push    esi
    call    sub_4825B0
    jmp     loc_482A99
    ; ---------------------------------------------------------------------------

    loc_4829FE:                             ; CODE XREF: sub_482910+E1j
    movsx   eax, word ptr [esi+8]
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     ebx, eax
    sar     ebx, 5
    sub     ebx, 5
    jns     short loc_482A16
    xor     ebx, ebx
    jmp     short loc_482A28
    ; ---------------------------------------------------------------------------

    loc_482A16:                             ; CODE XREF: sub_482910+100j
    mov     edx, [ecx+1485Bh]
    xor     eax, eax
    mov     ax, [edx]
    cmp     ebx, eax
    jl      short loc_482A28
    lea     ebx, [eax-1]

    loc_482A28:                             ; CODE XREF: sub_482910+104j
                                            ; sub_482910+113j
    mov     eax, [edi]
    mov     ecx, [ecx+1485Bh]
    cdq
    and     edx, 1FFFFFh
    push    ebx
    add     eax, edx
    push    ecx
    mov     ebp, eax
    movsx   eax, word ptr [esi+16h]
    cdq
    and     edx, 3Fh
    add     eax, edx
    mov     edi, eax
    mov     eax, [esi+18h]
    cdq
    and     edx, 1FFFFFh
    sar     edi, 6
    add     eax, edx
    mov     [esp+18h+arg_4], edi
    mov     edi, eax
    mov     eax, [esp+18h+arg_4]
    sar     edi, 15h
    sar     ebp, 15h
    sub     edi, eax
    call    sub_4B7F30
    movsx   edx, word ptr [eax+4]
    mov     ecx, [esi+4]
    sub     ebp, edx
    movsx   eax, word ptr [eax+6]
    mov     [ecx], bp
    mov     edx, [esi+4]
    sub     edi, eax
    push    esi
    mov     [edx+2], di
    mov     eax, [esi+0Ch]
    mov     [eax], bl
    call    sub_482270
    push    esi
    call    sub_481930

    loc_482A99:                             ; CODE XREF: sub_482910+C8j
                                            ; sub_482910+E9j
    mov     eax, TAdynmemStructPtr
    pop     ebx
    pop     ebp
    pop     esi
    mov     ecx, [eax+14277h]
    pop     edi
    inc     ecx
    mov     [eax+14277h], ecx

    locret_482AAF:                          ; CODE XREF: sub_482910+10j
                                            ; sub_482910+1Fj
    retn    10h
    sub_482910 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_482AC0 proc near                    ; CODE XREF: sub_485F50+228p
                                            ; sub_4861D0+142p

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= word ptr -1Ch
    var_1A= byte ptr -1Ah
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4

    sub     esp, 24h
    mov     eax, [esp+24h+arg_0]
    push    ebx
    push    esi
    push    edi
    mov     ecx, [eax+96h]
    lea     edx, [eax+7Ah]
    mov     [esp+30h+var_24], ecx
    mov     ecx, [eax+92h]
    mov     [esp+30h+var_20], edx
    lea     esi, [eax+0F8h]
    mov     dx, [ecx+202h]
    add     eax, 6Ah
    mov     [esp+30h+var_1C], dx
    mov     [esp+30h+var_18], esi
    mov     edx, [eax]
    mov     [esp+30h+var_14], edx
    mov     edx, [eax+4]
    mov     [esp+30h+var_10], edx
    mov     eax, [eax+8]
    mov     [esp+30h+var_C], eax
    mov     cl, [ecx+170h]
    mov     [esp+30h+var_1A], cl
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [ecx+1427Fh]
    inc     eax
    shl     eax, 10h
    cmp     edx, eax
    jge     short loc_482B32
    mov     [esp+30h+var_10], eax

    loc_482B32:                             ; CODE XREF: sub_482AC0+6Cj
    mov     dl, [ecx+14281h]
    and     dl, 2
    cmp     dl, 2
    jnz     loc_482C0D
    mov     byte ptr [esi], 0
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+14281h]
    and     al, 4
    cmp     al, 4
    jnz     short loc_482B6C
    lea     ecx, [esp+30h+var_24]
    push    ecx
    call    sub_4825B0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 24h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_482B6C:                             ; CODE XREF: sub_482AC0+97j
    movsx   eax, [esp+30h+var_1C]
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     ebx, eax
    sar     ebx, 5
    sub     ebx, 5
    jns     short loc_482B85
    xor     ebx, ebx
    jmp     short loc_482B97
    ; ---------------------------------------------------------------------------

    loc_482B85:                             ; CODE XREF: sub_482AC0+BFj
    mov     edx, [ecx+1485Bh]
    xor     eax, eax
    mov     ax, [edx]
    cmp     ebx, eax
    jl      short loc_482B97
    lea     ebx, [eax-1]

    loc_482B97:                             ; CODE XREF: sub_482AC0+C3j
                                            ; sub_482AC0+D2j
    mov     eax, [esp+30h+var_14]
    push    ebx
    cdq
    and     edx, 1FFFFFh
    add     eax, edx
    mov     edi, eax
    mov     eax, [esp+34h+var_C]
    cdq
    and     edx, 1FFFFFh
    add     eax, edx
    mov     esi, eax
    movsx   eax, word ptr [esp+34h+var_10+2]
    cdq
    and     edx, 3Fh
    add     eax, edx
    sar     esi, 15h
    sar     eax, 6
    sub     esi, eax
    mov     eax, [ecx+1485Bh]
    push    eax
    sar     edi, 15h
    call    sub_4B7F30
    movsx   ecx, word ptr [eax+4]
    movsx   edx, word ptr [eax+6]
    mov     eax, [esp+30h+var_20]
    sub     edi, ecx
    sub     esi, edx
    mov     [eax], di
    mov     ecx, [esp+30h+var_20]
    lea     eax, [esp+30h+var_24]
    mov     [ecx+2], si
    mov     edx, [esp+30h+var_18]
    push    eax
    mov     [edx], bl
    call    sub_482270
    lea     ecx, [esp+30h+var_24]
    push    ecx
    call    sub_481930

    loc_482C0D:                             ; CODE XREF: sub_482AC0+7Ej
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 24h
    retn    4
    sub_482AC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_482C20 proc near                    ; CODE XREF: sub_483610+6DCp

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    0Ah                             ; int
    call    sub_4B4F10
    xor     ebp, ebp
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_482C46
    mov     byte ptr [eax], 0
    mov     byte ptr [eax+1], 0
    mov     [eax+2], ebp
    mov     [eax+6], ebp
    jmp     short loc_482C48
    ; ---------------------------------------------------------------------------

    loc_482C46:                             ; CODE XREF: sub_482C20+15j
    xor     eax, eax

    loc_482C48:                             ; CODE XREF: sub_482C20+24j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142B7h], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+142B7h]
    mov     dword ptr [eax+2], 1Fh
    mov     eax, TAdynmemStructPtr
    mov     edi, [eax+14227h]
    mov     ecx, [eax+1429Fh]
    lea     esi, [eax+1429Fh]
    mov     eax, [eax+14223h]
    shl     edi, 10h
    shl     eax, 10h
    mov     [esi+14h], edi
    add     edi, 7FFFFFh
    lea     ebx, [eax+7FFFFFh]
    push    ecx
    sar     edi, 17h
    sar     ebx, 17h
    mov     [esi+10h], eax
    mov     [esi+4], ebx
    mov     [esi+8], edi
    call    sub_4B4F20
    imul    edi, ebx
    add     edi, 7
    add     esp, 4
    and     edi, 0FFFFFFF8h
    mov     [esi+0Ch], edi
    jz      short loc_482CF1
    lea     edx, [edi+edi*4]
    shl     edx, 1
    push    edx                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_482CF1
    lea     edx, [edi-1]
    cmp     edx, ebp
    jl      short loc_482CF3
    lea     ecx, [eax+2]
    inc     edx

    loc_482CDC:                             ; CODE XREF: sub_482C20+CDj
    mov     byte ptr [ecx-2], 0
    mov     byte ptr [ecx-1], 0
    mov     [ecx], ebp
    mov     [ecx+4], ebp
    add     ecx, 0Ah
    dec     edx
    jnz     short loc_482CDC
    jmp     short loc_482CF3
    ; ---------------------------------------------------------------------------

    loc_482CF1:                             ; CODE XREF: sub_482C20+9Dj
                                            ; sub_482C20+AFj
    xor     eax, eax

    loc_482CF3:                             ; CODE XREF: sub_482C20+B6j
                                            ; sub_482C20+CFj
    mov     [esi], eax
    mov     edi, TAdynmemStructPtr
    mov     [esp+28h+var_14], eax
    mov     eax, [esi+4]
    mov     ebx, [edi+14287h]
    xor     ecx, ecx
    cmp     eax, ebp
    jbe     short loc_482D30
    xor     edx, edx

    loc_482D10:                             ; CODE XREF: sub_482C20+108j
    mov     eax, [esi]
    mov     edi, [eax+edx+2]
    lea     eax, [eax+edx+2]
    or      edi, 1
    inc     ecx
    mov     [eax], edi
    mov     eax, [esi+4]
    add     edx, 0Ah
    cmp     ecx, eax
    jb      short loc_482D10
    mov     edi, TAdynmemStructPtr

    loc_482D30:                             ; CODE XREF: sub_482C20+ECj
    mov     ecx, [esi+4]
    xor     edx, edx
    cmp     ecx, ebp
    jbe     short loc_482D62

    loc_482D39:                             ; CODE XREF: sub_482C20+13Aj
    mov     eax, [esi+8]
    dec     eax
    imul    eax, ecx
    add     eax, edx
    lea     ecx, [eax+eax*4]
    mov     eax, [esi]
    mov     edi, [eax+ecx*2+2]
    lea     eax, [eax+ecx*2+2]
    or      edi, 2
    inc     edx
    mov     [eax], edi
    mov     ecx, [esi+4]
    cmp     edx, ecx
    jb      short loc_482D39
    mov     edi, TAdynmemStructPtr

    loc_482D62:                             ; CODE XREF: sub_482C20+117j
    mov     eax, [esi+8]
    xor     ecx, ecx
    cmp     eax, ebp
    jbe     short loc_482D91

    loc_482D6B:                             ; CODE XREF: sub_482C20+169j
    mov     eax, ecx
    imul    eax, [esi+4]
    lea     edx, [eax+eax*4]
    mov     eax, [esi]
    mov     edi, [eax+edx*2+2]
    lea     eax, [eax+edx*2+2]
    or      edi, 4
    inc     ecx
    mov     [eax], edi
    mov     eax, [esi+8]
    cmp     ecx, eax
    jb      short loc_482D6B
    mov     edi, TAdynmemStructPtr

    loc_482D91:                             ; CODE XREF: sub_482C20+149j
    mov     ecx, [esi+8]
    xor     eax, eax
    cmp     ecx, ebp
    jbe     short loc_482DC0

    loc_482D9A:                             ; CODE XREF: sub_482C20+198j
    lea     ecx, [eax+1]
    mov     eax, [esi+4]
    imul    eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, [esi]
    lea     eax, [eax+edx*2-8]
    mov     edx, [eax]
    or      edx, 8
    mov     [eax], edx
    mov     eax, ecx
    cmp     eax, [esi+8]
    jb      short loc_482D9A
    mov     edi, TAdynmemStructPtr

    loc_482DC0:                             ; CODE XREF: sub_482C20+178j
    mov     ecx, [esi+0Ch]
    xor     eax, eax
    cmp     ecx, ebp
    jle     short loc_482DE8
    xor     ecx, ecx

    loc_482DCB:                             ; CODE XREF: sub_482C20+1C6j
    mov     ebp, [esi]
    mov     dl, [edi+1427Fh]
    inc     eax
    mov     [ebp+ecx+0], dl
    mov     edx, [esi+0Ch]
    mov     edi, TAdynmemStructPtr
    add     ecx, 0Ah
    cmp     eax, edx
    jl      short loc_482DCB

    loc_482DE8:                             ; CODE XREF: sub_482C20+1A7j
    mov     eax, [edi+14237h]
    xor     ebp, ebp
    test    eax, eax
    jle     short loc_482E53

    loc_482DF4:                             ; CODE XREF: sub_482C20+231j
    mov     eax, [edi+14233h]
    mov     edx, [esp+28h+var_14]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_482E2D

    loc_482E04:                             ; CODE XREF: sub_482C20+20Bj
    mov     al, [ebx+5]
    cmp     al, [edx]
    jbe     short loc_482E13
    mov     [edx], al
    mov     edi, TAdynmemStructPtr

    loc_482E13:                             ; CODE XREF: sub_482C20+1E9j
    mov     eax, ecx
    and     eax, 7
    cmp     al, 7
    jnz     short loc_482E1F
    add     edx, 0Ah

    loc_482E1F:                             ; CODE XREF: sub_482C20+1FAj
    mov     eax, [edi+14233h]
    inc     ecx
    add     ebx, 0Dh
    cmp     ecx, eax
    jl      short loc_482E04

    loc_482E2D:                             ; CODE XREF: sub_482C20+1E2j
    mov     ecx, ebp
    and     ecx, 7
    cmp     cl, 7
    jnz     short loc_482E48
    mov     eax, [esi+4]
    lea     edx, [eax+eax*4]
    mov     eax, [esp+28h+var_14]
    lea     ecx, [eax+edx*2]
    mov     [esp+28h+var_14], ecx

    loc_482E48:                             ; CODE XREF: sub_482C20+215j
    mov     eax, [edi+14237h]
    inc     ebp
    cmp     ebp, eax
    jl      short loc_482DF4

    loc_482E53:                             ; CODE XREF: sub_482C20+1D2j
    mov     eax, [esi+8]
    xor     ebp, ebp
    test    eax, eax
    jbe     short loc_482EAB

    loc_482E5C:                             ; CODE XREF: sub_482C20+283j
    mov     edx, [esi+4]
    mov     eax, ebp
    imul    eax, edx
    mov     ecx, [esi]
    mov     edi, 1
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*2]
    xor     cl, cl
    cmp     edx, edi
    jbe     short loc_482E9A

    loc_482E77:                             ; CODE XREF: sub_482C20+278j
    mov     dl, [eax+0Ah]
    mov     bl, cl
    mov     cl, [eax]
    cmp     cl, dl
    ja      short loc_482E84
    mov     cl, dl

    loc_482E84:                             ; CODE XREF: sub_482C20+260j
    cmp     bl, cl
    mov     dl, bl
    ja      short loc_482E8C
    mov     dl, cl

    loc_482E8C:                             ; CODE XREF: sub_482C20+268j
    mov     [eax+1], dl
    mov     edx, [esi+4]
    inc     edi
    add     eax, 0Ah
    cmp     edi, edx
    jb      short loc_482E77

    loc_482E9A:                             ; CODE XREF: sub_482C20+255j
    mov     [eax+1], cl
    mov     eax, [esi+8]
    inc     ebp
    cmp     ebp, eax
    jb      short loc_482E5C
    mov     edi, TAdynmemStructPtr

    loc_482EAB:                             ; CODE XREF: sub_482C20+23Aj
    mov     eax, [esi+4]
    mov     [esp+28h+var_18], 0
    test    eax, eax
    jbe     short loc_482F1B
    xor     ebp, ebp

    loc_482EBC:                             ; CODE XREF: sub_482C20+2F3j
    mov     ecx, [esi]
    mov     ebx, [esi+8]
    mov     edi, 1
    add     ecx, ebp
    xor     dl, dl
    cmp     ebx, edi
    jbe     short loc_482EFF
    lea     eax, [eax+eax*4]
    shl     eax, 1

    loc_482ED3:                             ; CODE XREF: sub_482C20+2DDj
    mov     al, [ecx+eax+1]
    mov     bl, dl
    mov     dl, [ecx+1]
    cmp     dl, al
    ja      short loc_482EE2
    mov     dl, al

    loc_482EE2:                             ; CODE XREF: sub_482C20+2BEj
    cmp     bl, dl
    mov     al, bl
    ja      short loc_482EEA
    mov     al, dl

    loc_482EEA:                             ; CODE XREF: sub_482C20+2C6j
    mov     [ecx+1], al
    mov     eax, [esi+4]
    mov     ebx, [esi+8]
    inc     edi
    lea     eax, [eax+eax*4]
    shl     eax, 1
    add     ecx, eax
    cmp     edi, ebx
    jb      short loc_482ED3

    loc_482EFF:                             ; CODE XREF: sub_482C20+2ACj
    mov     [ecx+1], dl
    mov     ecx, [esp+28h+var_18]
    mov     eax, [esi+4]
    inc     ecx
    add     ebp, 0Ah
    cmp     ecx, eax
    mov     [esp+28h+var_18], ecx
    jb      short loc_482EBC
    mov     edi, TAdynmemStructPtr

    loc_482F1B:                             ; CODE XREF: sub_482C20+298j
    mov     eax, [edi+14237h]
    lea     ebx, [edi+1428Fh]
    cdq
    sub     eax, edx
    mov     [esp+28h+var_14], ebx
    mov     esi, eax
    mov     eax, [edi+14233h]
    cdq
    sub     eax, edx
    mov     edx, [ebx]
    mov     edi, eax
    push    edx
    sar     esi, 1
    sar     edi, 1
    mov     [ebx+4], edi
    mov     [ebx+8], esi
    call    sub_4B4F20
    imul    esi, edi
    add     esi, 7
    add     esp, 4
    and     esi, 0FFFFFFF8h
    mov     [ebx+0Ch], esi
    jz      short loc_482F6C
    lea     eax, [esi+esi]
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    jmp     short loc_482F6E
    ; ---------------------------------------------------------------------------

    loc_482F6C:                             ; CODE XREF: sub_482C20+33Cj
    xor     eax, eax

    loc_482F6E:                             ; CODE XREF: sub_482C20+34Aj
    mov     ecx, [ebx+0Ch]
    xor     esi, esi
    mov     [ebx], eax
    xor     eax, eax
    cmp     ecx, esi
    jle     short loc_482F92
    mov     cl, 0FFh

    loc_482F7D:                             ; CODE XREF: sub_482C20+370j
    mov     edx, [ebx]
    inc     eax
    mov     byte ptr [edx+eax*2-2], 0
    mov     edx, [ebx]
    mov     [edx+eax*2-1], cl
    mov     edx, [ebx+0Ch]
    cmp     eax, edx
    jl      short loc_482F7D

    loc_482F92:                             ; CODE XREF: sub_482C20+359j
    mov     ebp, TAdynmemStructPtr
    xor     ecx, ecx
    mov     [esp+28h+var_18], ecx
    cmp     [ebp+14233h], esi
    jle     loc_483189

    loc_482FAA:                             ; CODE XREF: sub_482C20+563j
    lea     eax, [ecx-1]
    xor     edi, edi
    sar     eax, 1
    mov     [esp+28h+var_8], eax
    mov     eax, ecx
    sar     eax, 1
    mov     [esp+28h+var_4], eax
    mov     eax, [ebp+14237h]
    cmp     eax, esi
    mov     [esp+28h+var_10], esi
    jle     loc_483176
    mov     [esp+28h+var_C], esi

    loc_482FD3:                             ; CODE XREF: sub_482C20+54Aj
    mov     eax, [ebp+14233h]
    mov     ebx, [esp+28h+var_18]
    imul    eax, [esp+28h+var_10]
    add     eax, ebx
    xor     ebx, ebx
    lea     ecx, [eax+eax*2]
    lea     edx, [eax+ecx*4]
    mov     eax, [ebp+14287h]
    mov     bl, [edx+eax+4]
    mov     edx, [esp+28h+var_C]
    mov     ecx, ebx
    sar     ecx, 1
    sub     edx, ecx
    mov     ecx, edx
    sar     ecx, 5
    cmp     ecx, 0FFFFFFFFh
    jle     loc_4830F9
    mov     eax, ecx
    lea     ebp, [edx+1Fh]
    shl     eax, 5
    add     eax, 1Fh
    imul    eax, ebx
    cdq
    idiv    ebp
    test    esi, esi
    jz      short loc_483046
    xor     edx, edx
    mov     dl, [esi]
    mov     ebp, edx
    cmp     ebp, eax
    jg      short loc_48302F
    mov     edx, eax

    loc_48302F:                             ; CODE XREF: sub_482C20+40Bj
    mov     [esi], dl
    xor     edx, edx
    mov     dl, [esi+1]
    cmp     edx, eax
    jge     short loc_483041
    xor     edx, edx
    mov     dl, [esi+1]
    jmp     short loc_483043
    ; ---------------------------------------------------------------------------

    loc_483041:                             ; CODE XREF: sub_482C20+418j
    mov     edx, eax

    loc_483043:                             ; CODE XREF: sub_482C20+41Fj
    mov     [esi+1], dl

    loc_483046:                             ; CODE XREF: sub_482C20+401j
    test    edi, edi
    jz      short loc_48306D
    xor     edx, edx
    mov     dl, [edi]
    mov     esi, edx
    cmp     esi, eax
    jg      short loc_483056
    mov     edx, eax

    loc_483056:                             ; CODE XREF: sub_482C20+432j
    mov     [edi], dl
    xor     edx, edx
    mov     dl, [edi+1]
    cmp     edx, eax
    jge     short loc_483068
    xor     edx, edx
    mov     dl, [edi+1]
    jmp     short loc_48306A
    ; ---------------------------------------------------------------------------

    loc_483068:                             ; CODE XREF: sub_482C20+43Fj
    mov     edx, eax

    loc_48306A:                             ; CODE XREF: sub_482C20+446j
    mov     [edi+1], dl

    loc_48306D:                             ; CODE XREF: sub_482C20+428j
    mov     edi, [esp+28h+var_14]
    mov     esi, [esp+28h+var_8]
    mov     edx, [edi+4]
    cmp     esi, edx
    jnb     short loc_4830B1
    cmp     ecx, [edi+8]
    jnb     short loc_4830B1
    mov     ebp, ecx
    imul    ebp, edx
    mov     edx, [edi]
    add     ebp, esi
    lea     esi, [edx+ebp*2]
    xor     edx, edx
    mov     dl, [esi]
    mov     edi, edx
    cmp     edi, eax
    jg      short loc_483099
    mov     edx, eax

    loc_483099:                             ; CODE XREF: sub_482C20+475j
    mov     [esi], dl
    xor     edx, edx
    mov     dl, [esi+1]
    mov     edi, edx
    cmp     edi, eax
    jl      short loc_4830A8
    mov     edx, eax

    loc_4830A8:                             ; CODE XREF: sub_482C20+484j
    mov     edi, [esp+28h+var_14]
    mov     [esi+1], dl
    jmp     short loc_4830B3
    ; ---------------------------------------------------------------------------

    loc_4830B1:                             ; CODE XREF: sub_482C20+45Aj
                                            ; sub_482C20+45Fj
    xor     esi, esi

    loc_4830B3:                             ; CODE XREF: sub_482C20+48Fj
    mov     ebp, [esp+28h+var_4]
    mov     edx, [esp+28h+var_8]
    cmp     edx, ebp
    jz      short loc_4830F1
    mov     edx, [edi+4]
    cmp     ebp, edx
    jnb     short loc_4830F1
    cmp     ecx, [edi+8]
    jnb     short loc_4830F1
    imul    ecx, edx
    mov     edx, [edi]
    add     ecx, ebp
    lea     edi, [edx+ecx*2]
    xor     ecx, ecx
    mov     cl, [edi]
    cmp     ecx, eax
    jg      short loc_4830DF
    mov     ecx, eax

    loc_4830DF:                             ; CODE XREF: sub_482C20+4BBj
    mov     [edi], cl
    xor     ecx, ecx
    mov     cl, [edi+1]
    cmp     ecx, eax
    jge     short loc_4830EC
    mov     eax, ecx

    loc_4830EC:                             ; CODE XREF: sub_482C20+4C8j
    mov     [edi+1], al
    jmp     short loc_4830F3
    ; ---------------------------------------------------------------------------

    loc_4830F1:                             ; CODE XREF: sub_482C20+49Dj
                                            ; sub_482C20+4A4j ...
    xor     edi, edi

    loc_4830F3:                             ; CODE XREF: sub_482C20+4CFj
    mov     ebp, TAdynmemStructPtr

    loc_4830F9:                             ; CODE XREF: sub_482C20+3E8j
    test    esi, esi
    jz      short loc_483124
    xor     eax, eax
    mov     al, [esi]
    cmp     eax, ebx
    jg      short loc_483107
    mov     eax, ebx

    loc_483107:                             ; CODE XREF: sub_482C20+4E3j
    mov     [esi], al
    xor     eax, eax
    mov     al, [esi+1]
    cmp     eax, ebx
    jge     short loc_483119
    xor     eax, eax
    mov     al, [esi+1]
    jmp     short loc_48311B
    ; ---------------------------------------------------------------------------

    loc_483119:                             ; CODE XREF: sub_482C20+4F0j
    mov     eax, ebx

    loc_48311B:                             ; CODE XREF: sub_482C20+4F7j
    mov     [esi+1], al
    mov     ebp, TAdynmemStructPtr

    loc_483124:                             ; CODE XREF: sub_482C20+4DBj
    test    edi, edi
    jz      short loc_48314E
    xor     eax, eax
    mov     al, [edi]
    cmp     eax, ebx
    jg      short loc_483132
    mov     eax, ebx

    loc_483132:                             ; CODE XREF: sub_482C20+50Ej
    xor     ecx, ecx
    mov     [edi], al
    mov     cl, [edi+1]
    cmp     ecx, ebx
    jge     short loc_483143
    xor     eax, eax
    mov     al, cl
    jmp     short loc_483145
    ; ---------------------------------------------------------------------------

    loc_483143:                             ; CODE XREF: sub_482C20+51Bj
    mov     eax, ebx

    loc_483145:                             ; CODE XREF: sub_482C20+521j
    mov     [edi+1], al
    mov     ebp, TAdynmemStructPtr

    loc_48314E:                             ; CODE XREF: sub_482C20+506j
    mov     eax, [esp+28h+var_10]
    mov     edx, [esp+28h+var_C]
    mov     ecx, [ebp+14237h]
    inc     eax
    add     edx, 10h
    cmp     eax, ecx
    mov     [esp+28h+var_10], eax
    mov     [esp+28h+var_C], edx
    jl      loc_482FD3
    mov     ecx, [esp+28h+var_18]
    xor     esi, esi

    loc_483176:                             ; CODE XREF: sub_482C20+3A9j
    mov     eax, [ebp+14233h]
    inc     ecx
    cmp     ecx, eax
    mov     [esp+28h+var_18], ecx
    jl      loc_482FAA

    loc_483189:                             ; CODE XREF: sub_482C20+384j
    mov     eax, [esp+28h+var_14]
    xor     edx, edx
    mov     dl, [ebp+1427Fh]
    mov     [esp+28h+var_C], 0
    mov     ecx, [eax+0Ch]
    mov     ebp, edx
    test    ecx, ecx
    jle     short loc_483207

    loc_4831A6:                             ; CODE XREF: sub_482C20+5E5j
    mov     ecx, [esp+28h+var_14]
    mov     eax, [esp+28h+var_C]
    mov     edx, [ecx]
    lea     ecx, [edx+eax*2]
    xor     edx, edx
    xor     eax, eax
    mov     dl, [ecx]
    mov     al, [ecx+1]
    mov     esi, edx
    mov     edi, eax
    mov     eax, 55555556h
    lea     edx, [edi+esi*2]
    imul    edx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 55555556h
    mov     ebx, edx
    lea     edx, [esi+edi*2]
    imul    edx
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     ebx, ebp
    jg      short loc_4831EA
    mov     ebx, ebp

    loc_4831EA:                             ; CODE XREF: sub_482C20+5C6j
    cmp     edx, ebp
    mov     [ecx], bl
    jg      short loc_4831F2
    mov     edx, ebp

    loc_4831F2:                             ; CODE XREF: sub_482C20+5CEj
    mov     eax, [esp+28h+var_C]
    mov     [ecx+1], dl
    mov     ecx, [esp+28h+var_14]
    inc     eax
    mov     [esp+28h+var_C], eax
    cmp     eax, [ecx+0Ch]
    jl      short loc_4831A6

    loc_483207:                             ; CODE XREF: sub_482C20+584j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn
    sub_482C20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_483210 proc near                    ; CODE XREF: sub_47CC30+270p
                                            ; sub_47D0E0+FFp ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    mov     ecx, TAdynmemStructPtr
    push    ebx
    movsx   edx, word ptr [esp+1Ch+arg_4]
    mov     eax, [ecx+14237h]
    push    ebp
    mov     [esp+20h+var_14], eax
    mov     ax, word ptr [esp+20h+arg_0]
    movsx   ebp, ax
    mov     ebx, [ecx+14233h]
    add     ebp, edx
    mov     dx, word ptr [esp+20h+arg_0+2]
    push    esi
    movsx   esi, word ptr [esp+24h+arg_4+2]
    push    edi
    mov     [esp+28h+var_C], ebx
    movsx   edi, dx
    add     edi, esi
    test    ax, ax
    mov     [esp+28h+arg_0], edi
    jge     short loc_48325B
    xor     ax, ax

    loc_48325B:                             ; CODE XREF: sub_483210+46j
    test    dx, dx
    jge     short loc_483263
    xor     dx, dx

    loc_483263:                             ; CODE XREF: sub_483210+4Ej
    cmp     ebp, ebx
    jl      short loc_48326A
    lea     ebp, [ebx-1]

    loc_48326A:                             ; CODE XREF: sub_483210+55j
    mov     esi, [esp+28h+var_14]
    cmp     edi, esi
    jl      short loc_483279
    dec     esi
    mov     [esp+28h+arg_0], esi
    mov     edi, esi

    loc_483279:                             ; CODE XREF: sub_483210+60j
    movsx   esi, ax
    cmp     esi, ebp
    mov     [esp+28h+var_4], esi
    jge     loc_483361
    movsx   eax, dx
    cmp     eax, edi
    jge     loc_483361
    mov     edx, eax
    cmp     edx, edi
    mov     [esp+28h+arg_4], edx
    jge     loc_483361
    lea     eax, [ebx+ebx*2]
    lea     eax, [ebx+eax*4]
    mov     [esp+28h+var_18], eax
    mov     eax, edx
    imul    eax, ebx
    add     eax, esi
    lea     ebx, [eax+eax*2]
    lea     ebx, [eax+ebx*4]
    mov     [esp+28h+var_10], ebx

    loc_4832BC:                             ; CODE XREF: sub_483210+14Bj
    mov     eax, [ecx+14287h]
    add     eax, ebx
    cmp     esi, ebp
    jge     short loc_483346
    mov     edx, [esp+28h+var_14]
    mov     ecx, [esp+28h+var_C]
    dec     edx
    lea     edi, [ecx-1]
    mov     [esp+28h+var_8], edx

    loc_4832D8:                             ; CODE XREF: sub_483210+122j
    mov     cl, [eax+4]
    cmp     esi, edi
    mov     bl, cl
    jge     short loc_4832F0
    mov     dl, [eax+11h]
    cmp     dl, cl
    jnb     short loc_4832EA
    mov     cl, dl

    loc_4832EA:                             ; CODE XREF: sub_483210+D6j
    cmp     dl, bl
    jbe     short loc_4832F0
    mov     bl, dl

    loc_4832F0:                             ; CODE XREF: sub_483210+CFj
                                            ; sub_483210+DCj
    mov     edx, [esp+28h+var_8]
    cmp     [esp+28h+arg_4], edx
    jge     short loc_483326
    mov     edx, [esp+28h+var_18]
    mov     dl, [eax+edx+4]
    cmp     dl, cl
    jnb     short loc_483308
    mov     cl, dl

    loc_483308:                             ; CODE XREF: sub_483210+F4j
    cmp     dl, bl
    jbe     short loc_48330E
    mov     bl, dl

    loc_48330E:                             ; CODE XREF: sub_483210+FAj
    cmp     esi, edi
    jge     short loc_483326
    mov     edx, [esp+28h+var_18]
    mov     dl, [eax+edx+11h]
    cmp     dl, cl
    jnb     short loc_483320
    mov     cl, dl

    loc_483320:                             ; CODE XREF: sub_483210+10Cj
    cmp     dl, bl
    jbe     short loc_483326
    mov     bl, dl

    loc_483326:                             ; CODE XREF: sub_483210+E8j
                                            ; sub_483210+100j ...
    mov     [eax+6], cl
    mov     [eax+5], bl
    inc     esi
    add     eax, 0Dh
    cmp     esi, ebp
    jl      short loc_4832D8
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+28h+arg_4]
    mov     esi, [esp+28h+var_4]
    mov     edi, [esp+28h+arg_0]

    loc_483346:                             ; CODE XREF: sub_483210+B6j
    mov     ebx, [esp+28h+var_10]
    mov     eax, [esp+28h+var_18]
    inc     edx
    add     ebx, eax
    cmp     edx, edi
    mov     [esp+28h+arg_4], edx
    mov     [esp+28h+var_10], ebx
    jl      loc_4832BC

    loc_483361:                             ; CODE XREF: sub_483210+72j
                                            ; sub_483210+7Dj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    sub_483210 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 8
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+14233h]
    mov     dx, [eax+14237h]
    xor     eax, eax
    mov     [esp+0], cx
    mov     [esp+2], dx
    mov     [esp+4], ax
    mov     [esp+6], ax
    mov     eax, [esp+0]
    mov     ecx, [esp+4]
    push    eax
    push    ecx
    call    sub_483210
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4833B0 proc near                    ; CODE XREF: sub_483610+6E1p
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+14223h]
    push    edi
    sub     ecx, 20h
    xor     esi, esi
    mov     [eax+1422Bh], ecx
    mov     eax, TAdynmemStructPtr
    mov     ebp, 0FFFDh
    mov     edx, [eax+14227h]
    sub     edx, 80h
    mov     [eax+1422Fh], edx
    mov     ecx, TAdynmemStructPtr
    mov     edi, [ecx+14233h]
    mov     eax, [ecx+14237h]
    sub     edi, 2
    test    eax, eax
    jle     short loc_483471

    loc_4833FF:                             ; CODE XREF: sub_4833B0+BFj
    test    edi, edi
    jl      short loc_48342C
    mov     edx, [ecx+14233h]
    cmp     edi, edx
    jge     short loc_48342C
    test    esi, esi
    jl      short loc_48342C
    cmp     esi, eax
    jge     short loc_48342C
    mov     eax, esi
    imul    eax, edx
    add     eax, edi
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    mov     edx, [ecx+14287h]
    add     eax, edx
    jmp     short loc_48342E
    ; ---------------------------------------------------------------------------

    loc_48342C:                             ; CODE XREF: sub_4833B0+51j
                                            ; sub_4833B0+5Bj ...
    xor     eax, eax

    loc_48342E:                             ; CODE XREF: sub_4833B0+7Aj
    mov     dx, [eax+8]
    cmp     dx, 0FFFFh
    jz      short loc_483440
    cmp     dx, 0FFFEh
    jnz     short loc_48344A

    loc_483440:                             ; CODE XREF: sub_4833B0+87j
    mov     [eax+8], bp
    mov     ecx, TAdynmemStructPtr

    loc_48344A:                             ; CODE XREF: sub_4833B0+8Ej
    mov     dx, [eax+15h]
    cmp     dx, 0FFFFh
    jz      short loc_48345C
    cmp     dx, 0FFFEh
    jnz     short loc_483466

    loc_48345C:                             ; CODE XREF: sub_4833B0+A3j
    mov     [eax+15h], bp
    mov     ecx, TAdynmemStructPtr

    loc_483466:                             ; CODE XREF: sub_4833B0+AAj
    mov     eax, [ecx+14237h]
    inc     esi
    cmp     esi, eax
    jl      short loc_4833FF

    loc_483471:                             ; CODE XREF: sub_4833B0+4Dj
    mov     eax, [ecx+14233h]
    xor     esi, esi
    test    eax, eax
    jle     short loc_4834F5

    loc_48347D:                             ; CODE XREF: sub_4833B0+13Ej
    xor     edi, edi
    xor     ebp, ebp

    loc_483481:                             ; CODE XREF: sub_4833B0+133j
    test    esi, esi
    jl      short loc_4834B2
    mov     edx, [ecx+14233h]
    cmp     esi, edx
    jge     short loc_4834B2
    test    ebp, ebp
    jl      short loc_4834B2
    cmp     edi, [ecx+14237h]
    jge     short loc_4834B2
    mov     eax, edi
    imul    eax, edx
    add     eax, esi
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    mov     edx, [ecx+14287h]
    add     eax, edx
    jmp     short loc_4834B4
    ; ---------------------------------------------------------------------------

    loc_4834B2:                             ; CODE XREF: sub_4833B0+D3j
                                            ; sub_4833B0+DDj ...
    xor     eax, eax

    loc_4834B4:                             ; CODE XREF: sub_4833B0+100j
    xor     edx, edx
    mov     ebx, ebp
    mov     dl, [eax+4]
    shr     edx, 1
    sub     ebx, edx
    jns     short loc_4834E5
    mov     dx, [eax+8]
    cmp     dx, 0FFFFh
    jz      short loc_4834D3
    cmp     dx, 0FFFEh
    jnz     short loc_4834DF

    loc_4834D3:                             ; CODE XREF: sub_4833B0+11Aj
    mov     word ptr [eax+8], 0FFFDh
    mov     ecx, TAdynmemStructPtr

    loc_4834DF:                             ; CODE XREF: sub_4833B0+121j
    inc     edi
    add     ebp, 10h
    jmp     short loc_483481
    ; ---------------------------------------------------------------------------

    loc_4834E5:                             ; CODE XREF: sub_4833B0+10Fj
    mov     eax, [ecx+14233h]
    inc     esi
    cmp     esi, eax
    jl      short loc_48347D
    mov     ebp, 0FFFDh

    loc_4834F5:                             ; CODE XREF: sub_4833B0+CBj
    mov     eax, [ecx+14233h]
    xor     edi, edi
    test    eax, eax
    jle     loc_48359F

    loc_483505:                             ; CODE XREF: sub_4833B0+1E4j
    mov     esi, [ecx+14237h]
    dec     esi
    mov     ebp, esi
    shl     ebp, 4

    loc_483511:                             ; CODE XREF: sub_4833B0+1D9j
    test    edi, edi
    jl      short loc_483542
    mov     edx, [ecx+14233h]
    cmp     edi, edx
    jge     short loc_483542
    test    esi, esi
    jl      short loc_483542
    cmp     esi, [ecx+14237h]
    jge     short loc_483542
    mov     eax, esi
    imul    eax, edx
    add     eax, edi
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    mov     edx, [ecx+14287h]
    add     eax, edx
    jmp     short loc_483544
    ; ---------------------------------------------------------------------------

    loc_483542:                             ; CODE XREF: sub_4833B0+163j
                                            ; sub_4833B0+16Dj ...
    xor     eax, eax

    loc_483544:                             ; CODE XREF: sub_4833B0+190j
    xor     edx, edx
    mov     ebx, ebp
    mov     dl, [eax+4]
    shr     edx, 1
    sub     ebx, edx
    mov     edx, [ecx+1422Fh]
    cmp     ebx, edx
    jle     short loc_48358B
    mov     edx, [ecx+14233h]
    lea     ebx, [edx+edx*2]
    lea     edx, [edx+ebx*4]
    sub     eax, edx
    mov     dx, [eax+8]
    cmp     dx, 0FFFFh
    jz      short loc_483579
    cmp     dx, 0FFFEh
    jnz     short loc_483585

    loc_483579:                             ; CODE XREF: sub_4833B0+1C0j
    mov     word ptr [eax+8], 0FFFDh
    mov     ecx, TAdynmemStructPtr

    loc_483585:                             ; CODE XREF: sub_4833B0+1C7j
    dec     esi
    sub     ebp, 10h
    jmp     short loc_483511
    ; ---------------------------------------------------------------------------

    loc_48358B:                             ; CODE XREF: sub_4833B0+1A7j
    mov     eax, [ecx+14233h]
    inc     edi
    cmp     edi, eax
    jl      loc_483505
    mov     ebp, 0FFFDh

    loc_48359F:                             ; CODE XREF: sub_4833B0+14Fj
    mov     eax, [ecx+391E9h]
    mov     edx, [eax+0D44h]
    test    edx, edx
    jz      short loc_483600
    mov     edx, [ecx+14233h]
    mov     eax, [ecx+14287h]
    imul    edx, [ecx+14237h]
    mov     edi, eax
    lea     esi, [edx+edx*2]
    add     edi, edx
    lea     esi, [edi+esi*4]
    cmp     eax, esi
    jnb     short loc_483600

    loc_4835D0:                             ; CODE XREF: sub_4833B0+24Ej
    mov     dl, [eax+6]
    mov     bl, [ecx+1427Fh]
    cmp     dl, bl
    ja      short loc_4835F9
    mov     dx, [eax+8]
    cmp     dx, 0FFFFh
    jz      short loc_4835EF
    cmp     dx, 0FFFEh
    jnz     short loc_4835F9

    loc_4835EF:                             ; CODE XREF: sub_4833B0+236j
    mov     [eax+8], bp
    mov     ecx, TAdynmemStructPtr

    loc_4835F9:                             ; CODE XREF: sub_4833B0+22Bj
                                            ; sub_4833B0+23Dj
    add     eax, 0Dh
    cmp     eax, esi
    jb      short loc_4835D0

    loc_483600:                             ; CODE XREF: sub_4833B0+1FDj
                                            ; sub_4833B0+21Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4833B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_483610 proc near                    ; CODE XREF: sub_4917D0+F0p

    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= word ptr -54h
    var_52= word ptr -52h
    var_50= byte ptr -50h
    var_4F= byte ptr -4Fh
    var_4E= byte ptr -4Eh
    var_4D= byte ptr -4Dh
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    Text= dword ptr -40h

    sub     esp, 0A4h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+391E9h]
    push    edi
    push    1
    lea     ebp, [eax+141FBh]
    call    sub_4356C0
    push    eax
    call    sub_429660
    mov     ebx, eax
    mov     eax, [ebx]
    cmp     eax, 1020h
    mov     [esp+0B4h+var_9C], eax
    jz      loc_483701
    cmp     eax, 2000h
    jz      short loc_483678
    push    eax
    lea     eax, [esp+0B8h+Text]
    push    offset aUnknownTntVers          ; "Unknown TNT version:  0x%08x"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+0B4h+Text]
    push    ecx                             ; lpText
    call    sub_4B6290
    mov     eax, [esp+0B4h+var_9C]
    jmp     loc_483788
    ; ---------------------------------------------------------------------------

    loc_483678:                             ; CODE XREF: sub_483610+40j
    mov     edx, [ebx+4]
    xor     esi, esi
    mov     [esp+0B4h+var_98], edx
    mov     ecx, [ebx+8]
    mov     [esp+0B4h+var_94], ecx
    mov     edx, [ebx+24h]
    mov     [esp+0B4h+var_90], edx
    mov     [esp+0B4h+var_84], esi
    mov     [esp+0B4h+var_8C], 64h
    mov     [esp+0B4h+var_88], 7D0h
    mov     ecx, [ebx+1Ch]
    mov     [esp+0B4h+var_80], ecx
    mov     edx, [ebx+20h]
    add     edx, ebx
    mov     [esp+0B4h+var_7C], edx
    mov     ecx, [ebx+18h]
    mov     [esp+0B4h+var_74], ecx
    mov     edx, [ebx+14h]
    add     edx, ebx
    mov     [esp+0B4h+var_78], edx
    mov     ecx, [ebx+0Ch]
    add     ecx, ebx
    mov     [esp+0B4h+var_70], ecx
    mov     edx, [ebx+10h]
    mov     ecx, [esp+0B4h+var_60]
    add     edx, ebx
    mov     [esp+0B4h+var_68], edx
    mov     [esp+0B4h+var_6C], esi
    mov     [esp+0B4h+var_64], 0FFFBh
    mov     edx, [ebx+2Ch]
    xor     edx, ecx
    and     edx, 1
    xor     ecx, edx
    mov     [esp+0B4h+var_60], ecx
    mov     ecx, [ebx+28h]
    add     ecx, ebx
    mov     [esp+0B4h+var_5C], ecx
    jmp     loc_48378A
    ; ---------------------------------------------------------------------------

    loc_483701:                             ; CODE XREF: sub_483610+35j
    mov     edx, [ebx+4]
    mov     [esp+0B4h+var_98], edx
    mov     ecx, [ebx+8]
    mov     [esp+0B4h+var_94], ecx
    mov     edx, [ebx+24h]
    mov     [esp+0B4h+var_90], edx
    mov     ecx, [ebx+34h]
    mov     [esp+0B4h+var_84], ecx
    mov     edx, [ebx+28h]
    mov     [esp+0B4h+var_8C], edx
    mov     ecx, [ebx+2Ch]
    mov     [esp+0B4h+var_88], ecx
    mov     edx, [ebx+1Ch]
    mov     [esp+0B4h+var_80], edx
    mov     ecx, [ebx+20h]
    add     ecx, ebx
    mov     [esp+0B4h+var_7C], ecx
    mov     edx, [ebx+18h]
    mov     [esp+0B4h+var_74], edx
    mov     ecx, [ebx+14h]
    add     ecx, ebx
    mov     [esp+0B4h+var_78], ecx
    mov     edx, [ebx+0Ch]
    add     edx, ebx
    mov     [esp+0B4h+var_70], edx
    mov     ecx, [ebx+10h]
    add     ecx, ebx
    mov     [esp+0B4h+var_68], 0
    mov     [esp+0B4h+var_6C], ecx
    mov     ecx, [esp+0B4h+var_60]
    mov     [esp+0B4h+var_64], 0FCh
    mov     edx, [ebx+3Ch]
    xor     edx, ecx
    and     edx, 1
    xor     ecx, edx
    mov     [esp+0B4h+var_60], ecx
    mov     ecx, [ebx+38h]
    add     ecx, ebx
    mov     [esp+0B4h+var_5C], ecx

    loc_483788:                             ; CODE XREF: sub_483610+63j
    xor     esi, esi

    loc_48378A:                             ; CODE XREF: sub_483610+ECj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    mov     ecx, [ecx+0D34h]
    cmp     ecx, esi
    jl      short loc_4837AC
    cmp     eax, 2000h
    jl      short loc_4837AC
    mov     [ebp+60h], ecx
    jmp     short loc_4837B3
    ; ---------------------------------------------------------------------------

    loc_4837AC:                             ; CODE XREF: sub_483610+18Ej
                                            ; sub_483610+195j
    mov     edx, [esp+0B4h+var_8C]
    mov     [ebp+60h], edx

    loc_4837B3:                             ; CODE XREF: sub_483610+19Aj
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    mov     eax, [ecx+0D38h]
    cmp     eax, esi
    jl      short loc_4837D7
    cmp     [esp+0B4h+var_9C], 2000h
    jl      short loc_4837D7
    mov     [ebp+64h], eax
    jmp     short loc_4837DE
    ; ---------------------------------------------------------------------------

    loc_4837D7:                             ; CODE XREF: sub_483610+1B6j
                                            ; sub_483610+1C0j
    mov     edx, [esp+0B4h+var_88]
    mov     [ebp+64h], edx

    loc_4837DE:                             ; CODE XREF: sub_483610+1C5j
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    mov     eax, [ecx+0D3Ch]
    cmp     eax, esi
    mov     [esp+0B4h+var_A4], eax
    jl      short loc_48381B
    cmp     [esp+0B4h+var_9C], 2000h
    jl      short loc_48381B
    fild    [esp+0B4h+var_A4]
    fmul    ds:dbl_4FD680
    fmul    ds:dbl_4FD688
    call    __ftol
    mov     [ebp+68h], eax
    jmp     short loc_483842
    ; ---------------------------------------------------------------------------

    loc_48381B:                             ; CODE XREF: sub_483610+1E5j
                                            ; sub_483610+1EFj
    cmp     [esp+0B4h+var_84], esi
    jz      short loc_48383B
    fild    [esp+0B4h+var_84]
    fmul    ds:dbl_4FD680
    fmul    ds:dbl_4FD688
    call    __ftol
    mov     [ebp+68h], eax
    jmp     short loc_483842
    ; ---------------------------------------------------------------------------

    loc_48383B:                             ; CODE XREF: sub_483610+20Fj
    mov     dword ptr [ebp+68h], 1FDBh

    loc_483842:                             ; CODE XREF: sub_483610+209j
                                            ; sub_483610+229j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    fld     dword ptr [ecx+0D40h]
    fcomp   ds:flt_4FD690
    fnstsw  ax
    test    ah, 1
    jnz     short loc_48386C
    mov     eax, [ecx+0D40h]
    mov     [ebp+6Ch], eax
    jmp     short loc_483873
    ; ---------------------------------------------------------------------------

    loc_48386C:                             ; CODE XREF: sub_483610+24Fj
    mov     dword ptr [ebp+6Ch], 3F000000h

    loc_483873:                             ; CODE XREF: sub_483610+25Aj
    mov     cl, byte ptr [esp+0B4h+var_90]
    mov     [ebp+84h], cl
    mov     edx, [esp+0B4h+var_98]
    mov     [ebp+38h], edx
    mov     eax, [esp+0B4h+var_94]
    mov     ecx, edx
    mov     edx, eax
    shl     ecx, 4
    shl     edx, 4
    mov     [ebp+3Ch], eax
    mov     [ebp+28h], ecx
    mov     [ebp+2Ch], edx
    mov     al, byte ptr [esp+0B4h+var_60]
    test    al, 1
    jz      loc_483930
    mov     eax, [esp+0B4h+var_5C]
    mov     cx, [eax]
    mov     word ptr [esp+0B4h+var_58], cx
    mov     dx, [eax+4]
    lea     ecx, [eax+8]
    mov     word ptr [esp+0B4h+var_58+2], dx
    mov     [esp+0B4h+var_54], si
    mov     [esp+0B4h+var_52], si
    mov     [esp+0B4h+var_50], 0
    mov     [esp+0B4h+var_4F], 0
    mov     [esp+0B4h+var_4E], 0
    mov     [esp+0B4h+var_4D], 0
    mov     [esp+0B4h+var_4C], esi
    mov     [esp+0B4h+var_48], ecx
    mov     [esp+0B4h+var_44], esi
    mov     edx, [eax+4]
    mov     eax, [eax]
    push    edx
    push    eax
    push    offset aTedGeneratedPi          ; "TED GENERATED PIC"
    call    sub_4B8DA0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+1426Bh], eax
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+0B4h+Text]
    mov     eax, [edx+1426Bh]
    push    eax                             ; int
    push    ecx                             ; int
    call    sub_4B8A80
    push    esi
    lea     edx, [esp+0B8h+var_58]
    push    esi
    lea     eax, [esp+0BCh+Text]
    push    edx
    push    eax
    call    sub_4B7F90
    jmp     short loc_48393C
    ; ---------------------------------------------------------------------------

    loc_483930:                             ; CODE XREF: sub_483610+291j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+1426Bh], esi

    loc_48393C:                             ; CODE XREF: sub_483610+31Ej
    mov     eax, [ebp+2Ch]
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     ecx, eax
    mov     eax, [ebp+28h]
    cdq
    and     edx, 1Fh
    add     eax, edx
    sar     ecx, 5
    sar     eax, 5
    imul    ecx, eax
    lea     esi, [ecx+ecx]
    push    esi
    push    offset aTileMap                 ; "TILE MAP"
    call    sub_4D83B0
    mov     ecx, esi
    mov     [ebp+90h], eax
    mov     esi, [esp+0BCh+var_70]
    mov     edx, ecx
    mov     edi, eax
    add     esp, 8
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [ebp+38h]
    imul    esi, [ebp+3Ch]
    mov     [esp+0B4h+var_A4], esi
    lea     eax, [esi+esi*2]
    lea     ecx, [esi+eax*4]
    push    ecx
    push    offset aPlotMemory              ; "PLOT MEMORY"
    call    sub_4D83B0
    mov     [ebp+8Ch], eax
    mov     edx, TAdynmemStructPtr
    xor     edi, edi
    add     esp, 8
    mov     ecx, [edx+391E9h]
    mov     ecx, [ecx+0D30h]
    cmp     ecx, edi
    jl      short loc_4839CD
    cmp     [esp+0B4h+var_9C], 2000h
    jge     short loc_4839CF

    loc_4839CD:                             ; CODE XREF: sub_483610+3B1j
    xor     ecx, ecx

    loc_4839CF:                             ; CODE XREF: sub_483610+3BBj
    cmp     esi, edi
    jle     short loc_4839EF
    mov     edx, esi

    loc_4839D5:                             ; CODE XREF: sub_483610+3DDj
    and     byte ptr [eax+0Ch], 0FCh
    mov     [eax], di
    mov     [eax+2], di
    mov     word ptr [eax+8], 0FFFFh
    mov     [eax+7], cl
    add     eax, 0Dh
    dec     edx
    jnz     short loc_4839D5

    loc_4839EF:                             ; CODE XREF: sub_483610+3C1j
    lea     edx, [esp+0B4h+var_9C]
    push    edx
    call    sub_421F20
    mov     ecx, [esp+0B4h+var_6C]
    cmp     ecx, edi
    jz      loc_483A99
    mov     eax, [ebp+8Ch]
    cmp     esi, edi
    jle     short loc_483A39
    add     eax, 0Ch
    mov     edi, esi

    loc_483A14:                             ; CODE XREF: sub_483610+421j
    mov     dl, [ecx]
    add     ecx, 8
    mov     [eax-8], dl
    mov     dl, [ecx-2]
    mov     [eax-5], dl
    mov     dl, [eax]
    and     dl, 0D7h
    add     eax, 0Dh
    or      dl, 50h
    dec     edi
    mov     [eax-0Dh], dl
    jnz     short loc_483A14
    mov     ecx, [esp+0B4h+var_6C]
    xor     edi, edi

    loc_483A39:                             ; CODE XREF: sub_483610+3FDj
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D6Bh], edi
    jnz     loc_483B53
    mov     edi, [ebp+8Ch]
    test    esi, esi
    jle     loc_483B53
    add     ecx, 2
    mov     [esp+0B4h+var_A0], ecx

    loc_483A5F:                             ; CODE XREF: sub_483610+482j
    mov     al, [ecx]
    mov     edx, [esp+0B4h+var_64]
    mov     ecx, eax
    and     ecx, 0FFh
    cmp     ecx, edx
    jge     short loc_483A83
    xor     dx, dx
    push    0Ah
    push    0
    mov     dl, al
    push    0
    push    edx
    push    edi
    call    sub_423C50

    loc_483A83:                             ; CODE XREF: sub_483610+45Fj
    mov     ecx, [esp+0B4h+var_A0]
    add     edi, 0Dh
    add     ecx, 8
    dec     esi
    mov     [esp+0B4h+var_A0], ecx
    jnz     short loc_483A5F
    jmp     loc_483B53
    ; ---------------------------------------------------------------------------

    loc_483A99:                             ; CODE XREF: sub_483610+3EFj
    mov     eax, [esp+0B4h+var_68]
    cmp     eax, edi
    jz      loc_483B53
    mov     ecx, [esp+0B4h+var_A4]
    mov     esi, [ebp+8Ch]
    test    ecx, ecx
    mov     edi, eax
    jle     short loc_483AFC
    mov     [esp+0B4h+var_A0], ecx

    loc_483AB9:                             ; CODE XREF: sub_483610+4E2j
    mov     cl, [esi+0Ch]
    mov     al, [edi]
    and     cl, 0D7h
    mov     [esi+4], al
    or      cl, 50h
    mov     [esi+0Ch], cl
    cmp     word ptr [edi+1], 0FFFCh
    jnz     short loc_483AE3
    push    0Ah
    push    0
    push    0
    push    0FFFCh
    push    esi
    call    sub_423C50

    loc_483AE3:                             ; CODE XREF: sub_483610+4C0j
    mov     eax, [esp+0B4h+var_A0]
    add     esi, 0Dh
    add     edi, 4
    dec     eax
    mov     [esp+0B4h+var_A0], eax
    jnz     short loc_483AB9
    mov     eax, [esp+0B4h+var_68]
    mov     ecx, [esp+0B4h+var_A4]

    loc_483AFC:                             ; CODE XREF: sub_483610+4A3j
    mov     edx, TAdynmemStructPtr
    mov     esi, [edx+38D6Bh]
    test    esi, esi
    jnz     short loc_483B53
    mov     esi, [ebp+8Ch]
    test    ecx, ecx
    jle     short loc_483B4E
    lea     edi, [eax+1]
    mov     [esp+0B4h+var_A4], ecx

    loc_483B1D:                             ; CODE XREF: sub_483610+53Cj
    mov     ax, [edi]
    mov     edx, [esp+0B4h+var_64]
    mov     ecx, eax
    and     ecx, 0FFFFh
    cmp     ecx, edx
    jge     short loc_483B3D
    push    0Ah
    push    0
    push    0
    push    eax
    push    esi
    call    sub_423C50

    loc_483B3D:                             ; CODE XREF: sub_483610+51Ej
    mov     eax, [esp+0B4h+var_A4]
    add     esi, 0Dh
    add     edi, 4
    dec     eax
    mov     [esp+0B4h+var_A4], eax
    jnz     short loc_483B1D

    loc_483B4E:                             ; CODE XREF: sub_483610+504j
    call    sub_423160

    loc_483B53:                             ; CODE XREF: sub_483610+434j
                                            ; sub_483610+442j ...
    mov     edx, [esp+0B4h+var_74]
    shl     edx, 0Ah
    add     edx, 8
    push    edx
    push    offset aTileSet                 ; "TILE SET"
    call    sub_4D83B0
    mov     [ebp+88h], eax
    mov     ecx, [esp+0BCh+var_74]
    mov     [eax], ecx
    mov     eax, [ebp+88h]
    add     esp, 8
    lea     edx, [eax+8]
    mov     [eax+4], edx
    mov     ecx, [esp+0B4h+var_74]
    mov     eax, [ebp+88h]
    mov     esi, [esp+0B4h+var_78]
    shl     ecx, 0Ah
    mov     edi, [eax+4]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    push    ebx                             ; int
    and     ecx, 3
    rep movsb
    call    sub_4D85A0
    add     esp, 4
    mov     ecx, offset byte_51E6A0
    call    sub_433130
    mov     eax, TAdynmemStructPtr
    push    10h                             ; int
    mov     esi, [eax+37E37h]
    mov     ebx, [eax+37E3Bh]
    mov     eax, esi
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4
    mov     [ebp+40h], eax
    mov     eax, ebx
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4
    mov     [ebp+44h], eax
    mov     eax, esi
    cdq
    and     edx, 1Fh
    add     eax, edx
    sar     eax, 5
    mov     [ebp+48h], eax
    mov     eax, ebx
    cdq
    and     edx, 1Fh
    add     eax, edx
    sar     eax, 5
    mov     [ebp+4Ch], eax
    call    sub_4B4F10
    xor     edi, edi
    add     esp, 4
    cmp     eax, edi
    jz      short loc_483C1E
    mov     [eax+4], edi
    mov     [eax+8], edi
    mov     [eax+0Ch], edi
    mov     [eax], edi
    mov     edi, eax

    loc_483C1E:                             ; CODE XREF: sub_483610+5FFj
    mov     eax, esi
    mov     ecx, 2
    cdq
    xor     eax, edx
    mov     [ebp+24h], edi
    sub     eax, edx
    mov     [esp+0B4h+var_A4], ecx
    and     eax, 1Fh
    xor     eax, edx
    sub     eax, edx
    jz      short loc_483C42
    mov     [esp+0B4h+var_A4], 3

    loc_483C42:                             ; CODE XREF: sub_483610+628j
    mov     eax, ebx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 1Fh
    xor     eax, edx
    sub     eax, edx
    jz      short loc_483C57
    mov     ecx, 3

    loc_483C57:                             ; CODE XREF: sub_483610+640j
    mov     eax, [ebp+44h]
    cdq
    sub     eax, edx
    mov     esi, eax
    mov     eax, [ebp+40h]
    cdq
    sub     eax, edx
    mov     edx, [esp+0B4h+var_A4]
    mov     ebx, eax
    mov     eax, [edi]
    sar     esi, 1
    sar     ebx, 1
    add     esi, ecx
    add     ebx, edx
    push    eax
    mov     [edi+4], ebx
    mov     [edi+8], esi
    call    sub_4B4F20
    imul    esi, ebx
    add     esi, 7
    add     esp, 4
    and     esi, 0FFFFFFF8h
    mov     [edi+0Ch], esi
    jz      short loc_483CA2
    lea     ecx, [esi+esi]
    push    ecx                             ; int
    call    sub_4B4F10
    add     esp, 4
    xor     ebx, ebx
    jmp     short loc_483CA6
    ; ---------------------------------------------------------------------------

    loc_483CA2:                             ; CODE XREF: sub_483610+680j
    xor     ebx, ebx
    xor     eax, eax

    loc_483CA6:                             ; CODE XREF: sub_483610+690j
    mov     [edi], eax
    mov     eax, TAdynmemStructPtr
    mov     word ptr [esp+0B4h+var_A0], bx
    mov     word ptr [esp+0B4h+var_A0+2], bx
    and     word ptr [eax+14281h], 0FFF7h
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+14233h]
    mov     ax, [eax+14237h]
    mov     word ptr [esp+0B4h+var_A4], dx
    mov     edx, [esp+0B4h+var_A0]
    mov     word ptr [esp+0B4h+var_A4+2], ax
    mov     ecx, [esp+0B4h+var_A4]
    push    ecx
    push    edx
    call    sub_483210
    call    sub_482C20
    call    sub_4833B0
    mov     esi, [ebp+38h]
    imul    esi, [ebp+3Ch]
    shl     esi, 1
    shr     esi, 2
    push    esi
    push    offset aMappedMemory            ; "MAPPED MEMORY"
    call    sub_4D83B0
    mov     ecx, esi
    mov     edi, eax
    mov     edx, ecx
    xor     eax, eax
    shr     ecx, 2
    mov     [ebp+78h], edi
    add     esp, 8
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     eax, [ebp+44h]
    mov     ecx, [ebp+40h]
    add     eax, 20h
    add     ecx, 0Ch
    mov     [ebp+54h], eax
    imul    eax, ecx
    shl     eax, 2
    push    eax
    push    offset aSortUnitList            ; "SORT UNIT LIST"
    mov     [ebp+50h], ecx
    call    sub_4D83B0
    mov     [ebp+0], eax
    mov     eax, [ebp+54h]
    add     esp, 8
    shl     eax, 2
    push    eax
    push    offset aSortIndices             ; "SORT INDICES"
    call    sub_4D83B0
    mov     ecx, [ebp+54h]
    add     esp, 8
    shl     ecx, 1
    push    ecx
    push    offset aSortLineCount           ; "SORT LINE COUNT"
    mov     [ebp+4], eax
    call    sub_4D83B0
    add     esp, 8
    mov     [ebp+8], eax
    call    sub_422040
    mov     edx, TAdynmemStructPtr
    push    2D0h
    push    offset aEyeballMemory           ; "EYEBALL MEMORY"
    mov     [edx+14277h], ebx
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [ecx+1427Bh], eax
    mov     [ebp+5Ch], ebx
    mov     edx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     byte ptr [edx+38D70h], 64h
    pop     ebx
    add     esp, 0A4h
    retn
    sub_483610 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_483DD0 proc near                    ; CODE XREF: sub_491B60+53p
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    mov     ecx, [eax+1427Bh]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    call    sub_422170
    mov     edx, TAdynmemStructPtr
    xor     esi, esi
    mov     eax, [edx+1426Bh]
    cmp     eax, esi
    jz      short loc_483E11
    push    eax                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     [eax+1426Bh], esi

    loc_483E11:                             ; CODE XREF: sub_483DD0+2Bj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14203h]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     ecx, [eax+141FFh]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     eax, [edx+141FBh]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     edx, [ecx+14283h]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     ecx, [eax+14273h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     eax, [edx+14287h]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     edx, [ecx+1428Bh]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     [eax+14203h], esi
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+141FFh], esi
    mov     edx, TAdynmemStructPtr
    mov     [edx+141FBh], esi
    mov     eax, TAdynmemStructPtr
    mov     [eax+14283h], esi
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+14273h], esi
    mov     edx, TAdynmemStructPtr
    mov     [edx+14287h], esi
    mov     eax, TAdynmemStructPtr
    mov     [eax+1428Bh], esi
    mov     ecx, TAdynmemStructPtr
    mov     edi, [ecx+1421Fh]
    cmp     edi, esi
    jz      short loc_483F17
    mov     edx, [edi]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    push    edi
    call    sub_4B4F20
    add     esp, 4

    loc_483F17:                             ; CODE XREF: sub_483DD0+131j
    mov     eax, TAdynmemStructPtr
    mov     [eax+1421Fh], esi
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+14293h], esi
    mov     [ecx+14297h], esi
    mov     edx, [ecx+1428Fh]
    lea     edi, [ecx+1428Fh]
    push    edx
    call    sub_4B4F20
    mov     [edi+0Ch], esi
    mov     [edi], esi
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     [eax+142A3h], esi
    mov     [eax+142A7h], esi
    mov     ecx, [eax+1429Fh]
    lea     edi, [eax+1429Fh]
    push    ecx
    call    sub_4B4F20
    mov     [edi+0Ch], esi
    mov     [edi], esi
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     eax, [edx+142B7h]
    push    eax
    call    sub_4B4F20
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     [ecx+142B7h], esi
    pop     edi
    pop     esi
    retn
    sub_483DD0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_483FA0 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+C0p

    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= word ptr -14h
    var_12= word ptr -12h
    var_F= byte ptr -0Fh
    var_E= byte ptr -0Eh
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 48h
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     eax, [ecx+37E27h]
    mov     esi, [ecx+1431Fh]
    mov     edx, [ecx+37E2Bh]
    mov     [esp+54h+var_38], eax
    mov     eax, esi
    mov     [esp+54h+var_3C], edx
    cdq
    and     edx, 1Fh
    push    edi
    mov     edi, [ecx+14323h]
    add     eax, edx
    sar     eax, 5
    mov     [esp+58h+var_44], eax
    mov     eax, edi
    cdq
    mov     ebx, [ecx+37E37h]
    and     edx, 1Fh
    add     eax, edx
    mov     edx, [esp+58h+var_44]
    sar     eax, 5
    shl     edx, 5
    mov     [esp+58h+var_34], eax
    sub     esi, edx
    shl     eax, 5
    sub     edi, eax
    lea     eax, [ebx+esi]
    mov     ebp, [ecx+37E3Bh]
    cdq
    and     edx, 1Fh
    add     eax, edx
    sar     eax, 5
    mov     [esp+58h+var_48], eax
    lea     eax, [ebp+edi+0]
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     edx, [esp+58h+var_48]
    shl     edx, 5
    sar     eax, 5
    sub     ebx, edx
    mov     edx, eax
    shl     edx, 5
    sub     ebp, edx
    add     ebx, esi
    add     ebp, edi
    mov     [esp+58h+var_40], eax
    mov     edx, ebp
    xor     ebp, ebp
    cmp     ebx, ebp
    mov     [esp+58h+var_28], ebx
    mov     [esp+58h+var_24], edx
    jz      short loc_48404E
    inc     [esp+58h+var_48]

    loc_48404E:                             ; CODE XREF: sub_483FA0+A8j
    cmp     edx, ebp
    jz      short loc_484057
    inc     eax
    mov     [esp+58h+var_40], eax

    loc_484057:                             ; CODE XREF: sub_483FA0+B0j
    mov     eax, [ecx+14233h]
    mov     ebx, [esp+58h+arg_0]
    cdq
    sub     eax, edx
    mov     edx, 20h
    sar     eax, 1
    cmp     esi, ebp
    mov     [esp+58h+var_30], eax
    mov     word ptr [esp+58h+var_18], dx
    mov     word ptr [esp+58h+var_18+2], dx
    mov     [esp+58h+var_14], bp
    mov     [esp+58h+var_12], bp
    mov     [esp+58h+var_F], 0
    mov     [esp+58h+var_E], 0
    jnz     short loc_48409B
    cmp     [esp+58h+var_28], ebp
    jz      loc_484191

    loc_48409B:                             ; CODE XREF: sub_483FA0+EFj
    imul    eax, [esp+58h+var_34]
    mov     edx, [esp+58h+var_44]
    add     eax, edx
    mov     edx, [ecx+1428Bh]
    lea     ebp, [edx+eax*2]
    mov     [esp+58h+arg_0], ebp
    mov     ebp, [esp+58h+var_48]
    add     eax, ebp
    lea     edx, [edx+eax*2-2]
    mov     eax, [esp+58h+var_40]
    test    eax, eax
    mov     [esp+58h+var_2C], edx
    jle     loc_484195
    mov     edx, [esp+58h+var_30]
    mov     ebp, [esp+58h+var_3C]
    add     edx, edx
    mov     [esp+58h+var_20], eax
    mov     [esp+58h+var_1C], edx

    loc_4840DF:                             ; CODE XREF: sub_483FA0+1EBj
    test    esi, esi
    jz      short loc_48411B
    mov     edx, [esp+58h+arg_0]
    mov     ecx, [ecx+14283h]
    xor     eax, eax
    mov     ax, [edx]
    mov     edx, [ecx+4]
    shl     eax, 0Ah
    add     eax, edx
    mov     edx, ebp
    mov     [esp+58h+var_8], eax
    mov     eax, [esp+58h+var_38]
    sub     edx, edi
    sub     eax, esi
    push    edx
    lea     ecx, [esp+5Ch+var_18]
    push    eax
    push    ecx
    push    ebx
    call    sub_4B8150
    mov     ecx, TAdynmemStructPtr

    loc_48411B:                             ; CODE XREF: sub_483FA0+141j
    mov     eax, [esp+58h+var_28]
    test    eax, eax
    jz      short loc_484167
    mov     eax, [esp+58h+var_2C]
    mov     ecx, [ecx+14283h]
    xor     edx, edx
    mov     dx, [eax]
    mov     eax, [ecx+4]
    shl     edx, 0Ah
    add     edx, eax
    mov     eax, [esp+58h+var_48]
    mov     [esp+58h+var_8], edx
    mov     edx, ebp
    sub     edx, edi
    lea     ecx, [esp+58h+var_18]
    push    edx
    mov     edx, [esp+5Ch+var_38]
    shl     eax, 5
    add     eax, edx
    sub     eax, esi
    sub     eax, 20h
    push    eax
    push    ecx
    push    ebx
    call    sub_4B8150
    mov     ecx, TAdynmemStructPtr

    loc_484167:                             ; CODE XREF: sub_483FA0+181j
    mov     eax, [esp+58h+var_1C]
    mov     edx, [esp+58h+arg_0]
    add     edx, eax
    add     ebp, 20h
    mov     [esp+58h+arg_0], edx
    mov     edx, [esp+58h+var_2C]
    add     edx, eax
    mov     eax, [esp+58h+var_20]
    dec     eax
    mov     [esp+58h+var_2C], edx
    mov     [esp+58h+var_20], eax
    jnz     loc_4840DF

    loc_484191:                             ; CODE XREF: sub_483FA0+F5j
    mov     ebp, [esp+58h+var_48]

    loc_484195:                             ; CODE XREF: sub_483FA0+127j
    test    edi, edi
    jnz     short loc_4841A5
    mov     eax, [esp+58h+var_24]
    test    eax, eax
    jz      loc_4842AE

    loc_4841A5:                             ; CODE XREF: sub_483FA0+1F7j
    mov     edx, [esp+58h+var_30]
    mov     eax, [ecx+1428Bh]
    imul    edx, [esp+58h+var_34]
    add     edx, [esp+58h+var_44]
    lea     eax, [eax+edx*2]
    mov     edx, [esp+58h+var_34]
    mov     [esp+58h+arg_0], eax
    mov     eax, [esp+58h+var_40]
    lea     edx, [edx+eax-1]
    mov     eax, [esp+58h+var_44]
    imul    edx, [esp+58h+var_30]
    add     edx, eax
    mov     eax, [ecx+1428Bh]
    test    ebp, ebp
    lea     eax, [eax+edx*2]
    mov     [esp+58h+var_2C], eax
    jle     loc_4842AE
    mov     edx, [esp+58h+var_48]
    mov     ebp, [esp+58h+var_38]
    mov     [esp+58h+var_20], edx

    loc_4841F7:                             ; CODE XREF: sub_483FA0+304j
    test    edi, edi
    jz      short loc_484233
    mov     edx, [esp+58h+arg_0]
    mov     ecx, [ecx+14283h]
    xor     eax, eax
    mov     ax, [edx]
    mov     edx, [ecx+4]
    shl     eax, 0Ah
    add     eax, edx
    mov     edx, [esp+58h+var_3C]
    mov     [esp+58h+var_8], eax
    mov     eax, ebp
    sub     edx, edi
    sub     eax, esi
    push    edx
    lea     ecx, [esp+5Ch+var_18]
    push    eax
    push    ecx
    push    ebx
    call    sub_4B8150
    mov     ecx, TAdynmemStructPtr

    loc_484233:                             ; CODE XREF: sub_483FA0+259j
    mov     eax, [esp+58h+var_24]
    test    eax, eax
    jz      short loc_48427F
    mov     eax, [esp+58h+var_2C]
    mov     ecx, [ecx+14283h]
    xor     edx, edx
    mov     dx, [eax]
    mov     eax, [ecx+4]
    mov     ecx, [esp+58h+var_3C]
    shl     edx, 0Ah
    add     edx, eax
    mov     eax, ebp
    mov     [esp+58h+var_8], edx
    mov     edx, [esp+58h+var_40]
    shl     edx, 5
    add     edx, ecx
    sub     eax, esi
    sub     edx, edi
    lea     ecx, [esp+58h+var_18]
    sub     edx, 20h
    push    edx
    push    eax
    push    ecx
    push    ebx
    call    sub_4B8150
    mov     ecx, TAdynmemStructPtr

    loc_48427F:                             ; CODE XREF: sub_483FA0+299j
    mov     edx, [esp+58h+arg_0]
    mov     eax, 2
    add     edx, eax
    add     ebp, 20h
    mov     [esp+58h+arg_0], edx
    mov     edx, [esp+58h+var_2C]
    add     edx, eax
    mov     eax, [esp+58h+var_20]
    dec     eax
    mov     [esp+58h+var_2C], edx
    mov     [esp+58h+var_20], eax
    jnz     loc_4841F7
    mov     ebp, [esp+58h+var_48]

    loc_4842AE:                             ; CODE XREF: sub_483FA0+1FFj
                                            ; sub_483FA0+245j
    test    esi, esi
    jz      short loc_4842D1
    mov     eax, [esp+58h+var_44]
    mov     edx, 20h
    sub     edx, esi
    mov     esi, [esp+58h+var_38]
    dec     ebp
    add     esi, edx
    inc     eax
    mov     [esp+58h+var_48], ebp
    mov     [esp+58h+var_38], esi
    mov     [esp+58h+var_44], eax

    loc_4842D1:                             ; CODE XREF: sub_483FA0+310j
    test    edi, edi
    jz      short loc_4842F2
    mov     edx, [esp+58h+var_3C]
    mov     esi, [esp+58h+var_40]
    mov     eax, 20h
    dec     esi
    sub     eax, edi
    add     edx, eax
    mov     [esp+58h+var_3C], edx
    mov     edx, [esp+58h+var_34]
    inc     edx
    jmp     short loc_4842FA
    ; ---------------------------------------------------------------------------

    loc_4842F2:                             ; CODE XREF: sub_483FA0+333j
    mov     edx, [esp+58h+var_34]
    mov     esi, [esp+58h+var_40]

    loc_4842FA:                             ; CODE XREF: sub_483FA0+350j
    mov     eax, [esp+58h+var_28]
    test    eax, eax
    jz      short loc_484307
    dec     ebp
    mov     [esp+58h+var_48], ebp

    loc_484307:                             ; CODE XREF: sub_483FA0+360j
    mov     eax, [esp+58h+var_24]
    test    eax, eax
    jz      short loc_484310
    dec     esi

    loc_484310:                             ; CODE XREF: sub_483FA0+36Dj
    test    esi, esi
    jle     loc_4843AC
    mov     eax, [esp+58h+var_3C]
    mov     [esp+58h+var_24], esi
    mov     [esp+58h+arg_0], eax
    mov     eax, [esp+58h+var_30]
    and     eax, 0FFFFh
    imul    edx, eax
    lea     edi, [eax+eax]
    mov     [esp+58h+var_1C], edi
    mov     edi, [esp+58h+var_44]
    add     edx, edi
    shl     edx, 1
    mov     eax, edx
    mov     [esp+58h+var_20], eax

    loc_484345:                             ; CODE XREF: sub_483FA0+40Aj
    mov     esi, [ecx+1428Bh]
    add     esi, eax
    test    ebp, ebp
    jle     short loc_484388
    mov     edi, [esp+58h+var_38]

    loc_484355:                             ; CODE XREF: sub_483FA0+3E2j
    mov     eax, [ecx+14283h]
    xor     edx, edx
    mov     dx, [esi]
    mov     ecx, [eax+4]
    shl     edx, 0Ah
    add     edx, ecx
    mov     ecx, [esp+58h+arg_0]
    push    edx
    push    ecx
    push    edi
    push    ebx
    call    sub_4C6E70
    mov     ecx, TAdynmemStructPtr
    add     edi, 20h
    add     esi, 2
    dec     ebp
    jnz     short loc_484355
    mov     ebp, [esp+58h+var_48]

    loc_484388:                             ; CODE XREF: sub_483FA0+3AFj
    mov     eax, [esp+58h+var_20]
    mov     edi, [esp+58h+var_1C]
    mov     esi, [esp+58h+arg_0]
    mov     edx, [esp+58h+var_24]
    add     eax, edi
    add     esi, 20h
    dec     edx
    mov     [esp+58h+var_20], eax
    mov     [esp+58h+arg_0], esi
    mov     [esp+58h+var_24], edx
    jnz     short loc_484345

    loc_4843AC:                             ; CODE XREF: sub_483FA0+372j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    4
    sub_483FA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl GameUnit_LOS_Painting()
    GameUnit_LOS_Painting proc near         ; CODE XREF: sub_4848E0+1Ap

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    field_141FB= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 20h
    mov     edx, TAdynmemStructPtr
    push    ebx
    xor     ecx, ecx
    push    ebp
    mov     cl, [edx+TAdynmemStruct.LOS_Sight]
    lea     eax, [edx+TAdynmemStruct.field_141FB]
    push    esi
    mov     [esp+2Ch+field_141FB], eax
    mov     esi, [eax+24h]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    add     edx, ecx
    push    edi
    mov     edi, [esi]
    lea     eax, [eax+eax*4]
    lea     ebp, [edx+eax*2+TAdynmemStruct.Players.field_7C]
    mov     eax, 1
    shl     eax, cl
    mov     ecx, [esi+0Ch]
    mov     [esp+30h+var_10], ebp
    shl     ecx, 1
    mov     edx, ecx
    mov     [esp+30h+var_4], eax
    xor     eax, eax
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     edi, TAdynmemStructPtr
    mov     ebx, [edi+TAdynmemStruct.MapY]
    mov     edi, [edi+TAdynmemStruct.MapX]
    mov     eax, ebx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 1Fh
    xor     eax, edx
    mov     ecx, eax
    mov     eax, edi
    sub     ecx, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 1Fh
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 10h
    mov     eax, edi
    cdq
    jge     short loc_484460
    and     edx, 1Fh
    add     eax, edx
    mov     edi, eax
    sar     edi, 5
    dec     edi
    jmp     short loc_48446A
    ; ---------------------------------------------------------------------------

    loc_484460:                             ; CODE XREF: GameUnit_LOS_Painting+91j
    and     edx, 1Fh
    add     eax, edx
    mov     edi, eax
    sar     edi, 5

    loc_48446A:                             ; CODE XREF: GameUnit_LOS_Painting+9Ej
    mov     eax, ebx
    cmp     ecx, 10h
    cdq
    jge     short loc_48447D
    and     edx, 1Fh
    add     eax, edx
    sar     eax, 5
    dec     eax
    jmp     short loc_484485
    ; ---------------------------------------------------------------------------

    loc_48447D:                             ; CODE XREF: GameUnit_LOS_Painting+B0j
    and     edx, 1Fh
    add     eax, edx
    sar     eax, 5

    loc_484485:                             ; CODE XREF: GameUnit_LOS_Painting+BBj
    mov     edx, [esi+4]
    mov     ecx, [esi+8]
    mov     [esp+30h+var_20], eax
    mov     eax, edi
    mov     ebx, [esp+30h+var_20]
    add     eax, edx
    mov     edx, ebx
    mov     [esp+30h+var_14], eax
    add     edx, ecx
    mov     [esp+30h+var_1C], ebx
    cmp     ebx, edx
    mov     [esp+30h+var_8], edx
    jge     loc_4846A1

    loc_4844AF:                             ; CODE XREF: GameUnit_LOS_Painting+2D7j
    cmp     edi, eax
    mov     ecx, edi
    jge     loc_484690

    loc_4844B9:                             ; CODE XREF: GameUnit_LOS_Painting+2C6j
    mov     eax, [ebp+4]
    cmp     ecx, eax
    jnb     loc_48467B
    cmp     ebx, [ebp+8]
    jnb     loc_48467B
    mov     edx, ebx
    imul    edx, eax
    mov     eax, [ebp+0]
    add     edx, ecx
    cmp     byte ptr [edx+eax], 0
    jnz     loc_4845A5
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+14281h], 2
    jz      loc_4845A5
    mov     edx, [esi+4]
    mov     ebp, ecx
    sub     ebp, edi
    cmp     ebp, edx
    jnb     short loc_484522
    mov     eax, ebx
    mov     ebx, [esp+30h+var_20]
    sub     eax, ebx
    mov     ebx, [esi+8]
    cmp     eax, ebx
    jnb     short loc_48451E
    imul    eax, edx
    mov     edx, [esi]
    add     eax, ecx
    sub     eax, edi
    lea     eax, [edx+eax*2+1]
    or      byte ptr [eax], 1

    loc_48451E:                             ; CODE XREF: GameUnit_LOS_Painting+14Cj
    mov     ebx, [esp+30h+var_1C]

    loc_484522:                             ; CODE XREF: GameUnit_LOS_Painting+13Dj
    mov     edx, [esi+4]
    lea     eax, [ebp-1]
    cmp     eax, edx
    mov     [esp+30h+var_18], eax
    jnb     short loc_484553
    mov     eax, ebx
    mov     ebx, [esp+30h+var_20]
    sub     eax, ebx
    mov     ebx, [esi+8]
    cmp     eax, ebx
    jnb     short loc_48454F
    imul    eax, edx
    mov     edx, [esi]
    add     eax, ecx
    sub     eax, edi
    lea     eax, [edx+eax*2-1]
    or      byte ptr [eax], 2

    loc_48454F:                             ; CODE XREF: GameUnit_LOS_Painting+17Dj
    mov     ebx, [esp+30h+var_1C]

    loc_484553:                             ; CODE XREF: GameUnit_LOS_Painting+16Ej
    mov     edx, [esi+4]
    cmp     ebp, edx
    jnb     short loc_48457A
    mov     ebp, [esp+30h+var_20]
    mov     eax, ebx
    sub     eax, ebp
    mov     ebp, [esi+8]
    dec     eax
    cmp     eax, ebp
    jnb     short loc_48457A
    imul    eax, edx
    mov     edx, [esi]
    add     eax, ecx
    sub     eax, edi
    lea     eax, [edx+eax*2+1]
    or      byte ptr [eax], 4

    loc_48457A:                             ; CODE XREF: GameUnit_LOS_Painting+198j
                                            ; GameUnit_LOS_Painting+1A8j
    mov     edx, [esi+4]
    mov     eax, [esp+30h+var_18]
    cmp     eax, edx
    jnb     short loc_4845A5
    mov     ebp, [esp+30h+var_20]
    mov     eax, ebx
    sub     eax, ebp
    mov     ebp, [esi+8]
    dec     eax
    cmp     eax, ebp
    jnb     short loc_4845A5
    imul    eax, edx
    mov     edx, [esi]
    add     eax, ecx
    sub     eax, edi
    lea     eax, [edx+eax*2-1]
    or      byte ptr [eax], 8

    loc_4845A5:                             ; CODE XREF: GameUnit_LOS_Painting+11Bj
                                            ; GameUnit_LOS_Painting+12Ej ...
    mov     ebp, [esp+30h+field_141FB]
    mov     eax, [ebp+38h]
    imul    eax, ebx
    cdq
    sub     eax, edx
    mov     edx, [ebp+78h]
    mov     ebp, [esp+30h+var_4]
    sar     eax, 1
    add     eax, ecx
    mov     ax, [edx+eax*2]
    and     eax, ebp
    test    ax, ax
    jnz     loc_48467B
    mov     edx, [esi+4]
    mov     ebp, ecx
    sub     ebp, edi
    cmp     ebp, edx
    jnb     short loc_4845F9
    mov     eax, ebx
    mov     ebx, [esp+30h+var_20]
    sub     eax, ebx
    mov     ebx, [esi+8]
    cmp     eax, ebx
    jnb     short loc_4845F5
    imul    eax, edx
    mov     edx, [esi]
    add     eax, ecx
    sub     eax, edi
    lea     eax, [edx+eax*2]
    or      byte ptr [eax], 1

    loc_4845F5:                             ; CODE XREF: GameUnit_LOS_Painting+224j
    mov     ebx, [esp+30h+var_1C]

    loc_4845F9:                             ; CODE XREF: GameUnit_LOS_Painting+215j
    mov     edx, [esi+4]
    lea     eax, [ebp-1]
    cmp     eax, edx
    mov     [esp+30h+var_18], eax
    jnb     short loc_48462A
    mov     eax, ebx
    mov     ebx, [esp+30h+var_20]
    sub     eax, ebx
    mov     ebx, [esi+8]
    cmp     eax, ebx
    jnb     short loc_484626
    imul    eax, edx
    mov     edx, [esi]
    add     eax, ecx
    sub     eax, edi
    lea     eax, [edx+eax*2-2]
    or      byte ptr [eax], 2

    loc_484626:                             ; CODE XREF: GameUnit_LOS_Painting+254j
    mov     ebx, [esp+30h+var_1C]

    loc_48462A:                             ; CODE XREF: GameUnit_LOS_Painting+245j
    mov     edx, [esi+4]
    cmp     ebp, edx
    jnb     short loc_484650
    mov     ebp, [esp+30h+var_20]
    mov     eax, ebx
    sub     eax, ebp
    mov     ebp, [esi+8]
    dec     eax
    cmp     eax, ebp
    jnb     short loc_484650
    imul    eax, edx
    mov     edx, [esi]
    add     eax, ecx
    sub     eax, edi
    lea     eax, [edx+eax*2]
    or      byte ptr [eax], 4

    loc_484650:                             ; CODE XREF: GameUnit_LOS_Painting+26Fj
                                            ; GameUnit_LOS_Painting+27Fj
    mov     edx, [esi+4]
    mov     eax, [esp+30h+var_18]
    cmp     eax, edx
    jnb     short loc_48467B
    mov     ebp, [esp+30h+var_20]
    mov     eax, ebx
    sub     eax, ebp
    mov     ebp, [esi+8]
    dec     eax
    cmp     eax, ebp
    jnb     short loc_48467B
    imul    eax, edx
    mov     edx, [esi]
    add     eax, ecx
    sub     eax, edi
    lea     eax, [edx+eax*2-2]
    or      byte ptr [eax], 8

    loc_48467B:                             ; CODE XREF: GameUnit_LOS_Painting+FEj
                                            ; GameUnit_LOS_Painting+107j ...
    mov     eax, [esp+30h+var_14]
    mov     ebp, [esp+30h+var_10]
    inc     ecx
    cmp     ecx, eax
    jl      loc_4844B9
    mov     edx, [esp+30h+var_8]

    loc_484690:                             ; CODE XREF: GameUnit_LOS_Painting+F3j
    inc     ebx
    cmp     ebx, edx
    mov     [esp+30h+var_1C], ebx
    jl      loc_4844AF
    mov     ebx, [esp+30h+var_20]

    loc_4846A1:                             ; CODE XREF: GameUnit_LOS_Painting+E9j
    test    ebx, ebx
    jge     short loc_48470C
    mov     eax, [esi+4]
    xor     edx, edx
    test    eax, eax
    jbe     short loc_48470C

    loc_4846AE:                             ; CODE XREF: GameUnit_LOS_Painting+34Aj
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+14281h]
    shr     cl, 1
    test    cl, 1
    jz      short loc_4846E4
    mov     eax, [esi]
    lea     ecx, [eax+edx*2+1]
    mov     al, [eax+edx*2+1]
    test    al, 4
    jz      short loc_4846D2
    or      al, 1
    mov     [ecx], al

    loc_4846D2:                             ; CODE XREF: GameUnit_LOS_Painting+30Cj
    mov     ecx, [esi]
    mov     al, [ecx+edx*2+1]
    lea     ecx, [ecx+edx*2+1]
    test    al, 8
    jz      short loc_4846E4
    or      al, 2
    mov     [ecx], al

    loc_4846E4:                             ; CODE XREF: GameUnit_LOS_Painting+2FEj
                                            ; GameUnit_LOS_Painting+31Ej
    mov     eax, [esi]
    lea     ecx, [eax+edx*2]
    mov     al, [eax+edx*2]
    test    al, 4
    jz      short loc_4846F4
    or      al, 1
    mov     [ecx], al

    loc_4846F4:                             ; CODE XREF: GameUnit_LOS_Painting+32Ej
    mov     ecx, [esi]
    mov     al, [ecx+edx*2]
    lea     ecx, [ecx+edx*2]
    test    al, 8
    jz      short loc_484704
    or      al, 2
    mov     [ecx], al

    loc_484704:                             ; CODE XREF: GameUnit_LOS_Painting+33Ej
    mov     eax, [esi+4]
    inc     edx
    cmp     edx, eax
    jb      short loc_4846AE

    loc_48470C:                             ; CODE XREF: GameUnit_LOS_Painting+2E3j
                                            ; GameUnit_LOS_Painting+2ECj
    mov     ebp, [esp+30h+field_141FB]
    mov     ecx, [esp+30h+var_8]
    mov     eax, [ebp+3Ch]
    cdq
    sub     eax, edx
    sar     eax, 1
    cmp     ecx, eax
    jle     loc_4847BD
    mov     eax, [esi+4]
    xor     ecx, ecx
    test    eax, eax
    jbe     loc_4847BD

    loc_484731:                             ; CODE XREF: GameUnit_LOS_Painting+3F7j
    mov     edx, TAdynmemStructPtr
    mov     dl, [edx+14281h]
    shr     dl, 1
    test    dl, 1
    jz      short loc_48477B
    mov     edx, [esi+8]
    sub     edx, 2
    imul    edx, eax
    mov     eax, [esi]
    add     edx, ecx
    lea     edx, [eax+edx*2+1]
    mov     al, [edx]
    test    al, 1
    jz      short loc_48475F
    or      al, 4
    mov     [edx], al

    loc_48475F:                             ; CODE XREF: GameUnit_LOS_Painting+399j
    mov     edx, [esi+8]
    mov     eax, [esi]
    sub     edx, 2
    imul    edx, [esi+4]
    add     edx, ecx
    lea     edx, [eax+edx*2+1]
    mov     al, [edx]
    test    al, 2
    jz      short loc_48477B
    or      al, 8
    mov     [edx], al

    loc_48477B:                             ; CODE XREF: GameUnit_LOS_Painting+382j
                                            ; GameUnit_LOS_Painting+3B5j
    mov     edx, [esi+8]
    mov     eax, [esi]
    sub     edx, 2
    imul    edx, [esi+4]
    add     edx, ecx
    lea     edx, [eax+edx*2]
    mov     al, [edx]
    test    al, 1
    jz      short loc_484796
    or      al, 4
    mov     [edx], al

    loc_484796:                             ; CODE XREF: GameUnit_LOS_Painting+3D0j
    mov     edx, [esi+8]
    mov     eax, [esi]
    sub     edx, 2
    imul    edx, [esi+4]
    add     edx, ecx
    lea     edx, [eax+edx*2]
    mov     al, [edx]
    test    al, 2
    jz      short loc_4847B1
    or      al, 8
    mov     [edx], al

    loc_4847B1:                             ; CODE XREF: GameUnit_LOS_Painting+3EBj
    mov     eax, [esi+4]
    inc     ecx
    cmp     ecx, eax
    jb      loc_484731

    loc_4847BD:                             ; CODE XREF: GameUnit_LOS_Painting+35Ej
                                            ; GameUnit_LOS_Painting+36Bj
    test    edi, edi
    jge     short loc_48483A
    mov     eax, [esi+8]
    xor     ecx, ecx
    test    eax, eax
    jbe     short loc_48483A

    loc_4847CA:                             ; CODE XREF: GameUnit_LOS_Painting+478j
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+14281h]
    shr     al, 1
    test    al, 1
    jz      short loc_484808
    mov     edx, ecx
    mov     eax, [esi]
    imul    edx, [esi+4]
    lea     edx, [eax+edx*2+1]
    mov     al, [edx]
    test    al, 8
    jz      short loc_4847F2
    or      al, 4
    mov     [edx], al

    loc_4847F2:                             ; CODE XREF: GameUnit_LOS_Painting+42Cj
    mov     edx, ecx
    mov     eax, [esi]
    imul    edx, [esi+4]
    lea     edx, [eax+edx*2+1]
    mov     al, [edx]
    test    al, 2
    jz      short loc_484808
    or      al, 1
    mov     [edx], al

    loc_484808:                             ; CODE XREF: GameUnit_LOS_Painting+41Aj
                                            ; GameUnit_LOS_Painting+442j
    mov     edx, ecx
    mov     eax, [esi]
    imul    edx, [esi+4]
    lea     edx, [eax+edx*2]
    mov     al, [edx]
    test    al, 8
    jz      short loc_48481D
    or      al, 4
    mov     [edx], al

    loc_48481D:                             ; CODE XREF: GameUnit_LOS_Painting+457j
    mov     edx, ecx
    mov     eax, [esi]
    imul    edx, [esi+4]
    lea     edx, [eax+edx*2]
    mov     al, [edx]
    test    al, 2
    jz      short loc_484832
    or      al, 1
    mov     [edx], al

    loc_484832:                             ; CODE XREF: GameUnit_LOS_Painting+46Cj
    mov     eax, [esi+8]
    inc     ecx
    cmp     ecx, eax
    jb      short loc_4847CA

    loc_48483A:                             ; CODE XREF: GameUnit_LOS_Painting+3FFj
                                            ; GameUnit_LOS_Painting+408j
    mov     eax, [ebp+38h]
    mov     ecx, [esp+30h+var_14]
    cdq
    sub     eax, edx
    sar     eax, 1
    cmp     ecx, eax
    jle     loc_4848CF
    mov     eax, [esi+8]
    test    eax, eax
    jbe     short loc_4848CF
    mov     ecx, 1

    loc_48485A:                             ; CODE XREF: GameUnit_LOS_Painting+50Dj
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+14281h]
    shr     al, 1
    test    al, 1
    jz      short loc_484898
    mov     edx, ecx
    mov     eax, [esi]
    imul    edx, [esi+4]
    lea     edx, [eax+edx*2-3]
    mov     al, [edx]
    test    al, 4
    jz      short loc_484882
    or      al, 8
    mov     [edx], al

    loc_484882:                             ; CODE XREF: GameUnit_LOS_Painting+4BCj
    mov     edx, ecx
    mov     eax, [esi]
    imul    edx, [esi+4]
    lea     edx, [eax+edx*2-3]
    mov     al, [edx]
    test    al, 1
    jz      short loc_484898
    or      al, 2
    mov     [edx], al

    loc_484898:                             ; CODE XREF: GameUnit_LOS_Painting+4AAj
                                            ; GameUnit_LOS_Painting+4D2j
    mov     edx, ecx
    mov     eax, [esi]
    imul    edx, [esi+4]
    lea     edx, [eax+edx*2-4]
    mov     al, [edx]
    test    al, 4
    jz      short loc_4848AE
    or      al, 8
    mov     [edx], al

    loc_4848AE:                             ; CODE XREF: GameUnit_LOS_Painting+4E8j
    mov     edx, ecx
    mov     eax, [esi]
    imul    edx, [esi+4]
    lea     edx, [eax+edx*2-4]
    mov     al, [edx]
    test    al, 1
    jz      short loc_4848C4
    or      al, 2
    mov     [edx], al

    loc_4848C4:                             ; CODE XREF: GameUnit_LOS_Painting+4FEj
    mov     eax, [esi+8]
    inc     ecx
    lea     edx, [ecx-1]
    cmp     edx, eax
    jb      short loc_48485A

    loc_4848CF:                             ; CODE XREF: GameUnit_LOS_Painting+488j
                                            ; GameUnit_LOS_Painting+493j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn
    GameUnit_LOS_Painting endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4848E0 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+109Ep

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 2Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    mov     ebx, 8
    push    edi
    test    [esi+14281h], bl
    jnz     short loc_484911
    call    GameUnit_LOS_Painting
    mov     eax, TAdynmemStructPtr
    or      [eax+14281h], bx
    mov     esi, TAdynmemStructPtr

    loc_484911:                             ; CODE XREF: sub_4848E0+18j
    mov     edi, [esi+1431Fh]
    mov     ebx, [esi+14323h]
    mov     ecx, [esi+1421Fh]
    lea     eax, [edi+10h]
    mov     [esp+3Ch+var_28], ecx
    cdq
    and     edx, 1Fh
    add     eax, edx
    mov     ebp, eax
    lea     eax, [ebx+10h]
    cdq
    and     edx, 1Fh
    add     eax, edx
    sar     ebp, 5
    sar     eax, 5
    add     ebp, eax
    lea     eax, [ebx+edi]
    and     eax, 1
    mov     [esp+3Ch+var_18], ebp
    mov     [esp+3Ch+var_1C], eax
    mov     eax, edi
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 1Fh
    xor     eax, edx
    mov     edi, eax
    mov     eax, ebx
    sub     edi, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 1Fh
    xor     eax, edx
    sub     eax, edx
    cmp     edi, 10h
    mov     edx, 0FFFFFFF0h
    jl      short loc_48497E
    mov     edx, 10h

    loc_48497E:                             ; CODE XREF: sub_4848E0+97j
    sub     edx, edi
    cmp     eax, 10h
    mov     [esp+3Ch+var_24], edx
    mov     edx, 0FFFFFFF0h
    jl      short loc_484993
    mov     edx, 10h

    loc_484993:                             ; CODE XREF: sub_4848E0+ACj
    sub     edx, eax
    mov     eax, [ecx+8]
    xor     ebx, ebx
    mov     [esp+3Ch+var_20], edx
    test    eax, eax
    jbe     loc_484B41

    loc_4849A6:                             ; CODE XREF: sub_4848E0+25Bj
    mov     eax, [ecx+4]
    xor     edi, edi
    cmp     eax, edi
    jbe     loc_484B35
    mov     edx, ebx
    mov     [esp+3Ch+var_2C], edi
    shl     edx, 5
    mov     [esp+3Ch+var_14], edx

    loc_4849C0:                             ; CODE XREF: sub_4848E0+24Fj
    mov     edx, ebx
    imul    edx, eax
    mov     eax, [ecx]
    mov     ecx, [esp+3Ch+var_2C]
    add     edx, edi
    lea     ebp, [eax+edx*2]
    mov     eax, [esi+37E27h]
    mov     edx, [esp+3Ch+var_24]
    add     eax, edx
    mov     edx, [esp+3Ch+var_20]
    add     eax, ecx
    mov     [esp+3Ch+var_10], eax
    mov     ecx, [esi+37E2Bh]
    add     ecx, edx
    mov     edx, [esp+3Ch+var_14]
    add     ecx, edx
    add     eax, 1Fh
    mov     [esp+3Ch+var_C], ecx
    add     ecx, 1Fh
    mov     [esp+3Ch+var_8], eax
    mov     [esp+3Ch+var_4], ecx
    cmp     byte ptr [ebp+0], 0Fh
    jnz     short loc_484A29
    mov     eax, [esp+3Ch+arg_0]
    xor     ecx, ecx
    mov     cl, [esi+0DCBh]
    lea     edx, [esp+3Ch+var_10]
    push    ecx
    push    edx
    push    eax
    call    sub_4BF6F0
    jmp     loc_484B14
    ; ---------------------------------------------------------------------------

    loc_484A29:                             ; CODE XREF: sub_4848E0+12Aj
    mov     al, [ebp+1]
    test    al, al
    jz      loc_484AD8
    cmp     al, 0Fh
    jz      short loc_484A9F
    and     eax, 0FFh
    lea     ecx, [edi+ebx]
    dec     eax
    push    eax
    mov     eax, [esp+40h+var_18]
    add     ecx, eax
    and     ecx, 3
    mov     edx, [esi+ecx*4+1486Fh]
    push    edx
    call    sub_4B7F30
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+37F06h]
    shr     dl, 6
    test    dl, 1
    jz      short loc_484A88
    mov     ecx, [esp+3Ch+var_1C]
    mov     edx, [esp+3Ch+var_C]
    push    ecx
    mov     ecx, [esp+40h+var_10]
    push    edx
    mov     edx, [esp+44h+arg_0]
    push    ecx
    push    eax
    push    edx
    call    sub_4B88D0
    jmp     short loc_484AD2
    ; ---------------------------------------------------------------------------

    loc_484A88:                             ; CODE XREF: sub_4848E0+18Aj
    mov     ecx, [esp+3Ch+var_C]
    mov     edx, [esp+3Ch+var_10]
    push    ecx
    push    edx
    push    eax
    mov     eax, [esp+48h+arg_0]
    push    eax
    call    sub_4B86E0
    jmp     short loc_484AD2
    ; ---------------------------------------------------------------------------

    loc_484A9F:                             ; CODE XREF: sub_4848E0+156j
    mov     cl, [esi+37F06h]
    shr     cl, 6
    test    cl, 1
    jz      short loc_484AC3
    mov     edx, [esp+3Ch+var_1C]
    mov     ecx, [esp+3Ch+arg_0]
    lea     eax, [esp+3Ch+var_10]
    push    edx
    push    eax
    push    ecx
    call    sub_4BFF20
    jmp     short loc_484AD2
    ; ---------------------------------------------------------------------------

    loc_484AC3:                             ; CODE XREF: sub_4848E0+1CBj
    mov     eax, [esp+3Ch+arg_0]
    lea     edx, [esp+3Ch+var_10]
    push    edx
    push    eax
    call    sub_4BFE10

    loc_484AD2:                             ; CODE XREF: sub_4848E0+1A6j
                                            ; sub_4848E0+1BDj ...
    mov     esi, TAdynmemStructPtr

    loc_484AD8:                             ; CODE XREF: sub_4848E0+14Ej
    mov     al, [ebp+0]
    test    al, al
    jbe     short loc_484B1A
    mov     ebp, [esp+3Ch+var_18]
    lea     ecx, [edi+ebx]
    add     ecx, ebp
    and     eax, 0FFh
    and     ecx, 3
    dec     eax
    push    eax
    mov     edx, [esi+ecx*4+1485Fh]
    push    edx
    call    sub_4B7F30
    mov     ecx, [esp+3Ch+var_C]
    mov     edx, [esp+3Ch+var_10]
    push    ecx
    push    edx
    push    eax
    mov     eax, [esp+48h+arg_0]
    push    eax
    call    sub_4B7F90

    loc_484B14:                             ; CODE XREF: sub_4848E0+144j
    mov     esi, TAdynmemStructPtr

    loc_484B1A:                             ; CODE XREF: sub_4848E0+1FDj
    mov     ecx, [esp+3Ch+var_28]
    mov     edx, [esp+3Ch+var_2C]
    inc     edi
    add     edx, 20h
    mov     eax, [ecx+4]
    mov     [esp+3Ch+var_2C], edx
    cmp     edi, eax
    jb      loc_4849C0

    loc_484B35:                             ; CODE XREF: sub_4848E0+CDj
    mov     eax, [ecx+8]
    inc     ebx
    cmp     ebx, eax
    jb      loc_4849A6

    loc_484B41:                             ; CODE XREF: sub_4848E0+C0j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    4
    sub_4848E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_484B50 proc near                    ; CODE XREF: sub_48F200+18p
                                            ; sub_498CD0+23p ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    sub     esp, 18h
    test    eax, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    jge     short loc_484B61
    xor     eax, eax

    loc_484B61:                             ; CODE XREF: sub_484B50+Dj
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14223h]
    cmp     eax, edx
    jl      short loc_484B74
    lea     eax, [edx-1]

    loc_484B74:                             ; CODE XREF: sub_484B50+1Fj
    mov     ebp, [esp+28h+arg_4]
    test    ebp, ebp
    jge     short loc_484B7E
    xor     ebp, ebp

    loc_484B7E:                             ; CODE XREF: sub_484B50+2Aj
    mov     edx, [ecx+14227h]
    cmp     ebp, edx
    jl      short loc_484B8B
    lea     ebp, [edx-1]

    loc_484B8B:                             ; CODE XREF: sub_484B50+36j
    shl     eax, 10h
    mov     [esp+28h+var_18], eax
    mov     eax, ebp
    and     al, 0F0h
    mov     ebx, 80h
    lea     edi, [eax+80h]
    shl     edi, 10h
    jmp     short loc_484BAC
    ; ---------------------------------------------------------------------------

    loc_484BA6:                             ; CODE XREF: sub_484B50+AAj
    mov     ecx, TAdynmemStructPtr

    loc_484BAC:                             ; CODE XREF: sub_484B50+54j
    xor     eax, eax
    mov     [esp+28h+var_10], edi
    mov     al, [ecx+1427Fh]
    lea     ecx, [esp+28h+var_18]
    push    ecx
    mov     esi, eax
    call    sub_485070
    cmp     eax, esi
    jle     short loc_484BD4
    lea     edx, [esp+28h+var_18]
    push    edx
    call    sub_485070
    jmp     short loc_484BD6
    ; ---------------------------------------------------------------------------

    loc_484BD4:                             ; CODE XREF: sub_484B50+76j
    mov     eax, esi

    loc_484BD6:                             ; CODE XREF: sub_484B50+82j
    movsx   esi, word ptr [esp+28h+var_10+2]
    shl     eax, 10h
    mov     [esp+28h+var_14], eax
    movsx   ecx, word ptr [esp+28h+var_14+2]
    sar     ecx, 1
    sub     esi, ecx
    cmp     esi, ebp
    jle     short loc_484C01
    sub     ebx, 10h
    sub     edi, 100000h
    test    ebx, ebx
    jge     short loc_484BA6
    jmp     loc_484CB9
    ; ---------------------------------------------------------------------------

    loc_484C01:                             ; CODE XREF: sub_484B50+9Dj
    mov     edx, [esp+28h+var_18]
    mov     ecx, TAdynmemStructPtr
    mov     [esp+28h+var_8], eax
    mov     eax, [esp+28h+var_10]
    mov     [esp+28h+var_4], eax
    add     eax, 100000h
    mov     [esp+28h+var_4], eax
    mov     [esp+28h+var_C], edx
    xor     eax, eax
    lea     edx, [esp+28h+var_C]
    mov     al, [ecx+1427Fh]
    push    edx
    mov     edi, eax
    call    sub_485070
    cmp     eax, edi
    jle     short loc_484C48
    lea     eax, [esp+28h+var_C]
    push    eax
    call    sub_485070
    jmp     short loc_484C4A
    ; ---------------------------------------------------------------------------

    loc_484C48:                             ; CODE XREF: sub_484B50+EAj
    mov     eax, edi

    loc_484C4A:                             ; CODE XREF: sub_484B50+F6j
    movsx   ecx, word ptr [esp+28h+var_4+2]
    shl     eax, 10h
    mov     [esp+28h+var_8], eax
    movsx   edx, word ptr [esp+28h+var_8+2]
    sar     edx, 1
    sub     ecx, edx
    cmp     esi, ecx
    jge     short loc_484C67
    cmp     ebp, esi
    jge     short loc_484C6B

    loc_484C67:                             ; CODE XREF: sub_484B50+111j
    cmp     ebp, ecx
    jg      short loc_484CB5

    loc_484C6B:                             ; CODE XREF: sub_484B50+115j
    mov     eax, ebp
    sub     ecx, esi
    sub     eax, esi
    mov     ebx, [esp+28h+var_10]
    shl     eax, 14h
    cdq
    idiv    ecx
    mov     ecx, TAdynmemStructPtr
    lea     edx, [esp+28h+var_18]
    push    edx
    add     ebx, eax
    xor     eax, eax
    mov     [esp+2Ch+var_10], ebx
    mov     al, [ecx+1427Fh]
    mov     esi, eax
    call    sub_485070
    cmp     eax, esi
    jle     short loc_484CAE
    lea     eax, [esp+28h+var_18]
    push    eax
    call    sub_485070
    shl     eax, 10h
    jmp     short loc_484CB9
    ; ---------------------------------------------------------------------------

    loc_484CAE:                             ; CODE XREF: sub_484B50+14Dj
    mov     eax, esi
    shl     eax, 10h
    jmp     short loc_484CB9
    ; ---------------------------------------------------------------------------

    loc_484CB5:                             ; CODE XREF: sub_484B50+119j
    mov     eax, [esp+28h+var_14]

    loc_484CB9:                             ; CODE XREF: sub_484B50+ACj
                                            ; sub_484B50+15Cj ...
    mov     ecx, [esp+28h+arg_8]
    mov     edx, [esp+28h+var_18]
    pop     edi
    pop     esi
    mov     [ecx], edx
    pop     ebp
    pop     ebx
    mov     [ecx+4], eax
    mov     eax, [esp+18h+var_10]
    mov     [ecx+8], eax
    add     esp, 18h
    retn    0Ch
    sub_484B50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_484CE0 proc near                    ; CODE XREF: sub_4326B0+379p

    arg_0= dword ptr  8

    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    push    edi
    push    offset aMetal                   ; char *
    mov     ecx, ebp
    call    sub_4B4560
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+14233h]
    imul    esi, [eax+14237h]
    push    esi                             ; int
    call    sub_4B4F10
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     ecx, [eax+14287h]
    xor     eax, eax
    test    esi, esi
    jle     short loc_484D31
    add     ecx, 7

    loc_484D24:                             ; CODE XREF: sub_484CE0+4Fj
    mov     dl, [ecx]
    add     ecx, 0Dh
    mov     [eax+edi], dl
    inc     eax
    cmp     eax, esi
    jl      short loc_484D24

    loc_484D31:                             ; CODE XREF: sub_484CE0+3Fj
    push    offset aPlotmap                 ; "Plotmap"
    mov     ecx, ebp
    call    sub_4B4BA0
    push    esi
    push    edi
    mov     ecx, ebp
    call    sub_4B4CF0
    push    edi
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    retn    4
    sub_484CE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_484D60 proc near                    ; CODE XREF: sub_432610+50p

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    push    edi
    push    offset aMetal                   ; char *
    mov     ecx, ebx
    call    sub_4B4560
    test    eax, eax
    jz      short loc_484DE7
    push    offset aPlotmap                 ; "Plotmap"
    mov     ecx, ebx
    call    sub_4B4BA0
    test    eax, eax
    jz      short loc_484DE7
    mov     eax, TAdynmemStructPtr
    mov     ecx, ebx
    mov     esi, [eax+14233h]
    imul    esi, [eax+14237h]
    call    sub_4B4BF0
    cmp     eax, esi
    jnz     short loc_484DE7
    push    esi                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     edi, eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, ebx
    push    esi
    push    edi
    mov     ebp, [eax+14287h]
    call    sub_4B4C80
    cmp     eax, esi
    jb      short loc_484DE7
    xor     eax, eax
    test    esi, esi
    jle     short loc_484DDE
    lea     ecx, [ebp+7]

    loc_484DD1:                             ; CODE XREF: sub_484D60+7Cj
    mov     dl, [eax+edi]
    inc     eax
    mov     [ecx], dl
    add     ecx, 0Dh
    cmp     eax, esi
    jl      short loc_484DD1

    loc_484DDE:                             ; CODE XREF: sub_484D60+6Cj
    push    edi
    call    sub_4B4F20
    add     esp, 4

    loc_484DE7:                             ; CODE XREF: sub_484D60+16j
                                            ; sub_484D60+26j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_484D60 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_484DF0 proc near                    ; CODE XREF: sub_4326B0+36Fp

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    push    edi
    push    offset aPlayerfeatures          ; char *
    mov     ecx, ebx
    call    sub_4B4560
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14233h]
    mov     esi, [ecx+14287h]
    imul    eax, [ecx+14237h]
    cdq
    sub     eax, edx
    mov     edi, eax
    sar     edi, 1
    push    edi                             ; int
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jz      short loc_484E77
    xor     eax, eax
    test    edi, edi
    jle     short loc_484E59
    add     esi, 19h

    loc_484E3C:                             ; CODE XREF: sub_484DF0+67j
    mov     cl, [esi]
    mov     dl, [esi-0Dh]
    shr     cl, 3
    and     dl, 0F8h
    and     cl, 0Fh
    shl     dl, 1
    or      cl, dl
    add     esi, 1Ah
    mov     [eax+ebp], cl
    inc     eax
    cmp     eax, edi
    jl      short loc_484E3C

    loc_484E59:                             ; CODE XREF: sub_484DF0+47j
    push    offset aPlotmap                 ; "Plotmap"
    mov     ecx, ebx
    call    sub_4B4BA0
    push    edi
    push    ebp
    mov     ecx, ebx
    call    sub_4B4CF0
    push    ebp
    call    sub_4B4F20
    add     esp, 4

    loc_484E77:                             ; CODE XREF: sub_484DF0+41j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_484DF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_484E80 proc near                    ; CODE XREF: sub_432610+56p

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    push    offset aPlayerfeatures          ; char *
    mov     ecx, esi
    call    sub_4B4560
    test    eax, eax
    jz      loc_484F3B
    push    offset aPlotmap                 ; "Plotmap"
    mov     ecx, esi
    call    sub_4B4BA0
    test    eax, eax
    jz      loc_484F3B
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14233h]
    imul    eax, [ecx+14237h]
    cdq
    sub     eax, edx
    mov     ecx, esi
    mov     ebp, eax
    sar     ebp, 1
    call    sub_4B4BF0
    cmp     eax, ebp
    jnz     short loc_484F3B
    push    ebp                             ; int
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    test    edi, edi
    jz      short loc_484F3B
    mov     eax, TAdynmemStructPtr
    push    ebp
    push    edi
    mov     ecx, esi
    mov     ebx, [eax+14287h]
    call    sub_4B4C80
    cmp     eax, ebp
    jb      short loc_484F3B
    xor     esi, esi
    test    ebp, ebp
    jle     short loc_484F32
    lea     eax, [ebx+19h]

    loc_484F05:                             ; CODE XREF: sub_484E80+B0j
    mov     cl, [esi+edi]
    mov     dl, [eax-0Dh]
    shr     cl, 1
    and     cl, 78h
    and     dl, 87h
    or      cl, dl
    mov     dl, [eax]
    mov     [eax-0Dh], cl
    mov     cl, [esi+edi]
    and     cl, 0Fh
    and     dl, 87h
    shl     cl, 3
    or      cl, dl
    inc     esi
    mov     [eax], cl
    add     eax, 1Ah
    cmp     esi, ebp
    jl      short loc_484F05

    loc_484F32:                             ; CODE XREF: sub_484E80+80j
    push    edi
    call    sub_4B4F20
    add     esp, 4

    loc_484F3B:                             ; CODE XREF: sub_484E80+16j
                                            ; sub_484E80+2Aj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_484E80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_484F50 proc near                    ; CODE XREF: sub_4326B0+35Bp

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    push    offset aMapping_0               ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, TAdynmemStructPtr
    push    offset aData                    ; "Data"
    mov     ecx, edi
    mov     esi, [eax+14233h]
    imul    esi, [eax+14237h]
    shl     esi, 1
    shr     esi, 2
    call    sub_4B4BA0
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+14273h]
    push    ecx
    mov     ecx, edi
    call    sub_4B4CF0
    pop     edi
    pop     esi
    retn    4
    sub_484F50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_484FA0 proc near                    ; CODE XREF: sub_432610+5Cp

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    push    offset aMapping_0               ; char *
    mov     ecx, edi
    call    sub_4B4560
    test    eax, eax
    jz      short loc_484FFC
    push    offset aData                    ; "Data"
    mov     ecx, edi
    call    sub_4B4BA0
    test    eax, eax
    jz      short loc_484FFC
    mov     eax, TAdynmemStructPtr
    mov     ecx, edi
    mov     esi, [eax+14233h]
    imul    esi, [eax+14237h]
    shl     esi, 1
    shr     esi, 2
    call    sub_4B4BF0
    cmp     eax, esi
    jnz     short loc_484FFC
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+14273h]
    push    ecx
    mov     ecx, edi
    call    sub_4B4C80

    loc_484FFC:                             ; CODE XREF: sub_484FA0+14j
                                            ; sub_484FA0+24j ...
    pop     edi
    pop     esi
    retn    4
    sub_484FA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485010 proc near                    ; CODE XREF: sub_46B9D0+16p
                                            ; sub_47D2E0+A5p

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    push    esi
    movsx   eax, word ptr [ecx+2]
    movsx   ecx, word ptr [ecx]
    test    ecx, ecx
    jl      short loc_485051
    mov     edx, TAdynmemStructPtr
    mov     esi, [edx+14233h]
    cmp     ecx, esi
    jge     short loc_485051
    test    eax, eax
    jl      short loc_485051
    cmp     eax, [edx+14237h]
    jge     short loc_485051
    imul    eax, esi
    add     eax, ecx
    lea     ecx, [eax+eax*2]
    lea     eax, [eax+ecx*4]
    mov     ecx, [edx+14287h]
    add     eax, ecx
    jmp     short loc_485053
    ; ---------------------------------------------------------------------------

    loc_485051:                             ; CODE XREF: sub_485010+Ej
                                            ; sub_485010+1Ej ...
    xor     eax, eax

    loc_485053:                             ; CODE XREF: sub_485010+3Fj
    test    eax, eax
    jz      short loc_485062
    xor     edx, edx
    mov     dl, [eax+4]
    mov     eax, edx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_485062:                             ; CODE XREF: sub_485010+45j
    xor     eax, eax
    pop     esi
    retn    4
    sub_485010 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485070 proc near                    ; CODE XREF: .text:00404C17p
                                            ; .text:00404CE6p ...

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    movsx   eax, word ptr [ecx+2]
    movsx   edx, word ptr [ecx+0Ah]
    mov     ecx, eax
    mov     esi, edx
    sar     ecx, 4
    sar     esi, 4
    and     eax, 0Fh
    and     edx, 0Fh
    test    ecx, ecx
    push    edi
    mov     ebp, eax
    mov     [esp+10h+arg_0], edx
    jl      loc_485136
    mov     edi, TAdynmemStructPtr
    lea     eax, [ecx+1]
    mov     edx, [edi+14233h]
    cmp     eax, edx
    jge     loc_485136
    test    esi, esi
    jl      short loc_485136
    mov     ebx, [edi+14237h]
    lea     eax, [esi+1]
    cmp     eax, ebx
    jge     short loc_485136
    mov     eax, edx
    xor     ebx, ebx
    imul    eax, esi
    mov     esi, [edi+14287h]
    add     eax, ecx
    lea     edi, [edx+edx*2]
    lea     ecx, [eax+eax*2]
    lea     ecx, [eax+ecx*4]
    xor     eax, eax
    mov     al, [ecx+esi+4]
    add     ecx, esi
    mov     esi, eax
    xor     eax, eax
    mov     al, [ecx+11h]
    lea     ecx, [ecx+edi*4]
    sub     eax, esi
    imul    eax, ebp
    lea     edi, [ecx+edx]
    cdq
    mov     bl, [edi+4]
    and     edx, 0Fh
    add     eax, edx
    mov     ecx, eax
    xor     eax, eax
    mov     al, [edi+11h]
    sub     eax, ebx
    imul    eax, ebp
    cdq
    and     edx, 0Fh
    sar     ecx, 4
    add     eax, edx
    add     ecx, esi
    sar     eax, 4
    sub     eax, ecx
    add     eax, ebx
    imul    eax, [esp+10h+arg_0]
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4
    add     eax, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_485136:                             ; CODE XREF: sub_485070+28j
                                            ; sub_485070+3Fj ...
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn    4
    sub_485070 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485140 proc near                    ; CODE XREF: sub_420F30+C5p
                                            ; sub_4213B0+BDp ...

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    push    esi
    movsx   eax, word ptr [ecx+2]
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     esi, eax
    movsx   eax, word ptr [ecx+0Ah]
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     esi, 4
    sar     eax, 4
    test    esi, esi
    jl      short loc_485196
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+14233h]
    cmp     esi, ecx
    jge     short loc_485196
    test    eax, eax
    jl      short loc_485196
    cmp     eax, [edx+14237h]
    jge     short loc_485196
    imul    ecx, eax
    add     ecx, esi
    lea     eax, [ecx+ecx*2]
    lea     ecx, [ecx+eax*4]
    mov     eax, [edx+14287h]
    add     ecx, eax
    jmp     short loc_485198
    ; ---------------------------------------------------------------------------

    loc_485196:                             ; CODE XREF: sub_485140+23j
                                            ; sub_485140+33j ...
    xor     ecx, ecx

    loc_485198:                             ; CODE XREF: sub_485140+54j
    test    ecx, ecx
    jz      short loc_4851AE
    xor     eax, eax
    xor     edx, edx
    mov     al, [ecx+6]
    mov     dl, [ecx+5]
    add     eax, edx
    sar     eax, 1
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4851AE:                             ; CODE XREF: sub_485140+5Aj
    or      eax, 0FFFFFFFFh
    pop     esi
    retn    4
    sub_485140 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 0Ch
    mov     eax, [esp+20h]
    mov     ecx, [esp+1Ch]
    push    ebx
    mov     ebx, [esp+14h]
    push    ebp
    push    esi
    mov     esi, [esp+20h]
    mov     ebp, [esp+24h]
    sub     eax, esi
    sub     ecx, ebx
    mov     [esp+10h], eax
    mov     eax, ecx
    cdq
    push    edi
    mov     edi, [esp+34h]
    mov     esi, eax
    sub     edi, ebp
    xor     esi, edx
    mov     eax, edi
    sub     esi, edx
    mov     [esp+10h], ecx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     esi, eax
    jl      short loc_485203
    mov     eax, esi

    loc_485203:                             ; CODE XREF: .text:004851FFj
    cdq
    and     edx, 0FFFFFh
    add     eax, edx
    mov     esi, eax
    mov     eax, ecx
    sar     esi, 14h
    cdq
    inc     esi
    idiv    esi
    mov     [esp+10h], eax
    mov     eax, edi
    cdq
    idiv    esi
    xor     edi, edi
    test    esi, esi
    mov     [esp+18h], eax
    jl      loc_485315
    inc     esi
    mov     [esp+2Ch], esi
    mov     esi, TAdynmemStructPtr

    loc_485239:                             ; CODE XREF: .text:0048530Fj
    mov     eax, ebp
    cdq
    and     edx, 0FFFFFh
    add     eax, edx
    mov     ecx, eax
    mov     eax, ebx
    cdq
    and     edx, 0FFFFFh
    add     eax, edx
    sar     ecx, 14h
    sar     eax, 14h
    js      short loc_485284
    mov     edx, [esi+14233h]
    cmp     eax, edx
    jge     short loc_485284
    test    ecx, ecx
    jl      short loc_485284
    cmp     ecx, [esi+14237h]
    jge     short loc_485284
    imul    ecx, edx
    add     ecx, eax
    lea     eax, [ecx+ecx*2]
    lea     eax, [ecx+eax*4]
    mov     ecx, [esi+14287h]
    add     eax, ecx
    jmp     short loc_485286
    ; ---------------------------------------------------------------------------

    loc_485284:                             ; CODE XREF: .text:00485257j
                                            ; .text:00485261j ...
    xor     eax, eax

    loc_485286:                             ; CODE XREF: .text:00485282j
    test    eax, eax
    jz      short loc_4852EC
    mov     edx, [esi+1426Fh]
    xor     ecx, ecx
    mov     cx, [eax+8]
    shl     ecx, 8
    movzx   cx, byte ptr [edx+ecx+0FAh]
    movzx   dx, byte ptr [eax+4]
    add     ecx, edx
    cmp     di, cx
    jge     short loc_4852B0
    mov     edi, ecx

    loc_4852B0:                             ; CODE XREF: .text:004852ACj
    mov     ax, [eax]
    test    ax, ax
    jz      short loc_4852EC
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [esi+14357h]
    lea     eax, [eax+eax*4]
    mov     edx, [ecx+eax*8+92h]
    lea     eax, [ecx+eax*8]
    mov     eax, [eax+6Eh]
    mov     ecx, [edx+16Eh]
    add     eax, ecx
    sar     eax, 10h
    cmp     di, ax
    jge     short loc_4852EC
    mov     edi, eax

    loc_4852EC:                             ; CODE XREF: .text:00485288j
                                            ; .text:004852B6j ...
    mov     eax, [esp+10h]
    mov     edx, [esp+24h]
    mov     ecx, [esp+18h]
    add     ebx, eax
    mov     eax, [esp+14h]
    add     ebp, ecx
    add     edx, eax
    mov     eax, [esp+2Ch]
    dec     eax
    mov     [esp+24h], edx
    mov     [esp+2Ch], eax
    jnz     loc_485239

    loc_485315:                             ; CODE XREF: .text:00485228j
    movsx   eax, di
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    18h
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    mov     edx, [esp+8]
    push    ebx
    push    esi
    test    ecx, ecx
    push    edi
    jl      short loc_485372
    mov     esi, TAdynmemStructPtr
    mov     edi, [esi+14233h]
    cmp     ecx, edi
    jge     short loc_485372
    test    edx, edx
    jl      short loc_485372
    cmp     edx, [esi+14237h]
    jge     short loc_485372
    mov     eax, edx
    imul    eax, edi
    add     eax, ecx
    lea     edi, [eax+eax*2]
    lea     eax, [eax+edi*4]
    mov     edi, [esi+14287h]
    add     eax, edi
    jmp     short loc_485374
    ; ---------------------------------------------------------------------------

    loc_485372:                             ; CODE XREF: .text:0048533Dj
                                            ; .text:0048534Dj ...
    xor     eax, eax

    loc_485374:                             ; CODE XREF: .text:00485370j
    test    eax, eax
    jz      short loc_48539F
    mov     esi, [esp+18h]
    xor     edi, edi
    mov     ebx, esi
    shl     ecx, 4
    mov     [ebx], edi
    shl     edx, 4
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [esi+2], cx
    movzx   ax, byte ptr [eax+4]
    mov     [esi+6], ax
    mov     [esi+0Ah], dx

    loc_48539F:                             ; CODE XREF: .text:00485376j
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    esi
    mov     edx, [eax]
    test    edx, edx
    jge     short loc_4853C3
    mov     dword ptr [eax], 0
    jmp     short loc_4853E3
    ; ---------------------------------------------------------------------------

    loc_4853C3:                             ; CODE XREF: .text:004853B9j
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+14223h]
    mov     esi, ecx
    shl     esi, 10h
    cmp     edx, esi
    jl      short loc_4853E3
    add     ecx, 0FFFFh
    shl     ecx, 10h
    mov     [eax], ecx

    loc_4853E3:                             ; CODE XREF: .text:004853C1j
                                            ; .text:004853D6j
    mov     ecx, [eax+8]
    test    ecx, ecx
    jge     short loc_4853F5
    mov     dword ptr [eax+8], 0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4853F5:                             ; CODE XREF: .text:004853E8j
    mov     edx, TAdynmemStructPtr
    mov     edx, [edx+14227h]
    mov     esi, edx
    shl     esi, 10h
    cmp     ecx, esi
    jl      short loc_485416
    add     edx, 0FFFFh
    shl     edx, 10h
    mov     [eax+8], edx

    loc_485416:                             ; CODE XREF: .text:00485408j
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485420 proc near                    ; CODE XREF: Network_Process+1B78p
                                            ; sub_4934B0+1E5p

    arg_0= dword ptr  14h
    arg_4= byte ptr  18h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    mov     cl, byte ptr [esp+arg_0]
    mov     ebx, 1
    mov     ebp, 1
    mov     eax, [edi+14233h]
    xor     esi, esi
    imul    eax, [edi+14237h]
    cdq
    and     edx, 3
    shl     ebx, cl
    mov     cl, [esp+arg_4]
    add     eax, edx
    sar     eax, 2
    shl     ebp, cl
    test    eax, eax
    mov     [esp+arg_0], eax
    jle     short loc_48548C

    loc_485460:                             ; CODE XREF: sub_485420+6Aj
    mov     eax, [edi+14273h]
    mov     dx, [eax+esi*2]
    lea     ecx, [eax+esi*2]
    mov     eax, ebx
    and     eax, edx
    test    ax, ax
    jz      short loc_485483
    mov     eax, ebp
    or      eax, edx
    mov     [ecx], ax
    mov     edi, TAdynmemStructPtr

    loc_485483:                             ; CODE XREF: sub_485420+54j
    mov     eax, [esp+arg_0]
    inc     esi
    cmp     esi, eax
    jl      short loc_485460

    loc_48548C:                             ; CODE XREF: sub_485420+3Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_485420 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4854A0 proc near                    ; CODE XREF: sub_4917D0+104p

    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    arg_14= dword ptr  18h

    sub     esp, 30h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     word ptr [eax+1436Fh], 0
    mov     eax, TAdynmemStructPtr
    push    edi
    mov     ebx, [eax+14373h]
    and     ebx, 0FFFFFFFDh
    mov     [eax+14373h], ebx
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37EE6h]
    mov     [eax+1434Fh], cx
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     dx, [eax+37EE6h]
    imul    dx, 0Ah
    inc     edx
    mov     [eax+14351h], dx
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+14351h]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    shl     ecx, 3
    push    ecx
    push    offset aUnitMemory              ; "UNIT MEMORY"
    call    sub_4D83B0
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    add     esp, 8
    mov     [edx+14357h], eax
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+14351h]
    mov     ebp, [eax+14357h]
    mov     eax, ecx
    mov     edi, ebp
    shl     eax, 3
    sub     eax, ecx
    mov     [esp+40h+var_2C], ebp
    lea     ecx, [eax+eax*4]
    xor     eax, eax
    shl     ecx, 3
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     ax, [ecx+37EE6h]
    lea     esi, [eax+eax*4]
    shl     esi, 1
    lea     edx, [esi+esi]
    push    edx
    push    offset aHotUnits                ; "HOT UNITS"
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    lea     edx, [esi+esi*4]
    add     esp, 8
    shl     edx, 1
    push    edx
    push    offset aHotRadarUnits           ; "HOT RADAR UNITS"
    mov     [ecx+1435Fh], eax
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [ecx+14363h], eax
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cx, [edx+14351h]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8-118h]
    mov     [edx+1435Bh], eax
    xor     edx, edx
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+14351h], dx
    jbe     short loc_48562B

    loc_4855ED:                             ; CODE XREF: sub_4854A0+189j
    mov     ecx, edx
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     eax, [ebp+eax*8+0]
    mov     [eax+0A8h], dx
    mov     ecx, TAdynmemStructPtr
    inc     edx
    mov     ecx, [ecx+1439Bh]
    mov     [eax+92h], ecx
    mov     eax, TAdynmemStructPtr
    cmp     dx, [eax+14351h]
    jb      short loc_4855ED

    loc_48562B:                             ; CODE XREF: sub_4854A0+14Bj
    mov     edx, TAdynmemStructPtr
    lea     ecx, [esp+40h+var_28]
    lea     eax, [edx+1B63h]
    mov     edx, 0Ah

    loc_485640:                             ; CODE XREF: sub_4854A0+1ABj
    mov     [ecx], eax
    add     eax, 14Bh
    add     ecx, 4
    dec     edx
    jnz     short loc_485640
    mov     eax, 28h
    cmp     eax, 40h
    jg      short loc_4856C7
    lea     ebx, [esp+40h+var_24]

    loc_48565B:                             ; CODE XREF: sub_4854A0+220j
    mov     eax, TAdynmemStructPtr
    mov     esi, [ebx]
    mov     edi, [esp+40h+var_28]
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_485680
    mov     ecx, [esi+4]
    mov     edx, [edi+4]
    cmp     ecx, edx
    jmp     short loc_485682
    ; ---------------------------------------------------------------------------

    loc_485680:                             ; CODE XREF: sub_4854A0+1D4j
    cmp     esi, edi

    loc_485682:                             ; CODE XREF: sub_4854A0+1DEj
    sbb     eax, eax
    neg     eax
    test    eax, eax
    jnz     short loc_485698
    push    offset sub_485940
    push    esi
    push    ebx
    call    sub_488920
    jmp     short loc_4856B7
    ; ---------------------------------------------------------------------------

    loc_485698:                             ; CODE XREF: sub_4854A0+1E8j
    lea     edx, [esp+40h+var_28]
    mov     eax, ebx
    cmp     edx, ebx
    jz      short loc_4856B3

    loc_4856A2:                             ; CODE XREF: sub_4854A0+211j
    mov     ecx, [eax-4]
    sub     eax, 4
    lea     edx, [esp+40h+var_28]
    cmp     eax, edx
    mov     [eax+4], ecx
    jnz     short loc_4856A2

    loc_4856B3:                             ; CODE XREF: sub_4854A0+200j
    mov     [esp+40h+var_28], esi

    loc_4856B7:                             ; CODE XREF: sub_4854A0+1F6j
    add     ebx, 4
    lea     eax, [esp+40h]
    cmp     ebx, eax
    jnz     short loc_48565B
    jmp     loc_48587E
    ; ---------------------------------------------------------------------------

    loc_4856C7:                             ; CODE XREF: sub_4854A0+1B5j
    cmp     eax, 40h
    lea     ebx, [esp+40h]
    lea     edi, [esp+40h+var_28]
    jle     loc_48578E

    loc_4856D8:                             ; CODE XREF: sub_4854A0+2E8j
    mov     eax, ebx
    mov     esi, [edi]
    sub     eax, edi
    mov     ecx, [ebx-4]
    sar     eax, 2
    cdq
    sub     eax, edx
    mov     [esp+40h+var_30], ecx
    sar     eax, 1
    mov     ebp, [edi+eax*4]
    push    ebp
    push    esi
    call    sub_485940
    test    eax, eax
    jz      short loc_48571D
    mov     edx, [esp+40h+var_30]
    push    edx
    push    ebp
    call    sub_485940
    test    eax, eax
    jnz     short loc_485741
    mov     ebp, [esp+40h+var_30]
    push    ebp
    push    esi
    call    sub_485940
    test    eax, eax
    jnz     short loc_485741
    mov     eax, esi
    jmp     short loc_485743
    ; ---------------------------------------------------------------------------

    loc_48571D:                             ; CODE XREF: sub_4854A0+259j
    mov     eax, [esp+40h+var_30]
    push    eax
    push    esi
    call    sub_485940
    test    eax, eax
    jz      short loc_485730
    mov     eax, esi
    jmp     short loc_485743
    ; ---------------------------------------------------------------------------

    loc_485730:                             ; CODE XREF: sub_4854A0+28Aj
    mov     esi, [esp+40h+var_30]
    push    esi
    push    ebp
    call    sub_485940
    test    eax, eax
    mov     eax, esi
    jnz     short loc_485743

    loc_485741:                             ; CODE XREF: sub_4854A0+268j
                                            ; sub_4854A0+277j
    mov     eax, ebp

    loc_485743:                             ; CODE XREF: sub_4854A0+27Bj
                                            ; sub_4854A0+28Ej ...
    push    offset sub_485940
    push    eax
    push    ebx
    push    edi
    call    sub_488960
    mov     esi, eax
    mov     ecx, ebx
    mov     edx, esi
    sub     ecx, esi
    sub     edx, edi
    and     ecx, 0FFFFFFFCh
    and     edx, 0FFFFFFFCh
    push    0
    cmp     ecx, edx
    push    offset sub_485940
    jg      short loc_485776
    push    ebx
    push    esi
    call    sub_488810
    mov     ebx, esi
    jmp     short loc_48577F
    ; ---------------------------------------------------------------------------

    loc_485776:                             ; CODE XREF: sub_4854A0+2C9j
    push    esi
    push    edi
    call    sub_488810
    mov     edi, esi

    loc_48577F:                             ; CODE XREF: sub_4854A0+2D4j
    mov     eax, ebx
    sub     eax, edi
    and     al, 0FCh
    cmp     eax, 40h
    jg      loc_4856D8

    loc_48578E:                             ; CODE XREF: sub_4854A0+232j
    lea     ebp, [esp+40h+var_24]

    loc_485792:                             ; CODE XREF: sub_4854A0+379j
    mov     ecx, TAdynmemStructPtr
    mov     edi, [ebp+0]
    mov     esi, [esp+40h+var_28]
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_4857B9
    mov     edx, [edi+4]
    mov     ebx, [esi+4]
    cmp     edx, ebx
    jmp     short loc_4857BB
    ; ---------------------------------------------------------------------------

    loc_4857B9:                             ; CODE XREF: sub_4854A0+30Dj
    cmp     edi, esi

    loc_4857BB:                             ; CODE XREF: sub_4854A0+317j
    sbb     eax, eax
    neg     eax
    test    eax, eax
    jnz     short loc_4857F1
    mov     eax, [ebp-4]
    lea     esi, [ebp-4]
    push    eax
    push    edi
    mov     ebx, ebp
    call    sub_485940
    test    eax, eax
    jz      short loc_4857ED

    loc_4857D6:                             ; CODE XREF: sub_4854A0+34Bj
    mov     ecx, [esi]
    mov     [ebx], ecx
    mov     edx, [esi-4]
    mov     ebx, esi
    sub     esi, 4
    push    edx
    push    edi
    call    sub_485940
    test    eax, eax
    jnz     short loc_4857D6

    loc_4857ED:                             ; CODE XREF: sub_4854A0+334j
    mov     [ebx], edi
    jmp     short loc_485810
    ; ---------------------------------------------------------------------------

    loc_4857F1:                             ; CODE XREF: sub_4854A0+321j
    lea     ecx, [esp+40h+var_28]
    mov     eax, ebp
    cmp     ecx, ebp
    jz      short loc_48580C

    loc_4857FB:                             ; CODE XREF: sub_4854A0+36Aj
    mov     edx, [eax-4]
    sub     eax, 4
    lea     ecx, [esp+40h+var_28]
    cmp     eax, ecx
    mov     [eax+4], edx
    jnz     short loc_4857FB

    loc_48580C:                             ; CODE XREF: sub_4854A0+359j
    mov     [esp+40h+var_28], edi

    loc_485810:                             ; CODE XREF: sub_4854A0+34Fj
    add     ebp, 4
    lea     edx, [esp+40h+arg_14]
    cmp     ebp, edx
    jnz     loc_485792
    lea     ebp, [esp+40h+arg_14]

    loc_485823:                             ; CODE XREF: sub_4854A0+3D8j
    mov     ebx, [ebp+0]
    mov     [esp+40h+var_30], ebp
    mov     esi, ebp

    loc_48582C:                             ; CODE XREF: sub_4854A0+3C7j
    mov     eax, TAdynmemStructPtr
    mov     edi, [esi-4]
    sub     esi, 4
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_485851
    mov     ecx, [ebx+4]
    mov     edx, [edi+4]
    cmp     ecx, edx
    jmp     short loc_485853
    ; ---------------------------------------------------------------------------

    loc_485851:                             ; CODE XREF: sub_4854A0+3A5j
    cmp     ebx, edi

    loc_485853:                             ; CODE XREF: sub_4854A0+3AFj
    sbb     eax, eax
    neg     eax
    test    eax, eax
    jz      short loc_485869
    mov     eax, [esp+40h+var_30]
    mov     edx, [esi]
    mov     [esp+40h+var_30], esi
    mov     [eax], edx
    jmp     short loc_48582C
    ; ---------------------------------------------------------------------------

    loc_485869:                             ; CODE XREF: sub_4854A0+3B9j
    mov     ecx, [esp+40h+var_30]
    add     ebp, 4
    lea     edx, [esp+40h]
    cmp     ebp, edx
    mov     [ecx], ebx
    jnz     short loc_485823
    mov     ebp, [esp+40h+var_2C]

    loc_48587E:                             ; CODE XREF: sub_4854A0+222j
    xor     edi, edi
    mov     byte ptr [ebp+0FFh], 0FFh
    mov     [ebp+96h], edi
    lea     ebp, [esp+40h+var_28]
    or      ebx, 0FFFFFFFFh

    loc_485894:                             ; CODE XREF: sub_4854A0+48Ej
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     eax, [ebp+0]
    mov     cx, [edx+37EE6h]
    imul    ecx, edi
    inc     ecx
    mov     edx, ecx
    shl     edx, 3
    sub     edx, ecx
    lea     ecx, [edx+edx*4]
    mov     edx, [esp+40h+var_2C]
    lea     esi, [edx+ecx*8]
    xor     edx, edx
    mov     [eax+67h], esi
    mov     ecx, TAdynmemStructPtr
    mov     dx, [ecx+37EE6h]
    mov     ecx, edx
    shl     ecx, 3
    sub     ecx, edx
    lea     edx, [ecx+ecx*4]
    lea     ecx, [esi+edx*8-118h]
    mov     edx, esi
    mov     [eax+6Bh], ecx
    mov     cx, [edx+0A8h]
    mov     edx, [eax+6Bh]
    mov     [eax+6Fh], cx
    mov     cx, [edx+0A8h]
    mov     [eax+71h], cx
    mov     ecx, esi
    cmp     ecx, edx
    ja      short loc_485927

    loc_485902:                             ; CODE XREF: sub_4854A0+485j
    mov     [ecx+96h], eax
    mov     dl, [eax+146h]
    mov     [ecx+0FFh], dl
    mov     [ecx+0ACh], ebx
    mov     edx, [eax+6Bh]
    add     ecx, 118h
    cmp     ecx, edx
    jbe     short loc_485902

    loc_485927:                             ; CODE XREF: sub_4854A0+460j
    inc     edi
    add     ebp, 4
    cmp     edi, 0Ah
    jl      loc_485894
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn
    sub_4854A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485940 proc near                    ; CODE XREF: sub_4854A0+252p
                                            ; sub_4854A0+261p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    mov     ecx, [esp+arg_0]
    cmp     eax, 3
    jnz     short loc_48596A
    mov     eax, [esp+arg_4]
    mov     edx, [ecx+4]
    cmp     edx, [eax+4]
    sbb     eax, eax
    neg     eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48596A:                             ; CODE XREF: sub_485940+17j
    cmp     ecx, [esp+arg_4]
    sbb     eax, eax
    neg     eax
    retn    8
    sub_485940 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485980 proc near                    ; CODE XREF: sub_491B60+35p
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    mov     esi, [eax+14357h]
    mov     edi, [eax+1435Bh]
    test    esi, esi
    jz      short loc_4859BC
    cmp     esi, edi
    ja      short loc_4859BC

    loc_48599B:                             ; CODE XREF: sub_485980+35j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_4859AD
    push    8
    push    esi
    call    sub_4864B0

    loc_4859AD:                             ; CODE XREF: sub_485980+23j
    add     esi, 118h
    cmp     esi, edi
    jbe     short loc_48599B
    mov     eax, TAdynmemStructPtr

    loc_4859BC:                             ; CODE XREF: sub_485980+15j
                                            ; sub_485980+19j
    mov     eax, [eax+14363h]
    test    eax, eax
    jz      short loc_4859CF
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4859CF:                             ; CODE XREF: sub_485980+44j
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+14363h], 0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+1435Fh]
    test    eax, eax
    jz      short loc_4859F7
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4859F7:                             ; CODE XREF: sub_485980+6Cj
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+1435Fh], 0
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+14357h]
    test    eax, eax
    jz      short loc_485A1F
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_485A1F:                             ; CODE XREF: sub_485980+94j
    mov     ecx, TAdynmemStructPtr
    pop     edi
    pop     esi
    mov     dword ptr [ecx+14357h], 0
    retn
    sub_485980 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485A40 proc near                    ; CODE XREF: sub_485E90+68p
                                            ; sub_485F50+150p ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h
    arg_C= dword ptr  18h
    arg_10= dword ptr  1Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    xor     ecx, ecx
    push    edi
    xor     ebx, ebx
    mov     cx, [esi+0A6h]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1439Bh]
    lea     eax, [eax+eax*8]
    add     edx, eax
    mov     eax, [esi+110h]
    or      eax, 10000000h
    mov     [esi+92h], edx
    mov     [esi+110h], eax
    mov     cl, [edx+22Fh]
    mov     edi, eax
    xor     eax, eax
    and     edi, 0DFFFBFFFh
    cmp     cl, bl
    setz    al
    and     eax, 1
    shl     eax, 1Dh
    or      edi, eax
    mov     [esi+110h], edi
    mov     ecx, [edx+14Ah]
    mov     [esi+7Eh], ecx
    mov     eax, [edx+241h]
    and     eax, 0FFFF0000h
    mov     ecx, edi
    shl     eax, 0Fh
    and     ecx, 7FFFFFFFh
    or      eax, ecx
    mov     [esi+110h], eax
    mov     ecx, [edx+241h]
    mov     eax, [esi+114h]
    shr     ecx, 7
    and     al, 0FEh
    and     ecx, 1
    or      eax, ecx
    mov     [esi+114h], eax
    mov     ecx, [edx+241h]
    mov     eax, [esi+110h]
    and     ecx, 200h
    and     eax, 0BFFFFFFFh
    shl     ecx, 15h
    or      eax, ecx
    mov     [esi+110h], eax
    mov     eax, [esp+4+arg_10]
    cmp     eax, ebx
    jz      short loc_485B27
    mov     [esi+104h], ebx
    mov     ax, [edx+1FAh]
    mov     [esi+108h], ax
    jmp     short loc_485B3E
    ; ---------------------------------------------------------------------------

    loc_485B27:                             ; CODE XREF: sub_485A40+CFj
    mov     dword ptr [esi+104h], 3F800000h
    mov     [esi+100h], ebx
    mov     [esi+108h], bx

    loc_485B3E:                             ; CODE XREF: sub_485A40+E5j
    mov     al, [esi+10Fh]
    mov     ecx, [esi+110h]
    and     al, 0F0h
    and     ecx, 0FFFDF3E1h
    mov     [esi+10Fh], al
    lea     eax, [esi+6Ah]
    mov     edi, eax
    mov     eax, [esp+4+arg_4]
    or      ecx, 10021h
    mov     [esi+0F6h], bl
    mov     [esi+110h], ecx
    mov     ecx, [esp+4+arg_8]
    mov     [edi], eax
    mov     [esi+0F7h], bl
    mov     [esi+10Eh], bl
    mov     [esi+0B0h], ebx
    mov     [edi+4], ecx
    mov     ecx, [esp+4+arg_C]
    mov     [esi+68h], bx
    mov     [edi+8], ecx
    mov     edi, [esi+7Eh]
    mov     [esp+4+arg_10], edi
    movsx   edi, di
    shl     edi, 13h
    sub     eax, edi
    add     eax, 80000h
    sar     eax, 14h
    mov     word ptr [esp+4+arg_0], ax
    movsx   eax, word ptr [esp+4+arg_10+2]
    shl     eax, 13h
    sub     ecx, eax
    xor     eax, eax
    add     ecx, 80000h
    sar     ecx, 14h
    mov     word ptr [esp+4+arg_0+2], cx
    mov     ecx, [esp+4+arg_0]
    mov     [esi+76h], ecx
    mov     ax, [edx+210h]
    push    eax                             ; int
    call    GetRandom
    mov     ecx, [esi+92h]
    mov     dx, [ecx+210h]
    mov     ecx, 8000h
    shr     dx, 1
    sub     ecx, edx
    mov     edx, [esi+96h]
    add     eax, ecx
    mov     [esi+64h], bx
    mov     [esi+66h], ax
    mov     [esi+7Ah], bx
    mov     [esi+7Ch], bx
    mov     [esi+0FAh], bl
    mov     [esi+0FBh], ebx
    mov     al, [edx+146h]
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    cmp     al, [edx+TAdynmemStruct.LOS_Sight]
    mov     eax, [esi+110h]
    setz    cl
    and     ecx, 1
    and     ah, 0FCh
    shl     ecx, 9
    or      ecx, eax
    xor     edi, edi
    mov     [esi+110h], ecx

    loc_485C4E:                             ; CODE XREF: sub_485A40+221j
    push    edi
    push    esi
    call    sub_48A160
    push    edi
    mov     ecx, esi
    call    sub_489800
    inc     edi
    cmp     edi, 3
    jl      short loc_485C4E
    mov     ecx, [esi+92h]
    mov     eax, [esi+110h]
    mov     [esi+0BAh], bx
    mov     [esi+0B8h], bx
    mov     [esi+0F0h], ebx
    mov     byte ptr [esi+0F4h], 0Ah
    mov     edx, [ecx+241h]
    and     eax, 0FFF3FFFFh
    and     edx, 3
    shl     edx, 12h
    or      eax, edx
    mov     [esi+110h], eax
    mov     edx, [ecx+241h]
    and     edx, 0Ch
    and     eax, 0FFCFFFFFh
    shl     edx, 12h
    or      eax, edx
    mov     [esi+110h], eax
    mov     edx, [ecx+241h]
    and     edx, 10h
    and     eax, 0F3FFF7FFh
    shl     edx, 7
    or      eax, edx
    mov     [esi+110h], eax
    mov     dl, [ecx+22Eh]
    cmp     dl, 1
    jbe     short loc_485CEC
    and     eax, 0FCFFFFFFh
    or      eax, 0C00000h
    jmp     short loc_485CF1
    ; ---------------------------------------------------------------------------

    loc_485CEC:                             ; CODE XREF: sub_485A40+29Ej
    and     eax, 0FC3FFFFFh

    loc_485CF1:                             ; CODE XREF: sub_485A40+2AAj
    mov     [esi+110h], eax
    mov     al, [esi+0FFh]
    push    eax
    lea     ecx, [esi+0BCh]
    mov     [esi+0F8h], bl
    call    sub_401070
    push    10000h                          ; int
    mov     byte ptr [esi+0F9h], 0FFh
    call    GetRandom
    push    ebx
    push    esi
    mov     [esi+0AAh], ax
    call    sub_480250
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_485A40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485D40 proc near                    ; CODE XREF: sub_485E90+6Ep
                                            ; sub_485F50+156p ...

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    esi
    mov     esi, [esp+8+arg_0]
    mov     edx, [ecx+14377h]
    xor     eax, eax
    mov     ax, [esi+0A6h]
    mov     ebx, [edx+eax*4]
    mov     eax, [esi+92h]
    mov     ecx, [eax+18Eh]
    test    ecx, ecx
    jz      loc_485DFE
    push    edi
    push    544h                            ; int
    call    sub_4B4F10
    mov     edi, eax
    add     esp, 4
    test    edi, edi
    jz      short loc_485D97
    mov     ecx, edi
    call    sub_4B0610
    mov     dword ptr [edi], offset off_4FD698
    mov     ecx, edi
    jmp     short loc_485D99
    ; ---------------------------------------------------------------------------

    loc_485D97:                             ; CODE XREF: sub_485D40+44j
    xor     ecx, ecx

    loc_485D99:                             ; CODE XREF: sub_485D40+55j
    mov     edx, [esi+92h]
    mov     [esi+9Ah], ecx
    mov     eax, [edx+18Eh]
    push    eax
    call    sub_4B0720
    mov     ecx, [esi+92h]
    push    esi
    mov     edx, [ecx+18Eh]
    push    edx
    push    ebx
    call    sub_45A950
    mov     ecx, [esi+9Ah]
    push    eax
    mov     [esi+9Eh], eax
    call    sub_480D40
    mov     ecx, [esi+9Ah]
    push    1                               ; RunNow
    push    0                               ; CompletedScriptMethodCallback
    push    offset aCreate                  ; FunctionName
    call    InvokeScript
    mov     eax, [esi+9Eh]
    pop     edi
    mov     dword ptr [eax+10h], 0
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_485DFE:                             ; CODE XREF: sub_485D40+2Cj
    push    ebx
    mov     dword ptr [esi+9Ah], 0
    call    sub_45A8D0
    mov     [esi+9Eh], eax
    mov     [eax+0Ch], esi
    mov     eax, [esi+9Eh]
    pop     esi
    pop     ebx
    mov     dword ptr [eax+10h], 0
    retn    4
    sub_485D40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485E30 proc near                    ; DATA XREF: .rdata:004FD6E8o

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    call    sub_4B06F0
    test    [esp+arg_0], 1
    jz      short loc_485E48
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_485E48:                             ; CODE XREF: sub_485E30+Dj
    mov     eax, esi
    pop     esi
    retn    4
    sub_485E30 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    push    2Fh
    call    sub_4B4F10
    mov     esi, [esp+0Ch]
    add     esp, 4
    test    eax, eax
    jz      short loc_485E6D
    push    esi
    mov     ecx, eax
    call    sub_43DC00
    jmp     short loc_485E6F
    ; ---------------------------------------------------------------------------

    loc_485E6D:                             ; CODE XREF: .text:00485E61j
    xor     eax, eax

    loc_485E6F:                             ; CODE XREF: .text:00485E6Bj
    mov     [esi], eax
    mov     eax, [esi+92h]
    mov     cx, [eax+210h]
    mov     [esi+66h], cx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_485E90 proc near

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    mov     edx, [esp+arg_0]
    push    esi
    mov     ecx, edx
    mov     esi, [esp+4+arg_14]
    and     ecx, 0FFFFh
    push    edi
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edi, [ecx+1439Bh]
    lea     eax, [eax+eax*8]
    add     edi, eax
    test    esi, esi
    jz      short loc_485ED2
    lea     eax, [esi+8]
    mov     ecx, 3

    loc_485EC6:                             ; CODE XREF: sub_485E90+40j
    mov     dword ptr [eax], offset off_4FD6F0
    add     eax, 1Ch
    dec     ecx
    jnz     short loc_485EC6

    loc_485ED2:                             ; CODE XREF: sub_485E90+2Cj
    mov     [esi+0A6h], dx
    mov     edx, [esp+8+arg_10]
    mov     ecx, [esp+8+arg_4]
    push    edx
    mov     edx, [esp+0Ch+arg_8]
    sub     esp, 0Ch
    mov     eax, esp
    push    esi
    mov     [eax], ecx
    mov     ecx, [esp+1Ch+arg_C]
    mov     [eax+4], edx
    mov     [eax+8], ecx
    call    sub_485A40
    push    esi
    call    sub_485D40
    push    esi
    call    sub_49E070
    push    esi
    call    sub_437840
    cmp     byte ptr [edi+22Fh], 1
    jnz     short loc_485F45
    push    2Fh                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_485F30
    push    esi
    mov     ecx, eax
    call    sub_43DC00
    jmp     short loc_485F32
    ; ---------------------------------------------------------------------------

    loc_485F30:                             ; CODE XREF: sub_485E90+94j
    xor     eax, eax

    loc_485F32:                             ; CODE XREF: sub_485E90+9Ej
    mov     edx, [esi+92h]
    mov     [esi], eax
    mov     ax, [edx+210h]
    mov     [esi+66h], ax

    loc_485F45:                             ; CODE XREF: sub_485E90+86j
    pop     edi
    pop     esi
    retn    18h
    sub_485E90 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_485F50(int,int,int,int,int,int,int,int)
    sub_485F50 proc near                    ; CODE XREF: .text:004028EAp
                                            ; .text:00403D5Bp ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    ebx
    and     eax, 0FFh
    push    ebp
    mov     ecx, eax
    push    esi
    mov     esi, [esp+10h+arg_4]
    push    edi
    shl     ecx, 5
    add     ecx, eax
    mov     edi, TAdynmemStructPtr
    test    si, si
    lea     ecx, [ecx+ecx*4]
    lea     edx, [eax+ecx*2]
    mov     [esp+14h+var_4], edx
    jz      loc_4861BD
    mov     ecx, esi
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    mov     ecx, [edi+TAdynmemStruct.UnitDef]
    lea     eax, [eax+eax*8]
    add     eax, ecx
    mov     [esp+14h+arg_0], eax
    test    dword ptr [eax+241h], 800000h
    jz      loc_4861BD
    mov     ebp, [eax+15Ah]
    cmp     ebp, 0FFFFFFFFh
    jz      short loc_485FEA
    mov     eax, [edi+edx+TAdynmemStruct.Players.Units]
    mov     ecx, [edi+edx+TAdynmemStruct.Players.Units_End]
    xor     ebx, ebx
    cmp     eax, ecx
    ja      short loc_485FE2

    loc_485FCF:                             ; CODE XREF: sub_485F50+90j
    cmp     [eax+0A6h], si
    jnz     short loc_485FD9
    inc     ebx

    loc_485FD9:                             ; CODE XREF: sub_485F50+86j
    add     eax, 118h
    cmp     eax, ecx
    jbe     short loc_485FCF

    loc_485FE2:                             ; CODE XREF: sub_485F50+7Dj
    cmp     ebx, ebp
    jge     loc_4861BD

    loc_485FEA:                             ; CODE XREF: sub_485F50+69j
    mov     ebx, [edi+edx+TAdynmemStruct.Players.Units]
    mov     ebp, [edi+edx+TAdynmemStruct.Players.Units_End]
    mov     esi, ebx
    cmp     esi, ebp
    ja      loc_4861BD
    mov     edx, [esp+14h+arg_1C]

    loc_486006:                             ; CODE XREF: sub_485F50+101j
    test    dx, dx
    jz      short loc_486036
    mov     ecx, edx
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edi+TAdynmemStruct.Units]
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*8]
    cmp     esi, ebx
    jb      loc_4861BD
    cmp     esi, ebp
    ja      loc_4861BD

    loc_486036:                             ; CODE XREF: sub_485F50+B9j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48605D
    test    dx, dx
    jnz     loc_4861BD
    add     esi, 118h
    cmp     esi, ebp
    jbe     short loc_486006
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_48605D:                             ; CODE XREF: sub_485F50+EEj
    test    esi, esi
    jz      short loc_486075
    lea     eax, [esi+8]
    mov     ecx, 3

    loc_486069:                             ; CODE XREF: sub_485F50+123j
    mov     dword ptr [eax], offset off_4FD6F0
    add     eax, 1Ch
    dec     ecx
    jnz     short loc_486069

    loc_486075:                             ; CODE XREF: sub_485F50+10Fj
    mov     edi, [esp+14h+arg_14]
    mov     dx, word ptr [esp+14h+arg_4]
    mov     ecx, [esp+14h+arg_8]
    push    edi
    sub     esp, 0Ch
    mov     [esi+0A6h], dx
    mov     edx, [esp+24h+arg_C]
    mov     eax, esp
    push    esi
    mov     [eax], ecx
    mov     ecx, [esp+28h+arg_10]
    mov     [eax+4], edx
    mov     [eax+8], ecx
    call    sub_485A40
    push    esi
    call    sub_485D40
    push    esi
    call    sub_49E070
    push    esi
    call    sub_437840
    mov     ebx, [esp+14h+arg_0]
    cmp     byte ptr [ebx+22Fh], 1
    jnz     short loc_4860F1
    push    2Fh                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4860DC
    push    esi
    mov     ecx, eax
    call    sub_43DC00
    jmp     short loc_4860DE
    ; ---------------------------------------------------------------------------

    loc_4860DC:                             ; CODE XREF: sub_485F50+180j
    xor     eax, eax

    loc_4860DE:                             ; CODE XREF: sub_485F50+18Aj
    mov     edx, [esi+92h]
    mov     [esi], eax
    mov     ax, [edx+210h]
    mov     [esi+66h], ax

    loc_4860F1:                             ; CODE XREF: sub_485F50+172j
    mov     eax, [esi+110h]
    mov     ecx, [esp+14h+arg_18]
    xor     ecx, eax
    push    esi
    and     ecx, 3
    xor     ecx, eax
    mov     [esi+110h], ecx
    call    sub_48A870
    push    esi
    call    sub_47CC30
    push    esi
    call    sub_456050
    test    edi, edi
    jz      short loc_486177
    mov     al, [ebx+22Fh]
    test    al, al
    jnz     short loc_48612F
    push    esi
    push    esi
    call    sub_4560C0

    loc_48612F:                             ; CODE XREF: sub_485F50+1D6j
    mov     edx, [esi+92h]
    mov     eax, [edx+241h]
    shr     eax, 12h
    test    al, 1
    jz      short loc_48614D
    push    1                               ; int
    push    1                               ; idTo
    mov     ecx, esi
    call    sub_48B090

    loc_48614D:                             ; CODE XREF: sub_485F50+1F0j
    mov     ecx, [esi+92h]
    mov     edx, [ecx+241h]
    shr     edx, 18h
    test    dl, 1
    jz      short loc_486177
    mov     eax, [esi+110h]
    mov     byte ptr [esi+0F5h], 7
    or      ah, 40h
    mov     [esi+110h], eax

    loc_486177:                             ; CODE XREF: sub_485F50+1CCj
                                            ; sub_485F50+20Fj
    push    esi
    call    sub_482AC0
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [esp+18h+var_4]
    inc     [eax+ecx+TAdynmemStruct.Players.NumUnits]
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+ecx+TAdynmemStruct.Players.field_140]
    inc     edx
    mov     [eax+ecx+TAdynmemStruct.Players.field_140], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391EDh]
    call    sub_490580
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4861BD:                             ; CODE XREF: sub_485F50+2Cj
                                            ; sub_485F50+5Aj ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    20h
    sub_485F50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4861D0 proc near                    ; CODE XREF: Network_Process+16A4p
                                            ; sub_48B3F0+A7p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    mov     eax, [esp+0Ch+arg_0]
    push    ebx
    and     eax, 0FFh
    push    ebp
    mov     ecx, eax
    push    esi
    shl     ecx, 5
    add     ecx, eax
    mov     ebx, TAdynmemStructPtr
    push    edi
    mov     edi, [esp+1Ch+arg_4]
    lea     ecx, [ecx+ecx*4]
    lea     edx, [eax+ecx*2]
    mov     ax, [edi+3]
    test    ax, ax
    mov     [esp+1Ch+arg_0], edx
    jnz     short loc_486208
    xor     esi, esi
    jmp     short loc_486220
    ; ---------------------------------------------------------------------------

    loc_486208:                             ; CODE XREF: sub_4861D0+32j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [ebx+14357h]
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*8]

    loc_486220:                             ; CODE XREF: sub_4861D0+36j
    mov     eax, [ebx+edx+1BCAh]
    test    eax, eax
    jnz     short loc_486237
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_486237:                             ; CODE XREF: sub_4861D0+59j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48624F
    push    0
    push    esi
    call    sub_4864B0
    mov     ebx, TAdynmemStructPtr

    loc_48624F:                             ; CODE XREF: sub_4861D0+6Fj
    lea     edx, [edi+5]
    mov     ebp, [edi+5]
    mov     eax, [edx+4]
    mov     [esp+1Ch+var_8], eax
    mov     ecx, [edx+8]
    mov     dx, [edi+1]
    mov     [esp+1Ch+var_4], ecx
    mov     ecx, edx
    and     ecx, 0FFFFh
    mov     edi, [ebx+1439Bh]
    mov     eax, ecx
    shl     eax, 6
    add     eax, ecx
    lea     eax, [eax+eax*8]
    add     edi, eax
    test    esi, esi
    jz      short loc_486299
    lea     eax, [esi+8]
    mov     ecx, 3

    loc_48628D:                             ; CODE XREF: sub_4861D0+C7j
    mov     dword ptr [eax], offset off_4FD6F0
    add     eax, 1Ch
    dec     ecx
    jnz     short loc_48628D

    loc_486299:                             ; CODE XREF: sub_4861D0+B3j
    push    0
    mov     eax, [esp+20h+var_4]
    sub     esp, 0Ch
    mov     [esi+0A6h], dx
    mov     edx, [esp+2Ch+var_8]
    mov     ecx, esp
    push    esi
    mov     [ecx], ebp
    mov     [ecx+4], edx
    mov     [ecx+8], eax
    call    sub_485A40
    push    esi
    call    sub_485D40
    push    esi
    call    sub_49E070
    push    esi
    call    sub_437840
    cmp     byte ptr [edi+22Fh], 1
    jnz     short loc_486305
    push    2Fh                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4862F0
    push    esi
    mov     ecx, eax
    call    sub_43DC00
    jmp     short loc_4862F2
    ; ---------------------------------------------------------------------------

    loc_4862F0:                             ; CODE XREF: sub_4861D0+114j
    xor     eax, eax

    loc_4862F2:                             ; CODE XREF: sub_4861D0+11Ej
    mov     ecx, [esi+92h]
    mov     [esi], eax
    mov     dx, [ecx+210h]
    mov     [esi+66h], dx

    loc_486305:                             ; CODE XREF: sub_4861D0+106j
    push    esi
    call    sub_48A870
    push    esi
    call    sub_47CC30
    push    esi
    call    sub_482AC0
    mov     ecx, TAdynmemStructPtr
    push    esi
    mov     eax, [esp+20h+arg_0]
    inc     word ptr [ecx+eax+1CA7h]
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+eax+1CA3h]
    inc     edx
    mov     [ecx+eax+1CA3h], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391EDh]
    call    sub_490580
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_4861D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_486360 proc near                    ; CODE XREF: sub_4866D0+69Fp

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h
    arg_8= dword ptr  1Ch

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     eax, [edi+92h]
    mov     si, [eax+1BCh]
    mov     eax, [esp+arg_4]
    cmp     eax, 1
    jle     short loc_4863AC
    mov     ecx, TAdynmemStructPtr

    loc_486384:                             ; CODE XREF: sub_486360+4Aj
    cmp     si, 0FFFBh
    jnb     loc_486450
    mov     edx, [ecx+1426Fh]
    and     esi, 0FFFFh
    shl     esi, 8
    dec     eax
    mov     si, [edx+esi+0F4h]
    cmp     eax, 1
    jg      short loc_486384

    loc_4863AC:                             ; CODE XREF: sub_486360+1Cj
    cmp     si, 0FFFBh
    jnb     loc_486450
    movsx   eax, word ptr [edi+78h]
    movsx   ecx, word ptr [edi+76h]
    push    eax
    push    ecx
    call    sub_481550
    mov     ebx, eax
    test    ebx, ebx
    jz      loc_486450
    lea     ebp, [edi+6Ah]
    push    ebp
    call    sub_485070
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+1427Fh]
    cmp     eax, edx
    jg      short loc_486426
    mov     dl, [edi+0FFh]
    lea     eax, [edi+64h]
    push    edx
    push    eax
    push    ebp
    push    esi
    push    ebx
    call    sub_423C50
    xor     ecx, ecx
    cmp     eax, ecx
    jz      short loc_486439
    mov     edx, [edi+92h]
    test    dword ptr [edx+241h], 1000000h
    jnz     short loc_486420
    mov     dword ptr [eax+18h], 0FFFFD334h
    mov     [eax+1Ch], ecx

    loc_486420:                             ; CODE XREF: sub_486360+B4j
    mov     [esp+arg_8], ecx
    jmp     short loc_486439
    ; ---------------------------------------------------------------------------

    loc_486426:                             ; CODE XREF: sub_486360+89j
    mov     al, [edi+0FFh]
    add     edi, 64h
    push    eax
    push    edi
    push    ebp
    push    esi
    push    ebx
    call    sub_423C50

    loc_486439:                             ; CODE XREF: sub_486360+A2j
                                            ; sub_486360+C4j
    mov     eax, [esp+arg_8]
    test    eax, eax
    jz      short loc_486450
    push    9
    push    384h
    push    0Fh
    push    ebp
    call    sub_472630

    loc_486450:                             ; CODE XREF: sub_486360+29j
                                            ; sub_486360+51j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_486360 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     ecx, [eax+92h]
    mov     edx, [eax+96h]
    add     ecx, 20h
    mov     eax, [edx+27h]
    push    ecx
    xor     ecx, ecx
    mov     cl, [eax+95h]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*4]
    lea     eax, [ecx+edx*8]
    mov     ecx, TAdynmemStructPtr
    lea     edx, [ecx+eax*2+37F5Fh]
    push    edx
    call    __strcmpi
    add     esp, 8
    neg     eax
    sbb     eax, eax
    inc     eax
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4864B0 proc near                    ; CODE XREF: sub_485980+28p
                                            ; sub_4861D0+74p ...

    var_10= dword ptr -10h
    idTo= dword ptr -0Ch
    var_5= word ptr -5
    var_3= byte ptr -3
    var_2= byte ptr -2
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+1Ch+arg_0]
    push    edi
    test    dword ptr [esi+110h], 10000000h
    jz      loc_4866B8
    mov     ecx, [esi+96h]
    mov     eax, [esi+92h]
    add     eax, 20h
    mov     edx, [ecx+27h]
    xor     ecx, ecx
    push    eax                             ; char *
    mov     cl, [edx+95h]
    mov     edx, TAdynmemStructPtr
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    lea     eax, [edx+ecx*2+37F5Fh]
    push    eax                             ; char *
    call    __strcmpi
    mov     edi, eax
    add     esp, 8
    neg     edi
    sbb     edi, edi
    inc     edi
    jz      short loc_486521
    mov     eax, [esi+96h]
    and     word ptr [eax+149h], 0FFFEh

    loc_486521:                             ; CODE XREF: sub_4864B0+60j
    mov     ebx, [esp+20h+arg_4]
    cmp     ebx, 7
    jnz     short loc_48653D
    xor     ebp, ebp
    mov     [esp+20h+var_10], 1
    mov     [esp+20h+arg_0], ebp
    jmp     loc_4865D2
    ; ---------------------------------------------------------------------------

    loc_48653D:                             ; CODE XREF: sub_4864B0+78j
    xor     ebp, ebp
    cmp     ebx, 4
    jz      loc_4865CA
    cmp     ebx, 5
    jz      short loc_4865CA
    cmp     ebx, 9
    jz      short loc_4865CA
    mov     ax, [esi+108h]
    cmp     ax, bp
    jg      short loc_4865CA
    movsx   ecx, ax
    mov     eax, ecx
    xor     edx, edx
    neg     eax
    shl     eax, 2
    sub     eax, ecx
    mov     ecx, [esi+92h]
    lea     eax, [eax+eax*4]
    shl     eax, 2
    div     dword ptr [ecx+1FAh]
    xor     edx, edx
    mov     dl, [esi+0F7h]
    add     eax, edx
    cdq
    sub     eax, edx
    sar     eax, 1
    cmp     eax, 1
    mov     [esp+20h+arg_0], eax
    jge     short loc_48659F
    mov     eax, 1
    mov     [esp+20h+arg_0], eax

    loc_48659F:                             ; CODE XREF: sub_4864B0+E4j
    cmp     eax, 64h
    jle     short loc_4865AC
    mov     [esp+20h+arg_0], 64h

    loc_4865AC:                             ; CODE XREF: sub_4864B0+F2j
    push    ebp                             ; int
    lea     eax, [esp+24h+var_10]
    push    ebp                             ; int
    lea     ecx, [esp+28h+arg_0]
    push    eax                             ; int
    push    ecx                             ; int
    mov     ecx, [esi+9Ah]
    push    offset aKilled                  ; int
    call    sub_4B0BC0
    jmp     short loc_4865D2
    ; ---------------------------------------------------------------------------

    loc_4865CA:                             ; CODE XREF: sub_4864B0+92j
                                            ; sub_4864B0+9Bj ...
    mov     [esp+20h+arg_0], ebp
    mov     [esp+20h+var_10], ebp

    loc_4865D2:                             ; CODE XREF: sub_4864B0+88j
                                            ; sub_4864B0+118j
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FD6F8
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_4865E9
    mov     [esp+20h+var_10], ebp

    loc_4865E9:                             ; CODE XREF: sub_4864B0+133j
    mov     al, byte ptr [esp+20h+arg_0]
    mov     dx, [esi+0A8h]
    mov     [esp+20h+var_3], al
    mov     al, [esp+20h+var_2]
    mov     word ptr [esp+20h+idTo+1], dx
    mov     dl, byte ptr [esp+20h+var_10]
    mov     cl, al
    mov     byte ptr [esp+20h+idTo], 0Ch
    xor     cl, dl
    mov     dl, [esi+0F4h]
    and     cl, 0Fh
    push    edx                             ; int
    xor     al, cl
    and     al, 0Fh
    shl     bl, 4
    or      al, bl
    mov     [esp+24h+var_2], al
    call    PlayerNumberToID
    mov     [esp+20h+idTo+3], eax
    mov     eax, [esi+0F0h]
    cmp     eax, ebp
    jnz     short loc_48663F
    mov     [esp+20h+var_5], bp
    jmp     short loc_48664B
    ; ---------------------------------------------------------------------------

    loc_48663F:                             ; CODE XREF: sub_4864B0+186j
    mov     ax, [eax+0A8h]
    mov     [esp+20h+var_5], ax

    loc_48664B:                             ; CODE XREF: sub_4864B0+18Dj
    mov     eax, [esi+96h]
    cmp     [eax], ebp
    jz      short loc_486672
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_486662
    cmp     cl, 2
    jnz     short loc_486672

    loc_486662:                             ; CODE XREF: sub_4864B0+1ABj
    mov     edx, [eax+4]
    lea     ecx, [esp+20h+idTo]
    push    0Bh                             ; idFrom
    push    ecx                             ; idTo
    push    edx                             ; PlayerID
    call    sub_451DF0

    loc_486672:                             ; CODE XREF: sub_4864B0+1A3j
                                            ; sub_4864B0+1B0j
    lea     eax, [esp+20h+idTo]
    push    1
    push    eax
    call    sub_4866D0
    cmp     edi, ebp
    jz      short loc_4866B8
    mov     ecx, TAdynmemStructPtr
    cmp     [ecx+37EF6h], ebp
    jz      short loc_4866B8
    mov     eax, [esi+96h]
    cmp     [eax], ebp
    jz      short loc_4866B8
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_4866A5
    cmp     al, 2
    jnz     short loc_4866B8

    loc_4866A5:                             ; CODE XREF: sub_4864B0+1EFj
    push    1
    call    sub_491D70
    mov     dl, [esi+0FFh]
    push    edx
    call    sub_486F10

    loc_4866B8:                             ; CODE XREF: sub_4864B0+15j
                                            ; sub_4864B0+1D0j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    sub_4864B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4866D0 proc near                    ; CODE XREF: Network_Process+16E3p
                                            ; sub_4864B0+1C9p

    var_68= dword ptr -68h
    var_64= byte ptr -64h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 68h
    mov     edx, TAdynmemStructPtr
    push    ebx
    mov     ebx, [esp+6Ch+arg_0]
    push    ebp
    push    esi
    mov     ax, [ebx+1]
    push    edi
    test    ax, ax
    jnz     short loc_4866EE
    xor     esi, esi
    jmp     short loc_486706
    ; ---------------------------------------------------------------------------

    loc_4866EE:                             ; CODE XREF: sub_4866D0+18j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+TAdynmemStruct.Units]
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*8]

    loc_486706:                             ; CODE XREF: sub_4866D0+1Cj
    test    dword ptr [esi+110h], 10000000h
    jz      loc_486E59
    mov     eax, [esi+UnitStruct.Owner]
    mov     cl, [eax+PlayerStruct.PlayerNumber]
    mov     al, [edx+TAdynmemStruct.LOS_Sight]
    cmp     cl, al
    jnz     short loc_486753
    mov     eax, [esi+UnitStruct.UnitType]
    push    3Ch
    lea     ecx, [esi+UnitStruct.XPos]
    movsx   edx, word ptr [eax+170h]
    movsx   eax, [eax+UnitDefStruct.nSightDistance]
    push    edx
    push    eax
    push    ecx
    call    sub_482910
    mov     edx, TAdynmemStructPtr

    loc_486753:                             ; CODE XREF: sub_4866D0+5Aj
    mov     ax, [ebx+7]
    test    ax, ax
    jnz     short loc_486760
    xor     eax, eax
    jmp     short loc_486778
    ; ---------------------------------------------------------------------------

    loc_486760:                             ; CODE XREF: sub_4866D0+8Aj
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+TAdynmemStruct.Units]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]

    loc_486778:                             ; CODE XREF: sub_4866D0+8Ej
    mov     [esi+0F0h], eax
    mov     edx, [ebx+3]
    push    edx                             ; int
    call    sub_44FE40
    mov     [esi+0F4h], al
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+391EDh]
    call    sub_4904C0
    push    1
    push    esi
    call    sub_439EB0
    push    esi
    call    sub_47F8C0
    push    0FFFFFFFFh
    push    esi
    call    sub_480250
    push    esi
    call    sub_49C880
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_4867D0
    push    1
    push    0FFFFFFFFh
    push    0
    push    esi
    call    sub_48AAC0

    loc_4867D0:                             ; CODE XREF: sub_4866D0+F2j
    mov     eax, [esi+8Ah]
    test    eax, eax
    jz      short loc_48682C

    loc_4867DA:                             ; CODE XREF: sub_4866D0+15Aj
    mov     cl, [ebx+0Ah]
    push    0
    and     cl, 0F0h
    sub     cl, 30h
    neg     cl
    sbb     ecx, ecx
    and     ecx, 3
    add     ecx, 3
    mov     byte ptr [esp+7Ch+var_68], cl
    mov     edx, [esp+7Ch+var_68]
    and     edx, 0FFh
    push    edx
    push    7530h
    push    eax
    mov     eax, [esi+0F0h]
    push    eax
    call    sub_489BB0
    mov     ecx, [esi+8Ah]
    push    1
    push    0FFFFFFFFh
    push    0
    push    ecx
    call    sub_48AAC0
    mov     eax, [esi+8Ah]
    test    eax, eax
    jnz     short loc_4867DA

    loc_48682C:                             ; CODE XREF: sub_4866D0+108j
    push    esi
    call    sub_47CBD0
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+14281h]
    and     al, 2
    cmp     al, 2
    jnz     short loc_48684A
    push    esi
    call    sub_482090

    loc_48684A:                             ; CODE XREF: sub_4866D0+172j
    mov     eax, [esp+78h+arg_4]
    test    eax, eax
    jnz     short loc_48687C
    mov     al, [ebx+9]
    test    al, al
    jle     short loc_48687C
    movsx   ecx, al
    push    0
    push    0
    push    0
    push    ecx
    mov     ecx, [esi+9Ah]
    push    1
    push    1
    push    0
    push    offset aKilled                  ; "Killed"
    call    sub_4B0A70

    loc_48687C:                             ; CODE XREF: sub_4866D0+183j
                                            ; sub_4866D0+18Aj
    xor     edx, edx
    xor     edi, edi
    mov     dl, [ebx+0Ah]
    shr     edx, 4
    lea     eax, [edx-1]                    ; switch 6 cases
    cmp     eax, 5
    ja      loc_486A98                      ; default
    jmp     ds:off_486E64[eax*4]            ; switch jump

    loc_486899:                             ; DATA XREF: .text:00486E64o
    mov     al, [esi+0F4h]                  ; case 0x5
    cmp     al, 0Ah
    jz      loc_486A98                      ; default
    cmp     al, [esi+0FFh]
    jz      loc_486A98                      ; default

    loc_4868B3:                             ; CODE XREF: sub_4866D0+1C2j
                                            ; DATA XREF: .text:00486E64o
    mov     eax, [esi+96h]                  ; case 0x1
    test    eax, eax
    jz      loc_486A98                      ; default
    inc     word ptr [eax+0FEh]
    mov     cl, [esi+0F4h]
    cmp     cl, 0Ah
    jz      short loc_486915
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FD6F8
    fnstsw  ax
    test    ah, 40h
    jz      short loc_486915
    cmp     [esi+0FFh], cl
    jz      short loc_486915
    mov     edx, TAdynmemStructPtr
    and     ecx, 0FFh
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    inc     word ptr [edx+eax*2+1C5Fh]
    lea     eax, [edx+eax*2+1C5Fh]

    loc_486915:                             ; CODE XREF: sub_4866D0+201j
                                            ; sub_4866D0+214j ...
    mov     ecx, [esi+96h]
    mov     eax, [esi+92h]
    add     eax, 20h
    mov     edx, [ecx+27h]
    xor     ecx, ecx
    push    eax                             ; char *
    mov     cl, [edx+95h]
    mov     edx, TAdynmemStructPtr
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    lea     eax, [edx+ecx*2+37F5Fh]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    neg     eax
    sbb     eax, eax
    inc     eax
    mov     [esp+78h+arg_4], eax
    jz      short loc_48699D
    mov     al, [esi+0F4h]
    cmp     al, 0Ah
    jz      short loc_486990
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    inc     word ptr [eax+edx*2+1C67h]
    lea     eax, [eax+edx*2+1C67h]

    loc_486990:                             ; CODE XREF: sub_4866D0+299j
    mov     eax, [esi+96h]
    inc     word ptr [eax+106h]

    loc_48699D:                             ; CODE XREF: sub_4866D0+28Fj
    mov     ecx, [esi+0F0h]
    test    ecx, ecx
    jz      short loc_4869D1
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FD6F8
    fnstsw  ax
    test    ah, 40h
    jz      short loc_4869D1
    mov     dl, [esi+0FFh]
    mov     al, [esi+0F4h]
    cmp     dl, al
    jz      short loc_4869D1
    inc     word ptr [ecx+0B8h]

    loc_4869D1:                             ; CODE XREF: sub_4866D0+2D5j
                                            ; sub_4866D0+2E8j ...
    mov     ecx, TAdynmemStructPtr
    mov     al, [esi+0F4h]
    cmp     al, [ecx+2A42h]
    jnz     loc_486A93
    push    5
    call    sub_494FF0
    jmp     loc_486A93
    ; ---------------------------------------------------------------------------

    loc_4869F5:                             ; CODE XREF: sub_4866D0+1C2j
                                            ; DATA XREF: .text:00486E64o
    mov     ecx, [esi+96h]                  ; case 0x3
    test    ecx, ecx
    jz      loc_486A98                      ; default
    mov     ebx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ebx+2A42h]
    mov     eax, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     eax, [ebx+eax*2]
    xor     ebx, ebx
    mov     bl, [ecx+146h]
    add     eax, edx
    mov     dl, [ebx+eax+1C8Ch]
    test    dl, dl
    jnz     short loc_486A98                ; default
    inc     word ptr [ecx+0FEh]
    mov     ecx, [esi+92h]
    mov     edx, [esi+96h]
    add     ecx, 20h
    push    ecx                             ; char *
    xor     ecx, ecx
    mov     eax, [edx+27h]
    mov     cl, [eax+95h]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*4]
    lea     eax, [ecx+edx*8]
    mov     ecx, TAdynmemStructPtr
    lea     edx, [ecx+eax*2+37F5Fh]
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    neg     eax
    sbb     eax, eax
    inc     eax
    mov     [esp+78h+arg_4], eax
    jz      short loc_486A93
    mov     eax, [esi+96h]
    inc     word ptr [eax+106h]

    loc_486A93:                             ; CODE XREF: sub_4866D0+313j
                                            ; sub_4866D0+320j ...
    mov     edi, 1

    loc_486A98:                             ; CODE XREF: sub_4866D0+1BCj
                                            ; sub_4866D0+1C2j ...
    test    edi, edi                        ; default
    jz      loc_486C9E
    mov     cl, [esi+0F4h]
    cmp     cl, 0Ah
    jz      loc_486C9E
    mov     edx, TAdynmemStructPtr
    and     ecx, 0FFh
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ebx, [edx+eax*2+1B63h]
    mov     [esp+78h+arg_4], ebx
    cmp     dword ptr [ebx], 0
    jz      loc_486C6E
    mov     al, [ebx+73h]
    cmp     al, 1
    jz      short loc_486AF1
    cmp     al, 2
    jz      short loc_486AF1
    cmp     al, 3
    jnz     loc_486C6E

    loc_486AF1:                             ; CODE XREF: sub_4866D0+413j
                                            ; sub_4866D0+417j
    cmp     byte ptr [ebx+146h], 0Ah
    jz      loc_486C6E
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jz      short loc_486B2D
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 2
    jnz     loc_486C6E

    loc_486B2D:                             ; CODE XREF: sub_4866D0+441j
    mov     al, [ebx+148h]
    test    al, al
    jbe     loc_486C6E
    and     eax, 0FFh
    mov     [esp+78h+var_68], eax
    mov     edx, eax
    mov     eax, TAdynmemStructPtr
    cmp     dword ptr [eax+37EF6h], 2
    jnz     short loc_486B5D
    mov     ax, [ebx+104h]
    jmp     short loc_486B64
    ; ---------------------------------------------------------------------------

    loc_486B5D:                             ; CODE XREF: sub_4866D0+482j
    mov     ax, [ebx+0FCh]

    loc_486B64:                             ; CODE XREF: sub_4866D0+48Bj
    mov     ecx, TAdynmemStructPtr
    mov     ebp, 0Ah
    movsx   edi, ax
    lea     eax, [ecx+1B8Ah]

    loc_486B78:                             ; CODE XREF: sub_4866D0+506j
    mov     cl, [eax+4Ch]
    test    cl, cl
    jz      short loc_486BD0
    mov     ecx, [eax]
    mov     cl, [ecx+9Bh]
    shr     cl, 6
    test    cl, 1
    jnz     short loc_486BD0
    mov     ecx, TAdynmemStructPtr
    cmp     dword ptr [ecx+37EF6h], 2
    jnz     short loc_486BA7
    movsx   ecx, word ptr [eax+0DDh]
    jmp     short loc_486BAE
    ; ---------------------------------------------------------------------------

    loc_486BA7:                             ; CODE XREF: sub_4866D0+4CCj
    movsx   ecx, word ptr [eax+0D5h]

    loc_486BAE:                             ; CODE XREF: sub_4866D0+4D5j
    xor     ebx, ebx
    cmp     edi, ecx
    setnle  bl
    mov     ecx, ebx
    test    ecx, ecx
    jz      short loc_486BC9
    xor     ecx, ecx
    mov     cl, [eax+121h]
    cmp     ecx, edx
    jge     short loc_486BC9
    mov     edx, ecx

    loc_486BC9:                             ; CODE XREF: sub_4866D0+4E9j
                                            ; sub_4866D0+4F5j
    mov     ebx, [esp+78h+arg_4]

    loc_486BD0:                             ; CODE XREF: sub_4866D0+4ADj
                                            ; sub_4866D0+4BDj
    add     eax, 14Bh
    dec     ebp
    jnz     short loc_486B78
    cmp     edx, [esp+78h+var_68]
    jge     loc_486C6E
    mov     eax, TAdynmemStructPtr
    mov     edi, 0Ah
    lea     ecx, [eax+1CABh]

    loc_486BF2:                             ; CODE XREF: sub_4866D0+543j
    mov     al, [ecx]
    mov     ebp, eax
    and     ebp, 0FFh
    cmp     ebp, edx
    jl      short loc_486C0C
    cmp     al, [ebx+148h]
    jnb     short loc_486C0C
    inc     al
    mov     [ecx], al

    loc_486C0C:                             ; CODE XREF: sub_4866D0+52Ej
                                            ; sub_4866D0+536j
    add     ecx, 14Bh
    dec     edi
    jnz     short loc_486BF2
    test    edx, edx
    mov     [ebx+148h], dl
    jnz     short loc_486C6E
    mov     ecx, TAdynmemStructPtr
    cmp     dword ptr [ecx+37EF6h], 2
    jnz     short loc_486C37
    mov     ax, [ebx+104h]
    jmp     short loc_486C3E
    ; ---------------------------------------------------------------------------

    loc_486C37:                             ; CODE XREF: sub_4866D0+55Cj
    mov     ax, [ebx+0FCh]

    loc_486C3E:                             ; CODE XREF: sub_4866D0+565j
    movsx   edx, ax
    add     ebx, 2Bh
    push    edx
    push    ebx
    push    offset aSHasTakenTheLe          ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esp+84h+var_64]
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+78h+var_64]
    push    0Ah                             ; char
    push    0                               ; __int16
    push    2                               ; char
    push    ecx                             ; char *
    call    sub_463CA0

    loc_486C6E:                             ; CODE XREF: sub_4866D0+408j
                                            ; sub_4866D0+41Bj ...
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+37F06h]
    shr     al, 7
    test    al, 1
    jz      short loc_486C9E
    mov     ecx, [esi+96h]
    xor     edx, edx
    xor     eax, eax
    mov     dl, [ecx+146h]
    mov     al, [esi+0F4h]
    push    edx
    push    eax
    call    sub_4948B0

    loc_486C9E:                             ; CODE XREF: sub_4866D0+3CAj
                                            ; sub_4866D0+3D9j ...
    mov     ecx, [esp+78h+arg_0]
    mov     dl, [ecx+0Ah]
    and     dl, 0F0h
    cmp     dl, 50h
    jnz     short loc_486D24
    mov     eax, [esi+0F0h]
    test    eax, eax
    jz      short loc_486D24
    fld     ds:flt_4FD6FC
    fsub    dword ptr [esi+104h]
    mov     ecx, [esi+92h]
    fmul    dword ptr [ecx+18Ah]
    mov     ecx, [eax+0ECh]
    cmp     dword ptr [ecx], 0
    jz      short loc_486D18
    cmp     byte ptr [ecx+73h], 2
    jnz     short loc_486D18
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+37EEEh]
    sub     ecx, 0
    jz      short loc_486D06
    dec     ecx
    jnz     short loc_486D18
    fmul    ds:dbl_4FD700
    fld     dword ptr [eax+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_486D1E
    ; ---------------------------------------------------------------------------

    loc_486D06:                             ; CODE XREF: sub_4866D0+61Fj
    fmul    ds:dbl_4FD708
    fld     dword ptr [eax+0D4h]
    fxch    st(1)
    fsubp   st(1), st
    jmp     short loc_486D1E
    ; ---------------------------------------------------------------------------

    loc_486D18:                             ; CODE XREF: sub_4866D0+608j
                                            ; sub_4866D0+60Ej ...
    fadd    dword ptr [eax+0D4h]

    loc_486D1E:                             ; CODE XREF: sub_4866D0+634j
                                            ; sub_4866D0+646j
    fstp    dword ptr [eax+0D4h]

    loc_486D24:                             ; CODE XREF: sub_4866D0+5DBj
                                            ; sub_4866D0+5E5j
    mov     edi, [esp+78h+arg_0]
    mov     al, [edi+9]
    test    al, al
    jle     short loc_486D55
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FD6F8
    fnstsw  ax
    test    ah, 40h
    jz      short loc_486D55
    mov     al, [edi+0Ah]
    xor     ecx, ecx
    and     al, 0F0h
    cmp     al, 30h
    setz    cl
    push    ecx
    push    esi
    call    sub_49B000

    loc_486D55:                             ; CODE XREF: sub_4866D0+65Dj
                                            ; sub_4866D0+670j
    mov     al, [edi+0Ah]
    test    al, 0Fh
    jbe     short loc_486D74
    mov     dl, al
    xor     ecx, ecx
    and     dl, 0F0h
    cmp     dl, 70h
    setnz   cl
    and     eax, 0Fh
    push    ecx
    push    eax
    push    esi
    call    sub_486360

    loc_486D74:                             ; CODE XREF: sub_4866D0+68Aj
    push    esi
    call    sub_489740
    mov     ecx, [esi+9Ah]
    xor     ebx, ebx
    cmp     ecx, ebx
    jz      short loc_486D93
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax+50h]
    mov     [esi+9Ah], ebx

    loc_486D93:                             ; CODE XREF: sub_4866D0+6B4j
    mov     eax, [esi+9Eh]
    cmp     eax, ebx
    jz      short loc_486DA9
    push    eax
    call    sub_45AAA0
    mov     [esi+9Eh], ebx

    loc_486DA9:                             ; CODE XREF: sub_4866D0+6CBj
    mov     edi, [esi]
    cmp     edi, ebx
    jz      short loc_486DC1
    mov     ecx, edi
    call    sub_43DD10
    push    edi
    call    sub_4B4F20
    add     esp, 4
    mov     [esi], ebx

    loc_486DC1:                             ; CODE XREF: sub_4866D0+6DDj
    mov     ebp, [esi+110h]
    mov     [esi+0A6h], bx
    and     ebp, 0EFFFFFFFh
    mov     [esi+110h], ebp
    mov     ecx, TAdynmemStructPtr
    mov     eax, ebp
    mov     edx, [ecx+1439Bh]
    and     al, 0CFh
    mov     [esi+110h], eax
    mov     eax, [esi+96h]
    mov     [esi+92h], edx
    dec     word ptr [eax+144h]
    mov     eax, [esi+96h]
    cmp     [eax+144h], bx
    jnz     short loc_486E59
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_486E37
    mov     edx, [esi+96h]
    mov     eax, [edx+4]
    push    eax
    call    sub_450380

    loc_486E37:                             ; CODE XREF: sub_4866D0+756j
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 2
    jnz     short loc_486E59
    mov     edx, [esi+96h]
    push    edx
    call    sub_47BD70

    loc_486E59:                             ; CODE XREF: sub_4866D0+40j
                                            ; sub_4866D0+740j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    8
    sub_4866D0 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_486E64 dd offset loc_4868B3         ; DATA XREF: sub_4866D0+1C2r
    dd offset loc_486A98                    ; jump table for switch statement
    dd offset loc_4869F5
    dd offset loc_486A98
    dd offset loc_486899
    dd offset loc_4868B3
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_486E80 proc near                    ; CODE XREF: .text:004174B8p

    arg_0= word ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     bx, [esp+4+arg_0]
    push    esi
    mov     esi, [eax+14357h]
    push    edi
    mov     edi, [eax+1435Bh]
    test    bx, bx
    jz      short loc_486EC1
    test    esi, esi
    jz      short loc_486EC1
    cmp     esi, edi
    ja      short loc_486EC1

    loc_486EA6:                             ; CODE XREF: sub_486E80+3Fj
    cmp     [esi+0A6h], bx
    jnz     short loc_486EB7
    push    8
    push    esi
    call    sub_4864B0

    loc_486EB7:                             ; CODE XREF: sub_486E80+2Dj
    add     esi, 118h
    cmp     esi, edi
    jbe     short loc_486EA6

    loc_486EC1:                             ; CODE XREF: sub_486E80+1Cj
                                            ; sub_486E80+20j ...
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_486E80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_486ED0 proc near                    ; CODE XREF: .text:004164BDp
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    mov     esi, [eax+14357h]
    mov     edi, [eax+1435Bh]
    test    esi, esi
    jz      short loc_486F07
    cmp     esi, edi
    ja      short loc_486F07

    loc_486EEB:                             ; CODE XREF: sub_486ED0+35j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_486EFD
    push    8
    push    esi
    call    sub_4864B0

    loc_486EFD:                             ; CODE XREF: sub_486ED0+23j
    add     esi, 118h
    cmp     esi, edi
    jbe     short loc_486EEB

    loc_486F07:                             ; CODE XREF: sub_486ED0+15j
                                            ; sub_486ED0+19j
    pop     edi
    pop     esi
    retn
    sub_486ED0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_486F10 proc near                    ; CODE XREF: .text:004164DFp
                                            ; sub_4169D0+30p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    push    esi
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    push    edi
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2]
    lea     ecx, [eax+1B63h]
    test    ecx, ecx
    jz      loc_486FC4
    cmp     word ptr [ecx+144h], 0
    jz      short loc_486FC4
    mov     esi, [eax+1BCAh]
    mov     edi, [eax+1BCEh]
    test    esi, esi
    jz      short loc_486FC4
    cmp     esi, edi
    ja      short loc_486FC4
    push    ebx
    mov     ebx, 4000h

    loc_486F62:                             ; CODE XREF: sub_486F10+B1j
    mov     eax, [esi+110h]
    test    eax, 10000000h
    jz      short loc_486FB9
    test    ebx, eax
    jnz     short loc_486FB9
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_486F9B
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_486F89
    cmp     al, 2
    jnz     short loc_486F9B

    loc_486F89:                             ; CODE XREF: sub_486F10+73j
    push    0
    push    3
    push    7530h
    push    esi
    push    esi
    call    sub_489BB0
    jmp     short loc_486FB9
    ; ---------------------------------------------------------------------------

    loc_486F9B:                             ; CODE XREF: sub_486F10+6Cj
                                            ; sub_486F10+77j
    push    1
    push    esi
    call    sub_49B000
    mov     edx, [esi+110h]
    push    3
    or      edx, ebx
    push    esi
    mov     [esi+110h], edx
    call    sub_4864B0

    loc_486FB9:                             ; CODE XREF: sub_486F10+5Dj
                                            ; sub_486F10+61j ...
    add     esi, 118h
    cmp     esi, edi
    jbe     short loc_486F62
    pop     ebx

    loc_486FC4:                             ; CODE XREF: sub_486F10+28j
                                            ; sub_486F10+36j ...
    pop     edi
    pop     esi
    retn    4
    sub_486F10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_486FD0 proc near                    ; CODE XREF: sub_432610+62p

    var_B8= dword ptr -0B8h
    var_97= dword ptr -97h
    arg_0= dword ptr  4

    sub     esp, 0B8h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+0C4h+arg_0]
    push    edi
    push    offset aUnits_0                 ; char *
    mov     ecx, esi
    call    sub_4B4560
    test    eax, eax
    jz      short loc_487065
    xor     ebp, ebp
    mov     ecx, esi
    push    ebp                             ; int
    push    offset aVersion                 ; char *
    call    sub_4B4800
    cmp     eax, 11h
    jnz     short loc_487065
    push    ebp                             ; int
    push    offset aNumberOfUnits           ; char *
    mov     ecx, esi
    call    sub_4B4800
    mov     ebx, eax
    xor     edi, edi
    cmp     ebx, ebp
    jle     short loc_487065

    loc_48701A:                             ; CODE XREF: sub_486FD0+93j
    push    edi
    mov     ecx, esi
    call    sub_4B4B50
    test    eax, eax
    jz      short loc_487060
    push    ebp
    mov     ecx, esi
    call    sub_4B4C10
    lea     eax, [esp+0C8h+var_B8]
    push    0B8h
    push    eax
    mov     ecx, esi
    call    sub_4B4C80
    cmp     eax, 0B8h
    jz      short loc_487055
    add     eax, 2
    cmp     eax, 0B8h
    jnz     short loc_487060
    mov     word ptr [esp+0C8h+var_97], bp

    loc_487055:                             ; CODE XREF: sub_486FD0+74j
    mov     ecx, [esp+0C8h+var_97]
    push    esi
    push    ecx
    call    sub_487080

    loc_487060:                             ; CODE XREF: sub_486FD0+54j
                                            ; sub_486FD0+7Ej
    inc     edi
    cmp     edi, ebx
    jl      short loc_48701A

    loc_487065:                             ; CODE XREF: sub_486FD0+1Fj
                                            ; sub_486FD0+33j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0B8h
    retn    4
    sub_486FD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_487080 proc near                    ; CODE XREF: sub_43A420+1CDp
                                            ; sub_44DE80+68p ...

    var_100= dword ptr -100h
    var_FC= dword ptr -0FCh
    var_F8= byte ptr -0F8h
    var_D7= dword ptr -0D7h
    var_D1= dword ptr -0D1h
    var_CD= dword ptr -0CDh
    var_C9= dword ptr -0C9h
    var_C5= dword ptr -0C5h
    var_C1= dword ptr -0C1h
    var_BD= word ptr -0BDh
    var_BB= word ptr -0BBh
    var_B9= word ptr -0B9h
    var_B3= dword ptr -0B3h
    var_6F= dword ptr -6Fh
    var_6B= byte ptr -6Bh
    var_6A= byte ptr -6Ah
    var_69= dword ptr -69h
    var_65= dword ptr -65h
    var_61= dword ptr -61h
    var_5D= dword ptr -5Dh
    var_59= dword ptr -59h
    var_55= dword ptr -55h
    var_51= dword ptr -51h
    var_4D= byte ptr -4Dh
    var_4C= byte ptr -4Ch
    var_4B= byte ptr -4Bh
    var_4A= word ptr -4Ah
    var_48= byte ptr -48h
    var_47= byte ptr -47h
    var_46= byte ptr -46h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_20= dword ptr -20h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 100h
    push    ebx
    mov     ebx, [esp+104h+arg_0]
    push    ebp
    push    esi
    test    bx, bx
    push    edi
    jnz     short loc_48709A
    xor     eax, eax
    jmp     short loc_4870BB
    ; ---------------------------------------------------------------------------

    loc_48709A:                             ; CODE XREF: sub_487080+14j
    mov     ecx, ebx
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [edx+eax*8]

    loc_4870BB:                             ; CODE XREF: sub_487080+18j
    test    eax, eax
    jz      loc_4876AE
    test    dword ptr [eax+110h], 10000000h
    jnz     loc_4876AE
    mov     edi, [esp+110h+arg_4]
    push    0                               ; int
    push    offset aNumberOfUnits           ; char *
    mov     ecx, edi
    call    sub_4B4800
    mov     esi, eax
    xor     ebp, ebp
    test    esi, esi
    mov     [esp+110h+var_100], ebp
    jle     short loc_487148

    loc_4870F4:                             ; CODE XREF: sub_487080+BFj
    mov     eax, [esp+110h+var_100]
    mov     ecx, edi
    push    eax
    call    sub_4B4B50
    test    eax, eax
    jz      loc_4876AC
    push    0
    mov     ecx, edi
    call    sub_4B4C10
    lea     ecx, [esp+110h+var_F8]
    push    0B8h
    push    ecx
    mov     ecx, edi
    call    sub_4B4C80
    cmp     eax, 0B8h
    jnz     loc_4876AC
    cmp     word ptr [esp+110h+var_D7], bx
    jz      short loc_487143
    mov     eax, [esp+110h+var_100]
    inc     eax
    cmp     eax, esi
    mov     [esp+110h+var_100], eax
    jl      short loc_4870F4
    jmp     short loc_487148
    ; ---------------------------------------------------------------------------

    loc_487143:                             ; CODE XREF: sub_487080+B2j
    mov     ebp, 1

    loc_487148:                             ; CODE XREF: sub_487080+72j
                                            ; sub_487080+C1j
    test    ebp, ebp
    jz      loc_4876AC
    mov     eax, [esp+110h+var_44]
    mov     edx, [esp+110h+var_D7]
    shr     eax, 4
    and     eax, 3
    push    edx                             ; int
    mov     edx, [esp+114h+var_CD]
    push    eax                             ; int
    push    1                               ; int
    mov     eax, [esp+11Ch+var_C9]
    sub     esp, 0Ch                        ; int
    mov     ecx, esp
    mov     [ecx], edx
    mov     edx, [esp+128h+var_C5]
    mov     [ecx+4], eax
    lea     eax, [esp+128h+var_F8]
    push    eax                             ; char *
    mov     [ecx+8], edx
    call    sub_488B10
    push    eax                             ; int
    mov     ecx, [esp+54h]
    push    ecx                             ; int
    call    sub_485F50
    mov     esi, eax
    test    esi, esi
    jz      loc_4876AC
    mov     eax, [esp+110h+var_C1]
    lea     edx, [esi+64h]
    mov     [esi+64h], eax
    mov     cx, [esp+110h+var_BD]
    mov     [edx+4], cx
    mov     dx, [esp+110h+var_BB]
    mov     [esi+108h], dx
    mov     ax, [esp+110h+var_B9]
    mov     [esi+0B8h], ax
    mov     ecx, [esp+110h+var_C9]
    mov     [esi+6Eh], ecx
    mov     eax, [esp+110h+var_6F]
    test    ax, ax
    jz      short loc_487204
    push    edi
    push    eax
    call    sub_487080
    test    eax, eax
    jz      short loc_487204
    mov     edx, [esp+110h+var_44]
    movsx   ecx, [esp+110h+var_6B]
    shr     edx, 4
    and     edx, 3
    push    edx
    push    ecx
    push    eax
    push    esi
    call    sub_48AAC0

    loc_487204:                             ; CODE XREF: sub_487080+159j
                                            ; sub_487080+164j
    mov     edx, [esp+110h+var_6F+2]
    push    edi
    push    edx
    call    sub_487080
    mov     [esi+0F0h], eax
    mov     al, [esp+110h+var_6B]
    mov     [esi+0F9h], al
    mov     cl, [esp+110h+var_6A]
    mov     [esi+0F4h], cl
    mov     edx, [esp+110h+var_69]
    mov     [esi+58h], edx
    mov     eax, [esp+110h+var_65]
    mov     [esi+76h], eax
    mov     ecx, [esp+110h+var_61]
    mov     [esi+7Ah], ecx
    mov     edx, [esp+110h+var_5D]
    mov     [esi+7Eh], edx
    mov     eax, [esp+110h+var_59]
    mov     [esi+0ACh], eax
    mov     ecx, [esp+110h+var_59]
    push    ecx
    push    esi
    call    sub_480250
    mov     edx, [esp+110h+var_51]
    mov     [esi+104h], edx
    mov     al, [esp+110h+var_4D]
    mov     [esi+0F5h], al
    mov     cl, [esp+110h+var_4C]
    mov     [esi+0F6h], cl
    mov     dl, [esp+110h+var_4B]
    mov     [esi+0F7h], dl
    mov     ax, [esp+110h+var_4A]
    mov     [esi+0BAh], ax
    mov     cl, [esp+110h+var_48]
    mov     [esi+0F8h], cl
    mov     dl, [esp+110h+var_47]
    mov     [esi+0FAh], dl
    mov     al, [esp+110h+var_46]
    mov     [esi+10Eh], al
    mov     al, [esi+10Fh]
    mov     cl, byte ptr [esp+110h+var_44]
    xor     cl, al
    and     cl, 1
    xor     cl, al
    mov     [esi+10Fh], cl
    mov     eax, [esp+110h+var_44]
    shr     eax, 1
    and     al, 1
    and     cl, 0FDh
    shl     al, 1
    or      al, cl
    mov     [esi+10Fh], al
    mov     ecx, [esp+110h+var_44]
    shr     ecx, 2
    and     cl, 1
    and     al, 0FBh
    shl     cl, 2
    or      cl, al
    mov     [esi+10Fh], cl
    mov     edx, [esp+110h+var_44]
    shr     edx, 3
    and     dl, 1
    and     cl, 0F7h
    shl     dl, 3
    or      dl, cl
    mov     ecx, [esi+110h]
    mov     [esi+10Fh], dl
    mov     eax, [esp+110h+var_44]
    shr     eax, 4
    and     eax, 0Ch
    and     ecx, 0FFFFFFF3h
    or      eax, ecx
    mov     [esi+110h], eax
    mov     ecx, [esp+110h+var_44]
    shr     ecx, 4
    and     ecx, 10h
    and     al, 0EFh
    or      ecx, eax
    mov     [esi+110h], ecx
    mov     eax, [esp+110h+var_44]
    shr     eax, 4
    and     eax, 20h
    and     ecx, 0FFFFFFDFh
    or      eax, ecx
    mov     [esi+110h], eax
    mov     ecx, [esp+110h+var_44]
    shr     ecx, 4
    and     ecx, 0C0h
    and     al, 3Fh
    or      ecx, eax
    mov     [esi+110h], ecx
    mov     eax, [esp+110h+var_44]
    shr     eax, 4
    and     eax, 100h
    and     ch, 0FEh
    or      eax, ecx
    mov     [esi+110h], eax
    mov     edx, [esp+110h+var_44]
    shr     edx, 4
    and     ah, 0FDh
    and     edx, 200h
    or      eax, edx
    mov     [esi+110h], eax
    mov     ecx, [esp+110h+var_44]
    shr     ecx, 4
    and     ecx, 400h
    and     ah, 0FBh
    or      ecx, eax
    mov     [esi+110h], ecx
    mov     eax, [esp+110h+var_44]
    shr     eax, 4
    and     eax, 800h
    and     ch, 0F7h
    or      eax, ecx
    mov     [esi+110h], eax
    mov     ecx, [esp+110h+var_55]
    mov     edx, [esi+110h]
    mov     [esi+0B0h], ecx
    mov     eax, [esp+110h+var_44]
    and     dh, 0DFh
    shr     eax, 3
    and     eax, 2000h
    or      eax, edx
    mov     [esi+110h], eax
    mov     ecx, [esp+110h+var_44]
    shr     ecx, 6
    and     ecx, 4000h
    and     ah, 0BFh
    or      ecx, eax
    mov     [esi+110h], ecx
    mov     eax, [esp+110h+var_44]
    shr     eax, 6
    and     eax, 8000h
    and     ch, 7Fh
    or      eax, ecx
    mov     [esi+110h], eax
    mov     ecx, [esp+110h+var_44]
    shr     ecx, 6
    and     ecx, 10000h
    and     eax, 0FFFEFFFFh
    or      ecx, eax
    mov     [esi+110h], ecx
    mov     eax, [esp+110h+var_44]
    shr     eax, 6
    and     eax, 20000h
    and     ecx, 0FFFDFFFFh
    or      eax, ecx
    mov     [esi+110h], eax
    mov     ecx, [esp+110h+var_44]
    shr     ecx, 6
    and     ecx, 0C0000h
    and     eax, 0FFF3FFFFh
    or      ecx, eax
    mov     [esi+110h], ecx
    mov     edx, [esp+110h+var_44]
    shr     edx, 6
    and     edx, 300000h
    and     ecx, 0FFCFFFFFh
    or      edx, ecx
    mov     [esi+110h], edx
    mov     eax, [esp+110h+var_44]
    shr     eax, 6
    and     eax, 400000h
    and     edx, 0FFBFFFFFh
    or      eax, edx
    push    edi
    mov     [esi+110h], eax
    mov     ecx, [esp+114h+var_44]
    shr     ecx, 6
    and     eax, 0FC7FFFFFh
    and     ecx, 3800000h
    or      eax, ecx
    push    esi
    lea     ecx, [esi+0BCh]
    mov     [esi+110h], eax
    call    sub_401110
    mov     eax, [esp+110h+var_D1]
    test    eax, eax
    jz      short loc_487546
    mov     ecx, [esi]
    push    edi
    push    esi
    call    sub_43DE30

    loc_487546:                             ; CODE XREF: sub_487080+4BBj
    mov     eax, [esp+110h+var_D7+2]
    lea     edx, [esi+60h]
    xor     ebx, ebx
    lea     ebp, [esi+5Ch]
    test    eax, eax
    mov     [esp+110h+var_FC], edx
    jle     short loc_4875C4

    loc_48755A:                             ; CODE XREF: sub_487080+542j
    xor     eax, eax
    push    ebx
    mov     ax, [esi+0A8h]
    lea     ecx, [esp+114h+var_40]
    push    eax
    push    offset aU04xm04x                ; "u%04xm%04x"
    push    ecx
    call    _sprintf
    add     esp, 10h
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_48759B
    lea     edx, [esp+110h+var_40]
    mov     ecx, eax
    push    edx
    push    edi
    push    esi
    call    sub_43A420
    jmp     short loc_48759D
    ; ---------------------------------------------------------------------------

    loc_48759B:                             ; CODE XREF: sub_487080+506j
    xor     eax, eax

    loc_48759D:                             ; CODE XREF: sub_487080+519j
    test    dword ptr [eax+42h], 40000h
    jz      short loc_4875B5
    mov     ecx, [esp+110h+var_FC]
    mov     [ecx], eax
    add     eax, 4Ah
    mov     [esp+110h+var_FC], eax
    jmp     short loc_4875BB
    ; ---------------------------------------------------------------------------

    loc_4875B5:                             ; CODE XREF: sub_487080+524j
    mov     [ebp+0], eax
    lea     ebp, [eax+4Ah]

    loc_4875BB:                             ; CODE XREF: sub_487080+533j
    mov     eax, [esp+110h+var_D7+2]
    inc     ebx
    cmp     ebx, eax
    jl      short loc_48755A

    loc_4875C4:                             ; CODE XREF: sub_487080+4D8j
    mov     ecx, [esi+5Ch]
    test    ecx, ecx
    jz      short loc_4875D0
    call    sub_4388B0

    loc_4875D0:                             ; CODE XREF: sub_487080+549j
    mov     edx, [esp+110h+var_100]
    lea     eax, [esp+110h+var_20]
    push    edx
    push    offset aScriptI                 ; "Script%i"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+110h+var_20]
    push    ecx
    mov     ecx, edi
    call    sub_4B4BA0
    mov     ecx, [esi+9Ah]
    push    edi
    call    sub_4B2040
    lea     edi, [esp+110h+var_B3]
    lea     eax, [esi+0Ch]
    mov     ebp, 3

    loc_487611:                             ; CODE XREF: sub_487080+60Cj
    mov     edx, [edi-4]
    add     edi, 18h
    mov     [eax-8], edx
    mov     ecx, [edi-18h]
    mov     [eax], ecx
    mov     edx, [eax+4]
    mov     cl, [edi-14h]
    add     eax, 1Ch
    mov     [edx+10Ah], cl
    mov     edx, [edi-10h]
    mov     [eax-14h], edx
    mov     cx, [edi-0Ch]
    mov     [eax-10h], cx
    mov     dx, [edi-0Ah]
    mov     [eax-0Eh], dx
    mov     cx, [edi-8]
    mov     [eax-0Ch], cx
    mov     dl, [edi-6]
    mov     [eax-0Ah], dl
    mov     dl, [eax-9]
    mov     bl, [edi-5]
    mov     cl, dl
    xor     cl, bl
    and     cl, 1
    xor     cl, dl
    mov     [eax-9], cl
    mov     dl, [edi-5]
    xor     dl, cl
    and     dl, 2
    xor     dl, cl
    mov     [eax-9], dl
    mov     cl, [edi-5]
    xor     cl, dl
    and     cl, 0Ch
    xor     cl, dl
    mov     [eax-9], cl
    mov     dl, [edi-5]
    xor     dl, cl
    and     dl, 10h
    xor     dl, cl
    dec     ebp
    mov     [eax-9], dl
    jnz     short loc_487611
    test    byte ptr [esi+10Fh], 4
    jz      short loc_48769D
    push    esi
    call    sub_47DB20

    loc_48769D:                             ; CODE XREF: sub_487080+615j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4876AC:                             ; CODE XREF: sub_487080+82j
                                            ; sub_487080+A7j ...
    xor     eax, eax

    loc_4876AE:                             ; CODE XREF: sub_487080+3Dj
                                            ; sub_487080+4Dj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    8
    sub_487080 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4876C0 proc near                    ; CODE XREF: sub_4326B0+351p

    var_120= dword ptr -120h
    var_11C= dword ptr -11Ch
    var_118= dword ptr -118h
    var_F8= byte ptr -0F8h
    var_F7= word ptr -0F7h
    var_F5= dword ptr -0F5h
    var_F1= dword ptr -0F1h
    var_ED= dword ptr -0EDh
    var_E9= dword ptr -0E9h
    var_E5= dword ptr -0E5h
    var_E1= dword ptr -0E1h
    var_DD= word ptr -0DDh
    var_DB= word ptr -0DBh
    var_D9= word ptr -0D9h
    var_D3= dword ptr -0D3h
    var_8F= word ptr -8Fh
    var_8D= word ptr -8Dh
    var_8B= byte ptr -8Bh
    var_8A= byte ptr -8Ah
    var_89= dword ptr -89h
    var_85= dword ptr -85h
    var_81= dword ptr -81h
    var_7D= dword ptr -7Dh
    var_79= dword ptr -79h
    var_75= dword ptr -75h
    var_71= dword ptr -71h
    var_6D= byte ptr -6Dh
    var_6C= byte ptr -6Ch
    var_6B= byte ptr -6Bh
    var_6A= word ptr -6Ah
    var_68= byte ptr -68h
    var_67= byte ptr -67h
    var_66= word ptr -66h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_40= dword ptr -40h
    var_20= dword ptr -20h
    arg_0= dword ptr  4

    sub     esp, 120h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+130h+arg_0]
    xor     esi, esi
    push    offset aUnits_0                 ; char *
    mov     ecx, edi
    mov     [esp+134h+var_120], esi
    call    sub_4B4560
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+1435Bh]
    mov     ebp, [ecx+14357h]
    cmp     ebp, eax
    mov     [esp+130h+var_11C], eax
    ja      loc_487ABA

    loc_487701:                             ; CODE XREF: sub_4876C0+3F4j
    test    dword ptr [ebp+110h], 10000000h
    jz      loc_487AAC
    push    esi
    lea     eax, [esp+134h+var_60]
    push    offset aScriptI                 ; "Script%i"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+130h+var_60]
    push    ecx
    mov     ecx, edi
    call    sub_4B4BA0
    mov     ecx, [ebp+9Ah]
    push    edi
    call    sub_4B1EC0
    mov     esi, [ebp+5Ch]
    xor     ebx, ebx
    test    esi, esi
    jz      short loc_487784

    loc_48774B:                             ; CODE XREF: sub_4876C0+C2j
    xor     edx, edx
    push    ebx
    mov     dx, [ebp+0A8h]
    lea     eax, [esp+134h+var_20]
    push    edx
    push    offset aU04xm04x                ; "u%04xm%04x"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+130h+var_20]
    push    ecx
    push    edi
    push    ebp
    mov     ecx, esi
    call    sub_43A970
    mov     esi, [esi+4Ah]
    inc     ebx
    test    esi, esi
    jnz     short loc_48774B

    loc_487784:                             ; CODE XREF: sub_4876C0+89j
    mov     esi, [ebp+60h]
    test    esi, esi
    jz      short loc_4877C4

    loc_48778B:                             ; CODE XREF: sub_4876C0+102j
    xor     edx, edx
    push    ebx
    mov     dx, [ebp+0A8h]
    lea     eax, [esp+134h+var_40]
    push    edx
    push    offset aU04xm04x                ; "u%04xm%04x"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+130h+var_40]
    push    ecx
    push    edi
    push    ebp
    mov     ecx, esi
    call    sub_43A970
    mov     esi, [esi+4Ah]
    inc     ebx
    test    esi, esi
    jnz     short loc_48778B

    loc_4877C4:                             ; CODE XREF: sub_4876C0+C9j
    mov     ecx, [ebp+0]
    test    ecx, ecx
    jz      short loc_4877D2
    push    edi
    push    ebp
    call    sub_43DD70

    loc_4877D2:                             ; CODE XREF: sub_4876C0+109j
    push    edi
    push    ebp
    lea     ecx, [ebp+0BCh]
    call    sub_4010B0
    mov     edi, [ebp+92h]
    or      ecx, 0FFFFFFFFh
    add     edi, 20h
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+130h+var_118]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     dx, [ebp+0A8h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    lea     eax, [ebp+6Ah]
    and     ecx, 3
    rep movsb
    mov     cl, [ebp+0FFh]
    mov     [esp+130h+var_F7], dx
    mov     [esp+130h+var_F8], cl
    mov     ecx, [eax]
    mov     [esp+130h+var_ED], ecx
    lea     ecx, [ebp+64h]
    mov     edx, [eax+4]
    mov     esi, [ebp+0]
    mov     [esp+130h+var_E9], edx
    mov     edx, [ecx]
    mov     eax, [eax+8]
    mov     [esp+130h+var_E1], edx
    mov     [esp+130h+var_E5], eax
    mov     ax, [ecx+4]
    mov     cx, [ebp+108h]
    mov     [esp+130h+var_DD], ax
    mov     [esp+130h+var_DB], cx
    mov     dx, [ebp+0B8h]
    xor     ecx, ecx
    xor     eax, eax
    cmp     esi, ecx
    mov     [esp+130h+var_F5], ebx
    setnz   al
    mov     [esp+130h+var_F1], eax
    mov     eax, [ebp+86h]
    cmp     eax, ecx
    mov     [esp+130h+var_D9], dx
    jz      short loc_4878C3
    test    dword ptr [eax+110h], 10000000h
    jz      short loc_4878C3
    cmp     eax, ecx
    jnz     short loc_4878A5
    mov     al, [ebp+0F9h]
    mov     [esp+130h+var_8F], cx
    mov     [esp+130h+var_8B], al
    jmp     short loc_4878D3
    ; ---------------------------------------------------------------------------

    loc_4878A5:                             ; CODE XREF: sub_4876C0+1CCj
    mov     dx, [eax+0A8h]
    mov     al, [ebp+0F9h]
    mov     [esp+130h+var_8F], dx
    mov     [esp+130h+var_8B], al
    jmp     short loc_4878D3
    ; ---------------------------------------------------------------------------

    loc_4878C3:                             ; CODE XREF: sub_4876C0+1BCj
                                            ; sub_4876C0+1C8j
    mov     [esp+130h+var_8F], cx
    mov     [esp+130h+var_8B], 0FFh

    loc_4878D3:                             ; CODE XREF: sub_4876C0+1E3j
                                            ; sub_4876C0+201j
    mov     eax, [ebp+0F0h]
    cmp     eax, ecx
    jz      short loc_4878F4
    test    dword ptr [eax+110h], 10000000h
    jz      short loc_4878F4
    cmp     eax, ecx
    jz      short loc_4878F4
    mov     cx, [eax+0A8h]

    loc_4878F4:                             ; CODE XREF: sub_4876C0+21Bj
                                            ; sub_4876C0+227j ...
    mov     eax, [ebp+58h]
    mov     dl, [ebp+0F4h]
    mov     [esp+130h+var_89], eax
    mov     eax, [ebp+7Eh]
    mov     [esp+130h+var_7D], eax
    mov     al, [ebp+0F5h]
    mov     [esp+130h+var_8A], dl
    mov     edx, [ebp+7Ah]
    mov     [esp+130h+var_6D], al
    mov     ax, [ebp+0BAh]
    mov     [esp+130h+var_81], edx
    mov     edx, [ebp+104h]
    mov     [esp+130h+var_8D], cx
    mov     ecx, [ebp+76h]
    mov     [esp+130h+var_6A], ax
    mov     [esp+130h+var_71], edx
    movzx   ax, byte ptr [ebp+10Eh]
    mov     dl, [ebp+0F7h]
    mov     [esp+130h+var_85], ecx
    mov     ecx, [ebp+0ACh]
    mov     [esp+130h+var_6B], dl
    mov     dl, [ebp+0FAh]
    mov     [esp+130h+var_66], ax
    mov     eax, [ebp+110h]
    mov     [esp+130h+var_79], ecx
    mov     cl, [ebp+0F6h]
    mov     [esp+130h+var_67], dl
    mov     edx, eax
    mov     [esp+130h+var_6C], cl
    mov     cl, [ebp+0F8h]
    and     edx, 0FFFFC000h
    mov     esi, eax
    mov     [esp+130h+var_68], cl
    mov     ecx, [ebp+0B0h]
    and     esi, 0FFFh
    shl     edx, 2
    or      edx, esi
    mov     [esp+130h+var_75], ecx
    xor     ecx, ecx
    and     eax, 2000h
    mov     cl, [ebp+10Fh]
    lea     esi, [ebp+0Ch]
    shl     edx, 1
    or      edx, eax
    mov     eax, [esp+130h+var_64]
    shl     edx, 3
    and     ecx, 0Fh
    and     eax, 0E0000h
    or      edx, ecx
    mov     edi, 3
    or      edx, eax
    lea     eax, [esp+130h+var_D3]
    mov     [esp+130h+var_64], edx

    loc_487A0D:                             ; CODE XREF: sub_4876C0+3BDj
    mov     ecx, [esi-8]
    mov     edx, [esi]
    mov     [eax-4], ecx
    mov     ecx, [esi+4]
    mov     [eax], edx
    xor     edx, edx
    mov     dl, [ecx+10Ah]
    mov     ecx, [esi+8]
    mov     [eax+4], edx
    mov     dx, [esi+0Ch]
    mov     [eax+8], ecx
    mov     cx, [esi+0Eh]
    mov     bl, [esi+13h]
    mov     [eax+0Ch], dx
    mov     dx, [esi+10h]
    mov     [eax+0Eh], cx
    mov     cl, [esi+12h]
    mov     [eax+10h], dx
    mov     [eax+12h], cl
    mov     dl, [eax+13h]
    mov     cl, dl
    add     esi, 1Ch
    xor     cl, bl
    add     eax, 18h
    and     cl, 1
    xor     cl, dl
    mov     dl, cl
    xor     dl, bl
    and     dl, 2
    xor     dl, cl
    mov     cl, dl
    xor     cl, bl
    and     cl, 0Ch
    xor     cl, dl
    mov     dl, cl
    xor     dl, bl
    and     dl, 10h
    xor     dl, cl
    dec     edi
    mov     [eax-5], dl
    jnz     short loc_487A0D
    mov     esi, [esp+130h+var_120]
    mov     edi, [esp+130h+arg_0]
    push    esi
    mov     ecx, edi
    call    sub_4B4B50
    lea     eax, [esp+130h+var_118]
    push    0B8h
    push    eax
    mov     ecx, edi
    call    sub_4B4CF0
    inc     esi
    mov     eax, [esp+130h+var_11C]
    mov     [esp+130h+var_120], esi

    loc_487AAC:                             ; CODE XREF: sub_4876C0+4Bj
    add     ebp, 118h
    cmp     ebp, eax
    jbe     loc_487701

    loc_487ABA:                             ; CODE XREF: sub_4876C0+3Bj
    test    esi, esi
    jle     short loc_487AD9
    push    esi                             ; int
    push    offset aNumberOfUnits           ; char *
    mov     ecx, edi
    call    sub_4B4630
    push    11h                             ; int
    push    offset aVersion                 ; char *
    mov     ecx, edi
    call    sub_4B4630

    loc_487AD9:                             ; CODE XREF: sub_4876C0+3FCj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 120h
    retn    4
    sub_4876C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_487AF0(char *,int,int)
    sub_487AF0 proc near                    ; CODE XREF: sub_487BF0+229p
                                            ; sub_487BF0+5C2p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_8]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    push    esi
    xor     esi, esi
    test    ecx, ecx
    push    edi
    jz      short loc_487B34
    mov     edx, [ebp+4]
    mov     esi, 1
    cmp     [edx], ecx
    jz      short loc_487B34
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+391E9h]
    mov     edi, [eax+0DB0h]

    loc_487B1F:                             ; CODE XREF: sub_487AF0+42j
    cmp     esi, edi
    jge     loc_487BD8
    lea     eax, ds:0[esi*4]
    inc     esi
    cmp     [eax+edx], ecx
    jnz     short loc_487B1F

    loc_487B34:                             ; CODE XREF: sub_487AF0+10j
                                            ; sub_487AF0+1Cj
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+391E9h]
    cmp     esi, [eax+0DB0h]
    jge     loc_487BD8
    lea     ebx, [esi+esi*8]
    shl     ebx, 2

    loc_487B52:                             ; CODE XREF: sub_487AF0+C3j
    mov     edi, [eax+0DACh]
    mov     eax, [edi+ebx+4]
    add     edi, ebx
    test    eax, eax
    jz      short loc_487B7D
    mov     edx, [esp+10h+arg_0]
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_487B7D
    mov     eax, [ebp+4]
    cmp     dword ptr [eax+esi*4], 0
    jnz     short loc_487BBE

    loc_487B7D:                             ; CODE XREF: sub_487AF0+70j
                                            ; sub_487AF0+82j
    mov     edi, [edi]
    test    edi, edi
    jz      short loc_487B9E
    mov     ecx, [esp+10h+arg_0]
    push    ecx                             ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_487B9E
    mov     edx, [ebp+4]
    cmp     dword ptr [edx+esi*4], 0
    jnz     short loc_487BCB

    loc_487B9E:                             ; CODE XREF: sub_487AF0+91j
                                            ; sub_487AF0+A3j
    mov     eax, TAdynmemStructPtr
    inc     esi
    add     ebx, 24h
    mov     eax, [eax+391E9h]
    cmp     esi, [eax+0DB0h]
    jl      short loc_487B52
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_487BBE:                             ; CODE XREF: sub_487AF0+8Bj
    mov     ecx, [ebp+4]
    mov     eax, [ecx+esi*4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_487BCB:                             ; CODE XREF: sub_487AF0+ACj
    mov     edx, [ebp+4]
    mov     eax, [edx+esi*4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_487BD8:                             ; CODE XREF: sub_487AF0+31j
                                            ; sub_487AF0+56j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    0Ch
    sub_487AF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_487BF0 proc near                    ; CODE XREF: sub_488310+204p

    var_140= dword ptr -140h
    var_13C= dword ptr -13Ch
    var_138= dword ptr -138h
    var_134= dword ptr -134h
    var_130= dword ptr -130h
    var_12C= dword ptr -12Ch
    var_128= dword ptr -128h
    var_124= dword ptr -124h
    var_120= dword ptr -120h
    var_11C= dword ptr -11Ch
    var_118= dword ptr -118h
    var_114= dword ptr -114h
    var_110= dword ptr -110h
    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 140h
    push    ebx
    push    ebp
    mov     ebp, [esp+148h+arg_4]
    push    esi
    mov     esi, [esp+14Ch+arg_0]
    push    edi
    mov     al, [ebp+0]
    xor     ebx, ebx
    xor     edi, edi
    cmp     al, bl
    mov     [esp+150h+var_124], ebx
    jz      loc_487E5B

    loc_487C1B:                             ; CODE XREF: sub_487BF0+265j
    movsx   eax, al
    push    eax                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jz      short loc_487C3D

    loc_487C2B:                             ; CODE XREF: sub_487BF0+4Bj
    movsx   ecx, byte ptr [ebp+1]
    inc     ebp
    push    ecx                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jnz     short loc_487C2B

    loc_487C3D:                             ; CODE XREF: sub_487BF0+39j
    push    offset asc_508CE4               ; char *
    push    ebp                             ; char *
    call    _strcspn
    add     esp, 8
    lea     edx, [esp+150h+var_100]
    mov     [esp+150h+var_138], eax
    push    eax                             ; size_t
    push    ebp                             ; char *
    push    edx                             ; char *
    call    _strncpy
    mov     eax, [esp+15Ch+var_138]
    add     esp, 0Ch
    add     ebp, eax
    mov     [esp+eax+150h+var_100], bl
    mov     [esp+150h+arg_4], ebp
    cmp     byte ptr [ebp+0], 2Ch
    jnz     short loc_487C7D
    inc     ebp
    mov     [esp+150h+arg_4], ebp

    loc_487C7D:                             ; CODE XREF: sub_487BF0+83j
    movsx   eax, [esp+150h+var_100]
    add     eax, 0FFFFFFBFh
    cmp     eax, 36h
    ja      loc_487E50
    xor     ecx, ecx
    mov     cl, ds:byte_4882CC[eax]
    jmp     ds:off_488270[ecx*4]

    loc_487C9D:                             ; DATA XREF: .text:00488288o
                                            ; .text:004882B4o
    mov     edx, [esi+110h]
    mov     eax, [esi+110h]
    shr     edx, 12h
    and     edx, 3
    lea     ecx, [esp+150h+var_118]
    shr     eax, 14h
    mov     [esp+150h+var_128], edx
    and     eax, 3
    lea     edx, [esp+150h+var_128]
    mov     [esp+150h+var_118], eax
    push    ecx
    push    edx
    lea     eax, [esp+59h]
    push    offset aDD                      ; " %d %d"
    push    eax
    call    _sscanf
    mov     ecx, [esp+160h+var_118]
    mov     edx, [esp+160h+var_128]
    mov     eax, [esi+110h]
    and     ecx, 3
    shl     ecx, 2
    and     edx, 3
    and     eax, 0FFC3FFFFh
    or      ecx, edx
    add     esp, 10h
    shl     ecx, 12h
    or      ecx, eax
    mov     [esi+110h], ecx
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_487D07:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:00488284o ...
    lea     ecx, [esp+150h+var_13C]
    lea     edx, [esp+150h+var_140]
    push    ecx
    push    edx
    lea     eax, [esp+59h]
    push    offset aFF                      ; " %f %f"
    push    eax
    call    _sscanf
    fld     [esp+160h+var_140]
    fmul    ds:dbl_4FD710
    add     esp, 10h
    call    __ftol
    fld     [esp+150h+var_13C]
    fmul    ds:dbl_4FD710
    mov     [esp+150h+var_134], eax
    mov     [esp+150h+var_130], ebx
    call    __ftol
    lea     ecx, [esp+150h+var_134]
    lea     edx, [esp+150h+var_10C]
    push    ecx
    push    ebx
    push    esi
    push    2
    push    edx
    mov     [esp+164h+var_12C], eax
    call    sub_43F0E0
    push    ebx
    lea     eax, [esp+154h+var_134]
    mov     ecx, [esp+154h+var_10C]
    push    ebx
    push    eax
    push    ebx
    push    esi
    push    1
    push    ecx
    call    sub_43ADC0
    mov     edi, 1
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_487D7F:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:00488294o ...
    lea     edx, [esp+150h+var_13C]
    lea     eax, [esp+150h+var_140]
    push    edx
    push    eax
    lea     ecx, [esp+59h]
    push    offset aFF                      ; " %f %f"
    push    ecx
    call    _sscanf
    fld     [esp+160h+var_140]
    fmul    ds:dbl_4FD710
    add     esp, 10h
    call    __ftol
    fld     [esp+150h+var_13C]
    fmul    ds:dbl_4FD710
    mov     [esp+150h+var_134], eax
    mov     [esp+150h+var_130], ebx
    call    __ftol
    lea     edx, [esp+150h+var_134]
    mov     [esp+150h+var_12C], eax
    push    edx
    push    ebx
    push    esi
    lea     eax, [esp+15Ch+var_108]
    push    5
    push    eax
    call    sub_43F0E0
    push    ebx
    lea     ecx, [esp+154h+var_134]
    mov     edx, [esp+154h+var_108]
    push    ebx
    push    ecx
    push    ebx
    push    esi
    push    1
    push    edx
    call    sub_43ADC0
    mov     edi, 1
    jmp     short loc_487E50
    ; ---------------------------------------------------------------------------

    loc_487DF4:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:0048827Co ...
    lea     eax, [esp+150h+var_100]
    lea     ecx, [esp+51h]
    push    eax
    push    offset aAZaZ09__                ; " %[a-zA-Z0-9_.]"
    push    ecx
    call    _sscanf
    mov     edx, [esp+15Ch+arg_8]
    add     esp, 0Ch
    lea     eax, [esp+150h+var_100]
    push    ebx                             ; int
    push    edx                             ; int
    push    eax                             ; char *
    call    sub_487AF0
    mov     ebp, eax
    cmp     ebp, ebx
    jz      short loc_487E49
    push    ebx
    push    ebp
    push    esi
    lea     ecx, [esp+15Ch+var_114]
    push    7
    push    ecx
    call    sub_43F0E0
    push    ebx
    push    ebx
    mov     edx, [esp+158h+var_114]
    push    ebx
    push    ebp
    push    esi
    push    1
    push    edx
    call    sub_43ADC0
    mov     edi, 1

    loc_487E49:                             ; CODE XREF: sub_487BF0+232j
    mov     ebp, [esp+150h+arg_4]

    loc_487E50:                             ; CODE XREF: sub_487BF0+98j
                                            ; sub_487BF0+A6j ...
    mov     al, [ebp+0]
    cmp     al, bl
    jnz     loc_487C1B

    loc_487E5B:                             ; CODE XREF: sub_487BF0+25j
    cmp     edi, ebx
    jz      short loc_487E8F
    mov     ecx, [esi+110h]
    mov     eax, [esp+150h+var_124]
    and     ecx, 0FFFFFFDFh
    cmp     eax, ebx
    mov     [esi+110h], ecx
    jnz     short loc_487E8F
    push    ebx
    push    ebx
    push    ebx
    push    ebx
    push    esi
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aMakeselectable          ; char *
    call    sub_438760
    call    sub_43ADC0

    loc_487E8F:                             ; CODE XREF: sub_487BF0+26Dj
                                            ; sub_487BF0+284j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 140h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_487E9C:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:0048828Co ...
    lea     eax, [esp+150h+var_11C]
    lea     ecx, [esp+150h+var_13C]
    push    eax
    lea     edx, [esp+154h+var_140]
    push    ecx
    push    edx
    lea     eax, [esp+5Dh]
    push    offset aFFF                     ; " %f %f %f"
    push    eax
    mov     [esp+164h+var_11C], 0
    call    _sscanf
    fld     [esp+164h+var_140]
    fmul    ds:dbl_4FD710
    add     esp, 14h
    call    __ftol
    fld     [esp+150h+var_13C]
    fmul    ds:dbl_4FD710
    mov     [esp+150h+var_134], eax
    mov     [esp+150h+var_130], ebx
    call    __ftol
    lea     ecx, [esp+150h+var_134]
    lea     edx, [esp+150h+var_104]
    push    ecx
    push    ebx
    push    esi
    push    9
    push    edx
    mov     [esp+164h+var_12C], eax
    call    sub_43F0E0
    fld     [esp+150h+var_11C]
    fmul    ds:flt_4FD718
    push    ebx
    call    __ftol
    mov     ecx, [esp+154h+var_104]
    push    eax
    lea     eax, [esp+158h+var_134]
    mov     edi, 1
    push    eax
    push    ebx
    push    esi
    push    edi
    push    ecx
    call    sub_43ADC0
    mov     [esp+150h+var_124], edi
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_487F33:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:00488270o ...
    lea     edx, [esp+150h+var_13C]
    lea     eax, [esp+150h+var_140]
    push    edx
    push    eax
    lea     ecx, [esp+59h]
    push    offset aFF                      ; " %f %f"
    push    ecx
    call    _sscanf
    add     esp, 10h
    cmp     eax, 2
    jnz     short loc_487FB3
    fld     [esp+150h+var_140]
    fmul    ds:dbl_4FD710
    call    __ftol
    fld     [esp+150h+var_13C]
    fmul    ds:dbl_4FD710
    mov     [esp+150h+var_134], eax
    mov     [esp+150h+var_130], ebx
    call    __ftol
    lea     edx, [esp+150h+var_134]
    mov     [esp+150h+var_12C], eax
    push    edx
    push    ebx
    push    esi
    lea     eax, [esp+15Ch+var_110]
    push    3
    push    eax
    call    sub_43F0E0
    push    ebx
    lea     ecx, [esp+154h+var_134]
    mov     edx, [esp+154h+var_110]
    push    ebx
    push    ecx
    push    ebx
    mov     edi, 1
    push    esi
    push    edi
    push    edx
    call    sub_43ADC0
    mov     [esp+150h+var_124], edi
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_487FB3:                             ; CODE XREF: sub_487BF0+362j
    lea     eax, [esp+150h+var_100]
    lea     ecx, [esp+51h]
    push    eax
    push    offset aAZaZ09__                ; " %[a-zA-Z0-9_.]"
    push    ecx
    call    _sscanf
    add     esp, 0Ch
    lea     edx, [esp+150h+var_100]
    push    edx                             ; char *
    call    sub_488B10
    cmp     ax, bx
    jz      loc_487E50
    and     eax, 0FFFFh
    push    ebx
    push    eax
    push    ebx
    push    ebx
    push    esi
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aAttackutype             ; char *
    call    sub_438760
    call    sub_43ADC0
    mov     edi, 1
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_488005:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:00488274o ...
    mov     al, [esp+51h]
    mov     [esp+150h+var_138], 1
    cmp     al, 77h
    jz      loc_4880E1
    cmp     al, 57h
    jz      loc_4880E1
    lea     eax, [esp+150h+var_13C]
    lea     ecx, [esp+150h+var_140]
    push    eax
    lea     edx, [esp+154h+var_138]
    push    ecx
    lea     eax, [esp+158h+var_100]
    push    edx
    push    eax
    lea     ecx, [esp+61h]
    push    offset aAZaZ09__DFF             ; " %[a-zA-Z0-9_.] %d %f %f"
    push    ecx
    call    _sscanf
    fld     [esp+168h+var_140]
    fmul    ds:dbl_4FD710
    add     esp, 18h
    call    __ftol
    fld     [esp+150h+var_13C]
    fmul    ds:dbl_4FD710
    mov     [esp+150h+var_134], eax
    mov     [esp+150h+var_130], ebx
    call    __ftol
    lea     edx, [esp+150h+var_100]
    mov     [esp+150h+var_12C], eax
    push    edx                             ; char *
    call    sub_488B10
    cmp     ax, bx
    jz      loc_487E50
    mov     ecx, [esi]
    cmp     ecx, ebx
    mov     ecx, [esp+150h+var_138]
    push    ecx
    jz      short loc_4880BA
    and     eax, 0FFFFh
    lea     edx, [esp+154h+var_134]
    push    eax
    push    edx
    push    ebx
    push    esi
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aMobilebuild             ; char *
    call    sub_438760
    call    sub_43ADC0
    mov     edi, 1
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_4880BA:                             ; CODE XREF: sub_487BF0+49Dj
    and     eax, 0FFFFh
    push    eax
    push    ebx
    push    ebx
    push    esi
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aBuildingbuil_0          ; char *
    call    sub_438760
    call    sub_43ADC0
    mov     edi, 1
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_4880E1:                             ; CODE XREF: sub_487BF0+423j
                                            ; sub_487BF0+42Bj
    lea     edx, [esp+150h+var_138]
    lea     eax, [esp+52h]
    push    edx
    push    offset aD_2                     ; " %d"
    push    eax
    call    _sscanf
    mov     ecx, [esp+15Ch+var_138]
    add     esp, 0Ch
    push    ecx
    push    ebx
    push    ebx
    push    ebx
    push    esi
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aBuildweapon             ; char *
    call    sub_438760
    call    sub_43ADC0
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_48811A:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:00488298o ...
    mov     al, [esp+51h]
    cmp     al, 61h
    jz      short loc_488184
    cmp     al, 41h
    jz      short loc_488184
    lea     edx, [esp+150h+var_128]
    lea     eax, [esp+150h+var_120]
    push    edx
    push    eax
    lea     ecx, [esp+59h]
    push    offset aFD                      ; " %f %d"
    push    ecx
    mov     [esp+160h+var_120], 0
    mov     [esp+160h+var_128], ebx
    call    _sscanf
    fld     [esp+160h+var_120]
    fmul    ds:flt_4FD718
    mov     edx, [esp+160h+var_128]
    add     esp, 10h
    push    edx
    call    __ftol
    push    eax
    push    ebx
    push    ebx
    push    esi
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aWait                    ; char *
    call    sub_438760
    call    sub_43ADC0
    mov     edi, 1
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_488184:                             ; CODE XREF: sub_487BF0+530j
                                            ; sub_487BF0+534j
    lea     eax, [esp+150h+var_100]
    lea     ecx, [esp+52h]
    push    eax
    push    offset aAZaZ09_                 ; " %[a-zA-Z0-9.]"
    push    ecx
    call    _sscanf
    mov     ecx, eax
    add     esp, 0Ch
    xor     eax, eax
    cmp     ecx, 1
    jnz     short loc_4881B7
    mov     edx, [esp+150h+arg_8]
    push    ebx                             ; int
    lea     eax, [esp+154h+var_100]
    push    edx                             ; int
    push    eax                             ; char *
    call    sub_487AF0

    loc_4881B7:                             ; CODE XREF: sub_487BF0+5B2j
    cmp     eax, ebx
    jnz     short loc_4881BD
    mov     eax, esi

    loc_4881BD:                             ; CODE XREF: sub_487BF0+5C9j
    push    ebx
    push    ebx
    push    ebx
    push    eax
    push    esi
    push    1
    push    ecx
    mov     ecx, esp
    push    offset aWaitforattack           ; char *
    call    sub_438760
    call    sub_43ADC0
    mov     edi, 1
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_4881E0:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:00488278o ...
    mov     edi, 1
    push    ebx
    push    edi
    push    ebx
    push    ebx
    push    esi
    push    edi
    push    ecx
    mov     ecx, esp
    push    offset aSelfdestructfg          ; char *
    call    sub_438760
    call    sub_43ADC0
    mov     [esp+150h+var_124], edi
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_488206:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:00488290o ...
    push    ebx
    push    ebx
    push    ebx
    push    ebx
    mov     edi, 1
    push    esi
    push    edi
    push    ecx
    mov     ecx, esp
    push    offset aMakeselectable          ; char *
    call    sub_438760
    call    sub_43ADC0
    mov     [esp+150h+var_124], edi
    jmp     loc_487E50
    ; ---------------------------------------------------------------------------

    loc_48822C:                             ; CODE XREF: sub_487BF0+A6j
                                            ; DATA XREF: .text:00488280o ...
    lea     ecx, [esp+150h+var_100]
    lea     edx, [esp+51h]
    push    ecx
    push    offset aAZaZ09__                ; " %[a-zA-Z0-9_.]"
    push    edx
    call    _sscanf
    mov     eax, [esp+15Ch+arg_8]
    add     esp, 0Ch
    lea     ecx, [esp+150h+var_100]
    push    ebx                             ; int
    push    eax                             ; int
    push    ecx                             ; char *
    call    sub_487AF0
    cmp     eax, ebx
    jz      loc_487E50
    push    ebx
    push    0FFFFFFFFh
    push    eax
    push    esi
    call    sub_48AAC0
    jmp     loc_487E50
    sub_487BF0 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_488270 dd offset loc_487F33         ; DATA XREF: sub_487BF0+A6r
    dd offset loc_488005
    dd offset loc_4881E0
    dd offset loc_487DF4
    dd offset loc_48822C
    dd offset loc_487D07
    dd offset loc_487C9D
    dd offset loc_487E9C
    dd offset loc_488206
    dd offset loc_487D7F
    dd offset loc_48811A
    dd offset loc_487F33
    dd offset loc_488005
    dd offset loc_4881E0
    dd offset loc_487DF4
    dd offset loc_48822C
    dd offset loc_487D07
    dd offset loc_487C9D
    dd offset loc_487E9C
    dd offset loc_488206
    dd offset loc_487D7F
    dd offset loc_48811A
    dd offset loc_487E50
    byte_4882CC db 0                        ; DATA XREF: sub_487BF0+A0r
    ; ---------------------------------------------------------------------------
    add     [esi], edx
    add     dl, [esi]
    push    ss
    add     edx, [esi]
    add     al, 16h
    push    ss
    push    ss
    add     eax, 16070616h
    push    ss
    or      [esi], dl
    or      [esi], edx
    or      dl, [esi]
    push    ss
    push    ss
    push    ss
    push    ss
    push    ss
    push    ss
    push    ss
    push    ss
    or      ecx, [esi+edx]
    or      eax, 160E1616h
    movhps  xmm2, qword ptr [esi]
    push    ss
    adc     [esi], dl
    adc     [edx], edx
    push    ss
    push    ss
    adc     edx, [esi]
    adc     al, 16h
    adc     eax, 90909090h
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488310 proc near                    ; CODE XREF: sub_497180+9C0p

    var_7D= byte ptr -7Dh
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    Text= byte ptr -64h

    sub     esp, 80h
    mov     eax, TAdynmemStructPtr
    mov     dl, [esp+80h+var_7D]
    push    ebx
    push    ebp
    mov     ecx, [eax+391E9h]
    push    esi
    xor     ebx, ebx
    push    edi
    mov     esi, [ecx+0DB0h]
    mov     [esp+90h+var_7C], ebx
    cmp     esi, ebx
    mov     byte ptr [esp+90h+var_74], dl
    mov     eax, esi
    jge     short loc_488341
    xor     eax, eax

    loc_488341:                             ; CODE XREF: sub_488310+2Dj
    shl     eax, 2
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    lea     ecx, [esp+90h+var_7C]
    mov     [esp+90h+var_70], eax
    push    ecx
    push    esi
    push    eax
    lea     ecx, [esp+9Ch+var_74]
    call    sub_406C40
    mov     edx, [esp+90h+var_70]
    lea     eax, [edx+esi*4]
    mov     edx, TAdynmemStructPtr
    mov     [esp+90h+var_6C], eax
    mov     [esp+90h+var_68], eax
    mov     eax, [edx+391E9h]
    cmp     [eax+0DB0h], ebx
    jle     loc_4884DF
    mov     [esp+90h+var_7C], ebx

    loc_48838C:                             ; CODE XREF: sub_488310+1C9j
    mov     esi, [eax+0DACh]
    mov     edx, [esp+90h+var_7C]
    add     esi, edx
    mov     eax, [esi]
    push    eax                             ; char *
    call    sub_488A50
    mov     ebp, eax
    test    ebp, ebp
    jnz     short loc_4883B2
    mov     ecx, [esp+90h+var_70]
    mov     [ecx+ebx*4], eax
    jmp     loc_4884BB
    ; ---------------------------------------------------------------------------

    loc_4883B2:                             ; CODE XREF: sub_488310+94j
    mov     dl, [esi+22h]
    mov     al, dl
    dec     al
    cmp     al, 0Ah
    mov     byte ptr [esp+90h+var_78], al
    jnb     short loc_488409
    mov     eax, [esp+90h+var_78]
    mov     edi, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edi+ecx*2+1B63h]
    mov     ecx, [edi+ecx*2+1B63h]
    test    ecx, ecx
    jz      short loc_488409
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_488400
    cmp     cl, 2
    jz      short loc_488400
    cmp     cl, 3
    jnz     short loc_488409

    loc_488400:                             ; CODE XREF: sub_488310+E4j
                                            ; sub_488310+E9j
    cmp     byte ptr [eax+146h], 0Ah
    jnz     short loc_48842F

    loc_488409:                             ; CODE XREF: sub_488310+AFj
                                            ; sub_488310+DCj ...
    mov     eax, [esi]
    and     edx, 0FFh
    push    eax
    push    edx
    lea     ecx, [esp+98h+Text]
    push    offset aPlayerNumberDI          ; "Player number %d invalid for unit %s"
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+90h+Text]
    push    edx                             ; lpText
    call    sub_4B6290

    loc_48842F:                             ; CODE XREF: sub_488310+F7j
    lea     edi, [esi+0Ch]
    push    edi
    push    ebp
    call    sub_47DDC0
    mov     ecx, [edi]
    push    0                               ; int
    push    1                               ; int
    push    1                               ; int
    mov     edx, [edi+4]
    sub     esp, 0Ch                        ; int
    mov     eax, esp
    mov     [eax], ecx
    mov     ecx, [edi+8]
    mov     [eax+4], edx
    mov     dx, [ebp+21Eh]
    push    edx                             ; int
    mov     [eax+8], ecx
    mov     al, [esi+22h]
    dec     al
    push    eax                             ; int
    call    sub_485F50
    mov     ecx, eax
    test    ecx, ecx
    jz      short loc_4884BB
    mov     edx, [ecx+110h]
    xor     eax, eax
    mov     al, [esi+23h]
    and     dh, 7Fh
    and     al, 80h
    shl     eax, 8
    or      edx, eax
    mov     [ecx+110h], edx
    mov     edx, [ecx+92h]
    movsx   eax, word ptr [esi+1Ah]
    mov     edx, [edx+1FAh]
    imul    edx, eax
    mov     eax, 51EB851Fh
    mul     edx
    shr     edx, 5
    mov     [ecx+108h], dx
    mov     ax, [esi+18h]
    mov     [ecx+66h], ax
    mov     edx, [esp+90h+var_70]
    mov     [edx+ebx*4], ecx

    loc_4884BB:                             ; CODE XREF: sub_488310+9Dj
                                            ; sub_488310+15Bj
    mov     edx, [esp+90h+var_7C]
    inc     ebx
    add     edx, 24h
    mov     [esp+90h+var_7C], edx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391E9h]
    cmp     ebx, [eax+0DB0h]
    jl      loc_48838C

    loc_4884DF:                             ; CODE XREF: sub_488310+72j
    mov     eax, [edx+391E9h]
    xor     esi, esi
    mov     ecx, [eax+0DB0h]
    test    ecx, ecx
    jle     short loc_488531
    xor     edi, edi

    loc_4884F3:                             ; CODE XREF: sub_488310+21Fj
    mov     eax, [eax+0DACh]
    add     eax, edi
    mov     eax, [eax+8]
    test    eax, eax
    jz      short loc_48851F
    mov     ecx, [esp+90h+var_70]
    mov     ecx, [ecx+esi*4]
    test    ecx, ecx
    jz      short loc_48851F
    lea     edx, [esp+90h+var_74]
    push    edx
    push    eax
    push    ecx
    call    sub_487BF0
    mov     edx, TAdynmemStructPtr

    loc_48851F:                             ; CODE XREF: sub_488310+1F0j
                                            ; sub_488310+1FBj
    mov     eax, [edx+391E9h]
    inc     esi
    add     edi, 24h
    cmp     esi, [eax+0DB0h]
    jl      short loc_4884F3

    loc_488531:                             ; CODE XREF: sub_488310+1DFj
    mov     eax, [edx+391E9h]
    mov     ecx, [eax+0DB0h]
    test    ecx, ecx
    jg      short loc_48854C
    mov     ecx, [edx+391EDh]
    call    sub_4904B0

    loc_48854C:                             ; CODE XREF: sub_488310+22Fj
    mov     ecx, [esp+90h+var_70]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 80h
    retn
    sub_488310 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488570 proc near                    ; CODE XREF: .text:004046C5p
                                            ; Network_Process+1A3Bp ...

    idTo= dword ptr -18h
    var_11= dword ptr -11h
    var_D= dword ptr -0Dh
    var_9= dword ptr -9
    var_5= word ptr -5
    var_3= byte ptr -3
    var_2= byte ptr -2
    var_1= byte ptr -1
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+24h+arg_0]
    push    edi
    mov     edi, [esp+28h+arg_4]
    cmp     [esi+96h], edi
    jz      loc_4887F7
    mov     eax, [esi+110h]
    test    eax, 10000000h
    jz      loc_4887F7
    test    ah, 40h
    jnz     loc_4887F7
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+391EDh]
    call    sub_490520
    mov     eax, [esi+96h]
    mov     bl, 2
    cmp     dword ptr [eax], 0
    jz      loc_4886B3
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_4885D6
    cmp     al, bl
    jnz     loc_4886B3

    loc_4885D6:                             ; CODE XREF: sub_488570+5Cj
    cmp     dword ptr [edi], 0
    jz      loc_4887F7
    cmp     byte ptr [edi+73h], 3
    jnz     loc_4886B3
    mov     ebp, [esi+110h]
    push    edi
    and     ebp, 0FFFFFFEFh
    mov     dword ptr [esi+0FBh], 96h
    mov     [esi+110h], ebp
    mov     byte ptr [esp+2Ch+idTo], 14h
    call    sub_450010
    mov     cx, [esi+0A8h]
    fld     dword ptr [esi+104h]
    mov     [esp+28h+idTo+3], eax
    mov     word ptr [esp+28h+idTo+1], cx
    call    __ftol
    movsx   edx, word ptr [esi+108h]
    mov     [esp+28h+var_11], eax
    lea     eax, [esi+64h]
    mov     [esp+28h+var_D], edx
    mov     ecx, [eax]
    mov     [esp+28h+var_9], ecx
    mov     dx, [eax+4]
    mov     al, [esi+1Fh]
    and     al, bl
    mov     [esp+28h+var_5], dx
    jz      short loc_488659
    mov     cl, [esi+1Eh]
    mov     [esp+28h+var_3], cl
    jmp     short loc_48865E
    ; ---------------------------------------------------------------------------

    loc_488659:                             ; CODE XREF: sub_488570+DEj
    mov     [esp+28h+var_3], 0

    loc_48865E:                             ; CODE XREF: sub_488570+E7j
    test    al, al
    jz      short loc_48866B
    mov     dl, [esi+3Ah]
    mov     [esp+28h+var_2], dl
    jmp     short loc_488670
    ; ---------------------------------------------------------------------------

    loc_48866B:                             ; CODE XREF: sub_488570+F0j
    mov     [esp+28h+var_2], 0

    loc_488670:                             ; CODE XREF: sub_488570+F9j
    test    al, al
    jz      short loc_48867D
    mov     al, [esi+56h]
    mov     [esp+28h+var_1], al
    jmp     short loc_488682
    ; ---------------------------------------------------------------------------

    loc_48867D:                             ; CODE XREF: sub_488570+102j
    mov     [esp+28h+var_1], 0

    loc_488682:                             ; CODE XREF: sub_488570+10Bj
    mov     edx, [esi+96h]
    lea     ecx, [esp+28h+idTo]
    push    18h                             ; idFrom
    push    ecx                             ; idTo
    mov     eax, [edx+4]
    push    eax                             ; PlayerID
    call    sub_451DF0
    push    0
    push    4
    push    7530h
    push    esi
    push    0
    call    sub_489BB0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4886B3:                             ; CODE XREF: sub_488570+51j
                                            ; sub_488570+60j ...
    cmp     dword ptr [edi], 0
    jz      loc_4887F7
    mov     al, [edi+73h]
    cmp     al, 1
    jz      short loc_4886CB
    cmp     al, bl
    jnz     loc_4887F7

    loc_4886CB:                             ; CODE XREF: sub_488570+151j
    mov     ecx, [esi+110h]
    push    0                               ; int
    and     ecx, 3
    lea     edx, [esi+6Ah]
    push    ecx                             ; int
    push    1                               ; int
    mov     ecx, [edx]
    sub     esp, 0Ch                        ; int
    mov     eax, esp
    mov     [eax], ecx
    mov     ecx, [edx+4]
    mov     edx, [edx+8]
    mov     [eax+4], ecx
    mov     cl, [edi+146h]
    mov     [eax+8], edx
    mov     ax, [esi+0A6h]
    push    eax                             ; int
    push    ecx                             ; int
    call    sub_485F50
    mov     edi, eax
    test    edi, edi
    jz      loc_4887F7
    mov     edx, [edi+110h]
    mov     eax, [esp+28h+arg_8]
    and     edx, 0FFC3FFFFh
    test    eax, eax
    mov     [edi+110h], edx
    jz      short loc_488774
    mov     dx, [eax+0Bh]
    lea     ecx, [eax+0Fh]
    mov     [edi+108h], dx
    lea     edx, [edi+64h]
    fild    dword ptr [eax+7]
    fstp    dword ptr [edi+104h]
    mov     ebp, [ecx]
    mov     [edx], ebp
    mov     cx, [ecx+4]
    mov     [edx+4], cx
    mov     cl, [edi+1Fh]
    test    bl, cl
    jz      short loc_48875C
    mov     dl, [eax+15h]
    mov     [edi+1Eh], dl

    loc_48875C:                             ; CODE XREF: sub_488570+1E4j
    test    [edi+3Bh], bl
    jz      short loc_488767
    mov     cl, [eax+16h]
    mov     [edi+3Ah], cl

    loc_488767:                             ; CODE XREF: sub_488570+1EFj
    test    [edi+57h], bl
    jz      short loc_4887D5
    mov     dl, [eax+17h]
    mov     [edi+56h], dl
    jmp     short loc_4887D5
    ; ---------------------------------------------------------------------------

    loc_488774:                             ; CODE XREF: sub_488570+1B7j
    mov     ax, [esi+108h]
    lea     edx, [esi+64h]
    mov     [edi+108h], ax
    mov     ecx, [esi+104h]
    mov     [edi+104h], ecx
    mov     ecx, [edx]
    lea     eax, [edi+64h]
    mov     [edi+64h], ecx
    mov     dx, [edx+4]
    mov     [eax+4], dx
    mov     al, [edi+1Fh]
    test    bl, al
    jz      short loc_4887AE
    mov     al, [esi+1Eh]
    mov     [edi+1Eh], al

    loc_4887AE:                             ; CODE XREF: sub_488570+236j
    test    [edi+3Bh], bl
    jz      short loc_4887B9
    mov     cl, [esi+3Ah]
    mov     [edi+3Ah], cl

    loc_4887B9:                             ; CODE XREF: sub_488570+241j
    test    [edi+57h], bl
    jz      short loc_4887C4
    mov     dl, [esi+56h]
    mov     [edi+56h], dl

    loc_4887C4:                             ; CODE XREF: sub_488570+24Cj
    push    0
    push    4
    push    7530h
    push    esi
    push    0
    call    sub_489BB0

    loc_4887D5:                             ; CODE XREF: sub_488570+1FAj
                                            ; sub_488570+202j
    mov     al, [esi+10Eh]
    push    1                               ; int
    push    eax                             ; idTo
    mov     ecx, edi
    call    sub_48B090
    mov     cl, [esi+10Eh]
    push    0                               ; int
    not     cl
    push    ecx                             ; idTo
    mov     ecx, edi
    call    sub_48B090

    loc_4887F7:                             ; CODE XREF: sub_488570+15j
                                            ; sub_488570+26j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    0Ch
    sub_488570 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488810 proc near                    ; CODE XREF: sub_4854A0+2CDp
                                            ; sub_4854A0+2D8p ...

    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    sub     eax, ecx
    mov     edx, eax
    and     edx, 0FFFFFFFCh
    cmp     edx, 40h
    jle     locret_488914
    push    edi
    push    esi
    push    ebp
    push    ebx
    mov     ebx, [esp+10h+arg_8]
    jmp     short loc_488836
    ; ---------------------------------------------------------------------------

    loc_488832:                             ; CODE XREF: sub_488810+FAj
    mov     ecx, [esp+10h+arg_0]

    loc_488836:                             ; CODE XREF: sub_488810+20j
    sar     eax, 2
    cdq
    mov     ebp, [ecx]
    sub     eax, edx
    sar     eax, 1
    mov     esi, [ecx+eax*4]
    mov     eax, [esp+10h+arg_4]
    push    esi
    push    ebp
    mov     edi, [eax-4]
    call    ebx
    test    eax, eax
    push    edi
    jz      short loc_488866
    push    esi
    call    ebx
    test    eax, eax
    jnz     short loc_488877
    push    edi
    push    ebp
    call    ebx
    test    eax, eax
    jz      short loc_488879
    mov     ebp, edi
    jmp     short loc_488879
    ; ---------------------------------------------------------------------------

    loc_488866:                             ; CODE XREF: sub_488810+41j
    push    ebp
    call    ebx
    test    eax, eax
    jnz     short loc_488879
    push    edi
    push    esi
    call    ebx
    test    eax, eax
    mov     ebp, edi
    jnz     short loc_488879

    loc_488877:                             ; CODE XREF: sub_488810+48j
    mov     ebp, esi

    loc_488879:                             ; CODE XREF: sub_488810+50j
                                            ; sub_488810+54j ...
    mov     edi, [esp+10h+arg_4]
    mov     esi, [esp+10h+arg_0]

    loc_488881:                             ; CODE XREF: sub_488810+B4j
    mov     ecx, [esi]
    push    ebp
    push    ecx
    call    ebx
    test    eax, eax
    jz      short loc_488899

    loc_48888B:                             ; CODE XREF: sub_488810+87j
    mov     edx, [esi+4]
    add     esi, 4
    push    ebp
    push    edx
    call    ebx
    test    eax, eax
    jnz     short loc_48888B

    loc_488899:                             ; CODE XREF: sub_488810+79j
    mov     eax, [edi-4]
    sub     edi, 4
    push    eax
    push    ebp
    call    ebx
    test    eax, eax
    jz      short loc_4888B5

    loc_4888A7:                             ; CODE XREF: sub_488810+A3j
    mov     ecx, [edi-4]
    sub     edi, 4
    push    ecx
    push    ebp
    call    ebx
    test    eax, eax
    jnz     short loc_4888A7

    loc_4888B5:                             ; CODE XREF: sub_488810+95j
    cmp     edi, esi
    jbe     short loc_4888C6
    mov     edx, [edi]
    mov     eax, [esi]
    mov     [esi], edx
    mov     [edi], eax
    add     esi, 4
    jmp     short loc_488881
    ; ---------------------------------------------------------------------------

    loc_4888C6:                             ; CODE XREF: sub_488810+A7j
    mov     ebp, [esp+10h+arg_4]
    mov     edi, [esp+10h+arg_0]
    mov     eax, esi
    mov     ecx, ebp
    sub     eax, edi
    sub     ecx, esi
    and     al, 0FCh
    and     ecx, 0FFFFFFFCh
    cmp     ecx, eax
    push    0
    push    ebx
    jg      short loc_4888F1
    push    ebp
    push    esi
    call    sub_488810
    mov     ebp, esi
    mov     [esp+10h+arg_4], esi
    jmp     short loc_4888FE
    ; ---------------------------------------------------------------------------

    loc_4888F1:                             ; CODE XREF: sub_488810+D0j
    push    esi
    push    edi
    call    sub_488810
    mov     edi, esi
    mov     [esp+10h+arg_0], esi

    loc_4888FE:                             ; CODE XREF: sub_488810+DFj
    mov     eax, ebp
    sub     eax, edi
    mov     edx, eax
    and     edx, 0FFFFFFFCh
    cmp     edx, 40h
    jg      loc_488832
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    locret_488914:                          ; CODE XREF: sub_488810+12j
    retn    10h
    sub_488810 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488920 proc near                    ; CODE XREF: sub_4854A0+1F1p

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h
    arg_8= dword ptr  1Ch

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     ebx, [esp+arg_4]
    mov     ebp, [esp+arg_8]
    mov     eax, [edi-4]
    lea     esi, [edi-4]
    push    eax
    push    ebx
    call    ebp
    test    eax, eax
    jz      short loc_488952

    loc_48893E:                             ; CODE XREF: sub_488920+30j
    mov     ecx, [esi]
    mov     [edi], ecx
    mov     edx, [esi-4]
    mov     edi, esi
    sub     esi, 4
    push    edx
    push    ebx
    call    ebp
    test    eax, eax
    jnz     short loc_48893E

    loc_488952:                             ; CODE XREF: sub_488920+1Cj
    mov     [edi], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_488920 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488960 proc near                    ; CODE XREF: sub_4854A0+2ABp

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h

    push    ebx
    mov     ebx, [esp+arg_C]
    push    ebp
    mov     ebp, [esp+4+arg_8]
    push    esi
    mov     esi, [esp+8+arg_4]
    push    edi
    mov     edi, [esp+0Ch+arg_0]

    loc_488974:                             ; CODE XREF: sub_488960+57j
    mov     eax, [edi]
    push    ebp
    push    eax
    call    ebx
    test    eax, eax
    jz      short loc_48898C

    loc_48897E:                             ; CODE XREF: sub_488960+2Aj
    mov     ecx, [edi+4]
    add     edi, 4
    push    ebp
    push    ecx
    call    ebx
    test    eax, eax
    jnz     short loc_48897E

    loc_48898C:                             ; CODE XREF: sub_488960+1Cj
    mov     edx, [esi-4]
    sub     esi, 4
    push    edx
    push    ebp
    call    ebx
    test    eax, eax
    jz      short loc_4889A8

    loc_48899A:                             ; CODE XREF: sub_488960+46j
    mov     eax, [esi-4]
    sub     esi, 4
    push    eax
    push    ebp
    call    ebx
    test    eax, eax
    jnz     short loc_48899A

    loc_4889A8:                             ; CODE XREF: sub_488960+38j
    cmp     esi, edi
    jbe     short loc_4889B9
    mov     ecx, [esi]
    mov     eax, [edi]
    mov     [edi], ecx
    mov     [esi], eax
    add     edi, 4
    jmp     short loc_488974
    ; ---------------------------------------------------------------------------

    loc_4889B9:                             ; CODE XREF: sub_488960+4Aj
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_488960 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    mov     al, [esp+3]
    push    offset loc_488A00
    mov     byte_51E6B0, al
    xor     eax, eax
    mov     dword_51E6B4, eax
    mov     dword_51E6B8, eax
    mov     dword_51E6BC, eax
    call    _atexit
    add     esp, 4
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    loc_488A00:                             ; DATA XREF: .text:004889D5o
    push    esi
    mov     esi, dword_51E6B4
    push    edi
    mov     edi, dword_51E6B8
    cmp     esi, edi
    jz      short loc_488A26

    loc_488A12:                             ; CODE XREF: .text:00488A1Ej
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_488A12
    mov     esi, dword_51E6B4

    loc_488A26:                             ; CODE XREF: .text:00488A10j
    push    esi
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     dword_51E6B4, eax
    mov     dword_51E6B8, eax
    pop     edi
    mov     dword_51E6BC, eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_488A50(char *)
    sub_488A50 proc near                    ; CODE XREF: sub_488310+8Bp

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+1438Fh]
    mov     ebp, [eax+1439Bh]
    mov     eax, ecx
    push    edi
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [ebp+eax*8+0]
    add     ebp, 249h
    add     eax, ecx
    mov     esi, eax
    mov     eax, 0E00E00E1h
    mov     ecx, esi
    mov     [esp+14h+var_4], esi
    sub     ecx, ebp
    imul    ecx
    add     edx, ecx
    sar     edx, 9
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     edi, edx
    test    edi, edi
    jle     short loc_488AE2

    loc_488A9C:                             ; CODE XREF: sub_488A50+8Cj
    mov     eax, edi
    cdq
    sub     eax, edx
    mov     edx, [esp+14h+arg_0]
    mov     esi, eax
    push    edx                             ; char *
    sar     esi, 1
    mov     eax, esi
    shl     eax, 6
    add     eax, esi
    lea     ecx, [ebp+eax*8+0]
    add     eax, ecx
    mov     ebx, eax
    lea     eax, [ebx+20h]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jge     short loc_488AD8
    or      ecx, 0FFFFFFFFh
    lea     ebp, [ebx+249h]
    sub     ecx, esi
    add     edi, ecx
    jmp     short loc_488ADA
    ; ---------------------------------------------------------------------------

    loc_488AD8:                             ; CODE XREF: sub_488A50+77j
    mov     edi, esi

    loc_488ADA:                             ; CODE XREF: sub_488A50+86j
    test    edi, edi
    jg      short loc_488A9C
    mov     esi, [esp+14h+var_4]

    loc_488AE2:                             ; CODE XREF: sub_488A50+4Aj
    cmp     ebp, esi
    jz      short loc_488B05
    mov     eax, [esp+14h+arg_0]
    lea     edx, [ebp+20h]
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_488B05
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_488B05:                             ; CODE XREF: sub_488A50+94j
                                            ; sub_488A50+A9j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    4
    sub_488A50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_488B10(char *)
    sub_488B10 proc near                    ; CODE XREF: .text:00404F60p
                                            ; .text:004174ABp ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+1438Fh]
    mov     ebp, [eax+TAdynmemStruct.UnitDef]
    mov     eax, ecx
    push    edi
    shl     eax, 6
    add     eax, ecx
    lea     ecx, [ebp+eax*8+0]
    add     ebp, 249h
    add     eax, ecx
    mov     esi, eax
    mov     eax, 0E00E00E1h
    mov     ecx, esi
    mov     [esp+14h+var_4], esi
    sub     ecx, ebp
    imul    ecx
    add     edx, ecx
    sar     edx, 9
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     edi, edx
    test    edi, edi
    jle     short loc_488BA2

    loc_488B5C:                             ; CODE XREF: sub_488B10+8Cj
    mov     eax, edi
    cdq
    sub     eax, edx
    mov     edx, [esp+14h+arg_0]
    mov     esi, eax
    push    edx                             ; char *
    sar     esi, 1
    mov     eax, esi
    shl     eax, 6
    add     eax, esi
    lea     ecx, [ebp+eax*8+0]
    add     eax, ecx
    mov     ebx, eax
    lea     eax, [ebx+20h]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jge     short loc_488B98
    or      ecx, 0FFFFFFFFh
    lea     ebp, [ebx+249h]
    sub     ecx, esi
    add     edi, ecx
    jmp     short loc_488B9A
    ; ---------------------------------------------------------------------------

    loc_488B98:                             ; CODE XREF: sub_488B10+77j
    mov     edi, esi

    loc_488B9A:                             ; CODE XREF: sub_488B10+86j
    test    edi, edi
    jg      short loc_488B5C
    mov     esi, [esp+14h+var_4]

    loc_488BA2:                             ; CODE XREF: sub_488B10+4Aj
    cmp     ebp, esi
    jz      short loc_488BBB
    mov     eax, [esp+14h+arg_0]
    lea     edx, [ebp+20h]
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_488BBD

    loc_488BBB:                             ; CODE XREF: sub_488B10+94j
    xor     ebp, ebp

    loc_488BBD:                             ; CODE XREF: sub_488B10+A9j
    test    ebp, ebp
    jz      short loc_488BD0
    mov     ax, [ebp+21Eh]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_488BD0:                             ; CODE XREF: sub_488B10+AFj
    pop     edi
    pop     esi
    pop     ebp
    xor     ax, ax
    pop     ebx
    pop     ecx
    retn    4
    sub_488B10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488BE0 proc near                    ; CODE XREF: sub_4917D0+D7p
    mov     dword_51E6C0, 1
    retn
    sub_488BE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488BF0 proc near                    ; CODE XREF: sub_491B60+DAp
    mov     eax, dword_51E6B8
    push    ebx
    push    esi
    mov     esi, dword_51E6B4
    cmp     esi, eax
    push    edi
    jz      short loc_488C20

    loc_488C02:                             ; CODE XREF: sub_488BF0+28j
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, dword_51E6B8
    add     esi, 8
    add     esp, 4
    cmp     esi, eax
    jnz     short loc_488C02
    mov     esi, dword_51E6B4

    loc_488C20:                             ; CODE XREF: sub_488BF0+10j
    cmp     esi, eax
    mov     ebx, esi
    mov     edi, eax
    jz      short loc_488C36

    loc_488C28:                             ; CODE XREF: sub_488BF0+44j
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_488C28

    loc_488C36:                             ; CODE XREF: sub_488BF0+36j
    pop     edi
    mov     dword_51E6B8, ebx
    pop     esi
    mov     dword_51E6C0, 0
    pop     ebx
    retn
    sub_488BF0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_488C50(char *)
    sub_488C50 proc near                    ; CODE XREF: sub_41C310+28p
                                            ; sub_42BF40+E8p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    mov     ebx, dword_51E6B4
    push    ebp
    push    esi
    push    edi
    mov     edi, dword_51E6B8
    mov     ebp, [esp+18h+arg_0]
    sub     edi, ebx
    sar     edi, 3
    test    edi, edi
    jle     short loc_488C9D

    loc_488C70:                             ; CODE XREF: sub_488C50+4Bj
    mov     eax, edi
    push    ebp                             ; char *
    cdq
    sub     eax, edx
    mov     esi, eax
    sar     esi, 1
    mov     eax, [ebx+esi*8]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jge     short loc_488C97
    or      ecx, 0FFFFFFFFh
    lea     ebx, [ebx+esi*8+8]
    sub     ecx, esi
    add     edi, ecx
    jmp     short loc_488C99
    ; ---------------------------------------------------------------------------

    loc_488C97:                             ; CODE XREF: sub_488C50+38j
    mov     edi, esi

    loc_488C99:                             ; CODE XREF: sub_488C50+45j
    test    edi, edi
    jg      short loc_488C70

    loc_488C9D:                             ; CODE XREF: sub_488C50+1Ej
    cmp     ebx, dword_51E6B8
    jz      short loc_488CC2
    mov     edx, [ebx]
    push    ebp                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_488CC2
    mov     eax, [ebx+4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_488CC2:                             ; CODE XREF: sub_488C50+53j
                                            ; sub_488C50+63j
    push    40h                             ; int
    call    sub_4B4F10
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jz      short loc_488CDF
    mov     ecx, 10h
    xor     eax, eax
    mov     edi, esi
    rep stosd
    jmp     short loc_488CE1
    ; ---------------------------------------------------------------------------

    loc_488CDF:                             ; CODE XREF: sub_488C50+80j
    xor     esi, esi

    loc_488CE1:                             ; CODE XREF: sub_488C50+8Dj
    push    ebp
    lea     ecx, [esp+1Ch+arg_0]
    call    sub_4C91B0
    push    eax
    lea     ecx, [esp+1Ch+var_8]
    call    sub_4C91A0
    lea     eax, [esp+18h+var_8]
    mov     ecx, offset byte_51E6B0
    push    eax
    push    1
    push    ebx
    mov     [esp+24h+var_4], esi
    call    sub_488FB0
    lea     ecx, [esp+18h+var_8]
    call    sub_4C9390
    lea     ecx, [esp+18h+arg_0]
    call    sub_4C9390
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_488C50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_488D30(char *,int)
    sub_488D30 proc near                    ; CODE XREF: sub_406DB0+39p
                                            ; sub_406E40+3Dp

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 8
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ecx, [eax+1438Fh]
    mov     ebp, [eax+1439Bh]
    mov     eax, ecx
    push    esi
    shl     eax, 6
    add     eax, ecx
    push    edi
    mov     [esp+18h+var_8], ebx
    lea     ecx, [ebp+eax*8+0]
    add     ebp, 249h
    add     eax, ecx
    mov     esi, eax
    mov     eax, 0E00E00E1h
    mov     ecx, esi
    mov     [esp+18h+var_4], esi
    sub     ecx, ebp
    imul    ecx
    add     edx, ecx
    sar     edx, 9
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     edi, edx
    test    edi, edi
    jle     short loc_488DCE

    loc_488D84:                             ; CODE XREF: sub_488D30+94j
    mov     eax, edi
    cdq
    sub     eax, edx
    mov     edx, [esp+18h+arg_0]
    mov     esi, eax
    push    edx                             ; char *
    sar     esi, 1
    mov     eax, esi
    shl     eax, 6
    add     eax, esi
    lea     ecx, [ebp+eax*8+0]
    add     eax, ecx
    mov     ebx, eax
    lea     eax, [ebx+20h]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jge     short loc_488DC0
    or      ecx, 0FFFFFFFFh
    lea     ebp, [ebx+249h]
    sub     ecx, esi
    add     edi, ecx
    jmp     short loc_488DC2
    ; ---------------------------------------------------------------------------

    loc_488DC0:                             ; CODE XREF: sub_488D30+7Fj
    mov     edi, esi

    loc_488DC2:                             ; CODE XREF: sub_488D30+8Ej
    test    edi, edi
    jg      short loc_488D84
    mov     ebx, [esp+18h+var_8]
    mov     esi, [esp+18h+var_4]

    loc_488DCE:                             ; CODE XREF: sub_488D30+52j
    cmp     ebp, esi
    jz      short loc_488DE7
    mov     eax, [esp+18h+arg_0]
    lea     edx, [ebp+20h]
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_488DE9

    loc_488DE7:                             ; CODE XREF: sub_488D30+A0j
    xor     ebp, ebp

    loc_488DE9:                             ; CODE XREF: sub_488D30+B5j
    test    ebp, ebp
    jz      short loc_488DF6
    mov     cx, [ebp+21Eh]
    jmp     short loc_488DF8
    ; ---------------------------------------------------------------------------

    loc_488DF6:                             ; CODE XREF: sub_488D30+BBj
    xor     ecx, ecx

    loc_488DF8:                             ; CODE XREF: sub_488D30+C4j
    test    cx, cx
    jz      short loc_488E2F
    and     ecx, 0FFFFh
    mov     edx, ecx
    and     ecx, 1Fh
    shr     edx, 5
    lea     eax, [ebx+edx*4]
    mov     edx, 1
    shl     edx, cl
    mov     ecx, [eax]
    or      ecx, edx
    mov     [eax], ecx
    mov     eax, [esp+18h+arg_4]
    mov     dword ptr [eax], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_488E2F:                             ; CODE XREF: sub_488D30+CBj
    mov     ecx, [esp+18h+arg_0]
    push    ecx                             ; char *
    call    sub_488C50
    mov     ecx, ebx
    sub     eax, ebx
    mov     edx, 10h

    loc_488E42:                             ; CODE XREF: sub_488D30+11Fj
    mov     esi, [eax+ecx]
    mov     ebx, [ecx]
    or      ebx, esi
    mov     [ecx], ebx
    add     ecx, 4
    dec     edx
    jnz     short loc_488E42
    mov     edx, [esp+18h+arg_4]
    pop     edi
    pop     esi
    pop     ebp
    mov     dword ptr [edx], 0
    pop     ebx
    add     esp, 8
    retn    8
    sub_488D30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488E70 proc near                    ; CODE XREF: sub_42BF40+D00p

    var_104= dword ptr -104h
    var_100= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 104h
    lea     eax, [esp+104h+var_104]
    push    ebx
    mov     ebx, ecx
    push    esi
    mov     esi, [esp+10Ch+arg_0]
    lea     ecx, [esp+10Ch+var_100]
    push    eax
    push    ecx
    push    offset aSN                      ; " %s %n"
    push    esi
    call    _sscanf
    add     esp, 10h
    cmp     eax, 1
    jnz     short loc_488EF4
    push    edi

    loc_488E9F:                             ; CODE XREF: sub_488E70+81j
    mov     ecx, [esp+110h+var_104]
    mov     di, [ebx+21Eh]
    lea     edx, [esp+110h+var_100]
    add     esi, ecx
    push    edx                             ; char *
    call    sub_488C50
    mov     ecx, edi
    and     ecx, 0FFFFh
    mov     edx, ecx
    and     ecx, 1Fh
    shr     edx, 5
    lea     eax, [eax+edx*4]
    mov     edx, 1
    shl     edx, cl
    mov     ecx, [eax]
    or      ecx, edx
    mov     [eax], ecx
    lea     eax, [esp+110h+var_104]
    lea     ecx, [esp+110h+var_100]
    push    eax
    push    ecx
    push    offset aSN                      ; " %s %n"
    push    esi
    call    _sscanf
    add     esp, 10h
    cmp     eax, 1
    jz      short loc_488E9F
    pop     edi

    loc_488EF4:                             ; CODE XREF: sub_488E70+2Cj
    mov     bx, [ebx+21Eh]
    push    offset off_507C14               ; char *
    call    sub_488C50
    mov     ecx, ebx
    pop     esi
    and     ecx, 0FFFFh
    pop     ebx
    mov     edx, ecx
    and     ecx, 1Fh
    shr     edx, 5
    lea     eax, [eax+edx*4]
    mov     edx, 1
    shl     edx, cl
    or      [eax], edx
    add     esp, 104h
    retn    4
    sub_488E70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488F30 proc near                    ; CODE XREF: .text:00409610p
                                            ; sub_409730+1A1p ...

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    fld     dword ptr [ecx+1C6h]
    fcomp   ds:dbl_4FD720
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_488F50
    fld     dword ptr [ecx+1C6h]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_488F50:                             ; CODE XREF: sub_488F30+15j
    fld     dword ptr [ecx+1D2h]
    fcomp   ds:flt_4FD728
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_488F79
    mov     eax, TAdynmemStructPtr
    fld     dword ptr [eax+37EDEh]
    fmul    dword ptr [ecx+1D2h]
    fchs
    retn    4
    ; ---------------------------------------------------------------------------

    loc_488F79:                             ; CODE XREF: sub_488F30+31j
    fld     dword ptr [ecx+1D6h]
    fcomp   ds:flt_4FD728
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_488FA3
    mov     edx, TAdynmemStructPtr
    fld     dword ptr [edx+14267h]
    fmul    dword ptr [ecx+1D6h]
    fchs
    retn    4
    ; ---------------------------------------------------------------------------

    loc_488FA3:                             ; CODE XREF: sub_488F30+5Aj
    fld     ds:flt_4FD728
    retn    4
    sub_488F30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_488FB0 proc near                    ; CODE XREF: sub_488C50+B6p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    mov     eax, [ecx+0Ch]
    push    ebx
    mov     edx, [esp+10h+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     [esp+1Ch+var_C], ecx
    sub     eax, edi
    sar     eax, 3
    cmp     eax, edx
    jnb     loc_489127
    mov     ecx, [ecx+4]
    test    ecx, ecx
    jnz     short loc_488FDD
    xor     eax, eax
    jmp     short loc_488FE4
    ; ---------------------------------------------------------------------------

    loc_488FDD:                             ; CODE XREF: sub_488FB0+27j
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 3

    loc_488FE4:                             ; CODE XREF: sub_488FB0+2Bj
    cmp     edx, eax
    jnb     short loc_488FF9
    test    ecx, ecx
    jnz     short loc_488FF0
    xor     eax, eax
    jmp     short loc_488FFB
    ; ---------------------------------------------------------------------------

    loc_488FF0:                             ; CODE XREF: sub_488FB0+3Aj
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 3
    jmp     short loc_488FFB
    ; ---------------------------------------------------------------------------

    loc_488FF9:                             ; CODE XREF: sub_488FB0+36j
    mov     eax, edx

    loc_488FFB:                             ; CODE XREF: sub_488FB0+3Ej
                                            ; sub_488FB0+47j
    test    ecx, ecx
    jnz     short loc_489003
    xor     edi, edi
    jmp     short loc_489008
    ; ---------------------------------------------------------------------------

    loc_489003:                             ; CODE XREF: sub_488FB0+4Dj
    sub     edi, ecx
    sar     edi, 3

    loc_489008:                             ; CODE XREF: sub_488FB0+51j
    add     eax, edi
    test    eax, eax
    mov     [esp+1Ch+var_4], eax
    jge     short loc_489014
    xor     eax, eax

    loc_489014:                             ; CODE XREF: sub_488FB0+60j
    lea     ecx, ds:0[eax*8]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     edx, [esp+20h+var_C]
    mov     ecx, [esp+20h+arg_0]
    add     esp, 4
    mov     [esp+1Ch+var_8], eax
    mov     esi, [edx+4]
    mov     ebx, eax
    cmp     esi, ecx
    jz      short loc_489053

    loc_489039:                             ; CODE XREF: sub_488FB0+A1j
    test    ebx, ebx
    jz      short loc_489045
    push    esi
    mov     ecx, ebx
    call    sub_489260

    loc_489045:                             ; CODE XREF: sub_488FB0+8Bj
    mov     ecx, [esp+1Ch+arg_0]
    add     esi, 8
    add     ebx, 8
    cmp     esi, ecx
    jnz     short loc_489039

    loc_489053:                             ; CODE XREF: sub_488FB0+87j
    mov     edi, [esp+1Ch+arg_4]
    mov     esi, ebx
    test    edi, edi
    jbe     short loc_48907B
    mov     ebp, [esp+1Ch+arg_8]

    loc_489061:                             ; CODE XREF: sub_488FB0+C1j
    test    esi, esi
    jz      short loc_48906D
    push    ebp
    mov     ecx, esi
    call    sub_489260

    loc_48906D:                             ; CODE XREF: sub_488FB0+B3j
    add     esi, 8
    dec     edi
    jnz     short loc_489061
    mov     edi, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+arg_0]

    loc_48907B:                             ; CODE XREF: sub_488FB0+ABj
    mov     edx, [esp+1Ch+var_C]
    lea     eax, ds:0[edi*8]
    mov     ebp, [edx+8]
    lea     edi, [ebx+eax]
    cmp     ecx, ebp
    jz      short loc_4890AE
    mov     esi, edi
    sub     esi, ebx
    add     esi, ecx
    sub     esi, eax

    loc_489098:                             ; CODE XREF: sub_488FB0+FCj
    test    edi, edi
    jz      short loc_4890A4
    push    esi
    mov     ecx, edi
    call    sub_489260

    loc_4890A4:                             ; CODE XREF: sub_488FB0+EAj
    add     esi, 8
    add     edi, 8
    cmp     esi, ebp
    jnz     short loc_489098

    loc_4890AE:                             ; CODE XREF: sub_488FB0+DEj
    mov     edi, [esp+1Ch+var_C]
    mov     ebx, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, ebx
    jz      short loc_4890CA

    loc_4890BC:                             ; CODE XREF: sub_488FB0+118j
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 8
    cmp     esi, ebx
    jnz     short loc_4890BC

    loc_4890CA:                             ; CODE XREF: sub_488FB0+10Aj
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+20h+var_8]
    mov     eax, [esp+20h+var_4]
    add     esp, 4
    lea     ecx, [edx+eax*8]
    mov     [edi+0Ch], ecx
    mov     ecx, [edi+4]
    test    ecx, ecx
    jnz     short loc_489106
    mov     ecx, [esp+1Ch+arg_4]
    xor     eax, eax
    add     ecx, eax
    mov     [edi+4], edx
    lea     eax, [edx+ecx*8]
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_489106:                             ; CODE XREF: sub_488FB0+139j
    mov     eax, [edi+8]
    mov     [edi+4], edx
    sub     eax, ecx
    mov     ecx, [esp+1Ch+arg_4]
    sar     eax, 3
    add     ecx, eax
    lea     eax, [edx+ecx*8]
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_489127:                             ; CODE XREF: sub_488FB0+1Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     eax, edi
    sub     eax, ebp
    sar     eax, 3
    cmp     eax, edx
    jnb     short loc_4891B3
    lea     eax, ds:0[edx*8]
    cmp     ebp, edi
    mov     [esp+1Ch+arg_0], eax
    lea     ebx, [ebp+eax+0]
    jz      short loc_48916B
    mov     esi, ebx
    sub     esi, eax

    loc_48914D:                             ; CODE XREF: sub_488FB0+1B5j
    test    ebx, ebx
    jz      short loc_48915D
    push    esi
    mov     ecx, ebx
    call    sub_489260
    mov     edx, [esp+1Ch+arg_4]

    loc_48915D:                             ; CODE XREF: sub_488FB0+19Fj
    add     esi, 8
    add     ebx, 8
    cmp     esi, edi
    jnz     short loc_48914D
    mov     ecx, [esp+1Ch+var_C]

    loc_48916B:                             ; CODE XREF: sub_488FB0+197j
    mov     esi, [ecx+8]
    mov     ebx, [esp+1Ch+arg_8]
    mov     eax, esi
    sub     eax, ebp
    sar     eax, 3
    sub     edx, eax
    jz      short loc_489195
    mov     edi, edx

    loc_48917F:                             ; CODE XREF: sub_488FB0+1DFj
    test    esi, esi
    jz      short loc_48918B
    push    ebx
    mov     ecx, esi
    call    sub_489260

    loc_48918B:                             ; CODE XREF: sub_488FB0+1D1j
    add     esi, 8
    dec     edi
    jnz     short loc_48917F
    mov     ecx, [esp+1Ch+var_C]

    loc_489195:                             ; CODE XREF: sub_488FB0+1CBj
    mov     edi, [ecx+8]
    mov     esi, ebp
    cmp     ebp, edi
    jz      loc_489224

    loc_4891A2:                             ; CODE XREF: sub_488FB0+1FFj
    push    ebx
    mov     ecx, esi
    call    sub_489240
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_4891A2
    jmp     short loc_489224
    ; ---------------------------------------------------------------------------

    loc_4891B3:                             ; CODE XREF: sub_488FB0+184j
    test    edx, edx
    jbe     short loc_48922F
    shl     edx, 3
    mov     esi, edi
    mov     ebx, edi
    sub     esi, edx
    mov     [esp+1Ch+arg_0], edx
    cmp     esi, edi
    jz      short loc_4891E6

    loc_4891C8:                             ; CODE XREF: sub_488FB0+22Cj
    test    ebx, ebx
    jz      short loc_4891D4
    push    esi
    mov     ecx, ebx
    call    sub_489260

    loc_4891D4:                             ; CODE XREF: sub_488FB0+21Aj
    add     esi, 8
    add     ebx, 8
    cmp     esi, edi
    jnz     short loc_4891C8
    mov     ecx, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]

    loc_4891E6:                             ; CODE XREF: sub_488FB0+216j
    mov     edi, [ecx+8]
    mov     esi, edi
    sub     esi, edx
    cmp     ebp, esi
    jz      short loc_489203

    loc_4891F1:                             ; CODE XREF: sub_488FB0+251j
    sub     esi, 8
    sub     edi, 8
    push    esi
    mov     ecx, edi
    call    sub_489240
    cmp     esi, ebp
    jnz     short loc_4891F1

    loc_489203:                             ; CODE XREF: sub_488FB0+23Fj
    mov     edx, [esp+1Ch+arg_0]
    mov     esi, ebp
    lea     edi, [ebp+edx+0]
    cmp     ebp, edi
    jz      short loc_489224
    mov     ebx, [esp+1Ch+arg_8]

    loc_489215:                             ; CODE XREF: sub_488FB0+272j
    push    ebx
    mov     ecx, esi
    call    sub_489240
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_489215

    loc_489224:                             ; CODE XREF: sub_488FB0+1ECj
                                            ; sub_488FB0+201j ...
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, [esp+1Ch+arg_0]
    add     [eax+8], ecx

    loc_48922F:                             ; CODE XREF: sub_488FB0+205j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_488FB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489240 proc near                    ; CODE XREF: sub_488FB0+1F5p
                                            ; sub_488FB0+24Ap ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_4C93B0
    mov     eax, [edi+4]
    pop     edi
    mov     [esi+4], eax
    mov     eax, esi
    pop     esi
    retn    4
    sub_489240 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489260 proc near                    ; CODE XREF: sub_488FB0+90p
                                            ; sub_488FB0+B8p ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_4C91A0
    mov     eax, [edi+4]
    pop     edi
    mov     [esi+4], eax
    mov     eax, esi
    pop     esi
    retn    4
    sub_489260 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489280 proc near                    ; CODE XREF: sub_4942E0+15Fp

    var_20= qword ptr -20h
    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    0C0h
    push    offset aProplist                ; "PropList"
    call    sub_4D83B0
    mov     ebx, ds:wsprintfA
    add     esp, 8
    mov     ebp, eax
    mov     ecx, 30h
    xor     eax, eax
    mov     edi, ebp
    push    offset byte_50319C              ; LPCSTR
    push    ebp                             ; LPSTR
    rep stosd
    call    ebx ; wsprintfA
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    mov     esi, [esp+14h+arg_0]
    not     ecx
    fld     dword ptr [esi+186h]
    dec     ecx
    lea     edi, [ecx+ebp+1]
    mov     [esp+14h+var_4], edi
    call    __ftol
    push    eax
    push    offset aD_0                     ; LPCSTR
    push    edi                             ; LPSTR
    call    ebx ; wsprintfA
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    fld     dword ptr [esi+18Ah]
    mov     eax, [esp+14h+var_4]
    not     ecx
    dec     ecx
    lea     edi, [eax+ecx+1]
    mov     [esp+14h+var_4], edi
    call    __ftol
    push    eax
    push    offset aD_0                     ; LPCSTR
    push    edi                             ; LPSTR
    call    ebx ; wsprintfA
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    mov     edx, [esp+14h+var_4]
    repne scasb
    mov     eax, [esi+1EAh]
    not     ecx
    dec     ecx
    push    eax
    push    offset aD_0                     ; LPCSTR
    lea     edi, [edx+ecx+1]
    push    edi                             ; LPSTR
    mov     [esp+20h+var_4], edi
    call    ebx ; wsprintfA
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    mov     edx, [esp+14h+var_4]
    repne scasb
    not     ecx
    dec     ecx
    push    offset byte_50319C              ; LPCSTR
    lea     edi, [edx+ecx+1]
    push    edi                             ; LPSTR
    mov     [esp+1Ch+var_4], edi
    call    ebx ; wsprintfA
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    mov     eax, [esp+14h+var_4]
    not     ecx
    dec     ecx
    lea     ebx, [eax+ecx+1]
    mov     al, [esi+22Fh]
    test    al, al
    jz      loc_489475
    fild    dword ptr [esi+192h]
    push    offset aMS                      ; int
    fmul    ds:flt_4FD730
    fstp    [esp+18h+var_4]
    call    sub_4C5740
    push    eax
    call    sub_4B6330
    mov     [esp+18h+arg_0], eax
    sub     esp, 8
    fild    [esp+20h+arg_0]
    fmul    [esp+20h+var_4]
    fmul    ds:dbl_4FD738
    fstp    [esp+20h+var_20]
    push    offset a_1fS                    ; "%.1f %s "
    push    ebx
    call    _sprintf
    fild    dword ptr [esi+19Eh]
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 14h
    repne scasb
    fmul    ds:flt_4FD730
    fstp    [esp+14h+var_4]
    not     ecx
    dec     ecx
    push    offset aMSS                     ; int
    lea     ebx, [ebx+ecx+1]
    call    sub_4C5740
    push    eax
    call    sub_4B6330
    mov     [esp+18h+arg_0], eax
    sub     esp, 8
    fild    [esp+20h+arg_0]
    fmul    [esp+20h+var_4]
    fmul    ds:dbl_4FD738
    fstp    [esp+20h+var_20]
    push    offset a_2fS                    ; "%.2f %s"
    push    ebx
    call    _sprintf
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 14h
    repne scasb
    not     ecx
    dec     ecx
    push    offset aDegS                    ; int
    lea     edi, [ebx+ecx+1]
    call    sub_4C5740
    push    eax
    call    sub_4B6330
    xor     ecx, ecx
    mov     [esp+18h+arg_0], eax
    mov     cx, [esi+1BAh]
    sub     esp, 8
    fild    [esp+20h+arg_0]
    mov     [esp+20h+arg_0], ecx
    fild    [esp+20h+arg_0]
    fmulp   st(1), st
    fmul    ds:dbl_4FD740
    fstp    [esp+20h+var_20]
    push    offset a_0fS                    ; "%.0f %s"
    push    edi
    call    _sprintf
    add     esp, 14h
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489475:                             ; CODE XREF: sub_489280+F4j
    push    offset off_508D18               ; int
    call    sub_4C5740
    push    eax
    push    offset aS_1                     ; "%s"
    push    ebx
    call    _sprintf
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    push    offset off_508D18               ; int
    lea     ebx, [ebx+ecx+1]
    call    sub_4C5740
    push    eax
    push    offset aS_1                     ; "%s"
    push    ebx
    call    _sprintf
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    push    offset off_508D18               ; int
    lea     esi, [ebx+ecx+1]
    call    sub_4C5740
    push    eax
    push    offset aS_1                     ; "%s"
    push    esi
    call    _sprintf
    add     esp, 0Ch
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_489280 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    xor     eax, eax
    push    esi
    mov     ecx, [ecx+92h]
    mov     edx, [ecx+152h]
    test    edx, edx
    jle     short loc_48952E
    mov     ecx, [ecx+156h]
    mov     si, [esp+0Ch]

    loc_489512:                             ; CODE XREF: .text:0048951Dj
    cmp     [ecx], si
    jz      short loc_489525
    inc     eax
    add     ecx, 2
    cmp     eax, edx
    jl      short loc_489512
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_489525:                             ; CODE XREF: .text:00489515j
    mov     eax, 1
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48952E:                             ; CODE XREF: .text:00489505j
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    xor     edx, edx
    cmp     eax, edx
    jz      short loc_489568
    cmp     [eax+0A6h], dx
    jz      short loc_489568
    mov     [ecx+4], eax
    mov     edx, [eax+0A2h]
    mov     [ecx+8], edx
    mov     [eax+0A2h], ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489568:                             ; CODE XREF: .text:00489548j
                                            ; .text:00489551j
    mov     [ecx+4], edx
    mov     [ecx+8], edx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx+4]
    test    eax, eax
    jz      short locret_4895B4
    lea     edx, [eax+0A2h]
    mov     eax, [eax+0A2h]
    cmp     eax, ecx
    jz      short loc_4895A1

    loc_489597:                             ; CODE XREF: .text:0048959Fj
    lea     edx, [eax+8]
    mov     eax, [eax+8]
    cmp     eax, ecx
    jnz     short loc_489597

    loc_4895A1:                             ; CODE XREF: .text:00489595j
    mov     eax, [ecx+8]
    mov     [edx], eax
    mov     dword ptr [ecx+4], 0
    mov     dword ptr [ecx+8], 0

    locret_4895B4:                          ; CODE XREF: .text:00489585j
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4895C0 proc near                    ; CODE XREF: sub_43A0C0+23p
                                            ; sub_43A420+20p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, ecx
    xor     edx, edx
    mov     ecx, [esp+arg_4]
    mov     [eax+0Ch], ecx
    mov     ecx, [esp+arg_0]
    cmp     ecx, edx
    mov     dword ptr [eax], offset off_4FD754
    jz      short loc_4895F7
    cmp     [ecx+0A6h], dx
    jz      short loc_4895F7
    mov     [eax+4], ecx
    mov     edx, [ecx+0A2h]
    mov     [eax+8], edx
    mov     [ecx+0A2h], eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4895F7:                             ; CODE XREF: sub_4895C0+17j
                                            ; sub_4895C0+20j
    mov     [eax+4], edx
    mov     [eax+8], edx
    retn    8
    sub_4895C0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489600 proc near                    ; DATA XREF: .rdata:004FD754o

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    xor     edx, edx
    mov     eax, [esi+4]
    mov     dword ptr [esi], offset off_4FD754
    cmp     eax, edx
    jz      short loc_489637
    lea     ecx, [eax+0A2h]
    mov     eax, [eax+0A2h]
    cmp     eax, esi
    jz      short loc_48962C

    loc_489622:                             ; CODE XREF: sub_489600+2Aj
    lea     ecx, [eax+8]
    mov     eax, [eax+8]
    cmp     eax, esi
    jnz     short loc_489622

    loc_48962C:                             ; CODE XREF: sub_489600+20j
    mov     eax, [esi+8]
    mov     [ecx], eax
    mov     [esi+4], edx
    mov     [esi+8], edx

    loc_489637:                             ; CODE XREF: sub_489600+10j
    test    [esp+arg_0], 1
    jz      short loc_489647
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_489647:                             ; CODE XREF: sub_489600+3Cj
    mov     eax, esi
    pop     esi
    retn    4
    sub_489600 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489650 proc near                    ; CODE XREF: sub_43A1F0+D1p
                                            ; sub_44DE80+D2p ...
    mov     eax, [ecx+4]
    mov     dword ptr [ecx], offset off_4FD754
    test    eax, eax
    jz      short locret_48968A
    lea     edx, [eax+0A2h]
    mov     eax, [eax+0A2h]
    cmp     eax, ecx
    jz      short loc_489677

    loc_48966D:                             ; CODE XREF: sub_489650+25j
    lea     edx, [eax+8]
    mov     eax, [eax+8]
    cmp     eax, ecx
    jnz     short loc_48966D

    loc_489677:                             ; CODE XREF: sub_489650+1Bj
    mov     eax, [ecx+8]
    mov     [edx], eax
    mov     dword ptr [ecx+4], 0
    mov     dword ptr [ecx+8], 0

    locret_48968A:                          ; CODE XREF: sub_489650+Bj
    retn
    sub_489650 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489690 proc near                    ; CODE XREF: .text:00402267p
                                            ; .text:004023BEp ...

    arg_0= dword ptr  4

    mov     eax, [ecx+4]
    push    esi
    xor     esi, esi
    cmp     eax, esi
    jz      short loc_4896BF
    lea     edx, [eax+0A2h]
    mov     eax, [eax+0A2h]
    cmp     eax, ecx
    jz      short loc_4896B4

    loc_4896AA:                             ; CODE XREF: sub_489690+22j
    lea     edx, [eax+8]
    mov     eax, [eax+8]
    cmp     eax, ecx
    jnz     short loc_4896AA

    loc_4896B4:                             ; CODE XREF: sub_489690+18j
    mov     eax, [ecx+8]
    mov     [edx], eax
    mov     [ecx+4], esi
    mov     [ecx+8], esi

    loc_4896BF:                             ; CODE XREF: sub_489690+8j
    mov     eax, [esp+4+arg_0]
    cmp     eax, esi
    jz      short loc_4896E6
    cmp     [eax+0A6h], si
    jz      short loc_4896E6
    mov     [ecx+4], eax
    mov     edx, [eax+0A2h]
    mov     [ecx+8], edx
    mov     [eax+0A2h], ecx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4896E6:                             ; CODE XREF: sub_489690+35j
                                            ; sub_489690+3Ej
    mov     [ecx+4], esi
    mov     [ecx+8], esi
    pop     esi
    retn    4
    sub_489690 endp

    ; ---------------------------------------------------------------------------
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [esi+0Ch]
    mov     edi, [esi+4]
    test    ecx, ecx
    jz      short loc_489704
    mov     eax, [ecx]
    push    8
    call    dword ptr [eax]

    loc_489704:                             ; CODE XREF: .text:004896FCj
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_48973C
    test    eax, eax
    jz      short loc_48973C
    lea     ecx, [eax+0A2h]
    mov     eax, [eax+0A2h]
    cmp     eax, esi
    jz      short loc_489729

    loc_48971F:                             ; CODE XREF: .text:00489727j
    lea     ecx, [eax+8]
    mov     eax, [eax+8]
    cmp     eax, esi
    jnz     short loc_48971F

    loc_489729:                             ; CODE XREF: .text:0048971Dj
    mov     edx, [esi+8]
    mov     [ecx], edx
    mov     dword ptr [esi+4], 0
    mov     dword ptr [esi+8], 0

    loc_48973C:                             ; CODE XREF: .text:00489709j
                                            ; .text:0048970Dj
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489740 proc near                    ; CODE XREF: sub_4866D0+6A5p

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    xor     ebx, ebx
    mov     esi, [ebp+0A2h]
    cmp     esi, ebx
    jz      short loc_48979F
    push    edi

    loc_489754:                             ; CODE XREF: sub_489740+5Cj
    mov     ecx, [esi+0Ch]
    mov     edi, [esi+4]
    cmp     ecx, ebx
    jz      short loc_489764
    mov     eax, [ecx]
    push    8
    call    dword ptr [eax]

    loc_489764:                             ; CODE XREF: sub_489740+1Cj
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_489794
    cmp     eax, ebx
    jz      short loc_489794
    lea     ecx, [eax+0A2h]
    mov     eax, [eax+0A2h]
    cmp     eax, esi
    jz      short loc_489789

    loc_48977F:                             ; CODE XREF: sub_489740+47j
    lea     ecx, [eax+8]
    mov     eax, [eax+8]
    cmp     eax, esi
    jnz     short loc_48977F

    loc_489789:                             ; CODE XREF: sub_489740+3Dj
    mov     edx, [esi+8]
    mov     [ecx], edx
    mov     [esi+4], ebx
    mov     [esi+8], ebx

    loc_489794:                             ; CODE XREF: sub_489740+29j
                                            ; sub_489740+2Dj
    mov     esi, [ebp+0A2h]
    cmp     esi, ebx
    jnz     short loc_489754
    pop     edi

    loc_48979F:                             ; CODE XREF: sub_489740+11j
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_489740 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4897B0 proc near                    ; CODE XREF: sub_406F80+Cp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, [eax+0A2h]
    test    esi, esi
    jz      short loc_4897D8
    push    edi
    mov     edi, [esp+8+arg_4]

    loc_4897C4:                             ; CODE XREF: sub_4897B0+25j
    mov     ecx, [esi+0Ch]
    test    ecx, ecx
    jz      short loc_4897D0
    mov     edx, [ecx]
    push    edi
    call    dword ptr [edx]

    loc_4897D0:                             ; CODE XREF: sub_4897B0+19j
    mov     esi, [esi+8]
    test    esi, esi
    jnz     short loc_4897C4
    pop     edi

    loc_4897D8:                             ; CODE XREF: sub_4897B0+Dj
    pop     esi
    retn    8
    sub_4897B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4897E0 proc near                    ; CODE XREF: .text:00403597p
    mov     al, [ecx+1Fh]
    mov     dl, 2
    test    dl, al
    jz      short loc_4897EC
    xor     al, al
    retn
    ; ---------------------------------------------------------------------------

    loc_4897EC:                             ; CODE XREF: sub_4897E0+7j
    test    [ecx+3Bh], dl
    jz      short loc_4897F4
    mov     al, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_4897F4:                             ; CODE XREF: sub_4897E0+Fj
    mov     al, [ecx+57h]
    and     al, dl
    retn
    sub_4897E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489800 proc near                    ; CODE XREF: .text:00402197p
                                            ; .text:00402239p ...

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    push    edi
    cmp     al, 3
    mov     edi, ecx
    jnz     short loc_489821
    push    0
    call    sub_489800
    push    1
    mov     ecx, edi
    call    sub_489800
    mov     [esp+8+arg_0], 2

    loc_489821:                             ; CODE XREF: sub_489800+Aj
    mov     esi, dword ptr [esp+8+arg_0]
    and     esi, 0FFh
    lea     eax, ds:0[esi*8]
    sub     eax, esi
    lea     ecx, [edi+eax*4+4]
    mov     al, [edi+eax*4+1Fh]
    test    al, 2
    jz      short loc_48989D
    test    al, 10h
    jnz     short loc_48989D
    or      al, 10h
    mov     [ecx+1Bh], al
    mov     ecx, esi
    shl     ecx, 3
    sub     ecx, esi
    cmp     word ptr [edi+ecx*4+4], 0
    lea     eax, [edi+ecx*4+4]
    mov     ecx, 0FFFF8000h
    jnz     short loc_489867
    cmp     [eax+2], cx
    jz      short loc_48989D

    loc_489867:                             ; CODE XREF: sub_489800+5Fj
    mov     word ptr [eax], 0
    mov     [eax+2], cx
    mov     ecx, [edi+9Ah]
    push    offset aStartbuilding           ; "StartBuilding"
    call    sub_4B07C0
    mov     ecx, [edi+9Ah]
    push    0
    push    0
    push    0
    push    esi
    push    1
    push    0
    push    0
    push    offset aTargetcleared           ; "TargetCleared"
    call    sub_4B0A70

    loc_48989D:                             ; CODE XREF: sub_489800+3Ej
                                            ; sub_489800+42j ...
    pop     edi
    pop     esi
    retn    4
    sub_489800 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4898B0 proc near                    ; CODE XREF: .text:004021AEp
                                            ; .text:00402298p ...

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    push    edi
    cmp     al, 3
    mov     edi, ecx
    jnz     short loc_4898D1
    push    0
    call    sub_4898B0
    push    1
    mov     ecx, edi
    call    sub_4898B0
    mov     [esp+8+arg_0], 2

    loc_4898D1:                             ; CODE XREF: sub_4898B0+Aj
    mov     esi, dword ptr [esp+8+arg_0]
    and     esi, 0FFh
    lea     eax, ds:0[esi*8]
    sub     eax, esi
    lea     ecx, [edi+eax*4+4]
    mov     al, [edi+eax*4+1Fh]
    test    al, 2
    jz      short loc_48994D
    test    al, 10h
    jz      short loc_48994D
    and     al, 0EFh
    mov     [ecx+1Bh], al
    mov     ecx, esi
    shl     ecx, 3
    sub     ecx, esi
    cmp     word ptr [edi+ecx*4+4], 0
    lea     eax, [edi+ecx*4+4]
    mov     ecx, 0FFFF8000h
    jnz     short loc_489917
    cmp     [eax+2], cx
    jz      short loc_48994D

    loc_489917:                             ; CODE XREF: sub_4898B0+5Fj
    mov     word ptr [eax], 0
    mov     [eax+2], cx
    mov     ecx, [edi+9Ah]
    push    offset aStartbuilding           ; "StartBuilding"
    call    sub_4B07C0
    mov     ecx, [edi+9Ah]
    push    0
    push    0
    push    0
    push    esi
    push    1
    push    0
    push    0
    push    offset aTargetcleared           ; "TargetCleared"
    call    sub_4B0A70

    loc_48994D:                             ; CODE XREF: sub_4898B0+3Ej
                                            ; sub_4898B0+42j ...
    pop     edi
    pop     esi
    retn    4
    sub_4898B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489960 proc near                    ; CODE XREF: .text:00404788p
                                            ; .text:00404961p ...

    arg_0= dword ptr  4

    mov     eax, [ecx+92h]
    mov     ecx, [eax+245h]
    test    ch, 4
    jz      short loc_48999C
    mov     eax, [esp+arg_0]
    mov     ecx, [eax+110h]
    and     ecx, 3
    cmp     cl, 2
    jz      short loc_48999C
    mov     edx, [eax+92h]
    mov     eax, [edx+245h]
    test    ah, 10h
    jnz     short loc_48999C
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48999C:                             ; CODE XREF: sub_489960+Fj
                                            ; sub_489960+21j ...
    xor     eax, eax
    retn    4
    sub_489960 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4899B0 proc near                    ; CODE XREF: .text:0040FE6Ep
                                            ; .text:0040FF0Ep ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    test    eax, eax
    push    edi
    jz      loc_489A61
    mov     esi, [ecx+92h]
    mov     ecx, [esi+245h]
    test    ch, 2
    jz      loc_489A61
    mov     edi, [eax+92h]
    movsx   ecx, word ptr [eax+108h]
    cmp     ecx, [edi+1FAh]
    jz      short loc_489A61
    mov     edx, [eax+110h]
    and     edx, 3
    cmp     dl, 2
    jz      short loc_489A61
    mov     ecx, [esi+241h]
    mov     ebp, TAdynmemStructPtr
    mov     edx, ecx
    and     edx, 800h
    jz      short loc_489A2F
    test    ecx, 200000h
    jnz     short loc_489A2F
    movsx   ecx, word ptr [eax+70h]
    movsx   ebx, word ptr [edi+170h]
    add     ecx, ebx
    xor     ebx, ebx
    mov     bl, [ebp+1427Fh]
    cmp     ecx, ebx
    jl      short loc_489A61

    loc_489A2F:                             ; CODE XREF: sub_4899B0+5Cj
                                            ; sub_4899B0+64j
    test    edx, edx
    jnz     short loc_489A55
    movsx   edx, word ptr [eax+70h]
    movsx   eax, word ptr [edi+170h]
    add     edx, eax
    xor     ecx, ecx
    movsx   eax, word ptr [esi+1BEh]
    mov     cl, [ebp+1427Fh]
    sub     ecx, eax
    cmp     edx, ecx
    jl      short loc_489A61

    loc_489A55:                             ; CODE XREF: sub_4899B0+81j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489A61:                             ; CODE XREF: sub_4899B0+Aj
                                            ; sub_4899B0+1Fj ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    4
    sub_4899B0 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     edx, [ecx+8Ah]
    xor     eax, eax
    test    edx, edx
    jz      short locret_489A8F

    loc_489A7C:                             ; CODE XREF: .text:00489A8Dj
    cmp     [edx+86h], ecx
    jnz     short loc_489A85
    inc     eax

    loc_489A85:                             ; CODE XREF: .text:00489A82j
    mov     edx, [edx+8Eh]
    test    edx, edx
    jnz     short loc_489A7C

    locret_489A8F:                          ; CODE XREF: .text:00489A7Aj
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489A90 proc near                    ; CODE XREF: sub_43E490+350p
                                            ; sub_43E490+61Fp ...

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    mov     esi, [ebx+92h]
    push    edi
    mov     eax, [esi+245h]
    shr     eax, 13h
    test    al, 1
    jz      short loc_489AB2
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489AB2:                             ; CODE XREF: sub_489A90+18j
    mov     edi, [ecx+92h]
    mov     eax, [edi+245h]
    test    ah, 1
    jnz     short loc_489ACB
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489ACB:                             ; CODE XREF: sub_489A90+31j
    mov     eax, [ecx+8Ah]
    xor     edx, edx
    test    eax, eax
    jz      short loc_489AEA

    loc_489AD7:                             ; CODE XREF: sub_489A90+58j
    cmp     [eax+86h], ecx
    jnz     short loc_489AE0
    inc     edx

    loc_489AE0:                             ; CODE XREF: sub_489A90+4Dj
    mov     eax, [eax+8Eh]
    test    eax, eax
    jnz     short loc_489AD7

    loc_489AEA:                             ; CODE XREF: sub_489A90+45j
    xor     ecx, ecx
    mov     cl, [edi+22Bh]
    cmp     edx, ecx
    jl      short loc_489AFE
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489AFE:                             ; CODE XREF: sub_489A90+64j
    cmp     dword ptr [ebx], 0
    jnz     short loc_489B0B
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489B0B:                             ; CODE XREF: sub_489A90+71j
    movzx   dx, byte ptr [edi+22Ah]
    cmp     [esi+14Ah], dx
    jle     short loc_489B24
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489B24:                             ; CODE XREF: sub_489A90+8Aj
    mov     eax, [ebx+110h]
    and     eax, 3
    cmp     al, 2
    jnz     short loc_489B39
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489B39:                             ; CODE XREF: sub_489A90+9Fj
    mov     eax, [edi+241h]
    test    ah, 8
    jnz     short loc_489B56
    cmp     word ptr [esi+1C0h], 0
    jl      short loc_489B56
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489B56:                             ; CODE XREF: sub_489A90+B2j
                                            ; sub_489A90+BCj
    mov     eax, TAdynmemStructPtr
    mov     ecx, [ebx+6Eh]
    mov     edi, [esi+16Eh]
    xor     edx, edx
    mov     dl, [eax+1427Fh]
    add     ecx, edi
    shl     edx, 10h
    cmp     ecx, edx
    jg      short loc_489B7D
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489B7D:                             ; CODE XREF: sub_489A90+E3j
    fld     dword ptr [ebx+104h]
    fcomp   ds:flt_4FD748
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_489B98
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489B98:                             ; CODE XREF: sub_489A90+FEj
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    retn    4
    sub_489A90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489BB0 proc near                    ; CODE XREF: .text:00402147p
                                            ; .text:00402701p ...

    idTo= dword ptr -0Ch
    var_7= word ptr -7
    var_5= byte ptr -5
    var_4= byte ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_11= byte ptr  15h

    sub     esp, 0Ch
    push    ebx
    mov     ebx, [esp+10h+arg_C]
    push    esi
    mov     esi, [esp+14h+arg_4]
    cmp     ebx, 0Ah
    push    edi
    jz      short loc_489C36
    mov     al, [esi+10Eh]
    mov     edi, [esp+18h+arg_8]
    test    al, 2
    jz      short loc_489BF3
    cmp     edi, 7530h
    jge     short loc_489BF3
    mov     eax, [esi+92h]
    mov     ecx, 10h
    mov     eax, [eax+1AAh]
    imul    edi
    call    __allshr
    mov     edi, eax

    loc_489BF3:                             ; CODE XREF: sub_489BB0+1Fj
                                            ; sub_489BB0+27j
    xor     ecx, ecx
    mov     eax, 66666667h
    mov     cx, [esi+0B8h]
    imul    ecx
    sar     edx, 1
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    cmp     edx, 5
    jle     short loc_489C16
    mov     edx, 5

    loc_489C16:                             ; CODE XREF: sub_489BB0+5Fj
    mov     ecx, 19h
    mov     eax, 51EB851Fh
    sub     ecx, edx
    imul    ecx, edi
    shl     ecx, 2
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    jmp     short loc_489C3A
    ; ---------------------------------------------------------------------------

    loc_489C36:                             ; CODE XREF: sub_489BB0+11j
    mov     edx, [esp+18h+arg_8]

    loc_489C3A:                             ; CODE XREF: sub_489BB0+84j
    test    esi, esi
    mov     byte ptr [esp+18h+idTo], 0Bh
    jnz     short loc_489C4A
    mov     word ptr [esp+18h+idTo+1], si
    jmp     short loc_489C56
    ; ---------------------------------------------------------------------------

    loc_489C4A:                             ; CODE XREF: sub_489BB0+91j
    mov     cx, [esi+0A8h]
    mov     word ptr [esp+18h+idTo+1], cx

    loc_489C56:                             ; CODE XREF: sub_489BB0+98j
    mov     edi, [esp+18h+arg_0]
    test    edi, edi
    jnz     short loc_489C65
    mov     word ptr [esp+18h+idTo+3], di
    jmp     short loc_489C71
    ; ---------------------------------------------------------------------------

    loc_489C65:                             ; CODE XREF: sub_489BB0+ACj
    mov     ax, [edi+0A8h]
    mov     word ptr [esp+18h+idTo+3], ax

    loc_489C71:                             ; CODE XREF: sub_489BB0+B3j
    mov     [esp+18h+var_7], dx
    xor     ecx, ecx
    mov     cl, [esp+18h+arg_11]
    lea     edx, [esp+18h+idTo]
    push    edx
    mov     [esp+1Ch+var_5], cl
    mov     [esp+1Ch+var_4], bl
    call    sub_489CE0
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_489CD2
    cmp     byte ptr [eax+73h], 3
    jnz     short loc_489CD2
    cmp     ebx, 0Bh
    jz      short loc_489CD2
    lea     eax, [esp+18h+idTo]
    push    9                               ; idFrom
    test    edi, edi
    push    eax                             ; idTo
    jz      short loc_489CC7
    mov     ecx, [edi+96h]
    mov     edx, [ecx+4]
    push    edx                             ; PlayerID
    call    sub_451DF0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0Ch
    retn    14h                             ; idTo
    ; ---------------------------------------------------------------------------

    loc_489CC7:                             ; CODE XREF: sub_489BB0+FDj
    call    sub_44FDB0
    push    eax                             ; PlayerID
    call    sub_451DF0

    loc_489CD2:                             ; CODE XREF: sub_489BB0+E7j
                                            ; sub_489BB0+EDj ...
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0Ch
    retn    14h
    sub_489BB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_489CE0 proc near                    ; CODE XREF: Network_Process+16D2p
                                            ; sub_489BB0+D9p

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     edx, TAdynmemStructPtr
    push    edi
    mov     edi, [esp+4+arg_0]
    mov     ax, [edi+1]
    test    ax, ax
    jnz     short loc_489CFA
    xor     esi, esi
    jmp     short loc_489D12
    ; ---------------------------------------------------------------------------

    loc_489CFA:                             ; CODE XREF: sub_489CE0+14j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*8]

    loc_489D12:                             ; CODE XREF: sub_489CE0+18j
    mov     ax, [edi+3]
    test    ax, ax
    jnz     short loc_489D1F
    xor     ebx, ebx
    jmp     short loc_489D37
    ; ---------------------------------------------------------------------------

    loc_489D1F:                             ; CODE XREF: sub_489CE0+39j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     ebx, [ecx+eax*8]

    loc_489D37:                             ; CODE XREF: sub_489CE0+3Dj
    test    esi, esi
    jz      loc_489F93
    mov     eax, [esi+110h]
    test    eax, 10000000h
    jz      loc_489F93
    test    ah, 40h
    jnz     loc_489F93
    cmp     byte ptr [edi+8], 0Ah
    jnz     short loc_489D8D
    movsx   eax, word ptr [esi+108h]
    mov     ecx, [esi+92h]
    xor     edx, edx
    mov     dx, [edi+5]
    mov     ecx, [ecx+1FAh]
    add     eax, edx
    cmp     eax, ecx
    jb      short loc_489D80
    mov     eax, ecx

    loc_489D80:                             ; CODE XREF: sub_489CE0+9Cj
    mov     [esi+108h], ax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489D8D:                             ; CODE XREF: sub_489CE0+7Dj
    push    esi
    call    sub_467950
    cmp     byte ptr [edi+8], 0Bh
    jz      short loc_489DA7
    xor     edx, edx
    mov     dx, [edi+5]
    push    edx
    push    esi
    push    ebx
    call    sub_406F80

    loc_489DA7:                             ; CODE XREF: sub_489CE0+B7j
    mov     al, [edi+8]
    test    ebx, ebx
    mov     [esi+0F5h], al
    jz      short loc_489DEB
    mov     cl, [ebx+0FFh]
    mov     [esi+0F0h], ebx
    mov     [esi+0F4h], cl
    mov     edx, TAdynmemStructPtr
    mov     cl, [ebx+0FFh]
    mov     al, [edx+2A42h]
    cmp     cl, al
    jz      short loc_489DE4
    cmp     [esi+0FFh], al
    jnz     short loc_489DEB

    loc_489DE4:                             ; CODE XREF: sub_489CE0+FAj
    push    1
    call    sub_494FF0

    loc_489DEB:                             ; CODE XREF: sub_489CE0+D2j
                                            ; sub_489CE0+102j
    cmp     byte ptr [edi+8], 2
    jnz     loc_489EB1
    mov     eax, [esi+110h]
    xor     ebx, ebx
    mov     bx, [edi+5]
    test    eax, 10000000h
    jz      loc_489F93
    test    ah, 40h
    jnz     loc_489F93
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      loc_489F93
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_489E33
    cmp     al, 2
    jnz     loc_489F93

    loc_489E33:                             ; CODE XREF: sub_489CE0+149j
    mov     eax, [esi+92h]
    test    dword ptr [eax+241h], 4000000h
    jnz     loc_489F93
    push    offset aParalyze                ; char *
    lea     ecx, [esp+8+arg_0]
    call    sub_438760
    mov     eax, [esi+5Ch]
    test    eax, eax
    jz      short loc_489E72
    mov     cl, [eax+4]
    mov     dl, byte ptr [esp+4+arg_0]
    cmp     cl, dl
    jnz     short loc_489E72
    add     [eax+36h], ebx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489E72:                             ; CODE XREF: sub_489CE0+17Cj
                                            ; sub_489CE0+187j
    push    56h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_489EA2
    mov     edx, [esp+4+arg_0]
    push    0
    push    0
    push    ebx
    push    0
    push    0
    push    edx
    mov     ecx, eax
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43ACB0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489EA2:                             ; CODE XREF: sub_489CE0+19Ej
    xor     eax, eax
    push    eax
    push    esi
    call    sub_43ACB0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489EB1:                             ; CODE XREF: sub_489CE0+10Fj
    mov     ax, [edi+5]
    sub     [esi+108h], ax
    cmp     word ptr [esi+108h], 0
    jg      short loc_489EFA
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_489EF1
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_489EDC
    cmp     al, 2
    jnz     short loc_489EF1

    loc_489EDC:                             ; CODE XREF: sub_489CE0+1F6j
    mov     eax, [esi+110h]
    or      ah, 40h
    mov     [esi+110h], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_489EF1:                             ; CODE XREF: sub_489CE0+1EFj
                                            ; sub_489CE0+1FAj
    mov     word ptr [esi+108h], 0

    loc_489EFA:                             ; CODE XREF: sub_489CE0+1E4j
    cmp     byte ptr [edi+8], 1
    jnz     loc_489F93
    xor     ecx, ecx
    push    190h
    mov     ch, [edi+7]
    push    ecx
    call    sub_4B7123
    add     esp, 8
    xor     edx, edx
    mov     dh, [edi+7]
    mov     ebx, eax
    push    190h
    push    edx
    call    sub_4B70EF
    add     esp, 8
    mov     ecx, [esi+9Ah]
    push    0
    push    0
    push    eax
    push    ebx
    push    2
    push    0
    push    0
    push    offset aHitbyweapon             ; "HitByWeapon"
    call    sub_4B0A70
    movsx   eax, word ptr [esi+108h]
    mov     ecx, [esi+92h]
    xor     edx, edx
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 2
    div     dword ptr [ecx+1FAh]
    test    eax, eax
    jge     short loc_489F6C
    xor     eax, eax

    loc_489F6C:                             ; CODE XREF: sub_489CE0+288j
    cmp     eax, 64h
    jle     short loc_489F76
    mov     eax, 64h

    loc_489F76:                             ; CODE XREF: sub_489CE0+28Fj
    mov     ecx, [esi+9Ah]
    push    0
    push    0
    push    0
    push    eax
    push    1
    push    0
    push    0
    push    offset aTakedamage              ; "TakeDamage"
    call    sub_4B0A70

    loc_489F93:                             ; CODE XREF: sub_489CE0+59j
                                            ; sub_489CE0+6Aj ...
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_489CE0 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+8]
    mov     eax, [esi+110h]
    test    eax, 10000000h
    jz      loc_48A056
    test    ah, 40h
    jnz     loc_48A056
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      loc_48A056
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_489FD9
    cmp     al, 2
    jnz     short loc_48A056

    loc_489FD9:                             ; CODE XREF: .text:00489FD3j
    mov     eax, [esi+92h]
    test    dword ptr [eax+241h], 4000000h
    jnz     short loc_48A056
    push    offset aParalyze                ; "paralyze"
    lea     ecx, [esp+0Ch]
    call    sub_438760
    mov     eax, [esi+5Ch]
    test    eax, eax
    jz      short loc_48A01B
    mov     cl, [eax+4]
    mov     dl, [esp+8]
    cmp     cl, dl
    jnz     short loc_48A01B
    mov     edx, [esp+0Ch]
    mov     ecx, [eax+36h]
    add     ecx, edx
    mov     [eax+36h], ecx
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48A01B:                             ; CODE XREF: .text:00489FFEj
                                            ; .text:0048A009j
    push    56h
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_48A04D
    mov     ecx, [esp+0Ch]
    mov     edx, [esp+8]
    push    0
    push    0
    push    ecx
    push    0
    push    0
    push    edx
    mov     ecx, eax
    call    sub_43A0C0
    push    eax
    push    esi
    call    sub_43ACB0
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48A04D:                             ; CODE XREF: .text:0048A027j
    xor     eax, eax
    push    eax
    push    esi
    call    sub_43ACB0

    loc_48A056:                             ; CODE XREF: .text:00489FB0j
                                            ; .text:00489FB9j ...
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A060 proc near                    ; CODE XREF: .text:004021BAp
                                            ; .text:004022A3p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    mov     edx, [esp+arg_4]
    mov     ecx, eax
    mov     dx, [edx+0A8h]
    shl     ecx, 3
    sub     ecx, eax
    mov     eax, [esp+arg_0]
    lea     ecx, [eax+ecx*4]
    mov     [ecx+4], dx
    mov     word ptr [ecx+6], 8000h
    and     word ptr [eax+0BAh], 83FFh
    retn    0Ch
    sub_48A060 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A0A0 proc near                    ; CODE XREF: .text:00403985p
                                            ; .text:004039B9p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    mov     edx, [esp+arg_0]
    mov     ecx, eax
    push    esi
    shl     ecx, 3
    sub     ecx, eax
    mov     eax, [esp+4+arg_4]
    mov     esi, [eax]
    lea     ecx, [edx+ecx*4+4]
    sar     esi, 10h
    mov     [ecx], si
    mov     eax, [eax+8]
    sar     eax, 10h
    cmp     ax, 8000h
    mov     [ecx+2], ax
    jnz     short loc_48A0D6
    mov     word ptr [ecx+2], 8001h

    loc_48A0D6:                             ; CODE XREF: sub_48A0A0+2Ej
    and     word ptr [edx+0BAh], 83FFh
    pop     esi
    retn    0Ch
    sub_48A0A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A0F0 proc near                    ; CODE XREF: sub_401C20+13p
                                            ; sub_401C20+1Bp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_4]
    mov     eax, esi
    push    edi
    mov     edi, [esp+4+arg_0]
    mov     ecx, 0FFFF8000h
    shl     eax, 3
    sub     eax, esi
    cmp     word ptr [edi+eax*4+4], 0
    lea     eax, [edi+eax*4+4]
    jnz     short loc_48A118
    cmp     [eax+2], cx
    jz      short loc_48A14E

    loc_48A118:                             ; CODE XREF: sub_48A0F0+20j
    mov     word ptr [eax], 0
    mov     [eax+2], cx
    mov     ecx, [edi+9Ah]
    push    offset aStartbuilding           ; "StartBuilding"
    call    sub_4B07C0
    mov     ecx, [edi+9Ah]
    push    0
    push    0
    push    0
    push    esi
    push    1
    push    0
    push    0
    push    offset aTargetcleared           ; "TargetCleared"
    call    sub_4B0A70

    loc_48A14E:                             ; CODE XREF: sub_48A0F0+26j
    pop     edi
    pop     esi
    retn    8
    sub_48A0F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A160 proc near                    ; CODE XREF: sub_485A40+210p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     edx, [esp+arg_0]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     eax, [edx+ecx*4+4]
    mov     word ptr [eax], 0
    mov     word ptr [eax+2], 8000h
    retn    8
    sub_48A160 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A190 proc near                    ; CODE XREF: .text:0040225Ep
                                            ; .text:0040644Fp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     edx, [esp+arg_0]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    cmp     word ptr [edx+ecx*4+6], 8000h
    lea     eax, [edx+ecx*4+4]
    jz      short loc_48A1B1
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48A1B1:                             ; CODE XREF: sub_48A190+1Aj
    mov     ax, [eax]
    test    ax, ax
    jnz     short loc_48A1BE
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48A1BE:                             ; CODE XREF: sub_48A190+27j
    movsx   ecx, ax
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [edx+eax*8]
    retn    8
    sub_48A190 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A1E0 proc near                    ; CODE XREF: sub_49E1A0+41p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    mov     edx, 0FFFF8000h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+18h+arg_8]
    mov     eax, esi
    push    edi
    mov     edi, [esp+1Ch+arg_0]
    shl     eax, 3
    sub     eax, esi
    cmp     [edi+eax*4+6], dx
    lea     ebx, [edi+eax*4+4]
    jz      short loc_48A268
    movsx   ecx, word ptr [ebx]
    mov     esi, [esp+1Ch+arg_4]
    xor     eax, eax
    shl     ecx, 10h
    mov     [esi], ecx
    push    esi
    movsx   edx, word ptr [ebx+2]
    shl     edx, 10h
    mov     [esi+8], edx
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+1427Fh]
    mov     edi, eax
    call    sub_485070
    cmp     eax, edi
    jle     short loc_48A251
    push    esi
    call    sub_485070
    shl     eax, 10h
    mov     [esi+4], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_48A251:                             ; CODE XREF: sub_48A1E0+54j
    mov     eax, edi
    shl     eax, 10h
    mov     [esi+4], eax
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_48A268:                             ; CODE XREF: sub_48A1E0+24j
    mov     ax, [ebx]
    test    ax, ax
    jnz     short loc_48A27C
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_48A27C:                             ; CODE XREF: sub_48A1E0+8Ej
    movsx   ecx, ax
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*8+0A6h], 0
    lea     ebp, [ecx+eax*8]
    jnz     short loc_48A2F1
    cmp     word ptr [ebx], 0
    jnz     short loc_48A2AF
    cmp     [ebx+2], dx
    jz      short loc_48A2E5

    loc_48A2AF:                             ; CODE XREF: sub_48A1E0+C7j
    mov     word ptr [ebx], 0
    mov     [ebx+2], dx
    mov     ecx, [edi+9Ah]
    push    offset aStartbuilding           ; "StartBuilding"
    call    sub_4B07C0
    mov     ecx, [edi+9Ah]
    push    0
    push    0
    push    0
    push    esi
    push    1
    push    0
    push    0
    push    offset aTargetcleared           ; "TargetCleared"
    call    sub_4B0A70

    loc_48A2E5:                             ; CODE XREF: sub_48A1E0+CDj
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_48A2F1:                             ; CODE XREF: sub_48A1E0+C1j
    mov     esi, [esp+1Ch+arg_4]
    push    esi
    push    ebp
    call    sub_43E3C0
    test    byte ptr [ebx+1Bh], 2
    jz      loc_48A42D
    mov     ebx, [ebx+0Ch]
    test    dword ptr [ebx+111h], 2000000h
    jnz     loc_48A42D
    mov     ebp, [ebp+0]
    test    ebp, ebp
    jz      loc_48A42D
    cmp     word ptr [edi+0B8h], 5
    jbe     loc_48A42D
    mov     ebx, [ebx+68h]
    test    ebx, ebx
    jz      loc_48A42D
    mov     eax, [esi]
    mov     edx, [edi+6Ah]
    mov     ecx, [edi+6Eh]
    sub     edx, eax
    mov     eax, [esi+4]
    mov     [esp+1Ch+var_C], edx
    mov     edx, [edi+72h]
    sub     ecx, eax
    mov     eax, [esi+8]
    mov     [esp+1Ch+var_8], ecx
    fild    [esp+1Ch+var_C]
    fild    [esp+1Ch+var_8]
    sub     edx, eax
    mov     [esp+1Ch+var_4], edx
    fild    [esp+1Ch+var_4]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    cdq
    fstp    st
    mov     ecx, 10h
    call    __allshl
    mov     ecx, eax
    mov     eax, ebx
    mov     edi, edx
    cdq
    push    edx
    push    eax
    push    edi
    push    ecx
    call    __alldiv
    cdq
    push    0
    push    0CCCCh
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    cdq
    mov     edi, eax
    mov     eax, [ebp+8]
    mov     ebx, edx
    cdq
    push    ebx
    push    edi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esp+1Ch+var_C], eax
    mov     eax, [ebp+0Ch]
    cdq
    push    ebx
    push    edi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     [esp+1Ch+var_8], eax
    mov     eax, [ebp+10h]
    cdq
    push    ebx
    push    edi
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     ecx, [esi]
    mov     edx, [esp+1Ch+var_C]
    add     edx, ecx
    mov     ecx, [esi+4]
    mov     [esi], edx
    mov     edx, [esp+1Ch+var_8]
    add     edx, ecx
    mov     ecx, [esi+8]
    add     eax, ecx
    mov     [esi+4], edx
    mov     [esi+8], eax

    loc_48A42D:                             ; CODE XREF: sub_48A1E0+120j
                                            ; sub_48A1E0+133j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_48A1E0 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     edx, [esp+8]
    push    ebx
    push    esi
    xor     ecx, ecx
    push    edi
    add     eax, 4
    mov     esi, 0FFFF8000h

    loc_48A455:                             ; CODE XREF: .text:0048A472j
    cmp     [eax+2], si
    jnz     short loc_48A46B
    movsx   ebx, word ptr [eax]
    xor     edi, edi
    mov     di, [edx+0A8h]
    cmp     ebx, edi
    jz      short loc_48A47C

    loc_48A46B:                             ; CODE XREF: .text:0048A459j
    inc     ecx
    add     eax, 1Ch
    cmp     ecx, 3
    jl      short loc_48A455
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48A47C:                             ; CODE XREF: .text:0048A469j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A490 proc near                    ; CODE XREF: sub_48A870+FAp

    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_34= dword ptr -34h
    var_2C= dword ptr -2Ch
    var_20= dword ptr -20h
    var_14= dword ptr -14h
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 7Ch
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     edx, [ecx+14377h]
    push    edi
    mov     edi, [esp+8Ch+arg_0]
    xor     eax, eax
    mov     ax, [edi+0A6h]
    mov     edx, [edx+eax*4]
    mov     [esp+8Ch+var_68], edx
    mov     ecx, [edx+0Ch]
    mov     eax, [edx+28h]
    mov     esi, ecx
    shl     esi, 5
    add     eax, esi
    test    ecx, ecx
    mov     [esp+8Ch+var_6C], eax
    jl      loc_48A7DF
    lea     ecx, [esp+8Ch+var_2C]
    mov     [esp+8Ch+var_7C], 0
    mov     [esp+8Ch+var_70], ecx
    lea     ecx, [esp+8Ch+var_4C]
    mov     [esp+8Ch+var_74], ecx
    jmp     short loc_48A4F5
    ; ---------------------------------------------------------------------------

    loc_48A4ED:                             ; CODE XREF: sub_48A490+2CDj
    mov     eax, [esp+8Ch+var_6C]
    mov     edx, [esp+8Ch+var_68]

    loc_48A4F5:                             ; CODE XREF: sub_48A490+5Bj
    mov     esi, [eax+0Ch]
    mov     ebx, [esp+8Ch+var_7C]
    mov     edx, [edx+24h]
    xor     eax, eax
    mov     ax, [esi+ebx*2]
    lea     eax, [eax+eax*2]
    lea     eax, [edx+eax*4]
    mov     edx, [eax]
    mov     [esp+8Ch+var_58], edx
    mov     eax, [eax+8]
    mov     [ecx-4], edx
    mov     [esp+8Ch+var_54], eax
    mov     [ecx], eax
    mov     cx, [edi+66h]
    lea     eax, [esp+8Ch+var_58]
    push    eax
    push    ecx
    call    sub_4B7173
    mov     edx, [esp+94h+var_58]
    mov     ebx, [edi+6Ah]
    mov     eax, [edi+72h]
    add     edx, ebx
    sar     edx, 10h
    movsx   ebp, dx
    mov     edx, [esp+94h+var_54]
    mov     esi, ebp
    sub     eax, edx
    mov     edx, ebp
    sar     eax, 10h
    movsx   ecx, ax
    mov     [esp+94h+var_5C], ecx
    mov     eax, ecx
    and     ecx, 0Fh
    add     esp, 8
    mov     [esp+8Ch+var_78], ecx
    mov     ecx, TAdynmemStructPtr
    shr     edx, 4
    mov     ecx, [ecx+14233h]
    and     esi, 0Fh
    shr     eax, 4
    lea     ebx, [ecx-1]
    cmp     edx, ebx
    jnb     loc_48A7DF
    mov     ebx, TAdynmemStructPtr
    mov     ebx, [ebx+14237h]
    dec     ebx
    cmp     eax, ebx
    jnb     loc_48A7DF
    imul    eax, ecx
    add     eax, edx
    lea     edx, [eax+eax*2]
    lea     eax, [eax+edx*4]
    mov     edx, TAdynmemStructPtr
    mov     ebx, [edx+14287h]
    lea     edx, [ecx+ecx*2]
    add     eax, ebx
    xor     ebx, ebx
    add     ecx, eax
    mov     bl, [eax+4]
    lea     ecx, [ecx+edx*4]
    xor     edx, edx
    mov     [esp+8Ch+var_64], ecx
    mov     dl, [ecx+4]
    xor     ecx, ecx
    mov     cl, [eax+11h]
    mov     [esp+8Ch+var_60], edx
    mov     eax, ecx
    sub     eax, ebx
    imul    eax, esi
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     edx, [esp+8Ch+var_64]
    mov     ecx, eax
    xor     eax, eax
    mov     al, [edx+11h]
    sar     ecx, 4
    add     ecx, ebx
    mov     ebx, [esp+8Ch+var_60]
    sub     eax, ebx
    imul    eax, esi
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     edx, [edi+92h]
    sar     eax, 4
    mov     esi, [edx+241h]
    add     eax, ebx
    mov     ebx, [esp+8Ch+var_70]
    test    esi, 1000h
    mov     [ebx-4], ebp
    jz      loc_48A724
    mov     edx, [edi+110h]
    test    edx, 10000000h
    jz      loc_48A724
    test    dh, 40h
    jnz     loc_48A724
    sub     eax, ecx
    imul    eax, [esp+8Ch+var_78]
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     edx, TAdynmemStructPtr
    sar     eax, 4
    add     ecx, eax
    xor     eax, eax
    mov     al, [edx+1427Fh]
    mov     [ebx], ecx
    cmp     ecx, eax
    mov     [esp+8Ch+var_78], ecx
    jg      short loc_48A664
    mov     [esp+8Ch+var_78], eax

    loc_48A664:                             ; CODE XREF: sub_48A490+1CEj
    mov     eax, [esp+8Ch+var_78]
    mov     [ebx], eax
    call    sub_4B6340
    mov     ecx, [esp+8Ch+var_7C]
    and     eax, 1Fh
    mov     edx, [edi+92h]
    mov     ebp, [edi]
    lea     eax, [eax+ecx*8]
    shl     eax, 0Bh
    add     ax, [edi+0AAh]
    mov     [esp+8Ch+var_64], eax
    mov     eax, [edx+192h]
    cdq
    sub     eax, edx
    mov     esi, eax
    mov     eax, [ebp+20h]
    sar     esi, 1
    cmp     eax, esi
    jl      short loc_48A6A5
    mov     eax, esi

    loc_48A6A5:                             ; CODE XREF: sub_48A490+211j
    cdq
    mov     ecx, 10h
    call    __allshl
    mov     ecx, eax
    mov     eax, esi
    mov     [esp+8Ch+var_60], ecx
    mov     ecx, edx
    cdq
    push    edx
    mov     edx, [esp+90h+var_60]
    push    eax
    push    ecx
    push    edx
    call    __alldiv
    cdq
    push    0
    push    2
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     esi, [ebp+2Ah]
    mov     ecx, 2
    sub     ecx, eax
    mov     eax, TAdynmemStructPtr
    mov     eax, [eax+38A47h]
    sub     eax, esi
    cmp     eax, 3Ch
    jb      short loc_48A6FF
    mov     eax, 3Ch

    loc_48A6FF:                             ; CODE XREF: sub_48A490+268j
    mov     edx, ecx
    imul    edx, eax
    mov     eax, 88888889h
    mul     edx
    mov     eax, [esp+8Ch+var_64]
    shr     edx, 5
    sub     ecx, edx
    push    ecx
    push    eax
    call    sub_4B7123
    mov     ecx, [esp+94h+var_78]
    add     esp, 8
    jmp     short loc_48A734
    ; ---------------------------------------------------------------------------

    loc_48A724:                             ; CODE XREF: sub_48A490+185j
                                            ; sub_48A490+197j ...
    sub     eax, ecx
    imul    eax, [esp+8Ch+var_78]
    cdq
    and     edx, 0Fh
    add     eax, edx
    sar     eax, 4

    loc_48A734:                             ; CODE XREF: sub_48A490+292j
    add     eax, ecx
    mov     ecx, [esp+8Ch+var_5C]
    mov     [ebx], eax
    mov     eax, [esp+8Ch+var_7C]
    mov     [ebx+4], ecx
    mov     ecx, [esp+8Ch+var_74]
    inc     eax
    add     ecx, 8
    add     ebx, 0Ch
    cmp     eax, 4
    mov     [esp+8Ch+var_7C], eax
    mov     [esp+8Ch+var_74], ecx
    mov     [esp+8Ch+var_70], ebx
    jl      loc_48A4ED
    mov     ebx, [esp+8Ch+var_2C]
    mov     ebp, [esp+8Ch+var_20]
    lea     eax, [ebx+ebp]
    cdq
    sub     eax, edx
    mov     edx, [esp+8Ch+var_14]
    mov     esi, eax
    mov     eax, [esp+8Ch+var_8]
    add     eax, edx
    cdq
    sub     eax, edx
    mov     ecx, eax
    sar     esi, 1
    sar     ecx, 1
    lea     eax, [ecx+esi]
    sub     ecx, esi
    cdq
    sub     eax, edx
    mov     edx, [esp+8Ch+var_34]
    sar     eax, 1
    mov     [edi+70h], ax
    mov     eax, [esp+8Ch+var_4C]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    sar     eax, 10h
    movsx   edx, ax
    push    edx
    push    ecx
    call    sub_4B715A
    mov     edx, [esp+94h+var_48]
    mov     [edi+68h], ax
    mov     eax, [esp+94h+var_50]
    add     esp, 8
    sub     eax, edx
    sub     ebx, ebp
    cdq
    xor     eax, edx
    sub     eax, edx
    sar     eax, 10h
    movsx   eax, ax
    push    eax
    push    ebx
    call    sub_4B715A
    add     esp, 8
    mov     [edi+64h], ax

    loc_48A7DF:                             ; CODE XREF: sub_48A490+3Dj
                                            ; sub_48A490+E8j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7Ch
    retn    4
    sub_48A490 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    edi
    mov     edi, [esp+8]
    mov     eax, [edi+92h]
    mov     ecx, [eax+241h]
    shr     ecx, 0Ch
    test    cl, 1
    jz      short loc_48A857
    mov     eax, TAdynmemStructPtr
    mov     ecx, [edi+92h]
    xor     edx, edx
    push    esi
    mov     dl, [eax+1427Fh]
    push    ebx
    xor     eax, eax
    lea     ebx, [edi+6Ah]
    mov     al, [ecx+22Ch]
    mov     esi, edx
    push    ebx
    sub     esi, eax
    call    sub_485070
    cmp     eax, esi
    jle     short loc_48A849
    push    ebx
    call    sub_485070
    shl     eax, 10h
    pop     ebx
    mov     [edi+6Eh], eax
    pop     esi
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48A849:                             ; CODE XREF: .text:0048A835j
    mov     eax, esi
    pop     ebx
    shl     eax, 10h
    mov     [edi+6Eh], eax
    pop     esi
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48A857:                             ; CODE XREF: .text:0048A807j
    lea     ecx, [edi+6Ah]
    push    ecx
    call    sub_485070
    shl     eax, 10h
    mov     [edi+6Eh], eax
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A870 proc near                    ; CODE XREF: sub_485F50+1B9p
                                            ; sub_4861D0+136p ...

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+110h]
    test    eax, 10000h
    jnz     short loc_48A899
    mov     ecx, [esi+92h]
    mov     edx, [ecx+241h]
    test    dh, 10h
    jz      loc_48A96F

    loc_48A899:                             ; CODE XREF: sub_48A870+12j
    mov     ecx, [esi]
    and     eax, 0FFFEFFFFh
    test    ecx, ecx
    mov     [esi+110h], eax
    jz      loc_48A96F
    and     eax, 3
    cmp     al, 1
    jnz     loc_48A96F
    mov     ecx, [esi+92h]
    mov     eax, [ecx+241h]
    mov     edx, eax
    shr     edx, 14h
    test    dl, 1
    jz      short loc_48A938
    shr     eax, 0Ch
    test    al, 1
    jz      short loc_48A923
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esi+92h]
    xor     eax, eax
    lea     ebx, [esi+6Ah]
    mov     al, [ecx+1427Fh]
    xor     ecx, ecx
    mov     cl, [edx+22Ch]
    mov     edi, eax
    push    ebx
    sub     edi, ecx
    call    sub_485070
    cmp     eax, edi
    jle     short loc_48A915
    push    ebx
    call    sub_485070
    shl     eax, 10h
    mov     [esi+6Eh], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48A915:                             ; CODE XREF: sub_48A870+91j
    mov     eax, edi
    shl     eax, 10h
    mov     [esi+6Eh], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48A923:                             ; CODE XREF: sub_48A870+64j
    lea     edx, [esi+6Ah]
    push    edx
    call    sub_485070
    shl     eax, 10h
    mov     [esi+6Eh], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48A938:                             ; CODE XREF: sub_48A870+5Dj
    shr     eax, 13h
    test    al, 1
    jz      short loc_48A969
    xor     eax, eax
    xor     edx, edx
    mov     al, [ecx+22Ch]
    mov     ecx, eax
    shl     ecx, 10h
    sub     ecx, eax
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+1427Fh]
    add     ecx, edx
    shl     ecx, 10h
    mov     [esi+6Eh], ecx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48A969:                             ; CODE XREF: sub_48A870+CDj
    push    esi
    call    sub_48A490

    loc_48A96F:                             ; CODE XREF: sub_48A870+23j
                                            ; sub_48A870+38j ...
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_48A870 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A980 proc near                    ; CODE XREF: sub_403621+68p
                                            ; .text:00403DD5p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    push    esi
    mov     edx, [eax+8]
    mov     esi, [ecx+8]
    mov     eax, [eax]
    sub     edx, esi
    push    edx
    mov     edx, [ecx]
    sub     eax, edx
    push    eax
    call    sub_4B715A
    add     esp, 8
    pop     esi
    retn    8
    sub_48A980 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    mov     edx, [esp+8]
    push    esi
    mov     eax, [ecx]
    mov     esi, [edx]
    mov     ecx, [ecx+8]
    sub     eax, esi
    sub     ecx, [edx+8]
    test    eax, eax
    jnz     short loc_48A9D6
    test    ecx, ecx
    jnz     short loc_48A9D6
    mov     ax, [esp+10h]
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_48A9D6:                             ; CODE XREF: .text:0048A9C7j
                                            ; .text:0048A9CBj
    push    ecx
    push    eax
    call    sub_4B715A
    add     esp, 8
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48A9F0 proc near                    ; CODE XREF: .text:00406BC0p
                                            ; sub_43D6D0+A5p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+10h+arg_0]
    mov     ebx, [esp+10h+arg_4]
    mov     ebp, [esp+10h+arg_C]
    mov     eax, [esi+7Eh]
    push    edi
    mov     [esp+14h+var_4], eax
    mov     edi, [esp+14h+arg_10]
    movsx   edx, word ptr [esp+14h+var_4+2]
    movsx   eax, ax
    shl     eax, 13h
    mov     ecx, eax
    mov     eax, ebx
    sub     eax, ecx
    mov     ecx, ebp
    shl     edx, 13h
    sub     ecx, edx
    add     eax, 80000h
    add     ecx, 80000h
    sar     eax, 14h
    sar     ecx, 14h
    cmp     ax, [esi+76h]
    mov     word ptr [esp+14h+arg_0], ax
    mov     word ptr [esp+14h+arg_0+2], cx
    jnz     short loc_48AA6A
    cmp     cx, [esi+78h]
    jnz     short loc_48AA6A
    mov     eax, [esi+110h]
    and     eax, 3
    cmp     edi, eax
    jnz     short loc_48AA6A
    mov     edx, [esp+14h+arg_8]
    lea     ecx, [esi+6Ah]
    mov     [esi+6Ah], ebx
    mov     [ecx+4], edx
    mov     [ecx+8], ebp
    jmp     short loc_48AAA5
    ; ---------------------------------------------------------------------------

    loc_48AA6A:                             ; CODE XREF: sub_48A9F0+53j
                                            ; sub_48A9F0+59j ...
    push    esi
    call    sub_47D0E0
    lea     eax, [esi+6Ah]
    and     edi, 3
    mov     ecx, [esp+14h+arg_8]
    mov     edx, [esp+14h+arg_0]
    mov     [eax], ebx
    push    esi
    mov     [esi+76h], edx
    mov     [eax+4], ecx
    mov     [eax+8], ebp
    mov     eax, [esi+110h]
    and     al, 0FCh
    or      edi, eax
    mov     [esi+110h], edi
    call    sub_47CC30
    push    esi
    call    sub_4827B0

    loc_48AAA5:                             ; CODE XREF: sub_48A9F0+78j
    mov     eax, [esi+110h]
    pop     edi
    or      eax, 10000h
    mov     [esi+110h], eax
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    14h
    sub_48A9F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48AAC0 proc near                    ; CODE XREF: .text:00402948p
                                            ; GameUnit_EndTransport+21p ...

    idTo= dword ptr -8
    var_3= byte ptr -3
    var_2= byte ptr -2
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch
    arg_C= byte ptr  10h

    mov     ecx, [esp+arg_0]
    sub     esp, 8
    mov     eax, [ecx+110h]
    test    eax, 10000000h
    jz      loc_48AB67
    test    eax, 20000000h
    jnz     loc_48AB67
    mov     eax, [ecx+8Ah]
    xor     edx, edx
    cmp     eax, edx
    jnz     short loc_48AB67
    mov     eax, [esp+8+arg_4]
    cmp     eax, edx
    jz      short loc_48AB0F
    test    dword ptr [eax+110h], 10000000h
    jz      short loc_48AB67
    cmp     eax, ecx
    jz      short loc_48AB67
    cmp     [eax+86h], edx
    jnz     short loc_48AB67

    loc_48AB0F:                             ; CODE XREF: sub_48AAC0+35j
    cmp     ecx, edx
    mov     byte ptr [esp+8+idTo], 0Ah
    jnz     short loc_48AB1F
    mov     word ptr [esp+8+idTo+1], dx
    jmp     short loc_48AB2B
    ; ---------------------------------------------------------------------------

    loc_48AB1F:                             ; CODE XREF: sub_48AAC0+56j
    mov     cx, [ecx+0A8h]
    mov     word ptr [esp+8+idTo+1], cx

    loc_48AB2B:                             ; CODE XREF: sub_48AAC0+5Dj
    cmp     eax, edx
    jz      short loc_48AB36
    mov     dx, [eax+0A8h]

    loc_48AB36:                             ; CODE XREF: sub_48AAC0+6Dj
    mov     al, [esp+8+arg_8]
    mov     cl, [esp+8+arg_C]
    mov     word ptr [esp+8+idTo+3], dx
    lea     edx, [esp+8+idTo]
    push    7                               ; idFrom
    push    edx                             ; idTo
    mov     [esp+10h+var_3], al
    mov     [esp+10h+var_2], cl
    call    sub_44FDB0
    push    eax                             ; PlayerID
    call    sub_451DF0
    lea     eax, [esp+8+idTo]
    push    eax
    call    sub_48AB70

    loc_48AB67:                             ; CODE XREF: sub_48AAC0+12j
                                            ; sub_48AAC0+1Dj ...
    add     esp, 8
    retn    10h
    sub_48AAC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48AB70 proc near                    ; CODE XREF: Network_Process+16C3p
                                            ; sub_48AAC0+A2p ...

    arg_0= dword ptr  4

    mov     edx, TAdynmemStructPtr
    push    ebp
    mov     ebp, [esp+4+arg_0]
    push    esi
    push    edi
    mov     ax, [ebp+1]
    test    ax, ax
    jnz     short loc_48AB8A
    xor     esi, esi
    jmp     short loc_48ABA2
    ; ---------------------------------------------------------------------------

    loc_48AB8A:                             ; CODE XREF: sub_48AB70+14j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*8]

    loc_48ABA2:                             ; CODE XREF: sub_48AB70+18j
    mov     ax, [ebp+3]
    test    ax, ax
    jnz     short loc_48ABAF
    xor     edi, edi
    jmp     short loc_48ABC7
    ; ---------------------------------------------------------------------------

    loc_48ABAF:                             ; CODE XREF: sub_48AB70+39j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     edi, [ecx+eax*8]

    loc_48ABC7:                             ; CODE XREF: sub_48AB70+3Dj
    test    esi, esi
    jz      loc_48AD2A
    mov     eax, [esi+110h]
    test    eax, 10000000h
    jz      loc_48AD2A
    test    eax, 20000000h
    jnz     loc_48AD2A
    mov     eax, [esi+8Ah]
    test    eax, eax
    jnz     loc_48AD2A
    test    edi, edi
    jz      short loc_48AC23
    test    dword ptr [edi+110h], 10000000h
    jz      loc_48AD2A
    cmp     edi, esi
    jz      loc_48AD2A
    mov     eax, [edi+86h]
    test    eax, eax
    jnz     loc_48AD2A

    loc_48AC23:                             ; CODE XREF: sub_48AB70+8Bj
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_48AC57
    lea     ecx, [eax+8Ah]
    mov     eax, [eax+8Ah]
    cmp     eax, esi
    jz      short loc_48AC4D

    loc_48AC3D:                             ; CODE XREF: sub_48AB70+DBj
    lea     ecx, [eax+8Eh]
    mov     eax, [eax+8Eh]
    cmp     eax, esi
    jnz     short loc_48AC3D

    loc_48AC4D:                             ; CODE XREF: sub_48AB70+CBj
    mov     edx, [esi+8Eh]
    mov     [ecx], edx
    jmp     short loc_48AC63
    ; ---------------------------------------------------------------------------

    loc_48AC57:                             ; CODE XREF: sub_48AB70+BBj
    mov     ecx, [esi+82h]
    push    esi
    call    sub_47CB00

    loc_48AC63:                             ; CODE XREF: sub_48AB70+E5j
    mov     al, [ebp+5]
    test    edi, edi
    mov     [esi+0F9h], al
    jz      short loc_48ACAF
    mov     [esi+86h], edi
    mov     ecx, [edi+8Ah]
    mov     [esi+8Eh], ecx
    mov     [edi+8Ah], esi
    mov     edx, [esi+110h]
    mov     cl, [ebp+5]
    and     edx, 0FFFDFFFFh
    xor     eax, eax
    cmp     cl, 0FFh
    setz    al
    and     eax, 1
    shl     eax, 11h
    or      edx, eax
    mov     [esi+110h], edx
    jmp     short loc_48ACE1
    ; ---------------------------------------------------------------------------

    loc_48ACAF:                             ; CODE XREF: sub_48AB70+FEj
    mov     ecx, [esi+110h]
    push    esi
    and     ecx, 0FFFDFFFFh
    mov     dword ptr [esi+8Eh], 0
    mov     [esi+110h], ecx
    mov     ecx, [esi+82h]
    mov     dword ptr [esi+86h], 0
    call    sub_47CB40

    loc_48ACE1:                             ; CODE XREF: sub_48AB70+13Dj
    mov     eax, [esi]
    mov     dl, [ebp+6]
    mov     cl, [eax+2Eh]
    xor     dl, cl
    and     dl, 3
    xor     dl, cl
    mov     [eax+2Eh], dl
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_48AD24
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_48AD09
    cmp     al, 2
    jnz     short loc_48AD24

    loc_48AD09:                             ; CODE XREF: sub_48AB70+193j
    test    edi, edi
    jz      short loc_48AD24
    mov     eax, [edi+92h]
    mov     ecx, [eax+241h]
    test    ch, 2
    jnz     short loc_48AD24
    push    esi
    call    sub_4384A0

    loc_48AD24:                             ; CODE XREF: sub_48AB70+18Cj
                                            ; sub_48AB70+197j ...
    push    esi
    call    sub_48C9B0

    loc_48AD2A:                             ; CODE XREF: sub_48AB70+59j
                                            ; sub_48AB70+6Aj ...
    pop     edi
    pop     esi
    pop     ebp
    retn    4
    sub_48AB70 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48AD30 proc near                    ; CODE XREF: .text:004954EDp

    var_24= dword ptr -24h
    var_D= byte ptr -0Dh
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 10h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    lea     ebx, [eax+14353h]
    xor     al, al
    cmp     al, 0Ah
    push    edi
    mov     [esp+20h+var_8], ebx
    mov     dword ptr [ebx], 0
    mov     [esp+20h+var_D], al
    mov     [esp+20h+var_C], 0
    jnb     loc_48B008

    loc_48AD62:                             ; CODE XREF: sub_48AD30+2F2j
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+20h+var_C]            ; int
    mov     eax, [ecx+edx+1B63h]
    lea     edi, [ecx+edx+1B63h]
    test    eax, eax
    jz      loc_48B008
    mov     al, [edi+73h]
    cmp     al, 1
    jz      short loc_48AD95
    cmp     al, 2
    jz      short loc_48AD95
    cmp     al, 3
    jnz     loc_48B008

    loc_48AD95:                             ; CODE XREF: sub_48AD30+57j
                                            ; sub_48AD30+5Bj
    cmp     byte ptr [edi+146h], 0Ah
    jz      loc_48B008
    mov     ebp, [edi+6Bh]
    mov     esi, [edi+67h]
    cmp     esi, ebp
    ja      loc_48AFE4

    loc_48ADB0:                             ; CODE XREF: sub_48AD30+2AEj
    cmp     word ptr [esi+0A6h], 0
    jz      loc_48AFD6
    mov     edx, [ebx]                      ; int
    push    esi
    inc     edx
    mov     [ebx], edx
    call    sub_437910
    cmp     dword ptr [edi], 0
    jz      short loc_48ADDF
    mov     al, [edi+73h]
    cmp     al, 1
    jz      short loc_48ADD9
    cmp     al, 2
    jnz     short loc_48ADDF

    loc_48ADD9:                             ; CODE XREF: sub_48AD30+A3j
    push    esi
    call    sub_49E1A0

    loc_48ADDF:                             ; CODE XREF: sub_48AD30+9Cj
                                            ; sub_48AD30+A7j
    mov     ecx, [esi+9Ah]                  ; int
    test    ecx, ecx
    jz      short loc_48ADF0
    push    1                               ; int
    call    sub_4B0D60

    loc_48ADF0:                             ; CODE XREF: sub_48AD30+B7j
    mov     al, [esi+0FAh]
    test    al, al
    jz      short loc_48AE02
    dec     al
    mov     [esi+0FAh], al

    loc_48AE02:                             ; CODE XREF: sub_48AD30+C8j
    mov     eax, [esi+0FBh]
    test    eax, eax
    jz      short loc_48AE13
    dec     eax
    mov     [esi+0FBh], eax

    loc_48AE13:                             ; CODE XREF: sub_48AD30+DAj
    mov     ecx, [esi+110h]
    test    cl, 10h
    jz      short loc_48AE5F
    test    cl, 20h
    jz      short loc_48AE56
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FD748
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48AE56
    mov     eax, [esi+0FBh]
    test    eax, eax
    jnz     short loc_48AE56
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_48AE5F
    test    dword ptr [eax+110h], 40000000h
    jnz     short loc_48AE5F

    loc_48AE56:                             ; CODE XREF: sub_48AD30+F1j
                                            ; sub_48AD30+104j ...
    and     ecx, 0FFFFFFEFh
    mov     [esi+110h], ecx

    loc_48AE5F:                             ; CODE XREF: sub_48AD30+ECj
                                            ; sub_48AD30+118j ...
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     ecx, 1Eh
    mov     eax, [eax+38A47h]
    div     ecx
    test    edx, edx
    jnz     short loc_48AEB5
    movsx   eax, word ptr [esi+108h]
    mov     ecx, [esi+92h]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 2
    div     dword ptr [ecx+1FAh]
    test    eax, eax
    jge     short loc_48AE99
    xor     eax, eax

    loc_48AE99:                             ; CODE XREF: sub_48AD30+165j
    cmp     eax, 64h
    jle     short loc_48AEA3
    mov     eax, 64h

    loc_48AEA3:                             ; CODE XREF: sub_48AD30+16Cj
    mov     dl, [esi+0F6h]
    mov     [esi+0F6h], al
    mov     [esi+0F7h], dl

    loc_48AEB5:                             ; CODE XREF: sub_48AD30+145j
    mov     eax, [esi+96h]
    cmp     dword ptr [eax], 0
    jz      loc_48AFB9
    mov     al, [eax+73h]
    cmp     al, 1
    jz      short loc_48AED3
    cmp     al, 2
    jnz     loc_48AFB9

    loc_48AED3:                             ; CODE XREF: sub_48AD30+199j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391E9h]
    mov     ecx, [eax+0D4Ch]
    test    ecx, ecx
    jz      short loc_48AF37
    mov     ecx, [eax+0D50h]
    test    ecx, ecx
    jz      short loc_48AF37
    mov     eax, [edx+38A47h]
    xor     edx, edx
    mov     ebx, 1Eh
    div     ebx
    test    edx, edx
    jnz     short loc_48AF37
    mov     eax, TAdynmemStructPtr
    movzx   dx, byte ptr [eax+1427Fh]
    cmp     [esi+70h], dx
    jg      short loc_48AF37
    mov     eax, [esi+92h]
    mov     edx, [eax+241h]
    test    dh, 10h
    jnz     short loc_48AF37
    push    0
    push    0Bh
    push    ecx
    push    esi
    push    0
    call    sub_489BB0

    loc_48AF37:                             ; CODE XREF: sub_48AD30+1B7j
                                            ; sub_48AD30+1C1j ...
    mov     ecx, [esi+92h]
    mov     ax, [ecx+200h]
    test    ax, ax
    jz      short loc_48AF97
    movsx   edx, word ptr [esi+108h]
    cmp     edx, [ecx+1FAh]
    jnb     short loc_48AF97
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+38A47h], 7
    jnz     short loc_48AF97
    and     eax, 0FFFFh
    shl     eax, 3
    mov     ecx, eax
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    push    ecx
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [esp+24h+var_4], edx
    fild    [esp+24h+var_4]
    fstp    [esp+24h+var_24]
    push    esi
    push    esi
    call    sub_41BD10

    loc_48AF97:                             ; CODE XREF: sub_48AD30+217j
                                            ; sub_48AD30+226j ...
    push    esi
    call    sub_43B7C0
    push    esi
    call    sub_43BAD0
    mov     ecx, [esi]
    test    ecx, ecx
    jz      short loc_48AFB5
    push    esi
    call    sub_43DD20
    push    esi
    call    sub_48A870

    loc_48AFB5:                             ; CODE XREF: sub_48AD30+277j
    mov     ebx, [esp+20h+var_8]

    loc_48AFB9:                             ; CODE XREF: sub_48AD30+18Ej
                                            ; sub_48AD30+19Dj
    mov     ecx, [esi+110h]
    shr     ecx, 0Eh
    test    cl, 1
    jz      short loc_48AFD6
    xor     edx, edx
    mov     dl, [esi+0F5h]
    push    edx
    push    esi
    call    sub_4864B0

    loc_48AFD6:                             ; CODE XREF: sub_48AD30+88j
                                            ; sub_48AD30+295j
    add     esi, 118h
    cmp     esi, ebp
    jbe     loc_48ADB0

    loc_48AFE4:                             ; CODE XREF: sub_48AD30+7Aj
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 1
    jz      short loc_48B008
    cmp     dword ptr [edi], 0
    jz      short loc_48B008
    mov     al, [edi+73h]
    cmp     al, 1
    jz      short loc_48B002
    cmp     al, 2
    jnz     short loc_48B008

    loc_48B002:                             ; CODE XREF: sub_48AD30+2CCj
    push    edi
    call    sub_48B710

    loc_48B008:                             ; CODE XREF: sub_48AD30+2Cj
                                            ; sub_48AD30+4Cj ...
    mov     al, [esp+20h+var_D]
    mov     edx, [esp+20h+var_C]
    inc     al
    add     edx, 14Bh
    cmp     al, 0Ah
    mov     [esp+20h+var_D], al
    mov     [esp+20h+var_C], edx
    jb      loc_48AD62
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+14373h]
    shr     edx, 1
    test    dl, 1
    jz      short loc_48B079
    push    0F9h
    call    sub_4C1B80
    test    eax, eax
    jnz     short loc_48B079
    mov     eax, TAdynmemStructPtr
    dec     word ptr [eax+14371h]
    mov     eax, TAdynmemStructPtr
    cmp     word ptr [eax+14371h], 0
    jg      short loc_48B079
    mov     word ptr [eax+14371h], 5Ah
    call    sub_48D790
    push    0
    call    sub_41C2E0

    loc_48B079:                             ; CODE XREF: sub_48AD30+309j
                                            ; sub_48AD30+317j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn
    sub_48AD30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_48B090(int idTo,int)
    sub_48B090 proc near                    ; CODE XREF: sub_401360+512p
                                            ; .text:0040270Cp ...

    var_1= dword ptr -1
    idTo= dword ptr  7
    arg_4= dword ptr  0Bh

    push    ecx
    mov     eax, [esp+1+arg_4]
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    test    eax, eax
    mov     cl, [edi+10Eh]
    mov     byte ptr [esp+0Dh+var_1], cl
    jz      short loc_48B0BF
    mov     eax, [esp+0Dh+var_1]
    mov     edx, [esp+0Dh+idTo]
    and     eax, 0FFh
    and     edx, 0FFh
    or      eax, edx
    jmp     short loc_48B0D6
    ; ---------------------------------------------------------------------------

    loc_48B0BF:                             ; CODE XREF: sub_48B090+16j
    mov     eax, [esp+0Dh+idTo]
    mov     edx, [esp+0Dh+var_1]
    and     eax, 0FFh
    and     edx, 0FFh
    not     eax
    and     eax, edx

    loc_48B0D6:                             ; CODE XREF: sub_48B090+2Dj
    cmp     al, cl
    mov     [edi+10Eh], al
    jz      loc_48B1F8
    mov     bl, cl
    not     bl
    and     bl, al
    not     al
    and     cl, al
    test    bl, 1
    mov     byte ptr [esp+0Dh+idTo], cl
    jz      short loc_48B115
    mov     ecx, [edi+9Ah]
    push    0                               ; RunNow
    push    0                               ; CompletedScriptMethodCallback
    push    offset aActivate                ; FunctionName
    call    InvokeScript
    push    0
    push    3
    push    edi
    call    sub_47F780

    loc_48B115:                             ; CODE XREF: sub_48B090+65j
    test    byte ptr [esp+0Dh+idTo], 1
    jz      short loc_48B13A
    mov     ecx, [edi+9Ah]
    push    0                               ; RunNow
    push    0                               ; CompletedScriptMethodCallback
    push    offset aDeactivate              ; FunctionName
    call    InvokeScript
    push    0
    push    4
    push    edi
    call    sub_47F780

    loc_48B13A:                             ; CODE XREF: sub_48B090+8Aj
    test    bl, 8
    jz      short loc_48B153
    mov     ecx, [edi+9Ah]
    push    0                               ; RunNow
    push    0                               ; CompletedScriptMethodCallback
    push    offset aStartbuilding           ; FunctionName
    call    InvokeScript

    loc_48B153:                             ; CODE XREF: sub_48B090+ADj
    test    byte ptr [esp+0Dh+idTo], 8
    jz      short loc_48B16E
    mov     ecx, [edi+9Ah]
    push    0                               ; RunNow
    push    0                               ; CompletedScriptMethodCallback
    push    offset aStopbuilding            ; FunctionName
    call    InvokeScript

    loc_48B16E:                             ; CODE XREF: sub_48B090+C8j
    test    bl, 4
    jz      short loc_48B19E
    push    0
    push    0Eh
    push    edi
    call    sub_47F780
    mov     esi, [edi+0A2h]
    test    esi, esi
    jz      short loc_48B19E

    loc_48B187:                             ; CODE XREF: sub_48B090+10Cj
    mov     ecx, [esi+0Ch]
    test    ecx, ecx
    jz      short loc_48B197
    mov     eax, [ecx]
    push    10000h
    call    dword ptr [eax]

    loc_48B197:                             ; CODE XREF: sub_48B090+FCj
    mov     esi, [esi+8]
    test    esi, esi
    jnz     short loc_48B187

    loc_48B19E:                             ; CODE XREF: sub_48B090+E1j
                                            ; sub_48B090+F5j
    test    byte ptr [esp+0Dh+idTo], 4
    jz      short loc_48B1AF
    push    0
    push    0Fh
    push    edi
    call    sub_47F780

    loc_48B1AF:                             ; CODE XREF: sub_48B090+113j
    push    edi
    call    sub_41C110
    mov     eax, [edi+96h]
    cmp     dword ptr [eax], 0
    jz      short loc_48B1F8
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_48B1CD
    cmp     cl, 2
    jnz     short loc_48B1F8

    loc_48B1CD:                             ; CODE XREF: sub_48B090+136j
    mov     cx, [edi+0A8h]
    mov     dl, [edi+10Eh]
    mov     word ptr [esp+0Dh+idTo+1], cx
    mov     byte ptr [esp+0Dh+idTo], 11h
    mov     byte ptr [esp+0Dh+idTo+3], dl
    mov     edx, [eax+4]
    lea     ecx, [esp+0Dh+idTo]
    push    4                               ; idFrom
    push    ecx                             ; idTo
    push    edx                             ; PlayerID
    call    sub_451DF0

    loc_48B1F8:                             ; CODE XREF: sub_48B090+4Ej
                                            ; sub_48B090+12Ej ...
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    8
    sub_48B090 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48B200 proc near                    ; CODE XREF: sub_48B710+194p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    push    esi
    mov     esi, [esp+4+arg_0]
    push    edi
    mov     edi, [esp+8+arg_4]
    mov     ecx, [eax+14393h]
    xor     edx, edx
    push    ecx
    mov     dx, [edi+0A6h]
    mov     ecx, esi
    push    edx
    call    sub_415C10
    cmp     word ptr [edi+0A6h], 0
    jz      loc_48B3DC
    movsx   eax, word ptr [edi+108h]
    push    10h
    push    eax
    mov     ecx, esi
    call    sub_415C10
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD748
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_48B273
    fld     dword ptr [edi+104h]
    fmul    ds:flt_4FD74C
    call    __ftol
    mov     ecx, 1
    sub     ecx, eax
    jmp     short loc_48B275
    ; ---------------------------------------------------------------------------

    loc_48B273:                             ; CODE XREF: sub_48B200+57j
    xor     ecx, ecx

    loc_48B275:                             ; CODE XREF: sub_48B200+71j
    push    8
    push    ecx
    mov     ecx, esi
    call    sub_415C10
    xor     ecx, ecx
    push    8
    mov     cl, [edi+10Eh]
    push    ecx
    mov     ecx, esi
    call    sub_415C10
    mov     edx, [edi+110h]
    push    2
    and     edx, 3
    mov     ecx, esi
    push    edx
    call    sub_415C10
    mov     eax, [edi+86h]
    test    eax, eax
    jz      loc_48B33C
    mov     eax, [esi]
    mov     ecx, [esi+0Ch]
    mov     edx, 1
    lea     eax, [ecx+eax*4]
    mov     ecx, [esi+4]
    shl     edx, cl
    mov     ecx, [eax]
    or      ecx, edx
    mov     [eax], ecx
    mov     ecx, [esi+4]
    inc     ecx
    mov     eax, ecx
    mov     [esi+4], ecx
    cmp     eax, 20h
    jnz     short loc_48B300
    mov     edx, [esi]
    mov     ecx, [esi+8]
    inc     edx
    mov     dword ptr [esi+4], 0
    mov     eax, edx
    mov     [esi], edx
    cmp     eax, ecx
    jnz     short loc_48B2F4
    mov     ecx, esi
    call    sub_415BB0

    loc_48B2F4:                             ; CODE XREF: sub_48B200+EBj
    mov     eax, [esi]
    mov     ecx, [esi+0Ch]
    mov     dword ptr [ecx+eax*4], 0

    loc_48B300:                             ; CODE XREF: sub_48B200+D6j
    mov     ecx, [edi+86h]
    test    ecx, ecx
    jnz     short loc_48B30E
    xor     eax, eax
    jmp     short loc_48B317
    ; ---------------------------------------------------------------------------

    loc_48B30E:                             ; CODE XREF: sub_48B200+108j
    xor     eax, eax
    mov     ax, [ecx+0A8h]

    loc_48B317:                             ; CODE XREF: sub_48B200+10Cj
    and     eax, 0FFFFh
    push    0Fh
    push    eax
    mov     ecx, esi
    call    sub_415C10
    movsx   edx, byte ptr [edi+0F9h]
    push    8
    push    edx
    mov     ecx, esi
    call    sub_415C10
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48B33C:                             ; CODE XREF: sub_48B200+ACj
    mov     edx, [esi+4]
    inc     edx
    mov     eax, edx
    mov     [esi+4], edx
    cmp     eax, 20h
    jnz     short loc_48B372
    mov     edx, [esi]
    mov     ecx, [esi+8]
    inc     edx
    mov     dword ptr [esi+4], 0
    mov     eax, edx
    mov     [esi], edx
    cmp     eax, ecx
    jnz     short loc_48B366
    mov     ecx, esi
    call    sub_415BB0

    loc_48B366:                             ; CODE XREF: sub_48B200+15Dj
    mov     eax, [esi]
    mov     ecx, [esi+0Ch]
    mov     dword ptr [ecx+eax*4], 0

    loc_48B372:                             ; CODE XREF: sub_48B200+148j
    mov     edx, [edi+6Ah]
    push    20h
    push    edx
    mov     ecx, esi
    call    sub_415C10
    mov     eax, [edi+6Eh]
    push    20h
    push    eax
    mov     ecx, esi
    call    sub_415C10
    mov     ecx, [edi+72h]
    push    20h
    push    ecx
    mov     ecx, esi
    call    sub_415C10
    xor     edx, edx
    push    10h
    mov     dx, [edi+66h]
    mov     ecx, esi
    push    edx
    call    sub_415C10
    xor     eax, eax
    push    10h
    mov     ax, [edi+68h]
    mov     ecx, esi
    push    eax
    call    sub_415C10
    xor     ecx, ecx
    push    10h
    mov     cx, [edi+64h]
    push    ecx
    mov     ecx, esi
    call    sub_415C10
    mov     edi, [edi]
    test    edi, edi
    jz      short loc_48B3DC
    mov     edx, [edi+20h]
    push    20h
    push    edx
    mov     ecx, esi
    call    sub_415C10

    loc_48B3DC:                             ; CODE XREF: sub_48B200+2Fj
                                            ; sub_48B200+1CDj
    pop     edi
    pop     esi
    retn    8
    sub_48B200 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48B3F0 proc near                    ; CODE XREF: sub_48B920+1A3p

    var_20= qword ptr -20h
    var_18= byte ptr -18h
    var_15= dword ptr -15h
    var_F= dword ptr -0Fh
    var_B= dword ptr -0Bh
    var_7= dword ptr -7
    var_3= word ptr -3
    arg_0= dword ptr  4
    idTo= dword ptr  8

    mov     eax, TAdynmemStructPtr
    sub     esp, 20h
    mov     ecx, [eax+14393h]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+2Ch+arg_0]
    push    edi
    push    ecx
    mov     ecx, esi
    call    sub_415DC0
    xor     ebp, ebp
    cmp     ax, bp
    jnz     short loc_48B43F
    mov     eax, [esp+30h+idTo]
    cmp     [eax+0A6h], bp
    jz      loc_48B6FC
    mov     ecx, [eax+110h]
    or      ch, 40h
    mov     [eax+110h], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48B43F:                             ; CODE XREF: sub_48B3F0+23j
    mov     edi, [esp+30h+idTo]
    cmp     [edi+0A6h], ax
    jz      short loc_48B49C
    mov     dx, [edi+0A8h]
    mov     [esp+19h], ax
    lea     eax, [edi+6Ah]
    mov     word ptr [esp+30h+var_15], dx
    mov     [esp+30h+var_18], 9
    mov     ecx, [eax]
    mov     [esp+30h+var_15+2], ecx
    lea     ecx, [edi+64h]
    mov     edx, [eax+4]
    mov     [esp+30h+var_F], edx
    mov     edx, [ecx]
    mov     eax, [eax+8]
    mov     [esp+30h+var_7], edx
    mov     dl, [edi+0FFh]
    mov     [esp+30h+var_B], eax
    mov     ax, [ecx+4]
    lea     ecx, [esp+30h+var_18]
    push    ecx
    push    edx
    mov     [esp+38h+var_3], ax
    call    sub_4861D0

    loc_48B49C:                             ; CODE XREF: sub_48B3F0+5Aj
    mov     eax, [edi+9Eh]
    push    10h
    mov     ecx, esi
    mov     [eax+10h], ebp
    call    sub_415DC0
    push    8
    mov     ecx, esi
    mov     [edi+108h], ax
    call    sub_415DC0
    mov     dword ptr [esp+30h+var_20], eax
    mov     dword ptr [esp+30h+var_20+4], ebp
    fild    [esp+30h+var_20]
    fmul    ds:flt_4FD750
    fcom    dword ptr [edi+104h]
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_48B4F4
    mov     eax, [edi+110h]
    fstp    dword ptr [edi+104h]
    or      ah, 20h
    mov     [edi+110h], eax
    jmp     short loc_48B4F6
    ; ---------------------------------------------------------------------------

    loc_48B4F4:                             ; CODE XREF: sub_48B3F0+EBj
    fstp    st

    loc_48B4F6:                             ; CODE XREF: sub_48B3F0+102j
    push    8
    mov     ecx, esi
    call    sub_415DC0
    mov     bl, al
    push    1                               ; int
    mov     byte ptr [esp+34h+idTo], bl
    mov     ecx, [esp+34h+idTo]
    push    ecx                             ; idTo
    mov     ecx, edi
    call    sub_48B090
    not     bl
    push    ebp                             ; int
    push    ebx                             ; idTo
    mov     ecx, edi
    call    sub_48B090
    push    2
    mov     ecx, esi
    call    sub_415DC0
    mov     ecx, [esi+8]
    mov     edx, [esi+4]
    mov     ebp, 1
    mov     ebx, eax
    mov     eax, [esi]
    shl     ebp, cl
    mov     eax, [eax+edx*4]
    and     eax, ebp
    neg     eax
    sbb     eax, eax
    neg     eax
    inc     ecx
    cmp     ecx, 20h
    mov     [esi+8], ecx
    jnz     short loc_48B557
    inc     edx
    mov     dword ptr [esi+8], 0
    mov     [esi+4], edx

    loc_48B557:                             ; CODE XREF: sub_48B3F0+15Aj
    test    eax, eax
    jz      short loc_48B59A
    mov     cx, [edi+0A8h]
    push    0Fh
    mov     word ptr [esp+34h+var_20+1], cx
    mov     ecx, esi
    call    sub_415DC0
    push    8
    mov     ecx, esi
    mov     word ptr [esp+34h+var_20+3], ax
    call    sub_415E60
    lea     edx, [esp+30h+var_20]
    mov     byte ptr [esp+30h+var_20+6], bl
    push    edx
    mov     byte ptr [esp+34h+var_20+5], al
    call    sub_48AB70
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48B59A:                             ; CODE XREF: sub_48B3F0+169j
    mov     eax, [edi+86h]
    test    eax, eax
    jz      short loc_48B5CA
    mov     ax, [edi+0A8h]
    lea     ecx, [esp+30h+var_20]
    push    ecx
    mov     word ptr [esp+34h+var_20+1], ax
    mov     word ptr [esp+34h+var_20+3], 0
    mov     byte ptr [esp+34h+var_20+5], 0FFh
    mov     byte ptr [esp+34h+var_20+6], bl
    call    sub_48AB70

    loc_48B5CA:                             ; CODE XREF: sub_48B3F0+1B2j
    push    20h
    mov     ecx, esi
    call    sub_415DC0
    push    20h
    mov     ecx, esi
    mov     ebp, eax
    call    sub_415DC0
    push    20h
    mov     ecx, esi
    mov     [esp+34h+var_15+1], eax
    call    sub_415DC0
    push    10h
    mov     ecx, esi
    mov     [esp+24h], eax
    call    sub_415DC0
    push    10h
    mov     ecx, esi
    mov     word ptr [esp+34h+var_20+2], ax
    call    sub_415DC0
    push    10h
    mov     ecx, esi
    mov     word ptr [esp+34h+var_20+4], ax
    call    sub_415DC0
    mov     word ptr [esp+30h+var_20], ax
    mov     eax, [edi+7Eh]
    mov     [esp+30h+arg_0], eax
    movsx   ecx, word ptr [esp+30h+arg_0+2]
    movsx   edx, ax
    shl     edx, 13h
    mov     eax, ebp
    shl     ecx, 13h
    sub     eax, edx
    mov     edx, ecx
    mov     ecx, [esp+20h]
    add     eax, 80000h
    sub     ecx, edx
    add     ecx, 80000h
    sar     eax, 14h
    sar     ecx, 14h
    cmp     ax, [edi+76h]
    mov     word ptr [esp+30h+idTo], ax
    mov     word ptr [esp+30h+idTo+2], cx
    jnz     short loc_48B684
    cmp     cx, [edi+78h]
    jnz     short loc_48B684
    mov     eax, [edi+110h]
    and     eax, 3
    cmp     ebx, eax
    jnz     short loc_48B684
    mov     edx, [esp+30h+var_15+1]
    mov     eax, [esp+20h]
    lea     ecx, [edi+6Ah]
    mov     [edi+6Ah], ebp
    mov     [ecx+4], edx
    mov     [ecx+8], eax
    jmp     short loc_48B6C4
    ; ---------------------------------------------------------------------------

    loc_48B684:                             ; CODE XREF: sub_48B3F0+269j
                                            ; sub_48B3F0+26Fj ...
    push    edi
    call    sub_47D0E0
    lea     ecx, [edi+6Ah]
    and     ebx, 3
    mov     edx, [esp+30h+var_15+1]
    mov     eax, [esp+20h]
    mov     [ecx], ebp
    push    edi
    mov     [ecx+4], edx
    mov     edx, [edi+110h]
    and     edx, 0FFFFFFFCh
    mov     [ecx+8], eax
    mov     ecx, [esp+34h+idTo]
    or      ebx, edx
    mov     [edi+76h], ecx
    mov     [edi+110h], ebx
    call    sub_47CC30
    push    edi
    call    sub_4827B0

    loc_48B6C4:                             ; CODE XREF: sub_48B3F0+292j
    mov     ecx, [edi+110h]
    mov     dx, word ptr [esp+30h+var_20+4]
    or      ecx, 10000h
    lea     eax, [edi+64h]
    mov     [edi+110h], ecx
    mov     ecx, dword ptr [esp+30h+var_20]
    mov     [eax], ecx
    mov     [eax+4], dx
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_48B6FC
    push    20h
    mov     ecx, esi
    call    sub_415DC0
    mov     ecx, [edi]
    mov     [ecx+20h], eax

    loc_48B6FC:                             ; CODE XREF: sub_48B3F0+30j
                                            ; sub_48B3F0+2FCj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    8
    sub_48B3F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48B710 proc near                    ; CODE XREF: sub_48AD30+2D3p

    var_414= dword ptr -414h
    var_410= dword ptr -410h
    var_40C= dword ptr -40Ch
    var_408= dword ptr -408h
    arg_0= dword ptr  4

    sub     esp, 410h
    lea     ecx, [esp+410h+var_410]
    push    ebx
    push    esi
    push    edi
    call    sub_415B60
    push    8
    push    2Ch
    lea     ecx, [esp+424h+var_410]
    call    sub_415C10
    push    10h
    push    0
    lea     ecx, [esp+424h+var_410]
    call    sub_415C10
    mov     eax, TAdynmemStructPtr
    push    20h
    mov     ecx, [eax+38A47h]
    push    ecx
    lea     ecx, [esp+424h+var_410]
    call    sub_415C10
    mov     edx, TAdynmemStructPtr
    mov     edi, [esp+41Ch+arg_0]
    mov     eax, [edx+38A47h]
    mov     esi, [edi+67h]
    mov     [edi+18h], eax
    cmp     esi, [edi+6Bh]
    ja      loc_48B80E
    mov     ebx, 10000000h

    loc_48B77A:                             ; CODE XREF: sub_48B710+F8j
    test    [esi+110h], ebx
    jz      short loc_48B7FD
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_48B7FD
    mov     eax, [eax]
    mov     ecx, eax
    mov     edx, [eax]
    call    dword ptr [edx+1Ch]
    test    eax, eax
    jz      short loc_48B7FD
    mov     ecx, [esi+96h]
    xor     eax, eax
    mov     ax, [esi+0A8h]
    xor     edx, edx
    mov     dx, [ecx+6Fh]
    push    10h
    sub     eax, edx
    lea     ecx, [esp+420h+var_410]
    push    eax
    call    sub_415C10
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [esi+0A6h]
    mov     ecx, [eax+14393h]
    push    ecx
    push    edx
    lea     ecx, [esp+424h+var_410]
    call    sub_415C10
    mov     eax, [esi]
    mov     ecx, [eax]
    lea     eax, [esp+41Ch+var_410]
    push    eax
    mov     edx, [ecx]
    call    dword ptr [edx+20h]
    mov     ecx, [esp+41Ch+var_40C]
    mov     edx, [esp+41Ch+var_410]
    add     ecx, 7
    sar     ecx, 3
    lea     eax, [ecx+edx*4]
    cmp     eax, 200h
    jge     short loc_48B80E

    loc_48B7FD:                             ; CODE XREF: sub_48B710+70j
                                            ; sub_48B710+76j ...
    mov     eax, [edi+6Bh]
    add     esi, 118h
    cmp     esi, eax
    jbe     loc_48B77A

    loc_48B80E:                             ; CODE XREF: sub_48B710+5Fj
                                            ; sub_48B710+EBj
    push    10h
    push    0FFFFFFFFh
    lea     ecx, [esp+424h+var_410]
    call    sub_415C10
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     ebx, 1
    mov     cx, [eax+37EE6h]
    mov     eax, [eax+38A47h]
    cdq
    idiv    ecx
    mov     ecx, [esp+41Ch+var_40C]
    mov     eax, [esp+18h]
    shl     ebx, cl
    mov     esi, edx
    mov     edx, [esp+41Ch+var_410]
    mov     ecx, [eax+edx*4]
    or      ecx, ebx
    mov     [eax+edx*4], ecx
    mov     eax, [esp+41Ch+var_40C]
    inc     eax
    cmp     eax, 20h
    mov     [esp+41Ch+var_40C], eax
    jnz     short loc_48B88E
    mov     eax, [esp+41Ch+var_410]
    mov     ecx, [esp+41Ch+var_408]
    inc     eax
    mov     [esp+41Ch+var_40C], 0
    cmp     eax, ecx
    mov     [esp+41Ch+var_410], eax
    jnz     short loc_48B87F
    lea     ecx, [esp+41Ch+var_410]
    call    sub_415BB0

    loc_48B87F:                             ; CODE XREF: sub_48B710+164j
    mov     edx, [esp+18h]
    mov     eax, [esp+41Ch+var_410]
    mov     dword ptr [edx+eax*4], 0

    loc_48B88E:                             ; CODE XREF: sub_48B710+14Bj
    mov     edx, [edi+67h]
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     ecx, [eax+eax*4]
    lea     eax, [edx+ecx*8]
    lea     ecx, [esp+41Ch+var_410]
    push    eax
    push    ecx
    call    sub_48B200
    lea     ecx, [esp+41Ch+var_410]
    mov     edx, [esp+41Ch+var_40C]
    mov     al, byte ptr [esp+41Ch+var_410]
    add     edx, 7
    sar     edx, 3
    shl     al, 2
    add     dl, al
    push    edx
    push    1
    call    sub_415DA0
    mov     ecx, [esp+41Ch+var_40C]
    mov     edx, [esp+41Ch+var_410]
    add     ecx, 7
    sar     ecx, 3
    lea     eax, [ecx+edx*4]
    lea     ecx, [esp+41Ch+var_410]
    sar     eax, 8
    push    eax
    push    2
    call    sub_415DA0
    mov     ecx, [esp+41Ch+var_40C]
    mov     edx, [esp+41Ch+var_410]
    add     ecx, 7
    sar     ecx, 3
    lea     eax, [ecx+edx*4]
    mov     ecx, [esp+18h]
    mov     edx, [edi+4]
    push    eax                             ; idFrom
    push    ecx                             ; idTo
    push    edx                             ; PlayerID
    call    sub_451DF0
    lea     ecx, [esp+41Ch+var_410]
    call    sub_415B90
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 410h
    retn    4
    sub_48B710 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48B920 proc near                    ; CODE XREF: Network_Process+16B4p

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= byte ptr -18h
    var_15= word ptr -15h
    var_13= dword ptr -13h
    var_F= dword ptr -0Fh
    var_B= dword ptr -0Bh
    var_7= dword ptr -7
    var_3= word ptr -3
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 24h
    mov     eax, [esp+24h+arg_4]
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     esi, esi
    push    8
    lea     ecx, [esp+38h+var_24]
    mov     [esp+38h+var_24], eax
    mov     [esp+38h+var_20], esi
    mov     [esp+38h+var_1C], esi
    call    sub_415DC0
    push    10h
    lea     ecx, [esp+38h+var_24]
    call    sub_415DC0
    push    20h
    lea     ecx, [esp+38h+var_24]
    call    sub_415DC0
    mov     ebp, eax
    mov     edi, [esp+34h+arg_0]
    mov     eax, [edi+67h]
    mov     [edi+18h], ebp
    cmp     eax, esi
    jz      loc_48BAC8
    push    10h
    lea     ecx, [esp+38h+var_24]
    call    sub_415DC0
    cmp     ax, 0FFFFh
    jz      loc_48BA28
    mov     bl, 9

    loc_48B985:                             ; CODE XREF: sub_48B920+102j
    movsx   ecx, ax
    mov     edx, [edi+67h]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    lea     esi, [edx+ecx*8]
    mov     ecx, [eax+14393h]
    push    ecx
    lea     ecx, [esp+38h+var_24]
    call    sub_415DC0
    cmp     [esi+0A6h], ax
    jz      short loc_48BA05
    mov     dx, [esi+0A8h]
    mov     [esp+1Dh], ax
    lea     eax, [esi+6Ah]
    mov     [esp+34h+var_15], dx
    mov     [esp+34h+var_18], bl
    mov     ecx, [eax]
    mov     [esp+34h+var_13], ecx
    lea     ecx, [esi+64h]
    mov     edx, [eax+4]
    mov     [esp+34h+var_F], edx
    mov     edx, [ecx]
    mov     eax, [eax+8]
    mov     [esp+34h+var_7], edx
    mov     dl, [esi+0FFh]
    mov     [esp+34h+var_B], eax
    mov     ax, [ecx+4]
    lea     ecx, [esp+34h+var_18]
    push    ecx
    push    edx
    mov     [esp+3Ch+var_3], ax
    call    sub_4861D0

    loc_48BA05:                             ; CODE XREF: sub_48B920+94j
    mov     eax, [esi]
    mov     ecx, [eax]
    lea     eax, [esp+34h+var_24]
    push    eax
    mov     edx, [ecx]
    call    dword ptr [edx+24h]
    push    10h
    lea     ecx, [esp+38h+var_24]
    call    sub_415DC0
    cmp     ax, 0FFFFh
    jnz     loc_48B985

    loc_48BA28:                             ; CODE XREF: sub_48B920+5Dj
    mov     esi, [edi+67h]
    mov     eax, [edi+6Bh]
    cmp     esi, eax
    ja      short loc_48BA5E
    mov     ebx, 10000000h

    loc_48BA37:                             ; CODE XREF: sub_48B920+13Cj
    test    [esi+110h], ebx
    jz      short loc_48BA51
    mov     ecx, [esi]
    test    ecx, ecx
    jz      short loc_48BA51
    push    esi
    call    sub_43DD20
    push    esi
    call    sub_48A870

    loc_48BA51:                             ; CODE XREF: sub_48B920+11Dj
                                            ; sub_48B920+123j
    mov     eax, [edi+6Bh]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48BA37

    loc_48BA5E:                             ; CODE XREF: sub_48B920+110j
    mov     ecx, [esp+34h+var_1C]
    mov     eax, [esp+34h+var_24]
    mov     esi, [esp+34h+var_20]
    mov     edx, 1
    shl     edx, cl
    mov     eax, [eax+esi*4]
    and     eax, edx
    neg     eax
    sbb     eax, eax
    neg     eax
    inc     ecx
    cmp     ecx, 20h
    mov     [esp+34h+var_1C], ecx
    jnz     short loc_48BA95
    mov     ecx, esi
    mov     [esp+34h+var_1C], 0
    inc     ecx
    mov     [esp+34h+var_20], ecx

    loc_48BA95:                             ; CODE XREF: sub_48B920+164j
    test    eax, eax
    jz      short loc_48BAC8
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     eax, ebp
    mov     cx, [edx+37EE6h]
    cdq
    idiv    ecx
    mov     ecx, [edi+67h]
    mov     eax, edx
    shl     eax, 3
    sub     eax, edx
    lea     eax, [eax+eax*4]
    lea     edx, [ecx+eax*8]
    lea     eax, [esp+34h+var_24]
    push    edx
    push    eax
    call    sub_48B3F0

    loc_48BAC8:                             ; CODE XREF: sub_48B920+48j
                                            ; sub_48B920+177j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    8
    sub_48B920 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl GameUnit_LOS_Sight()
    GameUnit_LOS_Sight proc near            ; CODE XREF: sub_48D4D0+D5p
                                            ; sub_495A30+23Dp ...

    field_37E27= dword ptr -20h
    NumHotUnits= dword ptr -1Ch
    MapY= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    HotUnits= dword ptr -0Ch
    MapX= dword ptr -8
    Player= dword ptr -4

    sub     esp, 20h
    push    ebx
    push    esi
    mov     esi, TAdynmemStructPtr          ; Initial hookpoint (jmp @GameUnit_LOS_Sight_Start)
    mov     [esp+28h+NumHotUnits], 0
    mov     eax, [esi+TAdynmemStruct.HotUnits]
    lea     ecx, [esi+TAdynmemStruct.field_37E27]
    mov     [esp+28h+field_37E27], ecx
    xor     ecx, ecx
    mov     cl, [esi+TAdynmemStruct.LOS_Sight]
    mov     [esp+28h+HotUnits], eax
    mov     eax, ecx
    mov     ebx, [esi+TAdynmemStruct.Units]
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, esi
    add     eax, ecx
    lea     ecx, [eax+edx*2+TAdynmemStruct.Players]
    mov     eax, [esi+TAdynmemStruct.Units_EndMarker]
    cmp     ebx, eax
    mov     [esp+28h+Player], ecx
    ja      loc_48BC99
    push    edi
    push    ebp

    loc_48BB3E:                             ; CODE XREF: GameUnit_LOS_Sight+1B1j
    cmp     word ptr [ebx+0A6h], 0
    jz      loc_48BC83
    mov     eax, [ebx+UnitStruct.UnitType]
    mov     ecx, [esi+TAdynmemStruct.MapX]
    movsx   ebp, word ptr [ebx+6Ch]
    movsx   edx, word ptr [eax+160h]
    movsx   edi, word ptr [ebx+70h]
    mov     esi, [esi+TAdynmemStruct.MapY]
    add     edx, ebp
    sub     edx, ecx
    mov     [esp+30h+MapY], esi
    movsx   ecx, word ptr [eax+170h]
    movsx   esi, word ptr [eax+168h]
    add     ecx, edi
    mov     [esp+30h+var_14], edx
    movsx   edi, word ptr [ebx+74h]
    add     esi, edi
    mov     edi, [esp+30h+MapY]
    sub     esi, edi
    mov     [esp+30h+var_10], ecx
    movsx   edi, word ptr [eax+16Ch]
    add     edi, ebp
    mov     ebp, TAdynmemStructPtr
    sub     edi, [ebp+TAdynmemStruct.MapX]
    movsx   ebp, word ptr [eax+164h]
    mov     [esp+30h+MapX], edi
    movsx   edi, word ptr [ebx+70h]
    add     ebp, edi
    movsx   edi, word ptr [eax+174h]
    movsx   eax, word ptr [ebx+74h]
    add     edi, eax
    mov     eax, [esp+30h+MapY]
    sub     edi, eax
    mov     eax, [ebx+110h]
    and     eax, 3
    cmp     al, 1
    jz      short loc_48BC01
    lea     ecx, [ebx+UnitStruct.XPos]
    push    ecx                             ; int
    call    sub_4815A0
    test    eax, eax
    jz      short loc_48BBF9
    xor     edx, edx
    mov     dl, [eax+4]
    mov     eax, edx
    cmp     ebp, eax
    jle     short loc_48BBF9
    mov     ebp, eax

    loc_48BBF9:                             ; CODE XREF: GameUnit_LOS_Sight+10Aj
                                            ; GameUnit_LOS_Sight+115j
    mov     edx, [esp+30h+var_14]
    mov     ecx, [esp+30h+var_10]

    loc_48BC01:                             ; CODE XREF: GameUnit_LOS_Sight+FDj
    mov     eax, [esp+30h+MapX]
    add     edx, 80h
    sar     ecx, 1
    sub     esi, ecx
    mov     ecx, [esp+30h+field_37E27]
    sar     ebp, 1
    sub     edi, ebp
    mov     ebp, [ecx+8]
    add     esi, 20h
    add     eax, 80h
    add     edi, 20h
    cmp     edx, ebp
    jg      short loc_48BC7D
    mov     edx, ecx
    cmp     eax, [edx]
    jl      short loc_48BC7D
    mov     eax, edx
    cmp     esi, [eax+0Ch]
    jg      short loc_48BC7D
    mov     ecx, edx
    cmp     edi, [ecx+4]
    jl      short loc_48BC7D
    mov     eax, TAdynmemStructPtr
    mov     dl, [ebx+UnitStruct.OwnerIndex]
    cmp     dl, [eax+TAdynmemStruct.LOS_Sight]
    jz      short loc_48BC5F
    mov     ecx, [esp+30h+Player]
    push    ebx                             ; Unit
    push    ecx                             ; Player
    call    PlayerCanSeeUnit
    test    eax, eax
    jz      short loc_48BC7D

    loc_48BC5F:                             ; CODE XREF: GameUnit_LOS_Sight+16Ej
    mov     eax, [esp+30h+HotUnits]
    mov     dx, [ebx+0A8h]
    mov     [eax], dx
    add     eax, 2
    mov     [esp+30h+HotUnits], eax
    mov     eax, [esp+30h+NumHotUnits]
    inc     eax
    mov     [esp+30h+NumHotUnits], eax

    loc_48BC7D:                             ; CODE XREF: GameUnit_LOS_Sight+147j
                                            ; GameUnit_LOS_Sight+14Dj ...
    mov     esi, TAdynmemStructPtr

    loc_48BC83:                             ; CODE XREF: GameUnit_LOS_Sight+66j
    mov     eax, [esi+TAdynmemStruct.Units_EndMarker]
    add     ebx, 118h
    cmp     ebx, eax
    jbe     loc_48BB3E
    pop     ebp
    pop     edi

    loc_48BC99:                             ; CODE XREF: GameUnit_LOS_Sight+56j
    mov     eax, [esp+28h+NumHotUnits]
    mov     [esi+TAdynmemStruct.NumHotUnits], eax
    pop     esi
    pop     ebx
    add     esp, 20h
    retn
    GameUnit_LOS_Sight endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_48BCB0(int)
    sub_48BCB0 proc near                    ; CODE XREF: sub_47F7E0+6p
                                            ; sub_47F850+6p

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    esi
    mov     ecx, [eax+TAdynmemStruct.HotUnits]
    mov     edx, [eax+TAdynmemStruct.NumHotUnits]
    xor     eax, eax
    test    edx, edx
    jle     short loc_48BCEF
    mov     esi, [esp+4+arg_0]
    mov     si, [esi+0A8h]

    loc_48BCD3:                             ; CODE XREF: sub_48BCB0+2Ej
    cmp     [ecx], si
    jz      short loc_48BCE6
    inc     eax
    add     ecx, 2
    cmp     eax, edx
    jl      short loc_48BCD3
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48BCE6:                             ; CODE XREF: sub_48BCB0+26j
    mov     eax, 1
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48BCEF:                             ; CODE XREF: sub_48BCB0+16j
    xor     eax, eax
    pop     esi
    retn    4
    sub_48BCB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48BD00 proc near                    ; CODE XREF: sub_495E90+FCp
                                            ; sub_498F70+ECp ...
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14357h]
    mov     edx, [ecx+1435Bh]
    cmp     eax, edx
    ja      short loc_48BD3B
    push    esi
    mov     ecx, 0FFFFFF2Fh

    loc_48BD1C:                             ; CODE XREF: sub_48BD00+38j
    mov     esi, [eax+110h]
    add     eax, 118h
    and     esi, ecx
    mov     [eax-8], esi
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+1435Bh]
    jbe     short loc_48BD1C
    pop     esi

    loc_48BD3B:                             ; CODE XREF: sub_48BD00+14j
    push    0
    call    sub_491D70
    retn
    sub_48BD00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48BD50 proc near                    ; CODE XREF: .text:004963CEp
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    esi
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*2+1B63h]
    mov     ecx, [ecx+eax*2+1BCAh]
    mov     eax, [esi+6Bh]
    cmp     ecx, eax
    ja      short loc_48BDE6
    push    edi
    push    ebx
    xor     edi, edi
    mov     ebx, 40000000h

    loc_48BD89:                             ; CODE XREF: sub_48BD50+92j
    mov     edx, [ecx+110h]
    test    dl, 20h
    jz      short loc_48BDD7
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48BDD7
    cmp     [ecx+0FBh], edi
    jnz     short loc_48BDD7
    mov     eax, [ecx+86h]
    cmp     eax, edi
    jz      short loc_48BDC1
    test    [eax+110h], ebx
    jz      short loc_48BDD7

    loc_48BDC1:                             ; CODE XREF: sub_48BD50+67j
    or      edx, 10h
    mov     [ecx+110h], edx
    mov     edx, TAdynmemStructPtr
    mov     [edx+37E9Ch], di

    loc_48BDD7:                             ; CODE XREF: sub_48BD50+42j
                                            ; sub_48BD50+55j ...
    mov     eax, [esi+6Bh]
    add     ecx, 118h
    cmp     ecx, eax
    jbe     short loc_48BD89
    pop     ebx
    pop     edi

    loc_48BDE6:                             ; CODE XREF: sub_48BD50+2Ej
    call    sub_495860
    mov     eax, TAdynmemStructPtr
    pop     esi
    or      byte ptr [eax+37EBEh], 10h
    retn
    sub_48BD50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48BE00 proc near                    ; CODE XREF: .text:00496413p

    var_40= dword ptr -40h

    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    sub     esp, 40h
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    push    ebx
    shl     eax, 5
    add     eax, ecx
    add     edx, ecx
    push    ebp
    push    esi
    lea     eax, [eax+eax*4]
    push    edi
    mov     ecx, 10h
    lea     edi, [esp+50h+var_40]
    lea     ebp, [edx+eax*2+1B63h]
    xor     eax, eax
    rep stosd
    mov     edx, [ebp+67h]
    mov     edi, [ebp+6Bh]
    mov     eax, edx
    cmp     eax, edi
    ja      short loc_48BE80

    loc_48BE41:                             ; CODE XREF: sub_48BE00+7Ej
    mov     ecx, [eax+110h]
    shr     ecx, 4
    test    cl, 1
    jz      short loc_48BE77
    mov     cx, [eax+0A6h]
    mov     ebx, 1
    and     ecx, 0FFFFh
    mov     esi, ecx
    and     ecx, 1Fh
    shr     esi, 5
    shl     ebx, cl
    mov     ecx, [esp+esi*4+50h+var_40]
    lea     esi, [esp+esi*4+50h+var_40]
    or      ecx, ebx
    mov     [esi], ecx

    loc_48BE77:                             ; CODE XREF: sub_48BE00+4Dj
    add     eax, 118h
    cmp     eax, edi
    jbe     short loc_48BE41

    loc_48BE80:                             ; CODE XREF: sub_48BE00+3Fj
    cmp     edx, edi
    ja      short loc_48BEFA
    mov     esi, 40000000h

    loc_48BE89:                             ; CODE XREF: sub_48BE00+F8j
    mov     ebx, [edx+110h]
    test    bl, 20h
    jz      short loc_48BEED
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48BEED
    mov     eax, [edx+0FBh]
    test    eax, eax
    jnz     short loc_48BEED
    mov     eax, [edx+86h]
    test    eax, eax
    jz      short loc_48BEC3
    test    [eax+110h], esi
    jz      short loc_48BEED

    loc_48BEC3:                             ; CODE XREF: sub_48BE00+B9j
    mov     ax, [edx+0A6h]
    mov     edi, 1
    and     eax, 0FFFFh
    mov     ecx, eax
    and     ecx, 1Fh
    shl     edi, cl
    shr     eax, 5
    test    [esp+eax*4+50h+var_40], edi
    jz      short loc_48BEED
    or      ebx, 10h
    mov     [edx+110h], ebx

    loc_48BEED:                             ; CODE XREF: sub_48BE00+92j
                                            ; sub_48BE00+A5j ...
    mov     eax, [ebp+6Bh]
    add     edx, 118h
    cmp     edx, eax
    jbe     short loc_48BE89

    loc_48BEFA:                             ; CODE XREF: sub_48BE00+82j
    mov     edx, TAdynmemStructPtr
    mov     word ptr [edx+37E9Ch], 0
    call    sub_495860
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    or      byte ptr [eax+37EBEh], 10h
    pop     ebx
    add     esp, 40h
    retn
    sub_48BE00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48BF30 proc near                    ; CODE XREF: .text:004963F4p
                                            ; .text:00496404p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    esi
    push    edi
    push    eax                             ; char *
    call    sub_488C50
    mov     ebx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     esi, eax
    mov     cl, [ebx+2A42h]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, ebx
    add     eax, ecx
    lea     edi, [eax+edx*2+1B63h]
    mov     edx, [eax+edx*2+1BCAh]
    mov     eax, [edi+6Bh]
    cmp     edx, eax
    ja      loc_48C001
    push    ebp

    loc_48BF75:                             ; CODE XREF: sub_48BF30+C4j
    mov     ebx, [edx+110h]
    test    bl, 20h
    jz      short loc_48BFE9
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48BFE9
    mov     eax, [edx+0FBh]
    test    eax, eax
    jnz     short loc_48BFE9
    mov     eax, [edx+86h]
    test    eax, eax
    jz      short loc_48BFB3
    test    dword ptr [eax+110h], 40000000h
    jz      short loc_48BFE9

    loc_48BFB3:                             ; CODE XREF: sub_48BF30+75j
    mov     ax, [edx+0A6h]
    mov     ebp, 1
    and     eax, 0FFFFh
    mov     ecx, eax
    and     ecx, 1Fh
    shl     ebp, cl
    shr     eax, 5
    test    [esi+eax*4], ebp
    jz      short loc_48BFD8
    or      ebx, 10h
    jmp     short loc_48BFE3
    ; ---------------------------------------------------------------------------

    loc_48BFD8:                             ; CODE XREF: sub_48BF30+A1j
    mov     eax, [esp+10h+arg_4]
    test    eax, eax
    jnz     short loc_48BFE9
    and     ebx, 0FFFFFFEFh

    loc_48BFE3:                             ; CODE XREF: sub_48BF30+A6j
    mov     [edx+110h], ebx

    loc_48BFE9:                             ; CODE XREF: sub_48BF30+4Ej
                                            ; sub_48BF30+61j ...
    mov     eax, [edi+6Bh]
    add     edx, 118h
    cmp     edx, eax
    jbe     loc_48BF75
    mov     ebx, TAdynmemStructPtr
    pop     ebp

    loc_48C001:                             ; CODE XREF: sub_48BF30+3Ej
    mov     word ptr [ebx+37E9Ch], 0
    call    sub_495860
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebx
    or      byte ptr [eax+37EBEh], 10h
    retn    8
    sub_48BF30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48C030 proc near                    ; CODE XREF: .text:004964DCp
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    xor     ebx, ebx
    mov     eax, [ecx+14357h]
    mov     edx, [ecx+1435Bh]
    push    esi
    cmp     eax, edx
    push    edi
    ja      short loc_48C06F
    mov     ecx, 0FFFFFF2Fh

    loc_48C051:                             ; CODE XREF: sub_48C030+3Dj
    mov     ebp, [eax+110h]
    add     eax, 118h
    and     ebp, ecx
    mov     [eax-8], ebp
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+1435Bh]
    jbe     short loc_48C051

    loc_48C06F:                             ; CODE XREF: sub_48C030+1Aj
    push    0
    call    sub_491D70
    mov     esi, TAdynmemStructPtr
    xor     ebp, ebp
    mov     eax, [esi+14367h]
    mov     edi, [esi+1435Fh]
    test    eax, eax
    jle     loc_48C11A

    loc_48C092:                             ; CODE XREF: sub_48C030+E4j
    xor     ecx, ecx
    mov     cx, [edi]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [esi+14357h]
    lea     eax, [eax+eax*4]
    mov     edx, [ecx+eax*8+110h]
    lea     ecx, [ecx+eax*8]
    test    dl, 20h
    jz      short loc_48C108
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48C108
    mov     eax, [ecx+0FBh]
    test    eax, eax
    jnz     short loc_48C108
    mov     eax, [ecx+86h]
    test    eax, eax
    jz      short loc_48C0E6
    test    byte ptr [eax+113h], 40h
    jz      short loc_48C108

    loc_48C0E6:                             ; CODE XREF: sub_48C030+ABj
    mov     al, [ecx+0FFh]
    cmp     al, [esi+2A42h]
    jnz     short loc_48C108
    or      edx, 10h
    mov     ebx, 1
    mov     [ecx+110h], edx
    mov     esi, TAdynmemStructPtr

    loc_48C108:                             ; CODE XREF: sub_48C030+84j
                                            ; sub_48C030+97j ...
    mov     eax, [esi+14367h]
    inc     ebp
    add     edi, 2
    cmp     ebp, eax
    jl      loc_48C092

    loc_48C11A:                             ; CODE XREF: sub_48C030+5Cj
    test    ebx, ebx
    jz      short loc_48C13E
    call    sub_495860
    mov     ecx, TAdynmemStructPtr
    mov     word ptr [ecx+37E9Ch], 0
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37EBEh], 10h

    loc_48C13E:                             ; CODE XREF: sub_48C030+ECj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_48C030 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14357h]
    mov     edx, [ecx+1435Bh]
    cmp     eax, edx
    ja      short locret_48C18B
    push    esi
    mov     ecx, 0FFFFFF3Fh

    loc_48C16C:                             ; CODE XREF: .text:0048C188j
    mov     esi, [eax+110h]
    add     eax, 118h
    and     esi, ecx
    mov     [eax-8], esi
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+1435Bh]
    jbe     short loc_48C16C
    pop     esi

    locret_48C18B:                          ; CODE XREF: .text:0048C164j
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_48C190(int,int)
    sub_48C190 proc near                    ; CODE XREF: sub_418310+59p
                                            ; sub_41C2E0+12p ...

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edx, esi
    mov     cl, [esi+TAdynmemStruct.SharedBits]
    push    edi
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     edi, [edx+eax*2+TAdynmemStruct.Players]
    mov     eax, [esp+4+arg_0]
    test    eax, eax
    jnz     short loc_48C1C3
    xor     ebx, ebx
    jmp     short loc_48C1CA
    ; ---------------------------------------------------------------------------

    loc_48C1C3:                             ; CODE XREF: sub_48C190+2Dj
    mov     bx, [eax+0A8h]

    loc_48C1CA:                             ; CODE XREF: sub_48C190+31j
    mov     bp, [edi+6Fh]
    cmp     bx, bp
    jb      short loc_48C1D9
    cmp     bx, [edi+71h]
    jbe     short loc_48C1DB

    loc_48C1D9:                             ; CODE XREF: sub_48C190+41j
    mov     ebx, ebp

    loc_48C1DB:                             ; CODE XREF: sub_48C190+47j
    mov     eax, [esp+4+arg_4]
    test    eax, eax
    jz      loc_48C27E
    cmp     bx, bp
    mov     edx, ebx
    jz      short loc_48C22A

    loc_48C1EE:                             ; CODE XREF: sub_48C190+98j
    dec     edx
    test    dx, dx
    jnz     short loc_48C1F8
    xor     eax, eax
    jmp     short loc_48C213
    ; ---------------------------------------------------------------------------

    loc_48C1F8:                             ; CODE XREF: sub_48C190+62j
    mov     ecx, edx
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [esi+TAdynmemStruct.Units]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]

    loc_48C213:                             ; CODE XREF: sub_48C190+66j
    mov     ecx, [eax+110h]
    shr     ecx, 4
    test    cl, 1
    jnz     loc_48C30B
    cmp     dx, bp
    jnz     short loc_48C1EE

    loc_48C22A:                             ; CODE XREF: sub_48C190+5Cj
    mov     dx, [edi+71h]
    inc     dx
    cmp     dx, bx
    jz      loc_48C309

    loc_48C239:                             ; CODE XREF: sub_48C190+E3j
    dec     edx
    test    dx, dx
    jnz     short loc_48C243
    xor     eax, eax
    jmp     short loc_48C25E
    ; ---------------------------------------------------------------------------

    loc_48C243:                             ; CODE XREF: sub_48C190+ADj
    mov     ecx, edx
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [esi+TAdynmemStruct.Units]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]

    loc_48C25E:                             ; CODE XREF: sub_48C190+B1j
    mov     ecx, [eax+110h]
    shr     ecx, 4
    test    cl, 1
    jnz     loc_48C30B
    cmp     dx, bx
    jnz     short loc_48C239
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48C27E:                             ; CODE XREF: sub_48C190+51j
    mov     di, [edi+71h]
    cmp     bx, di
    jz      short loc_48C2C5
    lea     edx, [ebx+1]

    loc_48C28A:                             ; CODE XREF: sub_48C190+133j
    test    dx, dx
    jnz     short loc_48C293
    xor     eax, eax
    jmp     short loc_48C2AE
    ; ---------------------------------------------------------------------------

    loc_48C293:                             ; CODE XREF: sub_48C190+FDj
    mov     ecx, edx
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [esi+TAdynmemStruct.Units]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]

    loc_48C2AE:                             ; CODE XREF: sub_48C190+101j
    mov     ecx, [eax+110h]
    shr     ecx, 4
    test    cl, 1
    jnz     short loc_48C30B
    inc     edx
    lea     eax, [edx-1]
    cmp     ax, di
    jnz     short loc_48C28A

    loc_48C2C5:                             ; CODE XREF: sub_48C190+F5j
    lea     edi, [ebp-1]
    cmp     di, bx
    jz      short loc_48C309
    lea     edx, [edi+1]

    loc_48C2D0:                             ; CODE XREF: sub_48C190+177j
    test    dx, dx
    jnz     short loc_48C2D9
    xor     eax, eax
    jmp     short loc_48C2F4
    ; ---------------------------------------------------------------------------

    loc_48C2D9:                             ; CODE XREF: sub_48C190+143j
    mov     ecx, edx
    and     ecx, 0FFFFh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, [esi+14357h]
    lea     eax, [eax+ecx*8]

    loc_48C2F4:                             ; CODE XREF: sub_48C190+147j
    mov     ecx, [eax+110h]
    shr     ecx, 4
    test    cl, 1
    jnz     short loc_48C30B
    inc     edi
    inc     edx
    cmp     di, bx
    jnz     short loc_48C2D0

    loc_48C309:                             ; CODE XREF: sub_48C190+A3j
                                            ; sub_48C190+13Bj
    xor     eax, eax

    loc_48C30B:                             ; CODE XREF: sub_48C190+8Fj
                                            ; sub_48C190+DAj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_48C190 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, TAdynmemStructPtr
    push    esi
    push    edi
    xor     edi, edi
    mov     eax, [edx+14367h]
    mov     esi, [edx+1435Fh]
    test    eax, eax
    jle     short loc_48C38A
    push    ebx

    loc_48C33B:                             ; CODE XREF: .text:0048C387j
    xor     ecx, ecx
    mov     bl, [edx+2A42h]
    mov     cx, [esi]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]
    mov     cl, [eax+0FFh]
    cmp     cl, bl
    jnz     short loc_48C37B
    mov     edx, [eax+110h]
    and     dl, 7Fh
    or      edx, 40h
    mov     [eax+110h], edx
    mov     edx, TAdynmemStructPtr

    loc_48C37B:                             ; CODE XREF: .text:0048C361j
    mov     eax, [edx+14367h]
    inc     edi
    add     esi, 2
    cmp     edi, eax
    jl      short loc_48C33B
    pop     ebx

    loc_48C38A:                             ; CODE XREF: .text:0048C338j
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48C390 proc near                    ; CODE XREF: .text:0049944Cp

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 1Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    push    edi
    mov     [esp+2Ch+var_10], 0
    mov     eax, [esi+1431Fh]
    mov     edi, [esi+2C92h]
    mov     ebx, [esi+2C96h]
    mov     ebp, [esi+2C9Eh]
    mov     edx, [esi+2C9Ah]
    mov     ecx, [esi+14323h]
    sub     edi, eax
    sub     ebp, eax
    mov     eax, [esi+2CA2h]
    add     edi, 80h
    sar     ebx, 1
    sub     edx, ebx
    mov     ebx, [esi+2CA6h]
    sar     eax, 1
    sub     ebx, eax
    sub     edx, ecx
    sub     ebx, ecx
    add     ebp, 80h
    add     edx, 20h
    add     ebx, 20h
    cmp     edi, ebp
    mov     [esp+2Ch+var_18], edx
    mov     [esp+2Ch+var_1C], ebp
    mov     [esp+2Ch+var_14], ebx
    jle     short loc_48C40F
    mov     eax, edi
    mov     edi, ebp
    mov     [esp+2Ch+var_1C], eax

    loc_48C40F:                             ; CODE XREF: sub_48C390+75j
    cmp     edx, ebx
    jle     short loc_48C41D
    mov     eax, edx
    mov     [esp+2Ch+var_18], ebx
    mov     [esp+2Ch+var_14], eax

    loc_48C41D:                             ; CODE XREF: sub_48C390+81j
    mov     ecx, [esp+2Ch+arg_0]
    mov     eax, [ecx+8]
    shr     eax, 2
    and     eax, 1
    mov     [esp+2Ch+var_C], eax
    jnz     short loc_48C470
    mov     eax, [esi+14357h]
    mov     ecx, [esi+1435Bh]
    cmp     eax, ecx
    ja      short loc_48C463
    mov     ecx, 0FFFFFF2Fh

    loc_48C445:                             ; CODE XREF: sub_48C390+D1j
    mov     ebp, [eax+110h]
    add     eax, 118h
    and     ebp, ecx
    mov     [eax-8], ebp
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+1435Bh]
    jbe     short loc_48C445

    loc_48C463:                             ; CODE XREF: sub_48C390+AEj
    push    0
    call    sub_491D70
    mov     esi, TAdynmemStructPtr

    loc_48C470:                             ; CODE XREF: sub_48C390+9Ej
    xor     ecx, ecx
    mov     edx, esi
    mov     cl, [esi+2A42h]
    xor     ebp, ebp
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    mov     [esp+2Ch+arg_0], ebp
    lea     eax, [eax+eax*4]
    mov     ecx, [edx+eax*2+1BCAh]
    lea     eax, [edx+eax*2+1B63h]
    mov     [esp+2Ch+var_8], eax
    cmp     ecx, [eax+6Bh]
    ja      loc_48C599

    loc_48C4A7:                             ; CODE XREF: sub_48C390+1FFj
    mov     ebx, [ecx+110h]
    test    bl, 20h
    jz      loc_48C582
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      loc_48C582
    mov     eax, [ecx+0FBh]
    test    eax, eax
    jnz     loc_48C582
    mov     eax, [ecx+86h]
    test    eax, eax
    jz      short loc_48C4F5
    test    dword ptr [eax+110h], 40000000h
    jz      loc_48C582

    loc_48C4F5:                             ; CODE XREF: sub_48C390+153j
    movsx   edx, word ptr [ecx+6Ch]
    mov     ebp, [esi+1431Fh]
    movsx   eax, word ptr [ecx+74h]
    sub     edx, ebp
    mov     ebp, [esi+14323h]
    sub     eax, ebp
    add     edx, 80h
    movsx   ebp, word ptr [ecx+70h]
    sar     ebp, 1
    sub     eax, ebp
    add     eax, 20h
    cmp     edx, edi
    jl      short loc_48C568
    cmp     edx, [esp+2Ch+var_1C]
    jg      short loc_48C568
    cmp     eax, [esp+2Ch+var_18]
    jl      short loc_48C568
    cmp     eax, [esp+2Ch+var_14]
    jg      short loc_48C568
    mov     eax, [esp+2Ch+var_C]
    test    eax, eax
    jnz     short loc_48C547
    or      ebx, 10h
    mov     [ecx+110h], ebx
    jmp     short loc_48C55A
    ; ---------------------------------------------------------------------------

    loc_48C547:                             ; CODE XREF: sub_48C390+1AAj
    mov     eax, ebx
    mov     edx, ebx
    not     eax
    xor     edx, eax
    and     edx, 10h
    xor     edx, ebx
    mov     [ecx+110h], edx

    loc_48C55A:                             ; CODE XREF: sub_48C390+1B5j
    mov     esi, TAdynmemStructPtr
    mov     [esp+2Ch+var_10], 1

    loc_48C568:                             ; CODE XREF: sub_48C390+190j
                                            ; sub_48C390+196j ...
    mov     eax, [ecx+110h]
    shr     eax, 4
    test    al, 1
    jz      short loc_48C582
    mov     eax, [esp+2Ch+arg_0]
    mov     [esp+2Ch+var_4], ecx
    inc     eax
    mov     [esp+2Ch+arg_0], eax

    loc_48C582:                             ; CODE XREF: sub_48C390+120j
                                            ; sub_48C390+137j ...
    mov     edx, [esp+2Ch+var_8]
    add     ecx, 118h
    cmp     ecx, [edx+6Bh]
    jbe     loc_48C4A7
    mov     ebp, [esp+2Ch+arg_0]

    loc_48C599:                             ; CODE XREF: sub_48C390+111j
    mov     word ptr [esi+37E9Ch], 0
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+14357h]
    mov     ecx, [edx+1435Bh]
    cmp     eax, ecx
    ja      short loc_48C5DB
    mov     ecx, 0FFFFFF3Fh

    loc_48C5BD:                             ; CODE XREF: sub_48C390+249j
    mov     ebx, [eax+110h]
    add     eax, 118h
    and     ebx, ecx
    mov     [eax-8], ebx
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+1435Bh]
    jbe     short loc_48C5BD

    loc_48C5DB:                             ; CODE XREF: sub_48C390+226j
    mov     eax, [edx+14367h]
    mov     esi, [edx+1435Fh]
    xor     edi, edi
    test    eax, eax
    jle     short loc_48C63B

    loc_48C5ED:                             ; CODE XREF: sub_48C390+2A9j
    xor     ecx, ecx
    mov     bl, [edx+2A42h]
    mov     cx, [esi]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]
    mov     cl, [eax+0FFh]
    cmp     cl, bl
    jnz     short loc_48C62D
    mov     edx, [eax+110h]
    and     dl, 7Fh
    or      edx, 40h
    mov     [eax+110h], edx
    mov     edx, TAdynmemStructPtr

    loc_48C62D:                             ; CODE XREF: sub_48C390+283j
    mov     eax, [edx+14367h]
    inc     edi
    add     esi, 2
    cmp     edi, eax
    jl      short loc_48C5ED

    loc_48C63B:                             ; CODE XREF: sub_48C390+25Bj
    mov     eax, [esp+2Ch+var_10]
    test    eax, eax
    jz      short loc_48C64A
    or      byte ptr [edx+37EBEh], 10h

    loc_48C64A:                             ; CODE XREF: sub_48C390+2B1j
    test    ebp, ebp
    jnz     short loc_48C65A
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48C65A:                             ; CODE XREF: sub_48C390+2BCj
    cmp     ebp, 1
    push    0
    jnz     short loc_48C67C
    mov     eax, [esp+30h+var_4]
    push    1
    push    eax
    call    sub_47F780
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    4                               ; int
    ; ---------------------------------------------------------------------------

    loc_48C67C:                             ; CODE XREF: sub_48C390+2CFj
    push    offset aSelectmultiple          ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 1Ch
    retn    4
    sub_48C390 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48C6A0 proc near                    ; CODE XREF: sub_48CD80+95p

    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_30= dword ptr -30h
    var_28= dword ptr -28h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 88h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+94h+arg_0]
    push    edi
    lea     eax, [esp+98h+var_38]
    push    0
    push    eax
    mov     eax, TAdynmemStructPtr
    lea     ecx, [esp+0A0h+var_74]
    xor     edx, edx
    push    ecx
    mov     dx, [esi+0A6h]
    mov     ecx, [eax+14377h]
    mov     edx, [ecx+edx*4]
    push    edx
    call    sub_4CB650
    mov     edi, [esp+98h+var_38]
    mov     ebx, [esi+6Ah]
    mov     eax, [esp+98h+var_70]
    mov     edx, [esp+98h+var_6C]
    mov     ecx, [esp+98h+var_74]
    mov     ebp, [esi+72h]
    mov     [esp+98h+var_64], eax
    mov     [esp+98h+var_60], edx
    mov     [esp+98h+var_58], eax
    mov     [esp+98h+var_54], edx
    mov     edx, [esp+98h+var_30]
    mov     [esp+98h+var_4C], eax
    mov     [esp+98h+var_40], eax
    mov     eax, TAdynmemStructPtr
    mov     [esp+98h+var_68], ecx
    mov     [esp+98h+var_5C], edi
    mov     [esp+98h+var_50], edi
    mov     [esp+98h+var_48], edx
    mov     [esp+98h+var_44], ecx
    mov     [esp+98h+var_3C], edx
    mov     ecx, [eax+1431Fh]
    mov     eax, [eax+14323h]
    mov     edx, [esi+6Eh]
    lea     edi, [esp+98h+var_68]
    shl     ecx, 10h
    shl     eax, 10h
    sub     ebx, ecx
    sub     ebp, eax
    add     esi, 64h
    mov     [esp+98h+var_28], edx
    mov     [esp+98h+var_84], esi
    lea     esi, [esp+98h+var_1C]
    mov     [esp+98h+var_88], 4

    loc_48C75D:                             ; CODE XREF: sub_48C6A0+119j
    mov     ecx, [esp+98h+var_84]
    lea     edx, [esp+98h+var_80]
    push    ecx
    push    edx
    push    edi
    call    sub_4B6CC0
    add     edi, 0Ch
    add     esi, 8
    mov     eax, [esp+98h+var_80]
    mov     edx, [esp+98h+var_7C]
    add     eax, ebx
    sar     eax, 10h
    movsx   ecx, ax
    mov     eax, [esp+98h+var_28]
    add     ecx, 80h
    add     edx, eax
    mov     eax, [esp+98h+var_78]
    sar     edx, 10h
    mov     [esi-0Ch], ecx
    movsx   ecx, dx
    mov     edx, ebp
    sub     edx, eax
    sar     edx, 10h
    movsx   eax, dx
    sar     ecx, 1
    sub     eax, ecx
    add     eax, 20h
    mov     [esi-8], eax
    mov     eax, [esp+98h+var_88]
    dec     eax
    mov     [esp+98h+var_88], eax
    jnz     short loc_48C75D
    mov     eax, [esp+98h+arg_4]
    mov     ecx, [eax+4]
    mov     edx, [eax]
    push    ecx
    push    edx
    lea     eax, [esp+0A0h+var_20]
    push    4
    push    eax
    call    sub_4C1320
    neg     eax
    pop     edi
    pop     esi
    sbb     eax, eax
    pop     ebp
    neg     eax
    pop     ebx
    add     esp, 88h
    retn    8
    sub_48C6A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48C7F0 proc near                    ; CODE XREF: sub_498F70+C7p

    arg_0= dword ptr  4

    mov     edx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ax, [edx+2CBAh]
    push    edi
    test    ax, ax
    jnz     short loc_48C80A
    xor     ebp, ebp
    jmp     short loc_48C822
    ; ---------------------------------------------------------------------------

    loc_48C80A:                             ; CODE XREF: sub_48C7F0+14j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     ebp, [ecx+eax*8]

    loc_48C822:                             ; CODE XREF: sub_48C7F0+18j
    test    ebp, ebp
    jz      loc_48C9A8
    mov     al, [ebp+0FFh]
    mov     cl, [edx+2A42h]
    cmp     al, cl
    jnz     loc_48C9A8
    mov     ecx, [ebp+110h]
    test    cl, 20h
    jz      loc_48C9A8
    fld     dword ptr [ebp+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      loc_48C9A8
    mov     eax, [ebp+0FBh]
    test    eax, eax
    jnz     loc_48C9A8
    mov     eax, [ebp+86h]
    test    eax, eax
    jz      short loc_48C88C
    test    dword ptr [eax+110h], 40000000h
    jz      loc_48C9A8

    loc_48C88C:                             ; CODE XREF: sub_48C7F0+8Aj
    mov     eax, [esp+10h+arg_0]
    test    byte ptr [eax+8], 4
    jz      short loc_48C8DF
    mov     edx, ecx
    mov     eax, ecx
    not     edx
    xor     eax, edx
    mov     esi, 10h
    and     eax, esi
    xor     eax, ecx
    mov     [ebp+110h], eax
    shr     eax, 4
    test    al, 1
    jz      short loc_48C8BE
    push    0
    push    1
    push    ebp
    call    sub_47F780

    loc_48C8BE:                             ; CODE XREF: sub_48C7F0+C2j
    mov     eax, TAdynmemStructPtr
    mov     word ptr [eax+37E9Ch], 0
    mov     eax, TAdynmemStructPtr
    or      [eax+37EBEh], si
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48C8DF:                             ; CODE XREF: sub_48C7F0+A4j
    mov     eax, [edx+14357h]
    mov     ecx, [edx+1435Bh]
    cmp     eax, ecx
    ja      short loc_48C912
    mov     ecx, 0FFFFFF2Fh

    loc_48C8F4:                             ; CODE XREF: sub_48C7F0+120j
    mov     ebx, [eax+110h]
    add     eax, 118h
    and     ebx, ecx
    mov     [eax-8], ebx
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+1435Bh]
    jbe     short loc_48C8F4

    loc_48C912:                             ; CODE XREF: sub_48C7F0+FDj
    push    0
    call    sub_491D70
    mov     edx, TAdynmemStructPtr
    xor     edi, edi
    mov     eax, [edx+14367h]
    mov     esi, [edx+1435Fh]
    test    eax, eax
    jle     short loc_48C97F

    loc_48C931:                             ; CODE XREF: sub_48C7F0+18Dj
    xor     ecx, ecx
    mov     bl, [edx+2A42h]
    mov     cx, [esi]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]
    mov     cl, [eax+0FFh]
    cmp     cl, bl
    jnz     short loc_48C971
    mov     edx, [eax+110h]
    and     dl, 7Fh
    or      edx, 40h
    mov     [eax+110h], edx
    mov     edx, TAdynmemStructPtr

    loc_48C971:                             ; CODE XREF: sub_48C7F0+167j
    mov     eax, [edx+14367h]
    inc     edi
    add     esi, 2
    cmp     edi, eax
    jl      short loc_48C931

    loc_48C97F:                             ; CODE XREF: sub_48C7F0+13Fj
    mov     eax, [ebp+110h]
    mov     esi, 10h
    push    0
    or      eax, esi
    push    1
    push    ebp
    mov     [ebp+110h], eax
    call    sub_47F780
    mov     eax, TAdynmemStructPtr
    or      [eax+37EBEh], si

    loc_48C9A8:                             ; CODE XREF: sub_48C7F0+34j
                                            ; sub_48C7F0+48j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_48C7F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48C9B0 proc near                    ; CODE XREF: sub_48AB70+1B5p

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    mov     ecx, [edx+110h]
    test    cl, 10h
    jz      short locret_48CA1A
    test    cl, 20h
    jz      short loc_48C9F7
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48C9F7
    mov     eax, [edx+0FBh]
    test    eax, eax
    jnz     short loc_48C9F7
    mov     eax, [edx+86h]
    test    eax, eax
    jz      short locret_48CA1A
    test    dword ptr [eax+110h], 40000000h
    jnz     short locret_48CA1A

    loc_48C9F7:                             ; CODE XREF: sub_48C9B0+12j
                                            ; sub_48C9B0+25j ...
    and     ecx, 0FFFFFFEFh
    mov     [edx+110h], ecx
    mov     eax, TAdynmemStructPtr
    mov     word ptr [eax+37E9Ch], 0
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37EBEh], 10h

    locret_48CA1A:                          ; CODE XREF: sub_48C9B0+Dj
                                            ; sub_48C9B0+39j ...
    retn    4
    sub_48C9B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48CA20 proc near                    ; CODE XREF: sub_4933E0+21p
                                            ; .text:00496436p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+14h+arg_0]
    push    edi
    mov     edx, [esi+8]
    mov     ecx, [esi+4]
    cmp     edx, edx
    mov     eax, edx
    jz      short loc_48CA45

    loc_48CA37:                             ; CODE XREF: sub_48CA20+23j
    mov     edi, [eax]
    add     eax, 4
    mov     [ecx], edi
    add     ecx, 4
    cmp     eax, edx
    jnz     short loc_48CA37

    loc_48CA45:                             ; CODE XREF: sub_48CA20+15j
    mov     eax, [esi+8]
    mov     [esi+8], ecx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     [esp+18h+var_4], eax
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     ebx, [ecx+eax*2+1B63h]
    mov     [esp+18h+var_4], ebx
    mov     eax, [ebx+67h]
    mov     [esp+18h+arg_0], eax
    mov     ecx, [ebx+6Bh]
    cmp     eax, ecx
    ja      loc_48CC17

    loc_48CA86:                             ; CODE XREF: sub_48CA20+1F1j
    mov     ecx, [eax+110h]
    shr     ecx, 4
    test    cl, 1
    jz      loc_48CBFF
    mov     eax, [esi+8]
    mov     edx, [esi+0Ch]
    sub     edx, eax
    mov     edi, eax
    sar     edx, 2
    cmp     edx, 1
    jnb     loc_48CB6F
    mov     edx, [esi+4]
    test    edx, edx
    jnz     short loc_48CAB9
    xor     ecx, ecx
    jmp     short loc_48CAC0
    ; ---------------------------------------------------------------------------

    loc_48CAB9:                             ; CODE XREF: sub_48CA20+93j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2

    loc_48CAC0:                             ; CODE XREF: sub_48CA20+97j
    cmp     ecx, 1
    jbe     short loc_48CAD6
    test    edx, edx
    jnz     short loc_48CACD
    xor     ecx, ecx
    jmp     short loc_48CADB
    ; ---------------------------------------------------------------------------

    loc_48CACD:                             ; CODE XREF: sub_48CA20+A7j
    mov     ecx, eax
    sub     ecx, edx
    sar     ecx, 2
    jmp     short loc_48CADB
    ; ---------------------------------------------------------------------------

    loc_48CAD6:                             ; CODE XREF: sub_48CA20+A3j
    mov     ecx, 1

    loc_48CADB:                             ; CODE XREF: sub_48CA20+ABj
                                            ; sub_48CA20+B4j
    test    edx, edx
    jnz     short loc_48CAE3
    xor     eax, eax
    jmp     short loc_48CAE8
    ; ---------------------------------------------------------------------------

    loc_48CAE3:                             ; CODE XREF: sub_48CA20+BDj
    sub     eax, edx
    sar     eax, 2

    loc_48CAE8:                             ; CODE XREF: sub_48CA20+C1j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_8], eax
    jge     short loc_48CAF4
    xor     eax, eax

    loc_48CAF4:                             ; CODE XREF: sub_48CA20+D0j
    shl     eax, 2
    push    eax                             ; int
    call    sub_4B4F10
    mov     ecx, [esi+4]
    add     esp, 4
    mov     ebx, eax
    push    ebx
    push    edi
    push    ecx
    mov     ecx, esi
    call    sub_406C10
    lea     edx, [esp+18h+arg_0]
    mov     ebp, eax
    push    edx
    push    1
    push    ebp
    mov     ecx, esi
    call    sub_406C40
    mov     eax, [esi+8]
    add     ebp, 4
    push    ebp
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     ecx, [esi+8]
    mov     edx, [esi+4]
    push    ecx
    push    edx
    mov     ecx, esi
    call    nullsub_1
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+1Ch+var_8]
    add     esp, 4
    lea     ecx, [ebx+eax*4]
    mov     [esi+0Ch], ecx
    mov     ecx, esi
    call    sub_40C560
    lea     edx, [ebx+eax*4+4]
    mov     [esi+4], ebx
    mov     ebx, [esp+18h+var_4]
    mov     [esi+8], edx
    jmp     loc_48CBFF
    ; ---------------------------------------------------------------------------

    loc_48CB6F:                             ; CODE XREF: sub_48CA20+88j
    mov     ecx, eax
    sub     ecx, edi
    sar     ecx, 2
    cmp     ecx, 1
    jnb     short loc_48CBBD
    lea     ecx, [edi+4]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+8]
    lea     edx, [esp+18h+arg_0]
    mov     ecx, eax
    push    edx
    sub     ecx, edi
    mov     edx, 1
    sar     ecx, 2
    sub     edx, ecx
    mov     ecx, esi
    push    edx
    push    eax
    call    sub_406C40
    mov     eax, [esi+8]
    cmp     edi, eax
    jz      short loc_48CBFB

    loc_48CBAE:                             ; CODE XREF: sub_48CA20+199j
    mov     ecx, [esp+18h+arg_0]
    mov     [edi], ecx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_48CBAE
    jmp     short loc_48CBFB
    ; ---------------------------------------------------------------------------

    loc_48CBBD:                             ; CODE XREF: sub_48CA20+159j
    lea     ecx, [eax-4]
    push    eax
    push    eax
    mov     [esp+20h+var_8], ecx
    push    ecx
    mov     ecx, esi
    call    sub_406C10
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_48CBE7

    loc_48CBD8:                             ; CODE XREF: sub_48CA20+1C5j
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_48CBD8

    loc_48CBE7:                             ; CODE XREF: sub_48CA20+1B6j
    lea     eax, [edi+4]
    cmp     edi, eax
    jz      short loc_48CBFB

    loc_48CBEE:                             ; CODE XREF: sub_48CA20+1D9j
    mov     ecx, [esp+18h+arg_0]
    mov     [edi], ecx
    add     edi, 4
    cmp     edi, eax
    jnz     short loc_48CBEE

    loc_48CBFB:                             ; CODE XREF: sub_48CA20+18Cj
                                            ; sub_48CA20+19Bj ...
    add     dword ptr [esi+8], 4

    loc_48CBFF:                             ; CODE XREF: sub_48CA20+72j
                                            ; sub_48CA20+14Aj
    mov     eax, [esp+18h+arg_0]
    add     eax, 118h
    mov     [esp+18h+arg_0], eax
    mov     ecx, [ebx+6Bh]
    cmp     eax, ecx
    jbe     loc_48CA86

    loc_48CC17:                             ; CODE XREF: sub_48CA20+60j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_48CA20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48CC30 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+F0Cp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    ebx
    push    ebp
    mov     cl, [edx+TAdynmemStruct.SharedBits]
    push    esi
    mov     eax, ecx
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    push    edi
    lea     eax, [eax+eax*4]
    lea     ebp, [esi+eax*2+TAdynmemStruct.Players]
    mov     ax, [edx+37E9Ch]
    test    ax, ax
    mov     [esp+14h+var_4], ebp
    jnz     short loc_48CC6C
    xor     esi, esi
    jmp     short loc_48CC84
    ; ---------------------------------------------------------------------------

    loc_48CC6C:                             ; CODE XREF: sub_48CC30+36j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, [edx+TAdynmemStruct.Units]
    lea     esi, [eax+ecx*8]

    loc_48CC84:                             ; CODE XREF: sub_48CC30+3Aj
    mov     ax, [edx+TAdynmemStruct.MouseOverUnit]
    test    ax, ax
    jnz     short loc_48CC94
    xor     ecx, ecx
    jmp     short loc_48CCAC
    ; ---------------------------------------------------------------------------

    loc_48CC94:                             ; CODE XREF: sub_48CC30+5Ej
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, [edx+TAdynmemStruct.Units]
    lea     ecx, [eax+ecx*8]

    loc_48CCAC:                             ; CODE XREF: sub_48CC30+62j
    mov     edi, [esp+14h+arg_4]
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_48CCC6
    mov     eax, [eax+UnitStruct.UnitType]
    mov     ebx, [eax+156h]
    test    ebx, ebx
    jnz     short loc_48CCEE

    loc_48CCC6:                             ; CODE XREF: sub_48CC30+84j
    test    esi, esi
    jz      short loc_48CCDA
    mov     eax, [esi+UnitStruct.UnitType]
    mov     esi, [eax+156h]
    test    esi, esi
    jnz     short loc_48CCEE

    loc_48CCDA:                             ; CODE XREF: sub_48CC30+98j
    test    ecx, ecx
    jz      short loc_48CCF2
    mov     ecx, [ecx+92h]
    mov     eax, [ecx+156h]
    test    eax, eax
    jz      short loc_48CCF2

    loc_48CCEE:                             ; CODE XREF: sub_48CC30+94j
                                            ; sub_48CC30+A8j
    mov     bl, 1
    jmp     short loc_48CCF4
    ; ---------------------------------------------------------------------------

    loc_48CCF2:                             ; CODE XREF: sub_48CC30+ACj
                                            ; sub_48CC30+BCj
    xor     bl, bl

    loc_48CCF4:                             ; CODE XREF: sub_48CC30+C0j
    mov     esi, [ebp+PlayerStruct.Units]
    mov     eax, [ebp+PlayerStruct.Units_End]
    cmp     esi, eax
    ja      short loc_48CD6B
    mov     ebp, [esp+14h+arg_0]

    loc_48CD02:                             ; CODE XREF: sub_48CC30+139j
    mov     ecx, [esi+110h]
    test    ecx, 10000000h
    jz      short loc_48CD5C
    test    ch, 40h
    jnz     short loc_48CD5C
    cmp     esi, [edi]
    jz      short loc_48CD4A
    mov     ax, [esi+0A8h]
    cmp     ax, [edx+37E9Ch]
    jz      short loc_48CD4A
    cmp     ax, [edx+TAdynmemStruct.MouseOverUnit]
    jz      short loc_48CD4A
    shr     ecx, 4
    test    cl, 1
    jz      short loc_48CD3E
    push    0
    jmp     short loc_48CD4C
    ; ---------------------------------------------------------------------------

    loc_48CD3E:                             ; CODE XREF: sub_48CC30+108j
    test    bl, bl
    jz      short loc_48CD5C
    push    1
    push    edi
    push    ebp
    push    1
    jmp     short loc_48CD50
    ; ---------------------------------------------------------------------------

    loc_48CD4A:                             ; CODE XREF: sub_48CC30+E7j
                                            ; sub_48CC30+F7j ...
    push    1

    loc_48CD4C:                             ; CODE XREF: sub_48CC30+10Cj
    push    edi
    push    ebp
    push    1Fh

    loc_48CD50:                             ; CODE XREF: sub_48CC30+118j
    push    esi
    call    sub_439B30
    mov     edx, TAdynmemStructPtr

    loc_48CD5C:                             ; CODE XREF: sub_48CC30+DEj
                                            ; sub_48CC30+E3j ...
    mov     eax, [esp+14h+var_4]
    add     esi, 118h
    cmp     esi, [eax+6Bh]
    jbe     short loc_48CD02

    loc_48CD6B:                             ; CODE XREF: sub_48CC30+CCj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_48CC30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48CD80 proc near                    ; CODE XREF: .text:00491D18p
                                            ; .text:00499278p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+2C7Ah]
    mov     edx, [eax+2C76h]
    lea     esi, [eax+2C76h]
    push    edi
    push    ecx
    add     eax, 37E27h
    xor     edi, edi
    push    edx
    push    eax
    mov     [esp+28h+var_8], esi
    mov     [esp+28h+var_C], edi
    call    sub_4B6720
    test    eax, eax
    jz      loc_48CEAA
    mov     edx, TAdynmemStructPtr
    mov     ebx, 7FFF0000h
    mov     ebp, [edx+1435Fh]
    cmp     ebp, edi
    jnz     short loc_48CDDD
    xor     ax, ax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_48CDDD:                             ; CODE XREF: sub_48CD80+50j
    mov     eax, [edx+14367h]
    mov     [esp+1Ch+var_4], edi
    cmp     eax, edi
    jle     loc_48CF1F

    loc_48CDEF:                             ; CODE XREF: sub_48CD80+117j
    xor     ecx, ecx
    mov     cx, [ebp+0]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*8+0A6h], 0
    lea     edi, [ecx+eax*8]
    jz      short loc_48CE83
    push    esi
    push    edi
    call    sub_48C6A0
    test    eax, eax
    jz      short loc_48CE7D
    mov     esi, [edi+92h]
    push    0
    push    8000h
    mov     eax, [esi+17Ah]
    cdq
    push    edx
    push    eax
    call    __allmul
    mov     ecx, 10h
    call    __allshr
    mov     edx, [esi+17Eh]
    mov     ecx, 10h
    add     eax, edx
    imul    dword ptr [esi+176h]
    call    __allshr
    cmp     eax, ebx
    jge     short loc_48CE79
    mov     dx, [edi+0A8h]
    mov     esi, [esp+1Ch+var_8]
    mov     word ptr [esp+1Ch+var_C], dx
    mov     edx, TAdynmemStructPtr
    mov     ebx, eax
    jmp     short loc_48CE83
    ; ---------------------------------------------------------------------------

    loc_48CE79:                             ; CODE XREF: sub_48CD80+DDj
    mov     esi, [esp+1Ch+var_8]

    loc_48CE7D:                             ; CODE XREF: sub_48CD80+9Cj
    mov     edx, TAdynmemStructPtr

    loc_48CE83:                             ; CODE XREF: sub_48CD80+91j
                                            ; sub_48CD80+F7j
    mov     eax, [esp+1Ch+var_4]
    mov     ecx, [edx+14367h]
    inc     eax
    add     ebp, 2
    cmp     eax, ecx
    mov     [esp+1Ch+var_4], eax
    jl      loc_48CDEF
    mov     ax, word ptr [esp+1Ch+var_C]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_48CEAA:                             ; CODE XREF: sub_48CD80+37j
    mov     eax, [esi+4]
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esi]
    push    eax
    add     edx, 142BBh
    push    ecx
    push    edx
    call    sub_4B6720
    test    eax, eax
    jz      short loc_48CF1F
    mov     eax, TAdynmemStructPtr
    mov     ebx, 1869Fh
    mov     edx, [eax+14363h]
    mov     eax, [eax+1436Bh]
    cmp     eax, edi
    jle     short loc_48CF1F
    mov     edi, [esi+4]
    mov     esi, [esi]
    mov     [esp+1Ch+var_4], eax

    loc_48CEEA:                             ; CODE XREF: sub_48CD80+19Dj
    mov     ecx, [edx+6]
    mov     eax, [edx+2]
    sub     ecx, edi
    sub     eax, esi
    mov     ebp, ecx
    imul    eax, eax
    imul    ebp, ecx
    add     eax, ebp
    cmp     eax, 4
    jge     short loc_48CF11
    cmp     eax, ebx
    jge     short loc_48CF11
    mov     ebx, eax
    mov     ax, [edx]
    mov     word ptr [esp+1Ch+var_C], ax

    loc_48CF11:                             ; CODE XREF: sub_48CD80+181j
                                            ; sub_48CD80+185j
    mov     eax, [esp+1Ch+var_4]
    add     edx, 0Ah
    dec     eax
    mov     [esp+1Ch+var_4], eax
    jnz     short loc_48CEEA

    loc_48CF1F:                             ; CODE XREF: sub_48CD80+69j
                                            ; sub_48CD80+145j ...
    mov     ax, word ptr [esp+1Ch+var_C]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_48CD80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48CF30 proc near                    ; CODE XREF: .text:00416366p
                                            ; sub_419BE0+10Dp ...

    var_32= dword ptr -32h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 34h
    mov     eax, [esp+34h+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+8]
    xor     esi, esi
    shr     eax, 2
    and     eax, 1
    push    edi
    mov     [esp+44h+var_2C], eax
    mov     eax, [esp+44h+arg_4]
    test    al, al
    mov     [esp+44h+var_32+2], esi
    jz      short loc_48CF5E
    push    eax
    call    sub_43E470
    jmp     short loc_48CF70
    ; ---------------------------------------------------------------------------

    loc_48CF5E:                             ; CODE XREF: sub_48CF30+24j
    lea     ecx, [esp+44h+arg_8]
    call    sub_438830
    mov     eax, [eax+11h]
    shr     eax, 9
    and     eax, 1

    loc_48CF70:                             ; CODE XREF: sub_48CF30+2Cj
    mov     edx, TAdynmemStructPtr
    cmp     eax, esi
    jz      short loc_48CFA8
    mov     ax, [edx+2CBAh]
    cmp     ax, si
    jnz     short loc_48CF8C
    mov     [esp+44h+var_32+2], esi
    jmp     short loc_48CFA8
    ; ---------------------------------------------------------------------------

    loc_48CF8C:                             ; CODE XREF: sub_48CF30+54j
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [eax+eax*4]
    mov     eax, [edx+14357h]
    lea     ecx, [eax+ecx*8]
    mov     [esp+44h+var_32+2], ecx

    loc_48CFA8:                             ; CODE XREF: sub_48CF30+48j
                                            ; sub_48CF30+5Aj
    xor     ecx, ecx
    xor     edi, edi
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ebx, [edx+eax*2+1BCAh]
    mov     ebp, [edx+eax*2+1BCEh]
    lea     edx, [edx+eax*2+1B63h]
    mov     ecx, ebx
    xor     eax, eax
    cmp     ecx, ebp
    mov     [esp+44h+var_24], edx
    ja      short loc_48D00F

    loc_48CFDF:                             ; CODE XREF: sub_48CF30+DDj
    test    byte ptr [ecx+110h], 10h
    jz      short loc_48D005
    cmp     ecx, [esp+44h+var_32+2]
    jz      short loc_48D005
    mov     edx, [ecx+6Ah]
    inc     edi
    sar     edx, 10h
    movsx   edx, dx
    add     eax, edx
    mov     edx, [ecx+72h]
    sar     edx, 10h
    movsx   edx, dx
    add     esi, edx

    loc_48D005:                             ; CODE XREF: sub_48CF30+B6j
                                            ; sub_48CF30+BCj
    add     ecx, 118h
    cmp     ecx, ebp
    jbe     short loc_48CFDF

    loc_48D00F:                             ; CODE XREF: sub_48CF30+ADj
    test    edi, edi
    jz      loc_48D20C
    cdq
    idiv    edi
    mov     [esp+44h+arg_0], eax
    fild    [esp+44h+arg_0]
    fmul    ds:dbl_4FD760
    call    __ftol
    mov     [esp+44h+var_18], eax
    mov     eax, esi
    cdq
    idiv    edi
    mov     [esp+44h+arg_0], eax
    fild    [esp+44h+arg_0]
    fmul    ds:dbl_4FD760
    call    __ftol
    mov     [esp+44h+var_10], eax
    lea     eax, [edi+edi*2]
    mov     esi, ebx
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 3
    cmp     esi, ebp
    mov     [esp+44h+var_28], eax
    ja      loc_48D20C

    loc_48D06A:                             ; CODE XREF: sub_48CF30+2D6j
    test    byte ptr [esi+110h], 10h
    jz      loc_48D1F9
    mov     edi, [esp+44h+var_32+2]
    cmp     esi, edi
    jz      loc_48D1F9
    mov     eax, [esp+44h+arg_4]
    test    al, al
    jz      short loc_48D0AB
    mov     ecx, TAdynmemStructPtr
    lea     edx, [esp+44h+var_32+1]
    add     ecx, 2CAAh
    push    ecx
    push    edi
    push    esi
    push    eax
    push    edx
    call    sub_43F0E0
    mov     al, [eax]
    mov     byte ptr [esp+44h+arg_8], al

    loc_48D0AB:                             ; CODE XREF: sub_48CF30+159j
    mov     al, byte ptr [esp+44h+arg_8]
    test    al, al
    jz      loc_48D1F9
    push    offset aStanding_fireo          ; char *
    lea     ecx, [esp+48h+arg_0]
    call    sub_438760
    mov     cl, byte ptr [esp+44h+arg_8]
    mov     al, byte ptr [esp+44h+arg_0]
    cmp     cl, al
    jnz     short loc_48D0E4
    mov     edx, [esi+92h]
    test    byte ptr [edx+245h], 2
    jz      loc_48D1F9

    loc_48D0E4:                             ; CODE XREF: sub_48CF30+19Fj
    push    offset aStanding_moveo          ; char *
    lea     ecx, [esp+48h+var_32]
    call    sub_438760
    mov     al, byte ptr [esp+44h+arg_8]
    mov     cl, byte ptr [esp+44h+var_32]
    cmp     al, cl
    jnz     short loc_48D111
    mov     ecx, [esi+92h]
    test    byte ptr [ecx+245h], 1
    jz      loc_48D1F9

    loc_48D111:                             ; CODE XREF: sub_48CF30+1CCj
    mov     eax, [esp+44h+arg_C]
    test    eax, eax
    jz      loc_48D1D9
    lea     ecx, [esp+44h+arg_8]
    call    sub_438830
    test    byte ptr [eax+11h], 2
    jz      loc_48D1D9
    mov     eax, [esi+6Ah]
    mov     edi, [esp+44h+var_18]
    mov     ecx, [esi+72h]
    mov     ebx, [esp+44h+var_10]
    sub     eax, edi
    sub     ecx, ebx
    cdq
    mov     edi, eax
    mov     ebp, edx
    mov     eax, ecx
    push    ebp
    cdq
    push    edi
    push    ebp
    push    edi
    mov     ebx, eax
    mov     [esp+54h+var_1C], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edi, eax
    mov     eax, [esp+44h+var_1C]
    push    eax
    push    ebx
    push    eax
    push    ebx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     edi, eax
    mov     eax, [esp+44h+var_28]
    cmp     edi, eax
    jg      short loc_48D1D5
    mov     eax, [esp+44h+arg_C]
    mov     ecx, [esi+6Ah]
    mov     ebp, [esp+44h+var_18]
    mov     ebx, [esi+72h]
    mov     edx, [eax]
    mov     edi, [esp+44h+var_10]
    add     edx, ecx
    mov     ecx, [eax+4]
    sub     edx, ebp
    mov     [esp+44h+var_8], ecx
    mov     ecx, [esp+44h+arg_10]
    mov     [esp+44h+var_C], edx
    mov     edx, [eax+8]
    mov     eax, [esp+44h+arg_14]
    add     edx, ebx
    push    eax
    mov     eax, [esp+48h+var_32+2]
    sub     edx, edi
    mov     [esp+48h+var_4], edx
    lea     edx, [esp+48h+var_C]
    push    ecx
    mov     ecx, [esp+4Ch+var_2C]
    push    edx
    mov     edx, [esp+50h+arg_8]
    push    eax
    push    esi
    push    ecx
    push    edx
    jmp     short loc_48D1F4
    ; ---------------------------------------------------------------------------

    loc_48D1D5:                             ; CODE XREF: sub_48CF30+254j
    mov     edi, [esp+44h+var_32+2]

    loc_48D1D9:                             ; CODE XREF: sub_48CF30+1E7j
                                            ; sub_48CF30+1FAj
    mov     eax, [esp+44h+arg_14]
    mov     ecx, [esp+44h+arg_10]
    mov     edx, [esp+44h+arg_C]
    push    eax
    mov     eax, [esp+48h+var_2C]
    push    ecx
    mov     ecx, [esp+4Ch+arg_8]
    push    edx
    push    edi
    push    esi
    push    eax
    push    ecx

    loc_48D1F4:                             ; CODE XREF: sub_48CF30+2A3j
    call    sub_43AFC0

    loc_48D1F9:                             ; CODE XREF: sub_48CF30+141j
                                            ; sub_48CF30+14Dj ...
    mov     edx, [esp+44h+var_24]
    add     esi, 118h
    cmp     esi, [edx+6Bh]
    jbe     loc_48D06A

    loc_48D20C:                             ; CODE XREF: sub_48CF30+E1j
                                            ; sub_48CF30+134j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    18h
    sub_48CF30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48D220 proc near                    ; CODE XREF: .text:00491D36p
                                            ; .text:00499297p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= byte ptr  4

    mov     edx, TAdynmemStructPtr
    sub     esp, 14h
    mov     ax, [edx+2CBAh]
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     edi, edi
    cmp     ax, di
    jz      short loc_48D255
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    lea     ebp, [ecx+eax*8]
    jmp     short loc_48D257
    ; ---------------------------------------------------------------------------

    loc_48D255:                             ; CODE XREF: sub_48D220+19j
    xor     ebp, ebp

    loc_48D257:                             ; CODE XREF: sub_48D220+33j
    mov     dl, [esp+24h+arg_0]
    push    edi
    push    edi
    lea     ecx, [esp+2Ch+var_10]
    mov     byte ptr [esp+2Ch+var_10], dl
    mov     [esp+2Ch+var_C], edi
    mov     [esp+2Ch+var_8], edi
    mov     [esp+2Ch+var_4], edi
    call    sub_40C9F0
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     esi, ecx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     esi, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     esi, [esi+eax*2+1B63h]
    mov     eax, [esi+67h]
    mov     [esp+24h+var_14], eax
    mov     edx, [esi+6Bh]
    cmp     eax, edx
    ja      short loc_48D2E2

    loc_48D2A7:                             ; CODE XREF: sub_48D220+C0j
    mov     edx, [eax+110h]
    shr     edx, 4
    test    dl, 1
    jz      short loc_48D2D2
    mov     ecx, [esp+24h+var_8]
    lea     eax, [esp+24h+var_14]
    push    eax
    push    ecx
    lea     ecx, [esp+2Ch+var_10]
    call    sub_48DDC0
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+24h+var_14]

    loc_48D2D2:                             ; CODE XREF: sub_48D220+93j
    add     eax, 118h
    mov     [esp+24h+var_14], eax
    mov     edx, [esi+6Bh]
    cmp     eax, edx
    jbe     short loc_48D2A7

    loc_48D2E2:                             ; CODE XREF: sub_48D220+85j
    cmp     ebp, edi
    jz      short loc_48D2F6
    push    ebp
    lea     ecx, [esp+28h+var_10]
    call    sub_480100
    mov     ecx, TAdynmemStructPtr

    loc_48D2F6:                             ; CODE XREF: sub_48D220+C4j
    mov     esi, [esp+24h+var_C]
    mov     edx, [esp+24h+var_8]
    cmp     esi, edi
    jnz     short loc_48D306
    xor     eax, eax
    jmp     short loc_48D30D
    ; ---------------------------------------------------------------------------

    loc_48D306:                             ; CODE XREF: sub_48D220+E0j
    mov     eax, edx
    sub     eax, esi
    sar     eax, 2

    loc_48D30D:                             ; CODE XREF: sub_48D220+E4j
    xor     ebx, ebx
    test    eax, eax
    setz    bl
    test    bl, bl
    jz      loc_48D3C1
    cmp     [esp+24h+arg_0], 1
    jnz     short loc_48D39A
    test    ebp, ebp
    jz      short loc_48D39A
    mov     al, [ebp+0FFh]
    mov     bl, [ecx+2A42h]
    cmp     al, bl
    jnz     short loc_48D39A
    test    byte ptr [ebp+110h], 20h
    jz      short loc_48D39A
    fld     dword ptr [ebp+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48D39A
    mov     eax, [ebp+0FBh]
    test    eax, eax
    jnz     short loc_48D39A
    mov     eax, [ebp+86h]
    test    eax, eax
    jz      short loc_48D373
    test    dword ptr [eax+110h], 40000000h
    jz      short loc_48D39A

    loc_48D373:                             ; CODE XREF: sub_48D220+145j
    push    edx
    push    esi
    lea     ecx, [esp+2Ch+var_10]
    call    nullsub_1
    mov     ecx, [esp+24h+var_C]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 0Fh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48D39A:                             ; CODE XREF: sub_48D220+101j
                                            ; sub_48D220+105j ...
    push    edx
    push    esi
    lea     ecx, [esp+2Ch+var_10]
    call    nullsub_1
    mov     edx, [esp+24h+var_C]
    push    edx
    call    sub_4B4F20
    add     esp, 4
    mov     eax, 13h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48D3C1:                             ; CODE XREF: sub_48D220+F6j
    cmp     esi, edx
    mov     edi, 13h
    jz      short loc_48D3FE
    jmp     short loc_48D3D2
    ; ---------------------------------------------------------------------------

    loc_48D3CC:                             ; CODE XREF: sub_48D220+1D8j
    mov     ecx, TAdynmemStructPtr

    loc_48D3D2:                             ; CODE XREF: sub_48D220+1AAj
    mov     edx, [esi]
    lea     eax, [ecx+2CAAh]
    push    eax                             ; int
    mov     al, [ecx+2CC3h]
    push    ebp                             ; int
    push    edx                             ; int
    push    eax                             ; int
    call    sub_43E490
    cmp     eax, edi
    jge     short loc_48D3EF
    mov     edi, eax

    loc_48D3EF:                             ; CODE XREF: sub_48D220+1CBj
    mov     eax, [esp+24h+var_8]
    add     esi, 4
    cmp     esi, eax
    jnz     short loc_48D3CC
    mov     esi, [esp+24h+var_C]

    loc_48D3FE:                             ; CODE XREF: sub_48D220+1A8j
    push    esi
    call    sub_4B4F20
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    4
    sub_48D220 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edx, esi
    push    edi
    mov     cl, [esi+2A42h]
    mov     bl, 0C0h
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [edx+eax*2+1BCEh]
    lea     edx, [edx+eax*2+1B63h]
    mov     eax, [edx+67h]
    cmp     eax, ecx
    ja      short loc_48D471

    loc_48D456:                             ; CODE XREF: .text:0048D46Fj
    cmp     word ptr [eax+0A6h], 0
    jz      short loc_48D468
    test    [eax+110h], bl
    jz      short loc_48D4CB

    loc_48D468:                             ; CODE XREF: .text:0048D45Ej
    add     eax, 118h
    cmp     eax, ecx
    jbe     short loc_48D456

    loc_48D471:                             ; CODE XREF: .text:0048D454j
    mov     eax, [esi+14357h]
    mov     ecx, [esi+1435Bh]
    cmp     eax, ecx
    ja      short loc_48D4A4
    mov     ecx, 0FFFFFF3Fh

    loc_48D486:                             ; CODE XREF: .text:0048D4A2j
    mov     edi, [eax+110h]
    add     eax, 118h
    and     edi, ecx
    mov     [eax-8], edi
    mov     esi, TAdynmemStructPtr
    cmp     eax, [esi+1435Bh]
    jbe     short loc_48D486

    loc_48D4A4:                             ; CODE XREF: .text:0048D47Fj
    mov     eax, [edx+67h]
    mov     edx, [edx+6Bh]
    cmp     eax, edx
    ja      short loc_48D4C9

    loc_48D4AE:                             ; CODE XREF: .text:0048D4C7j
    cmp     word ptr [eax+0A6h], 0
    jz      short loc_48D4C0
    test    [eax+110h], bl
    jz      short loc_48D4CB

    loc_48D4C0:                             ; CODE XREF: .text:0048D4B6j
    add     eax, 118h
    cmp     eax, edx
    jbe     short loc_48D4AE

    loc_48D4C9:                             ; CODE XREF: .text:0048D4ACj
    xor     eax, eax

    loc_48D4CB:                             ; CODE XREF: .text:0048D466j
                                            ; .text:0048D4BEj
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48D4D0 proc near                    ; CODE XREF: .text:004964D2p
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    ebx
    push    ebp
    mov     cl, [edx+TAdynmemStruct.SharedBits]
    push    esi
    mov     eax, ecx
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    push    edi
    mov     bl, 0C0h
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+TAdynmemStruct.Players.Units_End]
    lea     esi, [esi+eax*2+TAdynmemStruct.Players]
    mov     eax, [esi+67h]
    cmp     eax, ecx
    ja      short loc_48D526

    loc_48D507:                             ; CODE XREF: sub_48D4D0+54j
    cmp     word ptr [eax+0A6h], 0
    jz      short loc_48D51D
    test    [eax+110h], bl
    jz      loc_48D625

    loc_48D51D:                             ; CODE XREF: sub_48D4D0+3Fj
    add     eax, 118h
    cmp     eax, ecx
    jbe     short loc_48D507

    loc_48D526:                             ; CODE XREF: sub_48D4D0+35j
    mov     eax, [edx+TAdynmemStruct.Units]
    mov     ecx, [edx+TAdynmemStruct.Units_EndMarker]
    cmp     eax, ecx
    ja      short loc_48D559
    mov     ecx, 0FFFFFF3Fh

    loc_48D53B:                             ; CODE XREF: sub_48D4D0+87j
    mov     edx, [eax+110h]
    add     eax, 118h
    and     edx, ecx
    mov     [eax-8], edx
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+TAdynmemStruct.Units_EndMarker]
    jbe     short loc_48D53B

    loc_48D559:                             ; CODE XREF: sub_48D4D0+64j
    mov     eax, [esi+67h]
    mov     ecx, [esi+6Bh]
    cmp     eax, ecx
    ja      short loc_48D582

    loc_48D563:                             ; CODE XREF: sub_48D4D0+B0j
    cmp     word ptr [eax+0A6h], 0
    jz      short loc_48D579
    test    [eax+110h], bl
    jz      loc_48D625

    loc_48D579:                             ; CODE XREF: sub_48D4D0+9Bj
    add     eax, 118h
    cmp     eax, ecx
    jbe     short loc_48D563

    loc_48D582:                             ; CODE XREF: sub_48D4D0+91j
    xor     ebp, ebp

    loc_48D584:                             ; CODE XREF: sub_48D4D0+157j
    test    ebp, ebp
    jz      loc_48D620
    mov     cx, [ebp+0A8h]
    push    1
    mov     [edx+TAdynmemStruct.field_1436F], cx
    lea     edx, [ebp+6Ah]
    push    edx
    call    sub_41C8E0
    call    GameUnit_LOS_Sight
    mov     edx, TAdynmemStructPtr
    xor     edi, edi
    mov     eax, [edx+TAdynmemStruct.NumHotUnits]
    mov     esi, [edx+TAdynmemStruct.HotUnits]
    test    eax, eax
    jle     short loc_48D610

    loc_48D5C2:                             ; CODE XREF: sub_48D4D0+13Ej
    xor     ecx, ecx
    mov     bl, [edx+TAdynmemStruct.SharedBits]
    mov     cx, [esi]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+TAdynmemStruct.Units]
    lea     eax, [eax+eax*4]
    lea     eax, [ecx+eax*8]
    mov     cl, [eax+0FFh]
    cmp     cl, bl
    jnz     short loc_48D602
    mov     edx, [eax+110h]
    and     dl, 7Fh
    or      edx, 40h
    mov     [eax+110h], edx
    mov     edx, TAdynmemStructPtr

    loc_48D602:                             ; CODE XREF: sub_48D4D0+118j
    mov     eax, [edx+TAdynmemStruct.NumHotUnits]
    inc     edi
    add     esi, 2
    cmp     edi, eax
    jl      short loc_48D5C2

    loc_48D610:                             ; CODE XREF: sub_48D4D0+F0j
    mov     eax, [ebp+110h]
    and     al, 7Fh
    or      al, 40h
    mov     [ebp+110h], eax

    loc_48D620:                             ; CODE XREF: sub_48D4D0+B6j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_48D625:                             ; CODE XREF: sub_48D4D0+47j
                                            ; sub_48D4D0+A3j
    mov     ebp, eax
    jmp     loc_48D584
    sub_48D4D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48D630 proc near                    ; CODE XREF: UpdateDatePlayers+576p

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edx, esi
    mov     cl, [esi+TAdynmemStruct.LOS_Sight]
    push    edi
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [edx+eax*2+TAdynmemStruct.Players]
    xor     edx, edx
    mov     eax, [ecx+27h]
    mov     edi, [ecx+67h]
    mov     dl, [eax+95h]
    mov     eax, edx
    shl     eax, 3
    sub     eax, edx
    lea     eax, [eax+eax*4]
    lea     edx, [edx+eax*8]
    lea     ebp, [esi+edx*2+37F5Fh]
    mov     edx, [ecx+6Bh]
    cmp     edi, edx
    ja      loc_48D785

    loc_48D684:                             ; CODE XREF: sub_48D630+D0j
    test    byte ptr [edi+110h], 20h
    jz      short loc_48D6F8
    fld     dword ptr [edi+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48D6F8
    mov     eax, [edi+0FBh]
    test    eax, eax
    jnz     short loc_48D6F8
    mov     eax, [edi+86h]
    test    eax, eax
    jz      short loc_48D6C0
    test    dword ptr [eax+110h], 40000000h
    jz      short loc_48D6F8

    loc_48D6C0:                             ; CODE XREF: sub_48D630+82j
    mov     eax, [edi+92h]
    mov     esi, ebp
    add     eax, 20h

    loc_48D6CB:                             ; CODE XREF: sub_48D630+B9j
    mov     bl, [eax]
    mov     cl, bl
    cmp     bl, [esi]
    jnz     short loc_48D6EF
    test    cl, cl
    jz      short loc_48D6EB
    mov     bl, [eax+1]
    mov     cl, bl
    cmp     bl, [esi+1]
    jnz     short loc_48D6EF
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_48D6CB

    loc_48D6EB:                             ; CODE XREF: sub_48D630+A5j
    xor     eax, eax
    jmp     short loc_48D6F4
    ; ---------------------------------------------------------------------------

    loc_48D6EF:                             ; CODE XREF: sub_48D630+A1j
                                            ; sub_48D630+AFj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_48D6F4:                             ; CODE XREF: sub_48D630+BDj
    test    eax, eax
    jz      short loc_48D709

    loc_48D6F8:                             ; CODE XREF: sub_48D630+5Bj
                                            ; sub_48D630+6Ej ...
    add     edi, 118h
    cmp     edi, edx
    jbe     short loc_48D684
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48D709:                             ; CODE XREF: sub_48D630+C6j
    call    sub_41C390
    lea     eax, [edi+6Ah]
    push    1
    push    eax
    call    sub_41C8E0
    mov     eax, [esp+4+arg_0]
    test    eax, eax
    jz      short loc_48D785
    call    sub_495860
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+14357h]
    mov     edx, [ecx+1435Bh]
    cmp     eax, edx
    ja      short loc_48D75F
    mov     ecx, 0FFFFFF2Fh

    loc_48D741:                             ; CODE XREF: sub_48D630+12Dj
    mov     ebp, [eax+110h]
    add     eax, 118h
    and     ebp, ecx
    mov     [eax-8], ebp
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+1435Bh]
    jbe     short loc_48D741

    loc_48D75F:                             ; CODE XREF: sub_48D630+10Aj
    push    0
    call    sub_491D70
    mov     esi, [edi+110h]
    mov     ecx, 10h
    or      esi, ecx
    mov     [edi+110h], esi
    mov     eax, TAdynmemStructPtr
    or      [eax+37EBEh], cx

    loc_48D785:                             ; CODE XREF: sub_48D630+4Ej
                                            ; sub_48D630+EFj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_48D630 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48D790 proc near                    ; CODE XREF: sub_48AD30+33Dp
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     edx, edi
    xor     ebx, ebx
    mov     cl, [edi+TAdynmemStruct.LOS_Sight]
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     esi, [edx+eax*2+TAdynmemStruct.Players.Units]
    lea     ebp, [edx+eax*2+TAdynmemStruct.Players]
    mov     edx, [edx+eax*2+TAdynmemStruct.Players.Units_End]
    cmp     esi, edx
    ja      loc_48D864

    loc_48D7CF:                             ; CODE XREF: sub_48D790+90j
    mov     ecx, dword ptr [esi+UnitStruct.UnitSelected]
    test    cl, 20h
    jz      short loc_48D818
    fld     [esi+UnitStruct.Nanoframe]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48D818
    mov     eax, dword ptr [esi+UnitStruct.Height]
    test    eax, eax
    jnz     short loc_48D818
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_48D80A
    test    byte ptr [eax+113h], 40h
    jz      short loc_48D818

    loc_48D80A:                             ; CODE XREF: sub_48D790+6Fj
    test    ebx, ebx
    jnz     short loc_48D810
    mov     ebx, esi

    loc_48D810:                             ; CODE XREF: sub_48D790+7Cj
    shr     ecx, 4
    test    cl, 1
    jnz     short loc_48D824

    loc_48D818:                             ; CODE XREF: sub_48D790+48j
                                            ; sub_48D790+5Bj ...
    add     esi, 118h
    cmp     esi, edx
    jbe     short loc_48D7CF
    jmp     short loc_48D864
    ; ---------------------------------------------------------------------------

    loc_48D824:                             ; CODE XREF: sub_48D790+86j
    mov     eax, [edi+TAdynmemStruct.Units]
    mov     ecx, [edi+TAdynmemStruct.Units_EndMarker]
    cmp     eax, ecx
    ja      short loc_48D857
    mov     ecx, 0FFFFFF2Fh

    loc_48D839:                             ; CODE XREF: sub_48D790+C5j
    mov     edi, dword ptr [eax+UnitStruct.UnitSelected]
    add     eax, 118h
    and     edi, ecx
    mov     [eax-8], edi
    mov     edx, TAdynmemStructPtr
    cmp     eax, [edx+TAdynmemStruct.Units_EndMarker]
    jbe     short loc_48D839

    loc_48D857:                             ; CODE XREF: sub_48D790+A2j
    push    0
    call    sub_491D70
    mov     edi, TAdynmemStructPtr

    loc_48D864:                             ; CODE XREF: sub_48D790+39j
                                            ; sub_48D790+92j
    test    ebx, ebx
    mov     edx, 10h
    jz      loc_48D908
    mov     ecx, [ebp+6Bh]
    add     esi, 118h
    cmp     esi, ecx
    ja      short loc_48D8F4

    loc_48D87E:                             ; CODE XREF: sub_48D790+134j
    test    byte ptr [esi+110h], 20h
    jz      short loc_48D8BA
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48D8BA
    mov     eax, [esi+0FBh]
    test    eax, eax
    jnz     short loc_48D8BA
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_48D8C6
    test    dword ptr [eax+110h], 40000000h
    jnz     short loc_48D8C6

    loc_48D8BA:                             ; CODE XREF: sub_48D790+F5j
                                            ; sub_48D790+108j ...
    add     esi, 118h
    cmp     esi, ecx
    ja      short loc_48D8F4
    jmp     short loc_48D87E
    ; ---------------------------------------------------------------------------

    loc_48D8C6:                             ; CODE XREF: sub_48D790+11Cj
                                            ; sub_48D790+128j
    mov     eax, [esi+110h]
    or      eax, edx
    mov     [esi+110h], eax
    mov     eax, TAdynmemStructPtr
    mov     word ptr [eax+37E9Ch], 0
    mov     edi, TAdynmemStructPtr
    or      [edi+37EBEh], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_48D8F4:                             ; CODE XREF: sub_48D790+ECj
                                            ; sub_48D790+132j
    mov     eax, [ebx+110h]
    or      eax, edx
    mov     [ebx+110h], eax
    mov     edi, TAdynmemStructPtr

    loc_48D908:                             ; CODE XREF: sub_48D790+DBj
    or      [edi+37EBEh], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_48D790 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48D920 proc near                    ; CODE XREF: sub_495E90+114p

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    esi
    push    edi
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     esi, [ecx+eax*2+1BCAh]
    lea     edi, [ecx+eax*2+1B63h]
    mov     eax, [ecx+eax*2+1BCEh]
    cmp     esi, eax
    ja      short loc_48D993
    push    ebx
    mov     ebx, [esp+0Ch+arg_0]

    loc_48D95A:                             ; CODE XREF: sub_48D920+70j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48D985
    mov     ecx, [esi+110h]
    shr     ecx, 4
    test    cl, 1
    jz      short loc_48D975
    push    ebx
    jmp     short loc_48D97F
    ; ---------------------------------------------------------------------------

    loc_48D975:                             ; CODE XREF: sub_48D920+50j
    cmp     [esi+0ACh], ebx
    jnz     short loc_48D985
    push    0

    loc_48D97F:                             ; CODE XREF: sub_48D920+53j
    push    esi
    call    sub_480250

    loc_48D985:                             ; CODE XREF: sub_48D920+42j
                                            ; sub_48D920+5Bj
    mov     eax, [edi+6Bh]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48D95A
    pop     ebx

    loc_48D993:                             ; CODE XREF: sub_48D920+33j
    pop     edi
    pop     esi
    retn    4
    sub_48D920 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48D9A0 proc near                    ; CODE XREF: sub_495E90+16Dp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    offset aCtrl_f                  ; char *
    call    sub_488C50
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     [esp+20h+var_4], eax
    xor     ebx, ebx
    mov     dl, [ecx+2A42h]
    push    offset aCtrl_f                  ; char *
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    mov     [esp+24h+var_10], ebx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*2+1B63h]
    mov     [esp+24h+var_8], ecx
    call    sub_488C50
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     ebp, eax
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     edx, [ecx+eax*2+1BCAh]
    mov     edi, [ecx+eax*2+1BCEh]
    lea     esi, [ecx+eax*2+1B63h]
    cmp     edx, edi
    ja      loc_48DB0E

    loc_48DA23:                             ; CODE XREF: sub_48D9A0+FAj
    test    byte ptr [edx+110h], 20h
    jz      short loc_48DA92
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48DA92
    mov     eax, [edx+0FBh]
    test    eax, eax
    jnz     short loc_48DA92
    mov     eax, [edx+86h]
    test    eax, eax
    jz      short loc_48DA5F
    test    dword ptr [eax+110h], 40000000h
    jz      short loc_48DA92

    loc_48DA5F:                             ; CODE XREF: sub_48D9A0+B1j
    mov     ecx, [esp+20h+arg_0]
    mov     eax, [edx+0ACh]
    cmp     eax, ecx
    jnz     short loc_48DA92
    mov     ax, [edx+0A6h]
    mov     ebx, 1
    and     eax, 0FFFFh
    mov     ecx, eax
    and     ecx, 1Fh
    shl     ebx, cl
    shr     eax, 5
    test    [ebp+eax*4+0], ebx
    jnz     short loc_48DA9E
    mov     ebx, [esp+20h+var_10]

    loc_48DA92:                             ; CODE XREF: sub_48D9A0+8Aj
                                            ; sub_48D9A0+9Dj ...
    add     edx, 118h
    cmp     edx, edi
    jbe     short loc_48DA23
    jmp     short loc_48DB0E
    ; ---------------------------------------------------------------------------

    loc_48DA9E:                             ; CODE XREF: sub_48D9A0+ECj
    mov     ecx, [esi+67h]
    mov     esi, [esi+6Bh]
    cmp     ecx, esi
    ja      short loc_48DB0A

    loc_48DAA8:                             ; CODE XREF: sub_48D9A0+168j
    mov     edx, [ecx+110h]
    test    dl, 20h
    jz      short loc_48DB00
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48DB00
    mov     eax, [ecx+0FBh]
    test    eax, eax
    jnz     short loc_48DB00
    mov     eax, [ecx+86h]
    test    eax, eax
    jz      short loc_48DAE6
    test    dword ptr [eax+110h], 40000000h
    jz      short loc_48DB00

    loc_48DAE6:                             ; CODE XREF: sub_48D9A0+138j
    mov     eax, [ecx+0ACh]
    mov     edi, [esp+20h+arg_0]
    cmp     eax, edi
    jnz     short loc_48DB00
    test    edx, 80000000h
    jnz     loc_48DC13

    loc_48DB00:                             ; CODE XREF: sub_48D9A0+111j
                                            ; sub_48D9A0+124j ...
    add     ecx, 118h
    cmp     ecx, esi
    jbe     short loc_48DAA8

    loc_48DB0A:                             ; CODE XREF: sub_48D9A0+106j
    mov     ebx, [esp+20h+var_10]

    loc_48DB0E:                             ; CODE XREF: sub_48D9A0+7Dj
                                            ; sub_48D9A0+FCj
    mov     [esp+20h+var_C], 0

    loc_48DB16:                             ; CODE XREF: sub_48D9A0+27Fj
    mov     edi, [esp+20h+var_8]
    mov     esi, [edi+67h]
    mov     eax, [edi+6Bh]
    cmp     esi, eax
    ja      loc_48DBE2

    loc_48DB28:                             ; CODE XREF: sub_48D9A0+23Cj
    mov     edx, [esi+110h]
    test    dl, 20h
    jz      loc_48DBD1
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      loc_48DBD1
    mov     eax, [esi+0FBh]
    test    eax, eax
    jnz     short loc_48DBD1
    mov     eax, [esi+86h]
    test    eax, eax
    jz      short loc_48DB6E
    test    dword ptr [eax+110h], 40000000h
    jz      short loc_48DBD1

    loc_48DB6E:                             ; CODE XREF: sub_48D9A0+1C0j
    mov     ecx, [esp+20h+arg_0]
    mov     eax, [esi+0ACh]
    cmp     eax, ecx
    jnz     short loc_48DBC0
    mov     eax, [esp+20h+var_C]
    test    eax, eax
    jz      short loc_48DBB4
    mov     ax, [esi+0A6h]
    mov     ebp, 1
    and     eax, 0FFFFh
    mov     ecx, eax
    and     ecx, 1Fh
    shl     ebp, cl
    mov     ecx, [esp+20h+var_4]
    shr     eax, 5
    test    [ecx+eax*4], ebp
    jnz     short loc_48DBC8
    or      edx, 10h
    inc     ebx
    mov     [esi+110h], edx
    jmp     short loc_48DBD1
    ; ---------------------------------------------------------------------------

    loc_48DBB4:                             ; CODE XREF: sub_48D9A0+1E2j
    or      edx, 10h
    inc     ebx
    mov     [esi+110h], edx
    jmp     short loc_48DBD1
    ; ---------------------------------------------------------------------------

    loc_48DBC0:                             ; CODE XREF: sub_48D9A0+1DAj
    mov     eax, [esp+20h+arg_4]
    test    eax, eax
    jnz     short loc_48DBD1

    loc_48DBC8:                             ; CODE XREF: sub_48D9A0+206j
    and     edx, 0FFFFFFEFh
    mov     [esi+110h], edx

    loc_48DBD1:                             ; CODE XREF: sub_48D9A0+191j
                                            ; sub_48D9A0+1A8j ...
    mov     eax, [edi+6Bh]
    add     esi, 118h
    cmp     esi, eax
    jbe     loc_48DB28

    loc_48DBE2:                             ; CODE XREF: sub_48D9A0+182j
    call    sub_495860
    mov     edx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     word ptr [edx+37E9Ch], 0
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37EBEh], 10h
    xor     eax, eax
    test    ebx, ebx
    setnle  al
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48DC13:                             ; CODE XREF: sub_48D9A0+15Aj
    mov     ebx, [esp+20h+var_10]
    mov     [esp+20h+var_C], 1
    jmp     loc_48DB16
    sub_48D9A0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    offset aCtrl_f                  ; "CTRL_F"
    call    sub_488C50
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     esi, eax
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     edx, [ecx+eax*2+1BCAh]
    mov     edi, [ecx+eax*2+1BCEh]
    lea     eax, [ecx+eax*2+1B63h]
    cmp     edx, edi
    ja      loc_48DCFE
    mov     ebp, [esp+14h]

    loc_48DC7B:                             ; CODE XREF: .text:0048DCE7j
    test    byte ptr [edx+110h], 20h
    jz      short loc_48DCDF
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48DCDF
    mov     eax, [edx+0FBh]
    test    eax, eax
    jnz     short loc_48DCDF
    mov     eax, [edx+86h]
    test    eax, eax
    jz      short loc_48DCB7
    test    dword ptr [eax+110h], 40000000h
    jz      short loc_48DCDF

    loc_48DCB7:                             ; CODE XREF: .text:0048DCA9j
    cmp     [edx+0ACh], ebp
    jnz     short loc_48DCDF
    mov     ax, [edx+0A6h]
    mov     ebx, 1
    and     eax, 0FFFFh
    mov     ecx, eax
    and     ecx, 1Fh
    shl     ebx, cl
    shr     eax, 5
    test    [esi+eax*4], ebx
    jnz     short loc_48DCF2

    loc_48DCDF:                             ; CODE XREF: .text:0048DC82j
                                            ; .text:0048DC95j ...
    add     edx, 118h
    cmp     edx, edi
    jbe     short loc_48DC7B
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48DCF2:                             ; CODE XREF: .text:0048DCDDj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48DCFE:                             ; CODE XREF: .text:0048DC71j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    ebx
    mov     dl, [ecx+2A42h]
    push    esi
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    push    edi
    lea     eax, [eax+eax*4]
    mov     esi, [ecx+eax*2+1BCEh]
    lea     eax, [ecx+eax*2+1B63h]
    mov     ecx, [eax+67h]
    cmp     ecx, esi
    ja      short loc_48DDB2
    mov     edi, [esp+10h]
    mov     ebx, 40000000h

    loc_48DD4B:                             ; CODE XREF: .text:0048DD9Dj
    mov     edx, [ecx+110h]
    test    dl, 20h
    jz      short loc_48DD95
    fld     dword ptr [ecx+104h]
    fcomp   ds:flt_4FD758
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48DD95
    mov     eax, [ecx+0FBh]
    test    eax, eax
    jnz     short loc_48DD95
    mov     eax, [ecx+86h]
    test    eax, eax
    jz      short loc_48DD85
    test    [eax+110h], ebx
    jz      short loc_48DD95

    loc_48DD85:                             ; CODE XREF: .text:0048DD7Bj
    cmp     [ecx+0ACh], edi
    jnz     short loc_48DD95
    test    edx, 80000000h
    jnz     short loc_48DDA7

    loc_48DD95:                             ; CODE XREF: .text:0048DD54j
                                            ; .text:0048DD67j ...
    add     ecx, 118h
    cmp     ecx, esi
    jbe     short loc_48DD4B
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48DDA7:                             ; CODE XREF: .text:0048DD93j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_48DDB2:                             ; CODE XREF: .text:0048DD40j
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48DDC0 proc near                    ; CODE XREF: sub_48D220+A3p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     edi, [esp+1Ch+arg_0]
    mov     eax, [esi+8]
    mov     edx, [esi+0Ch]
    mov     ecx, [esi+4]
    mov     ebp, edi
    sub     edx, eax
    sub     ebp, ecx
    sar     edx, 2
    sar     ebp, 2
    cmp     edx, 1
    mov     [esp+1Ch+var_4], ebp
    jnb     loc_48DEDC
    test    ecx, ecx
    jnz     short loc_48DDF7
    xor     edx, edx
    jmp     short loc_48DDFE
    ; ---------------------------------------------------------------------------

    loc_48DDF7:                             ; CODE XREF: sub_48DDC0+31j
    mov     edx, eax
    sub     edx, ecx
    sar     edx, 2

    loc_48DDFE:                             ; CODE XREF: sub_48DDC0+35j
    cmp     edx, 1
    jbe     short loc_48DE14
    test    ecx, ecx
    jnz     short loc_48DE0B
    xor     edx, edx
    jmp     short loc_48DE19
    ; ---------------------------------------------------------------------------

    loc_48DE0B:                             ; CODE XREF: sub_48DDC0+45j
    mov     edx, eax
    sub     edx, ecx
    sar     edx, 2
    jmp     short loc_48DE19
    ; ---------------------------------------------------------------------------

    loc_48DE14:                             ; CODE XREF: sub_48DDC0+41j
    mov     edx, 1

    loc_48DE19:                             ; CODE XREF: sub_48DDC0+49j
                                            ; sub_48DDC0+52j
    test    ecx, ecx
    jnz     short loc_48DE21
    xor     eax, eax
    jmp     short loc_48DE26
    ; ---------------------------------------------------------------------------

    loc_48DE21:                             ; CODE XREF: sub_48DDC0+5Bj
    sub     eax, ecx
    sar     eax, 2

    loc_48DE26:                             ; CODE XREF: sub_48DDC0+5Fj
    add     eax, edx
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_48DE32
    xor     eax, eax

    loc_48DE32:                             ; CODE XREF: sub_48DDC0+6Ej
    shl     eax, 2
    push    eax                             ; int
    call    sub_4B4F10
    mov     ebx, [esi+4]
    add     esp, 4
    cmp     ebx, edi
    mov     [esp+1Ch+var_C], eax
    mov     ebp, eax
    jz      short loc_48DE5C

    loc_48DE4B:                             ; CODE XREF: sub_48DDC0+9Aj
    push    ebx
    push    ebp
    call    sub_406C70
    add     ebx, 4
    add     ebp, 4
    cmp     ebx, edi
    jnz     short loc_48DE4B

    loc_48DE5C:                             ; CODE XREF: sub_48DDC0+89j
    mov     ebx, ebp
    mov     [esp+1Ch+arg_0], 1

    loc_48DE66:                             ; CODE XREF: sub_48DDC0+BDj
    mov     ecx, [esp+1Ch+arg_4]
    push    ecx
    push    ebx
    call    sub_406C70
    mov     eax, [esp+1Ch+arg_0]
    add     ebx, 4
    dec     eax
    mov     [esp+1Ch+arg_0], eax
    jnz     short loc_48DE66
    mov     edx, [esi+8]
    add     ebp, 4
    push    ebp
    push    edx
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    eax
    push    ecx
    mov     ecx, esi
    call    nullsub_1
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edi, [esp+20h+var_C]
    mov     edx, [esp+20h+var_8]
    add     esp, 4
    mov     ecx, esi
    lea     eax, [edi+edx*4]
    mov     [esi+0Ch], eax
    call    sub_40C560
    mov     ebp, [esp+1Ch+var_4]
    lea     ecx, [edi+eax*4+4]
    mov     [esi+8], ecx
    mov     [esi+4], edi
    mov     esi, edi
    lea     eax, [esi+ebp*4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_48DEDC:                             ; CODE XREF: sub_48DDC0+29j
    mov     edx, eax
    sub     edx, edi
    sar     edx, 2
    cmp     edx, 1
    jnb     short loc_48DF2A
    lea     ecx, [edi+4]
    push    ecx
    push    eax
    push    edi
    mov     ecx, esi
    call    sub_406C10
    mov     eax, [esi+8]
    mov     ebx, [esp+1Ch+arg_4]
    mov     edx, eax
    mov     ecx, 1
    sub     edx, edi
    push    ebx
    sar     edx, 2
    sub     ecx, edx
    push    ecx
    push    eax
    mov     ecx, esi
    call    sub_406C40
    mov     ecx, [esi+8]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_48DF68

    loc_48DF1D:                             ; CODE XREF: sub_48DDC0+166j
    mov     edx, [ebx]
    mov     [eax], edx
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_48DF1D
    jmp     short loc_48DF68
    ; ---------------------------------------------------------------------------

    loc_48DF2A:                             ; CODE XREF: sub_48DDC0+126j
    push    eax
    push    eax
    add     eax, 0FFFFFFFCh
    mov     ecx, esi
    push    eax
    call    sub_406C10
    mov     ecx, [esi+8]
    lea     eax, [ecx-4]
    cmp     edi, eax
    jz      short loc_48DF50

    loc_48DF41:                             ; CODE XREF: sub_48DDC0+18Ej
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, edi
    mov     [ecx], edx
    jnz     short loc_48DF41

    loc_48DF50:                             ; CODE XREF: sub_48DDC0+17Fj
    lea     ecx, [edi+4]
    mov     eax, edi
    cmp     edi, ecx
    jz      short loc_48DF68
    mov     edx, [esp+1Ch+arg_4]

    loc_48DF5D:                             ; CODE XREF: sub_48DDC0+1A6j
    mov     edi, [edx]
    mov     [eax], edi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_48DF5D

    loc_48DF68:                             ; CODE XREF: sub_48DDC0+15Bj
                                            ; sub_48DDC0+168j ...
    mov     eax, [esi+8]
    pop     edi
    add     eax, 4
    mov     [esi+8], eax
    mov     esi, [esi+4]
    lea     eax, [esi+ebp*4]
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_48DDC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48DF90 proc near                    ; CODE XREF: sub_435DA0+49p
    mov     eax, ecx
    xor     ecx, ecx
    mov     dword ptr [eax+88h], 1
    mov     [eax+40h], ecx
    mov     [eax+84h], ecx
    retn
    sub_48DF90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48DFB0 proc near                    ; CODE XREF: sub_434FF0+18p
                                            ; sub_435DA0+28p
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    xor     edi, edi
    mov     eax, [esi+40h]
    test    eax, eax
    jle     short loc_48DFD6
    mov     ebx, esi

    loc_48DFC0:                             ; CODE XREF: sub_48DFB0+24j
    mov     eax, [ebx]
    push    eax
    call    sub_4B4F20
    mov     eax, [esi+40h]
    add     esp, 4
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_48DFC0

    loc_48DFD6:                             ; CODE XREF: sub_48DFB0+Cj
    mov     eax, [esi+84h]
    xor     edi, edi
    test    eax, eax
    jle     short loc_48DFFE
    lea     ebx, [esi+44h]

    loc_48DFE5:                             ; CODE XREF: sub_48DFB0+4Cj
    mov     ecx, [ebx]
    push    ecx
    call    sub_4B4F20
    mov     eax, [esi+84h]
    add     esp, 4
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_48DFE5

    loc_48DFFE:                             ; CODE XREF: sub_48DFB0+30j
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_48DFB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48E010 proc near                    ; CODE XREF: sub_435DA0+839p

    var_21C= dword ptr -21Ch
    var_218= dword ptr -218h
    var_214= dword ptr -214h
    var_210= dword ptr -210h
    var_20C= dword ptr -20Ch
    var_208= dword ptr -208h
    var_204= dword ptr -204h
    var_200= byte ptr -200h
    var_100= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 21Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+22Ch+arg_0]
    xor     ebx, ebx
    mov     ebp, ecx
    push    ebx                             ; int
    mov     ecx, [edi+4]
    push    offset aKillenemycomma          ; char *
    mov     [esp+234h+var_210], ebp
    call    sub_4C46C0
    cmp     eax, ebx
    jz      short loc_48E067
    push    0Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E057
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    mov     dword ptr [eax], offset off_4FD960
    jmp     short loc_48E059
    ; ---------------------------------------------------------------------------

    loc_48E057:                             ; CODE XREF: sub_48E010+37j
    xor     eax, eax

    loc_48E059:                             ; CODE XREF: sub_48E010+45j
    mov     ecx, [ebp+40h]
    mov     [ebp+ecx*4+0], eax
    mov     eax, [ebp+40h]
    inc     eax
    mov     [ebp+40h], eax

    loc_48E067:                             ; CODE XREF: sub_48E010+29j
    mov     ecx, [edi+4]
    push    ebx                             ; int
    push    offset aDestroyallunit          ; char *
    call    sub_4C46C0
    cmp     eax, ebx
    jz      short loc_48E0A5
    push    0Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E095
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    mov     dword ptr [eax], offset off_4FD948
    jmp     short loc_48E097
    ; ---------------------------------------------------------------------------

    loc_48E095:                             ; CODE XREF: sub_48E010+75j
    xor     eax, eax

    loc_48E097:                             ; CODE XREF: sub_48E010+83j
    mov     edx, [ebp+40h]
    mov     [ebp+edx*4+0], eax
    mov     eax, [ebp+40h]
    inc     eax
    mov     [ebp+40h], eax

    loc_48E0A5:                             ; CODE XREF: sub_48E010+67j
    mov     ecx, [edi+4]
    push    ebx                             ; int
    push    offset aKillallmobileu          ; char *
    call    sub_4C46C0
    cmp     eax, ebx
    jz      short loc_48E0F4
    push    14h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E0E4
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    mov     dword ptr [eax+0Ch], offset off_4FD940
    mov     dword ptr [eax], offset off_4FD928
    mov     dword ptr [eax+0Ch], offset off_4FD920
    mov     [eax+10h], ebx
    jmp     short loc_48E0E6
    ; ---------------------------------------------------------------------------

    loc_48E0E4:                             ; CODE XREF: sub_48E010+B3j
    xor     eax, eax

    loc_48E0E6:                             ; CODE XREF: sub_48E010+D2j
    mov     ecx, [ebp+40h]
    mov     [ebp+ecx*4+0], eax
    mov     eax, [ebp+40h]
    inc     eax
    mov     [ebp+40h], eax

    loc_48E0F4:                             ; CODE XREF: sub_48E010+A5j
    mov     ecx, [edi+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+234h+var_200]
    push    offset aBuildunittype           ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, ebx
    jz      short loc_48E185
    push    32h                             ; int
    call    sub_4B4F10
    mov     edx, eax
    add     esp, 4
    cmp     edx, ebx
    jz      short loc_48E175
    mov     [edx+8], ebx
    mov     [edx+4], ebx
    mov     dword ptr [edx+0Ch], offset off_4FD940
    lea     edi, [esp+22Ch+var_200]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     dword ptr [edx], offset off_4FD908
    mov     dword ptr [edx+0Ch], offset off_4FD900
    repne scasb
    not     ecx
    lea     esi, [edx+10h]
    sub     edi, ecx
    mov     eax, ecx
    mov     [esp+22Ch+var_21C], esi
    mov     esi, edi
    mov     edi, [esp+22Ch+var_21C]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+22Ch+arg_0]
    mov     [edx+30h], bx
    jmp     short loc_48E177
    ; ---------------------------------------------------------------------------

    loc_48E175:                             ; CODE XREF: sub_48E010+112j
    xor     edx, edx

    loc_48E177:                             ; CODE XREF: sub_48E010+163j
    mov     ecx, [ebp+40h]
    mov     [ebp+ecx*4+0], edx
    mov     eax, [ebp+40h]
    inc     eax
    mov     [ebp+40h], eax

    loc_48E185:                             ; CODE XREF: sub_48E010+102j
    mov     ecx, [edi+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+234h+var_200]
    push    offset aCaptureunittyp          ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, ebx
    jz      short loc_48E204
    push    2Ch                             ; int
    call    sub_4B4F10
    mov     edx, eax
    add     esp, 4
    cmp     edx, ebx
    jz      short loc_48E1F4
    lea     edi, [esp+22Ch+var_200]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [edx+8], ebx
    mov     [edx+4], ebx
    mov     dword ptr [edx], offset off_4FD8E8
    repne scasb
    not     ecx
    lea     esi, [edx+0Ch]
    sub     edi, ecx
    mov     eax, ecx
    mov     [esp+22Ch+var_21C], esi
    mov     esi, edi
    mov     edi, [esp+22Ch+var_21C]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+22Ch+arg_0]
    jmp     short loc_48E1F6
    ; ---------------------------------------------------------------------------

    loc_48E1F4:                             ; CODE XREF: sub_48E010+1A3j
    xor     edx, edx

    loc_48E1F6:                             ; CODE XREF: sub_48E010+1E2j
    mov     ecx, [ebp+40h]
    mov     [ebp+ecx*4+0], edx
    mov     eax, [ebp+40h]
    inc     eax
    mov     [ebp+40h], eax

    loc_48E204:                             ; CODE XREF: sub_48E010+193j
    mov     ecx, [edi+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+234h+var_200]
    push    offset aKillalloftype           ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, ebx
    jz      short loc_48E291
    push    36h                             ; int
    call    sub_4B4F10
    mov     edx, eax
    add     esp, 4
    cmp     edx, ebx
    jz      short loc_48E281
    mov     [edx+8], ebx
    mov     [edx+4], ebx
    mov     dword ptr [edx+0Ch], offset off_4FD940
    lea     edi, [esp+22Ch+var_200]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     dword ptr [edx], offset off_4FD8D0
    mov     dword ptr [edx+0Ch], offset off_4FD8C8
    repne scasb
    not     ecx
    lea     esi, [edx+10h]
    sub     edi, ecx
    mov     eax, ecx
    mov     [esp+22Ch+var_21C], esi
    mov     esi, edi
    mov     edi, [esp+22Ch+var_21C]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+22Ch+arg_0]
    jmp     short loc_48E283
    ; ---------------------------------------------------------------------------

    loc_48E281:                             ; CODE XREF: sub_48E010+222j
    xor     edx, edx

    loc_48E283:                             ; CODE XREF: sub_48E010+26Fj
    mov     ecx, [ebp+40h]
    mov     [ebp+ecx*4+0], edx
    mov     eax, [ebp+40h]
    inc     eax
    mov     [ebp+40h], eax

    loc_48E291:                             ; CODE XREF: sub_48E010+212j
    mov     ecx, [edi+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+234h+var_200]
    push    offset aKillunittype            ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, ebx
    jz      loc_48E345
    lea     eax, [esp+22Ch+var_21C]
    lea     ecx, [esp+22Ch+var_100]
    push    eax
    push    ecx
    lea     edx, [esp+234h+var_200]
    push    offset aAZaZI                   ; "%[a-zA-Z],%i"
    push    edx
    call    _sscanf
    add     esp, 10h
    push    30h                             ; int
    call    sub_4B4F10
    mov     edx, eax
    add     esp, 4
    cmp     edx, ebx
    jz      short loc_48E335
    mov     eax, [esp+22Ch+var_21C]
    lea     edi, [esp+22Ch+var_100]
    mov     [esp+22Ch+var_204], eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [edx+8], ebx
    mov     [edx+4], ebx
    mov     dword ptr [edx], offset off_4FD8B0
    repne scasb
    not     ecx
    lea     esi, [edx+0Ch]
    sub     edi, ecx
    mov     eax, ecx
    mov     [esp+22Ch+var_208], esi
    mov     esi, edi
    mov     edi, [esp+22Ch+var_208]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+22Ch+var_204]
    mov     edi, [esp+22Ch+arg_0]
    mov     [edx+2Ch], ecx
    jmp     short loc_48E337
    ; ---------------------------------------------------------------------------

    loc_48E335:                             ; CODE XREF: sub_48E010+2D2j
    xor     edx, edx

    loc_48E337:                             ; CODE XREF: sub_48E010+323j
    mov     eax, [ebp+40h]
    mov     [ebp+eax*4+0], edx
    mov     eax, [ebp+40h]
    inc     eax
    mov     [ebp+40h], eax

    loc_48E345:                             ; CODE XREF: sub_48E010+29Fj
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     ecx, [esp+234h+var_200]
    push    offset aMoveunittoradi          ; char *
    push    ecx                             ; char *
    mov     ecx, [edi+4]
    call    sub_4C48C0
    cmp     eax, ebx
    jz      loc_48E45B
    lea     edx, [esp+22Ch+var_204]
    lea     eax, [esp+22Ch+var_208]
    push    edx
    lea     ecx, [esp+230h+var_21C]
    push    eax
    lea     edx, [esp+234h+var_100]
    push    ecx
    push    edx
    lea     eax, [esp+23Ch+var_200]
    push    offset aAZaZIII                 ; "%[a-zA-Z],%i,%i,%i"
    push    eax
    call    _sscanf
    add     esp, 18h
    push    40h                             ; int
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    cmp     ebp, ebx
    jz      loc_48E43F
    mov     esi, [esp+22Ch+var_204]
    mov     ecx, [esp+22Ch+var_208]
    mov     edx, [esp+22Ch+var_21C]
    lea     eax, [esp+22Ch+var_100]
    mov     [ebp+8], ebx
    mov     [ebp+4], ebx
    push    offset aAnytype                 ; char *
    mov     dword ptr [ebp+0Ch], offset off_4FD8A8
    push    eax                             ; char *
    mov     [esp+234h+var_20C], esi
    mov     [esp+234h+var_218], ecx
    mov     [esp+234h+var_214], edx
    mov     dword ptr [ebp+0], offset off_4FD890
    mov     dword ptr [ebp+0Ch], offset off_4FD888
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48E3F7
    mov     [ebp+10h], bl
    jmp     short loc_48E422
    ; ---------------------------------------------------------------------------

    loc_48E3F7:                             ; CODE XREF: sub_48E010+3E0j
    lea     edi, [esp+22Ch+var_100]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp+10h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     esi, [esp+22Ch+var_20C]

    loc_48E422:                             ; CODE XREF: sub_48E010+3E5j
    mov     ecx, [esp+22Ch+var_214]
    mov     edx, [esp+22Ch+var_218]
    shl     esi, 10h
    mov     [ebp+30h], ecx
    mov     [ebp+38h], edx
    mov     [ebp+3Ch], esi
    mov     dword ptr [ebp+34h], 12345678h
    jmp     short loc_48E441
    ; ---------------------------------------------------------------------------

    loc_48E43F:                             ; CODE XREF: sub_48E010+390j
    xor     ebp, ebp

    loc_48E441:                             ; CODE XREF: sub_48E010+42Dj
    mov     eax, [esp+22Ch+var_210]
    mov     edi, [esp+22Ch+arg_0]
    mov     ecx, [eax+40h]
    mov     [eax+ecx*4], ebp
    mov     ecx, [eax+40h]
    inc     ecx
    mov     ebp, eax
    mov     [eax+40h], ecx

    loc_48E45B:                             ; CODE XREF: sub_48E010+353j
    mov     ecx, [edi+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+234h+var_200]
    push    offset aUnittypepasses          ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, ebx
    jz      loc_48E544
    lea     eax, [esp+22Ch+var_218]
    lea     ecx, [esp+22Ch+var_100]
    push    eax
    push    ecx
    lea     edx, [esp+234h+var_200]
    push    offset aAZaZI                   ; "%[a-zA-Z],%i"
    push    edx
    call    _sscanf
    add     esp, 10h
    push    34h                             ; int
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    cmp     ebp, ebx
    jz      short loc_48E528
    mov     esi, [esp+22Ch+var_218]
    lea     eax, [esp+22Ch+var_100]
    mov     [ebp+8], ebx
    mov     [ebp+4], ebx
    push    offset aAnytype                 ; char *
    mov     dword ptr [ebp+0Ch], offset off_4FD940
    push    eax                             ; char *
    mov     [esp+234h+var_214], esi
    mov     dword ptr [ebp+0], offset off_4FD870
    mov     dword ptr [ebp+0Ch], offset off_4FD868
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48E4F5
    sar     esi, 4
    mov     [ebp+10h], bl
    mov     [ebp+30h], esi
    jmp     short loc_48E52A
    ; ---------------------------------------------------------------------------

    loc_48E4F5:                             ; CODE XREF: sub_48E010+4D8j
    lea     edi, [esp+22Ch+var_100]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp+10h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     esi, [esp+22Ch+var_214]
    sar     esi, 4
    mov     [ebp+30h], esi
    jmp     short loc_48E52A
    ; ---------------------------------------------------------------------------

    loc_48E528:                             ; CODE XREF: sub_48E010+49Cj
    xor     ebp, ebp

    loc_48E52A:                             ; CODE XREF: sub_48E010+4E3j
                                            ; sub_48E010+516j
    mov     eax, [esp+22Ch+var_210]
    mov     edi, [esp+22Ch+arg_0]
    mov     ecx, [eax+40h]
    mov     [eax+ecx*4], ebp
    mov     ecx, [eax+40h]
    inc     ecx
    mov     ebp, eax
    mov     [eax+40h], ecx

    loc_48E544:                             ; CODE XREF: sub_48E010+469j
    mov     ecx, [edi+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+234h+var_200]
    push    offset aUnittypepass_0          ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, ebx
    jz      loc_48E62D
    lea     eax, [esp+22Ch+var_218]
    lea     ecx, [esp+22Ch+var_100]
    push    eax
    push    ecx
    lea     edx, [esp+234h+var_200]
    push    offset aAZaZI                   ; "%[a-zA-Z],%i"
    push    edx
    call    _sscanf
    add     esp, 10h
    push    34h                             ; int
    call    sub_4B4F10
    mov     ebp, eax
    add     esp, 4
    cmp     ebp, ebx
    jz      short loc_48E611
    mov     esi, [esp+22Ch+var_218]
    lea     eax, [esp+22Ch+var_100]
    mov     [ebp+8], ebx
    mov     [ebp+4], ebx
    push    offset aAnytype                 ; char *
    mov     dword ptr [ebp+0Ch], offset off_4FD940
    push    eax                             ; char *
    mov     [esp+234h+var_214], esi
    mov     dword ptr [ebp+0], offset off_4FD850
    mov     dword ptr [ebp+0Ch], offset off_4FD848
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48E5DE
    sar     esi, 4
    mov     [ebp+10h], bl
    mov     [ebp+30h], esi
    jmp     short loc_48E613
    ; ---------------------------------------------------------------------------

    loc_48E5DE:                             ; CODE XREF: sub_48E010+5C1j
    lea     edi, [esp+22Ch+var_100]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp+10h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     esi, [esp+22Ch+var_214]
    sar     esi, 4
    mov     [ebp+30h], esi
    jmp     short loc_48E613
    ; ---------------------------------------------------------------------------

    loc_48E611:                             ; CODE XREF: sub_48E010+585j
    xor     ebp, ebp

    loc_48E613:                             ; CODE XREF: sub_48E010+5CCj
                                            ; sub_48E010+5FFj
    mov     eax, [esp+22Ch+var_210]
    mov     edi, [esp+22Ch+arg_0]
    mov     ecx, [eax+40h]
    mov     [eax+ecx*4], ebp
    mov     ecx, [eax+40h]
    inc     ecx
    mov     ebp, eax
    mov     [eax+40h], ecx

    loc_48E62D:                             ; CODE XREF: sub_48E010+552j
    mov     ecx, [edi+4]
    push    ebx                             ; int
    push    offset aVictorytimerru          ; char *
    call    sub_4C46C0
    mov     esi, eax
    cmp     esi, ebx
    jle     short loc_48E678
    push    10h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E668
    lea     ecx, [esi+esi*2]
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    mov     dword ptr [eax], offset off_4FD830
    lea     edx, [ecx+ecx*4]
    shl     edx, 1
    mov     [eax+0Ch], edx
    jmp     short loc_48E66A
    ; ---------------------------------------------------------------------------

    loc_48E668:                             ; CODE XREF: sub_48E010+63Dj
    xor     eax, eax

    loc_48E66A:                             ; CODE XREF: sub_48E010+656j
    mov     ecx, [ebp+40h]
    mov     [ebp+ecx*4+0], eax
    mov     eax, [ebp+40h]
    inc     eax
    mov     [ebp+40h], eax

    loc_48E678:                             ; CODE XREF: sub_48E010+62Fj
    mov     ecx, [edi+4]
    push    ebx                             ; int
    push    offset aCommanderkille          ; char *
    call    sub_4C46C0
    cmp     eax, ebx
    jz      short loc_48E6BF
    push    0Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E6A6
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    mov     dword ptr [eax], offset off_4FD818
    jmp     short loc_48E6A8
    ; ---------------------------------------------------------------------------

    loc_48E6A6:                             ; CODE XREF: sub_48E010+686j
    xor     eax, eax

    loc_48E6A8:                             ; CODE XREF: sub_48E010+694j
    mov     edx, [ebp+84h]
    mov     [ebp+edx*4+44h], eax
    mov     eax, [ebp+84h]
    inc     eax
    mov     [ebp+84h], eax

    loc_48E6BF:                             ; CODE XREF: sub_48E010+678j
    mov     ecx, [edi+4]
    push    ebx                             ; int
    push    offset aAllunitskilled          ; char *
    call    sub_4C46C0
    cmp     eax, ebx
    jz      short loc_48E714
    push    10h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E6FB
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    mov     dword ptr [eax+0Ch], offset off_4FD940
    mov     dword ptr [eax], offset off_4FD800
    mov     dword ptr [eax+0Ch], offset off_4FD7F8
    jmp     short loc_48E6FD
    ; ---------------------------------------------------------------------------

    loc_48E6FB:                             ; CODE XREF: sub_48E010+6CDj
    xor     eax, eax

    loc_48E6FD:                             ; CODE XREF: sub_48E010+6E9j
    mov     ecx, [ebp+84h]
    mov     [ebp+ecx*4+44h], eax
    mov     eax, [ebp+84h]
    inc     eax
    mov     [ebp+84h], eax

    loc_48E714:                             ; CODE XREF: sub_48E010+6BFj
    mov     ecx, [edi+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+234h+var_200]
    push    offset aAllunitskill_0          ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, ebx
    jz      short loc_48E7AA
    push    36h                             ; int
    call    sub_4B4F10
    mov     edx, eax
    add     esp, 4
    cmp     edx, ebx
    jz      short loc_48E791
    mov     [edx+8], ebx
    mov     [edx+4], ebx
    mov     dword ptr [edx+0Ch], offset off_4FD940
    lea     edi, [esp+22Ch+var_200]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     dword ptr [edx], offset off_4FD7E0
    mov     dword ptr [edx+0Ch], offset off_4FD7D8
    repne scasb
    not     ecx
    lea     esi, [edx+10h]
    sub     edi, ecx
    mov     eax, ecx
    mov     [esp+22Ch+var_218], esi
    mov     esi, edi
    mov     edi, [esp+22Ch+var_218]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+22Ch+arg_0]
    jmp     short loc_48E793
    ; ---------------------------------------------------------------------------

    loc_48E791:                             ; CODE XREF: sub_48E010+732j
    xor     edx, edx

    loc_48E793:                             ; CODE XREF: sub_48E010+77Fj
    mov     ecx, [ebp+84h]
    mov     [ebp+ecx*4+44h], edx
    mov     eax, [ebp+84h]
    inc     eax
    mov     [ebp+84h], eax

    loc_48E7AA:                             ; CODE XREF: sub_48E010+722j
    mov     ecx, [edi+4]
    push    offset Data                     ; int
    push    100h                            ; size_t
    lea     edx, [esp+234h+var_200]
    push    offset aUnittypekilled          ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    cmp     eax, ebx
    jz      loc_48E867
    lea     eax, [esp+22Ch+var_218]
    lea     ecx, [esp+22Ch+var_100]
    push    eax
    push    ecx
    lea     edx, [esp+234h+var_200]
    push    offset aAZaZI                   ; "%[a-zA-Z],%i"
    push    edx
    call    _sscanf
    add     esp, 10h
    push    30h                             ; int
    call    sub_4B4F10
    mov     edx, eax
    add     esp, 4
    cmp     edx, ebx
    jz      short loc_48E84E
    mov     eax, [esp+22Ch+var_218]
    lea     edi, [esp+22Ch+var_100]
    mov     [esp+22Ch+var_20C], eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [edx+8], ebx
    mov     [edx+4], ebx
    mov     dword ptr [edx], offset off_4FD7C0
    repne scasb
    not     ecx
    lea     esi, [edx+0Ch]
    sub     edi, ecx
    mov     eax, ecx
    mov     [esp+22Ch+var_214], esi
    mov     esi, edi
    mov     edi, [esp+22Ch+var_214]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+22Ch+var_20C]
    mov     edi, [esp+22Ch+arg_0]
    mov     [edx+2Ch], ecx
    jmp     short loc_48E850
    ; ---------------------------------------------------------------------------

    loc_48E84E:                             ; CODE XREF: sub_48E010+7EBj
    xor     edx, edx

    loc_48E850:                             ; CODE XREF: sub_48E010+83Cj
    mov     eax, [ebp+84h]
    mov     [ebp+eax*4+44h], edx
    mov     eax, [ebp+84h]
    inc     eax
    mov     [ebp+84h], eax

    loc_48E867:                             ; CODE XREF: sub_48E010+7B8j
    mov     ecx, [edi+4]
    push    ebx                             ; int
    push    offset aDeathtimerruns          ; char *
    call    sub_4C46C0
    mov     esi, eax
    cmp     esi, ebx
    jle     short loc_48E8BB
    push    10h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E8A2
    lea     ecx, [esi+esi*2]
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    mov     dword ptr [eax], offset off_4FD7A8
    lea     ecx, [ecx+ecx*4]
    shl     ecx, 1
    mov     [eax+0Ch], ecx
    jmp     short loc_48E8A4
    ; ---------------------------------------------------------------------------

    loc_48E8A2:                             ; CODE XREF: sub_48E010+877j
    xor     eax, eax

    loc_48E8A4:                             ; CODE XREF: sub_48E010+890j
    mov     edx, [ebp+84h]
    mov     [ebp+edx*4+44h], eax
    mov     eax, [ebp+84h]
    inc     eax
    mov     [ebp+84h], eax

    loc_48E8BB:                             ; CODE XREF: sub_48E010+869j
    mov     ecx, [edi+4]
    push    0FFFFFFFFh                      ; int
    push    offset aAnyunitpassesx          ; char *
    call    sub_4C46C0
    mov     esi, eax
    cmp     esi, ebx
    jl      short loc_48E919
    push    14h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E900
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    sar     esi, 4
    mov     dword ptr [eax+0Ch], offset off_4FD940
    mov     dword ptr [eax], offset off_4FD790
    mov     dword ptr [eax+0Ch], offset off_4FD788
    mov     [eax+10h], esi
    jmp     short loc_48E902
    ; ---------------------------------------------------------------------------

    loc_48E900:                             ; CODE XREF: sub_48E010+8CCj
    xor     eax, eax

    loc_48E902:                             ; CODE XREF: sub_48E010+8EEj
    mov     ecx, [ebp+84h]
    mov     [ebp+ecx*4+44h], eax
    mov     eax, [ebp+84h]
    inc     eax
    mov     [ebp+84h], eax

    loc_48E919:                             ; CODE XREF: sub_48E010+8BEj
    mov     ecx, [edi+4]
    push    0FFFFFFFFh                      ; int
    push    offset aAnyunitpassesz          ; char *
    call    sub_4C46C0
    mov     esi, eax
    cmp     esi, ebx
    jl      short loc_48E977
    push    14h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E95E
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    sar     esi, 4
    mov     dword ptr [eax+0Ch], offset off_4FD940
    mov     dword ptr [eax], offset off_4FD770
    mov     dword ptr [eax+0Ch], offset off_4FD768
    mov     [eax+10h], esi
    jmp     short loc_48E960
    ; ---------------------------------------------------------------------------

    loc_48E95E:                             ; CODE XREF: sub_48E010+92Aj
    xor     eax, eax

    loc_48E960:                             ; CODE XREF: sub_48E010+94Cj
    mov     edx, [ebp+84h]
    mov     [ebp+edx*4+44h], eax
    mov     eax, [ebp+84h]
    inc     eax
    mov     [ebp+84h], eax

    loc_48E977:                             ; CODE XREF: sub_48E010+91Cj
    cmp     [ebp+40h], ebx
    jnz     short loc_48E9A8
    push    0Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E998
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    mov     dword ptr [eax], offset off_4FD948
    jmp     short loc_48E99A
    ; ---------------------------------------------------------------------------

    loc_48E998:                             ; CODE XREF: sub_48E010+978j
    xor     eax, eax

    loc_48E99A:                             ; CODE XREF: sub_48E010+986j
    mov     ecx, [ebp+40h]
    mov     [ebp+ecx*4+0], eax
    mov     eax, [ebp+40h]
    inc     eax
    mov     [ebp+40h], eax

    loc_48E9A8:                             ; CODE XREF: sub_48E010+96Aj
    cmp     [ebp+84h], ebx
    jnz     short loc_48E9F1
    push    10h                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_48E9DA
    mov     [eax+8], ebx
    mov     [eax+4], ebx
    mov     dword ptr [eax+0Ch], offset off_4FD940
    mov     dword ptr [eax], offset off_4FD800
    mov     dword ptr [eax+0Ch], offset off_4FD7F8
    mov     ebx, eax

    loc_48E9DA:                             ; CODE XREF: sub_48E010+9ACj
    mov     edx, [ebp+84h]
    mov     [ebp+edx*4+44h], ebx
    mov     eax, [ebp+84h]
    inc     eax
    mov     [ebp+84h], eax

    loc_48E9F1:                             ; CODE XREF: sub_48E010+99Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 21Ch
    retn    4
    sub_48E010 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EA00 proc near                    ; DATA XREF: .rdata:004FD7C0o
                                            ; .rdata:004FD7E0o ...
    mov     eax, [ecx+4]
    retn
    sub_48EA00 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_71. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_72. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_73. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EA40 proc near                    ; DATA XREF: .rdata:004FD964o

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    esi
    mov     esi, ecx
    cmp     byte ptr [edx+0FFh], 1
    jnz     short loc_48EAB2
    mov     eax, [edx+96h]
    mov     edx, [edx+92h]
    add     edx, 20h
    mov     ecx, [eax+27h]
    xor     eax, eax
    mov     al, [ecx+95h]
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    mov     eax, TAdynmemStructPtr
    lea     ecx, [eax+ecx*2+37F5Fh]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48EAB2
    mov     eax, [esi+8]
    mov     dword ptr [esi+4], 1
    test    eax, eax
    jnz     short loc_48EAB2
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     dword ptr [esi+8], 1

    loc_48EAB2:                             ; CODE XREF: sub_48EA40+Ej
                                            ; sub_48EA40+4Fj ...
    pop     esi
    retn    4
    sub_48EA40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EAC0 proc near                    ; DATA XREF: .rdata:004FD970o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictoryconditi          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48EAC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EB00 proc near                    ; DATA XREF: .rdata:004FD974o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictoryconditi          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48EB00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EB40 proc near                    ; DATA XREF: .rdata:004FD948o
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     esi, ecx
    cmp     word ptr [eax+1DF2h], 0
    jnz     short loc_48EB73
    mov     eax, [esi+8]
    test    eax, eax
    jnz     short loc_48EB6C
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     dword ptr [esi+8], 1

    loc_48EB6C:                             ; CODE XREF: sub_48EB40+17j
    mov     eax, 1
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_48EB73:                             ; CODE XREF: sub_48EB40+10j
    xor     eax, eax
    pop     esi
    retn
    sub_48EB40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EB80 proc near                    ; DATA XREF: .rdata:004FD958o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_0          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48EB80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EBC0 proc near                    ; DATA XREF: .rdata:004FD95Co

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_0          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48EBC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EC00 proc near                    ; DATA XREF: .rdata:004FD920o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    cmp     dword ptr [eax], 0
    jz      short loc_48EC0C
    inc     dword ptr [ecx+4]

    loc_48EC0C:                             ; CODE XREF: sub_48EC00+7j
    mov     edx, [ecx+4]
    xor     eax, eax
    cmp     edx, 1
    setle   al
    retn    4
    sub_48EC00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EC20 proc near                    ; DATA XREF: .rdata:004FD92Co

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     cl, [eax+0FFh]
    push    esi
    cmp     cl, 1
    push    edi
    jnz     short loc_48ECA9
    mov     ecx, [eax]
    xor     edi, edi
    cmp     ecx, edi
    jz      short loc_48ECA9
    cmp     ebx, edi
    mov     [ebx+10h], edi
    jz      short loc_48EC47
    lea     edi, [ebx+0Ch]

    loc_48EC47:                             ; CODE XREF: sub_48EC20+22j
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+1D15h]
    lea     ebp, [eax+1D19h]
    mov     eax, [eax+1D19h]
    cmp     esi, eax
    ja      short loc_48EC84

    loc_48EC62:                             ; CODE XREF: sub_48EC20+62j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48EC77
    mov     eax, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [eax]
    test    eax, eax
    jz      short loc_48EC84

    loc_48EC77:                             ; CODE XREF: sub_48EC20+4Aj
    mov     eax, [ebp+0]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48EC62

    loc_48EC84:                             ; CODE XREF: sub_48EC20+40j
                                            ; sub_48EC20+55j
    mov     eax, [ebx+10h]
    mov     esi, 1
    cmp     eax, esi
    jg      short loc_48ECA9
    mov     eax, [ebx+8]
    mov     [ebx+4], esi
    test    eax, eax
    jnz     short loc_48ECA9
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     [ebx+8], esi

    loc_48ECA9:                             ; CODE XREF: sub_48EC20+13j
                                            ; sub_48EC20+1Bj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_48EC20 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48ECB0 proc near                    ; DATA XREF: .rdata:004FD938o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_1          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+10h]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aNumunits                ; char *
    call    sub_4B4630
    mov     ecx, [esi+4]
    push    ecx                             ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4630
    mov     edx, [esi+8]
    mov     ecx, edi
    push    edx                             ; int
    push    offset aCelebrated              ; char *
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48ECB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48ED00 proc near                    ; DATA XREF: .rdata:004FD93Co

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_1          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aNumunits                ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    mov     [esi+10h], eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48ED00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48ED50 proc near                    ; DATA XREF: .rdata:004FD900o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, ecx
    mov     cx, [eax+0A6h]
    cmp     cx, [esi+24h]
    jnz     short loc_48ED98
    fld     dword ptr [eax+104h]
    fcomp   ds:flt_4FD978
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48ED98
    mov     dword ptr [esi-8], 1
    mov     eax, [esi-4]
    test    eax, eax
    jnz     short loc_48ED98
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     dword ptr [esi-4], 1

    loc_48ED98:                             ; CODE XREF: sub_48ED50+12j
                                            ; sub_48ED50+25j ...
    mov     ecx, [esi-8]
    xor     eax, eax
    test    ecx, ecx
    setz    al
    pop     esi
    retn    4
    sub_48ED50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EDB0 proc near                    ; DATA XREF: .rdata:004FD908o
    push    ebp
    mov     ebp, ecx
    mov     eax, [ebp+4]
    test    eax, eax
    jz      short loc_48EDC1
    mov     eax, 1
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------

    loc_48EDC1:                             ; CODE XREF: sub_48EDB0+8j
    cmp     word ptr [ebp+30h], 0
    push    edi
    push    esi
    push    ebx
    jnz     short loc_48EDD8
    lea     eax, [ebp+10h]
    push    eax                             ; char *
    call    sub_488B10
    mov     [ebp+30h], ax

    loc_48EDD8:                             ; CODE XREF: sub_48EDB0+19j
    test    ebp, ebp
    jz      short loc_48EDE1
    lea     edi, [ebp+0Ch]
    jmp     short loc_48EDE3
    ; ---------------------------------------------------------------------------

    loc_48EDE1:                             ; CODE XREF: sub_48EDB0+2Aj
    xor     edi, edi

    loc_48EDE3:                             ; CODE XREF: sub_48EDB0+2Fj
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+1BCAh]
    lea     ebx, [eax+1BCEh]
    mov     eax, [eax+1BCEh]
    cmp     esi, eax
    ja      short loc_48EE1F

    loc_48EDFE:                             ; CODE XREF: sub_48EDB0+6Dj
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48EE13
    mov     edx, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [edx]
    test    eax, eax
    jz      short loc_48EE1F

    loc_48EE13:                             ; CODE XREF: sub_48EDB0+56j
    mov     eax, [ebx]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48EDFE

    loc_48EE1F:                             ; CODE XREF: sub_48EDB0+4Cj
                                            ; sub_48EDB0+61j
    mov     eax, [ebp+4]
    pop     ebx
    pop     esi
    pop     edi
    pop     ebp
    retn
    sub_48EDB0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EE30 proc near                    ; DATA XREF: .rdata:004FD918o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_2          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48EE30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EE70 proc near                    ; DATA XREF: .rdata:004FD91Co

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_2          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48EE70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EEB0 proc near                    ; DATA XREF: .rdata:004FD8F0o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, ecx
    cmp     byte ptr [eax+0FFh], 1
    jnz     short loc_48EEFB
    mov     eax, [eax+92h]
    lea     ecx, [esi+0Ch]
    add     eax, 20h
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48EEFB
    mov     eax, [esi+8]
    mov     dword ptr [esi+4], 1
    test    eax, eax
    jnz     short loc_48EEFB
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     dword ptr [esi+8], 1

    loc_48EEFB:                             ; CODE XREF: sub_48EEB0+Ej
                                            ; sub_48EEB0+28j ...
    pop     esi
    retn    4
    sub_48EEB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EF00 proc near                    ; DATA XREF: .rdata:004FD8F8o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_3          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48EF00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EF40 proc near                    ; DATA XREF: .rdata:004FD8FCo

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_3          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48EF40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EF80 proc near                    ; DATA XREF: .rdata:004FD8C8o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     dx, [eax+0A6h]
    cmp     dx, [ecx+24h]
    jnz     short loc_48EF94
    inc     dword ptr [ecx+26h]

    loc_48EF94:                             ; CODE XREF: sub_48EF80+Fj
    mov     edx, [ecx+26h]
    xor     eax, eax
    cmp     edx, 1
    setle   al
    retn    4
    sub_48EF80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48EFB0 proc near                    ; DATA XREF: .rdata:004FD8D4o

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    xor     edi, edi
    cmp     [ebp+4], edi
    jnz     loc_48F061
    mov     eax, [esp+8+arg_0]
    cmp     byte ptr [eax+0FFh], 1
    jnz     loc_48F061
    mov     eax, [eax+92h]
    lea     esi, [ebp+10h]
    add     eax, 20h
    push    eax                             ; char *
    push    esi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48F061
    push    esi                             ; char *
    call    sub_488B10
    cmp     ebp, edi
    mov     [ebp+30h], ax
    mov     [ebp+32h], edi
    jz      short loc_48F000
    lea     edi, [ebp+0Ch]

    loc_48F000:                             ; CODE XREF: sub_48EFB0+4Bj
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+1D15h]
    lea     ebx, [eax+1D19h]
    mov     eax, [eax+1D19h]
    cmp     esi, eax
    ja      short loc_48F03C

    loc_48F01B:                             ; CODE XREF: sub_48EFB0+8Aj
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48F030
    mov     edx, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [edx]
    test    eax, eax
    jz      short loc_48F03C

    loc_48F030:                             ; CODE XREF: sub_48EFB0+73j
    mov     eax, [ebx]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48F01B

    loc_48F03C:                             ; CODE XREF: sub_48EFB0+69j
                                            ; sub_48EFB0+7Ej
    mov     eax, [ebp+32h]
    mov     esi, 1
    cmp     eax, esi
    jg      short loc_48F061
    mov     eax, [ebp+8]
    mov     [ebp+4], esi
    test    eax, eax
    jnz     short loc_48F061
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     [ebp+8], esi

    loc_48F061:                             ; CODE XREF: sub_48EFB0+Bj
                                            ; sub_48EFB0+1Cj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_48EFB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F070 proc near                    ; DATA XREF: .rdata:004FD8E0o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_4          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48F070 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F0B0 proc near                    ; DATA XREF: .rdata:004FD8E4o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_4          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48F0B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F0F0 proc near                    ; DATA XREF: .rdata:004FD8B4o

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    mov     eax, [esi+2Ch]
    test    eax, eax
    jle     short loc_48F14F
    mov     eax, [esp+arg_0]
    cmp     byte ptr [eax+0FFh], 1
    jnz     short loc_48F14F
    mov     eax, [eax+92h]
    lea     ecx, [esi+0Ch]
    add     eax, 20h
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48F14F
    mov     ecx, [esi+2Ch]
    dec     ecx
    mov     eax, ecx
    mov     [esi+2Ch], ecx
    test    eax, eax
    jg      short loc_48F14F
    mov     eax, [esi+8]
    mov     dword ptr [esi+4], 1
    test    eax, eax
    jnz     short loc_48F14F
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     dword ptr [esi+8], 1

    loc_48F14F:                             ; CODE XREF: sub_48F0F0+8j
                                            ; sub_48F0F0+15j ...
    pop     esi
    retn    4
    sub_48F0F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F160 proc near                    ; DATA XREF: .rdata:004FD8C0o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_5          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+2Ch]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aNumlefttokill           ; char *
    call    sub_4B4630
    mov     ecx, [esi+4]
    push    ecx                             ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4630
    mov     edx, [esi+8]
    mov     ecx, edi
    push    edx                             ; int
    push    offset aCelebrated              ; char *
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48F160 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F1B0 proc near                    ; DATA XREF: .rdata:004FD8C4o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_5          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aNumlefttokill           ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    mov     [esi+2Ch], eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48F1B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F200 proc near                    ; DATA XREF: .rdata:004FD890o
    push    esi
    mov     esi, ecx
    cmp     dword ptr [esi+34h], 12345678h
    jnz     short loc_48F21D
    mov     ecx, [esi+38h]
    mov     edx, [esi+30h]
    lea     eax, [esi+30h]
    push    eax
    push    ecx
    push    edx
    call    sub_484B50

    loc_48F21D:                             ; CODE XREF: sub_48F200+Aj
    test    esi, esi
    jz      short loc_48F237
    lea     eax, [esi+0Ch]
    lea     ecx, [esi+30h]
    push    eax
    mov     eax, [esi+3Ch]
    push    eax
    push    ecx
    call    sub_47E890
    mov     eax, [esi+4]
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_48F237:                             ; CODE XREF: sub_48F200+1Fj
    xor     eax, eax
    lea     ecx, [esi+30h]
    push    eax
    mov     eax, [esi+3Ch]
    push    eax
    push    ecx
    call    sub_47E890
    mov     eax, [esi+4]
    pop     esi
    retn
    sub_48F200 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F250 proc near                    ; DATA XREF: .rdata:004FD888o

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, ecx
    mov     al, [esi+0FFh]
    test    al, al
    jnz     short loc_48F2DD
    mov     cl, [edi+4]
    lea     eax, [edi+4]
    test    cl, cl
    jz      short loc_48F283
    mov     ecx, [esi+92h]
    add     ecx, 20h
    push    ecx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48F2DD

    loc_48F283:                             ; CODE XREF: sub_48F250+1Aj
    test    byte ptr [esi+110h], 20h
    jz      short loc_48F2DD
    fld     dword ptr [esi+104h]
    fcomp   ds:flt_4FD978
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48F2DD
    mov     eax, [esi+0FBh]
    test    eax, eax
    jnz     short loc_48F2DD
    mov     esi, [esi+86h]
    test    esi, esi
    jz      short loc_48F2BF
    test    dword ptr [esi+110h], 40000000h
    jz      short loc_48F2DD

    loc_48F2BF:                             ; CODE XREF: sub_48F250+61j
    mov     esi, 1
    mov     [edi-8], esi
    mov     eax, [edi-4]
    test    eax, eax
    jnz     short loc_48F2DD
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     [edi-4], esi

    loc_48F2DD:                             ; CODE XREF: sub_48F250+10j
                                            ; sub_48F250+31j ...
    pop     edi
    pop     esi
    retn    4
    sub_48F250 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F2F0 proc near                    ; DATA XREF: .rdata:004FD8A0o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_6          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48F2F0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F330 proc near                    ; DATA XREF: .rdata:004FD8A4o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_6          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48F330 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F370 proc near                    ; DATA XREF: .rdata:004FD868o

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    mov     cl, [esi+4]
    push    edi
    mov     edi, [esp+4+arg_0]
    lea     eax, [esi+4]
    test    cl, cl
    jz      short loc_48F399
    mov     ecx, [edi+92h]
    add     ecx, 20h
    push    ecx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48F3C8

    loc_48F399:                             ; CODE XREF: sub_48F370+10j
    movsx   eax, word ptr [edi+76h]
    sub     eax, [esi+24h]
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 2
    jg      short loc_48F3C8
    mov     edi, 1
    mov     [esi-8], edi
    mov     eax, [esi-4]
    test    eax, eax
    jnz     short loc_48F3C8
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     [esi-4], edi

    loc_48F3C8:                             ; CODE XREF: sub_48F370+27j
                                            ; sub_48F370+38j ...
    mov     ecx, [esi-8]
    xor     eax, eax
    test    ecx, ecx
    pop     edi
    pop     esi
    setz    al
    retn    4
    sub_48F370 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F3E0 proc near                    ; DATA XREF: .rdata:004FD870o
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     eax, [ebp+4]
    test    eax, eax
    jnz     short loc_48F434
    test    ebp, ebp
    jz      short loc_48F3F6
    lea     edi, [ebp+0Ch]
    jmp     short loc_48F3F8
    ; ---------------------------------------------------------------------------

    loc_48F3F6:                             ; CODE XREF: sub_48F3E0+Fj
    xor     edi, edi

    loc_48F3F8:                             ; CODE XREF: sub_48F3E0+14j
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+1BCAh]
    lea     ebx, [eax+1BCEh]
    mov     eax, [eax+1BCEh]
    cmp     esi, eax
    ja      short loc_48F434

    loc_48F413:                             ; CODE XREF: sub_48F3E0+52j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48F428
    mov     eax, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [eax]
    test    eax, eax
    jz      short loc_48F434

    loc_48F428:                             ; CODE XREF: sub_48F3E0+3Bj
    mov     eax, [ebx]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48F413

    loc_48F434:                             ; CODE XREF: sub_48F3E0+Bj
                                            ; sub_48F3E0+31j ...
    mov     eax, [ebp+4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_48F3E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F440 proc near                    ; DATA XREF: .rdata:004FD880o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_7          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48F440 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F480 proc near                    ; DATA XREF: .rdata:004FD884o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_7          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48F480 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F4C0 proc near                    ; DATA XREF: .rdata:004FD848o

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    mov     cl, [esi+4]
    push    edi
    mov     edi, [esp+4+arg_0]
    lea     eax, [esi+4]
    test    cl, cl
    jz      short loc_48F4E9
    mov     ecx, [edi+92h]
    add     ecx, 20h
    push    ecx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48F518

    loc_48F4E9:                             ; CODE XREF: sub_48F4C0+10j
    movsx   eax, word ptr [edi+78h]
    sub     eax, [esi+24h]
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 2
    jg      short loc_48F518
    mov     edi, 1
    mov     [esi-8], edi
    mov     eax, [esi-4]
    test    eax, eax
    jnz     short loc_48F518
    push    0                               ; int
    push    offset aVictoryConditi          ; char *
    call    sub_47F1A0
    mov     [esi-4], edi

    loc_48F518:                             ; CODE XREF: sub_48F4C0+27j
                                            ; sub_48F4C0+38j ...
    mov     ecx, [esi-8]
    xor     eax, eax
    test    ecx, ecx
    pop     edi
    pop     esi
    setz    al
    retn    4
    sub_48F4C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F530 proc near                    ; DATA XREF: .rdata:004FD850o
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     eax, [ebp+4]
    test    eax, eax
    jnz     short loc_48F584
    test    ebp, ebp
    jz      short loc_48F546
    lea     edi, [ebp+0Ch]
    jmp     short loc_48F548
    ; ---------------------------------------------------------------------------

    loc_48F546:                             ; CODE XREF: sub_48F530+Fj
    xor     edi, edi

    loc_48F548:                             ; CODE XREF: sub_48F530+14j
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+1BCAh]
    lea     ebx, [eax+1BCEh]
    mov     eax, [eax+1BCEh]
    cmp     esi, eax
    ja      short loc_48F584

    loc_48F563:                             ; CODE XREF: sub_48F530+52j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48F578
    mov     eax, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [eax]
    test    eax, eax
    jz      short loc_48F584

    loc_48F578:                             ; CODE XREF: sub_48F530+3Bj
    mov     eax, [ebx]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48F563

    loc_48F584:                             ; CODE XREF: sub_48F530+Bj
                                            ; sub_48F530+31j ...
    mov     eax, [ebp+4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_48F530 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F590 proc near                    ; DATA XREF: .rdata:004FD860o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_8          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48F590 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F5D0 proc near                    ; DATA XREF: .rdata:004FD864o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_8          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48F5D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F610 proc near                    ; DATA XREF: .rdata:004FD830o
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+38A47h]
    mov     eax, [ecx+0Ch]
    cmp     edx, eax
    sbb     eax, eax
    inc     eax
    retn
    sub_48F610 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F630 proc near                    ; DATA XREF: .rdata:004FD840o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_9          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48F630 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F670 proc near                    ; DATA XREF: .rdata:004FD844o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aVictorycondi_9          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48F670 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F6B0 proc near                    ; DATA XREF: .rdata:004FD81Co

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    esi
    mov     esi, ecx
    mov     al, [edx+0FFh]
    test    al, al
    jnz     short loc_48F709
    mov     eax, [edx+96h]
    mov     edx, [edx+92h]
    add     edx, 20h
    mov     ecx, [eax+27h]
    xor     eax, eax
    mov     al, [ecx+95h]
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    mov     eax, TAdynmemStructPtr
    lea     ecx, [eax+ecx*2+37F5Fh]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48F709
    mov     dword ptr [esi+4], 1

    loc_48F709:                             ; CODE XREF: sub_48F6B0+Fj
                                            ; sub_48F6B0+50j
    pop     esi
    retn    4
    sub_48F6B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F710 proc near                    ; DATA XREF: .rdata:004FD828o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatconditio          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48F710 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F750 proc near                    ; DATA XREF: .rdata:004FD82Co

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatconditio          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48F750 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F790 proc near                    ; DATA XREF: .rdata:004FD7F8o

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    test    byte ptr [edx+110h], 20h
    jz      short loc_48F7D7
    fld     dword ptr [edx+104h]
    fcomp   ds:flt_4FD978
    fnstsw  ax
    test    ah, 40h
    jz      short loc_48F7D7
    mov     eax, [edx+0FBh]
    test    eax, eax
    jnz     short loc_48F7D7
    mov     edx, [edx+86h]
    test    edx, edx
    jz      short loc_48F7D0
    test    dword ptr [edx+110h], 40000000h
    jz      short loc_48F7D7

    loc_48F7D0:                             ; CODE XREF: sub_48F790+32j
    mov     dword ptr [ecx-8], 0

    loc_48F7D7:                             ; CODE XREF: sub_48F790+Bj
                                            ; sub_48F790+1Ej ...
    mov     eax, [ecx-8]
    retn    4
    sub_48F790 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F7E0 proc near                    ; DATA XREF: .rdata:004FD800o
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    test    ebp, ebp
    push    edi
    mov     dword ptr [ebp+4], 1
    jz      short loc_48F7F6
    lea     edi, [ebp+0Ch]
    jmp     short loc_48F7F8
    ; ---------------------------------------------------------------------------

    loc_48F7F6:                             ; CODE XREF: sub_48F7E0+Fj
    xor     edi, edi

    loc_48F7F8:                             ; CODE XREF: sub_48F7E0+14j
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+1BCAh]
    lea     ebx, [eax+1BCEh]
    mov     eax, [eax+1BCEh]
    cmp     esi, eax
    ja      short loc_48F834

    loc_48F813:                             ; CODE XREF: sub_48F7E0+52j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48F828
    mov     eax, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [eax]
    test    eax, eax
    jz      short loc_48F834

    loc_48F828:                             ; CODE XREF: sub_48F7E0+3Bj
    mov     eax, [ebx]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48F813

    loc_48F834:                             ; CODE XREF: sub_48F7E0+31j
                                            ; sub_48F7E0+46j
    mov     eax, [ebp+4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_48F7E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F840 proc near                    ; DATA XREF: .rdata:004FD810o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_0          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48F840 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F880 proc near                    ; DATA XREF: .rdata:004FD814o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_0          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48F880 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F8C0 proc near                    ; DATA XREF: .rdata:004FD7C4o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, ecx
    mov     ecx, [eax+92h]
    add     ecx, 20h
    lea     edx, [esi+0Ch]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_48F8F5
    mov     ecx, [esi+2Ch]
    dec     ecx
    mov     eax, ecx
    mov     [esi+2Ch], ecx
    test    eax, eax
    jg      short loc_48F8F5
    mov     dword ptr [esi+4], 1

    loc_48F8F5:                             ; CODE XREF: sub_48F8C0+1Fj
                                            ; sub_48F8C0+2Cj
    pop     esi
    retn    4
    sub_48F8C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F900 proc near                    ; DATA XREF: .rdata:004FD7D0o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_1          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+2Ch]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aNumlefttokill           ; char *
    call    sub_4B4630
    mov     ecx, [esi+4]
    push    ecx                             ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4630
    mov     edx, [esi+8]
    mov     ecx, edi
    push    edx                             ; int
    push    offset aCelebrated              ; char *
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48F900 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F950 proc near                    ; DATA XREF: .rdata:004FD7D4o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_1          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aNumlefttokill           ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    mov     [esi+2Ch], eax
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48F950 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F9A0 proc near                    ; DATA XREF: .rdata:004FD7D8o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     dx, [eax+0A6h]
    cmp     dx, [ecx+24h]
    jnz     short loc_48F9B4
    inc     dword ptr [ecx+26h]

    loc_48F9B4:                             ; CODE XREF: sub_48F9A0+Fj
    mov     edx, [ecx+26h]
    xor     eax, eax
    cmp     edx, 1
    setle   al
    retn    4
    sub_48F9A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48F9D0 proc near                    ; DATA XREF: .rdata:004FD7E4o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    mov     ebp, ecx
    mov     ecx, [eax+92h]
    push    esi
    add     ecx, 20h
    push    edi
    lea     esi, [ebp+10h]
    push    ecx                             ; char *
    push    esi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     loc_48FAA2
    push    esi                             ; char *
    call    sub_488B10
    xor     edi, edi
    mov     [ebp+30h], ax
    cmp     ebp, edi
    mov     [ebp+32h], edi
    jz      short loc_48FA0E
    lea     edi, [ebp+0Ch]

    loc_48FA0E:                             ; CODE XREF: sub_48F9D0+39j
    mov     ebx, TAdynmemStructPtr
    mov     esi, [ebx+1BCAh]
    mov     eax, [ebx+1BCEh]
    add     ebx, 1BCEh
    cmp     esi, eax
    ja      short loc_48FA4B

    loc_48FA2A:                             ; CODE XREF: sub_48F9D0+79j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48FA3F
    mov     edx, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [edx]
    test    eax, eax
    jz      short loc_48FA4B

    loc_48FA3F:                             ; CODE XREF: sub_48F9D0+62j
    mov     eax, [ebx]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48FA2A

    loc_48FA4B:                             ; CODE XREF: sub_48F9D0+58j
                                            ; sub_48F9D0+6Dj
    test    ebp, ebp
    jz      short loc_48FA54
    lea     edi, [ebp+0Ch]
    jmp     short loc_48FA56
    ; ---------------------------------------------------------------------------

    loc_48FA54:                             ; CODE XREF: sub_48F9D0+7Dj
    xor     edi, edi

    loc_48FA56:                             ; CODE XREF: sub_48F9D0+82j
    mov     ebx, TAdynmemStructPtr
    mov     esi, [ebx+1D15h]
    mov     eax, [ebx+1D19h]
    add     ebx, 1D19h
    cmp     esi, eax
    ja      short loc_48FA93

    loc_48FA72:                             ; CODE XREF: sub_48F9D0+C1j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48FA87
    mov     eax, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [eax]
    test    eax, eax
    jz      short loc_48FA93

    loc_48FA87:                             ; CODE XREF: sub_48F9D0+AAj
    mov     eax, [ebx]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48FA72

    loc_48FA93:                             ; CODE XREF: sub_48F9D0+A0j
                                            ; sub_48F9D0+B5j
    mov     ecx, [ebp+32h]
    mov     eax, 1
    cmp     ecx, eax
    jg      short loc_48FAA2
    mov     [ebp+4], eax

    loc_48FAA2:                             ; CODE XREF: sub_48F9D0+22j
                                            ; sub_48F9D0+CDj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_48F9D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FAB0 proc near                    ; DATA XREF: .rdata:004FD7F0o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_2          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48FAB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FAF0 proc near                    ; DATA XREF: .rdata:004FD7F4o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_2          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48FAF0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FB30 proc near                    ; DATA XREF: .rdata:004FD788o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+4]
    movsx   eax, word ptr [eax+76h]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 2
    jg      short loc_48FB4E
    mov     dword ptr [ecx-8], 1

    loc_48FB4E:                             ; CODE XREF: sub_48FB30+15j
    mov     edx, [ecx-8]
    xor     eax, eax
    test    edx, edx
    setz    al
    retn    4
    sub_48FB30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FB60 proc near                    ; DATA XREF: .rdata:004FD790o
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     eax, [ebp+4]
    test    eax, eax
    jnz     short loc_48FBB4
    test    ebp, ebp
    jz      short loc_48FB76
    lea     edi, [ebp+0Ch]
    jmp     short loc_48FB78
    ; ---------------------------------------------------------------------------

    loc_48FB76:                             ; CODE XREF: sub_48FB60+Fj
    xor     edi, edi

    loc_48FB78:                             ; CODE XREF: sub_48FB60+14j
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+1D15h]
    lea     ebx, [eax+1D19h]
    mov     eax, [eax+1D19h]
    cmp     esi, eax
    ja      short loc_48FBB4

    loc_48FB93:                             ; CODE XREF: sub_48FB60+52j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48FBA8
    mov     eax, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [eax]
    test    eax, eax
    jz      short loc_48FBB4

    loc_48FBA8:                             ; CODE XREF: sub_48FB60+3Bj
    mov     eax, [ebx]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48FB93

    loc_48FBB4:                             ; CODE XREF: sub_48FB60+Bj
                                            ; sub_48FB60+31j ...
    mov     eax, [ebp+4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_48FB60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FBC0 proc near                    ; DATA XREF: .rdata:004FD7A0o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_3          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48FBC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FC00 proc near                    ; DATA XREF: .rdata:004FD7A4o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_3          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48FC00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FC40 proc near                    ; DATA XREF: .rdata:004FD768o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+4]
    movsx   eax, word ptr [eax+78h]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 2
    jg      short loc_48FC5E
    mov     dword ptr [ecx-8], 1

    loc_48FC5E:                             ; CODE XREF: sub_48FC40+15j
    mov     edx, [ecx-8]
    xor     eax, eax
    test    edx, edx
    setz    al
    retn    4
    sub_48FC40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FC70 proc near                    ; DATA XREF: .rdata:004FD770o
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     eax, [ebp+4]
    test    eax, eax
    jnz     short loc_48FCC4
    test    ebp, ebp
    jz      short loc_48FC86
    lea     edi, [ebp+0Ch]
    jmp     short loc_48FC88
    ; ---------------------------------------------------------------------------

    loc_48FC86:                             ; CODE XREF: sub_48FC70+Fj
    xor     edi, edi

    loc_48FC88:                             ; CODE XREF: sub_48FC70+14j
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+1D15h]
    lea     ebx, [eax+1D19h]
    mov     eax, [eax+1D19h]
    cmp     esi, eax
    ja      short loc_48FCC4

    loc_48FCA3:                             ; CODE XREF: sub_48FC70+52j
    cmp     word ptr [esi+0A6h], 0
    jz      short loc_48FCB8
    mov     eax, [edi]
    push    esi
    mov     ecx, edi
    call    dword ptr [eax]
    test    eax, eax
    jz      short loc_48FCC4

    loc_48FCB8:                             ; CODE XREF: sub_48FC70+3Bj
    mov     eax, [ebx]
    add     esi, 118h
    cmp     esi, eax
    jbe     short loc_48FCA3

    loc_48FCC4:                             ; CODE XREF: sub_48FC70+Bj
                                            ; sub_48FC70+31j ...
    mov     eax, [ebp+4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_48FC70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FCD0 proc near                    ; DATA XREF: .rdata:004FD780o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_4          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48FCD0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FD10 proc near                    ; DATA XREF: .rdata:004FD784o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_4          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48FD10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FD50 proc near                    ; DATA XREF: .rdata:004FD7A8o
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+38A47h]
    mov     eax, [ecx+0Ch]
    cmp     edx, eax
    sbb     eax, eax
    inc     eax
    retn
    sub_48FD50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FD70 proc near                    ; DATA XREF: .rdata:004FD7B8o

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_5          ; char *
    mov     ecx, edi
    call    sub_4B4560
    mov     eax, [esi+4]
    mov     ecx, edi
    push    eax                             ; int
    push    offset aSatisfied               ; char *
    call    sub_4B4630
    mov     ecx, [esi+8]
    push    ecx                             ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    call    sub_4B4630
    pop     edi
    pop     esi
    retn    4
    sub_48FD70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FDB0 proc near                    ; DATA XREF: .rdata:004FD7BCo

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    offset aDefeatcondit_5          ; char *
    mov     ecx, edi
    call    sub_4B4560
    push    0                               ; int
    push    offset aSatisfied               ; char *
    mov     ecx, edi
    call    sub_4B4800
    push    0                               ; int
    push    offset aCelebrated              ; char *
    mov     ecx, edi
    mov     [esi+4], eax
    call    sub_4B4800
    mov     [esi+8], eax
    pop     edi
    pop     esi
    retn    4
    sub_48FDB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FDF0 proc near                    ; CODE XREF: sub_4326B0+398p

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_48FE52
    mov     eax, [esi+40h]
    mov     ebp, [esp+10h+arg_0]
    xor     edi, edi
    test    eax, eax
    jle     short loc_48FE2D
    mov     ebx, esi

    loc_48FE1A:                             ; CODE XREF: sub_48FDF0+3Bj
    mov     ecx, [ebx]
    push    ebp
    mov     edx, [ecx]
    call    dword ptr [edx+10h]
    mov     eax, [esi+40h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_48FE1A

    loc_48FE2D:                             ; CODE XREF: sub_48FDF0+26j
    mov     eax, [esi+84h]
    xor     edi, edi
    test    eax, eax
    jle     short loc_48FE52
    lea     ebx, [esi+44h]

    loc_48FE3C:                             ; CODE XREF: sub_48FDF0+60j
    mov     ecx, [ebx]
    push    ebp
    mov     eax, [ecx]
    call    dword ptr [eax+10h]
    mov     eax, [esi+84h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_48FE3C

    loc_48FE52:                             ; CODE XREF: sub_48FDF0+19j
                                            ; sub_48FDF0+47j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_48FDF0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_48FE60 proc near                    ; CODE XREF: sub_432610+7Ap

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_48FEC2
    mov     eax, [esi+40h]
    mov     ebp, [esp+10h+arg_0]
    xor     edi, edi
    test    eax, eax
    jle     short loc_48FE9D
    mov     ebx, esi

    loc_48FE8A:                             ; CODE XREF: sub_48FE60+3Bj
    mov     ecx, [ebx]
    push    ebp
    mov     edx, [ecx]
    call    dword ptr [edx+14h]
    mov     eax, [esi+40h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_48FE8A

    loc_48FE9D:                             ; CODE XREF: sub_48FE60+26j
    mov     eax, [esi+84h]
    xor     edi, edi
    test    eax, eax
    jle     short loc_48FEC2
    lea     ebx, [esi+44h]

    loc_48FEAC:                             ; CODE XREF: sub_48FE60+60j
    mov     ecx, [ebx]
    push    ebp
    mov     eax, [ecx]
    call    dword ptr [eax+14h]
    mov     eax, [esi+84h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_48FEAC

    loc_48FEC2:                             ; CODE XREF: sub_48FE60+19j
                                            ; sub_48FE60+47j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_48FE60 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    mov     ebx, ecx
    push    esi
    xor     esi, esi
    mov     eax, [ebx+40h]
    push    edi
    cmp     eax, esi
    jnz     short loc_48FF0B
    push    0Ch
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, esi
    jz      short loc_48FEFA
    mov     [eax+8], esi
    mov     [eax+4], esi
    mov     dword ptr [eax], offset off_4FD948
    jmp     short loc_48FEFC
    ; ---------------------------------------------------------------------------

    loc_48FEFA:                             ; CODE XREF: .text:0048FEEAj
    xor     eax, eax

    loc_48FEFC:                             ; CODE XREF: .text:0048FEF8j
    mov     ecx, [ebx+40h]
    mov     [ebx+ecx*4], eax
    mov     eax, [ebx+40h]
    inc     eax
    mov     [ebx+40h], eax
    cmp     eax, esi

    loc_48FF0B:                             ; CODE XREF: .text:0048FEDCj
    jle     short loc_48FF33
    mov     edi, ebx

    loc_48FF0F:                             ; CODE XREF: .text:0048FF22j
    mov     ecx, [edi]
    mov     edx, [ecx]
    call    dword ptr [edx]
    test    eax, eax
    jz      short loc_48FF2D
    mov     eax, [ebx+40h]
    inc     esi
    add     edi, 4
    cmp     esi, eax
    jl      short loc_48FF0F
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_48FF2D:                             ; CODE XREF: .text:0048FF17j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_48FF33:                             ; CODE XREF: .text:0048FF0Bj
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    mov     ebx, ecx
    push    esi
    xor     esi, esi
    mov     eax, [ebx+84h]
    push    edi
    cmp     eax, esi
    jnz     short loc_48FF96
    push    10h
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, esi
    jz      short loc_48FF7B
    mov     [eax+8], esi
    mov     [eax+4], esi
    mov     dword ptr [eax+0Ch], offset off_4FD940
    mov     dword ptr [eax], offset off_4FD800
    mov     dword ptr [eax+0Ch], offset off_4FD7F8
    jmp     short loc_48FF7D
    ; ---------------------------------------------------------------------------

    loc_48FF7B:                             ; CODE XREF: .text:0048FF5Dj
    xor     eax, eax

    loc_48FF7D:                             ; CODE XREF: .text:0048FF79j
    mov     ecx, [ebx+84h]
    mov     [ebx+ecx*4+44h], eax
    mov     eax, [ebx+84h]
    inc     eax
    mov     [ebx+84h], eax
    cmp     eax, esi

    loc_48FF96:                             ; CODE XREF: .text:0048FF4Fj
    jle     short loc_48FFC2
    lea     edi, [ebx+44h]

    loc_48FF9B:                             ; CODE XREF: .text:0048FFB1j
    mov     ecx, [edi]
    mov     edx, [ecx]
    call    dword ptr [edx]
    test    eax, eax
    jnz     short loc_48FFB9
    mov     eax, [ebx+84h]
    inc     esi
    add     edi, 4
    cmp     esi, eax
    jl      short loc_48FF9B
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_48FFB9:                             ; CODE XREF: .text:0048FFA3j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_48FFC2:                             ; CODE XREF: .text:0048FF96j
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    push    ebx
    push    esi
    mov     esi, TAdynmemStructPtr
    push    edi
    mov     edx, esi
    mov     bl, [esi+2A42h]
    mov     eax, ebx
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     edi, [edx+ecx*2+1B63h]
    xor     dl, dl
    mov     [esp+0Ch], dl

    loc_490002:                             ; CODE XREF: .text:0049003Bj
    cmp     dl, bl
    jz      short loc_490032
    mov     ecx, [esp+0Ch]
    and     ecx, 0FFh
    mov     al, [edi+ecx+108h]
    test    al, al
    jnz     short loc_490032
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    add     ecx, esi
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*2+1CA7h], 0
    jnz     short loc_490047

    loc_490032:                             ; CODE XREF: .text:00490004j
                                            ; .text:00490019j
    inc     dl
    cmp     dl, 0Ah
    mov     [esp+0Ch], dl
    jb      short loc_490002
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_490047:                             ; CODE XREF: .text:00490030j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    cmp     [ecx+eax*2+1CA7h], dx
    setz    dl
    mov     eax, edx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490080 proc near                    ; CODE XREF: sub_490230+40p

    var_1= dword ptr -1

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, TAdynmemStructPtr
    cmp     dword ptr [edi+37EF6h], 2
    jnz     short loc_49009C
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_49009C:                             ; CODE XREF: sub_490080+12j
    mov     al, [edi+2A42h]
    mov     edx, edi
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    xor     bl, bl
    mov     byte ptr [esp+11h+var_1], bl
    lea     ecx, [ecx+ecx*4]
    lea     ebp, [edx+ecx*2+1B63h]

    loc_4900C2:                             ; CODE XREF: sub_490080+161j
    mov     ecx, [esp+11h+var_1]
    and     ecx, 0FFh
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [edi+ecx]
    lea     eax, [eax+eax*4]
    lea     esi, [edx+eax*2+1B63h]
    mov     al, [edi+2A42h]
    cmp     bl, al
    jz      loc_4901D8
    cmp     dword ptr [esi], 0
    jz      loc_4901D8
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_49010A
    cmp     al, 2
    jz      short loc_49010A
    cmp     al, 3
    jnz     loc_4901D8

    loc_49010A:                             ; CODE XREF: sub_490080+7Cj
                                            ; sub_490080+80j
    cmp     byte ptr [esi+146h], 0Ah
    jz      loc_4901D8
    mov     edx, [esi+27h]
    test    byte ptr [edx+9Bh], 40h
    jnz     loc_4901D8
    cmp     dword ptr [esi+140h], 0
    jz      loc_4901F2
    cmp     al, 1
    jz      short loc_490144
    cmp     al, 2
    jz      short loc_490144
    cmp     al, 3
    jnz     loc_4901D8

    loc_490144:                             ; CODE XREF: sub_490080+B6j
                                            ; sub_490080+BAj
    cmp     word ptr [esi+144h], 0
    jz      loc_4901D8
    test    byte ptr [edx+9Dh], 2
    jz      loc_4901F2
    mov     eax, [ebp+27h]
    test    byte ptr [eax+9Dh], 2
    jz      loc_4901F2
    mov     al, [ebp+ecx+108h]
    test    al, al
    jz      short loc_4901F2
    mov     al, [ebp+ecx+113h]
    test    al, al
    jz      short loc_4901F2
    xor     edx, edx
    lea     eax, [edi+1BD6h]

    loc_49018D:                             ; CODE XREF: sub_490080+156j
    mov     ecx, [eax-73h]
    test    ecx, ecx
    jz      short loc_4901CD
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_4901A5
    cmp     cl, 2
    jz      short loc_4901A5
    cmp     cl, 3
    jnz     short loc_4901CD

    loc_4901A5:                             ; CODE XREF: sub_490080+119j
                                            ; sub_490080+11Ej
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_4901CD
    cmp     word ptr [eax+0D1h], 0
    jnz     short loc_4901C2
    mov     ecx, [eax+0CDh]
    test    ecx, ecx
    jnz     short loc_4901CD

    loc_4901C2:                             ; CODE XREF: sub_490080+136j
    mov     cl, [edx+esi+108h]
    test    cl, cl
    jz      short loc_4901F2

    loc_4901CD:                             ; CODE XREF: sub_490080+112j
                                            ; sub_490080+123j ...
    inc     edx
    add     eax, 14Bh
    cmp     edx, 0Ah
    jl      short loc_49018D

    loc_4901D8:                             ; CODE XREF: sub_490080+68j
                                            ; sub_490080+71j ...
    inc     bl
    cmp     bl, 0Ah
    mov     byte ptr [esp+11h+var_1], bl
    jb      loc_4900C2
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4901F2:                             ; CODE XREF: sub_490080+AEj
                                            ; sub_490080+D9j ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_490080 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    cmp     [ecx+eax*2+1CA7h], dx
    setz    dl
    mov     eax, edx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490230 proc near                    ; CODE XREF: sub_457540+185p
                                            ; UpdateDatePlayers+149p ...

    var_1= dword ptr -1

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebp, ebp
    cmp     [edi+88h], ebp
    jnz     short loc_490249
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_490249:                             ; CODE XREF: sub_490230+Fj
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+TAdynmemStruct.MapFile]
    call    sub_435100
    dec     eax
    jz      loc_4902EE
    dec     eax
    jz      short loc_49027B
    dec     eax
    jz      short loc_49026E
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_49026E:                             ; CODE XREF: sub_490230+34j
    mov     ecx, edi
    call    sub_490080
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_49027B:                             ; CODE XREF: sub_490230+31j
    mov     esi, TAdynmemStructPtr
    mov     edx, esi
    mov     bl, [esi+2A42h]
    mov     eax, ebx
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     edi, [edx+ecx*2+1B63h]
    xor     dl, dl
    mov     byte ptr [esp+11h+var_1], dl

    loc_4902A9:                             ; CODE XREF: sub_490230+B1j
    cmp     dl, bl
    jz      short loc_4902D8
    mov     ecx, [esp+11h+var_1]
    and     ecx, 0FFh
    mov     al, [ecx+edi+108h]
    test    al, al
    jnz     short loc_4902D8
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    add     ecx, esi
    lea     eax, [eax+eax*4]
    cmp     [ecx+eax*2+1CA7h], bp
    jnz     short loc_49034A

    loc_4902D8:                             ; CODE XREF: sub_490230+7Bj
                                            ; sub_490230+90j
    inc     dl
    cmp     dl, 0Ah
    mov     byte ptr [esp+11h+var_1], dl
    jb      short loc_4902A9
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4902EE:                             ; CODE XREF: sub_490230+2Aj
    cmp     [edi+40h], ebp
    jnz     short loc_49031E
    push    0Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebp
    jz      short loc_49030F
    mov     [eax+8], ebp
    mov     [eax+4], ebp
    mov     dword ptr [eax], offset off_4FD948
    jmp     short loc_490311
    ; ---------------------------------------------------------------------------

    loc_49030F:                             ; CODE XREF: sub_490230+CFj
    xor     eax, eax

    loc_490311:                             ; CODE XREF: sub_490230+DDj
    mov     edx, [edi+40h]
    mov     [edi+edx*4], eax
    mov     eax, [edi+40h]
    inc     eax
    mov     [edi+40h], eax

    loc_49031E:                             ; CODE XREF: sub_490230+C1j
    mov     eax, [edi+40h]
    xor     esi, esi
    cmp     eax, ebp
    jle     short loc_490352
    mov     ebp, edi

    loc_490329:                             ; CODE XREF: sub_490230+10Dj
    mov     ecx, [ebp+0]
    mov     eax, [ecx]
    call    dword ptr [eax]
    test    eax, eax
    jz      short loc_49034A
    mov     eax, [edi+40h]
    inc     esi
    add     ebp, 4
    cmp     esi, eax
    jl      short loc_490329
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_49034A:                             ; CODE XREF: sub_490230+A6j
                                            ; sub_490230+102j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_490352:                             ; CODE XREF: sub_490230+F5j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    pop     ecx
    retn
    sub_490230 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490360 proc near                    ; CODE XREF: UpdateDatePlayers+161p
                                            ; UpdateDatePlayers+1EDp
    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    mov     eax, [ebx+88h]
    test    eax, eax
    jz      loc_4904A8
    call    sub_41D8B0
    test    eax, eax
    jz      short loc_4903D2
    mov     eax, dword_51E6C4
    test    eax, eax
    jnz     short loc_4903B1
    call    _rand
    cdq
    push    0
    push    2328h
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, 2328h
    mov     dword_51E6C4, eax

    loc_4903B1:                             ; CODE XREF: sub_490360+23j
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+TAdynmemStruct.GameTime]
    ja      short loc_4903D2
    mov     dword_51E6C4, 0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4903D2:                             ; CODE XREF: sub_490360+1Aj
                                            ; sub_490360+5Dj
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+TAdynmemStruct.MapFile]
    call    sub_435100
    dec     eax
    jz      short loc_49041D
    dec     eax
    jz      short loc_4903F0
    dec     eax
    jnz     loc_4904A8

    loc_4903F0:                             ; CODE XREF: sub_490360+87j
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    xor     edx, edx
    lea     eax, [eax+eax*4]
    cmp     [ecx+eax*2+TAdynmemStruct.Players.NumUnits], dx
    setz    dl
    mov     eax, edx
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_49041D:                             ; CODE XREF: sub_490360+84j
    mov     eax, [ebx+84h]
    test    eax, eax
    jnz     short loc_490472
    push    10h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_490459
    mov     dword ptr [eax+8], 0
    mov     dword ptr [eax+4], 0
    mov     dword ptr [eax+0Ch], offset off_4FD940
    mov     dword ptr [eax], offset off_4FD800
    mov     dword ptr [eax+0Ch], offset off_4FD7F8
    jmp     short loc_49045B
    ; ---------------------------------------------------------------------------

    loc_490459:                             ; CODE XREF: sub_490360+D3j
    xor     eax, eax

    loc_49045B:                             ; CODE XREF: sub_490360+F7j
    mov     ecx, [ebx+84h]
    mov     [ebx+ecx*4+44h], eax
    mov     eax, [ebx+84h]
    inc     eax
    mov     [ebx+84h], eax

    loc_490472:                             ; CODE XREF: sub_490360+C5j
    mov     eax, [ebx+84h]
    xor     esi, esi
    test    eax, eax
    jle     short loc_4904A8
    lea     edi, [ebx+44h]

    loc_490481:                             ; CODE XREF: sub_490360+137j
    mov     ecx, [edi]
    mov     edx, [ecx]
    call    dword ptr [edx]
    test    eax, eax
    jnz     short loc_49049F
    mov     eax, [ebx+84h]
    inc     esi
    add     edi, 4
    cmp     esi, eax
    jl      short loc_490481
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_49049F:                             ; CODE XREF: sub_490360+129j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4904A8:                             ; CODE XREF: sub_490360+Dj
                                            ; sub_490360+8Aj ...
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn
    sub_490360 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4904B0 proc near                    ; CODE XREF: .text:004164CDp
                                            ; .text:004164EFp ...
    mov     dword ptr [ecx+88h], 0
    retn
    sub_4904B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4904C0 proc near                    ; CODE XREF: sub_4866D0+C9p

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    edi
    xor     edi, edi
    mov     eax, [esi+40h]
    test    eax, eax
    jle     short loc_4904E8
    mov     ebx, esi

    loc_4904D5:                             ; CODE XREF: sub_4904C0+26j
    mov     ecx, [ebx]
    push    ebp
    mov     eax, [ecx]
    call    dword ptr [eax+4]
    mov     eax, [esi+40h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_4904D5

    loc_4904E8:                             ; CODE XREF: sub_4904C0+11j
    mov     eax, [esi+84h]
    xor     edi, edi
    test    eax, eax
    jle     short loc_49050D
    lea     ebx, [esi+44h]

    loc_4904F7:                             ; CODE XREF: sub_4904C0+4Bj
    mov     ecx, [ebx]
    push    ebp
    mov     edx, [ecx]
    call    dword ptr [edx+4]
    mov     eax, [esi+84h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_4904F7

    loc_49050D:                             ; CODE XREF: sub_4904C0+32j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_4904C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490520 proc near                    ; CODE XREF: sub_488570+41p

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    edi
    xor     edi, edi
    mov     eax, [esi+40h]
    test    eax, eax
    jle     short loc_490548
    mov     ebx, esi

    loc_490535:                             ; CODE XREF: sub_490520+26j
    mov     ecx, [ebx]
    push    ebp
    mov     eax, [ecx]
    call    dword ptr [eax+8]
    mov     eax, [esi+40h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_490535

    loc_490548:                             ; CODE XREF: sub_490520+11j
    mov     eax, [esi+84h]
    xor     edi, edi
    test    eax, eax
    jle     short loc_49056D
    lea     ebx, [esi+44h]

    loc_490557:                             ; CODE XREF: sub_490520+4Bj
    mov     ecx, [ebx]
    push    ebp
    mov     edx, [ecx]
    call    dword ptr [edx+8]
    mov     eax, [esi+84h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_490557

    loc_49056D:                             ; CODE XREF: sub_490520+32j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_490520 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490580 proc near                    ; CODE XREF: sub_485F50+25Ep
                                            ; sub_4861D0+17Ap

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    edi
    xor     edi, edi
    mov     eax, [esi+40h]
    test    eax, eax
    jle     short loc_4905A8
    mov     ebx, esi

    loc_490595:                             ; CODE XREF: sub_490580+26j
    mov     ecx, [ebx]
    push    ebp
    mov     eax, [ecx]
    call    dword ptr [eax+0Ch]
    mov     eax, [esi+40h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_490595

    loc_4905A8:                             ; CODE XREF: sub_490580+11j
    mov     eax, [esi+84h]
    xor     edi, edi
    test    eax, eax
    jle     short loc_4905CD
    lea     ebx, [esi+44h]

    loc_4905B7:                             ; CODE XREF: sub_490580+4Bj
    mov     ecx, [ebx]
    push    ebp
    mov     edx, [ecx]
    call    dword ptr [edx+0Ch]
    mov     eax, [esi+84h]
    inc     edi
    add     ebx, 4
    cmp     edi, eax
    jl      short loc_4905B7

    loc_4905CD:                             ; CODE XREF: sub_490580+32j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_490580 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+10h]
    mov     esi, ecx
    push    edi
    call    sub_44EF20
    lea     eax, [edi+6Ah]
    mov     dword ptr [esi], offset off_4FD980
    lea     ecx, [esi+0Ch]
    lea     ebx, [esi+18h]
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    xor     edx, edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    xor     eax, eax
    mov     [ebx], eax
    xor     ecx, ecx
    mov     eax, esi
    mov     [ebx+4], ecx
    mov     [ebx+8], edx
    mov     cx, [edi+66h]
    mov     [esi+24h], cx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490630 proc near                    ; DATA XREF: .rdata:004FD980o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD428
    jz      short loc_49064A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_49064A:                             ; CODE XREF: sub_490630+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_490630 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490650 proc near                    ; DATA XREF: .rdata:004FD990o
                                            ; .rdata:004FD9C0o ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     edx, [esp+arg_0]
    lea     eax, [ecx+0Ch]
    push    esi
    mov     esi, [eax]
    mov     [edx], esi
    mov     esi, [eax+4]
    mov     [edx+4], esi
    mov     eax, [eax+8]
    mov     [edx+8], eax
    mov     eax, [esp+4+arg_4]
    lea     edx, [ecx+18h]
    mov     esi, [ecx+18h]
    mov     [eax], esi
    mov     esi, [edx+4]
    mov     [eax+4], esi
    pop     esi
    mov     edx, [edx+8]
    mov     [eax+8], edx
    mov     ax, [ecx+24h]
    mov     ecx, [esp+arg_8]
    mov     [ecx], ax
    retn    0Ch
    sub_490650 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490690 proc near                    ; CODE XREF: sub_490880+1Fp
                                            ; DATA XREF: .rdata:004FD988o ...

    var_34= qword ptr -34h
    var_2C= qword ptr -2Ch
    var_14= dword ptr -14h
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 10h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [esi+4]
    test    ecx, ecx
    jz      loc_4907CE
    lea     edi, [esi+0Ch]
    mov     eax, edi
    push    edi
    mov     ebx, [eax]
    mov     ebp, [eax+4]
    mov     edx, [eax+8]
    mov     eax, [ecx]
    mov     [esp+24h+var_4], edx
    call    dword ptr [eax+20h]
    mov     eax, [edi]
    mov     edx, [edi+8]
    mov     ecx, [edi+4]
    sub     eax, ebx
    mov     ebx, [esp+20h+var_4]
    sub     ecx, ebp
    sub     edx, ebx
    lea     ebx, [esi+18h]
    sub     esp, 8
    mov     [ebx], eax
    mov     eax, [esi+8]
    sub     esp, 8
    mov     [ebx+4], ecx
    mov     [ebx+8], edx
    mov     ecx, [eax+72h]
    mov     edx, [esi+14h]
    mov     ebx, [edi]
    sub     ecx, edx
    mov     edx, [eax+6Ah]
    mov     [esp+20h], ecx
    sub     edx, ebx
    fild    dword ptr [esp+20h]
    mov     [esp+20h], edx
    fstp    [esp+30h+var_2C+4]
    fild    dword ptr [esp+20h]
    fstp    [esp+30h+var_34+4]
    call    __hypot
    add     esp, 10h
    call    __ftol
    mov     ebx, eax
    cmp     ebx, 0A00000h
    jle     short loc_49076E
    mov     ebp, [esi+8]
    mov     eax, [ebp+92h]
    mov     ecx, [eax+241h]
    shr     ecx, 16h
    test    cl, 1
    jz      short loc_490754
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    movsx   eax, word ptr [eax+21Ch]
    mov     dl, [ecx+1427Fh]
    add     edx, eax
    shl     edx, 10h
    mov     [esi+10h], edx
    jmp     short loc_49076E
    ; ---------------------------------------------------------------------------

    loc_490754:                             ; CODE XREF: sub_490690+A3j
    movsx   ecx, word ptr [eax+21Ch]
    mov     edx, [ebp+82h]
    xor     eax, eax
    mov     al, [edx+1]
    add     ecx, eax
    shl     ecx, 10h
    mov     [esi+10h], ecx

    loc_49076E:                             ; CODE XREF: sub_490690+8Cj
                                            ; sub_490690+C2j
    cmp     ebx, 1400000h
    jg      short loc_49078E
    mov     ecx, [esi+4]
    lea     eax, [esi+24h]
    push    eax
    mov     edx, [ecx]
    call    dword ptr [edx+24h]
    test    eax, eax
    jnz     short loc_49079F
    cmp     ebx, 100000h
    jle     short loc_49079F

    loc_49078E:                             ; CODE XREF: sub_490690+E4j
    mov     ecx, [esi+8]
    push    edi
    add     ecx, 6Ah
    push    ecx
    call    sub_48A980
    mov     [esi+24h], ax

    loc_49079F:                             ; CODE XREF: sub_490690+F4j
                                            ; sub_490690+FCj
    mov     ecx, [esi+4]
    mov     eax, [esi+8]
    push    eax
    mov     edx, [ecx]
    call    dword ptr [edx+10h]
    test    eax, eax
    jz      short loc_4907CE
    mov     ecx, [esi+4]
    push    20h
    call    sub_44CED0
    mov     ecx, [esi+4]
    mov     edx, [ecx]
    call    dword ptr [edx+2Ch]
    test    eax, eax
    jnz     short loc_4907CE
    mov     eax, [esi]
    push    0
    mov     ecx, esi
    call    dword ptr [eax+4]

    loc_4907CE:                             ; CODE XREF: sub_490690+Ej
                                            ; sub_490690+11Dj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn
    sub_490690 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4907E0 proc near                    ; CODE XREF: sub_43DC00+D3p

    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_44EF20
    lea     eax, [edi+6Ah]
    mov     dword ptr [esi], offset off_4FD980
    lea     ecx, [esi+0Ch]
    lea     ebx, [esi+18h]
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    xor     edx, edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    xor     eax, eax
    mov     [ebx], eax
    xor     ecx, ecx
    mov     eax, esi
    mov     [ebx+4], ecx
    mov     [ebx+8], edx
    mov     dl, [esi+27h]
    mov     cx, [edi+66h]
    and     dl, 0F9h
    or      dl, 1
    mov     [esi+24h], cx
    mov     dword ptr [esi], offset off_4FD9B0
    mov     [esi+27h], dl
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_4907E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490840 proc near                    ; DATA XREF: .rdata:004FD9B0o

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    mov     esi, ecx
    test    al, 1
    mov     dword ptr [esi], offset off_4FD428
    jz      short loc_49085A
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_49085A:                             ; CODE XREF: sub_490840+Fj
    mov     eax, esi
    pop     esi
    retn    4
    sub_490840 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490860 proc near                    ; DATA XREF: .rdata:004FD9B4o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    eax
    call    sub_44EF90
    mov     al, [esi+27h]
    or      al, 1
    mov     [esi+27h], al
    pop     esi
    retn    4
    sub_490860 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490880 proc near                    ; DATA XREF: .rdata:004FD9B8o
    mov     edx, [ecx+8]
    mov     al, [ecx+27h]
    push    ebx
    mov     bl, al
    mov     edx, [edx]
    shr     bl, 1
    mov     dl, [edx+2Eh]
    and     bl, 3
    and     dl, 3
    xor     dl, bl
    jz      short loc_49089F
    or      al, 1
    mov     [ecx+27h], al

    loc_49089F:                             ; CODE XREF: sub_490880+18j
    call    sub_490690
    pop     ebx
    retn
    sub_490880 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4908B0 proc near                    ; DATA XREF: .rdata:004FD9CCo
    mov     al, [ecx+27h]
    and     eax, 1
    retn
    sub_4908B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4908C0 proc near                    ; DATA XREF: .rdata:004FD9D0o

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    push    edi
    mov     edi, [esp+4+arg_0]
    mov     ecx, [esi+4]
    test    ecx, ecx
    jnz     short loc_4908DC
    push    2
    push    0
    mov     ecx, edi
    call    sub_415C10
    jmp     short loc_49090C
    ; ---------------------------------------------------------------------------

    loc_4908DC:                             ; CODE XREF: sub_4908C0+Dj
    mov     eax, [ecx]
    call    dword ptr [eax+8]
    cmp     eax, 2
    jnz     short loc_4908EB
    push    eax
    push    1
    jmp     short loc_4908FC
    ; ---------------------------------------------------------------------------

    loc_4908EB:                             ; CODE XREF: sub_4908C0+24j
    mov     ecx, [esi+4]
    mov     eax, [ecx]
    call    dword ptr [eax+8]
    cmp     eax, 3
    jnz     short loc_49090C
    push    2
    push    2

    loc_4908FC:                             ; CODE XREF: sub_4908C0+29j
    mov     ecx, edi
    call    sub_415C10
    mov     ecx, [esi+4]
    push    edi
    mov     edx, [ecx]
    call    dword ptr [edx+28h]

    loc_49090C:                             ; CODE XREF: sub_4908C0+1Aj
                                            ; sub_4908C0+36j
    mov     eax, [esi+8]
    push    2
    mov     ecx, [eax]
    mov     dl, [ecx+2Eh]
    mov     ecx, edi
    and     edx, 3
    push    edx
    call    sub_415C10
    mov     eax, [esi+8]
    pop     edi
    mov     ecx, [eax]
    mov     al, [esi+27h]
    and     al, 0F8h
    mov     dl, [ecx+2Eh]
    and     dl, 3
    shl     dl, 1
    or      dl, al
    mov     [esi+27h], dl
    pop     esi
    retn    4
    sub_4908C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490940 proc near                    ; CODE XREF: sub_43DC00+82p

    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_44EF20
    lea     eax, [edi+6Ah]
    mov     dword ptr [esi], offset off_4FD980
    lea     ecx, [esi+0Ch]
    lea     ebx, [esi+18h]
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    xor     edx, edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    xor     eax, eax
    mov     [ebx], eax
    xor     ecx, ecx
    mov     eax, esi
    mov     [ebx+4], ecx
    mov     [ebx+8], edx
    mov     cx, [edi+66h]
    mov     [esi+24h], cx
    mov     dword ptr [esi], offset off_4FD9E0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_490940 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4909A0 proc near                    ; DATA XREF: .rdata:004FD9E0o
    push    esi
    mov     esi, ecx
    mov     ecx, [esi+4]
    mov     dword ptr [esi], offset off_4FD9E0
    test    ecx, ecx
    jz      short loc_4909B6
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4909B6:                             ; CODE XREF: sub_4909A0+Ej
    mov     al, [esp+8]
    mov     dword ptr [esi+4], 0
    test    al, 1
    mov     dword ptr [esi], offset off_4FD428
    jz      short loc_4909D4
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4909D4:                             ; CODE XREF: sub_4909A0+29j
    mov     eax, esi
    pop     esi
    retn    4
    sub_4909A0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, ecx
    mov     ecx, [esi+4]
    mov     dword ptr [esi], offset off_4FD9E0
    test    ecx, ecx
    jz      short loc_4909F6
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]

    loc_4909F6:                             ; CODE XREF: .text:004909EEj
    mov     dword ptr [esi+4], 0
    mov     dword ptr [esi], offset off_4FD428
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490A10 proc near                    ; DATA XREF: .rdata:004FDA04o
    push    esi
    mov     esi, ecx
    push    edi
    mov     ecx, [esi+4]
    test    ecx, ecx
    jz      short loc_490A28
    mov     eax, [ecx]
    push    1
    call    dword ptr [eax]
    mov     dword ptr [esi+4], 0

    loc_490A28:                             ; CODE XREF: sub_490A10+9j
    mov     edi, [esp+0Ch]
    push    2
    mov     ecx, edi
    call    sub_415DC0
    cmp     eax, 1
    jnz     short loc_490A56
    push    36h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_490A77
    mov     ecx, [esi+8]
    push    edi
    push    ecx
    mov     ecx, eax
    call    sub_44E080
    jmp     short loc_490A79
    ; ---------------------------------------------------------------------------

    loc_490A56:                             ; CODE XREF: sub_490A10+28j
    cmp     eax, 2
    jnz     short loc_490A7C
    push    2Ch                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_490A77
    mov     edx, [esi+8]
    push    edi
    push    edx
    mov     ecx, eax
    call    sub_44E9C0
    jmp     short loc_490A79
    ; ---------------------------------------------------------------------------

    loc_490A77:                             ; CODE XREF: sub_490A10+36j
                                            ; sub_490A10+57j
    xor     eax, eax

    loc_490A79:                             ; CODE XREF: sub_490A10+44j
                                            ; sub_490A10+65j
    mov     [esi+4], eax

    loc_490A7C:                             ; CODE XREF: sub_490A10+49j
    push    2
    mov     ecx, edi
    call    sub_415DC0
    mov     esi, [esi+8]
    push    eax
    push    esi
    mov     ecx, [esi]
    call    sub_43D210
    pop     edi
    pop     esi
    retn    4
    sub_490A10 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 20h
    lea     eax, [esp+0]
    mov     dword ptr [esp+0], 20h
    push    eax
    call    ds:GlobalMemoryStatus
    add     esp, 20h
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E23h]
    mov     edx, [eax+37E1Fh]
    push    ecx
    push    edx
    push    offset aOffscreen               ; "OFFSCREEN"
    call    sub_4C69F0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E1Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C61F0
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    push    0
    mov     dword ptr [edx+37E1Bh], 0
    call    sub_4C61F0
    jmp     sub_4C62C0

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490B30 proc near                    ; CODE XREF: sub_41EC50+20Bp
                                            ; sub_41EC50+3D7p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, TAdynmemStructPtr
    cmp     eax, 7
    mov     [ecx+391F1h], eax
    ja      loc_490BE3
    jmp     ds:off_490C14[eax*4]

    loc_490B50:                             ; DATA XREF: .text:00490C14o
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+391F5h], offset loc_496A60
    jmp     loc_490BF3
    ; ---------------------------------------------------------------------------

    loc_490B65:                             ; CODE XREF: sub_490B30+19j
                                            ; DATA XREF: .text:00490C18o
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+391F5h], offset loc_496B10
    jmp     short loc_490BF3
    ; ---------------------------------------------------------------------------

    loc_490B77:                             ; CODE XREF: sub_490B30+19j
                                            ; DATA XREF: .text:00490C1Co
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+391F5h], offset dword_496BB0
    jmp     short loc_490BF3
    ; ---------------------------------------------------------------------------

    loc_490B89:                             ; CODE XREF: sub_490B30+19j
                                            ; DATA XREF: .text:00490C20o
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+391F5h], offset loc_496CE0
    jmp     short loc_490BF3
    ; ---------------------------------------------------------------------------

    loc_490B9B:                             ; CODE XREF: sub_490B30+19j
                                            ; DATA XREF: .text:00490C24o
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+391F5h], offset loc_496DB0
    jmp     short loc_490BF3
    ; ---------------------------------------------------------------------------

    loc_490BAD:                             ; CODE XREF: sub_490B30+19j
                                            ; DATA XREF: .text:00490C28o
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+391F5h], offset sub_497F40
    jmp     short loc_490BF3
    ; ---------------------------------------------------------------------------

    loc_490BBF:                             ; CODE XREF: sub_490B30+19j
                                            ; DATA XREF: .text:00490C2Co
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+391F5h], offset loc_499200
    jmp     short loc_490BF3
    ; ---------------------------------------------------------------------------

    loc_490BD1:                             ; CODE XREF: sub_490B30+19j
                                            ; DATA XREF: .text:00490C30o
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+391F5h], offset loc_499880
    jmp     short loc_490BF3
    ; ---------------------------------------------------------------------------

    loc_490BE3:                             ; CODE XREF: sub_490B30+13j
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+391F5h], 0

    loc_490BF3:                             ; CODE XREF: sub_490B30+30j
                                            ; sub_490B30+45j ...
    cmp     eax, 6
    push    0
    jnz     short loc_490C07
    push    offset sub_4609A0
    call    sub_4B4FD0
    retn    4
    ; ---------------------------------------------------------------------------

    loc_490C07:                             ; CODE XREF: sub_490B30+C8j
    push    offset loc_4578F0
    call    sub_4B4FD0
    retn    4
    sub_490B30 endp

    ; ---------------------------------------------------------------------------
    off_490C14 dd offset loc_490B50         ; DATA XREF: sub_490B30+19r
    dd offset loc_490B65
    dd offset loc_490B77
    dd offset loc_490B89
    dd offset loc_490B9B
    dd offset loc_490BAD
    dd offset loc_490BBF
    dd offset loc_490BD1
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490C40 proc near                    ; CODE XREF: sub_4917D0+133p
                                            ; .text:0049558Fp
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EC4h]
    mov     edx, [eax+38A47h]
    cmp     ecx, edx
    jnb     loc_490D87
    push    esi
    lea     esi, [eax+37EC4h]
    call    _rand
    cdq
    push    0
    push    0Ah
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    add     eax, 5
    lea     eax, [eax+eax*2]
    lea     edx, [eax+eax*4]
    mov     eax, [esi]
    shl     edx, 1
    add     eax, edx
    mov     [esi], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+1425Fh]
    mov     edx, [eax+1425Bh]
    sub     ecx, edx
    push    ecx                             ; int
    call    GetRandom
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1425Bh]
    add     edx, eax
    mov     [ecx+37EDAh], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EDAh]
    test    ecx, ecx
    jz      short loc_490CE8
    push    10000h                          ; int
    call    GetRandom
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37ED8h], ax
    mov     eax, TAdynmemStructPtr

    loc_490CE8:                             ; CODE XREF: sub_490C40+8Aj
    mov     edx, [eax+37EDAh]
    mov     ax, [eax+37ED8h]
    push    edx
    push    eax
    call    sub_4B70EF
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    neg     eax
    shl     eax, 1
    mov     [ecx+37ECCh], eax
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37EDAh]
    mov     ax, [eax+37ED8h]
    push    edx
    push    eax
    call    sub_4B7123
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    neg     eax
    shl     eax, 1
    mov     [ecx+37ED4h], eax
    mov     eax, TAdynmemStructPtr
    fild    dword ptr [eax+37EDAh]
    fidiv   dword ptr [eax+37EC8h]
    fstp    dword ptr [eax+37EDEh]
    mov     ecx, TAdynmemStructPtr
    fld     dword ptr [ecx+37EDEh]
    fcomp   ds:dbl_4FDA10
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_490D7B
    mov     dword ptr [ecx+37EDEh], 3F800000h
    mov     ecx, TAdynmemStructPtr

    loc_490D7B:                             ; CODE XREF: sub_490C40+129j
    mov     dword ptr [ecx+37EE2h], 1
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_490D87:                             ; CODE XREF: sub_490C40+13j
    mov     dword ptr [eax+37EE2h], 0
    retn
    sub_490C40 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_490DD4
    mov     ecx, TAdynmemStructPtr
    mov     eax, 0Ah
    mov     [ecx+38A4Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+38A4Dh], ax

    loc_490DD4:                             ; CODE XREF: .text:00490DB3j
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+38A43h], 0
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490DF0 proc near                    ; CODE XREF: Network_Process+1C12p
                                            ; .text:0045C15Ap ...

    var_64= byte ptr -64h
    idTo= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 64h
    push    ebx
    mov     ebx, [esp+68h+idTo]
    push    esi
    cmp     ebx, 14h
    push    edi
    jle     short loc_490E04
    mov     ebx, 14h

    loc_490E04:                             ; CODE XREF: sub_490DF0+Dj
    cmp     ebx, 1
    jge     short loc_490E0E
    mov     ebx, 1

    loc_490E0E:                             ; CODE XREF: sub_490DF0+17j
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     ax, [ecx+38A4Bh]
    cmp     ebx, eax
    jz      short loc_490E95
    lea     eax, [ebx-0Ah]
    test    eax, eax
    jnz     short loc_490E57
    push    offset aGameSpeedNorma          ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+70h+var_64]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_490E85
    ; ---------------------------------------------------------------------------

    loc_490E57:                             ; CODE XREF: sub_490DF0+36j
    test    eax, eax
    setle   cl
    dec     ecx
    push    eax
    and     ecx, 0Bh
    add     ecx, 20h
    movsx   edx, cl
    push    edx
    push    offset aGameSpeed               ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esp+7Ch+var_64]
    push    offset aSCD                     ; "%s  %c%d\n"
    push    eax
    call    _sprintf
    add     esp, 14h

    loc_490E85:                             ; CODE XREF: sub_490DF0+65j
    push    0Ah                             ; char
    push    0                               ; __int16
    lea     ecx, [esp+78h+var_64]
    push    2                               ; char
    push    ecx                             ; char *
    call    sub_463CA0

    loc_490E95:                             ; CODE XREF: sub_490DF0+2Fj
    mov     edx, TAdynmemStructPtr
    mov     [edx+38A4Bh], bx
    mov     eax, TAdynmemStructPtr
    mov     [eax+38A4Dh], bx
    mov     eax, [esp+70h+arg_4]
    test    eax, eax
    jz      short loc_490ED6
    lea     ecx, [esp+70h+idTo]
    push    3                               ; idFrom
    push    ecx                             ; idTo
    mov     byte ptr [esp+78h+idTo], 19h
    mov     byte ptr [esp+78h+idTo+1], 1
    mov     byte ptr [esp+78h+idTo+2], bl
    call    sub_44FDB0
    push    eax                             ; PlayerID
    call    sub_451DF0

    loc_490ED6:                             ; CODE XREF: sub_490DF0+C4j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 64h
    retn    8
    sub_490DF0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    mov     ax, [eax+38A4Bh]
    cmp     ax, 14h
    jnb     short locret_490F00
    and     eax, 0FFFFh
    push    1
    inc     eax
    push    eax
    call    sub_490DF0

    locret_490F00:                          ; CODE XREF: .text:00490EF0j
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     ax, [eax+38A4Bh]
    cmp     ax, 1
    jbe     short locret_490F30
    and     eax, 0FFFFh
    push    1
    dec     eax
    push    eax
    call    sub_490DF0

    locret_490F30:                          ; CODE XREF: .text:00490F20j
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    lea     eax, [esp+0]
    mov     dword ptr [esp+0], 0AA0h
    push    eax
    push    offset dword_51E828
    push    offset aCdlists                 ; "CDLISTS"
    call    sub_42F980
    test    eax, eax
    jnz     short loc_490F6F
    push    edi
    mov     ecx, 2A8h
    mov     edi, offset dword_51E828
    rep stosd
    pop     edi

    loc_490F6F:                             ; CODE XREF: .text:00490F5Fj
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490F80 proc near                    ; CODE XREF: sub_49E830+366p
    mov     eax, TAdynmemStructPtr
    push    esi
    xor     esi, esi
    mov     ecx, [eax+10h]
    call    sub_4CE450
    test    eax, eax
    jle     short loc_490FC2
    push    edi

    loc_490F95:                             ; CODE XREF: sub_490F80+3Fj
    mov     ecx, TAdynmemStructPtr
    lea     edi, [esi+1]
    push    edi
    mov     ecx, [ecx+10h]
    call    sub_4CE7E0
    mov     edx, TAdynmemStructPtr
    mov     byte ptr dword_51E84C[esi], al
    mov     esi, edi
    mov     ecx, [edx+10h]
    call    sub_4CE450
    cmp     esi, eax
    jl      short loc_490F95
    pop     edi

    loc_490FC2:                             ; CODE XREF: sub_490F80+12j
    push    0AA0h
    push    offset dword_51E828
    push    offset aCdlists                 ; "CDLISTS"
    call    sub_42F960
    pop     esi
    retn
    sub_490F80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_490FE0 proc near                    ; CODE XREF: sub_491200+268p
                                            ; sub_49E830+403p
                                            ; DATA XREF: ...

    var_98= byte ptr -98h
    var_95= byte ptr -95h
    var_94= byte ptr -94h
    var_92= byte ptr -92h
    var_91= byte ptr -91h
    var_90= byte ptr -90h
    var_8E= byte ptr -8Eh
    var_8D= byte ptr -8Dh
    var_8C= byte ptr -8Ch
    var_8A= byte ptr -8Ah
    var_89= byte ptr -89h
    var_88= dword ptr -88h

    sub     esp, 98h
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     ebx, 1
    push    ebp
    push    esi
    mov     [esp+0A4h+var_98], bl
    mov     [esp+0Dh], bl
    mov     [esp+0Eh], bl
    mov     [esp+0A4h+var_95], bl
    mov     [esp+0A4h+var_94], bl
    mov     [esp+11h], bl
    mov     [esp+0A4h+var_92], bl
    mov     [esp+0A4h+var_91], 0
    mov     [esp+0A4h+var_90], 0
    mov     byte ptr [esp+15h], 0
    mov     [esp+0A4h+var_8E], 0
    mov     [esp+0A4h+var_8D], 0
    mov     [esp+0A4h+var_8C], 0
    mov     byte ptr [esp+19h], 0
    mov     [esp+0A4h+var_8A], 0
    mov     [esp+0A4h+var_89], 0
    mov     ecx, [eax+10h]
    push    edi
    call    sub_4CE680
    mov     esi, ds:mciSendStringA
    push    0                               ; hwndCallback
    push    0                               ; uReturnLength
    push    0                               ; lpstrReturnString
    push    offset aStopCdaudio             ; lpstrCommand
    mov     edi, eax
    call    esi ; mciSendStringA
    push    0                               ; hwndCallback
    push    0                               ; uReturnLength
    push    0                               ; lpstrReturnString
    push    offset aCloseCdaudio            ; lpstrCommand
    call    esi ; mciSendStringA
    push    0                               ; hwndCallback
    push    0                               ; uReturnLength
    push    0                               ; lpstrReturnString
    push    offset aOpenCdaudio             ; lpstrCommand
    call    esi ; mciSendStringA
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    and     ecx, ebx
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4CEDC0
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [eax+37F16h]
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE7A0
    mov     eax, TAdynmemStructPtr
    push    edi
    mov     ecx, [eax+10h]
    call    sub_4CE690
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CD9C0
    mov     ebp, eax
    xor     ebx, ebx
    mov     eax, offset dword_51E848

    loc_4910C5:                             ; CODE XREF: sub_490FE0+F4j
    cmp     [eax], ebp
    jz      short loc_4910D8
    add     eax, 88h
    inc     ebx
    cmp     eax, offset dword_51F2E8
    jl      short loc_4910C5
    jmp     short loc_491131
    ; ---------------------------------------------------------------------------

    loc_4910D8:                             ; CODE XREF: sub_490FE0+E7j
    mov     edx, ebx
    mov     ecx, 22h
    shl     edx, 4
    add     edx, ebx
    lea     edi, [esp+0A8h+var_88]
    test    ebx, ebx
    lea     eax, ds:51E828h[edx*8]
    mov     esi, eax
    rep movsd
    jle     short loc_49110F
    mov     edi, eax
    mov     edx, ebx

    loc_4910FB:                             ; CODE XREF: sub_490FE0+12Dj
    lea     eax, [edi-88h]
    mov     ecx, 22h
    mov     esi, eax
    dec     edx
    rep movsd
    mov     edi, eax
    jnz     short loc_4910FB

    loc_49110F:                             ; CODE XREF: sub_490FE0+115j
    mov     eax, TAdynmemStructPtr
    mov     ecx, 22h
    lea     esi, [esp+0A8h+var_88]
    mov     edi, offset dword_51E828
    rep movsd
    mov     ecx, [eax+10h]
    push    offset dword_51E84C
    call    sub_4CE3E0

    loc_491131:                             ; CODE XREF: sub_490FE0+F6j
    cmp     ebx, 14h
    jnz     loc_4911BD
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CE450
    cmp     eax, 10h
    jnz     short loc_491172
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CE460
    test    eax, eax
    jz      short loc_491172
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+0A8h+var_98]
    push    eax
    mov     ecx, [ecx+10h]
    call    sub_4CE3E0

    loc_491172:                             ; CODE XREF: sub_490FE0+16Bj
                                            ; sub_490FE0+17Dj
    mov     edi, offset dword_51F240

    loc_491177:                             ; CODE XREF: sub_490FE0+1AEj
    lea     eax, [edi-88h]
    mov     ecx, 22h
    mov     esi, eax
    rep movsd
    mov     edi, eax
    cmp     edi, offset dword_51E828
    jg      short loc_491177
    mov     edx, dword ptr [esp+0A8h+var_98]
    mov     eax, dword ptr [esp+0A8h+var_94]
    mov     ecx, dword ptr [esp+0A8h+var_90]
    mov     dword_51E84C, edx
    mov     edx, dword ptr [esp+0A8h+var_8C]
    mov     dword_51E850, eax
    mov     dword_51E854, ecx
    mov     dword_51E858, edx
    mov     dword_51E848, ebp

    loc_4911BD:                             ; CODE XREF: sub_490FE0+154j
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 4
    jz      short loc_4911E7
    cmp     dword ptr [eax+391F1h], 6
    jnz     short loc_4911E7
    mov     ecx, [eax+10h]
    call    sub_4CDB40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 98h
    retn
    ; ---------------------------------------------------------------------------

    loc_4911E7:                             ; CODE XREF: sub_490FE0+1E9j
                                            ; sub_490FE0+1F2j
    mov     ecx, [eax+10h]
    call    sub_4CED40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 98h
    retn
    sub_490FE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_491200()
    sub_491200 proc near                    ; CODE XREF: sub_49E830+232p

    var_34= dword ptr -34h
    cbData= dword ptr -24h
    Buffer= _MEMORYSTATUS ptr -20h

    sub     esp, 24h
    push    ebx
    push    esi
    mov     esi, ds:GlobalMemoryStatus
    lea     eax, [esp+2Ch+Buffer]
    push    edi
    push    eax                             ; lpBuffer
    mov     [esp+34h+Buffer.dwLength], 20h
    call    esi ; GlobalMemoryStatus
    call    sub_4B6700
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E1Fh], eax
    call    sub_4B6710
    mov     edx, TAdynmemStructPtr
    mov     [edx+37E23h], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E23h]
    mov     edx, [eax+37E1Fh]
    push    ecx                             ; int
    push    edx                             ; int
    push    offset aOffscreen               ; int
    call    sub_4C69F0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E1Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C61F0
    mov     eax, TAdynmemStructPtr
    xor     ebx, ebx
    push    ebx
    and     word ptr [eax+3923Bh], 0FFFEh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFFDh
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+39249h], ebx
    call    sub_434AB0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_4912DD
    mov     ecx, TAdynmemStructPtr
    mov     eax, 0Ah
    mov     [ecx+38A4Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+38A4Dh], ax

    loc_4912DD:                             ; CODE XREF: sub_491200+BCj
    mov     eax, TAdynmemStructPtr
    push    ebx
    mov     [eax+38A43h], ebx
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+37EECh]
    mov     [eax+37EE6h], cx
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+37EE6h]
    mov     [eax+37EEAh], dx
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37EFEh], 3
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F2Fh], 0FDFFh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F2Fh], 0FF7Fh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F2Fh], 0FEFFh
    call    sub_4C61B0
    call    sub_429870
    call    sub_47ED40
    call    sub_4259B0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 12EFh
    push    ecx
    call    sub_451FD0
    call    sub_43C050
    call    sub_42A320
    call    sub_42A400
    call    sub_42F7E0
    mov     edx, TAdynmemStructPtr
    add     edx, 143A7h
    push    edx
    call    sub_42E140
    mov     eax, TAdynmemStructPtr
    add     eax, 143A7h
    push    eax
    call    sub_42E1D0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 143A7h
    push    ecx
    call    sub_42E260
    mov     edx, TAdynmemStructPtr
    add     edx, 143A7h
    push    edx
    call    sub_42E2F0
    mov     eax, TAdynmemStructPtr
    add     eax, 143A7h
    push    eax
    call    sub_42E300
    push    22Ch
    push    offset aSkirmishinfo            ; "SkirmishInfo"
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [ecx+29A0h], eax
    call    WriteRegistrySettings_1
    lea     edx, [esp+30h+cbData]
    mov     [esp+30h+cbData], 0AA0h
    push    edx                             ; lpcbData
    push    offset dword_51E828             ; lpData
    push    offset aCdlists                 ; lpValueName
    call    sub_42F980
    cmp     eax, ebx
    jnz     short loc_491429
    mov     ecx, 2A8h
    xor     eax, eax
    mov     edi, offset dword_51E828
    rep stosd

    loc_491429:                             ; CODE XREF: sub_491200+219j
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    and     ecx, 1
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4CEDC0
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [eax+37F16h]
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE7A0
    mov     eax, TAdynmemStructPtr
    push    offset sub_490FE0
    mov     ecx, [eax+10h]
    call    sub_4CD9D0
    call    sub_490FE0
    mov     ecx, TAdynmemStructPtr
    push    ebx
    mov     ecx, [ecx+10h]
    call    sub_4CE690
    call    sub_45BCC0
    call    sub_431A60
    call    sub_4318C0
    mov     edx, TAdynmemStructPtr
    push    ecx
    fild    dword ptr [edx+37F08h]
    fmul    ds:flt_4FDA18
    fsubr   ds:dbl_4FDA20
    fstp    [esp+34h+var_34]
    call    sub_4BA590
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AA850
    mov     ecx, TAdynmemStructPtr
    push    offset aGuis                    ; char *
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_49FBA0
    mov     edx, TAdynmemStructPtr
    push    offset aAnims                   ; char *
    add     edx, 519h
    push    edx                             ; int
    call    sub_49FBF0
    mov     eax, TAdynmemStructPtr
    push    offset aFonts                   ; char *
    add     eax, 519h
    push    eax                             ; int
    call    sub_49FB50
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391F9h]
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AA8E0
    mov     edx, TAdynmemStructPtr
    push    ebx
    mov     eax, [edx+148CBh]
    push    eax
    call    sub_4B7F30
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4AB4E0
    mov     edx, TAdynmemStructPtr
    push    offset aCommongui               ; "commongui"
    add     edx, 519h
    push    edx
    call    sub_4AEEE0
    mov     eax, TAdynmemStructPtr
    push    ebx
    add     eax, 519h
    push    offset aHattfont12              ; "hattfont12"
    push    eax
    call    sub_4AEDD0
    mov     ecx, TAdynmemStructPtr
    push    1
    push    offset aHattfont11              ; "hattfont11"
    add     ecx, 519h
    push    ecx
    call    sub_4AEDD0
    mov     eax, TAdynmemStructPtr
    push    0FEh
    mov     edx, [eax+521h]
    mov     [eax+52Dh], edx
    call    sub_4C13D0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391F9h]
    push    ecx
    call    sub_4C1420
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    offset loc_4578F0
    mov     [edx+14280h], bl
    mov     eax, TAdynmemStructPtr
    mov     [eax+38C53h], ebx
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38C5Fh], ebx
    mov     edx, TAdynmemStructPtr
    mov     [edx+38C63h], ebx
    mov     eax, TAdynmemStructPtr
    mov     [eax+38C67h], ebx
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38D6Bh], ebx
    mov     edx, TAdynmemStructPtr
    mov     [edx+38D7Bh], ebx
    mov     eax, TAdynmemStructPtr
    mov     [eax+391F1h], ebx
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+391F5h], offset loc_496A60
    call    sub_4B4FD0
    lea     edx, [esp+30h+Buffer]
    push    edx                             ; lpBuffer
    mov     [esp+34h+Buffer.dwLength], 20h
    call    esi ; GlobalMemoryStatus
    call    sub_4287B0
    mov     eax, TAdynmemStructPtr
    push    250                             ; nDefault
    push    offset aUnitlimit               ; lpKeyName
    mov     dword ptr [eax+TAdynmemStruct.AlteredUnitLimit], 1
    call    ReadIniFileValue
    cmp     eax, 500                        ; Max unit limit!
    jle     short loc_491678
    mov     ecx, TAdynmemStructPtr
    mov     eax, 500
    mov     [ecx+TAdynmemStruct.UnitLimit], ax
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 24h
    retn
    ; ---------------------------------------------------------------------------

    loc_491678:                             ; CODE XREF: sub_491200+45Dj
    cmp     eax, 20                         ; Minium unit limit
    jge     short loc_491682
    mov     eax, 20                         ; Minium unit limit

    loc_491682:                             ; CODE XREF: sub_491200+47Bj
    mov     ecx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebx
    mov     [ecx+TAdynmemStruct.UnitLimit], ax
    add     esp, 24h
    retn
    sub_491200 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4916A0 proc near                    ; CODE XREF: sub_49E830+4A6p
    mov     eax, TAdynmemStructPtr
    push    esi
    xor     esi, esi
    mov     ecx, [eax+TAdynmemStruct.DSound]
    call    sub_4CE450
    test    eax, eax
    jle     short loc_4916E2
    push    edi

    loc_4916B5:                             ; CODE XREF: sub_4916A0+3Fj
    mov     ecx, TAdynmemStructPtr
    lea     edi, [esi+1]
    push    edi
    mov     ecx, [ecx+TAdynmemStruct.DSound]
    call    sub_4CE7E0
    mov     edx, TAdynmemStructPtr
    mov     byte ptr dword_51E84C[esi], al
    mov     esi, edi
    mov     ecx, [edx+TAdynmemStruct.DSound]
    call    sub_4CE450
    cmp     esi, eax
    jl      short loc_4916B5
    pop     edi

    loc_4916E2:                             ; CODE XREF: sub_4916A0+12j
    push    0AA0h
    push    offset dword_51E828
    push    offset aCdlists                 ; "CDLISTS"
    call    sub_42F960
    call    sub_428730
    mov     eax, TAdynmemStructPtr
    push    1
    add     eax, 519h
    push    eax
    call    sub_4AEDA0
    mov     ecx, TAdynmemStructPtr
    push    0
    add     ecx, 519h
    push    ecx
    call    sub_4AEDA0
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4AEF80
    call    sub_431920
    call    sub_431A20
    call    sub_42F8C0
    call    sub_42A3B0
    call    sub_47EEE0
    call    sub_42A010
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    push    0
    mov     dword ptr [edx+37E1Bh], 0
    call    sub_4C61F0
    call    sub_4C62C0
    call    sub_43C350
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+29A0h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     dword ptr [edx+29A0h], 0
    call    sub_42BCC0
    mov     eax, TAdynmemStructPtr
    add     eax, 12EFh
    push    eax
    call    sub_452370
    call    sub_434B90
    pop     esi
    retn
    sub_4916A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4917D0 proc near                    ; CODE XREF: sub_497180+401p
    push    esi
    push    edi
    call    sub_463C80
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    add     ecx, 2BF1h
    xor     esi, esi
    mov     [ecx], eax
    mov     [ecx+4], eax
    mov     [ecx+8], ax
    mov     [ecx+0Ah], al
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+2CC3h], 1
    mov     eax, TAdynmemStructPtr
    mov     [eax+2CC4h], si
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+2CC6h]
    and     dl, 0DFh
    mov     [eax+2CC6h], dl
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2CC6h]
    and     cl, 0BFh
    mov     [eax+2CC6h], cl
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2CBAh], si
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFFEh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0F7FFh
    mov     edx, TAdynmemStructPtr
    mov     [edx+39249h], esi
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F2Fh], 0FDFFh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F2Fh], 0FF7Fh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37F2Fh], 0FEFFh
    call    sub_4679A0
    call    sub_47EE30
    call    sub_42A440
    call    sub_4222E0
    call    sub_488BE0
    call    nullsub_11
    call    sub_471D90
    call    sub_499A30
    call    sub_42E310
    call    sub_483610
    call    sub_41C2B0
    call    sub_42D2E0
    call    sub_42DCF0
    call    sub_4854A0
    call    sub_422EA0
    call    sub_4223E0
    call    sub_440940
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37EC8h], 1388h
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37EC4h], esi
    call    sub_490C40
    push    960h
    push    offset aTempXformPts            ; "TEMP XFORM PTS"
    call    sub_4D83B0
    mov     edx, TAdynmemStructPtr
    add     esp, 8
    push    640h
    push    offset aTempProjectedP          ; "TEMP PROJECTED PTS"
    mov     [edx+14383h], eax
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    push    0A0h
    push    offset aAssemPts                ; "ASSEM PTS"
    mov     [ecx+14387h], eax
    call    sub_4D83B0
    mov     edx, TAdynmemStructPtr
    add     esp, 8
    mov     [edx+1438Bh], eax
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38A37h], eax
    mov     edx, TAdynmemStructPtr
    mov     [edx+38A47h], esi
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_4919B3
    mov     ecx, TAdynmemStructPtr
    mov     eax, 0Ah
    mov     [ecx+38A4Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+38A4Dh], ax

    loc_4919B3:                             ; CODE XREF: sub_4917D0+1C2j
    mov     eax, TAdynmemStructPtr
    mov     [eax+38A43h], esi
    call    sub_437CD0
    call    sub_4669B0
    call    sub_464990
    call    sub_44F6A0
    call    sub_420620
    call    sub_419560
    xor     eax, eax

    loc_4919DE:                             ; CODE XREF: sub_4917D0+225j
    mov     ecx, TAdynmemStructPtr
    add     eax, 14Bh
    cmp     eax, 0CEEh
    mov     [ecx+eax+1B58h], esi
    jl      short loc_4919DE
    mov     eax, TAdynmemStructPtr
    mov     ecx, 1Eh
    mov     edi, offset dword_51E710
    and     word ptr [eax+3923Bh], 0FFFBh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFDFh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFBFh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+2BEEh], 0FF1Fh
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     byte ptr [edx+2A46h], 0FFh
    mov     dword_51F2DC, esi
    rep stosd
    mov     dword_51F2D8, esi
    pop     edi
    pop     esi
    retn
    sub_4917D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_491A70 proc near                    ; CODE XREF: .text:0041FB36p
                                            ; .text:00426406p
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37E1Fh], 280h
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+37E23h], 1E0h
    call    sub_4B6700
    cmp     eax, 280h
    jnz     short loc_491AAB
    call    sub_4B6710
    cmp     eax, 1E0h
    jz      locret_491B5D

    loc_491AAB:                             ; CODE XREF: sub_491A70+29j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    push    0
    mov     dword ptr [ecx+37E1Bh], 0
    call    sub_4C61F0
    call    sub_4C62C0
    mov     edx, TAdynmemStructPtr
    push    4                               ; uFlags
    push    1E0h                            ; cy
    push    280h                            ; cx
    mov     eax, [edx+0Ch]
    push    0                               ; Y
    push    0                               ; X
    push    0                               ; hWndInsertAfter
    mov     ecx, [eax+40h]
    push    ecx                             ; hWnd
    call    ds:SetWindowPos
    push    1E0h
    push    280h
    call    sub_4B5940
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37E23h]
    mov     eax, [eax+37E1Fh]
    push    edx                             ; int
    push    eax                             ; int
    push    offset aOffscreen               ; int
    call    sub_4C69F0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E1Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C61F0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37E1Bh]
    push    edx
    call    sub_4C69A0

    locret_491B5D:                          ; CODE XREF: sub_491A70+35j
    retn
    sub_491A70 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_491B60 proc near                    ; CODE XREF: .text:00460630p
                                            ; sub_491C60+Ap ...
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+TAdynmemStruct.NetworkLayerEnabled], 0FFFBh
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+TAdynmemStruct.DSound]
    call    sub_4CED40
    mov     ecx, TAdynmemStructPtr
    push    4
    mov     ecx, [ecx+TAdynmemStruct.DSound]
    call    sub_4CE690
    call    sub_41DC20
    call    nullsub_42
    call    sub_485980
    call    sub_471DE0
    call    sub_420960
    call    sub_44F6E0
    call    sub_464A00
    call    sub_466AA0
    call    sub_483DD0
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1438Bh]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    mov     edx, [ecx+14387h]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     ecx, [eax+14383h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    add     esp, 4
    mov     [edx+1438Bh], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+14387h], eax
    mov     edx, TAdynmemStructPtr
    mov     [edx+14383h], eax
    call    sub_42E120
    call    sub_42DB90
    call    sub_42F3A0
    call    sub_42A570
    call    sub_499A80
    call    sub_440A00
    call    sub_488BF0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short locret_491C59
    jmp     loc_450DD0
    ; ---------------------------------------------------------------------------

    locret_491C59:                          ; CODE XREF: sub_491B60+F2j
    retn
    sub_491B60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_491C60 proc near                    ; CODE XREF: .text:00460626p
    call    sub_4257A0
    call    sub_451B60
    call    sub_491B60
    push    0                               ; lpText
    call    sub_4B6230
    retn
    sub_491C60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_491C80 proc near                    ; CODE XREF: sub_41EC50+219p
                                            ; sub_41EC50+346p ...

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+arg_0]
    movsx   edx, byte ptr [ecx+2CBEh]
    cmp     edx, eax
    jz      short locret_491CB5
    mov     [ecx+2CBEh], al
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+eax*4+1487Fh]
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_4AB400

    locret_491CB5:                          ; CODE XREF: sub_491C80+13j
    retn    4
    sub_491C80 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+2CC6h]
    mov     cl, dl
    and     cl, 2
    jz      short loc_491CE3
    cmp     byte ptr [eax+2CC3h], 0Eh
    jnz     short loc_491CE3
    call    sub_4197D0
    retn    4
    ; ---------------------------------------------------------------------------

    loc_491CE3:                             ; CODE XREF: .text:00491CD0j
                                            ; .text:00491CD9j
    test    cl, cl
    jnz     short loc_491D18
    test    dl, 1
    jnz     short loc_491D18
    mov     dl, [eax+2CBEh]
    mov     cl, 13h
    cmp     dl, cl
    jz      short locret_491D6C
    mov     [eax+2CBEh], cl
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148CBh]
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AB400
    retn    4
    ; ---------------------------------------------------------------------------

    loc_491D18:                             ; CODE XREF: .text:00491CE5j
                                            ; .text:00491CEAj
    call    sub_48CD80
    mov     edx, TAdynmemStructPtr
    mov     [edx+2CBAh], ax
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2CC3h]
    push    ecx
    call    sub_48D220
    mov     ecx, TAdynmemStructPtr
    movsx   edx, byte ptr [ecx+2CBEh]
    cmp     edx, eax
    jz      short locret_491D6C
    mov     [ecx+2CBEh], al
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+eax*4+1487Fh]
    add     ecx, 519h
    push    eax
    push    ecx
    call    sub_4AB400

    locret_491D6C:                          ; CODE XREF: .text:00491CF6j
                                            ; .text:00491D4Aj
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_491D70 proc near                    ; CODE XREF: sub_41B2E0+46Ep
                                            ; sub_41B2E0+547p ...

    arg_0= dword ptr  4

    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37EBEh]
    test    ah, 8
    jnz     short loc_491D8F
    test    al, 65h
    jnz     short loc_491D8F
    test    byte ptr [ecx+2BEEh], 0E0h
    jz      short loc_491DA5

    loc_491D8F:                             ; CODE XREF: sub_491D70+10j
                                            ; sub_491D70+14j
    mov     edx, [esp+arg_0]
    test    edx, edx
    jnz     short loc_491DA5
    or      al, 10h
    mov     [ecx+37EBEh], ax
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_491DA5:                             ; CODE XREF: sub_491D70+1Dj
                                            ; sub_491D70+25j
    mov     word ptr [ecx+37E9Ch], 0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    test    ecx, ecx
    jz      short loc_491E01

    loc_491DBD:                             ; CODE XREF: sub_491D70+82j
    lea     ecx, [eax+37EA0h]
    add     eax, 519h
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4AB060
    test    eax, eax
    jnz     short loc_491DF9
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4A9660
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    test    ecx, ecx
    jnz     short loc_491DBD
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_491DF9:                             ; CODE XREF: sub_491D70+61j
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_491E01:                             ; CODE XREF: sub_491D70+4Bj
    xor     eax, eax
    retn    4
    sub_491D70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_491E10 proc near
    mov     eax, TAdynmemStructPtr
    lea     ecx, [eax+37EA0h]
    add     eax, 519h
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4AB060
    test    eax, eax
    jnz     short locret_491E48
    mov     edx, TAdynmemStructPtr
    mov     [edx+37E9Ch], ax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A9660

    locret_491E48:                          ; CODE XREF: sub_491E10+19j
    retn
    sub_491E10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_491E50 proc near
    mov     eax, dword_51F2E0
    push    esi
    xor     esi, esi
    cmp     eax, esi
    jz      short loc_491E65
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_491E65:                             ; CODE XREF: sub_491E50+Aj
    mov     eax, dword_51F2E4
    cmp     eax, esi
    jz      short loc_491E77
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_491E77:                             ; CODE XREF: sub_491E50+1Cj
    mov     eax, dword_51F2E8
    cmp     eax, esi
    jz      short loc_491E89
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_491E89:                             ; CODE XREF: sub_491E50+2Ej
    mov     eax, dword_51F2EC
    mov     dword_51F2E8, esi
    cmp     eax, esi
    mov     dword_51F2E4, esi
    mov     dword_51F2E0, esi
    jz      short loc_491EAD
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_491EAD:                             ; CODE XREF: sub_491E50+52j
    mov     dword_51F2EC, esi
    pop     esi
    retn
    sub_491E50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_491EC0 proc near                    ; CODE XREF: .text:00492DE0p
                                            ; sub_492DF0+15Ap ...

    var_144= dword ptr -144h
    var_140= dword ptr -140h
    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= dword ptr -100h

    mov     eax, TAdynmemStructPtr
    sub     esp, 144h
    push    ebx
    lea     ebx, [eax+519h]
    mov     eax, [eax+531h]
    push    ebp
    push    esi
    push    offset aGames_0                 ; char *
    mov     esi, [eax+4]
    push    esi                             ; int
    call    sub_49FF90
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_49231A
    push    edi
    push    3
    push    offset aGamename                ; char *
    push    esi                             ; int
    call    sub_49FDF0
    mov     esi, eax
    mov     ax, [ebp+0BAh]
    cmp     ax, 0FFFFh
    jle     loc_49228F
    mov     edx, dword_51F2E4
    movsx   ecx, ax
    push    ecx
    push    edx
    call    sub_4B6AF0
    mov     edx, eax
    test    edx, edx
    jz      loc_49228F
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_49228F
    push    edx
    push    esi
    push    ebx
    call    sub_4A0880
    movsx   eax, word ptr [ebp+0BAh]
    mov     ecx, dword_51F2E0
    push    eax
    push    ecx
    call    sub_4B6AF0
    mov     edx, dword_5091C8
    push    eax
    push    edx
    lea     eax, [esp+160h+var_104]
    push    offset aSS                      ; "%s\\%s"
    push    eax
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+158h+var_104]
    push    ecx
    call    sub_432520
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_49228F
    push    offset aRadarImage              ; "Radar Image"
    mov     ecx, ebp
    call    sub_4B4BA0
    mov     edx, [ebx+18h]
    push    offset aRadar_1                 ; char *
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_4A0280
    mov     esi, eax
    mov     eax, dword_51F2EC
    test    eax, eax
    jz      short loc_491FB7
    push    eax
    call    sub_4C6AC0

    loc_491FB7:                             ; CODE XREF: sub_491EC0+EFj
    push    ebp
    call    sub_4C6F80
    test    eax, eax
    mov     dword_51F2EC, eax
    jz      short loc_491FE0
    push    eax
    push    offset dword_51E6F8
    call    sub_4B8AE0
    mov     dword ptr [esi+0C2h], offset dword_51E6F8
    mov     eax, dword_51F2EC

    loc_491FE0:                             ; CODE XREF: sub_491EC0+104j
    xor     ecx, ecx
    test    eax, eax
    setnz   cl
    push    ecx                             ; int
    push    offset aRadar_1                 ; char *
    push    ebx                             ; int
    call    sub_4A0570
    push    0                               ; int
    push    offset aPlayers                 ; char *
    mov     ecx, ebp
    call    sub_4B4800
    push    0                               ; int
    push    offset aGametype                ; char *
    mov     ecx, ebp
    mov     esi, eax
    call    sub_4B4800
    test    esi, esi
    mov     [esp+10h], eax
    jz      short loc_49203E
    cmp     eax, 1
    jnz     short loc_492029
    lea     edx, [esp+158h+var_144]
    mov     edi, offset aSingle             ; "Single"
    jmp     short loc_492047
    ; ---------------------------------------------------------------------------

    loc_492029:                             ; CODE XREF: sub_491EC0+15Cj
    push    esi
    lea     ecx, [esp+15Ch+var_144]
    push    offset aSkirmishDPlaye          ; "Skirmish (%d players)"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    jmp     short loc_492064
    ; ---------------------------------------------------------------------------

    loc_49203E:                             ; CODE XREF: sub_491EC0+157j
    lea     edx, [esp+158h+var_144]
    mov     edi, offset a???                ; "???"

    loc_492047:                             ; CODE XREF: sub_491EC0+167j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_492064:                             ; CODE XREF: sub_491EC0+17Cj
    lea     ecx, [esp+158h+var_144]
    push    0
    push    ecx
    push    offset aGametype_0              ; "GAMETYPE"
    push    ebx
    call    sub_4A0BF0
    push    0                               ; int
    cmp     dword ptr [esp+14h], 1
    jnz     short loc_4920F2
    push    offset aCampaign                ; char *
    mov     ecx, ebp
    call    sub_4B48A0
    test    eax, eax
    jz      short loc_4920DE
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+158h+var_144]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+15Ch+var_144]
    push    ecx
    push    offset aCampaign_0              ; "CAMPAIGN"
    push    ebx
    call    sub_4A0BF0
    push    1                               ; int
    push    offset aCamptext                ; char *
    push    ebx                             ; int
    call    sub_4A0570
    push    1                               ; int
    push    offset aCampaign_0              ; char *
    push    ebx                             ; int
    call    sub_4A0570

    loc_4920DE:                             ; CODE XREF: sub_491EC0+1CDj
    push    0                               ; int
    push    offset aMission                 ; char *
    mov     ecx, ebp
    call    sub_4B48A0
    test    eax, eax
    jz      short loc_492151
    jmp     short loc_49211C                ; int
    ; ---------------------------------------------------------------------------

    loc_4920F2:                             ; CODE XREF: sub_491EC0+1BDj
    push    offset aCamptext                ; char *
    push    ebx                             ; int
    call    sub_4A0570
    push    0                               ; int
    push    offset aCampaign_0              ; char *
    push    ebx                             ; int
    call    sub_4A0570
    push    0                               ; int
    push    offset aMap                     ; char *
    mov     ecx, ebp
    call    sub_4B48A0
    test    eax, eax
    jz      short loc_492151

    loc_49211C:                             ; CODE XREF: sub_491EC0+230j
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+158h+var_144]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+15Ch+var_144]
    push    ecx
    push    offset aMission_0               ; "MISSION"
    push    ebx
    call    sub_4A0BF0

    loc_492151:                             ; CODE XREF: sub_491EC0+22Ej
                                            ; sub_491EC0+25Aj
    push    0                               ; int
    push    offset aGameTime                ; char *
    mov     ecx, ebp
    call    sub_4B4800
    mov     ecx, eax
    mov     eax, 88888889h
    imul    ecx
    add     edx, ecx
    sar     edx, 4
    mov     esi, edx
    mov     eax, edx
    shr     esi, 1Fh
    add     eax, esi
    mov     esi, 3Ch
    cdq
    idiv    esi
    mov     eax, 91A2B3C5h
    push    edx
    imul    ecx
    add     edx, ecx
    sar     edx, 0Ah
    mov     esi, edx
    mov     eax, edx
    shr     esi, 1Fh
    add     eax, esi
    mov     esi, 3Ch
    cdq
    idiv    esi
    mov     eax, 9B583739h
    push    edx
    imul    ecx
    add     edx, ecx
    lea     ecx, [esp+160h+var_144]
    sar     edx, 10h
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    push    edx
    push    offset a02d02d02d               ; "%02d:%02d:%02d"
    push    ecx
    call    _sprintf
    add     esp, 14h
    lea     edx, [esp+158h+var_144]
    push    0
    push    edx
    push    offset aTime                    ; "TIME"
    push    ebx
    call    sub_4A0BF0
    mov     eax, dword_51F2E8
    test    eax, eax
    jz      short loc_492200
    push    0                               ; int
    push    offset aSide_0                  ; char *
    mov     ecx, ebp
    call    sub_4B4800
    push    eax
    mov     eax, dword_51F2E8
    push    eax
    call    sub_4B6AF0
    lea     edx, [esp+158h+var_144]
    mov     edi, eax
    jmp     short loc_492209
    ; ---------------------------------------------------------------------------

    loc_492200:                             ; CODE XREF: sub_491EC0+31Cj
    lea     edx, [esp+158h+var_144]
    mov     edi, offset a???                ; "???"

    loc_492209:                             ; CODE XREF: sub_491EC0+33Ej
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    push    0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+15Ch+var_144]
    push    ecx
    push    offset aSide_1                  ; "SIDE"
    push    ebx
    call    sub_4A0BF0
    push    0                               ; int
    push    offset aDifficulty              ; char *
    mov     ecx, ebp
    mov     dword ptr [esp+50h], offset aEasy ; "Easy"
    mov     [esp+160h+var_10C], offset aMedium ; "Medium"
    mov     [esp+160h+var_108], offset aHard ; "Hard"
    call    sub_4B4800
    mov     edx, [esp+eax*4+48h]
    lea     eax, [esp+158h+var_144]
    push    edx
    push    offset aS_1                     ; "%s"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+158h+var_144]
    push    0
    push    ecx
    push    offset aDiff                    ; "DIFF"
    push    ebx
    call    sub_4A0BF0
    push    ebp
    call    sub_432590
    jmp     short loc_492307
    ; ---------------------------------------------------------------------------

    loc_49228F:                             ; CODE XREF: sub_491EC0+4Dj
                                            ; sub_491EC0+67j ...
    push    offset Data
    push    esi
    push    ebx
    call    sub_4A0880
    push    0
    push    offset Data
    push    offset aSide_1                  ; "SIDE"
    push    ebx
    call    sub_4A0BF0
    push    0
    push    offset Data
    push    offset aDiff                    ; "DIFF"
    push    ebx
    call    sub_4A0BF0
    push    0
    push    offset Data
    push    offset aMission_0               ; "MISSION"
    push    ebx
    call    sub_4A0BF0
    push    0
    push    offset Data
    push    offset aCampaign_0              ; "CAMPAIGN"
    push    ebx
    call    sub_4A0BF0
    push    0
    push    offset Data
    push    offset aGametype_0              ; "GAMETYPE"
    push    ebx
    call    sub_4A0BF0
    push    0
    push    offset Data
    push    offset aTime                    ; "TIME"
    push    ebx
    call    sub_4A0BF0

    loc_492307:                             ; CODE XREF: sub_491EC0+3CDj
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx                             ; int
    call    sub_49FA90
    pop     edi

    loc_49231A:                             ; CODE XREF: sub_491EC0+2Cj
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 144h
    retn
    sub_491EC0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    push    1
    push    1
    push    140h
    push    offset aInvalidSavegam          ; "Invalid savegame file"
    call    sub_4C5740
    push    eax
    mov     esi, [esp+18h]
    push    esi
    call    sub_4ABD90
    push    esi
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_492360 proc near                    ; DATA XREF: sub_4931D0+24o

    var_104= dword ptr -104h
    arg_0= dword ptr  4

    sub     esp, 104h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+114h+arg_0]
    or      esi, 0FFFFFFFFh
    mov     eax, [edi+18h]
    mov     ebp, [eax+4]
    mov     eax, [edi+60h]
    cmp     eax, esi
    jz      loc_492AFF
    push    offset aCancel_0                ; "CANCEL"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      loc_492430
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2A44h]
    shr     cl, 2
    test    cl, 1
    jz      short loc_4923B6
    add     eax, 519h
    push    eax
    call    sub_49FA70

    loc_4923B6:                             ; CODE XREF: sub_492360+49j
    mov     eax, dword_51F2E0
    xor     ebx, ebx
    cmp     eax, ebx
    jz      short loc_4923CA
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4923CA:                             ; CODE XREF: sub_492360+5Fj
    mov     eax, dword_51F2E4
    cmp     eax, ebx
    jz      short loc_4923DC
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4923DC:                             ; CODE XREF: sub_492360+71j
    mov     eax, dword_51F2E8
    cmp     eax, ebx
    jz      short loc_4923EE
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4923EE:                             ; CODE XREF: sub_492360+83j
    mov     eax, dword_51F2EC
    mov     dword_51F2E8, ebx
    cmp     eax, ebx
    mov     dword_51F2E4, ebx
    mov     dword_51F2E0, ebx
    jz      short loc_492412
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_492412:                             ; CODE XREF: sub_492360+A7j
    push    ebx                             ; int
    push    offset aPrevious                ; char *
    mov     dword_51F2EC, ebx
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_492430:                             ; CODE XREF: sub_492360+32j
    push    offset aLoad                    ; "LOAD"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_49246A
    push    offset aGames_0                 ; "GAMES"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_49246A
    cmp     [edi+60h], esi
    jz      loc_492AFF
    push    edi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49246A:                             ; CODE XREF: sub_492360+DDj
                                            ; sub_492360+ECj
    push    offset aGames_0                 ; char *
    push    ebp                             ; int
    call    sub_49FF90
    movsx   edx, word ptr [eax+0BAh]
    mov     eax, dword_51F2E0
    push    edx
    push    eax
    call    sub_4B6AF0
    mov     ecx, dword_5091C8
    push    eax
    push    ecx
    lea     edx, [esp+11Ch+var_104]
    push    offset aSS                      ; "%s\\%s"
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+114h+var_104]
    push    eax
    call    sub_432520
    mov     esi, eax
    xor     ebx, ebx
    cmp     esi, ebx
    jz      loc_492AB4
    push    ebx                             ; int
    push    offset aGametype                ; char *
    mov     ecx, esi
    call    sub_4B4800
    push    esi
    mov     edi, eax
    call    sub_432590
    mov     eax, edi
    dec     eax
    jz      short loc_49252D
    dec     eax
    jnz     loc_492AAD
    push    1
    call    sub_41D6A0
    test    al, al
    jnz     loc_49257A
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_1          ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49252D:                             ; CODE XREF: sub_492360+170j
    push    ebx
    call    sub_41D6A0
    test    al, al
    jnz     short loc_49257A
    push    1
    push    1
    push    0C8h
    push    offset aPleaseInsert_0          ; int
    call    sub_4C5740
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4ABD90
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49257A:                             ; CODE XREF: sub_492360+182j
                                            ; sub_492360+1D5j
    call    sub_41D4C0
    call    sub_4257A0
    mov     eax, TAdynmemStructPtr
    mov     cl, 14h
    cmp     [eax+2CBEh], cl
    jz      short loc_4925B5
    mov     [eax+2CBEh], cl
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+148CFh]
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4AB400
    mov     eax, TAdynmemStructPtr

    loc_4925B5:                             ; CODE XREF: sub_492360+231j
    mov     cl, [eax+2A44h]
    shr     cl, 2
    test    cl, 1
    jz      short loc_4925CE
    add     eax, 519h
    push    eax
    call    sub_49FA70

    loc_4925CE:                             ; CODE XREF: sub_492360+261j
    push    ebx                             ; int
    push    offset aSmlbutton_0             ; char *
    call    sub_47F1A0
    push    offset aGames_0                 ; char *
    push    ebp                             ; int
    call    sub_49FF90
    movsx   edx, word ptr [eax+0BAh]
    mov     eax, dword_51F2E0
    push    edx
    push    eax
    call    sub_4B6AF0
    mov     ecx, dword_5091C8
    mov     edx, TAdynmemStructPtr
    push    eax
    push    ecx
    add     edx, 38C6Bh
    push    offset aSS                      ; "%s\\%s"
    push    edx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 10h
    mov     cl, [eax+2A44h]
    shr     cl, 2
    test    cl, 1
    jz      short loc_492636
    call    sub_491B60
    mov     eax, TAdynmemStructPtr

    loc_492636:                             ; CODE XREF: sub_492360+2CAj
    or      byte ptr [eax+3923Bh], 8
    mov     edx, TAdynmemStructPtr
    add     edx, 38C6Bh
    push    edx
    call    sub_4325B0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38D6Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+38D6Bh]
    cmp     ecx, ebx
    jz      loc_492AAD
    push    offset aSummary                 ; char *
    call    sub_4B4560
    mov     eax, TAdynmemStructPtr
    push    ebx                             ; int
    push    offset aGametype                ; char *
    mov     ecx, [eax+38D6Bh]
    call    sub_4B4800
    push    eax
    call    sub_434AB0
    mov     ecx, TAdynmemStructPtr
    push    ebx                             ; int
    push    offset aCampaign                ; char *
    mov     ecx, [ecx+38D6Bh]
    call    sub_4B48A0
    cmp     eax, ebx
    jz      short loc_4926C2
    mov     edx, TAdynmemStructPtr
    push    eax
    mov     ecx, [edx+391E9h]
    call    sub_435110

    loc_4926C2:                             ; CODE XREF: sub_492360+34Ej
    mov     eax, TAdynmemStructPtr
    push    ebx                             ; int
    push    offset aSide_0                  ; char *
    mov     ecx, [eax+38D6Bh]
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    push    ebx                             ; int
    push    offset aDifficulty              ; char *
    mov     [ecx+37EF2h], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+38D6Bh]
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37EEEh], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_492766
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37EF2h]
    mov     eax, [eax+1B8Ah]
    cmp     ecx, ebx
    jnz     short loc_49274D
    mov     [eax+95h], bl
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1CD5h]
    mov     byte ptr [edx+95h], 1
    jmp     short loc_492766
    ; ---------------------------------------------------------------------------

    loc_49274D:                             ; CODE XREF: sub_492360+3D0j
    mov     byte ptr [eax+95h], 1
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+1CD5h]
    mov     [edx+95h], bl

    loc_492766:                             ; CODE XREF: sub_492360+3BBj
                                            ; sub_492360+3EBj
    mov     eax, TAdynmemStructPtr
    push    ebx                             ; int
    push    offset aMission                 ; char *
    mov     ecx, [eax+38D6Bh]
    call    sub_4B48A0
    mov     esi, eax
    cmp     esi, ebx
    jz      loc_492AAD
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_492AAD
    mov     ecx, TAdynmemStructPtr
    push    esi
    mov     ecx, [ecx+391E9h]
    call    sub_435A20
    test    eax, eax
    jz      loc_492AAD
    mov     edx, TAdynmemStructPtr
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [edx+29A0h]
    push    ebx                             ; int
    add     edx, 11Ch
    push    offset aThumbs                  ; char *
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+38D6Bh]
    call    sub_4B48A0
    mov     edx, TAdynmemStructPtr
    push    19h                             ; size_t
    add     edx, 391CFh
    push    eax                             ; char *
    push    edx                             ; char *
    call    _strncpy
    mov     eax, TAdynmemStructPtr
    or      ecx, 0FFFFFFFFh
    add     esp, 0Ch
    lea     edi, [eax+391CFh]
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     ecx, 19h
    jz      short loc_492831
    call    sub_41DA30

    loc_492831:                             ; CODE XREF: sub_492360+4CAj
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    mov     ebp, 2
    cmp     eax, ebp
    jnz     loc_492956
    mov     edx, TAdynmemStructPtr
    push    offset aSummary                 ; char *
    mov     ecx, [edx+38D6Bh]
    call    sub_4B4560
    mov     eax, TAdynmemStructPtr
    push    ebx                             ; int
    push    offset aPlayers                 ; char *
    mov     ecx, [eax+38D6Bh]
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    push    offset aCommanderdeath          ; char *
    mov     [ecx+2A3Ch], ax
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+38D6Bh]
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    push    offset aLocation                ; char *
    mov     edx, [ecx+29A0h]
    mov     [edx+108h], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38D6Bh]
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    push    offset aMapping_0               ; char *
    mov     edx, [ecx+29A0h]
    mov     [edx+118h], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38D6Bh]
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    push    offset aLineofsight_0           ; char *
    mov     edx, [ecx+29A0h]
    mov     [edx+10Ch], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38D6Bh]
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    push    offset aLineofsighttyp          ; char *
    mov     edx, [ecx+29A0h]
    mov     [edx+110h], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38D6Bh]
    call    sub_4B4800
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     [edx+114h], eax

    loc_492956:                             ; CODE XREF: sub_492360+4E9j
    mov     eax, TAdynmemStructPtr
    mov     edi, offset dword_496BB0
    push    ebx
    push    offset loc_4578F0
    or      byte ptr [eax+2A44h], 4
    mov     eax, TAdynmemStructPtr
    mov     [eax+391F1h], ebp
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+391F5h], edi
    call    sub_4B4FD0
    mov     eax, dword_51F2E0
    cmp     eax, ebx
    jz      short loc_49299B
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_49299B:                             ; CODE XREF: sub_492360+630j
    mov     eax, dword_51F2E4
    cmp     eax, ebx
    jz      short loc_4929AD
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4929AD:                             ; CODE XREF: sub_492360+642j
    mov     eax, dword_51F2E8
    cmp     eax, ebx
    jz      short loc_4929BF
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4929BF:                             ; CODE XREF: sub_492360+654j
    mov     eax, dword_51F2EC
    mov     dword_51F2E8, ebx
    cmp     eax, ebx
    mov     dword_51F2E4, ebx
    mov     dword_51F2E0, ebx
    jz      short loc_4929E3
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4929E3:                             ; CODE XREF: sub_492360+678j
    push    1
    mov     dword_51F2EC, ebx
    call    sub_491D70
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     loc_492A9B
    mov     eax, TAdynmemStructPtr
    push    offset aBetweenmission          ; char *
    mov     ecx, [eax+38D6Bh]
    call    sub_4B48F0
    test    eax, eax
    jz      short loc_492A9B
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2A44h], 8
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+38D6Bh]
    cmp     esi, ebx
    jz      short loc_492A5E
    mov     ecx, esi
    call    sub_4B3630
    push    esi
    call    sub_4B4F20
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     [eax+38D6Bh], ebx
    mov     eax, TAdynmemStructPtr

    loc_492A5E:                             ; CODE XREF: sub_492360+6DCj
    and     word ptr [eax+2A44h], 0FFFBh
    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    offset loc_4578F0
    mov     [ecx+391F1h], ebp
    mov     edx, TAdynmemStructPtr
    mov     [edx+391F5h], edi
    call    sub_4B4FD0
    push    offset aCCavedogWarg_1          ; "c:\\cavedog\\wargame\\wargame.cpp"
    push    48Ch
    push    0Eh
    call    sub_425860

    loc_492A9B:                             ; CODE XREF: sub_492360+6A4j
                                            ; sub_492360+6C1j
    call    sub_4257A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_492AAD:                             ; CODE XREF: sub_492360+173j
                                            ; sub_492360+309j ...
    mov     edi, [esp+114h+arg_0]

    loc_492AB4:                             ; CODE XREF: sub_492360+152j
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+38D6Bh]
    cmp     esi, ebx
    jz      short loc_492AD3
    mov     ecx, esi
    call    sub_4B3630
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_492AD3:                             ; CODE XREF: sub_492360+761j
    mov     ecx, TAdynmemStructPtr
    push    1
    push    1
    push    140h
    push    offset aInvalidSavegam          ; int
    mov     [ecx+38D6Bh], ebx
    call    sub_4C5740
    push    eax
    push    edi
    call    sub_4ABD90
    push    edi
    call    sub_4AB0A0

    loc_492AFF:                             ; CODE XREF: sub_492360+1Fj
                                            ; sub_492360+F1j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    4
    sub_492360 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_492B10 proc near                    ; CODE XREF: sub_492DF0+14Fp
                                            ; sub_493060+5Cp ...

    var_110= dword ptr -110h
    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= dword ptr -100h
    arg_0= dword ptr  4

    mov     eax, dword_5091C8
    sub     esp, 110h
    lea     ecx, [esp+110h+var_100]
    push    ebx
    push    offset aSav                     ; "SAV"
    push    offset asc_50372C               ; "*"
    push    eax
    push    ecx
    call    sub_4290F0
    lea     edx, [esp+114h+var_100]
    push    0
    push    edx
    call    sub_4BC930
    test    eax, eax
    mov     ebx, [esp+114h+arg_0]
    mov     [ebx], eax
    jnz     short loc_492B72
    push    eax
    push    eax
    mov     eax, TAdynmemStructPtr
    push    offset Data
    add     eax, 519h
    push    offset aGames_0                 ; "GAMES"
    push    eax
    call    sub_4A32A0
    xor     eax, eax
    pop     ebx
    add     esp, 110h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_492B72:                             ; CODE XREF: sub_492B10+38j
    push    edi
    push    esi
    shl     eax, 8
    push    ebp
    push    eax
    push    offset aSavegameNames           ; "SAVEGAME NAMES"
    call    sub_4D83B0
    mov     dword_51F2E0, eax
    mov     ecx, [ebx]
    add     esp, 8
    shl     ecx, 6
    push    ecx
    push    offset aSavegameDescs           ; "SAVEGAME DESCS"
    call    sub_4D83B0
    mov     edi, eax
    xor     eax, eax
    mov     dword_51F2E4, edi
    mov     ecx, [ebx]
    shl     ecx, 6
    mov     edx, ecx
    add     esp, 8
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    push    1
    and     ecx, 3
    push    0
    rep stosb
    mov     ecx, [ebx]
    mov     edi, dword_51F2E0
    shl     ecx, 8
    mov     edx, ecx
    xor     eax, eax
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    push    0
    and     ecx, 3
    push    0
    rep stosb
    mov     eax, dword_51F2E0
    lea     ecx, [esp+130h+var_100]
    push    eax
    push    ecx
    call    sub_4AF320
    mov     edx, [ebx]
    mov     ebp, dword_51F2E4
    shl     edx, 8
    push    edx
    push    offset aSavegame2               ; "SAVEGAME2"
    mov     [esp+128h+var_104], ebp
    mov     [esp+128h+var_110], 0
    call    sub_4D83B0
    mov     ecx, [ebx]
    mov     esi, dword_51F2E0
    shl     ecx, 8
    mov     edx, ecx
    mov     edi, eax
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    add     esp, 8
    and     ecx, 3
    mov     [esp+120h+var_10C], eax
    rep movsb
    mov     ecx, [ebx]
    xor     esi, esi
    test    ecx, ecx
    mov     [esp+120h+var_108], esi
    jle     loc_492D91
    jmp     short loc_492C4C
    ; ---------------------------------------------------------------------------

    loc_492C44:                             ; CODE XREF: sub_492B10+275j
    mov     ebp, [esp+120h+var_104]
    mov     eax, [esp+120h+var_10C]

    loc_492C4C:                             ; CODE XREF: sub_492B10+132j
    push    esi
    push    eax
    call    sub_4B6AF0
    push    eax
    mov     eax, dword_5091C8
    push    eax
    lea     ecx, [esp+128h+var_100]
    push    offset aSS                      ; "%s\\%s"
    push    ecx
    call    _sprintf
    add     esp, 10h
    lea     edx, [esp+120h+var_100]
    push    edx
    call    sub_432520
    mov     ebx, eax
    xor     eax, eax
    test    ebx, ebx
    jz      loc_492D0A
    push    eax                             ; int
    push    offset aDescription             ; char *
    mov     ecx, ebx
    call    sub_4B48A0
    test    ebx, ebx
    jz      short loc_492D0A
    test    eax, eax
    jz      short loc_492D0A
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+120h+var_100]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+120h+var_100]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     edx, [esp+120h+var_110]
    and     ecx, 3
    rep movsb
    lea     edi, [esp+120h+var_100]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    inc     edx
    mov     [esp+120h+var_110], edx
    lea     eax, [ebp+ecx+1]
    mov     ecx, ebx
    mov     [esp+120h+var_104], eax
    call    sub_4B3630
    push    ebx
    call    sub_4B4F20
    add     esp, 4
    jmp     short loc_492D73
    ; ---------------------------------------------------------------------------

    loc_492D0A:                             ; CODE XREF: sub_492B10+16Cj
                                            ; sub_492B10+181j ...
    mov     ecx, [esp+120h+var_110]
    mov     edx, dword_51F2E0
    push    ecx
    push    edx
    call    sub_4B6AF0
    mov     ebp, eax
    lea     ebx, [esi+1]
    mov     eax, [esp+120h+arg_0]
    cmp     ebx, [eax]
    jge     short loc_492D77

    loc_492D2B:                             ; CODE XREF: sub_492B10+261j
    mov     ecx, [esp+120h+var_10C]
    push    ebx
    push    ecx
    call    sub_4B6AF0
    mov     edx, eax
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    inc     ebx
    lea     ebp, [ebp+ecx+1]
    mov     ecx, [esp+120h+arg_0]
    cmp     ebx, [ecx]
    jl      short loc_492D2B

    loc_492D73:                             ; CODE XREF: sub_492B10+1F8j
    mov     esi, [esp+120h+var_108]

    loc_492D77:                             ; CODE XREF: sub_492B10+219j
    mov     edx, [esp+120h+arg_0]
    inc     esi
    mov     [esp+120h+var_108], esi
    cmp     esi, [edx]
    jl      loc_492C44
    mov     eax, [esp+120h+var_10C]
    mov     ebx, edx

    loc_492D91:                             ; CODE XREF: sub_492B10+12Cj
    push    eax                             ; int
    call    sub_4D85A0
    mov     esi, [esp+124h+var_110]
    mov     eax, dword_51F2E4
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    add     ecx, 519h
    push    0
    push    esi
    push    eax
    push    offset aGames_0                 ; "GAMES"
    push    ecx
    call    sub_4A32A0
    mov     eax, esi
    mov     [ebx], esi
    mov     ecx, dword_51F2E0
    pop     ebp
    neg     eax
    sbb     eax, eax
    pop     esi
    pop     edi
    and     eax, ecx
    pop     ebx
    add     esp, 110h
    retn    4
    sub_492B10 endp

    ; ---------------------------------------------------------------------------
    align 8

    loc_492DE0:                             ; DATA XREF: sub_493060+B2o
                                            ; sub_4931D0+F5o
    call    sub_491EC0
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_492DF0 proc near                    ; DATA XREF: sub_493060+31o

    var_108= dword ptr -108h
    var_104= dword ptr -104h
    FileName= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 108h
    push    ebx
    push    esi
    mov     esi, [esp+110h+arg_0]
    push    edi
    or      edi, 0FFFFFFFFh
    mov     eax, [esi+18h]
    mov     ebx, [eax+4]
    mov     eax, [esi+60h]
    cmp     eax, edi
    jnz     loc_492E98
    push    1
    push    esi
    call    sub_4AB190
    mov     eax, dword_51F2E0
    test    eax, eax
    jz      short loc_492E2E
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_492E2E:                             ; CODE XREF: sub_492DF0+33j
    mov     eax, dword_51F2E4
    test    eax, eax
    jz      short loc_492E40
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_492E40:                             ; CODE XREF: sub_492DF0+45j
    mov     eax, dword_51F2E8
    test    eax, eax
    jz      short loc_492E52
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_492E52:                             ; CODE XREF: sub_492DF0+57j
    mov     eax, dword_51F2EC
    mov     dword_51F2E8, 0
    test    eax, eax
    mov     dword_51F2E4, 0
    mov     dword_51F2E0, 0
    jz      short loc_492E82
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_492E82:                             ; CODE XREF: sub_492DF0+87j
    mov     dword_51F2EC, 0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 108h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_492E98:                             ; CODE XREF: sub_492DF0+1Ej
    push    offset aCancel_0                ; "CANCEL"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_492EDD
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2A44h]
    shr     cl, 2
    test    cl, 1
    jz      short loc_492EC5
    add     eax, 519h
    push    eax
    call    sub_49FA70

    loc_492EC5:                             ; CODE XREF: sub_492DF0+C8j
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 108h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_492EDD:                             ; CODE XREF: sub_492DF0+B5j
    push    offset aDelete                  ; "DELETE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_492F5B
    push    0                               ; int
    push    offset aSmallbutton             ; char *
    call    sub_47F1A0
    push    offset aGames_0                 ; char *
    push    ebx                             ; int
    call    sub_49FF90
    movsx   edx, word ptr [eax+0BAh]
    mov     eax, dword_51F2E0
    push    edx
    push    eax
    call    sub_4B6AF0
    mov     ecx, dword_5091C8
    push    eax
    push    ecx
    lea     edx, [esp+11Ch+FileName]
    push    offset aSS                      ; "%s\\%s"
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+114h+FileName]
    push    eax                             ; lpFileName
    call    sub_4BBC30
    lea     ecx, [esp+114h+var_104]
    push    ecx
    call    sub_492B10
    push    esi
    call    sub_4AB0A0
    call    sub_491EC0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 108h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_492F5B:                             ; CODE XREF: sub_492DF0+FAj
    push    offset aGames_0                 ; "GAMES"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_492FA3
    push    offset aLoad                    ; "LOAD"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_492FA3
    push    offset aGamename                ; "GAMENAME"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_492FA3
    cmp     [esi+60h], edi
    jz      loc_49304E
    push    esi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 108h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_492FA3:                             ; CODE XREF: sub_492DF0+178j
                                            ; sub_492DF0+187j ...
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+2A44h]
    shr     dl, 2
    test    dl, 1
    jz      short loc_492FC1
    add     eax, 519h
    push    eax
    call    sub_49FA70

    loc_492FC1:                             ; CODE XREF: sub_492DF0+1C4j
    push    0                               ; int
    push    offset aSmlbutton               ; char *
    call    sub_47F1A0
    push    3
    push    offset aGamename                ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    xor     eax, eax
    lea     esi, [edx+ecx*2+0B6h]
    or      ecx, 0FFFFFFFFh
    mov     edi, esi
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_49304E
    push    offset aGames_0                 ; char *
    push    ebx                             ; int
    call    sub_49FF90
    mov     ecx, TAdynmemStructPtr
    push    offset aSav                     ; "SAV"
    mov     [esp+10h], eax
    mov     eax, dword_5091C8
    push    esi
    add     ecx, 38C6Bh
    push    eax
    push    ecx
    call    sub_4290F0
    push    0                               ; time_t *
    call    _time
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    add     edx, 38C6Bh
    push    eax                             ; int
    push    esi                             ; int
    push    edx                             ; int
    call    sub_4326B0

    loc_49304E:                             ; CODE XREF: sub_492DF0+19Bj
                                            ; sub_492DF0+211j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 108h
    retn    4
    sub_492DF0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_493060 proc near                    ; CODE XREF: sub_41EC50+19Fp
                                            ; sub_4609B0+E9p

    var_4= dword ptr -4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    push    880h
    or      byte ptr [eax+38A51h], 1
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    offset aLoadgame_gui            ; "LOADGAME.GUI"
    push    eax
    call    sub_4AA8F0
    mov     edi, eax
    push    0
    push    0
    push    0
    mov     dword ptr [edi+8], offset sub_492DF0
    mov     ecx, TAdynmemStructPtr
    push    offset aDsavegame2              ; "DSAVEGAME2"
    mov     [edi+0Ch], ecx
    call    sub_4288D0
    mov     edx, dword_5091C8
    push    edx
    call    sub_4BCF00
    lea     eax, [esp+0Ch+var_4]
    push    eax
    call    sub_492B10
    mov     ecx, TAdynmemStructPtr
    push    0
    push    offset aSaveGame                ; "Save Game"
    add     ecx, 519h
    push    offset aTitle                   ; "TITLE"
    push    ecx
    call    sub_4A0BF0
    mov     eax, [esp+0Ch+var_4]
    test    eax, eax
    jnz     short loc_493100
    mov     edx, TAdynmemStructPtr
    push    0                               ; int
    add     edx, 519h
    push    offset aDelete                  ; char *
    push    edx                             ; int
    call    sub_4A0570

    loc_493100:                             ; CODE XREF: sub_493060+85j
    mov     eax, [edi+4]
    push    offset aGames_0                 ; char *
    push    eax                             ; int
    call    sub_49FF90
    test    eax, eax
    jz      short loc_49311C
    mov     dword ptr [eax+0CEh], offset loc_492DE0

    loc_49311C:                             ; CODE XREF: sub_493060+B0j
    mov     ecx, [edi+4]
    push    3
    push    offset aGamename                ; char *
    push    ecx                             ; int
    call    sub_49FDF0
    mov     esi, eax
    shl     eax, 3
    sub     eax, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    lea     ecx, [esi+eax*4]
    mov     eax, [edi+4]
    lea     edx, [esi+ecx*2]
    mov     ecx, [edx+eax+1Bh]
    or      ecx, 2
    lea     eax, [edx+eax+1Bh]
    mov     [eax], ecx
    call    sub_476830
    mov     dword_51F2E8, eax
    call    sub_491EC0
    mov     ecx, TAdynmemStructPtr
    push    esi
    add     ecx, 519h
    push    ecx
    call    sub_4A7190
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    call    sub_428B60
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    add     eax, 519h
    push    offset aLoadgame                ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA50
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ecx
    retn
    sub_493060 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4931D0 proc near                    ; CODE XREF: sub_41EC50+16Cp
                                            ; sub_4609B0+C5p ...

    var_4= dword ptr -4

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    esi
    push    980h
    add     eax, 519h
    push    offset aLoadgame_gui            ; "LOADGAME.GUI"
    push    eax
    call    sub_4AA8F0
    mov     esi, eax
    push    0
    push    0
    push    0
    mov     dword ptr [esi+8], offset sub_492360
    mov     ecx, TAdynmemStructPtr
    push    offset aDloadgame2              ; "DLOADGAME2"
    mov     [esi+0Ch], ecx
    call    sub_4288D0
    lea     edx, [esp+8+var_4]
    push    edx
    call    sub_492B10
    test    eax, eax
    jnz     short loc_493255
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A9660
    push    1
    push    1
    push    140h
    push    offset aThereAreNoSave          ; int
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4ABD90
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_493255:                             ; CODE XREF: sub_4931D0+4Aj
    call    sub_476830
    mov     edx, [esp+8+var_4]
    mov     ecx, TAdynmemStructPtr
    mov     dword_51F2E8, eax
    mov     eax, dword_51F2E4
    push    0
    push    edx
    push    eax
    add     ecx, 519h
    push    offset aGames_0                 ; "GAMES"
    push    ecx
    call    sub_4A32A0
    mov     edx, TAdynmemStructPtr
    push    0                               ; int
    add     edx, 519h
    push    offset aDelete                  ; char *
    push    edx                             ; int
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    add     eax, 519h
    push    offset aGamename                ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, [esi+4]
    push    offset aGames_0                 ; char *
    push    ecx                             ; int
    call    sub_49FF90
    test    eax, eax
    jz      short loc_4932CF
    mov     dword ptr [eax+0CEh], offset loc_492DE0

    loc_4932CF:                             ; CODE XREF: sub_4931D0+F3j
    call    sub_491EC0
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    call    sub_428B60
    mov     eax, TAdynmemStructPtr
    push    0                               ; int
    add     eax, 519h
    push    offset aSavegame_0              ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FA50
    mov     edx, TAdynmemStructPtr
    push    40h
    add     edx, 519h
    push    edx
    call    sub_4A81E0
    mov     eax, TAdynmemStructPtr
    pop     esi
    or      byte ptr [eax+38A51h], 1
    pop     ecx
    retn
    sub_4931D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_493340 proc near                    ; DATA XREF: sub_4936F0+E9o

    var_34= dword ptr -34h
    arg_0= dword ptr  4

    sub     esp, 34h
    push    esi
    mov     esi, [esp+38h+arg_0]
    push    offset aMetal_1                 ; char *
    mov     eax, [esi+18h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    test    eax, eax
    jz      short loc_493388
    push    eax
    call    sub_45BA20
    push    eax
    lea     edx, [esp+3Ch+var_34]
    push    offset aD_0                     ; "%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+38h+var_34]
    push    0
    push    eax
    push    offset aMetal_2                 ; "METAL#"
    push    esi
    call    sub_4A0BF0

    loc_493388:                             ; CODE XREF: sub_493340+1Bj
    pop     esi
    add     esp, 34h
    retn    8
    sub_493340 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_493390 proc near                    ; DATA XREF: sub_4936F0+19Co

    var_34= dword ptr -34h
    arg_0= dword ptr  4

    sub     esp, 34h
    push    esi
    mov     esi, [esp+38h+arg_0]
    push    offset aEnergy_1                ; char *
    mov     eax, [esi+18h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    test    eax, eax
    jz      short loc_4933D8
    push    eax
    call    sub_45BA20
    push    eax
    lea     edx, [esp+3Ch+var_34]
    push    offset aD_0                     ; "%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+38h+var_34]
    push    0
    push    eax
    push    offset aEnergy_2                ; "ENERGY#"
    push    esi
    call    sub_4A0BF0

    loc_4933D8:                             ; CODE XREF: sub_493390+1Bj
    pop     esi
    add     esp, 34h
    retn    8
    sub_493390 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4933E0 proc near                    ; CODE XREF: sub_4934B0+1C3p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= byte ptr  4

    sub     esp, 10h
    mov     al, [esp+10h+arg_0]
    push    ebx
    push    esi
    mov     byte ptr [esp+18h+var_10], al
    lea     ecx, [esp+18h+var_10]
    push    edi
    xor     eax, eax
    push    ecx
    mov     [esp+20h+var_C], eax
    mov     [esp+20h+var_8], eax
    mov     [esp+20h+var_4], eax
    call    sub_48CA20
    push    offset aCommander_0             ; char *
    mov     eax, dword ptr [esp+20h+arg_0]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     edx, [ecx+ecx*4]
    mov     ecx, TAdynmemStructPtr
    add     ecx, eax
    lea     ebx, [ecx+edx*2+1B63h]
    call    sub_488C50
    mov     esi, [esp+1Ch+var_C]
    mov     edi, eax
    cmp     esi, [esp+1Ch+var_8]
    jz      short loc_49349B
    push    ebp

    loc_49343F:                             ; CODE XREF: sub_4933E0+B4j
    mov     edx, [esi]
    mov     eax, [edx+110h]
    and     eax, 3
    cmp     al, 2
    jz      short loc_49348B
    mov     eax, [edx+8Ah]
    test    eax, eax
    jnz     short loc_49348B
    mov     eax, [edx+86h]
    test    eax, eax
    jnz     short loc_49348B
    mov     ax, [edx+0A6h]
    mov     ebp, 1
    and     eax, 0FFFFh
    mov     ecx, eax
    and     ecx, 1Fh
    shl     ebp, cl
    shr     eax, 5
    test    [edi+eax*4], ebp
    jnz     short loc_49348B
    push    0
    push    ebx
    push    edx
    call    sub_488570

    loc_49348B:                             ; CODE XREF: sub_4933E0+6Cj
                                            ; sub_4933E0+76j ...
    mov     eax, [esp+20h+var_8]
    add     esi, 4
    cmp     esi, eax
    jnz     short loc_49343F
    mov     esi, [esp+20h+var_C]
    pop     ebp

    loc_49349B:                             ; CODE XREF: sub_4933E0+5Cj
    push    esi
    call    sub_4B4F20
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10h
    retn    4
    sub_4933E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4934B0 proc near                    ; DATA XREF: sub_4936F0+69o

    var_8= dword ptr -8
    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    or      esi, 0FFFFFFFFh
    mov     eax, [edi+18h]
    mov     ebx, [eax+4]
    mov     eax, [edi+60h]
    cmp     eax, esi
    jnz     short loc_4934F5
    push    offset aPlyrlist                ; char *
    push    ebx                             ; int
    call    sub_49FF90
    mov     ecx, [eax+0D2h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    and     word ptr [eax+37EBEh], 0FFBFh
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4934F5:                             ; CODE XREF: sub_4934B0+15j
    push    offset aMapinfo                 ; "MAPINFO"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_493513
    push    offset aSharunit                ; "SHARUNIT"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_493531

    loc_493513:                             ; CODE XREF: sub_4934B0+52j
    push    edi                             ; int
    call    sub_49FA90
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    edi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_493531:                             ; CODE XREF: sub_4934B0+61j
    push    offset byte_502AE8
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      loc_4936B2
    push    0                               ; int
    push    offset aOptions                 ; char *
    call    sub_47F1A0
    push    offset aPlyrlist                ; char *
    push    ebx                             ; int
    call    sub_49FF90
    mov     ax, [eax+0BAh]
    test    ax, ax
    jl      loc_4936DE
    movsx   edx, ax
    mov     eax, dword_51E6D0[edx*4]
    push    eax                             ; int
    call    sub_44FE40
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     esi, eax
    shl     eax, 5
    add     eax, esi
    add     edx, esi
    lea     ecx, [eax+eax*4]
    mov     eax, [edx+ecx*2+1B63h]
    test    eax, eax
    lea     ecx, [edx+ecx*2+1B63h]
    jz      loc_4936DE
    mov     al, [ecx+73h]
    cmp     al, 1
    jz      short loc_4935BB
    cmp     al, 2
    jz      short loc_4935BB
    cmp     al, 3
    jnz     loc_4936DE

    loc_4935BB:                             ; CODE XREF: sub_4934B0+FDj
                                            ; sub_4934B0+101j
    cmp     byte ptr [ecx+146h], 0Ah
    jz      loc_4936DE
    mov     edx, [ecx+27h]
    test    byte ptr [edx+9Bh], 40h
    jnz     loc_4936DE
    cmp     al, 1
    jz      short loc_4935E8
    cmp     al, 2
    jz      short loc_4935E8
    cmp     al, 3
    jnz     loc_4936DE

    loc_4935E8:                             ; CODE XREF: sub_4934B0+12Aj
                                            ; sub_4934B0+12Ej
    cmp     word ptr [ecx+144h], 0
    jnz     short loc_493600
    mov     eax, [ecx+140h]
    test    eax, eax
    jnz     loc_4936DE

    loc_493600:                             ; CODE XREF: sub_4934B0+140j
    push    1
    push    offset aMetal_1                 ; char *
    push    ebx                             ; int
    call    sub_4A0200
    push    eax
    call    sub_45BA20
    push    ecx
    mov     [esp+8+arg_0], eax
    mov     eax, TAdynmemStructPtr
    fild    [esp+8+arg_0]
    mov     cl, [eax+2A42h]
    fstp    [esp+8+var_8]
    push    esi
    push    ecx
    call    sub_464C60
    push    1
    push    offset aEnergy_1                ; char *
    push    ebx                             ; int
    call    sub_4A0200
    push    eax
    call    sub_45BA20
    mov     edx, TAdynmemStructPtr
    push    ecx
    mov     [esp+8+arg_0], eax
    fild    [esp+8+arg_0]
    mov     al, [edx+2A42h]
    fstp    [esp+8+var_8]
    push    esi
    push    eax
    call    sub_464B30
    push    offset aSharunit                ; char *
    push    edi                             ; int
    call    sub_4A0F60
    test    eax, eax
    jz      short loc_493678
    push    esi
    call    sub_4933E0

    loc_493678:                             ; CODE XREF: sub_4934B0+1C0j
    push    offset aMapinfo                 ; char *
    push    edi                             ; int
    call    sub_4A0F60
    test    eax, eax
    jz      short loc_4936DE
    mov     ecx, TAdynmemStructPtr
    push    esi
    mov     dl, [ecx+2A42h]
    push    edx
    call    sub_485420
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     cl, [eax+2A42h]
    push    ecx
    call    sub_4571C0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4936B2:                             ; CODE XREF: sub_4934B0+8Ej
    push    offset aCancel_0                ; "CANCEL"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4936D3
    push    0                               ; int
    push    offset aPrevious                ; char *
    call    sub_47F1A0
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4936D3:                             ; CODE XREF: sub_4934B0+20Fj
    cmp     [edi+60h], esi
    jz      short loc_4936DE
    push    edi
    call    sub_4AB0A0

    loc_4936DE:                             ; CODE XREF: sub_4934B0+B5j
                                            ; sub_4934B0+F2j ...
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_4934B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4936F0 proc near                    ; CODE XREF: .text:004947B4p
                                            ; .text:004964C8p

    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h

    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    sub     esp, 44h
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    push    ebx
    shl     eax, 5
    push    ebp
    push    esi
    add     eax, edx
    mov     esi, ecx
    add     esi, edx
    push    edi
    lea     eax, [eax+eax*4]
    mov     edx, [esi+eax*2+1B8Ah]
    mov     al, [edx+9Bh]
    shr     al, 6
    test    al, 1
    jnz     loc_493ACA
    push    800h
    add     ecx, 519h
    push    offset aShare_gui               ; "SHARE.GUI"
    push    ecx
    call    sub_4AA8F0
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    push    0Eh
    push    offset aMetal_1                 ; char *
    or      byte ptr [eax+37EBEh], 40h
    mov     edi, [esi+4]
    mov     dword ptr [esi+8], offset sub_4934B0
    mov     ecx, TAdynmemStructPtr
    push    edi                             ; int
    mov     [esi+0Ch], ecx
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_4937FD
    lea     edx, [eax+eax*4]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esi+4]
    lea     eax, [eax+ecx*2]
    add     edi, eax
    mov     cx, [eax+edx+19h]
    mov     [edi+142h], cx
    mov     edx, [esi+4]
    mov     ax, [eax+edx+17h]
    xor     edx, edx
    sub     ax, cx
    mov     [edi+136h], ax
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    fld     dword ptr [ecx+eax*2+1BFBh]
    call    __ftol
    push    0
    push    edi
    mov     [edi+13Ch], eax
    mov     dword ptr [edi+144h], offset sub_493340
    mov     word ptr [edi+140h], 0
    call    sub_45B9B0
    mov     ecx, TAdynmemStructPtr
    mov     [edi+14Ah], ecx

    loc_4937FD:                             ; CODE XREF: sub_4936F0+82j
    mov     edx, [esi+4]
    push    0Eh
    push    offset aEnergy_1                ; char *
    push    edx                             ; int
    call    sub_49FDF0
    mov     ebp, eax
    cmp     ebp, 0FFFFFFFFh
    jz      loc_4938B0
    mov     eax, [esi+4]
    push    offset aEnergy_1                ; char *
    push    eax                             ; int
    call    sub_4A0200
    lea     ecx, [ebp+ebp*4+0]
    mov     edi, eax
    lea     edx, [ebp+ecx*4+0]
    lea     eax, [ebp+edx*2+0]
    mov     edx, [esi+4]
    lea     ecx, [ebp+eax*4+0]
    lea     ebp, [ebp+ecx*2+0]
    mov     ax, [ebp+edx+19h]
    mov     [edi+142h], ax
    mov     ecx, [esi+4]
    mov     dx, [ebp+ecx+17h]
    sub     dx, ax
    mov     [edi+136h], dx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    fld     dword ptr [ecx+eax*2+1BEFh]
    call    __ftol
    push    0
    push    edi
    mov     [edi+13Ch], eax
    mov     dword ptr [edi+144h], offset sub_493390
    mov     word ptr [edi+140h], 0
    call    sub_45B9B0
    mov     ecx, TAdynmemStructPtr
    mov     [edi+14Ah], ecx

    loc_4938B0:                             ; CODE XREF: sub_4936F0+122j
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [eax+2A3Ch]
    imul    edx, 1Eh
    push    edx
    push    offset aPlayers_0               ; "PLAYERS"
    call    sub_4D83B0
    mov     [esp+64h+var_40], eax
    mov     ebx, eax
    mov     byte ptr [eax], 0
    mov     esi, TAdynmemStructPtr
    mov     ecx, 0Ah
    or      eax, 0FFFFFFFFh
    mov     edi, offset dword_51E6D0
    add     esp, 8
    rep stosd
    xor     ecx, ecx
    mov     dword ptr [esp+14h], offset dword_51E6D0
    mov     [esp+10h], ecx
    mov     [esp+5Ch+var_44], ecx

    loc_4938FF:                             ; CODE XREF: sub_4936F0+2CAj
    mov     eax, [esi+ecx+1B63h]
    lea     edx, [esi+ecx+1B63h]
    test    eax, eax
    jz      loc_4939AA
    mov     al, [edx+73h]
    cmp     al, 1
    jz      short loc_493928
    cmp     al, 2
    jz      short loc_493928
    cmp     al, 3
    jnz     loc_4939AA

    loc_493928:                             ; CODE XREF: sub_4936F0+22Aj
                                            ; sub_4936F0+22Ej
    cmp     byte ptr [edx+146h], 0Ah
    jz      short loc_4939AA
    cmp     word ptr [edx+144h], 0
    jnz     short loc_493945
    mov     edi, [edx+140h]
    test    edi, edi
    jnz     short loc_4939AA

    loc_493945:                             ; CODE XREF: sub_4936F0+249j
    cmp     al, 1
    jz      short loc_4939AA
    mov     eax, [edx+27h]
    test    byte ptr [eax+9Bh], 40h
    jnz     short loc_4939AA
    lea     ebp, [edx+2Bh]
    or      ecx, 0FFFFFFFFh
    mov     edi, ebp
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+14h]
    mov     esi, TAdynmemStructPtr
    not     ecx
    dec     ecx
    lea     ebx, [ebx+ecx+1]
    mov     ecx, [edx+4]
    mov     edx, [esp+10h]
    mov     [eax], ecx
    mov     ecx, [esp+5Ch+var_44]
    inc     edx
    add     eax, 4
    mov     [esp+10h], edx
    mov     [esp+14h], eax

    loc_4939AA:                             ; CODE XREF: sub_4936F0+21Fj
                                            ; sub_4936F0+232j ...
    add     ecx, 14Bh
    cmp     ecx, 0CEEh
    mov     [esp+5Ch+var_44], ecx
    jl      loc_4938FF
    mov     eax, [esp+10h]
    test    eax, eax
    jnz     short loc_4939DC
    add     esi, 519h
    push    esi
    call    sub_4A9660
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn
    ; ---------------------------------------------------------------------------

    loc_4939DC:                             ; CODE XREF: sub_4936F0+2D6j
    mov     edx, [esp+5Ch+var_40]
    push    0
    push    eax
    push    edx
    add     esi, 519h
    push    offset aPlyrlist                ; "PLYRLIST"
    push    esi
    call    sub_4A32A0
    mov     eax, TAdynmemStructPtr
    push    offset aMetal_1                 ; char *
    mov     ecx, [eax+531h]
    lea     esi, [eax+519h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_4A0200
    test    eax, eax
    jz      short loc_493A43
    push    eax
    call    sub_45BA20
    push    eax
    lea     eax, [esp+60h+var_3C]
    push    offset aD_0                     ; "%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+5Ch+var_3C]
    push    0
    push    ecx
    push    offset aMetal_2                 ; "METAL#"
    push    esi
    call    sub_4A0BF0

    loc_493A43:                             ; CODE XREF: sub_4936F0+326j
    mov     edx, TAdynmemStructPtr
    push    offset aEnergy_1                ; char *
    mov     eax, [edx+531h]
    lea     esi, [edx+519h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4A0200
    test    eax, eax
    jz      short loc_493A92
    push    eax
    call    sub_45BA20
    push    eax
    lea     edx, [esp+60h+var_3C]
    push    offset aD_0                     ; "%d"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+5Ch+var_3C]
    push    0
    push    eax
    push    offset aEnergy_2                ; "ENERGY#"
    push    esi
    call    sub_4A0BF0

    loc_493A92:                             ; CODE XREF: sub_4936F0+375j
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_49FA90
    mov     edx, TAdynmemStructPtr
    push    1
    add     edx, 519h
    push    edx
    call    sub_49FB10
    mov     eax, TAdynmemStructPtr
    push    40h
    add     eax, 519h
    push    eax
    call    sub_4A81E0

    loc_493ACA:                             ; CODE XREF: sub_4936F0+35j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn
    sub_4936F0 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_493AE0 proc near                    ; CODE XREF: sub_493BF0+1A6p
                                            ; sub_494050+165p

    var_34= byte ptr -34h

    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    sub     esp, 34h
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    push    ebp
    shl     eax, 5
    add     eax, edx
    add     ecx, edx
    push    esi
    push    edi
    lea     eax, [eax+eax*4]
    xor     esi, esi
    xor     edi, edi
    lea     ebp, [ecx+eax*2+1C6Bh]

    loc_493B0B:                             ; CODE XREF: sub_493AE0+E8j
    push    esi
    lea     ecx, [esp+44h+var_34]
    push    offset aPlayerD                 ; "PLAYER%d"
    push    ecx
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     edx, [esp+40h+var_34]
    add     eax, 519h
    push    0                               ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    mov     al, [ecx+edi+1BD6h]
    test    al, al
    jz      short loc_493BBA
    cmp     al, 4
    jz      short loc_493BBA
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    cmp     esi, edx
    jz      short loc_493BBA
    push    esi
    lea     eax, [esp+44h+var_34]
    push    offset aLiveplyrD               ; "LIVEPLYR%d"
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    add     esp, 0Ch
    xor     eax, eax
    mov     cl, [edx+2BF0h]
    cmp     ecx, 3                          ; switch 4 cases
    ja      short loc_493BA8                ; default
    jmp     ds:off_493BD8[ecx*4]            ; switch jump

    loc_493B85:                             ; DATA XREF: .text:00493BD8o
    xor     eax, eax                        ; case 0x1
    mov     al, [ebp+0]
    jmp     short loc_493BA8                ; default
    ; ---------------------------------------------------------------------------

    loc_493B8C:                             ; CODE XREF: sub_493AE0+9Ej
                                            ; DATA XREF: .text:00493BD8o
    mov     cl, [ebp+0]                     ; case 0x2
    xor     eax, eax
    test    cl, cl
    setz    al
    jmp     short loc_493BA8                ; default
    ; ---------------------------------------------------------------------------

    loc_493B98:                             ; CODE XREF: sub_493AE0+9Ej
                                            ; DATA XREF: .text:00493BD8o
    mov     eax, 1                          ; case 0x0
    jmp     short loc_493BA8                ; default
    ; ---------------------------------------------------------------------------

    loc_493B9F:                             ; CODE XREF: sub_493AE0+9Ej
                                            ; DATA XREF: .text:00493BD8o
    xor     eax, eax                        ; case 0x3
    mov     al, [edx+esi+2BF1h]

    loc_493BA8:                             ; CODE XREF: sub_493AE0+9Cj
                                            ; sub_493AE0+AAj ...
    lea     ecx, [esp+40h+var_34]           ; default
    push    eax                             ; char
    add     edx, 519h
    push    ecx                             ; char *
    push    edx                             ; int
    call    sub_4A1080

    loc_493BBA:                             ; CODE XREF: sub_493AE0+64j
                                            ; sub_493AE0+68j ...
    inc     esi
    add     edi, 14Bh
    inc     ebp
    cmp     edi, 0CEEh
    jl      loc_493B0B
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 34h
    retn
    sub_493AE0 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_493BD8 dd offset loc_493B98         ; DATA XREF: sub_493AE0+9Er
    dd offset loc_493B85                    ; jump table for switch statement
    dd offset loc_493B8C
    dd offset loc_493B9F
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_493BF0 proc near                    ; DATA XREF: sub_494050+D0o

    var_244= dword ptr -244h
    var_240= dword ptr -240h
    var_23C= dword ptr -23Ch
    var_238= dword ptr -238h
    var_234= word ptr -234h
    var_230= dword ptr -230h
    String1= byte ptr -22Ch
    var_12C= dword ptr -12Ch
    arg_0= dword ptr  4

    sub     esp, 244h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+254h+arg_0]
    mov     eax, [edi+18h]
    mov     ebx, [eax+4]
    mov     eax, [edi+60h]
    cmp     eax, 0FFFFFFFFh
    mov     [esp+254h+var_240], ebx
    jnz     short loc_493C2E
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+37EBEh], 0FFFBh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 244h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_493C2E:                             ; CODE XREF: sub_493BF0+21j
    lea     ecx, ds:0[eax*8]
    push    8                               ; size_t
    sub     ecx, eax
    push    offset aLiveplyr                ; char *
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     edx, [ebx+eax]
    lea     eax, [edx+ecx*2+2]
    push    eax                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_493CDA
    push    eax                             ; int
    push    offset aSmallbutton             ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     byte ptr [ecx+2BF0h], 3
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+2BF0h]
    push    edx                             ; char
    push    offset aSendtype                ; char *
    push    edi                             ; int
    call    sub_4A1080
    mov     eax, [edi+60h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    lea     eax, [edx+ecx*2+0Ah]
    push    eax                             ; char *
    call    _atoi
    mov     ecx, [edi+60h]
    add     esp, 4
    mov     esi, eax
    push    ecx
    push    edi
    call    sub_4A0FF0
    mov     edx, TAdynmemStructPtr
    push    edi                             ; int
    mov     [edx+esi+2BF1h], al
    call    sub_49FA90
    push    edi
    call    sub_4AB0A0
    jmp     loc_494003
    ; ---------------------------------------------------------------------------

    loc_493CDA:                             ; CODE XREF: sub_493BF0+69j
    push    offset aSendto                  ; "SENDTO"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_493D4F
    push    0                               ; int
    push    offset aSmallbutton             ; char *
    call    sub_47F1A0
    mov     eax, [edi+60h]
    push    eax
    push    edi
    call    sub_4A0FF0
    mov     ecx, TAdynmemStructPtr
    and     al, 1
    xor     ebx, ebx
    push    offset dword_51E788             ; int
    mov     dx, [ecx+2BEEh]
    mov     bh, al
    and     edx, 0FEFFh
    push    offset aTalk                    ; char *
    or      edx, ebx
    push    edi                             ; int
    mov     [ecx+2BEEh], dx
    call    sub_4A0D00
    push    edi
    call    sub_4A9660
    call    sub_494050
    push    edi
    call    sub_4AB0A0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 244h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_493D4F:                             ; CODE XREF: sub_493BF0+F7j
    push    offset aSendtype                ; "SENDTYPE"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_493DA6
    push    0                               ; int
    push    offset aSmallbutton             ; char *
    call    sub_47F1A0
    push    offset aSendtype                ; char *
    push    edi                             ; int
    call    sub_4A0F60
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2BF0h], al
    mov     eax, TAdynmemStructPtr
    cmp     byte ptr [eax+2BF0h], 4
    jb      short loc_493D96
    mov     byte ptr [eax+2BF0h], 0

    loc_493D96:                             ; CODE XREF: sub_493BF0+19Dj
    call    sub_493AE0
    push    edi
    call    sub_4AB0A0
    jmp     loc_494003
    ; ---------------------------------------------------------------------------

    loc_493DA6:                             ; CODE XREF: sub_493BF0+16Cj
    push    offset aTalk                    ; "TALK"
    push    edi
    call    sub_49FD60
    test    eax, eax
    jz      loc_494003
    push    offset aTalk                    ; char *
    push    ebx                             ; int
    call    sub_4A0010
    mov     edx, TAdynmemStructPtr
    add     eax, 0B6h
    push    100h                            ; iMaxLength
    xor     ecx, ecx
    mov     cl, [edx+2BF0h]
    push    eax                             ; lpString2
    lea     eax, [esp+25Ch+String1]
    mov     [esp+25Ch+var_244], ecx
    push    eax                             ; lpString1
    call    ds:lstrcpynA
    lea     esi, [esp+254h+String1]
    mov     al, [esp+254h+String1]
    test    al, al
    jz      short loc_493E04

    loc_493DF8:                             ; CODE XREF: sub_493BF0+212j
    cmp     al, 20h
    jnz     short loc_493E04
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_493DF8

    loc_493E04:                             ; CODE XREF: sub_493BF0+206j
                                            ; sub_493BF0+20Aj
    cmp     byte ptr [esi], 2Bh
    jnz     short loc_493E51
    mov     ecx, TAdynmemStructPtr
    mov     eax, 1
    mov     dl, [ecx+37F2Fh]
    shr     dl, 1
    test    al, dl
    jz      short loc_493E25
    mov     eax, 7

    loc_493E25:                             ; CODE XREF: sub_493BF0+22Ej
    mov     ecx, dword_5091CC
    test    ecx, ecx
    jz      short loc_493E31
    or      al, 2

    loc_493E31:                             ; CODE XREF: sub_493BF0+23Dj
    push    eax                             ; access
    lea     eax, [esi+1]
    push    eax                             ; Command
    call    InterpretCommand
    mov     ecx, [edi+18h]
    test    al, 2
    mov     edx, [ecx+4]
    mov     [esp+254h+var_240], edx
    jz      short loc_493E51
    mov     [esp+254h+var_244], 0

    loc_493E51:                             ; CODE XREF: sub_493BF0+217j
                                            ; sub_493BF0+257j
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_493FE1
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    xor     ebx, ebx
    mov     edi, edx
    mov     cl, [edx+2A42h]
    mov     bl, [edx+2BF0h]
    mov     eax, ecx
    add     edi, ecx
    shl     eax, 5
    add     eax, ecx
    add     edx, 2BF1h
    xor     ebp, ebp
    lea     eax, [eax+eax*4]
    lea     ecx, [edi+eax*2+1B63h]
    mov     eax, [edx]
    mov     [esp+254h+var_230], ecx
    mov     [esp+254h+var_23C], eax
    mov     ecx, [edx+4]
    mov     al, [esi+1]
    cmp     al, 20h
    mov     [esp+254h+var_238], ecx
    mov     dx, [edx+8]
    mov     [esp+254h+var_234], dx
    jle     loc_493F86
    movsx   eax, al
    push    eax                             ; int
    push    offset asc_5093F4               ; char *
    call    _strchr
    add     esp, 8
    test    eax, eax
    jz      loc_493F86
    movsx   ecx, byte ptr [esi]
    push    ecx                             ; int
    call    _isdigit
    add     esp, 4
    test    eax, eax
    movsx   eax, byte ptr [esi]
    jz      short loc_493F54
    sub     eax, 30h
    js      loc_493FE1
    cmp     eax, 9
    jg      loc_493FE1
    mov     edx, TAdynmemStructPtr
    mov     ecx, eax
    shl     ecx, 5
    add     ecx, eax
    mov     edi, edx
    add     edi, eax
    lea     ecx, [ecx+ecx*4]
    lea     ebp, [edi+ecx*2]
    mov     ecx, [edi+ecx*2+1B67h]
    test    ecx, ecx
    jz      loc_493FE7
    add     esi, 2
    add     ebp, 1B8Eh
    xor     ecx, ecx
    add     edx, 2BF1h
    mov     [esp+254h+var_244], 3
    mov     [edx], ecx
    mov     [edx+4], ecx
    mov     [edx+8], cx
    mov     [edx+0Ah], cl
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+eax+2BF1h], 1
    jmp     short loc_493F86
    ; ---------------------------------------------------------------------------

    loc_493F54:                             ; CODE XREF: sub_493BF0+2F5j
    push    eax                             ; int
    call    _tolower
    add     esp, 4
    cmp     eax, 61h
    jz      short loc_493F76
    cmp     eax, 65h
    jnz     short loc_493F86
    mov     [esp+254h+var_244], 2
    mov     ebp, offset aEnemies            ; "Enemies"
    jmp     short loc_493F83
    ; ---------------------------------------------------------------------------

    loc_493F76:                             ; CODE XREF: sub_493BF0+370j
    mov     [esp+254h+var_244], 1
    mov     ebp, offset aAllies             ; "Allies"

    loc_493F83:                             ; CODE XREF: sub_493BF0+384j
    add     esi, 2

    loc_493F86:                             ; CODE XREF: sub_493BF0+2C5j
                                            ; sub_493BF0+2DEj ...
    mov     edx, TAdynmemStructPtr
    mov     cl, byte ptr [esp+254h+var_244]
    xor     eax, eax
    lea     edi, [esp+254h+var_12C]
    mov     [edx+2BF0h], cl
    mov     ecx, 4Bh
    rep stosd
    mov     eax, [esp+254h+var_230]
    push    ebp
    push    4
    push    esi
    push    eax
    call    ChatHandling_1
    mov     ecx, TAdynmemStructPtr
    mov     edx, [esp+254h+var_23C]
    mov     eax, [esp+254h+var_238]
    add     ecx, 2BF1h
    mov     [ecx], edx
    mov     dx, [esp+254h+var_234]
    mov     [ecx+4], eax
    mov     [ecx+8], dx
    mov     eax, TAdynmemStructPtr
    mov     [eax+2BF0h], bl

    loc_493FE1:                             ; CODE XREF: sub_493BF0+26Dj
                                            ; sub_493BF0+2FAj ...
    mov     edx, TAdynmemStructPtr

    loc_493FE7:                             ; CODE XREF: sub_493BF0+329j
    mov     ecx, 20h
    xor     eax, eax
    mov     edi, offset dword_51E788
    mov     ebx, [esp+254h+var_240]
    rep stosd
    stosb
    and     word ptr [edx+2BEEh], 0FEFFh

    loc_494003:                             ; CODE XREF: sub_493BF0+E5j
                                            ; sub_493BF0+1B1j ...
    push    3
    push    offset aTalk                    ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_49FC50
    push    3
    push    offset aTalk                    ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     edx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     ecx, [edx+531h]
    pop     ebx
    mov     [ecx+20h], eax
    add     esp, 244h
    retn    4
    sub_493BF0 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_494050 proc near                    ; CODE XREF: sub_493BF0+147p
                                            ; sub_4964FD+Bp
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    ebx
    push    esi
    mov     cl, [edx+2A42h]
    mov     esi, edx
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    push    edi
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B8Ah]
    mov     al, [ecx+9Bh]
    shr     al, 6
    test    al, 1
    jnz     loc_494215
    mov     eax, dword_51F2F0
    test    eax, eax
    jnz     short loc_4940A9
    mov     ecx, 20h
    xor     eax, eax
    mov     edi, offset dword_51E788
    mov     dword_51F2F0, 1
    rep stosd
    stosb

    loc_4940A9:                             ; CODE XREF: sub_494050+3Ej
    test    byte ptr [edx+37EBFh], 8
    jnz     loc_494215
    test    byte ptr [edx+2BEFh], 1
    jz      short loc_4940E2
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_4940DC
    mov     edx, TAdynmemStructPtr
    mov     esi, 1
    jmp     short loc_4940E4
    ; ---------------------------------------------------------------------------

    loc_4940DC:                             ; CODE XREF: sub_494050+7Dj
    mov     edx, TAdynmemStructPtr

    loc_4940E2:                             ; CODE XREF: sub_494050+6Dj
    xor     esi, esi

    loc_4940E4:                             ; CODE XREF: sub_494050+8Aj
    test    esi, esi
    mov     eax, offset aTalk2_gui          ; "TALK2.GUI"
    jnz     short loc_4940F2
    mov     eax, offset aTalk_gui           ; "TALK.GUI"

    loc_4940F2:                             ; CODE XREF: sub_494050+9Bj
    mov     ecx, esi
    neg     ecx
    sbb     ecx, ecx
    add     edx, 519h
    and     ecx, 0FFFFFF80h
    add     ecx, 880h
    push    ecx
    push    eax
    push    edx
    call    sub_4AA8F0
    mov     edi, eax
    push    0
    push    offset dword_51E788
    push    offset aTalk                    ; "TALK"
    mov     ebx, [edi+4]
    mov     dword ptr [edi+8], offset sub_493BF0
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37EBEh], 4
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4A0BF0
    mov     eax, TAdynmemStructPtr
    push    esi                             ; char
    add     eax, 519h
    push    offset aSendto                  ; char *
    push    eax                             ; int
    call    sub_4A1080
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jz      short loc_49418C
    mov     edx, TAdynmemStructPtr
    push    0                               ; int
    add     edx, 519h
    push    offset aSendto                  ; char *
    push    edx                             ; int
    call    sub_4A0570
    jmp     short loc_4941BA
    ; ---------------------------------------------------------------------------

    loc_49418C:                             ; CODE XREF: sub_494050+11Fj
    test    esi, esi
    jz      short loc_4941BA
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [eax+2BF0h]
    add     eax, 519h
    push    ecx                             ; char
    push    offset aSendtype                ; char *
    push    eax                             ; int
    call    sub_4A1080
    push    1
    call    sub_447380
    call    sub_493AE0

    loc_4941BA:                             ; CODE XREF: sub_494050+13Aj
                                            ; sub_494050+13Ej
    push    3
    push    offset aTalk                    ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_49FC50
    push    3
    push    offset aTalk                    ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    neg     esi
    sbb     esi, esi
    mov     [edi+20h], eax
    mov     eax, TAdynmemStructPtr
    and     esi, 0FFFFFF80h
    mov     [edi+0Ch], eax
    mov     ecx, TAdynmemStructPtr
    add     esi, 80h
    add     ecx, 519h
    or      esi, 40h
    push    esi
    push    ecx
    call    sub_4A81E0

    loc_494215:                             ; CODE XREF: sub_494050+31j
                                            ; sub_494050+60j
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_494050 endp ; sp = -8

    ; ---------------------------------------------------------------------------
    align 8
    dword_494220 dd 424448Bh, 0FF607883h, 408B2E75h, 942C6818h, 488B0050h, 45E85104h, 8B0000C0h
                                            ; DATA XREF: sub_4942E0+F0o
    dd 0BA90h, 79E85200h
    ; ---------------------------------------------------------------------------
    sub     [ebx], al

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_494246 proc near                    ; DATA XREF: .data:00503928o
    add     byte ptr TAdynmemStructPtr[ecx], ah
    and     word ptr [eax+37EBEh], 0F7FFh
    retn    4
    sub_494246 endp

    ; ---------------------------------------------------------------------------
    push    offset aDone                    ; "DONE"
    push    eax
    call    sub_49FD60
    test    eax, eax
    jz      short loc_494276
    push    0
    push    offset aSmlbutton               ; "smlbutton"
    call    sub_47F1A0
    retn    4
    ; ---------------------------------------------------------------------------

    loc_494276:                             ; CODE XREF: .text:00494265j
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4AB0A0
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_494290 proc near                    ; DATA XREF: sub_4942E0+11Fo

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    esi
    mov     esi, [esp+14h+arg_4]
    mov     eax, [esi+0BAh]
    test    eax, eax
    jz      short loc_4942D4
    lea     eax, [esp+14h+var_10]
    push    eax
    push    esi
    call    sub_4A1630
    mov     eax, [esi+0BAh]
    mov     ecx, [esp+14h+var_C]
    mov     edx, [esp+14h+var_10]
    push    ecx
    mov     ecx, [esp+18h+arg_0]
    push    edx
    push    eax
    mov     edx, [ecx+18h]
    mov     eax, [edx+4]
    mov     ecx, [eax+0BCh]
    push    ecx
    call    sub_4C6B70

    loc_4942D4:                             ; CODE XREF: sub_494290+10j
    pop     esi
    add     esp, 10h
    retn    8
    sub_494290 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4942E0 proc near                    ; CODE XREF: .text:00496129p

    var_12C= word ptr -12Ch
    var_128= dword ptr -128h
    var_124= dword ptr -124h
    var_120= byte ptr -120h
    var_110= byte ptr -110h
    var_100= dword ptr -100h

    mov     eax, TAdynmemStructPtr
    sub     esp, 12Ch
    mov     cx, [eax+37EBEh]
    push    ebx
    shr     ecx, 0Bh
    push    ebp
    push    esi
    test    cl, 1
    push    edi
    jnz     loc_49472E
    mov     ecx, [eax+581h]
    xor     esi, esi
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_494354
    mov     edx, [eax+531h]
    lea     eax, ds:0[ecx*8]
    sub     eax, ecx
    push    10h                             ; size_t
    mov     edx, [edx+4]
    lea     eax, [eax+eax*2]
    lea     eax, [ecx+eax*2]
    lea     eax, [ecx+eax*4]
    lea     ecx, [ecx+eax*2]
    lea     eax, [edx+ecx+2]
    lea     ecx, [esp+140h+var_120]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    lea     edx, [esp+13Ch+var_120]
    mov     [esp+13Ch+var_110], 0
    push    edx                             ; char *
    call    sub_488B10
    mov     esi, eax
    jmp     short loc_4943AA
    ; ---------------------------------------------------------------------------

    loc_494354:                             ; CODE XREF: sub_4942E0+2Dj
    mov     cx, [eax+2CBAh]
    test    cx, cx
    jz      short loc_4943AF
    and     ecx, 0FFFFh
    mov     edx, ecx
    shl     ecx, 3
    sub     ecx, edx
    mov     edx, [eax+14357h]
    lea     ecx, [ecx+ecx*4]
    lea     esi, [edx+ecx*8]
    xor     edx, edx
    mov     dl, [eax+TAdynmemStruct.LOS_Sight]
    push    esi                             ; Unit
    mov     ecx, edx
    add     eax, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    lea     edx, [eax+ecx*2+TAdynmemStruct.Players]
    push    edx                             ; Player
    call    PlayerCanSeeUnit
    test    eax, eax
    jnz     short loc_4943A3
    xor     esi, esi
    jmp     short loc_4943AA
    ; ---------------------------------------------------------------------------

    loc_4943A3:                             ; CODE XREF: sub_4942E0+BDj
    mov     si, [esi+0A6h]

    loc_4943AA:                             ; CODE XREF: sub_4942E0+72j
                                            ; sub_4942E0+C1j
    mov     eax, TAdynmemStructPtr

    loc_4943AF:                             ; CODE XREF: sub_4942E0+7Ej
    test    si, si
    jz      loc_49472E
    push    1000h
    add     eax, 519h
    push    offset aUnitinfox_gui           ; "UNITINFOx.GUI"
    push    eax
    call    sub_4AA8F0
    mov     edi, [eax+4]
    mov     dword ptr [eax+8], offset dword_494220
    mov     ecx, TAdynmemStructPtr
    push    offset aHotr                    ; char *
    push    edi                             ; int
    mov     [eax+0Ch], ecx
    call    sub_4A0280
    and     esi, 0FFFFh
    mov     ebp, eax
    mov     eax, esi
    push    offset aPcx                     ; "PCX"
    shl     eax, 6
    add     eax, esi
    mov     dword ptr [ebp+0B6h], offset sub_494290
    lea     edx, [eax+eax*8]
    mov     eax, TAdynmemStructPtr
    mov     ebx, [eax+1439Bh]
    add     ebx, edx
    lea     edx, [esp+140h+var_100]
    lea     ecx, [ebx+20h]
    push    ecx
    push    offset aUnitpics                ; "unitpics"
    push    edx
    call    sub_4290F0
    lea     eax, [esp+13Ch+var_100]
    push    0
    push    eax
    call    sub_4CAF30
    push    ebx
    mov     [ebp+0BAh], eax
    call    sub_489280
    movsx   esi, word ptr [edi+0B6h]
    push    2                               ; int
    push    0FFFFFFFFh                      ; int
    push    20h                             ; __int16
    push    82h                             ; int
    push    offset aCost                    ; int
    mov     [esp+150h+var_128], eax
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char *
    push    offset aText_0                  ; int
    mov     edx, [ecx+531h]
    push    edx                             ; int
    call    sub_4AB1B0
    inc     esi
    push    2                               ; int
    mov     eax, esi
    push    0FFFFFFFFh                      ; int
    shl     eax, 3
    sub     eax, esi
    push    2Fh                             ; __int16
    mov     ebp, 411h
    push    8Ch                             ; int
    lea     eax, [eax+eax*2]
    push    offset aEnergy                  ; int
    lea     ecx, [esi+eax*2]
    mov     eax, edi
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     [eax+edx*2+1Bh], ebp
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char *
    push    offset aText_0                  ; int
    mov     edx, [ecx+531h]
    push    edx                             ; int
    call    sub_4AB1B0
    inc     esi
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, edi
    lea     edx, [esi+ecx*4]
    push    2                               ; int
    push    0FFFFFFFFh                      ; int
    add     eax, esi
    push    3Eh                             ; __int16
    push    8Ch                             ; int
    push    offset aMetal                   ; int
    mov     [eax+edx*2+1Bh], ebp
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char *
    push    offset aText_0                  ; int
    mov     edx, [ecx+531h]
    push    edx                             ; int
    call    sub_4AB1B0
    inc     esi
    push    2                               ; int
    mov     eax, esi
    push    0FFFFFFFFh                      ; int
    shl     eax, 3
    sub     eax, esi
    push    4Dh                             ; __int16
    push    8Ch                             ; int
    push    offset aBuildTime               ; int
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, edi
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     [eax+edx*2+1Bh], ebp
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char *
    push    offset aText_0                  ; int
    mov     edx, [ecx+531h]
    push    edx                             ; int
    call    sub_4AB1B0
    inc     esi
    push    2                               ; int
    mov     eax, esi
    push    0FFFFFFFFh                      ; int
    shl     eax, 3
    sub     eax, esi
    push    5Ch                             ; __int16
    push    82h                             ; int
    push    offset aStatistics              ; int
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, edi
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     [eax+edx*2+1Bh], ebp
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char *
    push    offset aText_0                  ; int
    mov     edx, [ecx+531h]
    push    edx                             ; int
    call    sub_4AB1B0
    inc     esi
    push    2                               ; int
    mov     eax, esi
    push    0FFFFFFFFh                      ; int
    shl     eax, 3
    sub     eax, esi
    push    6Bh                             ; __int16
    push    8Ch                             ; int
    push    offset aMaxVelocity             ; int
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, edi
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     [eax+edx*2+1Bh], ebp
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char *
    push    offset aText_0                  ; int
    mov     edx, [ecx+531h]
    push    edx                             ; int
    call    sub_4AB1B0
    inc     esi
    mov     eax, esi
    push    2                               ; int
    shl     eax, 3
    sub     eax, esi
    push    0FFFFFFFFh                      ; int
    push    7Ah                             ; __int16
    push    8Ch                             ; int
    lea     eax, [eax+eax*2]
    push    offset aAcceleration_0          ; int
    lea     ecx, [esi+eax*2]
    mov     eax, edi
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     [eax+edx*2+1Bh], ebp
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char *
    push    offset aText_0                  ; int
    mov     edx, [ecx+531h]
    push    edx                             ; int
    call    sub_4AB1B0
    inc     esi
    push    2                               ; int
    mov     eax, esi
    push    0FFFFFFFFh                      ; int
    shl     eax, 3
    sub     eax, esi
    push    89h                             ; __int16
    push    8Ch                             ; int
    push    offset aTurnRate                ; int
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, edi
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     [eax+edx*2+1Bh], ebp
    call    sub_4C5740
    mov     ecx, TAdynmemStructPtr
    push    eax                             ; char *
    push    offset aText_0                  ; int
    mov     edx, [ecx+531h]
    push    edx                             ; int
    call    sub_4AB1B0
    inc     esi
    mov     eax, esi
    add     edi, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    lea     edx, [esi+ecx*4]
    mov     esi, [esp+13Ch+var_128]
    lea     edi, [edi+edx*2+1Bh]
    mov     [edi], ebp
    mov     al, [esi]
    test    al, al
    jz      short loc_4946F8
    mov     dword ptr [esp+13Ch+var_12C], 20h
    jmp     short loc_49469F
    ; ---------------------------------------------------------------------------

    loc_49469B:                             ; CODE XREF: sub_4942E0+412j
    mov     edi, [esp+13Ch+var_124]

    loc_49469F:                             ; CODE XREF: sub_4942E0+3B9j
    mov     eax, dword ptr [esp+13Ch+var_12C]
    mov     ecx, TAdynmemStructPtr
    push    2                               ; int
    push    0FFFFFFFFh                      ; int
    mov     edx, [ecx+531h]
    push    eax                             ; __int16
    push    0F0h                            ; int
    push    esi                             ; char *
    push    offset aText_0                  ; int
    push    edx                             ; int
    call    sub_4AB1B0
    add     edi, 15Bh
    or      ecx, 0FFFFFFFFh
    mov     [esp+13Ch+var_124], edi
    xor     eax, eax
    mov     [edi], ebp
    mov     edi, esi
    repne scasb
    not     ecx
    dec     ecx
    mov     al, [esi+ecx+1]
    lea     esi, [esi+ecx+1]
    mov     ecx, dword ptr [esp+13Ch+var_12C]
    add     ecx, 0Fh
    test    al, al
    mov     dword ptr [esp+13Ch+var_12C], ecx
    jnz     short loc_49469B
    mov     esi, [esp+13Ch+var_128]

    loc_4946F8:                             ; CODE XREF: sub_4942E0+3AFj
    push    esi                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    add     eax, 519h
    push    80h
    push    ebx
    push    offset aName_0                  ; "NAME"
    push    eax
    call    sub_4A0BF0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx                             ; int
    call    sub_49FA90

    loc_49472E:                             ; CODE XREF: sub_4942E0+1Cj
                                            ; sub_4942E0+D2j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 12Ch
    retn
    sub_4942E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    loc_494740:                             ; DATA XREF: sub_495010+94o
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_494763
    mov     eax, TAdynmemStructPtr
    push    esi
    and     word ptr [eax+2BEEh], 0FF1Fh
    call    sub_49FA70
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_494763:                             ; CODE XREF: .text:00494749j
    push    offset aOptions_1               ; "OPTIONS"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_494799
    mov     eax, TAdynmemStructPtr
    push    0
    push    offset aBigbutton               ; "BigButton"
    or      byte ptr [eax+37EBEh], 1
    call    sub_47F1A0
    call    sub_460CC0
    push    esi
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_494799:                             ; CODE XREF: .text:00494770j
    push    offset aShare                   ; "SHARE"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4947C3
    push    0
    push    offset aBigbutton               ; "BigButton"
    call    sub_47F1A0
    call    sub_4936F0
    push    esi
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4947C3:                             ; CODE XREF: .text:004947A6j
    push    offset aControl                 ; "CONTROL"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_4947ED
    push    0
    push    offset aBigbutton               ; "BigButton"
    call    sub_47F1A0
    call    sub_4466B0
    push    esi
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4947ED:                             ; CODE XREF: .text:004947D0j
    push    offset aAllies_0                ; "ALLIES"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_494817
    push    0
    push    offset aBigbutton               ; "BigButton"
    call    sub_47F1A0
    call    sub_4478B0
    push    esi
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_494817:                             ; CODE XREF: .text:004947FAj
    push    offset aCancel_0                ; "CANCEL"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jz      short loc_494830
    push    esi
    call    sub_4A9660
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_494830:                             ; CODE XREF: .text:00494824j
    push    esi
    call    sub_4AB0A0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+8]
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     short loc_49486D
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+2BEEh], 0FF1Fh
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA70
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49486D:                             ; CODE XREF: .text:00494849j
    push    offset aCancel_0                ; "CANCEL"
    push    esi
    call    sub_49FD60
    test    eax, eax
    jnz     short loc_494882
    push    esi
    call    sub_4AB0A0

    loc_494882:                             ; CODE XREF: .text:0049487Aj
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    loc_494890:                             ; DATA XREF: .text:00495219o
                                            ; sub_497180+A4Bo
    mov     eax, [esp+4]
    cmp     dword ptr [eax+60h], 0FFFFFFFFh
    jz      short locret_4948A0
    push    eax
    call    sub_4AB0A0

    locret_4948A0:                          ; CODE XREF: .text:00494898j
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4948B0 proc near                    ; CODE XREF: sub_4866D0+5C9p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     cl, 1Eh
    test    eax, eax
    jl      short loc_4948C0
    mov     byte ptr dword_51F2C8[eax], cl

    loc_4948C0:                             ; CODE XREF: sub_4948B0+8j
    mov     eax, [esp+arg_4]
    test    eax, eax
    jl      short locret_4948CE
    mov     byte ptr dword_51E810[eax], cl

    locret_4948CE:                          ; CODE XREF: sub_4948B0+16j
    retn    8
    sub_4948B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4948E0 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+1275p

    var_D0= dword ptr -0D0h
    var_CC= dword ptr -0CCh
    var_C8= dword ptr -0C8h
    var_C4= dword ptr -0C4h
    var_C0= dword ptr -0C0h
    var_BC= dword ptr -0BCh
    var_B8= dword ptr -0B8h
    var_B4= dword ptr -0B4h
    var_B0= dword ptr -0B0h
    var_AC= dword ptr -0ACh
    var_A8= dword ptr -0A8h
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    arg_0= dword ptr  4

    sub     esp, 0D0h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6340
    cmp     dword_51F2F4, eax
    jge     short loc_494930
    call    sub_4B6340
    inc     eax
    mov     dword_51F2F4, eax
    xor     eax, eax

    loc_494904:                             ; CODE XREF: sub_4948E0+4Ej
    mov     cl, byte ptr dword_51F2C8[eax]
    test    cl, cl
    jbe     short loc_494917
    sub     cl, 2
    mov     byte ptr dword_51F2C8[eax], cl

    loc_494917:                             ; CODE XREF: sub_4948E0+2Cj
    mov     cl, byte ptr dword_51E810[eax]
    test    cl, cl
    jbe     short loc_49492A
    sub     cl, 2
    mov     byte ptr dword_51E810[eax], cl

    loc_49492A:                             ; CODE XREF: sub_4948E0+3Fj
    inc     eax
    cmp     eax, 0Ah
    jl      short loc_494904

    loc_494930:                             ; CODE XREF: sub_4948E0+15j
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37F06h], 80h
    jnz     loc_4949E5
    push    20h
    call    sub_4C1B80
    test    eax, eax
    jz      short loc_494986
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+57Dh]
    cmp     eax, 0FFFFFFFFh
    jz      loc_4949E5
    mov     edx, [ecx+531h]
    lea     ecx, ds:0[eax*8]
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [eax+ecx*2]
    mov     ecx, [edx+4]
    cmp     byte ptr [ecx+eax], 3
    jnz     short loc_4949E5

    loc_494986:                             ; CODE XREF: sub_4948E0+6Bj
    mov     ecx, dword_51F2D8
    test    ecx, ecx
    jle     loc_494E5D
    cmp     ecx, 7Dh
    jnz     short loc_4949AB
    push    0                               ; int
    push    offset aPanel                   ; char *
    call    sub_47F1A0
    mov     ecx, dword_51F2D8

    loc_4949AB:                             ; CODE XREF: sub_4948E0+B7j
    mov     eax, ecx
    mov     esi, 1
    cdq
    and     edx, 3
    add     eax, edx
    sar     eax, 2
    cmp     eax, esi
    jg      short loc_4949C1
    mov     eax, esi

    loc_4949C1:                             ; CODE XREF: sub_4948E0+DDj
    sub     ecx, eax
    test    ecx, ecx
    mov     dword_51F2D8, ecx
    jg      short loc_494A47
    push    0                               ; int
    push    offset aOptions                 ; char *
    mov     dword_51F2D8, 0
    call    sub_47F1A0
    jmp     short loc_494A47
    ; ---------------------------------------------------------------------------

    loc_4949E5:                             ; CODE XREF: sub_4948E0+5Cj
                                            ; sub_4948E0+7Cj ...
    mov     ecx, dword_51F2D8
    cmp     ecx, 7Dh
    jge     short loc_494A42
    test    ecx, ecx
    jnz     short loc_494A05
    push    ecx                             ; int
    push    offset aPanel                   ; char *
    call    sub_47F1A0
    mov     ecx, dword_51F2D8

    loc_494A05:                             ; CODE XREF: sub_4948E0+112j
    mov     eax, 7Dh
    sub     eax, ecx
    cdq
    and     edx, 3
    add     eax, edx
    sar     eax, 2
    cmp     eax, 1
    jg      short loc_494A1F
    mov     eax, 1

    loc_494A1F:                             ; CODE XREF: sub_4948E0+138j
    add     ecx, eax
    cmp     ecx, 7Dh
    mov     dword_51F2D8, ecx
    jl      short loc_494A42
    push    0                               ; int
    push    offset aOptions                 ; char *
    mov     dword_51F2D8, 7Dh
    call    sub_47F1A0

    loc_494A42:                             ; CODE XREF: sub_4948E0+10Ej
                                            ; sub_4948E0+14Aj
    mov     esi, 1

    loc_494A47:                             ; CODE XREF: sub_4948E0+EBj
                                            ; sub_4948E0+103j
    call    sub_4B6700
    mov     ecx, dword_51F2D8
    mov     edx, TAdynmemStructPtr
    sub     eax, ecx
    mov     ebp, [esp+0E0h+arg_0]
    mov     [esp+0E0h+var_C8], eax
    add     eax, 7Dh
    mov     [esp+0E0h+var_C0], eax
    xor     eax, eax
    mov     [esp+0E0h+var_C4], 20h
    mov     ax, [edx+2A3Ch]
    lea     edx, [esp+0E0h+var_C8]
    push    0FFFFFFE8h
    lea     eax, [eax+eax*4]
    push    edx
    push    ebp
    lea     ecx, ds:2Eh[eax*8]
    mov     [esp+0ECh+var_BC], ecx
    call    sub_4BF4D0
    mov     ebx, [esp+0E0h+var_C4]
    push    offset aKills                   ; int
    mov     ecx, [esp+0E4h+var_C8]
    mov     [esp+0E4h+var_84], esi
    mov     [esp+0E4h+var_80], esi
    mov     [esp+0E4h+var_6C], esi
    lea     eax, [ecx+7Dh]
    mov     [esp+0E4h+var_78], esi
    mov     [esp+0E4h+var_C0], eax
    sub     eax, ecx
    sub     eax, 6
    mov     [esp+0E4h+var_D0], eax
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0E0h+var_64]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, [esp+0E4h+var_C8]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    add     edx, 2
    and     ecx, 3
    lea     eax, [esp+0E4h+var_64]
    rep movsb
    mov     ecx, [esp+0E4h+var_D0]
    push    ecx
    push    ebx
    push    edx
    push    eax
    push    ebp
    call    sub_4A50E0
    push    offset aLosses                  ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0E0h+var_64]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+0E4h+var_64]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+0E4h+var_D0]
    push    ecx
    push    ebx
    push    edx
    call    sub_4A5030
    lea     edx, [esp+0ECh+var_64]
    mov     ecx, [esp+0ECh+var_C0]
    sub     ecx, eax
    sub     ecx, 2
    push    ecx
    push    edx
    push    ebp
    call    sub_4A50E0
    mov     edx, TAdynmemStructPtr
    add     ebx, 0Fh
    mov     [esp+0E0h+var_CC], 0
    cmp     word ptr [edx+2A3Ch], 0
    jbe     loc_494E5D

    loc_494B84:                             ; CODE XREF: sub_4948E0+577j
    mov     ecx, [esp+0E0h+var_C8]
    lea     esi, [edx+1B63h]
    lea     eax, [ecx+7]
    mov     [esp+0E0h+var_9C], eax
    mov     [esp+0E0h+var_B4], eax
    mov     eax, [esp+0E0h+var_D0]
    add     eax, ecx
    xor     edi, edi
    mov     [esp+0E0h+var_AC], eax
    mov     [esp+0E0h+var_A4], eax
    lea     eax, [ebx+1]
    mov     [esp+0E0h+var_A8], eax
    mov     [esp+0E0h+var_B0], eax
    lea     eax, [ebx+25h]
    mov     [esp+0E0h+var_98], eax
    mov     [esp+0E0h+var_A0], eax

    loc_494BBF:                             ; CODE XREF: sub_4948E0+336j
    cmp     dword ptr [esi], 0
    jz      short loc_494C0C
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_494BD3
    cmp     al, 2
    jz      short loc_494BD3
    cmp     al, 3
    jnz     short loc_494C0C

    loc_494BD3:                             ; CODE XREF: sub_4948E0+2E9j
                                            ; sub_4948E0+2EDj
    cmp     byte ptr [esi+146h], 0Ah
    jz      short loc_494C0C
    cmp     word ptr [esi+144h], 0
    jnz     short loc_494BF0
    mov     eax, [esi+140h]
    test    eax, eax
    jnz     short loc_494C0C

    loc_494BF0:                             ; CODE XREF: sub_4948E0+304j
    mov     ecx, [esi+27h]
    test    byte ptr [ecx+9Bh], 40h
    jnz     short loc_494C0C
    mov     ecx, [esp+0E0h+var_CC]
    xor     eax, eax
    mov     al, [esi+148h]
    cmp     eax, ecx
    jz      short loc_494C1D

    loc_494C0C:                             ; CODE XREF: sub_4948E0+2E2j
                                            ; sub_4948E0+2F1j ...
    inc     edi
    add     esi, 14Bh
    cmp     edi, 0Ah
    jl      short loc_494BBF
    jmp     loc_494DC0
    ; ---------------------------------------------------------------------------

    loc_494C1D:                             ; CODE XREF: sub_4948E0+32Aj
    mov     ecx, [esp+0E0h+var_C8]
    mov     eax, [esp+0E0h+var_C0]
    add     ecx, 4
    add     eax, 0FFFFFFFCh
    mov     [esp+0E0h+var_94], ecx
    lea     ecx, [ebx-1]
    mov     [esp+0E0h+var_8C], eax
    mov     [esp+0E0h+var_90], ecx
    lea     eax, [ebx+26h]
    xor     ecx, ecx
    mov     [esp+0E0h+var_88], eax
    mov     cl, [edx+2A42h]
    cmp     edi, ecx
    jnz     short loc_494C6D
    lea     edx, [esp+0E0h+var_94]
    push    1Fh
    push    edx
    push    ebp
    call    sub_4BF4D0
    lea     eax, [esp+0E0h+var_94]
    push    14h
    push    eax
    push    ebp
    call    sub_4BF4D0
    mov     edx, TAdynmemStructPtr

    loc_494C6D:                             ; CODE XREF: sub_4948E0+36Bj
    mov     ecx, [esi+27h]
    xor     eax, eax
    mov     al, [ecx+96h]
    mov     ecx, [edx+148DBh]
    push    eax
    push    ecx
    call    sub_4B7F30
    xor     edx, edx
    xor     ecx, ecx
    mov     dx, [eax]
    dec     edx
    mov     [esp+0E0h+var_7C], edx
    mov     cx, [eax]
    dec     ecx
    xor     edx, edx
    mov     [esp+0E0h+var_74], ecx
    mov     dx, [eax+2]
    dec     edx
    xor     ecx, ecx
    mov     [esp+0E0h+var_70], edx
    mov     cx, [eax+2]
    dec     ecx
    lea     edx, [esp+0E0h+var_84]
    mov     [esp+0E0h+var_68], ecx
    lea     ecx, [esp+0E0h+var_B4]
    push    edx
    push    ecx
    push    eax
    push    ebp
    call    sub_4C7580
    push    0
    mov     eax, [esp+0E4h+var_B0]
    mov     edx, [esp+0E4h+var_D0]
    mov     ecx, [esp+0E4h+var_B4]
    add     eax, 5
    push    edx
    add     ecx, 2
    push    eax
    lea     edx, [esi+2Bh]
    push    ecx
    push    edx
    push    ebp
    call    sub_4A50E0
    mov     eax, TAdynmemStructPtr
    cmp     dword ptr [eax+37EF6h], 2
    jnz     short loc_494CF8
    mov     ax, [esi+104h]
    jmp     short loc_494CFF
    ; ---------------------------------------------------------------------------

    loc_494CF8:                             ; CODE XREF: sub_4948E0+40Dj
    mov     ax, [esi+0FCh]

    loc_494CFF:                             ; CODE XREF: sub_4948E0+416j
    movsx   ecx, ax
    push    ecx
    lea     edx, [esp+0E4h+var_64]
    push    offset aD_0                     ; "%d"
    push    edx
    call    _sprintf
    mov     edx, [esp+0ECh+var_B0]
    mov     ecx, [esp+0ECh+var_D0]
    xor     eax, eax
    add     esp, 0Ch
    mov     al, byte ptr dword_51F2C8[edi]
    add     edx, 14h
    push    eax
    mov     eax, [esp+0E4h+var_B4]
    push    ecx
    add     eax, 2
    push    edx
    lea     ecx, [esp+0ECh+var_64]
    push    eax
    push    ecx
    push    ebp
    call    sub_4A50E0
    mov     edx, TAdynmemStructPtr
    cmp     dword ptr [edx+37EF6h], 2
    jnz     short loc_494D5C
    mov     si, [esi+106h]
    jmp     short loc_494D63
    ; ---------------------------------------------------------------------------

    loc_494D5C:                             ; CODE XREF: sub_4948E0+471j
    mov     si, [esi+0FEh]

    loc_494D63:                             ; CODE XREF: sub_4948E0+47Aj
    movsx   eax, si
    push    eax
    lea     ecx, [esp+0E4h+var_64]
    push    offset aD_0                     ; "%d"
    push    ecx
    call    _sprintf
    mov     ecx, [esp+0ECh+var_B0]
    mov     eax, [esp+0ECh+var_D0]
    xor     edx, edx
    add     esp, 0Ch
    mov     dl, byte ptr dword_51E810[edi]
    add     ecx, 14h
    push    edx
    push    eax
    lea     edx, [esp+0E8h+var_64]
    push    ecx
    push    edx
    call    sub_4A5030
    lea     edx, [esp+0ECh+var_64]
    mov     ecx, [esp+0ECh+var_AC]
    sub     ecx, eax
    sub     ecx, 2
    push    ecx
    push    edx
    push    ebp
    call    sub_4A50E0
    mov     edx, TAdynmemStructPtr
    add     ebx, 28h

    loc_494DC0:                             ; CODE XREF: sub_4948E0+338j
    cmp     edi, 0Ah
    jnz     short loc_494E43
    lea     eax, [edx+1B63h]
    mov     [esp+0E0h+var_B8], edi

    loc_494DCF:                             ; CODE XREF: sub_4948E0+561j
    cmp     dword ptr [eax], 0
    jz      short loc_494E33
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_494DE6
    cmp     cl, 2
    jz      short loc_494DE6
    cmp     cl, 3
    jnz     short loc_494E33

    loc_494DE6:                             ; CODE XREF: sub_4948E0+4FAj
                                            ; sub_4948E0+4FFj
    cmp     byte ptr [eax+146h], 0Ah
    jz      short loc_494E33
    cmp     word ptr [eax+144h], 0
    jnz     short loc_494E03
    mov     ecx, [eax+140h]
    test    ecx, ecx
    jnz     short loc_494E33

    loc_494E03:                             ; CODE XREF: sub_4948E0+517j
    mov     ecx, [eax+27h]
    test    byte ptr [ecx+9Bh], 40h
    jnz     short loc_494E33
    mov     cl, [eax+148h]
    mov     edi, [esp+0E0h+var_CC]
    mov     esi, ecx
    and     esi, 0FFh
    cmp     esi, edi
    jle     short loc_494E33
    dec     cl
    mov     [eax+148h], cl
    mov     edx, TAdynmemStructPtr

    loc_494E33:                             ; CODE XREF: sub_4948E0+4F2j
                                            ; sub_4948E0+504j ...
    mov     ecx, [esp+0E0h+var_B8]
    add     eax, 14Bh
    dec     ecx
    mov     [esp+0E0h+var_B8], ecx
    jnz     short loc_494DCF

    loc_494E43:                             ; CODE XREF: sub_4948E0+4E3j
    mov     eax, [esp+0E0h+var_CC]
    xor     ecx, ecx
    mov     cx, [edx+2A3Ch]
    inc     eax
    cmp     eax, ecx
    mov     [esp+0E0h+var_CC], eax
    jl      loc_494B84

    loc_494E5D:                             ; CODE XREF: sub_4948E0+AEj
                                            ; sub_4948E0+29Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D0h
    retn    4
    sub_4948E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_494E70 proc near                    ; CODE XREF: sub_499890+111p

    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     eax, TAdynmemStructPtr
    sub     esp, 8
    mov     cl, [eax+2A44h]
    push    ebx
    push    ebp
    push    esi
    test    cl, 4
    push    edi
    jz      loc_494FDB
    test    byte ptr [eax+38D75h], 1
    jz      short loc_494EA1
    test    byte ptr [eax+38D75h], 2
    jz      loc_494FDB

    loc_494EA1:                             ; CODE XREF: sub_494E70+22j
    call    sub_4B6340
    mov     ecx, dword_51F2F8
    add     ecx, 1Eh
    cmp     eax, ecx
    jbe     loc_494FDB
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CE680
    mov     [esp+18h+var_4], eax
    mov     eax, dword_51F2FC
    inc     eax
    cmp     eax, 0Ah
    mov     dword_51F2FC, eax
    jle     loc_494FA1
    mov     ebx, dword_51F2DC
    xor     ebp, ebp
    mov     [esp+18h+var_8], ebp
    mov     edi, 5
    lea     edx, [ebx-1]
    xor     eax, eax
    lea     esi, ds:51E710h[edx*4]

    loc_494EFA:                             ; CODE XREF: sub_494E70+A7j
    test    edx, edx
    jge     short loc_494F04
    add     edx, 1Eh
    add     esi, 78h

    loc_494F04:                             ; CODE XREF: sub_494E70+8Cj
    mov     ecx, [esi]
    add     eax, ecx
    test    edi, edi
    jz      short loc_494F0F
    dec     edi
    add     ebp, ecx

    loc_494F0F:                             ; CODE XREF: sub_494E70+9Aj
    cmp     edx, ebx
    jz      short loc_494F19
    dec     edx
    sub     esi, 4
    jmp     short loc_494EFA
    ; ---------------------------------------------------------------------------

    loc_494F19:                             ; CODE XREF: sub_494E70+A1j
    mov     ecx, [esp+18h+var_4]
    mov     ebx, dword_5091D0
    mov     edi, TAdynmemStructPtr
    mov     [esp+18h+var_8], ebp
    test    ecx, ecx
    mov     esi, ebx
    jnz     short loc_494F69
    cmp     eax, 32h
    jg      short loc_494F3D
    cmp     ebp, 1Eh
    jle     short loc_494F69

    loc_494F3D:                             ; CODE XREF: sub_494E70+C6j
    xor     edx, edx
    mov     ebp, edi
    mov     dl, [edi+2A42h]
    mov     ecx, edx
    add     ebp, edx
    shl     ecx, 5
    add     ecx, edx
    lea     ecx, [ecx+ecx*4]
    cmp     word ptr [ebp+ecx*2+1CA7h], 1Eh
    jbe     short loc_494F65
    mov     esi, 1
    jmp     short loc_494F84
    ; ---------------------------------------------------------------------------

    loc_494F65:                             ; CODE XREF: sub_494E70+ECj
    mov     ebp, [esp+18h+var_8]

    loc_494F69:                             ; CODE XREF: sub_494E70+C1j
                                            ; sub_494E70+CBj
    cmp     [esp+18h+var_4], 1
    jnz     short loc_494F84
    cmp     eax, 0Ah
    jge     short loc_494F84
    test    ebp, ebp
    jnz     short loc_494F84
    cmp     dword_51F2FC, 3Ch
    jle     short loc_494F84
    xor     esi, esi

    loc_494F84:                             ; CODE XREF: sub_494E70+F3j
                                            ; sub_494E70+FEj ...
    cmp     esi, ebx
    jz      short loc_494FA1
    mov     ecx, [edi+10h]
    push    esi
    call    sub_4CE690
    mov     dword_51F2FC, 0
    mov     dword_5091D0, esi

    loc_494FA1:                             ; CODE XREF: sub_494E70+67j
                                            ; sub_494E70+116j
    mov     eax, dword_51F2DC
    inc     eax
    cmp     eax, 1Eh
    mov     dword_51F2DC, eax
    jl      short loc_494FBB
    mov     dword_51F2DC, 0

    loc_494FBB:                             ; CODE XREF: sub_494E70+13Fj
    mov     edx, dword_51F2DC
    mov     dword_51E710[edx*4], 0
    call    RIWrapper_IntervalTimer
    call    sub_4B6340
    mov     dword_51F2F8, eax

    loc_494FDB:                             ; CODE XREF: sub_494E70+15j
                                            ; sub_494E70+2Bj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    sub_494E70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_494FF0 proc near                    ; CODE XREF: sub_4866D0+31Bp
                                            ; sub_489CE0+106p

    arg_0= dword ptr  4

    mov     eax, dword_51F2DC
    mov     ecx, [esp+arg_0]
    add     dword_51E710[eax*4], ecx
    retn    4
    sub_494FF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_495010 proc near                    ; CODE XREF: .text:0049615Bp
    push    ebx
    push    esi
    push    edi
    push    0                               ; int
    push    offset aSmallbutton             ; char *
    call    sub_47F1A0
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+2BEEh]
    test    al, 0E0h
    jz      short loc_49506F
    and     eax, 0FF1Fh
    push    offset aTabmenu_gui             ; char *
    mov     [ecx+2BEEh], ax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax                             ; int
    call    sub_4AB060
    test    eax, eax
    jz      loc_4951FA
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A9660
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_49506F:                             ; CODE XREF: sub_495010+1Ej
    and     eax, 0FF3Fh
    or      al, 20h
    mov     [ecx+2BEEh], ax
    call    sub_4C2470
    mov     edx, TAdynmemStructPtr
    push    800h
    add     edx, 519h
    push    offset aTabmenu_gui             ; "TABMENU.GUI"
    push    edx
    call    sub_4AA8F0
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [eax+8], offset loc_494740
    mov     [eax+0Ch], ecx
    mov     edi, TAdynmemStructPtr
    xor     esi, esi
    mov     ecx, 0Ah
    lea     eax, [edi+1B63h]
    mov     ebx, 1

    loc_4950C6:                             ; CODE XREF: sub_495010+D7j
    cmp     dword ptr [eax], 0
    jz      short loc_4950D0
    cmp     [eax+73h], bl
    jz      short loc_4950E1

    loc_4950D0:                             ; CODE XREF: sub_495010+B9j
    mov     edx, [eax+27h]
    mov     dl, [edx+9Bh]
    shr     dl, 6
    test    bl, dl
    jnz     short loc_4950E1
    inc     esi

    loc_4950E1:                             ; CODE XREF: sub_495010+BEj
                                            ; sub_495010+CEj
    add     eax, 14Bh
    dec     ecx
    jnz     short loc_4950C6
    mov     ecx, [edi+391E9h]
    call    sub_435100
    mov     ecx, TAdynmemStructPtr
    cmp     eax, 3
    jnz     loc_49518C
    xor     edx, edx
    mov     edi, ecx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     edi, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     edx, [edi+eax*2+1B8Ah]
    test    byte ptr [edx+9Bh], 40h
    jnz     short loc_49518C
    xor     eax, eax
    test    esi, esi
    setnle  al
    mov     esi, eax
    add     ecx, 519h
    push    esi                             ; int
    push    offset aAllies_0                ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    esi                             ; int
    add     ecx, 519h
    push    offset aShare                   ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    test    [edx+2C74h], bl
    jnz     short loc_495177
    call    sub_457A50
    test    eax, eax
    jz      short loc_495177
    mov     eax, ebx
    jmp     short loc_495179
    ; ---------------------------------------------------------------------------

    loc_495177:                             ; CODE XREF: sub_495010+158j
                                            ; sub_495010+161j
    xor     eax, eax

    loc_495179:                             ; CODE XREF: sub_495010+165j
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    offset aControl                 ; "CONTROL"
    push    eax
    jmp     short loc_4951CC
    ; ---------------------------------------------------------------------------

    loc_49518C:                             ; CODE XREF: sub_495010+EDj
                                            ; sub_495010+117j
    push    0                               ; int
    add     ecx, 519h
    push    offset aAllies_0                ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     ecx, TAdynmemStructPtr
    push    0                               ; int
    add     ecx, 519h
    push    offset aShare                   ; char *
    push    ecx                             ; int
    call    sub_4A0570
    mov     edx, TAdynmemStructPtr
    push    0                               ; int
    add     edx, 519h
    push    offset aControl                 ; char *
    push    edx                             ; int

    loc_4951CC:                             ; CODE XREF: sub_495010+17Aj
    call    sub_4A0570
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA50
    mov     ecx, TAdynmemStructPtr
    push    40h
    add     ecx, 519h
    push    ecx
    call    sub_4A81E0
    call    sub_4C2870

    loc_4951FA:                             ; CODE XREF: sub_495010+43j
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_495010 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, TAdynmemStructPtr
    push    20h
    lea     ecx, [eax+37EA0h]
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AA8F0
    mov     dword ptr [eax+8], offset loc_494890
    mov     edx, TAdynmemStructPtr
    mov     [eax+0Ch], edx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_495230 proc near                    ; CODE XREF: sub_496790+63p
                                            ; sub_496790+198p

    var_8= qword ptr -8

    sub     esp, 8
    push    ebx
    push    esi
    push    edi
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    mov     edx, eax
    sub     edx, [ecx+38A37h]
    mov     [ecx+38A3Fh], edx

    loc_49524F:                             ; DATA XREF: .data:005110ECo
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38A37h], eax
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+38A4Dh]
    mov     edx, ecx
    and     edx, 0FFFFh
    cmp     cx, [eax+38A4Bh]
    mov     dword ptr [esp+14h+var_8], edx
    mov     dx, [eax+38A51h]
    sbb     ecx, ecx
    and     edx, 0FFFBh
    neg     ecx
    and     ecx, 1
    xor     edi, edi
    shl     ecx, 2
    or      ecx, edx
    fild    dword ptr [esp+14h+var_8]
    mov     [eax+38A51h], cx
    mov     eax, TAdynmemStructPtr
    mov     esi, [eax+38A47h]
    mov     [eax+511h], edi
    mov     edx, TAdynmemStructPtr
    fmul    ds:dbl_4FDA28
    lea     eax, [edx+1B63h]
    lea     ecx, [edx+2851h]
    cmp     eax, ecx
    jz      short loc_495305
    mov     bl, 3

    loc_4952CF:                             ; CODE XREF: sub_495230+D3j
    cmp     [eax], edi
    jz      short loc_4952F6
    cmp     [eax+73h], bl
    jnz     short loc_4952F6
    cmp     [eax+144h], di
    jbe     short loc_4952F6
    mov     ecx, [eax+18h]
    cmp     ecx, esi
    jge     short loc_4952F6
    mov     [edx+511h], eax
    mov     edx, TAdynmemStructPtr
    mov     esi, ecx

    loc_4952F6:                             ; CODE XREF: sub_495230+A1j
                                            ; sub_495230+A6j ...
    add     eax, 14Bh
    lea     ecx, [edx+2851h]
    cmp     eax, ecx
    jnz     short loc_4952CF

    loc_495305:                             ; CODE XREF: sub_495230+9Bj
    mov     eax, [edx+38A47h]
    sub     eax, esi
    mov     [edx+515h], eax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+515h]
    cmp     eax, 384h
    jl      short loc_495367
    cmp     eax, 0E10h
    jle     short loc_495332
    mov     eax, 0E10h

    loc_495332:                             ; CODE XREF: sub_495230+FBj
    mov     edx, 0E10h
    sub     edx, eax
    mov     dword ptr [esp+14h+var_8], edx
    fild    dword ptr [esp+14h+var_8]
    fmul    ds:dbl_4FDA30
    fcom    ds:dbl_4FDA38
    fnstsw  ax
    test    ah, 1
    jz      short loc_49535C
    fstp    st
    fld     ds:dbl_4FDA38

    loc_49535C:                             ; CODE XREF: sub_495230+122j
    or      byte ptr [ecx+38A51h], 2
    fmulp   st(1), st
    jmp     short loc_495370
    ; ---------------------------------------------------------------------------

    loc_495367:                             ; CODE XREF: sub_495230+F4j
    and     word ptr [ecx+38A51h], 0FFFDh

    loc_495370:                             ; CODE XREF: sub_495230+135j
    mov     eax, TAdynmemStructPtr
    fild    dword ptr [eax+38A3Fh]
    fmul    st, st(1)
    fadd    dword ptr [eax+38A43h]
    fstp    [esp+14h+var_8]
    mov     eax, dword ptr [esp+14h+var_8+4]
    mov     ecx, dword ptr [esp+14h+var_8]
    push    eax
    push    ecx
    fstp    st
    call    _floor
    fld     st
    add     esp, 8
    call    __ftol
    fld     [esp+14h+var_8]
    mov     edx, TAdynmemStructPtr
    fsub    st, st(1)
    mov     [edx+38A3Bh], eax
    mov     eax, TAdynmemStructPtr
    fstp    dword ptr [eax+38A43h]
    mov     eax, TAdynmemStructPtr
    fstp    st
    cmp     [eax+38A3Bh], edi
    jge     short loc_4953D9
    mov     [eax+38A3Bh], edi
    mov     eax, TAdynmemStructPtr

    loc_4953D9:                             ; CODE XREF: sub_495230+19Cj
    test    byte ptr [eax+38A51h], 1
    jz      short loc_4953EF
    mov     [eax+38A3Bh], edi
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4953EF:                             ; CODE XREF: sub_495230+1B0j
    mov     edx, [eax+38A3Bh]
    mov     ecx, 5
    cmp     edx, ecx
    jle     short loc_495448
    mov     [eax+38A3Bh], ecx
    mov     eax, TAdynmemStructPtr
    inc     word ptr [eax+38A4Fh]
    mov     eax, TAdynmemStructPtr
    cmp     word ptr [eax+38A4Fh], 0Ah
    jle     short loc_495482
    mov     [eax+38A4Fh], di
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+38A4Dh]
    cmp     ax, 1
    jbe     short loc_495482
    dec     eax
    mov     [ecx+38A4Dh], ax
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_495448:                             ; CODE XREF: sub_495230+1CCj
    dec     word ptr [eax+38A4Fh]
    mov     eax, TAdynmemStructPtr
    cmp     word ptr [eax+38A4Fh], 0FF9Ch
    jge     short loc_495482
    mov     [eax+38A4Fh], di
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+38A4Dh]
    cmp     cx, [eax+38A4Bh]
    jnb     short loc_495482
    inc     ecx
    mov     [eax+38A4Dh], cx

    loc_495482:                             ; CODE XREF: sub_495230+1EDj
                                            ; sub_495230+207j ...
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    sub_495230 endp

    ; ---------------------------------------------------------------------------
    align 8

    loc_495490:                             ; CODE XREF: sub_496790+7Cp
                                            ; sub_496790+1AEp
    mov     eax, TAdynmemStructPtr
    push    esi
    push    edi
    mov     ecx, [eax+38A3Bh]
    mov     edx, ecx
    dec     ecx
    test    edx, edx
    jz      loc_495674
    mov     edi, [esp+0Ch]
    push    ebx
    lea     ebx, [ecx+1]
    jmp     short loc_4954B7
    ; ---------------------------------------------------------------------------

    loc_4954B2:                             ; CODE XREF: sub_49562A+43j
    mov     eax, TAdynmemStructPtr

    loc_4954B7:                             ; CODE XREF: .text:004954B0j
    mov     ecx, [eax+38A47h]
    inc     ecx
    test    edi, edi
    mov     [eax+38A47h], ecx
    jz      short loc_4954ED
    call    Network_Process
    mov     eax, TAdynmemStructPtr
    lea     esi, [eax+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+2Ch]
    add     edx, ecx
    mov     [esi+2Ch], edx
    mov     [esi], eax

    loc_4954ED:                             ; CODE XREF: .text:004954C6j
    call    sub_48AD30
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+30h]
    add     edx, ecx
    mov     [esi+30h], edx
    mov     [esi], eax
    call    sub_49B720
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+48h]
    add     edx, ecx
    mov     [esi+48h], edx
    mov     [esi], eax
    call    sub_420F30
    mov     edx, TAdynmemStructPtr

    loc_495544:                             ; DATA XREF: .data:00502828o
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+4Ch]
    add     edx, ecx
    mov     [esi+4Ch], edx
    mov     [esi], eax
    call    UpdateDatePlayers
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+34h]
    add     edx, ecx
    mov     [esi+34h], edx
    mov     [esi], eax
    call    sub_424050
    call    sub_415B30
    call    sub_490C40
    call    sub_437DE0
    call    sub_41CA10
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+4Ch]
    add     edx, ecx
    mov     [esi+4Ch], edx
    mov     [esi], eax
    call    sub_471EB0
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+44h]
    add     edx, ecx
    mov     [esi+44h], edx
    mov     [esi], eax
    call    sub_466580
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+4Ch]
    add     edx, ecx
    mov     [esi+4Ch], edx
    mov     [esi], eax
    test    edi, edi
    jz      short loc_49566C
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_49566C
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49562A proc near                    ; DATA XREF: .data:00508490o
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*2+1B63h]
    push    ecx
    call    sub_457D30
    push    0
    mov     ecx, offset dword_513000
    call    sub_4618A0
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+2Ch]
    add     edx, ecx
    mov     [esi+2Ch], edx
    mov     [esi], eax

    loc_49566C:                             ; CODE XREF: .text:0049560Dj
                                            ; .text:00495616j
    dec     ebx
    jnz     loc_4954B2
    pop     ebx

    loc_495674:                             ; CODE XREF: .text:004954A2j
    call    nullsub_35
    call    nullsub_36
    call    nullsub_37
    call    sub_463EF0
    call    sub_482130
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edi, [esi]
    mov     edx, [esi+4Ch]
    mov     ecx, eax
    sub     ecx, edi
    pop     edi
    add     edx, ecx
    mov     [esi+4Ch], edx
    mov     [esi], eax
    pop     esi
    retn    4
    sub_49562A endp ; sp =  0Ch

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4956C0 proc near                    ; CODE XREF: sub_4964FD+E4p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    ebx
    add     eax, 0FFFFFFC3h
    cmp     eax, 33h
    ja      loc_49580C
    xor     ecx, ecx
    mov     cl, ds:byte_49582C[eax]
    jmp     ds:off_495810[ecx*4]

    loc_4956E0:                             ; DATA XREF: .text:0049581Co
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+3923Bh]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [ecx+3923Bh], dx
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_495703:                             ; CODE XREF: sub_4956C0+19j
                                            ; DATA XREF: .text:00495820o
    mov     eax, TAdynmemStructPtr
    mov     dl, [eax+14280h]
    inc     dl
    mov     [eax+14280h], dl
    mov     eax, TAdynmemStructPtr
    cmp     byte ptr [eax+14280h], 5
    jnz     loc_49580C
    mov     byte ptr [eax+14280h], 0
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_495733:                             ; CODE XREF: sub_4956C0+19j
                                            ; DATA XREF: .text:00495814o
    push    1
    call    sub_4C61B0
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49573E:                             ; CODE XREF: sub_4956C0+19j
                                            ; DATA XREF: .text:00495824o
    push    0
    call    sub_4C61B0
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_495749:                             ; CODE XREF: sub_4956C0+19j
                                            ; DATA XREF: .text:00495818o
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cx, [edx+2CBAh]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [edx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [ecx+eax*8+0A6h], 0
    lea     eax, [ecx+eax*8]
    jz      loc_49580C
    mov     ecx, [eax+110h]
    mov     byte ptr [eax+0F4h], 0Ah
    or      ch, 40h
    mov     dword ptr [eax+0F0h], 0
    mov     [eax+110h], ecx
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49579E:                             ; CODE XREF: sub_4956C0+19j
                                            ; DATA XREF: .text:00495810o
    mov     edx, TAdynmemStructPtr
    xor     bl, bl
    xor     eax, eax
    cmp     bl, 0Ah
    jnb     short loc_495800

    loc_4957AD:                             ; CODE XREF: sub_4956C0+14Aj
    mov     ecx, [edx+eax+1B63h]
    test    ecx, ecx
    jz      short loc_495800
    mov     cl, [edx+eax+1BD6h]
    cmp     cl, 1
    jz      short loc_4957CE
    cmp     cl, 2
    jz      short loc_4957CE
    cmp     cl, 3
    jnz     short loc_495800

    loc_4957CE:                             ; CODE XREF: sub_4956C0+102j
                                            ; sub_4956C0+107j
    cmp     byte ptr [edx+eax+1CA9h], 0Ah
    jz      short loc_495800
    mov     ecx, [edx+eax+1C07h]
    mov     [edx+eax+1BEFh], ecx
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+eax+1C0Bh]
    mov     [ecx+eax+1BFBh], edx
    mov     edx, TAdynmemStructPtr

    loc_495800:                             ; CODE XREF: sub_4956C0+EBj
                                            ; sub_4956C0+F6j ...
    inc     bl
    add     eax, 14Bh
    cmp     bl, 0Ah
    jb      short loc_4957AD

    loc_49580C:                             ; CODE XREF: sub_4956C0+Bj
                                            ; sub_4956C0+19j ...
    pop     ebx
    retn    4
    sub_4956C0 endp

    ; ---------------------------------------------------------------------------
    off_495810 dd offset loc_49579E         ; DATA XREF: sub_4956C0+19r
    dd offset loc_495733
    dd offset loc_495749
    dd offset loc_4956E0
    dd offset loc_495703
    dd offset loc_49573E
    dd offset loc_49580C
    byte_49582C db 0                        ; DATA XREF: sub_4956C0+13r
    dd 4 dup(6060606h), 6010606h, 2 dup(6060606h), 2060606h, 2 dup(6060606h)
    dd 3060606h, 4060606h
    db 2 dup(6), 5

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_495860 proc near                    ; CODE XREF: sub_48BD50+96p
                                            ; sub_48BE00+109p ...
    mov     eax, TAdynmemStructPtr
    push    offset aStop                    ; char *
    mov     byte ptr [eax+2CC3h], 1
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2CC6h]
    and     cl, 0DFh
    mov     [eax+2CC6h], cl
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short locret_4958B2
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A6A40

    locret_4958B2:                          ; CODE XREF: sub_495860+3Dj
    retn
    sub_495860 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    test    eax, eax
    mov     eax, TAdynmemStructPtr
    jz      short loc_4958D7
    or      byte ptr [eax+2CC6h], 20h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4958D7:                             ; CODE XREF: .text:004958CBj
    mov     byte ptr [eax+2CC3h], 1
    mov     eax, TAdynmemStructPtr
    push    offset aStop                    ; "STOP"
    mov     cl, [eax+2CC6h]
    and     cl, 0DFh
    mov     [eax+2CC6h], cl
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short locret_495924
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A6A40

    locret_495924:                          ; CODE XREF: .text:0049590Fj
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_495930 proc near                    ; CODE XREF: sub_495A30+21p

    var_119= byte ptr -119h
    var_118= dword ptr -118h
    var_104= byte ptr -104h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 11Ch
    mov     edx, [esp+11Ch+arg_4]
    push    ebx
    push    ebp
    xor     ebp, ebp
    mov     al, [edx]
    push    esi
    test    al, al
    push    edi
    mov     [esp+12Ch+var_119], 0
    jz      short loc_495966
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     byte ptr [ecx+edx-1], 5Ch
    jz      short loc_495966
    mov     [esp+12Ch+var_119], 1

    loc_495966:                             ; CODE XREF: sub_495930+1Cj
                                            ; sub_495930+2Fj
    mov     al, [esp+12Ch+var_119]
    test    al, al
    mov     eax, offset byte_503374
    jnz     short loc_495978
    mov     eax, offset Data

    loc_495978:                             ; CODE XREF: sub_495930+41j
    mov     ecx, [esp+12Ch+arg_C]
    mov     esi, [esp+12Ch+arg_8]
    mov     edi, [esp+12Ch+arg_0]
    push    ecx
    push    esi
    push    eax
    push    edx
    push    offset aSSS_S                   ; "%s%s%s*.%s"
    push    edi
    call    _sprintf
    add     esp, 18h
    lea     edx, [esp+12Ch+var_118]
    push    1
    push    0FFFFFFFFh
    push    edx
    push    edi
    call    sub_4BC4B0
    mov     ebx, eax
    test    ebx, ebx
    jl      short loc_4959EF

    loc_4959B4:                             ; CODE XREF: sub_495930+B0j
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+12Ch+var_104]
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    cmp     eax, ebp
    jle     short loc_4959D3
    mov     ebp, eax

    loc_4959D3:                             ; CODE XREF: sub_495930+9Fj
    lea     ecx, [esp+12Ch+var_118]
    push    ecx
    push    ebx
    call    sub_4BC640
    test    eax, eax
    jz      short loc_4959B4
    push    ebx
    call    sub_4BC8D0
    mov     edi, [esp+12Ch+arg_0]

    loc_4959EF:                             ; CODE XREF: sub_495930+82j
    mov     al, [esp+12Ch+var_119]
    test    al, al
    mov     eax, offset byte_503374
    jnz     short loc_495A01
    mov     eax, offset Data

    loc_495A01:                             ; CODE XREF: sub_495930+CAj
    mov     edx, [esp+12Ch+arg_C]
    inc     ebp
    push    edx
    push    ebp
    push    esi
    push    eax
    mov     eax, [esp+13Ch+arg_4]
    push    eax
    push    offset aSSS04i_S                ; "%s%s%s%04i.%s"
    push    edi
    call    _sprintf
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 11Ch
    retn    10h
    sub_495930 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_495A30(int,int,int,int,int,int)
    sub_495A30 proc near                    ; CODE XREF: sub_417600+138p

    var_1B0= dword ptr -1B0h
    var_1AC= dword ptr -1ACh
    var_1A8= dword ptr -1A8h
    var_1A4= dword ptr -1A4h
    var_1A0= dword ptr -1A0h
    var_19C= dword ptr -19Ch
    var_198= dword ptr -198h
    MapY= dword ptr -194h
    var_190= dword ptr -190h
    MapXScrollingTo= dword ptr -18Ch
    var_188= dword ptr -188h
    var_184= dword ptr -184h
    var_180= dword ptr -180h
    var_17C= dword ptr -17Ch
    MapYScrollingTo= dword ptr -178h
    var_174= dword ptr -174h
    var_170= dword ptr -170h
    var_16C= dword ptr -16Ch
    var_15C= dword ptr -15Ch
    var_154= byte ptr -154h
    var_138= dword ptr -138h
    var_134= dword ptr -134h
    var_104= dword ptr -104h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    sub     esp, 1B0h
    lea     edx, [esp+1B0h+var_104]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    offset aBmp                     ; "bmp"
    push    eax
    push    ecx
    push    edx
    call    sub_495930
    lea     ecx, [esp+1C0h+var_16C]
    call    sub_4CB7C0
    mov     eax, [esp+1C0h+arg_14]
    mov     esi, [esp+1C0h+arg_10]
    push    eax
    lea     ecx, [esp+1C4h+var_104]
    push    esi
    push    ecx
    lea     ecx, [esp+1CCh+var_16C]
    call    sub_4CB7F0
    test    al, al
    jz      loc_495E6B
    mov     eax, TAdynmemStructPtr
    push    0
    mov     ecx, [eax+1423Bh]
    mov     edi, [eax+1423Fh]
    mov     edx, [eax+37E27h]
    shl     ecx, 4
    shl     edi, 4
    mov     [esp+1C4h+var_1A0], ecx
    mov     ecx, [eax+37E2Bh]
    dec     edi
    mov     [esp+1C4h+var_17C], edx
    mov     [esp+1C4h+var_190], ecx
    mov     [esp+1C4h+var_1A8], edi
    call    sub_4D8E50
    add     esp, 4
    push    edi
    push    esi
    push    offset aScreenshot              ; "ScreenShot"
    call    sub_4B8DA0
    mov     ebp, eax
    test    ebp, ebp
    mov     [esp+1C0h+var_1AC], ebp
    jnz     short loc_495AFD
    mov     eax, edi
    cdq
    sub     eax, edx
    sar     eax, 1
    push    eax
    push    esi
    push    offset aScreenshot              ; "ScreenShot"
    mov     [esp+1CCh+var_1A8], eax
    call    sub_4B8DA0
    mov     ebp, eax
    mov     edi, [esp+1C0h+var_1A8]
    mov     [esp+1C0h+var_1AC], eax

    loc_495AFD:                             ; CODE XREF: sub_495A30+AAj
    call    sub_49E6F0
    test    ebp, ebp
    jz      loc_495E6B
    mov     esi, TAdynmemStructPtr
    push    1                               ; int
    mov     eax, [esi+TAdynmemStruct.MapY]
    mov     cx, [esi+14281h]
    mov     [esp+1C4h+MapY], eax
    mov     edx, [esi+TAdynmemStruct.MapX]
    mov     eax, ecx
    and     ecx, 0FFFEh
    and     eax, 0FFFFh
    mov     [esi+14281h], cx
    mov     ebx, eax
    mov     [esp+1C4h+MapXScrollingTo], edx
    shr     eax, 1
    and     eax, 1
    and     ebx, 1
    mov     [esp+1C4h+var_184], eax
    mov     eax, TAdynmemStructPtr
    mov     [esp+1C4h+var_180], ebx
    and     word ptr [eax+14281h], 0FFFDh
    call    Set_LOS_State
    mov     edx, TAdynmemStructPtr
    push    ebp                             ; int
    mov     ax, [edx+38A51h]
    mov     ecx, eax
    and     eax, 0FFFEh
    and     ecx, 1
    mov     [edx+38A51h], ax
    mov     [esp+1C4h+var_170], ecx
    mov     ecx, TAdynmemStructPtr
    lea     edx, [esp+1C4h+var_134]
    mov     ax, [ecx+37F2Fh]
    push    edx                             ; int
    mov     esi, eax
    and     eax, 0FFBFh
    mov     [ecx+37F2Fh], ax
    mov     eax, TAdynmemStructPtr
    shr     esi, 6
    mov     ecx, [eax+37F27h]
    and     esi, 1
    mov     [esp+1C8h+var_198], esi
    mov     [esp+1C8h+var_174], ecx
    mov     dword ptr [eax+37F27h], 0
    call    sub_4B8A80
    call    sub_4B6220
    mov     eax, [eax+0BCh]
    lea     ecx, [esp+1C0h+var_15C]
    push    eax
    push    ecx
    call    sub_4B8AE0
    xor     ebp, ebp
    mov     [esp+1C0h+var_154], 0
    cmp     [esp+1C0h+arg_14], ebp
    jle     loc_495DA8
    mov     eax, edi
    mov     [esp+1C0h+var_19C], edi
    neg     eax
    or      ebx, 0FFFFFFFFh
    mov     [esp+1C0h+var_1B0], ebp
    mov     [esp+1C0h+var_188], eax
    mov     [esp+1C0h+var_1A4], ebx

    loc_495C15:                             ; CODE XREF: sub_495A30+36Aj
    mov     edx, [esp+1C0h+var_1AC]
    push    0
    push    edx
    call    sub_4B8E50
    xor     esi, esi
    mov     eax, [esp+1C0h+arg_10]
    test    eax, eax
    jle     loc_495D0D
    mov     eax, [esp+1C0h+arg_C]
    mov     ebx, [esp+1C0h+arg_8]
    dec     edi
    lea     ecx, [ebp+eax+0]
    mov     eax, [esp+1C0h+var_1A0]
    mov     [esp+1C0h+MapYScrollingTo], ecx
    mov     [esp+1C0h+var_138], edi
    sub     ebx, eax

    loc_495C56:                             ; CODE XREF: sub_495A30+2CFj
    mov     edx, [esp+1C0h+var_1A0]
    mov     eax, [esp+1C0h+MapYScrollingTo]
    push    0                               ; int
    push    eax                             ; MapYScrollingTo
    lea     edi, [esi+edx]
    lea     ecx, [ebx+edi]
    push    ecx                             ; MapXScrollingTo
    call    ScrollMap
    call    GameUnit_LOS_Sight
    push    0                               ; int
    push    1                               ; int
    call    GameUnit_LOS_Unknown1
    lea     eax, [edi-1]
    mov     ecx, [esp+1C0h+var_134]
    cmp     eax, ecx
    jl      short loc_495C8C
    lea     eax, [ecx-1]

    loc_495C8C:                             ; CODE XREF: sub_495A30+257j
    sub     esp, 10h
    xor     ecx, ecx
    mov     edx, esp
    mov     [edx], esi
    mov     [edx+4], ecx
    lea     ecx, [esp+1D0h+var_134]
    mov     [edx+8], eax
    mov     eax, [esp+1D0h+var_138]
    mov     [edx+0Ch], eax
    call    sub_4C6B10
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+1C0h+arg_C]
    mov     esi, [esp+1C0h+var_190]
    mov     ecx, [eax+14323h]
    sub     ecx, ebp
    sub     ecx, edx
    mov     edx, [eax+1431Fh]
    sub     ecx, esi
    mov     esi, [esp+1C0h+arg_8]
    push    ecx
    mov     ecx, [esp+1C4h+var_17C]
    sub     edx, esi
    lea     eax, [esp+1C4h+var_15C]
    sub     edx, ecx
    lea     ecx, [esp+1C4h+var_134]
    push    edx
    push    eax
    push    ecx
    call    sub_4B7F90
    mov     esi, edi
    cmp     esi, [esp+1C0h+arg_10]
    jl      loc_495C56
    mov     edi, [esp+1C0h+var_1A8]
    mov     ebx, [esp+1C0h+var_1A4]

    loc_495D0D:                             ; CODE XREF: sub_495A30+1FCj
    mov     esi, [esp+1C0h+var_1B0]
    xor     edx, edx
    cmp     ebx, 0FFFFFFFFh
    mov     eax, edi
    mov     ecx, ebp
    jge     short loc_495D29
    lea     ecx, [ebp+1]
    mov     esi, ebx
    lea     eax, [edi-1]
    mov     edx, 1

    loc_495D29:                             ; CODE XREF: sub_495A30+2EAj
    add     ecx, eax
    cmp     ecx, [esp+1C0h+arg_14]
    jle     short loc_495D3D
    mov     eax, [esp+1C0h+arg_14]
    add     eax, esi

    loc_495D3D:                             ; CODE XREF: sub_495A30+302j
    mov     ecx, [esp+1C0h+arg_10]
    push    edx
    push    0
    push    ebp
    push    0
    push    eax
    lea     edx, [esp+1D4h+var_134]
    push    ecx
    push    edx
    lea     ecx, [esp+1DCh+var_16C]
    call    sub_4CB940
    test    al, al
    jz      short loc_495DA0
    mov     ecx, [esp+1C0h+var_19C]
    mov     edx, [esp+1C0h+arg_14]
    cmp     ecx, edx
    jge     short loc_495D7C
    mov     eax, [esp+1C0h+var_1B0]
    dec     ebp
    inc     eax
    inc     ebx
    mov     [esp+1C0h+var_1B0], eax
    dec     ecx

    loc_495D7C:                             ; CODE XREF: sub_495A30+33Ej
    mov     eax, [esp+1C0h+var_188]
    mov     esi, [esp+1C0h+var_1B0]
    add     ebp, edi
    add     esi, eax
    add     ebx, eax
    add     ecx, edi
    cmp     ebp, edx
    mov     [esp+1C0h+var_1B0], esi
    mov     [esp+1C0h+var_1A4], ebx
    mov     [esp+1C0h+var_19C], ecx
    jl      loc_495C15

    loc_495DA0:                             ; CODE XREF: sub_495A30+32Fj
    mov     esi, [esp+1C0h+var_198]
    mov     ebx, [esp+1C0h+var_180]

    loc_495DA8:                             ; CODE XREF: sub_495A30+1C8j
    mov     eax, [esp+1C0h+var_1AC]
    push    eax                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    mov     eax, [esp+1C4h+var_170]
    and     esi, 1
    add     esp, 4
    mov     cx, [edx+38A51h]
    xor     al, cl
    push    0                               ; int
    and     eax, 1
    xor     eax, ecx
    mov     [edx+38A51h], ax
    mov     eax, TAdynmemStructPtr
    shl     esi, 6
    mov     cx, [eax+37F2Fh]
    and     ecx, 0FFBFh
    or      ecx, esi
    mov     [eax+37F2Fh], cx
    mov     edx, TAdynmemStructPtr
    mov     eax, [esp+1C4h+var_174]
    mov     ecx, [esp+1C4h+MapY]
    mov     [edx+37F27h], eax
    mov     edx, [esp+1C4h+MapXScrollingTo]
    push    ecx                             ; MapYScrollingTo
    push    edx                             ; MapXScrollingTo
    call    ScrollMap
    mov     ecx, TAdynmemStructPtr
    push    1                               ; int
    mov     ax, [ecx+14281h]
    xor     bl, al
    and     ebx, 1
    xor     ebx, eax
    mov     eax, [esp+1C4h+var_184]
    mov     [ecx+14281h], bx
    mov     ecx, TAdynmemStructPtr
    and     eax, 1
    mov     dx, [ecx+14281h]
    and     edx, 0FFFDh
    shl     eax, 1
    or      edx, eax
    mov     [ecx+14281h], dx
    call    Set_LOS_State
    call    GameUnit_LOS_Sight
    push    1                               ; int
    push    1                               ; int
    call    GameUnit_LOS_Unknown1

    loc_495E6B:                             ; CODE XREF: sub_495A30+52j
                                            ; sub_495A30+D4j
    lea     ecx, [esp+1C0h+var_16C]
    call    sub_4CB7D0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1B0h
    retn    18h
    sub_495A30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_495E90 proc near                    ; CODE XREF: sub_496790+1E1p
    sub     esp, 230h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4C1AB0
    mov     ebp, eax
    xor     ebx, ebx
    cmp     ebp, ebx
    jz      loc_4965E6
    push    0F9h
    call    sub_4C1B80
    mov     esi, eax
    lea     eax, [ebp-9]
    cmp     eax, 0EFh
    ja      loc_4965CE
    xor     ecx, ecx
    mov     cl, ds:byte_496694[eax]
    jmp     ds:off_4965F4[ecx*4]

    loc_495ED4:                             ; DATA XREF: .text:004965FCo
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EBEh], 1
    jz      short loc_495F2D
    and     word ptr [eax+37EBEh], 0FFFEh
    mov     eax, TAdynmemStructPtr
    lea     edx, [eax+37EA0h]
    add     eax, 519h
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4AB060
    cmp     eax, ebx
    jnz     loc_4965CE
    mov     eax, TAdynmemStructPtr
    mov     [eax+37E9Ch], bx
    mov     ecx, TAdynmemStructPtr
    add     ecx, TAdynmemStruct.field_519
    push    ecx
    call    sub_4A9660
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_495F2D:                             ; CODE XREF: sub_495E90+50j
    cmp     byte ptr [eax+2CC3h], 1
    jz      short loc_495F8C
    mov     byte ptr [eax+2CC3h], 1
    mov     eax, TAdynmemStructPtr
    push    offset aStop                    ; char *
    mov     bl, [eax+2CC6h]
    and     bl, 0DFh
    mov     [eax+2CC6h], bl
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      loc_4965CE
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4A6A40
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_495F8C:                             ; CODE XREF: sub_495E90+A4j
    call    sub_48BD00
    push    1
    call    sub_491D70
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_495F9D:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496664o
    lea     eax, [ebp-0C4h]
    push    eax
    call    sub_48D920
    push    ebx                             ; int
    push    offset aCreatesquad             ; char *
    call    sub_47F1A0
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_495FB9:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:0049661Co
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    0FBh
    mov     cl, [edx+37F07h]
    test    cl, 1
    jz      short loc_495FEF
    call    sub_4C1B80
    test    eax, eax
    jz      short loc_495FE8
    lea     eax, [ebp-31h]
    push    eax
    call    sub_41C060
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_495FE8:                             ; CODE XREF: sub_495E90+148j
    lea     ecx, [ebp-30h]
    push    esi
    push    ecx
    jmp     short loc_495FFD
    ; ---------------------------------------------------------------------------

    loc_495FEF:                             ; CODE XREF: sub_495E90+13Fj
    call    sub_4C1B80
    test    eax, eax
    jz      short loc_496012
    lea     edx, [ebp-30h]
    push    esi
    push    edx

    loc_495FFD:                             ; CODE XREF: sub_495E90+15Dj
    call    sub_48D9A0
    push    ebx                             ; int
    push    offset aSelectsquad             ; char *
    call    sub_47F1A0
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_496012:                             ; CODE XREF: sub_495E90+166j
    lea     eax, [ebp-31h]
    push    eax
    call    sub_41C060
    jmp     loc_4965CE
    sub_495E90 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_496020 proc near                    ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496668o
    push    ebx                             ; int
    push    offset aSelectsquad             ; char *
    call    sub_47F1A0
    lea     ecx, [ebp-0D2h]
    push    ecx
    call    sub_41D3B0
    jmp     loc_4965CE
    sub_496020 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49603C proc near                    ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496680o
    push    ebx                             ; int
    push    offset aSelectsquad             ; char *
    call    sub_47F1A0
    lea     edx, [ebp-0E6h]
    push    edx
    call    sub_41D3F0
    jmp     loc_4965CE
    sub_49603C endp

    ; ---------------------------------------------------------------------------

    loc_496058:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496600o ...
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [ecx+37F06h], dx
    call    WriteRegistrySettings_2
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_496081:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496610o
    push    1
    call    sub_41BF10
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_49608D:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496618o
    push    1
    call    sub_41BDE0
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_496099:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:0049668Co
    mov     ecx, TAdynmemStructPtr
    mov     byte ptr [esp+10h], 19h
    mov     [esp+11h], bl
    push    3
    mov     ax, [ecx+38A51h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 1
    xor     edx, eax
    mov     [ecx+38A51h], dx
    mov     eax, TAdynmemStructPtr
    lea     edx, [esp+14h]
    mov     cl, [eax+38A51h]
    push    edx
    and     cl, 1
    mov     [esp+1Ah], cl
    call    sub_44FDB0
    push    eax
    call    sub_451DF0
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4960EA:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496670o
    cmp     esi, ebx
    jz      short loc_496129
    mov     eax, TAdynmemStructPtr
    cmp     [eax+2CBAh], bx
    jz      short loc_49611E
    mov     dword ptr [eax+391B3h], 1
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+2CBAh]
    mov     [eax+391B7h], cx
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_49611E:                             ; CODE XREF: .text:004960FAj
    mov     [eax+391B3h], ebx
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_496129:                             ; CODE XREF: .text:004960ECj
    call    sub_4942E0
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_496133:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:004965F4o
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_496165
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+37EBEh], 4
    jnz     loc_4965CE
    call    sub_495010
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_496165:                             ; CODE XREF: sub_495E90+3Dj
                                            ; .text:00496147j
                                            ; DATA XREF: ...
    cmp     esi, ebx
    jz      short loc_4961A4
    mov     eax, TAdynmemStructPtr
    cmp     [eax+2CBAh], bx
    jz      short loc_496199
    mov     dword ptr [eax+391B9h], 1
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+2CBAh]
    mov     [eax+391BDh], cx
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_496199:                             ; CODE XREF: .text:00496175j
    mov     [eax+391B9h], ebx
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4961A4:                             ; CODE XREF: .text:00496167j
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+37EBEh], 1
    jnz     loc_4965CE
    call    sub_460CC0
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+37EBEh], 1
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4961CD:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496678o
    call    sub_464000
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4961D7:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:0049666Co
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F2Fh]
    shr     cl, 1
    test    cl, 1
    jz      loc_4965CE
    mov     ecx, [eax+38C53h]
    mov     [eax+38C53h], ebx
    cmp     ecx, ebx
    jnz     loc_4965CE
    mov     edx, TAdynmemStructPtr
    lea     eax, [esp+140h]
    add     edx, 38A53h
    push    edx
    push    offset aSMovie                  ; "%s\\MOVIE*"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+28h]
    lea     edx, [esp+140h]
    push    1
    push    0FFFFFFFFh
    push    ecx
    push    edx
    call    sub_4BC4B0
    mov     esi, eax
    cmp     esi, ebx
    jl      short loc_496275

    loc_49623F:                             ; CODE XREF: .text:0049626Dj
    lea     eax, [esp+41h]
    push    eax
    call    _atoi
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    cmp     eax, [ecx+38C53h]
    jle     short loc_496260
    mov     [ecx+38C53h], eax

    loc_496260:                             ; CODE XREF: .text:00496258j
    lea     ecx, [esp+28h]
    push    ecx
    push    esi
    call    sub_4BC640
    test    eax, eax
    jz      short loc_49623F
    push    esi
    call    sub_4BC8D0

    loc_496275:                             ; CODE XREF: .text:0049623Dj
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+38C53h]
    inc     edx
    mov     [eax+38C53h], edx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+38C53h]
    lea     ecx, [eax+38A53h]
    push    edx
    push    ecx
    add     eax, 38B53h
    push    offset aSMovie03i               ; "%s\\MOVIE%03i"
    push    eax
    call    _sprintf
    mov     edx, TAdynmemStructPtr
    add     esp, 10h
    add     edx, 38B53h
    push    edx
    call    sub_4BCF00
    push    1
    push    ebx
    call    GameUnit_LOS_Unknown1
    mov     eax, TAdynmemStructPtr
    push    offset aFram                    ; "FRAM"
    add     eax, 38B53h
    push    eax
    call    sub_4CB170
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    mov     [eax+38C5Bh], ecx
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4962F2:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496684o
    mov     esi, TAdynmemStructPtr
    mov     dl, [esi+37F2Fh]
    shr     dl, 1
    test    dl, 1
    jz      loc_4965CE
    mov     ax, [esi+3923Bh]
    mov     ecx, eax
    not     ecx
    xor     cl, al
    and     ecx, 2
    xor     ecx, eax
    mov     [esi+3923Bh], cx
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+3923Bh]
    mov     dl, al
    shr     dl, 1
    test    dl, 1
    jz      short loc_49634A
    add     ecx, 519h
    push    ebx
    push    ecx
    call    sub_4AB190
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_49634A:                             ; CODE XREF: .text:00496336j
    and     eax, 0FFFEh
    push    1
    mov     [ecx+3923Bh], ax
    mov     eax, TAdynmemStructPtr
    mov     [eax+14280h], bl
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4AB190
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_49637A:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496628o
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+37F2Fh]
    shr     al, 1
    test    al, 1
    jz      loc_4965CE
    push    0FFFFFFFFh
    push    ebx
    call    InterpretCommand
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_49639D:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:0049667Co
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F06h]
    mov     edx, eax
    not     edx
    xor     dl, al
    and     edx, 80h
    xor     edx, eax
    mov     [ecx+37F06h], dx
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4963C4:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496688o
    call    sub_463C80
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4963CE:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496644o
    call    sub_48BD50
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4963D8:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496648o ...
    lea     eax, [ebp-69h]
    lea     ecx, [esp+10h]
    push    eax
    push    offset aCtrl_C                  ; "CTRL_%c"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+10h]
    push    esi
    push    edx
    call    sub_48BF30
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4963FE:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:0049664Co
    push    esi
    push    offset aCtrl_c                  ; "CTRL_C"
    call    sub_48BF30
    call    sub_41C310
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_496413:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496660o
    call    sub_48BE00
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_49641D:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496650o
    mov     al, [esp+17h]
    lea     ecx, [esp+18h]
    push    ecx
    mov     [esp+1Ch], al
    mov     [esp+20h], ebx
    mov     [esp+24h], ebx
    mov     [esp+28h], ebx
    call    sub_48CA20
    push    offset aSelfdestruct            ; "SELFDESTRUCT"
    lea     ecx, [esp+14h]
    xor     edi, edi
    call    sub_438760
    mov     esi, [esp+1Ch]
    cmp     esi, [esp+20h]
    jz      short loc_49647F

    loc_496455:                             ; CODE XREF: .text:0049647Dj
    mov     edx, [esp+10h]
    mov     eax, [esi]
    push    edx
    push    eax
    call    sub_439E30
    cmp     eax, ebx
    jz      short loc_496474
    mov     ecx, [esi]
    push    eax
    push    ecx
    mov     edi, 1
    call    sub_439F80

    loc_496474:                             ; CODE XREF: .text:00496464j
    mov     eax, [esp+20h]
    add     esi, 4
    cmp     esi, eax
    jnz     short loc_496455

    loc_49647F:                             ; CODE XREF: .text:00496453j
    cmp     edi, ebx
    jnz     short loc_49649C
    mov     edx, [esp+10h]
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebx
    push    ebx
    push    edx
    add     eax, 2C76h
    push    ebx
    push    eax
    call    sub_48CF30

    loc_49649C:                             ; CODE XREF: .text:00496481j
    mov     ecx, [esp+1Ch]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4964AE:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496634o
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     loc_4965CE
    call    sub_4936F0
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4964D2:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496638o
    call    sub_48D4D0
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_4964DC:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496658o
    call    sub_48C030
    jmp     loc_4965CE

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4964E6 proc near                    ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:0049663Co
    push    ebx
    call    sub_41C2E0
    jmp     loc_4965CE
    sub_4964E6 endp

    ; ---------------------------------------------------------------------------

    loc_4964F1:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496624o
    push    1
    call    sub_41C2E0
    jmp     loc_4965CE

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4964FD proc near                    ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:004965F8o
    push    ebx                             ; int
    push    offset aSmallbutton             ; char *
    call    sub_47F1A0
    call    sub_494050
    jmp     loc_4965CE
    ; ---------------------------------------------------------------------------

    loc_496512:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:00496614o ...
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+3923Bh], 2
    jnz     loc_4965CE
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B63h]
    lea     eax, [esi+eax*2+1B63h]
    cmp     ecx, ebx
    jz      short loc_496559
    mov     ecx, [eax+27h]
    test    byte ptr [ecx+9Bh], 40h
    jnz     short loc_4965CE

    loc_496559:                             ; CODE XREF: sub_4964FD+4Ej
    mov     ax, [edx+38A4Bh]
    cmp     ax, 1
    jbe     short loc_4965CE
    and     eax, 0FFFFh
    push    1
    dec     eax
    jmp     short loc_4965C8
    ; ---------------------------------------------------------------------------

    loc_496570:                             ; CODE XREF: sub_495E90+3Dj
                                            ; DATA XREF: .text:0049660Co ...
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+3923Bh], 2
    jnz     short loc_4965CE
    xor     ecx, ecx
    mov     esi, edx
    mov     cl, [edx+2A42h]
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B63h]
    lea     eax, [esi+eax*2+1B63h]
    cmp     ecx, ebx
    jz      short loc_4965B3
    mov     ecx, [eax+27h]
    test    byte ptr [ecx+9Bh], 40h
    jnz     short loc_4965CE

    loc_4965B3:                             ; CODE XREF: sub_4964FD+A8j
    mov     ax, [edx+38A4Bh]
    cmp     ax, 14h
    jnb     short loc_4965CE
    and     eax, 0FFFFh
    push    1
    inc     eax

    loc_4965C8:                             ; CODE XREF: sub_4964FD+71j
    push    eax
    call    sub_490DF0

    loc_4965CE:                             ; CODE XREF: sub_495E90+2Fj
                                            ; sub_495E90+3Dj ...
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+3923Bh]
    shr     al, 1
    test    al, 1
    jz      short loc_4965E6
    push    ebp
    call    sub_4956C0

    loc_4965E6:                             ; CODE XREF: sub_495E90+15j
                                            ; sub_4964FD+E1j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 230h
    retn
    sub_4964FD endp ; sp =  23Ch

    ; ---------------------------------------------------------------------------
    align 4
    off_4965F4 dd offset loc_496133         ; DATA XREF: sub_495E90+3Dr
    dd offset sub_4964FD
    dd offset loc_495ED4
    dd offset loc_496058
    dd offset loc_496058
    dd offset loc_496058
    dd offset loc_496570
    dd offset loc_496081
    dd offset loc_496512
    dd offset loc_49608D
    dd offset loc_495FB9
    dd offset loc_496570
    dd offset loc_4964F1
    dd offset loc_49637A
    dd offset loc_496512
    dd offset loc_496058
    dd offset loc_4964AE
    dd offset loc_4964D2
    dd offset sub_4964E6
    dd offset loc_496058
    dd offset loc_4963CE
    dd offset loc_4963D8
    dd offset loc_4963FE
    dd offset loc_49641D
    dd offset loc_4963D8
    dd offset loc_4964DC
    dd offset loc_4963D8
    dd offset loc_496413
    dd offset loc_495F9D
    dd offset sub_496020
    dd offset loc_4961D7
    dd offset loc_4960EA
    dd offset loc_496165
    dd offset loc_4961CD
    dd offset loc_49639D
    dd offset sub_49603C
    dd offset loc_4962F2
    dd offset loc_4963C4
    dd offset loc_496099
    dd offset loc_4965CE
    byte_496694 db 0                        ; DATA XREF: sub_495E90+37r
    ; ---------------------------------------------------------------------------
    daa
    daa
    daa
    add     [edi], esp
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    add     ah, [edi]
    daa
    daa
    daa
    daa
    add     esp, [edi]
    add     al, 27h
    daa
    daa
    daa
    daa
    daa
    add     eax, 9080706h
    daa
    daa
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      cl, [edx]
    or      ah, [edi]
    daa
    daa
    or      esp, [edi]
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    or      al, 27h
    daa
    daa
    daa
    daa
    daa
    daa
    or      eax, 0F0E2727h
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    adc     [edi], ah
    daa
    daa
    daa
    daa
    adc     [edi], esp
    daa
    daa
    daa
    daa
    adc     ah, [edi]
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    adc     esp, [edi]
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    adc     al, 15h
    push    ss
    pop     ss
    sbb     [eax], bl
    sbb     [eax], bl
    sbb     [eax], bl
    sbb     [eax], bl
    sbb     [eax], bl
    sbb     [eax], bl
    sbb     [eax], bl
    sbb     [edx], ebx
    sbb     bl, [edx]
    sbb     bl, [edx]
    sbb     bl, [ebx]
    daa
    sbb     al, 1Ch
    sbb     al, 1Ch
    sbb     al, 1Ch
    sbb     al, 1Ch
    sbb     al, 27h
    daa
    daa
    daa
    sbb     eax, 271D1D1Dh
    push    ds
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    pop     ds
    and     [ecx], ah
    and     ah, [ebx]
    and     esp, [ebx]
    and     esp, [edi]
    daa
    and     al, 25h
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    daa
    db      26h
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_496790 proc near                    ; CODE XREF: sub_497F40+4EFp
                                            ; .text:004995B8p ...
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    mov     dword ptr [eax+38D89h], 0
    lea     esi, [eax+38D85h]
    mov     ecx, 9
    lea     eax, [esi+2Ch]

    loc_4967AF:                             ; CODE XREF: sub_496790+3Aj
    mov     edx, [eax]
    mov     ebx, [esi+4]
    add     ebx, edx
    add     eax, 4
    mov     [esi+4], ebx
    mov     edx, [eax-4]
    mov     [eax-28h], edx
    mov     dword ptr [eax-4], 0
    dec     ecx
    jnz     short loc_4967AF
    mov     eax, [esi+4]
    mov     ebx, 1
    test    eax, eax
    jg      short loc_4967DB
    mov     [esi+4], ebx

    loc_4967DB:                             ; CODE XREF: sub_496790+46j
    call    GetTickCount
    mov     [esi], eax
    mov     eax, TAdynmemStructPtr
    test    [eax+2A44h], bl
    jz      loc_496918
    call    sub_495230
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A3Bh]
    test    ecx, ecx
    jz      loc_4968AA
    push    ebx
    call    loc_495490
    mov     eax, TAdynmemStructPtr
    lea     esi, [eax+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+4Ch]
    add     edx, ecx
    mov     [esi+4Ch], edx
    mov     [esi], eax
    call    unknown_libname_8
    call    unknown_libname_9
    call    unknown_libname_10
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+38D75h]
    shr     al, 2
    test    bl, al
    jz      short loc_496896
    call    sub_4568C0
    test    eax, eax
    jz      short loc_496875
    mov     eax, TAdynmemStructPtr
    mov     cx, [eax+38D75h]
    and     ecx, 0FFFBh
    mov     [eax+38D75h], cx

    loc_496875:                             ; CODE XREF: sub_496790+CAj
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+2Ch]
    add     edx, ecx
    mov     [esi+2Ch], edx
    mov     [esi], eax

    loc_496896:                             ; CODE XREF: sub_496790+C1j
    call    nullsub_52
    call    nullsub_53
    call    nullsub_54
    jmp     loc_496964
    ; ---------------------------------------------------------------------------

    loc_4968AA:                             ; CODE XREF: sub_496790+75j
    test    [eax+38A51h], bl
    jz      loc_496969
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_4968CB
    push    0
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_4968CB:                             ; CODE XREF: sub_496790+12Dj
    call    Network_Process
    call    sub_4B6340
    cmp     eax, dword_51F300
    jle     short loc_4968F7
    call    sub_4B6340
    add     eax, 3Ch
    push    0
    mov     dword_51F300, eax
    call    sub_44FDB0
    push    eax
    call    sub_453320

    loc_4968F7:                             ; CODE XREF: sub_496790+14Bj
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+2Ch]
    add     edx, ecx
    mov     [esi+2Ch], edx
    jmp     short loc_496962
    ; ---------------------------------------------------------------------------

    loc_496918:                             ; CODE XREF: sub_496790+5Dj
    test    [eax+37EBEh], bl
    jnz     short loc_49697B
    test    [eax+38A51h], bl
    jnz     short loc_496969
    call    sub_495230
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A3Bh]
    test    ecx, ecx
    jz      short loc_496969
    push    0
    call    loc_495490
    mov     edx, TAdynmemStructPtr
    lea     esi, [edx+38D85h]
    call    GetTickCount
    mov     edx, [esi]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi+4Ch]
    add     edx, ecx
    mov     [esi+4Ch], edx

    loc_496962:                             ; CODE XREF: sub_496790+186j
    mov     [esi], eax

    loc_496964:                             ; CODE XREF: sub_496790+115j
    mov     eax, TAdynmemStructPtr

    loc_496969:                             ; CODE XREF: sub_496790+120j
                                            ; sub_496790+196j ...
    test    [eax+37EBEh], bl
    jnz     short loc_49697B
    call    sub_495E90
    call    sub_41CE90

    loc_49697B:                             ; CODE XREF: sub_496790+18Ej
                                            ; sub_496790+1DFj
    call    GameUnit_LOS_Sight
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37EBEh]
    test    ah, 8
    jnz     short loc_4969BB
    test    al, 65h
    jnz     short loc_4969BB
    test    byte ptr [ecx+2BEEh], 0E0h
    jnz     short loc_4969BB
    mov     dl, al
    shr     dl, 4
    test    bl, dl
    jz      short loc_4969CB
    and     eax, 0FFEFh
    mov     [ecx+37EBEh], ax
    call    sub_41B2E0
    jmp     short loc_4969CB
    ; ---------------------------------------------------------------------------

    loc_4969BB:                             ; CODE XREF: sub_496790+200j
                                            ; sub_496790+204j ...
    shr     al, 4
    test    bl, al
    jz      short loc_4969CB
    mov     word ptr [ecx+37E9Ch], 0

    loc_4969CB:                             ; CODE XREF: sub_496790+216j
                                            ; sub_496790+229j ...
    push    ebx                             ; int
    push    ebx                             ; int
    call    GameUnit_LOS_Unknown1
    mov     eax, TAdynmemStructPtr
    lea     esi, [eax+38D85h]
    call    GetTickCount
    mov     ebx, [esi]
    mov     edx, [esi+4Ch]
    mov     ecx, eax
    sub     ecx, ebx
    add     edx, ecx
    mov     [esi+4Ch], edx
    mov     [esi], eax
    call    nullsub_53
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38C53h]
    test    ecx, ecx
    jle     short loc_496A4F
    mov     edx, [eax+38C5Bh]
    mov     ecx, [eax+38A47h]
    cmp     edx, ecx
    ja      short loc_496A4F
    add     eax, 38B53h
    push    offset aFram                    ; "FRAM"
    push    eax
    call    sub_4CB170
    mov     ecx, TAdynmemStructPtr
    mov     eax, 1Eh
    cdq
    idiv    dword ptr [ecx+38C57h]
    add     [ecx+38C5Bh], eax
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38A37h], eax

    loc_496A4F:                             ; CODE XREF: sub_496790+274j
                                            ; sub_496790+284j
    call    nullsub_54
    pop     esi
    pop     ebx
    retn
    sub_496790 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h

    loc_496A60:                             ; DATA XREF: sub_490B30+26o
                                            ; sub_491200+417o
    mov     eax, TAdynmemStructPtr
    mov     cl, 13h
    cmp     [eax+2CBEh], cl
    jz      short loc_496A8C
    mov     [eax+2CBEh], cl
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148CBh]
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AB400

    loc_496A8C:                             ; CODE XREF: .text:00496A6Dj
    call    sub_4C2870
    mov     eax, TAdynmemStructPtr
    push    0
    and     word ptr [eax+2A44h], 0FFFBh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+2A44h], 0FFF7h
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+2A44h], 0FFFEh
    call    sub_434AB0
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFFBh
    call    sub_4C1A40
    mov     edx, TAdynmemStructPtr
    push    0
    push    offset loc_4578F0
    mov     dword ptr [edx+391F1h], 2
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+391F5h], offset dword_496BB0
    call    sub_4B4FD0
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_496B10:                             ; DATA XREF: sub_490B30+3Bo
    call    sub_425A90
    mov     eax, TAdynmemStructPtr
    push    0
    and     word ptr [eax+2A44h], 0FFFBh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+2A44h], 0FFF7h
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+2A44h], 0FFFEh
    call    sub_434AB0
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFEFh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+3923Bh], 0FFFBh
    call    sub_4C1A40
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_49FA50
    mov     ecx, TAdynmemStructPtr
    push    0
    push    offset loc_4578F0
    mov     dword ptr [ecx+391F1h], 2
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+391F5h], offset dword_496BB0
    call    sub_4B4FD0
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    dword_496BB0 dd 0F9515BE8h, 2C6E8FFh, 0E8A1FFF9h, 0F600511Dh, 2A4480h, 840F0400h, 82h
                                            ; DATA XREF: sub_490B30+4Do
                                            ; sub_492360+5FBo ...
    dd 91E9888Bh, 29E80003h, 83FFF9E5h, 297501F8h, 2B88FE8h, 1DE8A100h, 80C70051h
    dd 391F1h, 4, 1DE80D8Bh, 81C70051h, 391F5h, 496DB0h, 0A9E9h, 1DE8A100h
    dd 80F60051h, 2A44h, 8B3B7404h, 391E988h, 0E4E2E800h, 0F883FFF9h, 0E8267502h
    dd 2B848h, 1DE8158Bh, 82C70051h, 391F1h, 5, 511DE8A1h, 0F580C700h, 40000391h
    dd 0EB00497Fh, 1DE8A165h, 888A0051h, 2BBEh, 7511F980h, 44888A10h, 0C000002Ah
    dd 0C1F602E9h, 0EB537401h, 10F98021h, 888A4C75h, 2B4Ch, 0F604E9C0h, 3E7401C1h
    dd 2BBF808Ah, 123C0000h, 133C0474h, 0E1E83075h, 8B0002B7h, 511DE815h, 0F182C700h
    dd 3000391h, 0A1000000h, 511DE8h, 91F580C7h, 6CE00003h, 6A0049h, 4578F068h
    dd 0E316E800h, 0B1E80001h, 8B0002B7h, 511DE80Dh, 81006A00h, 519C1h, 51006A00h
    ; ---------------------------------------------------------------------------

    unknown_libname_45:
    call    sub_4AB170
    jmp     sub_4C2870
    ; ---------------------------------------------------------------------------
    align 8

    loc_496CE0:                             ; DATA XREF: sub_490B30+5Fo
    push    ecx
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    push    esi
    mov     cl, [edx+2A42h]
    mov     esi, edx
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 5
    add     eax, ecx
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+eax*2+1B8Ah]
    lea     eax, [esi+eax*2+1B63h]
    test    byte ptr [ecx+97h], 1
    jz      short loc_496D2C
    mov     byte ptr [esp+7], 8
    mov     eax, [eax+4]
    lea     edx, [esp+7]
    push    1
    push    edx
    push    eax
    call    sub_451DF0
    jmp     short loc_496D58
    ; ---------------------------------------------------------------------------

    loc_496D2C:                             ; CODE XREF: .text:00496D13j
    mov     al, [edx+2B4Ch]
    shr     al, 4
    test    al, 1
    jz      short loc_496D87
    call    sub_4B6340
    cmp     dword_51F304, eax
    jnb     short loc_496D58
    call    sub_4B6340
    add     eax, 3Ch
    mov     dword_51F304, eax
    call    sub_456310

    loc_496D58:                             ; CODE XREF: .text:00496D2Aj
                                            ; .text:00496D44j
    mov     ecx, TAdynmemStructPtr
    push    0
    push    offset loc_4578F0
    mov     dword ptr [ecx+391F1h], 5
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+391F5h], offset sub_497F40
    call    sub_4B4FD0
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_496D87:                             ; CODE XREF: .text:00496D37j
    mov     dword ptr [edx+391F1h], 5
    mov     eax, TAdynmemStructPtr
    push    0
    push    offset loc_4578F0
    mov     dword ptr [eax+391F5h], offset sub_497F40
    call    sub_4B4FD0
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_496DB0:                             ; DATA XREF: sub_490B30+71o
    mov     eax, TAdynmemStructPtr
    push    1
    push    0
    mov     word ptr [eax+2A3Ch], 2
    call    sub_464290
    push    2
    push    1
    call    sub_464290
    mov     ecx, TAdynmemStructPtr
    push    0
    push    offset loc_4578F0
    mov     edx, [ecx+1CD5h]
    mov     byte ptr [edx+96h], 1
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+391F1h], 5
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+391F5h], offset sub_497F40
    call    sub_4B4FD0
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    esi
    mov     ecx, [eax]
    mov     [edx+37EF6h], ecx
    mov     ecx, TAdynmemStructPtr
    mov     bl, [eax+0Ch]
    mov     dx, [ecx+14281h]
    and     ebx, 1
    and     edx, 0FFFBh
    shl     ebx, 2
    or      edx, ebx
    mov     [ecx+14281h], dx
    mov     esi, TAdynmemStructPtr
    mov     dl, [eax+4]
    mov     cx, [esi+14281h]
    xor     dl, cl
    and     edx, 1
    xor     edx, ecx
    mov     [esi+14281h], dx
    mov     ecx, TAdynmemStructPtr
    mov     al, [eax+8]
    pop     esi
    mov     dx, [ecx+14281h]
    and     eax, 1
    and     edx, 0FFFDh
    pop     ebx
    shl     eax, 1
    or      edx, eax
    mov     [ecx+14281h], dx
    retn    4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_496E90 proc near                    ; CODE XREF: UpdateDatePlayers+48Fp
                                            ; sub_465E30+112p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_8]
    mov     edx, 0C8h
    mov     [esp+arg_0], ecx
    or      byte ptr [eax+149h], 1
    cmp     ecx, edx
    jge     short loc_496EB0
    mov     [esp+arg_0], edx

    loc_496EB0:                             ; CODE XREF: sub_496E90+1Aj
    fild    [esp+arg_0]
    mov     ecx, [esp+arg_4]
    cmp     ecx, edx
    mov     [esp+arg_0], ecx
    fstp    dword ptr [eax+0DCh]
    jge     short loc_496ECA
    mov     [esp+arg_0], edx

    loc_496ECA:                             ; CODE XREF: sub_496E90+34j
    fild    [esp+arg_0]
    fstp    dword ptr [eax+0E0h]
    retn    0Ch
    sub_496E90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_496EE0 proc near                    ; CODE XREF: sub_497180+7E3p
                                            ; sub_497180+94Dp

    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    Text= byte ptr -80h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 90h
    push    ebx
    push    esi
    mov     esi, [esp+98h+arg_0]
    push    edi
    mov     ecx, esi
    mov     ebx, 0C8h
    shl     ecx, 5
    add     ecx, esi
    lea     eax, [esi+esi*2]
    shl     eax, 3
    lea     ecx, [ecx+ecx*4]
    lea     edi, [esi+ecx*2]
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     ecx, [ecx+edi+TAdynmemStruct.Players.PlayerInfo]
    mov     dl, [edx+eax+4]
    mov     [ecx+95h], dl
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+29A0h]
    mov     ecx, [ecx+edi+TAdynmemStruct.Players.PlayerInfo]
    mov     dl, [edx+eax+14h]
    mov     [ecx+96h], dl
    mov     edx, TAdynmemStructPtr
    lea     ecx, [edx+edi+TAdynmemStruct.Players]
    mov     edx, [edx+29A0h]
    add     eax, edx
    mov     edx, [eax+10h]
    mov     eax, [eax+0Ch]
    or      byte ptr [ecx+149h], 1
    cmp     edx, ebx
    mov     [esp+9Ch+var_90], edx
    jge     short loc_496F70
    mov     [esp+9Ch+var_90], ebx

    loc_496F70:                             ; CODE XREF: sub_496EE0+8Aj
    fild    [esp+9Ch+var_90]
    cmp     eax, ebx
    mov     [esp+9Ch+var_90], eax
    fstp    dword ptr [ecx+0DCh]
    jge     short loc_496F86
    mov     [esp+9Ch+var_90], ebx

    loc_496F86:                             ; CODE XREF: sub_496EE0+A0j
    fild    [esp+9Ch+var_90]
    mov     ebx, [esp+9Ch+arg_4]
    lea     eax, [esp+9Ch+var_8C]
    push    ebx
    push    eax
    fstp    dword ptr [ecx+0E0h]
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+TAdynmemStruct.MapFile]
    call    sub_437320
    test    eax, eax
    jz      short loc_497009
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     eax, [edx+edi+TAdynmemStruct.Players.PlayerInfo]
    mov     cl, [eax+95h]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    lea     edx, [edx+ecx*2+37F5Fh]
    push    edx                             ; char *
    call    sub_488B10
    push    0                               ; int
    push    1                               ; int
    mov     edx, [esp+0A4h+var_8C]
    push    1                               ; int
    sub     esp, 0Ch                        ; int
    mov     ecx, esp
    push    eax                             ; int
    push    esi                             ; int
    mov     [ecx], edx
    mov     edx, [esp+0BCh+var_88]
    mov     [ecx+4], edx
    mov     edx, [esp+0BCh+var_84]
    mov     [ecx+8], edx
    call    sub_485F50
    jmp     short loc_497026
    ; ---------------------------------------------------------------------------

    loc_497009:                             ; CODE XREF: sub_496EE0+D0j
    push    ebx
    lea     eax, [esp+0A0h+Text]
    push    offset aErrorCouldNotF          ; "Error: Could not find start position nu"...
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+9Ch+Text]
    push    ecx                             ; lpText
    call    sub_4B6290

    loc_497026:                             ; CODE XREF: sub_496EE0+127j
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    cmp     esi, edx
    jnz     short loc_497065
    mov     eax, [ecx+37E3Bh]
    push    0                               ; int
    cdq
    sub     eax, edx
    movsx   edx, word ptr [esp+0A0h+var_84+2]
    sar     eax, 1
    sub     edx, eax
    mov     eax, [ecx+37E37h]
    movsx   ecx, word ptr [esp+0A0h+var_8C+2]
    push    edx                             ; MapYScrollingTo
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ecx, eax
    push    ecx                             ; MapXScrollingTo
    call    ScrollMap

    loc_497065:                             ; CODE XREF: sub_496EE0+156j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 90h
    retn    8
    sub_496EE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_497080 proc near

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    mov     edx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    xor     esi, esi
    push    edi
    xor     ebx, ebx
    mov     [esp+1Ch+var_C], esi
    mov     [esp+1Ch+var_8], esi
    xor     edi, edi

    loc_49709B:                             ; CODE XREF: sub_497080+EAj
    cmp     bl, 0Ah
    jnb     loc_49715A
    mov     eax, ebx
    mov     ebp, edx
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+1B63h]
    mov     ecx, [ebp+ecx*2+1B63h]
    test    ecx, ecx
    jz      loc_49715A
    mov     cl, [eax+73h]
    cmp     cl, 1
    jz      short loc_4970E1
    cmp     cl, 2
    jz      short loc_4970E1
    cmp     cl, 3
    jnz     short loc_49715A

    loc_4970E1:                             ; CODE XREF: sub_497080+55j
                                            ; sub_497080+5Aj
    cmp     byte ptr [eax+146h], 0Ah
    jz      short loc_49715A
    mov     eax, [edx+29A0h]
    mov     ebp, [esp+1Ch+var_C]
    add     eax, esi
    mov     ecx, [eax+0Ch]
    cmp     ecx, ebp
    jle     short loc_497103
    mov     ebp, ecx
    mov     [esp+1Ch+var_C], ebp

    loc_497103:                             ; CODE XREF: sub_497080+7Bj
    mov     eax, [eax+10h]
    mov     ecx, [esp+1Ch+var_8]
    cmp     eax, ecx
    jle     short loc_497114
    mov     ecx, eax
    mov     [esp+1Ch+var_8], ecx

    loc_497114:                             ; CODE XREF: sub_497080+8Cj
    or      byte ptr [edx+edi+1CACh], 1
    lea     eax, [edx+edi+1B63h]
    mov     edx, 0C8h
    mov     [esp+1Ch+var_4], ecx
    cmp     ecx, edx
    jge     short loc_497134
    mov     [esp+1Ch+var_4], edx

    loc_497134:                             ; CODE XREF: sub_497080+AEj
    fild    [esp+1Ch+var_4]
    cmp     ebp, edx
    mov     [esp+1Ch+var_4], ebp
    fstp    dword ptr [eax+0DCh]
    jge     short loc_49714A
    mov     [esp+1Ch+var_4], edx

    loc_49714A:                             ; CODE XREF: sub_497080+C4j
    fild    [esp+1Ch+var_4]
    fstp    dword ptr [eax+0E0h]
    mov     edx, TAdynmemStructPtr

    loc_49715A:                             ; CODE XREF: sub_497080+1Ej
                                            ; sub_497080+49j ...
    add     esi, 18h
    inc     ebx
    add     edi, 14Bh
    cmp     esi, 0F0h
    jl      loc_49709B
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_497080 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_497180 proc near                    ; CODE XREF: sub_497C70+31p

    var_4C= dword ptr -4Ch
    PerformanceCount= LARGE_INTEGER ptr -48h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h

    sub     esp, 4Ch
    lea     eax, [esp+4Ch+PerformanceCount]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    eax                             ; lpPerformanceCount
    call    ds:QueryPerformanceCounter
    mov     ecx, dword ptr [esp+5Ch+PerformanceCount]
    mov     edx, dword ptr [esp+5Ch+PerformanceCount+4]
    add     ecx, edx
    push    ecx
    call    sub_4B6CA0
    xor     esi, esi
    push    esi                             ; time_t *
    call    _time
    add     esp, 4
    push    eax                             ; unsigned int
    call    _srand
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    mov     [eax+38A47h], esi
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    dec     eax
    mov     edi, 1
    jz      loc_49745C
    dec     eax
    jz      loc_4973C1
    dec     eax
    jnz     loc_4974E3
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+37EECh]
    mov     [eax+37EE6h], dx
    mov     eax, TAdynmemStructPtr
    mov     dword_5091CC, edi
    and     word ptr [eax+38A51h], 0FFFEh
    call    sub_456850
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    and     eax, 0FFh
    mov     edi, ecx
    mov     dl, [ecx+2A42h]
    mov     esi, eax
    mov     eax, edx
    add     edi, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    test    byte ptr [edi+eax*2+1B84h], 2
    jz      short loc_4972BA
    jmp     short loc_49724D
    ; ---------------------------------------------------------------------------

    loc_497247:                             ; CODE XREF: sub_497180+118j
                                            ; sub_497180+121j ...
    mov     ecx, TAdynmemStructPtr

    loc_49724D:                             ; CODE XREF: sub_497180+C5j
    xor     edx, edx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     edi, [ecx+eax*2+1B8Ah]
    mov     eax, dword_506DBC
    test    eax, eax
    jz      short loc_49727D
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_49727D:                             ; CODE XREF: sub_497180+EFj
    call    Network_Process
    call    sub_456850
    and     eax, 0FFh
    push    32h                             ; dwMilliseconds
    mov     esi, eax
    call    sub_4B6B50
    cmp     esi, 0Ah
    jz      short loc_497247
    cmp     byte ptr [edi+96h], 0FFh
    jz      short loc_497247
    mov     al, [edi+8Fh]
    test    al, al
    jz      short loc_497247
    push    32h                             ; dwMilliseconds
    call    sub_4B6B50
    mov     ecx, TAdynmemStructPtr

    loc_4972BA:                             ; CODE XREF: sub_497180+C3j
    mov     eax, esi
    shl     eax, 5
    add     eax, esi
    lea     edx, [eax+eax*4]
    mov     eax, ecx
    mov     ecx, [ecx+391E9h]
    add     eax, esi
    mov     edx, [eax+edx*2+1B8Ah]
    push    edx
    call    sub_435A20
    call    sub_456850
    cmp     al, 0Ah
    jz      loc_4974E3
    call    sub_456850
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFh
    mov     ecx, eax
    mov     esi, edx
    shl     eax, 5
    add     eax, ecx
    add     esi, ecx
    xor     ebx, ebx
    lea     eax, [eax+eax*4]
    mov     eax, [esi+eax*2+1B8Ah]
    mov     cx, [eax+9Bh]
    shr     ecx, 0Dh
    and     ecx, 1
    mov     dword_5091CC, ecx
    mov     cx, [eax+9Bh]
    shr     ecx, 0Bh
    and     ecx, 3
    mov     [edx+37EF6h], ecx
    mov     ecx, TAdynmemStructPtr
    mov     bl, [eax+9Ch]
    mov     dx, [ecx+14281h]
    and     ebx, 2
    and     edx, 0FFFDh
    or      edx, ebx
    xor     ebx, ebx
    mov     [ecx+14281h], dx
    mov     ecx, TAdynmemStructPtr
    mov     bl, [eax+9Ch]
    mov     dx, [ecx+14281h]
    and     ebx, 4
    and     edx, 0FFFBh
    or      edx, ebx
    xor     ebx, ebx
    mov     [ecx+14281h], dx
    mov     ecx, TAdynmemStructPtr
    mov     bl, [eax+9Ch]
    mov     dx, [ecx+14281h]
    and     ebx, 1
    and     edx, 0FFFEh
    or      edx, ebx
    mov     [ecx+14281h], dx
    mov     ecx, TAdynmemStructPtr
    mov     ax, [eax+0A5h]
    mov     [ecx+37EE6h], ax
    jmp     loc_4974E3
    ; ---------------------------------------------------------------------------

    loc_4973C1:                             ; CODE XREF: sub_497180+5Fj
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+37EECh]
    mov     [eax+37EE6h], dx
    mov     ecx, TAdynmemStructPtr
    mov     dword_5091CC, edi
    mov     eax, [ecx+29A0h]
    add     eax, 108h
    mov     edx, [eax]
    mov     [ecx+37EF6h], edx
    mov     ecx, TAdynmemStructPtr
    mov     bl, [eax+0Ch]
    mov     dx, [ecx+14281h]
    and     ebx, edi
    and     edx, 0FFFBh
    shl     ebx, 2
    or      edx, ebx
    mov     [ecx+14281h], dx
    mov     esi, TAdynmemStructPtr
    mov     dl, [eax+4]
    mov     cx, [esi+14281h]
    xor     dl, cl
    and     edx, edi
    xor     edx, ecx
    mov     [esi+14281h], dx
    mov     ecx, TAdynmemStructPtr
    mov     al, [eax+8]
    mov     dx, [ecx+14281h]
    and     eax, edi
    and     edx, 0FFFDh
    shl     eax, 1
    or      edx, eax
    mov     [ecx+14281h], dx
    jmp     loc_4974E3
    ; ---------------------------------------------------------------------------

    loc_49745C:                             ; CODE XREF: sub_497180+58j
    mov     ecx, TAdynmemStructPtr
    mov     dword_5091CC, esi
    mov     edx, [ecx+39219h]
    lea     eax, [ecx+39219h]
    mov     [ecx+37EF6h], edx
    mov     ecx, TAdynmemStructPtr
    mov     bl, [eax+0Ch]
    mov     dx, [ecx+14281h]
    and     ebx, edi
    and     edx, 0FFFBh
    shl     ebx, 2
    or      edx, ebx
    mov     [ecx+14281h], dx
    mov     esi, TAdynmemStructPtr
    mov     dl, [eax+4]
    mov     cx, [esi+14281h]
    xor     dl, cl
    and     edx, edi
    xor     edx, ecx
    mov     [esi+14281h], dx
    mov     ecx, TAdynmemStructPtr
    mov     al, [eax+8]
    mov     dx, [ecx+14281h]
    and     eax, edi
    and     edx, 0FFFDh
    shl     eax, 1
    or      edx, eax
    mov     [ecx+14281h], dx
    call    sub_431740

    loc_4974E3:                             ; CODE XREF: sub_497180+66j
                                            ; sub_497180+162j ...
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+38D6Bh]
    test    ecx, ecx
    jz      loc_497581
    push    offset aSummary                 ; char *
    call    sub_4B4560
    mov     edx, TAdynmemStructPtr
    push    offset aBetweenmission          ; char *
    mov     ecx, [edx+38D6Bh]
    call    sub_4B48F0
    test    eax, eax
    jnz     short loc_497581
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38D6Bh]
    push    ecx
    call    sub_465FB0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 2
    jnz     short loc_497581
    mov     edi, TAdynmemStructPtr
    xor     esi, esi
    xor     eax, eax
    mov     edx, [edi+29A0h]

    loc_497552:                             ; CODE XREF: sub_497180+3E8j
    mov     ecx, [edx]
    cmp     ecx, 1
    jz      short loc_49755E
    cmp     ecx, 2
    jnz     short loc_497561

    loc_49755E:                             ; CODE XREF: sub_497180+3D7j
    lea     esi, [eax+1]

    loc_497561:                             ; CODE XREF: sub_497180+3DCj
    inc     eax
    add     edx, 18h
    cmp     eax, 0Ah
    jl      short loc_497552
    mov     eax, [edi+38D81h]
    cmp     esi, eax
    jle     short loc_497576
    mov     eax, esi

    loc_497576:                             ; CODE XREF: sub_497180+3F2j
    mov     [edi+38D81h], eax
    call    sub_47A760

    loc_497581:                             ; CODE XREF: sub_497180+371j
                                            ; sub_497180+399j ...
    call    sub_4917D0
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 1
    jz      loc_497AE3
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     loc_4978DA
    mov     eax, TAdynmemStructPtr
    mov     bl, 8
    mov     dx, [eax+38D75h]
    or      edx, 4
    mov     [eax+38D75h], dx
    mov     eax, TAdynmemStructPtr
    test    [eax+38D75h], bl
    jnz     short loc_4975F3

    loc_4975DE:                             ; CODE XREF: sub_497180+471j
    push    32h                             ; dwMilliseconds
    call    sub_4B6B50
    mov     ecx, TAdynmemStructPtr
    test    [ecx+38D75h], bl
    jz      short loc_4975DE

    loc_4975F3:                             ; CODE XREF: sub_497180+45Cj
    call    sub_456850
    and     eax, 0FFh
    mov     ecx, eax
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    mov     esi, eax
    add     esi, ecx
    mov     cx, [eax+14281h]
    and     ecx, 0FFFEh
    mov     ebp, [esi+edx*2+1B8Ah]
    xor     edx, edx
    mov     dl, [ebp+9Ch]
    and     edx, 1
    or      ecx, edx
    xor     edx, edx
    mov     [eax+14281h], cx
    mov     eax, TAdynmemStructPtr
    mov     dl, [ebp+9Ch]
    mov     cx, [eax+14281h]
    and     edx, 2
    and     ecx, 0FFFDh
    or      ecx, edx
    xor     edx, edx
    mov     [eax+14281h], cx
    mov     eax, TAdynmemStructPtr
    mov     dl, [ebp+9Ch]
    mov     cx, [eax+14281h]
    and     edx, 4
    and     ecx, 0FFFBh
    or      ecx, edx
    mov     [eax+14281h], cx
    mov     ax, [ebp+9Bh]
    mov     ecx, TAdynmemStructPtr
    shr     eax, 0Bh
    and     eax, 3
    xor     ebx, ebx
    mov     [ecx+37EF6h], eax
    mov     ecx, TAdynmemStructPtr

    loc_4976A5:                             ; CODE XREF: sub_497180+6B8j
    mov     eax, [ecx+ebx+1B63h]
    lea     esi, [ecx+ebx+1B63h]
    test    eax, eax
    jz      loc_49782C
    mov     al, [esi+73h]
    cmp     al, 1
    jz      short loc_4976CA
    cmp     al, 2
    jnz     loc_49782C

    loc_4976CA:                             ; CODE XREF: sub_497180+540j
    mov     edx, [ecx+14223h]
    sub     edx, 0A0h
    push    edx                             ; int
    call    GetRandom
    add     eax, 50h
    mov     [esp+5Ch+var_3C], 0
    shl     eax, 10h
    mov     [esp+5Ch+var_40], eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14227h]
    sub     ecx, 0A0h
    push    ecx                             ; int
    call    GetRandom
    add     eax, 50h
    shl     eax, 10h
    mov     [esp+5Ch+var_38], eax
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_497725
    mov     edx, [esi+27h]
    test    byte ptr [edx+9Bh], 40h
    jnz     loc_497826

    loc_497725:                             ; CODE XREF: sub_497180+593j
    mov     eax, [esi+27h]
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax+95h]
    mov     dl, [esi+147h]
    mov     edi, ecx
    mov     ecx, TAdynmemStructPtr
    lea     eax, [esp+5Ch+var_40]
    push    edx
    mov     ecx, [ecx+391E9h]
    push    eax
    call    sub_437320
    cmp     dword ptr [esi], 0
    jz      short loc_497774
    cmp     byte ptr [esi+73h], 1
    jnz     short loc_497774
    mov     edx, [esp+5Ch+var_40]
    mov     eax, [esp+5Ch+var_3C]
    mov     ecx, [esp+5Ch+var_38]
    mov     [esp+5Ch+var_34], edx
    mov     [esp+5Ch+var_30], eax
    mov     [esp+5Ch+var_2C], ecx

    loc_497774:                             ; CODE XREF: sub_497180+5D4j
                                            ; sub_497180+5DAj
    mov     eax, edi
    mov     ecx, TAdynmemStructPtr
    shl     eax, 3
    sub     eax, edi
    lea     edx, [eax+eax*4]
    lea     eax, [edi+edx*8]
    lea     edx, [ecx+eax*2+37F5Fh]
    push    edx                             ; char *
    call    sub_488B10
    mov     edx, [esp+5Ch+var_40]
    push    0                               ; int
    push    1                               ; int
    push    1                               ; int
    sub     esp, 0Ch                        ; int
    mov     ecx, esp
    push    eax                             ; int
    mov     al, [esi+146h]
    mov     [ecx], edx
    mov     edx, [esp+78h+var_3C]
    push    eax                             ; int
    mov     [ecx+4], edx
    mov     edx, [esp+7Ch+var_38]
    mov     [ecx+8], edx
    call    sub_485F50
    xor     eax, eax
    mov     ax, [ebp+0A1h]
    lea     eax, [eax+eax*4]
    lea     ecx, [eax+eax*4]
    xor     eax, eax
    mov     ax, [ebp+0A3h]
    or      byte ptr [esi+149h], 1
    shl     ecx, 2
    lea     eax, [eax+eax*4]
    mov     [esp+5Ch+var_4C], ecx
    lea     eax, [eax+eax*4]
    shl     eax, 2
    cmp     ecx, 0C8h
    jge     short loc_4977FF
    mov     [esp+5Ch+var_4C], 0C8h

    loc_4977FF:                             ; CODE XREF: sub_497180+675j
    fild    [esp+5Ch+var_4C]
    cmp     eax, 0C8h
    mov     [esp+5Ch+var_4C], eax
    fstp    dword ptr [esi+0DCh]
    jge     short loc_49781C
    mov     [esp+5Ch+var_4C], 0C8h

    loc_49781C:                             ; CODE XREF: sub_497180+692j
    fild    [esp+5Ch+var_4C]
    fstp    dword ptr [esi+0E0h]

    loc_497826:                             ; CODE XREF: sub_497180+59Fj
    mov     ecx, TAdynmemStructPtr

    loc_49782C:                             ; CODE XREF: sub_497180+535j
                                            ; sub_497180+544j
    add     ebx, 14Bh
    cmp     ebx, 0CEEh
    jl      loc_4976A5
    xor     edx, edx
    mov     esi, ecx
    mov     dl, [ecx+2A42h]
    mov     eax, edx
    add     esi, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    mov     edx, [esi+eax*2+1B8Ah]
    mov     al, [edx+9Bh]
    shr     al, 6
    test    al, 1
    jz      short loc_49789F
    and     word ptr [ecx+14281h], 0FFFEh
    mov     eax, TAdynmemStructPtr
    and     word ptr [eax+14281h], 0FFFDh
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+37E37h]
    cdq
    sub     eax, edx
    mov     esi, eax
    mov     eax, [ecx+37E3Bh]
    cdq
    sub     eax, edx
    sar     esi, 1
    sar     eax, 1
    jmp     short loc_4978C5
    ; ---------------------------------------------------------------------------

    loc_49789F:                             ; CODE XREF: sub_497180+6E6j
    mov     eax, [ecx+37E37h]
    movsx   esi, word ptr [esp+5Ch+var_34+2]
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     esi, eax
    mov     eax, [ecx+37E3Bh]
    cdq
    sub     eax, edx
    mov     ecx, eax
    movsx   eax, word ptr [esp+5Ch+var_2C+2]
    sar     ecx, 1
    sub     eax, ecx

    loc_4978C5:                             ; CODE XREF: sub_497180+71Dj
    push    0                               ; int
    push    eax                             ; MapYScrollingTo
    push    esi                             ; MapXScrollingTo
    call    ScrollMap
    push    6
    call    RIWrapper_Report
    jmp     loc_497AE3
    ; ---------------------------------------------------------------------------

    loc_4978DA:                             ; CODE XREF: sub_497180+433j
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 2
    jnz     loc_497AE3
    mov     esi, TAdynmemStructPtr
    mov     eax, [esi+38D6Bh]
    test    eax, eax
    jnz     loc_497AE3
    mov     eax, [esi+29A0h]
    mov     ecx, [eax+118h]
    test    ecx, ecx
    jz      short loc_497979
    xor     ebx, ebx

    loc_49791A:                             ; CODE XREF: sub_497180+7F2j
    cmp     bl, 0Ah
    jnb     short loc_49796E
    mov     eax, ebx
    mov     edx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+TAdynmemStruct.Players]
    mov     ecx, [edx+ecx*2+TAdynmemStruct.Players.PlayerActive]
    test    ecx, ecx
    jz      short loc_49796E
    mov     cl, [eax+73h]
    cmp     cl, Player_LocalHuman
    jz      short loc_497958
    cmp     cl, Player_AI
    jz      short loc_497958
    cmp     cl, Player_RemoteHuman
    jnz     short loc_49796E

    loc_497958:                             ; CODE XREF: sub_497180+7CCj
                                            ; sub_497180+7D1j
    cmp     byte ptr [eax+146h], 0Ah
    jz      short loc_49796E
    push    ebx
    push    ebx
    call    sub_496EE0
    mov     esi, TAdynmemStructPtr

    loc_49796E:                             ; CODE XREF: sub_497180+79Dj
                                            ; sub_497180+7C4j ...
    inc     ebx
    cmp     ebx, 0Ah
    jl      short loc_49791A
    jmp     loc_497ADE
    ; ---------------------------------------------------------------------------

    loc_497979:                             ; CODE XREF: sub_497180+796j
    mov     ecx, 0Ah
    or      eax, 0FFFFFFFFh
    lea     edi, [esp+5Ch+var_28]
    xor     ebx, ebx
    rep stosd
    xor     edx, edx
    lea     edi, [esp+5Ch+var_28]

    loc_49798F:                             ; CODE XREF: sub_497180+860j
    cmp     dl, 0Ah
    jnb     short loc_4979DC
    mov     eax, edx
    mov     ebp, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     ebp, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [ebp+ecx*2+TAdynmemStruct.Players]
    mov     ecx, [ebp+ecx*2+TAdynmemStruct.Players.PlayerActive]
    test    ecx, ecx
    jz      short loc_4979DC
    mov     cl, [eax+73h]
    cmp     cl, Player_LocalHuman
    jz      short loc_4979CD
    cmp     cl, Player_AI
    jz      short loc_4979CD
    cmp     cl, Player_RemoteHuman
    jnz     short loc_4979DC

    loc_4979CD:                             ; CODE XREF: sub_497180+841j
                                            ; sub_497180+846j
    cmp     [eax+PlayerStruct.PlayerNumber], 0Ah
    jz      short loc_4979DC
    mov     [edi], edx
    inc     ebx
    add     edi, 4

    loc_4979DC:                             ; CODE XREF: sub_497180+812j
                                            ; sub_497180+839j ...
    inc     edx
    cmp     edx, 0Ah
    jl      short loc_49798F
    cmp     ebx, 2
    jg      short loc_497A10
    call    _rand
    cdq
    push    0
    push    2
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    test    eax, eax
    jz      short loc_497A73
    mov     esi, TAdynmemStructPtr

    loc_497A10:                             ; CODE XREF: sub_497180+865j
    lea     ebx, [esp+ebx*4+5Ch+var_28]
    lea     edx, [esp+5Ch+var_28]
    cmp     edx, ebx
    jz      short loc_497A79
    lea     eax, [esp+5Ch+var_24]
    mov     edi, 1
    cmp     eax, ebx
    lea     ebp, [esp+5Ch+var_24]
    jz      short loc_497A79

    loc_497A2D:                             ; CODE XREF: sub_497180+8F1j
    mov     esi, 7FFFh
    call    _rand
    and     eax, esi
    cmp     edi, esi
    jbe     short loc_497A57

    loc_497A3D:                             ; CODE XREF: sub_497180+8D5j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_497A57
    shl     esi, 0Fh
    shl     eax, 0Fh
    or      esi, 7FFFh
    or      eax, 7FFFh
    cmp     esi, edi
    jb      short loc_497A3D

    loc_497A57:                             ; CODE XREF: sub_497180+8BBj
                                            ; sub_497180+8C0j
    xor     edx, edx
    mov     ecx, [ebp+0]
    div     edi
    add     ebp, 4
    inc     edi
    cmp     ebp, ebx
    lea     eax, [esp+edx*4+5Ch+var_28]
    mov     edx, [esp+edx*4+5Ch+var_28]
    mov     [ebp-4], edx
    mov     [eax], ecx
    jnz     short loc_497A2D

    loc_497A73:                             ; CODE XREF: sub_497180+888j
    mov     esi, TAdynmemStructPtr

    loc_497A79:                             ; CODE XREF: sub_497180+89Aj
                                            ; sub_497180+8ABj
    xor     ebx, ebx
    lea     edi, [esp+5Ch+var_28]

    loc_497A7F:                             ; CODE XREF: sub_497180+95Cj
    cmp     bl, 0Ah
    jnb     short loc_497AD8
    mov     eax, ebx
    mov     edx, esi
    and     eax, 0FFh
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 5
    add     ecx, eax
    lea     ecx, [ecx+ecx*4]
    lea     eax, [edx+ecx*2+1B63h]
    mov     ecx, [edx+ecx*2+1B63h]
    test    ecx, ecx
    jz      short loc_497AD8
    mov     cl, [eax+73h]
    cmp     cl, Player_LocalHuman
    jz      short loc_497ABD
    cmp     cl, Player_AI
    jz      short loc_497ABD
    cmp     cl, Player_RemoteHuman
    jnz     short loc_497AD8

    loc_497ABD:                             ; CODE XREF: sub_497180+931j
                                            ; sub_497180+936j
    cmp     [eax+PlayerStruct.PlayerNumber], 0Ah
    jz      short loc_497AD8
    mov     eax, [edi]
    add     edi, 4
    push    eax
    push    ebx
    call    sub_496EE0
    mov     esi, TAdynmemStructPtr

    loc_497AD8:                             ; CODE XREF: sub_497180+902j
                                            ; sub_497180+929j ...
    inc     ebx
    cmp     ebx, 0Ah
    jl      short loc_497A7F

    loc_497ADE:                             ; CODE XREF: sub_497180+7F4j
    call    sub_465E30

    loc_497AE3:                             ; CODE XREF: sub_497180+419j
                                            ; sub_497180+755j ...
    push    1                               ; int
    call    Set_LOS_State
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38D6Bh]
    test    ecx, ecx
    jz      short loc_497B30
    push    offset aSummary                 ; char *
    call    sub_4B4560
    mov     eax, TAdynmemStructPtr
    push    offset aBetweenmission          ; char *
    mov     ecx, [eax+38D6Bh]
    call    sub_4B48F0
    test    eax, eax
    jnz     short loc_497B40
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+38D6Bh]
    push    edx
    call    sub_432610
    jmp     short loc_497B4A
    ; ---------------------------------------------------------------------------

    loc_497B30:                             ; CODE XREF: sub_497180+977j
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     short loc_497B4A

    loc_497B40:                             ; CODE XREF: sub_497180+99Aj
    call    sub_488310
    call    sub_41D1F0

    loc_497B4A:                             ; CODE XREF: sub_497180+9AEj
                                            ; sub_497180+9BEj
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    push    0
    push    0
    mov     dl, [ecx+TAdynmemStruct.LOS_Sight]
    push    0
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    push    0
    lea     eax, [eax+eax*4]
    lea     esi, [ecx+eax*2+TAdynmemStruct.Players]
    call    sub_4288D0
    mov     ecx, [esi+27h]
    xor     edx, edx
    mov     dl, [ecx+95h]
    mov     ecx, edx
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*8]
    mov     eax, TAdynmemStructPtr
    lea     edx, [eax+ecx*2+37F5Bh]
    add     eax, 37EA0h
    push    edx
    push    offset aSmain2_gui              ; "%sMAIN2.GUI"
    push    eax
    call    _sprintf
    mov     eax, TAdynmemStructPtr
    add     esp, 0Ch
    lea     ecx, [eax+37EA0h]
    push    20h
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AA8F0
    mov     dword ptr [eax+8], offset loc_494890
    mov     edx, TAdynmemStructPtr
    mov     [eax+0Ch], edx
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [ecx+TAdynmemStruct.SharedBits]
    mov     eax, edx
    add     ecx, edx
    shl     eax, 5
    add     eax, edx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+eax*2+TAdynmemStruct.Players]
    mov     eax, [ecx+27h]
    or      byte ptr [eax+9Bh], 10h
    call    sub_450F90
    call    sub_451180
    call    UpdateDatePlayers
    call    sub_465E30
    mov     ecx, TAdynmemStructPtr
    mov     esi, [ecx+38D6Bh]
    test    esi, esi
    jz      short loc_497C4A
    mov     ecx, esi
    call    sub_4B3630
    push    esi
    call    sub_4B4F20
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     dword ptr [edx+38D6Bh], 0

    loc_497C4A:                             ; CODE XREF: sub_497180+AA8j
    call    sub_4649D0
    mov     eax, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     cx, [eax+38D75h]
    pop     ebx
    or      ecx, 2
    mov     [eax+38D75h], cx
    add     esp, 4Ch
    retn
    sub_497180 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_497C70 proc near                    ; DATA XREF: sub_497F40+385o

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_4= dword ptr -4
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset stru_4FDA48
    push    offset __except_handler3
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    sub     esp, 8
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_18], esp
    mov     [ebp+var_4], 0
    mov     eax, [ebp+arg_0]
    push    eax
    call    sub_497180
    add     esp, 4
    jmp     short loc_497CBD
    ; ---------------------------------------------------------------------------

    loc_497CAB:                             ; DATA XREF: .rdata:004FDA48o
    push    offset aLoadThread              ; "Load Thread"
    mov     ecx, [ebp+var_14]
    push    ecx
    call    sub_4CBAB0
    retn
    ; ---------------------------------------------------------------------------

    loc_497CBA:                             ; DATA XREF: .rdata:004FDA48o
    mov     esp, [ebp+var_18]

    loc_497CBD:                             ; CODE XREF: sub_497C70+39j
    mov     [ebp+var_4], 0FFFFFFFFh
    mov     ecx, [ebp+var_10]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    sub_497C70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_497CE0 proc near                    ; CODE XREF: sub_497F40+D59p

    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    sub     esp, 98h
    add     eax, 519h
    push    ebx
    push    edi
    push    40h
    push    eax
    call    sub_4A81E0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_49FAD0
    mov     edx, TAdynmemStructPtr
    xor     ebx, ebx
    push    ebx
    add     edx, 519h
    push    ebx
    push    edx
    call    sub_4AB170
    mov     edi, TAdynmemStructPtr
    mov     al, [edi+38D75h]
    shr     al, 3
    test    al, 1
    jz      short loc_497D44
    push    offset aSynchronizatio          ; int
    call    sub_4C5740
    jmp     loc_497F0F
    ; ---------------------------------------------------------------------------

    loc_497D44:                             ; CODE XREF: sub_497CE0+53j
    push    esi
    push    ebp
    mov     [esp+0A8h+var_98], ebx
    mov     [esp+0A8h+var_94], ebx
    lea     esi, [edi+29A4h]
    lea     eax, [edi+1BD6h]
    mov     ebp, 0Ah

    loc_497D5F:                             ; CODE XREF: sub_497CE0+D7j
    mov     edx, [eax-73h]
    test    edx, edx
    jz      short loc_497DAE
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_497D77
    cmp     cl, 2
    jz      short loc_497D77
    cmp     cl, 3
    jnz     short loc_497D84

    loc_497D77:                             ; CODE XREF: sub_497CE0+8Bj
                                            ; sub_497CE0+90j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_497D84
    inc     [esp+0A8h+var_98]

    loc_497D84:                             ; CODE XREF: sub_497CE0+95j
                                            ; sub_497CE0+9Ej
    test    edx, edx
    jz      short loc_497DAE
    mov     cl, [eax]
    cmp     cl, 1
    jz      short loc_497D99
    cmp     cl, 2
    jz      short loc_497D99
    cmp     cl, 3
    jnz     short loc_497DAE

    loc_497D99:                             ; CODE XREF: sub_497CE0+ADj
                                            ; sub_497CE0+B2j
    cmp     byte ptr [eax+0D3h], 0Ah
    jz      short loc_497DAE
    cmp     byte ptr [eax-53h], 64h
    jnz     short loc_497DAE
    cmp     dword ptr [esi], 0
    jz      short loc_497DAE
    inc     ebx

    loc_497DAE:                             ; CODE XREF: sub_497CE0+84j
                                            ; sub_497CE0+A6j ...
    add     esi, 4
    add     eax, 14Bh
    dec     ebp
    jnz     short loc_497D5F
    mov     eax, 26Ch
    mov     [esp+0A8h+var_94], ebx
    cdq
    idiv    [esp+0A8h+var_98]
    xor     ecx, ecx
    mov     [esp+0A8h+var_90], 0Ah
    mov     [esp+0A8h+var_8C], 1A4h
    mov     [esp+0A8h+var_84], 1B3h
    mov     [esp+0A8h+var_98], ecx
    mov     esi, 0Bh
    mov     ebx, eax

    loc_497DEC:                             ; CODE XREF: sub_497CE0+1EAj
    mov     eax, [edi+ecx+1B63h]
    lea     ebp, [edi+ecx+1B63h]
    test    eax, eax
    jz      loc_497EBA
    mov     al, [ebp+73h]
    cmp     al, 1
    jz      short loc_497E15
    cmp     al, 2
    jz      short loc_497E15
    cmp     al, 3
    jnz     loc_497EBA

    loc_497E15:                             ; CODE XREF: sub_497CE0+127j
                                            ; sub_497CE0+12Bj
    cmp     byte ptr [ebp+146h], 0Ah
    jz      loc_497EBA
    lea     ecx, [ebx+esi-2]
    xor     edx, edx
    mov     [esp+0A8h+var_90], esi
    mov     [esp+0A8h+var_88], ecx
    mov     dl, [edi+0DCFh]
    mov     ecx, [esp+0A8h+arg_0]
    lea     eax, [esp+0A8h+var_90]
    push    edx
    push    eax
    push    ecx
    call    sub_4BF6F0
    xor     ecx, ecx
    lea     edi, [ebx-2]
    mov     cl, [ebp+20h]
    mov     eax, 51EB851Fh
    imul    ecx, edi
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    xor     ecx, ecx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, [esp+0A8h+var_90]
    add     edx, eax
    lea     eax, [esp+0A8h+var_90]
    mov     [esp+0A8h+var_88], edx
    mov     edx, TAdynmemStructPtr
    mov     cl, [edx+0DD5h]
    push    ecx
    mov     ecx, [esp+0ACh+arg_0]
    push    eax
    push    ecx
    call    sub_4BF6F0
    push    0
    push    edi
    mov     edx, [esp+0B0h+var_90]
    mov     eax, [esp+0B0h+arg_0]
    push    1A4h
    add     ebp, 2Bh
    push    edx
    push    ebp
    push    eax
    call    sub_4A50E0
    mov     edi, TAdynmemStructPtr
    add     esi, ebx
    mov     ecx, [esp+0A8h+var_98]

    loc_497EBA:                             ; CODE XREF: sub_497CE0+11Cj
                                            ; sub_497CE0+12Fj ...
    add     ecx, 14Bh
    cmp     ecx, 0CEEh
    mov     [esp+0A8h+var_98], ecx
    jl      loc_497DEC
    mov     esi, [esp+0A8h+var_94]
    cmp     esi, 1
    jnz     short loc_497EE0
    push    offset aPlayerReady             ; "player ready"
    jmp     short loc_497EE5
    ; ---------------------------------------------------------------------------

    loc_497EE0:                             ; CODE XREF: sub_497CE0+1F7j
    push    offset aPlayersReady            ; int

    loc_497EE5:                             ; CODE XREF: sub_497CE0+1FEj
    call    sub_4C5740
    push    eax
    push    esi
    push    offset aWaitingForOthe          ; int
    call    sub_4C5740
    push    eax
    lea     ecx, [esp+0B4h+var_80]
    push    offset aS_IS                    ; "%s.  %i %s"
    push    ecx
    call    _sprintf
    add     esp, 14h
    lea     eax, [esp+0A8h+var_80]
    pop     ebp
    pop     esi

    loc_497F0F:                             ; CODE XREF: sub_497CE0+5Fj
    mov     edx, [esp+0A0h+arg_0]
    push    0
    push    0FFFFFFFFh
    push    190h
    push    0Ah
    push    eax
    push    edx
    call    sub_4A50E0
    pop     edi
    pop     ebx
    add     esp, 98h
    retn    4
    sub_497CE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_497F40 proc near                    ; DATA XREF: sub_490B30+83o
                                            ; .text:00496D75o ...

    var_234= dword ptr -234h
    var_230= dword ptr -230h
    var_22C= dword ptr -22Ch
    var_228= dword ptr -228h
    var_221= byte ptr -221h
    var_220= dword ptr -220h
    var_21C= dword ptr -21Ch
    var_1F0= dword ptr -1F0h
    var_1EC= qword ptr -1ECh
    MultiByteStr= dword ptr -1E4h
    var_181= byte ptr -181h
    var_180= byte ptr -180h
    var_100= dword ptr -100h

    mov     eax, TAdynmemStructPtr
    sub     esp, 234h
    mov     cl, [eax+38D75h]
    push    ebx
    push    ebp
    push    esi
    test    cl, 1
    push    edi
    jnz     loc_498340
    mov     ecx, [eax+531h]
    xor     ebp, ebp
    cmp     ecx, ebp
    jz      short loc_497F82

    loc_497F6A:                             ; CODE XREF: sub_497F40+40j
    add     eax, 519h
    push    eax
    call    sub_4A9660
    mov     eax, TAdynmemStructPtr
    cmp     [eax+531h], ebp
    jnz     short loc_497F6A

    loc_497F82:                             ; CODE XREF: sub_497F40+28j
    add     eax, 519h
    push    eax
    call    sub_49FA70
    mov     eax, TAdynmemStructPtr
    mov     cl, 14h
    cmp     [eax+2CBEh], cl
    jz      short loc_497FBE
    mov     [eax+2CBEh], cl
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148CFh]
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AB400
    mov     eax, TAdynmemStructPtr

    loc_497FBE:                             ; CODE XREF: sub_497F40+5Aj
    mov     edx, [eax+391F9h]
    push    edx
    call    sub_4C1420
    mov     eax, TAdynmemStructPtr
    push    100h
    add     eax, 143A7h
    push    ebp
    push    eax
    call    sub_4BA200
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 2
    jz      short loc_497FFB
    call    WriteRegistrySettings_2

    loc_497FFB:                             ; CODE XREF: sub_497F40+B4j
    mov     eax, TAdynmemStructPtr
    cmp     [eax+531h], ebp
    jz      short loc_498020

    loc_498008:                             ; CODE XREF: sub_497F40+DEj
    add     eax, 519h
    push    eax
    call    sub_4A9660
    mov     eax, TAdynmemStructPtr
    cmp     [eax+531h], ebp
    jnz     short loc_498008

    loc_498020:                             ; CODE XREF: sub_497F40+C6j
    call    sub_4257A0
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+37E1Fh], 280h
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37E23h], 1E0h
    call    sub_4B6700
    cmp     eax, 280h
    jnz     short loc_498060
    call    sub_4B6710
    cmp     eax, 1E0h
    jz      loc_498109

    loc_498060:                             ; CODE XREF: sub_497F40+10Ej
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37E1Bh]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, TAdynmemStructPtr
    add     esp, 4
    push    ebp
    mov     [eax+37E1Bh], ebp
    call    sub_4C61F0
    call    sub_4C62C0
    mov     ecx, TAdynmemStructPtr
    push    4                               ; uFlags
    push    1E0h                            ; cy
    push    280h                            ; cx
    mov     edx, [ecx+0Ch]
    push    ebp                             ; Y
    push    ebp                             ; X
    push    ebp                             ; hWndInsertAfter
    mov     eax, [edx+40h]
    push    eax                             ; hWnd
    call    ds:SetWindowPos
    push    1E0h
    push    280h
    call    sub_4B5940
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E23h]
    mov     edx, [eax+37E1Fh]
    push    ecx                             ; int
    push    edx                             ; int
    push    offset aOffscreen               ; int
    call    sub_4C69F0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E1Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C61F0
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+37E1Bh]
    push    edx
    call    sub_4C69A0

    loc_498109:                             ; CODE XREF: sub_497F40+11Aj
    push    offset off_5031D0
    push    offset aGuipal                  ; "guipal"
    lea     eax, [esp+24Ch+var_100]
    push    offset aPalettes                ; "palettes"
    push    eax
    call    sub_4290F0
    lea     ecx, [esp+244h+var_100]
    push    ebp
    push    ecx
    call    sub_4BBE50
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    push    esi
    lea     edx, [eax+143A7h]
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4AC7D0
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    ebp
    push    ebp
    mov     [ecx+38A37h], eax
    mov     edx, TAdynmemStructPtr
    push    offset aLoadgame2bg             ; "loadgame2bg"
    mov     [edx+38A3Bh], ebp
    mov     eax, TAdynmemStructPtr
    mov     [eax+38A47h], ebp
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38A4Fh], bp
    mov     edx, TAdynmemStructPtr
    mov     word ptr [edx+39239h], 0FFFFh
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F1Bh]
    mov     [eax+37E1Fh], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37F1Fh]
    mov     [eax+37E23h], edx
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+37E27h], 80h
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+37E2Bh], 20h
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37E1Fh]
    dec     edx
    mov     [eax+37E2Fh], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E23h]
    sub     ecx, 21h
    mov     [eax+37E33h], ecx
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+37E2Fh]
    mov     esi, [eax+37E27h]
    sub     edx, esi
    inc     edx
    mov     [eax+37E37h], edx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E33h]
    mov     ebx, [eax+37E2Bh]
    sub     ecx, ebx
    inc     ecx
    mov     [eax+37E3Bh], ecx
    call    sub_4288D0
    mov     edx, TAdynmemStructPtr
    mov     ecx, 23h
    xor     eax, eax
    mov     bl, 40h
    lea     edi, [edx+29A4h]
    rep stosd
    xor     edi, edi
    mov     eax, 29A4h

    loc_498260:                             ; CODE XREF: sub_497F40+381j
    mov     esi, TAdynmemStructPtr
    mov     edx, [esi+edi+1B63h]
    lea     ecx, [esi+edi+1B63h]
    cmp     edx, ebp
    jz      short loc_49828E
    mov     dl, [ecx+73h]
    cmp     dl, 1
    jz      short loc_498285
    cmp     dl, 2
    jnz     short loc_49828E

    loc_498285:                             ; CODE XREF: sub_497F40+33Ej
    mov     dword ptr [esi+eax], 1
    jmp     short loc_498291
    ; ---------------------------------------------------------------------------

    loc_49828E:                             ; CODE XREF: sub_497F40+336j
                                            ; sub_497F40+343j
    mov     [esi+eax], ebp

    loc_498291:                             ; CODE XREF: sub_497F40+34Cj
    cmp     [ecx], ebp
    jz      short loc_4982A7
    mov     ecx, [ecx+27h]
    test    [ecx+9Bh], bl
    jz      short loc_4982A7
    mov     ecx, 1
    jmp     short loc_4982A9
    ; ---------------------------------------------------------------------------

    loc_4982A7:                             ; CODE XREF: sub_497F40+353j
                                            ; sub_497F40+35Ej
    xor     ecx, ecx

    loc_4982A9:                             ; CODE XREF: sub_497F40+365j
    mov     edx, TAdynmemStructPtr
    add     eax, 4
    add     edi, 14Bh
    cmp     eax, 29CCh
    mov     [edx+eax+28h], ecx
    jl      short loc_498260
    push    ebp                             ; lpThreadId
    push    ebp                             ; dwStackSize
    push    offset sub_497C70               ; int
    call    sub_4B6B20
    test    eax, eax
    jnz     short loc_4982DD
    push    offset aUnableToStartT          ; lpText
    call    sub_4B6290

    loc_4982DD:                             ; CODE XREF: sub_497F40+391j
    xor     eax, eax
    xor     ecx, ecx
    mov     dword_51F2C8, eax
    mov     dword_51E810, ecx
    mov     dword_51F2CC, eax
    xor     edx, edx
    mov     word_51F2D0, ax
    mov     dword_51E820, eax
    mov     word_51E824, ax
    mov     eax, TAdynmemStructPtr
    mov     dword_51E814, ecx
    mov     dword_51E6C8, edx
    mov     word_51E818, cx
    mov     word ptr dword_51E6CC, dx
    mov     cx, [eax+38D75h]
    or      ecx, 1
    mov     [eax+38D75h], cx
    call    sub_45B640
    mov     eax, TAdynmemStructPtr
    jmp     short loc_498342
    ; ---------------------------------------------------------------------------

    loc_498340:                             ; CODE XREF: sub_497F40+18j
    xor     ebp, ebp

    loc_498342:                             ; CODE XREF: sub_497F40+3FEj
    mov     dl, [eax+38D75h]
    shr     dl, 1
    test    dl, 1
    jz      loc_4984DD
    call    sub_47F750
    call    sub_4257A0
    call    sub_428730
    call    sub_4B6700
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+37F1Bh]
    jnz     short loc_49838C
    call    sub_4B6710
    mov     ecx, TAdynmemStructPtr
    cmp     eax, [ecx+37F1Fh]
    jz      loc_49842A

    loc_49838C:                             ; CODE XREF: sub_497F40+433j
    mov     eax, [ecx+37E1Bh]
    push    eax                             ; int
    call    sub_4D85A0
    mov     ecx, TAdynmemStructPtr
    add     esp, 4
    push    ebp
    mov     [ecx+37E1Bh], ebp
    call    sub_4C61F0
    call    sub_4C62C0
    mov     eax, TAdynmemStructPtr
    push    4                               ; uFlags
    mov     edx, [eax+37F1Fh]
    mov     ecx, [eax+37F1Bh]
    push    edx                             ; cy
    mov     edx, [eax+0Ch]
    push    ecx                             ; cx
    push    ebp                             ; Y
    mov     eax, [edx+40h]
    push    ebp                             ; X
    push    ebp                             ; hWndInsertAfter
    push    eax                             ; hWnd
    call    ds:SetWindowPos
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37F1Fh]
    mov     edx, [eax+37F1Bh]
    push    ecx
    push    edx
    call    sub_4B5940
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E23h]
    mov     edx, [eax+37E1Fh]
    push    ecx                             ; int
    push    edx                             ; int
    push    offset aOffscreen               ; int
    call    sub_4C69F0
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37E1Bh], eax
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+37E1Bh]
    push    eax
    call    sub_4C61F0

    loc_49842A:                             ; CODE XREF: sub_497F40+446j
    call    sub_467D70
    call    sub_496790
    call    sub_4C2870
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    offset sub_4609A0
    mov     dword ptr [ecx+391F1h], 6
    mov     edx, TAdynmemStructPtr
    mov     dword ptr [edx+391F5h], offset loc_499200
    call    sub_4B4FD0
    mov     eax, TAdynmemStructPtr
    xor     ecx, ecx
    push    ebp
    mov     [eax+589h], ebp
    mov     edx, TAdynmemStructPtr
    add     edx, 38D6Fh
    mov     [edx], ecx
    mov     [edx+4], ecx
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CE690
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+10h]
    call    sub_4CE800
    test    eax, eax
    jnz     short loc_4984B0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CDB40

    loc_4984B0:                             ; CODE XREF: sub_497F40+560j
    mov     eax, TAdynmemStructPtr
    mov     ecx, 0Ah
    add     eax, 1BD6h

    loc_4984BF:                             ; CODE XREF: sub_497F40+590j
    cmp     [eax-73h], ebp
    jz      short loc_4984CA
    mov     dl, [eax]
    mov     [esp+244h+var_221], dl

    loc_4984CA:                             ; CODE XREF: sub_497F40+582j
    add     eax, 14Bh
    dec     ecx
    jnz     short loc_4984BF
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 234h
    retn
    ; ---------------------------------------------------------------------------

    loc_4984DD:                             ; CODE XREF: sub_497F40+40Dj
    xor     esi, esi

    loc_4984DF:                             ; CODE XREF: sub_497F40+5ECj
    cmp     [eax+esi+1B63h], ebp
    jz      short loc_498520
    mov     cl, [eax+esi+1BD6h]
    cmp     cl, 1
    jz      short loc_4984F9
    cmp     cl, 2
    jnz     short loc_498520

    loc_4984F9:                             ; CODE XREF: sub_497F40+5B2j
    mov     eax, [eax+esi+1B67h]
    push    ebp
    push    eax
    call    sub_453320
    cmp     dword_506DBC, ebp
    jz      short loc_49851B
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_49851B:                             ; CODE XREF: sub_497F40+5CDj
    mov     eax, TAdynmemStructPtr

    loc_498520:                             ; CODE XREF: sub_497F40+5A6j
                                            ; sub_497F40+5B7j
    add     esi, 14Bh
    cmp     esi, 0CEEh
    jl      short loc_4984DF
    call    Network_Process
    mov     ecx, TAdynmemStructPtr
    mov     dl, [ecx+38D75h]
    shr     dl, 2
    test    dl, 1
    jz      short loc_498585
    call    sub_4568C0
    test    eax, eax
    jz      short loc_498585
    mov     eax, TAdynmemStructPtr
    push    ebp                             ; GuaranteePackets
    mov     cx, [eax+38D75h]
    and     ecx, 0FFFBh
    mov     [eax+38D75h], cx
    mov     eax, TAdynmemStructPtr
    mov     dx, [eax+38D75h]
    or      edx, 8
    mov     [eax+38D75h], dx
    call    HAPINET_GuaranteePackets

    loc_498585:                             ; CODE XREF: sub_497F40+605j
                                            ; sub_497F40+60Ej
    cmp     dword_506DBC, ebp
    jz      short loc_498599
    push    1
    mov     ecx, offset dword_513000
    call    sub_4618A0

    loc_498599:                             ; CODE XREF: sub_497F40+64Bj
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+37E1Bh]
    push    ecx
    call    sub_4C69A0
    lea     edx, [esp+244h+var_220]
    push    edx
    call    sub_4C5E70
    cmp     eax, ebp
    jz      loc_498CB2
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     al, [ecx+0DDAh]
    mov     esi, eax
    call    sub_4B6340
    cmp     dword_51F308, eax
    jge     short loc_4985FD
    call    sub_4B6340
    mov     dword_51F308, eax
    xor     ecx, ecx

    loc_4985E5:                             ; CODE XREF: sub_497F40+6BBj
    mov     al, byte ptr dword_51E6C8[ecx]
    test    al, al
    jz      short loc_4985F7
    sub     al, 2
    mov     byte ptr dword_51E6C8[ecx], al

    loc_4985F7:                             ; CODE XREF: sub_497F40+6ADj
    inc     ecx
    cmp     ecx, 6
    jl      short loc_4985E5

    loc_4985FD:                             ; CODE XREF: sub_497F40+697j
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+391F9h]
    push    eax
    call    sub_4C1420
    mov     ecx, TAdynmemStructPtr
    push    ebp
    push    ebp
    lea     eax, [esp+24Ch+var_220]
    mov     edx, [ecx+11EBh]
    push    edx
    push    eax
    call    sub_4C6B70
    mov     ecx, TAdynmemStructPtr
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 1
    mov     ebx, 64h
    jz      loc_49872F
    push    0FEh
    push    esi
    call    sub_4C13A0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435C30
    push    ebx                             ; size_t
    push    eax                             ; char *
    lea     eax, [esp+24Ch+MultiByteStr]
    push    eax                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     [esp+244h+var_181], 0
    call    sub_49F580
    test    eax, eax
    jz      short loc_4986A7
    push    offset aEnglish                 ; char *
    call    sub_49F580
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4986A7
    lea     ecx, [esp+244h+MultiByteStr]
    push    ecx                             ; lpMultiByteStr
    call    sub_4E8960
    add     esp, 4

    loc_4986A7:                             ; CODE XREF: sub_497F40+741j
                                            ; sub_497F40+758j
    lea     edx, [esp+244h+MultiByteStr]
    push    edx                             ; int
    call    sub_4C5740
    push    eax
    push    offset aMap                     ; int
    call    sub_4C5740
    push    eax
    lea     eax, [esp+24Ch+var_180]
    push    offset aSS_1                    ; LPCSTR
    push    eax                             ; LPSTR
    call    ds:wsprintfA
    add     esp, 10h
    lea     ecx, [esp+244h+var_180]
    push    ecx
    call    sub_4A5030
    cdq
    fild    [esp+244h+var_21C]
    sub     eax, edx
    push    ebp
    mov     ecx, eax
    mov     eax, [esp+248h+var_220]
    cdq
    fstp    [esp+248h+var_1EC]
    sub     eax, edx
    push    0FFFFFFFFh
    mov     esi, eax
    sar     ecx, 1
    sar     esi, 1
    sub     esi, ecx
    call    sub_4C1450
    mov     [esp+24Ch+var_1F0], eax
    fild    [esp+24Ch+var_1F0]
    fmul    ds:dbl_4FDA40
    fsubr   [esp+24Ch+var_1EC]
    call    __ftol
    push    eax
    lea     edx, [esp+250h+var_180]
    push    esi
    lea     eax, [esp+254h+var_220]
    push    edx
    push    eax
    call    sub_4A50E0

    loc_49872F:                             ; CODE XREF: sub_497F40+701j
    mov     ecx, TAdynmemStructPtr
    push    offset aLightbar                ; char *
    mov     edx, [ecx+51Dh]
    push    edx                             ; int
    call    sub_4B8D40
    push    ebp
    push    eax
    call    sub_4B7F30
    mov     esi, eax
    mov     [esi+6], bp
    mov     [esi+4], bp
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D6Fh], bl
    sbb     ecx, ecx
    xor     edx, edx
    and     ecx, 2
    add     ecx, 0Ah
    mov     dl, [ecx+eax+0DCBh]
    mov     edi, edx
    call    sub_4C13F0
    push    eax
    push    edi
    call    sub_4C13A0
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D6Fh], bl
    jnz     short loc_49879D
    cmp     byte ptr dword_51E820, bl
    jz      short loc_49879D
    mov     byte ptr dword_51E6C8, 1Eh

    loc_49879D:                             ; CODE XREF: sub_497F40+84Cj
                                            ; sub_497F40+854j
    mov     ecx, dword_51E6C8
    mov     al, [eax+38D6Fh]
    and     ecx, 0FFh
    mov     byte ptr dword_51E820, al
    push    ecx
    push    0FFFFFFFFh
    push    87h
    push    5Ah
    push    offset aTextures_0              ; int
    call    sub_4C5740
    lea     edx, [esp+254h+var_220]
    push    eax
    push    edx
    call    sub_4A50E0
    mov     eax, TAdynmemStructPtr
    mov     ebp, 0CDh
    mov     [esp+244h+var_234], ebp
    push    edi
    mov     cl, [eax+38D6Fh]
    mov     [esp+248h+var_230], 87h
    and     ecx, 0FFh
    mov     [esp+248h+var_228], 9Bh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [esp+248h+var_234]
    cdq
    sub     eax, edx
    lea     edx, [esp+248h+var_220]
    sar     eax, 1
    add     eax, ebp
    push    ecx
    push    edx
    mov     [esp+250h+var_22C], eax
    call    sub_4BF6F0
    lea     edx, [esp+244h+var_220]
    mov     eax, [esp+244h+var_230]
    mov     ecx, [esp+244h+var_234]
    push    eax
    push    ecx
    push    esi
    push    edx
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D70h], bl
    sbb     ecx, ecx
    xor     edx, edx
    and     ecx, 2
    add     ecx, 0Ah
    mov     dl, [ecx+eax+0DCBh]
    mov     edi, edx
    call    sub_4C13F0
    push    eax
    push    edi
    call    sub_4C13A0
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D70h], bl
    jnz     short loc_49887A
    cmp     byte ptr dword_51E820+1, bl
    jz      short loc_49887A
    mov     byte ptr dword_51E6C8+1, 1Eh

    loc_49887A:                             ; CODE XREF: sub_497F40+929j
                                            ; sub_497F40+931j
    mov     al, [eax+38D70h]
    xor     ecx, ecx
    mov     cl, byte ptr dword_51E6C8+1
    mov     byte ptr dword_51E820+1, al
    push    ecx
    push    0FFFFFFFFh
    push    0B1h
    push    5Ah
    push    offset aTerrain                 ; int
    call    sub_4C5740
    lea     edx, [esp+254h+var_220]
    push    eax
    push    edx
    call    sub_4A50E0
    mov     eax, TAdynmemStructPtr
    mov     [esp+244h+var_234], ebp
    push    edi
    mov     cl, [eax+38D70h]
    mov     [esp+248h+var_230], 0B1h
    and     ecx, 0FFh
    mov     [esp+248h+var_228], 0C5h
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [esp+248h+var_234]
    cdq
    sub     eax, edx
    lea     edx, [esp+248h+var_220]
    sar     eax, 1
    add     eax, ebp
    push    ecx
    push    edx
    mov     [esp+250h+var_22C], eax
    call    sub_4BF6F0
    lea     edx, [esp+244h+var_220]
    mov     eax, [esp+244h+var_230]
    mov     ecx, [esp+244h+var_234]
    push    eax
    push    ecx
    push    esi
    push    edx
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D71h], bl
    sbb     ecx, ecx
    xor     edx, edx
    and     ecx, 2
    add     ecx, 0Ah
    mov     dl, [ecx+eax+0DCBh]
    mov     edi, edx
    call    sub_4C13F0
    push    eax
    push    edi
    call    sub_4C13A0
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D71h], bl
    jnz     short loc_49894E
    cmp     byte ptr dword_51E820+2, bl
    jz      short loc_49894E
    mov     byte ptr dword_51E6C8+2, 1Eh

    loc_49894E:                             ; CODE XREF: sub_497F40+9FDj
                                            ; sub_497F40+A05j
    mov     al, [eax+38D71h]
    xor     ecx, ecx
    mov     cl, byte ptr dword_51E6C8+2
    mov     byte ptr dword_51E820+2, al
    push    ecx
    push    0FFFFFFFFh
    push    0DAh
    push    5Ah
    push    offset aUnits_0                 ; int
    call    sub_4C5740
    lea     edx, [esp+254h+var_220]
    push    eax
    push    edx
    call    sub_4A50E0
    mov     eax, TAdynmemStructPtr
    mov     [esp+244h+var_234], ebp
    push    edi
    mov     cl, [eax+38D71h]
    mov     [esp+248h+var_230], 0DAh
    and     ecx, 0FFh
    mov     [esp+248h+var_228], 0EEh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [esp+248h+var_234]
    cdq
    sub     eax, edx
    lea     edx, [esp+248h+var_220]
    sar     eax, 1
    add     eax, ebp
    push    ecx
    push    edx
    mov     [esp+250h+var_22C], eax
    call    sub_4BF6F0
    lea     edx, [esp+244h+var_220]
    mov     eax, [esp+244h+var_230]
    mov     ecx, [esp+244h+var_234]
    push    eax
    push    ecx
    push    esi
    push    edx
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D72h], bl
    sbb     ecx, ecx
    xor     edx, edx
    and     ecx, 2
    add     ecx, 0Ah
    mov     dl, [ecx+eax+0DCBh]
    mov     edi, edx
    call    sub_4C13F0
    push    eax
    push    edi
    call    sub_4C13A0
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D72h], bl
    jnz     short loc_498A22
    cmp     byte ptr dword_51E820+3, bl
    jz      short loc_498A22
    mov     byte ptr dword_51E6C8+3, 1Eh

    loc_498A22:                             ; CODE XREF: sub_497F40+AD1j
                                            ; sub_497F40+AD9j
    mov     al, [eax+38D72h]
    xor     ecx, ecx
    mov     cl, byte ptr dword_51E6C8+3
    mov     byte ptr dword_51E820+3, al
    push    ecx
    push    0FFFFFFFFh
    push    106h
    push    5Ah
    push    offset aAnimation               ; int
    call    sub_4C5740
    lea     edx, [esp+254h+var_220]
    push    eax
    push    edx
    call    sub_4A50E0
    mov     eax, TAdynmemStructPtr
    mov     [esp+244h+var_234], ebp
    push    edi
    mov     cl, [eax+38D72h]
    mov     [esp+248h+var_230], 106h
    and     ecx, 0FFh
    mov     [esp+248h+var_228], 11Ah
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [esp+248h+var_234]
    cdq
    sub     eax, edx
    lea     edx, [esp+248h+var_220]
    sar     eax, 1
    add     eax, ebp
    push    ecx
    push    edx
    mov     [esp+250h+var_22C], eax
    call    sub_4BF6F0
    lea     edx, [esp+244h+var_220]
    mov     eax, [esp+244h+var_230]
    mov     ecx, [esp+244h+var_234]
    push    eax
    push    ecx
    push    esi
    push    edx
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D73h], bl
    sbb     ecx, ecx
    xor     edx, edx
    and     ecx, 2
    add     ecx, 0Ah
    mov     dl, [ecx+eax+0DCBh]
    mov     edi, edx
    call    sub_4C13F0
    push    eax
    push    edi
    call    sub_4C13A0
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D73h], bl
    jnz     short loc_498AF6
    cmp     byte ptr word_51E824, bl
    jz      short loc_498AF6
    mov     byte ptr dword_51E6CC, 1Eh

    loc_498AF6:                             ; CODE XREF: sub_497F40+BA5j
                                            ; sub_497F40+BADj
    mov     ecx, dword_51E6CC
    mov     al, [eax+38D73h]
    and     ecx, 0FFh
    mov     byte ptr word_51E824, al
    push    ecx
    push    0FFFFFFFFh
    push    130h
    push    5Ah
    push    offset a3dData                  ; int
    call    sub_4C5740
    lea     edx, [esp+254h+var_220]
    push    eax
    push    edx
    call    sub_4A50E0
    mov     eax, TAdynmemStructPtr
    mov     [esp+244h+var_234], ebp
    push    edi
    mov     cl, [eax+38D73h]
    mov     [esp+248h+var_230], 130h
    and     ecx, 0FFh
    mov     [esp+248h+var_228], 144h
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [esp+248h+var_234]
    cdq
    sub     eax, edx
    lea     edx, [esp+248h+var_220]
    sar     eax, 1
    add     eax, ebp
    push    ecx
    push    edx
    mov     [esp+250h+var_22C], eax
    call    sub_4BF6F0
    lea     edx, [esp+244h+var_220]
    mov     eax, [esp+244h+var_230]
    mov     ecx, [esp+244h+var_234]
    push    eax
    push    ecx
    push    esi
    push    edx
    call    sub_4B7F90
    movsx   eax, word ptr [esi+6]
    mov     ecx, [esp+244h+var_230]
    movsx   edx, word ptr [esi+4]
    add     ecx, eax
    mov     eax, [esp+244h+var_234]
    add     eax, edx
    push    ecx
    push    eax
    lea     ecx, [esp+24Ch+var_220]
    push    esi
    push    ecx
    call    sub_4B7F90
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D74h], bl
    sbb     edx, edx
    xor     ecx, ecx
    and     edx, 2
    add     edx, 0Ah
    mov     cl, [edx+eax+0DCBh]
    mov     edi, ecx
    call    sub_4C13F0
    push    eax
    push    edi
    call    sub_4C13A0
    mov     eax, TAdynmemStructPtr
    cmp     [eax+38D74h], bl
    jnz     short loc_498BEF
    cmp     byte ptr word_51E824+1, bl
    jz      short loc_498BEF
    mov     byte ptr dword_51E6CC+1, 1Eh

    loc_498BEF:                             ; CODE XREF: sub_497F40+C9Ej
                                            ; sub_497F40+CA6j
    mov     dl, [eax+38D74h]
    xor     eax, eax
    mov     al, byte ptr dword_51E6CC+1
    mov     byte ptr word_51E824+1, dl
    push    eax
    push    0FFFFFFFFh
    push    15Bh
    push    5Ah
    push    offset aExplosions              ; int
    call    sub_4C5740
    lea     ecx, [esp+254h+var_220]
    push    eax
    push    ecx
    call    sub_4A50E0
    mov     edx, TAdynmemStructPtr
    mov     [esp+244h+var_234], ebp
    push    edi
    mov     cl, [edx+38D74h]
    mov     [esp+248h+var_230], 15Bh
    and     ecx, 0FFh
    mov     [esp+248h+var_228], 16Fh
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     ecx, [esp+248h+var_220]
    cdq
    sub     eax, edx
    sar     eax, 1
    add     eax, ebp
    mov     [esp+248h+var_22C], eax
    lea     eax, [esp+248h+var_234]
    push    eax
    push    ecx
    call    sub_4BF6F0
    lea     ecx, [esp+244h+var_220]
    mov     edx, [esp+244h+var_230]
    mov     eax, [esp+244h+var_234]
    push    edx
    push    eax
    push    esi
    push    ecx
    call    sub_4B7F90
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_498CA3
    lea     eax, [esp+244h+var_220]
    push    eax
    call    sub_497CE0
    call    sub_456DE0

    loc_498CA3:                             ; CODE XREF: sub_497F40+D52j
    lea     ecx, [esp+244h+var_220]
    push    ecx
    call    sub_4C5FA0
    call    sub_4C63A0

    loc_498CB2:                             ; CODE XREF: sub_497F40+676j
    push    0C8h                            ; dwMilliseconds
    call    sub_4B6B50
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 234h
    retn
    sub_497F40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_498CD0 proc near

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    mov     ecx, [esp+arg_4]
    push    esi
    push    eax
    mov     eax, [esp+8+arg_0]
    mov     esi, [ecx+30h]
    mov     ecx, [ecx+2Ch]
    mov     edx, [eax+4]
    lea     edx, [edx+esi-20h]
    push    edx
    mov     edx, [eax]
    lea     eax, [ecx+edx-80h]
    push    eax
    call    sub_484B50
    pop     esi
    retn    0Ch
    sub_498CD0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_498D00 proc near

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    sub     esp, 18h
    mov     ecx, 6
    movsx   edx, word ptr [eax+142E7h]
    push    esi
    push    edi
    lea     esi, [eax+2C76h]
    lea     edi, [esp+20h+var_18]
    movsx   eax, word ptr [eax+142E9h]
    rep movsd
    mov     edi, [esp+20h+var_14]
    mov     ecx, [esp+20h+var_18]
    mov     esi, [esp+20h+arg_0]
    sub     edi, eax
    sub     ecx, edx
    mov     eax, esi
    xor     edx, edx
    push    esi
    mov     [eax], edx
    mov     [eax+4], edx
    mov     [eax+8], edx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+1422Bh]
    imul    eax, ecx
    movsx   ecx, [edx+TAdynmemStruct.RadarPicSizeX]
    cdq
    idiv    ecx
    mov     [esi+2], ax
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+1422Fh]
    imul    eax, edi
    movsx   ecx, [ecx+TAdynmemStruct.RadarPicSizeY]
    cdq
    idiv    ecx
    mov     [esi+0Ah], ax
    call    sub_485070
    mov     [esi+6], ax
    pop     edi
    pop     esi
    add     esp, 18h
    retn    4
    sub_498D00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_498DA0 proc near                    ; CODE XREF: .text:00499221p

    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 0Ch
    mov     edx, TAdynmemStructPtr
    add     edx, 142BBh
    push    ebx
    push    ebp
    mov     ebp, [esp+14h+arg_0]
    push    esi
    push    edi
    mov     eax, [ebp+4]
    mov     ecx, [ebp+0]
    push    eax
    push    ecx
    push    edx
    call    sub_4B6720
    mov     ecx, TAdynmemStructPtr
    test    eax, eax
    jz      short loc_498E32
    mov     bl, [ecx+2CC6h]
    test    bl, 8
    jnz     short loc_498E32
    movsx   edx, word ptr [ecx+142E7h]
    mov     eax, [ebp+0]
    or      bl, 1
    sub     eax, edx
    imul    eax, [ecx+1422Bh]
    movsx   esi, word ptr [ecx+142EBh]
    cdq
    idiv    esi
    movsx   edx, word ptr [ecx+142E9h]
    movsx   esi, word ptr [ecx+142EDh]
    mov     edi, eax
    mov     eax, [ebp+4]
    sub     eax, edx
    imul    eax, [ecx+1422Fh]
    cdq
    idiv    esi
    mov     [ecx+2CC6h], bl
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    and     byte ptr [eax+2CC6h], 0FDh
    jmp     loc_498EC2
    ; ---------------------------------------------------------------------------

    loc_498E32:                             ; CODE XREF: sub_498DA0+2Dj
                                            ; sub_498DA0+38j
    mov     esi, [ebp+0]
    mov     eax, [ecx+37E27h]
    lea     edx, [ecx+37E27h]
    cmp     esi, eax
    mov     ebx, esi
    jg      short loc_498E49
    mov     ebx, eax

    loc_498E49:                             ; CODE XREF: sub_498DA0+A5j
    mov     edi, [edx+8]
    cmp     ebx, edi
    jge     short loc_498E58
    cmp     esi, eax
    jg      short loc_498E5A
    mov     esi, eax
    jmp     short loc_498E5A
    ; ---------------------------------------------------------------------------

    loc_498E58:                             ; CODE XREF: sub_498DA0+AEj
    mov     esi, edi

    loc_498E5A:                             ; CODE XREF: sub_498DA0+B2j
                                            ; sub_498DA0+B6j
    mov     edi, [ecx+1431Fh]
    add     edi, esi
    mov     esi, [ebp+4]
    sub     edi, eax
    mov     eax, [edx+4]
    cmp     esi, eax
    jg      short loc_498E70
    mov     esi, eax

    loc_498E70:                             ; CODE XREF: sub_498DA0+CCj
    mov     ebx, [edx+0Ch]
    cmp     esi, ebx
    jge     short loc_498E80
    mov     ebx, [ebp+4]
    cmp     ebx, eax
    jg      short loc_498E80
    mov     ebx, eax

    loc_498E80:                             ; CODE XREF: sub_498DA0+D5j
                                            ; sub_498DA0+DCj
    mov     esi, [ecx+14323h]
    add     esi, ebx
    mov     bl, [ecx+2CC6h]
    and     bl, 0FEh
    sub     esi, eax
    mov     [ecx+2CC6h], bl
    mov     eax, [ebp+4]
    mov     ecx, [ebp+0]
    push    eax
    push    ecx
    push    edx
    call    sub_4B6720
    mov     ecx, TAdynmemStructPtr
    and     al, 1
    shl     al, 1
    mov     dl, [ecx+2CC6h]
    and     dl, 0FDh
    or      dl, al
    mov     [ecx+2CC6h], dl

    loc_498EC2:                             ; CODE XREF: sub_498DA0+8Dj
    mov     edx, TAdynmemStructPtr
    mov     cl, [edx+2CC6h]
    test    cl, 3
    jnz     short loc_498ED7
    xor     eax, eax
    jmp     short loc_498EDC
    ; ---------------------------------------------------------------------------

    loc_498ED7:                             ; CODE XREF: sub_498DA0+131j
    mov     eax, 1

    loc_498EDC:                             ; CODE XREF: sub_498DA0+135j
    and     al, 1
    and     cl, 0FBh
    shl     al, 2
    or      al, cl
    mov     [edx+2CC6h], al
    mov     eax, TAdynmemStructPtr
    add     eax, 2CAAh
    push    eax
    push    esi
    push    edi
    call    sub_484B50
    mov     edx, TAdynmemStructPtr
    lea     ecx, [edx+2CAAh]
    mov     eax, [edx+2CAAh]
    shr     eax, 14h
    mov     esi, [ecx+4]
    mov     word ptr [esp+1Ch+arg_0], ax
    mov     [esp+1Ch+var_8], esi
    mov     ecx, [ecx+8]
    shr     ecx, 14h
    mov     word ptr [esp+1Ch+arg_0+2], cx
    mov     eax, [esp+1Ch+arg_0]
    mov     [edx+2C8Eh], eax
    mov     eax, TAdynmemStructPtr
    movsx   ecx, word ptr [eax+2C90h]
    movsx   edx, word ptr [eax+2C8Eh]
    push    ecx
    push    edx
    call    sub_481550
    push    eax
    call    sub_421E60
    mov     ecx, TAdynmemStructPtr
    pop     edi
    pop     esi
    pop     ebp
    mov     [ecx+2CBCh], ax
    pop     ebx
    add     esp, 0Ch
    retn    4
    sub_498DA0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_498F70 proc near                    ; CODE XREF: .text:004995B3p

    var_1= dword ptr -1
    arg_0= dword ptr  7

    push    ecx
    mov     eax, TAdynmemStructPtr
    push    esi
    mov     cl, [eax+2CC3h]
    cmp     cl, 0Eh
    jnz     loc_499027
    test    byte ptr [eax+2CC6h], 40h
    jz      loc_499016
    mov     esi, [esp+5+arg_0]
    push    esi
    call    sub_419670
    push    0                               ; int
    push    offset aOktobuild               ; char *
    call    sub_47F1A0
    test    byte ptr [esi+8], 4
    mov     eax, TAdynmemStructPtr
    jz      short loc_498FC0
    or      byte ptr [eax+2CC6h], 20h
    pop     esi
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_498FC0:                             ; CODE XREF: sub_498F70+42j
    mov     byte ptr [eax+2CC3h], 1
    mov     eax, TAdynmemStructPtr
    push    offset aStop                    ; char *
    mov     cl, [eax+2CC6h]
    and     cl, 0DFh
    mov     [eax+2CC6h], cl
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+531h]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      loc_4990F6
    mov     ecx, TAdynmemStructPtr
    push    eax
    add     ecx, 519h
    push    ecx
    call    sub_4A6A40
    pop     esi
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_499016:                             ; CODE XREF: sub_498F70+1Dj
    push    0                               ; int
    push    offset aNotoktobuild            ; char *
    call    sub_47F1A0
    pop     esi
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_499027:                             ; CODE XREF: sub_498F70+10j
    mov     dl, [eax+2CBEh]
    cmp     dl, 0Fh
    jnz     short loc_499041
    mov     edx, [esp+5+arg_0]
    push    edx
    call    sub_48C7F0
    pop     esi
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_499041:                             ; CODE XREF: sub_498F70+C0j
    cmp     dl, 11h
    jl      short loc_49906D
    cmp     dword ptr [eax+37EFAh], 1
    jnz     loc_4990F6
    cmp     cl, 1
    jnz     loc_4990F6
    call    sub_48BD00
    push    1
    call    sub_491D70
    pop     esi
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49906D:                             ; CODE XREF: sub_498F70+D4j
    mov     esi, [esp+5+arg_0]
    push    0
    add     eax, 2CAAh
    push    0
    mov     byte ptr [esp+0Dh+var_1], 0
    push    eax
    mov     eax, [esp+11h+var_1]
    push    eax
    push    ecx
    push    esi
    call    sub_48CF30
    test    byte ptr [esi+8], 4
    jz      short loc_4990A3
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2CC6h], 20h
    pop     esi
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4990A3:                             ; CODE XREF: sub_498F70+120j
    mov     ecx, TAdynmemStructPtr
    push    offset aStop                    ; char *
    mov     byte ptr [ecx+2CC3h], 1
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+2CC6h]
    and     cl, 0DFh
    mov     [eax+2CC6h], cl
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4990F6
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4A6A40

    loc_4990F6:                             ; CODE XREF: sub_498F70+88j
                                            ; sub_498F70+DDj ...
    pop     esi
    pop     ecx
    retn    4
    sub_498F70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_499100 proc near                    ; CODE XREF: .text:004993ACp

    var_1= dword ptr -1
    arg_0= dword ptr  7

    push    ecx
    mov     ecx, TAdynmemStructPtr
    cmp     byte ptr [ecx+2CC3h], 1
    jz      short loc_499162
    mov     byte ptr [ecx+2CC3h], 1
    mov     eax, TAdynmemStructPtr
    push    offset aStop                    ; char *
    mov     dl, [eax+2CC6h]
    and     dl, 0DFh
    mov     [eax+2CC6h], dl
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+531h]
    mov     edx, [ecx+4]
    push    edx                             ; int
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      loc_4991FA
    push    eax
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A6A40
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_499162:                             ; CODE XREF: sub_499100+Ej
    mov     eax, [ecx+37EFAh]
    test    eax, eax
    mov     al, [ecx+2CC6h]
    jnz     short loc_4991D5
    test    al, 2
    jz      short loc_499199
    mov     ecx, [esp+1+arg_0]
    test    byte ptr [ecx+8], 8
    jz      short loc_499189
    call    sub_41CC60
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_499189:                             ; CODE XREF: sub_499100+7Ej
    call    sub_48BD00
    push    1
    call    sub_491D70
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_499199:                             ; CODE XREF: sub_499100+74j
    test    al, 1
    jz      short loc_4991FA
    or      al, 10h
    mov     [ecx+2CC6h], al
    mov     eax, TAdynmemStructPtr
    mov     cl, 13h
    cmp     [eax+2CBEh], cl
    jz      short loc_4991FA
    mov     [eax+2CBEh], cl
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+148CBh]
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4AB400
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4991D5:                             ; CODE XREF: sub_499100+70j
    test    al, 4
    jz      short loc_4991FA
    mov     byte ptr [esp+1+var_1], 0
    mov     eax, [esp+1+var_1]
    push    0
    add     ecx, 2CAAh
    push    0
    push    ecx
    mov     ecx, [esp+0Dh+arg_0]
    push    eax
    push    1
    push    ecx
    call    sub_48CF30

    loc_4991FA:                             ; CODE XREF: sub_499100+47j
                                            ; sub_499100+9Bj ...
    pop     ecx
    retn    4
    sub_499100 endp

    ; ---------------------------------------------------------------------------
    align 4

    loc_499200:                             ; DATA XREF: sub_490B30+95o
                                            ; sub_497F40+515o
    mov     eax, TAdynmemStructPtr
    sub     esp, 18h
    mov     ecx, 6
    push    ebx
    push    esi
    push    edi
    lea     esi, [eax+2C76h]
    lea     edi, [esp+0Ch]
    rep movsd
    lea     ecx, [esp+0Ch]
    push    ecx
    call    sub_498DA0
    mov     edx, TAdynmemStructPtr
    mov     cl, [edx+2CC6h]
    mov     al, cl
    and     al, 2
    jz      short loc_49924B
    cmp     byte ptr [edx+2CC3h], 0Eh
    jnz     short loc_49924B
    call    sub_4197D0
    jmp     loc_4992CD
    ; ---------------------------------------------------------------------------

    loc_49924B:                             ; CODE XREF: .text:00499236j
                                            ; .text:0049923Fj
    test    al, al
    jnz     short loc_499278
    test    cl, 1
    jnz     short loc_499278
    cmp     byte ptr [edx+2CBEh], 13h
    jz      short loc_4992CD
    mov     byte ptr [edx+2CBEh], 13h
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+148CBh]
    add     eax, 519h
    push    edx
    push    eax
    jmp     short loc_4992C8
    ; ---------------------------------------------------------------------------

    loc_499278:                             ; CODE XREF: .text:0049924Dj
                                            ; .text:00499252j
    call    sub_48CD80
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2CBAh], ax
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+2CC3h]
    push    eax
    call    sub_48D220
    mov     ecx, TAdynmemStructPtr
    movsx   edx, byte ptr [ecx+2CBEh]
    cmp     edx, eax
    jz      short loc_4992CD
    mov     [ecx+2CBEh], al
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+eax*4+1487Fh]
    add     ecx, 519h
    push    eax
    push    ecx

    loc_4992C8:                             ; CODE XREF: .text:00499276j
    call    sub_4AB400

    loc_4992CD:                             ; CODE XREF: .text:00499246j
                                            ; .text:0049925Bj ...
    call    sub_41C180
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+2CC6h], 20h
    jz      short loc_499348
    push    0F9h
    call    sub_4C1B80
    test    eax, eax
    jnz     short loc_499342
    mov     ecx, TAdynmemStructPtr
    push    offset aStop                    ; "STOP"
    mov     byte ptr [ecx+2CC3h], 1
    mov     eax, TAdynmemStructPtr
    mov     bl, [eax+2CC6h]
    and     bl, 0DFh
    mov     [eax+2CC6h], bl
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+531h]
    mov     ecx, [eax+4]
    push    ecx
    call    sub_49FE60
    cmp     eax, 0FFFFFFFFh
    jz      short loc_499342
    mov     edx, TAdynmemStructPtr
    push    eax
    add     edx, 519h
    push    edx
    call    sub_4A6A40

    loc_499342:                             ; CODE XREF: .text:004992EDj
                                            ; .text:0049932Dj
    mov     ecx, TAdynmemStructPtr

    loc_499348:                             ; CODE XREF: .text:004992DFj
    mov     al, [ecx+2CC6h]
    test    al, 10h
    jz      short loc_499387
    mov     edx, [ecx+37EFAh]
    test    edx, edx
    mov     edx, [esp+1Ch]
    jnz     short loc_499368
    cmp     edx, 205h
    jmp     short loc_49936E
    ; ---------------------------------------------------------------------------

    loc_499368:                             ; CODE XREF: .text:0049935Ej
    cmp     edx, 202h

    loc_49936E:                             ; CODE XREF: .text:00499366j
    jnz     short loc_49937D
    and     al, 0EFh
    mov     [ecx+2CC6h], al
    jmp     loc_4995B8
    ; ---------------------------------------------------------------------------

    loc_49937D:                             ; CODE XREF: .text:0049936Ej
    call    sub_41D0F0
    jmp     loc_4995B8
    ; ---------------------------------------------------------------------------

    loc_499387:                             ; CODE XREF: .text:00499350j
    mov     edx, [ecx+2CDFh]
    test    edx, edx
    jz      short loc_49939B
    call    sub_41CD50
    jmp     loc_4995B8
    ; ---------------------------------------------------------------------------

    loc_49939B:                             ; CODE XREF: .text:0049938Fj
    mov     edx, [esp+1Ch]
    cmp     edx, 204h
    jnz     short loc_4993B6
    lea     eax, [esp+0Ch]
    push    eax
    call    sub_499100
    jmp     loc_4995B8
    ; ---------------------------------------------------------------------------

    loc_4993B6:                             ; CODE XREF: .text:004993A5j
    cmp     byte ptr [ecx+2CC3h], 1
    jz      short loc_4993D5
    cmp     edx, 201h
    jnz     loc_4995B8
    lea     ecx, [esp+0Ch]
    push    ecx
    jmp     loc_4995B3
    ; ---------------------------------------------------------------------------

    loc_4993D5:                             ; CODE XREF: .text:004993BDj
    test    al, 8
    jz      loc_4994A0
    cmp     edx, 202h
    jnz     loc_49946A
    and     al, 0F7h
    mov     [ecx+2CC6h], al
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+2C92h]
    mov     edx, [ecx+2C9Eh]
    sub     eax, edx
    cdq
    mov     esi, eax
    mov     eax, [ecx+2C9Ah]
    xor     esi, edx
    sub     esi, edx
    mov     edx, [ecx+2CA6h]
    sub     eax, edx
    cdq
    mov     edi, eax
    xor     edi, edx
    sub     edi, edx
    call    sub_4B6340
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+2CB6h]
    add     ecx, 19h
    cmp     ecx, eax
    jle     short loc_499447
    cmp     esi, 20h
    jge     short loc_499447
    cmp     edi, 20h
    jl      loc_4995AE

    loc_499447:                             ; CODE XREF: .text:00499437j
                                            ; .text:0049943Cj
    lea     eax, [esp+0Ch]
    push    eax
    call    sub_48C390
    test    eax, eax
    jnz     loc_4995B8
    call    sub_48BD00
    push    1
    call    sub_491D70
    jmp     loc_4995B8
    ; ---------------------------------------------------------------------------

    loc_49946A:                             ; CODE XREF: .text:004993E3j
    movsx   edx, word ptr [ecx+2CACh]
    mov     [ecx+2C9Eh], edx
    mov     eax, TAdynmemStructPtr
    movsx   ecx, word ptr [eax+2CB0h]
    mov     [eax+2CA2h], ecx
    mov     eax, TAdynmemStructPtr
    movsx   edx, word ptr [eax+2CB4h]
    mov     [eax+2CA6h], edx
    jmp     loc_4995B8
    ; ---------------------------------------------------------------------------

    loc_4994A0:                             ; CODE XREF: .text:004993D7j
    cmp     edx, 201h
    jnz     loc_4995B8
    test    al, 2
    jz      loc_499567
    or      al, 8
    mov     [ecx+2CC6h], al
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+2CB6h], eax
    mov     eax, TAdynmemStructPtr
    movsx   edx, word ptr [eax+2CACh]
    mov     [eax+2C92h], edx
    mov     eax, TAdynmemStructPtr
    movsx   ecx, word ptr [eax+2CB0h]
    mov     [eax+2C96h], ecx
    mov     eax, TAdynmemStructPtr
    movsx   edx, word ptr [eax+2CB4h]
    mov     [eax+2C9Ah], edx
    mov     eax, TAdynmemStructPtr
    movsx   ecx, word ptr [eax+2CACh]
    mov     [eax+2C9Eh], ecx
    mov     eax, TAdynmemStructPtr
    movsx   edx, word ptr [eax+2CB0h]
    mov     [eax+2CA2h], edx
    mov     eax, TAdynmemStructPtr
    movsx   ecx, word ptr [eax+2CB4h]
    mov     [eax+2CA6h], ecx
    mov     eax, TAdynmemStructPtr
    cmp     byte ptr [eax+2CBEh], 13h
    jz      short loc_4995B8
    mov     byte ptr [eax+2CBEh], 13h
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+148CBh]
    add     eax, 519h
    push    edx
    push    eax
    call    sub_4AB400
    jmp     short loc_4995B8
    ; ---------------------------------------------------------------------------

    loc_499567:                             ; CODE XREF: .text:004994AEj
    cmp     dword ptr [ecx+37EFAh], 1
    jnz     short loc_4995AA
    test    al, 1
    jz      short loc_4995B8
    or      al, 10h
    mov     [ecx+2CC6h], al
    mov     eax, TAdynmemStructPtr
    cmp     byte ptr [eax+2CBEh], 13h
    jz      short loc_4995B8
    mov     byte ptr [eax+2CBEh], 13h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148CBh]
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AB400
    jmp     short loc_4995B8
    ; ---------------------------------------------------------------------------

    loc_4995AA:                             ; CODE XREF: .text:0049956Ej
    test    al, 1
    jz      short loc_4995B8

    loc_4995AE:                             ; CODE XREF: .text:00499441j
    lea     edx, [esp+0Ch]
    push    edx

    loc_4995B3:                             ; CODE XREF: .text:004993D0j
    call    sub_498F70

    loc_4995B8:                             ; CODE XREF: .text:00499378j
                                            ; .text:00499382j ...
    call    sub_496790
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37E9Ch]
    test    ax, ax
    jz      short loc_4995FC
    and     eax, 0FFFFh
    mov     edx, eax
    shl     eax, 3
    sub     eax, edx
    mov     edx, [ecx+14357h]
    lea     eax, [eax+eax*4]
    cmp     word ptr [edx+eax*8+0A6h], 0
    jnz     short loc_4995FC
    push    0
    call    sub_491D70
    mov     ecx, TAdynmemStructPtr

    loc_4995FC:                             ; CODE XREF: .text:004995CDj
                                            ; .text:004995EDj
    mov     ax, [ecx+3923Bh]
    mov     edi, 4
    test    al, 14h
    jz      loc_4996FB
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_499646
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     loc_4996F5
    call    sub_4572A0
    test    eax, eax
    jz      loc_4996F5

    loc_499646:                             ; CODE XREF: .text:0049961Ej
    mov     eax, TAdynmemStructPtr
    cmp     byte ptr [eax+2CBEh], 13h
    jz      short loc_499672
    mov     byte ptr [eax+2CBEh], 13h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148CBh]
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AB400

    loc_499672:                             ; CODE XREF: .text:00499652j
    push    1
    call    sub_491D70
    mov     edx, TAdynmemStructPtr
    add     edx, 519h
    push    edx
    call    sub_4A9660
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jnz     short loc_4996AA
    call    sub_463C80
    call    sub_496790

    loc_4996AA:                             ; CODE XREF: .text:0049969Ej
    call    sub_491B60
    call    sub_4C1A40
    mov     ecx, TAdynmemStructPtr
    push    edi
    mov     ecx, [ecx+10h]
    call    sub_4CE690
    mov     edx, TAdynmemStructPtr
    push    0
    push    offset loc_4578F0
    mov     dword ptr [edx+391F1h], 7
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+391F5h], offset loc_499880
    call    sub_4B4FD0
    push    0
    call    sub_41D9F0

    loc_4996F5:                             ; CODE XREF: .text:00499633j
                                            ; .text:00499640j
    mov     ecx, TAdynmemStructPtr

    loc_4996FB:                             ; CODE XREF: .text:0049960Aj
    mov     eax, [ecx+39249h]
    test    eax, eax
    jz      loc_499870
    mov     ecx, [ecx+391E9h]
    call    sub_435100
    cmp     eax, 1
    jnz     loc_4997A0
    call    sub_491B60
    push    1
    call    sub_491D70
    mov     ecx, TAdynmemStructPtr
    add     ecx, 519h
    push    ecx
    call    sub_4A9660
    call    sub_4257A0
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+391E9h]
    call    sub_435C50
    mov     esi, eax
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_4352B0
    mov     ecx, TAdynmemStructPtr
    push    eax
    mov     ecx, [ecx+391E9h]
    call    sub_435110
    mov     edx, TAdynmemStructPtr
    push    esi
    mov     ecx, [edx+391E9h]
    call    sub_435C00
    test    eax, eax
    jz      loc_499836
    mov     eax, TAdynmemStructPtr
    or      byte ptr [eax+2A44h], 8
    jmp     loc_49982A
    ; ---------------------------------------------------------------------------

    loc_4997A0:                             ; CODE XREF: .text:00499717j
    mov     edx, TAdynmemStructPtr
    xor     esi, esi
    mov     si, [edx+TAdynmemStruct.LOS_Radar]
    call    sub_491B60
    push    1
    call    sub_491D70
    mov     eax, TAdynmemStructPtr
    add     eax, TAdynmemStruct.field_519
    push    eax
    call    sub_4A9660
    call    sub_4257A0
    mov     eax, TAdynmemStructPtr
    cmp     byte ptr [eax+2CBEh], 14h
    jz      short loc_499801
    mov     byte ptr [eax+2CBEh], 14h
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+148CFh]
    add     eax, 519h
    push    ecx
    push    eax
    call    sub_4AB400
    mov     eax, TAdynmemStructPtr

    loc_499801:                             ; CODE XREF: .text:004997DCj
    mov     [eax+TAdynmemStruct.LOS_Radar], si
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+29A0h]
    mov     ecx, [eax+391E9h]
    add     edx, 11Ch
    push    edx
    call    sub_435A20
    call    sub_47A760

    loc_49982A:                             ; CODE XREF: .text:0049979Bj
    mov     eax, TAdynmemStructPtr
    or      [eax+2A44h], di

    loc_499836:                             ; CODE XREF: .text:00499789j
    mov     eax, TAdynmemStructPtr
    push    0
    push    offset loc_4578F0
    mov     dword ptr [eax+391F1h], 2
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+391F5h], offset dword_496BB0
    call    sub_4B4FD0
    mov     edx, TAdynmemStructPtr
    push    edi
    mov     ecx, [edx+10h]
    call    sub_4CE690

    loc_499870:                             ; CODE XREF: .text:00499703j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    loc_499880:                             ; DATA XREF: sub_490B30+A7o
                                            ; .text:004996DFo
    jmp     loc_41F7F0
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_499890 proc near                    ; CODE XREF: sub_49E830+433p

    var_130= dword ptr -130h
    var_120= dword ptr -120h
    var_118= dword ptr -118h
    var_108= dword ptr -108h
    var_100= dword ptr -100h

    sub     esp, 130h
    push    esi
    push    edi
    call    sub_4C1B00
    mov     edi, eax
    cmp     edi, 7Eh
    jnz     short loc_4998C0
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F2Fh]
    shr     cl, 1
    test    cl, 1
    jz      short loc_4998C0
    call    sub_4C1AB0
    call    sub_4B5910

    loc_4998C0:                             ; CODE XREF: sub_499890+12j
                                            ; sub_499890+24j
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+37EBEh], 1
    jz      short loc_499915
    cmp     edi, 0E3h
    jnz     short loc_499915
    call    sub_4C1AB0
    push    0
    call    sub_491D70
    mov     eax, TAdynmemStructPtr
    mov     esi, 0FFFEh
    and     [eax+37EBEh], si
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+391E9h]
    call    sub_435100
    cmp     eax, 3
    jz      short loc_499915
    mov     eax, TAdynmemStructPtr
    and     [eax+38A51h], si

    loc_499915:                             ; CODE XREF: sub_499890+3Dj
                                            ; sub_499890+45j ...
    cmp     edi, 0D6h
    jnz     short loc_49997D
    call    sub_4C1AB0
    mov     ecx, TAdynmemStructPtr
    add     ecx, 38A53h
    push    ecx
    call    sub_4BCF00
    mov     edx, TAdynmemStructPtr
    lea     eax, [esp+138h+var_100]
    add     edx, 38A53h
    push    edx
    push    offset aSScreenshots            ; "%s\\screenshots"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+138h+var_100]
    push    ecx
    call    sub_4BCF00
    lea     edx, [esp+138h+var_100]
    push    offset aShot                    ; "SHOT"
    push    edx
    call    sub_4CB170
    call    sub_4B6340
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+38A37h], eax

    loc_49997D:                             ; CODE XREF: sub_499890+8Bj
    lea     edx, [esp+138h+var_130]
    push    edx
    call    sub_4C2DE0
    mov     eax, TAdynmemStructPtr
    add     eax, 519h
    push    eax
    call    sub_4A9FD0
    lea     ecx, [esp+138h+var_118]
    push    ecx
    call    sub_4C2DE0
    call    sub_494E70
    call    sub_47F680
    mov     eax, [esp+138h+var_120]
    mov     ecx, [esp+138h+var_108]
    cmp     eax, ecx
    jnz     short loc_4999CB
    mov     edx, TAdynmemStructPtr
    add     edx, 2C76h
    push    edx
    call    sub_4C2D60
    jmp     short loc_499A06
    ; ---------------------------------------------------------------------------

    loc_4999CB:                             ; CODE XREF: sub_499890+125j
    cmp     eax, 205h
    jz      short loc_4999EF
    cmp     eax, 202h
    jz      short loc_4999EF
    mov     eax, TAdynmemStructPtr
    mov     ecx, 6
    lea     esi, [esp+138h+var_118]
    lea     edi, [eax+2C76h]
    jmp     short loc_499A04
    ; ---------------------------------------------------------------------------

    loc_4999EF:                             ; CODE XREF: sub_499890+140j
                                            ; sub_499890+147j
    mov     ecx, TAdynmemStructPtr
    lea     esi, [esp+138h+var_130]
    lea     edi, [ecx+2C76h]
    mov     ecx, 6

    loc_499A04:                             ; CODE XREF: sub_499890+15Dj
    rep movsd

    loc_499A06:                             ; CODE XREF: sub_499890+139j
    call    sub_4B6370
    mov     eax, TAdynmemStructPtr
    mov     edx, [eax+0Ch]
    test    byte ptr [edx+0F1h], 8
    jnz     short loc_499A22
    call    dword ptr [eax+391F5h]

    loc_499A22:                             ; CODE XREF: sub_499890+18Aj
    pop     edi
    pop     esi
    add     esp, 130h
    retn
    sub_499890 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_499A30 proc near                    ; CODE XREF: sub_4917D0+E6p
    push    edi
    push    7D64h
    push    offset aWeaponArray             ; "WEAPON ARRAY"
    call    sub_4D83B0
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    mov     [ecx+141F7h], eax
    mov     edx, TAdynmemStructPtr
    mov     ecx, 1F59h
    xor     eax, eax
    mov     edi, [edx+141F7h]
    rep stosd
    mov     eax, TAdynmemStructPtr
    pop     edi
    mov     dword ptr [eax+141F3h], 0
    retn
    sub_499A30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_499A80 proc near                    ; CODE XREF: sub_491B60+D0p
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+141F7h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, TAdynmemStructPtr
    add     esp, 4
    mov     dword ptr [edx+141F7h], 0
    retn
    sub_499A80 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    sub     esp, 24h
    test    byte ptr [eax+2A44h], 1
    jz      loc_499B90
    mov     ecx, [esp+34h]
    mov     byte ptr [esp+0], 0Dh
    push    esi
    mov     edx, [ecx]
    mov     [esp+5], edx
    mov     edx, [esp+3Ch]
    mov     eax, [ecx+4]
    mov     [esp+9], eax
    mov     eax, [edx]
    mov     ecx, [ecx+8]
    mov     [esp+11h], eax
    mov     eax, [esp+2Ch]
    mov     [esp+0Dh], ecx
    mov     ecx, [edx+4]
    mov     [esp+15h], ecx
    mov     ecx, [eax+0Ch]
    mov     edx, [edx+8]
    mov     [esp+19h], edx
    mov     dl, [ecx+10Ah]
    mov     [esp+1Dh], dl
    mov     dl, [eax+1Bh]
    shr     dl, 2
    and     dl, 3
    mov     [esp+27h], dl
    mov     edx, [esp+30h]
    test    edx, edx
    jnz     short loc_499B28
    mov     [esp+25h], dx
    jmp     short loc_499B34
    ; ---------------------------------------------------------------------------

    loc_499B28:                             ; CODE XREF: .text:00499B1Fj
    mov     si, [edx+0A8h]
    mov     [esp+25h], si

    loc_499B34:                             ; CODE XREF: .text:00499B26j
    mov     esi, [esp+34h]
    test    esi, esi
    jnz     short loc_499B43
    mov     [esp+23h], si
    jmp     short loc_499B4F
    ; ---------------------------------------------------------------------------

    loc_499B43:                             ; CODE XREF: .text:00499B3Aj
    mov     si, [esi+0A8h]
    mov     [esp+23h], si

    loc_499B4F:                             ; CODE XREF: .text:00499B41j
    mov     si, [eax+16h]
    mov     ax, [eax+18h]
    mov     [esp+1Fh], si
    mov     [esp+21h], ax
    mov     ecx, [ecx+111h]
    mov     al, [esp+1Eh]
    shr     ecx, 1Eh
    xor     cl, al
    push    24h
    and     cl, 1
    xor     al, cl
    mov     ecx, [edx+96h]
    mov     [esp+22h], al
    lea     eax, [esp+8]
    mov     edx, [ecx+4]
    push    eax
    push    edx
    call    sub_451DF0
    pop     esi

    loc_499B90:                             ; CODE XREF: .text:00499ABFj
    add     esp, 24h
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, TAdynmemStructPtr
    sub     esp, 24h
    test    byte ptr [eax+2A44h], 1
    jz      short loc_499C00
    mov     ecx, [esp+2Ch]
    push    24h
    mov     byte ptr [esp+4], 0Dh
    mov     edx, [ecx]
    mov     [esp+5], edx
    mov     edx, [esp+34h]
    mov     eax, [ecx+4]
    mov     [esp+9], eax
    mov     eax, [edx]
    mov     ecx, [ecx+8]
    mov     [esp+11h], eax
    mov     al, [esp+2Ch]
    mov     [esp+0Dh], ecx
    mov     ecx, [edx+4]
    mov     [esp+1Dh], al
    mov     [esp+15h], ecx
    lea     ecx, [esp+4]
    mov     edx, [edx+8]
    push    ecx
    mov     [esp+1Dh], edx
    call    sub_44FDB0
    push    eax
    call    sub_451DF0

    loc_499C00:                             ; CODE XREF: .text:00499BAFj
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    push    ebx
    mov     ebx, [esp+8]
    push    esi
    mov     si, [eax+16h]
    push    edi
    sub     si, [ebx+66h]
    push    320h
    push    esi
    call    sub_4B70EF
    add     esp, 8
    mov     edi, eax
    neg     edi
    push    320h
    push    esi
    call    sub_4B7123
    add     esp, 8
    mov     ecx, [ebx+9Ah]
    neg     eax
    push    0
    push    0
    push    edi
    push    eax
    push    2
    push    0
    push    0
    push    offset aRockunit                ; "RockUnit"
    call    sub_4B0A70
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebp
    mov     ebp, [esp+0Ch]
    push    esi
    mov     esi, [esp+0Ch]
    push    edi
    push    3F800000h
    push    ebp
    push    esi
    call    sub_499CD0
    mov     edi, [esi+52h]
    test    edi, edi
    jz      short loc_499CC2
    push    ebx
    mov     bl, [esi+66h]
    xor     edx, edx
    xor     ecx, ecx
    cmp     bl, [ebp+0FFh]
    jz      short loc_499CA2
    mov     edx, eax
    jmp     short loc_499CA4
    ; ---------------------------------------------------------------------------

    loc_499CA2:                             ; CODE XREF: .text:00499C9Cj
    mov     ecx, eax

    loc_499CA4:                             ; CODE XREF: .text:00499CA0j
    mov     eax, [edi+96h]
    and     ecx, 0FFFFh
    and     edx, 0FFFFh
    push    ecx
    mov     ecx, [eax+74h]
    push    edx
    push    esi
    call    sub_406F50
    pop     ebx

    loc_499CC2:                             ; CODE XREF: .text:00499C8Cj
    pop     edi
    pop     esi
    pop     ebp
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_499CD0 proc near                    ; CODE XREF: .text:00499C82p
                                            ; sub_499EB0+1B2p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    mov     eax, [esp+8+arg_0]
    xor     ecx, ecx
    push    ebx
    push    ebp
    mov     eax, [eax]
    push    esi
    push    edi
    mov     edi, [esp+18h+arg_4]
    mov     cx, [eax+0D4h]
    mov     eax, [eax+64h]
    test    eax, eax
    mov     [esp+18h+var_8], ecx
    mov     [esp+18h+var_4], eax
    jz      short loc_499D73
    mov     ebp, [edi+92h]
    mov     esi, [eax+5]
    mov     ebx, [eax+9]
    add     ebp, 20h
    cmp     esi, ebx
    jz      short loc_499D46

    loc_499D0C:                             ; CODE XREF: sub_499CD0+6Cj
    mov     eax, ebx
    push    ebp                             ; char *
    sub     eax, esi
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     edx, [esi+eax*8]
    lea     edi, [esi+eax*8]
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_499D38
    lea     esi, [edi+8]
    jmp     short loc_499D3A
    ; ---------------------------------------------------------------------------

    loc_499D38:                             ; CODE XREF: sub_499CD0+61j
    mov     ebx, edi

    loc_499D3A:                             ; CODE XREF: sub_499CD0+66j
    cmp     esi, ebx
    jnz     short loc_499D0C
    mov     edi, [esp+18h+arg_4]
    mov     eax, [esp+18h+var_4]

    loc_499D46:                             ; CODE XREF: sub_499CD0+3Aj
    cmp     esi, [eax+9]
    jz      short loc_499D67
    mov     edx, [esi]
    push    edx                             ; char *
    push    ebp                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jnz     short loc_499D67
    add     esi, 4
    jmp     short loc_499D69
    ; ---------------------------------------------------------------------------

    loc_499D67:                             ; CODE XREF: sub_499CD0+79j
                                            ; sub_499CD0+90j
    xor     esi, esi

    loc_499D69:                             ; CODE XREF: sub_499CD0+95j
    test    esi, esi
    jz      short loc_499D73
    mov     edx, [esi]
    mov     [esp+18h+var_8], edx

    loc_499D73:                             ; CODE XREF: sub_499CD0+27j
                                            ; sub_499CD0+9Bj
    fild    [esp+18h+var_8]
    fmul    [esp+18h+arg_8]
    call    __ftol
    mov     ebx, [esp+18h+arg_0]
    mov     edx, [edi+72h]
    mov     esi, eax
    mov     eax, [ebx+0Ch]
    mov     ecx, [ebx+4]
    sub     eax, edx
    push    eax
    mov     eax, [edi+6Ah]
    sub     ecx, eax
    push    ecx
    call    sub_4B715A
    mov     ebx, [ebx+52h]
    mov     bp, ax
    sub     bp, [edi+66h]
    add     esp, 8
    test    ebx, ebx
    jz      short loc_499DEE
    xor     ecx, ecx
    mov     eax, 66666667h
    mov     cx, [ebx+0B8h]
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, 5
    jle     short loc_499DD1
    mov     edx, 5

    loc_499DD1:                             ; CODE XREF: sub_499CD0+FAj
    lea     ecx, [edx+edx*2]
    mov     eax, 51EB851Fh
    lea     ecx, [ecx+ecx+64h]
    imul    ecx, esi
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     esi, edx

    loc_499DEE:                             ; CODE XREF: sub_499CD0+DCj
    mov     ecx, TAdynmemStructPtr
    mov     ax, [ecx+37F2Fh]
    mov     dl, al
    shr     dl, 7
    test    dl, 1
    jz      short loc_499E07
    add     esi, esi

    loc_499E07:                             ; CODE XREF: sub_499CD0+133j
    xor     ecx, ecx
    mov     cl, ah
    test    cl, 1
    jz      short loc_499E19
    mov     eax, esi
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     esi, eax

    loc_499E19:                             ; CODE XREF: sub_499CD0+13Ej
    mov     edx, [esp+18h+arg_0]
    push    ebp
    mov     eax, [edx]
    mov     ecx, [eax+111h]
    shr     ecx, 7
    and     cl, 1
    neg     cl
    sbb     ecx, ecx
    neg     ecx
    inc     ecx
    push    ecx
    push    esi
    push    edi
    push    ebx
    call    sub_489BB0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_499CD0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, TAdynmemStructPtr
    mov     ecx, [esp+4]
    mov     eax, [edx+142F7h]
    cmp     ecx, eax
    jnz     short loc_499EA4
    add     eax, 4
    push    esi
    add     edx, 1433Fh
    mov     esi, [eax]
    mov     [edx], esi
    mov     esi, [eax+4]
    mov     [edx+4], esi
    pop     esi
    mov     eax, [eax+8]
    mov     [edx+8], eax
    mov     edx, [ecx]
    mov     ax, [edx+0FEh]
    mov     edx, TAdynmemStructPtr
    mov     [edx+1434Bh], ax
    mov     eax, TAdynmemStructPtr
    mov     dword ptr [eax+142F7h], 0

    loc_499EA4:                             ; CODE XREF: .text:00499E62j
    or      byte ptr [ecx+69h], 2
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_499EB0 proc near                    ; CODE XREF: sub_49A120+644p
                                            ; sub_49AF90+5Bp ...

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    xor     ebx, ebx
    mov     edi, [esi]
    lea     ebp, [esi+4]
    push    ebp                             ; int
    call    sub_4815A0
    mov     ecx, TAdynmemStructPtr
    test    eax, eax
    jz      short loc_499EDE
    mov     al, [eax+5]
    mov     dl, [ecx+1427Fh]
    cmp     al, dl
    sbb     ebx, ebx
    neg     ebx

    loc_499EDE:                             ; CODE XREF: sub_499EB0+1Dj
    test    dword ptr [edi+111h], 400000h
    jnz     short loc_499F3C
    mov     eax, [ecx+142F7h]
    cmp     esi, eax
    jnz     short loc_499F32
    add     eax, 4
    add     ecx, 1433Fh
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    mov     ecx, [esi]
    mov     eax, TAdynmemStructPtr
    mov     dx, [ecx+0FEh]
    mov     [eax+1434Bh], dx
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+142F7h], 0

    loc_499F32:                             ; CODE XREF: sub_499EB0+42j
    or      byte ptr [esi+69h], 2
    mov     ecx, TAdynmemStructPtr

    loc_499F3C:                             ; CODE XREF: sub_499EB0+38j
    mov     edx, [ecx+391E9h]
    mov     eax, [edx+0D48h]
    test    eax, eax
    jz      short loc_499FAB
    test    ebx, ebx
    jz      short loc_499FAB
    mov     eax, [esp+4+arg_4]
    test    eax, eax
    jnz     short loc_499FAB
    mov     eax, [ecx+142F7h]
    cmp     esi, eax
    jnz     short loc_499FA0
    add     eax, 4
    add     ecx, 1433Fh
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    mov     ecx, [esi]
    mov     eax, TAdynmemStructPtr
    mov     dx, [ecx+0FEh]
    mov     [eax+1434Bh], dx
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+142F7h], 0

    loc_499FA0:                             ; CODE XREF: sub_499EB0+B0j
    or      byte ptr [esi+69h], 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_499FAB:                             ; CODE XREF: sub_499EB0+9Aj
                                            ; sub_499EB0+9Ej ...
    mov     edx, [edi+0D0h]
    mov     eax, [edi+0CCh]
    push    edx
    push    eax
    push    eax
    call    sub_41C640
    test    ebx, ebx
    jz      short loc_499FE5
    mov     eax, [esp+4+arg_4]
    test    eax, eax
    jnz     short loc_499FE5
    xor     eax, eax
    push    0
    mov     ax, [edi+0F8h]
    push    ebp
    push    eax
    call    sub_47F300
    mov     ecx, [edi+7Ch]
    push    ebx
    push    0
    jmp     short loc_49A014
    ; ---------------------------------------------------------------------------

    loc_499FE5:                             ; CODE XREF: sub_499EB0+111j
                                            ; sub_499EB0+119j
    xor     edx, edx
    push    0
    mov     dx, [edi+0F6h]
    push    ebp
    push    edx
    call    sub_47F300
    mov     eax, [edi+111h]
    shr     eax, 0Ah
    test    al, 1
    jz      short loc_49A00E
    push    9
    push    ebp
    call    sub_472810
    jmp     short loc_49A01B
    ; ---------------------------------------------------------------------------

    loc_49A00E:                             ; CODE XREF: sub_499EB0+152j
    mov     ecx, [edi+78h]
    push    ebx
    push    0

    loc_49A014:                             ; CODE XREF: sub_499EB0+133j
    push    ecx
    push    ebp
    call    sub_420A30

    loc_49A01B:                             ; CODE XREF: sub_499EB0+15Cj
    xor     ecx, ecx
    mov     cl, [esi+66h]
    mov     eax, ecx
    shl     eax, 5
    add     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    add     eax, ecx
    mov     ecx, [eax+edx*2+1B63h]
    lea     eax, [eax+edx*2+1B63h]
    test    ecx, ecx
    jz      short loc_49A049
    cmp     byte ptr [eax+73h], 3
    jz      short loc_49A0AE

    loc_49A049:                             ; CODE XREF: sub_499EB0+191j
    cmp     word ptr [edi+0D6h], 10h
    ja      short loc_49A0A7
    mov     edi, [esp+4+arg_4]
    test    edi, edi
    jz      short loc_49A0A7
    push    3F800000h
    push    edi
    push    esi
    call    sub_499CD0
    mov     ebp, [esi+52h]
    test    ebp, ebp
    jz      short loc_49A0AE
    mov     bl, [esi+66h]
    xor     edx, edx
    xor     ecx, ecx
    cmp     bl, [edi+0FFh]
    jz      short loc_49A081
    mov     edx, eax
    jmp     short loc_49A083
    ; ---------------------------------------------------------------------------

    loc_49A081:                             ; CODE XREF: sub_499EB0+1CBj
    mov     ecx, eax

    loc_49A083:                             ; CODE XREF: sub_499EB0+1CFj
    and     ecx, 0FFFFh
    and     edx, 0FFFFh
    push    ecx
    mov     ecx, [ebp+96h]
    push    edx
    push    esi
    mov     ecx, [ecx+74h]
    call    sub_406F50
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49A0A7:                             ; CODE XREF: sub_499EB0+1A1j
                                            ; sub_499EB0+1A9j
    push    ebp
    push    esi
    call    sub_49A120

    loc_49A0AE:                             ; CODE XREF: sub_499EB0+197j
                                            ; sub_499EB0+1BCj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_499EB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49A0C0 proc near                    ; CODE XREF: sub_4239C0+220p

    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_1A= dword ptr -1Ah
    var_6= byte ptr -6
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 6Ch
    push    edi
    mov     ecx, 1Ah
    xor     eax, eax
    lea     edi, [esp+70h+var_6C]
    rep stosd
    stosw
    stosb
    mov     eax, [esp+70h+arg_0]
    mov     [esp+70h+var_1A], 0
    mov     [esp+70h+var_6C], eax
    mov     eax, [esp+70h+arg_4]
    mov     ecx, eax
    push    eax
    mov     [esp+74h+var_6], 0Ah
    mov     edx, [ecx]
    mov     [esp+74h+var_68], edx
    mov     edx, [ecx+4]
    mov     [esp+74h+var_64], edx
    lea     edx, [esp+74h+var_6C]
    mov     ecx, [ecx+8]
    push    edx
    mov     [esp+78h+var_60], ecx
    call    sub_49A120
    pop     edi
    add     esp, 6Ch
    retn    8
    sub_49A0C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_49A120 proc near                    ; CODE XREF: sub_499EB0+1F9p
                                            ; sub_49A0C0+49p

    var_1E4= dword ptr -1E4h
    var_1E0= dword ptr -1E0h
    var_1DC= dword ptr -1DCh
    var_1D8= dword ptr -1D8h
    var_1D0= qword ptr -1D0h
    var_1C4= dword ptr -1C4h
    var_1C0= dword ptr -1C0h
    var_1BC= dword ptr -1BCh
    var_1B8= dword ptr -1B8h
    var_1B4= dword ptr -1B4h
    var_1B0= dword ptr -1B0h
    var_1AC= dword ptr -1ACh
    var_1A8= dword ptr -1A8h
    var_1A4= dword ptr -1A4h
    var_1A0= dword ptr -1A0h
    idTo= dword ptr -19Ch
    var_197= dword ptr -197h
    var_193= dword ptr -193h
    var_18F= byte ptr -18Fh
    var_18C= dword ptr -18Ch
    var_188= dword ptr -188h
    var_184= dword ptr -184h
    var_180= dword ptr -180h
    var_17C= dword ptr -17Ch
    var_178= dword ptr -178h
    var_174= dword ptr -174h
    var_170= dword ptr -170h
    var_16C= dword ptr -16Ch
    var_168= dword ptr -168h
    var_164= dword ptr -164h
    var_160= dword ptr -160h
    var_15C= dword ptr -15Ch
    var_158= dword ptr -158h
    var_154= dword ptr -154h
    var_150= dword ptr -150h
    var_100= dword ptr -100h
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebp
    mov     ebp, esp
    and     esp, 0FFFFFFF8h
    sub     esp, 1E4h
    xor     eax, eax
    push    ebx
    mov     [esp+1E8h+var_154], eax
    mov     [esp+1E8h+var_158], eax
    mov     eax, [ebp+arg_0]
    push    esi
    mov     esi, [ebp+arg_4]
    push    edi
    mov     ecx, [eax]
    xor     eax, eax
    mov     ax, [ecx+0D6h]
    shr     eax, 1
    mov     [esp+1F0h+var_1A4], eax
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     ecx, eax
    movsx   eax, word ptr [esi+2]
    cdq
    and     edx, 0Fh
    sar     ecx, 4
    add     eax, edx
    inc     ecx
    sar     eax, 4
    mov     edi, eax
    lea     ebx, [ecx+eax]
    sub     edi, ecx
    movsx   eax, word ptr [esi+0Ah]
    cdq
    and     edx, 0Fh
    mov     [esp+1F0h+var_1A0], edi
    add     eax, edx
    mov     [esp+1F0h+var_1A8], ebx
    sar     eax, 4
    mov     edx, eax
    sub     edx, ecx
    add     ecx, eax
    test    edi, edi
    mov     [esp+1F0h+var_1E4], ecx
    jge     short loc_49A1A1
    mov     [esp+1F0h+var_1A0], 0

    loc_49A1A1:                             ; CODE XREF: sub_49A120+77j
    mov     esi, TAdynmemStructPtr
    mov     eax, [esi+14233h]
    cmp     ebx, eax
    jle     short loc_49A1B5
    mov     [esp+1F0h+var_1A8], eax

    loc_49A1B5:                             ; CODE XREF: sub_49A120+8Fj
    xor     edi, edi
    cmp     edx, edi
    jge     short loc_49A1BD
    xor     edx, edx

    loc_49A1BD:                             ; CODE XREF: sub_49A120+99j
    mov     eax, [esi+14237h]
    cmp     ecx, eax
    jle     short loc_49A1CB
    mov     [esp+1F0h+var_1E4], eax

    loc_49A1CB:                             ; CODE XREF: sub_49A120+A5j
    mov     eax, [esp+1F0h+var_1E4]
    mov     ebx, edx
    cmp     edx, eax
    mov     [esp+1F0h+var_1C0], edi
    mov     [esp+1F0h+var_1AC], edi
    mov     [esp+1F0h+var_1C4], ebx
    jge     loc_49A664
    mov     esi, [esp+1F0h+var_1A0]

    loc_49A1E9:                             ; CODE XREF: sub_49A120+53Ej
    push    ebx
    push    esi
    call    sub_481550
    mov     edi, eax
    mov     eax, [esp+1F0h+var_1A8]
    cmp     esi, eax
    mov     [esp+1F0h+var_1DC], edi
    mov     [esp+1F0h+var_1B0], esi
    jge     loc_49A653

    loc_49A206:                             ; CODE XREF: sub_49A120+525j
    test    edi, edi
    jz      loc_49A62F
    xor     eax, eax
    mov     [esp+1F0h+var_1E0], eax

    loc_49A214:                             ; CODE XREF: sub_49A120+301j
    test    eax, eax
    jz      short loc_49A225
    mov     ax, [edi+2]
    test    ax, ax
    jnz     short loc_49A231
    xor     esi, esi
    jmp     short loc_49A24E
    ; ---------------------------------------------------------------------------

    loc_49A225:                             ; CODE XREF: sub_49A120+F6j
    mov     ax, [edi]
    test    ax, ax
    jnz     short loc_49A231
    xor     esi, esi
    jmp     short loc_49A24E
    ; ---------------------------------------------------------------------------

    loc_49A231:                             ; CODE XREF: sub_49A120+FFj
                                            ; sub_49A120+10Bj
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+14357h]
    lea     esi, [ecx+edx*8]

    loc_49A24E:                             ; CODE XREF: sub_49A120+103j
                                            ; sub_49A120+10Fj
    test    esi, esi
    jz      loc_49A415
    mov     ebx, [ebp+arg_0]
    cmp     esi, [ebx+52h]
    jz      loc_49A415
    mov     ecx, [esp+1F0h+var_158]
    xor     eax, eax
    test    ecx, ecx
    jle     short loc_49A28F
    lea     ecx, [esp+1F0h+var_150]

    loc_49A276:                             ; CODE XREF: sub_49A120+16Bj
    cmp     [ecx], esi
    jz      loc_49A415
    mov     edx, [esp+1F0h+var_158]
    inc     eax
    add     ecx, 4
    cmp     eax, edx
    jl      short loc_49A276
    mov     ecx, edx

    loc_49A28F:                             ; CODE XREF: sub_49A120+14Dj
    cmp     ecx, 14h
    jge     short loc_49A2AA
    mov     [esp+ecx*4+1F0h+var_150], esi
    mov     eax, [esp+1F0h+var_158]
    inc     eax
    mov     [esp+1F0h+var_158], eax

    loc_49A2AA:                             ; CODE XREF: sub_49A120+172j
    mov     edx, [ebp+arg_4]
    mov     eax, [esi+92h]
    mov     edi, [esi+6Ah]
    mov     ecx, [edx]
    mov     edx, [eax+15Eh]
    add     edx, edi
    cmp     ecx, edx
    jge     short loc_49A2CC
    sub     edx, ecx
    mov     [esp+1F0h+var_1BC], edx
    jmp     short loc_49A2E8
    ; ---------------------------------------------------------------------------

    loc_49A2CC:                             ; CODE XREF: sub_49A120+1A2j
    mov     edx, [eax+16Ah]
    add     edi, edx
    cmp     ecx, edi
    jle     short loc_49A2E0
    sub     ecx, edi
    mov     [esp+1F0h+var_1BC], ecx
    jmp     short loc_49A2E8
    ; ---------------------------------------------------------------------------

    loc_49A2E0:                             ; CODE XREF: sub_49A120+1B6j
    mov     [esp+1F0h+var_1BC], 0

    loc_49A2E8:                             ; CODE XREF: sub_49A120+1AAj
                                            ; sub_49A120+1BEj
    mov     ecx, [ebp+arg_4]
    mov     edi, [esi+6Eh]
    mov     edx, [eax+162h]
    mov     ecx, [ecx+4]
    add     edx, edi
    cmp     ecx, edx
    jge     short loc_49A305
    sub     edx, ecx
    mov     [esp+1F0h+var_1B8], edx
    jmp     short loc_49A321
    ; ---------------------------------------------------------------------------

    loc_49A305:                             ; CODE XREF: sub_49A120+1DBj
    mov     edx, [eax+16Eh]
    add     edi, edx
    cmp     ecx, edi
    jle     short loc_49A319
    sub     ecx, edi
    mov     [esp+1F0h+var_1B8], ecx
    jmp     short loc_49A321
    ; ---------------------------------------------------------------------------

    loc_49A319:                             ; CODE XREF: sub_49A120+1EFj
    mov     [esp+1F0h+var_1B8], 0

    loc_49A321:                             ; CODE XREF: sub_49A120+1E3j
                                            ; sub_49A120+1F7j
    mov     ecx, [ebp+arg_4]
    mov     edi, [esi+72h]
    mov     edx, [eax+166h]
    mov     ecx, [ecx+8]
    add     edx, edi
    cmp     ecx, edx
    jge     short loc_49A33E
    sub     edx, ecx
    mov     [esp+1F0h+var_1B4], edx
    jmp     short loc_49A35A
    ; ---------------------------------------------------------------------------

    loc_49A33E:                             ; CODE XREF: sub_49A120+214j
    mov     eax, [eax+172h]
    add     edi, eax
    cmp     ecx, edi
    jle     short loc_49A352
    sub     ecx, edi
    mov     [esp+1F0h+var_1B4], ecx
    jmp     short loc_49A35A
    ; ---------------------------------------------------------------------------

    loc_49A352:                             ; CODE XREF: sub_49A120+228j
    mov     [esp+1F0h+var_1B4], 0

    loc_49A35A:                             ; CODE XREF: sub_49A120+21Cj
                                            ; sub_49A120+230j
    fild    [esp+1F0h+var_1BC]
    fild    [esp+1F0h+var_1B8]
    fild    [esp+1F0h+var_1B4]
    fxch    st(2)
    fst     [esp+1F0h+var_1D0]
    fxch    st(1)
    fst     qword ptr [esp+1F0h+var_1D8]
    fxch    st(1)
    fmul    [esp+1F0h+var_1D0]
    fxch    st(1)
    fmul    qword ptr [esp+1F0h+var_1D8]
    fld     st(2)
    fmul    st, st(3)
    fxch    st(1)
    faddp   st(2), st
    faddp   st(1), st
    fsqrt
    call    __ftol
    mov     ecx, [esp+1F0h+var_1A4]
    mov     [esp+1F0h+var_1D8], eax
    movsx   eax, word ptr [esp+1F0h+var_1D8+2]
    fstp    st
    cmp     eax, ecx
    mov     [esp+1F0h+var_1D8], eax
    jge     short loc_49A411
    mov     ecx, [ebx]
    test    eax, eax
    mov     edx, [ecx+0D8h]
    mov     [esp+1F0h+var_184], edx
    jz      short loc_49A3E6
    fild    [esp+1F0h+var_1D8]
    fild    [esp+1F0h+var_1A4]
    fld     ds:flt_4FDA58
    fsub    [esp+1F0h+var_184]
    fxch    st(1)
    fdivp   st(2), st
    fxch    st(1)
    fsub    ds:flt_4FDA58
    fxch    st(1)
    fld     st(1)
    fmulp   st(2), st
    fmulp   st(1), st
    fadd    [esp+1F0h+var_184]
    fstp    [esp+1F0h+var_17C]
    jmp     short loc_49A3EE
    ; ---------------------------------------------------------------------------

    loc_49A3E6:                             ; CODE XREF: sub_49A120+294j
    mov     [esp+1F0h+var_17C], 3F800000h

    loc_49A3EE:                             ; CODE XREF: sub_49A120+2C4j
    mov     eax, [esp+1F0h+var_17C]
    push    eax
    push    esi
    push    ebx
    call    sub_499CD0
    mov     cl, [ebx+66h]
    mov     dl, [esi+0FFh]
    cmp     cl, dl
    jnz     short loc_49A40D
    add     [esp+1F0h+var_1AC], eax
    jmp     short loc_49A411
    ; ---------------------------------------------------------------------------

    loc_49A40D:                             ; CODE XREF: sub_49A120+2E5j
    add     [esp+1F0h+var_1C0], eax

    loc_49A411:                             ; CODE XREF: sub_49A120+284j
                                            ; sub_49A120+2EBj
    mov     edi, [esp+1F0h+var_1DC]

    loc_49A415:                             ; CODE XREF: sub_49A120+130j
                                            ; sub_49A120+13Cj ...
    mov     eax, [esp+1F0h+var_1E0]
    inc     eax
    cmp     eax, 1
    mov     [esp+1F0h+var_1E0], eax
    jle     loc_49A214
    mov     edx, [ebp+arg_0]
    mov     eax, [edx]
    mov     ecx, [eax+111h]
    test    ch, 40h
    jnz     loc_49A62F
    mov     eax, [esp+1F0h+var_1B0]
    mov     ecx, [esp+1F0h+var_1C4]
    cmp     word ptr [edi+8], 0FFFEh
    mov     [esp+1F0h+var_1E0], edi
    mov     [esp+1F0h+var_1D8], eax
    mov     [esp+1F0h+var_18C], ecx
    jnz     short loc_49A478
    xor     edx, edx
    mov     dl, [edi+0Bh]
    sub     eax, edx
    xor     edx, edx
    mov     dl, [edi+0Ah]
    mov     [esp+1F0h+var_1D8], eax
    sub     ecx, edx
    push    ecx
    push    eax
    mov     [esp+1F8h+var_18C], ecx
    call    sub_481550
    mov     [esp+1F0h+var_1E0], eax

    loc_49A478:                             ; CODE XREF: sub_49A120+335j
    mov     eax, [esp+1F0h+var_1E0]
    mov     si, [eax+8]
    cmp     si, 0FFFBh
    jnb     loc_49A62F
    mov     ebx, TAdynmemStructPtr
    mov     ecx, edi
    mov     eax, 4EC4EC4Fh
    mov     edx, [ebx+14287h]
    mov     edi, [ebx+14233h]
    sub     ecx, edx
    imul    ecx
    sar     edx, 2
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     ecx, edx
    mov     eax, ecx
    cdq
    idiv    edi
    mov     eax, ecx
    mov     ecx, [esp+1F0h+var_1DC]
    mov     word ptr [esp+1F0h+var_180], dx
    cdq
    idiv    edi
    mov     word ptr [esp+1F0h+var_180+2], ax
    mov     edx, [esp+1F0h+var_180]
    xor     eax, eax
    mov     [esp+1F0h+var_178], edx
    mov     ax, [ecx+0Ah]
    mov     edi, [ebx+1420Bh]
    mov     dl, [ecx+0Ch]
    lea     eax, [eax+eax*2]
    shl     eax, 4
    add     eax, edi
    test    dl, 1
    jz      short loc_49A53E
    test    eax, eax
    jz      short loc_49A53E
    mov     esi, [ebp+arg_4]
    mov     edx, [eax+8]
    mov     ebx, [eax+0Ch]
    mov     edi, [eax+10h]
    mov     ecx, [esi]
    lea     eax, [esp+1F0h+var_164]
    sub     ecx, edx
    mov     edx, [esi+4]
    mov     esi, [esi+8]
    sub     edx, ebx
    sub     esi, edi
    push    eax
    mov     [esp+1F4h+var_164], ecx
    mov     [esp+1F4h+var_160], edx
    mov     [esp+1F4h+var_15C], esi
    call    sub_49A850
    mov     dword ptr [esp+1F0h+var_1D0], eax
    movsx   eax, word ptr [esp+1F0h+var_1D0+2]
    jmp     loc_49A5C8
    ; ---------------------------------------------------------------------------

    loc_49A53E:                             ; CODE XREF: sub_49A120+3CEj
                                            ; sub_49A120+3D2j
    mov     ecx, [ebx+1426Fh]
    and     esi, 0FFFFh
    shl     esi, 8
    add     ecx, esi
    lea     edx, [esp+1F0h+var_178]
    push    ecx
    lea     eax, [esp+1F4h+idTo]
    push    edx
    push    eax
    call    sub_421EB0
    mov     ecx, [eax]
    mov     edx, [eax+4]
    mov     esi, [eax+8]
    mov     eax, [ebp+arg_4]
    mov     edi, [eax]
    sub     edi, ecx
    mov     ecx, [eax+4]
    sub     ecx, edx
    mov     edx, [eax+8]
    mov     [esp+1F0h+var_170], edi
    mov     [esp+1F0h+var_16C], ecx
    fild    [esp+1F0h+var_170]
    fild    [esp+1F0h+var_16C]
    sub     edx, esi
    mov     [esp+1F0h+var_168], edx
    fild    [esp+1F0h+var_168]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    mov     dword ptr [esp+1F0h+var_1D0], eax
    movsx   eax, word ptr [esp+1F0h+var_1D0+2]
    fstp    st

    loc_49A5C8:                             ; CODE XREF: sub_49A120+419j
    cmp     eax, [esp+1F0h+var_1A4]
    jge     short loc_49A62B
    mov     esi, [esp+1F0h+var_154]
    xor     ecx, ecx
    test    esi, esi
    jle     short loc_49A5F6
    lea     edx, [esp+1F0h+var_100]

    loc_49A5E2:                             ; CODE XREF: sub_49A120+4D2j
    mov     eax, [esp+1F0h+var_1E0]
    mov     edi, [edx]
    cmp     edi, eax
    jz      short loc_49A62B
    inc     ecx
    add     edx, 4
    cmp     ecx, esi
    jl      short loc_49A5E2
    jmp     short loc_49A5FA
    ; ---------------------------------------------------------------------------

    loc_49A5F6:                             ; CODE XREF: sub_49A120+4B9j
    mov     eax, [esp+1F0h+var_1E0]

    loc_49A5FA:                             ; CODE XREF: sub_49A120+4D4j
    cmp     esi, 40h
    jge     short loc_49A615
    mov     [esp+esi*4+1F0h+var_100], eax
    mov     ecx, [esp+1F0h+var_154]
    inc     ecx
    mov     [esp+1F0h+var_154], ecx

    loc_49A615:                             ; CODE XREF: sub_49A120+4DDj
    mov     ecx, [ebp+arg_0]
    mov     edx, [ecx]
    mov     ecx, [esp+1F0h+var_18C]
    push    edx                             ; int
    mov     edx, [esp+1F4h+var_1D8]
    push    ecx                             ; int
    push    edx                             ; int
    push    eax                             ; int
    call    sub_4244B0

    loc_49A62B:                             ; CODE XREF: sub_49A120+4ACj
                                            ; sub_49A120+4CAj
    mov     edi, [esp+1F0h+var_1DC]

    loc_49A62F:                             ; CODE XREF: sub_49A120+E8j
                                            ; sub_49A120+315j ...
    mov     eax, [esp+1F0h+var_1B0]
    mov     ecx, [esp+1F0h+var_1A8]
    inc     eax
    add     edi, 0Dh
    cmp     eax, ecx
    mov     [esp+1F0h+var_1B0], eax
    mov     [esp+1F0h+var_1DC], edi
    jl      loc_49A206
    mov     esi, [esp+1F0h+var_1A0]
    mov     ebx, [esp+1F0h+var_1C4]

    loc_49A653:                             ; CODE XREF: sub_49A120+E0j
    mov     eax, [esp+1F0h+var_1E4]
    inc     ebx
    cmp     ebx, eax
    mov     [esp+1F0h+var_1C4], ebx
    jl      loc_49A1E9

    loc_49A664:                             ; CODE XREF: sub_49A120+BFj
    mov     eax, [ebp+arg_0]
    mov     ecx, [eax]
    mov     edx, [ecx+111h]
    shr     edx, 1Eh
    test    dl, 1
    jz      loc_49A819
    mov     eax, TAdynmemStructPtr
    mov     [esp+1F0h+var_1D8], 0
    mov     edx, [eax+141F3h]
    mov     ecx, [eax+141F7h]
    test    edx, edx
    mov     [esp+1F0h+var_1E4], ecx
    jle     loc_49A819
    lea     ebx, [ecx+0Ch]

    loc_49A6A3:                             ; CODE XREF: sub_49A120+6F3j
    test    byte ptr [ebx+5Dh], 2
    jnz     loc_49A7EE
    mov     edx, [ebp+arg_0]
    cmp     ecx, edx
    jz      loc_49A7EE
    mov     eax, [edx+4]
    mov     ecx, [ebx-8]
    mov     edi, [ebx-4]
    mov     esi, [ebx]
    sub     eax, ecx
    mov     ecx, [edx+8]
    sub     ecx, edi
    mov     edi, [edx+0Ch]
    mov     edx, [edx]
    sub     edi, esi
    xor     esi, esi
    mov     si, [edx+0D6h]
    cdq
    mov     [esp+1F0h+var_178], eax
    mov     eax, ecx
    mov     [esp+1F0h+var_174], edx
    mov     ecx, [esp+1F0h+var_174]
    cdq
    mov     dword ptr [esp+1F0h+var_1D0], eax
    mov     eax, edi
    mov     dword ptr [esp+1F0h+var_1D0+4], edx
    push    ecx
    cdq
    mov     [esp+1F4h+var_18C], eax
    mov     eax, [esp+1F4h+var_178]
    push    eax
    push    ecx
    push    eax
    mov     [esp+200h+var_188], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ecx, dword ptr [esp+1F0h+var_1D0+4]
    mov     edi, eax
    mov     eax, dword ptr [esp+1F0h+var_1D0]
    push    ecx
    push    eax
    push    ecx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ecx, [esp+1F0h+var_188]
    add     edi, eax
    mov     eax, [esp+1F0h+var_18C]
    push    ecx
    push    eax
    push    ecx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     edi, eax
    mov     eax, esi
    imul    eax, esi
    cmp     edi, eax
    jge     loc_49A7EE
    mov     esi, [esp+1F0h+var_1E4]
    push    0
    push    esi
    call    sub_499EB0
    lea     ecx, [ebx+1Ch]
    mov     byte ptr [esp+1F0h+idTo], 0Eh
    push    0Eh                             ; idFrom
    mov     edx, [ecx]
    mov     [esp+1F4h+idTo+1], edx
    mov     edx, [esi]
    mov     eax, [ecx+4]
    mov     esi, [ebp+arg_0]
    mov     [esp+1F4h+var_197], eax
    mov     ecx, [ecx+8]
    mov     [esp+1F4h+var_193], ecx
    mov     al, [edx+10Ah]
    mov     edx, [esi+52h]
    mov     [esp+1F4h+var_18F], al
    lea     ecx, [esp+1F4h+idTo]
    mov     eax, [edx+96h]
    push    ecx                             ; idTo
    mov     ecx, [eax+4]
    push    ecx                             ; PlayerID
    call    sub_451DF0
    lea     edx, [esi+28h]
    mov     byte ptr [esp+1F0h+idTo], 0Eh
    push    0Eh                             ; idFrom
    mov     eax, [edx]
    mov     [esp+1F4h+idTo+1], eax
    mov     eax, [esi]
    mov     ecx, [edx+4]
    mov     [esp+1F4h+var_197], ecx
    mov     edx, [edx+8]
    mov     [esp+1F4h+var_193], edx
    mov     cl, [eax+10Ah]
    mov     eax, [esi+52h]
    mov     [esp+1F4h+var_18F], cl
    lea     edx, [esp+1F4h+idTo]
    mov     ecx, [eax+96h]
    push    edx                             ; idTo
    mov     edx, [ecx+4]
    push    edx                             ; PlayerID
    call    sub_451DF0

    loc_49A7EE:                             ; CODE XREF: sub_49A120+587j
                                            ; sub_49A120+592j ...
    mov     edx, TAdynmemStructPtr
    mov     eax, [esp+1F0h+var_1D8]
    mov     ecx, [esp+1F0h+var_1E4]
    inc     eax
    mov     esi, [edx+141F3h]
    add     ecx, 6Bh
    add     ebx, 6Bh
    cmp     eax, esi
    mov     [esp+1F0h+var_1D8], eax
    mov     [esp+1F0h+var_1E4], ecx
    jl      loc_49A6A3

    loc_49A819:                             ; CODE XREF: sub_49A120+555j
                                            ; sub_49A120+57Aj
    mov     ecx, [ebp+arg_0]
    mov     eax, [ecx+52h]
    test    eax, eax
    jz      short loc_49A83C
    mov     edx, [esp+1F0h+var_1AC]
    mov     eax, [eax+96h]
    push    edx
    mov     edx, [esp+1F4h+var_1C0]
    push    edx
    push    ecx
    mov     ecx, [eax+74h]
    call    sub_406F50

    loc_49A83C:                             ; CODE XREF: sub_49A120+701j
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    8
    sub_49A120 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49A850 proc near                    ; CODE XREF: sub_49A120+40Bp

    var_10= qword ptr -10h
    var_8= qword ptr -8
    arg_0= dword ptr  4

    sub     esp, 10h
    mov     eax, [esp+10h+arg_0]
    fild    dword ptr [eax]
    fild    dword ptr [eax+4]
    fild    dword ptr [eax+8]
    fxch    st(2)
    fst     [esp+10h+var_10]
    fxch    st(1)
    fst     [esp+10h+var_8]
    fxch    st(1)
    fmul    [esp+10h+var_10]
    fxch    st(1)
    fmul    [esp+10h+var_8]
    fld     st(2)
    fmul    st, st(3)
    fxch    st(1)
    faddp   st(2), st
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    add     esp, 10h
    retn    4
    sub_49A850 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49A890 proc near                    ; CODE XREF: sub_49AA80+107p
                                            ; sub_49ABB0+1B7p ...

    var_40= qword ptr -40h
    var_38= qword ptr -38h
    var_30= qword ptr -30h
    var_28= qword ptr -28h
    var_20= qword ptr -20h
    var_18= qword ptr -18h
    var_10= qword ptr -10h
    var_8= qword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 30h
    mov     eax, TAdynmemStructPtr
    sub     esp, 8
    fild    [esp+38h+arg_0]
    mov     eax, [eax+14263h]
    sub     esp, 8
    fild    [esp+40h+arg_8]
    mov     ecx, eax
    mov     dword ptr [esp+40h+var_30], eax
    imul    ecx, eax
    fstp    [esp+40h+var_38]
    fstp    [esp+40h+var_40]
    mov     [esp+40h+arg_8], ecx
    call    __hypot
    fild    dword ptr [esp+40h+var_30]
    fild    [esp+40h+arg_4]
    add     esp, 10h
    fstp    [esp+30h+var_30]
    fmul    [esp+30h+var_30]
    fild    [esp+30h+arg_C]
    fxch    st(2)
    fst     [esp+30h+var_20]
    fmul    [esp+30h+var_20]
    fxch    st(2)
    fst     [esp+30h+var_28]
    fld     [esp+30h+var_30]
    fxch    st(1)
    fmul    [esp+30h+var_28]
    fxch    st(2)
    fst     [esp+30h+var_8]
    fxch    st(1)
    fmul    [esp+30h+var_30]
    fxch    st(3)
    fstp    [esp+30h+var_30]
    fmul    ds:dbl_4FDA60
    fld     [esp+30h+var_30]
    fmul    [esp+30h+var_30]
    fxch    st(2)
    fstp    [esp+30h+var_20]
    fsubr   [esp+30h+var_20]
    fild    [esp+30h+arg_8]
    fxch    st(3)
    fst     [esp+30h+var_18]
    fld     [esp+30h+var_18]
    fxch    st(2)
    fmul    [esp+30h+var_20]
    fxch    st(4)
    fstp    [esp+30h+var_18]
    fmul    [esp+30h+var_18]
    fxch    st(1)
    fadd    [esp+30h+var_30]
    fxch    st(2)
    fst     [esp+30h+var_10]
    fmul    [esp+30h+var_18]
    fxch    st(1)
    faddp   st(3), st
    fxch    st(1)
    fstp    [esp+30h+var_18]
    fmul    [esp+30h+var_18]
    fxch    st(1)
    fmul    [esp+30h+var_10]
    fxch    st(1)
    fsubp   st(1), st
    fcom    ds:dbl_4FDA68
    fnstsw  ax
    test    ah, 1
    jnz     loc_49AA6C
    fsqrt
    fld     [esp+30h+var_20]
    fadd    [esp+30h+var_8]
    fld     [esp+30h+var_18]
    fadd    st, st
    fxch    st(1)
    fmul    [esp+30h+var_30]
    fxch    st(2)
    fst     [esp+30h+var_8]
    fxch    st(1)
    fstp    [esp+30h+var_10]
    fadd    st, st(1)
    fxch    st(1)
    fsub    [esp+30h+var_8]
    fxch    st(1)
    fdiv    [esp+30h+var_10]
    fxch    st(1)
    fdiv    [esp+30h+var_10]
    fxch    st(1)
    fst     [esp+30h+var_8]
    fcomp   ds:dbl_4FDA68
    fstp    [esp+30h+var_10]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_49A9D9
    fld     [esp+30h+var_8]
    fsqrt
    fdiv    [esp+30h+var_28]
    call    __CIacos
    fstp    [esp+30h+var_30]
    jmp     short loc_49A9E9
    ; ---------------------------------------------------------------------------

    loc_49A9D9:                             ; CODE XREF: sub_49A890+132j
    mov     dword ptr [esp+30h+var_30], 54442D11h
    mov     dword ptr [esp+30h+var_30+4], 3FF921FBh

    loc_49A9E9:                             ; CODE XREF: sub_49A890+147j
    fld     [esp+30h+var_10]
    fcomp   ds:dbl_4FDA68
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_49AA0B
    fld     [esp+30h+var_10]
    fsqrt
    fdiv    [esp+30h+var_28]
    call    __CIacos
    jmp     short loc_49AA11
    ; ---------------------------------------------------------------------------

    loc_49AA0B:                             ; CODE XREF: sub_49A890+168j
    fld     ds:dbl_4FDA78

    loc_49AA11:                             ; CODE XREF: sub_49A890+179j
    fld     [esp+30h+arg_10]
    fcomp   [esp+30h+var_30]
    fnstsw  ax
    test    ah, 1
    jz      short loc_49AA39
    fld     [esp+30h+var_30]
    fcomp   ds:dbl_4FDA80
    fnstsw  ax
    test    ah, 41h
    jz      short loc_49AA39
    fstp    st
    fld     [esp+30h+var_30]
    jmp     short loc_49AA55
    ; ---------------------------------------------------------------------------

    loc_49AA39:                             ; CODE XREF: sub_49A890+18Ej
                                            ; sub_49A890+19Fj
    fld     [esp+30h+arg_10]
    fld     st(1)
    fcompp  st(1), st
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_49AA6C
    fcom    ds:dbl_4FDA80
    fnstsw  ax
    test    ah, 41h
    jz      short loc_49AA6C

    loc_49AA55:                             ; CODE XREF: sub_49A890+1A7j
    fmul    ds:dbl_4FDA88
    fmul    ds:dbl_4FDA90
    call    __ftol
    add     esp, 30h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_49AA6C:                             ; CODE XREF: sub_49A890+E1j
                                            ; sub_49A890+1B6j ...
    fstp    st
    mov     ax, 8000h
    add     esp, 30h
    retn    14h
    sub_49A890 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49AA80 proc near                    ; CODE XREF: sub_407E90+1A5p
                                            ; sub_43E490+132p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 10h
    mov     eax, [esp+10h+arg_C]
    mov     edx, [esp+10h+arg_0]
    and     eax, 0FFh
    push    ebx
    mov     ecx, eax
    push    ebp
    shl     ecx, 3
    push    esi
    mov     esi, [esp+1Ch+arg_4]
    push    edi
    mov     edi, [esp+20h+arg_8]
    mov     ebp, [esi]
    sub     ecx, eax
    mov     eax, [esi+8]
    mov     ebx, [edx+ecx*4+10h]
    mov     ecx, [edi+8]
    sub     ecx, eax
    mov     eax, [edi]
    sub     eax, ebp
    cdq
    mov     ebp, eax
    mov     eax, ecx
    mov     [esp+20h+var_4], edx
    cdq
    mov     [esp+20h+var_10], eax
    mov     eax, [esp+20h+var_4]
    push    eax
    push    ebp
    push    eax
    push    ebp
    mov     [esp+30h+var_C], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ecx, [esp+20h+var_C]
    mov     ebp, eax
    mov     eax, [esp+20h+var_10]
    push    ecx
    push    eax
    push    ecx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     ebp, eax
    mov     eax, [ebx+0DCh]
    mov     ecx, eax
    imul    ecx, eax
    cmp     ebp, ecx
    jle     short loc_49AB18
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49AB18:                             ; CODE XREF: sub_49AA80+8Aj
    mov     eax, [ebx+111h]
    mov     edx, eax
    shr     edx, 10h
    test    dl, 1
    jnz     short loc_49AB9E
    mov     edx, [esp+20h+arg_0]
    mov     ebp, TAdynmemStructPtr
    movsx   ecx, word ptr [esi+6]
    mov     edx, [edx+92h]
    movsx   edx, word ptr [edx+170h]
    add     ecx, edx
    xor     edx, edx
    mov     dl, [ebp+1427Fh]
    cmp     ecx, edx
    jg      short loc_49AB5D
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49AB5D:                             ; CODE XREF: sub_49AA80+CFj
    shr     eax, 1
    test    al, 1
    jz      short loc_49AB9E
    mov     edx, [edi]
    mov     eax, [esi]
    mov     ebp, [edi+4]
    mov     ecx, [esi+4]
    mov     edi, [edi+8]
    mov     esi, [esi+8]
    sub     eax, edx
    mov     edx, [ebx+0C8h]
    push    edx
    mov     edx, [ebx+68h]
    sub     esi, edi
    sub     ecx, ebp
    push    edx
    push    esi
    push    ecx
    push    eax
    call    sub_49A890
    cmp     ax, 8000h
    jnz     short loc_49AB9E
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49AB9E:                             ; CODE XREF: sub_49AA80+A6j
                                            ; sub_49AA80+E1j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 10h
    retn    10h
    sub_49AA80 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49ABB0 proc near                    ; CODE XREF: .text:00402302p
                                            ; .text:004035D6p ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    sub     esp, 0Ch
    and     eax, 0FFh
    mov     ecx, eax
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+18h+arg_0]
    push    edi
    shl     ecx, 3
    sub     ecx, eax
    mov     edi, [esi+ecx*4+10h]
    mov     eax, [edi+111h]
    mov     edx, eax
    shr     edx, 10h
    test    dl, 1
    jz      loc_49ACAF
    mov     eax, [esp+1Ch+arg_4]
    mov     ebx, TAdynmemStructPtr
    mov     ecx, [eax+92h]
    mov     edx, [ecx+241h]
    test    edx, 80000h
    jnz     short loc_49AC1B
    movzx   bp, byte ptr [ebx+1427Fh]
    cmp     [eax+70h], bp
    jle     short loc_49AC1B
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49AC1B:                             ; CODE XREF: sub_49ABB0+4Fj
                                            ; sub_49ABB0+5Dj
    test    dh, 10h
    jz      short loc_49AC47
    movsx   ecx, word ptr [ecx+170h]
    movsx   edx, word ptr [eax+70h]
    sar     ecx, 1
    add     edx, ecx
    xor     ecx, ecx
    mov     cl, [ebx+1427Fh]
    cmp     edx, ecx
    jle     short loc_49AC47
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49AC47:                             ; CODE XREF: sub_49ABB0+6Ej
                                            ; sub_49ABB0+89j
    mov     ecx, [eax+72h]
    mov     eax, [eax+6Ah]
    mov     edx, [esi+6Ah]
    mov     ebx, [esi+72h]
    sub     eax, edx
    mov     edi, [edi+0DCh]
    cdq
    sub     ecx, ebx
    mov     esi, eax
    mov     ebx, edx
    mov     eax, ecx
    push    ebx
    push    esi
    cdq
    push    ebx
    push    esi
    mov     ebp, eax
    mov     [esp+2Ch+var_8], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     esi, eax
    mov     eax, [esp+1Ch+var_8]
    push    eax
    push    ebp
    push    eax
    push    ebp
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     edx, edi
    add     esi, eax
    imul    edx, edi
    xor     eax, eax
    cmp     esi, edx
    setle   al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49ACAF:                             ; CODE XREF: sub_49ABB0+2Dj
    mov     edx, TAdynmemStructPtr
    mov     ebx, [esi+92h]
    xor     ecx, ecx
    mov     cl, [edx+1427Fh]
    movsx   edx, word ptr [esi+70h]
    movsx   ebx, word ptr [ebx+170h]
    add     edx, ebx
    cmp     edx, ecx
    jg      short loc_49ACE0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49ACE0:                             ; CODE XREF: sub_49ABB0+122j
    mov     ebx, [esp+1Ch+arg_4]
    mov     ebp, [ebx+92h]
    movsx   edx, word ptr [ebx+70h]
    movsx   ebp, word ptr [ebp+170h]
    add     edx, ebp
    cmp     edx, ecx
    jg      short loc_49AD07
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49AD07:                             ; CODE XREF: sub_49ABB0+149j
    test    eax, 20000h
    jz      short loc_49AD28
    mov     ecx, [ebx+110h]
    and     ecx, 3
    cmp     cl, 2
    jz      short loc_49AD28
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49AD28:                             ; CODE XREF: sub_49ABB0+15Cj
                                            ; sub_49ABB0+16Aj
    shr     eax, 1
    test    al, 1
    jz      short loc_49AD7E
    lea     edx, [ebx+6Ah]
    mov     eax, [ebx+6Ah]
    mov     [esp+1Ch+var_C], eax
    mov     ebp, [edx+4]
    mov     ecx, [edx+8]
    lea     edx, [esi+6Ah]
    mov     [esp+1Ch+var_4], ecx
    mov     eax, [edx]
    sub     eax, [esp+1Ch+var_C]
    mov     ecx, [edx+4]
    sub     ecx, ebp
    mov     ebp, [esp+1Ch+var_4]
    mov     edx, [edx+8]
    sub     edx, ebp
    mov     ebp, [edi+0C8h]
    push    ebp
    mov     ebp, [edi+68h]
    push    ebp
    push    edx
    push    ecx
    push    eax
    call    sub_49A890
    cmp     ax, 8000h
    jnz     short loc_49AD7E
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49AD7E:                             ; CODE XREF: sub_49ABB0+17Cj
                                            ; sub_49ABB0+1C0j
    mov     eax, [ebx+6Ah]
    mov     edx, [esi+6Ah]
    mov     ecx, [ebx+72h]
    mov     ebp, [esi+72h]
    sub     eax, edx
    mov     edi, [edi+0DCh]
    cdq
    sub     ecx, ebp
    mov     esi, eax
    mov     ebx, edx
    mov     eax, ecx
    push    ebx
    push    esi
    cdq
    push    ebx
    push    esi
    mov     ebp, eax
    mov     [esp+2Ch+var_8], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     esi, eax
    mov     eax, [esp+1Ch+var_8]
    push    eax
    push    ebp
    push    eax
    push    ebp
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     esi, eax
    mov     eax, edi
    imul    eax, edi
    xor     ecx, ecx
    cmp     esi, eax
    pop     edi
    pop     esi
    setle   cl
    pop     ebp
    mov     eax, ecx
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_49ABB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49ADF0 proc near                    ; CODE XREF: sub_403621+2p
                                            ; .text:0040392Ep ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     edx, [esp+arg_0]
    and     eax, 0FFh
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     eax, [edx+ecx*4+10h]
    mov     eax, [eax+0DCh]
    retn    8
    sub_49ADF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49AE20 proc near                    ; CODE XREF: sub_49B720+733p
                                            ; sub_49C880+74p

    var_4C0= dword ptr -4C0h
    var_4BC= dword ptr -4BCh
    var_4B8= dword ptr -4B8h
    var_4B4= dword ptr -4B4h
    var_4B0= word ptr -4B0h
    var_258= word ptr -258h

    sub     esp, 4C0h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [eax+141F7h]
    mov     eax, [eax+141F3h]
    xor     ebx, ebx
    xor     ebp, ebp
    xor     esi, esi
    test    eax, eax
    mov     [esp+4D0h+var_4B4], edi
    mov     [esp+4D0h+var_4BC], eax
    mov     [esp+4D0h+var_4C0], esi
    jle     loc_49AF10
    lea     eax, [edi+56h]
    mov     [esp+4D0h+var_4B8], eax

    loc_49AE5C:                             ; CODE XREF: sub_49AE20+EAj
    mov     cl, [eax+13h]
    mov     [eax+11h], si
    shr     cl, 1
    test    cl, 1
    jz      short loc_49AE77
    test    ebp, ebp
    jnz     short loc_49AE71
    lea     ebp, [eax-56h]

    loc_49AE71:                             ; CODE XREF: sub_49AE20+4Cj
    dec     [esp+4D0h+var_4BC]
    jmp     short loc_49AEF0
    ; ---------------------------------------------------------------------------

    loc_49AE77:                             ; CODE XREF: sub_49AE20+48j
    test    ebp, ebp
    jz      short loc_49AEF0
    mov     ecx, TAdynmemStructPtr
    lea     edx, [eax-56h]
    cmp     [ecx+142F7h], edx
    jnz     short loc_49AE92
    mov     [ecx+142F7h], ebp

    loc_49AE92:                             ; CODE XREF: sub_49AE20+6Aj
    mov     esi, [eax]
    test    esi, esi
    jz      short loc_49AED2
    mov     ecx, ebp
    mov     eax, 4C8F8D29h
    sub     ecx, edi
    sub     esi, edi
    imul    ecx
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, 4C8F8D29h
    mov     [esp+ebx*2+4D0h+var_258], dx
    imul    esi
    sar     edx, 5
    mov     eax, [esp+4D0h+var_4B8]
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    mov     [esp+ebx*2+4D0h+var_4B0], dx
    inc     ebx

    loc_49AED2:                             ; CODE XREF: sub_49AE20+76j
    lea     esi, [eax-56h]
    mov     ecx, 1Ah
    mov     edi, ebp
    mov     eax, [esp+4D0h+var_4B8]
    rep movsd
    movsw
    movsb
    mov     edi, [esp+4D0h+var_4B4]
    mov     esi, [esp+4D0h+var_4C0]
    add     ebp, 6Bh

    loc_49AEF0:                             ; CODE XREF: sub_49AE20+55j
                                            ; sub_49AE20+59j
    mov     edx, TAdynmemStructPtr
    inc     esi
    add     eax, 6Bh
    mov     [esp+4D0h+var_4C0], esi
    mov     ecx, [edx+141F3h]
    mov     [esp+4D0h+var_4B8], eax
    cmp     esi, ecx
    jl      loc_49AE5C

    loc_49AF10:                             ; CODE XREF: sub_49AE20+2Fj
    xor     esi, esi
    cmp     ebx, esi
    jz      short loc_49AF6A
    mov     eax, [esp+4D0h+var_4BC]
    mov     [esp+4D0h+var_4C0], esi
    cmp     eax, esi
    jle     short loc_49AF6A
    mov     edx, edi

    loc_49AF24:                             ; CODE XREF: sub_49AE20+148j
    xor     ebp, ebp
    test    ebx, ebx
    jle     short loc_49AF56

    loc_49AF2A:                             ; CODE XREF: sub_49AE20+134j
    mov     ax, [edx+67h]
    cmp     ax, [esp+ebp*2+4D0h+var_4B0]
    jnz     short loc_49AF51
    movsx   eax, [esp+ebp*2+4D0h+var_258]
    lea     ecx, [eax+eax*2]
    lea     ecx, [ecx+ecx*8]
    shl     ecx, 2
    sub     ecx, eax
    inc     esi
    cmp     esi, ebx
    mov     [ecx+edi+56h], edx
    jz      short loc_49AF6A

    loc_49AF51:                             ; CODE XREF: sub_49AE20+113j
    inc     ebp
    cmp     ebp, ebx
    jl      short loc_49AF2A

    loc_49AF56:                             ; CODE XREF: sub_49AE20+108j
    mov     eax, [esp+4D0h+var_4C0]
    mov     ecx, [esp+4D0h+var_4BC]
    inc     eax
    add     edx, 6Bh
    cmp     eax, ecx
    mov     [esp+4D0h+var_4C0], eax
    jl      short loc_49AF24

    loc_49AF6A:                             ; CODE XREF: sub_49AE20+F4j
                                            ; sub_49AE20+100j ...
    mov     eax, TAdynmemStructPtr
    mov     edx, [esp+4D0h+var_4BC]
    pop     edi
    pop     esi
    pop     ebp
    mov     [eax+141F3h], edx
    pop     ebx
    add     esp, 4C0h
    retn
    sub_49AE20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49AF90 proc near                    ; CODE XREF: Network_Process+1703p

    arg_4= dword ptr  8

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    xor     ecx, ecx
    mov     ebp, [eax+141F3h]
    push    esi
    mov     esi, [eax+141F7h]
    push    edi
    test    ebp, ebp
    jle     short loc_49AFF0
    mov     edi, [esp+10h+arg_4]
    lea     eax, [esi+2Ch]
    mov     edx, [edi+1]

    loc_49AFB5:                             ; CODE XREF: sub_49AF90+4Fj
    cmp     [eax-4], edx
    jnz     short loc_49AFD6
    mov     ebx, [eax+4]
    cmp     ebx, [edi+9]
    jnz     short loc_49AFD6
    mov     ebx, [eax]
    cmp     ebx, [edi+5]
    jnz     short loc_49AFD6
    mov     ebx, [esi]
    mov     bl, [ebx+10Ah]
    cmp     bl, [edi+0Dh]
    jz      short loc_49AFE8

    loc_49AFD6:                             ; CODE XREF: sub_49AF90+28j
                                            ; sub_49AF90+30j ...
    inc     ecx
    add     esi, 6Bh
    add     eax, 6Bh
    cmp     ecx, ebp
    jl      short loc_49AFB5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49AFE8:                             ; CODE XREF: sub_49AF90+44j
    push    0
    push    esi
    call    sub_499EB0

    loc_49AFF0:                             ; CODE XREF: sub_49AF90+19j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_49AF90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49B000 proc near                    ; CODE XREF: sub_4866D0+680p
                                            ; sub_486F10+8Ep

    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_1E= dword ptr -1Eh
    var_1A= dword ptr -1Ah
    var_6= byte ptr -6
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    sub     esp, 6Ch
    xor     edx, edx
    cmp     eax, edx
    mov     eax, [ecx+92h]
    push    esi
    push    edi
    jz      short loc_49B021
    mov     eax, [eax+224h]
    jmp     short loc_49B027
    ; ---------------------------------------------------------------------------

    loc_49B021:                             ; CODE XREF: sub_49B000+17j
    mov     eax, [eax+220h]

    loc_49B027:                             ; CODE XREF: sub_49B000+1Fj
    cmp     eax, edx
    jz      short loc_49B079
    mov     [esp+74h+var_6C], eax
    lea     eax, [ecx+6Ah]
    mov     esi, eax
    mov     cl, [ecx+0FFh]
    mov     [esp+74h+var_1E], edx
    mov     [esp+74h+var_1A], edx
    mov     edi, [esi]
    push    edx
    mov     [esp+78h+var_68], edi
    lea     edx, [esp+78h+var_6C]
    mov     edi, [esi+4]
    push    edx
    mov     [esp+7Ch+var_64], edi
    mov     [esp+7Ch+var_6], cl
    mov     esi, [esi+8]
    mov     [esp+7Ch+var_60], esi
    mov     esi, [eax]
    mov     [esp+7Ch+var_5C], esi
    mov     esi, [eax+4]
    mov     eax, [eax+8]
    mov     [esp+7Ch+var_58], esi
    mov     [esp+7Ch+var_54], eax
    call    sub_499EB0

    loc_49B079:                             ; CODE XREF: sub_49B000+29j
    pop     edi
    pop     esi
    add     esp, 6Ch
    retn    8
    sub_49B000 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49B090 proc near                    ; CODE XREF: sub_49B720+668p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+24h+arg_4]
    push    edi
    lea     edi, [esi+4]
    push    edi                             ; int
    call    sub_4815A0
    mov     ebx, eax
    test    ebx, ebx
    mov     [esp+28h+arg_4], ebx
    jnz     short loc_49B106
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+142F7h]
    cmp     esi, eax
    jnz     short loc_49B0F8
    add     eax, 4
    add     ecx, 1433Fh
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    mov     ecx, [esi]
    mov     eax, TAdynmemStructPtr
    mov     dx, [ecx+0FEh]
    mov     [eax+1434Bh], dx
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F7h], ebx

    loc_49B0F8:                             ; CODE XREF: sub_49B090+2Cj
    or      byte ptr [esi+69h], 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49B106:                             ; CODE XREF: sub_49B090+1Cj
    mov     edx, [esi+56h]
    test    edx, edx
    jz      loc_49B1B2
    mov     ecx, [edi+4]
    mov     ebx, [edx+8]
    mov     eax, [edi]
    mov     ebp, [edx+4]
    sub     ecx, ebx
    mov     ebx, [edi+8]
    mov     edi, [edx+0Ch]
    mov     edx, [esi]
    sub     ebx, edi
    xor     edi, edi
    mov     di, [edx+0D6h]
    sub     eax, ebp
    cdq
    mov     ebp, eax
    mov     eax, ecx
    mov     [esp+28h+var_C], edx
    cdq
    mov     [esp+28h+var_18], eax
    mov     eax, ebx
    mov     [esp+28h+var_14], edx
    cdq
    mov     ebx, eax
    mov     eax, [esp+28h+var_C]
    push    eax
    push    ebp
    push    eax
    push    ebp
    mov     [esp+38h+var_4], edx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    mov     ecx, [esp+28h+var_14]
    mov     ebp, eax
    mov     eax, [esp+28h+var_18]
    push    ecx
    push    eax
    push    ecx
    push    eax
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     ebp, eax
    mov     eax, [esp+28h+var_4]
    push    eax
    push    ebx
    push    eax
    push    ebx
    call    __allmul
    mov     ecx, 20h
    call    __allshr
    add     ebp, eax
    mov     eax, edi
    imul    eax, edi
    cmp     ebp, eax
    jge     short loc_49B1AE
    push    0
    push    esi
    call    sub_499EB0

    loc_49B1AE:                             ; CODE XREF: sub_49B090+114j
    mov     ebx, [esp+28h+arg_4]

    loc_49B1B2:                             ; CODE XREF: sub_49B090+7Bj
    xor     eax, eax
    xor     ecx, ecx
    mov     al, [ebx+5]
    mov     cl, [ebx+6]
    add     eax, ecx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esi+5Eh], ax
    mov     ax, [ebx]
    mov     edi, TAdynmemStructPtr
    test    ax, ax
    jz      short loc_49B222
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, [edi+14357h]
    mov     cl, [eax+edx*8+0FFh]
    lea     eax, [eax+edx*8]
    cmp     cl, [esi+66h]
    jz      short loc_49B222
    mov     edx, [eax+92h]
    mov     ebp, [eax+6Eh]
    mov     ecx, [edx+16Eh]
    mov     edx, [esi+8]
    add     ecx, ebp
    cmp     edx, ecx
    jge     short loc_49B222
    push    eax
    push    esi
    call    sub_499EB0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49B222:                             ; CODE XREF: sub_49B090+143j
                                            ; sub_49B090+167j ...
    mov     ax, [ebx+2]
    test    ax, ax
    jz      short loc_49B28A
    and     eax, 0FFFFh
    mov     ecx, eax
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*4]
    mov     eax, [edi+14357h]
    mov     cl, [eax+edx*8+0FFh]
    lea     eax, [eax+edx*8]
    cmp     cl, [esi+66h]
    jz      short loc_49B28A
    mov     ecx, [eax+92h]
    mov     edx, [eax+6Eh]
    mov     edi, [esi+8]
    mov     ebp, [ecx+162h]
    add     ebp, edx
    cmp     edi, ebp
    jl      short loc_49B284
    mov     ecx, [ecx+16Eh]
    add     ecx, edx
    cmp     edi, ecx
    jg      short loc_49B284
    push    eax
    push    esi
    call    sub_499EB0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49B284:                             ; CODE XREF: sub_49B090+1D5j
                                            ; sub_49B090+1E1j
    mov     edi, TAdynmemStructPtr

    loc_49B28A:                             ; CODE XREF: sub_49B090+199j
                                            ; sub_49B090+1BDj
    mov     edx, [esp+28h+arg_0]
    mov     eax, [edx+111h]
    test    ah, 40h
    jnz     loc_49B3D2
    movsx   eax, word ptr [esi+6]
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     ebp, eax
    movsx   eax, word ptr [esi+0Eh]
    cdq
    and     edx, 0Fh
    add     eax, edx
    mov     dx, [ebx+8]
    sar     ebp, 4
    sar     eax, 4
    cmp     dx, 0FFFBh
    mov     [esp+28h+arg_4], eax
    jnb     short loc_49B2DC
    mov     eax, [edi+14253h]
    and     edx, 0FFFFh
    cmp     edx, eax
    jl      short loc_49B31B
    xor     ecx, ecx
    jmp     short loc_49B326
    ; ---------------------------------------------------------------------------

    loc_49B2DC:                             ; CODE XREF: sub_49B090+236j
    cmp     dx, 0FFFEh
    jz      short loc_49B2E7
    xor     ecx, ecx
    jmp     short loc_49B326
    ; ---------------------------------------------------------------------------

    loc_49B2E7:                             ; CODE XREF: sub_49B090+251j
    mov     ecx, [edi+14233h]
    xor     eax, eax
    mov     al, [ebx+0Ah]
    xor     edx, edx
    imul    ecx, eax
    mov     dl, [ebx+0Bh]
    add     ecx, edx
    mov     edx, ebx
    lea     eax, [ecx+ecx*2]
    lea     ecx, [ecx+eax*4]
    sub     edx, ecx
    mov     dx, [edx+8]
    cmp     dx, 0FFFBh
    jb      short loc_49B315
    xor     ecx, ecx
    jmp     short loc_49B326
    ; ---------------------------------------------------------------------------

    loc_49B315:                             ; CODE XREF: sub_49B090+27Fj
    and     edx, 0FFFFh

    loc_49B31B:                             ; CODE XREF: sub_49B090+246j
    mov     ecx, [edi+1426Fh]
    shl     edx, 8
    add     ecx, edx

    loc_49B326:                             ; CODE XREF: sub_49B090+24Aj
                                            ; sub_49B090+255j ...
    test    ecx, ecx
    jz      short loc_49B36D
    xor     eax, eax
    xor     edx, edx
    mov     al, [ecx+0FAh]
    mov     dl, [ebx+6]
    add     eax, edx
    movsx   edx, word ptr [esi+0Ah]
    cmp     eax, edx
    jle     short loc_49B367
    cmp     [esi+5Ah], bp
    jnz     short loc_49B352
    mov     ax, [esi+5Ch]
    cmp     ax, word ptr [esp+28h+arg_4]
    jz      short loc_49B367

    loc_49B352:                             ; CODE XREF: sub_49B090+2B5j
    mov     dx, word ptr [esp+28h+arg_4]
    mov     [esi+5Ah], bp
    mov     [esi+5Ch], dx
    mov     edi, TAdynmemStructPtr
    jmp     short loc_49B369
    ; ---------------------------------------------------------------------------

    loc_49B367:                             ; CODE XREF: sub_49B090+2AFj
                                            ; sub_49B090+2C0j
    xor     ecx, ecx

    loc_49B369:                             ; CODE XREF: sub_49B090+2D5j
    test    ecx, ecx
    jnz     short loc_49B3CA

    loc_49B36D:                             ; CODE XREF: sub_49B090+298j
    movzx   cx, byte ptr [ebx+6]
    mov     ax, [esi+0Ah]
    mov     edx, [esp+28h+arg_0]
    cmp     cx, ax
    jle     short loc_49B3A1
    mov     eax, [edx+111h]
    shr     eax, 0Fh
    test    al, 1
    jz      short loc_49B3CA
    mov     ecx, [esi+20h]
    sar     ecx, 2
    neg     ecx
    mov     [esi+20h], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49B3A1:                             ; CODE XREF: sub_49B090+2EDj
    test    dword ptr [edx+111h], 10000h
    jnz     short loc_49B3D2
    movzx   cx, byte ptr [edi+1427Fh]
    cmp     ax, cx
    jge     short loc_49B3D2
    mov     edx, [edi+391E9h]
    mov     eax, [edx+0D48h]
    test    eax, eax
    jnz     short loc_49B3D2

    loc_49B3CA:                             ; CODE XREF: sub_49B090+2DBj
                                            ; sub_49B090+2FAj
    push    0
    push    esi
    call    sub_499EB0

    loc_49B3D2:                             ; CODE XREF: sub_49B090+207j
                                            ; sub_49B090+31Bj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    sub_49B090 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49B3E0 proc near                    ; CODE XREF: sub_49B720+33Dp

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+18h+arg_0]
    push    edi
    mov     eax, [esi]
    mov     ebx, [eax+111h]
    shr     ebx, 19h
    and     bl, 1
    jz      short loc_49B47A
    mov     ecx, [esi+4]
    mov     ebp, [esi+28h]
    mov     edx, [esi+8]
    mov     edi, [esi+2Ch]
    mov     eax, [esi+0Ch]
    sub     ecx, ebp
    mov     [esp+1Ch+var_C], ecx
    mov     ecx, [esi+30h]
    fild    [esp+1Ch+var_C]
    sub     edx, edi
    sub     eax, ecx
    mov     [esp+1Ch+var_8], edx
    mov     [esp+1Ch+var_4], eax
    fild    [esp+1Ch+var_8]
    fild    [esp+1Ch+var_4]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    mov     [esp+1Ch+arg_0], eax
    cmp     word ptr [esp+1Ch+arg_0+2], 400h
    fstp    st
    jle     short loc_49B4AE
    lea     eax, [esi+10h]
    mov     edx, ebp
    mov     ecx, eax
    mov     [ecx], edx
    mov     edx, [esi+2Ch]
    mov     [ecx+4], edx
    mov     edx, [esi+30h]
    mov     [ecx+8], edx
    mov     word ptr [esi+16h], 2BCh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49B47A:                             ; CODE XREF: sub_49B3E0+19j
    mov     eax, [esi+56h]
    test    eax, eax
    jz      short loc_49B48E
    add     eax, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49B48E:                             ; CODE XREF: sub_49B3E0+9Fj
    mov     eax, [esi+4Eh]
    test    eax, eax
    jz      short loc_49B4AE
    test    dword ptr [eax+110h], 10000000h
    jz      short loc_49B4AE
    add     eax, 6Ah
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49B4AE:                             ; CODE XREF: sub_49B3E0+73j
                                            ; sub_49B3E0+B3j ...
    test    bl, bl
    jz      short loc_49B510
    lea     edi, [esi+28h]
    lea     ebp, [esi+10h]
    mov     eax, edi
    mov     ecx, ebp
    xor     ebx, ebx
    push    edi
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    mov     ecx, TAdynmemStructPtr
    mov     bl, [ecx+1427Fh]
    call    sub_485070
    cmp     eax, ebx
    jle     short loc_49B4FC
    push    edi
    call    sub_485070
    shl     eax, 10h
    mov     [esi+14h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49B4FC:                             ; CODE XREF: sub_49B3E0+102j
    mov     eax, ebx
    shl     eax, 10h
    mov     [esi+14h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49B510:                             ; CODE XREF: sub_49B3E0+D0j
    lea     eax, [esi+28h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    4
    sub_49B3E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49B520 proc near                    ; CODE XREF: sub_49B720+344p

    var_24= qword ptr -24h
    var_1C= qword ptr -1Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     edx, [esp+4+arg_4]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+10h+arg_0]
    mov     ebx, [edx]
    push    edi
    mov     edi, [edx+4]
    mov     ecx, [esi+8]
    mov     eax, [esi+4]
    sub     ecx, edi
    mov     ebp, [esi]
    sub     eax, ebx
    mov     ebx, [edx+8]
    mov     [esp+14h+var_4], ecx
    mov     ecx, [esi+0Ch]
    sub     ecx, ebx
    mov     [esp+14h+arg_4], eax
    push    ecx
    push    eax
    mov     [esp+1Ch+arg_0], ecx
    call    sub_4B715A
    fild    [esp+1Ch+arg_0]
    add     esp, 8
    mov     ebx, eax
    sub     esp, 8
    fstp    [esp+1Ch+var_1C]
    fild    [esp+1Ch+arg_4]
    sub     esp, 8
    fstp    [esp+24h+var_24]
    call    __hypot
    add     esp, 10h
    call    __ftol
    sar     eax, 10h
    movsx   edx, ax
    movsx   eax, word ptr [esp+14h+var_4+2]
    neg     eax
    push    edx
    push    eax
    call    sub_4B715A
    mov     di, [esi+36h]
    mov     ecx, ebx
    sub     ecx, edi
    mov     [esp+1Ch+arg_0], eax
    movsx   eax, cx
    cdq
    xor     eax, edx
    add     esp, 8
    sub     eax, edx
    cmp     ax, 6978h
    jle     short loc_49B5C6
    test    dword ptr [ebp+111h], 800000h
    jz      short loc_49B5C6
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49B5C6:                             ; CODE XREF: sub_49B520+8Ej
                                            ; sub_49B520+9Aj
    mov     dx, [ebp+0E8h]
    movsx   eax, ax
    and     edx, 0FFFFh
    cmp     eax, edx
    jge     short loc_49B5E0
    mov     [esi+36h], bx
    jmp     short loc_49B5FA
    ; ---------------------------------------------------------------------------

    loc_49B5E0:                             ; CODE XREF: sub_49B520+B8j
    mov     ax, [ebp+0E8h]
    test    cx, cx
    jge     short loc_49B5F4
    sub     edi, eax
    mov     [esi+36h], di
    jmp     short loc_49B5FA
    ; ---------------------------------------------------------------------------

    loc_49B5F4:                             ; CODE XREF: sub_49B520+CAj
    add     eax, edi
    mov     [esi+36h], ax

    loc_49B5FA:                             ; CODE XREF: sub_49B520+BEj
                                            ; sub_49B520+D2j
    mov     ebx, [esp+14h+arg_0]
    mov     di, [esi+38h]
    mov     ecx, ebx
    sub     ecx, edi
    movsx   eax, cx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     ax, 6978h
    jle     short loc_49B62A
    test    dword ptr [ebp+111h], 800000h
    jz      short loc_49B62A
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49B62A:                             ; CODE XREF: sub_49B520+F2j
                                            ; sub_49B520+FEj
    mov     bp, [ebp+0E8h]
    movsx   edx, ax
    mov     eax, ebp
    and     eax, 0FFFFh
    cmp     edx, eax
    jge     short loc_49B650
    mov     [esi+38h], bx
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49B650:                             ; CODE XREF: sub_49B520+11Dj
    test    cx, cx
    jge     short loc_49B668
    sub     edi, ebp
    mov     eax, 1
    mov     [esi+38h], di
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49B668:                             ; CODE XREF: sub_49B520+133j
    add     edi, ebp
    mov     eax, 1
    mov     [esi+38h], di
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_49B520 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+8]
    push    edi
    mov     eax, [esi+3Ah]
    mov     cx, [esi+38h]
    push    eax
    push    ecx
    call    sub_4B70EF
    mov     edx, [esi+3Ah]
    add     esp, 8
    mov     [esi+20h], eax
    mov     ax, [esi+38h]
    push    edx
    push    eax
    call    sub_4B7123
    mov     cx, [esi+36h]
    add     esp, 8
    mov     edi, eax
    push    edi
    push    ecx
    call    sub_4B70EF
    mov     dx, [esi+36h]
    add     esp, 8
    neg     eax
    push    edi
    push    edx
    mov     [esi+1Ch], eax
    call    sub_4B7123
    add     esp, 8
    neg     eax
    mov     [esi+24h], eax
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, TAdynmemStructPtr
    xor     eax, eax
    mov     ecx, [edx+141F3h]
    cmp     ecx, 12Ch
    jge     short locret_49B71F
    lea     eax, [ecx+ecx*2]
    push    esi
    lea     esi, [eax+eax*8]
    mov     eax, [edx+141F7h]
    shl     esi, 2
    sub     esi, ecx
    add     eax, esi
    inc     ecx
    mov     [edx+141F3h], ecx
    pop     esi
    and     word ptr [eax+69h], 0FFFDh
    mov     dword ptr [eax+4Eh], 0

    locret_49B71F:                          ; CODE XREF: .text:0049B6F4j
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49B720 proc near                    ; CODE XREF: .text:00495513p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     eax, TAdynmemStructPtr
    sub     esp, 14h
    mov     eax, [eax+141F3h]
    push    edi
    xor     edi, edi
    cmp     eax, edi
    jle     loc_49BE53
    push    esi
    push    ebp
    push    ebx
    mov     [esp+24h+var_10], edi
    mov     [esp+24h+var_C], eax

    loc_49B744:                             ; CODE XREF: sub_49B720+72Aj
    mov     ecx, TAdynmemStructPtr
    mov     esi, [esp+24h+var_10]
    mov     ebp, [ecx+141F7h]
    mov     cx, [ebp+esi+0Ah]
    add     ebp, esi
    movsx   edx, cx
    mov     ax, [ebp+60h]
    mov     esi, [ebp+0]
    cmp     ax, di
    mov     [esp+24h+var_8], esi
    mov     [esp+24h+var_4], edx
    jz      loc_49B9AE
    mov     cx, [esi+0ECh]
    mov     ebx, [ebp+42h]
    mov     edx, ecx
    and     edx, 0FFFFh
    add     ebx, edx
    mov     edx, TAdynmemStructPtr
    cmp     [edx+38A47h], ebx
    jb      loc_49BE36
    cmp     cx, 5
    jnb     short loc_49B7A6
    test    al, 1
    jz      short loc_49B7E6

    loc_49B7A6:                             ; CODE XREF: sub_49B720+80j
    mov     ecx, [ebp+52h]
    xor     dl, dl
    mov     byte ptr [esp+24h+var_14], dl

    loc_49B7AF:                             ; CODE XREF: sub_49B720+AEj
    mov     eax, [esp+24h+var_14]
    and     eax, 0FFh
    mov     ebx, eax
    shl     ebx, 3
    sub     ebx, eax
    cmp     [ecx+ebx*4+10h], esi
    jz      short loc_49B7D0
    inc     dl
    cmp     dl, 3
    mov     byte ptr [esp+24h+var_14], dl
    jb      short loc_49B7AF

    loc_49B7D0:                             ; CODE XREF: sub_49B720+A3j
    mov     edx, [esp+24h+var_14]
    xor     eax, eax
    mov     ax, [ebp+62h]
    push    eax
    lea     eax, [ebp+4]
    push    edx
    push    eax
    push    ecx
    call    sub_43E240

    loc_49B7E6:                             ; CODE XREF: sub_49B720+84j
    dec     word ptr [ebp+60h]
    mov     edx, [ebp+42h]
    xor     ecx, ecx
    xor     ebx, ebx
    mov     cx, [esi+0ECh]
    add     edx, ecx
    mov     [ebp+42h], edx
    mov     edx, TAdynmemStructPtr
    mov     eax, [edx+141F3h]
    cmp     eax, 12Ch
    jge     short loc_49B833
    mov     ebx, [edx+141F7h]
    lea     ecx, [eax+eax*2]
    lea     ecx, [ecx+ecx*8]
    shl     ecx, 2
    sub     ecx, eax
    add     ebx, ecx
    inc     eax
    mov     [edx+141F3h], eax
    and     word ptr [ebx+69h], 0FFFDh
    mov     [ebx+4Eh], edi

    loc_49B833:                             ; CODE XREF: sub_49B720+EEj
    cmp     ebx, edi
    jz      loc_49B950
    mov     ecx, 1Ah
    mov     esi, ebp
    mov     edi, ebx
    rep movsd
    movsw
    movsb
    mov     edx, TAdynmemStructPtr
    mov     esi, [esp+24h+var_8]
    mov     eax, [edx+38A47h]
    mov     [ebx+42h], eax
    mov     ecx, [esi+111h]
    shr     ecx, 0Bh
    test    cl, 1
    jz      short loc_49B87F
    xor     eax, eax
    lea     edx, [ebp+4]
    mov     ax, [esi+0F4h]
    push    0
    push    edx
    push    eax
    call    sub_47F300

    loc_49B87F:                             ; CODE XREF: sub_49B720+148j
    mov     ax, [esi+0E6h]
    test    ax, ax
    jz      short loc_49B8A3
    mov     ecx, TAdynmemStructPtr
    and     eax, 0FFFFh
    mov     edx, [ecx+38A47h]
    add     edx, eax
    mov     [ebx+46h], edx
    jmp     short loc_49B8BF
    ; ---------------------------------------------------------------------------

    loc_49B8A3:                             ; CODE XREF: sub_49B720+169j
    mov     eax, [ebp+3Eh]
    xor     edx, edx
    add     eax, 100000h
    mov     ecx, TAdynmemStructPtr
    div     dword ptr [ebp+3Ah]
    add     eax, [ecx+38A47h]
    mov     [ebx+46h], eax

    loc_49B8BF:                             ; CODE XREF: sub_49B720+181j
    mov     ax, [esi+0F2h]
    test    ax, ax
    jz      short loc_49B8EB
    and     eax, 0FFFFh
    push    eax                             ; int
    call    GetRandom
    mov     ecx, [ebx+46h]
    xor     edx, edx
    mov     dx, [esi+0F2h]
    shr     edx, 1
    sub     eax, edx
    add     ecx, eax
    mov     [ebx+46h], ecx

    loc_49B8EB:                             ; CODE XREF: sub_49B720+1A9j
    mov     word ptr [ebx+60h], 0
    mov     ax, [esi+0EEh]
    test    ax, ax
    jz      short loc_49B94E
    and     eax, 0FFFFh
    push    eax                             ; int
    call    GetRandom
    mov     cx, [ebp+36h]
    mov     edx, [esi+68h]
    mov     edi, eax
    mov     ax, [esi+0EEh]
    shr     ax, 1
    sub     cx, ax
    mov     ax, [ebp+38h]
    push    edx
    push    eax
    add     edi, ecx
    call    sub_4B7123
    add     esp, 8
    mov     esi, eax
    push    esi
    push    edi
    call    sub_4B70EF
    add     esp, 8
    neg     eax
    push    esi
    push    edi
    mov     [ebp+1Ch], eax
    call    sub_4B7123
    add     esp, 8
    neg     eax
    mov     [ebp+24h], eax

    loc_49B94E:                             ; CODE XREF: sub_49B720+1DBj
    xor     edi, edi

    loc_49B950:                             ; CODE XREF: sub_49B720+115j
    cmp     [ebp+60h], di
    jnz     loc_49BE36
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ecx+142F7h]
    cmp     ebp, eax
    jnz     short loc_49B9A5
    add     eax, 4
    add     ecx, 1433Fh
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    mov     ecx, [ebp+0]
    mov     eax, TAdynmemStructPtr
    mov     dx, [ecx+0FEh]
    mov     [eax+1434Bh], dx
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F7h], edi

    loc_49B9A5:                             ; CODE XREF: sub_49B720+248j
    or      byte ptr [ebp+69h], 2
    jmp     loc_49BE36
    ; ---------------------------------------------------------------------------

    loc_49B9AE:                             ; CODE XREF: sub_49B720+50j
    mov     edx, [esi+111h]
    shr     edx, 15h
    test    dl, 1
    jz      short loc_49B9C2
    add     word ptr [ebp+64h], 400h

    loc_49B9C2:                             ; CODE XREF: sub_49B720+29Aj
    mov     eax, [esi+111h]
    mov     edx, eax
    shr     edx, 14h
    test    dl, 1
    jz      loc_49BB60
    mov     edx, TAdynmemStructPtr
    mov     ebx, [ebp+46h]
    cmp     ebx, [edx+38A47h]
    jbe     loc_49BAC3
    test    eax, 10000h
    jz      short loc_49BA16
    movzx   ax, byte ptr [edx+1427Fh]
    cmp     cx, ax
    jl      short loc_49BA16
    mov     ecx, [edx+14263h]
    mov     eax, [ebp+20h]
    sub     eax, ecx
    mov     [ebp+20h], eax
    mov     [ebp+38h], di
    jmp     loc_49BB3A
    ; ---------------------------------------------------------------------------

    loc_49BA16:                             ; CODE XREF: sub_49B720+2D0j
                                            ; sub_49B720+2DDj
    mov     eax, [ebp+3Ah]
    mov     ecx, [esi+68h]
    xor     edx, edx
    cmp     eax, ecx
    jnb     short loc_49BA34
    mov     ecx, [esi+70h]
    add     eax, ecx
    mov     [ebp+3Ah], eax
    mov     ecx, [esi+68h]
    cmp     eax, ecx
    jbe     short loc_49BA34
    mov     [ebp+3Ah], ecx

    loc_49BA34:                             ; CODE XREF: sub_49B720+300j
                                            ; sub_49B720+30Fj
    mov     eax, [esi+111h]
    mov     ecx, eax
    shr     ecx, 18h
    test    cl, 1
    jz      short loc_49BA4C
    test    byte ptr [ebp+69h], 30h
    jbe     short loc_49BA58
    jmp     short loc_49BA53
    ; ---------------------------------------------------------------------------

    loc_49BA4C:                             ; CODE XREF: sub_49B720+322j
    shr     eax, 0Ch
    test    al, 1
    jz      short loc_49BA58

    loc_49BA53:                             ; CODE XREF: sub_49B720+32Aj
    mov     edx, 1

    loc_49BA58:                             ; CODE XREF: sub_49B720+328j
                                            ; sub_49B720+331j
    cmp     edx, edi
    jz      short loc_49BA74
    push    ebp
    call    sub_49B3E0
    push    eax
    push    ebp
    call    sub_49B520
    test    eax, eax
    jnz     short loc_49BA74
    push    edi
    push    ebp
    call    sub_499EB0

    loc_49BA74:                             ; CODE XREF: sub_49B720+33Aj
                                            ; sub_49B720+34Bj
    mov     edx, [ebp+3Ah]
    mov     ax, [ebp+38h]
    push    edx
    push    eax
    call    sub_4B70EF
    mov     ecx, [ebp+3Ah]
    mov     dx, [ebp+38h]
    add     esp, 8
    mov     [ebp+20h], eax
    push    ecx
    push    edx
    call    sub_4B7123
    add     esp, 8
    mov     ebx, eax
    mov     ax, [ebp+36h]
    push    ebx
    push    eax
    call    sub_4B70EF
    mov     cx, [ebp+36h]
    add     esp, 8
    neg     eax
    push    ebx
    push    ecx
    mov     [ebp+1Ch], eax
    call    sub_4B7123
    add     esp, 8
    neg     eax
    mov     [ebp+24h], eax
    jmp     short loc_49BB3A
    ; ---------------------------------------------------------------------------

    loc_49BAC3:                             ; CODE XREF: sub_49B720+2C5j
    shr     eax, 17h
    test    al, 1
    jz      short loc_49BAD3
    push    edi
    push    ebp
    call    sub_499EB0
    jmp     short loc_49BB3A
    ; ---------------------------------------------------------------------------

    loc_49BAD3:                             ; CODE XREF: sub_49B720+3A8j
    mov     edx, [edx+14263h]
    mov     ebx, [ebp+20h]
    sub     ebx, edx
    mov     [ebp+20h], ebx
    mov     eax, [esi+111h]
    shr     eax, 18h
    test    al, 1
    jz      short loc_49BB3A
    mov     ax, [ebp+69h]
    test    al, 30h
    jnz     short loc_49BB3A
    mov     ecx, [ebp+0]
    mov     ebx, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [ecx+0FCh]
    mov     ebx, [ebx+38A47h]
    add     ebx, edx
    mov     edx, eax
    and     edx, 0FFF0h
    mov     [ebp+46h], ebx
    add     edx, 10h
    xor     dl, al
    and     edx, 30h
    xor     edx, eax
    mov     [ebp+69h], dx
    mov     eax, [ecx+111h]
    test    ah, 20h
    jnz     short loc_49BB3A
    mov     [ebp+56h], edi
    mov     [ebp+4Eh], edi

    loc_49BB3A:                             ; CODE XREF: sub_49B720+2F1j
                                            ; sub_49B720+3A1j ...
    mov     eax, [ebp+1Ch]
    mov     ecx, [ebp+4]
    add     ecx, eax
    mov     eax, [ebp+8]
    mov     ebx, [ebp+0Ch]
    mov     [ebp+4], ecx
    mov     ecx, [ebp+20h]
    add     eax, ecx
    mov     [ebp+8], eax
    mov     edx, [ebp+24h]
    add     ebx, edx
    mov     [ebp+0Ch], ebx
    jmp     loc_49BD86
    ; ---------------------------------------------------------------------------

    loc_49BB60:                             ; CODE XREF: sub_49B720+2B0j
    test    byte ptr [esi+111h], 1
    jz      loc_49BC0C
    mov     ecx, TAdynmemStructPtr
    mov     eax, [ebp+46h]
    cmp     eax, [ecx+38A47h]
    jbe     loc_49BC8B
    mov     ecx, [ebp+1Ch]
    mov     edx, [ebp+4]
    mov     eax, [ebp+8]
    add     edx, ecx
    mov     ebx, [ebp+0Ch]
    mov     [ebp+4], edx
    mov     edx, [ebp+20h]
    add     eax, edx
    mov     [ebp+8], eax
    mov     eax, [ebp+24h]
    add     ebx, eax
    mov     [ebp+0Ch], ebx
    mov     ecx, [esi+111h]
    shr     ecx, 3
    test    cl, 1
    jz      loc_49BD86
    test    byte ptr [ebp+69h], 1
    jz      short loc_49BBE1
    mov     edx, [ebp+1Ch]
    mov     ebx, [ebp+10h]
    mov     ecx, [ebp+14h]
    add     ebx, edx
    mov     [ebp+10h], ebx
    mov     eax, [ebp+20h]
    add     ecx, eax
    mov     eax, [ebp+18h]
    mov     [ebp+14h], ecx
    mov     ecx, [ebp+24h]
    add     eax, ecx
    mov     [ebp+18h], eax
    jmp     loc_49BD86
    ; ---------------------------------------------------------------------------

    loc_49BBE1:                             ; CODE XREF: sub_49B720+499j
    mov     eax, [ebp+42h]
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     dx, [esi+0F0h]
    add     eax, edx
    mov     edx, [ecx+38A47h]
    cmp     edx, eax
    jbe     loc_49BD86
    or      byte ptr [ebp+69h], 1
    jmp     loc_49BD86
    ; ---------------------------------------------------------------------------

    loc_49BC0C:                             ; CODE XREF: sub_49B720+447j
    mov     edx, eax
    shr     edx, 1
    test    dl, 1
    jz      loc_49BCD9
    cmp     [esi+0E6h], di
    jz      loc_49BCE3
    mov     edx, TAdynmemStructPtr
    mov     ecx, [ebp+46h]
    cmp     ecx, [edx+38A47h]
    jbe     short loc_49BC67
    mov     eax, [ebp+1Ch]
    mov     ecx, [ebp+4]
    add     ecx, eax
    mov     eax, [ebp+8]
    mov     ebx, [ebp+0Ch]
    mov     [ebp+4], ecx
    mov     ecx, [ebp+20h]
    add     eax, ecx
    mov     [ebp+8], eax
    mov     edx, [ebp+24h]
    add     ebx, edx
    mov     [ebp+0Ch], ebx
    mov     eax, TAdynmemStructPtr
    add     eax, 37ECCh
    jmp     loc_49BD10
    ; ---------------------------------------------------------------------------

    loc_49BC67:                             ; CODE XREF: sub_49B720+515j
    shr     eax, 17h
    test    al, 1
    jz      short loc_49BC7A
    push    edi
    push    ebp
    call    sub_499EB0
    jmp     loc_49BD8D
    ; ---------------------------------------------------------------------------

    loc_49BC7A:                             ; CODE XREF: sub_49B720+54Cj
    lea     eax, [ebp+4]
    push    9
    push    eax
    call    sub_472810
    mov     ecx, TAdynmemStructPtr

    loc_49BC8B:                             ; CODE XREF: sub_49B720+45Cj
    mov     eax, [ecx+142F7h]
    cmp     ebp, eax
    jnz     short loc_49BCD0
    add     eax, 4
    add     ecx, 1433Fh
    mov     edx, [eax]
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     eax, [eax+8]
    mov     [ecx+8], eax
    mov     ecx, [ebp+0]
    mov     eax, TAdynmemStructPtr
    mov     dx, [ecx+0FEh]
    mov     [eax+1434Bh], dx
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+142F7h], edi

    loc_49BCD0:                             ; CODE XREF: sub_49B720+573j
    or      byte ptr [ebp+69h], 2
    jmp     loc_49BD8D
    ; ---------------------------------------------------------------------------

    loc_49BCD9:                             ; CODE XREF: sub_49B720+4F3j
    mov     ecx, eax
    shr     ecx, 8
    test    cl, 1
    jz      short loc_49BD46

    loc_49BCE3:                             ; CODE XREF: sub_49B720+500j
    mov     edx, [ebp+1Ch]
    mov     ebx, [ebp+4]
    mov     ecx, [ebp+8]
    add     ebx, edx
    mov     [ebp+4], ebx
    mov     eax, [ebp+20h]
    mov     ebx, [ebp+0Ch]
    add     ecx, eax
    mov     [ebp+8], ecx
    mov     ecx, [ebp+24h]
    add     ebx, ecx
    mov     [ebp+0Ch], ebx
    mov     edx, TAdynmemStructPtr
    lea     eax, [edx+37ECCh]

    loc_49BD10:                             ; CODE XREF: sub_49B720+542j
    mov     ecx, [eax]
    mov     edx, [ebp+4]
    mov     ebx, [ebp+8]
    add     edx, ecx
    mov     ecx, [ebp+0Ch]
    mov     [ebp+4], edx
    mov     edx, [eax+4]
    add     ebx, edx
    mov     [ebp+8], ebx
    mov     eax, [eax+8]
    add     ecx, eax
    mov     [ebp+0Ch], ecx
    mov     ecx, TAdynmemStructPtr
    mov     ebx, [ebp+20h]
    mov     edx, [ecx+14263h]
    sub     ebx, edx
    mov     [ebp+20h], ebx
    jmp     short loc_49BD86
    ; ---------------------------------------------------------------------------

    loc_49BD46:                             ; CODE XREF: sub_49B720+5C1j
    shr     eax, 5
    test    al, 1
    jz      short loc_49BD8D
    mov     eax, [ebp+1Ch]
    mov     ecx, [ebp+4]
    add     ecx, eax
    mov     eax, [ebp+8]
    mov     ebx, [ebp+0Ch]
    mov     [ebp+4], ecx
    mov     ecx, [ebp+20h]
    add     eax, ecx
    mov     [ebp+8], eax
    mov     edx, [ebp+24h]
    add     ebx, edx
    mov     [ebp+0Ch], ebx
    mov     ax, [ebp+1Eh]
    mov     cx, [ebp+26h]
    shl     ax, 8
    add     [ebp+34h], ax
    shl     cx, 8
    add     [ebp+38h], cx

    loc_49BD86:                             ; CODE XREF: sub_49B720+43Bj
                                            ; sub_49B720+48Fj ...
    push    ebp
    push    esi
    call    sub_49B090

    loc_49BD8D:                             ; CODE XREF: sub_49B720+555j
                                            ; sub_49B720+5B4j ...
    test    byte ptr [ebp+69h], 2
    jnz     loc_49BE36
    test    dword ptr [esi+111h], 40000h
    jz      short loc_49BDD7
    mov     edx, TAdynmemStructPtr
    mov     ecx, [ebp+46h]
    mov     eax, [edx+38A47h]
    cmp     ecx, eax
    jbe     short loc_49BDD7
    cmp     [ebp+4Ah], eax
    jnb     short loc_49BDD7
    lea     eax, [ebp+4]
    push    9
    push    eax
    call    sub_472810
    mov     eax, [ebp+4Ah]
    xor     ecx, ecx
    mov     cx, [esi+0FAh]
    add     eax, ecx
    mov     [ebp+4Ah], eax

    loc_49BDD7:                             ; CODE XREF: sub_49B720+681j
                                            ; sub_49B720+694j ...
    mov     edx, TAdynmemStructPtr
    mov     al, [edx+1427Fh]
    mov     edx, [esp+24h+var_4]
    mov     ecx, eax
    and     ecx, 0FFh
    cmp     edx, ecx
    jle     short loc_49BE36
    xor     dx, dx
    mov     dl, al
    cmp     [ebp+0Ah], dx
    jg      short loc_49BE36
    add     ebp, 4
    push    ebp                             ; int
    call    sub_4815A0
    cmp     eax, edi
    jz      short loc_49BE36
    mov     cl, [eax+5]
    mov     eax, TAdynmemStructPtr
    cmp     cl, [eax+1427Fh]
    jnb     short loc_49BE36
    mov     edx, [eax+391E9h]
    cmp     [edx+0D48h], edi
    jnz     short loc_49BE36
    mov     eax, [esi+7Ch]
    push    1
    push    edi
    push    eax
    push    ebp
    call    sub_420A30

    loc_49BE36:                             ; CODE XREF: sub_49B720+76j
                                            ; sub_49B720+234j ...
    mov     ecx, [esp+24h+var_10]
    mov     eax, [esp+24h+var_C]
    add     ecx, 6Bh
    dec     eax
    mov     [esp+24h+var_10], ecx
    mov     [esp+24h+var_C], eax
    jnz     loc_49B744
    pop     ebx
    pop     ebp
    pop     esi

    loc_49BE53:                             ; CODE XREF: sub_49B720+13j
    call    sub_49AE20
    pop     edi
    add     esp, 14h
    retn
    sub_49B720 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49BE60 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+E32p

    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= word ptr -44h
    var_40= dword ptr -40h
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 68h
    mov     eax, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     edx, [eax+1480Fh]
    mov     ecx, [eax+38A47h]
    xor     esi, esi
    push    edi
    push    esi
    push    edx
    mov     [esp+80h+var_60], ecx
    call    sub_4B7F30
    mov     edi, TAdynmemStructPtr
    mov     [esp+78h+var_64], eax
    mov     [esp+78h+var_54], esi
    cmp     [edi+141F3h], esi
    jle     loc_49C07A
    mov     [esp+78h+var_5C], esi

    loc_49BEA3:                             ; CODE XREF: sub_49BE60+214j
    mov     esi, [edi+141F7h]
    mov     ecx, [esp+78h+var_5C]
    add     esi, ecx
    cmp     word ptr [esi+60h], 0
    jnz     loc_49C058
    xor     ecx, ecx
    mov     edx, edi
    mov     cl, [edi+TAdynmemStruct.LOS_Sight]
    lea     ebp, [esi+4]
    mov     eax, ecx
    add     edx, ecx
    shl     eax, 5
    add     eax, ecx
    mov     cl, [edi+14281h]
    and     cl, 2
    lea     eax, [eax+eax*4]
    cmp     cl, 2
    lea     eax, [edx+eax*2+TAdynmemStruct.Players]
    jnz     short loc_49BF2D
    movsx   ebx, word ptr [ebp+6]
    movsx   ecx, word ptr [ebp+0Ah]
    movsx   edx, word ptr [ebp+2]
    sar     ebx, 1
    sub     ecx, ebx
    mov     ebx, [eax+80h]
    sar     edx, 5
    sar     ecx, 5
    cmp     edx, ebx
    jnb     short loc_49BF29
    cmp     ecx, [eax+84h]
    jnb     short loc_49BF29
    mov     ebx, [eax+80h]
    imul    ebx, ecx
    add     ebx, [eax+7Ch]
    cmp     byte ptr [ebx+edx], 0
    jz      short loc_49BF29
    mov     eax, 1
    jmp     short loc_49BF3A
    ; ---------------------------------------------------------------------------

    loc_49BF29:                             ; CODE XREF: sub_49BE60+A6j
                                            ; sub_49BE60+AEj ...
    xor     eax, eax
    jmp     short loc_49BF3A
    ; ---------------------------------------------------------------------------

    loc_49BF2D:                             ; CODE XREF: sub_49BE60+86j
    push    ebp                             ; int
    push    eax                             ; int
    call    sub_408090
    mov     edi, TAdynmemStructPtr

    loc_49BF3A:                             ; CODE XREF: sub_49BE60+C7j
                                            ; sub_49BE60+CBj
    test    eax, eax
    jz      loc_49C058
    mov     ebx, [esi]
    mov     al, [ebx+10Ch]
    test    al, al
    jnz     loc_49C099
    xor     edx, edx
    xor     eax, eax
    mov     dl, [ebx+10Dh]
    mov     al, [edx+edi+0DCBh]
    xor     edx, edx
    mov     [esp+78h+var_68], eax
    mov     al, [ebx+10Eh]
    mov     ecx, eax
    and     ecx, 0FFh
    movsx   ebx, word ptr [ebp+2]
    mov     dl, [edi+ecx+0DCBh]
    movsx   ecx, word ptr [edi+1431Fh]
    mov     [esp+78h+var_58], edx
    sub     ebx, ecx
    movsx   edx, word ptr [edi+14323h]
    movsx   edi, word ptr [ebp+6]
    sar     edi, 1
    mov     [esp+78h+var_50], edi
    add     ebx, 80h
    movsx   edi, word ptr [ebp+0Ah]
    mov     ebp, [esp+78h+var_50]
    sub     edi, ebp
    movsx   ebp, word ptr [esi+12h]
    sub     ebp, ecx
    sub     edi, edx
    movsx   ecx, word ptr [esi+16h]
    movsx   esi, word ptr [esi+1Ah]
    sar     ecx, 1
    sub     esi, ecx
    add     edi, 20h
    sub     esi, edx
    add     ebp, 80h
    add     esi, 20h
    test    al, al
    jz      loc_49C084
    mov     eax, ebx
    sub     eax, ebp
    cdq
    mov     ecx, eax
    mov     eax, edi
    xor     ecx, edx
    sub     eax, esi
    sub     ecx, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     ecx, eax
    jle     short loc_49C013
    cmp     ebx, ebp
    jle     short loc_49C002
    mov     eax, ebx
    mov     ebx, ebp
    mov     ebp, eax
    mov     eax, edi
    mov     edi, esi
    mov     esi, eax

    loc_49C002:                             ; CODE XREF: sub_49BE60+194j
    mov     edx, [esp+78h+var_58]
    lea     eax, [esi-1]
    push    edx
    push    eax
    lea     ecx, [edi-1]
    push    ebp
    push    ecx
    push    ebx
    jmp     short loc_49C032
    ; ---------------------------------------------------------------------------

    loc_49C013:                             ; CODE XREF: sub_49BE60+190j
    cmp     edi, esi
    jle     short loc_49C023
    mov     eax, ebx
    mov     ebx, ebp
    mov     ebp, eax
    mov     eax, edi
    mov     edi, esi
    mov     esi, eax

    loc_49C023:                             ; CODE XREF: sub_49BE60+1B5j
    mov     edx, [esp+78h+var_58]
    lea     eax, [ebp+1]
    push    edx
    push    esi
    push    eax
    lea     ecx, [ebx-1]
    push    edi
    push    ecx

    loc_49C032:                             ; CODE XREF: sub_49BE60+1B1j
    mov     edx, [esp+8Ch+arg_0]
    push    edx
    call    sub_4BE950
    mov     eax, [esp+78h+var_68]
    mov     ecx, [esp+78h+arg_0]
    push    eax
    push    esi
    push    ebp
    push    edi
    push    ebx
    push    ecx
    call    sub_4BE950

    loc_49C052:                             ; CODE XREF: sub_49BE60+237j
                                            ; sub_49BE60+2D4j ...
    mov     edi, TAdynmemStructPtr

    loc_49C058:                             ; CODE XREF: sub_49BE60+54j
                                            ; sub_49BE60+DCj ...
    mov     eax, [esp+78h+var_54]
    mov     edx, [esp+78h+var_5C]
    mov     ecx, [edi+141F3h]
    inc     eax
    add     edx, 6Bh
    cmp     eax, ecx
    mov     [esp+78h+var_54], eax
    mov     [esp+78h+var_5C], edx
    jl      loc_49BEA3

    loc_49C07A:                             ; CODE XREF: sub_49BE60+39j
                                            ; sub_49BE60+36Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49C084:                             ; CODE XREF: sub_49BE60+174j
    mov     edx, [esp+78h+var_68]
    mov     eax, [esp+78h+arg_0]
    push    edx
    push    esi
    push    ebp
    push    edi
    push    ebx
    push    eax
    call    sub_4BE950
    jmp     short loc_49C052
    ; ---------------------------------------------------------------------------

    loc_49C099:                             ; CODE XREF: sub_49BE60+ECj
    cmp     al, 1
    jnz     loc_49C18F
    mov     ecx, [edi+1431Fh]
    mov     edx, [ebp+0]
    shl     ecx, 10h
    sub     edx, ecx
    mov     [esp+78h+var_30], edx
    mov     eax, [esi+8]
    mov     [esp+78h+var_2C], eax
    mov     ecx, [edi+14323h]
    mov     edx, [esi+0Ch]
    xor     eax, eax
    shl     ecx, 10h
    sub     edx, ecx
    mov     edi, [esp+78h+arg_0]
    mov     [esp+78h+var_28], edx
    mov     ax, [esi+5Eh]
    movsx   ecx, word ptr [esp+78h+var_28+2]
    movsx   edx, word ptr [esp+78h+var_30+2]
    shr     eax, 1
    sub     ecx, eax
    mov     eax, [esp+78h+var_64]
    add     ecx, 20h
    add     edx, 80h
    push    ecx
    push    edx
    push    eax
    push    edi
    call    sub_4B8500
    lea     ecx, [esi+34h]
    mov     edx, [esi+34h]
    mov     [esp+78h+var_48], edx
    add     word ptr [esp+78h+var_48+2], 8000h
    mov     ax, [ecx+4]
    mov     ecx, [ebx+74h]
    add     ax, 8000h
    lea     edx, [esp+78h+var_30]
    mov     [esp+78h+var_44], ax
    lea     eax, [esp+78h+var_48]
    push    eax
    push    ecx
    push    edx
    push    edi
    call    sub_46BAE0
    mov     eax, [ebx+74h]
    mov     ecx, [eax+30h]
    test    ecx, ecx
    jz      loc_49C052
    mov     edx, [esp+78h+var_60]
    mov     ebp, [esi+46h]
    cmp     ebp, edx
    jle     loc_49C052
    mov     edx, [ebx+111h]
    shr     edx, 15h
    test    dl, 1
    jz      short loc_49C179
    mov     cx, [esi+64h]
    lea     edx, [esp+78h+var_48]
    mov     word ptr [esp+78h+var_48], cx
    mov     eax, [eax+30h]
    push    edx
    lea     ecx, [esp+7Ch+var_30]
    push    eax
    push    ecx
    push    edi
    call    sub_46BAE0
    jmp     loc_49C052
    ; ---------------------------------------------------------------------------

    loc_49C179:                             ; CODE XREF: sub_49BE60+2F5j
    lea     edx, [esp+78h+var_48]
    lea     eax, [esp+78h+var_30]
    push    edx
    push    ecx
    push    eax
    push    edi
    call    sub_46BAE0
    jmp     loc_49C052
    ; ---------------------------------------------------------------------------

    loc_49C18F:                             ; CODE XREF: sub_49BE60+23Bj
    cmp     al, 2
    jnz     short loc_49C1F2
    movsx   edx, word ptr [edi+14323h]
    movsx   esi, word ptr [ebp+0Ah]
    movsx   eax, word ptr [ebp+6]
    movsx   ecx, word ptr [edi+1431Fh]
    movsx   ebx, word ptr [ebp+2]
    sub     esi, edx
    sub     ebx, ecx
    sar     eax, 1
    sub     esi, eax
    add     ebx, 80h
    add     esi, 20h
    add     edi, 37E27h
    push    esi
    push    ebx
    push    edi
    call    sub_4B6720
    test    eax, eax
    jz      loc_49C07A
    mov     ecx, TAdynmemStructPtr
    mov     eax, [esp+78h+arg_0]
    push    esi
    push    ebx
    mov     edx, [ecx+1AB9Bh]
    push    edx
    push    eax
    call    sub_4B9360
    jmp     loc_49C052
    ; ---------------------------------------------------------------------------

    loc_49C1F2:                             ; CODE XREF: sub_49BE60+331j
    cmp     al, 3
    jnz     short loc_49C268
    mov     ecx, [edi+1431Fh]
    mov     edx, [ebp+0]
    shl     ecx, 10h
    sub     edx, ecx
    mov     [esp+78h+var_30], edx
    mov     eax, [esi+8]
    mov     [esp+78h+var_2C], eax
    mov     ecx, [edi+14323h]
    mov     edx, [esi+0Ch]
    xor     eax, eax
    shl     ecx, 10h
    sub     edx, ecx
    mov     [esp+78h+var_28], edx
    mov     ax, [esi+5Eh]
    movsx   ecx, word ptr [esp+78h+var_28+2]
    movsx   edx, word ptr [esp+78h+var_30+2]
    mov     esi, [esp+78h+arg_0]
    add     edx, 80h
    shr     eax, 1
    sub     ecx, eax
    mov     eax, [esp+78h+var_64]
    add     ecx, 20h
    push    ecx
    push    edx
    push    eax
    push    esi
    call    sub_4B8500
    mov     edx, [ebx+74h]
    lea     ecx, [esp+78h+var_40]
    push    ecx
    lea     eax, [esp+7Ch+var_30]
    push    edx
    push    eax
    push    esi
    call    sub_46BAE0
    jmp     loc_49C052
    ; ---------------------------------------------------------------------------

    loc_49C268:                             ; CODE XREF: sub_49BE60+394j
    cmp     al, 4
    jnz     loc_49C382
    cmp     byte ptr [ebx+10Dh], 0FFh
    jnb     loc_49C058
    mov     ecx, [edi+1431Fh]
    mov     edx, [ebp+0]
    shl     ecx, 10h
    sub     edx, ecx
    mov     [esp+78h+var_68], 0
    mov     [esp+78h+var_30], edx
    mov     eax, [esi+8]
    mov     [esp+78h+var_2C], eax
    mov     ecx, [edi+14323h]
    mov     edx, [esi+0Ch]
    xor     eax, eax
    shl     ecx, 10h
    sub     edx, ecx
    mov     [esp+78h+var_28], edx
    mov     ax, [esi+5Eh]
    movsx   ecx, word ptr [esp+78h+var_28+2]
    movsx   edx, word ptr [esp+78h+var_30+2]
    shr     eax, 1
    sub     ecx, eax
    mov     eax, [esp+78h+var_64]
    add     ecx, 20h
    add     edx, 80h
    push    ecx
    mov     ecx, [esp+7Ch+arg_0]
    push    edx
    push    eax
    push    ecx
    call    sub_4B8500
    movsx   ebp, word ptr [esp+78h+var_30+2]
    movsx   edx, word ptr [esp+78h+var_2C+2]
    movsx   eax, word ptr [esp+78h+var_28+2]
    mov     edi, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cl, [ebx+10Dh]
    add     ebp, 80h
    sar     edx, 1
    sub     eax, edx
    add     eax, 20h
    cmp     ecx, 4                          ; switch 5 cases
    ja      short loc_49C349                ; default
    jmp     ds:off_49C72C[ecx*4]            ; switch jump

    loc_49C317:                             ; DATA XREF: .text:0049C72Co
    mov     ecx, [edi+147BBh]               ; case 0x0
    jmp     short loc_49C345
    ; ---------------------------------------------------------------------------

    loc_49C31F:                             ; CODE XREF: sub_49BE60+4B0j
                                            ; DATA XREF: .text:0049C72Co
    mov     edx, [edi+147BFh]               ; case 0x1
    mov     [esp+78h+var_68], edx
    jmp     short loc_49C349                ; default
    ; ---------------------------------------------------------------------------

    loc_49C32B:                             ; CODE XREF: sub_49BE60+4B0j
                                            ; DATA XREF: .text:0049C72Co
    mov     ecx, [edi+147C3h]               ; case 0x2
    jmp     short loc_49C345
    ; ---------------------------------------------------------------------------

    loc_49C333:                             ; CODE XREF: sub_49BE60+4B0j
                                            ; DATA XREF: .text:0049C72Co
    mov     edx, [edi+147C7h]               ; case 0x3
    mov     [esp+78h+var_68], edx
    jmp     short loc_49C349                ; default
    ; ---------------------------------------------------------------------------

    loc_49C33F:                             ; CODE XREF: sub_49BE60+4B0j
                                            ; DATA XREF: .text:0049C72Co
    mov     ecx, [edi+147CBh]               ; case 0x4

    loc_49C345:                             ; CODE XREF: sub_49BE60+4BDj
                                            ; sub_49BE60+4D1j
    mov     [esp+78h+var_68], ecx

    loc_49C349:                             ; CODE XREF: sub_49BE60+4AEj
                                            ; sub_49BE60+4C9j ...
    mov     ecx, [esp+78h+var_68]           ; default
    test    ecx, ecx
    jz      loc_49C058
    mov     edi, [esi+42h]
    push    eax
    mov     eax, [esp+7Ch+var_60]
    xor     esi, esi
    mov     si, [ecx]
    sub     eax, edi
    cdq
    idiv    esi
    push    ebp
    push    edx
    push    ecx
    call    sub_4B7F30
    push    eax
    mov     edx, [esp+84h+arg_0]
    push    edx
    call    sub_4B7F90
    jmp     loc_49C052
    ; ---------------------------------------------------------------------------

    loc_49C382:                             ; CODE XREF: sub_49BE60+40Aj
    cmp     al, 5
    jnz     loc_49C418
    movsx   ecx, word ptr [edi+1431Fh]
    movsx   eax, word ptr [ebp+2]
    movsx   edx, word ptr [edi+14323h]
    sub     eax, ecx
    mov     edi, [edi+147F3h]
    movsx   ecx, word ptr [ebp+6]
    add     eax, 80h
    push    edi
    mov     [esp+7Ch+var_58], eax
    movsx   eax, word ptr [ebp+0Ah]
    sub     eax, edx
    sar     ecx, 1
    sub     eax, ecx
    add     eax, 20h
    mov     [esp+7Ch+var_50], eax
    call    sub_4B7F60
    mov     ebp, eax
    mov     eax, [esi+46h]
    mov     esi, [esp+78h+var_60]
    xor     ecx, ecx
    sub     eax, esi
    mov     cx, [ebx+0E6h]
    imul    eax, ebp
    cdq
    idiv    ecx
    mov     ecx, ebp
    sub     ecx, eax
    js      loc_49C052
    cmp     ecx, ebp
    jge     loc_49C052
    mov     edx, [esp+78h+var_50]
    mov     eax, [esp+78h+var_58]
    push    edx
    push    eax
    push    ecx
    push    edi
    call    sub_4B7F30
    push    eax
    mov     ecx, [esp+84h+arg_0]
    push    ecx
    call    sub_4B8500
    jmp     loc_49C052
    ; ---------------------------------------------------------------------------

    loc_49C418:                             ; CODE XREF: sub_49BE60+524j
    cmp     al, 6
    jnz     short loc_49C48C
    mov     edx, [edi+1431Fh]
    mov     eax, [ebp+0]
    shl     edx, 10h
    sub     eax, edx
    mov     [esp+78h+var_30], eax
    mov     ecx, [esi+8]
    mov     [esp+78h+var_2C], ecx
    mov     edx, [edi+14323h]
    mov     eax, [esi+0Ch]
    xor     ecx, ecx
    shl     edx, 10h
    sub     eax, edx
    mov     edi, [esp+78h+arg_0]
    mov     [esp+78h+var_28], eax
    mov     cx, [esi+5Eh]
    movsx   edx, word ptr [esp+78h+var_28+2]
    movsx   eax, word ptr [esp+78h+var_30+2]
    shr     ecx, 1
    sub     edx, ecx
    mov     ecx, [esp+78h+var_64]
    add     edx, 20h
    add     eax, 80h
    push    edx
    push    eax
    push    ecx
    push    edi
    call    sub_4B8500
    mov     edx, [ebx+74h]
    add     esi, 34h
    push    esi
    lea     eax, [esp+7Ch+var_30]
    push    edx
    push    eax
    push    edi
    call    sub_46BAE0
    jmp     loc_49C052
    ; ---------------------------------------------------------------------------

    loc_49C48C:                             ; CODE XREF: sub_49BE60+5BAj
    cmp     al, 7
    jnz     loc_49C058
    xor     ecx, ecx
    mov     eax, [ebp+4]
    mov     cl, [ebx+10Dh]
    mov     ebx, [ebp+0]
    xor     edx, edx
    mov     ebp, [ebp+8]
    mov     dl, [ecx+edi+0DCBh]
    mov     ecx, [esi+14h]
    add     esi, 10h
    mov     [esp+78h+var_4C], edx
    sub     eax, ecx
    mov     [esp+78h+var_50], esi
    mov     edx, [esi]
    mov     [esp+78h+var_14], eax
    sub     ebx, edx
    mov     edx, [esi+8]
    mov     [esp+78h+var_18], ebx
    sub     ebp, edx
    fild    [esp+78h+var_18]
    fild    [esp+78h+var_14]
    mov     [esp+78h+var_10], ebp
    fild    [esp+78h+var_10]
    fld     st(2)
    fmul    st, st(3)
    fld     st(2)
    fmul    st, st(3)
    faddp   st(1), st
    fld     st(1)
    fmul    st, st(2)
    faddp   st(1), st
    fsqrt
    call    __ftol
    fstp    st
    fstp    st
    cdq
    fstp    st
    mov     ecx, 10h
    call    __allshl
    push    0
    push    50000h
    push    edx
    push    eax
    call    __alldiv
    test    eax, eax
    mov     [esp+78h+var_68], eax
    jz      loc_49C058
    cdq
    mov     [esp+78h+var_38], eax
    mov     eax, ebx
    mov     [esp+78h+var_34], edx
    mov     ecx, 10h
    cdq
    call    __allshl
    mov     ecx, [esp+78h+var_34]
    push    ecx
    mov     ecx, [esp+7Ch+var_38]
    push    ecx
    push    edx
    push    eax
    call    __alldiv
    mov     ebx, eax
    mov     ecx, 10h
    mov     eax, [esp+78h+var_14]
    cdq
    call    __allshl
    mov     ecx, [esp+78h+var_34]
    push    ecx
    mov     ecx, [esp+7Ch+var_38]
    push    ecx
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, 10h
    mov     [esp+78h+var_14], eax
    mov     eax, ebp
    cdq
    call    __allshl
    mov     ecx, [esp+78h+var_34]
    push    ecx
    mov     ecx, [esp+7Ch+var_38]
    push    ecx
    push    edx
    push    eax
    call    __alldiv
    mov     [esp+78h+var_10], eax
    mov     [esp+78h+var_58], 2
    jmp     short loc_49C59E
    ; ---------------------------------------------------------------------------

    loc_49C59A:                             ; CODE XREF: sub_49BE60+8C1j
    mov     esi, [esp+78h+var_50]

    loc_49C59E:                             ; CODE XREF: sub_49BE60+738j
    mov     edx, esi
    mov     ebp, [esi]
    mov     ecx, [edx]
    mov     eax, [edx+4]
    mov     edx, [edx+8]
    mov     [esp+78h+var_30], ebp
    mov     ebp, [esi+4]
    mov     [esp+78h+var_2C], ebp
    mov     esi, [esi+8]
    mov     [esp+78h+var_28], esi
    mov     si, word ptr [esp+78h+var_68+2]
    test    si, si
    jle     loc_49C718
    movsx   ebp, si
    jmp     short loc_49C5DB
    ; ---------------------------------------------------------------------------

    loc_49C5CF:                             ; CODE XREF: sub_49BE60+8ACj
    mov     eax, [esp+78h+var_20]
    mov     ecx, [esp+78h+var_24]
    mov     edx, [esp+78h+var_1C]

    loc_49C5DB:                             ; CODE XREF: sub_49BE60+76Dj
    mov     edi, [esp+78h+var_14]
    mov     esi, [esp+78h+var_10]
    mov     [esp+78h+var_C], ecx
    mov     ecx, [esp+78h+var_28]
    mov     [esp+78h+var_8], eax
    mov     eax, [esp+78h+var_2C]
    mov     [esp+78h+var_4], edx
    mov     edx, [esp+78h+var_30]
    add     edx, ebx
    add     eax, edi
    add     ecx, esi
    mov     [esp+78h+var_30], edx
    mov     [esp+78h+var_2C], eax
    mov     [esp+78h+var_28], ecx
    mov     [esp+78h+var_24], edx
    mov     [esp+78h+var_20], eax
    mov     [esp+78h+var_1C], ecx
    call    _rand
    cdq
    push    0
    push    0Bh
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    sub     eax, 5
    mov     si, word ptr [esp+78h+var_24+2]
    add     si, ax
    mov     word ptr [esp+78h+var_24+2], si
    call    _rand
    cdq
    push    0
    push    0Bh
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    sub     eax, 5
    mov     di, word ptr [esp+78h+var_20+2]
    add     di, ax
    mov     word ptr [esp+78h+var_20+2], di
    call    _rand
    cdq
    push    0
    push    0Bh
    push    edx
    push    eax
    call    __allmul
    push    0
    push    8000h
    push    edx
    push    eax
    call    __alldiv
    mov     ecx, TAdynmemStructPtr
    sub     eax, 5
    mov     dx, word ptr [esp+78h+var_1C+2]
    push    [esp+78h+var_4C]
    add     dx, ax
    movsx   eax, word ptr [ecx+14323h]
    movsx   edi, di
    mov     word ptr [esp+7Ch+var_1C+2], dx
    movsx   edx, dx
    sar     edi, 1
    movsx   ecx, word ptr [ecx+1431Fh]
    sub     edx, edi
    sub     edx, eax
    add     edx, 20h
    push    edx
    movsx   edx, si
    sub     edx, ecx
    add     edx, 80h
    push    edx
    movsx   edx, word ptr [esp+84h+var_8+2]
    movsx   esi, word ptr [esp+84h+var_4+2]
    sar     edx, 1
    sub     esi, edx
    sub     esi, eax
    movsx   eax, word ptr [esp+84h+var_C+2]
    sub     eax, ecx
    mov     ecx, [esp+84h+arg_0]
    add     esi, 20h
    add     eax, 80h
    push    esi
    push    eax
    push    ecx
    call    sub_4BE950
    dec     ebp
    jnz     loc_49C5CF
    mov     edi, TAdynmemStructPtr

    loc_49C718:                             ; CODE XREF: sub_49BE60+764j
    mov     eax, [esp+78h+var_58]
    dec     eax
    mov     [esp+78h+var_58], eax
    jnz     loc_49C59A
    jmp     loc_49C058
    sub_49BE60 endp

    ; ---------------------------------------------------------------------------
    off_49C72C dd offset loc_49C317         ; DATA XREF: sub_49BE60+4B0r
    dd offset loc_49C31F                    ; jump table for switch statement
    dd offset loc_49C32B
    dd offset loc_49C333
    dd offset loc_49C33F

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49C740 proc near                    ; CODE XREF: sub_49C9C0+72p
                                            ; sub_49CC20+70p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch

    push    ebx
    mov     ebx, [esp+arg_8]
    push    ebp
    mov     ebp, [esp+4+arg_4]
    push    esi
    mov     esi, [esp+8+arg_0]
    mov     ecx, ebx
    push    edi
    mov     [esi], ebp
    lea     eax, [esi+4]
    mov     edx, [ecx]
    mov     [eax], edx
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    lea     edx, [esi+10h]
    mov     ecx, [ecx+8]
    mov     [eax+8], ecx
    mov     eax, ebx
    mov     ecx, [eax]
    mov     [edx], ecx
    mov     ecx, [eax+4]
    mov     [edx+4], ecx
    xor     ecx, ecx
    mov     eax, [eax+8]
    mov     [edx+8], eax
    mov     eax, [esp+0Ch+arg_C]
    cmp     eax, ecx
    jz      short loc_49C79A
    mov     edi, [eax]
    lea     edx, [esi+28h]
    mov     [esi+28h], edi
    mov     edi, [eax+4]
    mov     [edx+4], edi
    mov     eax, [eax+8]
    mov     [edx+8], eax

    loc_49C79A:                             ; CODE XREF: sub_49C740+44j
    mov     edx, [esp+0Ch+arg_10]
    and     word ptr [esi+69h], 0FFFEh
    mov     ax, [esi+69h]
    mov     edi, [esp+0Ch+arg_14]
    mov     [esi+42h], edx
    mov     [esi+60h], cx
    mov     edx, TAdynmemStructPtr
    and     eax, 0FFCFh
    cmp     edi, ecx
    mov     edx, [edx+38A47h]
    mov     [esi+56h], ecx
    mov     [esi+4Ah], edx
    mov     [esi+4Eh], ecx
    mov     [esi+69h], ax
    jz      short loc_49C853
    mov     al, [edi+0FFh]
    mov     [esi+52h], edi
    mov     [esi+66h], al
    mov     eax, [edi+110h]
    test    eax, 20000000h
    jz      short loc_49C801
    mov     eax, TAdynmemStructPtr
    cmp     [eax+142F3h], edi
    jnz     short loc_49C801
    mov     [eax+142F7h], esi

    loc_49C801:                             ; CODE XREF: sub_49C740+ACj
                                            ; sub_49C740+B9j
    xor     cl, cl
    mov     byte ptr [esp+0Ch+arg_4], cl

    loc_49C807:                             ; CODE XREF: sub_49C740+E6j
    mov     eax, [esp+0Ch+arg_4]
    and     eax, 0FFh
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    cmp     [edi+edx*4+10h], ebp
    jz      short loc_49C828
    inc     cl
    cmp     cl, 3
    mov     byte ptr [esp+0Ch+arg_4], cl
    jb      short loc_49C807

    loc_49C828:                             ; CODE XREF: sub_49C740+DBj
    mov     eax, [esp+0Ch+arg_4]
    push    eax
    push    edi
    call    sub_43E1E0
    mov     [esi+62h], ax
    mov     ecx, TAdynmemStructPtr
    mov     edx, [ecx+38A47h]
    add     edx, 258h
    xor     ecx, ecx
    mov     [edi+0B0h], edx
    jmp     short loc_49C85A
    ; ---------------------------------------------------------------------------

    loc_49C853:                             ; CODE XREF: sub_49C740+93j
    mov     byte ptr [esi+66h], 0Ah
    mov     [esi+52h], ecx

    loc_49C85A:                             ; CODE XREF: sub_49C740+111j
    xor     eax, eax
    push    ecx
    mov     ax, [ebp+0F4h]
    push    ebx
    push    eax
    call    sub_47F300
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    18h
    sub_49C740 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49C880 proc near                    ; CODE XREF: sub_4866D0+E5p

    arg_0= dword ptr  4

    mov     eax, TAdynmemStructPtr
    push    ebx
    push    esi
    push    edi
    mov     ecx, [eax+141F3h]
    mov     esi, [eax+141F7h]
    xor     ebx, ebx
    xor     edi, edi
    cmp     ecx, ebx
    jle     short loc_49C90D
    push    ebp
    mov     ebp, [esp+10h+arg_0]

    loc_49C8A1:                             ; CODE XREF: sub_49C880+8Aj
    cmp     [esi+60h], bx
    jz      short loc_49C8FE
    cmp     [esi+52h], ebp
    jnz     short loc_49C8FE
    mov     ecx, [eax+142F7h]
    cmp     esi, ecx
    jnz     short loc_49C8F0
    add     ecx, 4
    add     eax, 1433Fh
    mov     edx, [ecx]
    mov     [eax], edx
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     ecx, [ecx+8]
    mov     [eax+8], ecx
    mov     edx, [esi]
    mov     ecx, TAdynmemStructPtr
    mov     ax, [edx+0FEh]
    mov     [ecx+1434Bh], ax
    mov     edx, TAdynmemStructPtr
    mov     [edx+142F7h], ebx

    loc_49C8F0:                             ; CODE XREF: sub_49C880+34j
    or      byte ptr [esi+69h], 2
    call    sub_49AE20
    mov     eax, TAdynmemStructPtr

    loc_49C8FE:                             ; CODE XREF: sub_49C880+25j
                                            ; sub_49C880+2Aj
    mov     ecx, [eax+141F3h]
    inc     edi
    add     esi, 6Bh
    cmp     edi, ecx
    jl      short loc_49C8A1
    pop     ebp

    loc_49C90D:                             ; CODE XREF: sub_49C880+1Aj
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_49C880 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+8]
    mov     eax, [esi]
    mov     ecx, [eax+68h]
    test    ecx, ecx
    jz      short loc_49C95A
    test    dword ptr [eax+111h], 8000000h
    jnz     short loc_49C95A
    mov     eax, [eax+0DCh]
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     ecx, TAdynmemStructPtr
    add     eax, [ecx+38A47h]
    mov     [esi+46h], eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49C95A:                             ; CODE XREF: .text:0049C92Cj
                                            ; .text:0049C938j
    xor     edx, edx
    mov     dx, [eax+0E6h]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    add     ecx, edx
    mov     [esi+46h], ecx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+8]
    mov     eax, [ecx+6Ch]
    test    eax, eax
    jz      short loc_49C995
    mov     ecx, [esp+4]
    mov     [ecx+3Ah], eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49C995:                             ; CODE XREF: .text:0049C989j
    mov     eax, [ecx+70h]
    test    eax, eax
    jnz     short loc_49C9A9
    mov     eax, [esp+4]
    mov     edx, [ecx+68h]
    mov     [eax+3Ah], edx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49C9A9:                             ; CODE XREF: .text:0049C99Aj
    mov     ecx, [esp+4]
    mov     dword ptr [ecx+3Ah], 0
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49C9C0 proc near                    ; CODE XREF: .text:0049D115p
                                            ; sub_49D270+2E8p ...

    var_20= qword ptr -20h
    var_18= qword ptr -18h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     eax, [ecx+141F3h]
    xor     esi, esi
    cmp     eax, 12Ch
    push    edi
    jge     short loc_49CA06
    mov     esi, [ecx+141F7h]
    lea     edx, [eax+eax*2]
    lea     edx, [edx+edx*8]
    shl     edx, 2
    sub     edx, eax
    add     esi, edx
    inc     eax
    mov     [ecx+141F3h], eax
    and     word ptr [esi+69h], 0FFFDh
    mov     dword ptr [esi+4Eh], 0
    mov     ecx, TAdynmemStructPtr

    loc_49CA06:                             ; CODE XREF: sub_49C9C0+17j
    test    esi, esi
    jnz     short loc_49CA13
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_49CA13:                             ; CODE XREF: sub_49C9C0+48j
    mov     ebp, [esp+10h+arg_4]
    mov     edi, [esp+10h+arg_0]
    mov     eax, [ecx+38A47h]
    mov     ebx, [esp+10h+arg_C]
    mov     ecx, [esp+10h+arg_8]
    mov     edx, [edi+0Ch]
    push    ebp
    push    eax
    push    ebx
    push    ecx
    push    edx
    push    esi
    call    sub_49C740
    mov     edx, [ebx]
    mov     ecx, [esp+10h+arg_8]
    mov     eax, [ecx]
    sub     eax, edx
    mov     edx, [ecx+4]
    sub     edx, [ebx+4]
    mov     ecx, [ecx+8]
    mov     [esp+10h+arg_4], eax
    mov     [esp+10h+arg_C], edx
    mov     edx, [ebx+8]
    sub     ecx, edx
    push    ecx
    push    eax
    mov     [esp+18h+arg_0], ecx
    call    sub_4B715A
    fild    [esp+18h+arg_0]
    add     esp, 8
    mov     ebx, eax
    sub     esp, 8
    fstp    [esp+18h+var_18]
    fild    [esp+18h+arg_4]
    sub     esp, 8
    fstp    [esp+20h+var_20]
    call    __hypot
    add     esp, 10h
    call    __ftol
    movsx   ecx, word ptr [esp+10h+arg_C+2]
    mov     [esi+3Eh], eax
    shr     eax, 10h
    movsx   eax, ax
    neg     ecx
    push    eax
    push    ecx
    call    sub_4B715A
    mov     [esi+36h], bx
    mov     [esi+38h], ax
    mov     ecx, [edi+0Ch]
    add     esp, 8
    mov     [esp+10h+arg_0], eax
    mov     edx, [ecx+6Ch]
    test    edx, edx
    jz      short loc_49CABD
    mov     [esi+3Ah], edx
    jmp     short loc_49CAD3
    ; ---------------------------------------------------------------------------

    loc_49CABD:                             ; CODE XREF: sub_49C9C0+F6j
    mov     edx, [ecx+70h]
    test    edx, edx
    jnz     short loc_49CACC
    mov     edx, [ecx+68h]
    mov     [esi+3Ah], edx
    jmp     short loc_49CAD3
    ; ---------------------------------------------------------------------------

    loc_49CACC:                             ; CODE XREF: sub_49C9C0+102j
    mov     dword ptr [esi+3Ah], 0

    loc_49CAD3:                             ; CODE XREF: sub_49C9C0+FBj
                                            ; sub_49C9C0+10Aj
    mov     ecx, [esi+3Ah]
    push    ecx
    push    eax
    call    sub_4B70EF
    mov     edx, [esi+3Ah]
    add     esp, 8
    mov     [esi+20h], eax
    mov     eax, [esp+10h+arg_0]
    push    edx
    push    eax
    call    sub_4B7123
    add     esp, 8
    mov     [esp+10h+arg_0], eax
    push    eax
    push    ebx
    call    sub_4B70EF
    mov     ecx, [esp+18h+arg_0]
    add     esp, 8
    neg     eax
    push    ecx
    push    ebx
    mov     [esi+1Ch], eax
    call    sub_4B7123
    neg     eax
    mov     [esi+24h], eax
    mov     eax, [esi]
    add     esp, 8
    mov     ecx, [eax+68h]
    test    ecx, ecx
    jz      short loc_49CB4A
    test    dword ptr [eax+111h], 8000000h
    jnz     short loc_49CB4A
    mov     eax, [eax+0DCh]
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+38A47h]
    jmp     short loc_49CB5F
    ; ---------------------------------------------------------------------------

    loc_49CB4A:                             ; CODE XREF: sub_49C9C0+161j
                                            ; sub_49C9C0+16Dj
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cx, [eax+0E6h]
    mov     eax, [edx+38A47h]

    loc_49CB5F:                             ; CODE XREF: sub_49C9C0+188j
    add     eax, ecx
    mov     ecx, [esp+10h+arg_10]
    mov     [esi+46h], eax
    mov     [esi+4Eh], ecx
    mov     edx, [edi+0Ch]
    push    0                               ; RunNow
    push    0                               ; CompletedScriptMethodCallback
    mov     ax, [edx+0EAh]
    mov     [esi+60h], ax
    mov     cl, [edi+1Bh]
    shr     ecx, 2
    and     ecx, 3
    mov     edx, FunctionName[ecx*4]
    mov     ecx, [ebp+9Ah]
    push    edx                             ; FunctionName
    call    InvokeScript
    mov     al, [edi+1Bh]
    push    320h
    shr     eax, 2
    and     eax, 3
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     si, [ebp+ecx*4+1Ah]
    sub     si, [ebp+66h]
    push    esi
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    320h
    push    esi
    call    sub_4B7123
    add     esp, 8
    mov     ecx, [ebp+9Ah]
    neg     eax
    push    0
    push    0
    push    ebx
    push    eax
    push    2
    push    0
    push    0
    push    offset aRockunit                ; "RockUnit"
    call    sub_4B0A70
    mov     edx, [edi+0Ch]
    mov     eax, [edx+111h]
    shr     eax, 9
    test    al, 1
    jz      short loc_49CC0C
    mov     ecx, [esp+10h+arg_8]
    push    9
    push    ecx
    call    sub_4729D0

    loc_49CC0C:                             ; CODE XREF: sub_49C9C0+23Ej
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    14h
    sub_49C9C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49CC20 proc near                    ; CODE XREF: sub_49D270+209p
                                            ; sub_49DB70+E2p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     eax, [ecx+141F3h]
    xor     ebx, ebx
    xor     esi, esi
    cmp     eax, 12Ch
    push    edi
    jge     short loc_49CC64
    mov     esi, [ecx+141F7h]
    lea     edx, [eax+eax*2]
    lea     edx, [edx+edx*8]
    shl     edx, 2
    sub     edx, eax
    add     esi, edx
    inc     eax
    mov     [ecx+141F3h], eax
    and     word ptr [esi+69h], 0FFFDh
    mov     [esi+4Eh], ebx
    mov     ecx, TAdynmemStructPtr

    loc_49CC64:                             ; CODE XREF: sub_49CC20+19j
    cmp     esi, ebx
    jnz     short loc_49CC71
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_49CC71:                             ; CODE XREF: sub_49CC20+46j
    mov     ebp, [esp+10h+arg_4]
    mov     edi, [esp+10h+arg_0]
    mov     eax, [ecx+38A47h]
    mov     ecx, [esp+10h+arg_C]
    mov     edx, [esp+10h+arg_8]
    push    ebp
    push    eax
    mov     eax, [edi+0Ch]
    push    ecx
    push    edx
    push    eax
    push    esi
    call    sub_49C740
    mov     [esi+36h], bx
    mov     word ptr [esi+38h], 4000h
    mov     eax, [edi+0Ch]
    mov     [edi+8], ebx
    mov     ecx, [eax+6Ch]
    cmp     ecx, ebx
    jz      short loc_49CCB1
    mov     [esi+3Ah], ecx
    jmp     short loc_49CCC1
    ; ---------------------------------------------------------------------------

    loc_49CCB1:                             ; CODE XREF: sub_49CC20+8Aj
    cmp     [eax+70h], ebx
    jnz     short loc_49CCBE
    mov     ecx, [eax+68h]
    mov     [esi+3Ah], ecx
    jmp     short loc_49CCC1
    ; ---------------------------------------------------------------------------

    loc_49CCBE:                             ; CODE XREF: sub_49CC20+94j
    mov     [esi+3Ah], ebx

    loc_49CCC1:                             ; CODE XREF: sub_49CC20+8Fj
                                            ; sub_49CC20+9Cj
    lea     eax, [esi+1Ch]
    xor     edx, edx
    mov     [eax], edx
    mov     [eax+4], edx
    mov     [eax+8], edx
    mov     eax, [esi]
    mov     ecx, [eax+68h]
    cmp     ecx, ebx
    jz      short loc_49CD01
    test    dword ptr [eax+111h], 8000000h
    jnz     short loc_49CD01
    mov     eax, [eax+0DCh]
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     ecx, TAdynmemStructPtr
    add     eax, [ecx+38A47h]
    mov     [esi+46h], eax
    jmp     short loc_49CD1A
    ; ---------------------------------------------------------------------------

    loc_49CD01:                             ; CODE XREF: sub_49CC20+B5j
                                            ; sub_49CC20+C1j
    xor     edx, edx
    mov     dx, [eax+0E6h]
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+38A47h]
    add     ecx, edx
    mov     [esi+46h], ecx

    loc_49CD1A:                             ; CODE XREF: sub_49CC20+DFj
    mov     edx, [esp+10h+arg_10]
    mov     eax, [esp+10h+arg_14]
    mov     [esi+4Eh], edx
    mov     [esi+56h], eax
    mov     ecx, [edi+0Ch]
    push    ebx                             ; RunNow
    push    ebx                             ; CompletedScriptMethodCallback
    mov     dx, [ecx+0EAh]
    mov     [esi+60h], dx
    mov     al, [edi+1Bh]
    shr     eax, 2
    and     eax, 3
    mov     ecx, FunctionName[eax*4]
    push    ecx                             ; FunctionName
    mov     ecx, [ebp+9Ah]
    call    InvokeScript
    mov     al, [edi+1Bh]
    push    320h
    shr     eax, 2
    and     eax, 3
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    mov     si, [ebp+edx*4+1Ah]
    sub     si, [ebp+66h]
    push    esi
    call    sub_4B70EF
    add     esp, 8
    mov     ebx, eax
    neg     ebx
    push    320h
    push    esi
    call    sub_4B7123
    add     esp, 8
    mov     ecx, [ebp+9Ah]
    neg     eax
    push    0
    push    0
    push    ebx
    push    eax
    push    2
    push    0
    push    0
    push    offset aRockunit                ; "RockUnit"
    call    sub_4B0A70
    mov     eax, [edi+0Ch]
    mov     ecx, [eax+111h]
    shr     ecx, 9
    test    cl, 1
    jz      short loc_49CDC8
    mov     edx, [esp+10h+arg_8]
    push    9
    push    edx
    call    sub_4729D0

    loc_49CDC8:                             ; CODE XREF: sub_49CC20+19Aj
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    18h
    sub_49CC20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49CDE0 proc near                    ; CODE XREF: .text:0049D0F8p
                                            ; sub_49D270+1DEp ...

    var_20= qword ptr -20h
    var_18= qword ptr -18h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     ecx, TAdynmemStructPtr
    push    ebx
    push    ebp
    push    esi
    mov     eax, [ecx+141F3h]
    push    edi
    xor     edi, edi
    cmp     eax, 12Ch
    jge     short loc_49CE26
    mov     edi, [ecx+141F7h]
    lea     edx, [eax+eax*2]
    lea     edx, [edx+edx*8]
    shl     edx, 2
    sub     edx, eax
    add     edi, edx
    inc     eax
    mov     [ecx+141F3h], eax
    and     word ptr [edi+69h], 0FFFDh
    mov     dword ptr [edi+4Eh], 0
    mov     ecx, TAdynmemStructPtr

    loc_49CE26:                             ; CODE XREF: sub_49CDE0+17j
    test    edi, edi
    jz      loc_49CFF7
    mov     ebx, [esp+10h+arg_4]
    mov     esi, [esp+10h+arg_0]
    mov     eax, [ecx+38A47h]
    mov     ecx, [esp+10h+arg_8]
    mov     edx, [esi+0Ch]
    push    ebx
    push    eax
    push    0
    push    ecx
    push    edx
    push    edi
    call    sub_49C740
    mov     ax, [esi+16h]
    mov     [edi+36h], ax
    mov     cx, [esi+18h]
    mov     [edi+38h], cx
    mov     edx, [esi+0Ch]
    mov     eax, [esi+10h]
    mov     ecx, [edx+68h]
    xor     edx, edx
    div     ecx
    push    ecx
    mov     cx, [esi+18h]
    push    ecx
    mov     ebp, eax
    mov     eax, TAdynmemStructPtr
    imul    ebp, [eax+14263h]
    call    sub_4B70EF
    sub     eax, ebp
    add     esp, 8
    mov     [edi+20h], eax
    mov     edx, [esi+0Ch]
    mov     cx, [esi+18h]
    mov     eax, [edx+68h]
    push    eax
    push    ecx
    call    sub_4B7123
    mov     dx, [esi+16h]
    add     esp, 8
    mov     ebp, eax
    push    ebp
    push    edx
    call    sub_4B70EF
    neg     eax
    add     esp, 8
    mov     [edi+1Ch], eax
    mov     ax, [esi+16h]
    push    ebp
    push    eax
    call    sub_4B7123
    neg     eax
    mov     [edi+24h], eax
    mov     eax, [esi+0Ch]
    add     esp, 8
    mov     ecx, [eax+111h]
    shr     ecx, 17h
    test    cl, 1
    jz      short loc_49CF29
    mov     ecx, [esp+10h+arg_8]
    mov     eax, [esp+10h+arg_C]
    sub     esp, 8
    mov     edx, [ecx+8]
    mov     ecx, [ecx]
    sub     edx, [eax+8]
    sub     esp, 8
    mov     [esp+20h+arg_0], edx
    mov     edx, [eax]
    fild    [esp+20h+arg_0]
    sub     ecx, edx
    mov     [esp+20h+arg_0], ecx
    fstp    [esp+20h+var_18]
    fild    [esp+20h+arg_0]
    fstp    [esp+20h+var_20]
    call    __hypot
    add     esp, 10h
    call    __ftol
    cdq
    idiv    ebp
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+38A47h]
    jmp     short loc_49CF3E
    ; ---------------------------------------------------------------------------

    loc_49CF29:                             ; CODE XREF: sub_49CDE0+F8j
    mov     edx, TAdynmemStructPtr
    xor     ecx, ecx
    mov     cx, [eax+0E6h]
    mov     eax, [edx+38A47h]

    loc_49CF3E:                             ; CODE XREF: sub_49CDE0+147j
    add     eax, ecx
    push    0                               ; RunNow
    mov     [edi+46h], eax
    mov     ecx, [esi+0Ch]
    mov     eax, [esp+14h+arg_10]
    push    0                               ; CompletedScriptMethodCallback
    mov     dx, [ecx+0EAh]
    mov     [edi+4Eh], eax
    mov     [edi+60h], dx
    mov     cl, [esi+1Bh]
    shr     ecx, 2
    and     ecx, 3
    mov     edx, FunctionName[ecx*4]
    mov     ecx, [ebx+9Ah]
    push    edx                             ; FunctionName
    call    InvokeScript
    mov     al, [esi+1Bh]
    push    320h
    shr     eax, 2
    and     eax, 3
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     di, [ebx+ecx*4+1Ah]
    sub     di, [ebx+66h]
    push    edi
    call    sub_4B70EF
    add     esp, 8
    mov     ebp, eax
    neg     ebp
    push    320h
    push    edi
    call    sub_4B7123
    add     esp, 8
    mov     ecx, [ebx+9Ah]
    neg     eax
    push    0
    push    0
    push    ebp
    push    eax
    push    2
    push    0
    push    0
    push    offset aRockunit                ; "RockUnit"
    call    sub_4B0A70
    mov     edx, [esi+0Ch]
    mov     eax, [edx+111h]
    shr     eax, 9
    test    al, 1
    jz      short loc_49CFEB
    mov     ecx, [esp+10h+arg_8]
    push    9
    push    ecx
    call    sub_4729D0

    loc_49CFEB:                             ; CODE XREF: sub_49CDE0+1FDj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_49CFF7:                             ; CODE XREF: sub_49CDE0+48j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    14h
    sub_49CDE0 endp

    ; ---------------------------------------------------------------------------
    mov     ecx, TAdynmemStructPtr
    push    esi
    xor     esi, esi
    push    edi
    mov     eax, [ecx+141F3h]
    cmp     eax, 12Ch
    jge     short loc_49D044
    mov     esi, [ecx+141F7h]
    lea     edx, [eax+eax*2]
    lea     edx, [edx+edx*8]
    shl     edx, 2
    sub     edx, eax
    add     esi, edx
    inc     eax
    mov     [ecx+141F3h], eax
    and     word ptr [esi+69h], 0FFFDh
    mov     dword ptr [esi+4Eh], 0
    mov     ecx, TAdynmemStructPtr

    loc_49D044:                             ; CODE XREF: .text:0049D015j
    test    esi, esi
    jz      short loc_49D0B5
    mov     edi, [esp+10h]
    mov     eax, [ecx+38A47h]
    mov     edx, [esp+0Ch]
    mov     ecx, [esp+14h]
    push    edi
    push    eax
    mov     eax, [edx+0Ch]
    push    0
    push    ecx
    push    eax
    push    esi
    call    sub_49C740
    mov     cx, [edi+66h]
    mov     dword ptr [esi+3Ah], 0
    mov     [esi+36h], cx
    mov     dword ptr [esi+20h], 0
    mov     edx, [edi]
    mov     eax, [edx+20h]
    push    eax
    push    ecx
    call    sub_4B70EF
    mov     cx, [esi+36h]
    add     esp, 8
    neg     eax
    mov     [esi+1Ch], eax
    mov     edx, [edi]
    mov     eax, [edx+20h]
    push    eax
    push    ecx
    call    sub_4B7123
    add     esp, 8
    neg     eax
    mov     [esi+24h], eax
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49D0B5:                             ; CODE XREF: .text:0049D046j
    pop     edi
    xor     eax, eax
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     edx, [esp+4]
    xor     eax, eax
    mov     ecx, [edx+0Ch]
    mov     ecx, [ecx+111h]
    test    cl, 1
    jnz     short loc_49D100
    test    ecx, 100000h
    jnz     short loc_49D100
    shr     ecx, 1
    test    cl, 1
    jz      short locret_49D11A
    mov     eax, [esp+10h]
    mov     ecx, [esp+14h]
    push    eax
    mov     eax, [esp+10h]
    push    ecx
    mov     ecx, [esp+10h]
    push    eax
    push    ecx
    push    edx
    call    sub_49CDE0
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_49D100:                             ; CODE XREF: .text:0049D0D2j
                                            ; .text:0049D0DAj
    mov     eax, [esp+10h]
    mov     ecx, [esp+14h]
    push    eax
    mov     eax, [esp+10h]
    push    ecx
    mov     ecx, [esp+10h]
    push    eax
    push    ecx
    push    edx
    call    sub_49C9C0

    locret_49D11A:                          ; CODE XREF: .text:0049D0E1j
    retn    14h
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49D120 proc near                    ; CODE XREF: .text:00408945p
                                            ; sub_4089A0+1A8p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    ebx
    and     eax, 0FFh
    push    ebp
    mov     ebp, [esp+8+arg_0]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    push    esi
    push    edi
    lea     eax, [ebp+ecx*4+4]
    mov     cl, [ebp+ecx*4+1Eh]
    test    cl, cl
    jz      loc_49D1CD
    mov     edx, [eax+0Ch]
    mov     ecx, TAdynmemStructPtr
    xor     ebx, ebx
    mov     edi, [edx+0E0h]
    mov     esi, [ecx+141F3h]
    mov     eax, [ecx+141F7h]
    shl     edi, 10h
    test    esi, esi
    mov     [esp+10h+arg_4], eax
    jle     short loc_49D1CD

    loc_49D170:                             ; CODE XREF: sub_49D120+ABj
    mov     cl, [ebp+0FFh]
    mov     dl, [eax+66h]
    cmp     dl, cl
    jz      short loc_49D1C5
    mov     ecx, [eax]
    mov     edx, [ecx+111h]
    shr     edx, 1Dh
    test    dl, 1
    jz      short loc_49D1C5
    mov     edx, [ebp+6Ah]
    lea     ecx, [edi+edi]
    sub     edx, [eax+28h]
    add     edx, edi
    cmp     edx, ecx
    ja      short loc_49D1C5
    mov     edx, [ebp+72h]
    sub     edx, [eax+30h]
    add     edx, edi
    cmp     edx, ecx
    ja      short loc_49D1C5
    xor     ecx, ecx
    test    esi, esi
    jle     short loc_49D1C1
    mov     edx, [esp+10h+arg_4]
    add     edx, 56h

    loc_49D1B5:                             ; CODE XREF: sub_49D120+9Fj
    cmp     [edx], eax
    jz      short loc_49D1C1
    inc     ecx
    add     edx, 6Bh
    cmp     ecx, esi
    jl      short loc_49D1B5

    loc_49D1C1:                             ; CODE XREF: sub_49D120+8Cj
                                            ; sub_49D120+97j
    cmp     ecx, esi
    jz      short loc_49D1CF

    loc_49D1C5:                             ; CODE XREF: sub_49D120+5Bj
                                            ; sub_49D120+6Bj ...
    inc     ebx
    add     eax, 6Bh
    cmp     ebx, esi
    jl      short loc_49D170

    loc_49D1CD:                             ; CODE XREF: sub_49D120+22j
                                            ; sub_49D120+4Ej
    xor     eax, eax

    loc_49D1CF:                             ; CODE XREF: sub_49D120+A3j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_49D120 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+10h]
    push    edi
    test    byte ptr [esi+1Ah], 1
    jz      short loc_49D258
    mov     ecx, TAdynmemStructPtr
    xor     edx, edx
    mov     edi, [ecx+141F3h]
    mov     al, [ecx+2A42h]
    mov     ebp, [ecx+141F7h]
    test    edi, edi
    jle     short loc_49D258
    lea     ecx, [ebp+2Ch]

    loc_49D20F:                             ; CODE XREF: .text:0049D244j
    cmp     [ecx+3Ah], al
    jz      short loc_49D23B
    mov     ebx, [ecx-4]
    cmp     ebx, [esi+0Dh]
    jnz     short loc_49D23B
    mov     ebx, [ecx+4]
    cmp     ebx, [esi+15h]
    jnz     short loc_49D23B
    mov     ebx, [ecx]
    cmp     ebx, [esi+11h]
    jnz     short loc_49D23B
    mov     ebx, [ecx+26h]
    mov     bx, [ebx+0A8h]
    cmp     bx, [esi+1Fh]
    jz      short loc_49D24F

    loc_49D23B:                             ; CODE XREF: .text:0049D212j
                                            ; .text:0049D21Aj ...
    inc     edx
    add     ebp, 6Bh
    add     ecx, 6Bh
    cmp     edx, edi
    jl      short loc_49D20F
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49D24F:                             ; CODE XREF: .text:0049D239j
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49D258:                             ; CODE XREF: .text:0049D1ECj
                                            ; .text:0049D20Aj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49D270 proc near                    ; CODE XREF: Network_Process+16F3p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_4= dword ptr  8

    sub     esp, 10h
    mov     eax, [esp+10h+arg_4]
    xor     edx, edx
    push    ebx
    push    ebp
    mov     dl, [eax+19h]
    push    esi
    push    edi
    lea     ecx, [edx+edx*2]
    shl     ecx, 3
    sub     ecx, edx
    lea     esi, [ecx+ecx*2]
    mov     ecx, TAdynmemStructPtr
    mov     edi, ecx
    add     edi, edx
    mov     edx, [edi+esi*4+2E04h]
    shr     edx, 5
    lea     ebp, [edi+esi*4+2CF3h]
    test    dl, 1
    mov     [esp+20h+var_4], ebp
    jz      short loc_49D329
    lea     edi, [eax+0Dh]
    lea     ebx, [eax+1]
    mov     eax, [ecx+141F3h]
    xor     esi, esi
    cmp     eax, 12Ch
    jge     short loc_49D2F1
    mov     esi, [ecx+141F7h]
    lea     edx, [eax+eax*2]
    lea     edx, [edx+edx*8]
    shl     edx, 2
    sub     edx, eax
    add     esi, edx
    inc     eax
    mov     [ecx+141F3h], eax
    and     word ptr [esi+69h], 0FFFDh
    mov     dword ptr [esi+4Eh], 0
    mov     ecx, TAdynmemStructPtr

    loc_49D2F1:                             ; CODE XREF: sub_49D270+52j
    test    esi, esi
    jz      loc_49D55D
    mov     eax, [ecx+38A47h]
    push    0
    push    eax
    push    0
    push    ebx
    push    ebp
    push    esi
    call    sub_49C740
    mov     ecx, [edi]
    add     esi, 1Ch
    mov     [esi], ecx
    mov     edx, [edi+4]
    mov     [esi+4], edx
    mov     eax, [edi+8]
    mov     [esi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49D329:                             ; CODE XREF: sub_49D270+3Dj
    mov     dx, [eax+21h]
    xor     esi, esi
    cmp     dx, si
    jnz     short loc_49D338
    xor     ebp, ebp
    jmp     short loc_49D34C
    ; ---------------------------------------------------------------------------

    loc_49D338:                             ; CODE XREF: sub_49D270+C2j
    and     edx, 0FFFFh
    mov     ebp, [ecx+14357h]
    imul    edx, 118h
    add     ebp, edx

    loc_49D34C:                             ; CODE XREF: sub_49D270+C6j
    cmp     ebp, esi
    jz      loc_49D55D
    test    dword ptr [ebp+110h], 10000000h
    jz      loc_49D55D
    xor     ecx, ecx
    mov     cl, [eax+23h]
    mov     edx, ecx
    shl     edx, 3
    sub     edx, ecx
    lea     ecx, [ebp+edx*4+4]
    mov     dx, [eax+1Dh]
    mov     [esp+20h+var_10], ecx
    mov     [ecx+18h], dx
    mov     dx, [eax+1Bh]
    mov     [ecx+16h], dx
    mov     cx, [eax+1Fh]
    mov     ebx, TAdynmemStructPtr
    cmp     cx, si
    mov     [esp+20h+var_8], ecx
    jnz     short loc_49D3A1
    mov     [esp+20h+arg_4], esi
    jmp     short loc_49D3BB
    ; ---------------------------------------------------------------------------

    loc_49D3A1:                             ; CODE XREF: sub_49D270+129j
    mov     edx, ecx
    mov     ecx, [ebx+14357h]
    and     edx, 0FFFFh
    imul    edx, 118h
    add     ecx, edx
    mov     [esp+20h+arg_4], ecx

    loc_49D3BB:                             ; CODE XREF: sub_49D270+12Fj
    test    byte ptr [eax+1Ah], 1
    jz      short loc_49D428
    mov     edi, [ebx+141F3h]
    mov     ecx, [ebx+141F7h]
    test    edi, edi
    mov     [esp+20h+var_C], ecx
    jle     short loc_49D428
    add     ecx, 2Ch

    loc_49D3D8:                             ; CODE XREF: sub_49D270+1B6j
    mov     dl, [ebx+2A42h]
    cmp     [ecx+3Ah], dl
    jz      short loc_49D415
    mov     edx, [ecx-4]
    cmp     edx, [eax+0Dh]
    jnz     short loc_49D415
    mov     edx, [ecx+4]
    cmp     edx, [eax+15h]
    jnz     short loc_49D415
    mov     edx, [ecx]
    cmp     edx, [eax+11h]
    jnz     short loc_49D415
    mov     edx, [ecx+26h]
    mov     bx, word ptr [esp+20h+var_8]
    cmp     [edx+0A8h], bx
    jz      loc_49D567
    mov     ebx, TAdynmemStructPtr

    loc_49D415:                             ; CODE XREF: sub_49D270+171j
                                            ; sub_49D270+179j ...
    mov     edx, [esp+20h+var_C]
    inc     esi
    add     edx, 6Bh
    add     ecx, 6Bh
    cmp     esi, edi
    mov     [esp+20h+var_C], edx
    jl      short loc_49D3D8

    loc_49D428:                             ; CODE XREF: sub_49D270+14Fj
                                            ; sub_49D270+163j
    xor     esi, esi

    loc_49D42A:                             ; CODE XREF: sub_49D270+301j
    mov     ecx, [esp+20h+var_4]
    mov     ecx, [ecx+111h]
    mov     edx, ecx
    shr     edx, 1
    test    dl, 1
    jz      short loc_49D45D
    mov     ecx, [esp+20h+arg_4]
    lea     edx, [eax+0Dh]
    push    ecx
    inc     eax
    push    edx
    push    eax
    mov     eax, [esp+2Ch+var_10]
    push    ebp
    push    eax
    call    sub_49CDE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49D45D:                             ; CODE XREF: sub_49D270+1CBj
    mov     edx, ecx
    shr     edx, 4
    test    dl, 1
    jz      short loc_49D488
    mov     ecx, [esp+20h+arg_4]
    push    esi
    lea     edx, [eax+0Dh]
    push    ecx
    inc     eax
    push    edx
    push    eax
    mov     eax, [esp+30h+var_10]
    push    ebp
    push    eax
    call    sub_49CC20
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49D488:                             ; CODE XREF: sub_49D270+1F5j
    test    cl, 1
    jnz     loc_49D547
    test    ecx, 100000h
    jnz     loc_49D547
    shr     ecx, 8
    test    cl, 1
    jz      loc_49D55D
    mov     ecx, [ebx+141F3h]
    xor     edi, edi
    xor     esi, esi
    cmp     ecx, 12Ch
    jge     short loc_49D4E4
    mov     esi, [ebx+141F7h]
    lea     edx, [ecx+ecx*2]
    lea     edx, [edx+edx*8]
    shl     edx, 2
    sub     edx, ecx
    add     esi, edx
    inc     ecx
    mov     [ebx+141F3h], ecx
    and     word ptr [esi+69h], 0FFFDh
    mov     [esi+4Eh], edi
    mov     ebx, TAdynmemStructPtr

    loc_49D4E4:                             ; CODE XREF: sub_49D270+249j
    cmp     esi, edi
    jz      short loc_49D55D
    mov     ecx, [ebx+38A47h]
    mov     edx, [esp+20h+var_10]
    push    ebp
    push    ecx
    inc     eax
    push    edi
    push    eax
    mov     eax, [edx+0Ch]
    push    eax
    push    esi
    call    sub_49C740
    mov     cx, [ebp+66h]
    mov     [esi+3Ah], edi
    mov     [esi+36h], cx
    mov     [esi+20h], edi
    mov     edx, [ebp+0]
    mov     eax, [edx+20h]
    push    eax
    push    ecx
    call    sub_4B70EF
    mov     cx, [esi+36h]
    add     esp, 8
    neg     eax
    mov     [esi+1Ch], eax
    mov     edx, [ebp+0]
    mov     eax, [edx+20h]
    push    eax
    push    ecx
    call    sub_4B7123
    add     esp, 8
    neg     eax
    mov     [esi+24h], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49D547:                             ; CODE XREF: sub_49D270+21Bj
                                            ; sub_49D270+227j
    mov     edx, [esp+20h+arg_4]
    lea     ecx, [eax+0Dh]
    push    edx
    mov     edx, [esp+24h+var_10]
    inc     eax
    push    ecx
    push    eax
    push    ebp
    push    edx
    call    sub_49C9C0

    loc_49D55D:                             ; CODE XREF: sub_49D270+83j
                                            ; sub_49D270+DEj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49D567:                             ; CODE XREF: sub_49D270+199j
    mov     esi, [esp+20h+var_C]
    mov     ebx, TAdynmemStructPtr
    jmp     loc_49D42A
    sub_49D270 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49D580 proc near                    ; DATA XREF: sub_49E010+14o

    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    idTo= dword ptr -24h
    var_1F= dword ptr -1Fh
    var_1B= dword ptr -1Bh
    var_17= dword ptr -17h
    var_13= dword ptr -13h
    var_F= dword ptr -0Fh
    var_B= byte ptr -0Bh
    var_A= byte ptr -0Ah
    var_9= word ptr -9
    var_7= word ptr -7
    var_5= word ptr -5
    var_3= word ptr -3
    var_1= byte ptr -1
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 44h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+50h+arg_4]
    push    edi
    mov     al, [esi+1Bh]
    test    al, 1
    jz      loc_49D86D
    mov     ecx, [esi+8]
    test    ecx, ecx
    jz      loc_49D86D
    mov     ecx, [esi+0Ch]
    mov     edi, [esp+54h+arg_0]
    mov     [esp+54h+var_44], ecx
    mov     edx, [ecx+111h]
    shr     edx, 1
    test    dl, 1
    jz      short loc_49D62A
    shr     al, 2
    and     al, 3
    push    eax
    lea     eax, [esp+58h+var_30]
    push    eax
    push    edi
    call    sub_43E2E0
    mov     ebp, [esp+54h+var_30]
    mov     ecx, [esp+54h+arg_C]
    mov     eax, [ecx]
    mov     ebx, [ecx+4]
    mov     edx, [ecx+8]
    sub     ebp, eax
    mov     eax, [esp+54h+var_2C]
    sub     eax, ebx
    mov     ebx, [esp+54h+var_28]
    sub     ebx, edx
    mov     [esp+54h+var_40], eax
    push    ebx
    push    ebp
    call    sub_4B715A
    sub     ax, [edi+66h]
    add     esp, 8
    mov     [esp+54h+arg_0], eax
    mov     eax, [esp+54h+var_44]
    mov     ecx, [eax+0C8h]
    mov     edx, [eax+68h]
    mov     eax, [esp+54h+var_40]
    push    ecx
    push    edx
    push    ebx
    push    eax
    push    ebp
    call    sub_49A890
    xor     ecx, ecx
    cmp     ax, 8000h
    setnz   cl
    mov     [esp+54h+arg_4], eax
    mov     eax, ecx
    jmp     short loc_49D653
    ; ---------------------------------------------------------------------------

    loc_49D62A:                             ; CODE XREF: sub_49D580+37j
    test    byte ptr [ecx+111h], 1
    jz      short loc_49D651
    mov     ebp, [esp+54h+arg_C]
    lea     edx, [esp+54h+arg_4]
    shr     al, 2
    and     al, 3
    push    ebp
    push    eax
    lea     eax, [esp+5Ch+arg_0]
    push    edx
    push    eax
    push    ecx
    push    edi
    call    sub_49D910
    jmp     short loc_49D657
    ; ---------------------------------------------------------------------------

    loc_49D651:                             ; CODE XREF: sub_49D580+B1j
    xor     eax, eax

    loc_49D653:                             ; CODE XREF: sub_49D580+A8j
    mov     ebp, [esp+54h+arg_C]

    loc_49D657:                             ; CODE XREF: sub_49D580+CFj
    test    eax, eax
    jnz     short loc_49D675
    mov     cl, [esi+1Bh]
    and     cl, 0FEh
    mov     [esi+1Bh], cl
    or      byte ptr [edi+0BBh], 10h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49D675:                             ; CODE XREF: sub_49D580+D9j
    mov     ecx, [esp+54h+arg_4]
    mov     edx, [esp+54h+arg_0]
    push    ecx
    push    edx
    push    esi
    push    edi
    call    sub_49D880
    test    eax, eax
    jnz     short loc_49D69E
    mov     al, [esi+1Bh]
    and     al, 0FEh
    mov     [esi+1Bh], al
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49D69E:                             ; CODE XREF: sub_49D580+108j
    mov     al, [esi+1Bh]
    push    0FFFFFFFFh
    shr     al, 2
    and     al, 3
    lea     ecx, [esp+58h+var_3C]
    push    eax
    push    ecx
    push    edi
    call    sub_43E240
    mov     dx, [edi+66h]
    add     [esi+16h], dx
    mov     ecx, [edi+92h]
    movsx   eax, word ptr [edi+108h]
    shl     eax, 0Bh
    xor     edx, edx
    div     dword ptr [ecx+1FAh]
    mov     edx, [esi+0Ch]
    mov     cx, [edx+104h]
    xor     edx, edx
    mov     dx, [edi+0B8h]
    sub     cx, ax
    mov     eax, 2AAAAAABh
    imul    edx
    sar     edx, 1
    mov     eax, edx
    add     ecx, 800h
    shr     eax, 1Fh
    add     edx, eax
    mov     ebx, edx
    cmp     ebx, 1
    jle     short loc_49D713
    mov     eax, ecx
    and     eax, 0FFFFh
    cdq
    idiv    ebx
    mov     ecx, eax

    loc_49D713:                             ; CODE XREF: sub_49D580+185j
    test    cx, cx
    jz      short loc_49D742
    mov     ebx, ecx
    mov     bp, cx
    and     ebx, 0FFFFh
    push    ebx                             ; int
    shr     bp, 1
    call    GetRandom
    sub     eax, ebp
    push    ebx                             ; int
    add     [esi+16h], ax
    call    GetRandom
    sub     eax, ebp
    mov     ebp, [esp+54h+arg_C]
    add     [esi+18h], ax

    loc_49D742:                             ; CODE XREF: sub_49D580+196j
    mov     ecx, [esi+0Ch]
    mov     ebx, [esp+54h+arg_8]
    xor     eax, eax
    mov     ecx, [ecx+111h]
    test    cl, 1
    jnz     short loc_49D775
    test    ecx, 100000h
    jnz     short loc_49D775
    shr     ecx, 1
    test    cl, 1
    jz      short loc_49D783
    push    ebx
    lea     edx, [esp+58h+var_3C]
    push    ebp
    push    edx
    push    edi
    push    esi
    call    sub_49CDE0
    jmp     short loc_49D783
    ; ---------------------------------------------------------------------------

    loc_49D775:                             ; CODE XREF: sub_49D580+1D4j
                                            ; sub_49D580+1DCj
    push    ebx
    lea     eax, [esp+58h+var_3C]
    push    ebp
    push    eax
    push    edi
    push    esi
    call    sub_49C9C0

    loc_49D783:                             ; CODE XREF: sub_49D580+1E3j
                                            ; sub_49D580+1F3j
    test    eax, eax
    jz      loc_49D86D
    mov     al, [esi+1Bh]
    mov     dword ptr [esi+8], 0
    and     al, 0FEh
    mov     [esi+1Bh], al
    mov     ecx, TAdynmemStructPtr
    test    byte ptr [ecx+2A44h], 1
    jz      loc_49D85E
    mov     ecx, [esp+54h+var_38]
    mov     edx, [esp+54h+var_3C]
    mov     [esp+54h+var_1F], ecx
    mov     ecx, [ebp+0]
    mov     [esp+54h+idTo+1], edx
    mov     edx, [esp+54h+var_34]
    mov     [esp+54h+var_17], ecx
    mov     ecx, [ebp+8]
    mov     [esp+54h+var_1B], edx
    mov     edx, [ebp+4]
    mov     [esp+54h+var_F], ecx
    mov     ecx, [esi+0Ch]
    shr     al, 2
    mov     byte ptr [esp+54h+idTo], 0Dh
    mov     [esp+54h+var_13], edx
    mov     dl, [ecx+10Ah]
    and     al, 3
    mov     [esp+54h+var_1], al
    xor     eax, eax
    cmp     edi, eax
    mov     [esp+54h+var_B], dl
    jnz     short loc_49D802
    mov     [esp+54h+var_3], ax
    jmp     short loc_49D80E
    ; ---------------------------------------------------------------------------

    loc_49D802:                             ; CODE XREF: sub_49D580+279j
    mov     dx, [edi+0A8h]
    mov     [esp+54h+var_3], dx

    loc_49D80E:                             ; CODE XREF: sub_49D580+280j
    cmp     ebx, eax
    jz      short loc_49D819
    mov     ax, [ebx+0A8h]

    loc_49D819:                             ; CODE XREF: sub_49D580+290j
    mov     dx, [esi+16h]
    mov     [esp+54h+var_5], ax
    mov     ax, [esi+18h]
    mov     [esp+54h+var_9], dx
    mov     [esp+54h+var_7], ax
    mov     ecx, [ecx+111h]
    mov     al, [esp+54h+var_A]
    lea     edx, [esp+54h+idTo]
    shr     ecx, 1Eh
    xor     cl, al
    push    24h                             ; idFrom
    and     cl, 1
    push    edx                             ; idTo
    xor     al, cl
    mov     [esp+5Ch+var_A], al
    mov     eax, [edi+96h]
    mov     ecx, [eax+4]
    push    ecx                             ; PlayerID
    call    sub_451DF0

    loc_49D85E:                             ; CODE XREF: sub_49D580+227j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49D86D:                             ; CODE XREF: sub_49D580+10j
                                            ; sub_49D580+1Bj ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 44h
    retn    10h
    sub_49D580 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49D880 proc near                    ; CODE XREF: sub_49D580+101p
                                            ; sub_49D9C0+A5p

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= word ptr  14h
    arg_C= word ptr  18h

    push    esi
    push    edi
    mov     edi, [esp+arg_4]
    mov     ecx, [edi+0Ch]
    mov     ax, [ecx+106h]
    test    ax, ax
    jnz     short loc_49D8B4
    mov     eax, [esp+arg_0]
    test    byte ptr [eax+110h], 0Ch
    jz      short loc_49D8AB
    mov     esi, 7D0h
    mov     ecx, esi
    jmp     short loc_49D8D1
    ; ---------------------------------------------------------------------------

    loc_49D8AB:                             ; CODE XREF: sub_49D880+20j
    mov     esi, 96h
    mov     ecx, esi
    jmp     short loc_49D8D1
    ; ---------------------------------------------------------------------------

    loc_49D8B4:                             ; CODE XREF: sub_49D880+13j
    mov     cx, [ecx+108h]
    and     eax, 0FFFFh
    test    cx, cx
    mov     esi, eax
    jz      short loc_49D8CF
    and     ecx, 0FFFFh
    jmp     short loc_49D8D1
    ; ---------------------------------------------------------------------------

    loc_49D8CF:                             ; CODE XREF: sub_49D880+45j
    mov     ecx, eax

    loc_49D8D1:                             ; CODE XREF: sub_49D880+29j
                                            ; sub_49D880+32j ...
    mov     dx, [edi+16h]
    sub     dx, [esp+arg_8]
    movsx   eax, dx
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, esi
    jg      short loc_49D905
    mov     ax, [edi+18h]
    sub     ax, [esp+arg_C]
    movsx   eax, ax
    cdq
    xor     eax, edx
    sub     eax, edx
    cmp     eax, ecx
    jg      short loc_49D905
    mov     eax, 1
    pop     edi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49D905:                             ; CODE XREF: sub_49D880+64j
                                            ; sub_49D880+79j
    pop     edi
    xor     eax, eax
    pop     esi
    retn    10h
    sub_49D880 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49D910 proc near                    ; CODE XREF: sub_49D580+CAp
                                            ; sub_49E1A0+125p

    var_24= qword ptr -24h
    var_1C= qword ptr -1Ch
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 0Ch
    mov     eax, [esp+0Ch+arg_10]
    push    esi
    mov     esi, [esp+10h+arg_0]
    push    edi
    lea     ecx, [esp+14h+var_C]
    push    eax
    push    ecx
    push    esi
    call    sub_43E2E0
    mov     edx, [esp+14h+arg_14]
    mov     eax, [esp+14h+var_C]
    mov     ecx, [edx]
    mov     edi, [edx+4]
    sub     eax, ecx
    mov     ecx, [esp+14h+var_8]
    sub     ecx, edi
    mov     edi, [edx+8]
    mov     [esp+14h+arg_14], ecx
    mov     ecx, [esp+14h+var_4]
    sub     ecx, edi
    mov     [esp+14h+arg_0], eax
    push    ecx
    push    eax
    mov     [esp+1Ch+arg_10], ecx
    call    sub_4B715A
    fild    [esp+1Ch+arg_10]
    add     esp, 8
    sub     ax, [esi+66h]
    mov     edx, [esp+14h+arg_8]
    sub     esp, 8
    fstp    [esp+1Ch+var_1C]
    fild    [esp+1Ch+arg_0]
    sub     esp, 8
    mov     [edx], ax
    fstp    [esp+24h+var_24]
    call    __hypot
    add     esp, 10h
    call    __ftol
    movsx   ecx, word ptr [esp+14h+arg_14+2]
    sar     eax, 10h
    movsx   eax, ax
    neg     ecx
    push    eax
    push    ecx
    call    sub_4B715A
    mov     edx, [esp+1Ch+arg_C]
    add     esp, 8
    mov     [edx], ax
    pop     edi
    mov     eax, 1
    pop     esi
    add     esp, 0Ch
    retn    18h
    sub_49D910 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49D9C0 proc near                    ; DATA XREF: sub_49E010+4Eo

    var_50= qword ptr -50h
    var_48= qword ptr -48h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    idTo= dword ptr -24h
    var_1F= dword ptr -1Fh
    var_1B= dword ptr -1Bh
    var_17= dword ptr -17h
    var_13= dword ptr -13h
    var_F= dword ptr -0Fh
    var_B= byte ptr -0Bh
    var_A= byte ptr -0Ah
    var_9= word ptr -9
    var_7= word ptr -7
    var_5= word ptr -5
    var_3= word ptr -3
    var_1= byte ptr -1
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 30h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+3Ch+arg_4]
    push    edi
    mov     edi, [esp+40h+arg_0]
    mov     al, [esi+1Bh]
    push    0FFFFFFFFh
    shr     al, 2
    and     al, 3
    lea     ecx, [esp+44h+var_30]
    push    eax
    push    ecx
    push    edi
    call    sub_43E240
    mov     ebx, [esp+40h+arg_C]
    mov     eax, [esp+40h+var_30]
    mov     edx, [ebx]
    mov     ecx, [ebx+4]
    mov     ebp, [ebx+8]
    sub     eax, edx
    mov     edx, [esp+40h+var_2C]
    mov     [esp+40h+arg_0], eax
    sub     edx, ecx
    mov     ecx, [esp+40h+var_28]
    sub     ecx, ebp
    mov     [esp+40h+arg_C], edx
    push    ecx
    push    eax
    mov     [esp+48h+arg_4], ecx
    call    sub_4B715A
    fild    [esp+48h+arg_4]
    add     esp, 8
    mov     [esi+16h], ax
    sub     esp, 8
    fstp    [esp+48h+var_48]
    fild    [esp+48h+arg_0]
    sub     esp, 8
    fstp    [esp+50h+var_50]
    call    __hypot
    add     esp, 10h
    call    __ftol
    movsx   ecx, word ptr [esp+40h+arg_C+2]
    sar     eax, 10h
    movsx   eax, ax
    neg     ecx
    push    eax
    push    ecx
    call    sub_4B715A
    add     esp, 8
    mov     [esi+18h], ax
    mov     dx, [edi+68h]
    mov     ax, [edi+66h]
    push    edx
    push    eax
    push    esi
    push    edi
    call    sub_49D880
    test    eax, eax
    jz      loc_49DB61
    mov     ebp, [esp+40h+arg_8]
    lea     ecx, [esp+40h+var_30]
    push    ebp
    push    ebx
    push    ecx
    push    edi
    push    esi
    call    sub_49C9C0
    test    eax, eax
    jz      loc_49DB61
    mov     edx, TAdynmemStructPtr
    test    byte ptr [edx+2A44h], 1
    jz      loc_49DB52
    lea     eax, [edi+6Ah]
    mov     byte ptr [esp+40h+idTo], 0Dh
    mov     ecx, [eax]
    mov     [esp+40h+idTo+1], ecx
    mov     ecx, [ebx]
    mov     edx, [eax+4]
    mov     [esp+40h+var_17], ecx
    mov     [esp+40h+var_1F], edx
    mov     edx, [ebx+4]
    mov     eax, [eax+8]
    mov     [esp+40h+var_13], edx
    mov     dl, [esi+1Bh]
    mov     [esp+40h+var_1B], eax
    mov     eax, [ebx+8]
    mov     [esp+40h+var_F], eax
    mov     eax, [esi+0Ch]
    shr     dl, 2
    mov     cl, [eax+10Ah]
    and     dl, 3
    mov     [esp+40h+var_B], cl
    xor     ecx, ecx
    cmp     edi, ecx
    mov     [esp+40h+var_1], dl
    jnz     short loc_49DAF6
    mov     [esp+40h+var_3], cx
    jmp     short loc_49DB02
    ; ---------------------------------------------------------------------------

    loc_49DAF6:                             ; CODE XREF: sub_49D9C0+12Dj
    mov     dx, [edi+0A8h]
    mov     [esp+40h+var_3], dx

    loc_49DB02:                             ; CODE XREF: sub_49D9C0+134j
    cmp     ebp, ecx
    jz      short loc_49DB0D
    mov     cx, [ebp+0A8h]

    loc_49DB0D:                             ; CODE XREF: sub_49D9C0+144j
    mov     dx, [esi+16h]
    mov     [esp+40h+var_5], cx
    mov     cx, [esi+18h]
    mov     [esp+40h+var_9], dx
    mov     [esp+40h+var_7], cx
    mov     edx, [eax+111h]
    mov     al, [esp+40h+var_A]
    mov     ecx, [edi+96h]
    shr     edx, 1Eh
    xor     dl, al
    push    24h                             ; idFrom
    and     dl, 1
    xor     al, dl
    mov     [esp+44h+var_A], al
    mov     edx, [ecx+4]
    lea     eax, [esp+44h+idTo]
    push    eax                             ; idTo
    push    edx                             ; PlayerID
    call    sub_451DF0

    loc_49DB52:                             ; CODE XREF: sub_49D9C0+D9j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49DB61:                             ; CODE XREF: sub_49D9C0+ACj
                                            ; sub_49D9C0+C6j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 30h
    retn    10h
    sub_49D9C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49DB70 proc near                    ; DATA XREF: sub_49E010+28o

    var_50= qword ptr -50h
    var_48= qword ptr -48h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    idTo= dword ptr -24h
    var_1F= dword ptr -1Fh
    var_1B= dword ptr -1Bh
    var_17= dword ptr -17h
    var_13= dword ptr -13h
    var_F= dword ptr -0Fh
    var_B= byte ptr -0Bh
    var_A= byte ptr -0Ah
    var_9= word ptr -9
    var_7= word ptr -7
    var_5= word ptr -5
    var_3= word ptr -3
    var_1= byte ptr -1
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 30h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+3Ch+arg_4]
    push    edi
    mov     eax, [esi+8]
    test    eax, eax
    jz      loc_49DD4A
    mov     al, [esi+1Bh]
    mov     ebx, [esp+40h+arg_0]
    shr     al, 2
    and     al, 3
    push    0FFFFFFFFh
    lea     ecx, [esp+44h+var_30]
    push    eax
    push    ecx
    push    ebx
    call    sub_43E240
    mov     edi, [esp+40h+arg_C]
    mov     edx, [esp+40h+var_2C]
    mov     eax, [esp+40h+var_30]
    mov     ebp, [edi+4]
    mov     ecx, [edi]
    sub     edx, ebp
    sub     eax, ecx
    mov     ecx, [esp+40h+var_28]
    mov     [esp+40h+arg_C], edx
    mov     edx, [edi+8]
    mov     [esp+40h+arg_0], eax
    sub     ecx, edx
    push    ecx
    push    eax
    mov     [esp+48h+arg_4], ecx
    call    sub_4B715A
    fild    [esp+48h+arg_4]
    add     esp, 8
    mov     [esi+16h], ax
    sub     esp, 8
    fstp    [esp+48h+var_48]
    fild    [esp+48h+arg_0]
    sub     esp, 8
    fstp    [esp+50h+var_50]
    call    __hypot
    add     esp, 10h
    call    __ftol
    movsx   ecx, word ptr [esp+40h+arg_C+2]
    sar     eax, 10h
    movsx   eax, ax
    neg     ecx
    push    eax
    push    ecx
    call    sub_4B715A
    mov     edx, [esi+0Ch]
    mov     [esi+18h], ax
    add     esp, 8
    mov     eax, [edx+111h]
    shr     eax, 1Eh
    test    al, 1
    jz      short loc_49DC42
    mov     cl, [esi+1Bh]
    shr     cl, 2
    and     cl, 3
    push    ecx
    push    ebx
    call    sub_49D120
    test    eax, eax
    jnz     short loc_49DC44
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49DC42:                             ; CODE XREF: sub_49DB70+B2j
    xor     eax, eax

    loc_49DC44:                             ; CODE XREF: sub_49DB70+C6j
    mov     ebp, [esp+40h+arg_8]
    push    eax
    push    ebp
    lea     edx, [esp+48h+var_30]
    push    edi
    push    edx
    push    ebx
    push    esi
    call    sub_49CC20
    test    eax, eax
    jz      loc_49DD4A
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 1
    jz      loc_49DD2E
    mov     edx, [esp+40h+var_2C]
    mov     eax, [esp+40h+var_28]
    mov     ecx, [esp+40h+var_30]
    mov     [esp+40h+var_1F], edx
    mov     edx, [edi+4]
    mov     [esp+40h+var_1B], eax
    mov     eax, [edi+8]
    mov     [esp+40h+var_13], edx
    mov     dl, [esi+1Bh]
    mov     [esp+40h+idTo+1], ecx
    mov     ecx, [edi]
    mov     [esp+40h+var_F], eax
    mov     eax, [esi+0Ch]
    mov     byte ptr [esp+40h+idTo], 0Dh
    shr     dl, 2
    mov     [esp+40h+var_17], ecx
    mov     cl, [eax+10Ah]
    xor     edi, edi
    and     dl, 3
    cmp     ebx, edi
    mov     [esp+40h+var_B], cl
    mov     [esp+40h+var_1], dl
    jnz     short loc_49DCC9
    mov     [esp+40h+var_3], di
    jmp     short loc_49DCD5
    ; ---------------------------------------------------------------------------

    loc_49DCC9:                             ; CODE XREF: sub_49DB70+150j
    mov     cx, [ebx+0A8h]
    mov     [esp+40h+var_3], cx

    loc_49DCD5:                             ; CODE XREF: sub_49DB70+157j
    cmp     ebp, edi
    jnz     short loc_49DCE0
    mov     [esp+40h+var_5], di
    jmp     short loc_49DCEC
    ; ---------------------------------------------------------------------------

    loc_49DCE0:                             ; CODE XREF: sub_49DB70+167j
    mov     dx, [ebp+0A8h]
    mov     [esp+40h+var_5], dx

    loc_49DCEC:                             ; CODE XREF: sub_49DB70+16Ej
    mov     cx, [esi+16h]
    mov     dx, [esi+18h]
    mov     [esp+40h+var_9], cx
    mov     [esp+40h+var_7], dx
    mov     ecx, [eax+111h]
    mov     al, [esp+40h+var_A]
    shr     ecx, 1Eh
    xor     cl, al
    lea     edx, [esp+40h+idTo]
    and     cl, 1
    push    24h                             ; idFrom
    xor     al, cl
    push    edx                             ; idTo
    mov     [esp+48h+var_A], al
    mov     eax, [ebx+96h]
    mov     ecx, [eax+4]
    push    ecx                             ; PlayerID
    call    sub_451DF0
    jmp     short loc_49DD30
    ; ---------------------------------------------------------------------------

    loc_49DD2E:                             ; CODE XREF: sub_49DB70+FBj
    xor     edi, edi

    loc_49DD30:                             ; CODE XREF: sub_49DB70+1BCj
    mov     al, [esi+1Bh]
    mov     [esi+8], edi
    and     al, 0FEh
    mov     [esi+1Bh], al
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49DD4A:                             ; CODE XREF: sub_49DB70+10j
                                            ; sub_49DB70+E9j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 30h
    retn    10h
    sub_49DB70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49DD60 proc near                    ; DATA XREF: sub_49E010+44o

    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    idTo= dword ptr -24h
    var_1F= dword ptr -1Fh
    var_1B= dword ptr -1Bh
    var_17= dword ptr -17h
    var_13= dword ptr -13h
    var_F= dword ptr -0Fh
    var_B= byte ptr -0Bh
    var_A= byte ptr -0Ah
    var_9= word ptr -9
    var_7= word ptr -7
    var_5= word ptr -5
    var_3= word ptr -3
    var_1= byte ptr -1
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 30h
    lea     ecx, [esp+30h+var_30]
    push    ebx
    mov     ebx, [esp+34h+arg_4]
    push    ebp
    push    esi
    mov     al, [ebx+1Bh]
    push    edi
    mov     edi, [esp+40h+arg_0]
    push    0FFFFFFFFh
    shr     al, 2
    and     al, 3
    push    eax
    push    ecx
    push    edi
    call    sub_43E240
    mov     ecx, TAdynmemStructPtr
    xor     ebp, ebp
    xor     esi, esi
    mov     eax, [ecx+141F3h]
    cmp     eax, 12Ch
    jge     short loc_49DDC5
    mov     esi, [ecx+141F7h]
    lea     edx, [eax+eax*2]
    lea     edx, [edx+edx*8]
    shl     edx, 2
    sub     edx, eax
    add     esi, edx
    inc     eax
    mov     [ecx+141F3h], eax
    and     word ptr [esi+69h], 0FFFDh
    mov     [esi+4Eh], ebp
    mov     ecx, TAdynmemStructPtr

    loc_49DDC5:                             ; CODE XREF: sub_49DD60+3Aj
    cmp     esi, ebp
    jz      loc_49DF02
    mov     eax, [ecx+38A47h]
    mov     edx, [ebx+0Ch]
    push    edi
    push    eax
    lea     ecx, [esp+48h+var_30]
    push    ebp
    push    ecx
    push    edx
    push    esi
    call    sub_49C740
    mov     ax, [edi+66h]
    mov     [esi+3Ah], ebp
    mov     [esi+36h], ax
    mov     [esi+20h], ebp
    mov     ecx, [edi]
    mov     edx, [ecx+20h]
    push    edx
    push    eax
    call    sub_4B70EF
    neg     eax
    mov     [esi+1Ch], eax
    mov     ecx, [edi]
    mov     ax, [esi+36h]
    add     esp, 8
    mov     edx, [ecx+20h]
    push    edx
    push    eax
    call    sub_4B7123
    neg     eax
    mov     [esi+24h], eax
    mov     ecx, TAdynmemStructPtr
    add     esp, 8
    test    byte ptr [ecx+2A44h], 1
    jz      loc_49DEF3
    mov     edx, [esp+40h+var_30]
    mov     eax, [esp+40h+var_2C]
    mov     ecx, [esp+40h+var_28]
    mov     [esp+40h+idTo+1], edx
    mov     edx, [esp+40h+arg_C]
    mov     [esp+40h+var_1F], eax
    mov     [esp+40h+var_1B], ecx
    mov     byte ptr [esp+40h+idTo], 0Dh
    mov     eax, [edx]
    mov     [esp+40h+var_17], eax
    mov     eax, [ebx+0Ch]
    mov     ecx, [edx+4]
    mov     [esp+40h+var_13], ecx
    mov     edx, [edx+8]
    mov     [esp+40h+var_F], edx
    mov     dl, [ebx+1Bh]
    mov     cl, [eax+10Ah]
    shr     dl, 2
    and     dl, 3
    cmp     edi, ebp
    mov     [esp+40h+var_B], cl
    mov     [esp+40h+var_1], dl
    jnz     short loc_49DE8C
    mov     [esp+40h+var_3], bp
    jmp     short loc_49DE98
    ; ---------------------------------------------------------------------------

    loc_49DE8C:                             ; CODE XREF: sub_49DD60+123j
    mov     cx, [edi+0A8h]
    mov     [esp+40h+var_3], cx

    loc_49DE98:                             ; CODE XREF: sub_49DD60+12Aj
    mov     ecx, [esp+40h+arg_8]
    cmp     ecx, ebp
    jnz     short loc_49DEA7
    mov     [esp+40h+var_5], bp
    jmp     short loc_49DEB3
    ; ---------------------------------------------------------------------------

    loc_49DEA7:                             ; CODE XREF: sub_49DD60+13Ej
    mov     dx, [ecx+0A8h]
    mov     [esp+40h+var_5], dx

    loc_49DEB3:                             ; CODE XREF: sub_49DD60+145j
    mov     cx, [ebx+16h]
    mov     dx, [ebx+18h]
    mov     [esp+40h+var_9], cx
    mov     [esp+40h+var_7], dx
    mov     ecx, [eax+111h]
    mov     al, [esp+40h+var_A]
    shr     ecx, 1Eh
    xor     cl, al
    lea     edx, [esp+40h+idTo]
    and     cl, 1
    push    24h                             ; idFrom
    xor     al, cl
    push    edx                             ; idTo
    mov     [esp+48h+var_A], al
    mov     eax, [edi+96h]
    mov     ecx, [eax+4]
    push    ecx                             ; PlayerID
    call    sub_451DF0

    loc_49DEF3:                             ; CODE XREF: sub_49DD60+CCj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49DF02:                             ; CODE XREF: sub_49DD60+67j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 30h
    retn    10h
    sub_49DD60 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49DF10 proc near                    ; CODE XREF: sub_437DE0+264p

    idTo= dword ptr -24h
    var_1F= dword ptr -1Fh
    var_1B= dword ptr -1Bh
    var_17= dword ptr -17h
    var_13= dword ptr -13h
    var_F= dword ptr -0Fh
    var_B= byte ptr -0Bh
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     ecx, TAdynmemStructPtr
    sub     esp, 24h
    mov     eax, [ecx+141F3h]
    push    ebx
    push    esi
    xor     esi, esi
    cmp     eax, 12Ch
    push    edi
    jge     short loc_49DF58
    mov     esi, [ecx+141F7h]
    lea     edx, [eax+eax*2]
    lea     edx, [edx+edx*8]
    shl     edx, 2
    sub     edx, eax
    add     esi, edx
    inc     eax
    mov     [ecx+141F3h], eax
    and     word ptr [esi+69h], 0FFFDh
    mov     dword ptr [esi+4Eh], 0
    mov     ecx, TAdynmemStructPtr

    loc_49DF58:                             ; CODE XREF: sub_49DF10+19j
    test    esi, esi
    jnz     short loc_49DF67
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 24h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49DF67:                             ; CODE XREF: sub_49DF10+4Aj
    mov     eax, [ecx+38A47h]
    mov     edi, [esp+30h+arg_4]
    mov     ebx, [esp+30h+arg_0]
    push    0
    push    eax
    push    0
    push    edi
    push    ebx
    push    esi
    call    sub_49C740
    add     esi, 1Ch
    mov     eax, [esp+30h+arg_8]
    mov     ecx, eax
    mov     edx, [ecx]
    mov     [esi], edx
    mov     edx, [ecx+4]
    mov     [esi+4], edx
    mov     ecx, [ecx+8]
    mov     [esi+8], ecx
    mov     ecx, [esp+30h+arg_C]
    test    ecx, ecx
    jz      short loc_49DFFB
    mov     edx, TAdynmemStructPtr
    mov     bl, [ebx+10Ah]
    test    byte ptr [edx+2A44h], 1
    jz      short loc_49DFFB
    mov     ecx, [edi]
    mov     edx, [edi+4]
    mov     [esp+30h+idTo+1], ecx
    mov     ecx, [edi+8]
    mov     [esp+30h+var_1F], edx
    mov     edx, [eax]
    mov     [esp+30h+var_1B], ecx
    mov     ecx, [eax+4]
    mov     [esp+30h+var_17], edx
    mov     edx, [eax+8]
    lea     eax, [esp+30h+idTo]
    push    24h                             ; idFrom
    push    eax                             ; idTo
    mov     byte ptr [esp+38h+idTo], 0Dh
    mov     [esp+38h+var_13], ecx
    mov     [esp+38h+var_F], edx
    mov     [esp+38h+var_B], bl
    call    sub_44FDB0
    push    eax                             ; PlayerID
    call    sub_451DF0

    loc_49DFFB:                             ; CODE XREF: sub_49DF10+91j
                                            ; sub_49DF10+A6j
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    add     esp, 24h
    retn    10h
    sub_49DF10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49E010 proc near                    ; CODE XREF: sub_42E440+ED4p
                                            ; sub_42E440+EEEp

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    mov     eax, [ecx+111h]
    mov     edx, eax
    shr     edx, 13h
    test    dl, 1
    jz      short loc_49E02E
    mov     dword ptr [ecx+60h], offset sub_49D580
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49E02E:                             ; CODE XREF: sub_49E010+12j
    mov     edx, eax
    shr     edx, 4
    test    dl, 1
    jz      short loc_49E042
    mov     dword ptr [ecx+60h], offset sub_49DB70
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49E042:                             ; CODE XREF: sub_49E010+26j
    test    al, 1
    jnz     short loc_49E05E
    test    eax, 100000h
    jnz     short loc_49E05E
    shr     eax, 8
    test    al, 1
    jz      short locret_49E065
    mov     dword ptr [ecx+60h], offset sub_49DD60
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49E05E:                             ; CODE XREF: sub_49E010+34j
                                            ; sub_49E010+3Bj
    mov     dword ptr [ecx+60h], offset sub_49D9C0

    locret_49E065:                          ; CODE XREF: sub_49E010+42j
    retn    4
    sub_49E010 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49E070 proc near                    ; CODE XREF: sub_485E90+74p
                                            ; sub_485F50+15Cp ...

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 20h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+30h+arg_0]
    xor     ebp, ebp
    mov     [esp+30h+var_1C], ebp
    mov     byte ptr [esp+30h+var_20], 0
    lea     esi, [edi+1Fh]

    loc_49E089:                             ; CODE XREF: sub_49E070+D5j
    mov     al, byte ptr [esp+30h+var_20]
    mov     cl, [esi]
    and     al, 3
    and     cl, 0F2h
    shl     al, 2
    or      al, cl
    mov     word ptr [esi-7], 0
    mov     [esi], al
    mov     edx, [edi+92h]
    push    0FFFFFFFFh
    mov     ecx, [edx+ebp+1EEh]
    mov     [esi-0Fh], ecx
    mov     edx, [edi+92h]
    mov     ecx, [edx+ebp+1EEh]
    xor     edx, edx
    mov     bl, [ecx+10Ah]
    mov     byte ptr [esi-1], 0
    test    bl, bl
    setnz   dl
    mov     ebx, [esp+34h+var_20]
    and     dl, 1
    or      dl, 8
    and     al, 0FDh
    shl     dl, 1
    or      dl, al
    lea     eax, [esp+34h+var_18]
    push    ebx
    push    eax
    push    edi
    mov     [esi], dl
    call    sub_43E240
    lea     ecx, [esp+30h+var_C]
    push    ebx
    push    ecx
    push    edi
    call    sub_43E2E0
    mov     ebx, [esp+30h+var_4]
    mov     edx, [esp+30h+var_10]
    sub     edx, ebx
    mov     [esp+30h+arg_0], edx
    fild    [esp+30h+arg_0]
    fmul    ds:dbl_4FDA98
    call    __ftol
    mov     ecx, [esi-0Fh]
    mov     [esi-0Bh], eax
    xor     eax, eax
    mov     ax, [ecx+0E4h]
    mov     ecx, [esp+30h+var_1C]
    cmp     eax, ecx
    jle     short loc_49E133
    mov     [esp+30h+var_1C], eax

    loc_49E133:                             ; CODE XREF: sub_49E070+BDj
    mov     al, byte ptr [esp+30h+var_20]
    add     esi, 1Ch
    inc     al
    add     ebp, 4
    cmp     al, 3
    mov     byte ptr [esp+30h+var_20], al
    jb      loc_49E089
    mov     eax, [esp+30h+var_1C]
    push    0
    push    0
    push    0
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     ecx, [eax+eax*4]
    mov     eax, 88888889h
    shl     ecx, 3
    imul    ecx
    add     edx, ecx
    mov     ecx, [edi+9Ah]
    sar     edx, 4
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    push    edx
    push    1
    push    0
    push    0
    push    offset aSetmaxreloadti          ; "SetMaxReloadTime"
    call    sub_4B0A70
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn    4
    sub_49E070 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49E1A0 proc near                    ; CODE XREF: sub_48AD30+AAp

    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4

    sub     esp, 30h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+40h+arg_0]
    mov     byte ptr [esp+40h+var_28], 0
    mov     [esp+40h+var_30], 0
    lea     esi, [edi+1Fh]

    loc_49E1BB:                             ; CODE XREF: sub_49E1A0+3B9j
    mov     al, [esi]
    mov     ebx, [esi-0Fh]
    test    al, 2
    jz      loc_49E541
    mov     ax, [esi-7]
    test    ax, ax
    jbe     short loc_49E1D6
    dec     eax
    mov     [esi-7], ax

    loc_49E1D6:                             ; CODE XREF: sub_49E1A0+2Fj
    mov     eax, [esp+40h+var_30]
    lea     ecx, [esp+40h+var_18]
    push    eax
    push    ecx
    push    edi
    call    sub_48A1E0
    test    eax, eax
    jnz     short loc_49E1F2
    and     byte ptr [esi], 0FEh
    jmp     loc_49E541
    ; ---------------------------------------------------------------------------

    loc_49E1F2:                             ; CODE XREF: sub_49E1A0+48j
    mov     eax, [ebx+60h]
    test    eax, eax
    jz      loc_49E541
    mov     eax, [ebx+111h]
    mov     edx, eax
    shr     edx, 13h
    test    dl, 1
    jz      loc_49E33D
    mov     al, [esi]
    test    al, 1
    jnz     loc_49E3AE
    mov     ebp, [esi-0Fh]
    mov     ecx, [ebp+111h]
    shr     ecx, 1
    test    cl, 1
    jz      short loc_49E2A5
    shr     al, 2
    and     al, 3
    lea     edx, [esp+40h+var_C]
    push    eax
    push    edx
    push    edi
    call    sub_43E2E0
    lea     eax, [esp+40h+var_24]
    lea     ecx, [esp+40h+var_1C]
    push    eax
    lea     edx, [esp+44h+var_20]
    push    ecx
    lea     eax, [esp+48h+var_18]
    push    edx
    lea     ecx, [esp+4Ch+var_C]
    push    eax
    push    ecx
    call    sub_49E570
    mov     edx, [esp+40h+var_24]
    mov     eax, [esp+40h+var_20]
    push    edx
    push    eax
    call    sub_4B715A
    sub     ax, [edi+66h]
    add     esp, 8
    mov     [esp+40h+var_2C], eax
    mov     ecx, [ebp+0C8h]
    mov     edx, [ebp+68h]
    mov     eax, [esp+40h+var_24]
    push    ecx
    mov     ecx, [esp+44h+var_1C]
    push    edx
    mov     edx, [esp+48h+var_20]
    push    eax
    push    ecx
    push    edx
    call    sub_49A890
    mov     ecx, eax
    xor     eax, eax
    cmp     cx, 8000h
    mov     [esp+40h+arg_0], ecx
    setnz   al
    jmp     short loc_49E2D2
    ; ---------------------------------------------------------------------------

    loc_49E2A5:                             ; CODE XREF: sub_49E1A0+89j
    test    byte ptr [ebp+111h], 1
    jz      short loc_49E2CC
    shr     al, 2
    lea     ecx, [esp+40h+var_18]
    and     al, 3
    push    ecx
    push    eax
    lea     edx, [esp+48h+arg_0]
    lea     eax, [esp+48h+var_2C]
    push    edx
    push    eax
    push    ebp
    push    edi
    call    sub_49D910
    jmp     short loc_49E2CE
    ; ---------------------------------------------------------------------------

    loc_49E2CC:                             ; CODE XREF: sub_49E1A0+10Cj
    xor     eax, eax

    loc_49E2CE:                             ; CODE XREF: sub_49E1A0+12Aj
    mov     ecx, [esp+40h+arg_0]

    loc_49E2D2:                             ; CODE XREF: sub_49E1A0+103j
    test    eax, eax
    jz      loc_49E3AE
    mov     eax, [esp+40h+var_2C]
    mov     dl, [esi]
    mov     [esi-3], cx
    mov     [esi-5], ax
    push    0
    and     ecx, 0FFFFh
    shr     edx, 2
    push    0
    and     eax, 0FFFFh
    push    ecx
    and     edx, 3
    push    eax
    mov     dword ptr [esi-13h], 0
    mov     eax, dword_509688[edx*4]
    push    2
    lea     ecx, [esi-17h]
    push    0
    push    ecx
    mov     ecx, [edi+9Ah]
    push    eax
    call    sub_4B0A70
    push    0
    push    0
    mov     ecx, [esp+48h+arg_0]
    mov     edx, [esp+48h+var_2C]
    and     ecx, 0FFFFh
    and     edx, 0FFFFh
    push    ecx
    push    edx
    jmp     short loc_49E393
    ; ---------------------------------------------------------------------------

    loc_49E33D:                             ; CODE XREF: sub_49E1A0+6Bj
    mov     edx, eax
    shr     edx, 4
    test    dl, 1
    jz      short loc_49E3AE
    test    eax, 10000000h
    jz      short loc_49E355
    mov     al, [esi-1]
    test    al, al
    jz      short loc_49E3AE

    loc_49E355:                             ; CODE XREF: sub_49E1A0+1ACj
    mov     al, [esi]
    test    al, 1
    jnz     short loc_49E3AE
    push    0
    push    0
    shr     eax, 2
    push    0
    and     eax, 3
    push    0
    mov     dword ptr [esi-13h], 0
    mov     edx, dword_509688[eax*4]
    push    2
    lea     ecx, [esi-17h]
    push    0
    push    ecx
    mov     ecx, [edi+9Ah]
    push    edx
    call    sub_4B0A70
    push    0
    push    0
    push    0
    push    0

    loc_49E393:                             ; CODE XREF: sub_49E1A0+19Bj
    mov     al, [esi]
    push    2
    shr     eax, 2
    and     eax, 3
    mov     ecx, dword_509688[eax*4]
    push    ecx
    push    edi
    call    sub_456200
    or      byte ptr [esi], 1

    loc_49E3AE:                             ; CODE XREF: sub_49E1A0+75j
                                            ; sub_49E1A0+134j ...
    cmp     word ptr [esi-7], 0
    jnz     loc_49E541
    mov     edx, [esp+40h+var_28]
    lea     eax, [esp+40h+var_18]
    push    edx
    lea     ecx, [edi+6Ah]
    push    eax
    push    ecx
    push    edi
    call    sub_49AA80
    test    eax, eax
    jz      loc_49E53A
    mov     eax, [ebx+111h]
    xor     edx, edx
    shr     eax, 1Ch
    test    al, 1
    jz      short loc_49E3ED
    mov     al, [esi-1]
    test    al, al
    jz      short loc_49E41E
    jmp     short loc_49E419
    ; ---------------------------------------------------------------------------

    loc_49E3ED:                             ; CODE XREF: sub_49E1A0+242j
    mov     ecx, [edi+0ECh]
    fld     dword ptr [ecx+8Ch]
    fcomp   dword ptr [ebx+0C0h]
    fnstsw  ax
    test    ah, 1
    jnz     short loc_49E41E
    fld     dword ptr [ecx+98h]
    fcomp   dword ptr [ebx+0C4h]
    fnstsw  ax
    test    ah, 1
    jnz     short loc_49E41E

    loc_49E419:                             ; CODE XREF: sub_49E1A0+24Bj
    mov     edx, 1

    loc_49E41E:                             ; CODE XREF: sub_49E1A0+249j
                                            ; sub_49E1A0+264j ...
    test    edx, edx
    jz      loc_49E541
    mov     ecx, [esp+40h+var_30]
    push    ecx
    push    edi
    call    sub_48A190
    lea     edx, [esp+40h+var_18]
    push    edx
    push    eax
    lea     eax, [esi-1Bh]
    push    eax
    push    edi
    call    dword ptr [ebx+60h]
    test    eax, eax
    jz      loc_49E541
    mov     ecx, [ebx+111h]
    shr     ecx, 1Ch
    test    cl, 1
    jz      short loc_49E468
    mov     cl, [esi-1]
    push    edi
    dec     cl
    mov     [esi-1], cl
    call    sub_41C150
    jmp     loc_49E4F2
    ; ---------------------------------------------------------------------------

    loc_49E468:                             ; CODE XREF: sub_49E1A0+2B3j
    xor     ecx, ecx
    mov     eax, 66666667h
    mov     cx, [edi+0B8h]
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ecx, edx
    cmp     ecx, 5
    jle     short loc_49E48D
    mov     ecx, 5

    loc_49E48D:                             ; CODE XREF: sub_49E1A0+2E6j
    movsx   eax, word ptr [edi+108h]
    mov     ebp, [edi+92h]
    xor     edx, edx
    lea     eax, [eax+eax*4]
    lea     ecx, [ecx+ecx*2]
    shl     eax, 2
    div     dword ptr [ebp+1FAh]
    mov     ebp, 78h
    shl     ecx, 1
    mov     edx, ecx
    mov     ecx, 64h
    sub     ecx, edx
    sub     ebp, eax
    xor     eax, eax
    mov     ax, [ebx+0E4h]
    imul    ecx, eax
    mov     eax, 51EB851Fh
    imul    ecx
    sar     edx, 5
    mov     ecx, edx
    mov     eax, 51EB851Fh
    shr     ecx, 1Fh
    add     edx, ecx
    imul    ebp, edx
    imul    ebp
    sar     edx, 5
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     [esi-7], dx

    loc_49E4F2:                             ; CODE XREF: sub_49E1A0+2C3j
    mov     eax, [ebx+111h]
    shr     eax, 1Ah
    and     al, 1
    neg     al
    sbb     eax, eax
    and     eax, 400h
    add     eax, 400h
    or      [edi+0BAh], ax
    mov     eax, [ebx+111h]
    test    eax, 10000000h
    jnz     short loc_49E541
    mov     ecx, [ebx+0C4h]
    mov     edx, [ebx+0C0h]
    push    ecx
    push    edx
    lea     ecx, [edi+0BCh]
    call    sub_4012A0
    jmp     short loc_49E541
    ; ---------------------------------------------------------------------------

    loc_49E53A:                             ; CODE XREF: sub_49E1A0+22Fj
    or      byte ptr [edi+0BBh], 10h

    loc_49E541:                             ; CODE XREF: sub_49E1A0+22j
                                            ; sub_49E1A0+4Dj ...
    mov     al, byte ptr [esp+40h+var_28]
    mov     ebx, [esp+40h+var_30]
    inc     al
    inc     ebx
    add     esi, 1Ch
    cmp     al, 3
    mov     byte ptr [esp+40h+var_28], al
    mov     [esp+40h+var_30], ebx
    jb      loc_49E1BB
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    4
    sub_49E1A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49E570 proc near                    ; CODE XREF: sub_49E1A0+B5p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    push    esi
    mov     edx, [eax]
    mov     esi, [ecx]
    sub     edx, esi
    mov     esi, [esp+4+arg_8]
    mov     [esi], edx
    mov     edx, [eax+4]
    mov     esi, [ecx+4]
    sub     edx, esi
    mov     esi, [esp+4+arg_C]
    mov     [esi], edx
    mov     eax, [eax+8]
    mov     edx, [ecx+8]
    mov     ecx, [esp+4+arg_10]
    sub     eax, edx
    pop     esi
    mov     [ecx], eax
    retn    14h
    sub_49E570 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49E5B0(char *)
    sub_49E5B0 proc near                    ; CODE XREF: sub_4224B0+873p
                                            ; sub_42BF40+EBBp ...

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    push    edi
    test    ebx, ebx
    jz      short loc_49E603
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_49E603
    xor     esi, esi

    loc_49E5CB:                             ; CODE XREF: sub_49E5B0+41j
    mov     eax, TAdynmemStructPtr
    push    ebx                             ; char *
    lea     edi, [eax+esi+2CF3h]
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_49E5FB
    add     esi, 115h
    cmp     esi, 11500h
    jl      short loc_49E5CB
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49E5FB:                             ; CODE XREF: sub_49E5B0+33j
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49E603:                             ; CODE XREF: sub_49E5B0+9j
                                            ; sub_49E5B0+17j
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    4
    sub_49E5B0 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, offset dword_51F310
    call    sub_4C2EA0
    push    offset unknown_libname_46
    call    _atexit
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_46:                     ; DATA XREF: .text:0049E61Ao
    mov     ecx, offset dword_51F310
    jmp     sub_4C2EB0
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    push    edi
    push    offset aDebug_fil               ; "DEBUG.FIL"
    call    sub_4BB2C0
    mov     esi, eax
    test    esi, esi
    jnz     short loc_49E65E
    push    offset aDebug_fil               ; "DEBUG.FIL"
    call    sub_4BB6A0
    mov     esi, eax

    loc_49E65E:                             ; CODE XREF: .text:0049E650j
    mov     edx, [esp+0Ch]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    push    esi
    call    sub_4BB5D0
    pop     edi
    pop     esi
    retn    4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_49E680 proc near                    ; CODE XREF: sub_49E700+E4p

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_4= dword ptr -4
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset stru_4FDAD0
    push    offset __except_handler3
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    add     esp, 0FFFFFFF4h
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_18], esp
    xor     eax, eax
    mov     [ebp+var_1C], eax
    mov     [ebp+var_4], eax
    push    eax
    push    edx
    div     [ebp+var_1C]
    pop     edx
    pop     eax
    jmp     short loc_49E6D0
    ; ---------------------------------------------------------------------------

    loc_49E6B7:                             ; DATA XREF: .rdata:004FDAD0o
    mov     eax, [ebp+arg_0]
    push    eax
    mov     ecx, [ebp+var_14]
    push    ecx
    call    sub_4D8E60
    add     esp, 8
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_49E6CD:                             ; DATA XREF: .rdata:004FDAD0o
    mov     esp, [ebp+var_18]

    loc_49E6D0:                             ; CODE XREF: sub_49E680+35j
    mov     [ebp+var_4], 0FFFFFFFFh
    mov     ecx, [ebp+var_10]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    sub_49E680 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49E6F0 proc near                    ; CODE XREF: sub_495A30+CDp
    push    offset sub_49E700
    call    sub_4D8E50
    add     esp, 4
    retn
    sub_49E6F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49E700 proc near                    ; DATA XREF: sub_49E6F0o
                                            ; sub_49E830+14o

    NumberOfBytesWritten= dword ptr -3ECh
    FileName= byte ptr -3E8h

    sub     esp, 3ECh
    lea     eax, [esp+3ECh+FileName]
    push    ebx
    push    esi
    push    edi
    push    3E8h                            ; nSize
    push    eax                             ; lpFilename
    push    0                               ; hModule
    call    ds:GetModuleFileNameA
    lea     ecx, [esp+3F8h+FileName]
    push    5Ch                             ; int
    push    ecx                             ; char *
    call    _strrchr
    add     esp, 8
    test    eax, eax
    jz      short loc_49E734
    mov     byte ptr [eax+1], 0
    jmp     short loc_49E75A
    ; ---------------------------------------------------------------------------

    loc_49E734:                             ; CODE XREF: sub_49E700+2Cj
    mov     edi, offset aC_0                ; "C:\\"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+3F8h+FileName]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_49E75A:                             ; CODE XREF: sub_49E700+32j
    mov     edi, offset aErrorlog_txt       ; "ErrorLog.txt"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+3F8h+FileName]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    eax                             ; hTemplateFile
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    push    80h                             ; dwFlagsAndAttributes
    push    4                               ; dwCreationDisposition
    mov     ecx, ebx
    push    eax                             ; lpSecurityAttributes
    push    eax                             ; dwShareMode
    and     ecx, 3
    lea     eax, [esp+40Ch+FileName]
    push    40000000h                       ; dwDesiredAccess
    rep movsb
    push    eax                             ; lpFileName
    call    ds:CreateFileA
    mov     esi, eax
    test    esi, esi
    jz      short loc_49E7DF
    push    2                               ; dwMoveMethod
    push    0                               ; lpDistanceToMoveHigh
    push    0                               ; lDistanceToMove
    push    esi                             ; hFile
    call    ds:SetFilePointer
    lea     ecx, [esp+3F8h+NumberOfBytesWritten]
    push    0                               ; lpOverlapped
    push    ecx                             ; lpNumberOfBytesWritten
    mov     edi, offset aOutOfMemoryYou     ; "Out of memory!\r\nYour hard disk may be f"...
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    ecx                             ; nNumberOfBytesToWrite
    push    offset aOutOfMemoryYou          ; lpBuffer
    push    esi                             ; hFile
    call    ds:WriteFile
    push    esi                             ; hObject
    call    ds:CloseHandle

    loc_49E7DF:                             ; CODE XREF: sub_49E700+A6j
    push    offset aOutOfMemoryHan          ; "Out of memory handler"
    call    sub_49E680
    push    41010h                          ; uType
    push    offset aTotalAnnihilat          ; lpCaption
    push    offset aOutOfMemoryYou          ; lpText
    push    0                               ; hWnd
    call    ds:MessageBoxA
    call    nullsub_22
    push    16h
    call    _raise
    add     esp, 4
    push    3                               ; int
    call    __exit
    ; ---------------------------------------------------------------------------
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 3ECh
    retn
    sub_49E700 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49E830 proc near                    ; CODE XREF: WinMain(x,x,x,x)+3Dp

    hKey= dword ptr -98h
    var_94= dword ptr -94h
    dwType= dword ptr -90h
    var_8C= dword ptr -8Ch
    cbData= dword ptr -88h
    Msg= MSG ptr -84h
    Data= byte ptr -68h
    var_34= dword ptr -34h
    arg_0= dword ptr  4
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 98h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    8
    call    sub_4DA1D0
    add     esp, 4
    push    offset sub_49E700
    call    sub_4D8E50
    mov     al, byte_51F31C
    add     esp, 4
    test    al, 1
    jnz     short loc_49E872
    mov     dl, al
    push    offset nullsub_15               ; void (*)(void)
    or      dl, 1
    mov     byte_51F31C, dl
    call    _atexit
    add     esp, 4

    loc_49E872:                             ; CODE XREF: sub_49E830+28j
    call    sub_41D920
    mov     eax, lpName
    xor     ebx, ebx
    push    eax                             ; lpName
    push    ebx                             ; bInheritHandle
    push    1F0003h                         ; dwDesiredAccess
    call    ds:OpenSemaphoreA
    cmp     eax, ebx
    jz      short loc_49E89F
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 98h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49E89F:                             ; CODE XREF: sub_49E830+5Dj
    mov     ecx, lpName
    push    ecx                             ; lpName
    push    1                               ; lMaximumCount
    push    1                               ; lInitialCount
    push    ebx                             ; lpSemaphoreAttributes
    call    ds:CreateSemaphoreA
    push    ebx                             ; time_t *
    call    _time
    add     esp, 4
    push    eax                             ; unsigned int
    call    _srand
    mov     edx, lpName
    mov     eax, [esp+0ACh+arg_8]
    add     esp, 4
    push    edx
    push    eax
    call    sub_49EE30
    test    eax, eax
    jnz     short loc_49E8ED
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 98h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49E8ED:                             ; CODE XREF: sub_49E830+A9j
    push    offset dword_51F320
    call    sub_4B52E0
    mov     ecx, dword_51FB48
    mov     dl, byte ptr word_51F522
    mov     ax, word_51F522
    push    offset dword_51F320
    not     ecx
    xor     dl, cl
    mov     ecx, [esp+0ACh+arg_C]
    and     edx, 1
    mov     dword_51F51A, 280h
    xor     ax, dx
    mov     edx, dword_509718
    or      al, 2
    or      ah, 1
    or      al, 10h
    or      ah, 2
    or      al, 20h
    mov     dword_51F51E, 1E0h
    or      al, 40h
    mov     dword_51F324, ecx
    or      al, 80h
    mov     dword_51F328, edx
    mov     word_51F522, ax
    mov     eax, [esp+0ACh+arg_0]
    mov     dword_51F320, eax
    mov     eax, lpName
    mov     dword_51F32C, eax
    mov     dword_51F334, ebx
    call    sub_4B5980
    cmp     eax, ebx
    jnz     short loc_49E98F
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 98h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_49E98F:                             ; CODE XREF: sub_49E830+14Ej
    push    1Eh
    call    sub_4B62D0
    call    sub_41D4C0
    push    offset aWargame                 ; "Wargame"
    call    sub_4B62C0
    mov     ecx, TAdynmemStructPtr
    mov     edi, offset byte_51FB50
    mov     dword ptr [ecx+0Ch], offset dword_51F320
    mov     edx, TAdynmemStructPtr
    mov     byte ptr [edx+1], 3
    mov     eax, TAdynmemStructPtr
    mov     byte ptr [eax+2], 1
    mov     ecx, TAdynmemStructPtr
    xor     eax, eax
    mov     byte ptr [ecx+3], 1
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_49EA29
    lea     edx, [esp+0A8h+var_8C]
    mov     [esp+0A8h+var_8C], 40h
    push    edx                             ; lpcbData
    push    offset byte_51FB50              ; lpData
    push    offset aLanguage                ; lpValueName
    call    sub_42F980
    cmp     byte_51FB50, bl
    jnz     short loc_49EA29
    mov     edi, offset aEnglish            ; "english"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, offset byte_51FB50
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_49EA29:                             ; CODE XREF: sub_49E830+1AEj
                                            ; sub_49E830+1D2j
    push    offset byte_51FB50
    push    offset aGamedataTransl          ; "gamedata\\translate.tdf"
    call    sub_4C54F0
    push    294h                            ; int
    call    sub_4B4F10
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_49EA52
    mov     ecx, eax
    call    sub_4CEE50
    jmp     short loc_49EA54
    ; ---------------------------------------------------------------------------

    loc_49EA52:                             ; CODE XREF: sub_49E830+217j
    xor     eax, eax

    loc_49EA54:                             ; CODE XREF: sub_49E830+220j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+10h], eax
    call    nullsub_7
    call    sub_491200
    lea     edx, [esp+0A8h+hKey]
    mov     esi, 32h
    push    edx                             ; phkResult
    push    0F003Fh                         ; samDesired
    push    ebx                             ; ulOptions
    push    offset aSoftwareClasse          ; lpSubKey
    push    80000002h                       ; hKey
    mov     [esp+0BCh+cbData], esi
    mov     [esp+0BCh+hKey], ebx
    mov     [esp+0BCh+var_94], esi
    call    ds:RegOpenKeyExA
    test    eax, eax
    jnz     loc_49EB74
    lea     eax, [esp+0A8h+cbData]
    lea     ecx, [esp+0A8h+Data]
    push    eax                             ; lpcbData
    mov     eax, [esp+0ACh+hKey]
    lea     edx, [esp+0ACh+dwType]
    push    ecx                             ; lpData
    push    edx                             ; lpType
    push    ebx                             ; lpReserved
    push    ebx                             ; lpValueName
    push    eax                             ; hKey
    call    ds:RegQueryValueExA
    test    eax, eax
    jnz     short loc_49EAD6
    mov     ecx, [esp+0A8h+dwType]
    mov     edx, [esp+0A8h+hKey]
    push    1                               ; cbData
    push    offset Data                     ; lpData
    push    ecx                             ; dwType
    push    ebx                             ; Reserved
    push    ebx                             ; lpValueName
    push    edx                             ; hKey
    call    ds:RegSetValueExA
    jmp     short loc_49EB01
    ; ---------------------------------------------------------------------------

    loc_49EAD6:                             ; CODE XREF: sub_49E830+289j
    mov     edi, offset Data
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0A8h+Data]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     esi, 32h

    loc_49EB01:                             ; CODE XREF: sub_49E830+2A4j
    lea     ecx, [esp+0A8h+var_94]
    lea     edx, [esp+0A8h+var_34]
    push    ecx                             ; lpcbData
    push    edx                             ; lpData
    push    offset aCdshell                 ; lpValueName
    mov     [esp+0B4h+var_94], esi
    call    sub_42F980
    lea     edi, [esp+0A8h+var_34]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_49EB4E
    lea     edi, [esp+0A8h+var_34]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+0A8h+Data]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_49EB5E
    ; ---------------------------------------------------------------------------

    loc_49EB4E:                             ; CODE XREF: sub_49E830+2F7j
    lea     ecx, [esp+0A8h+Data]
    push    esi
    push    ecx
    push    offset aCdshell                 ; "cdshell"
    call    sub_42F960

    loc_49EB5E:                             ; CODE XREF: sub_49E830+31Cj
    mov     edx, [esp+0A8h+hKey]
    push    edx                             ; hKey
    call    ds:RegFlushKey                  ; Write all the attributes of the
                                            ; specified open key into the registry
    mov     eax, [esp+0A8h+hKey]
    push    eax                             ; hKey
    call    ds:RegCloseKey

    loc_49EB74:                             ; CODE XREF: sub_49E830+265j
    mov     ebp, ds:PeekMessageA
    mov     edi, ds:__imp_GetTickCount

    loc_49EB80:                             ; CODE XREF: sub_49E830+449j
                                            ; sub_49E830+463j ...
    mov     eax, dword_51F400
    mov     ecx, TAdynmemStructPtr
    cmp     eax, ebx
    jnz     short loc_49EBC7
    mov     edx, [ecx+10h]
    cmp     [edx], ebx
    jz      short loc_49EBC7
    call    sub_490F80
    mov     eax, TAdynmemStructPtr
    mov     ecx, [eax+10h]
    call    sub_4CE680
    mov     ecx, TAdynmemStructPtr
    mov     dword_51FB90, eax
    mov     ecx, [ecx+10h]
    call    sub_4CE410
    mov     dword_509720, 1
    jmp     short loc_49EC3E
    ; ---------------------------------------------------------------------------

    loc_49EBC7:                             ; CODE XREF: sub_49E830+35Dj
                                            ; sub_49E830+364j
    cmp     eax, ebx
    jz      short loc_49EC3E
    mov     ecx, [ecx+10h]
    cmp     [ecx], ebx
    jnz     short loc_49EC3E
    cmp     dword_509720, ebx
    jz      short loc_49EC3E
    call    sub_4CE260
    mov     edx, TAdynmemStructPtr
    push    offset sub_490FE0
    mov     ecx, [edx+10h]
    call    sub_4CD9D0
    mov     eax, TAdynmemStructPtr
    mov     cl, [eax+37F14h]
    and     ecx, 1
    push    ecx
    mov     ecx, [eax+10h]
    call    sub_4CEDC0
    mov     eax, TAdynmemStructPtr
    xor     edx, edx
    mov     dl, [eax+37F16h]
    mov     ecx, [eax+10h]
    push    edx
    call    sub_4CE7A0
    mov     ecx, TAdynmemStructPtr
    mov     eax, dword_51FB90
    push    eax
    mov     ecx, [ecx+10h]
    call    sub_4CE690
    call    sub_490FE0
    mov     dword_509720, ebx

    loc_49EC3E:                             ; CODE XREF: sub_49E830+395j
                                            ; sub_49E830+399j ...
    push    ebx                             ; wRemoveMsg
    push    ebx                             ; wMsgFilterMax
    push    ebx                             ; wMsgFilterMin
    lea     edx, [esp+0B4h+Msg]
    push    ebx                             ; hWnd
    push    edx                             ; lpMsg
    call    ebp ; PeekMessageA
    test    eax, eax
    jnz     short loc_49EC98
    cmp     dword_51F400, ebx
    jnz     short loc_49EC63
    mov     eax, TAdynmemStructPtr
    test    byte ptr [eax+2A44h], 1
    jz      short loc_49EC98

    loc_49EC63:                             ; CODE XREF: sub_49E830+423j
    call    sub_499890
    call    edi ; __imp_GetTickCount
    mov     edx, dword_51FB94
    mov     esi, eax
    mov     ecx, esi
    sub     ecx, edx
    cmp     ecx, 64h
    jl      loc_49EB80
    mov     edx, TAdynmemStructPtr
    mov     ecx, [edx+10h]
    call    sub_4CF0B0
    mov     dword_51FB94, esi
    jmp     loc_49EB80
    ; ---------------------------------------------------------------------------

    loc_49EC98:                             ; CODE XREF: sub_49E830+41Bj
                                            ; sub_49E830+431j
    push    ebx                             ; wMsgFilterMax
    push    ebx                             ; wMsgFilterMin
    lea     eax, [esp+0B0h+Msg]
    push    ebx                             ; hWnd
    push    eax                             ; lpMsg
    call    ds:GetMessageA
    test    eax, eax
    jz      short loc_49ECC5
    lea     ecx, [esp+0A8h+Msg]
    push    ecx                             ; lpMsg
    call    ds:TranslateMessage
    lea     edx, [esp+0A8h+Msg]
    push    edx                             ; lpMsg
    call    ds:DispatchMessageA
    jmp     loc_49EB80
    ; ---------------------------------------------------------------------------

    loc_49ECC5:                             ; CODE XREF: sub_49E830+478j
    mov     eax, dword_51F410
    shr     eax, 0Bh
    test    al, 1
    jz      short loc_49ECDB
    call    sub_4C2CC0
    call    sub_4916A0

    loc_49ECDB:                             ; CODE XREF: sub_49E830+49Fj
    lea     ecx, [esp+0A8h+hKey]
    push    ecx                             ; phkResult
    push    0F003Fh                         ; samDesired
    push    ebx                             ; ulOptions
    push    offset aSoftwareClasse          ; lpSubKey
    push    80000002h                       ; hKey
    call    ds:RegOpenKeyExA
    test    eax, eax
    jnz     short loc_49ED6A
    lea     edi, [esp+0A8h+Data]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+0A8h+dwType]
    lea     edx, [esp+0A8h+Data]
    not     ecx
    push    ecx                             ; cbData
    mov     ecx, [esp+0ACh+hKey]
    push    edx                             ; lpData
    push    eax                             ; dwType
    push    ebx                             ; Reserved
    push    ebx                             ; lpValueName
    push    ecx                             ; hKey
    call    ds:RegSetValueExA
    mov     edx, [esp+0A8h+hKey]
    push    edx                             ; hKey
    call    ds:RegFlushKey                  ; Write all the attributes of the
                                            ; specified open key into the registry
    mov     eax, [esp+0A8h+hKey]
    push    eax                             ; hKey
    call    ds:RegCloseKey
    mov     edi, offset Data
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0A8h+Data]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    32h
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+0ACh+Data]
    push    ecx
    push    offset aCdshell                 ; "cdshell"
    call    sub_42F960

    loc_49ED6A:                             ; CODE XREF: sub_49E830+4C8j
    push    offset dword_51F320
    call    sub_4B6110
    pop     edi
    pop     esi
    mov     eax, [esp+0A0h+Msg.wParam]
    pop     ebp
    pop     ebx
    add     esp, 98h
    retn    10h
    sub_49E830 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_15. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    ; __stdcall WinMain(x,x,x,x)
    _WinMain@16 proc near                   ; CODE XREF: start+14Dp

    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset stru_4FDAE0
    push    offset __except_handler3
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    sub     esp, 8
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_18], esp
    mov     [ebp+var_4], 0
    mov     eax, [ebp+arg_C]
    push    eax
    mov     ecx, [ebp+arg_8]
    push    ecx
    mov     edx, [ebp+arg_4]
    push    edx
    mov     eax, [ebp+arg_0]
    push    eax
    call    sub_49E830
    mov     [ebp+var_4], 0FFFFFFFFh
    mov     ecx, [ebp+var_10]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    10h
    _WinMain@16 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49EDFC proc near                    ; DATA XREF: .rdata:004FDAE0o
    push    offset aMainThread              ; "Main Thread"
    mov     ecx, [ebp-14h]
    push    ecx
    call    sub_4CBAB0
    retn
    sub_49EDFC endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49EE0B proc near                    ; DATA XREF: .rdata:004FDAE0o
    mov     esp, [ebp-18h]
    mov     dword ptr [ebp-4], 0FFFFFFFFh
    xor     eax, eax
    mov     ecx, [ebp-10h]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    10h
    sub_49EE0B endp ; sp =  4

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_49EE30 proc near                    ; CODE XREF: sub_49E830+A2p

    var_574= byte ptr -574h
    var_570= byte ptr -570h
    var_46C= byte ptr -46Ch
    var_364= dword ptr -364h
    var_35C= dword ptr -35Ch
    var_358= dword ptr -358h
    var_354= dword ptr -354h
    var_350= dword ptr -350h
    var_34C= dword ptr -34Ch
    var_348= dword ptr -348h
    var_344= byte ptr -344h
    Filename= byte ptr -144h
    var_3C= dword ptr -3Ch
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  8
    lpCaption= dword ptr  0Ch

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset loc_4FB8B0
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    push    ecx
    sub     esp, 568h
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_10], esp
    mov     esi, [ebp+arg_0]
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, ecx
    add     eax, 4
    and     al, 0FCh
    call    __alloca_probe
    mov     edx, esp
    mov     [ebp+var_18], edx
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, TAdynmemStructPtr
    mov     dword ptr [ecx+37F31h], 1Eh
    xor     eax, eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F35h], eax
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+39245h], eax
    push    offset asc_509890               ; char *
    push    edx                             ; char *
    call    _strtok
    add     esp, 8
    mov     edi, eax
    mov     ebx, 1

    loc_49EED3:                             ; CODE XREF: sub_49EE30+642j
    test    edi, edi
    jz      loc_49F477
    mov     al, [edi]
    cmp     al, 2Dh
    jz      short loc_49EF0A
    cmp     al, 2Fh
    jz      short loc_49EF0A
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, offset byte_51FB50
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49EF0A:                             ; CODE XREF: sub_49EE30+AFj
                                            ; sub_49EE30+B3j
    push    edi                             ; char *
    call    sub_4DA0E0
    add     esp, 4
    test    al, al
    jnz     loc_49F461
    movsx   eax, byte ptr [edi+1]
    add     eax, 0FFFFFFBEh
    cmp     eax, 35h
    ja      loc_49F461
    xor     ecx, ecx
    mov     cl, ds:byte_49F500[eax]
    jmp     ds:off_49F494[ecx*4]

    loc_49EF3A:                             ; DATA XREF: .text:0049F494o
                                            ; .text:0049F4C8o
    cmp     byte ptr [edi], 0
    jnz     short loc_49EF50
    push    offset asc_509890               ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    mov     edi, eax

    loc_49EF50:                             ; CODE XREF: sub_49EE30+10Dj
    test    edi, edi
    jz      loc_49F461
    cmp     byte ptr [edi], 0
    jz      loc_49F461
    push    offset aLock                    ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_49EF84
    mov     eax, TAdynmemStructPtr
    or      [eax+2C74h], bx
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49EF84:                             ; CODE XREF: sub_49EE30+141j
    push    offset aDeathends               ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    push    offset aDeathplays              ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    push    offset aDeathmatch              ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    push    offset aFixedloc                ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    push    offset aMapping                 ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    push    offset aCirclos                 ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    push    offset aTruelos                 ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    push    offset aPermlos                 ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    push    offset aCheating                ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    push    offset aWatching                ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F05D:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F498o ...
    add     edi, 2
    cmp     byte ptr [edi], 0
    jnz     short loc_49F076
    push    offset asc_509890               ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    mov     edi, eax

    loc_49F076:                             ; CODE XREF: sub_49EE30+233j
    test    edi, edi
    jz      loc_49F1F1
    cmp     byte ptr [edi], 0
    jz      loc_49F1F1
    mov     [ebp+var_4], 0
    push    edi
    call    sub_45B670
    mov     [ebp+var_4], 0FFFFFFFFh
    jmp     loc_49F1EC
    ; ---------------------------------------------------------------------------

    loc_49F0A0:                             ; DATA XREF: .rdata:004FEF38o
    mov     eax, offset loc_49F0A6
    retn
    ; ---------------------------------------------------------------------------

    loc_49F0A6:                             ; DATA XREF: sub_49EE30+270o
    mov     [ebp+var_4], 0FFFFFFFFh
    jmp     loc_49F1EC
    ; ---------------------------------------------------------------------------

    loc_49F0B2:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F49Co ...
    mov     al, [edi+2]
    mov     dword_51FB48, 2
    cmp     al, 66h
    jz      loc_49F461
    cmp     al, 46h
    jz      loc_49F461
    mov     dword_51FB48, 3
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F0DE:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4A0o ...
    add     edi, 2
    cmp     byte ptr [edi], 0
    jnz     short loc_49F0F7
    push    offset asc_509890               ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    mov     edi, eax

    loc_49F0F7:                             ; CODE XREF: sub_49EE30+2B4j
    test    edi, edi
    jz      loc_49F461
    mov     cl, [edi]
    test    cl, cl
    jz      loc_49F461
    or      eax, 0FFFFFFFFh
    cmp     cl, 2Dh
    jz      short loc_49F11A
    push    edi                             ; char *
    call    _atoi
    add     esp, 4

    loc_49F11A:                             ; CODE XREF: sub_49EE30+2DFj
    test    eax, eax
    jl      short loc_49F123
    cmp     eax, 64h
    jle     short loc_49F125

    loc_49F123:                             ; CODE XREF: sub_49EE30+2ECj
    xor     eax, eax

    loc_49F125:                             ; CODE XREF: sub_49EE30+2F1j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F35h], eax
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F136:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4A4o ...
    push    ebx
    call    sub_41D4B0
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F141:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4A8o ...
    add     edi, 2
    cmp     byte ptr [edi], 0
    jz      short loc_49F155
    push    edi                             ; char *
    push    ebx                             ; int
    call    sub_45B820
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F155:                             ; CODE XREF: sub_49EE30+317j
    push    offset asc_509890               ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    test    eax, eax
    jz      loc_49F461
    mov     cl, [eax]
    test    cl, cl
    jz      loc_49F461
    cmp     cl, 2Dh
    jz      loc_49F461
    push    eax                             ; char *
    push    ebx                             ; int
    call    sub_45B820
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F18B:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4ACo ...
    push    0
    call    sub_41D4A0
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F197:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4B0o ...
    add     edi, 2
    cmp     byte ptr [edi], 0
    jnz     short loc_49F1B0
    push    offset asc_509890               ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    mov     edi, eax

    loc_49F1B0:                             ; CODE XREF: sub_49EE30+36Dj
    test    edi, edi
    jz      short loc_49F1F1
    mov     al, [edi]
    test    al, al
    jz      short loc_49F1F1
    cmp     al, 2Dh
    jz      short loc_49F1F1
    push    3Ah                             ; int
    push    edi                             ; char *
    call    _strchr
    add     esp, 8
    mov     ebx, eax
    push    edi                             ; char *
    call    _atoi
    add     esp, 4
    mov     esi, eax
    cmp     esi, 1
    jnz     short loc_49F1E6
    test    ebx, ebx
    jz      short loc_49F1E6
    inc     ebx
    push    ebx                             ; char *
    call    sub_45B800

    loc_49F1E6:                             ; CODE XREF: sub_49EE30+3A9j
                                            ; sub_49EE30+3ADj
    push    esi
    call    sub_45B860

    loc_49F1EC:                             ; CODE XREF: sub_49EE30+26Bj
                                            ; sub_49EE30+27Dj
    mov     ebx, 1

    loc_49F1F1:                             ; CODE XREF: sub_49EE30+248j
                                            ; sub_49EE30+251j ...
    mov     edx, TAdynmemStructPtr
    mov     [edx+39245h], ebx
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F202:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4B4o ...
    add     edi, 2
    cmp     byte ptr [edi], 0
    jnz     short loc_49F21B
    push    offset asc_509890               ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    mov     edi, eax

    loc_49F21B:                             ; CODE XREF: sub_49EE30+3D8j
    test    edi, edi
    jz      loc_49F461
    mov     cl, [edi]
    test    cl, cl
    jz      loc_49F461
    or      eax, 0FFFFFFFFh
    cmp     cl, 2Dh
    jz      short loc_49F23E
    push    edi                             ; char *
    call    _atoi
    add     esp, 4

    loc_49F23E:                             ; CODE XREF: sub_49EE30+403j
    push    eax
    call    sub_4578D0
    jmp     loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F249:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4B8o ...
    mov     eax, [ebp+arg_0]
    lea     ebx, [edi+eax]
    sub     ebx, [ebp+var_18]
    add     ebx, 2
    movsx   ecx, byte ptr [ebx]
    push    ecx                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jz      short loc_49F276

    loc_49F265:                             ; CODE XREF: sub_49EE30+444j
    inc     ebx
    movsx   edx, byte ptr [ebx]
    push    edx                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jnz     short loc_49F265

    loc_49F276:                             ; CODE XREF: sub_49EE30+433j
    push    104h                            ; nSize
    lea     eax, [ebp+Filename]
    push    eax                             ; lpFilename
    push    0                               ; hModule
    call    ds:GetModuleFileNameA
    mov     [ebp+var_3C], 0
    test    eax, eax
    jbe     loc_49F3D6
    mov     [ebp+var_344], 0
    mov     [ebp+var_570], 0
    lea     ecx, [ebp+var_570]
    push    ecx                             ; char *
    lea     edx, [ebp+var_344]
    push    edx                             ; char *
    lea     eax, [ebp-46Ah]
    push    eax                             ; char *
    lea     ecx, [ebp+var_574]
    push    ecx                             ; char *
    lea     edx, [ebp+Filename]
    push    edx                             ; char *
    call    __splitpath
    add     esp, 14h
    lea     edi, [ebp+var_570]
    lea     edx, [ebp+var_344]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    dec     edi
    mov     ecx, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     al, [ebp+var_574]
    mov     [ebp+var_46C], al
    mov     cl, [ebp-573h]
    mov     [ebp-46Bh], cl
    lea     edi, [ebp+var_46C]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     esi, [ebp+ecx-46Dh]
    movsx   edx, byte ptr [esi]
    push    edx                             ; int
    push    offset asc_5066CC               ; char *
    call    _strchr
    add     esp, 8
    test    eax, eax
    jz      short loc_49F34A
    mov     byte ptr [esi], 0

    loc_49F34A:                             ; CODE XREF: sub_49EE30+515j
    mov     ecx, 8
    xor     eax, eax
    lea     edi, [ebp+var_364]
    rep stosd
    mov     [ebp+var_364], 20h
    mov     eax, [ebp+lpCaption]
    mov     [ebp+var_35C], eax
    mov     [ebp+var_358], offset dword_4FCFB8
    lea     ecx, [ebp+var_344]
    mov     [ebp+var_354], ecx
    mov     [ebp+var_350], ebx
    lea     edx, [ebp+var_46C]
    mov     [ebp+var_34C], edx
    lea     eax, [ebp+var_46C]
    mov     [ebp+var_348], eax
    push    offset aDsetup_dll              ; lpLibFileName
    call    ds:LoadLibraryA
    mov     esi, eax
    test    esi, esi
    jz      short loc_49F3CF
    push    offset aDirectxregiste          ; lpProcName
    push    esi                             ; hModule
    call    ds:GetProcAddress
    test    eax, eax
    jz      short loc_49F3CF
    lea     ecx, [ebp+var_364]
    push    ecx
    push    0
    call    eax
    mov     [ebp+var_3C], eax

    loc_49F3CF:                             ; CODE XREF: sub_49EE30+57Fj
                                            ; sub_49EE30+58Fj
    push    esi                             ; hLibModule
    call    ds:FreeLibrary

    loc_49F3D6:                             ; CODE XREF: sub_49EE30+463j
    mov     eax, [ebp+var_3C]
    test    eax, eax
    jnz     short loc_49F3FE
    push    10h                             ; uType
    call    ds:MessageBeep
    push    offset aDirectplayRegi          ; int
    call    sub_4C5740
    push    10h                             ; uType
    mov     edx, [ebp+lpCaption]
    push    edx                             ; lpCaption
    push    eax                             ; lpText
    push    0                               ; hWnd
    call    ds:MessageBoxA

    loc_49F3FE:                             ; CODE XREF: sub_49EE30+5ABj
    xor     eax, eax
    jmp     short loc_49F479
    ; ---------------------------------------------------------------------------

    loc_49F402:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4BCo ...
    call    sub_47EFC0
    jmp     short loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F409:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4C0o ...
    add     edi, 2
    cmp     byte ptr [edi], 0
    jnz     short loc_49F422
    push    offset asc_509890               ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    mov     edi, eax

    loc_49F422:                             ; CODE XREF: sub_49EE30+5DFj
    test    edi, edi
    jz      short loc_49F461
    mov     cl, [edi]
    test    cl, cl
    jz      short loc_49F461
    or      eax, 0FFFFFFFFh
    cmp     cl, 2Dh
    jz      short loc_49F43D
    push    edi                             ; char *
    call    _atoi
    add     esp, 4

    loc_49F43D:                             ; CODE XREF: sub_49EE30+602j
    cmp     eax, 1Eh
    jl      short loc_49F449
    cmp     eax, 12Ch
    jle     short loc_49F44E

    loc_49F449:                             ; CODE XREF: sub_49EE30+610j
    mov     eax, 1Eh

    loc_49F44E:                             ; CODE XREF: sub_49EE30+617j
    mov     ecx, TAdynmemStructPtr
    mov     [ecx+37F31h], eax
    jmp     short loc_49F461
    ; ---------------------------------------------------------------------------

    loc_49F45C:                             ; CODE XREF: sub_49EE30+103j
                                            ; DATA XREF: .text:0049F4C4o ...
    call    sub_47EFD0

    loc_49F461:                             ; CODE XREF: sub_49EE30+D5j
                                            ; sub_49EE30+E5j ...
    push    offset asc_509890               ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    mov     edi, eax
    jmp     loc_49EED3
    ; ---------------------------------------------------------------------------

    loc_49F477:                             ; CODE XREF: sub_49EE30+A5j
    mov     eax, ebx

    loc_49F479:                             ; CODE XREF: sub_49EE30+5D0j
    lea     esp, [ebp-584h]
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    8
    sub_49EE30 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_49F494 dd offset loc_49EF3A         ; DATA XREF: sub_49EE30+103r
    dd offset loc_49F05D
    dd offset loc_49F0B2
    dd offset loc_49F0DE
    dd offset loc_49F136
    dd offset loc_49F141
    dd offset loc_49F18B
    dd offset loc_49F197
    dd offset loc_49F202
    dd offset loc_49F249
    dd offset loc_49F402
    dd offset loc_49F409
    dd offset loc_49F45C
    dd offset loc_49EF3A
    dd offset loc_49F05D
    dd offset loc_49F0B2
    dd offset loc_49F0DE
    dd offset loc_49F136
    dd offset loc_49F141
    dd offset loc_49F18B
    dd offset loc_49F197
    dd offset loc_49F202
    dd offset loc_49F249
    dd offset loc_49F402
    dd offset loc_49F409
    dd offset loc_49F45C
    dd offset loc_49F461
    byte_49F500 db 0                        ; DATA XREF: sub_49EE30+FDr
    ; ---------------------------------------------------------------------------
    add     [edx], eax
    add     eax, [edx+ebx]
    add     eax, 61A1A1Ah
    sbb     al, [edi]
    sbb     cl, [eax]
    sbb     cl, [ecx]
    or      cl, [ebx]
    sbb     bl, [edx]
    or      al, 1Ah
    sbb     bl, [edx]
    sbb     bl, [edx]
    sbb     bl, [edx]
    sbb     bl, [edx]
    sbb     cl, ds:11100F0Eh
    sbb     dl, [edx]
    sbb     bl, [edx]
    sbb     dl, [ebx]
    sbb     dl, [edx+ebx]
    adc     eax, 1817161Ah
    sbb     bl, [edx]
    sbb     [eax-6F6F6F70h], edx
    nop
    nop
    nop
    nop
    nop

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49F540 proc near                    ; CODE XREF: sub_41D4C0+1Bp

    PathName= byte ptr -100h

    sub     esp, 100h
    lea     eax, [esp+100h+PathName]
    push    100h                            ; nSize
    push    eax                             ; lpFilename
    push    0                               ; hModule
    call    ds:GetModuleFileNameA
    lea     ecx, [esp+100h+PathName]
    push    ecx
    call    sub_4BB120
    lea     edx, [esp+100h+PathName]
    push    edx                             ; lpPathName
    call    ds:SetCurrentDirectoryA
    add     esp, 100h
    retn
    sub_49F540 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49F580 proc near                    ; CODE XREF: sub_4290F0+4p
                                            ; sub_435430+91p ...
    push    edi
    mov     edi, offset byte_51FB50
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    pop     edi
    cmp     eax, ecx
    sbb     eax, eax
    and     eax, offset byte_51FB50
    retn
    sub_49F580 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall ReadIniFileValue(LPCSTR lpKeyName,INT nDefault)
    ReadIniFileValue proc near              ; CODE XREF: sub_47ED40+Ap
                                            ; sub_47ED40+24p ...

    Filename= byte ptr -200h
    FileName= byte ptr -100h
    lpKeyName= dword ptr  4
    nDefault= dword ptr  8

    sub     esp, 200h
    lea     eax, [esp+200h+Filename]
    push    100h                            ; nSize
    push    eax                             ; lpFilename
    push    0                               ; hModule
    call    ds:GetModuleFileNameA
    lea     ecx, [esp+200h+Filename]
    push    ecx
    call    sub_4BB120
    lea     edx, [esp+200h+Filename]
    lea     eax, [esp+200h+FileName]
    push    edx
    push    offset aSTotala_ini             ; "%s\\totala.ini"
    push    eax
    call    _sprintf
    mov     edx, [esp+20Ch+nDefault]
    mov     eax, [esp+20Ch+lpKeyName]
    add     esp, 0Ch
    lea     ecx, [esp+200h+FileName]
    push    ecx                             ; lpFileName
    push    edx                             ; nDefault
    push    eax                             ; lpKeyName
    push    offset aPreferences             ; lpAppName
    call    ds:GetPrivateProfileIntA
    add     esp, 200h
    retn    8
    ReadIniFileValue endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION unknown_libname_47. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49F620 proc near                    ; CODE XREF: sub_47F680+BBp
    mov     eax, pszSound
    test    eax, eax
    jz      short locret_49F634
    push    15h                             ; fdwSound
    push    0                               ; hmod
    push    eax                             ; pszSound
    call    ds:PlaySoundA                   ; Play a sound specified by the given
                                            ; filename, resource, or system event

    locret_49F634:                          ; CODE XREF: sub_49F620+7j
    retn
    sub_49F620 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_49F640:                             ; CODE XREF: sub_47F750+1Fj
    push    2000h
    push    0
    push    0
    call    ds:PlaySoundA                   ; Play a sound specified by the given
                                            ; filename, resource, or system event
    mov     eax, dword_51FBA0
    test    eax, eax
    jz      short loc_49F66B
    push    eax
    call    sub_4D85A0
    add     esp, 4
    mov     dword_51FBA0, 0

    loc_49F66B:                             ; CODE XREF: .text:0049F656j
    mov     pszSound, 0
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49F680(LPCSTR pszSound)
    sub_49F680 proc near                    ; CODE XREF: sub_47F0C0+40p

    pszSound= dword ptr  4

    mov     eax, [esp+pszSound]
    push    5                               ; fdwSound
    push    0                               ; hmod
    push    eax                             ; pszSound
    call    ds:PlaySoundA                   ; Play a sound specified by the given
                                            ; filename, resource, or system event
    retn    4
    sub_49F680 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49F6A0(LPCSTR pszSound)
    sub_49F6A0 proc near                    ; CODE XREF: sub_47F0C0+34p

    pszSound= dword ptr  4

    mov     eax, [esp+pszSound]
    push    0Dh                             ; fdwSound
    push    0                               ; hmod
    push    eax                             ; pszSound
    mov     pszSound, eax
    call    ds:PlaySoundA                   ; Play a sound specified by the given
                                            ; filename, resource, or system event
    retn    4
    sub_49F6A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49F6C0 proc near                    ; CODE XREF: sub_47F290+Fp
                                            ; sub_47FD70+113p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    push    0
    push    eax
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_49F6D7
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49F6D7:                             ; CODE XREF: sub_49F6C0+11j
    push    edi
    push    5                               ; fdwSound
    push    0                               ; hmod
    push    esi                             ; pszSound
    call    ds:PlaySoundA                   ; Play a sound specified by the given
                                            ; filename, resource, or system event
    mov     edi, eax
    mov     eax, dword_51FBA0
    test    eax, eax
    jz      short loc_49F6F7
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_49F6F7:                             ; CODE XREF: sub_49F6C0+2Cj
    mov     eax, edi
    mov     dword_51FBA0, esi
    pop     edi
    pop     esi
    retn    4
    sub_49F6C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION DirectDrawCreate. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------
    jmp     ds:mciSendStringA
    ; ---------------------------------------------------------------------------
    jmp     ds:PlaySoundA                   ; Play a sound specified by the given
                                            ; filename, resource, or system event
    ; ---------------------------------------------------------------------------
    jmp     ds:lstrcpynA
    ; ---------------------------------------------------------------------------
    jmp     ds:CloseHandle
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateFileA
    ; ---------------------------------------------------------------------------
    jmp     ds:DebugBreak
    ; ---------------------------------------------------------------------------
    jmp     ds:Sleep
    ; ---------------------------------------------------------------------------
    jmp     ds:__imp_GetTickCount
    ; ---------------------------------------------------------------------------
    jmp     ds:GetPrivateProfileIntA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetPrivateProfileStringA
    ; ---------------------------------------------------------------------------
    jmp     ds:GlobalFree
    ; ---------------------------------------------------------------------------
    jmp     ds:GlobalUnlock
    ; ---------------------------------------------------------------------------
    jmp     ds:GlobalHandle
    ; ---------------------------------------------------------------------------
    jmp     ds:lstrlenA
    ; ---------------------------------------------------------------------------
    jmp     ds:lstrcpyA
    ; ---------------------------------------------------------------------------
    jmp     ds:WaitForSingleObject
    ; ---------------------------------------------------------------------------
    jmp     ds:GetProcAddress
    ; ---------------------------------------------------------------------------
    jmp     ds:LoadLibraryA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetModuleFileNameA
    ; ---------------------------------------------------------------------------
    jmp     ds:FreeLibrary
    ; ---------------------------------------------------------------------------
    jmp     ds:SetThreadPriority
    ; ---------------------------------------------------------------------------
    jmp     ds:GetCurrentThread
    ; ---------------------------------------------------------------------------
    jmp     ds:GlobalMemoryStatus
    ; ---------------------------------------------------------------------------
    jmp     ds:QueryPerformanceCounter
    ; ---------------------------------------------------------------------------
    jmp     ds:WriteFile
    ; ---------------------------------------------------------------------------
    jmp     ds:SetFilePointer
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateSemaphoreA
    ; ---------------------------------------------------------------------------
    jmp     ds:OpenSemaphoreA
    ; ---------------------------------------------------------------------------
    jmp     ds:SetCurrentDirectoryA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetFocus
    ; ---------------------------------------------------------------------------
    jmp     ds:GetCursorPos
    ; ---------------------------------------------------------------------------
    jmp     ds:wsprintfA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetKeyState
    ; ---------------------------------------------------------------------------
    jmp     ds:SetWindowPos
    ; ---------------------------------------------------------------------------
    jmp     ds:ReleaseDC
    ; ---------------------------------------------------------------------------
    jmp     ds:GetDC
    ; ---------------------------------------------------------------------------
    jmp     ds:ClientToScreen               ; Convert the client coordinates of a
                                            ; specified point to screen coordinates.
    ; ---------------------------------------------------------------------------
    jmp     ds:MessageBoxA
    ; ---------------------------------------------------------------------------
    jmp     ds:EndPaint
    ; ---------------------------------------------------------------------------
    jmp     ds:BeginPaint
    ; ---------------------------------------------------------------------------
    jmp     ds:PostQuitMessage
    ; ---------------------------------------------------------------------------
    jmp     ds:DispatchMessageA
    ; ---------------------------------------------------------------------------
    jmp     ds:TranslateMessage
    ; ---------------------------------------------------------------------------
    jmp     ds:PeekMessageA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetMessageA
    ; ---------------------------------------------------------------------------
    jmp     ds:MessageBeep
    ; ---------------------------------------------------------------------------
    jmp     ds:GetSystemPaletteEntries
    ; ---------------------------------------------------------------------------
    jmp     ds:PatBlt
    ; ---------------------------------------------------------------------------
    jmp     ds:GetUserNameA
    ; ---------------------------------------------------------------------------
    jmp     ds:RegCloseKey
    ; ---------------------------------------------------------------------------
    jmp     ds:RegFlushKey                  ; Write all the attributes of the
                                            ; specified open key into the registry
    ; ---------------------------------------------------------------------------
    jmp     ds:RegSetValueExA
    ; ---------------------------------------------------------------------------
    jmp     ds:RegQueryValueExA
    ; ---------------------------------------------------------------------------
    jmp     ds:RegOpenKeyExA
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackSoundOnOff@8           ; SmackSoundOnOff(x,x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackOpen@12                ; SmackOpen(x,x,x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackSoundUseDirectSound@4  ; SmackSoundUseDirectSound(x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackSimulate@4             ; SmackSimulate(x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackClose@4                ; SmackClose(x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackColorRemap@16          ; SmackColorRemap(x,x,x,x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackBufferNewPalette@12    ; SmackBufferNewPalette(x,x,x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackBufferOpen@24          ; SmackBufferOpen(x,x,x,x,x,x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackGoto@8                 ; SmackGoto(x,x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackNextFrame@4            ; SmackNextFrame(x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackToBufferRect@8         ; SmackToBufferRect(x,x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackDoFrame@4              ; SmackDoFrame(x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackToBuffer@28            ; SmackToBuffer(x,x,x,x,x,x,x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackSummary@8              ; SmackSummary(x,x)
    ; ---------------------------------------------------------------------------
    jmp     ds:_SmackWait@4                 ; SmackWait(x)
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     edi, 1
    mov     ebx, [ecx+4]
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edx, edi
    jle     short loc_49F921
    mov     ebp, [esp+18h]
    lea     esi, [ebx+15Dh]

    loc_49F8E9:                             ; CODE XREF: .text:0049F90Aj
    push    10h
    push    ebp
    push    esi
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_49F915
    movsx   eax, word ptr [ebx+0B6h]
    inc     edi
    add     esi, 15Bh
    inc     eax
    cmp     edi, eax
    jl      short loc_49F8E9
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49F915:                             ; CODE XREF: .text:0049F8F7j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49F921:                             ; CODE XREF: .text:0049F8DDj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49F930(int,char *,LPCSTR lpString2)
    sub_49F930 proc near                    ; CODE XREF: sub_447380+323p
                                            ; sub_447380+424p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    lpString2= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+18h]
    push    edi
    test    eax, eax
    jz      short loc_49F9AC
    mov     ebx, [eax+4]
    mov     esi, 1
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_49F980
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_49F95D:                             ; CODE XREF: sub_49F930+4Ej
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_49F983
    movsx   edx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_49F95D

    loc_49F980:                             ; CODE XREF: sub_49F930+21j
    or      esi, 0FFFFFFFFh

    loc_49F983:                             ; CODE XREF: sub_49F930+3Bj
    cmp     esi, 0FFFFFFFFh
    jz      short loc_49F9AC
    mov     eax, [esp+10h+lpString2]
    push    11h                             ; iMaxLength
    push    eax                             ; lpString2
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    lea     eax, [esi+edx*4]
    lea     ecx, [ebx+eax*2+2]
    push    ecx                             ; lpString1
    call    ds:lstrcpynA

    loc_49F9AC:                             ; CODE XREF: sub_49F930+Dj
                                            ; sub_49F930+56j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_49F930 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49F9C0 proc near                    ; CODE XREF: sub_4436E0+D0p

    Msg= MSG ptr -1Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 1Ch
    push    ebx
    mov     ebx, ds:PeekMessageA
    push    ebp
    mov     ebp, ds:TranslateMessage
    push    esi
    mov     esi, [esp+28h+arg_0]
    push    edi
    mov     edi, [esp+2Ch+arg_4]

    loc_49F9DB:                             ; CODE XREF: sub_49F9C0+77j
    mov     eax, [esi+18h]
    test    eax, eax
    jz      short loc_49FA39
    mov     eax, [eax+4]
    push    10h                             ; size_t
    add     eax, 2
    push    edi                             ; char *
    push    eax                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_49FA39
    push    1                               ; wRemoveMsg
    push    eax                             ; wMsgFilterMax
    push    eax                             ; wMsgFilterMin
    lea     ecx, [esp+38h+Msg]
    push    eax                             ; hWnd
    push    ecx                             ; lpMsg
    call    ebx ; PeekMessageA
    test    eax, eax
    jz      short loc_49FA1A
    lea     edx, [esp+2Ch+Msg]
    push    edx                             ; lpMsg
    call    ebp ; TranslateMessage
    lea     eax, [esp+2Ch+Msg]
    push    eax                             ; lpMsg
    call    ds:DispatchMessageA

    loc_49FA1A:                             ; CODE XREF: sub_49F9C0+46j
    push    esi
    call    sub_4A9FD0
    mov     ecx, [esi+18h]
    push    0
    push    0
    push    ecx
    call    sub_4AB0B0
    call    sub_4C2870
    call    sub_4C63A0
    jmp     short loc_49F9DB
    ; ---------------------------------------------------------------------------

    loc_49FA39:                             ; CODE XREF: sub_49F9C0+20j
                                            ; sub_49F9C0+36j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    8
    sub_49F9C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49FA50 proc near                    ; CODE XREF: .text:0041FF88p
                                            ; .text:00426474p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     dword ptr [eax+0A2h], 1
    retn    4
    sub_49FA50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49FA70 proc near                    ; CODE XREF: sub_4609B0+1Ap
                                            ; sub_492360+51p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     dword ptr [eax+0A2h], 0
    retn    4
    sub_49FA70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FA90(int)
    sub_49FA90 proc near                    ; CODE XREF: sub_4199B0+FBp
                                            ; sub_41AA00+26Ep ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     dword ptr [eax+0CCAh], 1
    retn    4
    sub_49FA90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FAB0(int)
    sub_49FAB0 proc near

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     dword ptr [eax+0CCAh], 0
    retn    4
    sub_49FAB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49FAD0 proc near                    ; CODE XREF: sub_41F400+19Ep
                                            ; .text:0041F64Fp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     eax, [eax+18h]
    test    eax, eax
    jz      short locret_49FAE2
    mov     dword ptr [eax+14h], 1

    locret_49FAE2:                          ; CODE XREF: sub_49FAD0+9j
    retn    4
    sub_49FAD0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     ecx, [eax+18h]
    mov     dword ptr [ecx+14h], 0
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49FB10 proc near                    ; CODE XREF: sub_41F0A0+32Ep
                                            ; .text:0041F737p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     eax, [eax+18h]
    test    eax, eax
    jz      short locret_49FB22
    mov     ecx, [esp+arg_4]
    mov     [eax+18h], ecx

    locret_49FB22:                          ; CODE XREF: sub_49FB10+9j
    retn    8
    sub_49FB10 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     eax, [eax+18h]
    test    eax, eax
    jz      short loc_49FB41
    mov     eax, [eax+18h]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_49FB41:                             ; CODE XREF: .text:0049FB39j
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FB50(int,char *)
    sub_49FB50 proc near                    ; CODE XREF: sub_491200+2FAp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    push    ebx
    push    esi
    push    edi
    lea     ebx, [eax+0BB6h]
    push    100h                            ; size_t
    push    ecx                             ; char *
    push    ebx                             ; char *
    call    _strncpy
    mov     edi, offset byte_503374
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_49FB50 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FBA0(int,char *)
    sub_49FBA0 proc near                    ; CODE XREF: sub_491200+2CEp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    push    ebx
    push    esi
    push    edi
    lea     ebx, [eax+9B6h]
    push    100h                            ; size_t
    push    ecx                             ; char *
    push    ebx                             ; char *
    call    _strncpy
    mov     edi, offset byte_503374
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_49FBA0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FBF0(int,char *)
    sub_49FBF0 proc near                    ; CODE XREF: sub_491200+2E5p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    push    ebx
    push    esi
    push    edi
    lea     ebx, [eax+0AB6h]
    push    100h                            ; size_t
    push    ecx                             ; char *
    push    ebx                             ; char *
    call    _strncpy
    mov     edi, offset byte_503374
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_49FBF0 endp

    ; ---------------------------------------------------------------------------
    mov     eax, [esp+4]
    mov     dword ptr [eax+64h], 0FFFFFFFFh
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49FC50 proc near                    ; CODE XREF: sub_440D70+81p
                                            ; .text:0044234Cp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_0]
    push    esi
    push    edi
    mov     eax, [edx+64h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_49FC86
    lea     ecx, ds:0[eax*8]
    mov     esi, [edx+18h]
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [eax+ecx*2]
    mov     ecx, [esi+4]
    cmp     byte ptr [ecx+eax], 3
    jnz     short loc_49FC86
    mov     dword ptr [edx+64h], 0FFFFFFFFh

    loc_49FC86:                             ; CODE XREF: sub_49FC50+Cj
                                            ; sub_49FC50+2Dj
    mov     ecx, [edx+64h]
    mov     eax, [esp+8+arg_4]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_49FC9D
    cmp     ecx, eax
    jz      short loc_49FC9D
    xor     eax, eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49FC9D:                             ; CODE XREF: sub_49FC50+40j
                                            ; sub_49FC50+44j
    cmp     eax, 0FFFFFFFFh
    mov     [edx+64h], eax
    jz      short loc_49FCD8
    mov     ecx, eax
    mov     esi, [edx+18h]
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [eax+ecx*2]
    mov     ecx, [esi+4]
    add     eax, ecx
    cmp     byte ptr [eax], 3
    jnz     short loc_49FCD8
    lea     edi, [eax+0B6h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     [edx+74h], ecx

    loc_49FCD8:                             ; CODE XREF: sub_49FC50+53j
                                            ; sub_49FC50+73j
    pop     edi
    pop     esi
    mov     eax, 1
    retn    8
    sub_49FC50 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    xor     eax, eax
    mov     edx, [ecx+64h]
    mov     ecx, [esp+8]
    cmp     edx, ecx
    setz    al
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    xor     eax, eax
    cmp     dword ptr [ecx+64h], 0FFFFFFFFh
    setnz   al
    retn    4
    ; ---------------------------------------------------------------------------
    mov     eax, [esp+4]
    push    esi
    push    edi
    mov     ecx, 6
    lea     esi, [eax+3Ch]
    mov     eax, [esp+14h]
    mov     edi, eax
    rep movsd
    mov     ecx, [esp+10h]
    mov     esi, [eax]
    pop     edi
    movsx   edx, word ptr [ecx+13h]
    sub     esi, edx
    mov     edx, [eax+4]
    mov     [eax], esi
    pop     esi
    movsx   ecx, word ptr [ecx+15h]
    sub     edx, ecx
    mov     [eax+4], edx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_49FD60 proc near                    ; CODE XREF: sub_41EC50+157p
                                            ; sub_41EC50+18Ap ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    esi
    mov     edx, [eax+18h]
    test    edx, edx
    jnz     short loc_49FD74
    xor     eax, eax
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49FD74:                             ; CODE XREF: sub_49FD60+Bj
    mov     eax, [eax+60h]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_49FD83
    xor     eax, eax
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49FD83:                             ; CODE XREF: sub_49FD60+1Aj
    lea     ecx, ds:0[eax*8]
    mov     esi, [esp+8+arg_4]
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [eax+ecx*2]
    mov     ecx, [edx+4]
    lea     eax, [ecx+eax+2]

    loc_49FDA3:                             ; CODE XREF: sub_49FD60+65j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_49FDD7
    test    cl, cl
    jz      short loc_49FDC7
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_49FDD7
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_49FDA3

    loc_49FDC7:                             ; CODE XREF: sub_49FD60+4Fj
    xor     eax, eax
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49FDD7:                             ; CODE XREF: sub_49FD60+4Bj
                                            ; sub_49FD60+5Bj
    sbb     eax, eax
    pop     esi
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    pop     ebx
    retn    8
    sub_49FD60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FDF0(int,char *)
    sub_49FDF0 proc near                    ; CODE XREF: sub_41E420+16Cp
                                            ; sub_41F400+15Ep ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    movsx   eax, word ptr [ebx+0B6h]
    push    edi
    mov     edi, 1
    inc     eax
    cmp     eax, edi
    jle     short loc_49FE49
    mov     ebp, [esp+0Ch+arg_4]
    lea     esi, [ebx+15Dh]

    loc_49FE13:                             ; CODE XREF: sub_49FDF0+44j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    esi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_49FE40
    movsx   ecx, word ptr [ebx+0B6h]
    inc     edi
    add     esi, 15Bh
    inc     ecx
    cmp     edi, ecx
    jl      short loc_49FE13
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49FE40:                             ; CODE XREF: sub_49FDF0+31j
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_49FE49:                             ; CODE XREF: sub_49FDF0+17j
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn    0Ch
    sub_49FDF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FE60(int,char *)
    sub_49FE60 proc near                    ; CODE XREF: sub_419AC0+14p
                                            ; sub_41A120+1Dp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    movsx   eax, word ptr [ebx+0B6h]
    mov     esi, 1
    inc     eax
    cmp     eax, esi
    push    edi
    jle     short loc_49FEB7
    mov     ebp, [esp+0Ch+arg_4]
    lea     edi, [ebx+15Dh]

    loc_49FE83:                             ; CODE XREF: sub_49FE60+42j
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jnz     short loc_49FEAE
    movsx   ecx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_49FE83
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49FEAE:                             ; CODE XREF: sub_49FE60+2Fj
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49FEB7:                             ; CODE XREF: sub_49FE60+17j
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn    8
    sub_49FE60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FED0(int,char *,int)
    sub_49FED0 proc near                    ; CODE XREF: .text:00419642p
                                            ; sub_419BE0+47p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    push    esi
    mov     ecx, eax
    mov     esi, [esp+4+arg_4]
    shl     ecx, 3
    sub     ecx, eax
    push    10h                             ; size_t
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esp+8+arg_0]
    add     edx, eax
    lea     eax, [edx+ecx*2+2]
    push    eax                             ; char *
    push    esi                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [esi+10h], 0
    pop     esi
    retn    0Ch
    sub_49FED0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FF10(int,char *)
    sub_49FF10 proc near                    ; CODE XREF: .text:00419970p
                                            ; sub_447380+246p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    movsx   eax, word ptr [ebx+0B6h]
    mov     esi, 1
    inc     eax
    cmp     eax, esi
    push    edi
    jle     short loc_49FF56
    mov     ebp, [esp+0Ch+arg_4]
    lea     edi, [ebx+15Dh]

    loc_49FF33:                             ; CODE XREF: sub_49FF10+44j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_49FF59
    movsx   ecx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_49FF33

    loc_49FF56:                             ; CODE XREF: sub_49FF10+17j
    or      esi, 0FFFFFFFFh

    loc_49FF59:                             ; CODE XREF: sub_49FF10+31j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_49FF7A
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    lea     ecx, [esi+eax*4]
    lea     eax, [ebx+ecx*2]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49FF7A:                             ; CODE XREF: sub_49FF10+4Cj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    8
    sub_49FF10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_49FF90(int,char *)
    sub_49FF90 proc near                    ; CODE XREF: sub_41EC50+351p
                                            ; sub_4423C0+10Ep ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    movsx   eax, word ptr [ebx+0B6h]
    mov     esi, 1
    inc     eax
    cmp     eax, esi
    push    edi
    jle     short loc_49FFD6
    mov     ebp, [esp+0Ch+arg_4]
    lea     edi, [ebx+15Dh]

    loc_49FFB3:                             ; CODE XREF: sub_49FF90+44j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_49FFD9
    movsx   ecx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_49FFB3

    loc_49FFD6:                             ; CODE XREF: sub_49FF90+17j
    or      esi, 0FFFFFFFFh

    loc_49FFD9:                             ; CODE XREF: sub_49FF90+31j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_49FFFA
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    lea     ecx, [esi+eax*4]
    lea     eax, [ebx+ecx*2]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_49FFFA:                             ; CODE XREF: sub_49FF90+4Cj
    push    offset aErrorInGuiLayo          ; lpText
    call    sub_4B6290
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    8
    sub_49FF90 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0010(int,char *)
    sub_4A0010 proc near                    ; CODE XREF: sub_440D70+103p
                                            ; sub_441080+AFp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    movsx   eax, word ptr [ebx+0B6h]
    mov     esi, 1
    inc     eax
    cmp     eax, esi
    push    edi
    jle     short loc_4A0056
    mov     ebp, [esp+0Ch+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A0033:                             ; CODE XREF: sub_4A0010+44j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A0059
    movsx   ecx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_4A0033

    loc_4A0056:                             ; CODE XREF: sub_4A0010+17j
    or      esi, 0FFFFFFFFh

    loc_4A0059:                             ; CODE XREF: sub_4A0010+31j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A007A
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    lea     ecx, [esi+eax*4]
    lea     eax, [ebx+ecx*2]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A007A:                             ; CODE XREF: sub_4A0010+4Cj
    push    offset aErrorInGuiLayo          ; lpText
    call    sub_4B6290
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    8
    sub_4A0010 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A0090 proc near                    ; CODE XREF: sub_47AE60+A5Fp

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch+arg_0]
    push    esi
    push    edi
    mov     [esp+14h+var_4], offset Data
    mov     eax, [ebp+68h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A00CF
    lea     ecx, ds:0[eax*8]
    mov     edx, [ebp+18h]
    sub     ecx, eax
    mov     [ebp+6Ch], eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [eax+ecx*2]
    mov     ecx, [edx+4]
    lea     edx, [ecx+eax+33h]
    mov     [esp+14h+var_4], edx

    loc_4A00CF:                             ; CODE XREF: sub_4A0090+17j
    mov     eax, [ebp+18h]
    mov     esi, 1
    mov     ebx, [eax+4]
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4A0113
    lea     edi, [ebx+15Dh]

    loc_4A00EC:                             ; CODE XREF: sub_4A0090+81j
    push    10h                             ; size_t
    push    offset aHelptext                ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A0116
    movsx   edx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_4A00EC

    loc_4A0113:                             ; CODE XREF: sub_4A0090+54j
    or      esi, 0FFFFFFFFh

    loc_4A0116:                             ; CODE XREF: sub_4A0090+6Ej
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A016E
    mov     eax, [esp+14h+var_4]
    push    eax                             ; int
    call    sub_4C5740
    mov     ecx, esi
    mov     edi, eax
    shl     ecx, 3
    sub     ecx, esi
    xor     eax, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [esi+ecx*2]
    lea     ecx, [esi+edx*4]
    lea     edx, [esi+ecx*2]
    mov     ecx, [ebp+18h]
    mov     ecx, [ecx+4]
    lea     edx, [edx+ecx+0B6h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     dword ptr [ebp+0CCAh], 1

    loc_4A016E:                             ; CODE XREF: sub_4A0090+89j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_4A0090 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0180(int,char *)
    sub_4A0180 proc near                    ; CODE XREF: sub_448C70+169p
                                            ; sub_448C70+79Bp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    movsx   eax, word ptr [ebx+0B6h]
    mov     esi, 1
    inc     eax
    cmp     eax, esi
    push    edi
    jle     short loc_4A01C6
    mov     ebp, [esp+0Ch+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A01A3:                             ; CODE XREF: sub_4A0180+44j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A01C9
    movsx   ecx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_4A01A3

    loc_4A01C6:                             ; CODE XREF: sub_4A0180+17j
    or      esi, 0FFFFFFFFh

    loc_4A01C9:                             ; CODE XREF: sub_4A0180+31j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A01EA
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    lea     ecx, [esi+eax*4]
    lea     eax, [ebx+ecx*2]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A01EA:                             ; CODE XREF: sub_4A0180+4Cj
    push    offset aErrorInGuiLayo          ; lpText
    call    sub_4B6290
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    8
    sub_4A0180 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0200(int,char *)
    sub_4A0200 proc near                    ; CODE XREF: sub_41F0A0+215p
                                            ; sub_445B70+15p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    movsx   eax, word ptr [ebx+0B6h]
    mov     esi, 1
    inc     eax
    cmp     eax, esi
    push    edi
    jle     short loc_4A0246
    mov     ebp, [esp+0Ch+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A0223:                             ; CODE XREF: sub_4A0200+44j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A0249
    movsx   ecx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_4A0223

    loc_4A0246:                             ; CODE XREF: sub_4A0200+17j
    or      esi, 0FFFFFFFFh

    loc_4A0249:                             ; CODE XREF: sub_4A0200+31j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A026A
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    lea     ecx, [esi+eax*4]
    lea     eax, [ebx+ecx*2]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A026A:                             ; CODE XREF: sub_4A0200+4Cj
    push    offset aErrorInGuiLayo          ; lpText
    call    sub_4B6290
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    8
    sub_4A0200 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0280(int,char *)
    sub_4A0280 proc near                    ; CODE XREF: sub_444A20+C2p
                                            ; sub_444CB0+2Ap ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    movsx   eax, word ptr [ebx+0B6h]
    mov     esi, 1
    inc     eax
    cmp     eax, esi
    push    edi
    jle     short loc_4A02C6
    mov     ebp, [esp+0Ch+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A02A3:                             ; CODE XREF: sub_4A0280+44j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A02C9
    movsx   ecx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_4A02A3

    loc_4A02C6:                             ; CODE XREF: sub_4A0280+17j
    or      esi, 0FFFFFFFFh

    loc_4A02C9:                             ; CODE XREF: sub_4A0280+31j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A02EA
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    lea     ecx, [esi+eax*4]
    lea     eax, [ebx+ecx*2]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A02EA:                             ; CODE XREF: sub_4A0280+4Cj
    push    offset aErrorInGuiLayo          ; lpText
    call    sub_4B6290
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    8
    sub_4A0280 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0300(int,int,char *)
    sub_4A0300 proc near                    ; CODE XREF: .text:004261BAp
                                            ; .text:004261E0p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_4]
    cmp     ecx, 0FFFFFFFFh
    jnz     short loc_4A030E
    xor     eax, eax
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A030E:                             ; CODE XREF: sub_4A0300+7j
    mov     eax, [esp+arg_8]
    push    10h                             ; size_t
    push    eax                             ; char *
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     eax, [esp+8+arg_0]
    add     eax, ecx
    lea     ecx, [eax+edx*2+2]
    push    ecx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    neg     eax
    sbb     eax, eax
    inc     eax
    retn    0Ch
    sub_4A0300 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A0340 proc near                    ; CODE XREF: sub_4A1110+86p
                                            ; sub_4A11C0+32p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_4]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_0]
    push    esi
    push    edi
    mov     eax, [ebp+18h]
    mov     ebx, [eax+4]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     eax, ebx
    add     eax, ecx
    lea     eax, [eax+edx*2]
    mov     [esp+10h+arg_0], eax
    mov     dl, [eax+1]
    test    dl, dl
    jz      short loc_4A03E3
    movsx   edx, word ptr [ebx+0B6h]
    mov     edi, 1
    inc     edx
    cmp     edx, edi
    lea     esi, [ebx+15Bh]
    jle     short loc_4A03E3
    jmp     short loc_4A0395
    ; ---------------------------------------------------------------------------

    loc_4A038D:                             ; CODE XREF: sub_4A0340+A1j
    mov     ecx, [esp+10h+arg_4]
    mov     eax, [esp+10h+arg_0]

    loc_4A0395:                             ; CODE XREF: sub_4A0340+4Bj
    cmp     byte ptr [esi], 1
    jnz     short loc_4A03D0
    cmp     edi, ecx
    jz      short loc_4A03D0
    mov     cl, [esi+1]
    mov     dl, [eax+1]
    cmp     cl, dl
    jnz     short loc_4A03D0
    cmp     word ptr [esi+138h], 0
    jz      short loc_4A03D0
    push    edi
    push    ebp
    mov     word ptr [esi+138h], 0
    call    sub_4A5F40
    mov     eax, [ebp+18h]
    test    eax, eax
    jz      short loc_4A03D0
    mov     dword ptr [eax+14h], 1

    loc_4A03D0:                             ; CODE XREF: sub_4A0340+58j
                                            ; sub_4A0340+5Cj ...
    movsx   edx, word ptr [ebx+0B6h]
    inc     edi
    add     esi, 15Bh
    inc     edx
    cmp     edi, edx
    jl      short loc_4A038D

    loc_4A03E3:                             ; CODE XREF: sub_4A0340+32j
                                            ; sub_4A0340+49j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A0340 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A03F0 proc near                    ; CODE XREF: sub_41A120+306p
                                            ; sub_41A120+365p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    mov     ecx, [eax+18h]
    mov     eax, ebp
    shl     eax, 3
    mov     ecx, [ecx+4]
    sub     eax, ebp
    push    esi
    push    edi
    lea     edx, [eax+eax*2]
    lea     eax, [ebp+edx*2+0]
    lea     edx, [ebp+eax*4+0]
    mov     eax, ecx
    add     eax, ebp
    lea     esi, [eax+edx*2]
    mov     edx, [esp+10h+arg_8]
    mov     [esi+29h], dl
    mov     al, [esi]
    cmp     al, 4
    jnz     short loc_4A0459
    xor     edi, edi
    cmp     [ecx+0B6h], di
    jl      short loc_4A04A9
    lea     eax, [ecx+29h]

    loc_4A0436:                             ; CODE XREF: sub_4A03F0+65j
    cmp     byte ptr [eax-29h], 1
    jnz     short loc_4A0446
    mov     bl, [eax-28h]
    cmp     bl, [esi+1]
    jnz     short loc_4A0446
    mov     [eax], dl

    loc_4A0446:                             ; CODE XREF: sub_4A03F0+4Aj
                                            ; sub_4A03F0+52j
    movsx   ebx, word ptr [ecx+0B6h]
    inc     edi
    add     eax, 15Bh
    cmp     edi, ebx
    jle     short loc_4A0436
    jmp     short loc_4A04A9
    ; ---------------------------------------------------------------------------

    loc_4A0459:                             ; CODE XREF: sub_4A03F0+36j
    cmp     al, 2
    jnz     short loc_4A04A9
    test    edx, edx
    jnz     short loc_4A04D2
    movsx   eax, word ptr [ecx+0B6h]
    mov     bl, [esi+1]
    mov     edx, 1
    lea     esi, [eax+1]
    cmp     esi, edx
    jle     short loc_4A0491
    lea     eax, [ecx+15Bh]

    loc_4A047D:                             ; CODE XREF: sub_4A03F0+9Fj
    cmp     byte ptr [eax], 4
    jnz     short loc_4A0487
    cmp     [eax+1], bl
    jz      short loc_4A0493

    loc_4A0487:                             ; CODE XREF: sub_4A03F0+90j
    inc     edx
    add     eax, 15Bh
    cmp     edx, esi
    jl      short loc_4A047D

    loc_4A0491:                             ; CODE XREF: sub_4A03F0+85j
    xor     edx, edx

    loc_4A0493:                             ; CODE XREF: sub_4A03F0+95j
    cmp     edx, 0FFFFFFFFh
    jz      short loc_4A04A5
    mov     ecx, [esp+10h+arg_0]
    push    0
    push    edx
    push    ecx
    call    sub_4A03F0

    loc_4A04A5:                             ; CODE XREF: sub_4A03F0+A6j
    mov     edx, [esp+10h+arg_8]

    loc_4A04A9:                             ; CODE XREF: sub_4A03F0+41j
                                            ; sub_4A03F0+67j ...
    test    edx, edx
    jnz     short loc_4A04D2
    mov     esi, [esp+10h+arg_0]
    mov     edx, [esi+18h]
    cmp     ebp, [edx+20h]
    jnz     short loc_4A04D6
    push    1
    push    esi
    call    sub_4A7960
    mov     dword ptr [esi+0CCAh], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A04D2:                             ; CODE XREF: sub_4A03F0+6Fj
                                            ; sub_4A03F0+BBj
    mov     esi, [esp+10h+arg_0]

    loc_4A04D6:                             ; CODE XREF: sub_4A03F0+C7j
    mov     dword ptr [esi+0CCAh], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_4A03F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A04F0(int,char *)
    sub_4A04F0 proc near                    ; CODE XREF: sub_443480+6Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    mov     esi, 1
    push    edi
    mov     ebx, [ecx+4]
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edx, esi
    jle     short loc_4A053C
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A0519:                             ; CODE XREF: sub_4A04F0+4Aj
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A053F
    movsx   eax, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     eax
    cmp     esi, eax
    jl      short loc_4A0519

    loc_4A053C:                             ; CODE XREF: sub_4A04F0+1Dj
    or      esi, 0FFFFFFFFh

    loc_4A053F:                             ; CODE XREF: sub_4A04F0+37j
    cmp     esi, 0FFFFFFFFh
    jnz     short loc_4A054D
    or      al, 0FFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A054D:                             ; CODE XREF: sub_4A04F0+52j
    mov     eax, esi
    pop     edi
    shl     eax, 3
    sub     eax, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    lea     eax, [esi+edx*4]
    lea     ecx, [ebx+eax*2]
    mov     al, [ecx+esi+29h]
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A04F0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0570(int,char *,int)
    sub_4A0570 proc near                    ; CODE XREF: .text:0041A991p
                                            ; .text:0041A9E6p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+18h]
    push    edi
    test    eax, eax
    jz      short loc_4A05D8
    mov     ebx, [eax+4]
    mov     esi, 1
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4A05C0
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A059D:                             ; CODE XREF: sub_4A0570+4Ej
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A05C3
    movsx   edx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_4A059D

    loc_4A05C0:                             ; CODE XREF: sub_4A0570+21j
    or      esi, 0FFFFFFFFh

    loc_4A05C3:                             ; CODE XREF: sub_4A0570+3Bj
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A05D8
    mov     eax, [esp+10h+arg_8]
    mov     ecx, [esp+10h+arg_0]
    push    eax
    push    esi
    push    ecx
    call    sub_4A03F0

    loc_4A05D8:                             ; CODE XREF: sub_4A0570+Dj
                                            ; sub_4A0570+56j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_4A0570 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A05E0 proc near                    ; CODE XREF: sub_4A07D0+98p
                                            ; sub_4A09C0+97p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_4]
    sub     esp, 8
    cmp     ecx, 0FFFFFFFFh
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      loc_4A07C4
    mov     eax, [esp+18h+arg_0]
    mov     edx, [eax+18h]
    mov     eax, ecx
    shl     eax, 3
    mov     ebx, [edx+4]
    sub     eax, ecx
    mov     [esp+18h+arg_0], ebx
    lea     eax, [eax+eax*2]
    lea     edx, [ecx+eax*2]
    lea     eax, [ecx+edx*4]
    mov     edx, ebx
    add     edx, ecx
    lea     esi, [edx+eax*2]
    mov     [esp+18h+var_8], esi
    mov     dl, [esi]
    cmp     dl, 1
    jnz     short loc_4A0631
    test    dword ptr [esi+1Bh], 10000h
    jnz     loc_4A07C4

    loc_4A0631:                             ; CODE XREF: sub_4A05E0+42j
    cmp     dl, 5
    jnz     short loc_4A0650
    lea     edi, [esi+136h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_4A07C4
    cmp     dl, dl
    jz      short loc_4A0659

    loc_4A0650:                             ; CODE XREF: sub_4A05E0+54j
    cmp     dl, 1
    jnz     loc_4A07C4

    loc_4A0659:                             ; CODE XREF: sub_4A05E0+6Ej
    cmp     dl, 1
    jnz     short loc_4A06A2
    mov     al, [esi+136h]
    test    al, al
    jz      short loc_4A0679
    mov     byte ptr [esi+13Ah], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A0679:                             ; CODE XREF: sub_4A05E0+86j
    cmp     dl, 1
    jnz     short loc_4A06A2
    lea     edx, [esi+0B6h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_4A07C4
    mov     [esi+13Ah], al
    mov     [esp+18h+arg_4], edx
    jmp     short loc_4A06B8
    ; ---------------------------------------------------------------------------

    loc_4A06A2:                             ; CODE XREF: sub_4A05E0+7Cj
                                            ; sub_4A05E0+9Cj
    cmp     dl, 5
    jnz     short loc_4A06B8
    lea     eax, [esi+0B6h]
    mov     byte ptr [esi+147h], 0
    mov     [esp+18h+arg_4], eax

    loc_4A06B8:                             ; CODE XREF: sub_4A05E0+C0j
                                            ; sub_4A05E0+C5j
    mov     edi, [esp+18h+arg_4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     [esp+18h+var_4], ecx
    jz      loc_4A07C4
    xor     ebp, ebp
    test    ecx, ecx
    jle     loc_4A07C4

    loc_4A06DA:                             ; CODE XREF: sub_4A05E0+1A4j
    mov     edx, [esp+18h+arg_4]
    cmp     byte ptr [ebp+edx+0], 20h
    jz      loc_4A0781
    xor     edi, edi
    cmp     [ebx+0B6h], di
    jl      short loc_4A0772
    mov     esi, ebx

    loc_4A06F6:                             ; CODE XREF: sub_4A05E0+186j
    mov     al, [esi]
    cmp     al, 1
    jnz     short loc_4A0726
    movsx   eax, byte ptr [esi+13Ah]
    push    eax                             ; int
    call    _tolower
    mov     ecx, [esp+1Ch+arg_4]
    add     esp, 4
    mov     ebx, eax
    movsx   edx, byte ptr [ebp+ecx+0]
    push    edx                             ; int
    call    _tolower
    add     esp, 4
    cmp     ebx, eax
    jz      short loc_4A076A
    jmp     short loc_4A0752
    ; ---------------------------------------------------------------------------

    loc_4A0726:                             ; CODE XREF: sub_4A05E0+11Aj
    cmp     al, 5
    jnz     short loc_4A0756
    movsx   eax, byte ptr [esi+147h]
    push    eax                             ; int
    call    _tolower
    mov     ecx, [esp+1Ch+arg_4]
    add     esp, 4
    mov     ebx, eax
    movsx   edx, byte ptr [ebp+ecx+0]
    push    edx                             ; int
    call    _tolower
    add     esp, 4
    cmp     ebx, eax
    jz      short loc_4A076A

    loc_4A0752:                             ; CODE XREF: sub_4A05E0+144j
    mov     ebx, [esp+18h+arg_0]

    loc_4A0756:                             ; CODE XREF: sub_4A05E0+148j
    movsx   eax, word ptr [ebx+0B6h]
    inc     edi
    add     esi, 15Bh
    cmp     edi, eax
    jle     short loc_4A06F6
    jmp     short loc_4A076E
    ; ---------------------------------------------------------------------------

    loc_4A076A:                             ; CODE XREF: sub_4A05E0+142j
                                            ; sub_4A05E0+170j
    mov     ebx, [esp+18h+arg_0]

    loc_4A076E:                             ; CODE XREF: sub_4A05E0+188j
    mov     esi, [esp+18h+var_8]

    loc_4A0772:                             ; CODE XREF: sub_4A05E0+112j
    movsx   ecx, word ptr [ebx+0B6h]
    cmp     edi, ecx
    jg      short loc_4A0794
    mov     ecx, [esp+18h+var_4]

    loc_4A0781:                             ; CODE XREF: sub_4A05E0+103j
    inc     ebp
    cmp     ebp, ecx
    jl      loc_4A06DA
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A0794:                             ; CODE XREF: sub_4A05E0+19Bj
    mov     al, [esi]
    cmp     al, 1
    jnz     short loc_4A07B2
    mov     edx, [esp+18h+arg_4]
    mov     al, [ebp+edx+0]
    mov     [esi+13Ah], al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A07B2:                             ; CODE XREF: sub_4A05E0+1B8j
    cmp     al, 5
    jnz     short loc_4A07C4
    mov     ecx, [esp+18h+arg_4]
    mov     dl, [ebp+ecx+0]
    mov     [esi+147h], dl

    loc_4A07C4:                             ; CODE XREF: sub_4A05E0+Ej
                                            ; sub_4A05E0+4Bj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    sub_4A05E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A07D0 proc near                    ; CODE XREF: .text:004265C9p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+18h]
    push    edi
    test    eax, eax
    jz      loc_4A086D
    mov     edi, [eax+4]
    mov     esi, 1
    movsx   ecx, word ptr [edi+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4A0824
    mov     ebp, [esp+10h+arg_4]
    lea     ebx, [edi+15Dh]

    loc_4A0801:                             ; CODE XREF: sub_4A07D0+52j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A0827
    movsx   edx, word ptr [edi+0B6h]
    inc     esi
    add     ebx, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_4A0801

    loc_4A0824:                             ; CODE XREF: sub_4A07D0+25j
    or      esi, 0FFFFFFFFh

    loc_4A0827:                             ; CODE XREF: sub_4A07D0+3Fj
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A086D
    mov     eax, [esp+10h+arg_8]
    push    80h                             ; size_t
    push    eax                             ; char *
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     edi, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    lea     eax, [esi+edx*4]
    lea     ecx, [edi+eax*2+0B6h]
    push    ecx                             ; char *
    call    _strncpy
    mov     eax, [esp+1Ch+arg_0]
    add     esp, 0Ch
    push    esi
    push    eax
    mov     dword ptr [eax+0CCAh], 1
    call    sub_4A05E0

    loc_4A086D:                             ; CODE XREF: sub_4A07D0+Dj
                                            ; sub_4A07D0+5Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_4A07D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A0880 proc near                    ; CODE XREF: .text:0044B39Ep
                                            ; .text:0044B66Ep ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     edx, [esp+arg_4]
    push    ebx
    mov     eax, edx
    mov     ebx, [esp+4+arg_0]
    shl     eax, 3
    sub     eax, edx
    mov     ecx, [ebx+18h]
    push    ebp
    mov     ebp, [esp+8+arg_8]
    lea     eax, [eax+eax*2]
    mov     ecx, [ecx+4]
    push    esi
    push    edi
    lea     eax, [edx+eax*2]
    mov     edi, ebp
    lea     eax, [edx+eax*4]
    lea     eax, [edx+eax*2]
    lea     esi, [ecx+eax+0B6h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esp+10h+arg_0], esi
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+10h+arg_0]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    cmp     [ebx+64h], edx
    jnz     short loc_4A08E9
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     [ebx+74h], ecx

    loc_4A08E9:                             ; CODE XREF: sub_4A0880+58j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_4A0880 endp

    ; ---------------------------------------------------------------------------
    sub     esp, 8Ch
    mov     eax, [esp+90h]
    push    ebx
    push    ebp
    push    esi
    mov     edx, [eax+18h]
    mov     eax, [esp+0A0h]
    mov     ecx, eax
    push    edi
    shl     ecx, 3
    sub     ecx, eax
    lea     ebx, [esp+1Ch]
    mov     dword ptr [esp+10h], 0
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     ecx, [eax+ecx*2]
    mov     eax, [edx+4]
    add     eax, ecx
    mov     [esp+14h], eax
    mov     cl, [eax+136h]
    lea     edi, [eax+0B6h]
    test    cl, cl
    mov     [esp+18h], edi
    mov     ebp, edi
    jbe     short loc_4A09A7

    loc_4A0949:                             ; CODE XREF: .text:004A09A1j
    push    ebp
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     edx, [esp+14h]
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ebp
    lea     ebx, [ebx+ecx+1]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+10h]
    not     ecx
    dec     ecx
    inc     eax
    mov     [esp+10h], eax
    lea     ebp, [ebp+ecx+1]
    xor     ecx, ecx
    mov     cl, [edx+136h]
    cmp     eax, ecx
    jl      short loc_4A0949
    mov     edi, [esp+18h]

    loc_4A09A7:                             ; CODE XREF: .text:004A0947j
    mov     ecx, 20h
    lea     esi, [esp+1Ch]
    rep movsd
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8Ch
    retn    8
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A09C0 proc near                    ; CODE XREF: .text:00444537p
                                            ; sub_44474E+C9p ...

    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 8Ch
    push    ebx
    mov     ebx, [esp+90h+arg_4]
    cmp     ebx, 0FFFFFFFFh
    push    edi
    jz      loc_4A0BD6
    mov     edi, [esp+94h+arg_0]
    mov     eax, [edi+18h]
    test    eax, eax
    jz      loc_4A0BD6
    push    esi
    push    ebp
    mov     ebp, [eax+4]
    mov     eax, [esp+9Ch+arg_8]
    push    eax                             ; int
    call    sub_4C5740
    mov     edx, eax
    mov     eax, ebx
    shl     eax, 3
    sub     eax, ebx
    lea     ecx, [eax+eax*2]
    lea     eax, [ebx+ecx*2]
    lea     ecx, [ebx+eax*4]
    xor     eax, eax
    lea     esi, [ebx+ecx*2]
    mov     [esp+9Ch+var_8C], esi
    mov     al, [ebp+esi+0]
    dec     eax
    jz      loc_4A0AD9
    sub     eax, 2
    jz      short loc_4A0A61
    sub     eax, 2
    jnz     loc_4A0BC3
    push    80h                             ; size_t
    push    edx                             ; char *
    lea     edx, [ebp+esi+0B6h]
    push    edx                             ; char *
    call    _strncpy
    mov     al, [ebp+esi+136h]
    add     esp, 0Ch
    test    al, al
    jz      loc_4A0BC3
    push    ebx
    push    edi
    call    sub_4A05E0
    jmp     loc_4A0BC3
    ; ---------------------------------------------------------------------------

    loc_4A0A61:                             ; CODE XREF: sub_4A09C0+65j
    test    edx, edx
    jz      short loc_4A0ABD
    mov     eax, [edi+18h]
    mov     edi, edx
    mov     ecx, [eax+4]
    xor     eax, eax
    lea     esi, [ecx+esi+0B6h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     [esp+9Ch+var_88], esi
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+9Ch+var_88]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+9Ch+arg_0]
    cmp     [ecx+64h], ebx
    jnz     short loc_4A0AB9
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [esp+9Ch+arg_0]
    repne scasb
    not     ecx
    dec     ecx
    mov     [edx+74h], ecx

    loc_4A0AB9:                             ; CODE XREF: sub_4A09C0+E1j
    mov     esi, [esp+9Ch+var_8C]

    loc_4A0ABD:                             ; CODE XREF: sub_4A09C0+A3j
    mov     eax, [esp+9Ch+arg_C]
    test    eax, eax
    jz      loc_4A0BC3
    mov     [ebp+esi+138h], ax
    jmp     loc_4A0BC3
    ; ---------------------------------------------------------------------------

    loc_4A0AD9:                             ; CODE XREF: sub_4A09C0+5Cj
    lea     edi, [ebp+esi+0B6h]
    push    80h                             ; size_t
    push    edx                             ; char *
    push    edi                             ; char *
    call    _strncpy
    mov     eax, [esp+0A8h+arg_0]
    add     esp, 0Ch
    push    ebx
    push    eax
    call    sub_4A05E0
    mov     al, [ebp+esi+136h]
    test    al, al
    jz      loc_4A0BC3
    mov     ecx, edi
    mov     al, [ecx]
    test    al, al
    jz      short loc_4A0B23

    loc_4A0B14:                             ; CODE XREF: sub_4A09C0+161j
    cmp     al, 7Ch
    jnz     short loc_4A0B1B
    mov     byte ptr [ecx], 0

    loc_4A0B1B:                             ; CODE XREF: sub_4A09C0+156j
    mov     al, [ecx+1]
    inc     ecx
    test    al, al
    jnz     short loc_4A0B14

    loc_4A0B23:                             ; CODE XREF: sub_4A09C0+152j
    mov     ecx, [esp+9Ch+arg_0]
    lea     ebx, [esp+9Ch+var_80]
    mov     [esp+9Ch+var_8C], 0
    mov     edx, [ecx+18h]
    mov     eax, [edx+4]
    add     eax, esi
    mov     [esp+9Ch+var_88], eax
    mov     cl, [eax+136h]
    lea     edi, [eax+0B6h]
    test    cl, cl
    mov     [esp+9Ch+var_84], edi
    mov     ebp, edi
    jbe     short loc_4A0BB8

    loc_4A0B58:                             ; CODE XREF: sub_4A09C0+1F2j
    push    ebp                             ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [esp+9Ch+var_88]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ebp
    lea     ebx, [ebx+ecx+1]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+9Ch+var_8C]
    not     ecx
    dec     ecx
    inc     eax
    mov     [esp+9Ch+var_8C], eax
    lea     ebp, [ebp+ecx+1]
    xor     ecx, ecx
    mov     cl, [edx+136h]
    cmp     eax, ecx
    jl      short loc_4A0B58
    mov     edi, [esp+9Ch+var_84]

    loc_4A0BB8:                             ; CODE XREF: sub_4A09C0+196j
    mov     ecx, 20h
    lea     esi, [esp+9Ch+var_80]
    rep movsd

    loc_4A0BC3:                             ; CODE XREF: sub_4A09C0+6Aj
                                            ; sub_4A09C0+8Fj ...
    mov     eax, [esp+9Ch+arg_0]
    pop     ebp
    pop     esi
    mov     dword ptr [eax+0CCAh], 1

    loc_4A0BD6:                             ; CODE XREF: sub_4A09C0+12j
                                            ; sub_4A09C0+24j
    pop     edi
    pop     ebx
    add     esp, 8Ch
    retn    10h
    sub_4A09C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A0BF0 proc near                    ; CODE XREF: sub_41F0A0+31Cp
                                            ; sub_426200+167p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+18h]
    push    edi
    test    eax, eax
    jz      short loc_4A0C5D
    mov     ebx, [eax+4]
    mov     esi, 1
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4A0C40
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A0C1D:                             ; CODE XREF: sub_4A0BF0+4Ej
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A0C43
    movsx   edx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_4A0C1D

    loc_4A0C40:                             ; CODE XREF: sub_4A0BF0+21j
    or      esi, 0FFFFFFFFh

    loc_4A0C43:                             ; CODE XREF: sub_4A0BF0+3Bj
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A0C5D
    mov     eax, [esp+10h+arg_C]
    mov     ecx, [esp+10h+arg_8]
    mov     edx, [esp+10h+arg_0]
    push    eax
    push    ecx
    push    esi
    push    edx
    call    sub_4A09C0

    loc_4A0C5D:                             ; CODE XREF: sub_4A0BF0+Dj
                                            ; sub_4A0BF0+56j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_4A0BF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0C70(int,char *,int)
    sub_4A0C70 proc near                    ; CODE XREF: sub_476EF0+279p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+18h]
    push    edi
    test    eax, eax
    jz      short loc_4A0CF0
    mov     esi, [eax+4]
    mov     edi, 1
    movsx   ecx, word ptr [esi+0B6h]
    inc     ecx
    cmp     ecx, edi
    jle     short loc_4A0CC0
    mov     ebp, [esp+10h+arg_4]
    lea     ebx, [esi+15Dh]

    loc_4A0C9D:                             ; CODE XREF: sub_4A0C70+4Ej
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A0CF7
    movsx   edx, word ptr [esi+0B6h]
    inc     edi
    add     ebx, 15Bh
    inc     edx
    cmp     edi, edx
    jl      short loc_4A0C9D

    loc_4A0CC0:                             ; CODE XREF: sub_4A0C70+21j
    or      eax, 0FFFFFFFFh

    loc_4A0CC3:                             ; CODE XREF: sub_4A0C70+89j
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A0CF0
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    add     esi, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esp+10h+arg_8]
    mov     eax, [esp+10h+arg_0]
    mov     [esi+ecx*2+1Fh], edx
    mov     dword ptr [eax+0CCAh], 1

    loc_4A0CF0:                             ; CODE XREF: sub_4A0C70+Dj
                                            ; sub_4A0C70+56j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A0CF7:                             ; CODE XREF: sub_4A0C70+3Bj
    mov     eax, edi
    jmp     short loc_4A0CC3
    sub_4A0C70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0D00(int,char *,int)
    sub_4A0D00 proc near                    ; CODE XREF: sub_441C30+100p
                                            ; sub_441C30+1B5p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+10h+arg_0]
    push    edi
    mov     [esp+14h+var_4], 0
    mov     eax, [esi+18h]
    test    eax, eax
    jnz     short loc_4A0D22
    push    offset aInternalError           ; lpText
    call    sub_4B6290

    loc_4A0D22:                             ; CODE XREF: sub_4A0D00+16j
    mov     eax, [esi+18h]
    mov     edi, 1
    mov     esi, [eax+4]
    movsx   ecx, word ptr [esi+0B6h]
    inc     ecx
    cmp     ecx, edi
    jle     short loc_4A0D6A
    mov     ebp, [esp+14h+arg_4]
    lea     ebx, [esi+15Dh]

    loc_4A0D43:                             ; CODE XREF: sub_4A0D00+68j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      loc_4A0DEA
    movsx   edx, word ptr [esi+0B6h]
    inc     edi
    add     ebx, 15Bh
    inc     edx
    cmp     edi, edx
    jl      short loc_4A0D43

    loc_4A0D6A:                             ; CODE XREF: sub_4A0D00+37j
    or      eax, 0FFFFFFFFh

    loc_4A0D6D:                             ; CODE XREF: sub_4A0D00+ECj
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A0DDC
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    xor     eax, eax
    mov     al, [esi+ecx*2]
    lea     ecx, [esi+ecx*2]
    dec     eax
    jz      short loc_4A0D99
    sub     eax, 2
    jz      short loc_4A0D99
    sub     eax, 2
    jnz     short loc_4A0DA3

    loc_4A0D99:                             ; CODE XREF: sub_4A0D00+8Dj
                                            ; sub_4A0D00+92j
    add     ecx, 0B6h
    mov     [esp+14h+var_4], ecx

    loc_4A0DA3:                             ; CODE XREF: sub_4A0D00+97j
    mov     ebx, [esp+14h+var_4]
    test    ebx, ebx
    jz      short loc_4A0DE0
    mov     edx, [esp+14h+arg_8]
    test    edx, edx
    jz      short loc_4A0DE0
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, ebx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A0DDC:                             ; CODE XREF: sub_4A0D00+70j
    mov     ebx, [esp+14h+var_4]

    loc_4A0DE0:                             ; CODE XREF: sub_4A0D00+A9j
                                            ; sub_4A0D00+B1j
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A0DEA:                             ; CODE XREF: sub_4A0D00+51j
    mov     eax, edi
    jmp     loc_4A0D6D
    sub_4A0D00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0E00(int,char *,char *)
    sub_4A0E00 proc near                    ; CODE XREF: sub_47A910+175p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     eax, [ecx]
    test    eax, eax
    mov     ebx, [eax+4]
    jz      loc_4A0F1D
    movsx   edx, word ptr [ebx+0B6h]
    mov     esi, 1
    inc     edx
    cmp     edx, esi
    jle     short loc_4A0E5A
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A0E33:                             ; CODE XREF: sub_4A0E00+58j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      loc_4A0F24
    movsx   eax, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     eax
    cmp     esi, eax
    jl      short loc_4A0E33

    loc_4A0E5A:                             ; CODE XREF: sub_4A0E00+27j
    or      edx, 0FFFFFFFFh

    loc_4A0E5D:                             ; CODE XREF: sub_4A0E00+126j
    cmp     edx, 0FFFFFFFFh
    jz      loc_4A0F1D
    mov     eax, edx
    shl     eax, 3
    sub     eax, edx
    lea     ecx, [eax+eax*2]
    lea     eax, [edx+ecx*2]
    lea     ecx, [edx+eax*4]
    xor     eax, eax
    lea     esi, [edx+ecx*2]
    mov     al, [ebx+esi]
    dec     eax
    jz      short loc_4A0EF5
    sub     eax, 2
    jz      short loc_4A0EA3
    sub     eax, 2
    jnz     loc_4A0F0F
    mov     edx, [esp+10h+arg_8]
    push    80h
    lea     eax, [ebx+esi+0B6h]
    push    edx
    push    eax
    jmp     short loc_4A0F07
    ; ---------------------------------------------------------------------------

    loc_4A0EA3:                             ; CODE XREF: sub_4A0E00+84j
    mov     ecx, [esp+10h+arg_0]
    mov     ebx, [esp+10h+arg_8]
    mov     edi, ebx
    mov     eax, [ecx+18h]
    mov     ecx, [eax+4]
    xor     eax, eax
    lea     ebp, [ecx+esi+0B6h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+10h+arg_0]
    cmp     [ecx+64h], edx
    jnz     short loc_4A0F0F
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [esp+10h+arg_0]
    repne scasb
    not     ecx
    dec     ecx
    mov     [edx+74h], ecx
    jmp     short loc_4A0F0F
    ; ---------------------------------------------------------------------------

    loc_4A0EF5:                             ; CODE XREF: sub_4A0E00+7Fj
    mov     eax, [esp+10h+arg_8]
    push    80h                             ; size_t
    lea     ecx, [ebx+esi+0B6h]
    push    eax                             ; char *
    push    ecx                             ; char *

    loc_4A0F07:                             ; CODE XREF: sub_4A0E00+A1j
    call    _strncpy
    add     esp, 0Ch

    loc_4A0F0F:                             ; CODE XREF: sub_4A0E00+89j
                                            ; sub_4A0E00+DEj ...
    mov     edx, [esp+10h+arg_0]
    mov     dword ptr [edx+0CCAh], 1

    loc_4A0F1D:                             ; CODE XREF: sub_4A0E00+12j
                                            ; sub_4A0E00+60j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A0F24:                             ; CODE XREF: sub_4A0E00+41j
    mov     edx, esi
    jmp     loc_4A0E5D
    sub_4A0E00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A0F30 proc near                    ; CODE XREF: sub_443480+78p
                                            ; sub_447B10+6DEp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    mov     eax, [esp+arg_0]
    mov     ecx, [eax+18h]
    mov     eax, [ecx+4]
    movsx   eax, word ptr [edx+eax+138h]
    retn    8
    sub_4A0F30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A0F60(int,char *)
    sub_4A0F60 proc near                    ; CODE XREF: sub_447B10+BD9p
                                            ; sub_447B10+F73p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     edi, 1
    mov     esi, [ecx+4]
    movsx   edx, word ptr [esi+0B6h]
    inc     edx
    cmp     edx, edi
    jle     short loc_4A0FAC
    mov     ebp, [esp+10h+arg_4]
    lea     ebx, [esi+15Dh]

    loc_4A0F89:                             ; CODE XREF: sub_4A0F60+4Aj
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A0FEC
    movsx   eax, word ptr [esi+0B6h]
    inc     edi
    add     ebx, 15Bh
    inc     eax
    cmp     edi, eax
    jl      short loc_4A0F89

    loc_4A0FAC:                             ; CODE XREF: sub_4A0F60+1Dj
    or      eax, 0FFFFFFFFh

    loc_4A0FAF:                             ; CODE XREF: sub_4A0F60+8Ej
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A0FE2
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2]
    cmp     cl, 1
    jnz     short loc_4A0FE2
    xor     edx, edx
    mov     dl, [eax+137h]
    mov     eax, edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A0FE2:                             ; CODE XREF: sub_4A0F60+52j
                                            ; sub_4A0F60+6Fj
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A0FEC:                             ; CODE XREF: sub_4A0F60+37j
    mov     eax, edi
    jmp     short loc_4A0FAF
    sub_4A0F60 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A0FF0 proc near                    ; CODE XREF: sub_447150+1D4p
                                            ; sub_493BF0+C7p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+18h]
    mov     eax, [esp+arg_4]
    mov     edx, [ecx+4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [edx+ecx*2]
    mov     cl, [edx+ecx*2]
    cmp     cl, 1
    jnz     short loc_4A1028
    xor     edx, edx
    mov     dl, [eax+137h]
    mov     eax, edx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A1028:                             ; CODE XREF: sub_4A0FF0+29j
    or      eax, 0FFFFFFFFh
    retn    8
    sub_4A0FF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A1030 proc near                    ; CODE XREF: sub_45E5E0+3A6p
                                            ; sub_45E5E0+3DBp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+18h]
    mov     eax, [esp+arg_4]
    mov     edx, [ecx+4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [edx+ecx*2]
    mov     cl, [edx+ecx*2]
    cmp     cl, 1
    jnz     short loc_4A106D
    mov     dl, [esp+arg_8]
    mov     [eax+137h], dl
    mov     eax, 1
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A106D:                             ; CODE XREF: sub_4A1030+29j
    xor     eax, eax
    retn    0Ch
    sub_4A1030 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A1080(int,char *,char)
    sub_4A1080 proc near                    ; CODE XREF: sub_4455B0+508p
                                            ; sub_445ED0+4Fp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    mov     esi, 1
    push    edi
    mov     ebx, [ecx+4]
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edx, esi
    jle     short loc_4A10CC
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A10A9:                             ; CODE XREF: sub_4A1080+4Aj
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A10CF
    movsx   eax, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     eax
    cmp     esi, eax
    jl      short loc_4A10A9

    loc_4A10CC:                             ; CODE XREF: sub_4A1080+1Dj
    or      esi, 0FFFFFFFFh

    loc_4A10CF:                             ; CODE XREF: sub_4A1080+37j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A10FD
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    mov     cl, [esp+10h+arg_8]
    lea     eax, [esi+edx*4]
    mov     [ebx+eax*2+137h], cl
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A10FD:                             ; CODE XREF: sub_4A1080+52j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    0Ch
    sub_4A1080 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A1110(int,char *,int)
    sub_4A1110 proc near                    ; CODE XREF: sub_447B10+7EBp
                                            ; sub_448C70+34Dp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     edi, 1
    mov     esi, [ecx+4]
    movsx   edx, word ptr [esi+0B6h]
    inc     edx
    cmp     edx, edi
    jle     short loc_4A115C
    mov     ebp, [esp+10h+arg_4]
    lea     ebx, [esi+15Dh]

    loc_4A1139:                             ; CODE XREF: sub_4A1110+4Aj
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A11B0
    movsx   eax, word ptr [esi+0B6h]
    inc     edi
    add     ebx, 15Bh
    inc     eax
    cmp     edi, eax
    jl      short loc_4A1139

    loc_4A115C:                             ; CODE XREF: sub_4A1110+1Dj
    or      eax, 0FFFFFFFFh

    loc_4A115F:                             ; CODE XREF: sub_4A1110+A2j
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A11A7
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    mov     ecx, [esp+10h+arg_8]
    test    ecx, ecx
    lea     edx, [eax+edx*4]
    mov     [esi+edx*2+138h], cx
    mov     edx, [esp+10h+arg_0]
    mov     dword ptr [edx+0CCAh], 1
    jz      short loc_4A119B
    push    eax
    push    edx
    call    sub_4A0340

    loc_4A119B:                             ; CODE XREF: sub_4A1110+82j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A11A7:                             ; CODE XREF: sub_4A1110+52j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A11B0:                             ; CODE XREF: sub_4A1110+37j
    mov     eax, edi
    jmp     short loc_4A115F
    sub_4A1110 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A11C0 proc near                    ; CODE XREF: sub_419AC0+38p
                                            ; sub_41A120+4Ep ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= word ptr  0Ch

    mov     eax, [esp+arg_4]
    mov     edx, [esp+arg_0]
    mov     ecx, eax
    push    esi
    shl     ecx, 3
    sub     ecx, eax
    mov     esi, [edx+18h]
    push    edi
    mov     di, [esp+8+arg_8]
    lea     ecx, [ecx+ecx*2]
    mov     esi, [esi+4]
    push    eax
    push    edx
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     ecx, [eax+ecx*2]
    mov     [esi+ecx+138h], di
    call    sub_4A0340
    pop     edi
    pop     esi
    retn    0Ch
    sub_4A11C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A1200 proc near                    ; CODE XREF: sub_41A120+59p
                                            ; sub_41A120+9Ep ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    mov     eax, [esp+arg_4]
    push    esi
    mov     ecx, eax
    mov     esi, [esp+4+arg_0]
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    mov     eax, [esi+18h]
    mov     ecx, [eax+4]
    lea     eax, [edx+ecx+13Ch]
    mov     dl, [esp+4+arg_8]
    mov     cx, [eax]
    xor     dl, cl
    and     edx, 1
    xor     edx, ecx
    mov     [eax], dx
    mov     dword ptr [esi+0CCAh], 1
    pop     esi
    retn    0Ch
    sub_4A1200 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A1250(int,char *,char)
    sub_4A1250 proc near                    ; CODE XREF: sub_443CB0+148p
                                            ; sub_443CB0+161p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     edi, 1
    mov     esi, [ecx+4]
    movsx   edx, word ptr [esi+0B6h]
    inc     edx
    cmp     edx, edi
    jle     short loc_4A129C
    mov     ebp, [esp+10h+arg_4]
    lea     ebx, [esi+15Dh]

    loc_4A1279:                             ; CODE XREF: sub_4A1250+4Aj
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A12DA
    movsx   eax, word ptr [esi+0B6h]
    inc     edi
    add     ebx, 15Bh
    inc     eax
    cmp     edi, eax
    jl      short loc_4A1279

    loc_4A129C:                             ; CODE XREF: sub_4A1250+1Dj
    or      ecx, 0FFFFFFFFh

    loc_4A129F:                             ; CODE XREF: sub_4A1250+8Cj
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_4A12D3
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     cx, [esi+edx*2+13Ch]
    lea     eax, [esi+edx*2+13Ch]
    mov     dl, [esp+10h+arg_8]
    xor     dl, cl
    and     edx, 1
    xor     edx, ecx
    mov     [eax], dx

    loc_4A12D3:                             ; CODE XREF: sub_4A1250+52j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A12DA:                             ; CODE XREF: sub_4A1250+37j
    mov     ecx, edi
    jmp     short loc_4A129F
    sub_4A1250 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A12E0 proc near                    ; CODE XREF: sub_4A1450+5Fp
                                            ; .text:004A151Fp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     edi, [ecx+4]
    mov     ecx, [esp+10h+arg_4]
    cmp     ecx, 0FFFFFFFFh
    jz      loc_4A1424
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     eax, edi
    add     eax, ecx
    xor     ecx, ecx
    mov     cl, [eax+edx*2]
    lea     eax, [eax+edx*2]
    dec     ecx
    cmp     ecx, 0Bh
    ja      loc_4A1424
    xor     edx, edx
    mov     dl, ds:byte_4A1444[ecx]
    jmp     ds:off_4A142C[edx*4]

    loc_4A1330:                             ; DATA XREF: .text:004A1434o
    mov     edx, [esp+10h+arg_8]
    mov     esi, 1
    mov     [eax+157h], edx
    mov     al, [eax+1]
    movsx   ecx, word ptr [edi+0B6h]
    inc     ecx
    mov     byte ptr [esp+10h+arg_8], al
    cmp     ecx, esi
    jle     loc_4A1424
    lea     eax, [edi+297h]
    mov     ebp, 1800h

    loc_4A1361:                             ; CODE XREF: sub_4A12E0+BFj
    cmp     byte ptr [eax-13Ch], 1
    jnz     short loc_4A138F
    mov     cl, byte ptr [esp+10h+arg_8]
    mov     bl, [eax-13Bh]
    cmp     bl, cl
    jnz     short loc_4A138F
    test    [eax-121h], ebp
    jz      short loc_4A138F
    mov     cx, [eax]
    mov     bl, dl
    xor     bl, cl
    and     ebx, 1
    xor     ebx, ecx
    mov     [eax], bx

    loc_4A138F:                             ; CODE XREF: sub_4A12E0+88j
                                            ; sub_4A12E0+96j ...
    movsx   ecx, word ptr [edi+0B6h]
    inc     esi
    add     eax, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_4A1361
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A13A8:                             ; CODE XREF: sub_4A12E0+49j
                                            ; DATA XREF: .text:004A142Co
    mov     cx, [eax+13Ch]
    mov     dl, byte ptr [esp+10h+arg_8]
    xor     dl, cl
    and     edx, 1
    xor     edx, ecx
    mov     [eax+13Ch], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A13C8:                             ; CODE XREF: sub_4A12E0+49j
                                            ; DATA XREF: .text:004A1430o
    mov     ecx, [esp+10h+arg_8]
    test    ecx, ecx
    mov     ecx, [eax+1Bh]
    jz      short loc_4A13E0
    or      ch, 1
    mov     [eax+1Bh], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A13E0:                             ; CODE XREF: sub_4A12E0+F1j
    and     ch, 0FEh
    mov     [eax+1Bh], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A13ED:                             ; CODE XREF: sub_4A12E0+49j
                                            ; DATA XREF: .text:004A1438o
    mov     ecx, [eax+148h]
    mov     edx, [esp+10h+arg_8]
    xor     edx, ecx
    and     edx, 1
    xor     edx, ecx
    mov     [eax+148h], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A140B:                             ; CODE XREF: sub_4A12E0+49j
                                            ; DATA XREF: .text:004A143Co
    mov     cx, [eax+0BCh]
    mov     dl, byte ptr [esp+10h+arg_8]
    xor     dl, cl
    and     edx, 1
    xor     edx, ecx
    mov     [eax+0BCh], dx

    loc_4A1424:                             ; CODE XREF: sub_4A12E0+15j
                                            ; sub_4A12E0+3Bj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_4A12E0 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4A142C dd offset loc_4A13A8         ; DATA XREF: sub_4A12E0+49r
    dd offset loc_4A13C8
    dd offset loc_4A1330
    dd offset loc_4A13ED
    dd offset loc_4A140B
    dd offset loc_4A1424
    byte_4A1444 db 0                        ; DATA XREF: sub_4A12E0+43r
    ; ---------------------------------------------------------------------------
    add     ds:5050302h, eax
    add     eax, 4050505h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A1450 proc near                    ; CODE XREF: sub_4455B0+40Bp
                                            ; sub_447380+451p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    mov     esi, 1
    push    edi
    mov     ebx, [ecx+4]
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edx, esi
    jle     short loc_4A149C
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A1479:                             ; CODE XREF: sub_4A1450+4Aj
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A149F
    movsx   eax, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     eax
    cmp     esi, eax
    jl      short loc_4A1479

    loc_4A149C:                             ; CODE XREF: sub_4A1450+1Dj
    or      esi, 0FFFFFFFFh

    loc_4A149F:                             ; CODE XREF: sub_4A1450+37j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A14B4
    mov     ecx, [esp+10h+arg_8]
    mov     edx, [esp+10h+arg_0]
    push    ecx
    push    esi
    push    edx
    call    sub_4A12E0

    loc_4A14B4:                             ; CODE XREF: sub_4A1450+52j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_4A1450 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    mov     esi, 1
    push    edi
    mov     ebx, [ecx+4]
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edx, esi
    jle     short loc_4A150C
    mov     ebp, [esp+18h]
    lea     edi, [ebx+15Dh]

    loc_4A14E9:                             ; CODE XREF: .text:004A150Aj
    push    10h
    push    ebp
    push    edi
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A150F
    movsx   eax, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     eax
    cmp     esi, eax
    jl      short loc_4A14E9

    loc_4A150C:                             ; CODE XREF: .text:004A14DDj
    or      esi, 0FFFFFFFFh

    loc_4A150F:                             ; CODE XREF: .text:004A14F7j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A1524
    mov     ecx, [esp+1Ch]
    mov     edx, [esp+14h]
    push    ecx
    push    esi
    push    edx
    call    sub_4A12E0

    loc_4A1524:                             ; CODE XREF: .text:004A1512j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A1530(int,char *,char)
    sub_4A1530 proc near                    ; CODE XREF: .text:00477901p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    mov     esi, 1
    push    edi
    mov     ebx, [ecx+4]
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edx, esi
    jle     short loc_4A157C
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A1559:                             ; CODE XREF: sub_4A1530+4Aj
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A157F
    movsx   eax, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     eax
    cmp     esi, eax
    jl      short loc_4A1559

    loc_4A157C:                             ; CODE XREF: sub_4A1530+1Dj
    or      esi, 0FFFFFFFFh

    loc_4A157F:                             ; CODE XREF: sub_4A1530+37j
    mov     eax, esi
    mov     bl, [esp+10h+arg_8]
    shl     eax, 3
    sub     eax, esi
    pop     edi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    lea     eax, [esi+edx*4]
    lea     ecx, [esi+eax*2]
    mov     eax, [esp+0Ch+arg_0]
    pop     esi
    pop     ebp
    mov     edx, [eax+18h]
    mov     edx, [edx+4]
    mov     [ecx+edx+13Ah], bl
    mov     dword ptr [eax+0CCAh], 1
    pop     ebx
    retn    0Ch
    sub_4A1530 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A15C0 proc near                    ; CODE XREF: .text:0044AEA3p
                                            ; sub_4A7290+15Dp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    push    esi
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esp+4+arg_0]
    add     edx, eax
    mov     al, [edx+ecx*2]
    test    al, al
    lea     ecx, [edx+ecx*2]
    jnz     short loc_4A15F8
    mov     eax, [esp+4+arg_8]
    mov     dword ptr [eax], 0
    mov     dword ptr [eax+4], 0
    jmp     short loc_4A1609
    ; ---------------------------------------------------------------------------

    loc_4A15F8:                             ; CODE XREF: sub_4A15C0+23j
    movsx   edx, word ptr [ecx+13h]
    mov     eax, [esp+4+arg_8]
    mov     [eax], edx
    movsx   edx, word ptr [ecx+15h]
    mov     [eax+4], edx

    loc_4A1609:                             ; CODE XREF: sub_4A15C0+36j
    movsx   edx, word ptr [ecx+17h]
    mov     esi, [eax]
    lea     edx, [edx+esi-1]
    pop     esi
    mov     [eax+8], edx
    mov     edx, [eax+4]
    movsx   ecx, word ptr [ecx+19h]
    lea     ecx, [ecx+edx-1]
    mov     [eax+0Ch], ecx
    retn    0Ch
    sub_4A15C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A1630 proc near                    ; CODE XREF: sub_494290+18p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_0]
    push    esi
    cmp     byte ptr [ecx], 0
    jnz     short loc_4A164D
    mov     eax, [esp+4+arg_4]
    mov     dword ptr [eax], 0
    mov     dword ptr [eax+4], 0
    jmp     short loc_4A165E
    ; ---------------------------------------------------------------------------

    loc_4A164D:                             ; CODE XREF: sub_4A1630+8j
    movsx   edx, word ptr [ecx+13h]
    mov     eax, [esp+4+arg_4]
    mov     [eax], edx
    movsx   edx, word ptr [ecx+15h]
    mov     [eax+4], edx

    loc_4A165E:                             ; CODE XREF: sub_4A1630+1Bj
    movsx   edx, word ptr [ecx+17h]
    mov     esi, [eax]
    lea     edx, [edx+esi-1]
    pop     esi
    mov     [eax+8], edx
    mov     edx, [eax+4]
    movsx   ecx, word ptr [ecx+19h]
    lea     ecx, [ecx+edx-1]
    mov     [eax+0Ch], ecx
    retn    8
    sub_4A1630 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A1680 proc near                    ; CODE XREF: sub_4AB5D0+5Ap

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    push    ebx
    mov     ecx, eax
    push    esi
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esp+8+arg_0]
    mov     esi, edx
    add     esi, eax
    mov     eax, [esp+8+arg_8]
    lea     ecx, [esi+ecx*2]
    movsx   esi, word ptr [ecx+13h]
    mov     [eax], esi
    movsx   esi, word ptr [ecx+15h]
    mov     [eax+4], esi
    mov     bl, [ecx]
    test    bl, bl
    jz      short loc_4A16CE
    movsx   esi, word ptr [edx+13h]
    mov     ebx, [eax]
    add     ebx, esi
    mov     esi, [eax+4]
    mov     [eax], ebx
    movsx   edx, word ptr [edx+15h]
    add     esi, edx
    mov     [eax+4], esi

    loc_4A16CE:                             ; CODE XREF: sub_4A1680+36j
    movsx   edx, word ptr [ecx+17h]
    mov     esi, [eax]
    lea     edx, [edx+esi-1]
    pop     esi
    mov     [eax+8], edx
    mov     edx, [eax+4]
    movsx   ecx, word ptr [ecx+19h]
    pop     ebx
    lea     ecx, [ecx+edx-1]
    mov     [eax+0Ch], ecx
    retn    0Ch
    sub_4A1680 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A16F0 proc near                    ; CODE XREF: sub_4A81E0+129Bp
                                            ; sub_4A81E0+1325p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    mov     edx, 1
    push    ebx
    push    ebp
    mov     ebp, [esp+18h+arg_0]
    xor     ebx, ebx
    push    esi
    push    edi
    mov     eax, [ebp+18h]
    mov     eax, [eax+4]
    mov     [ebp+0CCAh], edx
    cmp     [eax+0B6h], dx
    jl      short loc_4A1737
    lea     ecx, [eax+15Bh]

    loc_4A171D:                             ; CODE XREF: sub_4A16F0+45j
    cmp     byte ptr [ecx], 3
    jnz     short loc_4A1725
    mov     [ecx+1Fh], ebx

    loc_4A1725:                             ; CODE XREF: sub_4A16F0+30j
    movsx   esi, word ptr [eax+0B6h]
    inc     edx
    add     ecx, 15Bh
    cmp     edx, esi
    jle     short loc_4A171D

    loc_4A1737:                             ; CODE XREF: sub_4A16F0+25j
    mov     ecx, [esp+20h+arg_4]
    mov     edx, ecx
    add     eax, ecx
    shl     edx, 3
    sub     edx, ecx
    lea     edx, [edx+edx*2]
    lea     edx, [ecx+edx*2]
    lea     edx, [ecx+edx*4]
    mov     cl, [eax+edx*2]
    cmp     cl, 3
    lea     eax, [eax+edx*2]
    jnz     short loc_4A1769
    mov     dword ptr [eax+1Fh], 1Eh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A1769:                             ; CODE XREF: sub_4A16F0+66j
    cmp     cl, 5
    jz      loc_4A1803
    cmp     cl, 2
    jz      loc_4A1803
    cmp     [eax], bl
    jnz     short loc_4A1789
    xor     ecx, ecx
    xor     edx, edx
    mov     [esp+20h+var_10], ecx
    jmp     short loc_4A1795
    ; ---------------------------------------------------------------------------

    loc_4A1789:                             ; CODE XREF: sub_4A16F0+8Dj
    movsx   ecx, word ptr [eax+13h]
    mov     [esp+20h+var_10], ecx
    movsx   edx, word ptr [eax+15h]

    loc_4A1795:                             ; CODE XREF: sub_4A16F0+97j
    mov     [esp+20h+var_C], edx
    mov     edi, 1Fh
    movsx   esi, word ptr [eax+17h]
    lea     ecx, [esi+ecx-1]
    xor     esi, esi
    mov     [esp+20h+var_8], ecx
    movsx   eax, word ptr [eax+19h]
    lea     ecx, [eax+edx-1]
    mov     [esp+20h+var_4], ecx

    loc_4A17B8:                             ; CODE XREF: sub_4A16F0+111j
    mov     edx, [esp+20h+var_10]
    mov     ecx, [esp+20h+var_C]
    mov     eax, [esp+20h+var_8]
    mov     ebx, [esp+20h+var_4]
    dec     edx
    dec     ecx
    inc     eax
    inc     ebx
    mov     [esp+20h+var_8], eax
    mov     eax, [ebp+18h]
    mov     [esp+20h+var_10], edx
    mov     [esp+20h+var_C], ecx
    mov     [esp+20h+var_4], ebx
    mov     ecx, [eax+4]
    lea     edx, [esp+20h+var_10]
    push    edi
    push    edx
    mov     edx, [ecx+0BCh]
    push    edx
    call    sub_4BF7B0
    mov     eax, 0FFFFFFFDh
    sub     eax, esi
    add     edi, eax
    inc     esi
    cmp     esi, 6
    jl      short loc_4A17B8

    loc_4A1803:                             ; CODE XREF: sub_4A16F0+7Cj
                                            ; sub_4A16F0+85j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    sub_4A16F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A1810 proc near                    ; CODE XREF: sub_476D80+9Bp
                                            ; sub_476EF0+D3p ...

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    xor     ebx, ebx
    mov     esi, 1
    movsx   eax, word ptr [edi+0B6h]
    inc     eax
    cmp     eax, esi
    mov     [esp+arg_0], eax
    jle     short loc_4A188E
    mov     ecx, [esp+arg_4]
    lea     edx, [edi+15Bh]

    loc_4A1839:                             ; CODE XREF: sub_4A1810+59j
    cmp     byte ptr [edx], 7
    jnz     short loc_4A1860
    mov     eax, ecx
    mov     ebp, edi
    shl     eax, 3
    sub     eax, ecx
    add     ebp, ecx
    lea     eax, [eax+eax*2]
    lea     eax, [ecx+eax*2]
    lea     eax, [ecx+eax*4]
    movsx   eax, byte ptr [ebp+eax*2+28h]
    cmp     ebx, eax
    jz      short loc_4A186D
    mov     eax, [esp+arg_0]
    inc     ebx

    loc_4A1860:                             ; CODE XREF: sub_4A1810+2Cj
    inc     esi
    add     edx, 15Bh
    cmp     esi, eax
    jl      short loc_4A1839
    jmp     short loc_4A188E
    ; ---------------------------------------------------------------------------

    loc_4A186D:                             ; CODE XREF: sub_4A1810+49j
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    mov     ecx, edi
    add     ecx, esi
    lea     eax, [esi+edx*4]
    mov     edx, [ecx+eax*2+0D6h]
    push    edx
    call    sub_4C1420

    loc_4A188E:                             ; CODE XREF: sub_4A1810+1Dj
                                            ; sub_4A1810+5Bj
    movsx   eax, word ptr [edi+0B6h]
    inc     eax
    cmp     esi, eax
    jnz     short loc_4A18AB
    mov     ecx, dword_51FBA4
    mov     edx, [ecx]
    push    edx
    call    sub_4C1420
    or      esi, 0FFFFFFFFh

    loc_4A18AB:                             ; CODE XREF: sub_4A1810+88j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A1810 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A18C0 proc near                    ; CODE XREF: sub_4B0230+8Ep

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    push    edi
    mov     edx, 1
    movsx   eax, word ptr [ebp+0B6h]
    xor     edi, edi
    lea     ebx, [eax+1]
    cmp     ebx, edx
    jle     short loc_4A1917
    mov     ecx, [esp+8+arg_4]
    lea     esi, [ebp+15Bh]

    loc_4A18E7:                             ; CODE XREF: sub_4A18C0+55j
    cmp     byte ptr [esi], 8
    jnz     short loc_4A190C
    mov     eax, ecx
    add     ebp, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*2]
    lea     eax, [ecx+eax*2]
    lea     eax, [ecx+eax*4]
    movsx   eax, byte ptr [ebp+eax*2+27h]
    cmp     edi, eax
    jz      short loc_4A1917
    mov     ebp, [esp+8+arg_0]
    inc     edi

    loc_4A190C:                             ; CODE XREF: sub_4A18C0+2Aj
    inc     edx
    add     esi, 15Bh
    cmp     edx, ebx
    jl      short loc_4A18E7

    loc_4A1917:                             ; CODE XREF: sub_4A18C0+1Bj
                                            ; sub_4A18C0+45j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    8
    sub_4A18C0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A1920 proc near                    ; CODE XREF: sub_4AB5D0+6Ep

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    cmp     ecx, [eax]
    jl      short loc_4A1949
    cmp     ecx, [eax+8]
    jg      short loc_4A1949
    mov     ecx, [esp+arg_8]
    mov     edx, [eax+4]
    cmp     ecx, edx
    jl      short loc_4A1949
    cmp     ecx, [eax+0Ch]
    jg      short loc_4A1949
    mov     eax, 1
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A1949:                             ; CODE XREF: sub_4A1920+Aj
                                            ; sub_4A1920+Fj ...
    xor     eax, eax
    retn    0Ch
    sub_4A1920 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, [esp+4]
    mov     ecx, [esp+8]
    push    esi
    xor     eax, eax
    mov     esi, [edx+4]
    cmp     ecx, esi
    pop     esi
    setl    al
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+4]
    mov     ecx, [esp+8]
    push    esi
    xor     eax, eax
    mov     esi, [edx+0Ch]
    cmp     ecx, esi
    pop     esi
    setnle  al
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    push    ebx
    mov     ecx, eax
    push    esi
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    mov     ecx, [esp+0Ch]
    mov     esi, ecx
    lea     edx, [eax+edx*4]
    add     esi, eax
    mov     eax, 1
    mov     bl, [esi+edx*2+1]
    movsx   edx, word ptr [ecx+0B6h]
    lea     esi, [edx+1]
    cmp     esi, eax
    jle     short loc_4A19E0
    add     ecx, 15Bh

    loc_4A19CB:                             ; CODE XREF: .text:004A19DEj
    cmp     byte ptr [ecx], 2
    jnz     short loc_4A19D5
    cmp     [ecx+1], bl
    jz      short loc_4A19E2

    loc_4A19D5:                             ; CODE XREF: .text:004A19CEj
    inc     eax
    add     ecx, 15Bh
    cmp     eax, esi
    jl      short loc_4A19CB

    loc_4A19E0:                             ; CODE XREF: .text:004A19C3j
    xor     eax, eax

    loc_4A19E2:                             ; CODE XREF: .text:004A19D3j
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    push    ebx
    mov     ecx, eax
    push    esi
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    mov     ecx, [esp+0Ch]
    mov     esi, ecx
    lea     edx, [eax+edx*4]
    add     esi, eax
    mov     eax, 1
    mov     bl, [esi+edx*2+1]
    movsx   edx, word ptr [ecx+0B6h]
    lea     esi, [edx+1]
    cmp     esi, eax
    jle     short loc_4A1A40
    add     ecx, 15Bh

    loc_4A1A2B:                             ; CODE XREF: .text:004A1A3Ej
    cmp     byte ptr [ecx], 4
    jnz     short loc_4A1A35
    cmp     [ecx+1], bl
    jz      short loc_4A1A42

    loc_4A1A35:                             ; CODE XREF: .text:004A1A2Ej
    inc     eax
    add     ecx, 15Bh
    cmp     eax, esi
    jl      short loc_4A1A2B

    loc_4A1A40:                             ; CODE XREF: .text:004A1A23j
    xor     eax, eax

    loc_4A1A42:                             ; CODE XREF: .text:004A1A33j
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    push    ebx
    mov     ecx, eax
    push    esi
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    mov     ecx, [esp+0Ch]
    mov     esi, ecx
    lea     edx, [eax+edx*4]
    add     esi, eax
    mov     eax, 1
    mov     bl, [esi+edx*2+1]
    movsx   edx, word ptr [ecx+0B6h]
    lea     esi, [edx+1]
    cmp     esi, eax
    jle     short loc_4A1AA0
    add     ecx, 15Bh

    loc_4A1A8B:                             ; CODE XREF: .text:004A1A9Ej
    cmp     byte ptr [ecx], 3
    jnz     short loc_4A1A95
    cmp     [ecx+1], bl
    jz      short loc_4A1AA2

    loc_4A1A95:                             ; CODE XREF: .text:004A1A8Ej
    inc     eax
    add     ecx, 15Bh
    cmp     eax, esi
    jl      short loc_4A1A8B

    loc_4A1AA0:                             ; CODE XREF: .text:004A1A83j
    xor     eax, eax

    loc_4A1AA2:                             ; CODE XREF: .text:004A1A93j
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    sub     esp, 10h
    mov     ecx, [eax+18h]
    mov     eax, [esp+18h]
    push    esi
    push    edi
    mov     esi, [ecx+4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, esi
    add     ecx, eax
    lea     eax, [ecx+edx*2]
    mov     cl, [ecx+edx*2]
    test    cl, cl
    jnz     short loc_4A1AEB
    xor     ecx, ecx
    xor     edx, edx
    mov     [esp+8], ecx
    jmp     short loc_4A1AF7
    ; ---------------------------------------------------------------------------

    loc_4A1AEB:                             ; CODE XREF: .text:004A1ADFj
    movsx   ecx, word ptr [eax+13h]
    mov     [esp+8], ecx
    movsx   edx, word ptr [eax+15h]

    loc_4A1AF7:                             ; CODE XREF: .text:004A1AE9j
    mov     [esp+0Ch], edx
    movsx   edi, word ptr [eax+17h]
    lea     ecx, [edi+ecx-1]
    mov     [esp+10h], ecx
    movsx   eax, word ptr [eax+19h]
    lea     ecx, [eax+edx-1]
    lea     edx, [esp+8]
    mov     [esp+14h], ecx
    mov     eax, [esi+0BCh]
    push    edx
    push    eax
    call    sub_4BFE10
    mov     edx, [esi+0BCh]
    lea     ecx, [esp+8]
    push    0FFFFFFECh
    push    ecx
    push    edx
    call    sub_4BF4D0
    pop     edi
    pop     esi
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A1B40 proc near                    ; CODE XREF: sub_4A2BE0+198p
                                            ; sub_4A2BE0+223p ...

    var_BC= dword ptr -0BCh
    var_B8= dword ptr -0B8h
    var_B4= dword ptr -0B4h
    var_B0= dword ptr -0B0h
    var_AC= dword ptr -0ACh
    var_A8= dword ptr -0A8h
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0BCh
    push    ebx
    push    ebp
    mov     ebp, [esp+0C4h+arg_0]
    xor     ebx, ebx
    push    esi
    push    edi
    mov     eax, [ebp+18h]
    mov     [esp+0CCh+var_B8], ebx
    cmp     eax, ebx
    jz      short loc_4A1B65
    mov     dword ptr [eax+14h], 1

    loc_4A1B65:                             ; CODE XREF: sub_4A1B40+1Cj
    mov     ecx, [esp+0CCh+arg_4]
    mov     edx, [ebp+18h]
    mov     eax, ecx
    mov     esi, [edx+4]
    shl     eax, 3
    sub     eax, ecx
    mov     [esp+0CCh+var_94], esi
    add     esi, ecx
    lea     eax, [eax+eax*2]
    lea     eax, [ecx+eax*2]
    lea     eax, [ecx+eax*4]
    lea     edi, [esi+eax*2]
    mov     [esp+0CCh+var_7C], edi
    movsx   eax, word ptr [edi+19h]
    mov     [esp+0CCh+var_98], eax
    mov     al, [edi]
    test    al, al
    jnz     short loc_4A1BA5
    xor     eax, eax
    mov     [esp+0CCh+var_8C], eax
    jmp     short loc_4A1BB1
    ; ---------------------------------------------------------------------------

    loc_4A1BA5:                             ; CODE XREF: sub_4A1B40+5Bj
    movsx   eax, word ptr [edi+13h]
    mov     [esp+0CCh+var_8C], eax
    movsx   ebx, word ptr [edi+15h]

    loc_4A1BB1:                             ; CODE XREF: sub_4A1B40+63j
    mov     [esp+0CCh+var_88], ebx
    movsx   esi, word ptr [edi+17h]
    lea     eax, [esi+eax-1]
    mov     [esp+0CCh+var_84], eax
    movsx   eax, word ptr [edi+19h]
    lea     eax, [eax+ebx-1]
    mov     [esp+0CCh+var_80], eax
    mov     eax, [edx+24h]
    test    eax, eax
    jnz     short loc_4A1BF2
    mov     eax, [ebp+0CD2h]
    test    eax, eax
    jnz     short loc_4A1BF2
    test    byte ptr [edx+10h], 80h
    jnz     short loc_4A1BEE
    push    eax
    push    ecx
    push    ebp
    call    sub_4B0230
    jmp     short loc_4A1C0D
    ; ---------------------------------------------------------------------------

    loc_4A1BEE:                             ; CODE XREF: sub_4A1B40+A2j
    test    eax, eax
    jz      short loc_4A1C0D

    loc_4A1BF2:                             ; CODE XREF: sub_4A1B40+92j
                                            ; sub_4A1B40+9Cj
    lea     ecx, [esp+0CCh+var_8C]
    lea     edx, [esp+0CCh+var_8C]
    push    ecx
    push    edx
    push    eax
    mov     eax, [esp+0D8h+var_94]
    mov     ecx, [eax+0BCh]
    push    ecx
    call    sub_4C6D20

    loc_4A1C0D:                             ; CODE XREF: sub_4A1B40+ACj
                                            ; sub_4A1B40+B0j
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A1C21
    call    sub_4C1450
    jmp     short loc_4A1C37
    ; ---------------------------------------------------------------------------

    loc_4A1C21:                             ; CODE XREF: sub_4A1B40+D8j
    mov     eax, [eax+0Ch]
    push    49h
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A1C37:                             ; CODE XREF: sub_4A1B40+DFj
    mov     cx, [edi+0DAh]
    mov     [esp+0CCh+var_90], eax
    test    cx, cx
    lea     ebx, [eax+1]
    jz      short loc_4A1C4D
    movsx   ebx, cx

    loc_4A1C4D:                             ; CODE XREF: sub_4A1B40+108j
    mov     eax, [edi+1Bh]
    mov     [esp+0CCh+var_78], ebx
    test    al, 10h
    jz      loc_4A2052
    mov     ecx, [edi+0C2h]
    test    ecx, ecx
    jz      loc_4A2052
    cmp     word ptr [edi+0C0h], 0
    jz      loc_4A2052
    mov     ebp, [esp+0CCh+var_94]
    mov     esi, 1
    mov     [esp+0CCh+var_BC], 0
    movsx   ecx, word ptr [ebp+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4A1CDB
    lea     eax, [ebp+15Bh]

    loc_4A1C9B:                             ; CODE XREF: sub_4A1B40+176j
    cmp     byte ptr [eax], 7
    jnz     short loc_4A1CAE
    movsx   edx, byte ptr [edi+28h]
    cmp     [esp+0CCh+var_BC], edx
    jz      short loc_4A1CBA
    inc     [esp+0CCh+var_BC]

    loc_4A1CAE:                             ; CODE XREF: sub_4A1B40+15Ej
    inc     esi
    add     eax, 15Bh
    cmp     esi, ecx
    jl      short loc_4A1C9B
    jmp     short loc_4A1CDB
    ; ---------------------------------------------------------------------------

    loc_4A1CBA:                             ; CODE XREF: sub_4A1B40+168j
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, ebp
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A1CDB:                             ; CODE XREF: sub_4A1B40+153j
                                            ; sub_4A1B40+178j
    movsx   edx, word ptr [ebp+0B6h]
    inc     edx
    cmp     esi, edx
    jnz     short loc_4A1CF4
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A1CF4:                             ; CODE XREF: sub_4A1B40+1A5j
    call    sub_4C1440
    call    sub_4C13F0
    movsx   edx, word ptr [edi+0BCh]
    mov     byte ptr [esp+0CCh+var_6C], al
    mov     eax, [edi+0C2h]
    push    edx
    push    eax
    call    sub_4B6AF0
    movsx   ecx, word ptr [edi+0BCh]
    mov     ebp, eax
    xor     eax, eax
    mov     [esp+0CCh+var_A0], ebp
    mov     [esp+0CCh+var_BC], eax
    mov     [esp+0CCh+var_A4], ecx
    mov     [esp+0CCh+var_9C], eax

    loc_4A1D31:                             ; CODE XREF: sub_4A1B40+4FFj
    mov     edx, [esp+0CCh+var_8C]
    movsx   eax, word ptr [edi+17h]
    lea     esi, [edx+2]
    mov     edx, [esp+0CCh+var_88]
    mov     [esp+0CCh+var_B4], esi
    lea     ecx, [esi+eax-2]
    mov     eax, [esp+0CCh+var_9C]
    mov     [esp+0CCh+var_AC], ecx
    lea     eax, [edx+eax+2]
    mov     [esp+0CCh+var_B0], eax
    add     eax, ebx
    xor     ebx, ebx
    mov     [esp+0CCh+var_A8], eax
    test    ebp, ebp
    jnz     short loc_4A1D68
    xor     edx, edx
    jmp     short loc_4A1DDA
    ; ---------------------------------------------------------------------------

    loc_4A1D68:                             ; CODE XREF: sub_4A1B40+222j
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A1D8D
    push    ebp
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    mov     esi, [esp+0CCh+var_B4]
    mov     edx, eax
    mov     ecx, [esp+0CCh+var_AC]
    jmp     short loc_4A1DDA
    ; ---------------------------------------------------------------------------

    loc_4A1D8D:                             ; CODE XREF: sub_4A1B40+233j
    mov     al, [ebp+0]
    mov     edi, ebp
    test    al, al
    jz      short loc_4A1DD4

    loc_4A1D96:                             ; CODE XREF: sub_4A1B40+28Aj
    mov     al, [edi]
    mov     edx, dword_51FBA4
    mov     byte ptr [esp+0CCh+var_64], al
    mov     ecx, [esp+0CCh+var_64]
    mov     eax, [edx+14h]
    and     ecx, 0FFh
    push    ecx
    mov     ecx, [eax+0Ch]
    push    ecx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A1DC4
    xor     edx, edx
    mov     dx, [eax]
    add     ebx, edx

    loc_4A1DC4:                             ; CODE XREF: sub_4A1B40+27Bj
    mov     al, [edi+1]
    inc     edi
    test    al, al
    jnz     short loc_4A1D96
    mov     ecx, [esp+0CCh+var_AC]
    mov     esi, [esp+0CCh+var_B4]

    loc_4A1DD4:                             ; CODE XREF: sub_4A1B40+254j
    mov     edi, [esp+0CCh+var_7C]
    mov     edx, ebx

    loc_4A1DDA:                             ; CODE XREF: sub_4A1B40+226j
                                            ; sub_4A1B40+24Bj
    mov     eax, [edi+1Fh]
    mov     ebp, [esp+0CCh+arg_0]
    xor     ebx, ebx
    mov     bl, [eax+ebp+8B2h]
    mov     eax, [edi+0D6h]
    test    eax, eax
    mov     [esp+0CCh+var_68], ebx
    jz      short loc_4A1E13
    mov     ebx, [esp+0CCh+var_A4]
    cmp     byte ptr [ebx+eax], 1
    jnz     short loc_4A1E13
    mov     ebp, [esp+0CCh+var_A0]
    mov     [esp+0CCh+var_B8], 1
    jmp     short loc_4A1E2E
    ; ---------------------------------------------------------------------------

    loc_4A1E13:                             ; CODE XREF: sub_4A1B40+2B9j
                                            ; sub_4A1B40+2C3j
    mov     ebp, [esp+0CCh+var_A0]
    cmp     byte ptr [ebp+0], 26h
    jnz     short loc_4A1E2E
    cmp     byte ptr [ebp+1], 47h
    jnz     short loc_4A1E2B
    mov     [esp+0CCh+var_B8], 1

    loc_4A1E2B:                             ; CODE XREF: sub_4A1B40+2E1j
    add     ebp, 2

    loc_4A1E2E:                             ; CODE XREF: sub_4A1B40+2D1j
                                            ; sub_4A1B40+2DBj
    mov     eax, [esp+0CCh+var_B0]
    mov     [esp+0CCh+var_A0], eax
    mov     eax, [edi+1Bh]
    test    al, 1
    jz      short loc_4A1E4E
    sub     ecx, esi
    mov     ebx, esi
    inc     ecx
    mov     [esp+0CCh+var_74], ebx
    mov     esi, ecx
    mov     [esp+0CCh+var_70], esi
    jmp     short loc_4A1E93
    ; ---------------------------------------------------------------------------

    loc_4A1E4E:                             ; CODE XREF: sub_4A1B40+2FBj
    test    al, 4
    jz      short loc_4A1E62
    sub     ecx, edx
    mov     esi, edx
    mov     ebx, ecx
    mov     [esp+0CCh+var_70], esi
    mov     [esp+0CCh+var_74], ebx
    jmp     short loc_4A1E93
    ; ---------------------------------------------------------------------------

    loc_4A1E62:                             ; CODE XREF: sub_4A1B40+310j
    test    al, 2
    jz      short loc_4A1E8B
    lea     eax, [esi+ecx]
    sub     eax, edx
    cdq
    sub     eax, edx
    mov     ebx, eax
    sar     ebx, 1
    cmp     ebx, esi
    mov     [esp+0CCh+var_74], ebx
    jge     short loc_4A1E80
    mov     ebx, esi
    mov     [esp+0CCh+var_74], ebx

    loc_4A1E80:                             ; CODE XREF: sub_4A1B40+338j
    sub     ecx, ebx
    inc     ecx
    mov     esi, ecx
    mov     [esp+0CCh+var_70], esi
    jmp     short loc_4A1E93
    ; ---------------------------------------------------------------------------

    loc_4A1E8B:                             ; CODE XREF: sub_4A1B40+324j
    mov     esi, [esp+0CCh+var_70]
    mov     ebx, [esp+0CCh+var_74]

    loc_4A1E93:                             ; CODE XREF: sub_4A1B40+30Cj
                                            ; sub_4A1B40+320j ...
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A1EA7
    call    sub_4C1450
    jmp     short loc_4A1EBD
    ; ---------------------------------------------------------------------------

    loc_4A1EA7:                             ; CODE XREF: sub_4A1B40+35Ej
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A1EBD:                             ; CODE XREF: sub_4A1B40+365j
    movsx   edx, word ptr [edi+0DAh]
    add     eax, 6
    push    0
    cmp     edx, eax
    jle     short loc_4A1EF2
    mov     eax, [esp+0D0h+var_80]
    mov     edx, [esp+0D0h+var_88]
    mov     ecx, [esp+0D0h+var_A0]
    sub     eax, edx
    push    eax
    push    esi
    mov     esi, [esp+0D8h+var_94]
    push    ecx
    push    ebx
    push    ebp
    mov     edx, [esi+0BCh]
    push    edx
    call    sub_4A51D0
    jmp     short loc_4A1F0A
    ; ---------------------------------------------------------------------------

    loc_4A1EF2:                             ; CODE XREF: sub_4A1B40+38Bj
    mov     eax, [esp+0D0h+var_A0]
    push    esi
    mov     esi, [esp+0D4h+var_94]
    push    eax
    push    ebx
    push    ebp
    mov     ecx, [esi+0BCh]
    push    ecx
    call    sub_4A50E0

    loc_4A1F0A:                             ; CODE XREF: sub_4A1B40+3B0j
    push    1
    push    ebp
    call    sub_4B6AF0
    mov     ebp, eax
    mov     eax, [esp+0CCh+var_B8]
    mov     [esp+0CCh+var_A0], ebp
    test    eax, eax
    jz      short loc_4A1F76
    mov     eax, [esi+0BCh]
    lea     edx, [esp+0CCh+var_B4]
    push    0FFFFFFEDh
    push    edx
    push    eax
    mov     [esp+0D8h+var_B8], 0
    call    sub_4BF4D0
    mov     edx, [esi+0BCh]
    lea     ecx, [esp+0CCh+var_B4]
    push    0FFFFFFECh
    push    ecx
    push    edx
    call    sub_4BF4D0
    mov     ecx, [esi+0BCh]
    lea     eax, [esp+0CCh+var_B4]
    push    0FFFFFFEBh
    push    eax
    push    ecx
    call    sub_4BF4D0
    mov     eax, [esi+0BCh]
    lea     edx, [esp+0CCh+var_B4]
    push    0FFFFFFEAh
    push    edx
    push    eax
    call    sub_4BF4D0
    jmp     short loc_4A1FF3
    ; ---------------------------------------------------------------------------

    loc_4A1F76:                             ; CODE XREF: sub_4A1B40+3DEj
    mov     eax, [edi+1Bh]
    test    ah, 1
    jnz     short loc_4A1FDE
    movsx   ecx, word ptr [edi+0BCh]
    mov     edx, [esp+0CCh+var_BC]
    movsx   eax, word ptr [edi+0BAh]
    add     edx, ecx
    cmp     eax, edx
    jnz     short loc_4A1FDE
    cmp     word ptr [edi+0C0h], 0
    jz      short loc_4A1FDE
    mov     ecx, [esp+0CCh+arg_0]
    mov     eax, [esp+0CCh+arg_4]
    push    1Eh
    mov     edx, [ecx+18h]
    cmp     [edx+20h], eax
    jnz     short loc_4A1FCB
    mov     edx, [esi+0BCh]
    lea     ecx, [esp+0D0h+var_B4]
    push    ecx
    push    edx
    call    sub_4BF4D0
    jmp     short loc_4A1FF3
    ; ---------------------------------------------------------------------------

    loc_4A1FCB:                             ; CODE XREF: sub_4A1B40+476j
    mov     ecx, [esi+0BCh]
    lea     eax, [esp+0D0h+var_B4]
    push    eax
    push    ecx
    call    sub_4BF4D0
    jmp     short loc_4A1FF3
    ; ---------------------------------------------------------------------------

    loc_4A1FDE:                             ; CODE XREF: sub_4A1B40+43Cj
                                            ; sub_4A1B40+454j ...
    mov     edx, [esp+0CCh+var_6C]
    mov     eax, [esp+0CCh+var_68]
    and     edx, 0FFh
    push    edx
    push    eax
    call    sub_4C13A0

    loc_4A1FF3:                             ; CODE XREF: sub_4A1B40+434j
                                            ; sub_4A1B40+489j ...
    mov     ebx, [esp+0CCh+var_78]
    mov     eax, [esp+0CCh+var_9C]
    mov     ecx, [esp+0CCh+var_BC]
    mov     esi, [esp+0CCh+var_A4]
    add     eax, ebx
    inc     ecx
    mov     [esp+0CCh+var_9C], eax
    mov     eax, [esp+0CCh+var_98]
    mov     [esp+0CCh+var_BC], ecx
    mov     ecx, [esp+0CCh+var_90]
    sub     eax, ebx
    inc     esi
    cmp     eax, ecx
    mov     [esp+0CCh+var_A4], esi
    mov     [esp+0CCh+var_98], eax
    jl      loc_4A22E4
    movsx   ecx, word ptr [edi+0BCh]
    mov     edx, [esp+0CCh+var_BC]
    movsx   eax, word ptr [edi+0C0h]
    add     edx, ecx
    cmp     edx, eax
    jl      loc_4A1D31
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A2052:                             ; CODE XREF: sub_4A1B40+116j
                                            ; sub_4A1B40+124j ...
    test    al, 0A0h
    jz      loc_4A22E4
    mov     ecx, [esp+0CCh+var_94]
    lea     edx, [esp+0CCh+var_30]
    shr     eax, 7
    mov     esi, [ecx+0BCh]
    and     eax, 1
    mov     ebp, eax
    push    edx
    mov     ecx, esi
    mov     [esp+0D0h+var_9C], ebp
    call    sub_4C6AE0
    sub     esp, 10h
    mov     ecx, [esp+0DCh+var_8C]
    mov     edx, [esp+0DCh+var_88]
    mov     eax, esp
    mov     [eax], ecx
    mov     ecx, [esp+0DCh+var_84]
    mov     [eax+4], edx
    mov     edx, [esp+0DCh+var_80]
    mov     [eax+8], ecx
    mov     ecx, esi
    mov     [eax+0Ch], edx
    call    sub_4C6B10
    movsx   ebx, word ptr [edi+0BCh]
    test    ebp, ebp
    mov     [esp+0CCh+var_98], ebx
    jnz     short loc_4A20C4
    mov     eax, [edi+0C6h]
    lea     ecx, [eax+ebx*4]
    mov     [esp+0CCh+var_BC], ecx
    jmp     short loc_4A20DC
    ; ---------------------------------------------------------------------------

    loc_4A20C4:                             ; CODE XREF: sub_4A1B40+573j
    mov     eax, [edi+0C6h]
    lea     edx, [ebx+ebx*2]
    mov     [esp+0CCh+var_BC], 0
    lea     ecx, [eax+edx*8]
    mov     [esp+0CCh+var_90], ecx

    loc_4A20DC:                             ; CODE XREF: sub_4A1B40+582j
    mov     edx, [esp+0CCh+var_88]
    mov     eax, [esp+0CCh+var_78]
    mov     ecx, [esp+0CCh+var_8C]
    lea     ebp, [edx+2]
    add     ecx, 2
    mov     [esp+0CCh+var_B8], ebp
    mov     [esp+0CCh+var_8C], ecx
    lea     edx, [ebp+eax+0]
    mov     [esp+0CCh+var_A4], edx
    jmp     short loc_4A2104
    ; ---------------------------------------------------------------------------

    loc_4A2100:                             ; CODE XREF: sub_4A1B40+76Bj
    mov     ecx, [esp+0CCh+var_8C]

    loc_4A2104:                             ; CODE XREF: sub_4A1B40+5BEj
    mov     eax, [esp+0CCh+var_9C]
    test    eax, eax
    jz      short loc_4A211B
    mov     eax, [esp+0CCh+var_90]
    mov     edi, eax
    add     eax, 18h
    mov     [esp+0CCh+var_90], eax
    jmp     short loc_4A2124
    ; ---------------------------------------------------------------------------

    loc_4A211B:                             ; CODE XREF: sub_4A1B40+5CAj
    mov     eax, [esp+0CCh+var_BC]
    mov     edx, [eax]
    mov     edi, [edx+28h]

    loc_4A2124:                             ; CODE XREF: sub_4A1B40+5D9j
    test    edi, edi
    jz      loc_4A2216
    mov     eax, [edi+10h]
    test    eax, eax
    jz      loc_4A2216
    mov     eax, 1
    mov     [esp+0CCh+var_48], ecx
    mov     [esp+0CCh+var_20], eax
    mov     [esp+0CCh+var_1C], eax
    mov     [esp+0CCh+var_8], eax
    mov     [esp+0CCh+var_14], eax
    mov     eax, [esp+0CCh+var_84]
    mov     [esp+0CCh+var_60], ecx
    mov     [esp+0CCh+var_58], eax
    mov     [esp+0CCh+var_50], eax
    mov     eax, [esp+0CCh+var_A4]
    lea     ecx, [esp+0CCh+var_20]
    dec     eax
    lea     edx, [esp+0CCh+var_60]
    mov     [esp+0CCh+var_44], eax
    mov     [esp+0CCh+var_4C], eax
    xor     eax, eax
    push    ecx
    mov     ax, [edi]
    push    edx
    dec     eax
    push    edi
    mov     [esp+0D8h+var_18], eax
    mov     [esp+0D8h+var_10], eax
    xor     eax, eax
    push    esi
    mov     ax, [edi+2]
    mov     [esp+0DCh+var_54], ebp
    dec     eax
    mov     [esp+0DCh+var_5C], ebp
    mov     [esp+0DCh+var_C], eax
    mov     [esp+0DCh+var_4], eax
    call    sub_4C7580
    mov     ebp, [esp+0CCh+var_5C]
    mov     eax, [esp+0CCh+var_4C]
    mov     ecx, [esp+0CCh+var_60]
    mov     edx, [esp+0CCh+var_58]
    mov     [esp+0CCh+var_A8], eax
    mov     eax, [esp+0CCh+var_7C]
    mov     [esp+0CCh+var_B4], ecx
    mov     [esp+0CCh+var_AC], edx
    mov     [esp+0CCh+var_B0], ebp
    mov     eax, [eax+0D6h]
    mov     al, [eax+ebx]
    test    al, 1
    jz      loc_4A22F1
    lea     ecx, [esp+0CCh+var_B4]
    push    0FFFFFFECh
    push    ecx
    push    esi
    call    sub_4BF4D0

    loc_4A2212:                             ; CODE XREF: sub_4A1B40+7B3j
    mov     ebp, [esp+0CCh+var_B8]

    loc_4A2216:                             ; CODE XREF: sub_4A1B40+5E6j
                                            ; sub_4A1B40+5F1j ...
    mov     ecx, [esp+0CCh+var_7C]
    mov     eax, [ecx+1Bh]
    test    ah, 1
    jnz     short loc_4A2274
    movsx   eax, word ptr [ecx+0BAh]
    cmp     eax, ebx
    jnz     short loc_4A2274
    mov     eax, [esp+0CCh+var_8C]
    xor     ecx, ecx
    mov     cx, [edi]
    mov     [esp+0CCh+var_40], eax
    push    14h
    mov     [esp+0D0h+var_3C], ebp
    lea     edx, [ecx+eax-1]
    xor     eax, eax
    mov     ax, [edi+2]
    mov     [esp+0D0h+var_38], edx
    lea     edx, [esp+0D0h+var_40]
    lea     ecx, [eax+ebp-1]
    push    edx
    push    esi
    mov     [esp+0D8h+var_34], ecx
    call    sub_4BF4D0
    mov     ecx, [esp+0CCh+var_7C]

    loc_4A2274:                             ; CODE XREF: sub_4A1B40+6E0j
                                            ; sub_4A1B40+6EBj
    mov     eax, [esp+0CCh+var_9C]
    inc     ebx
    test    eax, eax
    mov     [esp+0CCh+var_98], ebx
    jnz     short loc_4A2286
    add     [esp+0CCh+var_BC], 4

    loc_4A2286:                             ; CODE XREF: sub_4A1B40+73Fj
    mov     eax, [esp+0CCh+var_78]
    mov     edx, [esp+0CCh+var_A4]
    add     ebp, eax
    add     edx, eax
    mov     eax, [esp+0CCh+var_80]
    mov     [esp+0CCh+var_B8], ebp
    cmp     ebp, eax
    mov     [esp+0CCh+var_A4], edx
    jge     short loc_4A22B1
    movsx   eax, word ptr [ecx+0C0h]
    cmp     ebx, eax
    jl      loc_4A2100

    loc_4A22B1:                             ; CODE XREF: sub_4A1B40+760j
    mov     edx, [esp+0CCh+var_30]
    mov     eax, [esp+0CCh+var_2C]
    sub     esp, 10h
    mov     ecx, esp
    mov     [ecx], edx
    mov     edx, [esp+0DCh+var_28]
    mov     [ecx+4], eax
    mov     eax, [esp+0DCh+var_24]
    mov     [ecx+8], edx
    mov     [ecx+0Ch], eax
    mov     ecx, esi
    call    sub_4C6B10

    loc_4A22E4:                             ; CODE XREF: sub_4A1B40+4E3j
                                            ; sub_4A1B40+514j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0BCh
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A22F1:                             ; CODE XREF: sub_4A1B40+6BFj
    test    al, 2
    jz      loc_4A2212
    mov     ebx, [esp+0CCh+arg_0]
    xor     eax, eax
    inc     ebp
    add     edx, 0FFFFFFFEh
    mov     al, [ebx+8BEh]
    push    eax
    push    ebp
    push    edx
    mov     edx, [esp+0D8h+var_4C]
    dec     edx
    inc     ecx
    push    edx
    push    ecx
    push    esi
    call    sub_4BE950
    xor     eax, eax
    mov     ecx, [esp+0CCh+var_B0]
    mov     al, [ebx+8BEh]
    mov     edx, [esp+0CCh+var_AC]
    inc     ecx
    push    eax
    mov     eax, [esp+0D0h+var_A8]
    push    ecx
    mov     ecx, [esp+0D4h+var_B4]
    dec     edx
    dec     eax
    push    edx
    add     ecx, 2
    push    eax
    push    ecx
    push    esi
    call    sub_4BE950
    xor     edx, edx
    mov     eax, [esp+0CCh+var_A8]
    mov     dl, [ebx+8BEh]
    mov     ecx, [esp+0CCh+var_AC]
    add     eax, 0FFFFFFFEh
    push    edx
    mov     edx, [esp+0D0h+var_B0]
    push    eax
    mov     eax, [esp+0D4h+var_B4]
    dec     ecx
    add     edx, 2
    push    ecx
    inc     eax
    push    edx
    push    eax
    push    esi
    call    sub_4BE950
    xor     ecx, ecx
    mov     edx, [esp+0CCh+var_A8]
    mov     cl, [ebx+8BEh]
    mov     eax, [esp+0CCh+var_AC]
    add     edx, 0FFFFFFFEh
    push    ecx
    mov     ecx, [esp+0D0h+var_B0]
    push    edx
    mov     edx, [esp+0D4h+var_B4]
    add     eax, 0FFFFFFFEh
    add     ecx, 2
    push    eax
    add     edx, 2
    push    ecx
    push    edx
    push    esi
    call    sub_4BE950
    mov     ebp, [esp+0CCh+var_B8]
    mov     ebx, [esp+0CCh+var_98]
    jmp     loc_4A2216
    sub_4A1B40 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A23B0 proc near                    ; CODE XREF: sub_4A2580+CBp
                                            ; sub_4A4170+7Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_4]
    push    ebx
    mov     ecx, eax
    push    esi
    shl     ecx, 3
    sub     ecx, eax
    push    edi
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esp+0Ch+arg_0]
    add     edx, eax
    lea     eax, [edx+ecx*2]
    mov     ecx, [esp+0Ch+arg_8]
    movsx   edx, word ptr [eax+13h]
    mov     [ecx], edx
    movsx   edx, word ptr [eax+15h]
    mov     [ecx+4], edx
    mov     edx, [ecx]
    movsx   esi, word ptr [eax+17h]
    mov     edi, [ecx+4]
    add     esi, edx
    mov     [ecx+8], esi
    movsx   esi, word ptr [eax+19h]
    add     edi, esi
    mov     [ecx+0Ch], edi
    mov     bl, [eax+1Bh]
    test    bl, 1
    jz      short loc_4A2438
    movsx   esi, word ptr [eax+140h]
    lea     esi, [esi+edx+1]
    mov     edx, [esp+0Ch+arg_C]
    mov     [edx], esi
    mov     ecx, [ecx+4]
    inc     ecx
    mov     [edx+4], ecx
    movsx   ecx, word ptr [eax+142h]
    add     ecx, esi
    mov     [edx+8], ecx
    mov     ecx, [edx+4]
    movsx   eax, word ptr [eax+19h]
    lea     eax, [ecx+eax-2]
    mov     [edx+0Ch], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4A2438:                             ; CODE XREF: sub_4A23B0+4Ej
    lea     esi, [edx+1]
    mov     edx, [esp+0Ch+arg_C]
    pop     edi
    mov     [edx], esi
    mov     ecx, [ecx+4]
    movsx   esi, word ptr [eax+140h]
    lea     ecx, [esi+ecx+2]
    mov     esi, [edx]
    mov     [edx+4], ecx
    movsx   ecx, word ptr [eax+17h]
    lea     ecx, [esi+ecx-2]
    pop     esi
    mov     [edx+8], ecx
    mov     ecx, [edx+4]
    movsx   eax, word ptr [eax+142h]
    add     eax, ecx
    pop     ebx
    mov     [edx+0Ch], eax
    retn    10h
    sub_4A23B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    mov     eax, [esp+8]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    mov     eax, [esp+18h]
    push    edi
    push    0
    mov     ebx, [ecx+4]
    mov     ecx, eax
    shl     ecx, 3
    mov     edx, [ebx+0BCh]
    sub     ecx, eax
    mov     [esp+1Ch], edx
    add     ebx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     eax, [ebx+ecx*2+13Ah]
    push    eax
    mov     [esp+24h], eax
    lea     ebx, [ebx+ecx*2]
    call    sub_4B7F30
    mov     ecx, eax
    movsx   eax, word ptr [ebx+19h]
    movsx   ebp, word ptr [ebx+15h]
    cdq
    movsx   esi, word ptr [ebx+13h]
    sub     eax, edx
    mov     [esp+10h], ecx
    mov     edi, eax
    sar     edi, 1
    add     edi, ebp
    test    ecx, ecx
    jz      short loc_4A24F0
    xor     edx, edx
    mov     dx, [ecx+2]
    shr     edx, 1
    sub     edi, edx
    jmp     short loc_4A24F2
    ; ---------------------------------------------------------------------------

    loc_4A24F0:                             ; CODE XREF: .text:004A24E2j
    mov     edi, ebp

    loc_4A24F2:                             ; CODE XREF: .text:004A24EEj
    movsx   ebp, word ptr [ebx+17h]
    add     ebp, esi
    test    ecx, ecx
    jz      short loc_4A250D
    mov     eax, [esp+18h]
    push    edi
    push    esi
    push    ecx
    push    eax
    call    sub_4B7F90
    mov     ecx, [esp+10h]

    loc_4A250D:                             ; CODE XREF: .text:004A24FAj
    mov     eax, [esp+1Ch]
    xor     edx, edx
    mov     dx, [ecx]
    push    1
    push    eax
    add     esi, edx
    call    sub_4B7F30
    mov     ebx, eax
    xor     ecx, ecx
    mov     edx, esi
    mov     cx, [ebx]
    add     edx, ecx
    cmp     edx, ebp
    jge     short loc_4A254A

    loc_4A252F:                             ; CODE XREF: .text:004A2548j
    mov     eax, [esp+18h]
    push    edi
    push    esi
    push    ebx
    push    eax
    call    sub_4B7F90
    xor     eax, eax
    mov     ax, [ebx]
    add     esi, eax
    lea     ecx, [esi+eax]
    cmp     ecx, ebp
    jl      short loc_4A252F

    loc_4A254A:                             ; CODE XREF: .text:004A252Dj
    mov     edx, [esp+1Ch]
    push    2
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    push    edi
    mov     cx, [eax]
    mov     edx, [esp+1Ch]
    sub     ebp, ecx
    push    ebp
    push    eax
    push    edx
    call    sub_4B7F90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A2580 proc near                    ; CODE XREF: sub_4A2BE0+102p
                                            ; sub_4A3EF0+266p ...

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= byte ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_10= dword ptr -10h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 40h
    push    ebx
    push    ebp
    mov     ebp, [esp+48h+arg_0]
    push    esi
    push    edi
    mov     edi, [esp+50h+arg_4]
    mov     eax, [ebp+18h]
    mov     esi, 1
    mov     edx, [eax+4]
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    mov     [esp+50h+var_38], edx
    lea     ecx, [eax+eax*2]
    lea     eax, [edi+ecx*2]
    lea     ecx, [edi+eax*4]
    mov     eax, edx
    add     eax, edi
    lea     ebx, [eax+ecx*2]
    mov     ecx, [edx+0BCh]
    movsx   eax, word ptr [edx+0B6h]
    mov     [esp+50h+var_34], ecx
    xor     ecx, ecx
    inc     eax
    cmp     eax, esi
    jle     short loc_4A2621
    add     edx, 15Bh
    mov     [esp+50h+arg_4], edx

    loc_4A25D7:                             ; CODE XREF: sub_4A2580+76j
    cmp     byte ptr [edx], 7
    jnz     short loc_4A25E5
    movsx   edx, byte ptr [ebx+28h]
    cmp     ecx, edx
    jz      short loc_4A25FA
    inc     ecx

    loc_4A25E5:                             ; CODE XREF: sub_4A2580+5Aj
    mov     edx, [esp+50h+arg_4]
    inc     esi
    add     edx, 15Bh
    cmp     esi, eax
    mov     [esp+50h+arg_4], edx
    jl      short loc_4A25D7
    jmp     short loc_4A261D
    ; ---------------------------------------------------------------------------

    loc_4A25FA:                             ; CODE XREF: sub_4A2580+62j
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, [esp+50h+var_38]
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A261D:                             ; CODE XREF: sub_4A2580+78j
    mov     edx, [esp+50h+var_38]

    loc_4A2621:                             ; CODE XREF: sub_4A2580+4Bj
    movsx   eax, word ptr [edx+0B6h]
    inc     eax
    cmp     esi, eax
    jnz     short loc_4A263F
    mov     ecx, dword_51FBA4
    mov     edx, [ecx]
    push    edx
    call    sub_4C1420
    mov     edx, [esp+50h+var_38]

    loc_4A263F:                             ; CODE XREF: sub_4A2580+ABj
    lea     eax, [esp+50h+var_10]
    lea     ecx, [esp+50h+var_20]
    push    eax
    push    ecx
    push    edi
    push    edx
    call    sub_4A23B0
    mov     eax, [ebx+14Eh]
    test    eax, eax
    jnz     short loc_4A26AD
    mov     al, [ebp+8C3h]
    mov     esi, [esp+50h+var_34]
    xor     edx, edx
    xor     ecx, ecx
    mov     dl, [ebp+8C6h]
    mov     cl, [ebp+8B2h]
    push    edx
    push    eax
    lea     edx, [esp+58h+var_20]
    push    ecx
    push    edx
    push    esi
    call    sub_4B0510
    xor     eax, eax
    xor     ecx, ecx
    mov     al, [ebp+8C6h]
    mov     cl, [ebp+8C3h]
    xor     edx, edx
    push    eax
    mov     dl, [ebp+8B2h]
    push    ecx
    lea     eax, [esp+58h+var_10]
    push    edx
    push    eax
    push    esi
    call    sub_4B0590
    jmp     loc_4A29F3
    ; ---------------------------------------------------------------------------

    loc_4A26AD:                             ; CODE XREF: sub_4A2580+D8j
    mov     cx, [ebx+17h]
    mov     dx, [ebx+19h]
    cmp     cx, dx
    jge     loc_4A28CC
    mov     ecx, [ebp+18h]
    movsx   esi, word ptr [ebx+15h]
    mov     ecx, [ecx+4]
    movsx   edx, dx
    mov     ebp, [ecx+0BCh]
    movsx   edi, word ptr [ebx+13h]
    lea     ecx, [esi+edx-1]
    xor     edx, edx
    mov     dl, [ebx+152h]
    mov     [esp+50h+var_40], ecx
    push    edx
    push    eax
    call    sub_4B7F30
    test    eax, eax
    mov     [esp+50h+arg_4], eax
    jz      short loc_4A2701
    push    esi
    push    edi
    push    eax
    push    ebp
    call    sub_4B7F90
    mov     eax, [esp+50h+arg_4]

    loc_4A2701:                             ; CODE XREF: sub_4A2580+172j
    xor     ecx, ecx
    xor     edx, edx
    mov     cx, [eax+2]
    mov     dl, [ebx+152h]
    mov     eax, [ebx+14Eh]
    add     esi, ecx
    inc     edx
    push    edx
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     edx, esi
    mov     cx, [eax+2]
    mov     [esp+50h+arg_4], eax
    add     edx, ecx
    mov     ecx, [esp+50h+var_40]
    cmp     edx, ecx
    jg      short loc_4A275B
    jmp     short loc_4A273B
    ; ---------------------------------------------------------------------------

    loc_4A2737:                             ; CODE XREF: sub_4A2580+1D9j
    mov     eax, [esp+50h+arg_4]

    loc_4A273B:                             ; CODE XREF: sub_4A2580+1B5j
    push    esi
    push    edi
    push    eax
    push    ebp
    call    sub_4B7F90
    xor     eax, eax
    mov     ecx, [esp+50h+arg_4]
    mov     ax, [ecx+2]
    add     esi, eax
    lea     edx, [esi+eax]
    mov     eax, [esp+50h+var_40]
    cmp     edx, eax
    jle     short loc_4A2737

    loc_4A275B:                             ; CODE XREF: sub_4A2580+1B3j
    mov     ecx, [ebx+14Eh]
    xor     eax, eax
    mov     al, [ebx+152h]
    add     eax, 2
    push    eax
    push    ecx
    call    sub_4B7F30
    mov     esi, eax
    xor     edx, edx
    mov     eax, [esp+50h+var_40]
    mov     dx, [esi+2]
    sub     eax, edx
    inc     eax
    push    eax
    push    edi
    push    esi
    push    ebp
    call    sub_4B7F90
    mov     edx, [ebx+14Eh]
    xor     ecx, ecx
    mov     cl, [ebx+152h]
    xor     eax, eax
    mov     ax, [esi]
    add     ecx, 3
    shr     eax, 1
    push    ecx
    push    edx
    add     edi, eax
    call    sub_4B7F30
    movsx   edx, word ptr [ebx+140h]
    xor     ecx, ecx
    mov     [esp+50h+arg_4], eax
    mov     cx, [eax]
    movsx   eax, word ptr [ebx+19h]
    shr     ecx, 1
    sub     edi, ecx
    add     eax, 0FFFFFFFAh
    movsx   ecx, word ptr [ebx+15h]
    mov     [esp+50h+var_3C], eax
    lea     esi, [edx+ecx+3]
    movsx   edx, word ptr [ebx+142h]
    cmp     eax, edx
    jl      short loc_4A27E2
    mov     [esp+50h+var_3C], edx

    loc_4A27E2:                             ; CODE XREF: sub_4A2580+25Cj
    mov     eax, [esp+50h+var_3C]
    lea     edx, [eax+esi-1]
    movsx   eax, word ptr [ebx+19h]
    mov     [esp+50h+var_40], edx
    lea     ecx, [eax+ecx-4]
    cmp     edx, ecx
    jl      short loc_4A2800
    mov     [esp+50h+var_40], ecx
    mov     edx, ecx

    loc_4A2800:                             ; CODE XREF: sub_4A2580+278j
    sub     edx, [esp+50h+var_3C]
    lea     eax, [edx+1]
    cmp     esi, eax
    jle     short loc_4A280D
    mov     esi, eax

    loc_4A280D:                             ; CODE XREF: sub_4A2580+289j
    mov     ecx, [esp+50h+arg_4]
    push    esi
    push    edi
    push    ecx
    push    ebp
    call    sub_4B7F90
    xor     eax, eax
    mov     ecx, [ebx+14Eh]
    mov     edx, [esp+50h+arg_4]
    mov     ax, [edx+2]
    mov     edx, [esp+50h+var_3C]
    sub     edx, eax
    add     esi, eax
    xor     eax, eax
    mov     [esp+50h+var_3C], edx
    mov     al, [ebx+152h]
    add     eax, 4
    push    eax
    push    ecx
    call    sub_4B7F30
    xor     edx, edx
    mov     dx, [eax+2]
    mov     ecx, [esp+50h+var_40]
    sub     ecx, edx
    mov     [esp+50h+arg_4], eax
    cmp     esi, ecx
    jg      short loc_4A2887

    loc_4A285C:                             ; CODE XREF: sub_4A2580+305j
    push    esi
    push    edi
    push    eax
    push    ebp
    call    sub_4B7F90
    xor     eax, eax
    mov     edx, [esp+50h+arg_4]
    mov     ecx, [esp+50h+var_3C]
    mov     ax, [edx+2]
    sub     ecx, eax
    add     esi, eax
    mov     [esp+50h+var_3C], ecx
    mov     ecx, [esp+50h+var_40]
    sub     ecx, eax
    mov     eax, edx
    cmp     esi, ecx
    jle     short loc_4A285C

    loc_4A2887:                             ; CODE XREF: sub_4A2580+2DAj
    mov     ecx, [esp+50h+var_40]
    xor     edx, edx
    mov     dx, [eax+2]
    sub     ecx, edx
    push    ecx
    push    edi
    push    eax
    push    ebp
    call    sub_4B7F90
    mov     eax, [ebx+14Eh]
    xor     edx, edx
    mov     dl, [ebx+152h]
    add     edx, 5
    push    edx
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     edx, ecx
    mov     ecx, [esp+50h+var_40]
    sub     ecx, edx
    inc     ecx
    push    ecx
    push    edi
    push    eax
    push    ebp
    jmp     loc_4A29EA
    ; ---------------------------------------------------------------------------

    loc_4A28CC:                             ; CODE XREF: sub_4A2580+138j
    mov     edx, [ebp+18h]
    movsx   esi, word ptr [ebx+13h]
    mov     edx, [edx+4]
    movsx   ebp, word ptr [ebx+15h]
    mov     edx, [edx+0BCh]
    mov     [esp+50h+var_3C], edx
    xor     edx, edx
    mov     dl, [ebx+152h]
    movsx   ecx, cx
    push    edx
    push    eax
    lea     edi, [esi+ecx-1]
    call    sub_4B7F30
    test    eax, eax
    mov     [esp+50h+arg_4], eax
    jz      short loc_4A2913
    push    ebp
    push    esi
    push    eax
    mov     eax, [esp+5Ch+var_3C]
    push    eax
    call    sub_4B7F90
    mov     eax, [esp+50h+arg_4]

    loc_4A2913:                             ; CODE XREF: sub_4A2580+380j
    xor     ecx, ecx
    xor     edx, edx
    mov     cx, [eax]
    mov     dl, [ebx+152h]
    mov     eax, [ebx+14Eh]
    add     esi, ecx
    inc     edx
    push    edx
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     edx, esi
    mov     cx, [eax]
    mov     [esp+50h+arg_4], eax
    add     edx, ecx
    cmp     edx, edi
    jg      short loc_4A2966
    jmp     short loc_4A2947
    ; ---------------------------------------------------------------------------

    loc_4A2943:                             ; CODE XREF: sub_4A2580+3E4j
    mov     eax, [esp+50h+arg_4]

    loc_4A2947:                             ; CODE XREF: sub_4A2580+3C1j
    push    ebp
    push    esi
    push    eax
    mov     eax, [esp+5Ch+var_3C]
    push    eax
    call    sub_4B7F90
    xor     eax, eax
    mov     ecx, [esp+50h+arg_4]
    mov     ax, [ecx]
    add     esi, eax
    lea     edx, [esi+eax]
    cmp     edx, edi
    jle     short loc_4A2943

    loc_4A2966:                             ; CODE XREF: sub_4A2580+3BFj
    mov     ecx, [ebx+14Eh]
    xor     eax, eax
    mov     al, [ebx+152h]
    add     eax, 2
    push    eax
    push    ecx
    call    sub_4B7F30
    mov     esi, eax
    xor     edx, edx
    mov     ecx, [esp+50h+var_3C]
    mov     eax, edi
    mov     dx, [esi]
    push    ebp
    sub     eax, edx
    inc     eax
    push    eax
    push    esi
    push    ecx
    call    sub_4B7F90
    mov     ecx, [ebx+14Eh]
    xor     eax, eax
    mov     al, [ebx+152h]
    xor     edx, edx
    mov     dx, [esi+2]
    add     eax, 3
    shr     edx, 1
    push    eax
    push    ecx
    add     ebp, edx
    call    sub_4B7F30
    movsx   ecx, word ptr [ebx+140h]
    xor     edx, edx
    mov     dx, [eax+2]
    shr     edx, 1
    sub     ebp, edx
    movsx   edx, word ptr [ebx+13h]
    lea     ecx, [ecx+edx+3]
    xor     edx, edx
    mov     dx, [eax]
    sub     edi, edx
    add     edi, 0FFFFFFFEh
    cmp     ecx, edi
    jl      short loc_4A29E2
    mov     ecx, edi

    loc_4A29E2:                             ; CODE XREF: sub_4A2580+45Ej
    push    ebp
    push    ecx
    push    eax
    mov     eax, [esp+5Ch+var_3C]
    push    eax

    loc_4A29EA:                             ; CODE XREF: sub_4A2580+347j
    call    sub_4B7F90
    mov     ebp, [esp+50h+arg_0]

    loc_4A29F3:                             ; CODE XREF: sub_4A2580+128j
    test    byte ptr [ebx+1Bh], 4
    jz      loc_4A2B66
    call    sub_4C13F0
    xor     ecx, ecx
    push    eax
    mov     cl, [ebp+8C1h]
    push    ecx
    call    sub_4C13A0
    mov     al, [ebx+0B6h]
    lea     edi, [ebx+0B6h]
    test    al, al
    jz      short loc_4A2A44
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+50h+var_30]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_4A2AB7
    ; ---------------------------------------------------------------------------

    loc_4A2A44:                             ; CODE XREF: sub_4A2580+49Fj
    mov     eax, [ebx+13Ch]
    test    eax, eax
    mov     [esp+50h+arg_4], eax
    jz      short loc_4A2A89
    movsx   ecx, word ptr [ebx+140h]
    movsx   edx, word ptr [ebx+142h]
    movsx   eax, word ptr [ebx+17h]
    mov     [esp+50h+arg_0], ecx
    sub     eax, edx
    fild    [esp+50h+arg_0]
    mov     [esp+50h+arg_0], eax
    fimul   [esp+50h+arg_4]
    fidiv   [esp+50h+arg_0]
    call    __ftol
    lea     ecx, [esp+50h+var_30]
    push    0Ah
    push    ecx
    push    eax
    jmp     short loc_4A2AAF
    ; ---------------------------------------------------------------------------

    loc_4A2A89:                             ; CODE XREF: sub_4A2580+4D0j
    mov     al, [ebx+1Bh]
    push    0Ah                             ; int
    test    al, 8
    jz      short loc_4A2AA2
    movsx   eax, word ptr [ebx+140h]
    lea     edx, [esp+54h+var_30]
    inc     eax
    push    edx
    push    eax
    jmp     short loc_4A2AAF
    ; ---------------------------------------------------------------------------

    loc_4A2AA2:                             ; CODE XREF: sub_4A2580+510j
    movsx   edx, word ptr [ebx+140h]
    lea     ecx, [esp+54h+var_30]
    push    ecx                             ; char *
    push    edx                             ; int

    loc_4A2AAF:                             ; CODE XREF: sub_4A2580+507j
                                            ; sub_4A2580+520j
    call    __itoa
    add     esp, 0Ch

    loc_4A2AB7:                             ; CODE XREF: sub_4A2580+4C2j
    lea     eax, [esp+50h+var_30]
    xor     edi, edi
    test    eax, eax
    jz      short loc_4A2B22
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A2AE0
    lea     edx, [esp+50h+var_30]
    push    edx
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    jmp     short loc_4A2B22
    ; ---------------------------------------------------------------------------

    loc_4A2AE0:                             ; CODE XREF: sub_4A2580+54Cj
    mov     al, [esp+50h+var_30]
    lea     esi, [esp+50h+var_30]
    test    al, al
    jz      short loc_4A2B22

    loc_4A2AEC:                             ; CODE XREF: sub_4A2580+5A0j
    mov     al, [esi]
    mov     edx, dword_51FBA4
    mov     byte ptr [esp+50h+arg_0], al
    mov     ecx, [esp+50h+arg_0]
    mov     eax, [edx+14h]
    and     ecx, 0FFh
    push    ecx
    mov     ecx, [eax+0Ch]
    push    ecx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A2B1A
    xor     edx, edx
    mov     dx, [eax]
    add     edi, edx

    loc_4A2B1A:                             ; CODE XREF: sub_4A2580+591j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A2AEC

    loc_4A2B22:                             ; CODE XREF: sub_4A2580+53Fj
                                            ; sub_4A2580+55Ej ...
    mov     eax, dword_51FBA4
    mov     eax, [eax+14h]
    test    eax, eax
    jnz     short loc_4A2B35
    call    sub_4C1450
    jmp     short loc_4A2B40
    ; ---------------------------------------------------------------------------

    loc_4A2B35:                             ; CODE XREF: sub_4A2580+5ACj
    mov     ecx, [eax+0Ch]
    push    49h
    push    ecx
    call    sub_4B7F30

    loc_4A2B40:                             ; CODE XREF: sub_4A2580+5B3j
    movsx   edx, word ptr [ebx+15h]
    movsx   eax, word ptr [ebx+13h]
    movsx   ecx, word ptr [ebx+17h]
    add     edx, 4
    push    0FFFFFFFFh
    push    edx
    lea     edx, [eax+ecx+2]
    mov     ecx, [esp+58h+var_34]
    lea     eax, [esp+58h+var_30]
    push    edx
    push    eax
    push    ecx
    call    PrintGUIText

    loc_4A2B66:                             ; CODE XREF: sub_4A2580+477j
    test    byte ptr [ebx+1Bh], 10h
    jnz     short loc_4A2B76
    mov     eax, [ebx+157h]
    test    eax, eax
    jz      short loc_4A2BD5

    loc_4A2B76:                             ; CODE XREF: sub_4A2580+5EAj
    cmp     byte ptr [ebx], 0
    jnz     short loc_4A2B85
    xor     eax, eax
    xor     ecx, ecx
    mov     dword ptr [esp+50h+var_30], eax
    jmp     short loc_4A2B91
    ; ---------------------------------------------------------------------------

    loc_4A2B85:                             ; CODE XREF: sub_4A2580+5F9j
    movsx   eax, word ptr [ebx+13h]
    movsx   ecx, word ptr [ebx+15h]
    mov     dword ptr [esp+50h+var_30], eax

    loc_4A2B91:                             ; CODE XREF: sub_4A2580+603j
    movsx   edx, word ptr [ebx+17h]
    mov     esi, [esp+50h+var_38]
    mov     [esp+50h+var_2C], ecx
    lea     eax, [edx+eax-1]
    movsx   edx, word ptr [ebx+19h]
    mov     [esp+50h+var_28], eax
    lea     eax, [edx+ecx-1]
    mov     edx, [esi+0BCh]
    lea     ecx, [esp+50h+var_30]
    mov     [esp+50h+var_24], eax
    push    ecx
    push    edx
    call    sub_4BFE10
    mov     ecx, [esi+0BCh]
    lea     eax, [esp+50h+var_30]
    push    0FFFFFFECh
    push    eax
    push    ecx
    call    sub_4BF4D0

    loc_4A2BD5:                             ; CODE XREF: sub_4A2580+5F4j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    8
    sub_4A2580 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A2BE0 proc near                    ; CODE XREF: .text:004779C0p
                                            ; .text:00477A8Cp ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    mov     eax, [esp+10h+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     edi, 1
    mov     ebp, [ecx+4]
    mov     ecx, [esp+20h+arg_4]
    mov     eax, ecx
    mov     [esp+20h+var_4], ebp
    shl     eax, 3
    sub     eax, ecx
    mov     [esp+20h+var_10], edi
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     eax, ebp
    add     eax, ecx
    lea     ebx, [eax+edx*2]
    xor     edx, edx
    mov     dl, [ebx]
    mov     eax, [ebx+1Bh]
    mov     esi, edx
    mov     [esp+20h+var_8], eax
    movsx   edx, word ptr [ebp+0B6h]
    inc     edx
    mov     [esp+20h+var_C], esi
    cmp     edx, edi
    jle     loc_4A2E2B
    add     ebp, 29Bh
    jmp     short loc_4A2C46
    ; ---------------------------------------------------------------------------

    loc_4A2C42:                             ; CODE XREF: sub_4A2BE0+245j
    mov     ecx, [esp+20h+arg_4]

    loc_4A2C46:                             ; CODE XREF: sub_4A2BE0+60j
    cmp     edi, ecx
    jz      loc_4A2E0C
    mov     al, [ebp-13Fh]
    mov     cl, [ebx+1]
    cmp     al, cl
    jnz     loc_4A2E0C
    xor     eax, eax
    mov     al, [ebp-140h]
    sub     eax, 2
    jz      loc_4A2D51
    dec     eax
    jz      short loc_4A2CEC
    dec     eax
    jnz     loc_4A2E0C
    cmp     esi, 2
    jnz     loc_4A2E0C
    cmp     word ptr [ebx+0C0h], 1
    jle     loc_4A2E0C
    mov     ax, [ebx+0BEh]
    test    ax, ax
    jz      short loc_4A2CCA
    movsx   ecx, word ptr [ebx+0BCh]
    movsx   edx, word ptr [ebp-0Ah]
    mov     [esp+20h+var_10], ecx
    fild    [esp+20h+var_10]
    movsx   eax, ax
    mov     [esp+20h+var_10], edx
    fimul   [esp+20h+var_10]
    mov     [esp+20h+var_10], eax
    fidiv   [esp+20h+var_10]
    call    __ftol
    jmp     short loc_4A2CCC
    ; ---------------------------------------------------------------------------

    loc_4A2CCA:                             ; CODE XREF: sub_4A2BE0+BBj
    xor     eax, eax

    loc_4A2CCC:                             ; CODE XREF: sub_4A2BE0+E8j
    movsx   ecx, word ptr [ebp+0]
    cmp     ecx, eax
    jz      loc_4A2E0C
    mov     edx, [esp+20h+arg_0]
    push    edi
    push    edx
    mov     [ebp+0], ax
    call    sub_4A2580
    jmp     loc_4A2E0C
    ; ---------------------------------------------------------------------------

    loc_4A2CEC:                             ; CODE XREF: sub_4A2BE0+91j
    cmp     esi, 2
    jnz     loc_4A2E0C
    test    byte ptr [esp+20h+var_8], 8
    jz      loc_4A2E0C
    movsx   eax, word ptr [ebx+0BAh]
    mov     ecx, [ebx+0C2h]
    push    eax
    push    ecx
    call    sub_4B6AF0
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp-8Ah]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, [esp+20h+arg_0]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+20h+var_10]
    push    ecx
    push    edx
    call    sub_4A4D70
    mov     edi, [esp+20h+var_10]
    jmp     loc_4A2E08
    ; ---------------------------------------------------------------------------

    loc_4A2D51:                             ; CODE XREF: sub_4A2BE0+8Aj
    cmp     esi, 2
    jnz     short loc_4A2D82
    mov     ax, [ebx+0BCh]
    mov     edx, [esp+20h+arg_0]
    mov     [ebp-84h], ax
    mov     cx, [ebx+0BAh]
    push    edi
    push    edx
    mov     [ebp-86h], cx
    call    sub_4A1B40
    jmp     loc_4A2E0C
    ; ---------------------------------------------------------------------------

    loc_4A2D82:                             ; CODE XREF: sub_4A2BE0+174j
    cmp     esi, 4
    jnz     loc_4A2E0C
    test    byte ptr [ebp-125h], 20h
    jz      short loc_4A2DAA
    movsx   eax, word ptr [ebx+136h]
    movsx   ecx, word ptr [ebp-82h]
    cdq
    inc     ecx
    idiv    ecx
    mov     esi, eax
    jmp     short loc_4A2DAC
    ; ---------------------------------------------------------------------------

    loc_4A2DAA:                             ; CODE XREF: sub_4A2BE0+1B2j
    xor     esi, esi

    loc_4A2DAC:                             ; CODE XREF: sub_4A2BE0+1C8j
    mov     cx, [ebp-66h]
    test    cx, cx
    jz      short loc_4A2DFD
    movsx   eax, word ptr [ebp-127h]
    movsx   ecx, cx
    cdq
    idiv    ecx
    movsx   edx, word ptr [ebp-80h]
    movsx   ecx, word ptr [ebx+136h]
    sub     edx, eax
    movsx   eax, word ptr [ebx+140h]
    mov     [esp+20h+var_10], edx
    add     eax, esi
    fild    [esp+20h+var_10]
    mov     [esp+20h+var_10], eax
    dec     ecx
    fimul   [esp+20h+var_10]
    mov     [esp+20h+var_10], ecx
    fidiv   [esp+20h+var_10]
    call    __ftol
    mov     [ebp-84h], ax

    loc_4A2DFD:                             ; CODE XREF: sub_4A2BE0+1D3j
    mov     edx, [esp+20h+arg_0]
    push    edi
    push    edx
    call    sub_4A1B40

    loc_4A2E08:                             ; CODE XREF: sub_4A2BE0+16Cj
    mov     esi, [esp+20h+var_C]

    loc_4A2E0C:                             ; CODE XREF: sub_4A2BE0+68j
                                            ; sub_4A2BE0+79j ...
    mov     eax, [esp+20h+var_4]
    inc     edi
    add     ebp, 15Bh
    mov     [esp+20h+var_10], edi
    movsx   ecx, word ptr [eax+0B6h]
    inc     ecx
    cmp     edi, ecx
    jl      loc_4A2C42

    loc_4A2E2B:                             ; CODE XREF: sub_4A2BE0+54j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    sub_4A2BE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A2E40 proc near                    ; CODE XREF: sub_41F0A0+246p
                                            ; sub_41F0A0+271p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= word ptr  0Ch

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    mov     edi, 1
    mov     esi, [ecx+4]
    movsx   edx, word ptr [esi+0B6h]
    inc     edx
    cmp     edx, edi
    jle     short loc_4A2E90
    lea     ebx, [esi+15Dh]

    loc_4A2E65:                             ; CODE XREF: sub_4A2E40+4Ej
    mov     eax, [esp+10h+arg_4]
    push    10h                             ; size_t
    push    eax                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      loc_4A30B9
    movsx   ecx, word ptr [esi+0B6h]
    inc     edi
    add     ebx, 15Bh
    inc     ecx
    cmp     edi, ecx
    jl      short loc_4A2E65

    loc_4A2E90:                             ; CODE XREF: sub_4A2E40+1Dj
    or      ecx, 0FFFFFFFFh

    loc_4A2E93:                             ; CODE XREF: sub_4A2E40+27Bj
    cmp     ecx, 0FFFFFFFFh
    jz      loc_4A30B2
    mov     eax, ecx
    mov     edi, 1
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     eax, esi
    add     eax, ecx
    mov     cx, [esp+10h+arg_8]
    lea     ebp, [eax+edx*2]
    xor     edx, edx
    mov     [ebp+0BAh], cx
    movsx   eax, word ptr [esi+0B6h]
    inc     eax
    cmp     eax, edi
    jle     short loc_4A2F14
    lea     ecx, [esi+15Bh]

    loc_4A2ED8:                             ; CODE XREF: sub_4A2E40+AFj
    cmp     byte ptr [ecx], 7
    jnz     short loc_4A2EE6
    movsx   ebx, byte ptr [ebp+28h]
    cmp     edx, ebx
    jz      short loc_4A2EF3
    inc     edx

    loc_4A2EE6:                             ; CODE XREF: sub_4A2E40+9Bj
    inc     edi
    add     ecx, 15Bh
    cmp     edi, eax
    jl      short loc_4A2ED8
    jmp     short loc_4A2F14
    ; ---------------------------------------------------------------------------

    loc_4A2EF3:                             ; CODE XREF: sub_4A2E40+A3j
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     edx, [eax+eax*2]
    lea     eax, [edi+edx*2]
    mov     edx, esi
    add     edx, edi
    lea     ecx, [edi+eax*4]
    mov     eax, [edx+ecx*2+0D6h]
    push    eax
    call    sub_4C1420

    loc_4A2F14:                             ; CODE XREF: sub_4A2E40+90j
                                            ; sub_4A2E40+B1j
    movsx   ecx, word ptr [esi+0B6h]
    inc     ecx
    cmp     edi, ecx
    jnz     short loc_4A2F2E
    mov     edx, dword_51FBA4
    mov     eax, [edx]
    push    eax
    call    sub_4C1420

    loc_4A2F2E:                             ; CODE XREF: sub_4A2E40+DEj
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A2F44
    call    sub_4C1450
    mov     ecx, eax
    jmp     short loc_4A2F58
    ; ---------------------------------------------------------------------------

    loc_4A2F44:                             ; CODE XREF: sub_4A2E40+F9j
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    add     ecx, 2

    loc_4A2F58:                             ; CODE XREF: sub_4A2E40+102j
    movsx   eax, word ptr [ebp+19h]
    sub     eax, 2
    inc     ecx
    cdq
    idiv    ecx
    mov     bx, [ebp+0BCh]
    mov     di, [ebp+0BAh]
    movsx   ecx, bx
    lea     edx, [eax+ecx-1]
    movsx   eax, di
    cmp     eax, edx
    jg      short loc_4A2F88
    cmp     di, bx
    jge     loc_4A30A4

    loc_4A2F88:                             ; CODE XREF: sub_4A2E40+13Dj
    mov     ax, [ebp+0BEh]
    test    ax, ax
    jz      short loc_4A2F9B
    mov     [ebp+0BCh], di

    loc_4A2F9B:                             ; CODE XREF: sub_4A2E40+152j
    cmp     [ebp+0BCh], ax
    jle     short loc_4A2FAB
    mov     [ebp+0BCh], ax

    loc_4A2FAB:                             ; CODE XREF: sub_4A2E40+162j
    movsx   ecx, word ptr [esi+0B6h]
    mov     edi, 1
    inc     ecx
    cmp     ecx, edi
    jle     short loc_4A2FEF
    lea     ebx, [esi+15Dh]

    loc_4A2FC2:                             ; CODE XREF: sub_4A2E40+1A7j
    mov     edx, [esp+10h+arg_4]
    push    10h                             ; size_t
    push    edx                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A2FEB
    movsx   eax, word ptr [esi+0B6h]
    inc     edi
    add     ebx, 15Bh
    inc     eax
    cmp     edi, eax
    jl      short loc_4A2FC2
    jmp     short loc_4A2FEF
    ; ---------------------------------------------------------------------------

    loc_4A2FEB:                             ; CODE XREF: sub_4A2E40+194j
    mov     ecx, edi
    jmp     short loc_4A2FF2
    ; ---------------------------------------------------------------------------

    loc_4A2FEF:                             ; CODE XREF: sub_4A2E40+17Aj
                                            ; sub_4A2E40+1A9j
    or      ecx, 0FFFFFFFFh

    loc_4A2FF2:                             ; CODE XREF: sub_4A2E40+1ADj
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     eax, esi
    add     eax, ecx
    mov     ecx, 1
    mov     dl, [eax+edx*2+1]
    movsx   eax, word ptr [esi+0B6h]
    lea     edi, [eax+1]
    cmp     edi, ecx
    jle     short loc_4A3037
    lea     eax, [esi+15Bh]

    loc_4A3023:                             ; CODE XREF: sub_4A2E40+1F5j
    cmp     byte ptr [eax], 4
    jnz     short loc_4A302D
    cmp     [eax+1], dl
    jz      short loc_4A3039

    loc_4A302D:                             ; CODE XREF: sub_4A2E40+1E6j
    inc     ecx
    add     eax, 15Bh
    cmp     ecx, edi
    jl      short loc_4A3023

    loc_4A3037:                             ; CODE XREF: sub_4A2E40+1DBj
    xor     ecx, ecx

    loc_4A3039:                             ; CODE XREF: sub_4A2E40+1EBj
    mov     eax, ecx
    add     esi, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    movsx   eax, word ptr [esi+edx*2+136h]
    movsx   ecx, word ptr [ebp+0BCh]
    lea     esi, [esi+edx*2]
    mov     [esp+10h+arg_4], eax
    fild    [esp+10h+arg_4]
    movsx   edx, word ptr [ebp+0BEh]
    movsx   eax, word ptr [esi+140h]
    mov     [esp+10h+arg_4], ecx
    fimul   [esp+10h+arg_4]
    mov     [esp+10h+arg_4], edx
    fidiv   [esp+10h+arg_4]
    mov     [esp+10h+arg_4], eax
    fild    [esp+10h+arg_4]
    fcomp   st(1)
    fnstsw  ax
    test    ah, 40h
    jnz     short loc_4A30A2
    call    __ftol
    mov     [esi+140h], ax
    jmp     short loc_4A30A4
    ; ---------------------------------------------------------------------------

    loc_4A30A2:                             ; CODE XREF: sub_4A2E40+252j
    fstp    st

    loc_4A30A4:                             ; CODE XREF: sub_4A2E40+142j
                                            ; sub_4A2E40+260j
    mov     ecx, [esp+10h+arg_0]
    mov     dword ptr [ecx+0CCAh], 1

    loc_4A30B2:                             ; CODE XREF: sub_4A2E40+56j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A30B9:                             ; CODE XREF: sub_4A2E40+37j
    mov     ecx, edi
    jmp     loc_4A2E93
    sub_4A2E40 endp

    ; ---------------------------------------------------------------------------
    mov     eax, [esp+4]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    mov     eax, [esp+14h]
    push    edi
    mov     esi, 1
    mov     ebx, [ecx+4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebx
    add     ecx, eax
    lea     edi, [ecx+edx*2]
    xor     edx, edx
    mov     [edi+0BCh], dx
    mov     [edi+0BAh], dx
    movsx   eax, word ptr [ebx+0B6h]
    inc     eax
    cmp     eax, esi
    jle     short loc_4A314C
    lea     ecx, [ebx+15Bh]

    loc_4A3110:                             ; CODE XREF: .text:004A3127j
    cmp     byte ptr [ecx], 7
    jnz     short loc_4A311E
    movsx   ebp, byte ptr [edi+28h]
    cmp     edx, ebp
    jz      short loc_4A312B
    inc     edx

    loc_4A311E:                             ; CODE XREF: .text:004A3113j
    inc     esi
    add     ecx, 15Bh
    cmp     esi, eax
    jl      short loc_4A3110
    jmp     short loc_4A314C
    ; ---------------------------------------------------------------------------

    loc_4A312B:                             ; CODE XREF: .text:004A311Bj
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    mov     edx, ebx
    add     edx, esi
    lea     ecx, [esi+eax*4]
    mov     eax, [edx+ecx*2+0D6h]
    push    eax
    call    sub_4C1420

    loc_4A314C:                             ; CODE XREF: .text:004A3108j
                                            ; .text:004A3129j
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     esi, ecx
    jnz     short loc_4A3166
    mov     edx, dword_51FBA4
    mov     eax, [edx]
    push    eax
    call    sub_4C1420

    loc_4A3166:                             ; CODE XREF: .text:004A3156j
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A317A
    call    sub_4C1450
    jmp     short loc_4A3190
    ; ---------------------------------------------------------------------------

    loc_4A317A:                             ; CODE XREF: .text:004A3171j
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A3190:                             ; CODE XREF: .text:004A3178j
    movsx   ecx, word ptr [edi+19h]
    lea     esi, [eax+2]
    mov     eax, ecx
    cdq
    idiv    esi
    sub     ecx, edx
    mov     [edi+19h], cx
    call    sub_4B6340
    mov     [edi+0B6h], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 68h
    mov     eax, [esp+74h]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax-44h]
    push    edi
    push    ecx
    push    offset aScrollitems             ; "SCROLLITEMS"
    call    sub_4D83B0
    mov     ecx, [esp+90h]
    add     esp, 8
    xor     ebp, ebp
    mov     [esp+10h], eax
    test    ecx, ecx
    mov     ebx, eax
    jle     short loc_4A326D

    loc_4A31EF:                             ; CODE XREF: .text:004A3267j
    mov     edx, [esp+84h]
    push    64h
    push    ebp
    push    edx
    call    sub_4B6AF0
    push    eax
    lea     eax, [esp+1Ch]
    push    eax
    call    _strncpy
    mov     ecx, [esp+8Ch]
    mov     eax, [esp+88h]
    add     esp, 0Ch
    lea     edx, [esp+14h]
    push    0
    push    0FFFFFFFFh
    push    ecx
    push    edx
    push    eax
    call    sub_4AC610
    lea     edi, [esp+14h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    lea     edi, [esp+14h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    add     ebx, ecx
    mov     [ebx], al
    mov     eax, [esp+88h]
    inc     ebx
    inc     ebp
    cmp     ebp, eax
    jl      short loc_4A31EF
    mov     eax, [esp+10h]

    loc_4A326D:                             ; CODE XREF: .text:004A31EDj
    mov     edi, [esp+84h]
    mov     ecx, ebx
    sub     ecx, eax
    mov     esi, eax
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A32A0 proc near                    ; CODE XREF: sub_41F0A0+206p
                                            ; sub_441460+5A9p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [eax+18h]
    mov     ebp, [esp+10h+arg_4]
    push    edi
    mov     edi, 1
    mov     esi, [eax+4]
    mov     [esp+14h+var_4], eax
    movsx   ecx, word ptr [esi+0B6h]
    inc     ecx
    cmp     ecx, edi
    jle     short loc_4A32F1
    lea     ebx, [esi+15Dh]

    loc_4A32CE:                             ; CODE XREF: sub_4A32A0+4Fj
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A32F4
    movsx   edx, word ptr [esi+0B6h]
    inc     edi
    add     ebx, 15Bh
    inc     edx
    cmp     edi, edx
    jl      short loc_4A32CE

    loc_4A32F1:                             ; CODE XREF: sub_4A32A0+26j
    or      edi, 0FFFFFFFFh

    loc_4A32F4:                             ; CODE XREF: sub_4A32A0+3Cj
    cmp     edi, 0FFFFFFFFh
    jz      short loc_4A3310
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    add     esi, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    lea     edx, [edi+ecx*4]
    lea     esi, [esi+edx*2]
    jmp     short loc_4A331C
    ; ---------------------------------------------------------------------------

    loc_4A3310:                             ; CODE XREF: sub_4A32A0+57j
    push    offset aErrorInGuiLayo          ; lpText
    call    sub_4B6290
    xor     esi, esi

    loc_4A331C:                             ; CODE XREF: sub_4A32A0+6Ej
    mov     edx, [esi+1Bh]
    mov     ebx, [esp+14h+arg_C]
    mov     eax, [esp+14h+arg_8]
    or      edx, 10h
    mov     [esi+0C0h], bx
    mov     [esi+0C2h], eax
    mov     [esi+1Bh], edx
    mov     ecx, dword_51FBA4
    xor     edi, edi
    mov     eax, [ecx+14h]
    cmp     eax, edi
    jnz     short loc_4A3350
    call    sub_4C1450
    jmp     short loc_4A3366
    ; ---------------------------------------------------------------------------

    loc_4A3350:                             ; CODE XREF: sub_4A32A0+A7j
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A3366:                             ; CODE XREF: sub_4A32A0+AEj
    movsx   ecx, word ptr [esi+0DAh]
    inc     eax
    cmp     ecx, eax
    jle     short loc_4A3376
    mov     eax, ecx
    jmp     short loc_4A33A1
    ; ---------------------------------------------------------------------------

    loc_4A3376:                             ; CODE XREF: sub_4A32A0+D0j
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    cmp     eax, edi
    jnz     short loc_4A338A
    call    sub_4C1450
    jmp     short loc_4A33A0
    ; ---------------------------------------------------------------------------

    loc_4A338A:                             ; CODE XREF: sub_4A32A0+E1j
    mov     eax, [eax+0Ch]
    push    49h
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A33A0:                             ; CODE XREF: sub_4A32A0+E8j
    inc     eax

    loc_4A33A1:                             ; CODE XREF: sub_4A32A0+D4j
    mov     [esi+0DAh], ax
    mov     eax, [esp+14h+arg_10]
    cmp     eax, edi
    jz      short loc_4A33BF
    mov     [esi+0D6h], eax
    mov     eax, [esi+1Bh]
    or      ah, 8
    mov     [esi+1Bh], eax

    loc_4A33BF:                             ; CODE XREF: sub_4A32A0+10Ej
    cmp     word ptr [esi+0DAh], 0
    mov     [esi+0BCh], di
    mov     [esi+0BAh], di
    lea     edx, [ebx-1]
    movsx   edi, word ptr [esi+19h]
    mov     [esp+14h+arg_0], edi
    mov     [esi+0BEh], dx
    jnz     short loc_4A341A
    mov     eax, dword_51FBA4
    mov     eax, [eax+14h]
    test    eax, eax
    jnz     short loc_4A33FF
    call    sub_4C1450
    lea     ecx, [eax+1]
    jmp     short loc_4A3421
    ; ---------------------------------------------------------------------------

    loc_4A33FF:                             ; CODE XREF: sub_4A32A0+153j
    mov     ecx, [eax+0Ch]
    push    49h
    push    ecx
    call    sub_4B7F30
    xor     edx, edx
    mov     dx, [eax+2]
    mov     eax, edx
    add     eax, 2
    lea     ecx, [eax+1]
    jmp     short loc_4A3421
    ; ---------------------------------------------------------------------------

    loc_4A341A:                             ; CODE XREF: sub_4A32A0+147j
    movsx   ecx, word ptr [esi+0DAh]

    loc_4A3421:                             ; CODE XREF: sub_4A32A0+15Dj
                                            ; sub_4A32A0+178j
    lea     eax, [ebx-1]
    cmp     eax, 0FFFFFFFFh
    jle     short loc_4A343E

    loc_4A3429:                             ; CODE XREF: sub_4A32A0+198j
    sub     edi, ecx
    js      short loc_4A343A
    mov     [esi+0BEh], ax
    dec     eax
    cmp     eax, 0FFFFFFFFh
    jg      short loc_4A3429

    loc_4A343A:                             ; CODE XREF: sub_4A32A0+18Bj
    mov     [esp+14h+arg_0], edi

    loc_4A343E:                             ; CODE XREF: sub_4A32A0+187j
    mov     al, [esi+29h]
    test    al, al
    jz      loc_4A358E
    mov     eax, [esp+14h+var_4]
    mov     esi, 1
    mov     ebx, [eax+4]
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4A348E
    lea     edi, [ebx+15Dh]

    loc_4A3467:                             ; CODE XREF: sub_4A32A0+1ECj
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      loc_4A3596
    movsx   edx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_4A3467

    loc_4A348E:                             ; CODE XREF: sub_4A32A0+1BFj
    or      ecx, 0FFFFFFFFh

    loc_4A3491:                             ; CODE XREF: sub_4A32A0+2F8j
    mov     eax, [esp+14h+var_4]
    mov     esi, [eax+4]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    movsx   edi, word ptr [esi+0B6h]
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     eax, esi
    add     eax, ecx
    inc     edi
    mov     dl, [eax+edx*2+1]
    mov     eax, 1
    cmp     edi, eax
    jle     short loc_4A34E2
    lea     ecx, [esi+15Bh]

    loc_4A34C7:                             ; CODE XREF: sub_4A32A0+23Aj
    cmp     byte ptr [ecx], 4
    jnz     short loc_4A34D1
    cmp     [ecx+1], dl
    jz      short loc_4A34DE

    loc_4A34D1:                             ; CODE XREF: sub_4A32A0+22Aj
    inc     eax
    add     ecx, 15Bh
    cmp     eax, edi
    jl      short loc_4A34C7
    jmp     short loc_4A34E2
    ; ---------------------------------------------------------------------------

    loc_4A34DE:                             ; CODE XREF: sub_4A32A0+22Fj
    mov     ebp, eax
    jmp     short loc_4A34E4
    ; ---------------------------------------------------------------------------

    loc_4A34E2:                             ; CODE XREF: sub_4A32A0+21Fj
                                            ; sub_4A32A0+23Cj
    xor     ebp, ebp

    loc_4A34E4:                             ; CODE XREF: sub_4A32A0+240j
    cmp     ebp, 0FFFFFFFFh
    jz      loc_4A358E
    mov     eax, ebp
    add     esi, ebp
    shl     eax, 3
    sub     eax, ebp
    lea     ecx, [eax+eax*2]
    lea     edx, [ebp+ecx*2+0]
    lea     eax, [ebp+edx*4+0]
    lea     ecx, [esi+eax*2+2]
    mov     eax, dword_51FBA4
    mov     [esp+14h+arg_C], eax
    mov     [esp+14h+arg_4], ecx
    mov     eax, [eax+18h]
    test    eax, eax
    jz      short loc_4A3579
    mov     ebx, [eax+4]
    mov     esi, 1
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edx, esi
    jle     short loc_4A355A
    lea     edi, [ebx+15Dh]

    loc_4A3533:                             ; CODE XREF: sub_4A32A0+2B8j
    mov     eax, [esp+14h+arg_4]
    push    10h                             ; size_t
    push    eax                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A355D
    movsx   ecx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_4A3533

    loc_4A355A:                             ; CODE XREF: sub_4A32A0+28Bj
    or      esi, 0FFFFFFFFh

    loc_4A355D:                             ; CODE XREF: sub_4A32A0+2A5j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A3579
    mov     ebx, [esp+14h+arg_0]
    mov     eax, [esp+14h+arg_C]
    xor     edx, edx
    test    ebx, ebx
    setl    dl
    push    edx
    push    esi
    push    eax
    call    sub_4A03F0

    loc_4A3579:                             ; CODE XREF: sub_4A32A0+277j
                                            ; sub_4A32A0+2C0j
    mov     eax, [esp+14h+arg_0]
    test    eax, eax
    jge     short loc_4A358E
    mov     ecx, dword_51FBA4
    push    ebp
    push    ecx
    call    sub_4A3EF0

    loc_4A358E:                             ; CODE XREF: sub_4A32A0+1A3j
                                            ; sub_4A32A0+247j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4A3596:                             ; CODE XREF: sub_4A32A0+1D5j
    mov     ecx, esi
    jmp     loc_4A3491
    sub_4A32A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A35A0(int,char *,int,int)
    sub_4A35A0 proc near                    ; CODE XREF: sub_44C7E0+4F9p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ebx, [eax+4]
    mov     esi, 1
    push    edi
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4A35E9
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A35C6:                             ; CODE XREF: sub_4A35A0+47j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A35EC
    movsx   edx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_4A35C6

    loc_4A35E9:                             ; CODE XREF: sub_4A35A0+1Aj
    or      esi, 0FFFFFFFFh

    loc_4A35EC:                             ; CODE XREF: sub_4A35A0+34j
    xor     ebp, ebp
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A360A
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    lea     edx, [esi+ecx*4]
    lea     eax, [ebx+edx*2]
    jmp     short loc_4A3616
    ; ---------------------------------------------------------------------------

    loc_4A360A:                             ; CODE XREF: sub_4A35A0+51j
    push    offset aErrorInGuiLayo          ; lpText
    call    sub_4B6290
    xor     eax, eax

    loc_4A3616:                             ; CODE XREF: sub_4A35A0+68j
    mov     ecx, [esp+10h+arg_C]
    mov     edx, [esp+10h+arg_8]
    mov     edi, [eax+1Bh]
    mov     [eax+0C6h], edx
    lea     esi, [ecx+ecx*2]
    mov     [eax+0C0h], cx
    or      edi, 80h
    mov     [eax+0BCh], bp
    lea     edx, [edx+esi*8-18h]
    lea     esi, [ecx-1]
    dec     ecx
    mov     [eax+1Bh], edi
    movsx   edi, word ptr [eax+19h]
    cmp     ecx, 0FFFFFFFFh
    mov     [eax+0BAh], bp
    mov     [eax+0BEh], si
    jle     short loc_4A368F
    lea     esi, [edx+2]

    loc_4A3663:                             ; CODE XREF: sub_4A35A0+EDj
    mov     dx, [eax+0DAh]
    cmp     dx, bp
    jz      short loc_4A3674
    movsx   edx, dx
    jmp     short loc_4A3679
    ; ---------------------------------------------------------------------------

    loc_4A3674:                             ; CODE XREF: sub_4A35A0+CDj
    xor     edx, edx
    mov     dx, [esi]

    loc_4A3679:                             ; CODE XREF: sub_4A35A0+D2j
    sub     edi, edx
    cmp     edi, ebp
    jl      short loc_4A368F
    mov     [eax+0BEh], cx
    dec     ecx
    sub     esi, 18h
    cmp     ecx, 0FFFFFFFFh
    jg      short loc_4A3663

    loc_4A368F:                             ; CODE XREF: sub_4A35A0+BEj
                                            ; sub_4A35A0+DDj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_4A35A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4A36A0(int,char *,int,int)
    sub_4A36A0 proc near                    ; CODE XREF: .text:004452CCp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ebx, [eax+4]
    mov     esi, 1
    push    edi
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4A36E9
    mov     ebp, [esp+10h+arg_4]
    lea     edi, [ebx+15Dh]

    loc_4A36C6:                             ; CODE XREF: sub_4A36A0+47j
    push    10h                             ; size_t
    push    ebp                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A36EC
    movsx   edx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_4A36C6

    loc_4A36E9:                             ; CODE XREF: sub_4A36A0+1Aj
    or      esi, 0FFFFFFFFh

    loc_4A36EC:                             ; CODE XREF: sub_4A36A0+34j
    xor     edi, edi
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4A370A
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    add     ebx, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    lea     edx, [esi+ecx*4]
    lea     eax, [ebx+edx*2]
    jmp     short loc_4A3716
    ; ---------------------------------------------------------------------------

    loc_4A370A:                             ; CODE XREF: sub_4A36A0+51j
    push    offset aErrorInGuiLayo          ; lpText
    call    sub_4B6290
    xor     eax, eax

    loc_4A3716:                             ; CODE XREF: sub_4A36A0+68j
    mov     ecx, [esp+10h+arg_C]
    mov     edx, [esp+10h+arg_8]
    mov     ebx, [eax+1Bh]
    mov     [eax+0C6h], edx
    movsx   esi, word ptr [eax+19h]
    mov     [eax+0BCh], di
    mov     [eax+0BAh], di
    mov     [eax+0C0h], cx
    or      ebx, 20h
    lea     edx, [edx+ecx*4-4]
    lea     edi, [ecx-1]
    dec     ecx
    mov     [eax+1Bh], ebx
    cmp     ecx, 0FFFFFFFFh
    mov     [eax+0BEh], di
    jle     short loc_4A3779

    loc_4A375A:                             ; CODE XREF: sub_4A36A0+D7j
    mov     edi, [edx]
    xor     ebx, ebx
    mov     edi, [edi+28h]
    mov     bx, [edi+2]
    sub     esi, ebx
    js      short loc_4A3779
    mov     [eax+0BEh], cx
    dec     ecx
    sub     edx, 4
    cmp     ecx, 0FFFFFFFFh
    jg      short loc_4A375A

    loc_4A3779:                             ; CODE XREF: sub_4A36A0+B8j
                                            ; sub_4A36A0+C7j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_4A36A0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A3780 proc near                    ; CODE XREF: sub_4A9FD0+2BCp

    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 3Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+48h+arg_0]
    push    edi
    cmp     dword ptr [esi+60h], 0FFFFFFFFh
    jz      short loc_4A379D
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A379D:                             ; CODE XREF: sub_4A3780+Fj
    mov     eax, [esi+18h]
    mov     ecx, [esp+4Ch+arg_4]
    mov     edx, [eax+4]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     edi, edx
    add     edi, ecx
    mov     [esp+4Ch+var_38], edx
    lea     eax, [eax+eax*2]
    lea     eax, [ecx+eax*2]
    lea     eax, [ecx+eax*4]
    movsx   ecx, word ptr [edi+eax*2+0BAh]
    cmp     word ptr [edi+eax*2+0C0h], 0
    lea     ebp, [edi+eax*2]
    mov     [esp+4Ch+var_3C], ecx
    jnz     short loc_4A37E5
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A37E5:                             ; CODE XREF: sub_4A3780+57j
    cmp     byte ptr [ebp+0], 0
    jnz     short loc_4A37F5
    xor     eax, eax
    xor     ebx, ebx
    mov     [esp+4Ch+var_28], eax
    jmp     short loc_4A3801
    ; ---------------------------------------------------------------------------

    loc_4A37F5:                             ; CODE XREF: sub_4A3780+69j
    movsx   eax, word ptr [ebp+13h]
    movsx   ebx, word ptr [ebp+15h]
    mov     [esp+4Ch+var_28], eax

    loc_4A3801:                             ; CODE XREF: sub_4A3780+73j
    movsx   ecx, word ptr [ebp+17h]
    add     esi, 3Ch
    lea     edi, [esp+4Ch+var_18]
    lea     eax, [ecx+eax-1]
    mov     [esp+4Ch+var_34], 0
    movsx   ecx, word ptr [ebp+19h]
    mov     [esp+4Ch+var_20], eax
    lea     eax, [ecx+ebx-1]
    mov     ecx, 6
    sub     eax, 3
    add     ebx, 2
    mov     [esp+4Ch+var_1C], eax
    movsx   eax, word ptr [edx+13h]
    rep movsd
    mov     edi, [esp+4Ch+var_18]
    mov     esi, 1
    movsx   ecx, word ptr [edx+15h]
    sub     edi, eax
    movsx   eax, word ptr [edx+0B6h]
    mov     [esp+4Ch+var_18], edi
    mov     edi, [esp+4Ch+var_14]
    sub     edi, ecx
    inc     eax
    cmp     eax, esi
    jle     short loc_4A38B4
    lea     ecx, [edx+15Bh]

    loc_4A3864:                             ; CODE XREF: sub_4A3780+109j
    cmp     byte ptr [ecx], 7
    jnz     short loc_4A3880
    movsx   edx, byte ptr [ebp+28h]
    cmp     [esp+4Ch+var_34], edx
    jz      short loc_4A388D
    mov     edx, [esp+4Ch+var_34]
    inc     edx
    mov     [esp+4Ch+var_34], edx
    mov     edx, [esp+4Ch+var_38]

    loc_4A3880:                             ; CODE XREF: sub_4A3780+E7j
    inc     esi
    add     ecx, 15Bh
    cmp     esi, eax
    jl      short loc_4A3864
    jmp     short loc_4A38B4
    ; ---------------------------------------------------------------------------

    loc_4A388D:                             ; CODE XREF: sub_4A3780+F1j
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, [esp+4Ch+var_38]
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420
    mov     edx, [esp+4Ch+var_38]

    loc_4A38B4:                             ; CODE XREF: sub_4A3780+DCj
                                            ; sub_4A3780+10Bj
    movsx   edx, word ptr [edx+0B6h]
    inc     edx
    cmp     esi, edx
    jnz     short loc_4A38CD
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A38CD:                             ; CODE XREF: sub_4A3780+13Ej
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A38E1
    call    sub_4C1450
    jmp     short loc_4A38F7
    ; ---------------------------------------------------------------------------

    loc_4A38E1:                             ; CODE XREF: sub_4A3780+158j
    mov     eax, [eax+0Ch]
    push    49h
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A38F7:                             ; CODE XREF: sub_4A3780+15Fj
    mov     cx, [ebp+0DAh]
    test    cx, cx
    movsx   ecx, cx
    jnz     short loc_4A3909
    lea     ecx, [eax+1]

    loc_4A3909:                             ; CODE XREF: sub_4A3780+184j
    movsx   eax, word ptr [ebp+19h]
    sub     eax, 2
    mov     esi, [esp+4Ch+arg_0]
    cdq
    idiv    ecx
    push    1
    push    esi
    mov     [esp+54h+var_34], ecx
    mov     [esp+54h+var_30], eax
    call    sub_4AB570
    test    eax, eax
    jz      loc_4A3A10
    mov     esi, [esp+4Ch+var_18]
    mov     eax, [esp+4Ch+var_28]
    cmp     esi, eax
    jl      loc_4A3A9C
    cmp     esi, [esp+4Ch+var_20]
    jg      loc_4A3A9C
    cmp     edi, ebx
    jl      loc_4A3A9C
    cmp     edi, [esp+4Ch+var_1C]
    jg      loc_4A3A9C
    mov     si, [ebp+0C0h]
    test    si, si
    jz      loc_4A3A98
    mov     eax, [ebp+1Bh]
    test    ah, 2
    jz      loc_4A3D09
    mov     eax, edi
    mov     cx, [ebp+0BCh]
    sub     eax, ebx
    cdq
    idiv    [esp+4Ch+var_34]
    add     eax, ecx
    test    ax, ax
    mov     [ebp+0BAh], ax
    jl      loc_4A3D09
    movsx   edx, cx
    movsx   edi, ax
    mov     eax, [esp+4Ch+var_30]
    sub     edi, edx
    lea     edx, [eax-1]
    cmp     edi, edx
    jle     short loc_4A39B7
    lea     eax, [eax+ecx-1]
    mov     [ebp+0BAh], ax

    loc_4A39B7:                             ; CODE XREF: sub_4A3780+22Aj
    movsx   edx, word ptr [ebp+0BAh]
    movsx   ecx, si
    dec     ecx
    cmp     edx, ecx
    jl      short loc_4A39CE
    dec     esi
    mov     [ebp+0BAh], si

    loc_4A39CE:                             ; CODE XREF: sub_4A3780+244j
    movsx   eax, word ptr [ebp+0BAh]
    mov     ecx, [ebp+0C2h]
    push    eax
    push    ecx
    call    sub_4B6AF0
    push    2                               ; size_t
    push    eax                             ; char *
    push    offset byte_502A20              ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     loc_4A3D09
    mov     dx, word ptr [esp+4Ch+var_3C]
    mov     [ebp+0BAh], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A3A10:                             ; CODE XREF: sub_4A3780+1A9j
    push    1
    push    esi
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A3A55
    mov     esi, [esp+4Ch+var_18]
    mov     eax, [esp+4Ch+var_28]
    cmp     esi, eax
    jl      short loc_4A3A9C
    cmp     esi, [esp+4Ch+var_20]
    jg      short loc_4A3A9C
    cmp     edi, ebx
    jl      short loc_4A3A9C
    cmp     edi, [esp+4Ch+var_1C]
    jg      short loc_4A3A9C
    mov     eax, [esp+4Ch+arg_4]
    mov     ecx, [esp+4Ch+arg_0]
    push    eax
    push    ecx
    call    sub_49FC50
    push    1
    mov     edx, [esp+50h+arg_0]
    push    edx
    call    sub_4AB690
    jmp     short loc_4A3A9C
    ; ---------------------------------------------------------------------------

    loc_4A3A55:                             ; CODE XREF: sub_4A3780+29Aj
    push    2
    push    esi
    call    sub_4AB510
    test    eax, eax
    mov     esi, [esp+4Ch+var_18]
    jz      short loc_4A3A9C
    cmp     esi, [esp+4Ch+var_28]
    jl      short loc_4A3A9C
    cmp     esi, [esp+4Ch+var_20]
    jg      short loc_4A3A9C
    cmp     edi, ebx
    jl      short loc_4A3A9C
    cmp     edi, [esp+4Ch+var_1C]
    jg      short loc_4A3A9C
    mov     eax, [esp+4Ch+arg_4]
    mov     ecx, [esp+4Ch+arg_0]
    push    eax
    push    ecx
    call    sub_49FC50
    push    2
    mov     edx, [esp+50h+arg_0]
    push    edx
    call    sub_4AB690
    jmp     short loc_4A3A9C
    ; ---------------------------------------------------------------------------

    loc_4A3A98:                             ; CODE XREF: sub_4A3780+1E5j
    mov     esi, [esp+4Ch+var_18]

    loc_4A3A9C:                             ; CODE XREF: sub_4A3780+1B9j
                                            ; sub_4A3780+1C3j ...
    mov     eax, [esp+4Ch+arg_0]
    mov     ecx, [eax+64h]
    mov     eax, [esp+4Ch+arg_4]
    cmp     ecx, eax
    jnz     loc_4A3E8F
    mov     edx, [esp+4Ch+arg_0]
    push    3
    push    edx
    call    sub_4AB5B0
    test    eax, eax
    jnz     short loc_4A3ACA
    mov     eax, [esp+4Ch+arg_0]
    mov     dword ptr [eax+64h], 0FFFFFFFFh

    loc_4A3ACA:                             ; CODE XREF: sub_4A3780+33Dj
    cmp     esi, [esp+4Ch+var_28]
    jl      loc_4A3D27
    cmp     esi, [esp+4Ch+var_20]
    jg      loc_4A3D27
    cmp     edi, ebx
    jl      loc_4A3D2F
    cmp     edi, [esp+4Ch+var_1C]
    jg      loc_4A3D27
    mov     ecx, [esp+4Ch+arg_0]
    mov     eax, [esp+4Ch+arg_4]
    mov     edx, [ecx+18h]
    mov     [edx+20h], eax
    mov     eax, [ebp+1Bh]
    test    al, 10h
    mov     [esp+4Ch+var_2C], eax
    jz      loc_4A3C29
    mov     eax, edi
    mov     cx, [ebp+0BCh]
    sub     eax, ebx
    cdq
    idiv    [esp+4Ch+var_34]
    add     eax, ecx
    test    ax, ax
    mov     [ebp+0BAh], ax
    jl      loc_4A3C18
    movsx   edx, cx
    movsx   esi, ax
    mov     eax, [esp+4Ch+var_30]
    sub     esi, edx
    lea     edx, [eax-1]
    cmp     esi, edx
    jle     short loc_4A3B4D
    lea     eax, [eax+ecx-1]
    mov     [ebp+0BAh], ax

    loc_4A3B4D:                             ; CODE XREF: sub_4A3780+3C0j
    mov     ax, [ebp+0C0h]
    movsx   edx, word ptr [ebp+0BAh]
    movsx   ecx, ax
    dec     ecx
    cmp     edx, ecx
    jl      short loc_4A3B6B
    dec     eax
    mov     [ebp+0BAh], ax

    loc_4A3B6B:                             ; CODE XREF: sub_4A3780+3E1j
    cmp     word ptr [ebp+0BAh], 0
    jge     short loc_4A3B7E
    mov     word ptr [ebp+0BAh], 0

    loc_4A3B7E:                             ; CODE XREF: sub_4A3780+3F3j
    mov     eax, [esp+4Ch+var_2C]
    test    ah, 2
    jz      short loc_4A3BBB
    movsx   eax, word ptr [ebp+0BAh]
    mov     ecx, [ebp+0C2h]
    push    eax
    push    ecx
    call    sub_4B6AF0
    push    2                               ; size_t
    push    eax                             ; char *
    push    offset byte_502A20              ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4A3BBB
    mov     dx, word ptr [esp+4Ch+var_3C]
    mov     [ebp+0BAh], dx

    loc_4A3BBB:                             ; CODE XREF: sub_4A3780+405j
                                            ; sub_4A3780+42Dj
    mov     esi, [esp+4Ch+var_38]
    mov     edi, 1
    cmp     [esi+0B6h], di
    jl      loc_4A3CD3
    lea     eax, [esi+21Bh]

    loc_4A3BD7:                             ; CODE XREF: sub_4A3780+491j
    cmp     byte ptr [eax-0C0h], 2
    jnz     short loc_4A3C02
    mov     cl, [eax-0BFh]
    mov     dl, [ebp+1]
    cmp     cl, dl
    jnz     short loc_4A3C02
    movsx   ecx, word ptr [eax]
    movsx   edx, word ptr [ebp+0BAh]
    dec     ecx
    cmp     ecx, edx
    jl      short loc_4A3BFE
    mov     ecx, edx

    loc_4A3BFE:                             ; CODE XREF: sub_4A3780+47Aj
    mov     [eax-6], cx

    loc_4A3C02:                             ; CODE XREF: sub_4A3780+45Ej
                                            ; sub_4A3780+46Bj
    movsx   edx, word ptr [esi+0B6h]
    inc     edi
    add     eax, 15Bh
    cmp     edi, edx
    jle     short loc_4A3BD7
    jmp     loc_4A3CD3
    ; ---------------------------------------------------------------------------

    loc_4A3C18:                             ; CODE XREF: sub_4A3780+3A9j
    mov     ax, word ptr [esp+4Ch+var_3C]
    mov     [ebp+0BAh], ax
    jmp     loc_4A3CD3
    ; ---------------------------------------------------------------------------

    loc_4A3C29:                             ; CODE XREF: sub_4A3780+387j
    mov     ecx, eax
    and     ecx, 20h
    or      cl, 80h
    test    cl, cl
    jz      loc_4A3CD3
    shr     eax, 7
    and     eax, 1
    mov     [esp+4Ch+var_30], eax
    movsx   eax, word ptr [ebp+0BCh]
    jz      short loc_4A3C62
    mov     ecx, [ebp+0C6h]
    mov     esi, [esp+4Ch+arg_0]
    lea     edx, [eax+eax*2]
    lea     edx, [ecx+edx*8]
    mov     [esp+4Ch+var_38], edx
    jmp     short loc_4A3C6B
    ; ---------------------------------------------------------------------------

    loc_4A3C62:                             ; CODE XREF: sub_4A3780+4CAj
    mov     ecx, [ebp+0C6h]
    lea     esi, [ecx+eax*4]

    loc_4A3C6B:                             ; CODE XREF: sub_4A3780+4E0j
    sub     edi, ebx
    sub     edi, 2
    xor     edx, edx

    loc_4A3C72:                             ; CODE XREF: sub_4A3780+541j
    mov     ecx, [esp+4Ch+var_30]
    test    ecx, ecx
    jz      short loc_4A3C80
    mov     ecx, [esp+4Ch+var_38]
    jmp     short loc_4A3C85
    ; ---------------------------------------------------------------------------

    loc_4A3C80:                             ; CODE XREF: sub_4A3780+4F8j
    mov     ecx, [esi]
    mov     ecx, [ecx+28h]

    loc_4A3C85:                             ; CODE XREF: sub_4A3780+4FEj
    cmp     word ptr [ebp+0DAh], 0
    jz      short loc_4A3C95
    sub     edi, [esp+4Ch+var_34]
    jmp     short loc_4A3C9D
    ; ---------------------------------------------------------------------------

    loc_4A3C95:                             ; CODE XREF: sub_4A3780+50Dj
    xor     ebx, ebx
    mov     bx, [ecx+2]
    sub     edi, ebx

    loc_4A3C9D:                             ; CODE XREF: sub_4A3780+513j
    test    edi, edi
    jle     short loc_4A3CC3
    mov     ecx, [esp+4Ch+var_30]
    test    ecx, ecx
    jz      short loc_4A3CB0
    add     [esp+4Ch+var_38], 18h
    jmp     short loc_4A3CB3
    ; ---------------------------------------------------------------------------

    loc_4A3CB0:                             ; CODE XREF: sub_4A3780+527j
    add     esi, 4

    loc_4A3CB3:                             ; CODE XREF: sub_4A3780+52Ej
    movsx   ecx, word ptr [ebp+0C0h]
    inc     edx
    inc     eax
    dec     ecx
    cmp     eax, ecx
    jg      short loc_4A3CD3
    jmp     short loc_4A3C72
    ; ---------------------------------------------------------------------------

    loc_4A3CC3:                             ; CODE XREF: sub_4A3780+51Fj
    mov     ax, [ebp+0BCh]
    add     edx, eax
    mov     [ebp+0BAh], dx

    loc_4A3CD3:                             ; CODE XREF: sub_4A3780+44Bj
                                            ; sub_4A3780+493j ...
    movsx   edx, word ptr [ebp+0BAh]
    cmp     [esp+4Ch+var_3C], edx
    jz      short loc_4A3CFF
    mov     eax, [esp+4Ch+arg_4]
    mov     esi, [esp+4Ch+arg_0]
    push    eax
    push    esi
    call    sub_4A1B40
    mov     eax, [ebp+0CEh]
    test    eax, eax
    jz      short loc_4A3D03
    push    ebp
    push    esi
    call    eax
    jmp     short loc_4A3D03
    ; ---------------------------------------------------------------------------

    loc_4A3CFF:                             ; CODE XREF: sub_4A3780+55Ej
    mov     esi, [esp+4Ch+arg_0]

    loc_4A3D03:                             ; CODE XREF: sub_4A3780+577j
                                            ; sub_4A3780+57Dj
    test    byte ptr [ebp+1Bh], 40h
    jz      short loc_4A3D18

    loc_4A3D09:                             ; CODE XREF: sub_4A3780+1F1j
                                            ; sub_4A3780+213j ...
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A3D18:                             ; CODE XREF: sub_4A3780+587j
    mov     dword ptr [esi+0CCAh], 1
    jmp     loc_4A3E8F
    ; ---------------------------------------------------------------------------

    loc_4A3D27:                             ; CODE XREF: sub_4A3780+34Ej
                                            ; sub_4A3780+358j ...
    cmp     edi, ebx
    jge     loc_4A3DEF

    loc_4A3D2F:                             ; CODE XREF: sub_4A3780+360j
    cmp     word ptr [ebp+0BCh], 0
    jle     loc_4A3DD3
    call    sub_4B6340
    cmp     [ebp+0B6h], eax
    jge     loc_4A3DD3
    call    sub_4B6340
    add     eax, 2
    mov     [ebp+0B6h], eax
    mov     ax, [ebp+0BCh]
    cmp     [ebp+0BAh], ax
    jle     short loc_4A3D73
    mov     [ebp+0BAh], ax

    loc_4A3D73:                             ; CODE XREF: sub_4A3780+5EAj
    dec     eax
    dec     word ptr [ebp+0BAh]
    mov     cx, [ebp+0BAh]
    mov     [ebp+0BCh], ax
    mov     eax, [ebp+0C2h]
    test    eax, eax
    jz      loc_4A3E79
    test    cx, cx
    jge     short loc_4A3DA0
    xor     ecx, ecx
    jmp     short loc_4A3DA3
    ; ---------------------------------------------------------------------------

    loc_4A3DA0:                             ; CODE XREF: sub_4A3780+61Aj
    movsx   ecx, cx

    loc_4A3DA3:                             ; CODE XREF: sub_4A3780+61Ej
    push    ecx
    push    eax
    call    sub_4B6AF0
    push    2                               ; size_t
    push    eax                             ; char *
    push    offset byte_502A20              ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     loc_4A3E79
    mov     cx, word ptr [esp+4Ch+var_3C]
    mov     [ebp+0BAh], cx
    jmp     loc_4A3E79
    ; ---------------------------------------------------------------------------

    loc_4A3DD3:                             ; CODE XREF: sub_4A3780+5B7j
                                            ; sub_4A3780+5C8j
    cmp     word ptr [ebp+0BAh], 0
    jle     loc_4A3E8F
    mov     word ptr [ebp+0BAh], 0
    jmp     loc_4A3E79
    ; ---------------------------------------------------------------------------

    loc_4A3DEF:                             ; CODE XREF: sub_4A3780+5A9j
    cmp     edi, [esp+4Ch+var_1C]
    jle     loc_4A3E8F
    mov     dx, [ebp+0BCh]
    cmp     dx, [ebp+0BEh]
    jge     loc_4A3E8F
    call    sub_4B6340
    cmp     [ebp+0B6h], eax
    jge     short loc_4A3E8F
    call    sub_4B6340
    mov     ecx, [esp+4Ch+var_30]
    add     eax, 2
    inc     word ptr [ebp+0BCh]
    mov     [ebp+0B6h], eax
    mov     ax, [ebp+0BCh]
    lea     eax, [ecx+eax-1]
    mov     ecx, [ebp+0C2h]
    test    ecx, ecx
    mov     [ebp+0BAh], ax
    jz      short loc_4A3E79
    movsx   edx, ax
    push    edx
    push    ecx
    call    sub_4B6AF0
    push    2                               ; size_t
    push    eax                             ; char *
    push    offset byte_502A20              ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4A3E79
    mov     ax, word ptr [esp+4Ch+var_3C]
    mov     [ebp+0BAh], ax

    loc_4A3E79:                             ; CODE XREF: sub_4A3780+611j
                                            ; sub_4A3780+63Cj ...
    mov     esi, [esp+4Ch+arg_4]
    mov     edi, [esp+4Ch+arg_0]
    push    esi
    push    edi
    call    sub_4A1B40
    push    esi
    push    edi
    call    sub_4A2BE0

    loc_4A3E8F:                             ; CODE XREF: sub_4A3780+329j
                                            ; sub_4A3780+5A2j ...
    mov     ecx, [esp+4Ch+arg_0]
    xor     eax, eax
    pop     edi
    pop     esi
    mov     edx, [ecx+60h]
    pop     ebp
    cmp     edx, 0FFFFFFFFh
    pop     ebx
    setnz   al
    add     esp, 3Ch
    retn    0Ch
    sub_4A3780 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esp+4]
    lea     eax, [eax+ecx*2]
    mov     ecx, [edx+18h]
    mov     edx, [ecx+4]
    xor     ecx, ecx
    add     eax, edx
    mov     [eax+140h], cx
    mov     [eax+144h], ecx
    mov     [eax+14Ah], ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A3EF0 proc near                    ; CODE XREF: sub_4A32A0+2E9p
                                            ; sub_4A81E0+115Bp

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    sub     esp, 8
    mov     ecx, [eax+18h]
    push    ebx
    push    ebp
    push    esi
    mov     ebp, [ecx+4]
    mov     ecx, [esp+14h+arg_4]
    mov     eax, ecx
    push    edi
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     eax, ebp
    add     eax, ecx
    mov     cl, [eax+edx*2+1]
    lea     esi, [eax+edx*2]
    mov     eax, 1
    movsx   edx, word ptr [ebp+0B6h]
    inc     edx
    cmp     edx, eax
    jle     short loc_4A3F4C
    lea     edi, [ebp+15Bh]

    loc_4A3F37:                             ; CODE XREF: sub_4A3EF0+5Aj
    cmp     byte ptr [edi], 2
    jnz     short loc_4A3F41
    cmp     [edi+1], cl
    jz      short loc_4A3F4E

    loc_4A3F41:                             ; CODE XREF: sub_4A3EF0+4Aj
    inc     eax
    add     edi, 15Bh
    cmp     eax, edx
    jl      short loc_4A3F37

    loc_4A3F4C:                             ; CODE XREF: sub_4A3EF0+3Fj
    xor     eax, eax

    loc_4A3F4E:                             ; CODE XREF: sub_4A3EF0+4Fj
    xor     ecx, ecx
    cmp     eax, ecx
    jz      loc_4A414C
    mov     edi, eax
    mov     ebx, ebp
    shl     edi, 3
    sub     edi, eax
    add     ebx, eax
    lea     edi, [edi+edi*2]
    lea     edi, [eax+edi*2]
    lea     edi, [eax+edi*4]
    mov     al, [ebx+edi*2]
    cmp     al, 2
    lea     ebx, [ebx+edi*2]
    jnz     loc_4A414C
    mov     eax, [ebx+1Bh]
    test    al, 10h
    jz      loc_4A409F
    mov     edi, 1
    mov     [esp+18h+var_8], ecx
    cmp     edx, edi
    jle     short loc_4A3FD8
    lea     eax, [ebp+15Bh]

    loc_4A3F98:                             ; CODE XREF: sub_4A3EF0+C3j
    cmp     byte ptr [eax], 7
    jnz     short loc_4A3FAB
    movsx   ecx, byte ptr [ebx+28h]
    cmp     [esp+18h+var_8], ecx
    jz      short loc_4A3FB7
    inc     [esp+18h+var_8]

    loc_4A3FAB:                             ; CODE XREF: sub_4A3EF0+ABj
    inc     edi
    add     eax, 15Bh
    cmp     edi, edx
    jl      short loc_4A3F98
    jmp     short loc_4A3FD8
    ; ---------------------------------------------------------------------------

    loc_4A3FB7:                             ; CODE XREF: sub_4A3EF0+B5j
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     edx, [eax+eax*2]
    lea     eax, [edi+edx*2]
    mov     edx, ebp
    add     edx, edi
    lea     ecx, [edi+eax*4]
    mov     eax, [edx+ecx*2+0D6h]
    push    eax
    call    sub_4C1420

    loc_4A3FD8:                             ; CODE XREF: sub_4A3EF0+A0j
                                            ; sub_4A3EF0+C5j
    movsx   ecx, word ptr [ebp+0B6h]
    inc     ecx
    cmp     edi, ecx
    jnz     short loc_4A3FF2
    mov     edx, dword_51FBA4
    mov     eax, [edx]
    push    eax
    call    sub_4C1420

    loc_4A3FF2:                             ; CODE XREF: sub_4A3EF0+F2j
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A4006
    call    sub_4C1450
    jmp     short loc_4A401C
    ; ---------------------------------------------------------------------------

    loc_4A4006:                             ; CODE XREF: sub_4A3EF0+10Dj
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A401C:                             ; CODE XREF: sub_4A3EF0+114j
    movsx   ecx, word ptr [ebx+19h]
    movsx   edx, word ptr [ebx+0DAh]
    lea     edi, [eax+1]
    sub     ecx, 2
    cmp     edx, edi
    jle     short loc_4A4033
    mov     edi, edx

    loc_4A4033:                             ; CODE XREF: sub_4A3EF0+13Fj
    mov     eax, ecx
    cdq
    idiv    edi
    movsx   ebx, word ptr [ebx+0C0h]
    mov     [esp+18h+var_4], ebx
    mov     di, [esi+19h]
    movsx   edx, di
    sub     edx, 3
    mov     ebp, eax
    mov     [esp+18h+var_8], ebp
    fild    [esp+18h+var_8]
    fidiv   [esp+18h+var_4]
    mov     [esp+18h+var_4], edx
    fimul   [esp+18h+var_4]
    call    __ftol
    cmp     ax, 0Ah
    mov     [esi+142h], ax
    jge     short loc_4A407E
    mov     word ptr [esi+142h], 0Ah

    loc_4A407E:                             ; CODE XREF: sub_4A3EF0+183j
    cmp     ebx, ebp
    jg      short loc_4A4090
    mov     word ptr [esi+136h], 0
    jmp     loc_4A414C
    ; ---------------------------------------------------------------------------

    loc_4A4090:                             ; CODE XREF: sub_4A3EF0+190j
    sub     di, [esi+142h]
    sub     edi, 3
    jmp     loc_4A4145
    ; ---------------------------------------------------------------------------

    loc_4A409F:                             ; CODE XREF: sub_4A3EF0+8Fj
    test    al, 20h
    jz      short loc_4A40F0
    movsx   eax, word ptr [ebx+0C0h]
    mov     edx, [ebx+0C6h]
    test    eax, eax
    jle     short loc_4A40C2
    mov     ecx, [edx]
    mov     edx, [ecx+28h]
    xor     ecx, ecx
    mov     cx, [edx+2]
    imul    ecx, eax

    loc_4A40C2:                             ; CODE XREF: sub_4A3EF0+1C2j
    mov     di, [esi+19h]
    movsx   eax, word ptr [ebx+19h]
    movsx   edx, di
    imul    eax, edx
    cdq
    idiv    ecx
    test    byte ptr [esi+1Bh], 1
    mov     [esi+142h], ax
    jz      short loc_4A4143
    mov     cx, [esi+17h]
    sub     cx, ax
    mov     [esi+136h], cx
    jmp     short loc_4A414C
    ; ---------------------------------------------------------------------------

    loc_4A40F0:                             ; CODE XREF: sub_4A3EF0+1B1j
    test    al, 80h
    jz      short loc_4A414C
    mov     dx, [ebx+0DAh]
    cmp     dx, cx
    jz      short loc_4A414C
    mov     cx, [ebx+0C0h]
    test    cx, cx
    jz      short loc_4A414C
    movsx   eax, word ptr [ebx+19h]
    movsx   ebx, dx
    cdq
    idiv    ebx
    mov     di, [esi+19h]
    movsx   edx, di
    movsx   ecx, cx
    imul    eax, edx
    cdq
    idiv    ecx
    test    byte ptr [esi+1Bh], 1
    mov     [esi+142h], ax
    jz      short loc_4A4143
    mov     dx, [esi+17h]
    sub     dx, ax
    mov     [esi+136h], dx
    jmp     short loc_4A414C
    ; ---------------------------------------------------------------------------

    loc_4A4143:                             ; CODE XREF: sub_4A3EF0+1EEj
                                            ; sub_4A3EF0+241j
    sub     edi, eax

    loc_4A4145:                             ; CODE XREF: sub_4A3EF0+1AAj
    mov     [esi+136h], di

    loc_4A414C:                             ; CODE XREF: sub_4A3EF0+62j
                                            ; sub_4A3EF0+84j ...
    mov     eax, [esp+18h+arg_4]
    mov     ecx, [esp+18h+arg_0]
    push    eax
    push    ecx
    call    sub_4A2580
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    sub_4A3EF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A4170 proc near                    ; CODE XREF: sub_4A9FD0+2EFp

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 38h
    push    ebx
    push    ebp
    mov     ebp, [esp+40h+arg_0]
    push    esi
    push    edi
    mov     eax, [ebp+18h]
    mov     edx, [eax+4]
    mov     eax, [esp+48h+arg_4]
    mov     ecx, eax
    mov     esi, edx
    shl     ecx, 3
    sub     ecx, eax
    add     esi, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     ebx, [esi+ecx*2]
    mov     cl, [esi+ecx*2+1Bh]
    test    cl, 10h
    jnz     loc_4A4430
    mov     ecx, [ebx+157h]
    test    ecx, ecx
    jnz     loc_4A4430
    lea     esi, [ebp+3Ch]
    mov     ecx, 6
    lea     edi, [esp+48h+var_18]
    rep movsd
    movsx   ecx, word ptr [edx+13h]
    mov     esi, [esp+48h+var_18]
    mov     edi, [esp+48h+var_14]
    sub     esi, ecx
    movsx   ecx, word ptr [edx+15h]
    sub     edi, ecx
    lea     ecx, [esp+48h+var_38]
    push    ecx
    lea     ecx, [esp+4Ch+var_28]
    push    ecx
    push    eax
    push    edx
    mov     [esp+58h+var_18], esi
    mov     [esp+58h+var_14], edi
    call    sub_4A23B0
    mov     eax, [ebp+64h]
    mov     edx, [esp+48h+arg_4]
    cmp     eax, edx
    jnz     loc_4A4301
    push    3
    push    ebp
    call    sub_4AB5B0
    test    eax, eax
    jnz     short loc_4A421B
    xor     edx, edx
    mov     dword ptr [ebp+64h], 0FFFFFFFFh
    mov     [ebp+78h], edx
    jmp     short loc_4A421D
    ; ---------------------------------------------------------------------------

    loc_4A421B:                             ; CODE XREF: sub_4A4170+9Bj
    xor     edx, edx

    loc_4A421D:                             ; CODE XREF: sub_4A4170+A9j
    cmp     [ebp+78h], edx
    jz      short loc_4A424A
    mov     al, [ebx+1Bh]
    movsx   ecx, word ptr [ebx+140h]
    test    al, 1
    mov     ax, [ebp+94h]
    jz      short loc_4A423F
    sub     ax, [ebp+7Ch]
    add     eax, esi
    jmp     short loc_4A427B
    ; ---------------------------------------------------------------------------

    loc_4A423F:                             ; CODE XREF: sub_4A4170+C5j
    sub     ax, [ebp+80h]
    add     eax, edi
    jmp     short loc_4A427B
    ; ---------------------------------------------------------------------------

    loc_4A424A:                             ; CODE XREF: sub_4A4170+B0j
    mov     ax, [ebx+140h]
    test    byte ptr [ebx+1Bh], 1
    movsx   ecx, ax
    jz      short loc_4A426B
    cmp     esi, [esp+48h+var_38]
    jge     short loc_4A4263
    dec     eax
    jmp     short loc_4A427B
    ; ---------------------------------------------------------------------------

    loc_4A4263:                             ; CODE XREF: sub_4A4170+EEj
    cmp     esi, [esp+48h+var_30]
    jle     short loc_4A4282
    jmp     short loc_4A427A
    ; ---------------------------------------------------------------------------

    loc_4A426B:                             ; CODE XREF: sub_4A4170+E8j
    cmp     edi, [esp+48h+var_34]
    jge     short loc_4A4274
    dec     eax
    jmp     short loc_4A427B
    ; ---------------------------------------------------------------------------

    loc_4A4274:                             ; CODE XREF: sub_4A4170+FFj
    cmp     edi, [esp+48h+var_2C]
    jle     short loc_4A4282

    loc_4A427A:                             ; CODE XREF: sub_4A4170+F9j
    inc     eax

    loc_4A427B:                             ; CODE XREF: sub_4A4170+CDj
                                            ; sub_4A4170+D8j ...
    mov     [ebx+140h], ax

    loc_4A4282:                             ; CODE XREF: sub_4A4170+F7j
                                            ; sub_4A4170+108j
    mov     ax, [ebx+136h]
    movsx   edi, word ptr [ebx+140h]
    movsx   esi, ax
    dec     esi
    cmp     edi, esi
    jle     short loc_4A42A0
    dec     eax
    mov     [ebx+140h], ax

    loc_4A42A0:                             ; CODE XREF: sub_4A4170+126j
    cmp     [ebx+140h], dx
    jge     short loc_4A42B0
    mov     [ebx+140h], dx

    loc_4A42B0:                             ; CODE XREF: sub_4A4170+137j
    movsx   eax, word ptr [ebx+140h]
    cmp     eax, ecx
    jz      loc_4A4430
    mov     eax, [ebp+18h]
    cmp     eax, edx
    jz      short loc_4A42CD
    mov     dword ptr [eax+14h], 1

    loc_4A42CD:                             ; CODE XREF: sub_4A4170+154j
    mov     esi, [esp+48h+arg_4]
    push    esi
    push    ebp
    call    sub_4A2580
    push    esi
    push    ebp
    call    sub_4A2BE0
    mov     eax, [ebx+144h]
    test    eax, eax
    jz      loc_4A4430
    mov     ecx, [ebx+14Ah]
    push    ecx
    push    ebp
    call    eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A4301:                             ; CODE XREF: sub_4A4170+8Bj
    mov     eax, [ebp+78h]
    test    eax, eax
    jnz     loc_4A4430
    push    1
    push    ebp
    call    sub_4AB510
    test    eax, eax
    jz      loc_4A43B5
    mov     eax, [esp+48h+var_28]
    mov     dword ptr [ebp+78h], 0
    cmp     esi, eax
    jl      loc_4A4430
    cmp     esi, [esp+48h+var_20]
    jg      loc_4A4430
    cmp     edi, [esp+48h+var_24]
    jl      loc_4A4430
    cmp     edi, [esp+48h+var_1C]
    jg      loc_4A4430
    mov     edx, [esp+48h+arg_4]
    push    edx
    push    ebp
    call    sub_49FC50
    push    1
    push    ebp
    call    sub_4AB690
    cmp     esi, [esp+48h+var_38]
    jl      loc_4A4430
    cmp     esi, [esp+48h+var_30]
    jg      loc_4A4430
    cmp     edi, [esp+48h+var_34]
    jl      loc_4A4430
    cmp     edi, [esp+48h+var_2C]
    jg      loc_4A4430
    lea     edi, [ebp+7Ch]
    mov     ecx, 6
    lea     esi, [esp+48h+var_18]
    mov     dword ptr [ebp+78h], 1
    rep movsd
    mov     ax, [ebx+140h]
    mov     [ebp+94h], ax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A43B5:                             ; CODE XREF: sub_4A4170+1A6j
    push    2
    push    ebp
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A4430
    mov     eax, [esp+48h+var_28]
    mov     dword ptr [ebp+78h], 0
    cmp     esi, eax
    jl      short loc_4A4430
    cmp     esi, [esp+48h+var_20]
    jg      short loc_4A4430
    cmp     edi, [esp+48h+var_24]
    jl      short loc_4A4430
    cmp     edi, [esp+48h+var_1C]
    jg      short loc_4A4430
    mov     ecx, [esp+48h+arg_4]
    push    ecx
    push    ebp
    call    sub_49FC50
    push    2
    push    ebp
    call    sub_4AB690
    cmp     esi, [esp+48h+var_38]
    jl      short loc_4A4430
    cmp     esi, [esp+48h+var_30]
    jg      short loc_4A4430
    cmp     edi, [esp+48h+var_34]
    jl      short loc_4A4430
    cmp     edi, [esp+48h+var_2C]
    jg      short loc_4A4430
    lea     edi, [ebp+7Ch]
    mov     ecx, 6
    lea     esi, [esp+48h+var_18]
    mov     dword ptr [ebp+78h], 1
    rep movsd
    mov     dx, [ebx+140h]
    mov     [ebp+94h], dx

    loc_4A4430:                             ; CODE XREF: sub_4A4170+33j
                                            ; sub_4A4170+41j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    8
    sub_4A4170 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A4440 proc near                    ; CODE XREF: sub_4A9FD0+300p

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 28h
    push    ebx
    mov     ebx, [esp+2Ch+arg_0]
    push    ebp
    mov     ebp, [esp+30h+arg_4]
    mov     eax, [ebx+18h]
    push    esi
    push    edi
    mov     edx, [eax+4]
    mov     eax, ebp
    shl     eax, 3
    sub     eax, ebp
    mov     [esp+38h+arg_0], edx
    lea     ecx, [eax+eax*2]
    lea     eax, [ebp+ecx*2+0]
    lea     ecx, [ebp+eax*4+0]
    mov     eax, edx
    add     eax, ebp
    lea     eax, [eax+ecx*2]
    mov     [esp+38h+arg_4], eax
    mov     cl, [eax+147h]
    test    cl, cl
    jnz     short loc_4A448A
    test    byte ptr [eax+1Bh], 10h
    jnz     loc_4A4611

    loc_4A448A:                             ; CODE XREF: sub_4A4440+3Ej
    cmp     byte ptr [eax], 0
    jnz     short loc_4A4497
    xor     ecx, ecx
    mov     [esp+38h+var_28], ecx
    jmp     short loc_4A44A3
    ; ---------------------------------------------------------------------------

    loc_4A4497:                             ; CODE XREF: sub_4A4440+4Dj
    movsx   ecx, word ptr [eax+13h]
    mov     [esp+38h+var_28], ecx
    movsx   ecx, word ptr [eax+15h]

    loc_4A44A3:                             ; CODE XREF: sub_4A4440+55j
    mov     esi, [esp+38h+var_28]
    mov     [esp+38h+var_24], ecx
    movsx   ecx, word ptr [eax+17h]
    movsx   eax, word ptr [eax+19h]
    lea     ecx, [ecx+esi-1]
    lea     esi, [ebx+3Ch]
    mov     [esp+38h+var_20], ecx
    mov     ecx, [esp+38h+var_24]
    lea     edi, [esp+38h+var_18]
    push    1
    lea     eax, [eax+ecx-1]
    mov     ecx, 6
    rep movsd
    movsx   ecx, word ptr [edx+13h]
    movsx   edx, word ptr [edx+15h]
    mov     esi, [esp+3Ch+var_18]
    mov     edi, [esp+3Ch+var_14]
    push    ebx
    mov     [esp+40h+var_1C], eax
    sub     esi, ecx
    sub     edi, edx
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A4518
    cmp     esi, [esp+38h+var_28]
    jl      short loc_4A454B
    cmp     esi, [esp+38h+var_20]
    jg      short loc_4A454B
    cmp     edi, [esp+38h+var_24]
    jl      short loc_4A454B
    cmp     edi, [esp+38h+var_1C]
    jg      short loc_4A454B
    push    ebp
    push    ebx
    call    sub_49FC50
    push    1
    jmp     short loc_4A4545
    ; ---------------------------------------------------------------------------

    loc_4A4518:                             ; CODE XREF: sub_4A4440+B3j
    push    2
    push    ebx
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A454B
    cmp     esi, [esp+38h+var_28]
    jl      short loc_4A454B
    cmp     esi, [esp+38h+var_20]
    jg      short loc_4A454B
    cmp     edi, [esp+38h+var_24]
    jl      short loc_4A454B
    cmp     edi, [esp+38h+var_1C]
    jg      short loc_4A454B
    push    ebp
    push    ebx
    call    sub_49FC50
    push    2

    loc_4A4545:                             ; CODE XREF: sub_4A4440+D6j
    push    ebx
    call    sub_4AB690

    loc_4A454B:                             ; CODE XREF: sub_4A4440+B9j
                                            ; sub_4A4440+BFj ...
    cmp     [ebx+64h], ebp
    jnz     short loc_4A458C
    push    3
    push    ebx
    call    sub_4AB5B0
    test    eax, eax
    jnz     short loc_4A458C
    mov     eax, [esp+38h+var_28]
    mov     dword ptr [ebx+64h], 0FFFFFFFFh
    cmp     esi, eax
    jl      short loc_4A458C
    cmp     esi, [esp+38h+var_20]
    jg      short loc_4A458C
    cmp     edi, [esp+38h+var_24]
    jl      short loc_4A458C
    cmp     edi, [esp+38h+var_1C]
    jg      short loc_4A458C
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A458C:                             ; CODE XREF: sub_4A4440+10Ej
                                            ; sub_4A4440+11Aj ...
    mov     eax, [ebx+64h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A45C0
    lea     ecx, ds:0[eax*8]
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esp+38h+arg_0]
    add     edx, eax
    cmp     byte ptr [edx+ecx*2], 3
    jnz     short loc_4A45C0
    push    0FBh
    call    sub_4C1B80
    test    eax, eax
    jz      short loc_4A4611

    loc_4A45C0:                             ; CODE XREF: sub_4A4440+152j
                                            ; sub_4A4440+170j
    cmp     dword ptr [ebx+0CC6h], 1
    jnz     short loc_4A4611
    mov     ebx, [esp+38h+arg_8]
    test    ebx, ebx
    jz      short loc_4A4611
    mov     esi, [esp+38h+arg_4]
    movsx   eax, byte ptr [esi+147h]
    push    eax                             ; int
    call    _tolower
    add     esp, 4
    cmp     al, bl
    jz      short loc_4A45FD
    movsx   ecx, byte ptr [esi+147h]
    push    ecx                             ; int
    call    _toupper
    add     esp, 4
    cmp     al, bl
    jnz     short loc_4A4611

    loc_4A45FD:                             ; CODE XREF: sub_4A4440+1A7j
    call    sub_4C1AB0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A4611:                             ; CODE XREF: sub_4A4440+44j
                                            ; sub_4A4440+17Ej ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 28h
    retn    0Ch
    sub_4A4440 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    push    esi
    mov     edx, [eax+18h]
    mov     eax, [esp+0Ch]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     esi, [edx+4]
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [eax+ecx*2]
    add     esi, eax
    call    sub_4B6340
    add     eax, [esi+0C2h]
    mov     [esi+0C6h], eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A4660 proc near                    ; CODE XREF: .text:004A4923p
                                            ; sub_4A81E0+1204p ...

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= byte ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 24h
    push    ebx
    push    ebp
    mov     ebp, [esp+2Ch+arg_0]
    push    esi
    push    edi
    xor     edi, edi
    mov     eax, [ebp+18h]
    mov     edx, [eax+4]
    mov     eax, [esp+34h+arg_4]
    mov     ecx, eax
    mov     esi, edx
    shl     ecx, 3
    sub     ecx, eax
    add     esi, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    mov     eax, [ebp+0Ch]
    mov     [ebp+14h], eax
    mov     ebx, [edx+0BCh]
    cmp     ebx, edi
    lea     esi, [esi+ecx*2]
    jnz     short loc_4A46A4
    mov     ebx, [ebp+0CD2h]

    loc_4A46A4:                             ; CODE XREF: sub_4A4660+3Cj
    push    ebx
    call    sub_4C5E70
    movsx   ecx, word ptr [esi+13h]
    mov     [esp+34h+var_24], ecx
    movsx   edx, word ptr [esi+15h]
    mov     [esp+34h+var_20], edx
    movsx   eax, word ptr [esi+17h]
    movsx   ecx, word ptr [esi+13h]
    add     eax, ecx
    xor     ecx, ecx
    mov     [esp+34h+var_1C], eax
    mov     cl, [ebp+8C6h]
    movsx   edx, word ptr [esi+19h]
    movsx   eax, word ptr [esi+15h]
    add     edx, eax
    xor     eax, eax
    mov     al, [ebp+8B2h]
    mov     [esp+34h+var_18], edx
    xor     edx, edx
    push    ecx
    mov     dl, [ebp+8C3h]
    lea     ecx, [esp+38h+var_24]
    push    edx
    push    eax
    push    ecx
    push    ebx
    call    sub_4B04B0
    mov     eax, 2
    mov     edx, [esp+34h+var_24]
    mov     ecx, [esp+34h+var_20]
    add     edx, eax
    add     ecx, eax
    mov     [esp+34h+var_24], edx
    mov     edx, [esp+34h+var_1C]
    mov     [esp+34h+var_20], ecx
    mov     ecx, [esp+34h+var_18]
    sub     edx, eax
    sub     ecx, eax
    mov     [esp+34h+var_1C], edx
    mov     [esp+34h+var_18], ecx
    mov     edx, [esi+23h]
    lea     eax, [esp+34h+var_24]
    push    edx
    push    eax
    push    ebx
    call    sub_4BF6F0
    fild    dword ptr [esi+0BAh]
    movsx   ecx, word ptr [esi+17h]
    fidiv   dword ptr [esi+0B6h]
    sub     ecx, 4
    mov     [esp+34h+arg_0], ecx
    fimul   [esp+34h+arg_0]
    call    __ftol
    add     eax, [esp+34h+var_24]
    mov     [esp+34h+var_1C], eax
    mov     edx, [esi+1Fh]
    lea     eax, [esp+34h+var_24]
    push    edx
    push    eax
    push    ebx
    call    sub_4BF6F0
    cmp     [esi+0D2h], edi
    jz      loc_4A4876
    mov     edx, [esi+0BAh]
    lea     ecx, [esp+34h+var_14]
    push    0Ah                             ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    __itoa
    lea     eax, [esp+40h+var_14]
    add     esp, 0Ch
    test    eax, eax
    mov     [esp+34h+arg_0], edi
    jz      short loc_4A480A
    mov     ecx, dword_51FBA4
    cmp     [ecx+14h], edi
    jnz     short loc_4A47BC
    lea     edx, [esp+34h+var_14]
    push    edx
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    mov     edi, eax
    jmp     short loc_4A480A
    ; ---------------------------------------------------------------------------

    loc_4A47BC:                             ; CODE XREF: sub_4A4660+146j
    mov     al, [esp+34h+var_14]
    lea     edi, [esp+34h+var_14]
    test    al, al
    jz      short loc_4A4806

    loc_4A47C8:                             ; CODE XREF: sub_4A4660+1A4j
    mov     al, [edi]
    mov     edx, dword_51FBA4
    mov     byte ptr [esp+34h+arg_4], al
    mov     ecx, [esp+34h+arg_4]
    mov     eax, [edx+14h]
    and     ecx, 0FFh
    push    ecx
    mov     ecx, [eax+0Ch]
    push    ecx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A47FE
    xor     edx, edx
    mov     dx, [eax]
    mov     eax, [esp+34h+arg_0]
    add     eax, edx
    mov     [esp+34h+arg_0], eax

    loc_4A47FE:                             ; CODE XREF: sub_4A4660+18Dj
    mov     al, [edi+1]
    inc     edi
    test    al, al
    jnz     short loc_4A47C8

    loc_4A4806:                             ; CODE XREF: sub_4A4660+166j
    mov     edi, [esp+34h+arg_0]

    loc_4A480A:                             ; CODE XREF: sub_4A4660+13Bj
                                            ; sub_4A4660+15Aj
    mov     eax, dword_51FBA4
    mov     eax, [eax+14h]
    test    eax, eax
    jnz     short loc_4A481D
    call    sub_4C1450
    jmp     short loc_4A4833
    ; ---------------------------------------------------------------------------

    loc_4A481D:                             ; CODE XREF: sub_4A4660+1B4j
    mov     ecx, [eax+0Ch]
    push    49h
    push    ecx
    call    sub_4B7F30
    xor     edx, edx
    mov     dx, [eax+2]
    mov     eax, edx
    add     eax, 2

    loc_4A4833:                             ; CODE XREF: sub_4A4660+1BBj
    cdq
    sub     eax, edx
    push    0
    mov     ecx, eax
    push    0FFFFFFFFh
    movsx   eax, word ptr [esi+19h]
    cdq
    sub     eax, edx
    movsx   edx, word ptr [esi+15h]
    sar     ecx, 1
    sar     eax, 1
    sub     eax, ecx
    add     eax, edx
    push    eax
    mov     eax, edi
    cdq
    sub     eax, edx
    mov     ecx, eax
    movsx   eax, word ptr [esi+17h]
    cdq
    sub     eax, edx
    movsx   edx, word ptr [esi+13h]
    sar     ecx, 1
    sar     eax, 1
    sub     eax, ecx
    add     eax, edx
    push    eax
    lea     eax, [esp+44h+var_14]
    push    eax
    push    ebx
    call    sub_4A50E0

    loc_4A4876:                             ; CODE XREF: sub_4A4660+115j
    mov     ecx, [ebp+8]
    push    ebx
    mov     [ebp+14h], ecx
    call    sub_4C5FA0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    8
    sub_4A4660 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+14h]
    mov     eax, edi
    mov     ebx, [esp+10h]
    shl     eax, 3
    sub     eax, edi
    mov     ecx, [ebx+18h]
    lea     edx, [eax+eax*2]
    mov     esi, [ecx+4]
    lea     eax, [edi+edx*2]
    lea     edx, [edi+eax*4]
    lea     eax, [edi+edx*2]
    add     esi, eax
    mov     eax, [esi+0CEh]
    test    eax, eax
    jz      short loc_4A4928
    mov     ecx, [esi+0BAh]
    mov     eax, [esi+0BEh]
    cmp     ecx, eax
    jge     short loc_4A4928
    call    sub_4B6340
    cmp     eax, [esi+0C6h]
    jle     short loc_4A4921
    fld     dword ptr [esi+0CAh]
    call    __ftol
    mov     ecx, [esi+0BAh]
    add     ecx, eax
    mov     eax, [esi+0BEh]
    cmp     ecx, eax
    mov     [esi+0BAh], ecx
    jle     short loc_4A4910
    mov     [esi+0BAh], eax
    mov     dword ptr [esi+0CEh], 0

    loc_4A4910:                             ; CODE XREF: .text:004A48FEj
    call    sub_4B6340
    add     eax, [esi+0C2h]
    mov     [esi+0C6h], eax

    loc_4A4921:                             ; CODE XREF: .text:004A48DBj
    push    edi
    push    ebx
    call    sub_4A4660

    loc_4A4928:                             ; CODE XREF: .text:004A48BEj
                                            ; .text:004A48CEj
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    mov     edx, [eax+18h]
    mov     eax, [esp+8]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     ecx, [eax+ecx*2]
    mov     eax, [edx+4]
    add     eax, ecx
    xor     ecx, ecx
    mov     [eax+0B6h], ecx
    mov     [eax+0BEh], ecx
    mov     [eax+0C2h], ecx
    mov     [eax+0C6h], cx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A4980 proc near                    ; CODE XREF: sub_4A81E0+11C4p

    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 50h
    push    ebx
    push    ebp
    mov     ebp, [esp+58h+arg_0]
    push    esi
    push    edi
    mov     eax, [ebp+18h]
    mov     ebx, [eax+4]
    mov     eax, [esp+60h+arg_4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    lea     eax, [edx+ecx*2]
    mov     cl, [edx+ecx*2]
    test    cl, cl
    jnz     short loc_4A49BD
    xor     ecx, ecx
    xor     edx, edx
    mov     [esp+60h+var_50], ecx
    jmp     short loc_4A49C9
    ; ---------------------------------------------------------------------------

    loc_4A49BD:                             ; CODE XREF: sub_4A4980+31j
    movsx   ecx, word ptr [eax+13h]
    mov     [esp+60h+var_50], ecx
    movsx   edx, word ptr [eax+15h]

    loc_4A49C9:                             ; CODE XREF: sub_4A4980+3Bj
    mov     [esp+60h+var_4C], edx
    movsx   esi, word ptr [eax+17h]
    lea     esi, [esi+ecx-1]
    mov     [esp+60h+var_48], esi
    movsx   edi, word ptr [eax+19h]
    mov     [esp+60h+var_20], ecx
    mov     [esp+60h+var_8], ecx
    lea     edi, [edi+edx-1]
    mov     ecx, 1
    mov     [esp+60h+var_44], edi
    mov     [esp+60h+var_1C], edx
    mov     [esp+60h+var_18], esi
    mov     [esp+60h+var_14], edx
    mov     [esp+60h+var_10], esi
    mov     [esp+60h+var_C], edi
    mov     [esp+60h+var_4], edi
    mov     [esp+60h+var_40], ecx
    mov     [esp+60h+var_3C], ecx
    mov     [esp+60h+var_28], ecx
    mov     [esp+60h+var_34], ecx
    mov     ecx, [eax+0BEh]
    test    ecx, ecx
    jz      loc_4A4ABD
    movsx   eax, word ptr [eax+0C6h]
    push    eax
    push    ecx
    call    sub_4B7F30
    test    eax, eax
    jz      loc_4A4B44
    xor     ecx, ecx
    xor     edx, edx
    mov     cx, [eax]
    dec     ecx
    mov     [esp+60h+var_38], ecx
    mov     dx, [eax]
    dec     edx
    xor     ecx, ecx
    mov     [esp+60h+var_30], edx
    mov     cx, [eax+2]
    dec     ecx
    xor     edx, edx
    mov     [esp+60h+var_2C], ecx
    mov     dx, [eax+2]
    dec     edx
    mov     [esp+60h+var_24], edx
    mov     cl, [eax+9]
    test    cl, cl
    jnz     short loc_4A4A90
    lea     ecx, [esp+60h+var_40]
    lea     edx, [esp+60h+var_20]
    push    ecx
    push    edx
    push    eax
    mov     eax, [ebx+0BCh]
    push    eax
    call    sub_4C7580
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 50h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A4A90:                             ; CODE XREF: sub_4A4980+EDj
    movsx   ecx, word ptr [eax+6]
    mov     edx, [esp+60h+var_4C]
    mov     edi, [esp+60h+var_50]
    add     ecx, edx
    movsx   edx, word ptr [eax+4]
    add     edx, edi
    push    ecx
    push    edx
    push    eax
    mov     eax, [ebx+0BCh]
    push    eax
    call    sub_4B7F90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 50h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A4ABD:                             ; CODE XREF: sub_4A4980+A2j
    mov     ecx, [eax+0C2h]
    test    ecx, ecx
    jz      short loc_4A4B2A
    xor     edx, edx
    mov     dx, [ecx]
    dec     edx
    mov     [esp+60h+var_38], edx
    mov     ecx, [eax+0C2h]
    xor     edx, edx
    mov     dx, [ecx]
    dec     edx
    mov     [esp+60h+var_30], edx
    mov     ecx, [eax+0C2h]
    xor     edx, edx
    mov     dx, [ecx+2]
    dec     edx
    mov     [esp+60h+var_2C], edx
    mov     ecx, [eax+0C2h]
    xor     edx, edx
    mov     dx, [ecx+2]
    lea     ecx, [esp+60h+var_40]
    dec     edx
    push    ecx
    mov     [esp+64h+var_24], edx
    mov     eax, [eax+0C2h]
    mov     ecx, [ebx+0BCh]
    lea     edx, [esp+64h+var_20]
    push    edx
    push    eax
    push    ecx
    call    sub_4C7580
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 50h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A4B2A:                             ; CODE XREF: sub_4A4980+145j
    mov     ecx, [ebx+0BCh]
    xor     edx, edx
    mov     dl, [ebp+8B9h]
    lea     eax, [esp+60h+var_50]
    push    edx
    push    eax
    push    ecx
    call    sub_4BF6F0

    loc_4A4B44:                             ; CODE XREF: sub_4A4980+B8j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 50h
    retn    8
    sub_4A4980 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A4B50 proc near                    ; CODE XREF: sub_4A9FD0+4A8p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    ebx
    mov     ebx, [esp+14h+arg_4]
    push    ebp
    push    esi
    mov     esi, [esp+1Ch+arg_0]
    push    edi
    mov     eax, [esi+18h]
    mov     ecx, [eax+4]
    mov     eax, ebx
    shl     eax, 3
    sub     eax, ebx
    add     ecx, ebx
    lea     edx, [eax+eax*2]
    lea     eax, [ebx+edx*2]
    lea     edx, [ebx+eax*4]
    mov     al, [ecx+edx*2]
    test    al, al
    lea     edi, [ecx+edx*2]
    jnz     short loc_4A4B89
    xor     ebp, ebp
    mov     [esp+20h+var_C], ebp
    jmp     short loc_4A4B95
    ; ---------------------------------------------------------------------------

    loc_4A4B89:                             ; CODE XREF: sub_4A4B50+2Fj
    movsx   eax, word ptr [edi+15h]
    movsx   ebp, word ptr [edi+13h]
    mov     [esp+20h+var_C], eax

    loc_4A4B95:                             ; CODE XREF: sub_4A4B50+37j
    movsx   ecx, word ptr [edi+17h]
    movsx   eax, word ptr [edi+19h]
    lea     edx, [ecx+ebp-1]
    mov     ecx, [esp+20h+var_C]
    mov     [esp+20h+var_8], edx
    lea     edx, [eax+ecx-1]
    mov     eax, [edi+0B6h]
    test    eax, eax
    mov     [esp+20h+var_4], edx
    jz      short loc_4A4BBF
    push    edi
    push    esi
    call    eax

    loc_4A4BBF:                             ; CODE XREF: sub_4A4B50+69j
    test    byte ptr [edi+0C8h], 1
    jz      loc_4A4C79
    push    1
    push    esi
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A4BFF
    mov     eax, [esi+3Ch]
    mov     ecx, [esi+40h]
    cmp     eax, ebp
    jl      short loc_4A4C36
    cmp     eax, [esp+20h+var_8]
    jg      short loc_4A4C36
    cmp     ecx, [esp+20h+var_C]
    jl      short loc_4A4C36
    cmp     ecx, [esp+20h+var_4]
    jg      short loc_4A4C36
    push    ebx
    push    esi
    call    sub_49FC50
    push    1
    jmp     short loc_4A4C30
    ; ---------------------------------------------------------------------------

    loc_4A4BFF:                             ; CODE XREF: sub_4A4B50+86j
    push    2
    push    esi
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A4C36
    mov     eax, [esi+3Ch]
    mov     ecx, [esi+40h]
    cmp     eax, ebp
    jl      short loc_4A4C36
    cmp     eax, [esp+20h+var_8]
    jg      short loc_4A4C36
    cmp     ecx, [esp+20h+var_C]
    jl      short loc_4A4C36
    cmp     ecx, [esp+20h+var_4]
    jg      short loc_4A4C36
    push    ebx
    push    esi
    call    sub_49FC50
    push    2

    loc_4A4C30:                             ; CODE XREF: sub_4A4B50+ADj
    push    esi
    call    sub_4AB690

    loc_4A4C36:                             ; CODE XREF: sub_4A4B50+90j
                                            ; sub_4A4B50+96j ...
    cmp     [esi+64h], ebx
    jnz     short loc_4A4C79
    push    3
    push    esi
    call    sub_4AB5B0
    test    eax, eax
    jnz     short loc_4A4C79
    mov     dword ptr [esi+64h], 0FFFFFFFFh
    mov     eax, [esi+40h]
    mov     esi, [esi+3Ch]
    cmp     esi, ebp
    jl      short loc_4A4C79
    cmp     esi, [esp+20h+var_8]
    jg      short loc_4A4C79
    cmp     eax, [esp+20h+var_C]
    jl      short loc_4A4C79
    cmp     eax, [esp+20h+var_4]
    jg      short loc_4A4C79
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A4C79:                             ; CODE XREF: sub_4A4B50+76j
                                            ; sub_4A4B50+E9j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 10h
    retn    8
    sub_4A4B50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A4C90 proc near                    ; CODE XREF: sub_4A81E0+1227p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    mov     edx, [esp+arg_0]
    sub     esp, 10h
    mov     eax, [edx+18h]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [eax+4]
    mov     eax, [esp+20h+arg_4]
    mov     esi, edi
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [esi+ecx*2]
    mov     cl, [esi+ecx*2]
    test    cl, cl
    jnz     short loc_4A4CC9
    xor     ecx, ecx
    xor     esi, esi
    jmp     short loc_4A4CD1
    ; ---------------------------------------------------------------------------

    loc_4A4CC9:                             ; CODE XREF: sub_4A4C90+31j
    movsx   ecx, word ptr [eax+13h]
    movsx   esi, word ptr [eax+15h]

    loc_4A4CD1:                             ; CODE XREF: sub_4A4C90+37j
    movsx   ebx, word ptr [eax+17h]
    lea     ebp, [ebx+ecx-1]
    movsx   ebx, word ptr [eax+19h]
    lea     ebx, [ebx+esi-1]
    mov     [esp+20h+var_4], ebx
    mov     bl, [esp+20h+arg_8]
    test    bl, 1
    jz      short loc_4A4D5D
    mov     ebx, [eax+1Bh]
    test    bl, 1
    jz      short loc_4A4D1D
    mov     eax, [eax+1Fh]
    xor     ebx, ebx
    mov     bl, [eax+edx+8B2h]
    push    ebx
    push    esi
    push    ebp
    push    esi
    push    ecx
    mov     ecx, [edi+0BCh]
    push    ecx
    call    sub_4BE950
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A4D1D:                             ; CODE XREF: sub_4A4C90+64j
    test    bl, 2
    jz      short loc_4A4D37
    mov     eax, [eax+1Fh]
    xor     ebx, ebx
    mov     bl, [eax+edx+8B2h]
    mov     edx, [esp+20h+var_4]
    push    ebx
    push    edx
    push    ecx
    jmp     short loc_4A4D4F
    ; ---------------------------------------------------------------------------

    loc_4A4D37:                             ; CODE XREF: sub_4A4C90+90j
    test    bl, 4
    jz      short loc_4A4D5D
    mov     eax, [eax+1Fh]
    xor     ebx, ebx
    mov     bl, [eax+edx+8B2h]
    mov     edx, [esp+20h+var_4]
    push    ebx
    push    edx
    push    ebp

    loc_4A4D4F:                             ; CODE XREF: sub_4A4C90+A5j
    mov     eax, [edi+0BCh]
    push    esi
    push    ecx
    push    eax
    call    sub_4BE950

    loc_4A4D5D:                             ; CODE XREF: sub_4A4C90+5Cj
                                            ; sub_4A4C90+AAj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    sub_4A4C90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A4D70 proc near                    ; CODE XREF: sub_4A2BE0+163p
                                            ; sub_4A81E0+1117p ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    mov     edx, [esp+18h+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [edx+18h]
    mov     esi, [esp+24h+arg_4]
    push    edi
    mov     edi, 1
    mov     ebx, [eax+4]
    xor     ebp, ebp
    mov     [esp+28h+var_18], ebx
    movsx   eax, word ptr [ebx+0B6h]
    lea     ecx, [eax+1]
    cmp     ecx, edi
    jle     short loc_4A4DFF
    lea     edx, [ebx+15Bh]

    loc_4A4DA4:                             ; CODE XREF: sub_4A4D70+62j
    cmp     byte ptr [edx], 7
    jnz     short loc_4A4DC9
    mov     eax, esi
    add     ebx, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     eax, [esi+eax*2]
    lea     eax, [esi+eax*4]
    movsx   eax, byte ptr [ebx+eax*2+28h]
    cmp     ebp, eax
    jz      short loc_4A4DD6
    mov     ebx, [esp+28h+var_18]
    inc     ebp

    loc_4A4DC9:                             ; CODE XREF: sub_4A4D70+37j
    inc     edi
    add     edx, 15Bh
    cmp     edi, ecx
    jl      short loc_4A4DA4
    jmp     short loc_4A4DFB
    ; ---------------------------------------------------------------------------

    loc_4A4DD6:                             ; CODE XREF: sub_4A4D70+52j
    mov     eax, edi
    mov     ebx, [esp+28h+var_18]
    shl     eax, 3
    sub     eax, edi
    lea     ecx, [eax+eax*2]
    lea     edx, [edi+ecx*2]
    mov     ecx, ebx
    add     ecx, edi
    lea     eax, [edi+edx*4]
    mov     edx, [ecx+eax*2+0D6h]
    push    edx
    call    sub_4C1420

    loc_4A4DFB:                             ; CODE XREF: sub_4A4D70+64j
    mov     edx, [esp+28h+arg_0]

    loc_4A4DFF:                             ; CODE XREF: sub_4A4D70+2Cj
    movsx   eax, word ptr [ebx+0B6h]
    inc     eax
    cmp     edi, eax
    jnz     short loc_4A4E1D
    mov     ecx, dword_51FBA4
    mov     edx, [ecx]
    push    edx
    call    sub_4C1420
    mov     edx, [esp+28h+arg_0]

    loc_4A4E1D:                             ; CODE XREF: sub_4A4D70+99j
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    lea     eax, [esi+ecx*4]
    mov     ecx, ebx
    add     ecx, esi
    lea     edi, [ecx+eax*2]
    mov     al, [ecx+eax*2]
    test    al, al
    jnz     short loc_4A4E45
    xor     eax, eax
    xor     ecx, ecx
    mov     [esp+28h+var_10], eax
    jmp     short loc_4A4E51
    ; ---------------------------------------------------------------------------

    loc_4A4E45:                             ; CODE XREF: sub_4A4D70+C9j
    movsx   eax, word ptr [edi+13h]
    mov     [esp+28h+var_10], eax
    movsx   ecx, word ptr [edi+15h]

    loc_4A4E51:                             ; CODE XREF: sub_4A4D70+D3j
    mov     [esp+28h+var_C], ecx
    movsx   ebp, word ptr [edi+17h]
    lea     eax, [ebp+eax-1]
    mov     [esp+28h+var_8], eax
    movsx   eax, word ptr [edi+19h]
    lea     ecx, [eax+ecx-1]
    mov     [esp+28h+var_4], ecx
    mov     al, [edi+1Bh]
    test    al, 1
    jz      short loc_4A4E90
    xor     eax, eax
    lea     ecx, [esp+28h+var_10]
    mov     al, [edx+8B2h]
    mov     edx, [ebx+0BCh]
    push    eax
    push    ecx
    push    edx
    call    sub_4BF6F0
    jmp     short loc_4A4EC5
    ; ---------------------------------------------------------------------------

    loc_4A4E90:                             ; CODE XREF: sub_4A4D70+102j
    mov     eax, [edx+18h]
    mov     eax, [eax+24h]
    test    eax, eax
    jnz     short loc_4A4EAE
    mov     eax, [edx+0CD2h]
    test    eax, eax
    jnz     short loc_4A4EAE
    push    eax
    push    esi
    push    edx
    call    sub_4B0230
    jmp     short loc_4A4EC5
    ; ---------------------------------------------------------------------------

    loc_4A4EAE:                             ; CODE XREF: sub_4A4D70+128j
                                            ; sub_4A4D70+132j
    lea     ecx, [esp+28h+var_10]
    lea     edx, [esp+28h+var_10]
    push    ecx
    push    edx
    push    eax
    mov     eax, [ebx+0BCh]
    push    eax
    call    sub_4C6D20

    loc_4A4EC5:                             ; CODE XREF: sub_4A4D70+11Ej
                                            ; sub_4A4D70+13Cj
    call    sub_4C13F0
    mov     ecx, [edi+1Fh]
    push    eax
    mov     eax, [esp+2Ch+arg_0]
    xor     edx, edx
    mov     dl, [ecx+eax+8B2h]
    push    edx
    call    sub_4C13A0
    lea     ebp, [edi+0B6h]
    mov     eax, [esp+28h+var_C]
    mov     edx, [esp+28h+var_8]
    add     eax, 3
    mov     [esp+28h+var_C], eax
    mov     ecx, [edi+1Fh]
    push    ecx
    mov     ecx, [esp+2Ch+var_10]
    sub     edx, ecx
    push    edx
    push    eax
    mov     eax, [ebx+0BCh]
    push    ecx
    push    ebp
    push    eax
    call    sub_4A50E0
    mov     eax, [esp+28h+arg_0]
    cmp     esi, [eax+64h]
    jnz     loc_4A4FFB
    mov     ecx, [eax+74h]
    xor     esi, esi
    cmp     ebp, esi
    mov     [esp+28h+var_18], esi
    mov     dl, [ecx+edi+0B6h]
    lea     edi, [ecx+edi+0B6h]
    mov     byte ptr [esp+28h+arg_4], dl
    mov     byte ptr [edi], 0
    jz      short loc_4A4FA3
    mov     eax, dword_51FBA4
    cmp     [eax+14h], esi
    jnz     short loc_4A4F59
    push    ebp
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    mov     esi, eax
    jmp     short loc_4A4FA3
    ; ---------------------------------------------------------------------------

    loc_4A4F59:                             ; CODE XREF: sub_4A4D70+1D7j
    mov     al, [ebp+0]
    mov     esi, ebp
    test    al, al
    jz      short loc_4A4F9F

    loc_4A4F62:                             ; CODE XREF: sub_4A4D70+22Dj
    mov     cl, [esi]
    mov     eax, dword_51FBA4
    mov     byte ptr [esp+28h+var_14], cl
    mov     edx, [esp+28h+var_14]
    mov     ecx, [eax+14h]
    and     edx, 0FFh
    push    edx
    mov     edx, [ecx+0Ch]
    push    edx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A4F97
    xor     ecx, ecx
    mov     cx, [eax]
    mov     eax, [esp+28h+var_18]
    add     eax, ecx
    mov     [esp+28h+var_18], eax

    loc_4A4F97:                             ; CODE XREF: sub_4A4D70+216j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A4F62

    loc_4A4F9F:                             ; CODE XREF: sub_4A4D70+1F0j
    mov     esi, [esp+28h+var_18]

    loc_4A4FA3:                             ; CODE XREF: sub_4A4D70+1CDj
                                            ; sub_4A4D70+1E7j
    mov     dl, byte ptr [esp+28h+arg_4]
    mov     [edi], dl
    mov     eax, dword_51FBA4
    mov     eax, [eax+14h]
    test    eax, eax
    jnz     short loc_4A4FBC
    call    sub_4C1450
    jmp     short loc_4A4FD2
    ; ---------------------------------------------------------------------------

    loc_4A4FBC:                             ; CODE XREF: sub_4A4D70+243j
    mov     ecx, [eax+0Ch]
    push    49h
    push    ecx
    call    sub_4B7F30
    xor     edx, edx
    mov     dx, [eax+2]
    mov     eax, edx
    add     eax, 2

    loc_4A4FD2:                             ; CODE XREF: sub_4A4D70+24Aj
    mov     ecx, [esp+28h+var_10]
    xor     edx, edx
    add     ecx, esi
    mov     esi, [esp+28h+arg_0]
    mov     dl, [esi+8BBh]
    push    edx
    mov     edx, [esp+2Ch+var_C]
    add     eax, edx
    push    eax
    mov     eax, [ebx+0BCh]
    push    ecx
    push    edx
    push    ecx
    push    eax
    call    sub_4BE950

    loc_4A4FFB:                             ; CODE XREF: sub_4A4D70+1A7j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    sub_4A4D70 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, dword_51FBA4
    mov     eax, [esp+4]
    and     eax, 0FFh
    mov     edx, [ecx+14h]
    push    eax
    mov     eax, [edx+0Ch]
    push    eax
    call    sub_4B7F30
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A5030 proc near                    ; CODE XREF: .text:0042576Bp
                                            ; .text:004265E2p ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    xor     edi, edi
    test    esi, esi
    jnz     short loc_4A5043
    xor     eax, eax
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4A5043:                             ; CODE XREF: sub_4A5030+Aj
    mov     eax, dword_51FBA4
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_4A5060
    push    esi
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4A5060:                             ; CODE XREF: sub_4A5030+1Dj
    cmp     byte ptr [esi], 0
    jz      short loc_4A509A

    loc_4A5065:                             ; CODE XREF: sub_4A5030+68j
    mov     cl, [esi]
    mov     eax, dword_51FBA4
    mov     byte ptr [esp+4+arg_0], cl
    mov     edx, [esp+4+arg_0]
    mov     ecx, [eax+14h]
    and     edx, 0FFh
    push    edx
    mov     edx, [ecx+0Ch]
    push    edx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A5092
    xor     ecx, ecx
    mov     cx, [eax]
    add     edi, ecx

    loc_4A5092:                             ; CODE XREF: sub_4A5030+59j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A5065

    loc_4A509A:                             ; CODE XREF: sub_4A5030+33j
    mov     eax, edi
    pop     edi
    pop     esi
    retn    4
    sub_4A5030 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A50B0 proc near                    ; CODE XREF: sub_41E420+1CDp
                                            ; sub_448C70+8Ap ...
    mov     eax, dword_51FBA4
    mov     eax, [eax+14h]
    test    eax, eax
    jnz     short loc_4A50C1
    jmp     sub_4C1450
    ; ---------------------------------------------------------------------------

    loc_4A50C1:                             ; CODE XREF: sub_4A50B0+Aj
    mov     ecx, [eax+0Ch]
    push    49h
    push    ecx
    call    sub_4B7F30
    xor     edx, edx
    mov     dx, [eax+2]
    mov     eax, edx
    add     eax, 2
    retn
    sub_4A50B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A50E0 proc near                    ; CODE XREF: .text:0044AF11p
                                            ; sub_464060+1D0p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    mov     eax, dword_51FBA4
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+14h]
    push    edi
    test    ecx, ecx
    jnz     short loc_4A5112
    mov     ecx, [esp+10h+arg_C]
    mov     edx, [esp+10h+arg_8]
    mov     eax, [esp+10h+arg_4]
    push    0FFFFFFFFh
    push    ecx
    mov     ecx, [esp+18h+arg_0]
    push    edx
    push    eax
    push    ecx
    call    PrintGUIText
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4A5112:                             ; CODE XREF: sub_4A50E0+Ej
    mov     eax, [esp+10h+arg_4]
    mov     ecx, eax
    mov     dl, [eax]
    mov     [esp+10h+arg_4], ecx
    test    dl, dl
    jz      loc_4A51C7
    mov     ebx, [esp+10h+arg_C]
    mov     ebp, [esp+10h+arg_0]
    mov     edi, [esp+10h+arg_8]

    loc_4A5132:                             ; CODE XREF: sub_4A50E0+E1j
    mov     al, [ecx]
    cmp     al, 20h
    jb      short loc_4A51B5
    mov     byte ptr [esp+10h+arg_C], al
    mov     eax, dword_51FBA4
    mov     edx, [esp+10h+arg_C]
    mov     ecx, [eax+14h]
    and     edx, 0FFh
    push    edx
    mov     edx, [ecx+0Ch]
    push    edx
    call    sub_4B7F30
    mov     esi, eax
    test    esi, esi
    jz      short loc_4A51B5
    mov     eax, [esp+10h+arg_10]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A5170
    xor     ecx, ecx
    mov     cx, [esi]
    cmp     ecx, eax
    jg      short loc_4A51C7

    loc_4A5170:                             ; CODE XREF: sub_4A50E0+85j
    mov     edx, [esp+10h+arg_4]
    cmp     byte ptr [edx], 20h
    jz      short loc_4A5196
    mov     eax, [esp+10h+arg_14]
    test    eax, eax
    jnz     short loc_4A518C
    push    ebx
    push    edi
    push    esi
    push    ebp
    call    sub_4B7F90
    jmp     short loc_4A5196
    ; ---------------------------------------------------------------------------

    loc_4A518C:                             ; CODE XREF: sub_4A50E0+9Fj
    push    eax
    push    ebx
    push    edi
    push    esi
    push    ebp
    call    sub_4B8310

    loc_4A5196:                             ; CODE XREF: sub_4A50E0+97j
                                            ; sub_4A50E0+AAj
    cmp     [esp+10h+arg_10], 0FFFFFFFFh
    jz      short loc_4A51AE
    mov     ecx, [esp+10h+arg_10]
    xor     eax, eax
    mov     ax, [esi]
    sub     ecx, eax
    mov     [esp+10h+arg_10], ecx
    js      short loc_4A51C7

    loc_4A51AE:                             ; CODE XREF: sub_4A50E0+BBj
    xor     ecx, ecx
    mov     cx, [esi]
    add     edi, ecx

    loc_4A51B5:                             ; CODE XREF: sub_4A50E0+56j
                                            ; sub_4A50E0+7Cj
    mov     ecx, [esp+10h+arg_4]
    inc     ecx
    mov     [esp+10h+arg_4], ecx
    cmp     byte ptr [ecx], 0
    jnz     loc_4A5132

    loc_4A51C7:                             ; CODE XREF: sub_4A50E0+40j
                                            ; sub_4A50E0+8Ej ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    18h
    sub_4A50E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A51D0 proc near                    ; CODE XREF: sub_4A1B40+3ABp
                                            ; sub_4A56B0+3AEp

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    sub     esp, 18h
    push    ebx
    push    ebp
    mov     ebp, [esp+20h+arg_4]
    push    esi
    push    edi
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    xor     edx, edx
    repne scasb
    mov     al, [ebp+0]
    mov     [esp+28h+var_10], edx
    not     ecx
    dec     ecx
    mov     [esp+28h+var_C], edx
    mov     edi, ecx
    mov     [esp+28h+var_18], edx
    test    al, al
    mov     [esp+28h+var_8], edi
    jz      loc_4A5389
    jmp     short loc_4A520C
    ; ---------------------------------------------------------------------------

    loc_4A5208:                             ; CODE XREF: sub_4A51D0+1B3j
    mov     ebp, [esp+28h+arg_4]

    loc_4A520C:                             ; CODE XREF: sub_4A51D0+36j
    cmp     edx, edi
    jz      short loc_4A5224

    loc_4A5210:                             ; CODE XREF: sub_4A51D0+4Ej
    mov     al, [edx+ebp]
    cmp     al, 20h
    jz      short loc_4A5220
    cmp     al, 0Dh
    jz      short loc_4A5220
    inc     edx
    cmp     edx, edi
    jnz     short loc_4A5210

    loc_4A5220:                             ; CODE XREF: sub_4A51D0+45j
                                            ; sub_4A51D0+49j
    mov     [esp+28h+var_18], edx

    loc_4A5224:                             ; CODE XREF: sub_4A51D0+3Ej
    mov     eax, [esp+28h+var_C]
    mov     bl, [edx+ebp]
    lea     esi, [edx+ebp]
    add     ebp, eax
    xor     eax, eax
    cmp     ebp, eax
    mov     byte ptr [esi], 0
    mov     [esp+28h+var_14], eax
    jz      short loc_4A52AC
    mov     ecx, dword_51FBA4
    cmp     [ecx+14h], eax
    jnz     short loc_4A525A
    push    ebp
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    mov     edx, [esp+28h+var_18]
    jmp     short loc_4A52AC
    ; ---------------------------------------------------------------------------

    loc_4A525A:                             ; CODE XREF: sub_4A51D0+76j
    mov     al, [ebp+0]
    mov     edi, ebp
    test    al, al
    jz      short loc_4A52A4

    loc_4A5263:                             ; CODE XREF: sub_4A51D0+CEj
    mov     dl, [edi]
    mov     ecx, dword_51FBA4
    mov     byte ptr [esp+28h+var_4], dl
    mov     eax, [esp+28h+var_4]
    mov     edx, [ecx+14h]
    and     eax, 0FFh
    push    eax
    mov     eax, [edx+0Ch]
    push    eax
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A5298
    xor     ecx, ecx
    mov     cx, [eax]
    mov     eax, [esp+28h+var_14]
    add     eax, ecx
    mov     [esp+28h+var_14], eax

    loc_4A5298:                             ; CODE XREF: sub_4A51D0+B7j
    mov     al, [edi+1]
    inc     edi
    test    al, al
    jnz     short loc_4A5263
    mov     edx, [esp+28h+var_18]

    loc_4A52A4:                             ; CODE XREF: sub_4A51D0+91j
    mov     eax, [esp+28h+var_14]
    mov     edi, [esp+28h+var_8]

    loc_4A52AC:                             ; CODE XREF: sub_4A51D0+6Bj
                                            ; sub_4A51D0+88j
    mov     ecx, [esp+28h+arg_10]
    cmp     eax, ecx
    jle     loc_4A5397
    mov     edx, [esp+28h+arg_4]
    mov     [esi], bl
    mov     esi, [esp+28h+var_10]
    mov     [esp+28h+var_18], esi
    add     esi, edx
    mov     bl, [esi]
    mov     byte ptr [esi], 0

    loc_4A52CD:                             ; CODE XREF: sub_4A51D0+1CAj
                                            ; sub_4A51D0+1D2j
    mov     eax, [esp+28h+arg_18]
    mov     edi, [esp+28h+arg_C]
    mov     edx, [esp+28h+arg_0]
    push    eax
    push    ecx
    mov     ecx, [esp+30h+arg_8]
    push    edi
    push    ecx
    push    ebp
    push    edx
    call    sub_4A50E0
    mov     [esi], bl
    mov     eax, dword_51FBA4
    mov     eax, [eax+14h]
    test    eax, eax
    jnz     short loc_4A52FD
    call    sub_4C1450
    jmp     short loc_4A5313
    ; ---------------------------------------------------------------------------

    loc_4A52FD:                             ; CODE XREF: sub_4A51D0+124j
    mov     ecx, [eax+0Ch]
    push    49h
    push    ecx
    call    sub_4B7F30
    xor     edx, edx
    mov     dx, [eax+2]
    mov     eax, edx
    add     eax, 2

    loc_4A5313:                             ; CODE XREF: sub_4A51D0+12Bj
    mov     ecx, dword_51FBA4
    lea     eax, [edi+eax+2]
    mov     [esp+28h+arg_C], eax
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A532F
    call    sub_4C1450
    jmp     short loc_4A5345
    ; ---------------------------------------------------------------------------

    loc_4A532F:                             ; CODE XREF: sub_4A51D0+156j
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A5345:                             ; CODE XREF: sub_4A51D0+15Dj
    mov     ecx, [esp+28h+arg_14]
    mov     edx, 0FFFFFFFEh
    sub     edx, eax
    mov     al, [esi]
    add     ecx, edx
    test    al, al
    mov     [esp+28h+arg_14], ecx
    jz      short loc_4A5389
    mov     eax, [esp+28h+var_18]
    inc     eax
    test    ecx, ecx
    mov     [esp+28h+var_C], eax
    jle     short loc_4A5389
    mov     edi, [esp+28h+var_8]
    mov     [esp+28h+var_10], eax
    mov     [esp+28h+var_18], eax
    mov     edx, eax

    loc_4A5377:                             ; CODE XREF: sub_4A51D0+1E3j
    mov     ecx, [esp+28h+var_C]
    mov     eax, [esp+28h+arg_4]
    cmp     byte ptr [ecx+eax], 0
    jnz     loc_4A5208

    loc_4A5389:                             ; CODE XREF: sub_4A51D0+30j
                                            ; sub_4A51D0+18Aj ...
    mov     eax, [esp+28h+arg_C]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4A5397:                             ; CODE XREF: sub_4A51D0+E2j
    cmp     bl, 0Dh
    jz      loc_4A52CD
    cmp     edx, edi
    jz      loc_4A52CD
    mov     [esp+28h+var_10], edx
    inc     edx
    mov     [esi], bl
    mov     [esp+28h+var_18], edx
    jmp     short loc_4A5377
    sub_4A51D0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    mov     eax, [esp+14h]
    push    edi
    mov     esi, 1
    mov     edi, [ecx+4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, edi
    add     ecx, eax
    movsx   eax, word ptr [edi+0B6h]
    lea     ebp, [ecx+edx*2]
    xor     edx, edx
    inc     eax
    cmp     eax, esi
    jle     short loc_4A543E
    lea     ecx, [edi+15Bh]

    loc_4A5402:                             ; CODE XREF: .text:004A5419j
    cmp     byte ptr [ecx], 7
    jnz     short loc_4A5410
    movsx   ebx, byte ptr [ebp+28h]
    cmp     edx, ebx
    jz      short loc_4A541D
    inc     edx

    loc_4A5410:                             ; CODE XREF: .text:004A5405j
    inc     esi
    add     ecx, 15Bh
    cmp     esi, eax
    jl      short loc_4A5402
    jmp     short loc_4A543E
    ; ---------------------------------------------------------------------------

    loc_4A541D:                             ; CODE XREF: .text:004A540Dj
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    mov     edx, edi
    add     edx, esi
    lea     ecx, [esi+eax*4]
    mov     eax, [edx+ecx*2+0D6h]
    push    eax
    call    sub_4C1420

    loc_4A543E:                             ; CODE XREF: .text:004A53FAj
                                            ; .text:004A541Bj
    movsx   ecx, word ptr [edi+0B6h]
    inc     ecx
    cmp     esi, ecx
    jnz     short loc_4A5458
    mov     edx, dword_51FBA4
    mov     eax, [edx]
    push    eax
    call    sub_4C1420

    loc_4A5458:                             ; CODE XREF: .text:004A5448j
    cmp     byte ptr [ebp+0], 0
    jnz     short loc_4A5462
    xor     esi, esi
    jmp     short loc_4A5466
    ; ---------------------------------------------------------------------------

    loc_4A5462:                             ; CODE XREF: .text:004A545Cj
    movsx   esi, word ptr [ebp+13h]

    loc_4A5466:                             ; CODE XREF: .text:004A5460j
    mov     ecx, dword_51FBA4
    mov     ebx, esi
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A547C
    call    sub_4C1450
    jmp     short loc_4A5492
    ; ---------------------------------------------------------------------------

    loc_4A547C:                             ; CODE XREF: .text:004A5473j
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A5492:                             ; CODE XREF: .text:004A547Aj
    mov     [esp+14h], eax
    mov     eax, [ebp+1Bh]
    test    al, 4
    jz      loc_4A554D
    movsx   ebx, word ptr [ebp+17h]
    add     ebx, esi
    lea     esi, [ebp+0B6h]
    xor     edi, edi
    test    esi, esi
    jnz     short loc_4A54CB
    mov     dx, [esp+14h]
    xor     eax, eax
    sub     ebx, eax
    mov     [ebp+13h], bx
    mov     [ebp+19h], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A54CB:                             ; CODE XREF: .text:004A54B1j
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A54FA
    push    esi
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    sub     ebx, eax
    mov     dx, [esp+14h]
    mov     [ebp+13h], bx
    mov     [ebp+19h], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A54FA:                             ; CODE XREF: .text:004A54D6j
    cmp     byte ptr [esi], 0
    jz      short loc_4A5535

    loc_4A54FF:                             ; CODE XREF: .text:004A5533j
    mov     al, [esi]
    mov     edx, dword_51FBA4
    mov     [esp+18h], al
    mov     ecx, [esp+18h]
    mov     eax, [edx+14h]
    and     ecx, 0FFh
    push    ecx
    mov     ecx, [eax+0Ch]
    push    ecx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A552D
    xor     edx, edx
    mov     dx, [eax]
    add     edi, edx

    loc_4A552D:                             ; CODE XREF: .text:004A5524j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A54FF

    loc_4A5535:                             ; CODE XREF: .text:004A54FDj
    mov     dx, [esp+14h]
    mov     eax, edi
    sub     ebx, eax
    mov     [ebp+13h], bx
    mov     [ebp+19h], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A554D:                             ; CODE XREF: .text:004A549Bj
    test    al, 2
    jz      loc_4A562A
    movsx   eax, word ptr [ebp+17h]
    cdq
    sub     eax, edx
    xor     edi, edi
    mov     ebx, eax
    sar     ebx, 1
    add     ebx, esi
    lea     esi, [ebp+0B6h]
    test    esi, esi
    jnz     short loc_4A5592
    xor     eax, eax
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ebx, eax
    lea     edx, [eax+eax]
    mov     [ebp+17h], dx
    mov     dx, [esp+14h]
    mov     [ebp+13h], bx
    mov     [ebp+19h], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A5592:                             ; CODE XREF: .text:004A556Cj
    mov     eax, dword_51FBA4
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_4A55CC
    push    esi
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ebx, eax
    lea     edx, [eax+eax]
    mov     [ebp+17h], dx
    mov     dx, [esp+14h]
    mov     [ebp+13h], bx
    mov     [ebp+19h], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A55CC:                             ; CODE XREF: .text:004A559Cj
    cmp     byte ptr [esi], 0
    jz      short loc_4A5606

    loc_4A55D1:                             ; CODE XREF: .text:004A5604j
    mov     cl, [esi]
    mov     eax, dword_51FBA4
    mov     [esp+18h], cl
    mov     edx, [esp+18h]
    mov     ecx, [eax+14h]
    and     edx, 0FFh
    push    edx
    mov     edx, [ecx+0Ch]
    push    edx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A55FE
    xor     ecx, ecx
    mov     cx, [eax]
    add     edi, ecx

    loc_4A55FE:                             ; CODE XREF: .text:004A55F5j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A55D1

    loc_4A5606:                             ; CODE XREF: .text:004A55CFj
    mov     eax, edi
    cdq
    sub     eax, edx
    sar     eax, 1
    sub     ebx, eax
    lea     edx, [eax+eax]
    mov     [ebp+17h], dx
    mov     dx, [esp+14h]
    mov     [ebp+13h], bx
    mov     [ebp+19h], dx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A562A:                             ; CODE XREF: .text:004A554Fj
    test    al, 1
    jz      short loc_4A5698
    lea     esi, [ebp+0B6h]
    xor     edi, edi
    test    esi, esi
    jnz     short loc_4A563E
    xor     eax, eax
    jmp     short loc_4A5694
    ; ---------------------------------------------------------------------------

    loc_4A563E:                             ; CODE XREF: .text:004A5638j
    mov     eax, dword_51FBA4
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_4A5658
    push    esi
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    jmp     short loc_4A5694
    ; ---------------------------------------------------------------------------

    loc_4A5658:                             ; CODE XREF: .text:004A5648j
    cmp     byte ptr [esi], 0
    jz      short loc_4A5692

    loc_4A565D:                             ; CODE XREF: .text:004A5690j
    mov     cl, [esi]
    mov     eax, dword_51FBA4
    mov     [esp+18h], cl
    mov     edx, [esp+18h]
    mov     ecx, [eax+14h]
    and     edx, 0FFh
    push    edx
    mov     edx, [ecx+0Ch]
    push    edx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A568A
    xor     ecx, ecx
    mov     cx, [eax]
    add     edi, ecx

    loc_4A568A:                             ; CODE XREF: .text:004A5681j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A565D

    loc_4A5692:                             ; CODE XREF: .text:004A565Bj
    mov     eax, edi

    loc_4A5694:                             ; CODE XREF: .text:004A563Cj
                                            ; .text:004A5656j
    mov     [ebp+17h], ax

    loc_4A5698:                             ; CODE XREF: .text:004A562Cj
    mov     dx, [esp+14h]
    mov     [ebp+13h], bx
    pop     edi
    mov     [ebp+19h], dx
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A56B0 proc near                    ; CODE XREF: sub_4A81E0+117Dp

    var_AC= dword ptr -0ACh
    var_A8= byte ptr -0A8h
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= byte ptr -80h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0ACh
    mov     eax, [esp+0ACh+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+0Ch]
    mov     edx, [eax+18h]
    mov     [eax+14h], ecx
    mov     esi, [esp+0B8h+arg_4]
    mov     ebx, [edx+4]
    push    edi
    mov     edi, 1
    mov     [esp+0BCh+var_AC], 0
    movsx   eax, word ptr [ebx+0B6h]
    mov     dword ptr [esp+0BCh+var_A8], edi
    lea     ecx, [eax+1]
    cmp     ecx, edi
    jle     short loc_4A575C
    lea     edx, [ebx+15Bh]

    loc_4A56F9:                             ; CODE XREF: sub_4A56B0+7Fj
    cmp     byte ptr [edx], 7
    jnz     short loc_4A5726
    mov     eax, esi
    mov     ebp, ebx
    shl     eax, 3
    sub     eax, esi
    add     ebp, esi
    lea     eax, [eax+eax*2]
    lea     eax, [esi+eax*2]
    lea     eax, [esi+eax*4]
    movsx   eax, byte ptr [ebp+eax*2+28h]
    mov     ebp, [esp+0BCh+var_AC]
    cmp     ebp, eax
    jz      short loc_4A5737
    mov     eax, ebp
    inc     eax
    mov     [esp+0BCh+var_AC], eax

    loc_4A5726:                             ; CODE XREF: sub_4A56B0+4Cj
    inc     edi
    add     edx, 15Bh
    cmp     edi, ecx
    jl      short loc_4A56F9
    mov     dword ptr [esp+0BCh+var_A8], edi
    jmp     short loc_4A575C
    ; ---------------------------------------------------------------------------

    loc_4A5737:                             ; CODE XREF: sub_4A56B0+6Dj
    mov     eax, edi
    mov     dword ptr [esp+0BCh+var_A8], edi
    shl     eax, 3
    sub     eax, edi
    lea     ecx, [eax+eax*2]
    lea     edx, [edi+ecx*2]
    mov     ecx, ebx
    add     ecx, edi
    lea     eax, [edi+edx*4]
    mov     edx, [ecx+eax*2+0D6h]
    push    edx
    call    sub_4C1420

    loc_4A575C:                             ; CODE XREF: sub_4A56B0+41j
                                            ; sub_4A56B0+85j
    movsx   eax, word ptr [ebx+0B6h]
    inc     eax
    or      ebp, 0FFFFFFFFh
    cmp     edi, eax
    jnz     short loc_4A577D
    mov     ecx, dword_51FBA4
    mov     edx, [ecx]
    push    edx
    call    sub_4C1420
    mov     dword ptr [esp+0BCh+var_A8], ebp

    loc_4A577D:                             ; CODE XREF: sub_4A56B0+B9j
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    lea     edx, [esi+ecx*4]
    lea     esi, [esi+edx*2]
    cmp     [ebx+esi+13h], bp
    jnz     short loc_4A5810
    lea     edi, [ebx+esi+0B6h]
    xor     ebp, ebp
    test    edi, edi
    jnz     short loc_4A57A8
    xor     ecx, ecx
    jmp     short loc_4A5800
    ; ---------------------------------------------------------------------------

    loc_4A57A8:                             ; CODE XREF: sub_4A56B0+F2j
    mov     eax, dword_51FBA4
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_4A57C4
    push    edi
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    mov     ecx, eax
    jmp     short loc_4A5800
    ; ---------------------------------------------------------------------------

    loc_4A57C4:                             ; CODE XREF: sub_4A56B0+102j
    cmp     byte ptr [edi], 0
    jz      short loc_4A57FE

    loc_4A57C9:                             ; CODE XREF: sub_4A56B0+14Cj
    mov     cl, [edi]
    mov     eax, dword_51FBA4
    mov     byte ptr [esp+0BCh+var_AC], cl
    mov     edx, [esp+0BCh+var_AC]
    mov     ecx, [eax+14h]
    and     edx, 0FFh
    push    edx
    mov     edx, [ecx+0Ch]
    push    edx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A57F6
    xor     ecx, ecx
    mov     cx, [eax]
    add     ebp, ecx

    loc_4A57F6:                             ; CODE XREF: sub_4A56B0+13Dj
    mov     al, [edi+1]
    inc     edi
    test    al, al
    jnz     short loc_4A57C9

    loc_4A57FE:                             ; CODE XREF: sub_4A56B0+117j
    mov     ecx, ebp

    loc_4A5800:                             ; CODE XREF: sub_4A56B0+F6j
                                            ; sub_4A56B0+112j
    movsx   eax, word ptr [ebx+17h]
    sub     eax, ecx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebx+esi+13h], ax

    loc_4A5810:                             ; CODE XREF: sub_4A56B0+E5j
    cmp     byte ptr [ebx+esi], 0
    jnz     short loc_4A5820
    xor     ecx, ecx
    xor     eax, eax
    mov     [esp+0BCh+var_A0], ecx
    jmp     short loc_4A582E
    ; ---------------------------------------------------------------------------

    loc_4A5820:                             ; CODE XREF: sub_4A56B0+164j
    movsx   ecx, word ptr [ebx+esi+13h]
    mov     [esp+0BCh+var_A0], ecx
    movsx   eax, word ptr [ebx+esi+15h]

    loc_4A582E:                             ; CODE XREF: sub_4A56B0+16Ej
    mov     [esp+0BCh+var_9C], eax
    movsx   edx, word ptr [ebx+esi+17h]
    lea     edx, [edx+ecx-1]
    mov     [esp+0BCh+var_98], edx
    movsx   edx, word ptr [ebx+esi+19h]
    lea     eax, [edx+eax-1]
    mov     [esp+0BCh+var_94], eax
    mov     eax, [ebx+esi+23h]
    test    eax, eax
    jz      short loc_4A587A
    mov     edx, [esp+0BCh+arg_0]
    xor     ecx, ecx
    mov     cl, [edx+eax+8B2h]
    lea     eax, [esp+0BCh+var_A0]
    push    ecx
    mov     ecx, [ebx+0BCh]
    push    eax
    push    ecx
    call    sub_4BF6F0
    mov     ecx, [esp+0BCh+var_A0]

    loc_4A587A:                             ; CODE XREF: sub_4A56B0+1A2j
    mov     eax, [ebx+esi+1Bh]
    mov     ebp, ecx
    test    al, 4
    jz      loc_4A590C
    movsx   ebp, word ptr [ebx+esi+17h]
    lea     edi, [ebx+esi+0B6h]
    xor     eax, eax
    add     ebp, ecx
    cmp     edi, eax
    mov     [esp+0BCh+var_AC], eax
    jz      short loc_4A5905
    mov     edx, dword_51FBA4
    cmp     [edx+14h], eax
    jnz     short loc_4A58BE
    push    edi
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    sub     ebp, eax
    jmp     loc_4A599B
    ; ---------------------------------------------------------------------------

    loc_4A58BE:                             ; CODE XREF: sub_4A56B0+1F9j
    cmp     byte ptr [edi], 0
    jz      short loc_4A5901

    loc_4A58C3:                             ; CODE XREF: sub_4A56B0+24Fj
    mov     al, [edi]
    mov     edx, dword_51FBA4
    mov     byte ptr [esp+0BCh+var_A4], al
    mov     ecx, [esp+0BCh+var_A4]
    mov     eax, [edx+14h]
    and     ecx, 0FFh
    push    ecx
    mov     ecx, [eax+0Ch]
    push    ecx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A58F9
    xor     edx, edx
    mov     dx, [eax]
    mov     eax, [esp+0BCh+var_AC]
    add     eax, edx
    mov     [esp+0BCh+var_AC], eax

    loc_4A58F9:                             ; CODE XREF: sub_4A56B0+238j
    mov     al, [edi+1]
    inc     edi
    test    al, al
    jnz     short loc_4A58C3

    loc_4A5901:                             ; CODE XREF: sub_4A56B0+211j
    mov     eax, [esp+0BCh+var_AC]

    loc_4A5905:                             ; CODE XREF: sub_4A56B0+1EEj
    sub     ebp, eax
    jmp     loc_4A599B
    ; ---------------------------------------------------------------------------

    loc_4A590C:                             ; CODE XREF: sub_4A56B0+1D2j
    test    al, 2
    jz      loc_4A599B
    movsx   eax, word ptr [ebx+esi+17h]
    cdq
    sub     eax, edx
    lea     edi, [ebx+esi+0B6h]
    mov     ebp, eax
    xor     eax, eax
    sar     ebp, 1
    add     ebp, ecx
    cmp     edi, eax
    mov     [esp+0BCh+var_AC], eax
    jz      short loc_4A5992
    mov     ecx, dword_51FBA4
    cmp     [ecx+14h], eax
    jnz     short loc_4A594C
    push    edi
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    jmp     short loc_4A5992
    ; ---------------------------------------------------------------------------

    loc_4A594C:                             ; CODE XREF: sub_4A56B0+28Cj
    cmp     byte ptr [edi], 0
    jz      short loc_4A598E

    loc_4A5951:                             ; CODE XREF: sub_4A56B0+2DCj
    mov     dl, [edi]
    mov     ecx, dword_51FBA4
    mov     byte ptr [esp+0BCh+var_A4], dl
    mov     eax, [esp+0BCh+var_A4]
    mov     edx, [ecx+14h]
    and     eax, 0FFh
    push    eax
    mov     eax, [edx+0Ch]
    push    eax
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A5986
    xor     ecx, ecx
    mov     cx, [eax]
    mov     eax, [esp+0BCh+var_AC]
    add     eax, ecx
    mov     [esp+0BCh+var_AC], eax

    loc_4A5986:                             ; CODE XREF: sub_4A56B0+2C5j
    mov     al, [edi+1]
    inc     edi
    test    al, al
    jnz     short loc_4A5951

    loc_4A598E:                             ; CODE XREF: sub_4A56B0+29Fj
    mov     eax, [esp+0BCh+var_AC]

    loc_4A5992:                             ; CODE XREF: sub_4A56B0+281j
                                            ; sub_4A56B0+29Aj
    cdq
    sub     eax, edx
    sar     eax, 1
    neg     eax
    add     ebp, eax

    loc_4A599B:                             ; CODE XREF: sub_4A56B0+209j
                                            ; sub_4A56B0+257j ...
    mov     edi, dword ptr [esp+0BCh+var_A8]
    cmp     edi, 0FFFFFFFFh
    jz      short loc_4A59E8
    test    byte ptr [ebx+esi+1Bh], 8
    jz      short loc_4A59E8
    call    sub_4C13F0
    push    eax
    mov     eax, [esp+0C0h+arg_0]
    xor     edx, edx
    mov     dl, [eax+8B2h]
    push    edx
    call    sub_4C13A0
    push    0FFFFFFFFh
    lea     edx, [ebp+1]
    mov     ecx, [esp+0C0h+var_9C]
    lea     eax, [ebx+esi+0B6h]
    add     ecx, 3
    push    ecx
    mov     ecx, [ebx+0BCh]
    push    edx
    push    eax
    push    ecx
    call    PrintGUIText

    loc_4A59E8:                             ; CODE XREF: sub_4A56B0+2F2j
                                            ; sub_4A56B0+2F9j
    call    sub_4C13F0
    mov     edx, [ebx+esi+1Fh]
    push    eax
    push    edx
    call    sub_4C13A0
    cmp     edi, 0FFFFFFFFh
    jnz     loc_4A5A82
    mov     eax, dword_51FBA4
    mov     eax, [eax+14h]
    test    eax, eax
    jnz     short loc_4A5A14
    call    sub_4C1450
    jmp     short loc_4A5A2A
    ; ---------------------------------------------------------------------------

    loc_4A5A14:                             ; CODE XREF: sub_4A56B0+35Bj
    mov     ecx, [eax+0Ch]
    push    49h
    push    ecx
    call    sub_4B7F30
    xor     edx, edx
    mov     dx, [eax+2]
    mov     eax, edx
    add     eax, 2

    loc_4A5A2A:                             ; CODE XREF: sub_4A56B0+362j
    mov     ecx, [esp+0BCh+var_94]
    mov     edx, [esp+0BCh+var_9C]
    sub     ecx, edx
    add     eax, eax
    cmp     ecx, eax
    mov     eax, [ebx+esi+1Fh]
    lea     edi, [ebx+esi+0B6h]
    push    eax
    jle     short loc_4A5A65
    mov     eax, [esp+0C0h+var_A0]
    inc     ecx
    push    ecx
    mov     ecx, [esp+0C4h+var_98]
    sub     ecx, eax
    inc     ecx
    push    ecx
    push    edx
    mov     edx, [ebx+0BCh]
    push    ebp
    push    edi
    push    edx
    call    sub_4A51D0
    jmp     short loc_4A5A9E
    ; ---------------------------------------------------------------------------

    loc_4A5A65:                             ; CODE XREF: sub_4A56B0+394j
    mov     ecx, [esp+0C0h+var_98]
    mov     eax, [esp+0C0h+var_A0]
    sub     ecx, eax
    inc     ecx
    push    ecx
    push    edx
    mov     edx, [ebx+0BCh]
    push    ebp
    push    edi
    push    edx
    call    sub_4A50E0
    jmp     short loc_4A5A9E
    ; ---------------------------------------------------------------------------

    loc_4A5A82:                             ; CODE XREF: sub_4A56B0+34Bj
    mov     eax, [esp+0BCh+var_9C]
    mov     ecx, [ebx+0BCh]
    push    0FFFFFFFFh
    lea     edi, [ebx+esi+0B6h]
    push    eax
    push    ebp
    push    edi
    push    ecx
    call    PrintGUIText

    loc_4A5A9E:                             ; CODE XREF: sub_4A56B0+3B3j
                                            ; sub_4A56B0+3D0j
    test    byte ptr [ebx+esi+148h], 1
    jz      loc_4A5B2C
    mov     ebx, [esp+0BCh+arg_0]
    mov     edx, [ebx+18h]
    mov     edi, [edx+4]
    cmp     byte ptr [edi+esi], 0
    jnz     short loc_4A5AC9
    xor     eax, eax
    xor     ecx, ecx
    mov     [esp+0BCh+var_90], eax
    jmp     short loc_4A5AD7
    ; ---------------------------------------------------------------------------

    loc_4A5AC9:                             ; CODE XREF: sub_4A56B0+40Dj
    movsx   eax, word ptr [edi+esi+13h]
    mov     [esp+0BCh+var_90], eax
    movsx   ecx, word ptr [edi+esi+15h]

    loc_4A5AD7:                             ; CODE XREF: sub_4A56B0+417j
    mov     [esp+0BCh+var_8C], ecx
    movsx   edx, word ptr [edi+esi+17h]
    lea     eax, [edx+eax-1]
    mov     [esp+0BCh+var_88], eax
    movsx   edx, word ptr [edi+esi+19h]
    lea     eax, [edx+ecx-1]
    lea     ecx, [esp+0BCh+var_90]
    mov     [esp+0BCh+var_84], eax
    mov     edx, [edi+0BCh]
    push    ecx
    push    edx
    call    sub_4BFE10
    mov     ecx, [edi+0BCh]
    lea     eax, [esp+0BCh+var_90]
    push    0FFFFFFECh
    push    eax
    push    ecx
    call    sub_4BF4D0
    mov     ecx, [ebx+8]
    mov     [ebx+14h], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0ACh
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A5B2C:                             ; CODE XREF: sub_4A56B0+3F6j
    mov     bl, [ebx+esi+147h]
    test    bl, bl
    jz      loc_4A5D14
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+0BCh+var_80]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+0BCh+var_80]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     [esp+0BCh+var_A8], bl
    and     ecx, 3
    mov     byte ptr [esp+15h], 0
    rep movsb
    lea     ecx, [esp+0BCh+var_A8]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jz      loc_4A5D14
    mov     ecx, [esp+0BCh+var_9C]
    lea     edx, [esp+0BCh+var_80]
    xor     edi, edi
    mov     byte ptr [eax], 0
    mov     ebx, [esp+0BCh+var_A0]
    mov     [esp+0BCh+var_AC], ecx
    test    edx, edx
    jnz     short loc_4A5B9C
    xor     eax, eax
    jmp     short loc_4A5BFD
    ; ---------------------------------------------------------------------------

    loc_4A5B9C:                             ; CODE XREF: sub_4A56B0+4E6j
    mov     eax, dword_51FBA4
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_4A5BBA
    lea     ecx, [esp+0BCh+var_80]
    push    ecx
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    jmp     short loc_4A5BFD
    ; ---------------------------------------------------------------------------

    loc_4A5BBA:                             ; CODE XREF: sub_4A56B0+4F6j
    mov     al, [esp+0BCh+var_80]
    lea     esi, [esp+0BCh+var_80]
    test    al, al
    jz      short loc_4A5BFB

    loc_4A5BC6:                             ; CODE XREF: sub_4A56B0+549j
    mov     dl, [esi]
    mov     ecx, dword_51FBA4
    mov     byte ptr [esp+0BCh+var_A4], dl
    mov     eax, [esp+0BCh+var_A4]
    mov     edx, [ecx+14h]
    and     eax, 0FFh
    push    eax
    mov     eax, [edx+0Ch]
    push    eax
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A5BF3
    xor     ecx, ecx
    mov     cx, [eax]
    add     edi, ecx

    loc_4A5BF3:                             ; CODE XREF: sub_4A56B0+53Aj
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A5BC6

    loc_4A5BFB:                             ; CODE XREF: sub_4A56B0+514j
    mov     eax, edi

    loc_4A5BFD:                             ; CODE XREF: sub_4A56B0+4EAj
                                            ; sub_4A56B0+508j
    lea     edx, [esp+0BCh+var_A8]
    add     ebx, eax
    xor     edi, edi
    mov     ebp, ebx
    test    edx, edx
    jnz     short loc_4A5C0F
    xor     eax, eax
    jmp     short loc_4A5C70
    ; ---------------------------------------------------------------------------

    loc_4A5C0F:                             ; CODE XREF: sub_4A56B0+559j
    mov     eax, dword_51FBA4
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_4A5C2D
    lea     ecx, [esp+0BCh+var_A8]
    push    ecx
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    jmp     short loc_4A5C70
    ; ---------------------------------------------------------------------------

    loc_4A5C2D:                             ; CODE XREF: sub_4A56B0+569j
    mov     al, [esp+0BCh+var_A8]
    lea     esi, [esp+0BCh+var_A8]
    test    al, al
    jz      short loc_4A5C6E

    loc_4A5C39:                             ; CODE XREF: sub_4A56B0+5BCj
    mov     dl, [esi]
    mov     ecx, dword_51FBA4
    mov     byte ptr [esp+0BCh+var_A4], dl
    mov     eax, [esp+0BCh+var_A4]
    mov     edx, [ecx+14h]
    and     eax, 0FFh
    push    eax
    mov     eax, [edx+0Ch]
    push    eax
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A5C66
    xor     ecx, ecx
    mov     cx, [eax]
    add     edi, ecx

    loc_4A5C66:                             ; CODE XREF: sub_4A56B0+5ADj
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A5C39

    loc_4A5C6E:                             ; CODE XREF: sub_4A56B0+587j
    mov     eax, edi

    loc_4A5C70:                             ; CODE XREF: sub_4A56B0+55Dj
                                            ; sub_4A56B0+57Bj
    mov     edx, dword_51FBA4
    add     ebx, eax
    mov     [esp+0BCh+var_A4], ebx
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A5C8C
    call    sub_4C1450
    mov     esi, eax
    jmp     short loc_4A5CA0
    ; ---------------------------------------------------------------------------

    loc_4A5C8C:                             ; CODE XREF: sub_4A56B0+5D1j
    mov     eax, [eax+0Ch]
    push    49h
    push    eax
    call    sub_4B7F30
    xor     esi, esi
    mov     si, [eax+2]
    add     esi, 2

    loc_4A5CA0:                             ; CODE XREF: sub_4A56B0+5DAj
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A5CB4
    call    sub_4C1450
    jmp     short loc_4A5CCA
    ; ---------------------------------------------------------------------------

    loc_4A5CB4:                             ; CODE XREF: sub_4A56B0+5FBj
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A5CCA:                             ; CODE XREF: sub_4A56B0+602j
    mov     ebx, [esp+0BCh+arg_0]
    mov     ecx, [esp+0BCh+var_AC]
    xor     edx, edx
    mov     dl, [ebx+8B4h]
    lea     eax, [eax+ecx-1]
    push    edx
    lea     edx, [esi+ecx-1]
    mov     ecx, [ebx+18h]
    push    edx
    mov     edx, [esp+0C4h+var_A4]
    dec     edx
    push    edx
    mov     edx, [ecx+4]
    push    eax
    push    ebp
    mov     eax, [edx+0BCh]
    push    eax
    call    sub_4BE950
    mov     ecx, [ebx+8]
    mov     [ebx+14h], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0ACh
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A5D14:                             ; CODE XREF: sub_4A56B0+485j
                                            ; sub_4A56B0+4C9j
    mov     ebx, [esp+0BCh+arg_0]
    pop     edi
    pop     esi
    pop     ebp
    mov     ecx, [ebx+8]
    mov     [ebx+14h], ecx
    pop     ebx
    add     esp, 0ACh
    retn    8
    sub_4A56B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A5D30 proc near                    ; CODE XREF: .text:0044AE43p
                                            ; .text:0044AF33p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    mov     edx, [eax+ecx*4+8]
    mov     [eax+14h], edx
    retn    8
    sub_4A5D30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A5D50 proc near                    ; CODE XREF: .text:0044534Dp
                                            ; sub_4455B0+179p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+14h+arg_0]
    xor     ebx, ebx
    push    ebx                             ; int
    mov     eax, [edi+18h]
    mov     edx, [eax+4]
    mov     eax, [esp+18h+arg_4]
    mov     ecx, eax
    add     edx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     esi, [edx+ecx*2]
    mov     [esp+18h+var_4], esi
    lea     edx, [esi+2]
    push    edx                             ; char *
    push    edi                             ; int
    call    sub_4A0D00
    mov     ebp, eax
    cmp     ebp, ebx
    jnz     short loc_4A5D99
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A5D99:                             ; CODE XREF: sub_4A5D50+3Dj
    mov     al, [esi]
    cmp     al, 5
    jz      short loc_4A5DAB
    cmp     al, 1
    jnz     short loc_4A5DB1
    mov     eax, [esi+1Bh]
    test    ah, 80h
    jz      short loc_4A5DB1

    loc_4A5DAB:                             ; CODE XREF: sub_4A5D50+4Dj
    mov     eax, [edi+0Ch]
    mov     [edi+14h], eax

    loc_4A5DB1:                             ; CODE XREF: sub_4A5D50+51j
                                            ; sub_4A5D50+59j ...
    mov     ecx, dword_51FBA4
    xor     edi, edi
    cmp     [ecx+14h], ebx
    jnz     short loc_4A5DCC
    push    ebp
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    jmp     short loc_4A5E10
    ; ---------------------------------------------------------------------------

    loc_4A5DCC:                             ; CODE XREF: sub_4A5D50+6Cj
    mov     al, [ebp+0]
    mov     esi, ebp
    cmp     al, bl
    jz      short loc_4A5E0A

    loc_4A5DD5:                             ; CODE XREF: sub_4A5D50+B8j
    mov     dl, [esi]
    mov     ecx, dword_51FBA4
    mov     byte ptr [esp+14h+arg_4], dl
    mov     eax, [esp+14h+arg_4]
    mov     edx, [ecx+14h]
    and     eax, 0FFh
    push    eax
    mov     eax, [edx+0Ch]
    push    eax
    call    sub_4B7F30
    cmp     eax, ebx
    jz      short loc_4A5E02
    xor     ecx, ecx
    mov     cx, [eax]
    add     edi, ecx

    loc_4A5E02:                             ; CODE XREF: sub_4A5D50+A9j
    mov     al, [esi+1]
    inc     esi
    cmp     al, bl
    jnz     short loc_4A5DD5

    loc_4A5E0A:                             ; CODE XREF: sub_4A5D50+83j
    mov     esi, [esp+14h+var_4]
    mov     eax, edi

    loc_4A5E10:                             ; CODE XREF: sub_4A5D50+7Aj
    movsx   edx, word ptr [esi+17h]
    sub     edx, 6
    cmp     eax, edx
    jle     short loc_4A5E3C
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4A5DB1
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     [ecx+ebp-1], bl
    jmp     loc_4A5DB1
    ; ---------------------------------------------------------------------------

    loc_4A5E3C:                             ; CODE XREF: sub_4A5D50+C9j
    mov     ecx, [esp+14h+arg_0]
    pop     edi
    pop     esi
    pop     ebp
    mov     edx, [ecx+8]
    pop     ebx
    mov     [ecx+14h], edx
    pop     ecx
    retn    8
    sub_4A5D50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A5E50 proc near                    ; CODE XREF: sub_4A81E0+FBBp
                                            ; sub_4A9FD0+55Cp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    sub     esp, 10h
    mov     ecx, [eax+18h]
    push    ebp
    push    esi
    push    edi
    test    ecx, ecx
    jz      short loc_4A5E68
    mov     dword ptr [ecx+14h], 1

    loc_4A5E68:                             ; CODE XREF: sub_4A5E50+Fj
    mov     eax, [eax+18h]
    mov     edi, [eax+4]
    mov     eax, [esp+1Ch+arg_4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, edi
    add     edx, eax
    mov     eax, [edx+ecx*2+0B8h]
    test    eax, eax
    lea     esi, [edx+ecx*2]
    jz      loc_4A5F2B
    cmp     byte ptr [esi], 0
    jnz     short loc_4A5EA7
    xor     ecx, ecx
    xor     edx, edx
    mov     [esp+1Ch+var_10], ecx
    jmp     short loc_4A5EB3
    ; ---------------------------------------------------------------------------

    loc_4A5EA7:                             ; CODE XREF: sub_4A5E50+4Bj
    movsx   ecx, word ptr [esi+13h]
    mov     [esp+1Ch+var_10], ecx
    movsx   edx, word ptr [esi+15h]

    loc_4A5EB3:                             ; CODE XREF: sub_4A5E50+55j
    mov     [esp+1Ch+var_C], edx
    movsx   ebp, word ptr [esi+17h]
    lea     ebp, [ebp+ecx-1]
    mov     [esp+1Ch+var_8], ebp
    movsx   ebp, word ptr [esi+19h]
    lea     ebp, [ebp+edx-1]
    mov     [esp+1Ch+var_4], ebp
    mov     ebp, [esi+1Fh]
    test    ebp, ebp
    jle     short loc_4A5EF4
    push    ebp
    movsx   ebp, word ptr [eax+6]
    add     ebp, edx
    movsx   edx, word ptr [eax+4]
    add     edx, ecx
    push    ebp
    push    edx
    push    eax
    mov     eax, [edi+0BCh]
    push    eax
    call    sub_4B8310
    jmp     short loc_4A5F0F
    ; ---------------------------------------------------------------------------

    loc_4A5EF4:                             ; CODE XREF: sub_4A5E50+84j
    movsx   ebp, word ptr [eax+6]
    add     ebp, edx
    movsx   edx, word ptr [eax+4]
    add     edx, ecx
    push    ebp
    push    edx
    push    eax
    mov     eax, [edi+0BCh]
    push    eax
    call    sub_4B7F90

    loc_4A5F0F:                             ; CODE XREF: sub_4A5E50+A2j
    test    byte ptr [esi+0BCh], 1
    jz      short loc_4A5F2B
    mov     edx, [edi+0BCh]
    lea     ecx, [esp+1Ch+var_10]
    push    0FFFFFFE4h
    push    ecx
    push    edx
    call    sub_4BF4D0

    loc_4A5F2B:                             ; CODE XREF: sub_4A5E50+42j
                                            ; sub_4A5E50+C6j
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 10h
    retn    8
    sub_4A5E50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A5F40 proc near                    ; CODE XREF: sub_447150+14Fp
                                            ; sub_447B10+419p ...

    var_D8= byte ptr -0D8h
    var_D4= dword ptr -0D4h
    var_D0= dword ptr -0D0h
    var_CC= dword ptr -0CCh
    var_C8= dword ptr -0C8h
    var_C4= dword ptr -0C4h
    var_C0= dword ptr -0C0h
    var_BC= dword ptr -0BCh
    var_B8= dword ptr -0B8h
    var_B4= dword ptr -0B4h
    var_B0= dword ptr -0B0h
    var_AC= dword ptr -0ACh
    var_A8= dword ptr -0A8h
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= byte ptr -80h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0D8h
    push    ebx
    push    ebp
    mov     ebp, [esp+0E0h+arg_0]
    xor     edx, edx
    push    esi
    push    edi
    mov     eax, [ebp+18h]
    mov     [esp+0E8h+var_A8], edx
    cmp     eax, edx
    jz      short loc_4A5F65
    mov     dword ptr [eax+14h], 1

    loc_4A5F65:                             ; CODE XREF: sub_4A5F40+1Cj
    mov     eax, [ebp+18h]
    mov     ecx, [esp+0E8h+arg_4]
    mov     ebx, [eax+4]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     esi, ebx
    add     esi, ecx
    lea     eax, [eax+eax*2]
    lea     eax, [ecx+eax*2]
    lea     eax, [ecx+eax*4]
    lea     edi, [esi+eax*2]
    mov     [esp+0E8h+var_CC], edi
    cmp     byte ptr [edi], 0
    jnz     short loc_4A5F9C
    xor     eax, eax
    xor     ecx, ecx
    mov     [esp+0E8h+var_C4], eax
    jmp     short loc_4A5FA8
    ; ---------------------------------------------------------------------------

    loc_4A5F9C:                             ; CODE XREF: sub_4A5F40+50j
    movsx   eax, word ptr [edi+13h]
    mov     [esp+0E8h+var_C4], eax
    movsx   ecx, word ptr [edi+15h]

    loc_4A5FA8:                             ; CODE XREF: sub_4A5F40+5Aj
    mov     [esp+0E8h+var_C0], ecx
    movsx   esi, word ptr [edi+17h]
    lea     eax, [esi+eax-1]
    mov     [esp+0E8h+var_BC], eax
    movsx   eax, word ptr [edi+19h]
    lea     ecx, [eax+ecx-1]
    mov     [esp+0E8h+var_B8], ecx
    mov     eax, [edi+1Bh]
    test    ah, 80h
    jz      short loc_4A5FD2
    mov     eax, [ebp+0Ch]
    mov     [ebp+14h], eax

    loc_4A5FD2:                             ; CODE XREF: sub_4A5F40+8Aj
    movsx   eax, word ptr [ebx+0B6h]
    mov     esi, 1
    mov     [esp+0E8h+var_D0], edx
    lea     ecx, [eax+1]
    cmp     ecx, esi
    jle     short loc_4A602F
    lea     eax, [ebx+15Bh]

    loc_4A5FEF:                             ; CODE XREF: sub_4A5F40+CAj
    cmp     byte ptr [eax], 7
    jnz     short loc_4A6002
    movsx   edx, byte ptr [edi+28h]
    cmp     [esp+0E8h+var_D0], edx
    jz      short loc_4A600E
    inc     [esp+0E8h+var_D0]

    loc_4A6002:                             ; CODE XREF: sub_4A5F40+B2j
    inc     esi
    add     eax, 15Bh
    cmp     esi, ecx
    jl      short loc_4A5FEF
    jmp     short loc_4A602F
    ; ---------------------------------------------------------------------------

    loc_4A600E:                             ; CODE XREF: sub_4A5F40+BCj
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, ebx
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A602F:                             ; CODE XREF: sub_4A5F40+A7j
                                            ; sub_4A5F40+CCj
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     esi, edx
    jnz     short loc_4A6048
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A6048:                             ; CODE XREF: sub_4A5F40+F9j
    mov     edx, [esp+0E8h+arg_4]
    push    edx
    push    ebp
    call    sub_4A5D50
    mov     ebx, [ebx+0BCh]
    xor     esi, esi
    mov     [esp+0E8h+var_A0], eax
    mov     eax, [edi+2Fh]
    cmp     eax, esi
    mov     [esp+0E8h+var_D4], ebx
    jz      loc_4A61C8
    test    byte ptr [edi+13Ch], 1
    jz      loc_4A6110
    mov     ecx, [edi+1Bh]
    test    ch, 1
    jz      short loc_4A6092
    xor     ecx, ecx
    mov     cx, [eax]
    dec     ecx
    push    ecx
    jmp     loc_4A616C
    ; ---------------------------------------------------------------------------

    loc_4A6092:                             ; CODE XREF: sub_4A5F40+144j
    mov     dl, [edi+136h]
    test    dl, dl
    jz      short loc_4A60B8
    xor     edx, edx
    mov     dl, [edi+137h]
    push    edx
    push    eax
    call    sub_4B7F30
    mov     [esp+0E8h+var_A8], 1
    jmp     loc_4A6172
    ; ---------------------------------------------------------------------------

    loc_4A60B8:                             ; CODE XREF: sub_4A5F40+15Aj
    test    ch, 18h
    jz      short loc_4A60D9
    xor     ecx, ecx
    mov     cl, [edi+13Bh]
    push    ecx
    push    eax
    call    sub_4B7F30
    mov     [esp+0E8h+var_A8], 1
    jmp     loc_4A6172
    ; ---------------------------------------------------------------------------

    loc_4A60D9:                             ; CODE XREF: sub_4A5F40+17Bj
    movsx   edx, word ptr [edi+138h]
    xor     ecx, ecx
    add     edx, 2
    mov     cx, [eax]
    dec     ecx
    cmp     edx, ecx
    jge     short loc_4A60EF
    mov     ecx, edx

    loc_4A60EF:                             ; CODE XREF: sub_4A5F40+1ABj
    xor     edx, edx
    mov     dl, [edi+13Bh]
    add     edx, ecx
    push    edx
    push    eax
    call    sub_4B7F30
    test    byte ptr [edi+1Bh], 80h
    jnz     short loc_4A6172
    mov     [esp+0E8h+var_A8], 1
    jmp     short loc_4A6172
    ; ---------------------------------------------------------------------------

    loc_4A6110:                             ; CODE XREF: sub_4A5F40+138j
    mov     si, [edi+138h]
    test    si, si
    jz      short loc_4A614E
    mov     dl, [edi+136h]
    mov     cx, [eax]
    movzx   bp, dl
    cmp     cx, bp
    jbe     short loc_4A614E
    test    dl, dl
    jz      short loc_4A613E
    and     ecx, 0FFFFh
    sub     ecx, 2
    push    ecx
    jmp     short loc_4A616C
    ; ---------------------------------------------------------------------------

    loc_4A613E:                             ; CODE XREF: sub_4A5F40+1F0j
    xor     ecx, ecx
    mov     cl, [edi+13Bh]
    movsx   edx, si
    add     ecx, edx
    push    ecx
    jmp     short loc_4A616C
    ; ---------------------------------------------------------------------------

    loc_4A614E:                             ; CODE XREF: sub_4A5F40+1DAj
                                            ; sub_4A5F40+1ECj
    mov     cl, [edi+136h]
    test    cl, cl
    jz      short loc_4A6163
    xor     ecx, ecx
    mov     cl, [edi+137h]
    push    ecx
    jmp     short loc_4A616C
    ; ---------------------------------------------------------------------------

    loc_4A6163:                             ; CODE XREF: sub_4A5F40+216j
    xor     edx, edx
    mov     dl, [edi+13Bh]
    push    edx

    loc_4A616C:                             ; CODE XREF: sub_4A5F40+14Dj
                                            ; sub_4A5F40+1FCj ...
    push    eax
    call    sub_4B7F30

    loc_4A6172:                             ; CODE XREF: sub_4A5F40+173j
                                            ; sub_4A5F40+194j ...
    xor     esi, esi
    cmp     eax, esi
    jz      loc_4A6248
    mov     ecx, [edi+1Fh]
    cmp     ecx, esi
    jz      short loc_4A61A6
    mov     ebp, [esp+0E8h+var_C0]
    push    ecx
    movsx   ecx, word ptr [eax+6]
    movsx   edx, word ptr [eax+4]
    add     ecx, ebp
    push    ecx
    mov     ecx, [esp+0F0h+var_C4]
    add     edx, ecx
    push    edx
    push    eax
    push    ebx
    call    sub_4B8310
    jmp     loc_4A6248
    ; ---------------------------------------------------------------------------

    loc_4A61A6:                             ; CODE XREF: sub_4A5F40+241j
    movsx   ecx, word ptr [eax+6]
    mov     ebp, [esp+0E8h+var_C0]
    movsx   edx, word ptr [eax+4]
    add     ecx, ebp
    push    ecx
    mov     ecx, [esp+0ECh+var_C4]
    add     edx, ecx
    push    edx
    push    eax
    push    ebx
    call    sub_4B7F90
    jmp     loc_4A6248
    ; ---------------------------------------------------------------------------

    loc_4A61C8:                             ; CODE XREF: sub_4A5F40+12Bj
    test    byte ptr [edi+13Ch], 1
    jz      short loc_4A61F1
    xor     eax, eax
    lea     ecx, [esp+0E8h+var_C4]
    mov     al, [ebp+8C5h]
    push    eax
    push    eax
    xor     eax, eax
    mov     al, [ebp+8B2h]
    push    eax
    push    ecx
    push    ebx
    call    sub_4B04B0
    jmp     short loc_4A6248
    ; ---------------------------------------------------------------------------

    loc_4A61F1:                             ; CODE XREF: sub_4A5F40+28Fj
    cmp     [edi+138h], si
    jz      short loc_4A6222
    xor     edx, edx
    xor     eax, eax
    mov     dl, [ebp+8C6h]
    mov     al, [ebp+8C3h]
    xor     ecx, ecx
    push    edx
    mov     cl, [ebp+8B2h]
    push    eax
    lea     edx, [esp+0F0h+var_C4]
    push    ecx
    push    edx
    push    ebx
    call    sub_4B04B0
    jmp     short loc_4A6248
    ; ---------------------------------------------------------------------------

    loc_4A6222:                             ; CODE XREF: sub_4A5F40+2B8j
    xor     eax, eax
    xor     ecx, ecx
    mov     al, [ebp+8C6h]
    mov     cl, [ebp+8C3h]
    xor     edx, edx
    push    eax
    mov     dl, [ebp+8B2h]
    push    ecx
    lea     eax, [esp+0F0h+var_C4]
    push    edx
    push    eax
    push    ebx
    call    sub_4B04E0

    loc_4A6248:                             ; CODE XREF: sub_4A5F40+236j
                                            ; sub_4A5F40+261j ...
    cmp     [edi+138h], si
    mov     [esp+0E8h+var_D0], esi
    mov     [esp+0E8h+var_A4], esi
    jz      short loc_4A6266
    mov     eax, 1
    mov     [esp+0E8h+var_D0], eax
    mov     [esp+0E8h+var_A4], eax

    loc_4A6266:                             ; CODE XREF: sub_4A5F40+317j
    lea     ecx, [edi+0B6h]
    mov     [esp+0E8h+var_98], esi
    mov     [esp+0E8h+var_9C], ecx

    loc_4A6274:                             ; CODE XREF: sub_4A5F40+A48j
    cmp     word ptr [edi+138h], 0
    jz      short loc_4A6296
    call    sub_4C13F0
    mov     esi, [esp+0E8h+arg_0]
    xor     edx, edx
    push    eax
    mov     dl, [esi+8B2h]
    push    edx
    jmp     short loc_4A62B0
    ; ---------------------------------------------------------------------------

    loc_4A6296:                             ; CODE XREF: sub_4A5F40+33Cj
    call    sub_4C13F0
    mov     esi, [esp+0E8h+arg_0]
    push    eax
    mov     eax, [edi+1Fh]
    xor     ecx, ecx
    mov     cl, [eax+esi+8B2h]
    push    ecx

    loc_4A62B0:                             ; CODE XREF: sub_4A5F40+354j
    call    sub_4C13A0
    mov     al, [edi+136h]
    mov     ebp, [esp+0E8h+var_9C]
    test    al, al
    jz      short loc_4A62E1
    xor     eax, eax
    mov     al, [edi+137h]
    test    eax, eax
    jz      short loc_4A62E1

    loc_4A62CF:                             ; CODE XREF: sub_4A5F40+39Fj
    cmp     byte ptr [ebp+0], 0
    jz      short loc_4A62DD

    loc_4A62D5:                             ; CODE XREF: sub_4A5F40+39Bj
    mov     cl, [ebp+1]
    inc     ebp
    test    cl, cl
    jnz     short loc_4A62D5

    loc_4A62DD:                             ; CODE XREF: sub_4A5F40+393j
    inc     ebp
    dec     eax
    jnz     short loc_4A62CF

    loc_4A62E1:                             ; CODE XREF: sub_4A5F40+381j
                                            ; sub_4A5F40+38Dj
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A62F7
    call    sub_4C1450
    mov     ecx, eax
    jmp     short loc_4A630B
    ; ---------------------------------------------------------------------------

    loc_4A62F7:                             ; CODE XREF: sub_4A5F40+3ACj
    mov     eax, [eax+0Ch]
    push    49h
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    add     ecx, 2

    loc_4A630B:                             ; CODE XREF: sub_4A5F40+3B5j
    mov     eax, [esp+0E8h+var_B8]
    sub     eax, ecx
    mov     ecx, [esp+0E8h+var_C0]
    sub     eax, ecx
    cdq
    sub     eax, edx
    mov     ebx, eax
    mov     eax, [esp+0E8h+var_A4]
    sar     ebx, 1
    add     ebx, eax
    mov     eax, [edi+1Bh]
    add     ebx, ecx
    test    ah, 80h
    jz      short loc_4A6334
    mov     ecx, [esi+0Ch]
    mov     [esi+14h], ecx

    loc_4A6334:                             ; CODE XREF: sub_4A5F40+3ECj
    mov     eax, [edi+1Bh]
    test    al, 1
    jz      short loc_4A6358
    mov     edx, [esp+0E8h+var_BC]
    mov     eax, [esp+0E8h+var_C4]
    mov     ecx, [esp+0E8h+var_D0]
    sub     edx, eax
    inc     edx
    push    0
    push    edx
    lea     edx, [ecx+eax+3]
    push    ebx
    push    edx
    jmp     loc_4A6970
    ; ---------------------------------------------------------------------------

    loc_4A6358:                             ; CODE XREF: sub_4A5F40+3F9j
    test    al, 4
    jz      short loc_4A6388
    mov     ecx, [esp+0E8h+var_BC]
    mov     esi, [esp+0E8h+var_A0]
    mov     edx, [esp+0E8h+var_C4]
    mov     eax, ecx
    sub     eax, esi
    sub     eax, 3
    cmp     eax, edx
    jge     short loc_4A6375
    mov     eax, edx

    loc_4A6375:                             ; CODE XREF: sub_4A5F40+431j
    sub     ecx, edx
    push    0
    inc     ecx
    push    ecx
    mov     ecx, [esp+0F0h+var_D4]
    push    ebx
    push    eax
    push    ebp
    push    ecx
    jmp     loc_4A6976
    ; ---------------------------------------------------------------------------

    loc_4A6388:                             ; CODE XREF: sub_4A5F40+41Aj
    test    al, 2
    jz      loc_4A6758
    mov     ecx, [esp+0E8h+var_BC]
    mov     esi, [esp+0E8h+var_A0]
    mov     eax, ecx
    sub     eax, esi
    mov     esi, [esp+0E8h+var_C4]
    sub     eax, esi
    cdq
    sub     eax, edx
    mov     edx, [esp+0E8h+var_D0]
    sar     eax, 1
    add     eax, edx
    lea     edx, [eax+esi+1]
    mov     al, [edi+13Ah]
    test    al, al
    mov     [esp+0E8h+var_B4], edx
    jz      loc_4A674B
    test    byte ptr [edi+13Ch], 1
    jnz     loc_4A674B
    sub     ecx, esi
    mov     [esp+0E8h+var_D8], al
    inc     ecx
    mov     edi, ebp
    mov     [esp+0E8h+var_AC], ecx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0E8h+var_80]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     byte ptr [esp+11h], 0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+0E8h+var_80]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+0E8h+var_D8]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strstr
    add     esp, 8
    mov     [esp+0E8h+var_B0], eax
    test    eax, eax
    jz      loc_4A672A
    call    sub_4C1440
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0E8h+var_80]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, [esp+0ECh+var_AC]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+0ECh+var_B4]
    and     ecx, 3
    push    edx
    mov     edx, [esp+0F0h+var_D4]
    push    ebx
    rep movsb
    mov     ecx, [esp+0F4h+var_B0]
    push    eax
    mov     byte ptr [ecx], 0
    lea     ecx, [esp+0F8h+var_80]
    push    ecx
    push    edx
    call    sub_4A50E0
    lea     eax, [esp+0E8h+var_80]
    xor     edi, edi
    test    eax, eax
    jz      short loc_4A64D9
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A6495
    lea     edx, [esp+0E8h+var_80]
    push    edx
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    jmp     short loc_4A64D9
    ; ---------------------------------------------------------------------------

    loc_4A6495:                             ; CODE XREF: sub_4A5F40+541j
    mov     al, [esp+0E8h+var_80]
    lea     esi, [esp+0E8h+var_80]
    test    al, al
    jz      short loc_4A64D7

    loc_4A64A1:                             ; CODE XREF: sub_4A5F40+595j
    mov     al, [esi]
    mov     edx, dword_51FBA4
    mov     byte ptr [esp+0E8h+var_88], al
    mov     ecx, [esp+0E8h+var_88]
    mov     eax, [edx+14h]
    and     ecx, 0FFh
    push    ecx
    mov     ecx, [eax+0Ch]
    push    ecx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A64CF
    xor     edx, edx
    mov     dx, [eax]
    add     edi, edx

    loc_4A64CF:                             ; CODE XREF: sub_4A5F40+586j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A64A1

    loc_4A64D7:                             ; CODE XREF: sub_4A5F40+55Fj
    mov     eax, edi

    loc_4A64D9:                             ; CODE XREF: sub_4A5F40+534j
                                            ; sub_4A5F40+553j
    mov     esi, [esp+0E8h+var_B4]
    mov     edi, [esp+0E8h+var_CC]
    add     esi, eax
    cmp     word ptr [edi+138h], 0
    mov     [esp+0E8h+var_B4], esi
    mov     [esp+0E8h+var_94], esi
    jz      short loc_4A650C
    call    sub_4C13F0
    mov     ecx, [esp+0E8h+arg_0]
    push    eax
    xor     eax, eax
    mov     al, [ecx+8B2h]
    jmp     short loc_4A6525
    ; ---------------------------------------------------------------------------

    loc_4A650C:                             ; CODE XREF: sub_4A5F40+5B3j
    call    sub_4C13F0
    mov     edx, [edi+1Fh]
    mov     ecx, [esp+0E8h+arg_0]
    push    eax
    xor     eax, eax
    mov     al, [edx+ecx+8B2h]

    loc_4A6525:                             ; CODE XREF: sub_4A5F40+5CAj
    push    eax
    call    sub_4C13A0
    push    0
    lea     eax, [esp+0ECh+var_D8]
    mov     edx, [esp+0ECh+var_AC]
    mov     ebp, [esp+0ECh+var_D4]
    push    edx
    push    ebx
    push    esi
    push    eax
    push    ebp
    call    sub_4A50E0
    lea     ecx, [esp+0E8h+var_D8]
    xor     eax, eax
    test    ecx, ecx
    mov     [esp+0E8h+var_C8], eax
    jz      short loc_4A65C7
    mov     edx, dword_51FBA4
    cmp     [edx+14h], eax
    jnz     short loc_4A656E
    lea     eax, [esp+0E8h+var_D8]
    push    eax
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    jmp     short loc_4A65C7
    ; ---------------------------------------------------------------------------

    loc_4A656E:                             ; CODE XREF: sub_4A5F40+61Aj
    mov     al, [esp+0E8h+var_D8]
    lea     esi, [esp+0E8h+var_D8]
    test    al, al
    jz      short loc_4A65B7

    loc_4A657A:                             ; CODE XREF: sub_4A5F40+675j
    mov     cl, [esi]
    mov     eax, dword_51FBA4
    mov     byte ptr [esp+0E8h+var_90], cl
    mov     edx, [esp+0E8h+var_90]
    mov     ecx, [eax+14h]
    and     edx, 0FFh
    push    edx
    mov     edx, [ecx+0Ch]
    push    edx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A65AF
    xor     ecx, ecx
    mov     cx, [eax]
    mov     eax, [esp+0E8h+var_C8]
    add     eax, ecx
    mov     [esp+0E8h+var_C8], eax

    loc_4A65AF:                             ; CODE XREF: sub_4A5F40+65Ej
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4A657A

    loc_4A65B7:                             ; CODE XREF: sub_4A5F40+638j
    mov     eax, [esp+0E8h+var_C8]
    mov     ebp, [esp+0E8h+var_D4]
    mov     esi, [esp+0E8h+var_B4]
    mov     edi, [esp+0E8h+var_CC]

    loc_4A65C7:                             ; CODE XREF: sub_4A5F40+60Fj
                                            ; sub_4A5F40+62Cj
    add     esi, eax
    cmp     word ptr [edi+138h], 0
    jz      short loc_4A664C
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A65E9
    call    sub_4C1450
    mov     edi, eax
    jmp     short loc_4A65FD
    ; ---------------------------------------------------------------------------

    loc_4A65E9:                             ; CODE XREF: sub_4A5F40+69Ej
    mov     eax, [eax+0Ch]
    push    49h
    push    eax
    call    sub_4B7F30
    xor     edi, edi
    mov     di, [eax+2]
    add     edi, 2

    loc_4A65FD:                             ; CODE XREF: sub_4A5F40+6A7j
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A6611
    call    sub_4C1450
    jmp     short loc_4A6627
    ; ---------------------------------------------------------------------------

    loc_4A6611:                             ; CODE XREF: sub_4A5F40+6C8j
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A6627:                             ; CODE XREF: sub_4A5F40+6CFj
    mov     ecx, [esp+0E8h+arg_0]
    xor     edx, edx
    mov     dl, [ecx+8B2h]
    lea     ecx, [esi-1]
    push    edx
    lea     edx, [edi+ebx-1]
    push    edx
    lea     edx, [eax+ebx-1]
    mov     eax, [esp+0F0h+var_94]
    push    ecx
    push    edx
    push    eax
    jmp     short loc_4A66C2
    ; ---------------------------------------------------------------------------

    loc_4A664C:                             ; CODE XREF: sub_4A5F40+691j
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A6662
    call    sub_4C1450
    mov     edi, eax
    jmp     short loc_4A6676
    ; ---------------------------------------------------------------------------

    loc_4A6662:                             ; CODE XREF: sub_4A5F40+717j
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     edi, edi
    mov     di, [eax+2]
    add     edi, 2

    loc_4A6676:                             ; CODE XREF: sub_4A5F40+720j
    mov     eax, dword_51FBA4
    mov     eax, [eax+14h]
    test    eax, eax
    jnz     short loc_4A6689
    call    sub_4C1450
    jmp     short loc_4A669F
    ; ---------------------------------------------------------------------------

    loc_4A6689:                             ; CODE XREF: sub_4A5F40+740j
    mov     ecx, [eax+0Ch]
    push    49h
    push    ecx
    call    sub_4B7F30
    xor     edx, edx
    mov     dx, [eax+2]
    mov     eax, edx
    add     eax, 2

    loc_4A669F:                             ; CODE XREF: sub_4A5F40+747j
    mov     edx, [esp+0E8h+arg_0]
    xor     ecx, ecx
    lea     eax, [eax+ebx-1]
    mov     cl, [edx+8B4h]
    lea     edx, [esi-1]
    push    ecx
    lea     ecx, [edi+ebx-1]
    push    ecx
    mov     ecx, [esp+0F0h+var_94]
    push    edx
    push    eax
    push    ecx

    loc_4A66C2:                             ; CODE XREF: sub_4A5F40+70Aj
    push    ebp
    call    sub_4BE950
    mov     edi, [esp+0E8h+var_CC]
    cmp     word ptr [edi+138h], 0
    jz      short loc_4A66ED
    call    sub_4C13F0
    push    eax
    mov     eax, [esp+0ECh+arg_0]
    xor     edx, edx
    mov     dl, [eax+8B2h]
    jmp     short loc_4A6706
    ; ---------------------------------------------------------------------------

    loc_4A66ED:                             ; CODE XREF: sub_4A5F40+794j
    call    sub_4C13F0
    mov     ecx, [edi+1Fh]
    push    eax
    mov     eax, [esp+0ECh+arg_0]
    xor     edx, edx
    mov     dl, [ecx+eax+8B2h]

    loc_4A6706:                             ; CODE XREF: sub_4A5F40+7ABj
    push    edx
    call    sub_4C13A0
    push    0
    mov     ecx, [esp+0ECh+var_AC]
    mov     edx, [esp+0ECh+var_B0]
    push    ecx
    push    ebx
    inc     edx
    push    esi
    push    edx
    push    ebp
    call    sub_4A50E0
    mov     edi, [esp+0E8h+var_CC]
    jmp     loc_4A697B
    ; ---------------------------------------------------------------------------

    loc_4A672A:                             ; CODE XREF: sub_4A5F40+4DBj
    mov     eax, [esp+0E8h+var_AC]
    mov     ecx, [esp+0E8h+var_B4]
    mov     edx, [esp+0E8h+var_D4]
    push    0
    push    eax
    push    ebx
    push    ecx
    push    ebp
    push    edx
    call    sub_4A50E0
    mov     edi, [esp+0E8h+var_CC]
    jmp     loc_4A697B
    ; ---------------------------------------------------------------------------

    loc_4A674B:                             ; CODE XREF: sub_4A5F40+47Dj
                                            ; sub_4A5F40+48Aj
    sub     ecx, esi
    push    0
    inc     ecx
    push    ecx
    push    ebx
    push    edx
    jmp     loc_4A6970
    ; ---------------------------------------------------------------------------

    loc_4A6758:                             ; CODE XREF: sub_4A5F40+44Aj
    test    al, 20h
    jz      loc_4A697B
    mov     eax, [esp+0E8h+var_BC]
    mov     esi, [esp+0E8h+var_A0]
    mov     ecx, [esp+0E8h+var_C4]
    sub     eax, esi
    sub     eax, ecx
    cdq
    sub     eax, edx
    mov     edx, [esp+0E8h+var_D0]
    sar     eax, 1
    add     eax, edx
    lea     ebx, [eax+ecx+1]
    mov     ecx, dword_51FBA4
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4A6793
    call    sub_4C1450
    jmp     short loc_4A67A9
    ; ---------------------------------------------------------------------------

    loc_4A6793:                             ; CODE XREF: sub_4A5F40+84Aj
    mov     edx, [eax+0Ch]
    push    49h
    push    edx
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A67A9:                             ; CODE XREF: sub_4A5F40+851j
    mov     edx, [esp+0E8h+var_A4]
    sub     edx, eax
    mov     eax, [esp+0E8h+var_B8]
    lea     esi, [edx+eax-4]
    mov     al, [edi+13Ah]
    test    al, al
    mov     [esp+0E8h+var_C8], esi
    jz      loc_4A6960
    movsx   ecx, al
    push    ecx                             ; int
    push    ebp                             ; char *
    call    _strchr
    add     esp, 8
    mov     [esp+0E8h+var_B0], eax
    test    eax, eax
    jz      loc_4A6960
    mov     esi, [esp+0E8h+var_BC]
    mov     eax, [esp+0E8h+var_C4]
    mov     dl, [edi+13Ah]
    sub     esi, eax
    inc     esi
    mov     [esp+12h], dl
    mov     byte ptr [esp+13h], 0
    call    sub_4C1440
    mov     ecx, [esp+0E8h+var_C8]
    mov     eax, [esp+0E8h+var_B0]
    mov     edx, [esp+0E8h+var_D4]
    push    0
    push    esi
    push    ecx
    push    ebx
    push    ebp
    push    edx
    mov     byte ptr [eax], 0
    call    sub_4A50E0
    xor     ebp, ebp
    mov     eax, [esp+0E8h+var_9C]
    test    eax, eax
    jz      short loc_4A6884
    mov     ecx, dword_51FBA4
    mov     edx, [ecx+14h]
    test    edx, edx
    jnz     short loc_4A6841
    push    eax
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    jmp     short loc_4A6884
    ; ---------------------------------------------------------------------------

    loc_4A6841:                             ; CODE XREF: sub_4A5F40+8F1j
    mov     cl, [eax]
    mov     edi, eax
    test    cl, cl
    jz      short loc_4A687E

    loc_4A6849:                             ; CODE XREF: sub_4A5F40+93Cj
    mov     dl, [edi]
    mov     ecx, dword_51FBA4
    mov     byte ptr [esp+0E8h+var_84], dl
    mov     eax, [esp+0E8h+var_84]
    mov     edx, [ecx+14h]
    and     eax, 0FFh
    push    eax
    mov     eax, [edx+0Ch]
    push    eax
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A6876
    xor     ecx, ecx
    mov     cx, [eax]
    add     ebp, ecx

    loc_4A6876:                             ; CODE XREF: sub_4A5F40+92Dj
    mov     al, [edi+1]
    inc     edi
    test    al, al
    jnz     short loc_4A6849

    loc_4A687E:                             ; CODE XREF: sub_4A5F40+907j
    mov     edi, [esp+0E8h+var_CC]
    mov     eax, ebp

    loc_4A6884:                             ; CODE XREF: sub_4A5F40+8E4j
                                            ; sub_4A5F40+8FFj
    add     ebx, eax
    call    sub_4C13F0
    push    eax
    mov     eax, [esp+0ECh+arg_0]
    xor     edx, edx
    mov     dl, [eax+8BCh]
    push    edx
    call    sub_4C13A0
    push    0
    push    esi
    mov     ecx, [esp+0F0h+var_C8]
    mov     eax, [esp+0F0h+var_D4]
    push    ecx
    lea     edx, [esp+1Eh]
    push    ebx
    push    edx
    push    eax
    call    sub_4A50E0
    lea     ecx, [esp+12h]
    xor     ebp, ebp
    test    ecx, ecx
    jz      short loc_4A6929
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A68E4
    lea     eax, [esp+12h]
    push    eax
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    mov     ebp, eax
    jmp     short loc_4A6929
    ; ---------------------------------------------------------------------------

    loc_4A68E4:                             ; CODE XREF: sub_4A5F40+98Ej
    mov     al, [esp+12h]
    lea     edi, [esp+12h]
    test    al, al
    jz      short loc_4A6925

    loc_4A68F0:                             ; CODE XREF: sub_4A5F40+9E3j
    mov     cl, [edi]
    mov     eax, dword_51FBA4
    mov     byte ptr [esp+0E8h+var_8C], cl
    mov     edx, [esp+0E8h+var_8C]
    mov     ecx, [eax+14h]
    and     edx, 0FFh
    push    edx
    mov     edx, [ecx+0Ch]
    push    edx
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A691D
    xor     ecx, ecx
    mov     cx, [eax]
    add     ebp, ecx

    loc_4A691D:                             ; CODE XREF: sub_4A5F40+9D4j
    mov     al, [edi+1]
    inc     edi
    test    al, al
    jnz     short loc_4A68F0

    loc_4A6925:                             ; CODE XREF: sub_4A5F40+9AEj
    mov     edi, [esp+0E8h+var_CC]

    loc_4A6929:                             ; CODE XREF: sub_4A5F40+981j
                                            ; sub_4A5F40+9A2j
    call    sub_4C13F0
    mov     edx, [edi+1Fh]
    mov     ecx, [esp+0E8h+arg_0]
    push    eax
    xor     eax, eax
    mov     al, [edx+ecx+8B2h]
    push    eax
    call    sub_4C13A0
    push    0
    push    esi
    mov     edx, [esp+0F0h+var_C8]
    mov     eax, [esp+0F0h+var_B0]
    mov     ecx, [esp+0F0h+var_D4]
    add     ebp, ebx
    push    edx
    inc     eax
    push    ebp
    push    eax
    push    ecx
    jmp     short loc_4A6976
    ; ---------------------------------------------------------------------------

    loc_4A6960:                             ; CODE XREF: sub_4A5F40+883j
                                            ; sub_4A5F40+89Cj
    mov     edx, [esp+0E8h+var_BC]
    mov     ecx, [esp+0E8h+var_C4]
    sub     edx, ecx
    push    0
    inc     edx
    push    edx
    push    esi
    push    ebx

    loc_4A6970:                             ; CODE XREF: sub_4A5F40+413j
                                            ; sub_4A5F40+813j
    mov     eax, [esp+0F8h+var_D4]
    push    ebp
    push    eax

    loc_4A6976:                             ; CODE XREF: sub_4A5F40+443j
                                            ; sub_4A5F40+A1Ej
    call    sub_4A50E0

    loc_4A697B:                             ; CODE XREF: sub_4A5F40+7E5j
                                            ; sub_4A5F40+806j ...
    mov     eax, [esp+0E8h+var_98]
    mov     ecx, eax
    dec     eax
    test    ecx, ecx
    mov     [esp+0E8h+var_98], eax
    jnz     loc_4A6274
    mov     eax, [esp+0E8h+arg_0]
    mov     edx, [eax+8]
    mov     [eax+14h], edx
    mov     eax, [esp+0E8h+var_A8]
    test    eax, eax
    jz      short loc_4A69BF
    mov     esi, [esp+0E8h+var_D4]
    lea     eax, [esp+0E8h+var_C4]
    push    eax
    push    esi
    call    sub_4BFE10
    lea     ecx, [esp+0E8h+var_C4]
    push    0FFFFFFECh
    push    ecx
    push    esi
    call    sub_4BF4D0

    loc_4A69BF:                             ; CODE XREF: sub_4A5F40+A61j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D8h
    retn    8
    sub_4A5F40 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch]
    push    esi
    push    edi
    mov     edi, 1
    mov     eax, [ebp+18h]
    mov     ebx, [eax+4]
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    lea     esi, [ebx+15Bh]
    cmp     ecx, edi
    jle     short loc_4A6A31

    loc_4A69F5:                             ; CODE XREF: .text:004A6A2Fj
    cmp     byte ptr [esi], 1
    jnz     short loc_4A6A1E
    cmp     word ptr [esi+138h], 0
    jz      short loc_4A6A1E
    push    edi
    push    ebp
    mov     word ptr [esi+138h], 0
    call    sub_4A5F40
    mov     dword ptr [ebp+0CCAh], 1

    loc_4A6A1E:                             ; CODE XREF: .text:004A69F8j
                                            ; .text:004A6A02j
    movsx   edx, word ptr [ebx+0B6h]
    inc     edi
    add     esi, 15Bh
    inc     edx
    cmp     edi, edx
    jl      short loc_4A69F5

    loc_4A6A31:                             ; CODE XREF: .text:004A69F3j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A6A40 proc near                    ; CODE XREF: sub_495860+4Dp
                                            ; .text:0049591Fp ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    push    edi
    mov     edi, 1
    mov     eax, [ebp+18h]
    mov     ebx, [eax+4]
    mov     eax, [esp+8+arg_4]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     esi, [ebx+15Bh]
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    mov     al, [edx+ecx*2+1]
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    mov     byte ptr [esp+8+arg_0], al
    cmp     ecx, edi
    jle     short loc_4A6ACC

    loc_4A6A85:                             ; CODE XREF: sub_4A6A40+8Aj
    cmp     byte ptr [esi], 1
    jnz     short loc_4A6AB9
    mov     dl, byte ptr [esp+8+arg_0]
    mov     al, [esi+1]
    cmp     al, dl
    jnz     short loc_4A6AB9
    cmp     word ptr [esi+138h], 0
    jz      short loc_4A6AB9
    push    edi
    push    ebp
    mov     word ptr [esi+138h], 0
    call    sub_4A5F40
    mov     dword ptr [ebp+0CCAh], 1

    loc_4A6AB9:                             ; CODE XREF: sub_4A6A40+48j
                                            ; sub_4A6A40+53j ...
    movsx   eax, word ptr [ebx+0B6h]
    inc     edi
    add     esi, 15Bh
    inc     eax
    cmp     edi, eax
    jl      short loc_4A6A85

    loc_4A6ACC:                             ; CODE XREF: sub_4A6A40+43j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A6A40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A6AE0 proc near                    ; CODE XREF: sub_4A9FD0+27Cp

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 28h
    mov     ecx, [esp+28h+arg_4]
    push    ebx
    mov     ebx, [esp+2Ch+arg_0]
    push    ebp
    push    esi
    push    edi
    mov     eax, [ebx+18h]
    mov     edx, [eax+4]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    mov     esi, edx
    add     esi, ecx
    mov     [esp+38h+arg_0], edx
    lea     eax, [eax+eax*2]
    lea     eax, [ecx+eax*2]
    lea     eax, [ecx+eax*4]
    lea     ebp, [esi+eax*2]
    mov     al, [esi+eax*2+13Ch]
    test    al, 1
    jnz     loc_4A717B
    cmp     byte ptr [ebp+0], 0
    jnz     short loc_4A6B2F
    xor     eax, eax
    xor     ecx, ecx
    mov     [esp+38h+var_28], eax
    jmp     short loc_4A6B3B
    ; ---------------------------------------------------------------------------

    loc_4A6B2F:                             ; CODE XREF: sub_4A6AE0+43j
    movsx   eax, word ptr [ebp+13h]
    movsx   ecx, word ptr [ebp+15h]
    mov     [esp+38h+var_28], eax

    loc_4A6B3B:                             ; CODE XREF: sub_4A6AE0+4Dj
    movsx   esi, word ptr [ebp+17h]
    mov     [esp+38h+var_24], ecx
    lea     edi, [esp+38h+var_18]
    lea     esi, [esi+eax-1]
    mov     [esp+38h+var_20], esi
    movsx   esi, word ptr [ebp+19h]
    lea     ecx, [esi+ecx-1]
    lea     esi, [ebx+3Ch]
    mov     [esp+38h+var_1C], ecx
    mov     ecx, 6
    rep movsd
    movsx   ecx, word ptr [edx+13h]
    movsx   edx, word ptr [edx+15h]
    mov     esi, [esp+38h+var_18]
    mov     edi, [esp+38h+var_14]
    sub     esi, ecx
    sub     edi, edx
    cmp     esi, eax
    mov     [esp+38h+var_14], edi
    jl      short loc_4A6BFE
    cmp     esi, [esp+38h+var_20]
    jg      short loc_4A6BFE
    mov     ecx, [esp+38h+var_24]
    mov     eax, edi
    cmp     eax, ecx
    jl      short loc_4A6BFE
    cmp     eax, [esp+38h+var_1C]
    jg      short loc_4A6BFE
    mov     edi, [esp+38h+arg_4]
    push    1
    push    ebx
    mov     [ebx+68h], edi
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A6BCF
    push    edi
    push    ebx
    mov     dword ptr [ebx+64h], 0FFFFFFFFh
    call    sub_49FC50
    push    1
    push    ebx
    call    sub_4AB690
    movsx   eax, word ptr [ebp+138h]
    mov     [ebx+0CCEh], eax
    jmp     short loc_4A6BFE
    ; ---------------------------------------------------------------------------

    loc_4A6BCF:                             ; CODE XREF: sub_4A6AE0+C8j
    push    2
    push    ebx
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A6BFE
    push    edi
    push    ebx
    mov     dword ptr [ebx+64h], 0FFFFFFFFh
    call    sub_49FC50
    push    2
    push    ebx
    call    sub_4AB690
    movsx   ecx, word ptr [ebp+138h]
    mov     [ebx+0CCEh], ecx

    loc_4A6BFE:                             ; CODE XREF: sub_4A6AE0+9Fj
                                            ; sub_4A6AE0+A5j ...
    mov     eax, [ebx+64h]
    mov     edi, [esp+38h+arg_4]
    cmp     eax, edi
    jnz     loc_4A70A7
    mov     eax, [ebp+1Bh]
    test    al, 10h
    jz      short loc_4A6C77
    push    3
    push    ebx
    call    sub_4AB5B0
    test    eax, eax
    jz      loc_4A717B
    mov     eax, [esp+38h+var_28]
    mov     dword ptr [ebx+64h], 0FFFFFFFFh
    cmp     esi, eax
    jl      short loc_4A6C56
    cmp     esi, [esp+38h+var_20]
    jg      short loc_4A6C56
    mov     eax, [esp+38h+var_14]
    mov     ecx, [esp+38h+var_24]
    cmp     eax, ecx
    jl      short loc_4A6C56
    cmp     eax, [esp+38h+var_1C]
    jg      short loc_4A6C56
    mov     word ptr [ebp+138h], 1
    jmp     short loc_4A6CC6
    ; ---------------------------------------------------------------------------

    loc_4A6C56:                             ; CODE XREF: sub_4A6AE0+151j
                                            ; sub_4A6AE0+157j ...
    mov     dx, [ebx+0CCEh]
    push    edi
    push    ebx
    mov     [ebp+138h], dx
    call    sub_4A5F40
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A6C77:                             ; CODE XREF: sub_4A6AE0+132j
    test    al, 40h
    jz      loc_4A6D5F
    push    3
    push    ebx
    call    sub_4AB5B0
    test    eax, eax
    jnz     short loc_4A6D04
    mov     eax, [esp+38h+var_28]
    mov     dword ptr [ebx+64h], 0FFFFFFFFh
    cmp     esi, eax
    jl      short loc_4A6CE3
    cmp     esi, [esp+38h+var_20]
    jg      short loc_4A6CE3
    mov     eax, [esp+38h+var_14]
    mov     ecx, [esp+38h+var_24]
    cmp     eax, ecx
    jl      short loc_4A6CE3
    cmp     eax, [esp+38h+var_1C]
    jg      short loc_4A6CE3
    mov     ecx, [ebx+0CCEh]
    xor     eax, eax
    test    ecx, ecx
    setz    al
    mov     [ebp+138h], ax

    loc_4A6CC6:                             ; CODE XREF: sub_4A6AE0+174j
    push    edi
    push    ebx
    call    sub_4A0340
    push    edi
    push    ebx
    call    sub_4A5F40
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A6CE3:                             ; CODE XREF: sub_4A6AE0+1B8j
                                            ; sub_4A6AE0+1BEj ...
    mov     cx, [ebx+0CCEh]
    push    edi
    push    ebx
    mov     [ebp+138h], cx
    call    sub_4A5F40
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A6D04:                             ; CODE XREF: sub_4A6AE0+1A9j
    cmp     esi, [esp+38h+var_28]
    jl      short loc_4A6D4C
    cmp     esi, [esp+38h+var_20]
    jg      short loc_4A6D4C
    mov     eax, [esp+38h+var_14]
    mov     ecx, [esp+38h+var_24]
    cmp     eax, ecx
    jl      short loc_4A6D4C
    cmp     eax, [esp+38h+var_1C]
    jg      short loc_4A6D4C
    cmp     word ptr [ebp+138h], 0
    jnz     loc_4A717B
    push    edi
    push    ebx
    mov     word ptr [ebp+138h], 1
    call    sub_4A5F40
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A6D4C:                             ; CODE XREF: sub_4A6AE0+228j
                                            ; sub_4A6AE0+22Ej ...
    cmp     word ptr [ebp+138h], 0
    jz      loc_4A717B
    jmp     loc_4A708B
    ; ---------------------------------------------------------------------------

    loc_4A6D5F:                             ; CODE XREF: sub_4A6AE0+199j
    test    al, 8
    jz      short loc_4A6DC6
    push    3
    push    ebx
    call    sub_4AB5B0
    test    eax, eax
    jnz     loc_4A717B
    cmp     esi, [esp+38h+var_28]
    jl      loc_4A717B
    cmp     esi, [esp+38h+var_20]
    jg      loc_4A717B
    mov     eax, [esp+38h+var_14]
    mov     ecx, [esp+38h+var_24]
    cmp     eax, ecx
    jl      loc_4A717B
    cmp     eax, [esp+38h+var_1C]
    jg      loc_4A717B
    mov     ax, [ebp+138h]
    cmp     ax, 1
    jz      loc_4A6E32
    test    ax, ax
    jnz     loc_4A6E3B
    mov     word ptr [ebp+138h], 1
    jmp     short loc_4A6E3B
    ; ---------------------------------------------------------------------------

    loc_4A6DC6:                             ; CODE XREF: sub_4A6AE0+281j
    test    ah, 1
    jz      loc_4A6E5F
    push    1
    push    ebx
    call    sub_4AB510
    test    eax, eax
    jz      loc_4A717B
    cmp     esi, [esp+38h+var_28]
    jl      loc_4A717B
    cmp     esi, [esp+38h+var_20]
    jg      loc_4A717B
    mov     eax, [esp+38h+var_14]
    mov     ecx, [esp+38h+var_24]
    cmp     eax, ecx
    jl      loc_4A717B
    cmp     eax, [esp+38h+var_1C]
    jg      loc_4A717B
    mov     eax, [ebp+2Fh]
    test    eax, eax
    jz      short loc_4A6E3B
    mov     cx, [ebp+138h]
    xor     edx, edx
    mov     dx, [eax]
    movsx   eax, cx
    dec     edx
    cmp     eax, edx
    jge     short loc_4A6E32
    inc     ecx
    mov     [ebp+138h], cx
    jmp     short loc_4A6E3B
    ; ---------------------------------------------------------------------------

    loc_4A6E32:                             ; CODE XREF: sub_4A6AE0+2CCj
                                            ; sub_4A6AE0+346j
    mov     word ptr [ebp+138h], 0

    loc_4A6E3B:                             ; CODE XREF: sub_4A6AE0+2D5j
                                            ; sub_4A6AE0+2E4j ...
    push    edi
    push    ebx
    call    sub_4A0340
    push    edi
    push    ebx
    call    sub_4A5F40
    mov     dword ptr [ebx+64h], 0FFFFFFFFh
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A6E5F:                             ; CODE XREF: sub_4A6AE0+2E9j
    push    3
    push    ebx
    call    sub_4AB5B0
    test    eax, eax
    jnz     loc_4A6EF9
    push    edi
    mov     dword ptr [ebx+64h], 0FFFFFFFFh
    push    ebx
    mov     [ebp+138h], ax
    call    sub_4A0340
    cmp     esi, [esp+38h+var_28]
    jl      loc_4A7094
    cmp     esi, [esp+38h+var_20]
    jg      loc_4A7094
    mov     eax, [esp+38h+var_14]
    mov     ecx, [esp+38h+var_24]
    cmp     eax, ecx
    jl      loc_4A7094
    cmp     eax, [esp+38h+var_1C]
    jg      loc_4A7094
    mov     eax, [ebp+1Bh]
    test    ah, 18h
    jnz     loc_4A7094
    mov     al, [ebp+136h]
    test    al, al
    jz      short loc_4A6EE3
    mov     dl, [ebp+137h]
    inc     dl
    mov     cl, dl
    mov     [ebp+137h], dl
    cmp     cl, al
    jb      short loc_4A6EE3
    mov     byte ptr [ebp+137h], 0

    loc_4A6EE3:                             ; CODE XREF: sub_4A6AE0+3E6j
                                            ; sub_4A6AE0+3FAj
    push    edi
    push    ebx
    call    sub_4A5F40
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A6EF9:                             ; CODE XREF: sub_4A6AE0+389j
    mov     ax, [ebp+138h]
    test    ax, ax
    jz      short loc_4A6F4C
    mov     ecx, [ebp+1Bh]
    test    ch, 20h
    jz      short loc_4A6F43
    call    sub_4B6340
    cmp     dword_51FBB0, eax
    jz      loc_4A717B
    call    sub_4B6340
    mov     dword_51FBB0, eax
    mov     eax, dword_51FBAC
    test    eax, eax
    jle     short loc_4A6F8D
    dec     eax
    mov     dword_51FBAC, eax
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A6F43:                             ; CODE XREF: sub_4A6AE0+42Bj
    test    ax, ax
    jnz     loc_4A7069

    loc_4A6F4C:                             ; CODE XREF: sub_4A6AE0+423j
    cmp     esi, [esp+38h+var_28]
    jl      loc_4A7060
    cmp     esi, [esp+38h+var_20]
    jg      loc_4A7060
    mov     ecx, [esp+38h+var_14]
    mov     edx, [esp+38h+var_24]
    cmp     ecx, edx
    jl      loc_4A7060
    cmp     ecx, [esp+38h+var_1C]
    jg      loc_4A7060
    mov     word ptr [ebp+138h], 1
    mov     dword_51FBAC, 0Fh

    loc_4A6F8D:                             ; CODE XREF: sub_4A6AE0+44Fj
    push    edi
    push    ebx
    call    sub_4A5F40
    mov     edx, [ebp+1Bh]
    test    dh, 18h
    jz      loc_4A717B
    mov     edi, [esp+38h+arg_0]
    mov     cl, [ebp+1]
    mov     esi, 1
    movsx   eax, word ptr [edi+0B6h]
    lea     ebp, [eax+1]
    cmp     ebp, esi
    jle     short loc_4A6FD4
    lea     eax, [edi+15Bh]

    loc_4A6FC0:                             ; CODE XREF: sub_4A6AE0+4F2j
    cmp     byte ptr [eax], 4
    jnz     short loc_4A6FCA
    cmp     [eax+1], cl
    jz      short loc_4A6FD6

    loc_4A6FCA:                             ; CODE XREF: sub_4A6AE0+4E3j
    inc     esi
    add     eax, 15Bh
    cmp     esi, ebp
    jl      short loc_4A6FC0

    loc_4A6FD4:                             ; CODE XREF: sub_4A6AE0+4D8j
    xor     esi, esi

    loc_4A6FD6:                             ; CODE XREF: sub_4A6AE0+4E8j
    cmp     esi, 0FFFFFFFFh
    jz      loc_4A717B
    mov     eax, esi
    add     edi, esi
    shl     eax, 3
    sub     eax, esi
    test    dh, 10h
    lea     ecx, [eax+eax*2]
    lea     eax, [esi+ecx*2]
    lea     ecx, [esi+eax*4]
    mov     ax, [edi+ecx*2+140h]
    lea     edi, [edi+ecx*2]
    jz      short loc_4A7009
    test    ax, ax
    jle     short loc_4A7020
    dec     eax
    jmp     short loc_4A7019
    ; ---------------------------------------------------------------------------

    loc_4A7009:                             ; CODE XREF: sub_4A6AE0+51Fj
    movsx   edx, word ptr [edi+136h]
    movsx   ecx, ax
    dec     edx
    cmp     ecx, edx
    jge     short loc_4A7020
    inc     eax

    loc_4A7019:                             ; CODE XREF: sub_4A6AE0+527j
    mov     [edi+140h], ax

    loc_4A7020:                             ; CODE XREF: sub_4A6AE0+524j
                                            ; sub_4A6AE0+536j
    mov     eax, [ebx+18h]
    test    eax, eax
    jz      short loc_4A702E
    mov     dword ptr [eax+14h], 1

    loc_4A702E:                             ; CODE XREF: sub_4A6AE0+545j
    push    esi
    push    ebx
    call    sub_4A2580
    push    esi
    push    ebx
    call    sub_4A2BE0
    mov     eax, [edi+144h]
    test    eax, eax
    jz      loc_4A717B
    mov     edx, [edi+14Ah]
    push    edx
    push    ebx
    call    eax
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A7060:                             ; CODE XREF: sub_4A6AE0+470j
                                            ; sub_4A6AE0+47Aj ...
    test    ax, ax
    jz      loc_4A717B

    loc_4A7069:                             ; CODE XREF: sub_4A6AE0+466j
    cmp     esi, [esp+38h+var_28]
    jl      short loc_4A708B
    cmp     esi, [esp+38h+var_20]
    jg      short loc_4A708B
    mov     eax, [esp+38h+var_14]
    mov     ecx, [esp+38h+var_24]
    cmp     eax, ecx
    jl      short loc_4A708B
    cmp     eax, [esp+38h+var_1C]
    jle     loc_4A717B

    loc_4A708B:                             ; CODE XREF: sub_4A6AE0+27Aj
                                            ; sub_4A6AE0+58Dj ...
    mov     word ptr [ebp+138h], 0

    loc_4A7094:                             ; CODE XREF: sub_4A6AE0+3A8j
                                            ; sub_4A6AE0+3B2j ...
    push    edi
    push    ebx
    call    sub_4A5F40
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A70A7:                             ; CODE XREF: sub_4A6AE0+127j
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A70DC
    lea     ecx, ds:0[eax*8]
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, [esp+38h+arg_0]
    add     edx, eax
    cmp     byte ptr [edx+ecx*2], 3
    jnz     short loc_4A70DC
    push    0FBh
    call    sub_4C1B80
    test    eax, eax
    jz      loc_4A717B

    loc_4A70DC:                             ; CODE XREF: sub_4A6AE0+5CAj
                                            ; sub_4A6AE0+5E8j
    mov     eax, [ebx+0CC6h]
    mov     esi, 1
    cmp     eax, esi
    jnz     loc_4A717B
    mov     eax, [esp+38h+arg_8]
    test    eax, eax
    jz      loc_4A717B
    movsx   eax, byte ptr [ebp+13Ah]
    push    eax                             ; int
    call    _tolower
    mov     cl, byte ptr [esp+3Ch+arg_8]
    add     esp, 4
    cmp     al, cl
    jz      short loc_4A712B
    movsx   ecx, byte ptr [ebp+13Ah]
    push    ecx                             ; int
    call    _toupper
    mov     cl, byte ptr [esp+3Ch+arg_8]
    add     esp, 4
    cmp     al, cl
    jnz     short loc_4A717B

    loc_4A712B:                             ; CODE XREF: sub_4A6AE0+631j
    mov     eax, [ebp+1Bh]
    test    al, 40h
    jz      short loc_4A7147
    xor     edx, edx
    cmp     [ebp+138h], dx
    setz    dl
    mov     [ebp+138h], dx
    jmp     short loc_4A715C
    ; ---------------------------------------------------------------------------

    loc_4A7147:                             ; CODE XREF: sub_4A6AE0+650j
    test    al, 10h
    jz      short loc_4A7163
    cmp     word ptr [ebp+138h], 0
    jnz     short loc_4A7163
    mov     [ebp+138h], si

    loc_4A715C:                             ; CODE XREF: sub_4A6AE0+665j
    push    edi
    push    ebx
    call    sub_4A5F40

    loc_4A7163:                             ; CODE XREF: sub_4A6AE0+669j
                                            ; sub_4A6AE0+673j
    push    edi
    push    ebx
    call    sub_4A0340
    call    sub_4C1AB0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A717B:                             ; CODE XREF: sub_4A6AE0+39j
                                            ; sub_4A6AE0+13Ej ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 28h
    retn    0Ch
    sub_4A6AE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A7190 proc near                    ; CODE XREF: sub_440D70+184p
                                            ; sub_440D70+20Fp ...

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, [esp+4+arg_4]
    mov     eax, [esi+18h]
    mov     ebx, [eax+4]
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     ecx, [eax+eax*2]
    lea     edx, [edi+ecx*2]
    mov     ecx, ebx
    add     ecx, edi
    lea     eax, [edi+edx*4]
    lea     ebp, [ecx+eax*2]
    call    sub_4C13F0
    mov     edx, [ebp+1Fh]
    push    eax
    xor     eax, eax
    mov     al, [edx+esi+8B2h]
    push    eax
    call    sub_4C13A0
    movsx   eax, word ptr [ebx+0B6h]
    xor     ecx, ecx
    mov     esi, 1
    inc     eax
    cmp     eax, esi
    jle     short loc_4A7236
    lea     edx, [ebx+15Bh]
    mov     [esp+4+arg_4], edx

    loc_4A71EE:                             ; CODE XREF: sub_4A7190+81j
    mov     edx, [esp+4+arg_4]
    cmp     byte ptr [edx], 7
    jnz     short loc_4A7200
    movsx   edx, byte ptr [ebp+28h]
    cmp     ecx, edx
    jz      short loc_4A7215
    inc     ecx

    loc_4A7200:                             ; CODE XREF: sub_4A7190+65j
    mov     edx, [esp+4+arg_4]
    inc     esi
    add     edx, 15Bh
    cmp     esi, eax
    mov     [esp+4+arg_4], edx
    jl      short loc_4A71EE
    jmp     short loc_4A7236
    ; ---------------------------------------------------------------------------

    loc_4A7215:                             ; CODE XREF: sub_4A7190+6Dj
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, ebx
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A7236:                             ; CODE XREF: sub_4A7190+52j
                                            ; sub_4A7190+83j
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     esi, edx
    jnz     short loc_4A724F
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A724F:                             ; CODE XREF: sub_4A7190+B0j
    mov     esi, [esp+4+arg_0]
    push    edi
    push    esi
    call    sub_49FC50
    mov     edx, [esi+18h]
    push    0
    add     ebp, 0B6h
    mov     [edx+20h], edi
    movsx   eax, word ptr [ebp+82h]
    push    eax
    push    ebp
    push    edi
    push    esi
    call    sub_4AB6C0
    call    sub_4C1A40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A7190 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A7290 proc near                    ; CODE XREF: sub_4A9FD0+2D6p

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 2Ch
    push    ebx
    mov     ebx, [esp+30h+arg_0]
    push    ebp
    mov     ebp, [esp+34h+arg_4]
    mov     eax, [ebx+18h]
    push    esi
    push    edi
    mov     esi, [eax+4]
    mov     eax, ebp
    shl     eax, 3
    sub     eax, ebp
    mov     [esp+3Ch+var_2C], esi
    lea     ecx, [eax+eax*2]
    lea     edx, [ebp+ecx*2+0]
    lea     eax, [ebp+edx*4+0]
    lea     ebp, [ebp+eax*2+0]
    cmp     byte ptr [esi+ebp], 0
    jnz     short loc_4A72D1
    xor     eax, eax
    mov     [esp+3Ch+var_28], eax
    mov     [esp+3Ch+var_24], eax
    jmp     short loc_4A72E5
    ; ---------------------------------------------------------------------------

    loc_4A72D1:                             ; CODE XREF: sub_4A7290+33j
    movsx   ecx, word ptr [esi+ebp+13h]
    movsx   edx, word ptr [esi+ebp+15h]
    mov     [esp+3Ch+var_28], ecx
    mov     [esp+3Ch+var_24], edx
    xor     eax, eax

    loc_4A72E5:                             ; CODE XREF: sub_4A7290+3Fj
    movsx   ecx, word ptr [esi+ebp+17h]
    mov     edx, [esp+3Ch+var_28]
    mov     [esp+3Ch+arg_0], eax
    movsx   eax, word ptr [esi+0B6h]
    lea     ecx, [ecx+edx-1]
    mov     edi, 1
    movsx   edx, word ptr [esi+ebp+19h]
    mov     [esp+3Ch+var_20], ecx
    mov     ecx, [esp+3Ch+var_24]
    inc     eax
    lea     edx, [edx+ecx-1]
    cmp     eax, edi
    mov     [esp+3Ch+var_1C], edx
    jle     short loc_4A7364
    lea     ecx, [esi+15Bh]

    loc_4A7322:                             ; CODE XREF: sub_4A7290+AFj
    cmp     byte ptr [ecx], 7
    jnz     short loc_4A7336
    movsx   edx, byte ptr [esi+ebp+28h]
    cmp     [esp+3Ch+arg_0], edx
    jz      short loc_4A7343
    inc     [esp+3Ch+arg_0]

    loc_4A7336:                             ; CODE XREF: sub_4A7290+95j
    inc     edi
    add     ecx, 15Bh
    cmp     edi, eax
    jl      short loc_4A7322
    jmp     short loc_4A7364
    ; ---------------------------------------------------------------------------

    loc_4A7343:                             ; CODE XREF: sub_4A7290+A0j
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    mov     eax, esi
    add     eax, edi
    lea     edx, [edi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A7364:                             ; CODE XREF: sub_4A7290+8Aj
                                            ; sub_4A7290+B1j
    movsx   edx, word ptr [esi+0B6h]
    inc     edx
    cmp     edi, edx
    jnz     short loc_4A737D
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A737D:                             ; CODE XREF: sub_4A7290+DEj
    lea     esi, [ebx+3Ch]
    mov     ecx, 6
    lea     edi, [esp+3Ch+var_18]
    rep movsd
    mov     edi, [esp+3Ch+var_2C]
    mov     eax, [esp+3Ch+var_18]
    mov     ecx, [esp+3Ch+var_14]
    movsx   edx, word ptr [edi+13h]
    sub     eax, edx
    movsx   edx, word ptr [edi+15h]
    sub     ecx, edx
    mov     edx, [esp+3Ch+var_28]
    cmp     eax, edx
    jl      loc_4A74C4
    cmp     eax, [esp+3Ch+var_20]
    jg      loc_4A74C4
    cmp     ecx, [esp+3Ch+var_24]
    jl      loc_4A74C4
    cmp     ecx, [esp+3Ch+var_1C]
    jg      loc_4A74C4
    mov     esi, [esp+3Ch+arg_4]
    push    1
    push    ebx
    mov     [ebx+68h], esi
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A744C
    mov     eax, [ebx+18h]
    lea     ecx, [esp+3Ch+var_28]
    push    ecx
    push    esi
    mov     edi, [eax+4]
    push    edi
    call    sub_4A15C0
    call    sub_4C13F0
    mov     edx, [edi+ebp+1Fh]
    push    eax
    xor     eax, eax
    mov     al, [edx+ebx+8B2h]
    push    eax
    call    sub_4C13A0
    push    esi
    push    edi
    call    sub_4A1810
    push    esi
    push    ebx
    call    sub_49FC50
    mov     ecx, [ebx+18h]
    push    0
    lea     eax, [edi+ebp+0B6h]
    mov     [ecx+20h], esi
    movsx   edx, word ptr [edi+ebp+138h]
    push    edx
    push    eax
    push    esi
    push    ebx
    call    sub_4AB6C0
    call    sub_4C1A40
    push    1
    push    ebx
    call    sub_4AB690
    mov     edi, [esp+3Ch+var_2C]
    jmp     short loc_4A74C8
    ; ---------------------------------------------------------------------------

    loc_4A744C:                             ; CODE XREF: sub_4A7290+14Ej
    push    2
    push    ebx
    call    sub_4AB510
    test    eax, eax
    jz      short loc_4A74C8
    mov     ecx, [ebx+18h]
    lea     edx, [esp+3Ch+var_28]
    push    edx
    push    esi
    mov     edi, [ecx+4]
    push    edi
    call    sub_4A15C0
    call    sub_4C13F0
    push    eax
    mov     eax, [edi+ebp+1Fh]
    xor     ecx, ecx
    mov     cl, [eax+ebx+8B2h]
    push    ecx
    call    sub_4C13A0
    push    esi
    push    edi
    call    sub_4A1810
    push    esi
    push    ebx
    call    sub_49FC50
    mov     edx, [ebx+18h]
    push    0
    lea     ecx, [edi+ebp+0B6h]
    mov     [edx+20h], esi
    movsx   eax, word ptr [edi+ebp+138h]
    push    eax
    push    ecx
    push    esi
    push    ebx
    call    sub_4AB6C0
    call    sub_4C1A40
    push    2
    push    ebx
    call    sub_4AB690
    mov     edi, [esp+3Ch+var_2C]
    jmp     short loc_4A74C8
    ; ---------------------------------------------------------------------------

    loc_4A74C4:                             ; CODE XREF: sub_4A7290+119j
                                            ; sub_4A7290+123j ...
    mov     esi, [esp+3Ch+arg_4]

    loc_4A74C8:                             ; CODE XREF: sub_4A7290+1BAj
                                            ; sub_4A7290+1C6j ...
    cmp     [ebx+64h], esi
    jnz     short loc_4A7546
    mov     edx, [edi+ebp+23h]
    mov     ecx, [edi+ebp+1Fh]
    xor     eax, eax
    mov     al, [edx+ebx+8B2h]
    xor     edx, edx
    mov     dl, [ecx+ebx+8B2h]
    push    eax
    push    edx
    call    sub_4C13A0
    mov     eax, [esp+3Ch+arg_8]
    push    eax
    push    esi
    push    ebx
    call    sub_4AB720
    cmp     eax, 0Dh
    jnz     short loc_4A7515
    mov     dword ptr [ebx+64h], 0FFFFFFFFh
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A7515:                             ; CODE XREF: sub_4A7290+26Dj
    cmp     eax, 1Bh
    jnz     short loc_4A7538
    mov     dword ptr [ebx+64h], 0FFFFFFFFh
    mov     byte ptr [edi+ebp+0B6h], 0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4A7538:                             ; CODE XREF: sub_4A7290+288j
    mov     ebx, [ebx+18h]
    test    ebx, ebx
    jz      short loc_4A7546
    mov     dword ptr [ebx+14h], 1

    loc_4A7546:                             ; CODE XREF: sub_4A7290+23Bj
                                            ; sub_4A7290+2ADj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    sub_4A7290 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    mov     eax, [esp+0Ch]
    push    esi
    push    edi
    mov     edi, [esp+10h]
    mov     esi, eax
    inc     eax
    movsx   ecx, word ptr [edi+0B6h]
    lea     edx, [ecx+1]
    cmp     eax, edx
    jge     short loc_4A75A5
    mov     ecx, eax
    mov     ebx, edi
    shl     ecx, 3
    sub     ecx, eax
    add     ebx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     ecx, [ebx+ecx*2]

    loc_4A7593:                             ; CODE XREF: .text:004A75A1j
    cmp     byte ptr [ecx], 3
    jz      short loc_4A75A3
    inc     eax
    add     ecx, 15Bh
    cmp     eax, edx
    jl      short loc_4A7593

    loc_4A75A3:                             ; CODE XREF: .text:004A7596j
    cmp     eax, edx

    loc_4A75A5:                             ; CODE XREF: .text:004A757Aj
    jnz     short loc_4A75C6
    mov     eax, 1
    cmp     esi, eax
    jle     short loc_4A75C6
    lea     ecx, [edi+15Bh]

    loc_4A75B6:                             ; CODE XREF: .text:004A75C4j
    cmp     byte ptr [ecx], 3
    jz      short loc_4A75C6
    inc     eax
    add     ecx, 15Bh
    cmp     eax, esi
    jl      short loc_4A75B6

    loc_4A75C6:                             ; CODE XREF: .text:004A75A5j
                                            ; .text:004A75AEj ...
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A75D0 proc near                    ; CODE XREF: .text:0047939Fp

    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 100h
    push    ebx
    mov     ebx, [esp+104h+arg_0]
    push    ebp
    push    esi
    mov     cl, [ebx+0AB6h]
    lea     eax, [ebx+0AB6h]
    test    cl, cl
    push    edi
    mov     [esp+110h+var_100], 0
    jz      short loc_4A7609
    push    100h                            ; size_t
    push    eax                             ; char *
    lea     eax, [esp+118h+var_100]
    push    eax                             ; char *
    call    _strncpy
    add     esp, 0Ch

    loc_4A7609:                             ; CODE XREF: sub_4A75D0+24j
    mov     edi, [esp+110h+arg_4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+110h+var_100]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    offset off_502E38
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    lea     eax, [esp+114h+var_100]
    and     ecx, 3
    push    eax
    rep movsb
    lea     ecx, [esp+118h+var_100]
    push    ecx
    call    sub_4BAFF0
    lea     edx, [esp+110h+var_100]
    push    edx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_4A7693
    lea     eax, [esp+110h+var_100]
    push    eax
    call    sub_4B8C60
    mov     ecx, [ebx+18h]
    mov     edx, [ecx+4]
    mov     [edx+0C0h], eax
    mov     eax, [ebx+18h]
    mov     ecx, [eax+4]
    mov     eax, [ecx+0C0h]
    test    eax, eax
    jz      short loc_4A7693
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A7693:                             ; CODE XREF: sub_4A75D0+89j
                                            ; sub_4A75D0+AFj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 100h
    retn    8
    sub_4A75D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A76B0 proc near                    ; CODE XREF: sub_41F0A0+144p
                                            ; sub_41F400+18Ep ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    mov     esi, 1
    push    edi
    mov     eax, [ebp+18h]
    mov     ebx, [eax+4]
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4A76FC
    lea     edi, [ebx+15Dh]

    loc_4A76D5:                             ; CODE XREF: sub_4A76B0+4Aj
    mov     edx, [esp+8+arg_4]
    push    10h                             ; size_t
    push    edx                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A76FF
    movsx   eax, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     eax
    cmp     esi, eax
    jl      short loc_4A76D5

    loc_4A76FC:                             ; CODE XREF: sub_4A76B0+1Dj
    or      esi, 0FFFFFFFFh

    loc_4A76FF:                             ; CODE XREF: sub_4A76B0+37j
    cmp     esi, 0FFFFFFFFh
    jz      loc_4A781B
    mov     ecx, [ebp+18h]
    mov     dword ptr [ebp+64h], 0FFFFFFFFh
    mov     [ecx+20h], esi
    mov     ecx, [ebp+18h]
    mov     esi, [ecx+20h]
    add     ebx, esi
    lea     eax, ds:0[esi*8]
    sub     eax, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    lea     edx, [esi+eax*4]
    cmp     byte ptr [ebx+edx*2], 3
    jnz     loc_4A781B
    mov     eax, esi
    mov     ebx, [ecx+4]
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, ebx
    add     eax, esi
    lea     edx, [esi+ecx*4]
    lea     ebp, [eax+edx*2]
    call    sub_4C13F0
    mov     ecx, [ebp+1Fh]
    push    eax
    mov     eax, [esp+0Ch+arg_0]
    xor     edx, edx
    mov     dl, [ecx+eax+8B2h]
    push    edx
    call    sub_4C13A0
    movsx   eax, word ptr [ebx+0B6h]
    xor     ecx, ecx
    mov     edi, 1
    inc     eax
    cmp     eax, edi
    jle     short loc_4A77D4
    lea     edx, [ebx+15Bh]
    mov     [esp+8+arg_4], edx

    loc_4A778C:                             ; CODE XREF: sub_4A76B0+FFj
    mov     edx, [esp+8+arg_4]
    cmp     byte ptr [edx], 7
    jnz     short loc_4A779E
    movsx   edx, byte ptr [ebp+28h]
    cmp     ecx, edx
    jz      short loc_4A77B3
    inc     ecx

    loc_4A779E:                             ; CODE XREF: sub_4A76B0+E3j
    mov     edx, [esp+8+arg_4]
    inc     edi
    add     edx, 15Bh
    cmp     edi, eax
    mov     [esp+8+arg_4], edx
    jl      short loc_4A778C
    jmp     short loc_4A77D4
    ; ---------------------------------------------------------------------------

    loc_4A77B3:                             ; CODE XREF: sub_4A76B0+EBj
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    mov     eax, ebx
    add     eax, edi
    lea     edx, [edi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A77D4:                             ; CODE XREF: sub_4A76B0+D0j
                                            ; sub_4A76B0+101j
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edi, edx
    jnz     short loc_4A77ED
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A77ED:                             ; CODE XREF: sub_4A76B0+12Ej
    mov     edi, [esp+8+arg_0]
    push    esi
    push    edi
    call    sub_49FC50
    mov     edx, [edi+18h]
    push    0
    add     ebp, 0B6h
    mov     [edx+20h], esi
    movsx   eax, word ptr [ebp+82h]
    push    eax
    push    ebp
    push    esi
    push    edi
    call    sub_4AB6C0
    call    sub_4C1A40

    loc_4A781B:                             ; CODE XREF: sub_4A76B0+52j
                                            ; sub_4A76B0+83j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A76B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A7830 proc near                    ; CODE XREF: sub_440D70+41p
                                            ; sub_440D70+6Dp ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    esi
    mov     ecx, [esp+arg_4]
    push    edi
    mov     edi, [esp+4+arg_0]
    mov     eax, [edi+18h]
    mov     edx, [eax+4]
    mov     dword ptr [edi+64h], 0FFFFFFFFh
    mov     [eax+20h], ecx
    mov     ecx, [edi+18h]
    mov     esi, [ecx+20h]
    add     edx, esi
    lea     eax, ds:0[esi*8]
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     eax, [esi+eax*2]
    lea     eax, [esi+eax*4]
    cmp     byte ptr [edx+eax*2], 3
    jnz     loc_4A794F
    mov     ebx, [ecx+4]
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    push    ebp
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    mov     ecx, ebx
    add     ecx, esi
    lea     eax, [esi+edx*4]
    lea     ebp, [ecx+eax*2]
    call    sub_4C13F0
    mov     edx, [ebp+1Fh]
    push    eax
    xor     eax, eax
    mov     al, [edx+edi+8B2h]
    push    eax
    call    sub_4C13A0
    movsx   eax, word ptr [ebx+0B6h]
    xor     ecx, ecx
    mov     edi, 1
    inc     eax
    cmp     eax, edi
    jle     short loc_4A7907
    lea     edx, [ebx+15Bh]
    mov     [esp+8+arg_4], edx

    loc_4A78BF:                             ; CODE XREF: sub_4A7830+B2j
    mov     edx, [esp+8+arg_4]
    cmp     byte ptr [edx], 7
    jnz     short loc_4A78D1
    movsx   edx, byte ptr [ebp+28h]
    cmp     ecx, edx
    jz      short loc_4A78E6
    inc     ecx

    loc_4A78D1:                             ; CODE XREF: sub_4A7830+96j
    mov     edx, [esp+8+arg_4]
    inc     edi
    add     edx, 15Bh
    cmp     edi, eax
    mov     [esp+8+arg_4], edx
    jl      short loc_4A78BF
    jmp     short loc_4A7907
    ; ---------------------------------------------------------------------------

    loc_4A78E6:                             ; CODE XREF: sub_4A7830+9Ej
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    mov     eax, ebx
    add     eax, edi
    lea     edx, [edi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A7907:                             ; CODE XREF: sub_4A7830+83j
                                            ; sub_4A7830+B4j
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edi, edx
    jnz     short loc_4A7920
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A7920:                             ; CODE XREF: sub_4A7830+E1j
    mov     edi, [esp+8+arg_0]
    push    esi
    push    edi
    call    sub_49FC50
    mov     edx, [edi+18h]
    push    0
    add     ebp, 0B6h
    mov     [edx+20h], esi
    movsx   eax, word ptr [ebp+82h]
    push    eax
    push    ebp
    push    esi
    push    edi
    call    sub_4AB6C0
    call    sub_4C1A40
    pop     ebp

    loc_4A794F:                             ; CODE XREF: sub_4A7830+39j
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_4A7830 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A7960 proc near                    ; CODE XREF: sub_47B9F0+19Ap
                                            ; sub_4A03F0+CCp ...

    var_338= dword ptr -338h
    var_334= dword ptr -334h
    var_330= dword ptr -330h
    var_32C= dword ptr -32Ch
    var_328= dword ptr -328h
    var_324= dword ptr -324h
    var_320= dword ptr -320h
    var_31C= dword ptr -31Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 338h
    mov     eax, [esp+338h+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [eax+18h]
    push    edi
    mov     [esp+348h+var_328], esi
    mov     ebx, [esi+20h]
    mov     edx, [esi+4]
    cmp     ebx, 0FFFFFFFFh
    mov     [esp+348h+var_330], edx
    jz      loc_4A7E9D
    mov     ecx, 32h
    xor     eax, eax
    lea     edi, [esp+348h+var_320]
    rep stosd
    movsx   eax, word ptr [edx+0B6h]
    inc     eax
    cmp     eax, 1
    mov     [esp+348h+var_324], eax
    jle     loc_4A7A32
    lea     ecx, [esp+348h+var_31C]
    dec     eax
    mov     [esp+348h+var_338], ecx
    lea     ebp, [edx+16Eh]
    mov     [esp+348h+var_334], eax

    loc_4A79C0:                             ; CODE XREF: sub_4A7960+C8j
    mov     eax, [esp+348h+var_31C]
    or      edi, 0FFFFFFFFh
    test    eax, eax
    mov     edx, 1
    jz      short loc_4A79F3
    movsx   esi, word ptr [ebp+0]
    lea     ecx, [esp+348h+var_31C]

    loc_4A79D8:                             ; CODE XREF: sub_4A7960+8Dj
    sub     eax, esi
    cmp     eax, 0Ah
    jge     short loc_4A79E4
    cmp     eax, 0FFFFFFF6h
    jg      short loc_4A79F1

    loc_4A79E4:                             ; CODE XREF: sub_4A7960+7Dj
    mov     eax, [ecx+4]
    add     ecx, 4
    inc     edx
    test    eax, eax
    jnz     short loc_4A79D8
    jmp     short loc_4A79F3
    ; ---------------------------------------------------------------------------

    loc_4A79F1:                             ; CODE XREF: sub_4A7960+82j
    mov     edi, edx

    loc_4A79F3:                             ; CODE XREF: sub_4A7960+6Ej
                                            ; sub_4A7960+8Fj
    cmp     edi, 0FFFFFFFFh
    jz      short loc_4A7A04
    mov     eax, [esp+348h+var_338]
    mov     edx, [esp+edi*4+348h+var_320]
    mov     [eax], edx
    jmp     short loc_4A7A0E
    ; ---------------------------------------------------------------------------

    loc_4A7A04:                             ; CODE XREF: sub_4A7960+96j
    movsx   ecx, word ptr [ebp+0]
    mov     edx, [esp+348h+var_338]
    mov     [edx], ecx

    loc_4A7A0E:                             ; CODE XREF: sub_4A7960+A2j
    mov     ecx, [esp+348h+var_338]
    mov     eax, [esp+348h+var_334]
    add     ebp, 15Bh
    add     ecx, 4
    dec     eax
    mov     [esp+348h+var_338], ecx
    mov     [esp+348h+var_334], eax
    jnz     short loc_4A79C0
    mov     edx, [esp+348h+var_330]
    mov     esi, [esp+348h+var_328]

    loc_4A7A32:                             ; CODE XREF: sub_4A7960+47j
    mov     eax, [esp+348h+arg_4]
    cmp     eax, 3                          ; switch 4 cases
    ja      loc_4A7B1B                      ; default
    jmp     ds:off_4A7EAC[eax*4]            ; switch jump

    loc_4A7A49:                             ; DATA XREF: .text:004A7EACo
    mov     eax, ebx                        ; case 0x0
    shl     eax, 3
    sub     eax, ebx
    lea     eax, [eax+eax*2]
    lea     ecx, [ebx+eax*2]
    lea     eax, [ebx+ecx*4]
    mov     ecx, edx
    add     ecx, ebx
    lea     eax, [ecx+eax*2]
    movsx   ecx, word ptr [eax+15h]
    movsx   eax, word ptr [eax+13h]
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [ecx+ecx*4]
    jmp     short loc_4A7A9F
    ; ---------------------------------------------------------------------------

    loc_4A7A76:                             ; CODE XREF: sub_4A7960+E2j
                                            ; DATA XREF: .text:004A7EACo
    mov     eax, [esp+ebx*4+348h+var_320]   ; case 0x2
    mov     edi, edx
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     ecx, [eax+eax*4]
    mov     eax, ebx
    shl     eax, 3
    sub     eax, ebx
    add     edi, ebx
    lea     eax, [eax+eax*2]
    lea     eax, [ebx+eax*2]
    lea     eax, [ebx+eax*4]
    movsx   eax, word ptr [edi+eax*2+15h]

    loc_4A7A9F:                             ; CODE XREF: sub_4A7960+114j
    lea     ebp, [eax+ecx*8]
    mov     [esp+348h+var_338], ebp
    lea     ecx, [ebp-17D7840h]
    mov     [esp+348h+var_32C], ecx
    jmp     short loc_4A7B1F
    ; ---------------------------------------------------------------------------

    loc_4A7AB2:                             ; CODE XREF: sub_4A7960+E2j
                                            ; DATA XREF: .text:004A7EACo
    mov     eax, ebx                        ; case 0x1
    shl     eax, 3
    sub     eax, ebx
    lea     eax, [eax+eax*2]
    lea     ecx, [ebx+eax*2]
    lea     eax, [ebx+ecx*4]
    mov     ecx, edx
    add     ecx, ebx
    lea     eax, [ecx+eax*2]
    movsx   ecx, word ptr [eax+15h]
    movsx   eax, word ptr [eax+13h]
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [ecx+ecx*4]
    lea     ecx, [ecx+ecx*4]
    jmp     short loc_4A7B08
    ; ---------------------------------------------------------------------------

    loc_4A7ADF:                             ; CODE XREF: sub_4A7960+E2j
                                            ; DATA XREF: .text:004A7EACo
    mov     eax, [esp+ebx*4+348h+var_320]   ; case 0x3
    mov     edi, edx
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     ecx, [eax+eax*4]
    mov     eax, ebx
    shl     eax, 3
    sub     eax, ebx
    add     edi, ebx
    lea     eax, [eax+eax*2]
    lea     eax, [ebx+eax*2]
    lea     eax, [ebx+eax*4]
    movsx   eax, word ptr [edi+eax*2+15h]

    loc_4A7B08:                             ; CODE XREF: sub_4A7960+17Dj
    lea     ebp, [eax+ecx*8]
    mov     [esp+348h+var_338], ebp
    lea     ecx, [ebp+17D7840h]
    mov     [esp+348h+var_32C], ecx
    jmp     short loc_4A7B1F
    ; ---------------------------------------------------------------------------

    loc_4A7B1B:                             ; CODE XREF: sub_4A7960+DCj
    mov     ebp, [esp+348h+var_338]         ; default

    loc_4A7B1F:                             ; CODE XREF: sub_4A7960+150j
                                            ; sub_4A7960+1B9j
    mov     eax, [esp+348h+var_324]
    mov     edi, 1
    cmp     eax, edi
    jle     loc_4A7C65
    lea     eax, [esp+348h+var_31C]
    lea     ecx, [edx+172h]
    mov     edx, [esp+348h+var_328]
    mov     [esp+348h+var_334], eax

    loc_4A7B42:                             ; CODE XREF: sub_4A7960+2FBj
    mov     al, [ecx+12h]
    test    al, al
    jz      loc_4A7C43                      ; default
    mov     esi, [ecx+4]
    test    esi, 400h
    jnz     loc_4A7C43                      ; default
    mov     al, [ecx-17h]
    cmp     al, 1
    jnz     short loc_4A7B6F
    test    [ecx+125h], al
    jnz     loc_4A7C43                      ; default

    loc_4A7B6F:                             ; CODE XREF: sub_4A7960+201j
    cmp     al, 4
    jnz     short loc_4A7B80
    cmp     dword ptr [ecx+140h], 0
    jnz     loc_4A7C43                      ; default

    loc_4A7B80:                             ; CODE XREF: sub_4A7960+211j
    cmp     al, 3
    jz      short loc_4A7B98
    cmp     al, 4
    jz      short loc_4A7B9C
    cmp     al, 1
    jz      short loc_4A7B98
    cmp     al, 6
    jz      short loc_4A7B98
    cmp     al, 2
    jnz     loc_4A7C43                      ; default

    loc_4A7B98:                             ; CODE XREF: sub_4A7960+222j
                                            ; sub_4A7960+22Aj ...
    cmp     al, 4
    jnz     short loc_4A7BAD

    loc_4A7B9C:                             ; CODE XREF: sub_4A7960+226j
    mov     bp, [ecx]
    cmp     bp, [ecx+2]
    mov     ebp, [esp+348h+var_338]
    jl      loc_4A7C43                      ; default

    loc_4A7BAD:                             ; CODE XREF: sub_4A7960+23Aj
    cmp     al, 2
    jnz     short loc_4A7BBD
    test    esi, 100h
    jnz     loc_4A7C43                      ; default

    loc_4A7BBD:                             ; CODE XREF: sub_4A7960+24Fj
    cmp     al, 1
    jnz     short loc_4A7BCA
    test    byte ptr [ecx+125h], 1
    jnz     short loc_4A7C43                ; default

    loc_4A7BCA:                             ; CODE XREF: sub_4A7960+25Fj
    mov     esi, [esp+348h+arg_4]
    cmp     esi, 3                          ; switch 4 cases
    ja      short loc_4A7C43                ; default
    jmp     ds:off_4A7EBC[esi*4]            ; switch jump

    loc_4A7BDD:                             ; DATA XREF: .text:004A7EBCo
    movsx   eax, word ptr [ecx-2]           ; case 0x0
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     edx, [eax+eax*4]
    movsx   eax, word ptr [ecx-4]
    lea     edx, [eax+edx*8]
    jmp     short loc_4A7C0F
    ; ---------------------------------------------------------------------------

    loc_4A7BF6:                             ; CODE XREF: sub_4A7960+276j
                                            ; DATA XREF: .text:004A7EBCo
    mov     edx, [esp+348h+var_334]         ; case 0x2
    mov     eax, [edx]
    movsx   edx, word ptr [ecx-2]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     edx, [edx+eax*8]

    loc_4A7C0F:                             ; CODE XREF: sub_4A7960+294j
    cmp     esi, 3                          ; switch 4 cases
    ja      short loc_4A7C43                ; default
    jmp     ds:off_4A7ECC[esi*4]            ; switch jump

    loc_4A7C1B:                             ; DATA XREF: .text:004A7ECCo
    cmp     edx, ebp                        ; case 0x1
    jg      short loc_4A7C25
    add     edx, 17D7840h

    loc_4A7C25:                             ; CODE XREF: sub_4A7960+2BDj
    cmp     edx, [esp+348h+var_32C]
    jge     short loc_4A7C43                ; default
    jmp     short loc_4A7C3D
    ; ---------------------------------------------------------------------------

    loc_4A7C2D:                             ; CODE XREF: sub_4A7960+2B4j
                                            ; DATA XREF: .text:004A7ECCo
    cmp     edx, ebp                        ; case 0x0
    jl      short loc_4A7C37
    sub     edx, 17D7840h

    loc_4A7C37:                             ; CODE XREF: sub_4A7960+2CFj
    cmp     edx, [esp+348h+var_32C]
    jle     short loc_4A7C43                ; default

    loc_4A7C3D:                             ; CODE XREF: sub_4A7960+2CBj
    mov     [esp+348h+var_32C], edx
    mov     ebx, edi

    loc_4A7C43:                             ; CODE XREF: sub_4A7960+1E7j
                                            ; sub_4A7960+1F6j ...
    mov     eax, [esp+348h+var_334]         ; default
    inc     edi
    add     eax, 4
    add     ecx, 15Bh
    mov     [esp+348h+var_334], eax
    mov     eax, [esp+348h+var_324]
    cmp     edi, eax
    jl      loc_4A7B42
    mov     esi, [esp+348h+var_328]

    loc_4A7C65:                             ; CODE XREF: sub_4A7960+1CAj
    mov     eax, [esp+348h+arg_0]
    mov     dword ptr [eax+64h], 0FFFFFFFFh
    mov     [esi+20h], ebx
    mov     ecx, [eax+18h]
    mov     esi, [ecx+20h]
    lea     eax, ds:0[esi*8]
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     edx, [esi+eax*2]
    lea     eax, [esi+edx*4]
    mov     edx, [esp+348h+var_330]
    add     edx, esi
    cmp     byte ptr [edx+eax*2], 3
    jnz     loc_4A7D86
    mov     eax, esi
    mov     ebp, [ecx+4]
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, ebp
    add     eax, esi
    lea     edx, [esi+ecx*4]
    lea     ebx, [eax+edx*2]
    call    sub_4C13F0
    mov     ecx, [ebx+1Fh]
    push    eax
    mov     eax, [esp+34Ch+arg_0]
    xor     edx, edx
    mov     dl, [ecx+eax+8B2h]
    push    edx
    call    sub_4C13A0
    movsx   eax, word ptr [ebp+0B6h]
    xor     ecx, ecx
    mov     edi, 1
    inc     eax
    cmp     eax, edi
    jle     short loc_4A7D3C
    lea     edx, [ebp+15Bh]
    mov     [esp+348h+var_334], edx

    loc_4A7CF4:                             ; CODE XREF: sub_4A7960+3B7j
    mov     edx, [esp+348h+var_334]
    cmp     byte ptr [edx], 7
    jnz     short loc_4A7D06
    movsx   edx, byte ptr [ebx+28h]
    cmp     ecx, edx
    jz      short loc_4A7D1B
    inc     ecx

    loc_4A7D06:                             ; CODE XREF: sub_4A7960+39Bj
    mov     edx, [esp+348h+var_334]
    inc     edi
    add     edx, 15Bh
    cmp     edi, eax
    mov     [esp+348h+var_334], edx
    jl      short loc_4A7CF4
    jmp     short loc_4A7D3C
    ; ---------------------------------------------------------------------------

    loc_4A7D1B:                             ; CODE XREF: sub_4A7960+3A3j
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    mov     eax, ebp
    add     eax, edi
    lea     edx, [edi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A7D3C:                             ; CODE XREF: sub_4A7960+388j
                                            ; sub_4A7960+3B9j
    movsx   edx, word ptr [ebp+0B6h]
    inc     edx
    cmp     edi, edx
    jnz     short loc_4A7D55
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A7D55:                             ; CODE XREF: sub_4A7960+3E6j
    mov     edi, [esp+348h+arg_0]
    push    esi
    push    edi
    call    sub_49FC50
    mov     edx, [edi+18h]
    push    0
    add     ebx, 0B6h
    mov     [edx+20h], esi
    movsx   eax, word ptr [ebx+82h]
    push    eax
    push    ebx
    push    esi
    push    edi
    call    sub_4AB6C0
    call    sub_4C1A40

    loc_4A7D86:                             ; CODE XREF: sub_4A7960+338j
    mov     ecx, [esp+348h+arg_0]
    mov     ecx, [ecx+18h]
    mov     esi, [ecx+20h]
    lea     eax, ds:0[esi*8]
    sub     eax, esi
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*2]
    lea     edx, [esi+eax*4]
    mov     eax, [esp+348h+var_330]
    add     eax, esi
    cmp     byte ptr [eax+edx*2], 3
    jnz     loc_4A7E9D
    mov     ebp, [ecx+4]
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    mov     ecx, ebp
    add     ecx, esi
    lea     eax, [esi+edx*4]
    lea     ebx, [ecx+eax*2]
    call    sub_4C13F0
    mov     edx, [ebx+1Fh]
    mov     ecx, [esp+348h+arg_0]
    push    eax
    xor     eax, eax
    mov     al, [edx+ecx+8B2h]
    push    eax
    call    sub_4C13A0
    movsx   eax, word ptr [ebp+0B6h]
    xor     ecx, ecx
    mov     edi, 1
    inc     eax
    cmp     eax, edi
    jle     short loc_4A7E53
    lea     edx, [ebp+15Bh]
    mov     [esp+348h+var_330], edx

    loc_4A7E0B:                             ; CODE XREF: sub_4A7960+4CEj
    mov     edx, [esp+348h+var_330]
    cmp     byte ptr [edx], 7
    jnz     short loc_4A7E1D
    movsx   edx, byte ptr [ebx+28h]
    cmp     ecx, edx
    jz      short loc_4A7E32
    inc     ecx

    loc_4A7E1D:                             ; CODE XREF: sub_4A7960+4B2j
    mov     edx, [esp+348h+var_330]
    inc     edi
    add     edx, 15Bh
    cmp     edi, eax
    mov     [esp+348h+var_330], edx
    jl      short loc_4A7E0B
    jmp     short loc_4A7E53
    ; ---------------------------------------------------------------------------

    loc_4A7E32:                             ; CODE XREF: sub_4A7960+4BAj
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    mov     eax, ebp
    add     eax, edi
    lea     edx, [edi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A7E53:                             ; CODE XREF: sub_4A7960+49Fj
                                            ; sub_4A7960+4D0j
    movsx   edx, word ptr [ebp+0B6h]
    inc     edx
    cmp     edi, edx
    jnz     short loc_4A7E6C
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A7E6C:                             ; CODE XREF: sub_4A7960+4FDj
    mov     edi, [esp+348h+arg_0]
    push    esi
    push    edi
    call    sub_49FC50
    mov     edx, [edi+18h]
    push    0
    add     ebx, 0B6h
    mov     [edx+20h], esi
    movsx   eax, word ptr [ebx+82h]
    push    eax
    push    ebx
    push    esi
    push    edi
    call    sub_4AB6C0
    call    sub_4C1A40

    loc_4A7E9D:                             ; CODE XREF: sub_4A7960+25j
                                            ; sub_4A7960+44Fj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 338h
    retn    8
    sub_4A7960 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4A7EAC dd offset loc_4A7A49         ; DATA XREF: sub_4A7960+E2r
    dd offset loc_4A7AB2                    ; jump table for switch statement
    dd offset loc_4A7A76
    dd offset loc_4A7ADF
    off_4A7EBC dd offset loc_4A7BDD         ; DATA XREF: sub_4A7960+276r
    dd offset loc_4A7BDD                    ; jump table for switch statement
    dd offset loc_4A7BF6
    dd offset loc_4A7BF6
    off_4A7ECC dd offset loc_4A7C2D         ; DATA XREF: sub_4A7960+2B4r
    dd offset loc_4A7C1B                    ; jump table for switch statement
    dd offset loc_4A7C2D
    dd offset loc_4A7C1B
    align 8
    mov     eax, [esp+8]
    sub     esp, 15Ch
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A7F58
    mov     ecx, eax
    push    edi
    shl     ecx, 3
    sub     ecx, eax
    push    esi
    push    ebx
    mov     ebx, [esp+16Ch]
    lea     ecx, [ecx+ecx*2]
    lea     edi, [esp+0Ch]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    cmp     eax, 1
    lea     edx, [edx+ecx*2]
    mov     ecx, 56h
    mov     esi, edx
    rep movsd
    movsw
    movsb
    jle     short loc_4A7F41
    mov     edi, edx
    lea     edx, [eax-1]

    loc_4A7F2A:                             ; CODE XREF: .text:004A7F3Fj
    lea     eax, [edi-15Bh]
    mov     ecx, 56h
    mov     esi, eax
    dec     edx
    rep movsd
    movsw
    movsb
    mov     edi, eax
    jnz     short loc_4A7F2A

    loc_4A7F41:                             ; CODE XREF: .text:004A7F23j
    lea     edi, [ebx+15Bh]
    mov     ecx, 56h
    lea     esi, [esp+0Ch]
    pop     ebx
    rep movsd
    movsw
    movsb
    pop     esi
    pop     edi

    loc_4A7F58:                             ; CODE XREF: .text:004A7EEDj
    add     esp, 15Ch
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 30h
    push    ebx
    mov     ebx, [esp+38h]
    push    ebp
    mov     ebp, [esp+40h]
    mov     eax, [ebx+18h]
    push    esi
    push    edi
    lea     ecx, [ebp+2]
    mov     edi, [eax+4]
    push    10h
    lea     edx, [esp+14h]
    push    ecx
    push    edx
    xor     esi, esi
    call    _strncpy
    mov     byte ptr [esp+2Bh], 0
    mov     byte ptr [ebp+13Bh], 0
    mov     eax, [edi+0C0h]
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A7FBD
    lea     ecx, [esp+10h]
    push    ecx
    push    eax
    call    sub_4B8D40
    mov     esi, eax

    loc_4A7FBD:                             ; CODE XREF: .text:004A7FAEj
    test    esi, esi
    jnz     loc_4A8111
    mov     eax, [ebx+4]
    test    eax, eax
    jz      loc_4A8111
    lea     edx, [esp+10h]
    push    edx
    push    eax
    call    sub_4B8D40
    mov     esi, eax
    test    esi, esi
    jnz     loc_4A8111
    test    byte ptr [ebp+1Bh], 80h
    jz      short loc_4A7FF9
    mov     eax, [ebx+4]
    push    offset aCheckbox                ; "CHECKBOX"
    push    eax
    jmp     loc_4A8081
    ; ---------------------------------------------------------------------------

    loc_4A7FF9:                             ; CODE XREF: .text:004A7FE9j
    mov     al, [ebp+136h]
    test    al, al
    jz      short loc_4A8052
    cmp     al, 4
    jnb     short loc_4A800E
    and     eax, 0FFh
    jmp     short loc_4A8013
    ; ---------------------------------------------------------------------------

    loc_4A800E:                             ; CODE XREF: .text:004A8005j
    mov     eax, 4

    loc_4A8013:                             ; CODE XREF: .text:004A800Cj
    push    eax
    lea     ecx, [esp+24h]
    push    offset aStagebuttnD             ; "stagebuttn%d"
    push    ecx
    call    _sprintf
    mov     eax, [ebx+4]
    add     esp, 0Ch
    lea     edx, [esp+20h]
    push    edx
    push    eax
    call    sub_4B8D40
    mov     esi, eax
    mov     al, [ebp+136h]
    cmp     al, 1
    jnz     short loc_4A8088
    mov     eax, [ebp+1Bh]
    mov     byte ptr [ebp+136h], 2
    or      ah, 40h
    mov     [ebp+1Bh], eax
    jmp     short loc_4A8088
    ; ---------------------------------------------------------------------------

    loc_4A8052:                             ; CODE XREF: .text:004A8001j
    mov     edi, offset aButtons0           ; "BUTTONS0"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+20h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, [ebx+4]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+20h]
    push    ecx
    push    edx

    loc_4A8081:                             ; CODE XREF: .text:004A7FF4j
    call    sub_4B8D40
    mov     esi, eax

    loc_4A8088:                             ; CODE XREF: .text:004A803Ej
                                            ; .text:004A8050j
    test    esi, esi
    jz      loc_4A8111
    xor     edi, edi
    mov     dword ptr [esp+44h], 3E8h
    cmp     [esi], di
    jbe     short loc_4A80BE

    loc_4A809F:                             ; CODE XREF: .text:004A80BCj
    push    edi
    push    esi
    call    sub_4B7F30
    xor     ecx, ecx
    cmp     eax, ecx
    jz      short loc_4A80B4
    mov     [eax+6], cx
    mov     [eax+4], cx

    loc_4A80B4:                             ; CODE XREF: .text:004A80AAj
    xor     eax, eax
    inc     edi
    mov     ax, [esi]
    cmp     edi, eax
    jl      short loc_4A809F

    loc_4A80BE:                             ; CODE XREF: .text:004A809Dj
    xor     ebx, ebx
    cmp     [esi], bx
    jbe     short loc_4A8111

    loc_4A80C5:                             ; CODE XREF: .text:004A810Fj
    push    ebx
    push    esi
    call    sub_4B7F30
    mov     edi, eax
    xor     ecx, ecx
    movsx   eax, word ptr [ebp+19h]
    mov     cx, [edi+2]
    sub     eax, ecx
    cdq
    mov     ecx, eax
    movsx   eax, word ptr [ebp+17h]
    xor     ecx, edx
    sub     ecx, edx
    xor     edx, edx
    mov     dx, [edi]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    add     ecx, eax
    mov     eax, [esp+44h]
    cmp     ecx, eax
    jge     short loc_4A8105
    mov     [ebp+13Bh], bl
    mov     [esp+44h], ecx

    loc_4A8105:                             ; CODE XREF: .text:004A80F9j
    xor     eax, eax
    add     ebx, 4
    mov     ax, [esi]
    cmp     ebx, eax
    jl      short loc_4A80C5

    loc_4A8111:                             ; CODE XREF: .text:004A7FBFj
                                            ; .text:004A7FCAj ...
    test    esi, esi
    mov     [ebp+2Fh], esi
    jz      short loc_4A813A
    xor     ecx, ecx
    mov     cl, [ebp+13Bh]
    push    ecx
    push    esi
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A813A
    mov     dx, [eax]
    mov     [ebp+17h], dx
    mov     ax, [eax+2]
    mov     [ebp+19h], ax

    loc_4A813A:                             ; CODE XREF: .text:004A8116j
                                            ; .text:004A8129j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    esi
    push    edi
    mov     ecx, [eax+18h]
    mov     edx, [ecx+4]
    mov     esi, edx
    inc     word ptr [edx+0B6h]
    movsx   eax, word ptr [edx+0B6h]
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    xor     eax, eax
    lea     esi, [esi+ecx*2]
    mov     ecx, 56h
    mov     edi, esi
    rep stosd
    stosw
    stosb
    mov     al, [esp+10h]
    mov     byte ptr [esi+29h], 1
    mov     [esi], al
    pop     edi
    movsx   eax, word ptr [edx+0B6h]
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     ecx, [esp+8]
    add     eax, 0AB6h
    mov     byte ptr [ecx], 0
    cmp     byte ptr [eax], 0
    jz      short locret_4A81D4
    push    100h
    push    eax
    push    ecx
    call    _strncpy
    add     esp, 0Ch

    locret_4A81D4:                          ; CODE XREF: .text:004A81C3j
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A81E0 proc near                    ; CODE XREF: sub_41A490+459p
                                            ; sub_41ACE0+233p ...

    var_3C0= dword ptr -3C0h
    var_3BC= dword ptr -3BCh
    var_3B8= dword ptr -3B8h
    var_3B4= dword ptr -3B4h
    var_3B0= dword ptr -3B0h
    var_3AC= dword ptr -3ACh
    var_3A8= dword ptr -3A8h
    var_3A4= dword ptr -3A4h
    var_3A0= byte ptr -3A0h
    var_380= byte ptr -380h
    var_370= byte ptr -370h
    var_280= byte ptr -280h
    var_180= dword ptr -180h
    var_80= dword ptr -80h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    sub     esp, 3C0h
    mov     eax, [eax+18h]
    push    ebx
    push    ebp
    push    esi
    test    eax, eax
    push    edi
    jnz     short loc_4A8202
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3C0h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A8202:                             ; CODE XREF: sub_4A81E0+13j
    mov     ebp, [eax+4]
    mov     ebx, [esp+3D0h+arg_4]
    or      eax, 0FFFFFFFFh
    test    bh, 1
    jz      short loc_4A8221
    test    bl, 1
    jz      short loc_4A8221
    mov     [ebp+15h], ax
    mov     [ebp+13h], ax

    loc_4A8221:                             ; CODE XREF: sub_4A81E0+32j
                                            ; sub_4A81E0+37j
    test    bh, 10h
    mov     esi, 0FFFFFFFEh
    jz      short loc_4A8238
    test    bl, 1
    jz      short loc_4A8238
    mov     [ebp+15h], si
    mov     [ebp+13h], si

    loc_4A8238:                             ; CODE XREF: sub_4A81E0+49j
                                            ; sub_4A81E0+4Ej
    cmp     [ebp+13h], ax
    jnz     short loc_4A8266
    call    sub_4B6700
    movsx   ecx, word ptr [ebp+17h]
    sub     eax, ecx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebp+13h], ax
    call    sub_4B6710
    movsx   edx, word ptr [ebp+19h]
    sub     eax, edx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebp+15h], ax

    loc_4A8266:                             ; CODE XREF: sub_4A81E0+5Cj
    cmp     [ebp+13h], si
    jnz     short loc_4A82A0
    call    sub_4B6700
    movsx   ecx, word ptr [ebp+17h]
    mov     edx, 0FFFFFF80h
    sub     edx, ecx
    add     eax, edx
    cdq
    sub     eax, edx
    sar     eax, 1
    add     eax, 80h
    mov     [ebp+13h], ax
    call    sub_4B6710
    movsx   ecx, word ptr [ebp+19h]
    sub     eax, ecx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebp+15h], ax

    loc_4A82A0:                             ; CODE XREF: sub_4A81E0+8Aj
    call    sub_4B6700
    movsx   edx, word ptr [ebp+13h]
    movsx   ecx, word ptr [ebp+17h]
    add     edx, ecx
    cmp     edx, eax
    jle     short loc_4A82C7
    call    sub_4B6700
    movsx   edx, word ptr [ebp+17h]
    sub     eax, edx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebp+13h], ax

    loc_4A82C7:                             ; CODE XREF: sub_4A81E0+D1j
    call    sub_4B6710
    movsx   ecx, word ptr [ebp+15h]
    movsx   edx, word ptr [ebp+19h]
    add     ecx, edx
    cmp     ecx, eax
    jle     short loc_4A82EE
    call    sub_4B6710
    movsx   ecx, word ptr [ebp+19h]
    sub     eax, ecx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebp+15h], ax

    loc_4A82EE:                             ; CODE XREF: sub_4A81E0+F8j
    mov     eax, ebx
    and     eax, 1
    mov     [esp+3D0h+var_3B8], eax
    jz      loc_4A90D1
    xor     esi, esi

    loc_4A82FF:                             ; CODE XREF: sub_4A81E0+126j
    call    sub_4C1AB0
    cmp     eax, esi
    jnz     short loc_4A82FF
    mov     edx, [esp+3D0h+arg_0]
    cmp     [edx+70h], esi
    jz      short loc_4A833E
    xor     ecx, ecx
    cmp     [ebp+0B6h], si
    jl      short loc_4A833E
    mov     eax, ebp

    loc_4A8321:                             ; CODE XREF: sub_4A81E0+15Cj
    cmp     byte ptr [eax], 1
    jnz     short loc_4A832D
    mov     byte ptr [eax+13Ah], 0

    loc_4A832D:                             ; CODE XREF: sub_4A81E0+144j
    movsx   edx, word ptr [ebp+0B6h]
    inc     ecx
    add     eax, 15Bh
    cmp     ecx, edx
    jle     short loc_4A8321

    loc_4A833E:                             ; CODE XREF: sub_4A81E0+132j
                                            ; sub_4A81E0+13Dj
    call    sub_4B6700
    movsx   ecx, word ptr [ebp+17h]
    cmp     ecx, eax
    jg      loc_4A95E3
    call    sub_4B6710
    movsx   edx, word ptr [ebp+19h]
    cmp     edx, eax
    jg      loc_4A95E3
    movsx   eax, word ptr [ebp+0B6h]
    inc     eax
    mov     [ebp+0C0h], esi
    test    eax, eax
    mov     [esp+3D0h+var_3B4], esi
    jle     loc_4A9065
    mov     ecx, [esp+3D0h+arg_0]
    lea     edi, [ecx+9B6h]
    mov     [esp+3D0h+var_3A4], edi
    jmp     short loc_4A8391
    ; ---------------------------------------------------------------------------

    loc_4A838D:                             ; CODE XREF: sub_4A81E0+E78j
    mov     edi, [esp+3D0h+var_3A4]

    loc_4A8391:                             ; CODE XREF: sub_4A81E0+1ABj
    mov     al, [edi]
    mov     byte ptr [esp+3D0h+var_180], 0
    test    al, al
    jz      short loc_4A83C3
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+3D0h+var_180]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4A83C3:                             ; CODE XREF: sub_4A81E0+1BDj
    mov     ebx, [esp+3D0h+var_3B4]
    mov     [esp+3D0h+var_3C0], 0
    mov     eax, ebx
    shl     eax, 3
    sub     eax, ebx
    lea     ecx, [eax+eax*2]
    lea     edx, [ebx+ecx*2]
    lea     eax, [ebx+edx*4]
    lea     ebx, [ebx+eax*2]
    test    byte ptr [ebp+ebx+0B4h], 1
    jz      loc_4A84DC
    mov     ecx, [esp+3D0h+arg_0]
    xor     eax, eax
    mov     [ebp+ebx+2Bh], eax
    mov     [ebp+ebx+2Fh], eax
    mov     [esp+3D0h+var_280], al
    lea     eax, [ecx+0AB6h]
    mov     cl, [ecx+0AB6h]
    test    cl, cl
    jz      short loc_4A842E
    push    100h                            ; size_t
    lea     edx, [esp+3D4h+var_280]
    push    eax                             ; char *
    push    edx                             ; char *
    call    _strncpy
    add     esp, 0Ch

    loc_4A842E:                             ; CODE XREF: sub_4A81E0+236j
    lea     edi, [ebp+ebx+2]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+3D0h+var_280]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    offset off_502E38
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     edx, [esp+3D4h+var_280]
    and     ecx, 3
    rep movsb
    mov     edi, offset a_gadget            ; "_gadget"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     eax, [esp+3D4h+var_280]
    and     ecx, 3
    push    eax
    rep movsb
    lea     ecx, [esp+3D8h+var_280]
    push    ecx
    call    sub_4BAFF0
    lea     edx, [esp+3D0h+var_280]
    push    edx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_4A84DC
    lea     eax, [esp+3D0h+var_280]
    push    eax
    call    sub_4B8C60
    test    eax, eax
    mov     [ebp+ebx+2Bh], eax
    jz      short loc_4A84DC
    lea     ecx, [ebp+ebx+2]
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     [ebp+ebx+2Fh], eax

    loc_4A84DC:                             ; CODE XREF: sub_4A81E0+20Aj
                                            ; sub_4A81E0+2D6j ...
    xor     eax, eax
    mov     al, [ebp+ebx+0]
    cmp     eax, 0Dh                        ; switch 14 cases
    ja      loc_4A9045                      ; default
    jmp     ds:off_4A95F4[eax*4]            ; switch jump

    loc_4A84F2:                             ; DATA XREF: .text:004A95F4o
    cmp     word ptr [ebp+15h], 0           ; case 0x0
    jge     short loc_4A8502
    call    sub_4B6710
    add     [ebp+15h], ax

    loc_4A8502:                             ; CODE XREF: sub_4A81E0+317j
    mov     ecx, [esp+3D0h+arg_0]
    mov     [esp+3D0h+var_280], 0
    lea     eax, [ecx+0AB6h]
    mov     cl, [ecx+0AB6h]
    test    cl, cl
    jz      short loc_4A8537
    push    100h                            ; size_t
    lea     edx, [esp+3D4h+var_280]
    push    eax                             ; char *
    push    edx                             ; char *
    call    _strncpy
    add     esp, 0Ch

    loc_4A8537:                             ; CODE XREF: sub_4A81E0+33Fj
    lea     eax, [ebp+2]
    push    10h                             ; size_t
    lea     ecx, [esp+3D4h+var_380]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    _strncpy
    lea     edi, [esp+3DCh+var_380]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    mov     [esp+3D0h+var_370], 0
    lea     edx, [esp+3D0h+var_280]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    offset off_502E38
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    lea     eax, [esp+3D4h+var_280]
    and     ecx, 3
    push    eax
    rep movsb
    lea     ecx, [esp+3D8h+var_280]
    push    ecx
    call    sub_4BAFF0
    mov     eax, [ebp+0C0h]
    xor     ebx, ebx
    cmp     eax, ebx
    jnz     short loc_4A85C9
    lea     edx, [esp+3D0h+var_280]
    push    edx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_4A85C9
    lea     eax, [esp+3D0h+var_280]
    push    eax
    call    sub_4B8C60
    mov     [ebp+0C0h], eax

    loc_4A85C9:                             ; CODE XREF: sub_4A81E0+3C3j
                                            ; sub_4A81E0+3D4j
    lea     ecx, [ebp+0FCh]
    push    10h                             ; size_t
    lea     edx, [esp+3D4h+var_380]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    mov     eax, [ebp+0C0h]
    add     esp, 0Ch
    cmp     eax, ebx
    mov     [esp+3D0h+var_370], 0
    jz      short loc_4A85FD
    lea     ecx, [esp+3D0h+var_380]
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    jmp     short loc_4A8601
    ; ---------------------------------------------------------------------------

    loc_4A85FD:                             ; CODE XREF: sub_4A81E0+40Cj
    mov     esi, [esp+3D0h+var_3C0]

    loc_4A8601:                             ; CODE XREF: sub_4A81E0+41Bj
    cmp     esi, ebx
    jnz     short loc_4A8658
    mov     edi, [esp+3D0h+arg_0]
    mov     eax, [edi+4]
    cmp     eax, ebx
    jz      short loc_4A8658
    lea     edx, [esp+3D0h+var_380]
    push    edx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    cmp     esi, ebx
    jnz     short loc_4A8658
    mov     eax, [edi+4]
    push    offset aBacktile                ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    cmp     esi, ebx
    jz      short loc_4A8658
    xor     edi, edi
    cmp     [esi], bx
    jbe     short loc_4A8658

    loc_4A863F:                             ; CODE XREF: sub_4A81E0+476j
    push    edi
    push    esi
    call    sub_4B7F30
    xor     ecx, ecx
    mov     [eax+6], bx
    mov     [eax+4], bx
    mov     cx, [esi]
    inc     edi
    cmp     edi, ecx
    jl      short loc_4A863F

    loc_4A8658:                             ; CODE XREF: sub_4A81E0+423j
                                            ; sub_4A81E0+431j ...
    mov     [ebp+0C4h], esi
    jmp     loc_4A9045                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A8663:                             ; CODE XREF: sub_4A81E0+30Bj
                                            ; DATA XREF: .text:004A95F4o
    mov     byte ptr [ebp+ebx+13Bh], 0      ; case 0x4
    mov     eax, [ebp+0C0h]
    test    eax, eax
    jz      short loc_4A8688
    push    offset aSliders                 ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    mov     [esp+3D0h+var_3C0], esi
    jmp     short loc_4A868C
    ; ---------------------------------------------------------------------------

    loc_4A8688:                             ; CODE XREF: sub_4A81E0+493j
    mov     esi, [esp+3D0h+var_3C0]

    loc_4A868C:                             ; CODE XREF: sub_4A81E0+4A6j
    test    esi, esi
    jnz     loc_4A8721
    mov     edx, [esp+3D0h+arg_0]
    mov     eax, [edx+4]
    test    eax, eax
    jz      short loc_4A8721
    push    offset aSliders                 ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    test    esi, esi
    mov     [esp+3D0h+var_3C0], esi
    jz      short loc_4A8721
    xor     edi, edi
    cmp     [esi], di
    jbe     short loc_4A86D9

    loc_4A86BE:                             ; CODE XREF: sub_4A81E0+4F7j
    push    edi
    push    esi
    call    sub_4B7F30
    xor     ecx, ecx
    inc     edi
    mov     [eax+6], cx
    mov     [eax+4], cx
    xor     eax, eax
    mov     ax, [esi]
    cmp     edi, eax
    jl      short loc_4A86BE

    loc_4A86D9:                             ; CODE XREF: sub_4A81E0+4DCj
    mov     cx, [ebp+ebx+17h]
    xor     eax, eax
    cmp     cx, [ebp+ebx+19h]
    setle   al
    dec     eax
    and     eax, 0Ah
    push    eax
    push    esi
    mov     [esp+3D8h+var_3BC], eax
    call    sub_4B7F30
    mov     dx, [ebp+ebx+17h]
    cmp     dx, [ebp+ebx+19h]
    jge     short loc_4A870D
    mov     ax, [eax]
    mov     [ebp+ebx+17h], ax
    jmp     short loc_4A8716
    ; ---------------------------------------------------------------------------

    loc_4A870D:                             ; CODE XREF: sub_4A81E0+521j
    mov     cx, [eax+2]
    mov     [ebp+ebx+19h], cx

    loc_4A8716:                             ; CODE XREF: sub_4A81E0+52Bj
    mov     dl, byte ptr [esp+3D0h+var_3BC]
    mov     [ebp+ebx+152h], dl

    loc_4A8721:                             ; CODE XREF: sub_4A81E0+4AEj
                                            ; sub_4A81E0+4C0j ...
    test    esi, esi
    mov     [ebp+ebx+14Eh], esi
    jz      loc_4A897E
    mov     eax, [esp+3D0h+arg_0]
    mov     ecx, [eax+18h]
    mov     edx, [ecx+4]
    mov     edi, edx
    inc     word ptr [edx+0B6h]
    movsx   eax, word ptr [edx+0B6h]
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    xor     eax, eax
    lea     edi, [edi+ecx*2]
    mov     ecx, 56h
    mov     [esp+3D0h+var_3BC], edi
    rep stosd
    stosw
    stosb
    mov     eax, [esp+3D0h+var_3BC]
    mov     byte ptr [eax], 1
    mov     byte ptr [eax+29h], 1
    movsx   eax, word ptr [edx+0B6h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebp
    add     ecx, eax
    lea     eax, [ebp+ebx+13h]
    mov     [esp+3D0h+var_3C0], eax
    lea     edi, [ecx+edx*2]
    mov     dx, [eax]
    lea     eax, [ebp+ebx+15h]
    mov     [edi+13h], dx
    mov     [esp+3D0h+var_3B0], eax
    mov     ax, [eax]
    mov     [edi+2Fh], esi
    mov     [edi+15h], ax
    mov     cl, [ebp+ebx+152h]
    add     cl, 6
    xor     eax, eax
    mov     [edi+13Bh], cl
    mov     dl, [ebp+ebx+1]
    mov     [edi+1], dl
    mov     al, [ebp+ebx+152h]
    add     eax, 6
    push    eax
    push    esi
    call    sub_4B7F30
    mov     cx, [eax]
    mov     [edi+17h], cx
    mov     dx, [eax+2]
    mov     ecx, [esp+3D0h+arg_0]
    mov     [edi+19h], dx
    mov     dword ptr [edi+1Bh], 3400h
    mov     al, [ebp+ebx+29h]
    mov     [edi+29h], al
    mov     edx, [ecx+18h]
    mov     edx, [edx+4]
    mov     edi, edx
    inc     word ptr [edx+0B6h]
    movsx   eax, word ptr [edx+0B6h]
    mov     ecx, eax
    add     edi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    xor     eax, eax
    lea     edi, [edi+ecx*2]
    mov     ecx, 56h
    mov     [esp+3D0h+var_3BC], edi
    rep stosd
    stosw
    stosb
    mov     eax, [esp+3D0h+var_3BC]
    mov     byte ptr [eax], 1
    mov     byte ptr [eax+29h], 1
    movsx   eax, word ptr [edx+0B6h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebp
    add     ecx, eax
    xor     eax, eax
    lea     edi, [ecx+edx*2]
    mov     dl, [ebp+ebx+29h]
    mov     [edi+29h], dl
    mov     al, [ebp+ebx+152h]
    add     eax, 8
    push    eax
    push    esi
    call    sub_4B7F30
    mov     ecx, [esp+3D0h+var_3B0]
    mov     dx, [ecx]
    mov     [edi+2Fh], esi
    mov     [edi+15h], dx
    mov     cl, [ebp+ebx+152h]
    add     cl, 8
    mov     [edi+13Bh], cl
    mov     dl, [ebp+ebx+1]
    mov     [edi+1], dl
    mov     dword ptr [edi+1Bh], 2C00h
    mov     cx, [eax]
    mov     [edi+17h], cx
    mov     dx, [eax+2]
    xor     eax, eax
    mov     [edi+19h], dx
    mov     al, [ebp+ebx+152h]
    add     eax, 6
    push    eax
    push    esi
    call    sub_4B7F30
    mov     cx, [ebp+ebx+17h]
    lea     edx, [ebp+ebx+19h]
    mov     [esp+3D0h+var_3BC], edx
    mov     dx, [edx]
    cmp     cx, dx
    jle     short loc_4A8947
    mov     edx, [esp+3D0h+var_3C0]
    mov     dx, [edx]
    sub     dx, [eax]
    add     edx, ecx
    mov     [edi+13h], dx
    mov     cx, [eax]
    imul    cx, 0FEh
    add     [ebp+ebx+17h], cx
    mov     dx, [eax]
    mov     eax, [esp+3D0h+var_3C0]
    add     [eax], dx
    xor     eax, eax
    mov     al, [ebp+ebx+152h]
    add     eax, 5
    push    eax
    push    esi
    call    sub_4B7F30
    mov     ax, [eax]
    mov     [ebp+ebx+142h], ax
    mov     cx, [ebp+ebx+17h]
    sub     cx, ax
    sub     ecx, 4
    mov     [ebp+ebx+136h], cx
    jmp     loc_4A9045                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A8947:                             ; CODE XREF: sub_4A81E0+709j
    mov     ecx, [esp+3D0h+var_3B0]
    mov     si, [ecx]
    sub     si, [eax+2]
    add     esi, edx
    mov     edx, [esp+3D0h+var_3C0]
    mov     [edi+15h], si
    mov     dx, [edx]
    mov     [edi+13h], dx
    mov     si, [eax+2]
    imul    si, 0FEh
    mov     edx, [esp+3D0h+var_3BC]
    add     [edx], si
    mov     ax, [eax+2]
    add     [ecx], ax
    jmp     loc_4A9045                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A897E:                             ; CODE XREF: sub_4A81E0+54Aj
    mov     ax, [ebp+ebx+17h]
    mov     cx, [ebp+ebx+19h]
    cmp     ax, cx
    jg      short loc_4A898F
    mov     eax, ecx

    loc_4A898F:                             ; CODE XREF: sub_4A81E0+7ABj
    add     eax, 0FFFFFFFAh
    mov     [ebp+ebx+136h], ax
    jmp     loc_4A9045                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A899F:                             ; CODE XREF: sub_4A81E0+30Bj
                                            ; DATA XREF: .text:004A95F4o
    mov     ecx, [esp+3D0h+arg_0]           ; case 0x3
    mov     eax, [ecx+4]
    test    eax, eax
    jz      short loc_4A89BC
    push    offset aTextinput               ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    jmp     short loc_4A89BE
    ; ---------------------------------------------------------------------------

    loc_4A89BC:                             ; CODE XREF: sub_4A81E0+7CBj
    xor     esi, esi

    loc_4A89BE:                             ; CODE XREF: sub_4A81E0+7DAj
    test    esi, esi
    jz      short loc_4A89E4
    xor     edi, edi
    cmp     [esi], di
    jbe     short loc_4A89E4

    loc_4A89C9:                             ; CODE XREF: sub_4A81E0+802j
    push    edi
    push    esi
    call    sub_4B7F30
    xor     ecx, ecx
    xor     edx, edx
    mov     [eax+6], cx
    mov     [eax+4], cx
    mov     dx, [esi]
    inc     edi
    cmp     edi, edx
    jl      short loc_4A89C9

    loc_4A89E4:                             ; CODE XREF: sub_4A81E0+7E0j
                                            ; sub_4A81E0+7E7j
    mov     [ebp+ebx+13Ah], esi
    cmp     word ptr [ebp+ebx+138h], 80h
    jl      short loc_4A8A01
    mov     word ptr [ebp+ebx+138h], 7Fh

    loc_4A8A01:                             ; CODE XREF: sub_4A81E0+815j
    mov     ecx, 20h
    xor     eax, eax
    lea     edi, [ebp+ebx+0B6h]
    rep stosd
    jmp     loc_4A9045                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A8A16:                             ; CODE XREF: sub_4A81E0+30Bj
                                            ; DATA XREF: .text:004A95F4o
    mov     eax, [esp+3D0h+arg_0]           ; case 0x2
    mov     eax, [eax+4]
    test    eax, eax
    jz      short loc_4A8A33
    push    offset aListbox                 ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    jmp     short loc_4A8A35
    ; ---------------------------------------------------------------------------

    loc_4A8A33:                             ; CODE XREF: sub_4A81E0+842j
    xor     esi, esi

    loc_4A8A35:                             ; CODE XREF: sub_4A81E0+851j
    test    esi, esi
    jz      short loc_4A8A59
    xor     edi, edi
    cmp     [esi], di
    jbe     short loc_4A8A59

    loc_4A8A40:                             ; CODE XREF: sub_4A81E0+877j
    push    edi
    push    esi
    call    sub_4B7F30
    xor     ecx, ecx
    inc     edi
    mov     [eax+6], cx
    mov     [eax+4], cx
    mov     cx, [esi]
    cmp     edi, ecx
    jl      short loc_4A8A40

    loc_4A8A59:                             ; CODE XREF: sub_4A81E0+857j
                                            ; sub_4A81E0+85Ej
    mov     [ebp+ebx+0CAh], esi
    mov     esi, 1
    cmp     [ebp+0B6h], si
    jl      loc_4A9045                      ; default
    mov     edi, [esp+3D0h+var_3B4]
    lea     eax, [ebp+235h]

    loc_4A8A7C:                             ; CODE XREF: sub_4A81E0+8E3j
    cmp     esi, edi
    jz      short loc_4A8AB4
    cmp     byte ptr [eax-0DAh], 2
    jnz     short loc_4A8AB4
    mov     dl, [eax-0D9h]
    mov     cl, [ebp+ebx+1]
    cmp     dl, cl
    jnz     short loc_4A8AB4
    mov     cx, [eax]
    mov     dx, [ebp+ebx+0DAh]
    cmp     cx, dx
    jg      short loc_4A8AA9
    mov     ecx, edx

    loc_4A8AA9:                             ; CODE XREF: sub_4A81E0+8C5j
    mov     [ebp+ebx+0DAh], cx
    mov     [eax], cx

    loc_4A8AB4:                             ; CODE XREF: sub_4A81E0+89Ej
                                            ; sub_4A81E0+8A7j ...
    movsx   ecx, word ptr [ebp+0B6h]
    inc     esi
    add     eax, 15Bh
    cmp     esi, ecx
    jle     short loc_4A8A7C
    jmp     loc_4A9045                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A8ACA:                             ; CODE XREF: sub_4A81E0+30Bj
                                            ; DATA XREF: .text:004A95F4o
    lea     edx, [ebp+ebx+2]                ; case 0xc
    push    10h                             ; size_t
    lea     eax, [esp+3D4h+var_380]
    push    edx                             ; char *
    push    eax                             ; char *
    mov     dword ptr [ebp+ebx+1Fh], 0
    call    _strncpy
    lea     ebx, [ebp+ebx+0B8h]
    add     esp, 0Ch
    mov     [esp+3D0h+var_370], 0
    mov     dword ptr [ebx], 0
    mov     eax, [ebp+0C0h]
    test    eax, eax
    jz      short loc_4A8B13
    lea     ecx, [esp+3D0h+var_380]
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     [esp+3D0h+var_3C0], eax
    jmp     short loc_4A8B17
    ; ---------------------------------------------------------------------------

    loc_4A8B13:                             ; CODE XREF: sub_4A81E0+920j
    mov     eax, [esp+3D0h+var_3C0]

    loc_4A8B17:                             ; CODE XREF: sub_4A81E0+931j
    test    eax, eax
    jnz     short loc_4A8B3C
    mov     eax, [esp+3D0h+arg_0]
    lea     edx, [esp+3D0h+var_380]
    push    edx                             ; char *
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4B8D40
    test    eax, eax
    mov     [esp+3D0h+var_3C0], eax
    jz      loc_4A9045                      ; default

    loc_4A8B3C:                             ; CODE XREF: sub_4A81E0+939j
    push    0
    push    eax
    call    sub_4B7F30
    mov     [ebx], eax
    jmp     loc_4A9045                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A8B4B:                             ; CODE XREF: sub_4A81E0+30Bj
                                            ; DATA XREF: .text:004A95F4o
    mov     ecx, [ebp+ebx+1Bh]              ; case 0x1
    lea     eax, [ebp+ebx+1Bh]
    test    ch, 18h
    mov     dword ptr [ebp+ebx+1Fh], 0
    mov     [esp+3D0h+var_3B0], eax
    jnz     loc_4A9045                      ; default
    test    byte ptr [ebp+ebx+0B4h], 1
    jnz     loc_4A9045                      ; default
    mov     edx, [esp+3D0h+var_3B4]
    mov     eax, [esp+3D0h+arg_0]
    push    edx
    push    eax
    call    sub_4A05E0
    lea     ecx, [ebp+ebx+2]
    push    10h                             ; size_t
    lea     edx, [esp+3D4h+var_380]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    mov     byte ptr [ebp+ebx+13Bh], 0
    mov     eax, [ebp+0C0h]
    add     esp, 0Ch
    mov     [esp+3D0h+var_370], 0
    test    eax, eax
    jz      short loc_4A8BC6
    lea     ecx, [esp+3D0h+var_380]
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    mov     [esp+3D0h+var_3C0], esi
    jmp     short loc_4A8BCA
    ; ---------------------------------------------------------------------------

    loc_4A8BC6:                             ; CODE XREF: sub_4A81E0+9D1j
    mov     esi, [esp+3D0h+var_3C0]

    loc_4A8BCA:                             ; CODE XREF: sub_4A81E0+9E4j
    test    esi, esi
    jnz     loc_4A8DCB
    mov     edx, [esp+3D0h+arg_0]
    mov     eax, [edx+4]
    test    eax, eax
    jz      loc_4A8DCB
    lea     ecx, [esp+3D0h+var_380]
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    test    esi, esi
    mov     [esp+3D0h+var_3C0], esi
    jnz     loc_4A8DCB
    test    byte ptr [ebp+ebx+1Bh], 80h
    jz      short loc_4A8C0E
    push    offset aCheckbox                ; "CHECKBOX"
    jmp     loc_4A8CCD
    ; ---------------------------------------------------------------------------

    loc_4A8C0E:                             ; CODE XREF: sub_4A81E0+A22j
    mov     cl, [ebp+ebx+136h]
    test    cl, cl
    jz      loc_4A8CE5
    mov     edi, offset aOffOn              ; "Off|On"
    lea     esi, [ebp+ebx+0B6h]

    loc_4A8C29:                             ; CODE XREF: sub_4A81E0+A67j
    mov     dl, [esi]
    mov     al, dl
    cmp     dl, [edi]
    jnz     short loc_4A8C4D
    test    al, al
    jz      short loc_4A8C49
    mov     dl, [esi+1]
    mov     al, dl
    cmp     dl, [edi+1]
    jnz     short loc_4A8C4D
    add     esi, 2
    add     edi, 2
    test    al, al
    jnz     short loc_4A8C29

    loc_4A8C49:                             ; CODE XREF: sub_4A81E0+A53j
    xor     eax, eax
    jmp     short loc_4A8C52
    ; ---------------------------------------------------------------------------

    loc_4A8C4D:                             ; CODE XREF: sub_4A81E0+A4Fj
                                            ; sub_4A81E0+A5Dj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4A8C52:                             ; CODE XREF: sub_4A81E0+A6Bj
    test    eax, eax
    jz      short loc_4A8C8F
    cmp     cl, 1
    jz      short loc_4A8C8F
    mov     eax, [esp+3D0h+var_3B0]
    mov     edx, [eax]
    test    dh, 40h
    jnz     short loc_4A8C8F
    cmp     cl, 4
    jnb     short loc_4A8C75
    and     ecx, 0FFh
    mov     eax, ecx
    jmp     short loc_4A8C7A
    ; ---------------------------------------------------------------------------

    loc_4A8C75:                             ; CODE XREF: sub_4A81E0+A89j
    mov     eax, 4

    loc_4A8C7A:                             ; CODE XREF: sub_4A81E0+A93j
    push    eax
    lea     ecx, [esp+3D4h+var_3A0]
    push    offset aStagebuttnD             ; "stagebuttn%d"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    jmp     short loc_4A8CC8
    ; ---------------------------------------------------------------------------

    loc_4A8C8F:                             ; CODE XREF: sub_4A81E0+A74j
                                            ; sub_4A81E0+A79j ...
    mov     edi, offset aStagebuttn1        ; "stagebuttn1"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     byte ptr [ebp+ebx+136h], 2
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+3D0h+var_3A0]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+3D0h+var_3B0]
    and     ecx, 3
    rep movsb
    mov     ecx, [eax]
    or      ch, 40h
    mov     [eax], ecx

    loc_4A8CC8:                             ; CODE XREF: sub_4A81E0+AADj
    lea     ecx, [esp+3D0h+var_3A0]
    push    ecx                             ; char *

    loc_4A8CCD:                             ; CODE XREF: sub_4A81E0+A29j
    mov     edx, [esp+3D4h+arg_0]
    mov     eax, [edx+4]
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    mov     [esp+3D0h+var_3C0], esi
    jmp     short loc_4A8D26
    ; ---------------------------------------------------------------------------

    loc_4A8CE5:                             ; CODE XREF: sub_4A81E0+A37j
    mov     edi, offset aButtons0           ; "BUTTONS0"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+3D0h+var_3A0]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, [esp+3D0h+arg_0]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [edx+4]
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+3D0h+var_3A0]
    push    ecx                             ; char *
    push    eax                             ; int
    call    sub_4B8D40
    mov     esi, eax
    mov     [esp+3D0h+var_3C0], eax

    loc_4A8D26:                             ; CODE XREF: sub_4A81E0+B03j
    test    esi, esi
    jz      loc_4A8DCB
    xor     edi, edi
    mov     [esp+3D0h+var_3BC], 3E8h
    cmp     [esi], di
    jbe     short loc_4A8D5C

    loc_4A8D3D:                             ; CODE XREF: sub_4A81E0+B7Aj
    push    edi
    push    esi
    call    sub_4B7F30
    xor     ecx, ecx
    cmp     eax, ecx
    jz      short loc_4A8D52
    mov     [eax+6], cx
    mov     [eax+4], cx

    loc_4A8D52:                             ; CODE XREF: sub_4A81E0+B68j
    xor     ecx, ecx
    inc     edi
    mov     cx, [esi]
    cmp     edi, ecx
    jl      short loc_4A8D3D

    loc_4A8D5C:                             ; CODE XREF: sub_4A81E0+B5Bj
    cmp     word ptr [esi], 0
    mov     [esp+3D0h+var_3C0], 0
    jbe     short loc_4A8DCB

    loc_4A8D6A:                             ; CODE XREF: sub_4A81E0+BE9j
    mov     edx, [esp+3D0h+var_3C0]
    push    edx
    push    esi
    call    sub_4B7F30
    mov     edi, eax
    xor     eax, eax
    mov     ax, [edi+2]
    mov     ecx, eax
    movsx   eax, word ptr [ebp+ebx+19h]
    sub     eax, ecx
    cdq
    mov     ecx, eax
    movsx   eax, word ptr [ebp+ebx+17h]
    xor     ecx, edx
    sub     ecx, edx
    xor     edx, edx
    mov     dx, [edi]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    add     ecx, eax
    mov     eax, [esp+3D0h+var_3BC]
    cmp     ecx, eax
    jge     short loc_4A8DB7
    mov     al, byte ptr [esp+3D0h+var_3C0]
    mov     [esp+3D0h+var_3BC], ecx
    mov     [ebp+ebx+13Bh], al

    loc_4A8DB7:                             ; CODE XREF: sub_4A81E0+BC6j
    mov     eax, [esp+3D0h+var_3C0]
    xor     ecx, ecx
    mov     cx, [esi]
    add     eax, 4
    cmp     eax, ecx
    mov     [esp+3D0h+var_3C0], eax
    jl      short loc_4A8D6A

    loc_4A8DCB:                             ; CODE XREF: sub_4A81E0+9ECj
                                            ; sub_4A81E0+9FEj ...
    test    esi, esi
    mov     [ebp+ebx+2Fh], esi
    jz      short loc_4A8DF8
    xor     edx, edx
    mov     dl, [ebp+ebx+13Bh]
    push    edx
    push    esi
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4A8DF8
    mov     cx, [eax]
    mov     [ebp+ebx+17h], cx
    mov     dx, [eax+2]
    mov     [ebp+ebx+19h], dx

    loc_4A8DF8:                             ; CODE XREF: sub_4A81E0+BF1j
                                            ; sub_4A81E0+C05j
    mov     al, [ebp+ebx+136h]
    test    al, al
    jz      loc_4A9045                      ; default
    mov     al, [ebp+ebx+0B6h]
    lea     ecx, [ebp+ebx+0B6h]
    test    al, al
    jz      short loc_4A8E28

    loc_4A8E19:                             ; CODE XREF: sub_4A81E0+C46j
    cmp     al, 7Ch
    jnz     short loc_4A8E20
    mov     byte ptr [ecx], 0

    loc_4A8E20:                             ; CODE XREF: sub_4A81E0+C3Bj
    mov     al, [ecx+1]
    inc     ecx
    test    al, al
    jnz     short loc_4A8E19

    loc_4A8E28:                             ; CODE XREF: sub_4A81E0+C37j
    mov     eax, [esp+3D0h+arg_0]
    mov     [esp+3D0h+var_3BC], 0
    mov     ecx, [eax+18h]
    mov     eax, [ecx+4]
    mov     cl, [eax+ebx+136h]
    add     eax, ebx
    lea     ebx, [esp+3D0h+var_80]
    test    cl, cl
    lea     edi, [eax+0B6h]
    mov     [esp+3D0h+var_3A8], eax
    mov     [esp+3D0h+var_3AC], edi
    mov     [esp+3D0h+var_3C0], edi
    jbe     short loc_4A8ECF

    loc_4A8E63:                             ; CODE XREF: sub_4A81E0+CE9j
    mov     edx, [esp+3D0h+var_3C0]
    push    edx                             ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [esp+3D0h+var_3C0]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, edx
    lea     ebx, [ebx+ecx+1]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    mov     eax, [esp+3D0h+var_3BC]
    dec     ecx
    inc     eax
    lea     ecx, [edx+ecx+1]
    xor     edx, edx
    mov     [esp+3D0h+var_3C0], ecx
    mov     ecx, [esp+3D0h+var_3A8]
    mov     [esp+3D0h+var_3BC], eax
    mov     dl, [ecx+136h]
    cmp     eax, edx
    jl      short loc_4A8E63
    mov     edi, [esp+3D0h+var_3AC]

    loc_4A8ECF:                             ; CODE XREF: sub_4A81E0+C81j
    mov     eax, [esp+3D0h+var_3B0]
    mov     ecx, 20h
    lea     esi, [esp+3D0h+var_80]
    rep movsd
    mov     edx, [eax]
    and     edx, 4000h
    or      edx, 1
    mov     [eax], edx
    jmp     loc_4A9045                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A8EF3:                             ; CODE XREF: sub_4A81E0+30Bj
                                            ; DATA XREF: .text:004A95F4o
    mov     eax, [esp+3D0h+arg_0]           ; case 0x7
    or      ecx, 0FFFFFFFFh
    lea     edx, [esp+3D0h+var_180]
    lea     edi, [eax+0BB6h]
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+3D0h+var_180]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    push    eax
    rep movsb
    lea     edi, [ebp+ebx+0B6h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     edx, [esp+3D4h+var_180]
    and     ecx, 3
    rep movsb
    mov     edi, offset a_fnt               ; ".FNT"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     eax, [esp+3D4h+var_180]
    and     ecx, 3
    push    eax
    rep movsb
    call    sub_4BBE50
    mov     [ebp+ebx+0D6h], eax
    jmp     loc_4A9045                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A8FA0:                             ; CODE XREF: sub_4A81E0+30Bj
                                            ; DATA XREF: .text:004A95F4o
    lea     edi, [ebp+ebx+0B6h]             ; case 0x8
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+3D0h+var_180]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    eax
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     eax, [esp+3D4h+var_180]
    and     ecx, 3
    push    eax
    rep movsb
    call    sub_4BBE50
    mov     [ebp+ebx+0D6h], eax
    jmp     short loc_4A9045                ; default
    ; ---------------------------------------------------------------------------

    loc_4A8FEA:                             ; CODE XREF: sub_4A81E0+30Bj
                                            ; DATA XREF: .text:004A95F4o
    mov     ecx, [esp+3D0h+arg_0]           ; case 0xd
    mov     edx, [ecx+18h]
    mov     esi, [edx+4]
    call    sub_4B6340
    add     eax, [esi+ebx+0C2h]
    mov     [esi+ebx+0C6h], eax
    jmp     short loc_4A9045                ; default
    ; ---------------------------------------------------------------------------

    loc_4A900C:                             ; CODE XREF: sub_4A81E0+30Bj
                                            ; DATA XREF: .text:004A95F4o
    lea     edi, [ebp+ebx+136h]             ; case 0x5
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_4A902B
    mov     eax, [ebp+ebx+1Bh]
    or      al, 10h
    mov     [ebp+ebx+1Bh], eax
    jmp     short loc_4A903D
    ; ---------------------------------------------------------------------------

    loc_4A902B:                             ; CODE XREF: sub_4A81E0+E3Dj
    mov     eax, [esp+3D0h+var_3B4]
    mov     ecx, [esp+3D0h+arg_0]
    push    eax
    push    ecx
    call    sub_4A05E0

    loc_4A903D:                             ; CODE XREF: sub_4A81E0+E49j
    mov     dword ptr [ebp+ebx+1Fh], 0

    loc_4A9045:                             ; CODE XREF: sub_4A81E0+305j
                                            ; sub_4A81E0+30Bj ...
    movsx   edx, word ptr [ebp+0B6h]        ; default
    mov     eax, [esp+3D0h+var_3B4]
    inc     eax
    inc     edx
    cmp     eax, edx
    mov     [esp+3D0h+var_3B4], eax
    jl      loc_4A838D
    mov     ebx, [esp+3D0h+arg_4]

    loc_4A9065:                             ; CODE XREF: sub_4A81E0+194j
    lea     eax, [ebp+2]
    test    eax, eax
    jnz     short loc_4A9071
    mov     eax, offset aGuiSurface         ; "GUI SURFACE"

    loc_4A9071:                             ; CODE XREF: sub_4A81E0+E8Aj
    movsx   ecx, word ptr [ebp+19h]
    movsx   edx, word ptr [ebp+17h]
    push    ecx                             ; int
    push    edx                             ; int
    push    eax                             ; int
    call    sub_4C69F0
    movsx   ecx, word ptr [ebp+15h]
    movsx   edx, word ptr [ebp+13h]
    neg     ecx
    neg     edx
    push    ecx
    push    edx
    push    0
    push    eax
    mov     [ebp+0BCh], eax
    call    sub_4C6B70
    test    bl, 20h
    jnz     loc_4A95D4
    movsx   eax, word ptr [ebp+19h]
    movsx   ecx, word ptr [ebp+17h]
    push    eax                             ; int
    push    ecx                             ; int
    push    offset aSaveUnder               ; int
    call    sub_4C69F0
    mov     edx, [ebp+0BCh]
    push    0
    push    0
    push    edx
    push    eax
    mov     [ebp+0B8h], eax
    call    sub_4C6B70

    loc_4A90D1:                             ; CODE XREF: sub_4A81E0+117j
                                            ; sub_4A81E0+13FEj
    test    bl, 4
    jnz     short loc_4A90E7
    mov     eax, [esp+3D0h+var_3B8]
    test    eax, eax
    jnz     short loc_4A90F4
    test    bl, 40h
    jz      loc_4A950A

    loc_4A90E7:                             ; CODE XREF: sub_4A81E0+EF4j
    mov     eax, [esp+3D0h+var_3B8]
    test    eax, eax
    jnz     short loc_4A90F4
    test    bl, 40h
    jz      short loc_4A912E

    loc_4A90F4:                             ; CODE XREF: sub_4A81E0+EFCj
                                            ; sub_4A81E0+F0Dj
    mov     esi, [esp+3D0h+arg_0]
    mov     eax, [esi+18h]
    mov     eax, [eax+24h]
    test    eax, eax
    jz      short loc_4A9118
    mov     ecx, [ebp+0BCh]
    push    0
    push    0
    push    eax
    push    ecx
    call    sub_4C6B70
    jmp     short loc_4A9135
    ; ---------------------------------------------------------------------------

    loc_4A9118:                             ; CODE XREF: sub_4A81E0+F23j
    test    bl, 80h
    jnz     short loc_4A9135
    mov     edx, [ebp+0C4h]
    push    edx
    push    0
    push    esi
    call    sub_4B0230
    jmp     short loc_4A9135
    ; ---------------------------------------------------------------------------

    loc_4A912E:                             ; CODE XREF: sub_4A81E0+F12j
    mov     esi, [esp+3D0h+arg_0]

    loc_4A9135:                             ; CODE XREF: sub_4A81E0+F36j
                                            ; sub_4A81E0+F3Bj ...
    movsx   eax, word ptr [ebp+0B6h]
    mov     edi, 1
    inc     eax
    cmp     eax, edi
    mov     [esp+3D0h+var_3B4], edi
    jle     loc_4A943B
    lea     eax, [ebp+21Fh]
    mov     ebx, 15Bh
    mov     [esp+3D0h+var_3C0], eax

    loc_4A915D:                             ; CODE XREF: sub_4A81E0+124Ej
    mov     cl, [eax-9Bh]
    test    cl, cl
    jz      loc_4A940C                      ; default
    xor     ecx, ecx
    mov     cl, [eax-0C4h]
    mov     eax, ecx
    dec     eax
    cmp     eax, 0Ch                        ; switch 13 cases
    ja      loc_4A940C                      ; default
    jmp     ds:off_4A962C[eax*4]            ; switch jump

    loc_4A9186:                             ; DATA XREF: .text:004A962Co
    mov     edx, [esp+3D0h+var_3C0]         ; case 0xa
    mov     eax, [edx]
    push    eax
    push    edi
    push    esi
    call    sub_4B0230
    jmp     loc_4A940C                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A9199:                             ; CODE XREF: sub_4A81E0+F9Fj
                                            ; DATA XREF: .text:004A962Co
    push    edi                             ; case 0xb
    push    esi
    call    sub_4A5E50
    jmp     loc_4A940C                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A91A5:                             ; CODE XREF: sub_4A81E0+F9Fj
                                            ; DATA XREF: .text:004A962Co
    mov     eax, [esp+3D0h+var_3B8]         ; case 0x0
    test    eax, eax
    jnz     short loc_4A91BB
    test    byte ptr [esp+3D0h+arg_4], 48h
    jz      loc_4A940C                      ; default

    loc_4A91BB:                             ; CODE XREF: sub_4A81E0+FCBj
    push    edi
    push    esi
    call    sub_4A5F40
    jmp     loc_4A940C                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A91C7:                             ; CODE XREF: sub_4A81E0+F9Fj
                                            ; DATA XREF: .text:004A962Co
    mov     eax, [esp+3D0h+var_3B8]         ; case 0x1
    test    eax, eax
    jz      loc_4A92C5
    mov     ecx, [esp+3D0h+arg_0]
    xor     eax, eax
    mov     [esp+3D0h+var_3B0], eax
    mov     edi, 1
    mov     edx, [ecx+18h]
    mov     esi, [edx+4]
    mov     [esi+ebx+0BCh], ax
    mov     [esi+ebx+0BAh], ax
    movsx   eax, word ptr [esi+0B6h]
    inc     eax
    cmp     eax, edi
    jle     short loc_4A924F
    lea     ecx, [esi+15Bh]

    loc_4A920D:                             ; CODE XREF: sub_4A81E0+104Aj
    cmp     byte ptr [ecx], 7
    jnz     short loc_4A9221
    movsx   edx, byte ptr [esi+ebx+28h]
    cmp     [esp+3D0h+var_3B0], edx
    jz      short loc_4A922E
    inc     [esp+3D0h+var_3B0]

    loc_4A9221:                             ; CODE XREF: sub_4A81E0+1030j
    inc     edi
    add     ecx, 15Bh
    cmp     edi, eax
    jl      short loc_4A920D
    jmp     short loc_4A924F
    ; ---------------------------------------------------------------------------

    loc_4A922E:                             ; CODE XREF: sub_4A81E0+103Bj
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    mov     eax, esi
    add     eax, edi
    lea     edx, [edi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A924F:                             ; CODE XREF: sub_4A81E0+1025j
                                            ; sub_4A81E0+104Cj
    movsx   edx, word ptr [esi+0B6h]
    inc     edx
    cmp     edi, edx
    jnz     short loc_4A9268
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A9268:                             ; CODE XREF: sub_4A81E0+1079j
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A927C
    call    sub_4C1450
    jmp     short loc_4A9292
    ; ---------------------------------------------------------------------------

    loc_4A927C:                             ; CODE XREF: sub_4A81E0+1093j
    mov     eax, [eax+0Ch]
    push    49h
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A9292:                             ; CODE XREF: sub_4A81E0+109Aj
    movsx   ecx, word ptr [esi+ebx+19h]
    lea     edi, [eax+2]
    mov     eax, ecx
    cdq
    idiv    edi
    sub     ecx, edx
    mov     [esi+ebx+19h], cx
    call    sub_4B6340
    mov     edi, [esp+3D0h+var_3B4]
    mov     [esi+ebx+0B6h], eax
    mov     eax, [esp+3D0h+var_3B8]
    mov     esi, [esp+3D0h+arg_0]
    test    eax, eax
    jnz     short loc_4A92D3

    loc_4A92C5:                             ; CODE XREF: sub_4A81E0+FEDj
    test    byte ptr [esp+3D0h+arg_4], 40h
    jz      loc_4A940C                      ; default

    loc_4A92D3:                             ; CODE XREF: sub_4A81E0+10E3j
    push    edi
    push    esi
    call    sub_4A1B40
    jmp     loc_4A940C                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A92DF:                             ; CODE XREF: sub_4A81E0+F9Fj
                                            ; DATA XREF: .text:004A962Co
    mov     eax, [esp+3D0h+var_3B8]         ; case 0x2
    test    eax, eax
    jnz     short loc_4A92F5
    test    byte ptr [esp+3D0h+arg_4], 40h
    jz      loc_4A940C                      ; default

    loc_4A92F5:                             ; CODE XREF: sub_4A81E0+1105j
    push    edi
    push    esi
    call    sub_4A4D70
    jmp     loc_4A940C                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A9301:                             ; CODE XREF: sub_4A81E0+F9Fj
                                            ; DATA XREF: .text:004A962Co
    mov     ecx, [esp+3D0h+var_3B8]         ; case 0x3
    xor     edx, edx
    cmp     ecx, edx
    jz      short loc_4A932B
    mov     eax, [esi+18h]
    cmp     ecx, edx
    mov     eax, [eax+4]
    mov     [eax+ebx+140h], dx
    mov     [eax+ebx+144h], edx
    mov     [eax+ebx+14Ah], edx
    jnz     short loc_4A9339

    loc_4A932B:                             ; CODE XREF: sub_4A81E0+1129j
    test    byte ptr [esp+3D0h+arg_4], 40h
    jz      loc_4A940C                      ; default

    loc_4A9339:                             ; CODE XREF: sub_4A81E0+1149j
    push    edi
    push    esi
    call    sub_4A3EF0
    jmp     loc_4A940C                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A9345:                             ; CODE XREF: sub_4A81E0+F9Fj
                                            ; DATA XREF: .text:004A962Co
    mov     eax, [esp+3D0h+var_3B8]         ; case 0x4
    test    eax, eax
    jnz     short loc_4A935B
    test    byte ptr [esp+3D0h+arg_4], 40h
    jz      loc_4A940C                      ; default

    loc_4A935B:                             ; CODE XREF: sub_4A81E0+116Bj
    push    edi
    push    esi
    call    sub_4A56B0
    jmp     loc_4A940C                      ; default
    ; ---------------------------------------------------------------------------

    loc_4A9367:                             ; CODE XREF: sub_4A81E0+F9Fj
                                            ; DATA XREF: .text:004A962Co
    mov     ecx, [esp+3D0h+var_3B8]         ; case 0x5
    xor     edx, edx
    cmp     ecx, edx
    jz      short loc_4A9398
    mov     eax, [esi+18h]
    cmp     ecx, edx
    mov     eax, [eax+4]
    mov     [eax+ebx+0B6h], edx
    mov     [eax+ebx+0BEh], edx
    mov     [eax+ebx+0C2h], edx
    mov     [eax+ebx+0C6h], dx
    jnz     short loc_4A93A2

    loc_4A9398:                             ; CODE XREF: sub_4A81E0+118Fj
    test    byte ptr [esp+3D0h+arg_4], 40h
    jz      short loc_4A940C                ; default

    loc_4A93A2:                             ; CODE XREF: sub_4A81E0+11B6j
    push    edi
    push    esi
    call    sub_4A4980
    jmp     short loc_4A940C                ; default
    ; ---------------------------------------------------------------------------

    loc_4A93AB:                             ; CODE XREF: sub_4A81E0+F9Fj
                                            ; DATA XREF: .text:004A962Co
    mov     eax, [esp+3D0h+var_3B8]         ; case 0xc
    test    eax, eax
    jz      short loc_4A93D8
    mov     ecx, [esi+18h]
    mov     edi, [ecx+4]
    call    sub_4B6340
    add     eax, [edi+ebx+0C2h]
    mov     [edi+ebx+0C6h], eax
    mov     eax, [esp+3D0h+var_3B8]
    mov     edi, [esp+3D0h+var_3B4]
    test    eax, eax
    jnz     short loc_4A93E2

    loc_4A93D8:                             ; CODE XREF: sub_4A81E0+11D1j
    test    byte ptr [esp+3D0h+arg_4], 40h
    jz      short loc_4A940C                ; default

    loc_4A93E2:                             ; CODE XREF: sub_4A81E0+11F6j
    push    edi
    push    esi
    call    sub_4A4660
    jmp     short loc_4A940C                ; default
    ; ---------------------------------------------------------------------------

    loc_4A93EB:                             ; CODE XREF: sub_4A81E0+F9Fj
                                            ; DATA XREF: .text:004A962Co
    mov     eax, [esp+3D0h+var_3B8]         ; case 0x9
    test    eax, eax
    jnz     short loc_4A93FD
    test    byte ptr [esp+3D0h+arg_4], 40h
    jz      short loc_4A940C                ; default

    loc_4A93FD:                             ; CODE XREF: sub_4A81E0+1211j
    mov     edx, [esp+3D0h+arg_4]
    push    edx
    push    edi
    push    esi
    call    sub_4A4C90

    loc_4A940C:                             ; CODE XREF: sub_4A81E0+F85j
                                            ; sub_4A81E0+F99j ...
    movsx   ecx, word ptr [ebp+0B6h]        ; default
    mov     eax, [esp+3D0h+var_3C0]
    inc     edi
    add     ebx, 15Bh
    add     eax, 15Bh
    inc     ecx
    mov     [esp+3D0h+var_3B4], edi
    cmp     edi, ecx
    mov     [esp+3D0h+var_3C0], eax
    jl      loc_4A915D
    mov     ebx, [esp+3D0h+arg_4]

    loc_4A943B:                             ; CODE XREF: sub_4A81E0+F68j
    mov     edx, [esi+18h]
    mov     eax, [edx+20h]
    cmp     eax, 0FFFFFFFFh
    jz      loc_4A950A
    mov     ecx, [esi+0A2h]
    test    ecx, ecx
    jz      loc_4A950A
    lea     ecx, ds:0[eax*8]
    push    8
    sub     ecx, eax
    push    eax
    push    esi
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    xor     ecx, ecx
    lea     edi, [eax+edx*4]
    lea     edx, [ebp+eax+0]
    mov     cl, [edx+edi*2]
    mov     [esp+3DCh+var_3AC], ecx
    call    sub_4A16F0
    movsx   eax, word ptr [ebp+0B6h]
    mov     edi, 1
    inc     eax
    cmp     eax, edi
    jle     short loc_4A94D2
    lea     ebx, [ebp+15Dh]

    loc_4A9497:                             ; CODE XREF: sub_4A81E0+12DEj
    lea     eax, [ebp+0CCh]
    push    10h                             ; size_t
    push    eax                             ; char *
    push    ebx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A94C9
    movsx   ecx, word ptr [ebp+0B6h]
    inc     edi
    add     ebx, 15Bh
    inc     ecx
    cmp     edi, ecx
    jl      short loc_4A9497
    mov     ebx, [esp+3D0h+arg_4]
    jmp     short loc_4A94D2
    ; ---------------------------------------------------------------------------

    loc_4A94C9:                             ; CODE XREF: sub_4A81E0+12CBj
    mov     ebx, [esp+3D0h+arg_4]
    jmp     short loc_4A94D5
    ; ---------------------------------------------------------------------------

    loc_4A94D2:                             ; CODE XREF: sub_4A81E0+12AFj
                                            ; sub_4A81E0+12E7j
    or      edi, 0FFFFFFFFh

    loc_4A94D5:                             ; CODE XREF: sub_4A81E0+12F0j
    cmp     edi, 0FFFFFFFFh
    jz      short loc_4A950A
    cmp     [esp+3D0h+var_3AC], 1
    jz      short loc_4A950A
    mov     ecx, [esp+3D0h+var_3B4]
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     edx, [eax+eax*2]
    lea     eax, [ecx+edx*2]
    lea     edx, [ecx+eax*4]
    mov     eax, ebp
    add     eax, ecx
    mov     cl, [eax+edx*2+29h]
    test    cl, cl
    jz      short loc_4A950A
    push    8
    push    edi
    push    esi
    call    sub_4A16F0

    loc_4A950A:                             ; CODE XREF: sub_4A81E0+F01j
                                            ; sub_4A81E0+1264j ...
    test    bl, 2
    jz      loc_4A95C2
    mov     eax, [ebp+0B8h]
    xor     ebx, ebx
    cmp     eax, ebx
    jz      short loc_4A9542
    movsx   ecx, word ptr [ebp+15h]
    movsx   edx, word ptr [ebp+13h]
    push    ecx
    push    edx
    push    eax
    push    ebx
    call    sub_4C6B70
    mov     eax, [ebp+0B8h]
    push    eax
    call    sub_4C6AC0
    mov     [ebp+0B8h], ebx

    loc_4A9542:                             ; CODE XREF: sub_4A81E0+133Dj
    mov     ecx, [ebp+0BCh]
    push    ecx
    call    sub_4C6AC0
    movsx   edx, word ptr [ebp+0B6h]
    xor     edi, edi
    inc     edx
    test    edx, edx
    mov     [ebp+0BCh], ebx
    jle     short loc_4A95C2
    lea     esi, [ebp+2Bh]

    loc_4A9565:                             ; CODE XREF: sub_4A81E0+13E0j
    test    byte ptr [esi+89h], 1
    jz      short loc_4A957D
    mov     eax, [esi]
    cmp     eax, ebx
    jz      short loc_4A957D
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4A957D:                             ; CODE XREF: sub_4A81E0+138Cj
                                            ; sub_4A81E0+1392j
    xor     eax, eax
    mov     al, [esi-2Bh]
    sub     eax, ebx
    jz      short loc_4A95A0
    sub     eax, 7
    jz      short loc_4A9597
    dec     eax
    jnz     short loc_4A95AF
    mov     eax, [esi+0ABh]
    push    eax
    jmp     short loc_4A95A7
    ; ---------------------------------------------------------------------------

    loc_4A9597:                             ; CODE XREF: sub_4A81E0+13A9j
    mov     ecx, [esi+0ABh]
    push    ecx
    jmp     short loc_4A95A7
    ; ---------------------------------------------------------------------------

    loc_4A95A0:                             ; CODE XREF: sub_4A81E0+13A4j
    mov     edx, [esi+95h]
    push    edx                             ; int

    loc_4A95A7:                             ; CODE XREF: sub_4A81E0+13B5j
                                            ; sub_4A81E0+13BEj
    call    sub_4D85A0
    add     esp, 4

    loc_4A95AF:                             ; CODE XREF: sub_4A81E0+13ACj
    movsx   eax, word ptr [ebp+0B6h]
    inc     edi
    add     esi, 15Bh
    inc     eax
    cmp     edi, eax
    jl      short loc_4A9565

    loc_4A95C2:                             ; CODE XREF: sub_4A81E0+132Dj
                                            ; sub_4A81E0+1380j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3C0h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A95D4:                             ; CODE XREF: sub_4A81E0+EC0j
    mov     dword ptr [ebp+0B8h], 0
    jmp     loc_4A90D1
    ; ---------------------------------------------------------------------------

    loc_4A95E3:                             ; CODE XREF: sub_4A81E0+169j
                                            ; sub_4A81E0+17Aj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 3C0h
    retn    8
    sub_4A81E0 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4A95F4 dd offset loc_4A84F2         ; DATA XREF: sub_4A81E0+30Br
    dd offset loc_4A8B4B                    ; jump table for switch statement
    dd offset loc_4A8A16
    dd offset loc_4A899F
    dd offset loc_4A8663
    dd offset loc_4A900C
    dd offset loc_4A9045
    dd offset loc_4A8EF3
    dd offset loc_4A8FA0
    dd offset loc_4A9045
    dd offset loc_4A9045
    dd offset loc_4A84F2
    dd offset loc_4A8ACA
    dd offset loc_4A8FEA
    off_4A962C dd offset loc_4A91A5         ; DATA XREF: sub_4A81E0+F9Fr
    dd offset loc_4A91C7                    ; jump table for switch statement
    dd offset loc_4A92DF
    dd offset loc_4A9301
    dd offset loc_4A9345
    dd offset loc_4A9367
    dd offset loc_4A940C
    dd offset loc_4A940C
    dd offset loc_4A940C
    dd offset loc_4A93EB
    dd offset loc_4A9186
    dd offset loc_4A9199
    dd offset loc_4A93AB

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A9660 proc near                    ; CODE XREF: .text:004263CEp
                                            ; sub_440D70+2DDp ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+18h]
    test    eax, eax
    jz      short loc_4A96C7
    mov     edi, [eax+10h]
    or      eax, 0FFFFFFFFh
    mov     [esi+64h], eax
    mov     [esi+60h], eax
    mov     [esi+68h], eax
    mov     eax, [esi+18h]
    mov     eax, [eax+8]
    test    eax, eax
    jz      short loc_4A9689
    push    esi
    call    eax

    loc_4A9689:                             ; CODE XREF: sub_4A9660+24j
    call    sub_4C2470
    push    2
    push    esi
    call    sub_4A81E0
    call    sub_4C2870
    mov     ecx, [esi+18h]
    mov     eax, [ecx]
    test    eax, eax
    mov     [esi+18h], eax
    jz      short loc_4A96AE
    mov     dword ptr [eax+14h], 1

    loc_4A96AE:                             ; CODE XREF: sub_4A9660+45j
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    test    edi, 800h
    jz      short loc_4A96C7
    push    40h
    push    esi
    call    sub_4A81E0

    loc_4A96C7:                             ; CODE XREF: sub_4A9660+Bj
                                            ; sub_4A9660+5Dj
    pop     edi
    pop     esi
    retn    4
    sub_4A9660 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A96D0 proc near                    ; CODE XREF: sub_4A9B90+286p

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_4]
    mov     ebx, [esp+arg_0]
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    mov     ecx, [ebx+18h]
    lea     edx, [eax+eax*2]
    mov     esi, [ecx+4]
    lea     eax, [edi+edx*2]
    lea     edx, [edi+eax*4]
    lea     eax, [edi+edx*2]
    add     esi, eax
    mov     ax, [esi+140h]
    mov     cx, [esi+136h]
    movsx   edx, ax
    dec     eax
    movsx   ebp, cx
    mov     [esi+140h], ax
    dec     ebp
    movsx   eax, ax
    cmp     eax, ebp
    jle     short loc_4A9723
    dec     ecx
    mov     [esi+140h], cx

    loc_4A9723:                             ; CODE XREF: sub_4A96D0+49j
    cmp     word ptr [esi+140h], 0
    jge     short loc_4A9736
    mov     word ptr [esi+140h], 0

    loc_4A9736:                             ; CODE XREF: sub_4A96D0+5Bj
    movsx   ecx, word ptr [esi+140h]
    cmp     ecx, edx
    jz      short loc_4A9759
    push    edi
    push    ebx
    mov     dword ptr [ebx+0CCAh], 1
    call    sub_4A2580
    push    edi
    push    ebx
    call    sub_4A2BE0

    loc_4A9759:                             ; CODE XREF: sub_4A96D0+6Fj
    mov     eax, [esi+144h]
    test    eax, eax
    jz      short loc_4A976D
    mov     edx, [esi+14Ah]
    push    edx
    push    ebx
    call    eax

    loc_4A976D:                             ; CODE XREF: sub_4A96D0+91j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A96D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A9780 proc near                    ; CODE XREF: sub_4A9B90+2C7p

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_4]
    mov     ebx, [esp+arg_0]
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    mov     eax, [ebx+18h]
    lea     edx, [edi+ecx*4]
    mov     ecx, [eax+4]
    lea     esi, [edi+edx*2]
    add     esi, ecx
    mov     ax, [esi+140h]
    mov     cx, [esi+136h]
    movsx   edx, ax
    inc     eax
    movsx   ebp, cx
    mov     [esi+140h], ax
    dec     ebp
    movsx   eax, ax
    cmp     eax, ebp
    jle     short loc_4A97D3
    dec     ecx
    mov     [esi+140h], cx

    loc_4A97D3:                             ; CODE XREF: sub_4A9780+49j
    cmp     word ptr [esi+140h], 0
    jge     short loc_4A97E6
    mov     word ptr [esi+140h], 0

    loc_4A97E6:                             ; CODE XREF: sub_4A9780+5Bj
    movsx   ecx, word ptr [esi+140h]
    cmp     ecx, edx
    jz      short loc_4A9809
    push    edi
    push    ebx
    mov     dword ptr [ebx+0CCAh], 1
    call    sub_4A2580
    push    edi
    push    ebx
    call    sub_4A2BE0

    loc_4A9809:                             ; CODE XREF: sub_4A9780+6Fj
    mov     eax, [esi+144h]
    test    eax, eax
    jz      short loc_4A981D
    mov     edx, [esi+14Ah]
    push    edx
    push    ebx
    call    eax

    loc_4A981D:                             ; CODE XREF: sub_4A9780+91j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A9780 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A9830 proc near                    ; CODE XREF: sub_4A9B90+257p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    mov     ecx, [eax+18h]
    mov     eax, ebp
    shl     eax, 3
    mov     ebx, [ecx+4]
    sub     eax, ebp
    push    esi
    mov     esi, 1
    lea     edx, [eax+eax*2]
    push    edi
    mov     [esp+10h+arg_4], 0
    lea     eax, [ebp+edx*2+0]
    mov     edx, ebx
    add     edx, ebp
    lea     ecx, [ebp+eax*4+0]
    movsx   eax, word ptr [ebx+0B6h]
    inc     eax
    lea     edi, [edx+ecx*2]
    cmp     eax, esi
    jle     short loc_4A98BB
    lea     ecx, [ebx+15Bh]

    loc_4A987A:                             ; CODE XREF: sub_4A9830+66j
    cmp     byte ptr [ecx], 7
    jnz     short loc_4A988D
    movsx   edx, byte ptr [edi+28h]
    cmp     [esp+10h+arg_4], edx
    jz      short loc_4A989A
    inc     [esp+10h+arg_4]

    loc_4A988D:                             ; CODE XREF: sub_4A9830+4Dj
    inc     esi
    add     ecx, 15Bh
    cmp     esi, eax
    jl      short loc_4A987A
    jmp     short loc_4A98BB
    ; ---------------------------------------------------------------------------

    loc_4A989A:                             ; CODE XREF: sub_4A9830+57j
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, ebx
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A98BB:                             ; CODE XREF: sub_4A9830+42j
                                            ; sub_4A9830+68j
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     esi, edx
    jnz     short loc_4A98D4
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A98D4:                             ; CODE XREF: sub_4A9830+95j
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A98E8
    call    sub_4C1450
    jmp     short loc_4A98FE
    ; ---------------------------------------------------------------------------

    loc_4A98E8:                             ; CODE XREF: sub_4A9830+AFj
    mov     eax, [eax+0Ch]
    push    49h
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     eax, ecx
    add     eax, 2

    loc_4A98FE:                             ; CODE XREF: sub_4A9830+B6j
    lea     ebx, [eax+1]
    mov     si, [edi+0BCh]
    movsx   eax, word ptr [edi+19h]
    sub     eax, 2
    mov     cx, [edi+0BAh]
    cdq
    idiv    ebx
    movsx   edx, si
    movsx   ebx, cx
    add     eax, edx
    cmp     ebx, eax
    jge     short loc_4A9996
    cmp     cx, si
    jl      short loc_4A9996
    cmp     word ptr [edi+0C0h], 0
    jz      short loc_4A99AF
    test    cx, cx
    jz      short loc_4A99AF
    dec     ecx
    cmp     cx, si
    mov     [edi+0BAh], cx
    jge     short loc_4A994E
    dec     esi
    mov     [edi+0BCh], si

    loc_4A994E:                             ; CODE XREF: sub_4A9830+114j
    mov     eax, [edi+0C2h]
    test    eax, eax
    jz      short loc_4A997D
    movsx   ecx, cx
    push    ecx
    push    eax
    call    sub_4B6AF0
    push    2                               ; size_t
    push    eax                             ; char *
    push    offset byte_502A20              ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4A997D
    mov     [edi+0BAh], bx

    loc_4A997D:                             ; CODE XREF: sub_4A9830+126j
                                            ; sub_4A9830+144j
    mov     esi, [esp+10h+arg_0]
    push    ebp
    push    esi
    call    sub_4A1B40
    push    ebp
    push    esi
    call    sub_4A2BE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A9996:                             ; CODE XREF: sub_4A9830+F3j
                                            ; sub_4A9830+F8j
    cmp     word ptr [edi+0C0h], 0
    jz      short loc_4A99AF
    mov     edx, [esp+10h+arg_0]
    add     edi, 2
    push    ebx
    push    edi
    push    edx
    call    sub_4A2E40

    loc_4A99AF:                             ; CODE XREF: sub_4A9830+102j
                                            ; sub_4A9830+107j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A9830 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A99C0 proc near                    ; CODE XREF: sub_4A9B90+298p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    mov     ecx, [eax+18h]
    mov     eax, ebp
    shl     eax, 3
    mov     ebx, [ecx+4]
    sub     eax, ebp
    push    esi
    mov     esi, 1
    lea     edx, [eax+eax*2]
    push    edi
    mov     [esp+10h+arg_4], 0
    lea     eax, [ebp+edx*2+0]
    mov     edx, ebx
    add     edx, ebp
    lea     ecx, [ebp+eax*4+0]
    movsx   eax, word ptr [ebx+0B6h]
    inc     eax
    lea     edi, [edx+ecx*2]
    cmp     eax, esi
    jle     short loc_4A9A4B
    lea     ecx, [ebx+15Bh]

    loc_4A9A0A:                             ; CODE XREF: sub_4A99C0+66j
    cmp     byte ptr [ecx], 7
    jnz     short loc_4A9A1D
    movsx   edx, byte ptr [edi+28h]
    cmp     [esp+10h+arg_4], edx
    jz      short loc_4A9A2A
    inc     [esp+10h+arg_4]

    loc_4A9A1D:                             ; CODE XREF: sub_4A99C0+4Dj
    inc     esi
    add     ecx, 15Bh
    cmp     esi, eax
    jl      short loc_4A9A0A
    jmp     short loc_4A9A4B
    ; ---------------------------------------------------------------------------

    loc_4A9A2A:                             ; CODE XREF: sub_4A99C0+57j
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*2]
    mov     eax, ebx
    add     eax, esi
    lea     edx, [esi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4A9A4B:                             ; CODE XREF: sub_4A99C0+42j
                                            ; sub_4A99C0+68j
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     esi, edx
    jnz     short loc_4A9A64
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4A9A64:                             ; CODE XREF: sub_4A99C0+95j
    mov     edx, dword_51FBA4
    mov     eax, [edx+14h]
    test    eax, eax
    jnz     short loc_4A9A7A
    call    sub_4C1450
    mov     ecx, eax
    jmp     short loc_4A9A8E
    ; ---------------------------------------------------------------------------

    loc_4A9A7A:                             ; CODE XREF: sub_4A99C0+AFj
    mov     eax, [eax+0Ch]
    push    49h
    push    eax
    call    sub_4B7F30
    xor     ecx, ecx
    mov     cx, [eax+2]
    add     ecx, 2

    loc_4A9A8E:                             ; CODE XREF: sub_4A99C0+B8j
    movsx   eax, word ptr [edi+19h]
    sub     eax, 2
    inc     ecx
    cdq
    idiv    ecx
    mov     si, [edi+0BCh]
    mov     cx, [edi+0BAh]
    movsx   edx, si
    movsx   ebx, cx
    mov     [esp+10h+arg_4], ebx
    add     edx, eax
    cmp     ebx, edx
    jge     loc_4A9B68
    cmp     cx, si
    jl      loc_4A9B68
    cmp     word ptr [edi+0C0h], 0
    jz      loc_4A9B64
    movsx   ebx, word ptr [edi+0BEh]
    lea     eax, [ebx+eax-1]
    mov     ebx, [esp+10h+arg_4]
    cmp     ebx, eax
    jz      loc_4A9B81
    inc     ecx
    dec     edx
    movsx   eax, cx
    cmp     eax, edx
    mov     [edi+0BAh], cx
    jle     short loc_4A9B01
    inc     esi
    mov     [edi+0BCh], si

    loc_4A9B01:                             ; CODE XREF: sub_4A99C0+137j
    mov     cx, [edi+0C0h]
    movsx   edx, cx
    dec     edx
    cmp     eax, edx
    jl      short loc_4A9B18
    dec     ecx
    mov     [edi+0BAh], cx

    loc_4A9B18:                             ; CODE XREF: sub_4A99C0+14Ej
    mov     eax, [edi+0C2h]
    test    eax, eax
    jz      short loc_4A9B4B
    movsx   ecx, word ptr [edi+0BAh]
    push    ecx
    push    eax
    call    sub_4B6AF0
    push    2                               ; size_t
    push    eax                             ; char *
    push    offset byte_502A20              ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4A9B4B
    mov     [edi+0BAh], bx

    loc_4A9B4B:                             ; CODE XREF: sub_4A99C0+160j
                                            ; sub_4A99C0+182j
    mov     esi, [esp+10h+arg_0]
    push    ebp
    push    esi
    call    sub_4A1B40
    push    ebp
    push    esi
    call    sub_4A2BE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A9B64:                             ; CODE XREF: sub_4A99C0+10Cj
    mov     ebx, [esp+10h+arg_4]

    loc_4A9B68:                             ; CODE XREF: sub_4A99C0+F5j
                                            ; sub_4A99C0+FEj
    cmp     word ptr [edi+0C0h], 0
    jz      short loc_4A9B81
    mov     edx, [esp+10h+arg_0]
    add     edi, 2
    push    ebx
    push    edi
    push    edx
    call    sub_4A2E40

    loc_4A9B81:                             ; CODE XREF: sub_4A99C0+123j
                                            ; sub_4A99C0+1B0j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4A99C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A9B90 proc near                    ; CODE XREF: sub_4A9FD0+87p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebp, [esp+14h+arg_0]
    push    esi
    push    edi
    mov     [esp+1Ch+var_C], 0FFFFFFFFh
    mov     eax, [ebp+18h]
    mov     edi, [eax+20h]
    mov     esi, [eax+4]
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    mov     eax, esi
    add     eax, edi
    lea     edx, [edi+ecx*4]
    mov     ecx, [esp+1Ch+arg_4]
    lea     ebx, [eax+edx*2]
    xor     edx, edx
    lea     eax, [ecx-9]
    mov     [esp+1Ch+var_4], ebx
    mov     dl, [ebx]
    cmp     eax, 0EEh
    mov     [esp+1Ch+var_8], edx
    ja      loc_4A9E78
    xor     ecx, ecx
    mov     cl, ds:byte_4A9EE0[eax]
    jmp     ds:off_4A9EBC[ecx*4]

    loc_4A9BF0:                             ; DATA XREF: .text:004A9EBCo
    push    0F9h
    call    sub_4C1B80
    test    eax, eax
    jz      loc_4A9E5E
    push    0
    jmp     loc_4A9E60
    ; ---------------------------------------------------------------------------

    loc_4A9C09:                             ; CODE XREF: sub_4A9B90+59j
                                            ; DATA XREF: .text:004A9EC4o
    movsx   edx, word ptr [esi+0B6h]
    mov     ebx, 1
    inc     edx
    cmp     edx, ebx
    jle     short loc_4A9C4D
    lea     edi, [esi+15Dh]

    loc_4A9C20:                             ; CODE XREF: sub_4A9B90+BBj
    lea     eax, [esi+0DCh]
    push    10h                             ; size_t
    push    eax                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      loc_4A9EB3
    movsx   eax, word ptr [esi+0B6h]
    inc     ebx
    add     edi, 15Bh
    inc     eax
    cmp     ebx, eax
    jl      short loc_4A9C20

    loc_4A9C4D:                             ; CODE XREF: sub_4A9B90+88j
    or      eax, 0FFFFFFFFh

    loc_4A9C50:                             ; CODE XREF: sub_4A9B90+325j
    cmp     eax, 0FFFFFFFFh
    jz      loc_4A9E78
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     dl, [esi+ecx*2+29h]
    test    dl, dl
    jz      loc_4A9E78
    mov     [esp+1Ch+var_C], eax
    jmp     loc_4A9E70
    ; ---------------------------------------------------------------------------

    loc_4A9C80:                             ; CODE XREF: sub_4A9B90+59j
                                            ; DATA XREF: .text:004A9EC0o
    mov     eax, [ebp+64h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A9CA6
    lea     ecx, ds:0[eax*8]
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    add     eax, esi
    cmp     byte ptr [eax+ecx*2], 3
    jz      loc_4A9E78

    loc_4A9CA6:                             ; CODE XREF: sub_4A9B90+F6j
    movsx   ecx, word ptr [esi+0B6h]
    mov     ebx, 1
    inc     ecx
    cmp     ecx, ebx
    jle     short loc_4A9CFC
    lea     ebp, [esi+15Dh]

    loc_4A9CBD:                             ; CODE XREF: sub_4A9B90+154j
    lea     eax, [esi+0CCh]
    push    10h                             ; size_t
    push    eax                             ; char *
    push    ebp                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4A9CF0
    movsx   edx, word ptr [esi+0B6h]
    inc     ebx
    add     ebp, 15Bh
    inc     edx
    cmp     ebx, edx
    jl      short loc_4A9CBD
    mov     ebp, [esp+1Ch+arg_0]
    mov     edx, [esp+1Ch+var_8]
    jmp     short loc_4A9CFC
    ; ---------------------------------------------------------------------------

    loc_4A9CF0:                             ; CODE XREF: sub_4A9B90+141j
    mov     ebp, [esp+1Ch+arg_0]
    mov     edx, [esp+1Ch+var_8]
    mov     eax, ebx
    jmp     short loc_4A9CFF
    ; ---------------------------------------------------------------------------

    loc_4A9CFC:                             ; CODE XREF: sub_4A9B90+125j
                                            ; sub_4A9B90+15Ej
    or      eax, 0FFFFFFFFh

    loc_4A9CFF:                             ; CODE XREF: sub_4A9B90+16Aj
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A9D37
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     esi, [esi+ecx*2]
    mov     cl, [esi+29h]
    test    cl, cl
    jz      short loc_4A9D37
    cmp     byte ptr [esi], 1
    jnz     short loc_4A9D2E
    test    byte ptr [esi+13Ch], 1
    jnz     short loc_4A9D37

    loc_4A9D2E:                             ; CODE XREF: sub_4A9B90+193j
    mov     [esp+1Ch+var_C], eax
    jmp     loc_4A9E70
    ; ---------------------------------------------------------------------------

    loc_4A9D37:                             ; CODE XREF: sub_4A9B90+172j
                                            ; sub_4A9B90+18Ej ...
    mov     ebx, [esp+1Ch+var_4]

    loc_4A9D3B:                             ; CODE XREF: sub_4A9B90+59j
                                            ; DATA XREF: .text:004A9EC8o
    cmp     edx, 3
    jz      loc_4A9E78
    cmp     edx, 1
    jz      short loc_4A9D57
    cmp     edx, 2
    jz      short loc_4A9D57
    cmp     edx, 6
    jnz     loc_4A9E78

    loc_4A9D57:                             ; CODE XREF: sub_4A9B90+1B7j
                                            ; sub_4A9B90+1BCj
    mov     al, [ebx+29h]
    test    al, al
    jz      loc_4A9E78
    cmp     edx, 1
    jnz     short loc_4A9D73
    test    [ebx+13Ch], dl
    jnz     loc_4A9E78

    loc_4A9D73:                             ; CODE XREF: sub_4A9B90+1D5j
    cmp     edx, 1
    mov     [esp+1Ch+var_C], edi
    jnz     loc_4A9E70
    test    byte ptr [ebx+1Bh], 10h
    jz      short loc_4A9D9F
    push    edi
    push    ebp
    mov     [ebx+138h], dx
    call    sub_4A0340
    push    edi
    push    ebp
    call    sub_4A5F40
    mov     edx, [esp+1Ch+var_8]

    loc_4A9D9F:                             ; CODE XREF: sub_4A9B90+1F4j
    cmp     edx, 1
    jnz     loc_4A9E70
    mov     al, [ebx+136h]
    test    al, al
    jz      loc_4A9E70
    mov     dl, [ebx+137h]
    inc     dl
    mov     [ebx+137h], dl
    mov     cl, [ebx+136h]
    mov     al, dl
    cmp     al, cl
    jb      loc_4A9E70
    mov     byte ptr [ebx+137h], 0
    jmp     loc_4A9E70
    ; ---------------------------------------------------------------------------

    loc_4A9DE0:                             ; CODE XREF: sub_4A9B90+59j
                                            ; DATA XREF: .text:004A9ED0o
    cmp     edx, 2
    jnz     short loc_4A9DFC
    push    edi
    push    ebp
    call    sub_4A9830
    mov     eax, [ebx+0CEh]
    test    eax, eax
    jz      short loc_4A9E66
    push    ebx
    push    ebp
    call    eax
    jmp     short loc_4A9E66
    ; ---------------------------------------------------------------------------

    loc_4A9DFC:                             ; CODE XREF: sub_4A9B90+253j
    push    2
    jmp     short loc_4A9E60
    ; ---------------------------------------------------------------------------

    loc_4A9E00:                             ; CODE XREF: sub_4A9B90+59j
                                            ; DATA XREF: .text:004A9ECCo
    cmp     edx, 3
    jz      short loc_4A9E78
    cmp     edx, 4
    jnz     short loc_4A9E1D
    mov     dx, [ebx+17h]
    cmp     dx, [ebx+19h]
    jle     short loc_4A9E1D
    push    edi
    push    ebp
    call    sub_4A96D0
    jmp     short loc_4A9E66
    ; ---------------------------------------------------------------------------

    loc_4A9E1D:                             ; CODE XREF: sub_4A9B90+278j
                                            ; sub_4A9B90+282j
    push    0
    jmp     short loc_4A9E60
    ; ---------------------------------------------------------------------------

    loc_4A9E21:                             ; CODE XREF: sub_4A9B90+59j
                                            ; DATA XREF: .text:004A9ED8o
    cmp     edx, 2
    jnz     short loc_4A9E3D
    push    edi
    push    ebp
    call    sub_4A99C0
    mov     eax, [ebx+0CEh]
    test    eax, eax
    jz      short loc_4A9E66
    push    ebx
    push    ebp
    call    eax
    jmp     short loc_4A9E66
    ; ---------------------------------------------------------------------------

    loc_4A9E3D:                             ; CODE XREF: sub_4A9B90+294j
    push    3
    jmp     short loc_4A9E60
    ; ---------------------------------------------------------------------------

    loc_4A9E41:                             ; CODE XREF: sub_4A9B90+59j
                                            ; DATA XREF: .text:004A9ED4o
    cmp     edx, 3
    jz      short loc_4A9E78
    cmp     edx, 4
    jnz     short loc_4A9E5E
    mov     ax, [ebx+17h]
    cmp     ax, [ebx+19h]
    jle     short loc_4A9E5E
    push    edi
    push    ebp
    call    sub_4A9780
    jmp     short loc_4A9E66
    ; ---------------------------------------------------------------------------

    loc_4A9E5E:                             ; CODE XREF: sub_4A9B90+6Cj
                                            ; sub_4A9B90+2B9j ...
    push    1

    loc_4A9E60:                             ; CODE XREF: sub_4A9B90+74j
                                            ; sub_4A9B90+26Ej ...
    push    ebp
    call    sub_4A7960

    loc_4A9E66:                             ; CODE XREF: sub_4A9B90+264j
                                            ; sub_4A9B90+26Aj ...
    mov     dword ptr [ebp+0CCAh], 1

    loc_4A9E70:                             ; CODE XREF: sub_4A9B90+EBj
                                            ; sub_4A9B90+1A2j ...
    mov     [esp+1Ch+arg_4], 0

    loc_4A9E78:                             ; CODE XREF: sub_4A9B90+4Bj
                                            ; sub_4A9B90+59j ...
    mov     eax, [esp+1Ch+arg_4]
    test    eax, eax
    jnz     short loc_4A9E8F
    mov     ecx, [ebp+18h]
    mov     eax, [ecx+18h]
    test    eax, eax
    jnz     short loc_4A9E8F
    call    sub_4C1AB0

    loc_4A9E8F:                             ; CODE XREF: sub_4A9B90+2EEj
                                            ; sub_4A9B90+2F8j
    mov     eax, [esp+1Ch+var_C]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4A9EA5
    mov     [ebp+60h], eax
    mov     dword ptr [ebp+0CCAh], 1

    loc_4A9EA5:                             ; CODE XREF: sub_4A9B90+306j
    mov     eax, [esp+1Ch+arg_4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4A9EB3:                             ; CODE XREF: sub_4A9B90+A4j
    mov     eax, ebx
    jmp     loc_4A9C50
    sub_4A9B90 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4A9EBC dd offset loc_4A9BF0         ; DATA XREF: sub_4A9B90+59r
    dd offset loc_4A9C80
    dd offset loc_4A9C09
    dd offset loc_4A9D3B
    dd offset loc_4A9E00
    dd offset loc_4A9DE0
    dd offset loc_4A9E41
    dd offset loc_4A9E21
    dd offset loc_4A9E78
    byte_4A9EE0 db 0                        ; DATA XREF: sub_4A9B90+53r
    ; ---------------------------------------------------------------------------
    or      [eax], cl
    or      [ecx], al
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [edx], al
    or      [eax], cl
    or      [eax], cl
    add     ecx, [eax]
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    add     al, 5
    push    es
    pop     es
    nop

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4A9FD0 proc near                    ; CODE XREF: .text:0041F7B7p
                                            ; .text:0041F9EAp ...

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    arg_0= dword ptr  4

    sub     esp, 34h
    push    ebx
    push    ebp
    mov     ebp, [esp+3Ch+arg_0]
    push    esi
    push    edi
    mov     eax, [ebp+18h]
    test    eax, eax
    jnz     short loc_4A9FEE
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4A9FEE:                             ; CODE XREF: sub_4A9FD0+10j
    call    sub_4B6340
    mov     edx, [ebp+96h]
    mov     ecx, eax
    sub     ecx, edx
    push    ebp
    mov     [ebp+9Ah], ecx
    mov     [ebp+96h], eax
    call    sub_4AB5D0
    mov     edx, [ebp+18h]
    mov     eax, [edx+18h]
    test    eax, eax
    jnz     short loc_4AA034
    call    sub_4C1B00
    cmp     eax, 0E2h
    mov     [esp+44h+var_28], eax
    jl      short loc_4AA03D
    cmp     eax, 0EBh
    jg      short loc_4AA03D
    xor     eax, eax
    jmp     short loc_4AA039
    ; ---------------------------------------------------------------------------

    loc_4AA034:                             ; CODE XREF: sub_4A9FD0+47j
    call    sub_4C1AB0

    loc_4AA039:                             ; CODE XREF: sub_4A9FD0+62j
    mov     [esp+44h+var_28], eax

    loc_4AA03D:                             ; CODE XREF: sub_4A9FD0+57j
                                            ; sub_4A9FD0+5Ej
    mov     ecx, [ebp+18h]
    mov     edx, [ecx+18h]
    test    edx, edx
    jz      short loc_4AA09D
    test    eax, eax
    jz      short loc_4AA09D
    mov     ecx, [ebp+0A2h]
    test    ecx, ecx
    jz      short loc_4AA09D
    push    eax
    push    ebp
    call    sub_4A9B90
    mov     esi, eax
    test    esi, esi
    mov     [esp+44h+var_28], esi
    jz      short loc_4AA09D
    xor     eax, eax

    loc_4AA068:                             ; CODE XREF: sub_4A9FD0+A8j
    mov     edx, [ebp+18h]
    lea     ecx, [eax+edx]
    inc     eax
    cmp     eax, 0Eh
    mov     dl, [ecx+29h]
    mov     [ecx+28h], dl
    jl      short loc_4AA068
    push    esi                             ; int
    call    _toupper
    mov     ecx, [ebp+18h]
    add     esp, 4
    mov     [ecx+36h], al
    mov     edx, [ebp+18h]
    mov     eax, [edx+3Bh]
    test    eax, eax
    jz      short loc_4AA096
    push    ebp
    call    eax

    loc_4AA096:                             ; CODE XREF: sub_4A9FD0+C1j
    mov     dword ptr [ebp+60h], 0FFFFFFFFh

    loc_4AA09D:                             ; CODE XREF: sub_4A9FD0+75j
                                            ; sub_4A9FD0+79j ...
    mov     eax, [ebp+60h]
    mov     [esp+48h], eax
    mov     eax, [ebp+18h]
    test    eax, eax
    jz      loc_4AA7FA
    cmp     dword ptr [ebp+0CCAh], 1
    jnz     short loc_4AA0D2
    mov     ecx, [ebp+18h]
    mov     dword ptr [ebp+0CCAh], 0
    mov     edx, [ecx+10h]
    or      edx, 40h
    push    edx
    push    ebp
    call    sub_4A81E0

    loc_4AA0D2:                             ; CODE XREF: sub_4A9FD0+E6j
    mov     eax, [ebp+18h]
    mov     ebx, [eax+4]
    test    ebx, ebx
    mov     [esp+48h+var_30], ebx
    jz      loc_4AA7FA
    mov     dl, [ebx]
    lea     esi, [ebp+3Ch]
    movsx   eax, word ptr [ebx+13h]
    movsx   ecx, word ptr [ebx+15h]
    test    dl, dl
    jz      short loc_4AA0F9
    add     eax, eax
    add     ecx, ecx

    loc_4AA0F9:                             ; CODE XREF: sub_4A9FD0+123j
    movsx   edx, word ptr [ebx+17h]
    mov     edi, [esi+4]
    lea     edx, [edx+eax-1]
    mov     [esp+48h+var_14], edx
    movsx   edx, word ptr [ebx+19h]
    lea     edx, [edx+ecx-1]
    mov     [esp+48h+var_10], edx
    mov     edx, [esi]
    cmp     edx, eax
    jl      short loc_4AA131
    cmp     edx, [esp+48h+var_14]
    jg      short loc_4AA131
    cmp     edi, ecx
    jl      short loc_4AA131
    cmp     edi, [esp+48h+var_10]
    jg      short loc_4AA131
    mov     eax, 1
    jmp     short loc_4AA133
    ; ---------------------------------------------------------------------------

    loc_4AA131:                             ; CODE XREF: sub_4A9FD0+148j
                                            ; sub_4A9FD0+14Ej ...
    xor     eax, eax

    loc_4AA133:                             ; CODE XREF: sub_4A9FD0+15Fj
    push    eax
    push    ebp
    call    sub_4AB440
    mov     eax, [ebp+68h]
    mov     ecx, 6
    lea     edi, [esp+48h+var_1C]
    mov     dword ptr [ebp+68h], 0FFFFFFFFh
    movsx   edx, word ptr [ebx+15h]
    rep movsd
    movsx   ecx, word ptr [ebx+13h]
    mov     edi, [esp+48h+var_1C]
    mov     esi, [esp+48h+var_18]
    sub     edi, ecx
    sub     esi, edx
    mov     [esp+48h+var_20], eax
    mov     [esp+48h+var_1C], edi
    mov     [esp+48h+var_18], esi
    call    sub_4B6340
    sub     eax, dword_51FBB4
    test    eax, eax
    jle     short loc_4AA192
    mov     [esp+48h+var_28], 1
    call    sub_4B6340
    mov     dword_51FBB4, eax
    jmp     short loc_4AA19A
    ; ---------------------------------------------------------------------------

    loc_4AA192:                             ; CODE XREF: sub_4A9FD0+1ACj
    mov     [esp+48h+var_28], 0

    loc_4AA19A:                             ; CODE XREF: sub_4A9FD0+1C0j
    mov     eax, [esp+48h+var_30]
    mov     ebx, 1
    mov     [esp+48h+var_38], ebx
    movsx   ecx, word ptr [eax+0B6h]
    inc     ecx
    cmp     ecx, ebx
    jle     loc_4AA573
    mov     ecx, eax
    mov     eax, 0FFFFFFE1h
    sub     eax, ecx
    lea     edi, [ecx+17Ah]
    mov     [esp+48h+var_24], eax
    mov     [esp+48h+var_34], edi

    loc_4AA1CE:                             ; CODE XREF: sub_4A9FD0+59Dj
    mov     al, [edi+0Ah]
    test    al, al
    jz      loc_4AA549                      ; default
    mov     al, [edi-1Fh]
    test    al, al
    jnz     short loc_4AA1E6
    xor     eax, eax
    xor     ecx, ecx
    jmp     short loc_4AA1EE
    ; ---------------------------------------------------------------------------

    loc_4AA1E6:                             ; CODE XREF: sub_4A9FD0+20Ej
    movsx   eax, word ptr [edi-0Ch]
    movsx   ecx, word ptr [edi-0Ah]

    loc_4AA1EE:                             ; CODE XREF: sub_4A9FD0+214j
    movsx   edx, word ptr [edi-8]
    movsx   esi, word ptr [edi-6]
    cmp     [esp+48h+var_1C], eax
    lea     edx, [edx+eax-1]
    lea     esi, [esi+ecx-1]
    jl      short loc_4AA219
    cmp     [esp+48h+var_1C], edx
    jg      short loc_4AA219
    mov     eax, [esp+48h+var_18]
    cmp     eax, ecx
    jl      short loc_4AA219
    cmp     eax, esi
    jg      short loc_4AA219
    mov     [ebp+68h], ebx

    loc_4AA219:                             ; CODE XREF: sub_4A9FD0+232j
                                            ; sub_4A9FD0+238j ...
    push    0FBh
    call    sub_4C1B80
    neg     eax
    mov     esi, [esp+48h+var_2C]
    sbb     eax, eax
    xor     ecx, ecx
    mov     cl, [edi-1Fh]
    not     eax
    and     eax, esi
    dec     ecx
    cmp     ecx, 0Ch                        ; switch 13 cases
    ja      loc_4AA549                      ; default
    jmp     ds:off_4AA810[ecx*4]            ; switch jump

    loc_4AA245:                             ; DATA XREF: .text:004AA810o
    mov     eax, [esp+48h+var_2C]           ; case 0x0
    push    eax
    push    ebx
    push    ebp
    call    sub_4A6AE0
    cmp     eax, 1
    jnz     short loc_4AA25A
    mov     [esp+48h], ebx

    loc_4AA25A:                             ; CODE XREF: sub_4A9FD0+284j
    mov     eax, [edi]
    test    eax, eax
    jz      loc_4AA549                      ; default
    mov     ecx, [esp+48h+var_28]
    test    ecx, ecx
    jz      loc_4AA549                      ; default
    add     eax, 0FFFFFFFEh
    test    eax, eax
    mov     [edi], eax
    jge     loc_4AA531
    mov     dword ptr [edi], 0
    jmp     loc_4AA531
    ; ---------------------------------------------------------------------------

    loc_4AA288:                             ; CODE XREF: sub_4A9FD0+26Ej
                                            ; DATA XREF: .text:004AA810o
    push    0                               ; case 0x1
    push    ebx
    push    ebp
    call    sub_4A3780
    cmp     eax, 1
    jnz     loc_4AA549                      ; default
    mov     [esp+48h], ebx
    jmp     loc_4AA549                      ; default
    ; ---------------------------------------------------------------------------

    loc_4AA2A3:                             ; CODE XREF: sub_4A9FD0+26Ej
                                            ; DATA XREF: .text:004AA810o
    push    eax                             ; case 0x2
    push    ebx
    push    ebp
    call    sub_4A7290
    cmp     eax, 1
    jnz     loc_4AA549                      ; default
    mov     [esp+48h], ebx
    jmp     loc_4AA549                      ; default
    ; ---------------------------------------------------------------------------

    loc_4AA2BD:                             ; CODE XREF: sub_4A9FD0+26Ej
                                            ; DATA XREF: .text:004AA810o
    push    ebx                             ; case 0x3
    push    ebp
    call    sub_4A4170
    jmp     loc_4AA549                      ; default
    ; ---------------------------------------------------------------------------

    loc_4AA2C9:                             ; CODE XREF: sub_4A9FD0+26Ej
                                            ; DATA XREF: .text:004AA810o
    mov     ecx, [esp+48h+var_2C]           ; case 0x4
    push    ecx
    push    ebx
    push    ebp
    call    sub_4A4440
    test    eax, eax
    jz      loc_4AA549                      ; default
    mov     edx, [esp+48h+var_30]
    mov     edi, 1
    movsx   eax, word ptr [edx+0B6h]
    inc     eax
    cmp     eax, edi
    jle     short loc_4AA32D
    mov     ecx, [esp+48h+var_34]
    lea     esi, [edx+15Dh]
    lea     ebx, [ecx+117h]

    loc_4AA302:                             ; CODE XREF: sub_4A9FD0+35Bj
    push    10h                             ; size_t
    push    ebx                             ; char *
    push    esi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      loc_4AA809
    mov     eax, [esp+48h+var_30]
    inc     edi
    add     esi, 15Bh
    movsx   ecx, word ptr [eax+0B6h]
    inc     ecx
    cmp     edi, ecx
    jl      short loc_4AA302

    loc_4AA32D:                             ; CODE XREF: sub_4A9FD0+320j
    or      eax, 0FFFFFFFFh

    loc_4AA330:                             ; CODE XREF: sub_4A9FD0+83Bj
    or      esi, 0FFFFFFFFh
    cmp     eax, esi
    jz      loc_4AA469
    mov     ecx, eax
    mov     [esp+48h], eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, [esp+48h+var_30]
    add     ecx, eax
    lea     ecx, [ecx+edx*2]
    mov     dl, [ecx]
    cmp     dl, 1
    jnz     short loc_4AA3A2
    mov     dl, [ecx+29h]
    test    dl, dl
    jz      loc_4AA460
    test    byte ptr [ecx+13Ch], 1
    jnz     loc_4AA460
    mov     dl, [ecx+137h]
    mov     bl, [ecx+136h]
    inc     dl
    cmp     dl, bl
    mov     [ecx+137h], dl
    jb      short loc_4AA396
    mov     byte ptr [ecx+137h], 0

    loc_4AA396:                             ; CODE XREF: sub_4A9FD0+3BDj
    push    eax
    push    ebp
    call    sub_4A5F40
    jmp     loc_4AA541
    ; ---------------------------------------------------------------------------

    loc_4AA3A2:                             ; CODE XREF: sub_4A9FD0+38Dj
    mov     bl, [ecx+29h]
    test    bl, bl
    jz      loc_4AA460
    cmp     dl, 4
    jnz     short loc_4AA3C5
    mov     edx, [ecx+157h]
    test    edx, edx
    jz      short loc_4AA3C5
    mov     [esp+48h], esi
    jmp     loc_4AA541
    ; ---------------------------------------------------------------------------

    loc_4AA3C5:                             ; CODE XREF: sub_4A9FD0+3E0j
                                            ; sub_4A9FD0+3EAj
    mov     edx, [ebp+18h]
    mov     ecx, [ebp+18h]
    mov     edx, [edx+4]
    mov     [ebp+64h], esi
    mov     [ecx+20h], eax
    mov     ecx, [ebp+18h]
    mov     esi, [ecx+20h]
    add     edx, esi
    lea     eax, ds:0[esi*8]
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     eax, [esi+eax*2]
    lea     eax, [esi+eax*4]
    cmp     byte ptr [edx+eax*2], 3
    jnz     loc_4AA541
    mov     ebx, [ecx+4]
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    mov     ecx, ebx
    add     ecx, esi
    lea     eax, [esi+edx*4]
    lea     edi, [ecx+eax*2]
    call    sub_4C13F0
    mov     edx, [edi+1Fh]
    push    eax
    xor     eax, eax
    mov     al, [edx+ebp+8B2h]
    push    eax
    call    sub_4C13A0
    push    esi
    push    ebx
    call    sub_4A1810
    push    esi
    push    ebp
    call    sub_49FC50
    mov     ecx, [ebp+18h]
    push    0
    add     edi, 0B6h
    mov     [ecx+20h], esi
    movsx   edx, word ptr [edi+82h]
    push    edx
    push    edi
    push    esi
    push    ebp
    call    sub_4AB6C0
    call    sub_4C1A40
    jmp     loc_4AA541
    ; ---------------------------------------------------------------------------

    loc_4AA460:                             ; CODE XREF: sub_4A9FD0+394j
                                            ; sub_4A9FD0+3A1j ...
    mov     [esp+48h], esi
    jmp     loc_4AA541
    ; ---------------------------------------------------------------------------

    loc_4AA469:                             ; CODE XREF: sub_4A9FD0+365j
    mov     eax, [esp+48h+var_38]
    mov     [esp+48h], eax
    jmp     loc_4AA541
    ; ---------------------------------------------------------------------------

    loc_4AA476:                             ; CODE XREF: sub_4A9FD0+26Ej
                                            ; DATA XREF: .text:004AA810o
    push    ebx                             ; case 0x5
    push    ebp
    call    sub_4A4B50
    cmp     eax, 1
    jnz     loc_4AA549                      ; default
    mov     [esp+48h], ebx
    jmp     loc_4AA549                      ; default
    ; ---------------------------------------------------------------------------

    loc_4AA48F:                             ; CODE XREF: sub_4A9FD0+26Ej
                                            ; DATA XREF: .text:004AA810o
    mov     ecx, [ebp+18h]                  ; case 0xc
    mov     edx, [esp+48h+var_24]
    mov     esi, [ecx+4]
    add     esi, edx
    add     esi, edi
    mov     eax, [esi+0CEh]
    test    eax, eax
    jz      loc_4AA549                      ; default
    mov     eax, [esi+0BAh]
    mov     ecx, [esi+0BEh]
    cmp     eax, ecx
    jge     loc_4AA549                      ; default
    call    sub_4B6340
    cmp     eax, [esi+0C6h]
    jle     short loc_4AA510
    fld     dword ptr [esi+0CAh]
    call    __ftol
    mov     ecx, [esi+0BAh]
    add     ecx, eax
    mov     eax, [esi+0BEh]
    cmp     ecx, eax
    mov     [esi+0BAh], ecx
    jle     short loc_4AA4FF
    mov     [esi+0BAh], eax
    mov     dword ptr [esi+0CEh], 0

    loc_4AA4FF:                             ; CODE XREF: sub_4A9FD0+51Dj
    call    sub_4B6340
    add     eax, [esi+0C2h]
    mov     [esi+0C6h], eax

    loc_4AA510:                             ; CODE XREF: sub_4A9FD0+4FAj
    push    ebx
    push    ebp
    call    sub_4A4660
    jmp     short loc_4AA549                ; default
    ; ---------------------------------------------------------------------------

    loc_4AA519:                             ; CODE XREF: sub_4A9FD0+26Ej
                                            ; DATA XREF: .text:004AA810o
    mov     eax, [edi]                      ; case 0xb
    test    eax, eax
    jz      short loc_4AA549                ; default
    mov     ecx, [esp+48h+var_28]
    test    ecx, ecx
    jz      short loc_4AA549                ; default
    dec     eax
    push    ebx
    push    ebp
    mov     [edi], eax
    call    sub_4A5E50

    loc_4AA531:                             ; CODE XREF: sub_4A9FD0+2A7j
                                            ; sub_4A9FD0+2B3j
    mov     eax, [ebp+18h]
    test    eax, eax
    jz      short loc_4AA549                ; default
    mov     dword ptr [eax+14h], 1
    jmp     short loc_4AA549                ; default
    ; ---------------------------------------------------------------------------

    loc_4AA541:                             ; CODE XREF: sub_4A9FD0+3CDj
                                            ; sub_4A9FD0+3F0j ...
    mov     ebx, [esp+48h+var_38]
    mov     edi, [esp+48h+var_34]

    loc_4AA549:                             ; CODE XREF: sub_4A9FD0+203j
                                            ; sub_4A9FD0+268j ...
    cmp     dword ptr [esp+48h], 0FFFFFFFFh ; default
    jnz     short loc_4AA573
    mov     ecx, [esp+48h+var_30]
    inc     ebx
    add     edi, 15Bh
    mov     [esp+48h+var_38], ebx
    movsx   edx, word ptr [ecx+0B6h]
    inc     edx
    mov     [esp+48h+var_34], edi
    cmp     ebx, edx
    jl      loc_4AA1CE

    loc_4AA573:                             ; CODE XREF: sub_4A9FD0+1E1j
                                            ; sub_4A9FD0+57Ej
    mov     eax, [ebp+68h]
    mov     ecx, [esp+48h+var_20]
    cmp     eax, ecx
    jz      loc_4AA654
    cmp     eax, 0FFFFFFFFh
    mov     [esp+48h+var_28], offset Data
    jz      short loc_4AA5B5
    lea     ecx, ds:0[eax*8]
    mov     [ebp+6Ch], eax
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    mov     eax, [ebp+18h]
    mov     ecx, [eax+4]
    lea     edx, [edx+ecx+33h]
    mov     [esp+48h+var_28], edx

    loc_4AA5B5:                             ; CODE XREF: sub_4A9FD0+5BDj
    mov     eax, [ebp+18h]
    mov     esi, 1
    mov     ebx, [eax+4]
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4AA5F9
    lea     edi, [ebx+15Dh]

    loc_4AA5D2:                             ; CODE XREF: sub_4A9FD0+627j
    push    10h                             ; size_t
    push    offset aHelptext                ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4AA5FC
    movsx   edx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_4AA5D2

    loc_4AA5F9:                             ; CODE XREF: sub_4A9FD0+5FAj
    or      esi, 0FFFFFFFFh

    loc_4AA5FC:                             ; CODE XREF: sub_4A9FD0+614j
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4AA654
    mov     eax, [esp+48h+var_28]
    push    eax                             ; int
    call    sub_4C5740
    mov     ecx, esi
    mov     edi, eax
    shl     ecx, 3
    sub     ecx, esi
    xor     eax, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [esi+ecx*2]
    lea     ecx, [esi+edx*4]
    lea     edx, [esi+ecx*2]
    mov     ecx, [ebp+18h]
    mov     ecx, [ecx+4]
    lea     edx, [edx+ecx+0B6h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     dword ptr [ebp+0CCAh], 1

    loc_4AA654:                             ; CODE XREF: sub_4A9FD0+5ACj
                                            ; sub_4A9FD0+62Fj
    mov     ecx, [ebp+18h]
    mov     eax, [ecx+1Ch]
    test    eax, eax
    jz      short loc_4AA660
    call    eax

    loc_4AA660:                             ; CODE XREF: sub_4A9FD0+68Cj
    mov     eax, [esp+48h]
    or      edi, 0FFFFFFFFh
    cmp     eax, edi
    jz      loc_4AA7FA
    mov     edx, [ebp+18h]
    mov     ecx, [ebp+18h]
    mov     [ebp+60h], eax
    mov     edx, [edx+4]
    mov     [ebp+64h], edi
    mov     [ecx+20h], eax
    mov     ecx, [ebp+18h]
    mov     esi, [ecx+20h]
    add     edx, esi
    lea     eax, ds:0[esi*8]
    sub     eax, esi
    lea     eax, [eax+eax*2]
    lea     eax, [esi+eax*2]
    lea     eax, [esi+eax*4]
    cmp     byte ptr [edx+eax*2], 3
    jnz     loc_4AA78D
    mov     ebx, [ecx+4]
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    mov     ecx, ebx
    add     ecx, esi
    lea     eax, [esi+edx*4]
    lea     edi, [ecx+eax*2]
    mov     [esp+48h+var_28], edi
    call    sub_4C13F0
    mov     edx, [edi+1Fh]
    push    eax
    xor     eax, eax
    mov     al, [edx+ebp+8B2h]
    push    eax
    call    sub_4C13A0
    movsx   eax, word ptr [ebx+0B6h]
    xor     ecx, ecx
    mov     edi, 1
    inc     eax
    cmp     eax, edi
    jle     short loc_4AA744
    lea     edx, [ebx+15Bh]
    mov     [esp+48h], edx

    loc_4AA6F8:                             ; CODE XREF: sub_4A9FD0+74Fj
    mov     edx, [esp+48h]
    cmp     byte ptr [edx], 7
    jnz     short loc_4AA70E
    mov     edx, [esp+48h+var_28]
    movsx   edx, byte ptr [edx+28h]
    cmp     ecx, edx
    jz      short loc_4AA723
    inc     ecx

    loc_4AA70E:                             ; CODE XREF: sub_4A9FD0+72Fj
    mov     edx, [esp+48h]
    inc     edi
    add     edx, 15Bh
    cmp     edi, eax
    mov     [esp+48h], edx
    jl      short loc_4AA6F8
    jmp     short loc_4AA744
    ; ---------------------------------------------------------------------------

    loc_4AA723:                             ; CODE XREF: sub_4A9FD0+73Bj
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     eax, [eax+eax*2]
    lea     ecx, [edi+eax*2]
    mov     eax, ebx
    add     eax, edi
    lea     edx, [edi+ecx*4]
    mov     ecx, [eax+edx*2+0D6h]
    push    ecx
    call    sub_4C1420

    loc_4AA744:                             ; CODE XREF: sub_4A9FD0+71Cj
                                            ; sub_4A9FD0+751j
    movsx   edx, word ptr [ebx+0B6h]
    inc     edx
    cmp     edi, edx
    jnz     short loc_4AA75D
    mov     eax, dword_51FBA4
    mov     ecx, [eax]
    push    ecx
    call    sub_4C1420

    loc_4AA75D:                             ; CODE XREF: sub_4A9FD0+77Ej
    push    esi
    push    ebp
    call    sub_49FC50
    mov     edx, [ebp+18h]
    push    0
    mov     eax, [esp+4Ch+var_28]
    mov     [edx+20h], esi
    movsx   ecx, word ptr [eax+138h]
    add     eax, 0B6h
    push    ecx
    push    eax
    push    esi
    push    ebp
    call    sub_4AB6C0
    call    sub_4C1A40
    or      edi, 0FFFFFFFFh

    loc_4AA78D:                             ; CODE XREF: sub_4A9FD0+6CFj
    mov     edx, [ebp+18h]
    mov     eax, [edx+8]
    test    eax, eax
    jz      short loc_4AA79A
    push    ebp
    call    eax

    loc_4AA79A:                             ; CODE XREF: sub_4A9FD0+7C5j
    cmp     [ebp+60h], edi
    jz      short loc_4AA7FA
    mov     eax, [ebp+18h]
    test    eax, eax
    jz      short loc_4AA7FA
    mov     esi, [eax+10h]
    mov     [ebp+64h], edi
    mov     [ebp+60h], edi
    mov     [ebp+68h], edi
    mov     eax, [eax+8]
    test    eax, eax
    jz      short loc_4AA7BC
    push    ebp
    call    eax

    loc_4AA7BC:                             ; CODE XREF: sub_4A9FD0+7E7j
    call    sub_4C2470
    push    2
    push    ebp
    call    sub_4A81E0
    call    sub_4C2870
    mov     ecx, [ebp+18h]
    mov     eax, [ecx]
    test    eax, eax
    mov     [ebp+18h], eax
    jz      short loc_4AA7E1
    mov     dword ptr [eax+14h], 1

    loc_4AA7E1:                             ; CODE XREF: sub_4A9FD0+808j
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    test    esi, 800h
    jz      short loc_4AA7FA
    push    40h
    push    ebp
    call    sub_4A81E0

    loc_4AA7FA:                             ; CODE XREF: sub_4A9FD0+D9j
                                            ; sub_4A9FD0+10Ej ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 34h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4AA809:                             ; CODE XREF: sub_4A9FD0+340j
    mov     eax, edi
    jmp     loc_4AA330
    sub_4A9FD0 endp

    ; ---------------------------------------------------------------------------
    off_4AA810 dd offset loc_4AA245         ; DATA XREF: sub_4A9FD0+26Er
    dd offset loc_4AA288                    ; jump table for switch statement
    dd offset loc_4AA2A3
    dd offset loc_4AA2BD
    dd offset loc_4AA2C9
    dd offset loc_4AA476
    dd offset loc_4AA549
    dd offset loc_4AA549
    dd offset loc_4AA549
    dd offset loc_4AA549
    dd offset loc_4AA549
    dd offset loc_4AA519
    dd offset loc_4AA48F
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AA850 proc near                    ; CODE XREF: sub_491200+2B7p

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    xor     ebx, ebx
    mov     dword_51FBA4, esi
    mov     [esi+18h], ebx
    mov     [esi+9B6h], bl
    mov     [esi+0AB6h], bl
    mov     [esi+0BB6h], bl
    mov     dword ptr [esi+0CC6h], 1
    call    sub_4B6340
    mov     [esi+96h], eax
    lea     ecx, [esi+8]
    xor     eax, eax
    mov     [esi+9Ah], ebx
    mov     dword ptr [esi+9Eh], 1
    mov     [esi+4], ebx
    mov     [esi+0CD2h], ebx
    mov     [esi+0CD6h], bl
    mov     [esi+78h], ebx
    mov     dword ptr [esi+68h], 0FFFFFFFFh
    mov     [ecx], eax
    mov     [ecx+4], eax
    mov     [ecx+8], eax
    mov     [esi+14h], ebx
    mov     dword ptr [esi+0A2h], 1
    pop     esi
    pop     ebx
    retn    4
    sub_4AA850 endp

    ; ---------------------------------------------------------------------------
    mov     eax, dword_51FBA4
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AA8E0 proc near                    ; CODE XREF: sub_491200+311p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_0]
    mov     eax, [esp+arg_4]
    mov     [ecx], eax
    retn    8
    sub_4AA8E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AA8F0 proc near                    ; CODE XREF: sub_41ACE0+F9p
                                            ; sub_41B0F0+6Dp ...

    var_21C= dword ptr -21Ch
    var_218= dword ptr -218h
    var_214= dword ptr -214h
    var_210= dword ptr -210h
    var_20C= dword ptr -20Ch
    var_208= dword ptr -208h
    var_204= dword ptr -204h
    var_200= byte ptr -200h
    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 21Ch
    mov     eax, [esp+21Ch+arg_8]
    push    ebx
    push    ebp
    push    esi
    xor     ebp, ebp
    push    edi
    mov     edi, [esp+22Ch+arg_0]
    mov     [esp+22Ch+var_218], 1
    test    ah, 8
    jz      short loc_4AA989
    mov     esi, [edi+18h]
    test    esi, esi
    jz      short loc_4AA97E
    mov     eax, [esi+4]
    cmp     byte ptr [eax], 0
    jnz     short loc_4AA930
    xor     ecx, ecx
    xor     edx, edx
    mov     [esp+22Ch+var_210], ecx
    jmp     short loc_4AA93C
    ; ---------------------------------------------------------------------------

    loc_4AA930:                             ; CODE XREF: sub_4AA8F0+34j
    movsx   ecx, word ptr [eax+13h]
    mov     [esp+22Ch+var_210], ecx
    movsx   edx, word ptr [eax+15h]

    loc_4AA93C:                             ; CODE XREF: sub_4AA8F0+3Ej
    mov     [esp+22Ch+var_20C], edx
    push    0FFFFFFE8h
    movsx   ebx, word ptr [eax+17h]
    lea     ecx, [ebx+ecx-1]
    mov     [esp+230h+var_208], ecx
    movsx   eax, word ptr [eax+19h]
    lea     ecx, [eax+edx-1]
    lea     edx, [esp+230h+var_210]
    mov     [esp+230h+var_204], ecx
    mov     eax, [esi+4]
    push    edx
    mov     ecx, [eax+0BCh]
    push    ecx
    call    sub_4BF4D0
    mov     eax, [edi+18h]
    test    eax, eax
    jz      short loc_4AA989
    mov     dword ptr [eax+14h], 1
    jmp     short loc_4AA989
    ; ---------------------------------------------------------------------------

    loc_4AA97E:                             ; CODE XREF: sub_4AA8F0+2Cj
    push    0FFFFFFE8h
    push    0
    push    0
    call    sub_4BF4D0

    loc_4AA989:                             ; CODE XREF: sub_4AA8F0+25j
                                            ; sub_4AA8F0+83j ...
    add     edi, 9B6h
    push    100h                            ; size_t
    lea     edx, [esp+230h+var_200]
    push    edi                             ; char *
    push    edx                             ; char *
    call    _strncpy
    mov     edx, [esp+238h+arg_4]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    add     esp, 0Ch
    lea     ebx, [esp+22Ch+var_200]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    100h                            ; size_t
    mov     esi, edi
    mov     edi, ebx
    mov     ebx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    lea     eax, [esp+230h+var_100]
    and     ecx, 3
    push    edx                             ; char *
    rep movsb
    push    eax                             ; char *
    call    _strncpy
    add     esp, 0Ch
    lea     ecx, [esp+22Ch+var_100]
    push    ecx
    call    sub_4BB150
    lea     edx, [esp+22Ch+var_200]
    push    offset off_502828
    lea     eax, [esp+230h+var_200]
    push    edx
    push    eax
    call    sub_4BAFF0
    lea     ecx, [esp+22Ch+var_200]
    push    ecx
    call    sub_4BBC40
    test    eax, eax
    jz      loc_4AAC2D
    mov     ebx, [esp+22Ch+arg_8]
    mov     eax, ebx
    and     eax, 200h
    mov     [esp+22Ch+var_214], eax
    jz      short loc_4AAA61
    mov     esi, [esp+22Ch+arg_0]
    mov     edi, [esi+18h]
    mov     [esp+22Ch+var_21C], edi
    mov     edx, [edi+4]
    movsx   eax, word ptr [edx+0B6h]
    inc     eax
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     ebp, [edx+ecx*2]
    jmp     short loc_4AAA98
    ; ---------------------------------------------------------------------------

    loc_4AAA61:                             ; CODE XREF: sub_4AA8F0+13Fj
    lea     edx, [esp+22Ch+var_100]
    push    10F57h
    push    edx
    call    sub_4D83B0
    mov     ebp, eax
    mov     ecx, 43D5h
    xor     eax, eax
    mov     edi, ebp
    rep stosd
    mov     esi, [esp+234h+arg_0]
    mov     [esp+234h+var_21C], ebp
    stosw
    stosb
    mov     edi, [esp+234h+var_21C]
    add     esp, 8
    add     ebp, 3Fh

    loc_4AAA98:                             ; CODE XREF: sub_4AA8F0+16Fj
    lea     eax, [esp+22Ch+var_200]
    push    eax
    push    ebp
    call    sub_4AEAC0
    test    eax, eax
    jz      loc_4AAC22
    mov     eax, [esp+22Ch+var_214]
    xor     ecx, ecx
    cmp     eax, ecx
    jz      loc_4AAC41
    mov     ebx, [edi+4]
    mov     esi, 1
    movsx   ecx, word ptr [ebx+0B6h]
    inc     ecx
    cmp     ecx, esi
    jle     short loc_4AAB02
    lea     edi, [ebx+15Dh]

    loc_4AAAD3:                             ; CODE XREF: sub_4AA8F0+20Cj
    push    10h                             ; size_t
    push    offset aPanel_0                 ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      loc_4AAFC7
    movsx   edx, word ptr [ebx+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     edx
    cmp     esi, edx
    jl      short loc_4AAAD3
    mov     edi, [esp+22Ch+var_21C]

    loc_4AAB02:                             ; CODE XREF: sub_4AA8F0+1DBj
    or      ecx, 0FFFFFFFFh

    loc_4AAB05:                             ; CODE XREF: sub_4AA8F0+6DDj
    cmp     ecx, 0FFFFFFFFh
    jz      loc_4AAB9B
    mov     eax, ecx
    shl     eax, 3
    sub     eax, ecx
    lea     eax, [eax+eax*2]
    lea     edx, [ecx+eax*2]
    lea     eax, [ecx+edx*4]
    lea     eax, [ecx+eax*2]
    mov     ecx, [edi+4]
    mov     byte ptr [ecx+eax+29h], 0
    mov     ecx, [esp+22Ch+arg_8]
    mov     edx, [edi+4]
    or      ecx, 20h
    mov     [esp+22Ch+arg_8], ecx
    lea     ecx, [edx+eax]
    movsx   edx, word ptr [ebp+17h]
    movsx   eax, word ptr [ecx+17h]
    sub     eax, edx
    cdq
    sub     eax, edx
    movsx   edx, word ptr [ebp+19h]
    mov     esi, eax
    movsx   eax, word ptr [ecx+13h]
    sar     esi, 1
    add     esi, eax
    movsx   eax, word ptr [ecx+19h]
    movsx   ecx, word ptr [ecx+15h]
    sub     eax, edx
    cdq
    sub     eax, edx
    mov     edx, 1
    sar     eax, 1
    add     eax, ecx
    cmp     [ebp+0B6h], dx
    jl      short loc_4AABCF
    lea     ecx, [ebp+170h]

    loc_4AAB80:                             ; CODE XREF: sub_4AA8F0+2A7j
    add     [ecx-2], si
    add     [ecx], ax
    movsx   ebx, word ptr [ebp+0B6h]
    inc     edx
    add     ecx, 15Bh
    cmp     edx, ebx
    jle     short loc_4AAB80
    jmp     short loc_4AABCF
    ; ---------------------------------------------------------------------------

    loc_4AAB9B:                             ; CODE XREF: sub_4AA8F0+218j
    mov     ecx, 1
    cmp     [ebp+0B6h], cx
    jl      short loc_4AABCF
    lea     eax, [ebp+170h]

    loc_4AABAF:                             ; CODE XREF: sub_4AA8F0+2DDj
    mov     dx, [ebp+13h]
    add     [eax-2], dx
    mov     dx, [ebp+15h]
    add     [eax], dx
    inc     ecx
    movsx   edx, word ptr [ebp+0B6h]
    add     eax, 15Bh
    cmp     ecx, edx
    jle     short loc_4AABAF

    loc_4AABCF:                             ; CODE XREF: sub_4AA8F0+288j
                                            ; sub_4AA8F0+2A9j ...
    mov     edi, [edi+4]
    mov     ax, [ebp+0B6h]
    lea     esi, [ebp+15Bh]
    mov     ebx, [esp+22Ch+arg_8]
    add     [edi+0B6h], ax
    mov     edi, ebp
    movsx   eax, word ptr [ebp+0B6h]
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     ecx, [eax+ecx*2]
    mov     eax, [esp+22Ch+var_21C]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     ebp, [eax+4]
    mov     edi, eax
    jmp     short loc_4AAC38
    ; ---------------------------------------------------------------------------

    loc_4AAC22:                             ; CODE XREF: sub_4AA8F0+1B5j
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4
    jmp     short loc_4AAC3F
    ; ---------------------------------------------------------------------------

    loc_4AAC2D:                             ; CODE XREF: sub_4AA8F0+127j
    mov     edi, [esp+22Ch+var_21C]
    mov     ebx, [esp+22Ch+arg_8]

    loc_4AAC38:                             ; CODE XREF: sub_4AA8F0+330j
    mov     esi, [esp+22Ch+arg_0]

    loc_4AAC3F:                             ; CODE XREF: sub_4AA8F0+33Bj
    xor     ecx, ecx

    loc_4AAC41:                             ; CODE XREF: sub_4AA8F0+1C3j
    mov     eax, ebx
    mov     [edi+4], ebp
    and     eax, 200h
    mov     [edi+1Ch], ecx
    mov     [edi+24h], ecx
    mov     [edi+3Bh], ecx
    jnz     short loc_4AAC5E
    mov     edx, [esi+18h]
    mov     [edi], edx
    mov     [esi+18h], edi

    loc_4AAC5E:                             ; CODE XREF: sub_4AA8F0+364j
    cmp     eax, ecx
    mov     [edi+10h], ecx
    jnz     short loc_4AAC71
    test    bl, 80h
    jz      short loc_4AAC71
    mov     dword ptr [edi+10h], 80h

    loc_4AAC71:                             ; CODE XREF: sub_4AA8F0+373j
                                            ; sub_4AA8F0+378j
    mov     edx, [edi+10h]
    mov     eax, ebx
    and     eax, 800h
    or      edx, eax
    mov     [edi+10h], edx
    mov     eax, [esi+18h]
    cmp     eax, ecx
    jz      short loc_4AAC8E
    mov     dword ptr [eax+14h], 1

    loc_4AAC8E:                             ; CODE XREF: sub_4AA8F0+395j
    mov     eax, [esi+18h]
    cmp     eax, ecx
    jz      short loc_4AAC98
    mov     [eax+18h], ecx

    loc_4AAC98:                             ; CODE XREF: sub_4AA8F0+3A3j
    lea     ecx, [esp+22Ch+var_100]
    push    10h                             ; size_t
    lea     edx, [ebp+2]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     dword ptr [esi+64h], 0FFFFFFFFh
    test    bh, 4
    jnz     short loc_4AACD2
    call    sub_4C2470
    or      ebx, 1
    push    ebx
    push    esi
    call    sub_4A81E0
    mov     [esp+22Ch+var_218], eax
    call    sub_4C2870

    loc_4AACD2:                             ; CODE XREF: sub_4AA8F0+3C8j
    lea     ebx, [ebp+0CCh]
    or      ecx, 0FFFFFFFFh
    mov     edi, ebx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jnz     loc_4AAD80
    mov     edi, 1
    cmp     [ebp+0B6h], di
    jl      loc_4AAD80
    lea     esi, [ebp+15Dh]

    loc_4AAD02:                             ; CODE XREF: sub_4AA8F0+450j
    cmp     byte ptr [esi-2], 1
    jnz     short loc_4AAD30
    push    2                               ; size_t
    push    offset byte_502AE8              ; char *
    push    esi                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4AAD44
    push    4                               ; size_t
    push    offset aNext                    ; char *
    push    esi                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4AAD44

    loc_4AAD30:                             ; CODE XREF: sub_4AA8F0+416j
    movsx   eax, word ptr [ebp+0B6h]
    inc     edi
    add     esi, 15Bh
    cmp     edi, eax
    jle     short loc_4AAD02
    jmp     short loc_4AAD79
    ; ---------------------------------------------------------------------------

    loc_4AAD44:                             ; CODE XREF: sub_4AA8F0+42Aj
                                            ; sub_4AA8F0+43Ej
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     ecx, [eax+eax*2]
    lea     edx, [edi+ecx*2]
    mov     ecx, ebp
    add     ecx, edi
    lea     eax, [edi+edx*4]
    lea     edi, [ecx+eax*2+2]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4AAD79:                             ; CODE XREF: sub_4AA8F0+452j
    mov     esi, [esp+22Ch+arg_0]

    loc_4AAD80:                             ; CODE XREF: sub_4AA8F0+3F4j
                                            ; sub_4AA8F0+406j
    lea     ebx, [ebp+0DCh]
    or      ecx, 0FFFFFFFFh
    mov     edi, ebx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jnz     loc_4AAE2E
    mov     edi, 1
    cmp     [ebp+0B6h], di
    jl      loc_4AAE2E
    lea     esi, [ebp+15Dh]

    loc_4AADB0:                             ; CODE XREF: sub_4AA8F0+4FEj
    cmp     byte ptr [esi-2], 1
    jnz     short loc_4AADDE
    push    4                               ; size_t
    push    offset aPrev                    ; char *
    push    esi                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4AADF2
    push    6                               ; size_t
    push    offset aCancel                  ; char *
    push    esi                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4AADF2

    loc_4AADDE:                             ; CODE XREF: sub_4AA8F0+4C4j
    movsx   eax, word ptr [ebp+0B6h]
    inc     edi
    add     esi, 15Bh
    cmp     edi, eax
    jle     short loc_4AADB0
    jmp     short loc_4AAE27
    ; ---------------------------------------------------------------------------

    loc_4AADF2:                             ; CODE XREF: sub_4AA8F0+4D8j
                                            ; sub_4AA8F0+4ECj
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    lea     ecx, [eax+eax*2]
    lea     edx, [edi+ecx*2]
    mov     ecx, ebp
    add     ecx, edi
    lea     eax, [edi+edx*4]
    lea     edi, [ecx+eax*2+2]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4AAE27:                             ; CODE XREF: sub_4AA8F0+500j
    mov     esi, [esp+22Ch+arg_0]

    loc_4AAE2E:                             ; CODE XREF: sub_4AA8F0+4A2j
                                            ; sub_4AA8F0+4B4j
    lea     ebx, [ebp+0ECh]
    or      ecx, 0FFFFFFFFh
    mov     edi, ebx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4AAE8F
    movsx   eax, word ptr [ebp+0B6h]
    mov     esi, 1
    inc     eax
    cmp     eax, esi
    jle     short loc_4AAE7C
    lea     edi, [ebp+15Dh]

    loc_4AAE59:                             ; CODE XREF: sub_4AA8F0+58Aj
    push    10h                             ; size_t
    push    ebx                             ; char *
    push    edi                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4AAE7F
    movsx   ecx, word ptr [ebp+0B6h]
    inc     esi
    add     edi, 15Bh
    inc     ecx
    cmp     esi, ecx
    jl      short loc_4AAE59

    loc_4AAE7C:                             ; CODE XREF: sub_4AA8F0+561j
    or      esi, 0FFFFFFFFh

    loc_4AAE7F:                             ; CODE XREF: sub_4AA8F0+577j
    mov     edx, [esp+22Ch+var_21C]
    mov     [edx+20h], esi
    mov     esi, [esp+22Ch+arg_0]
    jmp     short loc_4AAEA2
    ; ---------------------------------------------------------------------------

    loc_4AAE8F:                             ; CODE XREF: sub_4AA8F0+550j
    mov     eax, [esp+22Ch+var_21C]
    push    1
    push    esi
    mov     dword ptr [eax+20h], 0
    call    sub_4A7960

    loc_4AAEA2:                             ; CODE XREF: sub_4AA8F0+59Dj
    mov     eax, [esp+22Ch+var_218]
    mov     ebx, 1
    cmp     eax, ebx
    mov     dword ptr [esi+60h], 0FFFFFFFFh
    jnz     loc_4AAFAB
    cmp     [ebp+0B6h], bx
    jnz     loc_4AAF9A
    cmp     byte ptr [ebp+15Bh], 3
    jnz     loc_4AAF9A
    mov     ecx, [esi+18h]
    mov     edi, [ecx+4]
    lea     ebp, [edi+15Bh]
    call    sub_4C13F0
    mov     edx, [ebp+1Fh]
    push    eax
    xor     eax, eax
    mov     al, [edx+esi+8B2h]
    push    eax
    call    sub_4C13A0
    movsx   eax, word ptr [edi+0B6h]
    xor     edx, edx
    inc     eax
    cmp     eax, ebx
    mov     esi, ebx
    jle     short loc_4AAF49
    mov     ecx, ebp

    loc_4AAF0A:                             ; CODE XREF: sub_4AA8F0+634j
    cmp     byte ptr [ecx], 7
    jnz     short loc_4AAF1B
    movsx   ebx, byte ptr [edi+183h]
    cmp     edx, ebx
    jz      short loc_4AAF28
    inc     edx

    loc_4AAF1B:                             ; CODE XREF: sub_4AA8F0+61Dj
    inc     esi
    add     ecx, 15Bh
    cmp     esi, eax
    jl      short loc_4AAF0A
    jmp     short loc_4AAF49
    ; ---------------------------------------------------------------------------

    loc_4AAF28:                             ; CODE XREF: sub_4AA8F0+628j
    mov     eax, esi
    shl     eax, 3
    sub     eax, esi
    lea     ecx, [eax+eax*2]
    lea     edx, [esi+ecx*2]
    mov     ecx, edi
    add     ecx, esi
    lea     eax, [esi+edx*4]
    mov     edx, [ecx+eax*2+0D6h]
    push    edx
    call    sub_4C1420

    loc_4AAF49:                             ; CODE XREF: sub_4AA8F0+616j
                                            ; sub_4AA8F0+636j
    movsx   eax, word ptr [edi+0B6h]
    inc     eax
    cmp     esi, eax
    jnz     short loc_4AAF63
    mov     ecx, dword_51FBA4
    mov     edx, [ecx]
    push    edx
    call    sub_4C1420

    loc_4AAF63:                             ; CODE XREF: sub_4AA8F0+663j
    mov     esi, [esp+22Ch+arg_0]
    push    1
    push    esi
    call    sub_49FC50
    mov     eax, [esi+18h]
    push    0
    add     ebp, 0B6h
    mov     dword ptr [eax+20h], 1
    movsx   ecx, word ptr [ebp+82h]
    push    ecx
    push    ebp
    push    1
    push    esi
    call    sub_4AB6C0
    call    sub_4C1A40

    loc_4AAF9A:                             ; CODE XREF: sub_4AA8F0+5D1j
                                            ; sub_4AA8F0+5DEj
    mov     eax, [esp+22Ch+var_21C]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 21Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4AAFAB:                             ; CODE XREF: sub_4AA8F0+5C4j
    mov     edx, [esp+22Ch+var_21C]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 21Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4AAFC7:                             ; CODE XREF: sub_4AA8F0+1F5j
    mov     edi, [esp+22Ch+var_21C]
    mov     ecx, esi
    jmp     loc_4AAB05
    sub_4AA8F0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    sub     esp, 10h
    mov     eax, [ecx+18h]
    test    eax, eax
    jnz     short loc_4AAFF4
    add     esp, 10h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4AAFF4:                             ; CODE XREF: .text:004AAFECj
    mov     eax, [eax+4]
    push    edi
    push    esi
    movsx   edx, word ptr [eax+13h]
    mov     [esp+8], edx
    movsx   esi, word ptr [eax+15h]
    mov     [esp+0Ch], esi
    movsx   edi, word ptr [eax+17h]
    lea     edx, [edi+edx-1]
    mov     [esp+10h], edx
    movsx   eax, word ptr [eax+19h]
    lea     edx, [eax+esi-1]
    mov     eax, [ecx+40h]
    mov     ecx, [ecx+3Ch]
    mov     [esp+14h], edx
    push    eax
    lea     edx, [esp+0Ch]
    push    ecx
    push    edx
    call    sub_4B6720
    pop     esi
    pop     edi
    add     esp, 10h
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    xor     eax, eax
    mov     edx, [ecx+18h]
    test    edx, edx
    setnz   al
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4AB060(int,char *)
    sub_4AB060 proc near                    ; CODE XREF: sub_41B2E0+526p
                                            ; sub_41B8D0+A3p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     eax, [eax+18h]
    test    eax, eax
    jz      short loc_4AB08D
    mov     edx, [eax+4]
    mov     ecx, [esp+arg_4]
    push    10h                             ; size_t
    add     edx, 2
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4AB08D
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB08D:                             ; CODE XREF: sub_4AB060+9j
                                            ; sub_4AB060+23j
    xor     eax, eax
    retn    8
    sub_4AB060 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB0A0 proc near                    ; CODE XREF: sub_41AA00+94p
                                            ; sub_41AA00+C9p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     dword ptr [eax+60h], 0FFFFFFFFh
    retn    4
    sub_4AB0A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB0B0 proc near                    ; CODE XREF: sub_49F9C0+68p
                                            ; sub_4AB0B0+25p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 10h
    push    edi
    mov     edi, [esp+14h+arg_0]
    test    edi, edi
    jnz     short loc_4AB0C5
    xor     eax, eax
    pop     edi
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4AB0C5:                             ; CODE XREF: sub_4AB0B0+Aj
    mov     eax, [edi]
    push    esi
    push    ebp
    mov     ebp, [esp+1Ch+arg_4]
    push    ebx
    mov     ebx, [esp+20h+arg_8]
    push    ebx
    push    ebp
    push    eax
    call    sub_4AB0B0
    mov     esi, [edi+4]
    test    ebx, ebx
    movsx   eax, word ptr [esi+13h]
    mov     [esp+20h+var_10], eax
    movsx   ecx, word ptr [esi+15h]
    mov     [esp+20h+var_C], ecx
    movsx   edx, word ptr [esi+17h]
    lea     eax, [edx+eax-1]
    mov     [esp+20h+var_8], eax
    movsx   edx, word ptr [esi+19h]
    lea     eax, [edx+ecx-1]
    mov     [esp+20h+var_4], eax
    mov     eax, [edi+14h]
    jnz     short loc_4AB12B
    cmp     eax, 1
    jnz     short loc_4AB15D
    mov     dword ptr [edi+14h], 0
    mov     eax, [esi+0BCh]
    movsx   ecx, word ptr [esi+15h]
    movsx   edx, word ptr [esi+13h]
    push    ecx
    push    edx
    push    eax
    jmp     short loc_4AB157
    ; ---------------------------------------------------------------------------

    loc_4AB12B:                             ; CODE XREF: sub_4AB0B0+5Aj
    cmp     eax, 1
    jz      short loc_4AB13F
    lea     ecx, [esp+20h+var_10]
    push    ebx
    push    ecx
    call    sub_4B67D0
    test    eax, eax
    jz      short loc_4AB15D

    loc_4AB13F:                             ; CODE XREF: sub_4AB0B0+7Ej
    mov     dword ptr [edi+14h], 0
    mov     ecx, [esi+0BCh]
    movsx   edx, word ptr [esi+15h]
    movsx   eax, word ptr [esi+13h]
    push    edx
    push    eax
    push    ecx

    loc_4AB157:                             ; CODE XREF: sub_4AB0B0+79j
    push    ebp
    call    sub_4C6B70

    loc_4AB15D:                             ; CODE XREF: sub_4AB0B0+5Fj
                                            ; sub_4AB0B0+8Dj
    pop     ebx
    pop     ebp
    pop     esi
    mov     eax, 1
    pop     edi
    add     esp, 10h
    retn    0Ch
    sub_4AB0B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB170 proc near                    ; CODE XREF: .text:0041F7CBp
                                            ; .text:0041F9FEp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    mov     edx, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    push    eax
    mov     eax, [edx+18h]
    push    ecx
    push    eax
    call    sub_4AB0B0
    retn    0Ch
    sub_4AB170 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB190 proc near                    ; CODE XREF: sub_44B690+24p
                                            ; sub_44C420+8Dp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_0]
    mov     eax, [esp+arg_4]
    mov     [ecx+0CC6h], eax
    retn    8
    sub_4AB190 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4AB1B0(int,int,char *,int,__int16,int,int)
    sub_4AB1B0 proc near                    ; CODE XREF: sub_41E420+207p
                                            ; sub_45F1D0+125p ...

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h
    arg_8= dword ptr  18h
    arg_C= dword ptr  1Ch
    arg_10= word ptr  20h
    arg_14= dword ptr  24h
    arg_18= dword ptr  28h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edx, [esi+4]
    mov     cx, [edx+0B6h]
    movsx   eax, cx
    inc     eax
    inc     ecx
    mov     [edx+0B6h], cx
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     edi, [esi+4]
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     ebp, [eax+ecx*2]
    mov     cx, [esp+4+arg_10]
    mov     eax, [esp+4+arg_C]
    add     ebp, edi
    mov     [ebp+15h], cx
    mov     ecx, [esp+4+arg_14]
    cmp     ecx, 0FFFFFFFFh
    mov     byte ptr [ebp+0], 5
    mov     [ebp+13h], ax
    jnz     short loc_4AB214
    mov     dx, [edx+17h]
    sub     dx, ax
    sub     edx, 5
    mov     [ebp+17h], dx
    jmp     short loc_4AB218
    ; ---------------------------------------------------------------------------

    loc_4AB214:                             ; CODE XREF: sub_4AB1B0+52j
    mov     [ebp+17h], cx

    loc_4AB218:                             ; CODE XREF: sub_4AB1B0+62j
    mov     edi, [esp+4+arg_4]
    mov     eax, 0Fh
    mov     [ebp+19h], ax
    mov     [ebp+1Fh], eax
    mov     eax, [esp+4+arg_18]
    xor     ebx, ebx
    mov     [ebp+1Bh], eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [ebp+1], bl
    mov     [ebp+23h], ebx
    mov     [ebp+27h], bl
    mov     [ebp+28h], bl
    mov     byte ptr [ebp+29h], 1
    mov     [ebp+2Ah], bl
    lea     edx, [ebp+2]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    7Fh                             ; size_t
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [ebp+0B6h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+8+arg_8]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     [ebp+135h], bl
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    sub_4AB1B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB290 proc near                    ; CODE XREF: sub_4288D0+1C0p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     eax, [eax+18h]
    test    eax, eax
    jz      short loc_4AB2A2
    mov     ecx, [esp+arg_4]
    mov     [eax+24h], ecx

    loc_4AB2A2:                             ; CODE XREF: sub_4AB290+9j
    mov     eax, 1
    retn    8
    sub_4AB290 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB2B0 proc near                    ; CODE XREF: sub_479C50+144p
                                            ; sub_479C50+1DFp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+18h]
    mov     edx, [ecx+4]
    mov     ax, [edx+0B6h]
    cmp     ax, 0C8h
    jnz     short loc_4AB2CC
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB2CC:                             ; CODE XREF: sub_4AB2B0+15j
    inc     eax
    push    edi
    mov     [edx+0B6h], ax
    push    esi
    movsx   eax, ax
    mov     ecx, eax
    mov     esi, [esp+8+arg_4]
    shl     ecx, 3
    sub     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [edx+ecx*2]
    mov     ecx, 4Fh
    mov     edi, eax
    rep movsd
    movsw
    mov     byte ptr [eax], 1
    pop     esi
    mov     eax, 1
    pop     edi
    retn    8
    sub_4AB2B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB310 proc near                    ; CODE XREF: sub_41E420+15Cp
                                            ; sub_479C50+232p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    mov     eax, [ebx+18h]
    mov     esi, [eax+4]
    mov     ax, [esi+0B6h]
    cmp     ax, 0C8h
    jnz     short loc_4AB330
    xor     eax, eax
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB330:                             ; CODE XREF: sub_4AB310+17j
    inc     eax
    push    edi
    mov     [esi+0B6h], ax
    movsx   eax, ax
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    lea     edx, [eax+ecx*2]
    mov     ecx, 33h
    lea     eax, [esi+edx]
    mov     esi, [esp+8+arg_4]
    mov     edi, eax
    rep movsd
    mov     byte ptr [eax], 6
    mov     eax, [ebx+18h]
    xor     ecx, ecx
    pop     edi
    mov     eax, [eax+4]
    mov     [eax+edx+0B6h], ecx
    add     eax, edx
    pop     esi
    pop     ebx
    mov     [eax+0BEh], ecx
    mov     [eax+0C2h], ecx
    mov     [eax+0C6h], cx
    mov     eax, 1
    retn    8
    sub_4AB310 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB3A0 proc near                    ; CODE XREF: sub_41E420+2DAp
                                            ; sub_41E420+358p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+18h]
    mov     edx, [ecx+4]
    mov     ax, [edx+0B6h]
    cmp     ax, 0C8h
    jnz     short loc_4AB3BC
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB3BC:                             ; CODE XREF: sub_4AB3A0+15j
    inc     eax
    push    edi
    mov     [edx+0B6h], ax
    push    esi
    movsx   eax, ax
    mov     ecx, eax
    mov     esi, [esp+8+arg_4]
    shl     ecx, 3
    sub     ecx, eax
    add     edx, eax
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [eax+ecx*2]
    lea     ecx, [eax+ecx*4]
    lea     eax, [edx+ecx*2]
    mov     ecx, 35h
    mov     edi, eax
    rep movsd
    movsw
    mov     byte ptr [eax], 0Dh
    pop     esi
    mov     eax, 1
    pop     edi
    retn    8
    sub_4AB3A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB400 proc near                    ; CODE XREF: sub_491C80+30p
                                            ; .text:00491D10p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    push    edi
    push    0
    push    eax
    lea     edi, [esi+30h]
    mov     [esi+2Ch], eax
    push    edi
    call    sub_4B8B30
    mov     eax, [esi+5Ch]
    push    edi
    or      al, 1
    mov     [esi+5Ch], eax
    call    sub_4B7EE0
    push    eax
    call    sub_4C2B20
    pop     edi
    pop     esi
    retn    8
    sub_4AB400 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB440 proc near                    ; CODE XREF: sub_4A9FD0+165p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    push    edi
    test    eax, eax
    jz      short loc_4AB463
    mov     eax, [esi+28h]
    test    eax, eax
    jnz     short loc_4AB46A
    mov     edi, [esi+24h]
    call    sub_4C2BA0
    cmp     eax, edi
    jz      short loc_4AB4B5
    jmp     short loc_4AB4A0
    ; ---------------------------------------------------------------------------

    loc_4AB463:                             ; CODE XREF: sub_4AB440+Cj
    mov     eax, [esi+2Ch]
    test    eax, eax
    jz      short loc_4AB494

    loc_4AB46A:                             ; CODE XREF: sub_4AB440+13j
    cmp     [esi+38h], eax
    jz      short loc_4AB4B5
    lea     edi, [esi+30h]
    push    0
    push    eax
    push    edi
    call    sub_4B8B30
    push    edi
    call    sub_4B7EE0
    push    eax
    call    sub_4C2B20
    mov     eax, [esi+5Ch]
    or      al, 1
    mov     [esi+5Ch], eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB494:                             ; CODE XREF: sub_4AB440+28j
    mov     edi, [esi+20h]
    call    sub_4C2BA0
    cmp     eax, edi
    jz      short loc_4AB4B5

    loc_4AB4A0:                             ; CODE XREF: sub_4AB440+21j
    push    edi
    call    sub_4C2B20
    mov     eax, [esi+5Ch]
    mov     dword ptr [esi+38h], 0
    and     al, 0FEh
    mov     [esi+5Ch], eax

    loc_4AB4B5:                             ; CODE XREF: sub_4AB440+1Fj
                                            ; sub_4AB440+2Dj ...
    pop     edi
    pop     esi
    retn    8
    sub_4AB440 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+8]
    mov     eax, [esi+1Ch]
    push    eax
    call    sub_4C2B20
    mov     eax, [esi+5Ch]
    and     al, 0FEh
    mov     [esi+5Ch], eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB4E0 proc near                    ; CODE XREF: sub_491200+337p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    push    eax
    mov     [esi+1Ch], eax
    mov     [esi+20h], eax
    mov     [esi+24h], eax
    call    sub_4C2B20
    mov     eax, [esi+5Ch]
    and     al, 0FEh
    mov     [esi+5Ch], eax
    xor     eax, eax
    mov     [esi+54h], eax
    mov     [esi+28h], eax
    mov     [esi+2Ch], eax
    pop     esi
    retn    8
    sub_4AB4E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB510 proc near                    ; CODE XREF: sub_4A3780+293p
                                            ; sub_4A3780+2D8p ...

    arg_0= dword ptr  4
    arg_4= byte ptr  8

    mov     al, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    test    al, 1
    jz      short loc_4AB53D
    mov     eax, [ecx+4Ch]
    cmp     eax, 201h
    jnz     short loc_4AB52E
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB52E:                             ; CODE XREF: sub_4AB510+14j
    cmp     eax, 203h
    jnz     short loc_4AB562
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB53D:                             ; CODE XREF: sub_4AB510+Aj
    test    al, 2
    jz      short loc_4AB562
    mov     eax, [ecx+4Ch]
    cmp     eax, 204h
    jnz     short loc_4AB553
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB553:                             ; CODE XREF: sub_4AB510+39j
    cmp     eax, 206h
    jnz     short loc_4AB562
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB562:                             ; CODE XREF: sub_4AB510+23j
                                            ; sub_4AB510+2Fj ...
    xor     eax, eax
    retn    8
    sub_4AB510 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB570 proc near                    ; CODE XREF: sub_4A3780+1A2p

    arg_0= dword ptr  4
    arg_4= byte ptr  8

    mov     al, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    test    al, 1
    jz      short loc_4AB58D
    cmp     dword ptr [ecx+4Ch], 203h
    jnz     short loc_4AB5A2
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB58D:                             ; CODE XREF: sub_4AB570+Aj
    test    al, 2
    jz      short loc_4AB5A2
    cmp     dword ptr [ecx+4Ch], 206h
    jnz     short loc_4AB5A2
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AB5A2:                             ; CODE XREF: sub_4AB570+13j
                                            ; sub_4AB570+1Fj ...
    xor     eax, eax
    retn    8
    sub_4AB570 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB5B0 proc near                    ; CODE XREF: sub_4A3780+336p
                                            ; sub_4A4170+94p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    mov     eax, [eax+54h]
    and     eax, ecx
    neg     eax
    sbb     eax, eax
    neg     eax
    retn    8
    sub_4AB5B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB5D0 proc near                    ; CODE XREF: sub_4A9FD0+3Ap

    var_28= dword ptr -28h
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    arg_0= dword ptr  4

    sub     esp, 28h
    push    ebx
    mov     ebx, [esp+2Ch+arg_0]
    push    esi
    push    edi
    test    byte ptr [ebx+5Ch], 1
    jz      short loc_4AB60A
    mov     eax, [ebx+9Ah]
    lea     esi, [ebx+30h]
    xor     edi, edi
    push    eax
    mov     di, [esi]
    push    esi
    call    sub_4B8BF0
    xor     ecx, ecx
    mov     cx, [esi]
    cmp     ecx, edi
    jz      short loc_4AB60A
    push    esi
    call    sub_4B7EE0
    push    eax
    call    sub_4C2B20

    loc_4AB60A:                             ; CODE XREF: sub_4AB5D0+Ej
                                            ; sub_4AB5D0+2Cj
    lea     edx, [esp+34h+var_18]
    push    edx
    call    sub_4C2DE0
    test    eax, eax
    jz      short loc_4AB677
    mov     eax, [ebx+18h]
    test    eax, eax
    jz      short loc_4AB680
    mov     edx, [eax+4]
    lea     ecx, [esp+34h+var_28]
    push    ecx
    push    0
    push    edx
    call    sub_4A1680
    lea     edx, [esp+34h+var_28]
    mov     eax, [esp+34h+var_14]
    mov     ecx, [esp+34h+var_18]
    push    eax
    push    ecx
    push    edx
    call    sub_4A1920
    test    eax, eax
    jnz     short loc_4AB64F
    mov     eax, [esp+34h+var_10]
    test    eax, eax
    jnz     short loc_4AB680

    loc_4AB64F:                             ; CODE XREF: sub_4AB5D0+75j
    lea     eax, [esp+34h+var_18]
    push    eax
    call    sub_4C2D60
    lea     edi, [ebx+3Ch]
    lea     esi, [esp+34h+var_18]
    mov     ecx, [esp+34h+var_10]
    mov     [ebx+54h], ecx
    mov     ecx, 6
    rep movsd
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4AB677:                             ; CODE XREF: sub_4AB5D0+46j
    add     ebx, 3Ch
    push    ebx
    call    sub_4C2340

    loc_4AB680:                             ; CODE XREF: sub_4AB5D0+4Dj
                                            ; sub_4AB5D0+7Dj
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 28h
    retn    4
    sub_4AB5D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB690 proc near                    ; CODE XREF: sub_4A3780+2CEp
                                            ; sub_4A3780+311p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_0]
    mov     eax, [esp+arg_4]
    mov     [ecx+58h], eax
    mov     ecx, [ecx+18h]
    mov     [ecx+37h], eax
    retn    8
    sub_4AB690 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB6B0 proc near                    ; CODE XREF: sub_41AA00+209p
                                            ; sub_41AA00+221p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     eax, [eax+58h]
    retn    4
    sub_4AB6B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB6C0 proc near                    ; CODE XREF: sub_4A7190+E3p
                                            ; sub_4A7290+1A4p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     edx, [esp+arg_8]
    push    edi
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     eax, [esp+4+arg_10]
    not     ecx
    dec     ecx
    test    eax, eax
    jnz     short loc_4AB6F5
    cmp     ecx, [esp+4+arg_C]
    jg      short loc_4AB6F5
    mov     eax, [esp+4+arg_0]
    mov     [eax+74h], ecx
    mov     ecx, [esp+4+arg_4]
    push    ecx
    push    eax
    call    sub_4A4D70
    pop     edi
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4AB6F5:                             ; CODE XREF: sub_4AB6C0+17j
                                            ; sub_4AB6C0+1Dj
    mov     ecx, [esp+4+arg_4]
    mov     eax, [esp+4+arg_0]
    push    ecx
    mov     byte ptr [edx], 0
    push    eax
    mov     dword ptr [eax+74h], 0
    call    sub_4A4D70
    pop     edi
    retn    14h
    sub_4AB6C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AB720 proc near                    ; CODE XREF: sub_4A7290+265p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    hMem= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 10h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+20h+arg_4]
    mov     esi, [esp+20h+arg_0]
    mov     eax, edi
    shl     eax, 3
    sub     eax, edi
    mov     ecx, [esi+18h]
    lea     eax, [eax+eax*2]
    mov     ebx, [ecx+4]
    lea     edx, [edi+eax*2]
    lea     eax, [edi+edx*4]
    mov     edx, [ecx+18h]
    lea     ebp, [edi+eax*2]
    xor     eax, eax
    add     ebp, ebx
    mov     [esp+20h+var_C], eax
    mov     [esp+20h+var_10], ebp
    add     ebp, 0B6h
    cmp     edx, eax
    mov     [esp+20h+var_8], eax
    jnz     short loc_4AB76E
    call    sub_4C1AB0
    mov     ebx, eax
    jmp     short loc_4AB772
    ; ---------------------------------------------------------------------------

    loc_4AB76E:                             ; CODE XREF: sub_4AB720+43j
    mov     ebx, [esp+20h+arg_8]

    loc_4AB772:                             ; CODE XREF: sub_4AB720+4Cj
    test    ebx, ebx
    jz      loc_4AB9E2
    mov     [esp+20h+var_C], 1

    loc_4AB782:                             ; CODE XREF: sub_4AB720+2B8j
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esp+20h+var_8], ebx
    repne scasb
    not     ecx
    lea     edi, [ebx-8]
    dec     ecx
    cmp     edi, 0EEh
    ja      loc_4AB92F
    xor     edx, edx
    mov     dl, ds:byte_4ABA28[edi]
    jmp     ds:off_4ABA00[edx*4]

    loc_4AB7B0:                             ; DATA XREF: .text:004ABA18o
    mov     [esi+74h], ecx
    jmp     loc_4AB9CF
    ; ---------------------------------------------------------------------------

    loc_4AB7B8:                             ; CODE XREF: sub_4AB720+89j
                                            ; DATA XREF: .text:004ABA14o
    mov     dword ptr [esi+74h], 0
    jmp     loc_4AB9CF
    ; ---------------------------------------------------------------------------

    loc_4AB7C4:                             ; CODE XREF: sub_4AB720+89j
                                            ; DATA XREF: .text:004ABA00o
    mov     eax, [esi+74h]
    test    eax, eax
    jz      loc_4AB9CF
    lea     edx, [eax-1]
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esi+74h], edx
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, edx
    mov     edi, ecx
    lea     edx, [edi-1]
    cmp     eax, edx
    jge     short loc_4AB85B

    loc_4AB7EC:                             ; CODE XREF: sub_4AB720+D7j
    mov     cl, [ebp+eax+1]
    mov     [ebp+eax+0], cl
    inc     eax
    cmp     eax, edx
    jl      short loc_4AB7EC
    mov     byte ptr [edi+ebp-1], 0
    jmp     loc_4AB9CF
    ; ---------------------------------------------------------------------------

    loc_4AB803:                             ; CODE XREF: sub_4AB720+89j
                                            ; DATA XREF: .text:004ABA1Co
    mov     eax, [esi+74h]
    test    eax, eax
    jz      loc_4AB9CF
    dec     eax
    jmp     loc_4AB9CC
    ; ---------------------------------------------------------------------------

    loc_4AB814:                             ; CODE XREF: sub_4AB720+89j
                                            ; DATA XREF: .text:004ABA20o
    mov     eax, [esi+74h]
    cmp     eax, ecx
    jge     loc_4AB9CF
    jmp     loc_4AB9CB
    ; ---------------------------------------------------------------------------

    loc_4AB824:                             ; CODE XREF: sub_4AB720+89j
                                            ; DATA XREF: .text:004ABA10o
    test    ecx, ecx
    jz      loc_4AB9CF
    mov     edx, [esi+74h]
    cmp     edx, ecx
    jge     loc_4AB9CF
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, edx
    mov     edi, ecx
    lea     edx, [edi-1]
    cmp     eax, edx
    jge     short loc_4AB85B

    loc_4AB84E:                             ; CODE XREF: sub_4AB720+139j
    mov     cl, [ebp+eax+1]
    mov     [ebp+eax+0], cl
    inc     eax
    cmp     eax, edx
    jl      short loc_4AB84E

    loc_4AB85B:                             ; CODE XREF: sub_4AB720+CAj
                                            ; sub_4AB720+12Cj
    mov     byte ptr [edi+ebp-1], 0
    jmp     loc_4AB9CF
    ; ---------------------------------------------------------------------------

    loc_4AB865:                             ; CODE XREF: sub_4AB720+89j
                                            ; DATA XREF: .text:004ABA08o ...
    call    sub_4B6220
    mov     eax, [eax+40h]
    push    eax                             ; hWndNewOwner
    call    ds:OpenClipboard
    test    eax, eax
    jz      loc_4AB9CF
    push    1                               ; uFormat
    call    ds:GetClipboardData
    mov     edi, eax
    test    edi, edi
    mov     [esp+20h+hMem], edi
    jz      loc_4AB924
    push    edi                             ; hMem
    call    ds:GlobalSize
    mov     ebx, eax
    test    ebx, ebx
    jz      loc_4AB924
    push    edi                             ; hMem
    call    ds:GlobalLock
    mov     esi, eax
    mov     ecx, 20h
    mov     edx, [esp+20h+var_10]
    xor     eax, eax
    mov     edi, ebp
    rep stosd
    movsx   eax, word ptr [edx+138h]
    dec     eax
    cmp     ebx, eax
    jge     short loc_4AB8C9
    mov     eax, ebx

    loc_4AB8C9:                             ; CODE XREF: sub_4AB720+1A5j
    mov     ecx, eax
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    ebp
    and     ecx, 3
    rep movsb
    call    sub_4A5030
    mov     esi, [esp+20h+var_10]
    movsx   ecx, word ptr [esi+17h]
    cmp     eax, ecx
    jle     short loc_4AB915

    loc_4AB8EB:                             ; CODE XREF: sub_4AB720+1F3j
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4AB915
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    push    ebp
    mov     [ecx+ebp-1], al
    call    sub_4A5030
    movsx   edx, word ptr [esi+17h]
    cmp     eax, edx
    jg      short loc_4AB8EB

    loc_4AB915:                             ; CODE XREF: sub_4AB720+1C9j
                                            ; sub_4AB720+1D7j
    mov     eax, [esp+20h+hMem]
    push    eax                             ; hMem
    call    ds:GlobalUnlock
    mov     esi, [esp+20h+arg_0]

    loc_4AB924:                             ; CODE XREF: sub_4AB720+16Cj
                                            ; sub_4AB720+17Dj
    call    ds:CloseClipboard
    jmp     loc_4AB9CF
    ; ---------------------------------------------------------------------------

    loc_4AB92F:                             ; CODE XREF: sub_4AB720+7Bj
                                            ; sub_4AB720+89j
                                            ; DATA XREF: ...
    mov     eax, [esp+20h+var_10]
    movsx   edx, word ptr [eax+138h]
    cmp     ecx, edx
    jz      loc_4AB9CF
    cmp     ebx, 20h
    jl      loc_4AB9CF
    cmp     ebx, 7Fh
    jg      short loc_4AB9CF
    test    byte ptr [eax+1Bh], 2
    jz      short loc_4AB972
    push    ebx                             ; int
    call    _isalnum
    add     esp, 4
    test    eax, eax
    jnz     short loc_4AB972
    cmp     ebx, 5Fh
    jz      short loc_4AB972
    cmp     ebx, 20h
    jz      short loc_4AB972
    cmp     ebx, 27h
    jnz     short loc_4AB9CF

    loc_4AB972:                             ; CODE XREF: sub_4AB720+234j
                                            ; sub_4AB720+241j ...
    push    ebp
    mov     byte ptr [esp+24h+arg_8], bl
    mov     byte ptr [esp+24h+arg_8+1], 0
    call    sub_4A5030
    mov     edi, eax
    lea     eax, [esp+20h+arg_8]
    push    eax
    call    sub_4A5030
    add     edi, eax
    mov     ecx, [esp+20h+var_10]
    movsx   edx, word ptr [ecx+17h]
    sub     edx, 4
    cmp     edi, edx
    jg      short loc_4AB9CF
    mov     eax, ecx
    mov     ecx, [esi+74h]
    movsx   eax, word ptr [eax+138h]
    dec     eax
    cmp     eax, ecx
    jle     short loc_4AB9C1
    lea     edi, [ebp+eax+0]

    loc_4AB9B3:                             ; CODE XREF: sub_4AB720+29Fj
    mov     cl, [edi-1]
    dec     eax
    mov     [edi], cl
    mov     ecx, [esi+74h]
    dec     edi
    cmp     eax, ecx
    jg      short loc_4AB9B3

    loc_4AB9C1:                             ; CODE XREF: sub_4AB720+28Dj
    mov     edx, [esi+74h]
    mov     [ebp+edx+0], bl
    mov     eax, [esi+74h]

    loc_4AB9CB:                             ; CODE XREF: sub_4AB720+FFj
    inc     eax

    loc_4AB9CC:                             ; CODE XREF: sub_4AB720+EFj
    mov     [esi+74h], eax

    loc_4AB9CF:                             ; CODE XREF: sub_4AB720+93j
                                            ; sub_4AB720+9Fj ...
    call    sub_4C1AB0
    mov     ebx, eax
    test    ebx, ebx
    jnz     loc_4AB782

    loc_4AB9DE:                             ; CODE XREF: sub_4AB720+89j
                                            ; DATA XREF: .text:004ABA04o
    mov     edi, [esp+20h+arg_4]

    loc_4AB9E2:                             ; CODE XREF: sub_4AB720+54j
    mov     eax, [esp+20h+var_C]
    test    eax, eax
    jz      short loc_4AB9F1
    push    edi
    push    esi
    call    sub_4A4D70

    loc_4AB9F1:                             ; CODE XREF: sub_4AB720+2C8j
    mov     eax, [esp+20h+var_8]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    sub_4AB720 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4ABA00 dd offset loc_4AB7C4         ; DATA XREF: sub_4AB720+89r
    dd offset loc_4AB9DE
    dd offset loc_4AB865
    dd offset loc_4AB865
    dd offset loc_4AB824
    dd offset loc_4AB7B8
    dd offset loc_4AB7B0
    dd offset loc_4AB803
    dd offset loc_4AB814
    dd offset loc_4AB92F
    byte_4ABA28 db 0                        ; DATA XREF: sub_4AB720+83r
    dd 4 dup(9090909h), 9010909h, 28h dup(9090909h), 9020909h, 0Bh dup(9090909h)
    dd 5040309h, 7090906h, 90900809h, 90909090h, 8B909090h, 6A042444h, 99806800h
    dd 0E8500050h, 0FFFFEDBFh, 6074C085h, 708B5657h, 56A5304h, 50997868h, 0A8E85600h
    dd 8BFFFF42h, 0C1F003C8h, 0C82B03E1h, 14247C8Bh, 8D490C8Dh, 0C8D4814h
    dd 8DC03390h, 0C9834E14h, 0F7AEF2FFh, 8DF92BD1h, 0B69Ah, 8BC18B00h, 5BFB8BF7h
    dd 0F302E9C1h, 0B8C88BA5h, 1, 0F303E183h, 0C7665EA4h, 0FFFF1342h, 8C25Fh
    dd 8C2C033h, 90909000h, 8B909090h, 56042444h, 99946857h, 488B0050h, 60788B18h
    dd 4718B57h, 4745E856h, 8C68FFFFh, 57005099h, 4739E856h, 5E5FFFFFh, 900004C2h
    dd 55909090h, 24748B56h, 800680Ch, 68680000h, 56005031h, 0FFED0AE8h, 85E88BFFh
    dd 840FEDh, 8B000001h, 53571846h, 708B016Ah, 99946804h, 0E8560050h, 0FFFF41EBh
    dd 16AC88Bh, 2B03E1C1h, 998C68C8h, 8D560050h, 148D490Ch, 900C8D48h, 0D003D68Bh
    dd 0E84A3C8Dh, 0FFFF41C7h, 56AC88Bh, 2B03E1C1h, 997868C8h, 8D560050h, 148D490Ch
    dd 900C8D48h, 0D003D68Bh, 0E84A1C8Dh, 0FFFF41A3h, 0F003C88Bh, 2B03E1C1h
    dd 0B6C381C8h, 8D000000h, 148D490Ch, 900C8D48h, 148DC033h, 0B6B78D4Eh
    dd 8B000000h, 8320247Ch, 0AEF2FFC9h, 0F92BD1F7h, 14247489h, 0F78BC18Bh
    dd 14247C8Bh, 0B6C281h, 0E9C10000h, 8BA5F302h, 83C033C8h, 0A4F303E1h, 1C247C8Bh
    dd 0F2FFC983h, 2BD1F7AEh, 8BC18BF9h, 0C1FB8BF7h, 0A5F302E9h, 0C033C88Bh
    dd 0F303E183h, 247C8BA4h, 0FFC98318h, 0D1F7AEF2h, 0C18BF92Bh, 0FA8BF78Bh
    dd 0F302E9C1h, 5BC88BA5h, 0B803E183h, 1, 45C7A4F3h, 4ABBA008h, 5D5E5F00h
    dd 5E0010C2h, 0C25DC033h, 90900010h, 90909090h
    align 4

    loc_4ABD00:                             ; DATA XREF: sub_4ABD90+298o
    mov     eax, [esp+4]
    push    offset byte_502AE8
    mov     edx, [eax+18h]
    mov     ecx, [eax+60h]
    push    ecx
    mov     eax, [edx+4]
    push    eax
    call    sub_4A0300
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     eax, [eax+18h]
    test    eax, eax
    jnz     short loc_4ABD2E
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4ABD2E:                             ; CODE XREF: .text:004ABD29j
    mov     eax, [eax+4]
    push    esi
    push    ebx
    mov     esi, offset aMsgbox_gui         ; "MSGBOX.GUI"
    add     eax, 2

    loc_4ABD3B:                             ; CODE XREF: .text:004ABD5Dj
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4ABD6F
    test    cl, cl
    jz      short loc_4ABD5F
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4ABD6F
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4ABD3B

    loc_4ABD5F:                             ; CODE XREF: .text:004ABD47j
    xor     eax, eax
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    pop     ebx
    mov     eax, ecx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4ABD6F:                             ; CODE XREF: .text:004ABD43j
                                            ; .text:004ABD53j
    sbb     eax, eax
    pop     ebx
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4ABD90 proc near                    ; CODE XREF: sub_41EC50+30Ap
                                            ; .text:0041F6E5p ...

    var_20C= dword ptr -20Ch
    var_208= dword ptr -208h
    var_204= dword ptr -204h
    var_200= dword ptr -200h
    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 20Ch
    push    ebx
    mov     ebx, [esp+210h+arg_0]
    push    ebp
    push    800h
    push    offset aMsgbox_gui              ; "MSGBOX.GUI"
    push    ebx
    call    sub_4AA8F0
    mov     ebp, eax
    test    ebp, ebp
    mov     [esp+214h+var_208], ebp
    jz      loc_4AC059
    mov     eax, [esp+214h+arg_4]
    push    edi
    push    esi
    push    eax                             ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+21Ch+var_200]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    0FFFFFFFFh
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+220h+var_200]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+220h+arg_8]
    push    ecx
    push    edx
    push    ebx
    call    sub_4AC4C0
    mov     esi, eax
    push    2
    push    ebx
    mov     [esp+224h+var_204], esi
    call    sub_4A81E0
    push    0FEh                            ; size_t
    lea     eax, [esp+220h+var_100]
    push    esi                             ; char *
    push    eax                             ; char *
    call    _strncpy
    mov     ecx, [ebx+18h]
    add     esp, 0Ch
    lea     edx, [esp+21Ch+var_100]
    mov     ebx, [ecx+4]
    push    offset byte_50319C              ; char *
    push    edx                             ; char *
    call    _strtok
    mov     ecx, [ebp+4]
    add     esp, 8
    xor     edi, edi
    mov     esi, 14h
    movsx   ebp, word ptr [ecx+0B6h]
    inc     ebp
    test    eax, eax
    jz      short loc_4ABE8D

    loc_4ABE59:                             ; CODE XREF: sub_4ABD90+FBj
    mov     edx, [esp+21Ch+var_208]
    push    2                               ; int
    push    0FFFFFFFFh                      ; int
    push    esi                             ; __int16
    push    0                               ; int
    push    eax                             ; char *
    push    offset aText_0                  ; int
    push    edx                             ; int
    call    sub_4AB1B0
    call    sub_4C1450
    push    offset byte_50319C              ; char *
    push    0                               ; char *
    lea     esi, [esi+eax+5]
    call    _strtok
    add     esp, 8
    inc     edi
    test    eax, eax
    jnz     short loc_4ABE59

    loc_4ABE8D:                             ; CODE XREF: sub_4ABD90+C7j
    mov     eax, [esp+21Ch+arg_10]
    test    eax, eax
    jz      short loc_4ABEE7
    xor     esi, esi
    test    edi, edi
    jle     short loc_4ABEE2
    mov     eax, ebp
    mov     [esp+21Ch+var_20C], edi
    shl     eax, 3
    sub     eax, ebp
    lea     eax, [eax+eax*2]
    lea     ecx, [ebp+eax*2+0]
    mov     eax, ebx
    add     eax, ebp
    lea     edx, [ebp+ecx*4+0]
    lea     ebp, [eax+edx*2+0B6h]

    loc_4ABEBF:                             ; CODE XREF: sub_4ABD90+150j
    push    ebp
    call    sub_4A5030
    cmp     esi, eax
    jg      short loc_4ABED1
    push    ebp
    call    sub_4A5030
    mov     esi, eax

    loc_4ABED1:                             ; CODE XREF: sub_4ABD90+137j
    mov     eax, [esp+21Ch+var_20C]
    add     ebp, 15Bh
    dec     eax
    mov     [esp+21Ch+var_20C], eax
    jnz     short loc_4ABEBF

    loc_4ABEE2:                             ; CODE XREF: sub_4ABD90+10Cj
    add     esi, 14h
    jmp     short loc_4ABEEE
    ; ---------------------------------------------------------------------------

    loc_4ABEE7:                             ; CODE XREF: sub_4ABD90+106j
    mov     esi, [esp+21Ch+arg_8]

    loc_4ABEEE:                             ; CODE XREF: sub_4ABD90+155j
    lea     edi, [edi+edi*4]
    mov     [ebx+17h], si
    lea     ecx, [edi+edi*4]
    add     cx, [ebx+174h]
    add     ecx, 28h
    mov     [ebx+19h], cx
    call    sub_4B6700
    movsx   edx, word ptr [ebx+17h]
    sub     eax, edx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [ebx+13h], ax
    call    sub_4B6710
    movsx   ecx, word ptr [ebx+19h]
    sub     eax, ecx
    xor     ecx, ecx
    cdq
    sub     eax, edx
    sar     eax, 1
    cmp     [ebx+0B6h], cx
    mov     [ebx+15h], ax
    jl      short loc_4ABF62
    lea     eax, [ebx+1Bh]
    mov     dl, 5

    loc_4ABF3E:                             ; CODE XREF: sub_4ABD90+1D0j
    cmp     [eax-1Bh], dl
    jnz     short loc_4ABF51
    mov     si, [ebx+17h]
    mov     [eax-4], si
    mov     dword ptr [eax], 2

    loc_4ABF51:                             ; CODE XREF: sub_4ABD90+1B1j
    movsx   esi, word ptr [ebx+0B6h]
    inc     ecx
    add     eax, 15Bh
    cmp     ecx, esi
    jle     short loc_4ABF3E

    loc_4ABF62:                             ; CODE XREF: sub_4ABD90+1A7j
    mov     eax, [esp+21Ch+arg_C]
    test    eax, eax
    jz      loc_4AC066
    push    0Eh
    push    offset byte_502AE8              ; char *
    push    ebx                             ; int
    call    sub_49FDF0
    cmp     eax, 0FFFFFFFFh
    jz      loc_4AC00C
    mov     ecx, eax
    mov     edi, offset byte_502AE8
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, ebx
    add     ecx, eax
    lea     eax, [ecx+edx*2]
    mov     dx, [ebx+19h]
    sub     dx, [eax+19h]
    sub     edx, 0Fh
    mov     [eax+15h], dx
    mov     cx, [ebx+17h]
    sub     cx, [eax+17h]
    lea     edx, [ebx+0CCh]
    sub     ecx, 0Fh
    mov     [eax+13h], cx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [ebx+0DCh]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, offset byte_502AE8
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4AC00C:                             ; CODE XREF: sub_4ABD90+1F1j
    mov     esi, [esp+220h]

    loc_4AC013:                             ; CODE XREF: sub_4ABD90+2EAj
    push    1
    push    esi
    call    sub_49FB10
    push    1
    push    esi
    call    sub_4A81E0
    push    esi                             ; int
    mov     ecx, [esp+224h+var_20C]
    mov     dword ptr [ecx+8], offset loc_4ABD00
    call    sub_49FA90
    push    esi
    call    sub_4A9FD0
    mov     edx, [esp+220h+var_208]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, 1
    pop     esi
    pop     edi
    pop     ebp
    pop     ebx
    add     esp, 20Ch
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4AC059:                             ; CODE XREF: sub_4ABD90+27j
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 20Ch
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4AC066:                             ; CODE XREF: sub_4ABD90+1DBj
    mov     esi, [esp+21Ch+arg_0]
    push    0                               ; int
    push    offset byte_502AE8              ; char *
    push    esi                             ; int
    call    sub_4A0570
    jmp     short loc_4AC013
    sub_4ABD90 endp

    ; ---------------------------------------------------------------------------
    align 8

    loc_4AC080:                             ; DATA XREF: .text:004AC116o
    mov     eax, [esp+4]
    push    offset byte_502AE8
    mov     edx, [eax+18h]
    mov     ecx, [eax+60h]
    push    ecx
    mov     eax, [edx+4]
    push    eax
    call    sub_4A0300
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    push    esi
    mov     esi, [esp+0Ch]
    push    0
    push    offset aNotexist_gui            ; "NOTEXIST.GUI"
    push    esi
    call    sub_4AA8F0
    mov     ebx, eax
    test    ebx, ebx
    jz      short loc_4AC123
    mov     eax, [esi+18h]
    push    edi
    push    ebp
    push    5
    mov     esi, [eax+4]
    push    offset aName_0                  ; "NAME"
    push    esi
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     edi, [esp+18h]
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    xor     eax, eax
    lea     edx, [esi+ecx*2]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     ebp, [edx+0B6h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    pop     ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, 1
    and     ecx, 3
    rep movsb
    mov     word ptr [edx+13h], 0FFFFh
    mov     dword ptr [ebx+8], offset loc_4AC080
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4AC123:                             ; CODE XREF: .text:004AC0B7j
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    loc_4AC130:                             ; DATA XREF: .text:004AC2E2o
    mov     eax, [esp+4]
    push    esi
    push    0Eh
    push    offset aChc1                    ; "CHC1"
    mov     ecx, [eax+18h]
    mov     esi, [ecx+4]
    push    esi
    call    sub_49FDF0
    push    0Eh
    push    offset aChc2                    ; "CHC2"
    push    esi
    call    sub_49FDF0
    push    0Eh
    push    offset aChc3                    ; "CHC3"
    push    esi
    call    sub_49FDF0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    push    edi
    mov     edi, [esp+0Ch]
    push    0
    push    offset aChoice3_gui             ; "CHOICE3.GUI"
    push    edi
    call    sub_4AA8F0
    test    eax, eax
    mov     [esp+4], eax
    jz      loc_4AC2EE
    mov     eax, [edi+18h]
    push    esi
    push    ebp
    push    ebx
    mov     esi, [eax+4]
    push    1
    push    edi
    call    sub_4A81E0
    push    1
    push    offset aChc1                    ; "CHC1"
    push    esi
    call    sub_49FDF0
    mov     ecx, eax
    push    1
    shl     ecx, 3
    sub     ecx, eax
    push    offset aChc2                    ; "CHC2"
    push    esi
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    lea     edi, [edx+ecx*2]
    call    sub_49FDF0
    mov     ecx, eax
    push    1
    shl     ecx, 3
    sub     ecx, eax
    push    offset aChc3                    ; "CHC3"
    push    esi
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    lea     ebx, [edx+ecx*2]
    call    sub_49FDF0
    mov     ecx, eax
    push    5
    shl     ecx, 3
    sub     ecx, eax
    push    offset aTitl                    ; "TITL"
    push    esi
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    lea     ebp, [edx+ecx*2]
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    add     ebx, 0B6h
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    xor     eax, eax
    lea     edx, [esi+ecx*2]
    lea     esi, [edi+0B6h]
    mov     edi, [esp+20h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     [esp+18h], esi
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+18h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+24h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    lea     ebx, [ebp+0B6h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    lea     ebx, [edx+0B6h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+1Ch]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    pop     ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    pop     ebp
    and     ecx, 3
    mov     eax, 1
    rep movsb
    mov     ecx, [esp+8]
    mov     word ptr [edx+13h], 0FFFFh
    pop     esi
    mov     dword ptr [ecx+8], offset loc_4AC130
    pop     edi
    pop     ecx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4AC2EE:                             ; CODE XREF: .text:004AC189j
    xor     eax, eax
    pop     edi
    pop     ecx
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h

    loc_4AC300:                             ; DATA XREF: .text:004AC4A1o
    mov     eax, [esp+4]
    push    esi
    push    edi
    push    offset aChc1                    ; "CHC1"
    mov     ecx, [eax+18h]
    mov     edi, [eax+60h]
    push    edi
    mov     esi, [ecx+4]
    push    esi
    call    sub_4A0300
    push    offset aChc2                    ; "CHC2"
    push    edi
    push    esi
    call    sub_4A0300
    push    offset aInpt                    ; "INPT"
    push    edi
    push    esi
    call    sub_4A0300
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebp
    push    esi
    mov     esi, [esp+0Ch]
    push    0
    push    offset aInput_gui               ; "INPUT.GUI"
    push    esi
    call    sub_4AA8F0
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_4AC4AE
    mov     eax, [esi+18h]
    push    edi
    push    ebx
    push    3
    mov     ebx, [eax+4]
    push    offset aInpt                    ; "INPT"
    push    ebx
    call    sub_49FDF0
    mov     ecx, eax
    push    5
    shl     ecx, 3
    sub     ecx, eax
    mov     edi, [esp+20h]
    push    offset aTitl                    ; "TITL"
    push    ebx
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    lea     eax, [edx+ecx*2]
    or      ecx, 0FFFFFFFFh
    lea     edx, [eax+0B6h]
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    call    sub_49FDF0
    mov     ecx, eax
    push    1
    shl     ecx, 3
    sub     ecx, eax
    mov     edi, [esp+1Ch]
    push    offset aChc1                    ; "CHC1"
    push    ebx
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    xor     eax, eax
    lea     edx, [edx+ecx*2]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    lea     esi, [edx+0B6h]
    sub     edi, ecx
    mov     eax, ecx
    mov     [esp+20h], esi
    mov     esi, edi
    mov     edi, [esp+20h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     word ptr [edx+13h], 0FFFFh
    call    sub_49FDF0
    mov     ecx, eax
    push    1
    shl     ecx, 3
    sub     ecx, eax
    push    offset aChc2                    ; "CHC2"
    push    ebx
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, ebx
    add     edx, eax
    lea     esi, [edx+ecx*2]
    call    sub_49FDF0
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     edi, [esp+24h]
    add     ebx, eax
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    xor     eax, eax
    lea     edx, [ebx+ecx*2]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     ebx, [esi+0B6h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    add     edx, 0B6h
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    pop     ebx
    rep movsb
    mov     edi, [esp+1Ch]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, 1
    and     ecx, 3
    rep movsb
    mov     dword ptr [ebp+8], offset loc_4AC300
    pop     edi
    pop     esi
    pop     ebp
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4AC4AE:                             ; CODE XREF: .text:004AC357j
    pop     esi
    xor     eax, eax
    pop     ebp
    retn    18h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AC4C0 proc near                    ; CODE XREF: sub_4604A0+83p
                                            ; sub_476D80+BCp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    mov     ecx, [eax+18h]
    push    esi
    push    edi
    mov     edi, ebp
    mov     edx, [ecx+4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     edi, [esp+10h+arg_C]
    not     ecx
    dec     ecx
    cmp     edi, 0FFFFFFFFh
    mov     esi, ecx
    jz      short loc_4AC4F5
    push    edi
    push    edx
    call    sub_4A1810
    cmp     edi, 0FFFFFFFFh
    jnz     short loc_4AC501

    loc_4AC4F5:                             ; CODE XREF: sub_4AC4C0+27j
    push    offset aD_3                     ; "d"
    call    sub_4A5030
    jmp     short loc_4AC511
    ; ---------------------------------------------------------------------------

    loc_4AC501:                             ; CODE XREF: sub_4AC4C0+33j
    push    offset aD_3                     ; "d"
    call    sub_4C1440
    push    eax
    call    sub_4C1480

    loc_4AC511:                             ; CODE XREF: sub_4AC4C0+3Fj
    mov     ecx, eax
    mov     eax, [esp+10h+arg_8]
    cdq
    idiv    ecx
    mov     ecx, eax
    mov     eax, esi
    cdq
    idiv    ecx
    lea     edx, [esi+eax*2]
    lea     esi, [eax+edx+2]
    push    esi
    push    offset aWordwrap                ; "WordWrap"
    call    sub_4D83B0
    mov     ecx, esi
    mov     ebx, eax
    mov     edx, ecx
    xor     eax, eax
    mov     edi, ebx
    add     esp, 8
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    xor     esi, esi
    and     ecx, 3
    rep stosb
    mov     al, [ebp+0]
    mov     ecx, ebx
    test    al, al
    mov     edi, ebp
    mov     [esp+10h+arg_0], ecx
    jz      loc_4AC5F8
    jmp     short loc_4AC567
    ; ---------------------------------------------------------------------------

    loc_4AC563:                             ; CODE XREF: sub_4AC4C0+132j
    mov     ecx, [esp+10h+arg_0]

    loc_4AC567:                             ; CODE XREF: sub_4AC4C0+A1j
    mov     al, [edi]
    cmp     al, 0FFh
    jz      loc_4AC5F8
    mov     [esi+ebx], al
    mov     al, [edi+1]
    inc     esi
    inc     edi
    cmp     al, 20h
    jz      short loc_4AC585
    cmp     al, 0Ah
    jz      short loc_4AC585
    cmp     al, 2Dh
    jnz     short loc_4AC5E2

    loc_4AC585:                             ; CODE XREF: sub_4AC4C0+BBj
                                            ; sub_4AC4C0+BFj
    mov     eax, [esp+10h+arg_C]
    xor     ebp, ebp
    cmp     eax, 0FFFFFFFFh
    push    ecx
    jnz     short loc_4AC598
    call    sub_4A5030
    jmp     short loc_4AC5A3
    ; ---------------------------------------------------------------------------

    loc_4AC598:                             ; CODE XREF: sub_4AC4C0+CFj
    call    sub_4C1440
    push    eax
    call    sub_4C1480

    loc_4AC5A3:                             ; CODE XREF: sub_4AC4C0+D6j
    cmp     [esp+10h+arg_8], eax
    jg      short loc_4AC5D7
    mov     byte ptr [esi+ebx], 0
    mov     al, [edi-1]
    dec     esi
    dec     edi
    cmp     al, 20h
    mov     ebp, 1
    jz      short loc_4AC5CC

    loc_4AC5BB:                             ; CODE XREF: sub_4AC4C0+10Aj
    cmp     al, 2Dh
    jz      short loc_4AC5CC
    mov     byte ptr [esi+ebx], 0
    mov     al, [edi-1]
    dec     esi
    dec     edi
    cmp     al, 20h
    jnz     short loc_4AC5BB

    loc_4AC5CC:                             ; CODE XREF: sub_4AC4C0+F9j
                                            ; sub_4AC4C0+FDj
    mov     byte ptr [esi+ebx], 0Dh
    inc     esi
    mov     byte ptr [esi+ebx], 0Ah
    inc     esi
    inc     edi

    loc_4AC5D7:                             ; CODE XREF: sub_4AC4C0+E7j
    test    ebp, ebp
    jz      short loc_4AC5E2
    lea     eax, [esi+ebx]
    mov     [esp+10h+arg_0], eax

    loc_4AC5E2:                             ; CODE XREF: sub_4AC4C0+C3j
                                            ; sub_4AC4C0+119j
    mov     al, [edi]
    cmp     al, 0Ah
    jnz     short loc_4AC5F0
    lea     ecx, [esi+ebx+1]
    mov     [esp+10h+arg_0], ecx

    loc_4AC5F0:                             ; CODE XREF: sub_4AC4C0+126j
    test    al, al
    jnz     loc_4AC563

    loc_4AC5F8:                             ; CODE XREF: sub_4AC4C0+9Bj
                                            ; sub_4AC4C0+ABj
    mov     byte ptr [esi+ebx], 0
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    retn    10h
    sub_4AC4C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AC610 proc near                    ; CODE XREF: .text:004A3226p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     eax, [esp+arg_0]
    push    ebx
    mov     ebx, [esp+4+arg_C]
    push    ebp
    mov     ecx, [eax+18h]
    push    esi
    cmp     ebx, 0FFFFFFFFh
    push    edi
    mov     eax, [ecx+4]
    jz      short loc_4AC633
    push    ebx
    push    eax
    call    sub_4A1810
    cmp     ebx, 0FFFFFFFFh
    jnz     short loc_4AC64B

    loc_4AC633:                             ; CODE XREF: sub_4AC610+15j
    mov     esi, [esp+10h+arg_4]
    push    esi
    call    sub_4A5030
    mov     edi, eax
    cmp     edi, [esp+10h+arg_8]
    jl      loc_4AC705
    jmp     short loc_4AC667
    ; ---------------------------------------------------------------------------

    loc_4AC64B:                             ; CODE XREF: sub_4AC610+21j
    mov     esi, [esp+10h+arg_4]
    push    esi
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    mov     edi, eax
    cmp     edi, [esp+10h+arg_8]
    jl      loc_4AC705

    loc_4AC667:                             ; CODE XREF: sub_4AC610+39j
    mov     eax, [esp+10h+arg_10]
    test    eax, eax
    jz      short loc_4AC691
    cmp     ebx, 0FFFFFFFFh
    push    offset a___                     ; "..."
    jnz     short loc_4AC682
    call    sub_4A5030
    mov     ebp, eax
    jmp     short loc_4AC693
    ; ---------------------------------------------------------------------------

    loc_4AC682:                             ; CODE XREF: sub_4AC610+67j
    call    sub_4C1440
    push    eax
    call    sub_4C1480
    mov     ebp, eax
    jmp     short loc_4AC693
    ; ---------------------------------------------------------------------------

    loc_4AC691:                             ; CODE XREF: sub_4AC610+5Dj
    xor     ebp, ebp

    loc_4AC693:                             ; CODE XREF: sub_4AC610+70j
                                            ; sub_4AC610+7Fj
    mov     al, [esi]
    mov     ebx, esi
    test    al, al
    jz      short loc_4AC6A3

    loc_4AC69B:                             ; CODE XREF: sub_4AC610+91j
    mov     al, [ebx+1]
    inc     ebx
    test    al, al
    jnz     short loc_4AC69B

    loc_4AC6A3:                             ; CODE XREF: sub_4AC610+89j
    mov     eax, [esp+10h+arg_8]
    add     edi, ebp
    cmp     edi, eax
    jle     short loc_4AC6DB

    loc_4AC6AD:                             ; CODE XREF: sub_4AC610+C9j
    cmp     ebx, esi
    jz      short loc_4AC6DB
    mov     eax, [esp+10h+arg_C]
    dec     ebx
    cmp     eax, 0FFFFFFFFh
    push    esi
    mov     byte ptr [ebx], 0
    jnz     short loc_4AC6C6
    call    sub_4A5030
    jmp     short loc_4AC6D1
    ; ---------------------------------------------------------------------------

    loc_4AC6C6:                             ; CODE XREF: sub_4AC610+ADj
    call    sub_4C1440
    push    eax
    call    sub_4C1480

    loc_4AC6D1:                             ; CODE XREF: sub_4AC610+B4j
    mov     ecx, [esp+10h+arg_8]
    add     eax, ebp
    cmp     eax, ecx
    jg      short loc_4AC6AD

    loc_4AC6DB:                             ; CODE XREF: sub_4AC610+9Bj
                                            ; sub_4AC610+9Fj
    mov     eax, [esp+10h+arg_10]
    test    eax, eax
    jz      short loc_4AC705
    mov     edi, offset a___                ; "..."
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4AC705:                             ; CODE XREF: sub_4AC610+33j
                                            ; sub_4AC610+51j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    14h
    sub_4AC610 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 10h
    push    ebx
    mov     ebx, [esp+18h]
    push    ebp
    push    esi
    push    edi
    mov     dword ptr [esp+10h], 100h

    loc_4AC723:                             ; CODE XREF: .text:004AC7B3j
    xor     eax, eax
    xor     edi, edi
    mov     al, [ebx+2]
    xor     ecx, ecx
    mov     cl, [ebx+1]
    mov     [esp+14h], eax
    mov     eax, [esp+28h]
    xor     edx, edx
    mov     dl, [ebx]
    mov     ebp, 98967Fh
    mov     [esp+18h], ecx
    mov     [esp+24h], edx
    lea     esi, [eax+1]

    loc_4AC74B:                             ; CODE XREF: .text:004AC796j
    mov     eax, [esp+24h]
    xor     ecx, ecx
    mov     cl, [esi-1]
    sub     eax, ecx
    cdq
    mov     ecx, eax
    mov     eax, [esp+14h]
    xor     ecx, edx
    sub     ecx, edx
    xor     edx, edx
    mov     dl, [esi+1]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    add     ecx, eax
    xor     eax, eax
    mov     al, [esi]
    mov     edx, eax
    mov     eax, [esp+18h]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    add     ecx, eax
    cmp     ecx, ebp
    jge     short loc_4AC78C
    mov     ebp, ecx
    mov     [esp+1Ch], edi

    loc_4AC78C:                             ; CODE XREF: .text:004AC784j
    inc     edi
    add     esi, 4
    cmp     edi, 100h
    jl      short loc_4AC74B
    mov     eax, [esp+2Ch]
    mov     cl, [esp+1Ch]
    add     ebx, 4
    mov     [eax], cl
    inc     eax
    mov     [esp+2Ch], eax
    mov     eax, [esp+10h]
    dec     eax
    mov     [esp+10h], eax
    jnz     loc_4AC723
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AC7D0 proc near                    ; CODE XREF: .text:00426503p
                                            ; .text:00444629p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 10h
    mov     eax, [esp+10h+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+1Ch+arg_8]
    lea     ebx, [eax+0B2h]
    push    edi
    mov     ecx, 100h
    mov     edi, ebx
    add     eax, 8B2h
    rep movsd
    mov     [esp+20h+arg_0], eax
    mov     [esp+20h+arg_8], 100h

    loc_4AC7FF:                             ; CODE XREF: sub_4AC7D0+BFj
    xor     eax, eax
    xor     edi, edi
    mov     al, [ebx+2]
    xor     ecx, ecx
    mov     cl, [ebx+1]
    mov     [esp+20h+var_10], eax
    mov     eax, [esp+20h+arg_4]
    xor     edx, edx
    mov     dl, [ebx]
    mov     ebp, 98967Fh
    mov     [esp+20h+var_8], ecx
    mov     [esp+20h+var_C], edx
    lea     esi, [eax+1]

    loc_4AC827:                             ; CODE XREF: sub_4AC7D0+A2j
    mov     eax, [esp+20h+var_10]
    xor     ecx, ecx
    mov     cl, [esi+1]
    sub     eax, ecx
    cdq
    mov     ecx, eax
    mov     eax, [esp+20h+var_C]
    xor     ecx, edx
    sub     ecx, edx
    xor     edx, edx
    mov     dl, [esi-1]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    add     ecx, eax
    xor     eax, eax
    mov     al, [esi]
    mov     edx, eax
    mov     eax, [esp+20h+var_8]
    sub     eax, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    add     ecx, eax
    cmp     ecx, ebp
    jge     short loc_4AC868
    mov     ebp, ecx
    mov     [esp+20h+var_4], edi

    loc_4AC868:                             ; CODE XREF: sub_4AC7D0+90j
    inc     edi
    add     esi, 4
    cmp     edi, 100h
    jl      short loc_4AC827
    mov     eax, [esp+20h+arg_0]
    mov     cl, byte ptr [esp+20h+var_4]
    add     ebx, 4
    mov     [eax], cl
    inc     eax
    mov     [esp+20h+arg_0], eax
    mov     eax, [esp+20h+arg_8]
    dec     eax
    mov     [esp+20h+arg_8], eax
    jnz     loc_4AC7FF
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    0Ch
    sub_4AC7D0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    push    esi
    push    edi
    mov     edi, [esp+10h]
    lea     esi, [eax+0B2h]
    mov     ecx, 100h
    rep movsd
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 14h
    mov     eax, [esp+18h]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+18h]
    push    edi
    push    6
    push    offset aCols                    ; "COLS"
    mov     edi, [ecx+4]
    push    edi
    call    sub_49FDF0
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    movsx   ebx, word ptr [edi+15h]
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, edi
    add     ecx, eax
    movsx   esi, word ptr [ecx+edx*2+13h]
    lea     eax, [ecx+edx*2]
    mov     edx, [edi+0BCh]
    movsx   ecx, word ptr [edi+13h]
    mov     [esp+10h], edx
    add     esi, ecx
    movsx   edx, word ptr [eax+15h]
    add     ebx, edx
    mov     [esp+28h], esi
    xor     edi, edi
    jmp     short loc_4AC920
    ; ---------------------------------------------------------------------------

    loc_4AC91C:                             ; CODE XREF: .text:004AC95Bj
    mov     esi, [esp+28h]

    loc_4AC920:                             ; CODE XREF: .text:004AC91Aj
    mov     ebp, 10h

    loc_4AC925:                             ; CODE XREF: .text:004AC950j
    lea     eax, [esi+7]
    lea     edx, [esp+14h]
    mov     [esp+1Ch], eax
    mov     eax, [esp+10h]
    push    edi
    lea     ecx, [ebx+7]
    push    edx
    push    eax
    mov     [esp+20h], esi
    mov     [esp+24h], ebx
    mov     [esp+2Ch], ecx
    call    sub_4BF6F0
    add     esi, 8
    inc     edi
    dec     ebp
    jnz     short loc_4AC925
    add     ebx, 8
    cmp     edi, 100h
    jl      short loc_4AC91C
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 10h
    mov     eax, [esp+14h]
    push    ebx
    push    esi
    push    edi
    mov     ecx, [eax+18h]
    push    6
    push    offset aCols                    ; "COLS"
    mov     esi, [ecx+4]
    push    esi
    call    sub_49FDF0
    mov     ecx, eax
    mov     edi, [esi+0BCh]
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, esi
    add     ecx, eax
    movsx   ebx, word ptr [ecx+edx*2+13h]
    lea     eax, [ecx+edx*2]
    movsx   ecx, word ptr [esi+15h]
    movsx   edx, word ptr [eax+15h]
    movsx   eax, word ptr [esi+13h]
    mov     esi, [esp+24h]
    add     ebx, eax
    mov     eax, esi
    add     ecx, edx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 0Fh
    xor     eax, edx
    sub     eax, edx
    lea     ebx, [ebx+eax*8]
    mov     eax, esi
    cdq
    and     edx, 0Fh
    mov     [esp+0Ch], ebx
    add     eax, edx
    lea     edx, [esp+0Ch]
    sar     eax, 4
    add     ebx, 7
    lea     eax, [ecx+eax*8]
    mov     ecx, [esp+28h]
    mov     [esp+10h], eax
    push    ecx
    add     eax, 7
    push    edx
    push    edi
    mov     [esp+20h], ebx
    mov     [esp+24h], eax
    call    sub_4BF8C0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch]
    push    esi
    push    edi
    push    4
    mov     eax, [ebp+18h]
    push    offset off_509A00
    mov     esi, [eax+4]
    push    esi
    call    sub_49FDF0
    mov     ecx, eax
    push    4
    shl     ecx, 3
    sub     ecx, eax
    mov     edi, [esp+1Ch]
    mov     ebx, [esp+20h]
    push    offset aGren                    ; "GREN"
    lea     ecx, [ecx+ecx*2]
    push    esi
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    mov     edx, esi
    add     edx, eax
    lea     eax, [edx+ecx*2]
    movzx   cx, byte ptr [edi+ebx*4]
    mov     [eax+140h], cx
    call    sub_49FDF0
    mov     ecx, eax
    push    4
    shl     ecx, 3
    sub     ecx, eax
    push    offset aBlue                    ; "BLUE"
    push    esi
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, esi
    add     ecx, eax
    lea     eax, [ecx+edx*2]
    movzx   dx, byte ptr [edi+ebx*4+1]
    mov     [eax+140h], dx
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    push    4
    push    ebp
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    movzx   dx, byte ptr [edi+ebx*4+2]
    lea     eax, [esi+ecx*2]
    mov     [eax+140h], dx
    call    sub_4A81E0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 320h
    mov     eax, [esp+328h]
    mov     ecx, 100h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+330h]
    push    edi
    lea     edi, [esp+30h]
    rep movsd
    mov     ecx, [esp+33Ch]
    mov     ebp, eax
    cmp     eax, ecx
    jl      short loc_4ACB12
    mov     ebp, ecx

    loc_4ACB12:                             ; CODE XREF: .text:004ACB0Ej
    cmp     eax, ecx
    jle     short loc_4ACB1C
    mov     [esp+14h], eax
    jmp     short loc_4ACB22
    ; ---------------------------------------------------------------------------

    loc_4ACB1C:                             ; CODE XREF: .text:004ACB14j
    mov     [esp+14h], ecx
    mov     eax, ecx

    loc_4ACB22:                             ; CODE XREF: .text:004ACB1Aj
    lea     edi, [ebp+ebp*2+0]
    xor     edx, edx
    xor     ecx, ecx
    mov     ebx, eax
    mov     dl, [esp+edi+31h]
    mov     cl, [esp+edi+30h]
    mov     [esp+1Ch], edx
    xor     edx, edx
    mov     dl, [esp+edi+32h]
    lea     esi, [esp+edi+30h]
    mov     [esp+20h], edx
    lea     edi, [eax+eax*2]
    xor     edx, edx
    mov     [esp+18h], ecx
    mov     dl, [esp+edi+30h]
    sub     ebx, ebp
    sub     edx, ecx
    xor     ecx, ecx
    mov     cl, [esp+edi+31h]
    mov     [esp+24h], edx
    mov     edx, [esp+1Ch]
    mov     [esp+10h], ebp
    sub     ecx, edx
    xor     edx, edx
    mov     dl, [esp+edi+32h]
    mov     edi, [esp+20h]
    sub     edx, edi
    cmp     ebp, eax
    mov     [esp+28h], ecx
    mov     [esp+2Ch], edx
    jge     short loc_4ACBB7

    loc_4ACB83:                             ; CODE XREF: .text:004ACBB5j
    mov     edi, [esp+10h]
    sub     edi, ebp
    xor     ecx, ecx

    loc_4ACB8B:                             ; CODE XREF: .text:004ACBA4j
    mov     eax, [esp+ecx+24h]
    add     ecx, 4
    imul    eax, edi
    cdq
    idiv    ebx
    mov     dl, [esp+ecx+14h]
    add     al, dl
    mov     [esi], al
    inc     esi
    cmp     ecx, 0Ch
    jl      short loc_4ACB8B
    mov     eax, [esp+10h]
    mov     ecx, [esp+14h]
    inc     eax
    cmp     eax, ecx
    mov     [esp+10h], eax
    jl      short loc_4ACB83

    loc_4ACBB7:                             ; CODE XREF: .text:004ACB81j
    mov     edi, [esp+334h]
    mov     ecx, 100h
    lea     esi, [esp+30h]
    rep movsd
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 320h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    esi
    push    edi
    push    6
    mov     ecx, [eax+18h]
    push    offset aCols                    ; "COLS"
    mov     esi, [ecx+4]
    push    esi
    call    sub_49FDF0
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    lea     edx, [ecx+ecx*2]
    lea     ecx, [eax+edx*2]
    lea     edx, [eax+ecx*4]
    mov     ecx, esi
    add     ecx, eax
    mov     eax, [esp+10h]
    lea     edi, [ecx+edx*2]
    movsx   edx, word ptr [esi+13h]
    movsx   ecx, word ptr [edi+13h]
    sub     eax, edx
    sub     eax, ecx
    cdq
    and     edx, 7
    add     eax, edx
    movsx   edx, word ptr [esi+15h]
    mov     ecx, eax
    mov     eax, [esp+14h]
    sub     eax, edx
    movsx   edx, word ptr [edi+15h]
    sub     eax, edx
    cdq
    and     edx, 7
    add     eax, edx
    sar     ecx, 3
    sar     eax, 3
    test    ecx, ecx
    jge     short loc_4ACC4A
    xor     ecx, ecx

    loc_4ACC4A:                             ; CODE XREF: .text:004ACC46j
    cmp     ecx, 0Fh
    jle     short loc_4ACC54
    mov     ecx, 0Fh

    loc_4ACC54:                             ; CODE XREF: .text:004ACC4Dj
    test    eax, eax
    jge     short loc_4ACC5A
    xor     eax, eax

    loc_4ACC5A:                             ; CODE XREF: .text:004ACC56j
    cmp     eax, 0Fh
    jle     short loc_4ACC64
    mov     eax, 0Fh

    loc_4ACC64:                             ; CODE XREF: .text:004ACC5Dj
    shl     eax, 4
    pop     edi
    add     eax, ecx
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    push    esi
    push    1
    mov     ecx, [eax+0CB6h]
    mov     dl, [ecx+140h]
    mov     ecx, [eax+0CBAh]
    mov     [esp+0Ch], dl
    mov     dl, [ecx+140h]
    mov     ecx, [eax+0CBEh]
    mov     [esp+0Dh], dl
    mov     dl, [ecx+140h]
    mov     ecx, [eax+9B2h]
    mov     [esp+0Eh], dl
    mov     edx, [esp+10h]
    mov     esi, [esp+0Ch]
    mov     [edx+ecx*4], esi
    mov     eax, [eax+9B2h]
    lea     ecx, [esp+0Ch]
    push    eax
    push    ecx
    call    sub_4BA200
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4ACCD0 proc near                    ; CODE XREF: sub_4ACE50+17Ap
                                            ; sub_4ACE50+1EAp ...

    var_1= dword ptr -1
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    esi
    mov     esi, [esp+8+arg_4]
    test    esi, esi
    mov     byte ptr [esp+8+var_1], 9
    jle     short loc_4ACCF5
    push    edi
    mov     edi, [esp+0Ch+arg_0]

    loc_4ACCE4:                             ; CODE XREF: sub_4ACCD0+22j
    lea     eax, [esp+0Ch+var_1]
    push    1
    push    eax
    push    edi
    call    sub_4BBBE0
    dec     esi
    jnz     short loc_4ACCE4
    pop     edi

    loc_4ACCF5:                             ; CODE XREF: sub_4ACCD0+Dj
    pop     esi
    pop     ecx
    retn    8
    sub_4ACCD0 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 64h
    mov     eax, [esp+6Ch]
    push    ebp
    push    esi
    push    edi
    push    eax
    lea     ecx, [esp+10h]
    push    offset aS_2                     ; "[%s]"
    push    ecx
    call    _sprintf
    mov     ebp, [esp+88h]
    mov     esi, [esp+80h]
    add     esp, 0Ch
    mov     byte ptr [esp+78h], 9
    lea     edi, [ebp-1]
    test    edi, edi
    jle     short loc_4ACD47

    loc_4ACD37:                             ; CODE XREF: .text:004ACD45j
    lea     edx, [esp+78h]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ACD37

    loc_4ACD47:                             ; CODE XREF: .text:004ACD35j
    lea     edi, [esp+0Ch]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+0Ch]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    push    1
    push    offset byte_50319C
    push    esi
    call    sub_4BBBE0
    test    ebp, ebp
    mov     byte ptr [esp+78h], 9
    jle     short loc_4ACD89
    mov     edi, ebp

    loc_4ACD79:                             ; CODE XREF: .text:004ACD87j
    lea     ecx, [esp+78h]
    push    1
    push    ecx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ACD79

    loc_4ACD89:                             ; CODE XREF: .text:004ACD75j
    push    2
    push    offset dword_509A04
    push    esi
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 64h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    push    ecx
    push    esi
    mov     esi, [esp+10h]
    push    edi
    mov     edi, [esp+10h]
    test    esi, esi
    mov     byte ptr [esp+0Bh], 9
    jle     short loc_4ACDC4

    loc_4ACDB4:                             ; CODE XREF: .text:004ACDC2j
    lea     eax, [esp+0Bh]
    push    1
    push    eax
    push    edi
    call    sub_4BBBE0
    dec     esi
    jnz     short loc_4ACDB4

    loc_4ACDC4:                             ; CODE XREF: .text:004ACDB2j
    push    2
    push    offset dword_509A08
    push    edi
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4ACDE0 proc near                    ; CODE XREF: sub_4ACE50+4B5p
                                            ; sub_4ACE50+4C5p ...

    var_65= dword ptr -65h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 68h
    push    ebx
    mov     ebx, [esp+6Ch+arg_0]
    push    esi
    mov     esi, [esp+70h+arg_C]
    test    esi, esi
    push    edi
    mov     byte ptr [esp+74h+var_65], 9
    jle     short loc_4ACE0A

    loc_4ACDFA:                             ; CODE XREF: sub_4ACDE0+28j
    lea     eax, [esp+74h+var_65]
    push    1
    push    eax
    push    ebx
    call    sub_4BBBE0
    dec     esi
    jnz     short loc_4ACDFA

    loc_4ACE0A:                             ; CODE XREF: sub_4ACDE0+18j
    mov     ecx, [esp+74h+arg_8]
    mov     edx, [esp+74h+arg_4]
    push    ecx
    push    edx
    lea     eax, [esp+7Ch+var_65+1]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+84h+var_65+1]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    lea     ecx, [esp+78h+var_65+1]
    push    ecx
    push    ebx
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 68h
    retn    10h
    sub_4ACDE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4ACE50 proc near                    ; CODE XREF: .text:004AE7C7p

    var_CD= dword ptr -0CDh
    var_C8= dword ptr -0C8h
    var_64= byte ptr -64h
    var_54= byte ptr -54h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0D0h
    push    ebx
    push    ebp
    mov     ebp, [esp+0D8h+arg_0]
    push    esi
    xor     ecx, ecx
    push    edi
    mov     cl, [ebp+0]
    lea     eax, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    __itoa
    mov     ebx, [esp+0ECh+arg_8]
    mov     esi, [esp+0ECh+arg_4]
    add     esp, 0Ch
    mov     [esp+0E0h+var_CD+1], eax
    test    ebx, ebx
    mov     byte ptr [esp+0E0h+var_CD], 9
    jle     short loc_4ACEA3
    mov     edi, ebx

    loc_4ACE93:                             ; CODE XREF: sub_4ACE50+51j
    lea     edx, [esp+0E0h+var_CD]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ACE93

    loc_4ACEA3:                             ; CODE XREF: sub_4ACE50+3Fj
    mov     eax, [esp+0E0h+var_CD+1]
    lea     ecx, [esp+0E0h+var_C8]
    push    eax
    push    offset aId_0                    ; "id"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0E0h+var_C8]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    xor     ecx, ecx
    lea     eax, [esp+0E0h+var_64]
    mov     cl, [ebp+1]
    push    0Ah                             ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     [esp+0E0h+var_CD+1], eax
    test    ebx, ebx
    mov     byte ptr [esp+0E0h+var_CD], 9
    jle     short loc_4ACF0D
    mov     edi, ebx

    loc_4ACEFD:                             ; CODE XREF: sub_4ACE50+BBj
    lea     edx, [esp+0E0h+var_CD]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ACEFD

    loc_4ACF0D:                             ; CODE XREF: sub_4ACE50+A9j
    mov     eax, [esp+0E0h+var_CD+1]
    lea     ecx, [esp+0E0h+var_C8]
    push    eax
    push    offset aAssoc                   ; "assoc"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0E0h+var_C8]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    lea     eax, [ebp+2]
    push    10h                             ; size_t
    lea     ecx, [esp+0E4h+var_64]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     [esp+0E0h+var_54], 0
    test    ebx, ebx
    mov     byte ptr [esp+0E0h+var_CD], 9
    jle     short loc_4ACF7C
    mov     edi, ebx

    loc_4ACF6C:                             ; CODE XREF: sub_4ACE50+12Aj
    lea     edx, [esp+0E0h+var_CD]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ACF6C

    loc_4ACF7C:                             ; CODE XREF: sub_4ACE50+118j
    lea     eax, [esp+0E0h+var_64]
    lea     ecx, [esp+0E0h+var_C8]
    push    eax
    push    offset aName                    ; "name"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0E0h+var_C8]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    movsx   ecx, word ptr [ebp+13h]
    lea     eax, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aXpos_0                  ; "xpos"
    lea     edx, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+0E0h+var_C8]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    cmp     byte ptr [ebp+0], 0
    jnz     short loc_4AD022
    mov     eax, dword_51FBA8
    test    eax, eax
    jz      short loc_4AD022
    mov     ax, [ebp+15h]
    test    ax, ax
    jl      short loc_4AD022
    add     eax, 0FFFFFE20h
    mov     [ebp+15h], ax

    loc_4AD022:                             ; CODE XREF: sub_4ACE50+1B5j
                                            ; sub_4ACE50+1BEj ...
    movsx   edx, word ptr [ebp+15h]
    lea     ecx, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aYpos_0                  ; "ypos"
    lea     eax, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    lea     ecx, [esp+0E4h+var_C8]
    push    ecx
    push    esi
    call    sub_4BBBE0
    movsx   eax, word ptr [ebp+17h]
    lea     edx, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aWidth                   ; "width"
    lea     ecx, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0E0h+var_C8]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    movsx   ecx, word ptr [ebp+19h]
    lea     eax, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aHeight                  ; "height"
    lea     edx, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+0E0h+var_C8]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    mov     edx, [ebp+1Bh]
    lea     ecx, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aAttribs                 ; "attribs"
    lea     eax, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    lea     ecx, [esp+0E4h+var_C8]
    push    ecx
    push    esi
    call    sub_4BBBE0
    mov     eax, [ebp+1Fh]
    lea     edx, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aColorf                  ; "colorf"
    lea     ecx, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0E0h+var_C8]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    mov     ecx, [ebp+23h]
    lea     eax, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aColorb                  ; "colorb"
    lea     edx, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+0E0h+var_C8]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    movsx   edx, byte ptr [ebp+27h]
    lea     ecx, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aTexturenumber           ; "texturenumber"
    lea     eax, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    lea     ecx, [esp+0E4h+var_C8]
    push    ecx
    push    esi
    call    sub_4BBBE0
    movsx   eax, byte ptr [ebp+28h]
    lea     edx, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    edx                             ; char *
    push    eax                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aFontnumber              ; "fontnumber"
    lea     ecx, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0E0h+var_C8]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    movsx   ecx, byte ptr [ebp+29h]
    lea     eax, [esp+0E0h+var_64]
    push    0Ah                             ; int
    push    eax                             ; char *
    push    ecx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    push    ebx
    push    esi
    call    sub_4ACCD0
    push    edi
    push    offset aActive_0                ; "active"
    lea     edx, [esp+0E8h+var_C8]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+0F0h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+0E0h+var_C8]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    movsx   edx, byte ptr [ebp+2Ah]
    push    ebx
    lea     ecx, [esp+0E4h+var_64]
    push    0Ah                             ; int
    push    ecx                             ; char *
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aCommonattribs           ; "commonattribs"
    push    esi
    call    sub_4ACDE0
    lea     eax, [ebp+33h]
    push    ebx
    push    eax
    push    offset aHelp                    ; "help"
    push    esi
    call    sub_4ACDE0
    mov     dl, [ebp+0B4h]
    push    ebx
    lea     ecx, [esp+0E4h+var_64]
    push    0Ah                             ; int
    and     edx, 1
    push    ecx                             ; char *
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aGaffile                 ; "gaffile"
    push    esi
    call    sub_4ACDE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D0h
    retn    0Ch
    sub_4ACE50 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AD350 proc near                    ; CODE XREF: sub_4AEAC0+8Cp

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_4]
    push    offset aCommon                  ; char *
    mov     ecx, ebx
    call    sub_4C3410
    cmp     eax, 1
    jnz     loc_4AD4E3
    mov     ecx, [ebx+4]
    push    edi
    push    esi
    push    ebp
    push    0                               ; int
    push    offset aId_0                    ; char *
    call    sub_4C46C0
    push    0                               ; int
    push    offset aAssoc                   ; char *
    mov     esi, [esp+14h+arg_0]
    mov     [esi], al
    mov     ecx, [ebx+4]
    call    sub_4C46C0
    mov     [esi+1], al
    mov     ecx, [ebx+4]
    push    offset Data                     ; int
    push    10h                             ; size_t
    lea     eax, [esi+2]
    push    offset aName                    ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    mov     ecx, [ebx+4]
    push    0                               ; int
    push    offset aXpos_0                  ; char *
    call    sub_4C46C0
    mov     [esi+13h], ax
    mov     ecx, [ebx+4]
    push    0                               ; int
    push    offset aYpos_0                  ; char *
    call    sub_4C46C0
    mov     [esi+15h], ax
    mov     ecx, [ebx+4]
    push    0                               ; int
    push    offset aWidth                   ; char *
    call    sub_4C46C0
    mov     [esi+17h], ax
    mov     ecx, [ebx+4]
    push    0                               ; int
    push    offset aHeight                  ; char *
    call    sub_4C46C0
    mov     [esi+19h], ax
    mov     ecx, [ebx+4]
    push    0                               ; int
    push    offset aAttribs                 ; char *
    call    sub_4C46C0
    mov     [esi+1Bh], eax
    mov     ecx, [ebx+4]
    push    0                               ; int
    push    offset aColorf                  ; char *
    call    sub_4C46C0
    and     eax, 0FFFFh
    push    0                               ; int
    mov     [esi+1Fh], eax
    mov     ecx, [ebx+4]
    push    offset aColorb                  ; char *
    call    sub_4C46C0
    and     eax, 0FFFFh
    push    0                               ; int
    mov     [esi+23h], eax
    mov     ecx, [ebx+4]
    push    offset aTexturenumber           ; char *
    call    sub_4C46C0
    mov     [esi+27h], al
    mov     ecx, [ebx+4]
    push    0                               ; int
    push    offset aFontnumber              ; char *
    call    sub_4C46C0
    mov     [esi+28h], al
    mov     ecx, [ebx+4]
    push    0                               ; int
    push    offset aActive_0                ; char *
    call    sub_4C46C0
    mov     [esi+29h], al
    mov     ecx, [ebx+4]
    push    0                               ; int
    push    offset aCommonattribs           ; char *
    call    sub_4C46C0
    push    offset Data                     ; int
    mov     [esi+2Ah], al
    lea     ebp, [esi+33h]
    push    80h                             ; size_t
    mov     ecx, [ebx+4]
    push    offset aHelp                    ; char *
    push    ebp                             ; char *
    call    sub_4C48C0
    mov     ecx, 20h
    xor     eax, eax
    mov     edi, ebp
    push    80h                             ; size_t
    rep stosd
    push    ebp                             ; int
    stosb
    call    sub_4C5740
    push    eax                             ; char *
    push    ebp                             ; char *
    call    _strncpy
    mov     ecx, [ebx+4]
    add     esp, 0Ch
    push    0                               ; int
    push    offset aGaffile                 ; char *
    call    sub_4C46C0
    mov     cx, [esi+0B4h]
    pop     ebp
    xor     al, cl
    and     eax, 1
    xor     eax, ecx
    mov     [esi+0B4h], ax
    pop     esi
    pop     edi

    loc_4AD4E3:                             ; CODE XREF: sub_4AD350+14j
    pop     ebx
    retn    8
    sub_4AD350 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AD4F0 proc near                    ; CODE XREF: .text:004AE80Bp

    var_C9= dword ptr -0C9h
    var_64= byte ptr -64h
    var_54= byte ptr -54h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0CCh
    mov     ecx, [esp+0CCh+arg_0]
    push    ebx
    push    ebp
    push    esi
    movsx   edx, word ptr [ecx+0B6h]
    push    edi
    lea     eax, [esp+0DCh+var_64]
    push    0Ah                             ; int
    push    eax                             ; char *
    push    edx                             ; int
    call    __itoa
    mov     ebp, [esp+0E8h+arg_8]
    mov     esi, [esp+0E8h+arg_4]
    add     esp, 0Ch
    mov     ebx, eax
    test    ebp, ebp
    mov     byte ptr [esp+0DCh+var_C9], 9
    jle     short loc_4AD543
    mov     edi, ebp

    loc_4AD533:                             ; CODE XREF: sub_4AD4F0+51j
    lea     eax, [esp+0DCh+var_C9]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AD533

    loc_4AD543:                             ; CODE XREF: sub_4AD4F0+3Fj
    push    ebx
    push    offset aTotalgadgets            ; "totalgadgets"
    lea     ecx, [esp+0E4h+var_C9+1]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0ECh+var_C9+1]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0DCh+var_C9+1]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    push    offset aVersion_0               ; "VERSION"
    lea     eax, [esp+0E0h+var_C9+1]
    push    offset aS_2                     ; "[%s]"
    push    eax
    inc     ebp
    call    _sprintf
    lea     eax, [ebp-1]
    add     esp, 0Ch
    test    eax, eax
    mov     byte ptr [esp+0DCh+var_C9], 9
    jle     short loc_4AD5AB
    mov     edi, eax

    loc_4AD59B:                             ; CODE XREF: sub_4AD4F0+B9j
    lea     ecx, [esp+0DCh+var_C9]
    push    1
    push    ecx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AD59B

    loc_4AD5AB:                             ; CODE XREF: sub_4AD4F0+A7j
    lea     edi, [esp+0DCh+var_C9+1]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0DCh+var_C9+1]
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    push    1
    push    offset byte_50319C
    push    esi
    call    sub_4BBBE0
    push    ebp
    push    esi
    call    sub_4ACCD0
    push    2
    push    offset dword_509A04
    push    esi
    call    sub_4BBBE0
    lea     eax, [esp+0DCh+var_64]
    push    0Ah                             ; int
    mov     ecx, [esp+0E0h+arg_0]
    push    eax                             ; char *
    movsx   edx, byte ptr [ecx+0C9h]
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     ebx, eax
    test    ebp, ebp
    mov     byte ptr [esp+0DCh+var_C9], 9
    jle     short loc_4AD621
    mov     edi, ebp

    loc_4AD611:                             ; CODE XREF: sub_4AD4F0+12Fj
    lea     eax, [esp+0DCh+var_C9]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AD611

    loc_4AD621:                             ; CODE XREF: sub_4AD4F0+11Dj
    push    ebx
    push    offset aMajor                   ; "major"
    lea     ecx, [esp+0E4h+var_C9+1]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0ECh+var_C9+1]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0DCh+var_C9+1]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    lea     eax, [esp+0DCh+var_64]
    push    0Ah                             ; int
    mov     ecx, [esp+0E0h+arg_0]
    push    eax                             ; char *
    movsx   edx, byte ptr [ecx+0CAh]
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     ebx, eax
    test    ebp, ebp
    mov     byte ptr [esp+0DCh+var_C9], 9
    jle     short loc_4AD68E
    mov     edi, ebp

    loc_4AD67E:                             ; CODE XREF: sub_4AD4F0+19Cj
    lea     eax, [esp+0DCh+var_C9]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AD67E

    loc_4AD68E:                             ; CODE XREF: sub_4AD4F0+18Aj
    push    ebx
    push    offset aMinor                   ; "minor"
    lea     ecx, [esp+0E4h+var_C9+1]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0ECh+var_C9+1]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0DCh+var_C9+1]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    lea     eax, [esp+0DCh+var_64]
    push    0Ah                             ; int
    mov     ecx, [esp+0E0h+arg_0]
    push    eax                             ; char *
    movsx   edx, byte ptr [ecx+0CBh]
    push    edx                             ; int
    call    __itoa
    add     esp, 0Ch
    mov     ebx, eax
    test    ebp, ebp
    mov     byte ptr [esp+0DCh+var_C9], 9
    jle     short loc_4AD6FB
    mov     edi, ebp

    loc_4AD6EB:                             ; CODE XREF: sub_4AD4F0+209j
    lea     eax, [esp+0DCh+var_C9]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AD6EB

    loc_4AD6FB:                             ; CODE XREF: sub_4AD4F0+1F7j
    push    ebx
    push    offset aRevision                ; "revision"
    lea     ecx, [esp+0E4h+var_C9+1]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+0ECh+var_C9+1]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0DCh+var_C9+1]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    test    ebp, ebp
    mov     byte ptr [esp+0DCh+var_C9], 9
    jle     short loc_4AD746

    loc_4AD736:                             ; CODE XREF: sub_4AD4F0+254j
    lea     eax, [esp+0DCh+var_C9]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     ebp
    jnz     short loc_4AD736

    loc_4AD746:                             ; CODE XREF: sub_4AD4F0+244j
    push    2
    push    offset dword_509A08
    push    esi
    call    sub_4BBBE0
    push    10h                             ; size_t
    lea     edx, [esp+0E0h+var_64]
    mov     ebx, [esp+0E0h+arg_0]
    lea     ecx, [ebx+0FCh]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    mov     ebp, [esp+0E8h+arg_8]
    add     esp, 0Ch
    test    ebp, ebp
    mov     [esp+0DCh+var_54], 0
    mov     byte ptr [esp+0DCh+var_C9], 9
    jle     short loc_4AD79A
    mov     edi, ebp

    loc_4AD78A:                             ; CODE XREF: sub_4AD4F0+2A8j
    lea     eax, [esp+0DCh+var_C9]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AD78A

    loc_4AD79A:                             ; CODE XREF: sub_4AD4F0+296j
    lea     ecx, [esp+0DCh+var_64]
    lea     edx, [esp+0DCh+var_C9+1]
    push    ecx
    push    offset aPanel_1                 ; "panel"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+0ECh+var_C9+1]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+0DCh+var_C9+1]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    test    ebp, ebp
    mov     byte ptr [esp+0DCh+var_C9], 9
    jle     short loc_4AD7EB
    mov     edi, ebp

    loc_4AD7DB:                             ; CODE XREF: sub_4AD4F0+2F9j
    lea     ecx, [esp+0DCh+var_C9]
    push    1
    push    ecx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AD7DB

    loc_4AD7EB:                             ; CODE XREF: sub_4AD4F0+2E7j
    lea     edx, [ebx+0CCh]
    lea     eax, [esp+0DCh+var_C9+1]
    push    edx
    push    offset aCrdefault               ; "crdefault"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+0ECh+var_C9+1]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    lea     ecx, [esp+0E0h+var_C9+1]
    push    ecx
    push    esi
    call    sub_4BBBE0
    push    ebp
    push    esi
    call    sub_4ACCD0
    lea     edx, [ebx+0DCh]
    lea     eax, [esp+0DCh+var_C9+1]
    push    edx
    push    offset aEscdefault              ; "escdefault"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+0ECh+var_C9+1]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    lea     ecx, [esp+0E0h+var_C9+1]
    push    ecx
    push    esi
    call    sub_4BBBE0
    add     ebx, 0ECh
    push    ebp
    push    ebx
    push    offset aDefaultfocus            ; "defaultfocus"
    push    esi
    call    sub_4ACDE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    0Ch
    sub_4AD4F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AD890 proc near                    ; CODE XREF: sub_4AEAC0+B5p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_4]
    push    edi
    push    0                               ; int
    mov     ecx, [esi+4]
    push    offset aTotalgadgets            ; char *
    call    sub_4C46C0
    push    offset Data                     ; int
    push    10h                             ; size_t
    mov     edi, [esp+0Ch+arg_0]
    push    offset aPanel_1                 ; char *
    mov     [edi+0B6h], ax
    mov     ecx, [esi+4]
    lea     eax, [edi+0FCh]
    push    eax                             ; char *
    call    sub_4C48C0
    push    offset Data                     ; int
    push    10h                             ; size_t
    lea     ecx, [edi+0CCh]
    push    offset aCrdefault               ; char *
    push    ecx                             ; char *
    mov     ecx, [esi+4]
    call    sub_4C48C0
    mov     ecx, [esi+4]
    push    offset Data                     ; int
    push    10h                             ; size_t
    lea     edx, [edi+0DCh]
    push    offset aEscdefault              ; char *
    push    edx                             ; char *
    call    sub_4C48C0
    mov     ecx, [esi+4]
    push    offset Data                     ; int
    push    10h                             ; size_t
    lea     eax, [edi+0ECh]
    push    offset aDefaultfocus            ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    push    offset aVersion_0               ; char *
    mov     ecx, esi
    call    sub_4C3410
    cmp     eax, 1
    jnz     short loc_4AD96C
    mov     ecx, [esi+4]
    push    0                               ; int
    push    offset aMajor                   ; char *
    call    sub_4C46C0
    mov     [edi+0C9h], al
    mov     ecx, [esi+4]
    push    0                               ; int
    push    offset aMinor                   ; char *
    call    sub_4C46C0
    mov     [edi+0CAh], al
    mov     ecx, [esi+4]
    push    0                               ; int
    push    offset aRevision                ; char *
    call    sub_4C46C0
    mov     [edi+0CBh], al

    loc_4AD96C:                             ; CODE XREF: sub_4AD890+9Bj
    pop     edi
    pop     esi
    retn    8
    sub_4AD890 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 0CCh
    mov     ecx, [esp+0D0h]
    push    ebx
    push    esi
    push    edi
    movsx   edx, word ptr [ecx+0B6h]
    lea     eax, [esp+74h]
    push    0Ah
    push    eax
    push    edx
    call    __itoa
    mov     esi, [esp+0F0h]
    mov     ebx, [esp+0ECh]
    add     esp, 0Ch
    mov     edi, eax
    test    esi, esi
    mov     byte ptr [esp+0Fh], 9
    jle     short loc_4AD9D0

    loc_4AD9C0:                             ; CODE XREF: .text:004AD9CEj
    lea     eax, [esp+0Fh]
    push    1
    push    eax
    push    ebx
    call    sub_4BBBE0
    dec     esi
    jnz     short loc_4AD9C0

    loc_4AD9D0:                             ; CODE XREF: .text:004AD9BEj
    push    edi
    push    offset aStatus                  ; "status"
    lea     ecx, [esp+18h]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+20h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+10h]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0CCh
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+8]
    push    0
    push    offset aStatus                  ; "status"
    mov     ecx, [eax+4]
    call    sub_4C46C0
    mov     ecx, [esp+4]
    mov     [ecx+0B6h], ax
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 0D0h
    push    ebx
    mov     ebx, [esp+0D8h]
    push    ebp
    push    esi
    movsx   ecx, word ptr [ebx+138h]
    push    edi
    lea     eax, [esp+7Ch]
    push    0Ah
    push    eax
    push    ecx
    call    __itoa
    mov     ebp, [esp+0F8h]
    mov     esi, [esp+0F4h]
    add     esp, 0Ch
    mov     [esp+14h], eax
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4ADA95
    mov     edi, ebp

    loc_4ADA85:                             ; CODE XREF: .text:004ADA93j
    lea     edx, [esp+13h]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ADA85

    loc_4ADA95:                             ; CODE XREF: .text:004ADA81j
    mov     eax, [esp+14h]
    lea     ecx, [esp+18h]
    push    eax
    push    offset aStatus                  ; "status"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+18h]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4ADAE6
    mov     edi, ebp

    loc_4ADAD6:                             ; CODE XREF: .text:004ADAE4j
    lea     eax, [esp+13h]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ADAD6

    loc_4ADAE6:                             ; CODE XREF: .text:004ADAD2j
    lea     ecx, [ebx+0B6h]
    lea     edx, [esp+18h]
    push    ecx
    push    offset aText                    ; "text"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+18h]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    movsx   edx, byte ptr [ebx+13Ah]
    lea     ecx, [esp+7Ch]
    push    0Ah
    push    ecx
    push    edx
    call    __itoa
    add     esp, 0Ch
    mov     [esp+14h], eax
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4ADB54
    mov     edi, ebp

    loc_4ADB44:                             ; CODE XREF: .text:004ADB52j
    lea     eax, [esp+13h]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ADB44

    loc_4ADB54:                             ; CODE XREF: .text:004ADB40j
    mov     ecx, [esp+14h]
    lea     edx, [esp+18h]
    push    ecx
    push    offset aQuickkey                ; "quickkey"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+18h]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    mov     dl, [ebx+13Ch]
    lea     ecx, [esp+7Ch]
    push    0Ah
    and     edx, 1
    push    ecx
    push    edx
    call    __itoa
    add     esp, 0Ch
    mov     [esp+14h], eax
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4ADBC2
    mov     edi, ebp

    loc_4ADBB2:                             ; CODE XREF: .text:004ADBC0j
    lea     eax, [esp+13h]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ADBB2

    loc_4ADBC2:                             ; CODE XREF: .text:004ADBAEj
    mov     ecx, [esp+14h]
    lea     edx, [esp+18h]
    push    ecx
    push    offset aGrayedout               ; "grayedout"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+18h]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    xor     edx, edx
    lea     ecx, [esp+7Ch]
    mov     dl, [ebx+136h]
    push    0Ah
    push    ecx
    push    edx
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4ADC2B

    loc_4ADC1B:                             ; CODE XREF: .text:004ADC29j
    lea     eax, [esp+13h]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     ebp
    jnz     short loc_4ADC1B

    loc_4ADC2B:                             ; CODE XREF: .text:004ADC19j
    push    edi
    push    offset aStages                  ; "stages"
    lea     ecx, [esp+20h]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+18h]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D0h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4ADC70 proc near                    ; CODE XREF: sub_4AEAC0+C5p

    var_14= byte ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    push    ebx
    push    ebp
    mov     ebp, [esp+1Ch+arg_4]
    push    esi
    push    edi
    push    0                               ; int
    mov     ecx, [ebp+4]
    push    offset aStatus                  ; char *
    call    sub_4C46C0
    mov     ecx, 20h
    push    offset Data                     ; int
    mov     ebx, [esp+28h+arg_0]
    push    80h                             ; size_t
    push    offset aText                    ; char *
    lea     esi, [ebx+0B6h]
    mov     [ebx+138h], ax
    xor     eax, eax
    mov     edi, esi
    rep stosd
    mov     ecx, [ebp+4]
    push    esi                             ; char *
    call    sub_4C48C0
    push    80h                             ; size_t
    push    esi                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    esi                             ; char *
    call    _strncpy
    mov     ecx, [ebp+4]
    add     esp, 0Ch
    lea     eax, [esp+24h+var_14]
    push    offset Data                     ; int
    push    13h                             ; size_t
    push    offset aQuickkey                ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    mov     ecx, dword ptr [esp+24h+var_14]
    push    ecx                             ; ch
    call    ds:IsCharAlphaA
    test    eax, eax
    jz      short loc_4ADD07
    mov     dl, [esp+24h+var_14]
    mov     [ebx+13Ah], dl
    jmp     short loc_4ADD1A
    ; ---------------------------------------------------------------------------

    loc_4ADD07:                             ; CODE XREF: sub_4ADC70+89j
    lea     eax, [esp+24h+var_14]
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    mov     [ebx+13Ah], al

    loc_4ADD1A:                             ; CODE XREF: sub_4ADC70+95j
    mov     ecx, [ebp+4]
    push    0                               ; int
    push    offset aGrayedout               ; char *
    call    sub_4C46C0
    mov     cx, [ebx+13Ch]
    push    0                               ; int
    xor     al, cl
    push    offset aStages                  ; char *
    and     eax, 1
    xor     eax, ecx
    mov     [ebx+13Ch], ax
    mov     ecx, [ebp+4]
    call    sub_4C46C0
    pop     edi
    pop     esi
    mov     [ebx+136h], al
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    sub_4ADC70 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 0CCh
    mov     ecx, [esp+0D0h]
    push    ebx
    push    esi
    push    edi
    movsx   edx, word ptr [ecx+0DAh]
    lea     eax, [esp+74h]
    push    0Ah
    push    eax
    push    edx
    call    __itoa
    mov     esi, [esp+0F0h]
    mov     ebx, [esp+0ECh]
    add     esp, 0Ch
    mov     edi, eax
    test    esi, esi
    mov     byte ptr [esp+0Fh], 9
    jle     short loc_4ADDB0

    loc_4ADDA0:                             ; CODE XREF: .text:004ADDAEj
    lea     eax, [esp+0Fh]
    push    1
    push    eax
    push    ebx
    call    sub_4BBBE0
    dec     esi
    jnz     short loc_4ADDA0

    loc_4ADDB0:                             ; CODE XREF: .text:004ADD9Ej
    push    edi
    push    offset aItemheight              ; "itemheight"
    lea     ecx, [esp+18h]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+20h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+10h]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0CCh
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, [esp+8]
    xor     eax, eax
    mov     [esi+0CEh], eax
    mov     [esi+0D6h], eax
    push    eax
    mov     eax, [esp+10h]
    push    offset aItemheight              ; "itemheight"
    mov     ecx, [eax+4]
    call    sub_4C46C0
    mov     [esi+0DAh], ax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    sub     esp, 0CCh
    mov     ecx, [esp+0D0h]
    push    ebx
    push    ebp
    push    esi
    movsx   edx, word ptr [ecx+138h]
    push    edi
    lea     eax, [esp+78h]
    push    0Ah
    push    eax
    push    edx
    call    __itoa
    mov     ebp, [esp+0F4h]
    mov     esi, [esp+0F0h]
    add     esp, 0Ch
    mov     ebx, eax
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4ADE73
    mov     edi, ebp

    loc_4ADE63:                             ; CODE XREF: .text:004ADE71j
    lea     eax, [esp+13h]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ADE63

    loc_4ADE73:                             ; CODE XREF: .text:004ADE5Fj
    push    ebx
    push    offset aMaxchars                ; "maxchars"
    lea     ecx, [esp+1Ch]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+24h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+14h]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4ADEC0
    mov     edi, ebp

    loc_4ADEB0:                             ; CODE XREF: .text:004ADEBEj
    lea     eax, [esp+13h]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ADEB0

    loc_4ADEC0:                             ; CODE XREF: .text:004ADEACj
    mov     ecx, [esp+0E0h]
    lea     edx, [esp+14h]
    add     ecx, 0B6h
    push    ecx
    push    offset aText                    ; "text"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+24h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+14h]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    push    esi
    mov     esi, [esp+10h]
    push    edi
    push    0
    push    offset aMaxchars                ; "maxchars"
    mov     ecx, [esi+4]
    call    sub_4C46C0
    cmp     ax, 80h
    mov     ecx, [esp+10h]
    mov     [ecx+138h], ax
    jle     short loc_4ADF40
    mov     word ptr [ecx+138h], 80h

    loc_4ADF40:                             ; CODE XREF: .text:004ADF35j
    push    offset Data
    lea     ebx, [ecx+0B6h]
    mov     ecx, [esi+4]
    push    80h
    push    offset aText                    ; "text"
    push    ebx
    call    sub_4C48C0
    push    ebx
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 0D0h
    push    ebx
    mov     ebx, [esp+0D8h]
    push    ebp
    push    esi
    movsx   ecx, word ptr [ebx+136h]
    push    edi
    lea     eax, [esp+7Ch]
    push    0Ah
    push    eax
    push    ecx
    call    __itoa
    mov     ebp, [esp+0F8h]
    mov     esi, [esp+0F4h]
    add     esp, 0Ch
    mov     [esp+14h], eax
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4ADFE5
    mov     edi, ebp

    loc_4ADFD5:                             ; CODE XREF: .text:004ADFE3j
    lea     edx, [esp+13h]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4ADFD5

    loc_4ADFE5:                             ; CODE XREF: .text:004ADFD1j
    mov     eax, [esp+14h]
    lea     ecx, [esp+18h]
    push    eax
    push    offset aRange                   ; "range"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+18h]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    mov     ecx, [ebx+13Ch]
    lea     eax, [esp+7Ch]
    push    0Ah
    push    eax
    push    ecx
    call    __itoa
    add     esp, 0Ch
    mov     [esp+14h], eax
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4AE050
    mov     edi, ebp

    loc_4AE040:                             ; CODE XREF: .text:004AE04Ej
    lea     edx, [esp+13h]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AE040

    loc_4AE050:                             ; CODE XREF: .text:004AE03Cj
    mov     eax, [esp+14h]
    lea     ecx, [esp+18h]
    push    eax
    push    offset aThick                   ; "thick"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+18h]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    movsx   ecx, word ptr [ebx+140h]
    lea     eax, [esp+7Ch]
    push    0Ah
    push    eax
    push    ecx
    call    __itoa
    add     esp, 0Ch
    mov     [esp+14h], eax
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4AE0BC
    mov     edi, ebp

    loc_4AE0AC:                             ; CODE XREF: .text:004AE0BAj
    lea     edx, [esp+13h]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AE0AC

    loc_4AE0BC:                             ; CODE XREF: .text:004AE0A8j
    mov     eax, [esp+14h]
    lea     ecx, [esp+18h]
    push    eax
    push    offset aKnobpos                 ; "knobpos"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+18h]
    push    ecx
    push    edx
    push    esi
    call    sub_4BBBE0
    movsx   ecx, word ptr [ebx+142h]
    lea     eax, [esp+7Ch]
    push    0Ah
    push    eax
    push    ecx
    call    __itoa
    add     esp, 0Ch
    mov     edi, eax
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4AE124

    loc_4AE114:                             ; CODE XREF: .text:004AE122j
    lea     edx, [esp+13h]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     ebp
    jnz     short loc_4AE114

    loc_4AE124:                             ; CODE XREF: .text:004AE112j
    push    edi
    push    offset aKnobsize                ; "knobsize"
    lea     eax, [esp+20h]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+28h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    lea     ecx, [esp+1Ch]
    push    ecx
    push    esi
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D0h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+14h]
    push    0
    push    offset aRange                   ; "range"
    mov     ecx, [edi+4]
    call    sub_4C46C0
    push    0
    push    offset aThick                   ; "thick"
    mov     esi, [esp+18h]
    mov     [esi+136h], ax
    mov     ecx, [edi+4]
    call    sub_4C46C0
    movsx   eax, ax
    mov     [esi+13Ch], eax
    mov     ecx, [edi+4]
    push    0
    push    offset aKnobpos                 ; "knobpos"
    call    sub_4C46C0
    mov     [esi+140h], ax
    mov     ecx, [edi+4]
    push    0
    push    offset aKnobsize                ; "knobsize"
    call    sub_4C46C0
    push    offset Data
    lea     ebx, [esi+0B6h]
    push    80h
    mov     [esi+142h], ax
    mov     dword ptr [esi+144h], 0
    mov     ecx, [edi+4]
    push    offset aText                    ; "text"
    push    ebx
    call    sub_4C48C0
    push    ebx
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 68h
    push    ebx
    push    ebp
    mov     ebp, [esp+7Ch]
    push    esi
    mov     esi, [esp+7Ch]
    push    edi
    test    ebp, ebp
    mov     byte ptr [esp+13h], 9
    jle     short loc_4AE25A
    mov     edi, ebp

    loc_4AE24A:                             ; CODE XREF: .text:004AE258j
    lea     eax, [esp+13h]
    push    1
    push    eax
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AE24A

    loc_4AE25A:                             ; CODE XREF: .text:004AE246j
    mov     ebx, [esp+7Ch]
    lea     edx, [esp+14h]
    lea     ecx, [ebx+0B6h]
    push    ecx
    push    offset aText                    ; "text"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+24h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+14h]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    test    ebp, ebp
    mov     byte ptr [esp+84h], 9
    jle     short loc_4AE2B7
    mov     edi, ebp

    loc_4AE2A4:                             ; CODE XREF: .text:004AE2B5j
    lea     ecx, [esp+84h]
    push    1
    push    ecx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AE2A4

    loc_4AE2B7:                             ; CODE XREF: .text:004AE2A0j
    add     ebx, 136h
    lea     edx, [esp+14h]
    push    ebx
    push    offset aLink                    ; "link"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+24h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+14h]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    push    ebx
    push    esi
    push    edi
    lea     ebx, [eax+136h]
    lea     esi, [eax+0B6h]
    mov     byte ptr [eax+147h], 0
    mov     ecx, 20h
    xor     eax, eax
    mov     edi, esi
    mov     byte ptr [ebx], 0
    push    offset Data
    rep stosd
    mov     edi, [esp+18h]
    push    80h
    push    offset aText                    ; "text"
    push    esi
    mov     ecx, [edi+4]
    call    sub_4C48C0
    push    7Fh
    push    esi
    call    sub_4C5740
    push    eax
    push    esi
    call    _strncpy
    mov     ecx, [edi+4]
    add     esp, 0Ch
    push    offset Data
    push    10h
    push    offset aLink                    ; "link"
    push    ebx
    call    sub_4C48C0
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 0CCh
    mov     ecx, [esp+0D0h]
    push    ebx
    push    esi
    push    edi
    mov     edx, [ecx+0C8h]
    lea     eax, [esp+74h]
    push    0Ah
    and     edx, 1
    push    eax
    push    edx
    call    __itoa
    mov     esi, [esp+0F0h]
    mov     ebx, [esp+0ECh]
    add     esp, 0Ch
    mov     edi, eax
    test    esi, esi
    mov     byte ptr [esp+0Fh], 9
    jle     short loc_4AE3D2

    loc_4AE3C2:                             ; CODE XREF: .text:004AE3D0j
    lea     eax, [esp+0Fh]
    push    1
    push    eax
    push    ebx
    call    sub_4BBBE0
    dec     esi
    jnz     short loc_4AE3C2

    loc_4AE3D2:                             ; CODE XREF: .text:004AE3C0j
    push    edi
    push    offset aHotornot                ; "hotornot"
    lea     ecx, [esp+18h]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+20h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+10h]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0CCh
    retn    0Ch
    ; ---------------------------------------------------------------------------
    mov     eax, [esp+8]
    push    0
    push    offset aHotornot                ; "hotornot"
    mov     ecx, [eax+4]
    call    sub_4C46C0
    mov     edx, [esp+4]
    mov     ecx, [edx+0C8h]
    xor     eax, ecx
    and     eax, 1
    xor     eax, ecx
    mov     [edx+0C8h], eax
    retn    8
    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 68h
    push    ebx
    mov     ebx, [esp+74h]
    push    esi
    mov     esi, [esp+7Ch]
    test    esi, esi
    push    edi
    mov     byte ptr [esp+0Fh], 9
    jle     short loc_4AE467

    loc_4AE457:                             ; CODE XREF: .text:004AE465j
    lea     eax, [esp+0Fh]
    push    1
    push    eax
    push    ebx
    call    sub_4BBBE0
    dec     esi
    jnz     short loc_4AE457

    loc_4AE467:                             ; CODE XREF: .text:004AE455j
    mov     ecx, [esp+78h]
    lea     edx, [esp+10h]
    add     ecx, 0B6h
    push    ecx
    push    offset aFilename                ; "filename"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+20h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+10h]
    push    ecx
    push    eax
    push    ebx
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     ecx, [esp+8]
    push    offset Data
    push    20h
    mov     ecx, [ecx+4]
    add     eax, 0B6h
    push    offset aFilename                ; "filename"
    push    eax
    call    sub_4C48C0
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 68h
    push    ebx
    mov     ebx, [esp+74h]
    push    esi
    mov     esi, [esp+7Ch]
    test    esi, esi
    push    edi
    mov     byte ptr [esp+0Fh], 9
    jle     short loc_4AE507

    loc_4AE4F7:                             ; CODE XREF: .text:004AE505j
    lea     eax, [esp+0Fh]
    push    1
    push    eax
    push    ebx
    call    sub_4BBBE0
    dec     esi
    jnz     short loc_4AE4F7

    loc_4AE507:                             ; CODE XREF: .text:004AE4F5j
    mov     ecx, [esp+78h]
    lea     edx, [esp+10h]
    add     ecx, 0B6h
    push    ecx
    push    offset aFilename                ; "filename"
    push    offset aSS_6                    ; "%s=%s;\n"
    push    edx
    call    _sprintf
    lea     edi, [esp+20h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+10h]
    push    ecx
    push    eax
    push    ebx
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     ecx, [esp+8]
    push    offset Data
    push    20h
    mov     ecx, [ecx+4]
    add     eax, 0B6h
    push    offset aFilename                ; "filename"
    push    eax
    call    sub_4C48C0
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 0CCh
    mov     ecx, [esp+0D0h]
    push    ebx
    push    esi
    push    edi
    mov     edx, [ecx+0B6h]
    lea     eax, [esp+74h]
    push    0Ah
    push    eax
    push    edx
    call    __itoa
    mov     esi, [esp+0F0h]
    mov     ebx, [esp+0ECh]
    add     esp, 0Ch
    mov     edi, eax
    test    esi, esi
    mov     byte ptr [esp+0Fh], 9
    jle     short loc_4AE5CF

    loc_4AE5BF:                             ; CODE XREF: .text:004AE5CDj
    lea     eax, [esp+0Fh]
    push    1
    push    eax
    push    ebx
    call    sub_4BBBE0
    dec     esi
    jnz     short loc_4AE5BF

    loc_4AE5CF:                             ; CODE XREF: .text:004AE5BDj
    push    edi
    push    offset aNuttin                  ; "nuttin"
    lea     ecx, [esp+18h]
    push    offset aSS_6                    ; "%s=%s;\n"
    push    ecx
    call    _sprintf
    lea     edi, [esp+20h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+10h]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BBBE0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0CCh
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+8]
    push    0
    push    offset aNuttin                  ; "nuttin"
    mov     ecx, [eax+4]
    call    sub_4C46C0
    mov     ecx, [esp+4]
    mov     [ecx+0B6h], eax
    retn    8
    ; ---------------------------------------------------------------------------
    sub     esp, 58Ch
    lea     eax, [esp+1FCh]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+5A0h]
    push    edi
    push    offset off_502828
    push    eax
    push    esi
    call    sub_4BAFF0
    lea     ecx, [esp+20Ch]
    push    ecx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_4AE69A
    lea     edx, [esp+30Ch]
    push    offset aBgu                     ; "BGU"
    push    edx
    push    esi
    call    sub_4BAFF0
    lea     eax, [esp+30Ch]
    push    eax
    call    sub_4BBC30
    lea     ecx, [esp+30Ch]
    lea     edx, [esp+20Ch]
    push    ecx
    push    edx
    call    sub_4BBC10

    loc_4AE69A:                             ; CODE XREF: .text:004AE663j
    lea     eax, [esp+20Ch]
    push    eax
    call    sub_4BB6A0
    mov     esi, eax
    mov     ebp, [esp+5A0h]
    mov     dword ptr [esp+14h], 0
    movsx   ecx, word ptr [ebp+0B6h]
    inc     ecx
    test    ecx, ecx
    jle     loc_4AEA79
    add     ebp, 138h

    loc_4AE6CE:                             ; CODE XREF: .text:004AEA73j
    mov     edx, [esp+14h]
    lea     eax, [esp+1A8h]
    push    edx
    push    offset aGadgetD                 ; "GADGET%d"
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+1A8h]
    lea     edx, [esp+0E0h]
    push    ecx
    push    offset aS_2                     ; "[%s]"
    push    edx
    call    _sprintf
    lea     edi, [esp+0ECh]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+0E0h]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    push    1
    push    offset byte_50319C
    push    esi
    call    sub_4BBBE0
    push    1
    push    esi
    call    sub_4ACCD0
    push    2
    push    offset dword_509A04
    push    esi
    call    sub_4BBBE0
    push    offset aCommon                  ; "COMMON"
    lea     ecx, [esp+148h]
    push    offset aS_2                     ; "[%s]"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    mov     byte ptr [esp+13h], 9
    mov     edi, 1

    loc_4AE76B:                             ; CODE XREF: .text:004AE779j
    lea     edx, [esp+13h]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AE76B
    lea     edi, [esp+144h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+144h]
    push    ecx
    push    eax
    push    esi
    call    sub_4BBBE0
    push    1
    push    offset byte_50319C
    push    esi
    call    sub_4BBBE0
    push    2
    push    esi
    call    sub_4ACCD0
    push    2
    push    offset dword_509A04
    push    esi
    call    sub_4BBBE0
    lea     edi, [ebp-138h]
    push    2
    push    esi
    push    edi
    call    sub_4ACE50
    mov     ebx, 2
    mov     byte ptr [esp+13h], 9

    loc_4AE7D6:                             ; CODE XREF: .text:004AE7E4j
    lea     ecx, [esp+13h]
    push    1
    push    ecx
    push    esi
    call    sub_4BBBE0
    dec     ebx
    jnz     short loc_4AE7D6
    push    2
    push    offset dword_509A08
    push    esi
    call    sub_4BBBE0
    xor     eax, eax
    mov     al, [edi]
    cmp     eax, 0Ah                        ; switch 11 cases
    ja      loc_4AEA2C                      ; default
    jmp     ds:off_4AEA8C[eax*4]            ; switch jump

    loc_4AE807:                             ; DATA XREF: .text:004AEA8Co
    push    1                               ; case 0x0
    push    esi
    push    edi
    call    sub_4AD4F0
    jmp     loc_4AEA2C                      ; default
    ; ---------------------------------------------------------------------------

    loc_4AE815:                             ; CODE XREF: .text:004AE800j
                                            ; DATA XREF: .text:004AEA8Co
    movsx   eax, word ptr [ebp+0]           ; case 0x1
    push    1
    lea     edx, [esp+1Ch]
    push    0Ah
    push    edx
    push    eax
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aStatus                  ; "status"
    push    esi
    call    sub_4ACDE0
    lea     ecx, [ebp-82h]
    push    1
    push    ecx
    push    offset aText                    ; "text"
    push    esi
    call    sub_4ACDE0
    movsx   eax, byte ptr [ebp+2]
    push    1
    lea     edx, [esp+1Ch]
    push    0Ah
    push    edx
    push    eax
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aQuickkey                ; "quickkey"
    push    esi
    call    sub_4ACDE0
    mov     dl, [ebp+4]
    push    1
    lea     ecx, [esp+1Ch]
    push    0Ah
    and     edx, 1
    push    ecx
    push    edx
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aGrayedout               ; "grayedout"
    push    esi
    call    sub_4ACDE0
    xor     ecx, ecx
    push    1
    mov     cl, [ebp-2]
    lea     eax, [esp+1Ch]
    push    0Ah
    push    eax
    push    ecx
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aStages                  ; "stages"
    jmp     loc_4AEA26
    ; ---------------------------------------------------------------------------

    loc_4AE8B3:                             ; CODE XREF: .text:004AE800j
                                            ; DATA XREF: .text:004AEA8Co
    movsx   eax, word ptr [ebp-5Eh]         ; case 0x2
    push    1
    lea     edx, [esp+53Ch]
    push    0Ah
    push    edx
    push    eax
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aItemheight              ; "itemheight"
    jmp     loc_4AEA26
    ; ---------------------------------------------------------------------------

    loc_4AE8D7:                             ; CODE XREF: .text:004AE800j
                                            ; DATA XREF: .text:004AEA8Co
    movsx   edx, word ptr [ebp+0]           ; case 0x3
    push    1
    lea     ecx, [esp+474h]
    push    0Ah
    push    ecx
    push    edx
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aMaxchars                ; "maxchars"
    push    esi
    call    sub_4ACDE0
    lea     eax, [ebp-82h]
    push    1
    push    eax
    push    offset aText                    ; "text"
    jmp     loc_4AEA26
    ; ---------------------------------------------------------------------------

    loc_4AE90F:                             ; CODE XREF: .text:004AE800j
                                            ; DATA XREF: .text:004AEA8Co
    movsx   edx, word ptr [ebp-2]           ; case 0x4
    push    1
    lea     ecx, [esp+80h]
    push    0Ah
    push    ecx
    push    edx
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aRange                   ; "range"
    push    esi
    call    sub_4ACDE0
    mov     ecx, [ebp+4]
    push    1
    lea     eax, [esp+80h]
    push    0Ah
    push    eax
    push    ecx
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aThick                   ; "thick"
    push    esi
    call    sub_4ACDE0
    movsx   eax, word ptr [ebp+8]
    push    1
    lea     edx, [esp+80h]
    push    0Ah
    push    edx
    push    eax
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aKnobpos                 ; "knobpos"
    push    esi
    call    sub_4ACDE0
    movsx   edx, word ptr [ebp+0Ah]
    push    1
    lea     ecx, [esp+80h]
    push    0Ah
    push    ecx
    push    edx
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aKnobsize                ; "knobsize"
    jmp     loc_4AEA26
    ; ---------------------------------------------------------------------------

    loc_4AE9A1:                             ; CODE XREF: .text:004AE800j
                                            ; DATA XREF: .text:004AEA8Co
    lea     eax, [ebp-82h]                  ; case 0x5
    push    1
    push    eax
    push    offset aText                    ; "text"
    push    esi
    call    sub_4ACDE0
    lea     ecx, [ebp-2]
    push    1
    push    ecx
    push    offset aLink                    ; "link"
    jmp     short loc_4AEA26
    ; ---------------------------------------------------------------------------

    loc_4AE9C2:                             ; CODE XREF: .text:004AE800j
                                            ; DATA XREF: .text:004AEA8Co
    mov     eax, [ebp-70h]                  ; case 0x6
    push    1
    lea     edx, [esp+410h]
    push    0Ah
    and     eax, 1
    push    edx
    push    eax
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aHotornot                ; "hotornot"
    jmp     short loc_4AEA26
    ; ---------------------------------------------------------------------------

    loc_4AE9E5:                             ; CODE XREF: .text:004AE800j
                                            ; DATA XREF: .text:004AEA8Co
    lea     ecx, [ebp-82h]                  ; case 0x7
    push    1
    push    ecx
    push    offset aFilename                ; "filename"
    jmp     short loc_4AEA26
    ; ---------------------------------------------------------------------------

    loc_4AE9F5:                             ; CODE XREF: .text:004AE800j
                                            ; DATA XREF: .text:004AEA8Co
    lea     edx, [ebp-82h]                  ; case 0x8
    push    1
    push    edx
    push    offset aFilename                ; "filename"
    jmp     short loc_4AEA26
    ; ---------------------------------------------------------------------------

    loc_4AEA05:                             ; CODE XREF: .text:004AE800j
                                            ; DATA XREF: .text:004AEA8Co
    mov     ecx, [ebp-82h]                  ; case 0xa
    push    1
    lea     eax, [esp+4D8h]
    push    0Ah
    push    eax
    push    ecx
    call    __itoa
    add     esp, 0Ch
    push    eax
    push    offset aNuttin                  ; "nuttin"

    loc_4AEA26:                             ; CODE XREF: .text:004AE8AEj
                                            ; .text:004AE8D2j ...
    push    esi
    call    sub_4ACDE0

    loc_4AEA2C:                             ; CODE XREF: .text:004AE7FAj
                                            ; .text:004AE800j ...
    mov     byte ptr [esp+13h], 9           ; default
    mov     edi, 1

    loc_4AEA36:                             ; CODE XREF: .text:004AEA44j
    lea     edx, [esp+13h]
    push    1
    push    edx
    push    esi
    call    sub_4BBBE0
    dec     edi
    jnz     short loc_4AEA36
    push    2
    push    offset dword_509A08
    push    esi
    call    sub_4BBBE0
    add     ebp, 15Bh
    mov     ecx, [esp+5A0h]
    mov     eax, [esp+14h]
    inc     eax
    movsx   edx, word ptr [ecx+0B6h]
    inc     edx
    mov     [esp+14h], eax
    cmp     eax, edx
    jl      loc_4AE6CE

    loc_4AEA79:                             ; CODE XREF: .text:004AE6C2j
    push    esi
    call    sub_4BB5D0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 58Ch
    retn    8
    ; ---------------------------------------------------------------------------
    off_4AEA8C dd offset loc_4AE807         ; DATA XREF: .text:004AE800r
    dd offset loc_4AE815                    ; jump table for switch statement
    dd offset loc_4AE8B3
    dd offset loc_4AE8D7
    dd offset loc_4AE90F
    dd offset loc_4AE9A1
    dd offset loc_4AE9C2
    dd offset loc_4AE9E5
    dd offset loc_4AE9F5
    dd offset loc_4AEA2C
    dd offset loc_4AEA05
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AEAC0 proc near                    ; CODE XREF: sub_4AA8F0+1AEp

    var_114= dword ptr -114h
    var_110= dword ptr -110h
    var_108= dword ptr -108h
    var_104= dword ptr -104h
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 114h
    lea     ecx, [esp+114h+var_114]
    push    ebx
    push    esi
    call    sub_4C2EA0
    mov     ecx, [esp+11Ch+arg_4]
    lea     eax, [esp+11Ch+var_100]
    push    offset off_502828
    push    eax
    push    ecx
    xor     ebx, ebx
    xor     esi, esi
    call    sub_4BAFF0
    lea     edx, [esp+11Ch+var_100]
    lea     ecx, [esp+11Ch+var_114]
    push    edx
    call    sub_4C2F60
    cmp     eax, 1
    jnz     loc_4AED5A
    mov     [esp+11Ch+var_104], eax
    mov     eax, [esp+11Ch+arg_0]
    push    edi
    push    ebp
    mov     [esp+124h+var_108], esi
    lea     ebp, [eax+0D6h]

    loc_4AEB1A:                             ; CODE XREF: sub_4AEAC0+277j
    lea     ecx, [esp+124h+var_114]
    call    sub_4C3E10
    push    esi
    lea     ecx, [esp+128h+var_114]
    call    sub_4C3490
    test    eax, eax
    jz      loc_4AED3C
    lea     ecx, [esp+124h+var_114]
    call    sub_4C3E20
    lea     ecx, [esp+124h+var_114]
    lea     esi, [ebp-0D6h]
    push    ecx
    push    esi
    mov     edi, eax
    call    sub_4AD350
    push    edi
    lea     ecx, [esp+128h+var_114]
    call    sub_4C3E30
    xor     eax, eax
    mov     al, [esi]
    cmp     eax, 0Ah                        ; switch 11 cases
    ja      loc_4AED26                      ; default
    jmp     ds:off_4AED70[eax*4]            ; switch jump

    loc_4AEB6F:                             ; DATA XREF: .text:004AED70o
    lea     edx, [esp+124h+var_114]         ; case 0x0
    push    edx
    push    esi
    call    sub_4AD890
    jmp     loc_4AED26                      ; default
    ; ---------------------------------------------------------------------------

    loc_4AEB7F:                             ; CODE XREF: sub_4AEAC0+A8j
                                            ; DATA XREF: .text:004AED70o
    lea     eax, [esp+124h+var_114]         ; case 0x1
    push    eax
    push    esi
    call    sub_4ADC70
    jmp     loc_4AED26                      ; default
    ; ---------------------------------------------------------------------------

    loc_4AEB8F:                             ; CODE XREF: sub_4AEAC0+A8j
                                            ; DATA XREF: .text:004AED70o
    mov     ecx, [esp+124h+var_110]         ; case 0x2
    push    ebx                             ; int
    push    offset aItemheight              ; char *
    mov     [ebp-8], ebx
    mov     [ebp+0], ebx
    call    sub_4C46C0
    mov     [ebp+4], ax
    jmp     loc_4AED26                      ; default
    ; ---------------------------------------------------------------------------

    loc_4AEBAD:                             ; CODE XREF: sub_4AEAC0+A8j
                                            ; DATA XREF: .text:004AED70o
    mov     ecx, [esp+124h+var_110]         ; case 0x3
    push    ebx                             ; int
    push    offset aMaxchars                ; char *
    call    sub_4C46C0
    cmp     ax, 80h
    mov     [ebp+62h], ax
    jle     short loc_4AEC1F
    mov     word ptr [ebp+62h], 80h
    jmp     short loc_4AEC1F
    ; ---------------------------------------------------------------------------

    loc_4AEBCE:                             ; CODE XREF: sub_4AEAC0+A8j
                                            ; DATA XREF: .text:004AED70o
    mov     ecx, [esp+124h+var_110]         ; case 0x4
    push    ebx                             ; int
    push    offset aRange                   ; char *
    call    sub_4C46C0
    push    ebx                             ; int
    push    offset aThick                   ; char *
    mov     ecx, [esp+12Ch+var_110]
    mov     [ebp+60h], ax
    call    sub_4C46C0
    movsx   eax, ax
    mov     ecx, [esp+124h+var_110]
    push    ebx                             ; int
    push    offset aKnobpos                 ; char *
    mov     [ebp+66h], eax
    call    sub_4C46C0
    push    ebx                             ; int
    push    offset aKnobsize                ; char *
    mov     ecx, [esp+12Ch+var_110]
    mov     [ebp+6Ah], ax
    call    sub_4C46C0
    mov     [ebp+6Ch], ax
    mov     [ebp+6Eh], ebx

    loc_4AEC1F:                             ; CODE XREF: sub_4AEAC0+104j
                                            ; sub_4AEAC0+10Cj
    mov     ecx, [esp+124h+var_110]
    push    offset Data                     ; int
    lea     ebx, [ebp-20h]
    push    80h                             ; size_t
    push    offset aText                    ; char *
    push    ebx                             ; char *
    call    sub_4C48C0
    push    ebx                             ; int
    call    sub_4C5740
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    jmp     loc_4AED26                      ; default
    ; ---------------------------------------------------------------------------

    loc_4AEC65:                             ; CODE XREF: sub_4AEAC0+A8j
                                            ; DATA XREF: .text:004AED70o
    lea     ebx, [ebp+60h]                  ; case 0x5
    lea     esi, [ebp-20h]
    mov     ecx, 20h
    xor     eax, eax
    mov     edi, esi
    mov     byte ptr [ebx], 0
    mov     byte ptr [ebp+71h], 0
    push    offset Data                     ; int
    rep stosd
    mov     ecx, [esp+128h+var_110]
    push    80h                             ; size_t
    push    offset aText                    ; char *
    push    esi                             ; char *
    call    sub_4C48C0
    push    7Fh                             ; size_t
    push    esi                             ; int
    call    sub_4C5740
    push    eax                             ; char *
    push    esi                             ; char *
    call    _strncpy
    mov     ecx, [esp+130h+var_110]
    add     esp, 0Ch
    push    offset Data                     ; int
    push    10h                             ; size_t
    push    offset aLink                    ; char *
    push    ebx                             ; char *
    call    sub_4C48C0
    jmp     short loc_4AED26                ; default
    ; ---------------------------------------------------------------------------

    loc_4AECC0:                             ; CODE XREF: sub_4AEAC0+A8j
                                            ; DATA XREF: .text:004AED70o
    mov     ecx, [esp+124h+var_110]         ; case 0x6
    push    ebx                             ; int
    push    offset aHotornot                ; char *
    call    sub_4C46C0
    mov     ecx, [ebp-0Eh]
    xor     eax, ecx
    and     eax, 1
    xor     eax, ecx
    mov     [ebp-0Eh], eax
    jmp     short loc_4AED26                ; default
    ; ---------------------------------------------------------------------------

    loc_4AECDE:                             ; CODE XREF: sub_4AEAC0+A8j
                                            ; DATA XREF: .text:004AED70o
    mov     ecx, [esp+124h+var_110]         ; case 0x7
    push    offset Data                     ; int
    push    20h                             ; size_t
    lea     eax, [ebp-20h]
    push    offset aFilename                ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    jmp     short loc_4AED26                ; default
    ; ---------------------------------------------------------------------------

    loc_4AECF9:                             ; CODE XREF: sub_4AEAC0+A8j
                                            ; DATA XREF: .text:004AED70o
    push    offset Data                     ; case 0x8
    push    20h                             ; size_t
    lea     ecx, [ebp-20h]
    push    offset aFilename                ; char *
    push    ecx                             ; char *
    mov     ecx, [esp+134h+var_110]
    call    sub_4C48C0
    jmp     short loc_4AED26                ; default
    ; ---------------------------------------------------------------------------

    loc_4AED14:                             ; CODE XREF: sub_4AEAC0+A8j
                                            ; DATA XREF: .text:004AED70o
    mov     ecx, [esp+124h+var_110]         ; case 0xa
    push    ebx                             ; int
    push    offset aNuttin                  ; char *
    call    sub_4C46C0
    mov     [ebp-20h], eax

    loc_4AED26:                             ; CODE XREF: sub_4AEAC0+A2j
                                            ; sub_4AEAC0+A8j ...
    mov     esi, [esp+124h+var_108]         ; default
    add     ebp, 15Bh
    inc     esi
    xor     ebx, ebx
    mov     [esp+124h+var_108], esi
    jmp     loc_4AEB1A
    ; ---------------------------------------------------------------------------

    loc_4AED3C:                             ; CODE XREF: sub_4AEAC0+6Fj
    mov     edx, [esp+124h+arg_0]
    dec     esi
    lea     ecx, [esp+124h+var_114]
    mov     [edx+0B6h], si
    call    sub_4C3240
    mov     esi, [esp+124h+var_104]
    pop     ebp
    pop     edi

    loc_4AED5A:                             ; CODE XREF: sub_4AEAC0+3Dj
    lea     ecx, [esp+11Ch+var_114]
    call    sub_4C2EB0
    mov     eax, esi
    pop     esi
    pop     ebx
    add     esp, 114h
    retn    8
    sub_4AEAC0 endp

    ; ---------------------------------------------------------------------------
    off_4AED70 dd offset loc_4AEB6F         ; DATA XREF: sub_4AEAC0+A8r
    dd offset loc_4AEB7F                    ; jump table for switch statement
    dd offset loc_4AEB8F
    dd offset loc_4AEBAD
    dd offset loc_4AEBCE
    dd offset loc_4AEC65
    dd offset loc_4AECC0
    dd offset loc_4AECDE
    dd offset loc_4AECF9
    dd offset loc_4AED26
    dd offset loc_4AED14
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AEDA0 proc near                    ; CODE XREF: sub_4916A0+68p
                                            ; sub_4916A0+7Cp

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, [esp+4+arg_4]
    mov     eax, [esi+edi*4+8]
    test    eax, eax
    jz      short loc_4AEDCA
    push    eax                             ; int
    call    sub_4D85A0
    mov     dword ptr [esi+edi*4+8], 0
    add     esp, 4
    mov     dword ptr [esi+14h], 0

    loc_4AEDCA:                             ; CODE XREF: sub_4AEDA0+10j
    pop     edi
    pop     esi
    retn    8
    sub_4AEDA0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AEDD0 proc near                    ; CODE XREF: sub_491200+364p
                                            ; sub_491200+37Dp

    var_104= dword ptr -104h
    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 104h
    lea     ecx, [esp+104h+var_100]
    push    ebx
    push    ebp
    mov     ebp, [esp+10Ch+arg_0]
    push    esi
    push    edi
    push    100h                            ; size_t
    lea     eax, [ebp+0AB6h]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    _strncpy
    mov     edi, [esp+120h+arg_4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+114h+var_100]
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    lea     eax, [esp+114h+var_100]
    and     ecx, 3
    push    offset off_502E38
    rep movsb
    lea     ecx, [esp+118h+var_100]
    push    eax
    push    ecx
    call    sub_4BAFF0
    lea     edx, [esp+114h+var_100]
    push    edx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_4AEEB7
    lea     eax, [esp+114h+var_100]
    push    eax
    call    sub_4B8C60
    push    49h
    mov     ecx, [esp+118h+arg_8]
    mov     [ebp+ecx*4+8], eax
    mov     esi, [eax+0Ch]
    push    esi
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4AEE78
    xor     ebx, ebx
    mov     bx, [eax+2]
    jmp     short loc_4AEE7C
    ; ---------------------------------------------------------------------------

    loc_4AEE78:                             ; CODE XREF: sub_4AEDD0+9Ej
    mov     ebx, [esp+114h+var_104]

    loc_4AEE7C:                             ; CODE XREF: sub_4AEDD0+A6j
    xor     edi, edi
    cmp     [esi], di
    jbe     short loc_4AEE9C

    loc_4AEE83:                             ; CODE XREF: sub_4AEDD0+CAj
    push    edi
    push    esi
    call    sub_4B7F30
    test    eax, eax
    jz      short loc_4AEE92
    sub     [eax+6], bx

    loc_4AEE92:                             ; CODE XREF: sub_4AEDD0+BCj
    xor     edx, edx
    inc     edi
    mov     dx, [esi]
    cmp     edi, edx
    jl      short loc_4AEE83

    loc_4AEE9C:                             ; CODE XREF: sub_4AEDD0+B1j
    mov     eax, [esp+114h+arg_8]
    mov     ecx, [ebp+eax*4+8]
    mov     [ebp+14h], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4AEEB7:                             ; CODE XREF: sub_4AEDD0+7Aj
    mov     edx, [esp+114h+arg_8]
    pop     edi
    pop     esi
    mov     dword ptr [ebp+edx*4+8], 0
    pop     ebp
    pop     ebx
    add     esp, 104h
    retn    0Ch
    sub_4AEDD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AEEE0 proc near                    ; CODE XREF: sub_491200+34Ep

    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 100h
    lea     ecx, [esp+100h+var_100]
    push    ebx
    mov     ebx, [esp+104h+arg_0]
    push    ebp
    push    esi
    push    edi
    lea     eax, [ebx+0AB6h]
    push    100h                            ; size_t
    push    eax                             ; char *
    push    ecx                             ; char *
    call    _strncpy
    mov     edi, [esp+11Ch+arg_4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+110h+var_100]
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    lea     eax, [esp+110h+var_100]
    and     ecx, 3
    push    offset off_502E38
    rep movsb
    lea     ecx, [esp+114h+var_100]
    push    eax
    push    ecx
    call    sub_4BAFF0
    lea     edx, [esp+110h+var_100]
    push    edx
    call    sub_4BBC40
    test    eax, eax
    jz      short loc_4AEF69
    lea     eax, [esp+110h+var_100]
    push    eax
    call    sub_4B8C60
    mov     [ebx+4], eax

    loc_4AEF69:                             ; CODE XREF: sub_4AEEE0+7Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    8
    sub_4AEEE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AEF80 proc near                    ; CODE XREF: sub_4916A0+8Ep

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4AEF9C
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+4], 0

    loc_4AEF9C:                             ; CODE XREF: sub_4AEF80+Aj
    pop     esi
    retn    4
    sub_4AEF80 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AEFA0 proc near                    ; CODE XREF: sub_444EA0+139p
                                            ; sub_47AAF0+99p ...

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 24h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    17700h
    push    offset aSortedList1             ; "SORTED LIST1"
    call    sub_4D83B0
    add     esp, 8
    mov     [esp+34h+var_C], eax
    push    17700h
    push    offset aSortedList2             ; "SORTED LIST2"
    call    sub_4D83B0
    add     esp, 8
    mov     [esp+34h+var_10], eax
    push    2EE0h
    push    offset aPtrList1                ; "PTR LIST1"
    call    sub_4D83B0
    add     esp, 8
    mov     ebx, eax
    mov     [esp+34h+var_20], ebx
    push    2EE0h
    push    offset aPtrList2                ; "PTR LIST2"
    call    sub_4D83B0
    mov     edx, [esp+3Ch+arg_C]
    add     esp, 8
    or      ecx, 0FFFFFFFFh
    xor     esi, esi
    test    edx, edx
    mov     [esp+34h+var_24], eax
    mov     [esp+34h+var_18], ecx
    jle     short loc_4AF053
    mov     ebp, eax
    mov     edi, ebx
    sub     ebp, ebx

    loc_4AF018:                             ; CODE XREF: sub_4AEFA0+ADj
    mov     eax, [esp+34h+arg_0]
    push    esi
    push    eax
    call    sub_4B6AF0
    mov     [edi], eax
    mov     eax, [esp+34h+arg_4]
    test    eax, eax
    jz      short loc_4AF038
    push    esi
    push    eax
    call    sub_4B6AF0
    mov     [ebp+edi+0], eax

    loc_4AF038:                             ; CODE XREF: sub_4AEFA0+8Bj
    mov     ecx, [edi]
    cmp     byte ptr [ecx], 5Ch
    jnz     short loc_4AF043
    mov     [esp+34h+var_18], esi

    loc_4AF043:                             ; CODE XREF: sub_4AEFA0+9Dj
    mov     eax, [esp+34h+arg_C]
    inc     esi
    add     edi, 4
    cmp     esi, eax
    jl      short loc_4AF018
    mov     ecx, [esp+34h+var_18]

    loc_4AF053:                             ; CODE XREF: sub_4AEFA0+70j
    mov     ebp, [esp+34h+arg_8]
    cmp     ecx, 0FFFFFFFFh
    jz      loc_4AF11E

    loc_4AF060:                             ; CODE XREF: sub_4AEFA0+178j
    test    ecx, ecx
    mov     [esp+34h+var_1C], 0
    jle     loc_4AF112
    mov     eax, [esp+34h+var_24]
    mov     ecx, [esp+34h+var_20]
    mov     edx, [esp+34h+var_18]
    lea     esi, [ebx+4]
    sub     eax, ebx
    mov     ebx, ebp
    sub     ebx, ecx
    mov     ecx, [esp+34h+var_24]
    sub     ecx, ebp
    mov     edi, ebp
    mov     [esp+34h+arg_8], eax
    mov     [esp+34h+var_14], ecx
    mov     [esp+34h+var_8], edx

    loc_4AF099:                             ; CODE XREF: sub_4AEFA0+168j
    test    ebp, ebp
    jz      short loc_4AF0A6
    mov     eax, [edi]
    mov     edx, [ebx+esi]
    sub     eax, edx
    jmp     short loc_4AF0B9
    ; ---------------------------------------------------------------------------

    loc_4AF0A6:                             ; CODE XREF: sub_4AEFA0+FBj
    mov     eax, [esi]
    mov     ecx, [esi-4]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    mov     ecx, [esp+3Ch+var_14]
    add     esp, 8

    loc_4AF0B9:                             ; CODE XREF: sub_4AEFA0+104j
    test    eax, eax
    jle     short loc_4AF0F9
    mov     edx, [esi]
    mov     eax, [esi-4]
    mov     [esi-4], edx
    mov     [esi], eax
    mov     eax, [esp+34h+arg_4]
    test    eax, eax
    jz      short loc_4AF0E3
    mov     edx, [esp+34h+arg_8]
    mov     eax, [ecx+edi]
    mov     edx, [esi+edx]
    mov     [ecx+edi], edx
    mov     edx, [esp+34h+arg_8]
    mov     [esi+edx], eax

    loc_4AF0E3:                             ; CODE XREF: sub_4AEFA0+12Dj
    test    ebp, ebp
    jz      short loc_4AF0F1
    mov     edx, [ebx+esi]
    mov     eax, [edi]
    mov     [edi], edx
    mov     [ebx+esi], eax

    loc_4AF0F1:                             ; CODE XREF: sub_4AEFA0+145j
    mov     [esp+34h+var_1C], 1

    loc_4AF0F9:                             ; CODE XREF: sub_4AEFA0+11Bj
    mov     eax, [esp+34h+var_8]
    add     edi, 4
    add     esi, 4
    dec     eax
    mov     [esp+34h+var_8], eax
    jnz     short loc_4AF099
    mov     ebx, [esp+34h+var_20]
    mov     ecx, [esp+34h+var_18]

    loc_4AF112:                             ; CODE XREF: sub_4AEFA0+CAj
    mov     eax, [esp+34h+var_1C]
    test    eax, eax
    jnz     loc_4AF060

    loc_4AF11E:                             ; CODE XREF: sub_4AEFA0+BAj
    mov     eax, [esp+34h+arg_C]
    lea     edx, [ecx+1]
    dec     eax
    mov     [esp+34h+var_4], edx
    mov     [esp+34h+var_8], eax

    loc_4AF12E:                             ; CODE XREF: sub_4AEFA0+24Fj
    mov     eax, [esp+34h+var_8]
    mov     [esp+34h+var_1C], 0
    cmp     edx, eax
    jge     loc_4AF1E9
    mov     eax, [esp+34h+var_24]
    mov     ecx, [esp+34h+var_20]
    lea     esi, [ebx+edx*4+4]
    sub     eax, ebx
    mov     ebx, ebp
    mov     [esp+34h+arg_8], eax
    mov     eax, [esp+34h+var_8]
    sub     ebx, ecx
    mov     ecx, [esp+34h+var_24]
    lea     edi, [ebp+edx*4+0]
    sub     ecx, ebp
    sub     eax, edx
    mov     [esp+34h+var_14], ecx
    mov     [esp+34h+var_18], eax

    loc_4AF170:                             ; CODE XREF: sub_4AEFA0+23Fj
    test    ebp, ebp
    jz      short loc_4AF17D
    mov     eax, [esi+ebx]
    mov     edx, [edi]
    sub     eax, edx
    jmp     short loc_4AF190
    ; ---------------------------------------------------------------------------

    loc_4AF17D:                             ; CODE XREF: sub_4AEFA0+1D2j
    mov     ecx, [esi]
    mov     edx, [esi-4]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    mov     ecx, [esp+3Ch+var_14]
    add     esp, 8

    loc_4AF190:                             ; CODE XREF: sub_4AEFA0+1DBj
    test    eax, eax
    jle     short loc_4AF1D0
    mov     edx, [esi]
    mov     eax, [esi-4]
    mov     [esi-4], edx
    mov     [esi], eax
    mov     eax, [esp+34h+arg_4]
    test    eax, eax
    jz      short loc_4AF1BA
    mov     edx, [esp+34h+arg_8]
    mov     eax, [edi+ecx]
    mov     edx, [esi+edx]
    mov     [edi+ecx], edx
    mov     edx, [esp+34h+arg_8]
    mov     [esi+edx], eax

    loc_4AF1BA:                             ; CODE XREF: sub_4AEFA0+204j
    test    ebp, ebp
    jz      short loc_4AF1C8
    mov     edx, [esi+ebx]
    mov     eax, [edi]
    mov     [edi], edx
    mov     [esi+ebx], eax

    loc_4AF1C8:                             ; CODE XREF: sub_4AEFA0+21Cj
    mov     [esp+34h+var_1C], 1

    loc_4AF1D0:                             ; CODE XREF: sub_4AEFA0+1F2j
    mov     eax, [esp+34h+var_18]
    add     edi, 4
    add     esi, 4
    dec     eax
    mov     [esp+34h+var_18], eax
    jnz     short loc_4AF170
    mov     ebx, [esp+34h+var_20]
    mov     edx, [esp+34h+var_4]

    loc_4AF1E9:                             ; CODE XREF: sub_4AEFA0+19Cj
    mov     eax, [esp+34h+var_1C]
    test    eax, eax
    jnz     loc_4AF12E
    mov     eax, [esp+34h+var_10]
    mov     esi, [esp+34h+var_C]
    mov     [esp+34h+arg_8], eax
    mov     eax, [esp+34h+arg_C]
    test    eax, eax
    mov     ebx, esi
    jle     loc_4AF2A7
    mov     edx, [esp+34h+var_24]
    mov     ebp, [esp+34h+var_20]
    sub     ebp, edx
    mov     [esp+34h+arg_C], eax

    loc_4AF21D:                             ; CODE XREF: sub_4AEFA0+2FDj
    mov     edi, [ebp+edx+0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, [ebp+edx+0]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+34h+arg_4]
    not     ecx
    dec     ecx
    test    eax, eax
    lea     ebx, [ebx+ecx+1]
    jz      short loc_4AF291
    mov     edi, [edx]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+34h+arg_8]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, [edx]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+34h+arg_8]
    not     ecx
    dec     ecx
    lea     ecx, [eax+ecx+1]
    mov     [esp+34h+arg_8], ecx

    loc_4AF291:                             ; CODE XREF: sub_4AEFA0+2B6j
    mov     eax, [esp+34h+arg_C]
    add     edx, 4
    dec     eax
    mov     [esp+34h+arg_C], eax
    jnz     loc_4AF21D
    mov     esi, [esp+34h+var_C]

    loc_4AF2A7:                             ; CODE XREF: sub_4AEFA0+269j
    mov     edi, [esp+34h+arg_0]
    mov     ecx, ebx
    sub     ecx, esi
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, [esp+34h+arg_4]
    test    edi, edi
    jz      short loc_4AF2E1
    mov     ecx, [esp+34h+arg_8]
    mov     ebx, [esp+34h+var_10]
    sub     ecx, ebx
    mov     esi, ebx
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    jmp     short loc_4AF2E5
    ; ---------------------------------------------------------------------------

    loc_4AF2E1:                             ; CODE XREF: sub_4AEFA0+323j
    mov     ebx, [esp+34h+var_10]

    loc_4AF2E5:                             ; CODE XREF: sub_4AEFA0+33Fj
    mov     ecx, [esp+34h+var_24]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, [esp+38h+var_20]
    add     esp, 4
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    ebx                             ; int
    call    sub_4D85A0
    mov     eax, [esp+38h+var_C]
    add     esp, 4
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    10h
    sub_4AEFA0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AF320 proc near                    ; CODE XREF: sub_44B4E0+D7p
                                            ; .text:00476972p ...

    var_22C= dword ptr -22Ch
    var_228= dword ptr -228h
    var_224= dword ptr -224h
    var_220= dword ptr -220h
    var_21C= dword ptr -21Ch
    var_218= dword ptr -218h
    var_20C= dword ptr -20Ch
    var_204= dword ptr -204h
    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 22Ch
    push    ebx
    push    ebp
    mov     ebp, [esp+234h+arg_4]
    push    esi
    push    edi
    push    2EE0h
    push    offset aFiletimes               ; "FILETIMES"
    mov     [esp+244h+var_220], ebp
    mov     [esp+244h+var_22C], 0
    call    sub_4D83B0
    mov     edi, eax
    mov     eax, [esp+244h+arg_C]
    add     esp, 8
    cmp     eax, 1
    mov     [esp+23Ch+var_224], edi
    mov     [esp+23Ch+var_21C], edi
    jnz     loc_4AF438
    push    1
    lea     eax, [esp+240h+var_218]
    push    0FFFFFFFFh
    push    eax
    push    offset a__0                     ; "*."
    call    sub_4BC4B0
    mov     esi, eax
    cmp     esi, 0FFFFFFFFh
    mov     [esp+23Ch+var_228], esi
    jz      loc_4AF438
    mov     ebx, [esp+23Ch+arg_8]

    loc_4AF392:                             ; CODE XREF: sub_4AF320+106j
    cmp     byte ptr [esp+23Ch+var_204], 2Eh
    jz      short loc_4AF418
    cmp     [esp+23Ch+var_218], 10h
    jnz     short loc_4AF418
    push    1                               ; size_t
    push    offset byte_503374              ; char *
    push    ebp                             ; char *
    call    _strncpy
    add     esp, 0Ch
    lea     edi, [esp+23Ch+var_204]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    inc     ebp
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    lea     edi, [esp+23Ch+var_204]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    add     ebp, ecx
    mov     [ebp+0], al
    inc     ebp
    test    ebx, ebx
    jz      short loc_4AF40B
    mov     edi, offset aDir                ; "<DIR>"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    add     ebx, 6
    rep movsb

    loc_4AF40B:                             ; CODE XREF: sub_4AF320+C6j
    mov     eax, [esp+23Ch+var_22C]
    mov     esi, [esp+23Ch+var_228]
    inc     eax
    mov     [esp+23Ch+var_22C], eax

    loc_4AF418:                             ; CODE XREF: sub_4AF320+77j
                                            ; sub_4AF320+7Ej
    lea     ecx, [esp+23Ch+var_218]
    push    ecx
    push    esi
    call    sub_4BC640
    cmp     eax, 0FFFFFFFFh
    jnz     loc_4AF392
    push    esi
    call    sub_4BC8D0
    mov     edi, [esp+23Ch+var_224]
    jmp     short loc_4AF43F
    ; ---------------------------------------------------------------------------

    loc_4AF438:                             ; CODE XREF: sub_4AF320+43j
                                            ; sub_4AF320+65j
    mov     ebx, [esp+23Ch+arg_8]

    loc_4AF43F:                             ; CODE XREF: sub_4AF320+116j
    mov     eax, [esp+23Ch+arg_0]
    push    1
    lea     edx, [esp+240h+var_218]
    push    0FFFFFFFFh
    push    edx
    push    eax
    call    sub_4BC4B0
    mov     esi, eax
    cmp     esi, 0FFFFFFFFh
    mov     [esp+23Ch+var_228], esi
    jz      loc_4AF552

    loc_4AF464:                             ; CODE XREF: sub_4AF320+222j
    cmp     byte ptr [esp+23Ch+var_204], 2Eh
    jz      loc_4AF534
    cmp     [esp+23Ch+var_218], 10h
    jz      loc_4AF534
    lea     edi, [esp+23Ch+var_204]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, [esp+23Ch+arg_10]
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    cmp     eax, 1
    rep movsb
    jnz     short loc_4AF4AD
    push    ebp
    call    sub_4BB0F0

    loc_4AF4AD:                             ; CODE XREF: sub_4AF320+185j
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     eax, [esp+23Ch+var_21C]
    not     ecx
    dec     ecx
    add     eax, 4
    test    ebx, ebx
    lea     ebp, [ebp+ecx+1]
    mov     ecx, [esp+23Ch+var_20C]
    mov     [eax-4], ecx
    mov     [esp+23Ch+var_21C], eax
    jz      short loc_4AF527
    lea     edx, [esp+23Ch+var_100]
    push    0Ah                             ; int
    lea     eax, [esp+240h+var_204]
    push    edx                             ; char *
    push    eax
    call    sub_4BBC40
    push    eax                             ; int
    call    __itoa
    lea     edi, [esp+248h+var_100]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    lea     edi, [esp+23Ch+var_100]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     ebx, [ebx+ecx+1]

    loc_4AF527:                             ; CODE XREF: sub_4AF320+1B1j
    mov     eax, [esp+23Ch+var_22C]
    mov     esi, [esp+23Ch+var_228]
    inc     eax
    mov     [esp+23Ch+var_22C], eax

    loc_4AF534:                             ; CODE XREF: sub_4AF320+149j
                                            ; sub_4AF320+154j
    lea     eax, [esp+23Ch+var_218]
    push    eax
    push    esi
    call    sub_4BC640
    cmp     eax, 0FFFFFFFFh
    jnz     loc_4AF464
    push    esi
    call    sub_4BC8D0
    mov     edi, [esp+23Ch+var_224]

    loc_4AF552:                             ; CODE XREF: sub_4AF320+13Ej
    mov     eax, [esp+23Ch+arg_14]
    test    eax, eax
    jz      short loc_4AF584
    cmp     eax, 2
    jnz     short loc_4AF572
    mov     ecx, [esp+23Ch+var_22C]
    mov     edx, [esp+23Ch+var_220]
    push    ecx
    push    0
    push    0
    push    edx
    jmp     short loc_4AF57F
    ; ---------------------------------------------------------------------------

    loc_4AF572:                             ; CODE XREF: sub_4AF320+240j
    mov     eax, [esp+23Ch+var_22C]
    mov     ecx, [esp+23Ch+var_220]
    push    eax
    push    edi
    push    0
    push    ecx

    loc_4AF57F:                             ; CODE XREF: sub_4AF320+250j
    call    sub_4AEFA0

    loc_4AF584:                             ; CODE XREF: sub_4AF320+23Bj
    push    edi                             ; int
    call    sub_4D85A0
    mov     eax, [esp+240h+var_22C]
    add     esp, 4
    mov     byte ptr [ebp+0], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 22Ch
    retn    18h
    sub_4AF320 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AF5B0 proc near                    ; CODE XREF: sub_4AF670+396p
                                            ; .text:004AFC3Fp

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    lea     ebx, [esi+14h]
    push    ebx
    call    sub_4BC2E0
    lea     edi, [esi+24h]
    push    100h                            ; size_t
    push    edi                             ; int
    push    ebx                             ; int
    call    sub_4BC320
    mov     eax, [esi+238h]
    mov     edx, [esi+0Ch]
    mov     ecx, [esi+234h]
    push    0
    push    0
    push    1
    push    eax
    add     edx, 0B6h
    push    ecx
    push    edx
    call    sub_4AF320
    mov     ecx, [esi+234h]
    mov     ebx, eax
    mov     eax, [esi+238h]
    push    ebx
    push    0
    push    eax
    push    ecx
    call    sub_4AEFA0
    mov     edx, [esi+234h]
    mov     eax, [esi]
    push    0
    push    ebx
    push    edx
    push    offset aSwin                    ; "SWIN"
    push    eax
    call    sub_4A32A0
    mov     ecx, [esi+238h]
    mov     edx, [esi]
    push    0
    push    ebx
    push    ecx
    push    offset aSize                    ; "SIZE"
    push    edx
    call    sub_4A32A0
    mov     eax, [esi+4]
    or      ecx, 0FFFFFFFFh
    mov     word ptr [eax+140h], 0
    mov     edx, [esi+10h]
    xor     eax, eax
    add     edx, 0B6h
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_4AF5B0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AF670 proc near                    ; DATA XREF: .text:004AFAD3o

    var_6= dword ptr -6
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    mov     ebx, [esp+0Ch+arg_0]
    push    ebp
    push    esi
    mov     eax, [ebx+18h]
    mov     ecx, [ebx+60h]
    cmp     ecx, 0FFFFFFFFh
    push    edi
    mov     ebp, [eax+0Ch]
    jnz     short loc_4AF6B4
    lea     eax, [ebp+124h]
    push    eax
    call    sub_4BC300
    lea     ecx, [ebp+134h]
    push    ecx                             ; lpPathName
    call    sub_4BC360
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4AF6B4:                             ; CODE XREF: sub_4AF670+17j
    mov     esi, [eax+4]
    push    offset aLoad                    ; char *
    push    ecx                             ; int
    push    esi                             ; int
    mov     byte ptr [esp+24h+var_6+1], 0
    mov     [esp+24h+var_6+2], 0
    call    sub_4A0300
    test    eax, eax
    jnz     loc_4AF8AE
    mov     edx, [ebx+60h]
    push    offset aSwin                    ; char *
    push    edx                             ; int
    push    esi                             ; int
    call    sub_4A0300
    test    eax, eax
    jnz     loc_4AF8AE
    mov     eax, [ebx+60h]
    push    offset aCanc                    ; char *
    push    eax                             ; int
    push    esi                             ; int
    call    sub_4A0300
    test    eax, eax
    jz      short loc_4AF70F
    mov     [esp+18h+var_6+2], 1
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF70F:                             ; CODE XREF: sub_4AF670+90j
    mov     ecx, [ebx+60h]
    push    offset aPath                    ; char *
    push    ecx                             ; int
    push    esi                             ; int
    call    sub_4A0300
    test    eax, eax
    jz      short loc_4AF770
    lea     edx, [ebp+24h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    test    ecx, ecx
    jle     loc_4AF9E7

    loc_4AF739:                             ; CODE XREF: sub_4AF670+D2j
    cmp     byte ptr [ecx+edx], 5Ch
    jz      short loc_4AF749
    dec     ecx
    test    ecx, ecx
    jg      short loc_4AF739
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF749:                             ; CODE XREF: sub_4AF670+CDj
    cmp     byte ptr [ebp+ecx+23h], 3Ah
    jnz     short loc_4AF760
    push    edx                             ; lpPathName
    mov     byte ptr [ebp+ecx+25h], 0
    call    sub_4BC360
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF760:                             ; CODE XREF: sub_4AF670+DEj
    push    edx                             ; lpPathName
    mov     byte ptr [ebp+ecx+24h], 0
    call    sub_4BC360
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF770:                             ; CODE XREF: sub_4AF670+B0j
    mov     edx, [ebx+60h]
    push    offset aName_0                  ; char *
    push    edx                             ; int
    push    esi                             ; int
    call    sub_4A0300
    test    eax, eax
    jz      short loc_4AF7E7
    push    0Eh
    push    offset aLoad                    ; char *
    push    esi                             ; int
    call    sub_49FDF0
    push    3
    push    offset aName_0                  ; char *
    push    esi                             ; int
    mov     [ebx+60h], eax
    call    sub_49FDF0
    mov     ecx, eax
    add     esi, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     dword ptr [esp+14h], 1
    lea     ecx, [ecx+ecx*2]
    lea     edx, [eax+ecx*2]
    lea     ecx, [eax+edx*4]
    xor     eax, eax
    lea     edi, [esi+ecx*2+0B6h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, [ebp+23Ch]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF7E7:                             ; CODE XREF: sub_4AF670+111j
    mov     eax, [ebx+60h]
    push    offset aAdrv                    ; char *
    push    eax                             ; int
    push    esi                             ; int
    call    sub_4A0300
    test    eax, eax
    jz      short loc_4AF80E
    lea     ecx, [esp+18h+var_6]
    mov     byte ptr [esp+18h+var_6], 41h
    push    ecx
    call    sub_4BC300
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF80E:                             ; CODE XREF: sub_4AF670+188j
    mov     edx, [ebx+60h]
    push    offset aBdrv                    ; char *
    push    edx                             ; int
    push    esi                             ; int
    call    sub_4A0300
    test    eax, eax
    jz      short loc_4AF835
    lea     eax, [esp+18h+var_6]
    mov     byte ptr [esp+18h+var_6], 42h
    push    eax
    call    sub_4BC300
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF835:                             ; CODE XREF: sub_4AF670+1AFj
    mov     ecx, [ebx+60h]
    push    offset aCdrv                    ; char *
    push    ecx                             ; int
    push    esi                             ; int
    call    sub_4A0300
    test    eax, eax
    jz      short loc_4AF85C
    lea     edx, [esp+18h+var_6]
    mov     byte ptr [esp+18h+var_6], 43h
    push    edx
    call    sub_4BC300
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF85C:                             ; CODE XREF: sub_4AF670+1D6j
    mov     eax, [ebx+60h]
    push    offset aDdrv                    ; char *
    push    eax                             ; int
    push    esi                             ; int
    call    sub_4A0300
    test    eax, eax
    jz      short loc_4AF883
    lea     ecx, [esp+18h+var_6]
    mov     byte ptr [esp+18h+var_6], 44h
    push    ecx
    call    sub_4BC300
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF883:                             ; CODE XREF: sub_4AF670+1FDj
    mov     edx, [ebx+60h]
    push    offset aVdrv                    ; char *
    push    edx                             ; int
    push    esi                             ; int
    call    sub_4A0300
    test    eax, eax
    jz      loc_4AF9E7
    lea     eax, [esp+18h+var_6]
    mov     byte ptr [esp+18h+var_6], 52h
    push    eax
    call    sub_4BC300
    jmp     loc_4AF9E7
    ; ---------------------------------------------------------------------------

    loc_4AF8AE:                             ; CODE XREF: sub_4AF670+62j
                                            ; sub_4AF670+79j
    push    offset aSwin                    ; char *
    push    esi                             ; int
    call    sub_49FF90
    movsx   ecx, word ptr [eax+0BAh]
    mov     edx, [ebp+234h]
    push    ecx
    push    edx
    call    sub_4B6AF0
    mov     edx, eax
    cmp     byte ptr [edx], 5Ch
    jnz     loc_4AF960
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [ebp+23Ch]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    xor     eax, eax
    rep movsb
    mov     ecx, [ebp+23Ch]

    loc_4AF903:                             ; CODE XREF: sub_4AF670+29Dj
    cmp     byte ptr [eax+ecx], 20h
    jz      short loc_4AF911
    inc     eax
    cmp     eax, 0Ah
    jl      short loc_4AF903
    jmp     short loc_4AF915
    ; ---------------------------------------------------------------------------

    loc_4AF911:                             ; CODE XREF: sub_4AF670+297j
    mov     byte ptr [eax+ecx], 0

    loc_4AF915:                             ; CODE XREF: sub_4AF670+29Fj
    lea     edx, [ebp+24h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    mov     edi, [ebp+23Ch]
    not     ecx
    dec     ecx
    cmp     ecx, 3
    jnz     short loc_4AF930
    inc     edi

    loc_4AF930:                             ; CODE XREF: sub_4AF670+2BDj
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    push    edx                             ; lpPathName
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb
    call    sub_4BC360
    jmp     loc_4AF9E3
    ; ---------------------------------------------------------------------------

    loc_4AF960:                             ; CODE XREF: sub_4AF670+262j
    or      ecx, 0FFFFFFFFh
    lea     edi, [ebp+24h]
    xor     eax, eax
    mov     [esp+18h+var_6+2], 1
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [ebp+23Ch]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, offset byte_503374
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, [ebp+23Ch]
    mov     ebx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, [ebp+23Ch]
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4AF9E3:                             ; CODE XREF: sub_4AF670+2EBj
    mov     ebx, [esp+18h+arg_0]

    loc_4AF9E7:                             ; CODE XREF: sub_4AF670+9Aj
                                            ; sub_4AF670+C3j ...
    cmp     [esp+18h+var_6+2], 1
    jnz     short loc_4AFA05
    mov     eax, [ebp+244h]
    test    eax, eax
    jz      short loc_4AFA17
    push    ebp
    call    eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4AFA05:                             ; CODE XREF: sub_4AF670+37Cj
    push    ebp
    call    sub_4AF5B0
    push    ebx                             ; int
    call    sub_49FA90
    push    ebx
    call    sub_4AB0A0

    loc_4AFA17:                             ; CODE XREF: sub_4AF670+386j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_4AF670 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ecx
    push    esi
    mov     esi, [esp+0Ch]
    push    0
    push    offset aFilereq_gui             ; "FILEREQ.GUI"
    push    esi
    call    sub_4AA8F0
    test    eax, eax
    mov     [esp+4], eax
    jnz     short loc_4AFA50
    pop     esi
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4AFA50:                             ; CODE XREF: .text:004AFA49j
    push    edi
    push    ebp
    push    ebx
    push    24Ch
    push    offset aFileRequesterD          ; "FILE REQUESTER DATA"
    call    sub_4D83B0
    mov     ebp, [esp+24h]
    mov     ebx, eax
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    mov     [ebx], esi
    lea     edx, [ebx+24h]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    edx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    call    sub_4BB120
    lea     edx, [ebx+24h]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jnz     short loc_4AFAC6
    mov     edi, offset aNoPath             ; "NO PATH"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4AFAC6:                             ; CODE XREF: .text:004AFAA4j
    mov     eax, [esp+10h]
    mov     ecx, [esp+18h]
    push    offset aName_0                  ; "NAME"
    mov     dword ptr [eax+8], offset sub_4AF670
    mov     [eax+0Ch], ebx
    mov     dword ptr [ebx+244h], 0
    mov     edx, [ecx+18h]
    mov     esi, [edx+4]
    push    esi
    call    sub_4A0010
    push    offset aMask                    ; "MASK"
    push    esi
    mov     [ebx+8], eax
    call    sub_4A0010
    push    offset aPath                    ; "PATH"
    push    esi
    mov     [ebx+0Ch], eax
    call    sub_49FF10
    push    offset aTitl                    ; "TITL"
    push    esi
    mov     [ebx+10h], eax
    call    sub_4A0180
    mov     edi, eax
    push    offset aSlid                    ; "SLID"
    push    esi
    mov     [esp+18h], edi
    call    sub_4A0200
    or      edx, 0FFFFFFFFh
    mov     [ebx+4], eax
    mov     [esi+13h], dx
    mov     [esi+15h], dx
    lea     esi, [edi+0B6h]
    mov     edi, [esp+24h]
    mov     ecx, edx
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     [esp+1Ch], esi
    mov     eax, ecx
    mov     esi, edi
    mov     edi, [esp+1Ch]
    push    17700h
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    offset aFileNames               ; "FILE NAMES"
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+18h]
    mov     [ecx+13h], dx
    call    sub_4D83B0
    add     esp, 8
    mov     edi, eax
    mov     ecx, 5DC0h
    or      eax, 0FFFFFFFFh
    mov     [ebx+234h], edi
    push    0EA60h
    rep stosd
    push    offset aFileSizes               ; "FILE SIZES"
    call    sub_4D83B0
    mov     edx, [esp+28h]
    add     esp, 8
    mov     edi, eax
    mov     ecx, 3A98h
    or      eax, 0FFFFFFFFh
    mov     [ebx+238h], edi
    rep stosd
    push    ebp
    mov     [ebx+240h], edx
    mov     [ebx+23Ch], ebp
    call    sub_4BB150
    mov     edx, [ebx+8]
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     edx, 0B6h
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edx, [ebx+0Ch]
    mov     edi, [esp+20h]
    or      ecx, 0FFFFFFFFh
    add     edx, 0B6h
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     esi, [ebx+124h]
    push    esi
    call    sub_4BC2E0
    lea     ecx, [ebx+134h]
    push    100h
    push    ecx
    push    esi
    call    sub_4BC320
    push    ebx
    call    sub_4AF5B0
    mov     edx, [esp+18h]
    push    edx
    call    sub_49FA90
    mov     eax, ebx
    pop     ebx
    pop     ebp
    pop     edi
    pop     esi
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AFC60 proc near                    ; CODE XREF: .text:0045F89Bp
                                            ; sub_4609B0+28Dp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+0A6h]
    test    eax, eax
    jz      short loc_4AFC83
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+0A6h], 0

    loc_4AFC83:                             ; CODE XREF: sub_4AFC60+Ej
    mov     edi, [esp+4+arg_4]
    lea     eax, [edi+edi*4]
    lea     ecx, [edi+eax*8]
    shl     ecx, 2
    push    ecx
    push    offset aBlinkwords              ; "BlinkWords"
    call    sub_4D83B0
    add     esp, 8
    mov     [esi+0A6h], eax
    test    edi, edi
    jle     short loc_4AFCC2
    xor     eax, eax
    mov     ecx, edi

    loc_4AFCAC:                             ; CODE XREF: sub_4AFC60+60j
    mov     edx, [esi+0A6h]
    add     eax, 0A4h
    dec     ecx
    mov     byte ptr [edx+eax-0A4h], 0
    jnz     short loc_4AFCAC

    loc_4AFCC2:                             ; CODE XREF: sub_4AFC60+46j
    mov     eax, [esi+0A6h]
    mov     [esi+0AAh], edi
    mov     dword ptr [esi+0AEh], 1
    pop     edi
    mov     dword ptr [eax+0A0h], 0FFFFFFFFh
    pop     esi
    retn    8
    sub_4AFC60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AFCF0 proc near                    ; CODE XREF: .text:0045F786p
                                            ; .text:00478CC6p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    mov     eax, [esi+0A6h]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    mov     [esi+0A6h], eax
    mov     [esi+0AEh], eax
    pop     esi
    retn    4
    sub_4AFCF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AFD20 proc near                    ; CODE XREF: sub_476EF0+93p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     edx, [esp+arg_4]
    mov     ecx, [eax+0A6h]
    mov     [ecx+0A0h], edx
    retn    8
    sub_4AFD20 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    mov     ecx, [eax+0A6h]
    test    ecx, ecx
    jz      short locret_4AFD58
    mov     dword ptr [eax+0AEh], 1

    locret_4AFD58:                          ; CODE XREF: .text:004AFD4Cj
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     ecx, [eax+0A6h]
    test    ecx, ecx
    jz      short locret_4AFD78
    mov     dword ptr [eax+0AEh], 0

    locret_4AFD78:                          ; CODE XREF: .text:004AFD6Cj
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4AFD80(int,char *,int,int,int,int,int,int)
    sub_4AFD80 proc near                    ; CODE XREF: sub_476EF0+407p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    push    ecx
    push    esi
    push    edi
    mov     edi, [esp+0Ch+arg_0]
    mov     eax, [edi+0A6h]
    test    eax, eax
    jnz     short loc_4AFD97
    pop     edi
    pop     esi
    pop     ecx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4AFD97:                             ; CODE XREF: sub_4AFD80+Fj
    mov     ecx, [edi+0AAh]
    xor     esi, esi
    test    ecx, ecx
    jle     short loc_4AFDB2

    loc_4AFDA3:                             ; CODE XREF: sub_4AFD80+30j
    cmp     byte ptr [eax], 0
    jz      short loc_4AFDB2
    inc     esi
    add     eax, 0A4h
    cmp     esi, ecx
    jl      short loc_4AFDA3

    loc_4AFDB2:                             ; CODE XREF: sub_4AFD80+21j
                                            ; sub_4AFD80+26j
    cmp     esi, ecx
    jnz     short loc_4AFDBE
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ecx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4AFDBE:                             ; CODE XREF: sub_4AFD80+34j
    call    sub_4B6340
    mov     edx, [edi+0A6h]
    mov     ecx, [esp+0Ch+arg_4]
    mov     [esp+0Ch+var_4], eax
    lea     eax, [esi+esi*4]
    push    80h                             ; size_t
    push    ecx                             ; char *
    lea     esi, [esi+eax*8]
    shl     esi, 2
    add     edx, esi
    push    edx                             ; char *
    call    _strncpy
    mov     eax, [edi+0A6h]
    mov     ecx, [esp+18h+arg_8]
    fld     [esp+18h+arg_18]
    mov     [eax+esi+80h], ecx
    mov     edx, [edi+0A6h]
    mov     eax, [esp+18h+arg_C]
    add     esp, 0Ch
    mov     [edx+esi+84h], eax
    mov     ecx, [edi+0A6h]
    mov     edx, [esp+0Ch+arg_10]
    mov     [ecx+esi+88h], edx
    mov     eax, [edi+0A6h]
    mov     ecx, [esp+0Ch+arg_14]
    mov     [eax+esi+90h], ecx
    mov     edx, [edi+0A6h]
    fstp    dword ptr [edx+esi+8Ch]
    mov     eax, [edi+0A6h]
    fld     [esp+0Ch+arg_1C]
    fstp    dword ptr [eax+esi+94h]
    call    sub_4B6330
    mov     [esp+0Ch+arg_0], eax
    mov     ecx, [edi+0A6h]
    fild    [esp+0Ch+arg_0]
    mov     eax, 1
    fmul    [esp+0Ch+arg_18]
    fiadd   [esp+0Ch+var_4]
    fstp    dword ptr [ecx+esi+9Ch]
    mov     edx, [edi+0A6h]
    pop     edi
    mov     dword ptr [edx+esi+98h], 0
    pop     esi
    pop     ecx
    retn    20h
    sub_4AFD80 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     ecx, [esp+4]
    mov     eax, [esp+8]
    cmp     eax, [ecx+0AAh]
    jg      short locret_4AFEB0
    mov     ecx, [ecx+0A6h]
    lea     edx, [eax+eax*4]
    lea     eax, [eax+edx*8]
    mov     byte ptr [ecx+eax*4], 0

    locret_4AFEB0:                          ; CODE XREF: .text:004AFE9Ej
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AFEC0 proc near                    ; CODE XREF: sub_476EF0+73p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+0A6h]
    test    ecx, ecx
    jz      short locret_4AFEF9
    mov     edx, [eax+0AAh]
    xor     ecx, ecx
    test    edx, edx
    jle     short locret_4AFEF9
    push    esi
    xor     edx, edx

    loc_4AFEDD:                             ; CODE XREF: sub_4AFEC0+36j
    mov     esi, [eax+0A6h]
    inc     ecx
    mov     byte ptr [esi+edx], 0
    mov     esi, [eax+0AAh]
    add     edx, 0A4h
    cmp     ecx, esi
    jl      short loc_4AFEDD
    pop     esi

    locret_4AFEF9:                          ; CODE XREF: sub_4AFEC0+Cj
                                            ; sub_4AFEC0+18j
    retn    4
    sub_4AFEC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4AFF00 proc near                    ; CODE XREF: .text:00478954p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+14h+arg_0]
    push    edi
    mov     eax, [esi+0AEh]
    test    eax, eax
    jz      loc_4B007B
    call    sub_4B6340
    mov     [esp+18h+var_8], eax
    mov     eax, [esi+0A6h]
    mov     eax, [eax+0A0h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4AFF40
    mov     ecx, [esi+18h]
    push    eax
    mov     edx, [ecx+4]
    push    edx
    call    sub_4A1810

    loc_4AFF40:                             ; CODE XREF: sub_4AFF00+31j
    mov     eax, [esi+0AAh]
    xor     ebx, ebx
    test    eax, eax
    jle     loc_4B007B
    xor     edi, edi

    loc_4AFF52:                             ; CODE XREF: sub_4AFF00+175j
    mov     eax, [esi+0A6h]
    lea     ecx, [edi+eax]
    mov     al, [edi+eax]
    test    al, al
    jz      loc_4B0066
    fld     dword ptr [ecx+9Ch]
    fild    [esp+18h+var_8]
    fstp    [esp+18h+arg_0]
    fcomp   [esp+18h+arg_0]
    fnstsw  ax
    test    ah, 1
    jz      short loc_4AFFF9
    mov     eax, [ecx+98h]
    test    eax, eax
    jz      short loc_4AFFC2
    mov     ecx, [esi+0A6h]
    lea     ebp, [edi+ecx]
    call    sub_4B6330
    mov     [esp+18h+var_4], eax
    fild    [esp+18h+var_4]
    fmul    dword ptr [ebp+8Ch]
    fadd    [esp+18h+arg_0]
    fstp    dword ptr [ebp+9Ch]
    mov     edx, [esi+0A6h]
    mov     dword ptr [edi+edx+98h], 0
    jmp     short loc_4AFFF9
    ; ---------------------------------------------------------------------------

    loc_4AFFC2:                             ; CODE XREF: sub_4AFF00+87j
    mov     eax, [esi+0A6h]
    lea     ebp, [edi+eax]
    call    sub_4B6330
    mov     [esp+18h+var_4], eax
    fild    [esp+18h+var_4]
    fmul    dword ptr [ebp+94h]
    fadd    [esp+18h+arg_0]
    fstp    dword ptr [ebp+9Ch]
    mov     ecx, [esi+0A6h]
    mov     dword ptr [edi+ecx+98h], 1

    loc_4AFFF9:                             ; CODE XREF: sub_4AFF00+7Dj
                                            ; sub_4AFF00+C0j
    mov     edx, [esi+0A6h]
    mov     eax, [edi+edx+98h]
    test    eax, eax
    jz      short loc_4B0020
    call    sub_4C13F0
    push    eax
    mov     eax, [esi+0A6h]
    mov     ecx, [edi+eax+90h]
    push    ecx
    jmp     short loc_4B0034
    ; ---------------------------------------------------------------------------

    loc_4B0020:                             ; CODE XREF: sub_4AFF00+108j
    call    sub_4C13F0
    mov     edx, [esi+0A6h]
    push    eax
    mov     eax, [edi+edx+88h]
    push    eax

    loc_4B0034:                             ; CODE XREF: sub_4AFF00+11Ej
    call    sub_4C13A0
    mov     ecx, [esi+0A6h]
    push    0FFFFFFFFh
    mov     edx, [edi+ecx+84h]
    lea     eax, [edi+ecx]
    push    edx
    mov     edx, [esi+18h]
    mov     ecx, [eax+80h]
    push    ecx
    push    eax
    mov     eax, [edx+4]
    mov     ecx, [eax+0BCh]
    push    ecx
    call    PrintGUIText

    loc_4B0066:                             ; CODE XREF: sub_4AFF00+60j
    mov     eax, [esi+0AAh]
    inc     ebx
    add     edi, 0A4h
    cmp     ebx, eax
    jl      loc_4AFF52

    loc_4B007B:                             ; CODE XREF: sub_4AFF00+13j
                                            ; sub_4AFF00+4Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_4AFF00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0090 proc near                    ; CODE XREF: sub_4B04B0+24p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h

    push    ebx
    mov     ebx, [esp+arg_8]
    push    esi
    mov     esi, [esp+4+arg_4]
    push    edi
    mov     edi, [esp+8+arg_0]
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    inc     eax
    push    ebx
    dec     ecx
    push    eax
    push    ecx
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    mov     ecx, [esi+0Ch]
    mov     eax, [esi]
    mov     edx, [esi+4]
    push    ebx
    push    ecx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     eax, [esi]
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+4]
    inc     eax
    dec     ecx
    push    ebx
    push    ecx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+4]
    mov     ebx, [esp+8+arg_C]
    mov     eax, [esi+8]
    push    ebx
    push    ecx
    inc     edx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     eax, [esi+8]
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+4]
    dec     eax
    push    ebx
    push    ecx
    add     edx, 2
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    push    eax
    inc     edx
    push    edx
    push    edi
    call    sub_4BE950
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    dec     eax
    push    ebx
    push    eax
    push    ecx
    add     edx, 2
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_4B0090 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0160 proc near                    ; CODE XREF: sub_4B0230+F0p
                                            ; sub_4B0230+268p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h

    push    ebx
    mov     ebx, [esp+arg_C]
    push    esi
    mov     esi, [esp+4+arg_4]
    push    edi
    mov     edi, [esp+8+arg_0]
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    inc     eax
    push    ebx
    dec     ecx
    push    eax
    push    ecx
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    mov     ecx, [esi+0Ch]
    mov     eax, [esi]
    mov     edx, [esi+4]
    push    ebx
    push    ecx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     eax, [esi]
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+4]
    inc     eax
    dec     ecx
    push    ebx
    push    ecx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+4]
    mov     ebx, [esp+8+arg_8]
    mov     eax, [esi+8]
    push    ebx
    push    ecx
    inc     edx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     eax, [esi+8]
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+4]
    dec     eax
    push    ebx
    push    ecx
    add     edx, 2
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    push    eax
    inc     edx
    push    edx
    push    edi
    call    sub_4BE950
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    dec     eax
    push    ebx
    push    eax
    push    ecx
    add     edx, 2
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_4B0160 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0230 proc near                    ; CODE XREF: sub_4A1B40+A7p
                                            ; sub_4A4D70+137p ...

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 24h
    mov     edx, [esp+24h+arg_4]
    lea     ecx, [esp+24h+var_10]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+30h+arg_0]
    push    edi
    push    ecx
    mov     eax, [esi+18h]
    push    edx
    mov     edi, [eax+4]
    push    edi
    call    sub_4A15C0
    mov     ebx, [esp+34h+arg_8]
    test    ebx, ebx
    jnz     short loc_4B02AC
    mov     eax, [esi+4]
    test    eax, eax
    jz      loc_4B049D
    push    offset aListbox_0               ; char *
    push    eax                             ; int
    call    sub_4B8D40
    test    eax, eax
    mov     [esp+34h+arg_8], eax
    jz      loc_4B049D
    mov     ebp, [esp+34h+var_10]
    mov     ebx, [esp+34h+var_C]
    mov     edx, [esp+34h+var_8]
    mov     ecx, [esp+34h+var_4]
    mov     eax, 3
    sub     ebp, eax
    sub     ebx, eax
    add     edx, eax
    add     ecx, eax
    mov     [esp+34h+var_C], ebx
    mov     ebx, [esp+34h+arg_8]
    mov     [esp+34h+var_10], ebp
    mov     [esp+34h+var_8], edx
    mov     [esp+34h+var_4], ecx

    loc_4B02AC:                             ; CODE XREF: sub_4B0230+27j
    mov     eax, [esi+18h]
    mov     edx, [esp+34h+arg_4]
    push    edx
    push    edi
    mov     ecx, [eax+4]
    mov     ebp, [ecx+0BCh]
    call    sub_4A18C0
    mov     edi, eax
    test    edi, edi
    jz      short loc_4B032F
    mov     eax, [ebp+0]
    xor     ebx, ebx
    test    eax, eax
    jle     short loc_4B02FF

    loc_4B02D2:                             ; CODE XREF: sub_4B0230+C9j
    mov     eax, [ebp+4]
    xor     esi, esi
    test    eax, eax
    jle     short loc_4B02F0

    loc_4B02DB:                             ; CODE XREF: sub_4B0230+BEj
    push    esi
    push    ebx
    push    edi
    push    ebp
    call    sub_4C6B70
    mov     ecx, [edi+4]
    mov     eax, [ebp+4]
    add     esi, ecx
    cmp     esi, eax
    jl      short loc_4B02DB

    loc_4B02F0:                             ; CODE XREF: sub_4B0230+A9j
    mov     ecx, [edi]
    mov     eax, [ebp+0]
    add     ebx, ecx
    cmp     ebx, eax
    jl      short loc_4B02D2
    mov     esi, [esp+34h+arg_0]

    loc_4B02FF:                             ; CODE XREF: sub_4B0230+A0j
    xor     eax, eax
    xor     ecx, ecx
    mov     al, [esi+8C6h]
    mov     cl, [esi+8C3h]
    xor     edx, edx
    push    eax
    mov     dl, [esi+8B2h]
    push    ecx
    lea     eax, [esp+3Ch+var_10]
    push    edx
    push    eax
    push    ebp
    call    sub_4B0160
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B032F:                             ; CODE XREF: sub_4B0230+97j
    test    ebx, ebx
    jz      loc_4B0463
    cmp     word ptr [ebx], 1
    push    0
    push    ebx
    jbe     loc_4B0449
    call    sub_4B7F30
    mov     esi, [esp+34h+var_10]
    xor     ebx, ebx
    mov     bx, [eax]
    mov     edx, [esp+34h+arg_4]
    xor     ecx, ecx
    mov     cx, [eax+2]
    xor     eax, eax
    cmp     edx, eax
    mov     edx, [esp+34h+var_C]
    mov     [esp+34h+var_14], ecx
    jz      short loc_4B0374
    mov     [esp+34h+arg_0], edx
    mov     [esp+34h+var_20], esi
    jmp     short loc_4B037C
    ; ---------------------------------------------------------------------------

    loc_4B0374:                             ; CODE XREF: sub_4B0230+138j
    mov     [esp+34h+arg_0], eax
    mov     [esp+34h+var_20], eax

    loc_4B037C:                             ; CODE XREF: sub_4B0230+142j
    mov     eax, [esp+34h+var_4]
    mov     edi, [esp+34h+var_8]
    sub     eax, edx
    sub     edi, esi
    inc     eax
    inc     edi
    xor     edx, edx
    mov     [esp+34h+var_18], eax
    test    eax, eax
    mov     [esp+34h+arg_4], edx
    jle     loc_4B049D

    loc_4B039C:                             ; CODE XREF: sub_4B0230+209j
    test    edx, edx
    jnz     short loc_4B03A6
    mov     [esp+34h+var_24], edx
    jmp     short loc_4B03C3
    ; ---------------------------------------------------------------------------

    loc_4B03A6:                             ; CODE XREF: sub_4B0230+16Ej
    mov     esi, eax
    xor     edx, edx
    sub     esi, ecx
    inc     esi
    cmp     [esp+34h+arg_4], esi
    setnl   dl
    dec     edx
    and     edx, 0FFFFFFFDh
    add     edx, 6
    mov     [esp+34h+var_24], edx
    mov     edx, [esp+34h+arg_4]

    loc_4B03C3:                             ; CODE XREF: sub_4B0230+174j
    lea     esi, [ecx+edx]
    cmp     esi, eax
    jle     short loc_4B03D2
    mov     edx, eax
    sub     edx, ecx
    mov     [esp+34h+arg_4], edx

    loc_4B03D2:                             ; CODE XREF: sub_4B0230+198j
    xor     esi, esi
    test    edi, edi
    jle     short loc_4B0431
    mov     eax, [esp+34h+arg_0]
    add     eax, edx
    mov     [esp+34h+var_1C], eax

    loc_4B03E2:                             ; CODE XREF: sub_4B0230+1F3j
    lea     ecx, [ebx+esi]
    cmp     ecx, edi
    jl      short loc_4B03F4
    mov     esi, edi
    mov     eax, 2
    sub     esi, ebx
    jmp     short loc_4B03FB
    ; ---------------------------------------------------------------------------

    loc_4B03F4:                             ; CODE XREF: sub_4B0230+1B7j
    xor     eax, eax
    test    esi, esi
    setnz   al

    loc_4B03FB:                             ; CODE XREF: sub_4B0230+1C2j
    mov     edx, [esp+34h+var_24]
    add     edx, eax
    mov     eax, [esp+34h+arg_8]
    push    edx
    push    eax
    call    sub_4B7F30
    mov     edx, [esp+34h+var_20]
    mov     ecx, [esp+34h+var_1C]
    add     edx, esi
    push    ecx
    push    edx
    push    eax
    push    ebp
    call    sub_4B7F90
    add     esi, ebx
    cmp     esi, edi
    jl      short loc_4B03E2
    mov     edx, [esp+34h+arg_4]
    mov     eax, [esp+34h+var_18]
    mov     ecx, [esp+34h+var_14]

    loc_4B0431:                             ; CODE XREF: sub_4B0230+1A6j
    add     edx, ecx
    cmp     edx, eax
    mov     [esp+34h+arg_4], edx
    jl      loc_4B039C
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B0449:                             ; CODE XREF: sub_4B0230+10Ej
    call    sub_4B7F30
    push    0
    push    0
    push    eax
    push    ebp
    call    sub_4B7F90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B0463:                             ; CODE XREF: sub_4B0230+101j
    xor     eax, eax
    lea     ecx, [esp+34h+var_10]
    mov     al, [esi+8C6h]
    push    eax
    push    ecx
    push    ebp
    call    sub_4BF6F0
    xor     edx, edx
    xor     eax, eax
    mov     dl, [esi+8C6h]
    mov     al, [esi+8C3h]
    xor     ecx, ecx
    push    edx
    mov     cl, [esi+8B2h]
    push    eax
    lea     edx, [esp+3Ch+var_10]
    push    ecx
    push    edx
    push    ebp
    call    sub_4B0160

    loc_4B049D:                             ; CODE XREF: sub_4B0230+2Ej
                                            ; sub_4B0230+45j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    sub_4B0230 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B04B0 proc near                    ; CODE XREF: sub_4A4660+97p
                                            ; sub_4A5F40+2AAp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_10]
    push    edi
    mov     edi, [esp+8+arg_4]
    push    esi
    push    edi
    push    ebx
    call    sub_4BF6F0
    push    esi
    mov     eax, [esp+0Ch+arg_C]
    mov     ecx, [esp+0Ch+arg_8]
    push    eax
    push    ecx
    push    edi
    push    ebx
    call    sub_4B0090
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_4B04B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B04E0 proc near                    ; CODE XREF: sub_4A5F40+303p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_10]
    push    edi
    mov     edi, [esp+8+arg_4]
    push    esi
    push    edi
    push    ebx
    call    sub_4BF6F0
    push    esi
    mov     eax, [esp+0Ch+arg_C]
    mov     ecx, [esp+0Ch+arg_8]
    push    eax
    push    ecx
    push    edi
    push    ebx
    call    sub_4B0160
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_4B04E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0510 proc near                    ; CODE XREF: sub_4A2580+FDp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     eax, [esp+arg_10]
    push    ebx
    push    esi
    mov     esi, [esp+8+arg_4]
    push    edi
    mov     edi, [esp+0Ch+arg_0]
    push    eax
    push    esi
    push    edi
    call    sub_4BF6F0
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    mov     ebx, [esp+0Ch+arg_8]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    mov     ecx, [esi+0Ch]
    mov     eax, [esi]
    mov     edx, [esi+4]
    push    ebx
    push    ecx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+4]
    mov     ebx, [esp+0Ch+arg_C]
    mov     eax, [esi+8]
    push    ebx
    push    ecx
    inc     edx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    inc     edx
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_4B0510 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0590 proc near                    ; CODE XREF: sub_4A2580+123p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     eax, [esp+arg_10]
    push    ebx
    push    esi
    mov     esi, [esp+8+arg_4]
    push    edi
    mov     edi, [esp+0Ch+arg_0]
    push    eax
    push    esi
    push    edi
    call    sub_4BF6F0
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    mov     ebx, [esp+0Ch+arg_C]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    mov     ecx, [esi+0Ch]
    mov     eax, [esi]
    mov     edx, [esi+4]
    push    ebx
    push    ecx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+4]
    mov     ebx, [esp+0Ch+arg_8]
    mov     eax, [esi+8]
    push    ebx
    push    ecx
    inc     edx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    inc     edx
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    sub_4B0590 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0610 proc near                    ; CODE XREF: sub_485D40+48p
    push    esi
    mov     esi, ecx
    xor     edx, edx
    mov     ecx, 8
    mov     dword ptr [esi], offset off_4FDB00
    mov     [esi+8], edx
    mov     [esi+14h], edx
    mov     [esi+10h], edx
    lea     eax, [esi+1Ch]

    loc_4B062C:                             ; CODE XREF: sub_4B0610+24j
    mov     [eax], edx
    add     eax, 0A4h
    dec     ecx
    jnz     short loc_4B062C
    mov     [esi+53Ch], edx
    call    sub_4B6330
    mov     [esi+4], eax
    mov     eax, esi
    pop     esi
    retn
    sub_4B0610 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_78. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_79. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_80. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0680 proc near                    ; DATA XREF: .rdata:004FDB44o
    xor     eax, eax
    retn    14h
    sub_4B0680 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0690 proc near                    ; DATA XREF: .rdata:004FDB48o
    xor     eax, eax
    retn    4
    sub_4B0690 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_48. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B06B0 proc near                    ; DATA XREF: .rdata:004FDB50o

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    mov     eax, [esi+14h]
    mov     dword ptr [esi], offset off_4FDB00
    test    eax, eax
    jz      short loc_4B06C9
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B06C9:                             ; CODE XREF: sub_4B06B0+Ej
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4B06D9
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B06D9:                             ; CODE XREF: sub_4B06B0+1Ej
    test    [esp+arg_0], 1
    jz      short loc_4B06E9
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4B06E9:                             ; CODE XREF: sub_4B06B0+2Ej
    mov     eax, esi
    pop     esi
    retn    4
    sub_4B06B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B06F0 proc near                    ; CODE XREF: sub_485E30+3p
    push    esi
    mov     esi, ecx
    mov     eax, [esi+14h]
    mov     dword ptr [esi], offset off_4FDB00
    test    eax, eax
    jz      short loc_4B0709
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B0709:                             ; CODE XREF: sub_4B06F0+Ej
    mov     esi, [esi+10h]
    test    esi, esi
    jz      short loc_4B0719
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B0719:                             ; CODE XREF: sub_4B06F0+1Ej
    pop     esi
    retn
    sub_4B06F0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0720 proc near                    ; CODE XREF: sub_485D40+6Cp

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    test    edi, edi
    mov     [esi+8], edi
    jz      short loc_4B0793
    push    edi
    call    sub_4B26F0
    mov     [esi+0Ch], eax
    mov     eax, [edi+8]
    lea     ecx, [eax+eax*8]
    lea     edx, [eax+ecx*2]
    mov     eax, [esi+14h]
    shl     edx, 2
    push    edx                             ; int
    push    offset aObjectStates            ; int
    push    eax                             ; int
    call    Network_ReAllocPacketBuffer
    mov     edx, [esi+10h]
    mov     [esi+14h], eax
    mov     ecx, [edi+10h]
    add     esp, 0Ch
    shl     ecx, 2
    push    ecx                             ; int
    push    offset aStaticVaribles          ; int
    push    edx                             ; int
    call    Network_ReAllocPacketBuffer
    mov     [esi+10h], eax
    mov     edi, [edi+8]
    add     esp, 0Ch
    lea     eax, [edi+edi*8]
    lea     ecx, [edi+eax*2]
    mov     edi, [esi+14h]
    shl     ecx, 2
    mov     edx, ecx
    xor     eax, eax
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb

    loc_4B0793:                             ; CODE XREF: sub_4B0720+Dj
    pop     edi
    pop     esi
    retn    4
    sub_4B0720 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx+8]
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_49:
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B07C0 proc near                    ; CODE XREF: sub_438590+12p
                                            ; sub_4385F0+1Fp ...

    arg_0= dword ptr  4

    mov     ecx, [ecx+8]
    push    ebx
    push    ebp
    xor     ebp, ebp
    mov     eax, [ecx+4]
    push    esi
    test    eax, eax
    push    edi
    jle     short loc_4B0821
    mov     edi, [ecx+1Ch]

    loc_4B07D3:                             ; CODE XREF: sub_4B07C0+4Cj
    mov     esi, [edi]
    mov     ecx, [esp+10h+arg_0]

    loc_4B07D9:                             ; CODE XREF: sub_4B07C0+37j
    mov     bl, [ecx]
    mov     dl, bl
    cmp     bl, [esi]
    jnz     short loc_4B07FD
    test    dl, dl
    jz      short loc_4B07F9
    mov     bl, [ecx+1]
    mov     dl, bl
    cmp     bl, [esi+1]
    jnz     short loc_4B07FD
    add     ecx, 2
    add     esi, 2
    test    dl, dl
    jnz     short loc_4B07D9

    loc_4B07F9:                             ; CODE XREF: sub_4B07C0+23j
    xor     ecx, ecx
    jmp     short loc_4B0802
    ; ---------------------------------------------------------------------------

    loc_4B07FD:                             ; CODE XREF: sub_4B07C0+1Fj
                                            ; sub_4B07C0+2Dj
    sbb     ecx, ecx
    sbb     ecx, 0FFFFFFFFh

    loc_4B0802:                             ; CODE XREF: sub_4B07C0+3Bj
    test    ecx, ecx
    jz      short loc_4B0818
    inc     ebp
    add     edi, 4
    cmp     ebp, eax
    jl      short loc_4B07D3
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B0818:                             ; CODE XREF: sub_4B07C0+44j
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B0821:                             ; CODE XREF: sub_4B07C0+Ej
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn    4
    sub_4B07C0 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ecx
    mov     eax, [ecx+8]
    mov     [esp+0], ecx
    test    eax, eax
    jnz     short loc_4B0843
    or      eax, 0FFFFFFFFh
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B0843:                             ; CODE XREF: .text:004B083Aj
    push    edi
    push    esi
    push    ebp
    push    ebx
    mov     ebx, [eax+4]
    xor     ebp, ebp
    test    ebx, ebx
    jle     short loc_4B088E
    mov     edi, [eax+1Ch]

    loc_4B0853:                             ; CODE XREF: .text:004B088Cj
    mov     esi, [edi]
    mov     eax, [esp+18h]

    loc_4B0859:                             ; CODE XREF: .text:004B0877j
    mov     cl, [eax]
    mov     dl, cl
    cmp     cl, [esi]
    jnz     short loc_4B087D
    test    dl, dl
    jz      short loc_4B0879
    mov     cl, [eax+1]
    mov     dl, cl
    cmp     cl, [esi+1]
    jnz     short loc_4B087D
    add     eax, 2
    add     esi, 2
    test    dl, dl
    jnz     short loc_4B0859

    loc_4B0879:                             ; CODE XREF: .text:004B0863j
    xor     eax, eax
    jmp     short loc_4B0882
    ; ---------------------------------------------------------------------------

    loc_4B087D:                             ; CODE XREF: .text:004B085Fj
                                            ; .text:004B086Dj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4B0882:                             ; CODE XREF: .text:004B087Bj
    test    eax, eax
    jz      short loc_4B08A3
    inc     ebp
    add     edi, 4
    cmp     ebp, ebx
    jl      short loc_4B0853

    loc_4B088E:                             ; CODE XREF: .text:004B084Ej
    mov     ecx, [esp+10h]
    or      eax, 0FFFFFFFFh
    push    eax
    call    UnitScriptingData_StartScript
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B08A3:                             ; CODE XREF: .text:004B0884j
    mov     ecx, [esp+10h]
    mov     eax, ebp
    push    eax
    call    UnitScriptingData_StartScript
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall UnitScriptingData_StartScript(int MethodIndex)
    UnitScriptingData_StartScript proc near ; CODE XREF: .text:004B0896p
                                            ; .text:004B08AAp ...

    MethodIndex= dword ptr  8

    push    esi                             ; Method Index is a zero based index into the method name array.
                                            ; Method names are resolved into indexs at load-time and the indexs are used later.
    mov     esi, [esp+MethodIndex]
    test    esi, esi
    push    edi
    jl      short loc_4B092C                ; Make sure the Method index is greater than zero
    mov     eax, [ecx+UnitScriptingData.pCOB]
    cmp     esi, [eax+CobHeader.MethodCount]
    jge     short loc_4B092C                ; Make sure the Method Index is not greater than the total number of methods in the script
    xor     eax, eax
    lea     edx, [ecx+UnitScriptingData.ScriptSlots]

    loc_4B08D7:                             ; CODE XREF: UnitScriptingData_StartScript+26j
    cmp     [edx+ScriptSlot.Flags], 0       ; Look for a script-slot to use
    jz      short loc_4B08F0
    inc     eax
    add     edx, 0A4h                       ; Script slots at [ecx + 1Ch] 8*A4h
    cmp     eax, 8
    jl      short loc_4B08D7
    or      eax, 0FFFFFFFFh                 ; No script slots left
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B08F0:                             ; CODE XREF: UnitScriptingData_StartScript+1Aj
    lea     edx, [eax+eax*4]
    lea     edx, [eax+edx*8]
    lea     edx, [ecx+edx*4]
    mov     dword ptr [edx+1Ch], COB_IsRunnable ; Set the status flag
    mov     edi, [ecx+UnitScriptingData.pCOB]
    mov     edi, [edi+CobHeader.MethodEntryPoints]
    mov     esi, [edi+esi*4]
    mov     [edx+20h], esi                  ; These are relative to UnitScriptingData, not ScriptSlot
    mov     dword ptr [edx+24h], 0FFFFFFFFh ; ScriptSlot.StackIndex = -1;
    mov     dword ptr [edx+3Ch], 0          ; ScriptSlot.MethodReturnCallBack = null;
    mov     dword ptr [edx+38h], 1          ; ScriptSlots.field_18 = 1;
    inc     [ecx+UnitScriptingData.StartRunningNow]
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B092C:                             ; CODE XREF: UnitScriptingData_StartScript+8j
                                            ; UnitScriptingData_StartScript+10j
    pop     edi
    or      eax, 0FFFFFFFFh
    pop     esi
    retn    4
    UnitScriptingData_StartScript endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall InvokeScript(int FunctionName,int CompletedScriptMethodCallback,int RunNow)
    InvokeScript proc near                  ; CODE XREF: GameUnit_EndTransport+233p
                                            ; .text:0041148Dp ...

    MethodIndex= dword ptr -4
    FunctionName= dword ptr  4
    CompletedScriptMethodCallback= dword ptr  8
    RunNow= dword ptr  0Ch

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebp, ebp
    mov     [esp+14h+MethodIndex], edi
    mov     eax, [edi+8]
    mov     edx, [eax+4]
    test    edx, edx
    jle     short loc_4B0999
    mov     edi, [eax+1Ch]

    loc_4B095A:                             ; CODE XREF: InvokeScript+53j
    mov     esi, [edi]
    mov     eax, [esp+14h+FunctionName]

    loc_4B0960:                             ; CODE XREF: InvokeScript+3Ej
    mov     bl, [eax]
    mov     cl, bl                          ; MethodIndex
    cmp     bl, [esi]
    jnz     short loc_4B0984
    test    cl, cl
    jz      short loc_4B0980
    mov     bl, [eax+1]
    mov     cl, bl                          ; MethodIndex
    cmp     bl, [esi+1]
    jnz     short loc_4B0984
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4B0960

    loc_4B0980:                             ; CODE XREF: InvokeScript+2Aj
    xor     eax, eax
    jmp     short loc_4B0989
    ; ---------------------------------------------------------------------------

    loc_4B0984:                             ; CODE XREF: InvokeScript+26j
                                            ; InvokeScript+34j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4B0989:                             ; CODE XREF: InvokeScript+42j
    test    eax, eax
    jz      short loc_4B09FA
    inc     ebp
    add     edi, 4
    cmp     ebp, edx
    jl      short loc_4B095A
    mov     edi, [esp+14h+MethodIndex]

    loc_4B0999:                             ; CODE XREF: InvokeScript+15j
    or      eax, 0FFFFFFFFh

    loc_4B099C:                             ; CODE XREF: InvokeScript+C0j
    push    eax                             ; MethodIndex
    mov     ecx, edi                        ; MethodIndex
    call    UnitScriptingData_StartScript
    test    eax, eax
    jge     short loc_4B09B2
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B09B2:                             ; CODE XREF: InvokeScript+66j
    lea     ecx, [eax+eax*4]                ; int
    lea     edx, [eax+ecx*8]                ; int
    mov     eax, [esp+14h+CompletedScriptMethodCallback]
    mov     [edi+edx*4+UnitScriptingData.ScriptSlots.ScriptSlots.MethodReturnedCallBack], eax
    mov     eax, [esp+14h+RunNow]
    test    eax, eax
    jz      short loc_4B09ED
    mov     eax, [edi+UnitScriptingData.StartRunningNow]
    test    eax, eax
    jz      short loc_4B09E4
    xor     esi, esi

    loc_4B09D4:                             ; CODE XREF: InvokeScript+A2j
    push    0                               ; KeepProcessing
    push    esi                             ; ScriptNumber
    mov     ecx, edi                        ; int
    call    UnitScriptingData_COB_Handler
    inc     esi
    cmp     esi, 8
    jl      short loc_4B09D4

    loc_4B09E4:                             ; CODE XREF: InvokeScript+90j
    push    0
    mov     ecx, edi
    call    sub_4B1C00

    loc_4B09ED:                             ; CODE XREF: InvokeScript+86j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B09FA:                             ; CODE XREF: InvokeScript+4Bj
    mov     edi, [esp+14h+MethodIndex]
    mov     eax, ebp
    jmp     short loc_4B099C
    InvokeScript endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    edi
    mov     edi, ecx
    push    eax
    call    UnitScriptingData_StartScript
    test    eax, eax
    jge     short loc_4B0A27
    xor     eax, eax
    pop     edi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B0A27:                             ; CODE XREF: .text:004B0A1Fj
    lea     ecx, [eax+eax*4]
    lea     edx, [eax+ecx*8]
    mov     eax, [esp+0Ch]
    mov     [edi+edx*4+3Ch], eax
    mov     eax, [esp+10h]
    test    eax, eax
    jz      short loc_4B0A64
    mov     eax, [edi+53Ch]
    test    eax, eax
    jz      short loc_4B0A5B
    push    esi
    xor     esi, esi

    loc_4B0A4A:                             ; CODE XREF: .text:004B0A58j
    push    0
    push    esi
    mov     ecx, edi
    call    UnitScriptingData_COB_Handler
    inc     esi
    cmp     esi, 8
    jl      short loc_4B0A4A
    pop     esi

    loc_4B0A5B:                             ; CODE XREF: .text:004B0A45j
    push    0
    mov     ecx, edi
    call    sub_4B1C00

    loc_4B0A64:                             ; CODE XREF: .text:004B0A3Bj
    mov     eax, 1
    pop     edi
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0A70 proc near                    ; CODE XREF: .text:00406834p
                                            ; .text:004069BFp ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    push    ecx
    mov     eax, [ecx+8]
    push    ebx
    push    ebp
    xor     ebp, ebp
    mov     ebx, [eax+4]
    push    esi
    test    ebx, ebx
    push    edi
    mov     [esp+14h+var_4], ecx
    jle     short loc_4B0AC3
    mov     edi, [eax+1Ch]

    loc_4B0A88:                             ; CODE XREF: sub_4B0A70+51j
    mov     esi, [edi]
    mov     eax, [esp+14h+arg_0]

    loc_4B0A8E:                             ; CODE XREF: sub_4B0A70+3Cj
    mov     cl, [eax]
    mov     dl, cl
    cmp     cl, [esi]
    jnz     short loc_4B0AB2
    test    dl, dl
    jz      short loc_4B0AAE
    mov     cl, [eax+1]
    mov     dl, cl
    cmp     cl, [esi+1]
    jnz     short loc_4B0AB2
    add     eax, 2
    add     esi, 2
    test    dl, dl
    jnz     short loc_4B0A8E

    loc_4B0AAE:                             ; CODE XREF: sub_4B0A70+28j
    xor     eax, eax
    jmp     short loc_4B0AB7
    ; ---------------------------------------------------------------------------

    loc_4B0AB2:                             ; CODE XREF: sub_4B0A70+24j
                                            ; sub_4B0A70+32j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4B0AB7:                             ; CODE XREF: sub_4B0A70+40j
    test    eax, eax
    jz      short loc_4B0AFB
    inc     ebp
    add     edi, 4
    cmp     ebp, ebx
    jl      short loc_4B0A88

    loc_4B0AC3:                             ; CODE XREF: sub_4B0A70+13j
    or      eax, 0FFFFFFFFh

    loc_4B0AC6:                             ; CODE XREF: sub_4B0A70+8Dj
    mov     edx, [esp+14h+arg_1C]
    mov     ecx, [esp+14h+arg_18]
    push    edx
    mov     edx, [esp+18h+arg_14]
    push    ecx
    mov     ecx, [esp+1Ch+arg_10]
    push    edx
    mov     edx, [esp+20h+arg_C]
    push    ecx
    mov     ecx, [esp+24h+arg_8]
    push    edx
    mov     edx, [esp+28h+arg_4]
    push    ecx
    mov     ecx, [esp+2Ch+var_4]
    push    edx
    push    eax
    call    sub_4B0B00
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4B0AFB:                             ; CODE XREF: sub_4B0A70+49j
    mov     eax, ebp
    jmp     short loc_4B0AC6
    sub_4B0A70 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0B00 proc near                    ; CODE XREF: sub_438590+37p
                                            ; sub_4385F0+3Bp ...

    MethodIndex= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    mov     eax, [esp+MethodIndex]
    push    edi
    mov     edi, ecx
    push    eax                             ; MethodIndex
    call    UnitScriptingData_StartScript
    test    eax, eax
    jge     short loc_4B0B25
    mov     ecx, [esp+4+arg_4]              ; int
    test    ecx, ecx
    jz      short loc_4B0B1F
    mov     edx, [ecx]                      ; int
    push    0
    call    dword ptr [edx]

    loc_4B0B1F:                             ; CODE XREF: sub_4B0B00+17j
    xor     eax, eax
    pop     edi
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4B0B25:                             ; CODE XREF: sub_4B0B00+Fj
    lea     ecx, [eax+eax*4]                ; int
    push    esi
    lea     edx, [eax+ecx*8]                ; int
    mov     ecx, [esp+8+arg_4]              ; int
    lea     eax, [edi+edx*4]
    mov     edx, [esp+8+arg_10]             ; int
    mov     [eax+3Ch], ecx
    mov     ecx, [eax+24h]                  ; int
    inc     ecx
    mov     [eax+24h], ecx
    mov     [eax+ecx*4+40h], edx
    mov     esi, [eax+24h]
    mov     edx, [esp+8+arg_14]             ; int
    inc     esi
    mov     ecx, esi                        ; int
    mov     [eax+24h], esi
    mov     [eax+ecx*4+40h], edx
    mov     edx, [eax+24h]                  ; int
    inc     edx
    mov     [eax+24h], edx
    mov     ecx, edx                        ; int
    mov     edx, [esp+8+arg_18]             ; int
    mov     [eax+ecx*4+40h], edx
    mov     ecx, [eax+24h]                  ; int
    mov     edx, [esp+8+arg_1C]             ; int
    inc     ecx
    mov     [eax+24h], ecx
    mov     [eax+ecx*4+40h], edx
    mov     ecx, [esp+8+arg_C]              ; int
    dec     ecx
    mov     [eax+24h], ecx
    mov     eax, [esp+8+arg_8]
    test    eax, eax
    jz      short loc_4B0BAB
    mov     eax, [edi+53Ch]
    test    eax, eax
    jz      short loc_4B0BA2
    xor     esi, esi

    loc_4B0B92:                             ; CODE XREF: sub_4B0B00+A0j
    push    0                               ; KeepProcessing
    push    esi                             ; ScriptNumber
    mov     ecx, edi                        ; int
    call    UnitScriptingData_COB_Handler
    inc     esi
    cmp     esi, 8
    jl      short loc_4B0B92

    loc_4B0BA2:                             ; CODE XREF: sub_4B0B00+8Ej
    push    0
    mov     ecx, edi
    call    sub_4B1C00

    loc_4B0BAB:                             ; CODE XREF: sub_4B0B00+84j
    pop     esi
    mov     eax, 1
    pop     edi
    retn    20h
    sub_4B0B00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B0BC0(int,int,int,int,int)
    sub_4B0BC0 proc near                    ; CODE XREF: .text:004027FBp
                                            ; .text:004113B1p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    push    ecx
    mov     eax, [ecx+8]
    push    ebx
    push    ebp
    xor     ebp, ebp
    mov     ebx, [eax+4]
    push    esi
    test    ebx, ebx
    push    edi
    mov     [esp+14h+var_4], ecx
    jle     short loc_4B0C13
    mov     edi, [eax+1Ch]

    loc_4B0BD8:                             ; CODE XREF: sub_4B0BC0+51j
    mov     esi, [edi]
    mov     eax, [esp+14h+arg_0]

    loc_4B0BDE:                             ; CODE XREF: sub_4B0BC0+3Cj
    mov     cl, [eax]
    mov     dl, cl
    cmp     cl, [esi]
    jnz     short loc_4B0C02
    test    dl, dl
    jz      short loc_4B0BFE
    mov     cl, [eax+1]
    mov     dl, cl
    cmp     cl, [esi+1]
    jnz     short loc_4B0C02
    add     eax, 2
    add     esi, 2
    test    dl, dl
    jnz     short loc_4B0BDE

    loc_4B0BFE:                             ; CODE XREF: sub_4B0BC0+28j
    xor     eax, eax
    jmp     short loc_4B0C07
    ; ---------------------------------------------------------------------------

    loc_4B0C02:                             ; CODE XREF: sub_4B0BC0+24j
                                            ; sub_4B0BC0+32j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4B0C07:                             ; CODE XREF: sub_4B0BC0+40j
    test    eax, eax
    jz      short loc_4B0C3C
    inc     ebp
    add     edi, 4
    cmp     ebp, ebx
    jl      short loc_4B0BD8

    loc_4B0C13:                             ; CODE XREF: sub_4B0BC0+13j
    or      eax, 0FFFFFFFFh

    loc_4B0C16:                             ; CODE XREF: sub_4B0BC0+7Ej
    mov     edx, [esp+14h+arg_10]
    mov     ecx, [esp+14h+arg_C]
    push    edx
    mov     edx, [esp+18h+arg_8]
    push    ecx
    mov     ecx, [esp+1Ch+arg_4]
    push    edx
    push    ecx
    mov     ecx, [esp+24h+var_4]
    push    eax
    call    sub_4B0C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4B0C3C:                             ; CODE XREF: sub_4B0BC0+49j
    mov     eax, ebp
    jmp     short loc_4B0C16
    sub_4B0BC0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0C40 proc near                    ; CODE XREF: sub_4B0BC0+6Fp

    MethodIndex= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     eax, [esp+MethodIndex]
    push    edi
    mov     edi, ecx
    push    eax                             ; MethodIndex
    call    UnitScriptingData_StartScript
    test    eax, eax
    jge     short loc_4B0C57
    xor     eax, eax
    pop     edi
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4B0C57:                             ; CODE XREF: sub_4B0C40+Fj
    lea     ecx, [eax+eax*4]                ; int
    push    esi
    push    ebp
    mov     ebp, [esp+0Ch+arg_4]
    lea     edx, [eax+ecx*8]                ; int
    push    ebx
    test    ebp, ebp
    lea     esi, [edi+edx*4]
    mov     [esi+ScriptSlot.field_3C], 0
    jz      short loc_4B0C77
    mov     edx, [ebp+0]                    ; int
    jmp     short loc_4B0C79
    ; ---------------------------------------------------------------------------

    loc_4B0C77:                             ; CODE XREF: sub_4B0C40+30j
    xor     edx, edx                        ; int

    loc_4B0C79:                             ; CODE XREF: sub_4B0C40+35j
    mov     ebx, [esi+ScriptSlot.Stack]
    inc     ebx
    mov     ecx, ebx                        ; int
    mov     [esi+ScriptSlot.Stack], ebx
    mov     [esi+ecx*4+ScriptSlot.field_40], edx
    mov     ecx, [esp+10h+arg_8]            ; int
    test    ecx, ecx
    jz      short loc_4B0C92
    mov     edx, [ecx]                      ; int
    jmp     short loc_4B0C94
    ; ---------------------------------------------------------------------------

    loc_4B0C92:                             ; CODE XREF: sub_4B0C40+4Cj
    xor     edx, edx                        ; int

    loc_4B0C94:                             ; CODE XREF: sub_4B0C40+50j
    mov     ebx, [esi+ScriptSlot.Stack]
    inc     ebx
    mov     ecx, ebx                        ; int
    mov     [esi+ScriptSlot.Stack], ebx
    mov     [esi+ecx*4+ScriptSlot.field_40], edx
    mov     ecx, [esp+10h+arg_C]            ; int
    test    ecx, ecx
    jz      short loc_4B0CAD
    mov     edx, [ecx]                      ; int
    jmp     short loc_4B0CAF
    ; ---------------------------------------------------------------------------

    loc_4B0CAD:                             ; CODE XREF: sub_4B0C40+67j
    xor     edx, edx                        ; int

    loc_4B0CAF:                             ; CODE XREF: sub_4B0C40+6Bj
    mov     ebx, [esi+ScriptSlotArray.ScriptSlots.Stack]
    inc     ebx
    mov     [esi+ScriptSlot.Stack], ebx
    mov     ecx, ebx                        ; int
    mov     ebx, [esp+10h+arg_10]
    test    ebx, ebx
    mov     [esi+ecx*4+ScriptSlot.field_40], edx
    jz      short loc_4B0CC8
    mov     edx, [ebx]                      ; int
    jmp     short loc_4B0CCA
    ; ---------------------------------------------------------------------------

    loc_4B0CC8:                             ; CODE XREF: sub_4B0C40+82j
    xor     edx, edx                        ; int

    loc_4B0CCA:                             ; CODE XREF: sub_4B0C40+86j
    mov     ecx, [esi+ScriptSlot.Stack]     ; int
    push    0                               ; KeepProcessing
    inc     ecx
    push    eax                             ; ScriptNumber
    mov     [esi+ScriptSlot.Stack], ecx
    mov     [esi+ecx*4+ScriptSlot.field_40], edx
    mov     ecx, edi                        ; int
    mov     [esi+ScriptSlot.Stack], 3
    call    UnitScriptingData_COB_Handler
    test    ebp, ebp
    jz      short loc_4B0CF0
    mov     eax, [esi+ScriptSlot.field_40]
    mov     [ebp+0], eax

    loc_4B0CF0:                             ; CODE XREF: sub_4B0C40+A8j
    mov     eax, [esp+10h+arg_8]
    test    eax, eax
    jz      short loc_4B0CFD
    mov     ecx, [esi+44h]
    mov     [eax], ecx

    loc_4B0CFD:                             ; CODE XREF: sub_4B0C40+B6j
    mov     eax, [esp+10h+arg_C]
    test    eax, eax
    jz      short loc_4B0D0A
    mov     edx, [esi+48h]
    mov     [eax], edx

    loc_4B0D0A:                             ; CODE XREF: sub_4B0C40+C3j
    test    ebx, ebx
    jz      short loc_4B0D13
    mov     eax, [esi+4Ch]
    mov     [ebx], eax

    loc_4B0D13:                             ; CODE XREF: sub_4B0C40+CCj
    pop     ebx
    pop     ebp
    pop     esi
    mov     eax, 1
    pop     edi
    retn    14h
    sub_4B0C40 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [ecx+53Ch]
    test    eax, eax
    jz      short locret_4B0D54
    mov     edx, [esp+4]
    push    esi
    lea     eax, [ecx+3Ch]
    mov     ecx, 8
    mov     esi, 0FF000000h

    loc_4B0D3C:                             ; CODE XREF: .text:004B0D51j
    test    [eax-20h], esi
    jz      short loc_4B0D4B
    cmp     [eax], edx
    jnz     short loc_4B0D4B
    mov     dword ptr [eax], 0

    loc_4B0D4B:                             ; CODE XREF: .text:004B0D3Fj
                                            ; .text:004B0D43j
    add     eax, 0A4h
    dec     ecx
    jnz     short loc_4B0D3C
    pop     esi

    locret_4B0D54:                          ; CODE XREF: .text:004B0D28j
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B0D60 proc near                    ; CODE XREF: sub_48AD30+BBp

    KeepProcessing= dword ptr  8

    push    ebx
    mov     ebx, [esp+KeepProcessing]
    push    edi
    mov     edi, ecx
    mov     eax, [edi+53Ch]
    test    eax, eax
    jz      short loc_4B0D85
    push    esi
    xor     esi, esi

    loc_4B0D75:                             ; CODE XREF: sub_4B0D60+22j
    push    ebx                             ; KeepProcessing
    push    esi                             ; ScriptNumber
    mov     ecx, edi                        ; int
    call    UnitScriptingData_COB_Handler
    inc     esi
    cmp     esi, 8
    jl      short loc_4B0D75
    pop     esi

    loc_4B0D85:                             ; CODE XREF: sub_4B0D60+10j
    push    ebx
    mov     ecx, edi
    call    sub_4B1C00
    pop     edi
    pop     ebx
    retn    4
    sub_4B0D60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall UnitScriptingData_COB_Handler(int ScriptNumber,int KeepProcessing)
    UnitScriptingData_COB_Handler proc near ; CODE XREF: InvokeScript+99p
                                            ; .text:004B0A4Fp ...

    var_28= dword ptr -28h
    MethodIndex= dword ptr -20h
    ValuePushedOnStack= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    ScriptNumber= dword ptr  4
    KeepProcessing= dword ptr  8

    sub     esp, 20h                        ; esp -= 20h;
    push    ebx
    push    ebp
    mov     ebp, [esp+28h+ScriptNumber]     ; ebp = [esp+28h+arg_0];
    push    esi
    push    edi
    mov     edi, ecx                        ; edi = ecx;
    lea     eax, [ebp+ebp*4+0]              ; eax = &[ebp+ebp*4+0];
    lea     ecx, [ebp+eax*8+0]              ; ecx = &[ebp+eax*8+0];
    lea     esi, [edi+ecx*4+UnitScriptingData.ScriptSlots] ; esi = scriptingSlots[ScriptNumber]
    mov     ecx, [edi+ecx*4+UnitScriptingData.ScriptSlots.ScriptSlots.Flags] ; ecx = scriptingSlots[ScriptNumber].InUse
    mov     eax, ecx                        ; eax = ecx;
    and     eax, 0FF000000h                 ; Not to sure what the heck these flags do...
    jz      COB_Handler_exit
    cmp     eax, COB_RunningFlags_1
    jnz     short loc_4B0E3D                ; if (eax != 2000000h) goto loc_4B0E3D;
    and     ecx, 0F00000h
    cmp     ecx, COB_RunningFlags_2
    jz      short loc_4B0E1E                ; if (ecx == 100000h) goto loc_4B0E1E;
    cmp     ecx, COB_RunningFlags_3
    jz      short loc_4B0E03                ; if (ecx == 200000h) goto loc_4B0E03;
    cmp     ecx, COB_RunningFlags_4
    jnz     short loc_4B0E3D                ; if (ecx != 400000h) goto loc_4B0E3D;
    mov     edx, [esp+30h+KeepProcessing]   ; edx = [esp+30h+arg_4];
    mov     ecx, [esi+ScriptSlot.LoopsToWait] ; ecx = [esi+COB_Slot.field_C];
    sub     ecx, edx                        ; ecx -= edx;
    mov     eax, ecx                        ; eax = ecx;
    mov     [esi+ScriptSlot.LoopsToWait], ecx ; [esi+COB_Slot.field_C] = ecx;
    test    eax, eax
    jg      short loc_4B0E3D
    jmp     short loc_4B0E37                ; goto loc_4B0E37;
    ; ---------------------------------------------------------------------------

    loc_4B0E03:                             ; CODE XREF: UnitScriptingData_COB_Handler+45j
    mov     eax, [esi+ScriptSlot.field_10]  ; eax = [esi+COB_StackFrame.field_10];
    lea     ecx, [eax+eax*8]                ; ecx = &[eax+eax*8];
    lea     edx, [eax+ecx*2]                ; edx = &[eax+ecx*2];
    mov     eax, [esi+ScriptSlot.field_14]  ; eax = [esi+COB_StackFrame.field_14];
    mov     ecx, [edi+UnitScriptingData.field_14] ; ecx = [edi+14h];
    add     eax, edx                        ; eax += edx;
    mov     edx, [ecx+eax*4+10h]
    test    edx, edx
    jnz     short loc_4B0E3D                ; if (edx != 0) goto loc_4B0E3D;
    jmp     short loc_4B0E37                ; goto loc_4B0E37;
    ; ---------------------------------------------------------------------------

    loc_4B0E1E:                             ; CODE XREF: UnitScriptingData_COB_Handler+3Dj
    mov     eax, [esi+ScriptSlot.field_10]  ; eax = [esi+COB_StackFrame.field_10];
    mov     ecx, [esi+ScriptSlot.field_14]  ; ecx = [esi+COB_StackFrame.field_14];
    lea     edx, [eax+eax*8]                ; edx = &[eax+eax*8];
    lea     eax, [eax+edx*2]                ; eax = &[eax+edx*2];
    mov     edx, [edi+UnitScriptingData.field_14] ; edx = [edi+COB_StackFrame.field_14];
    add     ecx, eax                        ; ecx += eax;
    mov     eax, [edx+ecx*4+28h]            ; eax = [edx+ecx*4+28h];
    test    eax, eax
    jnz     short loc_4B0E3D                ; if (eax != 0) goto loc_4B0E3D;

    loc_4B0E37:                             ; CODE XREF: UnitScriptingData_COB_Handler+61j
                                            ; UnitScriptingData_COB_Handler+7Cj
    mov     [esi+ScriptSlot.Flags], COB_IsRunnable ; [esi+COB_StackFrame.field_0] = 1000000h;

    loc_4B0E3D:                             ; CODE XREF: UnitScriptingData_COB_Handler+2Fj
                                            ; UnitScriptingData_COB_Handler+4Dj ...
    mov     eax, [esi+ScriptSlot.Flags]     ; eax = [esi];
    and     eax, 0FF000000h
    cmp     eax, COB_IsRunnable
    jnz     COB_Handler_exit                ; if (eax != 1000000h) goto COB_Handler_exit;
    mov     [esp+30h+KeepProcessing], 1     ; [esp+30h+arg_4] = 1;
    jmp     short loc_4B0E5D                ; goto loc_4B0E5D;
    ; ---------------------------------------------------------------------------

    InstrLoop:                              ; CODE XREF: UnitScriptingData_COB_Handler+E42j
    mov     ebp, [esp+30h+ScriptNumber]     ; ebp = [esp+30h+arg_0];

    loc_4B0E5D:                             ; CODE XREF: UnitScriptingData_COB_Handler+B7j
    mov     edx, [edi+8]                    ; edx = [edi+8];
    mov     ecx, [esi+COB_StackFrame.field_0.InstrIndex] ; ecx = [esi+COB_StackFrame.InstrIndex];
    mov     eax, [edx+24h]                  ; eax = [edx+24h];
    mov     ebx, [eax+ecx*4]                ; ebx = [eax+ecx*4];
    mov     edx, ebx                        ; edx = ebx;
    and     edx, COB_ValidOPMask
    cmp     edx, COB_TurnPieceWithSpeed
    ja      loc_4B0FEC
    jz      COBHandler_TurnPieceWithSpeed
    cmp     edx, COB_MovePieceWithSpeed
    jnz     COB_UnknownInstr                ; if (edx != COB_MovePieceWithSpeed) goto COB_UnknownInstr;
    mov     ebx, [eax+ecx*4+4]              ; ebx = [eax+ecx*4+4];
    mov     ecx, [eax+ecx*4+8]              ; ecx = [eax+ecx*4+8];
    mov     eax, [esi+ScriptSlot.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ebp, ecx                        ; ebp = ecx;
    add     ebp, ebx                        ; ebp += ebx;
    push    ecx
    mov     edx, [esi+eax*4+ScriptSlot.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+ScriptSlot.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    lea     eax, [ebx+ebx*8]                ; eax = &[ebx+ebx*8];
    push    ebx
    mov     ecx, edi                        ; ecx = edi;
    lea     eax, [ebp+eax*2+0]              ; eax = &[ebp+eax*2+0];
    mov     ebp, [edi+14h]                  ; ebp = [edi+14h];
    mov     [esp+38h+var_18], eax           ; [esp+38h+var_18] = eax;
    lea     eax, ds:4[eax*4]                ; eax = &ds:4[eax*4];
    mov     [esp+38h+var_14], eax           ; [esp+38h+var_14] = eax;
    mov     [ebp+eax+0], edx                ; [ebp+eax+0] = edx;
    mov     edx, [esi+COB_StackFrame.field_0.StackIndex] ; edx = [esi+COB_StackFrame.StackIndex];
    mov     eax, [esi+edx*4+COB_StackFrame.field_0.Stack] ; eax = [esi+edx*4+COB_StackFrame.Stack];
    dec     edx                             ; edx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], edx ; [esi+COB_StackFrame.StackIndex] = edx;
    mov     edx, [esp+38h+var_18]           ; edx = [esp+38h+var_18];
    lea     ebp, ds:10h[edx*4]              ; ebp = &ds:10h[edx*4];
    cdq
    idiv    dword ptr [edi+4]
    mov     edx, [edi+14h]                  ; edx = [edi+14h];
    mov     [edx+ebp], eax                  ; [edx+ebp] = eax;
    mov     eax, [edi+14h]                  ; eax = [edi+14h];
    mov     edx, [edi]                      ; edx = [edi];
    mov     [esp+38h+MethodIndex], eax      ; [esp+38h+var_20] = eax;
    call    dword ptr [edx+14h]             ; dword ptr [edx+14h](ebx, ecx);
    mov     edx, [esp+30h+var_14]           ; edx = [esp+30h+var_14];
    mov     ecx, [esp+30h+MethodIndex]      ; ecx = [esp+30h+var_20];
    cmp     [edx+ecx], eax
    jge     short loc_4B0F0A
    mov     eax, [ebp+ecx+0]                ; eax = [ebp+ecx+0];
    neg     eax
    mov     [ebp+ecx+0], eax                ; [ebp+ecx+0] = eax;

    loc_4B0F0A:                             ; CODE XREF: UnitScriptingData_COB_Handler+15Ej
    mov     eax, [edi+14h]                  ; eax = [edi+14h];
    lea     ecx, [ebx+ebx*8]                ; ecx = &[ebx+ebx*8];
    lea     edx, [ebx+ecx*2]                ; edx = &[ebx+ecx*2];
    mov     dword ptr [eax+edx*4], 1        ; dword ptr [eax+edx*4] = 1;
    mov     dword ptr [edi+18h], 1          ; dword ptr [edi+18h] = 1;
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 3                          ; eax += 3;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_TurnPieceWithSpeed:          ; CODE XREF: UnitScriptingData_COB_Handler+DDj
    mov     edx, [esi+COB_StackFrame.field_0.StackIndex] ; edx = [esi+COB_StackFrame.StackIndex];
    mov     ebx, [eax+ecx*4+4]              ; ebx = [eax+ecx*4+4];
    mov     ecx, [eax+ecx*4+8]              ; ecx = [eax+ecx*4+8];
    mov     eax, [esi+edx*4+COB_StackFrame.field_0.Stack] ; eax = [esi+edx*4+COB_StackFrame.Stack];
    dec     edx                             ; edx--;
    mov     [esp+30h+var_14], ecx           ; [esp+30h+var_14] = ecx;
    mov     [esi+COB_StackFrame.field_0.StackIndex], edx ; [esi+COB_StackFrame.StackIndex] = edx;
    lea     edx, [ebx+ebx*8]                ; edx = &[ebx+ebx*8];
    add     ecx, ebx                        ; ecx += ebx;
    and     eax, 0FFFFh
    lea     edx, [ecx+edx*2]                ; edx = &[ecx+edx*2];
    mov     ecx, [edi+14h]                  ; ecx = [edi+14h];
    lea     ebp, ds:1Ch[edx*4]              ; ebp = &ds:1Ch[edx*4];
    mov     [ecx+ebp], eax                  ; [ecx+ebp] = eax;
    mov     eax, [edi+14h]                  ; eax = [edi+14h];
    mov     dword ptr [eax+edx*4+40h], 0    ; dword ptr [eax+edx*4+40h] = 0;
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    mov     eax, [esi+ecx*4+COB_StackFrame.field_0.Stack] ; eax = [esi+ecx*4+COB_StackFrame.Stack];
    dec     ecx                             ; ecx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    lea     ecx, ds:28h[edx*4]              ; ecx = &ds:28h[edx*4];
    cdq
    idiv    dword ptr [edi+4]
    mov     edx, [edi+14h]                  ; edx = [edi+14h];
    mov     [esp+30h+var_18], ecx           ; [esp+30h+var_18] = ecx;
    mov     [edx+ecx], eax                  ; [edx+ecx] = eax;
    mov     eax, [edi+14h]                  ; eax = [edi+14h];
    mov     edx, [edi]                      ; edx = [edi];
    mov     [esp+30h+MethodIndex], eax      ; [esp+30h+var_20] = eax;
    mov     eax, [esp+30h+var_14]           ; eax = [esp+30h+var_14];
    mov     ecx, edi                        ; ecx = edi;
    push    eax
    push    ebx
    call    dword ptr [edx+18h]             ; dword ptr [edx+18h](ebx, eax);
    mov     ecx, [esp+30h+MethodIndex]      ; ecx = [esp+30h+var_20];
    mov     ebp, [ebp+ecx+0]                ; ebp = [ebp+ecx+0];
    sub     ebp, eax                        ; ebp -= eax;
    jnz     short loc_4B0FBA
    mov     edx, [esp+30h+var_18]           ; edx = [esp+30h+var_18];
    mov     eax, ecx                        ; eax = ecx;
    mov     dword ptr [edx+eax], 0          ; dword ptr [edx+eax] = 0;
    jmp     loc_4B1064                      ; goto loc_4B1064;
    ; ---------------------------------------------------------------------------

    loc_4B0FBA:                             ; CODE XREF: UnitScriptingData_COB_Handler+206j
    mov     eax, ebp                        ; eax = ebp;
    xor     ecx, ecx                        ; ecx = 0;
    cdq
    xor     eax, edx                        ; eax ^= edx;
    sub     eax, edx                        ; eax -= edx;
    cmp     eax, 8000h
    setnle  cl
    xor     edx, edx                        ; edx = 0;
    test    ebp, ebp
    setl    dl
    xor     ecx, edx                        ; ecx ^= edx;
    jz      loc_4B1064
    mov     eax, [esp+30h+var_18]           ; eax = [esp+30h+var_18];
    mov     ecx, [esp+30h+MethodIndex]      ; ecx = [esp+30h+var_20];
    mov     edx, [eax+ecx]                  ; edx = [eax+ecx];
    neg     edx
    mov     [eax+ecx], edx                  ; [eax+ecx] = edx;
    jmp     short loc_4B1064                ; goto loc_4B1064;
    ; ---------------------------------------------------------------------------

    loc_4B0FEC:                             ; CODE XREF: UnitScriptingData_COB_Handler+D7j
    cmp     edx, COB_StopSpin
    ja      loc_4B10D3
    jz      COBHandler_StopSpin
    cmp     edx, COB_StartSpin
    jnz     COB_UnknownInstr                ; if (edx != COB_StartSpin) goto COB_UnknownInstr;
    mov     ebx, [eax+ecx*4+4]              ; ebx = [eax+ecx*4+4];
    mov     ecx, [eax+ecx*4+8]              ; ecx = [eax+ecx*4+8];
    mov     edx, [edi+14h]                  ; edx = [edi+14h];
    add     ecx, ebx                        ; ecx += ebx;
    lea     eax, [ebx+ebx*8]                ; eax = &[ebx+ebx*8];
    lea     ecx, [ecx+eax*2]                ; ecx = &[ecx+eax*2];
    mov     dword ptr [edx+ecx*4+1Ch], 0FFFFFFFFh ; dword ptr [edx+ecx*4+1Ch] = 0FFFFFFFFh;
    mov     edx, [esi+COB_StackFrame.field_0.StackIndex] ; edx = [esi+COB_StackFrame.StackIndex];
    mov     eax, [esi+edx*4+COB_StackFrame.field_0.Stack] ; eax = [esi+edx*4+COB_StackFrame.Stack];
    dec     edx                             ; edx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], edx ; [esi+COB_StackFrame.StackIndex] = edx;
    cdq
    idiv    dword ptr [edi+4]
    mov     edx, [edi+14h]                  ; edx = [edi+14h];
    mov     [edx+ecx*4+34h], eax            ; [edx+ecx*4+34h] = eax;
    mov     edx, [esi+COB_StackFrame.field_0.StackIndex] ; edx = [esi+COB_StackFrame.StackIndex];
    mov     eax, [esi+edx*4+COB_StackFrame.field_0.Stack] ; eax = [esi+edx*4+COB_StackFrame.Stack];
    dec     edx                             ; edx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], edx ; [esi+COB_StackFrame.StackIndex] = edx;
    cdq
    idiv    dword ptr [edi+4]
    mov     edx, [edi+14h]                  ; edx = [edi+14h];
    mov     [edx+ecx*4+40h], eax            ; [edx+ecx*4+40h] = eax;
    mov     eax, [edi+14h]                  ; eax = [edi+14h];
    mov     edx, [eax+ecx*4+40h]            ; edx = [eax+ecx*4+40h];
    test    edx, edx
    jnz     short loc_4B1064                ; if (edx != 0) goto loc_4B1064;
    mov     edx, [eax+ecx*4+34h]            ; edx = [eax+ecx*4+34h];
    mov     [eax+ecx*4+28h], edx            ; [eax+ecx*4+28h] = edx;

    loc_4B1064:                             ; CODE XREF: UnitScriptingData_COB_Handler+215j
                                            ; UnitScriptingData_COB_Handler+234j ...
    mov     edx, [edi+14h]                  ; edx = [edi+14h];
    lea     eax, [ebx+ebx*8]                ; eax = &[ebx+ebx*8];
    lea     ecx, [ebx+eax*2]                ; ecx = &[ebx+eax*2];
    mov     dword ptr [edx+ecx*4], 1        ; dword ptr [edx+ecx*4] = 1;
    mov     dword ptr [edi+18h], 1          ; dword ptr [edi+18h] = 1;
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 3                          ; eax += 3;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_StopSpin:                    ; CODE XREF: UnitScriptingData_COB_Handler+258j
    mov     edx, [eax+ecx*4+4]              ; edx = [eax+ecx*4+4];
    mov     eax, [eax+ecx*4+8]              ; eax = [eax+ecx*4+8];
    add     eax, edx                        ; eax += edx;
    xor     ebx, ebx                        ; ebx = 0;
    lea     ecx, [edx+edx*8]                ; ecx = &[edx+edx*8];
    mov     edx, [edi+14h]                  ; edx = [edi+14h];
    lea     ecx, [eax+ecx*2]                ; ecx = &[eax+ecx*2];
    mov     [edx+ecx*4+34h], ebx            ; [edx+ecx*4+34h] = ebx;
    mov     edx, [esi+COB_StackFrame.field_0.StackIndex] ; edx = [esi+COB_StackFrame.StackIndex];
    mov     eax, [esi+edx*4+COB_StackFrame.field_0.Stack] ; eax = [esi+edx*4+COB_StackFrame.Stack];
    dec     edx                             ; edx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], edx ; [esi+COB_StackFrame.StackIndex] = edx;
    cdq
    idiv    dword ptr [edi+4]
    mov     edx, [edi+14h]                  ; edx = [edi+14h];
    neg     eax
    mov     [edx+ecx*4+40h], eax            ; [edx+ecx*4+40h] = eax;
    mov     eax, [edi+14h]                  ; eax = [edi+14h];
    cmp     [eax+ecx*4+40h], ebx
    jnz     loc_4B18F8                      ; if ([eax+ecx*4+40h] != ebx) goto loc_4B18F8;
    mov     [eax+ecx*4+28h], ebx            ; [eax+ecx*4+28h] = ebx;
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 3                          ; eax += 3;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B10D3:                             ; CODE XREF: UnitScriptingData_COB_Handler+252j
    cmp     edx, COB_HidePiece
    ja      short loc_4B1108
    jz      short COBHandler_HidePiece
    cmp     edx, COB_ShowPiece
    jnz     COB_UnknownInstr                ; if (edx != COB_ShowPiece) goto COB_UnknownInstr;
    mov     edx, [edi]                      ; edx = [edi];
    push    1
    jmp     short loc_4B10F3                ; goto loc_4B10F3;
    ; ---------------------------------------------------------------------------

    COBHandler_HidePiece:                   ; CODE XREF: UnitScriptingData_COB_Handler+33Bj
    mov     edx, [edi]                      ; edx = [edi];
    push    0

    loc_4B10F3:                             ; CODE XREF: UnitScriptingData_COB_Handler+34Dj
    mov     eax, [eax+ecx*4+4]              ; eax = [eax+ecx*4+4];
    mov     ecx, edi                        ; ecx = edi;
    push    eax
    call    dword ptr [edx+8]               ; dword ptr [edx+8](eax, 0);
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1108:                             ; CODE XREF: UnitScriptingData_COB_Handler+339j
    cmp     edx, COB_DontCachePiece
    ja      short loc_4B113D
    jz      short COBHandler_DontCachePiece
    cmp     edx, COB_CachePiece
    jnz     COB_UnknownInstr                ; if (edx != COB_CachePiece) goto COB_UnknownInstr;
    mov     edx, [edi]                      ; edx = [edi];
    push    1
    jmp     short loc_4B1128                ; goto loc_4B1128;
    ; ---------------------------------------------------------------------------

    COBHandler_DontCachePiece:              ; CODE XREF: UnitScriptingData_COB_Handler+370j
    mov     edx, [edi]                      ; edx = [edi];
    push    0

    loc_4B1128:                             ; CODE XREF: UnitScriptingData_COB_Handler+382j
    mov     eax, [eax+ecx*4+4]              ; eax = [eax+ecx*4+4];
    mov     ecx, edi                        ; ecx = edi;
    push    eax
    call    dword ptr [edx+0Ch]             ; dword ptr [edx+0Ch](eax, 0);
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B113D:                             ; CODE XREF: UnitScriptingData_COB_Handler+36Ej
    cmp     edx, COB_DontShadow
    ja      short loc_4B119C
    jz      short COBHandler_DontShadow
    cmp     edx, COB_Unknown4
    jnz     COB_UnknownInstr                ; if (edx != COB_Unknown4) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    push    edx
    mov     ebx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     edx, [edi+8]                    ; edx = [edi+8];
    mov     eax, [edi]                      ; eax = [edi];
    push    ebx
    mov     edx, [edx+24h]                  ; edx = [edx+24h];
    mov     ecx, [edx+ecx*4+4]              ; ecx = [edx+ecx*4+4];
    push    ecx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [eax+28h]             ; dword ptr [eax+28h]();
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_DontShadow:                  ; CODE XREF: UnitScriptingData_COB_Handler+3A5j
    mov     eax, [eax+ecx*4+4]              ; eax = [eax+ecx*4+4];
    mov     edx, [edi]                      ; edx = [edi];
    push    eax
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [edx+2Ch]             ; dword ptr [edx+2Ch](eax);
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B119C:                             ; CODE XREF: UnitScriptingData_COB_Handler+3A3j
    cmp     edx, COB_TurnPieceNow
    ja      loc_4B1272
    jz      short COBHandler_TurnPieceNow
    cmp     edx, COB_MovePieceNow
    jnz     COB_UnknownInstr                ; if (edx != COB_MovePieceNow) goto COB_UnknownInstr;
    mov     edx, [eax+ecx*4+4]              ; edx = [eax+ecx*4+4];
    mov     eax, [eax+ecx*4+8]              ; eax = [eax+ecx*4+8];
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    mov     ebp, eax                        ; ebp = eax;
    add     ebp, edx                        ; ebp += edx;
    mov     ebx, [esi+ecx*4+24h]            ; ebx = [esi+ecx*4+24h];
    dec     ecx                             ; ecx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    lea     ecx, [edx+edx*8]                ; ecx = &[edx+edx*8];
    lea     ecx, [ebp+ecx*2+0]              ; ecx = &[ebp+ecx*2+0];
    mov     ebp, [edi+14h]                  ; ebp = [edi+14h];
    mov     [esp+30h+var_14], ecx           ; [esp+30h+var_14] = ecx;
    lea     ecx, ds:4[ecx*4]                ; ecx = &ds:4[ecx*4];
    mov     [ebp+ecx+0], ebx                ; [ebp+ecx+0] = ebx;
    mov     ebx, [edi+14h]                  ; ebx = [edi+14h];
    mov     ebp, [esp+30h+var_14]           ; ebp = [esp+30h+var_14];
    mov     dword ptr [ebx+ebp*4+10h], 0    ; dword ptr [ebx+ebp*4+10h] = 0;
    mov     ebp, [edi+14h]                  ; ebp = [edi+14h];
    mov     ebx, [edi]                      ; ebx = [edi];
    mov     ecx, [ebp+ecx+0]                ; ecx = [ebp+ecx+0];
    push    ecx
    push    eax
    push    edx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [ebx]                 ; dword ptr [ebx]();
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 3                          ; eax += 3;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_TurnPieceNow:                ; CODE XREF: UnitScriptingData_COB_Handler+408j
    mov     edx, [eax+ecx*4+4]              ; edx = [eax+ecx*4+4];
    mov     eax, [eax+ecx*4+8]              ; eax = [eax+ecx*4+8];
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    mov     [esp+30h+var_14], eax           ; [esp+30h+var_14] = eax;
    add     eax, edx                        ; eax += edx;
    mov     ebx, [esi+ecx*4+COB_StackFrame.field_0.Stack] ; ebx = [esi+ecx*4+COB_StackFrame.Stack];
    dec     ecx                             ; ecx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    mov     ebp, [edi+14h]                  ; ebp = [edi+14h];
    lea     ecx, [edx+edx*8]                ; ecx = &[edx+edx*8];
    and     ebx, 0FFFFh
    lea     eax, [eax+ecx*2]                ; eax = &[eax+ecx*2];
    lea     ecx, ds:1Ch[eax*4]              ; ecx = &ds:1Ch[eax*4];
    mov     [ebp+ecx+0], ebx                ; [ebp+ecx+0] = ebx;
    mov     ebp, [edi+14h]                  ; ebp = [edi+14h];
    xor     ebx, ebx                        ; ebx = 0;
    mov     [ebp+eax*4+40h], ebx            ; [ebp+eax*4+40h] = ebx;
    mov     ebp, [edi+14h]                  ; ebp = [edi+14h];
    mov     [ebp+eax*4+28h], ebx            ; [ebp+eax*4+28h] = ebx;
    mov     ebx, [edi+14h]                  ; ebx = [edi+14h];
    mov     eax, [edi]                      ; eax = [edi];
    mov     ecx, [ebx+ecx]                  ; ecx = [ebx+ecx];
    push    ecx
    mov     ecx, [esp+34h+var_14]           ; ecx = [esp+34h+var_14];
    push    ecx
    push    edx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [eax+4]               ; dword ptr [eax+4]();
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 3                          ; eax += 3;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1272:                             ; CODE XREF: UnitScriptingData_COB_Handler+402j
    cmp     edx, COB_DontShade
    ja      short loc_4B12A7
    jz      short COBHandler_DontShade
    cmp     edx, COB_Shade
    jnz     COB_UnknownInstr                ; if (edx != COB_Shade) goto COB_UnknownInstr;
    mov     edx, [edi]                      ; edx = [edi];
    push    1
    jmp     short loc_4B1292                ; goto loc_4B1292;
    ; ---------------------------------------------------------------------------

    COBHandler_DontShade:                   ; CODE XREF: UnitScriptingData_COB_Handler+4DAj
    mov     edx, [edi]                      ; edx = [edi];
    push    0

    loc_4B1292:                             ; CODE XREF: UnitScriptingData_COB_Handler+4ECj
    mov     eax, [eax+ecx*4+4]              ; eax = [eax+ecx*4+4];
    mov     ecx, edi                        ; ecx = edi;
    push    eax
    call    dword ptr [edx+10h]             ; dword ptr [edx+10h](eax, 0);
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B12A7:                             ; CODE XREF: UnitScriptingData_COB_Handler+4D8j
    cmp     edx, COB_WaitForTurn
    ja      short loc_4B130D
    jz      short COBHandler_WaitForTurn
    cmp     edx, COB_EmitSfx
    jnz     COB_UnknownInstr                ; if (edx != COB_EmitSfx) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    push    edx
    mov     edx, [edi+8]                    ; edx = [edi+8];
    mov     eax, [edi]                      ; eax = [edi];
    mov     edx, [edx+24h]                  ; edx = [edx+24h];
    mov     ecx, [edx+ecx*4+4]              ; ecx = [edx+ecx*4+4];
    push    ecx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [eax+30h]             ; dword ptr [eax+30h](ecx, edx);
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_WaitForTurn:                 ; CODE XREF: UnitScriptingData_COB_Handler+50Fj
    mov     edx, [eax+ecx*4+4]              ; edx = [eax+ecx*4+4];
    mov     eax, [eax+ecx*4+8]              ; eax = [eax+ecx*4+8];
    add     ecx, 3                          ; ecx += 3;
    mov     [esi+COB_StackFrame.field_0.Flags], 2100000h ; [esi+COB_StackFrame.field_0] = 2100000h;
    mov     [esi+COB_StackFrame.field_0.field_14], eax ; [esi+COB_StackFrame.field_14] = eax;
    mov     [esi+COB_StackFrame.field_0.field_10], edx ; [esi+COB_StackFrame.field_10] = edx;
    mov     [esi+COB_StackFrame.field_0.InstrIndex], ecx ; [esi+COB_StackFrame.InstrIndex] = ecx;
    mov     [esp+30h+KeepProcessing], 0     ; [esp+30h+arg_4] = 0;
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    loc_4B130D:                             ; CODE XREF: UnitScriptingData_COB_Handler+50Dj
    cmp     edx, COB_Sleep
    ja      short loc_4B1386
    jz      short COBHandler_Sleep
    cmp     edx, COB_WaitForMove
    jnz     COB_UnknownInstr                ; if (edx != COB_WaitForMove) goto COB_UnknownInstr;
    mov     edx, [eax+ecx*4+4]              ; edx = [eax+ecx*4+4];
    mov     eax, [eax+ecx*4+8]              ; eax = [eax+ecx*4+8];
    add     ecx, 3                          ; ecx += 3;
    mov     [esi+COB_StackFrame.field_0.Flags], 2200000h ; [esi+COB_StackFrame.field_0] = 2200000h;
    mov     [esi+COB_StackFrame.field_0.field_14], eax ; [esi+COB_StackFrame.field_14] = eax;
    mov     [esi+COB_StackFrame.field_0.field_10], edx ; [esi+COB_StackFrame.field_10] = edx;
    mov     [esp+30h+KeepProcessing], 0     ; [esp+30h+arg_4] = 0;
    mov     [esi+COB_StackFrame.field_0.InstrIndex], ecx ; [esi+COB_StackFrame.InstrIndex] = ecx;
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    COBHandler_Sleep:                       ; CODE XREF: UnitScriptingData_COB_Handler+575j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     [esi+COB_StackFrame.field_0.Flags], 2400000h ; [esi+COB_StackFrame.field_0] = 2400000h;
    mov     [esp+30h+KeepProcessing], 0     ; [esp+30h+arg_4] = 0;
    mov     ebx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     edx, [edi+4]                    ; edx = [edi+4];
    imul    edx, ebx
    mov     eax, 10624DD3h                  ; eax = 10624DD3h;
    imul    edx
    sar     edx, 6
    mov     eax, edx                        ; eax = edx;
    shr     eax, 1Fh
    add     edx, eax                        ; edx += eax;
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.LoopsToWait], edx ; [esi+COB_StackFrame.field_C] = edx;
    mov     [esi+COB_StackFrame.field_0.InstrIndex], ecx ; [esi+COB_StackFrame.InstrIndex] = ecx;
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    loc_4B1386:                             ; CODE XREF: UnitScriptingData_COB_Handler+573j
    cmp     edx, COB_StackAllocate
    ja      short loc_4B13F8
    jz      short COBHandle_StackAllocate
    cmp     edx, COB_MetaPush
    jnz     COB_UnknownInstr                ; if (edx != COB_MetaPush) goto COB_UnknownInstr;
    and     ebx, 7
    dec     ebx                             ; ebx--;
    jz      short CobHandler_PushConstant
    dec     ebx                             ; ebx--;
    jz      short CobHandler_PushLocalVar
    sub     ebx, 2                          ; ebx -= 2;
    jnz     short COB_MetaPush_ukn
    mov     ecx, [eax+ecx*4+4]              ; ecx = [eax+ecx*4+4];
    mov     edx, [edi+10h]                  ; edx = [edi+10h];
    mov     eax, [edx+ecx*4]                ; eax = [edx+ecx*4];
    jmp     short loc_4B13C8                ; goto loc_4B13C8;
    ; ---------------------------------------------------------------------------

    CobHandler_PushLocalVar:                ; CODE XREF: UnitScriptingData_COB_Handler+603j
    mov     ecx, [eax+ecx*4+4]              ; ecx = [eax+ecx*4+4];
    mov     edx, [esi+ecx*4+COB_StackFrame.field_0.Stack] ; edx = [esi+ecx*4+COB_StackFrame.Stack];
    mov     [esp+30h+ValuePushedOnStack], edx ; [esp+30h+ValuePushedOnStack] = edx;
    jmp     short COB_MetaPush_ukn          ; goto COB_MetaPush_ukn;
    ; ---------------------------------------------------------------------------

    CobHandler_PushConstant:                ; CODE XREF: UnitScriptingData_COB_Handler+600j
    mov     eax, [eax+ecx*4+4]              ; eax = [eax+ecx*4+4];

    loc_4B13C8:                             ; CODE XREF: UnitScriptingData_COB_Handler+614j
    mov     [esp+30h+ValuePushedOnStack], eax ; [esp+30h+ValuePushedOnStack] = eax;

    COB_MetaPush_ukn:                       ; CODE XREF: UnitScriptingData_COB_Handler+608j
                                            ; UnitScriptingData_COB_Handler+622j
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    mov     eax, ecx                        ; eax = ecx;
    mov     ecx, [esp+30h+ValuePushedOnStack] ; ecx = [esp+30h+ValuePushedOnStack];
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandle_StackAllocate:                ; CODE XREF: UnitScriptingData_COB_Handler+5EEj
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    inc     eax                             ; eax++;
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     [esi+COB_StackFrame.field_0.InstrIndex], ecx ; [esi+COB_StackFrame.InstrIndex] = ecx;
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    loc_4B13F8:                             ; CODE XREF: UnitScriptingData_COB_Handler+5ECj
    cmp     edx, COB_PopStack
    ja      short loc_4B1479
    jz      short COBHandler_PopStack
    cmp     edx, COB_MetaPop
    jnz     COB_UnknownInstr                ; if (edx != COB_MetaPop) goto COB_UnknownInstr;
    and     ebx, 7
    sub     ebx, 2                          ; ebx -= 2;
    jz      short CobHandler_SetLocalVar
    sub     ebx, 2                          ; ebx -= 2;
    jnz     IncInstrIndex2
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     eax, [edi+8]                    ; eax = [edi+8];
    mov     eax, [eax+24h]                  ; eax = [eax+24h];
    mov     ecx, [eax+ecx*4+4]              ; ecx = [eax+ecx*4+4];
    mov     eax, [edi+10h]                  ; eax = [edi+10h];
    mov     [eax+ecx*4], edx                ; [eax+ecx*4] = edx;
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    CobHandler_SetLocalVar:                 ; CODE XREF: UnitScriptingData_COB_Handler+674j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     eax, [edi+8]                    ; eax = [edi+8];
    mov     eax, [eax+24h]                  ; eax = [eax+24h];
    mov     ecx, [eax+ecx*4+4]              ; ecx = [eax+ecx*4+4];
    mov     [esi+ecx*4+COB_StackFrame.field_0.Stack], edx ; [esi+ecx*4+COB_StackFrame.Stack] = edx;
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_PopStack:                    ; CODE XREF: UnitScriptingData_COB_Handler+660j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    dec     eax                             ; eax--;
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     [esi+COB_StackFrame.field_0.InstrIndex], ecx ; [esi+COB_StackFrame.InstrIndex] = ecx;
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    loc_4B1479:                             ; CODE XREF: UnitScriptingData_COB_Handler+65Ej
    cmp     edx, COB_Subtract
    ja      short loc_4B14C9
    jz      short COBHandler_Subtract
    cmp     edx, COB_Add
    jnz     COB_UnknownInstr                ; if (edx != COB_Add) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    add     edx, ecx                        ; edx += ecx;
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], edx ; [esi+eax*4+COB_StackFrame.Stack] = edx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_Subtract:                    ; CODE XREF: UnitScriptingData_COB_Handler+6E1j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    sub     ecx, edx                        ; ecx -= edx;
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B14C9:                             ; CODE XREF: UnitScriptingData_COB_Handler+6DFj
    cmp     edx, COB_Divide
    ja      short loc_4B151B
    jz      short COBHandler_Divide
    cmp     edx, COB_Multiply
    jnz     COB_UnknownInstr                ; if (edx != COB_Multiply) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    imul    ecx, edx
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_Divide:                      ; CODE XREF: UnitScriptingData_COB_Handler+731j
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    mov     ebx, [esi+ecx*4+COB_StackFrame.field_0.Stack] ; ebx = [esi+ecx*4+COB_StackFrame.Stack];
    dec     ecx                             ; ecx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    mov     eax, [esi+ecx*4+COB_StackFrame.field_0.Stack] ; eax = [esi+ecx*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    cdq
    idiv    ebx
    mov     [esi+ecx*4+COB_StackFrame.field_0.Stack], eax ; [esi+ecx*4+COB_StackFrame.Stack] = eax;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B151B:                             ; CODE XREF: UnitScriptingData_COB_Handler+72Fj
    cmp     edx, COB_BitwiseOr
    ja      short loc_4B156B
    jz      short COBHandler_BitwiseOr
    cmp     edx, COB_BitwiseAnd
    jnz     COB_UnknownInstr                ; if (edx != COB_BitwiseAnd) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    and     ecx, edx
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_BitwiseOr:                   ; CODE XREF: UnitScriptingData_COB_Handler+783j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    or      ecx, edx
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B156B:                             ; CODE XREF: UnitScriptingData_COB_Handler+781j
    cmp     edx, COB_BitwiseNot
    ja      short loc_4B15B3
    jz      short COBHandler_BitwiseNot
    cmp     edx, COB_BitwiseXor
    jnz     COB_UnknownInstr                ; if (edx != COB_BitwiseXor) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    xor     ecx, edx                        ; ecx ^= edx;
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_BitwiseNot:                  ; CODE XREF: UnitScriptingData_COB_Handler+7D3j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    not     ecx
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B15B3:                             ; CODE XREF: UnitScriptingData_COB_Handler+7D1j
    cmp     edx, COB_GetUnitValue
    ja      short loc_4B1622
    jz      short COBHandle_GetUnitValue
    cmp     edx, COB_Random                 ; if (CurrentInstr == COB_Random)
                                            ; {
                                            ; int HighValue = PopStack();
                                            ; int LowValue = PopStack();
                                            ; int randomNumber = LowValue+GetRandom(HighValue-LowValue+1);
                                            ; PushStack( randomNumber );
                                            ; }
    jnz     COB_UnknownInstr                ; if (edx != COB_Random) goto COB_UnknownInstr;
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    mov     eax, [esi+ecx*4+COB_StackFrame.field_0.Stack] ; eax = [esi+ecx*4+COB_StackFrame.Stack];
    dec     ecx                             ; ecx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    mov     ebx, [esi+ecx*4+COB_StackFrame.field_0.Stack] ; ebx = [esi+ecx*4+COB_StackFrame.Stack];
    dec     ecx                             ; ecx--;
    sub     eax, ebx                        ; eax -= ebx;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    inc     eax                             ; eax++;
    push    eax
    call    GetRandom                       ; GetRandom(eax);
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    add     eax, ebx                        ; eax += ebx;
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    mov     [esi+ecx*4+COB_StackFrame.field_0.Stack], eax ; [esi+ecx*4+COB_StackFrame.Stack] = eax;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandle_GetUnitValue:                 ; CODE XREF: UnitScriptingData_COB_Handler+81Bj
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    push    0
    push    0
    push    0
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     edx, [edi]                      ; edx = [edi];
    push    0
    push    ecx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [edx+44h]             ; dword ptr [edx+44h]();
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    mov     [esi+ecx*4+COB_StackFrame.field_0.Stack], eax ; [esi+ecx*4+COB_StackFrame.Stack] = eax;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1622:                             ; CODE XREF: UnitScriptingData_COB_Handler+819j
    cmp     edx, COB_Unknown11
    ja      loc_4B16AE
    jz      short loc_4B168B
    cmp     edx, COB_GetFunctionResult
    jnz     COB_UnknownInstr                ; if (edx != COB_GetFunctionResult) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    push    ecx
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    push    edx
    mov     ebx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    push    ebx
    mov     ebp, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebp = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esp+3Ch+var_14], ebp           ; [esp+3Ch+var_14] = ebp;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ebp, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebp = [esi+eax*4+COB_StackFrame.Stack];
    mov     ecx, [esp+3Ch+var_14]           ; ecx = [esp+3Ch+var_14];
    dec     eax                             ; eax--;
    push    ecx
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     eax, [edi]                      ; eax = [edi];
    push    ebp
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [eax+44h]             ; dword ptr [eax+44h]();
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    mov     [esi+ecx*4+COB_StackFrame.field_0.Stack], eax ; [esi+ecx*4+COB_StackFrame.Stack] = eax;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B168B:                             ; CODE XREF: UnitScriptingData_COB_Handler+88Ej
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     edx, [edi]                      ; edx = [edi];
    push    ecx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [edx+48h]             ; dword ptr [edx+48h](ecx);
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    mov     [esi+ecx*4+COB_StackFrame.field_0.Stack], eax ; [esi+ecx*4+COB_StackFrame.Stack] = eax;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B16AE:                             ; CODE XREF: UnitScriptingData_COB_Handler+888j
    cmp     edx, COB_LessThan
    ja      short loc_4B16FD
    jz      short loc_4B16DB
    cmp     edx, COB_Unknown12
    jnz     COB_UnknownInstr                ; if (edx != COB_Unknown12) goto COB_UnknownInstr;
    mov     eax, [edi]                      ; eax = [edi];
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [eax+4Ch]             ; dword ptr [eax+4Ch]();
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    mov     [esi+ecx*4+COB_StackFrame.field_0.Stack], eax ; [esi+ecx*4+COB_StackFrame.Stack] = eax;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B16DB:                             ; CODE XREF: UnitScriptingData_COB_Handler+916j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    xor     edx, edx                        ; edx = 0;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ebp, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebp = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    cmp     ebp, ecx
    setl    dl
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], edx ; [esi+eax*4+COB_StackFrame.Stack] = edx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B16FD:                             ; CODE XREF: UnitScriptingData_COB_Handler+914j
    cmp     edx, COB_GreaterThan
    ja      short loc_4B1757
    jz      short loc_4B1735
    cmp     edx, COB_LessThanOrEqual
    jnz     COB_UnknownInstr                ; if (edx != COB_LessThanOrEqual) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    xor     edx, edx                        ; edx = 0;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ebp, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebp = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    cmp     ebp, ecx
    setle   dl
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], edx ; [esi+eax*4+COB_StackFrame.Stack] = edx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1735:                             ; CODE XREF: UnitScriptingData_COB_Handler+965j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    xor     edx, edx                        ; edx = 0;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ebp, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebp = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    cmp     ebp, ecx
    setnle  dl
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], edx ; [esi+eax*4+COB_StackFrame.Stack] = edx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1757:                             ; CODE XREF: UnitScriptingData_COB_Handler+963j
    cmp     edx, COB_Equal
    ja      short loc_4B17B1
    jz      short loc_4B178F
    cmp     edx, COB_GreaterThanOrEqual
    jnz     COB_UnknownInstr                ; if (edx != COB_GreaterThanOrEqual) goto COB_UnknownInstr;
    mov     eax, [esi+tm.tm_hour]           ; eax = [esi+tm.tm_hour];
    xor     edx, edx                        ; edx = 0;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ebp, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebp = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    cmp     ebp, ecx
    setnl   dl
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], edx ; [esi+eax*4+COB_StackFrame.Stack] = edx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B178F:                             ; CODE XREF: UnitScriptingData_COB_Handler+9BFj
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    xor     edx, edx                        ; edx = 0;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ebp, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebp = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    cmp     ebp, ecx
    setz    dl
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], edx ; [esi+eax*4+COB_StackFrame.Stack] = edx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B17B1:                             ; CODE XREF: UnitScriptingData_COB_Handler+9BDj
    cmp     edx, COB_Unknown13
    ja      short loc_4B1813
    jz      short loc_4B17E9
    cmp     edx, COB_NotEqual
    jnz     COB_UnknownInstr                ; if (edx != COB_NotEqual) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    xor     edx, edx                        ; edx = 0;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ebp, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebp = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    cmp     ebp, ecx
    setnz   dl
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], edx ; [esi+eax*4+COB_StackFrame.Stack] = edx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B17E9:                             ; CODE XREF: UnitScriptingData_COB_Handler+A19j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    test    ecx, ecx
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    jz      short loc_4B1804
    test    edx, edx
    jnz     short loc_4B1851                ; if (edx != 0) goto loc_4B1851;

    loc_4B1804:                             ; CODE XREF: UnitScriptingData_COB_Handler+A5Ej
    xor     ecx, ecx                        ; ecx = 0;
    inc     eax                             ; eax++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1813:                             ; CODE XREF: UnitScriptingData_COB_Handler+A17j
    cmp     edx, COB_LogicalXor(check)
    ja      short loc_4B1880
    jz      short loc_4B1863
    cmp     edx, COB_LogicalOr
    jnz     COB_UnknownInstr                ; if (edx != COB_LogicalOr) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    test    ecx, ecx
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    jnz     short loc_4B1851
    test    edx, edx
    jnz     short loc_4B1851                ; if (edx != 0) goto loc_4B1851;
    inc     eax                             ; eax++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1851:                             ; CODE XREF: UnitScriptingData_COB_Handler+A62j
                                            ; UnitScriptingData_COB_Handler+A9Ej ...
    inc     eax                             ; eax++;
    mov     ecx, 1                          ; ecx = 1;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1863:                             ; CODE XREF: UnitScriptingData_COB_Handler+A7Bj
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    xor     ecx, edx                        ; ecx ^= edx;
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], ecx ; [esi+eax*4+COB_StackFrame.Stack] = ecx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1880:                             ; CODE XREF: UnitScriptingData_COB_Handler+A79j
    cmp     edx, COB_StartScript
    ja      short loc_4B1903
    jz      short COBInstr_StartScript
    cmp     edx, COB_Unknown15
    jnz     COB_UnknownInstr                ; if (edx != COB_Unknown15) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    xor     edx, edx                        ; edx = 0;
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    test    ecx, ecx
    setz    dl
    mov     [esi+eax*4+COB_StackFrame.field_0.Stack], edx ; [esi+eax*4+COB_StackFrame.Stack] = edx;
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    COBInstr_StartScript:                   ; CODE XREF: UnitScriptingData_COB_Handler+AE8j
    mov     ebx, [eax+ecx*4+8]              ; ebx = [eax+ecx*4+8];
    mov     eax, [eax+ecx*4+4]              ; eax = [eax+ecx*4+4];
    push    eax                             ; MethodIndex
    mov     ecx, edi                        ; ecx = edi;
    call    UnitScriptingData_StartScript   ; COB_Object_StartScript(eax);
    test    eax, eax
    jl      short loc_4B18F8
    test    ebx, ebx
    jle     short loc_4B18EB
    mov     edx, ebx                        ; edx = ebx;
    lea     ecx, [eax+eax*4]                ; ecx = &[eax+eax*4];
    add     edx, eax                        ; edx += eax;
    mov     ebp, ebx                        ; ebp = ebx;
    lea     ecx, [edx+ecx*8]                ; ecx = &[edx+ecx*8];
    lea     edx, [edi+ecx*4+40h]            ; edx = &[edi+ecx*4+40h];

    loc_4B18D8:                             ; CODE XREF: UnitScriptingData_COB_Handler+B49j
    mov     ecx, [esi+COB_StackFrame.field_0.StackIndex] ; ecx = [esi+COB_StackFrame.StackIndex];
    sub     edx, 4                          ; edx -= 4;
    mov     ebx, [esi+ecx*4+COB_StackFrame.field_0.Stack] ; ebx = [esi+ecx*4+COB_StackFrame.Stack];
    dec     ecx                             ; ecx--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], ecx ; [esi+COB_StackFrame.StackIndex] = ecx;
    dec     ebp                             ; ebp--;
    mov     [edx], ebx                      ; [edx] = ebx;
    jnz     short loc_4B18D8

    loc_4B18EB:                             ; CODE XREF: UnitScriptingData_COB_Handler+B26j
    mov     ecx, [esi+COB_StackFrame.field_0.field_1C] ; ecx = [esi+COB_StackFrame.field_1C];
    lea     edx, [eax+eax*4]                ; edx = &[eax+eax*4];
    lea     eax, [eax+edx*8]                ; eax = &[eax+edx*8];
    mov     [edi+eax*4+38h], ecx            ; [edi+eax*4+38h] = ecx;

    loc_4B18F8:                             ; CODE XREF: UnitScriptingData_COB_Handler+31Ej
                                            ; UnitScriptingData_COB_Handler+B22j
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 3                          ; eax += 3;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1903:                             ; CODE XREF: UnitScriptingData_COB_Handler+AE6j
    cmp     edx, COB_Unknown16
    ja      loc_4B19B1
    jz      short loc_4B1984
    cmp     edx, COB_CallScript
    jnz     COB_UnknownInstr                ; if (edx != COB_CallScript) goto COB_UnknownInstr;
    mov     edx, [eax+ecx*4+4]              ; edx = [eax+ecx*4+4];
    mov     ebx, [eax+ecx*4+8]              ; ebx = [eax+ecx*4+8];
    push    edx                             ; MethodIndex
    mov     ecx, edi                        ; ecx = edi;
    call    UnitScriptingData_StartScript   ; COB_Object_StartScript(edx);
    test    eax, eax
    jl      short loc_4B1965
    test    ebx, ebx
    jle     short loc_4B1958
    mov     edx, ebx                        ; edx = ebx;
    lea     ecx, [eax+eax*4]                ; ecx = &[eax+eax*4];
    add     edx, eax                        ; edx += eax;
    mov     ebp, ebx                        ; ebp = ebx;
    lea     ecx, [edx+ecx*8]                ; ecx = &[edx+ecx*8];
    lea     edx, [edi+ecx*4+40h]            ; edx = &[edi+ecx*4+40h];

    loc_4B1945:                             ; CODE XREF: UnitScriptingData_COB_Handler+BB6j
    mov     ecx, [esi+ScriptSlotArray.ScriptSlots.StackIndex]
    sub     edx, 4                          ; edx -= 4;
    mov     ebx, [esi+ecx*4+ScriptSlot.Stack]
    dec     ecx                             ; ecx--;
    mov     [esi+ScriptSlot.StackIndex], ecx
    dec     ebp                             ; ebp--;
    mov     [edx], ebx                      ; [edx] = ebx;
    jnz     short loc_4B1945

    loc_4B1958:                             ; CODE XREF: UnitScriptingData_COB_Handler+B93j
    lea     edx, [eax+eax*4]                ; edx = &[eax+eax*4];
    lea     ecx, [eax+edx*8]                ; ecx = &[eax+edx*8];
    mov     edx, [esi+COB_StackFrame.field_0.field_1C] ; edx = [esi+COB_StackFrame.field_1C];
    mov     [edi+ecx*4+38h], edx            ; [edi+ecx*4+38h] = edx;

    loc_4B1965:                             ; CODE XREF: UnitScriptingData_COB_Handler+B8Fj
    mov     [esi+ScriptSlot.ScriptToWaitOn], eax
    mov     eax, [esi+ScriptSlot.InstrIndex]
    add     eax, 3                          ; eax += 3;
    mov     [esi+ScriptSlot.Flags], COB_CallScriptWait
    mov     [esi+ScriptSlot.InstrIndex], eax
    mov     [esp+30h+KeepProcessing], 0
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    loc_4B1984:                             ; CODE XREF: UnitScriptingData_COB_Handler+B6Fj
    mov     eax, [eax+ecx*4+8]              ; eax = [eax+ecx*4+8];
    dec     eax                             ; eax--;
    js      short loc_4B19A6
    lea     edx, [esp+eax*4+30h+var_10]     ; edx = &[esp+eax*4+30h+var_10];
    lea     ebp, [eax+1]                    ; ebp = &[eax+1];

    loc_4B1992:                             ; CODE XREF: UnitScriptingData_COB_Handler+C04j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    sub     edx, 4                          ; edx -= 4;
    mov     ebx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [edx+4], ebx                    ; [edx+4] = ebx;
    dec     ebp                             ; ebp--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    jnz     short loc_4B1992

    loc_4B19A6:                             ; CODE XREF: UnitScriptingData_COB_Handler+BE9j
    add     ecx, 3                          ; ecx += 3;
    mov     [esi+COB_StackFrame.field_0.InstrIndex], ecx ; [esi+COB_StackFrame.InstrIndex] = ecx;
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    loc_4B19B1:                             ; CODE XREF: UnitScriptingData_COB_Handler+B69j
    cmp     edx, COB_Return
    ja      short loc_4B1A32
    jz      short loc_4B19D0
    cmp     edx, COB_JumpToOffset
    jnz     COB_UnknownInstr                ; if (edx != COB_JumpToOffset) goto COB_UnknownInstr;
    mov     eax, [eax+ecx*4+4]              ; eax = [eax+ecx*4+4];
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B19D0:                             ; CODE XREF: UnitScriptingData_COB_Handler+C19j
    mov     ecx, [esi+ScriptSlot.MethodReturnedCallBack] ; ecx = [esi+COB_StackFrame.MethodReturnedCallBack];
    test    ecx, ecx
    jz      short loc_4B19E7                ; if (ecx == 0) goto loc_4B19E7;
    mov     eax, [esi+ScriptSlot.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+ScriptSlot.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+ScriptSlot.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     eax, [ecx]                      ; eax = [ecx];
    push    edx
    call    dword ptr [eax]                 ; dword ptr [eax](edx);

    loc_4B19E7:                             ; CODE XREF: UnitScriptingData_COB_Handler+C35j
    mov     [esi+ScriptSlot.Flags], COB_NotInUse ; [esi+COB_StackFrame.field_0] = 0;
    mov     eax, [edi+UnitScriptingData.StartRunningNow] ; eax = [edi+53Ch];
    dec     eax                             ; eax--;
    mov     ecx, 8                          ; ecx = 8;
    mov     [edi+UnitScriptingData.StartRunningNow], eax ; [edi+53Ch] = eax;
    lea     eax, [edi+1Ch]                  ; eax = &[edi+1Ch];

    loc_4B1A02:                             ; CODE XREF: UnitScriptingData_COB_Handler+C83j
    mov     edx, [eax]                      ; edx = [eax];
    and     edx, 0FFF00000h
    cmp     edx, 2800000h
    jnz     short loc_4B1A1D                ; if (edx != 2800000h) goto loc_4B1A1D;
    cmp     [eax+18h], ebp
    jnz     short loc_4B1A1D                ; if ([eax+18h] != ebp) goto loc_4B1A1D;
    mov     dword ptr [eax], 1000000h       ; dword ptr [eax] = 1000000h;

    loc_4B1A1D:                             ; CODE XREF: UnitScriptingData_COB_Handler+C70j
                                            ; UnitScriptingData_COB_Handler+C75j
    add     eax, 0A4h                       ; eax += 0A4h;
    dec     ecx                             ; ecx--;
    jnz     short loc_4B1A02
    mov     [esp+30h+KeepProcessing], 0     ; [esp+30h+arg_4] = 0;
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    loc_4B1A32:                             ; CODE XREF: UnitScriptingData_COB_Handler+C17j
    cmp     edx, COB_Signal
    ja      loc_4B1AF6
    jz      short loc_4B1A75
    cmp     edx, COB_JumpToOffsetIfFalse
    jnz     COB_UnknownInstr                ; if (edx != COB_JumpToOffsetIfFalse) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    test    edx, edx
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    jnz     short ChangeInstrIndex2
    mov     eax, [edi+8]                    ; eax = [edi+8];
    mov     edx, [eax+24h]                  ; edx = [eax+24h];
    mov     eax, [edx+ecx*4+4]              ; eax = [edx+ecx*4+4];
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    ChangeInstrIndex2:                      ; CODE XREF: UnitScriptingData_COB_Handler+CB9j
    add     ecx, 2                          ; ecx += 2;
    mov     [esi+COB_StackFrame.field_0.InstrIndex], ecx ; [esi+COB_StackFrame.InstrIndex] = ecx;
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    loc_4B1A75:                             ; CODE XREF: UnitScriptingData_COB_Handler+C9Ej
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esp+30h+var_14], ecx           ; [esp+30h+var_14] = ecx;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    xor     ebx, ebx                        ; ebx = 0;
    lea     ecx, [edi+1Ch]                  ; ecx = &[edi+1Ch];

    loc_4B1A89:                             ; CODE XREF: UnitScriptingData_COB_Handler+D4Fj
    cmp     dword ptr [ecx], 0
    jz      short loc_4B1AE5                ; if (dword ptr [ecx] == 0) goto loc_4B1AE5;
    mov     edx, [esp+30h+var_14]           ; edx = [esp+30h+var_14];
    mov     eax, [ecx+1Ch]                  ; eax = [ecx+1Ch];
    test    edx, eax
    jz      short loc_4B1AE5
    mov     dword ptr [ecx], 0              ; dword ptr [ecx] = 0;
    mov     eax, [edi+53Ch]                 ; eax = [edi+53Ch];
    dec     eax                             ; eax--;
    mov     edx, 8                          ; edx = 8;
    mov     [edi+53Ch], eax                 ; [edi+53Ch] = eax;
    lea     eax, [edi+1Ch]                  ; eax = &[edi+1Ch];

    loc_4B1AB4:                             ; CODE XREF: UnitScriptingData_COB_Handler+D35j
    mov     ebp, [eax]                      ; ebp = [eax];
    and     ebp, 0FFF00000h
    cmp     ebp, 2800000h
    jnz     short loc_4B1ACF                ; if (ebp != 2800000h) goto loc_4B1ACF;
    cmp     [eax+18h], ebx
    jnz     short loc_4B1ACF                ; if ([eax+18h] != ebx) goto loc_4B1ACF;
    mov     dword ptr [eax], 1000000h       ; dword ptr [eax] = 1000000h;

    loc_4B1ACF:                             ; CODE XREF: UnitScriptingData_COB_Handler+D22j
                                            ; UnitScriptingData_COB_Handler+D27j
    add     eax, 0A4h                       ; eax += 0A4h;
    dec     edx                             ; edx--;
    jnz     short loc_4B1AB4
    cmp     ebx, [esp+30h+ScriptNumber]
    jnz     short loc_4B1AE5                ; if (ebx != [esp+30h+arg_0]) goto loc_4B1AE5;
    mov     [esp+30h+KeepProcessing], 0     ; [esp+30h+arg_4] = 0;

    loc_4B1AE5:                             ; CODE XREF: UnitScriptingData_COB_Handler+CECj
                                            ; UnitScriptingData_COB_Handler+CF7j ...
    inc     ebx                             ; ebx++;
    add     ecx, 0A4h                       ; ecx += 0A4h;
    cmp     ebx, 8
    jl      short loc_4B1A89
    jmp     IncInstrIndex                   ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1AF6:                             ; CODE XREF: UnitScriptingData_COB_Handler+C98j
    cmp     edx, COB_Explode
    ja      short loc_4B1B48
    jz      short loc_4B1B1F
    cmp     edx, COB_SetSignalMask
    jnz     short COB_UnknownInstr          ; if (edx != COB_SetSignalMask) goto COB_UnknownInstr;
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    inc     ecx                             ; ecx++;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     [esi+COB_StackFrame.field_0.field_1C], edx ; [esi+COB_StackFrame.field_1C] = edx;
    mov     [esi+COB_StackFrame.field_0.InstrIndex], ecx ; [esi+COB_StackFrame.InstrIndex] = ecx;
    jmp     InstrLoopTest                   ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    loc_4B1B1F:                             ; CODE XREF: UnitScriptingData_COB_Handler+D5Ej
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    push    edx
    mov     edx, [edi+COB_StackFrame.field_0.StackIndex] ; edx = [edi+COB_StackFrame.StackIndex];
    mov     eax, [edi]                      ; eax = [edi];
    mov     edx, [edx+24h]                  ; edx = [edx+24h];
    mov     ecx, [edx+ecx*4+4]              ; ecx = [edx+ecx*4+4];
    push    ecx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [eax+34h]             ; dword ptr [eax+34h](ecx, edx);

    IncInstrIndex2:                         ; CODE XREF: UnitScriptingData_COB_Handler+679j
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    add     eax, 2                          ; eax += 2;
    jmp     ChangeInstrIndex                ; goto ChangeInstrIndex;
    ; ---------------------------------------------------------------------------

    loc_4B1B48:                             ; CODE XREF: UnitScriptingData_COB_Handler+D5Cj
    cmp     edx, COB_SetUnitValue
    jz      short COBHandler_SetUnitValue   ; if (edx == COB_SetUnitValue) goto COBHandler_SetUnitValue;
    cmp     edx, COB_AttachUnit
    jz      short COBHandler_AttachUnit     ; if (edx == COB_AttachUnit) goto COBHandler_AttachUnit;
    cmp     edx, COB_DropUnit
    jz      short COBHandler_DropUnit       ; if (edx == COB_DropUnit) goto COBHandler_DropUnit;

    COB_UnknownInstr:                       ; CODE XREF: UnitScriptingData_COB_Handler+E9j
                                            ; UnitScriptingData_COB_Handler+264j ...
    mov     [esi+COB_StackFrame.field_0.Flags], 0 ; [esi+COB_StackFrame.field_0] = 0;
    mov     eax, [edi+53Ch]                 ; eax = [edi+53Ch];
    dec     eax                             ; eax--;
    mov     [esp+30h+KeepProcessing], 0     ; [esp+30h+arg_4] = 0;
    mov     [edi+53Ch], eax                 ; [edi+53Ch] = eax;
    jmp     short InstrLoopTest             ; goto InstrLoopTest;
    ; ---------------------------------------------------------------------------

    COBHandler_DropUnit:                    ; CODE XREF: UnitScriptingData_COB_Handler+DBEj
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     edx, [edi]                      ; edx = [edi];
    push    ecx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [edx+3Ch]             ; dword ptr [edx+3Ch](ecx);
    jmp     short IncInstrIndex             ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_AttachUnit:                  ; CODE XREF: UnitScriptingData_COB_Handler+DB6j
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    push    ecx
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    push    edx
    mov     ebx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ebx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     eax, [edi]                      ; eax = [edi];
    push    ebx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [eax+38h]             ; dword ptr [eax+38h]();
    jmp     short IncInstrIndex             ; goto IncInstrIndex;
    ; ---------------------------------------------------------------------------

    COBHandler_SetUnitValue:                ; CODE XREF: UnitScriptingData_COB_Handler+DAEj
    mov     eax, [esi+COB_StackFrame.field_0.StackIndex] ; eax = [esi+COB_StackFrame.StackIndex];
    mov     ecx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; ecx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    push    ecx
    mov     edx, [esi+eax*4+COB_StackFrame.field_0.Stack] ; edx = [esi+eax*4+COB_StackFrame.Stack];
    dec     eax                             ; eax--;
    mov     [esi+COB_StackFrame.field_0.StackIndex], eax ; [esi+COB_StackFrame.StackIndex] = eax;
    mov     eax, [edi]                      ; eax = [edi];
    push    edx
    mov     ecx, edi                        ; ecx = edi;
    call    dword ptr [eax+40h]             ; dword ptr [eax+40h](edx, ecx);

    IncInstrIndex:                          ; CODE XREF: UnitScriptingData_COB_Handler+707j
                                            ; UnitScriptingData_COB_Handler+724j ...
    mov     eax, [esi+COB_StackFrame.field_0.InstrIndex] ; eax = [esi+COB_StackFrame.InstrIndex];
    inc     eax                             ; eax++;

    ChangeInstrIndex:                       ; CODE XREF: UnitScriptingData_COB_Handler+187j
                                            ; UnitScriptingData_COB_Handler+2E1j ...
    mov     [esi+COB_StackFrame.field_0.InstrIndex], eax ; [esi+COB_StackFrame.InstrIndex] = eax;

    InstrLoopTest:                          ; CODE XREF: UnitScriptingData_COB_Handler+568j
                                            ; UnitScriptingData_COB_Handler+5A5j ...
    mov     eax, [esp+30h+KeepProcessing]   ; eax = [esp+30h+arg_4];
    test    eax, eax
    jnz     InstrLoop                       ; if (eax != 0) goto InstrLoop;

    COB_Handler_exit:                       ; CODE XREF: UnitScriptingData_COB_Handler+24j
                                            ; UnitScriptingData_COB_Handler+A9j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h                        ; esp += 20h;
    retn    8                               ; return;
    UnitScriptingData_COB_Handler endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B1C00 proc near                    ; CODE XREF: InvokeScript+A8p
                                            ; .text:004B0A5Fp ...

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    sub     esp, 18h
    test    eax, eax
    push    ebp
    push    edi
    mov     edi, ecx
    jz      loc_4B1E42
    mov     eax, [edi+UnitScriptingData.field_18]
    test    eax, eax
    jz      loc_4B1E42
    mov     eax, [edi+UnitScriptingData.pCOB]
    mov     [edi+UnitScriptingData.field_18], 0
    xor     ebp, ebp
    mov     ecx, [eax+8]
    mov     [esp+20h+var_C], ebp
    test    ecx, ecx
    jle     loc_4B1E42
    push    esi
    xor     esi, esi
    push    ebx
    mov     [esp+28h+var_14], esi
    mov     [esp+28h+var_18], 0Dh

    loc_4B1C49:                             ; CODE XREF: sub_4B1C00+23Aj
    mov     ecx, [edi+14h]
    lea     eax, [ecx+esi]
    mov     ecx, [ecx+esi]
    test    ecx, ecx
    jz      loc_4B1E1B
    xor     ebx, ebx
    mov     dword ptr [eax], 0
    mov     [esp+28h+var_10], ebx
    add     esi, 28h

    loc_4B1C69:                             ; CODE XREF: sub_4B1C00+201j
    mov     edx, [edi+14h]
    mov     eax, [edx+esi-18h]
    test    eax, eax
    jz      short loc_4B1CD3
    mov     eax, [edi]
    push    ebx
    push    ebp
    mov     ecx, edi
    call    dword ptr [eax+14h]
    mov     ecx, [edi+14h]
    mov     ebp, [esp+28h+arg_0]
    mov     edx, [esi+ecx-18h]
    imul    ebp, edx
    add     eax, ebp
    xor     ebp, ebp
    cmp     edx, ebp
    mov     edx, [esp+28h+var_18]
    jle     short loc_4B1CA9
    add     edx, ebx
    mov     edx, [ecx+edx*4-30h]
    cmp     eax, edx
    jl      short loc_4B1CBB
    mov     eax, edx
    mov     [esi+ecx-18h], ebp
    jmp     short loc_4B1CC6
    ; ---------------------------------------------------------------------------

    loc_4B1CA9:                             ; CODE XREF: sub_4B1C00+95j
    add     edx, ebx
    mov     edx, [ecx+edx*4-30h]
    cmp     eax, edx
    jg      short loc_4B1CBB
    mov     eax, edx
    mov     [esi+ecx-18h], ebp
    jmp     short loc_4B1CC6
    ; ---------------------------------------------------------------------------

    loc_4B1CBB:                             ; CODE XREF: sub_4B1C00+9Fj
                                            ; sub_4B1C00+B1j
    mov     edx, [esp+28h+var_14]
    mov     dword ptr [edx+ecx], 1

    loc_4B1CC6:                             ; CODE XREF: sub_4B1C00+A7j
                                            ; sub_4B1C00+B9j
    mov     ebp, [esp+28h+var_C]
    mov     edx, [edi]
    push    eax
    push    ebx
    push    ebp
    mov     ecx, edi
    call    dword ptr [edx]

    loc_4B1CD3:                             ; CODE XREF: sub_4B1C00+72j
    mov     eax, [edi+14h]
    xor     edx, edx
    mov     ecx, [esi+eax+18h]
    cmp     ecx, edx
    jz      short loc_4B1D12
    add     [esi+eax], ecx
    mov     eax, [edi+14h]
    mov     ecx, [esi+eax+18h]
    cmp     ecx, edx
    mov     ecx, [esp+28h+var_18]
    jle     short loc_4B1CFE
    add     ecx, ebx
    mov     ecx, [eax+ecx*4]
    cmp     [esi+eax], ecx
    jl      short loc_4B1D12
    jmp     short loc_4B1D08
    ; ---------------------------------------------------------------------------

    loc_4B1CFE:                             ; CODE XREF: sub_4B1C00+F0j
    add     ecx, ebx
    mov     ecx, [eax+ecx*4]
    cmp     [esi+eax], ecx
    jg      short loc_4B1D12

    loc_4B1D08:                             ; CODE XREF: sub_4B1C00+FCj
    mov     [esi+eax], ecx
    mov     eax, [edi+14h]
    mov     [eax+esi+18h], edx

    loc_4B1D12:                             ; CODE XREF: sub_4B1C00+DEj
                                            ; sub_4B1C00+FAj ...
    mov     ecx, [edi+14h]
    cmp     [ecx+esi], edx
    jz      loc_4B1DF6
    mov     edx, [edi]
    push    ebx
    push    ebp
    mov     ecx, edi
    call    dword ptr [edx+18h]
    mov     ebp, [edi+14h]
    mov     ecx, [esp+28h+arg_0]
    mov     ebx, eax
    mov     edx, [esp+28h+var_10]
    mov     eax, [esi+ebp]
    mov     [esp+20h], ebx
    imul    ecx, eax
    mov     eax, [esp+28h+var_18]
    add     ebx, ecx
    add     edx, eax
    mov     edx, [ebp+edx*4-18h]
    cmp     edx, 0FFFFFFFFh
    mov     [esp+28h+var_4], edx
    jz      short loc_4B1DCB
    cmp     dword ptr [esi+ebp], 0
    jle     short loc_4B1D92
    mov     eax, edx
    mov     edx, [esp+20h]
    sub     eax, edx
    add     eax, 10000h
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 0FFFFh
    xor     eax, edx
    sub     eax, edx
    cmp     eax, ecx
    jg      short loc_4B1D85
    mov     ebx, [esp+28h+var_4]
    mov     dword ptr [esi+ebp], 0
    jmp     short loc_4B1DD6
    ; ---------------------------------------------------------------------------

    loc_4B1D85:                             ; CODE XREF: sub_4B1C00+176j
    mov     eax, [esp+28h+var_14]
    mov     dword ptr [eax+ebp], 1
    jmp     short loc_4B1DD6
    ; ---------------------------------------------------------------------------

    loc_4B1D92:                             ; CODE XREF: sub_4B1C00+157j
    mov     eax, [esp+20h]
    sub     eax, edx
    add     eax, 10000h
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 0FFFFh
    xor     eax, edx
    sub     eax, edx
    neg     ecx
    cmp     eax, ecx
    jg      short loc_4B1DBE
    mov     ebx, [esp+28h+var_4]
    mov     dword ptr [esi+ebp], 0
    jmp     short loc_4B1DD6
    ; ---------------------------------------------------------------------------

    loc_4B1DBE:                             ; CODE XREF: sub_4B1C00+1AFj
    mov     ecx, [esp+28h+var_14]
    mov     dword ptr [ecx+ebp], 1
    jmp     short loc_4B1DD6
    ; ---------------------------------------------------------------------------

    loc_4B1DCB:                             ; CODE XREF: sub_4B1C00+151j
    mov     edx, [esp+28h+var_14]
    mov     dword ptr [edx+ebp], 1

    loc_4B1DD6:                             ; CODE XREF: sub_4B1C00+183j
                                            ; sub_4B1C00+190j ...
    mov     ecx, [esp+28h+var_10]
    mov     edx, [esp+28h+var_C]
    mov     eax, [edi]
    and     ebx, 0FFFFh
    push    ebx
    push    ecx
    push    edx
    mov     ecx, edi
    call    dword ptr [eax+4]
    mov     ebx, [esp+28h+var_10]
    mov     ebp, [esp+28h+var_C]

    loc_4B1DF6:                             ; CODE XREF: sub_4B1C00+118j
    inc     ebx
    add     esi, 4
    cmp     ebx, 2
    mov     [esp+28h+var_10], ebx
    jle     loc_4B1C69
    mov     eax, [edi+14h]
    mov     esi, [esp+28h+var_14]
    cmp     dword ptr [eax+esi], 0
    jz      short loc_4B1E1B
    mov     dword ptr [edi+18h], 1

    loc_4B1E1B:                             ; CODE XREF: sub_4B1C00+54j
                                            ; sub_4B1C00+212j
    mov     ecx, [edi+8]
    mov     edx, [esp+28h+var_18]
    inc     ebp
    add     edx, 13h
    mov     eax, [ecx+8]
    add     esi, 4Ch
    cmp     ebp, eax
    mov     [esp+28h+var_C], ebp
    mov     [esp+28h+var_18], edx
    mov     [esp+28h+var_14], esi
    jl      loc_4B1C49
    pop     ebx
    pop     esi

    loc_4B1E42:                             ; CODE XREF: sub_4B1C00+Dj
                                            ; sub_4B1C00+18j ...
    pop     edi
    pop     ebp
    add     esp, 18h
    retn    4
    sub_4B1C00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B1E50 proc near                    ; DATA XREF: .rdata:004FDB1Co
    xor     eax, eax
    retn    4
    sub_4B1E50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B1E60 proc near                    ; DATA XREF: .rdata:004FDB20o
    xor     eax, eax
    retn    4
    sub_4B1E60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B1E70 proc near                    ; DATA XREF: .rdata:004FDB24o
    xor     eax, eax
    retn    4
    sub_4B1E70 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_74. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_75. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_76. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000003 BYTES: COLLAPSED FUNCTION nullsub_77. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B1EC0 proc near                    ; CODE XREF: sub_4876C0+7Dp

    var_5B8= dword ptr -5B8h
    var_5B4= dword ptr -5B4h
    var_5B0= dword ptr -5B0h
    var_5A8= dword ptr -5A8h
    var_5A4= dword ptr -5A4h
    var_59C= dword ptr -59Ch
    var_598= dword ptr -598h
    var_594= dword ptr -594h
    var_538= dword ptr -538h
    var_528= dword ptr -528h
    var_504= dword ptr -504h
    var_18= dword ptr -18h
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 59Ch
    push    ebx
    push    ebp
    push    esi
    mov     ebx, ecx
    mov     ecx, [esp+5A8h+arg_0]
    push    edi
    push    0
    call    sub_4B4C10
    mov     eax, [ebx+0Ch]
    lea     edx, [ebx+1Ch]
    mov     [esp+5ACh+var_528], eax
    lea     eax, [esp+5ACh+var_504]
    mov     ebp, 8

    loc_4B1EF3:                             ; CODE XREF: sub_4B1EC0+51j
    lea     edi, [eax-20h]
    mov     ecx, 29h
    mov     esi, edx
    add     edx, 0A4h
    rep movsd
    mov     dword ptr [eax], 0
    add     eax, 0A4h
    dec     ebp
    jnz     short loc_4B1EF3
    mov     ecx, [ebx+53Ch]
    mov     esi, [esp+5ACh+arg_0]
    lea     edx, [esp+5ACh+var_528]
    mov     [esp+5ACh+var_4], ecx
    push    528h
    push    edx
    mov     ecx, esi
    call    sub_4B4CF0
    mov     eax, [ebx+8]
    mov     edx, [ebx+10h]
    mov     ecx, [eax+10h]
    shl     ecx, 2
    push    ecx
    push    edx
    mov     ecx, esi
    call    sub_4B4CF0
    mov     eax, [ebx+8]
    xor     esi, esi
    mov     [esp+5ACh+var_59C], esi
    mov     ecx, [eax+8]
    test    ecx, ecx
    jle     loc_4B2030
    mov     [esp+5ACh+var_598], 10h
    jmp     short loc_4B1F72
    ; ---------------------------------------------------------------------------

    loc_4B1F6E:                             ; CODE XREF: sub_4B1EC0+16Aj
    mov     esi, [esp+5ACh+var_59C]

    loc_4B1F72:                             ; CODE XREF: sub_4B1EC0+ACj
    mov     edx, [ebx]
    push    esi
    mov     ecx, ebx
    call    dword ptr [edx+1Ch]
    mov     [esp+78h], eax
    mov     eax, [ebx]
    push    esi
    mov     ecx, ebx
    call    dword ptr [eax+20h]
    mov     edx, [ebx]
    push    esi
    mov     ecx, ebx
    mov     [esp+80h], eax
    call    dword ptr [edx+24h]
    mov     edi, [esp+5ACh+var_598]
    mov     [esp+80h], eax
    xor     ebp, ebp
    lea     esi, [esp+24h]

    loc_4B1FA6:                             ; CODE XREF: sub_4B1EC0+13Bj
    mov     eax, [ebx+14h]
    push    ebp
    mov     ecx, [edi+eax-0Ch]
    mov     [esi-0Ch], ecx
    mov     edx, [edi+eax]
    mov     [esi], edx
    mov     ecx, [edi+eax+0Ch]
    mov     [esi+0Ch], ecx
    mov     edx, [edi+eax+18h]
    mov     [esi+18h], edx
    mov     ecx, [edi+eax+24h]
    mov     [esi+24h], ecx
    mov     ecx, [esp+5B0h+var_59C]
    mov     edx, [edi+eax+30h]
    mov     eax, [ebx]
    push    ecx
    mov     ecx, ebx
    mov     [esi+30h], edx
    call    dword ptr [eax+14h]
    mov     edx, [ebx]
    mov     [esi+3Ch], eax
    mov     eax, [esp+5ACh+var_59C]
    push    ebp
    push    eax
    mov     ecx, ebx
    call    dword ptr [edx+18h]
    mov     [esi+48h], eax
    inc     ebp
    add     edi, 4
    add     esi, 4
    cmp     ebp, 2
    jle     short loc_4B1FA6
    lea     ecx, [esp+5ACh+var_594]
    push    6Ch
    push    ecx
    mov     ecx, [esp+5B4h+arg_0]
    call    sub_4B4CF0
    mov     edx, [esp+5ACh+var_598]
    mov     eax, [esp+5ACh+var_59C]
    add     edx, 4Ch
    inc     eax
    mov     [esp+5ACh+var_598], edx
    mov     edx, [ebx+8]
    mov     [esp+5ACh+var_59C], eax
    cmp     eax, [edx+8]
    jl      loc_4B1F6E

    loc_4B2030:                             ; CODE XREF: sub_4B1EC0+9Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 59Ch
    retn    4
    sub_4B1EC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B2040 proc near                    ; CODE XREF: sub_487080+580p

    var_568= dword ptr -568h
    var_564= dword ptr -564h
    var_560= dword ptr -560h
    var_55C= dword ptr -55Ch
    var_554= dword ptr -554h
    var_548= dword ptr -548h
    var_538= dword ptr -538h
    var_534= dword ptr -534h
    var_52C= dword ptr -52Ch
    var_528= dword ptr -528h
    var_524= dword ptr -524h
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 538h
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     eax, [ebx+8]
    mov     ebp, [esp+544h+arg_0]
    push    edi
    mov     ecx, ebp
    mov     esi, [eax+10h]
    mov     eax, [eax+8]
    shl     esi, 2
    lea     eax, [eax+eax*2]
    mov     [esp+548h+var_538], esi
    lea     edi, [eax+eax*8]
    shl     edi, 2
    mov     [esp+548h+var_534], edi
    call    sub_4B4BF0
    lea     ecx, [edi+esi+528h]
    cmp     eax, ecx
    jz      short loc_4B2091
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 538h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B2091:                             ; CODE XREF: sub_4B2040+40j
    push    0
    mov     ecx, ebp
    call    sub_4B4C10
    lea     edx, [esp+548h+var_528]
    push    528h
    push    edx
    mov     ecx, ebp
    call    sub_4B4C80
    cmp     eax, 528h
    jz      short loc_4B20C1
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 538h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B20C1:                             ; CODE XREF: sub_4B2040+70j
    mov     eax, [ebx+0Ch]
    mov     ecx, [esp+548h+var_528]
    cmp     eax, ecx
    jz      short loc_4B20DB
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 538h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B20DB:                             ; CODE XREF: sub_4B2040+8Aj
    lea     edx, [esp+548h+var_524]
    lea     eax, [ebx+3Ch]
    mov     ebp, 8

    loc_4B20E7:                             ; CODE XREF: sub_4B2040+C5j
    lea     edi, [eax-20h]
    mov     ecx, 29h
    mov     esi, edx
    add     edx, 0A4h
    rep movsd
    mov     dword ptr [eax], 0
    add     eax, 0A4h
    dec     ebp
    jnz     short loc_4B20E7
    mov     ecx, [esp+548h+var_4]
    mov     esi, [esp+548h+var_538]
    mov     edx, [ebx+10h]
    mov     ebp, [esp+548h+arg_0]
    mov     [ebx+53Ch], ecx
    push    esi
    push    edx
    mov     ecx, ebp
    call    sub_4B4C80
    cmp     eax, esi
    jz      short loc_4B213E
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 538h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B213E:                             ; CODE XREF: sub_4B2040+EDj
    mov     edi, [esp+548h+var_534]
    push    edi
    push    offset aPieceStates             ; "Piece States"
    call    sub_4D83B0
    add     esp, 8
    mov     esi, eax
    mov     ecx, ebp
    mov     [esp+548h+var_52C], esi
    push    edi
    push    esi
    call    sub_4B4C80
    cmp     eax, edi
    jz      short loc_4B2172
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 538h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B2172:                             ; CODE XREF: sub_4B2040+121j
    mov     eax, [ebx+8]
    xor     ebp, ebp
    mov     ecx, [eax+8]
    test    ecx, ecx
    jle     loc_4B226C
    xor     edi, edi
    add     esi, 64h
    mov     [esp+548h+var_534], edi
    mov     [esp+548h+var_538], esi
    jmp     short loc_4B2199
    ; ---------------------------------------------------------------------------

    loc_4B2191:                             ; CODE XREF: sub_4B2040+222j
    mov     esi, [esp+548h+var_538]
    mov     edi, [esp+548h+var_534]

    loc_4B2199:                             ; CODE XREF: sub_4B2040+14Fj
    mov     ecx, [ebx+14h]
    mov     dword ptr [edi+ecx], 1
    mov     eax, [esi-4]
    mov     edx, [ebx]
    push    eax
    push    ebp
    mov     ecx, ebx
    call    dword ptr [edx+8]
    mov     eax, [esi]
    mov     edx, [ebx]
    push    eax
    push    ebp
    mov     ecx, ebx
    call    dword ptr [edx+0Ch]
    mov     eax, [esi+4]
    mov     edx, [ebx]
    push    eax
    push    ebp
    mov     ecx, ebx
    call    dword ptr [edx+10h]
    add     edi, 10h
    mov     dword ptr [esp+18h], 0
    add     esi, 0FFFFFFA8h

    loc_4B21D4:                             ; CODE XREF: sub_4B2040+201j
    mov     ecx, [ebx+14h]
    mov     edx, [esi-0Ch]
    mov     [edi+ecx-0Ch], edx
    mov     eax, [ebx+14h]
    mov     ecx, [esi]
    mov     [edi+eax], ecx
    mov     edx, [ebx+14h]
    mov     eax, [esi+0Ch]
    mov     [edi+edx+0Ch], eax
    mov     ecx, [ebx+14h]
    mov     edx, [esi+18h]
    mov     [edi+ecx+18h], edx
    mov     eax, [ebx+14h]
    mov     ecx, [esi+24h]
    mov     [edi+eax+24h], ecx
    mov     edx, [ebx+14h]
    mov     eax, [esi+30h]
    mov     ecx, [esp+18h]
    mov     [edi+edx+30h], eax
    mov     eax, [esi+3Ch]
    mov     edx, [ebx]
    push    eax
    push    ecx
    push    ebp
    mov     ecx, ebx
    call    dword ptr [edx]
    mov     eax, [esi+48h]
    mov     ecx, [esp+18h]
    mov     edx, [ebx]
    push    eax
    push    ecx
    push    ebp
    mov     ecx, ebx
    call    dword ptr [edx+4]
    mov     eax, [esp+18h]
    add     esi, 4
    inc     eax
    add     edi, 4
    cmp     eax, 2
    mov     [esp+18h], eax
    jle     short loc_4B21D4
    mov     edx, [esp+548h+var_534]
    mov     ecx, [esp+548h+var_538]
    add     edx, 4Ch
    inc     ebp
    mov     [esp+548h+var_534], edx
    mov     edx, [ebx+8]
    add     ecx, 6Ch
    mov     eax, [edx+8]
    mov     [esp+548h+var_538], ecx
    cmp     ebp, eax
    jl      loc_4B2191
    mov     esi, [esp+548h+var_52C]

    loc_4B226C:                             ; CODE XREF: sub_4B2040+13Cj
    push    esi                             ; int
    mov     dword ptr [ebx+18h], 1
    call    sub_4D85A0
    add     esp, 4
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 538h
    retn    4
    sub_4B2040 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     cl, [esp-5]
    mov     al, [esp-5]
    sub     esp, 8
    mov     byte_51FBC1, cl
    lea     ecx, [esp+4]
    mov     byte_51FBC0, al
    push    ebx
    xor     ebx, ebx
    push    esi
    mov     byte_51FBC8, bl
    call    sub_4E39B0
    cmp     dword_51FBBC, ebx
    jnz     short loc_4B22E5
    push    18h
    call    sub_4B4F10
    mov     [eax+4], ebx
    mov     dword ptr [eax+14h], 1
    mov     dword_51FBBC, eax
    mov     [eax], ebx
    mov     edx, dword_51FBBC
    add     esp, 4
    mov     [edx+8], ebx

    loc_4B22E5:                             ; CODE XREF: .text:004B22BFj
    mov     ecx, dword_51FBB8
    mov     esi, dword_51FBBC
    inc     ecx
    push    18h
    mov     dword_51FBB8, ecx
    call    sub_4B4F10
    mov     [eax+4], esi
    mov     [eax+14h], ebx
    mov     dword_51FBC4, eax
    mov     dword_51FBCC, ebx
    mov     [eax], eax
    mov     eax, dword_51FBC4
    add     esp, 4
    lea     ecx, [esp+0Ch]
    mov     [eax+8], eax
    call    sub_4E3A70
    push    offset sub_4B2340
    call    _atexit
    add     esp, 4
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B2340 proc near                    ; DATA XREF: .text:004B2326o

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    mov     ecx, dword_51FBCC
    push    ebx
    push    esi
    push    edi
    mov     edi, dword_51FBC4
    xor     ebx, ebx
    cmp     ecx, ebx
    mov     eax, [edi]
    mov     [esp+14h+var_8], eax
    jz      short loc_4B23BC
    mov     esi, eax
    xor     ecx, ecx
    cmp     eax, esi
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_4B23BC
    lea     ecx, [esp+14h+var_4]
    call    sub_4E39B0
    mov     edx, dword_51FBC4
    mov     ecx, offset byte_51FBC0
    mov     eax, [edx+4]
    push    eax
    call    sub_4B2FB0
    mov     ecx, dword_51FBC4
    mov     edx, dword_51FBBC
    mov     [ecx+4], edx
    mov     eax, dword_51FBC4
    mov     dword_51FBCC, ebx
    lea     ecx, [esp+14h+var_4]
    mov     [eax], eax
    mov     eax, dword_51FBC4
    mov     [eax+8], eax
    call    sub_4E3A70
    jmp     short loc_4B23FB
    ; ---------------------------------------------------------------------------

    loc_4B23BC:                             ; CODE XREF: sub_4B2340+1Cj
                                            ; sub_4B2340+2Ej
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jz      short loc_4B2401

    loc_4B23CC:                             ; CODE XREF: sub_4B2340+B9j
    lea     ecx, [esp+14h+var_8]
    mov     esi, eax
    call    sub_4B3590
    lea     edx, [esp+14h+var_4]
    push    esi
    push    edx
    mov     ecx, offset byte_51FBC0
    call    sub_4B2AC0
    mov     eax, [esp+14h+var_8]
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_4B23CC

    loc_4B23FB:                             ; CODE XREF: sub_4B2340+7Aj
    mov     edi, dword_51FBC4

    loc_4B2401:                             ; CODE XREF: sub_4B2340+8Aj
    push    edi
    call    sub_4B4F20
    add     esp, 4
    lea     ecx, [esp+14h+var_4]
    mov     dword_51FBC4, ebx
    mov     dword_51FBCC, ebx
    call    sub_4E39B0
    mov     eax, dword_51FBB8
    dec     eax
    mov     dword_51FBB8, eax
    jnz     short loc_4B2440
    mov     eax, dword_51FBBC
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     dword_51FBBC, ebx

    loc_4B2440:                             ; CODE XREF: sub_4B2340+EAj
    lea     ecx, [esp+14h+var_4]
    call    sub_4E3A70
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    sub_4B2340 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B2450 proc near                    ; CODE XREF: sub_42D1F0+A4p
                                            ; sub_42D2E0+60Fp

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 10h
    push    esi
    push    edi
    mov     edi, [esp+18h+arg_0]
    push    0
    push    edi
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4B246F
    pop     edi
    pop     esi
    add     esp, 10h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B246F:                             ; CODE XREF: sub_4B2450+15j
    push    edi
    call    sub_4BBC40
    push    eax
    push    esi
    call    sub_4B6BA0
    mov     edi, eax
    lea     eax, [esp+18h+var_10]
    lea     ecx, [esp+18h+var_8]
    push    eax
    push    ecx
    mov     ecx, offset byte_51FBC0
    mov     [esp+20h+var_10], esi
    mov     [esp+20h+var_C], 0
    call    sub_4B2850
    xor     eax, eax
    mov     edx, [esp+18h+var_8]
    mov     [edx+10h], edi
    mov     edi, [esi+18h]
    mov     edx, [esi+1Ch]
    mov     ecx, [esi+4]
    add     edi, esi
    add     edx, esi
    test    ecx, ecx
    mov     [esi+18h], edi
    mov     [esi+1Ch], edx
    jle     short loc_4B24D3

    loc_4B24BE:                             ; CODE XREF: sub_4B2450+81j
    mov     ecx, [esi+1Ch]
    mov     edi, [ecx+eax*4]
    lea     ecx, [ecx+eax*4]
    add     edi, esi
    inc     eax
    mov     [ecx], edi
    mov     ecx, [esi+4]
    cmp     eax, ecx
    jl      short loc_4B24BE

    loc_4B24D3:                             ; CODE XREF: sub_4B2450+6Cj
    mov     edx, [esi+20h]
    mov     ecx, [esi+8]
    add     edx, esi
    xor     eax, eax
    test    ecx, ecx
    mov     [esi+20h], edx
    jle     short loc_4B24F9

    loc_4B24E4:                             ; CODE XREF: sub_4B2450+A7j
    mov     edx, [esi+20h]
    mov     edi, [edx+eax*4]
    lea     ecx, [edx+eax*4]
    add     edi, esi
    inc     eax
    mov     [ecx], edi
    mov     ecx, [esi+8]
    cmp     eax, ecx
    jl      short loc_4B24E4

    loc_4B24F9:                             ; CODE XREF: sub_4B2450+92j
    mov     edi, [esi+24h]
    mov     edx, [esi+28h]
    mov     ecx, [esi+14h]
    add     edi, esi
    add     edx, esi
    xor     eax, eax
    test    ecx, ecx
    mov     [esi+24h], edi
    mov     [esi+28h], edx
    jle     short loc_4B2529

    loc_4B2512:                             ; CODE XREF: sub_4B2450+D7j
    mov     ecx, [esi+28h]
    mov     edi, [ecx+eax*8+4]
    lea     ecx, [ecx+eax*8+4]
    add     edi, esi
    inc     eax
    mov     [ecx], edi
    mov     ecx, [esi+14h]
    cmp     eax, ecx
    jl      short loc_4B2512

    loc_4B2529:                             ; CODE XREF: sub_4B2450+C0j
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 10h
    retn    4
    sub_4B2450 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B2540 proc near                    ; CODE XREF: sub_42D1F0+85p
                                            ; sub_42DB90+ACp

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    sub     esp, 18h
    test    eax, eax
    jz      loc_4B26E1
    push    edi
    push    esi
    mov     [esp+20h+var_18], eax
    push    ebp
    lea     eax, [esp+24h+var_18]
    push    ebx
    push    eax
    mov     ecx, offset byte_51FBC0
    call    sub_4B3490
    lea     ecx, [esp+28h+var_18]
    mov     edi, eax
    push    ecx
    mov     ecx, offset byte_51FBC0
    call    sub_4B3430
    mov     ebp, eax
    xor     ebx, ebx
    cmp     ebp, edi
    mov     esi, ebp
    setz    bl
    neg     bl
    sbb     ebx, ebx
    inc     ebx
    test    bl, bl
    jz      short loc_4B25DB

    loc_4B258B:                             ; CODE XREF: sub_4B2540+99j
    lea     ecx, [esp+28h+var_10]
    call    sub_4E39B0
    mov     eax, [esi+8]
    mov     ecx, dword_51FBBC
    cmp     eax, ecx
    jz      short loc_4B25A9
    push    eax
    call    sub_4B3370
    jmp     short loc_4B25C0
    ; ---------------------------------------------------------------------------

    loc_4B25A9:                             ; CODE XREF: sub_4B2540+5Fj
    mov     eax, [esi+4]
    cmp     esi, [eax+8]
    jnz     short loc_4B25BB

    loc_4B25B1:                             ; CODE XREF: sub_4B2540+79j
    mov     esi, eax
    mov     eax, [eax+4]
    cmp     esi, [eax+8]
    jz      short loc_4B25B1

    loc_4B25BB:                             ; CODE XREF: sub_4B2540+6Fj
    cmp     [esi+8], eax
    jz      short loc_4B25C2

    loc_4B25C0:                             ; CODE XREF: sub_4B2540+67j
    mov     esi, eax

    loc_4B25C2:                             ; CODE XREF: sub_4B2540+7Ej
    lea     ecx, [esp+28h+var_10]
    call    sub_4E3A70
    xor     edx, edx
    cmp     esi, edi
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     short loc_4B258B

    loc_4B25DB:                             ; CODE XREF: sub_4B2540+49j
    mov     eax, dword_51FBCC
    mov     esi, ebp
    test    eax, eax
    mov     [esp+28h+var_14], esi
    jz      loc_4B269F
    mov     eax, dword_51FBC4
    xor     ecx, ecx
    cmp     ebp, [eax]
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     loc_4B269F
    xor     edx, edx
    cmp     edi, eax
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     loc_4B269F
    lea     ecx, [esp+28h+var_8]
    call    sub_4E39B0
    mov     eax, dword_51FBC4
    lea     ecx, [esp+28h+var_C]
    mov     edi, [eax+4]
    call    sub_4E39B0
    mov     eax, dword_51FBBC
    mov     esi, edi
    cmp     edi, eax
    jz      short loc_4B2664

    loc_4B2640:                             ; CODE XREF: sub_4B2540+122j
    mov     ecx, [esi+8]
    push    ecx
    mov     ecx, offset byte_51FBC0
    call    sub_4B2FB0
    mov     esi, [esi]
    push    edi
    call    sub_4B4F20
    mov     eax, dword_51FBBC
    add     esp, 4
    cmp     esi, eax
    mov     edi, esi
    jnz     short loc_4B2640

    loc_4B2664:                             ; CODE XREF: sub_4B2540+FEj
    lea     ecx, [esp+28h+var_C]
    call    sub_4E3A70
    mov     edx, dword_51FBC4
    mov     eax, dword_51FBBC
    lea     ecx, [esp+28h+var_8]
    mov     [edx+4], eax
    mov     eax, dword_51FBC4
    mov     dword_51FBCC, 0
    mov     [eax], eax
    mov     eax, dword_51FBC4
    mov     [eax+8], eax
    call    sub_4E3A70
    jmp     short loc_4B26D0
    ; ---------------------------------------------------------------------------

    loc_4B269F:                             ; CODE XREF: sub_4B2540+A8j
                                            ; sub_4B2540+C1j ...
    test    bl, bl
    jz      short loc_4B26D0

    loc_4B26A3:                             ; CODE XREF: sub_4B2540+18Ej
    lea     ecx, [esp+28h+var_14]
    call    sub_4B3590
    lea     ecx, [esp+28h+var_4]
    push    esi
    push    ecx
    mov     ecx, offset byte_51FBC0
    call    sub_4B2AC0
    mov     esi, [esp+28h+var_14]
    xor     edx, edx
    cmp     esi, edi
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     short loc_4B26A3

    loc_4B26D0:                             ; CODE XREF: sub_4B2540+15Dj
                                            ; sub_4B2540+161j
    mov     eax, [esp+28h+arg_0]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_4B26E1:                             ; CODE XREF: sub_4B2540+9j
    add     esp, 18h
    retn    4
    sub_4B2540 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B26F0 proc near                    ; CODE XREF: sub_4B0720+10p

    var_33= byte ptr -33h
    var_31= dword ptr -31h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 34h
    mov     eax, [esp+34h+arg_0]
    push    ebx
    push    esi
    push    edi
    mov     edi, dword_51FBC4
    mov     [esp+40h+var_18], eax
    mov     [esp+40h+var_14], 0
    lea     ecx, [esp+40h+var_2C]
    mov     esi, [edi+4]
    mov     bl, 1
    call    sub_4E39B0
    mov     ecx, dword_51FBBC
    cmp     esi, ecx
    jz      short loc_4B2743
    mov     eax, [esp+40h+var_18]

    loc_4B2728:                             ; CODE XREF: sub_4B26F0+51j
    mov     edx, [esi+0Ch]
    xor     ebx, ebx
    cmp     eax, edx
    mov     edi, esi
    setl    bl
    test    bl, bl
    jz      short loc_4B273C
    mov     esi, [esi]
    jmp     short loc_4B273F
    ; ---------------------------------------------------------------------------

    loc_4B273C:                             ; CODE XREF: sub_4B26F0+46j
    mov     esi, [esi+8]

    loc_4B273F:                             ; CODE XREF: sub_4B26F0+4Aj
    cmp     esi, ecx
    jnz     short loc_4B2728

    loc_4B2743:                             ; CODE XREF: sub_4B26F0+32j
    lea     ecx, [esp+40h+var_2C]
    call    sub_4E3A70
    mov     al, byte_51FBC8
    test    al, al
    jz      short loc_4B277A
    lea     ecx, [esp+40h+arg_0]
    lea     edx, [esp+40h+var_18]
    push    ecx
    push    edx
    push    edi
    lea     eax, [esp+4Ch+var_28]
    push    esi
    push    eax
    mov     ecx, offset byte_51FBC0
    mov     byte ptr [esp+54h+arg_0], 1
    call    sub_4B3020
    jmp     loc_4B2813
    ; ---------------------------------------------------------------------------

    loc_4B277A:                             ; CODE XREF: sub_4B26F0+63j
    test    bl, bl
    mov     [esp+40h+var_31+1], edi
    jz      short loc_4B27CD
    lea     ecx, [esp+40h+var_24]
    push    ecx
    mov     ecx, offset byte_51FBC0
    call    sub_4B2840
    mov     edx, eax
    xor     eax, eax
    mov     ecx, [esp+40h+var_31+1]
    cmp     ecx, [edx]
    setz    al
    test    al, al
    jz      short loc_4B27C4
    lea     edx, [esp+40h+var_33]
    lea     eax, [esp+40h+var_18]
    push    edx
    push    eax
    push    edi
    lea     ecx, [esp+4Ch+var_20]
    push    esi
    push    ecx
    mov     ecx, offset byte_51FBC0
    mov     [esp+54h+var_33], 1
    call    sub_4B3020
    jmp     short loc_4B2813
    ; ---------------------------------------------------------------------------

    loc_4B27C4:                             ; CODE XREF: sub_4B26F0+B0j
    lea     ecx, [esp+40h+var_31+1]
    call    sub_4B34F0

    loc_4B27CD:                             ; CODE XREF: sub_4B26F0+90j
    mov     eax, [esp+40h+var_31+1]
    mov     ebx, [esp+40h+var_18]
    xor     edx, edx
    mov     ecx, [eax+0Ch]
    cmp     ecx, ebx
    setl    dl
    test    dl, dl
    jz      short loc_4B2805
    lea     edx, [esp+0Eh]
    lea     eax, [esp+40h+var_18]
    push    edx
    push    eax
    push    edi
    lea     ecx, [esp+4Ch+var_1C]
    push    esi
    push    ecx
    mov     ecx, offset byte_51FBC0
    mov     byte ptr [esp+22h], 1
    call    sub_4B3020
    jmp     short loc_4B2813
    ; ---------------------------------------------------------------------------

    loc_4B2805:                             ; CODE XREF: sub_4B26F0+F1j
    lea     edx, [esp+40h+var_31]
    mov     byte ptr [esp+40h+var_31], 0
    push    edx
    lea     eax, [esp+44h+var_31+1]

    loc_4B2813:                             ; CODE XREF: sub_4B26F0+85j
                                            ; sub_4B26F0+D2j ...
    push    eax
    lea     ecx, [esp+48h+var_10]
    call    sub_4B3000
    lea     ecx, [esp+40h+var_C]
    lea     edx, [esp+40h+var_10]
    push    ecx
    push    edx
    lea     ecx, [esp+48h+var_8]
    call    sub_4B3000
    pop     edi
    pop     esi
    mov     eax, [esp+38h+var_8]
    pop     ebx
    mov     eax, [eax+10h]
    add     esp, 34h
    retn    4
    sub_4B26F0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B2840 proc near                    ; CODE XREF: sub_4B26F0+9Cp

    arg_0= dword ptr  4

    mov     eax, [ecx+4]
    mov     ecx, [eax]
    mov     eax, [esp+arg_0]
    mov     [eax], ecx
    retn    4
    sub_4B2840 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B2850 proc near                    ; CODE XREF: sub_4B2450+49p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    lea     ecx, [esp+20h+var_8]
    mov     edi, [ebp+4]
    mov     bl, 1
    mov     esi, [edi+4]
    call    sub_4E39B0
    mov     ecx, dword_51FBBC
    cmp     esi, ecx
    jz      short loc_4B2895
    mov     eax, [esp+20h+arg_4]
    mov     eax, [eax]

    loc_4B287A:                             ; CODE XREF: sub_4B2850+43j
    mov     edx, [esi+0Ch]
    xor     ebx, ebx
    cmp     eax, edx
    mov     edi, esi
    setl    bl
    test    bl, bl
    jz      short loc_4B288E
    mov     esi, [esi]
    jmp     short loc_4B2891
    ; ---------------------------------------------------------------------------

    loc_4B288E:                             ; CODE XREF: sub_4B2850+38j
    mov     esi, [esi+8]

    loc_4B2891:                             ; CODE XREF: sub_4B2850+3Cj
    cmp     esi, ecx
    jnz     short loc_4B287A

    loc_4B2895:                             ; CODE XREF: sub_4B2850+22j
    lea     ecx, [esp+20h+var_8]
    call    sub_4E3A70
    mov     al, [ebp+8]
    test    al, al
    jz      loc_4B2A42
    lea     ecx, [esp+20h+var_4]
    call    sub_4E39B0
    xor     ebx, ebx
    mov     ecx, ebp
    push    ebx
    push    edi
    call    sub_4B3410
    mov     ecx, dword_51FBBC
    mov     edx, eax
    mov     [esp+20h+var_10], edx
    mov     [edx], ecx
    mov     eax, dword_51FBBC
    mov     ecx, [esp+20h+arg_4]
    mov     [edx+8], eax
    lea     eax, [edx+0Ch]
    cmp     eax, ebx
    jz      short loc_4B28EC
    mov     edx, [ecx]
    mov     [eax], edx
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esp+20h+var_10]

    loc_4B28EC:                             ; CODE XREF: sub_4B2850+8Cj
    mov     eax, [ebp+0Ch]
    inc     eax
    mov     [ebp+0Ch], eax
    mov     eax, [ebp+4]
    cmp     edi, eax
    jz      short loc_4B2922
    cmp     esi, dword_51FBBC
    jnz     short loc_4B2922
    mov     eax, [ecx]
    mov     esi, [edi+0Ch]
    xor     ecx, ecx
    cmp     eax, esi
    setl    cl
    test    cl, cl
    jnz     short loc_4B2922
    mov     [edi+8], edx
    mov     eax, [ebp+4]
    cmp     edi, [eax+8]
    jnz     short loc_4B293C
    mov     [eax+8], edx
    jmp     short loc_4B293C
    ; ---------------------------------------------------------------------------

    loc_4B2922:                             ; CODE XREF: sub_4B2850+A8j
                                            ; sub_4B2850+B0j ...
    mov     [edi], edx
    mov     eax, [ebp+4]
    cmp     edi, eax
    jnz     short loc_4B2936
    mov     [eax+4], edx
    mov     eax, [ebp+4]
    mov     [eax+8], edx
    jmp     short loc_4B293C
    ; ---------------------------------------------------------------------------

    loc_4B2936:                             ; CODE XREF: sub_4B2850+D9j
    cmp     edi, [eax]
    jnz     short loc_4B293C
    mov     [eax], edx

    loc_4B293C:                             ; CODE XREF: sub_4B2850+CBj
                                            ; sub_4B2850+D0j ...
    mov     ecx, [ebp+4]
    mov     esi, edx
    cmp     edx, [ecx+4]
    jz      loc_4B2A14

    loc_4B294A:                             ; CODE XREF: sub_4B2850+1BEj
    mov     eax, [esi+4]
    cmp     [eax+14h], ebx
    jnz     loc_4B2A14
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     short loc_4B29B8
    mov     ecx, [edx+8]
    cmp     [ecx+14h], ebx
    jnz     short loc_4B2986
    mov     edx, 1
    mov     [eax+14h], edx
    mov     [ecx+14h], edx
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+14h], ebx
    mov     ecx, [esi+4]
    mov     esi, [ecx+4]
    jmp     loc_4B2A08
    ; ---------------------------------------------------------------------------

    loc_4B2986:                             ; CODE XREF: sub_4B2850+115j
    cmp     esi, [eax+8]
    jnz     short loc_4B2995
    mov     esi, eax
    mov     ecx, ebp
    push    esi
    call    sub_4B3310

    loc_4B2995:                             ; CODE XREF: sub_4B2850+139j
    mov     edx, [esi+4]
    mov     dword ptr [edx+14h], 1
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+14h], ebx
    mov     edx, [esi+4]
    mov     ecx, ebp
    mov     eax, [edx+4]
    push    eax
    call    sub_4B33B0
    jmp     short loc_4B2A08
    ; ---------------------------------------------------------------------------

    loc_4B29B8:                             ; CODE XREF: sub_4B2850+10Dj
    cmp     [ecx+14h], ebx
    jnz     short loc_4B29D9
    mov     edx, 1
    mov     [eax+14h], edx
    mov     [ecx+14h], edx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     [edx+14h], ebx
    mov     eax, [esi+4]
    mov     esi, [eax+4]
    jmp     short loc_4B2A08
    ; ---------------------------------------------------------------------------

    loc_4B29D9:                             ; CODE XREF: sub_4B2850+16Bj
    cmp     esi, [eax]
    jnz     short loc_4B29E7
    mov     esi, eax
    mov     ecx, ebp
    push    esi
    call    sub_4B33B0

    loc_4B29E7:                             ; CODE XREF: sub_4B2850+18Bj
    mov     ecx, [esi+4]
    mov     dword ptr [ecx+14h], 1
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+14h], ebx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     ecx, ebp
    push    edx
    call    sub_4B3310

    loc_4B2A08:                             ; CODE XREF: sub_4B2850+131j
                                            ; sub_4B2850+166j ...
    mov     eax, [ebp+4]
    cmp     esi, [eax+4]
    jnz     loc_4B294A

    loc_4B2A14:                             ; CODE XREF: sub_4B2850+F4j
                                            ; sub_4B2850+100j
    mov     ecx, [ebp+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+20h+var_4]
    mov     dword ptr [edx+14h], 1
    call    sub_4E3A70
    mov     eax, [esp+20h+arg_0]
    mov     ecx, [esp+20h+var_10]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B2A42:                             ; CODE XREF: sub_4B2850+53j
    mov     ecx, edi
    test    bl, bl
    mov     [esp+20h+var_C], ecx
    jz      short loc_4B2A75
    mov     edx, [ebp+4]
    xor     eax, eax
    cmp     edi, [edx]
    setz    al
    test    al, al
    jz      short loc_4B2A68
    mov     ecx, [esp+20h+arg_4]
    lea     edx, [esp+20h+arg_4]
    push    ecx
    push    edi
    push    esi
    push    edx
    jmp     short loc_4B2A8F
    ; ---------------------------------------------------------------------------

    loc_4B2A68:                             ; CODE XREF: sub_4B2850+208j
    lea     ecx, [esp+20h+var_C]
    call    sub_4B34F0
    mov     ecx, [esp+20h+var_C]

    loc_4B2A75:                             ; CODE XREF: sub_4B2850+1FAj
    mov     eax, [esp+20h+arg_4]
    mov     edx, [ecx+0Ch]
    xor     ebx, ebx
    cmp     edx, [eax]
    setl    bl
    test    bl, bl
    jz      short loc_4B2AAC
    push    eax
    push    edi
    lea     eax, [esp+28h+arg_4]
    push    esi
    push    eax

    loc_4B2A8F:                             ; CODE XREF: sub_4B2850+216j
    mov     ecx, ebp
    call    sub_4B3020
    mov     ecx, [eax]
    mov     eax, [esp+20h+arg_0]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B2AAC:                             ; CODE XREF: sub_4B2850+235j
    mov     eax, [esp+20h+arg_0]
    pop     edi
    pop     esi
    pop     ebp
    mov     [eax], ecx
    mov     byte ptr [eax+4], 0
    pop     ebx
    add     esp, 10h
    retn    8
    sub_4B2850 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B2AC0 proc near                    ; CODE XREF: sub_4B2340+A2p
                                            ; sub_4B2540+177p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    push    ebx
    push    ebp
    mov     [esp+1Ch+var_14], ecx
    push    esi
    push    edi
    mov     edi, [esp+24h+arg_4]
    lea     ecx, [esp+24h+arg_4]
    call    sub_4B3590
    mov     ebp, edi
    lea     ecx, [esp+24h+var_4]
    mov     [esp+24h+var_10], ebp
    call    sub_4E39B0
    mov     esi, [edi]
    mov     edx, dword_51FBBC
    lea     ebx, [edi+8]
    cmp     esi, edx
    mov     eax, ebx
    jnz     short loc_4B2AFC
    mov     esi, [ebx]
    jmp     short loc_4B2B37
    ; ---------------------------------------------------------------------------

    loc_4B2AFC:                             ; CODE XREF: sub_4B2AC0+36j
    mov     ecx, [ebx]
    cmp     ecx, edx
    jz      short loc_4B2B37
    mov     esi, ecx
    lea     ecx, [esp+24h+var_C]
    call    sub_4E39B0
    mov     eax, [esi]
    mov     ecx, dword_51FBBC
    cmp     eax, ecx
    jz      short loc_4B2B21

    loc_4B2B19:                             ; CODE XREF: sub_4B2AC0+5Fj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4B2B19

    loc_4B2B21:                             ; CODE XREF: sub_4B2AC0+57j
    lea     ecx, [esp+24h+var_C]
    call    sub_4E3A70
    lea     eax, [esi+8]
    mov     [esp+24h+var_10], esi
    mov     ebp, [esp+24h+var_10]
    mov     esi, [eax]

    loc_4B2B37:                             ; CODE XREF: sub_4B2AC0+3Aj
                                            ; sub_4B2AC0+40j
    cmp     ebp, edi
    jz      short loc_4B2B9E
    mov     ecx, [edi]
    mov     [ecx+4], ebp
    mov     edx, [edi]
    mov     [ebp+0], edx
    mov     ecx, [ebx]
    cmp     ebp, ecx
    jnz     short loc_4B2B50
    mov     [esi+4], ebp
    jmp     short loc_4B2B64
    ; ---------------------------------------------------------------------------

    loc_4B2B50:                             ; CODE XREF: sub_4B2AC0+89j
    mov     ecx, [ebp+4]
    mov     [esi+4], ecx
    mov     edx, [ebp+4]
    mov     [edx], esi
    mov     ecx, [ebx]
    mov     [eax], ecx
    mov     edx, [ebx]
    mov     [edx+4], ebp

    loc_4B2B64:                             ; CODE XREF: sub_4B2AC0+8Ej
    mov     eax, [esp+24h+var_14]
    mov     eax, [eax+4]
    cmp     [eax+4], edi
    jnz     short loc_4B2B75
    mov     [eax+4], ebp
    jmp     short loc_4B2B83
    ; ---------------------------------------------------------------------------

    loc_4B2B75:                             ; CODE XREF: sub_4B2AC0+AEj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_4B2B80
    mov     [eax], ebp
    jmp     short loc_4B2B83
    ; ---------------------------------------------------------------------------

    loc_4B2B80:                             ; CODE XREF: sub_4B2AC0+BAj
    mov     [eax+8], ebp

    loc_4B2B83:                             ; CODE XREF: sub_4B2AC0+B3j
                                            ; sub_4B2AC0+BEj
    mov     ecx, [edi+4]
    mov     [esp+24h+var_10], edi
    mov     [ebp+4], ecx
    mov     edx, [edi+14h]
    mov     eax, [ebp+14h]
    mov     [ebp+14h], edx
    mov     [edi+14h], eax
    jmp     loc_4B2C56
    ; ---------------------------------------------------------------------------

    loc_4B2B9E:                             ; CODE XREF: sub_4B2AC0+79j
    mov     eax, [ebp+4]
    mov     ebp, [esp+24h+var_14]
    mov     [esi+4], eax
    mov     eax, [ebp+4]
    cmp     [eax+4], edi
    jnz     short loc_4B2BB5
    mov     [eax+4], esi
    jmp     short loc_4B2BC3
    ; ---------------------------------------------------------------------------

    loc_4B2BB5:                             ; CODE XREF: sub_4B2AC0+EEj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_4B2BC0
    mov     [eax], esi
    jmp     short loc_4B2BC3
    ; ---------------------------------------------------------------------------

    loc_4B2BC0:                             ; CODE XREF: sub_4B2AC0+FAj
    mov     [eax+8], esi

    loc_4B2BC3:                             ; CODE XREF: sub_4B2AC0+F3j
                                            ; sub_4B2AC0+FEj
    mov     eax, [ebp+4]
    cmp     [eax], edi
    jnz     short loc_4B2C0A
    mov     ecx, [ebx]
    mov     edx, dword_51FBBC
    cmp     ecx, edx
    jnz     short loc_4B2BDD
    mov     edx, [edi+4]
    mov     [eax], edx
    jmp     short loc_4B2C0A
    ; ---------------------------------------------------------------------------

    loc_4B2BDD:                             ; CODE XREF: sub_4B2AC0+114j
    lea     ecx, [esp+24h+var_8]
    mov     ebx, esi
    call    sub_4E39B0
    mov     eax, [esi]
    mov     ecx, dword_51FBBC
    cmp     eax, ecx
    jz      short loc_4B2BFC

    loc_4B2BF4:                             ; CODE XREF: sub_4B2AC0+13Aj
    mov     ebx, eax
    mov     eax, [ebx]
    cmp     eax, ecx
    jnz     short loc_4B2BF4

    loc_4B2BFC:                             ; CODE XREF: sub_4B2AC0+132j
    lea     ecx, [esp+24h+var_8]
    call    sub_4E3A70
    mov     eax, [ebp+4]
    mov     [eax], ebx

    loc_4B2C0A:                             ; CODE XREF: sub_4B2AC0+108j
                                            ; sub_4B2AC0+11Bj
    mov     eax, [ebp+4]
    cmp     [eax+8], edi
    jnz     short loc_4B2C56
    mov     ecx, [edi]
    mov     edx, dword_51FBBC
    cmp     ecx, edx
    jnz     short loc_4B2C26
    mov     edx, [edi+4]
    mov     [eax+8], edx
    jmp     short loc_4B2C56
    ; ---------------------------------------------------------------------------

    loc_4B2C26:                             ; CODE XREF: sub_4B2AC0+15Cj
    lea     ecx, [esp+24h+var_8]
    mov     edi, esi
    call    sub_4E39B0
    mov     eax, [esi+8]
    mov     ecx, dword_51FBBC
    cmp     eax, ecx
    jz      short loc_4B2C47

    loc_4B2C3E:                             ; CODE XREF: sub_4B2AC0+185j
    mov     edi, eax
    mov     eax, [edi+8]
    cmp     eax, ecx
    jnz     short loc_4B2C3E

    loc_4B2C47:                             ; CODE XREF: sub_4B2AC0+17Cj
    lea     ecx, [esp+24h+var_8]
    call    sub_4E3A70
    mov     eax, [ebp+4]
    mov     [eax+8], edi

    loc_4B2C56:                             ; CODE XREF: sub_4B2AC0+D9j
                                            ; sub_4B2AC0+150j ...
    mov     ecx, [esp+24h+var_10]
    mov     ebp, 1
    cmp     [ecx+14h], ebp
    jnz     loc_4B2F6F
    mov     edx, [esp+24h+var_14]
    mov     eax, [edx+4]
    cmp     esi, [eax+4]
    jz      loc_4B2F6C
    xor     ebx, ebx

    loc_4B2C7A:                             ; CODE XREF: sub_4B2AC0+2E7j
    cmp     [esi+14h], ebp
    jnz     loc_4B2F6C
    mov     eax, [esi+4]
    mov     edi, [eax]
    cmp     esi, edi
    jnz     loc_4B2D17
    mov     edi, [eax+8]
    cmp     [edi+14h], ebx
    jnz     short loc_4B2CFB
    mov     [edi+14h], ebp
    mov     ecx, [esi+4]
    mov     [ecx+14h], ebx
    mov     edi, [esi+4]
    lea     ecx, [esp+24h+var_8]
    call    sub_4E39B0
    mov     eax, [edi+8]
    mov     edx, [eax]
    mov     [edi+8], edx
    mov     ecx, [eax]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B2CC2
    mov     [ecx+4], edi

    loc_4B2CC2:                             ; CODE XREF: sub_4B2AC0+1FDj
    mov     ecx, [edi+4]
    mov     edx, [esp+24h+var_14]
    mov     [eax+4], ecx
    mov     ecx, [edx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4B2CD9
    mov     [ecx+4], eax
    jmp     short loc_4B2CE7
    ; ---------------------------------------------------------------------------

    loc_4B2CD9:                             ; CODE XREF: sub_4B2AC0+212j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4B2CE4
    mov     [ecx], eax
    jmp     short loc_4B2CE7
    ; ---------------------------------------------------------------------------

    loc_4B2CE4:                             ; CODE XREF: sub_4B2AC0+21Ej
    mov     [ecx+8], eax

    loc_4B2CE7:                             ; CODE XREF: sub_4B2AC0+217j
                                            ; sub_4B2AC0+222j
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    sub_4E3A70
    mov     eax, [esi+4]
    mov     edi, [eax+8]

    loc_4B2CFB:                             ; CODE XREF: sub_4B2AC0+1D6j
    mov     ecx, [edi]
    cmp     [ecx+14h], ebp
    jnz     loc_4B2DB2
    mov     edx, [edi+8]
    cmp     [edx+14h], ebp
    jnz     loc_4B2DB2
    jmp     loc_4B2D97
    ; ---------------------------------------------------------------------------

    loc_4B2D17:                             ; CODE XREF: sub_4B2AC0+1CAj
    cmp     [edi+14h], ebx
    jnz     short loc_4B2D80
    mov     [edi+14h], ebp
    mov     eax, [esi+4]
    lea     ecx, [esp+24h+var_C]
    mov     [eax+14h], ebx
    mov     edi, [esi+4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B2D46
    mov     [ecx+4], edi

    loc_4B2D46:                             ; CODE XREF: sub_4B2AC0+281j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4B2D5D
    mov     [ecx+4], eax
    jmp     short loc_4B2D6C
    ; ---------------------------------------------------------------------------

    loc_4B2D5D:                             ; CODE XREF: sub_4B2AC0+296j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4B2D6A
    mov     [ecx+8], eax
    jmp     short loc_4B2D6C
    ; ---------------------------------------------------------------------------

    loc_4B2D6A:                             ; CODE XREF: sub_4B2AC0+2A3j
    mov     [ecx], eax

    loc_4B2D6C:                             ; CODE XREF: sub_4B2AC0+29Bj
                                            ; sub_4B2AC0+2A8j
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_C]
    mov     [edi+4], eax
    call    sub_4E3A70
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_4B2D80:                             ; CODE XREF: sub_4B2AC0+25Aj
    mov     eax, [edi+8]
    cmp     [eax+14h], ebp
    jnz     loc_4B2E9C
    mov     ecx, [edi]
    cmp     [ecx+14h], ebp
    jnz     loc_4B2E9C

    loc_4B2D97:                             ; CODE XREF: sub_4B2AC0+252j
    mov     edx, [esp+24h+var_14]
    mov     [edi+14h], ebx
    mov     esi, [esi+4]
    mov     eax, [edx+4]
    cmp     esi, [eax+4]
    jnz     loc_4B2C7A
    jmp     loc_4B2F6C
    ; ---------------------------------------------------------------------------

    loc_4B2DB2:                             ; CODE XREF: sub_4B2AC0+240j
                                            ; sub_4B2AC0+24Cj
    mov     ecx, [edi+8]
    cmp     [ecx+14h], ebp
    jnz     short loc_4B2E1B
    mov     edx, [edi]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+14h], ebp
    mov     [edi+14h], ebx
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B2DE0
    mov     [ecx+4], edi

    loc_4B2DE0:                             ; CODE XREF: sub_4B2AC0+31Bj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4B2DF7
    mov     [ecx+4], eax
    jmp     short loc_4B2E06
    ; ---------------------------------------------------------------------------

    loc_4B2DF7:                             ; CODE XREF: sub_4B2AC0+330j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4B2E04
    mov     [ecx+8], eax
    jmp     short loc_4B2E06
    ; ---------------------------------------------------------------------------

    loc_4B2E04:                             ; CODE XREF: sub_4B2AC0+33Dj
    mov     [ecx], eax

    loc_4B2E06:                             ; CODE XREF: sub_4B2AC0+335j
                                            ; sub_4B2AC0+342j
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    sub_4E3A70
    mov     edx, [esi+4]
    mov     edi, [edx+8]

    loc_4B2E1B:                             ; CODE XREF: sub_4B2AC0+2F8j
    mov     eax, [esi+4]
    mov     ecx, [eax+14h]
    mov     [edi+14h], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+14h], ebp
    mov     eax, [edi+8]
    mov     [eax+14h], ebp
    mov     edi, [esi+4]
    call    sub_4E39B0
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B2E51
    mov     [ecx+4], edi

    loc_4B2E51:                             ; CODE XREF: sub_4B2AC0+38Cj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4B2E74
    mov     [ecx+4], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4B2F67
    ; ---------------------------------------------------------------------------

    loc_4B2E74:                             ; CODE XREF: sub_4B2AC0+3A1j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4B2E8B
    mov     [ecx], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4B2F67
    ; ---------------------------------------------------------------------------

    loc_4B2E8B:                             ; CODE XREF: sub_4B2AC0+3B9j
    mov     [ecx+8], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4B2F67
    ; ---------------------------------------------------------------------------

    loc_4B2E9C:                             ; CODE XREF: sub_4B2AC0+2C6j
                                            ; sub_4B2AC0+2D1j
    mov     edx, [edi]
    cmp     [edx+14h], ebp
    jnz     short loc_4B2F02
    mov     eax, [edi+8]
    lea     ecx, [esp+24h+var_8]
    mov     [eax+14h], ebp
    mov     [edi+14h], ebx
    call    sub_4E39B0
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B2ECA
    mov     [ecx+4], edi

    loc_4B2ECA:                             ; CODE XREF: sub_4B2AC0+405j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4B2EE1
    mov     [ecx+4], eax
    jmp     short loc_4B2EEF
    ; ---------------------------------------------------------------------------

    loc_4B2EE1:                             ; CODE XREF: sub_4B2AC0+41Aj
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4B2EEC
    mov     [ecx], eax
    jmp     short loc_4B2EEF
    ; ---------------------------------------------------------------------------

    loc_4B2EEC:                             ; CODE XREF: sub_4B2AC0+426j
    mov     [ecx+8], eax

    loc_4B2EEF:                             ; CODE XREF: sub_4B2AC0+41Fj
                                            ; sub_4B2AC0+42Aj
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    sub_4E3A70
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_4B2F02:                             ; CODE XREF: sub_4B2AC0+3E1j
    mov     eax, [esi+4]
    mov     ecx, [eax+14h]
    mov     [edi+14h], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+14h], ebp
    mov     eax, [edi]
    mov     [eax+14h], ebp
    mov     edi, [esi+4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B2F37
    mov     [ecx+4], edi

    loc_4B2F37:                             ; CODE XREF: sub_4B2AC0+472j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4B2F4E
    mov     [ecx+4], eax
    jmp     short loc_4B2F5D
    ; ---------------------------------------------------------------------------

    loc_4B2F4E:                             ; CODE XREF: sub_4B2AC0+487j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4B2F5B
    mov     [ecx+8], eax
    jmp     short loc_4B2F5D
    ; ---------------------------------------------------------------------------

    loc_4B2F5B:                             ; CODE XREF: sub_4B2AC0+494j
    mov     [ecx], eax

    loc_4B2F5D:                             ; CODE XREF: sub_4B2AC0+48Cj
                                            ; sub_4B2AC0+499j
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]

    loc_4B2F67:                             ; CODE XREF: sub_4B2AC0+3AFj
                                            ; sub_4B2AC0+3C6j ...
    call    sub_4E3A70

    loc_4B2F6C:                             ; CODE XREF: sub_4B2AC0+1B2j
                                            ; sub_4B2AC0+1BDj ...
    mov     [esi+14h], ebp

    loc_4B2F6F:                             ; CODE XREF: sub_4B2AC0+1A2j
    mov     edx, [esp+24h+var_10]
    push    edx
    call    sub_4B4F20
    mov     eax, [esp+28h+var_14]
    mov     esi, [esp+28h+arg_0]
    add     esp, 4
    mov     ecx, [eax+0Ch]
    dec     ecx
    mov     [eax+0Ch], ecx
    mov     eax, [esp+24h+arg_4]
    lea     ecx, [esp+24h+var_4]
    mov     [esi], eax
    call    sub_4E3A70
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    sub_4B2AC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B2FB0 proc near                    ; CODE XREF: sub_4B2340+48p
                                            ; sub_4B2540+109p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    lea     ecx, [esp+10h+var_4]
    call    sub_4E39B0
    mov     edi, [esp+10h+arg_0]
    mov     eax, dword_51FBBC
    cmp     edi, eax
    mov     esi, edi
    jz      short loc_4B2FEF

    loc_4B2FCE:                             ; CODE XREF: sub_4B2FB0+3Dj
    mov     eax, [esi+8]
    mov     ecx, ebx
    push    eax
    call    sub_4B2FB0
    mov     esi, [esi]
    push    edi
    call    sub_4B4F20
    mov     eax, dword_51FBBC
    add     esp, 4
    cmp     esi, eax
    mov     edi, esi
    jnz     short loc_4B2FCE

    loc_4B2FEF:                             ; CODE XREF: sub_4B2FB0+1Cj
    lea     ecx, [esp+10h+var_4]
    call    sub_4E3A70
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    sub_4B2FB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3000 proc near                    ; CODE XREF: sub_4B26F0+128p
                                            ; sub_4B26F0+13Bp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     edx, [ecx]
    mov     ecx, [esp+arg_4]
    mov     [eax], edx
    mov     dl, [ecx]
    mov     [eax+4], dl
    retn    8
    sub_4B3000 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3020 proc near                    ; CODE XREF: sub_4B26F0+80p
                                            ; sub_4B26F0+CDp ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebx, ecx
    push    esi
    push    edi
    lea     ecx, [esp+1Ch+var_4]
    call    sub_4E39B0
    push    18h                             ; int
    call    sub_4B4F10
    mov     edi, eax
    mov     eax, [esp+20h+arg_8]
    add     esp, 4
    mov     [esp+1Ch+var_C], edi
    mov     [edi+4], eax
    mov     dword ptr [edi+14h], 0
    mov     ecx, dword_51FBBC
    mov     [edi], ecx
    mov     edx, dword_51FBBC
    lea     ecx, [edi+0Ch]
    mov     [edi+8], edx
    mov     edx, [esp+1Ch+arg_C]
    test    ecx, ecx
    jz      short loc_4B3076
    mov     esi, [edx]
    mov     [ecx], esi
    mov     esi, [edx+4]
    mov     [ecx+4], esi

    loc_4B3076:                             ; CODE XREF: sub_4B3020+4Aj
    mov     esi, [ebx+0Ch]
    mov     ecx, [ebx+4]
    inc     esi
    cmp     eax, ecx
    mov     [ebx+0Ch], esi
    jz      short loc_4B30B2
    mov     ecx, [esp+1Ch+arg_4]
    mov     esi, dword_51FBBC
    cmp     ecx, esi
    jnz     short loc_4B30B2
    mov     edx, [edx]
    mov     esi, [eax+0Ch]
    xor     ecx, ecx
    cmp     edx, esi
    setl    cl
    test    cl, cl
    jnz     short loc_4B30B2
    mov     [eax+8], edi
    mov     ecx, [ebx+4]
    cmp     eax, [ecx+8]
    jnz     short loc_4B30CC
    mov     [ecx+8], edi
    jmp     short loc_4B30CC
    ; ---------------------------------------------------------------------------

    loc_4B30B2:                             ; CODE XREF: sub_4B3020+62j
                                            ; sub_4B3020+70j ...
    mov     [eax], edi
    mov     ecx, [ebx+4]
    cmp     eax, ecx
    jnz     short loc_4B30C6
    mov     [ecx+4], edi
    mov     edx, [ebx+4]
    mov     [edx+8], edi
    jmp     short loc_4B30CC
    ; ---------------------------------------------------------------------------

    loc_4B30C6:                             ; CODE XREF: sub_4B3020+99j
    cmp     eax, [ecx]
    jnz     short loc_4B30CC
    mov     [ecx], edi

    loc_4B30CC:                             ; CODE XREF: sub_4B3020+8Bj
                                            ; sub_4B3020+90j ...
    mov     eax, [ebx+4]
    mov     esi, edi
    mov     ebp, 1
    cmp     edi, [eax+4]
    jz      loc_4B32E8

    loc_4B30DF:                             ; CODE XREF: sub_4B3020+2C2j
    mov     eax, [esi+4]
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     loc_4B32E8
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     loc_4B31F8
    mov     ecx, [edx+8]
    mov     edx, [ecx+14h]
    test    edx, edx
    jnz     short loc_4B3122
    mov     [eax+14h], ebp
    mov     [ecx+14h], ebp
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     dword ptr [edx+14h], 0
    mov     eax, [esi+4]
    mov     esi, [eax+4]
    jmp     loc_4B32DC
    ; ---------------------------------------------------------------------------

    loc_4B3122:                             ; CODE XREF: sub_4B3020+E2j
    cmp     esi, [eax+8]
    jnz     short loc_4B3176
    lea     ecx, [esp+1Ch+arg_8]
    mov     esi, eax
    call    sub_4E39B0
    mov     eax, [esi+8]
    mov     ecx, [eax]
    mov     [esi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B3147
    mov     [ecx+4], esi

    loc_4B3147:                             ; CODE XREF: sub_4B3020+122j
    mov     edx, [esi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     esi, [ecx+4]
    jnz     short loc_4B315A
    mov     [ecx+4], eax
    jmp     short loc_4B3168
    ; ---------------------------------------------------------------------------

    loc_4B315A:                             ; CODE XREF: sub_4B3020+133j
    mov     ecx, [esi+4]
    cmp     esi, [ecx]
    jnz     short loc_4B3165
    mov     [ecx], eax
    jmp     short loc_4B3168
    ; ---------------------------------------------------------------------------

    loc_4B3165:                             ; CODE XREF: sub_4B3020+13Fj
    mov     [ecx+8], eax

    loc_4B3168:                             ; CODE XREF: sub_4B3020+138j
                                            ; sub_4B3020+143j
    mov     [eax], esi
    lea     ecx, [esp+1Ch+arg_8]
    mov     [esi+4], eax
    call    sub_4E3A70

    loc_4B3176:                             ; CODE XREF: sub_4B3020+105j
    mov     eax, [esi+4]
    mov     [eax+14h], ebp
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+arg_C]
    mov     dword ptr [edx+14h], 0
    mov     eax, [esi+4]
    mov     edi, [eax+4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B31AD
    mov     [ecx+4], edi

    loc_4B31AD:                             ; CODE XREF: sub_4B3020+188j
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4B31CD
    mov     [ecx+4], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4B32D3
    ; ---------------------------------------------------------------------------

    loc_4B31CD:                             ; CODE XREF: sub_4B3020+199j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4B31E7
    mov     [ecx+8], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4B32D3
    ; ---------------------------------------------------------------------------

    loc_4B31E7:                             ; CODE XREF: sub_4B3020+1B3j
    mov     [ecx], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4B32D3
    ; ---------------------------------------------------------------------------

    loc_4B31F8:                             ; CODE XREF: sub_4B3020+D4j
    mov     edx, [ecx+14h]
    test    edx, edx
    jnz     short loc_4B321D
    mov     [eax+14h], ebp
    mov     [ecx+14h], ebp
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     dword ptr [ecx+14h], 0
    mov     edx, [esi+4]
    mov     esi, [edx+4]
    jmp     loc_4B32DC
    ; ---------------------------------------------------------------------------

    loc_4B321D:                             ; CODE XREF: sub_4B3020+1DDj
    cmp     esi, [eax]
    jnz     short loc_4B3272
    lea     ecx, [esp+1Ch+arg_4]
    mov     esi, eax
    call    sub_4E39B0
    mov     eax, [esi]
    mov     ecx, [eax+8]
    mov     [esi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B3241
    mov     [ecx+4], esi

    loc_4B3241:                             ; CODE XREF: sub_4B3020+21Cj
    mov     edx, [esi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     esi, [ecx+4]
    jnz     short loc_4B3254
    mov     [ecx+4], eax
    jmp     short loc_4B3263
    ; ---------------------------------------------------------------------------

    loc_4B3254:                             ; CODE XREF: sub_4B3020+22Dj
    mov     ecx, [esi+4]
    cmp     esi, [ecx+8]
    jnz     short loc_4B3261
    mov     [ecx+8], eax
    jmp     short loc_4B3263
    ; ---------------------------------------------------------------------------

    loc_4B3261:                             ; CODE XREF: sub_4B3020+23Aj
    mov     [ecx], eax

    loc_4B3263:                             ; CODE XREF: sub_4B3020+232j
                                            ; sub_4B3020+23Fj
    mov     [eax+8], esi
    lea     ecx, [esp+1Ch+arg_4]
    mov     [esi+4], eax
    call    sub_4E3A70

    loc_4B3272:                             ; CODE XREF: sub_4B3020+1FFj
    mov     eax, [esi+4]
    mov     [eax+14h], ebp
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+var_8]
    mov     dword ptr [edx+14h], 0
    mov     eax, [esi+4]
    mov     edi, [eax+4]
    call    sub_4E39B0
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_51FBBC
    jz      short loc_4B32A9
    mov     [ecx+4], edi

    loc_4B32A9:                             ; CODE XREF: sub_4B3020+284j
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4B32BC
    mov     [ecx+4], eax
    jmp     short loc_4B32CA
    ; ---------------------------------------------------------------------------

    loc_4B32BC:                             ; CODE XREF: sub_4B3020+295j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4B32C7
    mov     [ecx], eax
    jmp     short loc_4B32CA
    ; ---------------------------------------------------------------------------

    loc_4B32C7:                             ; CODE XREF: sub_4B3020+2A1j
    mov     [ecx+8], eax

    loc_4B32CA:                             ; CODE XREF: sub_4B3020+29Aj
                                            ; sub_4B3020+2A5j
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+var_8]

    loc_4B32D3:                             ; CODE XREF: sub_4B3020+1A8j
                                            ; sub_4B3020+1C2j ...
    call    sub_4E3A70
    mov     edi, [esp+1Ch+var_C]

    loc_4B32DC:                             ; CODE XREF: sub_4B3020+FDj
                                            ; sub_4B3020+1F8j
    mov     eax, [ebx+4]
    cmp     esi, [eax+4]
    jnz     loc_4B30DF

    loc_4B32E8:                             ; CODE XREF: sub_4B3020+B9j
                                            ; sub_4B3020+C7j
    mov     ecx, [ebx+4]
    mov     esi, [esp+1Ch+arg_0]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+var_4]
    mov     [edx+14h], ebp
    mov     [esi], edi
    call    sub_4E3A70
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    10h
    sub_4B3020 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3310 proc near                    ; CODE XREF: sub_4B2850+140p
                                            ; sub_4B2850+1B3p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    sub_4E39B0
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx+8]
    mov     edx, [eax]
    mov     [ecx+8], edx
    mov     edx, [eax]
    cmp     edx, dword_51FBBC
    jz      short loc_4B3336
    mov     [edx+4], ecx

    loc_4B3336:                             ; CODE XREF: sub_4B3310+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_4B3349
    mov     [edx+4], eax
    jmp     short loc_4B3357
    ; ---------------------------------------------------------------------------

    loc_4B3349:                             ; CODE XREF: sub_4B3310+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx]
    jnz     short loc_4B3354
    mov     [edx], eax
    jmp     short loc_4B3357
    ; ---------------------------------------------------------------------------

    loc_4B3354:                             ; CODE XREF: sub_4B3310+3Ej
    mov     [edx+8], eax

    loc_4B3357:                             ; CODE XREF: sub_4B3310+37j
                                            ; sub_4B3310+42j
    mov     [eax], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    sub_4E3A70
    pop     esi
    pop     ecx
    retn    4
    sub_4B3310 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3370 proc near                    ; CODE XREF: sub_4B2540+62p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    lea     ecx, [esp+8+var_4]
    call    sub_4E39B0
    mov     esi, [esp+8+arg_0]
    mov     ecx, dword_51FBBC
    mov     eax, [esi]
    cmp     eax, ecx
    jz      short loc_4B3393

    loc_4B338B:                             ; CODE XREF: sub_4B3370+21j
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4B338B

    loc_4B3393:                             ; CODE XREF: sub_4B3370+19j
    lea     ecx, [esp+8+var_4]
    call    sub_4E3A70
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_4B3370 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B33B0 proc near                    ; CODE XREF: sub_4B2850+161p
                                            ; sub_4B2850+192p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    sub_4E39B0
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx]
    mov     edx, [eax+8]
    mov     [ecx], edx
    mov     edx, [eax+8]
    cmp     edx, dword_51FBBC
    jz      short loc_4B33D6
    mov     [edx+4], ecx

    loc_4B33D6:                             ; CODE XREF: sub_4B33B0+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_4B33E9
    mov     [edx+4], eax
    jmp     short loc_4B33F8
    ; ---------------------------------------------------------------------------

    loc_4B33E9:                             ; CODE XREF: sub_4B33B0+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx+8]
    jnz     short loc_4B33F6
    mov     [edx+8], eax
    jmp     short loc_4B33F8
    ; ---------------------------------------------------------------------------

    loc_4B33F6:                             ; CODE XREF: sub_4B33B0+3Fj
    mov     [edx], eax

    loc_4B33F8:                             ; CODE XREF: sub_4B33B0+37j
                                            ; sub_4B33B0+44j
    mov     [eax+8], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    sub_4E3A70
    pop     esi
    pop     ecx
    retn    4
    sub_4B33B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3410 proc near                    ; CODE XREF: sub_4B2850+68p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    18h                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+4+arg_0]
    mov     edx, [esp+4+arg_4]
    add     esp, 4
    mov     [eax+4], ecx
    mov     [eax+14h], edx
    retn    8
    sub_4B3410 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3430 proc near                    ; CODE XREF: sub_4B2540+32p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    sub_4E39B0
    mov     ecx, [esi+4]
    mov     esi, ecx
    mov     eax, [ecx+4]
    mov     ecx, dword_51FBBC
    cmp     eax, ecx
    jz      short loc_4B3474
    mov     edx, [esp+8+arg_0]
    push    edi
    push    ebx
    mov     edi, [edx]

    loc_4B3457:                             ; CODE XREF: sub_4B3430+40j
    mov     ebx, [eax+0Ch]
    xor     edx, edx
    cmp     ebx, edi
    setl    dl
    test    dl, dl
    jz      short loc_4B346A
    mov     eax, [eax+8]
    jmp     short loc_4B346E
    ; ---------------------------------------------------------------------------

    loc_4B346A:                             ; CODE XREF: sub_4B3430+33j
    mov     esi, eax
    mov     eax, [eax]

    loc_4B346E:                             ; CODE XREF: sub_4B3430+38j
    cmp     eax, ecx
    jnz     short loc_4B3457
    pop     ebx
    pop     edi

    loc_4B3474:                             ; CODE XREF: sub_4B3430+1Dj
    lea     ecx, [esp+8+var_4]
    call    sub_4E3A70
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_4B3430 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3490 proc near                    ; CODE XREF: sub_4B2540+21p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    sub_4E39B0
    mov     ecx, [esi+4]
    mov     esi, ecx
    mov     eax, [ecx+4]
    mov     ecx, dword_51FBBC
    cmp     eax, ecx
    jz      short loc_4B34D4
    mov     edx, [esp+8+arg_0]
    push    edi
    push    ebx
    mov     edi, [edx]

    loc_4B34B7:                             ; CODE XREF: sub_4B3490+40j
    mov     ebx, [eax+0Ch]
    xor     edx, edx
    cmp     edi, ebx
    setl    dl
    test    dl, dl
    jz      short loc_4B34CB
    mov     esi, eax
    mov     eax, [eax]
    jmp     short loc_4B34CE
    ; ---------------------------------------------------------------------------

    loc_4B34CB:                             ; CODE XREF: sub_4B3490+33j
    mov     eax, [eax+8]

    loc_4B34CE:                             ; CODE XREF: sub_4B3490+39j
    cmp     eax, ecx
    jnz     short loc_4B34B7
    pop     ebx
    pop     edi

    loc_4B34D4:                             ; CODE XREF: sub_4B3490+1Dj
    lea     ecx, [esp+8+var_4]
    call    sub_4E3A70
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_4B3490 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B34F0 proc near                    ; CODE XREF: sub_4B26F0+D8p
                                            ; sub_4B2850+21Cp

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_4B3525
    mov     ecx, [eax+4]
    cmp     [ecx+4], eax
    jnz     short loc_4B3525
    mov     edx, [eax+8]
    lea     ecx, [esp+10h+var_4]
    mov     [edi], edx
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4B3525:                             ; CODE XREF: sub_4B34F0+17j
                                            ; sub_4B34F0+1Fj
    mov     esi, [eax]
    mov     ecx, dword_51FBBC
    cmp     esi, ecx
    jz      short loc_4B356A
    lea     ecx, [esp+10h+var_8]
    call    sub_4E39B0
    mov     eax, [esi+8]
    mov     ecx, dword_51FBBC
    cmp     eax, ecx
    jz      short loc_4B3550

    loc_4B3547:                             ; CODE XREF: sub_4B34F0+5Ej
    mov     esi, eax
    mov     eax, [esi+8]
    cmp     eax, ecx
    jnz     short loc_4B3547

    loc_4B3550:                             ; CODE XREF: sub_4B34F0+55j
    lea     ecx, [esp+10h+var_8]
    call    sub_4E3A70
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4B356A:                             ; CODE XREF: sub_4B34F0+3Fj
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax]
    jnz     short loc_4B357E

    loc_4B3573:                             ; CODE XREF: sub_4B34F0+8Cj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax]
    jz      short loc_4B3573

    loc_4B357E:                             ; CODE XREF: sub_4B34F0+81j
    lea     ecx, [esp+10h+var_4]
    mov     [edi], eax
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4B34F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3590 proc near                    ; CODE XREF: sub_4B2340+92p
                                            ; sub_4B2540+167p ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    sub_4E39B0
    mov     eax, [edi]
    mov     ecx, dword_51FBBC
    mov     esi, [eax+8]
    cmp     esi, ecx
    jz      short loc_4B35E6
    lea     ecx, [esp+10h+var_8]
    call    sub_4E39B0
    mov     eax, [esi]
    mov     ecx, dword_51FBBC
    cmp     eax, ecx
    jz      short loc_4B35CC

    loc_4B35C4:                             ; CODE XREF: sub_4B3590+3Aj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4B35C4

    loc_4B35CC:                             ; CODE XREF: sub_4B3590+32j
    lea     ecx, [esp+10h+var_8]
    call    sub_4E3A70
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4B35E6:                             ; CODE XREF: sub_4B3590+1Dj
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax+8]
    jnz     short loc_4B35FC

    loc_4B35F0:                             ; CODE XREF: sub_4B3590+6Aj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax+8]
    jz      short loc_4B35F0

    loc_4B35FC:                             ; CODE XREF: sub_4B3590+5Ej
    mov     ecx, [edi]
    cmp     [ecx+8], eax
    jz      short loc_4B3605
    mov     [edi], eax

    loc_4B3605:                             ; CODE XREF: sub_4B3590+71j
    lea     ecx, [esp+10h+var_4]
    call    sub_4E3A70
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4B3590 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3620 proc near                    ; CODE XREF: sub_42A8D0+2F2p
                                            ; sub_432520+11p ...
    mov     eax, ecx
    mov     dword ptr [eax], 0
    retn
    sub_4B3620 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3630 proc near                    ; CODE XREF: sub_42A8D0+8C2p
                                            ; sub_42A8D0+902p ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebp
    push    esi
    mov     esi, ecx
    xor     ebp, ebp
    mov     [esp+10h+var_4], esi
    mov     eax, [esi]
    cmp     eax, ebp
    jz      loc_4B3743
    mov     ecx, [eax]
    push    edi
    cmp     ecx, ebp
    push    ebx
    mov     [esp+18h+var_8], ebp
    jle     loc_4B3724

    loc_4B3657:                             ; CODE XREF: sub_4B3630+EEj
    mov     esi, [eax+4]
    mov     eax, [esi+ebp]
    add     esi, ebp
    push    eax                             ; int
    call    sub_4D85A0
    mov     eax, [esi+10h]
    add     esp, 4
    test    eax, eax
    jz      short loc_4B36B7
    mov     eax, [esi+4]
    xor     ebx, ebx
    test    eax, eax
    jle     short loc_4B36AB
    xor     edi, edi

    loc_4B367A:                             ; CODE XREF: sub_4B3630+79j
    mov     ecx, [esi+10h]
    mov     edx, [ecx+edi]
    push    edx                             ; int
    call    sub_4D85A0
    mov     eax, [esi+10h]
    add     esp, 4
    add     eax, edi
    cmp     dword ptr [eax+4], 3
    jnz     short loc_4B36A0
    mov     ecx, [eax+8]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B36A0:                             ; CODE XREF: sub_4B3630+62j
    mov     eax, [esi+4]
    inc     ebx
    add     edi, 10h
    cmp     ebx, eax
    jl      short loc_4B367A

    loc_4B36AB:                             ; CODE XREF: sub_4B3630+46j
    mov     edx, [esi+10h]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B36B7:                             ; CODE XREF: sub_4B3630+3Dj
    mov     eax, [esi+14h]
    test    eax, eax
    jz      short loc_4B370A
    mov     eax, [esi+8]
    xor     ebx, ebx
    test    eax, eax
    jle     short loc_4B36FE
    xor     edi, edi

    loc_4B36C9:                             ; CODE XREF: sub_4B3630+CCj
    mov     eax, [esi+14h]
    add     eax, edi
    cmp     dword ptr [eax], 0
    jz      short loc_4B36DF
    mov     ecx, [eax+4]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B36DF:                             ; CODE XREF: sub_4B3630+A1j
    mov     edx, [esi+14h]
    mov     eax, [edi+edx+10h]
    test    eax, eax
    jz      short loc_4B36F3
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B36F3:                             ; CODE XREF: sub_4B3630+B8j
    mov     eax, [esi+8]
    inc     ebx
    add     edi, 14h
    cmp     ebx, eax
    jl      short loc_4B36C9

    loc_4B36FE:                             ; CODE XREF: sub_4B3630+95j
    mov     eax, [esi+14h]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B370A:                             ; CODE XREF: sub_4B3630+8Cj
    mov     esi, [esp+18h+var_4]
    mov     ecx, [esp+18h+var_8]
    inc     ecx
    add     ebp, 18h
    mov     eax, [esi]
    mov     [esp+18h+var_8], ecx
    cmp     ecx, [eax]
    jl      loc_4B3657

    loc_4B3724:                             ; CODE XREF: sub_4B3630+21j
    mov     ecx, [esi]
    mov     eax, [ecx+4]
    test    eax, eax
    jz      short loc_4B3736
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B3736:                             ; CODE XREF: sub_4B3630+FBj
    mov     edx, [esi]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     ebx
    pop     edi

    loc_4B3743:                             ; CODE XREF: sub_4B3630+11j
    pop     esi
    pop     ebp
    add     esp, 8
    retn
    sub_4B3630 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3750 proc near                    ; CODE XREF: sub_4326B0+14p
    push    esi
    mov     esi, ecx
    call    sub_4B3630
    push    0Ch
    push    1
    call    sub_4D8460
    add     esp, 8
    mov     [esi], eax
    mov     dword ptr [eax+8], 0FFFFFFFFh
    pop     esi
    retn
    sub_4B3750 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3770 proc near                    ; CODE XREF: sub_42A8D0+32Ap
                                            ; sub_432520+30p ...

    var_B4= dword ptr -0B4h
    var_B0= dword ptr -0B0h
    var_AC= dword ptr -0ACh
    var_A8= dword ptr -0A8h
    var_A4= byte ptr -0A4h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= byte ptr -8Ch
    Text= byte ptr -80h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0B4h
    mov     eax, [esp+0B4h+arg_0]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    push    eax
    mov     [esp+0C8h+var_A8], edi
    call    sub_4BB5B0
    mov     ebp, eax
    xor     ebx, ebx
    cmp     ebp, ebx
    jnz     short loc_4B37A4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0B4h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B37A4:                             ; CODE XREF: sub_4B3770+23j
    lea     ecx, [esp+0C4h+var_A4]
    push    22h
    push    ecx
    push    ebp
    call    sub_4BB7C0
    push    8                               ; size_t
    lea     edx, [esp+0C8h+var_A4]
    push    offset aHapibank                ; char *
    push    edx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4B37DE
    push    ebp
    call    sub_4BB5D0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0B4h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B37DE:                             ; CODE XREF: sub_4B3770+57j
    cmp     [esp+0C4h+var_90], 1
    jz      short loc_4B37FA
    push    ebp
    call    sub_4BB5D0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0B4h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B37FA:                             ; CODE XREF: sub_4B3770+73j
    push    ebp
    mov     [esp+0C8h+var_B4], ebx
    mov     [esp+0C8h+var_B0], ebx
    call    sub_4BBD00
    mov     esi, eax
    mov     eax, [esp+0C4h+var_98]
    push    eax
    push    ebp
    sub     esi, eax
    call    sub_4BB710
    mov     al, [esp+0C4h+var_8C]
    test    al, al
    jz      loc_4B38C1
    push    esi
    call    sub_4D8450
    add     esp, 4
    mov     ebx, eax
    push    esi
    push    ebx
    push    ebp
    call    sub_4BB7C0
    push    ebx
    call    sub_4D1B40
    mov     esi, eax
    push    esi
    call    sub_4D8450
    add     esp, 4
    mov     edi, eax
    mov     [esp+0C4h+var_AC], edi
    push    ebx
    push    edi
    call    sub_4D1970
    test    eax, eax
    jz      short loc_4B387B
    push    eax
    call    sub_4D1C60
    push    eax
    lea     eax, [esp+0C8h+Text]
    push    offset aHapibankOpenba          ; "[HapiBank::OpenBank] Decompression Erro"...
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [esp+0C4h+Text]
    push    ecx                             ; lpText
    call    sub_4B6290

    loc_4B387B:                             ; CODE XREF: sub_4B3770+E6j
    mov     edx, [esp+0C4h+var_B4]
    push    esi
    push    edx
    call    sub_4D8580
    mov     [esp+0CCh+var_B0], esi
    mov     ecx, esi
    mov     esi, edi
    mov     [esp+0CCh+var_B4], eax
    mov     edi, eax
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    add     esp, 8
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+0C4h+var_AC]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    ebx                             ; int
    call    sub_4D85A0
    mov     edi, [esp+0C8h+var_A8]
    add     esp, 4
    jmp     short loc_4B38EB
    ; ---------------------------------------------------------------------------

    loc_4B38C1:                             ; CODE XREF: sub_4B3770+ADj
    mov     eax, [esp+0C4h+var_B4]
    cmp     eax, ebx
    jz      short loc_4B38D2
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B38D2:                             ; CODE XREF: sub_4B3770+157j
    push    esi
    call    sub_4D8450
    add     esp, 4
    mov     [esp+0C4h+var_B4], eax
    mov     [esp+0C4h+var_B0], esi
    push    esi
    push    eax
    push    ebp
    call    sub_4BB7C0

    loc_4B38EB:                             ; CODE XREF: sub_4B3770+14Fj
    mov     eax, [esp+0C4h+arg_4]
    test    eax, eax
    jz      short loc_4B3934
    mov     edx, [esp+0C4h+var_B4]
    mov     ecx, [esp+0C4h+var_9C]
    add     edx, ecx
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4B3934
    push    ebp
    call    sub_4BB5D0
    mov     eax, [esp+0C4h+var_B4]
    test    eax, eax
    jz      short loc_4B3925
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B3925:                             ; CODE XREF: sub_4B3770+1AAj
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0B4h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B3934:                             ; CODE XREF: sub_4B3770+184j
                                            ; sub_4B3770+19Cj
    mov     ecx, edi
    call    sub_4B3630
    push    0Ch
    push    1
    call    sub_4D8460
    mov     [edi], eax
    add     esp, 8
    mov     dword ptr [eax+8], 0FFFFFFFFh
    mov     edx, [esp+0C4h+var_94]
    push    edx
    push    ebp
    call    sub_4BB710
    push    ebp
    call    sub_4BB7A0
    cmp     eax, [esp+0C4h+var_98]
    jge     short loc_4B3988
    mov     esi, [esp+0C4h+arg_8]

    loc_4B396E:                             ; CODE XREF: sub_4B3770+216j
    lea     eax, [esp+0C4h+var_B4]
    push    esi
    push    eax
    push    ebp
    mov     ecx, edi
    call    sub_4B4270
    push    ebp
    call    sub_4BB7A0
    cmp     eax, [esp+0C4h+var_98]
    jl      short loc_4B396E

    loc_4B3988:                             ; CODE XREF: sub_4B3770+1F5j
    push    ebp
    call    sub_4BB5D0
    mov     eax, [esp+0C4h+var_B4]
    test    eax, eax
    jz      short loc_4B399F
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B399F:                             ; CODE XREF: sub_4B3770+224j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 0B4h
    retn    0Ch
    sub_4B3770 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B39C0 proc near                    ; CODE XREF: sub_4326B0+3B4p

    var_134= dword ptr -134h
    var_130= dword ptr -130h
    var_12C= dword ptr -12Ch
    var_128= dword ptr -128h
    var_124= byte ptr -124h
    var_11C= dword ptr -11Ch
    var_118= dword ptr -118h
    var_114= dword ptr -114h
    var_110= dword ptr -110h
    var_10C= byte ptr -10Ch
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 134h
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    mov     eax, [ebx]
    push    edi
    test    eax, eax
    jz      loc_4B3C47
    cmp     dword ptr [eax], 0
    jz      loc_4B3C47
    mov     eax, [esp+144h+arg_C]
    mov     ebp, [esp+144h+arg_0]
    test    eax, eax
    jz      short loc_4B3A58
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+144h+var_100]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+144h+var_100]
    push    ecx
    call    sub_4BB0F0
    mov     edi, offset a_cpa               ; ".cpa"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+144h+var_100]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     eax, [esp+144h+var_100]
    and     ecx, 3
    push    eax
    rep movsb
    mov     ecx, ebx
    call    sub_4B4D70

    loc_4B3A58:                             ; CODE XREF: sub_4B39C0+2Fj
    push    offset aWB                      ; "w+b"
    push    ebp
    call    _fopen
    mov     ebp, eax
    xor     eax, eax
    add     esp, 8
    cmp     ebp, eax
    jz      loc_4B3C47
    mov     ecx, 8
    lea     edi, [esp+144h+var_124]
    mov     [esp+144h+var_134], eax
    mov     [esp+144h+var_130], eax
    rep stosd
    push    8                               ; size_t
    lea     ecx, [esp+148h+var_124]
    push    offset aHapibank                ; char *
    push    ecx                             ; char *
    stosw
    call    _strncpy
    mov     edi, [esp+150h+arg_4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [esp+144h+var_130]
    mov     [esp+144h+var_110], 1
    not     ecx
    dec     ecx
    mov     esi, edx
    mov     [esp+144h+var_128], esi
    lea     eax, [edx+ecx+1]
    mov     edx, [esp+144h+var_134]
    push    eax
    push    edx
    mov     [esp+14Ch+var_130], eax
    call    sub_4D8580
    mov     edi, [esp+14Ch+arg_4]
    mov     [esp+14Ch+var_134], eax
    lea     edx, [esi+eax]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    sub     edi, ecx
    push    ebp
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    push    1
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    lea     edx, [esp+14Ch+var_124]
    and     ecx, 3
    push    22h
    rep movsb
    mov     ecx, [esp+150h+var_128]
    push    edx
    mov     [esp+154h+var_11C], ecx
    mov     [esp+154h+var_114], 22h
    call    sub_4E5D40
    mov     eax, [ebx]
    add     esp, 10h
    xor     esi, esi
    cmp     dword ptr [eax], 0
    jle     short loc_4B3B47
    mov     edi, [esp+144h+arg_8]

    loc_4B3B31:                             ; CODE XREF: sub_4B39C0+185j
    lea     ecx, [esp+144h+var_134]
    push    edi
    push    ecx
    push    ebp
    push    esi
    mov     ecx, ebx
    call    sub_4B3C60
    mov     edx, [ebx]
    inc     esi
    cmp     esi, [edx]
    jl      short loc_4B3B31

    loc_4B3B47:                             ; CODE XREF: sub_4B39C0+168j
    push    2
    push    0
    push    ebp
    call    _fseek
    add     esp, 0Ch
    push    ebp
    call    _ftell
    add     esp, 4
    mov     [esp+144h+var_118], eax
    mov     eax, [esp+144h+var_130]
    push    2
    push    eax
    mov     ebx, eax
    call    sub_4D1AA0
    push    0
    mov     [esp+148h+var_12C], eax
    call    sub_4D8E50
    add     esp, 4
    mov     edi, eax
    mov     eax, [esp+144h+var_12C]
    push    eax
    call    sub_4D8450
    add     esp, 4
    mov     esi, eax
    push    edi
    call    sub_4D8E50
    add     esp, 4
    test    esi, esi
    jz      short loc_4B3BB2
    mov     ecx, [esp+144h+var_134]
    push    0
    push    1
    push    ebx
    lea     edx, [esp+150h+var_12C]
    push    ecx
    push    edx
    push    esi
    call    sub_4D1820
    jmp     short loc_4B3BB6
    ; ---------------------------------------------------------------------------

    loc_4B3BB2:                             ; CODE XREF: sub_4B39C0+1D9j
    mov     eax, [esp+144h+var_128]

    loc_4B3BB6:                             ; CODE XREF: sub_4B39C0+1F0j
    test    esi, esi
    jz      short loc_4B3BDA
    test    eax, eax
    jnz     short loc_4B3BDA
    mov     eax, [esp+144h+var_12C]
    cmp     eax, ebx
    jge     short loc_4B3BDA
    push    ebp
    push    1
    push    eax
    push    esi
    call    sub_4E5D40
    add     esp, 10h
    mov     [esp+144h+var_10C], 1
    jmp     short loc_4B3BEF
    ; ---------------------------------------------------------------------------

    loc_4B3BDA:                             ; CODE XREF: sub_4B39C0+1F8j
                                            ; sub_4B39C0+1FCj ...
    mov     eax, [esp+144h+var_130]
    mov     ecx, [esp+144h+var_134]
    push    ebp
    push    1
    push    eax
    push    ecx
    call    sub_4E5D40
    add     esp, 10h

    loc_4B3BEF:                             ; CODE XREF: sub_4B39C0+218j
    push    0
    push    0
    push    ebp
    call    _fseek
    add     esp, 0Ch
    lea     edx, [esp+144h+var_124]
    push    ebp
    push    1
    push    22h
    push    edx
    call    sub_4E5D40
    add     esp, 10h
    push    ebp
    call    _fclose
    add     esp, 4
    test    esi, esi
    jz      short loc_4B3C24
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B3C24:                             ; CODE XREF: sub_4B39C0+259j
    mov     eax, [esp+144h+var_134]
    test    eax, eax
    jz      short loc_4B3C35
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B3C35:                             ; CODE XREF: sub_4B39C0+26Aj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 134h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B3C47:                             ; CODE XREF: sub_4B39C0+10j
                                            ; sub_4B39C0+19j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 134h
    retn    10h
    sub_4B39C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B3C60 proc near                    ; CODE XREF: sub_4B39C0+17Bp

    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= qword ptr -38h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    mov     ecx, [ecx]
    sub     esp, 48h
    mov     edx, [ecx+4]
    lea     eax, [eax+eax*2]
    push    ebx
    push    ebp
    lea     ebp, [edx+eax*8]
    push    esi
    push    edi
    mov     eax, [ebp+4]
    test    eax, eax
    jg      short loc_4B3C88
    mov     eax, [ebp+8]
    test    eax, eax
    jle     loc_4B425E

    loc_4B3C88:                             ; CODE XREF: sub_4B3C60+1Bj
    mov     esi, [esp+58h+arg_4]
    push    esi
    call    _ftell
    add     esp, 4
    mov     [esp+58h+var_44], eax
    mov     ecx, 8
    xor     eax, eax
    lea     edi, [esp+58h+var_20]
    push    esi
    rep stosd
    push    1
    lea     eax, [esp+60h+var_20]
    push    20h
    push    eax
    call    sub_4E5D40
    mov     ebx, [esp+68h+arg_8]
    mov     esi, [ebp+0]
    mov     edi, esi
    xor     eax, eax
    mov     ecx, [ebx+4]
    add     esp, 10h
    mov     [esp+58h+arg_0], ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     edx, [ebx+4]
    not     ecx
    add     edx, ecx
    mov     [ebx+4], edx
    mov     eax, edx
    mov     edx, [ebx]
    push    eax
    push    edx
    call    sub_4D8580
    mov     ecx, [esp+60h+arg_0]
    mov     [ebx], eax
    mov     edi, esi
    add     esp, 8
    lea     edx, [ecx+eax]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+58h+arg_0]
    xor     edi, edi
    mov     [esp+58h+var_1C], ecx
    mov     eax, [ebp+4]
    cmp     eax, edi
    mov     [esp+58h+arg_0], edi
    jle     loc_4B3DE8
    mov     [esp+58h+arg_8], edi

    loc_4B3D2C:                             ; CODE XREF: sub_4B3C60+180j
    mov     edx, [ebp+10h]
    mov     eax, [esp+58h+arg_8]
    add     eax, edx
    cmp     dword ptr [eax+4], 1
    jnz     loc_4B3DC7
    mov     ecx, [ebx+4]
    mov     esi, [eax]
    mov     [esp+58h+var_48], ecx
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     edx, [ebx+4]
    not     ecx
    add     edx, ecx
    mov     [ebx+4], edx
    mov     eax, edx
    mov     edx, [ebx]
    push    eax
    push    edx
    call    sub_4D8580
    mov     ecx, [esp+60h+var_48]
    mov     [ebx], eax
    mov     edi, esi
    add     esp, 8
    lea     edx, [ecx+eax]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+58h+arg_8]
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+58h+var_48]
    mov     edx, [ebp+10h]
    mov     [esp+58h+var_3C], ecx
    mov     ecx, [edx+eax+8]
    mov     edx, [esp+58h+arg_4]
    push    edx
    push    1
    lea     eax, [esp+60h+var_3C]
    push    8
    push    eax
    mov     dword ptr [esp+68h+var_38], ecx
    call    sub_4E5D40
    mov     eax, [esp+68h+var_18]
    add     esp, 10h
    inc     eax
    mov     [esp+58h+var_18], eax

    loc_4B3DC7:                             ; CODE XREF: sub_4B3C60+D9j
    mov     eax, [esp+58h+arg_0]
    mov     edx, [esp+58h+arg_8]
    mov     ecx, [ebp+4]
    inc     eax
    add     edx, 10h
    cmp     eax, ecx
    mov     [esp+58h+arg_0], eax
    mov     [esp+58h+arg_8], edx
    jl      loc_4B3D2C
    xor     edi, edi

    loc_4B3DE8:                             ; CODE XREF: sub_4B3C60+C2j
    mov     eax, [ebp+4]
    mov     [esp+58h+arg_0], edi
    cmp     eax, edi
    jle     loc_4B3EB8
    mov     [esp+58h+arg_8], edi

    loc_4B3DFB:                             ; CODE XREF: sub_4B3C60+250j
    mov     ecx, [ebp+10h]
    mov     edx, [esp+58h+arg_8]
    lea     eax, [ecx+edx]
    mov     ecx, [ecx+edx+4]
    cmp     ecx, 2
    jnz     loc_4B3E97
    mov     esi, [eax]
    mov     eax, [ebx+4]
    mov     [esp+58h+var_48], eax
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     eax, [ebx+4]
    not     ecx
    add     eax, ecx
    mov     ecx, [ebx]
    push    eax
    push    ecx
    mov     [ebx+4], eax
    call    sub_4D8580
    mov     edx, [esp+60h+var_48]
    mov     [ebx], eax
    add     edx, eax
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+58h+arg_8]
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+58h+var_48]
    mov     edx, [ebp+10h]
    mov     [esp+58h+var_3C], ecx
    mov     ecx, [esp+58h+arg_4]
    fld     qword ptr [edx+eax+8]
    push    ecx
    push    1
    fstp    [esp+60h+var_38]
    lea     edx, [esp+60h+var_3C]
    push    0Ch
    push    edx
    call    sub_4E5D40
    mov     eax, [esp+68h+var_14]
    add     esp, 10h
    inc     eax
    mov     [esp+58h+var_14], eax

    loc_4B3E97:                             ; CODE XREF: sub_4B3C60+1ACj
    mov     eax, [esp+58h+arg_0]
    mov     edx, [esp+58h+arg_8]
    mov     ecx, [ebp+4]
    inc     eax
    add     edx, 10h
    cmp     eax, ecx
    mov     [esp+58h+arg_0], eax
    mov     [esp+58h+arg_8], edx
    jl      loc_4B3DFB
    xor     edi, edi

    loc_4B3EB8:                             ; CODE XREF: sub_4B3C60+191j
    mov     eax, [ebp+4]
    mov     [esp+58h+arg_0], edi
    cmp     eax, edi
    jle     loc_4B3FD3
    mov     [esp+58h+arg_8], edi

    loc_4B3ECB:                             ; CODE XREF: sub_4B3C60+36Bj
    mov     eax, [ebp+10h]
    mov     ecx, [esp+58h+arg_8]
    add     eax, ecx
    cmp     dword ptr [eax+4], 3
    jnz     loc_4B3FB2
    mov     esi, [eax]
    mov     edx, [ebx+4]
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esp+58h+var_48], edx
    repne scasb
    not     ecx
    mov     eax, edx
    add     eax, ecx
    mov     [ebx+4], eax
    push    eax
    mov     eax, [ebx]
    push    eax
    call    sub_4D8580
    mov     ecx, [esp+60h+var_48]
    mov     [ebx], eax
    mov     edi, esi
    add     esp, 8
    lea     edx, [ecx+eax]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+58h+arg_8]
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+58h+var_48]
    mov     edx, [ebp+10h]
    mov     [esp+58h+var_3C], ecx
    mov     ecx, [ebx+4]
    mov     esi, [edx+eax+8]
    mov     [esp+58h+var_48], ecx
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [ebx+4]
    repne scasb
    not     ecx
    add     edx, ecx
    mov     [ebx+4], edx
    mov     eax, edx
    mov     edx, [ebx]
    push    eax
    push    edx
    call    sub_4D8580
    mov     ecx, [esp+60h+var_48]
    mov     [ebx], eax
    mov     edi, esi
    add     esp, 8
    lea     edx, [ecx+eax]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, [esp+58h+arg_4]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    edx
    and     ecx, 3
    push    1
    rep movsb
    mov     ecx, [esp+60h+var_48]
    lea     eax, [esp+60h+var_3C]
    push    8
    push    eax
    mov     dword ptr [esp+68h+var_38], ecx
    call    sub_4E5D40
    add     esp, 10h
    inc     [esp+58h+var_10]

    loc_4B3FB2:                             ; CODE XREF: sub_4B3C60+278j
    mov     eax, [esp+58h+arg_0]
    mov     edx, [esp+58h+arg_8]
    mov     ecx, [ebp+4]
    inc     eax
    add     edx, 10h
    cmp     eax, ecx
    mov     [esp+58h+arg_0], eax
    mov     [esp+58h+arg_8], edx
    jl      loc_4B3ECB
    xor     edi, edi

    loc_4B3FD3:                             ; CODE XREF: sub_4B3C60+261j
    mov     eax, [ebp+8]
    xor     ecx, ecx
    cmp     eax, edi
    jle     short loc_4B3FF6
    xor     eax, eax

    loc_4B3FDE:                             ; CODE XREF: sub_4B3C60+394j
    mov     edx, [ebp+14h]
    cmp     [edx+eax+8], edi
    jle     short loc_4B3FEB
    inc     [esp+58h+var_C]

    loc_4B3FEB:                             ; CODE XREF: sub_4B3C60+385j
    mov     edx, [ebp+8]
    inc     ecx
    add     eax, 14h
    cmp     ecx, edx
    jl      short loc_4B3FDE

    loc_4B3FF6:                             ; CODE XREF: sub_4B3C60+37Aj
    mov     esi, [esp+58h+arg_4]
    push    esi
    call    _ftell
    mov     ecx, [esp+5Ch+var_C]
    add     esp, 4
    shl     ecx, 4
    add     eax, ecx
    mov     [esp+58h+arg_0], edi
    mov     [esp+58h+arg_8], eax
    mov     eax, [ebp+8]
    cmp     eax, edi
    jle     loc_4B40F1
    mov     [esp+58h+var_48], edi

    loc_4B4023:                             ; CODE XREF: sub_4B3C60+48Bj
    mov     edx, [ebp+14h]
    mov     ecx, [edx+edi+8]
    lea     eax, [edx+edi]
    test    ecx, ecx
    jle     loc_4B40D6
    cmp     dword ptr [eax], 0
    jz      short loc_4B409C
    mov     edi, [eax+4]
    mov     esi, [ebx+4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esp+58h+var_40], edi
    mov     [esp+58h+var_3C], esi
    repne scasb
    not     ecx
    mov     eax, esi
    add     eax, ecx
    mov     [ebx+4], eax
    push    eax
    mov     eax, [ebx]
    push    eax
    call    sub_4D8580
    mov     edi, [esp+60h+var_40]
    mov     [ebx], eax
    lea     edx, [esi+eax]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+58h+var_3C]
    mov     esi, [esp+58h+arg_4]
    mov     edi, [esp+58h+var_48]
    mov     [esp+58h+var_30], ecx
    jmp     short loc_4B40AB
    ; ---------------------------------------------------------------------------

    loc_4B409C:                             ; CODE XREF: sub_4B3C60+3D8j
    mov     [esp+58h+var_30], 0FFFFFFFFh
    mov     edx, [eax+4]
    mov     [esp+58h+var_2C], edx

    loc_4B40AB:                             ; CODE XREF: sub_4B3C60+43Aj
    mov     ecx, [esp+58h+arg_8]
    mov     eax, [ebp+14h]
    mov     [esp+58h+var_28], ecx
    push    esi
    mov     eax, [eax+edi+8]
    push    1
    add     ecx, eax
    push    10h
    mov     [esp+64h+arg_8], ecx
    lea     ecx, [esp+64h+var_30]
    push    ecx
    mov     [esp+68h+var_24], eax
    call    sub_4E5D40
    add     esp, 10h

    loc_4B40D6:                             ; CODE XREF: sub_4B3C60+3CFj
    mov     eax, [esp+58h+arg_0]
    mov     ecx, [ebp+8]
    inc     eax
    add     edi, 14h
    cmp     eax, ecx
    mov     [esp+58h+arg_0], eax
    mov     [esp+58h+var_48], edi
    jl      loc_4B4023

    loc_4B40F1:                             ; CODE XREF: sub_4B3C60+3B9j
    mov     eax, [ebp+8]
    xor     ebx, ebx
    test    eax, eax
    jle     short loc_4B4125
    xor     edi, edi

    loc_4B40FC:                             ; CODE XREF: sub_4B3C60+4C3j
    mov     edx, [ebp+14h]
    mov     ecx, [edx+edi+8]
    lea     eax, [edx+edi]
    test    ecx, ecx
    jle     short loc_4B411A
    mov     eax, [eax+10h]
    push    esi
    push    1
    push    ecx
    push    eax
    call    sub_4E5D40
    add     esp, 10h

    loc_4B411A:                             ; CODE XREF: sub_4B3C60+4A8j
    mov     eax, [ebp+8]
    inc     ebx
    add     edi, 14h
    cmp     ebx, eax
    jl      short loc_4B40FC

    loc_4B4125:                             ; CODE XREF: sub_4B3C60+498j
    push    esi
    call    _ftell
    mov     ebp, [esp+5Ch+var_44]
    add     esp, 4
    sub     eax, ebp
    mov     [esp+58h+var_20], eax
    mov     eax, [esp+58h+arg_C]
    test    eax, eax
    jz      loc_4B4233
    push    0
    call    sub_4D8E50
    mov     ecx, [esp+5Ch+var_20]
    add     esp, 4
    mov     [esp+58h+arg_8], eax
    lea     edi, [ecx-20h]
    push    edi
    call    sub_4D8450
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    mov     [esp+58h+arg_0], ebx
    jz      loc_4B4226
    add     ebp, 20h
    push    0
    push    ebp
    push    esi
    call    _fseek
    add     esp, 0Ch
    push    esi
    push    1
    push    edi
    push    ebx
    call    sub_4E5BC0
    add     esp, 10h
    push    1
    push    edi
    call    sub_4D1AA0
    push    eax
    mov     [esp+5Ch+arg_4], eax
    call    sub_4D8450
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    jz      short loc_4B4215
    mov     edx, [esp+58h+arg_0]
    push    0
    push    1
    push    edi
    lea     eax, [esp+64h+arg_4]
    push    edx
    push    eax
    push    ebx
    call    sub_4D1820
    test    eax, eax
    jnz     short loc_4B420C
    cmp     [esp+58h+arg_4], edi
    jge     short loc_4B420C
    push    0
    push    ebp
    push    esi
    call    _fseek
    mov     ecx, [esp+64h+arg_4]
    add     esp, 0Ch
    push    esi
    push    1
    push    ecx
    push    ebx
    call    sub_4E5D40
    mov     edx, [esp+68h+arg_4]
    add     esp, 10h
    add     edx, 20h
    mov     [esp+58h+var_8], 1
    push    esi
    mov     [esp+5Ch+var_20], edx
    call    _ftell
    add     esp, 4
    push    eax
    mov     eax, [esi+10h]
    push    eax
    call    sub_4E7610
    add     esp, 8

    loc_4B420C:                             ; CODE XREF: sub_4B3C60+55Ej
                                            ; sub_4B3C60+564j
    push    ebx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B4215:                             ; CODE XREF: sub_4B3C60+545j
    mov     ecx, [esp+58h+arg_0]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     ebp, [esp+5Ch+var_44]
    add     esp, 4

    loc_4B4226:                             ; CODE XREF: sub_4B3C60+50Aj
    mov     edx, [esp+58h+arg_8]
    push    edx
    call    sub_4D8E50
    add     esp, 4

    loc_4B4233:                             ; CODE XREF: sub_4B3C60+4DEj
    push    0
    push    ebp
    push    esi
    call    _fseek
    add     esp, 0Ch
    lea     eax, [esp+58h+var_20]
    push    esi
    push    1
    push    20h
    push    eax
    call    sub_4E5D40
    add     esp, 10h
    push    2
    push    0
    push    esi
    call    _fseek
    add     esp, 0Ch

    loc_4B425E:                             ; CODE XREF: sub_4B3C60+22j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    10h
    sub_4B3C60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4270 proc near                    ; CODE XREF: sub_4B3770+207p

    var_42C= dword ptr -42Ch
    var_428= dword ptr -428h
    var_424= dword ptr -424h
    var_420= dword ptr -420h
    var_41C= dword ptr -41Ch
    var_418= dword ptr -418h
    var_414= dword ptr -414h
    var_410= dword ptr -410h
    var_40C= dword ptr -40Ch
    var_408= dword ptr -408h
    var_404= dword ptr -404h
    var_400= dword ptr -400h
    var_3EC= dword ptr -3ECh
    Text= byte ptr -3E8h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 42Ch
    push    ebx
    mov     ebx, [esp+430h+arg_0]
    push    ebp
    push    esi
    push    edi
    mov     ebp, ecx
    push    ebx
    call    sub_4BB7A0
    mov     esi, eax
    lea     eax, [esp+43Ch+var_418]
    push    20h
    push    eax
    push    ebx
    mov     [esp+448h+var_424], esi
    call    sub_4BB7C0
    mov     ecx, [esp+43Ch+var_418]
    mov     eax, [esp+43Ch+arg_8]
    mov     edi, [esp+43Ch+arg_4]
    add     esi, ecx
    test    eax, eax
    mov     [esp+43Ch+var_420], esi
    jz      short loc_4B42E2
    mov     edx, [edi]
    mov     ecx, [esp+43Ch+var_414]
    add     edx, ecx
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4B42E2
    push    esi
    push    ebx
    call    sub_4BB710
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 42Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B42E2:                             ; CODE XREF: sub_4B4270+46j
                                            ; sub_4B4270+5Cj
    mov     eax, [esp+43Ch+var_418]
    lea     esi, [eax-20h]
    test    esi, esi
    mov     [esp+43Ch+var_428], esi
    jle     loc_4B4544
    mov     eax, [esp+43Ch+var_400]
    push    esi
    cmp     eax, 1
    jnz     short loc_4B4365
    call    sub_4D8450
    mov     ecx, [esp+440h+var_428]
    add     esp, 4
    mov     esi, eax
    push    ecx
    push    esi
    push    ebx
    call    sub_4BB7C0
    push    esi
    call    sub_4D1B40
    push    eax
    call    sub_4D8450
    add     esp, 4
    mov     [esp+43Ch+var_42C], eax
    push    esi
    push    eax
    call    sub_4D1970
    test    eax, eax
    jz      short loc_4B435A
    add     ebx, 18h
    push    ebx
    push    eax
    call    sub_4D1C60
    push    eax
    lea     edx, [esp+444h+Text]
    push    offset aHapibankLoadac          ; "[HapiBank::LoadAccount] Decompression E"...
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+43Ch+Text]
    push    eax                             ; lpText
    call    sub_4B6290

    loc_4B435A:                             ; CODE XREF: sub_4B4270+C1j
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    jmp     short loc_4B4379
    ; ---------------------------------------------------------------------------

    loc_4B4365:                             ; CODE XREF: sub_4B4270+8Dj
    call    sub_4D8450
    add     esp, 4
    mov     [esp+43Ch+var_42C], eax
    push    esi
    push    eax
    push    ebx
    call    sub_4BB7C0

    loc_4B4379:                             ; CODE XREF: sub_4B4270+F3j
    mov     ecx, [edi]
    mov     esi, [esp+43Ch+var_414]
    add     ecx, esi
    push    ecx                             ; char *
    mov     ecx, ebp
    call    sub_4B4560
    mov     eax, [esp+43Ch+var_410]
    mov     esi, [esp+43Ch+var_42C]
    xor     ebx, ebx
    test    eax, eax
    jle     short loc_4B43B5

    loc_4B4397:                             ; CODE XREF: sub_4B4270+143j
    mov     eax, [esi]
    mov     edx, [edi]
    mov     ecx, [esi+4]
    add     edx, eax
    push    ecx                             ; int
    push    edx                             ; char *
    mov     ecx, ebp
    add     esi, 8
    call    sub_4B4630
    mov     eax, [esp+43Ch+var_410]
    inc     ebx
    cmp     ebx, eax
    jl      short loc_4B4397

    loc_4B43B5:                             ; CODE XREF: sub_4B4270+125j
    mov     eax, [esp+43Ch+var_40C]
    xor     ebx, ebx
    test    eax, eax
    jle     short loc_4B43E3

    loc_4B43BF:                             ; CODE XREF: sub_4B4270+171j
    mov     edx, esi
    add     esi, 0Ch
    mov     eax, [edx]
    mov     ecx, [edx+4]
    mov     edx, [edx+8]
    push    edx
    push    ecx                             ; __int64
    mov     ecx, [edi]
    add     ecx, eax
    push    ecx                             ; char *
    mov     ecx, ebp
    call    sub_4B46C0
    mov     eax, [esp+43Ch+var_40C]
    inc     ebx
    cmp     ebx, eax
    jl      short loc_4B43BF

    loc_4B43E3:                             ; CODE XREF: sub_4B4270+14Dj
    mov     eax, [esp+43Ch+var_408]
    xor     ebx, ebx
    test    eax, eax
    jle     short loc_4B440D

    loc_4B43ED:                             ; CODE XREF: sub_4B4270+19Bj
    mov     edx, [esi+4]
    mov     eax, [edi]
    mov     ecx, [esi]
    add     edx, eax
    add     ecx, eax
    push    edx                             ; int
    push    ecx                             ; char *
    mov     ecx, ebp
    add     esi, 8
    call    sub_4B4750
    mov     eax, [esp+43Ch+var_408]
    inc     ebx
    cmp     ebx, eax
    jl      short loc_4B43ED

    loc_4B440D:                             ; CODE XREF: sub_4B4270+17Bj
    mov     eax, [esp+43Ch+var_404]
    mov     [esp+43Ch+var_428], 0
    test    eax, eax
    jle     loc_4B4525
    jmp     short loc_4B442E
    ; ---------------------------------------------------------------------------

    loc_4B4423:                             ; CODE XREF: sub_4B4270+2AFj
    mov     edi, [esp+43Ch+arg_4]
    mov     esi, [esp+43Ch+var_41C]

    loc_4B442E:                             ; CODE XREF: sub_4B4270+1B1j
    mov     edx, esi
    add     esi, 10h
    mov     [esp+43Ch+var_41C], esi
    push    1
    mov     eax, [edx]
    test    eax, eax
    mov     ecx, [edx+4]
    mov     ebx, [edx+8]
    mov     edx, [edx+0Ch]
    mov     [esp+440h+var_3EC], edx
    jge     short loc_4B4456
    push    ecx
    mov     ecx, ebp
    call    sub_4B49D0
    jmp     short loc_4B4462                ; int
    ; ---------------------------------------------------------------------------

    loc_4B4456:                             ; CODE XREF: sub_4B4270+1DAj
    mov     edx, [edi]
    mov     ecx, ebp
    add     edx, eax
    push    edx                             ; char *
    call    sub_4B4A80

    loc_4B4462:                             ; CODE XREF: sub_4B4270+1E4j
    mov     ecx, [ebp+0]
    mov     esi, [esp+43Ch+var_3EC]
    mov     edx, [ecx+8]
    mov     ecx, [ecx+4]
    lea     edx, [edx+edx*2]
    mov     [ecx+edx*8+0Ch], eax
    mov     edx, [esp+43Ch+var_424]
    mov     eax, [ebp+0]
    sub     ebx, edx
    mov     edx, [esp+43Ch+var_42C]
    mov     ecx, [eax+8]
    lea     edi, [ebx+edx-20h]
    mov     edx, [eax+4]
    lea     ecx, [ecx+ecx*2]
    lea     eax, [edx+ecx*8]
    mov     ecx, [edx+ecx*8+0Ch]
    mov     edx, [eax+14h]
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edx+ecx*4+8]
    lea     ebx, [edx+ecx*4]
    mov     ecx, [edx+ecx*4+0Ch]
    add     esi, ecx
    cmp     esi, eax
    jle     short loc_4B44C1
    mov     eax, [ebx+10h]
    push    esi
    push    eax
    call    sub_4D8580
    add     esp, 8
    mov     [ebx+10h], eax
    mov     [ebx+8], esi

    loc_4B44C1:                             ; CODE XREF: sub_4B4270+23Cj
    mov     edx, [ebx+0Ch]
    mov     ecx, [esp+43Ch+var_3EC]
    mov     esi, edi
    mov     edi, [ebx+10h]
    add     edi, edx
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     eax, edx
    and     ecx, 3
    xor     edx, edx
    rep movsb
    mov     edi, [ebx+0Ch]
    add     edi, eax
    mov     [ebx+0Ch], edi
    mov     eax, [ebp+0]
    mov     ecx, [eax+8]
    mov     eax, [eax+4]
    lea     ecx, [ecx+ecx*2]
    lea     eax, [eax+ecx*8]
    mov     ecx, [eax+0Ch]
    mov     eax, [eax+14h]
    lea     ecx, [ecx+ecx*4]
    lea     eax, [eax+ecx*4]
    mov     ecx, [eax+8]
    test    ecx, ecx
    jge     short loc_4B450D
    mov     edx, ecx

    loc_4B450D:                             ; CODE XREF: sub_4B4270+299j
    mov     [eax+0Ch], edx
    mov     eax, [esp+43Ch+var_428]
    mov     ecx, [esp+43Ch+var_404]
    inc     eax
    cmp     eax, ecx
    mov     [esp+43Ch+var_428], eax
    jl      loc_4B4423

    loc_4B4525:                             ; CODE XREF: sub_4B4270+1ABj
    mov     ecx, [esp+43Ch+var_420]
    mov     edx, [esp+43Ch+arg_0]
    push    ecx
    push    edx
    call    sub_4BB710
    mov     eax, [esp+43Ch+var_42C]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B4544:                             ; CODE XREF: sub_4B4270+7Fj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 42Ch
    retn    0Ch
    sub_4B4270 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B4560(char *)
    sub_4B4560 proc near                    ; CODE XREF: sub_41D2B0+Dp
                                            ; sub_41D360+Cp ...

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    mov     ebp, [esp+arg_0]
    push    edi
    mov     eax, [esi]
    xor     edi, edi
    cmp     dword ptr [eax], 0
    jle     short loc_4B4593
    xor     ebx, ebx

    loc_4B4575:                             ; CODE XREF: sub_4B4560+31j
    mov     eax, [eax+4]
    push    ebp                             ; char *
    mov     ecx, [eax+ebx]
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4B4607
    mov     eax, [esi]
    inc     edi
    add     ebx, 18h
    cmp     edi, [eax]
    jl      short loc_4B4575

    loc_4B4593:                             ; CODE XREF: sub_4B4560+11j
    mov     eax, [esi]
    mov     ecx, [eax]
    mov     [eax+8], ecx
    mov     eax, [esi]
    mov     ebx, [eax]
    inc     ebx
    mov     [eax], ebx
    mov     eax, [esi]
    mov     ecx, [eax]
    mov     eax, [eax+4]
    lea     edx, [ecx+ecx*2]
    shl     edx, 3
    push    edx
    push    eax
    call    sub_4D8580
    mov     ecx, [esi]
    add     esp, 8
    mov     [ecx+4], eax
    mov     edx, [esi]
    mov     ecx, 6
    xor     eax, eax
    mov     edi, [edx+8]
    mov     edx, [edx+4]
    push    ebp
    lea     edi, [edi+edi*2]
    lea     edi, [edx+edi*8]
    rep stosd
    mov     edi, [esi]
    call    sub_4D8610
    mov     ecx, [edi+8]
    mov     edx, [edi+4]
    add     esp, 4
    lea     ecx, [ecx+ecx*2]
    mov     [edx+ecx*8], eax
    mov     esi, [esi]
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    lea     eax, [eax+eax*2]
    mov     dword ptr [ecx+eax*8+0Ch], 0FFFFFFFFh
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B4607:                             ; CODE XREF: sub_4B4560+27j
    mov     edx, [esi]
    lea     eax, [edi+edi*2]
    mov     [edx+8], edi
    mov     ecx, [esi]
    pop     edi
    pop     esi
    mov     edx, [ecx+4]
    pop     ebp
    pop     ebx
    mov     dword ptr [edx+eax*8+0Ch], 0FFFFFFFFh
    mov     eax, 1
    retn    4
    sub_4B4560 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B4630(char *,int)
    sub_4B4630 proc near                    ; CODE XREF: sub_41D360+24p
                                            ; sub_41D360+3Dp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4B46B3
    mov     ecx, [eax+8]
    test    ecx, ecx
    jl      short loc_4B46B3
    mov     eax, [esp+4+arg_0]
    push    1                               ; int
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_4B4910
    mov     ecx, [esi]
    shl     eax, 4
    mov     edi, eax
    mov     eax, [ecx+8]
    lea     edx, [eax+eax*2]
    mov     eax, [ecx+4]
    mov     ecx, [eax+edx*8+10h]
    lea     eax, [ecx+edi]
    mov     ecx, [ecx+edi+4]
    cmp     ecx, 3
    jnz     short loc_4B467B
    mov     edx, [eax+8]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B467B:                             ; CODE XREF: sub_4B4630+3Dj
    mov     eax, [esi]
    mov     ecx, [eax+8]
    mov     edx, [eax+4]
    lea     ecx, [ecx+ecx*2]
    mov     eax, [edx+ecx*8+10h]
    mov     ecx, [esp+4+arg_4]
    mov     [eax+edi+8], ecx
    mov     esi, [esi]
    mov     eax, [esi+8]
    lea     edx, [eax+eax*2]
    mov     eax, [esi+4]
    mov     ecx, [eax+edx*8+10h]
    mov     eax, 1
    mov     dword ptr [ecx+edi+4], 1
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B46B3:                             ; CODE XREF: sub_4B4630+8j
                                            ; sub_4B4630+Fj
    pop     edi
    xor     eax, eax
    pop     esi
    retn    8
    sub_4B4630 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B46C0(char *,__int64)
    sub_4B46C0 proc near                    ; CODE XREF: sub_4662F0+AEp
                                            ; sub_4662F0+C6p ...

    arg_0= dword ptr  8
    arg_4= qword ptr  0Ch

    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4B4743
    mov     ecx, [eax+8]
    test    ecx, ecx
    jl      short loc_4B4743
    mov     eax, [esp+4+arg_0]
    push    1                               ; int
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_4B4910
    mov     ecx, [esi]
    shl     eax, 4
    mov     edi, eax
    mov     eax, [ecx+8]
    lea     edx, [eax+eax*2]
    mov     eax, [ecx+4]
    mov     ecx, [eax+edx*8+10h]
    lea     eax, [ecx+edi]
    mov     ecx, [ecx+edi+4]
    cmp     ecx, 3
    jnz     short loc_4B470B
    mov     edx, [eax+8]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B470B:                             ; CODE XREF: sub_4B46C0+3Dj
    mov     eax, [esi]
    fld     [esp+4+arg_4]
    mov     ecx, [eax+8]
    mov     edx, [eax+4]
    lea     ecx, [ecx+ecx*2]
    mov     eax, [edx+ecx*8+10h]
    fstp    qword ptr [eax+edi+8]
    mov     esi, [esi]
    mov     eax, [esi+8]
    mov     edx, [esi+4]
    lea     ecx, [eax+eax*2]
    mov     eax, [edx+ecx*8+10h]
    mov     dword ptr [eax+edi+4], 2
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B4743:                             ; CODE XREF: sub_4B46C0+8j
                                            ; sub_4B46C0+Fj
    pop     edi
    xor     eax, eax
    pop     esi
    retn    0Ch
    sub_4B46C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B4750(char *,int)
    sub_4B4750 proc near                    ; CODE XREF: sub_4326B0+B9p
                                            ; sub_4326B0+F5p ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi]
    test    eax, eax
    jz      loc_4B47EE
    mov     ecx, [eax+8]
    test    ecx, ecx
    jl      loc_4B47EE
    mov     eax, [esp+4+arg_4]
    test    eax, eax
    jz      short loc_4B47EE
    mov     eax, [esp+4+arg_0]
    push    1                               ; int
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_4B4910
    mov     ecx, [esi]
    shl     eax, 4
    mov     edi, eax
    mov     eax, [ecx+8]
    lea     edx, [eax+eax*2]
    mov     eax, [ecx+4]
    mov     ecx, [eax+edx*8+10h]
    lea     eax, [ecx+edi]
    mov     ecx, [ecx+edi+4]
    cmp     ecx, 3
    jnz     short loc_4B47AC
    mov     edx, [eax+8]
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B47AC:                             ; CODE XREF: sub_4B4750+4Ej
    mov     eax, [esp+4+arg_4]
    mov     ebx, [esi]
    push    eax
    call    sub_4D8610
    mov     ecx, [ebx+8]
    mov     edx, [ebx+4]
    add     esp, 4
    lea     ecx, [ecx+ecx*2]
    mov     ecx, [edx+ecx*8+10h]
    mov     [ecx+edi+8], eax
    mov     esi, [esi]
    mov     eax, [esi+8]
    lea     edx, [eax+eax*2]
    mov     eax, [esi+4]
    mov     ecx, [eax+edx*8+10h]
    mov     eax, 1
    mov     dword ptr [ecx+edi+4], 3
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B47EE:                             ; CODE XREF: sub_4B4750+9j
                                            ; sub_4B4750+14j ...
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    8
    sub_4B4750 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B4800(char *,int)
    sub_4B4800 proc near                    ; CODE XREF: sub_41D2B0+25p
                                            ; sub_41D2B0+40p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, ecx
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4B4846
    mov     ecx, [eax+8]
    test    ecx, ecx
    jl      short loc_4B4846
    mov     eax, [esp+arg_0]
    push    0                               ; int
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_4B4910
    test    eax, eax
    jl      short loc_4B4846
    mov     ecx, [esi]
    shl     eax, 4
    mov     edx, [ecx+8]
    mov     ecx, [ecx+4]
    lea     edx, [edx+edx*2]
    mov     edx, [ecx+edx*8+10h]
    mov     ecx, [eax+edx+4]
    add     eax, edx
    cmp     ecx, 1
    jnz     short loc_4B4846
    mov     eax, [eax+8]
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B4846:                             ; CODE XREF: sub_4B4800+7j
                                            ; sub_4B4800+Ej ...
    mov     eax, [esp+arg_4]
    pop     esi
    retn    8
    sub_4B4800 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B4850(char *,__int64)
    sub_4B4850 proc near                    ; CODE XREF: sub_466050+B8p
                                            ; sub_466050+CEp ...

    arg_0= dword ptr  8
    arg_4= qword ptr  0Ch

    push    esi
    mov     esi, ecx
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4B4896
    mov     ecx, [eax+8]
    test    ecx, ecx
    jl      short loc_4B4896
    mov     eax, [esp+arg_0]
    push    0                               ; int
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_4B4910
    test    eax, eax
    jl      short loc_4B4896
    mov     ecx, [esi]
    shl     eax, 4
    mov     edx, [ecx+8]
    mov     ecx, [ecx+4]
    lea     edx, [edx+edx*2]
    mov     edx, [ecx+edx*8+10h]
    mov     ecx, [eax+edx+4]
    add     eax, edx
    cmp     ecx, 2
    jnz     short loc_4B4896
    fld     qword ptr [eax+8]
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B4896:                             ; CODE XREF: sub_4B4850+7j
                                            ; sub_4B4850+Ej ...
    fld     [esp+arg_4]
    pop     esi
    retn    0Ch
    sub_4B4850 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B48A0(char *,int)
    sub_4B48A0 proc near                    ; CODE XREF: .text:0043A3A6p
                                            ; sub_43A420+CDp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, ecx
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4B48E6
    mov     ecx, [eax+8]
    test    ecx, ecx
    jl      short loc_4B48E6
    mov     eax, [esp+arg_0]
    push    0                               ; int
    push    eax                             ; char *
    mov     ecx, esi
    call    sub_4B4910
    test    eax, eax
    jl      short loc_4B48E6
    mov     ecx, [esi]
    shl     eax, 4
    mov     edx, [ecx+8]
    mov     ecx, [ecx+4]
    lea     edx, [edx+edx*2]
    mov     edx, [ecx+edx*8+10h]
    mov     ecx, [eax+edx+4]
    add     eax, edx
    cmp     ecx, 3
    jnz     short loc_4B48E6
    mov     eax, [eax+8]
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B48E6:                             ; CODE XREF: sub_4B48A0+7j
                                            ; sub_4B48A0+Ej ...
    mov     eax, [esp+arg_4]
    pop     esi
    retn    8
    sub_4B48A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B48F0(char *)
    sub_4B48F0 proc near                    ; CODE XREF: sub_432610+19p
                                            ; .text:0043A309p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    0                               ; int
    push    eax                             ; char *
    call    sub_4B4910
    xor     ecx, ecx
    test    eax, eax
    setnl   cl
    mov     eax, ecx
    retn    4
    sub_4B48F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B4910(char *,int)
    sub_4B4910 proc near                    ; CODE XREF: sub_4B4630+1Ap
                                            ; sub_4B46C0+1Ap ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [ecx]
    push    ebx
    push    ebp
    push    esi
    test    ecx, ecx
    push    edi
    jz      loc_4B49B1
    mov     eax, [ecx+8]
    test    eax, eax
    jl      loc_4B49B1
    mov     ecx, [ecx+4]
    lea     eax, [eax+eax*2]
    mov     ebp, [esp+10h+arg_0]
    xor     edi, edi
    lea     esi, [ecx+eax*8]
    mov     eax, [ecx+eax*8+4]
    test    eax, eax
    jle     short loc_4B4961
    xor     ebx, ebx

    loc_4B4942:                             ; CODE XREF: sub_4B4910+4Fj
    mov     edx, [esi+10h]
    push    ebp                             ; char *
    mov     eax, [edx+ebx]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4B49BB
    mov     eax, [esi+4]
    inc     edi
    add     ebx, 10h
    cmp     edi, eax
    jl      short loc_4B4942

    loc_4B4961:                             ; CODE XREF: sub_4B4910+2Ej
    mov     eax, [esp+10h+arg_4]
    test    eax, eax
    jz      short loc_4B49B1
    mov     ebx, [esi+4]
    mov     ecx, [esi+10h]
    lea     eax, [ebx+1]
    mov     [esi+4], eax
    shl     eax, 4
    push    eax
    push    ecx
    call    sub_4D8580
    mov     edi, ebx
    mov     [esi+10h], eax
    shl     edi, 4
    add     eax, edi
    xor     edx, edx
    add     esp, 8
    mov     [eax], edx
    push    ebp
    mov     [eax+4], edx
    mov     [eax+8], edx
    mov     [eax+0Ch], edx
    call    sub_4D8610
    mov     ecx, [esi+10h]
    add     esp, 4
    mov     [ecx+edi], eax
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B49B1:                             ; CODE XREF: sub_4B4910+8j
                                            ; sub_4B4910+13j ...
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B49BB:                             ; CODE XREF: sub_4B4910+44j
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4B4910 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B49D0 proc near                    ; CODE XREF: sub_4B4270+1DFp
                                            ; sub_4B4B50+Ap

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [ecx]
    push    ebx
    push    esi
    push    edi
    test    ecx, ecx
    jz      loc_4B4A69
    mov     eax, [ecx+8]
    test    eax, eax
    jl      loc_4B4A69
    mov     ecx, [ecx+4]
    lea     eax, [eax+eax*2]
    mov     ebx, [esp+0Ch+arg_0]
    mov     esi, [ecx+eax*8+8]
    lea     edi, [ecx+eax*8]
    xor     eax, eax
    test    esi, esi
    jle     short loc_4B4A14
    mov     ecx, [edi+14h]

    loc_4B4A02:                             ; CODE XREF: sub_4B49D0+42j
    cmp     dword ptr [ecx], 0
    jnz     short loc_4B4A0C
    cmp     [ecx+4], ebx
    jz      short loc_4B4A6C

    loc_4B4A0C:                             ; CODE XREF: sub_4B49D0+35j
    inc     eax
    add     ecx, 14h
    cmp     eax, esi
    jl      short loc_4B4A02

    loc_4B4A14:                             ; CODE XREF: sub_4B49D0+2Dj
    mov     eax, [esp+0Ch+arg_4]
    test    eax, eax
    jz      short loc_4B4A69
    lea     eax, [esi+1]
    mov     [edi+8], eax
    lea     edx, [eax+eax*4]
    mov     eax, [edi+14h]
    shl     edx, 2
    push    edx
    push    eax
    call    sub_4D8580
    lea     ecx, [esi+esi*4]
    add     esp, 8
    shl     ecx, 2
    mov     [edi+14h], eax
    xor     edx, edx
    add     eax, ecx
    mov     [eax], edx
    mov     [eax+4], edx
    mov     [eax+8], edx
    mov     [eax+0Ch], edx
    mov     [eax+10h], edx
    mov     edx, [edi+14h]
    mov     [edx+ecx+4], ebx
    mov     eax, [edi+14h]
    mov     dword ptr [eax+ecx], 0
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B4A69:                             ; CODE XREF: sub_4B49D0+7j
                                            ; sub_4B49D0+12j ...
    or      eax, 0FFFFFFFFh

    loc_4B4A6C:                             ; CODE XREF: sub_4B49D0+3Aj
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_4B49D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B4A80(char *,int)
    sub_4B4A80 proc near                    ; CODE XREF: sub_4B4270+1EDp
                                            ; sub_4B4BA0+Ap

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [ecx]
    push    ebx
    push    ebp
    push    esi
    test    ecx, ecx
    push    edi
    jz      loc_4B4B3E
    mov     eax, [ecx+8]
    test    eax, eax
    jl      loc_4B4B3E
    mov     ecx, [ecx+4]
    lea     eax, [eax+eax*2]
    mov     ebp, [esp+10h+arg_0]
    xor     ebx, ebx
    lea     esi, [ecx+eax*8]
    mov     eax, [ecx+eax*8+8]
    test    eax, eax
    jle     short loc_4B4ADB
    xor     edi, edi

    loc_4B4AB2:                             ; CODE XREF: sub_4B4A80+59j
    mov     edx, [esi+14h]
    mov     ecx, [edx+edi]
    lea     eax, [edx+edi]
    test    ecx, ecx
    jz      short loc_4B4AD0
    mov     eax, [eax+4]
    push    ebp                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4B4B35

    loc_4B4AD0:                             ; CODE XREF: sub_4B4A80+3Dj
    mov     eax, [esi+8]
    inc     ebx
    add     edi, 14h
    cmp     ebx, eax
    jl      short loc_4B4AB2

    loc_4B4ADB:                             ; CODE XREF: sub_4B4A80+2Ej
    mov     eax, [esp+10h+arg_4]
    test    eax, eax
    jz      short loc_4B4B3E
    mov     ebx, [esi+8]
    mov     edx, [esi+14h]
    lea     eax, [ebx+1]
    mov     [esi+8], eax
    lea     ecx, [eax+eax*4]
    shl     ecx, 2
    push    ecx
    push    edx
    call    sub_4D8580
    lea     edi, [ebx+ebx*4]
    xor     ecx, ecx
    shl     edi, 2
    mov     [esi+14h], eax
    add     esp, 8
    lea     edx, [edi+eax]
    push    ebp
    mov     [edx], ecx
    mov     [edx+4], ecx
    mov     [edx+8], ecx
    mov     [edx+0Ch], ecx
    mov     [edx+10h], ecx
    call    sub_4D8610
    mov     ecx, [esi+14h]
    add     esp, 4
    mov     [ecx+edi+4], eax
    mov     edx, [esi+14h]
    mov     dword ptr [edx+edi], 1

    loc_4B4B35:                             ; CODE XREF: sub_4B4A80+4Ej
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B4B3E:                             ; CODE XREF: sub_4B4A80+8j
                                            ; sub_4B4A80+13j ...
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn    8
    sub_4B4A80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4B50 proc near                    ; CODE XREF: sub_486FD0+4Dp
                                            ; sub_487080+7Bp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    push    1
    mov     esi, ecx
    push    eax
    call    sub_4B49D0
    mov     ecx, [esi]
    mov     edx, [ecx+8]
    mov     ecx, [ecx+4]
    lea     edx, [edx+edx*2]
    mov     [ecx+edx*8+0Ch], eax
    mov     esi, [esi]
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+8]
    lea     edx, [ecx+ecx*2]
    mov     ecx, [esi+4]
    mov     ecx, [ecx+edx*8+14h]
    xor     edx, edx
    mov     esi, [ecx+eax*4+10h]
    test    esi, esi
    setnz   dl
    mov     eax, edx
    pop     esi
    retn    4
    sub_4B4B50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4BA0 proc near                    ; CODE XREF: sub_4010B0+32p
                                            ; sub_401110+32p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    push    1                               ; int
    mov     esi, ecx
    push    eax                             ; char *
    call    sub_4B4A80
    mov     ecx, [esi]
    mov     edx, [ecx+8]
    mov     ecx, [ecx+4]
    lea     edx, [edx+edx*2]
    mov     [ecx+edx*8+0Ch], eax
    mov     esi, [esi]
    lea     eax, [eax+eax*4]
    mov     ecx, [esi+8]
    lea     edx, [ecx+ecx*2]
    mov     ecx, [esi+4]
    mov     ecx, [ecx+edx*8+14h]
    xor     edx, edx
    mov     esi, [ecx+eax*4+10h]
    test    esi, esi
    setnz   dl
    mov     eax, edx
    pop     esi
    retn    4
    sub_4B4BA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4BF0 proc near                    ; CODE XREF: sub_424890+1B4p
                                            ; sub_424890+272p ...
    mov     eax, [ecx]
    mov     ecx, [eax+8]
    mov     edx, [eax+4]
    lea     ecx, [ecx+ecx*2]
    lea     eax, [edx+ecx*8]
    mov     ecx, [edx+ecx*8+0Ch]
    mov     edx, [eax+14h]
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edx+ecx*4+8]
    retn
    sub_4B4BF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4C10 proc near                    ; CODE XREF: sub_4010B0+3Bp
                                            ; sub_401110+3Fp ...

    arg_0= dword ptr  4

    mov     eax, [ecx]
    mov     ecx, [eax+8]
    mov     edx, [eax+4]
    lea     ecx, [ecx+ecx*2]
    lea     eax, [edx+ecx*8]
    mov     ecx, [edx+ecx*8+0Ch]
    mov     edx, [eax+14h]
    mov     eax, [esp+arg_0]
    lea     ecx, [ecx+ecx*4]
    test    eax, eax
    lea     ecx, [edx+ecx*4]
    jge     short loc_4B4C35
    xor     eax, eax

    loc_4B4C35:                             ; CODE XREF: sub_4B4C10+21j
    mov     edx, [ecx+8]
    cmp     eax, edx
    jle     short loc_4B4C3E
    mov     eax, edx

    loc_4B4C3E:                             ; CODE XREF: sub_4B4C10+2Aj
    mov     [ecx+0Ch], eax
    retn    4
    sub_4B4C10 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx]
    mov     ecx, [eax+8]
    mov     edx, [eax+4]
    lea     ecx, [ecx+ecx*2]
    lea     eax, [edx+ecx*8]
    mov     ecx, [edx+ecx*8+0Ch]
    mov     edx, [eax+14h]
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edx+ecx*4+8]
    lea     ecx, [edx+ecx*4]
    mov     [ecx+0Ch], eax
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4C80 proc near                    ; CODE XREF: sub_401110+49p
                                            ; sub_401110+56p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [ecx]
    push    edi
    mov     ecx, [eax+8]
    mov     edx, [eax+4]
    lea     ecx, [ecx+ecx*2]
    lea     eax, [edx+ecx*8]
    mov     ecx, [edx+ecx*8+0Ch]
    mov     edx, [eax+14h]
    lea     ecx, [ecx+ecx*4]
    mov     edi, [edx+ecx*4+0Ch]
    lea     edx, [edx+ecx*4]
    mov     ecx, [edx+8]
    sub     ecx, edi
    test    ecx, ecx
    jg      short loc_4B4CAF
    xor     eax, eax
    pop     edi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B4CAF:                             ; CODE XREF: sub_4B4C80+27j
    mov     eax, [esp+4+arg_4]
    push    esi
    cmp     eax, ecx
    push    ebx
    jle     short loc_4B4CBB
    mov     eax, ecx

    loc_4B4CBB:                             ; CODE XREF: sub_4B4C80+37j
    mov     esi, [edx+10h]
    mov     ecx, eax
    mov     ebx, ecx
    add     esi, edi
    mov     edi, [esp+0Ch+arg_0]
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    pop     ebx
    and     ecx, 3
    rep movsb
    mov     ecx, [edx+0Ch]
    pop     esi
    add     ecx, eax
    pop     edi
    mov     [edx+0Ch], ecx
    retn    8
    sub_4B4C80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4CF0 proc near                    ; CODE XREF: sub_4010B0+45p
                                            ; sub_4010B0+52p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [ecx]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    mov     ecx, [eax+8]
    mov     edx, [eax+4]
    push    esi
    mov     esi, ebp
    lea     ecx, [ecx+ecx*2]
    push    edi
    lea     eax, [edx+ecx*8]
    mov     ecx, [edx+ecx*8+0Ch]
    mov     edx, [eax+14h]
    lea     ecx, [ecx+ecx*4]
    mov     eax, [edx+ecx*4+8]
    lea     ebx, [edx+ecx*4]
    mov     ecx, [edx+ecx*4+0Ch]
    add     esi, ecx
    cmp     esi, eax
    jle     short loc_4B4D36
    mov     eax, [ebx+10h]
    push    esi
    push    eax
    call    sub_4D8580
    add     esp, 8
    mov     [ebx+10h], eax
    mov     [ebx+8], esi

    loc_4B4D36:                             ; CODE XREF: sub_4B4CF0+31j
    mov     edi, [ebx+10h]
    mov     edx, [ebx+0Ch]
    mov     esi, [esp+10h+arg_0]
    mov     ecx, ebp
    add     edi, edx
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     eax, [ebx+0Ch]
    pop     edi
    add     eax, ebp
    pop     esi
    mov     [ebx+0Ch], eax
    mov     eax, ebp
    pop     ebp
    pop     ebx
    retn    8
    sub_4B4CF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4D70 proc near                    ; CODE XREF: sub_4B39C0+93p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    mov     eax, [esp+8+arg_0]
    push    ebx
    push    esi
    push    edi
    mov     esi, ecx
    push    offset aW                       ; "w"
    push    eax
    mov     [esp+1Ch+var_4], esi
    call    _fopen
    mov     edi, eax
    xor     ebx, ebx
    add     esp, 8
    cmp     edi, ebx
    jz      loc_4B4F00
    push    offset aHapibankAuditF          ; "HapiBank Audit File\n\n"
    push    edi
    call    sub_4E4510
    mov     ecx, [esi]
    add     esp, 8
    mov     edx, [ecx]
    push    edx
    push    offset aNumberOfAccoun          ; "Number of accounts: %i\n\n"
    push    edi
    call    sub_4E4510
    mov     eax, [esi]
    add     esp, 0Ch
    mov     [esp+14h+var_8], ebx
    cmp     [eax], ebx
    jle     loc_4B4EE9
    push    ebp
    mov     [esp+18h+arg_0], ebx

    loc_4B4DCE:                             ; CODE XREF: sub_4B4D70+172j
    mov     esi, [eax+4]
    mov     eax, [esp+18h+arg_0]
    add     esi, eax
    mov     eax, [esi]
    push    eax
    push    offset aAccountS                ; "Account:  \"%s\"\n{\n"
    push    edi
    call    sub_4E4510
    mov     eax, [esi+4]
    add     esp, 0Ch
    xor     ebp, ebp
    test    eax, eax
    jle     short loc_4B4E61
    xor     ebx, ebx

    loc_4B4DF3:                             ; CODE XREF: sub_4B4D70+EFj
    mov     eax, [esi+10h]
    add     eax, ebx
    mov     ecx, [eax+4]
    dec     ecx
    jz      short loc_4B4E40
    dec     ecx
    jz      short loc_4B4E2E
    dec     ecx
    jz      short loc_4B4E17
    mov     ecx, [eax]
    push    ecx
    push    offset aItemSUninitial          ; "   Item \"%s\" Uninitialized or Unknown\n"
    push    edi
    call    sub_4E4510
    add     esp, 0Ch
    jmp     short loc_4B4E56
    ; ---------------------------------------------------------------------------

    loc_4B4E17:                             ; CODE XREF: sub_4B4D70+92j
    mov     edx, [eax+8]
    mov     eax, [eax]
    push    edx
    push    eax
    push    offset aItemSStringS            ; "   Item \"%s\" String:  \"%s\"\n"
    push    edi
    call    sub_4E4510
    add     esp, 10h
    jmp     short loc_4B4E56
    ; ---------------------------------------------------------------------------

    loc_4B4E2E:                             ; CODE XREF: sub_4B4D70+8Fj
    mov     ecx, [eax+0Ch]
    mov     edx, [eax+8]
    mov     eax, [eax]
    push    ecx
    push    edx
    push    eax
    push    offset aItemSDoubleF            ; "   Item \"%s\" Double:  %f\n"
    jmp     short loc_4B4E4D
    ; ---------------------------------------------------------------------------

    loc_4B4E40:                             ; CODE XREF: sub_4B4D70+8Cj
    mov     ecx, [eax+8]
    push    ecx
    push    ecx
    mov     ecx, [eax]
    push    ecx
    push    offset aItemSIntegerI0          ; "   Item \"%s\" Integer:  %i (0x%08x)\n"

    loc_4B4E4D:                             ; CODE XREF: sub_4B4D70+CEj
    push    edi
    call    sub_4E4510
    add     esp, 14h

    loc_4B4E56:                             ; CODE XREF: sub_4B4D70+A5j
                                            ; sub_4B4D70+BCj
    mov     eax, [esi+4]
    inc     ebp
    add     ebx, 10h
    cmp     ebp, eax
    jl      short loc_4B4DF3

    loc_4B4E61:                             ; CODE XREF: sub_4B4D70+7Fj
    push    offset byte_50319C
    push    edi
    call    sub_4E4510
    mov     eax, [esi+8]
    add     esp, 8
    xor     ebp, ebp
    test    eax, eax
    jle     short loc_4B4EB6
    xor     ebx, ebx

    loc_4B4E7A:                             ; CODE XREF: sub_4B4D70+144j
    mov     edx, [esi+14h]
    mov     eax, ebx
    add     eax, edx
    cmp     dword ptr [eax], 0
    jz      short loc_4B4E95
    mov     edx, [eax+8]
    mov     eax, [eax+4]
    push    edx
    push    eax
    push    offset aSafeDepositBox          ; "   Safe-Deposit Box \"%s\" contains %i by"...
    jmp     short loc_4B4EA2
    ; ---------------------------------------------------------------------------

    loc_4B4E95:                             ; CODE XREF: sub_4B4D70+114j
    mov     ecx, [eax+8]
    mov     edx, [eax+4]
    push    ecx
    push    edx
    push    offset aSafeDepositB_0          ; "   Safe-Deposit Box #%i contains %i byt"...

    loc_4B4EA2:                             ; CODE XREF: sub_4B4D70+123j
    push    edi
    call    sub_4E4510
    mov     eax, [esi+8]
    add     esp, 10h
    inc     ebp
    add     ebx, 14h
    cmp     ebp, eax
    jl      short loc_4B4E7A

    loc_4B4EB6:                             ; CODE XREF: sub_4B4D70+106j
    push    offset asc_509D40               ; "}\n\n"
    push    edi
    call    sub_4E4510
    mov     eax, [esp+20h+var_4]
    mov     ecx, [esp+20h+var_8]
    mov     esi, [esp+20h+arg_0]
    add     esp, 8
    mov     eax, [eax]
    inc     ecx
    add     esi, 18h
    mov     [esp+18h+var_8], ecx
    mov     edx, [eax]
    mov     [esp+18h+arg_0], esi
    cmp     ecx, edx
    jl      loc_4B4DCE
    pop     ebp

    loc_4B4EE9:                             ; CODE XREF: sub_4B4D70+53j
    push    offset aEof                     ; "----------EOF----------\n"
    push    edi
    call    sub_4E4510
    add     esp, 8
    push    edi
    call    _fclose
    add     esp, 4

    loc_4B4F00:                             ; CODE XREF: sub_4B4D70+24j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn    4
    sub_4B4D70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4B4F10(int)
    sub_4B4F10 proc near                    ; CODE XREF: sub_401C20+49p
                                            ; .text:00401F36p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax                             ; int
    call    sub_4D8660
    add     esp, 4
    retn
    sub_4B4F10 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4F20 proc near                    ; CODE XREF: .text:00401D52p
                                            ; .text:00401D6Ep ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax
    call    sub_4D8670
    add     esp, 4
    retn
    sub_4B4F20 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    push    eax
    call    sub_4D8660
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    push    eax
    call    sub_4D8670
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, dword_51FBD0
    mov     eax, [edx+4Ch]
    test    eax, eax
    jz      short loc_4B4F9B
    mov     eax, [edx+40h]
    push    esi
    push    eax
    call    ds:GetDC
    mov     ecx, dword_51FBD0
    mov     esi, eax
    push    0
    mov     edx, [ecx+4Ch]
    push    edx
    push    esi
    call    ds:SelectPalette
    push    esi
    call    ds:RealizePalette
    mov     eax, dword_51FBD0
    push    esi
    mov     ecx, [eax+40h]
    push    ecx
    call    ds:ReleaseDC
    mov     eax, 1
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4B4F9B:                             ; CODE XREF: .text:004B4F5Bj
    mov     ecx, [edx+88h]
    mov     eax, 80004005h
    test    ecx, ecx
    jz      short loc_4B4FBB
    mov     edx, [edx+94h]
    test    edx, edx
    jz      short loc_4B4FBB
    mov     eax, [ecx]
    push    edx
    push    ecx
    call    dword ptr [eax+7Ch]

    loc_4B4FBB:                             ; CODE XREF: .text:004B4FA8j
                                            ; .text:004B4FB2j
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4FD0 proc near                    ; CODE XREF: sub_450E20+7Ap
                                            ; .text:00457955p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    mov     dword_51FC78, eax
    mov     dword_51FC7C, ecx
    retn    8
    sub_4B4FD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B4FF0 proc near                    ; CODE XREF: sub_4B5510+64p
                                            ; sub_4B5980+2C5p ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    xor     edi, edi
    cmp     [esi+84h], edi
    jz      short loc_4B506A
    mov     eax, [esi+94h]
    cmp     eax, edi
    jz      short loc_4B5016
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+8]
    mov     [esi+94h], edi

    loc_4B5016:                             ; CODE XREF: sub_4B4FF0+18j
    mov     eax, [esi+8Ch]
    cmp     eax, edi
    jz      short loc_4B502C
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+8]
    mov     [esi+8Ch], edi

    loc_4B502C:                             ; CODE XREF: sub_4B4FF0+2Ej
    mov     eax, [esi+88h]
    cmp     eax, edi
    jz      short loc_4B5042
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+8]
    mov     [esi+88h], edi

    loc_4B5042:                             ; CODE XREF: sub_4B4FF0+44j
    mov     eax, [esi+90h]
    cmp     eax, edi
    jz      short loc_4B5058
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+8]
    mov     [esi+90h], edi

    loc_4B5058:                             ; CODE XREF: sub_4B4FF0+5Aj
    mov     eax, [esi+84h]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+8]
    mov     [esi+84h], edi

    loc_4B506A:                             ; CODE XREF: sub_4B4FF0+Ej
    pop     edi
    pop     esi
    retn    4
    sub_4B4FF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B5070 proc near                    ; CODE XREF: .text:004266A0p

    var_D4= dword ptr -0D4h
    hKey= dword ptr -0D0h
    var_CC= dword ptr -0CCh
    var_C8= dword ptr -0C8h
    cbData= dword ptr -0C4h
    hLibModule= dword ptr -0C0h
    Type= dword ptr -0BCh
    Data= byte ptr -0B8h
    var_B4= dword ptr -0B4h
    var_B0= dword ptr -0B0h
    var_9C= dword ptr -9Ch
    var_8C= dword ptr -8Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0CCh
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     esi, esi
    push    offset aDsetup_dll_0            ; lpLibFileName
    mov     ebx, esi
    mov     ebp, esi
    mov     edi, esi
    mov     [esp+0E0h+var_C8], esi
    call    ds:LoadLibraryA
    test    eax, eax
    mov     [esp+0DCh+Type], eax
    mov     [esp+0DCh+cbData], esi
    jz      short loc_4B50F5
    push    offset aDirectxsetupge          ; lpProcName
    push    eax                             ; hModule
    call    ds:GetProcAddress
    xor     ecx, ecx
    cmp     eax, ecx
    jz      short loc_4B50EA
    mov     [esp+0DCh+var_CC], ecx
    mov     [esp+0DCh+hLibModule], ecx
    lea     ecx, [esp+0DCh+hLibModule]
    lea     edx, [esp+0DCh+var_CC]
    push    ecx
    push    edx
    call    eax
    test    eax, eax
    mov     [esp+0E0h+var_CC], eax
    jz      short loc_4B50EA
    mov     eax, [esp+0E0h+hKey]
    mov     esi, [esp+0E0h+cbData]
    mov     ebx, eax
    mov     edi, esi
    and     eax, 0FFFFh
    shr     ebx, 10h
    shr     edi, 10h
    mov     ebp, eax
    and     esi, 0FFFFh

    loc_4B50EA:                             ; CODE XREF: sub_4B5070+3Dj
                                            ; sub_4B5070+59j
    mov     eax, [esp+0E0h+hLibModule]
    push    eax                             ; hLibModule
    call    ds:FreeLibrary

    loc_4B50F5:                             ; CODE XREF: sub_4B5070+2Bj
    mov     eax, [esp+0E0h+var_CC]
    test    eax, eax
    jnz     loc_4B51DE
    lea     ecx, [esp+48h]
    xor     esi, esi
    push    ecx                             ; lpVersionInformation
    mov     ebx, esi
    mov     [esp+0E4h+var_B4], esi
    mov     edi, esi
    mov     [esp+0E4h+var_C8], esi
    mov     dword ptr [esp+4Ch], 94h
    call    ds:GetVersionExA                ; Get extended information about the
                                            ; version of the operating system
    test    eax, eax
    jz      short loc_4B5136
    mov     eax, [esp+58h]
    xor     edx, edx
    cmp     eax, 2
    setz    dl
    mov     [esp+0E0h+var_C8], edx

    loc_4B5136:                             ; CODE XREF: sub_4B5070+B4j
    lea     eax, [esp+0E0h+hKey]
    xor     ebp, ebp
    push    eax                             ; phkResult
    push    20019h                          ; samDesired
    push    ebp                             ; ulOptions
    push    offset aSoftwareMicros          ; lpSubKey
    push    80000002h                       ; hKey
    mov     [esp+0F4h+hKey], ebp
    call    ds:RegOpenKeyExA
    cmp     eax, ebp
    jnz     loc_4B52BA
    mov     eax, [esp+0E0h+var_C8]
    mov     [esp+0E0h+var_CC], ebp
    cmp     eax, ebp
    jz      short loc_4B518F
    lea     ecx, [esp+0E0h+hLibModule]
    lea     edx, [esp+0E0h+var_CC]
    push    ecx
    mov     ecx, [esp+0E4h+hKey]
    lea     eax, [esp+0E4h+Type]
    push    edx
    push    eax
    push    ebp
    push    offset aInstalledversi          ; "InstalledVersion"
    mov     [esp+0F4h+hLibModule], 4
    push    ecx
    jmp     short loc_4B51B1
    ; ---------------------------------------------------------------------------

    loc_4B518F:                             ; CODE XREF: sub_4B5070+F9j
    lea     edx, [esp+0E0h+cbData]
    lea     eax, [esp+0E0h+Data]
    push    edx                             ; lpcbData
    mov     edx, [esp+0E4h+hKey]
    lea     ecx, [esp+0E4h+Type]
    push    eax                             ; lpData
    push    ecx                             ; lpType
    push    ebp                             ; lpReserved
    push    offset aVersion_2               ; lpValueName
    mov     [esp+0F4h+cbData], 1Eh
    push    edx                             ; hKey

    loc_4B51B1:                             ; CODE XREF: sub_4B5070+11Dj
    call    ds:RegQueryValueExA
    mov     ebp, eax
    mov     eax, [esp+0E0h+hKey]
    push    eax                             ; hKey
    call    ds:RegCloseKey
    test    ebp, ebp
    jnz     loc_4B52BA
    mov     eax, [esp+0E0h+var_C8]
    test    eax, eax
    jz      short loc_4B524A
    mov     ebp, [esp+0E0h+var_CC]
    and     ebp, 0FFh

    loc_4B51DE:                             ; CODE XREF: sub_4B5070+8Bj
                                            ; sub_4B5070+245j
    mov     eax, [esp+0E0h+var_C8]
    test    eax, eax
    jz      short loc_4B51FD
    cmp     ebp, [esp+0F0h]
    sbb     eax, eax
    inc     eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4B51FD:                             ; CODE XREF: sub_4B5070+174j
    cmp     ebx, [esp+0E0h]
    jnz     short loc_4B5233
    mov     eax, [esp+0E0h+arg_0]
    cmp     ebp, eax
    jnz     short loc_4B523A
    mov     eax, [esp+0E0h+arg_4]
    cmp     edi, eax
    jnz     short loc_4B523A
    cmp     esi, [esp+0E0h+arg_8]
    sbb     eax, eax
    inc     eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4B5233:                             ; CODE XREF: sub_4B5070+194j
    cmp     ebx, [esp+0E0h+arg_0]

    loc_4B523A:                             ; CODE XREF: sub_4B5070+19Fj
                                            ; sub_4B5070+1AAj
    sbb     eax, eax
    inc     eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0CCh
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4B524A:                             ; CODE XREF: sub_4B5070+162j
    lea     ecx, [esp+0E0h+Data]
    push    offset a__1                     ; char *
    push    ecx                             ; char *
    call    _strtok
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    mov     ebx, eax
    push    offset a__1                     ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    mov     ebp, eax
    push    offset a__1                     ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    mov     edi, eax
    push    offset a__1                     ; char *
    push    0                               ; char *
    call    _strtok
    add     esp, 8
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    mov     esi, eax
    jmp     loc_4B51DE
    ; ---------------------------------------------------------------------------

    loc_4B52BA:                             ; CODE XREF: sub_4B5070+E9j
                                            ; sub_4B5070+156j
    xor     edx, edx
    pop     edi
    mov     dword ptr [esp+0DCh+Data], edx
    pop     esi
    mov     [esp+0D8h+var_B4], edx
    pop     ebp
    mov     [esp+0D4h+var_B0], edx
    xor     eax, eax
    mov     [esp+28h], edx
    pop     ebx
    add     esp, 0CCh
    retn    14h
    sub_4B5070 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B52E0 proc near                    ; CODE XREF: sub_49E830+C2p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    xor     ecx, ecx
    and     word ptr [eax+202h], 0FC00h
    mov     dword ptr [eax+1FAh], 280h
    mov     dword ptr [eax+1FEh], 1E0h
    mov     [eax+1EAh], ecx
    mov     [eax+1EEh], ecx
    mov     dword ptr [eax+1F2h], 27Fh
    mov     dword ptr [eax+1F6h], 1DFh
    mov     dword ptr [eax+614h], 3F800000h
    retn    4
    sub_4B52E0 endp

    ; ---------------------------------------------------------------------------

    loc_4B5330:                             ; DATA XREF: sub_4B5370+170o
    mov     eax, [esp+8]
    push    esi
    mov     ecx, [eax]
    mov     edx, [eax+4]
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [edx+ecx*4]
    mov     edx, [esp+8]
    cmp     dword ptr [edx+54h], 8
    jnz     short loc_4B5360
    mov     esi, [edx+0Ch]
    mov     [ecx], esi
    mov     esi, [edx+8]
    mov     [ecx+4], esi
    mov     edx, [edx+18h]
    mov     [ecx+8], edx
    mov     ecx, [eax]
    inc     ecx
    mov     [eax], ecx

    loc_4B5360:                             ; CODE XREF: .text:004B5348j
    mov     eax, 1
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B5370 proc near                    ; CODE XREF: sub_446310+33p
                                            ; sub_45E5E0+EEp

    var_24= dword ptr -24h
    var_10= dword ptr -10h
    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     eax, dword_51FBD0
    push    ebx
    xor     ebx, ebx
    push    esi
    mov     ecx, [eax+44h]
    push    edi
    cmp     ecx, ebx
    jz      loc_4B54AF
    mov     esi, [esp+10h+arg_0]
    mov     edi, ds:GetSystemMetrics
    push    ebp
    push    ebx                             ; nIndex
    mov     ecx, [esi+4]
    mov     [esi], ebx
    mov     dword ptr [ecx], 280h
    mov     eax, [esi]
    lea     edx, [eax+eax*2]
    mov     eax, [esi+4]
    mov     dword ptr [eax+edx*4+4], 1E0h
    mov     eax, [esi]
    mov     edx, [esi+4]
    lea     ecx, [eax+eax*2]
    mov     [edx+ecx*4+8], ebx
    mov     ecx, [esi]
    inc     ecx
    mov     eax, ecx
    mov     [esi], ecx
    mov     ecx, [esi+4]
    lea     eax, [eax+eax*2]
    mov     dword ptr [ecx+eax*4], 320h
    mov     eax, [esi]
    lea     edx, [eax+eax*2]
    mov     eax, [esi+4]
    mov     dword ptr [eax+edx*4+4], 258h
    mov     eax, [esi]
    mov     edx, [esi+4]
    lea     ecx, [eax+eax*2]
    mov     [edx+ecx*4+8], ebx
    mov     eax, [esi]
    mov     ecx, [esi+4]
    inc     eax
    mov     [esi], eax
    lea     eax, [eax+eax*2]
    mov     dword ptr [ecx+eax*4], 400h
    mov     eax, [esi]
    lea     edx, [eax+eax*2]
    mov     eax, [esi+4]
    mov     dword ptr [eax+edx*4+4], 300h
    mov     eax, [esi]
    mov     edx, [esi+4]
    lea     ecx, [eax+eax*2]
    mov     [edx+ecx*4+8], ebx
    mov     ebp, [esi]
    inc     ebp
    mov     [esi], ebp
    call    edi ; GetSystemMetrics
    push    1                               ; nIndex
    mov     ebp, eax
    call    edi ; GetSystemMetrics
    cmp     ebp, 500h
    jl      short loc_4B5463
    cmp     eax, 400h
    jl      short loc_4B5463
    mov     ecx, [esi]
    mov     edx, [esi+4]
    lea     ecx, [ecx+ecx*2]
    mov     dword ptr [edx+ecx*4], 500h
    mov     ecx, [esi]
    mov     edx, [esi+4]
    lea     ecx, [ecx+ecx*2]
    mov     dword ptr [edx+ecx*4+4], 400h
    mov     ecx, [esi]
    mov     edx, [esi+4]
    lea     ecx, [ecx+ecx*2]
    mov     [edx+ecx*4+8], ebx
    mov     ecx, [esi]
    inc     ecx
    mov     [esi], ecx

    loc_4B5463:                             ; CODE XREF: sub_4B5370+BAj
                                            ; sub_4B5370+C1j
    cmp     ebp, 640h
    jl      short loc_4B54A2
    cmp     eax, 4B0h
    jl      short loc_4B54A2
    mov     eax, [esi]
    mov     ecx, [esi+4]
    lea     eax, [eax+eax*2]
    mov     dword ptr [ecx+eax*4], 640h
    mov     eax, [esi]
    lea     edx, [eax+eax*2]
    mov     eax, [esi+4]
    mov     dword ptr [eax+edx*4+4], 4B0h
    mov     eax, [esi]
    mov     edx, [esi+4]
    lea     ecx, [eax+eax*2]
    mov     [edx+ecx*4+8], ebx
    mov     eax, [esi]
    inc     eax
    mov     [esi], eax

    loc_4B54A2:                             ; CODE XREF: sub_4B5370+F9j
                                            ; sub_4B5370+100j
    mov     eax, 1
    pop     ebp
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B54AF:                             ; CODE XREF: sub_4B5370+10j
    mov     esi, [esp+10h+arg_0]
    mov     [esp+10h+var_4], ebx
    lea     edx, [esp+10h+var_4]
    mov     edi, 1
    mov     [esi], ebx
    mov     eax, dword_51FBD0
    push    edx
    push    offset dword_4FCCD8
    mov     eax, [eax+84h]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx]
    cmp     eax, ebx
    jnz     short loc_4B54F2
    mov     eax, [esp+10h+var_4]
    push    offset loc_4B5330
    push    esi
    push    ebx
    mov     ecx, [eax]
    push    ebx
    push    eax
    call    dword ptr [ecx+20h]
    cmp     eax, ebx
    jz      short loc_4B54F4

    loc_4B54F2:                             ; CODE XREF: sub_4B5370+16Aj
    xor     edi, edi

    loc_4B54F4:                             ; CODE XREF: sub_4B5370+180j
    mov     eax, [esp+10h+var_4]
    cmp     eax, ebx
    jz      short loc_4B5502
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+8]

    loc_4B5502:                             ; CODE XREF: sub_4B5370+18Aj
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    sub_4B5370 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B5510 proc near                    ; CODE XREF: sub_4B5910+14p
                                            ; sub_4B5910+1Cp ...

    var_4F4= dword ptr -4F4h
    var_4E0= dword ptr -4E0h
    var_4DC= dword ptr -4DCh
    var_4D8= dword ptr -4D8h
    var_4D4= dword ptr -4D4h
    var_4D0= dword ptr -4D0h
    var_4CC= dword ptr -4CCh
    var_478= dword ptr -478h
    var_428= BITMAPINFO ptr -428h
    arg_0= dword ptr  4

    sub     esp, 4D0h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ds:WaitForSingleObject
    mov     esi, 4D41494Eh
    xor     ebp, ebp

    loc_4B5527:                             ; CODE XREF: sub_4B5510+39j
    push    esi                             ; Value
    push    offset Target                   ; Target
    call    ds:InterlockedExchange
    cmp     eax, ebp
    jz      short loc_4B554B
    cmp     dword_52A4EC, esi
    jz      short loc_4B5557
    mov     eax, hHandle
    push    0FFFFFFFFh                      ; dwMilliseconds
    push    eax                             ; hHandle
    call    edi ; WaitForSingleObject
    jmp     short loc_4B5527
    ; ---------------------------------------------------------------------------

    loc_4B554B:                             ; CODE XREF: sub_4B5510+25j
    mov     dword_52A4EC, esi
    mov     [esp+4E0h+var_4D0], ebp
    jmp     short loc_4B555B
    ; ---------------------------------------------------------------------------

    loc_4B5557:                             ; CODE XREF: sub_4B5510+2Dj
    mov     [esp+4E0h+var_4D0], eax

    loc_4B555B:                             ; CODE XREF: sub_4B5510+45j
    mov     esi, dword_51FBD0
    mov     [esi+9Ch], ebp
    mov     ecx, dword_51FBD0
    lea     ebx, [esi+84h]
    push    ecx
    call    sub_4B4FF0
    mov     edi, dword_51FBD0
    lea     eax, [edi+48h]
    mov     [esp+4E0h+var_4CC], eax
    mov     eax, [eax]
    cmp     eax, ebp
    jz      short loc_4B5593
    push    eax                             ; HDC
    call    ds:DeleteDC

    loc_4B5593:                             ; CODE XREF: sub_4B5510+7Aj
    mov     eax, [edi+4Ch]
    cmp     eax, ebp
    jz      short loc_4B55A1
    push    eax                             ; HGDIOBJ
    call    ds:DeleteObject

    loc_4B55A1:                             ; CODE XREF: sub_4B5510+88j
    mov     eax, [edi+44h]
    cmp     eax, ebp
    jz      short loc_4B55AF
    push    eax                             ; HGDIOBJ
    call    ds:DeleteObject

    loc_4B55AF:                             ; CODE XREF: sub_4B5510+96j
    mov     edx, [esp+4E0h+var_4CC]
    mov     [edi+4Ch], ebp
    mov     [edi+44h], ebp
    push    6                               ; uFlags
    mov     [edx], ebp
    mov     eax, dword_51FBD0
    mov     ecx, [eax+0D8h]
    mov     edx, [eax+0D4h]
    mov     eax, [esi+40h]
    push    ecx                             ; cy
    push    edx                             ; cx
    push    ebp                             ; Y
    push    ebp                             ; X
    push    ebp                             ; hWndInsertAfter
    push    eax                             ; hWnd
    call    ds:SetWindowPos
    mov     eax, [esp+4E0h+arg_0]
    cmp     eax, ebp
    mov     eax, dword_51FBD0
    jz      loc_4B57C0
    or      byte ptr [eax+0F0h], 2
    push    ebp                             ; pUnkOuter
    push    ebx                             ; lplpDD
    push    ebp                             ; lpGUID
    call    DirectDrawCreate
    cmp     eax, ebp
    jnz     loc_4B578C
    mov     eax, [ebx]
    mov     edx, [esi+40h]
    push    53h
    push    edx
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+50h]
    cmp     eax, ebp
    jnz     loc_4B578C
    mov     ecx, dword_51FBD0
    mov     eax, [ebx]
    push    8
    mov     edi, [ecx+0D8h]
    mov     ecx, [ecx+0D4h]
    mov     edx, [eax]
    push    edi
    push    ecx
    push    eax
    call    dword ptr [edx+54h]
    cmp     eax, ebp
    jnz     loc_4B578C
    mov     ecx, 1Bh
    xor     eax, eax
    lea     edi, [esp+4FCh+var_4E0]
    push    ebp
    rep stosd

    loc_4B5652:                             ; DATA XREF: .data:005110F4o
    mov     eax, dword_51FBD0
    mov     [esp+500h+var_4E0], 6Ch
    mov     [esp+500h+var_4DC], 21h
    lea     edi, [ebx+4]
    mov     edx, [eax+0D4h]
    push    edi
    mov     [esp+504h+var_4D4], edx
    mov     eax, [eax+0D8h]
    mov     [esp+504h+var_4D8], eax
    mov     [esp+504h+var_478], 218h
    mov     [esp+504h+var_4CC], 1
    mov     eax, [ebx]
    lea     edx, [esp+504h+var_4E0]
    mov     ecx, [eax]
    push    edx
    push    eax
    call    dword ptr [ecx+18h]
    cmp     eax, ebp
    jnz     loc_4B578C
    mov     [esp+50Ch+var_4F4], 4
    mov     edi, [edi]
    lea     ecx, [ebx+8]
    lea     edx, [esp+50Ch+var_4F4]
    mov     eax, [edi]
    push    ecx
    push    edx
    push    edi
    call    dword ptr [eax+30h]
    cmp     eax, ebp
    jnz     loc_4B578C
    mov     eax, [ebx]
    lea     edi, [ebx+0Ch]
    push    ebp
    mov     dword ptr [ebx+18h], 1
    mov     ecx, [eax]
    push    edi
    push    ebp
    push    eax
    call    dword ptr [ecx+10h]
    cmp     eax, ebp
    jnz     loc_4B578C
    mov     eax, [edi]
    mov     ecx, [esi+40h]
    push    ecx
    push    ebp
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+20h]
    cmp     eax, ebp
    jnz     loc_4B578C
    mov     eax, [ebx+4]
    mov     ecx, [edi]
    lea     esi, [ebx+4]
    push    ecx
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+70h]
    cmp     eax, ebp
    jnz     short loc_4B578C
    mov     eax, [ebx]
    mov     ecx, dword_51FBD0
    add     ebx, 10h
    push    ebp
    mov     edx, [eax]
    add     ecx, 214h
    push    ebx
    push    ecx
    push    4
    push    eax
    call    dword ptr [edx+14h]
    cmp     eax, ebp
    jnz     short loc_4B573C
    mov     eax, [esi]
    mov     ecx, [ebx]
    push    ecx
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+7Ch]
    cmp     eax, ebp
    jnz     short loc_4B578C

    loc_4B573C:                             ; CODE XREF: sub_4B5510+21Bj
    mov     edx, dword_51FBD0
    cmp     [edx+98h], ebp
    jz      loc_4B58BC
    lea     eax, [esp+558h+var_4D0]
    push    eax
    call    sub_4C5E70
    mov     ecx, dword_51FBD0
    push    ebp
    push    ebp
    lea     eax, [esp+560h+var_4D0]
    mov     edx, [ecx+98h]
    push    edx
    push    eax
    call    sub_4CBBE0
    add     esp, 10h
    lea     ecx, [esp+558h+var_4D0]
    push    ecx
    call    sub_4C5FA0
    jmp     loc_4B58BC
    ; ---------------------------------------------------------------------------

    loc_4B578C:                             ; CODE XREF: sub_4B5510+F2j
                                            ; sub_4B5510+108j ...
    cmp     [esp+4E0h+var_4D0], ebp
    jnz     short loc_4B57B1
    push    ebp                             ; Value
    push    offset Target                   ; Target
    mov     dword_52A4EC, ebp
    call    ds:InterlockedExchange
    mov     edx, hHandle
    push    edx                             ; hEvent
    call    ds:SetEvent

    loc_4B57B1:                             ; CODE XREF: sub_4B5510+280j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 4D0h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B57C0:                             ; CODE XREF: sub_4B5510+DBj
    and     word ptr [eax+0F0h], 0FFFDh
    mov     eax, [esi+40h]
    push    eax                             ; hWnd
    call    ds:GetDC
    mov     edi, eax
    push    edi                             ; HDC
    call    ds:CreateCompatibleDC
    mov     ecx, [esi+40h]
    push    edi                             ; hDC
    push    ecx                             ; hWnd
    mov     [esi+48h], eax
    call    ds:ReleaseDC
    mov     eax, dword_51FBD0
    mov     [esp+4E0h+var_428.bmiHeader.biSize], 28h
    mov     ecx, 100h
    lea     edi, [esp+4E0h+var_428.bmiColors]
    mov     edx, [eax+0D4h]
    push    ebp                             ; DWORD
    mov     [esp+4E4h+var_428.bmiHeader.biWidth], edx
    mov     eax, [eax+0D8h]
    neg     eax
    mov     [esp+4E4h+var_428.bmiHeader.biHeight], eax
    xor     eax, eax
    mov     [esp+4E4h+var_428.bmiHeader.biPlanes], 1
    mov     [esp+4E4h+var_428.bmiHeader.biCompression], ebp
    mov     [esp+4E4h+var_428.bmiHeader.biBitCount], 8
    mov     [esp+4E4h+var_428.bmiHeader.biSizeImage], ebp
    mov     [esp+4E4h+var_428.bmiHeader.biClrUsed], ebp
    mov     [esp+4E4h+var_428.bmiHeader.biClrImportant], ebp
    rep stosd
    mov     eax, [esi+48h]
    lea     ecx, [esp+4E4h+var_4CC]
    push    ebp                             ; HANDLE
    push    ecx                             ; void **
    lea     edx, [esp+4ECh+var_428]
    push    ebp                             ; UINT
    push    edx                             ; BITMAPINFO *
    push    eax                             ; HDC
    call    ds:CreateDIBSection
    mov     [esi+44h], eax
    mov     ecx, dword_51FBD0
    mov     edx, [esp+4E0h+var_4CC]
    mov     eax, [ecx+0D4h]
    mov     ecx, [ecx+0D8h]
    push    edx
    lea     edx, [eax+3]
    and     edx, 0FFFFFFFCh
    push    edx
    push    ecx
    lea     edx, [esi+50h]
    push    eax
    push    edx
    call    sub_4C6A60
    mov     eax, [esi+44h]
    mov     ecx, [esi+48h]
    push    eax                             ; HGDIOBJ
    push    ecx                             ; HDC
    call    ds:SelectObject
    mov     edx, [esi+40h]
    push    13h                             ; uFlags
    push    ebp                             ; cy
    push    ebp                             ; cx
    push    ebp                             ; Y
    push    ebp                             ; X
    push    0FFFFFFFEh                      ; hWndInsertAfter
    push    edx                             ; hWnd
    call    ds:SetWindowPos

    loc_4B58BC:                             ; CODE XREF: sub_4B5510+238j
                                            ; sub_4B5510+277j
    mov     eax, dword_51FBD0
    push    100h
    add     eax, 214h
    push    ebp
    push    eax
    call    sub_4BA200
    cmp     [esp+4E0h+var_4D0], ebp
    jnz     short loc_4B58F7
    push    ebp                             ; Value
    push    offset Target                   ; Target
    mov     dword_52A4EC, ebp
    call    ds:InterlockedExchange
    mov     ecx, hHandle
    push    ecx                             ; hEvent
    call    ds:SetEvent

    loc_4B58F7:                             ; CODE XREF: sub_4B5510+3C6j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 4D0h
    retn    4
    sub_4B5510 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B5910 proc near                    ; CODE XREF: .text:00417B2Ep
                                            ; sub_451640+EDp ...
    mov     eax, dword_51FBD0
    mov     cl, [eax+0F0h]
    shr     cl, 1
    test    cl, 1
    jz      short loc_4B592A
    push    0
    call    sub_4B5510
    retn
    ; ---------------------------------------------------------------------------

    loc_4B592A:                             ; CODE XREF: sub_4B5910+10j
    push    1
    call    sub_4B5510
    retn
    sub_4B5910 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B5940 proc near                    ; CODE XREF: sub_491A70+9Bp
                                            ; sub_497F40+177p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, dword_51FBD0
    mov     ecx, [esp+arg_0]
    mov     [eax+0D4h], ecx
    mov     edx, dword_51FBD0
    mov     eax, [esp+arg_4]
    mov     [edx+0D8h], eax
    mov     ecx, dword_51FBD0
    mov     dl, [ecx+0F0h]
    shr     edx, 1
    and     edx, 1
    push    edx
    call    sub_4B5510
    retn    8
    sub_4B5940 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B5980 proc near                    ; CODE XREF: sub_49E830+147p

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    Buffer= _MEMORYSTATUS ptr -20h
    arg_0= dword ptr  4

    sub     esp, 38h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+44h+arg_0]
    lea     eax, [esp+44h+Buffer]
    push    edi
    push    eax                             ; lpBuffer
    mov     dword_51FBD0, esi
    mov     [esp+4Ch+Buffer.dwLength], 20h
    call    ds:GlobalMemoryStatus
    mov     edi, ds:SystemParametersInfoA
    push    1                               ; fWinIni
    mov     ecx, [esp+4Ch+Buffer.dwTotalPhys]
    xor     ebx, ebx
    mov     [esi+620h], ecx
    mov     edx, dword_51FBD0
    add     edx, 0ECh
    push    edx                             ; pvParam
    push    ebx                             ; uiParam
    push    5Eh                             ; uiAction
    call    edi ; SystemParametersInfoA
    push    1                               ; fWinIni
    push    ebx                             ; pvParam
    push    ebx                             ; uiParam
    push    5Dh                             ; uiAction
    call    edi ; SystemParametersInfoA
    mov     [esi+1DAh], ebx
    call    ds:__imp_GetTickCount
    mov     [esi+1DEh], eax
    mov     [esi+1E2h], ebx
    mov     [esi+1E6h], ebx
    mov     [esi+84h], ebx
    mov     cx, [esi+202h]
    mov     [esi+88h], ebx
    mov     [esi+8Ch], ebx
    mov     [esi+90h], ebx
    mov     [esi+94h], ebx
    mov     [esi+98h], ebx
    mov     [esi+624h], ebx
    mov     [esi+0DCh], ebx
    and     word ptr [esi+0F0h], 0F7FFh
    mov     [esi+40h], ebx
    mov     ax, [esi+0F0h]
    and     ecx, 200h
    and     eax, 0FBFFh
    push    1Eh
    shl     ecx, 1
    or      eax, ecx
    mov     [esi+0F0h], ax
    call    sub_4C1A60
    mov     dx, [esi+0F0h]
    shr     edx, 0Ah
    and     edx, 1
    push    edx
    push    14h
    call    sub_4C2BD0
    mov     [esp+48h+var_38], ebx
    mov     [esp+48h+var_34], ebx
    mov     [esp+48h+var_30], ebx
    mov     [esi+728h], bl
    call    sub_4BCE10
    lea     eax, [esp+48h+var_38]
    push    eax
    call    sub_4C2360
    mov     cx, [esi+202h]
    mov     ax, [esi+0F0h]
    and     ecx, 1FEh
    mov     edi, [esi+1FAh]
    mov     ebp, [esi+1FEh]
    and     eax, 0FC03h
    shl     ecx, 1
    or      eax, ecx
    mov     [esi+618h], ebx
    or      al, 1
    mov     [esi+61Ch], ebx
    mov     [esi+0F0h], ax
    mov     [esi+0D4h], edi
    shr     al, 6
    test    al, 1
    mov     [esi+0D8h], ebp
    jz      short loc_4B5AE6
    push    esi
    call    sub_4BA610
    jmp     short loc_4B5AEC
    ; ---------------------------------------------------------------------------

    loc_4B5AE6:                             ; CODE XREF: sub_4B5980+15Cj
    mov     [esi+0C4h], ebx

    loc_4B5AEC:                             ; CODE XREF: sub_4B5980+164j
    mov     cl, [esi+0F0h]
    shr     cl, 5
    test    cl, 1
    jz      short loc_4B5B00
    push    esi
    call    sub_4BA5C0

    loc_4B5B00:                             ; CODE XREF: sub_4B5980+178j
    mov     dl, [esi+0F0h]
    shr     dl, 7
    test    dl, 1
    jz      short loc_4B5B16
    push    esi
    call    sub_4BA660
    jmp     short loc_4B5B1C
    ; ---------------------------------------------------------------------------

    loc_4B5B16:                             ; CODE XREF: sub_4B5980+18Cj
    mov     [esi+0C8h], ebx

    loc_4B5B1C:                             ; CODE XREF: sub_4B5980+194j
    xor     eax, eax
    mov     al, [esi+0F1h]
    test    al, 1
    jz      short loc_4B5B2E
    push    esi
    call    sub_4BA6B0

    loc_4B5B2E:                             ; CODE XREF: sub_4B5980+1A6j
    mov     cx, [esi+0F0h]
    shr     ecx, 9
    test    cl, 1
    jz      short loc_4B5B43
    push    esi
    call    sub_4BA700

    loc_4B5B43:                             ; CODE XREF: sub_4B5980+1BBj
    mov     dl, [esi+0F0h]
    shr     dl, 2
    test    dl, 1
    jz      loc_4B5CA5
    lea     eax, [esi+1EAh]
    lea     ecx, [esi+0A0h]
    push    7F00h                           ; lpIconName
    mov     [esi+48h], ebx
    mov     edx, [eax]
    mov     [esi+4Ch], ebx
    mov     [ecx], edx
    mov     [esi+44h], ebx
    mov     edx, [eax+4]
    mov     [esi+80h], ebx
    mov     [ecx+4], edx
    mov     dword ptr [esi+1Ch], offset sub_4B5CC0
    mov     edx, [eax+8]
    mov     dword ptr [esi+18h], 8
    mov     [ecx+8], edx
    mov     eax, [eax+0Ch]
    mov     [ecx+0Ch], eax
    mov     eax, [esi]
    mov     ecx, [esi+8]
    push    eax                             ; hInstance
    mov     [esi+28h], eax
    mov     [esi+3Ch], ecx
    call    ds:LoadIconA
    mov     edx, [esi]
    push    67h                             ; lpCursorName
    push    edx                             ; hInstance
    mov     [esi+2Ch], eax
    call    ds:LoadCursorA
    mov     [esi+30h], eax
    xor     eax, eax
    mov     ax, [esi+14h]
    push    4                               ; int
    mov     [esi+38h], eax
    mov     [esi+20h], ebx
    mov     [esi+24h], ebx
    call    ds:GetStockObject
    mov     [esi+34h], eax
    lea     eax, [esi+18h]
    push    eax                             ; lpWndClass
    call    ds:RegisterClassA
    and     eax, 0FFFFh
    mov     [esp+48h+arg_0], eax
    jz      short loc_4B5C44
    mov     ecx, [esi]
    mov     edx, [esi+0Ch]
    push    ebx                             ; lpParam
    mov     eax, [esi+8]
    push    ecx                             ; hInstance
    push    ebx                             ; hMenu
    push    ebx                             ; hWndParent
    push    ebp                             ; nHeight
    push    edi                             ; nWidth
    push    80000000h                       ; Y
    push    80000000h                       ; X
    push    90080000h                       ; dwStyle
    push    edx                             ; lpWindowName
    push    eax                             ; lpClassName
    push    40000h                          ; dwExStyle
    call    ds:CreateWindowExA
    cmp     eax, ebx
    mov     [esi+40h], eax
    jz      short loc_4B5C44
    mov     ecx, [esi+4]
    push    ecx                             ; nCmdShow
    push    eax                             ; hWnd
    call    ds:ShowWindow
    mov     edx, [esi+40h]
    push    edx                             ; hWnd
    call    ds:UpdateWindow
    mov     al, [esi+202h]
    and     eax, 1
    push    eax
    call    sub_4B5510
    cmp     eax, ebx
    jnz     short loc_4B5CA5

    loc_4B5C44:                             ; CODE XREF: sub_4B5980+269j
                                            ; sub_4B5980+29Aj
    push    esi
    call    sub_4B4FF0
    mov     eax, [esi+48h]
    cmp     eax, ebx
    jz      short loc_4B5C58
    push    eax                             ; HDC
    call    ds:DeleteDC

    loc_4B5C58:                             ; CODE XREF: sub_4B5980+2CFj
    mov     eax, [esi+4Ch]
    mov     edi, ds:DeleteObject
    cmp     eax, ebx
    jz      short loc_4B5C68
    push    eax                             ; HGDIOBJ
    call    edi ; DeleteObject

    loc_4B5C68:                             ; CODE XREF: sub_4B5980+2E3j
    mov     eax, [esi+44h]
    cmp     eax, ebx
    jz      short loc_4B5C72
    push    eax                             ; HGDIOBJ
    call    edi ; DeleteObject

    loc_4B5C72:                             ; CODE XREF: sub_4B5980+2EDj
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+40h]
    push    ebx                             ; uType
    push    ecx                             ; lpCaption
    push    offset aErrorEnvironme          ; lpText
    push    edx                             ; hWnd
    mov     [esi+48h], ebx
    mov     [esi+4Ch], ebx
    mov     [esi+44h], ebx
    call    ds:MessageBoxA
    mov     eax, [esi+40h]
    push    eax                             ; hWnd
    call    ds:DestroyWindow
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 38h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B5CA5:                             ; CODE XREF: sub_4B5980+1CFj
                                            ; sub_4B5980+2C2j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 38h
    retn    4
    sub_4B5980 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B5CC0 proc near                    ; DATA XREF: sub_4B5980+1FFo

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    hWnd= dword ptr  4
    arg_4= dword ptr  8
    wParam= dword ptr  0Ch
    lParam= dword ptr  10h

    sub     esp, 18h
    push    esi
    mov     esi, [esp+1Ch+arg_4]
    cmp     esi, 6
    ja      short loc_4B5D42
    jz      short loc_4B5D09
    mov     eax, esi
    dec     eax
    jz      loc_4B606C
    dec     eax
    jnz     loc_4B5FA8                      ; default
    mov     eax, dword_51FBD0
    mov     cl, [eax+0F0h]
    shr     cl, 1
    test    cl, 1
    jz      short loc_4B5CF8
    push    0
    call    sub_4B5510

    loc_4B5CF8:                             ; CODE XREF: sub_4B5CC0+2Fj
    push    0                               ; nExitCode
    call    ds:PostQuitMessage
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5D09:                             ; CODE XREF: sub_4B5CC0+Dj
    cmp     word ptr [esp+1Ch+wParam], 0
    jnz     short loc_4B5D2A
    mov     edx, dword_51FBD0
    xor     eax, eax
    mov     dword ptr [edx+0E0h], 0
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5D2A:                             ; CODE XREF: sub_4B5CC0+4Fj
    mov     eax, dword_51FBD0
    mov     dword ptr [eax+0E0h], 1
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5D42:                             ; CODE XREF: sub_4B5CC0+Bj
    cmp     esi, 100h
    ja      short loc_4B5D9C
    jz      short loc_4B5D87
    cmp     esi, 10h
    jnz     loc_4B5FA8                      ; default
    mov     eax, dword_51FC78
    test    eax, eax
    jz      short loc_4B5D73
    mov     ecx, dword_51FC7C
    push    ecx
    call    eax
    add     esp, 4
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5D73:                             ; CODE XREF: sub_4B5CC0+9Cj
    mov     edx, [esp+1Ch+hWnd]
    push    edx                             ; hWnd
    call    ds:DestroyWindow
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5D87:                             ; CODE XREF: sub_4B5CC0+8Aj
    mov     eax, [esp+1Ch+wParam]
    push    0
    push    eax
    call    sub_4C1D50
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5D9C:                             ; CODE XREF: sub_4B5CC0+88j
    cmp     esi, 112h
    ja      loc_4B5E29
    jz      short loc_4B5DF8
    mov     eax, esi
    sub     eax, 102h
    jz      short loc_4B5DE5
    sub     eax, 2
    jnz     loc_4B5FA8                      ; default
    mov     esi, [esp+1Ch+wParam]
    push    1
    push    esi
    call    sub_4C1D50
    mov     ecx, [esp+1Ch+lParam]
    mov     edx, [esp+1Ch+hWnd]
    push    ecx                             ; lParam
    push    esi                             ; wParam
    push    104h                            ; Msg
    push    edx                             ; hWnd
    call    ds:DefWindowProcA
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5DE5:                             ; CODE XREF: sub_4B5CC0+F1j
    mov     eax, [esp+1Ch+wParam]
    push    eax
    call    sub_4C1B20
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5DF8:                             ; CODE XREF: sub_4B5CC0+E8j
    mov     eax, [esp+1Ch+wParam]
    cmp     eax, 0F100h
    jnz     short loc_4B5E0C
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5E0C:                             ; CODE XREF: sub_4B5CC0+141j
    mov     ecx, [esp+1Ch+lParam]
    mov     edx, [esp+1Ch+hWnd]
    push    ecx                             ; lParam
    push    eax                             ; wParam
    push    112h                            ; Msg
    push    edx                             ; hWnd
    call    ds:DefWindowProcA
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5E29:                             ; CODE XREF: sub_4B5CC0+E2j
    cmp     esi, 219h
    ja      loc_4B5F8F
    jz      loc_4B5F5F
    lea     eax, [esi-200h]                 ; switch 7 cases
    cmp     eax, 6
    ja      loc_4B5FA8                      ; default
    jmp     ds:off_4B60F4[eax*4]            ; switch jump

    loc_4B5E51:                             ; DATA XREF: .text:004B60F4o
    mov     eax, [esp+1Ch+lParam]           ; case 0x200
    mov     edx, [esp+1Ch+wParam]
    mov     ecx, eax
    mov     [esp+1Ch+var_10], edx
    and     ecx, 0FFFFh
    shr     eax, 10h
    mov     [esp+1Ch+var_18], ecx
    mov     [esp+1Ch+var_14], eax
    call    ds:__imp_GetTickCount
    mov     edx, dword_51FBD0
    mov     ecx, eax
    mov     eax, 10624DD3h
    imul    ecx, [edx+0E8h]
    mul     ecx
    lea     eax, [esp+1Ch+var_18]
    mov     [esp+1Ch+var_4], 0
    shr     edx, 6
    push    eax
    mov     [esp+20h+var_C], edx
    mov     [esp+20h+var_8], esi
    call    sub_4C2360
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5EB2:                             ; CODE XREF: sub_4B5CC0+18Aj
                                            ; DATA XREF: .text:004B60F4o
    mov     eax, [esp+1Ch+lParam]           ; case 0x201
    mov     edx, [esp+1Ch+wParam]
    mov     ecx, eax
    mov     [esp+1Ch+var_10], edx
    and     ecx, 0FFFFh
    shr     eax, 10h
    mov     [esp+1Ch+var_18], ecx
    mov     [esp+1Ch+var_14], eax
    call    ds:__imp_GetTickCount
    mov     edx, dword_51FBD0
    mov     ecx, eax
    mov     eax, 10624DD3h
    imul    ecx, [edx+0E8h]
    mul     ecx
    shr     edx, 6
    mov     [esp+1Ch+var_C], edx
    mov     [esp+1Ch+var_4], 0
    jmp     short loc_4B5F48
    ; ---------------------------------------------------------------------------

    loc_4B5EFE:                             ; CODE XREF: sub_4B5CC0+18Aj
                                            ; DATA XREF: .text:004B60F4o
    mov     eax, [esp+1Ch+lParam]           ; case 0x203
    mov     edx, [esp+1Ch+wParam]
    mov     ecx, eax
    mov     [esp+1Ch+var_10], edx
    and     ecx, 0FFFFh
    shr     eax, 10h
    mov     [esp+1Ch+var_18], ecx
    mov     [esp+1Ch+var_14], eax
    call    ds:__imp_GetTickCount
    mov     edx, dword_51FBD0
    mov     ecx, eax
    mov     eax, 10624DD3h
    imul    ecx, [edx+0E8h]
    mul     ecx
    shr     edx, 6
    mov     [esp+1Ch+var_C], edx
    mov     [esp+1Ch+var_4], 1

    loc_4B5F48:                             ; CODE XREF: sub_4B5CC0+23Cj
    lea     eax, [esp+1Ch+var_18]
    mov     [esp+1Ch+var_8], esi
    push    eax
    call    sub_4C2E30
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5F5F:                             ; CODE XREF: sub_4B5CC0+175j
    mov     ecx, dword_51FBD0
    mov     eax, [ecx+80h]
    test    eax, eax
    jz      short loc_4B5FE9
    mov     edx, [esp+1Ch+lParam]
    mov     ecx, [esp+1Ch+wParam]
    push    edx
    push    ecx
    push    219h
    call    eax
    add     esp, 0Ch
    mov     eax, 1
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5F8F:                             ; CODE XREF: sub_4B5CC0+16Fj
    mov     eax, esi
    sub     eax, 30Fh
    jz      loc_4B6075
    sub     eax, 2
    jz      short loc_4B5FF5
    sub     eax, 0A8h
    jz      short loc_4B5FC5

    loc_4B5FA8:                             ; CODE XREF: sub_4B5CC0+19j
                                            ; sub_4B5CC0+8Fj ...
    mov     edx, [esp+1Ch+lParam]           ; default
    mov     eax, [esp+1Ch+wParam]
    mov     ecx, [esp+1Ch+hWnd]
    push    edx                             ; lParam
    push    eax                             ; wParam
    push    esi                             ; Msg
    push    ecx                             ; hWnd
    call    ds:DefWindowProcA
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5FC5:                             ; CODE XREF: sub_4B5CC0+2E6j
    mov     edx, dword_51FBD0
    mov     eax, [edx+80h]
    test    eax, eax
    jz      short loc_4B5FE9
    mov     ecx, [esp+1Ch+lParam]
    mov     edx, [esp+1Ch+wParam]
    push    ecx
    push    edx
    push    3B9h
    call    eax
    add     esp, 0Ch

    loc_4B5FE9:                             ; CODE XREF: sub_4B5CC0+2ADj
                                            ; sub_4B5CC0+313j
    mov     eax, 1
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B5FF5:                             ; CODE XREF: sub_4B5CC0+2DFj
    mov     eax, dword_51FBD0
    mov     edx, [esp+1Ch+wParam]
    mov     ecx, [eax+40h]
    cmp     ecx, edx
    jnz     short loc_4B600E
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B600E:                             ; CODE XREF: sub_4B5CC0+343j
    mov     edx, [eax+4Ch]
    test    edx, edx
    jz      short loc_4B6051
    push    ecx                             ; hWnd
    call    ds:GetDC
    mov     esi, eax
    mov     eax, dword_51FBD0
    push    0                               ; BOOL
    mov     ecx, [eax+4Ch]
    push    ecx                             ; HPALETTE
    push    esi                             ; HDC
    call    ds:SelectPalette
    push    esi                             ; HDC
    call    ds:RealizePalette
    mov     edx, dword_51FBD0
    push    esi                             ; hDC
    mov     eax, [edx+40h]
    push    eax                             ; hWnd
    call    ds:ReleaseDC
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B6051:                             ; CODE XREF: sub_4B5CC0+353j
    mov     ecx, [eax+88h]
    test    ecx, ecx
    jz      short loc_4B606C
    mov     eax, [eax+94h]
    test    eax, eax
    jz      short loc_4B606C
    mov     edx, [ecx]
    push    eax
    push    ecx
    call    dword ptr [edx+7Ch]

    loc_4B606C:                             ; CODE XREF: sub_4B5CC0+12j
                                            ; sub_4B5CC0+399j ...
    xor     eax, eax
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B6075:                             ; CODE XREF: sub_4B5CC0+2D6j
    mov     ecx, dword_51FBD0
    mov     eax, [ecx+4Ch]
    test    eax, eax
    jz      short loc_4B60C4
    mov     eax, [ecx+40h]
    push    eax                             ; hWnd
    call    ds:GetDC
    mov     ecx, dword_51FBD0
    mov     esi, eax
    push    0                               ; BOOL
    mov     edx, [ecx+4Ch]
    push    edx                             ; HPALETTE
    push    esi                             ; HDC
    call    ds:SelectPalette
    push    esi                             ; HDC
    call    ds:RealizePalette
    mov     eax, dword_51FBD0
    push    esi                             ; hDC
    mov     ecx, [eax+40h]
    push    ecx                             ; hWnd
    call    ds:ReleaseDC
    mov     eax, 1
    pop     esi
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B60C4:                             ; CODE XREF: sub_4B5CC0+3C0j
    mov     edx, [ecx+88h]
    mov     eax, 80004005h
    test    edx, edx
    jz      short loc_4B60E4
    mov     ecx, [ecx+94h]
    test    ecx, ecx
    jz      short loc_4B60E4
    mov     eax, [edx]
    push    ecx
    push    edx
    call    dword ptr [eax+7Ch]

    loc_4B60E4:                             ; CODE XREF: sub_4B5CC0+411j
                                            ; sub_4B5CC0+41Bj
    xor     ecx, ecx
    pop     esi
    test    eax, eax
    setz    cl
    mov     eax, ecx
    add     esp, 18h
    retn    10h
    sub_4B5CC0 endp

    ; ---------------------------------------------------------------------------
    off_4B60F4 dd offset loc_4B5E51         ; DATA XREF: sub_4B5CC0+18Ar
    dd offset loc_4B5EB2                    ; jump table for switch statement
    dd offset loc_4B5EB2
    dd offset loc_4B5EFE
    dd offset loc_4B5EB2
    dd offset loc_4B5EB2
    dd offset loc_4B5EFE

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6110 proc near                    ; CODE XREF: sub_49E830+53Fp

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    call    nullsub_16
    call    sub_4C2CC0
    mov     esi, [esp+arg_0]
    xor     edi, edi
    mov     eax, [esi+61Ch]
    test    eax, eax
    jle     short loc_4B6146

    loc_4B612C:                             ; CODE XREF: sub_4B6110+34j
    mov     eax, [esi+618h]
    mov     ecx, [eax+edi*4]
    push    ecx
    call    sub_4BE070
    mov     eax, [esi+61Ch]
    inc     edi
    cmp     edi, eax
    jl      short loc_4B612C

    loc_4B6146:                             ; CODE XREF: sub_4B6110+1Aj
    mov     eax, [esi+618h]
    test    eax, eax
    jz      short loc_4B6159
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4B6159:                             ; CODE XREF: sub_4B6110+3Ej
    mov     dl, [esi+0F0h]
    shr     dl, 6
    test    dl, 1
    jz      short loc_4B616D
    push    esi
    call    sub_4BA640

    loc_4B616D:                             ; CODE XREF: sub_4B6110+55j
    mov     al, [esi+0F0h]
    shr     al, 5
    test    al, 1
    jz      short loc_4B6180
    push    esi
    call    sub_4BA5F0

    loc_4B6180:                             ; CODE XREF: sub_4B6110+68j
    mov     cl, [esi+0F0h]
    shr     cl, 7
    test    cl, 1
    jz      short loc_4B6194
    push    esi
    call    sub_4BA690

    loc_4B6194:                             ; CODE XREF: sub_4B6110+7Cj
    xor     edx, edx
    mov     dl, [esi+0F1h]
    test    dl, 1
    jz      short loc_4B61A7
    push    esi
    call    sub_4BA6E0

    loc_4B61A7:                             ; CODE XREF: sub_4B6110+8Fj
    mov     ax, [esi+0F0h]
    shr     eax, 9
    test    al, 1
    jz      short loc_4B61BB
    push    esi
    call    sub_4BA730

    loc_4B61BB:                             ; CODE XREF: sub_4B6110+A3j
    push    esi
    call    sub_4B4FF0
    mov     eax, [esi+48h]
    test    eax, eax
    jz      short loc_4B61CF
    push    eax                             ; HDC
    call    ds:DeleteDC

    loc_4B61CF:                             ; CODE XREF: sub_4B6110+B6j
    mov     eax, [esi+4Ch]
    mov     edi, ds:DeleteObject
    test    eax, eax
    jz      short loc_4B61DF
    push    eax                             ; HGDIOBJ
    call    edi ; DeleteObject

    loc_4B61DF:                             ; CODE XREF: sub_4B6110+CAj
    mov     eax, [esi+44h]
    test    eax, eax
    jz      short loc_4B61E9
    push    eax                             ; HGDIOBJ
    call    edi ; DeleteObject

    loc_4B61E9:                             ; CODE XREF: sub_4B6110+D4j
    mov     dword ptr [esi+48h], 0
    mov     dword ptr [esi+4Ch], 0
    mov     dword ptr [esi+44h], 0
    mov     ecx, dword_51FBD0
    push    1                               ; fWinIni
    push    0                               ; pvParam
    mov     edx, [ecx+0ECh]
    push    edx                             ; uiParam
    push    5Dh                             ; uiAction
    call    ds:SystemParametersInfoA
    pop     edi
    pop     esi
    retn    4
    sub_4B6110 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6220 proc near                    ; CODE XREF: .text:00417B1Cp
                                            ; sub_41CE90+3Ap ...
    mov     eax, dword_51FBD0
    retn
    sub_4B6220 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B6230(LPCSTR lpText)
    sub_4B6230 proc near                    ; CODE XREF: sub_450E20+CDp
                                            ; sub_450E20+DAp ...

    lpText= dword ptr  4

    mov     eax, dword_51FBD0
    or      byte ptr [eax+0F1h], 8
    mov     eax, dword_51FBD0
    mov     cl, [eax+0F0h]
    shr     cl, 1
    test    cl, 1
    jz      short loc_4B625A
    push    0
    call    sub_4B5510
    mov     eax, dword_51FBD0

    loc_4B625A:                             ; CODE XREF: sub_4B6230+1Cj
    mov     ecx, [esp+lpText]
    test    ecx, ecx
    jz      short loc_4B6278
    mov     edx, [eax+0Ch]
    mov     eax, [eax+40h]
    push    0                               ; uType
    push    edx                             ; lpCaption
    push    ecx                             ; lpText
    push    eax                             ; hWnd
    call    ds:MessageBoxA
    mov     eax, dword_51FBD0

    loc_4B6278:                             ; CODE XREF: sub_4B6230+30j
    mov     ecx, [eax+40h]
    push    0                               ; lParam
    push    0                               ; wParam
    push    2                               ; Msg
    push    ecx                             ; hWnd
    call    ds:PostMessageA
    retn    4
    sub_4B6230 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B6290(LPCSTR lpText)
    sub_4B6290 proc near                    ; CODE XREF: sub_4224B0+72p
                                            ; sub_429290+3Dp ...

    lpText= dword ptr  4

    mov     ecx, [esp+lpText]
    test    ecx, ecx
    jz      short loc_4B62B1
    mov     eax, dword_51FBD0
    push    1010h                           ; uType
    mov     edx, [eax+0Ch]
    mov     eax, [eax+40h]
    push    edx                             ; lpCaption
    push    ecx                             ; lpText
    push    eax                             ; hWnd
    call    ds:MessageBoxA

    loc_4B62B1:                             ; CODE XREF: sub_4B6290+6j
    push    1                               ; int
    call    _exit
    ; ---------------------------------------------------------------------------
    add     esp, 4
    retn    4
    sub_4B6290 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B62C0 proc near                    ; CODE XREF: sub_49E830+170p
    xor     eax, eax
    retn    4
    sub_4B62C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B62D0 proc near                    ; CODE XREF: sub_49E830+161p

    arg_0= dword ptr  4

    mov     ecx, dword_51FBD0
    mov     eax, [esp+arg_0]
    mov     [ecx+0E8h], eax
    mov     dword_51FC80, 0
    mov     eax, offset dword_51FBE0

    loc_4B62EF:                             ; CODE XREF: sub_4B62D0+2Dj
    mov     dword ptr [eax], 0FFFFFFFFh
    add     eax, 10h
    cmp     eax, offset dword_51FC80
    jl      short loc_4B62EF
    call    ds:__imp_GetTickCount
    mov     edx, eax
    mov     eax, dword_51FBD0
    imul    edx, [eax+0E8h]
    mov     eax, 10624DD3h
    mul     edx
    shr     edx, 6
    mov     dword_51FC84, edx
    retn    4
    sub_4B62D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6330 proc near                    ; CODE XREF: .text:0041FE0Ep
                                            ; .text:0041FED4p ...
    mov     eax, dword_51FBD0
    mov     eax, [eax+0E8h]
    retn
    sub_4B6330 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6340 proc near                    ; CODE XREF: sub_415FA0+1p
                                            ; sub_416150+1p ...
    call    ds:__imp_GetTickCount
    mov     edx, dword_51FBD0
    mov     ecx, eax
    mov     eax, 10624DD3h
    imul    ecx, [edx+0E8h]
    mul     ecx
    mov     eax, edx
    shr     eax, 6
    retn
    sub_4B6340 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6370 proc near                    ; CODE XREF: sub_499890+176p
    push    esi
    mov     esi, ds:__imp_GetTickCount
    push    edi
    call    esi ; __imp_GetTickCount
    mov     edx, dword_51FBD0
    mov     ecx, eax
    mov     eax, 10624DD3h
    imul    ecx, [edx+0E8h]
    mul     ecx
    mov     ecx, dword_51FC84
    shr     edx, 6
    sub     edx, ecx
    mov     edi, edx
    call    esi ; __imp_GetTickCount
    mov     edx, dword_51FBD0
    mov     ecx, eax
    mov     eax, 10624DD3h
    mov     esi, offset dword_51FBE0
    imul    ecx, [edx+0E8h]
    mul     ecx
    shr     edx, 6
    mov     dword_51FC84, edx

    loc_4B63C3:                             ; CODE XREF: sub_4B6370+7Bj
    cmp     dword ptr [esi], 0
    jl      short loc_4B63E2
    mov     ecx, [esi+4]
    sub     ecx, edi
    mov     eax, ecx
    mov     [esi+4], ecx
    test    eax, eax
    jg      short loc_4B63E2
    mov     eax, [esi-4]
    push    eax
    call    dword ptr [esi-8]
    mov     ecx, [esi]
    mov     [esi+4], ecx

    loc_4B63E2:                             ; CODE XREF: sub_4B6370+56j
                                            ; sub_4B6370+64j
    add     esi, 10h
    cmp     esi, offset dword_51FC80
    jl      short loc_4B63C3
    pop     edi
    pop     esi
    retn
    sub_4B6370 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B63F0 proc near                    ; CODE XREF: .text:004CE656p
                                            ; sub_4CE690+F4p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, ds:__imp_GetTickCount
    push    edi
    call    esi ; __imp_GetTickCount
    mov     edx, dword_51FBD0
    mov     ecx, eax
    mov     eax, 10624DD3h
    imul    ecx, [edx+0E8h]
    mul     ecx
    mov     ecx, dword_51FC84
    shr     edx, 6
    sub     edx, ecx
    mov     edi, edx
    call    esi ; __imp_GetTickCount
    mov     edx, dword_51FBD0

    loc_4B6425:                             ; DATA XREF: .data:0050783Co
    mov     ecx, eax
    mov     eax, 10624DD3h
    mov     esi, offset dword_51FBE0
    imul    ecx, [edx+0E8h]
    mul     ecx
    shr     edx, 6
    mov     dword_51FC84, edx

    loc_4B6443:                             ; CODE XREF: sub_4B63F0+7Bj
    cmp     dword ptr [esi], 0
    jl      short loc_4B6462
    mov     ecx, [esi+4]
    sub     ecx, edi
    mov     eax, ecx
    mov     [esi+4], ecx
    test    eax, eax
    jg      short loc_4B6462
    mov     eax, [esi-4]
    push    eax
    call    dword ptr [esi-8]
    mov     ecx, [esi]
    mov     [esi+4], ecx

    loc_4B6462:                             ; CODE XREF: sub_4B63F0+56j
                                            ; sub_4B63F0+64j
    add     esi, 10h
    cmp     esi, offset dword_51FC80
    jl      short loc_4B6443
    xor     eax, eax
    mov     ecx, offset dword_51FBE0

    loc_4B6474:                             ; CODE XREF: sub_4B63F0+93j
    cmp     dword ptr [ecx], 0
    jl      short loc_4B648D
    add     ecx, 10h
    inc     eax
    cmp     ecx, offset dword_51FC80
    jl      short loc_4B6474
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B648D:                             ; CODE XREF: sub_4B63F0+87j
    mov     edx, [esp+14h]
    mov     ecx, eax
    shl     ecx, 4
    mov     dword_51FBD8[ecx], edx
    mov     edx, [esp+4+arg_4]
    mov     dword_51FBDC[ecx], edx
    mov     edx, [esp+4+arg_0]
    mov     dword_51FBE0[ecx], edx
    mov     dword_51FBE4[ecx], edx
    inc     dword_51FC80
    pop     edi
    pop     esi
    retn    0Ch
    sub_4B63F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B64D0 proc near                    ; CODE XREF: sub_4CDB40+62p
                                            ; sub_4CDB40+15Fp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, dword_51FC80
    cmp     eax, ecx
    jl      short loc_4B64E3
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B64E3:                             ; CODE XREF: sub_4B64D0+Cj
    test    eax, eax
    jge     short loc_4B64EC
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B64EC:                             ; CODE XREF: sub_4B64D0+15j
    shl     eax, 4
    mov     dword_51FBE0[eax], 0FFFFFFFFh
    mov     eax, 1
    retn    4
    sub_4B64D0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     dword_51FC80, 0
    mov     eax, offset dword_51FBE0

    loc_4B651F:                             ; CODE XREF: .text:004B652Dj
    mov     dword ptr [eax], 0FFFFFFFFh
    add     eax, 10h
    cmp     eax, offset dword_51FC80
    jl      short loc_4B651F
    call    ds:__imp_GetTickCount
    mov     edx, dword_51FBD0
    mov     ecx, eax
    mov     eax, 10624DD3h
    imul    ecx, [edx+0E8h]
    mul     ecx
    shr     edx, 6
    mov     dword_51FC84, edx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: thunk

    ; DWORD GetTickCount(void)
    GetTickCount proc near                  ; CODE XREF: PlayerStatusMenu+15p
                                            ; PlayerStatusMenu+26p ...
    jmp     ds:__imp_GetTickCount
    GetTickCount endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, dword_51FBD0
    sub     esp, 84h
    push    ebx
    push    esi
    push    edi
    lea     esi, [eax+1DAh]
    call    ds:__imp_GetTickCount
    mov     edi, [esi+4]
    mov     edx, [esi]
    mov     ecx, eax
    mov     [esi+4], eax
    sub     ecx, edi
    add     edx, ecx
    mov     ecx, [esi+8]
    mov     eax, edx
    inc     ecx
    cmp     eax, 7D0h
    mov     [esi], edx
    mov     [esi+8], ecx
    jle     short loc_4B65B0
    mov     dword ptr [esi], 3E8h

    loc_4B65B0:                             ; CODE XREF: .text:004B65A8j
    mov     eax, [esi]
    cmp     eax, 3E8h
    jle     short loc_4B65CA
    add     eax, 0FFFFFC18h
    mov     [esi+0Ch], ecx
    mov     [esi], eax
    mov     dword ptr [esi+8], 0

    loc_4B65CA:                             ; CODE XREF: .text:004B65B7j
    mov     eax, dword_51FBD0
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     loc_4B6680
    mov     eax, [eax+8Ch]
    lea     ecx, [esp+0Ch]
    push    ecx
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+44h]
    test    eax, eax
    jnz     loc_4B6680
    mov     edx, [esp+0Ch]
    push    1
    push    edx
    call    ds:SetBkMode
    mov     eax, dword_51FBD0
    mov     esi, ds:SelectObject
    mov     edx, [esp+0Ch]
    mov     ecx, [eax+0B0h]
    push    ecx
    push    edx
    call    esi ; SelectObject
    mov     edi, eax
    mov     eax, dword_51FBD0
    lea     edx, [esp+10h]
    mov     ecx, [eax+1E6h]
    push    ecx
    push    offset aFrateD_0                ; "FRATE %d"
    push    edx
    call    ds:wsprintfA
    add     esp, 0Ch
    mov     ebx, eax
    mov     eax, [esp+0Ch]
    push    0FFFFh
    push    eax
    call    ds:SetTextColor
    lea     ecx, [esp+10h]
    push    ebx
    mov     edx, [esp+10h]
    push    ecx
    push    0
    push    0
    push    edx
    call    ds:TextOutA
    push    edi
    mov     eax, [esp+10h]
    push    eax
    call    esi ; SelectObject
    mov     ecx, dword_51FBD0
    mov     eax, [ecx+8Ch]
    mov     ecx, [esp+0Ch]
    push    ecx
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+68h]

    loc_4B6680:                             ; CODE XREF: .text:004B65D4j
                                            ; .text:004B65EDj
    mov     edx, dword_51FBD0
    pop     edi
    pop     esi
    pop     ebx
    mov     eax, [edx+1E6h]
    add     esp, 84h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B66A0 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+132Ap
    mov     eax, dword_51FBD0
    push    esi
    lea     esi, [eax+1DAh]
    call    ds:__imp_GetTickCount
    mov     edx, [esi+4]
    mov     ecx, eax
    sub     ecx, edx
    mov     edx, [esi]
    add     edx, ecx
    mov     ecx, [esi+8]
    mov     [esi+4], eax
    mov     eax, edx
    inc     ecx
    cmp     eax, 7D0h
    mov     [esi], edx
    mov     [esi+8], ecx
    jle     short loc_4B66D8
    mov     dword ptr [esi], 3E8h

    loc_4B66D8:                             ; CODE XREF: sub_4B66A0+30j
    mov     eax, [esi]
    cmp     eax, 3E8h
    jle     short loc_4B66F2
    add     eax, 0FFFFFC18h
    mov     [esi+0Ch], ecx
    mov     [esi], eax
    mov     dword ptr [esi+8], 0

    loc_4B66F2:                             ; CODE XREF: sub_4B66A0+3Fj
    mov     edx, dword_51FBD0
    pop     esi
    mov     eax, [edx+1E6h]
    retn
    sub_4B66A0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6700 proc near                    ; CODE XREF: sub_41CC60+89p
                                            ; sub_46BC70+35p ...
    mov     eax, dword_51FBD0
    mov     eax, [eax+0D4h]
    retn
    sub_4B6700 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6710 proc near                    ; CODE XREF: sub_41CC60+96p
                                            ; sub_467D70+74p ...
    mov     eax, dword_51FBD0
    mov     eax, [eax+0D8h]
    retn
    sub_4B6710 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6720 proc near                    ; CODE XREF: sub_420B00+A5p
                                            ; sub_420B00+14Ap ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    cmp     ecx, [eax]
    jl      short loc_4B6749
    cmp     ecx, [eax+8]
    jg      short loc_4B6749
    mov     ecx, [esp+arg_8]
    mov     edx, [eax+4]
    cmp     ecx, edx
    jl      short loc_4B6749
    cmp     ecx, [eax+0Ch]
    jg      short loc_4B6749
    mov     eax, 1
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B6749:                             ; CODE XREF: sub_4B6720+Aj
                                            ; sub_4B6720+Fj ...
    xor     eax, eax
    retn    0Ch
    sub_4B6720 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6750 proc near                    ; CODE XREF: PrintGUIText+1A7p
                                            ; PrintGUIText+219p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_0]
    mov     eax, [esp+arg_4]
    push    esi
    push    edi
    mov     ecx, [edx]
    mov     esi, [eax]
    cmp     ecx, esi
    jge     short loc_4B6769
    xor     eax, eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B6769:                             ; CODE XREF: sub_4B6750+10j
    mov     edi, [eax+8]
    cmp     ecx, edi
    jle     short loc_4B6777
    xor     eax, eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B6777:                             ; CODE XREF: sub_4B6750+1Ej
    mov     ecx, [edx+8]
    cmp     ecx, esi
    jge     short loc_4B6785
    xor     eax, eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B6785:                             ; CODE XREF: sub_4B6750+2Cj
    cmp     ecx, edi
    jle     short loc_4B6790
    xor     eax, eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B6790:                             ; CODE XREF: sub_4B6750+37j
    mov     ecx, [edx+4]
    mov     esi, [eax+4]
    cmp     ecx, esi
    jge     short loc_4B67A1
    xor     eax, eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B67A1:                             ; CODE XREF: sub_4B6750+48j
    mov     eax, [eax+0Ch]
    cmp     ecx, eax
    jle     short loc_4B67AF
    xor     eax, eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B67AF:                             ; CODE XREF: sub_4B6750+56j
    mov     edx, [edx+0Ch]
    cmp     edx, esi
    jge     short loc_4B67BD
    xor     eax, eax
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B67BD:                             ; CODE XREF: sub_4B6750+64j
    xor     ecx, ecx
    cmp     edx, eax
    setle   cl
    pop     edi
    mov     eax, ecx
    pop     esi
    retn    8
    sub_4B6750 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B67D0 proc near                    ; CODE XREF: sub_4AB0B0+86p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    push    esi
    mov     edx, [eax]
    mov     esi, [ecx+8]
    cmp     edx, esi
    jle     short loc_4B67E8
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B67E8:                             ; CODE XREF: sub_4B67D0+10j
    mov     edx, [eax+8]
    mov     esi, [ecx]
    cmp     edx, esi
    jge     short loc_4B67F7
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B67F7:                             ; CODE XREF: sub_4B67D0+1Fj
    mov     edx, [eax+4]
    mov     esi, [ecx+0Ch]
    cmp     edx, esi
    jle     short loc_4B6807
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B6807:                             ; CODE XREF: sub_4B67D0+2Fj
    mov     eax, [eax+0Ch]
    mov     esi, [ecx+4]
    xor     edx, edx
    cmp     eax, esi
    setnl   dl
    mov     eax, edx
    pop     esi
    retn    8
    sub_4B67D0 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     edx, [esp+8]
    push    ebx
    mov     cl, [eax+1]
    mov     bl, [edx+1]
    xor     eax, eax
    cmp     cl, bl
    setz    al
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     cl, [esp+8]
    mov     dl, [esp+0Ch]
    mov     [eax+1], cl
    mov     cl, [esp+10h]
    mov     [eax+2], dl
    mov     [eax+3], cl
    retn    10h
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall WriteRegistryValue_1(LPCSTR lpSubKey,LPCSTR lpValueName,BYTE *lpData,LPDWORD lpcbData)
    WriteRegistryValue_1 proc near          ; CODE XREF: sub_42F980+14p

    lpSubKey= dword ptr  4
    lpValueName= dword ptr  8
    lpData= dword ptr  0Ch
    lpcbData= dword ptr  10h

    mov     eax, [esp+lpcbData]
    mov     ecx, [esp+lpData]
    mov     edx, [esp+lpValueName]
    push    1                               ; dwDisposition
    push    0                               ; dwType
    push    eax                             ; lpcbData
    mov     eax, [esp+0Ch+lpSubKey]
    push    ecx                             ; lpData
    push    edx                             ; lpValueName
    push    eax                             ; lpSubKey
    call    WriteRegistryValue
    retn    10h
    WriteRegistryValue_1 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall WriteRegistryValue(LPCSTR lpSubKey,LPCSTR lpValueName,BYTE *lpData,LPDWORD lpcbData,DWORD dwType,DWORD dwDisposition)
    WriteRegistryValue proc near            ; CODE XREF: WriteRegistryValue_1+18p
                                            ; WriteRegistryValue_2+18p ...

    var_10= dword ptr -10h
    phkResult= dword ptr -0Ch
    hKey= dword ptr -8
    var_4= dword ptr -4
    lpSubKey= dword ptr  4
    lpValueName= dword ptr  8
    lpData= dword ptr  0Ch
    lpcbData= dword ptr  10h
    dwType= dword ptr  14h
    dwDisposition= dword ptr  18h

    sub     esp, 10h
    push    ebx
    push    ebp
    mov     ebp, [esp+18h+dwDisposition]
    push    esi
    mov     esi, ebp
    xor     ebx, ebx
    neg     esi
    sbb     esi, esi
    lea     eax, [esp+1Ch+dwDisposition]
    push    edi
    and     esi, 13h
    lea     ecx, [esp+20h+hKey]
    push    eax                             ; lpdwDisposition
    mov     edi, ds:RegCreateKeyExA
    add     esi, 20006h
    push    ecx                             ; phkResult
    push    ebx                             ; lpSecurityAttributes
    push    esi                             ; samDesired
    push    ebx                             ; dwOptions
    push    ebx                             ; lpClass
    push    ebx                             ; Reserved
    push    offset aSoftware                ; lpSubKey
    push    80000001h                       ; hKey
    mov     [esp+44h+hKey], ebx
    mov     [esp+44h+phkResult], ebx
    mov     [esp+44h+var_10], ebx
    mov     [esp+44h+var_4], ebx
    call    edi ; RegCreateKeyExA
    cmp     eax, ebx
    jnz     loc_4B6972
    lea     edx, [esp+20h+dwDisposition]
    mov     ecx, [esp+20h+hKey]
    lea     eax, [esp+20h+phkResult]
    push    edx                             ; lpdwDisposition
    push    eax                             ; phkResult
    push    ebx                             ; lpSecurityAttributes
    push    esi                             ; samDesired
    push    ebx                             ; dwOptions
    push    ebx                             ; lpClass
    push    ebx                             ; Reserved
    push    offset aCavedogEnterta          ; lpSubKey
    push    ecx                             ; hKey
    call    edi ; RegCreateKeyExA
    cmp     eax, ebx
    jnz     short loc_4B6972
    mov     ecx, [esp+20h+lpSubKey]
    lea     edx, [esp+20h+dwDisposition]
    lea     eax, [esp+20h+var_10]
    push    edx                             ; lpdwDisposition
    mov     edx, [esp+24h+phkResult]
    push    eax                             ; phkResult
    push    ebx                             ; lpSecurityAttributes
    push    esi                             ; samDesired
    push    ebx                             ; dwOptions
    push    ebx                             ; lpClass
    push    ebx                             ; Reserved
    push    ecx                             ; lpSubKey
    push    edx                             ; hKey
    call    edi ; RegCreateKeyExA
    cmp     eax, ebx
    jnz     short loc_4B6972
    cmp     ebp, ebx
    jz      short loc_4B6945
    mov     eax, [esp+20h+lpcbData]
    mov     ecx, [esp+20h+lpData]
    mov     edx, [esp+20h+lpValueName]
    push    eax                             ; lpcbData
    mov     eax, [esp+24h+var_10]
    push    ecx                             ; lpData
    push    ebx                             ; lpType
    push    ebx                             ; lpReserved
    push    edx                             ; lpValueName
    push    eax                             ; hKey
    call    ds:RegQueryValueExA
    cmp     eax, ebx
    jz      short loc_4B696B
    cmp     eax, 0EAh
    jnz     short loc_4B6972
    mov     edi, 1
    jmp     short loc_4B6976
    ; ---------------------------------------------------------------------------

    loc_4B6945:                             ; CODE XREF: WriteRegistryValue+95j
    mov     ecx, [esp+20h+lpcbData]
    mov     eax, [esp+20h+lpData]
    mov     edx, [ecx]
    mov     ecx, [esp+20h+dwType]
    push    edx                             ; cbData
    mov     edx, [esp+24h+lpValueName]
    push    eax                             ; lpData
    mov     eax, [esp+28h+var_10]
    push    ecx                             ; dwType
    push    ebx                             ; Reserved
    push    edx                             ; lpValueName
    push    eax                             ; hKey
    call    ds:RegSetValueExA
    cmp     eax, ebx
    jnz     short loc_4B6972

    loc_4B696B:                             ; CODE XREF: WriteRegistryValue+B5j
    mov     edi, 1
    jmp     short loc_4B6976
    ; ---------------------------------------------------------------------------

    loc_4B6972:                             ; CODE XREF: WriteRegistryValue+4Fj
                                            ; WriteRegistryValue+72j ...
    mov     edi, [esp+20h+var_4]

    loc_4B6976:                             ; CODE XREF: WriteRegistryValue+C3j
                                            ; WriteRegistryValue+F0j
    mov     eax, [esp+20h+var_10]
    mov     esi, ds:RegCloseKey
    cmp     eax, ebx
    jz      short loc_4B6987
    push    eax                             ; hKey
    call    esi ; RegCloseKey

    loc_4B6987:                             ; CODE XREF: WriteRegistryValue+102j
    mov     eax, [esp+20h+phkResult]
    cmp     eax, ebx
    jz      short loc_4B6992
    push    eax                             ; hKey
    call    esi ; RegCloseKey

    loc_4B6992:                             ; CODE XREF: WriteRegistryValue+10Dj
    mov     eax, [esp+20h+hKey]
    cmp     eax, ebx
    jz      short loc_4B699D
    push    eax                             ; hKey
    call    esi ; RegCloseKey

    loc_4B699D:                             ; CODE XREF: WriteRegistryValue+118j
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    18h
    WriteRegistryValue endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    WriteRegistryValue_2 proc near          ; CODE XREF: WriteRegistrySettings_1+8F6p
                                            ; WriteRegistrySettings_1+96Ap ...

    lpSubKey= dword ptr  4
    lpValueName= dword ptr  8
    lpData= dword ptr  0Ch
    lpcbData= dword ptr  10h

    mov     eax, [esp+lpcbData]
    mov     ecx, [esp+lpData]
    mov     edx, [esp+lpValueName]
    push    1                               ; dwDisposition
    push    0                               ; dwType
    push    eax                             ; lpcbData
    mov     eax, [esp+0Ch+lpSubKey]
    push    ecx                             ; lpData
    push    edx                             ; lpValueName
    push    eax                             ; lpSubKey
    call    WriteRegistryValue
    retn    10h
    WriteRegistryValue_2 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    WriteRegistryValue_3 proc near          ; CODE XREF: WriteRegistrySettings_1+19p
                                            ; WriteRegistrySettings_1+7Bp ...

    cbData= dword ptr -4
    lpSubKey= dword ptr  4
    lpValueName= dword ptr  8
    lpData= dword ptr  0Ch

    push    ecx
    mov     ecx, [esp+4+lpData]
    mov     edx, [esp+4+lpValueName]
    push    1                               ; dwDisposition
    lea     eax, [esp+8+cbData]
    push    0                               ; dwType
    push    eax                             ; lpcbData
    mov     eax, [esp+10h+lpSubKey]
    push    ecx                             ; lpData
    push    edx                             ; lpValueName
    push    eax                             ; lpSubKey
    mov     [esp+1Ch+cbData], 4
    call    WriteRegistryValue
    pop     ecx
    retn    0Ch
    WriteRegistryValue_3 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    WriteRegistryValue_4 proc near          ; CODE XREF: sub_42F960+14p

    lpSubKey= dword ptr  4
    lpValueName= dword ptr  8
    lpData= dword ptr  0Ch
    cbData= dword ptr  10h

    mov     ecx, [esp+lpData]
    mov     edx, [esp+lpValueName]
    push    0                               ; dwDisposition
    lea     eax, [esp+4+cbData]
    push    3                               ; dwType
    push    eax                             ; lpcbData
    mov     eax, [esp+0Ch+lpSubKey]
    push    ecx                             ; lpData
    push    edx                             ; lpValueName
    push    eax                             ; lpSubKey
    call    WriteRegistryValue
    retn    10h
    WriteRegistryValue_4 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    WriteRegistryValue_5 proc near          ; CODE XREF: WriteRegistrySettings_1+1259p
                                            ; WriteRegistrySettings_2+33Cp ...

    lpSubKey= dword ptr  4
    lpValueName= dword ptr  8
    cbData= dword ptr  0Ch

    mov     edx, [esp+cbData]
    push    edi
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    push    eax                             ; dwDisposition
    lea     eax, [esp+8+cbData]
    not     ecx
    push    1                               ; dwType
    mov     [esp+0Ch+cbData], ecx
    mov     ecx, [esp+0Ch+lpValueName]
    push    eax                             ; lpcbData
    push    edx                             ; lpData
    mov     edx, [esp+14h+lpSubKey]
    push    ecx                             ; lpValueName
    push    edx                             ; lpSubKey
    call    WriteRegistryValue
    pop     edi
    retn    0Ch
    WriteRegistryValue_5 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    WriteRegistryValue_6 proc near          ; CODE XREF: .text:0042F93Ep
                                            ; WriteRegistrySettings_1+67p ...

    cbData= dword ptr -4
    lpSubKey= dword ptr  4
    lpValueName= dword ptr  8
    Data= byte ptr  0Ch

    push    ecx
    mov     edx, [esp+4+lpValueName]
    push    0                               ; dwDisposition
    lea     eax, [esp+8+cbData]
    push    4                               ; dwType
    lea     ecx, [esp+0Ch+Data]
    push    eax                             ; lpcbData
    mov     eax, [esp+10h+lpSubKey]
    push    ecx                             ; lpData
    push    edx                             ; lpValueName
    push    eax                             ; lpSubKey
    mov     [esp+1Ch+cbData], 4
    call    WriteRegistryValue
    pop     ecx
    retn    0Ch
    WriteRegistryValue_6 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall Get_UserName(int)
    Get_UserName proc near                  ; CODE XREF: WriteRegistrySettings_1+A19p

    nSize= dword ptr -104h
    Buffer= byte ptr -100h
    arg_0= dword ptr  4

    sub     esp, 104h
    push    esi
    lea     eax, [esp+108h+nSize]
    push    edi
    lea     ecx, [esp+10Ch+Buffer]
    push    eax                             ; nSize
    push    ecx                             ; lpBuffer
    mov     [esp+114h+nSize], 100h
    call    ds:GetUserNameA
    test    eax, eax
    jz      short loc_4B6AE2
    mov     al, [esp+10Ch+Buffer]
    test    al, al
    jz      short loc_4B6AE2
    lea     edi, [esp+10Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, 1
    mov     edx, ecx
    mov     esi, edi
    mov     edi, [esp+10Ch+arg_0]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    add     esp, 104h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B6AE2:                             ; CODE XREF: Get_UserName+22j
                                            ; Get_UserName+2Aj
    pop     edi
    xor     eax, eax
    pop     esi
    add     esp, 104h
    retn    4
    Get_UserName endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6AF0 proc near                    ; CODE XREF: sub_435760+119p
                                            ; sub_435760+127p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, [esp+4+arg_4]
    xor     ecx, ecx
    xor     edx, edx

    loc_4B6AFE:                             ; CODE XREF: sub_4B6AF0+1Bj
                                            ; sub_4B6AF0+23j ...
    cmp     edi, edx
    jz      short loc_4B6B18
    mov     al, [ecx+esi]
    test    al, al
    jnz     short loc_4B6B0D
    inc     edx
    inc     ecx
    jmp     short loc_4B6AFE
    ; ---------------------------------------------------------------------------

    loc_4B6B0D:                             ; CODE XREF: sub_4B6AF0+17j
    cmp     al, 0Ah
    jnz     short loc_4B6B15
    inc     edx
    inc     ecx
    jmp     short loc_4B6AFE
    ; ---------------------------------------------------------------------------

    loc_4B6B15:                             ; CODE XREF: sub_4B6AF0+1Fj
    inc     ecx
    jmp     short loc_4B6AFE
    ; ---------------------------------------------------------------------------

    loc_4B6B18:                             ; CODE XREF: sub_4B6AF0+10j
    lea     eax, [ecx+esi]
    pop     edi
    pop     esi
    retn    8
    sub_4B6AF0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B6B20(int,DWORD dwStackSize,LPDWORD lpThreadId)
    sub_4B6B20 proc near                    ; CODE XREF: sub_497F40+38Ap
                                            ; .text:004C2A9Ap ...

    arg_0= dword ptr  4
    dwStackSize= dword ptr  8
    lpThreadId= dword ptr  0Ch

    mov     eax, [esp+lpThreadId]
    mov     ecx, [esp+dwStackSize]
    mov     edx, [esp+arg_0]
    push    eax                             ; lpThreadId
    push    ecx                             ; dwStackSize
    push    edx                             ; int
    call    __beginthread
    add     esp, 0Ch
    xor     ecx, ecx
    cmp     eax, 0FFFFFFFFh
    setnz   cl
    mov     eax, ecx
    retn    0Ch
    sub_4B6B20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B6B50(DWORD dwMilliseconds)
    sub_4B6B50 proc near                    ; CODE XREF: sub_4572A0+118p
                                            ; sub_497180+110p ...

    dwMilliseconds= dword ptr  4

    mov     eax, [esp+dwMilliseconds]
    push    eax                             ; dwMilliseconds
    call    ds:Sleep
    retn    4
    sub_4B6B50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6B60 proc near                    ; CODE XREF: sub_4CE260+148p

    arg_0= dword ptr  4

    mov     ecx, dword_51FBD0
    mov     eax, [esp+arg_0]
    mov     [ecx+80h], eax
    retn    4
    sub_4B6B60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B6B80(LPCSTR lpText)
    sub_4B6B80 proc near                    ; CODE XREF: sub_42A8D0+A46p
                                            ; sub_435DA0+891p

    lpText= dword ptr  4

    mov     eax, [esp+lpText]
    push    40000h                          ; uType
    push    offset aError                   ; lpCaption
    push    eax                             ; lpText
    push    0                               ; hWnd
    call    ds:MessageBoxA
    retn    8
    sub_4B6B80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6BA0 proc near                    ; CODE XREF: sub_42A610+65p
                                            ; sub_42A610+168p ...

    var_9= byte ptr -9
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    push    edi
    mov     edi, [esp+10h+arg_4]
    xor     edx, edx
    xor     ecx, ecx
    cmp     edi, edx
    mov     byte ptr [esp+10h+var_4], dl
    mov     byte ptr [esp+10h+var_8], dl
    mov     [esp+10h+var_9], dl
    jle     short loc_4B6BF4
    push    esi
    mov     esi, [esp+14h+arg_0]
    push    ebx

    loc_4B6BC2:                             ; CODE XREF: sub_4B6BA0+50j
    mov     al, [esi]
    mov     bl, byte ptr [esp+18h+var_4]
    add     bl, al
    mov     byte ptr [esp+18h+var_4], bl
    mov     bl, byte ptr [esp+18h+var_8]
    xor     bl, al
    mov     byte ptr [esp+18h+var_8], bl
    mov     bl, cl
    xor     bl, al
    add     dl, bl
    mov     bl, cl
    add     bl, al
    mov     al, [esp+18h+var_9]
    xor     al, bl
    inc     ecx
    inc     esi
    cmp     ecx, edi
    mov     [esp+18h+var_9], al
    jl      short loc_4B6BC2
    pop     ebx
    pop     esi

    loc_4B6BF4:                             ; CODE XREF: sub_4B6BA0+1Aj
    mov     ecx, [esp+10h+var_8]
    xor     eax, eax
    mov     ah, [esp+10h+var_9]
    and     ecx, 0FFh
    mov     al, dl
    mov     edx, [esp+10h+var_4]
    shl     eax, 8
    or      eax, ecx
    and     edx, 0FFh
    shl     eax, 8
    or      eax, edx
    pop     edi
    add     esp, 0Ch
    retn    8
    sub_4B6BA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall GetRandom(int)
    GetRandom proc near                     ; CODE XREF: .text:00401D84p
                                            ; .text:00401EEBp ...

    arg_0= dword ptr  8

    push    edi
    mov     edi, [esp+arg_0]
    cmp     edi, 2
    jge     short loc_4B6C40
    xor     eax, eax
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B6C40:                             ; CODE XREF: GetRandom+8j
    push    esi
    mov     esi, dword_51FC88
    mov     eax, 69C16BDh
    mov     ecx, esi
    mul     esi
    mov     eax, esi
    sub     ecx, edx
    shl     eax, 3
    sub     eax, esi
    shr     ecx, 1
    lea     eax, [eax+eax*4]
    add     ecx, edx
    shr     ecx, 10h
    lea     eax, [eax+eax*4]
    mov     edx, ecx
    shl     eax, 4
    add     eax, esi
    neg     edx
    lea     eax, [eax+eax*2]
    shl     edx, 1Fh
    lea     eax, [esi+eax*2]
    sub     edx, ecx
    sub     eax, edx
    test    eax, eax
    jg      short loc_4B6C85
    add     eax, 7FFFFFFFh

    loc_4B6C85:                             ; CODE XREF: GetRandom+4Ej
    xor     edx, edx
    mov     dword_51FC88, eax
    div     edi
    pop     esi
    pop     edi
    mov     eax, edx
    retn    4
    GetRandom endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6CA0 proc near                    ; CODE XREF: sub_497180+1Dp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    xor     eax, 66E29572h
    or      al, 1
    mov     dword_51FC88, eax
    retn    4
    sub_4B6CA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6CC0 proc near                    ; CODE XREF: sub_421550+9Ep
                                            ; sub_43DEF0+C0p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 10h
    push    esi
    mov     esi, [esp+14h+arg_0]
    push    edi
    mov     edi, [esp+18h+arg_8]
    mov     eax, [esi]
    mov     ecx, [esi+4]
    mov     [esp+18h+var_10], eax
    mov     ax, [edi]
    lea     edx, [esp+18h+var_10]
    mov     [esp+18h+var_C], ecx
    push    edx
    push    eax
    call    sub_4B7173
    mov     ecx, [esp+20h+var_C]
    mov     edx, [esi+8]
    add     esp, 8
    mov     [esp+18h+var_8], ecx
    mov     cx, [edi+4]
    lea     eax, [esp+18h+var_8]
    push    eax
    push    ecx
    mov     [esp+20h+var_4], edx
    call    sub_4B7173
    mov     esi, [esp+20h+arg_4]
    mov     edx, [esp+20h+var_8]
    mov     eax, [esp+20h+var_4]
    add     esp, 8
    mov     [esi+4], edx
    mov     dx, [edi+2]
    lea     ecx, [esp+18h+var_10]
    mov     [esp+18h+var_C], eax
    push    ecx
    push    edx
    call    sub_4B7173
    mov     eax, [esp+20h+var_10]
    mov     ecx, [esp+20h+var_C]
    add     esp, 8
    mov     [esi], eax
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    add     esp, 10h
    retn    0Ch
    sub_4B6CC0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    push    esi
    mov     esi, [esp+10h]
    lea     edx, [esp+4]
    mov     eax, [esi]
    mov     ecx, [esi+4]
    mov     [esp+4], eax
    mov     eax, [esp+18h]
    push    edx
    push    eax
    mov     [esp+10h], ecx
    call    sub_4B7173
    mov     eax, [esp+1Ch]
    mov     ecx, [esp+0Ch]
    mov     edx, [esp+10h]
    add     esp, 8
    mov     [eax], ecx
    mov     [eax+4], edx
    mov     ecx, [esi+8]
    pop     esi
    mov     [eax+8], ecx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    push    esi
    mov     esi, [esp+10h]
    lea     edx, [esp+4]
    mov     eax, [esi]
    mov     ecx, [esi+8]
    mov     [esp+4], eax
    mov     eax, [esp+18h]
    push    edx
    push    eax
    mov     [esp+10h], ecx
    call    sub_4B7173
    mov     eax, [esp+1Ch]
    mov     ecx, [esp+0Ch]
    add     esp, 8
    mov     [eax], ecx
    mov     edx, [esi+4]
    mov     ecx, [esp+8]
    mov     [eax+4], edx
    mov     [eax+8], ecx
    pop     esi
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    push    esi
    mov     esi, [esp+10h]
    lea     edx, [esp+4]
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    mov     [esp+4], eax
    mov     eax, [esp+18h]
    push    edx
    push    eax
    mov     [esp+10h], ecx
    call    sub_4B7173
    mov     eax, [esp+1Ch]
    mov     ecx, [esi]
    mov     edx, [esp+0Ch]
    add     esp, 8
    mov     [eax], ecx
    mov     ecx, [esp+8]
    mov     [eax+4], edx
    mov     [eax+8], ecx
    pop     esi
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    esi
    cdq
    mov     ecx, eax
    mov     eax, [esp+0Ch]
    xor     ecx, edx
    sub     ecx, edx
    cdq
    mov     esi, eax
    xor     esi, edx
    sub     esi, edx
    cmp     ecx, esi
    jle     short loc_4B6E66
    mov     eax, esi
    sar     eax, 2
    add     eax, ecx
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B6E66:                             ; CODE XREF: .text:004B6E59j
    mov     eax, ecx
    sar     eax, 2
    add     eax, esi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    fld     dword ptr [esp+14h]
    fld     dword ptr [esp+10h]
    fmul    dword ptr [esp+4]
    fld     dword ptr [esp+18h]
    fxch    st(2)
    fmul    dword ptr [esp+8]
    fxch    st(2)
    fmul    dword ptr [esp+0Ch]
    fxch    st(2)
    faddp   st(1), st
    fxch    st(1)
    faddp   st(1), st
    retn    18h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6EB0 proc near                    ; CODE XREF: sub_421700+372p
                                            ; sub_421700+3D7p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    sub     esp, 0Ch
    fld     [esp+0Ch+arg_10]
    fsub    [esp+0Ch+arg_4]
    mov     eax, [esp+0Ch+arg_0]
    mov     ecx, eax
    fstp    [esp+0Ch+var_C]
    fld     [esp+0Ch+arg_14]
    fsub    [esp+0Ch+arg_8]
    mov     edx, [esp+0Ch+var_C]
    mov     [ecx], edx
    fstp    [esp+0Ch+var_8]
    fld     [esp+0Ch+arg_18]
    fsub    [esp+0Ch+arg_C]
    mov     edx, [esp+0Ch+var_8]
    mov     [ecx+4], edx
    fstp    [esp+0Ch+var_4]
    mov     edx, [esp+0Ch+var_4]
    mov     [ecx+8], edx
    add     esp, 0Ch
    retn    1Ch
    sub_4B6EB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6F00 proc near                    ; CODE XREF: sub_459C70+3B7p
                                            ; sub_459C70+402p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    sub     esp, 10h
    mov     eax, [esp+10h+arg_10]
    mov     ecx, [esp+10h+arg_4]
    mov     edx, [esp+10h+arg_8]
    sub     eax, ecx
    mov     ecx, [esp+10h+arg_14]
    mov     [esp+10h+var_10], eax
    fild    [esp+10h+var_10]
    mov     eax, [esp+10h+arg_C]
    sub     ecx, edx
    mov     edx, [esp+10h+arg_18]
    mov     [esp+10h+var_10], ecx
    fstp    [esp+10h+var_C]
    fild    [esp+10h+var_10]
    sub     edx, eax
    mov     eax, [esp+10h+arg_0]
    mov     [esp+10h+arg_10], edx
    mov     edx, [esp+10h+var_C]
    fstp    [esp+10h+var_8]
    fild    [esp+10h+arg_10]
    mov     ecx, eax
    fstp    [esp+10h+var_4]
    mov     [ecx], edx
    mov     edx, [esp+10h+var_8]
    mov     [ecx+4], edx
    mov     edx, [esp+10h+var_4]
    mov     [ecx+8], edx
    add     esp, 10h
    retn    1Ch
    sub_4B6F00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6F70 proc near                    ; CODE XREF: sub_421700+3F9p
                                            ; sub_459C70+439p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    fld     [esp+arg_14]
    fld     [esp+arg_18]
    fmul    [esp+arg_8]
    fld     [esp+arg_10]
    fxch    st(2)
    fmul    [esp+arg_C]
    fld     [esp+arg_18]
    fxch    st(3)
    fmul    [esp+arg_C]
    fld     [esp+arg_14]
    fxch    st(4)
    fmul    [esp+arg_4]
    fld     [esp+arg_10]
    fxch    st(5)
    fmul    [esp+arg_4]
    fxch    st(5)
    fmul    [esp+arg_8]
    mov     eax, [esp+arg_0]
    push    esi
    fsubp   st(5), st
    fxch    st(2)
    fsubp   st(3), st
    fxch    st(3)
    fstp    [esp+4+arg_18]
    fxch    st(1)
    fstp    [esp+4+arg_10]
    mov     ecx, [esp+4+arg_10]
    mov     edx, [esp+4+arg_18]
    fsubp   st(1), st
    mov     esi, eax
    push    edi
    fstp    [esp+8+arg_14]
    mov     edi, [esp+8+arg_14]
    mov     [esi], ecx
    mov     [esi+4], edi
    pop     edi
    mov     [esi+8], edx
    pop     esi
    retn    1Ch
    sub_4B6F70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B6FF0 proc near                    ; CODE XREF: sub_421700+41Bp
                                            ; sub_459C70+46Cp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    fld     [esp+arg_8]
    fld     [esp+arg_4]
    fmul    [esp+arg_4]
    fld     [esp+arg_C]
    fxch    st(2)
    fmul    [esp+arg_8]
    fxch    st(2)
    fmul    [esp+arg_C]
    fxch    st(2)
    faddp   st(1), st
    fld     [esp+arg_4]
    fxch    st(2)
    faddp   st(1), st
    fld     [esp+arg_8]
    fld     [esp+arg_C]
    fxch    st(2)
    fsqrt
    mov     eax, [esp+arg_0]
    push    esi
    mov     ecx, eax
    fxch    st(3)
    fdiv    st, st(3)
    fxch    st(1)
    fdiv    st, st(3)
    fxch    st(2)
    fdiv    st, st(3)
    fxch    st(1)
    fstp    [esp+4+arg_4]
    mov     edx, [esp+4+arg_4]
    fxch    st(1)
    fstp    [esp+4+arg_8]
    mov     esi, [esp+4+arg_8]
    mov     [ecx], edx
    fstp    [esp+4+arg_C]
    mov     edx, [esp+4+arg_C]
    mov     [ecx+4], esi
    fstp    st
    mov     [ecx+8], edx
    pop     esi
    retn    10h
    sub_4B6FF0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    fld     dword ptr [esp+8]
    fld     dword ptr [esp+4]
    fmul    dword ptr [esp+4]
    fld     dword ptr [esp+0Ch]
    fxch    st(2)
    fmul    dword ptr [esp+8]
    fxch    st(2)
    fmul    dword ptr [esp+0Ch]
    fxch    st(2)
    faddp   st(1), st
    fxch    st(1)
    faddp   st(1), st
    fsqrt
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4B70A0 proc near                    ; CODE XREF: .text:004B71EFp
                                            ; .text:004B7206p ...

    arg_0= word ptr  8

    push    ebp
    mov     ebp, esp
    push    esi
    push    ebx
    lea     esi, ds:509F00h
    movzx   ebx, [ebp+arg_0]
    shr     ebx, 6
    and     ebx, 0FFFEh
    movsx   eax, word ptr [ebx+esi]
    pop     ebx
    pop     esi
    leave
    retn
    sub_4B70A0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4B70C0 proc near                    ; CODE XREF: .text:004B71B8p
                                            ; .text:004B71C6p ...

    arg_0= word ptr  8

    push    ebp
    mov     ebp, esp
    push    esi
    push    ebx
    lea     esi, ds:50A000h
    movzx   ebx, [ebp+arg_0]
    shr     ebx, 6
    and     ebx, 0FFFEh
    movsx   eax, word ptr [ebx+esi]
    pop     ebx
    pop     esi
    leave
    retn
    sub_4B70C0 endp

    ; ---------------------------------------------------------------------------
    push    ebp
    mov     ebp, esp
    push    edx
    mov     eax, [ebp+8]
    imul    dword ptr [ebp+0Ch]
    mov     eax, edx
    pop     edx
    leave
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4B70EF proc near                    ; CODE XREF: sub_403621+8Bp
                                            ; .text:00406742p ...

    arg_0= word ptr  8
    arg_4= dword ptr  0Ch

    push    ebp
    mov     ebp, esp
    push    esi
    push    ebx
    push    edx
    lea     esi, ds:509F00h
    movsx   ebx, [ebp+arg_0]
    add     ebx, 20h
    shr     ebx, 6
    and     ebx, 3FEh
    movsx   eax, word ptr [ebx+esi]
    imul    [ebp+arg_4]
    add     eax, 1000h
    adc     edx, 0
    shrd    eax, edx, 0Dh
    pop     edx
    pop     ebx
    pop     esi
    leave
    retn
    sub_4B70EF endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4B7123 proc near                    ; CODE XREF: sub_403621+9Dp
                                            ; .text:00406758p ...

    arg_0= word ptr  8
    arg_4= dword ptr  0Ch

    push    ebp
    mov     ebp, esp
    push    esi
    push    ebx
    push    edx
    lea     esi, ds:509F00h
    movzx   ebx, [ebp+arg_0]
    add     ebx, 4020h
    shr     ebx, 6
    and     ebx, 3FEh
    movsx   eax, word ptr [ebx+esi]
    imul    [ebp+arg_4]
    add     eax, 1000h
    adc     edx, 0
    shrd    eax, edx, 0Dh
    pop     edx
    pop     ebx
    pop     esi
    leave
    retn
    sub_4B7123 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4B715A proc near                    ; CODE XREF: .text:00412AC6p
                                            ; .text:0041410Dp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebp
    mov     ebp, esp
    fild    [ebp+arg_0]
    fild    [ebp+arg_4]
    fpatan
    fmul    dbl_509EF0
    fistp   [ebp+arg_0]
    mov     eax, [ebp+arg_0]
    leave
    retn
    sub_4B715A endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4B7173 proc near                    ; CODE XREF: sub_43D0D0+A3p
                                            ; sub_44EA60+AFp ...

    arg_0= word ptr  8
    arg_4= dword ptr  0Ch

    push    ebp
    mov     ebp, esp
    cmp     [ebp+arg_0], 0
    jz      short locret_4B71A5
    mov     eax, [ebp+arg_4]
    fild    dword ptr [eax+4]
    fild    dword ptr [eax]
    fld     st(1)
    fld     st(1)
    fild    [ebp+arg_0]
    fmul    dbl_509EF8
    fsincos
    fmul    st(5), st
    fmulp   st(4), st
    fmul    st(2), st
    fmulp   st(1), st
    faddp   st(3), st
    fsubp   st(1), st
    fistp   dword ptr [eax]
    fistp   dword ptr [eax+4]

    locret_4B71A5:                          ; CODE XREF: sub_4B7173+8j
    leave
    retn
    sub_4B7173 endp

    ; ---------------------------------------------------------------------------
    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFE8h
    push    esi
    push    edi
    push    ebx
    push    edx
    mov     esi, [ebp+8]
    push    small word ptr [esi+0Eh]
    call    sub_4B70C0
    mov     [ebp-8], eax
    mov     edi, eax
    push    small word ptr [esi+10h]
    call    sub_4B70C0
    add     sp, 4
    mov     [ebp-0Ch], eax
    imul    edi
    shrd    eax, edx, 0Dh
    mov     dword_50A400, eax
    push    small word ptr [esi+0Ch]
    call    sub_4B70C0
    mov     [ebp-4], eax
    mov     edi, eax
    push    small word ptr [esi+10h]
    call    sub_4B70A0
    add     sp, 4
    mov     [ebp-18h], eax
    imul    edi
    shrd    eax, edx, 0Dh
    push    eax
    push    small word ptr [esi+0Ch]
    call    sub_4B70A0
    mov     [ebp-10h], eax
    mov     edi, eax
    push    small word ptr [esi+0Eh]
    call    sub_4B70A0
    add     sp, 4
    mov     [ebp-14h], eax
    imul    edi
    shrd    eax, edx, 0Dh
    imul    dword ptr [ebp-0Ch]
    shrd    eax, edx, 0Dh
    pop     ebx
    add     eax, ebx
    mov     dword_50A404, eax
    mov     eax, [ebp-10h]
    imul    dword ptr [ebp-18h]
    shrd    eax, edx, 0Dh
    mov     edi, eax
    mov     eax, [ebp-4]
    imul    dword ptr [ebp-14h]
    shrd    eax, edx, 0Dh
    imul    dword ptr [ebp-0Ch]
    shrd    eax, edx, 0Dh
    sub     edi, eax
    mov     dword_50A408, edi
    mov     eax, [ebp-8]
    imul    dword ptr [ebp-18h]
    shrd    eax, edx, 0Dh
    neg     eax
    mov     dword_50A40C, eax
    mov     eax, [ebp-4]
    imul    dword ptr [ebp-0Ch]
    shrd    eax, edx, 0Dh
    mov     edi, eax
    mov     eax, [ebp-10h]
    imul    dword ptr [ebp-14h]
    shrd    eax, edx, 0Dh
    imul    dword ptr [ebp-18h]
    shrd    eax, edx, 0Dh
    sub     edi, eax
    mov     dword_50A410, edi
    mov     eax, [ebp-10h]
    imul    dword ptr [ebp-0Ch]
    shrd    eax, edx, 0Dh
    mov     edi, eax
    mov     eax, [ebp-4]
    imul    dword ptr [ebp-14h]
    shrd    eax, edx, 0Dh
    imul    dword ptr [ebp-18h]
    shrd    eax, edx, 0Dh
    add     eax, edi
    mov     dword_50A414, eax
    mov     eax, [ebp-14h]
    mov     dword_50A418, eax
    mov     eax, [ebp-10h]
    imul    dword ptr [ebp-8]
    shrd    eax, edx, 0Dh
    neg     eax
    mov     dword_50A41C, eax
    mov     eax, [ebp-4]
    imul    dword ptr [ebp-8]
    shrd    eax, edx, 0Dh
    mov     dword_50A420, eax
    pop     edx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    ; ---------------------------------------------------------------------------
    push    ebp
    mov     ebp, esp
    push    esi
    push    edi
    push    ecx
    push    edx
    mov     esi, [ebp+8]
    mov     edi, [ebp+0Ch]
    mov     eax, [esi]
    imul    dword_50A400
    shrd    eax, edx, 0Dh
    mov     ecx, eax
    mov     eax, [esi+4]
    imul    dword_50A40C
    shrd    eax, edx, 0Dh
    add     ecx, eax
    mov     eax, [esi+8]
    imul    dword_50A418
    shrd    eax, edx, 0Dh
    add     eax, ecx
    mov     [edi], eax
    mov     eax, [esi]
    imul    dword_50A404
    shrd    eax, edx, 0Dh
    mov     ecx, eax
    mov     eax, [esi+4]
    imul    dword_50A410
    shrd    eax, edx, 0Dh
    add     ecx, eax
    mov     eax, [esi+8]
    imul    dword_50A41C
    shrd    eax, edx, 0Dh
    add     eax, ecx
    mov     [edi+4], eax
    mov     eax, [esi]
    imul    dword_50A408
    shrd    eax, edx, 0Dh
    mov     ecx, eax
    mov     eax, [esi+4]
    imul    dword_50A414
    shrd    eax, edx, 0Dh
    add     ecx, eax
    mov     eax, [esi+8]
    imul    dword_50A420
    shrd    eax, edx, 0Dh
    add     eax, ecx
    mov     [edi+8], eax
    pop     edx
    pop     ecx
    pop     edi
    pop     esi
    leave
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4B7381 proc near                    ; CODE XREF: .text:004C7158p
                                            ; .text:004C7170p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebp
    mov     ebp, esp
    push    ebx
    push    ecx
    push    edx
    mov     ecx, [ebp+arg_8]
    or      ecx, ecx
    jz      short loc_4B739D
    mov     ebx, [ebp+arg_4]
    mov     eax, [ebp+arg_0]
    imul    ebx
    idiv    ecx
    pop     edx
    pop     ecx
    pop     ebx
    leave
    retn
    ; ---------------------------------------------------------------------------

    loc_4B739D:                             ; CODE XREF: sub_4B7381+Bj
    xor     eax, eax
    pop     edx
    pop     ecx
    pop     ebx
    leave
    retn
    sub_4B7381 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B73B0 proc near                    ; CODE XREF: sub_409F80+80p
                                            ; sub_40A040+80p ...
    mov     eax, ecx
    mov     dword ptr [eax+0D0h], 0
    retn
    sub_4B73B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B73C0 proc near                    ; CODE XREF: sub_406C90+39p
                                            ; sub_406C90+6Dp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    test    eax, eax
    jl      short loc_4B73D6
    cmp     eax, [ecx+0D0h]
    jge     short loc_4B73D6
    mov     eax, [ecx+eax*4]
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B73D6:                             ; CODE XREF: sub_4B73C0+6j
                                            ; sub_4B73C0+Ej
    mov     eax, [esp+arg_4]
    retn    8
    sub_4B73C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B73E0(int,int)
    sub_4B73E0 proc near                    ; CODE XREF: sub_406E40+48p
                                            ; sub_416280+15p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    test    eax, eax
    jl      short loc_4B73FF
    cmp     eax, [ecx+0D0h]
    jge     short loc_4B73FF
    mov     eax, [ecx+eax*4]
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B73FF:                             ; CODE XREF: sub_4B73E0+6j
                                            ; sub_4B73E0+Ej
    mov     eax, [esp+arg_4]
    retn    8
    sub_4B73E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7410 proc near                    ; CODE XREF: sub_406DB0+44p
                                            ; .text:00416DBBp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    test    eax, eax
    jl      short loc_4B742F
    cmp     eax, [ecx+0D0h]
    jge     short loc_4B742F
    mov     eax, [ecx+eax*4]
    push    eax                             ; char *
    call    _atof
    add     esp, 4
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B742F:                             ; CODE XREF: sub_4B7410+6j
                                            ; sub_4B7410+Ej
    fld     [esp+arg_4]
    retn    8
    sub_4B7410 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ResetTextCommandStruct proc near        ; CODE XREF: InterpretCommand+39p
                                            ; sub_4B7A30+47p

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, [esp+4+arg_4]
    mov     ebp, ecx
    test    edi, edi
    lea     ebx, [ebp+50h]
    jnz     short loc_4B7465
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ecx
    add     edi, esi

    loc_4B7465:                             ; CODE XREF: ResetTextCommandStruct+13j
    mov     dword ptr [ebp+0D0h], 0

    loc_4B746F:                             ; CODE XREF: ResetTextCommandStruct+99j
    cmp     esi, edi
    jz      short loc_4B74DB

    loc_4B7473:                             ; CODE XREF: ResetTextCommandStruct+46j
    movsx   eax, byte ptr [esi]
    push    eax                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jz      short loc_4B7488
    inc     esi
    cmp     esi, edi
    jnz     short loc_4B7473

    loc_4B7488:                             ; CODE XREF: ResetTextCommandStruct+41j
    cmp     esi, edi
    jz      short loc_4B74DB
    cmp     byte ptr [esi], 23h
    jz      short loc_4B74DB
    mov     eax, [ebp+0D0h]
    cmp     eax, 14h
    jge     short loc_4B74AD
    mov     [ebp+eax*4+0], ebx
    mov     eax, [ebp+0D0h]
    inc     eax
    mov     [ebp+0D0h], eax

    loc_4B74AD:                             ; CODE XREF: ResetTextCommandStruct+5Aj
                                            ; ResetTextCommandStruct+93j
    movsx   ecx, byte ptr [esi]
    push    ecx                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jnz     short loc_4B74D5
    mov     al, [esi]
    cmp     al, 23h
    jz      short loc_4B74D5
    lea     edx, [ebp+0CEh]
    cmp     ebx, edx
    jnb     short loc_4B74D5
    mov     [ebx], al
    inc     ebx
    inc     esi
    cmp     esi, edi
    jnz     short loc_4B74AD

    loc_4B74D5:                             ; CODE XREF: ResetTextCommandStruct+7Bj
                                            ; ResetTextCommandStruct+81j ...
    mov     byte ptr [ebx], 0
    inc     ebx
    jmp     short loc_4B746F
    ; ---------------------------------------------------------------------------

    loc_4B74DB:                             ; CODE XREF: ResetTextCommandStruct+31j
                                            ; ResetTextCommandStruct+4Aj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ResetTextCommandStruct endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B74F0 proc near                    ; CODE XREF: sub_4B7A30+58p

    arg_0= dword ptr  8

    push    ebp
    mov     ebp, ecx
    push    edi
    xor     edi, edi
    mov     eax, [ebp+0D0h]
    test    eax, eax
    jle     short loc_4B753A
    push    esi
    push    ebx
    mov     ebx, [esp+0Ch+arg_0]
    mov     esi, ebp

    loc_4B7508:                             ; CODE XREF: sub_4B74F0+46j
    mov     eax, [esi]
    cmp     byte ptr [eax], 25h
    jnz     short loc_4B752A
    inc     eax
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    test    eax, eax
    jl      short loc_4B752A
    cmp     eax, [ebx+0D0h]
    jge     short loc_4B752A
    mov     eax, [ebx+eax*4]
    mov     [esi], eax

    loc_4B752A:                             ; CODE XREF: sub_4B74F0+1Dj
                                            ; sub_4B74F0+2Bj ...
    mov     eax, [ebp+0D0h]
    inc     edi
    add     esi, 4
    cmp     edi, eax
    jl      short loc_4B7508
    pop     ebx
    pop     esi

    loc_4B753A:                             ; CODE XREF: sub_4B74F0+Ej
    pop     edi
    pop     ebp
    retn    4
    sub_4B74F0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [ecx+0D0h]
    push    edi
    mov     edi, [esp+8]
    cmp     eax, edi
    jl      short loc_4B755D
    mov     dword ptr [ecx+0D0h], 0
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B755D:                             ; CODE XREF: .text:004B754Dj
    lea     edx, [ecx+eax*4]
    lea     eax, [ecx+edi*4]
    cmp     eax, edx
    jz      short loc_4B757B
    push    esi
    mov     esi, ecx
    push    ebx
    sub     esi, eax

    loc_4B756D:                             ; CODE XREF: .text:004B7577j
    mov     ebx, [eax]
    mov     [eax+esi], ebx
    add     eax, 4
    cmp     eax, edx
    jnz     short loc_4B756D
    pop     ebx
    pop     esi

    loc_4B757B:                             ; CODE XREF: .text:004B7565j
    mov     eax, [ecx+0D0h]
    sub     eax, edi
    pop     edi
    mov     [ecx+0D0h], eax
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    xor     eax, eax
    mov     dword_51FC90, eax
    mov     dword_51FC94, eax
    retn
    ; ---------------------------------------------------------------------------
    align 4
    push    ecx
    mov     al, [esp+3]
    push    offset loc_4B75D0
    mov     byte_51FC99, al
    xor     eax, eax
    mov     dword_51FC9D, eax
    mov     dword_51FCA1, eax
    mov     dword_51FCA5, eax
    call    _atexit
    add     esp, 4
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    loc_4B75D0:                             ; DATA XREF: .text:004B75A5o
    push    esi
    mov     esi, dword_51FC9D
    push    edi
    mov     edi, dword_51FCA1
    cmp     esi, edi
    jz      short loc_4B75F6

    loc_4B75E2:                             ; CODE XREF: .text:004B75EEj
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 0Ch
    cmp     esi, edi
    jnz     short loc_4B75E2
    mov     esi, dword_51FC9D

    loc_4B75F6:                             ; CODE XREF: .text:004B75E0j
    push    esi
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     dword_51FC9D, eax
    mov     dword_51FCA1, eax
    pop     edi
    mov     dword_51FCA5, eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7620 proc near                    ; CODE XREF: sub_406F00+Cp
                                            ; sub_406F00+1Dp ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    sub     esp, 0Ch
    lea     ecx, [esp+0Ch+arg_0]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    eax
    call    sub_4C91B0
    mov     esi, dword_51FC9D
    mov     ebx, dword_51FCA1
    mov     ebp, [esp+1Ch+arg_0]
    cmp     esi, ebx
    jz      loc_4B76E3

    loc_4B764D:                             ; CODE XREF: sub_4B7620+6Fj
    mov     ecx, ebx
    mov     eax, 2AAAAAABh
    sub     ecx, esi
    push    ebp                             ; char *
    imul    ecx
    mov     eax, edx
    sar     eax, 1
    mov     ecx, eax
    shr     ecx, 1Fh
    add     eax, ecx
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     edx, [eax+eax*2]
    mov     eax, [esi+edx*4]
    push    eax                             ; char *
    lea     edi, [esi+edx*4]
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_4B768B
    lea     esi, [edi+0Ch]
    jmp     short loc_4B768D
    ; ---------------------------------------------------------------------------

    loc_4B768B:                             ; CODE XREF: sub_4B7620+64j
    mov     ebx, edi

    loc_4B768D:                             ; CODE XREF: sub_4B7620+69j
    cmp     esi, ebx
    jnz     short loc_4B764D
    mov     ebx, dword_51FCA1
    cmp     esi, ebx
    jz      short loc_4B76E3
    mov     edi, [esp+1Ch+arg_0]
    mov     eax, [esi]

    loc_4B76A1:                             ; CODE XREF: sub_4B7620+A3j
    mov     dl, [eax]
    mov     bl, [edi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4B76C9
    test    cl, cl
    jz      short loc_4B76C5
    mov     dl, [eax+1]
    mov     bl, [edi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4B76C9
    add     eax, 2
    add     edi, 2
    test    cl, cl
    jnz     short loc_4B76A1

    loc_4B76C5:                             ; CODE XREF: sub_4B7620+8Dj
    xor     eax, eax
    jmp     short loc_4B76CE
    ; ---------------------------------------------------------------------------

    loc_4B76C9:                             ; CODE XREF: sub_4B7620+89j
                                            ; sub_4B7620+99j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4B76CE:                             ; CODE XREF: sub_4B7620+A7j
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_4B76E3
    add     esi, 4
    jmp     short loc_4B773F
    ; ---------------------------------------------------------------------------

    loc_4B76E3:                             ; CODE XREF: sub_4B7620+27j
                                            ; sub_4B7620+79j ...
    lea     edx, [esp+1Ch+arg_0]
    lea     ecx, [esp+1Ch+var_C]
    push    edx
    xor     edi, edi
    xor     ebx, ebx
    call    sub_4C91A0
    mov     eax, dword_51FC9D
    mov     ecx, esi
    sub     ecx, eax
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    lea     ecx, [esp+1Ch+var_C]
    shr     eax, 1Fh
    push    ecx
    add     edx, eax
    push    1
    mov     [esp+24h+var_8], edi
    push    esi
    mov     ecx, offset byte_51FC99
    mov     [esp+28h+var_4], ebx
    mov     edi, edx
    call    sub_4B7B00
    mov     eax, dword_51FC9D
    lea     edx, [edi+edi*2]
    lea     ecx, [esp+1Ch+var_C]
    lea     esi, [eax+edx*4+4]
    call    sub_4C9390

    loc_4B773F:                             ; CODE XREF: sub_4B7620+C1j
    mov     eax, [esp+1Ch+arg_4]
    lea     ecx, [esp+1Ch+arg_0]
    mov     [esi], eax
    mov     eax, [esp+1Ch+arg_8]
    mov     [esi+4], eax
    call    sub_4C9390
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_4B7620 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7760 proc near                    ; CODE XREF: sub_419560+64p
                                            ; sub_419560+6Ep ...

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    sub     esp, 18h
    mov     eax, [ecx]
    test    eax, eax
    jz      loc_4B78CC
    push    edi
    push    esi
    push    ebp
    push    ebx
    jmp     short loc_4B777B
    ; ---------------------------------------------------------------------------

    loc_4B7777:                             ; CODE XREF: sub_4B7760+162j
    mov     ecx, [esp+28h+arg_0]

    loc_4B777B:                             ; CODE XREF: sub_4B7760+15j
    mov     edx, [ecx+8]
    mov     ecx, [ecx+4]
    mov     [esp+28h+var_14], ecx
    push    eax
    lea     ecx, [esp+2Ch+var_18]
    mov     [esp+2Ch+var_10], edx
    call    sub_4C91B0
    mov     esi, dword_51FC9D
    mov     ebx, dword_51FCA1
    mov     ebp, [esp+28h+var_18]
    cmp     esi, ebx
    jz      loc_4B7841

    loc_4B77AB:                             ; CODE XREF: sub_4B7760+8Dj
    mov     ecx, ebx
    mov     eax, 2AAAAAABh
    sub     ecx, esi
    push    ebp                             ; char *
    imul    ecx
    mov     eax, edx
    sar     eax, 1
    mov     edx, eax
    shr     edx, 1Fh
    add     eax, edx
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     eax, [eax+eax*2]
    mov     ecx, [esi+eax*4]
    lea     edi, [esi+eax*4]
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     edx, edx
    test    eax, eax
    setl    dl
    test    dl, dl
    jz      short loc_4B77E9
    lea     esi, [edi+0Ch]
    jmp     short loc_4B77EB
    ; ---------------------------------------------------------------------------

    loc_4B77E9:                             ; CODE XREF: sub_4B7760+82j
    mov     ebx, edi

    loc_4B77EB:                             ; CODE XREF: sub_4B7760+87j
    cmp     esi, ebx
    jnz     short loc_4B77AB
    mov     ebx, dword_51FCA1
    cmp     esi, ebx
    jz      short loc_4B7841
    mov     edi, [esp+28h+var_18]
    mov     eax, [esi]

    loc_4B77FF:                             ; CODE XREF: sub_4B7760+C1j
    mov     dl, [eax]
    mov     bl, [edi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4B7827
    test    cl, cl
    jz      short loc_4B7823
    mov     dl, [eax+1]
    mov     bl, [edi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4B7827
    add     eax, 2
    add     edi, 2
    test    cl, cl
    jnz     short loc_4B77FF

    loc_4B7823:                             ; CODE XREF: sub_4B7760+ABj
    xor     eax, eax
    jmp     short loc_4B782C
    ; ---------------------------------------------------------------------------

    loc_4B7827:                             ; CODE XREF: sub_4B7760+A7j
                                            ; sub_4B7760+B7j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4B782C:                             ; CODE XREF: sub_4B7760+C5j
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_4B7841
    add     esi, 4
    jmp     short loc_4B789D
    ; ---------------------------------------------------------------------------

    loc_4B7841:                             ; CODE XREF: sub_4B7760+45j
                                            ; sub_4B7760+97j ...
    lea     edx, [esp+28h+var_18]
    lea     ecx, [esp+28h+var_C]
    push    edx
    xor     edi, edi
    xor     ebx, ebx
    call    sub_4C91A0
    mov     eax, dword_51FC9D
    mov     ecx, esi
    sub     ecx, eax
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    lea     ecx, [esp+28h+var_C]
    shr     eax, 1Fh
    push    ecx
    add     edx, eax
    push    1
    mov     [esp+30h+var_8], edi
    push    esi
    mov     ecx, offset byte_51FC99
    mov     [esp+34h+var_4], ebx
    mov     edi, edx
    call    sub_4B7B00
    mov     eax, dword_51FC9D
    lea     edx, [edi+edi*2]
    lea     ecx, [esp+28h+var_C]
    lea     esi, [eax+edx*4+4]
    call    sub_4C9390

    loc_4B789D:                             ; CODE XREF: sub_4B7760+DFj
    mov     ecx, [esp+28h+var_14]
    mov     edx, [esp+28h+var_10]
    mov     [esi], ecx
    lea     ecx, [esp+28h+var_18]
    mov     [esi+4], edx
    call    sub_4C9390
    mov     eax, [esp+28h+arg_0]
    add     eax, 0Ch
    mov     [esp+28h+arg_0], eax
    mov     eax, [eax]
    test    eax, eax
    jnz     loc_4B7777
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_4B78CC:                             ; CODE XREF: sub_4B7760+Bj
    add     esp, 18h
    retn    4
    sub_4B7760 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B78E0 proc near                    ; CODE XREF: sub_419560+84p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    mov     dword_51FC90, eax
    mov     dword_51FC94, ecx
    retn    8
    sub_4B78E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall DoInterpretCommand(int,int)
    DoInterpretCommand proc near            ; CODE XREF: InterpretCommand+4Bp
                                            ; sub_4B7A30+6Ap

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 8
    push    edi
    mov     edi, [esp+0Ch+arg_0]
    mov     [esp+0Ch+var_4], 0
    cmp     dword ptr [edi+0D0h], 1
    jl      loc_4B7A03
    push    esi
    push    ebp
    push    ebx
    push    offset Data
    push    0
    mov     ecx, edi
    call    sub_4B73C0
    push    eax
    lea     ecx, [esp+1Ch+var_8]
    call    sub_4C91B0
    lea     ecx, [esp+18h+var_8]
    call    sub_4C9290
    mov     esi, dword_51FC9D
    mov     ebx, dword_51FCA1
    mov     ebp, [esp+18h+var_8]
    cmp     esi, ebx
    jz      short loc_4B79C3

    loc_4B7955:                             ; CODE XREF: DoInterpretCommand+97j
    mov     ecx, ebx
    mov     eax, 2AAAAAABh
    sub     ecx, esi
    push    ebp                             ; char *
    imul    ecx
    mov     eax, edx
    sar     eax, 1
    mov     ecx, eax
    shr     ecx, 1Fh
    add     eax, ecx
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     edx, [eax+eax*2]
    mov     eax, [esi+edx*4]
    push    eax                             ; char *
    lea     edi, [esi+edx*4]
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_4B7993
    lea     esi, [edi+0Ch]
    jmp     short loc_4B7995
    ; ---------------------------------------------------------------------------

    loc_4B7993:                             ; CODE XREF: DoInterpretCommand+8Cj
    mov     ebx, edi

    loc_4B7995:                             ; CODE XREF: DoInterpretCommand+91j
    cmp     esi, ebx
    jnz     short loc_4B7955
    mov     ebx, dword_51FCA1
    mov     edi, [esp+18h+arg_0]
    cmp     esi, ebx
    jz      short loc_4B79C3
    mov     edx, [esi]
    push    edx                             ; char *
    push    ebp                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jnz     short loc_4B79C3
    add     esi, 4
    jmp     short loc_4B79C5
    ; ---------------------------------------------------------------------------

    loc_4B79C3:                             ; CODE XREF: DoInterpretCommand+53j
                                            ; DoInterpretCommand+A5j ...
    xor     esi, esi

    loc_4B79C5:                             ; CODE XREF: DoInterpretCommand+C1j
    mov     edx, [esp+18h+arg_4]
    test    esi, esi
    jz      short loc_4B79DD
    mov     eax, [esi+4]
    test    eax, edx
    jz      short loc_4B79DD
    push    edi
    mov     [esp+1Ch+var_4], eax
    call    dword ptr [esi]
    jmp     short loc_4B79F7
    ; ---------------------------------------------------------------------------

    loc_4B79DD:                             ; CODE XREF: DoInterpretCommand+CBj
                                            ; DoInterpretCommand+D2j
    mov     ecx, dword_51FC90
    test    ecx, ecx
    jz      short loc_4B79F7
    mov     eax, dword_51FC94
    test    eax, edx
    jz      short loc_4B79F7
    push    edi
    mov     [esp+1Ch+var_4], eax
    call    ecx

    loc_4B79F7:                             ; CODE XREF: DoInterpretCommand+DBj
                                            ; DoInterpretCommand+E5j ...
    lea     ecx, [esp+18h+var_8]
    call    sub_4C9390
    pop     ebx
    pop     ebp
    pop     esi

    loc_4B7A03:                             ; CODE XREF: DoInterpretCommand+17j
    mov     eax, [esp+0Ch+var_4]
    pop     edi
    add     esp, 8
    retn    8
    DoInterpretCommand endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, [esp+8]
    xor     eax, eax
    test    edx, edx
    jle     short loc_4B7A29
    mov     ecx, [esp+4]

    loc_4B7A1E:                             ; CODE XREF: .text:004B7A27j
    cmp     byte ptr [eax+ecx], 0Ah
    jz      short locret_4B7A2B
    inc     eax
    cmp     eax, edx
    jl      short loc_4B7A1E

    loc_4B7A29:                             ; CODE XREF: .text:004B7A18j
    mov     eax, edx

    locret_4B7A2B:                          ; CODE XREF: .text:004B7A22j
    retn    8
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7A30 proc near                    ; CODE XREF: sub_409F80+8Ep
                                            ; sub_40A040+8Ep ...

    var_D4= dword ptr -0D4h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 0D4h
    lea     ecx, [esp+0D4h+var_D4]
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     ebp, ebp
    call    sub_4B73B0
    mov     edi, [esp+0E4h+arg_4]
    test    edi, edi
    jle     short loc_4B7AAF
    mov     eax, [esp+0E4h+arg_0]

    loc_4B7A57:                             ; CODE XREF: sub_4B7A30+7Dj
    xor     ebx, ebx
    test    edi, edi
    jle     short loc_4B7A68

    loc_4B7A5D:                             ; CODE XREF: sub_4B7A30+36j
    cmp     byte ptr [ebx+eax], 0Ah
    jz      short loc_4B7A6A
    inc     ebx
    cmp     ebx, edi
    jl      short loc_4B7A5D

    loc_4B7A68:                             ; CODE XREF: sub_4B7A30+2Bj
    mov     ebx, edi

    loc_4B7A6A:                             ; CODE XREF: sub_4B7A30+31j
    cmp     ebx, edi
    jg      short loc_4B7AAF
    lea     esi, [ebx+eax]
    lea     ecx, [esp+0E4h+var_D4]
    push    esi
    push    eax
    call    ResetTextCommandStruct
    lea     ecx, [esp+0E4h+var_D4]
    mov     eax, [esp+0E4h+arg_8]
    push    eax
    call    sub_4B74F0
    lea     edx, [esp+0E4h+var_D4]
    mov     ecx, [esp+0E4h+arg_C]
    push    ecx                             ; int
    push    edx                             ; int
    call    DoInterpretCommand
    or      ecx, 0FFFFFFFFh
    or      ebp, eax
    sub     ecx, ebx
    lea     eax, [esi+1]
    add     edi, ecx
    test    edi, edi
    jg      short loc_4B7A57

    loc_4B7AAF:                             ; CODE XREF: sub_4B7A30+1Ej
                                            ; sub_4B7A30+3Cj
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0D4h
    retn    10h
    sub_4B7A30 endp

    ; ---------------------------------------------------------------------------
    align 4
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    mov     esi, dword_51FC9D
    push    edi
    mov     edi, dword_51FCA1
    mov     ebx, esi
    cmp     esi, edi
    jz      short loc_4B7AF3

    loc_4B7AE5:                             ; CODE XREF: .text:004B7AF1j
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 0Ch
    cmp     esi, edi
    jnz     short loc_4B7AE5

    loc_4B7AF3:                             ; CODE XREF: .text:004B7AE3j
    pop     edi
    mov     dword_51FCA1, ebx
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7B00 proc near                    ; CODE XREF: sub_4B7620+105p
                                            ; sub_4B7760+123p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     eax, 2AAAAAABh
    mov     ebx, [esp+1Ch+arg_4]
    mov     [esp+1Ch+var_C], edi
    mov     esi, [edi+8]
    mov     ecx, [edi+0Ch]
    sub     ecx, esi
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, ebx
    jnb     loc_4B7CA9
    mov     edi, [edi+4]
    test    edi, edi
    jnz     short loc_4B7B3C
    xor     edx, edx
    jmp     short loc_4B7B50
    ; ---------------------------------------------------------------------------

    loc_4B7B3C:                             ; CODE XREF: sub_4B7B00+36j
    mov     ecx, esi
    mov     eax, 2AAAAAABh
    sub     ecx, edi
    imul    ecx
    sar     edx, 1
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_4B7B50:                             ; CODE XREF: sub_4B7B00+3Aj
    cmp     ebx, edx
    jnb     short loc_4B7B72
    test    edi, edi
    jnz     short loc_4B7B5C
    xor     ebx, ebx
    jmp     short loc_4B7B72
    ; ---------------------------------------------------------------------------

    loc_4B7B5C:                             ; CODE XREF: sub_4B7B00+56j
    mov     ecx, esi
    mov     eax, 2AAAAAABh
    sub     ecx, edi
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ebx, edx

    loc_4B7B72:                             ; CODE XREF: sub_4B7B00+52j
                                            ; sub_4B7B00+5Aj
    test    edi, edi
    jnz     short loc_4B7B7A
    xor     edx, edx
    jmp     short loc_4B7B8C
    ; ---------------------------------------------------------------------------

    loc_4B7B7A:                             ; CODE XREF: sub_4B7B00+74j
    sub     esi, edi
    mov     eax, 2AAAAAABh
    imul    esi
    sar     edx, 1
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_4B7B8C:                             ; CODE XREF: sub_4B7B00+78j
    lea     eax, [edx+ebx]
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_4B7B99
    xor     eax, eax

    loc_4B7B99:                             ; CODE XREF: sub_4B7B00+95j
    lea     edx, [eax+eax*2]
    shl     edx, 2
    push    edx                             ; int
    call    sub_4B4F10
    mov     ecx, [esp+20h+arg_0]
    mov     [esp+20h+var_4], eax
    mov     ebx, eax
    mov     eax, [esp+20h+var_C]
    add     esp, 4
    mov     esi, [eax+4]
    cmp     esi, ecx
    jz      short loc_4B7BD7

    loc_4B7BBD:                             ; CODE XREF: sub_4B7B00+D5j
    test    ebx, ebx
    jz      short loc_4B7BC9
    push    esi
    mov     ecx, ebx
    call    sub_4B7E30

    loc_4B7BC9:                             ; CODE XREF: sub_4B7B00+BFj
    mov     ecx, [esp+1Ch+arg_0]
    add     esi, 0Ch
    add     ebx, 0Ch
    cmp     esi, ecx
    jnz     short loc_4B7BBD

    loc_4B7BD7:                             ; CODE XREF: sub_4B7B00+BBj
    mov     eax, [esp+1Ch+arg_4]
    mov     esi, ebx
    test    eax, eax
    jbe     short loc_4B7C01
    mov     ebp, [esp+1Ch+arg_8]
    mov     edi, eax

    loc_4B7BE7:                             ; CODE XREF: sub_4B7B00+F7j
    test    esi, esi
    jz      short loc_4B7BF3
    push    ebp
    mov     ecx, esi
    call    sub_4B7E30

    loc_4B7BF3:                             ; CODE XREF: sub_4B7B00+E9j
    add     esi, 0Ch
    dec     edi
    jnz     short loc_4B7BE7
    mov     ecx, [esp+1Ch+arg_0]
    mov     eax, [esp+1Ch+arg_4]

    loc_4B7C01:                             ; CODE XREF: sub_4B7B00+DFj
    mov     edx, [esp+1Ch+var_C]
    lea     eax, [eax+eax*2]
    shl     eax, 2
    mov     ebp, [edx+8]
    cmp     ecx, ebp
    lea     edi, [ebx+eax]
    jz      short loc_4B7C33
    mov     esi, edi
    sub     esi, ebx
    add     esi, ecx
    sub     esi, eax

    loc_4B7C1D:                             ; CODE XREF: sub_4B7B00+131j
    test    edi, edi
    jz      short loc_4B7C29
    push    esi
    mov     ecx, edi
    call    sub_4B7E30

    loc_4B7C29:                             ; CODE XREF: sub_4B7B00+11Fj
    add     esi, 0Ch
    add     edi, 0Ch
    cmp     esi, ebp
    jnz     short loc_4B7C1D

    loc_4B7C33:                             ; CODE XREF: sub_4B7B00+113j
    mov     edi, [esp+1Ch+var_C]
    mov     ebx, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, ebx
    jz      short loc_4B7C4F

    loc_4B7C41:                             ; CODE XREF: sub_4B7B00+14Dj
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 0Ch
    cmp     esi, ebx
    jnz     short loc_4B7C41

    loc_4B7C4F:                             ; CODE XREF: sub_4B7B00+13Fj
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     eax, [esp+20h+var_8]
    mov     esi, [esp+20h+var_4]
    add     esp, 4
    lea     eax, [eax+eax*2]
    lea     ecx, [esi+eax*4]
    mov     eax, [edi+4]
    test    eax, eax
    mov     [edi+0Ch], ecx
    jnz     short loc_4B7C77
    xor     edx, edx
    jmp     short loc_4B7C8C
    ; ---------------------------------------------------------------------------

    loc_4B7C77:                             ; CODE XREF: sub_4B7B00+171j
    mov     ecx, [edi+8]
    sub     ecx, eax
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4B7C8C:                             ; CODE XREF: sub_4B7B00+175j
    mov     ecx, [esp+1Ch+arg_4]
    mov     [edi+4], esi
    lea     eax, [ecx+edx]
    lea     edx, [eax+eax*2]
    lea     eax, [esi+edx*4]
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B7CA9:                             ; CODE XREF: sub_4B7B00+2Bj
    mov     ebp, [esp+1Ch+arg_0]
    mov     ecx, esi
    sub     ecx, ebp
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 1
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx
    cmp     edx, ebx
    jnb     loc_4B7D61
    lea     eax, [ebx+ebx*2]
    shl     eax, 2
    cmp     ebp, esi
    mov     [esp+1Ch+arg_0], eax
    lea     ebx, [ebp+eax+0]
    jz      short loc_4B7CF5
    mov     edi, ebx
    sub     edi, eax

    loc_4B7CDF:                             ; CODE XREF: sub_4B7B00+1F3j
    test    ebx, ebx
    jz      short loc_4B7CEB
    push    edi
    mov     ecx, ebx
    call    sub_4B7E30

    loc_4B7CEB:                             ; CODE XREF: sub_4B7B00+1E1j
    add     edi, 0Ch
    add     ebx, 0Ch
    cmp     edi, esi
    jnz     short loc_4B7CDF

    loc_4B7CF5:                             ; CODE XREF: sub_4B7B00+1D9j
    mov     edx, [esp+1Ch+var_C]
    mov     eax, 2AAAAAABh
    mov     ebx, [esp+1Ch+arg_8]
    mov     esi, [edx+8]
    mov     ecx, esi
    sub     ecx, ebp
    imul    ecx
    sar     edx, 1
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, [esp+1Ch+arg_4]
    sub     eax, edx
    jz      short loc_4B7D30
    mov     edi, eax

    loc_4B7D1E:                             ; CODE XREF: sub_4B7B00+22Ej
    test    esi, esi
    jz      short loc_4B7D2A
    push    ebx
    mov     ecx, esi
    call    sub_4B7E30

    loc_4B7D2A:                             ; CODE XREF: sub_4B7B00+220j
    add     esi, 0Ch
    dec     edi
    jnz     short loc_4B7D1E

    loc_4B7D30:                             ; CODE XREF: sub_4B7B00+21Aj
    mov     ecx, [esp+1Ch+var_C]
    mov     esi, ebp
    mov     edi, [ecx+8]
    cmp     ebp, edi
    jz      short loc_4B7D4C

    loc_4B7D3D:                             ; CODE XREF: sub_4B7B00+24Aj
    push    ebx
    mov     ecx, esi
    call    sub_4B7E00
    add     esi, 0Ch
    cmp     esi, edi
    jnz     short loc_4B7D3D

    loc_4B7D4C:                             ; CODE XREF: sub_4B7B00+23Bj
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]
    add     [eax+8], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B7D61:                             ; CODE XREF: sub_4B7B00+1C3j
    test    ebx, ebx
    jbe     loc_4B7DE9
    mov     eax, [esp+1Ch+arg_4]
    mov     edi, esi
    mov     ebx, esi
    lea     eax, [eax+eax*2]
    shl     eax, 2
    sub     edi, eax
    mov     [esp+1Ch+arg_0], eax
    cmp     edi, esi
    jz      short loc_4B7D9B

    loc_4B7D81:                             ; CODE XREF: sub_4B7B00+295j
    test    ebx, ebx
    jz      short loc_4B7D8D
    push    edi
    mov     ecx, ebx
    call    sub_4B7E30

    loc_4B7D8D:                             ; CODE XREF: sub_4B7B00+283j
    add     edi, 0Ch
    add     ebx, 0Ch
    cmp     edi, esi
    jnz     short loc_4B7D81
    mov     eax, [esp+1Ch+arg_0]

    loc_4B7D9B:                             ; CODE XREF: sub_4B7B00+27Fj
    mov     ebx, [esp+1Ch+var_C]
    mov     edi, [ebx+8]
    mov     esi, edi
    sub     esi, eax
    cmp     ebp, esi
    jz      short loc_4B7DBC

    loc_4B7DAA:                             ; CODE XREF: sub_4B7B00+2BAj
    sub     esi, 0Ch
    sub     edi, 0Ch
    push    esi
    mov     ecx, edi
    call    sub_4B7E00
    cmp     esi, ebp
    jnz     short loc_4B7DAA

    loc_4B7DBC:                             ; CODE XREF: sub_4B7B00+2A8j
    mov     eax, [esp+1Ch+arg_0]
    mov     esi, ebp
    lea     edi, [ebp+eax+0]
    cmp     ebp, edi
    jz      short loc_4B7DDD
    mov     ebp, [esp+1Ch+arg_8]

    loc_4B7DCE:                             ; CODE XREF: sub_4B7B00+2DBj
    push    ebp
    mov     ecx, esi
    call    sub_4B7E00
    add     esi, 0Ch
    cmp     esi, edi
    jnz     short loc_4B7DCE

    loc_4B7DDD:                             ; CODE XREF: sub_4B7B00+2C8j
    mov     ecx, [esp+1Ch+arg_0]
    mov     eax, [ebx+8]
    add     eax, ecx
    mov     [ebx+8], eax

    loc_4B7DE9:                             ; CODE XREF: sub_4B7B00+263j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_4B7B00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7E00 proc near                    ; CODE XREF: sub_4B7B00+240p
                                            ; sub_4B7B00+2B3p ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_4C93B0
    mov     eax, [edi+4]
    mov     [esi+4], eax
    mov     ecx, [edi+8]
    mov     [esi+8], ecx
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    sub_4B7E00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7E30 proc near                    ; CODE XREF: sub_4B7B00+C4p
                                            ; sub_4B7B00+EEp ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_4C91A0
    mov     eax, [edi+4]
    mov     [esi+4], eax
    mov     ecx, [edi+8]
    mov     [esi+8], ecx
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    sub_4B7E30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7E60 proc near                    ; CODE XREF: sub_4B7F90+FFp
                                            ; sub_4B8150+FFp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_8]
    push    edi
    mov     ecx, [eax]
    mov     edx, [esi]
    sub     ecx, edx
    mov     edx, [esp+8+arg_0]
    jns     short loc_4B7E82
    mov     edi, [edx]
    sub     edi, ecx
    mov     [edx], edi
    mov     edi, [eax]
    sub     edi, ecx
    mov     [eax], edi

    loc_4B7E82:                             ; CODE XREF: sub_4B7E60+14j
    mov     ecx, [eax+8]
    mov     edi, [esi+8]
    sub     ecx, edi
    test    ecx, ecx
    jle     short loc_4B7E9E
    mov     edi, [edx+8]
    sub     edi, ecx
    mov     [edx+8], edi
    mov     edi, [eax+8]
    sub     edi, ecx
    mov     [eax+8], edi

    loc_4B7E9E:                             ; CODE XREF: sub_4B7E60+2Cj
    mov     ecx, [eax+4]
    mov     edi, [esi+4]
    sub     ecx, edi
    jns     short loc_4B7EB8
    mov     edi, [edx+4]
    sub     edi, ecx
    mov     [edx+4], edi
    mov     edi, [eax+4]
    sub     edi, ecx
    mov     [eax+4], edi

    loc_4B7EB8:                             ; CODE XREF: sub_4B7E60+46j
    mov     ecx, [eax+0Ch]
    mov     edi, [esi+0Ch]
    sub     ecx, edi
    test    ecx, ecx
    jle     short loc_4B7ED4
    mov     esi, [edx+0Ch]
    sub     esi, ecx
    mov     [edx+0Ch], esi
    mov     edx, [eax+0Ch]
    sub     edx, ecx
    mov     [eax+0Ch], edx

    loc_4B7ED4:                             ; CODE XREF: sub_4B7E60+62j
    pop     edi
    pop     esi
    retn    0Ch
    sub_4B7E60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7EE0 proc near                    ; CODE XREF: sub_420B00+BBp
                                            ; sub_420B00+17Ap ...

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    xor     eax, eax
    mov     ecx, [edx+8]
    test    ecx, ecx
    jz      short locret_4B7EF4
    mov     ax, [edx]
    mov     eax, [ecx+eax*8+28h]

    locret_4B7EF4:                          ; CODE XREF: sub_4B7EE0+Bj
    retn    4
    sub_4B7EE0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [esp+4]
    xor     eax, eax
    push    esi
    mov     ecx, [edx+8]
    test    ecx, ecx
    jz      short loc_4B7F23
    xor     esi, esi
    mov     si, [ecx]
    mov     ecx, [esp+0Ch]
    cmp     esi, ecx
    jle     short loc_4B7F23
    mov     [edx], cx
    mov     eax, 1

    loc_4B7F23:                             ; CODE XREF: .text:004B7F0Cj
                                            ; .text:004B7F19j
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7F30 proc near                    ; CODE XREF: sub_41F0A0+2D0p
                                            ; sub_41F0A0+2E8p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    xor     eax, eax
    test    edx, edx
    push    esi
    jl      short loc_4B7F50
    mov     ecx, [esp+4+arg_0]
    xor     esi, esi
    mov     si, [ecx]
    cmp     edx, esi
    jge     short loc_4B7F50
    test    ecx, ecx
    jz      short loc_4B7F50
    mov     eax, [ecx+edx*8+28h]

    loc_4B7F50:                             ; CODE XREF: sub_4B7F30+9j
                                            ; sub_4B7F30+16j ...
    pop     esi
    retn    8
    sub_4B7F30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7F60 proc near                    ; CODE XREF: sub_4737C0+195p
                                            ; sub_4743A0+197p ...

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    xor     eax, eax
    mov     ax, [ecx]
    retn    4
    sub_4B7F60 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     ecx, [esp+4]
    mov     eax, [ecx+8]
    test    eax, eax
    jz      short loc_4B7F88
    xor     edx, edx
    mov     dx, [ecx]
    mov     ax, [eax+edx*8+2Ch]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B7F88:                             ; CODE XREF: .text:004B7F79j
    mov     eax, 0FFFFh
    retn    4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B7F90 proc near                    ; CODE XREF: sub_41F0A0+2F2p
                                            ; sub_420B00+185p ...

    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 94h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+0A4h+arg_0]
    xor     ebx, ebx
    cmp     edi, ebx
    jnz     short loc_4B7FB9
    lea     eax, [esp+0A4h+var_30]
    push    eax
    call    sub_4C5E70
    cmp     eax, ebx
    jz      short loc_4B7FB9
    lea     edi, [esp+0A4h+var_30]

    loc_4B7FB9:                             ; CODE XREF: sub_4B7F90+15j
                                            ; sub_4B7F90+23j
    mov     esi, [esp+0A4h+arg_4]
    cmp     esi, ebx
    jz      loc_4B8128
    mov     al, [esi+0Ah]
    test    al, al
    jbe     short loc_4B8021
    test    al, al
    mov     [esp+0A4h+var_94], ebx
    jbe     loc_4B8128
    mov     ebp, [esp+0A4h+arg_C]
    mov     ebx, [esp+0A4h+arg_8]

    loc_4B7FE9:                             ; CODE XREF: sub_4B7F90+8Aj
    mov     ecx, [esi+10h]
    mov     edx, [esp+0A4h+var_94]
    push    ebp
    push    ebx
    mov     eax, [ecx+edx*4]
    push    eax
    push    edi
    mov     cl, [eax+0Bh]
    test    cl, cl
    jbe     short loc_4B8005
    call    sub_4B8500
    jmp     short loc_4B800A
    ; ---------------------------------------------------------------------------

    loc_4B8005:                             ; CODE XREF: sub_4B7F90+6Cj
    call    sub_4B7F90

    loc_4B800A:                             ; CODE XREF: sub_4B7F90+73j
    mov     eax, [esp+0A4h+var_94]
    xor     ecx, ecx
    mov     cl, [esi+0Ah]
    inc     eax
    cmp     eax, ecx
    mov     [esp+0A4h+var_94], eax
    jl      short loc_4B7FE9
    jmp     loc_4B8128
    ; ---------------------------------------------------------------------------

    loc_4B8021:                             ; CODE XREF: sub_4B7F90+3Dj
    xor     eax, eax
    xor     ecx, ecx
    mov     ax, [esi]
    mov     cx, [esi+2]
    movsx   ebp, word ptr [esi+6]
    lea     edx, [eax-1]
    mov     [esp+0A4h+var_80], ebx
    mov     [esp+0A4h+var_78], edx
    mov     [esp+0A4h+var_7C], ebx
    movsx   ebx, word ptr [esi+4]
    lea     edx, [ecx-1]
    mov     [esp+0A4h+var_74], edx
    mov     edx, [esp+0A4h+arg_8]
    sub     edx, ebx
    mov     ebx, [esp+0A4h+arg_C]
    sub     ebx, ebp
    mov     [esp+0A4h+var_90], edx
    lea     eax, [edx+eax-1]
    lea     edx, [esp+0A4h+var_70]
    lea     ecx, [ebx+ecx-1]
    push    edx
    mov     [esp+0A8h+var_84], ecx
    mov     ecx, edi
    mov     [esp+0A8h+var_8C], ebx
    mov     [esp+0A8h+var_88], eax
    call    sub_4C6AE0
    lea     eax, [esp+0A4h+var_70]
    lea     ecx, [esp+0A4h+var_90]
    push    eax
    lea     edx, [esp+0A8h+var_80]
    push    ecx
    push    edx
    call    sub_4B7E60
    mov     eax, [esp+0A4h+var_88]
    mov     ecx, [esp+0A4h+var_90]
    cmp     eax, ecx
    jl      loc_4B8128
    mov     ecx, [esp+0A4h+var_84]
    mov     eax, [esp+0A4h+var_8C]
    cmp     ecx, eax
    jl      short loc_4B8128
    mov     edx, [esp+0A4h+var_78]
    mov     eax, [esp+0A4h+var_80]
    cmp     edx, eax
    jl      short loc_4B8128
    mov     eax, [esp+0A4h+var_74]
    mov     ecx, [esp+0A4h+var_7C]
    cmp     eax, ecx
    jl      short loc_4B8128
    mov     al, [esi+9]
    test    al, al
    jnz     short loc_4B810A
    mov     edx, [esi+10h]
    xor     eax, eax
    mov     ax, [esi]
    xor     ecx, ecx
    mov     cx, [esi+2]
    mov     [esp+0A4h+var_60], eax
    mov     [esp+0A4h+var_58], eax
    xor     eax, eax
    mov     al, [esi+8]
    mov     [esp+0A4h+var_5C], ecx
    mov     [esp+0A4h+var_54], edx
    lea     ecx, [esp+0A4h+var_90]
    push    eax
    lea     edx, [esp+0A8h+var_80]
    push    ecx
    lea     eax, [esp+0ACh+var_60]
    push    edx
    push    eax
    push    edi
    call    sub_4CBE70
    jmp     short loc_4B8125
    ; ---------------------------------------------------------------------------

    loc_4B810A:                             ; CODE XREF: sub_4B7F90+13Dj
    mov     edx, [esi+10h]
    lea     ecx, [esp+0A4h+var_80]
    push    ecx
    mov     ecx, [edi+8]
    lea     eax, [esp+0A8h+var_90]
    push    edx
    mov     edx, [edi+0Ch]
    push    eax
    push    ecx
    push    edx
    call    sub_4CC51D

    loc_4B8125:                             ; CODE XREF: sub_4B7F90+178j
    add     esp, 14h

    loc_4B8128:                             ; CODE XREF: sub_4B7F90+32j
                                            ; sub_4B7F90+45j ...
    lea     eax, [esp+0A4h+var_30]
    cmp     edi, eax
    jnz     short loc_4B813A
    lea     ecx, [esp+0A4h+var_30]
    push    ecx
    call    sub_4C5FA0

    loc_4B813A:                             ; CODE XREF: sub_4B7F90+19Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 94h
    retn    10h
    sub_4B7F90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8150 proc near                    ; CODE XREF: sub_483FA0+170p
                                            ; sub_483FA0+1BCp ...

    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 94h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+0A4h+arg_0]
    xor     ebx, ebx
    cmp     edi, ebx
    jnz     short loc_4B8179
    lea     eax, [esp+0A4h+var_30]
    push    eax
    call    sub_4C5E70
    cmp     eax, ebx
    jz      short loc_4B8179
    lea     edi, [esp+0A4h+var_30]

    loc_4B8179:                             ; CODE XREF: sub_4B8150+15j
                                            ; sub_4B8150+23j
    mov     esi, [esp+0A4h+arg_4]
    cmp     esi, ebx
    jz      loc_4B82E5
    mov     al, [esi+0Ah]
    test    al, al
    jbe     short loc_4B81E1
    test    al, al
    mov     [esp+0A4h+var_94], ebx
    jbe     loc_4B82E5
    mov     ebp, [esp+0A4h+arg_C]
    mov     ebx, [esp+0A4h+arg_8]

    loc_4B81A9:                             ; CODE XREF: sub_4B8150+8Aj
    mov     ecx, [esi+10h]
    mov     edx, [esp+0A4h+var_94]
    push    ebp
    push    ebx
    mov     eax, [ecx+edx*4]
    push    eax
    push    edi
    mov     cl, [eax+0Bh]
    test    cl, cl
    jbe     short loc_4B81C5
    call    sub_4B8500
    jmp     short loc_4B81CA
    ; ---------------------------------------------------------------------------

    loc_4B81C5:                             ; CODE XREF: sub_4B8150+6Cj
    call    sub_4B7F90

    loc_4B81CA:                             ; CODE XREF: sub_4B8150+73j
    mov     eax, [esp+0A4h+var_94]
    xor     ecx, ecx
    mov     cl, [esi+0Ah]
    inc     eax
    cmp     eax, ecx
    mov     [esp+0A4h+var_94], eax
    jl      short loc_4B81A9
    jmp     loc_4B82E5
    ; ---------------------------------------------------------------------------

    loc_4B81E1:                             ; CODE XREF: sub_4B8150+3Dj
    xor     eax, eax
    xor     ecx, ecx
    mov     ax, [esi]
    mov     cx, [esi+2]
    movsx   ebp, word ptr [esi+6]
    lea     edx, [eax-1]
    mov     [esp+0A4h+var_80], ebx
    mov     [esp+0A4h+var_78], edx
    mov     [esp+0A4h+var_7C], ebx
    movsx   ebx, word ptr [esi+4]
    lea     edx, [ecx-1]
    mov     [esp+0A4h+var_74], edx
    mov     edx, [esp+0A4h+arg_8]
    sub     edx, ebx
    mov     ebx, [esp+0A4h+arg_C]
    sub     ebx, ebp
    mov     [esp+0A4h+var_90], edx
    lea     eax, [edx+eax-1]
    lea     edx, [esp+0A4h+var_70]
    lea     ecx, [ebx+ecx-1]
    push    edx
    mov     [esp+0A8h+var_84], ecx
    mov     ecx, edi
    mov     [esp+0A8h+var_8C], ebx
    mov     [esp+0A8h+var_88], eax
    call    sub_4C6AE0
    lea     eax, [esp+0A4h+var_70]
    lea     ecx, [esp+0A4h+var_90]
    push    eax
    lea     edx, [esp+0A8h+var_80]
    push    ecx
    push    edx
    call    sub_4B7E60
    mov     eax, [esp+0A4h+var_88]
    mov     ecx, [esp+0A4h+var_90]
    cmp     eax, ecx
    jl      loc_4B82E5
    mov     ecx, [esp+0A4h+var_84]
    mov     eax, [esp+0A4h+var_8C]
    cmp     ecx, eax
    jl      short loc_4B82E5
    mov     edx, [esp+0A4h+var_78]
    mov     eax, [esp+0A4h+var_80]
    cmp     edx, eax
    jl      short loc_4B82E5
    mov     eax, [esp+0A4h+var_74]
    mov     ecx, [esp+0A4h+var_7C]
    cmp     eax, ecx
    jl      short loc_4B82E5
    mov     al, [esi+9]
    test    al, al
    jnz     short loc_4B82C7
    mov     edx, [esi+10h]
    xor     eax, eax
    mov     ax, [esi]
    xor     ecx, ecx
    mov     cx, [esi+2]
    mov     [esp+0A4h+var_60], eax
    mov     [esp+0A4h+var_58], eax
    mov     [esp+0A4h+var_5C], ecx
    lea     eax, [esp+0A4h+var_90]
    mov     [esp+0A4h+var_54], edx
    lea     ecx, [esp+0A4h+var_80]
    push    eax
    lea     edx, [esp+0A8h+var_60]
    push    ecx
    push    edx
    push    edi
    call    sub_4CBDD1
    add     esp, 10h
    jmp     short loc_4B82E5
    ; ---------------------------------------------------------------------------

    loc_4B82C7:                             ; CODE XREF: sub_4B8150+13Dj
    mov     ecx, [esi+10h]
    lea     eax, [esp+0A4h+var_80]
    push    eax
    mov     eax, [edi+8]
    lea     edx, [esp+0A8h+var_90]
    push    ecx
    mov     ecx, [edi+0Ch]
    push    edx
    push    eax
    push    ecx
    call    sub_4CC51D
    add     esp, 14h

    loc_4B82E5:                             ; CODE XREF: sub_4B8150+32j
                                            ; sub_4B8150+45j ...
    lea     edx, [esp+0A4h+var_30]
    cmp     edi, edx
    jnz     short loc_4B82F7
    lea     eax, [esp+0A4h+var_30]
    push    eax
    call    sub_4C5FA0

    loc_4B82F7:                             ; CODE XREF: sub_4B8150+19Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 94h
    retn    10h
    sub_4B8150 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8310 proc near                    ; CODE XREF: sub_4A50E0+B1p
                                            ; sub_4A5E50+9Dp ...

    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 94h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     [esp+0A4h+var_94], eax
    mov     al, [eax+0F0h]
    and     al, 80h
    cmp     al, 80h
    jnz     loc_4B84E7
    mov     ebp, [esp+0A4h+arg_0]
    xor     ebx, ebx
    cmp     ebp, ebx
    jnz     short loc_4B8352
    lea     ecx, [esp+0A4h+var_30]
    push    ecx
    call    sub_4C5E70
    cmp     eax, ebx
    jz      short loc_4B8352
    lea     ebp, [esp+0A4h+var_30]

    loc_4B8352:                             ; CODE XREF: sub_4B8310+2Ej
                                            ; sub_4B8310+3Cj
    mov     esi, [esp+0A4h+arg_4]
    cmp     esi, ebx
    jz      loc_4B84D5
    mov     al, [esi+0Ah]
    cmp     al, bl
    jbe     short loc_4B839E
    xor     edi, edi
    cmp     al, bl
    jbe     loc_4B84D5
    mov     ebx, [esp+0A4h+arg_C]

    loc_4B8379:                             ; CODE XREF: sub_4B8310+87j
    mov     eax, [esi+10h]
    mov     edx, [esp+0A4h+arg_8]
    push    ebx
    push    edx
    mov     ecx, [eax+edi*4]
    push    ecx
    push    ebp
    call    sub_4B8500
    xor     edx, edx
    inc     edi
    mov     dl, [esi+0Ah]
    cmp     edi, edx
    jl      short loc_4B8379
    jmp     loc_4B84D5
    ; ---------------------------------------------------------------------------

    loc_4B839E:                             ; CODE XREF: sub_4B8310+56j
    xor     eax, eax
    mov     [esp+0A4h+var_80], ebx
    mov     ax, [esi]
    mov     [esp+0A4h+var_7C], ebx
    movsx   edi, word ptr [esi+4]
    lea     ecx, [eax-1]
    mov     [esp+0A4h+var_78], ecx
    xor     ecx, ecx
    mov     cx, [esi+2]
    movsx   ebx, word ptr [esi+6]
    lea     edx, [ecx-1]
    mov     [esp+0A4h+var_74], edx
    mov     edx, [esp+0A4h+arg_8]
    sub     edx, edi
    mov     edi, [esp+0A4h+arg_C]
    sub     edi, ebx
    mov     [esp+0A4h+var_90], edx
    lea     eax, [edx+eax-1]
    lea     edx, [esp+0A4h+var_70]
    lea     ecx, [edi+ecx-1]
    push    edx
    mov     [esp+0A8h+var_84], ecx
    mov     ecx, ebp
    mov     [esp+0A8h+var_8C], edi
    mov     [esp+0A8h+var_88], eax
    call    sub_4C6AE0
    lea     eax, [esp+0A4h+var_70]
    lea     ecx, [esp+0A4h+var_90]
    push    eax
    lea     edx, [esp+0A8h+var_80]
    push    ecx
    push    edx
    call    sub_4B7E60
    mov     eax, [esp+0A4h+var_88]
    mov     ecx, [esp+0A4h+var_90]
    cmp     eax, ecx
    jl      loc_4B84D5
    mov     ecx, [esp+0A4h+var_84]
    mov     eax, [esp+0A4h+var_8C]
    cmp     ecx, eax
    jl      loc_4B84D5
    mov     edx, [esp+0A4h+var_78]
    mov     eax, [esp+0A4h+var_80]
    cmp     edx, eax
    jl      loc_4B84D5
    mov     eax, [esp+0A4h+var_74]
    mov     ecx, [esp+0A4h+var_7C]
    cmp     eax, ecx
    jl      loc_4B84D5
    mov     al, [esi+9]
    test    al, al
    jnz     short loc_4B84A0
    mov     edx, [esi+10h]
    xor     eax, eax
    mov     ax, [esi]
    xor     ecx, ecx
    mov     cx, [esi+2]
    mov     [esp+0A4h+var_60], eax
    mov     [esp+0A4h+var_58], eax
    mov     eax, [esp+0A4h+var_94]
    mov     [esp+0A4h+var_5C], ecx
    mov     [esp+0A4h+var_54], edx
    mov     ecx, [eax+0C8h]
    mov     edx, [esp+0A4h+arg_10]
    push    ecx
    lea     eax, [esp+0A8h+var_90]
    push    edx
    lea     ecx, [esp+0ACh+var_80]
    push    eax
    lea     edx, [esp+0B0h+var_60]
    push    ecx
    push    edx
    push    ebp
    call    sub_4CBF2C
    jmp     short loc_4B84D2
    ; ---------------------------------------------------------------------------

    loc_4B84A0:                             ; CODE XREF: sub_4B8310+146j
    mov     ecx, [esp+0A4h+var_94]
    mov     eax, [esp+0A4h+arg_10]
    shl     eax, 8
    mov     edx, [ecx+0C8h]
    mov     ecx, [esi+10h]
    add     edx, eax
    lea     eax, [esp+0A4h+var_80]
    push    edx
    push    eax
    mov     eax, [ebp+8]
    lea     edx, [esp+0ACh+var_90]
    push    ecx
    mov     ecx, [ebp+0Ch]
    push    edx
    push    eax
    push    ecx
    call    sub_4CC3D0

    loc_4B84D2:                             ; CODE XREF: sub_4B8310+18Ej
    add     esp, 18h

    loc_4B84D5:                             ; CODE XREF: sub_4B8310+4Bj
                                            ; sub_4B8310+5Cj ...
    lea     edx, [esp+0A4h+var_30]
    cmp     ebp, edx
    jnz     short loc_4B84E7
    lea     eax, [esp+0A4h+var_30]
    push    eax
    call    sub_4C5FA0

    loc_4B84E7:                             ; CODE XREF: sub_4B8310+1Dj
                                            ; sub_4B8310+1CBj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 94h
    retn    14h
    sub_4B8310 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8500 proc near                    ; CODE XREF: sub_439740+27Bp
                                            ; sub_459200+119p ...

    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 94h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     cl, [eax+0F0h]
    mov     [esp+0A4h+var_94], eax
    test    cl, 20h
    jz      loc_4B86C4
    mov     ebp, [esp+0A4h+arg_0]
    xor     ebx, ebx
    cmp     ebp, ebx
    jnz     short loc_4B8541
    lea     eax, [esp+0A4h+var_30]
    push    eax
    call    sub_4C5E70
    cmp     eax, ebx
    jz      short loc_4B8541
    lea     ebp, [esp+0A4h+var_30]

    loc_4B8541:                             ; CODE XREF: sub_4B8500+2Dj
                                            ; sub_4B8500+3Bj
    mov     esi, [esp+0A4h+arg_4]
    cmp     esi, ebx
    jz      loc_4B86B2
    mov     al, [esi+0Ah]
    cmp     al, bl
    jbe     short loc_4B858D
    xor     edi, edi
    cmp     al, bl
    jbe     loc_4B86B2
    mov     ebx, [esp+0A4h+arg_C]

    loc_4B8568:                             ; CODE XREF: sub_4B8500+86j
    mov     edx, [esi+10h]
    mov     ecx, [esp+0A4h+arg_8]
    push    ebx
    push    ecx
    mov     eax, [edx+edi*4]
    push    eax
    push    ebp
    call    sub_4B8500
    xor     ecx, ecx
    inc     edi
    mov     cl, [esi+0Ah]
    cmp     edi, ecx
    jl      short loc_4B8568
    jmp     loc_4B86B2
    ; ---------------------------------------------------------------------------

    loc_4B858D:                             ; CODE XREF: sub_4B8500+55j
    xor     eax, eax
    xor     ecx, ecx
    mov     ax, [esi]
    mov     cx, [esi+2]
    movsx   edi, word ptr [esi+4]
    lea     edx, [eax-1]
    mov     [esp+0A4h+var_80], ebx
    mov     [esp+0A4h+var_78], edx
    lea     edx, [ecx-1]
    mov     [esp+0A4h+var_74], edx
    mov     edx, [esp+0A4h+arg_8]
    mov     [esp+0A4h+var_7C], ebx
    sub     edx, edi
    movsx   ebx, word ptr [esi+6]
    mov     edi, [esp+0A4h+arg_C]
    mov     [esp+0A4h+var_90], edx
    sub     edi, ebx
    lea     eax, [edx+eax-1]
    lea     edx, [esp+0A4h+var_70]
    mov     [esp+0A4h+var_8C], edi
    lea     ecx, [edi+ecx-1]
    push    edx
    mov     [esp+0A8h+var_84], ecx
    mov     ecx, ebp
    mov     [esp+0A8h+var_88], eax
    call    sub_4C6AE0
    lea     eax, [esp+0A4h+var_70]
    lea     ecx, [esp+0A4h+var_90]
    push    eax
    lea     edx, [esp+0A8h+var_80]
    push    ecx
    push    edx
    call    sub_4B7E60
    mov     eax, [esp+0A4h+var_88]
    mov     ecx, [esp+0A4h+var_90]
    cmp     eax, ecx
    jl      loc_4B86B2
    mov     ecx, [esp+0A4h+var_84]
    mov     eax, [esp+0A4h+var_8C]
    cmp     ecx, eax
    jl      loc_4B86B2
    mov     edx, [esp+0A4h+var_78]
    mov     eax, [esp+0A4h+var_80]
    cmp     edx, eax
    jl      loc_4B86B2
    mov     eax, [esp+0A4h+var_74]
    mov     ecx, [esp+0A4h+var_7C]
    cmp     eax, ecx
    jl      short loc_4B86B2
    mov     al, [esi+9]
    test    al, al
    jnz     short loc_4B8689
    mov     edx, [esi+10h]
    xor     eax, eax
    mov     ax, [esi]
    xor     ecx, ecx
    mov     cx, [esi+2]
    mov     [esp+0A4h+var_60], eax
    mov     [esp+0A4h+var_58], eax
    mov     eax, [esp+0A4h+var_94]
    mov     [esp+0A4h+var_54], edx
    mov     [esp+0A4h+var_5C], ecx
    mov     ecx, [eax+0C0h]
    xor     edx, edx
    mov     dl, [esi+8]
    push    ecx
    lea     eax, [esp+0A8h+var_90]
    push    edx
    lea     ecx, [esp+0ACh+var_80]
    push    eax
    lea     edx, [esp+0B0h+var_60]
    push    ecx
    push    edx
    push    ebp
    call    sub_4CBF2C
    jmp     short loc_4B86AF
    ; ---------------------------------------------------------------------------

    loc_4B8689:                             ; CODE XREF: sub_4B8500+141j
    mov     eax, [esp+0A4h+var_94]
    lea     edx, [esp+0A4h+var_80]
    mov     ecx, [eax+0C0h]
    mov     eax, [esi+10h]
    push    ecx
    push    edx
    mov     edx, [ebp+8]
    lea     ecx, [esp+0ACh+var_90]
    push    eax
    mov     eax, [ebp+0Ch]
    push    ecx
    push    edx
    push    eax
    call    sub_4CC057

    loc_4B86AF:                             ; CODE XREF: sub_4B8500+187j
    add     esp, 18h

    loc_4B86B2:                             ; CODE XREF: sub_4B8500+4Aj
                                            ; sub_4B8500+5Bj ...
    lea     ecx, [esp+0A4h+var_30]
    cmp     ebp, ecx
    jnz     short loc_4B86C4
    lea     edx, [esp+0A4h+var_30]
    push    edx
    call    sub_4C5FA0

    loc_4B86C4:                             ; CODE XREF: sub_4B8500+1Cj
                                            ; sub_4B8500+1B8j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 94h
    retn    10h
    sub_4B8500 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B86E0 proc near                    ; CODE XREF: sub_4848E0+1B8p
                                            ; sub_4B86E0+80p

    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= word ptr -58h
    var_56= word ptr -56h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 94h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    test    byte ptr [eax+0F1h], 1
    mov     [esp+0A4h+var_74], eax
    jz      loc_4B88B4
    mov     esi, [esp+0A4h+arg_4]
    xor     ebx, ebx
    cmp     [esi+9], bl
    jnz     loc_4B88B4
    mov     ebp, [esp+0A4h+arg_0]
    cmp     ebp, ebx
    jnz     short loc_4B872F
    lea     eax, [esp+0A4h+var_30]
    push    eax
    call    sub_4C5E70
    cmp     eax, ebx
    jz      short loc_4B872F
    lea     ebp, [esp+0A4h+var_30]

    loc_4B872F:                             ; CODE XREF: sub_4B86E0+3Bj
                                            ; sub_4B86E0+49j
    cmp     esi, ebx
    jz      loc_4B88A2
    mov     al, [esi+0Ah]
    cmp     al, bl
    jbe     short loc_4B8774
    xor     edi, edi
    cmp     al, bl
    jbe     loc_4B88A2
    mov     ebx, [esp+0A4h+arg_C]

    loc_4B874F:                             ; CODE XREF: sub_4B86E0+8Dj
    mov     edx, [esi+10h]
    mov     ecx, [esp+0A4h+arg_8]
    push    ebx
    push    ecx
    mov     eax, [edx+edi*4]
    push    eax
    push    ebp
    call    sub_4B86E0
    xor     ecx, ecx
    inc     edi
    mov     cl, [esi+0Ah]
    cmp     edi, ecx
    jl      short loc_4B874F
    jmp     loc_4B88A2
    ; ---------------------------------------------------------------------------

    loc_4B8774:                             ; CODE XREF: sub_4B86E0+5Cj
    xor     eax, eax
    xor     ecx, ecx
    mov     ax, [esi]
    mov     cx, [esi+2]
    movsx   edi, word ptr [esi+4]
    lea     edx, [eax-1]
    mov     [esp+0A4h+var_94], ebx
    mov     [esp+0A4h+var_8C], edx
    lea     edx, [ecx-1]
    mov     [esp+0A4h+var_88], edx
    mov     edx, [esp+0A4h+arg_8]
    mov     [esp+0A4h+var_90], ebx
    sub     edx, edi
    movsx   ebx, word ptr [esi+6]
    mov     edi, [esp+0A4h+arg_C]
    mov     [esp+0A4h+var_84], edx
    sub     edi, ebx
    lea     eax, [edx+eax-1]
    lea     edx, [esp+0A4h+var_40]
    mov     [esp+0A4h+var_80], edi
    lea     ecx, [edi+ecx-1]
    push    edx
    mov     [esp+0A8h+var_78], ecx
    mov     ecx, ebp
    mov     [esp+0A8h+var_7C], eax
    call    sub_4C6AE0
    lea     eax, [esp+0A4h+var_40]
    lea     ecx, [esp+0A4h+var_84]
    push    eax
    lea     edx, [esp+0A8h+var_94]
    push    ecx
    push    edx
    call    sub_4B7E60
    mov     eax, [esp+0A4h+var_7C]
    mov     ecx, [esp+0A4h+var_84]
    cmp     eax, ecx
    jl      loc_4B88A2
    mov     ecx, [esp+0A4h+var_78]
    mov     eax, [esp+0A4h+var_80]
    cmp     ecx, eax
    jl      loc_4B88A2
    mov     edx, [esp+0A4h+var_8C]
    mov     eax, [esp+0A4h+var_94]
    cmp     edx, eax
    jl      loc_4B88A2
    mov     eax, [esp+0A4h+var_88]
    mov     ecx, [esp+0A4h+var_90]
    cmp     eax, ecx
    jl      short loc_4B88A2
    xor     eax, eax
    mov     edx, [esi+10h]
    mov     ax, [esi]
    xor     ecx, ecx
    mov     cx, [esi+2]
    mov     [esp+0A4h+var_70], eax
    mov     [esp+0A4h+var_68], eax
    mov     ax, [esi+4]
    mov     [esp+0A4h+var_58], ax
    mov     eax, [esp+0A4h+var_44]
    mov     [esp+0A4h+var_64], edx
    or      al, 1
    mov     [esp+0A4h+var_6C], ecx
    mov     cx, [esi+6]
    lea     edx, [esp+0A4h+var_70]
    and     al, 0FDh
    push    edx
    mov     [esp+0A8h+var_60], 2710h
    mov     [esp+0A8h+var_5C], 0FFFFFFFFh
    mov     [esp+0A8h+var_56], cx
    mov     [esp+0A8h+var_44], eax
    call    sub_4C69C0
    xor     edx, edx
    mov     eax, [esp+0A4h+var_74]
    mov     dl, [esi+8]
    mov     ecx, [eax+0CCh]
    lea     eax, [esp+0A4h+var_84]
    push    ecx
    push    edx
    lea     ecx, [esp+0ACh+var_94]
    push    eax
    lea     edx, [esp+0B0h+var_70]
    push    ecx
    push    edx
    push    ebp
    call    sub_4CBFC4
    add     esp, 18h

    loc_4B88A2:                             ; CODE XREF: sub_4B86E0+51j
                                            ; sub_4B86E0+62j ...
    lea     eax, [esp+0A4h+var_30]
    cmp     ebp, eax
    jnz     short loc_4B88B4
    lea     ecx, [esp+0A4h+var_30]
    push    ecx
    call    sub_4C5FA0

    loc_4B88B4:                             ; CODE XREF: sub_4B86E0+1Aj
                                            ; sub_4B86E0+2Cj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 94h
    retn    10h
    sub_4B86E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B88D0 proc near                    ; CODE XREF: sub_4848E0+1A1p
                                            ; sub_4B88D0+62p

    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 60h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+70h+arg_4]
    mov     al, [edi+9]
    test    al, al
    jnz     loc_4B8A71
    mov     ebx, [esp+70h+arg_0]
    xor     esi, esi
    cmp     ebx, esi
    jnz     short loc_4B8906
    lea     eax, [esp+70h+var_30]
    push    eax
    call    sub_4C5E70
    cmp     eax, esi
    jz      short loc_4B8906
    lea     ebx, [esp+70h+var_30]
    mov     [esp+70h+arg_0], ebx

    loc_4B8906:                             ; CODE XREF: sub_4B88D0+1Ej
                                            ; sub_4B88D0+2Cj
    cmp     edi, esi
    jz      loc_4B8A5F
    mov     al, [edi+0Ah]
    test    al, al
    jbe     short loc_4B8946
    mov     ebp, [esp+70h+arg_10]

    loc_4B891C:                             ; CODE XREF: sub_4B88D0+6Fj
    mov     ecx, [esp+70h+arg_C]
    mov     eax, [edi+10h]
    mov     edx, [esp+70h+arg_8]
    push    ebp
    push    ecx
    mov     ecx, [eax+esi*4]
    push    edx
    push    ecx
    push    ebx
    call    sub_4B88D0
    xor     edx, edx
    inc     esi
    mov     dl, [edi+0Ah]
    cmp     esi, edx
    jl      short loc_4B891C
    jmp     loc_4B8A5F
    ; ---------------------------------------------------------------------------

    loc_4B8946:                             ; CODE XREF: sub_4B88D0+43j
    xor     eax, eax
    mov     [esp+70h+var_50], esi
    mov     ax, [edi]
    mov     [esp+70h+var_4C], esi
    movsx   esi, word ptr [edi+4]
    lea     ecx, [eax-1]
    mov     [esp+70h+var_48], ecx
    xor     ecx, ecx
    mov     cx, [edi+2]
    movsx   ebp, word ptr [edi+6]
    lea     edx, [ecx-1]
    mov     [esp+70h+var_44], edx
    mov     edx, [esp+70h+arg_8]
    sub     edx, esi
    mov     esi, [esp+70h+arg_C]
    sub     esi, ebp
    mov     [esp+70h+var_60], edx
    lea     eax, [edx+eax-1]
    lea     edx, [esp+70h+var_40]
    lea     ecx, [esi+ecx-1]
    push    edx
    mov     [esp+74h+var_54], ecx
    mov     ecx, ebx
    mov     [esp+74h+var_5C], esi
    mov     [esp+74h+var_58], eax
    call    sub_4C6AE0
    lea     eax, [esp+70h+var_40]
    lea     ecx, [esp+70h+var_60]
    push    eax
    lea     edx, [esp+74h+var_50]
    push    ecx
    push    edx
    call    sub_4B7E60
    mov     ebp, [esp+70h+var_60]
    cmp     [esp+70h+var_58], ebp
    jl      loc_4B8A5F
    mov     eax, [esp+70h+var_54]
    mov     edx, [esp+70h+var_5C]
    cmp     eax, edx
    jl      loc_4B8A5F
    mov     ecx, [esp+70h+var_48]
    mov     esi, [esp+70h+var_50]
    cmp     ecx, esi
    jl      short loc_4B8A5F
    mov     ecx, [esp+70h+var_4C]
    mov     esi, [esp+70h+var_44]
    cmp     esi, ecx
    jl      short loc_4B8A5F
    cmp     edx, eax
    mov     [esp+70h+arg_8], ecx
    jg      short loc_4B8A5F

    loc_4B89F4:                             ; CODE XREF: sub_4B88D0+18Dj
    xor     eax, eax
    mov     esi, [esp+70h+var_50]
    mov     ax, [edi]
    imul    ecx, eax
    mov     eax, [edi+10h]
    add     ecx, esi
    add     ecx, eax
    mov     eax, edx
    imul    eax, [ebx+8]
    mov     esi, [ebx+0Ch]
    add     eax, ebp
    add     eax, esi
    mov     esi, [esp+70h+var_58]
    lea     ebx, [edx+ebp]
    add     esi, eax
    add     ebx, [esp+70h+arg_10]
    sub     esi, ebp
    test    bl, 1
    jz      short loc_4B8A2D
    inc     eax
    inc     ecx

    loc_4B8A2D:                             ; CODE XREF: sub_4B88D0+159j
    cmp     eax, esi
    ja      short loc_4B8A49

    loc_4B8A31:                             ; CODE XREF: sub_4B88D0+177j
    mov     bl, [ecx]
    cmp     bl, [edi+8]
    jz      short loc_4B8A3F
    mov     byte ptr [eax], 0
    mov     ebp, [esp+70h+var_60]

    loc_4B8A3F:                             ; CODE XREF: sub_4B88D0+166j
    add     eax, 2
    add     ecx, 2
    cmp     eax, esi
    jbe     short loc_4B8A31

    loc_4B8A49:                             ; CODE XREF: sub_4B88D0+15Fj
    mov     ecx, [esp+70h+arg_8]
    mov     eax, [esp+70h+var_54]
    mov     ebx, [esp+70h+arg_0]
    inc     edx
    inc     ecx
    cmp     edx, eax
    mov     [esp+70h+arg_8], ecx
    jle     short loc_4B89F4

    loc_4B8A5F:                             ; CODE XREF: sub_4B88D0+38j
                                            ; sub_4B88D0+71j ...
    lea     ecx, [esp+70h+var_30]
    cmp     ebx, ecx
    jnz     short loc_4B8A71
    lea     edx, [esp+70h+var_30]
    push    edx
    call    sub_4C5FA0

    loc_4B8A71:                             ; CODE XREF: sub_4B88D0+10j
                                            ; sub_4B88D0+195j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 60h
    retn    14h
    sub_4B88D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B8A80(int,int)
    sub_4B8A80 proc near                    ; CODE XREF: sub_4589C0+26Ep
                                            ; sub_4665D0+E1p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_4]
    mov     eax, [esp+arg_0]
    xor     edx, edx
    push    eax
    mov     dx, [ecx]
    mov     [eax], edx
    xor     edx, edx
    mov     dx, [ecx+2]
    mov     [eax+4], edx
    xor     edx, edx
    mov     dx, [ecx]
    mov     [eax+8], edx
    mov     edx, [ecx+10h]
    mov     [eax+0Ch], edx
    mov     dword ptr [eax+10h], 2710h
    mov     dword ptr [eax+14h], 0FFFFFFFFh
    mov     dx, [ecx+4]
    mov     [eax+18h], dx
    mov     edx, [eax+2Ch]
    mov     cx, [ecx+6]
    and     edx, 0FFFFFFFDh
    or      edx, 1
    mov     [eax+1Ah], cx
    mov     [eax+2Ch], edx
    call    sub_4C69C0
    retn    8
    sub_4B8A80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8AE0 proc near                    ; CODE XREF: sub_44C0D0+F0p
                                            ; sub_460160+6Ep ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_4]
    mov     eax, [esp+arg_0]
    mov     dx, [ecx]
    mov     [eax], dx
    mov     dx, [ecx+4]
    mov     [eax+2], dx
    mov     dx, [ecx+8]
    mov     [eax], dx
    mov     edx, [ecx+0Ch]
    mov     [eax+10h], edx
    mov     dx, [ecx+18h]
    mov     [eax+4], dx
    mov     cx, [ecx+1Ah]
    mov     [eax+6], cx
    xor     cl, cl
    mov     [eax+9], cl
    mov     byte ptr [eax+8], 0FFh
    mov     [eax+0Ah], cl
    mov     [eax+0Bh], cl
    retn    8
    sub_4B8AE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8B30 proc near                    ; CODE XREF: sub_420A30+5Cp
                                            ; sub_420A30+80p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_8]
    xor     edx, edx
    push    ebx
    mov     dx, [eax]
    xor     ebx, ebx
    cmp     ecx, edx
    setnl   bl
    dec     ebx
    and     ebx, ecx
    mov     ecx, [esp+4+arg_0]
    test    eax, eax
    mov     [ecx], bx
    mov     [ecx+8], eax
    jz      short loc_4B8B6E
    xor     edx, edx
    mov     dx, bx
    mov     dx, [eax+edx*8+2Ch]
    mov     [ecx+2], dx
    mov     al, [eax+2]
    mov     [ecx+4], al
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B8B6E:                             ; CODE XREF: sub_4B8B30+24j
    mov     edx, 0FFFFh
    pop     ebx
    mov     [ecx+2], dx
    mov     al, [eax+2]
    mov     [ecx+4], al
    retn    0Ch
    sub_4B8B30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8B90 proc near                    ; CODE XREF: sub_415B30+1Fp
                                            ; sub_420F30+18Bp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+8]
    test    ecx, ecx
    jz      short loc_4B8BE6
    mov     dx, [eax+2]
    cmp     dx, 2
    jnb     short loc_4B8BE1
    inc     word ptr [eax]
    mov     dx, [eax]
    cmp     dx, [ecx]
    jb      short loc_4B8BBC
    mov     dl, [eax+4]
    test    dl, dl
    jz      short loc_4B8BD2
    mov     word ptr [eax], 0

    loc_4B8BBC:                             ; CODE XREF: sub_4B8B90+1Ej
    xor     edx, edx
    mov     dx, [eax]
    mov     cx, [ecx+edx*8+2Ch]
    mov     [eax+2], cx
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B8BD2:                             ; CODE XREF: sub_4B8B90+25j
    mov     dword ptr [eax+8], 0
    mov     eax, 1
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B8BE1:                             ; CODE XREF: sub_4B8B90+13j
    dec     edx
    mov     [eax+2], dx

    loc_4B8BE6:                             ; CODE XREF: sub_4B8B90+9j
    xor     eax, eax
    retn    4
    sub_4B8B90 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8BF0 proc near                    ; CODE XREF: sub_4AB5D0+20p

    arg_0= dword ptr  4
    arg_4= word ptr  8

    mov     eax, [esp+arg_0]
    mov     edx, [eax+8]
    test    edx, edx
    jz      short locret_4B8C52
    cmp     word ptr [edx], 1
    jbe     short locret_4B8C52
    mov     cx, [esp+arg_4]
    sub     [eax+2], cx
    cmp     word ptr [eax+2], 0
    jg      short locret_4B8C52

    loc_4B8C11:                             ; CODE XREF: sub_4B8BF0+56j
    inc     word ptr [eax]
    mov     cx, [eax]
    cmp     cx, [edx]
    jb      short loc_4B8C28
    mov     cl, [eax+4]
    test    cl, cl
    jz      short loc_4B8C4B
    mov     word ptr [eax], 0

    loc_4B8C28:                             ; CODE XREF: sub_4B8BF0+2Aj
    test    edx, edx
    jz      short loc_4B8C38
    xor     ecx, ecx
    mov     cx, [eax]
    mov     cx, [edx+ecx*8+2Ch]
    jmp     short loc_4B8C3D
    ; ---------------------------------------------------------------------------

    loc_4B8C38:                             ; CODE XREF: sub_4B8BF0+3Aj
    mov     ecx, 0FFFFh

    loc_4B8C3D:                             ; CODE XREF: sub_4B8BF0+46j
    add     [eax+2], cx
    cmp     word ptr [eax+2], 0
    jle     short loc_4B8C11
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B8C4B:                             ; CODE XREF: sub_4B8BF0+31j
    mov     dword ptr [eax+8], 0

    locret_4B8C52:                          ; CODE XREF: sub_4B8BF0+9j
                                            ; sub_4B8BF0+Fj ...
    retn    8
    sub_4B8BF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8C60 proc near                    ; CODE XREF: sub_4224B0+275p
                                            ; sub_429700+68p ...

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    sub     esp, 8
    push    edi
    push    0
    push    eax
    call    sub_4BBE50
    mov     edi, eax
    test    edi, edi
    jnz     short loc_4B8C7D
    pop     edi
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4B8C7D:                             ; CODE XREF: sub_4B8C60+14j
    cmp     word ptr [edi+4], 0
    mov     [esp+0Ch+var_8], 0
    jle     loc_4B8D2F
    push    esi
    lea     eax, [edi+0Ch]
    push    ebp
    push    ebx
    mov     [esp+18h+var_4], eax

    loc_4B8C9A:                             ; CODE XREF: sub_4B8C60+C6j
    mov     edx, [eax]
    mov     ebx, edi
    add     ebx, edx
    mov     [esp+18h+arg_0], 0
    mov     [eax], ebx
    cmp     word ptr [ebx], 0
    jbe     short loc_4B8D10
    lea     ebp, [ebx+28h]

    loc_4B8CB3:                             ; CODE XREF: sub_4B8C60+AAj
    mov     eax, [ebp+0]
    mov     ecx, edi
    add     ecx, eax
    mov     [ebp+0], ecx
    mov     esi, [ecx+10h]
    mov     al, [ecx+0Ah]
    add     esi, edi
    test    al, al
    mov     [ecx+10h], esi
    jbe     short loc_4B8CF7
    xor     edx, edx
    test    al, al
    jbe     short loc_4B8CF7

    loc_4B8CD2:                             ; CODE XREF: sub_4B8C60+95j
    mov     eax, [ecx+10h]
    lea     esi, [eax+edx*4]
    mov     eax, [eax+edx*4]
    add     eax, edi
    mov     [esi], eax
    mov     eax, [ecx+10h]
    mov     esi, [eax+edx*4]
    mov     eax, [esi+10h]
    add     eax, edi
    inc     edx
    mov     [esi+10h], eax
    xor     eax, eax
    mov     al, [ecx+0Ah]
    cmp     edx, eax
    jl      short loc_4B8CD2

    loc_4B8CF7:                             ; CODE XREF: sub_4B8C60+6Aj
                                            ; sub_4B8C60+70j
    mov     eax, [esp+18h+arg_0]
    xor     ecx, ecx
    mov     cx, [ebx]
    inc     eax
    add     ebp, 8
    cmp     eax, ecx
    mov     [esp+18h+arg_0], eax
    jl      short loc_4B8CB3
    mov     eax, [esp+18h+var_4]

    loc_4B8D10:                             ; CODE XREF: sub_4B8C60+4Ej
    mov     ecx, [esp+18h+var_8]
    add     eax, 4
    movsx   edx, word ptr [edi+4]
    inc     ecx
    mov     [esp+18h+var_4], eax
    cmp     ecx, edx
    mov     [esp+18h+var_8], ecx
    jl      loc_4B8C9A
    pop     ebx
    pop     ebp
    pop     esi

    loc_4B8D2F:                             ; CODE XREF: sub_4B8C60+2Aj
    mov     eax, edi
    pop     edi
    add     esp, 8
    retn    4
    sub_4B8C60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4B8D40(int,char *)
    sub_4B8D40 proc near                    ; CODE XREF: .text:004222CDp
                                            ; sub_4224B0+2E5p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    test    ebx, ebx
    push    edi
    jz      short loc_4B8D8C
    xor     edi, edi
    lea     esi, [ebx+0Ch]
    cmp     [ebx+4], di
    jle     short loc_4B8D8C
    mov     ebp, [esp+0Ch+arg_4]

    loc_4B8D5B:                             ; CODE XREF: sub_4B8D40+38j
    mov     eax, [esi]
    push    ebp                             ; char *
    add     eax, 8
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4B8D83
    movsx   ecx, word ptr [ebx+4]
    inc     edi
    add     esi, 4
    cmp     edi, ecx
    jl      short loc_4B8D5B
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B8D83:                             ; CODE XREF: sub_4B8D40+2Cj
    mov     eax, [esi]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4B8D8C:                             ; CODE XREF: sub_4B8D40+Aj
                                            ; sub_4B8D40+15j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    8
    sub_4B8D40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8DA0 proc near                    ; CODE XREF: sub_420D20+29p
                                            ; sub_4295B0+5Dp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    esi
    mov     esi, [esp+arg_8]
    push    edi
    mov     edi, [esp+4+arg_4]
    mov     eax, esi
    mov     ecx, [esp+4+arg_0]
    imul    eax, edi
    add     eax, 18h
    push    eax
    push    ecx
    call    sub_4D83B0
    xor     ecx, ecx
    add     esp, 8
    cmp     eax, ecx
    jnz     short loc_4B8DCD
    xor     eax, eax
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B8DCD:                             ; CODE XREF: sub_4B8DA0+24j
    mov     [eax], di
    lea     edx, [eax+18h]
    mov     [eax+2], si
    pop     edi
    mov     [eax+10h], edx
    mov     [eax+14h], ecx
    mov     [eax+4], cx
    mov     [eax+6], cx
    mov     [eax+9], cl
    mov     [eax+0Ah], cl
    mov     [eax+0Bh], cl
    pop     esi
    retn    0Ch
    sub_4B8DA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8E00 proc near                    ; CODE XREF: sub_458180+24p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    push    edi
    mov     edi, [esp+8+arg_8]
    mov     ecx, [esp+8+arg_0]
    mov     esi, edi
    imul    esi, ebx
    lea     eax, [esi+esi+18h]
    push    eax
    push    ecx
    call    sub_4D83B0
    lea     ecx, [eax+18h]
    add     esp, 8
    mov     [eax+10h], ecx
    add     ecx, esi
    mov     [eax+2], di
    mov     [eax+14h], ecx
    xor     ecx, ecx
    pop     edi
    mov     [eax], bx
    pop     esi
    mov     [eax+4], cx
    mov     [eax+6], cx
    mov     [eax+9], cl
    mov     [eax+0Ah], cl
    mov     [eax+0Bh], cl
    pop     ebx
    retn    0Ch
    sub_4B8E00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8E50 proc near                    ; CODE XREF: sub_495A30+1ECp

    arg_0= dword ptr  0Ch
    arg_4= byte ptr  10h

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     al, [esi+9]
    test    al, al
    jnz     short loc_4B8EB2
    xor     ecx, ecx
    xor     eax, eax
    mov     cx, [esi]
    mov     ax, [esi+2]
    imul    ecx, eax
    mov     al, [esp+4+arg_4]
    mov     edi, [esi+10h]
    mov     bl, al
    mov     edx, ecx
    mov     bh, bl
    mov     eax, ebx
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     edi, [esi+14h]
    test    edi, edi
    jz      short loc_4B8EB2
    xor     ecx, ecx
    xor     eax, eax
    mov     cx, [esi]
    mov     ax, [esi+2]
    imul    ecx, eax
    mov     edx, ecx
    xor     eax, eax
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb

    loc_4B8EB2:                             ; CODE XREF: sub_4B8E50+Cj
                                            ; sub_4B8E50+42j
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    sub_4B8E50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B8EC0 proc near                    ; CODE XREF: sub_420B00+C6p
                                            ; sub_4B8EC0+7Ap

    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 94h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     [esp+0A4h+var_94], eax
    mov     al, [eax+0F0h]
    and     al, 80h
    cmp     al, 80h
    jnz     loc_4B908E
    mov     ebp, [esp+0A4h+arg_0]
    xor     ebx, ebx
    cmp     ebp, ebx
    jnz     short loc_4B8F02
    lea     ecx, [esp+0A4h+var_30]
    push    ecx
    call    sub_4C5E70
    cmp     eax, ebx
    jz      short loc_4B8F02
    lea     ebp, [esp+0A4h+var_30]

    loc_4B8F02:                             ; CODE XREF: sub_4B8EC0+2Ej
                                            ; sub_4B8EC0+3Cj
    mov     esi, [esp+0A4h+arg_4]
    cmp     esi, ebx
    jz      loc_4B907C
    mov     al, [esi+0Ah]
    cmp     al, bl
    jbe     short loc_4B8F4E
    xor     edi, edi
    cmp     al, bl
    jbe     loc_4B907C
    mov     ebx, [esp+0A4h+arg_C]

    loc_4B8F29:                             ; CODE XREF: sub_4B8EC0+87j
    mov     eax, [esi+10h]
    mov     edx, [esp+0A4h+arg_8]
    push    ebx
    push    edx
    mov     ecx, [eax+edi*4]
    push    ecx
    push    ebp
    call    sub_4B8EC0
    xor     edx, edx
    inc     edi
    mov     dl, [esi+0Ah]
    cmp     edi, edx
    jl      short loc_4B8F29
    jmp     loc_4B907C
    ; ---------------------------------------------------------------------------

    loc_4B8F4E:                             ; CODE XREF: sub_4B8EC0+56j
    cmp     [esi+10h], ebx
    jz      loc_4B907C
    xor     eax, eax
    mov     [esp+0A4h+var_80], ebx
    mov     ax, [esi]
    mov     [esp+0A4h+var_7C], ebx
    movsx   edi, word ptr [esi+4]
    lea     ecx, [eax-1]
    mov     [esp+0A4h+var_78], ecx
    xor     ecx, ecx
    mov     cx, [esi+2]
    movsx   ebx, word ptr [esi+6]
    lea     edx, [ecx-1]
    mov     [esp+0A4h+var_74], edx
    mov     edx, [esp+0A4h+arg_8]
    sub     edx, edi
    mov     edi, [esp+0A4h+arg_C]
    sub     edi, ebx
    mov     [esp+0A4h+var_90], edx
    lea     eax, [edx+eax-1]
    lea     edx, [esp+0A4h+var_70]
    lea     ecx, [edi+ecx-1]
    push    edx
    mov     [esp+0A8h+var_84], ecx
    mov     ecx, ebp
    mov     [esp+0A8h+var_8C], edi
    mov     [esp+0A8h+var_88], eax
    call    sub_4C6AE0
    lea     eax, [esp+0A4h+var_70]
    lea     ecx, [esp+0A4h+var_90]
    push    eax
    lea     edx, [esp+0A8h+var_80]
    push    ecx
    push    edx
    call    sub_4B7E60
    mov     eax, [esp+0A4h+var_88]
    mov     ecx, [esp+0A4h+var_90]
    cmp     eax, ecx
    jl      loc_4B907C
    mov     ecx, [esp+0A4h+var_84]
    mov     eax, [esp+0A4h+var_8C]
    cmp     ecx, eax
    jl      loc_4B907C
    mov     edx, [esp+0A4h+var_78]
    mov     eax, [esp+0A4h+var_80]
    cmp     edx, eax
    jl      loc_4B907C
    mov     eax, [esp+0A4h+var_74]
    mov     ecx, [esp+0A4h+var_7C]
    cmp     eax, ecx
    jl      short loc_4B907C
    mov     al, [esi+9]
    test    al, al
    jnz     short loc_4B9053
    mov     edx, [esi+10h]
    xor     eax, eax
    mov     ax, [esi]
    xor     ecx, ecx
    mov     cx, [esi+2]
    mov     [esp+0A4h+var_60], eax
    mov     [esp+0A4h+var_58], eax
    mov     eax, [esp+0A4h+var_94]
    mov     [esp+0A4h+var_54], edx
    mov     [esp+0A4h+var_5C], ecx
    mov     ecx, [eax+0C8h]
    xor     edx, edx
    mov     dl, [esi+8]
    push    ecx
    lea     eax, [esp+0A8h+var_90]
    push    edx
    lea     ecx, [esp+0ACh+var_80]
    push    eax
    lea     edx, [esp+0B0h+var_60]
    push    ecx
    push    edx
    push    ebp
    call    sub_4CC332
    jmp     short loc_4B9079
    ; ---------------------------------------------------------------------------

    loc_4B9053:                             ; CODE XREF: sub_4B8EC0+14Bj
    mov     eax, [esp+0A4h+var_94]
    lea     edx, [esp+0A4h+var_80]
    mov     ecx, [eax+0C8h]
    mov     eax, [esi+10h]
    push    ecx
    push    edx
    mov     edx, [ebp+8]
    lea     ecx, [esp+0ACh+var_90]
    push    eax
    mov     eax, [ebp+0Ch]
    push    ecx
    push    edx
    push    eax
    call    sub_4CC1BF

    loc_4B9079:                             ; CODE XREF: sub_4B8EC0+191j
    add     esp, 18h

    loc_4B907C:                             ; CODE XREF: sub_4B8EC0+4Bj
                                            ; sub_4B8EC0+5Cj ...
    lea     ecx, [esp+0A4h+var_30]
    cmp     ebp, ecx
    jnz     short loc_4B908E
    lea     edx, [esp+0A4h+var_30]
    push    edx
    call    sub_4C5FA0

    loc_4B908E:                             ; CODE XREF: sub_4B8EC0+1Dj
                                            ; sub_4B8EC0+1C2j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 94h
    retn    10h
    sub_4B8EC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B90A0 proc near                    ; CODE XREF: sub_459200+4D8p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 8
    mov     edx, [esp+8+arg_4]
    push    ebx
    push    ebp
    mov     ebp, [esp+10h+arg_0]
    movsx   ebx, word ptr [edx+4]
    movsx   eax, word ptr [ebp+4]
    movsx   ecx, word ptr [ebp+6]
    sub     ebx, eax
    mov     eax, [esp+10h+arg_8]
    add     ebx, eax
    push    esi
    movsx   eax, word ptr [edx+6]
    mov     esi, [esp+14h+arg_C]
    sub     eax, ecx
    add     eax, esi
    push    edi
    test    ebx, ebx
    mov     [esp+18h+var_8], ebx
    jl      loc_4B919A
    test    eax, eax
    jl      loc_4B919A
    mov     ecx, [ebp+10h]
    cmp     word ptr [ebp+2], 0
    mov     edi, [ebp+14h]
    mov     [esp+18h+arg_0], ecx
    mov     [esp+18h+arg_C], 0
    jbe     loc_4B919A
    mov     [esp+18h+var_4], eax

    loc_4B9104:                             ; CODE XREF: sub_4B90A0+F4j
    xor     ecx, ecx
    mov     esi, ebx
    mov     cx, [edx]
    imul    ecx, eax
    mov     eax, [edx+10h]
    add     esi, eax
    mov     eax, ebx
    mov     ebx, [edx+14h]
    add     esi, ecx
    add     eax, ebx
    add     eax, ecx
    xor     ecx, ecx
    mov     cx, [ebp+0]
    mov     ebx, ecx
    dec     ecx
    test    ebx, ebx
    jz      short loc_4B9176
    inc     ecx
    mov     [esp+18h+arg_8], ecx

    loc_4B9130:                             ; CODE XREF: sub_4B90A0+D0j
    mov     edx, [esp+18h+arg_0]
    mov     cl, [edx]
    mov     dl, [ebp+8]
    cmp     cl, dl
    jz      short loc_4B915B
    mov     ebx, [esp+18h+arg_10]
    xor     edx, edx
    mov     dl, [edi]
    add     edx, ebx
    xor     ebx, ebx
    mov     bl, [eax]
    cmp     ebx, edx
    jg      short loc_4B915B
    mov     dl, byte ptr [esp+18h+arg_10]
    mov     [esi], cl
    mov     cl, [edi]
    add     cl, dl
    mov     [eax], cl

    loc_4B915B:                             ; CODE XREF: sub_4B90A0+9Bj
                                            ; sub_4B90A0+ADj
    mov     ecx, [esp+18h+arg_0]
    inc     esi
    inc     ecx
    inc     eax
    mov     [esp+18h+arg_0], ecx
    mov     ecx, [esp+18h+arg_8]
    inc     edi
    dec     ecx
    mov     [esp+18h+arg_8], ecx
    jnz     short loc_4B9130
    mov     edx, [esp+18h+arg_4]

    loc_4B9176:                             ; CODE XREF: sub_4B90A0+89j
    mov     ecx, [esp+18h+arg_C]
    mov     eax, [esp+18h+var_4]
    mov     ebx, [esp+18h+var_8]
    xor     esi, esi
    mov     si, [ebp+2]
    inc     ecx
    inc     eax
    cmp     ecx, esi
    mov     [esp+18h+arg_C], ecx
    mov     [esp+18h+var_4], eax
    jl      loc_4B9104

    loc_4B919A:                             ; CODE XREF: sub_4B90A0+35j
                                            ; sub_4B90A0+3Dj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    14h
    sub_4B90A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B91B0 proc near                    ; CODE XREF: sub_420620+1Ap

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= qword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 24h
    push    ebx
    push    ebp
    mov     ebp, [esp+2Ch+arg_0]
    push    esi
    mov     esi, [esp+30h+arg_4]
    push    edi
    lea     edi, [ebp+ebp+0]
    mov     ebx, edi
    imul    ebx, esi
    fild    [esp+34h+arg_8]
    fstp    [esp+34h+var_8]
    lea     eax, [ebx+ebx+18h]
    push    eax
    push    offset aLensframe               ; "LensFrame"
    call    sub_4D83B0
    mov     ecx, eax
    add     esp, 8
    mov     [esp+34h+arg_0], ecx
    lea     eax, [ecx+18h]
    mov     [ecx], di
    mov     [ecx+10h], eax
    add     eax, ebx
    mov     [ecx+14h], eax
    xor     eax, eax
    cmp     ecx, eax
    mov     [ecx+2], si
    mov     [ecx+4], ax
    mov     [ecx+6], ax
    mov     [ecx+9], al
    mov     [ecx+0Ah], al
    mov     [ecx+0Bh], al
    jnz     short loc_4B921B
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4B921B:                             ; CODE XREF: sub_4B91B0+5Fj
    mov     eax, ebp
    cdq
    sub     eax, edx
    mov     ebx, eax
    mov     eax, esi
    cdq
    sub     eax, edx
    mov     edx, eax
    xor     eax, eax
    shr     di, 1
    sar     ebx, 1
    sar     edx, 1
    test    esi, esi
    mov     [ecx], di
    mov     [esp+34h+arg_8], ebx
    mov     [ecx+4], bx
    mov     [esp+34h+var_24], edx
    mov     [ecx+6], dx
    mov     [esp+34h+var_20], eax
    jle     loc_4B934B
    fld     [esp+34h+var_8]
    xor     esi, esi
    mov     [esp+34h+var_1C], esi

    loc_4B925B:                             ; CODE XREF: sub_4B91B0+193j
    xor     edi, edi
    test    ebp, ebp
    jle     loc_4B9332
    movsx   ecx, dx
    sub     eax, ecx
    mov     ecx, eax
    mov     [esp+34h+var_C], eax
    imul    ecx, eax
    mov     eax, ebp
    mov     [esp+34h+var_18], ecx
    cdq
    and     edx, 3
    add     eax, edx
    sar     eax, 2
    movsx   ebx, bx
    mov     [esp+34h+var_10], eax
    jmp     short loc_4B928F
    ; ---------------------------------------------------------------------------

    loc_4B928B:                             ; CODE XREF: sub_4B91B0+16Cj
    mov     ecx, [esp+34h+var_18]

    loc_4B928F:                             ; CODE XREF: sub_4B91B0+D9j
    mov     eax, edi
    sub     eax, ebx
    mov     edx, eax
    mov     dword ptr [esp+34h+var_8], eax
    imul    edx, eax
    add     edx, ecx
    mov     [esp+34h+var_14], edx
    fild    [esp+34h+var_14]
    fsqrt
    fld     st
    call    __ftol
    cmp     eax, [esp+34h+var_10]
    jl      short loc_4B92C9
    mov     edx, [esp+34h+arg_0]
    lea     ecx, [edi+esi]
    fstp    st
    lea     eax, [edx+18h]
    mov     word ptr [eax+ecx*2], 7D00h
    jmp     short loc_4B9319
    ; ---------------------------------------------------------------------------

    loc_4B92C9:                             ; CODE XREF: sub_4B91B0+103j
    fisubr  [esp+34h+arg_8]
    add     esi, edi
    fdiv    st, st(1)
    fild    [esp+34h+var_C]
    fdiv    st, st(1)
    call    __ftol
    fild    dword ptr [esp+34h+var_8]
    mov     ebx, eax
    movsx   eax, word ptr [esp+34h+var_24]
    fdiv    st, st(1)
    add     ebx, eax
    imul    ebx, ebp
    call    __ftol
    mov     dword ptr [esp+34h+var_8], ebx
    movsx   ebx, word ptr [esp+34h+arg_8]
    fstp    st
    mov     edx, dword ptr [esp+34h+var_8]
    mov     ecx, ebx
    add     ecx, edx
    add     eax, ecx
    mov     ecx, [esp+34h+arg_0]
    sub     eax, esi
    add     ecx, 18h
    mov     [ecx+esi*2], ax
    mov     esi, [esp+34h+var_1C]

    loc_4B9319:                             ; CODE XREF: sub_4B91B0+117j
    inc     edi
    cmp     edi, ebp
    jl      loc_4B928B
    mov     ebx, [esp+34h+arg_8]
    mov     edx, [esp+34h+var_24]
    mov     eax, [esp+34h+var_20]
    mov     ecx, [esp+34h+arg_0]

    loc_4B9332:                             ; CODE XREF: sub_4B91B0+AFj
    mov     edi, [esp+34h+arg_4]
    inc     eax
    add     esi, ebp
    cmp     eax, edi
    mov     [esp+34h+var_20], eax
    mov     [esp+34h+var_1C], esi
    jl      loc_4B925B
    fstp    st

    loc_4B934B:                             ; CODE XREF: sub_4B91B0+9Bj
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, ecx
    pop     ebx
    add     esp, 24h
    retn    0Ch
    sub_4B91B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B9360 proc near                    ; CODE XREF: sub_49BE60+388p

    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= word ptr -18h
    var_16= word ptr -16h
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 50h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+5Ch+arg_4]
    xor     edx, edx
    push    edi
    mov     ecx, [esi+14h]
    mov     eax, [esi+10h]
    mov     [esi+10h], ecx
    mov     [esi+14h], eax
    xor     eax, eax
    mov     dx, [esi+2]
    mov     ax, [esi]
    mov     cx, [esi+4]
    mov     [esp+60h+var_30], eax
    mov     [esp+60h+var_28], eax
    mov     eax, [esi+10h]
    mov     [esp+60h+var_2C], edx
    mov     [esp+60h+var_24], eax
    mov     eax, [esp+60h+var_4]
    mov     dx, [esi+6]
    or      al, 1
    and     al, 0FDh
    mov     [esp+60h+var_20], 2710h
    mov     [esp+60h+var_4], eax
    lea     eax, [esp+60h+var_30]
    push    eax
    mov     [esp+64h+var_1C], 0FFFFFFFFh
    mov     [esp+64h+var_18], cx
    mov     [esp+64h+var_16], dx
    call    sub_4C69C0
    xor     ebx, ebx
    mov     ecx, [esp+60h+var_30]
    mov     ebp, [esp+60h+arg_8]
    mov     edi, ebp
    mov     [esp+60h+var_50], ebx
    lea     edx, [ecx-1]
    add     ecx, ebp
    mov     [esp+60h+var_48], edx
    mov     edx, [esp+60h+var_2C]
    mov     [esp+60h+var_4C], ebx
    lea     eax, [edx-1]
    mov     [esp+60h+var_44], eax
    movsx   eax, word ptr [esi+4]
    sub     ecx, eax
    sub     edi, eax
    movsx   eax, word ptr [esi+6]
    dec     ecx
    mov     [esp+60h+var_40], edi
    mov     [esp+60h+var_38], ecx
    mov     ecx, [esp+60h+arg_C]
    add     edx, ecx
    mov     edi, ecx
    sub     edx, eax
    sub     edi, eax
    mov     eax, [esp+60h+arg_0]
    dec     edx
    mov     [esp+60h+var_34], edx
    lea     ecx, [esp+60h+var_50]
    lea     edx, [esp+60h+var_40]
    push    ecx
    push    edx
    lea     ecx, [esp+68h+var_30]
    push    eax
    push    ecx
    mov     [esp+70h+var_3C], edi
    call    sub_4C6D20
    mov     edx, [esi+14h]
    mov     eax, [esi+10h]
    mov     [esi+10h], edx
    mov     [esi+14h], eax
    xor     eax, eax
    xor     ecx, ecx
    mov     ax, [esi]
    mov     cx, [esi+2]
    imul    eax, ecx
    mov     ecx, [esi+14h]
    mov     edi, [esi+10h]
    cmp     eax, ebx
    lea     edx, [ecx+eax]
    jz      short loc_4B947E

    loc_4B945F:                             ; CODE XREF: sub_4B9360+11Cj
    mov     bx, [edi]
    cmp     bx, 7D00h
    jz      short loc_4B9471
    movsx   ebx, bx
    mov     bl, [ecx+ebx]
    jmp     short loc_4B9474
    ; ---------------------------------------------------------------------------

    loc_4B9471:                             ; CODE XREF: sub_4B9360+107j
    mov     bl, [esi+8]

    loc_4B9474:                             ; CODE XREF: sub_4B9360+10Fj
    mov     [edx], bl
    inc     edx
    inc     ecx
    add     edi, 2
    dec     eax
    jnz     short loc_4B945F

    loc_4B947E:                             ; CODE XREF: sub_4B9360+FDj
    xor     edx, edx
    xor     eax, eax
    mov     dx, [esi]
    mov     ax, [esi+2]
    imul    edx, eax
    mov     eax, [esi+14h]
    mov     ecx, [esp+60h+arg_C]
    mov     edi, [esi+10h]
    add     edx, eax
    mov     [esi+10h], edx
    mov     edx, [esp+60h+arg_0]
    push    ecx
    push    ebp
    push    esi
    push    edx
    call    sub_4B7F90
    mov     [esi+10h], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 50h
    retn    10h
    sub_4B9360 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 50h
    push    ebx
    push    esi
    mov     esi, [esp+60h]
    xor     eax, eax
    xor     ecx, ecx
    push    edi
    mov     ax, [esi]
    mov     edx, [esi+10h]
    mov     cx, [esi+2]
    mov     [esp+2Ch], eax
    mov     [esp+34h], eax
    mov     ax, [esi+4]
    mov     [esp+44h], ax
    mov     eax, [esp+58h]
    mov     [esp+38h], edx
    or      al, 1
    mov     [esp+30h], ecx
    mov     cx, [esi+6]
    lea     edx, [esp+2Ch]
    and     al, 0FDh
    push    edx
    mov     dword ptr [esp+40h], 2710h
    mov     dword ptr [esp+44h], 0FFFFFFFFh
    mov     [esp+4Ah], cx
    mov     [esp+5Ch], eax
    call    sub_4C69C0
    xor     eax, eax
    mov     ecx, [esp+2Ch]
    mov     edi, [esp+68h]
    mov     [esp+0Ch], eax
    mov     [esp+10h], eax
    lea     edx, [ecx-1]
    add     ecx, edi
    mov     [esp+14h], edx
    mov     edx, [esp+30h]
    mov     ebx, edi
    lea     eax, [edx-1]
    mov     [esp+18h], eax
    movsx   eax, word ptr [esi+4]
    sub     ecx, eax
    sub     ebx, eax
    movsx   eax, word ptr [esi+6]
    dec     ecx
    mov     [esp+1Ch], ebx
    mov     [esp+24h], ecx
    mov     ecx, [esp+6Ch]
    add     edx, ecx
    mov     esi, ecx
    sub     edx, eax
    sub     esi, eax
    mov     eax, [esp+60h]
    dec     edx
    mov     [esp+28h], edx
    lea     ecx, [esp+0Ch]
    lea     edx, [esp+1Ch]
    push    ecx
    push    edx
    lea     ecx, [esp+34h]
    push    eax
    push    ecx
    mov     [esp+30h], esi
    call    sub_4C6D20
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 50h
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B95A0 proc near                    ; CODE XREF: sub_459830+3DCp
                                            ; sub_459C70+7ABp ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    ebx
    call    sub_4B6220
    mov     [esp+14h+var_8], eax
    mov     eax, [esp+14h+arg_4]
    xor     ebx, ebx
    cmp     [eax+2], bx
    mov     [esp+14h+var_C], ebx
    jbe     loc_4B9695
    mov     ecx, [esp+14h+arg_0]
    push    edi
    push    esi
    push    ebp
    mov     [esp+20h+var_10], 1

    loc_4B95D0:                             ; CODE XREF: sub_4B95A0+ECj
    xor     ebp, ebp
    xor     edx, edx
    mov     bp, [eax]
    test    ebp, ebp
    jle     loc_4B9674

    loc_4B95DF:                             ; CODE XREF: sub_4B95A0+CEj
    xor     esi, esi
    mov     edi, [ecx+10h]
    mov     si, [ecx]
    mov     ecx, [esp+20h+var_8]
    imul    ebx, esi
    add     ebx, edx
    mov     ecx, [ecx+0C0h]
    lea     eax, [edi+ebx*2]
    mov     ebx, [esp+20h+var_10]
    imul    ebx, esi
    add     edi, ebx
    xor     ebx, ebx
    mov     bl, [eax]
    mov     esi, ebx
    xor     ebx, ebx
    mov     bl, [eax+1]
    mov     eax, ecx
    shl     esi, 8
    mov     [esp+20h+var_4], ebx
    add     eax, esi
    mov     esi, [esp+20h+var_4]
    xor     ebx, ebx
    lea     edi, [edi+edx*2]
    mov     bl, [esi+eax]
    xor     eax, eax
    mov     al, [edi+1]
    mov     esi, eax
    xor     eax, eax
    mov     al, [edi]
    mov     edi, ecx
    shl     ebx, 8
    shl     eax, 8
    add     edi, esi
    mov     [esp+20h+var_4], ebx
    xor     ebx, ebx
    mov     bl, [eax+edi]
    mov     eax, [esp+20h+var_4]
    mov     esi, ebx
    mov     ebx, [esp+20h+var_C]
    mov     edi, ebx
    add     ecx, eax
    imul    edi, ebp
    mov     eax, [esp+20h+arg_4]
    mov     cl, [esi+ecx]
    add     edi, edx
    inc     edx
    mov     ebp, [eax+10h]
    mov     [edi+ebp], cl
    mov     ecx, [esp+20h+arg_0]
    xor     ebp, ebp
    mov     bp, [eax]
    cmp     edx, ebp
    jl      loc_4B95DF

    loc_4B9674:                             ; CODE XREF: sub_4B95A0+39j
    mov     edi, [esp+20h+var_10]
    xor     edx, edx
    mov     dx, [eax+2]
    inc     ebx
    add     edi, 2
    cmp     ebx, edx
    mov     [esp+20h+var_C], ebx
    mov     [esp+20h+var_10], edi
    jl      loc_4B95D0
    pop     ebp
    pop     esi
    pop     edi

    loc_4B9695:                             ; CODE XREF: sub_4B95A0+1Bj
    pop     ebx
    add     esp, 10h
    retn    8
    sub_4B95A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B96A0 proc near                    ; CODE XREF: sub_45A470+8Ep

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    xor     ecx, ecx
    xor     eax, eax
    push    esi
    mov     cx, [edx+2]
    mov     ax, [edx]
    imul    ecx, eax
    mov     eax, [edx+10h]
    mov     esi, ecx
    dec     ecx
    test    esi, esi
    jz      short loc_4B96D2
    push    ebx
    lea     esi, [ecx+1]

    loc_4B96C1:                             ; CODE XREF: sub_4B96A0+2Fj
    mov     cl, [eax]
    mov     bl, [edx+8]
    cmp     cl, bl
    jz      short loc_4B96CD
    mov     byte ptr [eax], 0

    loc_4B96CD:                             ; CODE XREF: sub_4B96A0+28j
    inc     eax
    dec     esi
    jnz     short loc_4B96C1
    pop     ebx

    loc_4B96D2:                             ; CODE XREF: sub_4B96A0+1Bj
    pop     esi
    retn    4
    sub_4B96A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B96E0 proc near                    ; CODE XREF: sub_459200+550p

    arg_0= dword ptr  8
    arg_4= byte ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    mov     esi, [ebx+10h]
    mov     ebp, [ebx+14h]
    push    edi
    xor     edi, edi
    mov     di, [ebx+2]
    xor     eax, eax
    mov     ax, [ebx]
    imul    edi, eax
    call    sub_4B6220
    mov     ecx, edi
    dec     edi
    test    ecx, ecx
    jz      short loc_4B9733
    inc     edi

    loc_4B9709:                             ; CODE XREF: sub_4B96E0+51j
    mov     dl, [ebp+0]
    mov     cl, [esp+0Ch+arg_4]
    cmp     dl, cl
    ja      short loc_4B972E
    mov     cl, [esi]
    mov     dl, [ebx+8]
    cmp     cl, dl
    jz      short loc_4B972E
    mov     edx, [eax+0D0h]
    and     ecx, 0FFh
    mov     cl, [edx+ecx]
    mov     [esi], cl

    loc_4B972E:                             ; CODE XREF: sub_4B96E0+32j
                                            ; sub_4B96E0+3Bj
    inc     esi
    inc     ebp
    dec     edi
    jnz     short loc_4B9709

    loc_4B9733:                             ; CODE XREF: sub_4B96E0+26j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4B96E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B9740 proc near                    ; CODE XREF: sub_4B9740+86p
                                            ; sub_4B9A50+8Cp

    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= qword ptr  14h
    arg_18= qword ptr  1Ch

    sub     esp, 78h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     edi, [esp+88h+arg_0]
    mov     [esp+88h+var_68], eax
    test    edi, edi
    jnz     short loc_4B9776
    lea     eax, [esp+88h+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      short loc_4B9776
    lea     ecx, [esp+88h+var_30]
    mov     [esp+88h+arg_0], ecx
    mov     edi, ecx

    loc_4B9776:                             ; CODE XREF: sub_4B9740+19j
                                            ; sub_4B9740+27j
    mov     ebx, [esp+88h+arg_4]
    mov     al, [ebx+0Ah]
    test    al, al
    jbe     short loc_4B97DA
    xor     esi, esi
    test    al, al
    jbe     loc_4B9A2E
    mov     ebp, dword ptr [esp+88h+arg_18+4]

    loc_4B9795:                             ; CODE XREF: sub_4B9740+93j
    mov     edx, dword ptr [esp+88h+arg_18]
    mov     eax, dword ptr [esp+88h+arg_10+4]
    mov     ecx, dword ptr [esp+88h+arg_10]
    push    ebp
    push    edx
    mov     edx, [esp+90h+arg_C]
    push    eax
    mov     eax, [esp+94h+arg_8]
    push    ecx
    mov     ecx, [ebx+10h]
    push    edx
    push    eax
    mov     edx, [ecx+esi*4]
    push    edx
    push    edi
    call    sub_4B9740
    xor     eax, eax
    inc     esi
    mov     al, [ebx+0Ah]
    cmp     esi, eax
    jl      short loc_4B9795
    jmp     loc_4B9A2E
    ; ---------------------------------------------------------------------------

    loc_4B97DA:                             ; CODE XREF: sub_4B9740+42j
    xor     eax, eax
    mov     ax, [ebx]
    mov     [esp+88h+var_78], eax
    fild    [esp+88h+var_78]
    fmul    [esp+88h+arg_10]
    call    __ftol
    mov     ebp, eax
    xor     eax, eax
    mov     ax, [ebx+2]
    mov     [esp+88h+var_74], eax
    fild    [esp+88h+var_74]
    fmul    [esp+88h+arg_18]
    call    __ftol
    movsx   ecx, word ptr [ebx+4]
    mov     [esp+88h+var_70], ecx
    mov     esi, eax
    fild    [esp+88h+var_70]
    fmul    [esp+88h+arg_10]
    call    __ftol
    movsx   edx, word ptr [ebx+6]
    mov     [esp+88h+var_70], edx
    mov     [esp+88h+var_6C], eax
    fild    [esp+88h+var_70]
    fmul    [esp+88h+arg_18]
    call    __ftol
    test    ebp, ebp
    jle     loc_4B9A2E
    test    esi, esi
    jle     loc_4B9A2E
    mov     ecx, [esp+88h+arg_8]
    mov     edx, [esp+88h+var_6C]
    sub     ecx, edx
    mov     edx, [esp+88h+arg_C]
    sub     edx, eax
    mov     [esp+88h+var_50], ecx
    lea     eax, [ebp+ecx-1]
    mov     [esp+88h+var_4C], edx
    mov     [esp+88h+var_48], eax
    xor     eax, eax
    mov     [esp+88h+var_60], eax
    mov     [esp+88h+var_5C], eax
    lea     eax, [esi-1]
    lea     ecx, [esi+edx-1]
    mov     [esp+88h+var_54], eax
    mov     eax, [esp+88h+var_78]
    lea     edx, [ebp-1]
    mov     [esp+88h+var_44], ecx
    shl     eax, 10h
    mov     [esp+88h+var_58], edx
    lea     ecx, [esp+88h+var_40]
    cdq
    idiv    ebp
    push    ecx
    mov     ecx, edi
    mov     [esp+8Ch+var_70], eax
    mov     eax, [esp+8Ch+var_74]
    shl     eax, 10h
    cdq
    idiv    esi
    mov     [esp+8Ch+var_64], eax
    call    sub_4C6AE0
    lea     edx, [esp+88h+var_40]
    lea     eax, [esp+88h+var_50]
    push    edx
    lea     ecx, [esp+8Ch+var_60]
    push    eax
    push    ecx
    call    sub_4B7E60
    mov     edx, [esp+88h+var_50]
    mov     eax, [esp+88h+var_48]
    cmp     eax, edx
    jl      loc_4B9A2E
    mov     ebp, [esp+88h+var_4C]
    mov     eax, [esp+88h+var_44]
    cmp     eax, ebp
    jl      loc_4B9A2E
    mov     eax, [esp+88h+var_58]
    mov     ecx, [esp+88h+var_60]
    cmp     eax, ecx
    jl      loc_4B9A2E
    mov     ecx, [esp+88h+var_54]
    mov     eax, [esp+88h+var_5C]
    cmp     ecx, eax
    jl      loc_4B9A2E
    fild    [esp+88h+var_60]
    fdiv    [esp+88h+arg_10]
    call    __ftol
    fild    [esp+88h+var_5C]
    mov     [esp+88h+var_60], eax
    fdiv    [esp+88h+arg_18]
    call    __ftol
    fild    [esp+88h+var_58]
    mov     esi, eax
    mov     [esp+88h+var_5C], esi
    fdiv    [esp+88h+arg_10]
    call    __ftol
    fild    [esp+88h+var_54]
    mov     [esp+88h+var_58], eax
    fdiv    [esp+88h+arg_18]
    call    __ftol
    mov     [esp+88h+var_54], eax
    mov     eax, [esp+88h+var_44]
    mov     ecx, ebp
    shl     esi, 10h
    cmp     ebp, eax
    mov     [esp+88h+var_74], ecx
    mov     [esp+88h+var_78], esi
    jg      loc_4B9A2E

    loc_4B9982:                             ; CODE XREF: sub_4B9740+2E8j
    imul    ecx, [edi+8]
    mov     edi, [esp+88h+var_60]
    mov     eax, [esp+88h+var_48]
    mov     ebp, esi
    mov     esi, [esp+88h+var_50]
    xor     edx, edx
    mov     dx, [ebx]
    sar     ebp, 10h
    imul    ebp, edx
    mov     edx, esi
    shl     edi, 10h
    cmp     edx, eax
    jg      short loc_4B9A04

    loc_4B99A8:                             ; CODE XREF: sub_4B9740+2C2j
    mov     eax, [ebx+10h]
    mov     edx, edi
    sar     edx, 10h
    add     edx, ebp
    mov     al, [edx+eax]
    mov     dl, [ebx+8]
    cmp     al, dl
    mov     byte ptr [esp+88h+var_6C], al
    jz      short loc_4B99F5
    mov     edx, [esp+88h+arg_0]
    mov     ebx, [esp+88h+var_68]
    mov     eax, [edx+0Ch]
    mov     edx, [esp+88h+var_6C]
    and     edx, 0FFh
    add     eax, ecx
    shl     edx, 8
    add     edx, [ebx+0C0h]
    add     eax, esi
    xor     ebx, ebx
    mov     bl, [eax]
    mov     dl, [edx+ebx]
    mov     ebx, [esp+88h+arg_4]
    mov     [eax], dl

    loc_4B99F5:                             ; CODE XREF: sub_4B9740+27Ej
    mov     edx, [esp+88h+var_70]
    mov     eax, [esp+88h+var_48]
    inc     esi
    add     edi, edx
    cmp     esi, eax
    jle     short loc_4B99A8

    loc_4B9A04:                             ; CODE XREF: sub_4B9740+266j
    mov     ecx, [esp+88h+var_74]
    mov     esi, [esp+88h+var_78]
    mov     edx, [esp+88h+var_64]
    mov     eax, [esp+88h+var_44]
    mov     edi, [esp+88h+arg_0]
    inc     ecx
    add     esi, edx
    cmp     ecx, eax
    mov     [esp+88h+var_74], ecx
    mov     [esp+88h+var_78], esi
    jle     loc_4B9982

    loc_4B9A2E:                             ; CODE XREF: sub_4B9740+48j
                                            ; sub_4B9740+95j ...
    lea     eax, [esp+88h+var_30]
    cmp     edi, eax
    jnz     short loc_4B9A40
    lea     ecx, [esp+88h+var_30]
    push    ecx
    call    sub_4C5FA0

    loc_4B9A40:                             ; CODE XREF: sub_4B9740+2F4j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 78h
    retn    20h
    sub_4B9740 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B9A50 proc near                    ; CODE XREF: sub_4B9A50+93p

    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= qword ptr  14h
    arg_18= qword ptr  1Ch

    sub     esp, 6Ch
    push    ebx
    push    ebp
    mov     ebp, [esp+74h+arg_0]
    push    esi
    test    ebp, ebp
    push    edi
    jnz     short loc_4B9A71
    lea     eax, [esp+7Ch+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      short loc_4B9A71
    lea     ebp, [esp+7Ch+var_30]

    loc_4B9A71:                             ; CODE XREF: sub_4B9A50+Dj
                                            ; sub_4B9A50+1Bj
    mov     ebx, [esp+7Ch+arg_4]
    mov     al, [ebx+0Ah]
    test    al, al
    jbe     loc_4B9B05
    test    al, al
    mov     [esp+7Ch+arg_4], 0
    jbe     loc_4B9D53
    mov     esi, dword ptr [esp+7Ch+arg_18+4]
    mov     edi, dword ptr [esp+7Ch+arg_18]

    loc_4B9AA4:                             ; CODE XREF: sub_4B9A50+AEj
    mov     ecx, [ebx+10h]
    mov     edx, [esp+7Ch+arg_4]
    push    esi
    push    edi
    mov     eax, [ecx+edx*4]
    mov     edx, dword ptr [esp+84h+arg_10]
    mov     cl, [eax+0Bh]
    test    cl, cl
    mov     ecx, dword ptr [esp+84h+arg_10+4]
    push    ecx
    mov     ecx, [esp+88h+arg_C]
    push    edx
    mov     edx, [esp+8Ch+arg_8]
    push    ecx
    push    edx
    push    eax
    push    ebp
    jbe     short loc_4B9AE3
    call    sub_4B9740
    jmp     short loc_4B9AE8
    ; ---------------------------------------------------------------------------

    loc_4B9AE3:                             ; CODE XREF: sub_4B9A50+8Aj
    call    sub_4B9A50

    loc_4B9AE8:                             ; CODE XREF: sub_4B9A50+91j
    mov     eax, [esp+7Ch+arg_4]
    xor     ecx, ecx
    mov     cl, [ebx+0Ah]
    inc     eax
    cmp     eax, ecx
    mov     [esp+7Ch+arg_4], eax
    jl      short loc_4B9AA4
    jmp     loc_4B9D53
    ; ---------------------------------------------------------------------------

    loc_4B9B05:                             ; CODE XREF: sub_4B9A50+2Dj
    xor     eax, eax
    mov     ax, [ebx]
    mov     [esp+7Ch+arg_0], eax
    fild    [esp+7Ch+arg_0]
    fmul    [esp+7Ch+arg_10]
    call    __ftol
    mov     esi, eax
    xor     eax, eax
    mov     ax, [ebx+2]
    mov     [esp+7Ch+var_6C], eax
    fild    [esp+7Ch+var_6C]
    fmul    [esp+7Ch+arg_18]
    call    __ftol
    movsx   edx, word ptr [ebx+4]
    mov     [esp+7Ch+var_68], edx
    mov     edi, eax
    fild    [esp+7Ch+var_68]
    fmul    [esp+7Ch+arg_10]
    call    __ftol
    mov     [esp+7Ch+var_64], eax
    movsx   eax, word ptr [ebx+6]
    mov     [esp+7Ch+var_68], eax
    fild    [esp+7Ch+var_68]
    fmul    [esp+7Ch+arg_18]
    call    __ftol
    test    esi, esi
    jle     loc_4B9D53
    test    edi, edi
    jle     loc_4B9D53
    mov     ecx, [esp+7Ch+arg_8]
    mov     edx, [esp+7Ch+var_64]
    sub     ecx, edx
    mov     edx, [esp+7Ch+arg_C]
    sub     edx, eax
    xor     eax, eax
    mov     [esp+7Ch+var_60], eax
    mov     [esp+7Ch+var_5C], eax
    lea     eax, [esi-1]
    mov     [esp+7Ch+var_4C], edx
    mov     [esp+7Ch+var_58], eax
    mov     eax, [esp+7Ch+arg_0]
    lea     edx, [edi+edx-1]
    mov     [esp+7Ch+var_50], ecx
    shl     eax, 10h
    mov     [esp+7Ch+var_44], edx
    lea     ecx, [esi+ecx-1]
    cdq
    idiv    esi
    mov     [esp+7Ch+var_48], ecx
    lea     ecx, [edi-1]
    mov     [esp+7Ch+var_54], ecx
    mov     ecx, ebp
    mov     [esp+7Ch+arg_0], eax
    mov     eax, [esp+7Ch+var_6C]
    shl     eax, 10h
    cdq
    idiv    edi
    lea     edx, [esp+7Ch+var_40]
    push    edx
    mov     [esp+80h+var_64], eax
    call    sub_4C6AE0
    lea     eax, [esp+7Ch+var_40]
    lea     ecx, [esp+7Ch+var_50]
    push    eax
    lea     edx, [esp+80h+var_60]
    push    ecx
    push    edx
    call    sub_4B7E60
    mov     eax, [esp+7Ch+var_50]
    mov     ecx, [esp+7Ch+var_48]
    cmp     ecx, eax
    jl      loc_4B9D53
    mov     edi, [esp+7Ch+var_4C]
    mov     eax, [esp+7Ch+var_44]
    cmp     eax, edi
    jl      loc_4B9D53
    mov     ecx, [esp+7Ch+var_58]
    mov     eax, [esp+7Ch+var_60]
    cmp     ecx, eax
    jl      loc_4B9D53
    mov     edx, [esp+7Ch+var_54]
    mov     eax, [esp+7Ch+var_5C]
    cmp     edx, eax
    jl      loc_4B9D53
    fild    [esp+7Ch+var_60]
    fdiv    [esp+7Ch+arg_10]
    call    __ftol
    fild    [esp+7Ch+var_5C]
    mov     [esp+7Ch+var_60], eax
    fdiv    [esp+7Ch+arg_18]
    call    __ftol
    fild    [esp+7Ch+var_58]
    mov     esi, eax
    mov     [esp+7Ch+var_5C], esi
    fdiv    [esp+7Ch+arg_10]
    call    __ftol
    fild    [esp+7Ch+var_54]
    mov     [esp+7Ch+var_58], eax
    fdiv    [esp+7Ch+arg_18]
    call    __ftol
    mov     [esp+7Ch+var_54], eax
    mov     eax, [esp+7Ch+var_44]
    mov     edx, edi
    shl     esi, 10h
    cmp     edi, eax
    mov     [esp+7Ch+arg_8], edx
    mov     [esp+7Ch+arg_C], esi
    jg      loc_4B9D53

    loc_4B9CBF:                             ; CODE XREF: sub_4B9A50+2FDj
    mov     edi, [esp+7Ch+var_50]
    xor     eax, eax
    mov     ax, [ebx]
    mov     ebx, [esp+7Ch+var_48]
    sar     esi, 10h
    imul    esi, eax
    mov     eax, [esp+7Ch+var_60]
    mov     ecx, edx
    imul    ecx, [ebp+8]
    shl     eax, 10h
    cmp     edi, ebx
    mov     ebx, [esp+7Ch+arg_4]
    jg      short loc_4B9D2B

    loc_4B9CEA:                             ; CODE XREF: sub_4B9A50+2D2j
    mov     ebx, [ebx+10h]
    mov     edx, eax
    sar     edx, 10h
    add     edx, esi
    mov     dl, [edx+ebx]
    mov     ebx, [esp+7Ch+arg_4]
    cmp     dl, [ebx+8]
    jz      short loc_4B9D12
    mov     ebx, [ebp+0Ch]
    add     ebx, ecx
    mov     [ebx+edi], dl
    mov     ebx, [esp+7Ch+arg_4]

    loc_4B9D12:                             ; CODE XREF: sub_4B9A50+2B1j
    mov     edx, [esp+7Ch+arg_0]
    inc     edi
    add     eax, edx
    mov     edx, [esp+7Ch+var_48]
    cmp     edi, edx
    jle     short loc_4B9CEA
    mov     edx, [esp+7Ch+arg_8]

    loc_4B9D2B:                             ; CODE XREF: sub_4B9A50+298j
    mov     esi, [esp+7Ch+arg_C]
    mov     ecx, [esp+7Ch+var_64]
    mov     eax, [esp+7Ch+var_44]
    inc     edx
    add     esi, ecx
    cmp     edx, eax
    mov     [esp+7Ch+arg_8], edx
    mov     [esp+7Ch+arg_C], esi
    jle     loc_4B9CBF

    loc_4B9D53:                             ; CODE XREF: sub_4B9A50+40j
                                            ; sub_4B9A50+B0j ...
    lea     eax, [esp+7Ch+var_30]
    cmp     ebp, eax
    jnz     short loc_4B9D65
    lea     ecx, [esp+7Ch+var_30]
    push    ecx
    call    sub_4C5FA0

    loc_4B9D65:                             ; CODE XREF: sub_4B9A50+309j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 6Ch
    retn    20h
    sub_4B9A50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B9D70 proc near                    ; CODE XREF: sub_45A790+BEp

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h
    arg_8= dword ptr  18h
    arg_C= dword ptr  1Ch

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, [esp+4+arg_4]
    movsx   edx, word ptr [esi+4]
    movsx   eax, word ptr [edi+4]
    mov     ecx, [esp+4+arg_8]
    sub     edx, eax
    movsx   eax, word ptr [edi+6]
    add     ecx, edx
    movsx   edx, word ptr [esi+6]
    sub     eax, edx
    mov     edx, [esp+4+arg_C]
    sub     eax, edx
    jns     short loc_4B9DA6
    neg     eax
    mov     ebp, eax
    xor     edx, edx
    jmp     short loc_4B9DAA
    ; ---------------------------------------------------------------------------

    loc_4B9DA6:                             ; CODE XREF: sub_4B9D70+2Cj
    xor     ebp, ebp
    mov     edx, eax

    loc_4B9DAA:                             ; CODE XREF: sub_4B9D70+34j
    neg     ecx
    mov     [esp+4+arg_0], ecx
    jns     short loc_4B9DC2
    neg     ecx
    mov     [esp+4+arg_4], ecx
    mov     [esp+4+arg_0], 0
    jmp     short loc_4B9DC8
    ; ---------------------------------------------------------------------------

    loc_4B9DC2:                             ; CODE XREF: sub_4B9D70+40j
    xor     ecx, ecx
    mov     [esp+4+arg_4], ecx

    loc_4B9DC8:                             ; CODE XREF: sub_4B9D70+50j
    xor     eax, eax
    xor     ebx, ebx
    mov     ax, [esi]
    mov     bx, [edi]
    sub     eax, ecx
    mov     [esp+4+arg_8], ebx
    cmp     eax, ebx
    jg      short loc_4B9DE0
    mov     [esp+4+arg_8], eax

    loc_4B9DE0:                             ; CODE XREF: sub_4B9D70+6Aj
    xor     eax, eax
    mov     ax, [esi+2]
    cmp     ebp, eax
    jge     short loc_4B9E53
    jmp     short loc_4B9DF0
    ; ---------------------------------------------------------------------------

    loc_4B9DEC:                             ; CODE XREF: sub_4B9D70+E1j
    mov     ecx, [esp+4+arg_4]

    loc_4B9DF0:                             ; CODE XREF: sub_4B9D70+7Aj
    xor     eax, eax
    mov     ax, [edi+2]
    cmp     edx, eax
    jge     short loc_4B9E53
    xor     eax, eax
    mov     ax, [esi]
    mov     ebx, eax
    mov     eax, ebp
    imul    eax, ebx
    add     eax, [esi+10h]
    add     eax, ecx
    xor     ecx, ecx
    mov     cx, [edi]
    mov     ebx, ecx
    mov     ecx, edx
    imul    ecx, ebx
    mov     ebx, [edi+10h]
    add     ecx, ebx
    mov     ebx, [esp+4+arg_0]
    add     ecx, ebx
    mov     ebx, [esp+4+arg_8]
    test    ebx, ebx
    jz      short loc_4B9E47
    mov     [esp+4+arg_C], ebx

    loc_4B9E2E:                             ; CODE XREF: sub_4B9D70+D5j
    mov     bl, [eax]
    cmp     bl, [esi+8]
    jz      short loc_4B9E3A
    mov     bl, [edi+8]
    mov     [ecx], bl

    loc_4B9E3A:                             ; CODE XREF: sub_4B9D70+C3j
    mov     ebx, [esp+4+arg_C]
    inc     eax
    inc     ecx
    dec     ebx
    mov     [esp+4+arg_C], ebx
    jnz     short loc_4B9E2E

    loc_4B9E47:                             ; CODE XREF: sub_4B9D70+B8j
    xor     eax, eax
    inc     ebp
    mov     ax, [esi+2]
    inc     edx
    cmp     ebp, eax
    jl      short loc_4B9DEC

    loc_4B9E53:                             ; CODE XREF: sub_4B9D70+78j
                                            ; sub_4B9D70+88j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_4B9D70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B9E60 proc near                    ; CODE XREF: sub_45A790+CBp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     eax, [esp+4+arg_4]
    xor     ecx, ecx
    push    ebx
    push    ebp
    mov     cx, [eax+2]
    mov     ebp, [eax+10h]
    push    edi
    xor     ebx, ebx
    xor     edi, edi
    mov     edx, ecx
    mov     di, [eax]
    dec     ecx
    test    edx, edx
    jle     short loc_4B9EC5
    inc     ecx
    push    esi
    mov     esi, [esp+14h+arg_0]
    mov     [esp+14h+var_4], ecx
    jmp     short loc_4B9E8F
    ; ---------------------------------------------------------------------------

    loc_4B9E8B:                             ; CODE XREF: sub_4B9E60+62j
    mov     eax, [esp+14h+arg_4]

    loc_4B9E8F:                             ; CODE XREF: sub_4B9E60+29j
    test    esi, esi
    jz      short loc_4B9E9A
    mov     [esp+14h+arg_0], esi
    add     esi, 2

    loc_4B9E9A:                             ; CODE XREF: sub_4B9E60+31j
    mov     al, [eax+8]
    push    eax
    push    edi
    push    ebp
    push    esi
    call    sub_4BA000
    add     ebp, edi
    lea     ebx, [ebx+eax+2]
    test    esi, esi
    jz      short loc_4B9EB9
    mov     ecx, [esp+14h+arg_0]
    add     esi, eax
    mov     [ecx], ax

    loc_4B9EB9:                             ; CODE XREF: sub_4B9E60+4Ej
    mov     eax, [esp+14h+var_4]
    dec     eax
    mov     [esp+14h+var_4], eax
    jnz     short loc_4B9E8B
    pop     esi

    loc_4B9EC5:                             ; CODE XREF: sub_4B9E60+1Dj
    pop     edi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_4B9E60 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B9ED0 proc near                    ; CODE XREF: sub_4BA000+A6p
                                            ; sub_4BA000+CEp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    push    esi
    push    edi
    xor     edi, edi

    loc_4B9EDE:                             ; CODE XREF: sub_4B9ED0+6Fj
    cmp     ebp, 40h
    mov     edx, ebp
    jle     short loc_4B9EEA
    mov     edx, 40h

    loc_4B9EEA:                             ; CODE XREF: sub_4B9ED0+13j
    mov     cl, dl
    sub     ebp, edx
    add     cl, 3Fh
    shl     cl, 2
    test    eax, eax
    jz      short loc_4B9EFB
    mov     [eax], cl
    inc     eax

    loc_4B9EFB:                             ; CODE XREF: sub_4B9ED0+26j
    mov     esi, dword_51FDB0
    inc     esi
    test    edx, edx
    mov     dword_51FDB0, esi
    jle     short loc_4B9F3D

    loc_4B9F0C:                             ; CODE XREF: sub_4B9ED0+6Bj
    xor     ecx, ecx
    mov     cl, byte_51FCB0[edi]
    inc     edi
    mov     esi, ecx
    xor     ecx, ecx

    loc_4B9F19:                             ; CODE XREF: sub_4B9ED0+68j
    test    eax, eax
    jz      short loc_4B9F25
    mov     ebx, esi
    sar     ebx, cl
    inc     eax
    mov     [eax-1], bl

    loc_4B9F25:                             ; CODE XREF: sub_4B9ED0+4Bj
    mov     ebx, dword_51FDB0
    add     ecx, 8
    inc     ebx
    cmp     ecx, 8
    mov     dword_51FDB0, ebx
    jb      short loc_4B9F19
    dec     edx
    jnz     short loc_4B9F0C

    loc_4B9F3D:                             ; CODE XREF: sub_4B9ED0+3Aj
    test    ebp, ebp
    jg      short loc_4B9EDE
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4B9ED0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4B9F50 proc near                    ; CODE XREF: sub_4BA000+12Fp
                                            ; sub_4BA000+184p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= byte ptr  10h

    mov     eax, [esp+arg_8]
    mov     cl, [esp+arg_C]
    cmp     al, cl
    push    esi
    jnz     short loc_4B9F94
    mov     edx, [esp+4+arg_4]
    mov     eax, [esp+4+arg_0]

    loc_4B9F65:                             ; CODE XREF: sub_4B9F50+3Ej
    cmp     edx, 7Fh
    mov     ecx, edx
    jle     short loc_4B9F71
    mov     ecx, 7Fh

    loc_4B9F71:                             ; CODE XREF: sub_4B9F50+1Aj
    sub     edx, ecx
    shl     cl, 1
    or      cl, 1
    test    eax, eax
    jz      short loc_4B9F7F
    mov     [eax], cl
    inc     eax

    loc_4B9F7F:                             ; CODE XREF: sub_4B9F50+2Aj
    mov     esi, dword_51FDB0
    inc     esi
    test    edx, edx
    mov     dword_51FDB0, esi
    jg      short loc_4B9F65
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4B9F94:                             ; CODE XREF: sub_4B9F50+Bj
    push    edi
    mov     edi, [esp+8+arg_4]
    and     eax, 0FFh
    push    ebp
    mov     ebp, eax
    mov     eax, [esp+0Ch+arg_0]

    loc_4B9FA5:                             ; CODE XREF: sub_4B9F50+A7j
    cmp     edi, 40h
    mov     ecx, edi
    jle     short loc_4B9FB1
    mov     ecx, 40h

    loc_4B9FB1:                             ; CODE XREF: sub_4B9F50+5Aj
    sub     edi, ecx
    add     cl, 3Fh
    shl     cl, 2
    or      cl, 2
    test    eax, eax
    jz      short loc_4B9FC3
    mov     [eax], cl
    inc     eax

    loc_4B9FC3:                             ; CODE XREF: sub_4B9F50+6Ej
    mov     ecx, dword_51FDB0
    inc     ecx
    xor     esi, esi
    mov     dword_51FDB0, ecx

    loc_4B9FD2:                             ; CODE XREF: sub_4B9F50+A3j
    test    eax, eax
    jz      short loc_4B9FE0
    mov     edx, ebp
    mov     ecx, esi
    sar     edx, cl
    inc     eax
    mov     [eax-1], dl

    loc_4B9FE0:                             ; CODE XREF: sub_4B9F50+84j
    mov     ecx, dword_51FDB0
    add     esi, 8
    inc     ecx
    cmp     esi, 8
    mov     dword_51FDB0, ecx
    jb      short loc_4B9FD2
    test    edi, edi
    jg      short loc_4B9FA5
    pop     ebp
    pop     edi
    pop     esi
    retn    10h
    sub_4B9F50 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA000 proc near                    ; CODE XREF: sub_4B9E60+41p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= byte ptr  10h

    mov     ecx, [esp+arg_8]
    sub     esp, 8
    xor     eax, eax
    push    ebx
    push    ebp
    xor     ebp, ebp
    push    esi
    mov     esi, [esp+14h+arg_4]
    cmp     ecx, ebp
    push    edi
    jle     short loc_4BA027

    loc_4BA017:                             ; CODE XREF: sub_4BA000+25j
    mov     dl, [esp+18h+arg_C]
    mov     bl, [eax+esi]
    cmp     dl, bl
    jnz     short loc_4BA027
    inc     eax
    cmp     eax, ecx
    jl      short loc_4BA017

    loc_4BA027:                             ; CODE XREF: sub_4BA000+15j
                                            ; sub_4BA000+20j
    cmp     eax, ecx
    jl      short loc_4BA037
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4BA037:                             ; CODE XREF: sub_4BA000+29j
    mov     bl, [esp+18h+arg_C]
    mov     edi, [esp+18h+arg_0]
    mov     dword_51FDB0, ebp
    mov     al, [esi]
    inc     esi
    dec     ecx
    xor     edx, edx
    cmp     al, bl
    setz    dl
    mov     [esp+18h+arg_0], esi
    mov     byte ptr [esp+18h+var_4], al
    test    ecx, ecx
    mov     byte ptr [esp+18h+arg_4], al
    mov     byte_51FCB0, al
    mov     esi, 1
    mov     [esp+18h+arg_8], edx
    jz      loc_4BA16A
    mov     [esp+18h+var_8], ecx

    loc_4BA076:                             ; CODE XREF: sub_4BA000+164j
    mov     eax, [esp+18h+arg_0]
    inc     esi
    mov     bl, [eax]
    inc     eax
    mov     byte_51FCAF[esi], bl
    mov     [esp+18h+arg_0], eax
    mov     eax, [esp+18h+arg_8]
    mov     byte ptr [esp+18h+var_4], bl
    sub     eax, 0
    jz      short loc_4BA09D
    dec     eax
    jz      short loc_4BA10E
    jmp     loc_4BA157
    ; ---------------------------------------------------------------------------

    loc_4BA09D:                             ; CODE XREF: sub_4BA000+93j
    cmp     bl, [esp+18h+arg_C]
    jnz     short loc_4BA0C3
    dec     esi
    push    esi
    push    edi
    call    sub_4B9ED0
    mov     esi, 1
    mov     edi, eax
    mov     byte_51FCB0, bl
    xor     ebp, ebp
    mov     [esp+18h+arg_8], esi
    jmp     loc_4BA157
    ; ---------------------------------------------------------------------------

    loc_4BA0C3:                             ; CODE XREF: sub_4BA000+A1j
    cmp     esi, 80h
    jle     short loc_4BA0E4
    dec     esi
    push    esi
    push    edi
    call    sub_4B9ED0
    mov     edi, eax
    mov     byte_51FCB0, bl
    mov     esi, 1
    xor     ebp, ebp
    jmp     short loc_4BA157
    ; ---------------------------------------------------------------------------

    loc_4BA0E4:                             ; CODE XREF: sub_4BA000+C9j
    cmp     bl, byte ptr [esp+18h+arg_4]
    jnz     short loc_4BA154
    mov     eax, esi
    sub     eax, ebp
    cmp     eax, 3
    jl      short loc_4BA102
    test    ebp, ebp
    jle     short loc_4BA106
    push    ebp
    push    edi
    call    sub_4B9ED0
    mov     edi, eax
    jmp     short loc_4BA106
    ; ---------------------------------------------------------------------------

    loc_4BA102:                             ; CODE XREF: sub_4BA000+F1j
    test    ebp, ebp
    jnz     short loc_4BA10E

    loc_4BA106:                             ; CODE XREF: sub_4BA000+F5j
                                            ; sub_4BA000+100j
    mov     [esp+18h+arg_8], 1

    loc_4BA10E:                             ; CODE XREF: sub_4BA000+96j
                                            ; sub_4BA000+104j
    cmp     bl, byte ptr [esp+18h+arg_4]
    jnz     short loc_4BA120
    mov     ecx, esi
    sub     ecx, ebp
    cmp     ecx, 80h
    jle     short loc_4BA157

    loc_4BA120:                             ; CODE XREF: sub_4BA000+112j
    mov     edx, dword ptr [esp+18h+arg_C]
    mov     eax, [esp+18h+arg_4]
    sub     esi, ebp
    push    edx
    dec     esi
    push    eax
    push    esi
    push    edi
    call    sub_4B9F50
    mov     edi, eax
    xor     ebp, ebp
    mov     al, [esp+18h+arg_C]
    xor     ecx, ecx
    cmp     bl, al
    mov     byte_51FCB0, bl
    setz    cl
    mov     esi, 1
    mov     [esp+18h+arg_8], ecx
    jmp     short loc_4BA157
    ; ---------------------------------------------------------------------------

    loc_4BA154:                             ; CODE XREF: sub_4BA000+E8j
    lea     ebp, [esi-1]

    loc_4BA157:                             ; CODE XREF: sub_4BA000+98j
                                            ; sub_4BA000+BEj ...
    mov     eax, [esp+18h+var_8]
    mov     byte ptr [esp+18h+arg_4], bl
    dec     eax
    mov     [esp+18h+var_8], eax
    jnz     loc_4BA076

    loc_4BA16A:                             ; CODE XREF: sub_4BA000+6Cj
    mov     eax, [esp+18h+arg_8]
    sub     eax, 0
    jz      short loc_4BA198
    dec     eax
    jnz     short loc_4BA19F
    mov     edx, dword ptr [esp+18h+arg_C]
    mov     eax, [esp+18h+var_4]
    push    edx
    sub     esi, ebp
    push    eax
    push    esi
    push    edi
    call    sub_4B9F50
    mov     eax, dword_51FDB0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4BA198:                             ; CODE XREF: sub_4BA000+171j
    push    esi
    push    edi
    call    sub_4B9ED0

    loc_4BA19F:                             ; CODE XREF: sub_4BA000+174j
    mov     eax, dword_51FDB0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    10h
    sub_4BA000 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4BA1B0(int,char)
    sub_4BA1B0 proc near                    ; CODE XREF: sub_459200+303p
                                            ; sub_459200+3CFp ...

    arg_0= dword ptr  0Ch
    arg_4= byte ptr  10h

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    xor     esi, esi
    xor     eax, eax
    mov     si, [ebp+2]
    mov     ax, [ebp+0]
    mov     ebx, [ebp+14h]
    push    edi
    mov     edi, [ebp+10h]
    imul    esi, eax
    call    sub_4B6220
    mov     ecx, esi
    dec     esi
    test    ecx, ecx
    jz      short loc_4BA1EE
    mov     cl, [esp+8+arg_4]
    lea     eax, [esi+1]

    loc_4BA1E0:                             ; CODE XREF: sub_4BA1B0+3Cj
    cmp     [ebx], cl
    ja      short loc_4BA1E9
    mov     dl, [ebp+8]
    mov     [edi], dl

    loc_4BA1E9:                             ; CODE XREF: sub_4BA1B0+32j
    inc     edi
    inc     ebx
    dec     eax
    jnz     short loc_4BA1E0

    loc_4BA1EE:                             ; CODE XREF: sub_4BA1B0+27j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4BA1B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA200 proc near                    ; CODE XREF: sub_41DFC0+40p
                                            ; sub_41E270+193p ...

    var_824= dword ptr -824h
    var_814= dword ptr -814h
    var_810= dword ptr -810h
    var_80C= dword ptr -80Ch
    var_808= dword ptr -808h
    var_804= dword ptr -804h
    var_800= dword ptr -800h
    var_404= byte ptr -404h
    var_403= byte ptr -403h
    var_402= byte ptr -402h
    var_401= byte ptr -401h
    var_400= RGBQUAD ptr -400h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 814h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ds:WaitForSingleObject
    mov     esi, 4D41494Eh

    loc_4BA215:                             ; CODE XREF: sub_4BA200+37j
    push    esi                             ; Value
    push    offset Target                   ; Target
    call    ds:InterlockedExchange
    test    eax, eax
    jz      short loc_4BA239
    cmp     dword_52A4EC, esi
    jz      short loc_4BA249
    mov     eax, hHandle
    push    0FFFFFFFFh                      ; dwMilliseconds
    push    eax                             ; hHandle
    call    edi ; WaitForSingleObject
    jmp     short loc_4BA215
    ; ---------------------------------------------------------------------------

    loc_4BA239:                             ; CODE XREF: sub_4BA200+23j
    mov     dword_52A4EC, esi
    mov     [esp+824h+var_810], 0
    jmp     short loc_4BA24D
    ; ---------------------------------------------------------------------------

    loc_4BA249:                             ; CODE XREF: sub_4BA200+2Bj
    mov     [esp+824h+var_810], eax

    loc_4BA24D:                             ; CODE XREF: sub_4BA200+47j
    call    sub_4B6220
    mov     edx, [esp+824h+arg_4]
    mov     ebp, eax
    mov     [esp+824h+var_808], ebp
    mov     ecx, [ebp+614h]
    lea     eax, [ebp+edx*4+214h]
    mov     [esp+824h+var_80C], ecx
    mov     ecx, [esp+824h+arg_8]
    add     ecx, edx
    cmp     edx, ecx
    jge     loc_4BA36F
    mov     edi, [esp+824h+arg_0]
    mov     esi, ecx
    sub     edi, eax
    sub     esi, edx

    loc_4BA28E:                             ; CODE XREF: sub_4BA200+97j
    mov     ebx, [eax+edi]
    mov     [eax], ebx
    add     eax, 4
    dec     esi
    jnz     short loc_4BA28E
    cmp     edx, ecx
    jge     loc_4BA36F
    mov     eax, [esp+824h+arg_0]
    lea     ebp, [esp+824h+var_800]
    lea     ebx, [esp+824h+var_800+1]
    sub     ebp, eax
    sub     ebx, eax
    sub     ecx, edx
    lea     edi, [esp+edx*4+824h+var_800+1]
    lea     esi, [eax+edx*4+2]
    mov     [esp+824h+var_804], ecx

    loc_4BA2C2:                             ; CODE XREF: sub_4BA200+15Ej
    xor     edx, edx
    mov     dl, [esi-2]
    mov     [esp+824h+var_814], edx
    fild    [esp+824h+var_814]
    fmul    [esp+824h+var_80C]
    fcom    ds:dbl_4FDBC0
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4BA2E8
    fstp    st
    fld     ds:flt_4FDBC8

    loc_4BA2E8:                             ; CODE XREF: sub_4BA200+DEj
    call    __ftol
    mov     [edi-1], al
    xor     eax, eax
    mov     al, [esi-1]
    mov     [esp+824h+var_814], eax
    fild    [esp+824h+var_814]
    fmul    [esp+824h+var_80C]
    fcom    ds:dbl_4FDBC0
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4BA316
    fstp    st
    fld     ds:flt_4FDBC8

    loc_4BA316:                             ; CODE XREF: sub_4BA200+10Cj
    call    __ftol
    xor     ecx, ecx
    mov     [edi], al
    mov     cl, [esi]
    mov     [esp+824h+var_814], ecx
    fild    [esp+824h+var_814]
    fmul    [esp+824h+var_80C]
    fcom    ds:dbl_4FDBC0
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4BA342
    fstp    st
    fld     ds:flt_4FDBC8

    loc_4BA342:                             ; CODE XREF: sub_4BA200+138j
    call    __ftol
    mov     [ebp+esi+0], al
    mov     eax, [esp+824h+var_804]
    mov     byte ptr [ebx+esi], 0
    add     edi, 4
    add     esi, 4
    dec     eax
    mov     [esp+824h+var_804], eax
    jnz     loc_4BA2C2
    mov     edx, [esp+824h+arg_4]
    mov     ebp, [esp+824h+var_808]

    loc_4BA36F:                             ; CODE XREF: sub_4BA200+7Bj
                                            ; sub_4BA200+9Bj
    mov     eax, [ebp+44h]
    xor     edi, edi
    cmp     eax, edi
    jz      loc_4BA450
    mov     ebp, [ebp+4Ch]
    cmp     ebp, edi
    jz      short loc_4BA38A
    push    ebp                             ; HGDIOBJ
    call    ds:DeleteObject

    loc_4BA38A:                             ; CODE XREF: sub_4BA200+181j
    push    408h
    push    offset aPalette                 ; "Palette"
    call    sub_4D83B0
    mov     esi, eax
    add     esp, 8
    xor     eax, eax
    lea     ecx, [esi+4]

    loc_4BA3A3:                             ; CODE XREF: sub_4BA200+1DDj
    mov     edx, [esp+eax+824h+var_800]
    add     eax, 4
    mov     [ecx], edx
    mov     dl, byte ptr [esp+eax+824h+var_804]
    mov     [esp+eax+824h+var_402], dl
    mov     dl, byte ptr [esp+eax+824h+var_804+1]
    mov     [esp+eax+824h+var_403], dl
    mov     dl, byte ptr [esp+eax+824h+var_804+2]
    mov     [esp+eax+824h+var_404], dl
    mov     [esp+eax+824h+var_401], 0
    add     ecx, 4
    cmp     eax, 400h
    jl      short loc_4BA3A3
    push    esi                             ; LOGPALETTE *
    mov     word ptr [esi], 300h
    mov     word ptr [esi+2], 100h
    call    ds:CreatePalette
    mov     ecx, [esp+824h+var_808]
    mov     [ecx+4Ch], eax
    mov     ecx, [ecx+48h]
    lea     eax, [esp+824h+var_400]
    push    eax                             ; RGBQUAD *
    push    100h                            ; UINT
    push    edi                             ; UINT
    push    ecx                             ; HDC
    call    ds:SetDIBColorTable
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BA419:                             ; CODE XREF: sub_4BA200+25Bj
                                            ; sub_4BA200+27Bj
    cmp     [esp+824h+var_810], edi
    jnz     short loc_4BA43E
    push    edi                             ; Value
    push    offset Target                   ; Target
    mov     dword_52A4EC, edi
    call    ds:InterlockedExchange
    mov     edx, hHandle
    push    edx                             ; hEvent
    call    ds:SetEvent

    loc_4BA43E:                             ; CODE XREF: sub_4BA200+21Dj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 814h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BA450:                             ; CODE XREF: sub_4BA200+176j
    mov     al, [ebp+0F0h]
    shr     al, 2
    test    al, 1
    jz      short loc_4BA419
    mov     ebp, [ebp+94h]
    lea     eax, [esp+edx*4+824h+var_800]
    push    eax
    mov     eax, [esp+828h+arg_8]
    mov     ecx, [ebp+0]
    push    eax
    push    edx
    push    edi
    push    ebp
    call    dword ptr [ecx+18h]
    cmp     eax, edi
    jz      short loc_4BA419
    cmp     [esp+824h+var_810], edi
    jnz     short loc_4BA4A2
    push    edi                             ; Value
    push    offset Target                   ; Target
    mov     dword_52A4EC, edi
    call    ds:InterlockedExchange
    mov     ecx, hHandle
    push    ecx                             ; hEvent
    call    ds:SetEvent

    loc_4BA4A2:                             ; CODE XREF: sub_4BA200+281j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 814h
    retn    0Ch
    sub_4BA200 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 400h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     cl, [eax+0F0h]
    xor     ebx, ebx
    shr     cl, 2
    test    cl, 1
    jz      short loc_4BA535
    cmp     [eax+44h], ebx
    jz      short loc_4BA50A
    mov     eax, [eax+4Ch]
    lea     edx, [esp+10h]
    push    edx
    push    100h
    push    ebx
    push    eax
    call    ds:GetPaletteEntries
    test    eax, eax
    jnz     short loc_4BA535
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 400h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BA50A:                             ; CODE XREF: .text:004BA4E2j
    mov     eax, [eax+94h]
    lea     edx, [esp+10h]
    push    edx
    push    100h
    mov     ecx, [eax]
    push    ebx
    push    ebx
    push    eax
    call    dword ptr [ecx+10h]
    cmp     eax, ebx
    jz      short loc_4BA535
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 400h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BA535:                             ; CODE XREF: .text:004BA4DDj
                                            ; .text:004BA4FBj ...
    mov     edi, [esp+41Ch]
    mov     edx, [esp+418h]
    add     edi, edx
    cmp     edx, edi
    jge     short loc_4BA57D
    mov     ebp, [esp+414h]
    lea     esi, [esp+10h]
    sub     esi, ebp
    lea     ecx, [esp+edx*4+11h]
    lea     eax, [ebp+edx*4+2]
    sub     edi, edx

    loc_4BA560:                             ; CODE XREF: .text:004BA57Bj
    mov     dl, [ecx-1]
    add     ecx, 4
    mov     [eax-2], dl
    mov     dl, [ecx-4]
    mov     [eax-1], dl
    mov     dl, [esi+eax]
    mov     [eax], dl
    mov     [eax+1], bl
    add     eax, 4
    dec     edi
    jnz     short loc_4BA560

    loc_4BA57D:                             ; CODE XREF: .text:004BA547j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 400h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA590 proc near                    ; CODE XREF: .text:004172B2p
                                            ; sub_45BCC0+1Bp ...

    arg_0= dword ptr  4

    call    sub_4B6220
    mov     ecx, [esp+arg_0]
    push    100h
    mov     [eax+614h], ecx
    add     eax, 214h
    push    0
    push    eax
    call    sub_4BA200
    retn    4
    sub_4BA590 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA5C0 proc near                    ; CODE XREF: sub_4B5980+17Bp

    arg_0= dword ptr  4

    push    10000h
    push    offset aAlphaTable              ; "ALPHA TABLE"
    call    sub_4D83B0
    mov     ecx, [esp+8+arg_0]
    add     esp, 8
    mov     [ecx+0C0h], eax
    mov     eax, 1
    retn    4
    sub_4BA5C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA5F0 proc near                    ; CODE XREF: sub_4B6110+6Bp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+0C0h]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    retn    4
    sub_4BA5F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA610 proc near                    ; CODE XREF: sub_4B5980+15Fp

    arg_0= dword ptr  4

    push    2000h
    push    offset aShadeTable              ; "SHADE TABLE"
    call    sub_4D83B0
    mov     ecx, [esp+8+arg_0]
    add     esp, 8
    mov     [ecx+0C4h], eax
    mov     eax, 1
    retn    4
    sub_4BA610 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA640 proc near                    ; CODE XREF: sub_4B6110+58p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+0C4h]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    retn    4
    sub_4BA640 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA660 proc near                    ; CODE XREF: sub_4B5980+18Fp

    arg_0= dword ptr  4

    push    2000h
    push    offset aLightTable              ; "LIGHT TABLE"
    call    sub_4D83B0
    mov     ecx, [esp+8+arg_0]
    add     esp, 8
    mov     [ecx+0C8h], eax
    mov     eax, 1
    retn    4
    sub_4BA660 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA690 proc near                    ; CODE XREF: sub_4B6110+7Fp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+0C8h]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    retn    4
    sub_4BA690 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA6B0 proc near                    ; CODE XREF: sub_4B5980+1A9p

    arg_0= dword ptr  4

    push    100h
    push    offset aGrayTable               ; "GRAY TABLE"
    call    sub_4D83B0
    mov     ecx, [esp+8+arg_0]
    add     esp, 8
    mov     [ecx+0CCh], eax
    mov     eax, 1
    retn    4
    sub_4BA6B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA6E0 proc near                    ; CODE XREF: sub_4B6110+92p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+0CCh]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    retn    4
    sub_4BA6E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA700 proc near                    ; CODE XREF: sub_4B5980+1BEp

    arg_0= dword ptr  4

    push    100h
    push    offset aBlueTable               ; "BLUE TABLE"
    call    sub_4D83B0
    mov     ecx, [esp+8+arg_0]
    add     esp, 8
    mov     [ecx+0D0h], eax
    mov     eax, 1
    retn    4
    sub_4BA700 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA730 proc near                    ; CODE XREF: sub_4B6110+A6p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+0D0h]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    retn    4
    sub_4BA730 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA750 proc near                    ; CODE XREF: sub_42E140+6Dp

    var_510= byte ptr -510h
    var_50E= byte ptr -50Eh
    var_50C= dword ptr -50Ch
    var_508= dword ptr -508h
    var_504= dword ptr -504h
    var_500= dword ptr -500h
    var_400= dword ptr -400h
    arg_0= dword ptr  4

    sub     esp, 510h
    call    sub_4B6220
    mov     [esp+510h+var_50C], eax
    mov     al, [eax+0F0h]
    shr     al, 5
    test    al, 1
    jz      loc_4BA86D
    push    edi
    push    esi
    mov     esi, [esp+518h+arg_0]
    push    ebp
    lea     ecx, [esp+51Ch+var_500]
    push    ebx
    lea     edx, [esp+520h+var_400]
    push    ecx
    push    edx
    push    esi
    call    sub_4BA920
    xor     eax, eax
    lea     edi, [esi+2]
    mov     [esp+520h+var_508], eax
    xor     ebx, ebx
    mov     [esp+520h+var_504], edi
    mov     ebp, edi
    jmp     short loc_4BA7A5
    ; ---------------------------------------------------------------------------

    loc_4BA7A1:                             ; CODE XREF: sub_4BA750+100j
    mov     edi, [esp+520h+var_504]

    loc_4BA7A5:                             ; CODE XREF: sub_4BA750+4Fj
    xor     esi, esi

    loc_4BA7A7:                             ; CODE XREF: sub_4BA750+E6j
    cmp     eax, esi
    jnz     short loc_4BA7BC
    mov     ecx, [esp+520h+var_50C]
    mov     edx, [ecx+0C0h]
    add     edx, esi
    mov     [edx+ebx], al
    jmp     short loc_4BA82C
    ; ---------------------------------------------------------------------------

    loc_4BA7BC:                             ; CODE XREF: sub_4BA750+59j
    xor     eax, eax
    xor     ecx, ecx
    mov     al, [ebp-2]
    mov     cl, [edi-2]
    add     eax, ecx
    xor     ecx, ecx
    cdq
    sub     eax, edx
    xor     edx, edx
    mov     dl, [edi-1]
    mov     cl, [edi]
    sar     eax, 1
    mov     [esp+520h+var_510], al
    xor     eax, eax
    mov     al, [ebp-1]
    add     eax, edx
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+11h], al
    xor     eax, eax
    mov     al, [ebp+0]
    add     eax, ecx
    lea     ecx, [esp+520h+var_400]
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     [esp+520h+var_50E], al
    mov     edx, dword ptr [esp+520h+var_510]
    lea     eax, [esp+520h+var_500]
    push    edx
    mov     edx, [esp+524h+arg_0]
    push    eax
    push    ecx
    push    edx
    call    sub_4BA9D0
    mov     ecx, [esp+520h+var_50C]
    mov     edx, [ecx+0C0h]
    add     edx, esi
    mov     [edx+ebx], al
    mov     eax, [esp+520h+var_508]

    loc_4BA82C:                             ; CODE XREF: sub_4BA750+6Aj
    inc     esi
    add     edi, 4
    cmp     esi, 100h
    jl      loc_4BA7A7
    add     ebx, 100h
    inc     eax
    add     ebp, 4
    cmp     ebx, 10000h
    mov     [esp+520h+var_508], eax
    jl      loc_4BA7A1
    mov     eax, [esp+520h+var_50C]
    pop     ebx
    pop     ebp
    pop     esi
    mov     eax, [eax+0C0h]
    pop     edi
    add     esp, 510h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BA86D:                             ; CODE XREF: sub_4BA750+1Aj
    xor     eax, eax
    add     esp, 510h
    retn    4
    sub_4BA750 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    mov     eax, [esp+10h]
    mov     ecx, [esp+12h]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+1Dh]
    xor     ebx, ebx
    and     eax, 0FFh
    and     esi, 0FFh
    and     ecx, 0FFh
    mov     [esp+1Ch], ecx
    mov     ecx, [esp+18h]
    push    edi
    mov     ebp, 3B9ACA00h
    mov     [esp+14h], eax
    mov     [esp+10h], esi
    lea     edi, [ecx+2]
    jmp     short loc_4BA8C8
    ; ---------------------------------------------------------------------------

    loc_4BA8C0:                             ; CODE XREF: .text:004BA907j
    mov     esi, [esp+10h]
    mov     eax, [esp+14h]

    loc_4BA8C8:                             ; CODE XREF: .text:004BA8BEj
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [edi-2]
    mov     dl, [edi-1]
    sub     ecx, eax
    xor     eax, eax
    mov     al, [edi]
    sub     edx, esi
    mov     esi, eax
    mov     eax, [esp+20h]
    sub     esi, eax
    mov     eax, edx
    imul    eax, edx
    imul    ecx, ecx
    mov     edx, esi
    add     ecx, eax
    imul    edx, esi
    add     ecx, edx
    cmp     ecx, ebp
    jge     short loc_4BA8FD
    mov     [esp+1Ch], bl
    mov     ebp, ecx

    loc_4BA8FD:                             ; CODE XREF: .text:004BA8F5j
    inc     ebx
    add     edi, 4
    cmp     ebx, 100h
    jl      short loc_4BA8C0
    mov     al, [esp+1Ch]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA920 proc near                    ; CODE XREF: sub_4BA750+39p
                                            ; sub_4BABD0+39p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     ecx, [esp+arg_0]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_8]
    push    esi
    push    edi
    mov     edi, [esp+10h+arg_4]
    xor     eax, eax
    mov     esi, edi
    add     ecx, 2

    loc_4BA937:                             ; CODE XREF: sub_4BA920+3Aj
    xor     edx, edx
    xor     ebx, ebx
    mov     dl, [ecx-2]
    mov     bl, [ecx-1]
    add     edx, ebx
    xor     ebx, ebx
    mov     bl, [ecx]
    add     ecx, 4
    add     edx, ebx
    mov     [esi], edx
    mov     [eax+ebp], al
    inc     eax
    add     esi, 4
    cmp     eax, 100h
    jl      short loc_4BA937
    mov     ecx, 1
    mov     ebx, edi
    sub     ecx, ebp
    mov     esi, ebp
    mov     [esp+10h+arg_4], ebx
    mov     [esp+10h+arg_8], ecx
    mov     [esp+10h+arg_0], 100h

    loc_4BA977:                             ; CODE XREF: sub_4BA920+9Ej
    lea     eax, [ecx+esi]
    cmp     eax, 100h
    jge     short loc_4BA9AD
    lea     ecx, [ebx+4]

    loc_4BA984:                             ; CODE XREF: sub_4BA920+87j
    mov     edx, [ebx]
    mov     edi, [ecx]
    cmp     edx, edi
    jle     short loc_4BA99E
    mov     [ebx], edi
    mov     [ecx], edx
    mov     bl, [eax+ebp]
    mov     dl, [esi]
    mov     [esi], bl
    mov     ebx, [esp+10h+arg_4]
    mov     [eax+ebp], dl

    loc_4BA99E:                             ; CODE XREF: sub_4BA920+6Aj
    inc     eax
    add     ecx, 4
    cmp     eax, 100h
    jl      short loc_4BA984
    mov     ecx, [esp+10h+arg_8]

    loc_4BA9AD:                             ; CODE XREF: sub_4BA920+5Fj
    mov     eax, [esp+10h+arg_0]
    add     ebx, 4
    inc     esi
    dec     eax
    mov     [esp+10h+arg_4], ebx
    mov     [esp+10h+arg_0], eax
    jnz     short loc_4BA977
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_4BA920 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BA9D0 proc near                    ; CODE XREF: sub_4BA750+C4p
                                            ; sub_4BABD0+F9p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_E= dword ptr  12h

    sub     esp, 10h
    mov     ecx, [esp+10h+arg_E]
    mov     eax, [esp+21h]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+2Ch]
    and     ecx, 0FFh
    and     eax, 0FFh
    mov     [esp+1Ch+var_4], ecx
    and     esi, 0FFh
    add     ecx, eax
    mov     [esp+1Ch+var_8], eax
    add     ecx, esi
    push    edi
    mov     edi, [esp+20h+arg_0]
    mov     ebp, 3B9ACA00h
    lea     eax, [ecx-28h]
    mov     [esp+20h+var_10], esi
    mov     [esp+20h+var_C], eax
    mov     eax, [esp+20h+arg_4]
    mov     [esp+30h], ecx
    xor     edx, edx
    mov     [esp+20h+arg_4], eax
    jmp     short loc_4BAA2C
    ; ---------------------------------------------------------------------------

    loc_4BAA24:                             ; CODE XREF: sub_4BA9D0+CAj
    mov     esi, [esp+20h+var_10]
    mov     ecx, [esp+30h]

    loc_4BAA2C:                             ; CODE XREF: sub_4BA9D0+52j
    mov     eax, [esp+20h+arg_4]
    mov     ebx, [esp+20h+var_C]
    mov     eax, [eax]
    cmp     eax, ebx
    jl      short loc_4BAA88
    add     ecx, 28h
    cmp     eax, ecx
    jg      short loc_4BAA9C
    mov     eax, [esp+20h+arg_8]
    xor     ecx, ecx
    xor     ebx, ebx
    mov     cl, [edx+eax]
    xor     eax, eax
    mov     al, [edi+ecx*4]
    mov     bl, [edi+ecx*4+1]
    sub     eax, esi
    mov     esi, ebx
    mov     ebx, [esp+20h+var_8]
    imul    eax, eax
    sub     esi, ebx
    xor     ebx, ebx
    mov     bl, [edi+ecx*4+2]
    mov     ecx, ebx
    mov     ebx, [esp+20h+var_4]
    sub     ecx, ebx
    mov     ebx, esi
    imul    ebx, esi
    mov     esi, ecx
    add     eax, ebx
    imul    esi, ecx
    add     eax, esi
    cmp     eax, ebp
    jge     short loc_4BAA88
    mov     byte ptr [esp+20h+arg_0], dl
    mov     ebp, eax

    loc_4BAA88:                             ; CODE XREF: sub_4BA9D0+68j
                                            ; sub_4BA9D0+B0j
    mov     ecx, [esp+20h+arg_4]
    inc     edx
    add     ecx, 4
    cmp     edx, 100h
    mov     [esp+20h+arg_4], ecx
    jl      short loc_4BAA24

    loc_4BAA9C:                             ; CODE XREF: sub_4BA9D0+6Fj
    cmp     ebp, 3B9ACA00h
    jnz     short loc_4BAAA8
    mov     byte ptr [esp+20h+arg_0], dl

    loc_4BAAA8:                             ; CODE XREF: sub_4BA9D0+D2j
    mov     ecx, [esp+20h+arg_0]
    mov     edx, [esp+20h+arg_8]
    and     ecx, 0FFh
    pop     edi
    pop     esi
    pop     ebp
    mov     al, [edx+ecx]
    pop     ebx
    add     esp, 10h
    retn    10h
    sub_4BA9D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BAAD0 proc near                    ; CODE XREF: sub_42E140+4Bp

    arg_0= dword ptr  4

    call    sub_4B6220
    mov     cl, [eax+0F0h]
    shr     cl, 5
    test    cl, 1
    jz      short locret_4BAAF8
    push    edi
    mov     edi, [eax+0C0h]
    push    esi
    mov     esi, [esp+8+arg_0]
    mov     ecx, 4000h
    rep movsd
    pop     esi
    pop     edi

    locret_4BAAF8:                          ; CODE XREF: sub_4BAAD0+11j
    retn    4
    sub_4BAAD0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BAB00 proc near                    ; CODE XREF: sub_42E1D0+4Bp

    arg_0= dword ptr  4

    call    sub_4B6220
    mov     cl, [eax+0F0h]
    shr     cl, 6
    test    cl, 1
    jz      short locret_4BAB28
    push    edi
    mov     edi, [eax+0C4h]
    push    esi
    mov     esi, [esp+8+arg_0]
    mov     ecx, 800h
    rep movsd
    pop     esi
    pop     edi

    locret_4BAB28:                          ; CODE XREF: sub_4BAB00+11j
    retn    4
    sub_4BAB00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BAB30 proc near                    ; CODE XREF: sub_42E260+4Bp

    arg_0= dword ptr  4

    call    sub_4B6220
    mov     cl, [eax+0F0h]
    shr     cl, 7
    test    cl, 1
    jz      short locret_4BAB58
    push    edi
    mov     edi, [eax+0C8h]
    push    esi
    mov     esi, [esp+8+arg_0]
    mov     ecx, 800h
    rep movsd
    pop     esi
    pop     edi

    locret_4BAB58:                          ; CODE XREF: sub_4BAB30+11j
    retn    4
    sub_4BAB30 endp

    ; ---------------------------------------------------------------------------
    align 8
    call    sub_4B6220
    xor     ecx, ecx
    mov     cl, [eax+0F1h]
    test    cl, 1
    jz      short locret_4BAB87
    push    edi
    mov     edi, [eax+0CCh]
    push    esi
    mov     esi, [esp+0Ch]
    mov     ecx, 40h
    rep movsd
    pop     esi
    pop     edi

    locret_4BAB87:                          ; CODE XREF: .text:004BAB70j
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    call    sub_4B6220
    mov     cx, [eax+0F0h]
    shr     ecx, 9
    test    cl, 1
    jz      short locret_4BABC9
    push    edi
    mov     edi, [eax+0D0h]
    push    esi
    mov     esi, [esp+0Ch]
    mov     ecx, 40h
    rep movsd
    pop     esi
    pop     edi

    locret_4BABC9:                          ; CODE XREF: .text:004BABB2j
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BABD0 proc near                    ; CODE XREF: sub_42E260+6Dp

    var_51C= dword ptr -51Ch
    var_518= dword ptr -518h
    var_514= byte ptr -514h
    var_512= byte ptr -512h
    var_510= dword ptr -510h
    var_50C= qword ptr -50Ch
    var_504= dword ptr -504h
    var_500= dword ptr -500h
    var_400= dword ptr -400h
    arg_0= dword ptr  4

    sub     esp, 51Ch
    call    sub_4B6220
    mov     [esp+51Ch+var_510], eax
    mov     al, [eax+0F0h]
    shr     al, 7
    test    al, 1
    jz      loc_4BAD16
    mov     eax, [esp+51Ch+arg_0]
    push    edi
    push    esi
    push    ebp
    lea     ecx, [esp+528h+var_500]
    push    ebx
    lea     edx, [esp+52Ch+var_400]
    push    ecx
    push    edx
    push    eax
    call    sub_4BA920
    mov     [esp+52Ch+var_518], 0

    loc_4BAC16:                             ; CODE XREF: sub_4BABD0+12Bj
    fild    [esp+52Ch+var_518]
    mov     ecx, [esp+52Ch+arg_0]
    mov     ebp, [esp+52Ch+var_518]
    xor     esi, esi
    fmul    ds:dbl_4FDBD0
    shl     ebp, 8
    lea     edi, [ecx+2]
    fsubr   ds:dbl_4FDBD8
    fstp    [esp+52Ch+var_50C]

    loc_4BAC3D:                             ; CODE XREF: sub_4BABD0+119j
    xor     edx, edx
    mov     dl, [edi-2]
    mov     [esp+52Ch+var_51C], edx
    fild    [esp+52Ch+var_51C]
    fmul    [esp+52Ch+var_50C]
    call    __ftol
    mov     ebx, eax
    xor     eax, eax
    mov     al, [edi-1]
    mov     [esp+52Ch+var_51C], eax
    fild    [esp+52Ch+var_51C]
    fmul    [esp+52Ch+var_50C]
    call    __ftol
    xor     ecx, ecx
    mov     [esp+52Ch+var_51C], eax
    mov     cl, [edi]
    mov     [esp+52Ch+var_504], ecx
    fild    [esp+52Ch+var_504]
    fmul    [esp+52Ch+var_50C]
    call    __ftol
    mov     ecx, 0FFh
    cmp     ebx, ecx
    jle     short loc_4BAC8F
    mov     ebx, ecx

    loc_4BAC8F:                             ; CODE XREF: sub_4BABD0+BBj
    cmp     [esp+52Ch+var_51C], ecx
    jle     short loc_4BAC99
    mov     [esp+52Ch+var_51C], ecx

    loc_4BAC99:                             ; CODE XREF: sub_4BABD0+C3j
    cmp     eax, ecx
    jle     short loc_4BAC9F
    mov     eax, ecx

    loc_4BAC9F:                             ; CODE XREF: sub_4BABD0+CBj
    mov     dl, byte ptr [esp+52Ch+var_51C]
    mov     [esp+52Ch+var_514], bl
    mov     [esp+19h], dl
    mov     [esp+52Ch+var_512], al
    mov     eax, dword ptr [esp+52Ch+var_514]
    lea     ecx, [esp+52Ch+var_500]
    push    eax
    mov     eax, [esp+530h+arg_0]
    lea     edx, [esp+530h+var_400]
    push    ecx
    push    edx
    push    eax
    call    sub_4BA9D0
    mov     ecx, esi
    add     edi, 4
    mov     edx, [esp+52Ch+var_510]
    mov     ebx, [edx+0C8h]
    add     ecx, ebx
    inc     esi
    cmp     esi, 100h
    mov     [ecx+ebp], al
    jl      loc_4BAC3D
    mov     eax, [esp+52Ch+var_518]
    inc     eax
    cmp     eax, 20h
    mov     [esp+52Ch+var_518], eax
    jl      loc_4BAC16
    mov     eax, edx
    pop     ebx
    pop     ebp
    pop     esi
    mov     eax, [eax+0C8h]
    pop     edi
    add     esp, 51Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BAD16:                             ; CODE XREF: sub_4BABD0+1Aj
    xor     eax, eax
    add     esp, 51Ch
    retn    4
    sub_4BABD0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BAD30 proc near                    ; CODE XREF: sub_42E2F0+5p

    var_504= byte ptr -504h
    var_502= byte ptr -502h
    var_500= dword ptr -500h
    var_400= dword ptr -400h
    arg_0= dword ptr  4

    sub     esp, 504h
    push    ebp
    call    sub_4B6220
    mov     ebp, eax
    xor     eax, eax
    mov     al, [ebp+0F1h]
    test    al, 1
    jz      loc_4BADDA
    push    edi
    push    esi
    lea     ecx, [esp+510h+var_500]
    push    ebx
    mov     ebx, [esp+514h+arg_0]
    lea     edx, [esp+514h+var_400]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BA920
    xor     edi, edi
    lea     esi, [ebx+2]

    loc_4BAD70:                             ; CODE XREF: sub_4BAD30+95j
    xor     eax, eax
    xor     edx, edx
    mov     al, [esi-2]
    mov     dl, [esi-1]
    mov     ecx, eax
    xor     eax, eax
    mov     al, [esi]
    add     ecx, edx
    add     ecx, eax
    mov     eax, 0AAAAAAABh
    mul     ecx
    shr     edx, 1
    mov     [esp+11h], dl
    mov     [esp+514h+var_502], dl
    mov     [esp+514h+var_504], dl
    mov     ecx, dword ptr [esp+514h+var_504]
    lea     edx, [esp+514h+var_500]
    push    ecx
    lea     eax, [esp+518h+var_400]
    push    edx
    push    eax
    push    ebx
    call    sub_4BA9D0
    mov     ecx, [ebp+0CCh]
    inc     edi
    add     esi, 4
    cmp     edi, 100h
    mov     [edi+ecx-1], al
    jl      short loc_4BAD70
    mov     eax, [ebp+0CCh]
    pop     ebx
    pop     esi
    pop     edi
    pop     ebp
    add     esp, 504h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BADDA:                             ; CODE XREF: sub_4BAD30+18j
    xor     eax, eax
    pop     ebp
    add     esp, 504h
    retn    4
    sub_4BAD30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BADF0 proc near                    ; CODE XREF: sub_42E1D0+6Dp

    var_514= byte ptr -514h
    var_512= byte ptr -512h
    var_510= dword ptr -510h
    var_50C= qword ptr -50Ch
    var_504= dword ptr -504h
    var_500= dword ptr -500h
    var_400= dword ptr -400h
    arg_0= dword ptr  4

    sub     esp, 514h
    call    sub_4B6220
    mov     [esp+514h+var_504], eax
    mov     al, [eax+0F0h]
    shr     al, 6
    test    al, 1
    jz      loc_4BAF22
    push    edi
    push    esi
    push    ebp
    lea     ecx, [esp+520h+var_500]
    push    ebx
    mov     ebx, [esp+524h+arg_0]
    lea     edx, [esp+524h+var_400]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BA920
    xor     ebp, ebp
    mov     dword ptr [esp+524h+var_50C], 0
    mov     dword ptr [esp+524h+var_50C+4], 0

    loc_4BAE40:                             ; CODE XREF: sub_4BADF0+115j
    xor     esi, esi
    lea     edi, [ebx+2]

    loc_4BAE45:                             ; CODE XREF: sub_4BADF0+F5j
    xor     eax, eax
    mov     al, [edi-2]
    mov     [esp+524h+var_510], eax
    fild    [esp+524h+var_510]
    fmul    [esp+524h+var_50C]
    call    __ftol
    cmp     ax, 0FFh
    mov     [esp+524h+var_514], al
    jbe     short loc_4BAE6A
    mov     [esp+524h+var_514], 0FFh

    loc_4BAE6A:                             ; CODE XREF: sub_4BADF0+73j
    xor     ecx, ecx
    mov     cl, [edi-1]
    mov     [esp+524h+var_510], ecx
    fild    [esp+524h+var_510]
    fmul    [esp+524h+var_50C]
    call    __ftol
    cmp     ax, 0FFh
    mov     [esp+11h], al
    jbe     short loc_4BAE8F
    mov     byte ptr [esp+11h], 0FFh

    loc_4BAE8F:                             ; CODE XREF: sub_4BADF0+98j
    xor     edx, edx
    mov     dl, [edi]
    mov     [esp+524h+var_510], edx
    fild    [esp+524h+var_510]
    fmul    [esp+524h+var_50C]
    call    __ftol
    cmp     ax, 0FFh
    mov     [esp+524h+var_512], al
    jbe     short loc_4BAEB3
    mov     [esp+524h+var_512], 0FFh

    loc_4BAEB3:                             ; CODE XREF: sub_4BADF0+BCj
    mov     eax, dword ptr [esp+524h+var_514]
    lea     ecx, [esp+524h+var_500]
    push    eax
    lea     edx, [esp+528h+var_400]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BA9D0
    lea     ecx, [esi+ebp]
    inc     esi
    mov     edx, [esp+524h+var_504]
    add     edi, 4
    cmp     esi, 100h
    mov     edx, [edx+0C4h]
    mov     [ecx+edx], al
    jl      loc_4BAE45
    fld     [esp+524h+var_50C]
    fsub    ds:dbl_4FDBE8
    add     ebp, 100h
    cmp     ebp, 2000h
    fstp    [esp+524h+var_50C]
    jl      loc_4BAE40
    mov     eax, [esp+524h+var_504]
    pop     ebx
    pop     ebp
    pop     esi
    mov     eax, [eax+0C4h]
    pop     edi
    add     esp, 514h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BAF22:                             ; CODE XREF: sub_4BADF0+1Aj
    xor     eax, eax
    add     esp, 514h
    retn    4
    sub_4BADF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BAF30 proc near                    ; CODE XREF: sub_42E300+5p

    var_504= byte ptr -504h
    var_502= byte ptr -502h
    var_500= dword ptr -500h
    var_400= dword ptr -400h
    arg_0= dword ptr  4

    sub     esp, 504h
    push    ebx
    call    sub_4B6220
    mov     ebx, eax
    mov     ax, [ebx+0F0h]
    shr     eax, 9
    test    al, 1
    jz      loc_4BAFE3
    push    edi
    push    esi
    lea     ecx, [esp+510h+var_500]
    push    ebp
    mov     ebp, [esp+514h+arg_0]
    lea     edx, [esp+514h+var_400]
    push    ecx
    push    edx
    push    ebp
    call    sub_4BA920
    xor     esi, esi
    lea     edi, [ebp+2]

    loc_4BAF72:                             ; CODE XREF: sub_4BAF30+9Ej
    mov     al, [edi-2]
    mov     cl, [edi-1]
    shr     al, 1
    mov     [esp+514h+var_504], al
    xor     eax, eax
    mov     al, [edi]
    shr     eax, 1
    shr     cl, 1
    lea     edx, [eax+3Ch]
    mov     [esp+11h], cl
    cmp     edx, 0FFh
    jle     short loc_4BAF9C
    mov     [esp+514h+var_502], 0FFh
    jmp     short loc_4BAFA2
    ; ---------------------------------------------------------------------------

    loc_4BAF9C:                             ; CODE XREF: sub_4BAF30+63j
    add     al, 32h
    mov     [esp+514h+var_502], al

    loc_4BAFA2:                             ; CODE XREF: sub_4BAF30+6Aj
    mov     eax, dword ptr [esp+514h+var_504]
    lea     ecx, [esp+514h+var_500]
    push    eax
    lea     edx, [esp+518h+var_400]
    push    ecx
    push    edx
    push    ebp
    call    sub_4BA9D0
    mov     ecx, [ebx+0D0h]
    inc     esi
    add     edi, 4
    cmp     esi, 100h
    mov     [esi+ecx-1], al
    jl      short loc_4BAF72
    mov     eax, [ebx+0D0h]
    pop     ebp
    pop     esi
    pop     edi
    pop     ebx
    add     esp, 504h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BAFE3:                             ; CODE XREF: sub_4BAF30+1Aj
    xor     eax, eax
    pop     ebx
    add     esp, 504h
    retn    4
    sub_4BAF30 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BAFF0 proc near                    ; CODE XREF: sub_4A75D0+78p
                                            ; sub_4A81E0+2C2p ...

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h
    arg_8= dword ptr  18h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     edx, [esp+arg_4]
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [ecx+edx-1]
    cmp     eax, edx
    jb      short loc_4BB042

    loc_4BB02C:                             ; CODE XREF: sub_4BAFF0+4Bj
    mov     cl, [eax]
    cmp     cl, 5Ch
    jz      short loc_4BB042
    cmp     cl, 2Eh
    jz      short loc_4BB03F
    dec     eax
    cmp     eax, edx
    jnb     short loc_4BB02C
    jmp     short loc_4BB042
    ; ---------------------------------------------------------------------------

    loc_4BB03F:                             ; CODE XREF: sub_4BAFF0+46j
    mov     byte ptr [eax], 0

    loc_4BB042:                             ; CODE XREF: sub_4BAFF0+3Aj
                                            ; sub_4BAFF0+41j ...
    mov     edi, offset Directory
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb
    mov     edi, [esp+arg_8]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    mov     eax, edx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_4BAFF0 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, [esp+8]
    push    edi
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    xor     edx, edx
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4BB0DC

    loc_4BB0B6:                             ; CODE XREF: .text:004BB0CBj
    cmp     byte ptr [edx+esi], 2Eh
    jz      short loc_4BB0D2
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    inc     edx
    repne scasb
    not     ecx
    dec     ecx
    cmp     edx, ecx
    jb      short loc_4BB0B6
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BB0D2:                             ; CODE XREF: .text:004BB0BAj
    mov     eax, 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BB0DC:                             ; CODE XREF: .text:004BB0B4j
    pop     edi
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB0F0 proc near                    ; CODE XREF: sub_41D7B0+58p
                                            ; sub_4290F0+45p ...

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    edi
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    js      short loc_4BB116

    loc_4BB103:                             ; CODE XREF: sub_4BB0F0+1Aj
    cmp     byte ptr [ecx+edx], 2Eh
    jz      short loc_4BB112
    dec     ecx
    jns     short loc_4BB103
    mov     eax, edx
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BB112:                             ; CODE XREF: sub_4BB0F0+17j
    mov     byte ptr [ecx+edx], 0

    loc_4BB116:                             ; CODE XREF: sub_4BB0F0+11j
    mov     eax, edx
    pop     edi
    retn    4
    sub_4BB0F0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB120 proc near                    ; CODE XREF: sub_49F540+1Dp
                                            ; ReadIniFileValue+1Dp ...

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    edi
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    js      short loc_4BB147

    loc_4BB133:                             ; CODE XREF: sub_4BB120+1Aj
    cmp     byte ptr [ecx+edx], 5Ch
    jz      short loc_4BB142
    dec     ecx
    jns     short loc_4BB133
    mov     eax, edx
    pop     edi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BB142:                             ; CODE XREF: sub_4BB120+17j
    mov     byte ptr [ecx+edx+1], 0

    loc_4BB147:                             ; CODE XREF: sub_4BB120+11j
    mov     eax, edx
    pop     edi
    retn    4
    sub_4BB120 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB150 proc near                    ; CODE XREF: sub_4AA8F0+102p
                                            ; .text:004AFBC9p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [ecx-1]
    test    eax, eax
    jl      short loc_4BB172

    loc_4BB169:                             ; CODE XREF: sub_4BB150+20j
    cmp     byte ptr [eax+esi], 5Ch
    jz      short loc_4BB172
    dec     eax
    jns     short loc_4BB169

    loc_4BB172:                             ; CODE XREF: sub_4BB150+17j
                                            ; sub_4BB150+1Dj
    lea     eax, [eax+esi+1]
    mov     ecx, esi

    loc_4BB178:                             ; CODE XREF: sub_4BB150+32j
    mov     dl, [eax]
    mov     [ecx], dl
    mov     dl, [eax]
    inc     ecx
    inc     eax
    test    dl, dl
    jnz     short loc_4BB178
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    sub_4BB150 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB190 proc near                    ; CODE XREF: sub_41D4C0+13Dp
                                            ; sub_41D6A0+64p ...

    RootPathName= byte ptr  4

    movsx   eax, [esp+RootPathName]
    push    ebx
    push    esi
    push    eax                             ; int
    call    _toupper
    mov     bl, al
    add     esp, 4
    cmp     bl, 41h
    jl      short loc_4BB1B0
    cmp     bl, 5Ah
    jg      short loc_4BB1B0
    inc     bl
    jmp     short loc_4BB1B2
    ; ---------------------------------------------------------------------------

    loc_4BB1B0:                             ; CODE XREF: sub_4BB190+15j
                                            ; sub_4BB190+1Aj
    mov     bl, 41h

    loc_4BB1B2:                             ; CODE XREF: sub_4BB190+1Ej
    cmp     bl, 5Ah
    jg      short loc_4BB1F4
    mov     esi, ds:GetDriveTypeA

    loc_4BB1BD:                             ; CODE XREF: sub_4BB190+54j
    movsx   ecx, bl
    push    ecx
    lea     edx, [esp+0Ch+RootPathName]
    push    offset aC                       ; "%c:\\"
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+8+RootPathName]
    push    eax                             ; lpRootPathName
    call    esi ; GetDriveTypeA
    cmp     eax, 5
    jz      short loc_4BB1ED
    inc     bl
    cmp     bl, 5Ah
    jle     short loc_4BB1BD
    xor     al, al
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BB1ED:                             ; CODE XREF: sub_4BB190+4Dj
    mov     al, bl
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BB1F4:                             ; CODE XREF: sub_4BB190+25j
    pop     esi
    xor     al, al
    pop     ebx
    retn    4
    sub_4BB190 endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 4Ch
    movsx   eax, byte ptr [esp+50h]
    push    eax
    lea     ecx, [esp+54h]
    push    offset aC                       ; "%c:\\"
    push    ecx
    mov     dword ptr [esp+0Ch], 0
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+0Ch]
    lea     eax, [esp+4]
    lea     ecx, [esp+8]
    push    40h
    push    edx
    push    eax
    mov     eax, [esp+64h]
    lea     edx, [esp+0Ch]
    push    ecx
    mov     ecx, [esp+64h]
    push    edx
    push    eax
    lea     edx, [esp+68h]
    push    ecx
    push    edx
    call    ds:GetVolumeInformationA
    mov     eax, [esp+0]
    add     esp, 4Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB260 proc near                    ; CODE XREF: sub_4CDA00+24p

    VolumeSerialNumber= dword ptr -90h
    RootPathName= byte ptr -8Ch
    FileSystemFlags= dword ptr -88h
    MaximumComponentLength= dword ptr -84h
    FileSystemNameBuffer= byte ptr -80h
    VolumeNameBuffer= byte ptr -40h
    arg_0= byte ptr  4

    sub     esp, 90h
    movsx   eax, [esp+90h+arg_0]
    push    eax
    lea     ecx, [esp+94h+RootPathName]
    push    offset aC                       ; "%c:\\"
    push    ecx
    mov     [esp+9Ch+VolumeSerialNumber], 0
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+90h+FileSystemNameBuffer]
    lea     eax, [esp+90h+FileSystemFlags]
    lea     ecx, [esp+90h+MaximumComponentLength]
    push    40h                             ; nFileSystemNameSize
    push    edx                             ; lpFileSystemNameBuffer
    push    eax                             ; lpFileSystemFlags
    lea     edx, [esp+9Ch+VolumeSerialNumber]
    push    ecx                             ; lpMaximumComponentLength
    push    edx                             ; lpVolumeSerialNumber
    lea     eax, [esp+0A4h+VolumeNameBuffer]
    push    40h                             ; nVolumeNameSize
    lea     ecx, [esp+0A8h+RootPathName]
    push    eax                             ; lpVolumeNameBuffer
    push    ecx                             ; lpRootPathName
    call    ds:GetVolumeInformationA
    mov     eax, [esp+90h+VolumeSerialNumber]
    add     esp, 90h
    retn    4
    sub_4BB260 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB2C0 proc near                    ; CODE XREF: .text:004352F4p
                                            ; .text:0049E647p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    offset aAB                      ; "a+b"
    push    eax
    call    sub_4BB2E0
    retn    4
    sub_4BB2C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB2E0 proc near                    ; CODE XREF: sub_4BB2C0+Ap
                                            ; sub_4BB5B0+Ap ...

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h

    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    push    118h
    push    offset aFileHandle              ; "File Handle"
    mov     esi, eax
    call    sub_4D83B0
    mov     ebp, eax
    mov     ecx, 46h
    xor     eax, eax
    mov     edi, ebp
    add     esp, 8
    rep stosd
    mov     edi, [esp+arg_0]
    push    100h                            ; size_t
    lea     eax, [ebp+18h]
    push    edi                             ; char *
    push    eax                             ; char *
    call    _strncpy
    mov     ecx, [esp+0Ch+arg_4]
    add     esp, 0Ch
    mov     byte ptr [ebp+117h], 0
    push    ecx
    push    edi
    call    _fopen
    xor     ebx, ebx
    add     esp, 8
    cmp     eax, ebx
    mov     [ebp+0], eax
    jz      short loc_4BB34A
    mov     [ebp+4], ebx
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BB34A:                             ; CODE XREF: sub_4BB2E0+5Cj
    cmp     [esi+61Ch], ebx
    jle     loc_4BB4C8
    jmp     short loc_4BB35C
    ; ---------------------------------------------------------------------------

    loc_4BB358:                             ; CODE XREF: sub_4BB2E0+A7j
    mov     edi, [esp+arg_0]

    loc_4BB35C:                             ; CODE XREF: sub_4BB2E0+76j
    mov     edx, [esi+618h]
    push    edi                             ; char *
    mov     eax, [edx+ebx*4]
    mov     ecx, [eax+8]
    mov     edx, [ecx+10h]
    push    edx                             ; int
    call    sub_4BB4E0
    mov     edi, eax
    test    edi, edi
    jz      short loc_4BB37E
    test    byte ptr [edi+8], 1
    jz      short loc_4BB39B

    loc_4BB37E:                             ; CODE XREF: sub_4BB2E0+96j
    mov     eax, [esi+61Ch]
    inc     ebx
    cmp     ebx, eax
    jl      short loc_4BB358
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BB39B:                             ; CODE XREF: sub_4BB2E0+9Cj
    mov     eax, [esi+618h]
    shl     ebx, 2
    mov     eax, [ebx+eax]
    cmp     dword ptr [eax], 0
    jnz     short loc_4BB3E1
    add     eax, 14h
    push    offset aRb                      ; "rb"
    push    eax
    call    _fopen
    mov     ecx, [esi+618h]
    add     esp, 8
    mov     edx, [ebx+ecx]
    mov     [edx], eax
    mov     eax, [esi+618h]
    mov     eax, [ebx+eax]
    cmp     dword ptr [eax], 0
    jz      loc_4BB4C8
    mov     dword ptr [eax+4], 0

    loc_4BB3E1:                             ; CODE XREF: sub_4BB2E0+CAj
    mov     ecx, [esi+618h]
    mov     eax, [ebx+ecx]
    mov     edx, [eax+0Ch]
    inc     edx
    mov     [eax+0Ch], edx
    mov     edx, [edi+4]
    mov     [ebp+8], edx
    mov     eax, [esi+618h]
    mov     ecx, [ebx+eax]
    mov     eax, edx
    mov     [ebp+4], ecx
    mov     dword ptr [ebp+0Ch], 0
    mov     cl, [eax+8]
    test    cl, cl
    jz      loc_4BB4BF
    mov     ecx, [eax+4]
    mov     eax, ecx
    cdq
    and     edx, 0FFFFh
    add     eax, edx
    mov     esi, eax
    mov     eax, ecx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 0FFFFh
    xor     eax, edx
    sub     eax, edx
    sar     esi, 10h
    neg     eax
    sbb     eax, eax
    neg     eax
    add     esi, eax
    shl     esi, 2
    push    esi
    push    offset aBlockSizes              ; "Block Sizes"
    call    sub_4D83B0
    mov     edx, [ebp+8]
    mov     [ebp+10h], eax
    mov     eax, [ebp+4]
    add     esp, 8
    mov     ebx, [edx]
    mov     ecx, [eax]
    push    0
    push    ebx
    push    ecx
    call    _fseek
    mov     edx, [ebp+4]
    mov     ecx, [ebp+10h]
    add     esp, 0Ch
    mov     eax, [edx]
    push    eax
    push    esi
    push    1
    push    ecx
    call    sub_4E5BC0
    mov     eax, [ebp+4]
    lea     edx, [ebx+esi]
    add     esp, 10h
    mov     [eax+4], edx
    mov     ecx, [ebp+4]
    mov     edi, [ebp+10h]
    mov     edx, [ecx+8]
    mov     cl, [edx+0Ch]
    test    cl, cl
    mov     byte ptr [esp+arg_0], cl
    jz      short loc_4BB4BF
    xor     eax, eax
    test    esi, esi
    jle     short loc_4BB4BF
    jmp     short loc_4BB4AA
    ; ---------------------------------------------------------------------------

    loc_4BB4A6:                             ; CODE XREF: sub_4BB2E0+1DDj
    mov     cl, byte ptr [esp+arg_0]

    loc_4BB4AA:                             ; CODE XREF: sub_4BB2E0+1C4j
    mov     dl, al
    add     dl, bl
    xor     dl, cl
    mov     cl, [edi+eax]
    not     cl
    xor     dl, cl
    mov     [edi+eax], dl
    inc     eax
    cmp     eax, esi
    jl      short loc_4BB4A6

    loc_4BB4BF:                             ; CODE XREF: sub_4BB2E0+131j
                                            ; sub_4BB2E0+1BCj ...
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BB4C8:                             ; CODE XREF: sub_4BB2E0+70j
                                            ; sub_4BB2E0+F4j
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    sub_4BB2E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    ; int __stdcall sub_4BB4E0(int,char *)
    sub_4BB4E0 proc near                    ; CODE XREF: sub_4BB2E0+8Dp
                                            ; sub_4BE400+247p

    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebp
    mov     ebp, esp
    push    ecx
    push    ebx
    mov     ebx, [ebp+arg_4]
    push    esi
    push    edi

    loc_4BB4EA:                             ; CODE XREF: sub_4BB4E0+9Ej
    push    5Ch                             ; int
    push    ebx                             ; char *
    call    _strchr
    add     esp, 8
    mov     [ebp+var_4], eax
    test    eax, eax
    jz      short loc_4BB527
    mov     esi, eax
    sub     esi, ebx
    lea     eax, [esi+1]
    add     eax, 3
    and     al, 0FCh
    call    __alloca_probe
    mov     edi, esp
    push    esi                             ; size_t
    push    ebx                             ; char *
    push    edi                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [edi+esi], 0
    mov     [ebp+arg_4], 0
    jmp     short loc_4BB530
    ; ---------------------------------------------------------------------------

    loc_4BB527:                             ; CODE XREF: sub_4BB4E0+1Aj
    mov     edi, ebx
    mov     [ebp+arg_4], 1

    loc_4BB530:                             ; CODE XREF: sub_4BB4E0+45j
    mov     eax, [ebp+arg_0]
    mov     esi, [eax]
    dec     esi
    lea     ebx, [esi+esi*8]

    loc_4BB539:                             ; CODE XREF: sub_4BB4E0+78j
    test    esi, esi
    jl      short loc_4BB598
    mov     ecx, [ebp+arg_0]
    mov     edx, [ecx+4]
    mov     eax, [edx+ebx]
    push    eax                             ; char *
    push    edi                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4BB55A
    dec     esi
    sub     ebx, 9
    jmp     short loc_4BB539
    ; ---------------------------------------------------------------------------

    loc_4BB55A:                             ; CODE XREF: sub_4BB4E0+72j
    mov     eax, [ebp+arg_4]
    test    eax, eax
    jnz     short loc_4BB583
    mov     edx, [ebp+arg_0]
    lea     ecx, [esi+esi*8]
    mov     eax, [edx+4]
    add     eax, ecx
    test    byte ptr [eax+8], 1
    jz      short loc_4BB598
    mov     ecx, [ebp+var_4]
    mov     edx, [eax+4]
    mov     [ebp+arg_0], edx
    lea     ebx, [ecx+1]
    jmp     loc_4BB4EA
    ; ---------------------------------------------------------------------------

    loc_4BB583:                             ; CODE XREF: sub_4BB4E0+7Fj
    mov     ecx, [ebp+arg_0]
    lea     eax, [esi+esi*8]
    add     eax, [ecx+4]
    lea     esp, [ebp-10h]
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BB598:                             ; CODE XREF: sub_4BB4E0+5Bj
                                            ; sub_4BB4E0+90j
    lea     esp, [ebp-10h]
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    8
    sub_4BB4E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB5B0 proc near                    ; CODE XREF: .text:0041780Cp
                                            ; sub_417890+14Cp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    offset aRb                      ; "rb"
    push    eax
    call    sub_4BB2E0
    retn    4
    sub_4BB5B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB5D0 proc near                    ; CODE XREF: .text:00417864p
                                            ; sub_417890+1A1p ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4BB60F
    mov     edx, [eax+0Ch]
    xor     edi, edi
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [esi+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BB61C
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BB61C
    mov     eax, [eax]
    push    eax
    call    _fclose
    mov     ecx, [esi+4]
    add     esp, 4
    mov     edi, eax
    mov     dword ptr [ecx], 0
    jmp     short loc_4BB61C
    ; ---------------------------------------------------------------------------

    loc_4BB60F:                             ; CODE XREF: sub_4BB5D0+Bj
    mov     edx, [esi]
    push    edx
    call    _fclose
    add     esp, 4
    mov     edi, eax

    loc_4BB61C:                             ; CODE XREF: sub_4BB5D0+1Ej
                                            ; sub_4BB5D0+25j ...
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4BB62C
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BB62C:                             ; CODE XREF: sub_4BB5D0+51j
    mov     eax, [esi+14h]
    test    eax, eax
    jz      short loc_4BB63C
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BB63C:                             ; CODE XREF: sub_4BB5D0+61j
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn    4
    sub_4BB5D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB650 proc near                    ; CODE XREF: sub_42A8D0+7DEp
                                            ; sub_4C2F60+6Bp

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    xor     eax, eax
    mov     edx, [ecx+4]
    test    edx, edx
    setnz   al
    retn    4
    sub_4BB650 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    esi
    mov     esi, ecx
    push    100h
    push    eax
    lea     ecx, [esi+18h]
    push    ecx
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [esi+117h], 0
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB6A0 proc near                    ; CODE XREF: .text:0049E657p
                                            ; .text:004AE6A2p

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    offset aWB                      ; "w+b"
    push    ebx
    call    _fopen
    mov     ebp, eax
    add     esp, 8
    test    ebp, ebp
    jz      short loc_4BB706
    push    edi
    push    esi
    push    118h
    push    offset aFileHandle              ; "File Handle"
    call    sub_4D83B0
    mov     esi, eax
    add     esp, 8
    mov     ecx, 46h
    xor     eax, eax
    mov     edi, esi
    push    100h                            ; size_t
    rep stosd
    lea     eax, [esi+18h]
    push    ebx                             ; char *
    push    eax                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [esi+117h], 0
    mov     [esi], ebp
    mov     dword ptr [esi+4], 0
    mov     eax, esi
    pop     esi
    pop     edi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BB706:                             ; CODE XREF: sub_4BB6A0+18j
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    4
    sub_4BB6A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB710 proc near                    ; CODE XREF: sub_4295B0+3Cp
                                            ; sub_4373A0+DFp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_0]
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4BB75D
    mov     ecx, [esp+arg_4]
    mov     eax, [esi+0Ch]
    cmp     ecx, 0FFFFFFFFh
    jnz     short loc_4BB733
    mov     ecx, [esi+8]
    mov     edx, [ecx+4]
    mov     [esi+0Ch], edx
    jmp     short loc_4BB736
    ; ---------------------------------------------------------------------------

    loc_4BB733:                             ; CODE XREF: sub_4BB710+16j
    mov     [esi+0Ch], ecx

    loc_4BB736:                             ; CODE XREF: sub_4BB710+21j
    xor     eax, [esi+0Ch]
    test    eax, 0FFFF0000h
    jz      short loc_4BB757
    mov     eax, [esi+14h]
    test    eax, eax
    jz      short loc_4BB757
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+14h], 0

    loc_4BB757:                             ; CODE XREF: sub_4BB710+2Ej
                                            ; sub_4BB710+35j
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BB75D:                             ; CODE XREF: sub_4BB710+Aj
    mov     eax, [esp+arg_4]
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_4BB76F
    mov     eax, [esi]
    push    2
    push    0
    push    eax
    jmp     short loc_4BB775
    ; ---------------------------------------------------------------------------

    loc_4BB76F:                             ; CODE XREF: sub_4BB710+54j
    mov     ecx, [esi]
    push    0
    push    eax
    push    ecx

    loc_4BB775:                             ; CODE XREF: sub_4BB710+5Dj
    call    _fseek
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4BB788
    or      eax, 0FFFFFFFFh
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BB788:                             ; CODE XREF: sub_4BB710+6Fj
    mov     edx, [esi]
    push    edx
    call    _ftell
    add     esp, 4
    pop     esi
    retn    8
    sub_4BB710 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB7A0 proc near                    ; CODE XREF: sub_4B3770+1ECp
                                            ; sub_4B3770+20Dp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+4]
    test    ecx, ecx
    jz      short loc_4BB7B1
    mov     eax, [eax+0Ch]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BB7B1:                             ; CODE XREF: sub_4BB7A0+9j
    mov     eax, [eax]
    push    eax
    call    _ftell
    add     esp, 4
    retn    4
    sub_4BB7A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BB7C0 proc near                    ; CODE XREF: sub_4295B0+2Ap
                                            ; sub_4295B0+49p ...

    var_409= byte ptr -409h
    var_408= dword ptr -408h
    var_404= dword ptr -404h
    var_400= dword ptr -400h
    var_3FC= dword ptr -3FCh
    var_3F8= dword ptr -3F8h
    var_3F4= dword ptr -3F4h
    var_3F0= dword ptr -3F0h
    var_3EC= dword ptr -3ECh
    Text= byte ptr -3E8h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 40Ch
    push    ebx
    push    ebp
    mov     ebp, [esp+414h+arg_0]
    push    esi
    push    edi
    mov     edi, [ebp+4]
    test    edi, edi
    jz      loc_4BBB9F
    mov     esi, [ebp+8]
    mov     eax, [ebp+0Ch]
    mov     ebx, [esp+41Ch+arg_8]
    mov     ecx, [esi+4]
    mov     [esp+41Ch+var_408], ebx
    mov     edx, ecx
    sub     edx, eax
    cmp     edx, ebx
    jge     short loc_4BB7FC
    mov     [esp+41Ch+var_408], edx

    loc_4BB7FC:                             ; CODE XREF: sub_4BB7C0+36j
    mov     dl, [esi+8]
    test    dl, dl
    jz      loc_4BBB08
    mov     ebx, [esp+41Ch+var_408]
    mov     [esp+41Ch+var_3F8], 0
    mov     [esp+41Ch+var_400], ebx
    lea     esi, [ebx+eax-1]
    and     eax, 0FFFF0000h
    and     esi, 0FFFF0000h
    sub     esi, eax
    mov     eax, ecx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 0FFFFh
    xor     eax, edx
    mov     edi, eax
    mov     eax, ecx
    shr     esi, 10h
    sub     edi, edx
    inc     esi
    neg     edi
    cdq
    sbb     edi, edi
    and     edx, 0FFFFh
    add     eax, edx
    mov     [esp+41Ch+var_3F4], esi
    neg     edi
    sar     eax, 10h
    add     edi, eax
    mov     eax, [esp+41Ch+arg_4]
    shl     edi, 2
    test    esi, esi
    mov     [esp+41Ch+var_3F0], edi
    mov     [esp+41Ch+var_404], eax
    jle     loc_4BBBC1

    loc_4BB872:                             ; CODE XREF: sub_4BB7C0+301j
    mov     ecx, [ebp+0Ch]
    mov     eax, [ebp+14h]
    shr     ecx, 10h
    test    eax, eax
    mov     [esp+41Ch+var_3EC], ecx
    jnz     loc_4BBA44
    xor     esi, esi
    mov     eax, edi
    test    ecx, ecx
    jle     short loc_4BB89E
    mov     edx, [ebp+10h]
    mov     esi, ecx

    loc_4BB894:                             ; CODE XREF: sub_4BB7C0+DCj
    mov     edi, [edx]
    add     edx, 4
    add     eax, edi
    dec     ecx
    jnz     short loc_4BB894

    loc_4BB89E:                             ; CODE XREF: sub_4BB7C0+CDj
    mov     ecx, [ebp+8]
    push    0
    mov     edx, [ecx]
    add     eax, edx
    mov     edx, [ebp+4]
    mov     ebx, eax
    mov     eax, [edx]
    push    ebx
    push    eax
    call    _fseek
    mov     ecx, [ebp+4]
    add     esp, 0Ch
    push    10000h
    push    offset aUncompressedBl          ; "Uncompressed Block"
    mov     [ecx+4], ebx
    call    sub_4D83B0
    mov     edx, [ebp+10h]
    lea     edi, ds:0[esi*4]
    add     esp, 8
    mov     [ebp+14h], eax
    mov     eax, [edi+edx]
    push    eax
    push    offset aCompressedBuff          ; "Compressed Buffer"
    call    sub_4D83B0
    mov     ecx, [ebp+4]
    add     esp, 8
    mov     [esp+41Ch+var_3FC], eax
    mov     edx, [ecx]
    mov     ecx, [ebp+10h]
    push    edx
    mov     edx, [edi+ecx]
    push    edx
    push    1
    push    eax
    call    sub_4E5BC0
    mov     esi, eax
    mov     eax, [ebp+10h]
    add     esp, 10h
    cmp     esi, [edi+eax]
    jnz     loc_4BBAD8
    mov     eax, [ebp+4]
    mov     edx, [eax+4]
    add     edx, esi
    mov     [eax+4], edx
    mov     ecx, [ebp+4]
    mov     edx, [ecx+8]
    mov     al, [edx+0Ch]
    test    al, al
    mov     [esp+41Ch+var_409], al
    jz      short loc_4BB959
    xor     ecx, ecx
    test    esi, esi
    jle     short loc_4BB959
    jmp     short loc_4BB940
    ; ---------------------------------------------------------------------------

    loc_4BB93C:                             ; CODE XREF: sub_4BB7C0+197j
    mov     al, [esp+41Ch+var_409]

    loc_4BB940:                             ; CODE XREF: sub_4BB7C0+17Aj
    mov     edi, [esp+41Ch+var_3FC]
    mov     dl, cl
    add     dl, bl
    xor     dl, al
    mov     al, [ecx+edi]
    not     al
    xor     dl, al
    mov     [ecx+edi], dl
    inc     ecx
    cmp     ecx, esi
    jl      short loc_4BB93C

    loc_4BB959:                             ; CODE XREF: sub_4BB7C0+172j
                                            ; sub_4BB7C0+178j
    mov     esi, [esp+41Ch+var_3FC]
    mov     ecx, [ebp+14h]
    push    esi
    push    ecx
    call    sub_4D1970
    test    eax, eax
    jz      loc_4BBA2F
    push    eax
    call    sub_4D1C60
    push    eax
    lea     edx, [esp+420h+Text]
    push    offset aHapi_readfromf          ; "[HAPI_readfromfile] Decompression Error"...
    push    edx
    call    _sprintf
    mov     eax, [esp+428h+var_3F4]
    mov     ecx, [esp+428h+var_3F8]
    add     esp, 0Ch
    lea     edi, [esp+41Ch+Text]
    push    eax
    push    ecx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    offset aBlockDOfD               ; "block %d of %d\n"
    lea     edx, [esp+ecx+428h+Text]
    push    edx
    call    _sprintf
    mov     eax, [ebp+4]
    add     esp, 10h
    add     eax, 14h
    lea     edi, [esp+41Ch+Text]
    push    eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    offset aBaseNameS               ; "base name '%s'\n"
    repne scasb
    not     ecx
    dec     ecx
    lea     ecx, [esp+ecx+424h+Text]
    push    ecx
    call    _sprintf
    lea     edi, [esp+428h+Text]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [esp+41Ch+arg_8]
    not     ecx
    dec     ecx
    push    edx
    push    offset aLengthD                 ; "length = %d\n"
    lea     eax, [esp+ecx+424h+Text]
    push    eax
    call    _sprintf
    add     esp, 0Ch
    lea     ecx, [ebp+18h]
    lea     edi, [esp+41Ch+Text]
    xor     eax, eax
    push    ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    push    offset aNameS                   ; "name = '%s'\n"
    lea     edx, [esp+ecx+424h+Text]
    push    edx
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+41Ch+Text]
    push    eax                             ; lpText
    call    sub_4B6290

    loc_4BBA2F:                             ; CODE XREF: sub_4BB7C0+1A9j
    push    esi                             ; int
    call    sub_4D85A0
    mov     ecx, [esp+420h+var_3EC]
    mov     esi, [esp+420h+var_3F4]
    mov     edi, [esp+420h+var_3F0]
    add     esp, 4

    loc_4BBA44:                             ; CODE XREF: sub_4BB7C0+C1j
    mov     eax, [ebp+0Ch]
    lea     ebx, [ecx+1]
    mov     ecx, [esp+41Ch+var_400]
    shl     ebx, 10h
    sub     ebx, eax
    cmp     ebx, ecx
    jle     short loc_4BBA59
    mov     ebx, ecx

    loc_4BBA59:                             ; CODE XREF: sub_4BB7C0+295j
    and     eax, 0FFFFh
    cmp     ebx, 1
    jnz     short loc_4BBA71
    mov     ecx, [ebp+14h]
    mov     dl, [eax+ecx]
    mov     eax, [esp+41Ch+var_404]
    mov     [eax], dl
    jmp     short loc_4BBA94
    ; ---------------------------------------------------------------------------

    loc_4BBA71:                             ; CODE XREF: sub_4BB7C0+2A1j
    mov     edx, [ebp+14h]
    mov     edi, [esp+41Ch+var_404]
    mov     esi, eax
    mov     ecx, ebx
    add     esi, edx
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [esp+41Ch+var_3F4]
    mov     edi, [esp+41Ch+var_3F0]

    loc_4BBA94:                             ; CODE XREF: sub_4BB7C0+2AFj
    mov     ecx, [ebp+0Ch]
    mov     edx, [esp+41Ch+var_404]
    mov     eax, ebx
    add     edx, ebx
    add     eax, ecx
    mov     [esp+41Ch+var_404], edx
    push    eax
    push    ebp
    call    sub_4BB710
    mov     eax, [esp+41Ch+var_400]
    sub     eax, ebx
    mov     [esp+41Ch+var_400], eax
    mov     eax, [esp+41Ch+var_3F8]
    inc     eax
    cmp     eax, esi
    mov     [esp+41Ch+var_3F8], eax
    jl      loc_4BB872
    mov     eax, [esp+41Ch+var_408]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BBAD8:                             ; CODE XREF: sub_4BB7C0+152j
    mov     ecx, [ebp+14h]
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edx, [esp+420h+var_3FC]
    add     esp, 4
    mov     dword ptr [ebp+14h], 0
    push    edx                             ; int
    call    sub_4D85A0
    add     esp, 4
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BBB08:                             ; CODE XREF: sub_4BB7C0+41j
    add     eax, [esi]
    mov     ebx, eax
    mov     eax, [edi+4]
    cmp     ebx, eax
    jz      short loc_4BBB27
    mov     eax, [edi]
    push    0
    push    ebx
    push    eax
    call    _fseek
    mov     ecx, [ebp+4]
    add     esp, 0Ch
    mov     [ecx+4], ebx

    loc_4BBB27:                             ; CODE XREF: sub_4BB7C0+351j
    mov     edx, [ebp+4]
    mov     ecx, [esp+41Ch+var_408]
    mov     esi, [esp+41Ch+arg_4]
    mov     eax, [edx]
    push    eax
    push    ecx
    push    1
    push    esi
    call    sub_4E5BC0
    mov     edx, [ebp+4]
    mov     edi, eax
    add     esp, 10h
    mov     [esp+41Ch+var_408], edi
    mov     eax, [edx+8]
    mov     al, [eax+0Ch]
    test    al, al
    mov     [esp+41Ch+var_409], al
    jz      short loc_4BBB7C
    xor     ecx, ecx
    test    edi, edi
    jle     short loc_4BBB7E
    jmp     short loc_4BBB67
    ; ---------------------------------------------------------------------------

    loc_4BBB63:                             ; CODE XREF: sub_4BB7C0+3BAj
    mov     al, [esp+41Ch+var_409]

    loc_4BBB67:                             ; CODE XREF: sub_4BB7C0+3A1j
    mov     dl, cl
    add     dl, bl
    xor     dl, al
    mov     al, [ecx+esi]
    not     al
    xor     dl, al
    mov     [ecx+esi], dl
    inc     ecx
    cmp     ecx, edi
    jl      short loc_4BBB63

    loc_4BBB7C:                             ; CODE XREF: sub_4BB7C0+399j
    test    edi, edi

    loc_4BBB7E:                             ; CODE XREF: sub_4BB7C0+39Fj
    jl      short loc_4BBBC1
    mov     eax, [esp+41Ch+var_408]
    mov     edx, [ebp+0Ch]
    add     edx, eax
    mov     [ebp+0Ch], edx
    mov     ebp, [ebp+4]
    add     [ebp+4], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BBB9F:                             ; CODE XREF: sub_4BB7C0+16j
    mov     ecx, [ebp+0]
    mov     edx, [esp+41Ch+arg_8]
    mov     eax, [esp+41Ch+arg_4]
    push    ecx
    push    edx
    push    1
    push    eax
    call    sub_4E5BC0
    add     esp, 10h
    mov     [esp+41Ch+var_408], eax

    loc_4BBBC1:                             ; CODE XREF: sub_4BB7C0+ACj
                                            ; sub_4BB7C0+3BEj
    mov     eax, [esp+41Ch+var_408]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40Ch
    retn    0Ch
    sub_4BB7C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BBBE0 proc near                    ; CODE XREF: .text:0049E670p
                                            ; sub_4ACCD0+1Cp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+4]
    test    ecx, ecx
    jz      short loc_4BBBF1
    or      eax, 0FFFFFFFFh
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BBBF1:                             ; CODE XREF: sub_4BBBE0+9j
    mov     eax, [eax]
    mov     ecx, [esp+arg_8]
    mov     edx, [esp+arg_4]
    push    eax
    push    ecx
    push    1
    push    edx
    call    sub_4E5D40
    add     esp, 10h
    retn    0Ch
    sub_4BBBE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4BBC10(LPCSTR lpExistingFileName,LPCSTR lpNewFileName)
    sub_4BBC10 proc near                    ; CODE XREF: .text:004AE695p

    lpExistingFileName= dword ptr  4
    lpNewFileName= dword ptr  8

    mov     eax, [esp+lpNewFileName]
    mov     ecx, [esp+lpExistingFileName]
    push    eax                             ; lpNewFileName
    push    ecx                             ; lpExistingFileName
    call    sub_4E7950
    add     esp, 8
    retn    8
    sub_4BBC10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4BBC30(LPCSTR lpFileName)
    sub_4BBC30 proc near                    ; CODE XREF: sub_429330+DEp
                                            ; sub_429330+101p ...

    lpFileName= dword ptr  4

    mov     eax, [esp+lpFileName]
    push    eax                             ; lpFileName
    call    _remove
    add     esp, 4
    retn    4
    sub_4BBC30 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BBC40 proc near                    ; CODE XREF: sub_41ACE0+78p
                                            ; sub_41DA60+10Ap ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    push    offset aRb                      ; "rb"
    push    eax
    call    sub_4BB2E0
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4BBC5A
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BBC5A:                             ; CODE XREF: sub_4BBC40+14j
    mov     eax, [esi+4]
    push    edi
    test    eax, eax
    jz      short loc_4BBC6A
    mov     ecx, [esi+8]
    mov     edi, [ecx+4]
    jmp     short loc_4BBC82
    ; ---------------------------------------------------------------------------

    loc_4BBC6A:                             ; CODE XREF: sub_4BBC40+20j
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4BBC80
    mov     edx, [eax+10h]
    push    edx
    call    __filelength
    add     esp, 4
    mov     edi, eax
    jmp     short loc_4BBC82
    ; ---------------------------------------------------------------------------

    loc_4BBC80:                             ; CODE XREF: sub_4BBC40+2Ej
    xor     edi, edi

    loc_4BBC82:                             ; CODE XREF: sub_4BBC40+28j
                                            ; sub_4BBC40+3Ej
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4BBCB7
    mov     edx, [eax+0Ch]
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [esi+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BBCC2
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BBCC2
    mov     eax, [eax]
    push    eax
    call    _fclose
    mov     ecx, [esi+4]
    add     esp, 4
    mov     dword ptr [ecx], 0
    jmp     short loc_4BBCC2
    ; ---------------------------------------------------------------------------

    loc_4BBCB7:                             ; CODE XREF: sub_4BBC40+47j
    mov     edx, [esi]
    push    edx
    call    _fclose
    add     esp, 4

    loc_4BBCC2:                             ; CODE XREF: sub_4BBC40+58j
                                            ; sub_4BBC40+5Fj ...
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4BBCD2
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BBCD2:                             ; CODE XREF: sub_4BBC40+87j
    mov     eax, [esi+14h]
    test    eax, eax
    jz      short loc_4BBCE2
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BBCE2:                             ; CODE XREF: sub_4BBC40+97j
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn    4
    sub_4BBC40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BBD00 proc near                    ; CODE XREF: sub_4295B0+1Dp
                                            ; sub_429660+1Cp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     ecx, [eax+4]
    test    ecx, ecx
    jz      short loc_4BBD14
    mov     eax, [eax+8]
    mov     eax, [eax+4]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BBD14:                             ; CODE XREF: sub_4BBD00+9j
    mov     eax, [eax]
    test    eax, eax
    jz      short loc_4BBD29
    mov     ecx, [eax+10h]
    push    ecx
    call    __filelength
    add     esp, 4
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BBD29:                             ; CODE XREF: sub_4BBD00+18j
    xor     eax, eax
    retn    4
    sub_4BBD00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BBD30 proc near                    ; CODE XREF: .text:00435386p
                                            ; sub_435DA0+4CFp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    push    esi
    push    edi
    push    offset aRb                      ; "rb"
    push    eax
    call    sub_4BB2E0
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4BBD4C
    pop     edi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4BBD4C:                             ; CODE XREF: sub_4BBD30+15j
    mov     ecx, [esp+8+arg_8]
    push    ecx
    push    esi
    call    sub_4BB710
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4BBD70
    mov     edx, [esp+8+arg_C]
    mov     edi, [esp+8+arg_4]
    push    edx
    push    edi
    push    esi
    call    sub_4BB7C0
    test    eax, eax
    jg      short loc_4BBDE0

    loc_4BBD70:                             ; CODE XREF: sub_4BBD30+2Aj
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4BBDA5
    mov     edx, [eax+0Ch]
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [esi+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BBDB0
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BBDB0
    mov     eax, [eax]
    push    eax
    call    _fclose
    mov     ecx, [esi+4]
    add     esp, 4
    mov     dword ptr [ecx], 0
    jmp     short loc_4BBDB0
    ; ---------------------------------------------------------------------------

    loc_4BBDA5:                             ; CODE XREF: sub_4BBD30+45j
    mov     edx, [esi]
    push    edx
    call    _fclose
    add     esp, 4

    loc_4BBDB0:                             ; CODE XREF: sub_4BBD30+56j
                                            ; sub_4BBD30+5Dj ...
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4BBDC0
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BBDC0:                             ; CODE XREF: sub_4BBD30+85j
    mov     eax, [esi+14h]
    test    eax, eax
    jz      short loc_4BBDD0
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BBDD0:                             ; CODE XREF: sub_4BBD30+95j
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4BBDE0:                             ; CODE XREF: sub_4BBD30+3Ej
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4BBE15
    mov     edx, [eax+0Ch]
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [esi+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BBE20
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BBE20
    mov     eax, [eax]
    push    eax
    call    _fclose
    mov     ecx, [esi+4]
    add     esp, 4
    mov     dword ptr [ecx], 0
    jmp     short loc_4BBE20
    ; ---------------------------------------------------------------------------

    loc_4BBE15:                             ; CODE XREF: sub_4BBD30+B5j
    mov     edx, [esi]
    push    edx
    call    _fclose
    add     esp, 4

    loc_4BBE20:                             ; CODE XREF: sub_4BBD30+C6j
                                            ; sub_4BBD30+CDj ...
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4BBE30
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BBE30:                             ; CODE XREF: sub_4BBD30+F5j
    mov     eax, [esi+14h]
    test    eax, eax
    jz      short loc_4BBE40
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BBE40:                             ; CODE XREF: sub_4BBD30+105j
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn    10h
    sub_4BBD30 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BBE50 proc near                    ; CODE XREF: .text:004264EFp
                                            ; .text:00429307p ...

    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 100h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+10Ch+arg_4]
    test    esi, esi
    push    edi
    jz      short loc_4BBE6B
    mov     dword ptr [esi], 0FFFFFFFFh

    loc_4BBE6B:                             ; CODE XREF: sub_4BBE50+13j
    mov     edi, [esp+110h+arg_0]
    push    offset aRb                      ; "rb"
    push    edi
    call    sub_4BB2E0
    mov     ebp, eax
    test    ebp, ebp
    jnz     short loc_4BBE90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BBE90:                             ; CODE XREF: sub_4BBE50+31j
    test    esi, esi
    jz      short loc_4BBE9A
    mov     dword ptr [esi], 0FFFFFFFFh

    loc_4BBE9A:                             ; CODE XREF: sub_4BBE50+42j
    mov     eax, [ebp+4]
    test    eax, eax
    jz      short loc_4BBEA9
    mov     eax, [ebp+8]
    mov     ebx, [eax+4]
    jmp     short loc_4BBEC2
    ; ---------------------------------------------------------------------------

    loc_4BBEA9:                             ; CODE XREF: sub_4BBE50+4Fj
    mov     eax, [ebp+0]
    test    eax, eax
    jz      short loc_4BBEC0
    mov     ecx, [eax+10h]
    push    ecx
    call    __filelength
    add     esp, 4
    mov     ebx, eax
    jmp     short loc_4BBEC2
    ; ---------------------------------------------------------------------------

    loc_4BBEC0:                             ; CODE XREF: sub_4BBE50+5Ej
    xor     ebx, ebx

    loc_4BBEC2:                             ; CODE XREF: sub_4BBE50+57j
                                            ; sub_4BBE50+6Ej
    test    ebx, ebx
    jg      short loc_4BBECD
    xor     esi, esi
    jmp     loc_4BBF6C
    ; ---------------------------------------------------------------------------

    loc_4BBECD:                             ; CODE XREF: sub_4BBE50+74j
    push    0
    push    ebp
    call    sub_4BB710
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_4BBEE1
    xor     esi, esi
    jmp     loc_4BBF6C
    ; ---------------------------------------------------------------------------

    loc_4BBEE1:                             ; CODE XREF: sub_4BBE50+88j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+110h+var_100]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+110h+var_100]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [ecx-1]
    test    eax, eax
    jl      short loc_4BBF22
    mov     cl, 5Ch

    loc_4BBF19:                             ; CODE XREF: sub_4BBE50+D0j
    cmp     byte ptr [esp+eax+110h+var_100], cl
    jz      short loc_4BBF22
    dec     eax
    jns     short loc_4BBF19

    loc_4BBF22:                             ; CODE XREF: sub_4BBE50+C5j
                                            ; sub_4BBE50+CDj
    lea     eax, [esp+eax+110h+var_100+1]
    lea     ecx, [esp+110h+var_100]

    loc_4BBF2A:                             ; CODE XREF: sub_4BBE50+E4j
    mov     dl, [eax]
    mov     [ecx], dl
    mov     dl, [eax]
    inc     ecx
    inc     eax
    test    dl, dl
    jnz     short loc_4BBF2A
    lea     eax, [esp+110h+var_100]
    push    ebx
    push    eax
    call    sub_4D83B0
    add     esp, 8
    mov     esi, eax
    push    ebx
    push    esi
    push    ebp
    call    sub_4BB7C0
    test    eax, eax
    jg      short loc_4BBF5F
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     esi, esi
    jmp     short loc_4BBF6C
    ; ---------------------------------------------------------------------------

    loc_4BBF5F:                             ; CODE XREF: sub_4BBE50+100j
    mov     eax, [esp+110h+arg_4]
    test    eax, eax
    jz      short loc_4BBF6C
    mov     [eax], ebx

    loc_4BBF6C:                             ; CODE XREF: sub_4BBE50+78j
                                            ; sub_4BBE50+8Cj ...
    mov     eax, [ebp+4]
    test    eax, eax
    jz      short loc_4BBFA1
    mov     edx, [eax+0Ch]
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [ebp+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BBFAD
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BBFAD
    mov     ecx, [eax]
    push    ecx
    call    _fclose
    mov     edx, [ebp+4]
    add     esp, 4
    mov     dword ptr [edx], 0
    jmp     short loc_4BBFAD
    ; ---------------------------------------------------------------------------

    loc_4BBFA1:                             ; CODE XREF: sub_4BBE50+121j
    mov     eax, [ebp+0]
    push    eax
    call    _fclose
    add     esp, 4

    loc_4BBFAD:                             ; CODE XREF: sub_4BBE50+132j
                                            ; sub_4BBE50+139j ...
    mov     eax, [ebp+10h]
    test    eax, eax
    jz      short loc_4BBFBD
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BBFBD:                             ; CODE XREF: sub_4BBE50+162j
    mov     eax, [ebp+14h]
    test    eax, eax
    jz      short loc_4BBFCD
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BBFCD:                             ; CODE XREF: sub_4BBE50+172j
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    8
    sub_4BBE50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BBFF0 proc near                    ; CODE XREF: .text:0041783Dp
                                            ; sub_417890+17Ep ...

    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    sub     esp, 100h
    test    eax, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    jz      short loc_4BC008
    mov     dword ptr [eax], 0FFFFFFFFh

    loc_4BC008:                             ; CODE XREF: sub_4BBFF0+10j
    mov     ebx, [esp+110h+arg_4]
    mov     eax, [ebx+4]
    test    eax, eax
    jz      short loc_4BC01E
    mov     eax, [ebx+8]
    mov     ebp, [eax+4]
    jmp     short loc_4BC036
    ; ---------------------------------------------------------------------------

    loc_4BC01E:                             ; CODE XREF: sub_4BBFF0+24j
    mov     eax, [ebx]
    test    eax, eax
    jz      short loc_4BC034
    mov     ecx, [eax+10h]
    push    ecx
    call    __filelength
    add     esp, 4
    mov     ebp, eax
    jmp     short loc_4BC036
    ; ---------------------------------------------------------------------------

    loc_4BC034:                             ; CODE XREF: sub_4BBFF0+32j
    xor     ebp, ebp

    loc_4BC036:                             ; CODE XREF: sub_4BBFF0+2Cj
                                            ; sub_4BBFF0+42j
    test    ebp, ebp
    jg      short loc_4BC049
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BC049:                             ; CODE XREF: sub_4BBFF0+48j
    push    0
    push    ebx
    call    sub_4BB710
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_4BC065
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BC065:                             ; CODE XREF: sub_4BBFF0+64j
    mov     edi, [esp+110h+arg_0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+110h+var_100]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+110h+var_100]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [ecx-1]
    test    eax, eax
    jl      short loc_4BC0AD
    mov     cl, 5Ch

    loc_4BC0A4:                             ; CODE XREF: sub_4BBFF0+BBj
    cmp     byte ptr [esp+eax+110h+var_100], cl
    jz      short loc_4BC0AD
    dec     eax
    jns     short loc_4BC0A4

    loc_4BC0AD:                             ; CODE XREF: sub_4BBFF0+B0j
                                            ; sub_4BBFF0+B8j
    lea     eax, [esp+eax+110h+var_100+1]
    lea     ecx, [esp+110h+var_100]

    loc_4BC0B5:                             ; CODE XREF: sub_4BBFF0+CFj
    mov     dl, [eax]
    mov     [ecx], dl
    mov     dl, [eax]
    inc     ecx
    inc     eax
    test    dl, dl
    jnz     short loc_4BC0B5
    lea     eax, [esp+110h+var_100]
    push    ebp
    push    eax
    call    sub_4D83B0
    add     esp, 8
    mov     esi, eax
    push    ebp
    push    esi
    push    ebx
    call    sub_4BB7C0
    test    eax, eax
    jg      short loc_4BC0F5
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BC0F5:                             ; CODE XREF: sub_4BBFF0+EBj
    mov     eax, [esp+110h+arg_8]
    test    eax, eax
    jz      short loc_4BC102
    mov     [eax], ebp

    loc_4BC102:                             ; CODE XREF: sub_4BBFF0+10Ej
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    0Ch
    sub_4BBFF0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    ebx
    push    esi
    push    edi
    push    offset aRb                      ; "rb"
    push    eax
    call    sub_4BB2E0
    mov     esi, eax
    test    esi, esi
    jz      loc_4BC274
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4BC14B
    mov     ecx, [esi+8]
    mov     edi, [ecx+4]
    jmp     short loc_4BC163
    ; ---------------------------------------------------------------------------

    loc_4BC14B:                             ; CODE XREF: .text:004BC141j
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4BC161
    mov     edx, [eax+10h]
    push    edx
    call    __filelength
    add     esp, 4
    mov     edi, eax
    jmp     short loc_4BC163
    ; ---------------------------------------------------------------------------

    loc_4BC161:                             ; CODE XREF: .text:004BC14Fj
    xor     edi, edi

    loc_4BC163:                             ; CODE XREF: .text:004BC149j
                                            ; .text:004BC15Fj
    test    edi, edi
    jle     short loc_4BC185
    push    0
    push    esi
    call    sub_4BB710
    test    eax, eax
    jl      short loc_4BC185
    mov     ebx, [esp+14h]
    push    edi
    push    ebx
    push    esi
    call    sub_4BB7C0
    mov     edi, eax
    test    edi, edi
    jge     short loc_4BC1FE

    loc_4BC185:                             ; CODE XREF: .text:004BC165j
                                            ; .text:004BC171j
    test    esi, esi
    jz      loc_4BC274
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4BC1C2
    mov     edx, [eax+0Ch]
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [esi+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BC1CD
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BC1CD
    mov     eax, [eax]
    push    eax
    call    _fclose
    mov     ecx, [esi+4]
    add     esp, 4
    mov     dword ptr [ecx], 0
    jmp     short loc_4BC1CD
    ; ---------------------------------------------------------------------------

    loc_4BC1C2:                             ; CODE XREF: .text:004BC192j
    mov     edx, [esi]
    push    edx
    call    _fclose
    add     esp, 4

    loc_4BC1CD:                             ; CODE XREF: .text:004BC1A3j
                                            ; .text:004BC1AAj ...
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4BC1DD
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BC1DD:                             ; CODE XREF: .text:004BC1D2j
    mov     eax, [esi+14h]
    test    eax, eax
    jz      short loc_4BC1ED
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BC1ED:                             ; CODE XREF: .text:004BC1E2j
    push    esi
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BC1FE:                             ; CODE XREF: .text:004BC183j
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4BC233
    mov     edx, [eax+0Ch]
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [esi+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BC23E
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BC23E
    mov     eax, [eax]
    push    eax
    call    _fclose
    mov     ecx, [esi+4]
    add     esp, 4
    mov     dword ptr [ecx], 0
    jmp     short loc_4BC23E
    ; ---------------------------------------------------------------------------

    loc_4BC233:                             ; CODE XREF: .text:004BC203j
    mov     edx, [esi]
    push    edx
    call    _fclose
    add     esp, 4

    loc_4BC23E:                             ; CODE XREF: .text:004BC214j
                                            ; .text:004BC21Bj ...
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4BC24E
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BC24E:                             ; CODE XREF: .text:004BC243j
    mov     eax, [esi+14h]
    test    eax, eax
    jz      short loc_4BC25E
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BC25E:                             ; CODE XREF: .text:004BC253j
    push    esi
    call    sub_4D85A0
    add     esp, 4
    test    edi, edi
    jg      short loc_4BC27C
    push    ebx
    call    sub_4D85A0
    add     esp, 4

    loc_4BC274:                             ; CODE XREF: .text:004BC136j
                                            ; .text:004BC187j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BC27C:                             ; CODE XREF: .text:004BC269j
    pop     edi
    mov     eax, ebx
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BC290 proc near                    ; CODE XREF: sub_429330+BBp
                                            ; sub_42E140+7Fp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    esi
    push    offset aWb                      ; "wb"
    push    eax
    call    _fopen
    mov     esi, eax
    add     esp, 8
    test    esi, esi
    jnz     short loc_4BC2B0
    or      eax, 0FFFFFFFFh
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BC2B0:                             ; CODE XREF: sub_4BC290+17j
    mov     ecx, [esp+4+arg_8]
    mov     edx, [esp+4+arg_4]
    push    edi
    push    esi
    push    ecx
    push    1
    push    edx
    call    sub_4E5D40
    add     esp, 10h
    mov     edi, eax
    push    esi
    call    _fclose
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn    0Ch
    sub_4BC290 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BC2E0 proc near                    ; CODE XREF: sub_4AF5B0+Bp
                                            ; .text:004AFC27p

    arg_0= dword ptr  4

    call    __getdrive
    mov     ecx, eax
    mov     eax, [esp+arg_0]
    add     cl, 40h
    mov     [eax], cl
    mov     byte ptr [eax+1], 0
    retn    4
    sub_4BC2E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BC300 proc near                    ; CODE XREF: sub_4AF670+20p
                                            ; sub_4AF670+194p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    test    eax, eax
    jnz     short loc_4BC30E

    unknown_libname_50:
    or      eax, 0FFFFFFFFh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BC30E:                             ; CODE XREF: sub_4BC300+6j
    movsx   eax, byte ptr [eax]
    sub     eax, 40h
    push    eax                             ; PathName
    call    __chdrive
    add     esp, 4
    retn    4
    sub_4BC300 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4BC320(int,int,size_t)
    sub_4BC320 proc near                    ; CODE XREF: sub_4AF5B0+1Ap
                                            ; .text:004AFC39p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    esi
    test    eax, eax
    jnz     short loc_4BC335
    call    __getdrive
    add     al, 40h
    movsx   eax, al
    jmp     short loc_4BC338
    ; ---------------------------------------------------------------------------

    loc_4BC335:                             ; CODE XREF: sub_4BC320+7j
    movsx   eax, byte ptr [eax]

    loc_4BC338:                             ; CODE XREF: sub_4BC320+13j
    mov     ecx, [esp+4+arg_8]
    mov     esi, [esp+4+arg_4]
    sub     eax, 40h
    push    ecx                             ; size_t
    push    esi                             ; int
    push    eax                             ; RootPathName
    call    __getdcwd
    add     esp, 0Ch
    mov     eax, esi
    pop     esi
    retn    0Ch
    sub_4BC320 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4BC360(LPCSTR lpPathName)
    sub_4BC360 proc near                    ; CODE XREF: sub_4AF670+2Cp
                                            ; sub_4AF670+E6p ...

    lpPathName= dword ptr  4

    mov     eax, [esp+lpPathName]
    push    eax                             ; lpPathName
    call    __chdir
    add     esp, 4
    retn    4
    sub_4BC360 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BC370 proc near                    ; CODE XREF: sub_417890+67p
                                            ; sub_4BC640+ECp ...

    var_195= byte ptr -195h
    var_194= dword ptr -194h
    var_190= dword ptr -190h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 198h
    mov     ecx, [esp+198h+arg_0]
    push    ebx
    push    ebp
    push    esi
    movsx   eax, byte ptr [ecx]
    push    edi
    inc     ecx
    push    eax                             ; int
    mov     [esp+1ACh+var_190], 0
    mov     esi, 1
    mov     [esp+1ACh+arg_0], ecx
    call    _toupper
    add     esp, 4
    mov     [esp+1A8h+var_195], al
    test    al, al
    jz      loc_4BC44C

    loc_4BC3AE:                             ; CODE XREF: sub_4BC370+D6j
    test    esi, esi
    mov     [esp+1A8h+var_194], 0
    jle     short loc_4BC425
    lea     edi, [esp+1A8h+var_190]
    lea     ebx, [esp+esi*4+1A8h+var_190]

    loc_4BC3C2:                             ; CODE XREF: sub_4BC370+B3j
    mov     ebp, [edi]
    mov     eax, [esp+1A8h+arg_4]
    movsx   ecx, byte ptr [eax+ebp]
    push    ecx                             ; int
    call    _toupper
    add     esp, 4
    cmp     al, 3Fh
    jz      short loc_4BC412
    cmp     al, [esp+1A8h+var_195]
    jz      short loc_4BC412
    cmp     al, 2Ah
    jnz     short loc_4BC3F4
    cmp     esi, 64h
    jge     short loc_4BC415
    inc     ebp
    inc     esi
    mov     [ebx], ebp
    add     ebx, 4
    jmp     short loc_4BC415
    ; ---------------------------------------------------------------------------

    loc_4BC3F4:                             ; CODE XREF: sub_4BC370+74j
    dec     esi
    sub     ebx, 4
    test    esi, esi
    jz      loc_4BC49B
    mov     ecx, [esp+1A8h+var_194]
    mov     edx, [ebx]
    dec     ecx
    mov     [edi], edx
    mov     [esp+1A8h+var_194], ecx
    sub     edi, 4
    jmp     short loc_4BC415
    ; ---------------------------------------------------------------------------

    loc_4BC412:                             ; CODE XREF: sub_4BC370+6Aj
                                            ; sub_4BC370+70j
    inc     ebp
    mov     [edi], ebp

    loc_4BC415:                             ; CODE XREF: sub_4BC370+79j
                                            ; sub_4BC370+82j ...
    mov     eax, [esp+1A8h+var_194]
    add     edi, 4
    inc     eax
    cmp     eax, esi
    mov     [esp+1A8h+var_194], eax
    jl      short loc_4BC3C2

    loc_4BC425:                             ; CODE XREF: sub_4BC370+48j
    mov     ecx, [esp+1A8h+arg_0]
    movsx   eax, byte ptr [ecx]
    inc     ecx
    push    eax                             ; int
    mov     [esp+1ACh+arg_0], ecx
    call    _toupper
    add     esp, 4
    mov     [esp+1A8h+var_195], al
    test    al, al
    jnz     loc_4BC3AE

    loc_4BC44C:                             ; CODE XREF: sub_4BC370+38j
    xor     edi, edi
    test    esi, esi
    jle     short loc_4BC49B
    lea     edx, [esp+1A8h+var_190]

    loc_4BC456:                             ; CODE XREF: sub_4BC370+108j
    mov     eax, [edx]
    mov     ecx, [esp+1A8h+arg_4]
    add     ecx, eax
    mov     al, [ecx]
    test    al, al
    jz      short loc_4BC489
    cmp     al, 2Ah
    jnz     short loc_4BC472
    mov     al, [ecx+1]
    test    al, al
    jz      short loc_4BC489

    loc_4BC472:                             ; CODE XREF: sub_4BC370+F9j
    inc     edi
    add     edx, 4
    cmp     edi, esi
    jl      short loc_4BC456
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 198h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BC489:                             ; CODE XREF: sub_4BC370+F5j
                                            ; sub_4BC370+100j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 198h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BC49B:                             ; CODE XREF: sub_4BC370+8Aj
                                            ; sub_4BC370+E0j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 198h
    retn    8
    sub_4BC370 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BC4B0 proc near                    ; CODE XREF: sub_41D4C0+4Bp
                                            ; sub_41D4C0+85p ...

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h
    arg_8= dword ptr  1Ch
    arg_C= byte ptr  20h

    push    ebx
    push    ebp
    push    esi
    push    edi
    push    20Dh
    push    offset aFindFilesStruc          ; "Find Files structure"
    call    sub_4D83B0
    mov     ebx, [esp+8+arg_0]
    mov     ebp, eax
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    js      short loc_4BC509

    loc_4BC4F9:                             ; CODE XREF: sub_4BC4B0+50j
    cmp     byte ptr [ecx+ebp], 5Ch
    jz      short loc_4BC504
    dec     ecx
    jns     short loc_4BC4F9
    jmp     short loc_4BC509
    ; ---------------------------------------------------------------------------

    loc_4BC504:                             ; CODE XREF: sub_4BC4B0+4Dj
    mov     byte ptr [ecx+ebp+1], 0

    loc_4BC509:                             ; CODE XREF: sub_4BC4B0+47j
                                            ; sub_4BC4B0+52j
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp+100h]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [ecx-1]
    test    eax, eax
    jl      short loc_4BC54A

    loc_4BC541:                             ; CODE XREF: sub_4BC4B0+98j
    cmp     byte ptr [edx+eax], 5Ch
    jz      short loc_4BC54A
    dec     eax
    jns     short loc_4BC541

    loc_4BC54A:                             ; CODE XREF: sub_4BC4B0+8Fj
                                            ; sub_4BC4B0+95j
    lea     eax, [edx+eax+1]
    mov     ecx, edx

    loc_4BC550:                             ; CODE XREF: sub_4BC4B0+AAj
    mov     bl, [eax]
    mov     [ecx], bl
    mov     bl, [eax]
    inc     ecx
    inc     eax
    test    bl, bl
    jnz     short loc_4BC550
    mov     esi, offset a_                  ; "*.*"
    mov     eax, edx

    loc_4BC563:                             ; CODE XREF: sub_4BC4B0+D1j
    mov     bl, [eax]
    mov     cl, bl
    cmp     bl, [esi]
    jnz     short loc_4BC587
    test    cl, cl
    jz      short loc_4BC583
    mov     bl, [eax+1]
    mov     cl, bl
    cmp     bl, [esi+1]
    jnz     short loc_4BC587
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BC563

    loc_4BC583:                             ; CODE XREF: sub_4BC4B0+BDj
    xor     eax, eax
    jmp     short loc_4BC58C
    ; ---------------------------------------------------------------------------

    loc_4BC587:                             ; CODE XREF: sub_4BC4B0+B9j
                                            ; sub_4BC4B0+C7j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BC58C:                             ; CODE XREF: sub_4BC4B0+D5j
    test    eax, eax
    jnz     short loc_4BC5B0
    mov     edi, offset asc_50372C          ; "*"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4BC5B0:                             ; CODE XREF: sub_4BC4B0+DEj
    mov     eax, [esp+arg_8]
    mov     cl, [esp+arg_C]
    mov     esi, [esp+arg_4]
    cmp     eax, 0FFFFFFFFh
    mov     [ebp+204h], cl
    mov     [ebp+200h], eax
    jnz     short loc_4BC603
    mov     edx, [esp+arg_0]
    push    esi
    push    edx
    call    __findfirst
    add     esp, 8
    cmp     eax, 0FFFFFFFFh
    mov     [ebp+205h], eax
    jz      short loc_4BC5EF
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4BC5EF:                             ; CODE XREF: sub_4BC4B0+134j
    mov     al, [ebp+204h]
    test    al, al
    jz      short loc_4BC622
    mov     dword ptr [ebp+200h], 0

    loc_4BC603:                             ; CODE XREF: sub_4BC4B0+11Bj
    push    esi
    push    ebp
    mov     dword ptr [ebp+209h], 0FFFFFFFFh
    call    sub_4BC640
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4BC622
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4BC622:                             ; CODE XREF: sub_4BC4B0+147j
                                            ; sub_4BC4B0+167j
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_4BC4B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BC640 proc near                    ; CODE XREF: sub_41D4C0+68p
                                            ; sub_41D4C0+A2p ...

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    cmp     esi, 0FFFFFFFFh
    push    edi
    jz      loc_4BC7F5
    test    esi, esi
    jz      loc_4BC7F5
    mov     eax, [esi+200h]
    test    eax, eax
    jge     short loc_4BC6B6
    mov     eax, [esp+4+arg_4]
    mov     ecx, [esi+205h]
    push    eax
    push    ecx
    call    __findnext
    add     esp, 8
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4BC685
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BC685:                             ; CODE XREF: sub_4BC640+3Aj
    mov     edx, [esi+205h]
    push    edx                             ; hFindFile
    call    __findclose
    mov     al, [esi+204h]
    add     esp, 4
    test    al, al
    mov     dword ptr [esi+200h], 0
    mov     dword ptr [esi+209h], 0FFFFFFFFh
    jz      loc_4BC7F5

    loc_4BC6B6:                             ; CODE XREF: sub_4BC640+21j
    call    sub_4B6220
    mov     ebx, eax
    mov     eax, [esi+200h]
    cmp     eax, [ebx+61Ch]
    jge     loc_4BC7F5

    loc_4BC6CF:                             ; CODE XREF: sub_4BC640+145j
    mov     eax, [esi+209h]
    test    eax, eax
    jge     short loc_4BC6FF
    mov     ecx, [esi+200h]
    mov     edx, [ebx+618h]
    push    esi                             ; char *
    mov     eax, [edx+ecx*4]
    mov     ecx, [eax+8]
    mov     edx, [ecx+10h]
    push    edx                             ; int
    call    sub_4BC800
    test    eax, eax
    mov     [esi+205h], eax
    jz      short loc_4BC764

    loc_4BC6FF:                             ; CODE XREF: sub_4BC640+97j
    mov     edi, [esi+209h]
    mov     ecx, [esi+205h]
    inc     edi
    mov     [esi+209h], edi
    mov     edx, [ecx]
    mov     eax, edi
    cmp     eax, edx
    jge     short loc_4BC756
    lea     ebp, [esi+100h]

    loc_4BC720:                             ; CODE XREF: sub_4BC640+114j
    mov     edx, [ecx+4]
    lea     edi, [eax+eax*8]
    add     edi, edx
    push    ebp
    mov     eax, [edi]
    push    eax
    call    sub_4BC370
    test    eax, eax
    jz      short loc_4BC73B
    test    byte ptr [edi+8], 2
    jz      short loc_4BC795

    loc_4BC73B:                             ; CODE XREF: sub_4BC640+F3j
    mov     edi, [esi+209h]
    mov     ecx, [esi+205h]
    inc     edi
    mov     [esi+209h], edi
    mov     edx, [ecx]
    mov     eax, edi
    cmp     eax, edx
    jl      short loc_4BC720

    loc_4BC756:                             ; CODE XREF: sub_4BC640+D8j
    mov     al, [esi+204h]
    test    al, al
    jz      loc_4BC7F5

    loc_4BC764:                             ; CODE XREF: sub_4BC640+BDj
    mov     edx, [esi+200h]
    mov     dword ptr [esi+209h], 0FFFFFFFFh
    inc     edx
    mov     [esi+200h], edx
    mov     ecx, [ebx+61Ch]
    mov     eax, edx
    cmp     eax, ecx
    jl      loc_4BC6CF
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BC795:                             ; CODE XREF: sub_4BC640+F9j
    test    byte ptr [edi+8], 1
    mov     eax, [esp+4+arg_4]
    jz      short loc_4BC7AC
    xor     ecx, ecx
    mov     dword ptr [eax], 11h
    mov     [eax+10h], ecx
    jmp     short loc_4BC7C1
    ; ---------------------------------------------------------------------------

    loc_4BC7AC:                             ; CODE XREF: sub_4BC640+15Dj
    mov     dword ptr [eax], 1
    mov     ecx, [edi+4]
    mov     edx, [ecx+4]
    xor     ecx, ecx
    mov     [eax+10h], edx
    mov     eax, [esp+4+arg_4]

    loc_4BC7C1:                             ; CODE XREF: sub_4BC640+16Aj
    mov     [eax+4], ecx
    mov     [eax+8], ecx
    mov     [eax+0Ch], ecx
    mov     edi, [edi]
    lea     edx, [eax+14h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    xor     eax, eax
    rep movsb
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BC7F5:                             ; CODE XREF: sub_4BC640+Bj
                                            ; sub_4BC640+13j ...
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn    8
    sub_4BC640 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    ; int __stdcall sub_4BC800(int,char *)
    sub_4BC800 proc near                    ; CODE XREF: sub_4BC640+B0p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebp
    mov     ebp, esp
    push    ebx
    push    esi
    push    edi
    mov     edi, [ebp+arg_4]
    push    5Ch                             ; int
    push    edi                             ; char *
    call    _strchr
    add     esp, 8
    mov     [ebp+arg_4], eax
    test    eax, eax
    jz      loc_4BC8B8
    jmp     short loc_4BC824
    ; ---------------------------------------------------------------------------

    loc_4BC821:                             ; CODE XREF: sub_4BC800+9Dj
    mov     eax, [ebp+arg_4]

    loc_4BC824:                             ; CODE XREF: sub_4BC800+1Fj
    mov     esi, eax
    sub     esi, edi
    lea     eax, [esi+1]
    add     eax, 3
    and     al, 0FCh
    call    __alloca_probe
    mov     ebx, esp
    push    esi                             ; size_t
    push    edi                             ; char *
    push    ebx                             ; char *
    call    _strncpy
    mov     eax, [ebp+arg_0]
    mov     byte ptr [esi+ebx], 0
    add     esp, 0Ch
    mov     esi, [eax]
    dec     esi
    lea     edi, [esi+esi*8]

    loc_4BC84F:                             ; CODE XREF: sub_4BC800+6Ej
    test    esi, esi
    jl      short loc_4BC8AC
    mov     ecx, [ebp+arg_0]
    mov     edx, [ecx+4]
    mov     eax, [edx+edi]
    push    eax                             ; char *
    push    ebx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4BC870
    dec     esi
    sub     edi, 9
    jmp     short loc_4BC84F
    ; ---------------------------------------------------------------------------

    loc_4BC870:                             ; CODE XREF: sub_4BC800+68j
    mov     edx, [ebp+arg_0]
    lea     ecx, [esi+esi*8]
    mov     eax, [edx+4]
    add     eax, ecx
    test    byte ptr [eax+8], 1
    jz      short loc_4BC8AC
    mov     ecx, [ebp+arg_4]
    mov     edx, [eax+4]
    push    5Ch                             ; int
    mov     [ebp+arg_0], edx
    lea     edi, [ecx+1]
    push    edi                             ; char *
    call    _strchr
    add     esp, 8
    mov     [ebp+arg_4], eax
    test    eax, eax
    jnz     short loc_4BC821
    mov     eax, [ebp+arg_0]
    lea     esp, [ebp-0Ch]
    pop     edi
    pop     esi
    pop     ebx
    pop     ebp
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BC8AC:                             ; CODE XREF: sub_4BC800+51j
                                            ; sub_4BC800+7Fj
    xor     eax, eax
    lea     esp, [ebp-0Ch]
    pop     edi
    pop     esi
    pop     ebx
    pop     ebp
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BC8B8:                             ; CODE XREF: sub_4BC800+19j
    mov     eax, [ebp+arg_0]
    lea     esp, [ebp-0Ch]
    pop     edi
    pop     esi
    pop     ebx
    pop     ebp
    retn    8
    sub_4BC800 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BC8D0 proc near                    ; CODE XREF: sub_41D4C0+72p
                                            ; sub_41D4C0+ACp ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    cmp     esi, 0FFFFFFFFh
    push    edi
    jz      short loc_4BC91C
    test    esi, esi
    jz      short loc_4BC91C
    mov     eax, [esi+200h]
    test    eax, eax
    jge     short loc_4BC90A
    mov     eax, [esi+205h]
    push    eax                             ; hFindFile
    call    __findclose
    add     esp, 4
    mov     edi, eax
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BC90A:                             ; CODE XREF: sub_4BC8D0+17j
    push    esi                             ; int
    xor     edi, edi
    call    sub_4D85A0
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BC91C:                             ; CODE XREF: sub_4BC8D0+9j
                                            ; sub_4BC8D0+Dj
    pop     edi
    or      eax, 0FFFFFFFFh
    pop     esi
    retn    4
    sub_4BC8D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BC930 proc near                    ; CODE XREF: sub_42A440+29p
                                            ; sub_44B4E0+28p ...

    var_118= dword ptr -118h
    var_104= dword ptr -104h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 118h
    mov     ecx, [esp+118h+arg_0]
    lea     eax, [esp+118h+var_118]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    1
    push    0FFFFFFFFh
    push    eax
    push    ecx
    xor     ebx, ebx
    call    sub_4BC4B0
    mov     edi, eax
    cmp     edi, 0FFFFFFFFh
    jz      loc_4BCA16
    mov     ebp, [esp+128h+arg_4]

    loc_4BC964:                             ; CODE XREF: sub_4BC930+BAj
    mov     esi, offset Directory
    lea     eax, [esp+128h+var_104]

    loc_4BC96D:                             ; CODE XREF: sub_4BC930+5Bj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BC991
    test    cl, cl
    jz      short loc_4BC98D
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BC991
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BC96D

    loc_4BC98D:                             ; CODE XREF: sub_4BC930+47j
    xor     eax, eax
    jmp     short loc_4BC996
    ; ---------------------------------------------------------------------------

    loc_4BC991:                             ; CODE XREF: sub_4BC930+43j
                                            ; sub_4BC930+51j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BC996:                             ; CODE XREF: sub_4BC930+5Fj
    test    eax, eax
    jz      short loc_4BC9DC
    mov     esi, offset a__                 ; ".."
    lea     eax, [esp+128h+var_104]

    loc_4BC9A3:                             ; CODE XREF: sub_4BC930+91j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BC9C7
    test    cl, cl
    jz      short loc_4BC9C3
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BC9C7
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BC9A3

    loc_4BC9C3:                             ; CODE XREF: sub_4BC930+7Dj
    xor     eax, eax
    jmp     short loc_4BC9CC
    ; ---------------------------------------------------------------------------

    loc_4BC9C7:                             ; CODE XREF: sub_4BC930+79j
                                            ; sub_4BC930+87j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BC9CC:                             ; CODE XREF: sub_4BC930+95j
    test    eax, eax
    jz      short loc_4BC9DC
    test    ebp, ebp
    jz      short loc_4BC9DB
    test    byte ptr [esp+128h+var_118], 10h
    jz      short loc_4BC9DC

    loc_4BC9DB:                             ; CODE XREF: sub_4BC930+A2j
    inc     ebx

    loc_4BC9DC:                             ; CODE XREF: sub_4BC930+68j
                                            ; sub_4BC930+9Ej ...
    lea     eax, [esp+128h+var_118]
    push    eax
    push    edi
    call    sub_4BC640
    cmp     eax, 0FFFFFFFFh
    jnz     loc_4BC964
    test    edi, edi
    jz      short loc_4BCA16
    mov     eax, [edi+200h]
    test    eax, eax
    jge     short loc_4BCA0D
    mov     ecx, [edi+205h]
    push    ecx                             ; hFindFile
    call    __findclose
    add     esp, 4

    loc_4BCA0D:                             ; CODE XREF: sub_4BC930+CCj
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BCA16:                             ; CODE XREF: sub_4BC930+27j
                                            ; sub_4BC930+C2j
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    add     esp, 118h
    retn    8
    sub_4BC930 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BCA30 proc near                    ; CODE XREF: sub_42A610+115p
                                            ; sub_42A8D0+35p ...

    var_11C= dword ptr -11Ch
    var_118= dword ptr -118h
    var_104= dword ptr -104h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 11Ch
    mov     ecx, [esp+11Ch+arg_0]
    lea     eax, [esp+11Ch+var_118]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    1
    push    0FFFFFFFFh
    push    eax
    push    ecx
    call    sub_4BC4B0
    mov     edi, eax
    cmp     edi, 0FFFFFFFFh
    jz      loc_4BCB43
    mov     ebp, [esp+12Ch+arg_8]
    mov     ebx, [esp+12Ch+arg_4]

    loc_4BCA69:                             ; CODE XREF: sub_4BCA30+E7j
    mov     esi, offset Directory
    lea     eax, [esp+12Ch+var_104]

    loc_4BCA72:                             ; CODE XREF: sub_4BCA30+60j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BCA96
    test    cl, cl
    jz      short loc_4BCA92
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BCA96
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BCA72

    loc_4BCA92:                             ; CODE XREF: sub_4BCA30+4Cj
    xor     eax, eax
    jmp     short loc_4BCA9B
    ; ---------------------------------------------------------------------------

    loc_4BCA96:                             ; CODE XREF: sub_4BCA30+48j
                                            ; sub_4BCA30+56j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BCA9B:                             ; CODE XREF: sub_4BCA30+64j
    test    eax, eax
    jz      short loc_4BCB09
    mov     esi, offset a__                 ; ".."
    lea     eax, [esp+12Ch+var_104]

    loc_4BCAA8:                             ; CODE XREF: sub_4BCA30+96j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BCACC
    test    cl, cl
    jz      short loc_4BCAC8
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BCACC
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BCAA8

    loc_4BCAC8:                             ; CODE XREF: sub_4BCA30+82j
    xor     eax, eax
    jmp     short loc_4BCAD1
    ; ---------------------------------------------------------------------------

    loc_4BCACC:                             ; CODE XREF: sub_4BCA30+7Ej
                                            ; sub_4BCA30+8Cj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BCAD1:                             ; CODE XREF: sub_4BCA30+9Aj
    test    eax, eax
    jz      short loc_4BCB09
    test    ebx, ebx
    jz      short loc_4BCAE0
    test    byte ptr [esp+12Ch+var_118], 10h
    jz      short loc_4BCB09

    loc_4BCAE0:                             ; CODE XREF: sub_4BCA30+A7j
    lea     eax, [esp+12Ch+var_104]
    lea     ecx, [esp+12Ch+var_11C]
    push    eax
    call    sub_4C91B0
    mov     edx, [ebp+8]
    lea     ecx, [esp+12Ch+var_11C]
    push    ecx
    push    1
    push    edx
    mov     ecx, ebp
    call    sub_4BE6C0
    lea     ecx, [esp+12Ch+var_11C]
    call    sub_4C9390

    loc_4BCB09:                             ; CODE XREF: sub_4BCA30+6Dj
                                            ; sub_4BCA30+A3j ...
    lea     eax, [esp+12Ch+var_118]
    push    eax
    push    edi
    call    sub_4BC640
    cmp     eax, 0FFFFFFFFh
    jnz     loc_4BCA69
    test    edi, edi
    jz      short loc_4BCB43
    mov     eax, [edi+200h]
    test    eax, eax
    jge     short loc_4BCB3A
    mov     ecx, [edi+205h]
    push    ecx                             ; hFindFile
    call    __findclose
    add     esp, 4

    loc_4BCB3A:                             ; CODE XREF: sub_4BCA30+F9j
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BCB43:                             ; CODE XREF: sub_4BCA30+25j
                                            ; sub_4BCA30+EFj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 11Ch
    retn    0Ch
    sub_4BCA30 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BCB50 proc near                    ; CODE XREF: sub_4222E0+59p
                                            ; sub_4BCB50+10Bp

    var_21C= dword ptr -21Ch
    var_218= dword ptr -218h
    var_204= dword ptr -204h
    var_100= dword ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 21Ch
    lea     eax, [esp+21Ch+var_100]
    push    ebx
    mov     ebx, [esp+220h+arg_0]
    push    ebp
    push    esi
    push    edi
    push    ebx
    push    offset aS                       ; "%s\\*"
    push    eax
    call    _sprintf
    mov     ecx, [esp+238h+arg_10]
    mov     edx, [esp+238h+arg_C]
    add     esp, 0Ch
    lea     eax, [esp+22Ch+var_218]
    push    ecx
    push    edx
    lea     ecx, [esp+234h+var_100]
    push    eax
    push    ecx
    call    sub_4BC4B0
    mov     ebp, eax
    cmp     ebp, 0FFFFFFFFh
    jz      loc_4BCCFD
    mov     edi, [esp+22Ch+arg_8]

    loc_4BCBAB:                             ; CODE XREF: sub_4BCB50+17Dj
    mov     esi, offset Directory
    lea     eax, [esp+22Ch+var_204]

    loc_4BCBB4:                             ; CODE XREF: sub_4BCB50+82j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BCBD8
    test    cl, cl
    jz      short loc_4BCBD4
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BCBD8
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BCBB4

    loc_4BCBD4:                             ; CODE XREF: sub_4BCB50+6Ej
    xor     eax, eax
    jmp     short loc_4BCBDD
    ; ---------------------------------------------------------------------------

    loc_4BCBD8:                             ; CODE XREF: sub_4BCB50+6Aj
                                            ; sub_4BCB50+78j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BCBDD:                             ; CODE XREF: sub_4BCB50+86j
    test    eax, eax
    jz      loc_4BCCBF
    mov     esi, offset a__                 ; ".."
    lea     eax, [esp+22Ch+var_204]

    loc_4BCBEE:                             ; CODE XREF: sub_4BCB50+BCj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BCC12
    test    cl, cl
    jz      short loc_4BCC0E
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BCC12
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BCBEE

    loc_4BCC0E:                             ; CODE XREF: sub_4BCB50+A8j
    xor     eax, eax
    jmp     short loc_4BCC17
    ; ---------------------------------------------------------------------------

    loc_4BCC12:                             ; CODE XREF: sub_4BCB50+A4j
                                            ; sub_4BCB50+B2j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BCC17:                             ; CODE XREF: sub_4BCB50+C0j
    test    eax, eax
    jz      loc_4BCCBF
    test    byte ptr [esp+22Ch+var_218], 10h
    jz      short loc_4BCC62
    lea     eax, [esp+22Ch+var_204]
    lea     ecx, [esp+22Ch+var_100]
    push    eax
    push    ebx
    push    offset aSS                      ; "%s\\%s"
    push    ecx
    call    _sprintf
    mov     edx, [ebp+200h]
    mov     eax, [esp+23Ch+arg_4]
    add     esp, 10h
    lea     ecx, [esp+22Ch+var_100]
    push    0
    push    edx
    push    edi
    push    eax
    push    ecx
    call    sub_4BCB50
    jmp     short loc_4BCCBF
    ; ---------------------------------------------------------------------------

    loc_4BCC62:                             ; CODE XREF: sub_4BCB50+D4j
    mov     edx, [esp+22Ch+arg_4]
    lea     eax, [esp+22Ch+var_204]
    push    edx
    push    eax
    call    sub_4BC370
    test    eax, eax
    jz      short loc_4BCCBF
    lea     ecx, [esp+22Ch+var_204]
    lea     edx, [esp+22Ch+var_100]
    push    ecx
    push    ebx
    push    offset aSS                      ; "%s\\%s"
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     eax, [esp+22Ch+var_100]
    lea     ecx, [esp+22Ch+var_21C]
    push    eax
    call    sub_4C91B0
    mov     edx, [edi+8]
    lea     ecx, [esp+22Ch+var_21C]
    push    ecx
    push    1
    push    edx
    mov     ecx, edi
    call    sub_4BE6C0
    lea     ecx, [esp+22Ch+var_21C]
    call    sub_4C9390

    loc_4BCCBF:                             ; CODE XREF: sub_4BCB50+8Fj
                                            ; sub_4BCB50+C9j ...
    lea     eax, [esp+22Ch+var_218]
    push    eax
    push    ebp
    call    sub_4BC640
    cmp     eax, 0FFFFFFFFh
    jnz     loc_4BCBAB
    cmp     ebp, eax
    jz      short loc_4BCCFD
    test    ebp, ebp
    jz      short loc_4BCCFD
    mov     eax, [ebp+200h]
    test    eax, eax
    jge     short loc_4BCCF4
    mov     ecx, [ebp+205h]
    push    ecx                             ; hFindFile
    call    __findclose
    add     esp, 4

    loc_4BCCF4:                             ; CODE XREF: sub_4BCB50+193j
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BCCFD:                             ; CODE XREF: sub_4BCB50+4Ej
                                            ; sub_4BCB50+185j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 21Ch
    retn    14h
    sub_4BCB50 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ecx
    mov     eax, [esp+10h]
    push    ebx
    push    ebp
    mov     ebp, [esp+10h]
    push    esi
    push    edi
    push    1
    push    0FFFFFFFFh
    push    ebp
    push    eax
    mov     dword ptr [esp+20h], 0
    call    sub_4BC4B0
    mov     ebx, eax
    cmp     ebx, 0FFFFFFFFh
    jz      loc_4BCDFB
    lea     edi, [ebp+14h]

    loc_4BCD3E:                             ; CODE XREF: .text:004BCDCFj
    mov     esi, offset Directory
    mov     eax, edi

    loc_4BCD45:                             ; CODE XREF: .text:004BCD63j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BCD69
    test    cl, cl
    jz      short loc_4BCD65
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BCD69
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BCD45

    loc_4BCD65:                             ; CODE XREF: .text:004BCD4Fj
    xor     eax, eax
    jmp     short loc_4BCD6E
    ; ---------------------------------------------------------------------------

    loc_4BCD69:                             ; CODE XREF: .text:004BCD4Bj
                                            ; .text:004BCD59j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BCD6E:                             ; CODE XREF: .text:004BCD67j
    test    eax, eax
    jz      short loc_4BCDC5
    mov     esi, offset a__                 ; ".."
    mov     eax, edi

    loc_4BCD79:                             ; CODE XREF: .text:004BCD97j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BCD9D
    test    cl, cl
    jz      short loc_4BCD99
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BCD9D
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BCD79

    loc_4BCD99:                             ; CODE XREF: .text:004BCD83j
    xor     eax, eax
    jmp     short loc_4BCDA2
    ; ---------------------------------------------------------------------------

    loc_4BCD9D:                             ; CODE XREF: .text:004BCD7Fj
                                            ; .text:004BCD8Dj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BCDA2:                             ; CODE XREF: .text:004BCD9Bj
    test    eax, eax
    jz      short loc_4BCDC5
    mov     eax, [esp+24h]
    test    eax, eax
    jz      short loc_4BCDB4
    test    byte ptr [ebp+0], 10h
    jz      short loc_4BCDC5

    loc_4BCDB4:                             ; CODE XREF: .text:004BCDACj
    mov     eax, [esp+10h]
    mov     ecx, [esp+1Ch]
    cmp     eax, ecx
    jz      short loc_4BCDD5
    inc     eax
    mov     [esp+10h], eax

    loc_4BCDC5:                             ; CODE XREF: .text:004BCD70j
                                            ; .text:004BCDA4j ...
    push    ebp
    push    ebx
    call    sub_4BC640
    cmp     eax, 0FFFFFFFFh
    jnz     loc_4BCD3E

    loc_4BCDD5:                             ; CODE XREF: .text:004BCDBEj
    test    ebx, ebx
    jz      short loc_4BCDFB
    mov     eax, [ebx+200h]
    test    eax, eax
    jge     short loc_4BCDF2
    mov     ecx, [ebx+205h]
    push    ecx
    call    __findclose
    add     esp, 4

    loc_4BCDF2:                             ; CODE XREF: .text:004BCDE1j
    push    ebx
    call    sub_4D85A0
    add     esp, 4

    loc_4BCDFB:                             ; CODE XREF: .text:004BCD35j
                                            ; .text:004BCDD7j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BCE10 proc near                    ; CODE XREF: sub_4B5980+FEp

    var_C= dword ptr -0Ch

    sub     esp, 0Ch
    push    esi
    call    sub_4B6220
    mov     esi, eax
    call    __getdrive
    lea     ecx, [esp+10h+var_C]
    add     al, 40h
    add     esi, 628h
    test    ecx, ecx
    jnz     short loc_4BCE37
    call    __getdrive
    add     al, 40h

    loc_4BCE37:                             ; CODE XREF: sub_4BCE10+1Ej
    movsx   eax, al
    sub     eax, 40h
    push    100h                            ; size_t
    push    esi                             ; int
    push    eax                             ; RootPathName
    call    __getdcwd
    add     esp, 0Ch
    pop     esi
    add     esp, 0Ch
    retn
    sub_4BCE10 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    push    edi
    call    sub_4B6220
    mov     ebx, [esp+10h]
    mov     edi, eax
    push    ebx
    call    __chdir
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jnz     short loc_4BCE92
    push    100h
    add     edi, 728h
    push    ebx
    push    edi
    call    _strncpy
    add     esp, 0Ch

    loc_4BCE92:                             ; CODE XREF: .text:004BCE7Bj
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    call    sub_4B6220
    add     eax, 728h
    push    100h
    push    eax
    mov     eax, [esp+0Ch]
    push    eax
    call    _strncpy
    add     esp, 0Ch
    retn    4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BCEC0 proc near                    ; CODE XREF: .text:004268C1p
                                            ; .text:00426AB8p

    arg_0= dword ptr  4

    call    sub_4B6220
    add     eax, 628h
    push    100h                            ; size_t
    push    eax                             ; char *
    mov     eax, [esp+8+arg_0]
    push    eax                             ; char *
    call    _strncpy
    add     esp, 0Ch
    retn    4
    sub_4BCEC0 endp

    ; ---------------------------------------------------------------------------
    call    sub_4B6220
    add     eax, 628h
    push    eax
    call    __chdir
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BCF00 proc near                    ; CODE XREF: .text:00417467p
                                            ; sub_417600+125p ...

    PathName= byte ptr -104h
    arg_0= dword ptr  4

    sub     esp, 104h
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+104h+PathName]
    push    esi
    push    edi
    mov     edi, [esp+10Ch+arg_0]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     al, [esp+10Ch+PathName]
    lea     esi, [esp+10Ch+PathName]
    test    al, al
    jz      short loc_4BCF61

    loc_4BCF3C:                             ; CODE XREF: sub_4BCF00+5Fj
    mov     al, [esi]
    cmp     al, 5Ch
    jz      short loc_4BCF46
    cmp     al, 2Fh
    jnz     short loc_4BCF59

    loc_4BCF46:                             ; CODE XREF: sub_4BCF00+40j
    lea     ecx, [esp+10Ch+PathName]
    mov     byte ptr [esi], 0
    push    ecx                             ; lpPathName
    call    __mkdir
    add     esp, 4
    mov     byte ptr [esi], 5Ch

    loc_4BCF59:                             ; CODE XREF: sub_4BCF00+44j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4BCF3C

    loc_4BCF61:                             ; CODE XREF: sub_4BCF00+3Aj
    lea     edx, [esp+10Ch+PathName]
    push    edx                             ; lpPathName
    call    __mkdir
    add     esp, 4
    pop     edi
    pop     esi
    add     esp, 104h
    retn    4
    sub_4BCF00 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ecx
    mov     eax, [esp+0Ch]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    offset aRb                      ; "rb"
    push    eax
    xor     ebx, ebx
    call    sub_4BB2E0
    mov     edi, eax
    cmp     edi, ebx
    jnz     short loc_4BCFA6
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BCFA6:                             ; CODE XREF: .text:004BCF9Aj
    cmp     [edi+4], ebx
    jz      short loc_4BCFB7
    mov     ecx, [edi+8]
    mov     edx, [ecx+4]
    mov     [esp+1Ch], edx
    jmp     short loc_4BCFD3
    ; ---------------------------------------------------------------------------

    loc_4BCFB7:                             ; CODE XREF: .text:004BCFA9j
    mov     eax, [edi]
    cmp     eax, ebx
    jz      short loc_4BCFCF
    mov     eax, [eax+10h]
    push    eax
    call    __filelength
    add     esp, 4
    mov     [esp+1Ch], eax
    jmp     short loc_4BCFD3
    ; ---------------------------------------------------------------------------

    loc_4BCFCF:                             ; CODE XREF: .text:004BCFBBj
    mov     [esp+1Ch], ebx

    loc_4BCFD3:                             ; CODE XREF: .text:004BCFB5j
                                            ; .text:004BCFCDj
    mov     esi, [esp+1Ch]
    cmp     esi, ebx
    jz      loc_4BD0C6
    push    ebx
    push    edi
    call    sub_4BB710
    cmp     eax, 0FFFFFFFFh
    jz      loc_4BD0C6
    push    19000h
    push    offset aCopyBuffer              ; "COPY BUFFER"
    call    sub_4D83B0
    mov     ebp, [esp+20h]
    add     esp, 8
    mov     ebx, eax
    mov     [esp+10h], esi

    loc_4BD00B:                             ; CODE XREF: .text:004BD04Fj
    push    19000h
    push    ebx
    push    edi
    call    sub_4BB7C0
    mov     esi, eax
    test    esi, esi
    jle     loc_4BD0C6
    mov     eax, [ebp+4]
    test    eax, eax
    jz      short loc_4BD02D
    or      eax, 0FFFFFFFFh
    jmp     short loc_4BD03D
    ; ---------------------------------------------------------------------------

    loc_4BD02D:                             ; CODE XREF: .text:004BD026j
    mov     ecx, [ebp+0]
    push    ecx
    push    esi
    push    1
    push    ebx
    call    sub_4E5D40
    add     esp, 10h

    loc_4BD03D:                             ; CODE XREF: .text:004BD02Bj
    cmp     eax, esi
    jnz     loc_4BD0C6
    mov     eax, [esp+10h]
    sub     eax, esi
    mov     [esp+10h], eax
    jnz     short loc_4BD00B
    mov     eax, [edi+4]
    test    eax, eax
    jz      short loc_4BD086
    mov     edx, [eax+0Ch]
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [edi+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BD091
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BD091
    mov     edx, [eax]
    push    edx
    call    _fclose
    mov     eax, [edi+4]
    add     esp, 4
    mov     dword ptr [eax], 0
    jmp     short loc_4BD091
    ; ---------------------------------------------------------------------------

    loc_4BD086:                             ; CODE XREF: .text:004BD056j
    mov     ecx, [edi]
    push    ecx
    call    _fclose
    add     esp, 4

    loc_4BD091:                             ; CODE XREF: .text:004BD067j
                                            ; .text:004BD06Ej ...
    mov     eax, [edi+10h]
    test    eax, eax
    jz      short loc_4BD0A1
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BD0A1:                             ; CODE XREF: .text:004BD096j
    mov     eax, [edi+14h]
    test    eax, eax
    jz      short loc_4BD0B1
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BD0B1:                             ; CODE XREF: .text:004BD0A6j
    push    edi
    call    sub_4D85A0
    mov     eax, [esp+20h]
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BD0C6:                             ; CODE XREF: .text:004BCFD9j
                                            ; .text:004BCFE9j ...
    test    ebx, ebx
    jz      short loc_4BD0D3
    push    ebx
    call    sub_4D85A0
    add     esp, 4

    loc_4BD0D3:                             ; CODE XREF: .text:004BD0C8j
    mov     eax, [edi+4]
    test    eax, eax
    jz      short loc_4BD108
    mov     edx, [eax+0Ch]
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [edi+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BD113
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BD113
    mov     edx, [eax]
    push    edx
    call    _fclose
    mov     eax, [edi+4]
    add     esp, 4
    mov     dword ptr [eax], 0
    jmp     short loc_4BD113
    ; ---------------------------------------------------------------------------

    loc_4BD108:                             ; CODE XREF: .text:004BD0D8j
    mov     ecx, [edi]
    push    ecx
    call    _fclose
    add     esp, 4

    loc_4BD113:                             ; CODE XREF: .text:004BD0E9j
                                            ; .text:004BD0F0j ...
    mov     eax, [edi+10h]
    test    eax, eax
    jz      short loc_4BD123
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BD123:                             ; CODE XREF: .text:004BD118j
    mov     eax, [edi+14h]
    test    eax, eax
    jz      short loc_4BD133
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BD133:                             ; CODE XREF: .text:004BD128j
    push    edi
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_51:
    xor     eax, eax
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 54h
    mov     eax, [esp+60h]
    push    ebx
    push    ebp
    xor     ebp, ebp
    push    esi
    cmp     eax, ebp
    push    edi
    mov     [esp+10h], ebp
    jz      short loc_4BD17B
    push    ebp
    call    eax
    add     esp, 4

    loc_4BD17B:                             ; CODE XREF: .text:004BD173j
    xor     ecx, ecx
    mov     eax, ecx
    mov     [esp+18h], ecx
    mov     eax, 14h
    push    eax
    push    offset aPackageData             ; "Package Data"
    push    ecx
    mov     [esp+20h], eax
    call    Network_ReAllocPacketBuffer
    mov     edx, [esp+74h]
    add     esp, 0Ch
    mov     [esp+18h], eax
    lea     eax, [esp+10h]
    lea     ecx, [esp+14h]
    push    eax
    push    ecx
    push    edx
    call    sub_4BD3B0
    mov     esi, [esp+18h]
    push    4
    push    offset aHapi                    ; "HAPI"
    push    esi
    mov     edi, eax
    call    _strncpy
    mov     ebx, [esp+80h]
    mov     byte ptr [esi+4], 0
    mov     byte ptr [esi+5], 0
    mov     byte ptr [esi+6], 1
    mov     byte ptr [esi+7], 0
    mov     eax, [esp+20h]
    mov     [esi+8], eax
    mov     eax, ebx
    add     esp, 0Ch
    and     eax, 0FFh
    test    bl, bl
    jnz     short loc_4BD1F6
    xor     cl, cl
    jmp     short loc_4BD202
    ; ---------------------------------------------------------------------------

    loc_4BD1F6:                             ; CODE XREF: .text:004BD1F0j
    mov     ecx, eax
    shr     ecx, 2
    shl     eax, 6
    or      ecx, eax
    not     cl

    loc_4BD202:                             ; CODE XREF: .text:004BD1F4j
    mov     [esi+0Ch], cl
    mov     ecx, [esp+6Ch]
    push    offset aWb                      ; "wb"
    push    ecx
    mov     byte ptr [esi+0Dh], 0
    mov     [esi+0Eh], bp
    mov     [esi+10h], edi
    call    _fopen
    mov     ebp, eax
    add     esp, 8
    test    ebp, ebp
    jnz     short loc_4BD245
    mov     eax, [esp+18h]
    test    eax, eax
    jz      short loc_4BD239
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BD239:                             ; CODE XREF: .text:004BD22Ej
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 54h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BD245:                             ; CODE XREF: .text:004BD226j
    mov     edx, [esp+14h]
    mov     eax, [esp+18h]
    push    ebp
    push    1
    push    edx
    push    eax
    call    sub_4E5D40
    mov     esi, [esp+80h]
    add     esp, 10h
    test    esi, esi
    jz      short loc_4BD26C
    push    5
    call    esi
    add     esp, 4

    loc_4BD26C:                             ; CODE XREF: .text:004BD263j
    mov     ecx, [esp+78h]
    mov     edx, [esp+10h]
    mov     eax, [esp+18h]
    push    ecx
    mov     ecx, [esp+6Ch]
    push    ebx
    push    edx
    push    esi
    push    ebp
    push    edi
    push    eax
    push    ecx
    call    sub_4BD830
    test    esi, esi
    jz      short loc_4BD294
    push    5Fh
    call    esi
    add     esp, 4

    loc_4BD294:                             ; CODE XREF: .text:004BD28Bj
    mov     edx, [esp+14h]
    mov     eax, [esp+18h]
    test    bl, bl
    lea     edi, [edx-14h]
    lea     esi, [eax+14h]
    jz      short loc_4BD2C3
    xor     eax, eax
    test    edi, edi
    jle     short loc_4BD2C3

    loc_4BD2AC:                             ; CODE XREF: .text:004BD2C1j
    mov     dl, [esi+eax]
    mov     cl, al
    add     cl, 14h
    xor     cl, bl
    xor     cl, dl
    inc     eax
    not     cl
    mov     [esi+eax-1], cl
    cmp     eax, edi
    jl      short loc_4BD2AC

    loc_4BD2C3:                             ; CODE XREF: .text:004BD2A4j
                                            ; .text:004BD2AAj
    push    ebp
    call    _rewind
    mov     edx, [esp+18h]
    mov     eax, [esp+1Ch]
    add     esp, 4
    push    ebp
    push    1
    push    edx
    push    eax
    call    sub_4E5D40
    add     esp, 10h
    push    0
    call    _time
    add     esp, 4
    lea     ecx, [esp+70h]
    mov     [esp+70h], eax
    push    ecx
    call    _localtime
    mov     edx, [eax+14h]
    add     esp, 4
    add     edx, 76Ch
    lea     eax, [esp+1Ch]
    push    edx
    push    offset aI                       ; "%i"
    push    eax
    call    _sprintf
    mov     edi, offset aCopyright0000C     ; "Copyright 0000 Cavedog Entertainment"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+24h]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    push    4
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    lea     edx, [esp+28h]
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+20h]
    push    ecx
    push    offset a0000                    ; "0000"
    push    edx
    call    _strstr
    add     esp, 8
    push    eax
    call    _strncpy
    add     esp, 0Ch
    push    2
    push    0
    push    ebp
    call    _fseek
    add     esp, 0Ch
    lea     eax, [esp+24h]
    push    eax
    push    ebp
    call    sub_4E4510
    add     esp, 8
    push    ebp
    call    _fclose
    mov     eax, [esp+1Ch]
    add     esp, 4
    test    eax, eax
    jz      short loc_4BD395
    push    eax
    call    sub_4D85A0
    add     esp, 4

    loc_4BD395:                             ; CODE XREF: .text:004BD38Aj
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 54h
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BD3B0 proc near                    ; CODE XREF: .text:004BD1AEp
                                            ; sub_4BD3B0+3B7p

    var_230= dword ptr -230h
    var_22C= dword ptr -22Ch
    var_228= dword ptr -228h
    var_224= dword ptr -224h
    var_220= dword ptr -220h
    var_21C= dword ptr -21Ch
    var_20C= dword ptr -20Ch
    var_208= dword ptr -208h
    var_105= byte ptr -105h
    var_104= dword ptr -104h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 230h
    push    ebx
    push    ebp
    mov     ebp, [esp+238h+arg_4]
    push    esi
    push    edi
    mov     eax, [ebp+0]
    mov     esi, eax
    add     eax, 8
    mov     [ebp+0], eax
    push    eax                             ; int
    mov     eax, [ebp+4]
    push    offset aPackageData             ; int
    push    eax                             ; int
    mov     [esp+24Ch+var_228], esi
    call    Network_ReAllocPacketBuffer
    mov     edi, [esp+24Ch+arg_0]
    mov     ebx, eax
    mov     [ebp+4], ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    mov     dword ptr [esi+ebx], 0
    lea     edx, [esp+240h+var_104]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+240h+var_104]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+240h+var_104]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    cmp     [esp+ecx+240h+var_105], 5Ch
    jz      short loc_4BD46B
    mov     edi, offset asc_50A57C          ; "\\*"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     [esp+240h+var_224], eax
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    jmp     short loc_4BD49D
    ; ---------------------------------------------------------------------------

    loc_4BD46B:                             ; CODE XREF: sub_4BD3B0+89j
    mov     edi, offset asc_50372C          ; "*"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esp+240h+var_224], 1
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4BD49D:                             ; CODE XREF: sub_4BD3B0+B9j
    push    1
    lea     eax, [esp+244h+var_21C]
    push    0FFFFFFFFh
    lea     ecx, [esp+248h+var_104]
    push    eax
    push    ecx
    call    sub_4BC4B0
    mov     edi, eax
    cmp     edi, 0FFFFFFFFh
    jz      loc_4BD56A

    loc_4BD4BE:                             ; CODE XREF: sub_4BD3B0+18Ej
    mov     esi, offset Directory
    lea     eax, [esp+240h+var_208]

    loc_4BD4C7:                             ; CODE XREF: sub_4BD3B0+135j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BD4EB
    test    cl, cl
    jz      short loc_4BD4E7
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BD4EB
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BD4C7

    loc_4BD4E7:                             ; CODE XREF: sub_4BD3B0+121j
    xor     eax, eax
    jmp     short loc_4BD4F0
    ; ---------------------------------------------------------------------------

    loc_4BD4EB:                             ; CODE XREF: sub_4BD3B0+11Dj
                                            ; sub_4BD3B0+12Bj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BD4F0:                             ; CODE XREF: sub_4BD3B0+139j
    test    eax, eax
    jz      short loc_4BD531
    mov     esi, offset a__                 ; ".."
    lea     eax, [esp+240h+var_208]

    loc_4BD4FD:                             ; CODE XREF: sub_4BD3B0+16Bj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BD521
    test    cl, cl
    jz      short loc_4BD51D
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BD521
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BD4FD

    loc_4BD51D:                             ; CODE XREF: sub_4BD3B0+157j
    xor     eax, eax
    jmp     short loc_4BD526
    ; ---------------------------------------------------------------------------

    loc_4BD521:                             ; CODE XREF: sub_4BD3B0+153j
                                            ; sub_4BD3B0+161j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BD526:                             ; CODE XREF: sub_4BD3B0+16Fj
    test    eax, eax
    jz      short loc_4BD531
    mov     eax, [esp+240h+var_228]
    inc     dword ptr [eax+ebx]

    loc_4BD531:                             ; CODE XREF: sub_4BD3B0+142j
                                            ; sub_4BD3B0+178j
    lea     eax, [esp+240h+var_21C]
    push    eax
    push    edi
    call    sub_4BC640
    test    eax, eax
    jz      loc_4BD4BE
    test    edi, edi
    jz      short loc_4BD56A
    mov     eax, [edi+200h]
    test    eax, eax
    jge     short loc_4BD561
    mov     ecx, [edi+205h]
    push    ecx                             ; hFindFile
    call    __findclose
    add     esp, 4

    loc_4BD561:                             ; CODE XREF: sub_4BD3B0+1A0j
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BD56A:                             ; CODE XREF: sub_4BD3B0+108j
                                            ; sub_4BD3B0+196j
    mov     edi, [esp+240h+var_228]
    mov     eax, [ebp+0]
    mov     esi, eax
    mov     ecx, [edi+ebx]
    mov     [esp+240h+var_22C], esi
    lea     edx, [eax+ecx*8]
    lea     eax, [ecx+edx]
    mov     [ebp+0], eax
    push    eax                             ; int
    mov     eax, [ebp+4]
    push    offset aPackageData             ; int
    push    eax                             ; int
    call    Network_ReAllocPacketBuffer
    add     esp, 0Ch
    lea     ecx, [esp+240h+var_21C]
    lea     edx, [esp+240h+var_104]
    mov     [ebp+4], eax
    push    1
    push    0FFFFFFFFh
    push    ecx
    push    edx
    mov     [edi+eax+4], esi
    call    sub_4BC4B0
    mov     edi, eax
    cmp     edi, 0FFFFFFFFh
    mov     [esp+240h+var_220], edi
    jz      loc_4BD81B
    mov     [esp+240h+var_230], 0

    loc_4BD5C9:                             ; CODE XREF: sub_4BD3B0+43Fj
    mov     esi, offset Directory
    lea     eax, [esp+240h+var_208]

    loc_4BD5D2:                             ; CODE XREF: sub_4BD3B0+244j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4BD5FA
    test    cl, cl
    jz      short loc_4BD5F6
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4BD5FA
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BD5D2

    loc_4BD5F6:                             ; CODE XREF: sub_4BD3B0+22Ej
    xor     eax, eax
    jmp     short loc_4BD5FF
    ; ---------------------------------------------------------------------------

    loc_4BD5FA:                             ; CODE XREF: sub_4BD3B0+22Aj
                                            ; sub_4BD3B0+23Aj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BD5FF:                             ; CODE XREF: sub_4BD3B0+248j
    test    eax, eax
    jz      loc_4BD7E2
    mov     esi, offset a__                 ; ".."
    lea     eax, [esp+240h+var_208]

    loc_4BD610:                             ; CODE XREF: sub_4BD3B0+282j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4BD638
    test    cl, cl
    jz      short loc_4BD634
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4BD638
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BD610

    loc_4BD634:                             ; CODE XREF: sub_4BD3B0+26Cj
    xor     eax, eax
    jmp     short loc_4BD63D
    ; ---------------------------------------------------------------------------

    loc_4BD638:                             ; CODE XREF: sub_4BD3B0+268j
                                            ; sub_4BD3B0+278j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BD63D:                             ; CODE XREF: sub_4BD3B0+286j
    test    eax, eax
    jz      loc_4BD7E2
    lea     edi, [esp+240h+var_208]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     ebx, [ebp+0]
    repne scasb
    mov     eax, [ebp+4]
    not     ecx
    add     ecx, ebx
    push    ecx                             ; int
    push    offset aPackageData             ; int
    push    eax                             ; int
    mov     [ebp+0], ecx
    call    Network_ReAllocPacketBuffer
    mov     [ebp+4], eax
    lea     edx, [ebx+eax]
    lea     edi, [esp+24Ch+var_208]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+240h+var_22C]
    and     ecx, 3
    rep movsb
    mov     edx, [ebp+4]
    mov     ecx, [esp+240h+var_230]
    add     eax, edx
    add     eax, ecx
    mov     [eax], ebx
    mov     bl, [eax+8]
    and     bl, 1
    mov     [eax+8], bl
    mov     dl, byte ptr [esp+240h+var_21C]
    test    dl, 10h
    mov     cl, bl
    jz      loc_4BD77F
    mov     edi, [esp+240h+arg_0]
    or      cl, 1
    mov     [eax+8], cl
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+240h+var_104]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+240h+var_224]
    and     ecx, 3
    test    eax, eax
    rep movsb
    jnz     short loc_4BD726
    mov     edi, offset byte_503374
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+240h+var_104]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb

    loc_4BD726:                             ; CODE XREF: sub_4BD3B0+343j
    lea     edi, [esp+240h+var_208]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+240h+var_104]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     eax, [esp+240h+arg_8]
    mov     ecx, ebx
    and     ecx, 3
    push    eax
    rep movsb
    lea     ecx, [esp+244h+var_104]
    push    ebp
    push    ecx
    call    sub_4BD3B0
    mov     edx, [ebp+4]
    mov     ecx, [esp+240h+var_22C]
    add     ecx, edx
    mov     edx, [esp+240h+var_230]
    mov     [ecx+edx+4], eax
    jmp     short loc_4BD7D3
    ; ---------------------------------------------------------------------------

    loc_4BD77F:                             ; CODE XREF: sub_4BD3B0+306j
    and     cl, 0FEh
    mov     [eax+8], cl
    mov     esi, [ebp+0]
    lea     eax, [esi+9]
    mov     [ebp+0], eax
    push    eax                             ; int
    mov     eax, [ebp+4]
    push    offset aPackageData             ; int
    push    eax                             ; int
    call    Network_ReAllocPacketBuffer
    mov     ecx, [esp+24Ch+var_22C]
    mov     edx, [esp+24Ch+var_230]
    add     ecx, edx
    mov     [ebp+4], eax
    add     ecx, eax
    add     esp, 0Ch
    mov     [ecx+4], esi
    mov     edi, [ebp+4]
    mov     eax, [esp+240h+var_20C]
    add     esi, edi
    mov     ecx, eax
    mov     [esi+4], eax
    mov     eax, [esp+240h+arg_8]
    mov     dword ptr [esi], 0
    mov     byte ptr [esi+8], 0
    add     [eax], ecx

    loc_4BD7D3:                             ; CODE XREF: sub_4BD3B0+3CDj
    mov     eax, [esp+240h+var_230]
    mov     edi, [esp+240h+var_220]
    add     eax, 9
    mov     [esp+240h+var_230], eax

    loc_4BD7E2:                             ; CODE XREF: sub_4BD3B0+251j
                                            ; sub_4BD3B0+28Fj
    lea     edx, [esp+240h+var_21C]
    push    edx
    push    edi
    call    sub_4BC640
    test    eax, eax
    jz      loc_4BD5C9
    test    edi, edi
    jz      short loc_4BD81B
    mov     eax, [edi+200h]
    test    eax, eax
    jge     short loc_4BD812
    mov     eax, [edi+205h]
    push    eax                             ; hFindFile
    call    __findclose
    add     esp, 4

    loc_4BD812:                             ; CODE XREF: sub_4BD3B0+451j
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BD81B:                             ; CODE XREF: sub_4BD3B0+20Bj
                                            ; sub_4BD3B0+447j
    mov     eax, [esp+240h+var_228]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 230h
    retn    0Ch
    sub_4BD3B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BD830 proc near                    ; CODE XREF: .text:004BD284p
                                            ; sub_4BD830+147p

    var_123C= dword ptr -123Ch
    var_1238= dword ptr -1238h
    var_1234= dword ptr -1234h
    var_1230= dword ptr -1230h
    var_122C= dword ptr -122Ch
    var_1228= dword ptr -1228h
    var_1224= dword ptr -1224h
    var_1220= dword ptr -1220h
    var_121C= dword ptr -121Ch
    var_1218= dword ptr -1218h
    var_1214= dword ptr -1214h
    var_1210= dword ptr -1210h
    var_120A= byte ptr -120Ah
    var_1208= dword ptr -1208h
    var_1104= dword ptr -1104h
    var_1001= byte ptr -1001h
    var_1000= dword ptr -1000h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    mov     eax, 123Ch
    call    __alloca_probe
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+124Ch+arg_0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+124Ch+var_1208]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+124Ch+var_1208]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    cmp     byte ptr [esp+ecx+43h], 5Ch
    jz      short loc_4BD8A9
    mov     edi, offset byte_503374
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+124Ch+var_1208]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb

    loc_4BD8A9:                             ; CODE XREF: sub_4BD830+49j
    mov     ebp, [esp+124Ch+arg_4]
    mov     eax, [esp+124Ch+arg_8]
    xor     ecx, ecx
    mov     edx, [eax+ebp]
    mov     [esp+124Ch+var_1218], ecx
    cmp     edx, ecx
    jbe     loc_4BDD57
    lea     eax, [eax+ebp+4]
    mov     [esp+124Ch+var_122C], ecx
    mov     [esp+124Ch+var_1210], eax

    loc_4BD8D4:                             ; CODE XREF: sub_4BD830+521j
    mov     ecx, [esp+124Ch+var_122C]
    mov     edx, [esp+124Ch+var_1210]
    lea     edi, [esp+124Ch+var_1208]
    xor     eax, eax
    lea     ebx, [ebp+ecx+0]
    mov     ecx, [edx]
    add     ebx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+124Ch+var_1104]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+124Ch+var_1104]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, [ebx]
    or      ecx, 0FFFFFFFFh
    add     edi, ebp
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    test    byte ptr [ebx+8], 1
    jz      short loc_4BD981
    mov     eax, [esp+124Ch+arg_1C]
    mov     ecx, [esp+124Ch+arg_18]
    mov     edx, [esp+124Ch+arg_14]
    push    eax
    mov     eax, [esp+1250h+arg_10]
    push    ecx
    mov     ecx, [esp+1254h+arg_C]
    push    edx
    mov     edx, [ebx+4]
    push    eax
    push    ecx
    push    edx
    lea     eax, [esp+1264h+var_1104]
    push    ebp
    push    eax
    call    sub_4BD830
    jmp     loc_4BDD33
    ; ---------------------------------------------------------------------------

    loc_4BD981:                             ; CODE XREF: sub_4BD830+110j
    lea     ecx, [esp+124Ch+var_1104]
    push    offset aRb                      ; "rb"
    push    ecx
    call    sub_4BB2E0
    mov     esi, [ebx+4]
    mov     edi, eax
    mov     edx, [esp+124Ch+arg_C]
    add     esi, ebp
    push    edx
    mov     [esp+1250h+var_1220], edi
    mov     [esp+1250h+var_123C], esi
    call    _ftell
    mov     [esi], eax
    mov     eax, [edi+4]
    add     esp, 4
    test    eax, eax
    jz      short loc_4BD9C3
    mov     eax, [edi+8]
    mov     ecx, [eax+4]
    jmp     short loc_4BD9DB
    ; ---------------------------------------------------------------------------

    loc_4BD9C3:                             ; CODE XREF: sub_4BD830+189j
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_4BD9D9
    mov     ecx, [eax+10h]
    push    ecx
    call    __filelength
    add     esp, 4
    mov     ecx, eax
    jmp     short loc_4BD9DB
    ; ---------------------------------------------------------------------------

    loc_4BD9D9:                             ; CODE XREF: sub_4BD830+197j
    xor     ecx, ecx

    loc_4BD9DB:                             ; CODE XREF: sub_4BD830+191j
                                            ; sub_4BD830+1A7j
    mov     ebx, [esp+124Ch+arg_1C]
    mov     [esi+4], ecx
    test    bl, bl
    mov     [esi+8], bl
    jz      loc_4BDC00
    mov     eax, ecx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 0FFFFh
    xor     eax, edx
    mov     esi, eax
    mov     eax, ecx
    sub     esi, edx
    neg     esi
    cdq
    sbb     esi, esi
    and     edx, 0FFFFh
    add     eax, edx
    neg     esi
    sar     eax, 10h
    add     esi, eax
    lea     eax, ds:0[esi*4]
    push    eax
    push    offset aBlockSizes              ; "Block Sizes"
    call    sub_4D83B0
    mov     edx, [esp+1254h+arg_C]
    add     esp, 8
    mov     ebp, eax
    push    edx
    push    4
    push    esi
    push    ebp
    mov     [esp+125Ch+var_1228], ebp
    call    sub_4E5D40
    add     esp, 10h
    and     ebx, 0FFh
    push    ebx
    push    10000h
    call    sub_4D1AA0
    push    eax
    push    offset aPackBuffer              ; "Pack Buffer"
    mov     [esp+48h], eax
    call    sub_4D83B0
    add     esp, 8
    mov     edi, eax
    push    10000h
    push    offset aDataBuffer              ; "Data Buffer"
    call    sub_4D83B0
    mov     [esp+1254h+var_1234], eax
    mov     eax, [esp+1254h+var_123C]
    add     esp, 8
    mov     eax, [eax+4]
    test    esi, esi
    mov     [esp+124Ch+var_1238], eax
    jle     loc_4BDB66
    mov     [esp+124Ch+var_1230], ebp
    mov     [esp+124Ch+var_121C], esi
    jmp     short loc_4BDAA3
    ; ---------------------------------------------------------------------------

    loc_4BDA9F:                             ; CODE XREF: sub_4BD830+32Cj
    mov     eax, [esp+124Ch+var_1238]

    loc_4BDAA3:                             ; CODE XREF: sub_4BD830+26Dj
    cmp     eax, 10000h
    mov     ebp, 10000h
    jnb     short loc_4BDAB1
    mov     ebp, eax

    loc_4BDAB1:                             ; CODE XREF: sub_4BD830+27Dj
    mov     ecx, [esp+124Ch+var_1234]
    mov     edx, [esp+124Ch+var_1220]
    push    ebp
    push    ecx
    push    edx
    call    sub_4BB7C0
    push    1
    push    ebx
    mov     ecx, [esp+1254h+var_1234]
    mov     eax, [esp+48h]
    push    ebp
    lea     edx, [esp+1258h+var_1224]
    push    ecx
    push    edx
    push    edi
    mov     [esp+1264h+var_1224], eax
    call    sub_4D1820
    mov     ecx, [esp+124Ch+var_1230]
    mov     edx, [esp+124Ch+arg_C]
    mov     eax, [esp+124Ch+var_1224]
    push    edx
    mov     [ecx], eax
    call    _ftell
    mov     ebp, [esp+1250h+var_1224]
    mov     [esp+1250h+var_1214], eax
    mov     al, byte ptr [esp+1250h+arg_18]
    add     esp, 4
    test    al, al
    jz      short loc_4BDB26
    xor     ecx, ecx
    test    ebp, ebp
    jle     short loc_4BDB26

    loc_4BDB10:                             ; CODE XREF: sub_4BD830+2F4j
    mov     dl, byte ptr [esp+124Ch+var_1214]
    add     dl, cl
    xor     dl, al
    xor     dl, [ecx+edi]
    inc     ecx
    cmp     ecx, ebp
    not     dl
    mov     [ecx+edi-1], dl
    jl      short loc_4BDB10

    loc_4BDB26:                             ; CODE XREF: sub_4BD830+2D8j
                                            ; sub_4BD830+2DEj
    mov     eax, [esp+124Ch+arg_C]
    push    eax
    push    1
    push    ebp
    push    edi
    call    sub_4E5D40
    mov     edx, [esp+125Ch+var_1230]
    mov     ecx, [esp+125Ch+var_1238]
    mov     eax, [esp+125Ch+var_121C]
    add     esp, 10h
    add     edx, 4
    sub     ecx, 10000h
    dec     eax
    mov     [esp+124Ch+var_1230], edx
    mov     [esp+124Ch+var_1238], ecx
    mov     [esp+124Ch+var_121C], eax
    jnz     loc_4BDA9F
    mov     ebp, [esp+124Ch+var_1228]

    loc_4BDB66:                             ; CODE XREF: sub_4BD830+25Fj
    mov     ecx, [esp+124Ch+var_123C]
    mov     ebx, [esp+124Ch+arg_C]
    push    0
    mov     edx, [ecx]
    push    edx
    push    ebx
    call    _fseek
    add     esp, 0Ch
    push    ebx
    call    _ftell
    mov     dl, byte ptr [esp+1250h+arg_18]
    add     esp, 4
    test    dl, dl
    mov     [esp+124Ch+var_1228], eax
    jz      short loc_4BDBC1
    lea     eax, ds:0[esi*4]
    xor     ecx, ecx
    test    eax, eax
    jle     short loc_4BDBC1

    loc_4BDBA4:                             ; CODE XREF: sub_4BD830+38Fj
    mov     al, byte ptr [esp+124Ch+var_1228]
    add     al, cl
    xor     al, dl
    xor     al, [ecx+ebp]
    inc     ecx
    not     al
    mov     [ecx+ebp-1], al
    lea     eax, ds:0[esi*4]
    cmp     ecx, eax
    jl      short loc_4BDBA4

    loc_4BDBC1:                             ; CODE XREF: sub_4BD830+365j
                                            ; sub_4BD830+372j
    push    ebx
    push    4
    push    esi
    push    ebp
    call    sub_4E5D40
    add     esp, 10h
    push    2
    push    0
    push    ebx
    call    _fseek
    add     esp, 0Ch
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    edi                             ; int
    call    sub_4D85A0
    mov     ecx, [esp+1250h+var_1234]
    add     esp, 4
    push    ecx                             ; int
    call    sub_4D85A0
    mov     edi, [esp+1250h+var_1220]
    add     esp, 4
    jmp     short loc_4BDC7F
    ; ---------------------------------------------------------------------------

    loc_4BDC00:                             ; CODE XREF: sub_4BD830+1BAj
    test    ecx, ecx
    mov     ebp, ecx
    jbe     short loc_4BDC83

    loc_4BDC06:                             ; CODE XREF: sub_4BD830+44Dj
    cmp     ebp, 1000h
    mov     esi, 1000h
    jnb     short loc_4BDC15
    mov     esi, ebp

    loc_4BDC15:                             ; CODE XREF: sub_4BD830+3E1j
    lea     edx, [esp+124Ch+var_1000]
    push    esi
    push    edx
    push    edi
    call    sub_4BB7C0
    mov     eax, [esp+124Ch+arg_C]
    push    eax
    call    _ftell
    mov     dl, byte ptr [esp+1250h+arg_18]
    add     esp, 4
    test    dl, dl
    jz      short loc_4BDC60
    xor     ecx, ecx
    test    esi, esi
    jle     short loc_4BDC60

    loc_4BDC45:                             ; CODE XREF: sub_4BD830+42Ej
    mov     bl, al
    add     bl, cl
    xor     bl, dl
    xor     bl, byte ptr [esp+ecx+124Ch+var_1000]
    inc     ecx
    cmp     ecx, esi
    not     bl
    mov     [esp+ecx+124Ch+var_1001], bl
    jl      short loc_4BDC45

    loc_4BDC60:                             ; CODE XREF: sub_4BD830+40Dj
                                            ; sub_4BD830+413j
    mov     ecx, [esp+124Ch+arg_C]
    lea     edx, [esp+124Ch+var_1000]
    push    ecx
    push    1
    push    esi
    push    edx
    call    sub_4E5D40
    add     esp, 10h
    sub     ebp, esi
    jnz     short loc_4BDC06

    loc_4BDC7F:                             ; CODE XREF: sub_4BD830+3CEj
    mov     esi, [esp+124Ch+var_123C]

    loc_4BDC83:                             ; CODE XREF: sub_4BD830+3D4j
    mov     eax, [edi+4]
    test    eax, eax
    jz      short loc_4BDCB8
    mov     edx, [eax+0Ch]
    dec     edx
    mov     [eax+0Ch], edx
    mov     eax, [edi+4]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jnz     short loc_4BDCC3
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4BDCC3
    mov     eax, [eax]
    push    eax
    call    _fclose
    mov     ecx, [edi+4]
    add     esp, 4
    mov     dword ptr [ecx], 0
    jmp     short loc_4BDCC3
    ; ---------------------------------------------------------------------------

    loc_4BDCB8:                             ; CODE XREF: sub_4BD830+458j
    mov     edx, [edi]
    push    edx
    call    _fclose
    add     esp, 4

    loc_4BDCC3:                             ; CODE XREF: sub_4BD830+469j
                                            ; sub_4BD830+470j ...
    mov     eax, [edi+10h]
    test    eax, eax
    jz      short loc_4BDCD3
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BDCD3:                             ; CODE XREF: sub_4BD830+498j
    mov     eax, [edi+14h]
    test    eax, eax
    jz      short loc_4BDCE3
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BDCE3:                             ; CODE XREF: sub_4BD830+4A8j
    push    edi                             ; int
    call    sub_4D85A0
    mov     eax, [esp+1250h+arg_10]
    add     esp, 4
    test    eax, eax
    jz      short loc_4BDD2C
    mov     eax, [esp+124Ch+arg_4]
    xor     edx, edx
    mov     eax, [eax+8]
    lea     eax, [eax+eax*4]
    lea     ecx, [eax+eax*8]
    mov     eax, [esi]
    shl     ecx, 1
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*8]
    shl     eax, 1
    sub     eax, ecx
    div     [esp+124Ch+arg_14]
    add     eax, 5
    push    eax
    call    [esp+1250h+arg_10]
    add     esp, 4

    loc_4BDD2C:                             ; CODE XREF: sub_4BD830+4C5j
    mov     ebp, [esp+124Ch+arg_4]

    loc_4BDD33:                             ; CODE XREF: sub_4BD830+14Cj
    mov     edx, [esp+124Ch+var_122C]
    mov     eax, [esp+124Ch+var_1218]
    add     edx, 9
    inc     eax
    mov     [esp+124Ch+var_122C], edx
    mov     edx, [esp+124Ch+arg_8]
    mov     [esp+124Ch+var_1218], eax
    cmp     eax, [edx+ebp]
    jb      loc_4BD8D4

    loc_4BDD57:                             ; CODE XREF: sub_4BD830+92j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 123Ch
    retn    20h
    sub_4BD830 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BDD70 proc near                    ; CODE XREF: sub_4BE0B0+6Bp

    var_5C= dword ptr -5Ch
    FilePart= dword ptr -58h
    var_54= byte ptr -54h
    var_50= byte ptr -50h
    var_4F= byte ptr -4Fh
    var_4E= byte ptr -4Eh
    var_4D= byte ptr -4Dh
    var_4C= dword ptr -4Ch
    var_48= byte ptr -48h
    var_40= dword ptr -40h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 5Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+68h+arg_0]
    push    edi
    push    offset aRb                      ; "rb"
    push    esi
    call    _fopen
    mov     ebx, eax
    add     esp, 8
    test    ebx, ebx
    mov     [esp+6Ch+var_5C], ebx
    jnz     short loc_4BDD9D
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 5Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BDD9D:                             ; CODE XREF: sub_4BDD70+21j
    push    118h
    push    offset aOpenhapifileSt          ; "OPENHAPIFILE structure"
    call    sub_4D83B0
    mov     ebp, eax
    mov     eax, [esp+74h+arg_4]
    add     esp, 8
    lea     ecx, [esp+6Ch+FilePart]
    lea     edx, [ebp+14h]
    mov     [ebp+0], ebx
    push    ecx                             ; lpFilePart
    push    edx                             ; lpBuffer
    push    104h                            ; nBufferLength
    push    esi                             ; lpFileName
    mov     dword ptr [ebp+4], 0FFFFFFFFh
    mov     dword ptr [ebp+0Ch], 0
    mov     [ebp+10h], eax
    call    ds:GetFullPathNameA
    push    ebx
    push    1
    lea     eax, [esp+74h+var_54]
    push    14h
    push    eax
    call    sub_4E5BC0
    add     esp, 10h
    lea     ecx, [esp+6Ch+var_54]
    push    4                               ; size_t
    push    offset aHapi                    ; char *
    push    ecx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     loc_4BDED6
    mov     al, [esp+6Ch+var_50]
    test    al, al
    jnz     loc_4BDED6
    mov     al, [esp+6Ch+var_4F]
    test    al, al
    jnz     loc_4BDED6
    cmp     [esp+6Ch+var_4E], 1
    jnz     loc_4BDED6
    mov     al, [esp+6Ch+var_4D]
    test    al, al
    jnz     loc_4BDED6
    mov     edi, offset aCopyright0000C     ; "Copyright 0000 Cavedog Entertainment"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    2
    repne scasb
    not     ecx
    dec     ecx
    mov     esi, ecx
    mov     edx, esi
    neg     edx
    push    edx
    push    ebx
    call    _fseek
    add     esp, 0Ch
    lea     eax, [esp+6Ch+var_40]
    push    ebx
    push    esi
    push    1
    push    eax
    call    sub_4E5BC0
    add     esp, 10h
    mov     byte ptr [esp+esi+6Ch+var_40], 0
    push    4                               ; size_t
    push    offset a0000                    ; char *
    push    offset a0000                    ; char *
    push    offset aCopyright0000C          ; char *
    call    _strstr
    lea     ecx, [esp+7Ch+var_40]
    add     esp, 8
    sub     ecx, offset aCopyright0000C     ; "Copyright 0000 Cavedog Entertainment"
    add     eax, ecx
    push    eax                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     esi, offset aCopyright0000C     ; "Copyright 0000 Cavedog Entertainment"
    lea     eax, [esp+6Ch+var_40]

    loc_4BDEA9:                             ; CODE XREF: sub_4BDD70+157j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BDECD
    test    cl, cl
    jz      short loc_4BDEC9
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BDECD
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BDEA9

    loc_4BDEC9:                             ; CODE XREF: sub_4BDD70+143j
    xor     eax, eax
    jmp     short loc_4BDED2
    ; ---------------------------------------------------------------------------

    loc_4BDECD:                             ; CODE XREF: sub_4BDD70+13Fj
                                            ; sub_4BDD70+14Dj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BDED2:                             ; CODE XREF: sub_4BDD70+15Bj
    test    eax, eax
    jz      short loc_4BDEF4

    loc_4BDED6:                             ; CODE XREF: sub_4BDD70+96j
                                            ; sub_4BDD70+A2j ...
    push    ebx
    call    _fclose
    add     esp, 4
    push    ebp                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 5Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BDEF4:                             ; CODE XREF: sub_4BDD70+164j
    mov     eax, [esp+6Ch+var_4C]
    push    eax
    push    offset aHapifileHeader          ; "HAPIFILE header"
    call    sub_4D83B0
    add     esp, 8
    mov     [ebp+8], eax
    push    ebx
    call    _rewind
    mov     ecx, [esp+70h+var_4C]
    mov     edx, [ebp+8]
    add     esp, 4
    push    ebx
    push    1
    push    ecx
    push    edx
    call    sub_4E5BC0
    mov     ecx, [ebp+8]
    add     esp, 10h
    mov     dl, [ecx+0Ch]
    mov     byte ptr [esp+6Ch+arg_0], dl
    mov     eax, [esp+6Ch+arg_0]
    and     eax, 0FFh
    test    dl, dl
    jz      short loc_4BDF49
    mov     edx, eax
    shr     edx, 6
    shl     eax, 2
    or      edx, eax
    not     dl

    loc_4BDF49:                             ; CODE XREF: sub_4BDD70+1CBj
    mov     [ecx+0Ch], dl
    mov     ecx, [ebp+8]
    mov     edx, [esp+6Ch+var_4C]
    mov     al, [ecx+0Ch]
    mov     [esp+6Ch+var_48], al
    mov     esi, [ebp+8]
    add     esi, 14h
    mov     cl, al
    test    al, al
    lea     edi, [edx-14h]
    jz      short loc_4BDF85
    xor     eax, eax
    test    edi, edi
    jle     short loc_4BDF85

    loc_4BDF6F:                             ; CODE XREF: sub_4BDD70+213j
    mov     bl, [esi+eax]
    mov     dl, al
    add     dl, 14h
    xor     dl, cl
    not     bl
    xor     dl, bl
    mov     [esi+eax], dl
    inc     eax
    cmp     eax, edi
    jl      short loc_4BDF6F

    loc_4BDF85:                             ; CODE XREF: sub_4BDD70+1F7j
                                            ; sub_4BDD70+1FDj
    mov     eax, [ebp+8]
    mov     esi, [eax+10h]
    add     esi, eax
    mov     [eax+10h], esi
    mov     esi, [ebp+8]
    mov     ebx, [esi+10h]
    mov     edx, [ebx+4]
    mov     eax, [ebx]
    add     edx, esi
    dec     eax
    mov     [ebx+4], edx
    js      short loc_4BDFDD
    lea     edi, [eax+eax*8]
    inc     eax
    mov     [esp+6Ch+arg_0], eax

    loc_4BDFAB:                             ; CODE XREF: sub_4BDD70+26Bj
    mov     ecx, [ebx+4]
    mov     eax, edi
    add     eax, ecx
    mov     edx, [eax]
    mov     ecx, [eax+4]
    add     edx, esi
    add     ecx, esi
    mov     [eax], edx
    mov     dl, [eax+8]
    test    dl, 1
    mov     [eax+4], ecx
    jz      short loc_4BDFCF
    push    esi
    push    ecx
    call    sub_4BE010

    loc_4BDFCF:                             ; CODE XREF: sub_4BDD70+256j
    mov     eax, [esp+6Ch+arg_0]
    sub     edi, 9
    dec     eax
    mov     [esp+6Ch+arg_0], eax
    jnz     short loc_4BDFAB

    loc_4BDFDD:                             ; CODE XREF: sub_4BDD70+231j
    mov     eax, [esp+6Ch+arg_4]
    test    eax, eax
    jnz     short loc_4BDFF9
    mov     eax, [esp+6Ch+var_5C]
    push    eax
    call    _fclose
    add     esp, 4
    mov     dword ptr [ebp+0], 0

    loc_4BDFF9:                             ; CODE XREF: sub_4BDD70+273j
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 5Ch
    retn    8
    sub_4BDD70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BE010 proc near                    ; CODE XREF: sub_4BDD70+25Ap
                                            ; sub_4BE010+40p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_4]
    mov     edx, [ebp+4]
    mov     eax, [ebp+0]
    add     edx, esi
    dec     eax
    mov     [ebp+4], edx
    js      short loc_4BE065
    push    edi
    lea     edi, [eax+eax*8]
    inc     eax
    push    ebx
    mov     [esp+0Ch+arg_0], eax
    mov     bl, 1

    loc_4BE034:                             ; CODE XREF: sub_4BE010+51j
    mov     eax, [ebp+4]
    add     eax, edi
    mov     edx, [eax]
    mov     ecx, [eax+4]
    add     edx, esi
    add     ecx, esi
    mov     [eax], edx
    mov     dl, [eax+8]
    test    bl, dl
    mov     [eax+4], ecx
    jz      short loc_4BE055
    push    esi
    push    ecx
    call    sub_4BE010

    loc_4BE055:                             ; CODE XREF: sub_4BE010+3Cj
    mov     eax, [esp+0Ch+arg_0]
    sub     edi, 9
    dec     eax
    mov     [esp+0Ch+arg_0], eax
    jnz     short loc_4BE034
    pop     ebx
    pop     edi

    loc_4BE065:                             ; CODE XREF: sub_4BE010+16j
    pop     esi
    pop     ebp
    retn    8
    sub_4BE010 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BE070 proc near                    ; CODE XREF: sub_4B6110+26p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jz      short loc_4BE09D
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4BE088
    push    eax
    call    _fclose
    add     esp, 4

    loc_4BE088:                             ; CODE XREF: sub_4BE070+Dj
    mov     eax, [esi+8]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BE09D:                             ; CODE XREF: sub_4BE070+7j
    pop     esi
    retn    4
    sub_4BE070 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4BE0B0(LPCSTR lpFileName,int)
    sub_4BE0B0 proc near                    ; CODE XREF: sub_41D4C0+5Dp
                                            ; sub_41D4C0+97p ...

    FilePart= dword ptr -104h
    Buffer= byte ptr -100h
    lpFileName= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 104h
    push    ebx
    push    esi
    push    edi
    call    sub_4B6220
    mov     ebx, [esp+110h+lpFileName]
    mov     esi, eax
    lea     eax, [esp+110h+FilePart]
    lea     ecx, [esp+110h+Buffer]
    push    eax                             ; lpFilePart
    push    ecx                             ; lpBuffer
    push    100h                            ; nBufferLength
    push    ebx                             ; lpFileName
    call    ds:GetFullPathNameA
    mov     eax, [esi+61Ch]
    xor     edi, edi
    test    eax, eax
    jle     short loc_4BE112

    loc_4BE0E9:                             ; CODE XREF: sub_4BE0B0+60j
    mov     edx, [esi+618h]
    lea     ecx, [esp+110h+Buffer]
    mov     eax, [edx+edi*4]
    add     eax, 14h
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4BE126
    mov     eax, [esi+61Ch]
    inc     edi
    cmp     edi, eax
    jl      short loc_4BE0E9

    loc_4BE112:                             ; CODE XREF: sub_4BE0B0+37j
    mov     edx, [esp+110h+arg_4]
    push    edx
    push    ebx
    call    sub_4BDD70
    mov     edi, eax
    test    edi, edi
    jnz     short loc_4BE134

    loc_4BE126:                             ; CODE XREF: sub_4BE0B0+55j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 104h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BE134:                             ; CODE XREF: sub_4BE0B0+74j
    mov     eax, [esi+61Ch]
    mov     edx, [esi+618h]
    lea     ecx, ds:4[eax*4]
    push    ecx                             ; int
    push    offset aHapifileArray           ; int
    push    edx                             ; int
    call    Network_ReAllocPacketBuffer
    mov     ecx, [esi+61Ch]
    mov     [esi+618h], eax
    add     esp, 0Ch
    mov     [eax+ecx*4], edi
    mov     eax, [esi+61Ch]
    inc     eax
    mov     [esi+61Ch], eax
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 104h
    retn    8
    sub_4BE0B0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BE180 proc near                    ; CODE XREF: sub_41D4C0+16p
    push    ebx
    push    esi
    call    sub_4B6220
    mov     esi, eax
    xor     ebx, ebx
    mov     eax, [esi+61Ch]
    test    eax, eax
    jle     loc_4BE268
    push    edi

    loc_4BE19A:                             ; CODE XREF: sub_4BE180+E1j
    mov     eax, [esi+618h]
    mov     eax, [eax+ebx*4]
    cmp     dword ptr [eax], 0
    jnz     loc_4BE258
    add     eax, 14h
    push    offset aRb                      ; "rb"
    push    eax
    call    _fopen
    mov     ecx, [esi+618h]
    add     esp, 8
    mov     edx, [ecx+ebx*4]
    mov     [edx], eax
    mov     eax, [esi+618h]
    mov     edi, [eax+ebx*4]
    mov     eax, [edi]
    test    eax, eax
    jnz     short loc_4BE240
    test    edi, edi
    jz      short loc_4BE1FD
    test    eax, eax
    jz      short loc_4BE1E8
    push    eax
    call    _fclose
    add     esp, 4

    loc_4BE1E8:                             ; CODE XREF: sub_4BE180+5Dj
    mov     ecx, [edi+8]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BE1FD:                             ; CODE XREF: sub_4BE180+59j
    mov     edx, [esi+618h]
    mov     eax, ebx
    mov     dword ptr [edx+ebx*4], 0
    mov     ecx, [esi+61Ch]
    dec     ecx
    cmp     ebx, ecx
    jge     short loc_4BE230

    loc_4BE217:                             ; CODE XREF: sub_4BE180+AEj
    mov     ecx, [esi+618h]
    inc     eax
    mov     edx, [ecx+eax*4]
    mov     [ecx+eax*4-4], edx
    mov     ecx, [esi+61Ch]
    dec     ecx
    cmp     eax, ecx
    jl      short loc_4BE217

    loc_4BE230:                             ; CODE XREF: sub_4BE180+95j
    mov     ecx, [esi+61Ch]
    dec     ecx
    dec     ebx
    mov     [esi+61Ch], ecx
    jmp     short loc_4BE258
    ; ---------------------------------------------------------------------------

    loc_4BE240:                             ; CODE XREF: sub_4BE180+55j
    push    eax
    call    _fclose
    mov     edx, [esi+618h]
    add     esp, 4
    mov     eax, [edx+ebx*4]
    mov     dword ptr [eax], 0

    loc_4BE258:                             ; CODE XREF: sub_4BE180+26j
                                            ; sub_4BE180+BEj
    mov     eax, [esi+61Ch]
    inc     ebx
    cmp     ebx, eax
    jl      loc_4BE19A
    pop     edi

    loc_4BE268:                             ; CODE XREF: sub_4BE180+13j
    pop     esi
    pop     ebx
    retn
    sub_4BE180 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    ebx
    push    esi
    push    edi
    call    sub_4B6220
    mov     edi, eax
    xor     esi, esi
    mov     ecx, [edi+61Ch]
    test    ecx, ecx
    jle     loc_4BE30C
    mov     ebx, [edi+618h]
    mov     edx, [esp+10h]
    mov     eax, ebx

    loc_4BE296:                             ; CODE XREF: .text:004BE2A0j
    cmp     [eax], edx
    jz      short loc_4BE2A8
    inc     esi
    add     eax, 4
    cmp     esi, ecx
    jl      short loc_4BE296
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4BE2A8:                             ; CODE XREF: .text:004BE298j
    mov     ebx, [ebx+esi*4]
    test    ebx, ebx
    jz      short loc_4BE2D3
    mov     eax, [ebx]
    test    eax, eax
    jz      short loc_4BE2BE
    push    eax
    call    _fclose
    add     esp, 4

    loc_4BE2BE:                             ; CODE XREF: .text:004BE2B3j
    mov     eax, [ebx+8]
    push    eax
    call    sub_4D85A0
    add     esp, 4
    push    ebx
    call    sub_4D85A0
    add     esp, 4

    loc_4BE2D3:                             ; CODE XREF: .text:004BE2ADj
    mov     ecx, [edi+618h]
    mov     eax, esi
    mov     dword ptr [ecx+esi*4], 0
    mov     edx, [edi+61Ch]
    dec     edx
    cmp     esi, edx
    jge     short loc_4BE306

    loc_4BE2ED:                             ; CODE XREF: .text:004BE304j
    mov     ecx, [edi+618h]
    inc     eax
    mov     edx, [ecx+eax*4]
    mov     [ecx+eax*4-4], edx
    mov     ecx, [edi+61Ch]
    dec     ecx
    cmp     eax, ecx
    jl      short loc_4BE2ED

    loc_4BE306:                             ; CODE XREF: .text:004BE2EBj
    dec     dword ptr [edi+61Ch]

    loc_4BE30C:                             ; CODE XREF: .text:004BE284j
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BE320 proc near                    ; CODE XREF: sub_41D4C0+1C8p

    var_4= dword ptr -4

    push    ecx
    call    sub_4B6220
    mov     ecx, eax
    mov     [esp+4+var_4], ecx
    mov     eax, [ecx+61Ch]
    test    eax, eax
    jle     short loc_4BE3A5
    push    ebx
    xor     ebx, ebx
    test    eax, eax
    jle     short loc_4BE396
    push    edi
    push    esi
    push    ebp

    loc_4BE340:                             ; CODE XREF: sub_4BE320+71j
    mov     eax, [ecx+618h]
    mov     edx, [eax+ebx*4]
    mov     eax, [edx+8]
    mov     edi, [eax+10h]
    mov     eax, [edi]
    dec     eax
    js      short loc_4BE388
    lea     esi, [eax+eax*8]
    lea     ebp, [eax+1]

    loc_4BE35A:                             ; CODE XREF: sub_4BE320+66j
    mov     edx, [edi+4]
    lea     eax, [edx+esi+8]
    mov     dl, [edx+esi+8]
    and     dl, 0FDh
    mov     [eax], dl
    mov     eax, [edi+4]
    add     eax, esi
    test    byte ptr [eax+8], 1
    jz      short loc_4BE382
    mov     ecx, [eax+4]
    push    ecx
    call    sub_4BE3B0
    mov     ecx, [esp+14h+var_4]

    loc_4BE382:                             ; CODE XREF: sub_4BE320+53j
    sub     esi, 9
    dec     ebp
    jnz     short loc_4BE35A

    loc_4BE388:                             ; CODE XREF: sub_4BE320+32j
    mov     eax, [ecx+61Ch]
    inc     ebx
    cmp     ebx, eax
    jl      short loc_4BE340
    pop     ebp
    pop     esi
    pop     edi

    loc_4BE396:                             ; CODE XREF: sub_4BE320+1Bj
    push    1
    push    0FFFFFFFFh
    push    offset Data
    call    sub_4BE400
    pop     ebx

    loc_4BE3A5:                             ; CODE XREF: sub_4BE320+14j
    pop     ecx
    retn
    sub_4BE320 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BE3B0 proc near                    ; CODE XREF: sub_4BE320+59p
                                            ; sub_4BE3B0+37p

    arg_0= dword ptr  8

    push    edi
    mov     edi, [esp+arg_0]
    mov     eax, [edi]
    dec     eax
    js      short loc_4BE3F5
    push    esi
    push    ebp
    push    ebx
    lea     esi, [eax+eax*8]
    lea     ebp, [eax+1]
    mov     bl, 1

    loc_4BE3C5:                             ; CODE XREF: sub_4BE3B0+40j
    mov     eax, [edi+4]
    mov     dl, [eax+esi+8]
    lea     eax, [eax+esi+8]
    and     dl, 0FDh
    mov     [eax], dl
    mov     ecx, [edi+4]
    lea     eax, [ecx+esi]
    mov     cl, [ecx+esi+8]
    test    bl, cl
    jz      short loc_4BE3EC
    mov     edx, [eax+4]
    push    edx
    call    sub_4BE3B0

    loc_4BE3EC:                             ; CODE XREF: sub_4BE3B0+31j
    sub     esi, 9
    dec     ebp
    jnz     short loc_4BE3C5
    pop     ebx
    pop     ebp
    pop     esi

    loc_4BE3F5:                             ; CODE XREF: sub_4BE3B0+8j
    pop     edi
    retn    4
    sub_4BE3B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BE400 proc near                    ; CODE XREF: sub_4BE320+7Fp
                                            ; sub_4BE400+1B5p

    var_21C= dword ptr -21Ch
    var_218= byte ptr -218h
    var_118= dword ptr -118h
    var_104= dword ptr -104h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 21Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     edi, [esp+22Ch+arg_0]
    mov     ebx, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+22Ch+var_218]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+22Ch+var_218]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, offset asc_50372C          ; "*"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     eax, [esp+22Ch+arg_8]
    mov     ecx, ebp
    and     ecx, 3
    push    eax
    rep movsb
    mov     ecx, [esp+230h+arg_4]
    lea     edx, [esp+230h+var_118]
    push    ecx
    lea     eax, [esp+234h+var_218]
    push    edx
    push    eax
    call    sub_4BC4B0
    mov     esi, eax
    cmp     esi, 0FFFFFFFFh
    mov     [esp+22Ch+var_21C], esi
    jz      loc_4BE6AE

    loc_4BE498:                             ; CODE XREF: sub_4BE400+282j
    test    byte ptr [esp+22Ch+var_118], 10h
    jz      loc_4BE5BF
    mov     esi, offset Directory
    lea     eax, [esp+22Ch+var_104]

    loc_4BE4B2:                             ; CODE XREF: sub_4BE400+D0j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BE4D6
    test    cl, cl
    jz      short loc_4BE4D2
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BE4D6
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BE4B2

    loc_4BE4D2:                             ; CODE XREF: sub_4BE400+BCj
    xor     eax, eax
    jmp     short loc_4BE4DB
    ; ---------------------------------------------------------------------------

    loc_4BE4D6:                             ; CODE XREF: sub_4BE400+B8j
                                            ; sub_4BE400+C6j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BE4DB:                             ; CODE XREF: sub_4BE400+D4j
    test    eax, eax
    jz      loc_4BE66D
    mov     esi, offset a__                 ; ".."
    lea     eax, [esp+22Ch+var_104]

    loc_4BE4EF:                             ; CODE XREF: sub_4BE400+10Dj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4BE513
    test    cl, cl
    jz      short loc_4BE50F
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4BE513
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4BE4EF

    loc_4BE50F:                             ; CODE XREF: sub_4BE400+F9j
    xor     eax, eax
    jmp     short loc_4BE518
    ; ---------------------------------------------------------------------------

    loc_4BE513:                             ; CODE XREF: sub_4BE400+F5j
                                            ; sub_4BE400+103j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4BE518:                             ; CODE XREF: sub_4BE400+111j
    test    eax, eax
    jz      loc_4BE66D
    mov     edi, [esp+22Ch+arg_0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+22Ch+var_218]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    shr     ecx, 2
    mov     edi, edx
    lea     edx, [esp+22Ch+var_218]
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    push    eax
    rep movsb
    lea     edi, [esp+230h+var_104]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    lea     edx, [esp+230h+var_218]
    and     ecx, 3
    rep movsb
    mov     edi, offset byte_503374
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     eax, [esp+230h+var_21C]
    mov     ecx, ebp
    and     ecx, 3
    lea     edx, [esp+230h+var_218]
    rep movsb
    mov     ecx, [eax+200h]
    push    ecx
    push    edx
    call    sub_4BE400
    jmp     loc_4BE66D
    ; ---------------------------------------------------------------------------

    loc_4BE5BF:                             ; CODE XREF: sub_4BE400+A0j
    mov     ebp, [esi+200h]
    test    ebp, ebp
    jge     short loc_4BE5CD
    xor     ebp, ebp
    jmp     short loc_4BE5CE
    ; ---------------------------------------------------------------------------

    loc_4BE5CD:                             ; CODE XREF: sub_4BE400+1C7j
    inc     ebp

    loc_4BE5CE:                             ; CODE XREF: sub_4BE400+1CBj
    cmp     ebp, [ebx+61Ch]
    jge     loc_4BE671

    loc_4BE5DA:                             ; CODE XREF: sub_4BE400+267j
    mov     edi, [esp+22Ch+arg_0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+22Ch+var_218]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+22Ch+var_218]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+22Ch+var_104]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     eax, [esp+22Ch+var_218]
    and     ecx, 3
    push    eax                             ; char *
    rep movsb
    mov     ecx, [ebx+618h]
    mov     edx, [ecx+ebp*4]
    mov     eax, [edx+8]
    mov     ecx, [eax+10h]
    push    ecx                             ; int
    call    sub_4BB4E0
    test    eax, eax
    jz      short loc_4BE65E
    mov     cl, [eax+8]
    test    cl, 1
    jnz     short loc_4BE65E
    or      cl, 2
    mov     [eax+8], cl

    loc_4BE65E:                             ; CODE XREF: sub_4BE400+24Ej
                                            ; sub_4BE400+256j
    mov     eax, [ebx+61Ch]
    inc     ebp
    cmp     ebp, eax
    jl      loc_4BE5DA

    loc_4BE66D:                             ; CODE XREF: sub_4BE400+DDj
                                            ; sub_4BE400+11Aj ...
    mov     esi, [esp+22Ch+var_21C]

    loc_4BE671:                             ; CODE XREF: sub_4BE400+1D4j
    lea     edx, [esp+22Ch+var_118]
    push    edx
    push    esi
    call    sub_4BC640
    cmp     eax, 0FFFFFFFFh
    jnz     loc_4BE498
    test    esi, esi
    jz      short loc_4BE6AE
    mov     eax, [esi+200h]
    test    eax, eax
    jge     short loc_4BE6A5
    mov     eax, [esi+205h]
    push    eax                             ; hFindFile
    call    __findclose
    add     esp, 4

    loc_4BE6A5:                             ; CODE XREF: sub_4BE400+294j
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4BE6AE:                             ; CODE XREF: sub_4BE400+92j
                                            ; sub_4BE400+28Aj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 21Ch
    retn    0Ch
    sub_4BE400 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BE6C0 proc near                    ; CODE XREF: sub_4BCA30+CBp
                                            ; sub_4BCB50+161p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    mov     eax, [ecx+0Ch]
    push    ebx
    mov     edx, [esp+10h+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     [esp+1Ch+var_C], ecx
    sub     eax, edi
    sar     eax, 2
    cmp     eax, edx
    jnb     loc_4BE837
    mov     ecx, [ecx+4]
    test    ecx, ecx
    jnz     short loc_4BE6ED
    xor     eax, eax
    jmp     short loc_4BE6F4
    ; ---------------------------------------------------------------------------

    loc_4BE6ED:                             ; CODE XREF: sub_4BE6C0+27j
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 2

    loc_4BE6F4:                             ; CODE XREF: sub_4BE6C0+2Bj
    cmp     edx, eax
    jnb     short loc_4BE709
    test    ecx, ecx
    jnz     short loc_4BE700
    xor     eax, eax
    jmp     short loc_4BE70B
    ; ---------------------------------------------------------------------------

    loc_4BE700:                             ; CODE XREF: sub_4BE6C0+3Aj
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 2
    jmp     short loc_4BE70B
    ; ---------------------------------------------------------------------------

    loc_4BE709:                             ; CODE XREF: sub_4BE6C0+36j
    mov     eax, edx

    loc_4BE70B:                             ; CODE XREF: sub_4BE6C0+3Ej
                                            ; sub_4BE6C0+47j
    test    ecx, ecx
    jnz     short loc_4BE713
    xor     edi, edi
    jmp     short loc_4BE718
    ; ---------------------------------------------------------------------------

    loc_4BE713:                             ; CODE XREF: sub_4BE6C0+4Dj
    sub     edi, ecx
    sar     edi, 2

    loc_4BE718:                             ; CODE XREF: sub_4BE6C0+51j
    add     eax, edi
    test    eax, eax
    mov     [esp+1Ch+var_4], eax
    jge     short loc_4BE724
    xor     eax, eax

    loc_4BE724:                             ; CODE XREF: sub_4BE6C0+60j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     edx, [esp+20h+var_C]
    mov     ecx, [esp+20h+arg_0]
    add     esp, 4
    mov     [esp+1Ch+var_8], eax
    mov     esi, [edx+4]
    mov     ebx, eax
    cmp     esi, ecx
    jz      short loc_4BE763

    loc_4BE749:                             ; CODE XREF: sub_4BE6C0+A1j
    test    ebx, ebx
    jz      short loc_4BE755
    push    esi
    mov     ecx, ebx
    call    sub_4C91A0

    loc_4BE755:                             ; CODE XREF: sub_4BE6C0+8Bj
    mov     ecx, [esp+1Ch+arg_0]
    add     esi, 4
    add     ebx, 4
    cmp     esi, ecx
    jnz     short loc_4BE749

    loc_4BE763:                             ; CODE XREF: sub_4BE6C0+87j
    mov     edi, [esp+1Ch+arg_4]
    mov     esi, ebx
    test    edi, edi
    jbe     short loc_4BE78B
    mov     ebp, [esp+1Ch+arg_8]

    loc_4BE771:                             ; CODE XREF: sub_4BE6C0+C1j
    test    esi, esi
    jz      short loc_4BE77D
    push    ebp
    mov     ecx, esi
    call    sub_4C91A0

    loc_4BE77D:                             ; CODE XREF: sub_4BE6C0+B3j
    add     esi, 4
    dec     edi
    jnz     short loc_4BE771
    mov     edi, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+arg_0]

    loc_4BE78B:                             ; CODE XREF: sub_4BE6C0+ABj
    mov     edx, [esp+1Ch+var_C]
    lea     eax, ds:0[edi*4]
    mov     ebp, [edx+8]
    lea     edi, [ebx+eax]
    cmp     ecx, ebp
    jz      short loc_4BE7BE
    mov     esi, edi
    sub     esi, ebx
    add     esi, ecx
    sub     esi, eax

    loc_4BE7A8:                             ; CODE XREF: sub_4BE6C0+FCj
    test    edi, edi
    jz      short loc_4BE7B4
    push    esi
    mov     ecx, edi
    call    sub_4C91A0

    loc_4BE7B4:                             ; CODE XREF: sub_4BE6C0+EAj
    add     esi, 4
    add     edi, 4
    cmp     esi, ebp
    jnz     short loc_4BE7A8

    loc_4BE7BE:                             ; CODE XREF: sub_4BE6C0+DEj
    mov     edi, [esp+1Ch+var_C]
    mov     ebx, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, ebx
    jz      short loc_4BE7DA

    loc_4BE7CC:                             ; CODE XREF: sub_4BE6C0+118j
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 4
    cmp     esi, ebx
    jnz     short loc_4BE7CC

    loc_4BE7DA:                             ; CODE XREF: sub_4BE6C0+10Aj
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+20h+var_8]
    mov     eax, [esp+20h+var_4]
    add     esp, 4
    lea     ecx, [edx+eax*4]
    mov     [edi+0Ch], ecx
    mov     ecx, [edi+4]
    test    ecx, ecx
    jnz     short loc_4BE816
    mov     ecx, [esp+1Ch+arg_4]
    xor     eax, eax
    add     ecx, eax
    mov     [edi+4], edx
    lea     eax, [edx+ecx*4]
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BE816:                             ; CODE XREF: sub_4BE6C0+139j
    mov     eax, [edi+8]
    mov     [edi+4], edx
    sub     eax, ecx
    mov     ecx, [esp+1Ch+arg_4]
    sar     eax, 2
    add     ecx, eax
    lea     eax, [edx+ecx*4]
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BE837:                             ; CODE XREF: sub_4BE6C0+1Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     eax, edi
    sub     eax, ebp
    sar     eax, 2
    cmp     eax, edx
    jnb     short loc_4BE8C3
    lea     eax, ds:0[edx*4]
    cmp     ebp, edi
    mov     [esp+1Ch+arg_0], eax
    lea     ebx, [ebp+eax+0]
    jz      short loc_4BE87B
    mov     esi, ebx
    sub     esi, eax

    loc_4BE85D:                             ; CODE XREF: sub_4BE6C0+1B5j
    test    ebx, ebx
    jz      short loc_4BE86D
    push    esi
    mov     ecx, ebx
    call    sub_4C91A0
    mov     edx, [esp+1Ch+arg_4]

    loc_4BE86D:                             ; CODE XREF: sub_4BE6C0+19Fj
    add     esi, 4
    add     ebx, 4
    cmp     esi, edi
    jnz     short loc_4BE85D
    mov     ecx, [esp+1Ch+var_C]

    loc_4BE87B:                             ; CODE XREF: sub_4BE6C0+197j
    mov     esi, [ecx+8]
    mov     ebx, [esp+1Ch+arg_8]
    mov     eax, esi
    sub     eax, ebp
    sar     eax, 2
    sub     edx, eax
    jz      short loc_4BE8A5
    mov     edi, edx

    loc_4BE88F:                             ; CODE XREF: sub_4BE6C0+1DFj
    test    esi, esi
    jz      short loc_4BE89B
    push    ebx
    mov     ecx, esi
    call    sub_4C91A0

    loc_4BE89B:                             ; CODE XREF: sub_4BE6C0+1D1j
    add     esi, 4
    dec     edi
    jnz     short loc_4BE88F
    mov     ecx, [esp+1Ch+var_C]

    loc_4BE8A5:                             ; CODE XREF: sub_4BE6C0+1CBj
    mov     edi, [ecx+8]
    mov     esi, ebp
    cmp     ebp, edi
    jz      loc_4BE934

    loc_4BE8B2:                             ; CODE XREF: sub_4BE6C0+1FFj
    push    ebx
    mov     ecx, esi
    call    sub_4C93B0
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_4BE8B2
    jmp     short loc_4BE934
    ; ---------------------------------------------------------------------------

    loc_4BE8C3:                             ; CODE XREF: sub_4BE6C0+184j
    test    edx, edx
    jbe     short loc_4BE93F
    shl     edx, 2
    mov     esi, edi
    mov     ebx, edi
    sub     esi, edx
    mov     [esp+1Ch+arg_0], edx
    cmp     esi, edi
    jz      short loc_4BE8F6

    loc_4BE8D8:                             ; CODE XREF: sub_4BE6C0+22Cj
    test    ebx, ebx
    jz      short loc_4BE8E4
    push    esi
    mov     ecx, ebx
    call    sub_4C91A0

    loc_4BE8E4:                             ; CODE XREF: sub_4BE6C0+21Aj
    add     esi, 4
    add     ebx, 4
    cmp     esi, edi
    jnz     short loc_4BE8D8
    mov     ecx, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]

    loc_4BE8F6:                             ; CODE XREF: sub_4BE6C0+216j
    mov     edi, [ecx+8]
    mov     esi, edi
    sub     esi, edx
    cmp     ebp, esi
    jz      short loc_4BE913

    loc_4BE901:                             ; CODE XREF: sub_4BE6C0+251j
    sub     esi, 4
    sub     edi, 4
    push    esi
    mov     ecx, edi
    call    sub_4C93B0
    cmp     esi, ebp
    jnz     short loc_4BE901

    loc_4BE913:                             ; CODE XREF: sub_4BE6C0+23Fj
    mov     edx, [esp+1Ch+arg_0]
    mov     esi, ebp
    lea     edi, [ebp+edx+0]
    cmp     ebp, edi
    jz      short loc_4BE934
    mov     ebx, [esp+1Ch+arg_8]

    loc_4BE925:                             ; CODE XREF: sub_4BE6C0+272j
    push    ebx
    mov     ecx, esi
    call    sub_4C93B0
    add     esi, 4
    cmp     esi, edi
    jnz     short loc_4BE925

    loc_4BE934:                             ; CODE XREF: sub_4BE6C0+1ECj
                                            ; sub_4BE6C0+201j ...
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, [esp+1Ch+arg_0]
    add     [eax+8], ecx

    loc_4BE93F:                             ; CODE XREF: sub_4BE6C0+205j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_4BE6C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BE950 proc near                    ; CODE XREF: .text:00417D14p
                                            ; .text:00417DE9p ...

    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 30h
    push    esi
    mov     esi, [esp+34h+arg_0]
    test    esi, esi
    jnz     short loc_4BE9CB
    lea     eax, [esp+34h+var_30]
    push    eax
    call    sub_4C5E70
    mov     esi, eax
    test    esi, esi
    jz      loc_4BEA10
    lea     ecx, [esp+34h+arg_10]
    lea     edx, [esp+34h+arg_C]
    push    ecx
    lea     eax, [esp+38h+arg_8]
    push    edx
    lea     ecx, [esp+3Ch+arg_4]
    push    eax
    lea     edx, [esp+40h+var_30]
    push    ecx
    push    edx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BE9B8
    mov     eax, [esp+34h+arg_14]
    mov     ecx, [esp+34h+arg_10]
    mov     edx, [esp+34h+arg_C]
    push    eax
    mov     eax, [esp+38h+arg_8]
    push    ecx
    mov     ecx, [esp+3Ch+arg_4]
    push    edx
    push    eax
    lea     edx, [esp+44h+var_30]
    push    ecx
    push    edx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BE9B8:                             ; CODE XREF: sub_4BE950+40j
    lea     eax, [esp+34h+var_30]
    push    eax
    call    sub_4C5FA0
    mov     eax, esi
    pop     esi
    add     esp, 30h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4BE9CB:                             ; CODE XREF: sub_4BE950+Aj
    lea     ecx, [esp+34h+arg_10]
    lea     edx, [esp+34h+arg_C]
    push    ecx
    lea     eax, [esp+38h+arg_8]
    push    edx
    lea     ecx, [esp+3Ch+arg_4]
    push    eax
    push    ecx
    push    esi
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BEA0B
    mov     edx, [esp+34h+arg_14]
    mov     eax, [esp+34h+arg_10]
    mov     ecx, [esp+34h+arg_C]
    push    edx
    mov     edx, [esp+38h+arg_8]
    push    eax
    mov     eax, [esp+3Ch+arg_4]
    push    ecx
    push    edx
    push    eax
    push    esi
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BEA0B:                             ; CODE XREF: sub_4BE950+97j
    mov     esi, 1

    loc_4BEA10:                             ; CODE XREF: sub_4BE950+1Aj
    mov     eax, esi
    pop     esi
    add     esp, 30h
    retn    18h
    sub_4BE950 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BEA20 proc near                    ; CODE XREF: sub_4BE950+39p
                                            ; sub_4BE950+90p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 10h
    mov     eax, [esp+10h+arg_C]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+1Ch+arg_4]
    mov     eax, [eax]
    push    edi
    mov     ebp, [esp+20h+arg_8]
    mov     edi, [esi]
    xor     ecx, ecx
    cmp     edi, eax
    mov     edx, [ebp+0]
    setle   cl
    mov     [esp+20h+arg_4], ecx
    mov     ecx, [esp+20h+arg_10]
    xor     ebx, ebx
    mov     ecx, [ecx]
    cmp     edx, ecx
    setle   bl
    sub     ecx, edx
    mov     [esp+20h+arg_8], ebx
    lea     edx, [esp+20h+var_10]
    sub     eax, edi
    mov     ebx, ecx
    mov     ecx, [esp+20h+arg_0]
    push    edx
    mov     edi, eax
    call    sub_4C6AE0
    mov     edx, [esi]
    mov     ecx, [esp+20h+var_10]
    cmp     edx, ecx
    jge     short loc_4BEAA6
    mov     eax, [esp+20h+arg_4]
    test    eax, eax
    jnz     short loc_4BEA8A
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEA8A:                             ; CODE XREF: sub_4BEA20+5Cj
    test    edi, edi
    jz      loc_4BEC52
    mov     eax, ecx
    sub     eax, edx
    imul    eax, ebx
    cdq
    idiv    edi
    mov     edx, [ebp+0]
    add     edx, eax
    mov     [ebp+0], edx
    mov     [esi], ecx

    loc_4BEAA6:                             ; CODE XREF: sub_4BEA20+54j
    mov     edx, [ebp+0]
    mov     eax, [esp+20h+var_C]
    cmp     edx, eax
    jge     short loc_4BEAE1
    cmp     [esp+20h+arg_8], 0
    jnz     short loc_4BEAC4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEAC4:                             ; CODE XREF: sub_4BEA20+96j
    test    ebx, ebx
    jz      loc_4BEC52
    sub     eax, edx
    imul    eax, edi
    cdq
    idiv    ebx
    mov     edx, [esi]
    add     edx, eax
    mov     eax, [esp+20h+var_C]
    mov     [esi], edx
    mov     [ebp+0], eax

    loc_4BEAE1:                             ; CODE XREF: sub_4BEA20+8Fj
    mov     edx, [esi]
    mov     eax, [esp+20h+var_8]
    cmp     edx, eax
    jle     short loc_4BEB1C
    cmp     [esp+20h+arg_4], 0
    jz      short loc_4BEAFE
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEAFE:                             ; CODE XREF: sub_4BEA20+D0j
    test    edi, edi
    jz      loc_4BEC52
    sub     eax, edx
    imul    eax, ebx
    cdq
    idiv    edi
    mov     edx, [ebp+0]
    add     edx, eax
    mov     [ebp+0], edx
    mov     edx, [esp+20h+var_8]
    mov     [esi], edx

    loc_4BEB1C:                             ; CODE XREF: sub_4BEA20+C9j
    mov     edx, [ebp+0]
    mov     eax, [esp+20h+var_4]
    cmp     edx, eax
    jle     short loc_4BEB57
    cmp     [esp+20h+arg_8], 0
    jz      short loc_4BEB3A
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEB3A:                             ; CODE XREF: sub_4BEA20+10Cj
    test    ebx, ebx
    jz      loc_4BEC52
    sub     eax, edx
    imul    eax, edi
    cdq
    idiv    ebx
    mov     edx, [esi]
    add     edx, eax
    mov     eax, [esp+20h+var_4]
    mov     [esi], edx
    mov     [ebp+0], eax

    loc_4BEB57:                             ; CODE XREF: sub_4BEA20+105j
    mov     ebp, [esp+20h+arg_C]
    mov     edx, [ebp+0]
    cmp     edx, ecx
    jge     short loc_4BEB97
    mov     eax, [esp+20h+arg_4]
    test    eax, eax
    jz      short loc_4BEB76
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEB76:                             ; CODE XREF: sub_4BEA20+148j
    test    edi, edi
    jz      loc_4BEC52
    mov     eax, ecx
    mov     esi, [esp+20h+arg_10]
    sub     eax, edx
    imul    eax, ebx
    cdq
    idiv    edi
    mov     edx, [esi]
    add     edx, eax
    mov     [esi], edx
    mov     [ebp+0], ecx
    jmp     short loc_4BEB9B
    ; ---------------------------------------------------------------------------

    loc_4BEB97:                             ; CODE XREF: sub_4BEA20+140j
    mov     esi, [esp+20h+arg_10]

    loc_4BEB9B:                             ; CODE XREF: sub_4BEA20+175j
    mov     edx, [esi]
    mov     ecx, [esp+20h+var_C]
    cmp     edx, ecx
    jge     short loc_4BEBD5
    mov     eax, [esp+20h+arg_8]
    test    eax, eax
    jz      short loc_4BEBB9
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEBB9:                             ; CODE XREF: sub_4BEA20+18Bj
    test    ebx, ebx
    jz      loc_4BEC52
    mov     eax, ecx
    sub     eax, edx
    imul    eax, edi
    cdq
    idiv    ebx
    mov     edx, [ebp+0]
    add     edx, eax
    mov     [ebp+0], edx
    mov     [esi], ecx

    loc_4BEBD5:                             ; CODE XREF: sub_4BEA20+183j
    mov     edx, [ebp+0]
    mov     ecx, [esp+20h+var_8]
    cmp     edx, ecx
    jle     short loc_4BEC0B
    mov     eax, [esp+20h+arg_4]
    test    eax, eax
    jnz     short loc_4BEBF4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEBF4:                             ; CODE XREF: sub_4BEA20+1C6j
    test    edi, edi
    jz      short loc_4BEC52
    mov     eax, ecx
    sub     eax, edx
    imul    eax, ebx
    cdq
    idiv    edi
    mov     edx, [esi]
    add     edx, eax
    mov     [esi], edx
    mov     [ebp+0], ecx

    loc_4BEC0B:                             ; CODE XREF: sub_4BEA20+1BEj
    mov     ecx, [esi]
    mov     eax, [esp+20h+var_4]
    cmp     ecx, eax
    jle     short loc_4BEC5E
    mov     edx, [esp+20h+arg_8]
    test    edx, edx
    jnz     short loc_4BEC29
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEC29:                             ; CODE XREF: sub_4BEA20+1FBj
    test    ebx, ebx
    jz      short loc_4BEC52
    sub     eax, ecx
    mov     ecx, [ebp+0]
    imul    eax, edi
    cdq
    idiv    ebx
    add     ecx, eax
    mov     eax, 1
    mov     [ebp+0], ecx
    mov     ecx, [esp+20h+var_4]
    mov     [esi], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEC52:                             ; CODE XREF: sub_4BEA20+6Cj
                                            ; sub_4BEA20+A6j ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BEC5E:                             ; CODE XREF: sub_4BEA20+1F3j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 10h
    retn    14h
    sub_4BEA20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BEC70 proc near                    ; CODE XREF: sub_4BF7B0+43p
                                            ; sub_4BF7B0+5Bp ...

    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 30h
    push    edi
    call    sub_4B6220
    mov     edi, eax
    mov     eax, [edi+0C8h]
    test    eax, eax
    jnz     short loc_4BEC8E
    xor     eax, eax
    pop     edi
    add     esp, 30h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4BEC8E:                             ; CODE XREF: sub_4BEC70+13j
    push    esi
    mov     esi, [esp+38h+arg_0]
    test    esi, esi
    jnz     short loc_4BED0E
    lea     eax, [esp+38h+var_30]
    push    eax
    call    sub_4C5E70
    mov     esi, eax
    test    esi, esi
    jz      loc_4BED5A
    lea     ecx, [esp+38h+arg_10]
    lea     edx, [esp+38h+arg_C]
    push    ecx
    lea     eax, [esp+3Ch+arg_8]
    push    edx
    lea     ecx, [esp+40h+arg_4]
    push    eax
    lea     edx, [esp+44h+var_30]
    push    ecx
    push    edx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BECFA
    mov     eax, [edi+0C8h]
    mov     ecx, [esp+38h+arg_14]
    mov     edx, [esp+38h+arg_10]
    push    eax
    mov     eax, [esp+3Ch+arg_C]
    push    ecx
    mov     ecx, [esp+40h+arg_8]
    push    edx
    mov     edx, [esp+44h+arg_4]
    push    eax
    push    ecx
    lea     eax, [esp+4Ch+var_30]
    push    edx
    push    eax
    call    sub_4CC8DF
    add     esp, 1Ch

    loc_4BECFA:                             ; CODE XREF: sub_4BEC70+5Bj
    lea     ecx, [esp+38h+var_30]
    push    ecx
    call    sub_4C5FA0
    mov     eax, esi
    pop     esi
    pop     edi
    add     esp, 30h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4BED0E:                             ; CODE XREF: sub_4BEC70+25j
    lea     edx, [esp+38h+arg_10]
    lea     eax, [esp+38h+arg_C]
    push    edx
    lea     ecx, [esp+3Ch+arg_8]
    push    eax
    lea     edx, [esp+40h+arg_4]
    push    ecx
    push    edx
    push    esi
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BED55
    mov     eax, [edi+0C8h]
    mov     ecx, [esp+38h+arg_14]
    mov     edx, [esp+38h+arg_10]
    push    eax
    mov     eax, [esp+3Ch+arg_C]
    push    ecx
    mov     ecx, [esp+40h+arg_8]
    push    edx
    mov     edx, [esp+44h+arg_4]
    push    eax
    push    ecx
    push    edx
    push    esi
    call    sub_4CC8DF
    add     esp, 1Ch

    loc_4BED55:                             ; CODE XREF: sub_4BEC70+BAj
    mov     esi, 1

    loc_4BED5A:                             ; CODE XREF: sub_4BEC70+35j
    mov     eax, esi
    pop     esi
    pop     edi
    add     esp, 30h
    retn    18h
    sub_4BEC70 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 30h
    push    esi
    push    edi
    call    sub_4B6220
    mov     esi, [esp+3Ch]
    mov     edi, eax
    test    esi, esi
    jnz     short loc_4BEDFB
    lea     eax, [esp+8]
    push    eax
    call    sub_4C5E70
    mov     esi, eax
    test    esi, esi
    jz      loc_4BEE47
    lea     ecx, [esp+4Ch]
    lea     edx, [esp+48h]
    push    ecx
    lea     eax, [esp+48h]
    push    edx
    lea     ecx, [esp+48h]
    push    eax
    lea     edx, [esp+14h]
    push    ecx
    push    edx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BEDE7
    mov     eax, [edi+0C0h]
    mov     ecx, [esp+50h]
    mov     edx, [esp+4Ch]
    push    eax
    mov     eax, [esp+4Ch]
    push    ecx
    mov     ecx, [esp+4Ch]
    push    edx
    mov     edx, [esp+4Ch]
    push    eax
    push    ecx
    lea     eax, [esp+1Ch]
    push    edx
    push    eax
    call    sub_4CC8DF
    add     esp, 1Ch

    loc_4BEDE7:                             ; CODE XREF: .text:004BEDB8j
    lea     ecx, [esp+8]
    push    ecx
    call    sub_4C5FA0
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 30h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4BEDFB:                             ; CODE XREF: .text:004BED82j
    lea     edx, [esp+4Ch]
    lea     eax, [esp+48h]
    push    edx
    lea     ecx, [esp+48h]
    push    eax
    lea     edx, [esp+48h]
    push    ecx
    push    edx
    push    esi
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BEE42
    mov     eax, [edi+0C0h]
    mov     ecx, [esp+50h]
    mov     edx, [esp+4Ch]
    push    eax
    mov     eax, [esp+4Ch]
    push    ecx
    mov     ecx, [esp+4Ch]
    push    edx
    mov     edx, [esp+4Ch]
    push    eax
    push    ecx
    push    edx
    push    esi
    call    sub_4CC8DF
    add     esp, 1Ch

    loc_4BEE42:                             ; CODE XREF: .text:004BEE17j
    mov     esi, 1

    loc_4BEE47:                             ; CODE XREF: .text:004BED92j
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 30h
    retn    18h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BEE60 proc near                    ; CODE XREF: sub_466780+1CFp
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+536p

    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 64h
    push    esi
    mov     esi, [esp+68h+arg_0]
    test    esi, esi
    jnz     loc_4BEF76
    lea     eax, [esp+68h+var_60]
    push    eax
    call    sub_4C5E70
    mov     esi, eax
    test    esi, esi
    jz      loc_4BEFD3
    mov     ecx, [esp+68h+arg_4]
    mov     eax, [esp+68h+arg_8]
    mov     [esp+68h+arg_4], ecx
    mov     [esp+68h+var_64], ecx
    lea     ecx, [esp+68h+var_60]
    mov     [esp+68h+arg_8], eax
    test    ecx, ecx
    mov     [esp+68h+arg_0], eax
    jnz     short loc_4BEF1B
    lea     edx, [esp+68h+var_30]
    push    edx
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4BEF63
    lea     eax, [esp+68h+arg_8]
    lea     ecx, [esp+68h+arg_4]
    push    eax
    lea     edx, [esp+6Ch+arg_0]
    push    ecx
    lea     eax, [esp+70h+var_64]
    push    edx
    lea     ecx, [esp+74h+var_30]
    push    eax
    push    ecx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BEEFE
    mov     edx, [esp+68h+arg_C]
    mov     eax, [esp+68h+arg_8]
    mov     ecx, [esp+68h+arg_4]
    push    edx
    mov     edx, [esp+6Ch+arg_0]
    push    eax
    mov     eax, [esp+70h+var_64]
    push    ecx
    push    edx
    lea     ecx, [esp+78h+var_30]
    push    eax
    push    ecx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BEEFE:                             ; CODE XREF: sub_4BEE60+76j
    lea     edx, [esp+68h+var_30]
    push    edx
    call    sub_4C5FA0
    lea     edx, [esp+68h+var_60]
    push    edx
    call    sub_4C5FA0
    mov     eax, esi
    pop     esi
    add     esp, 64h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4BEF1B:                             ; CODE XREF: sub_4BEE60+42j
    lea     eax, [esp+68h+arg_8]
    lea     ecx, [esp+68h+arg_4]
    push    eax
    lea     edx, [esp+6Ch+arg_0]
    push    ecx
    lea     eax, [esp+70h+var_64]
    push    edx
    lea     ecx, [esp+74h+var_60]
    push    eax
    push    ecx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BEF63
    mov     edx, [esp+68h+arg_C]
    mov     eax, [esp+68h+arg_8]
    mov     ecx, [esp+68h+arg_4]
    push    edx
    mov     edx, [esp+6Ch+arg_0]
    push    eax
    mov     eax, [esp+70h+var_64]
    push    ecx
    push    edx
    lea     ecx, [esp+78h+var_60]
    push    eax
    push    ecx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BEF63:                             ; CODE XREF: sub_4BEE60+50j
                                            ; sub_4BEE60+DBj
    lea     edx, [esp+68h+var_60]
    push    edx
    call    sub_4C5FA0
    mov     eax, esi
    pop     esi
    add     esp, 64h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4BEF76:                             ; CODE XREF: sub_4BEE60+Aj
    mov     eax, [esp+68h+arg_8]
    mov     ecx, [esp+68h+arg_4]
    mov     [esp+68h+arg_8], eax
    mov     [esp+68h+arg_0], eax
    mov     [esp+68h+arg_4], ecx
    mov     [esp+68h+var_64], ecx
    lea     eax, [esp+68h+arg_8]
    lea     ecx, [esp+68h+arg_4]
    push    eax
    lea     edx, [esp+6Ch+arg_0]
    push    ecx
    lea     eax, [esp+70h+var_64]
    push    edx
    push    eax
    push    esi
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BEFCE
    mov     ecx, [esp+68h+arg_C]
    mov     edx, [esp+68h+arg_8]
    mov     eax, [esp+68h+arg_4]
    push    ecx
    mov     ecx, [esp+6Ch+arg_0]
    push    edx
    mov     edx, [esp+70h+var_64]
    push    eax
    push    ecx
    push    edx
    push    esi
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BEFCE:                             ; CODE XREF: sub_4BEE60+14Aj
    mov     esi, 1

    loc_4BEFD3:                             ; CODE XREF: sub_4BEE60+1Ej
    mov     eax, esi
    pop     esi
    add     esp, 64h
    retn    10h
    sub_4BEE60 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    sub     esp, 30h
    test    eax, eax
    push    esi
    jnz     short loc_4BF027
    lea     eax, [esp+4]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      short loc_4BF046
    mov     ecx, [esp+0Ch]
    mov     edx, [esp+10h]
    imul    ecx, [esp+40h]
    mov     eax, [esp+3Ch]
    add     ecx, edx
    xor     edx, edx
    mov     dl, [ecx+eax]
    lea     ecx, [esp+4]
    push    ecx
    mov     esi, edx
    call    sub_4C5FA0
    mov     eax, esi
    pop     esi
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BF027:                             ; CODE XREF: .text:004BEFEAj
    mov     edx, [eax+8]
    mov     ecx, [eax+0Ch]
    imul    edx, [esp+40h]
    add     edx, ecx
    mov     ecx, [esp+3Ch]
    xor     eax, eax
    mov     al, [edx+ecx]
    mov     esi, eax
    pop     esi
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BF046:                             ; CODE XREF: .text:004BEFF8j
    mov     esi, [esp+40h]
    mov     eax, esi
    pop     esi
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 64h
    push    ebx
    mov     ebx, [esp+6Ch]
    push    ebp
    push    esi
    test    ebx, ebx
    push    edi
    jnz     loc_4BF1C2
    lea     eax, [esp+14h]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    mov     [esp+10h], eax
    jz      loc_4BF24E
    mov     ecx, [esp+80h]
    mov     esi, [esp+7Ch]
    lea     eax, [ecx-1]
    lea     edi, [esi+8]
    test    eax, eax
    jle     loc_4BF1AA
    mov     ebp, [esp+84h]
    mov     ebx, eax

    loc_4BF0AB:                             ; CODE XREF: .text:004BF1A4j
    mov     eax, [edi]
    mov     edx, [edi+4]
    mov     ecx, [esi+4]
    mov     [esp+80h], eax
    mov     [esp+7Ch], edx
    mov     edx, [esi]
    lea     eax, [esp+14h]
    mov     [esp+84h], ecx
    test    eax, eax
    mov     [esp+78h], edx
    jnz     short loc_4BF147
    lea     ecx, [esp+44h]
    push    ecx
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4BF19D
    lea     edx, [esp+7Ch]
    lea     eax, [esp+80h]
    push    edx
    lea     ecx, [esp+88h]
    push    eax
    lea     edx, [esp+80h]
    push    ecx
    lea     eax, [esp+50h]
    push    edx
    push    eax
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BF13B
    mov     ecx, [esp+7Ch]
    mov     edx, [esp+80h]
    mov     eax, [esp+84h]
    push    ebp
    push    ecx
    mov     ecx, [esp+80h]
    push    edx
    push    eax
    lea     edx, [esp+54h]
    push    ecx
    push    edx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BF13B:                             ; CODE XREF: .text:004BF10Ej
    lea     eax, [esp+44h]
    push    eax
    call    sub_4C5FA0
    jmp     short loc_4BF19D
    ; ---------------------------------------------------------------------------

    loc_4BF147:                             ; CODE XREF: .text:004BF0D1j
    lea     ecx, [esp+7Ch]
    lea     edx, [esp+80h]
    push    ecx
    lea     eax, [esp+88h]
    push    edx
    lea     ecx, [esp+80h]
    push    eax
    lea     edx, [esp+20h]
    push    ecx
    push    edx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BF19D
    mov     eax, [esp+7Ch]
    mov     ecx, [esp+80h]
    mov     edx, [esp+84h]
    push    ebp
    push    eax
    mov     eax, [esp+80h]
    push    ecx
    push    edx
    lea     ecx, [esp+24h]
    push    eax
    push    ecx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BF19D:                             ; CODE XREF: .text:004BF0DFj
                                            ; .text:004BF145j ...
    add     esi, 8
    add     edi, 8
    dec     ebx
    jnz     loc_4BF0AB

    loc_4BF1AA:                             ; CODE XREF: .text:004BF09Cj
    lea     edx, [esp+14h]
    push    edx
    call    sub_4C5FA0
    mov     eax, [esp+10h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4BF1C2:                             ; CODE XREF: .text:004BF06Dj
    mov     eax, [esp+80h]
    mov     esi, [esp+7Ch]
    dec     eax
    test    eax, eax
    lea     edi, [esi+8]
    jle     short loc_4BF246
    mov     ebp, eax

    loc_4BF1D7:                             ; CODE XREF: .text:004BF244j
    mov     ecx, [edi+4]
    mov     edx, [edi]
    mov     eax, [esi+4]
    mov     [esp+7Ch], ecx
    mov     ecx, [esi]
    mov     [esp+80h], edx
    mov     [esp+78h], eax
    lea     edx, [esp+7Ch]
    mov     [esp+10h], ecx
    lea     eax, [esp+80h]
    push    edx
    lea     ecx, [esp+7Ch]
    push    eax
    lea     edx, [esp+18h]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BF23D
    mov     eax, [esp+84h]
    mov     ecx, [esp+7Ch]
    mov     edx, [esp+80h]
    push    eax
    mov     eax, [esp+7Ch]
    push    ecx
    mov     ecx, [esp+18h]
    push    edx
    push    eax
    push    ecx
    push    ebx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BF23D:                             ; CODE XREF: .text:004BF213j
    add     esi, 8
    add     edi, 8
    dec     ebp
    jnz     short loc_4BF1D7

    loc_4BF246:                             ; CODE XREF: .text:004BF1D3j
    mov     dword ptr [esp+10h], 1

    loc_4BF24E:                             ; CODE XREF: .text:004BF083j
    mov     eax, [esp+10h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    10h
    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 64h
    push    ebx
    push    ebp
    mov     ebp, [esp+70h]
    push    esi
    test    ebp, ebp
    push    edi
    jnz     loc_4BF3E7
    lea     eax, [esp+14h]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    mov     [esp+10h], eax
    jz      loc_4BF4B4
    mov     eax, [esp+84h]
    mov     ebx, [esp+80h]
    mov     esi, [esp+7Ch]
    test    eax, eax
    jle     loc_4BF3CF
    mov     ebp, eax

    loc_4BF2A5:                             ; CODE XREF: .text:004BF3C9j
    mov     ecx, [ebx]
    xor     edi, edi
    dec     ecx
    test    ecx, ecx
    jle     loc_4BF3C2

    loc_4BF2B2:                             ; CODE XREF: .text:004BF3BCj
    mov     eax, [esi+8]
    mov     edx, [esi+0Ch]
    mov     ecx, [esi+4]
    mov     [esp+7Ch], eax
    mov     [esp+80h], edx
    mov     edx, [esi]
    lea     eax, [esp+14h]
    mov     [esp+84h], ecx
    test    eax, eax
    mov     [esp+78h], edx
    jnz     short loc_4BF356
    lea     ecx, [esp+44h]
    push    ecx
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4BF3B3
    lea     edx, [esp+80h]
    lea     eax, [esp+7Ch]
    push    edx
    lea     ecx, [esp+88h]
    push    eax
    lea     edx, [esp+80h]
    push    ecx
    lea     eax, [esp+50h]
    push    edx
    push    eax
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BF34A
    mov     ecx, [esp+88h]
    mov     edx, [esp+80h]
    mov     eax, [esp+7Ch]
    push    ecx
    mov     ecx, [esp+88h]
    push    edx
    mov     edx, [esp+80h]
    push    eax
    push    ecx
    lea     eax, [esp+54h]
    push    edx
    push    eax
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BF34A:                             ; CODE XREF: .text:004BF316j
    lea     ecx, [esp+44h]
    push    ecx
    call    sub_4C5FA0
    jmp     short loc_4BF3B3
    ; ---------------------------------------------------------------------------

    loc_4BF356:                             ; CODE XREF: .text:004BF2D9j
    lea     edx, [esp+80h]
    lea     eax, [esp+7Ch]
    push    edx
    lea     ecx, [esp+88h]
    push    eax
    lea     edx, [esp+80h]
    push    ecx
    lea     eax, [esp+20h]
    push    edx
    push    eax
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BF3B3
    mov     ecx, [esp+88h]
    mov     edx, [esp+80h]
    mov     eax, [esp+7Ch]
    push    ecx
    mov     ecx, [esp+88h]
    push    edx
    mov     edx, [esp+80h]
    push    eax
    push    ecx
    lea     eax, [esp+24h]
    push    edx
    push    eax
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BF3B3:                             ; CODE XREF: .text:004BF2E7j
                                            ; .text:004BF354j ...
    mov     ecx, [ebx]
    inc     edi
    add     esi, 8
    dec     ecx
    cmp     edi, ecx
    jl      loc_4BF2B2

    loc_4BF3C2:                             ; CODE XREF: .text:004BF2ACj
    add     esi, 8
    add     ebx, 4
    dec     ebp
    jnz     loc_4BF2A5

    loc_4BF3CF:                             ; CODE XREF: .text:004BF29Dj
    lea     edx, [esp+14h]
    push    edx
    call    sub_4C5FA0
    mov     eax, [esp+10h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4BF3E7:                             ; CODE XREF: .text:004BF26Dj
    mov     eax, [esp+84h]
    mov     ebx, [esp+80h]
    mov     esi, [esp+7Ch]
    test    eax, eax
    jle     loc_4BF4AC
    mov     [esp+10h], eax

    loc_4BF405:                             ; CODE XREF: .text:004BF4A6j
    mov     eax, [ebx]
    xor     edi, edi
    dec     eax
    test    eax, eax
    jle     loc_4BF497

    loc_4BF412:                             ; CODE XREF: .text:004BF491j
    mov     ecx, [esi+0Ch]
    mov     edx, [esi+8]
    mov     eax, [esi+4]
    mov     [esp+80h], ecx
    mov     ecx, [esi]
    mov     [esp+7Ch], edx
    mov     [esp+84h], eax
    lea     edx, [esp+80h]
    mov     [esp+78h], ecx
    lea     eax, [esp+7Ch]
    push    edx
    lea     ecx, [esp+88h]
    push    eax
    lea     edx, [esp+80h]
    push    ecx
    push    edx
    push    ebp
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BF488
    mov     eax, [esp+88h]
    mov     ecx, [esp+80h]
    mov     edx, [esp+7Ch]
    push    eax
    mov     eax, [esp+88h]
    push    ecx
    mov     ecx, [esp+80h]
    push    edx
    push    eax
    push    ecx
    push    ebp
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BF488:                             ; CODE XREF: .text:004BF458j
    mov     edx, [ebx]
    inc     edi
    add     esi, 8
    dec     edx
    cmp     edi, edx
    jl      loc_4BF412

    loc_4BF497:                             ; CODE XREF: .text:004BF40Cj
    mov     eax, [esp+10h]
    add     esi, 8
    add     ebx, 4
    dec     eax
    mov     [esp+10h], eax
    jnz     loc_4BF405

    loc_4BF4AC:                             ; CODE XREF: .text:004BF3FBj
    mov     dword ptr [esp+10h], 1

    loc_4BF4B4:                             ; CODE XREF: .text:004BF283j
    mov     eax, [esp+10h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BF4D0 proc near                    ; CODE XREF: .text:0041DF70p
                                            ; .text:0041FAE2p ...

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_24= dword ptr -24h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 40h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     ebx, [esp+50h+arg_0]
    mov     ebp, eax
    test    ebx, ebx
    jnz     short loc_4BF4FE
    lea     eax, [esp+50h+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jnz     short loc_4BF50B
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BF4FE:                             ; CODE XREF: sub_4BF4D0+14j
    mov     ecx, 0Ch
    mov     esi, ebx
    lea     edi, [esp+50h+var_30]
    rep movsd

    loc_4BF50B:                             ; CODE XREF: sub_4BF4D0+22j
    mov     esi, [esp+50h+arg_4]
    xor     edi, edi
    cmp     esi, edi
    jnz     short loc_4BF535
    mov     [esp+50h+var_3C], edi
    mov     [esp+50h+var_40], edi
    mov     ecx, [ebp+0D4h]
    lea     esi, [esp+50h+var_40]
    mov     [esp+50h+var_38], ecx
    mov     edx, [ebp+0D8h]
    mov     [esp+50h+var_34], edx

    loc_4BF535:                             ; CODE XREF: sub_4BF4D0+43j
    lea     eax, [esp+50h+var_30]
    push    esi
    push    eax
    call    sub_4BF620
    neg     eax
    sbb     eax, eax
    neg     eax
    mov     [esp+50h+arg_4], eax
    jz      loc_4BF5FF
    mov     eax, [esi+4]
    mov     ecx, [esp+50h+var_30]
    mov     edx, [esi+0Ch]
    imul    ecx, eax
    sub     edx, eax
    mov     eax, [esp+50h+var_24]
    add     ecx, eax
    mov     eax, [esi]
    add     ecx, eax
    mov     eax, [esp+50h+arg_8]
    inc     edx
    cmp     eax, edi
    jge     short loc_4BF595
    cmp     eax, 0FFFFFFE0h
    jge     short loc_4BF57C
    mov     eax, 0FFFFFFE0h

    loc_4BF57C:                             ; CODE XREF: sub_4BF4D0+A5j
    mov     edi, [ebp+0C4h]
    add     eax, 20h
    test    edi, edi
    jnz     short loc_4BF5B5
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BF595:                             ; CODE XREF: sub_4BF4D0+A0j
    cmp     eax, 1Fh
    jle     short loc_4BF59F
    mov     eax, 1Fh

    loc_4BF59F:                             ; CODE XREF: sub_4BF4D0+C8j
    mov     edi, [ebp+0C8h]
    test    edi, edi
    jnz     short loc_4BF5B5
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BF5B5:                             ; CODE XREF: sub_4BF4D0+B7j
                                            ; sub_4BF4D0+D7j
    shl     eax, 8
    add     eax, edi
    mov     ebp, eax
    test    ebp, ebp
    jnz     short loc_4BF5CA
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BF5CA:                             ; CODE XREF: sub_4BF4D0+EEj
    mov     eax, edx
    dec     edx
    test    eax, eax
    jz      short loc_4BF5FF
    inc     edx

    loc_4BF5D2:                             ; CODE XREF: sub_4BF4D0+129j
    mov     eax, [esi+8]
    mov     ebx, [esi]
    mov     edi, [esp+50h+var_30]
    sub     eax, ebx
    inc     eax
    add     edi, ecx
    mov     ebx, eax
    dec     eax
    test    ebx, ebx
    jz      short loc_4BF5F6
    inc     eax

    loc_4BF5E8:                             ; CODE XREF: sub_4BF4D0+124j
    movsx   ebx, byte ptr [ecx]
    inc     ecx
    dec     eax
    mov     bl, [ebp+ebx+0]
    mov     [ecx-1], bl
    jnz     short loc_4BF5E8

    loc_4BF5F6:                             ; CODE XREF: sub_4BF4D0+115j
    dec     edx
    mov     ecx, edi
    jnz     short loc_4BF5D2
    mov     ebx, [esp+50h+arg_0]

    loc_4BF5FF:                             ; CODE XREF: sub_4BF4D0+7Aj
                                            ; sub_4BF4D0+FFj
    test    ebx, ebx
    jnz     short loc_4BF60D
    lea     ecx, [esp+50h+var_30]
    push    ecx
    call    sub_4C5FA0

    loc_4BF60D:                             ; CODE XREF: sub_4BF4D0+131j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 40h
    retn    0Ch
    sub_4BF4D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BF620 proc near                    ; CODE XREF: sub_4BF4D0+6Bp
                                            ; sub_4BF6F0+46p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_0]
    sub     esp, 10h
    lea     eax, [esp+10h+var_10]
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    eax
    call    sub_4C6AE0
    mov     edi, [esp+20h+var_10]
    mov     eax, [esp+20h+arg_4]
    mov     ecx, [eax+8]
    cmp     ecx, edi
    jge     short loc_4BF650
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BF650:                             ; CODE XREF: sub_4BF620+22j
    mov     edx, [eax]
    mov     ecx, [esp+20h+var_8]
    cmp     edx, ecx
    jle     short loc_4BF666
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BF666:                             ; CODE XREF: sub_4BF620+38j
    mov     ebp, [eax+0Ch]
    mov     esi, [esp+20h+var_C]
    cmp     ebp, esi
    jge     short loc_4BF67D
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BF67D:                             ; CODE XREF: sub_4BF620+4Fj
    mov     ecx, [eax+4]
    mov     ebx, [esp+20h+var_4]
    cmp     ecx, ebx
    jle     short loc_4BF694
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BF694:                             ; CODE XREF: sub_4BF620+66j
    cmp     edx, edi
    jge     short loc_4BF69A
    mov     [eax], edi

    loc_4BF69A:                             ; CODE XREF: sub_4BF620+76j
    cmp     ecx, esi
    jge     short loc_4BF6A1
    mov     [eax+4], esi

    loc_4BF6A1:                             ; CODE XREF: sub_4BF620+7Cj
    mov     ecx, [eax+8]
    mov     edx, [esp+20h+var_8]
    cmp     ecx, edx
    jle     short loc_4BF6AF
    mov     [eax+8], edx

    loc_4BF6AF:                             ; CODE XREF: sub_4BF620+8Aj
    cmp     ebp, ebx
    jle     short loc_4BF6B6
    mov     [eax+0Ch], ebx

    loc_4BF6B6:                             ; CODE XREF: sub_4BF620+91j
    mov     ecx, [eax]
    mov     edx, [eax+8]
    cmp     ecx, edx
    jle     short loc_4BF6CB
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BF6CB:                             ; CODE XREF: sub_4BF620+9Dj
    mov     edx, [eax+4]
    mov     esi, [eax+0Ch]
    xor     ecx, ecx
    cmp     edx, esi
    pop     edi
    pop     esi
    setle   cl
    pop     ebp
    mov     eax, ecx
    pop     ebx
    add     esp, 10h
    retn    8
    sub_4BF620 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BF6F0 proc near                    ; CODE XREF: sub_418310+823p
                                            ; .text:00467BCAp ...

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 40h
    mov     eax, [esp+40h+arg_4]
    push    esi
    push    edi
    mov     edi, [esp+48h+arg_0]
    mov     ecx, [eax]
    mov     [esp+48h+var_40], ecx
    mov     edx, [eax+4]
    mov     [esp+48h+var_3C], edx
    mov     ecx, [eax+8]
    test    edi, edi
    mov     edx, [eax+0Ch]
    mov     [esp+48h+var_38], ecx
    mov     [esp+48h+var_34], edx
    jnz     short loc_4BF770
    lea     eax, [esp+48h+var_30]
    push    eax
    call    sub_4C5E70
    mov     esi, eax
    test    esi, esi
    jz      short loc_4BF798
    lea     ecx, [esp+48h+var_40]
    lea     edx, [esp+48h+var_30]
    push    ecx
    push    edx
    call    sub_4BF620
    mov     esi, eax
    neg     esi
    sbb     esi, esi
    neg     esi
    jz      short loc_4BF75C
    mov     eax, [esp+48h+arg_8]
    lea     ecx, [esp+48h+var_40]
    push    eax
    lea     edx, [esp+4Ch+var_30]
    push    ecx
    push    edx
    call    sub_4CCDEA
    add     esp, 0Ch

    loc_4BF75C:                             ; CODE XREF: sub_4BF6F0+53j
    lea     eax, [esp+48h+var_30]
    push    eax
    call    sub_4C5FA0
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 40h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BF770:                             ; CODE XREF: sub_4BF6F0+2Aj
    lea     ecx, [esp+48h+var_40]
    push    ecx
    push    edi
    call    sub_4BF620
    mov     esi, eax
    neg     esi
    sbb     esi, esi
    neg     esi
    jz      short loc_4BF798
    mov     edx, [esp+48h+arg_8]
    lea     eax, [esp+48h+var_40]
    push    edx
    push    eax
    push    edi
    call    sub_4CCDEA
    add     esp, 0Ch

    loc_4BF798:                             ; CODE XREF: sub_4BF6F0+3Aj
                                            ; sub_4BF6F0+93j
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 40h
    retn    0Ch
    sub_4BF6F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BF7B0 proc near                    ; CODE XREF: sub_4A16F0+FFp

    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 30h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+40h+arg_0]
    xor     ebp, ebp
    test    edi, edi
    jnz     loc_4BF854
    lea     eax, [esp+40h+var_30]
    push    eax
    call    sub_4C5E70
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_4BF8A9
    mov     esi, [esp+40h+arg_4]
    mov     edi, [esp+40h+arg_8]
    push    edi
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    eax
    push    ecx
    push    eax
    lea     eax, [esp+50h+var_30]
    push    edx
    push    eax
    call    sub_4BEC70
    mov     ecx, [esi+0Ch]
    mov     eax, [esi+8]
    mov     edx, [esi+4]
    push    edi
    push    ecx
    push    eax
    push    edx
    push    eax
    lea     eax, [esp+54h+var_30]
    push    eax
    call    sub_4BEC70
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    edi
    push    eax
    push    ecx
    push    eax
    lea     eax, [esp+50h+var_30]
    push    edx
    push    eax
    call    sub_4BEC70
    mov     ecx, [esi+0Ch]
    mov     eax, [esi]
    mov     edx, [esi+4]
    push    edi
    push    ecx
    push    eax
    push    edx
    push    eax
    lea     eax, [esp+54h+var_30]
    push    eax
    call    sub_4BEC70
    lea     ecx, [esp+40h+var_30]
    push    ecx
    call    sub_4C5FA0
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BF854:                             ; CODE XREF: sub_4BF7B0+Fj
    mov     esi, [esp+40h+arg_4]
    mov     ebx, [esp+40h+arg_8]
    push    ebx
    mov     eax, [esi+4]
    mov     edx, [esi+8]
    push    eax
    push    edx
    push    eax
    mov     eax, [esi]
    push    eax
    push    edi
    call    sub_4BEC70
    mov     ecx, [esi+0Ch]
    mov     eax, [esi+8]
    mov     edx, [esi+4]
    push    ebx
    push    ecx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BEC70
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    push    eax
    push    edx
    push    edi
    call    sub_4BEC70
    mov     ecx, [esi+0Ch]
    mov     eax, [esi]
    mov     edx, [esi+4]
    push    ebx
    push    ecx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BEC70

    loc_4BF8A9:                             ; CODE XREF: sub_4BF7B0+23j
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    sub_4BF7B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BF8C0 proc near                    ; CODE XREF: sub_466B00+5Ep
                                            ; sub_467E50+11Cp ...

    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 68h
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+74h+arg_0]
    test    edi, edi
    jnz     loc_4BFC5F
    lea     eax, [esp+74h+var_60]
    push    eax
    call    sub_4C5E70
    mov     ebx, eax
    test    ebx, ebx
    jz      loc_4BFD49
    mov     esi, [esp+74h+arg_4]
    mov     edi, [esp+74h+arg_8]
    mov     eax, [esi+4]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    mov     [esp+74h+arg_4], eax
    mov     [esp+74h+var_68], eax
    lea     eax, [esp+74h+var_60]
    test    eax, eax
    mov     [esp+74h+arg_0], ecx
    mov     [esp+74h+var_64], edx
    jnz     short loc_4BF973
    lea     ecx, [esp+74h+var_30]
    push    ecx
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4BF9B7
    lea     edx, [esp+74h+arg_4]
    lea     eax, [esp+74h+arg_0]
    push    edx
    lea     ecx, [esp+78h+var_68]
    push    eax
    lea     edx, [esp+7Ch+var_64]
    push    ecx
    lea     eax, [esp+80h+var_30]
    push    edx
    push    eax
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BF967
    mov     ecx, [esp+74h+arg_4]
    mov     edx, [esp+74h+arg_0]
    mov     eax, [esp+74h+var_68]
    push    edi
    push    ecx
    mov     ecx, [esp+7Ch+var_64]
    push    edx
    push    eax
    lea     edx, [esp+84h+var_30]
    push    ecx
    push    edx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BF967:                             ; CODE XREF: sub_4BF8C0+83j
    lea     eax, [esp+74h+var_30]
    push    eax
    call    sub_4C5FA0
    jmp     short loc_4BF9B7
    ; ---------------------------------------------------------------------------

    loc_4BF973:                             ; CODE XREF: sub_4BF8C0+4Fj
    lea     ecx, [esp+74h+arg_4]
    lea     edx, [esp+74h+arg_0]
    push    ecx
    lea     eax, [esp+78h+var_68]
    push    edx
    lea     ecx, [esp+7Ch+var_64]
    push    eax
    lea     edx, [esp+80h+var_60]
    push    ecx
    push    edx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BF9B7
    mov     eax, [esp+74h+arg_4]
    mov     ecx, [esp+74h+arg_0]
    mov     edx, [esp+74h+var_68]
    push    edi
    push    eax
    mov     eax, [esp+7Ch+var_64]
    push    ecx
    push    edx
    lea     ecx, [esp+84h+var_60]
    push    eax
    push    ecx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BF9B7:                             ; CODE XREF: sub_4BF8C0+5Dj
                                            ; sub_4BF8C0+B1j ...
    mov     edx, [esi+0Ch]
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    mov     [esp+74h+arg_4], edx
    lea     edx, [esp+74h+var_60]
    mov     [esp+74h+arg_8], eax
    test    edx, edx
    mov     [esp+74h+arg_0], ecx
    mov     [esp+74h+var_64], eax
    jnz     short loc_4BFA43
    lea     eax, [esp+74h+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4BFA8D
    lea     ecx, [esp+74h+arg_4]
    lea     edx, [esp+74h+arg_8]
    push    ecx
    lea     eax, [esp+78h+arg_0]
    push    edx
    lea     ecx, [esp+7Ch+var_64]
    push    eax
    lea     edx, [esp+80h+var_30]
    push    ecx
    push    edx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BFA37
    mov     eax, [esp+74h+arg_4]
    mov     ecx, [esp+74h+arg_8]
    mov     edx, [esp+74h+arg_0]
    push    edi
    push    eax
    mov     eax, [esp+7Ch+var_64]
    push    ecx
    push    edx
    lea     ecx, [esp+84h+var_30]
    push    eax
    push    ecx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BFA37:                             ; CODE XREF: sub_4BF8C0+150j
    lea     edx, [esp+74h+var_30]
    push    edx
    call    sub_4C5FA0
    jmp     short loc_4BFA8D
    ; ---------------------------------------------------------------------------

    loc_4BFA43:                             ; CODE XREF: sub_4BF8C0+119j
    lea     eax, [esp+74h+arg_4]
    lea     ecx, [esp+74h+arg_8]
    push    eax
    lea     edx, [esp+78h+arg_0]
    push    ecx
    lea     eax, [esp+7Ch+var_64]
    push    edx
    lea     ecx, [esp+80h+var_60]
    push    eax
    push    ecx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BFA8D
    mov     edx, [esp+74h+arg_4]
    mov     eax, [esp+74h+arg_8]
    mov     ecx, [esp+74h+arg_0]
    push    edi
    push    edx
    mov     edx, [esp+7Ch+var_64]
    push    eax
    push    ecx
    lea     eax, [esp+84h+var_60]
    push    edx
    push    eax
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BFA8D:                             ; CODE XREF: sub_4BF8C0+127j
                                            ; sub_4BF8C0+181j ...
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    mov     [esp+74h+arg_4], eax
    mov     [esp+74h+arg_0], eax
    lea     eax, [esp+74h+var_60]
    test    eax, eax
    mov     [esp+74h+arg_8], ecx
    mov     [esp+74h+var_64], edx
    jnz     short loc_4BFB18
    lea     ecx, [esp+74h+var_30]
    push    ecx
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4BFB62
    lea     edx, [esp+74h+arg_4]
    lea     eax, [esp+74h+arg_8]
    push    edx
    lea     ecx, [esp+78h+arg_0]
    push    eax
    lea     edx, [esp+7Ch+var_64]
    push    ecx
    lea     eax, [esp+80h+var_30]
    push    edx
    push    eax
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BFB0C
    mov     ecx, [esp+74h+arg_4]
    mov     edx, [esp+74h+arg_8]
    mov     eax, [esp+74h+arg_0]
    push    edi
    push    ecx
    mov     ecx, [esp+7Ch+var_64]
    push    edx
    push    eax
    lea     edx, [esp+84h+var_30]
    push    ecx
    push    edx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BFB0C:                             ; CODE XREF: sub_4BF8C0+225j
    lea     eax, [esp+74h+var_30]
    push    eax
    call    sub_4C5FA0
    jmp     short loc_4BFB62
    ; ---------------------------------------------------------------------------

    loc_4BFB18:                             ; CODE XREF: sub_4BF8C0+1EEj
    lea     ecx, [esp+74h+arg_4]
    lea     edx, [esp+74h+arg_8]
    push    ecx
    lea     eax, [esp+78h+arg_0]
    push    edx
    lea     ecx, [esp+7Ch+var_64]
    push    eax
    lea     edx, [esp+80h+var_60]
    push    ecx
    push    edx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BFB62
    mov     eax, [esp+74h+arg_4]
    mov     ecx, [esp+74h+arg_8]
    mov     edx, [esp+74h+arg_0]
    push    edi
    push    eax
    mov     eax, [esp+7Ch+var_64]
    push    ecx
    push    edx
    lea     ecx, [esp+84h+var_60]
    push    eax
    push    ecx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BFB62:                             ; CODE XREF: sub_4BF8C0+1FCj
                                            ; sub_4BF8C0+256j ...
    mov     edx, [esi+0Ch]
    mov     eax, [esi]
    mov     ecx, [esi+4]
    mov     [esp+74h+arg_4], edx
    lea     edx, [esp+74h+var_60]
    mov     [esp+74h+arg_8], eax
    test    edx, edx
    mov     [esp+74h+arg_0], ecx
    mov     [esp+74h+var_64], eax
    jnz     short loc_4BFC00
    lea     eax, [esp+74h+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4BFC4A
    lea     ecx, [esp+74h+arg_4]
    lea     edx, [esp+74h+arg_8]
    push    ecx
    lea     eax, [esp+78h+arg_0]
    push    edx
    lea     ecx, [esp+7Ch+var_64]
    push    eax
    lea     edx, [esp+80h+var_30]
    push    ecx
    push    edx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BFBE1
    mov     eax, [esp+74h+arg_4]
    mov     ecx, [esp+74h+arg_8]
    mov     edx, [esp+74h+arg_0]
    push    edi
    push    eax
    mov     eax, [esp+7Ch+var_64]
    push    ecx
    push    edx
    lea     ecx, [esp+84h+var_30]
    push    eax
    push    ecx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BFBE1:                             ; CODE XREF: sub_4BF8C0+2FAj
    lea     edx, [esp+74h+var_30]
    push    edx
    call    sub_4C5FA0
    lea     ecx, [esp+74h+var_60]
    push    ecx
    call    sub_4C5FA0
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BFC00:                             ; CODE XREF: sub_4BF8C0+2C3j
    lea     eax, [esp+74h+arg_4]
    lea     ecx, [esp+74h+arg_8]
    push    eax
    lea     edx, [esp+78h+arg_0]
    push    ecx
    lea     eax, [esp+7Ch+var_64]
    push    edx
    lea     ecx, [esp+80h+var_60]
    push    eax
    push    ecx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BFC4A
    mov     edx, [esp+74h+arg_4]
    mov     eax, [esp+74h+arg_8]
    mov     ecx, [esp+74h+arg_0]
    push    edi
    push    edx
    mov     edx, [esp+7Ch+var_64]
    push    eax
    push    ecx
    lea     eax, [esp+84h+var_60]
    push    edx
    push    eax
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BFC4A:                             ; CODE XREF: sub_4BF8C0+2D1j
                                            ; sub_4BF8C0+363j
    lea     ecx, [esp+74h+var_60]
    push    ecx
    call    sub_4C5FA0
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 68h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BFC5F:                             ; CODE XREF: sub_4BF8C0+Cj
    mov     esi, [esp+74h+arg_4]
    lea     ecx, [esp+74h+arg_4]
    push    ecx
    lea     ecx, [esp+78h+var_68]
    mov     eax, [esi+4]
    mov     edx, [esi+8]
    mov     [esp+78h+arg_4], eax
    mov     [esp+78h+var_64], eax
    mov     eax, [esi]
    mov     [esp+78h+arg_0], edx
    mov     [esp+78h+var_68], eax
    lea     edx, [esp+78h+arg_0]
    lea     eax, [esp+78h+var_64]
    push    edx
    push    eax
    push    ecx
    push    edi
    call    sub_4BEA20
    test    eax, eax
    mov     ebx, [esp+74h+arg_8]
    jz      short loc_4BFCC1
    mov     edx, [esp+74h+arg_4]
    mov     eax, [esp+74h+arg_0]
    mov     ecx, [esp+74h+var_64]
    push    ebx
    push    edx
    mov     edx, [esp+7Ch+var_68]
    push    eax
    push    ecx
    push    edx
    push    edi
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BFCC1:                             ; CODE XREF: sub_4BF8C0+3E1j
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+4]
    mov     [esp+74h+arg_4], eax
    mov     eax, [esi+8]
    mov     [esp+74h+arg_8], eax
    mov     [esp+74h+var_64], eax
    lea     edx, [esp+74h+arg_4]
    mov     [esp+74h+arg_0], ecx
    lea     eax, [esp+74h+arg_8]
    push    edx
    lea     ecx, [esp+78h+arg_0]
    push    eax
    lea     edx, [esp+7Ch+var_64]
    push    ecx
    push    edx
    push    edi
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4BFD1F
    mov     eax, [esp+74h+arg_4]
    mov     ecx, [esp+74h+arg_8]
    mov     edx, [esp+74h+arg_0]
    push    ebx
    push    eax
    mov     eax, [esp+7Ch+var_64]
    push    ecx
    push    edx
    push    eax
    push    edi
    call    sub_4CC7AB
    add     esp, 18h

    loc_4BFD1F:                             ; CODE XREF: sub_4BF8C0+43Cj
    mov     eax, [esi+0Ch]
    mov     ecx, [esi+8]
    mov     edx, [esi]
    push    ebx
    push    eax
    push    ecx
    push    eax
    push    edx
    push    edi
    call    sub_4BE950
    mov     ecx, [esi+0Ch]
    mov     eax, [esi]
    mov     edx, [esi+4]
    push    ebx
    push    ecx
    push    eax
    push    edx
    push    eax
    push    edi
    call    sub_4BE950
    mov     ebx, [esp+74h+arg_4]

    loc_4BFD49:                             ; CODE XREF: sub_4BF8C0+20j
    pop     edi
    mov     eax, ebx
    pop     esi
    pop     ebx
    add     esp, 68h
    retn    0Ch
    sub_4BF8C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 40h
    mov     eax, [esp+48h]
    push    esi
    mov     esi, [esp+48h]
    mov     ecx, [eax]
    mov     [esp+4], ecx
    mov     edx, [eax+4]
    mov     [esp+8], edx
    mov     ecx, [eax+8]
    test    esi, esi
    mov     edx, [eax+0Ch]
    mov     [esp+0Ch], ecx
    mov     [esp+10h], edx
    jnz     short loc_4BFDD8
    lea     eax, [esp+14h]
    push    eax
    call    sub_4C5E70
    mov     esi, eax
    test    esi, esi
    jz      short loc_4BFDFE
    lea     ecx, [esp+4]
    lea     edx, [esp+14h]
    push    ecx
    push    edx
    call    sub_4BF620
    test    eax, eax
    jz      short loc_4BFDC5
    mov     eax, [esp+50h]
    lea     ecx, [esp+4]
    push    eax
    lea     edx, [esp+18h]
    push    ecx
    push    edx
    call    sub_4CCE87
    add     esp, 0Ch

    loc_4BFDC5:                             ; CODE XREF: .text:004BFDACj
    lea     eax, [esp+14h]
    push    eax
    call    sub_4C5FA0
    mov     eax, esi
    pop     esi
    add     esp, 40h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4BFDD8:                             ; CODE XREF: .text:004BFD89j
    lea     ecx, [esp+4]
    push    ecx
    push    esi
    call    sub_4BF620
    test    eax, eax
    jz      short loc_4BFDFA
    mov     edx, [esp+50h]
    lea     eax, [esp+4]
    push    edx
    push    eax
    push    esi
    call    sub_4CCE87
    add     esp, 0Ch

    loc_4BFDFA:                             ; CODE XREF: .text:004BFDE5j
    mov     esi, [esp+50h]

    loc_4BFDFE:                             ; CODE XREF: .text:004BFD99j
    mov     eax, esi
    pop     esi
    add     esp, 40h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BFE10 proc near                    ; CODE XREF: sub_4848E0+1EDp
                                            ; .text:004A1B1Fp ...

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 40h
    mov     eax, [esp+40h+arg_4]
    push    edi
    mov     ecx, [eax]
    mov     [esp+44h+var_40], ecx
    mov     edx, [eax+4]
    mov     [esp+44h+var_3C], edx
    mov     ecx, [eax+8]
    mov     [esp+44h+var_38], ecx
    mov     edx, [eax+0Ch]
    mov     [esp+44h+var_34], edx
    call    sub_4B6220
    mov     edi, eax
    test    byte ptr [edi+0F1h], 1
    jnz     short loc_4BFE4C
    xor     eax, eax
    pop     edi
    add     esp, 40h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BFE4C:                             ; CODE XREF: sub_4BFE10+31j
    push    esi
    mov     esi, [esp+48h+arg_0]
    test    esi, esi
    jnz     short loc_4BFEC8
    lea     eax, [esp+48h+var_30]
    push    eax
    call    sub_4C5E70
    mov     esi, eax
    test    esi, esi
    jz      loc_4BFF11
    lea     ecx, [esp+48h+var_40]
    lea     edx, [esp+48h+var_30]
    push    ecx
    push    edx
    call    sub_4BF620
    test    eax, eax
    jz      short loc_4BFEB4
    mov     eax, [edi+0CCh]
    mov     ecx, [esp+48h+var_34]
    push    eax
    mov     eax, [esp+4Ch+var_3C]
    mov     edx, [esp+4Ch+var_38]
    sub     ecx, eax
    inc     ecx
    push    ecx
    mov     ecx, [esp+50h+var_40]
    sub     edx, ecx
    inc     edx
    push    edx
    mov     edx, [esp+54h+var_28]
    imul    eax, edx
    push    edx
    mov     edx, [esp+58h+var_24]
    add     eax, ecx
    add     eax, edx
    push    eax
    call    sub_4CCED5
    add     esp, 14h

    loc_4BFEB4:                             ; CODE XREF: sub_4BFE10+6Aj
    lea     eax, [esp+48h+var_30]
    push    eax
    call    sub_4C5FA0
    mov     eax, esi
    pop     esi
    pop     edi
    add     esp, 40h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4BFEC8:                             ; CODE XREF: sub_4BFE10+43j
    lea     ecx, [esp+48h+var_40]
    push    ecx
    push    esi
    call    sub_4BF620
    test    eax, eax
    jz      short loc_4BFF0D
    mov     edx, [edi+0CCh]
    mov     eax, [esp+48h+var_3C]
    mov     ecx, [esi+8]
    push    edx
    mov     edx, [esp+4Ch+var_34]
    mov     edi, [esp+4Ch+var_38]
    sub     edx, eax
    imul    eax, ecx
    inc     edx
    push    edx
    mov     edx, [esp+50h+var_40]
    sub     edi, edx
    inc     edi
    push    edi
    mov     edi, [esi+0Ch]
    add     eax, edi
    push    ecx
    add     eax, edx
    push    eax
    call    sub_4CCED5
    add     esp, 14h

    loc_4BFF0D:                             ; CODE XREF: sub_4BFE10+C5j
    mov     esi, [esp+48h+arg_4]

    loc_4BFF11:                             ; CODE XREF: sub_4BFE10+53j
    mov     eax, esi
    pop     esi
    pop     edi
    add     esp, 40h
    retn    8
    sub_4BFE10 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4BFF20 proc near                    ; CODE XREF: sub_4848E0+1DCp

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 40h
    push    ebx
    mov     ebx, [esp+44h+arg_0]
    push    ebp
    push    esi
    test    ebx, ebx
    push    edi
    jnz     short loc_4BFF49
    lea     eax, [esp+50h+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4C0060
    lea     ebx, [esp+50h+var_30]
    mov     [esp+50h+arg_0], ebx

    loc_4BFF49:                             ; CODE XREF: sub_4BFF20+Dj
    mov     ecx, [esp+50h+arg_4]
    mov     edx, [ecx]
    mov     [esp+50h+var_40], edx
    mov     eax, [ecx+4]
    mov     [esp+50h+var_3C], eax
    mov     edx, [ecx+8]
    mov     [esp+50h+var_38], edx
    mov     eax, [ecx+0Ch]
    lea     ecx, [esp+50h+var_40]
    push    ecx
    push    ebx
    mov     [esp+58h+var_34], eax
    call    sub_4BF620
    test    eax, eax
    jz      loc_4C003F
    mov     edx, [esp+50h+var_40]
    mov     eax, [esp+50h+var_38]
    mov     ecx, [esp+50h+var_34]
    lea     esi, [edx+3]
    lea     ebp, [eax+3]
    mov     eax, [esp+50h+var_3C]
    and     esi, 0FFFFFFFCh
    and     ebp, 0FFFFFFFCh
    cmp     eax, ecx
    mov     edi, eax
    jg      loc_4C003F

    loc_4BFFA1:                             ; CODE XREF: sub_4BFF20+119j
    mov     eax, edi
    mov     ecx, [esp+50h+var_40]
    imul    eax, [ebx+8]
    mov     edx, [ebx+0Ch]
    mov     ebx, [esp+50h+arg_8]
    add     ecx, edi
    add     eax, esi
    add     ecx, ebx
    add     eax, edx
    and     ecx, 1
    add     ecx, eax
    lea     edx, [eax+ebp]
    add     ecx, [esp+50h+var_40]
    sub     edx, esi
    sub     ecx, esi
    cmp     ecx, eax
    jnb     short loc_4BFFD8

    loc_4BFFCE:                             ; CODE XREF: sub_4BFF20+B6j
    mov     byte ptr [ecx], 0
    add     ecx, 2
    cmp     ecx, eax
    jb      short loc_4BFFCE

    loc_4BFFD8:                             ; CODE XREF: sub_4BFF20+ACj
    lea     ecx, [edi+ebx]
    test    cl, 1
    jz      short loc_4C0002
    cmp     eax, edx
    jnb     short loc_4BFFF6

    loc_4BFFE4:                             ; CODE XREF: sub_4BFF20+D4j
    mov     ecx, [eax]
    add     eax, 4
    and     ecx, 0FF00FFh
    cmp     eax, edx
    mov     [eax-4], ecx
    jb      short loc_4BFFE4

    loc_4BFFF6:                             ; CODE XREF: sub_4BFF20+C2j
    mov     edx, [esp+50h+var_38]
    lea     ecx, [eax+edx]
    sub     ecx, ebp
    inc     eax
    jmp     short loc_4C0020
    ; ---------------------------------------------------------------------------

    loc_4C0002:                             ; CODE XREF: sub_4BFF20+BEj
    cmp     eax, edx
    jnb     short loc_4C0018

    loc_4C0006:                             ; CODE XREF: sub_4BFF20+F6j
    mov     ecx, [eax]
    add     eax, 4
    and     ecx, 0FF00FF00h
    cmp     eax, edx
    mov     [eax-4], ecx
    jb      short loc_4C0006

    loc_4C0018:                             ; CODE XREF: sub_4BFF20+E4j
    mov     ecx, [esp+50h+var_38]
    add     ecx, eax
    sub     ecx, ebp

    loc_4C0020:                             ; CODE XREF: sub_4BFF20+E0j
    cmp     eax, ecx
    ja      short loc_4C002E

    loc_4C0024:                             ; CODE XREF: sub_4BFF20+10Cj
    mov     byte ptr [eax], 0
    add     eax, 2
    cmp     eax, ecx
    jbe     short loc_4C0024

    loc_4C002E:                             ; CODE XREF: sub_4BFF20+102j
    mov     eax, [esp+50h+var_34]
    mov     ebx, [esp+50h+arg_0]
    inc     edi
    cmp     edi, eax
    jle     loc_4BFFA1

    loc_4C003F:                             ; CODE XREF: sub_4BFF20+55j
                                            ; sub_4BFF20+7Bj
    lea     edx, [esp+50h+var_30]
    cmp     ebx, edx
    jnz     short loc_4C0051
    lea     eax, [esp+50h+var_30]
    push    eax
    call    sub_4C5FA0

    loc_4C0051:                             ; CODE XREF: sub_4BFF20+125j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C0060:                             ; CODE XREF: sub_4BFF20+1Bj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 40h
    retn    0Ch
    sub_4BFF20 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C0070 proc near                    ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+1E8p
                                            ; GameUnit_LOS_Minimap_UnitsProjectiles+22Bp ...

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 40h
    mov     eax, [esp+40h+arg_4]
    mov     ecx, [esp+40h+arg_8]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+50h+arg_C]
    mov     [esp+50h+var_34], ecx
    mov     ebx, 800h
    lea     ebp, [edi+eax]
    jmp     short loc_4C0095
    ; ---------------------------------------------------------------------------

    loc_4C0091:                             ; CODE XREF: sub_4C0070+11Dj
    mov     edi, [esp+50h+arg_C]

    loc_4C0095:                             ; CODE XREF: sub_4C0070+1Fj
    push    edi
    push    ebx
    call    sub_4B7123
    mov     ecx, [esp+58h+arg_4]
    add     esp, 8
    mov     esi, eax
    push    edi
    push    ebx
    add     esi, ecx
    call    sub_4B70EF
    mov     edx, [esp+58h+var_34]
    mov     ecx, [esp+58h+arg_8]
    mov     edi, eax
    mov     [esp+58h+var_34], ebp
    mov     ebp, [esp+58h+arg_0]
    add     esp, 8
    add     edi, ecx
    mov     [esp+50h+var_3C], esi
    test    ebp, ebp
    mov     [esp+50h+var_40], edi
    mov     [esp+50h+var_38], edx
    jnz     short loc_4C013B
    lea     eax, [esp+50h+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4C017B
    lea     ecx, [esp+50h+var_40]
    lea     edx, [esp+50h+var_3C]
    push    ecx
    lea     eax, [esp+54h+var_38]
    push    edx
    lea     ecx, [esp+58h+var_34]
    push    eax
    lea     edx, [esp+5Ch+var_30]
    push    ecx
    push    edx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4C012F
    mov     eax, [esp+50h+arg_10]
    mov     ecx, [esp+50h+var_40]
    mov     edx, [esp+50h+var_3C]
    push    eax
    mov     eax, [esp+54h+var_38]
    push    ecx
    mov     ecx, [esp+58h+var_34]
    push    edx
    push    eax
    lea     edx, [esp+60h+var_30]
    push    ecx
    push    edx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4C012F:                             ; CODE XREF: sub_4C0070+97j
    lea     eax, [esp+50h+var_30]
    push    eax
    call    sub_4C5FA0
    jmp     short loc_4C017B
    ; ---------------------------------------------------------------------------

    loc_4C013B:                             ; CODE XREF: sub_4C0070+63j
    lea     ecx, [esp+50h+var_40]
    lea     edx, [esp+50h+var_3C]
    push    ecx
    lea     eax, [esp+54h+var_38]
    push    edx
    lea     ecx, [esp+58h+var_34]
    push    eax
    push    ecx
    push    ebp
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4C017B
    mov     edx, [esp+50h+arg_10]
    mov     eax, [esp+50h+var_40]
    mov     ecx, [esp+50h+var_3C]
    push    edx
    mov     edx, [esp+54h+var_38]
    push    eax
    mov     eax, [esp+58h+var_34]
    push    ecx
    push    edx
    push    eax
    push    ebp
    call    sub_4CC7AB
    add     esp, 18h

    loc_4C017B:                             ; CODE XREF: sub_4C0070+71j
                                            ; sub_4C0070+C9j ...
    add     ebx, 800h
    mov     ebp, esi
    cmp     ebx, 10000h
    mov     [esp+50h+var_34], edi
    jle     loc_4C0091
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    14h
    sub_4C0070 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C01A0 proc near                    ; CODE XREF: GameUnit_LOS_Minimap_UnitsProjectiles+33Dp

    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    sub     esp, 40h
    mov     eax, [esp+40h+arg_4]
    push    ebx
    push    ebp
    push    edi
    mov     edi, [esp+4Ch+arg_C]
    mov     ecx, [esp+4Ch+arg_8]
    mov     [esp+4Ch+var_3C], ecx
    lea     ebx, [edi+eax]
    mov     eax, 10000h
    cdq
    idiv    [esp+4Ch+arg_14]
    mov     ebp, eax
    mov     [esp+4Ch+var_34], eax
    cmp     ebp, 10000h
    jg      loc_4C02F8
    mov     edx, [esp+4Ch+arg_18]
    push    esi
    mov     [esp+50h+var_38], edx
    jmp     short loc_4C01E4
    ; ---------------------------------------------------------------------------

    loc_4C01E0:                             ; CODE XREF: sub_4C01A0+151j
    mov     edi, [esp+50h+arg_C]

    loc_4C01E4:                             ; CODE XREF: sub_4C01A0+3Ej
    push    edi
    push    ebp
    call    sub_4B7123
    mov     ecx, [esp+58h+arg_4]
    add     esp, 8
    mov     esi, eax
    push    edi
    push    ebp
    add     esi, ecx
    call    sub_4B70EF
    mov     ecx, [esp+58h+arg_8]
    mov     edi, eax
    mov     al, byte ptr [esp+58h+var_38]
    add     esp, 8
    add     edi, ecx
    test    al, 1
    jz      loc_4C02D6
    mov     eax, [esp+50h+var_3C]
    mov     [esp+50h+var_3C], ebx
    mov     ebx, [esp+50h+arg_0]
    mov     [esp+50h+arg_14], edi
    test    ebx, ebx
    mov     [esp+50h+arg_18], esi
    mov     [esp+50h+var_40], eax
    jnz     short loc_4C0296
    lea     ecx, [esp+50h+var_30]
    push    ecx
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4C02D6
    lea     edx, [esp+50h+arg_14]
    lea     eax, [esp+50h+arg_18]
    push    edx
    lea     ecx, [esp+54h+var_40]
    push    eax
    lea     edx, [esp+58h+var_3C]
    push    ecx
    lea     eax, [esp+5Ch+var_30]
    push    edx
    push    eax
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4C028A
    mov     ecx, [esp+50h+arg_10]
    mov     edx, [esp+50h+arg_14]
    mov     eax, [esp+50h+arg_18]
    push    ecx
    mov     ecx, [esp+54h+var_40]
    push    edx
    mov     edx, [esp+58h+var_3C]
    push    eax
    push    ecx
    lea     eax, [esp+60h+var_30]
    push    edx
    push    eax
    call    sub_4CC7AB
    add     esp, 18h

    loc_4C028A:                             ; CODE XREF: sub_4C01A0+C2j
    lea     ecx, [esp+50h+var_30]
    push    ecx
    call    sub_4C5FA0
    jmp     short loc_4C02D6
    ; ---------------------------------------------------------------------------

    loc_4C0296:                             ; CODE XREF: sub_4C01A0+8Ej
    lea     edx, [esp+50h+arg_14]
    lea     eax, [esp+50h+arg_18]
    push    edx
    lea     ecx, [esp+54h+var_40]
    push    eax
    lea     edx, [esp+58h+var_3C]
    push    ecx
    push    edx
    push    ebx
    call    sub_4BEA20
    test    eax, eax
    jz      short loc_4C02D6
    mov     eax, [esp+50h+arg_10]
    mov     ecx, [esp+50h+arg_14]
    mov     edx, [esp+50h+arg_18]
    push    eax
    mov     eax, [esp+54h+var_40]
    push    ecx
    mov     ecx, [esp+58h+var_3C]
    push    edx
    push    eax
    push    ecx
    push    ebx
    call    sub_4CC7AB
    add     esp, 18h

    loc_4C02D6:                             ; CODE XREF: sub_4C01A0+6Ej
                                            ; sub_4C01A0+9Cj ...
    mov     ecx, [esp+50h+var_34]
    mov     edx, [esp+50h+var_38]
    add     ebp, ecx
    inc     edx
    cmp     ebp, 10000h
    mov     ebx, esi
    mov     [esp+50h+var_3C], edi
    mov     [esp+50h+var_38], edx
    jle     loc_4C01E0
    pop     esi

    loc_4C02F8:                             ; CODE XREF: sub_4C01A0+2Fj
    pop     edi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn    1Ch
    sub_4C01A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C0310 proc near                    ; CODE XREF: sub_418310+535p
                                            ; sub_4211D0+1B0p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_C]
    mov     ecx, [esp+arg_8]
    mov     edx, [esp+arg_4]
    push    eax
    mov     eax, [esp+4+arg_0]
    push    ecx
    push    edx
    push    eax
    call    sub_4C0330
    retn    10h
    sub_4C0310 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C0330 proc near                    ; CODE XREF: sub_4C0310+14p

    var_14060= dword ptr -14060h
    var_1405C= dword ptr -1405Ch
    var_14058= dword ptr -14058h
    var_14054= dword ptr -14054h
    var_14050= dword ptr -14050h
    var_1404C= dword ptr -1404Ch
    var_14048= dword ptr -14048h
    var_14044= dword ptr -14044h
    var_14040= dword ptr -14040h
    var_1403C= dword ptr -1403Ch
    var_14038= dword ptr -14038h
    var_14034= dword ptr -14034h
    var_14030= dword ptr -14030h
    var_14000= dword ptr -14000h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= byte ptr  10h

    mov     eax, 14060h
    call    __alloca_probe
    mov     eax, [esp+14060h+arg_0]
    push    ebx
    push    ebp
    push    esi
    test    eax, eax
    push    edi
    jnz     short loc_4C0379
    lea     eax, [esp+14070h+var_14030]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jnz     short loc_4C0364
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14060h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C0364:                             ; CODE XREF: sub_4C0330+25j
    lea     ecx, [esp+14070h+var_14030]
    mov     [esp+14070h+var_1405C], 1
    mov     [esp+14070h+arg_0], ecx
    jmp     short loc_4C0381
    ; ---------------------------------------------------------------------------

    loc_4C0379:                             ; CODE XREF: sub_4C0330+17j
    mov     [esp+14070h+var_1405C], 0

    loc_4C0381:                             ; CODE XREF: sub_4C0330+47j
    mov     eax, [esp+14070h+arg_8]
    mov     ebp, [esp+14070h+arg_4]
    mov     edi, 0F423Fh
    mov     esi, 0FFF0BDC1h
    mov     ebx, edi
    xor     ecx, ecx
    test    eax, eax
    mov     [esp+14070h+var_14054], edi
    mov     [esp+14070h+var_14058], esi
    mov     [esp+14070h+var_14060], ebx
    jle     short loc_4C03F3
    mov     edx, ebp

    loc_4C03AF:                             ; CODE XREF: sub_4C0330+C1j
    mov     eax, [edx+4]
    cmp     eax, edi
    jge     short loc_4C03C0
    mov     [esp+14070h+var_14054], eax
    mov     [esp+14070h+var_14048], ecx
    mov     edi, eax

    loc_4C03C0:                             ; CODE XREF: sub_4C0330+84j
    cmp     eax, [esp+14070h+var_14058]
    jle     short loc_4C03CE
    mov     [esp+14070h+var_14058], eax
    mov     [esp+14070h+var_1404C], ecx

    loc_4C03CE:                             ; CODE XREF: sub_4C0330+94j
    mov     eax, [edx]
    cmp     eax, esi
    jle     short loc_4C03D6
    mov     esi, eax

    loc_4C03D6:                             ; CODE XREF: sub_4C0330+A2j
    mov     ebx, [esp+14070h+var_14060]
    cmp     eax, ebx
    jge     short loc_4C03E4
    mov     ebx, eax
    mov     [esp+14070h+var_14060], ebx

    loc_4C03E4:                             ; CODE XREF: sub_4C0330+ACj
    mov     eax, [esp+14070h+arg_8]
    inc     ecx
    add     edx, 8
    cmp     ecx, eax
    jl      short loc_4C03AF

    loc_4C03F3:                             ; CODE XREF: sub_4C0330+7Bj
    mov     ecx, [esp+14070h+arg_0]
    lea     edx, [esp+14070h+var_14044]
    push    edx
    call    sub_4C6AE0
    cmp     esi, [esp+14070h+var_14044]
    jge     short loc_4C042F
    mov     eax, [esp+14070h+var_1405C]
    test    eax, eax
    jz      loc_4C04DA
    lea     eax, [esp+14070h+var_14030]
    push    eax
    call    sub_4C5FA0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14060h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C042F:                             ; CODE XREF: sub_4C0330+D8j
    cmp     ebx, [esp+14070h+var_1403C]
    jle     short loc_4C045A
    mov     eax, [esp+14070h+var_1405C]
    test    eax, eax
    jz      loc_4C04DA
    lea     ecx, [esp+14070h+var_14030]
    push    ecx
    call    sub_4C5FA0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14060h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C045A:                             ; CODE XREF: sub_4C0330+103j
    mov     ebx, [esp+14070h+var_14040]
    mov     ecx, [esp+14070h+var_14058]
    cmp     ecx, ebx
    jge     short loc_4C0487
    mov     eax, [esp+14070h+var_1405C]
    test    eax, eax
    jz      short loc_4C04DA
    lea     edx, [esp+14070h+var_14030]
    push    edx
    call    sub_4C5FA0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14060h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C0487:                             ; CODE XREF: sub_4C0330+134j
    mov     eax, [esp+14070h+var_14038]
    cmp     edi, eax
    jle     short loc_4C04B0
    mov     eax, [esp+14070h+var_1405C]
    test    eax, eax
    jz      short loc_4C04DA
    lea     eax, [esp+14070h+var_14030]
    push    eax
    call    sub_4C5FA0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14060h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C04B0:                             ; CODE XREF: sub_4C0330+15Dj
    cmp     edi, ebx
    jge     short loc_4C04BA
    mov     [esp+14070h+var_14054], ebx
    mov     edi, ebx

    loc_4C04BA:                             ; CODE XREF: sub_4C0330+182j
    cmp     ecx, eax
    jle     short loc_4C04C4
    mov     [esp+14070h+var_14058], eax
    mov     ecx, eax

    loc_4C04C4:                             ; CODE XREF: sub_4C0330+18Cj
    cmp     ecx, edi
    jnz     short loc_4C04E9
    mov     eax, [esp+14070h+var_1405C]
    test    eax, eax
    jz      short loc_4C04DA
    lea     ecx, [esp+14070h+var_14030]
    push    ecx
    call    sub_4C5FA0

    loc_4C04DA:                             ; CODE XREF: sub_4C0330+E0j
                                            ; sub_4C0330+10Bj ...
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14060h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C04E9:                             ; CODE XREF: sub_4C0330+196j
    mov     eax, [esp+14070h+var_14048]
    lea     edx, [esp+14070h+var_14000]
    mov     [esp+14070h+var_14060], edx

    loc_4C04F5:                             ; CODE XREF: sub_4C0330+260j
    lea     edx, [eax-1]
    test    edx, edx
    mov     [esp+14070h+var_14050], edx
    jge     short loc_4C050A
    mov     ecx, [esp+14070h+arg_8]
    lea     edx, [ecx-1]

    loc_4C050A:                             ; CODE XREF: sub_4C0330+1CEj
    mov     edi, [ebp+edx*8+4]
    mov     esi, [ebp+eax*8+4]
    cmp     edi, ebx
    jle     short loc_4C057C
    cmp     esi, edi
    jge     short loc_4C057C
    mov     ecx, [ebp+eax*8+0]
    mov     eax, edi
    sub     eax, esi
    mov     [esp+14070h+var_14034], eax
    mov     eax, [ebp+edx*8+0]
    mov     ebp, [esp+14070h+var_14034]
    sub     eax, ecx
    shl     eax, 10h
    cdq
    shl     ecx, 10h
    idiv    ebp
    add     ecx, 0FFFFh
    cmp     esi, ebx
    jge     short loc_4C054E
    mov     edx, ebx
    sub     edx, esi
    mov     esi, ebx
    imul    edx, eax
    add     ecx, edx

    loc_4C054E:                             ; CODE XREF: sub_4C0330+211j
    mov     edx, [esp+14070h+var_14038]
    cmp     edi, edx
    jle     short loc_4C0558
    mov     edi, edx

    loc_4C0558:                             ; CODE XREF: sub_4C0330+224j
    cmp     esi, edi
    jge     short loc_4C0575
    mov     edx, [esp+14070h+var_14060]
    sub     edi, esi

    loc_4C0562:                             ; CODE XREF: sub_4C0330+23Fj
    mov     esi, ecx
    add     ecx, eax
    sar     esi, 10h
    mov     [edx], esi
    add     edx, 28h
    dec     edi
    jnz     short loc_4C0562
    mov     [esp+14070h+var_14060], edx

    loc_4C0575:                             ; CODE XREF: sub_4C0330+22Aj
    mov     ebp, [esp+14070h+arg_4]

    loc_4C057C:                             ; CODE XREF: sub_4C0330+1E4j
                                            ; sub_4C0330+1E8j
    mov     eax, [esp+14070h+var_14050]
    test    eax, eax
    jge     short loc_4C058C
    mov     eax, [esp+14070h+arg_8]
    dec     eax

    loc_4C058C:                             ; CODE XREF: sub_4C0330+252j
    cmp     eax, [esp+14070h+var_1404C]
    jnz     loc_4C04F5
    mov     eax, [esp+14070h+var_14048]
    lea     ecx, [esp+14070h+var_14000]
    mov     [esp+14070h+var_14060], ecx

    loc_4C05A2:                             ; CODE XREF: sub_4C0330+306j
    mov     ecx, [esp+14070h+arg_8]
    lea     edx, [eax+1]
    cmp     edx, ecx
    mov     [esp+14070h+var_14050], edx
    jl      short loc_4C05B6
    xor     edx, edx

    loc_4C05B6:                             ; CODE XREF: sub_4C0330+282j
    mov     edi, [ebp+edx*8+4]
    mov     esi, [ebp+eax*8+4]
    cmp     edi, ebx
    jle     short loc_4C0621
    cmp     esi, edi
    jge     short loc_4C0621
    mov     ecx, [ebp+eax*8+0]
    mov     eax, [ebp+edx*8+0]
    sub     eax, ecx
    mov     ebp, edi
    shl     eax, 10h
    cdq
    sub     ebp, esi
    shl     ecx, 10h
    idiv    ebp
    add     ecx, 0FFFFh
    cmp     esi, ebx
    jge     short loc_4C05F2
    mov     edx, ebx
    sub     edx, esi
    mov     esi, ebx
    imul    edx, eax
    add     ecx, edx

    loc_4C05F2:                             ; CODE XREF: sub_4C0330+2B5j
    mov     edx, [esp+14070h+var_14038]
    cmp     edi, edx
    jle     short loc_4C05FC
    mov     edi, edx

    loc_4C05FC:                             ; CODE XREF: sub_4C0330+2C8j
    cmp     esi, edi
    jge     short loc_4C061A
    mov     edx, [esp+14070h+var_14060]
    sub     edi, esi

    loc_4C0606:                             ; CODE XREF: sub_4C0330+2E4j
    mov     esi, ecx
    add     ecx, eax
    sar     esi, 10h
    mov     [edx+4], esi
    add     edx, 28h
    dec     edi
    jnz     short loc_4C0606
    mov     [esp+14070h+var_14060], edx

    loc_4C061A:                             ; CODE XREF: sub_4C0330+2CEj
    mov     ebp, [esp+14070h+arg_4]

    loc_4C0621:                             ; CODE XREF: sub_4C0330+290j
                                            ; sub_4C0330+294j
    mov     eax, [esp+14070h+var_14050]
    mov     ecx, [esp+14070h+arg_8]
    cmp     eax, ecx
    jl      short loc_4C0632
    xor     eax, eax

    loc_4C0632:                             ; CODE XREF: sub_4C0330+2FEj
    cmp     eax, [esp+14070h+var_1404C]
    jnz     loc_4C05A2
    mov     ebp, [esp+14070h+var_14054]
    mov     eax, [esp+14070h+var_14058]
    cmp     ebp, eax
    lea     esi, [esp+14070h+var_14000]
    jge     short loc_4C06B0

    loc_4C064C:                             ; CODE XREF: sub_4C0330+37Ej
    mov     eax, [esp+14070h+var_1403C]
    mov     ecx, [esi+4]
    cmp     ecx, eax
    jle     short loc_4C065A
    mov     [esi+4], eax

    loc_4C065A:                             ; CODE XREF: sub_4C0330+325j
    mov     eax, [esp+14070h+var_14044]
    mov     ecx, [esi]
    cmp     ecx, eax
    jge     short loc_4C0666
    mov     [esi], eax

    loc_4C0666:                             ; CODE XREF: sub_4C0330+332j
    mov     edx, [esi]
    mov     ecx, [esi+4]
    sub     ecx, edx
    test    ecx, ecx
    jle     short loc_4C06A4
    mov     ebx, [esp+14070h+arg_0]
    mov     al, [esp+14070h+arg_C]
    mov     edi, [ebx+8]
    imul    edi, ebp
    add     edi, [ebx+0Ch]
    mov     bl, al
    mov     bh, bl
    mov     eax, ebx
    add     edi, edx
    mov     edx, ecx
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb

    loc_4C06A4:                             ; CODE XREF: sub_4C0330+33Fj
    mov     eax, [esp+14070h+var_14058]
    add     esi, 28h
    inc     ebp
    cmp     ebp, eax
    jl      short loc_4C064C

    loc_4C06B0:                             ; CODE XREF: sub_4C0330+31Aj
    mov     eax, [esp+14070h+var_1405C]
    test    eax, eax
    jz      short loc_4C06C2
    lea     eax, [esp+14070h+var_14030]
    push    eax
    call    sub_4C5FA0

    loc_4C06C2:                             ; CODE XREF: sub_4C0330+386j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 14060h
    retn    10h
    sub_4C0330 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C06E0 proc near                    ; CODE XREF: sub_4C1000+2F8p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= byte ptr  10h

    mov     eax, [esp+arg_8]
    mov     ecx, [esp+arg_4]
    push    ebx
    push    ebp
    mov     edx, [ecx+4]
    mov     ebp, [ecx]
    mov     ebx, [ecx+18h]
    push    esi
    mov     esi, [eax+14h]
    push    edi
    mov     edi, [eax+10h]
    mov     eax, [ecx+1Ch]
    sub     edx, ebp
    sub     eax, ebx
    mov     [esp+10h+arg_4], edx
    mov     ebp, [esp+10h+arg_4]
    cdq
    idiv    ebp
    mov     edx, [ecx]
    test    edx, edx
    mov     [esp+10h+arg_4], eax
    jge     short loc_4C0724
    imul    eax, edx
    sub     ebx, eax
    mov     dword ptr [ecx], 0
    mov     [ecx+18h], ebx

    loc_4C0724:                             ; CODE XREF: sub_4C06E0+34j
    mov     ebp, [esp+10h+arg_8]
    mov     edx, [ecx+4]
    xor     eax, eax
    mov     ax, [ebp+0]
    dec     eax
    cmp     edx, eax
    jle     short loc_4C0739
    mov     [ecx+4], eax

    loc_4C0739:                             ; CODE XREF: sub_4C06E0+54j
    mov     edx, [ecx]
    mov     ebx, [ecx+4]
    sub     ebx, edx
    test    ebx, ebx
    jle     short loc_4C07A1
    xor     eax, eax
    mov     ecx, [ecx+18h]
    mov     ax, [ebp+0]
    imul    eax, [esp+10h+arg_0]
    add     edx, eax
    add     edi, edx
    test    esi, esi
    jz      short loc_4C0781
    mov     eax, [esp+10h+arg_4]
    lea     ebp, [ebx]
    mov     bl, [esp+10h+arg_C]
    add     esi, edx

    loc_4C0766:                             ; CODE XREF: sub_4C06E0+98j
    mov     edx, ecx
    sar     edx, 10h
    cmp     [esi], dl
    ja      short loc_4C0773
    mov     [edi], bl
    mov     [esi], dl

    loc_4C0773:                             ; CODE XREF: sub_4C06E0+8Dj
    inc     edi
    inc     esi
    add     ecx, eax
    dec     ebp
    jnz     short loc_4C0766
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C0781:                             ; CODE XREF: sub_4C06E0+78j
    mov     al, [esp+10h+arg_C]
    lea     ecx, [ebx]
    mov     bl, al
    mov     edx, ecx
    mov     bh, bl
    mov     eax, ebx
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb

    loc_4C07A1:                             ; CODE XREF: sub_4C06E0+62j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_4C06E0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+0Ch]
    push    ebx
    mov     ebx, [esp+14h]
    push    ebp
    mov     ebp, [esp+0Ch]
    push    edi
    lea     edi, [eax-1]
    test    edi, edi
    jle     short loc_4C07EF
    mov     eax, [esp+14h]
    push    esi
    lea     esi, [eax+0Ch]

    loc_4C07CE:                             ; CODE XREF: .text:004C07E8j
    mov     ecx, [esi+4]
    mov     edx, [esi]
    mov     eax, [esi-8]
    push    ebx
    push    ecx
    mov     ecx, [esi-0Ch]
    push    edx
    push    eax
    push    ecx
    push    ebp
    call    sub_4BE950
    add     esi, 0Ch
    dec     edi
    jnz     short loc_4C07CE
    mov     eax, [esp+1Ch]
    pop     esi

    loc_4C07EF:                             ; CODE XREF: .text:004C07C4j
    mov     ecx, [esp+14h]
    lea     edx, [eax+eax*2]
    push    ebx
    lea     eax, [ecx+edx*4]
    mov     edx, [ecx+4]
    mov     ecx, [ecx]
    push    edx
    mov     edx, [eax-8]
    mov     eax, [eax-0Ch]
    push    ecx
    push    edx
    push    eax
    push    ebp
    call    sub_4BE950
    pop     edi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C0820 proc near                    ; CODE XREF: sub_458FA0+188p

    var_14024= dword ptr -14024h
    var_14020= dword ptr -14020h
    var_1401C= dword ptr -1401Ch
    var_14018= dword ptr -14018h
    var_14014= dword ptr -14014h
    var_14010= dword ptr -14010h
    var_1400C= dword ptr -1400Ch
    var_14008= dword ptr -14008h
    var_14004= dword ptr -14004h
    var_14000= dword ptr -14000h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, 14024h
    call    __alloca_probe
    mov     eax, [esp+14024h+arg_8]
    push    ebx
    mov     ebx, [esp+14028h+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     esi, 0F423Fh
    mov     edi, 0FFF0BDC1h
    xor     ecx, ecx
    mov     [esp+14034h+var_14018], esi
    test    eax, eax
    mov     [esp+14034h+var_14020], edi
    mov     [esp+14034h+var_14024], esi
    jle     short loc_4C089A
    mov     edx, ebx

    loc_4C085A:                             ; CODE XREF: sub_4C0820+78j
    mov     eax, [edx+4]
    cmp     eax, esi
    jge     short loc_4C086B
    mov     [esp+14034h+var_14018], eax
    mov     [esp+14034h+var_14004], ecx
    mov     esi, eax

    loc_4C086B:                             ; CODE XREF: sub_4C0820+3Fj
    cmp     eax, [esp+14034h+var_14020]
    jle     short loc_4C0879
    mov     [esp+14034h+var_14020], eax
    mov     [esp+14034h+var_14008], ecx

    loc_4C0879:                             ; CODE XREF: sub_4C0820+4Fj
    mov     eax, [edx]
    cmp     eax, edi
    jle     short loc_4C0881
    mov     edi, eax

    loc_4C0881:                             ; CODE XREF: sub_4C0820+5Dj
    cmp     eax, [esp+14034h+var_14024]
    jge     short loc_4C088B
    mov     [esp+14034h+var_14024], eax

    loc_4C088B:                             ; CODE XREF: sub_4C0820+65j
    mov     eax, [esp+14034h+arg_8]
    inc     ecx
    add     edx, 0Ch
    cmp     ecx, eax
    jl      short loc_4C085A

    loc_4C089A:                             ; CODE XREF: sub_4C0820+36j
    cmp     [esp+14034h+var_14020], esi
    jnz     short loc_4C08AF
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14024h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C08AF:                             ; CODE XREF: sub_4C0820+7Ej
    lea     eax, [esp+14034h+var_14000]
    mov     [esp+14034h+var_1401C], eax
    mov     eax, [esp+14034h+var_14004]

    loc_4C08BB:                             ; CODE XREF: sub_4C0820+146j
    lea     edi, [eax-1]
    mov     ecx, edi
    mov     [esp+14034h+var_14010], edi
    test    ecx, ecx
    jge     short loc_4C08D0
    mov     ecx, [esp+14034h+arg_8]
    dec     ecx

    loc_4C08D0:                             ; CODE XREF: sub_4C0820+A6j
    lea     edx, [eax+eax*2]
    mov     eax, [ebx+edx*4+4]
    lea     ecx, [ecx+ecx*2]
    mov     [esp+14034h+var_1400C], eax
    lea     ebp, [ebx+edx*4]
    mov     esi, [ebx+ecx*4+4]
    lea     edx, [ebx+ecx*4]
    cmp     eax, esi
    mov     [esp+14034h+var_14014], edx
    jge     short loc_4C0954
    mov     ecx, [ebp+0]
    mov     edi, esi
    sub     edi, eax
    mov     eax, [edx]
    sub     eax, ecx
    shl     eax, 10h
    cdq
    idiv    edi
    mov     edx, [esp+14034h+var_14014]
    shl     ecx, 10h
    add     ecx, 0FFFFh
    mov     ebx, ecx
    mov     ecx, [ebp+8]
    shl     ecx, 10h
    mov     [esp+14034h+var_14024], eax
    mov     eax, [edx+8]
    shl     eax, 10h
    sub     eax, ecx
    cdq
    idiv    edi
    sub     esi, [esp+14034h+var_1400C]

    loc_4C0929:                             ; CODE XREF: sub_4C0820+127j
    mov     edx, [esp+14034h+var_1401C]
    mov     edi, ebx
    sar     edi, 10h
    mov     [edx], edi
    mov     edi, [esp+14034h+var_14024]
    mov     [edx+18h], ecx
    add     ebx, edi
    add     ecx, eax
    add     edx, 28h
    dec     esi
    mov     [esp+14034h+var_1401C], edx
    jnz     short loc_4C0929
    mov     edi, [esp+14034h+var_14010]
    mov     ebx, [esp+14034h+arg_4]

    loc_4C0954:                             ; CODE XREF: sub_4C0820+CEj
    mov     eax, edi
    test    eax, eax
    jge     short loc_4C0962
    mov     eax, [esp+14034h+arg_8]
    dec     eax

    loc_4C0962:                             ; CODE XREF: sub_4C0820+138j
    cmp     eax, [esp+14034h+var_14008]
    jnz     loc_4C08BB
    mov     eax, [esp+14034h+var_14004]
    lea     ecx, [esp+14034h+var_14000]
    mov     [esp+14034h+var_1401C], ecx
    jmp     short loc_4C0981
    ; ---------------------------------------------------------------------------

    loc_4C097A:                             ; CODE XREF: sub_4C0820+20Fj
    mov     ebx, [esp+14034h+arg_4]

    loc_4C0981:                             ; CODE XREF: sub_4C0820+158j
    mov     edx, [esp+14034h+arg_8]
    lea     edi, [eax+1]
    mov     ecx, edi
    mov     [esp+14034h+var_1400C], edi
    cmp     ecx, edx
    jl      short loc_4C0997
    xor     ecx, ecx

    loc_4C0997:                             ; CODE XREF: sub_4C0820+173j
    lea     edx, [eax+eax*2]
    mov     eax, [ebx+edx*4+4]
    lea     ecx, [ecx+ecx*2]
    mov     [esp+14034h+var_14010], eax
    lea     ebp, [ebx+edx*4]
    mov     edx, [esp+14034h+arg_4]
    mov     esi, [edx+ecx*4+4]
    lea     edx, [edx+ecx*4]
    cmp     eax, esi
    mov     [esp+14034h+var_14014], edx
    jge     short loc_4C0A1C
    mov     ecx, [ebp+0]
    mov     edi, esi
    sub     edi, eax
    mov     eax, [edx]
    sub     eax, ecx
    shl     eax, 10h
    cdq
    idiv    edi
    shl     ecx, 10h
    add     ecx, 0FFFFh
    mov     ebx, ecx
    mov     ecx, [ebp+8]
    shl     ecx, 10h
    mov     [esp+14034h+var_14024], eax
    mov     eax, [esp+14034h+var_14014]
    mov     eax, [eax+8]
    shl     eax, 10h
    sub     eax, ecx
    cdq
    idiv    edi
    sub     esi, [esp+14034h+var_14010]

    loc_4C09F7:                             ; CODE XREF: sub_4C0820+1F6j
    mov     edx, [esp+14034h+var_1401C]
    mov     edi, ebx
    sar     edi, 10h
    mov     [edx+4], edi
    mov     edi, [esp+14034h+var_14024]
    mov     [edx+1Ch], ecx
    add     ebx, edi
    add     ecx, eax
    add     edx, 28h
    dec     esi
    mov     [esp+14034h+var_1401C], edx
    jnz     short loc_4C09F7
    mov     edi, [esp+14034h+var_1400C]

    loc_4C0A1C:                             ; CODE XREF: sub_4C0820+19Cj
    mov     ecx, [esp+14034h+arg_8]
    mov     eax, edi
    cmp     eax, ecx
    jl      short loc_4C0A2B
    xor     eax, eax

    loc_4C0A2B:                             ; CODE XREF: sub_4C0820+207j
    cmp     eax, [esp+14034h+var_14008]
    jnz     loc_4C097A
    mov     esi, [esp+14034h+var_14018]
    mov     eax, [esp+14034h+var_14020]
    cmp     esi, eax
    lea     edi, [esp+14034h+var_14000]
    jge     short loc_4C0A73
    mov     ebx, [esp+14034h+arg_C]
    mov     ebp, [esp+14034h+arg_0]

    loc_4C0A53:                             ; CODE XREF: sub_4C0820+251j
    mov     ecx, [edi+4]
    mov     edx, [edi]
    sub     ecx, edx
    test    ecx, ecx
    jle     short loc_4C0A67
    push    ebx
    push    ebp
    push    edi
    push    esi
    call    sub_4C0A90

    loc_4C0A67:                             ; CODE XREF: sub_4C0820+23Cj
    mov     eax, [esp+14034h+var_14020]
    add     edi, 28h
    inc     esi
    cmp     esi, eax
    jl      short loc_4C0A53

    loc_4C0A73:                             ; CODE XREF: sub_4C0820+223j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 14024h
    retn    10h
    sub_4C0820 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C0A90 proc near                    ; CODE XREF: sub_4C0820+242p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= byte ptr  10h

    mov     ecx, [esp+arg_8]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    mov     eax, [ecx+14h]
    push    esi
    mov     edx, [ebp+4]
    mov     esi, [ecx+10h]
    push    edi
    mov     edi, [ebp+0]
    sub     edx, edi
    test    edx, edx
    jle     short loc_4C0AFF
    xor     ebx, ebx
    mov     bx, [ecx]
    mov     ecx, [esp+10h+arg_0]
    imul    ecx, ebx
    lea     ebx, [ecx+edi]
    add     esi, ebx
    test    eax, eax
    jz      short loc_4C0AF6
    add     ecx, edi
    add     eax, ecx
    mov     ecx, [ebp+18h]
    sar     ecx, 10h
    mov     bl, [eax]
    cmp     bl, cl
    mov     bl, [esp+10h+arg_C]
    ja      short loc_4C0ADB
    mov     [esi], bl
    mov     [eax], cl

    loc_4C0ADB:                             ; CODE XREF: sub_4C0A90+45j
    mov     ecx, [ebp+1Ch]
    add     eax, edx
    add     esi, edx
    mov     dl, [eax]
    sar     ecx, 10h
    cmp     dl, cl
    ja      short loc_4C0AFF
    mov     [esi], bl
    mov     [eax], cl
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C0AF6:                             ; CODE XREF: sub_4C0A90+31j
    mov     al, [esp+10h+arg_C]
    mov     [esi], al
    mov     [edx+esi], al

    loc_4C0AFF:                             ; CODE XREF: sub_4C0A90+1Cj
                                            ; sub_4C0A90+59j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_4C0A90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C0B10 proc near                    ; CODE XREF: sub_4C0C70+362p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 0Ch
    mov     eax, [esp+0Ch+arg_8]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [eax+10h]
    push    edi
    mov     edi, [eax+14h]
    call    sub_4B6220
    mov     ecx, [esp+1Ch+arg_4]
    mov     [esp+1Ch+var_8], eax
    mov     edx, [ecx+18h]
    mov     eax, [ecx+1Ch]
    mov     ebx, [ecx+4]
    mov     ebp, [ecx]
    sub     eax, edx
    mov     [esp+1Ch+arg_4], edx
    cdq
    sub     ebx, ebp
    idiv    ebx
    mov     edx, [ecx+20h]
    mov     [esp+1Ch+var_4], edx
    mov     [esp+1Ch+var_C], eax
    mov     eax, [ecx+24h]
    sub     eax, edx
    cdq
    idiv    ebx
    test    ebp, ebp
    jge     short loc_4C0B7F
    mov     ebx, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_4]
    imul    ebx, ebp
    sub     edx, ebx
    mov     ebx, eax
    imul    ebx, ebp
    mov     [ecx+18h], edx
    mov     edx, [esp+1Ch+var_4]
    sub     edx, ebx
    mov     dword ptr [ecx], 0
    mov     [ecx+20h], edx

    loc_4C0B7F:                             ; CODE XREF: sub_4C0B10+49j
    mov     ebp, [esp+1Ch+arg_8]
    mov     ebx, [ecx+4]
    xor     edx, edx
    mov     dx, [ebp+0]
    dec     edx
    cmp     ebx, edx
    jle     short loc_4C0B94
    mov     [ecx+4], edx

    loc_4C0B94:                             ; CODE XREF: sub_4C0B10+7Fj
    mov     edx, [ecx]
    mov     ebx, [ecx+4]
    sub     ebx, edx
    mov     [esp+1Ch+arg_4], edx
    test    ebx, ebx
    jle     loc_4C0C66
    mov     edx, [ecx+18h]
    mov     ecx, [ecx+20h]
    mov     [esp+1Ch+arg_8], edx
    xor     edx, edx
    mov     dx, [ebp+0]
    mov     [esp+1Ch+var_4], edx
    mov     edx, [esp+1Ch+arg_0]
    mov     ebp, [esp+1Ch+var_4]
    imul    edx, ebp
    mov     ebp, [esp+1Ch+arg_4]
    add     ebp, edx
    add     esi, ebp
    test    edi, edi
    jz      short loc_4C0C38
    mov     ebp, [esp+1Ch+arg_4]
    mov     [esp+1Ch+arg_4], ebx
    mov     ebx, [esp+1Ch+arg_8]
    add     edx, ebp
    add     edi, edx

    loc_4C0BE2:                             ; CODE XREF: sub_4C0B10+11Cj
    mov     edx, ebx
    sar     edx, 10h
    cmp     [edi], dl
    ja      short loc_4C0C15
    mov     ebp, [esp+1Ch+var_8]
    mov     ebx, ecx
    sar     ebx, 10h
    mov     ebp, [ebp+0C4h]
    shl     ebx, 8
    add     ebp, ebx
    mov     ebx, [esp+1Ch+arg_C]
    and     ebx, 0FFh
    mov     bl, [ebp+ebx+0]
    mov     [esi], bl
    mov     ebx, [esp+1Ch+arg_8]
    mov     [edi], dl

    loc_4C0C15:                             ; CODE XREF: sub_4C0B10+D9j
    mov     edx, [esp+1Ch+var_C]
    inc     esi
    add     ebx, edx
    mov     edx, [esp+1Ch+arg_4]
    inc     edi
    add     ecx, eax
    dec     edx
    mov     [esp+1Ch+arg_8], ebx
    mov     [esp+1Ch+arg_4], edx
    jnz     short loc_4C0BE2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C0C38:                             ; CODE XREF: sub_4C0B10+C0j
    mov     edi, [esp+1Ch+arg_C]
    dec     ebx
    and     edi, 0FFh
    lea     ebp, [ebx+1]

    loc_4C0C46:                             ; CODE XREF: sub_4C0B10+154j
    mov     ebx, [esp+1Ch+var_8]
    mov     edx, ecx
    sar     edx, 10h
    mov     ebx, [ebx+0C4h]
    add     ecx, eax
    shl     edx, 8
    add     edx, edi
    inc     esi
    dec     ebp
    mov     dl, [edx+ebx]
    mov     [esi-1], dl
    jnz     short loc_4C0C46

    loc_4C0C66:                             ; CODE XREF: sub_4C0B10+91j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    10h
    sub_4C0B10 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C0C70 proc near                    ; CODE XREF: sub_459C70+74Ap

    var_1402C= dword ptr -1402Ch
    var_14028= dword ptr -14028h
    var_14024= dword ptr -14024h
    var_14020= dword ptr -14020h
    var_1401C= dword ptr -1401Ch
    var_14018= dword ptr -14018h
    var_14014= dword ptr -14014h
    var_14010= dword ptr -14010h
    var_1400C= dword ptr -1400Ch
    var_14008= dword ptr -14008h
    var_14004= dword ptr -14004h
    var_14000= dword ptr -14000h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, 1402Ch
    call    __alloca_probe
    mov     eax, [esp+1402Ch+arg_8]
    push    ebx
    mov     edx, [esp+14030h+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, 0F423Fh
    mov     ebp, 0FFF0BDC1h
    mov     ebx, edi
    xor     ecx, ecx
    test    eax, eax
    mov     [esp+1403Ch+var_14020], edi
    mov     [esp+1403Ch+var_14024], ebp
    mov     [esp+1403Ch+var_14028], ebx
    jle     short loc_4C0CF0
    mov     esi, edx

    loc_4C0CAC:                             ; CODE XREF: sub_4C0C70+7Ej
    mov     eax, [esi+4]
    cmp     eax, edi
    jge     short loc_4C0CBD
    mov     [esp+1403Ch+var_14020], eax
    mov     [esp+1403Ch+var_1400C], ecx
    mov     edi, eax

    loc_4C0CBD:                             ; CODE XREF: sub_4C0C70+41j
    cmp     eax, [esp+1403Ch+var_14024]
    jle     short loc_4C0CCB
    mov     [esp+1403Ch+var_14024], eax
    mov     [esp+1403Ch+var_14004], ecx

    loc_4C0CCB:                             ; CODE XREF: sub_4C0C70+51j
    mov     eax, [esi]
    cmp     eax, ebp
    jle     short loc_4C0CD3
    mov     ebp, eax

    loc_4C0CD3:                             ; CODE XREF: sub_4C0C70+5Fj
    mov     ebx, [esp+1403Ch+var_14028]
    cmp     eax, ebx
    jge     short loc_4C0CE1
    mov     ebx, eax
    mov     [esp+1403Ch+var_14028], ebx

    loc_4C0CE1:                             ; CODE XREF: sub_4C0C70+69j
    mov     eax, [esp+1403Ch+arg_8]
    inc     ecx
    add     esi, 10h
    cmp     ecx, eax
    jl      short loc_4C0CAC

    loc_4C0CF0:                             ; CODE XREF: sub_4C0C70+38j
    mov     ecx, [esp+1403Ch+arg_0]
    xor     eax, eax
    mov     ax, [ecx]
    dec     eax
    cmp     ebx, eax
    jle     short loc_4C0D10
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1402Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C0D10:                             ; CODE XREF: sub_4C0C70+8Fj
    mov     eax, [esp+1403Ch+var_14024]
    test    eax, eax
    jge     short loc_4C0D27
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1402Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C0D27:                             ; CODE XREF: sub_4C0C70+A6j
    xor     eax, eax
    mov     ax, [ecx+2]
    dec     eax
    cmp     edi, eax
    mov     [esp+1403Ch+var_14008], eax
    jle     short loc_4C0D45
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1402Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C0D45:                             ; CODE XREF: sub_4C0C70+C4j
    test    edi, edi
    jge     short loc_4C0D55
    mov     [esp+1403Ch+var_14020], 0
    mov     edi, [esp+1403Ch+var_14020]

    loc_4C0D55:                             ; CODE XREF: sub_4C0C70+D7j
    cmp     [esp+1403Ch+var_14024], eax
    jle     short loc_4C0D5F
    mov     [esp+1403Ch+var_14024], eax

    loc_4C0D5F:                             ; CODE XREF: sub_4C0C70+E9j
    cmp     [esp+1403Ch+var_14024], edi
    jnz     short loc_4C0D74
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1402Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C0D74:                             ; CODE XREF: sub_4C0C70+F3j
    mov     esi, [esp+1403Ch+var_1400C]
    lea     ecx, [esp+1403Ch+var_14000]
    mov     [esp+1403Ch+var_14028], ecx

    loc_4C0D80:                             ; CODE XREF: sub_4C0C70+218j
    lea     eax, [esi-1]
    mov     ebp, eax
    mov     [esp+1403Ch+var_14010], eax
    test    ebp, ebp
    jge     short loc_4C0D97
    mov     ecx, [esp+1403Ch+arg_8]
    lea     ebp, [ecx-1]

    loc_4C0D97:                             ; CODE XREF: sub_4C0C70+11Bj
    shl     esi, 4
    shl     ebp, 4
    mov     ebx, [esi+edx+4]
    add     esi, edx
    mov     edi, [ebp+edx+4]
    add     ebp, edx
    cmp     ebx, edi
    mov     [esp+1403Ch+var_1402C], edi
    jge     loc_4C0E74
    mov     ecx, [esi]
    mov     eax, [ebp+0]
    sub     eax, ecx
    sub     edi, ebx
    shl     eax, 10h
    cdq
    idiv    edi
    shl     ecx, 10h
    add     ecx, 0FFFFh
    mov     [esp+1403Ch+var_14018], ecx
    mov     ecx, [esi+8]
    shl     ecx, 10h
    mov     esi, [esi+0Ch]
    shl     esi, 10h
    mov     [esp+1403Ch+var_1401C], eax
    mov     eax, [ebp+8]
    shl     eax, 10h
    sub     eax, ecx
    cdq
    idiv    edi
    mov     [esp+1403Ch+var_14014], eax
    mov     eax, [ebp+0Ch]
    shl     eax, 10h
    sub     eax, esi
    cdq
    idiv    edi
    test    ebx, ebx
    jge     short loc_4C0E20
    mov     edx, [esp+1403Ch+var_1401C]
    mov     edi, [esp+1403Ch+var_14018]
    imul    edx, ebx
    sub     edi, edx
    mov     edx, [esp+1403Ch+var_14014]
    imul    edx, ebx
    sub     ecx, edx
    mov     edx, eax
    imul    edx, ebx
    sub     esi, edx
    xor     ebx, ebx
    jmp     short loc_4C0E24
    ; ---------------------------------------------------------------------------

    loc_4C0E20:                             ; CODE XREF: sub_4C0C70+18Dj
    mov     edi, [esp+1403Ch+var_14018]

    loc_4C0E24:                             ; CODE XREF: sub_4C0C70+1AEj
    mov     edx, [esp+1403Ch+var_14008]
    mov     ebp, [esp+1403Ch+var_1402C]
    cmp     ebp, edx
    jle     short loc_4C0E34
    mov     [esp+1403Ch+var_1402C], edx

    loc_4C0E34:                             ; CODE XREF: sub_4C0C70+1BEj
    mov     edx, [esp+1403Ch+var_1402C]
    cmp     ebx, edx
    jge     short loc_4C0E69
    sub     edx, ebx
    mov     ebx, edx

    loc_4C0E40:                             ; CODE XREF: sub_4C0C70+1F7j
    mov     edx, [esp+1403Ch+var_14028]
    mov     ebp, edi
    sar     ebp, 10h
    mov     [edx], ebp
    mov     ebp, [esp+1403Ch+var_1401C]
    add     edi, ebp
    mov     ebp, [esp+1403Ch+var_14014]
    mov     [edx+18h], ecx
    mov     [edx+20h], esi
    add     ecx, ebp
    add     esi, eax
    add     edx, 28h
    dec     ebx
    mov     [esp+1403Ch+var_14028], edx
    jnz     short loc_4C0E40

    loc_4C0E69:                             ; CODE XREF: sub_4C0C70+1CAj
    mov     edx, [esp+1403Ch+arg_4]
    mov     eax, [esp+1403Ch+var_14010]

    loc_4C0E74:                             ; CODE XREF: sub_4C0C70+13Fj
    mov     esi, eax
    test    esi, esi
    jge     short loc_4C0E84
    mov     eax, [esp+1403Ch+arg_8]
    lea     esi, [eax-1]

    loc_4C0E84:                             ; CODE XREF: sub_4C0C70+208j
    cmp     esi, [esp+1403Ch+var_14004]
    jnz     loc_4C0D80
    mov     esi, [esp+1403Ch+var_1400C]
    lea     ecx, [esp+1403Ch+var_14000]
    mov     [esp+1403Ch+var_14028], ecx
    jmp     short loc_4C0EA3
    ; ---------------------------------------------------------------------------

    loc_4C0E9C:                             ; CODE XREF: sub_4C0C70+32Fj
    mov     edx, [esp+1403Ch+arg_4]

    loc_4C0EA3:                             ; CODE XREF: sub_4C0C70+22Aj
    mov     eax, [esp+1403Ch+arg_8]
    lea     ebp, [esi+1]
    cmp     ebp, eax
    mov     [esp+1403Ch+var_14010], ebp
    jl      short loc_4C0EB7
    xor     ebp, ebp

    loc_4C0EB7:                             ; CODE XREF: sub_4C0C70+243j
    shl     esi, 4
    shl     ebp, 4
    mov     ebx, [esi+edx+4]
    add     esi, edx
    mov     edi, [ebp+edx+4]
    add     ebp, edx
    cmp     ebx, edi
    mov     [esp+1403Ch+var_1402C], edi
    jge     loc_4C0F8A
    mov     ecx, [esi]
    mov     eax, [ebp+0]
    sub     eax, ecx
    sub     edi, ebx
    shl     eax, 10h
    cdq
    idiv    edi
    shl     ecx, 10h
    add     ecx, 0FFFFh
    mov     [esp+1403Ch+var_14018], ecx
    mov     ecx, [esi+8]
    shl     ecx, 10h
    mov     esi, [esi+0Ch]
    shl     esi, 10h
    mov     [esp+1403Ch+var_1401C], eax
    mov     eax, [ebp+8]
    shl     eax, 10h
    sub     eax, ecx
    cdq
    idiv    edi
    mov     [esp+1403Ch+var_14014], eax
    mov     eax, [ebp+0Ch]
    shl     eax, 10h
    sub     eax, esi
    cdq
    idiv    edi
    test    ebx, ebx
    jge     short loc_4C0F40
    mov     edx, [esp+1403Ch+var_1401C]
    mov     edi, [esp+1403Ch+var_14018]
    imul    edx, ebx
    sub     edi, edx
    mov     edx, [esp+1403Ch+var_14014]
    imul    edx, ebx
    sub     ecx, edx
    mov     edx, eax
    imul    edx, ebx
    sub     esi, edx
    xor     ebx, ebx
    jmp     short loc_4C0F44
    ; ---------------------------------------------------------------------------

    loc_4C0F40:                             ; CODE XREF: sub_4C0C70+2ADj
    mov     edi, [esp+1403Ch+var_14018]

    loc_4C0F44:                             ; CODE XREF: sub_4C0C70+2CEj
    mov     edx, [esp+1403Ch+var_14008]
    mov     ebp, [esp+1403Ch+var_1402C]
    cmp     ebp, edx
    jle     short loc_4C0F54
    mov     [esp+1403Ch+var_1402C], edx

    loc_4C0F54:                             ; CODE XREF: sub_4C0C70+2DEj
    mov     edx, [esp+1403Ch+var_1402C]
    cmp     ebx, edx
    jge     short loc_4C0F8A
    sub     edx, ebx
    mov     ebx, edx

    loc_4C0F60:                             ; CODE XREF: sub_4C0C70+318j
    mov     edx, [esp+1403Ch+var_14028]
    mov     ebp, edi
    sar     ebp, 10h
    mov     [edx+4], ebp
    mov     ebp, [esp+1403Ch+var_1401C]
    add     edi, ebp
    mov     ebp, [esp+1403Ch+var_14014]
    mov     [edx+1Ch], ecx
    mov     [edx+24h], esi
    add     ecx, ebp
    add     esi, eax
    add     edx, 28h
    dec     ebx
    mov     [esp+1403Ch+var_14028], edx
    jnz     short loc_4C0F60

    loc_4C0F8A:                             ; CODE XREF: sub_4C0C70+25Fj
                                            ; sub_4C0C70+2EAj
    mov     esi, [esp+1403Ch+var_14010]
    mov     eax, [esp+1403Ch+arg_8]
    cmp     esi, eax
    jl      short loc_4C0F9B
    xor     esi, esi

    loc_4C0F9B:                             ; CODE XREF: sub_4C0C70+327j
    cmp     esi, [esp+1403Ch+var_14004]
    jnz     loc_4C0E9C
    mov     esi, [esp+1403Ch+var_14020]
    mov     ebx, [esp+1403Ch+var_14024]
    cmp     esi, ebx
    lea     edi, [esp+1403Ch+var_14000]
    jge     short loc_4C0FDF
    mov     ebp, [esp+1403Ch+arg_C]

    loc_4C0FBC:                             ; CODE XREF: sub_4C0C70+36Dj
    mov     eax, [edi+4]
    mov     edx, [edi]
    sub     eax, edx
    test    eax, eax
    jle     short loc_4C0FD7
    mov     ecx, [esp+1403Ch+arg_0]
    push    ebp
    push    ecx
    push    edi
    push    esi
    call    sub_4C0B10

    loc_4C0FD7:                             ; CODE XREF: sub_4C0C70+355j
    add     edi, 28h
    inc     esi
    cmp     esi, ebx
    jl      short loc_4C0FBC

    loc_4C0FDF:                             ; CODE XREF: sub_4C0C70+343j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 1402Ch
    retn    10h
    sub_4C0C70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1000 proc near                    ; CODE XREF: sub_459830+381p
                                            ; sub_45A610+140p

    var_14028= dword ptr -14028h
    var_14024= dword ptr -14024h
    var_14020= dword ptr -14020h
    var_1401C= dword ptr -1401Ch
    var_14018= dword ptr -14018h
    var_14014= dword ptr -14014h
    var_14010= dword ptr -14010h
    var_1400C= dword ptr -1400Ch
    var_14008= dword ptr -14008h
    var_14004= dword ptr -14004h
    var_14000= dword ptr -14000h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, 14028h
    call    __alloca_probe
    mov     eax, [esp+14028h+arg_8]
    push    ebx
    mov     ebx, [esp+1402Ch+arg_4]
    push    ebp
    push    esi
    mov     esi, 0F423Fh
    push    edi
    mov     edi, 0FFF0BDC1h
    mov     ebp, esi
    xor     ecx, ecx
    test    eax, eax
    mov     [esp+14038h+var_14020], esi
    mov     [esp+14038h+var_14028], edi
    mov     [esp+14038h+var_14024], ebp
    jle     short loc_4C1080
    mov     edx, ebx

    loc_4C103C:                             ; CODE XREF: sub_4C1000+7Ej
    mov     eax, [edx+4]
    cmp     eax, esi
    jge     short loc_4C104D
    mov     [esp+14038h+var_14020], eax
    mov     [esp+14038h+var_1400C], ecx
    mov     esi, eax

    loc_4C104D:                             ; CODE XREF: sub_4C1000+41j
    cmp     eax, [esp+14038h+var_14028]
    jle     short loc_4C105B
    mov     [esp+14038h+var_14028], eax
    mov     [esp+14038h+var_14008], ecx

    loc_4C105B:                             ; CODE XREF: sub_4C1000+51j
    mov     eax, [edx]
    cmp     eax, edi
    jle     short loc_4C1063
    mov     edi, eax

    loc_4C1063:                             ; CODE XREF: sub_4C1000+5Fj
    mov     ebp, [esp+14038h+var_14024]
    cmp     eax, ebp
    jge     short loc_4C1071
    mov     ebp, eax
    mov     [esp+14038h+var_14024], ebp

    loc_4C1071:                             ; CODE XREF: sub_4C1000+69j
    mov     eax, [esp+14038h+arg_8]
    inc     ecx
    add     edx, 0Ch
    cmp     ecx, eax
    jl      short loc_4C103C

    loc_4C1080:                             ; CODE XREF: sub_4C1000+38j
    mov     ecx, [esp+14038h+arg_0]
    xor     eax, eax
    mov     ax, [ecx]
    dec     eax
    cmp     ebp, eax
    jle     short loc_4C10A0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14028h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C10A0:                             ; CODE XREF: sub_4C1000+8Fj
    mov     eax, [esp+14038h+var_14028]
    test    eax, eax
    jge     short loc_4C10B7
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14028h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C10B7:                             ; CODE XREF: sub_4C1000+A6j
    xor     eax, eax
    mov     ax, [ecx+2]
    dec     eax
    cmp     esi, eax
    mov     [esp+14038h+var_14004], eax
    jle     short loc_4C10D5
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14028h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C10D5:                             ; CODE XREF: sub_4C1000+C4j
    test    esi, esi
    jge     short loc_4C10E5
    mov     [esp+14038h+var_14020], 0
    mov     esi, [esp+14038h+var_14020]

    loc_4C10E5:                             ; CODE XREF: sub_4C1000+D7j
    cmp     [esp+14038h+var_14028], eax
    jle     short loc_4C10EF
    mov     [esp+14038h+var_14028], eax

    loc_4C10EF:                             ; CODE XREF: sub_4C1000+E9j
    cmp     [esp+14038h+var_14028], esi
    jnz     short loc_4C1104
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14028h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C1104:                             ; CODE XREF: sub_4C1000+F3j
    mov     eax, [esp+14038h+var_1400C]
    lea     ecx, [esp+14038h+var_14000]
    mov     [esp+14038h+var_14018], ecx

    loc_4C1110:                             ; CODE XREF: sub_4C1000+1E4j
    lea     esi, [eax-1]
    mov     ecx, esi
    mov     [esp+14038h+var_14014], esi
    test    ecx, ecx
    jge     short loc_4C1127
    mov     edx, [esp+14038h+arg_8]
    lea     ecx, [edx-1]

    loc_4C1127:                             ; CODE XREF: sub_4C1000+11Bj
    lea     eax, [eax+eax*2]
    lea     ecx, [ecx+ecx*2]
    mov     edi, [ebx+eax*4+4]
    mov     ebp, [ebx+ecx*4+4]
    lea     eax, [ebx+eax*4]
    lea     edx, [ebx+ecx*4]
    cmp     edi, ebp
    mov     [esp+14038h+var_14010], eax
    mov     [esp+14038h+var_14024], edx
    jge     loc_4C11D2
    mov     ecx, [eax]
    mov     eax, [edx]
    sub     eax, ecx
    mov     esi, ebp
    shl     eax, 10h
    cdq
    sub     esi, edi
    idiv    esi
    mov     edx, [esp+14038h+var_14010]
    shl     ecx, 10h
    add     ecx, 0FFFFh
    mov     ebx, ecx
    mov     ecx, [edx+8]
    shl     ecx, 10h
    mov     [esp+14038h+var_1401C], eax
    mov     eax, [esp+14038h+var_14024]
    mov     eax, [eax+8]
    shl     eax, 10h
    sub     eax, ecx
    cdq
    idiv    esi
    mov     esi, [esp+14038h+var_1401C]
    test    edi, edi
    jge     short loc_4C119B
    mov     edx, esi
    imul    edx, edi
    sub     ebx, edx
    mov     edx, eax
    imul    edx, edi
    sub     ecx, edx
    xor     edi, edi

    loc_4C119B:                             ; CODE XREF: sub_4C1000+189j
    mov     edx, [esp+14038h+var_14004]
    cmp     ebp, edx
    jle     short loc_4C11A5
    mov     ebp, edx

    loc_4C11A5:                             ; CODE XREF: sub_4C1000+1A1j
    cmp     edi, ebp
    jge     short loc_4C11C7
    sub     ebp, edi

    loc_4C11AB:                             ; CODE XREF: sub_4C1000+1C5j
    mov     edx, [esp+14038h+var_14018]
    mov     edi, ebx
    sar     edi, 10h
    mov     [edx], edi
    mov     [edx+18h], ecx
    add     ebx, esi
    add     ecx, eax
    add     edx, 28h
    dec     ebp
    mov     [esp+14038h+var_14018], edx
    jnz     short loc_4C11AB

    loc_4C11C7:                             ; CODE XREF: sub_4C1000+1A7j
    mov     ebx, [esp+14038h+arg_4]
    mov     esi, [esp+14038h+var_14014]

    loc_4C11D2:                             ; CODE XREF: sub_4C1000+145j
    mov     eax, esi
    test    eax, eax
    jge     short loc_4C11E0
    mov     eax, [esp+14038h+arg_8]
    dec     eax

    loc_4C11E0:                             ; CODE XREF: sub_4C1000+1D6j
    cmp     eax, [esp+14038h+var_14008]
    jnz     loc_4C1110
    mov     eax, [esp+14038h+var_1400C]
    lea     ecx, [esp+14038h+var_14000]
    mov     [esp+14038h+var_14018], ecx
    jmp     short loc_4C11FF
    ; ---------------------------------------------------------------------------

    loc_4C11F8:                             ; CODE XREF: sub_4C1000+2C5j
    mov     ebx, [esp+14038h+arg_4]

    loc_4C11FF:                             ; CODE XREF: sub_4C1000+1F6j
    mov     edx, [esp+14038h+arg_8]
    lea     ecx, [eax+1]
    cmp     ecx, edx
    mov     [esp+14038h+var_14010], ecx
    jl      short loc_4C1213
    xor     ecx, ecx

    loc_4C1213:                             ; CODE XREF: sub_4C1000+20Fj
    lea     edx, [eax+eax*2]
    lea     ecx, [ecx+ecx*2]
    mov     edi, [ebx+edx*4+4]
    mov     ebp, [ebx+ecx*4+4]
    lea     eax, [ebx+edx*4]
    lea     edx, [ebx+ecx*4]
    cmp     edi, ebp
    mov     [esp+14038h+var_14014], eax
    mov     [esp+14038h+var_14024], edx
    jge     short loc_4C12B0
    mov     ecx, [eax]
    mov     eax, [edx]
    sub     eax, ecx
    mov     esi, ebp
    shl     eax, 10h
    cdq
    sub     esi, edi
    idiv    esi
    mov     edx, [esp+14038h+var_14014]
    shl     ecx, 10h
    add     ecx, 0FFFFh
    mov     ebx, ecx
    mov     ecx, [edx+8]
    shl     ecx, 10h
    mov     [esp+14038h+var_1401C], eax
    mov     eax, [esp+14038h+var_14024]
    mov     eax, [eax+8]
    shl     eax, 10h
    sub     eax, ecx
    cdq
    idiv    esi
    mov     esi, [esp+14038h+var_1401C]
    test    edi, edi
    jge     short loc_4C1283
    mov     edx, esi
    imul    edx, edi
    sub     ebx, edx
    mov     edx, eax
    imul    edx, edi
    sub     ecx, edx
    xor     edi, edi

    loc_4C1283:                             ; CODE XREF: sub_4C1000+271j
    mov     edx, [esp+14038h+var_14004]
    cmp     ebp, edx
    jle     short loc_4C128D
    mov     ebp, edx

    loc_4C128D:                             ; CODE XREF: sub_4C1000+289j
    cmp     edi, ebp
    jge     short loc_4C12B0
    sub     ebp, edi

    loc_4C1293:                             ; CODE XREF: sub_4C1000+2AEj
    mov     edx, [esp+14038h+var_14018]
    mov     edi, ebx
    sar     edi, 10h
    mov     [edx+4], edi
    mov     [edx+1Ch], ecx
    add     ebx, esi
    add     ecx, eax
    add     edx, 28h
    dec     ebp
    mov     [esp+14038h+var_14018], edx
    jnz     short loc_4C1293

    loc_4C12B0:                             ; CODE XREF: sub_4C1000+231j
                                            ; sub_4C1000+28Fj
    mov     eax, [esp+14038h+var_14010]
    mov     ecx, [esp+14038h+arg_8]
    cmp     eax, ecx
    jl      short loc_4C12C1
    xor     eax, eax

    loc_4C12C1:                             ; CODE XREF: sub_4C1000+2BDj
    cmp     eax, [esp+14038h+var_14008]
    jnz     loc_4C11F8
    mov     esi, [esp+14038h+var_14020]
    mov     ebx, [esp+14038h+var_14028]
    cmp     esi, ebx
    lea     edi, [esp+14038h+var_14000]
    jge     short loc_4C1305
    mov     ebp, [esp+14038h+arg_C]

    loc_4C12E2:                             ; CODE XREF: sub_4C1000+303j
    mov     eax, [edi+4]
    mov     edx, [edi]
    sub     eax, edx
    test    eax, eax
    jle     short loc_4C12FD
    mov     ecx, [esp+14038h+arg_0]
    push    ebp
    push    ecx
    push    edi
    push    esi
    call    sub_4C06E0

    loc_4C12FD:                             ; CODE XREF: sub_4C1000+2EBj
    add     edi, 28h
    inc     esi
    cmp     esi, ebx
    jl      short loc_4C12E2

    loc_4C1305:                             ; CODE XREF: sub_4C1000+2D9j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 14028h
    retn    10h
    sub_4C1000 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1320 proc near                    ; CODE XREF: sub_48C6A0+133p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     ecx, [esp+arg_4]
    push    ebx
    push    ebp
    push    esi
    cmp     ecx, 3
    push    edi
    jge     short loc_4C1336
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C1336:                             ; CODE XREF: sub_4C1320+Bj
    xor     edi, edi
    test    ecx, ecx
    jle     short loc_4C1392
    mov     esi, [esp+10h+arg_0]

    loc_4C1340:                             ; CODE XREF: sub_4C1320+5Bj
    inc     edi
    mov     ebp, [esp+10h+arg_C]
    mov     eax, edi
    cdq
    idiv    ecx
    mov     eax, [esp+10h+arg_0]
    mov     ecx, [esi+4]
    sub     ebp, ecx
    mov     ebx, [eax+edx*8]
    lea     eax, [eax+edx*8]
    mov     edx, [esi]
    sub     ebx, edx
    mov     eax, [eax+4]
    imul    ebx, ebp
    sub     eax, ecx
    mov     ecx, [esp+10h+arg_8]
    sub     ecx, edx
    imul    eax, ecx
    cmp     eax, ebx
    jle     short loc_4C1389
    mov     ecx, [esp+10h+arg_4]
    add     esi, 8
    cmp     edi, ecx
    jl      short loc_4C1340
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C1389:                             ; CODE XREF: sub_4C1320+50j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C1392:                             ; CODE XREF: sub_4C1320+1Aj
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    10h
    sub_4C1320 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C13A0 proc near                    ; CODE XREF: sub_418310+383p
                                            ; sub_418310+74Ep ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    call    sub_4B6220
    mov     ecx, [esp+arg_0]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_4C13B4
    mov     [eax+208h], ecx

    loc_4C13B4:                             ; CODE XREF: sub_4C13A0+Cj
    mov     ecx, [esp+arg_4]
    cmp     ecx, 0FFFFFFFFh
    jz      short locret_4C13C3
    mov     [eax+20Ch], ecx

    locret_4C13C3:                          ; CODE XREF: sub_4C13A0+1Bj
    retn    8
    sub_4C13A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C13D0 proc near                    ; CODE XREF: sub_491200+398p

    arg_0= dword ptr  4

    call    sub_4B6220
    mov     ecx, [esp+arg_0]
    mov     [eax+210h], ecx
    retn    4
    sub_4C13D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C13F0 proc near                    ; CODE XREF: sub_418310+372p
                                            ; sub_418310+742p ...
    call    sub_4B6220
    mov     eax, [eax+210h]
    retn
    sub_4C13F0 endp

    ; ---------------------------------------------------------------------------
    align 8
    call    sub_4B6220
    mov     eax, [eax+208h]
    retn
    ; ---------------------------------------------------------------------------
    align 8
    call    sub_4B6220
    mov     eax, [eax+20Ch]
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1420 proc near                    ; CODE XREF: sub_418310+36Dp
                                            ; sub_418310+73Dp ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jz      short loc_4C1434
    call    sub_4B6220
    mov     [eax+204h], esi

    loc_4C1434:                             ; CODE XREF: sub_4C1420+7j
    pop     esi
    retn    4
    sub_4C1420 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1440 proc near                    ; CODE XREF: sub_476EF0+D8p
                                            ; sub_476EF0+3A9p ...
    call    sub_4B6220
    mov     eax, [eax+204h]
    retn
    sub_4C1440 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1450 proc near                    ; CODE XREF: sub_464060+57p
                                            ; sub_464060+139p ...
    call    sub_4B6220
    mov     eax, dword ptr [eax+UnitDefStruct.nRadarDistance]
    xor     ecx, ecx
    mov     cl, [eax]
    mov     eax, ecx
    retn
    sub_4C1450 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1470 proc near                    ; CODE XREF: sub_476EF0+DEp

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    xor     eax, eax
    mov     al, [ecx]
    retn    4
    sub_4C1470 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1480 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+557p
                                            ; GameUnit_LOS_Unknown1+84Bp ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    esi
    push    edi
    mov     edi, [esp+arg_4]
    xor     eax, eax
    test    edi, edi
    jz      short loc_4C14DC
    mov     esi, [esp+arg_0]
    test    esi, esi
    jz      short loc_4C14DC
    mov     cl, [edi]
    test    cl, cl
    jz      short loc_4C14DC

    loc_4C149A:                             ; CODE XREF: sub_4C1480+5Aj
    cmp     cl, 0Ah
    jz      short loc_4C14DC
    mov     dl, [esi+3]
    mov     byte ptr [esp+arg_4], cl
    cmp     cl, dl
    jb      short loc_4C14D4
    mov     ecx, [esp+arg_4]
    and     edx, 0FFh
    and     ecx, 0FFh
    sub     ecx, edx
    xor     edx, edx
    and     ecx, 0FFFFh
    mov     dx, [esi+ecx*2+4]
    test    edx, edx
    jz      short loc_4C14D4
    xor     ecx, ecx
    mov     cl, [edx+esi]
    add     eax, ecx

    loc_4C14D4:                             ; CODE XREF: sub_4C1480+28j
                                            ; sub_4C1480+4Bj
    mov     cl, [edi+1]
    inc     edi
    test    cl, cl
    jnz     short loc_4C149A

    loc_4C14DC:                             ; CODE XREF: sub_4C1480+Aj
                                            ; sub_4C1480+12j ...
    pop     edi
    pop     esi
    retn    8
    sub_4C1480 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    PrintGUIText proc near                  ; CODE XREF: sub_418310+39Ap
                                            ; sub_418310+77Fp ...

    var_184= dword ptr -184h
    var_180= dword ptr -180h
    var_17C= dword ptr -17Ch
    var_178= dword ptr -178h
    var_174= dword ptr -174h
    var_170= dword ptr -170h
    var_16C= dword ptr -16Ch
    var_15C= dword ptr -15Ch
    var_154= dword ptr -154h
    var_150= dword ptr -150h
    var_12C= byte ptr -12Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 184h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     ebp, [esp+194h+arg_4]
    mov     edx, [eax+204h]
    xor     edi, edi
    mov     [esp+194h+var_184], eax
    test    ebp, ebp
    mov     esi, ebp
    jz      short loc_4C1562
    test    edx, edx
    jz      short loc_4C1562
    mov     al, [ebp+0]
    test    al, al
    jz      short loc_4C1562

    loc_4C1523:                             ; CODE XREF: PrintGUIText+70j
    cmp     al, 0Ah
    jz      short loc_4C1562
    mov     cl, [edx+3]
    mov     byte ptr [esp+194h+var_180], al
    cmp     al, cl
    jb      short loc_4C155A
    mov     eax, [esp+194h+var_180]
    and     ecx, 0FFh
    and     eax, 0FFh
    sub     eax, ecx
    xor     ecx, ecx
    and     eax, 0FFFFh
    mov     cx, [edx+eax*2+4]
    test    ecx, ecx
    jz      short loc_4C155A
    xor     eax, eax
    mov     al, [edx+ecx]
    add     edi, eax

    loc_4C155A:                             ; CODE XREF: PrintGUIText+40j
                                            ; PrintGUIText+61j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4C1523

    loc_4C1562:                             ; CODE XREF: PrintGUIText+26j
                                            ; PrintGUIText+2Aj ...
    mov     eax, [esp+194h+arg_10]
    mov     ebx, edi
    cmp     eax, 0FFFFFFFFh
    jz      loc_4C1629
    cmp     edi, eax
    jle     loc_4C1629
    push    12Bh                            ; size_t
    lea     ecx, [esp+198h+var_12C]
    push    ebp                             ; char *
    push    ecx                             ; char *
    call    _strncpy
    lea     edi, [esp+1A0h+var_12C]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+194h+var_12C]
    mov     [esp+194h+arg_4], edx
    lea     ebp, [esp+ecx+67h]

    loc_4C15AC:                             ; CODE XREF: PrintGUIText+137j
    lea     eax, [esp+194h+var_12C]
    mov     byte ptr [ebp+0], 0
    cmp     ebp, eax
    jz      short loc_4C1629
    mov     ecx, [esp+194h+var_184]
    lea     eax, [esp+194h+var_12C]
    dec     ebp
    xor     edi, edi
    mov     edx, [ecx+204h]
    lea     esi, [esp+194h+var_12C]
    test    eax, eax
    jz      short loc_4C161C
    test    edx, edx
    jz      short loc_4C161C
    mov     al, [esp+194h+var_12C]
    test    al, al
    jz      short loc_4C161C

    loc_4C15DD:                             ; CODE XREF: PrintGUIText+12Aj
    cmp     al, 0Ah
    jz      short loc_4C161C
    mov     cl, [edx+3]
    mov     byte ptr [esp+194h+var_180], al
    cmp     al, cl
    jb      short loc_4C1614
    mov     eax, [esp+194h+var_180]
    and     ecx, 0FFh
    and     eax, 0FFh
    sub     eax, ecx
    xor     ecx, ecx
    and     eax, 0FFFFh
    mov     cx, [edx+eax*2+4]
    test    ecx, ecx
    jz      short loc_4C1614
    xor     eax, eax
    mov     al, [edx+ecx]
    add     edi, eax

    loc_4C1614:                             ; CODE XREF: PrintGUIText+FAj
                                            ; PrintGUIText+11Bj
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4C15DD

    loc_4C161C:                             ; CODE XREF: PrintGUIText+DFj
                                            ; PrintGUIText+E3j ...
    mov     eax, [esp+194h+arg_10]
    mov     ebx, edi
    cmp     edi, eax
    jg      short loc_4C15AC

    loc_4C1629:                             ; CODE XREF: PrintGUIText+7Ej
                                            ; PrintGUIText+86j ...
    mov     esi, [esp+194h+arg_8]
    mov     ebp, [esp+194h+arg_C]
    add     ebx, esi
    mov     [esp+194h+var_17C], esi
    mov     [esp+194h+var_178], ebp
    mov     [esp+194h+var_174], ebx
    call    sub_4B6220
    mov     ecx, [eax+204h]
    mov     edi, [esp+194h+arg_0]
    xor     edx, edx
    mov     dl, [ecx]
    mov     ecx, [esp+194h+var_178]
    add     edx, ecx
    test    edi, edi
    mov     [esp+194h+var_170], edx
    jnz     loc_4C16F3
    lea     eax, [esp+194h+var_15C]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4C174C
    lea     ecx, [esp+194h+var_16C]
    push    ecx
    lea     ecx, [esp+198h+var_15C]
    call    sub_4C6AE0
    lea     edx, [esp+194h+var_16C]
    lea     eax, [esp+194h+var_17C]
    push    edx
    push    eax
    call    sub_4B6750
    test    eax, eax
    jz      short loc_4C16DC
    mov     eax, [esp+194h+var_184]
    mov     ecx, [eax+210h]
    mov     edx, [eax+20Ch]
    push    ecx
    mov     ecx, [eax+208h]
    mov     eax, [eax+204h]
    push    edx
    mov     edx, [esp+19Ch+arg_4]
    push    ecx
    mov     ecx, [esp+1A0h+var_154]
    push    ebp
    push    esi
    push    edx
    mov     edx, [esp+1ACh+var_150]
    push    eax
    push    ecx
    push    edx
    call    sub_4CCF60
    add     esp, 24h

    loc_4C16DC:                             ; CODE XREF: PrintGUIText+1AEj
    lea     eax, [esp+194h+var_15C]
    push    eax
    call    sub_4C5FA0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 184h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4C16F3:                             ; CODE XREF: PrintGUIText+177j
    lea     ecx, [esp+194h+var_16C]
    push    ecx
    mov     ecx, edi
    call    sub_4C6AE0
    lea     edx, [esp+194h+var_16C]
    lea     eax, [esp+194h+var_17C]
    push    edx
    push    eax
    call    sub_4B6750
    test    eax, eax
    jz      short loc_4C174C
    mov     eax, [esp+194h+var_184]
    mov     ecx, [eax+210h]
    mov     edx, [eax+20Ch]
    push    ecx
    mov     ecx, [eax+208h]
    mov     eax, [eax+204h]
    push    edx
    mov     edx, [esp+19Ch+arg_4]
    push    ecx
    mov     ecx, [edi+8]
    push    ebp
    push    esi
    push    edx
    mov     edx, [edi+0Ch]
    push    eax
    push    ecx
    push    edx
    call    sub_4CCF60
    add     esp, 24h

    loc_4C174C:                             ; CODE XREF: PrintGUIText+189j
                                            ; PrintGUIText+220j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 184h
    retn    14h
    PrintGUIText endp

    ; ---------------------------------------------------------------------------
    align 8
    sub     esp, 30h
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     ebp, [esp+44h]
    mov     edx, [eax+204h]
    xor     edi, edi
    mov     esi, ebp
    test    ebp, ebp
    jz      short loc_4C17C7
    test    edx, edx
    jz      short loc_4C17C7
    mov     al, [ebp+0]
    test    al, al
    jz      short loc_4C17C7

    loc_4C1788:                             ; CODE XREF: .text:004C17C5j
    cmp     al, 0Ah
    jz      short loc_4C17C7
    mov     cl, [edx+3]
    mov     [esp+44h], al
    cmp     al, cl
    jb      short loc_4C17BF
    mov     eax, [esp+44h]
    and     ecx, 0FFh
    and     eax, 0FFh
    sub     eax, ecx
    xor     ecx, ecx
    and     eax, 0FFFFh
    mov     cx, [edx+eax*2+4]
    test    ecx, ecx
    jz      short loc_4C17BF
    xor     eax, eax
    mov     al, [edx+ecx]
    add     edi, eax

    loc_4C17BF:                             ; CODE XREF: .text:004C1795j
                                            ; .text:004C17B6j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4C1788

    loc_4C17C7:                             ; CODE XREF: .text:004C177Bj
                                            ; .text:004C177Fj ...
    mov     eax, [esp+40h]
    test    eax, eax
    jnz     short loc_4C180B
    lea     ecx, [esp+0Ch]
    push    ecx
    call    sub_4C5E70
    test    eax, eax
    jz      short loc_4C1820
    mov     eax, [esp+0Ch]
    mov     edx, [esp+48h]
    sub     eax, edi
    push    0FFFFFFFFh
    sar     eax, 1
    push    edx
    push    eax
    lea     ecx, [esp+18h]
    push    ebp
    push    ecx
    call    PrintGUIText
    lea     edx, [esp+0Ch]
    push    edx
    call    sub_4C5FA0
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C180B:                             ; CODE XREF: .text:004C17CDj
    mov     edx, [eax]
    mov     ecx, [esp+48h]
    sub     edx, edi
    push    0FFFFFFFFh
    sar     edx, 1
    push    ecx
    push    edx
    push    ebp
    push    eax
    call    PrintGUIText

    loc_4C1820:                             ; CODE XREF: .text:004C17DBj
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1830 proc near                    ; CODE XREF: .text:0041FF2Dp

    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 30h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     ebp, [esp+40h+arg_4]
    mov     edx, [eax+204h]
    xor     ebx, ebx
    mov     esi, ebp
    test    ebp, ebp
    jz      short loc_4C1898
    test    edx, edx
    jz      short loc_4C1898
    mov     al, [ebp+0]
    test    al, al
    jz      short loc_4C1898

    loc_4C1859:                             ; CODE XREF: sub_4C1830+66j
    cmp     al, 0Ah
    jz      short loc_4C1898
    mov     cl, [edx+3]
    mov     byte ptr [esp+40h+arg_4], al
    cmp     al, cl
    jb      short loc_4C1890
    mov     eax, [esp+40h+arg_4]
    and     ecx, 0FFh
    and     eax, 0FFh
    sub     eax, ecx
    xor     ecx, ecx
    and     eax, 0FFFFh
    mov     cx, [edx+eax*2+4]
    test    ecx, ecx
    jz      short loc_4C1890
    xor     eax, eax
    mov     al, [edx+ecx]
    add     ebx, eax

    loc_4C1890:                             ; CODE XREF: sub_4C1830+36j
                                            ; sub_4C1830+57j
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4C1859

    loc_4C1898:                             ; CODE XREF: sub_4C1830+1Cj
                                            ; sub_4C1830+20j ...
    mov     edi, [esp+40h+arg_0]
    test    edi, edi
    jnz     loc_4C1981
    lea     ecx, [esp+40h+var_30]
    push    ecx
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4C1A2A
    mov     esi, [esp+40h+var_30]
    sub     esi, ebx
    sar     esi, 1
    call    sub_4B6220
    mov     edi, [eax+210h]
    call    sub_4B6220
    mov     ecx, [esp+40h+arg_8]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_4C18DD
    mov     [eax+208h], ecx

    loc_4C18DD:                             ; CODE XREF: sub_4C1830+A5j
    cmp     edi, 0FFFFFFFFh
    jz      short loc_4C18E8
    mov     [eax+20Ch], edi

    loc_4C18E8:                             ; CODE XREF: sub_4C1830+B0j
    mov     edi, [esp+40h+arg_10]
    push    0FFFFFFFFh
    lea     edx, [esi-1]
    push    edi
    push    edx
    lea     eax, [esp+4Ch+var_30]
    push    ebp
    push    eax
    call    PrintGUIText
    push    0FFFFFFFFh
    lea     ecx, [esi+1]
    push    edi
    push    ecx
    lea     edx, [esp+4Ch+var_30]
    push    ebp
    push    edx
    call    PrintGUIText
    lea     eax, [edi-1]
    push    0FFFFFFFFh
    push    eax
    push    esi
    lea     ecx, [esp+4Ch+var_30]
    push    ebp
    push    ecx
    call    PrintGUIText
    lea     edx, [edi+1]
    push    0FFFFFFFFh
    push    edx
    push    esi
    lea     eax, [esp+4Ch+var_30]
    push    ebp
    push    eax
    call    PrintGUIText
    call    sub_4B6220
    mov     ebx, [eax+210h]
    call    sub_4B6220
    mov     ecx, [esp+40h+arg_C]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_4C1953
    mov     [eax+208h], ecx

    loc_4C1953:                             ; CODE XREF: sub_4C1830+11Bj
    cmp     ebx, 0FFFFFFFFh
    jz      short loc_4C195E
    mov     [eax+20Ch], ebx

    loc_4C195E:                             ; CODE XREF: sub_4C1830+126j
    push    0FFFFFFFFh
    push    edi
    push    esi
    lea     ecx, [esp+4Ch+var_30]
    push    ebp
    push    ecx
    call    PrintGUIText
    lea     edx, [esp+40h+var_30]
    push    edx
    call    sub_4C5FA0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4C1981:                             ; CODE XREF: sub_4C1830+6Ej
    mov     esi, [edi]
    sub     esi, ebx
    sar     esi, 1
    call    sub_4B6220
    mov     ebx, [eax+210h]
    call    sub_4B6220
    mov     ecx, [esp+40h+arg_8]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_4C19A6
    mov     [eax+208h], ecx

    loc_4C19A6:                             ; CODE XREF: sub_4C1830+16Ej
    cmp     ebx, 0FFFFFFFFh
    jz      short loc_4C19B1
    mov     [eax+20Ch], ebx

    loc_4C19B1:                             ; CODE XREF: sub_4C1830+179j
    mov     ebx, [esp+40h+arg_10]
    push    0FFFFFFFFh
    lea     eax, [esi-1]
    push    ebx
    push    eax
    push    ebp
    push    edi
    call    PrintGUIText
    push    0FFFFFFFFh
    lea     ecx, [esi+1]
    push    ebx
    push    ecx
    push    ebp
    push    edi
    call    PrintGUIText
    lea     edx, [ebx-1]
    push    0FFFFFFFFh
    push    edx
    push    esi
    push    ebp
    push    edi
    call    PrintGUIText
    lea     eax, [ebx+1]
    push    0FFFFFFFFh
    push    eax
    push    esi
    push    ebp
    push    edi
    call    PrintGUIText
    call    sub_4B6220
    mov     ecx, [eax+210h]
    mov     [esp+40h+arg_8], ecx
    call    sub_4B6220
    mov     ecx, [esp+40h+arg_C]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_4C1A10
    mov     [eax+208h], ecx

    loc_4C1A10:                             ; CODE XREF: sub_4C1830+1D8j
    mov     ecx, [esp+40h+arg_8]
    cmp     ecx, 0FFFFFFFFh
    jz      short loc_4C1A1F
    mov     [eax+20Ch], ecx

    loc_4C1A1F:                             ; CODE XREF: sub_4C1830+1E7j
    push    0FFFFFFFFh
    push    ebx
    push    esi
    push    ebp
    push    edi
    call    PrintGUIText

    loc_4C1A2A:                             ; CODE XREF: sub_4C1830+80j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    14h
    sub_4C1830 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1A40 proc near                    ; CODE XREF: .text:00496ADEp
                                            ; .text:00496B62p ...
    call    sub_4B6220
    xor     ecx, ecx
    mov     [eax+16Eh], ecx
    mov     [eax+172h], ecx
    retn
    sub_4C1A40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1A60 proc near                    ; CODE XREF: sub_4B5980+D2p

    arg_0= dword ptr  4

    call    sub_4B6220
    mov     ecx, [esp+arg_0]
    cmp     ecx, 1Eh
    jg      short loc_4C1A76
    mov     [eax+0F2h], ecx
    jmp     short loc_4C1A80
    ; ---------------------------------------------------------------------------

    loc_4C1A76:                             ; CODE XREF: sub_4C1A60+Cj
    mov     dword ptr [eax+0F2h], 1Eh

    loc_4C1A80:                             ; CODE XREF: sub_4C1A60+14j
    call    sub_4B6220
    xor     ecx, ecx
    mov     [eax+16Eh], ecx
    mov     [eax+172h], ecx
    retn    4
    sub_4C1A60 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_16. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1AB0 proc near                    ; CODE XREF: .text:0041FE73p
                                            ; .text:0041FFD9p ...
    push    esi
    call    sub_4B6220
    mov     ecx, [eax+172h]
    mov     edx, [eax+16Eh]
    cmp     edx, ecx
    jnz     short loc_4C1ACC
    xor     edx, edx
    mov     eax, edx
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4C1ACC:                             ; CODE XREF: sub_4C1AB0+14j
    mov     esi, [eax+0F2h]
    mov     edx, [eax+ecx*4+0F6h]
    inc     ecx
    cmp     ecx, esi
    mov     [eax+172h], ecx
    jnz     short loc_4C1AEE
    mov     dword ptr [eax+172h], 0

    loc_4C1AEE:                             ; CODE XREF: sub_4C1AB0+32j
    mov     eax, edx
    pop     esi
    retn
    sub_4C1AB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1B00 proc near                    ; CODE XREF: sub_499890+8p
                                            ; sub_4A9FD0+49p ...
    call    sub_4B6220
    mov     ecx, [eax+172h]
    mov     edx, [eax+16Eh]
    cmp     edx, ecx
    jnz     short loc_4C1B18
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_4C1B18:                             ; CODE XREF: sub_4C1B00+13j
    mov     eax, [eax+ecx*4+0F6h]
    retn
    sub_4C1B00 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1B20 proc near                    ; CODE XREF: sub_4B5CC0+12Ap
                                            ; sub_4C1D50+26Ep ...

    arg_0= dword ptr  8

    push    esi
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      short loc_4C1B70
    mov     eax, [esp+arg_0]
    mov     [ecx+esi*4+0F2h], eax
    mov     esi, [ecx+16Eh]
    mov     edx, [ecx+0F2h]
    inc     esi
    mov     eax, esi
    mov     [ecx+16Eh], esi
    cmp     eax, edx
    jnz     short loc_4C1B70
    mov     dword ptr [ecx+16Eh], 0

    loc_4C1B70:                             ; CODE XREF: sub_4C1B20+20j
                                            ; sub_4C1B20+44j
    pop     esi
    retn    4
    sub_4C1B20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1B80 proc near                    ; CODE XREF: sub_41AA00+1FFp
                                            ; sub_41CE90+EAp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    add     eax, 0FFFFFFE0h
    cmp     eax, 0DBh
    ja      loc_4C1C41
    xor     ecx, ecx
    mov     cl, ds:byte_4C1C6C[eax]
    jmp     ds:off_4C1C48[ecx*4]

    loc_4C1BA1:                             ; DATA XREF: .text:004C1C64o
    push    12h                             ; vKey
    call    ds:GetAsyncKeyState             ; Determine whether a key is up or down
    and     al, 0FEh
    neg     ax
    sbb     eax, eax
    neg     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C1BB5:                             ; CODE XREF: sub_4C1B80+1Aj
                                            ; DATA XREF: .text:004C1C5Co
    push    10h                             ; vKey
    call    ds:GetAsyncKeyState             ; Determine whether a key is up or down
    and     al, 0FEh
    neg     ax
    sbb     eax, eax
    neg     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C1BC9:                             ; CODE XREF: sub_4C1B80+1Aj
                                            ; DATA XREF: .text:004C1C60o
    push    11h                             ; vKey
    call    ds:GetAsyncKeyState             ; Determine whether a key is up or down
    and     al, 0FEh
    neg     ax
    sbb     eax, eax
    neg     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C1BDD:                             ; CODE XREF: sub_4C1B80+1Aj
                                            ; DATA XREF: .text:004C1C50o
    push    26h                             ; vKey
    call    ds:GetAsyncKeyState             ; Determine whether a key is up or down
    and     al, 0FEh
    neg     ax
    sbb     eax, eax
    neg     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C1BF1:                             ; CODE XREF: sub_4C1B80+1Aj
                                            ; DATA XREF: .text:004C1C58o
    push    28h                             ; vKey
    call    ds:GetAsyncKeyState             ; Determine whether a key is up or down
    and     al, 0FEh
    neg     ax
    sbb     eax, eax
    neg     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C1C05:                             ; CODE XREF: sub_4C1B80+1Aj
                                            ; DATA XREF: .text:004C1C4Co
    push    25h                             ; vKey
    call    ds:GetAsyncKeyState             ; Determine whether a key is up or down
    and     al, 0FEh
    neg     ax
    sbb     eax, eax
    neg     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C1C19:                             ; CODE XREF: sub_4C1B80+1Aj
                                            ; DATA XREF: .text:004C1C54o
    push    27h                             ; vKey
    call    ds:GetAsyncKeyState             ; Determine whether a key is up or down
    and     al, 0FEh
    neg     ax
    sbb     eax, eax
    neg     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C1C2D:                             ; CODE XREF: sub_4C1B80+1Aj
                                            ; DATA XREF: .text:004C1C48o
    push    20h                             ; vKey
    call    ds:GetAsyncKeyState             ; Determine whether a key is up or down
    and     al, 0FEh
    neg     ax
    sbb     eax, eax
    neg     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C1C41:                             ; CODE XREF: sub_4C1B80+Cj
                                            ; sub_4C1B80+1Aj
                                            ; DATA XREF: ...
    xor     eax, eax
    retn    4
    sub_4C1B80 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4C1C48 dd offset loc_4C1C2D         ; DATA XREF: sub_4C1B80+1Ar
    dd offset loc_4C1C05
    dd offset loc_4C1BDD
    dd offset loc_4C1C19
    dd offset loc_4C1BF1
    dd offset loc_4C1BB5
    dd offset loc_4C1BC9
    dd offset loc_4C1BA1
    dd offset loc_4C1C41
    byte_4C1C6C db 0                        ; DATA XREF: sub_4C1B80+14r
    ; ---------------------------------------------------------------------------
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [eax], cl
    or      [ecx], al
    add     al, [ebx]
    add     al, 8
    add     eax, 90900706h
    nop
    nop
    nop
    nop
    nop
    nop

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C1D50 proc near                    ; CODE XREF: sub_4B5CC0+CEp
                                            ; sub_4B5CC0+103p

    var_D8= byte ptr -0D8h
    var_C2= byte ptr -0C2h
    var_8= byte ptr -8
    var_7= byte ptr -7
    var_6= byte ptr -6
    var_5= byte ptr -5
    var_4= byte ptr -4
    var_3= byte ptr -3
    var_2= byte ptr -2
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 8
    push    esi
    push    11h                             ; vKey
    call    ds:GetAsyncKeyState             ; Determine whether a key is up or down
    and     al, 0FEh
    mov     ecx, [esp+0Ch+arg_0]
    neg     ax
    sbb     eax, eax
    lea     esi, [ecx-13h]
    neg     eax
    cmp     esi, 68h
    ja      loc_4C20EA
    xor     edx, edx
    mov     dl, ds:byte_4C2230[esi]
    jmp     ds:off_4C21D0[edx*4]

    loc_4C1D84:                             ; DATA XREF: .text:004C21E8o
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0F5h
    jmp     loc_4C1F8B
    ; ---------------------------------------------------------------------------

    loc_4C1DB9:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21F0o
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0F7h
    jmp     loc_4C1F8B
    ; ---------------------------------------------------------------------------

    loc_4C1DEE:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21E4o
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0F4h
    jmp     loc_4C1F8B
    ; ---------------------------------------------------------------------------

    loc_4C1E23:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21ECo
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0F6h
    jmp     loc_4C1F8B
    ; ---------------------------------------------------------------------------

    loc_4C1E58:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21F4o
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0EEh
    jmp     loc_4C1F8B
    ; ---------------------------------------------------------------------------

    loc_4C1E8D:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21F8o
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0EFh
    jmp     loc_4C1F8B
    ; ---------------------------------------------------------------------------

    loc_4C1EC2:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21E0o
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0F0h
    jmp     loc_4C1F8B
    ; ---------------------------------------------------------------------------

    loc_4C1EF7:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21DCo
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0F1h
    jmp     short loc_4C1F8B
    ; ---------------------------------------------------------------------------

    loc_4C1F29:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21D4o
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0F2h
    jmp     short loc_4C1F8B
    ; ---------------------------------------------------------------------------

    loc_4C1F5B:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21D8o
    call    sub_4B6220
    mov     ecx, eax
    mov     eax, [ecx+16Eh]
    lea     esi, [eax+1]
    mov     eax, esi
    cdq
    idiv    dword ptr [ecx+0F2h]
    cmp     edx, [ecx+172h]
    jz      loc_4C21C7
    mov     dword ptr [ecx+esi*4+0F2h], 0F3h

    loc_4C1F8B:                             ; CODE XREF: sub_4C1D50+64j
                                            ; sub_4C1D50+99j ...
    mov     esi, [ecx+16Eh]
    mov     edx, [ecx+0F2h]
    inc     esi
    mov     eax, esi
    mov     [ecx+16Eh], esi
    cmp     eax, edx
    jnz     loc_4C21C7
    mov     dword ptr [ecx+16Eh], 0
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C1FB9:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21D0o
    push    0F8h
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C1FCA:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C21FCo
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0E2h
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C1FE2:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C2200o
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0E3h
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C1FFA:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C2204o
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0E4h
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C2012:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C2208o
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0E5h
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C202A:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C220Co
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0E6h
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C2042:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C2210o
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0E7h
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C205A:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C2214o
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0E8h
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C2072:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C2218o
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0E9h
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C208A:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C221Co
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0EAh
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C20A2:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C2220o
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0EBh
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C20BA:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C2224o
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0ECh
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C20D2:                             ; CODE XREF: sub_4C1D50+2Dj
                                            ; DATA XREF: .text:004C2228o
    neg     eax
    sbb     eax, eax
    and     al, 0ECh
    add     eax, 0EDh
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C20EA:                             ; CODE XREF: sub_4C1D50+1Fj
                                            ; sub_4C1D50+2Dj
                                            ; DATA XREF: ...
    mov     edx, [esp+0Ch+arg_4]
    test    edx, edx
    jnz     short loc_4C20FA
    test    eax, eax
    jz      loc_4C21C7

    loc_4C20FA:                             ; CODE XREF: sub_4C1D50+3A0j
    cmp     ecx, 30h
    jl      short loc_4C211F
    cmp     ecx, 39h
    jg      short loc_4C211F
    test    eax, eax
    jz      loc_4C21C1
    add     ecx, 94h
    push    ecx
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C211F:                             ; CODE XREF: sub_4C1D50+3ADj
                                            ; sub_4C1D50+3B2j
    cmp     ecx, 41h
    jl      short loc_4C214D
    cmp     ecx, 5Ah
    jg      short loc_4C214D
    test    eax, eax
    jz      short loc_4C213D
    add     ecx, 69h
    push    ecx
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C213D:                             ; CODE XREF: sub_4C1D50+3DBj
    add     ecx, 20h
    push    ecx
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C214D:                             ; CODE XREF: sub_4C1D50+3D2j
                                            ; sub_4C1D50+3D7j
    cmp     ecx, 0BAh
    jl      short loc_4C2195
    cmp     ecx, 0C0h
    jg      short loc_4C2195
    mov     [esp+0Ch+var_8], 3Bh
    mov     [esp+0Ch+var_7], 3Dh
    mov     [esp+0Ch+var_6], 2Ch
    mov     [esp+0Ch+var_5], 2Dh
    mov     [esp+0Ch+var_4], 2Eh
    mov     [esp+0Ch+var_3], 2Fh
    mov     [esp+0Ch+var_2], 60h
    movsx   eax, [esp+ecx+0Ch+var_C2]
    push    eax
    call    sub_4C1B20
    pop     esi
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C2195:                             ; CODE XREF: sub_4C1D50+403j
                                            ; sub_4C1D50+40Bj
    cmp     ecx, 0DBh
    jl      short loc_4C21C7
    cmp     ecx, 0DEh
    jg      short loc_4C21C7
    mov     byte ptr [esp+0Ch+arg_0], 5Bh
    mov     byte ptr [esp+0Ch+arg_0+1], 5Ch
    mov     byte ptr [esp+0Ch+arg_0+2], 5Dh
    mov     byte ptr [esp+0Ch+arg_0+3], 27h
    movsx   ecx, byte ptr [esp+ecx-0CBh]

    loc_4C21C1:                             ; CODE XREF: sub_4C1D50+3B6j
    push    ecx
    call    sub_4C1B20

    loc_4C21C7:                             ; CODE XREF: sub_4C1D50+53j
                                            ; sub_4C1D50+88j ...
    pop     esi
    add     esp, 8
    retn    8
    sub_4C1D50 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4C21D0 dd offset loc_4C1FB9         ; DATA XREF: sub_4C1D50+2Dr
    dd offset loc_4C1F29
    dd offset loc_4C1F5B
    dd offset loc_4C1EF7
    dd offset loc_4C1EC2
    dd offset loc_4C1DEE
    dd offset loc_4C1D84
    dd offset loc_4C1E23
    dd offset loc_4C1DB9
    dd offset loc_4C1E58
    dd offset loc_4C1E8D
    dd offset loc_4C1FCA
    dd offset loc_4C1FE2
    dd offset loc_4C1FFA
    dd offset loc_4C2012
    dd offset loc_4C202A
    dd offset loc_4C2042
    dd offset loc_4C205A
    dd offset loc_4C2072
    dd offset loc_4C208A
    dd offset loc_4C20A2
    dd offset loc_4C20BA
    dd offset loc_4C20D2
    dd offset loc_4C20EA
    byte_4C2230 db 0                        ; DATA XREF: sub_4C1D50+27r
    ; ---------------------------------------------------------------------------
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    add     [edx], eax
    add     eax, ds:17080706h[eax]
    pop     ss
    pop     ss
    pop     ss
    or      [edx], ecx
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    pop     ss
    or      ecx, ds:11100F0Eh[ecx]
    adc     dl, [ebx]
    adc     al, 15h
    push    ss
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    mov     eax, hHandle
    mov     Target, 0
    test    eax, eax
    jz      short loc_4C22BB
    push    eax
    call    ds:ResetEvent
    retn
    ; ---------------------------------------------------------------------------

    loc_4C22BB:                             ; CODE XREF: .text:004C22B1j
    push    0
    push    0
    push    0
    push    0
    call    ds:CreateEventA
    mov     hHandle, eax
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C22D0 proc near                    ; CODE XREF: sub_41EC50+212p
                                            ; sub_41EC50+33Fp ...

    arg_0= dword ptr  4

    call    sub_4B6220
    mov     ecx, [esp+arg_0]
    mov     [eax+1D2h], ecx
    retn    4
    sub_4C22D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C22F0(int X,int Y)
    sub_4C22F0 proc near                    ; CODE XREF: sub_41CC60+A8p
                                            ; .text:0041CD3Bp ...

    X= dword ptr  4
    Y= dword ptr  8

    mov     eax, [esp+Y]
    mov     ecx, [esp+X]
    push    eax                             ; Y
    push    ecx                             ; X
    call    ds:SetCursorPos
    retn    8
    sub_4C22F0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    lea     eax, [esp+0]
    push    eax
    call    ds:GetCursorPos
    mov     ecx, [esp+0Ch]
    mov     edx, [esp+0]
    mov     eax, [esp+10h]
    mov     [ecx], edx
    mov     ecx, [esp+4]
    mov     [eax], ecx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2340 proc near                    ; CODE XREF: sub_41CE90+35p
                                            ; .text:0041FE6Ep ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    call    sub_4B6220
    mov     edi, [esp+arg_0]
    lea     esi, [eax+196h]
    mov     ecx, 6
    rep movsd
    pop     edi
    pop     esi
    retn    4
    sub_4C2340 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2360 proc near                    ; CODE XREF: sub_4B5980+108p
                                            ; sub_4B5CC0+1E4p

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    call    sub_4B6220
    mov     esi, [esp+arg_0]
    lea     edi, [eax+196h]
    mov     ecx, 6
    rep movsd
    pop     edi
    pop     esi
    retn    4
    sub_4C2360 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 18h
    push    ebx
    call    sub_4B6220
    mov     ebx, eax
    cmp     dword ptr [ebx+1CEh], 1
    jz      short loc_4C23D0
    mov     eax, [ebx+1AEh]
    test    eax, eax
    jg      short loc_4C23D0
    push    edi
    push    esi
    call    sub_4B6220
    mov     edx, [ebx+1B2h]
    lea     esi, [eax+196h]
    mov     ecx, 6
    lea     edi, [esp+0Ch]
    rep movsd
    mov     eax, [esp+10h]
    mov     ecx, [esp+0Ch]
    push    eax
    push    ecx
    push    edx
    push    0
    call    sub_4B7F90
    pop     esi
    pop     edi

    loc_4C23D0:                             ; CODE XREF: .text:004C2392j
                                            ; .text:004C239Cj
    pop     ebx
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 40h
    push    esi
    mov     esi, [esp+48h]
    push    edi
    mov     eax, [esi+1D2h]
    test    eax, eax
    jz      short loc_4C2459
    mov     edi, [esi+1BEh]
    lea     eax, [esp+18h]
    push    eax
    call    sub_4C5FF0
    test    eax, eax
    jz      short loc_4C2459
    mov     ecx, [esi+1BAh]
    mov     edx, [esi+1B6h]
    push    ecx
    push    edx
    lea     eax, [esp+20h]
    push    edi
    push    eax
    call    sub_4CBBE0
    mov     eax, [esi+1B6h]
    mov     ecx, [edi]
    mov     esi, [esi+1BAh]
    mov     [esp+18h], eax
    add     esp, 10h
    add     eax, ecx
    mov     ecx, [edi+4]
    mov     [esp+10h], eax
    lea     edx, [esp+8]
    push    0
    lea     eax, [esp+1Ch]
    add     ecx, esi
    push    edx
    push    eax
    mov     [esp+18h], esi
    mov     [esp+20h], ecx
    call    sub_4C60D0

    loc_4C2459:                             ; CODE XREF: .text:004C23F1j
                                            ; .text:004C2405j
    pop     edi
    pop     esi
    add     esp, 40h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2470 proc near                    ; CODE XREF: sub_41CC60+2Ap
                                            ; .text:0042055Bp ...
    call    sub_4B6220
    cmp     dword ptr [eax+1CEh], 1
    jz      short locret_4C24AD
    mov     ecx, [eax+1AEh]
    test    ecx, ecx
    lea     edx, [ecx+1]
    mov     [eax+1AEh], edx
    jnz     short locret_4C24AD
    mov     ecx, [eax+1BAh]
    mov     edx, [eax+1B6h]
    mov     eax, [eax+1BEh]
    push    ecx
    push    edx
    push    eax
    push    0
    call    sub_4C6B70

    locret_4C24AD:                          ; CODE XREF: sub_4C2470+Cj
                                            ; sub_4C2470+1Fj
    retn
    sub_4C2470 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 48h
    push    esi
    mov     esi, [esp+50h]
    mov     eax, [esi+1D2h]
    test    eax, eax
    jz      loc_4C25D4
    lea     eax, [esp+1Ch]
    push    eax
    call    sub_4C5FF0
    test    eax, eax
    jz      loc_4C25D4
    lea     ecx, [esp+4]
    push    edi
    push    ecx
    call    ds:GetCursorPos
    mov     edx, [esi+1B2h]
    mov     eax, [esp+8]
    mov     ecx, [esp+0Ch]
    mov     [esi+196h], eax
    mov     [esi+19Ah], ecx
    movsx   edi, word ptr [edx+4]
    sub     eax, edi
    mov     [esi+1B6h], eax
    movsx   eax, word ptr [edx+6]
    sub     ecx, eax
    mov     [esi+1BAh], ecx
    xor     ecx, ecx
    mov     cx, [edx]
    mov     edx, [esi+1BEh]
    mov     [edx], ecx
    mov     eax, [esi+1B2h]
    mov     edx, [esi+1BEh]
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     [edx+4], ecx
    mov     eax, [esi+1B2h]
    mov     edx, [esi+1BEh]
    xor     ecx, ecx
    mov     cx, [eax]
    mov     [edx+8], ecx
    mov     eax, [esi+1BAh]
    mov     ecx, [esi+1B6h]
    lea     edx, [esp+20h]
    neg     eax
    neg     ecx
    push    eax
    mov     eax, [esi+1BEh]
    push    ecx
    push    edx
    push    eax
    call    sub_4CBBE0
    mov     ecx, [esi+19Ah]
    mov     edx, [esi+196h]
    mov     eax, [esi+1B2h]
    add     esp, 10h
    push    ecx
    push    edx
    lea     ecx, [esp+28h]
    push    eax
    push    ecx
    call    sub_4B7F90
    mov     eax, [esi+1B6h]
    mov     ecx, [esi+1BAh]
    mov     esi, [esi+1B2h]
    xor     edx, edx
    mov     [esp+10h], eax
    mov     [esp+14h], ecx
    mov     dx, [esi]
    push    0
    add     eax, edx
    lea     edx, [esp+24h]
    mov     [esp+1Ch], eax
    xor     eax, eax
    mov     ax, [esi+2]
    add     eax, ecx
    lea     ecx, [esp+14h]
    push    ecx
    push    edx
    mov     [esp+28h], eax
    call    sub_4C60D0
    pop     edi

    loc_4C25D4:                             ; CODE XREF: .text:004C24C0j
                                            ; .text:004C24D2j
    pop     esi
    add     esp, 48h
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C25E0 proc near                    ; CODE XREF: .text:004C2A0Dp

    Point= tagPOINT ptr -58h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    arg_0= dword ptr  4

    sub     esp, 58h
    push    esi
    mov     esi, [esp+5Ch+arg_0]
    mov     eax, [esi+1D2h]
    test    eax, eax
    jz      loc_4C2860
    lea     eax, [esp+5Ch+var_30]
    push    eax
    call    sub_4C5FF0
    test    eax, eax
    jz      loc_4C2860
    push    edi
    push    ebp
    lea     ecx, [esp+64h+Point]
    push    ebx
    push    ecx                             ; lpPoint
    call    ds:GetCursorPos
    mov     edi, [esp+68h+Point.x]
    mov     ebx, [esp+68h+Point.y]
    mov     eax, [esi+1B2h]
    mov     [esi+196h], edi
    mov     [esi+19Ah], ebx
    movsx   edx, word ptr [eax+4]
    movsx   ecx, word ptr [eax+6]
    sub     edi, edx
    xor     edx, edx
    mov     dx, [eax]
    mov     eax, [esi+1C2h]
    sub     ebx, ecx
    mov     [eax], edx
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1C2h]
    xor     edx, edx
    mov     dx, [ecx+2]
    mov     [eax+4], edx
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1C2h]
    xor     edx, edx
    mov     dx, [ecx]
    mov     [eax+8], edx
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1C6h]
    xor     edx, edx
    mov     dx, [ecx]
    mov     [eax], edx
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1C6h]
    xor     edx, edx
    mov     dx, [ecx+2]
    mov     [eax+4], edx
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1C6h]
    xor     edx, edx
    mov     dx, [ecx]
    mov     ecx, ebx
    mov     [eax+8], edx
    mov     edx, edi
    neg     ecx
    neg     edx
    push    ecx
    mov     ecx, [esi+1C2h]
    lea     eax, [esp+6Ch+var_30]
    push    edx
    push    eax
    push    ecx
    call    sub_4CBBE0
    mov     edx, [esi+1BAh]
    mov     eax, [esi+1B6h]
    mov     ecx, [esi+1BEh]
    add     esp, 10h
    sub     edx, ebx
    sub     eax, edi
    push    edx
    mov     edx, [esi+1C2h]
    push    eax
    push    ecx
    push    edx
    call    sub_4CBBE0
    mov     eax, [esi+1C2h]
    mov     ecx, [esi+1C6h]
    add     esp, 10h
    push    0
    push    0
    push    eax
    push    ecx
    call    sub_4CBBE0
    mov     edx, [esi+1C6h]
    add     esp, 10h
    push    edx
    call    sub_4C69C0
    mov     eax, [esi+1B2h]
    movsx   ecx, word ptr [eax+6]
    movsx   edx, word ptr [eax+4]
    push    ecx
    push    edx
    push    eax
    mov     eax, [esi+1C6h]
    push    eax
    call    sub_4B7F90
    mov     ebp, [esi+1BAh]
    mov     ecx, ebx
    mov     eax, [esi+1C6h]
    sub     ecx, ebp
    push    ecx
    mov     ecx, [esi+1B6h]
    mov     edx, edi
    sub     edx, ecx
    mov     ecx, [esi+1BEh]
    push    edx
    push    eax
    push    ecx
    call    sub_4CBBE0
    mov     edx, [esi+1B6h]
    mov     ebp, [esi+1BAh]
    mov     ecx, [esi+1BEh]
    mov     eax, edx
    mov     [esp+78h+var_40], eax
    mov     [esp+78h+var_3C], ebp
    add     eax, [ecx]
    add     esp, 10h
    mov     [esp+68h+var_38], eax
    mov     eax, [ecx+4]
    add     eax, ebp
    xor     ebp, ebp
    mov     [esp+68h+var_34], eax
    mov     eax, [esi+1B2h]
    mov     [esp+68h+var_50], edi
    mov     [esp+68h+var_4C], ebx
    mov     bp, [eax]
    mov     eax, edi
    add     eax, ebp
    xor     ebp, ebp
    mov     [esp+68h+var_48], eax
    mov     eax, [esi+1B2h]
    mov     bp, [eax+2]
    mov     eax, [esi+1BAh]
    push    eax
    push    edx
    push    ecx
    lea     ecx, [esp+74h+var_30]
    add     ebp, ebx
    push    ecx
    mov     [esp+78h+var_44], ebp
    call    sub_4CBBE0
    mov     edx, [esi+1C6h]
    add     esp, 10h
    lea     eax, [esp+68h+var_30]
    push    ebx
    push    edi
    push    edx
    push    eax
    call    sub_4CBBE0
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1BEh]
    xor     edx, edx
    add     esp, 10h
    mov     dx, [ecx]
    mov     [eax], edx
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1BEh]
    xor     edx, edx
    mov     dx, [ecx+2]
    push    0
    mov     [eax+4], edx
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1BEh]
    xor     edx, edx
    mov     dx, [ecx]
    push    0
    mov     [eax+8], edx
    mov     ecx, [esi+1C2h]
    mov     edx, [esi+1BEh]
    push    ecx
    push    edx
    call    sub_4CBBE0
    add     esp, 10h
    lea     eax, [esp+68h+var_50]
    lea     ecx, [esp+68h+var_40]
    lea     edx, [esp+68h+var_30]
    push    eax
    push    ecx
    push    edx
    mov     [esi+1B6h], edi
    mov     [esi+1BAh], ebx
    call    sub_4C60D0
    pop     ebx
    pop     ebp
    pop     edi

    loc_4C2860:                             ; CODE XREF: sub_4C25E0+10j
                                            ; sub_4C25E0+22j
    pop     esi
    add     esp, 58h
    retn    4
    sub_4C25E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2870 proc near                    ; CODE XREF: .text:0041CD40j
                                            ; sub_41CD50+12Ep ...

    Point= tagPOINT ptr -20h
    var_18= dword ptr -18h
    var_14= dword ptr -14h

    sub     esp, 20h
    push    ebx
    push    esi
    push    edi
    call    sub_4B6220
    mov     esi, eax
    mov     edi, 1
    cmp     [esi+1CEh], edi
    jz      loc_4C2983
    mov     edx, [esi+1AEh]
    dec     edx
    mov     eax, edx
    mov     [esi+1AEh], edx
    test    eax, eax
    jg      loc_4C2983
    lea     eax, [esp+2Ch+Point]
    push    eax                             ; lpPoint
    call    ds:GetCursorPos
    mov     eax, [esi+1B2h]
    mov     ecx, [esp+2Ch+Point.x]
    mov     edx, [esp+2Ch+Point.y]
    test    eax, eax
    mov     [esi+196h], ecx
    mov     [esi+19Ah], edx
    jz      short loc_4C291C
    movsx   ebx, word ptr [eax+4]
    sub     ecx, ebx
    mov     [esi+1B6h], ecx
    movsx   ecx, word ptr [eax+6]
    sub     edx, ecx
    mov     [esi+1BAh], edx
    xor     edx, edx
    mov     dx, [eax]
    mov     eax, [esi+1BEh]
    mov     [eax], edx
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1BEh]
    xor     edx, edx
    mov     dx, [ecx+2]
    mov     [eax+4], edx
    mov     ecx, [esi+1B2h]
    mov     eax, [esi+1BEh]
    xor     edx, edx
    mov     dx, [ecx]
    mov     [eax+8], edx

    loc_4C291C:                             ; CODE XREF: sub_4C2870+5Cj
    mov     ecx, [esi+1BAh]
    mov     edx, [esi+1B6h]
    mov     eax, [esi+1BEh]
    neg     ecx
    neg     edx
    push    ecx
    push    edx
    push    0
    push    eax
    call    sub_4C6B70
    call    sub_4B6220
    mov     ebx, eax
    cmp     [ebx+1CEh], edi
    jz      short loc_4C2983
    mov     eax, [ebx+1AEh]
    test    eax, eax
    jg      short loc_4C2983
    call    sub_4B6220
    lea     esi, [eax+196h]
    mov     eax, [ebx+1B2h]
    mov     ecx, 6
    lea     edi, [esp+2Ch+var_18]
    rep movsd
    mov     ecx, [esp+2Ch+var_14]
    mov     edx, [esp+2Ch+var_18]
    push    ecx
    push    edx
    push    eax
    push    0
    call    sub_4B7F90

    loc_4C2983:                             ; CODE XREF: sub_4C2870+18j
                                            ; sub_4C2870+2Fj ...
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 20h
    retn
    sub_4C2870 endp

    ; ---------------------------------------------------------------------------
    align 8

    loc_4C2990:                             ; DATA XREF: .text:004C2A8Bo
                                            ; sub_4C2BD0+B6o
    push    2
    call    ds:GetCurrentThread
    push    eax
    call    ds:SetThreadPriority
    mov     eax, [esp+4]
    mov     ecx, [eax+1D6h]
    test    ecx, ecx
    jnz     loc_4C2A66
    push    edi
    push    esi
    push    ebp
    mov     ebp, ds:__imp_GetTickCount
    push    ebx
    mov     ebx, ds:InterlockedExchange

    loc_4C29C1:                             ; CODE XREF: .text:004C2A5Cj
    call    ebp ; __imp_GetTickCount
    mov     esi, eax
    add     esi, 21h

    loc_4C29C8:                             ; CODE XREF: .text:004C29F0j
    mov     edi, 4D4F5553h
    push    edi
    push    offset Target
    call    ebx ; InterlockedExchange
    test    eax, eax
    jz      short loc_4C29F2
    cmp     dword_52A4EC, edi
    jz      short loc_4C29FC
    mov     ecx, hHandle
    push    0FFFFFFFFh
    push    ecx
    call    ds:WaitForSingleObject
    jmp     short loc_4C29C8
    ; ---------------------------------------------------------------------------

    loc_4C29F2:                             ; CODE XREF: .text:004C29D7j
    mov     dword_52A4EC, edi
    xor     edi, edi
    jmp     short loc_4C29FE
    ; ---------------------------------------------------------------------------

    loc_4C29FC:                             ; CODE XREF: .text:004C29DFj
    mov     edi, eax

    loc_4C29FE:                             ; CODE XREF: .text:004C29FAj
    mov     eax, [esp+14h]
    mov     ecx, [eax+1B2h]
    test    ecx, ecx
    jz      short loc_4C2A12
    push    eax
    call    sub_4C25E0

    loc_4C2A12:                             ; CODE XREF: .text:004C2A0Aj
    test    edi, edi
    jnz     short loc_4C2A31
    push    edi
    push    offset Target
    mov     dword_52A4EC, edi
    call    ebx ; InterlockedExchange
    mov     edx, hHandle
    push    edx
    call    ds:SetEvent

    loc_4C2A31:                             ; CODE XREF: .text:004C2A14j
    call    ebp ; __imp_GetTickCount
    mov     ecx, esi
    sub     ecx, eax
    cmp     ecx, 1
    jge     short loc_4C2A43
    mov     eax, 1
    jmp     short loc_4C2A49
    ; ---------------------------------------------------------------------------

    loc_4C2A43:                             ; CODE XREF: .text:004C2A3Aj
    call    ebp ; __imp_GetTickCount
    sub     esi, eax
    mov     eax, esi

    loc_4C2A49:                             ; CODE XREF: .text:004C2A41j
    push    eax
    call    ds:Sleep
    mov     edx, [esp+14h]
    mov     eax, [edx+1D6h]
    test    eax, eax
    jz      loc_4C29C1
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_4C2A66:                             ; CODE XREF: .text:004C29ABj
    mov     eax, [esp+4]
    mov     dword ptr [eax+1D6h], 0
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+8]
    push    esi
    push    8000h
    push    offset loc_4C2990
    mov     dword ptr [esi+1D6h], 0
    call    sub_4B6B20
    test    eax, eax
    mov     [esi+1CAh], eax
    jz      short loc_4C2AB8
    mov     eax, 1
    mov     [esi+1CEh], eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C2AB8:                             ; CODE XREF: .text:004C2AA7j
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, [esp+8]
    push    edi
    mov     eax, [esi+1CAh]
    test    eax, eax
    jz      short loc_4C2B0E
    mov     dword ptr [esi+1D6h], 1
    xor     edi, edi

    loc_4C2ADC:                             ; CODE XREF: .text:004C2AF1j
    inc     edi
    cmp     edi, 14h
    jg      short loc_4C2B07
    push    64h
    call    sub_4B6B50
    mov     eax, [esi+1D6h]
    test    eax, eax
    jnz     short loc_4C2ADC
    mov     dword ptr [esi+1CAh], 0
    mov     eax, 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C2B07:                             ; CODE XREF: .text:004C2AE0j
    xor     eax, eax
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C2B0E:                             ; CODE XREF: .text:004C2ACEj
    pop     edi
    mov     eax, 1
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2B20 proc near                    ; CODE XREF: sub_4AB400+28p
                                            ; sub_4AB440+42p ...

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, ds:WaitForSingleObject
    push    esi
    mov     esi, ds:InterlockedExchange
    push    edi
    mov     edi, 4D41494Eh

    loc_4C2B34:                             ; CODE XREF: sub_4C2B20+32j
    push    edi                             ; Value
    push    offset Target                   ; Target
    call    esi ; InterlockedExchange
    test    eax, eax
    jz      short loc_4C2B54
    cmp     dword_52A4EC, edi
    jz      short loc_4C2B5E
    mov     eax, hHandle
    push    0FFFFFFFFh                      ; dwMilliseconds
    push    eax                             ; hHandle
    call    ebx ; WaitForSingleObject
    jmp     short loc_4C2B34
    ; ---------------------------------------------------------------------------

    loc_4C2B54:                             ; CODE XREF: sub_4C2B20+1Ej
    mov     dword_52A4EC, edi
    xor     edi, edi
    jmp     short loc_4C2B60
    ; ---------------------------------------------------------------------------

    loc_4C2B5E:                             ; CODE XREF: sub_4C2B20+26j
    mov     edi, eax

    loc_4C2B60:                             ; CODE XREF: sub_4C2B20+3Cj
    call    sub_4B6220
    mov     ecx, [esp+8+arg_0]
    test    edi, edi
    mov     [eax+1B2h], ecx
    jnz     short loc_4C2B8E
    push    edi                             ; Value
    push    offset Target                   ; Target
    mov     dword_52A4EC, edi
    call    esi ; InterlockedExchange
    mov     edx, hHandle
    push    edx                             ; hEvent
    call    ds:SetEvent

    loc_4C2B8E:                             ; CODE XREF: sub_4C2B20+51j
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_4C2B20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2BA0 proc near                    ; CODE XREF: sub_4AB440+18p
                                            ; sub_4AB440+57p
    call    sub_4B6220
    mov     eax, [eax+1B2h]
    retn
    sub_4C2BA0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2BB0 proc near                    ; CODE XREF: .text:00426636p
    call    sub_4B6220
    xor     ecx, ecx
    mov     [eax+18Eh], ecx
    mov     [eax+192h], ecx
    retn
    sub_4C2BB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2BD0 proc near                    ; CODE XREF: sub_4B5980+E7p

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    esi
    push    edi
    call    sub_4B6220
    mov     esi, eax
    mov     eax, [esp+arg_0]
    mov     [esi+186h], eax
    lea     eax, [eax+eax*2]
    shl     eax, 3
    push    eax
    push    offset aMouseEvents             ; "MOUSE EVENTS"
    call    sub_4D83B0
    add     esp, 8
    mov     [esi+18Ah], eax
    call    sub_4B6220
    xor     edi, edi
    push    1                               ; int
    push    640h                            ; int
    mov     [eax+18Eh], edi
    mov     [eax+192h], edi
    push    offset aSavemouse1              ; int
    mov     [esi+1B2h], edi
    call    sub_4C69F0
    push    1                               ; int
    push    640h                            ; int
    push    offset aSavemouse2              ; int
    mov     [esi+1BEh], eax
    call    sub_4C69F0
    push    1                               ; int
    push    640h                            ; int
    push    offset aSavemouse3              ; int
    mov     [esi+1C2h], eax
    call    sub_4C69F0
    mov     [esi+1C6h], eax
    mov     dword ptr [esi+1AEh], 1
    mov     eax, [esp+arg_4]
    mov     [esi+1D2h], edi
    cmp     eax, 1
    mov     [esi+1CEh], edi
    mov     [esi+1D6h], edi
    jnz     short loc_4C2CAF
    push    esi                             ; lpThreadId
    push    8000h                           ; dwStackSize
    push    offset loc_4C2990               ; int
    mov     [esi+1D6h], edi
    call    sub_4B6B20
    cmp     eax, edi
    mov     [esi+1CAh], eax
    jz      short loc_4C2CB5
    mov     dword ptr [esi+1CEh], 1
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C2CAF:                             ; CODE XREF: sub_4C2BD0+AEj
    mov     [esi+1CAh], edi

    loc_4C2CB5:                             ; CODE XREF: sub_4C2BD0+CEj
    pop     edi
    pop     esi
    retn    8
    sub_4C2BD0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2CC0 proc near                    ; CODE XREF: sub_49E830+4A1p
                                            ; sub_4B6110+7p
    push    esi
    call    sub_4B6220
    mov     esi, eax
    mov     eax, [esi+18Ah]
    test    eax, eax
    jz      loc_4C2D5A
    mov     ax, [esi+0F0h]
    push    edi
    shr     eax, 0Ah
    test    al, 1
    jz      short loc_4C2D1C
    mov     eax, [esi+1CAh]
    test    eax, eax
    jz      short loc_4C2D1C
    mov     dword ptr [esi+1D6h], 1
    xor     edi, edi

    loc_4C2CFB:                             ; CODE XREF: sub_4C2CC0+50j
    inc     edi
    cmp     edi, 14h
    jg      short loc_4C2D1C
    push    64h                             ; dwMilliseconds
    call    sub_4B6B50
    mov     eax, [esi+1D6h]
    test    eax, eax
    jnz     short loc_4C2CFB
    mov     dword ptr [esi+1CAh], 0

    loc_4C2D1C:                             ; CODE XREF: sub_4C2CC0+23j
                                            ; sub_4C2CC0+2Dj ...
    mov     ecx, [esi+1C6h]
    push    ecx
    call    sub_4C6AC0
    mov     edx, [esi+1C2h]
    push    edx
    call    sub_4C6AC0
    mov     eax, [esi+1BEh]
    push    eax
    call    sub_4C6AC0
    mov     ecx, [esi+18Ah]
    push    ecx                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     dword ptr [esi+18Ah], 0
    pop     edi

    loc_4C2D5A:                             ; CODE XREF: sub_4C2CC0+10j
    pop     esi
    retn
    sub_4C2CC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2D60 proc near                    ; CODE XREF: sub_499890+134p
                                            ; sub_4AB5D0+84p

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    call    sub_4B6220
    mov     ecx, [eax+192h]
    mov     edx, [eax+18Eh]
    cmp     edx, ecx
    jnz     short loc_4C2D8F
    mov     edi, [esp+arg_0]
    lea     esi, [eax+196h]
    mov     ecx, 6
    xor     eax, eax
    rep movsd
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C2D8F:                             ; CODE XREF: sub_4C2D60+15j
    mov     edx, [eax+18Ah]
    mov     edi, [esp+arg_0]
    lea     ecx, [ecx+ecx*2]
    lea     esi, [edx+ecx*8]
    mov     ecx, 6
    rep movsd
    mov     esi, [eax+192h]
    mov     edx, [eax+186h]
    inc     esi
    mov     ecx, esi
    mov     [eax+192h], esi
    cmp     ecx, edx
    jnz     short loc_4C2DC9
    mov     dword ptr [eax+192h], 0

    loc_4C2DC9:                             ; CODE XREF: sub_4C2D60+5Dj
    pop     edi
    mov     eax, 1
    pop     esi
    retn    4
    sub_4C2D60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2DE0 proc near                    ; CODE XREF: sub_499890+F2p
                                            ; sub_499890+10Cp ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    call    sub_4B6220
    mov     ecx, [eax+192h]
    mov     edx, [eax+18Eh]
    cmp     edx, ecx
    jnz     short loc_4C2E0F
    mov     edi, [esp+arg_0]
    lea     esi, [eax+196h]
    mov     ecx, 6
    xor     eax, eax
    rep movsd
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C2E0F:                             ; CODE XREF: sub_4C2DE0+15j
    mov     edx, [eax+18Ah]
    mov     edi, [esp+arg_0]
    lea     ecx, [ecx+ecx*2]
    mov     eax, 1
    lea     esi, [edx+ecx*8]
    mov     ecx, 6
    rep movsd
    pop     edi
    pop     esi
    retn    4
    sub_4C2DE0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2E30 proc near                    ; CODE XREF: sub_4B5CC0+291p

    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    call    sub_4B6220
    mov     ebx, eax
    mov     ecx, [ebx+18Eh]
    lea     eax, [ecx+1]
    cdq
    idiv    dword ptr [ebx+186h]
    cmp     edx, [ebx+192h]
    jz      short loc_4C2E8C
    mov     esi, [esp+arg_0]
    lea     eax, [ecx+ecx*2]
    mov     ecx, [ebx+18Ah]
    lea     edi, [ecx+eax*8]
    mov     ecx, 6
    rep movsd
    mov     edx, [ebx+18Eh]
    mov     ecx, [ebx+186h]
    inc     edx
    mov     eax, edx
    mov     [ebx+18Eh], edx
    cmp     eax, ecx
    jnz     short loc_4C2E8C
    mov     dword ptr [ebx+18Eh], 0

    loc_4C2E8C:                             ; CODE XREF: sub_4C2E30+20j
                                            ; sub_4C2E30+50j
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_4C2E30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2EA0 proc near                    ; CODE XREF: sub_41D6A0+9Fp
                                            ; sub_4222E0+7Cp ...
    mov     eax, ecx
    xor     ecx, ecx
    mov     [eax], ecx
    mov     [eax+4], ecx
    mov     [eax+8], ecx
    retn
    sub_4C2EA0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2EB0 proc near                    ; CODE XREF: sub_41D6A0+DCp
                                            ; sub_41D6A0+EEp ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebp
    push    edi
    mov     edi, [ecx]
    xor     ebp, ebp
    cmp     edi, ebp
    mov     [esp+10h+var_8], ecx
    jz      loc_4C2F4D
    mov     eax, [edi]
    push    esi
    cmp     eax, ebp
    push    ebx
    jz      short loc_4C2ED6
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4C2ED6:                             ; CODE XREF: sub_4C2EB0+1Bj
    mov     esi, [edi+8]
    mov     eax, [edi+0Ch]
    cmp     esi, eax
    jnb     short loc_4C2EF7

    loc_4C2EE0:                             ; CODE XREF: sub_4C2EB0+45j
    mov     ecx, [esi]
    cmp     ecx, ebp
    jz      short loc_4C2EED
    push    1
    call    sub_4C32F0

    loc_4C2EED:                             ; CODE XREF: sub_4C2EB0+34j
    mov     eax, [edi+0Ch]
    add     esi, 4
    cmp     esi, eax
    jb      short loc_4C2EE0

    loc_4C2EF7:                             ; CODE XREF: sub_4C2EB0+2Ej
    mov     ebx, [edi+1Dh]
    mov     esi, [edi+19h]
    cmp     esi, ebx
    jz      short loc_4C2F10

    loc_4C2F01:                             ; CODE XREF: sub_4C2EB0+5Ej
    push    ebp
    mov     ecx, esi
    call    sub_4C51B0
    add     esi, 8
    cmp     esi, ebx
    jnz     short loc_4C2F01

    loc_4C2F10:                             ; CODE XREF: sub_4C2EB0+4Fj
    mov     eax, [edi+19h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     [edi+19h], ebp
    mov     [edi+1Dh], ebp
    mov     [edi+21h], ebp
    mov     eax, [edi+8]
    push    eax
    mov     [esp+1Ch+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [edi+8], ebp
    mov     [edi+0Ch], ebp
    mov     [edi+10h], ebp
    push    edi
    call    sub_4B4F20
    mov     ecx, [esp+1Ch+var_8]
    add     esp, 4
    pop     ebx
    pop     esi

    loc_4C2F4D:                             ; CODE XREF: sub_4C2EB0+Fj
    mov     [ecx], ebp
    mov     [ecx+4], ebp
    mov     [ecx+8], ebp
    pop     edi
    pop     ebp
    add     esp, 8
    retn
    sub_4C2EB0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C2F60 proc near                    ; CODE XREF: sub_41D6A0+ADp
                                            ; sub_4222E0+8Ep ...

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 14h
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+20h+arg_0]
    mov     ebp, ecx
    push    edi
    mov     [esp+24h+var_14], ebp
    call    sub_4BB5B0
    mov     esi, eax
    test    esi, esi
    mov     [esp+20h+var_8], esi
    jnz     short loc_4C2F89
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 14h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C2F89:                             ; CODE XREF: sub_4C2F60+1Ej
    push    ebx
    push    esi
    call    sub_4BBD00
    mov     ebx, eax
    mov     [esp+24h+var_C], 0
    test    ebx, ebx
    jle     loc_4C30FE
    push    ebx
    push    edi
    call    sub_4D83B0
    add     esp, 8
    mov     edi, eax
    mov     [esp+24h+var_10], edi
    push    0
    push    esi
    call    sub_4BB710
    push    ebx
    push    edi
    push    esi
    call    sub_4BB7C0
    test    eax, eax
    jl      loc_4C30F5
    push    esi
    call    sub_4BB650
    mov     esi, [ebp+0]
    mov     [esp+24h+var_C], eax
    test    esi, esi
    jz      loc_4C3067
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4C2FEE
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4C2FEE:                             ; CODE XREF: sub_4C2F60+83j
    mov     edi, [esi+8]
    mov     eax, [esi+0Ch]
    cmp     edi, eax
    jnb     short loc_4C300F

    loc_4C2FF8:                             ; CODE XREF: sub_4C2F60+ADj
    mov     ecx, [edi]
    test    ecx, ecx
    jz      short loc_4C3005
    push    1
    call    sub_4C32F0

    loc_4C3005:                             ; CODE XREF: sub_4C2F60+9Cj
    mov     eax, [esi+0Ch]
    add     edi, 4
    cmp     edi, eax
    jb      short loc_4C2FF8

    loc_4C300F:                             ; CODE XREF: sub_4C2F60+96j
    mov     ebp, [esi+1Dh]
    mov     edi, [esi+19h]
    cmp     edi, ebp
    jz      short loc_4C3026

    loc_4C3019:                             ; CODE XREF: sub_4C2F60+C4j
    push    edi
    call    sub_4C5170
    add     edi, 8
    cmp     edi, ebp
    jnz     short loc_4C3019

    loc_4C3026:                             ; CODE XREF: sub_4C2F60+B7j
    mov     eax, [esi+19h]
    push    eax
    call    sub_4B4F20
    xor     edi, edi
    add     esp, 4
    mov     [esi+19h], edi
    mov     [esi+1Dh], edi
    mov     [esi+21h], edi
    mov     eax, [esi+8]
    push    eax
    mov     [esp+28h+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+8], edi
    mov     [esi+0Ch], edi
    mov     [esi+10h], edi
    push    esi
    call    sub_4B4F20
    mov     edi, [esp+28h+var_10]
    mov     ebp, [esp+28h+var_14]
    add     esp, 4

    loc_4C3067:                             ; CODE XREF: sub_4C2F60+79j
    mov     ecx, [esp+24h+var_C]
    lea     edx, [ebx+1]
    push    edx
    push    offset aTdfFile                 ; "TDF file"
    mov     dword ptr [ebp+0], 0
    mov     dword ptr [ebp+4], 0
    mov     [ebp+8], ecx
    call    sub_4D83B0
    mov     ecx, ebx
    mov     ebp, eax
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    add     esp, 8
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    ebp
    and     ecx, 3
    rep movsb
    mov     esi, [esp+28h+var_14]
    mov     byte ptr [ebp+ebx+0], 0
    mov     ecx, esi
    call    sub_4C33A0
    push    29h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4C30D8
    mov     ecx, [esp+24h+arg_0]
    push    ecx
    push    0
    push    ebp
    push    offset aRoot                    ; "root"
    mov     ecx, eax
    call    sub_4C3E40
    jmp     short loc_4C30DA
    ; ---------------------------------------------------------------------------

    loc_4C30D8:                             ; CODE XREF: sub_4C2F60+160j
    xor     eax, eax

    loc_4C30DA:                             ; CODE XREF: sub_4C2F60+176j
    push    ebp                             ; int
    mov     [esi], eax
    call    sub_4D85A0
    mov     edi, [esp+28h+var_10]
    mov     esi, [esp+28h+var_8]
    add     esp, 4
    mov     [esp+24h+var_C], 1

    loc_4C30F5:                             ; CODE XREF: sub_4C2F60+64j
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4C30FE:                             ; CODE XREF: sub_4C2F60+3Cj
    push    esi
    call    sub_4BB5D0
    mov     eax, [esp+24h+var_C]
    pop     ebx
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 14h
    retn    4
    sub_4C2F60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3120 proc near                    ; CODE XREF: sub_42A8D0+393p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [ecx]
    xor     ebx, ebx
    cmp     edi, ebx
    mov     [esp+18h+var_8], ecx
    jz      loc_4C31BB
    mov     eax, [edi]
    cmp     eax, ebx
    jz      short loc_4C3146
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4C3146:                             ; CODE XREF: sub_4C3120+1Bj
    mov     esi, [edi+8]
    mov     eax, [edi+0Ch]
    cmp     esi, eax
    jnb     short loc_4C3167

    loc_4C3150:                             ; CODE XREF: sub_4C3120+45j
    mov     ecx, [esi]
    cmp     ecx, ebx
    jz      short loc_4C315D
    push    1
    call    sub_4C32F0

    loc_4C315D:                             ; CODE XREF: sub_4C3120+34j
    mov     eax, [edi+0Ch]
    add     esi, 4
    cmp     esi, eax
    jb      short loc_4C3150

    loc_4C3167:                             ; CODE XREF: sub_4C3120+2Ej
    mov     ebp, [edi+1Dh]
    mov     esi, [edi+19h]
    cmp     esi, ebp
    jz      short loc_4C3180

    loc_4C3171:                             ; CODE XREF: sub_4C3120+5Ej
    push    ebx
    mov     ecx, esi
    call    sub_4C51B0
    add     esi, 8
    cmp     esi, ebp
    jnz     short loc_4C3171

    loc_4C3180:                             ; CODE XREF: sub_4C3120+4Fj
    mov     eax, [edi+19h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     [edi+19h], ebx
    mov     [edi+1Dh], ebx
    mov     [edi+21h], ebx
    mov     eax, [edi+8]
    push    eax
    mov     [esp+1Ch+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [edi+8], ebx
    mov     [edi+0Ch], ebx
    mov     [edi+10h], ebx
    push    edi
    call    sub_4B4F20
    mov     ecx, [esp+1Ch+var_8]
    add     esp, 4

    loc_4C31BB:                             ; CODE XREF: sub_4C3120+11j
    mov     edx, [esp+18h+arg_8]
    mov     [ecx], ebx
    mov     [ecx+4], ebx
    mov     ebx, [esp+18h+arg_4]
    mov     [ecx+8], edx
    lea     eax, [ebx+1]
    push    eax
    push    offset aTdfFile                 ; "TDF file"
    call    sub_4D83B0
    mov     esi, [esp+20h+arg_0]
    mov     ecx, ebx
    mov     ebp, eax
    mov     edx, ecx
    mov     edi, ebp
    add     esp, 8
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    push    ebp
    and     ecx, 3
    rep movsb
    mov     esi, [esp+1Ch+var_8]
    mov     byte ptr [ebp+ebx+0], 0
    mov     ecx, esi
    call    sub_4C33A0
    push    29h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4C3229
    mov     ecx, [esp+18h+arg_C]
    push    ecx
    push    0
    push    ebp
    push    offset aRoot                    ; "root"
    mov     ecx, eax
    call    sub_4C3E40
    jmp     short loc_4C322B
    ; ---------------------------------------------------------------------------

    loc_4C3229:                             ; CODE XREF: sub_4C3120+F1j
    xor     eax, eax

    loc_4C322B:                             ; CODE XREF: sub_4C3120+107j
    push    ebp                             ; int
    mov     [esi], eax
    call    sub_4D85A0
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    10h
    sub_4C3120 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3240 proc near                    ; CODE XREF: sub_429870+77Ap
                                            ; sub_42BF40+42p ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    ebp
    push    esi
    mov     esi, [ecx]
    xor     ebp, ebp
    cmp     esi, ebp
    mov     [esp+10h+var_8], ecx
    jz      loc_4C32DC
    mov     eax, [esi]
    push    edi
    cmp     eax, ebp
    push    ebx
    jz      short loc_4C3266
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4C3266:                             ; CODE XREF: sub_4C3240+1Bj
    mov     edi, [esi+8]
    mov     eax, [esi+0Ch]
    cmp     edi, eax
    jnb     short loc_4C3287

    loc_4C3270:                             ; CODE XREF: sub_4C3240+45j
    mov     ecx, [edi]
    cmp     ecx, ebp
    jz      short loc_4C327D
    push    1
    call    sub_4C32F0

    loc_4C327D:                             ; CODE XREF: sub_4C3240+34j
    mov     eax, [esi+0Ch]
    add     edi, 4
    cmp     edi, eax
    jb      short loc_4C3270

    loc_4C3287:                             ; CODE XREF: sub_4C3240+2Ej
    mov     ebx, [esi+1Dh]
    mov     edi, [esi+19h]
    cmp     edi, ebx
    jz      short loc_4C329F

    loc_4C3291:                             ; CODE XREF: sub_4C3240+5Dj
    mov     ecx, edi
    call    sub_4C5190
    add     edi, 8
    cmp     edi, ebx
    jnz     short loc_4C3291

    loc_4C329F:                             ; CODE XREF: sub_4C3240+4Fj
    mov     eax, [esi+19h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+19h], ebp
    mov     [esi+1Dh], ebp
    mov     [esi+21h], ebp
    mov     eax, [esi+8]
    push    eax
    mov     [esp+1Ch+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [esi+8], ebp
    mov     [esi+0Ch], ebp
    mov     [esi+10h], ebp
    push    esi
    call    sub_4B4F20
    mov     ecx, [esp+1Ch+var_8]
    add     esp, 4
    pop     ebx
    pop     edi

    loc_4C32DC:                             ; CODE XREF: sub_4C3240+Fj
    mov     [ecx], ebp
    mov     [ecx+4], ebp
    mov     [ecx+8], ebp
    pop     esi
    pop     ebp
    add     esp, 8
    retn
    sub_4C3240 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C32F0 proc near                    ; CODE XREF: sub_4C2EB0+38p
                                            ; sub_4C2F60+A0p ...

    var_4= dword ptr -4
    arg_0= byte ptr  4

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebx, ebx
    mov     eax, [edi]
    cmp     eax, ebx
    jz      short loc_4C3308
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4C3308:                             ; CODE XREF: sub_4C32F0+Dj
    mov     esi, [edi+8]
    mov     eax, [edi+0Ch]
    cmp     esi, eax
    jnb     short loc_4C3329

    loc_4C3312:                             ; CODE XREF: sub_4C32F0+37j
    mov     ecx, [esi]
    cmp     ecx, ebx
    jz      short loc_4C331F
    push    1
    call    sub_4C32F0

    loc_4C331F:                             ; CODE XREF: sub_4C32F0+26j
    mov     eax, [edi+0Ch]
    add     esi, 4
    cmp     esi, eax
    jb      short loc_4C3312

    loc_4C3329:                             ; CODE XREF: sub_4C32F0+20j
    mov     ebp, [edi+1Dh]
    mov     esi, [edi+19h]
    cmp     esi, ebp
    jz      short loc_4C3350
    lea     ebx, [esi+4]

    loc_4C3336:                             ; CODE XREF: sub_4C32F0+5Cj
    mov     ecx, ebx
    call    sub_4C9390
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 8
    add     ebx, 8
    cmp     esi, ebp
    jnz     short loc_4C3336
    xor     ebx, ebx

    loc_4C3350:                             ; CODE XREF: sub_4C32F0+41j
    mov     eax, [edi+19h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     [edi+19h], ebx
    mov     [edi+1Dh], ebx
    mov     [edi+21h], ebx
    mov     eax, [edi+8]
    push    eax
    mov     [esp+18h+var_4], eax
    call    sub_4B4F20
    mov     al, [esp+18h+arg_0]
    add     esp, 4
    test    al, 1
    mov     [edi+8], ebx
    mov     [edi+0Ch], ebx
    mov     [edi+10h], ebx
    jz      short loc_4C338F
    push    edi
    call    sub_4B4F20
    add     esp, 4

    loc_4C338F:                             ; CODE XREF: sub_4C32F0+94j
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_4C32F0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C33A0 proc near                    ; CODE XREF: sub_4C2F60+14Fp
                                            ; sub_4C3120+E0p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    cmp     byte ptr [eax], 0
    jz      short locret_4C3406
    push    ebx
    mov     bl, 2Fh
    mov     dl, 20h

    loc_4C33AE:                             ; CODE XREF: sub_4C33A0+63j
    mov     cl, [eax]
    cmp     cl, bl
    jnz     short loc_4C33FF
    cmp     [eax+1], bl
    jnz     short loc_4C33CA

    loc_4C33B9:                             ; CODE XREF: sub_4C33A0+26j
    cmp     cl, 0Ah
    jz      short loc_4C3400
    mov     [eax], dl
    mov     cl, [eax+1]
    inc     eax
    test    cl, cl
    jnz     short loc_4C33B9
    jmp     short loc_4C3400
    ; ---------------------------------------------------------------------------

    loc_4C33CA:                             ; CODE XREF: sub_4C33A0+17j
    cmp     cl, bl
    jnz     short loc_4C33FF
    cmp     byte ptr [eax+1], 2Ah
    jnz     short loc_4C33FF
    mov     [eax+1], dl
    mov     [eax], dl
    mov     cl, [eax+2]
    add     eax, 2
    test    cl, cl
    jz      short loc_4C3400

    loc_4C33E3:                             ; CODE XREF: sub_4C33A0+56j
    cmp     byte ptr [eax-1], 2Ah
    jnz     short loc_4C33ED
    cmp     cl, bl
    jz      short loc_4C33FA

    loc_4C33ED:                             ; CODE XREF: sub_4C33A0+47j
    mov     [eax-1], dl
    mov     cl, [eax+1]
    inc     eax
    test    cl, cl
    jnz     short loc_4C33E3
    jmp     short loc_4C3400
    ; ---------------------------------------------------------------------------

    loc_4C33FA:                             ; CODE XREF: sub_4C33A0+4Bj
    mov     [eax], dl
    mov     [eax-1], dl

    loc_4C33FF:                             ; CODE XREF: sub_4C33A0+12j
                                            ; sub_4C33A0+2Cj ...
    inc     eax

    loc_4C3400:                             ; CODE XREF: sub_4C33A0+1Cj
                                            ; sub_4C33A0+28j ...
    cmp     byte ptr [eax], 0
    jnz     short loc_4C33AE
    pop     ebx

    locret_4C3406:                          ; CODE XREF: sub_4C33A0+7j
    retn    4
    sub_4C33A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C3410(char *)
    sub_4C3410 proc near                    ; CODE XREF: sub_41D6A0+BFp
                                            ; .text:0042247Fp ...

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     edi, [ebp+4]
    test    edi, edi
    jnz     short loc_4C3420
    mov     edi, [ebp+0]

    loc_4C3420:                             ; CODE XREF: sub_4C3410+Bj
    mov     esi, [edi+8]
    mov     eax, [edi+0Ch]
    cmp     esi, eax
    jnb     short loc_4C3470
    mov     ebx, [esp+8+arg_0]

    loc_4C342E:                             ; CODE XREF: sub_4C3410+38j
    mov     eax, [esi]
    push    ebx                             ; char *
    mov     ecx, [eax]
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4C345D
    mov     eax, [edi+0Ch]
    add     esi, 4
    cmp     esi, eax
    jb      short loc_4C342E
    xor     esi, esi
    xor     eax, eax
    test    esi, esi
    mov     [ebp+4], esi
    setnz   al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C345D:                             ; CODE XREF: sub_4C3410+2Ej
    mov     esi, [esi]
    xor     eax, eax
    test    esi, esi
    mov     [ebp+4], esi
    setnz   al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C3470:                             ; CODE XREF: sub_4C3410+18j
    xor     esi, esi
    xor     eax, eax
    mov     [ebp+4], esi
    pop     edi
    test    esi, esi
    pop     esi
    pop     ebp
    setnz   al
    pop     ebx
    retn    4
    sub_4C3410 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3490 proc near                    ; CODE XREF: sub_42DCF0+F3p
                                            ; sub_42E310+C9p ...

    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    arg_0= dword ptr  4

    sub     esp, 30h
    mov     edx, ecx
    push    ebx
    push    ebp
    push    esi
    mov     ebx, [edx+4]
    push    edi
    test    ebx, ebx
    mov     [esp+40h+var_30], edx
    jnz     short loc_4C34A6
    mov     ebx, [edx]

    loc_4C34A6:                             ; CODE XREF: sub_4C3490+12j
    mov     ecx, [ebx+8]
    test    ecx, ecx
    jnz     short loc_4C34B1
    xor     eax, eax
    jmp     short loc_4C34B9
    ; ---------------------------------------------------------------------------

    loc_4C34B1:                             ; CODE XREF: sub_4C3490+1Bj
    mov     eax, [ebx+0Ch]
    sub     eax, ecx
    sar     eax, 2

    loc_4C34B9:                             ; CODE XREF: sub_4C3490+1Fj
    mov     esi, [esp+40h+arg_0]
    cmp     esi, eax
    jb      short loc_4C34C8
    xor     eax, eax
    jmp     loc_4C359E
    ; ---------------------------------------------------------------------------

    loc_4C34C8:                             ; CODE XREF: sub_4C3490+2Fj
    mov     ecx, [ebx+8]
    test    ecx, ecx
    jnz     short loc_4C34D3
    xor     eax, eax
    jmp     short loc_4C34DB
    ; ---------------------------------------------------------------------------

    loc_4C34D3:                             ; CODE XREF: sub_4C3490+3Dj
    mov     eax, [ebx+0Ch]
    sub     eax, ecx
    sar     eax, 2

    loc_4C34DB:                             ; CODE XREF: sub_4C3490+41j
    cmp     eax, esi
    ja      loc_4C3598
    mov     al, byte ptr [esp+40h+arg_0]
    push    0
    lea     ecx, [esp+44h+var_2C]
    mov     byte ptr [esp+44h+var_2C], al
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     edi, offset aInvalidVectorT     ; "invalid vector<T> subscript"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    1
    repne scasb
    not     ecx
    dec     ecx
    mov     ebp, ecx
    lea     ecx, [esp+44h+var_2C]
    push    ebp
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C353E
    mov     edi, [esp+40h+var_28]
    mov     ecx, ebp
    mov     edx, ecx
    mov     esi, offset aInvalidVectorT     ; "invalid vector<T> subscript"
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    push    ebp
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+44h+var_2C]
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)
    mov     esi, [esp+40h+arg_0]

    loc_4C353E:                             ; CODE XREF: sub_4C3490+85j
    lea     eax, [esp+40h+var_2C]
    lea     ecx, [esp+40h+var_1C]
    push    eax
    call    sub_4C35C0
    lea     ecx, [esp+40h+var_1C]
    push    offset dword_4FEFB8
    push    ecx
    mov     [esp+48h+var_1C], offset off_4FDCB4
    call    __CxxThrowException@8           ; _CxxThrowException(x,x)
    mov     ecx, [esp+40h+var_28]
    xor     edi, edi
    cmp     ecx, edi
    jz      short loc_4C3588
    mov     al, [ecx-1]
    dec     ecx
    test    al, al
    jz      short loc_4C357F
    cmp     al, 0FFh
    jz      short loc_4C357F
    dec     al
    mov     [ecx], al
    jmp     short loc_4C3588
    ; ---------------------------------------------------------------------------

    loc_4C357F:                             ; CODE XREF: sub_4C3490+E3j
                                            ; sub_4C3490+E7j
    push    ecx
    call    sub_4B4F20
    add     esp, 4

    loc_4C3588:                             ; CODE XREF: sub_4C3490+DBj
                                            ; sub_4C3490+EDj
    mov     edx, [esp+40h+var_30]
    mov     [esp+40h+var_28], edi
    mov     [esp+40h+var_24], edi
    mov     [esp+40h+var_20], edi

    loc_4C3598:                             ; CODE XREF: sub_4C3490+4Dj
    mov     eax, [ebx+8]
    mov     eax, [eax+esi*4]

    loc_4C359E:                             ; CODE XREF: sub_4C3490+33j
    mov     [edx+4], eax
    xor     edx, edx
    test    eax, eax
    pop     edi
    pop     esi
    setnz   dl
    pop     ebp
    mov     eax, edx
    pop     ebx
    add     esp, 30h
    retn    4
    sub_4C3490 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C35C0 proc near                    ; CODE XREF: sub_4C3490+B7p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    ebp
    push    esi
    lea     eax, [esp+14h+var_8]
    push    edi
    mov     ebp, ecx
    push    eax
    mov     [esp+1Ch+var_4], ebp
    mov     [esp+1Ch+var_8], offset Data
    call    ??0exception@@QAE@ABQBD@Z       ; exception::exception(char const * const &)
    mov     esi, [esp+18h+arg_0]
    add     ebp, 0Ch
    xor     edi, edi
    mov     cl, [esi]
    mov     [ebp+4], edi
    mov     [ebp+0], cl
    mov     [ebp+8], edi
    mov     [ebp+0Ch], edi
    mov     eax, [esi+8]
    mov     ecx, ds:dword_4FDC1C
    mov     ebx, eax
    cmp     ecx, ebx
    jnb     short loc_4C3607
    mov     ebx, ecx

    loc_4C3607:                             ; CODE XREF: sub_4C35C0+43j
    cmp     ebp, esi
    jnz     short loc_4C367C
    cmp     ebx, edi
    mov     esi, ecx
    jbe     short loc_4C3616
    call    sub_4E4010

    loc_4C3616:                             ; CODE XREF: sub_4C35C0+4Fj
    mov     ecx, ebp
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [ebp+8]
    mov     ecx, eax
    sub     ecx, ebx
    cmp     ecx, esi
    jnb     short loc_4C362A
    mov     esi, ecx

    loc_4C362A:                             ; CODE XREF: sub_4C35C0+66j
    cmp     esi, edi
    jbe     short loc_4C3661
    mov     ecx, [ebp+4]
    sub     eax, esi
    lea     edx, [ebx+esi]
    sub     eax, ebx
    add     edx, ecx
    push    eax                             ; size_t
    add     ebx, ecx
    push    edx                             ; void *
    push    ebx                             ; void *
    call    _memcpy
    mov     ebx, [ebp+8]
    add     esp, 0Ch
    sub     ebx, esi
    mov     ecx, ebp
    push    edi
    push    ebx
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C3661
    push    ebx
    mov     ecx, ebp
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4C3661:                             ; CODE XREF: sub_4C35C0+6Cj
                                            ; sub_4C35C0+97j
    mov     ecx, ebp
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [esp+18h+var_4]
    mov     dword ptr [eax], offset off_4FDCA4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C367C:                             ; CODE XREF: sub_4C35C0+49j
    cmp     ebx, edi
    jbe     short loc_4C36D6
    cmp     ebx, eax
    jnz     short loc_4C36D6
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4C3690
    mov     eax, offset dword_4FDC18

    loc_4C3690:                             ; CODE XREF: sub_4C35C0+C9j
    cmp     byte ptr [eax-1], 0FEh
    jnb     short loc_4C36D6
    push    1
    mov     ecx, ebp
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4C36AB
    mov     eax, offset dword_4FDC18

    loc_4C36AB:                             ; CODE XREF: sub_4C35C0+E4j
    mov     [ebp+4], eax
    mov     ecx, [esi+8]
    mov     [ebp+8], ecx
    mov     edx, [esi+0Ch]
    mov     [ebp+0Ch], edx
    mov     cl, [eax-1]
    inc     cl
    mov     [eax-1], cl
    mov     eax, [esp+18h+var_4]
    mov     dword ptr [eax], offset off_4FDCA4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C36D6:                             ; CODE XREF: sub_4C35C0+BEj
                                            ; sub_4C35C0+C2j ...
    push    1
    push    ebx
    mov     ecx, ebp
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C370E
    mov     esi, [esi+4]
    cmp     esi, edi
    jnz     short loc_4C36F0
    mov     esi, offset dword_4FDC18

    loc_4C36F0:                             ; CODE XREF: sub_4C35C0+129j
    mov     edi, [ebp+4]
    mov     ecx, ebx
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebp+4]
    mov     [ebp+8], ebx
    add     ebx, eax
    mov     byte ptr [ebx], 0

    loc_4C370E:                             ; CODE XREF: sub_4C35C0+122j
    mov     eax, [esp+18h+var_4]
    pop     edi
    pop     esi
    pop     ebp
    mov     dword ptr [eax], offset off_4FDCA4
    pop     ebx
    add     esp, 8
    retn    4
    sub_4C35C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000000D BYTES: COLLAPSED FUNCTION unknown_libname_52. PRESS KEYPAD "+" TO EXPAND]
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3740 proc near                    ; DATA XREF: .rdata:004FDCACo

    var_1C= dword ptr -1Ch
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 1Ch
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    push    esi
    lea     ecx, [esp+2Ch+var_1C]
    call    ??0exception@@QAE@ABV0@@Z       ; exception::exception(exception const &)
    mov     al, [esi+0Ch]
    lea     edi, [esi+0Ch]
    mov     esi, ds:dword_4FDC1C
    mov     byte ptr [esp+28h+var_10], al
    mov     eax, [edi+8]
    mov     [esp+28h+var_C], 0
    mov     ebx, eax
    mov     [esp+28h+var_8], 0
    cmp     esi, ebx
    mov     [esp+28h+var_4], 0
    jnb     short loc_4C3785
    mov     ebx, esi

    loc_4C3785:                             ; CODE XREF: sub_4C3740+41j
    lea     ecx, [esp+28h+var_10]
    cmp     ecx, edi
    jnz     short loc_4C37F5
    test    ebx, ebx
    jbe     short loc_4C3796
    call    sub_4E4010

    loc_4C3796:                             ; CODE XREF: sub_4C3740+4Fj
    lea     ecx, [esp+28h+var_10]
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [esp+28h+var_8]
    sub     eax, ebx
    cmp     eax, esi
    jnb     short loc_4C37AB
    mov     esi, eax

    loc_4C37AB:                             ; CODE XREF: sub_4C3740+67j
    test    esi, esi
    jbe     short loc_4C37E7
    sub     eax, esi
    lea     edx, [ebx+esi]
    push    eax                             ; size_t
    mov     eax, [esp+2Ch+var_C]
    add     edx, eax
    add     ebx, eax
    push    edx                             ; void *
    push    ebx                             ; void *
    call    _memcpy
    mov     edi, [esp+34h+var_8]
    add     esp, 0Ch
    sub     edi, esi
    lea     ecx, [esp+28h+var_10]
    push    0
    push    edi
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C37E7
    push    edi
    lea     ecx, [esp+2Ch+var_10]
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4C37E7:                             ; CODE XREF: sub_4C3740+6Dj
                                            ; sub_4C3740+9Bj
    lea     ecx, [esp+28h+var_10]
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    jmp     loc_4C387E
    ; ---------------------------------------------------------------------------

    loc_4C37F5:                             ; CODE XREF: sub_4C3740+4Bj
    test    ebx, ebx
    jbe     short loc_4C3842
    cmp     ebx, eax
    jnz     short loc_4C3842
    mov     eax, [edi+4]
    test    eax, eax
    jnz     short loc_4C3809
    mov     eax, offset dword_4FDC18

    loc_4C3809:                             ; CODE XREF: sub_4C3740+C2j
    cmp     byte ptr [eax-1], 0FEh
    jnb     short loc_4C3842
    push    1
    lea     ecx, [esp+2Ch+var_10]
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     eax, [edi+4]
    test    eax, eax
    jnz     short loc_4C3826
    mov     eax, offset dword_4FDC18

    loc_4C3826:                             ; CODE XREF: sub_4C3740+DFj
    mov     ecx, [edi+8]
    mov     edx, [edi+0Ch]
    mov     [esp+28h+var_C], eax
    mov     [esp+28h+var_8], ecx
    mov     [esp+28h+var_4], edx
    mov     cl, [eax-1]
    inc     cl
    mov     [eax-1], cl
    jmp     short loc_4C387E
    ; ---------------------------------------------------------------------------

    loc_4C3842:                             ; CODE XREF: sub_4C3740+B7j
                                            ; sub_4C3740+BBj ...
    push    1
    push    ebx
    lea     ecx, [esp+30h+var_10]
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C387E
    mov     edi, [edi+4]
    mov     esi, offset dword_4FDC18
    test    edi, edi
    jz      short loc_4C3860
    mov     esi, edi

    loc_4C3860:                             ; CODE XREF: sub_4C3740+11Cj
    mov     edi, [esp+28h+var_C]
    mov     ecx, ebx
    mov     eax, ecx
    push    ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+2Ch+var_10]
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4C387E:                             ; CODE XREF: sub_4C3740+B0j
                                            ; sub_4C3740+100j ...
    lea     ecx, [esp+28h+var_1C]
    push    offset dword_4FEFD8
    push    ecx
    mov     [esp+30h+var_1C], offset off_4FDCA4
    call    __CxxThrowException@8           ; _CxxThrowException(x,x)
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 1Ch
    retn
    sub_4C3740 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [0000004B BYTES: COLLAPSED FUNCTION sub_4C38A0. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C38F0 proc near                    ; DATA XREF: .rdata:004FDCA4o

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    mov     dword ptr [esi], offset off_4FDCA4
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4C391D
    lea     ecx, [eax-1]
    mov     al, [eax-1]
    test    al, al
    jz      short loc_4C3914
    cmp     al, 0FFh
    jz      short loc_4C3914
    dec     al
    mov     [ecx], al
    jmp     short loc_4C391D
    ; ---------------------------------------------------------------------------

    loc_4C3914:                             ; CODE XREF: sub_4C38F0+18j
                                            ; sub_4C38F0+1Cj
    push    ecx
    call    sub_4B4F20
    add     esp, 4

    loc_4C391D:                             ; CODE XREF: sub_4C38F0+Ej
                                            ; sub_4C38F0+22j
    mov     ecx, esi
    mov     dword ptr [esi+10h], 0
    mov     dword ptr [esi+14h], 0
    mov     dword ptr [esi+18h], 0
    call    ??1exception@@UAE@XZ            ; exception::~exception(void)
    test    [esp+arg_0], 1
    jz      short loc_4C3949
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4C3949:                             ; CODE XREF: sub_4C38F0+4Ej
    mov     eax, esi
    pop     esi
    retn    4
    sub_4C38F0 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+14h]
    push    edi
    mov     ebp, ecx
    push    esi
    mov     [esp+14h], ebp
    call    ??0exception@@QAE@ABV0@@Z       ; exception::exception(exception const &)
    mov     al, [esi+0Ch]
    add     esi, 0Ch
    add     ebp, 0Ch
    xor     edi, edi
    mov     [ebp+0], al
    mov     [ebp+4], edi
    mov     [ebp+8], edi
    mov     [ebp+0Ch], edi
    mov     eax, [esi+8]
    mov     ecx, ds:dword_4FDC1C
    mov     ebx, eax
    cmp     ecx, ebx
    jnb     short loc_4C398D
    mov     ebx, ecx

    loc_4C398D:                             ; CODE XREF: .text:004C3989j
    cmp     ebp, esi
    jnz     short loc_4C39FC
    cmp     ebx, edi
    mov     esi, ecx
    jbe     short loc_4C399C
    call    sub_4E4010

    loc_4C399C:                             ; CODE XREF: .text:004C3995j
    mov     ecx, ebp
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [ebp+8]
    sub     eax, ebx
    cmp     eax, esi
    jnb     short loc_4C39AE
    mov     esi, eax

    loc_4C39AE:                             ; CODE XREF: .text:004C39AAj
    cmp     esi, edi
    jbe     short loc_4C39E3
    mov     ecx, [ebp+4]
    lea     edx, [ebx+esi]
    sub     eax, esi
    add     edx, ecx
    push    eax
    add     ebx, ecx
    push    edx
    push    ebx
    call    _memcpy
    mov     ebx, [ebp+8]
    add     esp, 0Ch
    sub     ebx, esi
    mov     ecx, ebp
    push    edi
    push    ebx
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C39E3
    push    ebx
    mov     ecx, ebp
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4C39E3:                             ; CODE XREF: .text:004C39B0j
                                            ; .text:004C39D9j
    mov     ecx, ebp
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [esp+10h]
    mov     dword ptr [eax], offset off_4FDCA4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C39FC:                             ; CODE XREF: .text:004C398Fj
    cmp     ebx, edi
    jbe     short loc_4C3A54
    cmp     ebx, eax
    jnz     short loc_4C3A54
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4C3A10
    mov     eax, offset dword_4FDC18

    loc_4C3A10:                             ; CODE XREF: .text:004C3A09j
    cmp     byte ptr [eax-1], 0FEh
    jnb     short loc_4C3A54
    push    1
    mov     ecx, ebp
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4C3A2B
    mov     eax, offset dword_4FDC18

    loc_4C3A2B:                             ; CODE XREF: .text:004C3A24j
    mov     [ebp+4], eax
    mov     ecx, [esi+8]
    mov     [ebp+8], ecx
    mov     edx, [esi+0Ch]
    mov     [ebp+0Ch], edx
    mov     cl, [eax-1]
    inc     cl
    mov     [eax-1], cl
    mov     eax, [esp+10h]
    mov     dword ptr [eax], offset off_4FDCA4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C3A54:                             ; CODE XREF: .text:004C39FEj
                                            ; .text:004C3A02j ...
    push    1
    push    ebx
    mov     ecx, ebp
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C3A8C
    mov     esi, [esi+4]
    cmp     esi, edi
    jnz     short loc_4C3A6E
    mov     esi, offset dword_4FDC18

    loc_4C3A6E:                             ; CODE XREF: .text:004C3A67j
    mov     edi, [ebp+4]
    mov     ecx, ebx
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebp+4]
    mov     [ebp+8], ebx
    add     ebx, eax
    mov     byte ptr [ebx], 0

    loc_4C3A8C:                             ; CODE XREF: .text:004C3A60j
    mov     eax, [esp+10h]
    pop     edi
    pop     esi
    pop     ebp
    mov     dword ptr [eax], offset off_4FDCA4
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    ; [0000004B BYTES: COLLAPSED FUNCTION sub_4C3AA0. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3AF0 proc near                    ; DATA XREF: .rdata:004FDCBCo

    var_1C= dword ptr -1Ch
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 1Ch
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    push    esi
    lea     ecx, [esp+2Ch+var_1C]
    call    ??0exception@@QAE@ABV0@@Z       ; exception::exception(exception const &)
    mov     al, [esi+0Ch]
    lea     edi, [esi+0Ch]
    mov     esi, ds:dword_4FDC1C
    mov     byte ptr [esp+28h+var_10], al
    mov     eax, [edi+8]
    mov     [esp+28h+var_C], 0
    mov     ebp, eax
    mov     [esp+28h+var_8], 0
    cmp     esi, ebp
    mov     [esp+28h+var_4], 0
    jnb     short loc_4C3B35
    mov     ebp, esi

    loc_4C3B35:                             ; CODE XREF: sub_4C3AF0+41j
    lea     ecx, [esp+28h+var_10]
    cmp     ecx, edi
    jnz     short loc_4C3BAA
    test    ebp, ebp
    jbe     short loc_4C3B46
    call    sub_4E4010

    loc_4C3B46:                             ; CODE XREF: sub_4C3AF0+4Fj
    lea     ecx, [esp+28h+var_10]
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [esp+28h+var_8]
    sub     eax, ebp
    cmp     eax, esi
    jnb     short loc_4C3B5B
    mov     esi, eax

    loc_4C3B5B:                             ; CODE XREF: sub_4C3AF0+67j
    test    esi, esi
    jbe     short loc_4C3B98
    sub     eax, esi
    lea     edx, [ebp+esi+0]
    push    eax                             ; size_t
    mov     eax, [esp+2Ch+var_C]
    add     edx, eax
    add     ebp, eax
    push    edx                             ; void *
    push    ebp                             ; void *
    call    _memcpy
    mov     edi, [esp+34h+var_8]
    add     esp, 0Ch
    sub     edi, esi
    lea     ecx, [esp+28h+var_10]
    push    0
    push    edi
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C3B98
    push    edi
    lea     ecx, [esp+2Ch+var_10]
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4C3B98:                             ; CODE XREF: sub_4C3AF0+6Dj
                                            ; sub_4C3AF0+9Cj
    push    0
    push    0
    lea     ecx, [esp+30h+var_10]
    call    ?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::erase(uint,uint)
    jmp     loc_4C3C36
    ; ---------------------------------------------------------------------------

    loc_4C3BAA:                             ; CODE XREF: sub_4C3AF0+4Bj
    test    ebp, ebp
    jbe     short loc_4C3BF7
    cmp     ebp, eax
    jnz     short loc_4C3BF7
    mov     eax, [edi+4]
    test    eax, eax
    jnz     short loc_4C3BBE
    mov     eax, offset dword_4FDC18

    loc_4C3BBE:                             ; CODE XREF: sub_4C3AF0+C7j
    cmp     byte ptr [eax-1], 0FEh
    jnb     short loc_4C3BF7
    push    1
    lea     ecx, [esp+2Ch+var_10]
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     eax, [edi+4]
    test    eax, eax
    jnz     short loc_4C3BDB
    mov     eax, offset dword_4FDC18

    loc_4C3BDB:                             ; CODE XREF: sub_4C3AF0+E4j
    mov     ecx, [edi+8]
    mov     edx, [edi+0Ch]
    mov     [esp+28h+var_C], eax
    mov     [esp+28h+var_8], ecx
    mov     [esp+28h+var_4], edx
    mov     cl, [eax-1]
    inc     cl
    mov     [eax-1], cl
    jmp     short loc_4C3C36
    ; ---------------------------------------------------------------------------

    loc_4C3BF7:                             ; CODE XREF: sub_4C3AF0+BCj
                                            ; sub_4C3AF0+C0j ...
    push    1
    push    ebp
    lea     ecx, [esp+30h+var_10]
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C3C36
    mov     edi, [edi+4]
    mov     esi, offset dword_4FDC18
    test    edi, edi
    jz      short loc_4C3C15
    mov     esi, edi

    loc_4C3C15:                             ; CODE XREF: sub_4C3AF0+121j
    mov     edi, [esp+28h+var_C]
    mov     ecx, ebp
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+28h+var_C]
    mov     [esp+28h+var_8], ebp
    mov     byte ptr [ebp+ecx+0], 0

    loc_4C3C36:                             ; CODE XREF: sub_4C3AF0+B5j
                                            ; sub_4C3AF0+105j ...
    lea     edx, [esp+28h+var_1C]
    push    offset dword_4FEFB8
    push    edx
    mov     [esp+30h+var_1C], offset off_4FDCB4
    call    __CxxThrowException@8           ; _CxxThrowException(x,x)
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 1Ch
    retn
    sub_4C3AF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3C60 proc near                    ; DATA XREF: .rdata:004FDCB4o

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    mov     dword ptr [esi], offset off_4FDCA4
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4C3C8D
    lea     ecx, [eax-1]
    mov     al, [eax-1]
    test    al, al
    jz      short loc_4C3C84
    cmp     al, 0FFh
    jz      short loc_4C3C84
    dec     al
    mov     [ecx], al
    jmp     short loc_4C3C8D
    ; ---------------------------------------------------------------------------

    loc_4C3C84:                             ; CODE XREF: sub_4C3C60+18j
                                            ; sub_4C3C60+1Cj
    push    ecx
    call    sub_4B4F20
    add     esp, 4

    loc_4C3C8D:                             ; CODE XREF: sub_4C3C60+Ej
                                            ; sub_4C3C60+22j
    mov     ecx, esi
    mov     dword ptr [esi+10h], 0
    mov     dword ptr [esi+14h], 0
    mov     dword ptr [esi+18h], 0
    call    ??1exception@@UAE@XZ            ; exception::~exception(void)
    test    [esp+arg_0], 1
    jz      short loc_4C3CB9
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4C3CB9:                             ; CODE XREF: sub_4C3C60+4Ej
    mov     eax, esi
    pop     esi
    retn    4
    sub_4C3C60 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+14h]
    push    edi
    mov     ebx, ecx
    push    esi
    mov     [esp+14h], ebx
    call    ??0exception@@QAE@ABV0@@Z       ; exception::exception(exception const &)
    mov     al, [esi+0Ch]
    add     esi, 0Ch
    add     ebx, 0Ch
    xor     edi, edi
    mov     [ebx], al
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     eax, [esi+8]
    mov     ecx, ds:dword_4FDC1C
    mov     ebp, eax
    cmp     ecx, ebp
    jnb     short loc_4C3CFC
    mov     ebp, ecx

    loc_4C3CFC:                             ; CODE XREF: .text:004C3CF8j
    cmp     ebx, esi
    jnz     short loc_4C3D6C
    cmp     ebp, edi
    mov     esi, ecx
    jbe     short loc_4C3D0B
    call    sub_4E4010

    loc_4C3D0B:                             ; CODE XREF: .text:004C3D04j
    mov     ecx, ebx
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [ebx+8]
    sub     eax, ebp
    cmp     eax, esi
    jnb     short loc_4C3D1D
    mov     esi, eax

    loc_4C3D1D:                             ; CODE XREF: .text:004C3D19j
    cmp     esi, edi
    jbe     short loc_4C3D53
    mov     ecx, [ebx+4]
    lea     edx, [ebp+esi+0]
    sub     eax, esi
    add     edx, ecx
    push    eax
    add     ebp, ecx
    push    edx
    push    ebp
    call    _memcpy
    mov     ebp, [ebx+8]
    add     esp, 0Ch
    sub     ebp, esi
    mov     ecx, ebx
    push    edi
    push    ebp
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C3D53
    push    ebp
    mov     ecx, ebx
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4C3D53:                             ; CODE XREF: .text:004C3D1Fj
                                            ; .text:004C3D49j
    mov     ecx, ebx
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [esp+10h]
    mov     dword ptr [eax], offset off_4FDCB4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C3D6C:                             ; CODE XREF: .text:004C3CFEj
    cmp     ebp, edi
    jbe     short loc_4C3DC4
    cmp     ebp, eax
    jnz     short loc_4C3DC4
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4C3D80
    mov     eax, offset dword_4FDC18

    loc_4C3D80:                             ; CODE XREF: .text:004C3D79j
    cmp     byte ptr [eax-1], 0FEh
    jnb     short loc_4C3DC4
    push    1
    mov     ecx, ebx
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4C3D9B
    mov     eax, offset dword_4FDC18

    loc_4C3D9B:                             ; CODE XREF: .text:004C3D94j
    mov     [ebx+4], eax
    mov     ecx, [esi+8]
    mov     [ebx+8], ecx
    mov     edx, [esi+0Ch]
    mov     [ebx+0Ch], edx
    mov     cl, [eax-1]
    inc     cl
    mov     [eax-1], cl
    mov     eax, [esp+10h]
    mov     dword ptr [eax], offset off_4FDCB4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C3DC4:                             ; CODE XREF: .text:004C3D6Ej
                                            ; .text:004C3D72j ...
    push    1
    push    ebp
    mov     ecx, ebx
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C3DF9
    mov     esi, [esi+4]
    cmp     esi, edi
    jnz     short loc_4C3DDE
    mov     esi, offset dword_4FDC18

    loc_4C3DDE:                             ; CODE XREF: .text:004C3DD7j
    mov     edi, [ebx+4]
    mov     ecx, ebp
    mov     eax, ecx
    push    ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, ebx
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4C3DF9:                             ; CODE XREF: .text:004C3DD0j
    mov     eax, [esp+10h]
    pop     edi
    pop     esi
    pop     ebp
    mov     dword ptr [eax], offset off_4FDCB4
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3E10 proc near                    ; CODE XREF: .text:00422477p
                                            ; sub_4224B0+1Bp ...
    mov     dword ptr [ecx+4], 0
    retn
    sub_4C3E10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3E20 proc near                    ; CODE XREF: sub_431950+12p
                                            ; sub_431A60+1DFp ...
    mov     eax, [ecx+4]
    retn
    sub_4C3E20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3E30 proc near                    ; CODE XREF: sub_431950+54p
                                            ; sub_431950+B6p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     [ecx+4], eax
    retn    4
    sub_4C3E30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C3E40 proc near                    ; CODE XREF: sub_4C2F60+171p
                                            ; sub_4C3120+102p ...

    var_7FC= dword ptr -7FCh
    var_7F5= byte ptr -7F5h
    var_7F4= dword ptr -7F4h
    var_7F0= dword ptr -7F0h
    var_7EC= dword ptr -7ECh
    var_7E8= dword ptr -7E8h
    var_7E4= dword ptr -7E4h
    var_7E0= dword ptr -7E0h
    var_7DC= dword ptr -7DCh
    var_7D8= dword ptr -7D8h
    var_7D4= dword ptr -7D4h
    Text= byte ptr -7D0h
    var_7B5= dword ptr -7B5h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 7FCh
    mov     al, [esp+7FCh+var_7F5]
    push    ebx
    push    ebp
    mov     ebp, ecx
    mov     cl, [esp+804h+var_7F5]
    push    esi
    lea     ebx, [ebp+4]
    push    edi
    mov     esi, offset aParseErrorIn_t     ; "Parse error in .TDF File! "
    lea     edi, [esp+80Ch+Text]
    mov     [ebx], al
    xor     eax, eax
    mov     [ebx+4], eax
    mov     [ebx+8], eax
    mov     [ebx+0Ch], eax
    mov     [ebp+15h], cl
    mov     ecx, 6
    mov     [ebp+19h], eax
    mov     [ebp+1Dh], eax
    mov     [ebp+21h], eax
    rep movsd
    movsw
    movsb
    mov     edx, [esp+80Ch+arg_0]
    mov     ecx, 1EDh
    lea     edi, [esp+80Ch+var_7B5]
    push    edx
    rep stosd
    mov     [esp+810h+var_7E8], ebp
    mov     [esp+810h+var_7D4], ebx
    stosb
    call    sub_4D8610
    mov     edi, [esp+810h+arg_4]
    add     esp, 4
    mov     [ebp+0], eax
    mov     [esp+80Ch+var_7FC], edi

    loc_4C3EB5:                             ; CODE XREF: sub_4C3E40+223j
                                            ; sub_4C3E40+2D6j
    mov     ecx, [esp+80Ch+var_7FC]
    mov     al, [ecx]
    test    al, al
    jz      short loc_4C3ED7

    loc_4C3EBF:                             ; CODE XREF: sub_4C3E40+95j
    cmp     al, 20h
    jz      short loc_4C3ECF
    cmp     al, 9
    jz      short loc_4C3ECF
    cmp     al, 0Dh
    jz      short loc_4C3ECF
    cmp     al, 0Ah
    jnz     short loc_4C3ED7

    loc_4C3ECF:                             ; CODE XREF: sub_4C3E40+81j
                                            ; sub_4C3E40+85j ...
    mov     al, [ecx+1]
    inc     ecx
    test    al, al
    jnz     short loc_4C3EBF

    loc_4C3ED7:                             ; CODE XREF: sub_4C3E40+7Dj
                                            ; sub_4C3E40+8Dj
    mov     [esp+80Ch+var_7FC], ecx
    mov     al, [ecx]
    test    al, al
    jz      loc_4C41DE
    cmp     al, 5Bh
    jz      loc_4C4068
    cmp     al, 7Dh
    jz      loc_4C4165
    push    3Dh                             ; int
    push    ecx                             ; char *
    call    _strchr
    mov     esi, eax
    add     esp, 8
    test    esi, esi
    jz      loc_4C411B
    mov     eax, [esp+80Ch+var_7FC]
    push    esi
    lea     ecx, [esp+810h+var_7F4]
    push    eax
    push    ecx
    mov     ecx, ebp
    call    sub_4C4340
    lea     eax, [esi+1]
    push    3Bh                             ; int
    push    eax                             ; char *
    mov     [esp+814h+var_7FC], eax
    call    _strchr
    mov     esi, eax
    add     esp, 8
    test    esi, esi
    jz      loc_4C4129
    mov     edx, [esp+80Ch+var_7FC]
    push    esi
    lea     eax, [esp+810h+var_7EC]
    push    edx
    push    eax
    mov     ecx, ebp
    call    sub_4C4340
    mov     edi, [ebp+19h]
    mov     ebx, [esp+80Ch+var_7F4]
    inc     esi
    mov     [esp+80Ch+var_7FC], esi
    mov     esi, [ebp+1Dh]
    cmp     edi, esi
    jz      short loc_4C3F93

    loc_4C3F5D:                             ; CODE XREF: sub_4C3E40+14Dj
    mov     eax, esi
    push    ebx                             ; char *
    sub     eax, edi
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    mov     ecx, [edi+eax*8]
    lea     ebp, [edi+eax*8]
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     edx, edx
    test    eax, eax
    setl    dl
    test    dl, dl
    jz      short loc_4C3F89
    lea     edi, [ebp+8]
    jmp     short loc_4C3F8B
    ; ---------------------------------------------------------------------------

    loc_4C3F89:                             ; CODE XREF: sub_4C3E40+142j
    mov     esi, ebp

    loc_4C3F8B:                             ; CODE XREF: sub_4C3E40+147j
    cmp     edi, esi
    jnz     short loc_4C3F5D
    mov     ebp, [esp+80Ch+var_7E8]

    loc_4C3F93:                             ; CODE XREF: sub_4C3E40+11Bj
    cmp     edi, [ebp+1Dh]
    jz      short loc_4C3FE0
    mov     esi, [esp+80Ch+var_7F4]
    mov     eax, [edi]

    loc_4C3F9E:                             ; CODE XREF: sub_4C3E40+180j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4C3FC6
    test    cl, cl
    jz      short loc_4C3FC2
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4C3FC6
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4C3F9E

    loc_4C3FC2:                             ; CODE XREF: sub_4C3E40+16Aj
    xor     eax, eax
    jmp     short loc_4C3FCB
    ; ---------------------------------------------------------------------------

    loc_4C3FC6:                             ; CODE XREF: sub_4C3E40+166j
                                            ; sub_4C3E40+176j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4C3FCB:                             ; CODE XREF: sub_4C3E40+184j
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_4C3FE0
    lea     ecx, [edi+4]
    jmp     short loc_4C403C
    ; ---------------------------------------------------------------------------

    loc_4C3FE0:                             ; CODE XREF: sub_4C3E40+156j
                                            ; sub_4C3E40+199j
    lea     ecx, [esp+80Ch+var_7E0]
    call    sub_4C9180
    lea     edx, [esp+80Ch+var_7F4]
    push    eax
    push    edx
    lea     ecx, [esp+814h+var_7DC]
    call    sub_4C54D0
    mov     eax, [ebp+19h]
    add     ebp, 15h
    mov     esi, edi
    mov     ecx, ebp
    sub     esi, eax
    lea     eax, [esp+80Ch+var_7DC]
    push    eax
    push    1
    push    edi
    sar     esi, 3
    call    sub_4C51E0
    mov     ecx, [ebp+4]
    lea     esi, [ecx+esi*8+4]
    lea     ecx, [esp+80Ch+var_7D8]
    call    sub_4C9390
    lea     ecx, [esp+80Ch+var_7DC]
    call    sub_4C9390
    lea     ecx, [esp+80Ch+var_7E0]
    call    sub_4C9390
    mov     ebp, [esp+80Ch+var_7E8]
    mov     ecx, esi

    loc_4C403C:                             ; CODE XREF: sub_4C3E40+19Ej
    lea     edx, [esp+80Ch+var_7EC]
    push    edx
    call    sub_4C93B0
    lea     ecx, [esp+80Ch+var_7EC]
    call    sub_4C9390
    lea     ecx, [esp+80Ch+var_7F4]
    call    sub_4C9390
    mov     edi, [esp+80Ch+arg_4]
    mov     ebx, [esp+80Ch+var_7D4]
    jmp     loc_4C3EB5
    ; ---------------------------------------------------------------------------

    loc_4C4068:                             ; CODE XREF: sub_4C3E40+A7j
    push    5Dh                             ; int
    push    ecx                             ; char *
    call    _strchr
    mov     esi, eax
    add     esp, 8
    test    esi, esi
    jz      loc_4C419A
    mov     eax, [esp+80Ch+var_7FC]
    push    esi
    inc     eax
    lea     ecx, [esp+810h+var_7F0]
    push    eax
    push    ecx
    mov     ecx, ebp
    call    sub_4C4340
    mov     al, [esi+1]
    lea     ecx, [esi+1]
    test    al, al
    jz      short loc_4C40B2

    loc_4C409A:                             ; CODE XREF: sub_4C3E40+270j
    cmp     al, 20h
    jz      short loc_4C40AA
    cmp     al, 9
    jz      short loc_4C40AA
    cmp     al, 0Dh
    jz      short loc_4C40AA
    cmp     al, 0Ah
    jnz     short loc_4C40B2

    loc_4C40AA:                             ; CODE XREF: sub_4C3E40+25Cj
                                            ; sub_4C3E40+260j ...
    mov     al, [ecx+1]
    inc     ecx
    test    al, al
    jnz     short loc_4C409A

    loc_4C40B2:                             ; CODE XREF: sub_4C3E40+258j
                                            ; sub_4C3E40+268j
    mov     [esp+80Ch+var_7FC], ecx
    mov     al, [ecx]
    cmp     al, 7Bh
    jnz     loc_4C41A5
    push    29h                             ; int
    call    sub_4B4F10
    add     esp, 4
    test    eax, eax
    jz      short loc_4C40F3
    mov     edx, [esp+80Ch+arg_C]
    lea     ecx, [esp+80Ch+var_7FC]
    push    edx
    mov     edx, [esp+810h+var_7FC]
    push    ecx
    mov     ecx, [esp+814h+var_7F0]
    inc     edx
    push    edx
    push    ecx
    mov     ecx, eax
    call    sub_4C3E40
    mov     [esp+80Ch+var_7E4], eax
    jmp     short loc_4C40FB
    ; ---------------------------------------------------------------------------

    loc_4C40F3:                             ; CODE XREF: sub_4C3E40+28Cj
    mov     [esp+80Ch+var_7E4], 0

    loc_4C40FB:                             ; CODE XREF: sub_4C3E40+2B1j
    mov     eax, [ebx+8]
    lea     edx, [esp+80Ch+var_7E4]
    push    edx
    push    1
    push    eax
    mov     ecx, ebx
    call    sub_4C4D70
    lea     ecx, [esp+80Ch+var_7F0]
    call    sub_4C9390
    jmp     loc_4C3EB5
    ; ---------------------------------------------------------------------------

    loc_4C411B:                             ; CODE XREF: sub_4C3E40+C4j
    lea     edx, [esp+80Ch+Text]
    mov     edi, offset aDataFieldNotFo     ; "Data field - '=' not found"
    jmp     loc_4C41F2
    ; ---------------------------------------------------------------------------

    loc_4C4129:                             ; CODE XREF: sub_4C3E40+F2j
    mov     edi, offset aDataFieldNot_0     ; "Data field - ';' not found"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+80Ch+Text]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd

    loc_4C4150:                             ; DATA XREF: .data:005031D0o
    mov     ecx, ebx
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+80Ch+var_7F4]
    call    sub_4C9390
    jmp     loc_4C4217
    ; ---------------------------------------------------------------------------

    loc_4C4165:                             ; CODE XREF: sub_4C3E40+AFj
    mov     eax, [esp+80Ch+arg_8]
    test    eax, eax
    jz      short loc_4C4175
    lea     edx, [ecx+1]
    mov     [eax], edx

    loc_4C4175:                             ; CODE XREF: sub_4C3E40+32Ej
    dec     ecx
    cmp     edi, ecx
    ja      loc_4C4285
    sub     ecx, edi
    dec     ecx
    push    ecx
    push    edi
    call    sub_4B6BA0
    mov     [ebp+25h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7FCh
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C419A:                             ; CODE XREF: sub_4C3E40+237j
    lea     edx, [esp+80Ch+Text]
    mov     edi, offset aSubRecordClosi     ; "Sub-record - closing ']' not found"
    jmp     short loc_4C41F2
    ; ---------------------------------------------------------------------------

    loc_4C41A5:                             ; CODE XREF: sub_4C3E40+27Aj
    mov     edi, offset aSubRecordOpeni     ; "Sub-record - opening '{' not found"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+80Ch+Text]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+80Ch+var_7F0]
    call    sub_4C9390
    jmp     short loc_4C4217
    ; ---------------------------------------------------------------------------

    loc_4C41DE:                             ; CODE XREF: sub_4C3E40+9Fj
    mov     eax, [esp+80Ch+arg_8]
    test    eax, eax
    jz      short loc_4C4264
    lea     edx, [esp+80Ch+Text]
    mov     edi, offset aEndOfFileNextb     ; "End of file - nextblock not zero"

    loc_4C41F2:                             ; CODE XREF: sub_4C3E40+2E4j
                                            ; sub_4C3E40+363j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb

    loc_4C4217:                             ; CODE XREF: sub_4C3E40+320j
                                            ; sub_4C3E40+39Cj
    mov     eax, [esp+80Ch+arg_0]
    test    eax, eax
    jz      short loc_4C424B
    mov     ecx, [esp+80Ch+arg_C]
    lea     edi, [esp+80Ch+Text]
    push    ecx
    push    eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    offset aNameSFromFileS          ; " - name = '%s' from file %s"
    lea     edx, [esp+ecx+818h+Text]
    push    edx
    call    _sprintf
    add     esp, 10h

    loc_4C424B:                             ; CODE XREF: sub_4C3E40+3E0j
    lea     eax, [esp+80Ch+Text]
    push    eax                             ; lpText
    call    sub_4B6290
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7FCh
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C4264:                             ; CODE XREF: sub_4C3E40+3A7j
    dec     ecx
    cmp     edi, ecx
    ja      short loc_4C4285
    sub     ecx, edi
    dec     ecx
    push    ecx
    push    edi
    call    sub_4B6BA0
    mov     [ebp+25h], eax
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7FCh
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C4285:                             ; CODE XREF: sub_4C3E40+338j
                                            ; sub_4C3E40+427j
    pop     edi
    mov     dword ptr [ebp+25h], 0
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7FCh
    retn    10h
    sub_4C3E40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C42A0 proc near                    ; CODE XREF: sub_4C42A0+2Ap

    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    ebp
    mov     ebx, ecx
    push    esi
    push    edi
    xor     edi, edi
    mov     eax, [ebx]
    cmp     eax, edi
    jz      short loc_4C42B8
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4C42B8:                             ; CODE XREF: sub_4C42A0+Dj
    mov     esi, [ebx+8]
    mov     eax, [ebx+0Ch]
    cmp     esi, eax
    jnb     short loc_4C42E4

    loc_4C42C2:                             ; CODE XREF: sub_4C42A0+40j
    mov     edi, [esi]
    test    edi, edi
    jz      short loc_4C42D8
    mov     ecx, edi
    call    sub_4C42A0
    push    edi
    call    sub_4B4F20
    add     esp, 4

    loc_4C42D8:                             ; CODE XREF: sub_4C42A0+26j
    mov     eax, [ebx+0Ch]
    add     esi, 4
    cmp     esi, eax
    jb      short loc_4C42C2
    xor     edi, edi

    loc_4C42E4:                             ; CODE XREF: sub_4C42A0+20j
    mov     ebp, [ebx+1Dh]
    mov     esi, [ebx+19h]
    cmp     esi, ebp
    jz      short loc_4C430B
    lea     edi, [esi+4]

    loc_4C42F1:                             ; CODE XREF: sub_4C42A0+67j
    mov     ecx, edi
    call    sub_4C9390
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 8
    add     edi, 8
    cmp     esi, ebp
    jnz     short loc_4C42F1
    xor     edi, edi

    loc_4C430B:                             ; CODE XREF: sub_4C42A0+4Cj
    mov     eax, [ebx+19h]
    push    eax
    call    sub_4B4F20
    add     esp, 4
    mov     [ebx+19h], edi
    mov     [ebx+1Dh], edi
    mov     [ebx+21h], edi
    mov     eax, [ebx+8]
    push    eax
    mov     [esp+18h+var_4], eax
    call    sub_4B4F20
    add     esp, 4
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     [ebx+10h], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_4C42A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C4340 proc near                    ; CODE XREF: sub_4C3E40+D7p
                                            ; sub_4C3E40+105p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    push    ebx
    mov     ecx, eax
    push    esi
    mov     al, [eax]
    test    al, al
    jz      short loc_4C4366

    loc_4C434E:                             ; CODE XREF: sub_4C4340+24j
    cmp     al, 20h
    jz      short loc_4C435E
    cmp     al, 9
    jz      short loc_4C435E
    cmp     al, 0Dh
    jz      short loc_4C435E
    cmp     al, 0Ah
    jnz     short loc_4C4366

    loc_4C435E:                             ; CODE XREF: sub_4C4340+10j
                                            ; sub_4C4340+14j ...
    mov     al, [ecx+1]
    inc     ecx
    test    al, al
    jnz     short loc_4C434E

    loc_4C4366:                             ; CODE XREF: sub_4C4340+Cj
                                            ; sub_4C4340+1Cj
    mov     eax, [esp+8+arg_8]
    cmp     ecx, eax
    jb      short loc_4C439C
    push    offset Data
    lea     ecx, [esp+0Ch+arg_4]
    call    sub_4C91B0
    mov     esi, [esp+8+arg_0]
    lea     eax, [esp+8+arg_4]
    push    eax
    mov     ecx, esi
    call    sub_4C91A0
    lea     ecx, [esp+8+arg_4]
    call    sub_4C9390
    mov     eax, esi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C439C:                             ; CODE XREF: sub_4C4340+2Cj
    lea     esi, [eax-1]

    loc_4C439F:                             ; CODE XREF: sub_4C4340+72j
    mov     al, [esi]
    cmp     al, 20h
    jz      short loc_4C43B1
    cmp     al, 9
    jz      short loc_4C43B1
    cmp     al, 0Dh
    jz      short loc_4C43B1
    cmp     al, 0Ah
    jnz     short loc_4C43B4

    loc_4C43B1:                             ; CODE XREF: sub_4C4340+63j
                                            ; sub_4C4340+67j ...
    dec     esi
    jmp     short loc_4C439F
    ; ---------------------------------------------------------------------------

    loc_4C43B4:                             ; CODE XREF: sub_4C4340+6Fj
    mov     bl, [esi+1]
    push    ecx
    lea     ecx, [esp+0Ch+arg_8]
    mov     byte ptr [esi+1], 0
    call    sub_4C91B0
    mov     [esi+1], bl
    mov     esi, [esp+8+arg_0]
    lea     ecx, [esp+8+arg_8]
    push    ecx
    mov     ecx, esi
    call    sub_4C91A0
    lea     ecx, [esp+8+arg_8]
    call    sub_4C9390
    mov     eax, esi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_4C4340 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+8]
    cmp     ecx, eax
    ja      short loc_4C4410
    sub     eax, ecx
    dec     eax
    push    eax
    push    ecx
    call    sub_4B6BA0
    mov     [esi+25h], eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C4410:                             ; CODE XREF: .text:004C43FDj
    mov     dword ptr [esi+25h], 0
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C4420(char *,size_t)
    sub_4C4420 proc near                    ; CODE XREF: sub_42F580+FEp
                                            ; sub_42F7E0+65p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     ecx, [ecx]
    mov     edx, [esp+arg_0]
    push    eax                             ; size_t
    push    ecx                             ; char *
    push    edx                             ; char *
    call    _strncpy
    add     esp, 0Ch
    retn    8
    sub_4C4420 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C4440 proc near                    ; CODE XREF: sub_42E440+13p
    mov     eax, [ecx]
    retn
    sub_4C4440 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C4450 proc near                    ; CODE XREF: sub_42F580+5Fp
                                            ; sub_436C30+68p ...
    mov     edx, [ecx+8]
    test    edx, edx
    jnz     short loc_4C445A
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_4C445A:                             ; CODE XREF: sub_4C4450+5j
    mov     eax, [ecx+0Ch]
    sub     eax, edx
    sar     eax, 2
    retn
    sub_4C4450 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C4470(char *)
    sub_4C4470 proc near                    ; CODE XREF: sub_42E440+B46p
                                            ; sub_436C30+57p ...

    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    mov     esi, [edi+8]
    mov     eax, [edi+0Ch]
    cmp     esi, eax
    jnb     short loc_4C44AF
    mov     ebx, [esp+arg_0]

    loc_4C4483:                             ; CODE XREF: sub_4C4470+2Dj
    mov     eax, [esi]
    push    ebx                             ; char *
    mov     ecx, [eax]
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4C44A7
    mov     eax, [edi+0Ch]
    add     esi, 4
    cmp     esi, eax
    jb      short loc_4C4483
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C44A7:                             ; CODE XREF: sub_4C4470+23j
    mov     eax, [esi]
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C44AF:                             ; CODE XREF: sub_4C4470+Dj
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    4
    sub_4C4470 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C44C0 proc near                    ; CODE XREF: sub_436860+247p
                                            ; sub_436860+2B3p ...

    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_1C= dword ptr -1Ch
    var_10= dword ptr -10h
    arg_0= dword ptr  4

    sub     esp, 2Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    mov     ecx, [ebp+8]
    test    ecx, ecx
    jnz     short loc_4C44D4
    xor     eax, eax
    jmp     short loc_4C44DC
    ; ---------------------------------------------------------------------------

    loc_4C44D4:                             ; CODE XREF: sub_4C44C0+Ej
    mov     eax, [ebp+0Ch]
    sub     eax, ecx
    sar     eax, 2

    loc_4C44DC:                             ; CODE XREF: sub_4C44C0+12j
    mov     esi, [esp+3Ch+arg_0]
    cmp     esi, eax
    jb      short loc_4C44F0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C44F0:                             ; CODE XREF: sub_4C44C0+22j
    mov     ecx, [ebp+8]
    test    ecx, ecx
    jnz     short loc_4C44FB
    xor     eax, eax
    jmp     short loc_4C4503
    ; ---------------------------------------------------------------------------

    loc_4C44FB:                             ; CODE XREF: sub_4C44C0+35j
    mov     eax, [ebp+0Ch]
    sub     eax, ecx
    sar     eax, 2

    loc_4C4503:                             ; CODE XREF: sub_4C44C0+39j
    cmp     eax, esi
    ja      loc_4C45AC
    mov     al, byte ptr [esp+3Ch+arg_0]
    push    0
    lea     ecx, [esp+40h+var_2C]
    mov     byte ptr [esp+40h+var_2C], al
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     edi, offset aInvalidVectorT     ; "invalid vector<T> subscript"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    1
    repne scasb
    not     ecx
    dec     ecx
    mov     ebx, ecx
    lea     ecx, [esp+40h+var_2C]
    push    ebx
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C4566
    mov     edi, [esp+3Ch+var_28]
    mov     ecx, ebx
    mov     edx, ecx
    mov     esi, offset aInvalidVectorT     ; "invalid vector<T> subscript"
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    push    ebx
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+40h+var_2C]
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)
    mov     esi, [esp+3Ch+arg_0]

    loc_4C4566:                             ; CODE XREF: sub_4C44C0+7Dj
    lea     eax, [esp+3Ch+arg_0]
    lea     ecx, [esp+3Ch+var_1C]
    push    eax
    mov     [esp+40h+arg_0], offset Data
    call    ??0exception@@QAE@ABQBD@Z       ; exception::exception(char const * const &)
    lea     ecx, [esp+3Ch+var_2C]
    push    ecx
    lea     ecx, [esp+40h+var_10]
    call    sub_4C49A0
    lea     edx, [esp+3Ch+var_1C]
    push    offset dword_4FEFB8
    push    edx
    mov     [esp+44h+var_1C], offset off_4FDCB4
    call    __CxxThrowException@8           ; _CxxThrowException(x,x)
    push    1
    lea     ecx, [esp+40h+var_2C]
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)

    loc_4C45AC:                             ; CODE XREF: sub_4C44C0+45j
    mov     ebp, [ebp+8]
    pop     edi
    mov     eax, [ebp+esi*4+0]
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    4
    sub_4C44C0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     edx, [ecx+19h]
    test    edx, edx
    jnz     short loc_4C45CA
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_4C45CA:                             ; CODE XREF: .text:004C45C5j
    mov     eax, [ecx+1Dh]
    sub     eax, edx
    sar     eax, 3
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C45E0 proc near                    ; CODE XREF: sub_42E440+B74p
                                            ; sub_42E440+EC4p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jl      short loc_4C4624
    mov     edx, [ecx+19h]
    test    edx, edx
    jnz     short loc_4C45F4
    xor     eax, eax
    jmp     short loc_4C45FC
    ; ---------------------------------------------------------------------------

    loc_4C45F4:                             ; CODE XREF: sub_4C45E0+Ej
    mov     eax, [ecx+1Dh]
    sub     eax, edx
    sar     eax, 3

    loc_4C45FC:                             ; CODE XREF: sub_4C45E0+12j
    cmp     esi, eax
    jnb     short loc_4C4624
    mov     eax, [ecx+19h]
    mov     ecx, [ecx+1Dh]
    xor     edx, edx
    cmp     eax, ecx
    jnb     short loc_4C4624

    loc_4C460C:                             ; CODE XREF: sub_4C45E0+36j
    cmp     edx, esi
    jz      short loc_4C461E
    add     eax, 8
    inc     edx
    cmp     eax, ecx
    jb      short loc_4C460C
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C461E:                             ; CODE XREF: sub_4C45E0+2Ej
    mov     eax, [eax]
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C4624:                             ; CODE XREF: sub_4C45E0+7j
                                            ; sub_4C45E0+1Ej ...
    xor     eax, eax
    pop     esi
    retn    4
    sub_4C45E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C4630(char *)
    sub_4C4630 proc near                    ; CODE XREF: sub_42A8D0+500p
                                            ; sub_42A8D0+570p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    mov     ebx, [ecx+1Dh]
    push    ebp
    mov     ebp, [esp+0Ch+arg_0]
    push    esi
    mov     esi, [ecx+19h]
    cmp     esi, ebx
    push    edi
    mov     [esp+14h+var_4], ecx
    jz      short loc_4C467D

    loc_4C4647:                             ; CODE XREF: sub_4C4630+47j
    mov     eax, ebx
    push    ebp                             ; char *
    sub     eax, esi
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     edi, [esi+eax*8]
    mov     eax, [esi+eax*8]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_4C4673
    lea     esi, [edi+8]
    jmp     short loc_4C4675
    ; ---------------------------------------------------------------------------

    loc_4C4673:                             ; CODE XREF: sub_4C4630+3Cj
    mov     ebx, edi

    loc_4C4675:                             ; CODE XREF: sub_4C4630+41j
    cmp     esi, ebx
    jnz     short loc_4C4647
    mov     ecx, [esp+14h+var_4]

    loc_4C467D:                             ; CODE XREF: sub_4C4630+15j
    cmp     esi, [ecx+1Dh]
    jz      short loc_4C469E
    mov     edx, [esi]
    push    edx                             ; char *
    push    ebp                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jnz     short loc_4C469E
    lea     eax, [esi+4]
    jmp     short loc_4C46A0
    ; ---------------------------------------------------------------------------

    loc_4C469E:                             ; CODE XREF: sub_4C4630+50j
                                            ; sub_4C4630+67j
    xor     eax, eax

    loc_4C46A0:                             ; CODE XREF: sub_4C4630+6Cj
    test    eax, eax
    jz      short loc_4C46AE
    mov     eax, [eax]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C46AE:                             ; CODE XREF: sub_4C4630+72j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    4
    sub_4C4630 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C46C0(char *,int)
    sub_4C46C0 proc near                    ; CODE XREF: sub_41D6A0+CFp
                                            ; sub_4224B0+F7p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    mov     ebx, [ecx+1Dh]
    push    ebp
    mov     ebp, [esp+0Ch+arg_0]
    push    esi
    mov     esi, [ecx+19h]
    cmp     esi, ebx
    push    edi
    mov     [esp+14h+var_4], ecx
    jz      short loc_4C470D

    loc_4C46D7:                             ; CODE XREF: sub_4C46C0+47j
    mov     eax, ebx
    push    ebp                             ; char *
    sub     eax, esi
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     edi, [esi+eax*8]
    mov     eax, [esi+eax*8]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_4C4703
    lea     esi, [edi+8]
    jmp     short loc_4C4705
    ; ---------------------------------------------------------------------------

    loc_4C4703:                             ; CODE XREF: sub_4C46C0+3Cj
    mov     ebx, edi

    loc_4C4705:                             ; CODE XREF: sub_4C46C0+41j
    cmp     esi, ebx
    jnz     short loc_4C46D7
    mov     ecx, [esp+14h+var_4]

    loc_4C470D:                             ; CODE XREF: sub_4C46C0+15j
    cmp     esi, [ecx+1Dh]
    jz      short loc_4C472E
    mov     edx, [esi]
    push    edx                             ; char *
    push    ebp                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jnz     short loc_4C472E
    lea     eax, [esi+4]
    jmp     short loc_4C4730
    ; ---------------------------------------------------------------------------

    loc_4C472E:                             ; CODE XREF: sub_4C46C0+50j
                                            ; sub_4C46C0+67j
    xor     eax, eax

    loc_4C4730:                             ; CODE XREF: sub_4C46C0+6Cj
    test    eax, eax
    jz      short loc_4C4738
    mov     eax, [eax]
    jmp     short loc_4C473A
    ; ---------------------------------------------------------------------------

    loc_4C4738:                             ; CODE XREF: sub_4C46C0+72j
    xor     eax, eax

    loc_4C473A:                             ; CODE XREF: sub_4C46C0+76j
    test    eax, eax
    jz      short loc_4C474F
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C474F:                             ; CODE XREF: sub_4C46C0+7Cj
    mov     eax, [esp+14h+arg_4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_4C46C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C4760(char *,__int64)
    sub_4C4760 proc near                    ; CODE XREF: sub_4224B0+83Bp
                                            ; sub_42A8D0+74Fp ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= qword ptr  8

    push    ecx
    push    ebx
    mov     ebx, [ecx+1Dh]
    push    ebp
    mov     ebp, [esp+0Ch+arg_0]
    push    esi
    mov     esi, [ecx+19h]
    cmp     esi, ebx
    push    edi
    mov     [esp+14h+var_4], ecx
    jz      short loc_4C47AD

    loc_4C4777:                             ; CODE XREF: sub_4C4760+47j
    mov     eax, ebx
    push    ebp                             ; char *
    sub     eax, esi
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     edi, [esi+eax*8]
    mov     eax, [esi+eax*8]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_4C47A3
    lea     esi, [edi+8]
    jmp     short loc_4C47A5
    ; ---------------------------------------------------------------------------

    loc_4C47A3:                             ; CODE XREF: sub_4C4760+3Cj
    mov     ebx, edi

    loc_4C47A5:                             ; CODE XREF: sub_4C4760+41j
    cmp     esi, ebx
    jnz     short loc_4C4777
    mov     ecx, [esp+14h+var_4]

    loc_4C47AD:                             ; CODE XREF: sub_4C4760+15j
    cmp     esi, [ecx+1Dh]
    jz      short loc_4C47CE
    mov     edx, [esi]
    push    edx                             ; char *
    push    ebp                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jnz     short loc_4C47CE
    lea     eax, [esi+4]
    jmp     short loc_4C47D0
    ; ---------------------------------------------------------------------------

    loc_4C47CE:                             ; CODE XREF: sub_4C4760+50j
                                            ; sub_4C4760+67j
    xor     eax, eax

    loc_4C47D0:                             ; CODE XREF: sub_4C4760+6Cj
    test    eax, eax
    jz      short loc_4C47D8
    mov     eax, [eax]
    jmp     short loc_4C47DA
    ; ---------------------------------------------------------------------------

    loc_4C47D8:                             ; CODE XREF: sub_4C4760+72j
    xor     eax, eax

    loc_4C47DA:                             ; CODE XREF: sub_4C4760+76j
    test    eax, eax
    jz      short loc_4C47EF
    push    eax                             ; char *
    call    _atof
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C47EF:                             ; CODE XREF: sub_4C4760+7Cj
    fld     [esp+14h+arg_4]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    sub_4C4760 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C4800(int,char *,int)
    sub_4C4800 proc near                    ; CODE XREF: sub_42BF40+1F9p
                                            ; sub_42BF40+217p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    push    ebx
    mov     ebx, [ecx+1Dh]
    push    ebp
    mov     ebp, [esp+0Ch+arg_4]
    push    esi
    mov     esi, [ecx+19h]
    cmp     esi, ebx
    push    edi
    mov     [esp+14h+var_4], ecx
    jz      short loc_4C484D

    loc_4C4817:                             ; CODE XREF: sub_4C4800+47j
    mov     eax, ebx
    push    ebp                             ; char *
    sub     eax, esi
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     edi, [esi+eax*8]
    mov     eax, [esi+eax*8]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_4C4843
    lea     esi, [edi+8]
    jmp     short loc_4C4845
    ; ---------------------------------------------------------------------------

    loc_4C4843:                             ; CODE XREF: sub_4C4800+3Cj
    mov     ebx, edi

    loc_4C4845:                             ; CODE XREF: sub_4C4800+41j
    cmp     esi, ebx
    jnz     short loc_4C4817
    mov     ecx, [esp+14h+var_4]

    loc_4C484D:                             ; CODE XREF: sub_4C4800+15j
    cmp     esi, [ecx+1Dh]
    jz      short loc_4C486E
    mov     edx, [esi]
    push    edx                             ; char *
    push    ebp                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jnz     short loc_4C486E
    lea     eax, [esi+4]
    jmp     short loc_4C4870
    ; ---------------------------------------------------------------------------

    loc_4C486E:                             ; CODE XREF: sub_4C4800+50j
                                            ; sub_4C4800+67j
    xor     eax, eax

    loc_4C4870:                             ; CODE XREF: sub_4C4800+6Cj
    test    eax, eax
    jz      short loc_4C4878
    mov     eax, [eax]
    jmp     short loc_4C487A
    ; ---------------------------------------------------------------------------

    loc_4C4878:                             ; CODE XREF: sub_4C4800+72j
    xor     eax, eax

    loc_4C487A:                             ; CODE XREF: sub_4C4800+76j
    test    eax, eax
    jz      short loc_4C48A2
    push    eax                             ; char *
    call    _atof
    fmul    ds:dbl_4FDC20
    add     esp, 4
    call    __ftol
    mov     ecx, [esp+14h+arg_0]
    mov     [ecx], eax
    mov     eax, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C48A2:                             ; CODE XREF: sub_4C4800+7Cj
    mov     eax, [esp+14h+arg_0]
    mov     edx, [esp+14h+arg_8]
    pop     edi
    pop     esi
    pop     ebp
    mov     [eax], edx
    pop     ebx
    pop     ecx
    retn    0Ch
    sub_4C4800 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C48C0(char *,char *,size_t,int)
    sub_4C48C0 proc near                    ; CODE XREF: sub_4224B0+E9p
                                            ; sub_4224B0+146p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    push    ecx
    push    ebx
    mov     ebx, [ecx+1Dh]
    push    ebp
    mov     ebp, [esp+0Ch+arg_4]
    push    esi
    mov     esi, [ecx+19h]
    cmp     esi, ebx
    push    edi
    mov     [esp+14h+var_4], ecx
    jz      short loc_4C490D

    loc_4C48D7:                             ; CODE XREF: sub_4C48C0+47j
    mov     eax, ebx
    push    ebp                             ; char *
    sub     eax, esi
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     edi, [esi+eax*8]
    mov     eax, [esi+eax*8]
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_4C4903
    lea     esi, [edi+8]
    jmp     short loc_4C4905
    ; ---------------------------------------------------------------------------

    loc_4C4903:                             ; CODE XREF: sub_4C48C0+3Cj
    mov     ebx, edi

    loc_4C4905:                             ; CODE XREF: sub_4C48C0+41j
    cmp     esi, ebx
    jnz     short loc_4C48D7
    mov     ecx, [esp+14h+var_4]

    loc_4C490D:                             ; CODE XREF: sub_4C48C0+15j
    cmp     esi, [ecx+1Dh]
    jz      short loc_4C492E
    mov     edx, [esi]
    push    edx                             ; char *
    push    ebp                             ; char *
    call    __strcmpi
    add     esp, 8
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jnz     short loc_4C492E
    lea     eax, [esi+4]
    jmp     short loc_4C4930
    ; ---------------------------------------------------------------------------

    loc_4C492E:                             ; CODE XREF: sub_4C48C0+50j
                                            ; sub_4C48C0+67j
    xor     eax, eax

    loc_4C4930:                             ; CODE XREF: sub_4C48C0+6Cj
    test    eax, eax
    jz      short loc_4C4938
    mov     eax, [eax]
    jmp     short loc_4C493A
    ; ---------------------------------------------------------------------------

    loc_4C4938:                             ; CODE XREF: sub_4C48C0+72j
    xor     eax, eax

    loc_4C493A:                             ; CODE XREF: sub_4C48C0+76j
    test    eax, eax
    jz      short loc_4C4963
    mov     esi, [esp+14h+arg_8]
    mov     edi, [esp+14h+arg_0]
    push    esi                             ; size_t
    push    eax                             ; char *
    push    edi                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [esi+edi-1], 0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C4963:                             ; CODE XREF: sub_4C48C0+7Cj
    mov     edi, [esp+14h+arg_C]
    test    edi, edi
    jz      short loc_4C498A
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, [esp+14h+arg_0]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4C498A:                             ; CODE XREF: sub_4C48C0+A9j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    10h
    sub_4C48C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C49A0 proc near                    ; CODE XREF: sub_4C44C0+C5p

    arg_0= dword ptr  10h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     ebx, ecx
    mov     al, [esi]
    xor     edi, edi
    mov     [ebx], al
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     ecx, [esi+8]
    mov     eax, ds:dword_4FDC1C
    mov     ebp, ecx
    cmp     eax, ebp
    jnb     short loc_4C49C9
    mov     ebp, eax

    loc_4C49C9:                             ; CODE XREF: sub_4C49A0+25j
    cmp     ebx, esi
    jnz     short loc_4C4A30
    cmp     ebp, edi
    mov     esi, eax
    jbe     short loc_4C49D8
    call    sub_4E4010

    loc_4C49D8:                             ; CODE XREF: sub_4C49A0+31j
    mov     ecx, ebx
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [ebx+8]
    sub     eax, ebp
    cmp     eax, esi
    jnb     short loc_4C49EA
    mov     esi, eax

    loc_4C49EA:                             ; CODE XREF: sub_4C49A0+46j
    cmp     esi, edi
    jbe     short loc_4C4A20
    mov     ecx, [ebx+4]
    lea     edx, [ebp+esi+0]
    sub     eax, esi
    add     edx, ecx
    push    eax                             ; size_t
    add     ebp, ecx
    push    edx                             ; void *
    push    ebp                             ; void *
    call    _memcpy
    mov     ebp, [ebx+8]
    add     esp, 0Ch
    sub     ebp, esi
    mov     ecx, ebx
    push    edi
    push    ebp
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C4A20
    push    ebp
    mov     ecx, ebx
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4C4A20:                             ; CODE XREF: sub_4C49A0+4Cj
                                            ; sub_4C49A0+76j
    mov     ecx, ebx
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C4A30:                             ; CODE XREF: sub_4C49A0+2Bj
    cmp     ebp, edi
    jbe     short loc_4C4A7F
    cmp     ebp, ecx
    jnz     short loc_4C4A7F
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4C4A44
    mov     eax, offset dword_4FDC18

    loc_4C4A44:                             ; CODE XREF: sub_4C49A0+9Dj
    cmp     byte ptr [eax-1], 0FEh
    jnb     short loc_4C4A7F
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4C4A5F
    mov     eax, offset dword_4FDC18

    loc_4C4A5F:                             ; CODE XREF: sub_4C49A0+B8j
    mov     [ebx+4], eax
    mov     ecx, [esi+8]
    mov     [ebx+8], ecx
    mov     edx, [esi+0Ch]
    mov     [ebx+0Ch], edx
    mov     cl, [eax-1]
    inc     cl
    mov     [eax-1], cl
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C4A7F:                             ; CODE XREF: sub_4C49A0+92j
                                            ; sub_4C49A0+96j ...
    push    1
    push    ebp
    mov     ecx, ebx
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4C4AB4
    mov     esi, [esi+4]
    cmp     esi, edi
    jnz     short loc_4C4A99
    mov     esi, offset dword_4FDC18

    loc_4C4A99:                             ; CODE XREF: sub_4C49A0+F2j
    mov     edi, [ebx+4]
    mov     ecx, ebp
    mov     eax, ecx
    push    ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, ebx
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4C4AB4:                             ; CODE XREF: sub_4C49A0+EBj
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    retn    4
    sub_4C49A0 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000048 BYTES: COLLAPSED FUNCTION std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000111 BYTES: COLLAPSED FUNCTION std::basic_string<char,std::char_traits<char>,std::allocator<char>>::erase(uint,uint). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000011 BYTES: COLLAPSED FUNCTION std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint). PRESS KEYPAD "+" TO EXPAND]
    ; [0000000F BYTES: COLLAPSED FUNCTION sub_4C4C41. PRESS KEYPAD "+" TO EXPAND]
    ; [00000120 BYTES: COLLAPSED FUNCTION std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool). PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C4D70 proc near                    ; CODE XREF: sub_4C3E40+2C8p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    push    ebx
    mov     ebx, ecx
    push    ebp
    mov     ebp, [esp+10h+arg_4]
    mov     ecx, [ebx+8]
    mov     eax, [ebx+0Ch]
    sub     eax, ecx
    push    esi
    sar     eax, 2
    cmp     eax, ebp
    push    edi
    mov     [esp+18h+var_8], ebx
    jnb     loc_4C4EB3
    mov     edx, [ebx+4]
    test    edx, edx
    jnz     short loc_4C4D9F
    xor     eax, eax
    jmp     short loc_4C4DA6
    ; ---------------------------------------------------------------------------

    loc_4C4D9F:                             ; CODE XREF: sub_4C4D70+29j
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2

    loc_4C4DA6:                             ; CODE XREF: sub_4C4D70+2Dj
    cmp     ebp, eax
    jnb     short loc_4C4DBB
    test    edx, edx
    jnz     short loc_4C4DB2
    xor     eax, eax
    jmp     short loc_4C4DBD
    ; ---------------------------------------------------------------------------

    loc_4C4DB2:                             ; CODE XREF: sub_4C4D70+3Cj
    mov     eax, ecx
    sub     eax, edx
    sar     eax, 2
    jmp     short loc_4C4DBD
    ; ---------------------------------------------------------------------------

    loc_4C4DBB:                             ; CODE XREF: sub_4C4D70+38j
    mov     eax, ebp

    loc_4C4DBD:                             ; CODE XREF: sub_4C4D70+40j
                                            ; sub_4C4D70+49j
    test    edx, edx
    jnz     short loc_4C4DC5
    xor     ecx, ecx
    jmp     short loc_4C4DCA
    ; ---------------------------------------------------------------------------

    loc_4C4DC5:                             ; CODE XREF: sub_4C4D70+4Fj
    sub     ecx, edx
    sar     ecx, 2

    loc_4C4DCA:                             ; CODE XREF: sub_4C4D70+53j
    add     eax, ecx
    test    eax, eax
    mov     [esp+18h+var_4], eax
    jge     short loc_4C4DD6
    xor     eax, eax

    loc_4C4DD6:                             ; CODE XREF: sub_4C4D70+62j
    lea     ecx, ds:0[eax*4]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     [esp+1Ch+arg_4], eax
    mov     edx, eax
    mov     eax, [ebx+4]
    mov     ebx, [esp+1Ch+arg_0]
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_4C4E09

    loc_4C4DF7:                             ; CODE XREF: sub_4C4D70+97j
    test    edx, edx
    jz      short loc_4C4DFF
    mov     ecx, [eax]
    mov     [edx], ecx

    loc_4C4DFF:                             ; CODE XREF: sub_4C4D70+89j
    add     eax, 4
    add     edx, 4
    cmp     eax, ebx
    jnz     short loc_4C4DF7

    loc_4C4E09:                             ; CODE XREF: sub_4C4D70+85j
    test    ebp, ebp
    mov     eax, edx
    jbe     short loc_4C4E23
    mov     esi, [esp+18h+arg_8]
    mov     ecx, ebp

    loc_4C4E15:                             ; CODE XREF: sub_4C4D70+B1j
    test    eax, eax
    jz      short loc_4C4E1D
    mov     edi, [esi]
    mov     [eax], edi

    loc_4C4E1D:                             ; CODE XREF: sub_4C4D70+A7j
    add     eax, 4
    dec     ecx
    jnz     short loc_4C4E15

    loc_4C4E23:                             ; CODE XREF: sub_4C4D70+9Dj
    mov     eax, [esp+18h+var_8]
    lea     edi, ds:0[ebp*4]
    mov     esi, [eax+8]
    lea     ecx, [edx+edi]
    cmp     ebx, esi
    jz      short loc_4C4E52
    mov     eax, ecx
    sub     eax, edx
    add     eax, ebx
    sub     eax, edi

    loc_4C4E40:                             ; CODE XREF: sub_4C4D70+E0j
    test    ecx, ecx
    jz      short loc_4C4E48
    mov     edx, [eax]
    mov     [ecx], edx

    loc_4C4E48:                             ; CODE XREF: sub_4C4D70+D2j
    add     eax, 4
    add     ecx, 4
    cmp     eax, esi
    jnz     short loc_4C4E40

    loc_4C4E52:                             ; CODE XREF: sub_4C4D70+C6j
    mov     eax, [esp+18h+var_8]
    mov     eax, [eax+4]
    push    eax
    mov     [esp+1Ch+arg_8], eax
    call    sub_4B4F20
    mov     esi, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+var_4]
    mov     edx, [esp+1Ch+var_8]
    add     esp, 4
    lea     eax, [esi+ecx*4]
    mov     ecx, [edx+4]
    mov     [edx+0Ch], eax
    test    ecx, ecx
    jnz     short loc_4C4E96
    xor     eax, eax
    mov     [edx+4], esi
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C4E96:                             ; CODE XREF: sub_4C4D70+10Dj
    mov     eax, [edx+8]
    mov     [edx+4], esi
    sub     eax, ecx
    sar     eax, 2
    add     ebp, eax
    lea     ecx, [esi+ebp*4]
    mov     [edx+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C4EB3:                             ; CODE XREF: sub_4C4D70+1Ej
    mov     esi, [esp+18h+arg_0]
    mov     edx, ecx
    sub     edx, esi
    sar     edx, 2
    cmp     edx, ebp
    jnb     short loc_4C4F2D
    lea     edi, ds:0[ebp*4]
    cmp     esi, ecx
    lea     edx, [esi+edi]
    jz      short loc_4C4EEA
    mov     eax, edx
    sub     eax, edi

    loc_4C4ED4:                             ; CODE XREF: sub_4C4D70+178j
    test    edx, edx
    jz      short loc_4C4EE0
    mov     ebx, [eax]
    mov     [edx], ebx
    mov     ebx, [esp+18h+var_8]

    loc_4C4EE0:                             ; CODE XREF: sub_4C4D70+166j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_4C4ED4

    loc_4C4EEA:                             ; CODE XREF: sub_4C4D70+15Ej
    mov     eax, [ebx+8]
    mov     edx, [esp+18h+arg_8]
    mov     ecx, eax
    sub     ecx, esi
    sar     ecx, 2
    sub     ebp, ecx
    mov     ecx, ebp
    jz      short loc_4C4F0C

    loc_4C4EFE:                             ; CODE XREF: sub_4C4D70+19Aj
    test    eax, eax
    jz      short loc_4C4F06
    mov     ebp, [edx]
    mov     [eax], ebp

    loc_4C4F06:                             ; CODE XREF: sub_4C4D70+190j
    add     eax, 4
    dec     ecx
    jnz     short loc_4C4EFE

    loc_4C4F0C:                             ; CODE XREF: sub_4C4D70+18Cj
    mov     ecx, [ebx+8]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_4C4F86

    loc_4C4F15:                             ; CODE XREF: sub_4C4D70+1AEj
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4C4F15
    add     [ebx+8], edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C4F2D:                             ; CODE XREF: sub_4C4D70+150j
    test    ebp, ebp
    jbe     short loc_4C4F89
    lea     edi, ds:0[ebp*4]
    mov     eax, ecx
    sub     eax, edi
    mov     edx, ecx
    cmp     eax, ecx
    jz      short loc_4C4F54

    loc_4C4F42:                             ; CODE XREF: sub_4C4D70+1E2j
    test    edx, edx
    jz      short loc_4C4F4A
    mov     ebp, [eax]
    mov     [edx], ebp

    loc_4C4F4A:                             ; CODE XREF: sub_4C4D70+1D4j
    add     eax, 4
    add     edx, 4
    cmp     eax, ecx
    jnz     short loc_4C4F42

    loc_4C4F54:                             ; CODE XREF: sub_4C4D70+1D0j
    mov     ecx, [ebx+8]
    mov     eax, ecx
    sub     eax, edi
    cmp     esi, eax
    jz      short loc_4C4F6E

    loc_4C4F5F:                             ; CODE XREF: sub_4C4D70+1FCj
    mov     edx, [eax-4]
    sub     eax, 4
    sub     ecx, 4
    cmp     eax, esi
    mov     [ecx], edx
    jnz     short loc_4C4F5F

    loc_4C4F6E:                             ; CODE XREF: sub_4C4D70+1EDj
    lea     ecx, [esi+edi]
    mov     eax, esi
    cmp     esi, ecx
    jz      short loc_4C4F86
    mov     edx, [esp+18h+arg_8]

    loc_4C4F7B:                             ; CODE XREF: sub_4C4D70+214j
    mov     esi, [edx]
    mov     [eax], esi
    add     eax, 4
    cmp     eax, ecx
    jnz     short loc_4C4F7B

    loc_4C4F86:                             ; CODE XREF: sub_4C4D70+1A3j
                                            ; sub_4C4D70+205j
    add     [ebx+8], edi

    loc_4C4F89:                             ; CODE XREF: sub_4C4D70+1BFj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_4C4D70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4C4FA0 proc near                    ; CODE XREF: std::basic_string<char,std::char_traits<char>,std::allocator<char>>::erase(uint,uint)+F9p
                                            ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)+D8p ...

    var_48= dword ptr -48h
    var_28= dword ptr -28h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset loc_4FB8C0
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    push    ecx
    sub     esp, 38h
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_10], esp
    mov     ebx, ecx
    mov     [ebp+var_48], ebx
    mov     eax, [ebp+arg_0]
    mov     edi, eax
    or      edi, 1Fh
    mov     [ebp+var_1C], edi
    cmp     edi, 0FFFFFFFDh
    jbe     short loc_4C4FDC
    mov     [ebp+var_1C], eax
    mov     edi, eax

    loc_4C4FDC:                             ; CODE XREF: sub_4C4FA0+35j
    mov     [ebp+var_4], 0
    lea     eax, [edi+2]
    mov     [ebp+var_28], eax
    test    eax, eax
    jge     short loc_4C4FF2
    xor     eax, eax
    mov     [ebp+var_28], eax

    loc_4C4FF2:                             ; CODE XREF: sub_4C4FA0+4Bj
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [ebp+var_18], eax
    jmp     short loc_4C5027
    ; ---------------------------------------------------------------------------

    loc_4C5000:                             ; DATA XREF: .rdata:004FF030o
    mov     eax, [ebp+arg_0]
    mov     [ebp+var_1C], eax
    add     eax, 2
    test    eax, eax
    jge     short loc_4C500F
    xor     eax, eax

    loc_4C500F:                             ; CODE XREF: sub_4C4FA0+6Bj
    push    eax                             ; int
    call    sub_4B4F10
    add     esp, 4
    mov     [ebp+var_18], eax
    mov     eax, offset loc_4C5021
    retn
    ; ---------------------------------------------------------------------------

    loc_4C5021:                             ; DATA XREF: sub_4C4FA0+7Bo
    mov     ebx, [ebp+var_48]
    mov     edi, [ebp+var_1C]

    loc_4C5027:                             ; CODE XREF: sub_4C4FA0+5Ej
    mov     [ebp+var_4], 0FFFFFFFFh
    mov     ecx, [ebx+8]
    test    ecx, ecx
    jbe     short loc_4C504F
    mov     esi, [ebx+4]
    mov     eax, [ebp+var_18]
    lea     edi, [eax+1]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, [ebp+var_1C]

    loc_4C504F:                             ; CODE XREF: sub_4C4FA0+93j
    mov     esi, [ebx+8]
    mov     eax, [ebx+4]
    test    eax, eax
    jz      short loc_4C5075
    lea     ecx, [eax-1]
    mov     al, [ecx]
    test    al, al
    jz      short loc_4C506C
    cmp     al, 0FFh
    jz      short loc_4C506C
    dec     al
    mov     [ecx], al
    jmp     short loc_4C5075
    ; ---------------------------------------------------------------------------

    loc_4C506C:                             ; CODE XREF: sub_4C4FA0+C0j
                                            ; sub_4C4FA0+C4j
    push    ecx
    call    sub_4B4F20
    add     esp, 4

    loc_4C5075:                             ; CODE XREF: sub_4C4FA0+B7j
                                            ; sub_4C4FA0+CAj
    mov     eax, [ebp+var_18]
    inc     eax
    mov     [ebx+4], eax
    mov     byte ptr [eax-1], 0
    mov     [ebx+0Ch], edi
    mov     [ebx+8], esi
    add     esi, [ebx+4]
    mov     byte ptr [esi], 0
    mov     ecx, [ebp+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    sub_4C4FA0 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [000000C9 BYTES: COLLAPSED FUNCTION std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void). PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5170 proc near                    ; CODE XREF: sub_4C2F60+BAp

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    lea     ecx, [esi+4]
    call    sub_4C9390
    mov     ecx, esi
    call    sub_4C9390
    pop     esi
    retn    4
    sub_4C5170 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5190 proc near                    ; CODE XREF: sub_4C3240+53p
                                            ; sub_4C51E0+10Ep ...
    push    esi
    mov     esi, ecx
    lea     ecx, [esi+4]
    call    sub_4C9390
    mov     ecx, esi
    call    sub_4C9390
    pop     esi
    retn
    sub_4C5190 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C51B0 proc near                    ; CODE XREF: sub_4C2EB0+54p
                                            ; sub_4C3120+54p

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    lea     ecx, [esi+4]
    call    sub_4C9390
    mov     ecx, esi
    call    sub_4C9390
    test    [esp+arg_0], 1
    jz      short loc_4C51D2
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4C51D2:                             ; CODE XREF: sub_4C51B0+17j
    mov     eax, esi
    pop     esi
    retn    4
    sub_4C51B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C51E0 proc near                    ; CODE XREF: sub_4C3E40+1CFp

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    mov     eax, [ecx+0Ch]
    push    ebx
    mov     edx, [esp+10h+arg_4]
    push    ebp
    push    esi
    push    edi
    mov     edi, [ecx+8]
    mov     [esp+1Ch+var_C], ecx
    sub     eax, edi
    sar     eax, 3
    cmp     eax, edx
    jnb     loc_4C5357
    mov     ecx, [ecx+4]
    test    ecx, ecx
    jnz     short loc_4C520D
    xor     eax, eax
    jmp     short loc_4C5214
    ; ---------------------------------------------------------------------------

    loc_4C520D:                             ; CODE XREF: sub_4C51E0+27j
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 3

    loc_4C5214:                             ; CODE XREF: sub_4C51E0+2Bj
    cmp     edx, eax
    jnb     short loc_4C5229
    test    ecx, ecx
    jnz     short loc_4C5220
    xor     eax, eax
    jmp     short loc_4C522B
    ; ---------------------------------------------------------------------------

    loc_4C5220:                             ; CODE XREF: sub_4C51E0+3Aj
    mov     eax, edi
    sub     eax, ecx
    sar     eax, 3
    jmp     short loc_4C522B
    ; ---------------------------------------------------------------------------

    loc_4C5229:                             ; CODE XREF: sub_4C51E0+36j
    mov     eax, edx

    loc_4C522B:                             ; CODE XREF: sub_4C51E0+3Ej
                                            ; sub_4C51E0+47j
    test    ecx, ecx
    jnz     short loc_4C5233
    xor     edi, edi
    jmp     short loc_4C5238
    ; ---------------------------------------------------------------------------

    loc_4C5233:                             ; CODE XREF: sub_4C51E0+4Dj
    sub     edi, ecx
    sar     edi, 3

    loc_4C5238:                             ; CODE XREF: sub_4C51E0+51j
    add     eax, edi
    test    eax, eax
    mov     [esp+1Ch+var_4], eax
    jge     short loc_4C5244
    xor     eax, eax

    loc_4C5244:                             ; CODE XREF: sub_4C51E0+60j
    lea     ecx, ds:0[eax*8]
    push    ecx                             ; int
    call    sub_4B4F10
    mov     edx, [esp+20h+var_C]
    mov     ecx, [esp+20h+arg_0]
    add     esp, 4
    mov     [esp+1Ch+var_8], eax
    mov     esi, [edx+4]
    mov     ebx, eax
    cmp     esi, ecx
    jz      short loc_4C5283

    loc_4C5269:                             ; CODE XREF: sub_4C51E0+A1j
    test    ebx, ebx
    jz      short loc_4C5275
    push    esi
    mov     ecx, ebx
    call    sub_4C54A0

    loc_4C5275:                             ; CODE XREF: sub_4C51E0+8Bj
    mov     ecx, [esp+1Ch+arg_0]
    add     esi, 8
    add     ebx, 8
    cmp     esi, ecx
    jnz     short loc_4C5269

    loc_4C5283:                             ; CODE XREF: sub_4C51E0+87j
    mov     edi, [esp+1Ch+arg_4]
    mov     esi, ebx
    test    edi, edi
    jbe     short loc_4C52AB
    mov     ebp, [esp+1Ch+arg_8]

    loc_4C5291:                             ; CODE XREF: sub_4C51E0+C1j
    test    esi, esi
    jz      short loc_4C529D
    push    ebp
    mov     ecx, esi
    call    sub_4C54A0

    loc_4C529D:                             ; CODE XREF: sub_4C51E0+B3j
    add     esi, 8
    dec     edi
    jnz     short loc_4C5291
    mov     edi, [esp+1Ch+arg_4]
    mov     ecx, [esp+1Ch+arg_0]

    loc_4C52AB:                             ; CODE XREF: sub_4C51E0+ABj
    mov     edx, [esp+1Ch+var_C]
    lea     eax, ds:0[edi*8]
    mov     ebp, [edx+8]
    lea     edi, [ebx+eax]
    cmp     ecx, ebp
    jz      short loc_4C52DE
    mov     esi, edi
    sub     esi, ebx
    add     esi, ecx
    sub     esi, eax

    loc_4C52C8:                             ; CODE XREF: sub_4C51E0+FCj
    test    edi, edi
    jz      short loc_4C52D4
    push    esi
    mov     ecx, edi
    call    sub_4C54A0

    loc_4C52D4:                             ; CODE XREF: sub_4C51E0+EAj
    add     esi, 8
    add     edi, 8
    cmp     esi, ebp
    jnz     short loc_4C52C8

    loc_4C52DE:                             ; CODE XREF: sub_4C51E0+DEj
    mov     edi, [esp+1Ch+var_C]
    mov     ebx, [edi+8]
    mov     esi, [edi+4]
    cmp     esi, ebx
    jz      short loc_4C52FA

    loc_4C52EC:                             ; CODE XREF: sub_4C51E0+118j
    mov     ecx, esi
    call    sub_4C5190
    add     esi, 8
    cmp     esi, ebx
    jnz     short loc_4C52EC

    loc_4C52FA:                             ; CODE XREF: sub_4C51E0+10Aj
    mov     eax, [edi+4]
    push    eax
    call    sub_4B4F20
    mov     edx, [esp+20h+var_8]
    mov     eax, [esp+20h+var_4]
    add     esp, 4
    lea     ecx, [edx+eax*8]
    mov     [edi+0Ch], ecx
    mov     ecx, [edi+4]
    test    ecx, ecx
    jnz     short loc_4C5336
    mov     ecx, [esp+1Ch+arg_4]
    xor     eax, eax
    add     ecx, eax
    mov     [edi+4], edx
    lea     eax, [edx+ecx*8]
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C5336:                             ; CODE XREF: sub_4C51E0+139j
    mov     eax, [edi+8]
    mov     [edi+4], edx
    sub     eax, ecx
    mov     ecx, [esp+1Ch+arg_4]
    sar     eax, 3
    add     ecx, eax
    lea     eax, [edx+ecx*8]
    mov     [edi+8], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C5357:                             ; CODE XREF: sub_4C51E0+1Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     eax, edi
    sub     eax, ebp
    sar     eax, 3
    cmp     eax, edx
    jnb     short loc_4C53E3
    lea     eax, ds:0[edx*8]
    cmp     ebp, edi
    mov     [esp+1Ch+arg_0], eax
    lea     ebx, [ebp+eax+0]
    jz      short loc_4C539B
    mov     esi, ebx
    sub     esi, eax

    loc_4C537D:                             ; CODE XREF: sub_4C51E0+1B5j
    test    ebx, ebx
    jz      short loc_4C538D
    push    esi
    mov     ecx, ebx
    call    sub_4C54A0
    mov     edx, [esp+1Ch+arg_4]

    loc_4C538D:                             ; CODE XREF: sub_4C51E0+19Fj
    add     esi, 8
    add     ebx, 8
    cmp     esi, edi
    jnz     short loc_4C537D
    mov     ecx, [esp+1Ch+var_C]

    loc_4C539B:                             ; CODE XREF: sub_4C51E0+197j
    mov     esi, [ecx+8]
    mov     ebx, [esp+1Ch+arg_8]
    mov     eax, esi
    sub     eax, ebp
    sar     eax, 3
    sub     edx, eax
    jz      short loc_4C53C5
    mov     edi, edx

    loc_4C53AF:                             ; CODE XREF: sub_4C51E0+1DFj
    test    esi, esi
    jz      short loc_4C53BB
    push    ebx
    mov     ecx, esi
    call    sub_4C54A0

    loc_4C53BB:                             ; CODE XREF: sub_4C51E0+1D1j
    add     esi, 8
    dec     edi
    jnz     short loc_4C53AF
    mov     ecx, [esp+1Ch+var_C]

    loc_4C53C5:                             ; CODE XREF: sub_4C51E0+1CBj
    mov     edi, [ecx+8]
    mov     esi, ebp
    cmp     ebp, edi
    jz      loc_4C5454

    loc_4C53D2:                             ; CODE XREF: sub_4C51E0+1FFj
    push    ebx
    mov     ecx, esi
    call    sub_4C5470
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_4C53D2
    jmp     short loc_4C5454
    ; ---------------------------------------------------------------------------

    loc_4C53E3:                             ; CODE XREF: sub_4C51E0+184j
    test    edx, edx
    jbe     short loc_4C545F
    shl     edx, 3
    mov     esi, edi
    mov     ebx, edi
    sub     esi, edx
    mov     [esp+1Ch+arg_0], edx
    cmp     esi, edi
    jz      short loc_4C5416

    loc_4C53F8:                             ; CODE XREF: sub_4C51E0+22Cj
    test    ebx, ebx
    jz      short loc_4C5404
    push    esi
    mov     ecx, ebx
    call    sub_4C54A0

    loc_4C5404:                             ; CODE XREF: sub_4C51E0+21Aj
    add     esi, 8
    add     ebx, 8
    cmp     esi, edi
    jnz     short loc_4C53F8
    mov     ecx, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]

    loc_4C5416:                             ; CODE XREF: sub_4C51E0+216j
    mov     edi, [ecx+8]
    mov     esi, edi
    sub     esi, edx
    cmp     ebp, esi
    jz      short loc_4C5433

    loc_4C5421:                             ; CODE XREF: sub_4C51E0+251j
    sub     esi, 8
    sub     edi, 8
    push    esi
    mov     ecx, edi
    call    sub_4C5470
    cmp     esi, ebp
    jnz     short loc_4C5421

    loc_4C5433:                             ; CODE XREF: sub_4C51E0+23Fj
    mov     edx, [esp+1Ch+arg_0]
    mov     esi, ebp
    lea     edi, [ebp+edx+0]
    cmp     ebp, edi
    jz      short loc_4C5454
    mov     ebx, [esp+1Ch+arg_8]

    loc_4C5445:                             ; CODE XREF: sub_4C51E0+272j
    push    ebx
    mov     ecx, esi
    call    sub_4C5470
    add     esi, 8
    cmp     esi, edi
    jnz     short loc_4C5445

    loc_4C5454:                             ; CODE XREF: sub_4C51E0+1ECj
                                            ; sub_4C51E0+201j ...
    mov     eax, [esp+1Ch+var_C]
    mov     ecx, [esp+1Ch+arg_0]
    add     [eax+8], ecx

    loc_4C545F:                             ; CODE XREF: sub_4C51E0+205j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_4C51E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5470 proc near                    ; CODE XREF: sub_4C51E0+1F5p
                                            ; sub_4C51E0+24Ap ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_4C93B0
    add     edi, 4
    lea     ecx, [esi+4]
    push    edi
    call    sub_4C93B0
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    sub_4C5470 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C54A0 proc near                    ; CODE XREF: sub_4C51E0+90p
                                            ; sub_4C51E0+B8p ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    push    edi
    call    sub_4C91A0
    add     edi, 4
    lea     ecx, [esi+4]
    push    edi
    call    sub_4C91A0
    mov     eax, esi
    pop     edi
    pop     esi
    retn    4
    sub_4C54A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C54D0 proc near                    ; CODE XREF: sub_4C3E40+1B3p
                                            ; sub_4C54F0+1C5p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, ecx
    push    eax
    call    sub_4C91A0
    mov     ecx, [esp+4+arg_4]
    push    ecx
    lea     ecx, [esi+4]
    call    sub_4C91A0
    mov     eax, esi
    pop     esi
    retn    8
    sub_4C54D0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C54F0 proc near                    ; CODE XREF: sub_49E830+203p

    var_224= dword ptr -224h
    var_21D= byte ptr -21Dh
    var_21C= dword ptr -21Ch
    var_218= dword ptr -218h
    var_214= dword ptr -214h
    var_20C= dword ptr -20Ch
    var_208= dword ptr -208h
    var_200= byte ptr -200h
    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    sub     esp, 224h
    push    offset byte_51FDC0              ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      loc_4C572E
    mov     eax, dword_51FDB8
    push    edi
    push    esi
    push    ebp
    test    eax, eax
    push    ebx
    jz      short loc_4C555A
    mov     ebp, [eax+9]
    mov     esi, [eax+5]
    lea     edi, [eax+1]
    cmp     esi, ebp
    mov     ebx, eax
    jz      short loc_4C553A

    loc_4C552C:                             ; CODE XREF: sub_4C54F0+48j
    mov     ecx, esi
    call    sub_4C5190
    add     esi, 8
    cmp     esi, ebp
    jnz     short loc_4C552C

    loc_4C553A:                             ; CODE XREF: sub_4C54F0+3Aj
    mov     ecx, [edi+4]
    push    ecx
    call    sub_4B4F20
    add     esp, 4
    xor     eax, eax
    mov     [edi+4], eax
    mov     [edi+8], eax
    push    ebx
    mov     [edi+0Ch], eax
    call    sub_4B4F20
    add     esp, 4

    loc_4C555A:                             ; CODE XREF: sub_4C54F0+2Bj
    push    11h                             ; int
    call    sub_4B4F10
    xor     ebx, ebx
    add     esp, 4
    cmp     eax, ebx
    jz      short loc_4C557C
    mov     dl, [esp+234h+var_21D]
    mov     [eax+5], ebx
    mov     [eax+1], dl
    mov     [eax+9], ebx
    mov     [eax+0Dh], ebx
    jmp     short loc_4C557E
    ; ---------------------------------------------------------------------------

    loc_4C557C:                             ; CODE XREF: sub_4C54F0+78j
    xor     eax, eax

    loc_4C557E:                             ; CODE XREF: sub_4C54F0+8Aj
    push    eax
    mov     dword_51FDB8, eax
    call    nullsub_23
    mov     edi, [esp+238h+arg_4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 4
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, offset byte_51FDC0
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+234h+var_218]
    call    sub_4C2EA0
    mov     ecx, [esp+234h+arg_0]
    push    ecx
    lea     ecx, [esp+238h+var_218]
    call    sub_4C2F60
    test    eax, eax
    jz      loc_4C5721
    push    ebx
    lea     ecx, [esp+238h+var_218]
    mov     [esp+238h+var_21C], ebx
    call    sub_4C3490
    test    eax, eax
    jz      loc_4C5718

    loc_4C55EB:                             ; CODE XREF: sub_4C54F0+222j
    mov     ecx, [esp+234h+var_214]
    lea     edx, [esp+234h+var_100]
    push    0FFh                            ; size_t
    push    edx                             ; char *
    call    sub_4C4420
    push    offset Data                     ; int
    push    0FFh                            ; size_t
    mov     ecx, [esp+23Ch+var_214]
    lea     eax, [esp+23Ch+var_200]
    push    offset byte_51FDC0              ; char *
    push    eax                             ; char *
    call    sub_4C48C0
    lea     edi, [esp+234h+var_200]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    jz      loc_4C56F4
    lea     ecx, [esp+234h+var_100]
    push    ecx
    lea     ecx, [esp+238h+var_224]
    call    sub_4C91B0
    mov     ecx, dword_51FDB8
    mov     edx, [esp+234h+var_224]
    mov     ebp, ecx
    push    edx
    call    sub_4C5C60
    mov     edi, eax
    mov     eax, [ebp+9]
    cmp     edi, eax
    jz      short loc_4C56A2
    mov     esi, [esp+234h+var_224]
    mov     eax, [edi]

    loc_4C5664:                             ; CODE XREF: sub_4C54F0+192j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4C5688
    test    cl, cl
    jz      short loc_4C5684
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4C5688
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4C5664

    loc_4C5684:                             ; CODE XREF: sub_4C54F0+17Ej
    xor     eax, eax
    jmp     short loc_4C568D
    ; ---------------------------------------------------------------------------

    loc_4C5688:                             ; CODE XREF: sub_4C54F0+17Aj
                                            ; sub_4C54F0+188j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4C568D:                             ; CODE XREF: sub_4C54F0+196j
    xor     ecx, ecx
    cmp     eax, ebx
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_4C56A2
    lea     ecx, [edi+4]
    jmp     short loc_4C56E1
    ; ---------------------------------------------------------------------------

    loc_4C56A2:                             ; CODE XREF: sub_4C54F0+16Cj
                                            ; sub_4C54F0+1ABj
    lea     ecx, [esp+234h+var_20C]
    call    sub_4C9180
    lea     edx, [esp+234h+var_224]
    push    eax
    push    edx
    lea     ecx, [esp+23Ch+var_208]
    call    sub_4C54D0
    lea     eax, [esp+234h+var_208]
    lea     ecx, [ebp+1]
    push    eax
    push    edi
    call    sub_4C59D0
    mov     esi, eax
    lea     ecx, [esp+234h+var_208]
    add     esi, 4
    call    sub_4C5190
    lea     ecx, [esp+234h+var_20C]
    call    sub_4C9390
    mov     ecx, esi

    loc_4C56E1:                             ; CODE XREF: sub_4C54F0+1B0j
    lea     edx, [esp+234h+var_200]
    push    edx
    call    sub_4C93F0
    lea     ecx, [esp+234h+var_224]
    call    sub_4C9390

    loc_4C56F4:                             ; CODE XREF: sub_4C54F0+13Cj
    lea     ecx, [esp+234h+var_218]
    call    sub_4C3E10
    mov     eax, [esp+234h+var_21C]
    lea     ecx, [esp+234h+var_218]
    inc     eax
    push    eax
    mov     [esp+238h+var_21C], eax
    call    sub_4C3490
    test    eax, eax
    jnz     loc_4C55EB

    loc_4C5718:                             ; CODE XREF: sub_4C54F0+F5j
    lea     ecx, [esp+234h+var_218]
    call    sub_4C3240

    loc_4C5721:                             ; CODE XREF: sub_4C54F0+DFj
    lea     ecx, [esp+234h+var_218]
    call    sub_4C2EB0
    pop     ebx
    pop     ebp
    pop     esi
    pop     edi

    loc_4C572E:                             ; CODE XREF: sub_4C54F0+1Aj
    add     esp, 224h
    retn    8
    sub_4C54F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C5740(int)
    sub_4C5740 proc near                    ; CODE XREF: sub_41EC50+2F7p
                                            ; .text:0041F6D2p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     ecx, [esp+4+arg_0]
    push    ebx
    push    ebp
    push    esi
    test    ecx, ecx
    push    edi
    jnz     short loc_4C5757
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C5757:                             ; CODE XREF: sub_4C5740+Bj
    mov     eax, dword_51FDB8
    test    eax, eax
    jnz     short loc_4C576A
    mov     eax, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C576A:                             ; CODE XREF: sub_4C5740+1Ej
    mov     ebp, [eax+5]
    mov     eax, [eax+9]
    mov     ebx, eax
    mov     [esp+14h+var_4], eax
    cmp     ebp, ebx
    jz      short loc_4C57D5

    loc_4C577A:                             ; CODE XREF: sub_4C5740+8Fj
    mov     eax, ebx
    mov     esi, [esp+14h+arg_0]
    sub     eax, ebp
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     edi, [ebp+eax*8+0]
    mov     eax, [ebp+eax*8+0]

    loc_4C5792:                             ; CODE XREF: sub_4C5740+70j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4C57B6
    test    cl, cl
    jz      short loc_4C57B2
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4C57B6
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4C5792

    loc_4C57B2:                             ; CODE XREF: sub_4C5740+5Cj
    xor     eax, eax
    jmp     short loc_4C57BB
    ; ---------------------------------------------------------------------------

    loc_4C57B6:                             ; CODE XREF: sub_4C5740+58j
                                            ; sub_4C5740+66j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4C57BB:                             ; CODE XREF: sub_4C5740+74j
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_4C57CB
    lea     ebp, [edi+8]
    jmp     short loc_4C57CD
    ; ---------------------------------------------------------------------------

    loc_4C57CB:                             ; CODE XREF: sub_4C5740+84j
    mov     ebx, edi

    loc_4C57CD:                             ; CODE XREF: sub_4C5740+89j
    cmp     ebp, ebx
    jnz     short loc_4C577A
    mov     eax, [esp+14h+var_4]

    loc_4C57D5:                             ; CODE XREF: sub_4C5740+38j
    cmp     ebp, eax
    jz      short loc_4C581D
    mov     esi, [ebp+0]
    mov     eax, [esp+14h+arg_0]

    loc_4C57E0:                             ; CODE XREF: sub_4C5740+C2j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4C5808
    test    cl, cl
    jz      short loc_4C5804
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4C5808
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4C57E0

    loc_4C5804:                             ; CODE XREF: sub_4C5740+ACj
    xor     eax, eax
    jmp     short loc_4C580D
    ; ---------------------------------------------------------------------------

    loc_4C5808:                             ; CODE XREF: sub_4C5740+A8j
                                            ; sub_4C5740+B8j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4C580D:                             ; CODE XREF: sub_4C5740+C6j
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jnz     short loc_4C581D
    lea     eax, [ebp+4]
    jmp     short loc_4C581F
    ; ---------------------------------------------------------------------------

    loc_4C581D:                             ; CODE XREF: sub_4C5740+97j
                                            ; sub_4C5740+D6j
    xor     eax, eax

    loc_4C581F:                             ; CODE XREF: sub_4C5740+DBj
    test    eax, eax
    jz      short loc_4C582D
    mov     eax, [eax]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C582D:                             ; CODE XREF: sub_4C5740+E1j
    mov     eax, [esp+14h+arg_0]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_4C5740 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C5840(char *)
    sub_4C5840 proc near                    ; CODE XREF: sub_435DA0+37Ep

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    test    edi, edi
    jz      short loc_4C588A
    mov     eax, dword_51FDB8
    test    eax, eax
    jz      short loc_4C588A
    mov     esi, [eax+5]
    mov     ecx, [eax+9]
    cmp     esi, ecx
    jnb     short loc_4C588A

    loc_4C585D:                             ; CODE XREF: sub_4C5840+3Aj
    mov     eax, [esi+4]
    push    edi                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jz      short loc_4C5883
    mov     ecx, dword_51FDB8
    add     esi, 8
    cmp     esi, [ecx+9]
    jb      short loc_4C585D
    xor     eax, eax
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C5883:                             ; CODE XREF: sub_4C5840+2Cj
    mov     eax, [esi]
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C588A:                             ; CODE XREF: sub_4C5840+8j
                                            ; sub_4C5840+11j ...
    pop     edi
    xor     eax, eax
    pop     esi
    retn    4
    sub_4C5840 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C58A0 proc near                    ; CODE XREF: sub_42A8D0+3BDp
                                            ; sub_42BF40+7Bp ...

    var_100= byte ptr -100h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 100h
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+100h+var_100]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, offset byte_51FDC0
    mov     ebp, [esp+110h+arg_8]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+110h+var_100]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb
    mov     esi, [esp+110h+arg_10]
    test    esi, esi
    jz      short loc_4C5968
    mov     ebx, [esp+110h+arg_C]
    mov     edi, [esp+110h+arg_0]
    mov     ebp, [esp+110h+arg_4]
    push    esi                             ; int
    mov     ecx, [edi+4]
    lea     eax, [esp+114h+var_100]
    push    ebx                             ; size_t
    push    eax                             ; char *
    push    ebp                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_4C5948
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4C5948:                             ; CODE XREF: sub_4C58A0+94j
    mov     ecx, [esp+110h+arg_8]
    push    esi                             ; int
    push    ebx                             ; size_t
    push    ecx                             ; char *
    mov     ecx, [edi+4]
    push    ebp                             ; char *
    call    sub_4C48C0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4C5968:                             ; CODE XREF: sub_4C58A0+6Bj
    mov     edi, [esp+110h+arg_C]
    mov     esi, [esp+110h+arg_0]
    mov     ebx, [esp+110h+arg_4]
    push    offset Data                     ; int
    mov     ecx, [esi+4]
    lea     edx, [esp+114h+var_100]
    push    edi                             ; size_t
    push    edx                             ; char *
    push    ebx                             ; char *
    call    sub_4C48C0
    test    eax, eax
    jz      short loc_4C59A7
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4C59A7:                             ; CODE XREF: sub_4C58A0+F3j
    mov     ecx, [esi+4]
    push    offset Data                     ; int
    push    edi                             ; size_t
    push    ebp                             ; char *
    push    ebx                             ; char *
    call    sub_4C48C0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 100h
    retn    14h
    sub_4C58A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C59D0 proc near                    ; CODE XREF: sub_4C54F0+1D3p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    push    ebx
    mov     ebx, [esp+10h+arg_0]
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     edi, ebx
    mov     eax, [esi+8]
    mov     edx, [esi+0Ch]
    mov     ecx, [esi+4]
    sub     edx, eax
    sub     edi, ecx
    sar     edx, 3
    sar     edi, 3
    cmp     edx, 1
    mov     [esp+1Ch+var_4], edi
    jnb     loc_4C5AED
    test    ecx, ecx
    jnz     short loc_4C5A07
    xor     edx, edx
    jmp     short loc_4C5A0E
    ; ---------------------------------------------------------------------------

    loc_4C5A07:                             ; CODE XREF: sub_4C59D0+31j
    mov     edx, eax
    sub     edx, ecx
    sar     edx, 3

    loc_4C5A0E:                             ; CODE XREF: sub_4C59D0+35j
    cmp     edx, 1
    jbe     short loc_4C5A24
    test    ecx, ecx
    jnz     short loc_4C5A1B
    xor     edx, edx
    jmp     short loc_4C5A29
    ; ---------------------------------------------------------------------------

    loc_4C5A1B:                             ; CODE XREF: sub_4C59D0+45j
    mov     edx, eax
    sub     edx, ecx
    sar     edx, 3
    jmp     short loc_4C5A29
    ; ---------------------------------------------------------------------------

    loc_4C5A24:                             ; CODE XREF: sub_4C59D0+41j
    mov     edx, 1

    loc_4C5A29:                             ; CODE XREF: sub_4C59D0+49j
                                            ; sub_4C59D0+52j
    test    ecx, ecx
    jnz     short loc_4C5A31
    xor     eax, eax
    jmp     short loc_4C5A36
    ; ---------------------------------------------------------------------------

    loc_4C5A31:                             ; CODE XREF: sub_4C59D0+5Bj
    sub     eax, ecx
    sar     eax, 3

    loc_4C5A36:                             ; CODE XREF: sub_4C59D0+5Fj
    add     eax, edx
    test    eax, eax
    mov     [esp+1Ch+var_8], eax
    jge     short loc_4C5A42
    xor     eax, eax

    loc_4C5A42:                             ; CODE XREF: sub_4C59D0+6Ej
    shl     eax, 3
    push    eax                             ; int
    call    sub_4B4F10
    mov     edi, [esi+4]

    loc_4C5A4E:                             ; DATA XREF: .data:005110CCo
                                            ; .data:005110D4o
    add     esp, 4
    cmp     edi, ebx
    mov     [esp+1Ch+var_C], eax
    mov     ebp, eax
    jz      short loc_4C5A6C

    loc_4C5A5B:                             ; CODE XREF: sub_4C59D0+9Aj
    push    edi
    push    ebp
    call    sub_4C5D60
    add     edi, 8
    add     ebp, 8
    cmp     edi, ebx
    jnz     short loc_4C5A5B

    loc_4C5A6C:                             ; CODE XREF: sub_4C59D0+89j
    mov     edi, ebp
    mov     [esp+1Ch+arg_0], 1

    loc_4C5A76:                             ; CODE XREF: sub_4C59D0+BDj
    mov     ecx, [esp+1Ch+arg_4]
    push    ecx
    push    edi
    call    sub_4C5D60
    mov     eax, [esp+1Ch+arg_0]
    add     edi, 8
    dec     eax
    mov     [esp+1Ch+arg_0], eax
    jnz     short loc_4C5A76
    mov     edx, [esi+8]
    add     ebp, 8
    push    ebp
    push    edx
    push    ebx
    mov     ecx, esi
    call    sub_4C5BC0
    mov     eax, [esi+8]
    mov     ecx, [esi+4]
    push    eax
    push    ecx
    mov     ecx, esi
    call    sub_4C5B70
    mov     eax, [esi+4]
    push    eax
    call    sub_4B4F20
    mov     edi, [esp+20h+var_C]
    mov     edx, [esp+20h+var_8]
    add     esp, 4
    mov     ecx, esi
    lea     eax, [edi+edx*8]
    mov     [esi+0Ch], eax
    call    sub_4C5BA0
    lea     ecx, [edi+eax*8+8]
    mov     [esi+4], edi
    mov     edi, [esp+1Ch+var_4]
    mov     [esi+8], ecx
    mov     esi, [esi+4]
    lea     eax, [esi+edi*8]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C5AED:                             ; CODE XREF: sub_4C59D0+29j
    mov     edx, eax
    sub     edx, ebx
    sar     edx, 3
    cmp     edx, 1
    jnb     short loc_4C5B2C
    lea     ecx, [ebx+8]
    push    ecx
    push    eax
    push    ebx
    mov     ecx, esi
    call    sub_4C5BC0
    mov     eax, [esi+8]
    mov     ebp, [esp+1Ch+arg_4]
    mov     edx, eax
    mov     ecx, 1
    sub     edx, ebx
    push    ebp
    sar     edx, 3
    sub     ecx, edx
    push    ecx
    push    eax
    mov     ecx, esi
    call    sub_4C5C20
    mov     edx, [esi+8]
    push    ebp
    push    edx
    jmp     short loc_4C5B50
    ; ---------------------------------------------------------------------------

    loc_4C5B2C:                             ; CODE XREF: sub_4C59D0+127j
    push    eax
    push    eax
    add     eax, 0FFFFFFF8h
    mov     ecx, esi
    push    eax
    call    sub_4C5BC0
    mov     eax, [esi+8]
    push    eax
    add     eax, 0FFFFFFF8h
    push    eax
    push    ebx
    call    sub_4C5D10
    mov     eax, [esp+1Ch+arg_4]
    lea     ecx, [ebx+8]
    push    eax
    push    ecx

    loc_4C5B50:                             ; CODE XREF: sub_4C59D0+15Aj
    push    ebx
    call    sub_4C5CD0
    mov     eax, [esi+8]
    add     eax, 8
    mov     [esi+8], eax
    mov     esi, [esi+4]
    lea     eax, [esi+edi*8]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_4C59D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5B70 proc near                    ; CODE XREF: sub_4C59D0+D9p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    cmp     esi, ebx
    jz      short loc_4C5B9B
    push    edi
    lea     edi, [esi+4]

    loc_4C5B82:                             ; CODE XREF: sub_4C5B70+28j
    mov     ecx, edi
    call    sub_4C9390
    mov     ecx, esi
    call    sub_4C9390
    add     esi, 8
    add     edi, 8
    cmp     esi, ebx
    jnz     short loc_4C5B82
    pop     edi

    loc_4C5B9B:                             ; CODE XREF: sub_4C5B70+Cj
    pop     esi
    pop     ebx
    retn    8
    sub_4C5B70 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5BA0 proc near                    ; CODE XREF: sub_4C59D0+FAp
    mov     edx, [ecx+4]
    test    edx, edx
    jnz     short loc_4C5BAA
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_4C5BAA:                             ; CODE XREF: sub_4C5BA0+5j
    mov     eax, [ecx+8]
    sub     eax, edx
    sar     eax, 3
    retn
    sub_4C5BA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5BC0 proc near                    ; CODE XREF: sub_4C59D0+CAp
                                            ; sub_4C59D0+131p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    push    ebx
    push    esi
    mov     esi, [esp+8+arg_0]
    cmp     esi, eax
    jz      short loc_4C5C0C
    mov     ebx, [esp+8+arg_8]
    push    edi
    push    ebp
    lea     ebp, [esi+4]
    lea     edi, [ebx+4]

    loc_4C5BDA:                             ; CODE XREF: sub_4C5BC0+41j
    cmp     edi, 4
    jz      short loc_4C5BEF
    push    esi
    mov     ecx, ebx
    call    sub_4C91A0
    push    ebp
    mov     ecx, edi
    call    sub_4C91A0

    loc_4C5BEF:                             ; CODE XREF: sub_4C5BC0+1Dj
    mov     eax, [esp+10h+arg_4]
    add     esi, 8
    add     ebx, 8
    add     edi, 8
    add     ebp, 8
    cmp     esi, eax
    jnz     short loc_4C5BDA
    pop     ebp
    pop     edi
    mov     eax, ebx
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C5C0C:                             ; CODE XREF: sub_4C5BC0+Cj
    mov     ebx, [esp+8+arg_8]
    pop     esi
    mov     eax, ebx
    pop     ebx
    retn    0Ch
    sub_4C5BC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5C20 proc near                    ; CODE XREF: sub_4C59D0+150p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebp
    mov     ebp, [esp+arg_4]
    test    ebp, ebp
    jbe     short loc_4C5C5B
    push    edi
    mov     edi, [esp+4+arg_0]
    push    esi
    push    ebx
    mov     ebx, [esp+0Ch+arg_8]
    lea     esi, [edi+4]

    loc_4C5C37:                             ; CODE XREF: sub_4C5C20+36j
    cmp     esi, 4
    jz      short loc_4C5C4F
    push    ebx
    mov     ecx, edi
    call    sub_4C91A0
    lea     eax, [ebx+4]
    mov     ecx, esi
    push    eax
    call    sub_4C91A0

    loc_4C5C4F:                             ; CODE XREF: sub_4C5C20+1Aj
    add     edi, 8
    add     esi, 8
    dec     ebp
    jnz     short loc_4C5C37
    pop     ebx
    pop     esi
    pop     edi

    loc_4C5C5B:                             ; CODE XREF: sub_4C5C20+7j
    pop     ebp
    retn    0Ch
    sub_4C5C20 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5C60 proc near                    ; CODE XREF: sub_4C54F0+160p

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [ecx+9]
    push    edi
    mov     edi, [ecx+5]
    cmp     edi, ebx
    jz      short loc_4C5CC5
    push    esi
    push    ebp

    loc_4C5C6E:                             ; CODE XREF: sub_4C5C60+61j
    mov     eax, ebx
    mov     esi, [esp+0Ch+arg_0]
    sub     eax, edi
    sar     eax, 3
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     ebp, [edi+eax*8]
    mov     eax, [edi+eax*8]

    loc_4C5C84:                             ; CODE XREF: sub_4C5C60+42j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4C5CA8
    test    cl, cl
    jz      short loc_4C5CA4
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4C5CA8
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4C5C84

    loc_4C5CA4:                             ; CODE XREF: sub_4C5C60+2Ej
    xor     eax, eax
    jmp     short loc_4C5CAD
    ; ---------------------------------------------------------------------------

    loc_4C5CA8:                             ; CODE XREF: sub_4C5C60+2Aj
                                            ; sub_4C5C60+38j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4C5CAD:                             ; CODE XREF: sub_4C5C60+46j
    xor     ecx, ecx
    test    eax, eax
    setl    cl
    test    cl, cl
    jz      short loc_4C5CBD
    lea     edi, [ebp+8]
    jmp     short loc_4C5CBF
    ; ---------------------------------------------------------------------------

    loc_4C5CBD:                             ; CODE XREF: sub_4C5C60+56j
    mov     ebx, ebp

    loc_4C5CBF:                             ; CODE XREF: sub_4C5C60+5Bj
    cmp     edi, ebx
    jnz     short loc_4C5C6E
    pop     ebp
    pop     esi

    loc_4C5CC5:                             ; CODE XREF: sub_4C5C60+Aj
    mov     eax, edi
    pop     edi
    pop     ebx
    retn    4
    sub_4C5C60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5CD0 proc near                    ; CODE XREF: sub_4C59D0+181p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    cmp     esi, eax
    jz      short loc_4C5D09
    push    edi
    push    ebp
    push    ebx
    mov     ebx, [esp+10h+arg_8]
    lea     edi, [esi+4]
    lea     ebp, [ebx+4]

    loc_4C5CEA:                             ; CODE XREF: sub_4C5CD0+34j
    push    ebx
    mov     ecx, esi
    call    sub_4C93B0
    push    ebp
    mov     ecx, edi
    call    sub_4C93B0
    add     esi, 8
    add     edi, 8
    cmp     esi, [esp+10h+arg_4]
    jnz     short loc_4C5CEA
    pop     ebx
    pop     ebp
    pop     edi

    loc_4C5D09:                             ; CODE XREF: sub_4C5CD0+Bj
    pop     esi
    retn    0Ch
    sub_4C5CD0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5D10 proc near                    ; CODE XREF: sub_4C59D0+172p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_4]
    push    edi
    cmp     eax, esi
    jz      short loc_4C5D55
    mov     edi, [esp+8+arg_8]
    push    ebp
    push    ebx
    lea     ebx, [esi+4]
    lea     ebp, [edi+4]

    loc_4C5D2A:                             ; CODE XREF: sub_4C5D10+3Aj
    sub     esi, 8
    sub     edi, 8
    push    esi
    mov     ecx, edi
    sub     ebx, 8
    sub     ebp, 8
    call    sub_4C93B0
    push    ebx
    mov     ecx, ebp
    call    sub_4C93B0
    cmp     esi, [esp+10h+arg_0]
    jnz     short loc_4C5D2A
    pop     ebx
    pop     ebp
    mov     eax, edi
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C5D55:                             ; CODE XREF: sub_4C5D10+Cj
    mov     edi, [esp+8+arg_8]
    mov     eax, edi
    pop     edi
    pop     esi
    retn    0Ch
    sub_4C5D10 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5D60 proc near                    ; CODE XREF: sub_4C59D0+8Dp
                                            ; sub_4C59D0+ACp

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jz      short loc_4C5D83
    push    edi
    mov     edi, [esp+4+arg_4]
    push    edi
    mov     ecx, esi
    call    sub_4C91A0
    add     edi, 4
    lea     ecx, [esi+4]
    push    edi
    call    sub_4C91A0
    pop     edi

    loc_4C5D83:                             ; CODE XREF: sub_4C5D60+7j
    pop     esi
    retn    8
    sub_4C5D60 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, dword_51FE00
    cmp     eax, 0Ah
    jge     short locret_4C5DB1
    mov     ecx, [esp+4]
    mov     dl, [esp+8]
    lea     eax, [eax+eax*4]
    mov     dword_51FE08[eax], ecx
    mov     byte_51FE0C[eax], dl

    locret_4C5DB1:                          ; CODE XREF: .text:004C5D98j
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short locret_4C5DCF
    dec     eax
    mov     dword_51FE00, eax

    locret_4C5DCF:                          ; CODE XREF: .text:004C5DC7j
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, dword_51FE00
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5DF0 proc near                    ; CODE XREF: sub_4CBAB0+72p
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short locret_4C5E2D
    push    esi

    loc_4C5DFA:                             ; CODE XREF: sub_4C5DF0+3Aj
    mov     esi, eax
    lea     eax, [eax+eax*4]
    mov     cl, byte_51FE0C[eax]
    test    cl, cl
    jz      short loc_4C5E2E
    mov     eax, [eax+51FE03h]
    push    0
    push    0
    push    eax
    call    sub_4C60D0

    loc_4C5E19:                             ; CODE XREF: sub_4C5DF0+48j
                                            ; sub_4C5DF0+52j ...
    mov     eax, dword_51FE00

    loc_4C5E1E:                             ; CODE XREF: sub_4C5DF0+72j
                                            ; sub_4C5DF0+7Aj
    cmp     esi, eax
    jnz     short loc_4C5E28
    dec     eax
    mov     dword_51FE00, eax

    loc_4C5E28:                             ; CODE XREF: sub_4C5DF0+30j
    test    eax, eax
    jg      short loc_4C5DFA
    pop     esi

    locret_4C5E2D:                          ; CODE XREF: sub_4C5DF0+7j
    retn
    ; ---------------------------------------------------------------------------

    loc_4C5E2E:                             ; CODE XREF: sub_4C5DF0+17j
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C5E19
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C5E19
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jz      short loc_4C5E19
    mov     eax, ecx
    push    0
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C5E1E
    dec     eax
    mov     dword_51FE00, eax
    jmp     short loc_4C5E1E
    sub_4C5DF0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5E70 proc near                    ; CODE XREF: .text:0045FBFBp
                                            ; sub_497F40+66Fp ...

    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_5C= dword ptr -5Ch
    var_10= dword ptr -10h
    arg_0= dword ptr  4

    sub     esp, 6Ch
    push    esi
    push    edi
    call    sub_4B6220
    mov     esi, eax
    mov     eax, [esi+0DCh]
    test    eax, eax
    jz      short loc_4C5EA4
    mov     esi, [esi+0BCh]
    mov     edi, [esp+74h+arg_0]
    mov     ecx, 0Ch
    mov     eax, 1
    rep movsd
    pop     edi
    pop     esi
    add     esp, 6Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C5EA4:                             ; CODE XREF: sub_4C5E70+14j
    mov     eax, [esi+44h]
    test    eax, eax
    jz      short loc_4C5EC6
    mov     edi, [esp+74h+arg_0]
    add     esi, 50h
    mov     ecx, 0Ch
    mov     eax, 1
    rep movsd
    pop     edi
    pop     esi
    add     esp, 6Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C5EC6:                             ; CODE XREF: sub_4C5E70+39j
    mov     eax, [esi+8Ch]
    test    eax, eax
    jnz     short loc_4C5EDA
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 6Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C5EDA:                             ; CODE XREF: sub_4C5E70+5Ej
    mov     eax, [esi+8Ch]
    push    0
    lea     edx, [esp+78h+var_6C]
    push    801h
    mov     [esp+7Ch+var_6C], 6Ch
    mov     ecx, [eax]
    push    edx
    push    0
    push    eax
    call    dword ptr [ecx+64h]
    test    eax, eax
    jz      short loc_4C5F0A
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 6Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C5F0A:                             ; CODE XREF: sub_4C5E70+8Ej
    mov     eax, [esp+74h+arg_0]
    mov     ecx, [esi+0D4h]
    add     esi, 0A0h
    mov     edi, [eax+2Ch]
    mov     [eax], ecx
    mov     edx, [esi+38h]
    mov     ecx, [esp+74h+var_5C]
    mov     [eax+4], edx
    mov     edx, [esp+2Ch]
    and     edi, 0FFFFFFFEh
    mov     [eax+8], ecx
    mov     [eax+0Ch], edx
    mov     word ptr [eax+18h], 0
    mov     word ptr [eax+1Ah], 0
    mov     dword ptr [eax+10h], 2710h
    mov     dword ptr [eax+14h], 0FFFFFFFFh
    mov     [eax+2Ch], edi
    mov     edx, [esi]
    lea     ecx, [eax+1Ch]
    mov     [eax+1Ch], edx
    mov     edx, [esi+4]
    mov     [ecx+4], edx
    mov     edx, [esi+8]
    mov     [ecx+8], edx
    mov     edx, [esi+0Ch]
    mov     [ecx+0Ch], edx
    mov     ecx, dword_51FE00
    cmp     ecx, 0Ah
    jge     short loc_4C5F88
    lea     ecx, [ecx+ecx*4]
    mov     dword_51FE08[ecx], eax
    mov     byte_51FE0C[ecx], 0

    loc_4C5F88:                             ; CODE XREF: sub_4C5E70+106j
    pop     edi
    mov     eax, 1
    pop     esi
    add     esp, 6Ch
    retn    4
    sub_4C5E70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5FA0 proc near                    ; CODE XREF: .text:0045FC22p
                                            ; sub_497F40+D68p ...
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C5FE5
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C5FE5
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jnz     short loc_4C5FC5
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C5FC5:                             ; CODE XREF: sub_4C5FA0+1Ej
    mov     eax, [eax+8Ch]
    push    0
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C5FE5
    dec     eax
    mov     dword_51FE00, eax

    loc_4C5FE5:                             ; CODE XREF: sub_4C5FA0+Aj
                                            ; sub_4C5FA0+14j ...
    mov     eax, 1
    retn    4
    sub_4C5FA0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C5FF0 proc near                    ; CODE XREF: .text:004C23FEp
                                            ; .text:004C24CBp ...

    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_5C= dword ptr -5Ch
    var_10= dword ptr -10h
    arg_0= dword ptr  4

    sub     esp, 6Ch
    push    esi
    push    edi
    call    sub_4B6220
    mov     esi, eax
    xor     edi, edi
    cmp     [esi+44h], edi
    jz      short loc_4C601E
    mov     edi, [esp+74h+arg_0]
    add     esi, 50h
    mov     ecx, 0Ch
    mov     eax, 1
    rep movsd
    pop     edi
    pop     esi
    add     esp, 6Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C601E:                             ; CODE XREF: sub_4C5FF0+11j
    cmp     [esi+88h], edi
    jnz     short loc_4C6030
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 6Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C6030:                             ; CODE XREF: sub_4C5FF0+34j
    mov     eax, [esi+88h]
    push    edi
    lea     edx, [esp+78h+var_6C]
    push    1
    mov     [esp+7Ch+var_6C], 6Ch
    mov     ecx, [eax]
    push    edx
    push    edi
    push    eax
    call    dword ptr [ecx+64h]
    test    eax, eax
    jz      short loc_4C605B
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 6Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C605B:                             ; CODE XREF: sub_4C5FF0+5Fj
    mov     eax, [esp+74h+arg_0]
    mov     ecx, [esi+0D4h]
    add     esi, 0A0h
    mov     [eax], ecx
    mov     ecx, [esp+74h+var_5C]
    mov     edx, [esi+38h]
    mov     [eax+8], ecx
    mov     ecx, [eax+2Ch]
    mov     [eax+4], edx
    mov     edx, [esp+2Ch]
    and     ecx, 0FFFFFFFEh
    mov     [eax+0Ch], edx
    mov     [eax+18h], di
    mov     [eax+1Ah], di
    mov     dword ptr [eax+10h], 2710h
    mov     dword ptr [eax+14h], 0FFFFFFFFh
    mov     [eax+2Ch], ecx
    mov     ecx, [esi]
    add     eax, 1Ch
    pop     edi
    mov     [eax], ecx
    mov     edx, [esi+4]
    mov     [eax+4], edx
    mov     ecx, [esi+8]
    mov     [eax+8], ecx
    mov     edx, [esi+0Ch]
    pop     esi
    mov     [eax+0Ch], edx
    mov     eax, 1
    add     esp, 6Ch
    retn    4
    sub_4C5FF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C60D0 proc near                    ; CODE XREF: .text:004C2454p
                                            ; .text:004C25CEp ...

    arg_4= dword ptr  18h
    arg_8= dword ptr  1Ch

    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     esi, eax
    mov     eax, [esi+44h]
    test    eax, eax
    jz      loc_4C6175
    mov     eax, [esi+40h]
    push    eax                             ; hWnd
    call    ds:GetDC
    mov     ecx, [esi+4Ch]
    mov     edi, eax
    push    0                               ; BOOL
    push    ecx                             ; HPALETTE
    push    edi                             ; HDC
    call    ds:SelectPalette
    push    edi                             ; HDC
    call    ds:RealizePalette
    mov     ebx, ds:BitBlt
    mov     eax, [esp+arg_4]
    test    eax, eax
    jz      short loc_4C6135
    mov     ecx, [eax+4]
    mov     edx, [eax]
    mov     ebp, [esi+48h]
    push    0CC0020h                        ; DWORD
    push    ecx                             ; int
    push    edx                             ; int
    push    ebp                             ; HDC
    mov     ebp, [eax+0Ch]
    mov     eax, [eax+8]
    sub     ebp, ecx
    sub     eax, edx
    push    ebp                             ; int
    push    eax                             ; int
    push    ecx                             ; int
    push    edx                             ; int
    push    edi                             ; HDC
    call    ebx ; BitBlt

    loc_4C6135:                             ; CODE XREF: sub_4C60D0+42j
    mov     eax, [esp+arg_8]
    test    eax, eax
    jz      short loc_4C615E
    mov     ecx, [eax+4]
    mov     edx, [eax]
    mov     ebp, [esi+48h]
    push    0CC0020h                        ; DWORD
    push    ecx                             ; int
    push    edx                             ; int
    push    ebp                             ; HDC
    mov     ebp, [eax+0Ch]
    mov     eax, [eax+8]
    sub     ebp, ecx
    sub     eax, edx
    push    ebp                             ; int
    push    eax                             ; int
    push    ecx                             ; int
    push    edx                             ; int
    push    edi                             ; HDC
    call    ebx ; BitBlt

    loc_4C615E:                             ; CODE XREF: sub_4C60D0+6Bj
    mov     ecx, [esi+40h]
    push    edi                             ; hDC
    push    ecx                             ; hWnd
    call    ds:ReleaseDC
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C6175:                             ; CODE XREF: sub_4C60D0+10j
    mov     eax, [esi+88h]
    test    eax, eax
    jnz     short loc_4C6188
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C6188:                             ; CODE XREF: sub_4C60D0+ADj
    mov     esi, [esi+88h]
    push    0
    push    esi
    mov     edx, [esi]
    call    dword ptr [edx+80h]
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    retn    0Ch
    sub_4C60D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C61B0 proc near                    ; CODE XREF: sub_491200+148p
                                            ; sub_4956C0+75p ...

    arg_0= dword ptr  8

    push    ebx
    call    sub_4B6220
    mov     edx, [esp+arg_0]
    mov     cx, [eax+0F0h]
    mov     bl, dl
    xor     bl, cl
    and     ebx, 1
    xor     ebx, ecx
    test    edx, edx
    mov     [eax+0F0h], bx
    jz      short loc_4C61E5
    mov     ecx, [eax+9Ch]
    test    ecx, ecx
    jnz     short loc_4C61E5
    xor     eax, eax
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C61E5:                             ; CODE XREF: sub_4C61B0+23j
                                            ; sub_4C61B0+2Dj
    mov     eax, 1
    pop     ebx
    retn    4
    sub_4C61B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C61F0 proc near                    ; CODE XREF: .text:00490AF6p
                                            ; .text:00490B26p ...

    arg_0= dword ptr  4

    call    sub_4B6220
    mov     ecx, [esp+arg_0]
    mov     [eax+98h], ecx
    retn    4
    sub_4C61F0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 30h
    push    ebx
    call    sub_4B6220
    mov     ebx, eax
    mov     eax, [ebx+44h]
    test    eax, eax
    jz      short loc_4C622B
    xor     eax, eax
    pop     ebx
    add     esp, 30h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C622B:                             ; CODE XREF: .text:004C6220j
    push    edi
    mov     edi, [esp+3Ch]
    push    esi
    mov     eax, [edi+4]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+6Ch]
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4C62AA
    mov     eax, [edi+8]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+6Ch]
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4C62AA
    lea     eax, [esp+0Ch]
    push    eax
    call    sub_4C5E70
    mov     ecx, [ebx+98h]
    push    esi
    push    esi
    lea     edx, [esp+14h]
    push    ecx
    push    edx
    call    sub_4CBBE0
    add     esp, 10h
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C62AA
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C62AA
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jz      short loc_4C62AA
    mov     eax, ecx
    push    esi
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C62AA
    dec     eax
    mov     dword_51FE00, eax

    loc_4C62AA:                             ; CODE XREF: .text:004C623Ej
                                            ; .text:004C624Dj ...
    mov     eax, esi
    pop     esi
    pop     edi
    pop     ebx
    add     esp, 30h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C62C0 proc near                    ; CODE XREF: .text:00490B2Bj
                                            ; sub_4916A0+DCp ...

    var_3C= dword ptr -3Ch

    sub     esp, 30h
    push    esi
    call    sub_4B6220
    mov     esi, eax
    mov     al, [esi+0F0h]
    shr     al, 1
    test    al, 1
    jz      loc_4C638C
    mov     eax, [esi+88h]
    push    edi
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+60h]
    cmp     eax, 887601C2h
    jnz     loc_4C637F
    call    sub_4B6220
    mov     edi, eax
    mov     eax, [edi+44h]
    test    eax, eax
    jnz     short loc_4C637F
    mov     eax, [esi+88h]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+6Ch]
    test    eax, eax
    jnz     short loc_4C637F
    mov     eax, [esi+8Ch]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+6Ch]
    test    eax, eax
    jnz     short loc_4C637F
    lea     edx, [esp+8]
    push    edx
    call    sub_4C5E70
    mov     eax, [edi+98h]
    push    0
    push    0
    lea     ecx, [esp+10h]
    push    eax
    push    ecx
    call    sub_4CBBE0
    add     esp, 10h
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C637F
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C637F
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jz      short loc_4C637F
    mov     eax, ecx
    push    0
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C637F
    dec     eax
    mov     dword_51FE00, eax

    loc_4C637F:                             ; CODE XREF: sub_4C62C0+2Dj
                                            ; sub_4C62C0+3Fj ...
    mov     eax, [esi+8Ch]
    pop     edi
    mov     [esi+0B4h], eax

    loc_4C638C:                             ; CODE XREF: sub_4C62C0+15j
    mov     dword ptr [esi+0DCh], 0
    pop     esi
    add     esp, 30h
    retn
    sub_4C62C0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C63A0 proc near                    ; CODE XREF: sub_41F0A0+1Dp
                                            ; .text:0041F7D5p ...

    var_108= dword ptr -108h
    dy= dword ptr -0F4h
    rc= tagRECT ptr -0ECh
    var_DC= dword ptr -0DCh
    var_D8= dword ptr -0D8h
    var_D4= dword ptr -0D4h
    var_D0= dword ptr -0D0h
    var_BC= dword ptr -0BCh
    var_B8= dword ptr -0B8h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_5C= dword ptr -5Ch

    sub     esp, 0F4h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     esi, eax
    mov     ax, [esi+0F0h]
    test    al, 2
    jnz     loc_4C6475
    mov     ebp, ds:InterlockedExchange
    mov     ebx, ds:WaitForSingleObject
    mov     edi, 4D41494Eh

    loc_4C63D1:                             ; CODE XREF: sub_4C63A0+4Fj
    push    edi                             ; Value
    push    offset Target                   ; Target
    call    ebp ; InterlockedExchange
    test    eax, eax
    jz      short loc_4C63F1
    cmp     dword_52A4EC, edi
    jz      short loc_4C6401
    mov     eax, hHandle
    push    0FFFFFFFFh                      ; dwMilliseconds
    push    eax                             ; hHandle
    call    ebx ; WaitForSingleObject
    jmp     short loc_4C63D1
    ; ---------------------------------------------------------------------------

    loc_4C63F1:                             ; CODE XREF: sub_4C63A0+3Bj
    mov     dword_52A4EC, edi
    mov     [esp+104h+dy], 0
    jmp     short loc_4C6405
    ; ---------------------------------------------------------------------------

    loc_4C6401:                             ; CODE XREF: sub_4C63A0+43j
    mov     [esp+104h+dy], eax

    loc_4C6405:                             ; CODE XREF: sub_4C63A0+5Fj
    mov     ecx, [esi+0BCh]
    push    0
    lea     ebx, [esi+50h]
    push    0
    push    ecx
    push    ebx
    call    sub_4C6B70
    push    ebx
    push    esi
    call    sub_4C67C0
    mov     edx, [esi+40h]
    push    edx                             ; hWnd
    call    ds:GetDC
    mov     edi, eax
    mov     eax, [esi+4Ch]
    push    0                               ; BOOL
    push    eax                             ; HPALETTE
    push    edi                             ; HDC
    call    ds:SelectPalette
    push    edi                             ; HDC
    call    ds:RealizePalette
    mov     ecx, [esi+48h]
    mov     edx, [esi+54h]
    mov     eax, [ebx]
    push    0CC0020h                        ; DWORD
    push    0                               ; int
    push    0                               ; int
    push    ecx                             ; HDC
    push    edx                             ; int
    push    eax                             ; int
    push    0                               ; int
    push    0                               ; int
    push    edi                             ; HDC
    call    ds:BitBlt
    mov     ecx, [esi+40h]
    push    edi                             ; hDC
    push    ecx                             ; hWnd
    call    ds:ReleaseDC
    mov     eax, [esp+104h+dy]
    test    eax, eax
    jmp     loc_4C6639
    ; ---------------------------------------------------------------------------

    loc_4C6475:                             ; CODE XREF: sub_4C63A0+1Aj
    mov     ecx, [esi+0DCh]
    xor     ebp, ebp
    cmp     ecx, ebp
    jz      loc_4C666A
    mov     edi, [esi+0BCh]
    mov     [esp+104h+dy], edi
    call    sub_4B6700
    cmp     [edi], eax
    jnz     loc_4C67B0
    call    sub_4B6710
    cmp     [edi+4], eax
    jnz     loc_4C67B0
    mov     ebp, ds:InterlockedExchange
    mov     ebx, ds:WaitForSingleObject
    mov     edi, 4D41494Eh

    loc_4C64BB:                             ; CODE XREF: sub_4C63A0+139j
    push    edi                             ; Value
    push    offset Target                   ; Target
    call    ebp ; InterlockedExchange
    test    eax, eax
    jz      short loc_4C64DB
    cmp     dword_52A4EC, edi
    jz      short loc_4C64E5
    mov     eax, hHandle
    push    0FFFFFFFFh                      ; dwMilliseconds
    push    eax                             ; hHandle
    call    ebx ; WaitForSingleObject
    jmp     short loc_4C64BB
    ; ---------------------------------------------------------------------------

    loc_4C64DB:                             ; CODE XREF: sub_4C63A0+125j
    mov     dword_52A4EC, edi
    xor     ebx, ebx
    jmp     short loc_4C64E7
    ; ---------------------------------------------------------------------------

    loc_4C64E5:                             ; CODE XREF: sub_4C63A0+12Dj
    mov     ebx, eax

    loc_4C64E7:                             ; CODE XREF: sub_4C63A0+143j
    mov     eax, [esi+88h]
    push    0
    lea     edx, [esp+108h+var_6C]
    push    1
    mov     [esp+10Ch+var_6C], 6Ch
    mov     ecx, [eax]
    push    edx
    push    0
    push    eax
    call    dword ptr [ecx+64h]
    test    eax, eax
    jnz     loc_4C65A0
    mov     eax, [esi+0D4h]
    mov     edi, [esp+104h+dy]
    mov     ecx, [esi+0D8h]
    mov     edx, [esp+104h+var_5C]
    mov     [esp+38h], eax
    mov     eax, [esp+0BCh]
    push    edi
    push    esi
    mov     [esp+44h], ecx
    mov     [esp+48h], edx
    mov     [esp+4Ch], eax
    call    sub_4C67C0
    push    0
    push    0
    lea     ecx, [esp+40h]
    push    edi
    push    ecx
    call    sub_4CBBE0
    mov     eax, [esi+1CEh]
    add     esp, 10h
    test    eax, eax
    jz      short loc_4C658A
    mov     eax, [esi+1D2h]
    test    eax, eax
    jz      short loc_4C658A
    mov     edx, [esi+1BAh]
    mov     eax, [esi+1B6h]
    mov     ecx, [esi+1BEh]
    push    edx
    push    eax
    push    ecx
    push    edi
    call    sub_4C6B70

    loc_4C658A:                             ; CODE XREF: sub_4C63A0+1C3j
                                            ; sub_4C63A0+1CDj
    mov     esi, [esi+88h]
    push    0
    push    esi
    mov     edx, [esi]
    call    dword ptr [edx+80h]
    jmp     loc_4C6637
    ; ---------------------------------------------------------------------------

    loc_4C65A0:                             ; CODE XREF: sub_4C63A0+16Ej
    cmp     eax, 887601C2h
    jnz     loc_4C6637
    call    sub_4B6220
    mov     edi, eax
    mov     eax, [edi+44h]
    test    eax, eax
    jnz     short loc_4C6637
    mov     eax, [esi+88h]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+6Ch]
    test    eax, eax
    jnz     short loc_4C6637
    mov     esi, [esi+8Ch]
    push    esi
    mov     edx, [esi]
    call    dword ptr [edx+6Ch]
    test    eax, eax
    jnz     short loc_4C6637
    lea     eax, [esp+68h]
    push    eax
    call    sub_4C5E70
    mov     ecx, [edi+98h]
    push    0
    push    0
    lea     edx, [esp+70h]
    push    ecx
    push    edx
    call    sub_4CBBE0
    add     esp, 10h
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C6637
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C6637
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jz      short loc_4C6637
    mov     eax, ecx
    push    0
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C6637
    dec     eax
    mov     dword_51FE00, eax

    loc_4C6637:                             ; CODE XREF: sub_4C63A0+1FBj
                                            ; sub_4C63A0+205j ...
    test    ebx, ebx

    loc_4C6639:                             ; CODE XREF: sub_4C63A0+D0j
    jnz     loc_4C67B0
    push    0                               ; Value
    push    offset Target                   ; Target
    mov     dword_52A4EC, 0
    call    ebp ; InterlockedExchange
    mov     edx, hHandle
    push    edx                             ; hEvent
    call    ds:SetEvent
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0F4h
    retn
    ; ---------------------------------------------------------------------------

    loc_4C666A:                             ; CODE XREF: sub_4C63A0+DFj
    cmp     [esi+9Ch], ebp
    jz      short loc_4C6690
    test    al, 1
    jz      short loc_4C6690
    mov     esi, [esi+88h]
    push    1
    push    ebp
    push    esi
    mov     eax, [esi]
    call    dword ptr [eax+2Ch]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0F4h
    retn
    ; ---------------------------------------------------------------------------

    loc_4C6690:                             ; CODE XREF: sub_4C63A0+2D0j
                                            ; sub_4C63A0+2D4j
    mov     edx, [esi+40h]
    lea     ecx, [esp+104h+rc]
    push    ecx                             ; lpRect
    push    edx                             ; hWnd
    call    ds:GetClientRect                ; Get the coordinates of a window's client area
    mov     [esp+104h+dy], ebp
    mov     [esp+14h], ebp
    mov     ecx, [esp+104h+rc.top]
    mov     edx, [esp+104h+rc.right]
    mov     eax, [esp+104h+rc.left]
    mov     [esp+104h+var_D8], ecx
    mov     [esp+104h+var_D4], edx
    mov     edx, [esi+40h]
    lea     ecx, [esp+104h+dy]
    mov     [esp+104h+var_DC], eax
    mov     eax, [esp+104h+rc.bottom]
    push    ecx                             ; lpPoint
    push    edx                             ; hWnd
    mov     [esp+10Ch+var_D0], eax
    call    ds:ClientToScreen               ; Convert the client coordinates of a
                                            ; specified point to screen coordinates.
    lea     edx, [esp+104h+rc]
    mov     eax, [esp+14h]
    mov     ecx, [esp+104h+dy]
    push    eax                             ; dy
    push    ecx                             ; dx
    push    edx                             ; lprc
    call    ds:OffsetRect                   ; Move the specified rectangle by
                                            ; the specified offsets

    loc_4C66EB:                             ; CODE XREF: sub_4C63A0+37Bj
                                            ; sub_4C63A0+39Dj ...
    mov     eax, [esi+88h]
    push    ebp
    lea     edx, [esp+108h+var_DC]
    push    1000000h
    mov     ecx, [eax]
    push    edx
    mov     edx, [esi+8Ch]
    push    edx
    lea     edx, [esp+114h+rc]
    push    edx
    push    eax
    call    dword ptr [ecx+14h]
    cmp     eax, ebp
    jz      loc_4C67B0
    cmp     eax, 887601C2h
    jnz     short loc_4C66EB
    call    sub_4B6220
    mov     ebx, eax
    cmp     [ebx+44h], ebp
    jz      short loc_4C672D
    xor     edi, edi
    jmp     short loc_4C67A8
    ; ---------------------------------------------------------------------------

    loc_4C672D:                             ; CODE XREF: sub_4C63A0+387j
    mov     eax, [esi+88h]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+6Ch]
    mov     edi, eax
    cmp     edi, ebp
    jnz     short loc_4C66EB
    mov     eax, [esi+8Ch]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+6Ch]
    mov     edi, eax
    cmp     edi, ebp
    jnz     short loc_4C66EB
    lea     eax, [esp+68h]
    push    eax
    call    sub_4C5E70
    mov     ecx, [ebx+98h]
    push    ebp
    push    ebp
    lea     edx, [esp+70h]
    push    ecx
    push    edx
    call    sub_4CBBE0
    add     esp, 10h
    call    sub_4B6220
    cmp     [eax+44h], ebp
    jnz     short loc_4C67A8
    cmp     [eax+0DCh], ebp
    jnz     short loc_4C67A8
    mov     ecx, [eax+8Ch]
    cmp     ecx, ebp
    jz      short loc_4C67A8
    mov     eax, ecx
    push    ebp
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+80h]
    mov     eax, dword_51FE00
    cmp     eax, ebp
    jle     short loc_4C67A8
    dec     eax
    mov     dword_51FE00, eax

    loc_4C67A8:                             ; CODE XREF: sub_4C63A0+38Bj
                                            ; sub_4C63A0+3D9j ...
    cmp     edi, ebp
    jnz     loc_4C66EB

    loc_4C67B0:                             ; CODE XREF: sub_4C63A0+F6j
                                            ; sub_4C63A0+104j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0F4h
    retn
    sub_4C63A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C67C0 proc near                    ; CODE XREF: sub_4C63A0+7Bp
                                            ; sub_4C63A0+1A4p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_0]
    mov     eax, [esi+1CEh]
    test    eax, eax
    jz      loc_4C6883
    mov     eax, [esi+1D2h]
    test    eax, eax
    jz      loc_4C6883
    mov     eax, [esi+1B2h]
    test    eax, eax
    jz      loc_4C6883
    mov     edx, [esi+1BEh]
    xor     ecx, ecx
    mov     cx, [eax]
    push    edi
    mov     [edx], ecx
    mov     eax, [esi+1B2h]
    mov     edx, [esi+1BEh]
    xor     ecx, ecx
    mov     cx, [eax+2]
    mov     edi, [esp+4+arg_4]
    mov     [edx+4], ecx
    mov     eax, [esi+1B2h]
    mov     edx, [esi+1BEh]
    xor     ecx, ecx
    mov     cx, [eax]
    mov     [edx+8], ecx
    mov     eax, [esi+1B2h]
    mov     edx, [esi+196h]
    movsx   ecx, word ptr [eax+4]
    sub     edx, ecx
    mov     [esi+1B6h], edx
    movsx   ecx, word ptr [eax+6]
    mov     eax, [esi+19Ah]
    sub     eax, ecx
    mov     [esi+1BAh], eax
    neg     eax
    neg     edx
    push    eax
    mov     eax, [esi+1BEh]
    push    edx
    push    edi
    push    eax
    call    sub_4C6B70
    mov     ecx, [esi+19Ah]
    mov     edx, [esi+196h]
    mov     eax, [esi+1B2h]
    push    ecx
    push    edx
    push    eax
    push    edi
    call    sub_4B7F90
    pop     edi

    loc_4C6883:                             ; CODE XREF: sub_4C67C0+Dj
                                            ; sub_4C67C0+1Bj ...
    pop     esi
    retn    8
    sub_4C67C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6890 proc near                    ; CODE XREF: sub_41F0A0+18p
                                            ; sub_4257A0+15p ...

    var_64= dword ptr -64h
    var_14= dword ptr -14h
    arg_0= dword ptr  4
    arg_4= byte ptr  8

    sub     esp, 64h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     esi, [esp+74h+arg_0]
    mov     edx, eax
    test    esi, esi
    mov     ebp, 1
    jnz     short loc_4C6922
    mov     eax, [edx+0DCh]
    test    eax, eax
    jz      short loc_4C68CB
    mov     edx, [edx+0BCh]
    mov     al, [esp+74h+arg_4]
    mov     ecx, [edx+4]
    mov     edi, [edx+0Ch]
    imul    ecx, [edx+8]
    jmp     short loc_4C6936
    ; ---------------------------------------------------------------------------

    loc_4C68CB:                             ; CODE XREF: sub_4C6890+23j
    test    byte ptr [edx+0F0h], 2
    jnz     short loc_4C68E4
    mov     ecx, [edx+54h]
    mov     al, [esp+74h+arg_4]
    imul    ecx, [edx+58h]
    mov     edi, [edx+5Ch]
    jmp     short loc_4C6936
    ; ---------------------------------------------------------------------------

    loc_4C68E4:                             ; CODE XREF: sub_4C6890+42j
    mov     eax, dword ptr [esp+74h+arg_4]
    mov     edx, [edx+8Ch]
    mov     [esp+74h+var_14], eax
    lea     eax, [esp+74h+var_64]
    push    eax
    push    1000400h
    push    0
    mov     [esp+80h+var_64], 64h
    mov     ecx, [edx]
    push    0
    push    0
    push    edx
    call    dword ptr [ecx+14h]
    test    eax, eax
    jz      short loc_4C698E
    xor     ebp, ebp
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C6922:                             ; CODE XREF: sub_4C6890+19j
    test    byte ptr [esi+2Ch], 1
    jz      short loc_4C695C
    mov     ecx, [esi+8]
    mov     al, [esp+74h+arg_4]
    imul    ecx, [esi+4]
    mov     edi, [esi+0Ch]

    loc_4C6936:                             ; CODE XREF: sub_4C6890+39j
                                            ; sub_4C6890+52j
    mov     bl, al
    mov     edx, ecx
    mov     bh, bl
    mov     eax, ebx
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C695C:                             ; CODE XREF: sub_4C6890+96j
    mov     eax, dword ptr [esp+74h+arg_4]
    mov     edx, [edx+8Ch]
    mov     [esp+74h+var_14], eax
    lea     eax, [esp+74h+var_64]
    push    eax
    push    1000400h
    push    0
    mov     [esp+80h+var_64], 64h
    mov     ecx, [edx]
    push    0
    push    0
    push    edx
    call    dword ptr [ecx+14h]
    test    eax, eax
    jz      short loc_4C698E
    xor     ebp, ebp

    loc_4C698E:                             ; CODE XREF: sub_4C6890+82j
                                            ; sub_4C6890+FAj
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 64h
    retn    8
    sub_4C6890 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C69A0 proc near                    ; CODE XREF: .text:0041F806p
                                            ; .text:0041FB57p ...

    arg_0= dword ptr  4

    call    sub_4B6220
    mov     ecx, [esp+arg_0]
    mov     dword ptr [eax+0DCh], 1
    mov     [eax+0BCh], ecx
    retn    4
    sub_4C69A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C69C0 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+14Ap
                                            ; GameUnit_LOS_Unknown1+126Bp ...

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    push    esi
    xor     esi, esi
    push    edi
    mov     eax, [edx]
    mov     ecx, [edx+4]
    add     edx, 1Ch
    xor     edi, edi
    dec     eax
    dec     ecx
    mov     [edx], esi
    mov     [edx+4], edi
    pop     edi
    pop     esi
    mov     [edx+8], eax
    mov     [edx+0Ch], ecx
    retn    4
    sub_4C69C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4C69F0(int,int,int)
    sub_4C69F0 proc near                    ; CODE XREF: .text:0041F85Ep
                                            ; sub_460160+30p ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h

    push    ebx
    push    esi
    mov     esi, [esp+arg_4]
    push    edi
    mov     edi, [esp+4+arg_8]
    mov     ecx, [esp+4+arg_0]
    mov     eax, edi
    imul    eax, esi
    add     eax, 30h
    push    eax
    push    ecx
    call    sub_4D83B0
    lea     edx, [eax+30h]
    lea     ebx, [eax+1Ch]
    mov     [eax+0Ch], edx
    mov     edx, [eax+2Ch]
    and     edx, 0FFFFFFFDh
    xor     ecx, ecx
    or      edx, 1
    mov     [ebx], ecx
    mov     [eax+2Ch], edx
    xor     edx, edx
    add     esp, 8
    mov     [eax], esi
    mov     [eax+8], esi
    mov     [ebx+4], edx
    dec     esi
    mov     [eax+4], edi
    mov     [ebx+8], esi
    dec     edi
    mov     [eax+18h], cx
    mov     [eax+1Ah], cx
    mov     [ebx+0Ch], edi
    pop     edi
    pop     esi
    mov     dword ptr [eax+10h], 2710h
    mov     dword ptr [eax+14h], 0FFFFFFFFh
    pop     ebx
    retn    0Ch
    sub_4C69F0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6A60 proc near                    ; CODE XREF: sub_4B5510+387p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    mov     edx, [esp+arg_8]
    push    esi
    mov     esi, [esp+4+arg_C]
    push    edi
    mov     edi, [eax+2Ch]
    mov     [eax+8], esi
    mov     esi, [esp+8+arg_10]
    and     edi, 0FFFFFFFDh
    mov     [eax+0Ch], esi
    xor     esi, esi
    or      edi, 1
    mov     [eax], ecx
    mov     [eax+4], edx
    mov     [eax+18h], si
    mov     [eax+1Ah], si
    mov     dword ptr [eax+10h], 2710h
    mov     dword ptr [eax+14h], 0FFFFFFFFh
    mov     [eax+2Ch], edi
    add     eax, 1Ch
    xor     edi, edi
    dec     ecx
    dec     edx
    mov     [eax], esi
    mov     [eax+4], edi
    pop     edi
    pop     esi
    mov     [eax+8], ecx
    mov     [eax+0Ch], edx
    retn    14h
    sub_4C6A60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6AC0 proc near                    ; CODE XREF: sub_41EC50+32p
                                            ; sub_41EC50+48p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    test    eax, eax
    jz      short locret_4C6AD7
    test    byte ptr [eax+2Ch], 1
    jz      short locret_4C6AD7
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4

    locret_4C6AD7:                          ; CODE XREF: sub_4C6AC0+6j
                                            ; sub_4C6AC0+Cj
    retn    4
    sub_4C6AC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6AE0 proc near                    ; CODE XREF: PlayerStatusMenu+11Fp
                                            ; sub_4A1B40+53Ap ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    add     ecx, 1Ch
    push    esi
    mov     edx, eax
    mov     esi, [ecx]
    mov     [edx], esi
    mov     esi, [ecx+4]
    mov     [edx+4], esi
    mov     esi, [ecx+8]
    mov     [edx+8], esi
    pop     esi
    mov     ecx, [ecx+0Ch]
    mov     [edx+0Ch], ecx
    retn    4
    sub_4C6AE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6B10 proc near                    ; CODE XREF: GameUnit_LOS_Unknown1+95p
                                            ; GameUnit_LOS_Unknown1+95Fp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    mov     edx, [esp+arg_4]
    add     ecx, 1Ch
    mov     [ecx], eax
    mov     eax, [esp+arg_8]
    mov     [ecx+4], edx
    mov     edx, [esp+arg_C]
    mov     [ecx+8], eax
    mov     [ecx+0Ch], edx
    retn    10h
    sub_4C6B10 endp

    ; ---------------------------------------------------------------------------
    align 10h
    call    sub_4B6220
    mov     ecx, [esp+4]
    mov     [eax+0E4h], ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6B60 proc near                    ; CODE XREF: sub_467E50+B4p
                                            ; .text:00468662p
    call    sub_4B6220
    mov     eax, [eax+0E4h]
    retn
    sub_4C6B60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6B70 proc near                    ; CODE XREF: .text:0041F794p
                                            ; .text:0041F890p ...

    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 30h
    push    esi
    mov     esi, [esp+34h+arg_0]
    test    esi, esi
    jnz     short loc_4C6BB8
    mov     esi, [esp+34h+arg_4]
    test    esi, esi
    jz      loc_4C6C49
    lea     eax, [esp+34h+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4C6C49
    movsx   ecx, word ptr [esi+1Ah]
    mov     edx, [esp+34h+arg_C]
    movsx   eax, word ptr [esi+18h]
    sub     edx, ecx
    mov     ecx, [esp+34h+arg_8]
    sub     ecx, eax
    push    edx
    push    ecx
    lea     edx, [esp+3Ch+var_30]
    push    esi
    push    edx
    jmp     short loc_4C6BDE
    ; ---------------------------------------------------------------------------

    loc_4C6BB8:                             ; CODE XREF: sub_4C6B70+Aj
    mov     eax, [esp+34h+arg_4]
    test    eax, eax
    jnz     short loc_4C6C29
    lea     edx, [esp+34h+var_30]
    push    edx
    call    sub_4C5E70
    test    eax, eax
    jz      short loc_4C6C49
    mov     eax, [esp+34h+arg_C]
    mov     ecx, [esp+34h+arg_8]
    push    eax
    lea     edx, [esp+38h+var_30]
    push    ecx
    push    edx
    push    esi

    loc_4C6BDE:                             ; CODE XREF: sub_4C6B70+46j
    call    sub_4CBBE0
    add     esp, 10h
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C6C49
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C6C49
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jz      short loc_4C6C49
    mov     eax, ecx
    push    0
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C6C49
    dec     eax
    mov     dword_51FE00, eax
    pop     esi
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C6C29:                             ; CODE XREF: sub_4C6B70+4Ej
    movsx   edx, word ptr [eax+1Ah]
    mov     ecx, [esp+34h+arg_C]
    sub     ecx, edx
    movsx   edx, word ptr [eax+18h]
    push    ecx
    mov     ecx, [esp+38h+arg_8]
    sub     ecx, edx
    push    ecx
    push    eax
    push    esi
    call    sub_4CBBE0
    add     esp, 10h

    loc_4C6C49:                             ; CODE XREF: sub_4C6B70+12j
                                            ; sub_4C6B70+24j ...
    pop     esi
    add     esp, 30h
    retn    10h
    sub_4C6B70 endp

    ; ---------------------------------------------------------------------------
    mov     ecx, [esp+4]
    sub     esp, 30h
    test    ecx, ecx
    push    esi
    jnz     loc_4C6CE2
    lea     eax, [esp+4]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4C6D0B
    mov     eax, [esp+3Ch]
    mov     ecx, [esp+48h]
    push    ecx
    mov     ecx, [esp+48h]
    movsx   edx, word ptr [eax+1Ah]
    sub     ecx, edx
    movsx   edx, word ptr [eax+18h]
    push    ecx
    mov     ecx, [esp+48h]
    sub     ecx, edx
    lea     edx, [esp+0Ch]
    push    ecx
    push    eax
    push    edx
    call    sub_4CBCD5
    add     esp, 14h
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C6D0B
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C6D0B
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jz      short loc_4C6D0B
    mov     eax, ecx
    push    0
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C6D0B
    dec     eax
    mov     dword_51FE00, eax
    pop     esi
    add     esp, 30h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4C6CE2:                             ; CODE XREF: .text:004C6C5Aj
    mov     edx, [esp+48h]
    mov     eax, [esp+3Ch]
    mov     esi, [esp+44h]
    push    edx
    movsx   edx, word ptr [eax+1Ah]
    sub     esi, edx
    movsx   edx, word ptr [eax+18h]
    push    esi
    mov     esi, [esp+48h]
    sub     esi, edx
    push    esi
    push    eax
    push    ecx
    call    sub_4CBCD5
    add     esp, 14h

    loc_4C6D0B:                             ; CODE XREF: .text:004C6C6Cj
                                            ; .text:004C6CA9j ...
    pop     esi
    add     esp, 30h
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6D20 proc near                    ; CODE XREF: sub_4A1B40+C8p
                                            ; sub_4A4D70+150p ...

    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    sub     esp, 30h
    test    eax, eax
    jnz     short loc_4C6D97
    lea     eax, [esp+30h+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      short loc_4C6DAF
    mov     ecx, [esp+30h+arg_C]
    mov     edx, [esp+30h+arg_8]
    mov     eax, [esp+30h+arg_4]
    push    ecx
    push    edx
    lea     ecx, [esp+38h+var_30]
    push    eax
    push    ecx
    call    sub_4CBDD1
    add     esp, 10h
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C6DAF
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C6DAF
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jz      short loc_4C6DAF
    mov     eax, ecx
    push    0
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C6DAF
    dec     eax
    mov     dword_51FE00, eax
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C6D97:                             ; CODE XREF: sub_4C6D20+9j
    mov     ecx, [esp+30h+arg_C]
    mov     edx, [esp+30h+arg_8]
    push    ecx
    mov     ecx, [esp+34h+arg_4]
    push    edx
    push    ecx
    push    eax
    call    sub_4CBDD1
    add     esp, 10h

    loc_4C6DAF:                             ; CODE XREF: sub_4C6D20+17j
                                            ; sub_4C6D20+3Fj ...
    add     esp, 30h
    retn    10h
    sub_4C6D20 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    sub     esp, 30h
    test    eax, eax
    jnz     short loc_4C6E40
    lea     eax, [esp+0]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      loc_4C6E5D
    mov     ecx, [esp+44h]
    mov     edx, [esp+40h]
    mov     eax, [esp+3Ch]
    push    ecx
    mov     ecx, [esp+3Ch]
    push    edx
    push    eax
    lea     edx, [esp+0Ch]
    push    ecx
    push    edx
    call    sub_4CBE70
    add     esp, 14h
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C6E5D
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C6E5D
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jz      short loc_4C6E5D
    mov     eax, ecx
    push    0
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C6E5D
    dec     eax
    mov     dword_51FE00, eax
    add     esp, 30h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4C6E40:                             ; CODE XREF: .text:004C6DC9j
    mov     edx, [esp+44h]
    mov     ecx, [esp+40h]
    push    edx
    mov     edx, [esp+40h]
    push    ecx
    mov     ecx, [esp+40h]
    push    edx
    push    ecx
    push    eax
    call    sub_4CBE70
    add     esp, 14h

    loc_4C6E5D:                             ; CODE XREF: .text:004C6DD7j
                                            ; .text:004C6E08j ...
    add     esp, 30h
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6E70 proc near                    ; CODE XREF: sub_483FA0+3D0p

    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    sub     esp, 30h
    test    eax, eax
    jnz     short loc_4C6EE7
    lea     eax, [esp+30h+var_30]
    push    eax
    call    sub_4C5E70
    test    eax, eax
    jz      short loc_4C6EFF
    mov     ecx, [esp+30h+arg_C]
    mov     edx, [esp+30h+arg_8]
    mov     eax, [esp+30h+arg_4]
    push    ecx
    push    edx
    lea     ecx, [esp+38h+var_30]
    push    eax
    push    ecx
    call    sub_4CBEF1
    add     esp, 10h
    call    sub_4B6220
    mov     ecx, [eax+44h]
    test    ecx, ecx
    jnz     short loc_4C6EFF
    mov     ecx, [eax+0DCh]
    test    ecx, ecx
    jnz     short loc_4C6EFF
    mov     ecx, [eax+8Ch]
    test    ecx, ecx
    jz      short loc_4C6EFF
    mov     eax, ecx
    push    0
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+80h]
    mov     eax, dword_51FE00
    test    eax, eax
    jle     short loc_4C6EFF
    dec     eax
    mov     dword_51FE00, eax
    add     esp, 30h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C6EE7:                             ; CODE XREF: sub_4C6E70+9j
    mov     ecx, [esp+30h+arg_C]
    mov     edx, [esp+30h+arg_8]
    push    ecx
    mov     ecx, [esp+34h+arg_4]
    push    edx
    push    ecx
    push    eax
    call    sub_4CBEF1
    add     esp, 10h

    loc_4C6EFF:                             ; CODE XREF: sub_4C6E70+17j
                                            ; sub_4C6E70+3Fj ...
    add     esp, 30h
    retn    10h
    sub_4C6E70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6F10 proc near                    ; CODE XREF: sub_4326B0+333p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 8
    push    ebx
    mov     ebx, [esp+0Ch+arg_4]
    push    esi
    push    edi
    push    0
    mov     ecx, ebx
    call    sub_4B4C10
    lea     edx, [esp+14h+var_8]
    push    8
    mov     edi, [esp+18h+arg_0]
    push    edx
    mov     ecx, [edi+4]
    mov     eax, [edi]
    mov     [esp+1Ch+var_4], ecx
    mov     ecx, ebx
    mov     [esp+1Ch+var_8], eax
    call    sub_4B4CF0
    xor     esi, esi
    mov     eax, [esp+14h+var_4]
    test    eax, eax
    jle     short loc_4C6F6B

    loc_4C6F4C:                             ; CODE XREF: sub_4C6F10+59j
    mov     eax, [esp+14h+var_8]
    mov     ecx, esi
    imul    ecx, [edi+8]
    push    eax
    mov     eax, [edi+0Ch]
    add     ecx, eax
    push    ecx
    mov     ecx, ebx
    call    sub_4B4CF0
    inc     esi
    cmp     esi, [esp+14h+var_4]
    jl      short loc_4C6F4C

    loc_4C6F6B:                             ; CODE XREF: sub_4C6F10+3Aj
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn    8
    sub_4C6F10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C6F80 proc near                    ; CODE XREF: sub_491EC0+F8p

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    ebp
    mov     ebp, [esp+10h+arg_0]
    push    esi
    push    edi
    push    0
    mov     ecx, ebp
    call    sub_4B4C10
    lea     eax, [esp+18h+var_8]
    push    8
    push    eax
    mov     ecx, ebp
    call    sub_4B4C80
    cmp     eax, 8
    jnb     short loc_4C6FB3
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C6FB3:                             ; CODE XREF: sub_4C6F80+25j
    mov     eax, [esp+18h+var_4]
    mov     edi, [esp+18h+var_8]
    mov     ebx, eax
    imul    eax, edi
    add     eax, 30h
    push    eax
    push    offset aLoadedSurface           ; "Loaded Surface"
    call    sub_4D83B0
    mov     esi, eax
    xor     eax, eax
    add     esp, 8
    mov     edx, [esi+2Ch]
    mov     [esi], edi
    and     edx, 0FFFFFFFDh
    mov     [esi+8], edi
    or      edx, 1
    mov     [esi+4], ebx
    mov     [esi+2Ch], edx
    lea     edx, [edi-1]
    lea     edi, [ebx-1]
    lea     ebx, [esi+1Ch]
    lea     ecx, [esi+30h]
    mov     [esi+18h], ax
    mov     [esi+0Ch], ecx
    mov     [ebx], eax
    xor     ecx, ecx
    mov     [esi+1Ah], ax
    mov     [ebx+4], ecx
    mov     dword ptr [esi+10h], 2710h
    mov     dword ptr [esi+14h], 0FFFFFFFFh
    mov     [ebx+8], edx
    mov     [ebx+0Ch], edi
    mov     eax, [esp+18h+var_4]
    xor     edi, edi
    test    eax, eax
    jle     short loc_4C706F
    mov     ecx, [esp+18h+var_8]

    loc_4C7029:                             ; CODE XREF: sub_4C6F80+CCj
    mov     eax, edi
    push    ecx
    imul    eax, [esi+8]
    mov     ecx, [esi+0Ch]
    add     eax, ecx
    mov     ecx, ebp
    push    eax
    call    sub_4B4C80
    mov     ecx, [esp+18h+var_8]
    cmp     eax, ecx
    jl      short loc_4C705A
    mov     eax, [esp+18h+var_4]
    inc     edi
    cmp     edi, eax
    jl      short loc_4C7029
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C705A:                             ; CODE XREF: sub_4C6F80+C3j
    push    esi                             ; int
    call    sub_4D85A0
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C706F:                             ; CODE XREF: sub_4C6F80+A3j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    4
    sub_4C6F80 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     edx, [esp+4]
    push    esi
    xor     esi, esi
    xor     eax, eax
    cmp     edx, esi
    jle     short loc_4C70C4
    push    edi
    lea     ecx, [edx-1]

    loc_4C7091:                             ; CODE XREF: .text:004C70C1j
    cmp     eax, esi
    jnz     short loc_4C709D
    mov     dword_51FE48, ecx
    jmp     short loc_4C70A7
    ; ---------------------------------------------------------------------------

    loc_4C709D:                             ; CODE XREF: .text:004C7093j
    lea     edi, [eax-1]
    mov     dword_51FE48[eax*4], edi

    loc_4C70A7:                             ; CODE XREF: .text:004C709Bj
    cmp     eax, ecx
    jnz     short loc_4C70B4
    mov     dword_51FEA0[eax*4], esi
    jmp     short loc_4C70BE
    ; ---------------------------------------------------------------------------

    loc_4C70B4:                             ; CODE XREF: .text:004C70A9j
    lea     edi, [eax+1]
    mov     dword_51FEA0[eax*4], edi

    loc_4C70BE:                             ; CODE XREF: .text:004C70B2j
    inc     eax
    cmp     eax, edx
    jl      short loc_4C7091
    pop     edi

    loc_4C70C4:                             ; CODE XREF: .text:004C708Bj
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, dword_51FF00
    push    ebx
    push    esi
    mov     esi, dword_51FEF8
    mov     eax, dword_51FE48[edx*4]
    push    edi
    mov     edi, [esp+10h]
    mov     dword_51FEFC, eax
    cmp     edi, [esi+eax*8+4]
    jle     short loc_4C7114

    loc_4C70F5:                             ; CODE XREF: .text:004C7112j
    mov     eax, dword_51FE48[eax*4]
    mov     edx, dword_51FE48[edx*4]
    mov     dword_51FEFC, eax
    mov     dword_51FF00, edx
    cmp     edi, [esi+eax*8+4]
    jg      short loc_4C70F5

    loc_4C7114:                             ; CODE XREF: .text:004C70F3j
    mov     eax, [esi+eax*8+4]
    mov     ebx, [esi+edx*8+4]
    mov     ecx, eax
    sub     eax, edi
    sub     ecx, ebx
    test    ecx, ecx
    mov     dword_51FEF0, ecx
    jz      loc_4C71D1                      ; default
    cmp     edx, 3                          ; switch 4 cases
    ja      loc_4C71D1                      ; default
    jmp     ds:off_4C71D8[edx*4]            ; switch jump

    loc_4C7140:                             ; DATA XREF: .text:004C71D8o
    mov     esi, [esp+14h]                  ; case 0x0
    sub     ecx, eax
    mov     dword ptr [esi], 0
    mov     eax, dword_51FEF0
    push    eax
    push    ecx
    mov     ecx, [esp+24h]
    push    ecx
    call    sub_4B7381
    add     esp, 0Ch
    mov     [esi+4], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7169:                             ; CODE XREF: .text:004C7139j
                                            ; DATA XREF: .text:004C71D8o
    mov     edx, [esp+18h]                  ; case 0x1
    push    ecx
    push    eax
    push    edx
    call    sub_4B7381
    mov     ecx, [esp+20h]
    add     esp, 0Ch
    mov     [ecx], eax
    mov     dword ptr [ecx+4], 0
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C718B:                             ; CODE XREF: .text:004C7139j
                                            ; DATA XREF: .text:004C71D8o
    mov     esi, [esp+14h]                  ; case 0x2
    mov     ecx, [esp+18h]
    mov     [esi], ecx
    mov     edx, dword_51FEF0
    push    edx
    push    eax
    mov     eax, [esp+24h]
    push    eax
    call    sub_4B7381
    add     esp, 0Ch
    mov     [esi+4], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C71B3:                             ; CODE XREF: .text:004C7139j
                                            ; DATA XREF: .text:004C71D8o
    push    ecx                             ; case 0x3
    sub     ecx, eax
    push    ecx
    mov     ecx, [esp+20h]
    push    ecx
    call    sub_4B7381
    mov     ecx, [esp+20h]
    mov     edx, [esp+28h]
    add     esp, 0Ch
    mov     [ecx], eax
    mov     [ecx+4], edx

    loc_4C71D1:                             ; CODE XREF: .text:004C712Aj
                                            ; .text:004C7133j
    pop     edi                             ; default
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 4
    off_4C71D8 dd offset loc_4C7140         ; DATA XREF: .text:004C7139r
    dd offset loc_4C7169                    ; jump table for switch statement
    dd offset loc_4C718B
    dd offset loc_4C71B3
    align 10h
    mov     edx, dword_51FE98
    push    ebx
    push    esi
    mov     esi, dword_51FEF8
    mov     eax, dword_51FEA0[edx*4]
    push    edi
    mov     edi, [esp+10h]
    mov     dword_51FEF4, eax
    cmp     edi, [esi+eax*8+4]
    jle     short loc_4C7234

    loc_4C7215:                             ; CODE XREF: .text:004C7232j
    mov     eax, dword_51FEA0[eax*4]
    mov     edx, dword_51FEA0[edx*4]
    mov     dword_51FEF4, eax
    mov     dword_51FE98, edx
    cmp     edi, [esi+eax*8+4]
    jg      short loc_4C7215

    loc_4C7234:                             ; CODE XREF: .text:004C7213j
    mov     eax, [esi+eax*8+4]
    mov     ebx, [esi+edx*8+4]
    mov     ecx, eax
    sub     eax, edi
    sub     ecx, ebx
    test    ecx, ecx
    mov     dword_51FE40, ecx
    jz      loc_4C72F1                      ; default
    cmp     edx, 3                          ; switch 4 cases
    ja      loc_4C72F1                      ; default
    jmp     ds:off_4C72F8[edx*4]            ; switch jump

    loc_4C7260:                             ; DATA XREF: .text:004C72F8o
    push    ecx                             ; case 0x0
    sub     ecx, eax
    mov     eax, [esp+1Ch]
    push    ecx
    push    eax
    call    sub_4B7381
    mov     ecx, [esp+20h]
    add     esp, 0Ch
    mov     [ecx], eax
    mov     dword ptr [ecx+4], 0
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7284:                             ; CODE XREF: .text:004C7259j
                                            ; DATA XREF: .text:004C72F8o
    mov     esi, [esp+14h]                  ; case 0x1
    mov     edx, [esp+18h]
    sub     ecx, eax
    mov     [esi], edx
    mov     eax, dword_51FE40
    push    eax
    push    ecx
    mov     ecx, [esp+24h]
    push    ecx
    call    sub_4B7381
    add     esp, 0Ch
    mov     [esi+4], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C72AD:                             ; CODE XREF: .text:004C7259j
                                            ; DATA XREF: .text:004C72F8o
    mov     edx, [esp+18h]                  ; case 0x2
    push    ecx
    push    eax
    push    edx
    call    sub_4B7381
    mov     ecx, [esp+20h]
    add     esp, 0Ch
    mov     [ecx], eax
    mov     eax, [esp+1Ch]
    mov     [ecx+4], eax
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C72CF:                             ; CODE XREF: .text:004C7259j
                                            ; DATA XREF: .text:004C72F8o
    mov     esi, [esp+14h]                  ; case 0x3
    mov     edx, [esp+1Ch]
    mov     dword ptr [esi], 0
    mov     ecx, dword_51FE40
    push    ecx
    push    eax
    push    edx
    call    sub_4B7381
    add     esp, 0Ch
    mov     [esi+4], eax

    loc_4C72F1:                             ; CODE XREF: .text:004C724Aj
                                            ; .text:004C7253j
    pop     edi                             ; default
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 4
    off_4C72F8 dd offset loc_4C7260         ; DATA XREF: .text:004C7259r
    dd offset loc_4C7284                    ; jump table for switch statement
    dd offset loc_4C72AD
    dd offset loc_4C72CF
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C7310 proc near                    ; CODE XREF: sub_4C7580+473p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 18h
    mov     eax, [esp+18h+arg_8]
    mov     ecx, [esp+18h+arg_C]
    push    ebx
    push    ebp
    mov     ebx, [ecx+10h]
    push    esi
    mov     esi, [eax+0Ch]
    push    edi
    mov     edi, [esp+28h+arg_4]
    mov     [esp+28h+var_14], ebx
    mov     ecx, [edi+4]
    mov     eax, [edi]
    mov     ebp, [edi+8]
    sub     ecx, eax
    mov     eax, [edi+10h]
    sub     eax, ebp
    cdq
    idiv    ecx
    mov     edx, [edi+0Ch]
    mov     ebp, eax
    mov     eax, [edi+14h]
    sub     eax, edx
    cdq
    idiv    ecx
    mov     ecx, [esp+28h+arg_8]
    lea     edx, [esp+28h+var_10]
    push    edx
    mov     [esp+2Ch+arg_4], eax
    call    sub_4C6AE0
    mov     eax, [edi]
    mov     edx, [esp+28h+var_10]
    cmp     eax, edx
    jge     short loc_4C7380
    mov     ecx, edx
    mov     [edi], edx
    sub     ecx, eax
    mov     eax, ebp
    imul    eax, ecx
    add     [edi+8], eax
    mov     eax, [esp+28h+arg_4]
    imul    eax, ecx
    add     [edi+0Ch], eax

    loc_4C7380:                             ; CODE XREF: sub_4C7310+56j
    mov     eax, [esp+28h+var_8]
    mov     ecx, [edi+4]
    cmp     ecx, eax
    jle     short loc_4C738E
    mov     [edi+4], eax

    loc_4C738E:                             ; CODE XREF: sub_4C7310+79j
    mov     edx, [edi]
    mov     eax, [edi+4]
    sub     eax, edx
    test    eax, eax
    mov     [esp+28h+var_18], eax
    jle     loc_4C74DE
    mov     eax, [edi+8]
    mov     ecx, [edi+0Ch]
    mov     edi, [esp+28h+arg_8]
    mov     edi, [edi+8]
    imul    edi, [esp+28h+arg_0]
    add     edi, edx
    xor     edx, edx
    add     esi, edi
    mov     edi, [esp+28h+arg_C]
    mov     dx, [edi]
    lea     edi, [edx-8]
    cmp     edi, 78h
    ja      loc_4C74A0
    xor     edx, edx
    mov     dl, ds:byte_4C7500[edi]
    jmp     ds:off_4C74E8[edx*4]

    loc_4C73DB:                             ; DATA XREF: .text:004C74F8o
    mov     edx, [esp+28h+arg_4]
    push    edx
    push    ebp
    push    ecx
    push    eax
    mov     eax, [esp+38h+var_18]
    push    eax
    push    ebx
    push    esi
    call    sub_4CD896
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C73FC:                             ; CODE XREF: sub_4C7310+C4j
                                            ; DATA XREF: .text:004C74F4o
    mov     edx, [esp+28h+arg_4]
    push    edx
    push    ebp
    push    ecx
    push    eax
    mov     eax, [esp+38h+var_18]
    push    eax
    push    ebx
    push    esi
    call    sub_4CD8DA
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C741D:                             ; CODE XREF: sub_4C7310+C4j
                                            ; DATA XREF: .text:004C74F0o
    mov     edx, [esp+28h+arg_4]
    push    edx
    push    ebp
    push    ecx
    push    eax
    mov     eax, [esp+38h+var_18]
    push    eax
    push    ebx
    push    esi
    call    sub_4CD91E
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C743E:                             ; CODE XREF: sub_4C7310+C4j
                                            ; DATA XREF: .text:004C74ECo
    mov     edx, [esp+28h+arg_4]
    push    edx
    push    ebp
    push    ecx
    push    eax
    mov     eax, [esp+38h+var_18]
    push    eax
    push    ebx
    push    esi
    call    sub_4CD962
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C745F:                             ; CODE XREF: sub_4C7310+C4j
                                            ; DATA XREF: .text:004C74E8o
    mov     edx, [esp+28h+var_18]
    mov     [esp+28h+arg_8], edx
    jmp     short loc_4C746D
    ; ---------------------------------------------------------------------------

    loc_4C7469:                             ; CODE XREF: sub_4C7310+184j
    mov     ebx, [esp+28h+var_14]

    loc_4C746D:                             ; CODE XREF: sub_4C7310+157j
    mov     edx, eax
    mov     edi, ecx
    sar     edx, 10h
    sar     edi, 0Dh
    and     edi, 0FFFFFFF8h
    add     ebx, edx
    inc     esi
    add     eax, ebp
    mov     dl, [edi+ebx]
    mov     edi, [esp+28h+arg_4]
    mov     [esi-1], dl
    mov     edx, [esp+28h+arg_8]
    add     ecx, edi
    dec     edx
    mov     [esp+28h+arg_8], edx
    jnz     short loc_4C7469
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C74A0:                             ; CODE XREF: sub_4C7310+B6j
                                            ; sub_4C7310+C4j
                                            ; DATA XREF: ...
    mov     edx, [esp+28h+var_18]
    mov     [esp+28h+arg_8], edx

    loc_4C74A8:                             ; CODE XREF: sub_4C7310+1CCj
    mov     ebx, [esp+28h+arg_C]
    mov     edx, ecx
    xor     edi, edi
    mov     di, [ebx]
    mov     ebx, [esp+28h+var_14]
    sar     edx, 10h
    imul    edx, edi
    mov     edi, eax
    add     ebx, edx
    sar     edi, 10h
    inc     esi
    add     eax, ebp
    mov     dl, [edi+ebx]
    mov     edi, [esp+28h+arg_4]
    mov     [esi-1], dl
    mov     edx, [esp+28h+arg_8]
    add     ecx, edi
    dec     edx
    mov     [esp+28h+arg_8], edx
    jnz     short loc_4C74A8

    loc_4C74DE:                             ; CODE XREF: sub_4C7310+8Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    10h
    sub_4C7310 endp

    ; ---------------------------------------------------------------------------
    off_4C74E8 dd offset loc_4C745F         ; DATA XREF: sub_4C7310+C4r
    dd offset loc_4C743E
    dd offset loc_4C741D
    dd offset loc_4C73FC
    dd offset loc_4C73DB
    dd offset loc_4C74A0
    byte_4C7500 db 0                        ; DATA XREF: sub_4C7310+BEr
    ; ---------------------------------------------------------------------------
    add     eax, 5050505h
    add     eax, 5050105h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5020505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, ds:5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 90040505h
    nop
    nop
    nop
    nop
    nop
    nop

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C7580 proc near                    ; CODE XREF: sub_4211D0+19Cp
                                            ; sub_4584D0+194p ...

    var_7D8C= dword ptr -7D8Ch
    var_7D88= dword ptr -7D88h
    var_7D84= dword ptr -7D84h
    var_7D80= dword ptr -7D80h
    var_7D7C= dword ptr -7D7Ch
    var_7D78= dword ptr -7D78h
    var_7D74= dword ptr -7D74h
    var_7D70= dword ptr -7D70h
    var_7D6C= dword ptr -7D6Ch
    var_7D68= dword ptr -7D68h
    var_7D64= dword ptr -7D64h
    var_7D60= dword ptr -7D60h
    var_7D5C= dword ptr -7D5Ch
    var_7D58= dword ptr -7D58h
    var_7D54= dword ptr -7D54h
    var_7D50= dword ptr -7D50h
    var_7D4C= dword ptr -7D4Ch
    var_7D48= dword ptr -7D48h
    var_7D44= dword ptr -7D44h
    var_7D40= dword ptr -7D40h
    var_7D3C= dword ptr -7D3Ch
    var_7D38= dword ptr -7D38h
    var_7D34= dword ptr -7D34h
    var_7D30= dword ptr -7D30h
    var_7D00= dword ptr -7D00h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, 7D8Ch
    call    __alloca_probe
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+7D98h+arg_4]
    xor     ebp, ebp
    push    edi
    cmp     esi, ebp
    jz      loc_4C7A12
    mov     edi, [esp+7D9Ch+arg_8]
    cmp     edi, ebp
    jz      loc_4C7A12
    cmp     [esp+7D9Ch+arg_0], ebp
    jnz     short loc_4C75DE
    lea     eax, [esp+7D9Ch+var_7D30]
    push    eax
    call    sub_4C5E70
    cmp     eax, ebp
    jz      loc_4C7A12
    lea     ecx, [esp+7D9Ch+var_7D30]
    mov     [esp+7D9Ch+var_7D84], 1
    mov     [esp+7D9Ch+arg_0], ecx
    jmp     short loc_4C75E2
    ; ---------------------------------------------------------------------------

    loc_4C75DE:                             ; CODE XREF: sub_4C7580+35j
    mov     [esp+7D9Ch+var_7D84], ebp

    loc_4C75E2:                             ; CODE XREF: sub_4C7580+5Cj
    cmp     [esp+7D9Ch+arg_C], ebp
    jnz     short loc_4C7623
    xor     eax, eax
    lea     edx, [esp+7D9Ch+var_7D50]
    mov     ax, [esi]
    mov     [esp+7D9Ch+arg_C], edx
    dec     eax
    mov     [esp+7D9Ch+var_7D50], ebp
    mov     [esp+7D9Ch+var_7D48], eax
    mov     [esp+7D9Ch+var_7D40], eax
    xor     eax, eax
    mov     [esp+7D9Ch+var_7D4C], ebp
    mov     ax, [esi+2]
    mov     [esp+7D9Ch+var_7D44], ebp
    dec     eax
    mov     [esp+7D9Ch+var_7D38], ebp
    mov     [esp+7D9Ch+var_7D3C], eax
    mov     [esp+7D9Ch+var_7D34], eax

    loc_4C7623:                             ; CODE XREF: sub_4C7580+69j
    mov     esi, 0F423Fh
    mov     ebx, 0FFF0BDC1h
    mov     [esp+7D9Ch+var_7D7C], esi
    mov     [esp+7D9Ch+var_7D80], ebx
    mov     [esp+7D9Ch+var_7D88], esi
    xor     ecx, ecx
    mov     edx, edi

    loc_4C763D:                             ; CODE XREF: sub_4C7580+F9j
    mov     eax, [edx+4]
    cmp     eax, esi
    jge     short loc_4C764E
    mov     [esp+7D9Ch+var_7D7C], eax
    mov     [esp+7D9Ch+var_7D68], ecx
    mov     esi, eax

    loc_4C764E:                             ; CODE XREF: sub_4C7580+C2j
    cmp     eax, [esp+7D9Ch+var_7D80]
    jle     short loc_4C765C
    mov     [esp+7D9Ch+var_7D80], eax
    mov     [esp+7D9Ch+var_7D64], ecx

    loc_4C765C:                             ; CODE XREF: sub_4C7580+D2j
    mov     eax, [edx]
    cmp     eax, ebx
    jle     short loc_4C7664
    mov     ebx, eax

    loc_4C7664:                             ; CODE XREF: sub_4C7580+E0j
    mov     ebp, [esp+7D9Ch+var_7D88]
    cmp     eax, ebp
    jge     short loc_4C7672
    mov     ebp, eax
    mov     [esp+7D9Ch+var_7D88], ebp

    loc_4C7672:                             ; CODE XREF: sub_4C7580+EAj
    inc     ecx
    add     edx, 8
    cmp     ecx, 4
    jl      short loc_4C763D
    mov     ecx, [esp+7D9Ch+arg_0]
    lea     eax, [esp+7D9Ch+var_7D60]
    push    eax
    call    sub_4C6AE0
    cmp     ebx, [esp+7D9Ch+var_7D60]
    jge     short loc_4C76A3
    mov     eax, [esp+7D9Ch+var_7D84]
    test    eax, eax
    jz      loc_4C7A12
    jmp     loc_4C7A08
    ; ---------------------------------------------------------------------------

    loc_4C76A3:                             ; CODE XREF: sub_4C7580+110j
    cmp     ebp, [esp+7D9Ch+var_7D58]
    jle     short loc_4C76CC
    mov     eax, [esp+7D9Ch+var_7D84]
    test    eax, eax
    jz      loc_4C7A12
    lea     edx, [esp+7D9Ch+var_7D30]
    push    edx
    call    sub_4C5FA0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7D8Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C76CC:                             ; CODE XREF: sub_4C7580+127j
    mov     edx, [esp+7D9Ch+var_7D5C]
    mov     ecx, [esp+7D9Ch+var_7D80]
    cmp     ecx, edx
    jge     short loc_4C76FB
    mov     eax, [esp+7D9Ch+var_7D84]
    test    eax, eax
    jz      loc_4C7A12
    lea     eax, [esp+7D9Ch+var_7D30]
    push    eax
    call    sub_4C5FA0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7D8Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C76FB:                             ; CODE XREF: sub_4C7580+156j
    mov     eax, [esp+7D9Ch+var_7D54]
    cmp     esi, eax
    jle     short loc_4C7714
    mov     eax, [esp+7D9Ch+var_7D84]
    test    eax, eax
    jz      loc_4C7A12
    jmp     loc_4C7A08
    ; ---------------------------------------------------------------------------

    loc_4C7714:                             ; CODE XREF: sub_4C7580+181j
    cmp     esi, edx
    jge     short loc_4C771E
    mov     [esp+7D9Ch+var_7D7C], edx
    mov     esi, edx

    loc_4C771E:                             ; CODE XREF: sub_4C7580+196j
    cmp     ecx, eax
    jle     short loc_4C7728
    mov     [esp+7D9Ch+var_7D80], eax
    mov     ecx, eax

    loc_4C7728:                             ; CODE XREF: sub_4C7580+1A0j
    cmp     ecx, esi
    jnz     short loc_4C774F
    mov     eax, [esp+7D9Ch+var_7D84]
    test    eax, eax
    jz      loc_4C7A12
    lea     edx, [esp+7D9Ch+var_7D30]
    push    edx
    call    sub_4C5FA0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7D8Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C774F:                             ; CODE XREF: sub_4C7580+1AAj
    lea     eax, [esp+7D9Ch+var_7D00]
    mov     [esp+7D9Ch+var_7D78], eax
    mov     eax, [esp+7D9Ch+var_7D68]

    loc_4C775E:                             ; CODE XREF: sub_4C7580+30Aj
    lea     ecx, [eax-1]
    test    ecx, ecx
    mov     [esp+7D9Ch+var_7D88], ecx
    jge     short loc_4C776E
    mov     ecx, 3

    loc_4C776E:                             ; CODE XREF: sub_4C7580+1E7j
    mov     ebx, [edi+eax*8+4]
    lea     ebp, ds:0[ecx*8]
    lea     esi, ds:0[eax*8]
    mov     eax, [edi+ebp+4]
    cmp     eax, edx
    mov     [esp+7D9Ch+var_7D8C], eax
    jle     loc_4C7879
    cmp     ebx, eax
    jge     loc_4C7879
    mov     edi, eax
    mov     eax, [esp+7D9Ch+arg_8]
    sub     edi, ebx
    mov     ecx, [eax+esi]
    mov     eax, [eax+ebp]
    sub     eax, ecx
    shl     eax, 10h
    cdq
    idiv    edi
    shl     ecx, 10h
    add     ecx, 0FFFFh
    mov     [esp+7D9Ch+var_7D74], ecx
    mov     [esp+7D9Ch+var_7D6C], eax
    mov     eax, [esp+7D9Ch+arg_C]
    mov     ecx, [eax+esi]
    mov     esi, [eax+esi+4]
    mov     eax, [eax+ebp]
    shl     ecx, 10h
    shl     eax, 10h
    sub     eax, ecx
    cdq
    idiv    edi
    mov     edx, [esp+7D9Ch+arg_C]
    shl     esi, 10h
    mov     [esp+7D9Ch+var_7D70], eax
    mov     eax, [edx+ebp+4]
    mov     ebp, [esp+7D9Ch+var_7D5C]
    shl     eax, 10h
    sub     eax, esi
    cdq
    idiv    edi
    cmp     ebx, ebp
    jge     short loc_4C7825
    mov     edx, ebp
    mov     edi, [esp+7D9Ch+var_7D74]
    sub     edx, ebx
    mov     ebx, [esp+7D9Ch+var_7D6C]
    imul    ebx, edx
    add     edi, ebx
    mov     ebx, [esp+7D9Ch+var_7D70]
    imul    ebx, edx
    add     ecx, ebx
    mov     ebx, eax
    imul    ebx, edx
    add     esi, ebx
    mov     ebx, ebp
    jmp     short loc_4C7829
    ; ---------------------------------------------------------------------------

    loc_4C7825:                             ; CODE XREF: sub_4C7580+27Ej
    mov     edi, [esp+7D9Ch+var_7D74]

    loc_4C7829:                             ; CODE XREF: sub_4C7580+2A3j
    mov     edx, [esp+7D9Ch+var_7D54]
    mov     ebp, [esp+7D9Ch+var_7D8C]
    cmp     ebp, edx
    jle     short loc_4C7839
    mov     [esp+7D9Ch+var_7D8C], edx

    loc_4C7839:                             ; CODE XREF: sub_4C7580+2B3j
    mov     edx, [esp+7D9Ch+var_7D8C]
    cmp     ebx, edx
    jge     short loc_4C786E
    sub     edx, ebx
    mov     ebx, edx

    loc_4C7845:                             ; CODE XREF: sub_4C7580+2ECj
    mov     edx, [esp+7D9Ch+var_7D78]
    mov     ebp, edi
    sar     ebp, 10h
    mov     [edx], ebp
    mov     ebp, [esp+7D9Ch+var_7D6C]
    add     edi, ebp
    mov     ebp, [esp+7D9Ch+var_7D70]
    mov     [edx+8], ecx
    mov     [edx+0Ch], esi
    add     ecx, ebp
    add     esi, eax
    add     edx, 28h
    dec     ebx
    mov     [esp+7D9Ch+var_7D78], edx
    jnz     short loc_4C7845

    loc_4C786E:                             ; CODE XREF: sub_4C7580+2BFj
    mov     edx, [esp+7D9Ch+var_7D5C]
    mov     edi, [esp+7D9Ch+arg_8]

    loc_4C7879:                             ; CODE XREF: sub_4C7580+20Aj
                                            ; sub_4C7580+212j
    mov     eax, [esp+7D9Ch+var_7D88]
    test    eax, eax
    jge     short loc_4C7886
    mov     eax, 3

    loc_4C7886:                             ; CODE XREF: sub_4C7580+2FFj
    cmp     eax, [esp+7D9Ch+var_7D64]
    jnz     loc_4C775E
    mov     ecx, [esp+7D9Ch+var_7D68]
    lea     eax, [esp+7D9Ch+var_7D00]
    mov     [esp+7D9Ch+var_7D78], eax

    loc_4C789F:                             ; CODE XREF: sub_4C7580+43Dj
    lea     eax, [ecx+1]
    mov     ebx, [edi+ecx*8+4]
    and     eax, 3
    lea     esi, ds:0[ecx*8]
    mov     [esp+7D9Ch+var_7D88], eax
    mov     ecx, [edi+eax*8+4]
    cmp     ecx, edx
    mov     [esp+7D9Ch+var_7D8C], ecx
    jle     loc_4C79B5
    cmp     ebx, ecx
    jge     loc_4C79B5
    mov     edx, [esp+7D9Ch+arg_8]
    mov     edi, ecx
    sub     edi, ebx
    mov     ebp, [esp+7D9Ch+arg_C]
    mov     ecx, [edx+esi]
    mov     eax, [edx+eax*8]
    sub     eax, ecx
    shl     eax, 10h
    cdq
    idiv    edi
    mov     edx, [esp+7D9Ch+var_7D88]
    shl     ecx, 10h
    add     ecx, 0FFFFh
    mov     [esp+7D9Ch+var_7D74], ecx
    mov     ecx, [ebp+esi+0]
    shl     ecx, 10h
    mov     esi, [ebp+esi+4]
    shl     esi, 10h
    mov     [esp+7D9Ch+var_7D6C], eax
    mov     eax, [ebp+edx*8+0]
    shl     eax, 10h
    sub     eax, ecx
    cdq
    idiv    edi
    mov     [esp+7D9Ch+var_7D70], eax
    mov     eax, [esp+7D9Ch+var_7D88]
    mov     eax, [ebp+eax*8+4]
    mov     ebp, [esp+7D9Ch+var_7D5C]
    shl     eax, 10h
    sub     eax, esi
    cdq
    idiv    edi
    cmp     ebx, ebp
    jge     short loc_4C795C
    mov     edx, ebp
    mov     edi, [esp+7D9Ch+var_7D74]
    sub     edx, ebx
    mov     ebx, [esp+7D9Ch+var_7D6C]
    imul    ebx, edx
    add     edi, ebx
    mov     ebx, [esp+7D9Ch+var_7D70]
    imul    ebx, edx
    add     ecx, ebx
    mov     ebx, eax
    imul    ebx, edx
    add     esi, ebx
    mov     ebx, ebp
    jmp     short loc_4C7960
    ; ---------------------------------------------------------------------------

    loc_4C795C:                             ; CODE XREF: sub_4C7580+3B5j
    mov     edi, [esp+7D9Ch+var_7D74]

    loc_4C7960:                             ; CODE XREF: sub_4C7580+3DAj
    mov     edx, [esp+7D9Ch+var_7D54]
    mov     ebp, [esp+7D9Ch+var_7D8C]
    cmp     ebp, edx
    jle     short loc_4C7970
    mov     [esp+7D9Ch+var_7D8C], edx

    loc_4C7970:                             ; CODE XREF: sub_4C7580+3EAj
    mov     edx, [esp+7D9Ch+var_7D8C]
    cmp     ebx, edx
    jge     short loc_4C79A6
    sub     edx, ebx
    mov     ebx, edx

    loc_4C797C:                             ; CODE XREF: sub_4C7580+424j
    mov     edx, [esp+7D9Ch+var_7D78]
    mov     ebp, edi
    sar     ebp, 10h
    mov     [edx+4], ebp
    mov     ebp, [esp+7D9Ch+var_7D6C]
    add     edi, ebp
    mov     ebp, [esp+7D9Ch+var_7D70]
    mov     [edx+10h], ecx
    mov     [edx+14h], esi
    add     ecx, ebp
    add     esi, eax
    add     edx, 28h
    dec     ebx
    mov     [esp+7D9Ch+var_7D78], edx
    jnz     short loc_4C797C

    loc_4C79A6:                             ; CODE XREF: sub_4C7580+3F6j
    mov     edx, [esp+7D9Ch+var_7D5C]
    mov     edi, [esp+7D9Ch+arg_8]
    mov     eax, [esp+7D9Ch+var_7D88]

    loc_4C79B5:                             ; CODE XREF: sub_4C7580+33Ej
                                            ; sub_4C7580+346j
    mov     ecx, eax
    mov     eax, [esp+7D9Ch+var_7D64]
    cmp     ecx, eax
    jnz     loc_4C789F
    mov     esi, [esp+7D9Ch+var_7D7C]
    mov     ebx, [esp+7D9Ch+var_7D80]
    cmp     esi, ebx
    lea     edi, [esp+7D9Ch+var_7D00]
    jge     short loc_4C7A00

    loc_4C79D6:                             ; CODE XREF: sub_4C7580+47Ej
    mov     ecx, [edi+4]
    mov     edx, [edi]
    sub     ecx, edx
    test    ecx, ecx
    jle     short loc_4C79F8
    mov     edx, [esp+7D9Ch+arg_4]
    mov     eax, [esp+7D9Ch+arg_0]
    push    edx
    push    eax
    push    edi
    push    esi
    call    sub_4C7310

    loc_4C79F8:                             ; CODE XREF: sub_4C7580+45Fj
    add     edi, 28h
    inc     esi
    cmp     esi, ebx
    jl      short loc_4C79D6

    loc_4C7A00:                             ; CODE XREF: sub_4C7580+454j
    mov     eax, [esp+7D9Ch+var_7D84]
    test    eax, eax
    jz      short loc_4C7A12

    loc_4C7A08:                             ; CODE XREF: sub_4C7580+11Ej
                                            ; sub_4C7580+18Fj
    lea     ecx, [esp+7D9Ch+var_7D30]
    push    ecx
    call    sub_4C5FA0

    loc_4C7A12:                             ; CODE XREF: sub_4C7580+19j
                                            ; sub_4C7580+28j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7D8Ch
    retn    10h
    sub_4C7580 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C7A20 proc near                    ; CODE XREF: sub_4C8760+42Cp

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 1Ch
    mov     eax, [esp+1Ch+arg_8]
    push    ebx
    mov     ebx, [esp+20h+arg_4]
    push    ebp
    mov     ecx, [eax+14h]
    push    esi
    mov     esi, [eax+10h]
    mov     eax, [esp+28h+arg_C]
    push    edi
    mov     edi, [ebx+4]
    mov     edx, [eax+10h]
    mov     eax, [ebx]
    mov     [esp+2Ch+var_14], edx
    mov     edx, [ebx+8]
    sub     edi, eax
    mov     eax, [ebx+10h]
    sub     eax, edx
    mov     [esp+2Ch+var_8], edx
    cdq
    idiv    edi
    mov     edx, [ebx+0Ch]
    mov     [esp+2Ch+var_18], edx
    mov     ebp, eax
    mov     eax, [ebx+14h]
    sub     eax, edx
    mov     [esp+2Ch+var_C], ebp
    cdq
    idiv    edi
    mov     edx, [ebx+18h]
    mov     [esp+2Ch+var_4], edx
    mov     [esp+2Ch+var_1C], eax
    mov     eax, [ebx+1Ch]
    sub     eax, edx
    cdq
    idiv    edi
    mov     edx, [ebx]
    test    edx, edx
    mov     [esp+2Ch+var_10], eax
    jge     short loc_4C7ABC
    mov     edi, ebp
    mov     eax, [esp+2Ch+var_8]
    imul    edi, edx
    sub     eax, edi
    mov     edi, [esp+2Ch+var_1C]
    imul    edi, edx
    mov     [ebx+8], eax
    mov     eax, [esp+2Ch+var_18]
    sub     eax, edi
    mov     edi, [esp+2Ch+var_10]
    imul    edi, edx
    mov     [ebx+0Ch], eax
    mov     eax, [esp+2Ch+var_4]
    sub     eax, edi
    mov     dword ptr [ebx], 0
    mov     [ebx+18h], eax

    loc_4C7ABC:                             ; CODE XREF: sub_4C7A20+66j
    mov     edx, [esp+2Ch+arg_8]
    xor     eax, eax
    mov     ax, [edx]
    mov     edx, [ebx+4]
    dec     eax
    cmp     edx, eax
    jle     short loc_4C7AD0
    mov     [ebx+4], eax

    loc_4C7AD0:                             ; CODE XREF: sub_4C7A20+ABj
    mov     edx, [ebx]
    mov     eax, [ebx+4]
    sub     eax, edx
    mov     [esp+2Ch+var_8], edx
    test    eax, eax
    mov     [esp+2Ch+var_18], eax
    jle     loc_4C7EE7
    mov     eax, [esp+2Ch+arg_4]
    mov     edi, [ebx+8]
    mov     ebx, [ebx+0Ch]
    mov     edx, [eax+18h]
    xor     eax, eax
    mov     [esp+2Ch+arg_4], edx
    mov     edx, [esp+2Ch+arg_8]
    mov     ax, [edx]
    mov     edx, [esp+2Ch+var_8]
    imul    eax, [esp+2Ch+arg_0]
    add     edx, eax
    add     esi, edx
    test    ecx, ecx
    jz      loc_4C7DBC
    mov     edx, [esp+2Ch+var_8]
    add     eax, edx
    mov     edx, [esp+2Ch+arg_C]
    add     ecx, eax
    xor     eax, eax
    mov     ax, [edx]
    add     eax, 0FFFFFFF8h
    cmp     eax, 78h
    ja      loc_4C7D4A
    xor     edx, edx
    mov     dl, ds:byte_4C7F0C[eax]
    jmp     ds:off_4C7EF4[edx*4]

    loc_4C7B42:                             ; DATA XREF: .text:004C7F04o
    mov     eax, [esp+2Ch+var_18]
    mov     [esp+2Ch+arg_C], eax

    loc_4C7B4A:                             ; CODE XREF: sub_4C7A20+17Ej
    mov     eax, [esp+2Ch+arg_4]
    mov     dl, [ecx]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+2Ch+arg_8], eax
    ja      short loc_4C7B7D
    mov     ebp, [esp+2Ch+var_14]
    mov     edx, ebx
    sar     edx, 9
    mov     eax, edi
    and     edx, 0FFFFFF80h
    sar     eax, 10h
    add     ebp, edx
    mov     dl, [eax+ebp]
    mov     al, byte ptr [esp+2Ch+arg_8]
    mov     ebp, [esp+2Ch+var_C]
    mov     [esi], dl
    mov     [ecx], al

    loc_4C7B7D:                             ; CODE XREF: sub_4C7A20+139j
    mov     edx, [esp+2Ch+var_1C]
    mov     eax, [esp+2Ch+arg_4]
    add     ebx, edx
    mov     edx, [esp+2Ch+var_10]
    add     eax, edx
    inc     esi
    mov     [esp+2Ch+arg_4], eax
    mov     eax, [esp+2Ch+arg_C]
    inc     ecx
    add     edi, ebp
    dec     eax
    mov     [esp+2Ch+arg_C], eax
    jnz     short loc_4C7B4A
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7BAA:                             ; CODE XREF: sub_4C7A20+11Bj
                                            ; DATA XREF: .text:004C7F00o
    mov     eax, [esp+2Ch+var_18]
    mov     [esp+2Ch+arg_C], eax

    loc_4C7BB2:                             ; CODE XREF: sub_4C7A20+1E6j
    mov     eax, [esp+2Ch+arg_4]
    mov     dl, [ecx]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+2Ch+arg_8], eax
    ja      short loc_4C7BE5
    mov     ebp, [esp+2Ch+var_14]
    mov     edx, ebx
    sar     edx, 0Ah
    mov     eax, edi
    and     edx, 0FFFFFFC0h
    sar     eax, 10h
    add     ebp, edx
    mov     dl, [eax+ebp]
    mov     al, byte ptr [esp+2Ch+arg_8]
    mov     ebp, [esp+2Ch+var_C]
    mov     [esi], dl
    mov     [ecx], al

    loc_4C7BE5:                             ; CODE XREF: sub_4C7A20+1A1j
    mov     edx, [esp+2Ch+var_1C]
    mov     eax, [esp+2Ch+arg_4]
    add     ebx, edx
    mov     edx, [esp+2Ch+var_10]
    add     eax, edx
    inc     esi
    mov     [esp+2Ch+arg_4], eax
    mov     eax, [esp+2Ch+arg_C]
    inc     ecx
    add     edi, ebp
    dec     eax
    mov     [esp+2Ch+arg_C], eax
    jnz     short loc_4C7BB2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7C12:                             ; CODE XREF: sub_4C7A20+11Bj
                                            ; DATA XREF: .text:004C7EFCo
    mov     eax, [esp+2Ch+var_18]
    mov     [esp+2Ch+arg_C], eax

    loc_4C7C1A:                             ; CODE XREF: sub_4C7A20+24Ej
    mov     eax, [esp+2Ch+arg_4]
    mov     dl, [ecx]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+2Ch+arg_8], eax
    ja      short loc_4C7C4D
    mov     ebp, [esp+2Ch+var_14]
    mov     edx, ebx
    sar     edx, 0Bh
    mov     eax, edi
    and     edx, 0FFFFFFE0h
    sar     eax, 10h
    add     ebp, edx
    mov     dl, [eax+ebp]
    mov     al, byte ptr [esp+2Ch+arg_8]
    mov     ebp, [esp+2Ch+var_C]
    mov     [esi], dl
    mov     [ecx], al

    loc_4C7C4D:                             ; CODE XREF: sub_4C7A20+209j
    mov     edx, [esp+2Ch+var_1C]
    mov     eax, [esp+2Ch+arg_4]
    add     ebx, edx
    mov     edx, [esp+2Ch+var_10]
    add     eax, edx
    inc     esi
    mov     [esp+2Ch+arg_4], eax
    mov     eax, [esp+2Ch+arg_C]
    inc     ecx
    add     edi, ebp
    dec     eax
    mov     [esp+2Ch+arg_C], eax
    jnz     short loc_4C7C1A
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7C7A:                             ; CODE XREF: sub_4C7A20+11Bj
                                            ; DATA XREF: .text:004C7EF8o
    mov     eax, [esp+2Ch+var_18]
    mov     [esp+2Ch+arg_C], eax

    loc_4C7C82:                             ; CODE XREF: sub_4C7A20+2B6j
    mov     eax, [esp+2Ch+arg_4]
    mov     dl, [ecx]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+2Ch+arg_8], eax
    ja      short loc_4C7CB5
    mov     ebp, [esp+2Ch+var_14]
    mov     edx, ebx
    sar     edx, 0Ch
    mov     eax, edi
    and     edx, 0FFFFFFF0h
    sar     eax, 10h
    add     ebp, edx
    mov     dl, [eax+ebp]
    mov     al, byte ptr [esp+2Ch+arg_8]
    mov     ebp, [esp+2Ch+var_C]
    mov     [esi], dl
    mov     [ecx], al

    loc_4C7CB5:                             ; CODE XREF: sub_4C7A20+271j
    mov     edx, [esp+2Ch+var_1C]
    mov     eax, [esp+2Ch+arg_4]
    add     ebx, edx
    mov     edx, [esp+2Ch+var_10]
    add     eax, edx
    inc     esi
    mov     [esp+2Ch+arg_4], eax
    mov     eax, [esp+2Ch+arg_C]
    inc     ecx
    add     edi, ebp
    dec     eax
    mov     [esp+2Ch+arg_C], eax
    jnz     short loc_4C7C82
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7CE2:                             ; CODE XREF: sub_4C7A20+11Bj
                                            ; DATA XREF: .text:004C7EF4o
    mov     eax, [esp+2Ch+var_18]
    mov     [esp+2Ch+arg_C], eax

    loc_4C7CEA:                             ; CODE XREF: sub_4C7A20+31Ej
    mov     eax, [esp+2Ch+arg_4]
    mov     dl, [ecx]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+2Ch+arg_8], eax
    ja      short loc_4C7D1D
    mov     ebp, [esp+2Ch+var_14]
    mov     edx, ebx
    sar     edx, 0Dh
    mov     eax, edi
    and     edx, 0FFFFFFF8h
    sar     eax, 10h
    add     ebp, edx
    mov     dl, [eax+ebp]
    mov     al, byte ptr [esp+2Ch+arg_8]
    mov     ebp, [esp+2Ch+var_C]
    mov     [esi], dl
    mov     [ecx], al

    loc_4C7D1D:                             ; CODE XREF: sub_4C7A20+2D9j
    mov     edx, [esp+2Ch+var_1C]
    mov     eax, [esp+2Ch+arg_4]
    add     ebx, edx
    mov     edx, [esp+2Ch+var_10]
    add     eax, edx
    inc     esi
    mov     [esp+2Ch+arg_4], eax
    mov     eax, [esp+2Ch+arg_C]
    inc     ecx
    add     edi, ebp
    dec     eax
    mov     [esp+2Ch+arg_C], eax
    jnz     short loc_4C7CEA
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7D4A:                             ; CODE XREF: sub_4C7A20+10Dj
                                            ; sub_4C7A20+11Bj
                                            ; DATA XREF: ...
    mov     eax, [esp+2Ch+var_18]
    mov     [esp+2Ch+arg_0], eax

    loc_4C7D52:                             ; CODE XREF: sub_4C7A20+390j
    mov     eax, [esp+2Ch+arg_4]
    mov     dl, [ecx]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+2Ch+arg_8], eax
    ja      short loc_4C7D8F
    mov     ebp, [esp+2Ch+arg_C]
    mov     edx, ebx
    xor     eax, eax
    mov     ax, [ebp+0]
    mov     ebp, [esp+2Ch+var_14]
    sar     edx, 10h
    imul    edx, eax
    mov     eax, edi
    sar     eax, 10h
    add     ebp, edx
    mov     dl, [eax+ebp]
    mov     al, byte ptr [esp+2Ch+arg_8]
    mov     ebp, [esp+2Ch+var_C]
    mov     [esi], dl
    mov     [ecx], al

    loc_4C7D8F:                             ; CODE XREF: sub_4C7A20+341j
    mov     edx, [esp+2Ch+var_1C]
    mov     eax, [esp+2Ch+arg_4]
    add     ebx, edx
    mov     edx, [esp+2Ch+var_10]
    add     eax, edx
    inc     esi
    mov     [esp+2Ch+arg_4], eax
    mov     eax, [esp+2Ch+arg_0]
    inc     ecx
    add     edi, ebp
    dec     eax
    mov     [esp+2Ch+arg_0], eax
    jnz     short loc_4C7D52
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7DBC:                             ; CODE XREF: sub_4C7A20+F0j
    mov     ecx, [esp+2Ch+arg_C]
    xor     eax, eax
    mov     ax, [ecx]
    add     eax, 0FFFFFFF8h
    cmp     eax, 78h
    ja      loc_4C7EA9
    xor     edx, edx
    mov     dl, ds:byte_4C7FA0[eax]
    jmp     ds:off_4C7F88[edx*4]

    loc_4C7DE0:                             ; DATA XREF: .text:004C7F98o
    mov     eax, [esp+2Ch+var_1C]
    mov     ecx, [esp+2Ch+var_18]
    mov     edx, [esp+2Ch+var_14]
    push    eax
    push    ebp
    push    ebx
    push    edi
    push    ecx
    push    edx
    push    esi
    call    sub_4CD896
    add     esp, 1Ch

    loc_4C7DFB:                             ; CODE XREF: sub_4C7A20+3B9j
                                            ; DATA XREF: .text:004C7F94o
    mov     eax, [esp+2Ch+var_1C]
    mov     ecx, [esp+2Ch+var_18]
    mov     edx, [esp+2Ch+var_14]
    push    eax
    push    ebp
    push    ebx
    push    edi
    push    ecx
    push    edx
    push    esi
    call    sub_4CD8DA
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7E20:                             ; CODE XREF: sub_4C7A20+3B9j
                                            ; DATA XREF: .text:004C7F90o
    mov     eax, [esp+2Ch+var_1C]
    mov     ecx, [esp+2Ch+var_18]
    mov     edx, [esp+2Ch+var_14]
    push    eax
    push    ebp
    push    ebx
    push    edi
    push    ecx
    push    edx
    push    esi
    call    sub_4CD91E
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7E45:                             ; CODE XREF: sub_4C7A20+3B9j
                                            ; DATA XREF: .text:004C7F8Co
    mov     eax, [esp+2Ch+var_1C]
    mov     ecx, [esp+2Ch+var_18]
    mov     edx, [esp+2Ch+var_14]
    push    eax
    push    ebp
    push    ebx
    push    edi
    push    ecx
    push    edx
    push    esi
    call    sub_4CD962
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7E6A:                             ; CODE XREF: sub_4C7A20+3B9j
                                            ; DATA XREF: .text:004C7F88o
    mov     eax, [esp+2Ch+var_18]
    mov     [esp+2Ch+arg_C], eax

    loc_4C7E72:                             ; CODE XREF: sub_4C7A20+47Dj
    mov     eax, [esp+2Ch+var_14]
    mov     ecx, ebx
    sar     ecx, 0Dh
    and     ecx, 0FFFFFFF8h
    mov     edx, edi
    sar     edx, 10h
    add     eax, ecx
    inc     esi
    add     edi, ebp
    mov     cl, [edx+eax]
    mov     eax, [esp+2Ch+arg_C]
    mov     [esi-1], cl
    mov     ecx, [esp+2Ch+var_1C]
    add     ebx, ecx
    dec     eax
    mov     [esp+2Ch+arg_C], eax
    jnz     short loc_4C7E72
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C7EA9:                             ; CODE XREF: sub_4C7A20+3ABj
                                            ; sub_4C7A20+3B9j
                                            ; DATA XREF: ...
    mov     edx, [esp+2Ch+var_18]
    mov     [esp+2Ch+arg_8], edx

    loc_4C7EB1:                             ; CODE XREF: sub_4C7A20+4C5j
    mov     edx, [esp+2Ch+arg_C]
    mov     eax, ebx
    xor     ecx, ecx
    mov     cx, [edx]
    mov     edx, [esp+2Ch+var_14]
    sar     eax, 10h
    imul    eax, ecx
    mov     ecx, edi
    add     edx, eax
    sar     ecx, 10h
    inc     esi
    add     edi, ebp
    mov     al, [ecx+edx]
    mov     ecx, [esp+2Ch+var_1C]
    mov     [esi-1], al
    mov     eax, [esp+2Ch+arg_8]
    add     ebx, ecx
    dec     eax
    mov     [esp+2Ch+arg_8], eax
    jnz     short loc_4C7EB1

    loc_4C7EE7:                             ; CODE XREF: sub_4C7A20+C1j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    10h
    sub_4C7A20 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4C7EF4 dd offset loc_4C7CE2         ; DATA XREF: sub_4C7A20+11Br
    dd offset loc_4C7C7A
    dd offset loc_4C7C12
    dd offset loc_4C7BAA
    dd offset loc_4C7B42
    dd offset loc_4C7D4A
    byte_4C7F0C db 0                        ; DATA XREF: sub_4C7A20+115r
    dd 5050505h, 1050505h, 3 dup(5050505h), 2050505h, 7 dup(5050505h), 3050505h
    dd 0Fh dup(5050505h), 4050505h
    align 4
    off_4C7F88 dd offset loc_4C7E6A         ; DATA XREF: sub_4C7A20+3B9r
    dd offset loc_4C7E45
    dd offset loc_4C7E20
    dd offset loc_4C7DFB
    dd offset loc_4C7DE0
    dd offset loc_4C7EA9
    byte_4C7FA0 db 0                        ; DATA XREF: sub_4C7A20+3B3r
    ; ---------------------------------------------------------------------------
    add     eax, 5050505h
    add     eax, 5050105h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5020505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, ds:5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 90040505h
    nop
    nop
    nop
    nop
    nop
    nop

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C8020 proc near                    ; CODE XREF: sub_4C8BB0+4E5p

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 28h
    mov     eax, [esp+28h+arg_8]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [eax+10h]
    mov     ebp, [eax+14h]
    mov     eax, [esp+34h+arg_C]
    push    edi
    mov     ecx, [eax+10h]
    mov     [esp+38h+var_1C], ecx
    call    sub_4B6220
    mov     ebx, [esp+38h+arg_4]
    mov     [esp+38h+var_C], eax
    mov     edi, [ebx+4]
    mov     eax, [ebx]
    mov     ecx, [ebx+8]
    sub     edi, eax
    mov     eax, [ebx+10h]
    mov     [esp+38h+var_8], ecx
    sub     eax, ecx
    cdq
    idiv    edi
    mov     edx, [ebx+0Ch]
    mov     [esp+38h+var_20], edx
    mov     ecx, eax
    mov     eax, [ebx+14h]
    sub     eax, edx
    mov     [esp+38h+var_10], ecx
    cdq
    idiv    edi
    mov     edx, [ebx+18h]
    mov     [esp+38h+var_28], edx
    mov     [esp+38h+var_24], eax
    mov     eax, [ebx+1Ch]
    sub     eax, edx
    cdq
    idiv    edi
    mov     edx, [ebx+20h]
    mov     [esp+38h+var_4], edx
    mov     [esp+38h+var_18], eax
    mov     eax, [ebx+24h]
    sub     eax, edx
    cdq
    idiv    edi
    mov     edx, [ebx]
    test    edx, edx
    mov     [esp+38h+var_14], eax
    jge     short loc_4C80E8
    mov     edi, ecx
    mov     eax, [esp+38h+var_8]
    imul    edi, edx
    sub     eax, edi
    mov     edi, [esp+38h+var_24]
    imul    edi, edx
    mov     [ebx+8], eax
    mov     eax, [esp+38h+var_20]
    sub     eax, edi
    mov     edi, [esp+38h+var_18]
    imul    edi, edx
    mov     [ebx+0Ch], eax
    mov     eax, [esp+38h+var_28]
    sub     eax, edi
    mov     edi, [esp+38h+var_14]
    imul    edi, edx
    mov     [ebx+18h], eax
    mov     eax, [esp+38h+var_4]
    sub     eax, edi
    mov     dword ptr [ebx], 0
    mov     [ebx+20h], eax

    loc_4C80E8:                             ; CODE XREF: sub_4C8020+82j
    mov     edx, [esp+38h+arg_8]
    xor     eax, eax
    mov     ax, [edx]
    mov     edx, [ebx+4]
    dec     eax
    cmp     edx, eax
    jle     short loc_4C80FC
    mov     [ebx+4], eax

    loc_4C80FC:                             ; CODE XREF: sub_4C8020+D7j
    mov     edx, [ebx]
    mov     eax, [ebx+4]
    sub     eax, edx
    mov     [esp+38h+var_8], edx
    test    eax, eax
    mov     [esp+38h+var_20], eax
    jle     loc_4C8623
    mov     eax, [esp+38h+arg_4]
    mov     edi, [ebx+8]
    mov     ebx, [ebx+0Ch]
    mov     edx, [eax+18h]
    mov     eax, [eax+20h]
    mov     [esp+38h+arg_4], edx
    mov     edx, [esp+38h+arg_8]
    mov     [esp+38h+var_28], eax
    xor     eax, eax
    mov     ax, [edx]
    mov     edx, [esp+38h+var_8]
    imul    eax, [esp+38h+arg_0]
    add     edx, eax
    add     esi, edx
    test    ebp, ebp
    jz      loc_4C84F4
    mov     edx, [esp+38h+var_8]
    add     eax, edx
    mov     edx, [esp+38h+arg_C]
    add     ebp, eax
    xor     eax, eax
    mov     ax, [edx]
    add     eax, 0FFFFFFF8h
    cmp     eax, 78h
    ja      loc_4C8454
    xor     edx, edx
    mov     dl, ds:byte_4C8648[eax]
    jmp     ds:off_4C8630[edx*4]

    loc_4C8175:                             ; DATA XREF: .text:004C8640o
    mov     eax, [esp+38h+var_20]
    mov     [esp+38h+arg_C], eax

    loc_4C817D:                             ; CODE XREF: sub_4C8020+1DCj
    mov     eax, [esp+38h+arg_4]
    mov     dl, [ebp+0]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+38h+arg_8], eax
    ja      short loc_4C81CD
    mov     eax, [esp+38h+var_1C]
    mov     ecx, ebx
    sar     ecx, 9
    and     ecx, 0FFFFFF80h
    mov     edx, edi
    sar     edx, 10h
    add     eax, ecx
    xor     ecx, ecx
    mov     cl, [edx+eax]
    mov     edx, [esp+38h+var_28]
    mov     eax, [esp+38h+var_C]
    sar     edx, 10h
    shl     edx, 8
    add     ecx, edx
    mov     edx, [eax+0C4h]
    mov     al, [ecx+edx]
    mov     cl, byte ptr [esp+38h+arg_8]
    mov     [esi], al
    mov     [ebp+0], cl
    mov     ecx, [esp+38h+var_10]

    loc_4C81CD:                             ; CODE XREF: sub_4C8020+16Dj
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+arg_4]
    add     ebx, edx
    mov     edx, [esp+38h+var_18]
    add     eax, edx
    mov     edx, [esp+38h+var_28]
    mov     [esp+38h+arg_4], eax
    mov     eax, [esp+38h+var_14]
    add     edx, eax
    mov     eax, [esp+38h+arg_C]
    inc     esi
    inc     ebp
    add     edi, ecx
    dec     eax
    mov     [esp+38h+var_28], edx
    mov     [esp+38h+arg_C], eax
    jnz     loc_4C817D
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C820C:                             ; CODE XREF: sub_4C8020+14Ej
                                            ; DATA XREF: .text:004C863Co
    mov     edx, [esp+38h+var_20]
    mov     [esp+38h+arg_C], edx

    loc_4C8214:                             ; CODE XREF: sub_4C8020+272j
    mov     eax, [esp+38h+arg_4]
    mov     dl, [ebp+0]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+38h+arg_8], eax
    ja      short loc_4C8263
    mov     edx, [esp+38h+var_1C]
    mov     eax, ebx
    sar     eax, 0Ah
    and     al, 0C0h
    mov     ecx, edi
    sar     ecx, 10h
    add     edx, eax
    xor     eax, eax
    mov     al, [ecx+edx]
    mov     ecx, [esp+38h+var_28]
    mov     edx, [esp+38h+var_C]
    sar     ecx, 10h
    shl     ecx, 8
    add     eax, ecx
    mov     ecx, [edx+0C4h]
    mov     dl, [eax+ecx]
    mov     al, byte ptr [esp+38h+arg_8]
    mov     ecx, [esp+38h+var_10]
    mov     [esi], dl
    mov     [ebp+0], al

    loc_4C8263:                             ; CODE XREF: sub_4C8020+204j
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+arg_4]
    add     ebx, edx
    mov     edx, [esp+38h+var_18]
    add     eax, edx
    mov     edx, [esp+38h+var_28]
    mov     [esp+38h+arg_4], eax
    mov     eax, [esp+38h+var_14]
    add     edx, eax
    mov     eax, [esp+38h+arg_C]
    inc     esi
    inc     ebp
    add     edi, ecx
    dec     eax
    mov     [esp+38h+var_28], edx
    mov     [esp+38h+arg_C], eax
    jnz     short loc_4C8214
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C829E:                             ; CODE XREF: sub_4C8020+14Ej
                                            ; DATA XREF: .text:004C8638o
    mov     edx, [esp+38h+var_20]
    mov     [esp+38h+arg_C], edx

    loc_4C82A6:                             ; CODE XREF: sub_4C8020+304j
    mov     eax, [esp+38h+arg_4]
    mov     dl, [ebp+0]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+38h+arg_8], eax
    ja      short loc_4C82F5
    mov     edx, [esp+38h+var_1C]
    mov     eax, ebx
    sar     eax, 0Bh
    and     al, 0E0h
    mov     ecx, edi
    sar     ecx, 10h
    add     edx, eax
    xor     eax, eax
    mov     al, [ecx+edx]
    mov     ecx, [esp+38h+var_28]
    mov     edx, [esp+38h+var_C]
    sar     ecx, 10h
    shl     ecx, 8
    add     eax, ecx
    mov     ecx, [edx+0C4h]
    mov     dl, [eax+ecx]
    mov     al, byte ptr [esp+38h+arg_8]
    mov     ecx, [esp+38h+var_10]
    mov     [esi], dl
    mov     [ebp+0], al

    loc_4C82F5:                             ; CODE XREF: sub_4C8020+296j
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+arg_4]
    add     ebx, edx
    mov     edx, [esp+38h+var_18]
    add     eax, edx
    mov     edx, [esp+38h+var_28]
    mov     [esp+38h+arg_4], eax
    mov     eax, [esp+38h+var_14]
    add     edx, eax
    mov     eax, [esp+38h+arg_C]
    inc     esi
    inc     ebp
    add     edi, ecx
    dec     eax
    mov     [esp+38h+var_28], edx
    mov     [esp+38h+arg_C], eax
    jnz     short loc_4C82A6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C8330:                             ; CODE XREF: sub_4C8020+14Ej
                                            ; DATA XREF: .text:004C8634o
    mov     edx, [esp+38h+var_20]
    mov     [esp+38h+arg_C], edx

    loc_4C8338:                             ; CODE XREF: sub_4C8020+396j
    mov     eax, [esp+38h+arg_4]
    mov     dl, [ebp+0]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+38h+arg_8], eax
    ja      short loc_4C8387
    mov     edx, [esp+38h+var_1C]
    mov     eax, ebx
    sar     eax, 0Ch
    and     al, 0F0h
    mov     ecx, edi
    sar     ecx, 10h
    add     edx, eax
    xor     eax, eax
    mov     al, [ecx+edx]
    mov     ecx, [esp+38h+var_28]
    mov     edx, [esp+38h+var_C]
    sar     ecx, 10h
    shl     ecx, 8
    add     eax, ecx
    mov     ecx, [edx+0C4h]
    mov     dl, [eax+ecx]
    mov     al, byte ptr [esp+38h+arg_8]
    mov     ecx, [esp+38h+var_10]
    mov     [esi], dl
    mov     [ebp+0], al

    loc_4C8387:                             ; CODE XREF: sub_4C8020+328j
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+arg_4]
    add     ebx, edx
    mov     edx, [esp+38h+var_18]
    add     eax, edx
    mov     edx, [esp+38h+var_28]
    mov     [esp+38h+arg_4], eax
    mov     eax, [esp+38h+var_14]
    add     edx, eax
    mov     eax, [esp+38h+arg_C]
    inc     esi
    inc     ebp
    add     edi, ecx
    dec     eax
    mov     [esp+38h+var_28], edx
    mov     [esp+38h+arg_C], eax
    jnz     short loc_4C8338
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C83C2:                             ; CODE XREF: sub_4C8020+14Ej
                                            ; DATA XREF: .text:004C8630o
    mov     edx, [esp+38h+var_20]
    mov     [esp+38h+arg_C], edx

    loc_4C83CA:                             ; CODE XREF: sub_4C8020+428j
    mov     eax, [esp+38h+arg_4]
    mov     dl, [ebp+0]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+38h+arg_8], eax
    ja      short loc_4C8419
    mov     edx, [esp+38h+var_1C]
    mov     eax, ebx
    sar     eax, 0Dh
    and     al, 0F8h
    mov     ecx, edi
    sar     ecx, 10h
    add     edx, eax
    xor     eax, eax
    mov     al, [ecx+edx]
    mov     ecx, [esp+38h+var_28]
    mov     edx, [esp+38h+var_C]
    sar     ecx, 10h
    shl     ecx, 8
    add     eax, ecx
    mov     ecx, [edx+0C4h]
    mov     dl, [eax+ecx]
    mov     al, byte ptr [esp+38h+arg_8]
    mov     ecx, [esp+38h+var_10]
    mov     [esi], dl
    mov     [ebp+0], al

    loc_4C8419:                             ; CODE XREF: sub_4C8020+3BAj
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+arg_4]
    add     ebx, edx
    mov     edx, [esp+38h+var_18]
    add     eax, edx
    mov     edx, [esp+38h+var_28]
    mov     [esp+38h+arg_4], eax
    mov     eax, [esp+38h+var_14]
    add     edx, eax
    mov     eax, [esp+38h+arg_C]
    inc     esi
    inc     ebp
    add     edi, ecx
    dec     eax
    mov     [esp+38h+var_28], edx
    mov     [esp+38h+arg_C], eax
    jnz     short loc_4C83CA
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C8454:                             ; CODE XREF: sub_4C8020+140j
                                            ; sub_4C8020+14Ej
                                            ; DATA XREF: ...
    mov     edx, [esp+38h+var_20]
    mov     [esp+38h+arg_0], edx

    loc_4C845C:                             ; CODE XREF: sub_4C8020+4C4j
    mov     eax, [esp+38h+arg_4]
    mov     dl, [ebp+0]
    sar     eax, 10h
    cmp     dl, al
    mov     [esp+38h+arg_8], eax
    ja      short loc_4C84B5
    mov     edx, [esp+38h+arg_C]
    mov     eax, ebx
    xor     ecx, ecx
    mov     cx, [edx]
    mov     edx, [esp+38h+var_1C]
    sar     eax, 10h
    imul    eax, ecx
    mov     ecx, edi
    add     edx, eax
    sar     ecx, 10h
    xor     eax, eax
    mov     al, [ecx+edx]
    mov     ecx, [esp+38h+var_28]
    mov     edx, [esp+38h+var_C]
    sar     ecx, 10h
    shl     ecx, 8
    add     eax, ecx
    mov     ecx, [edx+0C4h]
    mov     dl, [eax+ecx]
    mov     al, byte ptr [esp+38h+arg_8]
    mov     ecx, [esp+38h+var_10]
    mov     [esi], dl
    mov     [ebp+0], al

    loc_4C84B5:                             ; CODE XREF: sub_4C8020+44Cj
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+arg_4]
    add     ebx, edx
    mov     edx, [esp+38h+var_18]
    add     eax, edx
    mov     edx, [esp+38h+var_28]
    mov     [esp+38h+arg_4], eax
    mov     eax, [esp+38h+var_14]
    add     edx, eax
    mov     eax, [esp+38h+arg_0]
    inc     esi
    inc     ebp
    add     edi, ecx
    dec     eax
    mov     [esp+38h+var_28], edx
    mov     [esp+38h+arg_0], eax
    jnz     loc_4C845C
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C84F4:                             ; CODE XREF: sub_4C8020+123j
    mov     edx, [esp+38h+arg_C]
    xor     eax, eax
    mov     ax, [edx]
    lea     ebp, [eax-8]
    cmp     ebp, 78h
    ja      loc_4C85E4
    xor     eax, eax
    mov     al, ss:byte_4C86DC[ebp]
    jmp     ds:off_4C86C4[eax*4]

    loc_4C8518:                             ; DATA XREF: .text:004C86D4o
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+var_20]
    push    edx
    push    ecx
    mov     ecx, [esp+40h+var_1C]
    push    ebx
    push    edi
    push    eax
    push    ecx
    push    esi
    call    sub_4CD896
    mov     ecx, [esp+54h+var_10]
    add     esp, 1Ch

    loc_4C8537:                             ; CODE XREF: sub_4C8020+4F1j
                                            ; DATA XREF: .text:004C86D0o
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+var_20]
    push    edx
    push    ecx
    mov     ecx, [esp+40h+var_1C]
    push    ebx
    push    edi
    push    eax
    push    ecx
    push    esi
    call    sub_4CD8DA
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C855C:                             ; CODE XREF: sub_4C8020+4F1j
                                            ; DATA XREF: .text:004C86CCo
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+var_20]
    push    edx
    push    ecx
    mov     ecx, [esp+40h+var_1C]
    push    ebx
    push    edi
    push    eax
    push    ecx
    push    esi
    call    sub_4CD91E
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C8581:                             ; CODE XREF: sub_4C8020+4F1j
                                            ; DATA XREF: .text:004C86C8o
    mov     edx, [esp+38h+var_24]
    mov     eax, [esp+38h+var_20]
    push    edx
    push    ecx
    mov     ecx, [esp+40h+var_1C]
    push    ebx
    push    edi
    push    eax
    push    ecx
    push    esi
    call    sub_4CD962
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C85A6:                             ; CODE XREF: sub_4C8020+4F1j
                                            ; DATA XREF: .text:004C86C4o
    mov     edx, [esp+38h+var_20]
    mov     [esp+38h+arg_C], edx

    loc_4C85AE:                             ; CODE XREF: sub_4C8020+5B8j
    mov     ebp, [esp+38h+var_1C]
    mov     eax, ebx
    sar     eax, 0Dh
    and     al, 0F8h
    mov     edx, edi
    sar     edx, 10h
    add     ebp, eax
    inc     esi
    add     edi, ecx
    mov     al, [edx+ebp]
    mov     edx, [esp+38h+var_24]
    mov     [esi-1], al
    mov     eax, [esp+38h+arg_C]
    add     ebx, edx
    dec     eax
    mov     [esp+38h+arg_C], eax
    jnz     short loc_4C85AE
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C85E4:                             ; CODE XREF: sub_4C8020+4E3j
                                            ; sub_4C8020+4F1j
                                            ; DATA XREF: ...
    mov     edx, [esp+38h+var_20]
    mov     [esp+38h+arg_8], edx

    loc_4C85EC:                             ; CODE XREF: sub_4C8020+601j
    mov     ebp, [esp+38h+arg_C]
    mov     eax, ebx
    xor     edx, edx
    mov     dx, [ebp+0]
    mov     ebp, [esp+38h+var_1C]
    sar     eax, 10h
    imul    eax, edx
    mov     edx, edi
    add     ebp, eax
    sar     edx, 10h
    inc     esi
    add     edi, ecx
    mov     al, [edx+ebp]
    mov     edx, [esp+38h+var_24]
    mov     [esi-1], al
    mov     eax, [esp+38h+arg_8]
    add     ebx, edx
    dec     eax
    mov     [esp+38h+arg_8], eax
    jnz     short loc_4C85EC

    loc_4C8623:                             ; CODE XREF: sub_4C8020+EDj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    sub_4C8020 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4C8630 dd offset loc_4C83C2         ; DATA XREF: sub_4C8020+14Er
    dd offset loc_4C8330
    dd offset loc_4C829E
    dd offset loc_4C820C
    dd offset loc_4C8175
    dd offset loc_4C8454
    byte_4C8648 db 0                        ; DATA XREF: sub_4C8020+148r
    dd 5050505h, 1050505h, 3 dup(5050505h), 2050505h, 7 dup(5050505h), 3050505h
    dd 0Fh dup(5050505h), 4050505h
    align 4
    off_4C86C4 dd offset loc_4C85A6         ; DATA XREF: sub_4C8020+4F1r
    dd offset loc_4C8581
    dd offset loc_4C855C
    dd offset loc_4C8537
    dd offset loc_4C8518
    dd offset loc_4C85E4
    byte_4C86DC db 0                        ; DATA XREF: sub_4C8020+4EBr
    ; ---------------------------------------------------------------------------
    add     eax, 5050505h
    add     eax, 5050105h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5020505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, ds:5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 5050505h
    add     eax, 90040505h
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C8760 proc near                    ; CODE XREF: sub_459830+366p

    var_7D58= dword ptr -7D58h
    var_7D54= dword ptr -7D54h
    var_7D50= dword ptr -7D50h
    var_7D4C= dword ptr -7D4Ch
    var_7D48= dword ptr -7D48h
    var_7D44= dword ptr -7D44h
    var_7D40= dword ptr -7D40h
    var_7D3C= dword ptr -7D3Ch
    var_7D38= dword ptr -7D38h
    var_7D34= dword ptr -7D34h
    var_7D30= dword ptr -7D30h
    var_7D2C= dword ptr -7D2Ch
    var_7D28= dword ptr -7D28h
    var_7D24= dword ptr -7D24h
    var_7D20= dword ptr -7D20h
    var_7D1C= dword ptr -7D1Ch
    var_7D18= dword ptr -7D18h
    var_7D14= dword ptr -7D14h
    var_7D10= dword ptr -7D10h
    var_7D0C= dword ptr -7D0Ch
    var_7D08= dword ptr -7D08h
    var_7D04= dword ptr -7D04h
    var_7D00= dword ptr -7D00h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, 7D58h
    call    __alloca_probe
    mov     eax, [esp+7D58h+arg_0]
    push    ebx
    xor     edx, edx
    push    ebp
    push    esi
    cmp     eax, edx
    push    edi
    jz      loc_4C8B99
    mov     ecx, [esp+7D68h+arg_4]
    cmp     ecx, edx
    jz      loc_4C8B99
    mov     esi, [esp+7D68h+arg_8]
    cmp     esi, edx
    jz      loc_4C8B99
    cmp     [esp+7D68h+arg_C], edx
    jnz     short loc_4C87DE
    lea     eax, [esp+7D68h+var_7D20]
    mov     [esp+7D68h+var_7D20], edx
    mov     [esp+7D68h+arg_C], eax
    xor     eax, eax
    mov     ax, [ecx]
    mov     [esp+7D68h+var_7D1C], edx
    dec     eax
    mov     [esp+7D68h+var_7D14], edx
    mov     [esp+7D68h+var_7D18], eax
    mov     [esp+7D68h+var_7D10], eax
    xor     eax, eax
    mov     [esp+7D68h+var_7D08], edx
    mov     ax, [ecx+2]
    dec     eax
    mov     [esp+7D68h+var_7D0C], eax
    mov     [esp+7D68h+var_7D04], eax

    loc_4C87DE:                             ; CODE XREF: sub_4C8760+44j
    mov     edi, 0F423Fh
    mov     ebx, 0FFF0BDC1h
    mov     [esp+7D68h+var_7D44], edi
    mov     [esp+7D68h+var_7D48], ebx
    mov     [esp+7D68h+var_7D54], edi
    xor     ecx, ecx
    mov     edx, esi

    loc_4C87F8:                             ; CODE XREF: sub_4C8760+D4j
    mov     eax, [edx+4]
    cmp     eax, edi
    jge     short loc_4C8809
    mov     [esp+7D68h+var_7D44], eax
    mov     [esp+7D68h+var_7D40], ecx
    mov     edi, eax

    loc_4C8809:                             ; CODE XREF: sub_4C8760+9Dj
    cmp     eax, [esp+7D68h+var_7D48]
    jle     short loc_4C8817
    mov     [esp+7D68h+var_7D48], eax
    mov     [esp+7D68h+var_7D28], ecx

    loc_4C8817:                             ; CODE XREF: sub_4C8760+ADj
    mov     eax, [edx]
    cmp     eax, ebx
    jle     short loc_4C881F
    mov     ebx, eax

    loc_4C881F:                             ; CODE XREF: sub_4C8760+BBj
    mov     ebp, [esp+7D68h+var_7D54]
    cmp     eax, ebp
    jge     short loc_4C882D
    mov     ebp, eax
    mov     [esp+7D68h+var_7D54], ebp

    loc_4C882D:                             ; CODE XREF: sub_4C8760+C5j
    inc     ecx
    add     edx, 0Ch
    cmp     ecx, 4
    jl      short loc_4C87F8
    test    ebx, ebx
    jl      loc_4C8B99
    mov     ecx, [esp+7D68h+arg_0]
    xor     edx, edx
    mov     dx, [ecx]
    dec     edx
    cmp     ebp, edx
    jg      loc_4C8B99
    mov     edx, [esp+7D68h+var_7D48]
    test    edx, edx
    jl      loc_4C8B99
    xor     eax, eax
    mov     ax, [ecx+2]
    dec     eax
    cmp     edi, eax
    mov     [esp+7D68h+var_7D2C], eax
    jg      loc_4C8B99
    test    edi, edi
    jge     short loc_4C8882
    mov     [esp+7D68h+var_7D44], 0
    mov     edi, [esp+7D68h+var_7D44]

    loc_4C8882:                             ; CODE XREF: sub_4C8760+114j
    cmp     edx, eax
    jle     short loc_4C888C
    mov     [esp+7D68h+var_7D48], eax
    mov     edx, eax

    loc_4C888C:                             ; CODE XREF: sub_4C8760+124j
    cmp     edx, edi
    jz      loc_4C8B99
    mov     edi, [esp+7D68h+var_7D40]
    lea     eax, [esp+7D68h+var_7D00]
    mov     [esp+7D68h+var_7D38], eax

    loc_4C88A0:                             ; CODE XREF: sub_4C8760+29Dj
    lea     edx, [edi-1]
    mov     eax, edx
    mov     [esp+7D68h+var_7D24], edx
    test    eax, eax
    mov     [esp+7D68h+var_7D58], eax
    jge     short loc_4C88BD
    mov     [esp+7D68h+var_7D58], 3
    mov     eax, [esp+7D68h+var_7D58]

    loc_4C88BD:                             ; CODE XREF: sub_4C8760+14Fj
    lea     ecx, [edi+edi*2]
    lea     eax, [eax+eax*2]
    mov     ebp, [esi+ecx*4+4]
    lea     ebx, [esi+ecx*4]
    mov     ecx, [esi+eax*4+4]
    lea     eax, [esi+eax*4]
    cmp     ebp, ecx
    mov     [esp+7D68h+var_7D30], eax
    mov     [esp+7D68h+var_7D4C], ecx
    jge     loc_4C89EE
    mov     esi, [ebx]
    mov     eax, [eax]
    sub     eax, esi
    sub     ecx, ebp
    shl     eax, 10h
    cdq
    idiv    ecx
    shl     esi, 10h
    add     esi, 0FFFFh
    mov     ebx, [ebx+8]
    mov     [esp+7D68h+var_7D50], esi
    shl     ebx, 10h
    mov     [esp+7D68h+var_7D34], eax
    mov     eax, [esp+7D68h+arg_C]
    mov     edx, eax
    mov     esi, [eax+edi*8]
    mov     edi, [eax+edi*8+4]
    mov     eax, [esp+7D68h+var_7D58]
    shl     esi, 10h
    mov     eax, [edx+eax*8]
    shl     eax, 10h
    sub     eax, esi
    cdq
    idiv    ecx
    mov     edx, [esp+7D68h+arg_C]
    shl     edi, 10h
    mov     [esp+7D68h+var_7D3C], eax
    mov     eax, [esp+7D68h+var_7D58]
    mov     eax, [edx+eax*8+4]
    shl     eax, 10h
    sub     eax, edi
    cdq
    idiv    ecx
    mov     edx, [esp+7D68h+var_7D30]
    mov     [esp+7D68h+var_7D58], eax
    mov     eax, [edx+8]
    shl     eax, 10h
    sub     eax, ebx
    cdq
    idiv    ecx
    test    ebp, ebp
    jge     short loc_4C8989
    mov     ecx, [esp+7D68h+var_7D34]
    mov     edx, [esp+7D68h+var_7D50]
    imul    ecx, ebp
    sub     edx, ecx
    mov     ecx, [esp+7D68h+var_7D58]
    mov     [esp+7D68h+var_7D50], edx
    mov     edx, [esp+7D68h+var_7D3C]
    imul    edx, ebp
    imul    ecx, ebp
    sub     esi, edx
    mov     edx, eax
    imul    edx, ebp
    sub     edi, ecx
    sub     ebx, edx
    xor     ebp, ebp

    loc_4C8989:                             ; CODE XREF: sub_4C8760+1FBj
    mov     ecx, [esp+7D68h+var_7D4C]
    mov     edx, [esp+7D68h+var_7D2C]
    cmp     ecx, edx
    jle     short loc_4C899B
    mov     [esp+7D68h+var_7D4C], edx
    mov     ecx, edx

    loc_4C899B:                             ; CODE XREF: sub_4C8760+233j
    cmp     ebp, ecx
    jge     short loc_4C89E3
    mov     edx, [esp+7D68h+var_7D50]
    sub     ecx, ebp
    mov     [esp+7D68h+var_7D54], ecx

    loc_4C89A9:                             ; CODE XREF: sub_4C8760+281j
    mov     ecx, [esp+7D68h+var_7D38]
    mov     ebp, edx
    sar     ebp, 10h
    mov     [ecx], ebp
    mov     ebp, [esp+7D68h+var_7D34]
    add     edx, ebp
    mov     ebp, [esp+7D68h+var_7D3C]
    mov     [ecx+8], esi
    mov     [ecx+0Ch], edi
    mov     [ecx+18h], ebx
    add     ecx, 28h
    add     esi, ebp
    mov     ebp, [esp+7D68h+var_7D58]
    mov     [esp+7D68h+var_7D38], ecx
    mov     ecx, [esp+7D68h+var_7D54]
    add     edi, ebp
    add     ebx, eax
    dec     ecx
    mov     [esp+7D68h+var_7D54], ecx
    jnz     short loc_4C89A9

    loc_4C89E3:                             ; CODE XREF: sub_4C8760+23Dj
    mov     esi, [esp+7D68h+arg_8]
    mov     edx, [esp+7D68h+var_7D24]

    loc_4C89EE:                             ; CODE XREF: sub_4C8760+17Bj
    mov     edi, edx
    test    edi, edi
    jge     short loc_4C89F9
    mov     edi, 3

    loc_4C89F9:                             ; CODE XREF: sub_4C8760+292j
    cmp     edi, [esp+7D68h+var_7D28]
    jnz     loc_4C88A0
    mov     edi, [esp+7D68h+var_7D40]
    lea     eax, [esp+7D68h+var_7D00]
    mov     [esp+7D68h+var_7D38], eax
    jmp     short loc_4C8A18
    ; ---------------------------------------------------------------------------

    loc_4C8A11:                             ; CODE XREF: sub_4C8760+3F9j
    mov     esi, [esp+7D68h+arg_8]

    loc_4C8A18:                             ; CODE XREF: sub_4C8760+2AFj
    lea     eax, [edi+1]
    lea     ecx, [edi+edi*2]
    and     eax, 3
    mov     ebp, [esi+ecx*4+4]
    lea     ebx, [esi+ecx*4]
    mov     ecx, [esp+7D68h+arg_8]
    lea     edx, [eax+eax*2]
    mov     [esp+7D68h+var_7D54], eax
    lea     edx, [ecx+edx*4]
    mov     [esp+7D68h+var_7D30], edx
    mov     ecx, [edx+4]
    cmp     ebp, ecx
    mov     [esp+7D68h+var_7D4C], ecx
    jge     loc_4C8B51
    mov     esi, [ebx]
    mov     eax, [edx]
    sub     eax, esi
    sub     ecx, ebp
    shl     eax, 10h
    cdq
    idiv    ecx
    mov     edx, [esp+7D68h+var_7D54]
    mov     ebx, [ebx+8]
    shl     esi, 10h
    add     esi, 0FFFFh
    mov     [esp+7D68h+var_7D50], esi
    shl     ebx, 10h
    mov     [esp+7D68h+var_7D34], eax
    mov     eax, [esp+7D68h+arg_C]
    mov     esi, [eax+edi*8]
    mov     edi, [eax+edi*8+4]
    mov     eax, [eax+edx*8]
    shl     esi, 10h
    shl     eax, 10h
    sub     eax, esi
    cdq
    idiv    ecx
    mov     edx, [esp+7D68h+var_7D54]
    shl     edi, 10h
    mov     [esp+7D68h+var_7D3C], eax
    mov     eax, [esp+7D68h+arg_C]
    mov     eax, [eax+edx*8+4]
    shl     eax, 10h
    sub     eax, edi
    cdq
    idiv    ecx
    mov     [esp+7D68h+var_7D58], eax
    mov     eax, [esp+7D68h+var_7D30]
    mov     eax, [eax+8]
    shl     eax, 10h
    sub     eax, ebx
    cdq
    idiv    ecx
    test    ebp, ebp
    jge     short loc_4C8AF2
    mov     ecx, [esp+7D68h+var_7D34]
    mov     edx, [esp+7D68h+var_7D50]
    imul    ecx, ebp
    sub     edx, ecx
    mov     ecx, [esp+7D68h+var_7D58]
    mov     [esp+7D68h+var_7D50], edx
    mov     edx, [esp+7D68h+var_7D3C]
    imul    edx, ebp
    imul    ecx, ebp
    sub     esi, edx
    mov     edx, eax
    imul    edx, ebp
    sub     edi, ecx
    sub     ebx, edx
    xor     ebp, ebp

    loc_4C8AF2:                             ; CODE XREF: sub_4C8760+364j
    mov     ecx, [esp+7D68h+var_7D4C]
    mov     edx, [esp+7D68h+var_7D2C]
    cmp     ecx, edx
    jle     short loc_4C8B04
    mov     [esp+7D68h+var_7D4C], edx
    mov     ecx, edx

    loc_4C8B04:                             ; CODE XREF: sub_4C8760+39Cj
    cmp     ebp, ecx
    jge     short loc_4C8B4D
    mov     edx, [esp+7D68h+var_7D50]
    sub     ecx, ebp
    mov     [esp+7D68h+var_7D40], ecx

    loc_4C8B12:                             ; CODE XREF: sub_4C8760+3EBj
    mov     ecx, [esp+7D68h+var_7D38]
    mov     ebp, edx
    sar     ebp, 10h
    mov     [ecx+4], ebp
    mov     ebp, [esp+7D68h+var_7D34]
    add     edx, ebp
    mov     ebp, [esp+7D68h+var_7D3C]
    mov     [ecx+10h], esi
    mov     [ecx+14h], edi
    mov     [ecx+1Ch], ebx
    add     ecx, 28h
    add     esi, ebp
    mov     ebp, [esp+7D68h+var_7D58]
    mov     [esp+7D68h+var_7D38], ecx
    mov     ecx, [esp+7D68h+var_7D40]
    add     edi, ebp
    add     ebx, eax
    dec     ecx
    mov     [esp+7D68h+var_7D40], ecx
    jnz     short loc_4C8B12

    loc_4C8B4D:                             ; CODE XREF: sub_4C8760+3A6j
    mov     eax, [esp+7D68h+var_7D54]

    loc_4C8B51:                             ; CODE XREF: sub_4C8760+2E6j
    mov     edi, eax
    mov     eax, [esp+7D68h+var_7D28]
    cmp     edi, eax
    jnz     loc_4C8A11
    mov     esi, [esp+7D68h+var_7D44]
    mov     ebx, [esp+7D68h+var_7D48]
    cmp     esi, ebx
    lea     edi, [esp+7D68h+var_7D00]
    jge     short loc_4C8B99

    loc_4C8B6F:                             ; CODE XREF: sub_4C8760+437j
    mov     eax, [edi+4]
    mov     edx, [edi]
    sub     eax, edx
    test    eax, eax
    jle     short loc_4C8B91
    mov     ecx, [esp+7D68h+arg_4]
    mov     edx, [esp+7D68h+arg_0]
    push    ecx
    push    edx
    push    edi
    push    esi
    call    sub_4C7A20

    loc_4C8B91:                             ; CODE XREF: sub_4C8760+418j
    add     edi, 28h
    inc     esi
    cmp     esi, ebx
    jl      short loc_4C8B6F

    loc_4C8B99:                             ; CODE XREF: sub_4C8760+19j
                                            ; sub_4C8760+28j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7D58h
    retn    10h
    sub_4C8760 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C8BB0 proc near                    ; CODE XREF: sub_459C70+72Cp

    var_7D60= dword ptr -7D60h
    var_7D5C= dword ptr -7D5Ch
    var_7D58= dword ptr -7D58h
    var_7D54= dword ptr -7D54h
    var_7D50= dword ptr -7D50h
    var_7D4C= dword ptr -7D4Ch
    var_7D48= dword ptr -7D48h
    var_7D44= dword ptr -7D44h
    var_7D40= dword ptr -7D40h
    var_7D3C= dword ptr -7D3Ch
    var_7D38= dword ptr -7D38h
    var_7D34= dword ptr -7D34h
    var_7D30= dword ptr -7D30h
    var_7D2C= dword ptr -7D2Ch
    var_7D28= dword ptr -7D28h
    var_7D24= dword ptr -7D24h
    var_7D20= dword ptr -7D20h
    var_7D1C= dword ptr -7D1Ch
    var_7D18= dword ptr -7D18h
    var_7D14= dword ptr -7D14h
    var_7D10= dword ptr -7D10h
    var_7D0C= dword ptr -7D0Ch
    var_7D08= dword ptr -7D08h
    var_7D04= dword ptr -7D04h
    var_7D00= dword ptr -7D00h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, 7D60h
    call    __alloca_probe
    mov     eax, [esp+7D60h+arg_0]
    push    ebx
    push    ebp
    xor     ebp, ebp
    push    esi
    cmp     eax, ebp
    push    edi
    jz      loc_4C90A2
    mov     ecx, [esp+7D70h+arg_4]
    cmp     ecx, ebp
    jz      loc_4C90A2
    mov     edx, [esp+7D70h+arg_8]
    cmp     edx, ebp
    jz      loc_4C90A2
    mov     ebx, [esp+7D70h+arg_C]
    cmp     ebx, ebp
    jnz     short loc_4C8C37
    lea     eax, [esp+7D70h+var_7D20]
    mov     [esp+7D70h+var_7D20], ebp
    mov     [esp+7D70h+arg_C], eax
    xor     eax, eax
    mov     ax, [ecx]
    mov     ebx, [esp+7D70h+arg_C]
    dec     eax
    mov     [esp+7D70h+var_7D1C], ebp
    mov     [esp+7D70h+var_7D18], eax
    mov     [esp+7D70h+var_7D10], eax
    xor     eax, eax
    mov     [esp+7D70h+var_7D14], ebp
    mov     ax, [ecx+2]
    mov     [esp+7D70h+var_7D08], ebp
    dec     eax
    mov     [esp+7D70h+var_7D0C], eax
    mov     [esp+7D70h+var_7D04], eax

    loc_4C8C37:                             ; CODE XREF: sub_4C8BB0+46j
    mov     esi, 0F423Fh
    mov     edi, 0FFF0BDC1h
    mov     [esp+7D70h+var_7D3C], esi
    mov     [esp+7D70h+var_7D48], edi
    mov     [esp+7D70h+var_7D58], esi
    xor     ecx, ecx

    loc_4C8C4F:                             ; CODE XREF: sub_4C8BB0+DBj
    mov     eax, [edx+4]
    cmp     eax, esi
    jge     short loc_4C8C60
    mov     [esp+7D70h+var_7D3C], eax
    mov     [esp+7D70h+var_7D40], ecx
    mov     esi, eax

    loc_4C8C60:                             ; CODE XREF: sub_4C8BB0+A4j
    cmp     eax, [esp+7D70h+var_7D48]
    jle     short loc_4C8C6E
    mov     [esp+7D70h+var_7D48], eax
    mov     [esp+7D70h+var_7D28], ecx

    loc_4C8C6E:                             ; CODE XREF: sub_4C8BB0+B4j
    mov     eax, [edx]
    cmp     eax, edi
    jle     short loc_4C8C76
    mov     edi, eax

    loc_4C8C76:                             ; CODE XREF: sub_4C8BB0+C2j
    mov     ebp, [esp+7D70h+var_7D58]
    cmp     eax, ebp
    jge     short loc_4C8C84
    mov     ebp, eax
    mov     [esp+7D70h+var_7D58], ebp

    loc_4C8C84:                             ; CODE XREF: sub_4C8BB0+CCj
    inc     ecx
    add     edx, 10h
    cmp     ecx, 4
    jl      short loc_4C8C4F
    test    edi, edi
    jl      loc_4C90A2
    mov     ecx, [esp+7D70h+arg_0]
    xor     edx, edx
    mov     dx, [ecx]
    dec     edx
    cmp     ebp, edx
    jg      loc_4C90A2
    mov     edx, [esp+7D70h+var_7D48]
    test    edx, edx
    jl      loc_4C90A2
    xor     eax, eax
    mov     ax, [ecx+2]
    dec     eax
    cmp     esi, eax
    mov     [esp+7D70h+var_7D2C], eax
    jg      loc_4C90A2
    test    esi, esi
    jge     short loc_4C8CD9
    mov     [esp+7D70h+var_7D3C], 0
    mov     esi, [esp+7D70h+var_7D3C]

    loc_4C8CD9:                             ; CODE XREF: sub_4C8BB0+11Bj
    cmp     edx, eax
    jle     short loc_4C8CE3
    mov     [esp+7D70h+var_7D48], eax
    mov     edx, eax

    loc_4C8CE3:                             ; CODE XREF: sub_4C8BB0+12Bj
    cmp     edx, esi
    jz      loc_4C90A2
    mov     edi, [esp+7D70h+var_7D40]
    lea     eax, [esp+7D70h+var_7D00]
    mov     [esp+7D70h+var_7D44], eax

    loc_4C8CF7:                             ; CODE XREF: sub_4C8BB0+2FFj
    lea     edx, [edi-1]
    mov     eax, edx
    mov     [esp+7D70h+var_7D24], edx
    test    eax, eax
    mov     [esp+7D70h+var_7D5C], eax
    jge     short loc_4C8D14
    mov     [esp+7D70h+var_7D5C], 3
    mov     eax, [esp+7D70h+var_7D5C]

    loc_4C8D14:                             ; CODE XREF: sub_4C8BB0+156j
    mov     esi, [esp+7D70h+arg_8]
    mov     ecx, edi
    shl     ecx, 4
    shl     eax, 4
    lea     ebp, [ecx+esi]
    mov     ecx, [esp+7D70h+arg_8]
    add     eax, ecx
    mov     esi, [ebp+4]
    mov     [esp+7D70h+var_7D60], eax
    mov     ecx, [eax+4]
    mov     [esp+7D70h+var_7D50], esi
    test    ecx, ecx
    mov     [esp+7D70h+var_7D54], ecx
    jle     loc_4C8EA0
    cmp     esi, ecx
    jge     loc_4C8EA0
    mov     eax, [eax]
    sub     ecx, esi
    mov     esi, [ebp+0]
    sub     eax, esi
    shl     eax, 10h
    cdq
    idiv    ecx
    mov     edx, [esp+7D70h+arg_C]
    shl     esi, 10h
    add     esi, 0FFFFh
    mov     [esp+7D70h+var_7D4C], esi
    mov     esi, [ebx+edi*8]
    shl     esi, 10h
    mov     edi, [ebx+edi*8+4]
    mov     ebx, [ebp+8]
    shl     edi, 10h
    shl     ebx, 10h
    mov     ebp, [ebp+0Ch]
    shl     ebp, 10h
    mov     [esp+7D70h+var_7D30], eax
    mov     eax, [esp+7D70h+var_7D5C]
    mov     eax, [edx+eax*8]
    shl     eax, 10h
    sub     eax, esi
    cdq
    idiv    ecx
    mov     edx, [esp+7D70h+arg_C]
    mov     [esp+7D70h+var_7D34], eax
    mov     eax, [esp+7D70h+var_7D5C]
    mov     eax, [edx+eax*8+4]
    shl     eax, 10h
    sub     eax, edi
    cdq
    idiv    ecx
    mov     edx, [esp+7D70h+var_7D60]
    mov     [esp+7D70h+var_7D38], eax
    mov     eax, [edx+8]
    shl     eax, 10h
    sub     eax, ebx
    cdq
    idiv    ecx
    mov     [esp+7D70h+var_7D5C], eax
    mov     eax, [esp+7D70h+var_7D60]
    mov     eax, [eax+0Ch]
    shl     eax, 10h
    sub     eax, ebp
    cdq
    idiv    ecx
    mov     ecx, [esp+7D70h+var_7D50]
    test    ecx, ecx
    mov     [esp+7D70h+var_7D60], eax
    jge     short loc_4C8E2E
    mov     edx, [esp+7D70h+var_7D30]
    mov     eax, [esp+7D70h+var_7D4C]
    imul    edx, ecx
    sub     eax, edx
    mov     edx, [esp+7D70h+var_7D38]
    mov     [esp+7D70h+var_7D4C], eax
    mov     eax, [esp+7D70h+var_7D34]
    imul    eax, ecx
    imul    edx, ecx
    sub     esi, eax
    mov     eax, [esp+7D70h+var_7D5C]
    sub     edi, edx
    mov     edx, [esp+7D70h+var_7D60]
    imul    eax, ecx
    imul    edx, ecx
    mov     [esp+7D70h+var_7D50], 0
    sub     ebx, eax
    mov     ecx, [esp+7D70h+var_7D50]
    sub     ebp, edx

    loc_4C8E2E:                             ; CODE XREF: sub_4C8BB0+23Bj
    mov     eax, [esp+7D70h+var_7D54]
    mov     edx, [esp+7D70h+var_7D2C]
    cmp     eax, edx
    jle     short loc_4C8E40
    mov     [esp+7D70h+var_7D54], edx
    mov     eax, edx

    loc_4C8E40:                             ; CODE XREF: sub_4C8BB0+288j
    cmp     ecx, eax
    jge     short loc_4C8E95
    sub     eax, ecx
    mov     [esp+7D70h+var_7D58], eax
    mov     eax, [esp+7D70h+var_7D4C]

    loc_4C8E4E:                             ; CODE XREF: sub_4C8BB0+2E3j
    mov     ecx, [esp+7D70h+var_7D44]
    mov     edx, eax
    sar     edx, 10h
    mov     [ecx], edx
    mov     edx, [esp+7D70h+var_7D30]
    add     eax, edx
    mov     edx, [esp+7D70h+var_7D34]
    mov     [ecx+8], esi
    add     esi, edx
    mov     edx, [esp+7D70h+var_7D38]
    mov     [ecx+0Ch], edi
    add     edi, edx
    mov     edx, [esp+7D70h+var_7D5C]
    mov     [ecx+18h], ebx
    mov     [ecx+20h], ebp
    add     ecx, 28h
    add     ebx, edx
    mov     edx, [esp+7D70h+var_7D60]
    mov     [esp+7D70h+var_7D44], ecx
    mov     ecx, [esp+7D70h+var_7D58]
    add     ebp, edx
    dec     ecx
    mov     [esp+7D70h+var_7D58], ecx
    jnz     short loc_4C8E4E

    loc_4C8E95:                             ; CODE XREF: sub_4C8BB0+292j
    mov     ebx, [esp+7D70h+arg_C]
    mov     edx, [esp+7D70h+var_7D24]

    loc_4C8EA0:                             ; CODE XREF: sub_4C8BB0+193j
                                            ; sub_4C8BB0+19Bj
    mov     edi, edx
    test    edi, edi
    jge     short loc_4C8EAB
    mov     edi, 3

    loc_4C8EAB:                             ; CODE XREF: sub_4C8BB0+2F4j
    cmp     edi, [esp+7D70h+var_7D28]
    jnz     loc_4C8CF7
    mov     edi, [esp+7D70h+var_7D40]
    lea     eax, [esp+7D70h+var_7D00]
    mov     [esp+7D70h+var_7D44], eax

    loc_4C8EC1:                             ; CODE XREF: sub_4C8BB0+4B2j
    mov     edx, [esp+7D70h+arg_8]
    lea     esi, [edi+1]
    mov     ecx, edi
    and     esi, 3
    shl     ecx, 4
    mov     eax, esi
    mov     [esp+7D70h+var_7D58], esi
    lea     ebp, [ecx+edx]
    mov     ecx, [esp+7D70h+arg_8]
    shl     eax, 4
    mov     edx, [ebp+4]
    add     eax, ecx
    mov     [esp+7D70h+var_7D50], edx
    mov     [esp+7D70h+var_7D60], eax
    mov     ecx, [eax+4]
    test    ecx, ecx
    mov     [esp+7D70h+var_7D54], ecx
    jle     loc_4C905A
    cmp     edx, ecx
    jge     loc_4C905A
    mov     esi, [ebp+0]
    mov     eax, [eax]
    sub     eax, esi
    sub     ecx, edx
    shl     eax, 10h
    cdq
    idiv    ecx
    mov     edx, [esp+7D70h+arg_C]
    shl     esi, 10h
    add     esi, 0FFFFh
    mov     [esp+7D70h+var_7D4C], esi
    mov     esi, [ebx+edi*8]
    shl     esi, 10h
    mov     edi, [ebx+edi*8+4]
    mov     ebx, [ebp+8]
    shl     edi, 10h
    shl     ebx, 10h
    mov     ebp, [ebp+0Ch]
    shl     ebp, 10h
    mov     [esp+7D70h+var_7D30], eax
    mov     eax, [esp+7D70h+var_7D58]
    mov     eax, [edx+eax*8]
    shl     eax, 10h
    sub     eax, esi
    cdq
    idiv    ecx
    mov     edx, [esp+7D70h+arg_C]
    mov     [esp+7D70h+var_7D34], eax
    mov     eax, [esp+7D70h+var_7D58]
    mov     eax, [edx+eax*8+4]
    shl     eax, 10h
    sub     eax, edi
    cdq
    idiv    ecx
    mov     edx, [esp+7D70h+var_7D60]
    mov     [esp+7D70h+var_7D38], eax
    mov     eax, [edx+8]
    shl     eax, 10h
    sub     eax, ebx
    cdq
    idiv    ecx
    mov     [esp+7D70h+var_7D5C], eax
    mov     eax, [esp+7D70h+var_7D60]
    mov     eax, [eax+0Ch]
    shl     eax, 10h
    sub     eax, ebp
    cdq
    idiv    ecx
    mov     ecx, [esp+7D70h+var_7D50]
    test    ecx, ecx
    mov     [esp+7D70h+var_7D60], eax
    jge     short loc_4C8FE7
    mov     edx, [esp+7D70h+var_7D30]
    mov     eax, [esp+7D70h+var_7D4C]
    imul    edx, ecx
    sub     eax, edx
    mov     edx, [esp+7D70h+var_7D38]
    mov     [esp+7D70h+var_7D4C], eax
    mov     eax, [esp+7D70h+var_7D34]
    imul    eax, ecx
    imul    edx, ecx
    sub     esi, eax
    mov     eax, [esp+7D70h+var_7D5C]
    sub     edi, edx
    mov     edx, [esp+7D70h+var_7D60]
    imul    eax, ecx
    imul    edx, ecx
    mov     [esp+7D70h+var_7D50], 0
    sub     ebx, eax
    mov     ecx, [esp+7D70h+var_7D50]
    sub     ebp, edx

    loc_4C8FE7:                             ; CODE XREF: sub_4C8BB0+3F4j
    mov     eax, [esp+7D70h+var_7D54]
    mov     edx, [esp+7D70h+var_7D2C]
    cmp     eax, edx
    jle     short loc_4C8FF9
    mov     [esp+7D70h+var_7D54], edx
    mov     eax, edx

    loc_4C8FF9:                             ; CODE XREF: sub_4C8BB0+441j
    cmp     ecx, eax
    jge     short loc_4C904F
    sub     eax, ecx
    mov     [esp+7D70h+var_7D40], eax
    mov     eax, [esp+7D70h+var_7D4C]

    loc_4C9007:                             ; CODE XREF: sub_4C8BB0+49Dj
    mov     ecx, [esp+7D70h+var_7D44]
    mov     edx, eax
    sar     edx, 10h
    mov     [ecx+4], edx
    mov     edx, [esp+7D70h+var_7D30]
    add     eax, edx
    mov     edx, [esp+7D70h+var_7D34]
    mov     [ecx+10h], esi
    add     esi, edx
    mov     edx, [esp+7D70h+var_7D38]
    mov     [ecx+14h], edi
    add     edi, edx
    mov     edx, [esp+7D70h+var_7D5C]
    mov     [ecx+1Ch], ebx
    mov     [ecx+24h], ebp
    add     ecx, 28h
    add     ebx, edx
    mov     edx, [esp+7D70h+var_7D60]
    mov     [esp+7D70h+var_7D44], ecx
    mov     ecx, [esp+7D70h+var_7D40]
    add     ebp, edx
    dec     ecx
    mov     [esp+7D70h+var_7D40], ecx
    jnz     short loc_4C9007

    loc_4C904F:                             ; CODE XREF: sub_4C8BB0+44Bj
    mov     esi, [esp+7D70h+var_7D58]
    mov     ebx, [esp+7D70h+arg_C]

    loc_4C905A:                             ; CODE XREF: sub_4C8BB0+34Cj
                                            ; sub_4C8BB0+354j
    mov     eax, [esp+7D70h+var_7D28]
    mov     edi, esi
    cmp     edi, eax
    jnz     loc_4C8EC1
    mov     esi, [esp+7D70h+var_7D3C]
    mov     ebx, [esp+7D70h+var_7D48]
    cmp     esi, ebx
    lea     edi, [esp+7D70h+var_7D00]
    jge     short loc_4C90A2

    loc_4C9078:                             ; CODE XREF: sub_4C8BB0+4F0j
    mov     eax, [edi+4]
    mov     edx, [edi]
    sub     eax, edx
    test    eax, eax
    jle     short loc_4C909A
    mov     ecx, [esp+7D70h+arg_4]
    mov     edx, [esp+7D70h+arg_0]
    push    ecx
    push    edx
    push    edi
    push    esi
    call    sub_4C8020

    loc_4C909A:                             ; CODE XREF: sub_4C8BB0+4D1j
    add     edi, 28h
    inc     esi
    cmp     esi, ebx
    jl      short loc_4C9078

    loc_4C90A2:                             ; CODE XREF: sub_4C8BB0+19j
                                            ; sub_4C8BB0+28j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 7D60h
    retn    10h
    sub_4C8BB0 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    ecx
    mov     eax, [esp+8]
    push    ebx
    push    esi
    mov     ebx, ecx
    mov     esi, [eax]
    xor     ecx, ecx
    cmp     byte ptr [esi], 0
    setz    cl
    test    cl, cl
    jnz     loc_4C916B
    push    edi
    mov     edi, [ebx]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, esi
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    push    ebp
    mov     [esp+10h], edx
    lea     eax, [ecx+edx+1]
    add     eax, 5
    push    eax
    call    _malloc
    mov     dword ptr [eax], 1
    mov     edi, [ebx]
    lea     ebp, [eax+4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 4
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, [esp+10h]
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     edx, [eax+ebp]
    and     ecx, 3
    mov     eax, [esp+18h]
    rep movsb
    mov     edi, [eax]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebx]
    mov     edx, [eax-4]
    dec     edx
    mov     [eax-4], edx
    mov     eax, [ebx]
    add     eax, 0FFFFFFFCh
    cmp     dword ptr [eax], 0
    jnz     short loc_4C9167
    push    eax
    call    _free
    add     esp, 4

    loc_4C9167:                             ; CODE XREF: .text:004C915Cj
    mov     [ebx], ebp
    pop     ebp
    pop     edi

    loc_4C916B:                             ; CODE XREF: .text:004C90C5j
    mov     eax, ebx
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9180 proc near                    ; CODE XREF: sub_4C3E40+1A4p
                                            ; sub_4C54F0+1B6p
    mov     eax, ecx
    mov     ecx, dword_50A778
    inc     ecx
    mov     dword_50A778, ecx
    mov     dword ptr [eax], offset dword_50A77C
    retn
    sub_4C9180 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C91A0 proc near                    ; CODE XREF: sub_42E440+C88p
                                            ; sub_432C40+1Ap ...

    arg_0= dword ptr  4

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     edx, [ecx]
    mov     [eax], edx
    inc     dword ptr [edx-4]
    retn    4
    sub_4C91A0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C91B0 proc near                    ; CODE XREF: sub_42E440+BD7p
                                            ; sub_4373A0+16Cp ...

    arg_0= dword ptr  0Ch

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    test    esi, esi
    mov     ebx, ecx
    jz      short loc_4C920B
    cmp     byte ptr [esi], 0
    jz      short loc_4C920B
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    add     ecx, 4
    push    ecx                             ; size_t
    call    _malloc
    mov     dword ptr [eax], 1
    lea     edx, [eax+4]
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 4
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, ebx
    and     ecx, 3
    rep movsb
    mov     [ebx], edx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C920B:                             ; CODE XREF: sub_4C91B0+Bj
                                            ; sub_4C91B0+10j
    mov     eax, dword_50A778
    mov     edx, offset dword_50A77C
    inc     eax
    pop     edi
    mov     dword_50A778, eax
    mov     [ebx], edx
    mov     eax, ebx
    pop     esi
    pop     ebx
    retn    4
    sub_4C91B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    ebp
    mov     ebp, [esp+0Ch]
    mov     ebx, ecx
    test    ebp, ebp
    jnz     short loc_4C9254
    mov     eax, dword_50A778
    inc     eax
    mov     dword_50A778, eax
    mov     dword ptr [ebx], offset dword_50A77C
    mov     eax, ebx
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4C9254:                             ; CODE XREF: .text:004C923Aj
    push    edi
    mov     edi, [esp+14h]
    push    esi
    lea     eax, [edi+5]
    push    eax
    call    _malloc
    add     esp, 4
    lea     esi, [eax+4]
    mov     dword ptr [eax], 1
    push    edi
    push    ebp
    push    esi
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [esi+edi], 0
    mov     [ebx], esi
    mov     eax, ebx
    pop     esi
    pop     edi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9290 proc near                    ; CODE XREF: DoInterpretCommand+3Cp
    push    ebx
    mov     ebx, ecx
    push    edi
    or      ecx, 0FFFFFFFFh
    mov     edx, [ebx]
    xor     eax, eax
    mov     edi, edx
    repne scasb
    mov     eax, [edx-4]
    not     ecx
    dec     ecx
    cmp     eax, 1
    jz      short loc_4C9302
    push    esi
    add     ecx, 5
    push    ebp
    push    ecx                             ; size_t
    call    _malloc
    mov     dword ptr [eax], 1
    mov     edi, [ebx]
    lea     ebp, [eax+4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 4
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebx]
    mov     edx, [eax-4]
    dec     edx
    mov     [eax-4], edx
    mov     eax, [ebx]
    add     eax, 0FFFFFFFCh
    cmp     dword ptr [eax], 0
    jnz     short loc_4C92FC
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4C92FC:                             ; CODE XREF: sub_4C9290+61j
    mov     [ebx], ebp
    mov     edx, ebp
    pop     ebp
    pop     esi

    loc_4C9302:                             ; CODE XREF: sub_4C9290+18j
    push    edx                             ; lpMultiByteStr
    call    sub_4E8960
    add     esp, 4
    mov     eax, ebx
    pop     edi
    pop     ebx
    retn
    sub_4C9290 endp

    ; ---------------------------------------------------------------------------
    push    ebx
    mov     ebx, ecx
    push    edi
    or      ecx, 0FFFFFFFFh
    mov     edx, [ebx]
    xor     eax, eax
    mov     edi, edx
    repne scasb
    mov     eax, [edx-4]
    not     ecx
    dec     ecx
    cmp     eax, 1
    jz      short loc_4C9382
    push    esi
    add     ecx, 5
    push    ebp
    push    ecx
    call    _malloc
    mov     dword ptr [eax], 1
    mov     edi, [ebx]
    lea     ebp, [eax+4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 4
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebx]
    mov     edx, [eax-4]
    dec     edx
    mov     [eax-4], edx
    mov     eax, [ebx]
    add     eax, 0FFFFFFFCh
    cmp     dword ptr [eax], 0
    jnz     short loc_4C937C
    push    eax
    call    _free
    add     esp, 4

    loc_4C937C:                             ; CODE XREF: .text:004C9371j
    mov     [ebx], ebp
    mov     edx, ebp
    pop     ebp
    pop     esi

    loc_4C9382:                             ; CODE XREF: .text:004C9328j
    push    edx
    call    sub_4E8AE0
    add     esp, 4
    mov     eax, ebx
    pop     edi
    pop     ebx
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9390 proc near                    ; CODE XREF: sub_4222E0+DEp
                                            ; sub_42A610+22Fp ...
    mov     eax, [ecx]
    mov     edx, [eax-4]
    dec     edx
    mov     [eax-4], edx
    mov     ecx, [ecx]
    lea     eax, [ecx-4]
    mov     ecx, [ecx-4]
    test    ecx, ecx
    jnz     short locret_4C93AE
    push    eax                             ; void *
    call    _free
    add     esp, 4

    locret_4C93AE:                          ; CODE XREF: sub_4C9390+13j
    retn
    sub_4C9390 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C93B0 proc near                    ; CODE XREF: sub_432C80+16p
                                            ; sub_432CB0+1Cp ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    mov     esi, ecx
    mov     eax, [edi]
    mov     ecx, [eax-4]
    inc     ecx
    mov     [eax-4], ecx
    mov     eax, [esi]
    mov     edx, [eax-4]
    dec     edx
    mov     [eax-4], edx
    mov     eax, [esi]
    add     eax, 0FFFFFFFCh
    cmp     dword ptr [eax], 0
    jnz     short loc_4C93DD
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4C93DD:                             ; CODE XREF: sub_4C93B0+22j
    mov     eax, [edi]
    pop     edi
    mov     [esi], eax
    mov     eax, esi
    pop     esi
    retn    4
    sub_4C93B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C93F0 proc near                    ; CODE XREF: sub_4C54F0+1F6p

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    mov     eax, [ebx]
    mov     edx, [eax-4]
    dec     edx
    mov     [eax-4], edx
    mov     eax, [ebx]
    add     eax, 0FFFFFFFCh
    cmp     dword ptr [eax], 0
    jnz     short loc_4C9411
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4C9411:                             ; CODE XREF: sub_4C93F0+16j
    mov     esi, [esp+8+arg_0]
    test    esi, esi
    jz      short loc_4C9467
    cmp     byte ptr [esi], 0
    jz      short loc_4C9467
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    add     ecx, 4
    push    ecx                             ; size_t
    call    _malloc
    mov     dword ptr [eax], 1
    lea     edx, [eax+4]
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 4
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, ebx
    and     ecx, 3
    rep movsb
    mov     [ebx], edx
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9467:                             ; CODE XREF: sub_4C93F0+27j
                                            ; sub_4C93F0+2Cj
    mov     eax, dword_50A778
    mov     edx, offset dword_50A77C
    inc     eax
    pop     edi
    mov     dword_50A778, eax
    mov     [ebx], edx
    mov     eax, ebx
    pop     esi
    pop     ebx
    retn    4
    sub_4C93F0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [ecx]
    push    ebx
    push    esi
    push    edi
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     eax, [esp+14h]
    not     ecx
    dec     ecx
    test    eax, eax
    jge     short loc_4C94AB
    xor     eax, eax

    loc_4C94AB:                             ; CODE XREF: .text:004C94A7j
    mov     edi, [esp+18h]
    cmp     edi, ecx
    jle     short loc_4C94B5
    mov     edi, ecx

    loc_4C94B5:                             ; CODE XREF: .text:004C94B1j
    cmp     eax, edi
    jl      short loc_4C94D4
    mov     eax, dword_50A778
    inc     eax
    mov     dword_50A778, eax
    mov     eax, [esp+10h]
    mov     dword ptr [eax], offset dword_50A77C
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C94D4:                             ; CODE XREF: .text:004C94B7j
    lea     ebx, [eax+edx]
    sub     edi, eax
    test    ebx, ebx
    jnz     short loc_4C94F8
    mov     eax, dword_50A778
    inc     eax
    mov     dword_50A778, eax
    mov     eax, [esp+10h]
    mov     dword ptr [eax], offset dword_50A77C
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C94F8:                             ; CODE XREF: .text:004C94DBj
    lea     eax, [edi+5]
    push    eax
    call    _malloc
    add     esp, 4
    lea     esi, [eax+4]
    mov     dword ptr [eax], 1
    push    edi
    push    ebx
    push    esi
    call    _strncpy
    mov     eax, [esp+1Ch]
    add     esp, 0Ch
    mov     byte ptr [edi+esi], 0
    mov     [eax], esi
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9530 proc near                    ; CODE XREF: sub_462F30+4FDp
                                            ; sub_4C9750+6p ...

    arg_0= dword ptr  4

    push    offset aHapinet_getdpe          ; "HAPINET_GetDPErrorString\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    cmp     eax, 80004005h
    jg      short loc_4C9565
    jz      short loc_4C955D
    cmp     eax, 80004001h
    jnz     loc_4C971B
    mov     eax, offset aDperr_unsuppor     ; "DPERR_UNSUPPORTED - The function is not"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C955D:                             ; CODE XREF: sub_4C9530+18j
    mov     eax, offset aDperr_genericA     ; "DPERR_GENERIC - An undefined error cond"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9565:                             ; CODE XREF: sub_4C9530+16j
    cmp     eax, 80070057h
    jg      short loc_4C9589
    jz      short loc_4C9581
    cmp     eax, 8007000Eh
    jnz     loc_4C971B
    mov     eax, offset aDperr_outofmem     ; "DPERR_OUTOFMEMORY - There is insufficie"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9581:                             ; CODE XREF: sub_4C9530+3Cj
    mov     eax, offset aDperr_invalidp     ; "DPERR_INVALIDPARAMS - One or more of th"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9589:                             ; CODE XREF: sub_4C9530+3Aj
    cmp     eax, 8877000Ah
    jg      short loc_4C95AD
    jz      short loc_4C95A5
    cmp     eax, 88770005h
    jnz     loc_4C971B
    mov     eax, offset aDperr_alreadyi     ; "DPERR_ALREADYINITIALIZED - This object "...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C95A5:                             ; CODE XREF: sub_4C9530+60j
    mov     eax, offset aDperr_accessde     ; "DPERR_ACCESSDENIED - The session is ful"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C95AD:                             ; CODE XREF: sub_4C9530+5Ej
    cmp     eax, 8877001Eh
    jg      short loc_4C95D1
    jz      short loc_4C95C9
    cmp     eax, 88770014h
    jnz     loc_4C971B
    mov     eax, offset aDperr_activepl     ; "DPERR_ACTIVEPLAYERS - The requested ope"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C95C9:                             ; CODE XREF: sub_4C9530+84j
    mov     eax, offset aDperr_bufferto     ; "DPERR_BUFFERTOOSMALL - The supplied buf"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C95D1:                             ; CODE XREF: sub_4C9530+82j
    cmp     eax, 8877003Ch
    jg      short loc_4C95F5
    jz      short loc_4C95ED
    cmp     eax, 88770028h
    jnz     loc_4C971B
    mov     eax, offset aDperr_cantaddp     ; "DPERR_CANTADDPLAYER - The player cannot"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C95ED:                             ; CODE XREF: sub_4C9530+A8j
    mov     eax, offset aDperr_cantcrea     ; "DPERR_CANTCREATEPLAYER - A new player c"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C95F5:                             ; CODE XREF: sub_4C9530+A6j
    cmp     eax, 8877005Ah
    jg      short loc_4C9619
    jz      short loc_4C9611
    cmp     eax, 88770050h
    jnz     loc_4C971B
    mov     eax, offset aDperr_capsnota     ; "DPERR_CAPSNOTAVAILABLEYET - The capabil"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9611:                             ; CODE XREF: sub_4C9530+CCj
    mov     eax, offset aDperr_exceptio     ; "DPERR_EXCEPTION - An exception occurred"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9619:                             ; CODE XREF: sub_4C9530+CAj
    cmp     eax, 88770082h
    jg      short loc_4C963D
    jz      short loc_4C9635
    cmp     eax, 88770078h
    jnz     loc_4C971B
    mov     eax, offset aDperr_invalidf     ; "DPERR_INVALIDFLAGS - The flags passed t"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9635:                             ; CODE XREF: sub_4C9530+F0j
    mov     eax, offset aDperr_invalido     ; "DPERR_INVALIDOBJECT - The DirectPlay ob"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C963D:                             ; CODE XREF: sub_4C9530+EEj
    cmp     eax, 887700A0h
    jg      short loc_4C9661
    jz      short loc_4C9659
    cmp     eax, 88770096h
    jnz     loc_4C971B
    mov     eax, offset aDperr_invali_0     ; "DPERR_INVALIDPLAYER - The player ID is "...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9659:                             ; CODE XREF: sub_4C9530+114j
    mov     eax, offset aDperr_nocapsTh     ; "DPERR_NOCAPS - The communication link u"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9661:                             ; CODE XREF: sub_4C9530+112j
    cmp     eax, 887700BEh
    jg      short loc_4C9685
    jz      short loc_4C967D
    cmp     eax, 887700AAh
    jnz     loc_4C971B
    mov     eax, offset aDperr_noconnec     ; "DPERR_NOCONNECTION - No communication l"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C967D:                             ; CODE XREF: sub_4C9530+138j
    mov     eax, offset aDperr_nomessag     ; "DPERR_NOMESSAGES - There are no message"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9685:                             ; CODE XREF: sub_4C9530+136j
    cmp     eax, 887700D2h
    jg      short loc_4C96A9
    jz      short loc_4C96A1
    cmp     eax, 887700C8h
    jnz     loc_4C971B
    mov     eax, offset aDperr_nonamese     ; "DPERR_NONAMESERVERFOUND - No name serve"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C96A1:                             ; CODE XREF: sub_4C9530+15Cj
    mov     eax, offset aDperr_noplayer     ; "DPERR_NOPLAYERS - There are no active p"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C96A9:                             ; CODE XREF: sub_4C9530+15Aj
    cmp     eax, 887700E6h
    jg      short loc_4C96C9
    jz      short loc_4C96C1
    cmp     eax, 887700DCh
    jnz     short loc_4C971B
    mov     eax, offset aDperr_nosessio     ; "DPERR_NOSESSIONS - There are no existin"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C96C1:                             ; CODE XREF: sub_4C9530+180j
    mov     eax, offset aDperr_sendtoob     ; "DPERR_SENDTOOBIG - The message buffer p"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C96C9:                             ; CODE XREF: sub_4C9530+17Ej
    cmp     eax, 887700FAh
    jg      short loc_4C96E9
    jz      short loc_4C96E1
    cmp     eax, 887700F0h
    jnz     short loc_4C971B
    mov     eax, offset aDperr_timeoutT     ; "DPERR_TIMEOUT - The operation could not"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C96E1:                             ; CODE XREF: sub_4C9530+1A0j
    mov     eax, offset aDperr_unavaila     ; "DPERR_UNAVAILABLE - The requested servi"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C96E9:                             ; CODE XREF: sub_4C9530+19Ej
    cmp     eax, 88770118h
    jg      short loc_4C9709
    jz      short loc_4C9701
    cmp     eax, 8877010Eh
    jnz     short loc_4C971B
    mov     eax, offset aDperr_busyTheD     ; "DPERR_BUSY - The DirectPlay message que"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9701:                             ; CODE XREF: sub_4C9530+1C0j
    mov     eax, offset aDperr_usercanc     ; "DPERR_USERCANCEL - The user canceled th"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9709:                             ; CODE XREF: sub_4C9530+1BEj
    cmp     eax, 88770136h
    jz      short loc_4C9733
    cmp     eax, 88770140h
    jz      short loc_4C972B
    test    eax, eax
    jz      short loc_4C9723

    loc_4C971B:                             ; CODE XREF: sub_4C9530+1Fj
                                            ; sub_4C9530+43j ...
    mov     eax, offset aDperr_ihavenob     ; "DPERR_IHAVENOBLOODYIDEA - DirectPlay re"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9723:                             ; CODE XREF: sub_4C9530+1E9j
    mov     eax, offset aDp_okTheReques     ; "DP_OK - The request completed successfu"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C972B:                             ; CODE XREF: sub_4C9530+1E5j
    mov     eax, offset aDperr_uninitia     ; "DPERR_UNINITIALIZED - An object was not"...
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9733:                             ; CODE XREF: sub_4C9530+1DEj
    mov     eax, offset aDperr_sessionl     ; "DPERR_SESSIONLOST - The session was los"...
    retn    4
    sub_4C9530 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_17. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9750 proc near
    mov     eax, dword_51FF0C
    push    eax
    call    sub_4C9530
    test    eax, eax
    jnz     short loc_4C9769
    push    80004005h
    call    sub_4C9530

    loc_4C9769:                             ; CODE XREF: sub_4C9750+Dj
    push    offset asc_50B0C8               ; char *
    push    eax                             ; char *
    call    _strstr
    add     esp, 8
    test    eax, eax
    jnz     short loc_4C9786
    push    80004005h
    call    sub_4C9530
    retn
    ; ---------------------------------------------------------------------------

    loc_4C9786:                             ; CODE XREF: sub_4C9750+29j
    add     eax, 3
    push    eax                             ; int
    call    sub_4C5740
    retn
    sub_4C9750 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall HAPINET_GuaranteePackets(int GuaranteePackets)
    HAPINET_GuaranteePackets proc near      ; CODE XREF: sub_456310+90p
                                            ; sub_456310+C2p ...

    GuaranteePackets= dword ptr  4

    push    offset aHapinet_guaran          ; "HAPINET_guaranteepackets\n"
    call    nullsub_17
    mov     ecx, [esp+4+GuaranteePackets]
    mov     eax, Global_GuaranteePackets
    add     esp, 4
    mov     Global_GuaranteePackets, ecx
    retn    4
    HAPINET_GuaranteePackets endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall HAPINET_SendPacket(int HAPINET_this,int dwDataSize,int lpData,int idTo,int idFrom)
    HAPINET_SendPacket proc near            ; CODE XREF: Network_SendNetMessage+FDp
                                            ; Network_BroadcastMessage+1ECp ...

    HAPINET_this= dword ptr  4
    dwDataSize= dword ptr  8
    lpData= dword ptr  0Ch
    idTo= dword ptr  10h
    idFrom= dword ptr  14h

    push    offset aHapinet_sendpa          ; "HAPINET_sendpacket\n"
    call    nullsub_17
    mov     ecx, [esp+4+HAPINET_this]
    add     esp, 4
    mov     eax, 887700AAh                  ; error code on no DirectPlay interface
    mov     ecx, [ecx+HAPINET.DirectPlayInterface]
    test    ecx, ecx
    jz      short locret_4C97FA
    mov     eax, [esp+idFrom]
    push    esi
    mov     esi, Global_GuaranteePackets
    push    eax                             ; idFrom
    mov     eax, [esp+8+idTo]
    mov     edx, [ecx]
    push    eax                             ; idTo
    xor     eax, eax
    test    esi, esi
    setnz   al
    push    eax                             ; dwFlags
    mov     eax, [esp+10h+lpData]
    push    eax                             ; lpData
    mov     eax, [esp+14h+dwDataSize]
    push    eax                             ; dwDataSize
    push    ecx                             ; DirectPlay Interface
    call    dword ptr [edx+68h]
    pop     esi

    locret_4C97FA:                          ; CODE XREF: HAPINET_SendPacket+1Ej
    retn    14h
    HAPINET_SendPacket endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall HAPINET_SendPacketGuaranteed(int HAPINET_this,int dwDataSize,int lpData,int idTo,int idFrom)
    HAPINET_SendPacketGuaranteed proc near

    HAPINET_this= dword ptr  4
    dwDataSize= dword ptr  8
    lpData= dword ptr  0Ch
    idTo= dword ptr  10h
    idFrom= dword ptr  14h

    push    offset aHapinet_send_0          ; "HAPINET_sendpacketguaranteed\n"
    call    nullsub_17
    mov     ecx, [esp+4+HAPINET_this]
    add     esp, 4
    mov     eax, 887700AAh
    mov     ecx, [ecx+4C5h]
    test    ecx, ecx
    jz      short locret_4C983C
    mov     eax, [esp+idFrom]
    mov     edx, [ecx]
    push    eax                             ; lpidFrom
    mov     eax, [esp+4+idTo]
    push    eax                             ; lpidTo
    mov     eax, [esp+8+lpData]
    push    1                               ; dwFlags
    push    eax                             ; lpData
    mov     eax, [esp+10h+dwDataSize]
    push    eax                             ; dwDataSize
    push    ecx                             ; DirectPlay Interface
    call    dword ptr [edx+68h]

    locret_4C983C:                          ; CODE XREF: HAPINET_SendPacketGuaranteed+1Ej
    retn    14h
    HAPINET_SendPacketGuaranteed endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall HAPINET_ReceivePacket(int HAPINET_this,int lpidTo,int lpidFrom)
    HAPINET_ReceivePacket proc near         ; CODE XREF: sub_44F9C0+A3p
                                            ; HAPINET_GetPacket+D1p

    HAPINET_this= dword ptr  4
    lpidTo= dword ptr  8
    lpidFrom= dword ptr  0Ch

    push    offset aHapinet_rece_0          ; "HAPINET_receivepacket\n"
    call    nullsub_17
    mov     edx, [esp+4+HAPINET_this]
    add     esp, 4
    mov     eax, 887700AAh
    mov     ecx, [edx+HAPINET.DirectPlayInterface] ; Load the Directplay Interface into the register
    test    ecx, ecx
    jz      short locret_4C9882
    push    esi
    mov     esi, [esp+4+lpidFrom]
    mov     eax, [ecx]
    push    esi                             ; lpidFrom
    mov     esi, [esp+8+lpidTo]
    push    esi                             ; lpidTo
    lea     esi, [edx+HAPINET.BufferPtr]
    push    1                               ; dwFlags
    add     edx, HAPINET.DataSize
    push    esi                             ; lpData
    push    edx                             ; lpdwDataSize
    push    ecx                             ; DirectPlay Interface
    call    dword ptr [eax+64h]             ; Call DirectPlay2.Recieve
    pop     esi

    locret_4C9882:                          ; CODE XREF: HAPINET_ReceivePacket+1Ej
    retn    0Ch
    HAPINET_ReceivePacket endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9890 proc near                    ; CODE XREF: sub_451180+88p
                                            ; Network_Process+3F5p

    GameName= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_C= dword ptr  18h
    arg_10= dword ptr  1Ch
    arg_14= dword ptr  20h
    arg_18= dword ptr  24h

    push    esi
    push    edi
    push    offset aHapinet_update          ; "HAPINET_updategameinfo\n"
    call    nullsub_17
    mov     esi, [esp+4+GameName]
    add     esp, 4
    mov     eax, [esi+4C5h]
    test    eax, eax
    jz      short loc_4C9914
    mov     edi, [esp+arg_4]
    push    10h                             ; size_t
    push    edi                             ; char *
    push    esi                             ; char *
    call    _strncpy
    mov     ecx, [esp+0Ch+arg_18]
    mov     edx, [esp+0Ch+arg_14]
    mov     [esi+4A9h], ecx
    mov     ecx, [esp+0Ch+arg_10]
    mov     [esi+4A5h], edx
    mov     edx, [esp+0Ch+arg_C]
    add     esp, 0Ch
    lea     eax, [esi+45Dh]
    mov     [esi+4A1h], ecx
    mov     [esi+49Dh], edx
    mov     [esi+48Dh], edi
    mov     esi, [esi+4C5h]
    mov     dword ptr [eax], 50h
    push    0                               ; dwFlags
    mov     ecx, [esi]
    push    eax                             ; lpSessDesc
    push    esi                             ; DirectPlay Interface
    call    dword ptr [ecx+7Ch]             ; SetSessionDesc
    test    eax, eax
    jnz     short loc_4C9914
    mov     eax, 1
    pop     edi
    pop     esi
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4C9914:                             ; CODE XREF: sub_4C9890+1Bj
                                            ; sub_4C9890+78j
    pop     edi
    xor     eax, eax
    pop     esi
    retn    1Ch
    sub_4C9890 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9920 proc near                    ; CODE XREF: .text:004515BEp

    var_10= dword ptr -10h
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch
    arg_18= dword ptr  20h

    push    ebx
    push    esi
    push    edi
    push    offset aHapinet_crea_1          ; "HAPINET_createnewgame\n"
    call    nullsub_17
    mov     esi, [esp+0Ch+arg_0]
    add     esp, 4
    mov     eax, [esi+4C5h]
    test    eax, eax
    jz      loc_4C9A67
    mov     ebx, [esp+8+arg_4]
    push    10h                             ; size_t
    push    ebx                             ; char *
    push    esi                             ; char *
    call    _strncpy
    lea     edx, [esi+45Dh]
    mov     ecx, 14h
    xor     eax, eax
    mov     edi, edx
    rep stosd
    mov     eax, [esi+4DDh]
    lea     ecx, [esi+43Dh]
    mov     [esi+485h], eax
    lea     eax, [esi+475h]
    mov     edi, [ecx]
    add     esp, 0Ch
    mov     [eax], edi
    mov     dword ptr [edx], 50h
    mov     edi, [ecx+4]
    mov     [esi+48Dh], ebx
    mov     [eax+4], edi
    push    2
    mov     edi, [ecx+8]
    push    edx
    mov     [eax+8], edi
    mov     ecx, [ecx+0Ch]
    mov     [eax+0Ch], ecx
    mov     eax, [esp+10h+arg_18]
    mov     ecx, [esp+10h+arg_14]
    mov     [esi+4A9h], eax
    mov     eax, [esp+10h+arg_10]
    mov     [esi+4A5h], ecx
    mov     ecx, [esp+10h+arg_C]
    mov     [esi+4A1h], eax
    mov     eax, [esp+10h+arg_8]
    mov     [esi+49Dh], ecx
    mov     [esi+491h], eax
    mov     eax, [esi+4C5h]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+60h]
    mov     ebx, eax
    mov     eax, [esi+4C5h]
    lea     ecx, [esp+14h+var_4]
    mov     [esp+14h+var_4], 50h
    mov     edx, [eax]
    push    ecx
    push    0
    push    eax
    call    dword ptr [edx+58h]
    cmp     eax, 8877001Eh
    jnz     short loc_4C9A58
    mov     edx, [esp+20h+var_10]
    push    edx
    push    offset aDpSessionData2          ; "DP SESSION DATA2"
    call    sub_4D83B0
    mov     edi, eax
    add     esp, 8
    test    edi, edi
    jz      short loc_4C9A58
    mov     eax, [esi+4C5h]
    lea     edx, [esp+20h+var_10]
    push    edx
    push    edi
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+58h]
    test    eax, eax
    jnz     short loc_4C9A4F
    lea     eax, [edi+8]
    add     esi, 465h
    mov     ecx, [eax]
    mov     [esi], ecx
    mov     edx, [eax+4]
    mov     [esi+4], edx
    mov     ecx, [eax+8]
    mov     [esi+8], ecx
    mov     edx, [eax+0Ch]
    mov     [esi+0Ch], edx

    loc_4C9A4F:                             ; CODE XREF: sub_4C9920+10Ej
    push    edi                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4C9A58:                             ; CODE XREF: sub_4C9920+E0j
                                            ; sub_4C9920+F8j
    test    ebx, ebx
    jnz     short loc_4C9A67
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4C9A67:                             ; CODE XREF: sub_4C9920+1Cj
                                            ; sub_4C9920+13Aj
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    1Ch
    sub_4C9920 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9A70 proc near                    ; CODE XREF: sub_451640+155p

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h
    arg_8= dword ptr  1Ch
    arg_C= dword ptr  20h
    arg_10= dword ptr  24h
    arg_14= dword ptr  28h
    arg_18= dword ptr  2Ch

    push    ebx
    push    ebp
    push    esi
    push    edi
    push    offset aHapinet_crea_2          ; "HAPINET_createorjoinlobbygame\n"
    call    nullsub_17
    mov     ecx, [esp+4+arg_4]
    mov     ebx, [esp+4+arg_0]
    mov     ebp, [esp+4+arg_C]
    mov     edi, [esp+4+arg_8]
    add     esp, 4
    xor     eax, eax
    test    ecx, ecx
    jnz     short loc_4C9AB7
    test    edi, edi
    jnz     short loc_4C9AB7
    test    ebp, ebp
    jnz     short loc_4C9AB7
    mov     edx, [esp+arg_10]
    test    edx, edx
    jnz     short loc_4C9AB7
    mov     edx, [esp+arg_14]
    test    edx, edx
    jnz     short loc_4C9AB7
    mov     edx, [esp+arg_18]
    test    edx, edx
    jz      short loc_4C9B2E

    loc_4C9AB7:                             ; CODE XREF: sub_4C9A70+25j
                                            ; sub_4C9A70+29j ...
    mov     eax, [ebx+4D1h]
    test    ecx, ecx
    mov     esi, [eax+8]
    jz      short loc_4C9AD9
    mov     edx, [esi+34h]
    push    10h                             ; size_t
    push    ecx                             ; char *
    mov     byte ptr [edx], 0
    mov     eax, [esi+34h]
    push    eax                             ; char *
    call    _strncat
    add     esp, 0Ch

    loc_4C9AD9:                             ; CODE XREF: sub_4C9A70+52j
    mov     eax, [esi+28h]
    test    eax, eax
    jnz     short loc_4C9AE3
    mov     [esi+28h], edi

    loc_4C9AE3:                             ; CODE XREF: sub_4C9A70+6Ej
    mov     eax, [esi+40h]
    test    eax, eax
    jnz     short loc_4C9AED
    mov     [esi+40h], ebp

    loc_4C9AED:                             ; CODE XREF: sub_4C9A70+78j
    mov     eax, [esi+44h]
    test    eax, eax
    jnz     short loc_4C9AFB
    mov     ecx, [esp+arg_10]
    mov     [esi+44h], ecx

    loc_4C9AFB:                             ; CODE XREF: sub_4C9A70+82j
    mov     eax, [esi+48h]
    test    eax, eax
    jnz     short loc_4C9B09
    mov     edx, [esp+arg_14]
    mov     [esi+48h], edx

    loc_4C9B09:                             ; CODE XREF: sub_4C9A70+90j
    mov     eax, [esi+4Ch]
    test    eax, eax
    jnz     short loc_4C9B17
    mov     eax, [esp+arg_18]
    mov     [esi+4Ch], eax

    loc_4C9B17:                             ; CODE XREF: sub_4C9A70+9Ej
    mov     edx, [ebx+4D1h]
    mov     eax, [ebx+4CDh]
    push    edx
    push    0
    mov     ecx, [eax]
    push    0
    push    eax
    call    dword ptr [ecx+30h]

    loc_4C9B2E:                             ; CODE XREF: sub_4C9A70+45j
    test    eax, eax
    jl      short loc_4C9B5C
    mov     eax, [ebx+4D1h]
    lea     edi, [ebx+45Dh]
    mov     ecx, 14h
    add     ebx, 4C5h
    mov     esi, [eax+8]
    mov     eax, [ebx+8]
    rep movsd
    mov     ecx, [eax]
    push    0
    push    ebx
    push    0
    push    eax
    call    dword ptr [ecx+0Ch]

    loc_4C9B5C:                             ; CODE XREF: sub_4C9A70+C0j
    xor     edx, edx
    pop     edi
    test    eax, eax
    setnl   dl
    pop     esi
    pop     ebp
    mov     eax, edx
    pop     ebx
    retn    1Ch
    sub_4C9A70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9B70 proc near                    ; CODE XREF: .text:004446F4p
                                            ; .text:00450E06p ...

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    push    offset aHapinet_uninit          ; "HAPINET_uninitmultiplay\n"
    call    nullsub_17
    mov     esi, [esp+4+arg_0]
    xor     edi, edi
    add     esp, 4
    mov     eax, [esi+4C5h]
    cmp     eax, edi
    jz      short loc_4C9BA7
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+10h]
    mov     eax, [esi+4C5h]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+8]
    mov     [esi+4C5h], edi

    loc_4C9BA7:                             ; CODE XREF: sub_4C9B70+1Dj
    mov     eax, [esi+4C1h]
    cmp     eax, edi
    jz      short loc_4C9BC9
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+10h]
    mov     eax, [esi+4C1h]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+8]
    mov     [esi+4C1h], edi

    loc_4C9BC9:                             ; CODE XREF: sub_4C9B70+3Fj
    mov     eax, [esi+4CDh]
    cmp     eax, edi
    jz      short loc_4C9BDF
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+8]
    mov     [esi+4CDh], edi

    loc_4C9BDF:                             ; CODE XREF: sub_4C9B70+61j
    mov     eax, [esi+4C9h]
    cmp     eax, edi
    jz      short loc_4C9BF5
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+8]
    mov     [esi+4C9h], edi

    loc_4C9BF5:                             ; CODE XREF: sub_4C9B70+77j
    mov     eax, [esi+4D1h]
    cmp     eax, edi
    jz      short loc_4C9C14
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     [esi+4D1h], edi
    mov     [esi+4D5h], edi

    loc_4C9C14:                             ; CODE XREF: sub_4C9B70+8Dj
    pop     edi
    pop     esi
    retn    4
    sub_4C9B70 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9C20 proc near                    ; CODE XREF: .text:00450D89p
                                            ; .text:00457749p

    arg_0= dword ptr  4

    push    offset aHapinet_init_0          ; "HAPINET_initmultiplaydefaults\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    mov     dword ptr [eax+4DDh], 10h
    mov     dword ptr [eax+4E1h], 5DCh
    retn    4
    sub_4C9C20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_4C9C50:                             ; DATA XREF: sub_4C9E50+B7o
    push    offset aHapinet_getg_0          ; "HAPINET_getgamescallback\n"
    call    nullsub_17
    mov     al, [esp+10h]
    add     esp, 4
    test    al, 1
    jnz     loc_4C9D0A
    push    edi
    push    esi
    push    ebp
    mov     ebp, [esp+1Ch]
    push    ebx
    mov     ebx, [esp+14h]
    mov     ecx, [ebp+4E9h]
    mov     eax, ecx
    mov     edi, [ebx+30h]
    shl     eax, 3
    sub     eax, ecx
    mov     ecx, [ebp+4BDh]
    lea     eax, [eax+eax*2]
    lea     edx, [ecx+eax*4]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    lea     esi, [edx+18h]
    sub     edi, ecx
    mov     eax, ecx
    mov     [esp+1Ch], esi
    mov     esi, edi
    mov     edi, [esp+1Ch]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, [ebx+40h]
    mov     [edx+4], ecx
    mov     eax, [ebx+44h]
    mov     [edx+8], eax
    mov     ecx, [ebx+48h]
    mov     [edx+0Ch], ecx
    mov     eax, [ebx+4Ch]
    lea     ecx, [ebx+8]
    mov     [edx+10h], eax
    lea     eax, [edx+38h]
    mov     esi, [ecx]
    mov     [eax], esi
    mov     esi, [ecx+4]
    mov     [eax+4], esi
    mov     esi, [ecx+8]
    mov     [eax+8], esi
    mov     ecx, [ecx+0Ch]
    mov     [eax+0Ch], ecx
    mov     eax, [ebx+28h]
    mov     [edx+14h], eax
    mov     eax, [ebp+4E9h]
    inc     eax
    pop     ebx
    mov     [ebp+4E9h], eax
    pop     ebp
    pop     esi
    mov     eax, 1
    pop     edi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C9D0A:                             ; CODE XREF: .text:004C9C63j
    xor     eax, eax
    retn    10h
    ; ---------------------------------------------------------------------------
    align 4
    push    offset aHapinet_juston          ; "HAPINET_justone\n"
    call    nullsub_17
    mov     eax, [esp+18h]
    mov     ecx, [esp+8]
    add     esp, 4
    mov     [eax+48h], ecx
    xor     eax, eax
    retn    14h
    ; ---------------------------------------------------------------------------
    align 4
    push    offset aHapinet_setp_0          ; "HAPINET_setplayerdatabuffer\n"
    call    nullsub_17
    mov     eax, [esp+8]
    add     esp, 4
    mov     eax, [eax+4C5h]
    test    eax, eax
    jz      short loc_4C9D6E
    mov     edx, [esp+10h]
    mov     ecx, [eax]
    push    2
    push    edx
    mov     edx, [esp+14h]
    push    edx
    mov     edx, [esp+14h]
    push    edx
    push    eax
    call    dword ptr [ecx+74h]
    test    eax, eax
    jnz     short loc_4C9D6E
    mov     eax, 1
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C9D6E:                             ; CODE XREF: .text:004C9D49j
                                            ; .text:004C9D64j
    xor     eax, eax
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h
    push    offset aHapinet_getp_1          ; "HAPINET_getplayerdatabuffer\n"
    call    nullsub_17
    mov     eax, [esp+8]
    add     esp, 4
    mov     eax, [eax+4C5h]
    test    eax, eax
    jz      short loc_4C9DBE
    mov     edx, [esp+10h]
    mov     ecx, [eax]
    push    0
    push    edx
    mov     edx, [esp+14h]
    push    edx
    mov     edx, [esp+14h]
    push    edx
    push    eax
    call    dword ptr [ecx+50h]
    test    eax, eax
    jnz     short loc_4C9DBE
    mov     eax, 1
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4C9DBE:                             ; CODE XREF: .text:004C9D99j
                                            ; .text:004C9DB4j
    xor     eax, eax
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    edi
    push    offset aHapinet_getcur          ; "HAPINET_getcurrentplayers\n"
    call    nullsub_17
    mov     edi, [esp+10h]
    xor     ebx, ebx
    add     esp, 4
    mov     eax, [edi+4C5h]
    cmp     eax, ebx
    jz      short loc_4C9E3E
    lea     edx, [esp+0Ch]
    mov     [esp+0Ch], ebx
    mov     ecx, [eax]
    push    edx
    push    ebx
    push    eax
    call    dword ptr [ecx+58h]
    cmp     eax, 8877001Eh
    jnz     short loc_4C9E3E
    mov     eax, [esp+0Ch]
    push    esi
    push    eax
    push    offset aDpSessionData           ; "DP SESSION DATA"
    call    sub_4D83B0
    add     esp, 8
    mov     esi, eax
    mov     eax, [edi+4C5h]
    lea     edx, [esp+10h]
    push    edx
    push    esi
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+58h]
    cmp     eax, ebx
    jnz     short loc_4C9E34
    mov     ebx, [esi+2Ch]

    loc_4C9E34:                             ; CODE XREF: .text:004C9E2Fj
    push    esi
    call    sub_4D85A0
    add     esp, 4
    pop     esi

    loc_4C9E3E:                             ; CODE XREF: .text:004C9DEDj
                                            ; .text:004C9E04j
    mov     eax, ebx
    pop     edi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9E50 proc near                    ; CODE XREF: sub_441460+129p

    Msg= MSG ptr -84h
    var_50= dword ptr -50h
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 6Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    offset aHapinet_getgam          ; "HAPINET_getgames\n"
    call    nullsub_17
    mov     esi, [esp+80h+arg_0]
    add     esp, 4
    mov     eax, [esi+4C5h]
    mov     dword ptr [esi+4E9h], 0
    test    eax, eax
    jz      loc_4C9F83
    mov     ecx, 14h
    xor     eax, eax
    lea     edi, [esp+7Ch+var_50]
    mov     ebx, ds:PeekMessageA
    rep stosd
    lea     eax, [esi+43Dh]
    mov     ebp, ds:GetMessageA
    mov     [esp+7Ch+var_50], 50h
    mov     ecx, [eax]
    mov     [esp+7Ch+var_38], ecx
    mov     edx, [eax+4]
    mov     [esp+7Ch+var_34], edx
    mov     ecx, [eax+8]
    mov     [esp+7Ch+var_30], ecx
    mov     edx, [eax+0Ch]
    lea     eax, [esi+465h]
    mov     [esp+7Ch+var_2C], edx
    mov     ecx, [eax]
    mov     [esp+7Ch+var_48], ecx
    mov     edx, [eax+4]
    mov     [esp+7Ch+var_44], edx
    mov     ecx, [eax+8]
    mov     [esp+7Ch+var_40], ecx
    mov     edx, [eax+0Ch]
    mov     eax, [esp+7Ch+arg_4]
    mov     [esp+7Ch+var_3C], edx
    mov     [esi+4BDh], eax

    loc_4C9EF3:                             ; CODE XREF: sub_4C9E50+11Dj
    mov     edx, [esi+4E1h]
    mov     eax, [esi+4C5h]
    push    81h
    push    esi
    mov     ecx, [eax]
    push    offset loc_4C9C50
    push    edx
    lea     edx, [esp+8Ch+var_50]
    push    edx
    push    eax
    call    dword ptr [ecx+34h]
    push    0                               ; wRemoveMsg
    mov     edi, eax
    push    0                               ; wMsgFilterMax
    push    0                               ; wMsgFilterMin
    lea     eax, [esp+0A0h+Msg]
    push    0                               ; hWnd
    push    eax                             ; lpMsg
    mov     dword_51FF0C, edi
    call    ebx ; PeekMessageA
    test    eax, eax
    jz      short loc_4C9F54
    push    0                               ; wMsgFilterMax
    push    0                               ; wMsgFilterMin
    lea     ecx, [esp+9Ch+Msg]
    push    0                               ; hWnd
    push    ecx                             ; lpMsg
    call    ebp ; GetMessageA
    lea     edx, [esp+94h+Msg]
    push    edx                             ; lpMsg
    call    ds:TranslateMessage
    lea     eax, [esp+94h+Msg]
    push    eax                             ; lpMsg
    call    ds:DispatchMessageA

    loc_4C9F54:                             ; CODE XREF: sub_4C9E50+DFj
    call    sub_4C1B00
    test    eax, eax
    jz      short loc_4C9F67
    call    sub_4C1AB0
    cmp     eax, 1Bh
    jz      short loc_4C9F6F

    loc_4C9F67:                             ; CODE XREF: sub_4C9E50+10Bj
    cmp     edi, 8877015Eh
    jz      short loc_4C9EF3

    loc_4C9F6F:                             ; CODE XREF: sub_4C9E50+115j
    test    edi, edi
    jnz     short loc_4C9F83
    mov     eax, [esi+4E9h]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 6Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4C9F83:                             ; CODE XREF: sub_4C9E50+2Dj
                                            ; sub_4C9E50+121j
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    add     esp, 6Ch
    retn    0Ch
    sub_4C9E50 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9F90 proc near                    ; CODE XREF: sub_450E20+71p
                                            ; .text:0045794Cp

    arg_0= dword ptr  4

    push    offset aHapinet_quitga          ; "HAPINET_quitgame\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    mov     eax, [eax+4C5h]
    test    eax, eax
    jz      short loc_4C9FBA
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+10h]
    test    eax, eax
    jz      short loc_4C9FBA
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4C9FBA:                             ; CODE XREF: sub_4C9F90+19j
                                            ; sub_4C9F90+23j
    mov     eax, 1
    retn    4
    sub_4C9F90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4C9FD0 proc near                    ; CODE XREF: sub_4517B0+26Ep

    var_10= dword ptr -10h
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h

    push    ebx
    push    esi
    push    edi
    push    offset aHapinet_joinga          ; "HAPINET_joingame\n"
    call    nullsub_17
    mov     esi, [esp+0Ch+arg_0]
    add     esp, 4
    mov     eax, [esi+4C5h]
    test    eax, eax
    jz      loc_4CA0F4
    lea     edx, [esi+45Dh]
    mov     ecx, 14h
    xor     eax, eax
    mov     edi, edx
    rep stosd
    lea     eax, [esi+43Dh]
    lea     ecx, [esi+475h]
    mov     dword ptr [edx], 50h
    push    1
    mov     edi, [eax]
    push    edx
    mov     [ecx], edi
    mov     edi, [eax+4]
    mov     [ecx+4], edi
    mov     edi, [eax+8]
    mov     [ecx+8], edi
    lea     edi, [esi+465h]
    mov     eax, [eax+0Ch]
    mov     [ecx+0Ch], eax
    mov     eax, [esp+10h+arg_4]
    mov     ecx, edi
    mov     [ecx], eax
    mov     eax, [esp+10h+arg_8]
    mov     [ecx+4], eax
    mov     eax, [esp+10h+arg_C]
    mov     [ecx+8], eax
    mov     eax, [esp+10h+arg_10]
    mov     [ecx+0Ch], eax
    mov     eax, [esi+4C5h]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+60h]
    test    eax, eax
    jnz     loc_4CA0F4
    mov     eax, [esi+4C5h]
    lea     ecx, [esp+14h+var_4]
    mov     [esp+14h+var_4], 50h
    push    ecx
    mov     edx, [eax]
    push    0
    push    eax
    call    dword ptr [edx+58h]
    cmp     eax, 8877001Eh
    jnz     short loc_4CA0E9
    mov     edx, [esp+20h+var_10]
    push    edx
    push    offset aDpSessionData2          ; "DP SESSION DATA2"
    call    sub_4D83B0
    mov     ebx, eax
    add     esp, 8
    test    ebx, ebx
    jz      short loc_4CA0E9
    mov     eax, [esi+4C5h]
    lea     edx, [esp+20h+var_10]
    push    edx
    push    ebx
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+58h]
    test    eax, eax
    jnz     short loc_4CA0E0
    lea     eax, [ebx+8]
    mov     ecx, [ebx+8]
    mov     [edi], ecx
    mov     edx, [eax+4]
    mov     [edi+4], edx
    mov     ecx, [eax+8]
    mov     [edi+8], ecx
    mov     edx, [eax+0Ch]
    mov     [edi+0Ch], edx
    mov     eax, [ebx+30h]
    test    eax, eax
    jz      short loc_4CA0E0
    push    11h                             ; iMaxLength
    push    eax                             ; lpString2
    push    esi                             ; lpString1
    call    ds:lstrcpynA

    loc_4CA0E0:                             ; CODE XREF: sub_4C9FD0+E3j
                                            ; sub_4C9FD0+104j
    push    ebx                             ; int
    call    sub_4D85A0
    add     esp, 4

    loc_4CA0E9:                             ; CODE XREF: sub_4C9FD0+B5j
                                            ; sub_4C9FD0+CDj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebx
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CA0F4:                             ; CODE XREF: sub_4C9FD0+1Cj
                                            ; sub_4C9FD0+8Fj
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    14h
    sub_4C9FD0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA100 proc near                    ; DATA XREF: sub_4CA250+B6o

    var_C8= dword ptr -0C8h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_14= dword ptr  18h

    sub     esp, 0C8h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    offset aHapinet_enumco          ; "HAPINET_enumconnections\n"
    call    nullsub_17
    mov     edx, [esp+0DCh+arg_0]
    add     esp, 4
    mov     eax, offset off_50A788

    loc_4CA123:                             ; CODE XREF: sub_4CA100+3Ej
    mov     edi, [eax]
    mov     ecx, 10h
    mov     esi, edx
    xor     ebx, ebx
    repe cmpsb
    jz      loc_4CA234
    add     eax, 4
    cmp     eax, offset aDperr_sessionl     ; "DPERR_SESSIONLOST - The session was los"...
    jb      short loc_4CA123
    mov     ebx, [esp+0D8h+arg_14]
    mov     ebp, [esp+0D8h+arg_8]
    push    ebp
    push    offset aDplayConnect_1          ; "DPLAY CONNECTION"
    mov     eax, [ebx+4E5h]
    mov     ecx, [ebx+431h]
    shl     eax, 4
    add     ecx, eax
    mov     eax, [edx]
    mov     [ecx], eax
    mov     eax, [edx+4]
    mov     [ecx+4], eax
    mov     eax, [edx+8]
    mov     [ecx+8], eax
    mov     edx, [edx+0Ch]
    mov     [ecx+0Ch], edx
    call    sub_4D83B0
    mov     ecx, [ebx+4E5h]
    mov     edx, [ebx+435h]
    add     esp, 8
    mov     [edx+ecx*8], eax
    mov     eax, [ebx+4E5h]
    mov     ecx, [ebx+435h]
    mov     edi, [ecx+eax*8]
    test    edi, edi
    jnz     short loc_4CA1B4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0C8h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4CA1B4:                             ; CODE XREF: sub_4CA100+A3j
    mov     esi, [esp+0D8h+arg_4]
    mov     ecx, ebp
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     edx, [esp+0D8h+arg_C]
    and     ecx, 3
    rep movsb
    mov     eax, [ebx+4E5h]
    mov     ecx, [ebx+435h]
    mov     [ecx+eax*8+4], ebp
    mov     eax, [edx+8]
    push    eax
    lea     ecx, [esp+0DCh+var_C8]
    push    offset aS_1                     ; "%s"
    push    ecx
    call    _sprintf
    mov     edx, [ebx+4E5h]
    mov     eax, [ebx+439h]
    add     esp, 0Ch
    push    edx
    push    eax
    call    sub_4B6AF0
    mov     edx, eax
    lea     edi, [esp+0D8h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    inc     dword ptr [ebx+4E5h]

    loc_4CA234:                             ; CODE XREF: sub_4CA100+30j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 0C8h
    retn    18h
    sub_4CA100 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA250 proc near                    ; CODE XREF: .text:0044471Cp

    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 20h
    push    esi
    push    edi
    push    offset aHapinet_getcon          ; "HAPINET_getconnections\n"
    call    nullsub_17
    mov     esi, [esp+2Ch+arg_0]
    mov     edi, [esp+2Ch+arg_10]
    add     esp, 4
    mov     eax, [esi+4C5h]
    test    eax, eax
    jnz     short loc_4CA2D3
    mov     ecx, ds:dword_4FDAF4
    mov     eax, ds:dword_4FDAF0
    mov     edx, ds:dword_4FDAF8
    mov     [esp+28h+var_C], ecx
    mov     ecx, edi
    mov     [esp+28h+var_10], eax
    mov     eax, ds:dword_4FDAFC
    mov     [esp+28h+var_8], edx
    mov     edx, [ecx]
    mov     [esp+28h+var_4], eax
    mov     [esp+28h+var_20], edx
    mov     eax, [ecx+4]
    mov     [esp+28h+var_1C], eax
    mov     edx, [ecx+8]
    mov     [esp+28h+var_18], edx
    lea     edx, [esp+28h+var_10]
    mov     eax, [ecx+0Ch]
    lea     ecx, [esp+28h+var_20]
    push    ecx
    push    edx
    push    esi
    mov     [esp+34h+var_14], eax
    call    sub_4CA5D0
    test    eax, eax
    jnz     short loc_4CA2D3
    pop     edi
    pop     esi
    add     esp, 20h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CA2D3:                             ; CODE XREF: sub_4CA250+22j
                                            ; sub_4CA250+79j
    mov     eax, [esp+28h+arg_4]
    mov     ecx, [esp+28h+arg_8]
    mov     edx, [esp+28h+arg_C]
    mov     [esi+431h], eax
    mov     eax, [esi+4C5h]
    push    1
    push    esi
    mov     dword ptr [esi+4E5h], 0
    mov     [esi+435h], ecx
    mov     [esi+439h], edx
    mov     ecx, [eax]
    push    offset sub_4CA100
    push    edi
    push    eax
    call    dword ptr [ecx+8Ch]
    xor     edx, edx
    pop     edi
    test    eax, eax
    setz    dl
    mov     eax, edx
    pop     esi
    add     esp, 20h
    retn    14h
    sub_4CA250 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA330 proc near                    ; DATA XREF: .text:004CA42Ao

    var_C8= dword ptr -0C8h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 0C8h
    push    ebx
    push    esi
    push    edi
    push    offset aHapinet_enumpr          ; "HAPINET_enumproviders\n"
    call    nullsub_17
    mov     ebx, [esp+0D8h+arg_10]
    mov     edx, [esp+0D8h+arg_0]
    add     esp, 4
    mov     eax, [ebx+4E5h]
    mov     ecx, [ebx+431h]
    shl     eax, 4
    add     ecx, eax
    mov     eax, [edx]
    mov     [ecx], eax
    mov     eax, [edx+4]
    mov     [ecx+4], eax
    mov     eax, [edx+8]
    mov     [ecx+8], eax
    mov     edx, [edx+0Ch]
    mov     eax, [esp+0D4h+arg_C]
    mov     [ecx+0Ch], edx
    mov     ecx, [esp+0D4h+arg_8]
    mov     edx, [esp+0D4h+arg_4]
    push    eax
    push    ecx
    push    edx
    lea     eax, [esp+0E0h+var_C8]
    push    offset aSD_D                    ; "%s %d.%d"
    push    eax
    call    _sprintf
    mov     ecx, [ebx+4E5h]
    mov     edx, [ebx+439h]
    add     esp, 14h
    push    ecx
    push    edx
    call    sub_4B6AF0
    mov     edx, eax
    lea     edi, [esp+0D4h+var_C8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, [ebx+4E5h]
    pop     edi
    inc     eax
    pop     esi
    mov     [ebx+4E5h], eax
    mov     eax, 1
    pop     ebx
    add     esp, 0C8h
    retn    14h
    sub_4CA330 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    offset aHapinet_getpro          ; "HAPINET_getproviders\n"
    call    nullsub_17
    mov     eax, [esp+8]
    mov     ecx, [esp+0Ch]
    mov     edx, [esp+10h]
    add     esp, 4
    mov     dword ptr [eax+4E5h], 0
    mov     [eax+431h], ecx
    push    eax
    push    offset sub_4CA330
    mov     [eax+439h], edx
    call    DirectPlayEnumerateA
    mov     eax, 1
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA450 proc near                    ; CODE XREF: sub_451640+14p

    arg_0= dword ptr  4

    push    offset aHapinet_passwo          ; "HAPINET_passwordrequired\n"
    call    nullsub_17
    mov     ecx, [esp+4+arg_0]
    add     esp, 4
    mov     eax, [ecx+4D1h]
    test    eax, eax
    jz      short loc_4CA479
    mov     eax, [eax+8]
    mov     eax, [eax+4]
    and     eax, 400h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CA479:                             ; CODE XREF: sub_4CA450+19j
    mov     eax, [ecx+461h]
    and     eax, 400h
    retn    4
    sub_4CA450 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA490 proc near                    ; CODE XREF: .text:0044223Ep
                                            ; .text:004425AEp ...

    var_34= dword ptr -34h
    var_24= dword ptr -24h
    var_14= dword ptr -14h
    arg_0= dword ptr  0Ch

    push    ebp
    push    edi
    push    offset aHapinet_initlo          ; "HAPINET_initlobbiedconnection\n"
    call    nullsub_17
    mov     ebp, [esp+4+arg_0]
    xor     eax, eax
    add     esp, 4
    mov     ecx, [ebp+4CDh]
    lea     edi, [ebp+4CDh]
    cmp     ecx, eax
    jz      short loc_4CA4BA
    pop     edi
    pop     ebp
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CA4BA:                             ; CODE XREF: sub_4CA490+23j
    push    esi
    push    ebx
    push    eax
    lea     ebx, [ebp+4C9h]
    push    eax
    push    eax
    push    ebx
    push    eax
    mov     [ebx], eax
    mov     [edi], eax
    mov     [ebp+4D1h], eax
    mov     [ebp+4D5h], eax
    call    DirectPlayLobbyCreateA
    mov     esi, eax
    test    esi, esi
    jl      loc_4CA576
    mov     ebx, [ebx]
    push    edi
    push    offset dword_4FCE18
    push    ebx
    mov     eax, [ebx]
    call    dword ptr [eax]
    mov     esi, eax
    test    esi, esi
    jl      short loc_4CA576
    mov     eax, [edi]
    lea     edx, [esp+14h]
    push    edx
    mov     dword ptr [esp+18h], 0
    mov     ecx, [eax]
    push    0
    push    0
    push    eax
    call    dword ptr [ecx+20h]
    mov     esi, eax
    cmp     esi, 8877001Eh
    jnz     short loc_4CA55F
    mov     eax, [esp+14h]
    push    eax
    push    offset aDplayLobbyConn          ; "DPLAY LOBBY CONNECTION"
    call    sub_4D83B0
    add     esp, 8
    mov     [ebp+4D1h], eax
    test    eax, eax
    jz      short loc_4CA55A
    mov     edi, [edi]
    lea     edx, [esp+14h]
    push    edx
    push    eax
    mov     ecx, [edi]
    push    0
    push    edi
    call    dword ptr [ecx+20h]
    mov     esi, eax
    test    esi, esi
    jl      short loc_4CA55F
    mov     eax, [esp+14h]
    mov     [ebp+4D5h], eax
    jmp     short loc_4CA55F
    ; ---------------------------------------------------------------------------

    loc_4CA55A:                             ; CODE XREF: sub_4CA490+A6j
    mov     esi, 8007000Eh

    loc_4CA55F:                             ; CODE XREF: sub_4CA490+8Aj
                                            ; sub_4CA490+BCj ...
    push    offset aHapinet_guaran          ; "HAPINET_guaranteepackets\n"
    call    nullsub_17
    add     esp, 4
    mov     Global_GuaranteePackets, 1

    loc_4CA576:                             ; CODE XREF: sub_4CA490+50j
                                            ; sub_4CA490+67j
    xor     eax, eax
    pop     ebx
    test    esi, esi
    pop     esi
    pop     edi
    setnl   al
    pop     ebp
    retn    4
    sub_4CA490 endp ; sp = -0Ch

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA590 proc near                    ; CODE XREF: .text:00450DBBp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    offset aHapinet_initco          ; "HAPINET_initconnection\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    mov     edx, [esp+4+arg_4]
    add     esp, 4
    mov     eax, [eax+4C5h]
    mov     edx, [edx]
    push    0
    push    edx
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+98h]
    xor     ecx, ecx
    test    eax, eax
    setnl   cl

    unknown_libname_53:
    mov     eax, ecx
    retn    8
    sub_4CA590 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA5D0 proc near                    ; CODE XREF: sub_4CA250+72p

    arg_0= dword ptr  14h
    arg_4= dword ptr  18h
    arg_8= dword ptr  1Ch

    push    ebx
    push    ebp
    push    esi
    push    edi
    push    offset aHapinet_initmu          ; "HAPINET_initmultiplay\n"
    call    nullsub_17
    xor     ebx, ebx
    add     esp, 4
    mov     Global_GuaranteePackets, ebx
    call    sub_4B6220
    mov     ecx, [eax+40h]
    mov     eax, [esp+arg_0]
    push    ebx
    mov     [eax+4ADh], ecx
    mov     ecx, [esp+4+arg_8]
    lea     edx, [eax+43Dh]
    lea     edi, [eax+4C5h]
    mov     esi, [ecx]
    mov     [edx], esi
    mov     esi, [ecx+4]
    mov     [edx+4], esi
    mov     esi, [ecx+8]
    mov     [edx+8], esi
    lea     esi, [eax+4C1h]
    mov     ecx, [ecx+0Ch]
    mov     [eax+4C9h], ebx
    mov     [edx+0Ch], ecx
    mov     edx, [esp+4+arg_4]
    mov     [eax+4CDh], ebx
    mov     [eax+4D1h], ebx
    mov     [eax+4D5h], ebx
    add     eax, 44Dh
    mov     [esi], ebx
    mov     [edi], ebx
    mov     ebp, [edx]
    mov     ecx, eax
    push    esi
    push    eax
    mov     [ecx], ebp
    mov     ebp, [edx+4]
    mov     [ecx+4], ebp
    mov     ebp, [edx+8]
    mov     [ecx+8], ebp
    mov     edx, [edx+0Ch]
    mov     [ecx+0Ch], edx
    call    DirectPlayCreate
    cmp     eax, ebx
    jz      short loc_4CA679
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CA679:                             ; CODE XREF: sub_4CA5D0+9Ej
    mov     esi, [esi]
    push    edi
    push    offset dword_4FCD78
    push    esi
    mov     eax, [esi]
    call    dword ptr [eax]
    xor     ecx, ecx
    cmp     eax, ebx
    pop     edi
    pop     esi
    setz    cl
    pop     ebp
    mov     eax, ecx
    pop     ebx
    retn    0Ch
    sub_4CA5D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA6A0 proc near                    ; CODE XREF: sub_451220+201p

    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= byte ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= byte ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= word ptr  18h
    arg_18= word ptr  1Ch

    sub     esp, 28h
    push    esi
    push    offset aHapinet_addpla          ; "HAPINET_addplayer\n"
    call    nullsub_17
    mov     esi, [esp+30h+arg_0]
    add     esp, 4
    mov     eax, [esi+4C5h]
    test    eax, eax
    jz      loc_4CA776
    mov     eax, [esp+2Ch+arg_C]
    push    edi
    mov     edi, [esp+30h+arg_8]
    push    10h                             ; size_t
    mov     [esp+34h+var_1C], eax
    push    eax                             ; char *
    lea     eax, [esi+11h]
    mov     [esp+38h+var_28], 10h
    push    eax                             ; char *
    mov     [esp+3Ch+var_24], 0
    mov     [esp+3Ch+var_20], edi
    call    _strncpy
    add     esp, 0Ch
    lea     ecx, [esi+21h]
    push    10h                             ; size_t
    push    edi                             ; char *
    push    ecx                             ; char *
    call    _strncpy
    xor     edx, edx
    mov     eax, [esp+3Ch+arg_10]
    mov     dword ptr [esp+3Ch+var_18], edx
    add     esp, 0Ch
    mov     [esp+30h+var_14], edx
    lea     ecx, [esp+30h+var_18]
    mov     [esp+30h+var_10], edx
    push    10h                             ; size_t
    mov     [esp+34h+var_C], edx
    push    eax                             ; char *
    mov     [esp+38h+var_8], edx
    push    ecx                             ; char *
    mov     [esp+3Ch+var_4], dl
    call    _strncpy
    mov     dx, [esp+3Ch+arg_14]
    mov     ax, [esp+3Ch+arg_18]
    mov     esi, [esi+4C5h]
    add     esp, 0Ch
    mov     word ptr [esp+30h+var_8+1], dx
    lea     edx, [esp+30h+var_18]
    push    0
    mov     word ptr [esp+34h+var_8+3], ax
    mov     ecx, [esi]
    push    15h
    push    edx
    mov     edx, [esp+3Ch+arg_4]
    lea     eax, [esp+3Ch+var_28]
    push    0
    push    eax
    push    edx
    push    esi
    call    dword ptr [ecx+18h]
    xor     ecx, ecx
    pop     edi
    test    eax, eax
    setz    cl
    mov     eax, ecx
    pop     esi
    add     esp, 28h
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CA776:                             ; CODE XREF: sub_4CA6A0+1Dj
    xor     eax, eax
    pop     esi
    add     esp, 28h
    retn    1Ch
    sub_4CA6A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA780 proc near                    ; CODE XREF: sub_452CC0+199p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    offset aHapinet_remove          ; "HAPINET_removeplayer\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    mov     eax, [eax+4C5h]
    test    eax, eax
    jz      short loc_4CA7B2
    mov     edx, [esp+arg_4]
    mov     ecx, [eax]
    push    edx
    push    eax
    call    dword ptr [ecx+24h]
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CA7B2:                             ; CODE XREF: sub_4CA780+19j
    xor     eax, eax
    retn    8
    sub_4CA780 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA7C0 proc near                    ; CODE XREF: .text:00450171p
                                            ; sub_450A10+15Fp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    push    offset aHapinet_getpla          ; "HAPINET_getplayername\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    mov     eax, [eax+4C5h]
    test    eax, eax
    jz      short loc_4CA7F3
    mov     edx, [esp+arg_C]
    mov     ecx, [eax]
    push    edx
    mov     edx, [esp+4+arg_8]
    push    edx
    mov     edx, [esp+8+arg_4]
    push    edx
    push    eax
    call    dword ptr [ecx+54h]
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4CA7F3:                             ; CODE XREF: sub_4CA7C0+19j
    mov     eax, 88770140h
    retn    10h
    sub_4CA7C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA800 proc near                    ; CODE XREF: .text:0045011Ap

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    push    offset aHapinet_setpla          ; "HAPINET_setplayername\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    mov     eax, [eax+4C5h]
    test    eax, eax
    jz      short loc_4CA833
    mov     edx, [esp+arg_C]
    mov     ecx, [eax]
    push    edx
    mov     edx, [esp+4+arg_8]
    push    edx
    mov     edx, [esp+8+arg_4]
    push    edx
    push    eax
    call    dword ptr [ecx+78h]
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4CA833:                             ; CODE XREF: sub_4CA800+19j
    mov     eax, 88770140h
    retn    10h
    sub_4CA800 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA840 proc near                    ; CODE XREF: sub_4517B0+299p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    push    offset aHapinet_enumpl          ; "HAPINET_enumplayers\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    mov     eax, [eax+4C5h]
    test    eax, eax
    jz      short loc_4CA878
    mov     edx, [esp+arg_10]
    mov     ecx, [eax]
    push    edx
    mov     edx, [esp+4+arg_C]
    push    edx
    mov     edx, [esp+8+arg_8]
    push    edx
    mov     edx, [esp+0Ch+arg_4]
    push    edx
    push    eax
    call    dword ptr [ecx+30h]
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CA878:                             ; CODE XREF: sub_4CA840+19j
    mov     eax, 88770140h
    retn    14h
    sub_4CA840 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA880 proc near                    ; CODE XREF: sub_441C30+32Ep
                                            ; sub_441C30+372p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    push    offset aHapinet_create          ; "HAPINET_createcompoundaddress\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    mov     eax, [eax+4CDh]
    test    eax, eax
    jz      short loc_4CA8B8
    mov     edx, [esp+arg_10]
    mov     ecx, [eax]
    push    edx
    mov     edx, [esp+4+arg_C]
    push    edx
    mov     edx, [esp+8+arg_8]
    push    edx
    mov     edx, [esp+0Ch+arg_4]
    push    edx
    push    eax
    call    dword ptr [ecx+38h]
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CA8B8:                             ; CODE XREF: sub_4CA880+19j
    mov     eax, 88770140h
    retn    14h
    sub_4CA880 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA8C0 proc near                    ; CODE XREF: .text:0044322Fp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    push    offset aHapinet_enumad          ; "HAPINET_enumaddress\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    mov     eax, [eax+4CDh]
    test    eax, eax
    jz      short loc_4CA8F8
    mov     edx, [esp+arg_10]
    mov     ecx, [eax]
    push    edx
    mov     edx, [esp+4+arg_C]
    push    edx
    mov     edx, [esp+8+arg_8]
    push    edx
    mov     edx, [esp+0Ch+arg_4]
    push    edx
    push    eax
    call    dword ptr [ecx+14h]
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CA8F8:                             ; CODE XREF: sub_4CA8C0+19j
    mov     eax, 88770140h
    retn    14h
    sub_4CA8C0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA900 proc near                    ; CODE XREF: .text:00443188p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    push    offset aHapinet_crea_0          ; "HAPINET_createdplayinterface\n"
    call    nullsub_17
    mov     esi, [esp+4+arg_4]
    mov     edx, [esp+4+arg_0]
    mov     ecx, esi
    xor     eax, eax
    add     esp, 4
    mov     [ecx], eax
    push    eax
    push    esi
    push    edx
    mov     [ecx+4], eax
    call    DirectPlayCreate
    test    eax, eax
    jl      short loc_4CA93B
    mov     eax, [esi]
    add     esi, 4
    push    esi
    push    offset dword_4FCD78
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx]

    loc_4CA93B:                             ; CODE XREF: sub_4CA900+29j
    pop     esi
    retn    8
    sub_4CA900 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA940 proc near                    ; CODE XREF: .text:00443297p
                                            ; .text:0044345Ep

    arg_0= dword ptr  0Ch

    push    esi
    push    edi
    push    offset aHapinet_releas          ; "HAPINET_releasedplayinterface\n"
    call    nullsub_17
    mov     esi, [esp+4+arg_0]
    add     esp, 4
    xor     edi, edi
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4CA96B
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+8]
    mov     edi, eax
    mov     dword ptr [esi+4], 0

    loc_4CA96B:                             ; CODE XREF: sub_4CA940+1Aj
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4CA97D
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+8]
    mov     dword ptr [esi], 0

    loc_4CA97D:                             ; CODE XREF: sub_4CA940+2Fj
    mov     eax, edi
    pop     edi
    pop     esi
    retn    4
    sub_4CA940 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA990 proc near                    ; CODE XREF: .text:004431A1p
                                            ; .text:004431DFp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    push    offset aHapinet_getp_0          ; "HAPINET_getplayeraddress\n"
    call    nullsub_17
    mov     eax, [esp+4+arg_0]
    add     esp, 4
    mov     eax, [eax+4]
    test    eax, eax
    jz      short loc_4CA9C0
    mov     edx, [esp+arg_C]
    mov     ecx, [eax]
    push    edx
    mov     edx, [esp+4+arg_8]
    push    edx
    mov     edx, [esp+8+arg_4]
    push    edx
    push    eax
    call    dword ptr [ecx+48h]
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4CA9C0:                             ; CODE XREF: sub_4CA990+16j
    mov     eax, 88770140h
    retn    10h
    sub_4CA990 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA9D0 proc near                    ; CODE XREF: RIWrapper_Report+7Fp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     eax, [eax+4C9h]
    retn    4
    sub_4CA9D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA9E0 proc near                    ; CODE XREF: RIWrapper_Report+56p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    add     eax, 465h
    retn    4
    sub_4CA9E0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CA9F0 proc near                    ; CODE XREF: RIWrapper_Report+112p
    xor     eax, eax
    retn    4
    sub_4CA9F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CAA00 proc near                    ; CODE XREF: RIWrapper_ReportGameChat+50p
    mov     eax, 1
    retn    8
    sub_4CAA00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CAA10 proc near                    ; CODE XREF: RIWrapper_Report+168p
    mov     eax, 1
    retn    28h
    sub_4CAA10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CAA20 proc near                    ; CODE XREF: LoadReporter+C0p
                                            ; UnloadReporter+Cp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    mov     dword_51FF08, eax
    mov     dword_51FF04, ecx
    retn    8
    sub_4CAA20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CAA40 proc near                    ; CODE XREF: sub_4CAF30+A0p
                                            ; sub_4CB080+5Ep

    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 98h
    xor     eax, eax
    lea     edx, [esp+98h+var_80]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+0A4h+arg_4]
    mov     ecx, esi
    push    edi
    mov     edi, [esp+0A8h+arg_0]
    push    80h
    mov     [ecx], eax
    push    edx
    push    edi
    mov     [ecx+4], eax
    mov     [ecx+8], eax
    mov     [ecx+0Ch], eax
    call    sub_4BB7C0
    cmp     eax, 80h
    jnz     loc_4CAC2B
    cmp     byte ptr [esp+0A8h+var_80], 0Ah
    jnz     loc_4CAC2B
    cmp     byte ptr [esp+0A8h+var_80+1], 5
    jnz     loc_4CAC2B
    mov     eax, [esp+0A8h+var_78]
    mov     ecx, [esp+0A8h+var_7C]
    mov     edx, [esp+0A8h+var_78+2]
    and     eax, 0FFFFh
    and     ecx, 0FFFFh
    and     edx, 0FFFFh
    sub     eax, ecx
    lea     ecx, [eax+1]
    mov     eax, [esp+0A8h+var_7C+2]
    and     eax, 0FFFFh
    mov     [esi+8], ecx
    sub     edx, eax
    lea     eax, [edx+1]
    mov     [esi+0Ch], eax
    imul    eax, ecx
    push    eax
    push    offset aPcxBody                 ; "PCX BODY"
    call    sub_4D83B0
    add     esp, 8
    mov     [esi], eax
    push    300h
    push    offset aColorMap                ; "COLOR MAP"
    call    sub_4D83B0
    add     esp, 8
    mov     [esi+4], eax
    push    edi
    call    sub_4BBD00
    sub     eax, 300h
    push    eax
    push    edi
    call    sub_4BB710
    mov     ecx, [esi+4]
    push    300h
    push    ecx
    push    edi
    call    sub_4BB7C0
    push    80h
    push    edi
    call    sub_4BB710
    mov     ebp, [esi]
    mov     eax, [esi+8]
    mov     esi, [esi+0Ch]
    mov     [esp+0A8h+var_8C], ebp
    dec     esi
    mov     [esp+0A8h+var_84], eax
    js      loc_4CAC19
    inc     esi
    mov     [esp+0A8h+var_88], esi

    loc_4CAB3E:                             ; CODE XREF: sub_4CAA40+1D3j
    test    eax, eax
    mov     [esp+0A8h+var_98], eax
    jle     loc_4CAC00

    loc_4CAB4A:                             ; CODE XREF: sub_4CAA40+1B6j
    lea     edx, [esp+0A8h+var_94]
    push    1
    push    edx
    push    edi
    call    sub_4BB7C0
    mov     al, byte ptr [esp+0A8h+var_94]
    mov     cl, al
    and     cl, 0C0h
    cmp     cl, 0C0h
    jnz     short loc_4CABE3
    and     al, 3Fh
    mov     bl, al
    mov     eax, [esp+0A8h+var_98]
    mov     byte ptr [esp+0A8h+var_90], bl
    mov     edx, [esp+0A8h+var_90]
    and     edx, 0FFh
    sub     eax, edx
    mov     [esp+0A8h+var_98], eax
    jns     short loc_4CAB8B
    add     bl, byte ptr [esp+0A8h+var_98]
    mov     byte ptr [esp+0A8h+var_90], bl

    loc_4CAB8B:                             ; CODE XREF: sub_4CAA40+141j
    lea     eax, [esp+0A8h+var_94]
    push    1
    push    eax
    push    edi
    call    sub_4BB7C0
    cmp     bl, 1
    jnz     short loc_4CABA7
    mov     cl, byte ptr [esp+0A8h+var_94]
    mov     [ebp+0], cl
    inc     ebp
    jmp     short loc_4CABF0
    ; ---------------------------------------------------------------------------

    loc_4CABA7:                             ; CODE XREF: sub_4CAA40+15Bj
    mov     eax, [esp+0A8h+var_94]
    mov     esi, [esp+0A8h+var_90]
    and     eax, 0FFh
    and     esi, 0FFh
    mov     bl, al
    mov     ecx, esi
    mov     bh, bl
    mov     edx, ecx
    mov     eax, ebx
    mov     edi, ebp
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    add     ebp, esi
    rep stosb
    mov     edi, [esp+0A8h+arg_0]
    jmp     short loc_4CABF0
    ; ---------------------------------------------------------------------------

    loc_4CABE3:                             ; CODE XREF: sub_4CAA40+123j
    mov     [ebp+0], al
    mov     eax, [esp+0A8h+var_98]
    inc     ebp
    dec     eax
    mov     [esp+0A8h+var_98], eax

    loc_4CABF0:                             ; CODE XREF: sub_4CAA40+165j
                                            ; sub_4CAA40+1A1j
    mov     eax, [esp+0A8h+var_98]
    test    eax, eax
    jg      loc_4CAB4A
    mov     eax, [esp+0A8h+var_84]

    loc_4CAC00:                             ; CODE XREF: sub_4CAA40+104j
    mov     ebp, [esp+0A8h+var_8C]
    mov     ecx, [esp+0A8h+var_88]
    add     ebp, eax
    dec     ecx
    mov     [esp+0A8h+var_8C], ebp
    mov     [esp+0A8h+var_88], ecx
    jnz     loc_4CAB3E

    loc_4CAC19:                             ; CODE XREF: sub_4CAA40+F3j
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 98h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CAC2B:                             ; CODE XREF: sub_4CAA40+3Cj
                                            ; sub_4CAA40+47j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 98h
    retn    8
    sub_4CAA40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CAC40 proc near                    ; CODE XREF: .text:004CAF13p
                                            ; sub_4CB170+160p

    var_9A= byte ptr -9Ah
    var_99= dword ptr -99h
    var_95= dword ptr -95h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= word ptr -7Ch
    var_7A= word ptr -7Ah
    var_78= word ptr -78h
    var_76= word ptr -76h
    var_74= word ptr -74h
    var_72= word ptr -72h
    var_70= dword ptr -70h
    var_3F= byte ptr -3Fh
    var_3E= word ptr -3Eh
    var_3C= word ptr -3Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     eax, [esp+arg_0]
    sub     esp, 9Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    eax
    call    sub_4BB2C0
    mov     ebp, eax
    xor     edx, edx
    cmp     ebp, edx
    jz      loc_4CAE99
    mov     ebx, [esp+0ACh+arg_8]
    mov     ecx, 20h
    xor     eax, eax
    lea     edi, [esp+0ACh+var_80]
    rep stosd
    mov     eax, [esp+0ACh+arg_C]
    mov     esi, [esp+0ACh+arg_10]
    lea     ecx, [ebx-1]
    lea     edi, [esp+0ACh+var_70]
    mov     [esp+0ACh+var_78], cx
    lea     ecx, [eax-1]
    mov     [esp+0ACh+var_76], cx
    mov     ecx, 0Ch
    mov     byte ptr [esp+0ACh+var_80], 0Ah
    mov     byte ptr [esp+0ACh+var_80+1], 5
    mov     byte ptr [esp+0ACh+var_80+2], 1
    mov     byte ptr [esp+0ACh+var_80+3], 8
    mov     [esp+0ACh+var_7C], dx
    mov     [esp+0ACh+var_7A], dx
    mov     [esp+0ACh+var_74], bx
    mov     [esp+0ACh+var_72], ax
    rep movsd
    mov     [esp+0ACh+var_3C], dx
    lea     edx, [esp+0ACh+var_80]
    push    80h
    push    edx
    push    ebp
    mov     [esp+0B8h+var_3F], 1
    mov     [esp+0B8h+var_3E], bx
    call    sub_4BBBE0
    cmp     eax, 80h
    jnz     loc_4CAE8D
    mov     eax, [esp+0ACh+arg_C]
    mov     ecx, [esp+0ACh+arg_4]
    dec     eax
    mov     [esp+0ACh+var_88], ecx
    test    eax, eax
    jl      loc_4CAE61
    inc     eax
    mov     [esp+0ACh+var_90], eax

    loc_4CAD0F:                             ; CODE XREF: sub_4CAC40+21Bj
    mov     al, [ecx]
    mov     esi, 1
    inc     ecx
    cmp     ebx, esi
    mov     [esp+0ACh+var_95+1], 0
    mov     [esp+0ACh+var_9A], al
    jle     loc_4CADE0
    dec     ebx
    mov     [esp+0ACh+var_8C], ebx

    loc_4CAD30:                             ; CODE XREF: sub_4CAC40+193j
    mov     bl, [ecx]
    inc     ecx
    cmp     al, bl
    mov     byte ptr [esp+0ACh+var_99+2], bl
    mov     [esp+0ACh+var_84], ecx
    jnz     short loc_4CAD45
    inc     esi
    jmp     loc_4CADCA
    ; ---------------------------------------------------------------------------

    loc_4CAD45:                             ; CODE XREF: sub_4CAC40+FDj
    xor     edi, edi
    cmp     esi, 1
    jnz     short loc_4CAD6A
    mov     cl, al
    and     cl, 0C0h
    cmp     cl, 0C0h
    jz      short loc_4CAD6A
    lea     edx, [esp+0ACh+var_95]
    push    esi
    push    edx
    push    ebp
    mov     byte ptr [esp+0B8h+var_95], al
    call    sub_4BBBE0
    mov     edi, esi
    jmp     short loc_4CADB1
    ; ---------------------------------------------------------------------------

    loc_4CAD6A:                             ; CODE XREF: sub_4CAC40+10Aj
                                            ; sub_4CAC40+114j
    test    esi, esi
    jle     short loc_4CADB1

    loc_4CAD6E:                             ; CODE XREF: sub_4CAC40+16Bj
    cmp     esi, 3Fh
    mov     ebx, 3Fh
    jg      short loc_4CAD7A
    mov     ebx, esi

    loc_4CAD7A:                             ; CODE XREF: sub_4CAC40+136j
    mov     al, bl
    lea     ecx, [esp+0ACh+var_99+3]
    push    1
    or      al, 0C0h
    push    ecx
    push    ebp
    mov     byte ptr [esp+0B8h+var_99+3], al
    call    sub_4BBBE0
    lea     eax, [esp+0ACh+var_99+1]
    push    1
    mov     dl, [esp+0B0h+var_9A]
    push    eax
    push    ebp
    mov     byte ptr [esp+0B8h+var_99+1], dl
    call    sub_4BBBE0
    sub     esi, ebx
    add     edi, 2
    test    esi, esi
    jg      short loc_4CAD6E
    mov     bl, byte ptr [esp+0ACh+var_99+2]

    loc_4CADB1:                             ; CODE XREF: sub_4CAC40+128j
                                            ; sub_4CAC40+12Cj
    mov     eax, [esp+0ACh+var_95+1]
    mov     ecx, [esp+0ACh+var_84]
    add     eax, edi
    mov     [esp+0ACh+var_9A], bl
    mov     [esp+0ACh+var_95+1], eax
    mov     esi, 1
    mov     al, bl

    loc_4CADCA:                             ; CODE XREF: sub_4CAC40+100j
    mov     edx, [esp+0ACh+var_8C]
    dec     edx
    mov     [esp+0ACh+var_8C], edx
    jnz     loc_4CAD30
    mov     ebx, [esp+0ACh+arg_8]

    loc_4CADE0:                             ; CODE XREF: sub_4CAC40+E5j
    cmp     esi, 1
    jnz     short loc_4CAE01
    mov     cl, al
    and     cl, 0C0h
    cmp     cl, 0C0h
    jz      short loc_4CAE01
    lea     edx, [esp+0ACh+var_99]
    push    esi
    push    edx
    push    ebp
    mov     byte ptr [esp+0B8h+var_99], al
    call    sub_4BBBE0
    jmp     short loc_4CAE48
    ; ---------------------------------------------------------------------------

    loc_4CAE01:                             ; CODE XREF: sub_4CAC40+1A3j
                                            ; sub_4CAC40+1ADj
    test    esi, esi
    jle     short loc_4CAE48

    loc_4CAE05:                             ; CODE XREF: sub_4CAC40+1FFj
    cmp     esi, 3Fh
    mov     ebx, 3Fh
    jg      short loc_4CAE11
    mov     ebx, esi

    loc_4CAE11:                             ; CODE XREF: sub_4CAC40+1CDj
    mov     al, bl
    lea     ecx, [esp+0ACh+var_99+2]
    push    1
    or      al, 0C0h
    push    ecx
    push    ebp
    mov     byte ptr [esp+0B8h+var_99+2], al
    call    sub_4BBBE0
    lea     eax, [esp+0ACh+var_99+1]
    push    1
    mov     dl, [esp+0B0h+var_9A]
    push    eax
    push    ebp
    mov     byte ptr [esp+0B8h+var_99+1], dl
    call    sub_4BBBE0
    sub     esi, ebx
    test    esi, esi
    jg      short loc_4CAE05
    mov     ebx, [esp+0ACh+arg_8]

    loc_4CAE48:                             ; CODE XREF: sub_4CAC40+1BFj
                                            ; sub_4CAC40+1C3j
    mov     ecx, [esp+0ACh+var_88]
    mov     eax, [esp+0ACh+var_90]
    add     ecx, ebx
    dec     eax
    mov     [esp+0ACh+var_88], ecx
    mov     [esp+0ACh+var_90], eax
    jnz     loc_4CAD0F

    loc_4CAE61:                             ; CODE XREF: sub_4CAC40+C4j
    lea     ecx, [esp+0ACh+var_99]
    push    1
    push    ecx
    push    ebp
    mov     byte ptr [esp+0B8h+var_99], 0Ch
    call    sub_4BBBE0
    push    300h
    mov     edx, [esp+0B0h+arg_10]
    push    edx
    push    ebp
    call    sub_4BBBE0
    cmp     eax, 300h
    jz      short loc_4CAEA8

    loc_4CAE8D:                             ; CODE XREF: sub_4CAC40+A9j
    xor     edx, edx
    cmp     ebp, edx
    jz      short loc_4CAE99
    push    ebp
    call    sub_4BB5D0

    loc_4CAE99:                             ; CODE XREF: sub_4CAC40+1Aj
                                            ; sub_4CAC40+251j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 9Ch
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CAEA8:                             ; CODE XREF: sub_4CAC40+24Bj
    push    ebp
    call    sub_4BB5D0
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 9Ch
    retn    14h
    sub_4CAC40 endp

    ; ---------------------------------------------------------------------------
    sub     esp, 300h
    push    esi
    call    sub_4B6220
    lea     ecx, [esp+5]
    add     eax, 215h
    mov     esi, 100h

    loc_4CAEDA:                             ; CODE XREF: .text:004CAEF2j
    mov     dl, [eax-1]
    add     eax, 4
    mov     [ecx-1], dl
    mov     dl, [eax-4]
    mov     [ecx], dl
    mov     dl, [eax-3]
    mov     [ecx+1], dl
    add     ecx, 3
    dec     esi
    jnz     short loc_4CAEDA
    lea     eax, [esp+4]
    push    eax
    mov     eax, [esp+310h]
    mov     ecx, [eax+4]
    mov     edx, [eax]
    mov     eax, [eax+0Ch]
    push    ecx
    mov     ecx, [esp+310h]
    push    edx
    push    eax
    push    ecx
    call    sub_4CAC40
    pop     esi
    add     esp, 300h
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CAF30 proc near                    ; CODE XREF: sub_429290+2Dp
                                            ; sub_44C0D0+CAp ...

    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 94h
    push    ebx
    mov     ebx, [esp+98h+arg_0]
    push    ebp
    push    esi
    push    edi
    push    ebx
    call    sub_4BB5B0
    mov     ebp, eax
    test    ebp, ebp
    jz      loc_4CB06F
    lea     eax, [esp+0A4h+var_80]
    push    80h
    push    eax
    push    ebp
    call    sub_4BB7C0
    cmp     eax, 80h
    jnz     loc_4CB069
    cmp     byte ptr [esp+0A4h+var_80], 0Ah
    jnz     loc_4CB069
    cmp     byte ptr [esp+0A4h+var_80+1], 5
    jnz     loc_4CB069
    mov     esi, [esp+0A4h+var_78]
    mov     ecx, [esp+0A4h+var_7C]
    mov     edi, [esp+0A4h+var_78+2]
    mov     edx, [esp+0A4h+var_7C+2]
    and     esi, 0FFFFh
    and     ecx, 0FFFFh
    and     edi, 0FFFFh
    and     edx, 0FFFFh
    sub     esi, ecx
    sub     edi, edx
    inc     esi
    inc     edi
    push    edi                             ; int
    push    esi                             ; int
    push    ebx                             ; int
    call    sub_4C69F0
    mov     ebx, eax
    test    ebx, ebx
    jz      loc_4CB069
    push    0
    push    ebp
    call    sub_4BB710
    lea     eax, [esp+0A4h+var_90]
    push    eax
    push    ebp
    call    sub_4CAA40
    push    ebp
    mov     [esp+0A8h+var_94], eax
    call    sub_4BB5D0
    mov     eax, [esp+0A4h+var_94]
    test    eax, eax
    jz      short loc_4CB001
    mov     ecx, edi
    mov     edi, [ebx+0Ch]
    imul    ecx, esi
    mov     esi, [esp+0A4h+var_90]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4CB001:                             ; CODE XREF: sub_4CAF30+B5j
    mov     eax, [esp+0A4h+arg_4]
    mov     edi, [esp+0A4h+var_8C]
    test    eax, eax
    jz      short loc_4CB036
    lea     ecx, [edi+2]
    mov     esi, 100h

    loc_4CB018:                             ; CODE XREF: sub_4CAF30+104j
    mov     dl, [ecx-2]
    add     ecx, 3
    mov     [eax], dl
    mov     dl, [ecx-4]
    mov     [eax+1], dl
    mov     dl, [ecx-3]
    mov     [eax+2], dl
    mov     byte ptr [eax+3], 0
    add     eax, 4
    dec     esi
    jnz     short loc_4CB018

    loc_4CB036:                             ; CODE XREF: sub_4CAF30+DEj
    push    edi                             ; int
    call    sub_4D85A0
    mov     eax, [esp+0A8h+var_90]
    add     esp, 4
    push    eax                             ; int
    call    sub_4D85A0
    mov     eax, [esp+0A8h+var_94]
    add     esp, 4
    test    eax, eax
    jnz     short loc_4CB05A
    push    ebx
    call    sub_4C6AC0

    loc_4CB05A:                             ; CODE XREF: sub_4CAF30+122j
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 94h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CB069:                             ; CODE XREF: sub_4CAF30+36j
                                            ; sub_4CAF30+41j ...
    push    ebp
    call    sub_4BB5D0

    loc_4CB06F:                             ; CODE XREF: sub_4CAF30+1Bj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 94h
    retn    8
    sub_4CAF30 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB080 proc near                    ; CODE XREF: sub_429330+9Ap

    var_490= dword ptr -490h
    var_48C= dword ptr -48Ch
    var_480= dword ptr -480h
    var_3FF= dword ptr -3FFh
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    sub     esp, 490h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    eax
    call    sub_4BB5B0
    mov     esi, eax
    xor     ebx, ebx
    cmp     esi, ebx
    jz      loc_4CB15C
    lea     ecx, [esp+4A0h+var_480]
    push    80h
    push    ecx
    push    esi
    call    sub_4BB7C0
    cmp     eax, 80h
    jnz     loc_4CB156
    cmp     byte ptr [esp+4A0h+var_480], 0Ah
    jnz     loc_4CB156
    cmp     byte ptr [esp+4A0h+var_480+1], 5
    jnz     loc_4CB156
    push    ebx
    push    esi
    call    sub_4BB710
    lea     edx, [esp+4A0h+var_490]
    push    edx
    push    esi
    call    sub_4CAA40
    push    esi
    call    sub_4BB5D0
    mov     ebp, [esp+4A0h+var_48C]
    lea     eax, [esp+4A0h+var_3FF]
    mov     esi, 100h
    lea     ecx, [ebp+2]

    loc_4CB0FC:                             ; CODE XREF: sub_4CB080+97j
    mov     dl, [ecx-2]
    add     ecx, 3
    mov     [eax-1], dl
    mov     dl, [ecx-4]
    mov     [eax], dl
    mov     dl, [ecx-3]
    mov     [eax+1], dl
    mov     [eax+2], bl
    add     eax, 4
    dec     esi
    jnz     short loc_4CB0FC
    mov     edi, [esp+4A0h+arg_4]
    mov     ecx, 100h
    lea     esi, [esp+0A0h]
    push    ebp                             ; int
    rep movsd
    call    sub_4D85A0
    mov     eax, [esp+4A4h+var_490]
    add     esp, 4
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 490h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CB156:                             ; CODE XREF: sub_4CB080+35j
                                            ; sub_4CB080+40j ...
    push    esi
    call    sub_4BB5D0

    loc_4CB15C:                             ; CODE XREF: sub_4CB080+1Aj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 490h
    retn    8
    sub_4CB080 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB170 proc near                    ; CODE XREF: .text:004962D7p
                                            ; sub_496790+291p ...

    var_524= dword ptr -524h
    var_520= dword ptr -520h
    var_51C= dword ptr -51Ch
    var_418= dword ptr -418h
    var_404= byte ptr -404h
    var_2FF= dword ptr -2FFh
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 524h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4B6220
    mov     edx, [esp+534h+arg_0]
    mov     ebx, eax
    xor     esi, esi
    mov     [esp+534h+var_520], ebx
    mov     al, [edx]
    mov     [esp+534h+var_524], esi
    test    al, al
    jz      short loc_4CB1B3
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     byte ptr [ecx+edx-1], 5Ch
    jz      short loc_4CB1B3
    mov     [esp+534h+var_524], 1

    loc_4CB1B3:                             ; CODE XREF: sub_4CB170+26j
                                            ; sub_4CB170+39j
    cmp     [ebx+0DCh], esi
    jnz     short loc_4CB1CA
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 524h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CB1CA:                             ; CODE XREF: sub_4CB170+49j
    mov     eax, [esp+534h+var_524]
    cmp     eax, esi
    mov     eax, offset byte_503374
    jnz     short loc_4CB1DC
    mov     eax, offset Data

    loc_4CB1DC:                             ; CODE XREF: sub_4CB170+65j
    mov     ebx, [esp+534h+arg_4]
    push    ebx
    push    eax
    push    edx
    lea     eax, [esp+540h+var_51C]
    push    offset aSSS_pcx                 ; "%s%s%s*.pcx"
    push    eax
    call    _sprintf
    add     esp, 14h
    lea     ecx, [esp+534h+var_418]
    lea     edx, [esp+534h+var_51C]
    push    1
    push    0FFFFFFFFh
    push    ecx
    push    edx
    call    sub_4BC4B0
    mov     ebp, eax
    test    ebp, ebp
    jl      short loc_4CB24E

    loc_4CB214:                             ; CODE XREF: sub_4CB170+D6j
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+534h+var_404]
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    cmp     eax, esi
    jle     short loc_4CB236
    mov     esi, eax

    loc_4CB236:                             ; CODE XREF: sub_4CB170+C2j
    lea     ecx, [esp+534h+var_418]
    push    ecx
    push    ebp
    call    sub_4BC640
    test    eax, eax
    jz      short loc_4CB214
    push    ebp
    call    sub_4BC8D0

    loc_4CB24E:                             ; CODE XREF: sub_4CB170+A2j
    mov     eax, [esp+534h+var_524]
    test    eax, eax
    mov     eax, offset byte_503374
    jnz     short loc_4CB260
    mov     eax, offset Data

    loc_4CB260:                             ; CODE XREF: sub_4CB170+E9j
    mov     edx, [esp+534h+arg_0]
    inc     esi
    push    esi
    push    ebx
    push    eax
    push    edx
    lea     eax, [esp+544h+var_51C]
    push    offset aSSS04i_pcx              ; "%s%s%s%04i.pcx"
    push    eax
    call    _sprintf
    mov     ecx, [esp+54Ch+var_520]
    add     esp, 18h
    mov     edi, [ecx+0BCh]
    call    sub_4B6220
    lea     ecx, [esp+534h+var_2FF]
    add     eax, 215h
    mov     esi, 100h

    loc_4CB29E:                             ; CODE XREF: sub_4CB170+146j
    mov     dl, [eax-1]
    add     eax, 4
    mov     [ecx-1], dl
    mov     dl, [eax-4]
    mov     [ecx], dl
    mov     dl, [eax-3]
    mov     [ecx+1], dl
    add     ecx, 3
    dec     esi
    jnz     short loc_4CB29E
    mov     ecx, [edi+4]
    mov     edx, [edi]
    lea     eax, [esp+234h]
    push    eax
    mov     eax, [edi+0Ch]
    push    ecx
    push    edx
    lea     ecx, [esp+540h+var_51C]
    push    eax
    push    ecx
    call    sub_4CAC40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 524h
    retn    8
    sub_4CB170 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+8]
    push    ebx
    xor     eax, eax
    mov     ebx, [ecx+4]
    mov     edx, [ecx+0Ch]
    test    ebx, ebx
    jle     short loc_4CB324
    mov     ecx, [esp+8]
    push    edi
    push    esi
    push    ebp
    mov     edi, [ecx+24h]
    mov     esi, ebx

    loc_4CB30D:                             ; CODE XREF: .text:004CB31Fj
    xor     ecx, ecx
    mov     cx, [edx]
    add     edx, 2
    lea     ecx, [ecx+ecx*2]
    mov     ebp, [edi+ecx*4+4]
    add     eax, ebp
    dec     esi
    jnz     short loc_4CB30D
    pop     ebp
    pop     esi
    pop     edi

    loc_4CB324:                             ; CODE XREF: .text:004CB2FFj
    cdq
    idiv    ebx
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    mov     edx, [esp+8]
    sub     esp, 20h
    mov     ecx, 8
    push    esi
    push    edi
    mov     esi, eax
    lea     edi, [esp+8]
    rep movsd
    mov     ecx, 8
    mov     esi, edx
    mov     edi, eax
    rep movsd
    mov     ecx, 8
    lea     esi, [esp+8]
    mov     edi, edx
    rep movsd
    pop     edi
    pop     esi
    add     esp, 20h
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB370 proc near                    ; CODE XREF: sub_4CB4C0+92p

    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    arg_0= dword ptr  4

    sub     esp, 30h
    push    ebx
    push    ebp
    mov     ebp, [esp+38h+arg_0]
    push    esi
    push    edi
    mov     eax, [ebp+0Ch]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4CB3BE
    mov     ecx, [ebp+8]
    test    ecx, ecx
    jle     short loc_4CB3BE
    mov     edx, [ebp+28h]
    mov     ecx, 8
    shl     eax, 5
    add     eax, edx
    lea     edi, [esp+40h+var_20]
    mov     esi, eax
    rep movsd
    mov     ecx, 8
    mov     esi, edx
    mov     edi, eax
    rep movsd
    mov     ecx, 8
    lea     esi, [esp+40h+var_20]
    mov     edi, edx
    rep movsd
    mov     dword ptr [ebp+0Ch], 0

    loc_4CB3BE:                             ; CODE XREF: sub_4CB370+11j
                                            ; sub_4CB370+18j ...
    mov     ebx, [ebp+28h]
    mov     eax, [ebp+8]
    add     ebx, 20h
    dec     eax
    cmp     eax, 1
    mov     [esp+40h+var_28], 0
    mov     [esp+40h+var_30], ebx
    mov     [esp+40h+var_2C], 1
    jle     loc_4CB49F
    add     ebx, 24h

    loc_4CB3E8:                             ; CODE XREF: sub_4CB370+129j
    mov     esi, [ebx-20h]
    mov     edx, [ebx-18h]
    xor     eax, eax
    test    esi, esi
    jle     short loc_4CB40B
    mov     ebp, [ebp+24h]
    mov     edi, esi

    loc_4CB3F9:                             ; CODE XREF: sub_4CB370+99j
    xor     ecx, ecx
    mov     cx, [edx]
    add     edx, 2
    lea     ecx, [ecx+ecx*2]
    add     eax, [ebp+ecx*4+4]
    dec     edi
    jnz     short loc_4CB3F9

    loc_4CB40B:                             ; CODE XREF: sub_4CB370+82j
    cdq
    idiv    esi
    mov     ecx, [ebx]
    mov     edx, [ebx+8]
    lea     ebp, [ebx-4]
    mov     [esp+40h+var_24], eax
    xor     eax, eax
    test    ecx, ecx
    jle     short loc_4CB43B
    mov     esi, [esp+40h+arg_0]
    mov     edi, [esi+24h]
    mov     esi, ecx

    loc_4CB429:                             ; CODE XREF: sub_4CB370+C9j
    xor     ecx, ecx
    mov     cx, [edx]
    add     edx, 2
    lea     ecx, [ecx+ecx*2]
    add     eax, [edi+ecx*4+4]
    dec     esi
    jnz     short loc_4CB429

    loc_4CB43B:                             ; CODE XREF: sub_4CB370+AEj
    cdq
    idiv    dword ptr [ebp+4]
    cmp     [esp+40h+var_24], eax
    jle     short loc_4CB476
    mov     esi, [esp+40h+var_30]
    mov     ecx, 8
    lea     edi, [esp+40h+var_20]
    mov     [esp+40h+var_28], 1
    rep movsd
    mov     edi, [esp+40h+var_30]
    mov     ecx, 8
    mov     esi, ebp
    rep movsd
    mov     ecx, 8
    lea     esi, [esp+40h+var_20]
    mov     edi, ebp
    rep movsd

    loc_4CB476:                             ; CODE XREF: sub_4CB370+D3j
    mov     edx, [esp+40h+arg_0]
    mov     eax, [esp+40h+var_2C]
    mov     ebp, [esp+40h+var_30]
    inc     eax
    mov     ecx, [edx+8]
    add     ebp, 20h
    add     ebx, 20h
    dec     ecx
    mov     [esp+40h+var_30], ebp
    cmp     eax, ecx
    mov     [esp+40h+var_2C], eax
    mov     ebp, edx
    jl      loc_4CB3E8

    loc_4CB49F:                             ; CODE XREF: sub_4CB370+6Fj
    mov     eax, [esp+40h+var_28]
    test    eax, eax
    jnz     loc_4CB3BE
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    4
    sub_4CB370 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB4C0 proc near                    ; CODE XREF: sub_4CB4C0+41p
                                            ; sub_4CB4C0+54p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_4]
    push    edi
    mov     edi, [esp+4+arg_0]
    mov     eax, [esi+1Ch]
    test    eax, eax
    jz      short loc_4CB4D6
    add     eax, edi
    mov     [esi+1Ch], eax

    loc_4CB4D6:                             ; CODE XREF: sub_4CB4C0+Fj
    mov     eax, [esi+20h]
    test    eax, eax
    jz      short loc_4CB4E3
    lea     ecx, [edi+eax]
    mov     [esi+20h], ecx

    loc_4CB4E3:                             ; CODE XREF: sub_4CB4C0+1Bj
    mov     eax, [esi+24h]
    mov     edx, [esi+28h]
    add     eax, edi
    add     edx, edi
    mov     [esi+24h], eax
    mov     eax, [esi+2Ch]
    test    eax, eax
    mov     [esi+28h], edx
    jz      short loc_4CB506
    add     eax, edi
    push    eax
    push    edi
    mov     [esi+2Ch], eax
    call    sub_4CB4C0

    loc_4CB506:                             ; CODE XREF: sub_4CB4C0+38j
    mov     eax, [esi+30h]
    test    eax, eax
    jz      short loc_4CB519
    add     eax, edi
    push    eax
    push    edi
    mov     [esi+30h], eax
    call    sub_4CB4C0

    loc_4CB519:                             ; CODE XREF: sub_4CB4C0+4Bj
    mov     ecx, [esi+8]
    mov     eax, [esi+28h]
    xor     edx, edx
    test    ecx, ecx
    jle     short loc_4CB551
    add     eax, 8

    loc_4CB528:                             ; CODE XREF: sub_4CB4C0+8Fj
    mov     ecx, [eax]
    test    ecx, ecx
    jz      short loc_4CB532
    add     ecx, edi
    mov     [eax], ecx

    loc_4CB532:                             ; CODE XREF: sub_4CB4C0+6Cj
    mov     ecx, [eax+4]
    add     ecx, edi
    mov     [eax+4], ecx
    mov     ecx, [eax+8]
    test    ecx, ecx
    jz      short loc_4CB546
    add     ecx, edi
    mov     [eax+8], ecx

    loc_4CB546:                             ; CODE XREF: sub_4CB4C0+7Fj
    mov     ecx, [esi+8]
    inc     edx
    add     eax, 20h
    cmp     edx, ecx
    jl      short loc_4CB528

    loc_4CB551:                             ; CODE XREF: sub_4CB4C0+63j
    push    esi
    call    sub_4CB370
    pop     edi
    pop     esi
    retn    8
    sub_4CB4C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB560 proc near                    ; CODE XREF: sub_42A2C0+29p
                                            ; sub_42D2E0+486p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    push    0
    push    eax
    call    sub_4BBE50
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4CB577
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CB577:                             ; CODE XREF: sub_4CB560+11j
    push    esi
    push    esi
    call    sub_4CB4C0
    mov     eax, esi
    pop     esi
    retn    4
    sub_4CB560 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB590 proc near                    ; CODE XREF: sub_42A2C0+3Fp
                                            ; sub_42D2E0+49Fp ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi

    loc_4CB596:                             ; CODE XREF: sub_4CB590+58j
    mov     eax, [esi+4]
    xor     edx, edx
    test    eax, eax
    jle     short loc_4CB5C6
    xor     eax, eax

    loc_4CB5A1:                             ; CODE XREF: sub_4CB590+34j
    mov     ecx, [esi+24h]
    add     ecx, eax
    mov     edi, [ecx]
    neg     edi
    mov     [ecx], edi
    mov     ecx, [esi+24h]
    mov     edi, [ecx+eax+8]
    lea     ecx, [ecx+eax+8]
    neg     edi
    mov     [ecx], edi
    mov     ecx, [esi+4]
    inc     edx
    add     eax, 0Ch
    cmp     edx, ecx
    jl      short loc_4CB5A1

    loc_4CB5C6:                             ; CODE XREF: sub_4CB590+Dj
    mov     eax, [esi+18h]
    mov     edx, [esi+10h]
    neg     eax
    mov     [esi+18h], eax
    mov     eax, [esi+2Ch]
    neg     edx
    test    eax, eax
    mov     [esi+10h], edx
    jz      short loc_4CB5E3
    push    eax
    call    sub_4CB590

    loc_4CB5E3:                             ; CODE XREF: sub_4CB590+4Bj
    mov     esi, [esi+30h]
    test    esi, esi
    jnz     short loc_4CB596
    pop     edi
    pop     esi
    retn    4
    sub_4CB590 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB5F0 proc near                    ; CODE XREF: sub_42D2E0+4DFp
                                            ; sub_4CB5F0+37p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    xor     edi, edi
    test    esi, esi
    jz      short loc_4CB63D
    push    ebx

    loc_4CB5FD:                             ; CODE XREF: sub_4CB5F0+4Aj
    mov     eax, [esi+4]
    test    eax, eax
    jle     short loc_4CB61F
    mov     ecx, [esi+24h]
    mov     edx, [esi+14h]
    add     ecx, 4
    mov     ebx, eax

    loc_4CB60F:                             ; CODE XREF: sub_4CB5F0+2Dj
    mov     eax, [ecx]
    add     eax, edx
    cmp     eax, edi
    jle     short loc_4CB619
    mov     edi, eax

    loc_4CB619:                             ; CODE XREF: sub_4CB5F0+25j
    add     ecx, 0Ch
    dec     ebx
    jnz     short loc_4CB60F

    loc_4CB61F:                             ; CODE XREF: sub_4CB5F0+12j
    mov     eax, [esi+30h]
    test    eax, eax
    jz      short loc_4CB635
    push    eax
    call    sub_4CB5F0
    add     eax, [esi+14h]
    cmp     eax, edi
    jle     short loc_4CB635
    mov     edi, eax

    loc_4CB635:                             ; CODE XREF: sub_4CB5F0+34j
                                            ; sub_4CB5F0+41j
    mov     esi, [esi+2Ch]
    test    esi, esi
    jnz     short loc_4CB5FD
    pop     ebx

    loc_4CB63D:                             ; CODE XREF: sub_4CB5F0+Aj
    mov     eax, edi
    pop     edi
    pop     esi
    retn    4
    sub_4CB5F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB650 proc near                    ; CODE XREF: sub_46A530+3Fp
                                            ; sub_48C6A0+35p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 0Ch
    mov     eax, [esp+0Ch+arg_4]
    mov     ecx, [esp+0Ch+arg_8]
    xor     edx, edx
    mov     [eax], edx
    mov     [eax+4], edx
    mov     [eax+8], edx
    mov     [ecx], edx
    mov     [ecx+4], edx
    mov     [ecx+8], edx
    mov     [esp+0Ch+var_C], edx
    mov     [esp+0Ch+var_8], edx
    mov     [esp+0Ch+var_4], edx
    mov     edx, [esp+0Ch+arg_C]
    push    edx
    push    ecx
    mov     ecx, [esp+14h+arg_0]
    push    eax
    lea     eax, [esp+18h+var_C]
    push    eax
    push    ecx
    call    sub_4CB6A0
    add     esp, 0Ch
    retn    10h
    sub_4CB650 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB6A0 proc near                    ; CODE XREF: sub_4CB650+3Ap
                                            ; sub_4CB6A0+F4p ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 0Ch
    mov     ecx, [esp+0Ch+arg_4]
    push    ebx
    mov     ebx, [esp+10h+arg_0]
    push    ebp
    mov     edx, [ecx]
    push    esi
    mov     ebp, [ebx+10h]
    mov     eax, [ebx+14h]
    add     ebp, edx
    mov     edx, [ecx+4]
    push    edi
    mov     edi, [ebx+18h]
    add     edx, eax
    mov     eax, [ecx+8]
    mov     esi, [esp+1Ch+arg_C]
    add     eax, edi
    mov     edi, [esp+1Ch+arg_8]
    mov     [esp+1Ch+var_4], eax
    mov     eax, [ebx+4]
    mov     [esp+1Ch+var_C], ebp
    cmp     eax, 2
    mov     [esp+1Ch+var_8], edx
    jle     loc_4CB77C
    test    eax, eax
    mov     [esp+1Ch+arg_C], 0
    jle     loc_4CB77C
    mov     [esp+1Ch+arg_0], 0
    jmp     short loc_4CB704
    ; ---------------------------------------------------------------------------

    loc_4CB700:                             ; CODE XREF: sub_4CB6A0+D6j
    mov     edx, [esp+1Ch+var_8]

    loc_4CB704:                             ; CODE XREF: sub_4CB6A0+5Ej
    mov     eax, [ebx+24h]
    mov     ecx, [esp+1Ch+arg_0]
    add     eax, ecx
    mov     ecx, [eax]
    add     ecx, ebp
    cmp     ecx, [esi]
    jle     short loc_4CB717
    mov     [esi], ecx

    loc_4CB717:                             ; CODE XREF: sub_4CB6A0+73j
    mov     ecx, [eax]
    add     ecx, ebp
    cmp     ecx, [edi]
    jge     short loc_4CB721
    mov     [edi], ecx

    loc_4CB721:                             ; CODE XREF: sub_4CB6A0+7Dj
    mov     ecx, [eax+4]
    add     ecx, edx
    cmp     ecx, [esi+4]
    jle     short loc_4CB72E
    mov     [esi+4], ecx

    loc_4CB72E:                             ; CODE XREF: sub_4CB6A0+89j
    mov     ecx, [eax+4]
    add     ecx, edx
    mov     edx, [edi+4]
    cmp     ecx, edx
    jge     short loc_4CB73D
    mov     [edi+4], ecx

    loc_4CB73D:                             ; CODE XREF: sub_4CB6A0+98j
    mov     ecx, [eax+8]
    mov     edx, [esp+1Ch+var_4]
    add     ecx, edx
    cmp     ecx, [esi+8]
    jle     short loc_4CB74E
    mov     [esi+8], ecx

    loc_4CB74E:                             ; CODE XREF: sub_4CB6A0+A9j
    mov     eax, [eax+8]
    mov     ecx, [edi+8]
    add     eax, edx
    cmp     eax, ecx
    jge     short loc_4CB75D
    mov     [edi+8], eax

    loc_4CB75D:                             ; CODE XREF: sub_4CB6A0+B8j
    mov     eax, [esp+1Ch+arg_C]
    mov     edx, [esp+1Ch+arg_0]
    mov     ecx, [ebx+4]
    inc     eax
    add     edx, 0Ch
    cmp     eax, ecx
    mov     [esp+1Ch+arg_C], eax
    mov     [esp+1Ch+arg_0], edx
    jl      short loc_4CB700
    mov     ecx, [esp+1Ch+arg_4]

    loc_4CB77C:                             ; CODE XREF: sub_4CB6A0+40j
                                            ; sub_4CB6A0+50j
    mov     ebp, [esp+1Ch+arg_10]
    test    ebp, ebp
    jz      short loc_4CB7AE
    mov     eax, [ebx+30h]
    test    eax, eax
    jz      short loc_4CB79D
    push    ebp
    push    esi
    lea     ecx, [esp+24h+var_C]
    push    edi
    push    ecx
    push    eax
    call    sub_4CB6A0
    mov     ecx, [esp+1Ch+arg_4]

    loc_4CB79D:                             ; CODE XREF: sub_4CB6A0+E9j
    mov     ebx, [ebx+2Ch]
    test    ebx, ebx
    jz      short loc_4CB7AE
    push    ebp
    push    esi
    push    edi
    push    ecx
    push    ebx
    call    sub_4CB6A0

    loc_4CB7AE:                             ; CODE XREF: sub_4CB6A0+E2j
                                            ; sub_4CB6A0+102j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    14h
    sub_4CB6A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB7C0 proc near                    ; CODE XREF: sub_495A30+2Ap
    mov     eax, ecx
    mov     dword ptr [eax+0Ch], 0
    retn
    sub_4CB7C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB7D0 proc near                    ; CODE XREF: sub_495A30+43Fp
    mov     eax, [ecx+0Ch]
    test    eax, eax
    jz      short locret_4CB7E0
    push    eax
    call    _fclose
    add     esp, 4

    locret_4CB7E0:                          ; CODE XREF: sub_4CB7D0+5j
    retn
    sub_4CB7D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB7F0 proc near                    ; CODE XREF: sub_495A30+4Bp
                                            ; .text:004CBA02p

    var_438= dword ptr -438h
    var_432= word ptr -432h
    var_430= word ptr -430h
    var_42E= dword ptr -42Eh
    var_428= dword ptr -428h
    var_424= dword ptr -424h
    var_420= dword ptr -420h
    var_41C= word ptr -41Ch
    var_41A= word ptr -41Ah
    var_418= dword ptr -418h
    var_414= dword ptr -414h
    var_410= dword ptr -410h
    var_40C= dword ptr -40Ch
    var_408= dword ptr -408h
    var_404= dword ptr -404h
    var_3FF= dword ptr -3FFh
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 438h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    call    sub_4B6220
    mov     esi, [esp+448h+arg_4]
    mov     ebp, [esp+448h+arg_8]
    mov     ebx, eax
    mov     eax, [esp+448h+arg_0]
    push    offset aWb                      ; "wb"
    push    eax
    mov     [edi], esi
    mov     [edi+4], ebp
    call    _fopen
    xor     ecx, ecx
    add     esp, 8
    cmp     eax, ecx
    mov     [edi+0Ch], eax
    jnz     short loc_4CB843
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 438h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CB843:                             ; CODE XREF: sub_4CB7F0+42j
    mov     [esp+448h+var_438+2], ecx
    mov     [esp+448h+var_432], cx
    mov     [esp+448h+var_430], cx
    push    eax
    push    1
    lea     ecx, [esp+450h+var_438]
    push    0Eh
    push    ecx
    mov     word ptr [esp+458h+var_438], 4D42h
    mov     [esp+458h+var_42E], 436h
    call    sub_4E5D40
    add     esp, 10h
    cmp     eax, 1
    jz      short loc_4CB886
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 438h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CB886:                             ; CODE XREF: sub_4CB7F0+85j
    xor     eax, eax
    mov     [esp+448h+var_424], esi
    mov     [esp+448h+var_418], eax
    mov     [esp+448h+var_414], eax
    mov     eax, 0BB8h
    mov     esi, 100h
    mov     [esp+448h+var_410], eax
    mov     [esp+448h+var_40C], eax
    mov     [esp+448h+var_428], 28h
    mov     [esp+448h+var_420], ebp
    mov     [esp+448h+var_41C], 1
    mov     [esp+448h+var_41A], 8
    mov     [esp+448h+var_408], esi
    mov     [esp+448h+var_404], esi
    lea     eax, [esp+448h+var_3FF]
    lea     ecx, [ebx+215h]

    loc_4CB8D2:                             ; CODE XREF: sub_4CB7F0+FAj
    mov     dl, [ecx-1]
    add     ecx, 4
    mov     [eax+1], dl
    mov     dl, [ecx-4]
    mov     [eax], dl
    mov     dl, [ecx-3]
    mov     [eax-1], dl
    add     eax, 4
    dec     esi
    jnz     short loc_4CB8D2
    mov     eax, [edi+0Ch]
    lea     ecx, [esp+448h+var_428]
    push    eax
    push    1
    push    428h
    push    ecx
    call    sub_4E5D40
    add     esp, 10h
    cmp     eax, 1
    jz      short loc_4CB918
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 438h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CB918:                             ; CODE XREF: sub_4CB7F0+117j
    mov     edx, [edi+0Ch]
    push    edx
    call    _ftell
    add     esp, 4
    mov     [edi+8], eax
    mov     al, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 438h
    retn    0Ch
    sub_4CB7F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CB940 proc near                    ; CODE XREF: sub_495A30+328p

    arg_0= dword ptr  8
    arg_8= dword ptr  10h
    arg_10= dword ptr  18h
    arg_18= dword ptr  20h

    push    ebx
    mov     ebx, [esp+arg_8]
    push    ebp
    push    esi
    mov     esi, [esp+8+arg_0]
    mov     ebp, ecx
    mov     ecx, [esp+8+arg_10]
    push    edi
    mov     edi, [esi]
    mov     eax, [ebp+4]
    add     edi, 3
    sub     eax, ebx
    and     edi, 0FFFFFFFCh
    sub     eax, ecx
    imul    eax, edi
    mov     edx, [ebp+8]
    mov     ecx, [ebp+0Ch]
    add     eax, edx
    push    0
    push    eax
    push    ecx
    call    _fseek
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4CB985
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CB985:                             ; CODE XREF: sub_4CB940+3Aj
    dec     ebx
    test    ebx, ebx
    mov     [esp+0Ch+arg_0], ebx
    jl      short loc_4CB9D4
    mov     edx, [esp+0Ch+arg_18]
    add     ebx, edx

    loc_4CB994:                             ; CODE XREF: sub_4CB940+80j
    mov     ecx, [esi+8]
    mov     eax, [ebp+0Ch]
    imul    ecx, ebx
    mov     edx, [esi+0Ch]
    push    eax
    push    1
    add     ecx, edx
    push    edi
    push    ecx
    call    sub_4E5D40
    add     esp, 10h
    cmp     eax, 1
    jnz     short loc_4CB9CB
    mov     eax, [esp+0Ch+arg_0]
    dec     eax
    dec     ebx
    test    eax, eax
    mov     [esp+0Ch+arg_0], eax
    jge     short loc_4CB994
    mov     al, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CB9CB:                             ; CODE XREF: sub_4CB940+72j
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CB9D4:                             ; CODE XREF: sub_4CB940+4Cj
    pop     edi
    pop     esi
    pop     ebp
    mov     al, 1
    pop     ebx
    retn    1Ch
    sub_4CB940 endp

    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 10h
    mov     edx, [esp+14h]
    push    ebx
    push    esi
    mov     esi, [esp+20h]
    push    edi
    mov     dword ptr [esp+18h], 0
    mov     eax, [esi+4]
    mov     ecx, [esi]
    push    eax
    push    ecx
    push    edx
    lea     ecx, [esp+18h]
    call    sub_4CB7F0
    test    al, al
    jnz     short loc_4CBA11
    mov     eax, [esp+18h]
    jmp     short loc_4CBA76
    ; ---------------------------------------------------------------------------

    loc_4CBA11:                             ; CODE XREF: .text:004CBA09j
    mov     edi, [esi]
    mov     ebx, [esi+4]
    mov     eax, [esp+10h]
    add     edi, 3
    and     edi, 0FFFFFFFCh
    sub     eax, ebx
    imul    eax, edi
    mov     edx, [esp+14h]
    mov     ecx, [esp+18h]
    add     eax, edx
    push    0
    push    eax
    push    ecx
    call    _fseek
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4CBA43
    xor     al, al
    jmp     short loc_4CBA6E
    ; ---------------------------------------------------------------------------

    loc_4CBA43:                             ; CODE XREF: .text:004CBA3Dj
    dec     ebx
    test    ebx, ebx
    jl      short loc_4CBA6C

    loc_4CBA48:                             ; CODE XREF: .text:004CBA6Aj
    mov     edx, [esp+18h]
    mov     eax, ebx
    imul    eax, [esi+8]
    push    edx
    mov     edx, [esi+0Ch]
    push    1
    add     eax, edx
    push    edi
    push    eax
    call    sub_4E5D40
    add     esp, 10h
    cmp     eax, 1
    jnz     short loc_4CBAA9
    dec     ebx
    jns     short loc_4CBA48

    loc_4CBA6C:                             ; CODE XREF: .text:004CBA46j
    mov     al, 1

    loc_4CBA6E:                             ; CODE XREF: .text:004CBA41j
                                            ; .text:004CBAABj
    test    al, al
    mov     eax, [esp+18h]
    jnz     short loc_4CBA8E

    loc_4CBA76:                             ; CODE XREF: .text:004CBA0Fj
    test    eax, eax
    jz      short loc_4CBA83
    push    eax
    call    _fclose
    add     esp, 4

    loc_4CBA83:                             ; CODE XREF: .text:004CBA78j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CBA8E:                             ; CODE XREF: .text:004CBA74j
    test    eax, eax
    jz      short loc_4CBA9B
    push    eax
    call    _fclose
    add     esp, 4

    loc_4CBA9B:                             ; CODE XREF: .text:004CBA90j
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CBAA9:                             ; CODE XREF: .text:004CBA67j
    xor     al, al
    jmp     short loc_4CBA6E
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CBAB0 proc near                    ; CODE XREF: sub_497C70+44p
                                            ; sub_49EDFC+9p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    push    ebx
    push    esi
    push    edi
    push    eax
    push    ecx
    call    sub_4D8E60
    add     esp, 8
    call    sub_4B6220
    test    eax, eax
    mov     [esp+0Ch+arg_4], eax
    jz      loc_4CBB65
    mov     esi, ds:InterlockedExchange
    mov     ebx, ds:WaitForSingleObject
    mov     edi, 4D41494Eh

    loc_4CBAE7:                             ; CODE XREF: sub_4CBAB0+56j
    push    edi                             ; Value
    push    offset Target                   ; Target
    call    esi ; InterlockedExchange
    test    eax, eax
    jz      short loc_4CBB08
    cmp     dword_52A4EC, edi
    jz      short loc_4CBB12
    mov     edx, hHandle
    push    0FFFFFFFFh                      ; dwMilliseconds
    push    edx                             ; hHandle
    call    ebx ; WaitForSingleObject
    jmp     short loc_4CBAE7
    ; ---------------------------------------------------------------------------

    loc_4CBB08:                             ; CODE XREF: sub_4CBAB0+41j
    mov     dword_52A4EC, edi
    xor     edi, edi
    jmp     short loc_4CBB14
    ; ---------------------------------------------------------------------------

    loc_4CBB12:                             ; CODE XREF: sub_4CBAB0+49j
    mov     edi, eax

    loc_4CBB14:                             ; CODE XREF: sub_4CBAB0+60j
    mov     ebx, [esp+0Ch+arg_4]
    mov     dword ptr [ebx+1B2h], 0
    call    sub_4C5DF0
    test    edi, edi
    jnz     short loc_4CBB45
    push    edi                             ; Value
    push    offset Target                   ; Target
    mov     dword_52A4EC, edi
    call    esi ; InterlockedExchange
    mov     eax, hHandle
    push    eax                             ; hEvent
    call    ds:SetEvent

    loc_4CBB45:                             ; CODE XREF: sub_4CBAB0+79j
    push    ebx
    call    sub_4B4FF0
    mov     eax, [ebx+40h]
    test    eax, eax
    jz      short loc_4CBB65
    push    13h                             ; uFlags
    push    0                               ; cy
    push    0                               ; cx
    push    0                               ; Y
    push    0                               ; X
    push    0FFFFFFFEh                      ; hWndInsertAfter
    push    eax                             ; hWnd
    call    ds:SetWindowPos

    loc_4CBB65:                             ; CODE XREF: sub_4CBAB0+20j
                                            ; sub_4CBAB0+A0j
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    8
    sub_4CBAB0 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    push    offset aDebughelper_dl          ; "DebugHelper.dll"
    call    ds:LoadLibraryA
    mov     esi, eax
    test    esi, esi
    jz      short loc_4CBBC6
    push    offset aDebugfunc1              ; "DebugFunc1"
    push    esi
    call    ds:GetProcAddress
    test    eax, eax
    jz      short loc_4CBBAC
    mov     ecx, [esp+8]
    push    ecx
    call    eax
    push    esi
    mov     [esp+0Ch], eax
    call    ds:FreeLibrary
    mov     eax, [esp+8]
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CBBAC:                             ; CODE XREF: .text:004CBB90j
    push    offset aCouldnTFindF_0          ; "Couldn't find function.\n"
    call    ds:OutputDebugStringA
    push    esi
    call    ds:FreeLibrary
    mov     eax, [esp+8]
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CBBC6:                             ; CODE XREF: .text:004CBB80j
    push    offset aCouldnTFindL_0          ; "Couldn't find library.\n"
    call    ds:OutputDebugStringA
    pop     esi
    mov     eax, [esp+4]
    retn    4
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CBBE0 proc near                    ; CODE XREF: sub_4B5510+262p
                                            ; .text:004C241Bp ...

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFE4h
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    pushf
    cld
    mov     edi, [ebp+arg_0]
    mov     eax, [edi+8]
    mov     [ebp+var_4], eax
    mov     eax, [edi]
    mov     [ebp+var_1C], eax
    cmp     eax, [ebp+arg_8]
    jle     loc_4CBCCD
    mov     eax, [edi+4]
    mov     [ebp+var_8], eax
    cmp     eax, [ebp+arg_C]
    jle     loc_4CBCCD
    mov     esi, [ebp+arg_4]
    mov     ecx, [esi+8]
    mov     [ebp+var_C], ecx
    mov     ecx, [esi]
    mov     [ebp+var_18], ecx
    mov     eax, [ebp+arg_8]
    neg     eax
    cmp     eax, ecx
    jge     loc_4CBCCD
    mov     ecx, [esi+4]
    mov     [ebp+var_10], ecx
    mov     eax, [ebp+arg_C]
    neg     eax
    cmp     eax, ecx
    jge     loc_4CBCCD
    mov     esi, [esi+0Ch]
    mov     edi, [edi+0Ch]
    mov     ebx, [ebp+var_1C]
    mov     ecx, [ebp+var_18]
    mov     eax, [ebp+arg_8]
    cmp     eax, 0
    jl      short loc_4CBC5B
    sub     ebx, eax
    add     edi, eax
    jmp     short loc_4CBC61
    ; ---------------------------------------------------------------------------

    loc_4CBC5B:                             ; CODE XREF: sub_4CBBE0+73j
    add     ecx, eax
    neg     eax
    add     esi, eax

    loc_4CBC61:                             ; CODE XREF: sub_4CBBE0+79j
    cmp     ecx, ebx
    jle     short loc_4CBC67
    mov     ecx, ebx

    loc_4CBC67:                             ; CODE XREF: sub_4CBBE0+83j
    mov     [ebp+var_14], ecx
    mov     ebx, [ebp+var_8]
    mov     ecx, [ebp+var_10]
    mov     eax, [ebp+arg_C]
    cmp     eax, 0
    jl      short loc_4CBC81
    sub     ebx, eax
    mul     [ebp+var_4]
    add     edi, eax
    jmp     short loc_4CBC8A
    ; ---------------------------------------------------------------------------

    loc_4CBC81:                             ; CODE XREF: sub_4CBBE0+96j
    add     ecx, eax
    neg     eax
    mul     [ebp+var_C]
    add     esi, eax

    loc_4CBC8A:                             ; CODE XREF: sub_4CBBE0+9Fj
    cmp     ecx, ebx
    jle     short loc_4CBC90
    mov     ecx, ebx

    loc_4CBC90:                             ; CODE XREF: sub_4CBBE0+ACj
    mov     eax, ecx
    mov     edx, [ebp+var_C]
    sub     edx, [ebp+var_14]
    mov     ebx, [ebp+var_4]
    sub     ebx, [ebp+var_14]
    mov     ecx, edi
    and     ecx, 3
    jnz     short loc_4CBCB3
    mov     ecx, [ebp+var_14]
    and     ecx, 3
    jnz     short loc_4CBCB3
    shr     [ebp+var_14], 2
    jmp     short loc_4CBCC1
    ; ---------------------------------------------------------------------------

    loc_4CBCB3:                             ; CODE XREF: sub_4CBBE0+C3j
                                            ; sub_4CBBE0+CBj ...
    mov     ecx, [ebp+var_14]
    rep movsb
    add     esi, edx
    add     edi, ebx
    dec     eax
    jnz     short loc_4CBCB3
    jmp     short loc_4CBCCD
    ; ---------------------------------------------------------------------------

    loc_4CBCC1:                             ; CODE XREF: sub_4CBBE0+D1j
                                            ; sub_4CBBE0+EBj
    mov     ecx, [ebp+var_14]
    rep movsd
    add     esi, edx
    add     edi, ebx
    dec     eax
    jnz     short loc_4CBCC1

    loc_4CBCCD:                             ; CODE XREF: sub_4CBBE0+1Ej
                                            ; sub_4CBBE0+2Dj ...
    popf
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CBBE0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CBCD5 proc near                    ; CODE XREF: .text:004C6C97p
                                            ; .text:004C6D03p

    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= byte ptr  18h

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFDCh
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    pushf
    cld
    mov     edi, [ebp+arg_0]
    mov     eax, [edi+8]
    mov     [ebp+var_4], eax
    mov     eax, [edi]
    mov     [ebp+var_20], eax
    cmp     eax, [ebp+arg_8]
    jle     loc_4CBDC9
    mov     eax, [edi+4]
    mov     [ebp+var_8], eax
    cmp     eax, [ebp+arg_C]
    jle     loc_4CBDC9
    mov     esi, [ebp+arg_4]
    mov     ecx, [esi+8]
    mov     [ebp+var_10], ecx
    mov     ecx, [esi]
    mov     [ebp+var_1C], ecx
    mov     eax, [ebp+arg_8]
    neg     eax
    cmp     eax, ecx
    jge     loc_4CBDC9
    mov     ecx, [esi+4]
    mov     [ebp+var_14], ecx
    mov     eax, [ebp+arg_C]
    neg     eax
    cmp     eax, ecx
    jge     loc_4CBDC9
    mov     esi, [esi+0Ch]
    mov     edi, [edi+0Ch]
    mov     ebx, [ebp+var_20]
    mov     ecx, [ebp+var_1C]
    mov     eax, [ebp+arg_8]
    cmp     eax, 0
    jl      short loc_4CBD50
    sub     ebx, eax
    add     edi, eax
    jmp     short loc_4CBD56
    ; ---------------------------------------------------------------------------

    loc_4CBD50:                             ; CODE XREF: sub_4CBCD5+73j
    add     ecx, eax
    neg     eax
    add     esi, eax

    loc_4CBD56:                             ; CODE XREF: sub_4CBCD5+79j
    cmp     ecx, ebx
    jle     short loc_4CBD5C
    mov     ecx, ebx

    loc_4CBD5C:                             ; CODE XREF: sub_4CBCD5+83j
    mov     [ebp+var_24], ecx
    mov     ebx, [ebp+var_8]
    mov     ecx, [ebp+var_14]
    mov     eax, [ebp+arg_C]
    cmp     eax, 0
    jl      short loc_4CBD76
    sub     ebx, eax
    mul     [ebp+var_4]
    add     edi, eax
    jmp     short loc_4CBD7F
    ; ---------------------------------------------------------------------------

    loc_4CBD76:                             ; CODE XREF: sub_4CBCD5+96j
    add     ecx, eax
    neg     eax
    mul     [ebp+var_10]
    add     esi, eax

    loc_4CBD7F:                             ; CODE XREF: sub_4CBCD5+9Fj
    cmp     ecx, ebx
    jle     short loc_4CBD85
    mov     ecx, ebx

    loc_4CBD85:                             ; CODE XREF: sub_4CBCD5+ACj
    mov     [ebp+var_C], ecx
    mov     ebx, [ebp+var_4]
    sub     ebx, [ebp+var_24]
    mov     eax, [ebp+var_10]
    sub     eax, [ebp+var_24]
    mov     [ebp+var_18], eax
    mov     al, [ebp+arg_10]
    mov     dl, al
    shl     dx, 8
    mov     dl, al
    shl     edx, 10h
    mov     dl, al
    shl     dx, 8
    mov     dl, al

    loc_4CBDAD:                             ; CODE XREF: sub_4CBCD5+F0j
    mov     ecx, [ebp+var_24]

    loc_4CBDB0:                             ; CODE XREF: sub_4CBCD5+E6j
    mov     al, [esi]
    cmp     al, dl
    jz      short loc_4CBDB8
    mov     [edi], al

    loc_4CBDB8:                             ; CODE XREF: sub_4CBCD5+DFj
    inc     esi
    inc     edi
    dec     ecx
    jnz     short loc_4CBDB0
    add     esi, [ebp+var_18]
    add     edi, ebx
    dec     [ebp+var_C]
    jnz     short loc_4CBDAD
    jmp     short $+2

    loc_4CBDC9:                             ; CODE XREF: sub_4CBCD5+1Ej
                                            ; sub_4CBCD5+2Dj ...
    popf
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CBCD5 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CBDD1 proc near                    ; CODE XREF: sub_4B8150+16Dp
                                            ; sub_4C6D20+2Dp ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFF0h
    push    esi
    push    edi
    push    ebx
    pushf
    cld
    mov     esi, [ebp+arg_8]
    mov     edi, [ebp+arg_C]
    mov     ecx, [esi+8]
    sub     ecx, [esi]
    inc     ecx
    mov     [ebp+var_C], ecx
    mov     eax, [esi+0Ch]
    sub     eax, [esi+4]
    inc     eax
    mov     [ebp+var_10], eax
    mov     eax, [esi+4]
    mov     ebx, [esi]
    mov     esi, [ebp+arg_4]
    mov     ecx, [esi+8]
    mov     [ebp+var_4], ecx
    mov     esi, [esi+0Ch]
    mul     ecx
    add     eax, ebx
    add     esi, eax
    mov     eax, [edi+4]
    mov     ebx, [edi]
    mov     edi, [ebp+arg_0]
    mov     ecx, [edi+8]
    mov     [ebp+var_8], ecx
    mov     edi, [edi+0Ch]
    mul     ecx
    add     eax, ebx
    add     edi, eax
    mov     ecx, [ebp+var_C]
    mov     eax, [ebp+var_4]
    sub     eax, ecx
    mov     ebx, [ebp+var_8]
    sub     ebx, ecx
    mov     edx, [ebp+var_10]
    shr     ecx, 1
    jb      short loc_4CBE5E
    mov     [ebp+var_C], ecx
    shr     ecx, 1
    jb      short loc_4CBE4F
    mov     [ebp+var_C], ecx

    loc_4CBE41:                             ; CODE XREF: sub_4CBDD1+7Aj
    mov     ecx, [ebp+var_C]
    rep movsd
    add     esi, eax
    add     edi, ebx
    dec     edx
    jnz     short loc_4CBE41
    jmp     short loc_4CBE6A
    ; ---------------------------------------------------------------------------

    loc_4CBE4F:                             ; CODE XREF: sub_4CBDD1+6Bj
                                            ; sub_4CBDD1+89j
    mov     ecx, [ebp+var_C]
    rep movsw
    add     esi, eax
    add     edi, ebx
    dec     edx
    jnz     short loc_4CBE4F
    jmp     short loc_4CBE6A
    ; ---------------------------------------------------------------------------

    loc_4CBE5E:                             ; CODE XREF: sub_4CBDD1+64j
                                            ; sub_4CBDD1+97j
    mov     ecx, [ebp+var_C]
    rep movsb
    add     esi, eax
    add     edi, ebx
    dec     edx
    jnz     short loc_4CBE5E

    loc_4CBE6A:                             ; CODE XREF: sub_4CBDD1+7Cj
                                            ; sub_4CBDD1+8Bj
    popf
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CBDD1 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CBE70 proc near                    ; CODE XREF: sub_4B7F90+173p
                                            ; .text:004C6DF6p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= byte ptr  18h

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFF0h
    push    esi
    push    edi
    push    ebx
    pushf
    cld
    mov     esi, [ebp+arg_8]
    mov     edi, [ebp+arg_C]
    mov     ecx, [esi+8]
    sub     ecx, [esi]
    inc     ecx
    mov     [ebp+var_C], ecx
    mov     eax, [esi+0Ch]
    sub     eax, [esi+4]
    inc     eax
    mov     [ebp+var_10], eax
    mov     eax, [esi+4]
    mov     ebx, [esi]
    mov     esi, [ebp+arg_4]
    mov     ecx, [esi+8]
    mov     [ebp+var_4], ecx
    mov     esi, [esi+0Ch]
    mul     ecx
    add     eax, ebx
    add     esi, eax
    mov     eax, [edi+4]
    mov     ebx, [edi]
    mov     edi, [ebp+arg_0]
    mov     ecx, [edi+8]
    mov     [ebp+var_8], ecx
    mov     edi, [edi+0Ch]
    mul     ecx
    add     eax, ebx
    add     edi, eax
    mov     ecx, [ebp+var_C]
    mov     edx, [ebp+var_4]
    sub     edx, ecx
    mov     ebx, [ebp+var_8]
    sub     ebx, ecx
    mov     ah, [ebp+arg_10]

    loc_4CBED2:                             ; CODE XREF: sub_4CBE70+79j
    mov     ecx, [ebp+var_C]

    loc_4CBED5:                             ; CODE XREF: sub_4CBE70+70j
    mov     al, [esi]
    cmp     al, ah
    jz      short loc_4CBEDD
    mov     [edi], al

    loc_4CBEDD:                             ; CODE XREF: sub_4CBE70+69j
    inc     esi
    inc     edi
    dec     ecx
    jnz     short loc_4CBED5
    add     esi, edx
    add     edi, ebx
    dec     [ebp+var_10]
    jnz     short loc_4CBED2
    popf
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CBE70 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CBEF1 proc near                    ; CODE XREF: sub_4C6E70+2Dp
                                            ; sub_4C6E70+87p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h

    push    ebp
    mov     ebp, esp
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    pushf
    cld
    mov     esi, [ebp+arg_C]
    mov     edi, [ebp+arg_0]
    mov     eax, [edi+8]
    mov     ebx, eax
    mul     [ebp+arg_8]
    add     eax, [ebp+arg_4]
    mov     edi, [edi+0Ch]
    add     edi, eax
    mov     edx, 20h
    sub     ebx, edx

    loc_4CBF18:                             ; CODE XREF: sub_4CBEF1+31j
    mov     ecx, 8
    rep movsd
    add     edi, ebx
    dec     edx
    jnz     short loc_4CBF18
    popf
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CBEF1 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CBF2C proc near                    ; CODE XREF: sub_4B8310+189p
                                            ; sub_4B8500+182p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= byte ptr  18h
    arg_14= dword ptr  1Ch

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFE8h
    push    esi
    push    edi
    push    ebx
    pushf
    cld
    mov     esi, [ebp+arg_8]
    mov     edi, [ebp+arg_C]
    mov     ecx, [esi+8]
    sub     ecx, [esi]
    inc     ecx
    mov     [ebp+var_C], ecx
    mov     eax, [esi+0Ch]
    sub     eax, [esi+4]
    inc     eax
    mov     [ebp+var_10], eax
    mov     eax, [esi+4]
    mov     ebx, [esi]
    mov     esi, [ebp+arg_4]
    mov     ecx, [esi+8]
    mov     [ebp+var_4], ecx
    mov     esi, [esi+0Ch]
    mul     ecx
    add     eax, ebx
    add     esi, eax
    mov     eax, [edi+4]
    mov     ebx, [edi]
    mov     edi, [ebp+arg_0]
    mov     ecx, [edi+8]
    mov     [ebp+var_8], ecx
    mov     edi, [edi+0Ch]
    mul     ecx
    add     eax, ebx
    add     edi, eax
    mov     ecx, [ebp+var_C]
    mov     edx, [ebp+var_4]
    sub     edx, ecx
    mov     [ebp+var_14], edx
    mov     ebx, [ebp+var_8]
    sub     ebx, ecx
    mov     [ebp+var_18], ebx
    mov     edx, [ebp+arg_14]
    xor     eax, eax

    loc_4CBF96:                             ; CODE XREF: sub_4CBF2C+90j
    mov     ecx, [ebp+var_C]

    loc_4CBF99:                             ; CODE XREF: sub_4CBF2C+85j
    mov     al, [esi]
    cmp     al, [ebp+arg_10]
    jz      short loc_4CBFAE
    mov     ebx, eax
    shl     ebx, 8
    mov     al, [edi]
    add     ebx, edx
    mov     al, [eax+ebx]
    mov     [edi], al

    loc_4CBFAE:                             ; CODE XREF: sub_4CBF2C+72j
    inc     esi
    inc     edi
    dec     ecx
    jnz     short loc_4CBF99
    add     esi, [ebp+var_14]
    add     edi, [ebp+var_18]
    dec     [ebp+var_10]
    jnz     short loc_4CBF96
    popf
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CBF2C endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CBFC4 proc near                    ; CODE XREF: sub_4B86E0+1BAp

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= byte ptr  18h
    arg_14= dword ptr  1Ch

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFE8h
    push    esi
    push    edi
    push    ebx
    pushf
    cld
    mov     esi, [ebp+arg_8]
    mov     edi, [ebp+arg_C]
    mov     ecx, [esi+8]
    sub     ecx, [esi]
    inc     ecx
    mov     [ebp+var_C], ecx
    mov     eax, [esi+0Ch]
    sub     eax, [esi+4]
    inc     eax
    mov     [ebp+var_10], eax
    mov     eax, [esi+4]
    mov     ebx, [esi]
    mov     esi, [ebp+arg_4]
    mov     ecx, [esi+8]
    mov     [ebp+var_4], ecx
    mov     esi, [esi+0Ch]
    mul     ecx
    add     eax, ebx
    add     esi, eax
    mov     eax, [edi+4]
    mov     ebx, [edi]
    mov     edi, [ebp+arg_0]
    mov     ecx, [edi+8]
    mov     [ebp+var_8], ecx
    mov     edi, [edi+0Ch]
    mul     ecx
    add     eax, ebx
    add     edi, eax
    mov     ecx, [ebp+var_C]
    mov     edx, [ebp+var_4]
    sub     edx, ecx
    mov     [ebp+var_14], edx
    mov     ebx, [ebp+var_8]
    sub     ebx, ecx
    mov     [ebp+var_18], ebx
    mov     edx, [ebp+arg_14]
    xor     eax, eax
    mov     bh, [ebp+arg_10]

    loc_4CC031:                             ; CODE XREF: sub_4CBFC4+8Bj
    mov     ecx, [ebp+var_C]

    loc_4CC034:                             ; CODE XREF: sub_4CBFC4+80j
    mov     al, [esi]
    cmp     al, bh
    jz      short loc_4CC041
    mov     al, [edi]
    mov     bl, [eax+edx]
    mov     [edi], bl

    loc_4CC041:                             ; CODE XREF: sub_4CBFC4+74j
    inc     esi
    inc     edi
    dec     ecx
    jnz     short loc_4CC034
    add     esi, [ebp+var_14]
    add     edi, [ebp+var_18]
    dec     [ebp+var_10]
    jnz     short loc_4CC031
    popf
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CBFC4 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CC057 proc near                    ; CODE XREF: sub_4B8500+1AAp

    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFFCh
    push    ebx
    push    ecx
    push    esi
    push    edi
    push    ebp
    mov     edi, [ebp+arg_0]
    mov     esi, [ebp+arg_C]
    mov     ecx, [ebp+arg_4]
    mov     ebx, [ebp+arg_8]
    mov     eax, [ebx+4]
    imul    ecx
    add     edi, [ebx]
    add     edi, eax
    mov     edx, [ebp+arg_10]
    mov     ebx, [edx+4]
    or      ebx, ebx

    loc_4CC07F:                             ; CODE XREF: sub_4CC057+32j
    jz      short loc_4CC08C
    movzx   eax, word ptr [esi]
    lea     esi, [eax+esi+2]
    dec     ebx
    jmp     short loc_4CC07F
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC08C:                             ; CODE XREF: sub_4CC057+28j
    mov     ebx, [edx+0Ch]
    sub     ebx, [edx+4]
    mov     [ebp+var_4], ebx
    mov     ebx, [edx+8]
    jl      short loc_4CC0A9
    mov     edx, [edx]
    sub     ebx, edx
    inc     ebx
    jle     short loc_4CC0A9
    jmp     short loc_4CC0B5
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC0A4:                             ; CODE XREF: sub_4CC057+71j
    pop     esi
    pop     edi
    pop     ebx
    pop     ecx
    pop     edx

    loc_4CC0A9:                             ; CODE XREF: sub_4CC057+41j
                                            ; sub_4CC057+48j
    pop     ebp
    pop     edi
    pop     esi
    pop     ecx
    pop     ebx
    leave
    retn
    ; ---------------------------------------------------------------------------

    loc_4CC0B0:                             ; CODE XREF: sub_4CC057+7Bj
                                            ; sub_4CC057+BFj ...
    pop     esi
    pop     edi
    pop     ebx
    pop     ecx
    pop     edx

    loc_4CC0B5:                             ; CODE XREF: sub_4CC057+4Aj
    movzx   eax, word ptr [esi]
    push    edx
    push    ecx
    push    ebx
    add     ecx, edi
    push    ecx
    lea     ecx, [eax+esi+2]
    push    ecx
    mov     ecx, [ebp+var_4]
    or      ecx, ecx
    js      short loc_4CC0A4
    dec     [ebp+var_4]
    add     esi, 2
    or      eax, eax
    jz      short loc_4CC0B0
    or      edx, edx
    jle     short loc_4CC114

    loc_4CC0D8:                             ; CODE XREF: sub_4CC057+8Dj
                                            ; sub_4CC057+9Fj ...
    movzx   eax, byte ptr [esi]
    inc     esi
    shr     eax, 1
    jnb     short loc_4CC0EC
    sub     edx, eax
    jz      short loc_4CC114
    jg      short loc_4CC0D8
    mov     eax, edx
    neg     eax
    jmp     short loc_4CC120
    ; ---------------------------------------------------------------------------

    loc_4CC0EC:                             ; CODE XREF: sub_4CC057+87j
    shr     eax, 1
    jnb     short loc_4CC100
    inc     eax
    inc     esi
    sub     edx, eax
    jz      short loc_4CC114
    jg      short loc_4CC0D8
    mov     eax, edx
    dec     esi
    neg     eax
    jmp     short loc_4CC12D
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC100:                             ; CODE XREF: sub_4CC057+97j
    inc     eax
    add     esi, eax
    sub     edx, eax
    jz      short loc_4CC114
    jg      short loc_4CC0D8
    add     esi, edx
    mov     eax, edx
    neg     eax
    jmp     short loc_4CC175
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC114:                             ; CODE XREF: sub_4CC057+7Fj
                                            ; sub_4CC057+8Bj ...
    or      ebx, ebx
    jle     short loc_4CC0B0

    loc_4CC118:                             ; CODE XREF: sub_4CC057+CFj
    movzx   eax, byte ptr [esi]
    inc     esi
    shr     eax, 1
    jnb     short loc_4CC128

    loc_4CC120:                             ; CODE XREF: sub_4CC057+93j
    add     edi, eax
    sub     ebx, eax
    jle     short loc_4CC0B0
    jmp     short loc_4CC118
    ; ---------------------------------------------------------------------------

    loc_4CC128:                             ; CODE XREF: sub_4CC057+C7j
    shr     eax, 1
    jnb     short loc_4CC174
    inc     eax

    loc_4CC12D:                             ; CODE XREF: sub_4CC057+A6j
    sub     ebx, eax
    jl      short loc_4CC150
    mov     ecx, eax
    xor     edx, edx
    mov     dl, [esi]
    shl     edx, 8
    add     edx, [ebp+arg_14]
    inc     esi

    loc_4CC13E:                             ; CODE XREF: sub_4CC057+F5j
    xor     eax, eax
    mov     al, [edi]
    add     eax, edx
    mov     al, [eax]
    mov     [edi], al
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC13E
    jmp     short loc_4CC114
    ; ---------------------------------------------------------------------------

    loc_4CC150:                             ; CODE XREF: sub_4CC057+D8j
    add     eax, ebx
    mov     ecx, eax
    xor     edx, edx
    mov     dl, [esi]
    shl     edx, 8
    add     edx, [ebp+arg_14]
    inc     esi

    loc_4CC15F:                             ; CODE XREF: sub_4CC057+116j
    xor     eax, eax
    mov     al, [edi]
    add     eax, edx
    mov     al, [eax]
    mov     [edi], al
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC15F
    jmp     short loc_4CC114
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC174:                             ; CODE XREF: sub_4CC057+D3j
    inc     eax

    loc_4CC175:                             ; CODE XREF: sub_4CC057+B8j
    sub     ebx, eax
    jl      short loc_4CC19C
    mov     ecx, eax

    loc_4CC17B:                             ; CODE XREF: sub_4CC057+13Cj
    xor     edx, edx
    xor     eax, eax
    mov     dl, [esi]
    shl     edx, 8
    add     edx, [ebp+arg_14]
    mov     al, [edi]
    mov     al, [edx+eax]
    mov     [edi], al
    inc     esi
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC17B
    jmp     loc_4CC114
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC19C:                             ; CODE XREF: sub_4CC057+120j
    add     eax, ebx
    mov     ecx, eax

    loc_4CC1A0:                             ; CODE XREF: sub_4CC057+161j
    xor     edx, edx
    xor     eax, eax
    mov     dl, [esi]
    shl     edx, 8
    add     edx, [ebp+arg_14]
    mov     al, [edi]
    mov     al, [edx+eax]
    mov     [edi], al
    inc     esi
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC1A0
    jmp     loc_4CC114
    sub_4CC057 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CC1BF proc near                    ; CODE XREF: sub_4B8EC0+1B4p

    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFFCh
    push    ebx
    push    ecx
    push    esi
    push    edi
    push    ebp
    mov     edi, [ebp+arg_0]
    mov     esi, [ebp+arg_C]
    mov     ecx, [ebp+arg_4]
    mov     ebx, [ebp+arg_8]
    mov     eax, [ebx+4]
    imul    ecx
    add     edi, [ebx]
    add     edi, eax
    mov     edx, [ebp+arg_10]
    mov     ebx, [edx+4]
    or      ebx, ebx

    loc_4CC1E7:                             ; CODE XREF: sub_4CC1BF+32j
    jz      short loc_4CC1F4
    movzx   eax, word ptr [esi]
    lea     esi, [eax+esi+2]
    dec     ebx
    jmp     short loc_4CC1E7
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC1F4:                             ; CODE XREF: sub_4CC1BF+28j
    mov     ebx, [edx+0Ch]
    sub     ebx, [edx+4]
    mov     [ebp+var_4], ebx
    mov     ebx, [edx+8]
    jl      short loc_4CC211
    mov     edx, [edx]
    sub     ebx, edx
    inc     ebx
    jle     short loc_4CC211
    jmp     short loc_4CC21D
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC20C:                             ; CODE XREF: sub_4CC1BF+71j
    pop     esi
    pop     edi
    pop     ebx
    pop     ecx
    pop     edx

    loc_4CC211:                             ; CODE XREF: sub_4CC1BF+41j
                                            ; sub_4CC1BF+48j
    pop     ebp
    pop     edi
    pop     esi
    pop     ecx
    pop     ebx
    leave
    retn
    ; ---------------------------------------------------------------------------

    loc_4CC218:                             ; CODE XREF: sub_4CC1BF+7Bj
                                            ; sub_4CC1BF+BFj ...
    pop     esi
    pop     edi
    pop     ebx
    pop     ecx
    pop     edx

    loc_4CC21D:                             ; CODE XREF: sub_4CC1BF+4Aj
    movzx   eax, word ptr [esi]
    push    edx
    push    ecx
    push    ebx
    add     ecx, edi
    push    ecx
    lea     ecx, [eax+esi+2]
    push    ecx
    mov     ecx, [ebp+var_4]
    or      ecx, ecx
    js      short loc_4CC20C
    dec     [ebp+var_4]
    add     esi, 2
    or      eax, eax
    jz      short loc_4CC218
    or      edx, edx
    jle     short loc_4CC27C

    loc_4CC240:                             ; CODE XREF: sub_4CC1BF+8Dj
                                            ; sub_4CC1BF+9Fj ...
    movzx   eax, byte ptr [esi]
    inc     esi
    shr     eax, 1
    jnb     short loc_4CC254
    sub     edx, eax
    jz      short loc_4CC27C
    jg      short loc_4CC240
    mov     eax, edx
    neg     eax
    jmp     short loc_4CC288
    ; ---------------------------------------------------------------------------

    loc_4CC254:                             ; CODE XREF: sub_4CC1BF+87j
    shr     eax, 1
    jnb     short loc_4CC268
    inc     eax
    inc     esi
    sub     edx, eax
    jz      short loc_4CC27C
    jg      short loc_4CC240
    mov     eax, edx
    dec     esi
    neg     eax
    jmp     short loc_4CC295
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC268:                             ; CODE XREF: sub_4CC1BF+97j
    inc     eax
    add     esi, eax
    sub     edx, eax
    jz      short loc_4CC27C
    jg      short loc_4CC240
    add     esi, edx
    mov     eax, edx
    neg     eax
    jmp     short loc_4CC2E1
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC27C:                             ; CODE XREF: sub_4CC1BF+7Fj
                                            ; sub_4CC1BF+8Bj ...
    or      ebx, ebx
    jle     short loc_4CC218

    loc_4CC280:                             ; CODE XREF: sub_4CC1BF+CFj
    movzx   eax, byte ptr [esi]
    inc     esi
    shr     eax, 1
    jnb     short loc_4CC290

    loc_4CC288:                             ; CODE XREF: sub_4CC1BF+93j
    add     edi, eax
    sub     ebx, eax
    jle     short loc_4CC218
    jmp     short loc_4CC280
    ; ---------------------------------------------------------------------------

    loc_4CC290:                             ; CODE XREF: sub_4CC1BF+C7j
    shr     eax, 1
    jnb     short loc_4CC2E0
    inc     eax

    loc_4CC295:                             ; CODE XREF: sub_4CC1BF+A6j
    sub     ebx, eax
    jl      short loc_4CC2BC
    mov     ecx, eax
    xor     edx, edx
    mov     dl, [esi]
    sub     edx, 4Fh
    shl     edx, 8
    add     edx, [ebp+arg_14]
    inc     esi

    loc_4CC2A9:                             ; CODE XREF: sub_4CC1BF+F8j
    xor     eax, eax
    mov     al, [edi]
    add     eax, edx
    mov     al, [eax]
    mov     [edi], al
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC2A9
    jmp     short loc_4CC27C
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC2BC:                             ; CODE XREF: sub_4CC1BF+D8j
    add     eax, ebx
    mov     ecx, eax
    xor     edx, edx
    mov     dl, [esi]
    sub     edx, 4Fh
    shl     edx, 8
    add     edx, [ebp+arg_14]
    inc     esi

    loc_4CC2CE:                             ; CODE XREF: sub_4CC1BF+11Dj
    xor     eax, eax
    mov     al, [edi]
    add     eax, edx
    mov     al, [eax]
    mov     [edi], al
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC2CE
    jmp     short loc_4CC27C
    ; ---------------------------------------------------------------------------

    loc_4CC2E0:                             ; CODE XREF: sub_4CC1BF+D3j
    inc     eax

    loc_4CC2E1:                             ; CODE XREF: sub_4CC1BF+B8j
    sub     ebx, eax
    jl      short loc_4CC30C
    mov     ecx, eax

    loc_4CC2E7:                             ; CODE XREF: sub_4CC1BF+143j
    xor     edx, edx
    xor     eax, eax
    mov     dl, [esi]
    sub     edx, 4Fh
    shl     edx, 8
    add     edx, [ebp+arg_14]
    mov     al, [edi]
    mov     al, [edx+eax]
    mov     [edi], al
    inc     esi
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC2E7
    jmp     loc_4CC27C
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC30C:                             ; CODE XREF: sub_4CC1BF+124j
    add     eax, ebx
    mov     ecx, eax

    loc_4CC310:                             ; CODE XREF: sub_4CC1BF+16Cj
    xor     edx, edx
    xor     eax, eax
    mov     dl, [esi]
    sub     edx, 4Fh
    shl     edx, 8
    add     edx, [ebp+arg_14]
    mov     al, [edi]
    mov     al, [edx+eax]
    mov     [edi], al
    inc     esi
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC310
    jmp     loc_4CC27C
    sub_4CC1BF endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CC332 proc near                    ; CODE XREF: sub_4B8EC0+18Cp

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= byte ptr  18h
    arg_14= dword ptr  1Ch

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFE8h
    push    esi
    push    edi
    push    ebx
    pushf
    cld
    mov     esi, [ebp+arg_8]
    mov     edi, [ebp+arg_C]
    mov     ecx, [esi+8]
    sub     ecx, [esi]
    inc     ecx
    mov     [ebp+var_C], ecx
    mov     eax, [esi+0Ch]
    sub     eax, [esi+4]
    inc     eax
    mov     [ebp+var_10], eax
    mov     eax, [esi+4]
    mov     ebx, [esi]
    mov     esi, [ebp+arg_4]
    mov     ecx, [esi+8]
    mov     [ebp+var_4], ecx
    mov     esi, [esi+0Ch]
    mul     ecx
    add     eax, ebx
    add     esi, eax
    mov     eax, [edi+4]
    mov     ebx, [edi]
    mov     edi, [ebp+arg_0]
    mov     ecx, [edi+8]
    mov     [ebp+var_8], ecx
    mov     edi, [edi+0Ch]
    mul     ecx
    add     eax, ebx
    add     edi, eax
    mov     ecx, [ebp+var_C]
    mov     edx, [ebp+var_4]
    sub     edx, ecx
    mov     [ebp+var_14], edx
    mov     ebx, [ebp+var_8]
    sub     ebx, ecx
    mov     [ebp+var_18], ebx
    mov     edx, [ebp+arg_14]
    xor     eax, eax

    loc_4CC39C:                             ; CODE XREF: sub_4CC332+93j
    mov     ecx, [ebp+var_C]

    loc_4CC39F:                             ; CODE XREF: sub_4CC332+88j
    mov     al, [esi]
    cmp     al, [ebp+arg_10]
    jz      short loc_4CC3B7
    mov     ebx, eax
    sub     ebx, 4Fh
    shl     ebx, 8
    add     ebx, edx
    mov     al, [edi]
    mov     al, [eax+ebx]
    mov     [edi], al

    loc_4CC3B7:                             ; CODE XREF: sub_4CC332+72j
    inc     esi
    inc     edi
    dec     ecx
    jnz     short loc_4CC39F
    add     esi, [ebp+var_14]
    add     edi, [ebp+var_18]
    dec     [ebp+var_10]
    jnz     short loc_4CC39C
    popf
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CC332 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CC3D0 proc near                    ; CODE XREF: sub_4B8310+1BDp

    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFFCh
    push    ebx
    push    ecx
    push    esi
    push    edi
    push    ebp
    mov     edi, [ebp+arg_0]
    mov     esi, [ebp+arg_C]
    mov     ecx, [ebp+arg_4]
    mov     ebx, [ebp+arg_8]
    mov     eax, [ebx+4]
    imul    ecx
    add     edi, [ebx]
    add     edi, eax
    mov     edx, [ebp+arg_10]
    mov     ebx, [edx+4]
    or      ebx, ebx

    loc_4CC3F8:                             ; CODE XREF: sub_4CC3D0+32j
    jz      short loc_4CC404
    movzx   eax, word ptr [esi]
    lea     esi, [eax+esi+2]
    dec     ebx
    jmp     short loc_4CC3F8
    ; ---------------------------------------------------------------------------

    loc_4CC404:                             ; CODE XREF: sub_4CC3D0+28j
    mov     ebx, [edx+0Ch]
    sub     ebx, [edx+4]
    mov     [ebp+var_4], ebx
    mov     ebx, [edx+8]
    jl      short loc_4CC421
    mov     edx, [edx]
    sub     ebx, edx
    inc     ebx
    jle     short loc_4CC421
    jmp     short loc_4CC42D
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC41C:                             ; CODE XREF: sub_4CC3D0+70j
    pop     esi
    pop     edi
    pop     ebx
    pop     ecx
    pop     edx

    loc_4CC421:                             ; CODE XREF: sub_4CC3D0+40j
                                            ; sub_4CC3D0+47j
    pop     ebp
    pop     edi
    pop     esi
    pop     ecx
    pop     ebx
    leave
    retn
    ; ---------------------------------------------------------------------------

    loc_4CC428:                             ; CODE XREF: sub_4CC3D0+7Aj
                                            ; sub_4CC3D0+BEj ...
    pop     esi
    pop     edi
    pop     ebx
    pop     ecx
    pop     edx

    loc_4CC42D:                             ; CODE XREF: sub_4CC3D0+49j
    movzx   eax, word ptr [esi]
    push    edx
    push    ecx
    push    ebx
    add     ecx, edi
    push    ecx
    lea     ecx, [eax+esi+2]
    push    ecx
    mov     ecx, [ebp+var_4]
    or      ecx, ecx
    js      short loc_4CC41C
    dec     [ebp+var_4]
    add     esi, 2
    or      eax, eax
    jz      short loc_4CC428
    or      edx, edx
    jle     short loc_4CC48C

    loc_4CC450:                             ; CODE XREF: sub_4CC3D0+8Cj
                                            ; sub_4CC3D0+9Ej ...
    movzx   eax, byte ptr [esi]
    inc     esi
    shr     eax, 1
    jnb     short loc_4CC464
    sub     edx, eax
    jz      short loc_4CC48C
    jg      short loc_4CC450
    mov     eax, edx
    neg     eax
    jmp     short loc_4CC498
    ; ---------------------------------------------------------------------------

    loc_4CC464:                             ; CODE XREF: sub_4CC3D0+86j
    shr     eax, 1
    jnb     short loc_4CC478
    inc     eax
    inc     esi
    sub     edx, eax
    jz      short loc_4CC48C
    jg      short loc_4CC450
    mov     eax, edx
    dec     esi
    neg     eax
    jmp     short loc_4CC4A5
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC478:                             ; CODE XREF: sub_4CC3D0+96j
    inc     eax
    add     esi, eax
    sub     edx, eax
    jz      short loc_4CC48C
    jg      short loc_4CC450
    add     esi, edx
    mov     eax, edx
    neg     eax
    jmp     short loc_4CC4E1
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC48C:                             ; CODE XREF: sub_4CC3D0+7Ej
                                            ; sub_4CC3D0+8Aj ...
    or      ebx, ebx
    jle     short loc_4CC428

    loc_4CC490:                             ; CODE XREF: sub_4CC3D0+CEj
    movzx   eax, byte ptr [esi]
    inc     esi
    shr     eax, 1
    jnb     short loc_4CC4A0

    loc_4CC498:                             ; CODE XREF: sub_4CC3D0+92j
    add     edi, eax
    sub     ebx, eax
    jle     short loc_4CC428
    jmp     short loc_4CC490
    ; ---------------------------------------------------------------------------

    loc_4CC4A0:                             ; CODE XREF: sub_4CC3D0+C6j
    shr     eax, 1
    jnb     short loc_4CC4E0
    inc     eax

    loc_4CC4A5:                             ; CODE XREF: sub_4CC3D0+A5j
    sub     ebx, eax
    jl      short loc_4CC4C4
    mov     ecx, eax
    xor     edx, edx
    mov     dl, [esi]
    add     edx, [ebp+arg_14]
    xor     eax, eax
    mov     al, [edx]
    inc     esi

    loc_4CC4B7:                             ; CODE XREF: sub_4CC3D0+EDj
    mov     [edi], al
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC4B7
    jmp     short loc_4CC48C
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC4C4:                             ; CODE XREF: sub_4CC3D0+D7j
    add     eax, ebx
    mov     ecx, eax
    xor     edx, edx
    mov     dl, [esi]
    add     edx, [ebp+arg_14]
    xor     eax, eax
    mov     al, [edx]
    inc     esi

    loc_4CC4D4:                             ; CODE XREF: sub_4CC3D0+10Aj
    mov     [edi], al
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC4D4
    jmp     short loc_4CC48C
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC4E0:                             ; CODE XREF: sub_4CC3D0+D2j
    inc     eax

    loc_4CC4E1:                             ; CODE XREF: sub_4CC3D0+B7j
    sub     ebx, eax
    jl      short loc_4CC500
    mov     ecx, eax

    loc_4CC4E7:                             ; CODE XREF: sub_4CC3D0+129j
    xor     edx, edx
    xor     eax, eax
    mov     dl, [esi]
    add     edx, [ebp+arg_14]
    mov     al, [edx]
    mov     [edi], al
    inc     esi
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC4E7
    jmp     short loc_4CC48C
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC500:                             ; CODE XREF: sub_4CC3D0+113j
    add     eax, ebx
    mov     ecx, eax

    loc_4CC504:                             ; CODE XREF: sub_4CC3D0+146j
    xor     edx, edx
    xor     eax, eax
    mov     dl, [esi]
    add     edx, [ebp+arg_14]
    mov     al, [edx]
    mov     [edi], al
    inc     esi
    inc     edi
    sub     ecx, 1
    jnz     short loc_4CC504
    jmp     loc_4CC48C
    sub_4CC3D0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CC51D proc near                    ; CODE XREF: sub_4B7F90+190p
                                            ; sub_4B8150+18Dp

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h

    push    ebp
    mov     ebp, esp
    push    ebx
    push    ecx
    push    esi
    push    edi
    push    ebp
    mov     edi, [ebp+arg_0]
    mov     esi, [ebp+arg_C]
    mov     ecx, [ebp+arg_4]
    mov     ebx, [ebp+arg_8]
    mov     eax, [ebx+4]
    imul    ecx
    add     edi, [ebx]
    add     edi, eax
    mov     edx, [ebp+arg_10]
    mov     ebx, [edx+4]
    or      ebx, ebx

    loc_4CC542:                             ; CODE XREF: sub_4CC51D+2Fj
    jz      short loc_4CC550
    movzx   eax, word ptr [esi]
    lea     esi, [eax+esi+2]
    dec     ebx
    jmp     short loc_4CC542
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC550:                             ; CODE XREF: sub_4CC51D+25j
    mov     ebx, [edx+8]
    mov     ebp, [edx+0Ch]
    sub     ebp, [edx+4]
    jl      short loc_4CC569
    mov     edx, [edx]
    sub     ebx, edx
    inc     ebx
    jle     short loc_4CC569
    jmp     short loc_4CC575
    ; ---------------------------------------------------------------------------

    loc_4CC564:                             ; CODE XREF: sub_4CC51D+68j
    pop     esi
    pop     edi
    pop     ebx
    pop     ecx
    pop     edx

    loc_4CC569:                             ; CODE XREF: sub_4CC51D+3Cj
                                            ; sub_4CC51D+43j
    pop     ebp
    pop     edi
    pop     esi
    pop     ecx
    pop     ebx
    leave
    retn
    ; ---------------------------------------------------------------------------

    loc_4CC570:                             ; CODE XREF: sub_4CC51D+70j
                                            ; sub_4CC51D+B5j ...
    pop     esi
    pop     edi
    pop     ebx
    pop     ecx
    pop     edx

    loc_4CC575:                             ; CODE XREF: sub_4CC51D+45j
    movzx   eax, word ptr [esi]
    push    edx
    push    ecx
    push    ebx
    add     ecx, edi
    push    ecx
    lea     ecx, [eax+esi+2]
    push    ecx
    or      ebp, ebp
    js      short loc_4CC564
    dec     ebp
    add     esi, 2
    or      eax, eax
    jz      short loc_4CC570
    or      edx, edx
    jle     short loc_4CC5D0
    nop

    loc_4CC594:                             ; CODE XREF: sub_4CC51D+83j
                                            ; sub_4CC51D+95j ...
    movzx   eax, byte ptr [esi]
    inc     esi
    shr     eax, 1
    jnb     short loc_4CC5A8
    sub     edx, eax
    jz      short loc_4CC5D0
    jg      short loc_4CC594
    mov     eax, edx
    neg     eax
    jmp     short loc_4CC5DC
    ; ---------------------------------------------------------------------------

    loc_4CC5A8:                             ; CODE XREF: sub_4CC51D+7Dj
    shr     eax, 1
    jnb     short loc_4CC5BC
    inc     eax
    inc     esi
    sub     edx, eax
    jz      short loc_4CC5D0
    jg      short loc_4CC594
    mov     eax, edx
    dec     esi
    neg     eax
    jmp     short loc_4CC5E9
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC5BC:                             ; CODE XREF: sub_4CC51D+8Dj
    inc     eax
    add     esi, eax
    sub     edx, eax
    jz      short loc_4CC5D0
    jg      short loc_4CC594
    add     esi, edx
    mov     eax, edx
    neg     eax
    jmp     short loc_4CC619
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC5D0:                             ; CODE XREF: sub_4CC51D+74j
                                            ; sub_4CC51D+81j ...
    or      ebx, ebx
    jle     short loc_4CC570

    loc_4CC5D4:                             ; CODE XREF: sub_4CC51D+C5j
    movzx   eax, byte ptr [esi]
    inc     esi
    shr     eax, 1
    jnb     short loc_4CC5E4

    loc_4CC5DC:                             ; CODE XREF: sub_4CC51D+89j
    add     edi, eax
    sub     ebx, eax
    jle     short loc_4CC570
    jmp     short loc_4CC5D4
    ; ---------------------------------------------------------------------------

    loc_4CC5E4:                             ; CODE XREF: sub_4CC51D+BDj
    shr     eax, 1
    jnb     short loc_4CC618
    inc     eax

    loc_4CC5E9:                             ; CODE XREF: sub_4CC51D+9Cj
    sub     ebx, eax
    jl      short loc_4CC600
    mov     ecx, eax
    mov     al, [esi]
    inc     esi
    shr     ecx, 1
    mov     ah, al
    rep stosw
    jnb     short loc_4CC5D0
    mov     [edi], al
    inc     edi
    jmp     short loc_4CC5D0
    ; ---------------------------------------------------------------------------

    loc_4CC600:                             ; CODE XREF: sub_4CC51D+CEj
    add     eax, ebx
    mov     ecx, eax
    mov     al, [esi]
    inc     esi
    mov     ah, al
    shr     ecx, 1
    rep stosw
    jnb     short loc_4CC5D0
    mov     [edi], al
    inc     edi
    jmp     short loc_4CC5D0
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC618:                             ; CODE XREF: sub_4CC51D+C9j
    inc     eax

    loc_4CC619:                             ; CODE XREF: sub_4CC51D+AEj
    sub     ebx, eax
    jl      short loc_4CC630
    mov     ecx, eax
    shr     ecx, 1
    rep movsw
    jnb     short loc_4CC5D0
    mov     al, [esi]
    inc     esi
    mov     [edi], al
    inc     edi
    jmp     short loc_4CC5D0
    ; ---------------------------------------------------------------------------
    align 4

    loc_4CC630:                             ; CODE XREF: sub_4CC51D+FEj
    add     eax, ebx
    mov     ecx, eax
    shr     ecx, 1
    rep movsw
    jnb     short loc_4CC5D0
    mov     al, [esi]
    inc     esi
    mov     [edi], al
    inc     edi
    jmp     short loc_4CC5D0
    sub_4CC51D endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CC650 proc near                    ; CODE XREF: sub_4CC7AB+1Cp
                                            ; sub_4CCA33+19p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFF4h
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    mov     esi, [ebp+arg_0]
    mov     edi, [esi]
    mov     esi, [esi+4]
    mov     [ebp+var_C], 1

    loc_4CC66A:                             ; CODE XREF: sub_4CC650+148j
    mov     eax, [ebp+arg_4]
    mov     ebx, [ebp+arg_C]
    mov     ecx, [ebp+arg_8]
    mov     edx, [ebp+arg_10]
    cmp     eax, edi
    jge     short loc_4CC698
    jnb     short loc_4CC698
    cmp     ebx, edi
    jge     short loc_4CC698
    jnb     short loc_4CC698
    cmp     ecx, esi
    jge     short loc_4CC698
    jnb     short loc_4CC698
    cmp     edx, esi
    jge     short loc_4CC698
    jnb     short loc_4CC698
    jmp     loc_4CC79D
    ; ---------------------------------------------------------------------------

    loc_4CC693:                             ; CODE XREF: sub_4CC650+53j
                                            ; sub_4CC650+57j ...
    jmp     loc_4CC7A7
    ; ---------------------------------------------------------------------------

    loc_4CC698:                             ; CODE XREF: sub_4CC650+28j
                                            ; sub_4CC650+2Aj ...
    mov     [ebp+var_4], ebx
    sub     [ebp+var_4], eax
    jns     short loc_4CC6AB
    cmp     eax, 0
    jl      short loc_4CC693
    cmp     ebx, edi
    jge     short loc_4CC693
    jmp     short loc_4CC6B4
    ; ---------------------------------------------------------------------------

    loc_4CC6AB:                             ; CODE XREF: sub_4CC650+4Ej
    cmp     eax, edi
    jge     short loc_4CC693
    cmp     ebx, 0
    jl      short loc_4CC693

    loc_4CC6B4:                             ; CODE XREF: sub_4CC650+59j
    mov     [ebp+var_8], edx
    sub     [ebp+var_8], ecx
    jns     short loc_4CC6C7
    cmp     ecx, 0
    jl      short loc_4CC693
    cmp     edx, esi
    jge     short loc_4CC693
    jmp     short loc_4CC6D0
    ; ---------------------------------------------------------------------------

    loc_4CC6C7:                             ; CODE XREF: sub_4CC650+6Aj
    cmp     ecx, esi
    jge     short loc_4CC693
    cmp     edx, 0
    jl      short loc_4CC693

    loc_4CC6D0:                             ; CODE XREF: sub_4CC650+75j
    cmp     eax, 0
    jge     short loc_4CC6E9
    neg     eax
    imul    [ebp+var_8]
    idiv    [ebp+var_4]
    add     [ebp+arg_8], eax
    mov     [ebp+arg_4], 0
    jmp     short loc_4CC6FF
    ; ---------------------------------------------------------------------------

    loc_4CC6E9:                             ; CODE XREF: sub_4CC650+83j
    sub     eax, edi
    jl      short loc_4CC6FF
    inc     eax
    neg     eax
    imul    [ebp+var_8]
    idiv    [ebp+var_4]
    add     [ebp+arg_8], eax
    mov     [ebp+arg_4], edi
    dec     [ebp+arg_4]

    loc_4CC6FF:                             ; CODE XREF: sub_4CC650+97j
                                            ; sub_4CC650+9Bj
    mov     eax, [ebp+arg_8]
    cmp     eax, 0
    jge     short loc_4CC71B
    neg     eax
    imul    [ebp+var_4]
    idiv    [ebp+var_8]
    add     [ebp+arg_4], eax
    mov     [ebp+arg_8], 0
    jmp     short loc_4CC731
    ; ---------------------------------------------------------------------------

    loc_4CC71B:                             ; CODE XREF: sub_4CC650+B5j
    sub     eax, esi
    jl      short loc_4CC731
    inc     eax
    neg     eax
    imul    [ebp+var_4]
    idiv    [ebp+var_8]
    add     [ebp+arg_4], eax
    mov     [ebp+arg_8], esi
    dec     [ebp+arg_8]

    loc_4CC731:                             ; CODE XREF: sub_4CC650+C9j
                                            ; sub_4CC650+CDj
    mov     eax, [ebp+arg_C]
    cmp     eax, 0
    jge     short loc_4CC74D
    neg     eax
    imul    [ebp+var_8]
    idiv    [ebp+var_4]
    add     [ebp+arg_10], eax
    mov     [ebp+arg_C], 0
    jmp     short loc_4CC763
    ; ---------------------------------------------------------------------------

    loc_4CC74D:                             ; CODE XREF: sub_4CC650+E7j
    sub     eax, edi
    jl      short loc_4CC763
    inc     eax
    neg     eax
    imul    [ebp+var_8]
    idiv    [ebp+var_4]
    add     [ebp+arg_10], eax
    mov     [ebp+arg_C], edi
    dec     [ebp+arg_C]

    loc_4CC763:                             ; CODE XREF: sub_4CC650+FBj
                                            ; sub_4CC650+FFj
    mov     eax, [ebp+arg_10]
    cmp     eax, 0
    jge     short loc_4CC77F
    neg     eax
    imul    [ebp+var_4]
    idiv    [ebp+var_8]
    add     [ebp+arg_C], eax
    mov     [ebp+arg_10], 0
    jmp     short loc_4CC798
    ; ---------------------------------------------------------------------------

    loc_4CC77F:                             ; CODE XREF: sub_4CC650+119j
    sub     eax, esi
    jl      short loc_4CC798
    inc     eax
    neg     eax
    imul    [ebp+var_4]
    idiv    [ebp+var_8]
    add     [ebp+arg_C], eax
    mov     [ebp+arg_10], esi
    dec     [ebp+arg_10]
    inc     [ebp+var_C]

    loc_4CC798:                             ; CODE XREF: sub_4CC650+12Dj
                                            ; sub_4CC650+131j
    jmp     loc_4CC66A
    ; ---------------------------------------------------------------------------

    loc_4CC79D:                             ; CODE XREF: sub_4CC650+3Ej
    mov     eax, [ebp+var_C]

    loc_4CC7A0:                             ; CODE XREF: sub_4CC650+159j
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    ; ---------------------------------------------------------------------------

    loc_4CC7A7:                             ; CODE XREF: sub_4CC650+43j
    xor     eax, eax
    jmp     short loc_4CC7A0
    sub_4CC650 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CC7AB proc near                    ; CODE XREF: sub_4BE950+60p
                                            ; sub_4BE950+B3p ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFF4h
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    pushf
    cld
    push    [ebp+arg_10]
    push    [ebp+arg_C]
    push    [ebp+arg_8]
    push    [ebp+arg_4]
    push    [ebp+arg_0]
    call    sub_4CC650
    pop     [ebp+arg_0]
    pop     [ebp+arg_4]
    pop     [ebp+arg_8]
    pop     [ebp+arg_C]
    pop     [ebp+arg_10]
    or      eax, eax
    jz      loc_4CC8D7
    mov     edi, [ebp+arg_0]
    mov     esi, [edi+8]
    mov     ecx, [ebp+arg_C]
    sub     ecx, [ebp+arg_4]
    jz      short loc_4CC83B
    jns     short loc_4CC807
    neg     ecx
    mov     ebx, [ebp+arg_C]
    xchg    ebx, [ebp+arg_4]
    mov     [ebp+arg_C], ebx
    mov     ebx, [ebp+arg_10]
    xchg    ebx, [ebp+arg_8]
    mov     [ebp+arg_10], ebx

    loc_4CC807:                             ; CODE XREF: sub_4CC7AB+46j
    mov     ebx, [ebp+arg_10]
    sub     ebx, [ebp+arg_8]
    jz      short loc_4CC866
    jns     short loc_4CC815
    neg     ebx
    neg     esi

    loc_4CC815:                             ; CODE XREF: sub_4CC7AB+64j
    push    esi
    mov     [ebp+var_C], offset loc_4CC880
    cmp     ebx, ecx
    jle     short loc_4CC82A
    mov     [ebp+var_C], offset loc_4CC8AC
    xchg    ebx, ecx

    loc_4CC82A:                             ; CODE XREF: sub_4CC7AB+74j
    shl     ebx, 1
    mov     [ebp+var_4], ebx
    sub     ebx, ecx
    mov     esi, ebx
    sub     ebx, ecx
    mov     [ebp+var_8], ebx
    jmp     [ebp+var_C]
    ; ---------------------------------------------------------------------------

    loc_4CC83B:                             ; CODE XREF: sub_4CC7AB+44j
    mov     eax, [ebp+arg_8]
    mov     ebx, [ebp+arg_10]
    mov     ecx, ebx
    sub     ecx, eax
    jge     short loc_4CC84B
    neg     ecx
    mov     eax, ebx

    loc_4CC84B:                             ; CODE XREF: sub_4CC7AB+9Aj
    inc     ecx
    mov     ebx, [edi+0Ch]
    mov     edx, [edi+8]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_4]
    mov     edi, eax
    dec     esi
    mov     eax, [ebp+arg_14]

    loc_4CC85F:                             ; CODE XREF: sub_4CC7AB+B7j
    stosb
    add     edi, esi
    loop    loc_4CC85F
    jmp     short loc_4CC8D7
    ; ---------------------------------------------------------------------------

    loc_4CC866:                             ; CODE XREF: sub_4CC7AB+62j
    mov     ebx, [edi+0Ch]
    mov     eax, [ebp+arg_8]
    mov     edx, [edi+8]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_4]
    mov     edi, eax
    inc     ecx
    mov     eax, [ebp+arg_14]
    rep stosb
    jmp     short loc_4CC8D7
    ; ---------------------------------------------------------------------------

    loc_4CC880:                             ; DATA XREF: sub_4CC7AB+6Bo
    mov     ebx, [edi+0Ch]
    mov     eax, [ebp+arg_8]
    mov     edx, [edi+8]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_4]
    mov     edi, eax
    inc     ecx
    pop     ebx
    mov     eax, [ebp+arg_14]

    loc_4CC897:                             ; CODE XREF: sub_4CC7AB+F4j
                                            ; sub_4CC7AB+FDj
    stosb
    or      esi, esi
    jns     short loc_4CC8A3
    add     esi, [ebp+var_4]
    loop    loc_4CC897
    jmp     short loc_4CC8D7
    ; ---------------------------------------------------------------------------

    loc_4CC8A3:                             ; CODE XREF: sub_4CC7AB+EFj
    add     esi, [ebp+var_8]
    add     edi, ebx
    loop    loc_4CC897
    jmp     short loc_4CC8D7
    ; ---------------------------------------------------------------------------

    loc_4CC8AC:                             ; DATA XREF: sub_4CC7AB+76o
    mov     ebx, [edi+0Ch]
    mov     eax, [ebp+arg_8]
    mov     edx, [edi+8]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_4]
    mov     edi, eax
    inc     ecx
    pop     ebx
    mov     eax, [ebp+arg_14]

    loc_4CC8C3:                             ; CODE XREF: sub_4CC7AB+123j
                                            ; sub_4CC7AB+12Aj
    stosb
    add     edi, ebx
    or      esi, esi
    jns     short loc_4CC8D2
    add     esi, [ebp+var_4]
    dec     edi
    loop    loc_4CC8C3
    jmp     short loc_4CC8D7
    ; ---------------------------------------------------------------------------

    loc_4CC8D2:                             ; CODE XREF: sub_4CC7AB+11Dj
    add     esi, [ebp+var_8]
    loop    loc_4CC8C3

    loc_4CC8D7:                             ; CODE XREF: sub_4CC7AB+32j
                                            ; sub_4CC7AB+B9j ...
    popf
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CC7AB endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CC8DF proc near                    ; CODE XREF: sub_4BEC70+82p
                                            ; sub_4BEC70+DDp ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch
    arg_18= dword ptr  20h

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFF4h
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    pushf
    cld
    mov     edi, [ebp+arg_0]
    mov     esi, [edi+8]
    mov     ecx, [ebp+arg_C]
    sub     ecx, [ebp+arg_4]
    jz      short loc_4CC944
    jns     short loc_4CC910
    neg     ecx
    mov     ebx, [ebp+arg_C]
    xchg    ebx, [ebp+arg_4]
    mov     [ebp+arg_C], ebx
    mov     ebx, [ebp+arg_10]
    xchg    ebx, [ebp+arg_8]
    mov     [ebp+arg_10], ebx

    loc_4CC910:                             ; CODE XREF: sub_4CC8DF+1Bj
    mov     ebx, [ebp+arg_10]
    sub     ebx, [ebp+arg_8]
    jz      short loc_4CC983
    jns     short loc_4CC91E
    neg     ebx
    neg     esi

    loc_4CC91E:                             ; CODE XREF: sub_4CC8DF+39j
    push    esi
    mov     [ebp+var_C], offset loc_4CC9B0
    cmp     ebx, ecx
    jle     short loc_4CC933
    mov     [ebp+var_C], offset loc_4CC9EE
    xchg    ebx, ecx

    loc_4CC933:                             ; CODE XREF: sub_4CC8DF+49j
    shl     ebx, 1
    mov     [ebp+var_4], ebx
    sub     ebx, ecx
    mov     esi, ebx
    sub     ebx, ecx
    mov     [ebp+var_8], ebx
    jmp     [ebp+var_C]
    ; ---------------------------------------------------------------------------

    loc_4CC944:                             ; CODE XREF: sub_4CC8DF+19j
    mov     eax, [ebp+arg_8]
    mov     ebx, [ebp+arg_10]
    mov     ecx, ebx
    sub     ecx, eax
    jge     short loc_4CC954
    neg     ecx
    mov     eax, ebx

    loc_4CC954:                             ; CODE XREF: sub_4CC8DF+6Fj
    inc     ecx
    mov     ebx, [edi+0Ch]
    mov     edx, [edi]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_4]
    mov     edi, eax
    mov     edx, esi
    mov     esi, [ebp+arg_18]
    mov     eax, [ebp+arg_14]
    shl     eax, 8
    add     esi, eax
    xor     eax, eax

    loc_4CC972:                             ; CODE XREF: sub_4CC8DF+9Dj
    mov     al, [edi]
    mov     al, [eax+esi]
    mov     [edi], al
    add     edi, edx
    dec     ecx
    jnz     short loc_4CC972
    jmp     loc_4CCA2B
    ; ---------------------------------------------------------------------------

    loc_4CC983:                             ; CODE XREF: sub_4CC8DF+37j
    mov     ebx, [edi+0Ch]
    mov     eax, [ebp+arg_8]
    mov     edx, [edi+8]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_4]
    mov     edi, eax
    inc     ecx
    mov     eax, [ebp+arg_14]
    mov     esi, [ebp+arg_18]
    shl     eax, 8
    add     esi, eax
    xor     eax, eax

    loc_4CC9A3:                             ; CODE XREF: sub_4CC8DF+CDj
    mov     al, [edi]
    mov     al, [eax+esi]
    mov     [edi], al
    inc     edi
    dec     ecx
    jnz     short loc_4CC9A3
    jmp     short loc_4CCA2B
    ; ---------------------------------------------------------------------------

    loc_4CC9B0:                             ; DATA XREF: sub_4CC8DF+40o
    mov     ebx, [edi+0Ch]
    mov     eax, [ebp+arg_8]
    mov     edx, [edi+8]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_4]
    mov     edi, eax
    inc     ecx
    pop     ebx
    mov     edx, esi
    mov     esi, [ebp+arg_18]
    mov     eax, [ebp+arg_14]
    shl     eax, 8
    add     esi, eax
    xor     eax, eax

    loc_4CC9D3:                             ; CODE XREF: sub_4CC8DF+102j
                                            ; sub_4CC8DF+10Bj
    mov     al, [edi]
    mov     al, [eax+esi]
    mov     [edi], al
    or      edx, edx
    jns     short loc_4CC9E5
    add     edx, [ebp+var_4]
    loop    loc_4CC9D3
    jmp     short loc_4CCA2B
    ; ---------------------------------------------------------------------------

    loc_4CC9E5:                             ; CODE XREF: sub_4CC8DF+FDj
    add     edx, [ebp+var_8]
    add     edi, ebx
    loop    loc_4CC9D3
    jmp     short loc_4CCA2B
    ; ---------------------------------------------------------------------------

    loc_4CC9EE:                             ; DATA XREF: sub_4CC8DF+4Bo
    mov     ebx, [edi+0Ch]
    mov     eax, [ebp+arg_8]
    mov     edx, [edi+8]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_4]
    mov     edi, eax
    inc     ecx
    pop     ebx
    mov     edx, esi
    mov     esi, [ebp+arg_18]
    mov     eax, [ebp+arg_14]
    shl     eax, 8
    add     esi, eax
    xor     eax, eax

    loc_4CCA11:                             ; CODE XREF: sub_4CC8DF+143j
                                            ; sub_4CC8DF+14Aj
    mov     al, [edi]
    mov     al, [eax+esi]
    mov     [edi], al
    add     edi, ebx
    or      edx, edx
    jns     short loc_4CCA26
    add     edx, [ebp+var_4]
    dec     edi
    loop    loc_4CCA11
    jmp     short loc_4CCA2B
    ; ---------------------------------------------------------------------------

    loc_4CCA26:                             ; CODE XREF: sub_4CC8DF+13Dj
    add     edx, [ebp+var_8]
    loop    loc_4CCA11

    loc_4CCA2B:                             ; CODE XREF: sub_4CC8DF+9Fj
                                            ; sub_4CC8DF+CFj ...
    popf
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CC8DF endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CCA33 proc near                    ; CODE XREF: .text:004CCD9Ap
                                            ; .text:004CCDAEp ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFF4h
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    pushf
    cld
    push    [ebp+arg_C]
    push    [ebp+arg_8]
    push    [ebp+arg_4]
    push    [ebp+arg_0]
    call    sub_4CC650
    pop     [ebp+arg_0]
    pop     [ebp+arg_4]
    pop     [ebp+arg_8]
    pop     [ebp+arg_C]
    or      eax, eax
    jz      loc_4CCB5D
    movzx   esi, word ptr [edi]
    mov     ecx, [ebp+arg_8]
    sub     ecx, [ebp+arg_0]
    jz      short loc_4CCABA
    jns     short loc_4CCA86
    neg     ecx
    mov     ebx, [ebp+arg_8]
    xchg    ebx, [ebp+arg_0]
    mov     [ebp+arg_8], ebx
    mov     ebx, [ebp+arg_C]
    xchg    ebx, [ebp+arg_4]
    mov     [ebp+arg_C], ebx

    loc_4CCA86:                             ; CODE XREF: sub_4CCA33+3Dj
    mov     ebx, [ebp+arg_C]
    sub     ebx, [ebp+arg_4]
    jz      short loc_4CCAE5
    jns     short loc_4CCA94
    neg     ebx
    neg     esi

    loc_4CCA94:                             ; CODE XREF: sub_4CCA33+5Bj
    push    esi
    mov     [ebp+var_C], offset loc_4CCB02
    cmp     ebx, ecx
    jle     short loc_4CCAA9
    mov     [ebp+var_C], offset loc_4CCB30
    xchg    ebx, ecx

    loc_4CCAA9:                             ; CODE XREF: sub_4CCA33+6Bj
    shl     ebx, 1
    mov     [ebp+var_4], ebx
    sub     ebx, ecx
    mov     esi, ebx
    sub     ebx, ecx
    mov     [ebp+var_8], ebx
    jmp     [ebp+var_C]
    ; ---------------------------------------------------------------------------

    loc_4CCABA:                             ; CODE XREF: sub_4CCA33+3Bj
    mov     eax, [ebp+arg_4]
    mov     ebx, [ebp+arg_C]
    mov     ecx, ebx
    sub     ecx, eax
    jge     short loc_4CCACA
    neg     ecx
    mov     eax, ebx

    loc_4CCACA:                             ; CODE XREF: sub_4CCA33+91j
    inc     ecx
    mov     ebx, [edi+4]
    movzx   edx, word ptr [edi]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_0]
    mov     edi, eax
    mov     eax, [ebp+arg_10]

    loc_4CCADD:                             ; CODE XREF: sub_4CCA33+AEj
    xor     [edi], al
    add     edi, esi
    loop    loc_4CCADD
    jmp     short loc_4CCB5D
    ; ---------------------------------------------------------------------------

    loc_4CCAE5:                             ; CODE XREF: sub_4CCA33+59j
    mov     ebx, [edi+4]
    mov     eax, [ebp+arg_4]
    movzx   edx, word ptr [edi]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_0]
    mov     edi, eax
    inc     ecx
    mov     eax, [ebp+arg_10]

    loc_4CCAFB:                             ; CODE XREF: sub_4CCA33+CBj
    xor     [edi], al
    inc     edi
    loop    loc_4CCAFB
    jmp     short loc_4CCB5D
    ; ---------------------------------------------------------------------------

    loc_4CCB02:                             ; DATA XREF: sub_4CCA33+62o
    mov     ebx, [edi+4]
    mov     eax, [ebp+arg_4]
    movzx   edx, word ptr [edi]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_0]
    mov     edi, eax
    inc     ecx
    pop     ebx
    mov     eax, [ebp+arg_10]

    loc_4CCB19:                             ; CODE XREF: sub_4CCA33+F0j
                                            ; sub_4CCA33+F9j
    xor     [edi], al
    inc     edi
    or      esi, esi
    jns     short loc_4CCB27
    add     esi, [ebp+var_4]
    loop    loc_4CCB19
    jmp     short loc_4CCB5D
    ; ---------------------------------------------------------------------------

    loc_4CCB27:                             ; CODE XREF: sub_4CCA33+EBj
    add     esi, [ebp+var_8]
    add     edi, ebx
    loop    loc_4CCB19
    jmp     short loc_4CCB5D
    ; ---------------------------------------------------------------------------

    loc_4CCB30:                             ; DATA XREF: sub_4CCA33+6Do
    mov     ebx, [edi+4]
    mov     eax, [ebp+arg_4]
    movzx   edx, word ptr [edi]
    mul     edx
    add     eax, ebx
    add     eax, [ebp+arg_0]
    mov     edi, eax
    inc     ecx
    pop     ebx
    inc     ebx
    mov     eax, [ebp+arg_10]

    loc_4CCB48:                             ; CODE XREF: sub_4CCA33+121j
                                            ; sub_4CCA33+128j
    xor     [edi], al
    add     edi, ebx
    or      esi, esi
    jns     short loc_4CCB58
    add     esi, [ebp+var_4]
    dec     edi
    loop    loc_4CCB48
    jmp     short loc_4CCB5D
    ; ---------------------------------------------------------------------------

    loc_4CCB58:                             ; CODE XREF: sub_4CCA33+11Bj
    add     esi, [ebp+var_8]
    loop    loc_4CCB48

    loc_4CCB5D:                             ; CODE XREF: sub_4CCA33+2Cj
                                            ; sub_4CCA33+B0j ...
    popf
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CCA33 endp

    ; ---------------------------------------------------------------------------
    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFF4h
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    movzx   edi, word ptr [esi]
    movzx   esi, word ptr [esi+2]
    mov     dword ptr [ebp-0Ch], 1

    loc_4CCB7E:                             ; CODE XREF: .text:004CCD09j
    mov     ebx, [ebp+8]
    mov     eax, [ebx]
    cmp     eax, edi
    jge     short loc_4CCBAE
    jnb     short loc_4CCBAE
    mov     eax, [ebx+8]
    cmp     eax, edi
    jge     short loc_4CCBAE
    jnb     short loc_4CCBAE
    mov     eax, [ebx+4]
    cmp     eax, esi
    jge     short loc_4CCBAE
    jnb     short loc_4CCBAE
    mov     eax, [ebx+0Ch]
    cmp     eax, esi
    jge     short loc_4CCBAE
    jnb     short loc_4CCBAE
    jmp     loc_4CCD0E
    ; ---------------------------------------------------------------------------

    loc_4CCBA9:                             ; CODE XREF: .text:004CCBBDj
                                            ; .text:004CCBC2j ...
    jmp     loc_4CCD18
    ; ---------------------------------------------------------------------------

    loc_4CCBAE:                             ; CODE XREF: .text:004CCB85j
                                            ; .text:004CCB87j ...
    mov     eax, [ebx+8]
    sub     eax, [ebx]
    mov     [ebp-4], eax
    jns     short loc_4CCBC6
    mov     eax, [ebx]
    cmp     eax, 0
    jl      short loc_4CCBA9
    cmp     [ebx+8], edi
    jge     short loc_4CCBA9
    jmp     short loc_4CCBD0
    ; ---------------------------------------------------------------------------

    loc_4CCBC6:                             ; CODE XREF: .text:004CCBB6j
    cmp     [ebx], edi
    jge     short loc_4CCBA9
    cmp     dword ptr [ebx+8], 0
    jl      short loc_4CCBA9

    loc_4CCBD0:                             ; CODE XREF: .text:004CCBC4j
    mov     eax, [ebx+0Ch]
    sub     eax, [ebx+4]
    mov     [ebp-8], eax
    jns     short loc_4CCBE8
    cmp     dword ptr [ebx+4], 0
    jl      short loc_4CCBA9
    cmp     [ebx+0Ch], esi
    jge     short loc_4CCBA9
    jmp     short loc_4CCBF4
    ; ---------------------------------------------------------------------------

    loc_4CCBE8:                             ; CODE XREF: .text:004CCBD9j
    cmp     [ebx+4], esi
    jge     short loc_4CCBA9
    cmp     word ptr [ebx+0Ch], 0
    jl      short loc_4CCBA9

    loc_4CCBF4:                             ; CODE XREF: .text:004CCBE6j
    mov     eax, [ebx]
    cmp     eax, 0
    jge     short loc_4CCC18
    neg     eax
    imul    dword ptr [ebp-8]
    cmp     dword ptr [ebp-4], 0
    jnz     short loc_4CCC0A
    xor     eax, eax
    jmp     short loc_4CCC0D
    ; ---------------------------------------------------------------------------

    loc_4CCC0A:                             ; CODE XREF: .text:004CCC04j
    idiv    dword ptr [ebp-4]

    loc_4CCC0D:                             ; CODE XREF: .text:004CCC08j
    add     [ebx+4], eax
    mov     dword ptr [ebx], 0
    jmp     short loc_4CCC36
    ; ---------------------------------------------------------------------------

    loc_4CCC18:                             ; CODE XREF: .text:004CCBF9j
    sub     eax, edi
    jl      short loc_4CCC36
    inc     eax
    neg     eax
    imul    dword ptr [ebp-8]
    cmp     dword ptr [ebp-4], 0
    jnz     short loc_4CCC2C
    xor     eax, eax
    jmp     short loc_4CCC2F
    ; ---------------------------------------------------------------------------

    loc_4CCC2C:                             ; CODE XREF: .text:004CCC26j
    idiv    dword ptr [ebp-4]

    loc_4CCC2F:                             ; CODE XREF: .text:004CCC2Aj
    add     [ebx+4], eax
    mov     [ebx], edi
    dec     dword ptr [ebx]

    loc_4CCC36:                             ; CODE XREF: .text:004CCC16j
                                            ; .text:004CCC1Aj
    mov     eax, [ebx+4]
    cmp     eax, 0
    jge     short loc_4CCC5B
    neg     eax
    imul    dword ptr [ebp-4]
    cmp     dword ptr [ebp-8], 0
    jnz     short loc_4CCC4D
    xor     eax, eax
    jmp     short loc_4CCC50
    ; ---------------------------------------------------------------------------

    loc_4CCC4D:                             ; CODE XREF: .text:004CCC47j
    idiv    dword ptr [ebp-8]

    loc_4CCC50:                             ; CODE XREF: .text:004CCC4Bj
    add     [ebx], eax
    mov     dword ptr [ebx+4], 0
    jmp     short loc_4CCC7A
    ; ---------------------------------------------------------------------------

    loc_4CCC5B:                             ; CODE XREF: .text:004CCC3Cj
    sub     eax, esi
    jl      short loc_4CCC7A
    inc     eax
    neg     eax
    imul    dword ptr [ebp-4]
    cmp     dword ptr [ebp-8], 0
    jnz     short loc_4CCC6F
    xor     eax, eax
    jmp     short loc_4CCC72
    ; ---------------------------------------------------------------------------

    loc_4CCC6F:                             ; CODE XREF: .text:004CCC69j
    idiv    dword ptr [ebp-8]

    loc_4CCC72:                             ; CODE XREF: .text:004CCC6Dj
    add     [ebx], eax
    mov     [ebx+4], esi
    dec     dword ptr [ebx+4]

    loc_4CCC7A:                             ; CODE XREF: .text:004CCC59j
                                            ; .text:004CCC5Dj
    mov     eax, [ebx+8]
    cmp     eax, 0
    jge     short loc_4CCCA0
    neg     eax
    imul    dword ptr [ebp-8]
    cmp     dword ptr [ebp-4], 0
    jnz     short loc_4CCC91
    xor     eax, eax
    jmp     short loc_4CCC94
    ; ---------------------------------------------------------------------------

    loc_4CCC91:                             ; CODE XREF: .text:004CCC8Bj
    idiv    dword ptr [ebp-4]

    loc_4CCC94:                             ; CODE XREF: .text:004CCC8Fj
    add     [ebx+0Ch], eax
    mov     dword ptr [ebx+8], 0
    jmp     short loc_4CCCC0
    ; ---------------------------------------------------------------------------

    loc_4CCCA0:                             ; CODE XREF: .text:004CCC80j
    sub     eax, edi
    jl      short loc_4CCCC0
    inc     eax
    neg     eax
    imul    dword ptr [ebp-8]
    cmp     dword ptr [ebp-4], 0
    jnz     short loc_4CCCB4
    xor     eax, eax
    jmp     short loc_4CCCB7
    ; ---------------------------------------------------------------------------

    loc_4CCCB4:                             ; CODE XREF: .text:004CCCAEj
    idiv    dword ptr [ebp-4]

    loc_4CCCB7:                             ; CODE XREF: .text:004CCCB2j
    add     [ebx+0Ch], eax
    mov     [ebx+8], edi
    dec     dword ptr [ebx+8]

    loc_4CCCC0:                             ; CODE XREF: .text:004CCC9Ej
                                            ; .text:004CCCA2j
    mov     eax, [ebx+0Ch]
    cmp     eax, 0
    jge     short loc_4CCCE6
    neg     eax
    imul    dword ptr [ebp-4]
    cmp     dword ptr [ebp-8], 0
    jnz     short loc_4CCCD7
    xor     eax, eax
    jmp     short loc_4CCCDA
    ; ---------------------------------------------------------------------------

    loc_4CCCD7:                             ; CODE XREF: .text:004CCCD1j
    idiv    dword ptr [ebp-8]

    loc_4CCCDA:                             ; CODE XREF: .text:004CCCD5j
    add     [ebx+8], eax
    mov     dword ptr [ebx+0Ch], 0
    jmp     short loc_4CCD09
    ; ---------------------------------------------------------------------------

    loc_4CCCE6:                             ; CODE XREF: .text:004CCCC6j
    sub     eax, esi
    jl      short loc_4CCD09
    inc     eax
    neg     eax
    imul    dword ptr [ebp-4]
    cmp     dword ptr [ebp-8], 0
    jnz     short loc_4CCCFA
    xor     eax, eax
    jmp     short loc_4CCCFD
    ; ---------------------------------------------------------------------------

    loc_4CCCFA:                             ; CODE XREF: .text:004CCCF4j
    idiv    dword ptr [ebp-8]

    loc_4CCCFD:                             ; CODE XREF: .text:004CCCF8j
    add     [ebx+8], eax
    mov     [ebx+0Ch], esi
    dec     dword ptr [ebx+0Ch]
    inc     dword ptr [ebp-0Ch]

    loc_4CCD09:                             ; CODE XREF: .text:004CCCE4j
                                            ; .text:004CCCE8j
    jmp     loc_4CCB7E
    ; ---------------------------------------------------------------------------

    loc_4CCD0E:                             ; CODE XREF: .text:004CCBA4j
    mov     eax, [ebp-0Ch]

    loc_4CCD11:                             ; CODE XREF: .text:004CCD1Aj
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    ; ---------------------------------------------------------------------------

    loc_4CCD18:                             ; CODE XREF: .text:004CCBA9j
    xor     eax, eax
    jmp     short loc_4CCD11
    ; ---------------------------------------------------------------------------
    push    ebp
    mov     ebp, esp
    push    esi
    mov     esi, [ebp+0Ch]
    push    dword ptr [ebp+10h]
    push    dword ptr [esi+4]
    push    dword ptr [esi+8]
    push    dword ptr [esi+4]
    push    dword ptr [esi]
    push    dword ptr [ebp+8]
    call    sub_4CC7AB
    add     sp, 14h
    push    dword ptr [esi+0Ch]
    push    dword ptr [esi+8]
    push    dword ptr [esi+0Ch]
    push    dword ptr [esi]
    push    dword ptr [ebp+8]
    call    sub_4CC7AB
    add     sp, 14h
    push    dword ptr [esi+0Ch]
    push    dword ptr [esi]
    push    dword ptr [esi+4]
    push    dword ptr [esi]
    push    dword ptr [ebp+8]
    call    sub_4CC7AB
    add     sp, 14h
    push    dword ptr [esi+0Ch]
    push    dword ptr [esi+8]
    push    dword ptr [esi+4]
    push    dword ptr [esi+8]
    push    dword ptr [ebp+8]
    call    sub_4CC7AB
    add     sp, 18h
    pop     esi
    leave
    retn
    ; ---------------------------------------------------------------------------
    push    ebp
    mov     ebp, esp
    push    esi
    mov     esi, [ebp+8]
    push    dword ptr [ebp+0Ch]
    push    dword ptr [esi+4]
    push    dword ptr [esi+8]
    push    dword ptr [esi+4]
    push    dword ptr [esi]
    call    sub_4CCA33
    add     sp, 10h
    push    dword ptr [esi+0Ch]
    push    dword ptr [esi+8]
    push    dword ptr [esi+0Ch]
    push    dword ptr [esi]
    call    sub_4CCA33
    add     sp, 10h
    mov     eax, [esi+0Ch]
    dec     eax
    push    eax
    push    dword ptr [esi]
    mov     eax, [esi+4]
    inc     eax
    push    eax
    push    dword ptr [esi]
    call    sub_4CCA33
    add     sp, 10h
    mov     eax, [esi+0Ch]
    dec     eax
    push    eax
    push    dword ptr [esi+8]
    mov     eax, [esi+4]
    inc     eax
    push    eax
    push    dword ptr [esi+8]
    call    sub_4CCA33
    add     sp, 14h
    pop     esi
    leave
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CCDEA proc near                    ; CODE XREF: sub_4BF6F0+64p
                                            ; sub_4BF6F0+A0p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= byte ptr  10h

    push    ebp
    mov     ebp, esp
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    mov     esi, [ebp+arg_4]
    mov     edi, [ebp+arg_0]
    mov     ebx, [esi+8]
    mov     eax, [esi]
    inc     ebx
    and     eax, 3
    and     ebx, 3
    add     eax, ebx
    jnz     short loc_4CCE4C
    mov     ecx, [edi+8]
    mov     eax, [esi+4]
    mov     ebx, [edi+0Ch]
    mul     ecx
    add     eax, ebx
    mov     ebx, [esi]
    add     eax, ebx
    mov     edi, eax
    mov     edx, [esi+8]
    sub     edx, ebx
    inc     edx
    sub     ecx, edx
    mov     ebx, ecx
    mov     eax, [esi+0Ch]
    sub     eax, [esi+4]
    mov     esi, eax
    mov     al, [ebp+arg_8]
    mov     ah, al
    bswap   eax
    mov     al, [ebp+arg_8]
    mov     ah, al

    loc_4CCE39:                             ; CODE XREF: sub_4CCDEA+59j
    mov     ecx, edx
    shr     ecx, 2
    rep stosd
    add     edi, ebx
    dec     esi
    jns     short loc_4CCE39
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    ; ---------------------------------------------------------------------------

    loc_4CCE4C:                             ; CODE XREF: sub_4CCDEA+1Cj
    pushf
    cld
    mov     ecx, [edi+8]
    mov     eax, [esi+4]
    mov     ebx, [edi+0Ch]
    mul     ecx
    add     eax, ebx
    mov     ebx, [esi]
    add     eax, ebx
    mov     edi, eax
    mov     edx, [esi+8]
    sub     edx, ebx
    inc     edx
    sub     ecx, edx
    mov     ebx, ecx
    mov     eax, [esi+0Ch]
    sub     eax, [esi+4]
    mov     esi, eax
    mov     eax, dword ptr [ebp+arg_8]

    loc_4CCE76:                             ; CODE XREF: sub_4CCDEA+93j
    mov     ecx, edx
    rep stosb
    add     edi, ebx
    dec     esi
    jns     short loc_4CCE76
    popf
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CCDEA endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CCE87 proc near                    ; CODE XREF: .text:004BFDBDp
                                            ; .text:004BFDF2p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebp
    mov     ebp, esp
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    pushf
    cld
    mov     esi, [ebp+arg_4]
    mov     edi, [ebp+arg_0]
    movzx   ecx, word ptr [edi]
    mov     eax, [esi+4]
    mul     cx
    mov     ebx, [edi+4]
    add     eax, ebx
    mov     ebx, [esi]
    add     eax, ebx
    mov     edi, eax
    mov     edx, [esi+8]
    sub     edx, ebx
    inc     edx
    sub     ecx, edx
    mov     ebx, ecx
    mov     eax, [esi+0Ch]
    sub     eax, [esi+4]
    mov     esi, eax
    mov     eax, [ebp+arg_8]

    loc_4CCEC0:                             ; CODE XREF: sub_4CCE87+44j
    mov     ecx, edx

    loc_4CCEC2:                             ; CODE XREF: sub_4CCE87+3Fj
    xor     [edi], al
    inc     edi
    dec     ecx
    jnz     short loc_4CCEC2
    add     edi, ebx
    dec     esi
    jns     short loc_4CCEC0
    popf
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CCE87 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CCED5 proc near                    ; CODE XREF: sub_4BFE10+9Cp
                                            ; sub_4BFE10+F5p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h

    push    ebp
    mov     ebp, esp
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    mov     eax, [ebp+arg_0]
    mov     ebx, [ebp+arg_8]
    and     eax, 3
    and     ebx, 3
    add     eax, ebx
    jnz     short loc_4CCF32
    mov     eax, [ebp+arg_10]
    mov     ebx, [ebp+arg_0]
    mov     esi, eax
    mov     edi, ebx
    xor     eax, eax

    loc_4CCEF9:                             ; CODE XREF: sub_4CCED5+54j
    mov     ecx, [ebp+arg_8]

    loc_4CCEFC:                             ; CODE XREF: sub_4CCED5+4Cj
    mov     edx, [ecx+edi-4]
    mov     al, dl
    mov     bl, [eax+esi]
    mov     al, dh
    bswap   edx
    mov     bh, [eax+esi]
    mov     al, dl
    bswap   ebx
    mov     bl, [eax+esi]
    mov     al, dh
    mov     bh, [eax+esi]
    bswap   ebx
    mov     [ecx+edi-4], ebx
    sub     ecx, 4
    jnz     short loc_4CCEFC
    add     edi, [ebp+arg_4]
    dec     [ebp+arg_C]
    jnz     short loc_4CCEF9
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    ; ---------------------------------------------------------------------------

    loc_4CCF32:                             ; CODE XREF: sub_4CCED5+16j
    mov     eax, [ebp+arg_10]
    mov     ebx, [ebp+arg_0]
    mov     esi, eax
    mov     edi, ebx
    xor     eax, eax
    mov     edx, [ebp+arg_C]

    loc_4CCF41:                             ; CODE XREF: sub_4CCED5+81j
    mov     ecx, [ebp+arg_8]

    loc_4CCF44:                             ; CODE XREF: sub_4CCED5+7Bj
    mov     al, [ecx+edi-1]
    mov     bl, [eax+esi]
    mov     [ecx+edi-1], bl
    dec     ecx
    jnz     short loc_4CCF44
    add     edi, [ebp+arg_4]
    dec     edx
    jnz     short loc_4CCF41
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CCED5 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CCF60 proc near                    ; CODE XREF: PrintGUIText+1E4p
                                            ; PrintGUIText+254p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch
    arg_18= byte ptr  20h
    arg_1C= byte ptr  24h
    arg_20= byte ptr  28h

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFF0h
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    mov     edi, [ebp+arg_0]
    mov     esi, [ebp+arg_8]
    movzx   eax, byte ptr [esi]
    mov     [ebp+var_10], eax
    movzx   eax, byte ptr [esi+3]
    mov     [ebp+var_8], eax
    mov     eax, [ebp+arg_14]
    mov     cl, [esi+2]
    movsx   ebx, cl
    sub     eax, ebx
    mul     [ebp+arg_4]
    add     edi, eax
    add     edi, [ebp+arg_10]

    loc_4CCF91:                             ; CODE XREF: sub_4CCF60+4Dj
                                            ; sub_4CCF60+5Bj ...
    mov     [ebp+var_C], edi
    mov     edi, [ebp+arg_C]
    mov     al, [edi]
    mov     edi, [ebp+var_C]
    or      al, al
    jz      short loc_4CD008
    cmp     al, 0Ah
    jz      short loc_4CD008
    movzx   ebx, al
    inc     [ebp+arg_C]
    sub     ebx, [ebp+var_8]
    jb      short loc_4CCF91
    shl     ebx, 1
    add     ebx, 4
    add     ebx, esi
    movzx   ebx, word ptr [ebx]
    or      ebx, ebx
    jz      short loc_4CCF91
    add     ebx, esi
    mov     cl, [ebx]
    inc     ebx
    mov     eax, [ebp+var_10]
    mov     [ebp+var_4], eax
    mov     dl, 1

    loc_4CCFCA:                             ; CODE XREF: sub_4CCF60+A6j
    mov     ch, cl

    loc_4CCFCC:                             ; CODE XREF: sub_4CCF60+8Dj
    dec     dl
    jnz     short loc_4CCFD5
    mov     dh, [ebx]
    inc     ebx
    mov     dl, 8

    loc_4CCFD5:                             ; CODE XREF: sub_4CCF60+6Ej
    mov     al, [ebp+arg_18]
    mov     ah, [ebp+arg_20]
    shl     dh, 1
    jb      short loc_4CCFE2
    mov     al, [ebp+arg_1C]

    loc_4CCFE2:                             ; CODE XREF: sub_4CCF60+7Dj
    cmp     al, ah
    jz      short loc_4CCFE8
    mov     [edi], al

    loc_4CCFE8:                             ; CODE XREF: sub_4CCF60+84j
    inc     edi
    dec     ch
    jz      short loc_4CCFEF
    jmp     short loc_4CCFCC
    ; ---------------------------------------------------------------------------

    loc_4CCFEF:                             ; CODE XREF: sub_4CCF60+8Bj
    add     edi, [ebp+arg_4]
    dec     [ebp+var_4]
    jnz     short loc_4CD001
    mov     edi, [ebp+var_C]
    movzx   eax, cl
    add     edi, eax
    jmp     short loc_4CCF91
    ; ---------------------------------------------------------------------------

    loc_4CD001:                             ; CODE XREF: sub_4CCF60+95j
    movzx   eax, cl
    sub     edi, eax
    jmp     short loc_4CCFCA
    ; ---------------------------------------------------------------------------

    loc_4CD008:                             ; CODE XREF: sub_4CCF60+3Ej
                                            ; sub_4CCF60+42j
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CCF60 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFE8h
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    pushf
    cld
    mov     esi, [ebp+0Ch]
    mov     eax, [esi+8]
    mov     [ebp-4], eax
    mov     esi, [esi+0Ch]
    mov     edi, [ebp+8]
    mov     ecx, [ebp+20h]
    mov     eax, [ebp+18h]
    sub     eax, [ebp+10h]
    jz      loc_4CD65F
    jns     short loc_4CD06E
    neg     eax
    inc     eax
    mov     ebx, [ebp+1Ch]
    sub     ebx, [ebp+14h]
    jz      loc_4CD797
    jns     short loc_4CD05F
    neg     ebx
    inc     ebx
    cmp     eax, ebx
    jns     short loc_4CD05A
    jmp     loc_4CD5A5
    ; ---------------------------------------------------------------------------

    loc_4CD05A:                             ; CODE XREF: .text:004CD053j
    jmp     loc_4CD4EB
    ; ---------------------------------------------------------------------------

    loc_4CD05F:                             ; CODE XREF: .text:004CD04Cj
    inc     ebx
    cmp     eax, ebx
    jns     short loc_4CD069
    jmp     loc_4CD377
    ; ---------------------------------------------------------------------------

    loc_4CD069:                             ; CODE XREF: .text:004CD062j
    jmp     loc_4CD431
    ; ---------------------------------------------------------------------------

    loc_4CD06E:                             ; CODE XREF: .text:004CD03Bj
    inc     eax
    mov     ebx, [ebp+1Ch]
    sub     ebx, [ebp+14h]
    jz      loc_4CD81C
    jns     short loc_4CD08B
    neg     ebx
    inc     ebx
    cmp     eax, ebx
    jns     short loc_4CD086
    jmp     short loc_4CD09A
    ; ---------------------------------------------------------------------------

    loc_4CD086:                             ; CODE XREF: .text:004CD082j
    jmp     loc_4CD149
    ; ---------------------------------------------------------------------------

    loc_4CD08B:                             ; CODE XREF: .text:004CD07Bj
    inc     ebx
    cmp     eax, ebx
    jns     short loc_4CD095
    jmp     loc_4CD2BD
    ; ---------------------------------------------------------------------------

    loc_4CD095:                             ; CODE XREF: .text:004CD08Ej
    jmp     loc_4CD203
    ; ---------------------------------------------------------------------------

    loc_4CD09A:                             ; CODE XREF: .text:004CD084j
    cmp     ecx, ebx
    jle     short loc_4CD0E6
    cmp     ecx, eax
    jle     short loc_4CD0E4
    mov     [ebp-14h], eax
    mov     [ebp-18h], ebx
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    mov     ebx, ecx
    mov     edx, ecx

    loc_4CD0B7:                             ; CODE XREF: .text:004CD0D1j
                                            ; .text:004CD0D7j ...
    mov     al, [esi]

    loc_4CD0B9:                             ; CODE XREF: .text:004CD0DCj
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    sub     ebx, [ebp-18h]
    jnb     short loc_4CD0D9
    sub     esi, [ebp-4]
    add     ebx, [ebp+20h]
    sub     edx, [ebp-14h]
    jnb     short loc_4CD0B7
    inc     esi
    add     edx, [ebp+20h]
    jmp     short loc_4CD0B7
    ; ---------------------------------------------------------------------------

    loc_4CD0D9:                             ; CODE XREF: .text:004CD0C6j
    sub     edx, [ebp-14h]
    jnb     short loc_4CD0B9
    inc     esi
    add     edx, [ebp+20h]
    jmp     short loc_4CD0B7
    ; ---------------------------------------------------------------------------

    loc_4CD0E4:                             ; CODE XREF: .text:004CD0A0j
    jmp     short loc_4CD0EC
    ; ---------------------------------------------------------------------------

    loc_4CD0E6:                             ; CODE XREF: .text:004CD09Cj
    cmp     ecx, eax
    jle     short loc_4CD0EC
    jmp     short $+2

    loc_4CD0EC:                             ; CODE XREF: .text:004CD0E4j
                                            ; .text:004CD0E8j
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-8], edx
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, ebx
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-0Ch], edx
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    sub     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD12A:                             ; CODE XREF: .text:004CD147j
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     esi, [ebp-10h]
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD141
    sub     esi, [ebp-4]

    loc_4CD141:                             ; CODE XREF: .text:004CD13Cj
    add     edx, [ebp-8]
    adc     esi, 0
    jmp     short loc_4CD12A
    ; ---------------------------------------------------------------------------

    loc_4CD149:                             ; CODE XREF: .text:004CD086j
    cmp     ecx, ebx
    jle     short loc_4CD1A0
    cmp     ecx, eax
    jle     short loc_4CD19E
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-8], eax
    mov     edx, ebx
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-0Ch], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD17A:                             ; CODE XREF: .text:004CD194j
                                            ; .text:004CD19Cj
    mov     al, [esi]

    loc_4CD17C:                             ; CODE XREF: .text:004CD199j
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD196
    sub     esi, [ebp-4]
    add     edx, [ebp-8]
    adc     esi, 0
    jmp     short loc_4CD17A
    ; ---------------------------------------------------------------------------

    loc_4CD196:                             ; CODE XREF: .text:004CD189j
    add     edx, [ebp-8]
    jnb     short loc_4CD17C
    inc     esi
    jmp     short loc_4CD17A
    ; ---------------------------------------------------------------------------

    loc_4CD19E:                             ; CODE XREF: .text:004CD14Fj
    jmp     short loc_4CD1A6
    ; ---------------------------------------------------------------------------

    loc_4CD1A0:                             ; CODE XREF: .text:004CD14Bj
    cmp     ecx, eax
    jle     short loc_4CD1A6
    jmp     short $+2

    loc_4CD1A6:                             ; CODE XREF: .text:004CD19Ej
                                            ; .text:004CD1A2j
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-8], edx
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, ebx
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-0Ch], edx
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    sub     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD1E4:                             ; CODE XREF: .text:004CD201j
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     esi, [ebp-10h]
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD1FB
    sub     esi, [ebp-4]

    loc_4CD1FB:                             ; CODE XREF: .text:004CD1F6j
    add     edx, [ebp-8]
    adc     esi, 0
    jmp     short loc_4CD1E4
    ; ---------------------------------------------------------------------------

    loc_4CD203:                             ; CODE XREF: .text:004CD095j
    cmp     ecx, ebx
    jle     short loc_4CD25A
    cmp     ecx, eax
    jle     short loc_4CD258
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-8], eax
    mov     edx, ebx
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-0Ch], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD234:                             ; CODE XREF: .text:004CD24Ej
                                            ; .text:004CD256j
    mov     al, [esi]

    loc_4CD236:                             ; CODE XREF: .text:004CD253j
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD250
    add     esi, [ebp-4]
    add     edx, [ebp-8]
    adc     esi, 0
    jmp     short loc_4CD234
    ; ---------------------------------------------------------------------------

    loc_4CD250:                             ; CODE XREF: .text:004CD243j
    add     edx, [ebp-8]
    jnb     short loc_4CD236
    inc     esi
    jmp     short loc_4CD234
    ; ---------------------------------------------------------------------------

    loc_4CD258:                             ; CODE XREF: .text:004CD209j
    jmp     short loc_4CD260
    ; ---------------------------------------------------------------------------

    loc_4CD25A:                             ; CODE XREF: .text:004CD205j
    cmp     ecx, eax
    jle     short loc_4CD260
    jmp     short $+2

    loc_4CD260:                             ; CODE XREF: .text:004CD258j
                                            ; .text:004CD25Cj
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-8], edx
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, ebx
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-0Ch], edx
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    add     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD29E:                             ; CODE XREF: .text:004CD2BBj
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     esi, [ebp-10h]
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD2B5
    add     esi, [ebp-4]

    loc_4CD2B5:                             ; CODE XREF: .text:004CD2B0j
    add     edx, [ebp-8]
    adc     esi, 0
    jmp     short loc_4CD29E
    ; ---------------------------------------------------------------------------

    loc_4CD2BD:                             ; CODE XREF: .text:004CD090j
    cmp     ecx, ebx
    jle     short loc_4CD314
    cmp     ecx, eax
    jle     short loc_4CD312
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-8], eax
    mov     edx, ebx
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-0Ch], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD2EE:                             ; CODE XREF: .text:004CD308j
                                            ; .text:004CD310j
    mov     al, [esi]

    loc_4CD2F0:                             ; CODE XREF: .text:004CD30Dj
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD30A
    add     esi, [ebp-4]
    add     edx, [ebp-8]
    adc     esi, 0
    jmp     short loc_4CD2EE
    ; ---------------------------------------------------------------------------

    loc_4CD30A:                             ; CODE XREF: .text:004CD2FDj
    add     edx, [ebp-8]
    jnb     short loc_4CD2F0
    inc     esi
    jmp     short loc_4CD2EE
    ; ---------------------------------------------------------------------------

    loc_4CD312:                             ; CODE XREF: .text:004CD2C3j
    jmp     short loc_4CD31A
    ; ---------------------------------------------------------------------------

    loc_4CD314:                             ; CODE XREF: .text:004CD2BFj
    cmp     ecx, eax
    jle     short loc_4CD31A
    jmp     short $+2

    loc_4CD31A:                             ; CODE XREF: .text:004CD312j
                                            ; .text:004CD316j
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-8], edx
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, ebx
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-0Ch], edx
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    add     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD358:                             ; CODE XREF: .text:004CD375j
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     esi, [ebp-10h]
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD36F
    add     esi, [ebp-4]

    loc_4CD36F:                             ; CODE XREF: .text:004CD36Aj
    add     edx, [ebp-8]
    adc     esi, 0
    jmp     short loc_4CD358
    ; ---------------------------------------------------------------------------

    loc_4CD377:                             ; CODE XREF: .text:004CD064j
    cmp     ecx, ebx
    jle     short loc_4CD3CE
    cmp     ecx, eax
    jle     short loc_4CD3CC
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-8], eax
    mov     edx, ebx
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-0Ch], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD3A8:                             ; CODE XREF: .text:004CD3C2j
                                            ; .text:004CD3CAj
    mov     al, [esi]

    loc_4CD3AA:                             ; CODE XREF: .text:004CD3C7j
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD3C4
    add     esi, [ebp-4]
    add     edx, [ebp-8]
    sbb     esi, 0
    jmp     short loc_4CD3A8
    ; ---------------------------------------------------------------------------

    loc_4CD3C4:                             ; CODE XREF: .text:004CD3B7j
    add     edx, [ebp-8]
    jnb     short loc_4CD3AA
    dec     esi
    jmp     short loc_4CD3A8
    ; ---------------------------------------------------------------------------

    loc_4CD3CC:                             ; CODE XREF: .text:004CD37Dj
    jmp     short loc_4CD3D4
    ; ---------------------------------------------------------------------------

    loc_4CD3CE:                             ; CODE XREF: .text:004CD379j
    cmp     ecx, eax
    jle     short loc_4CD3D4
    jmp     short $+2

    loc_4CD3D4:                             ; CODE XREF: .text:004CD3CCj
                                            ; .text:004CD3D0j
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-8], edx
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, ebx
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-0Ch], edx
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    sub     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD412:                             ; CODE XREF: .text:004CD42Fj
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    sub     esi, [ebp-10h]
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD429
    add     esi, [ebp-4]

    loc_4CD429:                             ; CODE XREF: .text:004CD424j
    add     edx, [ebp-8]
    sbb     esi, 0
    jmp     short loc_4CD412
    ; ---------------------------------------------------------------------------

    loc_4CD431:                             ; CODE XREF: .text:004CD069j
    cmp     ecx, ebx
    jle     short loc_4CD488
    cmp     ecx, eax
    jle     short loc_4CD486
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-8], eax
    mov     edx, ebx
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-0Ch], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD462:                             ; CODE XREF: .text:004CD47Cj
                                            ; .text:004CD484j
    mov     al, [esi]

    loc_4CD464:                             ; CODE XREF: .text:004CD481j
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD47E
    add     esi, [ebp-4]
    add     edx, [ebp-8]
    sbb     esi, 0
    jmp     short loc_4CD462
    ; ---------------------------------------------------------------------------

    loc_4CD47E:                             ; CODE XREF: .text:004CD471j
    add     edx, [ebp-8]
    jnb     short loc_4CD464
    dec     esi
    jmp     short loc_4CD462
    ; ---------------------------------------------------------------------------

    loc_4CD486:                             ; CODE XREF: .text:004CD437j
    jmp     short loc_4CD48E
    ; ---------------------------------------------------------------------------

    loc_4CD488:                             ; CODE XREF: .text:004CD433j
    cmp     ecx, eax
    jle     short loc_4CD48E
    jmp     short $+2

    loc_4CD48E:                             ; CODE XREF: .text:004CD486j
                                            ; .text:004CD48Aj
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-8], edx
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, ebx
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-0Ch], edx
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    sub     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD4CC:                             ; CODE XREF: .text:004CD4E9j
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    sub     esi, [ebp-10h]
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD4E3
    add     esi, [ebp-4]

    loc_4CD4E3:                             ; CODE XREF: .text:004CD4DEj
    add     edx, [ebp-8]
    sbb     esi, 0
    jmp     short loc_4CD4CC
    ; ---------------------------------------------------------------------------

    loc_4CD4EB:                             ; CODE XREF: .text:004CD05Aj
    cmp     ecx, ebx
    jle     short loc_4CD542
    cmp     ecx, eax
    jle     short loc_4CD540
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-8], eax
    mov     edx, ebx
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-0Ch], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD51C:                             ; CODE XREF: .text:004CD536j
                                            ; .text:004CD53Ej
    mov     al, [esi]

    loc_4CD51E:                             ; CODE XREF: .text:004CD53Bj
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD538
    sub     esi, [ebp-4]
    add     edx, [ebp-8]
    sbb     esi, 0
    jmp     short loc_4CD51C
    ; ---------------------------------------------------------------------------

    loc_4CD538:                             ; CODE XREF: .text:004CD52Bj
    add     edx, [ebp-8]
    jnb     short loc_4CD51E
    dec     esi
    jmp     short loc_4CD51C
    ; ---------------------------------------------------------------------------

    loc_4CD540:                             ; CODE XREF: .text:004CD4F1j
    jmp     short loc_4CD548
    ; ---------------------------------------------------------------------------

    loc_4CD542:                             ; CODE XREF: .text:004CD4EDj
    cmp     ecx, eax
    jle     short loc_4CD548
    jmp     short $+2

    loc_4CD548:                             ; CODE XREF: .text:004CD540j
                                            ; .text:004CD544j
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-8], edx
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, ebx
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-0Ch], edx
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    add     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD586:                             ; CODE XREF: .text:004CD5A3j
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    sub     esi, [ebp-10h]
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD59D
    sub     esi, [ebp-4]

    loc_4CD59D:                             ; CODE XREF: .text:004CD598j
    add     edx, [ebp-8]
    sbb     esi, 0
    jmp     short loc_4CD586
    ; ---------------------------------------------------------------------------

    loc_4CD5A5:                             ; CODE XREF: .text:004CD055j
    cmp     ecx, ebx
    jle     short loc_4CD5FC
    cmp     ecx, eax
    jle     short loc_4CD5FA
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-8], eax
    mov     edx, ebx
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     [ebp-0Ch], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD5D6:                             ; CODE XREF: .text:004CD5F0j
                                            ; .text:004CD5F8j
    mov     al, [esi]

    loc_4CD5D8:                             ; CODE XREF: .text:004CD5F5j
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD5F2
    sub     esi, [ebp-4]
    add     edx, [ebp-8]
    sbb     esi, 0
    jmp     short loc_4CD5D6
    ; ---------------------------------------------------------------------------

    loc_4CD5F2:                             ; CODE XREF: .text:004CD5E5j
    add     edx, [ebp-8]
    jnb     short loc_4CD5D8
    dec     esi
    jmp     short loc_4CD5D6
    ; ---------------------------------------------------------------------------

    loc_4CD5FA:                             ; CODE XREF: .text:004CD5ABj
    jmp     short loc_4CD602
    ; ---------------------------------------------------------------------------

    loc_4CD5FC:                             ; CODE XREF: .text:004CD5A7j
    cmp     ecx, eax
    jle     short loc_4CD602
    jmp     short $+2

    loc_4CD602:                             ; CODE XREF: .text:004CD5FAj
                                            ; .text:004CD5FEj
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-8], edx
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, ebx
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     [ebp-0Ch], edx
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    add     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    xor     ebx, ebx
    xor     edx, edx

    loc_4CD640:                             ; CODE XREF: .text:004CD65Dj
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    sub     esi, [ebp-10h]
    add     ebx, [ebp-0Ch]
    jnb     short loc_4CD657
    sub     esi, [ebp-4]

    loc_4CD657:                             ; CODE XREF: .text:004CD652j
    add     edx, [ebp-8]
    sbb     esi, 0
    jmp     short loc_4CD640
    ; ---------------------------------------------------------------------------

    loc_4CD65F:                             ; CODE XREF: .text:004CD035j
    mov     eax, [ebp+1Ch]
    sub     eax, [ebp+14h]
    jge     loc_4CD701
    neg     eax
    inc     eax
    cmp     ecx, eax
    jz      short loc_4CD6E4
    jle     short loc_4CD6A7
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     ecx, eax
    mov     edx, [ebp-4]
    mov     eax, [ebp+14h]
    mul     edx
    add     eax, [ebp+10h]
    add     esi, eax
    mov     edx, [ebp+20h]
    xor     ebx, ebx

    loc_4CD692:                             ; CODE XREF: .text:004CD6A5j
    mov     al, [esi]
    sub     esi, [ebp-4]

    loc_4CD697:                             ; CODE XREF: .text:004CD6A3j
    mov     [edi], al
    dec     edx
    jz      loc_4CD88E
    inc     edi
    add     ebx, ecx
    jnb     short loc_4CD697
    jmp     short loc_4CD692
    ; ---------------------------------------------------------------------------

    loc_4CD6A7:                             ; CODE XREF: .text:004CD672j
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     ecx, eax
    shl     ecx, 10h
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    mov     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    mov     edx, [ebp+20h]
    xor     ebx, ebx

    loc_4CD6CC:                             ; CODE XREF: .text:004CD6DDj
                                            ; .text:004CD6E2j
    mov     al, [esi]
    mov     [edi], al
    dec     edx
    jz      loc_4CD88E
    inc     edi
    sub     esi, [ebp-10h]
    add     ebx, ecx
    jnb     short loc_4CD6CC
    sub     esi, [ebp-4]
    jmp     short loc_4CD6CC
    ; ---------------------------------------------------------------------------

    loc_4CD6E4:                             ; CODE XREF: .text:004CD670j
    mov     eax, [ebp+14h]
    mov     ebx, [ebp-4]
    mul     ebx
    add     eax, [ebp+10h]
    add     esi, eax

    loc_4CD6F1:                             ; CODE XREF: .text:004CD6FFj
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    sub     esi, ebx
    inc     edi
    jmp     short loc_4CD6F1
    ; ---------------------------------------------------------------------------

    loc_4CD701:                             ; CODE XREF: .text:004CD665j
    inc     eax
    cmp     ecx, eax
    jz      short loc_4CD77A
    jle     short loc_4CD73B
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     ecx, eax
    mov     edx, [ebp-4]
    mov     eax, [ebp+14h]
    mul     edx
    add     eax, [ebp+10h]
    add     esi, eax
    mov     edx, [ebp+20h]
    xor     ebx, ebx

    loc_4CD726:                             ; CODE XREF: .text:004CD739j
    mov     al, [esi]
    add     esi, [ebp-4]

    loc_4CD72B:                             ; CODE XREF: .text:004CD737j
    mov     [edi], al
    dec     edx
    jz      loc_4CD88E
    inc     edi
    add     ebx, ecx
    jnb     short loc_4CD72B
    jmp     short loc_4CD726
    ; ---------------------------------------------------------------------------

    loc_4CD73B:                             ; CODE XREF: .text:004CD706j
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     ecx, edx
    shr     eax, 10h
    mul     dword ptr [ebp-4]
    mov     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    mov     edx, [ebp+20h]
    xor     ebx, ebx

    loc_4CD762:                             ; CODE XREF: .text:004CD773j
                                            ; .text:004CD778j
    mov     al, [esi]
    mov     [edi], al
    dec     edx
    jz      loc_4CD88E
    inc     edi
    add     esi, [ebp-10h]
    add     ebx, ecx
    jnb     short loc_4CD762
    add     esi, [ebp-4]
    jmp     short loc_4CD762
    ; ---------------------------------------------------------------------------

    loc_4CD77A:                             ; CODE XREF: .text:004CD704j
    mov     eax, [ebp+14h]
    mov     ebx, [ebp-4]
    mul     ebx
    add     eax, [ebp+10h]
    add     esi, eax

    loc_4CD787:                             ; CODE XREF: .text:004CD795j
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      loc_4CD88E
    inc     edi
    add     esi, ebx
    jmp     short loc_4CD787
    ; ---------------------------------------------------------------------------

    loc_4CD797:                             ; CODE XREF: .text:004CD046j
    cmp     ecx, eax
    jz      short loc_4CD806
    jle     short loc_4CD7CC
    mov     edx, eax
    xor     eax, eax
    div     cx
    shl     eax, 10h
    mov     ecx, eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    mov     edx, [ebp+20h]
    xor     ebx, ebx

    loc_4CD7B9:                             ; CODE XREF: .text:004CD7CAj
    mov     al, [esi]
    dec     esi

    loc_4CD7BC:                             ; CODE XREF: .text:004CD7C8j
    mov     [edi], al
    dec     edx
    jz      loc_4CD88E
    inc     edi
    add     ebx, ecx
    jnb     short loc_4CD7BC
    jmp     short loc_4CD7B9
    ; ---------------------------------------------------------------------------

    loc_4CD7CC:                             ; CODE XREF: .text:004CD79Bj
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     edx, eax
    shl     edx, 10h
    mov     ecx, edx
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    mov     edx, [ebp+20h]
    xor     ebx, ebx

    loc_4CD7F0:                             ; CODE XREF: .text:004CD801j
                                            ; .text:004CD804j
    mov     al, [esi]
    mov     [edi], al
    dec     edx
    jz      loc_4CD88E
    inc     edi
    sub     esi, [ebp-10h]
    add     ebx, ecx
    jnb     short loc_4CD7F0
    dec     esi
    jmp     short loc_4CD7F0
    ; ---------------------------------------------------------------------------

    loc_4CD806:                             ; CODE XREF: .text:004CD799j
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax

    loc_4CD811:                             ; CODE XREF: .text:004CD81Aj
    mov     al, [esi]
    mov     [edi], al
    dec     ecx
    jz      short loc_4CD88E
    dec     esi
    inc     edi
    jmp     short loc_4CD811
    ; ---------------------------------------------------------------------------

    loc_4CD81C:                             ; CODE XREF: .text:004CD075j
    cmp     ecx, eax
    jz      short loc_4CD881
    jle     short loc_4CD84D
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    shl     eax, 10h
    mov     ecx, eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    mov     edx, [ebp+20h]
    xor     ebx, ebx

    loc_4CD83E:                             ; CODE XREF: .text:004CD84Bj
    mov     al, [esi]
    inc     esi

    loc_4CD841:                             ; CODE XREF: .text:004CD849j
    mov     [edi], al
    dec     edx
    jz      short loc_4CD88E
    inc     edi
    add     ebx, ecx
    jnb     short loc_4CD841
    jmp     short loc_4CD83E
    ; ---------------------------------------------------------------------------

    loc_4CD84D:                             ; CODE XREF: .text:004CD820j
    xor     edx, edx
    shl     eax, 10h
    div     ecx
    mov     ecx, eax
    shl     ecx, 10h
    shr     eax, 10h
    mov     [ebp-10h], eax
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    mov     edx, [ebp+20h]
    xor     ebx, ebx

    loc_4CD86F:                             ; CODE XREF: .text:004CD87Fj
    mov     al, [esi]
    mov     [edi], al
    dec     edx
    jz      short loc_4CD88E
    inc     edi
    add     esi, [ebp-10h]
    add     ebx, ecx
    adc     esi, 0
    jmp     short loc_4CD86F
    ; ---------------------------------------------------------------------------

    loc_4CD881:                             ; CODE XREF: .text:004CD81Ej
    mov     eax, [ebp+14h]
    mul     dword ptr [ebp-4]
    add     eax, [ebp+10h]
    add     esi, eax
    rep movsb

    loc_4CD88E:                             ; CODE XREF: .text:004CD0BCj
                                            ; .text:004CD12Fj ...
    popf
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CD896 proc near                    ; CODE XREF: sub_4C7310+DAp
                                            ; sub_4C7A20+3D3p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch
    arg_18= dword ptr  20h

    push    ebp
    mov     ebp, esp
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    mov     eax, [ebp+arg_0]
    mov     ebx, [ebp+arg_4]
    mov     edi, eax
    mov     esi, ebx
    mov     ecx, [ebp+arg_C]
    mov     edx, [ebp+arg_10]
    mov     eax, [ebp+arg_8]
    inc     eax

    loc_4CD8B2:                             ; CODE XREF: sub_4CD896+3Bj
    dec     eax
    jz      short loc_4CD8D3
    mov     ebx, edx
    shl     ebx, 7
    add     edx, [ebp+arg_18]
    and     ebx, 0FF800000h
    add     ebx, ecx
    shr     ebx, 10h
    add     ecx, [ebp+arg_14]
    mov     bl, [ebx+esi]
    mov     [edi], bl
    inc     edi
    jmp     short loc_4CD8B2
    ; ---------------------------------------------------------------------------

    loc_4CD8D3:                             ; CODE XREF: sub_4CD896+1Dj
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CD896 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CD8DA proc near                    ; CODE XREF: sub_4C7310+FBp
                                            ; sub_4C7A20+3EEp ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch
    arg_18= dword ptr  20h

    push    ebp
    mov     ebp, esp
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    mov     eax, [ebp+arg_0]
    mov     ebx, [ebp+arg_4]
    mov     edi, eax
    mov     esi, ebx
    mov     ecx, [ebp+arg_C]
    mov     edx, [ebp+arg_10]
    mov     eax, [ebp+arg_8]
    inc     eax

    loc_4CD8F6:                             ; CODE XREF: sub_4CD8DA+3Bj
    dec     eax
    jz      short loc_4CD917
    mov     ebx, edx
    shl     ebx, 6
    add     edx, [ebp+arg_18]
    and     ebx, 0FFC00000h
    add     ebx, ecx
    shr     ebx, 10h
    add     ecx, [ebp+arg_14]
    mov     bl, [ebx+esi]
    mov     [edi], bl
    inc     edi
    jmp     short loc_4CD8F6
    ; ---------------------------------------------------------------------------

    loc_4CD917:                             ; CODE XREF: sub_4CD8DA+1Dj
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CD8DA endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CD91E proc near                    ; CODE XREF: sub_4C7310+11Cp
                                            ; sub_4C7A20+413p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch
    arg_18= dword ptr  20h

    push    ebp
    mov     ebp, esp
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    mov     eax, [ebp+arg_0]
    mov     ebx, [ebp+arg_4]
    mov     edi, eax
    mov     esi, ebx
    mov     ecx, [ebp+arg_C]
    mov     edx, [ebp+arg_10]
    mov     eax, [ebp+arg_8]
    inc     eax

    loc_4CD93A:                             ; CODE XREF: sub_4CD91E+3Bj
    dec     eax
    jz      short loc_4CD95B
    mov     ebx, edx
    shl     ebx, 5
    add     edx, [ebp+arg_18]
    and     ebx, 0FFE00000h
    add     ebx, ecx
    shr     ebx, 10h
    add     ecx, [ebp+arg_14]
    mov     bl, [ebx+esi]
    mov     [edi], bl
    inc     edi
    jmp     short loc_4CD93A
    ; ---------------------------------------------------------------------------

    loc_4CD95B:                             ; CODE XREF: sub_4CD91E+1Dj
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CD91E endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4CD962 proc near                    ; CODE XREF: sub_4C7310+13Dp
                                            ; sub_4C7A20+438p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch
    arg_18= dword ptr  20h

    push    ebp
    mov     ebp, esp
    push    esi
    push    edi
    push    ebx
    push    ecx
    push    edx
    mov     eax, [ebp+arg_0]
    mov     ebx, [ebp+arg_4]
    mov     edi, eax
    mov     esi, ebx
    mov     ecx, [ebp+arg_C]
    mov     edx, [ebp+arg_10]
    mov     eax, [ebp+arg_8]
    inc     eax

    loc_4CD97E:                             ; CODE XREF: sub_4CD962+3Bj
    dec     eax
    jz      short loc_4CD99F
    mov     ebx, edx
    shl     ebx, 4
    add     edx, [ebp+arg_18]
    and     ebx, 0FFF00000h
    add     ebx, ecx
    shr     ebx, 10h
    add     ecx, [ebp+arg_14]
    mov     bl, [ebx+esi]
    mov     [edi], bl
    inc     edi
    jmp     short loc_4CD97E
    ; ---------------------------------------------------------------------------

    loc_4CD99F:                             ; CODE XREF: sub_4CD962+1Dj
    pop     edx
    pop     ecx
    pop     ebx
    pop     edi
    pop     esi
    leave
    retn
    sub_4CD962 endp

    ; ---------------------------------------------------------------------------
    align 10h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CD9C0 proc near                    ; CODE XREF: sub_490FE0+D7p
    mov     eax, [ecx+210h]
    retn
    sub_4CD9C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CD9D0 proc near                    ; CODE XREF: sub_491200+263p
                                            ; sub_49E830+3BDp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    mov     esi, ecx
    mov     [esi+28Ch], eax
    call    sub_4CDA00
    mov     esi, [esi+28Ch]
    test    esi, esi
    jz      short loc_4CD9EE
    call    esi

    loc_4CD9EE:                             ; CODE XREF: sub_4CD9D0+1Aj
    mov     eax, 1
    pop     esi
    retn    4
    sub_4CD9D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CDA00 proc near                    ; CODE XREF: sub_4CD9D0+Dp
                                            ; .text:004CE168p ...

    var_44= dword ptr -44h
    var_40= dword ptr -40h
    strReturnString= byte ptr -20h

    sub     esp, 44h
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebx, ebx
    push    ebx
    mov     [edi+208h], ebx
    mov     [edi+20Ch], ebx
    call    sub_4BB190
    movsx   eax, al
    cmp     eax, ebx
    jz      short loc_4CDA2F
    push    eax
    call    sub_4BB260
    mov     [edi+210h], eax

    loc_4CDA2F:                             ; CODE XREF: sub_4CDA00+21j
    mov     esi, ds:mciSendStringA
    push    ebx                             ; hwndCallback
    lea     eax, [esp+54h+strReturnString]
    push    20h                             ; uReturnLength
    push    eax                             ; lpstrReturnString
    push    offset aStatusCdaudioN          ; lpstrCommand
    call    esi ; mciSendStringA
    cmp     eax, ebx
    jnz     loc_4CDB2A
    lea     ecx, [esp+50h+strReturnString]
    push    ecx                             ; char *
    call    _atoi
    add     esp, 4
    mov     [edi+200h], eax
    push    ebx                             ; hwndCallback
    push    ebx                             ; uReturnLength
    push    ebx                             ; lpstrReturnString
    push    offset aSetCdaudioTime          ; lpstrCommand
    call    esi ; mciSendStringA
    push    ebx                             ; hwndCallback
    lea     edx, [esp+54h+var_40]
    push    20h                             ; uReturnLength
    push    edx                             ; lpstrReturnString
    push    offset aStatusCdaudioT          ; lpstrCommand
    call    esi ; mciSendStringA
    cmp     eax, ebx
    jnz     short loc_4CDAE8
    mov     esi, offset aAudio              ; "audio"
    lea     eax, [esp+50h+var_40]

    loc_4CDA85:                             ; CODE XREF: sub_4CDA00+A3j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4CDAA9
    cmp     cl, bl
    jz      short loc_4CDAA5
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4CDAA9
    add     eax, 2
    add     esi, 2
    cmp     cl, bl
    jnz     short loc_4CDA85

    loc_4CDAA5:                             ; CODE XREF: sub_4CDA00+8Fj
    xor     eax, eax
    jmp     short loc_4CDAAE
    ; ---------------------------------------------------------------------------

    loc_4CDAA9:                             ; CODE XREF: sub_4CDA00+8Bj
                                            ; sub_4CDA00+99j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4CDAAE:                             ; CODE XREF: sub_4CDA00+A7j
    cmp     eax, ebx
    jz      short loc_4CDB09
    mov     esi, offset aOther              ; "other"
    lea     eax, [esp+50h+var_40]

    loc_4CDABB:                             ; CODE XREF: sub_4CDA00+D9j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4CDADF
    cmp     cl, bl
    jz      short loc_4CDADB
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4CDADF
    add     eax, 2
    add     esi, 2
    cmp     cl, bl
    jnz     short loc_4CDABB

    loc_4CDADB:                             ; CODE XREF: sub_4CDA00+C5j
    xor     eax, eax
    jmp     short loc_4CDAE4
    ; ---------------------------------------------------------------------------

    loc_4CDADF:                             ; CODE XREF: sub_4CDA00+C1j
                                            ; sub_4CDA00+CFj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4CDAE4:                             ; CODE XREF: sub_4CDA00+DDj
    mov     [esp+50h+var_44], eax

    loc_4CDAE8:                             ; CODE XREF: sub_4CDA00+7Aj
    mov     eax, [edi+200h]
    mov     dword ptr [edi+280h], 1
    dec     eax
    mov     [edi+200h], eax
    jns     short loc_4CDB0F
    mov     [edi+200h], ebx
    jmp     short loc_4CDB0F
    ; ---------------------------------------------------------------------------

    loc_4CDB09:                             ; CODE XREF: sub_4CDA00+B0j
    mov     [edi+280h], ebx

    loc_4CDB0F:                             ; CODE XREF: sub_4CDA00+FFj
                                            ; sub_4CDA00+107j
    mov     eax, [edi+200h]
    cmp     eax, ebx
    jz      short loc_4CDB2C
    mov     dword ptr [edi+208h], 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 44h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CDB2A:                             ; CODE XREF: sub_4CDA00+46j
    xor     eax, eax

    loc_4CDB2C:                             ; CODE XREF: sub_4CDA00+117j
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 44h
    retn
    sub_4CDA00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CDB40 proc near                    ; CODE XREF: .text:0045C66Fp
                                            ; .text:0045C9B7p ...

    var_44= dword ptr -44h
    strReturnString= byte ptr -40h

    sub     esp, 44h
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    xor     edi, edi
    mov     eax, [ebp+200h]
    mov     [esp+54h+var_44], ebp
    cmp     eax, edi
    jz      loc_4CE002
    mov     eax, [ebp+278h]
    cmp     eax, 4
    jnz     short loc_4CDBB3
    push    edi                             ; hwndCallback
    push    edi                             ; uReturnLength
    push    edi                             ; lpstrReturnString
    push    offset aStopCdaudio             ; lpstrCommand
    call    ds:mciSendStringA
    cmp     [ebp+200h], edi
    jz      short loc_4CDB8A
    mov     dword ptr [ebp+208h], 1
    jmp     short loc_4CDB90
    ; ---------------------------------------------------------------------------

    loc_4CDB8A:                             ; CODE XREF: sub_4CDB40+3Cj
    mov     [ebp+208h], edi

    loc_4CDB90:                             ; CODE XREF: sub_4CDB40+48j
    mov     [ebp+20Ch], edi
    mov     [ebp+284h], edi
    mov     eax, dword_50B540
    push    eax
    call    sub_4B64D0
    mov     ecx, dword_50B544
    push    ecx
    jmp     loc_4CDCAA
    ; ---------------------------------------------------------------------------

    loc_4CDBB3:                             ; CODE XREF: sub_4CDB40+26j
    mov     ecx, [ebp+20Ch]
    cmp     ecx, 2
    jz      loc_4CE002
    cmp     eax, 2
    mov     ebx, 1
    jz      loc_4CDE96                      ; case 0x4
    cmp     eax, 3
    jz      loc_4CDE96                      ; case 0x4
    mov     eax, [ebp+1FCh]
    cmp     eax, 4                          ; switch 5 cases
    ja      loc_4CDFEB                      ; default
    jmp     ds:off_4CE00C[eax*4]            ; switch jump

    loc_4CDBEF:                             ; DATA XREF: .text:004CE00Co
    cmp     ecx, edi                        ; case 0x0
    jz      loc_4CE002
    push    edi                             ; hwndCallback
    lea     edx, [esp+58h+strReturnString]
    push    40h                             ; uReturnLength
    mov     [ebp+20Ch], edi
    mov     edi, ds:mciSendStringA
    push    edx                             ; lpstrReturnString
    push    offset aStatusCdaudioM          ; lpstrCommand
    call    edi ; mciSendStringA
    xor     ebx, ebx
    cmp     eax, ebx
    jnz     short loc_4CDC5E
    mov     esi, offset aPlaying            ; "playing"
    lea     eax, [esp+54h+strReturnString]

    loc_4CDC21:                             ; CODE XREF: sub_4CDB40+FFj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4CDC4E
    test    cl, cl
    jz      short loc_4CDC41
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4CDC4E
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CDC21

    loc_4CDC41:                             ; CODE XREF: sub_4CDB40+EBj
    xor     eax, eax
    xor     ecx, ecx
    cmp     eax, ebx
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDC60
    ; ---------------------------------------------------------------------------

    loc_4CDC4E:                             ; CODE XREF: sub_4CDB40+E7j
                                            ; sub_4CDB40+F5j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    cmp     eax, ebx
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDC60
    ; ---------------------------------------------------------------------------

    loc_4CDC5E:                             ; CODE XREF: sub_4CDB40+D6j
    xor     eax, eax

    loc_4CDC60:                             ; CODE XREF: sub_4CDB40+10Cj
                                            ; sub_4CDB40+11Cj
    cmp     eax, ebx
    jz      loc_4CE002
    push    ebx                             ; hwndCallback
    push    ebx                             ; uReturnLength
    push    ebx                             ; lpstrReturnString
    push    offset aStopCdaudio             ; lpstrCommand
    call    edi ; mciSendStringA
    cmp     [ebp+200h], ebx
    jz      short loc_4CDC86
    mov     dword ptr [ebp+208h], 1
    jmp     short loc_4CDC8C
    ; ---------------------------------------------------------------------------

    loc_4CDC86:                             ; CODE XREF: sub_4CDB40+138j
    mov     [ebp+208h], ebx

    loc_4CDC8C:                             ; CODE XREF: sub_4CDB40+144j
    mov     [ebp+20Ch], ebx
    mov     [ebp+284h], ebx
    mov     edx, dword_50B540
    push    edx
    call    sub_4B64D0
    mov     eax, dword_50B544
    push    eax

    loc_4CDCAA:                             ; CODE XREF: sub_4CDB40+6Ej
    call    sub_4B64D0
    or      eax, 0FFFFFFFFh
    mov     dword_50B544, eax
    mov     dword_50B540, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CDCC4:                             ; CODE XREF: sub_4CDB40+A8j
                                            ; DATA XREF: .text:004CE00Co
    push    edi                             ; case 0x1
    lea     ecx, [esp+58h+strReturnString]
    push    40h                             ; uReturnLength
    push    ecx                             ; lpstrReturnString
    push    offset aStatusCdaudioM          ; lpstrCommand
    call    ds:mciSendStringA
    cmp     eax, edi
    jnz     short loc_4CDD21
    mov     esi, offset aPlaying            ; "playing"
    lea     eax, [esp+54h+strReturnString]

    loc_4CDCE4:                             ; CODE XREF: sub_4CDB40+1C2j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4CDD11
    test    cl, cl
    jz      short loc_4CDD04
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4CDD11
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CDCE4

    loc_4CDD04:                             ; CODE XREF: sub_4CDB40+1AEj
    xor     eax, eax
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDD23
    ; ---------------------------------------------------------------------------

    loc_4CDD11:                             ; CODE XREF: sub_4CDB40+1AAj
                                            ; sub_4CDB40+1B8j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDD23
    ; ---------------------------------------------------------------------------

    loc_4CDD21:                             ; CODE XREF: sub_4CDB40+199j
    xor     eax, eax

    loc_4CDD23:                             ; CODE XREF: sub_4CDB40+1CFj
                                            ; sub_4CDB40+1DFj
    cmp     eax, edi
    jnz     loc_4CDFEB                      ; default
    mov     eax, [ebp+208h]
    cmp     eax, ebx
    jge     short loc_4CDD3D
    mov     [ebp+208h], ebx
    jmp     short loc_4CDD44
    ; ---------------------------------------------------------------------------

    loc_4CDD3D:                             ; CODE XREF: sub_4CDB40+1F3j
    inc     eax
    mov     [ebp+208h], eax

    loc_4CDD44:                             ; CODE XREF: sub_4CDB40+1FBj
    mov     eax, [ebp+208h]
    mov     edx, [ebp+200h]
    sub     edx, eax
    mov     ecx, ebp
    inc     edx
    push    edx
    push    eax
    call    sub_4CEB60
    mov     eax, [ebp+208h]
    mov     ecx, [ebp+200h]
    cmp     eax, ecx
    jle     loc_4CDFEB                      ; default
    mov     [ebp+208h], ebx
    jmp     loc_4CDFEB                      ; default
    ; ---------------------------------------------------------------------------

    loc_4CDD7B:                             ; CODE XREF: sub_4CDB40+A8j
                                            ; DATA XREF: .text:004CE00Co
    push    edi                             ; case 0x2
    lea     ecx, [esp+58h+strReturnString]
    push    40h                             ; uReturnLength
    push    ecx                             ; lpstrReturnString
    push    offset aStatusCdaudioM          ; lpstrCommand
    call    ds:mciSendStringA
    cmp     eax, edi
    jnz     short loc_4CDDD8
    mov     esi, offset aPlaying            ; "playing"
    lea     eax, [esp+54h+strReturnString]

    loc_4CDD9B:                             ; CODE XREF: sub_4CDB40+279j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4CDDC8
    test    cl, cl
    jz      short loc_4CDDBB
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4CDDC8
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CDD9B

    loc_4CDDBB:                             ; CODE XREF: sub_4CDB40+265j
    xor     eax, eax
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDDDA
    ; ---------------------------------------------------------------------------

    loc_4CDDC8:                             ; CODE XREF: sub_4CDB40+261j
                                            ; sub_4CDB40+26Fj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDDDA
    ; ---------------------------------------------------------------------------

    loc_4CDDD8:                             ; CODE XREF: sub_4CDB40+250j
    xor     eax, eax

    loc_4CDDDA:                             ; CODE XREF: sub_4CDB40+286j
                                            ; sub_4CDB40+296j
    cmp     eax, edi
    jnz     loc_4CDFEB                      ; default
    push    ebx
    call    _rand
    cdq
    idiv    dword ptr [ebp+200h]
    mov     ecx, ebp
    inc     edx
    push    edx
    call    sub_4CEB60
    jmp     loc_4CDFEB                      ; default
    ; ---------------------------------------------------------------------------

    loc_4CDDFD:                             ; CODE XREF: sub_4CDB40+A8j
                                            ; DATA XREF: .text:004CE00Co
    push    edi                             ; case 0x3
    lea     edx, [esp+58h+strReturnString]
    push    40h                             ; uReturnLength
    push    edx                             ; lpstrReturnString
    push    offset aStatusCdaudioM          ; lpstrCommand
    call    ds:mciSendStringA
    cmp     eax, edi
    jnz     short loc_4CDE5A
    mov     esi, offset aPlaying            ; "playing"
    lea     eax, [esp+54h+strReturnString]

    loc_4CDE1D:                             ; CODE XREF: sub_4CDB40+2FBj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4CDE4A
    test    cl, cl
    jz      short loc_4CDE3D
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4CDE4A
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CDE1D

    loc_4CDE3D:                             ; CODE XREF: sub_4CDB40+2E7j
    xor     eax, eax
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDE5C
    ; ---------------------------------------------------------------------------

    loc_4CDE4A:                             ; CODE XREF: sub_4CDB40+2E3j
                                            ; sub_4CDB40+2F1j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDE5C
    ; ---------------------------------------------------------------------------

    loc_4CDE5A:                             ; CODE XREF: sub_4CDB40+2D2j
    xor     eax, eax

    loc_4CDE5C:                             ; CODE XREF: sub_4CDB40+308j
                                            ; sub_4CDB40+318j
    cmp     eax, edi
    jz      short loc_4CDE74
    mov     edx, [ebp+208h]
    mov     eax, [ebp+204h]
    cmp     edx, eax
    jz      loc_4CDFEB                      ; default

    loc_4CDE74:                             ; CODE XREF: sub_4CDB40+31Ej
    cmp     [ebp+204h], edi
    jnz     short loc_4CDE82
    mov     [ebp+204h], ebx

    loc_4CDE82:                             ; CODE XREF: sub_4CDB40+33Aj
    mov     eax, [ebp+204h]
    push    ebx
    push    eax
    mov     ecx, ebp
    call    sub_4CEB60
    jmp     loc_4CDFEB                      ; default
    ; ---------------------------------------------------------------------------

    loc_4CDE96:                             ; CODE XREF: sub_4CDB40+8Aj
                                            ; sub_4CDB40+93j ...
    call    _rand                           ; case 0x4
    push    edi                             ; hwndCallback
    lea     ecx, [esp+58h+strReturnString]
    push    40h                             ; uReturnLength
    mov     ebx, eax
    push    ecx                             ; lpstrReturnString
    push    offset aStatusCdaudioM          ; lpstrCommand
    and     ebx, 0Fh
    call    ds:mciSendStringA
    cmp     eax, edi
    jnz     short loc_4CDF05
    mov     esi, offset aPlaying            ; "playing"
    lea     eax, [esp+54h+strReturnString]

    loc_4CDEC0:                             ; CODE XREF: sub_4CDB40+39Ej
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4CDEF1
    test    cl, cl
    jz      short loc_4CDEE0
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4CDEF1
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CDEC0

    loc_4CDEE0:                             ; CODE XREF: sub_4CDB40+38Aj
    mov     ebp, [esp+54h+var_44]
    xor     eax, eax
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDF07
    ; ---------------------------------------------------------------------------

    loc_4CDEF1:                             ; CODE XREF: sub_4CDB40+386j
                                            ; sub_4CDB40+394j
    sbb     eax, eax
    mov     ebp, [esp+54h+var_44]
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CDF07
    ; ---------------------------------------------------------------------------

    loc_4CDF05:                             ; CODE XREF: sub_4CDB40+375j
    xor     eax, eax

    loc_4CDF07:                             ; CODE XREF: sub_4CDB40+3AFj
                                            ; sub_4CDB40+3C3j
    test    eax, eax
    jz      short loc_4CDF28
    mov     edx, [ebp+208h]
    mov     ecx, [ebp+278h]
    xor     eax, eax
    mov     al, [edx+ebp+214h]
    cmp     eax, ecx
    jz      loc_4CDFEB                      ; default

    loc_4CDF28:                             ; CODE XREF: sub_4CDB40+3C9j
    mov     edi, [ebp+200h]
    lea     esi, [ebx+1]
    imul    esi, edi
    mov     ecx, [ebp+208h]
    test    esi, esi
    jle     short loc_4CDF98
    mov     edx, [esp+54h+var_44]
    mov     ebp, [edx+278h]

    loc_4CDF48:                             ; CODE XREF: sub_4CDB40+427j
    inc     ecx
    cmp     ecx, edi
    jle     short loc_4CDF52
    mov     ecx, 1

    loc_4CDF52:                             ; CODE XREF: sub_4CDB40+40Bj
    xor     eax, eax
    mov     al, [ecx+edx+214h]
    cmp     eax, ebp
    jnz     short loc_4CDF64
    dec     ebx
    test    ebx, ebx
    jle     short loc_4CDF6B

    loc_4CDF64:                             ; CODE XREF: sub_4CDB40+41Dj
    dec     esi
    test    esi, esi
    jg      short loc_4CDF48
    jmp     short loc_4CDF90
    ; ---------------------------------------------------------------------------

    loc_4CDF6B:                             ; CODE XREF: sub_4CDB40+422j
    cmp     ecx, edi
    mov     eax, ecx
    jg      short loc_4CDF83

    loc_4CDF71:                             ; CODE XREF: sub_4CDB40+441j
    xor     ebx, ebx
    mov     bl, [eax+edx+214h]
    cmp     ebx, ebp
    jnz     short loc_4CDF83
    inc     eax
    cmp     eax, edi
    jle     short loc_4CDF71

    loc_4CDF83:                             ; CODE XREF: sub_4CDB40+42Fj
                                            ; sub_4CDB40+43Cj
    sub     eax, ecx
    push    eax
    push    ecx
    mov     ecx, [esp+5Ch+var_44]
    call    sub_4CEB60

    loc_4CDF90:                             ; CODE XREF: sub_4CDB40+429j
    mov     ebp, [esp+54h+var_44]
    test    esi, esi
    jg      short loc_4CDFEB                ; default

    loc_4CDF98:                             ; CODE XREF: sub_4CDB40+3FCj
    xor     esi, esi
    push    esi                             ; hwndCallback
    push    esi                             ; uReturnLength
    push    esi                             ; lpstrReturnString
    push    offset aStopCdaudio             ; lpstrCommand
    call    ds:mciSendStringA
    mov     edi, [ebp+200h]
    xor     ecx, ecx
    cmp     edi, esi
    mov     [ebp+20Ch], esi
    setnz   cl
    mov     [ebp+208h], ecx
    mov     [ebp+284h], esi
    mov     edx, dword_50B540
    push    edx
    call    sub_4B64D0
    mov     eax, dword_50B544
    push    eax
    call    sub_4B64D0
    or      eax, 0FFFFFFFFh
    mov     dword_50B544, eax
    mov     dword_50B540, eax

    loc_4CDFEB:                             ; CODE XREF: sub_4CDB40+A2j
                                            ; sub_4CDB40+1E5j ...
    mov     ecx, [ebp+20h]                  ; default
    push    1
    push    ecx
    mov     ecx, ebp
    call    sub_4D00D0
    mov     dword ptr [ebp+20Ch], 1

    loc_4CE002:                             ; CODE XREF: sub_4CDB40+17j
                                            ; sub_4CDB40+7Cj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 44h
    retn
    sub_4CDB40 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4CE00C dd offset loc_4CDBEF         ; DATA XREF: sub_4CDB40+A8r
    dd offset loc_4CDCC4                    ; jump table for switch statement
    dd offset loc_4CDD7B
    dd offset loc_4CDDFD
    dd offset loc_4CDE96
    ; ---------------------------------------------------------------------------
    mov     eax, [ecx+20Ch]
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    loc_4CE030:                             ; DATA XREF: sub_4CE260+13Do
    mov     eax, [esp+4]
    sub     esp, 40h
    cmp     eax, 219h
    push    esi
    jz      loc_4CE0E9
    cmp     eax, 3B9h
    jnz     loc_4CE17F
    mov     ecx, [esp+4Ch]
    mov     eax, 1
    cmp     ecx, eax
    jnz     loc_4CE17F
    mov     ecx, dword_51FF14
    cmp     [ecx+20Ch], eax
    jnz     loc_4CE17F
    push    0
    lea     edx, [esp+8]
    push    40h
    push    edx
    push    offset aStatusCdaudioM          ; "status cdaudio mode"
    call    ds:mciSendStringA
    test    eax, eax
    jnz     short loc_4CE0CF
    mov     esi, offset aPlaying            ; "playing"
    lea     eax, [esp+4]

    loc_4CE092:                             ; CODE XREF: .text:004CE0B0j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4CE0BF
    test    cl, cl
    jz      short loc_4CE0B2
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4CE0BF
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CE092

    loc_4CE0B2:                             ; CODE XREF: .text:004CE09Cj
    xor     eax, eax
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CE0D1
    ; ---------------------------------------------------------------------------

    loc_4CE0BF:                             ; CODE XREF: .text:004CE098j
                                            ; .text:004CE0A6j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CE0D1
    ; ---------------------------------------------------------------------------

    loc_4CE0CF:                             ; CODE XREF: .text:004CE087j
    xor     eax, eax

    loc_4CE0D1:                             ; CODE XREF: .text:004CE0BDj
                                            ; .text:004CE0CDj
    test    eax, eax
    jnz     loc_4CE17F
    mov     ecx, dword_51FF14
    call    sub_4CDB40
    pop     esi
    add     esp, 40h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CE0E9:                             ; CODE XREF: .text:004CE03Dj
    mov     esi, dword_51FF14
    push    0
    push    0
    push    0
    push    offset aStopCdaudio             ; "stop cdaudio"
    call    ds:mciSendStringA
    mov     eax, [esi+200h]
    test    eax, eax
    jz      short loc_4CE116
    mov     dword ptr [esi+208h], 1
    jmp     short loc_4CE120
    ; ---------------------------------------------------------------------------

    loc_4CE116:                             ; CODE XREF: .text:004CE108j
    mov     dword ptr [esi+208h], 0

    loc_4CE120:                             ; CODE XREF: .text:004CE114j
    mov     dword ptr [esi+20Ch], 0
    mov     dword ptr [esi+284h], 0
    mov     edx, dword_50B540
    push    edx
    call    sub_4B64D0
    mov     eax, dword_50B544
    push    eax
    call    sub_4B64D0
    or      eax, 0FFFFFFFFh
    mov     dword_50B544, eax
    mov     dword_50B540, eax
    cmp     dword ptr [esp+4Ch], 8000h
    jnz     short loc_4CE17F
    mov     ecx, dword_51FF14
    call    sub_4CDA00
    mov     ecx, dword_51FF14
    mov     eax, [ecx+28Ch]
    test    eax, eax
    jz      short loc_4CE17F
    call    eax

    loc_4CE17F:                             ; CODE XREF: .text:004CE048j
                                            ; .text:004CE059j ...
    pop     esi
    add     esp, 40h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE190 proc near                    ; CODE XREF: .text:004261CCp
    mov     eax, hWnd
    test    eax, eax
    jz      short locret_4CE1CC
    push    esi
    mov     esi, ds:SendMessageA
    push    0                               ; lParam
    push    0                               ; wParam
    push    10h                             ; Msg
    push    eax                             ; hWnd
    call    esi ; SendMessageA
    mov     eax, hWnd
    push    0                               ; lParam
    push    0                               ; wParam
    push    12h                             ; Msg
    push    eax                             ; hWnd
    call    esi ; SendMessageA
    push    1F4h                            ; dwMilliseconds
    call    sub_4B6B50
    mov     hWnd, 0
    pop     esi

    locret_4CE1CC:                          ; CODE XREF: sub_4CE190+7j
    retn
    sub_4CE190 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE1D0 proc near                    ; CODE XREF: .text:00426670p
    mov     ecx, hWnd
    xor     eax, eax
    test    ecx, ecx
    setnz   al
    retn
    sub_4CE1D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; BOOL __stdcall EnumFunc(HWND,LPARAM)
    EnumFunc proc near                      ; DATA XREF: sub_4CE260+93o

    ClassName= byte ptr -0C8h
    hWnd= dword ptr  4

    sub     esp, 0C8h
    lea     eax, [esp+0C8h+ClassName]
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+0D4h+hWnd]
    push    0C7h                            ; nMaxCount
    push    eax                             ; lpClassName
    push    edi                             ; hWnd
    call    ds:GetClassNameA
    mov     esi, offset aSje_cdplayercl     ; "SJE_CdPlayerClass"
    lea     eax, [esp+0D4h+ClassName]

    loc_4CE20A:                             ; CODE XREF: EnumFunc+4Cj
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CE232
    test    cl, cl
    jz      short loc_4CE22E
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CE232
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CE20A

    loc_4CE22E:                             ; CODE XREF: EnumFunc+36j
    xor     eax, eax
    jmp     short loc_4CE237
    ; ---------------------------------------------------------------------------

    loc_4CE232:                             ; CODE XREF: EnumFunc+32j EnumFunc+42j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4CE237:                             ; CODE XREF: EnumFunc+50j
    test    eax, eax
    jnz     short loc_4CE241
    mov     hWnd, edi

    loc_4CE241:                             ; CODE XREF: EnumFunc+59j
    pop     edi
    pop     esi
    mov     eax, 1
    pop     ebx
    add     esp, 0C8h
    retn    8
    EnumFunc endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE260 proc near                    ; CODE XREF: sub_47ED40+A5p
                                            ; sub_49E830+3AAp
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    xor     ebp, ebp
    push    edi
    cmp     [esi], ebp
    jz      short loc_4CE276
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4CE276:                             ; CODE XREF: sub_4CE260+Aj
    mov     ebx, 1
    mov     hWnd, ebp
    mov     dword_51FF14, esi
    mov     [esi+214h], bl
    xor     ecx, ecx

    loc_4CE28F:                             ; CODE XREF: sub_4CE260+4Aj
    mov     eax, ecx
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 3
    xor     eax, edx
    sub     eax, edx
    inc     al
    mov     [ecx+esi+214h], al
    inc     ecx
    cmp     ecx, 64h
    jl      short loc_4CE28F
    mov     edi, ds:mciSendStringA
    push    ebp                             ; hwndCallback
    push    ebp                             ; uReturnLength
    push    ebp                             ; lpstrReturnString
    push    offset aOpenCdaudio             ; lpstrCommand
    mov     [esi+204h], ebx
    mov     [esi+208h], ebp
    mov     [esi+210h], ebp
    mov     [esi+28Ch], ebp
    mov     [esi+1FCh], ebx
    mov     [esi+278h], ebp
    mov     [esi], ebp
    mov     [esi+200h], ebp
    mov     [esi+280h], ebp
    call    edi ; mciSendStringA
    cmp     eax, ebp
    jz      short loc_4CE313
    push    ebp                             ; lParam
    push    offset EnumFunc                 ; lpEnumFunc
    call    ds:EnumWindows
    push    ebp                             ; hwndCallback
    push    ebp                             ; uReturnLength
    push    ebp                             ; lpstrReturnString
    push    offset aOpenCdaudio             ; lpstrCommand
    call    edi ; mciSendStringA
    cmp     eax, ebp
    jz      short loc_4CE313
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4CE313:                             ; CODE XREF: sub_4CE260+90j
                                            ; sub_4CE260+AAj
    push    ebp                             ; hwndCallback
    push    ebp                             ; uReturnLength
    push    ebp                             ; lpstrReturnString
    push    offset aStopCdaudio             ; lpstrCommand
    call    edi ; mciSendStringA
    mov     ecx, [esi+200h]
    xor     eax, eax
    cmp     ecx, ebp
    mov     [esi+20Ch], ebp
    setnz   al
    mov     [esi+208h], eax
    mov     [esi+284h], ebp
    mov     ecx, dword_50B540
    push    ecx
    call    sub_4B64D0
    mov     edx, dword_50B544
    push    edx
    call    sub_4B64D0
    push    ebp                             ; hwndCallback
    push    ebp                             ; uReturnLength
    or      eax, 0FFFFFFFFh
    push    ebp                             ; lpstrReturnString
    push    offset aSetCdaudioTi_0          ; lpstrCommand
    mov     dword_50B544, eax
    mov     dword_50B540, eax
    call    edi ; mciSendStringA
    cmp     eax, ebp
    jz      short loc_4CE390
    cmp     [esi], ebp
    jz      short loc_4CE389
    push    ebp                             ; hwndCallback
    push    ebp                             ; uReturnLength
    push    ebp                             ; lpstrReturnString
    push    offset aStopCdaudio             ; lpstrCommand
    call    edi ; mciSendStringA
    push    ebp                             ; hwndCallback
    push    ebp                             ; uReturnLength
    push    ebp                             ; lpstrReturnString
    push    offset aCloseCdaudio            ; lpstrCommand
    call    edi ; mciSendStringA
    mov     [esi], ebp

    loc_4CE389:                             ; CODE XREF: sub_4CE260+111j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4CE390:                             ; CODE XREF: sub_4CE260+10Dj
    mov     ecx, esi
    mov     [esi+210h], ebp
    call    sub_4CDA00
    push    offset loc_4CE030
    mov     [esi+200h], eax
    call    sub_4B6B60
    mov     [esi], ebx
    mov     [esi+204h], ebx
    mov     [esi+208h], ebp
    mov     [esi+28Ch], ebp
    mov     [esi+1FCh], ebx
    mov     [esi+278h], ebp
    mov     [esi+27Ch], ebx
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    retn
    sub_4CE260 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE3E0 proc near                    ; CODE XREF: .text:0045C970p
                                            ; .text:0045CC75p ...

    arg_0= dword ptr  4

    mov     eax, ecx
    push    esi
    mov     esi, [esp+4+arg_0]
    push    edi
    mov     ecx, [eax+200h]
    lea     edi, [eax+215h]
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    retn    4
    sub_4CE3E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE410 proc near                    ; CODE XREF: sub_49E830+386p
                                            ; sub_4CEEE0+79p
    push    esi
    mov     esi, ecx
    cmp     dword ptr [esi], 0
    jz      short loc_4CE440
    push    edi
    mov     edi, ds:mciSendStringA
    push    0                               ; hwndCallback
    push    0                               ; uReturnLength
    push    0                               ; lpstrReturnString
    push    offset aStopCdaudio             ; lpstrCommand
    call    edi ; mciSendStringA
    push    0                               ; hwndCallback
    push    0                               ; uReturnLength
    push    0                               ; lpstrReturnString
    push    offset aCloseCdaudio            ; lpstrCommand
    call    edi ; mciSendStringA
    mov     dword ptr [esi], 0
    pop     edi

    loc_4CE440:                             ; CODE XREF: sub_4CE410+6j
    pop     esi
    retn
    sub_4CE410 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE450 proc near                    ; CODE XREF: sub_45D280+139p
                                            ; sub_45D280+192p ...
    mov     eax, [ecx+200h]
    retn
    sub_4CE450 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE460 proc near                    ; CODE XREF: sub_490FE0+176p

    var_24= dword ptr -24h
    strReturnString= byte ptr -20h

    sub     esp, 24h
    push    ebx
    push    esi
    mov     esi, ds:mciSendStringA
    push    0                               ; hwndCallback
    push    0                               ; uReturnLength
    push    0                               ; lpstrReturnString
    push    offset aSetCdaudioTime          ; lpstrCommand
    call    esi ; mciSendStringA
    push    0                               ; hwndCallback
    lea     eax, [esp+30h+strReturnString]
    push    20h                             ; uReturnLength
    push    eax                             ; lpstrReturnString
    push    offset aStatusCdaudioT          ; lpstrCommand
    call    esi ; mciSendStringA
    test    eax, eax
    jnz     loc_4CE517
    mov     esi, offset aAudio              ; "audio"
    lea     eax, [esp+2Ch+strReturnString]

    loc_4CE499:                             ; CODE XREF: sub_4CE460+5Bj
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CE4C1
    test    cl, cl
    jz      short loc_4CE4BD
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CE4C1
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CE499

    loc_4CE4BD:                             ; CODE XREF: sub_4CE460+45j
    xor     eax, eax
    jmp     short loc_4CE4C6
    ; ---------------------------------------------------------------------------

    loc_4CE4C1:                             ; CODE XREF: sub_4CE460+41j
                                            ; sub_4CE460+51j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4CE4C6:                             ; CODE XREF: sub_4CE460+5Fj
    test    eax, eax
    jnz     short loc_4CE4D0
    pop     esi
    pop     ebx
    add     esp, 24h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CE4D0:                             ; CODE XREF: sub_4CE460+68j
    mov     esi, offset aOther              ; "other"
    lea     eax, [esp+2Ch+strReturnString]

    loc_4CE4D9:                             ; CODE XREF: sub_4CE460+9Bj
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CE50E
    test    cl, cl
    jz      short loc_4CE4FD
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CE50E
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CE4D9

    loc_4CE4FD:                             ; CODE XREF: sub_4CE460+85j
    xor     eax, eax
    mov     [esp+2Ch+var_24], eax
    mov     eax, 1
    pop     esi
    pop     ebx
    add     esp, 24h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CE50E:                             ; CODE XREF: sub_4CE460+81j
                                            ; sub_4CE460+91j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh
    mov     [esp+2Ch+var_24], eax

    loc_4CE517:                             ; CODE XREF: sub_4CE460+2Aj
    pop     esi
    mov     eax, 1
    pop     ebx
    add     esp, 24h
    retn
    sub_4CE460 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    sub     esp, 60h
    lea     ecx, [esp+20h]
    push    eax
    push    offset aStatusCdaudioL          ; "status cdaudio length track %i"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+0]
    lea     eax, [esp+20h]
    push    0
    push    20h
    push    edx
    push    eax
    call    ds:mciSendStringA
    test    eax, eax
    jnz     short loc_4CE575
    lea     ecx, [esp+0]
    push    ecx
    call    _atoi
    add     esp, 4
    add     esp, 60h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CE575:                             ; CODE XREF: .text:004CE560j
    xor     eax, eax
    add     esp, 60h
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE580 proc near                    ; CODE XREF: .text:0045C3DEp
                                            ; sub_45C3F0+106p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, [ecx+200h]
    cmp     eax, edx
    jg      short locret_4CE594
    mov     [ecx+204h], eax

    locret_4CE594:                          ; CODE XREF: sub_4CE580+Cj
    retn    4
    sub_4CE580 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE5A0 proc near                    ; CODE XREF: .text:0045CE57p
                                            ; sub_45D280+42Cp ...
    mov     eax, [ecx+204h]
    retn
    sub_4CE5A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_4CE5B0:                             ; DATA XREF: .text:004CE64Do
    mov     eax, dword_50B540
    push    eax
    call    sub_4B64D0
    mov     ecx, dword_51FF14
    mov     dword_50B540, 0FFFFFFFFh
    call    sub_4CDB40
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    loc_4CE5E0:                             ; DATA XREF: sub_4CE690+E0o
    mov     ecx, dword_51FF14
    mov     eax, dword_51FF10
    add     eax, [ecx+284h]
    test    eax, eax
    mov     dword_51FF10, eax
    jg      short loc_4CE66B
    mov     eax, dword_50B544
    push    eax
    call    sub_4B64D0
    mov     ecx, dword_51FF14
    mov     dword_50B544, 0FFFFFFFFh
    mov     dword_51FF10, 0
    push    1
    mov     dword ptr [ecx+284h], 0
    mov     edx, dword_51FF10
    mov     ecx, dword_51FF14
    push    edx
    call    sub_4D00D0
    mov     ecx, dword_51FF14
    mov     eax, [ecx+278h]
    test    eax, eax
    jnz     short loc_4CE663
    push    offset loc_4CE5B0
    push    0
    push    78h
    call    sub_4B63F0
    mov     dword_50B540, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CE663:                             ; CODE XREF: .text:004CE64Bj
    call    sub_4CDB40
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CE66B:                             ; CODE XREF: .text:004CE5F8j
    push    1
    push    eax
    call    sub_4D00D0
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE680 proc near                    ; CODE XREF: sub_490FE0+60p
                                            ; sub_494E70+50p ...
    mov     eax, [ecx+278h]
    retn
    sub_4CE680 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE690 proc near                    ; CODE XREF: sub_4175E0+16p
                                            ; sub_41EC50+12Ep ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    mov     ecx, [esp+arg_0]
    mov     eax, [esi+278h]
    cmp     eax, ecx
    jz      loc_4CE78E
    test    eax, eax
    jl      short loc_4CE6B6
    mov     edx, [esi+208h]
    mov     dword_51FF20[eax*4], edx

    loc_4CE6B6:                             ; CODE XREF: sub_4CE690+17j
    mov     edx, [esi+1FCh]
    mov     [esi+278h], ecx
    cmp     edx, 4
    jz      short loc_4CE6D5
    cmp     ecx, 2
    jz      short loc_4CE6D5
    cmp     ecx, 3
    jnz     loc_4CE78E

    loc_4CE6D5:                             ; CODE XREF: sub_4CE690+35j
                                            ; sub_4CE690+3Aj
    mov     ecx, [esi+20h]
    cmp     eax, 4
    mov     eax, dword_50B544
    mov     dword_51FF10, ecx
    jnz     short loc_4CE72D
    test    eax, eax
    jl      short loc_4CE6FC
    push    eax
    call    sub_4B64D0
    mov     dword_50B544, 0FFFFFFFFh

    loc_4CE6FC:                             ; CODE XREF: sub_4CE690+5Aj
    mov     eax, dword_50B540
    test    eax, eax
    jl      short loc_4CE715
    push    eax
    call    sub_4B64D0
    mov     dword_50B540, 0FFFFFFFFh

    loc_4CE715:                             ; CODE XREF: sub_4CE690+73j
    mov     edx, [esi+20h]
    push    0
    push    edx
    mov     ecx, esi
    call    sub_4D00D0
    mov     ecx, esi
    call    sub_4CDB40
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CE72D:                             ; CODE XREF: sub_4CE690+56j
    test    eax, eax
    jl      short loc_4CE761
    push    eax
    call    sub_4B64D0
    mov     eax, dword_50B540
    mov     dword_50B544, 0FFFFFFFFh
    push    eax
    call    sub_4B64D0
    mov     ecx, esi
    mov     dword_50B540, 0FFFFFFFFh
    call    sub_4CDB40
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CE761:                             ; CODE XREF: sub_4CE690+9Fj
    mov     ecx, [esi+20h]
    mov     eax, 0C71C71C7h
    imul    ecx
    sar     edx, 2
    mov     ecx, edx
    push    offset loc_4CE5E0
    shr     ecx, 1Fh
    add     edx, ecx
    push    0
    push    2
    mov     [esi+284h], edx
    call    sub_4B63F0
    mov     dword_50B544, eax

    loc_4CE78E:                             ; CODE XREF: sub_4CE690+Fj
                                            ; sub_4CE690+3Fj
    pop     esi
    retn    4
    sub_4CE690 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE7A0 proc near                    ; CODE XREF: .text:0045C997p
                                            ; .text:0045CC9Cp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     [ecx+1FCh], eax
    mov     eax, 1
    retn    4
    sub_4CE7A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE7C0 proc near                    ; CODE XREF: .text:0045C561p
                                            ; sub_45D280+4BCp ...

    arg_0= dword ptr  4
    arg_4= byte ptr  8

    mov     edx, [esp+arg_0]
    mov     al, [esp+arg_4]
    mov     [ecx+edx+214h], al
    retn    8
    sub_4CE7C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE7E0 proc near                    ; CODE XREF: sub_45C3F0+6Bp
                                            ; .text:0045CE6Cp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     al, [ecx+eax+214h]
    retn    4
    sub_4CE7E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE7F0 proc near                    ; CODE XREF: .text:0045D0F7p
                                            ; .text:0045D109p
    mov     eax, [ecx+208h]
    retn
    sub_4CE7F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE800 proc near                    ; CODE XREF: sub_497F40+559p

    strReturnString= byte ptr -40h

    sub     esp, 40h
    lea     eax, [esp+40h+strReturnString]
    push    0                               ; hwndCallback
    push    40h                             ; uReturnLength
    push    eax                             ; lpstrReturnString
    push    offset aStatusCdaudioM          ; lpstrCommand
    call    ds:mciSendStringA
    test    eax, eax
    jnz     short loc_4CE86F
    push    esi
    push    ebx
    mov     esi, offset aPlaying            ; "playing"
    lea     eax, [esp+48h+strReturnString]

    loc_4CE826:                             ; CODE XREF: sub_4CE800+48j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CE85B
    test    cl, cl
    jz      short loc_4CE84A
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CE85B
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CE826

    loc_4CE84A:                             ; CODE XREF: sub_4CE800+32j
    xor     eax, eax
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    pop     ebx
    mov     eax, ecx
    pop     esi
    add     esp, 40h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CE85B:                             ; CODE XREF: sub_4CE800+2Ej
                                            ; sub_4CE800+3Ej
    sbb     eax, eax
    pop     ebx
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    pop     esi
    add     esp, 40h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CE86F:                             ; CODE XREF: sub_4CE800+19j
    xor     eax, eax
    add     esp, 40h
    retn
    sub_4CE800 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 20h
    lea     eax, [esp+0]
    push    0
    push    20h
    push    eax
    push    offset aStatusCdaudioP          ; "status cdaudio position"
    call    ds:mciSendStringA
    test    eax, eax
    jnz     short loc_4CE8AC
    lea     ecx, [esp+0]
    push    ecx
    call    _atoi
    add     esp, 4
    add     esp, 20h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CE8AC:                             ; CODE XREF: .text:004CE899j
    xor     eax, eax
    add     esp, 20h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE8C0 proc near                    ; CODE XREF: sub_45D280+1DBp

    arg_0= dword ptr  8

    push    esi
    mov     esi, ecx
    mov     ecx, [esi+200h]
    test    ecx, ecx
    jnz     short loc_4CE8D3
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CE8D3:                             ; CODE XREF: sub_4CE8C0+Bj
    mov     eax, [esp+arg_0]
    cmp     eax, ecx
    jle     short loc_4CE8E0
    cdq
    idiv    ecx
    mov     eax, edx

    loc_4CE8E0:                             ; CODE XREF: sub_4CE8C0+19j
    cmp     dword ptr [esi+20Ch], 1
    jnz     short loc_4CE8FD
    push    1
    push    eax
    mov     ecx, esi
    call    sub_4CEB60
    mov     eax, [esi+208h]
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CE8FD:                             ; CODE XREF: sub_4CE8C0+27j
    mov     [esi+208h], eax
    pop     esi
    retn    4
    sub_4CE8C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CE910 proc near                    ; CODE XREF: sub_4609B0+A1p
                                            ; sub_460CC0+152p

    var_1FC= dword ptr -1FCh
    var_1F8= dword ptr -1F8h
    strCommand= byte ptr -1F4h
    var_190= dword ptr -190h
    strReturnString= byte ptr -0C8h
    arg_0= dword ptr  4

    sub     esp, 1FCh
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    mov     [esp+20Ch+var_1F8], esi
    mov     eax, [esi+27Ch]
    test    eax, eax
    jnz     short loc_4CE93C
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1FCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CE93C:                             ; CODE XREF: sub_4CE910+18j
    mov     eax, [esi+20Ch]
    test    eax, eax
    jnz     short loc_4CE958
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1FCh
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4CE958:                             ; CODE XREF: sub_4CE910+34j
    call    sub_4B6220
    mov     ebx, [eax+40h]
    mov     eax, [esp+20Ch+arg_0]
    mov     ebp, ds:mciSendStringA
    test    eax, eax
    jnz     loc_4CEB1E
    lea     eax, [esp+20Ch+strCommand]
    push    offset aStatusCdaudioC          ; "status cdaudio current track"
    push    eax
    call    _sprintf
    add     esp, 8
    lea     ecx, [esp+20Ch+strReturnString]
    lea     edx, [esp+20Ch+strCommand]
    push    ebx                             ; hwndCallback
    push    0C8h                            ; uReturnLength
    push    ecx                             ; lpstrReturnString
    push    edx                             ; lpstrCommand
    call    ebp ; mciSendStringA
    lea     eax, [esp+20Ch+strReturnString]
    push    eax                             ; char *
    call    _atoi
    add     esp, 4
    lea     ecx, [esp+20Ch+var_190]
    mov     edi, eax
    push    offset aPlayCdaudio             ; "play cdaudio"
    push    ecx
    mov     [esp+214h+var_1FC], edi
    call    _sprintf
    mov     eax, [esi+200h]
    add     esp, 8
    cmp     edi, eax
    jge     loc_4CEAE0
    mov     edi, offset aFrom               ; " from "
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+20Ch+var_190]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    offset aStatusCdaudioP          ; "status cdaudio position"
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     eax, [esp+210h+strCommand]
    and     ecx, 3
    push    eax
    rep movsb
    call    _sprintf
    add     esp, 8
    lea     ecx, [esp+20Ch+strReturnString]
    lea     edx, [esp+20Ch+strCommand]
    push    ebx                             ; hwndCallback
    push    0C8h                            ; uReturnLength
    push    ecx                             ; lpstrReturnString
    push    edx                             ; lpstrCommand
    call    ebp ; mciSendStringA
    lea     edi, [esp+20Ch+strReturnString]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+20Ch+var_190]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     eax, [esp+20Ch+var_1FC]
    mov     ecx, edx
    and     ecx, 3
    inc     eax
    rep movsb
    push    eax
    lea     ecx, [esp+210h+strCommand]
    push    offset aStatusCdaudi_0          ; "status cdaudio position track %i"
    push    ecx
    call    _sprintf
    add     esp, 0Ch
    lea     edx, [esp+20Ch+strReturnString]
    lea     eax, [esp+20Ch+strCommand]
    push    ebx                             ; hwndCallback
    push    0C8h                            ; uReturnLength
    push    edx                             ; lpstrReturnString
    push    eax                             ; lpstrCommand
    call    ebp ; mciSendStringA
    mov     edi, offset aTo                 ; " to "
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+20Ch+var_190]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    lea     edx, [esp+20Ch+var_190]
    and     ecx, 3
    rep movsb
    lea     edi, [esp+20Ch+strReturnString]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4CEAE0:                             ; CODE XREF: sub_4CE910+BCj
    mov     edi, offset aNotify             ; " notify"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+20Ch+var_190]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     eax, [esp+20Ch+var_1F8]
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     dword ptr [eax+20Ch], 1
    jmp     short loc_4CEB3A
    ; ---------------------------------------------------------------------------

    loc_4CEB1E:                             ; CODE XREF: sub_4CE910+5Fj
    lea     ecx, [esp+20Ch+var_190]
    push    offset aPauseCdaudio            ; "pause cdaudio"
    push    ecx
    call    _sprintf
    add     esp, 8
    mov     dword ptr [esi+20Ch], 2

    loc_4CEB3A:                             ; CODE XREF: sub_4CE910+20Cj
    push    ebx                             ; hwndCallback
    push    0                               ; uReturnLength
    lea     edx, [esp+214h+var_190]
    push    0                               ; lpstrReturnString
    push    edx                             ; lpstrCommand
    call    ebp ; mciSendStringA
    xor     ecx, ecx
    pop     edi
    test    eax, eax
    setz    cl
    pop     esi
    pop     ebp
    mov     eax, ecx
    pop     ebx
    add     esp, 1FCh
    retn    4
    sub_4CE910 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CEB60 proc near                    ; CODE XREF: .text:00416808p
                                            ; sub_45D280+F6p ...

    var_11C= dword ptr -11Ch
    strReturnString= byte ptr -108h
    strCommand= byte ptr -0C8h
    arg_0= dword ptr  4

    sub     esp, 11Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     eax, [edi+27Ch]
    test    eax, eax
    jnz     short loc_4CEB88
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 11Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CEB88:                             ; CODE XREF: sub_4CEB60+14j
    mov     ebp, [esp+12Ch+arg_0]
    mov     dword ptr [edi+20Ch], 1
    test    ebp, ebp
    jnz     short loc_4CEBB6
    mov     ecx, edi
    call    sub_4CDB40
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 11Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CEBB6:                             ; CODE XREF: sub_4CEB60+3Bj
    push    0                               ; hwndCallback
    lea     eax, [esp+130h+strReturnString]
    push    40h                             ; uReturnLength
    push    eax                             ; lpstrReturnString
    push    offset aStatusCdaudioM          ; lpstrCommand
    call    ds:mciSendStringA
    test    eax, eax
    jnz     short loc_4CEC18
    mov     esi, offset aPlaying            ; "playing"
    lea     eax, [esp+12Ch+strReturnString]

    loc_4CEBD7:                             ; CODE XREF: sub_4CEB60+99j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CEC08
    test    cl, cl
    jz      short loc_4CEBFB
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4CEC08
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4CEBD7

    loc_4CEBFB:                             ; CODE XREF: sub_4CEB60+83j
    xor     eax, eax
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CEC1A
    ; ---------------------------------------------------------------------------

    loc_4CEC08:                             ; CODE XREF: sub_4CEB60+7Fj
                                            ; sub_4CEB60+8Fj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh
    xor     ecx, ecx
    test    eax, eax
    setz    cl
    mov     eax, ecx
    jmp     short loc_4CEC1A
    ; ---------------------------------------------------------------------------

    loc_4CEC18:                             ; CODE XREF: sub_4CEB60+6Cj
    xor     eax, eax

    loc_4CEC1A:                             ; CODE XREF: sub_4CEB60+A6j
                                            ; sub_4CEB60+B6j
    test    eax, eax
    jz      short loc_4CEC38
    cmp     ebp, [edi+208h]
    jnz     short loc_4CEC38
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 11Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CEC38:                             ; CODE XREF: sub_4CEB60+BCj
                                            ; sub_4CEB60+C4j
    mov     ecx, [edi+280h]
    mov     [edi+208h], ebp
    add     ebp, ecx
    call    sub_4B6220
    mov     edx, [edi+20h]
    mov     ebx, [eax+40h]
    push    1
    push    edx
    mov     ecx, edi
    call    sub_4D00D0
    push    0                               ; hwndCallback
    push    0                               ; uReturnLength
    push    0                               ; lpstrReturnString
    push    offset aSetCdaudioTime          ; lpstrCommand
    call    ds:mciSendStringA
    test    eax, eax
    jz      short loc_4CEC7F
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 11Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4CEC7F:                             ; CODE XREF: sub_4CEB60+10Ej
    push    ebp
    lea     eax, [esp+130h+strCommand]
    push    offset aPlayCdaudioFro          ; "play cdaudio from %i"
    push    eax
    call    _sprintf
    mov     eax, [edi+200h]
    add     esp, 0Ch
    cmp     ebp, eax
    jge     short loc_4CECDD
    inc     ebp
    lea     ecx, [esp+12Ch+var_11C]
    push    ebp
    push    offset aToI                     ; " to %i"
    push    ecx
    call    _sprintf
    lea     edi, [esp+138h+var_11C]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+12Ch+strCommand]
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb

    loc_4CECDD:                             ; CODE XREF: sub_4CEB60+13Aj
    mov     edi, offset aNotify             ; " notify"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+12Ch+strCommand]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    ebx                             ; hwndCallback
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    push    eax                             ; uReturnLength
    and     ecx, 3
    push    eax                             ; lpstrReturnString
    rep movsb
    mov     edi, ds:mciSendStringA
    lea     eax, [esp+138h+strCommand]
    push    eax                             ; lpstrCommand
    call    edi ; mciSendStringA
    push    0                               ; hwndCallback
    push    0                               ; uReturnLength
    push    0                               ; lpstrReturnString
    push    offset aSetCdaudioTi_0          ; lpstrCommand
    mov     esi, eax
    call    edi ; mciSendStringA
    xor     eax, eax
    pop     edi
    test    esi, esi
    pop     esi
    pop     ebp
    setz    al
    pop     ebx
    add     esp, 11Ch
    retn    8
    sub_4CEB60 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CED40 proc near                    ; CODE XREF: .text:00416818p
                                            ; sub_45D280+27p ...
    push    esi
    push    edi
    push    0                               ; hwndCallback
    push    0                               ; uReturnLength
    push    0                               ; lpstrReturnString
    mov     esi, ecx
    push    offset aStopCdaudio             ; lpstrCommand
    call    ds:mciSendStringA
    mov     edi, eax
    mov     eax, [esi+200h]
    test    eax, eax
    jz      short loc_4CED6D
    mov     dword ptr [esi+208h], 1
    jmp     short loc_4CED77
    ; ---------------------------------------------------------------------------

    loc_4CED6D:                             ; CODE XREF: sub_4CED40+1Fj
    mov     dword ptr [esi+208h], 0

    loc_4CED77:                             ; CODE XREF: sub_4CED40+2Bj
    mov     dword ptr [esi+20Ch], 0
    mov     dword ptr [esi+284h], 0
    mov     eax, dword_50B540
    push    eax
    call    sub_4B64D0
    mov     ecx, dword_50B544
    push    ecx
    call    sub_4B64D0
    or      eax, 0FFFFFFFFh
    mov     dword_50B544, eax
    mov     dword_50B540, eax
    xor     eax, eax
    test    edi, edi
    pop     edi
    pop     esi
    setz    al
    retn
    sub_4CED40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CEDC0 proc near                    ; CODE XREF: sub_45D280+BAp
                                            ; sub_490FE0+A5p ...

    hwndCallback= dword ptr  4

    mov     eax, [esp+hwndCallback]
    push    esi
    mov     esi, ecx
    test    eax, eax
    mov     [esi+27Ch], eax
    jnz     short loc_4CEE37
    push    eax                             ; hwndCallback
    push    eax                             ; uReturnLength
    push    eax                             ; lpstrReturnString
    push    offset aStopCdaudio             ; lpstrCommand
    call    ds:mciSendStringA
    mov     eax, [esi+200h]
    test    eax, eax
    jz      short loc_4CEDF5
    mov     dword ptr [esi+208h], 1
    jmp     short loc_4CEDFF
    ; ---------------------------------------------------------------------------

    loc_4CEDF5:                             ; CODE XREF: sub_4CEDC0+27j
    mov     dword ptr [esi+208h], 0

    loc_4CEDFF:                             ; CODE XREF: sub_4CEDC0+33j
    mov     dword ptr [esi+20Ch], 0
    mov     dword ptr [esi+284h], 0
    mov     eax, dword_50B540
    push    eax
    call    sub_4B64D0
    mov     ecx, dword_50B544
    push    ecx
    call    sub_4B64D0
    or      eax, 0FFFFFFFFh
    mov     dword_50B544, eax
    mov     dword_50B540, eax

    loc_4CEE37:                             ; CODE XREF: sub_4CEDC0+Fj
    pop     esi
    retn    4
    sub_4CEDC0 endp

    ; ---------------------------------------------------------------------------
    align 8
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CEE50 proc near                    ; CODE XREF: sub_49E830+21Bp
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    xor     ebx, ebx
    mov     ecx, 8
    lea     edi, [esi+1C4h]
    xor     eax, eax
    mov     [esi], ebx
    mov     [esi+4], ebx
    mov     [esi+290h], ebx
    mov     dword ptr [esi+8], 3F800000h
    mov     dword ptr [esi+0Ch], 60AD78ECh
    mov     [esi+24h], ebx
    mov     [esi+28h], ebx
    rep stosd
    mov     ecx, esi
    call    sub_4CFF30
    mov     dword ptr [esi+2Ch], 8
    mov     [esi+30h], ebx
    mov     dword ptr [esi+34h], 1
    lea     eax, [esi+0B8h]
    mov     ecx, 20h

    loc_4CEEA8:                             ; CODE XREF: sub_4CEE50+67j
    mov     [eax-80h], ebx
    mov     [eax], ebx
    mov     [eax+80h], ebx
    add     eax, 4
    dec     ecx
    jnz     short loc_4CEEA8
    mov     ecx, esi
    mov     [esi+1E4h], ebx
    call    sub_4D0040
    mov     [esi+20h], eax
    mov     dword ptr [esi+288h], 0FFFFFFFFh
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_4CEE50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CEEE0 proc near                    ; CODE XREF: sub_47EEE0+C4p
                                            ; sub_4CEF90+E0p
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    mov     ebx, 8
    lea     esi, [edi+1C4h]

    loc_4CEEF0:                             ; CODE XREF: sub_4CEEE0+28j
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4CEF04
    push    eax
    mov     ecx, edi
    call    sub_4CF4D0
    mov     dword ptr [esi], 0

    loc_4CEF04:                             ; CODE XREF: sub_4CEEE0+14j
    add     esi, 4
    dec     ebx
    jnz     short loc_4CEEF0
    mov     eax, [edi+288h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4CEF25
    push    eax
    call    sub_4B64D0
    mov     dword ptr [edi+288h], 0FFFFFFFFh

    loc_4CEF25:                             ; CODE XREF: sub_4CEEE0+33j
    mov     eax, [edi+1E4h]
    test    eax, eax
    jz      short loc_4CEF57
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+48h]
    mov     eax, [edi+1E4h]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+8]
    mov     eax, [edi+1E8h]
    mov     dword ptr [edi+1E4h], 0
    push    eax
    call    sub_4BB5D0

    loc_4CEF57:                             ; CODE XREF: sub_4CEEE0+4Dj
    mov     ecx, edi
    call    sub_4CE410
    mov     eax, [edi+28h]
    test    eax, eax
    jz      short loc_4CEF6B
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+8]

    loc_4CEF6B:                             ; CODE XREF: sub_4CEEE0+83j
    mov     eax, [edi+24h]
    test    eax, eax
    jz      short loc_4CEF78
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+8]

    loc_4CEF78:                             ; CODE XREF: sub_4CEEE0+90j
    mov     dword ptr [edi+28h], 0
    mov     dword ptr [edi+24h], 0
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_4CEEE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CEF90 proc near                    ; CODE XREF: sub_47ED40+70p

    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= word ptr -40h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    arg_0= dword ptr  4

    sub     esp, 28h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    push    edi
    xor     ebx, ebx
    mov     eax, [esi+24h]
    lea     edi, [esi+24h]
    cmp     eax, ebx
    jnz     short loc_4CEFFE
    push    ebx
    push    edi
    push    ebx
    call    DirectSoundCreate
    cmp     eax, ebx
    jnz     loc_4CF05D
    mov     eax, [edi]
    mov     edx, [esp+44h+arg_0]
    push    2
    push    edx
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+18h]
    cmp     eax, ebx
    jnz     loc_4CF05D
    mov     edi, [edi]
    lea     ecx, [esi+28h]
    push    ebx
    lea     edx, [esp+28h]
    mov     dword ptr [esp+28h], 14h
    mov     dword ptr [esp+2Ch], 1
    mov     [esp+30h], ebx
    mov     [esp+34h], ebx
    mov     [esp+38h], ebx
    mov     eax, [edi]
    push    ecx
    push    edx
    push    edi
    call    dword ptr [eax+0Ch]
    cmp     eax, ebx
    jnz     short loc_4CF05D

    loc_4CEFFE:                             ; CODE XREF: sub_4CEF90+13j
    mov     ebp, [esp+40h]
    mov     edi, [esp+44h]
    mov     eax, ebp
    mov     ebx, [esp+38h+arg_0]
    cdq
    and     edx, 7
    mov     ecx, ebx
    add     eax, edx
    mov     word ptr [esp+38h+var_28], 1
    sar     eax, 3
    imul    eax, edi
    mov     word ptr [esp+38h+var_1C], ax
    mov     eax, [esp+38h+var_1C]
    and     eax, 0FFFFh
    mov     word ptr [esp+38h+var_28+2], di
    imul    ecx, eax
    mov     eax, [esi+28h]
    mov     [esp+38h+var_20], ecx
    lea     ecx, [esp+38h+var_28]
    mov     [esp+38h+var_24], ebx
    mov     word ptr [esp+38h+var_1C+2], bp
    mov     word ptr [esp+20h], 12h
    mov     edx, [eax]
    push    ecx
    push    eax
    call    dword ptr [edx+38h]
    test    eax, eax
    jz      short loc_4CF081

    loc_4CF05D:                             ; CODE XREF: sub_4CEF90+1Fj
                                            ; sub_4CEF90+36j ...
    cmp     eax, 88780078h
    jnz     short loc_4CF06E
    mov     dword ptr [esi+290h], 1

    loc_4CF06E:                             ; CODE XREF: sub_4CEF90+D2j
    mov     ecx, esi
    call    sub_4CEEE0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4CF081:                             ; CODE XREF: sub_4CEF90+CBj
    mov     [esi+1C0h], edi
    mov     [esi+1B8h], ebx
    mov     [esi+1BCh], ebp
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 28h
    retn    10h
    sub_4CEF90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF0B0 proc near                    ; CODE XREF: sub_49E830+458p
                                            ; .text:004CF804p ...

    var_14= dword ptr -14h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4

    push    ecx
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    mov     ebx, 8
    lea     esi, [edi+1C4h]

    loc_4CF0C1:                             ; CODE XREF: sub_4CF0B0+44j
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4CF0F0
    mov     eax, [eax]
    lea     edx, [esp+10h+var_4]
    push    edx
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+24h]
    test    eax, eax
    jnz     short loc_4CF0E0
    mov     eax, [esp+10h+var_4]
    test    eax, eax
    jnz     short loc_4CF0F0

    loc_4CF0E0:                             ; CODE XREF: sub_4CF0B0+26j
    mov     eax, [esi]
    mov     ecx, edi
    push    eax
    call    sub_4CF4D0
    mov     dword ptr [esi], 0

    loc_4CF0F0:                             ; CODE XREF: sub_4CF0B0+15j
                                            ; sub_4CF0B0+2Ej
    add     esi, 4
    dec     ebx
    jnz     short loc_4CF0C1
    lea     esi, [edi+38h]
    mov     ebx, 20h

    loc_4CF0FE:                             ; CODE XREF: sub_4CF0B0+7Cj
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4CF128
    mov     ecx, [eax]
    lea     edx, [esp+10h+var_4]
    push    edx
    push    eax
    call    dword ptr [ecx+24h]
    test    eax, eax
    jnz     short loc_4CF11B
    mov     eax, [esp+10h+var_4]
    test    eax, eax
    jnz     short loc_4CF128

    loc_4CF11B:                             ; CODE XREF: sub_4CF0B0+61j
    mov     dword ptr [esi], 0
    mov     eax, [edi+30h]
    dec     eax
    mov     [edi+30h], eax

    loc_4CF128:                             ; CODE XREF: sub_4CF0B0+52j
                                            ; sub_4CF0B0+69j
    add     esi, 4
    dec     ebx
    jnz     short loc_4CF0FE
    mov     eax, [edi+1E4h]
    test    eax, eax
    jz      short loc_4CF13F
    mov     ecx, edi
    call    sub_4CFBC0

    loc_4CF13F:                             ; CODE XREF: sub_4CF0B0+86j
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    sub_4CF0B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF150 proc near                    ; CODE XREF: sub_47F750+11p
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    mov     ebx, 20h
    lea     esi, [edi+38h]

    loc_4CF15D:                             ; CODE XREF: sub_4CF150+2Aj
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4CF176
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+48h]
    mov     dword ptr [esi], 0
    mov     eax, [edi+30h]
    dec     eax
    mov     [edi+30h], eax

    loc_4CF176:                             ; CODE XREF: sub_4CF150+11j
    add     esi, 4
    dec     ebx
    jnz     short loc_4CF15D
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_4CF150 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF180 proc near                    ; CODE XREF: sub_4CF570+4Ep
    push    ebx
    mov     ebx, ecx
    push    ebp
    push    esi
    push    edi
    xor     esi, esi
    lea     eax, [ebx+138h]

    loc_4CF18E:                             ; CODE XREF: sub_4CF180+24j
    mov     ecx, [eax-100h]
    test    ecx, ecx
    jz      short loc_4CF19D
    test    byte ptr [eax], 1
    jz      short loc_4CF1A6

    loc_4CF19D:                             ; CODE XREF: sub_4CF180+16j
    inc     esi
    add     eax, 4
    cmp     esi, 20h
    jl      short loc_4CF18E

    loc_4CF1A6:                             ; CODE XREF: sub_4CF180+1Bj
    lea     ecx, [esi+1]
    cmp     ecx, 20h
    jge     short loc_4CF1EC
    mov     edi, 0FFFFFEC8h
    lea     edx, ds:0[esi*4]
    lea     eax, [ebx+ecx*4+138h]
    sub     edi, ebx

    loc_4CF1C3:                             ; CODE XREF: sub_4CF180+6Aj
    mov     ebp, [eax-100h]
    test    ebp, ebp
    jz      short loc_4CF1E3
    test    byte ptr [eax], 1
    jnz     short loc_4CF1E3
    mov     ebp, [eax-80h]
    cmp     ebp, [ebx+edx+0B8h]
    jge     short loc_4CF1E3
    mov     esi, ecx
    lea     edx, [edi+eax]

    loc_4CF1E3:                             ; CODE XREF: sub_4CF180+4Bj
                                            ; sub_4CF180+50j ...
    inc     ecx
    add     eax, 4
    cmp     ecx, 20h
    jl      short loc_4CF1C3

    loc_4CF1EC:                             ; CODE XREF: sub_4CF180+2Cj
    mov     eax, [ebx+esi*4+38h]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+48h]
    mov     dword ptr [ebx+esi*4+38h], 0
    mov     eax, [ebx+30h]
    dec     eax
    pop     edi
    pop     esi
    mov     [ebx+30h], eax
    pop     ebp
    pop     ebx
    retn
    sub_4CF180 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF210 proc near                    ; CODE XREF: WriteRegistrySettings_1+4DDp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     [ecx+2Ch], eax
    retn    4
    sub_4CF210 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF220 proc near                    ; CODE XREF: WriteRegistrySettings_2+1A5p
    mov     eax, [ecx+2Ch]
    retn
    sub_4CF220 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF230 proc near                    ; CODE XREF: .text:004CF841p

    var_70= dword ptr -70h
    var_5C= dword ptr -5Ch
    var_3C= dword ptr -3Ch
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= word ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 2Ch
    xor     eax, eax
    push    ebx
    mov     ebx, [esp+30h+arg_C]
    mov     [esp+30h+var_2C], eax
    mov     [esp+30h+var_8], eax
    lea     eax, [esp+30h+var_28]
    mov     [esp+30h+var_4], eax
    mov     eax, ebx
    cdq
    and     edx, 7
    push    ebp
    push    esi
    add     eax, edx
    push    edi
    mov     edi, [esp+3Ch+arg_10]
    sar     eax, 3
    imul    eax, edi
    mov     esi, [esp+3Ch+arg_8]
    mov     word ptr [esp+3Ch+var_1C], ax
    mov     edx, [esp+3Ch+var_1C]
    mov     [esp+3Ch+var_24], esi
    and     edx, 0FFFFh
    mov     ebp, [esp+3Ch+arg_4]
    imul    esi, edx
    mov     eax, [ecx+24h]
    lea     edx, [esp+3Ch+var_2C]
    push    0
    push    edx
    lea     edx, [esp+44h+var_14]
    mov     [esp+44h+var_14], 14h
    mov     [esp+44h+var_10], 92h
    mov     [esp+44h+var_C], ebp
    mov     word ptr [esp+44h+var_28], 1
    mov     word ptr [esp+44h+var_28+2], di
    mov     [esp+44h+var_20], esi
    mov     word ptr [esp+44h+var_1C+2], bx
    mov     [esp+44h+var_18], 12h
    mov     ecx, [eax]
    push    edx
    push    eax
    call    dword ptr [ecx+0Ch]
    test    eax, eax
    jnz     short loc_4CF31D
    mov     eax, [esp+3Ch+var_2C]
    push    0
    push    0
    lea     edx, [esp+44h+arg_4]
    mov     ecx, [eax]
    push    0
    push    edx
    lea     edx, [esp+4Ch+arg_10]
    push    edx
    push    ebp
    push    0
    push    eax
    call    dword ptr [ecx+2Ch]
    test    eax, eax
    jnz     short loc_4CF31D
    mov     ecx, [esp+3Ch+arg_4]
    mov     esi, [esp+3Ch+arg_0]
    mov     edi, [esp+3Ch+arg_10]
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    0
    and     ecx, 3
    push    0
    rep movsb
    mov     edx, [esp+44h+arg_4]
    mov     eax, [esp+44h+var_2C]
    push    edx
    mov     edx, [esp+48h+arg_10]
    mov     ecx, [eax]
    push    edx
    push    eax
    call    dword ptr [ecx+4Ch]
    test    eax, eax
    jz      short loc_4CF337

    loc_4CF31D:                             ; CODE XREF: sub_4CF230+94j
                                            ; sub_4CF230+B5j
    mov     eax, [esp+3Ch+var_2C]
    test    eax, eax
    jz      short loc_4CF32B
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+8]

    loc_4CF32B:                             ; CODE XREF: sub_4CF230+F3j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CF337:                             ; CODE XREF: sub_4CF230+EBj
    push    10h
    push    offset aDigitalAudioSa          ; "Digital Audio Sample"
    call    sub_4D83B0
    add     esp, 8
    mov     ecx, eax
    xor     edx, edx
    mov     [ecx], edx
    pop     edi
    pop     esi
    pop     ebp
    mov     [ecx+4], edx
    pop     ebx
    mov     [ecx+8], edx
    mov     [ecx+0Ch], edx
    mov     edx, [esp+2Ch+var_2C]
    mov     [eax], edx
    add     esp, 2Ch
    retn    14h
    sub_4CF230 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF370 proc near                    ; CODE XREF: sub_4CF8A0+41p
                                            ; sub_4D02A0+362p

    var_70= dword ptr -70h
    var_5C= dword ptr -5Ch
    var_3C= dword ptr -3Ch
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= word ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 2Ch
    xor     eax, eax
    push    ebx
    mov     ebx, [esp+30h+arg_C]
    mov     [esp+30h+var_2C], eax
    mov     [esp+30h+var_8], eax
    lea     eax, [esp+30h+var_28]
    mov     [esp+30h+var_4], eax
    mov     eax, ebx
    cdq
    and     edx, 7
    push    ebp
    push    esi
    add     eax, edx
    push    edi
    mov     edi, [esp+3Ch+arg_10]
    sar     eax, 3
    imul    eax, edi
    mov     esi, ecx
    mov     word ptr [esp+3Ch+var_1C], ax
    mov     edx, [esp+3Ch+var_1C]
    mov     ecx, [esp+3Ch+arg_8]
    and     edx, 0FFFFh
    mov     [esp+3Ch+var_24], ecx
    imul    ecx, edx
    mov     ebp, [esp+3Ch+arg_4]
    push    0
    push    0
    mov     [esp+44h+var_14], 14h
    mov     [esp+44h+var_10], 92h
    mov     [esp+44h+var_C], ebp
    mov     word ptr [esp+44h+var_28], 1
    mov     word ptr [esp+44h+var_28+2], di
    mov     [esp+44h+var_20], ecx
    mov     word ptr [esp+44h+var_1C+2], bx
    mov     [esp+44h+var_18], 12h
    call    __controlfp
    add     esp, 8
    mov     edi, eax
    push    18h
    push    18h
    call    __controlfp
    mov     eax, [esi+24h]
    add     esp, 8
    lea     edx, [esp+3Ch+var_2C]
    mov     ecx, [eax]
    push    0
    push    edx
    lea     edx, [esp+44h+var_14]
    push    edx
    push    eax
    call    dword ptr [ecx+0Ch]
    push    18h
    push    edi
    mov     esi, eax
    call    __controlfp
    add     esp, 8
    test    esi, esi
    jnz     short loc_4CF484
    mov     eax, [esp+3Ch+var_2C]
    push    esi
    push    esi
    lea     edx, [esp+44h+arg_4]
    mov     ecx, [eax]
    push    esi
    push    edx
    lea     edx, [esp+4Ch+arg_10]
    push    edx
    push    ebp
    push    esi
    push    eax
    call    dword ptr [ecx+2Ch]
    test    eax, eax
    jnz     short loc_4CF484
    mov     eax, [esp+3Ch+arg_4]
    mov     ecx, [esp+3Ch+arg_10]
    mov     edx, [esp+3Ch+arg_0]
    push    eax
    push    ecx
    push    edx
    call    sub_4BB7C0
    mov     edx, [esp+3Ch+arg_4]
    push    0
    mov     esi, eax
    mov     eax, [esp+40h+var_2C]
    push    0
    push    edx
    mov     edx, [esp+48h+arg_10]
    mov     ecx, [eax]
    push    edx
    push    eax
    call    dword ptr [ecx+4Ch]
    test    eax, eax
    jnz     short loc_4CF484
    cmp     esi, [esp+3Ch+arg_4]
    jnb     short loc_4CF49E

    loc_4CF484:                             ; CODE XREF: sub_4CF370+BDj
                                            ; sub_4CF370+DAj ...
    mov     eax, [esp+3Ch+var_2C]
    test    eax, eax
    jz      short loc_4CF492
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+8]

    loc_4CF492:                             ; CODE XREF: sub_4CF370+11Aj
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CF49E:                             ; CODE XREF: sub_4CF370+112j
    push    10h
    push    offset aDigitalAudioSa          ; "Digital Audio Sample"
    call    sub_4D83B0
    add     esp, 8
    mov     ecx, eax
    xor     edx, edx
    mov     [ecx], edx
    pop     edi
    pop     esi
    pop     ebp
    mov     [ecx+4], edx
    pop     ebx
    mov     [ecx+8], edx
    mov     [ecx+0Ch], edx
    mov     edx, [esp+2Ch+var_2C]
    mov     [eax], edx
    add     esp, 2Ch
    retn    14h
    sub_4CF370 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF4D0 proc near                    ; CODE XREF: sub_47F060+27p
                                            ; sub_4CEEE0+19p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ebx
    push    esi
    mov     esi, [esp+8+arg_0]
    xor     ebx, ebx
    push    edi
    cmp     esi, ebx
    mov     edi, ecx
    jz      short loc_4CF531
    push    ebp
    mov     ebp, 4

    loc_4CF4E5:                             ; CODE XREF: sub_4CF4D0+51j
    mov     eax, [esi]
    cmp     eax, ebx
    jz      short loc_4CF51D
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+48h]
    mov     eax, [esi]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+8]
    mov     edx, [esi]
    xor     eax, eax
    lea     ecx, [edi+38h]

    loc_4CF500:                             ; CODE XREF: sub_4CF4D0+3Bj
    cmp     [ecx], edx
    jz      short loc_4CF50F
    inc     eax
    add     ecx, 4
    cmp     eax, 20h
    jl      short loc_4CF500
    jmp     short loc_4CF51D
    ; ---------------------------------------------------------------------------

    loc_4CF50F:                             ; CODE XREF: sub_4CF4D0+32j
    mov     [edi+eax*4+38h], ebx
    mov     [edi+eax*4+138h], ebx
    dec     dword ptr [edi+30h]

    loc_4CF51D:                             ; CODE XREF: sub_4CF4D0+19j
                                            ; sub_4CF4D0+3Dj
    add     esi, 4
    dec     ebp
    jnz     short loc_4CF4E5
    mov     eax, [esp+14h]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    pop     ebp

    loc_4CF531:                             ; CODE XREF: sub_4CF4D0+Dj
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    sub_4CF4D0 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF540 proc near                    ; CODE XREF: sub_47F0C0+A9p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     edx, [esp+arg_0]
    push    0
    push    eax
    push    edx
    mov     dword_51FF48, 1
    call    sub_4CF570
    mov     dword_51FF48, 0
    retn    8
    sub_4CF540 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF570 proc near                    ; CODE XREF: sub_47F0C0+C0p
                                            ; sub_47F300+279p ...

    var_68= dword ptr -68h
    var_60= dword ptr -60h
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_48= dword ptr -48h
    var_40= dword ptr -40h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 1Ch
    mov     eax, dword_51FF48
    push    ebx
    push    ebp
    push    esi
    xor     ebp, ebp
    mov     esi, ecx
    cmp     eax, ebp
    push    edi
    mov     [esp+2Ch+var_14], esi
    mov     [esp+2Ch+var_1C], ebp
    mov     [esp+2Ch+var_10], ebp
    jz      short loc_4CF5B2
    xor     ecx, ecx
    lea     eax, [esi+138h]

    loc_4CF598:                             ; CODE XREF: sub_4CF570+40j
    cmp     [eax-100h], ebp
    jz      short loc_4CF5A9
    cmp     dword ptr [eax], 1
    jz      loc_4CF786

    loc_4CF5A9:                             ; CODE XREF: sub_4CF570+2Ej
    inc     ecx
    add     eax, 4
    cmp     ecx, 20h
    jl      short loc_4CF598

    loc_4CF5B2:                             ; CODE XREF: sub_4CF570+1Ej
    mov     eax, [esi+30h]
    mov     ecx, [esi+2Ch]
    cmp     eax, ecx
    jl      short loc_4CF5CD

    loc_4CF5BC:                             ; CODE XREF: sub_4CF570+5Bj
    mov     ecx, esi
    call    sub_4CF180
    mov     ecx, [esi+30h]
    mov     eax, [esi+2Ch]
    cmp     ecx, eax
    jge     short loc_4CF5BC

    loc_4CF5CD:                             ; CODE XREF: sub_4CF570+4Aj
    mov     edi, [esp+2Ch+arg_0]
    xor     ebx, ebx
    cmp     edi, ebp
    jnz     short loc_4CF5E3
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CF5E3:                             ; CODE XREF: sub_4CF570+65j
    xor     esi, esi

    loc_4CF5E5:                             ; CODE XREF: sub_4CF570+C1j
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_4CF626
    mov     edx, [eax]
    lea     ecx, [esp+2Ch+var_C]
    push    ecx
    push    eax
    call    dword ptr [edx+24h]
    test    eax, eax
    jnz     loc_4CF786
    mov     eax, [esp+2Ch+var_C]
    test    eax, eax
    jz      short loc_4CF635
    mov     eax, [edi]
    lea     ecx, [esp+2Ch+var_4]
    push    ecx
    lea     ecx, [esp+28h]
    mov     edx, [eax]
    push    ecx
    push    eax
    call    dword ptr [edx+10h]
    mov     eax, [esp+24h]
    cmp     eax, ebx
    jbe     short loc_4CF62A
    mov     ebx, eax
    mov     ebp, esi
    jmp     short loc_4CF62A
    ; ---------------------------------------------------------------------------

    loc_4CF626:                             ; CODE XREF: sub_4CF570+79j
    mov     [esp+2Ch+var_10], esi

    loc_4CF62A:                             ; CODE XREF: sub_4CF570+AEj
                                            ; sub_4CF570+B4j
    inc     esi
    add     edi, 4
    cmp     esi, 4
    jl      short loc_4CF5E5
    jmp     short loc_4CF640
    ; ---------------------------------------------------------------------------

    loc_4CF635:                             ; CODE XREF: sub_4CF570+94j
    mov     edx, [esp+2Ch+arg_0]
    mov     eax, [edx+esi*4]
    mov     [esp+2Ch+var_1C], eax

    loc_4CF640:                             ; CODE XREF: sub_4CF570+C3j
    mov     eax, [esp+2Ch+var_1C]
    test    eax, eax
    jnz     short loc_4CF699
    mov     edi, [esp+2Ch+var_10]
    test    edi, edi
    jle     short loc_4CF686
    mov     esi, [esp+2Ch+var_14]
    lea     edx, [esp+2Ch+var_1C]
    push    edx
    mov     edx, [esp+30h+arg_0]
    mov     eax, [esi+24h]
    mov     edx, [edx]
    mov     ecx, [eax]
    push    edx
    push    eax
    call    dword ptr [ecx+14h]
    test    eax, eax
    jz      short loc_4CF679
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CF679:                             ; CODE XREF: sub_4CF570+FBj
    mov     eax, [esp+2Ch+arg_0]
    mov     ecx, [esp+2Ch+var_1C]
    mov     [eax+edi*4], ecx
    jmp     short loc_4CF69D
    ; ---------------------------------------------------------------------------

    loc_4CF686:                             ; CODE XREF: sub_4CF570+DEj
    mov     edx, [esp+2Ch+arg_0]
    push    0
    mov     eax, [edx+ebp*4]
    mov     [esp+30h+var_1C], eax
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+34h]

    loc_4CF699:                             ; CODE XREF: sub_4CF570+D6j
    mov     esi, [esp+2Ch+var_14]

    loc_4CF69D:                             ; CODE XREF: sub_4CF570+114j
    mov     eax, [esp+2Ch+var_1C]
    lea     ecx, [esp+2Ch+var_18]
    push    ecx
    push    offset dword_4FCF68
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx]
    test    eax, eax
    jnz     short loc_4CF72B
    mov     eax, [esi+4]
    test    eax, eax
    jz      short loc_4CF713
    mov     eax, [esp+38h]
    test    eax, eax
    jz      short loc_4CF713
    mov     ecx, [esp+2Ch+var_18]
    push    0
    fild    dword ptr [eax+8]
    push    ecx
    mov     edx, [ecx]
    fstp    [esp+34h+var_34]
    fild    dword ptr [eax+4]
    push    ecx
    fstp    dword ptr [esp+0]
    fild    dword ptr [eax]
    push    ecx
    fstp    dword ptr [esp+0]
    push    ecx
    call    dword ptr [edx+4Ch]
    mov     eax, [esp+2Ch+var_18]
    mov     edx, [esi+8]
    push    0
    push    edx
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+44h]
    mov     eax, [esp+2Ch+var_18]
    mov     edx, [esi+0Ch]
    push    0
    push    edx
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+40h]
    mov     eax, [esp+2Ch+var_18]
    push    0
    push    0
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+48h]
    jmp     short loc_4CF721
    ; ---------------------------------------------------------------------------

    loc_4CF713:                             ; CODE XREF: sub_4CF570+149j
                                            ; sub_4CF570+151j
    mov     eax, [esp+2Ch+var_18]
    push    0
    push    2
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+48h]

    loc_4CF721:                             ; CODE XREF: sub_4CF570+1A1j
    mov     eax, [esp+2Ch+var_18]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+8]

    loc_4CF72B:                             ; CODE XREF: sub_4CF570+142j
    mov     eax, [esp+2Ch+var_1C]
    push    0
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+34h]
    test    eax, eax
    jz      short loc_4CF747
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CF747:                             ; CODE XREF: sub_4CF570+1C9j
    mov     eax, [esp+2Ch+var_1C]
    mov     edx, [esp+34h]
    push    edx
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+3Ch]
    test    eax, eax
    jz      short loc_4CF766
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CF766:                             ; CODE XREF: sub_4CF570+1E8j
    mov     edi, dword_51FF48
    mov     eax, [esp+2Ch+var_1C]
    xor     edx, edx
    mov     ecx, [eax]
    test    edi, edi
    setnz   dl
    push    edx
    push    0
    push    0
    push    eax
    call    dword ptr [ecx+30h]
    test    eax, eax
    jz      short loc_4CF792

    loc_4CF786:                             ; CODE XREF: sub_4CF570+33j
                                            ; sub_4CF570+88j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CF792:                             ; CODE XREF: sub_4CF570+214j
    xor     eax, eax
    lea     ecx, [esi+38h]

    loc_4CF797:                             ; CODE XREF: sub_4CF570+233j
    cmp     dword ptr [ecx], 0
    jz      short loc_4CF7B4
    inc     eax
    add     ecx, 4
    cmp     eax, 20h
    jl      short loc_4CF797
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4CF7B4:                             ; CODE XREF: sub_4CF570+22Aj
    mov     ecx, [esp+2Ch+var_1C]
    pop     edi
    mov     [esi+eax*4+38h], ecx
    mov     edx, [esi+34h]
    inc     edx
    mov     ecx, edx
    mov     [esi+34h], edx
    mov     [esi+eax*4+0B8h], ecx
    mov     ecx, dword_51FF48
    xor     edx, edx
    test    ecx, ecx
    setnz   dl
    mov     [esi+eax*4+138h], edx
    mov     eax, [esi+30h]
    inc     eax
    mov     [esi+30h], eax
    pop     esi
    pop     ebp
    mov     eax, 1
    pop     ebx
    add     esp, 1Ch
    retn    0Ch
    sub_4CF570 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    push    edi
    mov     edi, ecx
    call    sub_4CF0B0
    xor     esi, esi
    lea     eax, [edi+1C4h]

    loc_4CF811:                             ; CODE XREF: .text:004CF81Dj
    cmp     dword ptr [eax], 0
    jz      short loc_4CF826
    inc     esi
    add     eax, 4
    cmp     esi, 8
    jl      short loc_4CF811
    xor     eax, eax
    pop     edi
    pop     esi
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CF826:                             ; CODE XREF: .text:004CF814j
    mov     eax, [esp+1Ch]
    mov     ecx, [esp+18h]
    mov     edx, [esp+14h]
    push    eax
    mov     eax, [esp+14h]
    push    ecx
    mov     ecx, [esp+14h]
    push    edx
    push    eax
    push    ecx
    mov     ecx, edi
    call    sub_4CF230
    test    eax, eax
    mov     [edi+esi*4+1C4h], eax
    jz      short loc_4CF892
    mov     edx, [esp+24h]
    mov     ecx, [esp+20h]
    push    edx
    push    ecx
    push    eax
    mov     ecx, edi
    call    sub_4CF570
    test    eax, eax
    jnz     short loc_4CF888
    mov     edx, [edi+esi*4+1C4h]
    mov     ecx, edi
    push    edx
    call    sub_4CF4D0
    mov     dword ptr [edi+esi*4+1C4h], 0
    xor     eax, eax
    pop     edi
    pop     esi
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CF888:                             ; CODE XREF: .text:004CF865j
    mov     eax, 1
    pop     edi
    pop     esi
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CF892:                             ; CODE XREF: .text:004CF84Fj
    pop     edi
    xor     eax, eax
    pop     esi
    retn    1Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF8A0 proc near                    ; CODE XREF: sub_4D02A0+249p
                                            ; sub_4D02A0+2E6p ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h
    arg_C= dword ptr  18h
    arg_10= dword ptr  1Ch
    arg_14= dword ptr  20h
    arg_18= dword ptr  24h

    push    esi
    push    edi
    mov     edi, ecx
    call    sub_4CF0B0
    xor     esi, esi
    lea     eax, [edi+1C4h]

    loc_4CF8B1:                             ; CODE XREF: sub_4CF8A0+1Dj
    cmp     dword ptr [eax], 0
    jz      short loc_4CF8C6
    inc     esi
    add     eax, 4
    cmp     esi, 8
    jl      short loc_4CF8B1
    xor     eax, eax
    pop     edi
    pop     esi
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CF8C6:                             ; CODE XREF: sub_4CF8A0+14j
    mov     eax, [esp+arg_10]
    mov     ecx, [esp+arg_C]
    mov     edx, [esp+arg_8]
    push    eax
    mov     eax, [esp+4+arg_4]
    push    ecx
    mov     ecx, [esp+8+arg_0]
    push    edx
    push    eax
    push    ecx
    mov     ecx, edi
    call    sub_4CF370
    test    eax, eax
    mov     [edi+esi*4+1C4h], eax
    jz      short loc_4CF932
    mov     edx, [esp+arg_18]
    mov     ecx, [esp+arg_14]
    push    edx
    push    ecx
    push    eax
    mov     ecx, edi
    call    sub_4CF570
    test    eax, eax
    jnz     short loc_4CF928
    mov     edx, [edi+esi*4+1C4h]
    mov     ecx, edi
    push    edx
    call    sub_4CF4D0
    mov     dword ptr [edi+esi*4+1C4h], 0
    xor     eax, eax
    pop     edi
    pop     esi
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CF928:                             ; CODE XREF: sub_4CF8A0+65j
    mov     eax, 1
    pop     edi
    pop     esi
    retn    1Ch
    ; ---------------------------------------------------------------------------

    loc_4CF932:                             ; CODE XREF: sub_4CF8A0+4Fj
    pop     edi
    xor     eax, eax
    pop     esi
    retn    1Ch
    sub_4CF8A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CF940 proc near                    ; CODE XREF: sub_4D02A0+21Ep
                                            ; sub_4D02A0+2B8p ...

    var_30= word ptr -30h
    var_2E= word ptr -2Eh
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= word ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 28h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    or      ebx, 0FFFFFFFFh
    push    edi
    mov     eax, [esi+288h]
    cmp     eax, ebx
    jz      short loc_4CF962
    push    eax
    call    sub_4B64D0
    mov     [esi+288h], ebx

    loc_4CF962:                             ; CODE XREF: sub_4CF940+14j
    mov     eax, [esi+1E4h]
    lea     edi, [esi+1E4h]
    test    eax, eax
    jz      short loc_4CF992
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+48h]
    mov     eax, [edi]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+8]
    mov     eax, [esi+1E8h]
    mov     dword ptr [edi], 0
    push    eax
    call    sub_4BB5D0

    loc_4CF992:                             ; CODE XREF: sub_4CF940+30j
    mov     eax, [esi+288h]
    cmp     eax, ebx
    jz      short loc_4CF9A8
    push    eax
    call    sub_4B64D0
    mov     [esi+288h], ebx

    loc_4CF9A8:                             ; CODE XREF: sub_4CF940+5Aj
    mov     ebx, [esp+48h]
    mov     eax, [esp+44h]
    mov     ecx, ebx
    mov     word ptr [esp+38h+var_28+2], bx
    imul    ecx, [esp+38h+arg_4]
    cdq
    and     edx, 7
    push    0
    add     eax, edx
    mov     [esp+3Ch+var_14], 14h
    mov     ebp, eax
    mov     [esp+3Ch+var_10], 82h
    sar     ebp, 3
    imul    ecx, ebp
    imul    ebx, ebp
    shl     ecx, 1
    mov     eax, ecx
    mov     word ptr [esp+3Ch+var_1C], bx
    cdq
    sub     eax, edx
    mov     edx, [esp+3Ch+var_1C]
    sar     eax, 1
    mov     [esi+1F0h], eax
    mov     eax, [esp+3Ch+arg_4]
    and     edx, 0FFFFh
    mov     ebx, [esp+48h]
    imul    edx, eax
    mov     [esp+3Ch+var_C], ecx
    mov     [esp+3Ch+var_24], eax
    mov     eax, [esi+24h]
    lea     ecx, [esp+3Ch+var_28]
    mov     dword ptr [esp+3Ch+var_20], edx
    lea     edx, [esp+3Ch+var_14]
    mov     dword ptr [esp+34h], 0
    mov     [esp+3Ch+var_4], ecx
    mov     word ptr [esp+3Ch+var_28], 1
    mov     word ptr [esp+3Ch+var_1C+2], bx
    mov     word ptr [esp+3Ch+var_18], 12h
    mov     ecx, [eax]
    push    edi
    push    edx
    push    eax
    call    dword ptr [ecx+0Ch]
    test    eax, eax
    jz      short loc_4CFA5A
    mov     dword ptr [edi], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CFA5A:                             ; CODE XREF: sub_4CF940+108j
    mov     eax, [esp+38h+arg_0]
    mov     [esi+1ECh], ebx
    or      ebx, 0FFFFFFFFh
    mov     ecx, esi
    mov     dword ptr [esi+1F4h], 0
    mov     [esi+1F8h], ebx
    mov     [esi+1E8h], eax
    call    sub_4CFCA0
    mov     eax, [edi]
    mov     edx, [esp+4Ch]
    push    edx
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+3Ch]
    test    eax, eax
    jz      short loc_4CFADB
    mov     eax, [esi+288h]
    cmp     eax, ebx
    jz      short loc_4CFAAB
    push    eax
    call    sub_4B64D0
    mov     [esi+288h], ebx

    loc_4CFAAB:                             ; CODE XREF: sub_4CF940+15Dj
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_4CFB29
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+48h]
    mov     eax, [edi]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+8]
    mov     eax, [esi+1E8h]
    mov     dword ptr [edi], 0
    push    eax
    call    sub_4BB5D0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4CFADB:                             ; CODE XREF: sub_4CF940+153j
    mov     eax, [edi]
    push    1
    push    0
    push    0
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+30h]
    test    eax, eax
    jz      short loc_4CFB29
    mov     eax, [esi+288h]
    cmp     eax, ebx
    jz      short loc_4CFB03
    push    eax
    call    sub_4B64D0
    mov     [esi+288h], ebx

    loc_4CFB03:                             ; CODE XREF: sub_4CF940+1B5j
    mov     eax, [edi]
    test    eax, eax
    jz      short loc_4CFB29
    mov     edx, [eax]
    push    eax
    call    dword ptr [edx+48h]
    mov     eax, [edi]
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+8]
    mov     edx, [esi+1E8h]
    mov     dword ptr [edi], 0
    push    edx
    call    sub_4BB5D0

    loc_4CFB29:                             ; CODE XREF: sub_4CF940+16Fj
                                            ; sub_4CF940+1ABj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 28h
    retn    14h
    sub_4CF940 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFB40 proc near                    ; CODE XREF: .text:0041FE8Ep
                                            ; .text:00478D27p ...
    push    esi
    mov     esi, ecx
    mov     eax, [esi+288h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4CFB5E
    push    eax
    call    sub_4B64D0
    mov     dword ptr [esi+288h], 0FFFFFFFFh

    loc_4CFB5E:                             ; CODE XREF: sub_4CFB40+Cj
    mov     eax, [esi+1E4h]
    test    eax, eax
    jz      short loc_4CFB90
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+48h]
    mov     eax, [esi+1E4h]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+8]
    mov     eax, [esi+1E8h]
    mov     dword ptr [esi+1E4h], 0
    push    eax
    call    sub_4BB5D0

    loc_4CFB90:                             ; CODE XREF: sub_4CFB40+26j
    pop     esi
    retn
    sub_4CFB40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFBA0 proc near                    ; CODE XREF: sub_478B40+41p
    mov     eax, [ecx+1E4h]
    test    eax, eax
    jnz     short unknown_libname_54
    cmp     dword ptr [ecx+288h], 0FFFFFFFFh
    jnz     short unknown_libname_54
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_54:                     ; CODE XREF: sub_4CFBA0+8j
                                            ; sub_4CFBA0+11j
    mov     eax, 1
    retn
    sub_4CFBA0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFBC0 proc near                    ; CODE XREF: sub_4CF0B0+8Ap

    var_14= dword ptr -14h
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    lea     edx, [esp+8+var_4]
    push    esi
    mov     esi, ecx
    push    edi
    push    edx
    mov     eax, [esi+1E4h]
    lea     edx, [esp+14h+var_8]
    push    edx
    push    eax
    mov     ecx, [eax]
    call    dword ptr [ecx+10h]
    mov     eax, [esi+1F8h]
    mov     edi, [esp+10h+var_8]
    test    eax, eax
    jl      short loc_4CFC68
    mov     edx, [esi+1F4h]
    test    edx, edx
    jnz     short loc_4CFC07
    mov     ecx, [esi+1F0h]
    cmp     eax, ecx
    jge     short loc_4CFC03
    cmp     edi, ecx
    jnb     short loc_4CFC15

    loc_4CFC03:                             ; CODE XREF: sub_4CFBC0+3Dj
    test    edx, edx
    jz      short loc_4CFC68

    loc_4CFC07:                             ; CODE XREF: sub_4CFBC0+33j
    mov     ecx, [esi+1F0h]
    cmp     eax, ecx
    jl      short loc_4CFC68
    cmp     edi, ecx
    jnb     short loc_4CFC68

    loc_4CFC15:                             ; CODE XREF: sub_4CFBC0+41j
    mov     eax, [esi+288h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4CFC30
    push    eax
    call    sub_4B64D0
    mov     dword ptr [esi+288h], 0FFFFFFFFh

    loc_4CFC30:                             ; CODE XREF: sub_4CFBC0+5Ej
    mov     eax, [esi+1E4h]
    test    eax, eax
    jz      short loc_4CFC94
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+48h]
    mov     eax, [esi+1E4h]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+8]
    mov     eax, [esi+1E8h]
    mov     dword ptr [esi+1E4h], 0
    push    eax
    call    sub_4BB5D0
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4CFC68:                             ; CODE XREF: sub_4CFBC0+29j
                                            ; sub_4CFBC0+45j ...
    mov     eax, [esi+1F0h]
    mov     ecx, [esi+1F4h]
    cmp     ecx, eax
    jl      short loc_4CFC89
    cmp     edi, eax
    jnb     short loc_4CFC94
    mov     ecx, esi
    call    sub_4CFCA0
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4CFC89:                             ; CODE XREF: sub_4CFBC0+B6j
    cmp     edi, eax
    jb      short loc_4CFC94
    mov     ecx, esi
    call    sub_4CFCA0

    loc_4CFC94:                             ; CODE XREF: sub_4CFBC0+78j
                                            ; sub_4CFBC0+BAj ...
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4CFBC0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFCA0 proc near                    ; CODE XREF: sub_4CF940+13Fp
                                            ; sub_4CFBC0+BEp ...

    var_28= dword ptr -28h
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    lea     edx, [esp+8+var_4]
    push    esi
    push    edi
    push    0
    push    0
    push    0
    push    edx
    mov     esi, ecx
    lea     edx, [esp+20h+var_8]
    push    edx
    mov     edx, [esi+1F0h]
    mov     eax, [esi+1E4h]
    push    edx
    mov     edx, [esi+1F4h]
    mov     ecx, [eax]
    push    edx
    push    eax
    call    dword ptr [ecx+2Ch]
    test    eax, eax
    jz      short loc_4CFD2C
    mov     eax, [esi+288h]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4CFCF0
    push    eax
    call    sub_4B64D0
    mov     dword ptr [esi+288h], 0FFFFFFFFh

    loc_4CFCF0:                             ; CODE XREF: sub_4CFCA0+3Ej
    mov     eax, [esi+1E4h]
    test    eax, eax
    jz      loc_4CFE2D
    mov     ecx, [eax]
    push    eax
    call    dword ptr [ecx+48h]
    mov     eax, [esi+1E4h]
    push    eax
    mov     edx, [eax]
    call    dword ptr [edx+8]
    mov     eax, [esi+1E8h]
    mov     dword ptr [esi+1E4h], 0
    push    eax
    call    sub_4BB5D0
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4CFD2C:                             ; CODE XREF: sub_4CFCA0+33j
    mov     eax, [esi+1F8h]
    test    eax, eax
    jl      short loc_4CFD66
    mov     eax, [esi+1ECh]
    mov     ecx, [esi+1F0h]
    cmp     eax, 8
    jz      short loc_4CFD5B
    cmp     eax, 10h
    jnz     loc_4CFDEB
    mov     edi, [esp+10h+var_8]
    xor     eax, eax
    jmp     loc_4CFDDD
    ; ---------------------------------------------------------------------------

    loc_4CFD5B:                             ; CODE XREF: sub_4CFCA0+A5j
    mov     edi, [esp+10h+var_8]
    mov     eax, 80808080h
    jmp     short loc_4CFDDD
    ; ---------------------------------------------------------------------------

    loc_4CFD66:                             ; CODE XREF: sub_4CFCA0+94j
    mov     eax, [esi+1E8h]
    push    eax
    call    sub_4BB7A0
    mov     ecx, [esi+1E8h]
    mov     edi, eax
    push    ecx
    call    sub_4BBD00
    sub     eax, edi
    mov     edi, [esi+1F0h]
    cmp     eax, edi
    jnb     short loc_4CFD8E
    mov     edi, eax

    loc_4CFD8E:                             ; CODE XREF: sub_4CFCA0+EAj
    mov     edx, [esp+10h+var_8]
    mov     eax, [esi+1E8h]
    push    edi
    push    edx
    push    eax
    call    sub_4BB7C0
    mov     eax, [esi+1F0h]
    cmp     edi, eax
    jnb     short loc_4CFDEB
    mov     edx, [esi+1F4h]
    mov     ecx, edi
    add     ecx, edx
    mov     edx, [esp+10h+var_8]
    sub     eax, edi
    add     edi, edx
    mov     edx, [esi+1ECh]
    mov     [esi+1F8h], ecx
    cmp     edx, 8
    mov     ecx, eax
    jz      short loc_4CFDD8
    cmp     edx, 10h
    jnz     short loc_4CFDEB
    xor     eax, eax
    jmp     short loc_4CFDDD
    ; ---------------------------------------------------------------------------

    loc_4CFDD8:                             ; CODE XREF: sub_4CFCA0+12Dj
    mov     eax, 80808080h

    loc_4CFDDD:                             ; CODE XREF: sub_4CFCA0+B6j
                                            ; sub_4CFCA0+C4j ...
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb

    loc_4CFDEB:                             ; CODE XREF: sub_4CFCA0+AAj
                                            ; sub_4CFCA0+108j ...
    mov     edx, [esi+1F0h]
    mov     eax, [esi+1E4h]
    push    0
    push    0
    mov     ecx, [eax]
    push    edx
    mov     edx, [esp+1Ch+var_8]
    push    edx
    push    eax
    call    dword ptr [ecx+4Ch]
    mov     eax, [esi+1F4h]
    test    eax, eax
    jnz     short loc_4CFE23
    mov     eax, [esi+1F0h]
    mov     [esi+1F4h], eax
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4CFE23:                             ; CODE XREF: sub_4CFCA0+16Fj
    mov     dword ptr [esi+1F4h], 0

    loc_4CFE2D:                             ; CODE XREF: sub_4CFCA0+58j
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4CFCA0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [ecx+1ECh]
    push    edi
    cmp     eax, 8
    jz      short loc_4CFE59
    cmp     eax, 10h
    jnz     short loc_4CFE74
    mov     ecx, [esp+0Ch]
    xor     eax, eax
    jmp     short loc_4CFE62
    ; ---------------------------------------------------------------------------

    loc_4CFE59:                             ; CODE XREF: .text:004CFE4Aj
    mov     ecx, [esp+0Ch]
    mov     eax, 80808080h

    loc_4CFE62:                             ; CODE XREF: .text:004CFE57j
    mov     edi, [esp+8]
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb

    loc_4CFE74:                             ; CODE XREF: .text:004CFE4Fj
    pop     edi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFE80 proc near                    ; CODE XREF: .text:00416850p
                                            ; WriteRegistrySettings_1+435p ...
    mov     dword ptr [ecx+4], 1
    retn
    sub_4CFE80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFE90 proc near                    ; CODE XREF: .text:0041683Ap
                                            ; WriteRegistrySettings_1+445p ...
    mov     dword ptr [ecx+4], 0
    retn
    sub_4CFE90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFEA0 proc near                    ; CODE XREF: .text:00416828p
                                            ; WriteRegistrySettings_1+473p ...
    mov     eax, [ecx+4]
    retn
    sub_4CFEA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFEB0 proc near                    ; CODE XREF: sub_47F300+260p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     edx, [esp+arg_4]
    mov     [ecx+8], eax
    mov     [ecx+0Ch], edx
    retn    8
    sub_4CFEB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_55:
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_56:
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_57:
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFF20 proc near                    ; CODE XREF: .text:0042671Cp
                                            ; sub_47ED40+81p
    mov     eax, [ecx+290h]
    retn
    sub_4CFF20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFF30 proc near                    ; CODE XREF: sub_4CEE50+37p

    pdwVolume= dword ptr -34h
    pac= tagAUXCAPSA ptr -30h

    sub     esp, 34h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     ebx, ecx
    call    ds:waveOutGetNumDevs
    mov     [ebx+10h], eax
    mov     dword ptr [ebx+14h], 0FFFFFFFFh
    call    ds:auxGetNumDevs                ; Get number of auxiliary output
                                            ; devices present in the system
    mov     ebp, eax
    xor     esi, esi
    test    ebp, ebp
    jle     short loc_4CFF7D
    mov     edi, ds:auxGetDevCapsA          ; Get the capabilities of a given
                                            ; auxiliary output device

    loc_4CFF5D:                             ; CODE XREF: sub_4CFF30+46j
    lea     eax, [esp+44h+pac]
    push    30h                             ; cbac
    push    eax                             ; pac
    push    esi                             ; uDeviceID
    call    edi ; auxGetDevCapsA            ; Get the capabilities of a given
                                            ; auxiliary output device
    test    eax, eax
    jnz     short loc_4CFF73
    cmp     [esp+44h+pac.wTechnology], 1
    jz      short loc_4CFF7A

    loc_4CFF73:                             ; CODE XREF: sub_4CFF30+39j
    inc     esi
    cmp     esi, ebp
    jl      short loc_4CFF5D
    jmp     short loc_4CFF7D
    ; ---------------------------------------------------------------------------

    loc_4CFF7A:                             ; CODE XREF: sub_4CFF30+41j
    mov     [ebx+14h], esi

    loc_4CFF7D:                             ; CODE XREF: sub_4CFF30+25j
                                            ; sub_4CFF30+48j
    mov     eax, [ebx+10h]
    xor     esi, esi
    test    eax, eax
    jle     short loc_4CFFA0
    mov     edi, ds:waveOutGetVolume

    loc_4CFF8C:                             ; CODE XREF: sub_4CFF30+6Ej
    lea     ecx, [esp+44h+pdwVolume]
    push    ecx                             ; pdwVolume
    push    esi                             ; hwo
    call    edi ; waveOutGetVolume
    test    eax, eax
    jz      short loc_4CFFDF
    mov     eax, [ebx+10h]
    inc     esi
    cmp     esi, eax
    jl      short loc_4CFF8C

    loc_4CFFA0:                             ; CODE XREF: sub_4CFF30+54j
    or      eax, 0FFFFFFFFh

    loc_4CFFA3:                             ; CODE XREF: sub_4CFF30+B8j
    mov     [ebx+18h], eax
    mov     eax, [ebx+14h]
    test    eax, eax
    jl      short loc_4CFFD1
    lea     edx, [esp+44h+pdwVolume]
    push    edx                             ; pdwVolume
    push    eax                             ; uDeviceID
    call    ds:auxGetVolume                 ; Get the current volume setting of
                                            ; the specified auxiliary output device
    test    eax, eax
    jnz     short loc_4CFFD1
    mov     eax, [esp+44h+pdwVolume]
    and     eax, 0FFFFh
    mov     [ebx+1Ch], eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CFFD1:                             ; CODE XREF: sub_4CFF30+7Bj
                                            ; sub_4CFF30+8Bj
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    mov     [ebx+1Ch], eax
    pop     ebp
    pop     ebx
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------

    loc_4CFFDF:                             ; CODE XREF: sub_4CFF30+66j
    mov     eax, [esp+44h+pdwVolume]
    and     eax, 0FFFFh
    jmp     short loc_4CFFA3
    sub_4CFF30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4CFFF0 proc near                    ; CODE XREF: WriteRegistrySettings_2+1D0p

    pdwVolume= dword ptr -4

    push    ecx
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    xor     esi, esi
    mov     eax, [edi+10h]
    test    eax, eax
    jle     short loc_4D002F
    mov     ebx, ds:waveOutGetVolume

    loc_4D0005:                             ; CODE XREF: sub_4CFFF0+27j
    lea     eax, [esp+10h+pdwVolume]
    push    eax                             ; pdwVolume
    push    esi                             ; hwo
    call    ebx ; waveOutGetVolume
    test    eax, eax
    jz      short loc_4D0021
    mov     eax, [edi+10h]
    inc     esi
    cmp     esi, eax
    jl      short loc_4D0005
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4D0021:                             ; CODE XREF: sub_4CFFF0+1Fj
    mov     eax, [esp+10h+pdwVolume]
    and     eax, 0FFFFh
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4D002F:                             ; CODE XREF: sub_4CFFF0+Dj
    pop     edi
    pop     esi
    or      eax, 0FFFFFFFFh
    pop     ebx
    pop     ecx
    retn
    sub_4CFFF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D0040 proc near                    ; CODE XREF: WriteRegistrySettings_2+1EEp
                                            ; sub_4CEE50+71p

    pdwVolume= dword ptr -4

    push    ecx
    mov     eax, [ecx+14h]
    test    eax, eax
    jl      short loc_4D0063
    lea     ecx, [esp+4+pdwVolume]
    push    ecx                             ; pdwVolume
    push    eax                             ; uDeviceID
    call    ds:auxGetVolume                 ; Get the current volume setting of
                                            ; the specified auxiliary output device
    test    eax, eax
    jnz     short loc_4D0063
    mov     eax, [esp+4+pdwVolume]
    and     eax, 0FFFFh
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4D0063:                             ; CODE XREF: sub_4D0040+6j
                                            ; sub_4D0040+16j
    or      eax, 0FFFFFFFFh
    pop     ecx
    retn
    sub_4D0040 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D0070 proc near                    ; CODE XREF: WriteRegistrySettings_1+562p
                                            ; sub_45BCC0+32p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    ebx
    push    ebp
    push    esi
    test    eax, eax
    push    edi
    mov     [esp+14h+var_4], ecx
    jge     short loc_4D0083
    xor     eax, eax

    loc_4D0083:                             ; CODE XREF: sub_4D0070+Fj
    cmp     eax, 0FFFFh
    jle     short loc_4D008F
    mov     eax, 0FFFFh

    loc_4D008F:                             ; CODE XREF: sub_4D0070+18j
    mov     edx, [ecx+10h]
    xor     ebp, ebp
    xor     esi, esi
    test    edx, edx
    jle     short loc_4D00BE
    mov     ebx, ds:waveOutSetVolume
    mov     edi, eax
    shl     edi, 10h
    or      edi, eax

    loc_4D00A7:                             ; CODE XREF: sub_4D0070+4Cj
    push    edi                             ; dwVolume
    push    esi                             ; hwo
    call    ebx ; waveOutSetVolume
    test    eax, eax
    jz      short loc_4D00B4
    mov     ebp, 1

    loc_4D00B4:                             ; CODE XREF: sub_4D0070+3Dj
    mov     eax, [esp+14h+var_4]
    inc     esi
    cmp     esi, [eax+10h]
    jl      short loc_4D00A7

    loc_4D00BE:                             ; CODE XREF: sub_4D0070+28j
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_4D0070 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D00D0 proc near                    ; CODE XREF: WriteRegistrySettings_1+58Ep
                                            ; sub_45BCC0+4Bp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [ecx+284h]
    mov     edx, [esp+arg_4]
    test    eax, eax
    jz      short loc_4D00EA
    test    edx, edx
    jnz     short loc_4D00EA
    mov     eax, 1
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D00EA:                             ; CODE XREF: sub_4D00D0+Cj
                                            ; sub_4D00D0+10j
    mov     eax, [esp+arg_0]
    test    eax, eax
    jge     short loc_4D00F4
    xor     eax, eax

    loc_4D00F4:                             ; CODE XREF: sub_4D00D0+20j
    cmp     eax, 0FFFFh
    jle     short loc_4D0100
    mov     eax, 0FFFFh

    loc_4D0100:                             ; CODE XREF: sub_4D00D0+29j
    test    edx, edx
    jnz     short loc_4D0107
    mov     [ecx+20h], eax

    loc_4D0107:                             ; CODE XREF: sub_4D00D0+32j
    mov     edx, eax
    shl     edx, 10h
    or      edx, eax
    mov     eax, [ecx+14h]
    push    edx                             ; dwVolume
    push    eax                             ; uDeviceID
    call    ds:auxSetVolume
    neg     eax
    sbb     eax, eax
    inc     eax
    retn    8
    sub_4D00D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D0130 proc near                    ; CODE XREF: sub_47EEE0+B0p
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     eax, [edi+18h]
    test    eax, eax
    jl      short loc_4D016F
    jge     short loc_4D0141
    xor     eax, eax

    loc_4D0141:                             ; CODE XREF: sub_4D0130+Dj
    cmp     eax, 0FFFFh
    jle     short loc_4D014D
    mov     eax, 0FFFFh

    loc_4D014D:                             ; CODE XREF: sub_4D0130+16j
    mov     ecx, [edi+10h]
    xor     esi, esi
    test    ecx, ecx
    jle     short loc_4D016F
    mov     ebp, ds:waveOutSetVolume
    mov     ebx, eax
    shl     ebx, 10h
    or      ebx, eax

    loc_4D0163:                             ; CODE XREF: sub_4D0130+3Dj
    push    ebx                             ; dwVolume
    push    esi                             ; hwo
    call    ebp ; waveOutSetVolume
    mov     eax, [edi+10h]
    inc     esi
    cmp     esi, eax
    jl      short loc_4D0163

    loc_4D016F:                             ; CODE XREF: sub_4D0130+Bj
                                            ; sub_4D0130+24j
    mov     eax, [edi+1Ch]
    test    eax, eax
    jl      short loc_4D01A7
    mov     ecx, [edi+284h]
    test    ecx, ecx
    jnz     short loc_4D01A7
    test    eax, eax
    jge     short loc_4D0186
    xor     eax, eax

    loc_4D0186:                             ; CODE XREF: sub_4D0130+52j
    cmp     eax, 0FFFFh
    jle     short loc_4D0192
    mov     eax, 0FFFFh

    loc_4D0192:                             ; CODE XREF: sub_4D0130+5Bj
    mov     edx, [edi+14h]
    mov     ecx, eax
    shl     ecx, 10h
    or      ecx, eax
    mov     [edi+20h], eax
    push    ecx                             ; dwVolume
    push    edx                             ; uDeviceID
    call    ds:auxSetVolume

    loc_4D01A7:                             ; CODE XREF: sub_4D0130+44j
                                            ; sub_4D0130+4Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4D0130 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D01B0 proc near                    ; CODE XREF: sub_4D02A0+32p

    arg_0= byte ptr  8

    push    esi
    mov     esi, dword ptr [esp+arg_0]
    push    0
    push    esi
    call    sub_4BB710
    lea     eax, [esp+arg_0]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    push    4                               ; size_t
    lea     ecx, [esp+4+arg_0]
    push    offset aDigi                    ; char *
    push    ecx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D0245
    push    8
    push    esi
    call    sub_4BB710
    lea     edx, [esp+arg_0]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    push    4                               ; size_t
    lea     eax, [esp+4+arg_0]
    push    offset aHshd                    ; char *
    push    eax                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D0245
    push    20h
    push    esi
    call    sub_4BB710
    lea     ecx, [esp+arg_0]
    push    4
    push    ecx
    push    esi
    call    sub_4BB7C0
    push    4                               ; size_t
    lea     edx, [esp+4+arg_0]
    push    offset aSdat                    ; char *
    push    edx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D0245
    mov     eax, 1
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D0245:                             ; CODE XREF: sub_4D01B0+30j
                                            ; sub_4D01B0+5Dj ...
    push    4                               ; size_t
    lea     eax, [esp+4+arg_0]
    push    offset aRiff                    ; char *
    push    eax                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D0293
    push    8
    push    esi
    call    sub_4BB710
    lea     ecx, [esp+arg_0]
    push    4
    push    ecx
    push    esi
    call    sub_4BB7C0
    push    4                               ; size_t
    lea     edx, [esp+4+arg_0]
    push    offset aWave                    ; char *
    push    edx                             ; char *
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D0293
    mov     eax, 2
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D0293:                             ; CODE XREF: sub_4D01B0+ABj
                                            ; sub_4D01B0+D8j
    xor     eax, eax
    pop     esi
    retn    4
    sub_4D01B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D02A0 proc near                    ; CODE XREF: sub_4D0620+Bp
                                            ; sub_4D0640+11p ...

    var_24= dword ptr -24h
    var_20= byte ptr -20h
    var_1C= byte ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_6= dword ptr -6
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 24h
    mov     eax, [esp+24h+arg_0]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    push    eax
    mov     [esp+38h+var_18], edi
    mov     [esp+38h+var_24], 0
    call    sub_4BB5B0
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4D02CF
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D02CF:                             ; CODE XREF: sub_4D02A0+23j
    push    esi
    mov     ecx, edi
    call    sub_4D01B0
    push    esi
    mov     ebp, eax
    call    sub_4BBD00
    mov     ebx, eax
    mov     eax, ebp
    sub     eax, 0
    jz      loc_4D059B
    dec     eax
    jz      loc_4D0505
    dec     eax
    jnz     loc_4D060B
    push    4
    push    esi
    call    sub_4BB710
    lea     ecx, [esp+34h+var_20]
    push    4
    push    ecx
    push    esi
    call    sub_4BB7C0
    mov     edi, dword ptr [esp+34h+var_20]
    push    0Ch
    add     edi, 8
    push    esi
    mov     dword ptr [esp+3Ch+var_20], edi
    call    sub_4BB710
    lea     edx, [esp+34h+var_1C]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    lea     eax, [esp+34h+arg_0]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    push    4                               ; size_t
    lea     ecx, [esp+38h+var_1C]
    push    offset aFmt                     ; char *
    push    ecx                             ; char *
    mov     edi, 14h
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4D03A9

    loc_4D0359:                             ; CODE XREF: sub_4D02A0+107j
    mov     edx, [esp+34h+arg_0]
    add     edx, edi
    push    edx
    push    esi
    call    sub_4BB710
    mov     ecx, [esp+34h+arg_0]
    mov     eax, dword ptr [esp+34h+var_20]
    add     edi, ecx
    cmp     edi, eax
    jnb     short loc_4D03AF
    lea     eax, [esp+34h+var_1C]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    lea     ecx, [esp+34h+arg_0]
    push    4
    push    ecx
    push    esi
    call    sub_4BB7C0
    push    4                               ; size_t
    lea     edx, [esp+38h+var_1C]
    push    offset aFmt                     ; char *
    push    edx                             ; char *
    add     edi, 8
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D0359

    loc_4D03A9:                             ; CODE XREF: sub_4D02A0+B7j
    mov     eax, [esp+34h+arg_0]
    jmp     short loc_4D03B1
    ; ---------------------------------------------------------------------------

    loc_4D03AF:                             ; CODE XREF: sub_4D02A0+D2j
    xor     eax, eax

    loc_4D03B1:                             ; CODE XREF: sub_4D02A0+10Dj
    cmp     eax, 10h
    jb      loc_4D060B
    lea     eax, [esp+34h+var_14]
    push    10h
    push    eax
    push    esi
    call    sub_4BB7C0
    mov     ebx, [esp+34h+var_6]
    mov     ebp, [esp+34h+var_14+2]
    push    4
    push    esi
    and     ebx, 0FFFFh
    and     ebp, 0FFFFh
    call    sub_4BB710
    lea     ecx, [esp+34h+var_1C]
    push    4
    push    ecx
    push    esi
    call    sub_4BB7C0
    mov     eax, dword ptr [esp+34h+var_1C]
    push    0Ch
    add     eax, 8
    push    esi
    mov     dword ptr [esp+3Ch+var_1C], eax
    call    sub_4BB710
    lea     edx, [esp+34h+var_20]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    lea     eax, [esp+34h+arg_0]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    push    4                               ; size_t
    lea     ecx, [esp+38h+var_20]
    push    offset aData_0                  ; char *
    push    ecx                             ; char *
    mov     edi, 14h
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4D048A

    loc_4D043A:                             ; CODE XREF: sub_4D02A0+1E8j
    mov     edx, [esp+34h+arg_0]
    add     edx, edi
    push    edx
    push    esi
    call    sub_4BB710
    mov     ecx, [esp+34h+arg_0]
    mov     eax, dword ptr [esp+34h+var_1C]
    add     edi, ecx
    cmp     edi, eax
    jnb     short loc_4D0490
    lea     eax, [esp+34h+var_20]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    lea     ecx, [esp+34h+arg_0]
    push    4
    push    ecx
    push    esi
    call    sub_4BB7C0
    push    4                               ; size_t
    lea     edx, [esp+38h+var_20]
    push    offset aData_0                  ; char *
    push    edx                             ; char *
    add     edi, 8
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D043A

    loc_4D048A:                             ; CODE XREF: sub_4D02A0+198j
    mov     eax, [esp+34h+arg_0]
    jmp     short loc_4D0492
    ; ---------------------------------------------------------------------------

    loc_4D0490:                             ; CODE XREF: sub_4D02A0+1B3j
    xor     eax, eax

    loc_4D0492:                             ; CODE XREF: sub_4D02A0+1EEj
    test    eax, eax
    jle     loc_4D060B
    mov     ecx, [esp+34h+arg_4]
    sub     ecx, 0
    jz      short loc_4D04F3
    dec     ecx
    jz      short loc_4D04D2
    dec     ecx
    jnz     loc_4D060B
    mov     eax, [esp+34h+arg_8]
    mov     ecx, [esp+34h+var_10]
    push    eax
    push    ebp
    push    ebx
    push    ecx
    mov     ecx, [esp+44h+var_18]
    push    esi
    call    sub_4CF940
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D04D2:                             ; CODE XREF: sub_4D02A0+204j
    mov     edx, [esp+34h+arg_C]
    mov     ecx, [esp+34h+arg_8]
    push    edx
    mov     edx, [esp+38h+var_10]
    push    ecx
    mov     ecx, [esp+3Ch+var_18]
    push    ebp
    push    ebx
    push    edx
    push    eax
    push    esi
    call    sub_4CF8A0
    jmp     loc_4D0607
    ; ---------------------------------------------------------------------------

    loc_4D04F3:                             ; CODE XREF: sub_4D02A0+201j
    mov     ecx, [esp+34h+var_10]
    push    ebp
    push    ebx
    push    ecx
    mov     ecx, [esp+40h+var_18]
    push    eax
    push    esi
    jmp     loc_4D0602
    ; ---------------------------------------------------------------------------

    loc_4D0505:                             ; CODE XREF: sub_4D02A0+4Dj
    push    16h
    push    esi
    call    sub_4BB710
    lea     edx, [esp+34h+arg_0]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    cmp     [esp+34h+arg_0], 2AF8h
    jnz     short loc_4D052C
    mov     [esp+34h+arg_0], 2B11h

    loc_4D052C:                             ; CODE XREF: sub_4D02A0+282j
    push    28h
    push    esi
    call    sub_4BB710
    mov     eax, [esp+34h+arg_4]
    sub     eax, 0
    jz      short loc_4D058D
    dec     eax
    jz      short loc_4D056C
    dec     eax
    jnz     loc_4D060B
    mov     eax, [esp+34h+arg_8]
    mov     ecx, [esp+34h+arg_0]
    push    eax
    push    1
    push    8
    push    ecx
    push    esi
    mov     ecx, edi
    call    sub_4CF940
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D056C:                             ; CODE XREF: sub_4D02A0+29Ej
    mov     edx, [esp+34h+arg_C]
    mov     eax, [esp+34h+arg_8]
    mov     ecx, [esp+34h+arg_0]
    push    edx
    push    eax
    push    1
    push    8
    add     ebx, 0FFFFFFD8h
    push    ecx
    push    ebx
    push    esi
    mov     ecx, edi
    call    sub_4CF8A0
    jmp     short loc_4D0607
    ; ---------------------------------------------------------------------------

    loc_4D058D:                             ; CODE XREF: sub_4D02A0+29Bj
    mov     edx, [esp+34h+arg_0]
    push    1
    push    8
    push    edx
    add     ebx, 0FFFFFFD8h
    jmp     short loc_4D05FE
    ; ---------------------------------------------------------------------------

    loc_4D059B:                             ; CODE XREF: sub_4D02A0+46j
    push    0
    push    esi
    call    sub_4BB710
    mov     eax, [esp+34h+arg_4]
    sub     eax, 0
    jz      short loc_4D05F5
    dec     eax
    jz      short loc_4D05D7
    dec     eax
    jnz     short loc_4D060B
    mov     eax, [esp+34h+arg_8]
    mov     ecx, edi
    push    eax
    push    1
    push    8
    push    2B11h
    push    esi
    call    sub_4CF940
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D05D7:                             ; CODE XREF: sub_4D02A0+30Dj
    mov     ecx, [esp+34h+arg_C]
    mov     edx, [esp+34h+arg_8]
    push    ecx
    push    edx
    push    1
    push    8
    push    2B11h
    push    ebx
    push    esi
    mov     ecx, edi
    call    sub_4CF8A0
    jmp     short loc_4D0607
    ; ---------------------------------------------------------------------------

    loc_4D05F5:                             ; CODE XREF: sub_4D02A0+30Aj
    push    1
    push    8
    push    2B11h

    loc_4D05FE:                             ; CODE XREF: sub_4D02A0+2F9j
    push    ebx
    push    esi
    mov     ecx, edi

    loc_4D0602:                             ; CODE XREF: sub_4D02A0+260j
    call    sub_4CF370

    loc_4D0607:                             ; CODE XREF: sub_4D02A0+24Ej
                                            ; sub_4D02A0+2EBj ...
    mov     [esp+34h+var_24], eax

    loc_4D060B:                             ; CODE XREF: sub_4D02A0+54j
                                            ; sub_4D02A0+114j ...
    push    esi
    call    sub_4BB5D0
    mov     eax, [esp+34h+var_24]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 24h
    retn    10h
    sub_4D02A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D0620 proc near                    ; CODE XREF: sub_47EFE0+6Bp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    0
    push    0
    push    0
    push    eax
    call    sub_4D02A0
    retn    4
    sub_4D0620 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D0640 proc near                    ; CODE XREF: sub_47F290+5Bp
                                            ; sub_47FD70+166p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    mov     edx, [esp+arg_4]
    push    eax
    mov     eax, [esp+4+arg_0]
    push    edx
    push    1
    push    eax
    call    sub_4D02A0
    retn    0Ch
    sub_4D0640 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+8]
    mov     edx, [esp+4]
    push    0
    push    eax
    push    2
    push    edx
    call    sub_4D02A0
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    loc_4D0680:                             ; DATA XREF: sub_4D06C0+18o
    mov     eax, dword_51FF14
    mov     ecx, [eax+288h]
    push    ecx
    call    sub_4B64D0
    mov     edx, dword_51FF14
    push    0
    mov     dword ptr [edx+288h], 0FFFFFFFFh
    mov     eax, dword_51FF58
    mov     ecx, dword_51FF14
    push    eax
    push    2
    push    offset dword_51FF60
    call    sub_4D02A0
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D06C0 proc near                    ; CODE XREF: sub_47F090+20p

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h

    push    ebx
    push    esi
    mov     ebx, ecx
    push    edi
    mov     edi, [esp+4+arg_0]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [esp+4+arg_8]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    offset loc_4D0680
    mov     eax, ecx
    mov     esi, edi
    mov     edi, offset dword_51FF60
    push    0
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    edx
    and     ecx, 3
    rep movsb
    mov     ecx, [esp+10h+arg_4]
    mov     dword_51FF58, ecx
    call    sub_4B63F0
    pop     edi
    mov     [ebx+288h], eax
    pop     esi
    mov     eax, 1
    pop     ebx
    retn    0Ch
    sub_4D06C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    push    ebx
    push    esi
    mov     esi, [esp+14h]
    push    edi
    push    4
    push    esi
    call    sub_4BB710
    lea     eax, [esp+0Ch]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    mov     edi, [esp+0Ch]
    push    0Ch
    add     edi, 8
    push    esi
    mov     [esp+14h], edi
    call    sub_4BB710
    lea     ecx, [esp+10h]
    push    4
    push    ecx
    push    esi
    call    sub_4BB7C0
    lea     edx, [esp+18h]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    mov     ebx, [esp+1Ch]
    push    4
    lea     eax, [esp+14h]
    push    ebx
    push    eax
    mov     edi, 14h
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4D07D5

    loc_4D0789:                             ; CODE XREF: .text:004D07D3j
    mov     ecx, [esp+18h]
    add     ecx, edi
    push    ecx
    push    esi
    call    sub_4BB710
    mov     ecx, [esp+18h]
    mov     eax, [esp+0Ch]
    add     edi, ecx
    cmp     edi, eax
    jnb     short loc_4D07E2
    lea     edx, [esp+10h]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    lea     eax, [esp+18h]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    push    4
    lea     ecx, [esp+14h]
    push    ebx
    push    ecx
    add     edi, 8
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D0789

    loc_4D07D5:                             ; CODE XREF: .text:004D0787j
    mov     eax, [esp+18h]
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D07E2:                             ; CODE XREF: .text:004D07A2j
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    add     esp, 8
    retn    8
    ; ---------------------------------------------------------------------------
    align 4
    sub     esp, 1Ch
    push    esi
    mov     esi, [esp+24h]
    push    edi
    push    4
    push    esi
    call    sub_4BB710
    lea     eax, [esp+8]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    mov     edx, [esp+8]
    push    0Ch
    add     edx, 8
    push    esi
    mov     [esp+10h], edx
    call    sub_4BB710
    lea     ecx, [esp+0Ch]
    push    4
    push    ecx
    push    esi
    call    sub_4BB7C0
    lea     edx, [esp+28h]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    push    4
    lea     eax, [esp+10h]
    push    offset aFmt                     ; "fmt "
    push    eax
    mov     edi, 14h
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4D08A8

    loc_4D0858:                             ; CODE XREF: .text:004D08A6j
    mov     ecx, [esp+28h]
    add     ecx, edi
    push    ecx
    push    esi
    call    sub_4BB710
    mov     ecx, [esp+28h]
    mov     eax, [esp+8]
    add     edi, ecx
    cmp     edi, eax
    jnb     short loc_4D08AE
    lea     edx, [esp+0Ch]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    lea     eax, [esp+28h]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    push    4
    lea     ecx, [esp+10h]
    push    offset aFmt                     ; "fmt "
    push    ecx
    add     edi, 8
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D0858

    loc_4D08A8:                             ; CODE XREF: .text:004D0856j
    mov     eax, [esp+28h]
    jmp     short loc_4D08B0
    ; ---------------------------------------------------------------------------

    loc_4D08AE:                             ; CODE XREF: .text:004D0871j
    xor     eax, eax

    loc_4D08B0:                             ; CODE XREF: .text:004D08ACj
    cmp     eax, 10h
    jnb     short loc_4D08BF
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D08BF:                             ; CODE XREF: .text:004D08B3j
    lea     edx, [esp+10h]
    push    10h
    push    edx
    push    esi
    call    sub_4BB7C0
    mov     eax, [esp+2Ch]
    mov     ecx, [esp+14h]
    mov     edx, [esp+1Eh]
    pop     edi
    mov     [eax], ecx
    mov     eax, [esp+2Ch]
    mov     ecx, [esp+0Eh]
    and     edx, 0FFFFh
    mov     [eax], edx
    mov     edx, [esp+30h]
    and     ecx, 0FFFFh
    mov     eax, 1
    mov     [edx], ecx
    pop     esi
    add     esp, 1Ch
    retn    10h
    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 8
    push    esi
    mov     esi, [esp+10h]
    push    edi
    push    4
    push    esi
    call    sub_4BB710
    lea     eax, [esp+8]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    mov     edx, [esp+8]
    push    0Ch
    add     edx, 8
    push    esi
    mov     [esp+10h], edx
    call    sub_4BB710
    lea     ecx, [esp+0Ch]
    push    4
    push    ecx
    push    esi
    call    sub_4BB7C0
    lea     edx, [esp+14h]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    push    4
    lea     eax, [esp+10h]
    push    offset aData_0                  ; "data"
    push    eax
    mov     edi, 14h
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4D09C8

    loc_4D0978:                             ; CODE XREF: .text:004D09C6j
    mov     ecx, [esp+14h]
    add     ecx, edi
    push    ecx
    push    esi
    call    sub_4BB710
    mov     ecx, [esp+14h]
    mov     eax, [esp+8]
    add     edi, ecx
    cmp     edi, eax
    jnb     short loc_4D09D4
    lea     edx, [esp+0Ch]
    push    4
    push    edx
    push    esi
    call    sub_4BB7C0
    lea     eax, [esp+14h]
    push    4
    push    eax
    push    esi
    call    sub_4BB7C0
    push    4
    lea     ecx, [esp+10h]
    push    offset aData_0                  ; "data"
    push    ecx
    add     edi, 8
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D0978

    loc_4D09C8:                             ; CODE XREF: .text:004D0976j
    mov     eax, [esp+14h]
    pop     edi
    pop     esi
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D09D4:                             ; CODE XREF: .text:004D0991j
    pop     edi
    xor     eax, eax
    pop     esi
    add     esp, 8
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, hEvent
    mov     dword_52A4FC, 0
    test    eax, eax
    jz      short loc_4D09FB
    push    eax
    call    ds:ResetEvent
    retn
    ; ---------------------------------------------------------------------------

    loc_4D09FB:                             ; CODE XREF: .text:004D09F1j
    push    0
    push    0
    push    0
    push    0
    call    ds:CreateEventA
    mov     hEvent, eax
    retn
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, dword_526FF0
    xor     ecx, ecx
    mov     [eax+6000h], cx
    mov     edx, dword_526FF0
    mov     eax, [esp+4]
    mov     [edx+6004h], ax
    mov     edx, dword_526FF0
    lea     eax, [eax+eax*2]
    mov     [edx+6002h], cx
    mov     edx, dword_526FF0
    shl     eax, 1
    mov     word ptr [edx+eax], 1000h
    mov     edx, dword_526FF0
    mov     [edx+eax+4], cx
    mov     edx, dword_526FF0
    mov     [edx+eax+2], cx
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    push    1011h
    push    1
    call    _calloc
    add     esp, 8
    mov     dword_526FF4, eax
    neg     eax
    sbb     eax, eax
    neg     eax
    dec     eax
    retn
    ; ---------------------------------------------------------------------------
    align 8
    push    6
    push    1001h
    call    _calloc
    add     esp, 8
    mov     dword_526FF0, eax
    neg     eax
    sbb     eax, eax
    neg     eax
    dec     eax
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, dword_526FF4
    test    eax, eax
    jnz     short loc_4D0ACA
    push    offset aHeyTheWindowBu          ; "Hey!  The window buffer ptr is not poin"...
    call    _printf
    add     esp, 4
    or      eax, 0FFFFFFFFh
    retn
    ; ---------------------------------------------------------------------------

    loc_4D0ACA:                             ; CODE XREF: .text:004D0AB7j
    push    eax
    call    _free
    add     esp, 4
    mov     dword_526FF4, 0
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    mov     eax, dword_526FF0
    test    eax, eax
    jnz     short loc_4D0AFA
    push    offset aHeyTheTreePtrI          ; "Hey!  The tree ptr is not pointing to a"...
    call    _printf
    add     esp, 4
    or      eax, 0FFFFFFFFh
    retn
    ; ---------------------------------------------------------------------------

    loc_4D0AFA:                             ; CODE XREF: .text:004D0AE7j
    push    eax
    call    _free
    add     esp, 4
    mov     dword_526FF0, 0
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    mov     edx, [esp+4]
    mov     eax, dword_526FF0
    push    ebx
    push    esi
    mov     esi, [esp+10h]
    lea     ecx, [edx+edx*2]
    shl     ecx, 1
    push    edi
    lea     edi, [esi+esi*2]
    mov     bx, [eax+ecx]
    mov     [eax+edi*2], bx
    mov     edi, dword_526FF0
    xor     eax, eax
    mov     ax, [edi+ecx]
    lea     eax, [eax+eax*2]
    cmp     [edi+eax*2+4], dx
    lea     eax, [edi+eax*2]
    jnz     short loc_4D0B5F
    mov     [eax+4], si
    mov     edx, dword_526FF0
    mov     word ptr [edx+ecx], 0
    pop     edi
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D0B5F:                             ; CODE XREF: .text:004D0B47j
    mov     [eax+2], si
    mov     edx, dword_526FF0
    pop     edi
    pop     esi
    mov     word ptr [edx+ecx], 0
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D0B80 proc near                    ; CODE XREF: DoNetworkCompression+39Ap

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_0]
    mov     edx, dword_526FF0
    push    ebx
    push    esi
    lea     esi, [ecx+ecx*2]
    xor     eax, eax
    shl     esi, 1
    push    edi
    mov     ax, [edx+esi]
    lea     eax, [eax+eax*2]
    cmp     [edx+eax*2+2], cx
    lea     eax, [edx+eax*2]
    mov     edx, [esp+0Ch+arg_4]
    jnz     short loc_4D0BAF
    mov     [eax+2], dx
    jmp     short loc_4D0BB3
    ; ---------------------------------------------------------------------------

    loc_4D0BAF:                             ; CODE XREF: sub_4D0B80+27j
    mov     [eax+4], dx

    loc_4D0BB3:                             ; CODE XREF: sub_4D0B80+2Dj
    mov     ecx, dword_526FF0
    lea     eax, [edx+edx*2]
    shl     eax, 1
    lea     edi, [ecx+esi]
    add     ecx, eax
    mov     ebx, [edi]
    mov     [ecx], ebx
    mov     di, [edi+4]
    mov     [ecx+4], di
    mov     edi, dword_526FF0
    xor     ecx, ecx
    mov     cx, [edi+eax+2]
    lea     ecx, [ecx+ecx*2]
    mov     [edi+ecx*2], dx
    mov     edi, dword_526FF0
    xor     ecx, ecx
    mov     cx, [edi+eax+4]
    lea     eax, [ecx+ecx*2]
    mov     [edi+eax*2], dx
    mov     ecx, dword_526FF0
    pop     edi
    mov     word ptr [ecx+esi], 0
    pop     esi
    pop     ebx
    retn    8
    sub_4D0B80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D0C10 proc near                    ; CODE XREF: DoNetworkCompression+38Bp

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    mov     edx, dword_526FF0
    lea     ecx, [eax+eax*2]
    xor     eax, eax
    mov     ax, [edx+ecx*2+2]
    lea     ecx, [eax+eax*2]
    mov     cx, [edx+ecx*2+4]
    test    cx, cx
    jz      short locret_4D0C45

    loc_4D0C31:                             ; CODE XREF: sub_4D0C10+33j
    mov     eax, ecx
    and     eax, 0FFFFh
    lea     ecx, [eax+eax*2]
    mov     cx, [edx+ecx*2+4]
    test    cx, cx
    jnz     short loc_4D0C31

    locret_4D0C45:                          ; CODE XREF: sub_4D0C10+1Fj
    retn    4
    sub_4D0C10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D0C50 proc near                    ; CODE XREF: sub_4D0C50+106p
                                            ; DoNetworkCompression+393p

    arg_0= dword ptr  4

    mov     ecx, dword_526FF0
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_0]
    push    esi
    push    edi
    lea     edi, [ebp+ebp*2+0]
    shl     edi, 1
    mov     bx, [ecx+edi]
    test    bx, bx
    jz      loc_4D0DCE
    mov     ax, [ecx+edi+4]
    test    ax, ax
    jnz     short loc_4D0CD0
    xor     eax, eax
    mov     ax, [ecx+edi+2]
    lea     edx, [eax+eax*2]
    mov     [ecx+edx*2], bx
    mov     edx, dword_526FF0
    xor     ecx, ecx
    mov     cx, [edx+edi]
    lea     ecx, [ecx+ecx*2]
    cmp     [edx+ecx*2+4], bp
    lea     ecx, [edx+ecx*2]
    jnz     short loc_4D0CB9
    mov     [ecx+4], ax
    mov     edx, dword_526FF0
    mov     word ptr [edx+edi], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D0CB9:                             ; CODE XREF: sub_4D0C50+50j
    mov     [ecx+2], ax
    mov     edx, dword_526FF0
    mov     word ptr [edx+edi], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D0CD0:                             ; CODE XREF: sub_4D0C50+29j
    mov     si, [ecx+edi+2]
    test    si, si
    jnz     short loc_4D0D2D
    and     eax, 0FFFFh
    mov     edx, eax
    lea     eax, [edx+edx*2]
    mov     [ecx+eax*2], bx
    mov     ecx, dword_526FF0
    xor     eax, eax
    mov     ax, [ecx+edi]
    lea     eax, [eax+eax*2]
    cmp     [ecx+eax*2+4], bp
    lea     eax, [ecx+eax*2]
    jnz     short loc_4D0D16
    mov     [eax+4], dx
    mov     ecx, dword_526FF0
    mov     [ecx+edi], si
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D0D16:                             ; CODE XREF: sub_4D0C50+AFj
    mov     [eax+2], dx
    mov     ecx, dword_526FF0
    mov     word ptr [ecx+edi], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D0D2D:                             ; CODE XREF: sub_4D0C50+88j
    and     esi, 0FFFFh
    lea     edx, [esi+esi*2]
    mov     ax, [ecx+edx*2+4]
    test    ax, ax
    jz      short loc_4D0D55

    loc_4D0D40:                             ; CODE XREF: sub_4D0C50+103j
    mov     esi, eax
    and     esi, 0FFFFh
    lea     eax, [esi+esi*2]
    mov     ax, [ecx+eax*2+4]
    test    ax, ax
    jnz     short loc_4D0D40

    loc_4D0D55:                             ; CODE XREF: sub_4D0C50+EEj
    push    esi
    call    sub_4D0C50
    mov     ecx, dword_526FF0
    xor     eax, eax
    mov     ax, [ecx+edi]
    lea     edx, [eax+eax*2]
    cmp     [ecx+edx*2+2], bp
    lea     eax, [ecx+edx*2]
    jnz     short loc_4D0D7A
    mov     [eax+2], si
    jmp     short loc_4D0D7E
    ; ---------------------------------------------------------------------------

    loc_4D0D7A:                             ; CODE XREF: sub_4D0C50+122j
    mov     [eax+4], si

    loc_4D0D7E:                             ; CODE XREF: sub_4D0C50+128j
    mov     ecx, dword_526FF0
    lea     eax, [esi+esi*2]
    shl     eax, 1
    lea     edx, [ecx+edi]
    add     ecx, eax
    mov     ebx, [edx]
    mov     [ecx], ebx
    mov     dx, [edx+4]
    mov     [ecx+4], dx
    mov     edx, dword_526FF0
    xor     ecx, ecx
    mov     cx, [edx+eax+2]
    lea     ecx, [ecx+ecx*2]
    mov     [edx+ecx*2], si
    mov     edx, dword_526FF0
    xor     ecx, ecx
    mov     cx, [edx+eax+4]
    lea     eax, [ecx+ecx*2]
    mov     [edx+eax*2], si
    mov     ecx, dword_526FF0
    mov     word ptr [ecx+edi], 0

    loc_4D0DCE:                             ; CODE XREF: sub_4D0C50+1Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    sub_4D0C50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D0DE0 proc near                    ; CODE XREF: DoNetworkCompression+3EFp
                                            ; .text:004D1769p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    mov     ecx, [esp+4+arg_0]
    push    ebx
    push    ebp
    push    esi
    test    ecx, ecx
    push    edi
    jnz     short loc_4D0DF7
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D0DF7:                             ; CODE XREF: sub_4D0DE0+Bj
    mov     eax, dword_526FF0
    mov     ebx, dword_526FF4
    xor     esi, esi
    mov     [esp+14h+var_4], 0
    mov     si, [eax+6004h]

    loc_4D0E13:                             ; CODE XREF: sub_4D0DE0+B2j
    mov     edi, esi
    xor     eax, eax
    sub     edi, ecx

    loc_4D0E19:                             ; CODE XREF: sub_4D0DE0+5Bj
    lea     edx, [edi+ecx]
    and     edx, 0FFFh
    movsx   ebp, byte ptr [edx+ebx]
    mov     edx, ecx
    and     edx, 0FFFh
    movsx   edx, byte ptr [edx+ebx]
    sub     edx, ebp
    jnz     short loc_4D0E3D
    inc     eax
    inc     ecx
    cmp     eax, 11h
    jl      short loc_4D0E19

    loc_4D0E3D:                             ; CODE XREF: sub_4D0DE0+54j
    mov     edi, [esp+14h+var_4]
    cmp     eax, edi
    jl      short loc_4D0E5C
    mov     ecx, [esp+14h+arg_4]
    mov     edi, eax
    cmp     eax, 11h
    mov     [esp+14h+var_4], edi
    mov     [ecx], esi
    jge     short loc_4D0E97
    mov     ebx, dword_526FF4

    loc_4D0E5C:                             ; CODE XREF: sub_4D0DE0+63j
    test    edx, edx
    jl      short loc_4D0E6E
    mov     eax, dword_526FF0
    lea     edx, [esi+esi*2]
    lea     ecx, [eax+edx*2+4]
    jmp     short loc_4D0E7B
    ; ---------------------------------------------------------------------------

    loc_4D0E6E:                             ; CODE XREF: sub_4D0DE0+7Ej
    mov     edx, dword_526FF0
    lea     ecx, [esi+esi*2]
    lea     ecx, [edx+ecx*2+2]

    loc_4D0E7B:                             ; CODE XREF: sub_4D0DE0+8Cj
    mov     ax, [ecx]
    test    ax, ax
    jz      loc_4D0F1B
    mov     ecx, [esp+14h+arg_0]
    and     eax, 0FFFFh
    mov     esi, eax
    jmp     loc_4D0E13
    ; ---------------------------------------------------------------------------

    loc_4D0E97:                             ; CODE XREF: sub_4D0DE0+74j
    mov     edx, dword_526FF0
    lea     edi, [esi+esi*2]
    shl     edi, 1
    xor     ecx, ecx
    mov     cx, [edx+edi]
    lea     ecx, [ecx+ecx*2]
    cmp     [edx+ecx*2+2], si
    mov     esi, [esp+14h+arg_0]
    lea     ecx, [edx+ecx*2]
    jnz     short loc_4D0EBF
    mov     [ecx+2], si
    jmp     short loc_4D0EC3
    ; ---------------------------------------------------------------------------

    loc_4D0EBF:                             ; CODE XREF: sub_4D0DE0+D7j
    mov     [ecx+4], si

    loc_4D0EC3:                             ; CODE XREF: sub_4D0DE0+DDj
    mov     edx, dword_526FF0
    lea     ecx, [esi+esi*2]
    shl     ecx, 1
    lea     ebx, [edx+edi]
    add     edx, ecx
    mov     ebp, [ebx]
    mov     [edx], ebp
    mov     bx, [ebx+4]
    mov     [edx+4], bx
    mov     ebx, dword_526FF0
    xor     edx, edx
    mov     dx, [ebx+ecx+2]
    lea     edx, [edx+edx*2]
    mov     [ebx+edx*2], si
    mov     ebx, dword_526FF0
    xor     edx, edx
    mov     dx, [ebx+ecx+4]
    lea     ecx, [edx+edx*2]
    mov     [ebx+ecx*2], si
    mov     edx, dword_526FF0
    mov     word ptr [edx+edi], 0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D0F1B:                             ; CODE XREF: sub_4D0DE0+A1j
    mov     eax, [esp+14h+arg_0]
    mov     [ecx], ax
    mov     ecx, dword_526FF0
    lea     eax, [eax+eax*2]
    shl     eax, 1
    mov     [ecx+eax], si
    mov     edx, dword_526FF0
    mov     word ptr [edx+eax+4], 0
    mov     ecx, dword_526FF0
    mov     word ptr [ecx+eax+2], 0
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    sub_4D0DE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    DoNetworkCompression proc near          ; CODE XREF: Network_SendNetMessage+21p
                                            ; sub_4D1820+143p

    var_1B0= dword ptr -1B0h
    var_1AC= dword ptr -1ACh
    var_1A8= dword ptr -1A8h
    var_1A4= dword ptr -1A4h
    var_1A0= dword ptr -1A0h
    var_19C= dword ptr -19Ch
    var_198= dword ptr -198h
    var_194= dword ptr -194h
    var_190= dword ptr -190h
    var_18C= dword ptr -18Ch
    var_188= byte ptr -188h
    var_104= dword ptr -104h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 1B0h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    ds:GetCurrentThreadId
    mov     edi, ds:WaitForSingleObject
    mov     esi, eax

    loc_4D0F78:                             ; CODE XREF: DoNetworkCompression+3Aj
    push    esi                             ; Value
    push    offset dword_52A4FC             ; Target
    call    ds:InterlockedExchange
    test    eax, eax
    jz      short loc_4D0F9C
    cmp     dword_52A4F4, esi
    jz      short loc_4D0FAC
    mov     eax, hEvent
    push    0FFFFFFFFh                      ; dwMilliseconds
    push    eax                             ; hHandle
    call    edi ; WaitForSingleObject
    jmp     short loc_4D0F78
    ; ---------------------------------------------------------------------------

    loc_4D0F9C:                             ; CODE XREF: DoNetworkCompression+26j
    mov     dword_52A4F4, esi
    mov     [esp+1C0h+var_1A0], 0
    jmp     short loc_4D0FB0
    ; ---------------------------------------------------------------------------

    loc_4D0FAC:                             ; CODE XREF: DoNetworkCompression+2Ej
    mov     [esp+1C0h+var_1A0], eax

    loc_4D0FB0:                             ; CODE XREF: DoNetworkCompression+4Aj
    mov     ecx, [esp+1C0h+arg_8]
    mov     ebp, [esp+1C0h+arg_4]
    mov     ebx, [esp+1C0h+arg_0]
    push    1011h                           ; size_t
    lea     esi, [ecx+ebp]
    push    1                               ; size_t
    mov     [esp+1C8h+var_18C], ebx
    mov     [esp+1C8h+var_190], esi
    call    _calloc
    xor     edi, edi
    add     esp, 8
    cmp     eax, edi
    mov     dword_526FF4, eax
    jnz     short loc_4D102E
    push    offset aCouldNotAllocD          ; "Could not alloc decompression window.\n"
    call    _printf
    mov     eax, [esp+1C4h+var_1A0]
    add     esp, 4
    cmp     eax, edi
    jnz     short loc_4D1079
    push    edi                             ; Value
    push    offset dword_52A4FC             ; Target
    mov     dword_52A4F4, edi
    call    ds:InterlockedExchange
    mov     edx, hEvent
    push    edx                             ; hEvent
    call    ds:SetEvent
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1B0h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D102E:                             ; CODE XREF: DoNetworkCompression+88j
    push    6                               ; size_t
    push    1001h                           ; size_t
    call    _calloc
    add     esp, 8
    cmp     eax, edi
    mov     dword_526FF0, eax
    jnz     short loc_4D1089
    push    offset aCouldNotAllocC          ; "Could not alloc compression tree.\n"
    call    _printf
    mov     eax, [esp+1C4h+var_1A0]
    add     esp, 4
    cmp     eax, edi
    jnz     short loc_4D1079
    push    edi                             ; Value
    push    offset dword_52A4FC             ; Target
    mov     dword_52A4F4, edi
    call    ds:InterlockedExchange
    mov     eax, hEvent
    push    eax                             ; hEvent
    call    ds:SetEvent

    loc_4D1079:                             ; CODE XREF: DoNetworkCompression+9Dj
                                            ; DoNetworkCompression+F9j
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1B0h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D1089:                             ; CODE XREF: DoNetworkCompression+E4j
    mov     edx, dword_526FF8
    mov     ecx, 1
    cmp     edx, edi
    mov     [esp+1C0h+var_1A8], ecx
    jz      short loc_4D10D3
    cmp     Global_NetworkCompressData, edi
    jz      short loc_4D10D3
    mov     edi, dword_526FF4
    mov     ecx, 404h
    mov     esi, offset dword_51FFD0
    rep movsd
    movsb
    mov     edi, dword_526FF0
    mov     ecx, 1801h
    mov     esi, offset dword_520FE8
    rep movsd
    movsw
    mov     esi, [esp+1C0h+var_190]
    xor     edi, edi
    jmp     short loc_4D1112
    ; ---------------------------------------------------------------------------

    loc_4D10D3:                             ; CODE XREF: DoNetworkCompression+13Aj
                                            ; DoNetworkCompression+142j
    mov     [eax+6000h], di
    mov     edx, dword_526FF0
    mov     [edx+6004h], cx
    mov     eax, dword_526FF0
    mov     [eax+6002h], di
    mov     ecx, dword_526FF0
    mov     word ptr [ecx+6], 1000h
    mov     edx, dword_526FF0
    mov     [edx+0Ah], di
    mov     eax, dword_526FF0
    mov     [eax+8], di

    loc_4D1112:                             ; CODE XREF: DoNetworkCompression+171j
    xor     eax, eax

    loc_4D1114:                             ; CODE XREF: DoNetworkCompression+1CAj
    cmp     ebp, esi
    jnb     short loc_4D112C
    mov     edx, dword_526FF4
    mov     cl, [ebp+0]
    inc     ebp
    mov     [edx+eax+1], cl
    inc     eax
    cmp     eax, 11h
    jl      short loc_4D1114

    loc_4D112C:                             ; CODE XREF: DoNetworkCompression+1B6j
    mov     esi, eax
    cmp     eax, edi
    mov     [esp+1C0h+arg_4], ebp
    mov     [esp+1C0h+var_1A4], esi
    mov     [esp+1C0h+var_1AC], edi
    mov     [esp+1C0h+var_194], edi
    mov     ecx, 1
    mov     byte ptr [esp+1C0h+var_1B0], 0
    jle     loc_4D1383
    mov     edi, dword_526FF0
    mov     eax, [esp+1C0h+var_1AC]
    jmp     short loc_4D1163
    ; ---------------------------------------------------------------------------

    loc_4D115F:                             ; CODE XREF: DoNetworkCompression+417j
    mov     ecx, [esp+1C0h+var_19C]

    loc_4D1163:                             ; CODE XREF: DoNetworkCompression+1FDj
    cmp     eax, esi
    jle     short loc_4D116B
    mov     [esp+1C0h+var_1AC], esi

    loc_4D116B:                             ; CODE XREF: DoNetworkCompression+205j
    mov     eax, [esp+1C0h+var_1AC]
    cmp     eax, 1
    jg      short loc_4D118C
    mov     edx, [esp+1C0h+var_1A8]
    mov     esi, dword_526FF4
    mov     ebp, 1
    mov     dl, [edx+esi]
    mov     [esp+ecx+1C0h+var_188], dl
    jmp     short loc_4D11B1
    ; ---------------------------------------------------------------------------

    loc_4D118C:                             ; CODE XREF: DoNetworkCompression+212j
    mov     esi, [esp+1C0h+var_194]
    mov     dl, al
    sub     dl, 2
    mov     ebp, eax
    and     edx, 0Fh
    shl     esi, 4
    or      edx, esi
    mov     word ptr [esp+ecx*2+1C0h+var_104], dx
    mov     dl, byte ptr [esp+1C0h+var_1B0]
    or      dl, cl
    mov     byte ptr [esp+1C0h+var_1B0], dl

    loc_4D11B1:                             ; CODE XREF: DoNetworkCompression+22Aj
    shl     ecx, 1
    test    ch, 1
    mov     [esp+1C0h+var_19C], ecx
    jz      short loc_4D1216
    mov     al, byte ptr [esp+1C0h+var_1B0]
    mov     esi, [esp+1C0h+var_1B0]
    mov     [ebx], al
    inc     ebx
    xor     ecx, ecx
    and     esi, 0FFh

    loc_4D11CF:                             ; CODE XREF: DoNetworkCompression+29Dj
    mov     eax, 1
    shl     eax, cl
    test    esi, eax
    jnz     short loc_4D11E0
    mov     dl, [esp+eax+1C0h+var_188]
    jmp     short loc_4D11F6
    ; ---------------------------------------------------------------------------

    loc_4D11E0:                             ; CODE XREF: DoNetworkCompression+278j
    mov     dl, byte ptr [esp+eax*2+1C0h+var_104]
    lea     eax, [esp+eax*2+1C0h+var_104]
    mov     [ebx], dl
    inc     ebx
    xor     edx, edx
    mov     dl, [eax+1]

    loc_4D11F6:                             ; CODE XREF: DoNetworkCompression+27Ej
    mov     [ebx], dl
    inc     ebx
    inc     ecx
    cmp     ecx, 8
    jl      short loc_4D11CF
    mov     edi, dword_526FF0
    mov     eax, [esp+1C0h+var_1AC]
    mov     [esp+1C0h+var_19C], 1
    mov     byte ptr [esp+1C0h+var_1B0], 0

    loc_4D1216:                             ; CODE XREF: DoNetworkCompression+25Aj
    test    ebp, ebp
    jle     loc_4D1371
    mov     [esp+1C0h+var_198], ebp

    loc_4D1222:                             ; CODE XREF: DoNetworkCompression+407j
    mov     eax, [esp+1C0h+var_1A8]
    lea     esi, [eax+11h]
    and     esi, 0FFFh
    lea     eax, [esi+esi*2]
    shl     eax, 1
    mov     bp, [edi+eax]
    test    bp, bp
    jz      loc_4D1305
    mov     cx, [edi+eax+4]
    test    cx, cx
    jnz     short loc_4D1296
    xor     ecx, ecx
    mov     cx, [edi+eax+2]
    lea     edx, [ecx+ecx*2]
    mov     [edi+edx*2], bp
    mov     edi, dword_526FF0
    xor     edx, edx
    mov     dx, [edi+eax]
    lea     edx, [edx+edx*2]
    cmp     [edi+edx*2+4], si
    lea     edx, [edi+edx*2]
    jnz     short loc_4D1284
    mov     [edx+4], cx
    mov     ecx, dword_526FF0
    mov     word ptr [ecx+eax], 0
    jmp     short loc_4D12FF
    ; ---------------------------------------------------------------------------

    loc_4D1284:                             ; CODE XREF: DoNetworkCompression+310j
    mov     [edx+2], cx
    mov     ecx, dword_526FF0
    mov     word ptr [ecx+eax], 0
    jmp     short loc_4D12FF
    ; ---------------------------------------------------------------------------

    loc_4D1296:                             ; CODE XREF: DoNetworkCompression+2E9j
    cmp     word ptr [edi+eax+2], 0
    jnz     short loc_4D12EA
    and     ecx, 0FFFFh
    mov     edx, ecx
    lea     ecx, [edx+edx*2]
    mov     [edi+ecx*2], bp
    mov     edi, dword_526FF0
    xor     ecx, ecx
    mov     cx, [edi+eax]
    lea     ecx, [ecx+ecx*2]
    cmp     [edi+ecx*2+4], si
    lea     ecx, [edi+ecx*2]
    jnz     short loc_4D12D8
    mov     [ecx+4], dx
    mov     edx, dword_526FF0
    mov     word ptr [edx+eax], 0
    jmp     short loc_4D12FF
    ; ---------------------------------------------------------------------------

    loc_4D12D8:                             ; CODE XREF: DoNetworkCompression+364j
    mov     [ecx+2], dx
    mov     edx, dword_526FF0
    mov     word ptr [edx+eax], 0
    jmp     short loc_4D12FF
    ; ---------------------------------------------------------------------------

    loc_4D12EA:                             ; CODE XREF: DoNetworkCompression+33Cj
    push    esi
    call    sub_4D0C10
    mov     edi, eax
    push    edi
    call    sub_4D0C50
    push    edi
    push    esi
    call    sub_4D0B80

    loc_4D12FF:                             ; CODE XREF: DoNetworkCompression+322j
                                            ; DoNetworkCompression+334j ...
    mov     edi, dword_526FF0

    loc_4D1305:                             ; CODE XREF: DoNetworkCompression+2DBj
    mov     eax, [esp+1C0h+arg_4]
    mov     ecx, [esp+1C0h+var_190]
    cmp     eax, ecx
    jb      short loc_4D131A
    dec     [esp+1C0h+var_1A4]
    jmp     short loc_4D1333
    ; ---------------------------------------------------------------------------

    loc_4D131A:                             ; CODE XREF: DoNetworkCompression+3B2j
    mov     edx, dword_526FF4
    mov     cl, [eax]
    inc     eax
    mov     [edx+esi], cl
    mov     edi, dword_526FF0
    mov     [esp+1C0h+arg_4], eax

    loc_4D1333:                             ; CODE XREF: DoNetworkCompression+3B8j
    mov     eax, [esp+1C0h+var_1A8]
    mov     ecx, [esp+1C0h+var_1A4]
    inc     eax
    and     eax, 0FFFh
    test    ecx, ecx
    mov     [esp+1C0h+var_1A8], eax
    jz      short loc_4D135E
    lea     ecx, [esp+1C0h+var_194]
    push    ecx
    push    eax
    call    sub_4D0DE0
    mov     edi, dword_526FF0
    mov     [esp+1C0h+var_1AC], eax

    loc_4D135E:                             ; CODE XREF: DoNetworkCompression+3E7j
    mov     eax, [esp+1C0h+var_198]
    dec     eax
    mov     [esp+1C0h+var_198], eax
    jnz     loc_4D1222
    mov     eax, [esp+1C0h+var_1AC]

    loc_4D1371:                             ; CODE XREF: DoNetworkCompression+2B8j
    mov     esi, [esp+1C0h+var_1A4]
    test    esi, esi
    jg      loc_4D115F
    mov     ecx, [esp+1C0h+var_19C]
    xor     edi, edi

    loc_4D1383:                             ; CODE XREF: DoNetworkCompression+1EDj
    mov     dl, byte ptr [esp+1C0h+var_1B0]
    mov     word ptr [esp+ecx*2+1C0h+var_104], di
    or      dl, cl
    cmp     ecx, edi
    mov     byte ptr [esp+1C0h+var_1B0], dl
    mov     esi, 1
    jz      short loc_4D13A3

    loc_4D139E:                             ; CODE XREF: DoNetworkCompression+441j
    inc     esi
    shr     ecx, 1
    jnz     short loc_4D139E

    loc_4D13A3:                             ; CODE XREF: DoNetworkCompression+43Cj
    mov     dl, byte ptr [esp+1C0h+var_1B0]
    xor     ecx, ecx
    mov     [ebx], dl
    inc     ebx
    cmp     esi, edi
    jle     short loc_4D13ED
    mov     edi, [esp+1C0h+var_1B0]
    and     edi, 0FFh

    loc_4D13BA:                             ; CODE XREF: DoNetworkCompression+489j
    mov     eax, 1
    shl     eax, cl
    test    edi, eax
    jnz     short loc_4D13CD
    mov     al, [esp+eax+1C0h+var_188]
    mov     [ebx], al
    jmp     short loc_4D13E5
    ; ---------------------------------------------------------------------------

    loc_4D13CD:                             ; CODE XREF: DoNetworkCompression+463j
    mov     dl, byte ptr [esp+eax*2+1C0h+var_104]
    lea     eax, [esp+eax*2+1C0h+var_104]
    mov     [ebx], dl
    inc     ebx
    xor     edx, edx
    mov     dl, [eax+1]
    mov     [ebx], dl

    loc_4D13E5:                             ; CODE XREF: DoNetworkCompression+46Bj
    inc     ebx
    inc     ecx
    cmp     ecx, esi
    jl      short loc_4D13BA
    xor     edi, edi

    loc_4D13ED:                             ; CODE XREF: DoNetworkCompression+44Ej
    mov     eax, dword_526FF0
    cmp     eax, edi
    jnz     short loc_4D1405
    push    offset aHeyTheTreePtrI          ; "Hey!  The tree ptr is not pointing to a"...
    call    _printf
    add     esp, 4
    jmp     short loc_4D1414
    ; ---------------------------------------------------------------------------

    loc_4D1405:                             ; CODE XREF: DoNetworkCompression+494j
    push    eax                             ; void *
    call    _free
    add     esp, 4
    mov     dword_526FF0, edi

    loc_4D1414:                             ; CODE XREF: DoNetworkCompression+4A3j
    mov     eax, dword_526FF4
    cmp     eax, edi
    jnz     short loc_4D142C
    push    offset aHeyTheWindowBu          ; "Hey!  The window buffer ptr is not poin"...
    call    _printf
    add     esp, 4
    jmp     short loc_4D143B
    ; ---------------------------------------------------------------------------

    loc_4D142C:                             ; CODE XREF: DoNetworkCompression+4BBj
    push    eax                             ; void *
    call    _free
    add     esp, 4
    mov     dword_526FF4, edi

    loc_4D143B:                             ; CODE XREF: DoNetworkCompression+4CAj
    mov     ecx, [esp+1C0h+var_18C]
    mov     eax, [esp+1C0h+var_1A0]
    sub     ebx, ecx
    cmp     eax, edi
    mov     esi, ebx
    jnz     short loc_4D1469
    push    edi                             ; Value
    push    offset dword_52A4FC             ; Target
    mov     dword_52A4F4, edi
    call    ds:InterlockedExchange
    mov     eax, hEvent
    push    eax                             ; hEvent
    call    ds:SetEvent

    loc_4D1469:                             ; CODE XREF: DoNetworkCompression+4E9j
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1B0h
    retn    0Ch
    DoNetworkCompression endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1480 proc near                    ; CODE XREF: sub_44F9C0+161p
                                            ; sub_4D1970+104p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    ds:GetCurrentThreadId
    mov     edi, ds:WaitForSingleObject
    mov     esi, eax

    loc_4D1495:                             ; CODE XREF: sub_4D1480+39j
    mov     ebx, ds:InterlockedExchange
    push    esi                             ; Value
    push    offset dword_52A4FC             ; Target
    call    ebx ; InterlockedExchange
    test    eax, eax
    jz      short loc_4D14BB
    cmp     dword_52A4F4, esi
    jz      short loc_4D14CB
    mov     eax, hEvent
    push    0FFFFFFFFh                      ; dwMilliseconds
    push    eax                             ; hHandle
    call    edi ; WaitForSingleObject
    jmp     short loc_4D1495
    ; ---------------------------------------------------------------------------

    loc_4D14BB:                             ; CODE XREF: sub_4D1480+25j
    mov     dword_52A4F4, esi
    mov     [esp+1Ch+var_8], 0
    jmp     short loc_4D14CF
    ; ---------------------------------------------------------------------------

    loc_4D14CB:                             ; CODE XREF: sub_4D1480+2Dj
    mov     [esp+1Ch+var_8], eax

    loc_4D14CF:                             ; CODE XREF: sub_4D1480+49j
    mov     ebp, [esp+1Ch+arg_0]
    push    1011h                           ; size_t
    push    1                               ; size_t
    mov     [esp+24h+var_4], ebp
    call    _calloc
    add     esp, 8
    mov     dword_526FF4, eax
    test    eax, eax
    jnz     short loc_4D1531
    push    offset aCouldNotAllocD          ; "Could not alloc decompression window.\n"
    call    _printf
    mov     eax, [esp+20h+var_8]
    add     esp, 4
    test    eax, eax
    jnz     short loc_4D1524
    push    0                               ; Value
    push    offset dword_52A4FC             ; Target
    mov     dword_52A4F4, 0
    call    ebx ; InterlockedExchange
    mov     ecx, hEvent
    push    ecx                             ; hEvent
    call    ds:SetEvent

    loc_4D1524:                             ; CODE XREF: sub_4D1480+82j
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D1531:                             ; CODE XREF: sub_4D1480+6Dj
    mov     ecx, dword_526FF8
    test    ecx, ecx
    jz      short loc_4D1554
    mov     ecx, Global_NetworkCompressData
    test    ecx, ecx
    jz      short loc_4D1554
    mov     ecx, 404h
    mov     esi, offset dword_51FFD0
    mov     edi, eax
    rep movsd
    movsb

    loc_4D1554:                             ; CODE XREF: sub_4D1480+B9j
                                            ; sub_4D1480+C3j
    mov     ebx, [esp+1Ch+arg_4]
    mov     eax, 1
    mov     [esp+1Ch+var_C], eax
    mov     dl, [ebx]
    inc     ebx
    mov     byte ptr [esp+1Ch+arg_0], dl

    loc_4D1568:                             ; CODE XREF: sub_4D1480+16Bj
                                            ; sub_4D1480+180j
    mov     cl, byte ptr [esp+1Ch+arg_0]
    mov     dl, byte ptr [esp+1Ch+var_C]
    test    cl, dl
    jnz     short loc_4D158C
    mov     cl, [ebx]
    mov     [ebp+0], cl
    mov     edx, dword_526FF4
    inc     ebp
    inc     ebx
    mov     [eax+edx], cl
    inc     eax
    and     eax, 0FFFh
    jmp     short loc_4D15DE
    ; ---------------------------------------------------------------------------

    loc_4D158C:                             ; CODE XREF: sub_4D1480+F2j
    xor     ecx, ecx
    mov     cx, [ebx]
    add     ebx, 2
    mov     esi, ecx
    and     ecx, 0Fh
    shr     esi, 4
    add     ecx, 2
    mov     [esp+1Ch+arg_4], ebx
    test    esi, esi
    mov     edi, ecx
    jz      short loc_4D1605
    xor     edx, edx
    test    edi, edi
    jle     short loc_4D15DE

    loc_4D15AF:                             ; CODE XREF: sub_4D1480+158j
    mov     ebx, dword_526FF4
    lea     ecx, [esi+edx]
    and     ecx, 0FFFh
    inc     ebp
    inc     eax
    mov     cl, [ecx+ebx]
    mov     [ebp-1], cl
    mov     ebx, dword_526FF4
    mov     [eax+ebx-1], cl
    and     eax, 0FFFh
    inc     edx
    cmp     edx, edi
    jl      short loc_4D15AF
    mov     ebx, [esp+1Ch+arg_4]

    loc_4D15DE:                             ; CODE XREF: sub_4D1480+10Aj
                                            ; sub_4D1480+12Dj
    mov     ecx, [esp+1Ch+var_C]
    shl     ecx, 1
    test    ch, 1
    mov     [esp+1Ch+var_C], ecx
    jz      loc_4D1568
    mov     dl, [ebx]
    mov     [esp+1Ch+var_C], 1
    mov     byte ptr [esp+1Ch+arg_0], dl
    inc     ebx
    jmp     loc_4D1568
    ; ---------------------------------------------------------------------------

    loc_4D1605:                             ; CODE XREF: sub_4D1480+127j
    mov     eax, dword_526FF4
    test    eax, eax
    jnz     short loc_4D161D
    push    offset aHeyTheWindowBu          ; "Hey!  The window buffer ptr is not poin"...
    call    _printf
    add     esp, 4
    jmp     short loc_4D1630
    ; ---------------------------------------------------------------------------

    loc_4D161D:                             ; CODE XREF: sub_4D1480+18Cj
    push    eax                             ; void *
    call    _free
    add     esp, 4
    mov     dword_526FF4, 0

    loc_4D1630:                             ; CODE XREF: sub_4D1480+19Bj
    mov     ecx, [esp+1Ch+var_4]
    mov     eax, [esp+1Ch+var_8]
    sub     ebp, ecx
    test    eax, eax
    jnz     short loc_4D1661
    push    0                               ; Value
    push    offset dword_52A4FC             ; Target
    mov     dword_52A4F4, 0
    call    ds:InterlockedExchange
    mov     eax, hEvent
    push    eax                             ; hEvent
    call    ds:SetEvent

    loc_4D1661:                             ; CODE XREF: sub_4D1480+1BCj
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    8
    sub_4D1480 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    1011h
    push    1
    call    _calloc
    xor     ebp, ebp
    add     esp, 8
    cmp     eax, ebp
    mov     dword_526FF4, eax
    jnz     short loc_4D16A7
    push    offset aCouldNotAllocD          ; "Could not alloc decompression window.\n"
    call    _printf
    add     esp, 4
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D16A7:                             ; CODE XREF: .text:004D168Dj
    push    6
    push    1001h
    call    _calloc
    add     esp, 8
    cmp     eax, ebp
    mov     dword_526FF0, eax
    jnz     short loc_4D16D7
    push    offset aCouldNotAllocC          ; "Could not alloc compression tree.\n"
    call    _printf
    add     esp, 4
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D16D7:                             ; CODE XREF: .text:004D16BDj
    mov     ebx, [esp+1Ch]
    cmp     ebx, 0FA0h
    jle     short loc_4D16E8
    mov     ebx, 0FA0h

    loc_4D16E8:                             ; CODE XREF: .text:004D16E1j
    mov     [eax+6000h], bp
    mov     eax, dword_526FF0
    mov     esi, [esp+18h]
    mov     word ptr [eax+6004h], 12h
    mov     ecx, dword_526FF0
    mov     [ecx+6002h], bp
    mov     edx, dword_526FF0
    mov     word ptr [edx+6Ch], 1000h
    mov     eax, dword_526FF0
    mov     [eax+70h], bp
    mov     ecx, dword_526FF0
    mov     [ecx+6Eh], bp
    mov     edx, dword_526FF4
    mov     ecx, ebx
    mov     eax, ecx
    lea     edi, [edx+13h]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     eax, dword_526FF4
    mov     ecx, 404h
    mov     esi, eax
    mov     edi, offset dword_51FFD0
    rep movsd
    movsb
    xor     esi, esi
    cmp     ebx, ebp
    jle     short loc_4D1778

    loc_4D1760:                             ; CODE XREF: .text:004D1771j
    lea     ecx, [esp+10h]
    lea     edx, [esi+13h]
    push    ecx
    push    edx
    call    sub_4D0DE0
    inc     esi
    cmp     esi, ebx
    jl      short loc_4D1760
    mov     eax, dword_526FF4

    loc_4D1778:                             ; CODE XREF: .text:004D175Ej
    mov     esi, dword_526FF0
    mov     ecx, 1801h
    mov     edi, offset dword_520FE8
    cmp     eax, ebp
    rep movsd
    movsw
    mov     dword_526FF8, 1
    jnz     short loc_4D17A9
    push    offset aHeyTheWindowBu          ; "Hey!  The window buffer ptr is not poin"...
    call    _printf
    add     esp, 4
    jmp     short loc_4D17B8
    ; ---------------------------------------------------------------------------

    loc_4D17A9:                             ; CODE XREF: .text:004D1798j
    push    eax
    call    _free
    add     esp, 4
    mov     dword_526FF4, ebp

    loc_4D17B8:                             ; CODE XREF: .text:004D17A7j
    mov     eax, dword_526FF0
    cmp     eax, ebp
    jnz     short loc_4D17D8
    push    offset aHeyTheTreePtrI          ; "Hey!  The tree ptr is not pointing to a"...
    call    _printf
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D17D8:                             ; CODE XREF: .text:004D17BFj
    push    eax
    call    _free
    add     esp, 4
    mov     dword_526FF0, ebp
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    Network_StopCompression proc near       ; CODE XREF: sub_44F9C0+169p
                                            ; Network_SendNetMessage+28p
    mov     Global_NetworkCompressData, 0
    xor     eax, eax
    retn
    Network_StopCompression endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    Network_StartCompression proc near      ; CODE XREF: sub_44F9C0+155p
                                            ; Network_SendNetMessage+Dp
    mov     Global_NetworkCompressData, 1
    xor     eax, eax
    retn
    Network_StartCompression endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1820 proc near                    ; CODE XREF: sub_4B39C0+1EBp
                                            ; sub_4B3C60+557p ...

    var_10= byte ptr -10h
    var_E= byte ptr -0Eh
    var_D= dword ptr -0Dh
    var_9= dword ptr -9
    var_5= dword ptr -5
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 14h
    push    ebx
    mov     ebx, [esp+18h+arg_0]
    push    ebp
    push    esi
    lea     esi, [ebx+13h]
    push    edi
    test    esi, esi
    jnz     short loc_4D1841
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4D1841:                             ; CODE XREF: sub_4D1820+10j
    mov     ecx, [esp+24h+arg_8]
    test    ecx, ecx
    jnz     short loc_4D1858
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4D1858:                             ; CODE XREF: sub_4D1820+27j
    mov     edi, [esp+24h+arg_C]
    test    edi, edi
    jnz     short loc_4D186F
    mov     eax, 6
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4D186F:                             ; CODE XREF: sub_4D1820+3Ej
    mov     eax, [esp+24h+arg_10]
    cmp     eax, 4
    jl      short loc_4D1887
    mov     eax, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4D1887:                             ; CODE XREF: sub_4D1820+56j
    dec     eax
    jz      loc_4D1960
    dec     eax
    jnz     short loc_4D18A8
    mov     eax, [esp+24h+arg_4]
    push    edi
    push    ecx
    mov     edx, [eax]
    lea     eax, [esp+2Ch+arg_8]
    push    eax
    push    esi
    mov     [esp+34h+arg_8], edx
    call    sub_4D1C80

    loc_4D18A8:                             ; CODE XREF: sub_4D1820+6Fj
    mov     eax, [esp+24h+arg_8]

    loc_4D18AC:                             ; CODE XREF: sub_4D1820+148j
    mov     edx, [esp+24h+arg_4]
    lea     ecx, [eax+13h]
    mov     [esp+24h+arg_8], ecx
    cmp     ecx, [edx]
    jle     short loc_4D18CA
    mov     eax, 5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4D18CA:                             ; CODE XREF: sub_4D1820+99j
    mov     edx, [esp+24h+arg_14]
    test    edx, edx
    jz      short loc_4D18EB
    xor     ecx, ecx
    test    eax, eax
    jbe     short loc_4D18EB

    loc_4D18D8:                             ; CODE XREF: sub_4D1820+C5j
    mov     bl, cl
    xor     bl, [ecx+esi]
    add     bl, cl
    mov     [ecx+esi], bl
    inc     ecx
    cmp     ecx, eax
    jb      short loc_4D18D8
    mov     ebx, [esp+24h+arg_0]

    loc_4D18EB:                             ; CODE XREF: sub_4D1820+B0j
                                            ; sub_4D1820+B6j
    mov     cl, byte ptr [esp+24h+arg_10]
    mov     ebp, dword ptr aSqsh            ; "SQSH"
    mov     [esp+24h+var_D], eax
    mov     [esp+24h+var_9], edi
    add     eax, esi
    xor     edi, edi
    mov     [esp+15h], cl
    cmp     esi, eax
    mov     [esp+24h+var_10], 2
    mov     [esp+24h+var_E], dl
    mov     ecx, esi
    jnb     short loc_4D191F

    loc_4D1914:                             ; CODE XREF: sub_4D1820+FDj
    xor     edx, edx
    mov     dl, [ecx]
    add     edi, edx
    inc     ecx
    cmp     ecx, eax
    jb      short loc_4D1914

    loc_4D191F:                             ; CODE XREF: sub_4D1820+F2j
    mov     eax, dword ptr [esp+24h+var_10]
    mov     ecx, [esp+24h+var_D+1]
    mov     [esp+24h+var_5], edi
    mov     edx, [esp+24h+var_9+1]
    mov     [ebx], ebp
    mov     [ebx+4], eax
    mov     ax, word ptr [esp+24h+var_5+1]
    mov     [ebx+8], ecx
    mov     cl, byte ptr [esp+24h+var_5+3]
    mov     [ebx+0Ch], edx
    mov     edx, [esp+24h+arg_8]
    mov     [ebx+10h], ax
    mov     eax, [esp+24h+arg_4]
    pop     edi
    mov     [ebx+12h], cl
    pop     esi
    mov     [eax], edx
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 14h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4D1960:                             ; CODE XREF: sub_4D1820+68j
    push    edi
    push    ecx
    push    esi
    call    DoNetworkCompression
    jmp     loc_4D18AC
    sub_4D1820 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1970 proc near                    ; CODE XREF: sub_4B3770+DFp
                                            ; sub_4B4270+BAp ...

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= word ptr -4
    var_2= byte ptr -2
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    mov     edx, [esp+14h+arg_4]
    push    ebx
    mov     eax, edx
    push    ebp
    push    esi
    push    edi
    mov     ecx, [eax]
    mov     edi, offset aSqsh               ; "SQSH"
    mov     [esp+24h+var_14], ecx
    lea     esi, [esp+24h+var_14]
    mov     ecx, [eax+4]
    mov     ebx, edx
    mov     [esp+24h+var_10], ecx
    mov     ecx, [eax+8]
    mov     [esp+24h+var_C], ecx
    mov     ecx, [eax+0Ch]
    mov     [esp+24h+var_8], ecx
    mov     cx, [eax+10h]
    mov     [esp+24h+var_4], cx
    mov     ecx, 4
    mov     al, [eax+12h]
    mov     [esp+24h+var_2], al
    xor     eax, eax
    repe cmpsb
    jz      short loc_4D19CD
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D19CD:                             ; CODE XREF: sub_4D1970+4Cj
    cmp     byte ptr [esp+24h+var_10+1], 4
    jb      short loc_4D19E3
    mov     eax, 4
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D19E3:                             ; CODE XREF: sub_4D1970+62j
    mov     ebp, [esp+24h+var_10+3]
    add     edx, 13h
    xor     edi, edi
    mov     eax, edx
    lea     esi, [ebp+edx+0]
    cmp     edx, esi
    jnb     short loc_4D1A01

    loc_4D19F6:                             ; CODE XREF: sub_4D1970+8Fj
    xor     ecx, ecx
    mov     cl, [eax]
    add     edi, ecx
    inc     eax
    cmp     eax, esi
    jb      short loc_4D19F6

    loc_4D1A01:                             ; CODE XREF: sub_4D1970+84j
    cmp     [esp+24h+var_8+3], edi
    jz      short loc_4D1A16
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D1A16:                             ; CODE XREF: sub_4D1970+95j
    mov     al, byte ptr [esp+24h+var_10+2]
    test    al, al
    jz      short loc_4D1A33
    xor     eax, eax
    test    ebp, ebp
    jbe     short loc_4D1A33

    loc_4D1A24:                             ; CODE XREF: sub_4D1970+C1j
    mov     cl, [eax+edx]
    sub     cl, al
    xor     cl, al
    mov     [eax+edx], cl
    inc     eax
    cmp     eax, ebp
    jb      short loc_4D1A24

    loc_4D1A33:                             ; CODE XREF: sub_4D1970+ACj
                                            ; sub_4D1970+B2j
    mov     eax, [esp+24h+var_10+1]
    and     eax, 0FFh
    dec     eax
    jz      short loc_4D1A6E
    dec     eax
    jnz     short loc_4D1A7D
    mov     ecx, 4
    mov     edi, offset aSqsh               ; "SQSH"
    mov     esi, ebx
    xor     eax, eax
    repe cmpsb
    jnz     short loc_4D1A57
    mov     eax, [ebx+0Bh]

    loc_4D1A57:                             ; CODE XREF: sub_4D1970+E2j
    push    ebp
    push    edx
    mov     edx, [esp+2Ch+arg_0]
    lea     ecx, [esp+2Ch+arg_4]
    push    ecx
    push    edx
    mov     [esp+34h+arg_4], eax
    call    sub_4D1D20
    jmp     short loc_4D1A7D
    ; ---------------------------------------------------------------------------

    loc_4D1A6E:                             ; CODE XREF: sub_4D1970+CDj
    mov     eax, [esp+24h+arg_0]
    push    edx
    push    eax
    call    sub_4D1480
    mov     [esp+24h+arg_4], eax

    loc_4D1A7D:                             ; CODE XREF: sub_4D1970+D0j
                                            ; sub_4D1970+FCj
    mov     eax, [esp+24h+var_C+3]
    mov     esi, [esp+24h+arg_4]
    sub     eax, esi
    pop     edi
    neg     eax
    sbb     eax, eax
    pop     esi
    pop     ebp
    and     eax, 3
    pop     ebx
    add     esp, 14h
    retn    8
    sub_4D1970 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1AA0 proc near                    ; CODE XREF: sub_4B39C0+1AAp
                                            ; sub_4B3C60+52Fp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    dec     eax
    jz      short loc_4D1AD2
    dec     eax
    jz      short loc_4D1AB1
    xor     edx, edx
    mov     eax, edx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D1AB1:                             ; CODE XREF: sub_4D1AA0+8j
    mov     eax, [esp+arg_0]
    lea     ecx, [eax+eax*4]
    lea     eax, [eax+ecx*2]
    lea     edx, [eax+eax*4]
    mov     eax, 51EB851Fh
    shl     edx, 1
    mul     edx
    shr     edx, 5
    add     edx, 77h
    mov     eax, edx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D1AD2:                             ; CODE XREF: sub_4D1AA0+5j
    mov     eax, [esp+arg_0]
    lea     eax, [eax+eax*2]
    lea     ecx, [eax+eax*4]
    mov     eax, 51EB851Fh
    shl     ecx, 3
    mul     ecx
    shr     edx, 5
    add     edx, 77h
    mov     eax, edx
    retn    8
    sub_4D1AA0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    esi
    push    edi
    mov     ecx, 4
    mov     edi, offset aSqsh               ; "SQSH"
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      short loc_4D1B22
    mov     eax, 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D1B22:                             ; CODE XREF: .text:004D1B16j
    mov     al, [eax+5]
    cmp     al, 4
    jb      short loc_4D1B33
    mov     eax, 4
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D1B33:                             ; CODE XREF: .text:004D1B27j
    pop     edi
    and     eax, 0FFh
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1B40 proc near                    ; CODE XREF: sub_4B3770+C7p
                                            ; sub_4B4270+A6p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    push    edi
    mov     ecx, 4
    mov     edi, offset aSqsh               ; "SQSH"
    mov     esi, eax
    xor     edx, edx
    repe cmpsb
    jz      short loc_4D1B5F
    xor     eax, eax
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D1B5F:                             ; CODE XREF: sub_4D1B40+16j
    mov     eax, [eax+0Bh]
    pop     edi
    pop     esi
    retn    4
    sub_4D1B40 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+0Ch]
    xor     eax, eax
    test    esi, esi
    jbe     short loc_4D1B8D
    mov     ecx, [esp+8]

    loc_4D1B7F:                             ; CODE XREF: .text:004D1B8Bj
    mov     dl, [ecx]
    xor     dl, al
    add     dl, al
    mov     [ecx], dl
    inc     ecx
    inc     eax
    cmp     eax, esi
    jb      short loc_4D1B7F

    loc_4D1B8D:                             ; CODE XREF: .text:004D1B79j
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+0Ch]
    xor     eax, eax
    test    esi, esi
    jbe     short loc_4D1BBD
    mov     ecx, [esp+8]

    loc_4D1BAF:                             ; CODE XREF: .text:004D1BBBj
    mov     dl, [ecx]
    sub     dl, al
    xor     dl, al
    mov     [ecx], dl
    inc     ecx
    inc     eax
    cmp     eax, esi
    jb      short loc_4D1BAF

    loc_4D1BBD:                             ; CODE XREF: .text:004D1BA9j
    xor     eax, eax
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     ecx, [esp+4]
    mov     eax, [esp+8]
    push    esi
    xor     esi, esi
    lea     edx, [eax+ecx]
    cmp     ecx, edx
    jnb     short loc_4D1BED

    loc_4D1BE2:                             ; CODE XREF: .text:004D1BEBj
    xor     eax, eax
    mov     al, [ecx]
    add     esi, eax
    inc     ecx
    cmp     ecx, edx
    jb      short loc_4D1BE2

    loc_4D1BED:                             ; CODE XREF: .text:004D1BE0j
    mov     eax, esi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+8]
    xor     eax, eax
    mov     al, [esi+5]
    push    eax
    push    offset aHeader_packtyp          ; "\nheader.packType     = %d\n"
    call    _printf
    xor     ecx, ecx
    add     esp, 8
    mov     cl, [esi+6]
    push    ecx
    push    offset aHeader_encrypt          ; "header.encryptType  = %d\n"
    call    _printf
    mov     edx, [esi+7]
    add     esp, 8
    push    edx
    push    offset aHeader_packeds          ; "header.packedSize   = %ld\n"
    call    _printf
    mov     eax, [esi+0Bh]
    add     esp, 8
    push    eax
    push    offset aHeader_unpacke          ; "header.unpackedSize = %ld\n"
    call    _printf
    add     esp, 8
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1C60 proc near                    ; CODE XREF: sub_4B3770+E9p
                                            ; sub_4B4270+C8p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    cmp     eax, 7
    jge     short loc_4D1C73
    mov     eax, dword_50B9E0[eax*4]
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D1C73:                             ; CODE XREF: sub_4D1C60+7j
    xor     eax, eax
    retn    4
    sub_4D1C60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1C80 proc near                    ; CODE XREF: sub_4D1820+83p

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 38h
    mov     ecx, [esp+38h+arg_C]
    mov     eax, [esp+38h+arg_8]
    mov     edx, [esp+38h+arg_0]
    push    esi
    push    edi
    mov     edi, [esp+40h+arg_4]
    mov     [esp+40h+var_34], ecx
    push    38h
    mov     [esp+44h+var_38], eax
    mov     eax, [edi]
    push    offset a1_0_4                   ; "1.0.4"
    lea     ecx, [esp+48h+var_38]
    push    0FFFFFFFFh
    push    ecx
    mov     [esp+50h+var_2C], edx
    mov     [esp+50h+var_28], eax
    mov     [esp+50h+var_18], 0
    mov     [esp+50h+var_14], 0
    mov     [esp+50h+var_10], 0
    call    sub_4D1DB0
    test    eax, eax
    jnz     short loc_4D1D16
    lea     edx, [esp+40h+var_38]
    push    4
    push    edx
    call    sub_4D23C0
    mov     esi, eax
    cmp     esi, 1
    jz      short loc_4D1D06
    lea     eax, [esp+40h+var_38]
    push    eax
    call    sub_4D2830
    test    esi, esi
    mov     eax, 0FFFFFFFBh
    jz      short loc_4D1D16
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 38h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D1D06:                             ; CODE XREF: sub_4D1C80+67j
    mov     ecx, [esp+40h+var_24]
    lea     edx, [esp+40h+var_38]
    push    edx
    mov     [edi], ecx
    call    sub_4D2830

    loc_4D1D16:                             ; CODE XREF: sub_4D1C80+54j
                                            ; sub_4D1C80+7Aj
    pop     edi
    pop     esi
    add     esp, 38h
    retn    10h
    sub_4D1C80 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1D20 proc near                    ; CODE XREF: sub_4D1970+F7p

    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 38h
    mov     ecx, [esp+38h+arg_C]
    mov     eax, [esp+38h+arg_8]
    mov     edx, [esp+38h+arg_0]
    push    esi
    mov     esi, [esp+3Ch+arg_4]
    push    edi
    mov     [esp+40h+var_34], ecx
    mov     [esp+40h+var_38], eax
    mov     eax, [esi]
    push    38h
    lea     ecx, [esp+44h+var_38]
    xor     edi, edi
    push    offset a1_0_4                   ; "1.0.4"
    push    ecx
    mov     [esp+4Ch+var_2C], edx
    mov     [esp+4Ch+var_28], eax
    mov     [esp+4Ch+var_18], edi
    mov     [esp+4Ch+var_14], edi
    call    sub_4D3780
    cmp     eax, edi
    jnz     short loc_4D1D9D
    lea     edx, [esp+40h+var_38]
    push    4
    push    edx
    call    sub_4D37A0
    mov     edi, eax
    cmp     edi, 1
    jz      short loc_4D1D8D
    lea     eax, [esp+40h+var_38]
    push    eax
    call    sub_4D35A0
    mov     eax, edi
    pop     edi
    pop     esi
    add     esp, 38h
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D1D8D:                             ; CODE XREF: sub_4D1D20+57j
    mov     ecx, [esp+40h+var_24]
    lea     edx, [esp+40h+var_38]
    push    edx
    mov     [esi], ecx
    call    sub_4D35A0

    loc_4D1D9D:                             ; CODE XREF: sub_4D1D20+44j
    pop     edi
    pop     esi
    add     esp, 38h
    retn    10h
    sub_4D1D20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1DB0 proc near                    ; CODE XREF: sub_4D1C80+4Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_C]
    mov     ecx, [esp+arg_8]
    mov     edx, [esp+arg_4]
    push    eax
    mov     eax, [esp+4+arg_0]
    push    ecx
    push    0
    push    8
    push    0Fh
    push    8
    push    edx
    push    eax
    call    sub_4D1DE0
    retn    10h
    sub_4D1DB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D1DE0 proc near                    ; CODE XREF: sub_4D1DB0+1Cp

    var_34= dword ptr -34h
    var_24= dword ptr -24h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    mov     eax, [esp+arg_18]
    push    ebx
    push    ebp
    xor     edx, edx
    xor     ebp, ebp
    push    esi
    cmp     eax, edx
    push    edi
    jz      loc_4D20E1
    mov     al, [eax]
    mov     cl, byte ptr a1_0_4             ; "1.0.4"
    cmp     al, cl
    jnz     loc_4D20E1
    cmp     [esp+10h+arg_1C], 38h
    jnz     loc_4D20E1
    mov     edi, [esp+10h+arg_0]
    cmp     edi, edx
    jnz     short loc_4D1E23
    mov     eax, 0FFFFFFFEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D1E23:                             ; CODE XREF: sub_4D1DE0+35j
    mov     eax, [edi+20h]
    mov     [edi+18h], edx
    cmp     eax, edx
    jnz     short loc_4D1E37
    mov     dword ptr [edi+20h], offset loc_4D3D70
    mov     [edi+28h], edx

    loc_4D1E37:                             ; CODE XREF: sub_4D1DE0+4Bj
    cmp     [edi+24h], edx
    jnz     short loc_4D1E43
    mov     dword ptr [edi+24h], offset loc_4D3D90

    loc_4D1E43:                             ; CODE XREF: sub_4D1DE0+5Aj
    mov     ecx, [esp+10h+arg_4]
    cmp     ecx, 0FFFFFFFFh
    jnz     short loc_4D1E58
    mov     [esp+10h+arg_4], 6
    mov     ecx, [esp+10h+arg_4]

    loc_4D1E58:                             ; CODE XREF: sub_4D1DE0+6Aj
    mov     ebx, [esp+10h+arg_C]
    cmp     ebx, edx
    jge     short loc_4D1E67
    mov     ebp, 1
    neg     ebx

    loc_4D1E67:                             ; CODE XREF: sub_4D1DE0+7Ej
    mov     eax, [esp+10h+arg_10]
    cmp     eax, 1
    jl      loc_4D20D5
    cmp     eax, 9
    jg      loc_4D20D5
    cmp     [esp+10h+arg_8], 8
    jnz     loc_4D20D5
    cmp     ebx, 8
    jl      loc_4D20D5
    cmp     ebx, 0Fh
    jg      loc_4D20D5
    cmp     ecx, edx
    jl      loc_4D20D5
    cmp     ecx, 9
    jg      loc_4D20D5
    mov     eax, [esp+10h+arg_14]
    cmp     eax, edx
    jl      loc_4D20D5
    cmp     eax, 2
    jg      loc_4D20D5
    mov     ecx, [edi+28h]
    push    16B1h
    push    1
    push    ecx
    call    dword ptr [edi+20h]
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4D1EE0
    mov     eax, 0FFFFFFFCh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D1EE0:                             ; CODE XREF: sub_4D1DE0+F2j
    mov     [edi+1Ch], esi
    mov     [esi+14h], ebp
    mov     [esi+22h], ebx
    mov     ecx, ebx
    mov     ebx, [esp+1Ch+arg_4]
    mov     ebp, 1
    shl     ebp, cl
    lea     ecx, [ebx+7]
    mov     eax, 1
    shl     eax, cl
    mov     [esi+42h], ecx
    add     ecx, 2
    mov     [esi], edi
    mov     [esi+1Eh], ebp
    lea     edx, [ebp-1]
    push    2
    mov     [esi+3Eh], eax
    dec     eax
    mov     [esi+46h], eax
    mov     eax, 0AAAAAAABh
    mov     [esi+26h], edx
    mul     ecx
    shr     edx, 1
    mov     [esi+4Ah], edx
    mov     eax, [edi+28h]
    push    ebp
    push    eax
    call    dword ptr [edi+20h]
    mov     ecx, [esi+1Eh]
    mov     [esi+2Ah], eax
    mov     edx, [edi+28h]
    push    2
    push    ecx
    push    edx
    call    dword ptr [edi+20h]
    mov     [esi+32h], eax
    mov     eax, [esi+3Eh]
    mov     ecx, [edi+28h]
    push    2
    push    eax
    push    ecx
    call    dword ptr [edi+20h]
    mov     [esi+36h], eax
    lea     ecx, [ebx+6]
    mov     eax, 1
    push    4
    shl     eax, cl
    mov     [esi+168Bh], eax
    mov     edx, [edi+28h]
    push    eax
    push    edx
    call    dword ptr [edi+20h]
    mov     ecx, [esi+2Ah]
    xor     ebp, ebp
    cmp     ecx, ebp
    mov     [esi+8], eax
    jz      loc_4D20BB
    cmp     [esi+32h], ebp
    jz      loc_4D20BB
    cmp     [esi+36h], ebp
    jz      loc_4D20BB
    cmp     eax, ebp
    jz      loc_4D20BB
    mov     ecx, [esi+168Bh]
    mov     byte ptr [esi+19h], 8
    mov     edx, ecx
    shr     edx, 1
    lea     edx, [eax+edx*2]
    lea     eax, [eax+ecx*2]
    add     ecx, eax
    mov     [esi+1693h], edx
    mov     edx, [esp+4Ch+var_24]
    mov     [esi+1687h], ecx
    mov     ecx, [esp+4Ch+var_34]
    mov     [esi+7Ah], edx
    mov     [esi+76h], ecx
    mov     esi, [edi+1Ch]
    cmp     esi, ebp
    jz      loc_4D20AD
    cmp     [edi+20h], ebp
    jz      loc_4D20AD
    cmp     [edi+24h], ebp
    jz      loc_4D20AD
    mov     ebx, 2
    mov     [edi+14h], ebp
    mov     [edi+8], ebp
    mov     [edi+18h], ebp
    mov     [edi+2Ch], ebx
    mov     eax, [esi+8]
    mov     [esi+0Ch], eax
    mov     eax, [esi+14h]
    cmp     eax, ebp
    mov     [esi+10h], ebp
    jge     short loc_4D2006
    mov     [esi+14h], ebp

    loc_4D2006:                             ; CODE XREF: sub_4D1DE0+221j
    mov     ecx, [esi+14h]
    push    esi
    neg     ecx
    sbb     ecx, ecx
    and     ecx, 47h
    add     ecx, 2Ah
    mov     [esi+4], ecx
    mov     dword ptr [edi+30h], 1
    mov     [esi+1Ah], ebp
    call    sub_4D3DA0
    mov     edx, [esi+1Eh]
    mov     eax, [esi+3Eh]
    mov     ecx, [esi+36h]
    shl     edx, 1
    mov     [esi+2Eh], edx
    mov     [ecx+eax*2-2], bp
    mov     edx, [esi+3Eh]
    mov     edi, [esi+36h]
    xor     eax, eax
    lea     ecx, [edx+edx-2]
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    xor     edx, edx
    and     ecx, 3
    rep stosb
    mov     eax, [esi+76h]
    xor     ecx, ecx
    lea     eax, [eax+eax*2]
    shl     eax, 2
    mov     cx, word_50BB52[eax]
    mov     [esi+72h], ecx
    mov     dx, word_50BB50[eax]
    xor     ecx, ecx
    mov     [esi+7Eh], edx
    mov     cx, word_50BB54[eax]
    xor     edx, edx
    mov     [esi+82h], ecx
    mov     dx, word_50BB56[eax]
    mov     [esi+6Eh], edx
    mov     [esi+5Eh], ebp
    mov     [esi+4Eh], ebp
    mov     [esi+66h], ebp
    mov     [esi+6Ah], ebx
    mov     [esi+52h], ebx
    mov     [esi+5Ah], ebp
    mov     [esi+3Ah], ebp
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D20AD:                             ; CODE XREF: sub_4D1DE0+1EAj
                                            ; sub_4D1DE0+1F3j ...
    mov     ebp, 0FFFFFFFEh
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D20BB:                             ; CODE XREF: sub_4D1DE0+195j
                                            ; sub_4D1DE0+19Ej ...
    mov     eax, dword_50BC50
    push    edi
    mov     [edi+18h], eax
    call    sub_4D2830
    mov     eax, 0FFFFFFFCh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D20D5:                             ; CODE XREF: sub_4D1DE0+8Ej
                                            ; sub_4D1DE0+97j ...
    mov     eax, 0FFFFFFFEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D20E1:                             ; CODE XREF: sub_4D1DE0+Ej
                                            ; sub_4D1DE0+1Ej ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 0FFFFFFFAh
    pop     ebx
    retn    20h
    sub_4D1DE0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+4]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+1Ch]
    test    eax, eax
    mov     ebp, edi
    jz      loc_4D21DF
    mov     ebx, [eax+1Ch]
    test    ebx, ebx
    jz      loc_4D21DF
    mov     esi, [esp+18h]
    test    esi, esi
    jz      loc_4D21DF
    cmp     dword ptr [ebx+4], 2Ah
    jnz     loc_4D21DF
    mov     eax, [eax+30h]
    push    edi
    push    esi
    push    eax
    call    sub_4D5CD0
    cmp     edi, 3
    mov     ecx, [esp+14h]
    mov     [ecx+30h], eax
    jnb     short loc_4D2147
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D2147:                             ; CODE XREF: .text:004D213Cj
    mov     eax, [ebx+1Eh]
    add     eax, 0FFFFFEFAh
    cmp     edi, eax
    jbe     short loc_4D2159
    mov     ebp, eax
    sub     edi, ebp
    add     esi, edi

    loc_4D2159:                             ; CODE XREF: .text:004D2151j
    mov     edi, [ebx+2Ah]
    mov     ecx, ebp
    mov     edx, ecx
    xor     eax, eax
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [ebx+2Ah]
    mov     ecx, [ebx+4Ah]
    mov     [ebx+5Eh], ebp
    mov     [ebx+4Eh], ebp
    mov     al, [esi]
    lea     edi, [ebp-3]
    mov     [ebx+3Ah], eax
    shl     eax, cl
    xor     ecx, ecx
    mov     cl, [esi+1]
    xor     eax, ecx
    mov     ecx, [ebx+46h]
    and     eax, ecx
    xor     esi, esi
    mov     [ebx+3Ah], eax

    loc_4D2195:                             ; CODE XREF: .text:004D21D4j
    mov     eax, [ebx+3Ah]
    mov     ecx, [ebx+4Ah]
    mov     edx, [ebx+2Ah]
    mov     ebp, [ebx+46h]
    shl     eax, cl
    xor     ecx, ecx
    mov     cl, [esi+edx+2]
    mov     edx, [ebx+36h]
    xor     eax, ecx
    xor     ecx, ecx
    and     eax, ebp
    mov     [ebx+3Ah], eax
    mov     cx, [edx+eax*2]
    mov     edx, [ebx+26h]
    mov     eax, esi
    and     eax, edx
    mov     edx, [ebx+32h]
    mov     [edx+eax*2], cx
    mov     eax, [ebx+3Ah]
    mov     ecx, [ebx+36h]
    mov     [ecx+eax*2], si
    inc     esi
    cmp     esi, edi
    jbe     short loc_4D2195
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D21DF:                             ; CODE XREF: .text:004D2100j
                                            ; .text:004D210Bj ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 0FFFFFFFEh
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, [esp+4]
    push    ebx
    xor     ebx, ebx
    push    esi
    cmp     eax, ebx
    push    edi
    jz      loc_4D22EF
    mov     esi, [eax+1Ch]
    cmp     esi, ebx
    jz      loc_4D22EF
    cmp     [eax+20h], ebx
    jz      loc_4D22EF
    cmp     [eax+24h], ebx
    jz      loc_4D22EF
    mov     [eax+14h], ebx
    mov     [eax+8], ebx
    mov     [eax+18h], ebx
    mov     dword ptr [eax+2Ch], 2
    mov     ecx, [esi+8]
    mov     [esi+10h], ebx
    mov     [esi+0Ch], ecx
    mov     ecx, [esi+14h]
    cmp     ecx, ebx
    jge     short loc_4D2241
    mov     [esi+14h], ebx

    loc_4D2241:                             ; CODE XREF: .text:004D223Cj
    mov     edx, [esi+14h]
    push    esi
    neg     edx
    sbb     edx, edx
    and     edx, 47h
    add     edx, 2Ah
    mov     [esi+4], edx
    mov     dword ptr [eax+30h], 1
    mov     [esi+1Ah], ebx
    call    sub_4D3DA0
    mov     eax, [esi+1Eh]
    mov     ecx, [esi+3Eh]
    mov     edx, [esi+36h]
    shl     eax, 1
    mov     [esi+2Eh], eax
    mov     [edx+ecx*2-2], bx
    mov     eax, [esi+3Eh]
    mov     edi, [esi+36h]
    lea     ecx, [eax+eax-2]
    xor     eax, eax
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    xor     edx, edx
    and     ecx, 3
    rep stosb
    mov     eax, [esi+76h]
    xor     ecx, ecx
    lea     eax, [eax+eax*2]
    shl     eax, 2
    mov     cx, word_50BB52[eax]
    mov     [esi+72h], ecx
    mov     dx, word_50BB50[eax]
    xor     ecx, ecx
    mov     [esi+7Eh], edx
    mov     cx, word_50BB54[eax]
    xor     edx, edx
    mov     [esi+82h], ecx
    mov     dx, word_50BB56[eax]
    mov     [esi+6Eh], edx
    mov     [esi+5Eh], ebx
    mov     [esi+4Eh], ebx
    mov     [esi+66h], ebx
    mov     dword ptr [esi+6Ah], 2
    mov     dword ptr [esi+52h], 2
    mov     [esi+5Ah], ebx
    mov     [esi+3Ah], ebx
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D22EF:                             ; CODE XREF: .text:004D21FBj
                                            ; .text:004D2206j ...
    pop     edi
    pop     esi
    mov     eax, 0FFFFFFFEh
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    mov     edx, [esp+4]
    push    ebx
    push    ebp
    xor     eax, eax
    push    esi
    push    edi
    test    edx, edx
    jz      loc_4D23B4
    mov     edi, [edx+1Ch]
    test    edi, edi
    jz      loc_4D23B4
    mov     ebx, [esp+18h]
    cmp     ebx, 0FFFFFFFFh
    jnz     short loc_4D232B
    mov     ebx, 6

    loc_4D232B:                             ; CODE XREF: .text:004D2324j
    test    ebx, ebx
    jl      loc_4D23B4
    cmp     ebx, 9
    jg      short loc_4D23B4
    mov     ebp, [esp+1Ch]
    test    ebp, ebp
    jl      short loc_4D23B4
    cmp     ebp, 2
    jg      short loc_4D23B4
    mov     ecx, [edi+76h]
    lea     esi, [ebx+ebx*2]
    shl     esi, 2
    lea     ecx, [ecx+ecx*2]
    mov     ecx, off_50BB58[ecx*4]
    cmp     ecx, off_50BB58[esi]
    jz      short loc_4D236F
    mov     ecx, [edx+8]
    test    ecx, ecx
    jz      short loc_4D236F
    push    1
    push    edx
    call    sub_4D23C0

    loc_4D236F:                             ; CODE XREF: .text:004D235Ej
                                            ; .text:004D2365j
    cmp     [edi+76h], ebx
    jz      short loc_4D23AA
    xor     edx, edx
    mov     [edi+76h], ebx
    mov     dx, word_50BB52[esi]
    xor     ecx, ecx
    mov     [edi+72h], edx
    mov     cx, word_50BB50[esi]
    xor     edx, edx
    mov     [edi+7Eh], ecx
    mov     dx, word_50BB54[esi]
    xor     ecx, ecx
    mov     [edi+82h], edx
    mov     cx, word_50BB56[esi]
    mov     [edi+6Eh], ecx

    loc_4D23AA:                             ; CODE XREF: .text:004D2372j
    mov     [edi+7Ah], ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D23B4:                             ; CODE XREF: .text:004D230Cj
                                            ; .text:004D2317j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 0FFFFFFFEh
    pop     ebx
    retn    0Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D23C0 proc near                    ; CODE XREF: sub_4D1C80+5Dp
                                            ; .text:004D236Ap

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    test    ebp, ebp
    push    edi
    jz      loc_4D2820
    mov     ebx, [ebp+1Ch]
    test    ebx, ebx
    jz      loc_4D2820
    mov     edi, [esp+8+arg_4]
    cmp     edi, 4
    jg      loc_4D2820
    test    edi, edi
    jl      loc_4D2820
    mov     eax, [ebp+0Ch]
    test    eax, eax
    jz      loc_4D2817
    cmp     dword ptr [ebp+0], 0
    jnz     short loc_4D240C
    mov     eax, [ebp+4]
    test    eax, eax
    jnz     loc_4D2817

    loc_4D240C:                             ; CODE XREF: sub_4D23C0+3Fj
    mov     eax, [ebx+4]
    cmp     eax, 29Ah
    jnz     short loc_4D241F
    cmp     edi, 4
    jnz     loc_4D2817

    loc_4D241F:                             ; CODE XREF: sub_4D23C0+54j
    mov     ecx, [ebp+10h]
    test    ecx, ecx
    jnz     short loc_4D243A
    mov     eax, dword_50BC54
    mov     [ebp+18h], eax
    mov     eax, 0FFFFFFFBh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D243A:                             ; CODE XREF: sub_4D23C0+64j
    mov     esi, [ebx+1Ah]
    cmp     eax, 2Ah
    mov     [ebx], ebp
    mov     [ebx+1Ah], edi
    jnz     loc_4D2516
    mov     ecx, [ebx+22h]
    mov     eax, [ebx+76h]
    shl     ecx, 0Ch
    sub     ecx, 7800h
    dec     eax
    sar     eax, 1
    cmp     eax, 3
    jbe     short loc_4D2467
    mov     eax, 3

    loc_4D2467:                             ; CODE XREF: sub_4D23C0+A0j
    shl     eax, 6
    or      ecx, eax
    mov     eax, [ebx+5Eh]
    test    eax, eax
    jz      short loc_4D2476
    or      ecx, 20h

    loc_4D2476:                             ; CODE XREF: sub_4D23C0+B1j
    mov     eax, ecx
    xor     edx, edx
    mov     edi, 1Fh
    mov     dword ptr [ebx+4], 71h
    div     edi
    mov     eax, edi
    mov     edi, [ebx+10h]
    sub     eax, edx
    add     ecx, eax
    mov     eax, [ebx+8]
    mov     edx, ecx
    shr     edx, 8
    mov     [eax+edi], dl
    mov     edx, [ebx+10h]
    inc     edx
    mov     [ebx+10h], edx
    mov     eax, edx
    mov     edx, [ebx+8]
    mov     [edx+eax], cl
    mov     ecx, [ebx+10h]
    mov     eax, [ebx+5Eh]
    inc     ecx
    test    eax, eax
    mov     [ebx+10h], ecx
    mov     edi, ecx
    jz      short loc_4D250B
    mov     eax, [ebp+30h]
    mov     edx, [ebx+8]
    shr     eax, 10h
    mov     ecx, eax
    shr     ecx, 8
    mov     [edx+edi], cl
    mov     edi, [ebx+10h]
    mov     edx, [ebx+8]
    inc     edi
    mov     ecx, edi
    mov     [ebx+10h], edi
    mov     [edx+ecx], al
    mov     edx, [ebx+10h]
    inc     edx
    mov     [ebx+10h], edx
    mov     eax, [ebp+30h]
    and     eax, 0FFFFh
    mov     edi, edx
    mov     edx, [ebx+8]
    mov     ecx, eax
    shr     ecx, 8
    mov     [edx+edi], cl
    mov     ecx, [ebx+10h]
    mov     edx, [ebx+8]
    inc     ecx
    mov     [ebx+10h], ecx
    mov     [edx+ecx], al
    mov     eax, [ebx+10h]
    inc     eax
    mov     [ebx+10h], eax

    loc_4D250B:                             ; CODE XREF: sub_4D23C0+F9j
    mov     edi, [esp+8+arg_4]
    mov     dword ptr [ebp+30h], 1

    loc_4D2516:                             ; CODE XREF: sub_4D23C0+85j
    mov     eax, [ebx+10h]
    test    eax, eax
    jz      loc_4D25A3
    mov     edx, [ebp+1Ch]
    mov     ecx, [ebp+10h]
    mov     eax, [edx+10h]
    cmp     eax, ecx
    jbe     short loc_4D2530
    mov     eax, ecx

    loc_4D2530:                             ; CODE XREF: sub_4D23C0+16Cj
    test    eax, eax
    jz      short loc_4D258C
    mov     esi, [edx+0Ch]
    mov     edi, [ebp+0Ch]
    mov     ecx, eax
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [ebp+0Ch]
    mov     ecx, [ebp+1Ch]
    add     esi, eax
    mov     [ebp+0Ch], esi
    mov     edx, [ecx+0Ch]
    add     edx, eax
    mov     [ecx+0Ch], edx
    mov     edi, [ebp+14h]
    mov     esi, [ebp+10h]
    mov     ecx, [ebp+1Ch]
    add     edi, eax
    sub     esi, eax
    mov     [ebp+14h], edi
    mov     [ebp+10h], esi
    mov     edx, [ecx+10h]
    sub     edx, eax
    mov     [ecx+10h], edx
    mov     eax, [ebp+1Ch]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4D2588
    mov     ecx, [eax+8]
    mov     [eax+0Ch], ecx

    loc_4D2588:                             ; CODE XREF: sub_4D23C0+1C0j
    mov     edi, [esp+8+arg_4]

    loc_4D258C:                             ; CODE XREF: sub_4D23C0+172j
    mov     eax, [ebp+10h]
    test    eax, eax
    jnz     short loc_4D25C8
    mov     dword ptr [ebx+1Ah], 0FFFFFFFFh
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D25A3:                             ; CODE XREF: sub_4D23C0+15Bj
    mov     eax, [ebp+4]
    test    eax, eax
    jnz     short loc_4D25C8
    cmp     edi, esi
    jg      short loc_4D25C8
    cmp     edi, 4
    jz      short loc_4D25C8
    mov     edx, dword_50BC54
    mov     eax, 0FFFFFFFBh
    mov     [ebp+18h], edx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D25C8:                             ; CODE XREF: sub_4D23C0+1D1j
                                            ; sub_4D23C0+1E8j ...
    mov     eax, [ebx+4]
    mov     ecx, [ebp+4]
    cmp     eax, 29Ah
    jnz     short loc_4D25ED
    test    ecx, ecx
    jz      short loc_4D25F1
    mov     eax, dword_50BC54
    mov     [ebp+18h], eax
    mov     eax, 0FFFFFFFBh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D25ED:                             ; CODE XREF: sub_4D23C0+213j
    test    ecx, ecx
    jnz     short loc_4D260B

    loc_4D25F1:                             ; CODE XREF: sub_4D23C0+217j
    mov     ecx, [ebx+66h]
    test    ecx, ecx
    jnz     short loc_4D260B
    test    edi, edi
    jz      loc_4D270F
    cmp     eax, 29Ah
    jz      loc_4D270F

    loc_4D260B:                             ; CODE XREF: sub_4D23C0+22Fj
                                            ; sub_4D23C0+236j
    mov     eax, [ebx+76h]
    push    edi
    push    ebx
    lea     ecx, [eax+eax*2]
    call    off_50BB58[ecx*4]
    cmp     eax, 2
    jz      short loc_4D2624
    cmp     eax, 3
    jnz     short loc_4D262B

    loc_4D2624:                             ; CODE XREF: sub_4D23C0+25Dj
    mov     dword ptr [ebx+4], 29Ah

    loc_4D262B:                             ; CODE XREF: sub_4D23C0+262j
    test    eax, eax
    jz      loc_4D2800
    cmp     eax, 2
    jz      loc_4D2800
    cmp     eax, 1
    jnz     loc_4D270F
    cmp     edi, eax
    jnz     short loc_4D2651
    push    ebx
    call    sub_4D4210
    jmp     short loc_4D268D
    ; ---------------------------------------------------------------------------

    loc_4D2651:                             ; CODE XREF: sub_4D23C0+287j
    push    0
    push    0
    push    0
    push    ebx
    call    sub_4D40A0
    cmp     edi, 3
    jnz     short loc_4D268D
    mov     edx, [ebx+3Eh]
    mov     eax, [ebx+36h]
    mov     word ptr [eax+edx*2-2], 0
    mov     ecx, [ebx+3Eh]
    mov     edi, [ebx+36h]
    xor     eax, eax
    lea     ecx, [ecx+ecx-2]
    mov     edx, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb
    mov     edi, [esp+18h]

    loc_4D268D:                             ; CODE XREF: sub_4D23C0+28Fj
                                            ; sub_4D23C0+2A0j
    mov     edx, [ebp+1Ch]
    mov     ecx, [ebp+10h]
    mov     eax, [edx+10h]
    cmp     eax, ecx
    jbe     short loc_4D269C
    mov     eax, ecx

    loc_4D269C:                             ; CODE XREF: sub_4D23C0+2D8j
    test    eax, eax
    jz      short loc_4D26F8
    mov     esi, [edx+0Ch]
    mov     edi, [ebp+0Ch]
    mov     ecx, eax
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [ebp+0Ch]
    mov     ecx, [ebp+1Ch]
    add     esi, eax
    mov     [ebp+0Ch], esi
    mov     edx, [ecx+0Ch]
    add     edx, eax
    mov     [ecx+0Ch], edx
    mov     edi, [ebp+14h]
    mov     esi, [ebp+10h]
    mov     ecx, [ebp+1Ch]
    add     edi, eax
    sub     esi, eax
    mov     [ebp+14h], edi
    mov     [ebp+10h], esi
    mov     edx, [ecx+10h]
    sub     edx, eax
    mov     [ecx+10h], edx
    mov     eax, [ebp+1Ch]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4D26F4
    mov     ecx, [eax+8]
    mov     [eax+0Ch], ecx

    loc_4D26F4:                             ; CODE XREF: sub_4D23C0+32Cj
    mov     edi, [esp+18h]

    loc_4D26F8:                             ; CODE XREF: sub_4D23C0+2DEj
    mov     eax, [ebp+10h]
    test    eax, eax
    jnz     short loc_4D270F
    mov     dword ptr [ebx+1Ah], 0FFFFFFFFh
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D270F:                             ; CODE XREF: sub_4D23C0+23Aj
                                            ; sub_4D23C0+245j ...
    cmp     edi, 4
    jz      short loc_4D271D
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D271D:                             ; CODE XREF: sub_4D23C0+352j
    mov     eax, [ebx+14h]
    test    eax, eax
    jz      short loc_4D2730
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D2730:                             ; CODE XREF: sub_4D23C0+362j
    mov     eax, [ebp+30h]
    mov     ecx, [ebx+8]
    mov     esi, [ebx+10h]
    shr     eax, 10h
    mov     edx, eax
    shr     edx, 8
    mov     [ecx+esi], dl
    mov     ecx, [ebx+10h]
    mov     edx, [ebx+8]
    inc     ecx
    mov     [ebx+10h], ecx
    mov     [edx+ecx], al
    mov     eax, [ebx+10h]
    inc     eax
    mov     edx, [ebx+8]
    mov     [ebx+10h], eax
    mov     esi, eax
    mov     eax, [ebp+30h]
    and     eax, 0FFFFh
    mov     ecx, eax
    shr     ecx, 8
    mov     [edx+esi], cl
    mov     ecx, [ebx+10h]
    mov     edx, [ebx+8]
    inc     ecx
    mov     [ebx+10h], ecx
    mov     [edx+ecx], al
    mov     edi, [ebx+10h]
    inc     edi
    mov     [ebx+10h], edi
    mov     edx, [ebp+1Ch]
    mov     ecx, [ebp+10h]
    mov     eax, [edx+10h]
    cmp     eax, ecx
    jbe     short loc_4D2790
    mov     eax, ecx

    loc_4D2790:                             ; CODE XREF: sub_4D23C0+3CCj
    test    eax, eax
    jz      short loc_4D27E8
    mov     esi, [edx+0Ch]
    mov     edi, [ebp+0Ch]
    mov     ecx, eax
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [ebp+0Ch]
    mov     ecx, [ebp+1Ch]
    add     esi, eax
    mov     [ebp+0Ch], esi
    mov     edx, [ecx+0Ch]
    add     edx, eax
    mov     [ecx+0Ch], edx
    mov     edi, [ebp+14h]
    mov     esi, [ebp+10h]
    mov     ecx, [ebp+1Ch]
    add     edi, eax
    sub     esi, eax
    mov     [ebp+14h], edi
    mov     [ebp+10h], esi
    mov     edx, [ecx+10h]
    sub     edx, eax
    mov     [ecx+10h], edx
    mov     ebp, [ebp+1Ch]
    mov     eax, [ebp+10h]
    test    eax, eax
    jnz     short loc_4D27E8
    mov     eax, [ebp+8]
    mov     [ebp+0Ch], eax

    loc_4D27E8:                             ; CODE XREF: sub_4D23C0+3D2j
                                            ; sub_4D23C0+420j
    mov     ecx, [ebx+10h]
    xor     eax, eax
    test    ecx, ecx
    mov     dword ptr [ebx+14h], 0FFFFFFFFh
    setz    al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D2800:                             ; CODE XREF: sub_4D23C0+26Dj
                                            ; sub_4D23C0+276j
    mov     eax, [ebp+10h]
    test    eax, eax
    jnz     short loc_4D280E
    mov     dword ptr [ebx+1Ah], 0FFFFFFFFh

    loc_4D280E:                             ; CODE XREF: sub_4D23C0+445j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D2817:                             ; CODE XREF: sub_4D23C0+35j
                                            ; sub_4D23C0+46j ...
    mov     ecx, dword_50BC48
    mov     [ebp+18h], ecx

    loc_4D2820:                             ; CODE XREF: sub_4D23C0+Aj
                                            ; sub_4D23C0+15j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 0FFFFFFFEh
    pop     ebx
    retn    8
    sub_4D23C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D2830 proc near                    ; CODE XREF: sub_4D1C80+6Ep
                                            ; sub_4D1C80+91p ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    push    edi
    jz      short loc_4D28AB
    mov     eax, [esi+1Ch]
    test    eax, eax
    jz      short loc_4D28AB
    mov     eax, [eax+8]
    test    eax, eax
    jz      short loc_4D2850
    push    eax
    mov     eax, [esi+28h]
    push    eax
    call    dword ptr [esi+24h]

    loc_4D2850:                             ; CODE XREF: sub_4D2830+16j
    mov     ecx, [esi+1Ch]
    mov     eax, [ecx+36h]
    test    eax, eax
    jz      short loc_4D2862
    mov     edx, [esi+28h]
    push    eax
    push    edx
    call    dword ptr [esi+24h]

    loc_4D2862:                             ; CODE XREF: sub_4D2830+28j
    mov     eax, [esi+1Ch]
    mov     eax, [eax+32h]
    test    eax, eax
    jz      short loc_4D2874
    mov     ecx, [esi+28h]
    push    eax
    push    ecx
    call    dword ptr [esi+24h]

    loc_4D2874:                             ; CODE XREF: sub_4D2830+3Aj
    mov     edx, [esi+1Ch]
    mov     eax, [edx+2Ah]
    test    eax, eax
    jz      short loc_4D2886
    push    eax
    mov     eax, [esi+28h]
    push    eax
    call    dword ptr [esi+24h]

    loc_4D2886:                             ; CODE XREF: sub_4D2830+4Cj
    mov     eax, [esi+1Ch]
    mov     ecx, [esi+28h]
    push    eax
    push    ecx
    mov     edi, [eax+4]
    call    dword ptr [esi+24h]
    xor     eax, eax
    cmp     edi, 71h
    setnz   al
    dec     eax
    mov     dword ptr [esi+1Ch], 0
    and     al, 0FDh
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D28AB:                             ; CODE XREF: sub_4D2830+8j
                                            ; sub_4D2830+Fj
    pop     edi
    mov     eax, 0FFFFFFFEh
    pop     esi
    retn    4
    sub_4D2830 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+0Ch]
    test    esi, esi
    push    edi
    jz      short loc_4D28E0
    mov     edi, [esp+0Ch]
    test    edi, edi
    jz      short loc_4D28E0
    mov     eax, [esi+1Ch]
    test    eax, eax
    jz      short loc_4D28E0
    mov     ecx, 0Eh
    rep movsd

    loc_4D28E0:                             ; CODE XREF: .text:004D28C8j
                                            ; .text:004D28D0j ...
    pop     edi
    mov     eax, 0FFFFFFFEh
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D28F0 proc near                    ; CODE XREF: sub_4D23C0+253p
                                            ; DATA XREF: .data:0050BB58o

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    push    ebp
    push    esi
    push    edi

    loc_4D28F8:                             ; CODE XREF: sub_4D28F0+6Cj
                                            ; sub_4D28F0+101j
    mov     eax, [ebx+66h]
    cmp     eax, 1
    ja      short loc_4D2921
    push    ebx
    call    sub_4D2AD0
    mov     eax, [ebx+66h]
    test    eax, eax
    jnz     short loc_4D2921
    mov     ecx, [esp+0Ch+arg_4]
    test    ecx, ecx
    jz      loc_4D2AC6
    test    eax, eax
    jz      loc_4D29F6

    loc_4D2921:                             ; CODE XREF: sub_4D28F0+Ej
                                            ; sub_4D28F0+1Bj
    mov     ecx, [ebx+5Eh]
    mov     dword ptr [ebx+66h], 0
    add     ecx, eax
    mov     [ebx+5Eh], ecx
    mov     eax, ecx
    jz      short loc_4D293B
    cmp     eax, 0FFFEh
    jbe     short loc_4D294A

    loc_4D293B:                             ; CODE XREF: sub_4D28F0+42j
    add     eax, 0FFFF0001h
    mov     dword ptr [ebx+5Eh], 0FFFFh
    mov     [ebx+66h], eax

    loc_4D294A:                             ; CODE XREF: sub_4D28F0+49j
    mov     edx, [ebx+4Eh]
    mov     ecx, [ebx+5Eh]
    mov     eax, [ebx+1Eh]
    sub     ecx, edx
    sub     eax, 106h
    cmp     ecx, eax
    jb      short loc_4D28F8
    test    edx, edx
    jl      short loc_4D2969
    mov     eax, [ebx+2Ah]
    add     eax, edx
    jmp     short loc_4D296B
    ; ---------------------------------------------------------------------------

    loc_4D2969:                             ; CODE XREF: sub_4D28F0+70j
    xor     eax, eax

    loc_4D296B:                             ; CODE XREF: sub_4D28F0+77j
    push    0
    push    ecx
    push    eax
    push    ebx
    call    sub_4D4590
    mov     ecx, [ebx+5Eh]
    mov     eax, [ebx]
    mov     [ebx+4Eh], ecx
    mov     esi, [eax+1Ch]
    mov     ecx, [eax+10h]
    mov     edx, [esi+10h]
    cmp     edx, ecx
    jbe     short loc_4D298C
    mov     edx, ecx

    loc_4D298C:                             ; CODE XREF: sub_4D28F0+98j
    test    edx, edx
    jz      short loc_4D29E4
    mov     esi, [esi+0Ch]
    mov     edi, [eax+0Ch]
    mov     ecx, edx
    mov     ebp, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb
    mov     edi, [eax+0Ch]
    mov     ecx, [eax+1Ch]
    add     edi, edx
    mov     [eax+0Ch], edi
    mov     esi, [ecx+0Ch]
    add     esi, edx
    mov     [ecx+0Ch], esi
    mov     ebp, [eax+14h]
    mov     edi, [eax+10h]
    mov     ecx, [eax+1Ch]
    add     ebp, edx
    sub     edi, edx
    mov     [eax+14h], ebp
    mov     [eax+10h], edi
    mov     esi, [ecx+10h]
    sub     esi, edx
    mov     [ecx+10h], esi
    mov     eax, [eax+1Ch]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4D29E4
    mov     edx, [eax+8]
    mov     [eax+0Ch], edx

    loc_4D29E4:                             ; CODE XREF: sub_4D28F0+9Ej
                                            ; sub_4D28F0+ECj
    mov     eax, [ebx]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jz      loc_4D2AC6
    jmp     loc_4D28F8
    ; ---------------------------------------------------------------------------

    loc_4D29F6:                             ; CODE XREF: sub_4D28F0+2Bj
    mov     esi, [ebx+4Eh]
    test    esi, esi
    jl      short loc_4D2A04
    mov     eax, [ebx+2Ah]
    add     eax, esi
    jmp     short loc_4D2A06
    ; ---------------------------------------------------------------------------

    loc_4D2A04:                             ; CODE XREF: sub_4D28F0+10Bj
    xor     eax, eax

    loc_4D2A06:                             ; CODE XREF: sub_4D28F0+112j
    mov     edx, [esp+0Ch+arg_4]
    xor     ecx, ecx
    cmp     edx, 4
    mov     edx, [ebx+5Eh]
    setz    cl
    sub     edx, esi
    push    ecx
    push    edx
    push    eax
    push    ebx
    call    sub_4D4590
    mov     eax, [ebx+5Eh]
    mov     [ebx+4Eh], eax
    mov     eax, [ebx]
    mov     esi, [eax+1Ch]
    mov     ecx, [eax+10h]
    mov     edx, [esi+10h]
    cmp     edx, ecx
    jbe     short loc_4D2A37
    mov     edx, ecx

    loc_4D2A37:                             ; CODE XREF: sub_4D28F0+143j
    test    edx, edx
    jz      short loc_4D2A8F
    mov     esi, [esi+0Ch]
    mov     edi, [eax+0Ch]
    mov     ecx, edx
    mov     ebp, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb
    mov     edi, [eax+0Ch]
    mov     ecx, [eax+1Ch]
    add     edi, edx
    mov     [eax+0Ch], edi
    mov     esi, [ecx+0Ch]
    add     esi, edx
    mov     [ecx+0Ch], esi
    mov     ebp, [eax+14h]
    mov     edi, [eax+10h]
    mov     ecx, [eax+1Ch]
    add     ebp, edx
    sub     edi, edx
    mov     [eax+14h], ebp
    mov     [eax+10h], edi
    mov     esi, [ecx+10h]
    sub     esi, edx
    mov     [ecx+10h], esi
    mov     eax, [eax+1Ch]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4D2A8F
    mov     ecx, [eax+8]
    mov     [eax+0Ch], ecx

    loc_4D2A8F:                             ; CODE XREF: sub_4D28F0+149j
                                            ; sub_4D28F0+197j
    mov     edx, [ebx]
    mov     eax, [edx+10h]
    test    eax, eax
    jnz     short loc_4D2AAF
    mov     esi, [esp+0Ch+arg_4]
    xor     eax, eax
    cmp     esi, 4
    setnz   al
    dec     eax
    and     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D2AAF:                             ; CODE XREF: sub_4D28F0+1A6j
    mov     eax, [esp+0Ch+arg_4]
    sub     eax, 4
    neg     eax
    sbb     eax, eax
    and     al, 0FEh
    add     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D2AC6:                             ; CODE XREF: sub_4D28F0+23j
                                            ; sub_4D28F0+FBj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn    8
    sub_4D28F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D2AD0 proc near                    ; CODE XREF: sub_4D28F0+11p
                                            ; .text:004D2C8Ap ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    mov     ebx, [esp+8+arg_0]
    push    ebp
    push    esi
    mov     edx, [ebx+1Eh]
    push    edi
    mov     [esp+14h+var_4], edx

    loc_4D2AE0:                             ; CODE XREF: sub_4D2AD0+18Fj
    mov     eax, [ebx+5Eh]
    mov     ecx, [ebx+2Eh]
    mov     esi, [ebx+66h]
    sub     ecx, eax
    sub     ecx, esi
    mov     [esp+14h+arg_0], ecx
    jnz     short loc_4D2B04
    test    eax, eax
    jnz     short loc_4D2B04
    test    esi, esi
    jnz     short loc_4D2B04
    mov     [esp+14h+arg_0], edx
    jmp     loc_4D2B97
    ; ---------------------------------------------------------------------------

    loc_4D2B04:                             ; CODE XREF: sub_4D2AD0+21j
                                            ; sub_4D2AD0+25j ...
    cmp     ecx, 0FFFFFFFFh
    jnz     short loc_4D2B16
    mov     [esp+14h+arg_0], 0FFFFFFFEh
    jmp     loc_4D2B97
    ; ---------------------------------------------------------------------------

    loc_4D2B16:                             ; CODE XREF: sub_4D2AD0+37j
    mov     esi, [ebx+1Eh]
    lea     esi, [edx+esi-106h]
    cmp     eax, esi
    jb      short loc_4D2B9B
    mov     edi, [ebx+2Ah]
    mov     ecx, edx
    mov     eax, ecx
    lea     esi, [edx+edi]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     esi, [ebx+62h]
    mov     ecx, [ebx+5Eh]
    mov     eax, [ebx+4Eh]
    sub     esi, edx
    sub     ecx, edx
    mov     [ebx+62h], esi
    mov     esi, [ebx+3Eh]
    mov     [ebx+5Eh], ecx
    mov     ecx, [ebx+36h]
    sub     eax, edx
    mov     [ebx+4Eh], eax
    lea     ecx, [ecx+esi*2]

    loc_4D2B5B:                             ; CODE XREF: sub_4D2AD0+A1j
    sub     ecx, 2
    xor     eax, eax
    mov     ax, [ecx]
    cmp     eax, edx
    jb      short loc_4D2B6B
    sub     eax, edx
    jmp     short loc_4D2B6D
    ; ---------------------------------------------------------------------------

    loc_4D2B6B:                             ; CODE XREF: sub_4D2AD0+95j
    xor     eax, eax

    loc_4D2B6D:                             ; CODE XREF: sub_4D2AD0+99j
    dec     esi
    mov     [ecx], ax
    jnz     short loc_4D2B5B
    mov     eax, [ebx+32h]
    mov     esi, edx
    lea     ecx, [eax+edx*2]

    loc_4D2B7B:                             ; CODE XREF: sub_4D2AD0+C1j
    sub     ecx, 2
    xor     eax, eax
    mov     ax, [ecx]
    cmp     eax, edx
    jb      short loc_4D2B8B
    sub     eax, edx
    jmp     short loc_4D2B8D
    ; ---------------------------------------------------------------------------

    loc_4D2B8B:                             ; CODE XREF: sub_4D2AD0+B5j
    xor     eax, eax

    loc_4D2B8D:                             ; CODE XREF: sub_4D2AD0+B9j
    dec     esi
    mov     [ecx], ax
    jnz     short loc_4D2B7B
    add     [esp+14h+arg_0], edx

    loc_4D2B97:                             ; CODE XREF: sub_4D2AD0+2Fj
                                            ; sub_4D2AD0+41j
    mov     ecx, [esp+14h+arg_0]

    loc_4D2B9B:                             ; CODE XREF: sub_4D2AD0+52j
    mov     ebp, [ebx]
    mov     eax, [ebp+4]
    test    eax, eax
    jz      loc_4D2C65
    mov     edi, [ebx+2Ah]
    mov     esi, [ebx+66h]
    mov     eax, [ebx+5Eh]
    add     edi, esi
    add     edi, eax
    mov     eax, [ebp+4]
    mov     esi, eax
    cmp     esi, ecx
    mov     [esp+14h+arg_0], esi
    jbe     short loc_4D2BC8
    mov     [esp+14h+arg_0], ecx
    mov     esi, ecx

    loc_4D2BC8:                             ; CODE XREF: sub_4D2AD0+F0j
    test    esi, esi
    jnz     short loc_4D2BD0
    xor     eax, eax
    jmp     short loc_4D2C1B
    ; ---------------------------------------------------------------------------

    loc_4D2BD0:                             ; CODE XREF: sub_4D2AD0+FAj
    mov     ecx, [ebp+1Ch]
    sub     eax, esi
    mov     [ebp+4], eax
    mov     eax, [ecx+14h]
    test    eax, eax
    jnz     short loc_4D2BF4
    mov     edx, [ebp+0]
    mov     eax, [ebp+30h]
    push    esi
    push    edx
    push    eax
    call    sub_4D5CD0
    mov     [ebp+30h], eax
    mov     edx, [esp+14h+var_4]

    loc_4D2BF4:                             ; CODE XREF: sub_4D2AD0+10Dj
    mov     ecx, esi
    mov     esi, [ebp+0]
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, [esp+14h+arg_0]
    and     ecx, 3
    rep movsb
    mov     esi, [ebp+0]
    mov     ecx, [ebp+8]
    add     esi, eax
    add     ecx, eax
    mov     [ebp+0], esi
    mov     [ebp+8], ecx

    loc_4D2C1B:                             ; CODE XREF: sub_4D2AD0+FEj
    mov     ecx, [ebx+66h]
    add     ecx, eax
    mov     ebp, ecx
    mov     [ebx+66h], ecx
    cmp     ebp, 3
    jb      short loc_4D2C50
    mov     ecx, [ebx+2Ah]
    mov     eax, [ebx+5Eh]
    lea     edi, [ecx+eax]
    xor     ecx, ecx
    xor     eax, eax
    mov     cl, [edi]
    mov     esi, ecx
    mov     ecx, [ebx+4Ah]
    mov     [ebx+3Ah], esi
    mov     al, [edi+1]
    shl     esi, cl
    xor     esi, eax
    mov     eax, [ebx+46h]
    and     esi, eax
    mov     [ebx+3Ah], esi

    loc_4D2C50:                             ; CODE XREF: sub_4D2AD0+158j
    cmp     ebp, 106h
    jnb     short loc_4D2C65
    mov     ecx, [ebx]
    mov     eax, [ecx+4]
    test    eax, eax
    jnz     loc_4D2AE0

    loc_4D2C65:                             ; CODE XREF: sub_4D2AD0+D2j
                                            ; sub_4D2AD0+186j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    4
    sub_4D2AD0 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    ecx
    push    ebx
    mov     ebx, [esp+0Ch]
    push    ebp
    push    esi
    xor     esi, esi
    push    edi
    mov     [esp+10h], esi

    loc_4D2C7F:                             ; CODE XREF: .text:004D2E03j
                                            ; .text:004D2EA8j
    mov     eax, [ebx+66h]
    cmp     eax, 106h
    jnb     short loc_4D2CAD
    push    ebx
    call    sub_4D2AD0
    mov     eax, [ebx+66h]
    cmp     eax, 106h
    jnb     short loc_4D2CA5
    mov     ecx, [esp+1Ch]
    test    ecx, ecx
    jz      loc_4D2F7F

    loc_4D2CA5:                             ; CODE XREF: .text:004D2C97j
    test    eax, eax
    jz      loc_4D2EAD

    loc_4D2CAD:                             ; CODE XREF: .text:004D2C87j
    cmp     eax, 3
    jb      short loc_4D2CF7
    mov     eax, [ebx+3Ah]
    mov     ecx, [ebx+4Ah]
    mov     edi, [ebx+5Eh]
    xor     edx, edx
    shl     eax, cl
    mov     ecx, [ebx+2Ah]
    xor     esi, esi
    mov     dl, [ecx+edi+2]
    mov     ecx, [ebx+46h]
    xor     eax, edx
    mov     edx, [ebx+26h]
    and     eax, ecx
    mov     ecx, [ebx+36h]
    mov     [ebx+3Ah], eax
    and     edx, edi
    mov     si, [ecx+eax*2]
    mov     eax, [ebx+32h]
    mov     [esp+10h], esi
    mov     [eax+edx*2], si
    mov     ecx, [ebx+3Ah]
    mov     edx, [ebx+36h]
    mov     ax, [ebx+5Eh]
    mov     [edx+ecx*2], ax

    loc_4D2CF7:                             ; CODE XREF: .text:004D2CB0j
    test    esi, esi
    jz      short loc_4D2D1D
    mov     ecx, [ebx+5Eh]
    mov     edx, [ebx+1Eh]
    sub     ecx, esi
    sub     edx, 106h
    cmp     ecx, edx
    ja      short loc_4D2D1D
    cmp     dword ptr [ebx+7Ah], 2
    jz      short loc_4D2D1D
    push    esi
    push    ebx
    call    sub_4D2F90
    mov     [ebx+52h], eax

    loc_4D2D1D:                             ; CODE XREF: .text:004D2CF9j
                                            ; .text:004D2D0Bj ...
    mov     eax, [ebx+52h]
    cmp     eax, 3
    jb      loc_4D2DE1
    mov     ecx, [ebx+62h]
    add     eax, 0FFFFFFFDh
    push    eax
    mov     eax, [ebx+5Eh]
    sub     eax, ecx
    push    eax
    push    ebx
    call    sub_4D56E0
    mov     ecx, [ebx+52h]
    mov     edx, [ebx+66h]
    mov     ebp, eax
    mov     eax, [ebx+72h]
    sub     edx, ecx
    cmp     ecx, eax
    mov     [ebx+66h], edx
    ja      short loc_4D2DAD
    cmp     edx, 3
    jb      short loc_4D2DAD
    dec     ecx
    mov     [ebx+52h], ecx

    loc_4D2D59:                             ; CODE XREF: .text:004D2DA9j
    mov     edx, [ebx+3Ah]
    mov     ecx, [ebx+4Ah]
    mov     edi, [ebx+5Eh]
    mov     esi, [ebx+46h]
    shl     edx, cl
    mov     ecx, [ebx+2Ah]
    inc     edi
    xor     eax, eax
    mov     [ebx+5Eh], edi
    mov     al, [ecx+edi+2]
    mov     ecx, [ebx+36h]
    xor     edx, eax
    mov     eax, [ebx+32h]
    and     edx, esi
    xor     esi, esi
    mov     [ebx+3Ah], edx
    mov     si, [ecx+edx*2]
    mov     edx, [ebx+26h]
    and     edx, edi
    mov     [esp+10h], esi
    mov     [eax+edx*2], si
    mov     ecx, [ebx+3Ah]
    mov     edx, [ebx+36h]
    mov     ax, [ebx+5Eh]
    mov     [edx+ecx*2], ax
    mov     eax, [ebx+52h]
    dec     eax
    mov     [ebx+52h], eax
    jnz     short loc_4D2D59
    jmp     short loc_4D2DFE
    ; ---------------------------------------------------------------------------

    loc_4D2DAD:                             ; CODE XREF: .text:004D2D4Ej
                                            ; .text:004D2D53j
    mov     edx, [ebx+5Eh]
    mov     dword ptr [ebx+52h], 0
    add     edx, ecx
    xor     eax, eax
    mov     [ebx+5Eh], edx
    mov     ecx, edx
    mov     edx, [ebx+2Ah]
    lea     edi, [ecx+edx]
    mov     ecx, [ebx+4Ah]
    xor     edx, edx
    mov     dl, [edi]
    mov     [ebx+3Ah], edx
    mov     al, [edi+1]
    shl     edx, cl
    xor     edx, eax
    mov     eax, [ebx+46h]
    and     edx, eax
    mov     [ebx+3Ah], edx
    jmp     short loc_4D2E01
    ; ---------------------------------------------------------------------------

    loc_4D2DE1:                             ; CODE XREF: .text:004D2D23j
    mov     ecx, [ebx+5Eh]
    mov     edx, [ebx+2Ah]
    xor     eax, eax
    mov     al, [ecx+edx]
    push    eax
    push    0
    push    ebx
    call    sub_4D56E0
    mov     ecx, [ebx+66h]
    mov     ebp, eax
    dec     ecx
    mov     [ebx+66h], ecx

    loc_4D2DFE:                             ; CODE XREF: .text:004D2DABj
    inc     dword ptr [ebx+5Eh]

    loc_4D2E01:                             ; CODE XREF: .text:004D2DDFj
    test    ebp, ebp
    jz      loc_4D2C7F
    mov     ecx, [ebx+4Eh]
    test    ecx, ecx
    jl      short loc_4D2E17
    mov     eax, [ebx+2Ah]
    add     eax, ecx
    jmp     short loc_4D2E19
    ; ---------------------------------------------------------------------------

    loc_4D2E17:                             ; CODE XREF: .text:004D2E0Ej
    xor     eax, eax

    loc_4D2E19:                             ; CODE XREF: .text:004D2E15j
    mov     edx, [ebx+5Eh]
    push    0
    sub     edx, ecx
    push    edx
    push    eax
    push    ebx
    call    sub_4D4590
    mov     eax, [ebx+5Eh]
    mov     [ebx+4Eh], eax
    mov     eax, [ebx]
    mov     edi, [eax+1Ch]
    mov     ecx, [eax+10h]
    mov     edx, [edi+10h]
    cmp     edx, ecx
    jbe     short loc_4D2E3F
    mov     edx, ecx

    loc_4D2E3F:                             ; CODE XREF: .text:004D2E3Bj
    test    edx, edx
    jz      short loc_4D2E9B
    mov     esi, [edi+0Ch]
    mov     edi, [eax+0Ch]
    mov     ecx, edx
    mov     ebp, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb
    mov     edi, [eax+0Ch]
    mov     ecx, [eax+1Ch]
    add     edi, edx
    mov     [eax+0Ch], edi
    mov     esi, [ecx+0Ch]
    add     esi, edx
    mov     [ecx+0Ch], esi
    mov     ebp, [eax+14h]
    mov     edi, [eax+10h]
    mov     ecx, [eax+1Ch]
    add     ebp, edx
    sub     edi, edx
    mov     [eax+14h], ebp
    mov     [eax+10h], edi
    mov     esi, [ecx+10h]
    sub     esi, edx
    mov     [ecx+10h], esi
    mov     eax, [eax+1Ch]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4D2E97
    mov     ecx, [eax+8]
    mov     [eax+0Ch], ecx

    loc_4D2E97:                             ; CODE XREF: .text:004D2E8Fj
    mov     esi, [esp+10h]

    loc_4D2E9B:                             ; CODE XREF: .text:004D2E41j
    mov     edx, [ebx]
    mov     eax, [edx+10h]
    test    eax, eax
    jz      loc_4D2F7F
    jmp     loc_4D2C7F
    ; ---------------------------------------------------------------------------

    loc_4D2EAD:                             ; CODE XREF: .text:004D2CA7j
    mov     esi, [ebx+4Eh]
    test    esi, esi
    jl      short loc_4D2EBB
    mov     eax, [ebx+2Ah]
    add     eax, esi
    jmp     short loc_4D2EBD
    ; ---------------------------------------------------------------------------

    loc_4D2EBB:                             ; CODE XREF: .text:004D2EB2j
    xor     eax, eax

    loc_4D2EBD:                             ; CODE XREF: .text:004D2EB9j
    mov     edx, [esp+1Ch]
    xor     ecx, ecx
    cmp     edx, 4
    mov     edx, [ebx+5Eh]
    setz    cl
    sub     edx, esi
    push    ecx
    push    edx
    push    eax
    push    ebx
    call    sub_4D4590
    mov     eax, [ebx+5Eh]
    mov     [ebx+4Eh], eax
    mov     eax, [ebx]
    mov     esi, [eax+1Ch]
    mov     ecx, [eax+10h]
    mov     edx, [esi+10h]
    cmp     edx, ecx
    jbe     short loc_4D2EEE
    mov     edx, ecx

    loc_4D2EEE:                             ; CODE XREF: .text:004D2EEAj
    test    edx, edx
    jz      short loc_4D2F46
    mov     esi, [esi+0Ch]
    mov     edi, [eax+0Ch]
    mov     ecx, edx
    mov     ebp, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb
    mov     edi, [eax+0Ch]
    mov     ecx, [eax+1Ch]
    add     edi, edx
    mov     [eax+0Ch], edi
    mov     esi, [ecx+0Ch]
    add     esi, edx
    mov     [ecx+0Ch], esi
    mov     ebp, [eax+14h]
    mov     edi, [eax+10h]
    mov     ecx, [eax+1Ch]
    add     ebp, edx
    sub     edi, edx
    mov     [eax+14h], ebp
    mov     [eax+10h], edi
    mov     esi, [ecx+10h]
    sub     esi, edx
    mov     [ecx+10h], esi
    mov     eax, [eax+1Ch]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4D2F46
    mov     ecx, [eax+8]
    mov     [eax+0Ch], ecx

    loc_4D2F46:                             ; CODE XREF: .text:004D2EF0j
                                            ; .text:004D2F3Ej
    mov     edx, [ebx]
    mov     eax, [edx+10h]
    test    eax, eax
    jnz     short loc_4D2F67
    mov     esi, [esp+1Ch]
    xor     eax, eax
    cmp     esi, 4
    setnz   al
    dec     eax
    and     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D2F67:                             ; CODE XREF: .text:004D2F4Dj
    mov     eax, [esp+1Ch]
    sub     eax, 4
    neg     eax
    sbb     eax, eax
    and     al, 0FEh
    add     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D2F7F:                             ; CODE XREF: .text:004D2C9Fj
                                            ; .text:004D2EA2j
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D2F90 proc near                    ; CODE XREF: .text:004D2D15p
                                            ; .text:004D31C1p

    var_11= byte ptr -11h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    push    ebx
    push    ebp
    mov     ebp, [esp+1Ch+arg_0]
    push    esi
    push    edi
    mov     esi, [ebp+1Eh]
    mov     eax, [ebp+6Eh]
    mov     edx, [ebp+5Eh]
    mov     ecx, [ebp+2Ah]
    mov     edi, [ebp+6Ah]
    mov     [esp+24h+var_10], eax
    mov     eax, [ebp+82h]
    lea     ebx, [esi-106h]
    add     ecx, edx
    cmp     edx, ebx
    mov     [esp+24h+var_C], eax
    jbe     short loc_4D2FD2
    sub     edx, esi
    add     edx, 106h
    mov     [esp+24h+var_8], edx
    jmp     short loc_4D2FDA
    ; ---------------------------------------------------------------------------

    loc_4D2FD2:                             ; CODE XREF: sub_4D2F90+32j
    mov     [esp+24h+var_8], 0

    loc_4D2FDA:                             ; CODE XREF: sub_4D2F90+40j
    mov     dl, [edi+ecx-1]
    lea     ebx, [ecx+102h]
    mov     byte ptr [esp+24h+arg_0], dl
    mov     dl, [edi+ecx]
    mov     [esp+24h+var_11], dl
    mov     edx, [ebp+7Eh]
    cmp     edi, edx
    jb      short loc_4D2FFB
    shr     [esp+24h+var_10], 2

    loc_4D2FFB:                             ; CODE XREF: sub_4D2F90+64j
    mov     edx, [ebp+66h]
    cmp     eax, edx
    mov     [esp+24h+var_4], edx
    jbe     short loc_4D300A
    mov     [esp+24h+var_C], edx

    loc_4D300A:                             ; CODE XREF: sub_4D2F90+74j
    mov     esi, [esp+24h+arg_4]

    loc_4D300E:                             ; CODE XREF: sub_4D2F90+155j
    mov     eax, [ebp+2Ah]
    lea     edx, [esi+eax]
    mov     al, [esp+24h+var_11]
    cmp     [edi+edx], al
    jnz     loc_4D30C6
    mov     al, byte ptr [esp+24h+arg_0]
    cmp     [edi+edx-1], al
    jnz     loc_4D30C6
    mov     al, [edx]
    cmp     al, [ecx]
    jnz     loc_4D30C6
    mov     al, [edx+1]
    inc     edx
    cmp     al, [ecx+1]
    jnz     loc_4D30C6
    add     ecx, 2
    inc     edx

    loc_4D304A:                             ; CODE XREF: sub_4D2F90+104j
    mov     al, [ecx+1]
    inc     ecx
    inc     edx
    cmp     al, [edx]
    jnz     short loc_4D3096
    mov     al, [ecx+1]
    inc     ecx
    inc     edx
    cmp     al, [edx]
    jnz     short loc_4D3096
    mov     al, [ecx+1]
    inc     ecx
    inc     edx
    cmp     al, [edx]
    jnz     short loc_4D3096
    mov     al, [ecx+1]
    inc     ecx
    inc     edx
    cmp     al, [edx]
    jnz     short loc_4D3096
    mov     al, [ecx+1]
    inc     ecx
    inc     edx
    cmp     al, [edx]
    jnz     short loc_4D3096
    mov     al, [ecx+1]
    inc     ecx
    inc     edx
    cmp     al, [edx]
    jnz     short loc_4D3096
    mov     al, [ecx+1]
    inc     ecx
    inc     edx
    cmp     al, [edx]
    jnz     short loc_4D3096
    mov     al, [ecx+1]
    inc     ecx
    inc     edx
    cmp     al, [edx]
    jnz     short loc_4D3096
    cmp     ecx, ebx
    jb      short loc_4D304A

    loc_4D3096:                             ; CODE XREF: sub_4D2F90+C1j
                                            ; sub_4D2F90+CAj ...
    mov     edx, ecx
    lea     ecx, [ebx-102h]
    sub     edx, ebx
    add     edx, 102h
    cmp     edx, edi
    jle     short loc_4D30C6
    mov     eax, [esp+24h+var_C]
    mov     [ebp+62h], esi
    cmp     edx, eax
    mov     edi, edx
    jge     short loc_4D30EB
    mov     al, [edx+ecx-1]
    mov     dl, [edx+ecx]
    mov     byte ptr [esp+24h+arg_0], al
    mov     [esp+24h+var_11], dl

    loc_4D30C6:                             ; CODE XREF: sub_4D2F90+8Bj
                                            ; sub_4D2F90+99j ...
    mov     edx, [ebp+26h]
    mov     eax, [ebp+32h]
    and     edx, esi
    xor     esi, esi
    mov     si, [eax+edx*2]
    mov     eax, [esp+24h+var_8]
    cmp     esi, eax
    jbe     short loc_4D30EB
    mov     eax, [esp+24h+var_10]
    dec     eax
    mov     [esp+24h+var_10], eax
    jnz     loc_4D300E

    loc_4D30EB:                             ; CODE XREF: sub_4D2F90+125j
                                            ; sub_4D2F90+14Aj
    mov     eax, [esp+24h+var_4]
    cmp     edi, eax
    ja      short loc_4D30F5
    mov     eax, edi

    loc_4D30F5:                             ; CODE XREF: sub_4D2F90+161j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    sub_4D2F90 endp

    ; ---------------------------------------------------------------------------
    align 4
    push    ecx
    push    ebx
    mov     ebx, [esp+0Ch]
    push    ebp
    xor     ebp, ebp
    push    esi
    push    edi
    mov     [esp+10h], ebp

    loc_4D310F:                             ; CODE XREF: .text:004D32A7j
                                            ; .text:004D3349j ...
    mov     eax, [ebx+66h]
    cmp     eax, 106h
    jnb     short loc_4D313D
    push    ebx
    call    sub_4D2AD0
    mov     eax, [ebx+66h]
    cmp     eax, 106h
    jnb     short loc_4D3135
    mov     ecx, [esp+1Ch]
    test    ecx, ecx
    jz      loc_4D3537

    loc_4D3135:                             ; CODE XREF: .text:004D3127j
    test    eax, eax
    jz      loc_4D3442

    loc_4D313D:                             ; CODE XREF: .text:004D3117j
    cmp     eax, 3
    jb      short loc_4D3187
    mov     eax, [ebx+3Ah]
    mov     ecx, [ebx+4Ah]
    mov     esi, [ebx+5Eh]
    xor     edx, edx
    shl     eax, cl
    mov     ecx, [ebx+2Ah]
    xor     ebp, ebp
    mov     dl, [ecx+esi+2]
    mov     ecx, [ebx+46h]
    xor     eax, edx
    mov     edx, [ebx+26h]
    and     eax, ecx
    mov     ecx, [ebx+36h]
    mov     [ebx+3Ah], eax
    and     edx, esi
    mov     bp, [ecx+eax*2]
    mov     eax, [ebx+32h]
    mov     [esp+10h], ebp
    mov     [eax+edx*2], bp
    mov     ecx, [ebx+3Ah]
    mov     edx, [ebx+36h]
    mov     ax, [ebx+5Eh]
    mov     [edx+ecx*2], ax

    loc_4D3187:                             ; CODE XREF: .text:004D3140j
    mov     ecx, [ebx+52h]
    mov     edx, [ebx+62h]
    mov     esi, 2
    mov     [ebx+6Ah], ecx
    test    ebp, ebp
    mov     [ebx+56h], edx
    mov     [ebx+52h], esi
    jz      short loc_4D31EE
    mov     eax, ecx
    mov     ecx, [ebx+72h]
    cmp     eax, ecx
    jnb     short loc_4D31EE
    mov     ecx, [ebx+5Eh]
    mov     edx, [ebx+1Eh]
    sub     ecx, ebp
    sub     edx, 106h
    cmp     ecx, edx
    ja      short loc_4D31EE
    cmp     [ebx+7Ah], esi
    jz      short loc_4D31C9
    push    ebp
    push    ebx
    call    sub_4D2F90
    mov     [ebx+52h], eax

    loc_4D31C9:                             ; CODE XREF: .text:004D31BDj
    mov     eax, [ebx+52h]
    cmp     eax, 5
    ja      short loc_4D31EE
    cmp     dword ptr [ebx+7Ah], 1
    jz      short loc_4D31EB
    cmp     eax, 3
    jnz     short loc_4D31EE
    mov     eax, [ebx+5Eh]
    mov     edx, [ebx+62h]
    sub     eax, edx
    cmp     eax, 1000h
    jbe     short loc_4D31EE

    loc_4D31EB:                             ; CODE XREF: .text:004D31D5j
    mov     [ebx+52h], esi

    loc_4D31EE:                             ; CODE XREF: .text:004D319Dj
                                            ; .text:004D31A6j ...
    mov     ecx, [ebx+6Ah]
    cmp     ecx, 3
    jb      loc_4D334E
    cmp     [ebx+52h], ecx
    ja      loc_4D334E
    mov     eax, [ebx+5Eh]
    mov     edx, [ebx+66h]
    mov     esi, [ebx+56h]
    add     ecx, 0FFFFFFFDh
    lea     edi, [edx+eax-3]
    sub     eax, esi
    dec     eax
    push    ecx
    push    eax
    push    ebx
    call    sub_4D56E0
    mov     ecx, [ebx+6Ah]
    mov     esi, [ebx+66h]
    mov     edx, 1
    sub     edx, ecx
    add     esi, edx
    add     ecx, 0FFFFFFFEh
    mov     [ebx+66h], esi
    mov     [ebx+6Ah], ecx

    loc_4D3236:                             ; CODE XREF: .text:004D3288j
    mov     edx, [ebx+5Eh]
    inc     edx
    mov     esi, edx
    mov     [ebx+5Eh], edx
    cmp     esi, edi
    ja      short loc_4D3281
    mov     edx, [ebx+3Ah]
    mov     ecx, [ebx+4Ah]
    mov     ebp, [ebx+2Ah]
    shl     edx, cl
    xor     ecx, ecx
    mov     cl, [ebp+esi+2]
    mov     ebp, [ebx+46h]
    xor     edx, ecx
    mov     ecx, [ebx+36h]
    and     edx, ebp
    xor     ebp, ebp
    mov     [ebx+3Ah], edx
    mov     bp, [ecx+edx*2]
    mov     edx, [ebx+26h]
    mov     ecx, [ebx+32h]
    and     edx, esi
    mov     [ecx+edx*2], bp
    mov     edx, [ebx+3Ah]
    mov     ecx, [ebx+36h]
    mov     si, [ebx+5Eh]
    mov     [ecx+edx*2], si

    loc_4D3281:                             ; CODE XREF: .text:004D3241j
    mov     ecx, [ebx+6Ah]
    dec     ecx
    mov     [ebx+6Ah], ecx
    jnz     short loc_4D3236
    mov     esi, [ebx+5Eh]
    mov     [esp+10h], ebp
    inc     esi
    mov     dword ptr [ebx+5Ah], 0
    test    eax, eax
    mov     dword ptr [ebx+52h], 2
    mov     [ebx+5Eh], esi
    mov     ecx, esi
    jz      loc_4D310F
    mov     edx, [ebx+4Eh]
    test    edx, edx
    jl      short loc_4D32BB
    mov     eax, [ebx+2Ah]
    add     eax, edx
    jmp     short loc_4D32BD
    ; ---------------------------------------------------------------------------

    loc_4D32BB:                             ; CODE XREF: .text:004D32B2j
    xor     eax, eax

    loc_4D32BD:                             ; CODE XREF: .text:004D32B9j
    sub     ecx, edx
    push    0
    push    ecx
    push    eax
    push    ebx
    call    sub_4D4590
    mov     edx, [ebx+5Eh]
    mov     eax, [ebx]
    mov     [ebx+4Eh], edx
    mov     esi, [eax+1Ch]
    mov     ecx, [eax+10h]
    mov     edx, [esi+10h]
    cmp     edx, ecx
    jbe     short loc_4D32E0
    mov     edx, ecx

    loc_4D32E0:                             ; CODE XREF: .text:004D32DCj
    test    edx, edx
    jz      short loc_4D333C
    mov     esi, [esi+0Ch]
    mov     edi, [eax+0Ch]
    mov     ecx, edx
    mov     ebp, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb
    mov     edi, [eax+0Ch]
    mov     ecx, [eax+1Ch]
    add     edi, edx
    mov     [eax+0Ch], edi
    mov     esi, [ecx+0Ch]
    add     esi, edx
    mov     [ecx+0Ch], esi
    mov     ebp, [eax+14h]
    mov     edi, [eax+10h]
    mov     ecx, [eax+1Ch]
    add     ebp, edx
    sub     edi, edx
    mov     [eax+14h], ebp
    mov     [eax+10h], edi
    mov     esi, [ecx+10h]
    sub     esi, edx
    mov     [ecx+10h], esi
    mov     eax, [eax+1Ch]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4D3338
    mov     ecx, [eax+8]
    mov     [eax+0Ch], ecx

    loc_4D3338:                             ; CODE XREF: .text:004D3330j
    mov     ebp, [esp+10h]

    loc_4D333C:                             ; CODE XREF: .text:004D32E2j
    mov     edx, [ebx]
    mov     eax, [edx+10h]
    test    eax, eax
    jz      loc_4D3537
    jmp     loc_4D310F
    ; ---------------------------------------------------------------------------

    loc_4D334E:                             ; CODE XREF: .text:004D31F4j
                                            ; .text:004D31FDj
    mov     eax, [ebx+5Ah]
    test    eax, eax
    jz      loc_4D3428
    mov     eax, [ebx+5Eh]
    mov     ecx, [ebx+2Ah]
    xor     edx, edx
    mov     dl, [eax+ecx-1]
    push    edx
    push    0
    push    ebx
    call    sub_4D56E0
    test    eax, eax
    jz      loc_4D3408
    mov     ecx, [ebx+4Eh]
    test    ecx, ecx
    jl      short loc_4D3384
    mov     eax, [ebx+2Ah]
    add     eax, ecx
    jmp     short loc_4D3386
    ; ---------------------------------------------------------------------------

    loc_4D3384:                             ; CODE XREF: .text:004D337Bj
    xor     eax, eax

    loc_4D3386:                             ; CODE XREF: .text:004D3382j
    mov     edx, [ebx+5Eh]
    push    0
    sub     edx, ecx
    push    edx
    push    eax
    push    ebx
    call    sub_4D4590
    mov     eax, [ebx+5Eh]
    mov     [ebx+4Eh], eax
    mov     eax, [ebx]
    mov     esi, [eax+1Ch]
    mov     ecx, [eax+10h]
    mov     edx, [esi+10h]
    cmp     edx, ecx
    jbe     short loc_4D33AC
    mov     edx, ecx

    loc_4D33AC:                             ; CODE XREF: .text:004D33A8j
    test    edx, edx
    jz      short loc_4D3408
    mov     esi, [esi+0Ch]
    mov     edi, [eax+0Ch]
    mov     ecx, edx
    mov     ebp, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb
    mov     edi, [eax+0Ch]
    mov     ecx, [eax+1Ch]
    add     edi, edx
    mov     [eax+0Ch], edi
    mov     esi, [ecx+0Ch]
    add     esi, edx
    mov     [ecx+0Ch], esi
    mov     ebp, [eax+14h]
    mov     edi, [eax+10h]
    mov     ecx, [eax+1Ch]
    add     ebp, edx
    sub     edi, edx
    mov     [eax+14h], ebp
    mov     [eax+10h], edi
    mov     esi, [ecx+10h]
    sub     esi, edx
    mov     [ecx+10h], esi
    mov     eax, [eax+1Ch]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4D3404
    mov     ecx, [eax+8]
    mov     [eax+0Ch], ecx

    loc_4D3404:                             ; CODE XREF: .text:004D33FCj
    mov     ebp, [esp+10h]

    loc_4D3408:                             ; CODE XREF: .text:004D3370j
                                            ; .text:004D33AEj
    mov     edx, [ebx+5Eh]
    mov     ecx, [ebx+66h]
    inc     edx
    dec     ecx
    mov     [ebx+5Eh], edx
    mov     edx, [ebx]
    mov     [ebx+66h], ecx
    mov     eax, [edx+10h]
    test    eax, eax
    jz      loc_4D3537
    jmp     loc_4D310F
    ; ---------------------------------------------------------------------------

    loc_4D3428:                             ; CODE XREF: .text:004D3353j
    mov     ecx, [ebx+5Eh]
    mov     eax, [ebx+66h]
    inc     ecx
    dec     eax
    mov     dword ptr [ebx+5Ah], 1
    mov     [ebx+5Eh], ecx
    mov     [ebx+66h], eax
    jmp     loc_4D310F
    ; ---------------------------------------------------------------------------

    loc_4D3442:                             ; CODE XREF: .text:004D3137j
    mov     eax, [ebx+5Ah]
    test    eax, eax
    jz      short loc_4D3465
    mov     eax, [ebx+2Ah]
    mov     ecx, [ebx+5Eh]
    xor     edx, edx
    mov     dl, [eax+ecx-1]
    push    edx
    push    0
    push    ebx
    call    sub_4D56E0
    mov     dword ptr [ebx+5Ah], 0

    loc_4D3465:                             ; CODE XREF: .text:004D3447j
    mov     esi, [ebx+4Eh]
    test    esi, esi
    jl      short loc_4D3473
    mov     eax, [ebx+2Ah]
    add     eax, esi
    jmp     short loc_4D3475
    ; ---------------------------------------------------------------------------

    loc_4D3473:                             ; CODE XREF: .text:004D346Aj
    xor     eax, eax

    loc_4D3475:                             ; CODE XREF: .text:004D3471j
    mov     edx, [esp+1Ch]
    xor     ecx, ecx
    cmp     edx, 4
    mov     edx, [ebx+5Eh]
    setz    cl
    sub     edx, esi
    push    ecx
    push    edx
    push    eax
    push    ebx
    call    sub_4D4590
    mov     eax, [ebx+5Eh]
    mov     [ebx+4Eh], eax
    mov     eax, [ebx]
    mov     esi, [eax+1Ch]
    mov     ecx, [eax+10h]
    mov     edx, [esi+10h]
    cmp     edx, ecx
    jbe     short loc_4D34A6
    mov     edx, ecx

    loc_4D34A6:                             ; CODE XREF: .text:004D34A2j
    test    edx, edx
    jz      short loc_4D34FE
    mov     esi, [esi+0Ch]
    mov     edi, [eax+0Ch]
    mov     ecx, edx
    mov     ebp, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb
    mov     edi, [eax+0Ch]
    mov     ecx, [eax+1Ch]
    add     edi, edx
    mov     [eax+0Ch], edi
    mov     esi, [ecx+0Ch]
    add     esi, edx
    mov     [ecx+0Ch], esi
    mov     ebp, [eax+14h]
    mov     edi, [eax+10h]
    mov     ecx, [eax+1Ch]
    add     ebp, edx
    sub     edi, edx
    mov     [eax+14h], ebp
    mov     [eax+10h], edi
    mov     esi, [ecx+10h]
    sub     esi, edx
    mov     [ecx+10h], esi
    mov     eax, [eax+1Ch]
    mov     ecx, [eax+10h]
    test    ecx, ecx
    jnz     short loc_4D34FE
    mov     ecx, [eax+8]
    mov     [eax+0Ch], ecx

    loc_4D34FE:                             ; CODE XREF: .text:004D34A8j
                                            ; .text:004D34F6j
    mov     edx, [ebx]
    mov     eax, [edx+10h]
    test    eax, eax
    jnz     short loc_4D351F
    mov     esi, [esp+1Ch]
    xor     eax, eax
    cmp     esi, 4
    setnz   al
    dec     eax
    and     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D351F:                             ; CODE XREF: .text:004D3505j
    mov     eax, [esp+1Ch]
    sub     eax, 4
    neg     eax
    sbb     eax, eax
    and     al, 0FEh
    add     eax, 3
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3537:                             ; CODE XREF: .text:004D312Fj
                                            ; .text:004D3343j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    xor     edx, edx
    cmp     eax, edx
    jz      short loc_4D358D
    mov     ecx, [eax+1Ch]
    cmp     ecx, edx
    jz      short loc_4D358D
    mov     [eax+14h], edx
    mov     [eax+8], edx
    mov     [eax+18h], edx
    mov     edx, [ecx+0Ch]
    neg     edx
    sbb     edx, edx
    and     edx, 7
    mov     [ecx], edx
    mov     edx, [eax+1Ch]
    lea     ecx, [esp+4]
    push    ecx
    push    eax
    mov     eax, [edx+14h]
    push    eax
    call    sub_4D5E00
    xor     eax, eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D358D:                             ; CODE XREF: .text:004D3558j
                                            ; .text:004D355Fj
    mov     eax, 0FFFFFFFEh
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D35A0 proc near                    ; CODE XREF: sub_4D1D20+5Ep
                                            ; sub_4D1D20+78p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jz      short loc_4D35E2
    mov     eax, [esi+1Ch]
    test    eax, eax
    jz      short loc_4D35E2
    mov     ecx, [esi+24h]
    test    ecx, ecx
    jz      short loc_4D35E2
    mov     eax, [eax+14h]
    test    eax, eax
    jz      short loc_4D35CA
    lea     ecx, [esp+arg_0]
    push    ecx
    push    esi
    push    eax
    call    sub_4D6B70

    loc_4D35CA:                             ; CODE XREF: sub_4D35A0+1Cj
    mov     edx, [esi+1Ch]
    mov     eax, [esi+28h]
    push    edx
    push    eax
    call    dword ptr [esi+24h]
    mov     dword ptr [esi+1Ch], 0
    xor     eax, eax
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D35E2:                             ; CODE XREF: sub_4D35A0+7j
                                            ; sub_4D35A0+Ej ...
    mov     eax, 0FFFFFFFEh
    pop     esi
    retn    4
    sub_4D35A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D35F0 proc near                    ; CODE XREF: sub_4D3780+11p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_8]
    push    esi
    push    edi
    xor     edi, edi
    cmp     eax, edi
    jz      loc_4D376A
    mov     al, [eax]
    mov     cl, byte ptr a1_0_4             ; "1.0.4"
    cmp     al, cl
    jnz     loc_4D376A
    cmp     [esp+8+arg_C], 38h
    jnz     loc_4D376A
    mov     esi, [esp+8+arg_0]
    cmp     esi, edi
    jnz     short loc_4D362D
    mov     eax, 0FFFFFFFEh
    pop     edi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D362D:                             ; CODE XREF: sub_4D35F0+31j
    mov     eax, [esi+20h]
    mov     [esi+18h], edi
    cmp     eax, edi
    jnz     short loc_4D3641
    mov     dword ptr [esi+20h], offset loc_4D3D70
    mov     [esi+28h], edi

    loc_4D3641:                             ; CODE XREF: sub_4D35F0+45j
    cmp     [esi+24h], edi
    jnz     short loc_4D364D
    mov     dword ptr [esi+24h], offset loc_4D3D90

    loc_4D364D:                             ; CODE XREF: sub_4D35F0+54j
    mov     ecx, [esi+28h]
    push    18h
    push    1
    push    ecx
    call    dword ptr [esi+20h]
    cmp     eax, edi
    mov     [esi+1Ch], eax
    jnz     short loc_4D3669
    mov     eax, 0FFFFFFFCh
    pop     edi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D3669:                             ; CODE XREF: sub_4D35F0+6Dj
    mov     ecx, [esp+14h+var_4]
    mov     [eax+14h], edi
    mov     edx, [esi+1Ch]
    cmp     ecx, edi
    mov     [edx+0Ch], edi
    jge     short loc_4D3686
    mov     eax, [esi+1Ch]
    neg     ecx
    mov     dword ptr [eax+0Ch], 1

    loc_4D3686:                             ; CODE XREF: sub_4D35F0+88j
    cmp     ecx, 8
    jl      loc_4D3733
    cmp     ecx, 0Fh
    jg      loc_4D3733
    mov     edx, [esi+1Ch]
    mov     eax, 1
    shl     eax, cl
    mov     [edx+10h], ecx
    mov     ecx, [esi+1Ch]
    mov     edx, [ecx+0Ch]
    neg     edx
    sbb     edx, edx
    push    eax
    not     edx
    and     edx, offset sub_4D5CD0
    push    edx
    push    esi
    call    sub_4D5E90
    mov     ecx, [esi+1Ch]
    mov     [ecx+14h], eax
    mov     eax, [esi+1Ch]
    cmp     [eax+14h], edi
    jnz     short loc_4D3701
    cmp     eax, edi
    jz      short loc_4D36F7
    cmp     [esi+24h], edi
    jz      short loc_4D36F7
    mov     eax, [eax+14h]
    cmp     eax, edi
    jz      short loc_4D36E9
    lea     edx, [esp+14h]
    push    edx
    push    esi
    push    eax
    call    sub_4D6B70

    loc_4D36E9:                             ; CODE XREF: sub_4D35F0+EBj
    mov     eax, [esi+1Ch]
    mov     ecx, [esi+28h]
    push    eax
    push    ecx
    call    dword ptr [esi+24h]
    mov     [esi+1Ch], edi

    loc_4D36F7:                             ; CODE XREF: sub_4D35F0+DFj
                                            ; sub_4D35F0+E4j
    mov     eax, 0FFFFFFFCh
    pop     edi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D3701:                             ; CODE XREF: sub_4D35F0+DBj
    cmp     eax, edi
    jz      short loc_4D372C
    mov     [esi+14h], edi
    mov     [esi+8], edi
    mov     [esi+18h], edi
    mov     edx, [eax+0Ch]
    neg     edx
    sbb     edx, edx
    and     edx, 7
    mov     [eax], edx
    mov     ecx, [esi+1Ch]
    lea     eax, [esp+14h]
    mov     edx, [ecx+14h]
    push    eax
    push    esi
    push    edx
    call    sub_4D5E00

    loc_4D372C:                             ; CODE XREF: sub_4D35F0+113j
    xor     eax, eax
    pop     edi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D3733:                             ; CODE XREF: sub_4D35F0+99j
                                            ; sub_4D35F0+A2j
    mov     eax, [esi+1Ch]
    cmp     eax, edi
    jz      short loc_4D3760
    cmp     [esi+24h], edi
    jz      short loc_4D3760
    mov     eax, [eax+14h]
    cmp     eax, edi
    jz      short loc_4D3752
    lea     ecx, [esp+14h]
    push    ecx
    push    esi
    push    eax
    call    sub_4D6B70

    loc_4D3752:                             ; CODE XREF: sub_4D35F0+154j
    mov     edx, [esi+1Ch]
    mov     eax, [esi+28h]
    push    edx
    push    eax
    call    dword ptr [esi+24h]
    mov     [esi+1Ch], edi

    loc_4D3760:                             ; CODE XREF: sub_4D35F0+148j
                                            ; sub_4D35F0+14Dj
    mov     eax, 0FFFFFFFEh
    pop     edi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D376A:                             ; CODE XREF: sub_4D35F0+Aj
                                            ; sub_4D35F0+1Aj ...
    pop     edi
    mov     eax, 0FFFFFFFAh
    pop     esi
    retn    10h
    sub_4D35F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D3780 proc near                    ; CODE XREF: sub_4D1D20+3Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    mov     ecx, [esp+arg_4]
    mov     edx, [esp+arg_0]
    push    eax
    push    ecx
    push    0Fh
    push    edx
    call    sub_4D35F0
    retn    0Ch
    sub_4D3780 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D37A0 proc near                    ; CODE XREF: sub_4D1D20+4Dp

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    push    edi
    jz      loc_4D3B8F                      ; default
    mov     eax, [esi+1Ch]
    test    eax, eax
    jz      loc_4D3B8F                      ; default
    cmp     dword ptr [esi], 0
    jz      loc_4D3B8F                      ; default
    mov     eax, [esp+4+arg_4]
    test    eax, eax
    jl      loc_4D3B8F                      ; default
    mov     edi, 0FFFFFFFBh

    loc_4D37D5:                             ; CODE XREF: sub_4D37A0+12Bj
    mov     ebx, 5

    loc_4D37DA:                             ; CODE XREF: sub_4D37A0+96j
                                            ; sub_4D37A0+BBj ...
    mov     eax, [esi+1Ch]
    mov     ecx, [eax]
    cmp     ecx, 0Dh                        ; switch 14 cases
    ja      loc_4D3B8F                      ; default
    jmp     ds:off_4D3B9C[ecx*4]            ; switch jump

    loc_4D37EF:                             ; DATA XREF: .text:004D3B9Co
    mov     ecx, [esi+4]                    ; case 0x0
    test    ecx, ecx
    jz      loc_4D3B65
    mov     ebp, [esi+8]
    xor     edi, edi
    dec     ecx
    inc     ebp
    mov     [esi+4], ecx
    mov     ecx, [esi]
    xor     edx, edx
    mov     [esi+8], ebp
    mov     dl, [ecx]
    mov     [eax+4], edx
    mov     eax, [esi+1Ch]
    mov     ebp, [esi]
    mov     ecx, [eax+4]
    and     ecx, 0Fh
    inc     ebp
    cmp     cl, 8
    mov     [esi], ebp
    jz      short loc_4D3838
    mov     dword ptr [eax], 0Dh
    mov     edx, [esi+1Ch]
    mov     dword ptr [esi+18h], offset aUnknownCompres ; "unknown compression method"
    mov     [edx+4], ebx
    jmp     short loc_4D37DA
    ; ---------------------------------------------------------------------------

    loc_4D3838:                             ; CODE XREF: sub_4D37A0+81j
    mov     ecx, [eax+4]
    mov     edx, [eax+10h]
    shr     ecx, 4
    add     ecx, 8
    cmp     ecx, edx
    jbe     short loc_4D3860
    mov     dword ptr [eax], 0Dh
    mov     edx, [esi+1Ch]
    mov     dword ptr [esi+18h], offset aInvalidWindowS ; "invalid window size"
    mov     [edx+4], ebx
    jmp     loc_4D37DA
    ; ---------------------------------------------------------------------------

    loc_4D3860:                             ; CODE XREF: sub_4D37A0+A6j
    mov     dword ptr [eax], 1

    loc_4D3866:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, [esi+4]                    ; case 0x1
    test    eax, eax
    jz      loc_4D3B65
    xor     edi, edi
    dec     eax
    mov     [esi+4], eax
    mov     eax, [esi+8]
    mov     ebx, [esi+1Ch]
    inc     eax
    mov     [esi+8], eax
    mov     eax, [esi]
    xor     ecx, ecx
    xor     edx, edx
    mov     cl, [eax]
    inc     eax
    mov     [esi], eax
    mov     eax, [ebx+4]
    shl     eax, 8
    add     eax, ecx
    mov     ebp, 1Fh
    div     ebp
    test    edx, edx
    jz      short loc_4D38BC
    mov     dword ptr [ebx], 0Dh
    mov     eax, [esi+1Ch]
    mov     ebx, 5
    mov     dword ptr [esi+18h], offset aIncorrectHeade ; "incorrect header check"
    mov     [eax+4], ebx
    jmp     loc_4D37DA
    ; ---------------------------------------------------------------------------

    loc_4D38BC:                             ; CODE XREF: sub_4D37A0+FDj
    test    cl, 20h
    jnz     loc_4D3A31
    mov     dword ptr [ebx], 7
    jmp     loc_4D37D5
    ; ---------------------------------------------------------------------------

    loc_4D38D0:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     ecx, [eax+14h]                  ; case 0x7
    push    edi
    push    esi
    push    ecx
    call    sub_4D5F00
    mov     edi, eax
    cmp     edi, 0FFFFFFFDh
    jnz     short loc_4D38FA
    mov     edx, [esi+1Ch]
    mov     dword ptr [edx], 0Dh
    mov     eax, [esi+1Ch]
    mov     dword ptr [eax+4], 0
    jmp     loc_4D37DA
    ; ---------------------------------------------------------------------------

    loc_4D38FA:                             ; CODE XREF: sub_4D37A0+140j
    cmp     edi, 1
    jnz     loc_4D3B65
    mov     eax, [esi+1Ch]
    xor     edi, edi
    mov     edx, [eax+14h]
    lea     ecx, [eax+4]
    push    ecx
    push    esi
    push    edx
    call    sub_4D5E00
    mov     eax, [esi+1Ch]
    mov     ecx, [eax+0Ch]
    test    ecx, ecx
    jz      short loc_4D392B
    mov     dword ptr [eax], 0Ch
    jmp     loc_4D37DA
    ; ---------------------------------------------------------------------------

    loc_4D392B:                             ; CODE XREF: sub_4D37A0+17Ej
    mov     dword ptr [eax], 8

    loc_4D3931:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, [esi+4]                    ; case 0x8
    test    eax, eax
    jz      loc_4D3B65
    mov     ebp, [esi+8]
    xor     edi, edi
    mov     edx, [esi+1Ch]
    dec     eax
    mov     [esi+4], eax
    mov     eax, [esi]
    inc     ebp
    xor     ecx, ecx
    mov     [esi+8], ebp
    mov     cl, [eax]
    shl     ecx, 18h
    mov     [edx+8], ecx
    mov     eax, [esi]
    inc     eax
    mov     [esi], eax
    mov     eax, [esi+1Ch]
    mov     dword ptr [eax], 9

    loc_4D3966:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, [esi+4]                    ; case 0x9
    test    eax, eax
    jz      loc_4D3B65
    mov     ecx, [esi]
    xor     edi, edi
    dec     eax
    xor     edx, edx
    mov     [esi+4], eax
    mov     eax, [esi+8]
    inc     eax
    mov     [esi+8], eax
    mov     eax, [esi+1Ch]
    mov     dl, [ecx]
    mov     ecx, [eax+8]
    shl     edx, 10h
    add     ecx, edx
    mov     [eax+8], ecx
    mov     eax, [esi]
    inc     eax
    mov     [esi], eax
    mov     eax, [esi+1Ch]
    mov     dword ptr [eax], 0Ah

    loc_4D39A0:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, [esi+4]                    ; case 0xa
    test    eax, eax
    jz      loc_4D3B65
    mov     ecx, [esi]
    xor     edi, edi
    dec     eax
    xor     edx, edx
    mov     [esi+4], eax
    mov     eax, [esi+8]
    inc     eax
    mov     [esi+8], eax
    mov     eax, [esi+1Ch]
    mov     dl, [ecx]
    mov     ecx, [eax+8]
    shl     edx, 8
    add     ecx, edx
    mov     [eax+8], ecx
    mov     eax, [esi]
    inc     eax
    mov     [esi], eax
    mov     eax, [esi+1Ch]
    mov     dword ptr [eax], 0Bh

    loc_4D39DA:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, [esi+4]                    ; case 0xb
    test    eax, eax
    jz      loc_4D3B65
    mov     edx, [esi+8]
    mov     ecx, [esi]
    xor     edi, edi
    dec     eax
    inc     edx
    mov     [esi+4], eax
    mov     eax, [esi+1Ch]
    mov     [esi+8], edx
    xor     edx, edx
    mov     dl, [ecx]
    mov     ecx, [eax+8]
    add     ecx, edx
    mov     [eax+8], ecx
    mov     ebp, [esi]
    mov     eax, [esi+1Ch]
    inc     ebp
    mov     [esi], ebp
    mov     ecx, [eax+4]
    mov     edx, [eax+8]
    cmp     ecx, edx
    jz      loc_4D3B6E
    mov     dword ptr [eax], 0Dh
    mov     edx, [esi+1Ch]
    mov     dword ptr [esi+18h], offset aIncorrectDataC ; "incorrect data check"
    mov     [edx+4], ebx
    jmp     loc_4D37DA
    ; ---------------------------------------------------------------------------

    loc_4D3A31:                             ; CODE XREF: sub_4D37A0+11Fj
    mov     eax, [esi+1Ch]
    mov     ebx, 5
    mov     dword ptr [eax], 2

    loc_4D3A3F:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, [esi+4]                    ; case 0x2
    test    eax, eax
    jnz     short loc_4D3A4F
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3A4F:                             ; CODE XREF: sub_4D37A0+2A4j
    mov     edx, [esi+8]
    mov     ecx, [esi]
    xor     edi, edi
    dec     eax
    inc     edx
    mov     [esi+4], eax
    mov     eax, [esi+1Ch]
    mov     [esi+8], edx
    xor     edx, edx
    mov     dl, [ecx]
    shl     edx, 18h
    mov     [eax+8], edx
    mov     eax, [esi]
    mov     ecx, [esi+1Ch]
    inc     eax
    mov     [esi], eax
    mov     dword ptr [ecx], 3

    loc_4D3A79:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, [esi+4]                    ; case 0x3
    test    eax, eax
    jnz     short loc_4D3A89
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3A89:                             ; CODE XREF: sub_4D37A0+2DEj
    mov     edx, [esi]
    xor     edi, edi
    dec     eax
    xor     ecx, ecx
    mov     [esi+4], eax
    mov     eax, [esi+8]
    inc     eax
    mov     [esi+8], eax
    mov     eax, [esi+1Ch]
    mov     cl, [edx]
    mov     edx, [eax+8]
    shl     ecx, 10h
    add     edx, ecx
    mov     [eax+8], edx
    mov     eax, [esi]
    mov     edx, [esi+1Ch]
    inc     eax
    mov     [esi], eax
    mov     dword ptr [edx], 4

    loc_4D3AB8:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, [esi+4]                    ; case 0x4
    test    eax, eax
    jnz     short loc_4D3AC8
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3AC8:                             ; CODE XREF: sub_4D37A0+31Dj
    mov     ecx, [esi]
    xor     edi, edi
    dec     eax
    xor     edx, edx
    mov     [esi+4], eax
    mov     eax, [esi+8]
    inc     eax
    mov     [esi+8], eax
    mov     eax, [esi+1Ch]
    mov     dl, [ecx]
    mov     ecx, [eax+8]
    shl     edx, 8
    add     ecx, edx
    mov     [eax+8], ecx
    mov     eax, [esi]
    inc     eax
    mov     [esi], eax
    mov     eax, [esi+1Ch]
    mov     [eax], ebx

    loc_4D3AF3:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, [esi+4]                    ; case 0x5
    test    eax, eax
    jnz     short loc_4D3B03
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3B03:                             ; CODE XREF: sub_4D37A0+358j
    mov     edx, [esi+8]
    mov     ecx, [esi]
    dec     eax
    inc     edx
    mov     [esi+4], eax
    mov     eax, [esi+1Ch]
    mov     [esi+8], edx
    xor     edx, edx
    mov     dl, [ecx]
    mov     ecx, [eax+8]
    add     ecx, edx
    mov     [eax+8], ecx
    mov     eax, [esi]
    inc     eax
    mov     [esi], eax
    mov     eax, [esi+1Ch]
    mov     ecx, [eax+8]
    mov     [esi+30h], ecx
    mov     dword ptr [eax], 6
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3B3F:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     edx, [esi+1Ch]                  ; case 0x6
    mov     dword ptr [edx], 0Dh
    mov     eax, [esi+1Ch]
    mov     dword ptr [esi+18h], offset aNeedDictionary ; "need dictionary"
    mov     dword ptr [eax+4], 0
    mov     eax, 0FFFFFFFEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3B65:                             ; CODE XREF: sub_4D37A0+54j
                                            ; sub_4D37A0+CBj ...
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3B6E:                             ; CODE XREF: sub_4D37A0+273j
    mov     ecx, [esi+1Ch]
    mov     dword ptr [ecx], 0Ch

    loc_4D3B77:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, 1                          ; case 0xc
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3B83:                             ; CODE XREF: sub_4D37A0+48j
                                            ; DATA XREF: .text:004D3B9Co
    mov     eax, 0FFFFFFFDh                 ; case 0xd
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4D3B8F:                             ; CODE XREF: sub_4D37A0+Aj
                                            ; sub_4D37A0+15j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    mov     eax, 0FFFFFFFEh
    pop     ebx
    retn    8
    sub_4D37A0 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4D3B9C dd offset loc_4D37EF         ; DATA XREF: sub_4D37A0+48r
    dd offset loc_4D3866                    ; jump table for switch statement
    dd offset loc_4D3A3F
    dd offset loc_4D3A79
    dd offset loc_4D3AB8
    dd offset loc_4D3AF3
    dd offset loc_4D3B3F
    dd offset loc_4D38D0
    dd offset loc_4D3931
    dd offset loc_4D3966
    dd offset loc_4D39A0
    dd offset loc_4D39DA
    dd offset loc_4D3B77
    dd offset loc_4D3B83
    align 10h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+18h]
    push    edi
    mov     edi, [esp+14h]
    test    edi, edi
    mov     ebx, esi
    jz      short loc_4D3C54
    mov     eax, [edi+1Ch]
    test    eax, eax
    jz      short loc_4D3C54
    cmp     dword ptr [eax], 6
    jnz     short loc_4D3C54
    mov     ebp, [esp+18h]
    push    esi
    push    ebp
    push    1
    call    sub_4D5CD0
    cmp     eax, [edi+30h]
    jz      short loc_4D3C1C
    mov     eax, 0FFFFFFFDh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D3C1C:                             ; CODE XREF: .text:004D3C0Ej
    mov     edx, [edi+1Ch]
    mov     eax, 1
    mov     [edi+30h], eax
    mov     ecx, [edx+10h]
    shl     eax, cl
    cmp     esi, eax
    jb      short loc_4D3C37
    lea     ebx, [eax-1]
    sub     esi, ebx
    add     ebp, esi

    loc_4D3C37:                             ; CODE XREF: .text:004D3C2Ej
    mov     eax, [edx+14h]
    push    ebx
    push    ebp
    push    eax
    call    sub_4D6BA0
    mov     ecx, [edi+1Ch]
    xor     eax, eax
    mov     dword ptr [ecx], 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D3C54:                             ; CODE XREF: .text:004D3BF0j
                                            ; .text:004D3BF7j ...
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 0FFFFFFFEh
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+10h]
    test    esi, esi
    push    edi
    jz      loc_4D3D54
    mov     eax, [esi+1Ch]
    test    eax, eax
    jz      loc_4D3D54
    cmp     dword ptr [eax], 0Dh
    jz      short loc_4D3C90
    mov     dword ptr [eax], 0Dh
    mov     eax, [esi+1Ch]
    mov     dword ptr [eax+4], 0

    loc_4D3C90:                             ; CODE XREF: .text:004D3C7Ej
    mov     ebp, [esi+4]
    test    ebp, ebp
    jnz     short loc_4D3CA3
    mov     eax, 0FFFFFFFBh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D3CA3:                             ; CODE XREF: .text:004D3C95j
    mov     eax, [esi+1Ch]
    mov     ebx, [esi]
    mov     edi, ebx
    mov     eax, [eax+4]

    loc_4D3CAD:                             ; CODE XREF: .text:004D3CDCj
    cmp     eax, 4
    jnb     short loc_4D3CDE
    mov     cl, [edi]
    cmp     eax, 2
    sbb     edx, edx
    and     dl, 1
    add     edx, 0FFh
    cmp     cl, dl
    jnz     short loc_4D3CC9
    inc     eax
    jmp     short loc_4D3CDA
    ; ---------------------------------------------------------------------------

    loc_4D3CC9:                             ; CODE XREF: .text:004D3CC4j
    test    cl, cl
    jz      short loc_4D3CD1
    xor     eax, eax
    jmp     short loc_4D3CDA
    ; ---------------------------------------------------------------------------

    loc_4D3CD1:                             ; CODE XREF: .text:004D3CCBj
    mov     ecx, 4
    sub     ecx, eax
    mov     eax, ecx

    loc_4D3CDA:                             ; CODE XREF: .text:004D3CC7j
                                            ; .text:004D3CCFj
    inc     edi
    dec     ebp
    jnz     short loc_4D3CAD

    loc_4D3CDE:                             ; CODE XREF: .text:004D3CB0j
    mov     ecx, [esi+1Ch]
    mov     edx, edi
    sub     edx, ebx
    mov     ebx, [esi+8]
    add     ebx, edx
    mov     [esi], edi
    mov     [esi+8], ebx
    mov     [esi+4], ebp
    cmp     eax, 4
    mov     [ecx+4], eax
    jz      short loc_4D3D06
    mov     eax, 0FFFFFFFDh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D3D06:                             ; CODE XREF: .text:004D3CF8j
    mov     eax, [esi+1Ch]
    mov     edi, [esi+8]
    mov     ebx, [esi+14h]
    xor     ecx, ecx
    cmp     eax, ecx
    jz      short loc_4D3D3C
    mov     [esi+14h], ecx
    mov     [esi+8], ecx
    mov     [esi+18h], ecx
    mov     ecx, [eax+0Ch]
    neg     ecx
    sbb     ecx, ecx
    lea     edx, [esp+14h]
    and     ecx, 7
    push    edx
    mov     [eax], ecx
    mov     eax, [esi+1Ch]
    push    esi
    mov     ecx, [eax+14h]
    push    ecx
    call    sub_4D5E00

    loc_4D3D3C:                             ; CODE XREF: .text:004D3D13j
    mov     edx, [esi+1Ch]
    mov     [esi+8], edi
    mov     [esi+14h], ebx
    xor     eax, eax
    mov     dword ptr [edx], 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D3D54:                             ; CODE XREF: .text:004D3C6Aj
                                            ; .text:004D3C75j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 0FFFFFFFEh
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------
    mov     eax, offset a1_0_4              ; "1.0.4"
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    loc_4D3D70:                             ; DATA XREF: sub_4D1DE0+4Do
                                            ; sub_4D35F0+47o
    mov     eax, [esp+0Ch]
    mov     ecx, [esp+8]
    push    eax
    push    ecx
    call    _calloc
    add     esp, 8
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 10h

    loc_4D3D90:                             ; DATA XREF: sub_4D1DE0+5Co
                                            ; sub_4D35F0+56o
    mov     eax, [esp+8]
    push    eax
    call    _free
    add     esp, 4
    retn    8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D3DA0 proc near                    ; CODE XREF: sub_4D1DE0+241p
                                            ; .text:004D225Cp

    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_32= word ptr -32h
    var_30= word ptr -30h
    var_2E= word ptr -2Eh
    var_20= dword ptr -20h
    arg_0= dword ptr  4

    mov     eax, dword_5278E8
    sub     esp, 44h
    test    eax, eax
    push    ebx
    push    ebp
    push    esi
    push    edi
    jnz     loc_4D3FDD
    xor     eax, eax
    xor     edx, edx
    mov     [esp+54h+var_44], eax

    loc_4D3DBC:                             ; CODE XREF: sub_4D3DA0+67j
    mov     ecx, dword_50BCD0[edx*4]
    mov     esi, 1
    shl     esi, cl
    mov     dword_527100[edx*4], eax
    test    esi, esi
    jle     short loc_4D3E03
    lea     edi, dword_527000[eax]
    mov     al, dl
    mov     bl, al
    mov     ecx, esi
    mov     bh, bl
    mov     ebp, ecx
    mov     eax, ebx
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, ebp
    and     ecx, 3
    rep stosb
    mov     eax, [esp+54h+var_44]
    add     eax, esi
    mov     [esp+54h+var_44], eax

    loc_4D3E03:                             ; CODE XREF: sub_4D3DA0+33j
    inc     edx
    cmp     edx, 1Ch
    jl      short loc_4D3DBC
    mov     [eax+526FFFh], dl
    xor     esi, esi
    xor     edx, edx

    loc_4D3E13:                             ; CODE XREF: sub_4D3DA0+BCj
    mov     ecx, dword_50BD48[edx*4]
    mov     eax, 1
    shl     eax, cl
    mov     dword_527870[edx*4], esi
    test    eax, eax
    mov     [esp+54h+var_44], eax
    jle     short loc_4D3E58
    mov     ecx, eax
    mov     al, dl
    mov     bl, al
    mov     ebp, ecx
    mov     bh, bl
    lea     edi, dword_527178[esi]
    mov     eax, ebx
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, ebp
    and     ecx, 3
    rep stosb
    mov     eax, ebp
    add     esi, eax

    loc_4D3E58:                             ; CODE XREF: sub_4D3DA0+8Ej
    inc     edx
    cmp     edx, 10h
    jl      short loc_4D3E13
    sar     esi, 7
    cmp     edx, 1Eh
    jge     short loc_4D3EB9

    loc_4D3E66:                             ; CODE XREF: sub_4D3DA0+117j
    mov     ecx, dword_50BD48[edx*4]
    mov     eax, esi
    shl     eax, 7
    mov     dword_527870[edx*4], eax
    sub     ecx, 7
    mov     eax, 1
    shl     eax, cl
    test    eax, eax
    mov     [esp+54h+var_44], eax
    jle     short loc_4D3EB3
    mov     ecx, eax
    mov     al, dl
    mov     bl, al
    mov     ebp, ecx
    mov     bh, bl
    lea     edi, dword_527278[esi]
    mov     eax, ebx
    shl     eax, 10h
    mov     ax, bx
    shr     ecx, 2
    rep stosd
    mov     ecx, ebp
    and     ecx, 3
    rep stosb
    mov     eax, ebp
    add     esi, eax

    loc_4D3EB3:                             ; CODE XREF: sub_4D3DA0+E9j
    inc     edx
    cmp     edx, 1Eh
    jl      short loc_4D3E66

    loc_4D3EB9:                             ; CODE XREF: sub_4D3DA0+C4j
    mov     ecx, 8
    xor     eax, eax
    lea     edi, [esp+54h+var_40]
    rep stosd
    mov     dx, [esp+54h+var_30]
    mov     eax, offset dword_52737A

    loc_4D3ED0:                             ; CODE XREF: sub_4D3DA0+13Fj
    mov     word ptr [eax], 8
    add     eax, 4
    inc     dx
    cmp     eax, offset dword_5275B6
    jle     short loc_4D3ED0
    mov     cx, [esp+54h+var_2E]
    mov     eax, offset dword_5275BA

    loc_4D3EEB:                             ; CODE XREF: sub_4D3DA0+15Aj
    mov     word ptr [eax], 9
    add     eax, 4
    inc     cx
    cmp     eax, offset byte_527776
    jle     short loc_4D3EEB
    mov     [esp+54h+var_2E], cx
    mov     cx, [esp+54h+var_32]
    mov     eax, (offset dword_527778+2)

    loc_4D3F0B:                             ; CODE XREF: sub_4D3DA0+17Aj
    mov     word ptr [eax], 7
    add     eax, 4
    inc     cx
    cmp     eax, offset dword_5277D6
    jle     short loc_4D3F0B
    mov     [esp+54h+var_32], cx
    mov     eax, offset dword_5277DA

    loc_4D3F26:                             ; CODE XREF: sub_4D3DA0+195j
    mov     word ptr [eax], 8
    add     eax, 4
    inc     dx
    cmp     eax, offset byte_5277F6
    jle     short loc_4D3F26
    xor     ecx, ecx
    mov     [esp+54h+var_30], dx
    xor     eax, eax

    loc_4D3F40:                             ; CODE XREF: sub_4D3DA0+1B7j
    mov     dx, word ptr [esp+eax+54h+var_40]
    add     eax, 2
    add     dx, cx
    shl     edx, 1
    mov     ecx, edx
    cmp     eax, 1Ch
    mov     word ptr [esp+eax+54h+var_20], cx
    jle     short loc_4D3F40
    mov     edi, offset byte_527378

    loc_4D3F5E:                             ; CODE XREF: sub_4D3DA0+1FCj
    xor     edx, edx
    mov     dx, [edi+2]
    test    edx, edx
    jz      short loc_4D3F93
    mov     si, word ptr [esp+edx*2+54h+var_20]
    lea     ecx, [esp+edx*2+54h+var_20]
    mov     eax, esi
    and     eax, 0FFFFh
    inc     esi
    mov     [ecx], si
    xor     ecx, ecx

    loc_4D3F7E:                             ; CODE XREF: sub_4D3DA0+1ECj
    mov     esi, eax
    and     esi, 1
    or      ecx, esi
    shr     eax, 1
    shl     ecx, 1
    dec     edx
    test    edx, edx
    jg      short loc_4D3F7E
    shr     ecx, 1
    mov     [edi], cx

    loc_4D3F93:                             ; CODE XREF: sub_4D3DA0+1C6j
    add     edi, 4
    cmp     edi, offset byte_5277F4
    jle     short loc_4D3F5E
    xor     edi, edi
    mov     edx, offset dword_5277F8
    mov     ebx, 5

    loc_4D3FAA:                             ; CODE XREF: sub_4D3DA0+231j
    mov     [edx+2], bx
    mov     ecx, edi
    xor     eax, eax
    mov     esi, ebx

    loc_4D3FB4:                             ; CODE XREF: sub_4D3DA0+220j
    mov     ebp, ecx
    and     ebp, 1
    or      eax, ebp
    shr     ecx, 1
    shl     eax, 1
    dec     esi
    jnz     short loc_4D3FB4
    shr     eax, 1
    mov     [edx], ax
    add     edx, 4
    inc     edi
    cmp     edx, offset dword_527870
    jl      short loc_4D3FAA
    mov     dword_5278E8, 1

    loc_4D3FDD:                             ; CODE XREF: sub_4D3DA0+Ej
    mov     eax, [esp+54h+arg_0]
    xor     ebx, ebx
    mov     edx, 11Eh
    lea     ecx, [eax+86h]
    lea     esi, [eax+97Ah]
    lea     edi, [eax+0A6Eh]
    mov     [eax+169Fh], ebx
    mov     [eax+0B0Ah], ecx
    mov     dword ptr [eax+0B12h], offset off_50BE28
    mov     [eax+0B16h], esi
    mov     dword ptr [eax+0B1Eh], offset off_50BE40
    mov     [eax+0B22h], edi
    mov     dword ptr [eax+0B2Ah], offset dword_50BE58
    mov     [eax+16ABh], bx
    mov     [eax+16ADh], ebx
    mov     dword ptr [eax+16A7h], 8

    loc_4D4047:                             ; CODE XREF: sub_4D3DA0+2AEj
    mov     [ecx], bx
    add     ecx, 4
    dec     edx
    jnz     short loc_4D4047
    mov     ecx, esi
    mov     edx, 1Eh

    loc_4D4057:                             ; CODE XREF: sub_4D3DA0+2BEj
    mov     [ecx], bx
    add     ecx, 4
    dec     edx
    jnz     short loc_4D4057
    mov     ecx, edi
    mov     edx, 13h

    loc_4D4067:                             ; CODE XREF: sub_4D3DA0+2CEj
    mov     [ecx], bx
    add     ecx, 4
    dec     edx
    jnz     short loc_4D4067
    pop     edi
    pop     esi
    mov     [eax+169Bh], ebx
    mov     [eax+1697h], ebx
    mov     [eax+16A3h], ebx
    mov     [eax+168Fh], ebx
    pop     ebp
    mov     word ptr [eax+486h], 1
    pop     ebx
    add     esp, 44h
    retn    4
    sub_4D3DA0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D40A0 proc near                    ; CODE XREF: sub_4D23C0+298p
                                            ; sub_4D4590+12Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_0]
    mov     edx, [esp+arg_C]
    push    ebx
    push    esi
    mov     ecx, [eax+16ADh]
    push    edi
    cmp     ecx, 0Dh
    jle     short loc_4D410E
    mov     esi, edx
    shl     esi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], si
    mov     esi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+esi], bl
    mov     esi, [eax+10h]
    mov     edi, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     esi
    mov     [eax+10h], esi
    mov     [esi+edi], cl
    mov     ecx, [eax+10h]
    mov     esi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, si
    shr     dx, cl
    add     esi, 0FFFFFFF3h
    mov     [eax+16ADh], esi
    mov     [eax+16ABh], dx
    jmp     short loc_4D4120
    ; ---------------------------------------------------------------------------

    loc_4D410E:                             ; CODE XREF: sub_4D40A0+14j
    shl     edx, cl
    or      [eax+16ABh], dx
    add     ecx, 3
    mov     [eax+16ADh], ecx

    loc_4D4120:                             ; CODE XREF: sub_4D40A0+6Cj
    mov     edx, [eax+169Fh]
    mov     ecx, [esp+0Ch+arg_8]
    add     edx, 0Ah
    mov     esi, [esp+0Ch+arg_4]
    and     edx, 0FFFFFFF8h
    lea     edx, [edx+ecx*8+20h]
    mov     [eax+169Fh], edx
    mov     edx, [eax+16ADh]
    cmp     edx, 8
    jle     short loc_4D416F
    mov     edx, [eax+8]
    mov     edi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [edx+edi], bl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    inc     edi
    xor     edx, edx
    mov     [eax+10h], edi
    mov     dl, [eax+16ACh]
    mov     [edi+ebx], dl
    jmp     short loc_4D4182
    ; ---------------------------------------------------------------------------

    loc_4D416F:                             ; CODE XREF: sub_4D40A0+A7j
    test    edx, edx
    jle     short loc_4D4185
    mov     edx, [eax+8]
    mov     edi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [edx+edi], bl

    loc_4D4182:                             ; CODE XREF: sub_4D40A0+CDj
    inc     dword ptr [eax+10h]

    loc_4D4185:                             ; CODE XREF: sub_4D40A0+D1j
    mov     edx, [eax+8]
    mov     edi, [eax+10h]
    mov     word ptr [eax+16ABh], 0
    mov     dword ptr [eax+16ADh], 0
    mov     dword ptr [eax+16A7h], 8
    mov     [edx+edi], cl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    xor     edx, edx
    inc     edi
    mov     dl, ch
    mov     [eax+10h], edi
    mov     [edi+ebx], dl
    mov     edx, [eax+10h]
    mov     ebx, [eax+8]
    inc     edx
    mov     [eax+10h], edx
    mov     edi, edx
    mov     dl, cl
    not     dl
    mov     [edi+ebx], dl
    mov     edx, [eax+10h]
    inc     edx
    xor     ebx, ebx
    mov     [eax+10h], edx
    mov     edi, edx
    mov     edx, ecx
    not     edx
    mov     bl, dh
    mov     edx, [eax+8]
    mov     [edi+edx], bl
    mov     ebx, [eax+10h]
    inc     ebx
    test    ecx, ecx
    mov     [eax+10h], ebx
    mov     edx, ebx
    jz      short loc_4D420A
    lea     edi, [ecx]

    loc_4D41F5:                             ; CODE XREF: sub_4D40A0+168j
    mov     ecx, [eax+8]
    mov     bl, [esi]
    mov     [edx+ecx], bl
    mov     ecx, [eax+10h]
    inc     ecx
    inc     esi
    dec     edi
    mov     [eax+10h], ecx
    mov     edx, ecx
    jnz     short loc_4D41F5

    loc_4D420A:                             ; CODE XREF: sub_4D40A0+151j
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    sub_4D40A0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D4210 proc near                    ; CODE XREF: sub_4D23C0+28Ap

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     ecx, [eax+16ADh]
    push    edi
    cmp     ecx, 0Dh
    mov     edx, 2
    jle     short loc_4D4283
    shl     edx, cl
    mov     ecx, [eax+10h]
    or      [eax+16ABh], dx
    mov     edx, [eax+8]
    mov     bl, [eax+16ABh]
    mov     [ecx+edx], bl
    mov     ecx, [eax+10h]
    mov     esi, [eax+8]
    xor     edx, edx
    mov     dl, [eax+16ACh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     [esi+ecx], dl
    mov     edx, [eax+16ADh]
    mov     ebp, [eax+10h]
    mov     cx, 10h
    sub     cx, dx
    mov     esi, 2
    shr     si, cl
    inc     ebp
    add     edx, 0FFFFFFF3h
    mov     [eax+10h], ebp
    mov     [eax+16ADh], edx
    mov     [eax+16ABh], si
    jmp     short loc_4D4295
    ; ---------------------------------------------------------------------------

    loc_4D4283:                             ; CODE XREF: sub_4D4210+16j
    shl     edx, cl
    or      [eax+16ABh], dx
    add     ecx, 3
    mov     [eax+16ADh], ecx

    loc_4D4295:                             ; CODE XREF: sub_4D4210+71j
    mov     ecx, [eax+16ADh]
    xor     esi, esi
    mov     si, word ptr dword_527778+2
    mov     edx, 10h
    sub     edx, esi
    cmp     ecx, edx
    mov     edx, dword_527778
    jle     short loc_4D4314
    and     edx, 0FFFFh
    mov     edi, edx
    shl     edi, cl
    mov     ecx, [eax+10h]
    or      [eax+16ABh], di
    mov     edi, [eax+8]
    mov     bl, [eax+16ABh]
    mov     [ecx+edi], bl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     edi
    mov     [eax+10h], edi
    mov     [ebx+edi], cl
    mov     ecx, [eax+10h]
    mov     edi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, di
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [esi+edi-10h]
    mov     [eax+16ADh], edx
    jmp     short loc_4D4325
    ; ---------------------------------------------------------------------------

    loc_4D4314:                             ; CODE XREF: sub_4D4210+A3j
    shl     edx, cl
    or      [eax+16ABh], dx
    add     esi, ecx
    mov     [eax+16ADh], esi

    loc_4D4325:                             ; CODE XREF: sub_4D4210+102j
    mov     esi, [eax+169Fh]
    mov     ecx, [eax+16ADh]
    add     esi, 0Ah
    xor     ebp, ebp
    cmp     ecx, 10h
    mov     [eax+169Fh], esi
    jnz     short loc_4D437D
    mov     ecx, [eax+10h]
    mov     edx, [eax+8]
    mov     bl, [eax+16ABh]
    mov     [ecx+edx], bl
    mov     edx, [eax+10h]
    mov     esi, [eax+8]
    inc     edx
    mov     [eax+10h], edx
    mov     ecx, edx
    xor     edx, edx
    mov     dl, [eax+16ACh]
    mov     [esi+ecx], dl
    mov     ecx, [eax+10h]
    inc     ecx
    mov     [eax+16ABh], bp
    mov     [eax+10h], ecx
    mov     [eax+16ADh], ebp
    jmp     short loc_4D43B6
    ; ---------------------------------------------------------------------------

    loc_4D437D:                             ; CODE XREF: sub_4D4210+12Fj
    cmp     ecx, 8
    jl      short loc_4D43B6
    mov     ecx, [eax+8]
    mov     edx, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edx], bl
    mov     edx, [eax+10h]
    xor     ecx, ecx
    inc     edx
    mov     cl, [eax+16ACh]
    mov     [eax+10h], edx
    mov     [eax+16ABh], cx
    mov     ecx, [eax+16ADh]
    add     ecx, 0FFFFFFF8h
    mov     [eax+16ADh], ecx

    loc_4D43B6:                             ; CODE XREF: sub_4D4210+16Bj
                                            ; sub_4D4210+170j
    mov     ecx, [eax+16ADh]
    mov     edx, [eax+16A7h]
    sub     edx, ecx
    add     edx, 0Bh
    cmp     edx, 9
    jge     loc_4D4577
    cmp     ecx, 0Dh
    mov     edx, 2
    jle     short loc_4D4437
    shl     edx, cl
    mov     ecx, [eax+10h]
    or      [eax+16ABh], dx
    mov     edx, [eax+8]
    mov     bl, [eax+16ABh]
    mov     [ecx+edx], bl
    mov     edx, [eax+10h]
    mov     esi, [eax+8]
    inc     edx
    mov     [eax+10h], edx
    mov     ecx, edx
    xor     edx, edx
    mov     dl, [eax+16ACh]
    mov     [esi+ecx], dl
    mov     ecx, [eax+10h]
    mov     edx, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, dx
    mov     esi, 2
    shr     si, cl
    add     edx, 0FFFFFFF3h
    mov     [eax+16ADh], edx
    mov     [eax+16ABh], si
    jmp     short loc_4D4449
    ; ---------------------------------------------------------------------------

    loc_4D4437:                             ; CODE XREF: sub_4D4210+1C8j
    shl     edx, cl
    or      [eax+16ABh], dx
    add     ecx, 3
    mov     [eax+16ADh], ecx

    loc_4D4449:                             ; CODE XREF: sub_4D4210+225j
    mov     ecx, [eax+16ADh]
    xor     esi, esi
    mov     si, word ptr dword_527778+2
    mov     edx, 10h
    sub     edx, esi
    cmp     ecx, edx
    mov     edx, dword_527778
    jle     short loc_4D44C8
    and     edx, 0FFFFh
    mov     edi, edx
    shl     edi, cl
    mov     ecx, [eax+10h]
    or      [eax+16ABh], di
    mov     edi, [eax+8]
    mov     bl, [eax+16ABh]
    mov     [ecx+edi], bl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     edi
    mov     [eax+10h], edi
    mov     [ebx+edi], cl
    mov     ecx, [eax+10h]
    mov     edi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, di
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [esi+edi-10h]
    mov     [eax+16ADh], edx
    jmp     short loc_4D44D9
    ; ---------------------------------------------------------------------------

    loc_4D44C8:                             ; CODE XREF: sub_4D4210+257j
    shl     edx, cl
    or      [eax+16ABh], dx
    add     esi, ecx
    mov     [eax+16ADh], esi

    loc_4D44D9:                             ; CODE XREF: sub_4D4210+2B6j
    mov     esi, [eax+169Fh]
    mov     ecx, [eax+16ADh]
    add     esi, 0Ah
    cmp     ecx, 10h
    mov     [eax+169Fh], esi
    jnz     short loc_4D453E
    mov     ecx, [eax+10h]
    mov     edx, [eax+8]
    mov     bl, [eax+16ABh]
    mov     [ecx+edx], bl
    mov     edx, [eax+10h]
    mov     esi, [eax+8]
    inc     edx
    mov     [eax+10h], edx
    mov     ecx, edx
    xor     edx, edx
    mov     dl, [eax+16ACh]
    mov     [esi+ecx], dl
    mov     ecx, [eax+10h]
    inc     ecx
    mov     [eax+16ABh], bp
    mov     [eax+10h], ecx
    mov     [eax+16ADh], ebp
    mov     dword ptr [eax+16A7h], 7
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D453E:                             ; CODE XREF: sub_4D4210+2E1j
    cmp     ecx, 8
    jl      short loc_4D4577
    mov     ecx, [eax+8]
    mov     edx, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edx], bl
    mov     edx, [eax+10h]
    xor     ecx, ecx
    inc     edx
    mov     cl, [eax+16ACh]
    mov     [eax+10h], edx
    mov     [eax+16ABh], cx
    mov     ecx, [eax+16ADh]
    add     ecx, 0FFFFFFF8h
    mov     [eax+16ADh], ecx

    loc_4D4577:                             ; CODE XREF: sub_4D4210+1BAj
                                            ; sub_4D4210+331j
    pop     edi
    pop     esi
    pop     ebp
    mov     dword ptr [eax+16A7h], 7
    pop     ebx
    retn    4
    sub_4D4210 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D4590 proc near                    ; CODE XREF: sub_4D28F0+80p
                                            ; sub_4D28F0+12Bp ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h
    arg_C= dword ptr  18h

    push    ebx
    push    ebp
    mov     ebx, [esp+arg_8]
    push    esi
    mov     esi, [esp+4+arg_0]
    xor     ebp, ebp
    push    edi
    mov     eax, [esi+76h]
    test    eax, eax
    jle     loc_4D46A1
    cmp     byte ptr [esi+18h], 2
    jnz     short loc_4D4606
    xor     edi, edi
    xor     ecx, ecx
    lea     eax, [esi+86h]
    mov     edx, 7

    loc_4D45BE:                             ; CODE XREF: sub_4D4590+39j
    xor     ebp, ebp
    mov     bp, [eax]
    add     eax, 4
    add     ecx, ebp
    dec     edx
    jnz     short loc_4D45BE
    lea     eax, [esi+0A2h]
    mov     edx, 79h

    loc_4D45D6:                             ; CODE XREF: sub_4D4590+51j
    xor     ebp, ebp
    mov     bp, [eax]
    add     eax, 4
    add     edi, ebp
    dec     edx
    jnz     short loc_4D45D6
    lea     eax, [esi+286h]
    mov     edx, 80h

    loc_4D45EE:                             ; CODE XREF: sub_4D4590+69j
    xor     ebp, ebp
    mov     bp, [eax]
    add     eax, 4
    add     ecx, ebp
    dec     edx
    jnz     short loc_4D45EE
    shr     edi, 2
    cmp     edi, ecx
    sbb     eax, eax
    inc     eax
    mov     [esi+18h], al

    loc_4D4606:                             ; CODE XREF: sub_4D4590+1Dj
    lea     ecx, [esi+0B0Ah]
    push    ecx
    push    esi
    call    sub_4D4B10
    lea     edx, [esi+0B16h]
    push    edx
    push    esi
    call    sub_4D4B10
    mov     eax, [esi+0B0Eh]
    lea     ecx, [esi+86h]
    push    eax
    push    ecx
    push    esi
    call    sub_4D5070
    mov     edx, [esi+0B1Ah]
    lea     eax, [esi+97Ah]
    push    edx
    push    eax
    push    esi
    call    sub_4D5070
    lea     ecx, [esi+0B22h]
    push    ecx
    push    esi
    call    sub_4D4B10
    mov     eax, 12h

    loc_4D465A:                             ; CODE XREF: sub_4D4590+E1j
    xor     edx, edx
    mov     dl, byte_50BE10[eax]
    cmp     word ptr [esi+edx*4+0A70h], 0
    jnz     short loc_4D4673
    dec     eax
    cmp     eax, 3
    jge     short loc_4D465A

    loc_4D4673:                             ; CODE XREF: sub_4D4590+DBj
    mov     edx, [esi+1697h]
    lea     ecx, [eax+eax*2+11h]
    add     edx, ecx
    mov     ebp, eax
    mov     ecx, edx
    mov     [esi+1697h], edx
    lea     edx, [ecx+0Ah]
    mov     ecx, [esi+169Bh]
    add     ecx, 0Ah
    shr     edx, 3
    shr     ecx, 3
    cmp     ecx, edx
    ja      short loc_4D46A6
    jmp     short loc_4D46A4
    ; ---------------------------------------------------------------------------

    loc_4D46A1:                             ; CODE XREF: sub_4D4590+13j
    lea     ecx, [ebx+5]

    loc_4D46A4:                             ; CODE XREF: sub_4D4590+10Fj
    mov     edx, ecx

    loc_4D46A6:                             ; CODE XREF: sub_4D4590+10Dj
    lea     eax, [ebx+4]
    cmp     eax, edx
    ja      short loc_4D46C7
    mov     eax, [esp+8+arg_4]
    test    eax, eax
    jz      short loc_4D46C7
    mov     ecx, [esp+8+arg_C]
    push    ecx
    push    ebx
    push    eax
    push    esi
    call    sub_4D40A0
    jmp     loc_4D4A80
    ; ---------------------------------------------------------------------------

    loc_4D46C7:                             ; CODE XREF: sub_4D4590+11Bj
                                            ; sub_4D4590+123j
    cmp     ecx, edx
    mov     ecx, [esi+16ADh]
    jnz     loc_4D477E
    cmp     ecx, 0Dh
    jle     short loc_4D4739
    mov     edx, [esp+8+arg_C]
    lea     eax, [edx+2]
    mov     edx, eax
    shl     edx, cl
    mov     ecx, [esi+8]
    or      [esi+16ABh], dx
    mov     edx, [esi+10h]
    mov     bl, [esi+16ABh]
    mov     [ecx+edx], bl
    mov     ecx, [esi+10h]
    mov     edi, [esi+8]
    xor     edx, edx
    mov     dl, [esi+16ACh]
    inc     ecx
    mov     [esi+10h], ecx
    mov     [ecx+edi], dl
    mov     edx, [esi+16ADh]
    mov     ebp, [esi+10h]
    mov     cx, 10h
    sub     cx, dx
    inc     ebp
    shr     ax, cl
    add     edx, 0FFFFFFF3h
    mov     [esi+10h], ebp
    mov     [esi+16ADh], edx
    mov     [esi+16ABh], ax
    jmp     short loc_4D4752
    ; ---------------------------------------------------------------------------

    loc_4D4739:                             ; CODE XREF: sub_4D4590+148j
    mov     eax, [esp+8+arg_C]
    add     eax, 2
    shl     eax, cl

    loc_4D4742:                             ; DATA XREF: .data:005031D4o
    or      [esi+16ABh], ax
    add     ecx, 3
    mov     [esi+16ADh], ecx

    loc_4D4752:                             ; CODE XREF: sub_4D4590+1A7j
    push    offset dword_5277F8
    push    offset byte_527378
    push    esi
    call    sub_4D5810
    mov     ecx, [esi+169Bh]
    mov     eax, [esi+169Fh]
    add     ecx, 3
    add     eax, ecx
    mov     [esi+169Fh], eax
    jmp     loc_4D4A80
    ; ---------------------------------------------------------------------------

    loc_4D477E:                             ; CODE XREF: sub_4D4590+13Fj
    mov     edx, [esp+8+arg_C]
    cmp     ecx, 0Dh
    jle     short loc_4D47E2
    add     edx, 4
    mov     eax, edx
    shl     eax, cl
    mov     ecx, [esi+8]
    or      [esi+16ABh], ax
    mov     eax, [esi+10h]
    mov     bl, [esi+16ABh]
    mov     [ecx+eax], bl
    mov     ecx, [esi+10h]
    mov     edi, [esi+8]
    xor     eax, eax
    mov     al, [esi+16ACh]
    inc     ecx
    mov     [esi+10h], ecx
    mov     [ecx+edi], al
    mov     edi, [esi+16ADh]
    mov     eax, [esi+10h]
    mov     cx, 10h
    sub     cx, di
    inc     eax
    shr     dx, cl
    add     edi, 0FFFFFFF3h
    mov     [esi+10h], eax
    mov     [esi+16ADh], edi
    mov     [esi+16ABh], dx
    jmp     short loc_4D47F7
    ; ---------------------------------------------------------------------------

    loc_4D47E2:                             ; CODE XREF: sub_4D4590+1F5j
    add     edx, 4
    shl     edx, cl
    or      [esi+16ABh], dx
    add     ecx, 3
    mov     [esi+16ADh], ecx

    loc_4D47F7:                             ; CODE XREF: sub_4D4590+250j
    mov     ebx, [esi+0B0Eh]
    mov     ecx, [esi+16ADh]
    inc     ebp
    mov     [esp+8+arg_0], ebp
    mov     ebp, [esi+0B1Ah]
    inc     ebp
    inc     ebx
    cmp     ecx, 0Bh
    mov     [esp+8+arg_8], ebx
    lea     eax, [ebx-101h]
    jle     short loc_4D4879
    mov     edx, eax
    mov     edi, [esi+8]
    shl     edx, cl
    or      [esi+16ABh], dx
    mov     edx, [esi+10h]
    mov     cl, [esi+16ABh]
    mov     [edi+edx], cl
    mov     edx, [esi+10h]
    mov     edi, [esi+8]
    inc     edx
    mov     [esi+10h], edx
    mov     ecx, edx
    xor     edx, edx
    mov     dl, [esi+16ACh]
    mov     [ecx+edi], dl
    mov     ecx, [esi+10h]
    mov     edx, [esi+16ADh]
    inc     ecx
    mov     [esi+10h], ecx
    mov     cx, 10h
    sub     cx, dx
    shr     ax, cl
    add     edx, 0FFFFFFF5h
    mov     [esi+16ADh], edx
    mov     [esi+16ABh], ax
    jmp     short loc_4D488B
    ; ---------------------------------------------------------------------------

    loc_4D4879:                             ; CODE XREF: sub_4D4590+28Dj
    shl     eax, cl
    or      [esi+16ABh], ax
    add     ecx, 5
    mov     [esi+16ADh], ecx

    loc_4D488B:                             ; CODE XREF: sub_4D4590+2E7j
    mov     ecx, [esi+16ADh]
    lea     eax, [ebp-1]
    cmp     ecx, 0Bh
    jle     short loc_4D48F3
    mov     edx, eax
    mov     edi, [esi+8]
    shl     edx, cl
    or      [esi+16ABh], dx
    mov     edx, [esi+10h]
    mov     cl, [esi+16ABh]
    mov     [edi+edx], cl
    mov     edx, [esi+10h]
    mov     edi, [esi+8]
    inc     edx
    mov     [esi+10h], edx
    mov     ecx, edx
    xor     edx, edx
    mov     dl, [esi+16ACh]
    mov     [ecx+edi], dl
    mov     ecx, [esi+10h]
    mov     edx, [esi+16ADh]
    inc     ecx
    mov     [esi+10h], ecx
    mov     cx, 10h
    sub     cx, dx
    shr     ax, cl
    add     edx, 0FFFFFFF5h
    mov     [esi+16ADh], edx
    mov     [esi+16ABh], ax
    jmp     short loc_4D4905
    ; ---------------------------------------------------------------------------

    loc_4D48F3:                             ; CODE XREF: sub_4D4590+307j
    shl     eax, cl
    or      [esi+16ABh], ax
    add     ecx, 5
    mov     [esi+16ADh], ecx

    loc_4D4905:                             ; CODE XREF: sub_4D4590+361j
    mov     ecx, [esi+16ADh]
    cmp     ecx, 0Ch
    jle     short loc_4D4971
    mov     edx, [esp+8+arg_0]
    mov     edi, [esi+8]
    lea     eax, [edx-4]
    mov     edx, eax
    shl     edx, cl
    or      [esi+16ABh], dx
    mov     edx, [esi+10h]
    mov     cl, [esi+16ABh]
    mov     [edi+edx], cl
    mov     edx, [esi+10h]
    mov     edi, [esi+8]
    inc     edx
    mov     [esi+10h], edx
    mov     ecx, edx
    xor     edx, edx
    mov     dl, [esi+16ACh]
    mov     [ecx+edi], dl
    mov     ecx, [esi+10h]
    mov     edx, [esi+16ADh]
    inc     ecx
    mov     [esi+10h], ecx
    mov     cx, 10h
    sub     cx, dx
    shr     ax, cl
    add     edx, 0FFFFFFF4h
    mov     [esi+16ADh], edx
    mov     [esi+16ABh], ax
    jmp     short loc_4D498A
    ; ---------------------------------------------------------------------------

    loc_4D4971:                             ; CODE XREF: sub_4D4590+37Ej
    mov     eax, [esp+8+arg_0]
    add     eax, 0FFFFFFFCh
    shl     eax, cl
    or      [esi+16ABh], ax
    add     ecx, 4
    mov     [esi+16ADh], ecx

    loc_4D498A:                             ; CODE XREF: sub_4D4590+3DFj
    mov     eax, [esp+8+arg_0]
    xor     edi, edi
    test    eax, eax
    jle     loc_4D4A43

    loc_4D4998:                             ; CODE XREF: sub_4D4590+4ADj
    mov     ecx, [esi+16ADh]
    cmp     ecx, 0Dh
    jle     short loc_4D4A13
    xor     edx, edx
    xor     eax, eax
    mov     dl, byte_50BE10[edi]
    mov     ax, [esi+edx*4+0A70h]
    mov     edx, eax
    shl     edx, cl
    mov     ecx, [esi+8]
    or      [esi+16ABh], dx
    mov     edx, [esi+10h]
    mov     bl, [esi+16ABh]
    mov     [ecx+edx], bl
    mov     edx, [esi+10h]
    mov     ebx, [esi+8]
    inc     edx
    mov     [esi+10h], edx
    mov     ecx, edx
    xor     edx, edx
    mov     dl, [esi+16ACh]
    mov     [ecx+ebx], dl
    mov     ecx, [esi+10h]
    mov     edx, [esi+16ADh]
    inc     ecx
    mov     [esi+10h], ecx
    mov     cx, 10h
    mov     ebx, [esp+8+arg_8]
    sub     cx, dx
    shr     ax, cl
    add     edx, 0FFFFFFF3h
    mov     [esi+16ADh], edx
    mov     [esi+16ABh], ax
    jmp     short loc_4D4A36
    ; ---------------------------------------------------------------------------

    loc_4D4A13:                             ; CODE XREF: sub_4D4590+411j
    xor     eax, eax
    mov     al, byte_50BE10[edi]
    mov     dx, [esi+eax*4+0A70h]
    shl     dx, cl
    or      [esi+16ABh], dx
    add     ecx, 3
    mov     [esi+16ADh], ecx

    loc_4D4A36:                             ; CODE XREF: sub_4D4590+481j
    mov     eax, [esp+8+arg_0]
    inc     edi
    cmp     edi, eax
    jl      loc_4D4998

    loc_4D4A43:                             ; CODE XREF: sub_4D4590+402j
    dec     ebx
    lea     edi, [esi+86h]
    push    ebx
    push    edi
    push    esi
    call    sub_4D5160
    dec     ebp
    lea     ebx, [esi+97Ah]
    push    ebp
    push    ebx
    push    esi
    call    sub_4D5160
    push    ebx
    push    edi
    push    esi
    call    sub_4D5810
    mov     eax, [esi+1697h]
    mov     ecx, [esi+169Fh]
    add     eax, 3
    add     ecx, eax
    mov     [esi+169Fh], ecx

    loc_4D4A80:                             ; CODE XREF: sub_4D4590+132j
                                            ; sub_4D4590+1E9j
    lea     eax, [esi+86h]
    mov     ecx, 11Eh

    loc_4D4A8B:                             ; CODE XREF: sub_4D4590+504j
    mov     word ptr [eax], 0
    add     eax, 4
    dec     ecx
    jnz     short loc_4D4A8B
    lea     eax, [esi+97Ah]
    mov     ecx, 1Eh

    loc_4D4AA1:                             ; CODE XREF: sub_4D4590+51Aj
    mov     word ptr [eax], 0
    add     eax, 4
    dec     ecx
    jnz     short loc_4D4AA1
    lea     eax, [esi+0A6Eh]
    mov     ecx, 13h

    loc_4D4AB7:                             ; CODE XREF: sub_4D4590+530j
    mov     word ptr [eax], 0
    add     eax, 4
    dec     ecx
    jnz     short loc_4D4AB7
    mov     ecx, [esp+8+arg_C]
    xor     eax, eax
    cmp     ecx, eax
    mov     word ptr [esi+486h], 1
    mov     [esi+169Bh], eax
    mov     [esi+1697h], eax
    mov     [esi+16A3h], eax
    mov     [esi+168Fh], eax
    jz      short loc_4D4AFA
    push    esi
    call    sub_4D5C60
    add     dword ptr [esi+169Fh], 7

    loc_4D4AFA:                             ; CODE XREF: sub_4D4590+55Bj
    mov     eax, [esi+169Fh]
    pop     edi
    pop     esi
    pop     ebp
    shr     eax, 3
    pop     ebx
    retn    10h
    sub_4D4590 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D4B10 proc near                    ; CODE XREF: sub_4D4590+7Ep
                                            ; sub_4D4590+8Bp ...

    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 48h
    mov     eax, [esp+48h+arg_4]
    push    ebx
    push    ebp
    push    esi
    mov     ebx, [eax]
    mov     eax, [eax+8]
    mov     esi, [esp+54h+arg_0]
    push    edi
    mov     edi, [eax]
    mov     ecx, [eax+0Ch]
    xor     eax, eax
    or      ebp, 0FFFFFFFFh
    cmp     ecx, eax
    mov     [esp+58h+var_44], ebx
    mov     [esp+58h+var_40], ecx
    mov     [esp+58h+var_48], ebp
    mov     [esi+1442h], eax
    mov     dword ptr [esi+1446h], 23Dh
    jle     short loc_4D4B8C
    mov     edx, ebx

    loc_4D4B50:                             ; CODE XREF: sub_4D4B10+7Aj
    cmp     word ptr [edx], 0
    jz      short loc_4D4B7A
    mov     ecx, [esi+1442h]
    mov     [esp+58h+var_48], eax
    inc     ecx
    mov     ebp, eax
    mov     [esi+1442h], ecx
    mov     [esi+ecx*4+0B4Eh], eax
    mov     byte ptr [eax+esi+144Ah], 0
    jmp     short loc_4D4B80
    ; ---------------------------------------------------------------------------

    loc_4D4B7A:                             ; CODE XREF: sub_4D4B10+44j
    mov     word ptr [edx+2], 0

    loc_4D4B80:                             ; CODE XREF: sub_4D4B10+68j
    mov     ecx, [esp+58h+var_40]
    inc     eax
    add     edx, 4
    cmp     eax, ecx
    jl      short loc_4D4B50

    loc_4D4B8C:                             ; CODE XREF: sub_4D4B10+3Cj
    mov     ecx, [esi+1442h]
    cmp     ecx, 2
    jge     short loc_4D4BFB

    loc_4D4B97:                             ; CODE XREF: sub_4D4B10+E5j
    cmp     ebp, 2
    jge     short loc_4D4BA1
    inc     ebp
    mov     eax, ebp
    jmp     short loc_4D4BA3
    ; ---------------------------------------------------------------------------

    loc_4D4BA1:                             ; CODE XREF: sub_4D4B10+8Aj
    xor     eax, eax

    loc_4D4BA3:                             ; CODE XREF: sub_4D4B10+8Fj
    inc     ecx
    mov     [esi+1442h], ecx
    mov     [esi+ecx*4+0B4Eh], eax
    lea     ecx, ds:0[eax*4]
    mov     word ptr [ebx+ecx], 1
    mov     byte ptr [eax+esi+144Ah], 0
    mov     edx, [esi+1697h]
    dec     edx
    test    edi, edi
    mov     [esi+1697h], edx
    jz      short loc_4D4BEC
    xor     eax, eax
    mov     ax, [edi+ecx+2]
    mov     ecx, [esi+169Bh]
    sub     ecx, eax
    mov     [esi+169Bh], ecx

    loc_4D4BEC:                             ; CODE XREF: sub_4D4B10+C5j
    mov     ecx, [esi+1442h]
    cmp     ecx, 2
    jl      short loc_4D4B97
    mov     [esp+58h+var_48], ebp

    loc_4D4BFB:                             ; CODE XREF: sub_4D4B10+85j
    mov     ecx, [esp+58h+arg_4]
    mov     [ecx+4], ebp
    mov     eax, [esi+1442h]
    cdq
    sub     eax, edx
    mov     edi, eax
    sar     edi, 1
    cmp     edi, 1
    jl      short loc_4D4C22

    loc_4D4C14:                             ; CODE XREF: sub_4D4B10+110j
    push    edi
    push    ebx
    push    esi
    call    sub_4D4FB0
    dec     edi
    cmp     edi, 1
    jge     short loc_4D4C14

    loc_4D4C22:                             ; CODE XREF: sub_4D4B10+102j
    mov     ebp, [esp+58h+var_40]
    lea     ebx, [ebx+ebp*4]

    loc_4D4C29:                             ; CODE XREF: sub_4D4B10+1D8j
    mov     eax, [esi+1442h]
    mov     edi, [esi+0B52h]
    push    1
    mov     edx, [esi+eax*4+0B4Eh]
    dec     eax
    mov     [esi+1442h], eax
    mov     eax, [esp+5Ch+var_44]
    push    eax
    push    esi
    mov     [esi+0B52h], edx
    call    sub_4D4FB0
    mov     edx, [esi+1446h]
    mov     eax, [esi+0B52h]
    dec     edx
    mov     ecx, edx
    mov     [esi+1446h], edx
    mov     [esi+ecx*4+0B4Eh], edi
    mov     ecx, [esi+1446h]
    dec     ecx
    mov     [esi+1446h], ecx
    mov     [esi+ecx*4+0B4Eh], eax
    mov     ecx, [esp+58h+var_44]
    mov     dx, [ecx+eax*4]
    add     dx, [ecx+edi*4]
    mov     [ebx], dx
    mov     cl, [edi+esi+144Ah]
    mov     dl, [eax+esi+144Ah]
    cmp     cl, dl
    jb      short loc_4D4CAF
    and     ecx, 0FFh
    jmp     short loc_4D4CB7
    ; ---------------------------------------------------------------------------

    loc_4D4CAF:                             ; CODE XREF: sub_4D4B10+195j
    and     edx, 0FFh
    mov     ecx, edx

    loc_4D4CB7:                             ; CODE XREF: sub_4D4B10+19Dj
    inc     cl
    push    1
    mov     [ebp+esi+144Ah], cl
    mov     ecx, [esp+5Ch+var_44]
    push    ecx
    push    esi
    mov     [ecx+eax*4+2], bp
    mov     [ecx+edi*4+2], bp
    mov     [esi+0B52h], ebp
    inc     ebp
    add     ebx, 4
    call    sub_4D4FB0
    cmp     dword ptr [esi+1442h], 2
    jge     loc_4D4C29
    mov     edx, [esi+1446h]
    mov     ecx, [esi+0B52h]
    dec     edx
    lea     edi, [esi+0B2Eh]
    mov     eax, edx
    mov     [esi+1446h], edx
    mov     [esp+58h+var_24], edi
    xor     ebp, ebp
    mov     [esi+eax*4+0B4Eh], ecx
    mov     eax, [esp+58h+arg_4]
    mov     [esp+58h+var_40], ebp
    mov     ebx, [eax]
    mov     edx, [eax+4]
    mov     eax, [eax+8]
    mov     [esp+58h+var_34], edx
    mov     ecx, [eax]
    mov     edx, [eax+4]
    mov     [esp+58h+var_28], ecx
    mov     ecx, [eax+8]
    mov     [esp+58h+var_2C], edx
    mov     edx, [eax+10h]
    mov     [esp+58h+var_30], ecx
    mov     ecx, 8
    xor     eax, eax
    mov     [esp+58h+var_3C], edx
    rep stosd
    mov     eax, [esi+1446h]
    mov     ecx, [esi+eax*4+0B4Eh]
    mov     [ebx+ecx*4+2], bp
    mov     ebp, [esi+1446h]
    inc     ebp
    cmp     ebp, 23Dh
    mov     [esp+58h+arg_4], ebp
    jge     loc_4D4E49
    lea     eax, [esi+ebp*4+0B4Eh]
    mov     [esp+58h+arg_0], eax
    mov     eax, 23Dh
    sub     eax, ebp
    add     ebp, eax
    mov     [esp+58h+var_38], eax
    mov     [esp+58h+arg_4], ebp

    loc_4D4D93:                             ; CODE XREF: sub_4D4B10+32Fj
    mov     ecx, [esp+58h+arg_0]
    xor     eax, eax
    xor     ebp, ebp
    mov     ecx, [ecx]
    mov     ax, [ebx+ecx*4+2]
    lea     edi, ds:0[ecx*4]
    mov     bp, [ebx+eax*4+2]
    mov     eax, ebp
    inc     eax
    cmp     eax, edx
    jle     short loc_4D4DC0
    mov     ebp, [esp+58h+var_40]
    mov     eax, edx
    inc     ebp
    mov     [esp+58h+var_40], ebp

    loc_4D4DC0:                             ; CODE XREF: sub_4D4B10+2A3j
    mov     ebp, [esp+58h+var_34]
    mov     [ebx+edi+2], ax
    cmp     ecx, ebp
    jg      short loc_4D4E2B
    mov     ebp, [esp+58h+var_30]
    inc     word ptr [esi+eax*2+0B2Eh]
    xor     edx, edx
    cmp     ecx, ebp
    jl      short loc_4D4DE8
    mov     edx, [esp+58h+var_2C]
    sub     ecx, ebp
    mov     edx, [edx+ecx*4]

    loc_4D4DE8:                             ; CODE XREF: sub_4D4B10+2CDj
    mov     cx, [ebx+edi]
    add     eax, edx
    and     ecx, 0FFFFh
    mov     ebp, [esi+1697h]
    imul    eax, ecx
    add     ebp, eax
    mov     eax, [esp+58h+var_28]
    test    eax, eax
    mov     [esi+1697h], ebp
    jz      short loc_4D4E27
    xor     ebp, ebp
    mov     bp, [eax+edi+2]
    mov     eax, [esi+169Bh]
    add     ebp, edx
    imul    ebp, ecx
    add     eax, ebp
    mov     [esi+169Bh], eax

    loc_4D4E27:                             ; CODE XREF: sub_4D4B10+2FBj
    mov     edx, [esp+58h+var_3C]

    loc_4D4E2B:                             ; CODE XREF: sub_4D4B10+2BBj
    mov     ecx, [esp+58h+arg_0]
    mov     eax, [esp+58h+var_38]
    add     ecx, 4
    dec     eax
    mov     [esp+58h+arg_0], ecx
    mov     [esp+58h+var_38], eax
    jnz     loc_4D4D93
    mov     ebp, [esp+58h+arg_4]

    loc_4D4E49:                             ; CODE XREF: sub_4D4B10+261j
    mov     edi, [esp+58h+var_40]
    test    edi, edi
    jz      loc_4D4F28

    loc_4D4E55:                             ; CODE XREF: sub_4D4B10+382j
    lea     eax, [edx-1]
    cmp     word ptr [esi+eax*2+0B2Eh], 0
    lea     ecx, [esi+eax*2+0B2Eh]
    jnz     short loc_4D4E74

    loc_4D4E6A:                             ; CODE XREF: sub_4D4B10+362j
    sub     ecx, 2
    dec     eax
    cmp     word ptr [ecx], 0
    jz      short loc_4D4E6A

    loc_4D4E74:                             ; CODE XREF: sub_4D4B10+358j
    dec     word ptr [esi+eax*2+0B2Eh]
    add     word ptr [esi+eax*2+0B30h], 2
    dec     word ptr [esi+edx*2+0B2Eh]
    sub     edi, 2
    test    edi, edi
    jg      short loc_4D4E55
    test    edx, edx
    mov     edi, edx
    jz      loc_4D4F28
    lea     edx, [esi+edx*2+0B2Eh]
    mov     [esp+58h+var_38], edx

    loc_4D4EA9:                             ; CODE XREF: sub_4D4B10+416j
    xor     eax, eax
    mov     ax, [edx]
    test    eax, eax
    mov     [esp+58h+arg_0], eax
    jz      short loc_4D4F18
    lea     ebp, [esi+ebp*4+0B4Eh]

    loc_4D4EBD:                             ; CODE XREF: sub_4D4B10+402j
    mov     edx, [esp+58h+arg_4]
    mov     ecx, [ebp-4]
    dec     edx
    sub     ebp, 4
    mov     [esp+58h+arg_4], edx
    mov     edx, [esp+58h+var_34]
    cmp     ecx, edx
    mov     [esp+58h+var_28], ebp
    jg      short loc_4D4F10
    lea     edx, [ebx+ecx*4+2]
    xor     eax, eax
    mov     ax, [edx]
    cmp     eax, edi
    jz      short loc_4D4F07
    mov     ebp, edi
    sub     ebp, eax
    xor     eax, eax
    mov     ax, [ebx+ecx*4]
    imul    ebp, eax
    mov     eax, [esi+1697h]
    add     eax, ebp
    mov     ebp, [esp+58h+var_28]
    mov     [esi+1697h], eax
    mov     [edx], di

    loc_4D4F07:                             ; CODE XREF: sub_4D4B10+3D3j
    mov     eax, [esp+58h+arg_0]
    dec     eax
    mov     [esp+58h+arg_0], eax

    loc_4D4F10:                             ; CODE XREF: sub_4D4B10+3C6j
    test    eax, eax
    jnz     short loc_4D4EBD
    mov     ebp, [esp+58h+arg_4]

    loc_4D4F18:                             ; CODE XREF: sub_4D4B10+3A4j
    mov     edx, [esp+58h+var_38]
    dec     edi
    sub     edx, 2
    test    edi, edi
    mov     [esp+58h+var_38], edx
    jnz     short loc_4D4EA9

    loc_4D4F28:                             ; CODE XREF: sub_4D4B10+33Fj
                                            ; sub_4D4B10+388j
    mov     ecx, [esp+58h+var_24]
    xor     eax, eax
    lea     edx, [esp+58h+var_20+2]
    mov     esi, 0Fh

    loc_4D4F37:                             ; CODE XREF: sub_4D4B10+43Cj
    mov     di, [ecx]
    add     ecx, 2
    add     di, ax
    add     edx, 2
    shl     edi, 1
    mov     eax, edi
    dec     esi
    mov     [edx-2], ax
    jnz     short loc_4D4F37
    mov     eax, [esp+58h+var_48]
    test    eax, eax
    jl      short loc_4D4F98
    mov     edi, [esp+58h+var_44]
    lea     ebx, [eax+1]

    loc_4D4F5D:                             ; CODE XREF: sub_4D4B10+486j
    xor     edx, edx
    mov     dx, [edi+2]
    test    edx, edx
    jz      short loc_4D4F92
    mov     si, word ptr [esp+edx*2+58h+var_20]
    lea     ecx, [esp+edx*2+58h+var_20]
    mov     eax, esi
    and     eax, 0FFFFh
    inc     esi
    mov     [ecx], si
    xor     ecx, ecx

    loc_4D4F7D:                             ; CODE XREF: sub_4D4B10+47Bj
    mov     esi, eax
    and     esi, 1
    or      ecx, esi
    shr     eax, 1
    shl     ecx, 1
    dec     edx
    test    edx, edx
    jg      short loc_4D4F7D
    shr     ecx, 1
    mov     [edi], cx

    loc_4D4F92:                             ; CODE XREF: sub_4D4B10+455j
    add     edi, 4
    dec     ebx
    jnz     short loc_4D4F5D

    loc_4D4F98:                             ; CODE XREF: sub_4D4B10+444j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 48h
    retn    8
    sub_4D4B10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D4FB0 proc near                    ; CODE XREF: sub_4D4B10+107p
                                            ; sub_4D4B10+141p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_8]
    push    ebx
    push    ebp
    mov     ebp, [eax+ecx*4+0B4Eh]
    mov     edx, [eax+1442h]
    add     ecx, ecx
    push    esi
    cmp     ecx, edx
    push    edi
    mov     [esp+10h+arg_0], ebp
    jg      short loc_4D5052
    mov     edi, [esp+10h+arg_4]
    cmp     ecx, edx

    loc_4D4FD9:                             ; CODE XREF: sub_4D4FB0+A0j
    jge     short loc_4D500F
    mov     esi, [eax+ecx*4+0B4Eh]
    mov     ebp, [eax+ecx*4+0B52h]
    mov     dx, [edi+ebp*4]
    mov     bx, [edi+esi*4]
    cmp     dx, bx
    jb      short loc_4D500A
    jnz     short loc_4D500B
    mov     dl, [eax+ebp+144Ah]
    mov     bl, [eax+esi+144Ah]
    cmp     dl, bl
    ja      short loc_4D500B

    loc_4D500A:                             ; CODE XREF: sub_4D4FB0+44j
    inc     ecx

    loc_4D500B:                             ; CODE XREF: sub_4D4FB0+46j
                                            ; sub_4D4FB0+58j
    mov     ebp, [esp+10h+arg_0]

    loc_4D500F:                             ; CODE XREF: sub_4D4FB0+29j
    mov     esi, [eax+ecx*4+0B4Eh]
    mov     dx, [edi+ebp*4]
    mov     bx, [edi+esi*4]
    cmp     dx, bx
    jb      short loc_4D5052
    jnz     short loc_4D5037
    mov     dl, [ebp+eax+144Ah]
    mov     bl, [eax+esi+144Ah]
    cmp     dl, bl
    jbe     short loc_4D5052

    loc_4D5037:                             ; CODE XREF: sub_4D4FB0+73j
    mov     edx, [esp+10h+arg_8]
    mov     [esp+10h+arg_8], ecx
    shl     ecx, 1
    mov     [eax+edx*4+0B4Eh], esi
    mov     edx, [eax+1442h]
    cmp     ecx, edx
    jle     short loc_4D4FD9

    loc_4D5052:                             ; CODE XREF: sub_4D4FB0+21j
                                            ; sub_4D4FB0+71j ...
    mov     ecx, [esp+10h+arg_8]
    pop     edi
    pop     esi
    mov     [eax+ecx*4+0B4Eh], ebp
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_4D4FB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D5070 proc near                    ; CODE XREF: sub_4D4590+9Fp
                                            ; sub_4D4590+B3p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    mov     eax, [esp+4+arg_4]
    push    ebx
    xor     edx, edx
    push    ebp
    mov     dx, [eax+2]
    push    esi
    xor     esi, esi
    push    edi
    test    edx, edx
    mov     [esp+14h+var_4], 0FFFFFFFFh
    mov     ecx, 7
    mov     edi, 4
    jnz     short loc_4D50A1
    mov     ecx, 8Ah
    mov     edi, 3

    loc_4D50A1:                             ; CODE XREF: sub_4D5070+25j
    mov     ebx, [esp+14h+arg_8]
    test    ebx, ebx
    mov     word ptr [eax+ebx*4+6], 0FFFFh
    jl      loc_4D5151
    inc     ebx
    lea     ebp, [eax+6]
    mov     [esp+14h+arg_4], ebx
    mov     ebx, [esp+14h+arg_0]

    loc_4D50C0:                             ; CODE XREF: sub_4D5070+DBj
    mov     eax, edx
    xor     edx, edx
    mov     dx, [ebp+0]
    inc     esi
    cmp     esi, ecx
    jge     short loc_4D50D1
    cmp     eax, edx
    jz      short loc_4D513F

    loc_4D50D1:                             ; CODE XREF: sub_4D5070+5Bj
    cmp     esi, edi
    jge     short loc_4D50DF
    add     [ebx+eax*4+0A6Eh], si
    jmp     short loc_4D510F
    ; ---------------------------------------------------------------------------

    loc_4D50DF:                             ; CODE XREF: sub_4D5070+63j
    test    eax, eax
    jz      short loc_4D50FA
    cmp     eax, [esp+14h+var_4]
    jz      short loc_4D50F1
    inc     word ptr [ebx+eax*4+0A6Eh]

    loc_4D50F1:                             ; CODE XREF: sub_4D5070+77j
    inc     word ptr [ebx+0AAEh]
    jmp     short loc_4D510F
    ; ---------------------------------------------------------------------------

    loc_4D50FA:                             ; CODE XREF: sub_4D5070+71j
    cmp     esi, 0Ah
    jg      short loc_4D5108
    inc     word ptr [ebx+0AB2h]
    jmp     short loc_4D510F
    ; ---------------------------------------------------------------------------

    loc_4D5108:                             ; CODE XREF: sub_4D5070+8Dj
    inc     word ptr [ebx+0AB6h]

    loc_4D510F:                             ; CODE XREF: sub_4D5070+6Dj
                                            ; sub_4D5070+88j ...
    xor     esi, esi
    mov     [esp+14h+var_4], eax
    test    edx, edx
    jnz     short loc_4D5125
    mov     ecx, 8Ah
    mov     edi, 3
    jmp     short loc_4D513F
    ; ---------------------------------------------------------------------------

    loc_4D5125:                             ; CODE XREF: sub_4D5070+A7j
    cmp     eax, edx
    jnz     short loc_4D5135
    mov     ecx, 6
    mov     edi, 3
    jmp     short loc_4D513F
    ; ---------------------------------------------------------------------------

    loc_4D5135:                             ; CODE XREF: sub_4D5070+B7j
    mov     ecx, 7
    mov     edi, 4

    loc_4D513F:                             ; CODE XREF: sub_4D5070+5Fj
                                            ; sub_4D5070+B3j ...
    mov     eax, [esp+14h+arg_4]
    add     ebp, 4
    dec     eax
    mov     [esp+14h+arg_4], eax
    jnz     loc_4D50C0

    loc_4D5151:                             ; CODE XREF: sub_4D5070+3Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    sub_4D5070 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D5160 proc near                    ; CODE XREF: sub_4D4590+4BDp
                                            ; sub_4D4590+4CCp

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 8
    mov     eax, [esp+8+arg_4]
    push    ebx
    xor     ebx, ebx
    push    ebp
    mov     bx, [eax+2]
    xor     edx, edx
    push    esi
    push    edi
    test    ebx, ebx
    mov     [esp+18h+var_8], 0FFFFFFFFh
    mov     ecx, 7
    mov     esi, 4
    jnz     short loc_4D5193
    mov     ecx, 8Ah
    mov     esi, 3

    loc_4D5193:                             ; CODE XREF: sub_4D5160+27j
    mov     edi, [esp+18h+arg_8]
    test    edi, edi
    jl      loc_4D56CD
    add     eax, 6
    inc     edi
    mov     [esp+18h+arg_8], eax
    mov     eax, [esp+18h+arg_0]
    mov     [esp+18h+var_4], edi

    loc_4D51AF:                             ; CODE XREF: sub_4D5160+567j
    mov     edi, [esp+18h+arg_8]
    mov     ebp, ebx
    xor     ebx, ebx
    inc     edx
    mov     bx, [edi]
    cmp     edx, ecx
    mov     [esp+18h+arg_0], ebx
    mov     [esp+18h+arg_4], edx
    jge     short loc_4D51CF
    cmp     ebp, ebx
    jz      loc_4D56B3

    loc_4D51CF:                             ; CODE XREF: sub_4D5160+65j
    cmp     edx, esi
    jge     loc_4D5283

    loc_4D51D7:                             ; CODE XREF: sub_4D5160+118j
    mov     ecx, [eax+16ADh]
    xor     esi, esi
    mov     si, [eax+ebp*4+0A70h]
    mov     edi, 10h
    sub     edi, esi
    cmp     ecx, edi
    jle     short loc_4D5259
    xor     edx, edx
    mov     dx, [eax+ebp*4+0A6Eh]
    mov     edi, edx
    shl     edi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], di
    mov     edi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edi], bl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     edi
    mov     [eax+10h], edi
    mov     [edi+ebx], cl
    mov     ecx, [eax+10h]
    mov     edi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, di
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [edi+esi-10h]
    mov     [eax+16ADh], edx
    mov     edx, [esp+18h+arg_4]
    jmp     short loc_4D5273
    ; ---------------------------------------------------------------------------

    loc_4D5259:                             ; CODE XREF: sub_4D5160+90j
    mov     di, [eax+ebp*4+0A6Eh]
    shl     di, cl
    or      [eax+16ABh], di
    add     ecx, esi
    mov     [eax+16ADh], ecx

    loc_4D5273:                             ; CODE XREF: sub_4D5160+F7j
    dec     edx
    mov     [esp+18h+arg_4], edx
    jnz     loc_4D51D7
    jmp     loc_4D567F
    ; ---------------------------------------------------------------------------

    loc_4D5283:                             ; CODE XREF: sub_4D5160+71j
    test    ebp, ebp
    jz      loc_4D544C
    cmp     ebp, [esp+18h+var_8]
    jz      loc_4D5336
    mov     ecx, [eax+16ADh]
    xor     esi, esi
    mov     si, [eax+ebp*4+0A70h]
    mov     edi, 10h
    sub     edi, esi
    cmp     ecx, edi
    jle     short loc_4D5317
    xor     edx, edx
    mov     dx, [eax+ebp*4+0A6Eh]
    mov     edi, edx
    shl     edi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], di
    mov     edi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edi], bl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     edi
    mov     [eax+10h], edi
    mov     [edi+ebx], cl
    mov     ecx, [eax+10h]
    mov     edi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, di
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [edi+esi-10h]
    mov     [eax+16ADh], edx
    mov     edx, [esp+18h+arg_4]
    jmp     short loc_4D5331
    ; ---------------------------------------------------------------------------

    loc_4D5317:                             ; CODE XREF: sub_4D5160+14Ej
    mov     di, [eax+ebp*4+0A6Eh]
    shl     di, cl
    or      [eax+16ABh], di
    add     ecx, esi
    mov     [eax+16ADh], ecx

    loc_4D5331:                             ; CODE XREF: sub_4D5160+1B5j
    dec     edx
    mov     [esp+18h+arg_4], edx

    loc_4D5336:                             ; CODE XREF: sub_4D5160+12Fj
    mov     ecx, [eax+16ADh]
    xor     esi, esi
    mov     si, [eax+0AB0h]
    mov     edi, 10h
    sub     edi, esi
    cmp     ecx, edi
    jle     short loc_4D53B6
    xor     edx, edx
    mov     dx, [eax+0AAEh]
    mov     edi, edx
    shl     edi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], di
    mov     edi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edi], bl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     edi
    mov     [eax+10h], edi
    mov     [edi+ebx], cl
    mov     ecx, [eax+10h]
    mov     edi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, di
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [edi+esi-10h]
    mov     [eax+16ADh], edx
    mov     edx, [esp+18h+arg_4]
    jmp     short loc_4D53CF
    ; ---------------------------------------------------------------------------

    loc_4D53B6:                             ; CODE XREF: sub_4D5160+1EEj
    mov     di, [eax+0AAEh]
    shl     di, cl
    or      [eax+16ABh], di
    add     ecx, esi
    mov     [eax+16ADh], ecx

    loc_4D53CF:                             ; CODE XREF: sub_4D5160+254j
    mov     ecx, [eax+16ADh]
    cmp     ecx, 0Eh
    jle     short loc_4D5438
    add     edx, 0FFFFFFFDh
    mov     esi, edx
    shl     esi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], si
    mov     esi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+esi], bl
    mov     esi, [eax+10h]
    mov     edi, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     esi
    mov     [eax+10h], esi
    mov     [esi+edi], cl
    mov     ecx, [eax+10h]
    mov     esi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, si
    shr     dx, cl
    add     esi, 0FFFFFFF2h
    mov     [eax+16ADh], esi
    mov     [eax+16ABh], dx
    jmp     loc_4D567F
    ; ---------------------------------------------------------------------------

    loc_4D5438:                             ; CODE XREF: sub_4D5160+278j
    add     edx, 0FFFFFFFDh
    shl     edx, cl

    loc_4D543D:                             ; DATA XREF: .data:0050229Co
    or      [eax+16ABh], dx
    add     ecx, 2
    jmp     loc_4D5679
    ; ---------------------------------------------------------------------------

    loc_4D544C:                             ; CODE XREF: sub_4D5160+125j
    cmp     edx, 0Ah
    jg      loc_4D556B
    mov     ecx, [eax+16ADh]
    xor     esi, esi
    mov     si, [eax+0AB4h]
    mov     edi, 10h
    sub     edi, esi
    cmp     ecx, edi
    jle     short loc_4D54D5
    xor     edx, edx
    mov     dx, [eax+0AB2h]
    mov     edi, edx
    shl     edi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], di
    mov     edi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edi], bl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     edi
    mov     [eax+10h], edi
    mov     [edi+ebx], cl
    mov     ecx, [eax+10h]
    mov     edi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, di
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [edi+esi-10h]
    mov     [eax+16ADh], edx
    mov     edx, [esp+18h+arg_4]
    jmp     short loc_4D54EE
    ; ---------------------------------------------------------------------------

    loc_4D54D5:                             ; CODE XREF: sub_4D5160+30Dj
    mov     di, [eax+0AB2h]
    shl     di, cl
    or      [eax+16ABh], di
    add     ecx, esi
    mov     [eax+16ADh], ecx

    loc_4D54EE:                             ; CODE XREF: sub_4D5160+373j
    mov     ecx, [eax+16ADh]
    cmp     ecx, 0Dh
    jle     short loc_4D5557
    add     edx, 0FFFFFFFDh
    mov     esi, edx
    shl     esi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], si
    mov     esi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+esi], bl
    mov     esi, [eax+10h]
    mov     edi, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     esi
    mov     [eax+10h], esi
    mov     [esi+edi], cl
    mov     ecx, [eax+10h]
    mov     esi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, si
    shr     dx, cl
    add     esi, 0FFFFFFF3h
    mov     [eax+16ADh], esi
    mov     [eax+16ABh], dx
    jmp     loc_4D567F
    ; ---------------------------------------------------------------------------

    loc_4D5557:                             ; CODE XREF: sub_4D5160+397j
    add     edx, 0FFFFFFFDh
    shl     edx, cl
    or      [eax+16ABh], dx
    add     ecx, 3
    jmp     loc_4D5679
    ; ---------------------------------------------------------------------------

    loc_4D556B:                             ; CODE XREF: sub_4D5160+2EFj
    mov     ecx, [eax+16ADh]
    xor     esi, esi
    mov     si, [eax+0AB8h]
    mov     edi, 10h
    sub     edi, esi
    cmp     ecx, edi
    jle     short loc_4D55EB
    xor     edx, edx
    mov     dx, [eax+0AB6h]
    mov     edi, edx
    shl     edi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], di
    mov     edi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edi], bl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     edi
    mov     [eax+10h], edi
    mov     [edi+ebx], cl
    mov     ecx, [eax+10h]
    mov     edi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, di
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [edi+esi-10h]
    mov     [eax+16ADh], edx
    mov     edx, [esp+18h+arg_4]
    jmp     short loc_4D5604
    ; ---------------------------------------------------------------------------

    loc_4D55EB:                             ; CODE XREF: sub_4D5160+423j
    mov     di, [eax+0AB6h]
    shl     di, cl
    or      [eax+16ABh], di
    add     ecx, esi
    mov     [eax+16ADh], ecx

    loc_4D5604:                             ; CODE XREF: sub_4D5160+489j
    mov     ecx, [eax+16ADh]
    cmp     ecx, 9
    jle     short loc_4D566A
    add     edx, 0FFFFFFF5h
    mov     esi, edx
    shl     esi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], si
    mov     esi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+esi], bl
    mov     esi, [eax+10h]
    mov     edi, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     esi
    mov     [eax+10h], esi
    mov     [esi+edi], cl
    mov     ecx, [eax+10h]
    mov     esi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, si
    shr     dx, cl
    add     esi, 0FFFFFFF7h
    mov     [eax+16ADh], esi
    mov     [eax+16ABh], dx
    jmp     short loc_4D567F
    ; ---------------------------------------------------------------------------

    loc_4D566A:                             ; CODE XREF: sub_4D5160+4ADj
    add     edx, 0FFFFFFF5h
    shl     edx, cl
    or      [eax+16ABh], dx
    add     ecx, 7

    loc_4D5679:                             ; CODE XREF: sub_4D5160+2E7j
                                            ; sub_4D5160+406j
    mov     [eax+16ADh], ecx

    loc_4D567F:                             ; CODE XREF: sub_4D5160+11Ej
                                            ; sub_4D5160+2D3j ...
    mov     ebx, [esp+18h+arg_0]
    xor     edx, edx
    test    ebx, ebx
    mov     [esp+18h+var_8], ebp
    jnz     short loc_4D5699
    mov     ecx, 8Ah
    mov     esi, 3
    jmp     short loc_4D56B3
    ; ---------------------------------------------------------------------------

    loc_4D5699:                             ; CODE XREF: sub_4D5160+52Bj
    cmp     ebp, ebx
    jnz     short loc_4D56A9
    mov     ecx, 6
    mov     esi, 3
    jmp     short loc_4D56B3
    ; ---------------------------------------------------------------------------

    loc_4D56A9:                             ; CODE XREF: sub_4D5160+53Bj
    mov     ecx, 7
    mov     esi, 4

    loc_4D56B3:                             ; CODE XREF: sub_4D5160+69j
                                            ; sub_4D5160+537j ...
    mov     ebp, [esp+18h+arg_8]
    mov     edi, [esp+18h+var_4]
    add     ebp, 4
    dec     edi
    mov     [esp+18h+arg_8], ebp
    mov     [esp+18h+var_4], edi
    jnz     loc_4D51AF

    loc_4D56CD:                             ; CODE XREF: sub_4D5160+39j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn    0Ch
    sub_4D5160 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D56E0 proc near                    ; CODE XREF: .text:004D2D37p
                                            ; .text:004D2DF0p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     edx, [esp+arg_0]
    push    ebx
    push    ebp
    push    esi
    mov     eax, [edx+168Fh]
    mov     ecx, [edx+1693h]
    mov     esi, [esp+0Ch+arg_4]
    push    edi
    mov     [ecx+eax*2], si
    mov     ecx, [edx+1687h]
    mov     edi, [edx+168Fh]
    mov     eax, [esp+10h+arg_8]
    mov     [ecx+edi], al
    mov     edi, [edx+168Fh]
    inc     edi
    test    esi, esi
    mov     [edx+168Fh], edi
    jnz     short loc_4D572A
    inc     word ptr [edx+eax*4+86h]
    jmp     short loc_4D5774
    ; ---------------------------------------------------------------------------

    loc_4D572A:                             ; CODE XREF: sub_4D56E0+3Ej
    mov     ebx, [edx+16A3h]
    xor     ecx, ecx
    inc     ebx
    dec     esi
    mov     [edx+16A3h], ebx
    mov     cl, byte ptr dword_527000[eax]
    inc     word ptr [edx+ecx*4+48Ah]
    cmp     esi, 100h
    lea     eax, [edx+ecx*4+48Ah]
    jnb     short loc_4D5761
    xor     eax, eax
    mov     al, byte ptr dword_527178[esi]
    jmp     short loc_4D576C
    ; ---------------------------------------------------------------------------

    loc_4D5761:                             ; CODE XREF: sub_4D56E0+75j
    shr     esi, 7
    xor     eax, eax
    mov     al, byte ptr dword_527278[esi]

    loc_4D576C:                             ; CODE XREF: sub_4D56E0+7Fj
    inc     word ptr [edx+eax*4+97Ah]

    loc_4D5774:                             ; CODE XREF: sub_4D56E0+48j
    cmp     dword ptr [edx+76h], 2
    jle     short loc_4D57E6
    mov     eax, [edx+168Fh]
    test    eax, 0FFFh
    mov     [esp+10h+arg_0], eax
    jnz     short loc_4D57E6
    mov     edi, [edx+5Eh]
    lea     esi, ds:0[eax*8]
    mov     eax, [edx+4Eh]
    lea     ecx, [edx+97Ah]
    sub     edi, eax
    mov     eax, offset dword_50BD48

    loc_4D57A5:                             ; CODE XREF: sub_4D56E0+DFj
    mov     ebx, [eax]
    xor     ebp, ebp
    mov     bp, [ecx]
    add     ebx, 5
    imul    ebx, ebp
    add     eax, 4
    add     esi, ebx
    add     ecx, 4
    cmp     eax, offset dword_50BDC0
    jl      short loc_4D57A5
    mov     eax, [esp+10h+arg_0]
    mov     ecx, [edx+16A3h]
    shr     eax, 1
    shr     esi, 3
    cmp     ecx, eax
    jnb     short loc_4D57E6
    shr     edi, 1
    cmp     esi, edi
    jnb     short loc_4D57E6
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D57E6:                             ; CODE XREF: sub_4D56E0+98j
                                            ; sub_4D56E0+A9j ...
    mov     eax, [edx+168Bh]
    mov     esi, [edx+168Fh]
    dec     eax
    xor     ecx, ecx
    cmp     esi, eax
    pop     edi
    setz    cl
    pop     esi
    pop     ebp
    mov     eax, ecx
    pop     ebx
    retn    0Ch
    sub_4D56E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D5810 proc near                    ; CODE XREF: sub_4D4590+1CDp
                                            ; sub_4D4590+4D4p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_0]
    sub     esp, 0Ch
    xor     ecx, ecx
    mov     edx, [eax+168Fh]
    push    ebx
    push    ebp
    mov     ebp, [esp+14h+arg_4]
    push    esi
    push    edi
    test    edx, edx
    jz      loc_4D5BA6

    loc_4D582F:                             ; CODE XREF: sub_4D5810+390j
    mov     edx, [eax+1693h]
    xor     edi, edi
    xor     ebx, ebx
    mov     di, [edx+ecx*2]
    mov     edx, [eax+1687h]
    mov     bl, [edx+ecx]
    inc     ecx
    test    edi, edi
    mov     edx, ebx
    mov     [esp+1Ch+var_4], ecx
    jnz     loc_4D58EC
    mov     di, [ebp+edx*4+2]
    mov     ecx, [eax+16ADh]
    mov     esi, 10h
    sub     esi, edi
    cmp     ecx, esi
    jle     short loc_4D58D0
    xor     esi, esi
    mov     si, [ebp+edx*4+0]
    mov     edx, esi
    shl     edx, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], dx
    mov     edx, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edx], bl
    mov     edx, [eax+10h]
    mov     ebx, [eax+8]
    inc     edx
    mov     [eax+10h], edx
    mov     ecx, edx
    xor     edx, edx
    mov     dl, [eax+16ACh]
    mov     [ebx+ecx], dl
    mov     ecx, [eax+10h]
    mov     edx, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, dx
    shr     si, cl
    lea     ecx, [edi+edx-10h]
    mov     [eax+16ADh], ecx
    mov     [eax+16ABh], si
    jmp     loc_4D5B94
    ; ---------------------------------------------------------------------------

    loc_4D58D0:                             ; CODE XREF: sub_4D5810+59j
    mov     dx, [ebp+edx*4+0]
    shl     dx, cl
    or      [eax+16ABh], dx
    add     edi, ecx
    mov     [eax+16ADh], edi
    jmp     loc_4D5B94
    ; ---------------------------------------------------------------------------

    loc_4D58EC:                             ; CODE XREF: sub_4D5810+3Fj
    xor     ecx, ecx
    xor     esi, esi
    mov     cl, byte ptr dword_527000[edx]
    mov     ebx, 10h
    mov     [esp+1Ch+var_C], ecx
    shl     ecx, 2
    mov     [esp+1Ch+arg_0], ecx
    mov     si, [ebp+ecx+406h]
    mov     ecx, [eax+16ADh]
    sub     ebx, esi
    mov     [esp+1Ch+var_8], esi
    cmp     ecx, ebx
    jle     short loc_4D598C
    mov     ebx, [esp+1Ch+var_C]
    xor     esi, esi
    mov     si, [ebp+ebx*4+404h]
    mov     ebp, [eax+8]
    mov     ebx, esi
    shl     ebx, cl
    or      [eax+16ABh], bx
    mov     ebx, [eax+10h]
    mov     cl, [eax+16ABh]
    mov     [ebp+ebx+0], cl
    mov     ebx, [eax+10h]
    inc     ebx
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    mov     [eax+10h], ebx
    mov     ebp, ebx
    mov     ebx, [eax+8]
    mov     [ebx+ebp], cl
    mov     ecx, [eax+10h]
    mov     ebx, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, bx
    shr     si, cl
    mov     ecx, [esp+1Ch+var_8]
    lea     ecx, [ecx+ebx-10h]
    mov     [eax+16ABh], si
    mov     [eax+16ADh], ecx
    jmp     short loc_4D59AA
    ; ---------------------------------------------------------------------------

    loc_4D598C:                             ; CODE XREF: sub_4D5810+10Cj
    mov     ebx, [esp+1Ch+var_C]
    mov     bx, [ebp+ebx*4+404h]
    shl     bx, cl
    or      [eax+16ABh], bx
    add     esi, ecx
    mov     [eax+16ADh], esi

    loc_4D59AA:                             ; CODE XREF: sub_4D5810+17Aj
    mov     ecx, [esp+1Ch+arg_0]
    mov     esi, dword_50BCD0[ecx]
    test    esi, esi
    jz      loc_4D5A42
    mov     ebx, dword_527100[ecx]
    mov     ecx, [eax+16ADh]
    sub     edx, ebx
    mov     ebx, 10h
    sub     ebx, esi
    cmp     ecx, ebx
    jle     short loc_4D5A31
    mov     ebx, edx
    mov     ebp, [eax+8]
    shl     ebx, cl
    or      [eax+16ABh], bx
    mov     ebx, [eax+10h]
    mov     cl, [eax+16ABh]
    mov     [ebp+ebx+0], cl
    mov     ebx, [eax+10h]
    inc     ebx
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    mov     [eax+10h], ebx
    mov     ebp, ebx
    mov     ebx, [eax+8]
    mov     [ebx+ebp], cl
    mov     ecx, [eax+10h]
    mov     ebx, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, bx
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [esi+ebx-10h]
    mov     [eax+16ADh], edx
    jmp     short loc_4D5A42
    ; ---------------------------------------------------------------------------

    loc_4D5A31:                             ; CODE XREF: sub_4D5810+1C3j
    shl     edx, cl
    or      [eax+16ABh], dx
    add     esi, ecx
    mov     [eax+16ADh], esi

    loc_4D5A42:                             ; CODE XREF: sub_4D5810+1A6j
                                            ; sub_4D5810+21Fj
    dec     edi
    cmp     edi, 100h
    jnb     short loc_4D5A55
    xor     ecx, ecx
    mov     cl, byte ptr dword_527178[edi]
    jmp     short loc_4D5A64
    ; ---------------------------------------------------------------------------

    loc_4D5A55:                             ; CODE XREF: sub_4D5810+239j
    mov     ecx, edi
    shr     ecx, 7
    xor     edx, edx
    mov     dl, byte ptr dword_527278[ecx]
    mov     ecx, edx

    loc_4D5A64:                             ; CODE XREF: sub_4D5810+243j
    mov     ebp, [esp+1Ch+arg_8]
    lea     ebx, ds:0[ecx*4]
    mov     ecx, [eax+16ADh]
    xor     esi, esi
    mov     si, [ebp+ebx+2]
    mov     edx, 10h
    sub     edx, esi
    mov     [esp+1Ch+arg_0], ebx
    cmp     ecx, edx
    jle     short loc_4D5AF2
    xor     edx, edx
    mov     dx, [ebp+ebx+0]
    mov     ebp, [eax+8]
    mov     ebx, edx
    shl     ebx, cl
    or      [eax+16ABh], bx
    mov     ebx, [eax+10h]
    mov     cl, [eax+16ABh]
    mov     [ebp+ebx+0], cl
    mov     ebx, [eax+10h]
    inc     ebx
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    mov     [eax+10h], ebx
    mov     ebp, ebx
    mov     ebx, [eax+8]
    mov     [ebx+ebp], cl
    mov     ecx, [eax+10h]
    mov     ebx, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, bx
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [esi+ebx-10h]
    mov     ebx, [esp+1Ch+arg_0]
    mov     [eax+16ADh], edx
    jmp     short loc_4D5B09
    ; ---------------------------------------------------------------------------

    loc_4D5AF2:                             ; CODE XREF: sub_4D5810+279j
    mov     dx, [ebp+ebx+0]
    shl     dx, cl
    or      [eax+16ABh], dx
    add     esi, ecx
    mov     [eax+16ADh], esi

    loc_4D5B09:                             ; CODE XREF: sub_4D5810+2E0j
    mov     edx, dword_50BD48[ebx]
    mov     ebp, [esp+1Ch+arg_4]
    test    edx, edx
    jz      short loc_4D5B94
    mov     ecx, dword_527870[ebx]
    mov     esi, 10h
    sub     edi, ecx
    mov     ecx, [eax+16ADh]
    sub     esi, edx
    cmp     ecx, esi
    jle     short loc_4D5B83
    mov     esi, edi
    shl     esi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], si
    mov     esi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+esi], bl
    mov     esi, [eax+10h]
    mov     ebx, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     esi
    mov     [eax+10h], esi
    mov     [ebx+esi], cl
    mov     ecx, [eax+10h]
    mov     esi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, si
    lea     edx, [edx+esi-10h]
    shr     di, cl
    mov     [eax+16ABh], di
    jmp     short loc_4D5B8E
    ; ---------------------------------------------------------------------------

    loc_4D5B83:                             ; CODE XREF: sub_4D5810+31Ej
    shl     edi, cl
    or      [eax+16ABh], di
    add     edx, ecx

    loc_4D5B8E:                             ; CODE XREF: sub_4D5810+371j
    mov     [eax+16ADh], edx

    loc_4D5B94:                             ; CODE XREF: sub_4D5810+BBj
                                            ; sub_4D5810+D7j ...
    mov     ecx, [esp+1Ch+var_4]
    mov     edx, [eax+168Fh]
    cmp     ecx, edx
    jb      loc_4D582F

    loc_4D5BA6:                             ; CODE XREF: sub_4D5810+19j
    mov     ecx, [eax+16ADh]
    xor     esi, esi
    mov     si, [ebp+402h]
    mov     edx, 10h
    sub     edx, esi
    cmp     ecx, edx
    jle     short loc_4D5C22
    xor     edx, edx
    mov     dx, [ebp+400h]
    mov     edi, edx
    shl     edi, cl
    mov     ecx, [eax+8]
    or      [eax+16ABh], di
    mov     edi, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edi], bl
    mov     edi, [eax+10h]
    mov     ebx, [eax+8]
    xor     ecx, ecx
    mov     cl, [eax+16ACh]
    inc     edi
    mov     [eax+10h], edi
    mov     [ebx+edi], cl
    mov     ecx, [eax+10h]
    mov     edi, [eax+16ADh]
    inc     ecx
    mov     [eax+10h], ecx
    mov     cx, 10h
    sub     cx, di
    shr     dx, cl
    mov     [eax+16ABh], dx
    lea     edx, [esi+edi-10h]
    mov     [eax+16ADh], edx
    jmp     short loc_4D5C3B
    ; ---------------------------------------------------------------------------

    loc_4D5C22:                             ; CODE XREF: sub_4D5810+3AEj
    mov     dx, [ebp+400h]
    shl     dx, cl
    or      [eax+16ABh], dx
    add     esi, ecx
    mov     [eax+16ADh], esi

    loc_4D5C3B:                             ; CODE XREF: sub_4D5810+410j
    xor     ecx, ecx
    pop     edi
    mov     cx, [ebp+402h]
    pop     esi
    pop     ebp
    mov     [eax+16A7h], ecx
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_4D5810 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D5C60 proc near                    ; CODE XREF: sub_4D4590+55Ep

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    ebx
    push    edi
    mov     ecx, [eax+16ADh]
    cmp     ecx, 8
    jle     short loc_4D5C99
    mov     ecx, [eax+8]
    mov     edx, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edx], bl
    mov     edx, [eax+10h]
    mov     edi, [eax+8]
    inc     edx
    mov     [eax+10h], edx
    mov     ecx, edx
    xor     edx, edx
    mov     dl, [eax+16ACh]
    mov     [edi+ecx], dl
    jmp     short loc_4D5CAC
    ; ---------------------------------------------------------------------------

    loc_4D5C99:                             ; CODE XREF: sub_4D5C60+Fj
    test    ecx, ecx
    jle     short loc_4D5CAF
    mov     ecx, [eax+8]
    mov     edx, [eax+10h]
    mov     bl, [eax+16ABh]
    mov     [ecx+edx], bl

    loc_4D5CAC:                             ; CODE XREF: sub_4D5C60+37j
    inc     dword ptr [eax+10h]

    loc_4D5CAF:                             ; CODE XREF: sub_4D5C60+3Bj
    pop     edi
    mov     word ptr [eax+16ABh], 0
    mov     dword ptr [eax+16ADh], 0
    pop     ebx
    retn    4
    sub_4D5C60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D5CD0 proc near                    ; CODE XREF: .text:004D212Dp
                                            ; sub_4D2AD0+118p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    esi
    mov     esi, [esp+arg_4]
    push    edi
    mov     edi, [esp+4+arg_0]
    mov     ecx, edi
    and     ecx, 0FFFFh
    shr     edi, 10h
    test    esi, esi
    jnz     short loc_4D5CF3
    mov     eax, 1
    pop     edi
    pop     esi
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D5CF3:                             ; CODE XREF: sub_4D5CD0+17j
    push    ebx
    mov     ebx, [esp+8+arg_8]
    test    ebx, ebx
    jbe     loc_4D5DEF
    push    ebp

    loc_4D5D01:                             ; CODE XREF: sub_4D5CD0+118j
    cmp     ebx, 15B0h
    mov     eax, ebx
    jb      short loc_4D5D10
    mov     eax, 15B0h

    loc_4D5D10:                             ; CODE XREF: sub_4D5CD0+39j
    sub     ebx, eax
    cmp     eax, 10h
    jl      loc_4D5DBC
    mov     ebp, eax
    shr     ebp, 4

    loc_4D5D20:                             ; CODE XREF: sub_4D5CD0+E6j
    xor     edx, edx
    sub     eax, 10h
    mov     dl, [esi]
    add     esi, 10h
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-0Fh]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-0Eh]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-0Dh]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-0Ch]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-0Bh]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-0Ah]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-9]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-8]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-7]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-6]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-5]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-4]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-3]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-2]
    add     edi, ecx
    add     ecx, edx
    xor     edx, edx
    mov     dl, [esi-1]
    add     edi, ecx
    add     ecx, edx
    add     edi, ecx
    dec     ebp
    jnz     loc_4D5D20

    loc_4D5DBC:                             ; CODE XREF: sub_4D5CD0+45j
    test    eax, eax
    jz      short loc_4D5DCC

    loc_4D5DC0:                             ; CODE XREF: sub_4D5CD0+FAj
    xor     edx, edx
    mov     dl, [esi]
    add     ecx, edx
    inc     esi
    add     edi, ecx
    dec     eax
    jnz     short loc_4D5DC0

    loc_4D5DCC:                             ; CODE XREF: sub_4D5CD0+EEj
    mov     eax, ecx
    xor     edx, edx
    mov     ecx, 0FFF1h
    div     ecx
    mov     eax, edi
    mov     edi, 0FFF1h
    mov     ecx, edx
    xor     edx, edx
    div     edi
    test    ebx, ebx
    mov     edi, edx
    ja      loc_4D5D01
    pop     ebp

    loc_4D5DEF:                             ; CODE XREF: sub_4D5CD0+2Aj
    mov     eax, edi
    pop     ebx
    shl     eax, 10h
    pop     edi
    or      eax, ecx
    pop     esi
    retn    0Ch
    sub_4D5CD0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D5E00 proc near                    ; CODE XREF: .text:004D3583p
                                            ; sub_4D35F0+137p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+34h]
    test    eax, eax
    jz      short loc_4D5E16
    mov     ecx, [esp+4+arg_8]
    mov     eax, [esi+38h]
    mov     [ecx], eax

    loc_4D5E16:                             ; CODE XREF: sub_4D5E00+Bj
    mov     eax, [esi]
    mov     edi, [esp+4+arg_4]
    cmp     eax, 4
    jz      short loc_4D5E26
    cmp     eax, 5
    jnz     short loc_4D5E31

    loc_4D5E26:                             ; CODE XREF: sub_4D5E00+1Fj
    mov     edx, [esi+0Ch]
    mov     eax, [edi+28h]
    push    edx
    push    eax
    call    dword ptr [edi+24h]

    loc_4D5E31:                             ; CODE XREF: sub_4D5E00+24j
    cmp     dword ptr [esi], 6
    jnz     short loc_4D5E54
    mov     ecx, [esi+0Ch]
    push    edi
    push    ecx
    call    sub_4D7C20
    mov     edx, [esi+8]
    push    edi
    push    edx
    call    sub_4D7410
    mov     eax, [esi+4]
    push    edi
    push    eax
    call    sub_4D7410

    loc_4D5E54:                             ; CODE XREF: sub_4D5E00+34j
    mov     eax, [esi+24h]
    mov     dword ptr [esi], 0
    mov     [esi+30h], eax
    mov     [esi+2Ch], eax
    mov     eax, [esi+34h]
    mov     dword ptr [esi+1Ch], 0
    test    eax, eax
    mov     dword ptr [esi+20h], 0
    jz      short loc_4D5E86
    push    0
    push    0
    push    0
    call    eax
    mov     [esi+38h], eax
    mov     [edi+30h], eax

    loc_4D5E86:                             ; CODE XREF: sub_4D5E00+76j
    pop     edi
    pop     esi
    retn    0Ch
    sub_4D5E00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D5E90 proc near                    ; CODE XREF: sub_4D35F0+CAp

    var_4= dword ptr -4
    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+arg_0]
    push    3Ch
    push    1
    mov     eax, [edi+28h]
    push    eax
    call    dword ptr [edi+20h]
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4D5EAE
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D5EAE:                             ; CODE XREF: sub_4D5E90+16j
    mov     ebx, [esp+18h]
    mov     ecx, [edi+28h]
    push    ebx
    push    1
    push    ecx
    call    dword ptr [edi+20h]
    test    eax, eax
    mov     [esi+24h], eax
    jnz     short loc_4D5ED3
    mov     edx, [edi+28h]
    push    esi
    push    edx
    call    dword ptr [edi+24h]
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D5ED3:                             ; CODE XREF: sub_4D5E90+31j
    lea     ecx, [esi+38h]
    add     ebx, eax
    mov     eax, [esp+14h]
    push    ecx
    push    edi
    push    esi
    mov     [esi+28h], ebx
    mov     [esi+34h], eax
    mov     dword ptr [esi], 0
    call    sub_4D5E00
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    0Ch
    sub_4D5E90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D5F00 proc near                    ; CODE XREF: sub_4D37A0+136p

    var_3C= dword ptr -3Ch
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 30h
    mov     eax, [esp+30h+arg_4]
    push    ebx
    mov     ebx, [esp+34h+arg_0]
    push    ebp
    mov     ecx, [eax]
    mov     edx, [eax+4]
    mov     eax, [ebx+20h]
    mov     ebp, [ebx+1Ch]
    mov     [esp+38h+var_2C], ecx
    mov     ecx, [ebx+30h]
    mov     [esp+38h+var_28], eax
    mov     eax, [ebx+2Ch]
    push    esi
    cmp     ecx, eax
    push    edi
    mov     [esp+40h+var_30], edx
    mov     [esp+40h+arg_0], ecx
    jnb     short loc_4D5F39
    sub     eax, ecx
    dec     eax
    jmp     short loc_4D5F3E
    ; ---------------------------------------------------------------------------

    loc_4D5F39:                             ; CODE XREF: sub_4D5F00+32j
    mov     eax, [ebx+28h]
    sub     eax, ecx

    loc_4D5F3E:                             ; CODE XREF: sub_4D5F00+37j
    mov     [esp+40h+var_24], eax

    loc_4D5F42:                             ; CODE XREF: sub_4D5F00+AFj
                                            ; sub_4D5F00+D1j ...
    mov     eax, [ebx]
    cmp     eax, 9                          ; switch 10 cases
    ja      loc_4D6AEF                      ; default
    jmp     ds:off_4D6B34[eax*4]            ; switch jump

    loc_4D5F54:                             ; DATA XREF: .text:004D6B34o
    mov     esi, [esp+40h+var_28]           ; case 0x0
    cmp     ebp, 3
    jnb     short loc_4D5F99
    mov     eax, [esp+40h+var_30]
    mov     edi, [esp+40h+var_2C]

    loc_4D5F65:                             ; CODE XREF: sub_4D5F00+95j
    test    eax, eax
    jz      loc_4D6689
    xor     ecx, ecx
    dec     eax
    mov     cl, [edi]
    mov     [esp+40h+arg_8], 0
    mov     edx, ecx
    mov     ecx, ebp
    shl     edx, cl
    add     ebp, 8
    mov     [esp+40h+var_30], eax
    or      esi, edx
    inc     edi
    cmp     ebp, 3
    mov     [esp+40h+var_28], esi
    mov     [esp+40h+var_2C], edi
    jb      short loc_4D5F65
    jmp     short loc_4D5F9D
    ; ---------------------------------------------------------------------------

    loc_4D5F99:                             ; CODE XREF: sub_4D5F00+5Bj
    mov     edi, [esp+40h+var_2C]

    loc_4D5F9D:                             ; CODE XREF: sub_4D5F00+97j
    mov     eax, esi
    and     eax, 7
    mov     ecx, eax
    shr     eax, 1
    and     ecx, 1
    cmp     eax, 3
    mov     [ebx+18h], ecx
    ja      short loc_4D5F42
    jmp     ds:off_4D6B5C[eax*4]

    loc_4D5FB8:                             ; DATA XREF: .text:004D6B5Co
    sub     ebp, 3
    mov     dword ptr [ebx], 1
    mov     ecx, ebp
    and     ecx, 7
    shr     esi, 3
    shr     esi, cl
    sub     ebp, ecx
    mov     [esp+40h+var_28], esi
    jmp     loc_4D5F42
    ; ---------------------------------------------------------------------------

    loc_4D5FD6:                             ; CODE XREF: sub_4D5F00+B1j
                                            ; DATA XREF: .text:004D6B60o
    lea     edx, [esp+40h+var_18]
    lea     eax, [esp+40h+var_14]
    push    edx
    lea     ecx, [esp+44h+var_10]
    push    eax
    lea     edx, [esp+48h+var_C]
    push    ecx
    push    edx
    call    sub_4D72B0
    mov     eax, [esp+40h+arg_4]
    mov     ecx, [esp+40h+var_18]
    mov     edx, [esp+40h+var_14]
    push    eax
    mov     eax, [esp+44h+var_10]
    push    ecx
    mov     ecx, [esp+48h+var_C]
    push    edx
    push    eax
    push    ecx
    call    sub_4D7450
    test    eax, eax
    mov     [ebx+0Ch], eax
    jz      loc_4D699B
    xor     eax, eax
    mov     dword ptr [ebx], 6
    shr     esi, 3
    mov     [ebx+4], eax
    mov     [ebx+8], eax
    mov     [esp+40h+var_28], esi
    sub     ebp, 3
    jmp     loc_4D5F42
    ; ---------------------------------------------------------------------------

    loc_4D6035:                             ; CODE XREF: sub_4D5F00+B1j
                                            ; DATA XREF: .text:004D6B64o
    shr     esi, 3
    mov     [esp+40h+var_28], esi
    sub     ebp, 3
    mov     dword ptr [ebx], 3
    jmp     loc_4D5F42
    ; ---------------------------------------------------------------------------

    loc_4D604A:                             ; CODE XREF: sub_4D5F00+4Dj
                                            ; DATA XREF: .text:004D6B34o
    mov     esi, [esp+40h+var_28]           ; case 0x1
    mov     edi, [esp+40h+var_30]
    mov     eax, [esp+40h+var_2C]
    cmp     ebp, 20h
    jnb     short loc_4D6083

    loc_4D605B:                             ; CODE XREF: sub_4D5F00+181j
    xor     edx, edx
    cmp     edi, edx
    jz      loc_4D6715
    mov     [esp+40h+arg_8], edx
    mov     dl, [eax]
    mov     ecx, ebp
    dec     edi
    shl     edx, cl
    add     ebp, 8
    mov     [esp+40h+var_30], edi
    or      esi, edx
    inc     eax
    cmp     ebp, 20h
    mov     [esp+40h+var_2C], eax
    jb      short loc_4D605B

    loc_4D6083:                             ; CODE XREF: sub_4D5F00+159j
    mov     edx, esi
    mov     ecx, esi
    not     edx
    and     ecx, 0FFFFh
    shr     edx, 10h
    xor     edx, ecx
    jnz     loc_4D674F
    xor     ebp, ebp
    mov     eax, ecx
    cmp     eax, ebp
    mov     [ebx+4], ecx
    mov     [esp+40h+var_28], ebp
    jz      loc_4D61D0
    mov     eax, 2
    mov     [ebx], eax
    jmp     loc_4D5F42
    ; ---------------------------------------------------------------------------

    loc_4D60B9:                             ; CODE XREF: sub_4D5F00+4Dj
                                            ; DATA XREF: .text:004D6B34o
    mov     edx, [esp+40h+var_30]           ; case 0x2
    test    edx, edx
    jz      loc_4D6793
    mov     ecx, [esp+40h+var_24]
    test    ecx, ecx
    jnz     loc_4D616B
    mov     esi, [ebx+28h]
    mov     edx, [esp+40h+arg_0]
    cmp     edx, esi
    jnz     short loc_4D60FF
    mov     eax, [ebx+2Ch]
    mov     edi, [ebx+24h]
    cmp     eax, edi
    jz      short loc_4D60FF
    mov     edx, edi
    cmp     edx, eax
    mov     [esp+40h+arg_0], edx
    jnb     short loc_4D60F7
    sub     eax, edx
    dec     eax
    mov     ecx, eax
    jmp     short loc_4D60FB
    ; ---------------------------------------------------------------------------

    loc_4D60F7:                             ; CODE XREF: sub_4D5F00+1EEj
    sub     esi, edx
    mov     ecx, esi

    loc_4D60FB:                             ; CODE XREF: sub_4D5F00+1F5j
    mov     [esp+40h+var_24], ecx

    loc_4D60FF:                             ; CODE XREF: sub_4D5F00+1DAj
                                            ; sub_4D5F00+1E4j
    test    ecx, ecx
    jnz     short loc_4D6167
    mov     eax, [esp+40h+arg_8]
    mov     ecx, [esp+40h+arg_4]
    push    eax
    push    ecx
    push    ebx
    mov     [ebx+30h], edx
    call    sub_4D7C40
    mov     edx, [ebx+30h]
    mov     esi, [ebx+2Ch]
    cmp     edx, esi
    mov     [esp+40h+arg_8], eax
    mov     [esp+40h+arg_0], edx
    jnb     short loc_4D612F
    mov     ecx, esi
    sub     ecx, edx
    dec     ecx
    jmp     short loc_4D6134
    ; ---------------------------------------------------------------------------

    loc_4D612F:                             ; CODE XREF: sub_4D5F00+226j
    mov     ecx, [ebx+28h]
    sub     ecx, edx

    loc_4D6134:                             ; CODE XREF: sub_4D5F00+22Dj
    mov     eax, [ebx+28h]
    mov     [esp+40h+var_24], ecx
    cmp     edx, eax
    jnz     short loc_4D615F
    mov     edi, [ebx+24h]
    cmp     esi, edi
    jz      short loc_4D615F
    mov     edx, edi
    cmp     edx, esi
    mov     [esp+40h+arg_0], edx
    jnb     short loc_4D6157
    sub     esi, edx
    dec     esi
    mov     ecx, esi
    jmp     short loc_4D615B
    ; ---------------------------------------------------------------------------

    loc_4D6157:                             ; CODE XREF: sub_4D5F00+24Ej
    sub     eax, edx
    mov     ecx, eax

    loc_4D615B:                             ; CODE XREF: sub_4D5F00+255j
    mov     [esp+40h+var_24], ecx

    loc_4D615F:                             ; CODE XREF: sub_4D5F00+23Dj
                                            ; sub_4D5F00+244j
    test    ecx, ecx
    jz      loc_4D67D9

    loc_4D6167:                             ; CODE XREF: sub_4D5F00+201j
    mov     edx, [esp+40h+var_30]

    loc_4D616B:                             ; CODE XREF: sub_4D5F00+1CBj
    mov     eax, [ebx+4]
    mov     [esp+40h+arg_8], 0
    cmp     eax, edx
    jbe     short loc_4D617C
    mov     eax, edx

    loc_4D617C:                             ; CODE XREF: sub_4D5F00+278j
    cmp     eax, ecx
    jbe     short loc_4D6182
    mov     eax, ecx

    loc_4D6182:                             ; CODE XREF: sub_4D5F00+27Ej
    mov     esi, [esp+40h+var_2C]
    mov     edi, [esp+40h+arg_0]
    mov     ecx, eax
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     edx, [esp+40h+var_24]
    and     ecx, 3
    sub     edx, eax
    rep movsb
    mov     ecx, [esp+40h+var_2C]
    mov     edi, [esp+40h+var_30]
    mov     esi, [esp+40h+arg_0]
    add     ecx, eax
    mov     [esp+40h+var_2C], ecx
    mov     ecx, [ebx+4]
    sub     edi, eax
    add     esi, eax
    sub     ecx, eax
    mov     [esp+40h+var_30], edi
    mov     [esp+40h+arg_0], esi
    mov     [esp+40h+var_24], edx
    mov     [ebx+4], ecx
    jnz     loc_4D5F42

    loc_4D61D0:                             ; CODE XREF: sub_4D5F00+1A7j
    mov     eax, [ebx+18h]
    neg     eax
    sbb     eax, eax
    and     eax, 7
    mov     [ebx], eax
    jmp     loc_4D5F42
    ; ---------------------------------------------------------------------------

    loc_4D61E1:                             ; CODE XREF: sub_4D5F00+4Dj
                                            ; DATA XREF: .text:004D6B34o
    mov     esi, [esp+40h+var_28]           ; case 0x3
    cmp     ebp, 0Eh
    jnb     short loc_4D6222
    mov     eax, [esp+40h+var_30]
    mov     edi, [esp+40h+var_2C]

    loc_4D61F2:                             ; CODE XREF: sub_4D5F00+31Ej
    test    eax, eax
    jz      loc_4D6874
    xor     ecx, ecx
    dec     eax
    mov     cl, [edi]
    mov     [esp+40h+arg_8], 0
    mov     edx, ecx
    mov     ecx, ebp
    shl     edx, cl
    add     ebp, 8
    mov     [esp+40h+var_30], eax
    or      esi, edx
    inc     edi
    cmp     ebp, 0Eh
    mov     [esp+40h+var_2C], edi
    jb      short loc_4D61F2
    jmp     short loc_4D6226
    ; ---------------------------------------------------------------------------

    loc_4D6222:                             ; CODE XREF: sub_4D5F00+2E8j
    mov     edi, [esp+40h+var_2C]

    loc_4D6226:                             ; CODE XREF: sub_4D5F00+320j
    mov     eax, esi
    and     eax, 3FFFh
    mov     ecx, eax
    mov     [ebx+4], eax
    and     ecx, 1Fh
    cmp     ecx, 1Dh
    ja      loc_4D6856
    mov     edx, eax
    and     edx, 3E0h
    cmp     edx, 3A0h
    ja      loc_4D6856
    shr     eax, 5
    and     eax, 1Fh
    lea     eax, [eax+ecx+102h]
    cmp     eax, 13h
    jnb     short loc_4D6269
    mov     eax, 13h

    loc_4D6269:                             ; CODE XREF: sub_4D5F00+362j
    push    4
    push    eax
    mov     eax, [esp+48h+arg_4]
    mov     ecx, [eax+28h]
    push    ecx
    call    dword ptr [eax+20h]
    test    eax, eax
    mov     [ebx+0Ch], eax
    jz      loc_4D681B
    shr     esi, 0Eh
    sub     ebp, 0Eh
    mov     dword ptr [ebx+8], 0
    mov     dword ptr [ebx], 4
    jmp     short loc_4D629F
    ; ---------------------------------------------------------------------------

    loc_4D6297:                             ; CODE XREF: sub_4D5F00+4Dj
                                            ; DATA XREF: .text:004D6B34o
    mov     esi, [esp+40h+var_28]           ; case 0x4
    mov     edi, [esp+40h+var_2C]

    loc_4D629F:                             ; CODE XREF: sub_4D5F00+395j
    mov     edx, [ebx+4]
    mov     eax, [ebx+8]
    shr     edx, 0Ah
    add     edx, 4
    cmp     eax, edx
    jnb     short loc_4D6317

    loc_4D62AF:                             ; CODE XREF: sub_4D5F00+415j
    cmp     ebp, 3
    jnb     short loc_4D62E6
    mov     eax, [esp+40h+var_30]

    loc_4D62B8:                             ; CODE XREF: sub_4D5F00+3E4j
    test    eax, eax
    jz      loc_4D68B2
    xor     ecx, ecx
    dec     eax
    mov     cl, [edi]
    mov     [esp+40h+arg_8], 0
    mov     edx, ecx
    mov     ecx, ebp
    shl     edx, cl
    add     ebp, 8
    mov     [esp+40h+var_30], eax
    or      esi, edx
    inc     edi
    cmp     ebp, 3
    mov     [esp+40h+var_2C], edi
    jb      short loc_4D62B8

    loc_4D62E6:                             ; CODE XREF: sub_4D5F00+3B2j
    mov     ecx, [ebx+8]
    mov     eax, esi
    and     eax, 7
    sub     ebp, 3
    mov     edx, dword_50BE70[ecx*4]
    mov     ecx, [ebx+0Ch]
    shr     esi, 3
    mov     [ecx+edx*4], eax
    mov     edx, [ebx+8]
    inc     edx
    mov     [ebx+8], edx
    mov     eax, edx
    mov     edx, [ebx+4]
    shr     edx, 0Ah
    add     edx, 4
    cmp     eax, edx
    jb      short loc_4D62AF

    loc_4D6317:                             ; CODE XREF: sub_4D5F00+3ADj
    mov     ecx, [ebx+8]
    mov     eax, 13h
    cmp     ecx, eax
    jnb     short loc_4D6344

    loc_4D6323:                             ; CODE XREF: sub_4D5F00+442j
    mov     ecx, [ebx+8]
    mov     edx, dword_50BE70[ecx*4]
    mov     ecx, [ebx+0Ch]
    mov     dword ptr [ecx+edx*4], 0
    mov     edx, [ebx+8]
    inc     edx
    mov     ecx, edx
    mov     [ebx+8], edx
    cmp     ecx, eax
    jb      short loc_4D6323

    loc_4D6344:                             ; CODE XREF: sub_4D5F00+421j
    mov     edx, [esp+40h+arg_4]
    lea     ecx, [ebx+14h]
    lea     eax, [ebx+10h]
    push    edx
    mov     edx, [ebx+0Ch]
    push    ecx
    push    eax
    push    edx
    mov     dword ptr [eax], 7
    call    sub_4D6BE0
    test    eax, eax
    jnz     loc_4D686C
    mov     [ebx+8], eax
    mov     dword ptr [ebx], 5
    jmp     short loc_4D637B
    ; ---------------------------------------------------------------------------

    loc_4D6373:                             ; CODE XREF: sub_4D5F00+4Dj
                                            ; DATA XREF: .text:004D6B34o
    mov     esi, [esp+40h+var_28]           ; case 0x5
    mov     edi, [esp+40h+var_2C]

    loc_4D637B:                             ; CODE XREF: sub_4D5F00+471j
    mov     eax, [ebx+4]
    mov     ecx, [ebx+8]
    mov     edx, eax
    and     eax, 1Fh
    shr     edx, 5
    and     edx, 1Fh
    lea     eax, [edx+eax+102h]
    cmp     ecx, eax
    jnb     loc_4D6516

    loc_4D639B:                             ; CODE XREF: sub_4D5F00+610j
    mov     eax, [ebx+10h]
    cmp     ebp, eax
    jnb     short loc_4D63D5

    loc_4D63A2:                             ; CODE XREF: sub_4D5F00+4D3j
    mov     ecx, [esp+40h+var_30]
    test    ecx, ecx
    jz      loc_4D6874
    mov     edx, ecx
    xor     ecx, ecx
    mov     cl, [edi]
    dec     edx
    mov     [esp+40h+var_30], edx
    mov     edx, ecx
    mov     ecx, ebp
    add     ebp, 8
    shl     edx, cl
    mov     [esp+40h+arg_8], 0
    or      esi, edx
    inc     edi
    cmp     ebp, eax
    mov     [esp+40h+var_2C], edi
    jb      short loc_4D63A2

    loc_4D63D5:                             ; CODE XREF: sub_4D5F00+4A0j
    mov     eax, dword_50C218[eax*4]
    mov     ecx, [ebx+14h]
    and     eax, esi
    xor     edx, edx
    mov     dl, [ecx+eax*8+1]
    lea     eax, [ecx+eax*8]
    mov     [esp+40h+var_8], edx
    mov     eax, [eax+4]
    cmp     eax, 10h
    mov     [esp+40h+var_4], eax
    jnb     short loc_4D6415
    mov     ecx, edx
    sub     ebp, edx
    mov     edx, [ebx+0Ch]
    shr     esi, cl
    mov     ecx, [ebx+8]
    mov     [edx+ecx*4], eax
    mov     eax, [ebx+8]
    inc     eax
    mov     [ebx+8], eax
    jmp     loc_4D64F6
    ; ---------------------------------------------------------------------------

    loc_4D6415:                             ; CODE XREF: sub_4D5F00+4F8j
    cmp     eax, 12h
    mov     ecx, 7
    jz      short loc_4D6422
    lea     ecx, [eax-0Eh]

    loc_4D6422:                             ; CODE XREF: sub_4D5F00+51Dj
    sub     eax, 12h
    mov     [esp+40h+var_24], ecx
    neg     eax
    sbb     eax, eax
    add     ecx, edx
    and     al, 0F8h
    mov     [esp+40h+var_28], ecx
    add     eax, 0Bh
    cmp     ebp, ecx
    jnb     short loc_4D6477

    loc_4D643C:                             ; CODE XREF: sub_4D5F00+571j
    mov     ecx, [esp+40h+var_30]
    test    ecx, ecx
    jz      loc_4D68B2
    mov     edx, ecx
    xor     ecx, ecx
    mov     cl, [edi]
    dec     edx
    mov     [esp+40h+var_30], edx
    mov     edx, ecx
    mov     ecx, ebp
    add     ebp, 8
    shl     edx, cl
    mov     ecx, [esp+40h+var_28]
    mov     [esp+40h+arg_8], 0
    or      esi, edx
    inc     edi
    cmp     ebp, ecx
    mov     [esp+40h+var_2C], edi
    jb      short loc_4D643C
    mov     edx, [esp+40h+var_8]

    loc_4D6477:                             ; CODE XREF: sub_4D5F00+53Aj
    mov     ecx, edx
    shr     esi, cl
    mov     ecx, [esp+40h+var_24]
    mov     ecx, dword_50C218[ecx*4]
    and     ecx, esi
    add     eax, ecx
    mov     ecx, [esp+40h+var_24]
    shr     esi, cl
    add     ecx, edx
    sub     ebp, ecx
    mov     ecx, [ebx+8]
    mov     [esp+40h+var_24], ecx
    mov     ecx, [ebx+4]
    mov     edx, ecx
    and     ecx, 1Fh
    shr     edx, 5
    and     edx, 1Fh
    lea     ecx, [edx+ecx+102h]
    mov     edx, [esp+40h+var_24]
    add     edx, eax
    cmp     edx, ecx
    ja      loc_4D68F0
    mov     edx, [esp+40h+var_4]
    mov     ecx, [esp+40h+var_24]
    cmp     edx, 10h
    jnz     short loc_4D64D4
    cmp     ecx, 1
    jb      loc_4D68F0

    loc_4D64D4:                             ; CODE XREF: sub_4D5F00+5C9j
    cmp     edx, 10h
    jnz     short loc_4D64E2
    mov     edx, [ebx+0Ch]
    mov     edx, [edx+ecx*4-4]
    jmp     short loc_4D64E4
    ; ---------------------------------------------------------------------------

    loc_4D64E2:                             ; CODE XREF: sub_4D5F00+5D7j
    xor     edx, edx

    loc_4D64E4:                             ; CODE XREF: sub_4D5F00+5E0j
                                            ; sub_4D5F00+5EDj
    mov     edi, [ebx+0Ch]
    inc     ecx
    dec     eax
    mov     [edi+ecx*4-4], edx
    jnz     short loc_4D64E4
    mov     edi, [esp+40h+var_2C]
    mov     [ebx+8], ecx

    loc_4D64F6:                             ; CODE XREF: sub_4D5F00+510j
    mov     eax, [ebx+4]
    mov     ecx, [ebx+8]
    mov     edx, eax
    and     eax, 1Fh
    shr     edx, 5
    and     edx, 1Fh
    lea     eax, [edx+eax+102h]
    cmp     ecx, eax
    jb      loc_4D639B

    loc_4D6516:                             ; CODE XREF: sub_4D5F00+495j
    mov     ecx, [esp+40h+arg_4]
    mov     edx, [ebx+14h]
    push    ecx
    push    edx
    call    sub_4D7410
    mov     eax, [ebx+4]
    lea     edx, [esp+40h+var_20]
    mov     ecx, [esp+40h+arg_4]
    mov     dword ptr [ebx+14h], 0
    push    ecx
    lea     ecx, [esp+44h+var_1C]
    push    edx
    push    ecx
    lea     edx, [esp+4Ch+var_24]
    lea     ecx, [esp+4Ch+var_28]
    push    edx
    mov     edx, [ebx+0Ch]
    push    ecx
    mov     ecx, eax
    shr     ecx, 5
    and     ecx, 1Fh
    and     eax, 1Fh
    inc     ecx
    push    edx
    add     eax, 101h
    push    ecx
    push    eax
    mov     [esp+60h+var_28], 9
    mov     [esp+60h+var_24], 6
    call    sub_4D7150
    test    eax, eax
    jnz     loc_4D6938
    mov     edx, [esp+40h+arg_4]
    mov     eax, [esp+40h+var_20]
    mov     ecx, [esp+40h+var_1C]
    push    edx
    mov     edx, [esp+44h+var_24]
    push    eax
    mov     eax, [esp+48h+var_28]
    push    ecx
    push    edx
    push    eax
    call    sub_4D7450
    test    eax, eax
    mov     [esp+40h+var_4], eax
    jz      loc_4D697D
    mov     eax, [esp+40h+arg_4]
    mov     ecx, [ebx+0Ch]
    push    ecx
    mov     edx, [eax+28h]
    push    edx
    call    dword ptr [eax+24h]
    mov     dword ptr [ebx], 6
    mov     eax, [esp+48h+var_C]
    mov     ecx, [esp+48h+var_24]
    mov     edx, [esp+48h+var_28]
    mov     [ebx+0Ch], eax
    mov     [ebx+4], ecx
    mov     [ebx+8], edx
    jmp     short loc_4D65D9
    ; ---------------------------------------------------------------------------

    loc_4D65D1:                             ; CODE XREF: sub_4D5F00+4Dj
                                            ; DATA XREF: .text:004D6B34o
    mov     esi, [esp+40h+var_28]           ; case 0x6
    mov     edi, [esp+40h+var_2C]

    loc_4D65D9:                             ; CODE XREF: sub_4D5F00+6CFj
    mov     eax, [esp+40h+arg_4]
    mov     ecx, [esp+40h+var_30]
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     ebp, [eax+8]
    mov     [eax+4], ecx
    mov     ecx, [eax]
    mov     edx, edi
    sub     edx, ecx
    mov     ecx, [esp+40h+arg_0]
    add     ebp, edx
    mov     edx, [esp+40h+arg_8]
    push    edx
    push    eax
    mov     [eax+8], ebp
    mov     [eax], edi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7490
    cmp     eax, 1
    jnz     loc_4D69D6
    mov     esi, [esp+40h+arg_4]
    mov     eax, [ebx+0Ch]
    push    esi
    push    eax
    mov     [esp+48h+arg_8], 0
    call    sub_4D7C20
    mov     ecx, [ebx+8]
    push    esi
    push    ecx
    call    sub_4D7410
    mov     edx, [ebx+4]
    push    esi
    push    edx
    call    sub_4D7410
    mov     eax, [esi+4]
    mov     ecx, [ebx+20h]
    mov     edi, [esi]
    mov     ebp, [ebx+1Ch]
    mov     [esp+40h+var_30], eax
    mov     eax, [ebx+2Ch]
    mov     [esp+40h+var_28], ecx
    mov     ecx, [ebx+30h]
    cmp     ecx, eax
    mov     [esp+40h+var_2C], edi
    mov     [esp+40h+arg_0], ecx
    jnb     short loc_4D666A
    sub     eax, ecx
    dec     eax
    jmp     short loc_4D666F
    ; ---------------------------------------------------------------------------

    loc_4D666A:                             ; CODE XREF: sub_4D5F00+763j
    mov     eax, [ebx+28h]
    sub     eax, ecx

    loc_4D666F:                             ; CODE XREF: sub_4D5F00+768j
    mov     [esp+40h+var_24], eax
    mov     eax, [ebx+18h]
    test    eax, eax
    jnz     loc_4D69EC
    mov     dword ptr [ebx], 0
    jmp     loc_4D5F42
    ; ---------------------------------------------------------------------------

    loc_4D6689:                             ; CODE XREF: sub_4D5F00+67j
    mov     eax, [esp+40h+arg_4]
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     edx, edi
    mov     ecx, [eax]
    mov     ebp, [eax+8]
    sub     edx, ecx
    mov     ecx, [esp+40h+arg_0]
    add     ebp, edx
    mov     edx, [esp+40h+arg_8]
    push    edx
    push    eax
    mov     dword ptr [eax+4], 0
    mov     [eax+8], ebp
    mov     [eax], edi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D66C7:                             ; CODE XREF: sub_4D5F00+B1j
                                            ; DATA XREF: .text:004D6B68o
    mov     eax, [esp+40h+arg_4]
    mov     edx, [esp+40h+var_30]
    mov     dword ptr [ebx], 9
    add     ebp, 0FFFFFFFDh
    shr     esi, 3
    mov     dword ptr [eax+18h], offset aInvalidBlockTy ; "invalid block type"
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     ebp, [eax]
    mov     esi, [eax+8]
    mov     ecx, edi
    sub     ecx, ebp
    mov     [eax+4], edx
    mov     edx, [esp+40h+arg_0]
    add     esi, ecx
    push    0FFFFFFFDh
    push    eax
    mov     [eax+8], esi
    mov     [eax], edi
    push    ebx
    mov     [ebx+30h], edx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D6715:                             ; CODE XREF: sub_4D5F00+15Fj
    mov     ecx, [esp+40h+arg_4]
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     ebp, [ecx]
    mov     edi, [ecx+8]
    mov     [ecx+4], edx
    mov     edx, eax
    sub     edx, ebp
    mov     [ecx], eax
    mov     eax, [esp+40h+arg_0]
    add     edi, edx
    mov     edx, [esp+40h+arg_8]
    mov     [ecx+8], edi
    push    edx
    push    ecx
    push    ebx
    mov     [ebx+30h], eax
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D674F:                             ; CODE XREF: sub_4D5F00+194j
    mov     ecx, [esp+40h+arg_4]
    mov     dword ptr [ebx], 9
    mov     edx, eax
    push    0FFFFFFFDh
    mov     dword ptr [ecx+18h], offset aInvalidStoredB ; "invalid stored block lengths"
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     ebp, [ecx]
    mov     [ecx+4], edi
    mov     edi, [ecx+8]
    sub     edx, ebp
    mov     [ecx], eax
    mov     eax, [esp+44h+arg_0]
    add     edi, edx
    push    ecx
    mov     [ecx+8], edi
    push    ebx
    mov     [ebx+30h], eax
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D6793:                             ; CODE XREF: sub_4D5F00+1BFj
    mov     ecx, [esp+40h+var_28]
    mov     eax, [esp+40h+arg_4]
    mov     [ebx+20h], ecx
    mov     ecx, [esp+40h+var_2C]
    mov     [ebx+1Ch], ebp
    mov     ebp, [eax]
    mov     edi, [eax+8]
    mov     edx, ecx
    sub     edx, ebp
    mov     [eax], ecx
    mov     ecx, [esp+40h+arg_0]
    add     edi, edx
    mov     edx, [esp+40h+arg_8]
    mov     dword ptr [eax+4], 0
    push    edx
    push    eax
    mov     [eax+8], edi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D67D9:                             ; CODE XREF: sub_4D5F00+261j
    mov     eax, [esp+40h+var_28]
    mov     ecx, [esp+40h+arg_4]
    mov     [ebx+20h], eax
    mov     eax, [esp+40h+var_30]
    mov     [ebx+1Ch], ebp
    mov     ebp, [ecx]
    mov     edi, [ecx+8]
    mov     [ecx+4], eax
    mov     eax, [esp+40h+var_2C]
    mov     esi, eax
    mov     [ecx], eax
    sub     esi, ebp
    add     edi, esi
    mov     [ecx+8], edi
    mov     [ebx+30h], edx
    mov     edx, [esp+40h+arg_8]
    push    edx
    push    ecx
    push    ebx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D681B:                             ; CODE XREF: sub_4D5F00+37Cj
    mov     eax, [esp+4Ch+var_4]
    mov     edx, [esp+4Ch+var_3C]
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     ebp, [eax]
    mov     esi, [eax+8]
    mov     ecx, edi
    mov     [eax+4], edx
    mov     edx, [esp+4Ch+var_8]
    sub     ecx, ebp
    add     esi, ecx
    push    0FFFFFFFCh
    push    eax
    mov     [eax+8], esi
    mov     [eax], edi
    push    ebx
    mov     [ebx+30h], edx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D6856:                             ; CODE XREF: sub_4D5F00+338j
                                            ; sub_4D5F00+34Cj
    mov     eax, [esp+40h+arg_4]
    mov     dword ptr [ebx], 9
    mov     dword ptr [eax+18h], offset aTooManyLengthO ; "too many length or distance symbols"
    jmp     loc_4D6901
    ; ---------------------------------------------------------------------------

    loc_4D686C:                             ; CODE XREF: sub_4D5F00+462j
    cmp     eax, 0FFFFFFFDh
    jmp     loc_4D693B
    ; ---------------------------------------------------------------------------

    loc_4D6874:                             ; CODE XREF: sub_4D5F00+2F4j
                                            ; sub_4D5F00+4A8j
    mov     eax, [esp+40h+arg_4]
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     ecx, edi
    mov     ebp, [eax]
    mov     esi, [eax+8]
    mov     edx, [esp+40h+arg_0]
    sub     ecx, ebp
    add     esi, ecx
    mov     ecx, [esp+40h+arg_8]
    push    ecx
    push    eax
    mov     dword ptr [eax+4], 0
    mov     [eax+8], esi
    mov     [eax], edi
    push    ebx
    mov     [ebx+30h], edx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D68B2:                             ; CODE XREF: sub_4D5F00+3BAj
                                            ; sub_4D5F00+542j
    mov     eax, [esp+40h+arg_4]
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     edx, edi
    mov     ecx, [eax]
    mov     ebp, [eax+8]
    sub     edx, ecx
    mov     ecx, [esp+40h+arg_0]
    add     ebp, edx
    mov     edx, [esp+40h+arg_8]
    push    edx
    push    eax
    mov     dword ptr [eax+4], 0
    mov     [eax+8], ebp
    mov     [eax], edi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D68F0:                             ; CODE XREF: sub_4D5F00+5B8j
                                            ; sub_4D5F00+5CEj
    mov     eax, [esp+40h+arg_4]
    mov     dword ptr [ebx], 9
    mov     dword ptr [eax+18h], offset aInvalidBitLeng ; "invalid bit length repeat"

    loc_4D6901:                             ; CODE XREF: sub_4D5F00+967j
    mov     ecx, [esp+40h+var_30]
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     ebp, [eax]
    mov     esi, [eax+8]
    mov     edx, edi
    sub     edx, ebp
    mov     [eax+4], ecx
    mov     ecx, [esp+40h+arg_0]
    add     esi, edx
    push    0FFFFFFFDh
    push    eax
    mov     [eax+8], esi
    mov     [eax], edi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D6938:                             ; CODE XREF: sub_4D5F00+675j
    cmp     eax, 0FFFFFFFDh

    loc_4D693B:                             ; CODE XREF: sub_4D5F00+96Fj
    jnz     short loc_4D6943
    mov     dword ptr [ebx], 9

    loc_4D6943:                             ; CODE XREF: sub_4D5F00+A3Bj
    mov     ecx, [esp+40h+arg_4]
    mov     edx, [esp+40h+var_30]
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     esi, [ecx]
    mov     ebp, [ecx+8]
    mov     [ecx+4], edx
    mov     edx, edi
    sub     edx, esi
    push    eax
    add     ebp, edx
    mov     edx, [esp+44h+arg_0]
    push    ecx
    mov     [ecx+8], ebp
    mov     [ecx], edi
    push    ebx
    mov     [ebx+30h], edx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D697D:                             ; CODE XREF: sub_4D5F00+69Fj
    mov     eax, [esp+40h+arg_4]
    mov     ecx, [esp+40h+var_20]
    push    eax
    push    ecx
    call    sub_4D7410
    mov     edx, [esp+40h+arg_4]
    mov     eax, [esp+40h+var_1C]
    push    edx
    push    eax
    call    sub_4D7410

    loc_4D699B:                             ; CODE XREF: sub_4D5F00+112j
    mov     eax, [esp+40h+arg_4]
    mov     ecx, [esp+40h+var_30]
    mov     [ebx+20h], esi
    mov     [ebx+1Ch], ebp
    mov     ebp, [eax]
    mov     esi, [eax+8]
    mov     edx, edi
    mov     [eax+4], ecx
    mov     ecx, [esp+40h+arg_0]
    sub     edx, ebp
    add     esi, edx
    push    0FFFFFFFCh
    push    eax
    mov     [eax+8], esi
    mov     [eax], edi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D69D6:                             ; CODE XREF: sub_4D5F00+710j
    mov     edx, [esp+40h+arg_4]
    push    eax
    push    edx
    push    ebx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D69EC:                             ; CODE XREF: sub_4D5F00+778j
    cmp     ebp, 7
    jbe     short loc_4D69FE
    mov     edx, [esp+40h+var_30]
    sub     ebp, 8
    inc     edx
    dec     edi
    mov     [esp+40h+var_30], edx

    loc_4D69FE:                             ; CODE XREF: sub_4D5F00+AEFj
    mov     dword ptr [ebx], 7
    jmp     short loc_4D6A12
    ; ---------------------------------------------------------------------------

    loc_4D6A06:                             ; CODE XREF: sub_4D5F00+4Dj
                                            ; DATA XREF: .text:004D6B34o
    mov     ecx, [esp+40h+arg_0]            ; case 0x7
    mov     edi, [esp+40h+var_2C]
    mov     esi, [esp+40h+arg_4]

    loc_4D6A12:                             ; CODE XREF: sub_4D5F00+B04j
    mov     eax, [esp+40h+arg_8]
    mov     [ebx+30h], ecx
    push    eax
    push    esi
    push    ebx
    call    sub_4D7C40
    mov     ecx, [ebx+30h]
    mov     edx, [ebx+2Ch]
    cmp     edx, ecx
    jz      short loc_4D6A61
    mov     edx, [esp+40h+var_28]
    mov     [ebx+1Ch], ebp
    mov     [ebx+20h], edx
    mov     edx, [esp+40h+var_30]
    mov     ebp, [esi]
    mov     [esi+4], edx
    mov     edx, edi
    push    eax
    sub     edx, ebp
    mov     ebp, [esi+8]
    add     ebp, edx
    push    esi
    mov     [esi+8], ebp
    mov     [esi], edi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D6A61:                             ; CODE XREF: sub_4D5F00+B29j
    mov     dword ptr [ebx], 8
    jmp     short loc_4D6A75
    ; ---------------------------------------------------------------------------

    loc_4D6A69:                             ; CODE XREF: sub_4D5F00+4Dj
                                            ; DATA XREF: .text:004D6B34o
    mov     ecx, [esp+40h+arg_0]            ; case 0x8
    mov     edi, [esp+40h+var_2C]
    mov     esi, [esp+40h+arg_4]

    loc_4D6A75:                             ; CODE XREF: sub_4D5F00+B67j
    mov     eax, [esp+40h+var_28]
    mov     edx, [esp+40h+var_30]
    mov     [ebx+20h], eax
    mov     [ebx+1Ch], ebp
    mov     ebp, [esi+8]
    mov     [esi+4], edx
    mov     edx, [esi]
    mov     eax, edi
    sub     eax, edx
    push    1
    add     ebp, eax
    push    esi
    mov     [esi+8], ebp
    mov     [esi], edi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D6AAC:                             ; CODE XREF: sub_4D5F00+4Dj
                                            ; DATA XREF: .text:004D6B34o
    mov     ecx, [esp+40h+var_28]           ; case 0x9
    mov     eax, [esp+40h+arg_4]
    mov     edx, [esp+40h+var_30]
    mov     [ebx+20h], ecx
    mov     ecx, [esp+40h+var_2C]
    mov     [ebx+1Ch], ebp
    mov     edi, [eax]
    mov     esi, [eax+8]
    mov     [eax+4], edx
    mov     edx, ecx
    sub     edx, edi
    mov     [eax], ecx
    mov     ecx, [esp+40h+arg_0]
    add     esi, edx
    push    0FFFFFFFDh
    push    eax
    mov     [eax+8], esi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D6AEF:                             ; CODE XREF: sub_4D5F00+47j
    mov     edx, [esp+40h+var_28]           ; default
    mov     eax, [esp+40h+arg_4]
    mov     ecx, [esp+40h+var_30]
    mov     [ebx+20h], edx
    mov     [ebx+1Ch], ebp
    mov     edi, [eax]
    mov     esi, [eax+8]
    mov     [eax+4], ecx
    mov     ecx, [esp+40h+var_2C]
    push    0FFFFFFFEh
    mov     edx, ecx
    mov     [eax], ecx
    mov     ecx, [esp+44h+arg_0]
    sub     edx, edi
    add     esi, edx
    push    eax
    mov     [eax+8], esi
    push    ebx
    mov     [ebx+30h], ecx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 30h
    retn    0Ch
    sub_4D5F00 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4D6B34 dd offset loc_4D5F54         ; DATA XREF: sub_4D5F00+4Dr
    dd offset loc_4D604A                    ; jump table for switch statement
    dd offset loc_4D60B9
    dd offset loc_4D61E1
    dd offset loc_4D6297
    dd offset loc_4D6373
    dd offset loc_4D65D1
    dd offset loc_4D6A06
    dd offset loc_4D6A69
    dd offset loc_4D6AAC
    off_4D6B5C dd offset loc_4D5FB8         ; DATA XREF: sub_4D5F00+B1r
    dd offset loc_4D5FD6
    dd offset loc_4D6035
    dd offset loc_4D66C7
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D6B70 proc near                    ; CODE XREF: sub_4D35A0+25p
                                            ; sub_4D35F0+F4p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    push    esi
    mov     esi, [esp+4+arg_4]
    push    edi
    mov     edi, [esp+8+arg_0]
    push    eax
    push    esi
    push    edi
    call    sub_4D5E00
    mov     ecx, [edi+24h]
    mov     edx, [esi+28h]
    push    ecx
    push    edx
    call    dword ptr [esi+24h]
    mov     eax, [esi+28h]
    push    edi
    push    eax
    call    dword ptr [esi+24h]
    pop     edi
    xor     eax, eax
    pop     esi
    retn    0Ch
    sub_4D6B70 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D6BA0 proc near                    ; CODE XREF: .text:004D3C3Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     edx, [esp+arg_8]
    mov     eax, [esp+arg_0]
    mov     ecx, edx
    push    ebx
    push    esi
    mov     esi, [esp+8+arg_4]
    mov     ebx, ecx
    push    edi
    mov     edi, [eax+24h]
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb
    mov     ecx, [eax+24h]
    pop     edi
    add     ecx, edx
    pop     esi
    mov     [eax+30h], ecx
    mov     [eax+2Ch], ecx
    pop     ebx
    retn    0Ch
    sub_4D6BA0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D6BE0 proc near                    ; CODE XREF: sub_4D5F00+45Bp

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_8]
    push    edi
    mov     edi, [esp+8+arg_C]
    mov     ecx, [esp+8+arg_0]
    push    edi
    push    eax
    push    esi
    push    0
    push    0
    push    13h
    push    13h
    push    ecx
    call    sub_4D6C60
    cmp     eax, 0FFFFFFFDh
    jnz     short loc_4D6C14
    mov     dword ptr [edi+18h], offset aOversubscribed ; "oversubscribed dynamic bit lengths tree"...
    pop     edi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4D6C14:                             ; CODE XREF: sub_4D6BE0+26j
    cmp     eax, 0FFFFFFFBh
    jnz     short loc_4D6C53
    mov     ecx, [esi]
    xor     eax, eax
    test    ecx, ecx
    jz      short loc_4D6C2F

    loc_4D6C21:                             ; CODE XREF: sub_4D6BE0+4Dj
    mov     edx, [ecx-4]
    mov     [ecx-4], eax
    mov     eax, ecx
    mov     ecx, edx
    test    edx, edx
    jnz     short loc_4D6C21

    loc_4D6C2F:                             ; CODE XREF: sub_4D6BE0+3Fj
    test    eax, eax
    jz      short loc_4D6C47

    loc_4D6C33:                             ; CODE XREF: sub_4D6BE0+65j
    mov     edx, [edi+28h]
    mov     esi, [eax-4]
    sub     eax, 8
    push    eax
    push    edx
    call    dword ptr [edi+24h]
    test    esi, esi
    mov     eax, esi
    jnz     short loc_4D6C33

    loc_4D6C47:                             ; CODE XREF: sub_4D6BE0+51j
    mov     dword ptr [edi+18h], offset aIncompleteDyna ; "incomplete dynamic bit lengths tree"
    mov     eax, 0FFFFFFFDh

    loc_4D6C53:                             ; CODE XREF: sub_4D6BE0+37j
    pop     edi
    pop     esi
    retn    10h
    sub_4D6BE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D6C60 proc near                    ; CODE XREF: sub_4D6BE0+1Ep
                                            ; sub_4D7150+2Cp ...

    var_584= dword ptr -584h
    var_580= dword ptr -580h
    var_57C= dword ptr -57Ch
    var_578= dword ptr -578h
    var_574= dword ptr -574h
    var_570= dword ptr -570h
    var_56C= dword ptr -56Ch
    var_560= dword ptr -560h
    var_55C= dword ptr -55Ch
    var_558= dword ptr -558h
    var_554= dword ptr -554h
    var_550= dword ptr -550h
    var_54C= dword ptr -54Ch
    var_548= dword ptr -548h
    var_544= dword ptr -544h
    var_540= dword ptr -540h
    var_53C= dword ptr -53Ch
    var_538= dword ptr -538h
    var_534= dword ptr -534h
    var_530= dword ptr -530h
    var_52C= dword ptr -52Ch
    var_528= dword ptr -528h
    var_524= dword ptr -524h
    var_520= dword ptr -520h
    var_51C= dword ptr -51Ch
    var_518= dword ptr -518h
    var_514= dword ptr -514h
    var_510= dword ptr -510h
    var_50C= dword ptr -50Ch
    var_508= dword ptr -508h
    var_504= dword ptr -504h
    var_500= dword ptr -500h
    var_4FC= dword ptr -4FCh
    var_4F8= dword ptr -4F8h
    var_4C8= dword ptr -4C8h
    var_4BC= dword ptr -4BCh
    var_48C= dword ptr -48Ch
    var_480= dword ptr -480h
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    sub     esp, 578h
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+584h+arg_4]
    push    edi
    mov     edi, [esp+588h+arg_0]
    xor     ebx, ebx
    mov     ecx, edi
    mov     [esp+588h+var_53C], ebx
    mov     [esp+588h+var_538], ebx
    mov     [esp+588h+var_534], ebx
    mov     [esp+588h+var_530], ebx
    mov     [esp+588h+var_52C], ebx
    mov     [esp+588h+var_528], ebx
    mov     [esp+588h+var_524], ebx
    mov     [esp+588h+var_520], ebx
    mov     [esp+588h+var_51C], ebx
    mov     [esp+588h+var_518], ebx
    mov     [esp+588h+var_514], ebx
    mov     [esp+588h+var_510], ebx
    mov     [esp+588h+var_50C], ebx
    mov     [esp+588h+var_508], ebx
    mov     [esp+588h+var_504], ebx
    mov     [esp+588h+var_500], ebx
    mov     edx, esi

    loc_4D6CC7:                             ; CODE XREF: sub_4D6C60+78j
    mov     eax, [ecx]
    add     ecx, 4
    mov     ebp, [esp+eax*4+588h+var_53C]
    lea     eax, [esp+eax*4+588h+var_53C]
    inc     ebp
    dec     edx
    mov     [eax], ebp
    jnz     short loc_4D6CC7
    cmp     [esp+588h+var_53C], esi
    jnz     short loc_4D6D01
    mov     ecx, [esp+588h+arg_14]
    mov     edx, [esp+588h+arg_18]
    xor     eax, eax
    mov     [ecx], ebx
    mov     [edx], ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 578h
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D6D01:                             ; CODE XREF: sub_4D6C60+7Ej
    mov     esi, [esp+588h+arg_18]
    mov     ecx, 1
    lea     eax, [esp+588h+var_538]
    mov     ebp, [esi]
    mov     [esp+588h+var_574], ebp

    loc_4D6D17:                             ; CODE XREF: sub_4D6C60+C2j
    cmp     [eax], ebx
    jnz     short loc_4D6D24
    inc     ecx
    add     eax, 4
    cmp     ecx, 0Fh
    jbe     short loc_4D6D17

    loc_4D6D24:                             ; CODE XREF: sub_4D6C60+B9j
    cmp     ebp, ecx
    mov     [esp+588h+var_578], ecx
    jnb     short loc_4D6D32
    mov     [esp+588h+var_574], ecx
    mov     ebp, ecx

    loc_4D6D32:                             ; CODE XREF: sub_4D6C60+CAj
    mov     eax, 0Fh
    lea     edx, [esp+588h+var_500]

    loc_4D6D3E:                             ; CODE XREF: sub_4D6C60+E8j
    cmp     [edx], ebx
    jnz     short loc_4D6D4A
    dec     eax
    sub     edx, 4
    cmp     eax, ebx
    jnz     short loc_4D6D3E

    loc_4D6D4A:                             ; CODE XREF: sub_4D6C60+E0j
    cmp     ebp, eax
    mov     [esp+588h+var_55C], eax
    jbe     short loc_4D6D58
    mov     [esp+588h+var_574], eax
    mov     ebp, eax

    loc_4D6D58:                             ; CODE XREF: sub_4D6C60+F0j
    mov     [esi], ebp
    mov     esi, 1
    shl     esi, cl
    cmp     ecx, eax
    jnb     short loc_4D6D77
    lea     edx, [esp+ecx*4+588h+var_53C]

    loc_4D6D69:                             ; CODE XREF: sub_4D6C60+115j
    sub     esi, [edx]
    js      short loc_4D6D83
    inc     ecx
    add     edx, 4
    shl     esi, 1
    cmp     ecx, eax
    jb      short loc_4D6D69

    loc_4D6D77:                             ; CODE XREF: sub_4D6C60+103j
    mov     ecx, [esp+eax*4+588h+var_53C]
    sub     esi, ecx
    mov     [esp+588h+var_544], esi
    jns     short loc_4D6D95

    loc_4D6D83:                             ; CODE XREF: sub_4D6C60+10Bj
    mov     eax, 0FFFFFFFDh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 578h
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D6D95:                             ; CODE XREF: sub_4D6C60+121j
    add     ecx, esi
    mov     [esp+588h+var_4F8], ebx
    mov     [esp+eax*4+588h+var_53C], ecx
    xor     ecx, ecx
    dec     eax
    jz      short loc_4D6DBA
    xor     edx, edx

    loc_4D6DA9:                             ; CODE XREF: sub_4D6C60+158j
    add     ecx, [esp+edx+588h+var_538]
    add     edx, 4
    dec     eax
    mov     [esp+edx+588h+var_4F8], ecx
    jnz     short loc_4D6DA9

    loc_4D6DBA:                             ; CODE XREF: sub_4D6C60+145j
    xor     edx, edx

    loc_4D6DBC:                             ; CODE XREF: sub_4D6C60+187j
    mov     eax, [edi]
    add     edi, 4
    cmp     eax, ebx
    jz      short loc_4D6DDD
    mov     ecx, [esp+eax*4+588h+var_4FC]
    lea     eax, [esp+eax*4+588h+var_4FC]
    mov     [esp+ecx*4+588h+var_480], edx
    inc     ecx
    mov     [eax], ecx

    loc_4D6DDD:                             ; CODE XREF: sub_4D6C60+163j
    mov     eax, [esp+588h+arg_4]
    inc     edx
    cmp     edx, eax
    jb      short loc_4D6DBC
    mov     edx, [esp+588h+var_578]
    mov     ecx, [esp+588h+var_55C]
    lea     eax, [esp+588h+var_480]
    xor     edi, edi
    mov     [esp+588h+var_56C], eax
    mov     eax, ebp
    neg     eax
    cmp     edx, ecx
    mov     [esp+588h+var_560], ebx
    mov     [esp+588h+var_4FC], edi
    mov     [esp+588h+var_570], 0FFFFFFFFh
    mov     [esp+588h+var_4BC], edi
    mov     [esp+588h+var_548], edi
    jg      loc_4D70C8
    lea     ecx, [esp+edx*4+588h+var_53C]
    mov     [esp+588h+var_558], ecx

    loc_4D6E30:                             ; CODE XREF: sub_4D6C60+462j
    mov     ecx, [esp+588h+var_558]
    mov     ecx, [ecx]
    mov     esi, ecx
    dec     ecx
    test    esi, esi
    mov     [esp+588h+var_554], ecx
    jz      loc_4D70A8
    jmp     short loc_4D6E4F
    ; ---------------------------------------------------------------------------

    loc_4D6E47:                             ; CODE XREF: sub_4D6C60+438j
    mov     ecx, [esp+588h+var_554]
    mov     edx, [esp+588h+var_578]

    loc_4D6E4F:                             ; CODE XREF: sub_4D6C60+1E5j
    lea     esi, [eax+ebp]
    cmp     edx, esi
    jle     loc_4D6F74
    inc     ecx
    mov     [esp+588h+var_550], esi
    mov     [esp+588h+var_540], ecx

    loc_4D6E63:                             ; CODE XREF: sub_4D6C60+30Aj
    mov     edx, [esp+588h+var_55C]
    mov     ecx, [esp+588h+var_570]
    mov     edi, [esp+588h+var_550]
    add     eax, ebp
    sub     edx, eax
    inc     ecx
    add     edi, ebp
    cmp     edx, ebp
    mov     [esp+588h+var_570], ecx
    mov     [esp+588h+var_54C], eax
    mov     [esp+588h+var_550], edi
    jbe     short loc_4D6E88
    mov     edx, ebp

    loc_4D6E88:                             ; CODE XREF: sub_4D6C60+224j
    mov     ebx, [esp+588h+var_578]
    sub     ebx, eax
    mov     eax, 1
    mov     ecx, ebx
    shl     eax, cl
    cmp     eax, [esp+588h+var_540]
    jbe     short loc_4D6EC8
    mov     edi, [esp+588h+var_554]
    mov     esi, [esp+588h+var_558]
    or      ecx, 0FFFFFFFFh
    sub     ecx, edi
    add     eax, ecx
    cmp     ebx, edx
    jnb     short loc_4D6EC8
    inc     ebx
    cmp     ebx, edx
    jnb     short loc_4D6EC8

    loc_4D6EB5:                             ; CODE XREF: sub_4D6C60+266j
    mov     ecx, [esi+4]
    add     esi, 4
    shl     eax, 1
    cmp     eax, ecx
    jbe     short loc_4D6EC8
    sub     eax, ecx
    inc     ebx
    cmp     ebx, edx
    jb      short loc_4D6EB5

    loc_4D6EC8:                             ; CODE XREF: sub_4D6C60+23Bj
                                            ; sub_4D6C60+24Ej ...
    mov     esi, [esp+588h+arg_1C]
    mov     edi, 1
    mov     ecx, ebx
    push    8
    mov     eax, [esi+28h]
    shl     edi, cl
    lea     edx, [edi+1]
    push    edx
    push    eax
    call    dword ptr [esi+20h]
    test    eax, eax
    jz      loc_4D70F4
    mov     edx, [esp+588h+arg_14]
    lea     ecx, [eax+8]
    add     eax, 4
    mov     [esp+588h+var_548], ecx
    mov     [edx], ecx
    mov     edx, [esp+588h+var_570]
    mov     [esp+588h+arg_14], eax
    mov     dword ptr [eax], 0
    lea     esi, ds:0[edx*4]
    test    edx, edx
    lea     eax, [esp+esi+588h+var_4BC]
    mov     [eax], ecx
    jz      short loc_4D6F58
    mov     ebp, [esp+588h+var_560]
    mov     edx, [esp+588h+var_574]
    mov     [esp+esi+588h+var_4FC], ebp
    mov     esi, ecx
    mov     ecx, [esp+588h+var_54C]
    mov     eax, [eax-4]
    sub     ecx, edx
    mov     [esp+21h], dl
    shr     ebp, cl
    mov     [esp+20h], bl
    mov     ecx, [esp+20h]
    mov     [esp+24h], esi
    mov     [eax+ebp*8], ecx
    mov     [eax+ebp*8+4], esi

    loc_4D6F58:                             ; CODE XREF: sub_4D6C60+2C3j
    mov     edx, [esp+588h+var_550]
    mov     eax, [esp+588h+var_578]
    mov     ebp, [esp+588h+var_574]
    cmp     eax, edx
    mov     eax, [esp+588h+var_54C]
    jg      loc_4D6E63
    mov     ebx, [esp+588h+var_560]

    loc_4D6F74:                             ; CODE XREF: sub_4D6C60+1F4j
    mov     cl, byte ptr [esp+588h+var_578]
    mov     edx, [esp+588h+arg_4]
    sub     cl, al
    mov     [esp+21h], cl
    mov     ecx, [esp+588h+var_56C]
    lea     edx, [esp+edx*4+588h+var_480]
    cmp     ecx, edx
    jb      short loc_4D6F9B
    mov     byte ptr [esp+20h], 0C0h
    jmp     short loc_4D6FEB
    ; ---------------------------------------------------------------------------

    loc_4D6F9B:                             ; CODE XREF: sub_4D6C60+332j
    mov     ecx, [ecx]
    mov     edx, [esp+588h+arg_8]
    cmp     ecx, edx
    jnb     short loc_4D6FBC
    cmp     ecx, 100h
    sbb     edx, edx
    and     edx, 0FFFFFFA0h
    add     edx, 60h
    mov     [esp+20h], dl
    jmp     short loc_4D6FDC
    ; ---------------------------------------------------------------------------

    loc_4D6FBC:                             ; CODE XREF: sub_4D6C60+346j
    sub     ecx, edx
    mov     edx, [esp+59Ch]
    shl     ecx, 2
    mov     dl, [ecx+edx]
    add     dl, 50h
    mov     [esp+20h], dl
    mov     edx, [esp+598h]
    mov     ecx, [ecx+edx]

    loc_4D6FDC:                             ; CODE XREF: sub_4D6C60+35Aj
    mov     [esp+24h], ecx
    mov     ecx, [esp+588h+var_56C]
    add     ecx, 4
    mov     [esp+588h+var_56C], ecx

    loc_4D6FEB:                             ; CODE XREF: sub_4D6C60+339j
    mov     ecx, [esp+588h+var_578]
    mov     esi, 1
    sub     ecx, eax
    mov     edx, ebx
    shl     esi, cl
    mov     ecx, eax
    shr     edx, cl
    cmp     edx, edi
    jnb     short loc_4D702D
    mov     ecx, [esp+588h+var_548]
    lea     ebx, ds:0[esi*8]
    lea     ecx, [ecx+edx*8]

    loc_4D7010:                             ; CODE XREF: sub_4D6C60+3C3j
    mov     ebp, [esp+20h]
    add     edx, esi
    mov     [ecx], ebp
    mov     ebp, [esp+24h]
    mov     [ecx+4], ebp
    add     ecx, ebx
    cmp     edx, edi
    jb      short loc_4D7010
    mov     ebp, [esp+588h+var_574]
    mov     ebx, [esp+588h+var_560]

    loc_4D702D:                             ; CODE XREF: sub_4D6C60+3A0j
    mov     edx, [esp+588h+var_578]
    lea     ecx, [edx-1]
    mov     edx, 1
    shl     edx, cl
    test    ebx, edx
    jz      short loc_4D7047

    loc_4D703F:                             ; CODE XREF: sub_4D6C60+3E5j
    xor     ebx, edx
    shr     edx, 1
    test    ebx, edx
    jnz     short loc_4D703F

    loc_4D7047:                             ; CODE XREF: sub_4D6C60+3DDj
    mov     ecx, [esp+588h+var_570]
    xor     ebx, edx
    mov     esi, 1
    mov     [esp+588h+var_560], ebx
    lea     edx, [esp+ecx*4+588h+var_4FC]
    mov     ecx, eax
    shl     esi, cl
    mov     ecx, [edx]
    dec     esi
    and     esi, ebx
    cmp     esi, ecx
    jz      short loc_4D708B

    loc_4D706A:                             ; CODE XREF: sub_4D6C60+429j
    mov     esi, [esp+588h+var_570]
    sub     eax, ebp
    dec     esi
    mov     ecx, eax
    mov     [esp+588h+var_570], esi
    mov     esi, 1
    shl     esi, cl
    mov     ecx, [edx-4]
    sub     edx, 4
    dec     esi
    and     esi, ebx
    cmp     esi, ecx
    jnz     short loc_4D706A

    loc_4D708B:                             ; CODE XREF: sub_4D6C60+408j
    mov     ecx, [esp+588h+var_554]
    mov     edx, ecx
    dec     ecx
    test    edx, edx
    mov     [esp+588h+var_554], ecx
    jnz     loc_4D6E47
    mov     esi, [esp+588h+var_544]
    mov     edx, [esp+588h+var_578]
    jmp     short loc_4D70AC
    ; ---------------------------------------------------------------------------

    loc_4D70A8:                             ; CODE XREF: sub_4D6C60+1DFj
    mov     esi, [esp+588h+var_544]

    loc_4D70AC:                             ; CODE XREF: sub_4D6C60+446j
    mov     ecx, [esp+588h+var_558]
    inc     edx
    add     ecx, 4
    mov     [esp+588h+var_578], edx
    mov     [esp+588h+var_558], ecx
    mov     ecx, [esp+588h+var_55C]
    cmp     edx, ecx
    jle     loc_4D6E30

    loc_4D70C8:                             ; CODE XREF: sub_4D6C60+1C2j
    test    esi, esi
    jz      short loc_4D70E5
    cmp     [esp+588h+var_55C], 1
    jz      short loc_4D70E5
    mov     eax, 0FFFFFFFBh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 578h
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D70E5:                             ; CODE XREF: sub_4D6C60+46Aj
                                            ; sub_4D6C60+471j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 578h
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D70F4:                             ; CODE XREF: sub_4D6C60+287j
    mov     eax, [esp+588h+var_570]
    test    eax, eax
    jz      short loc_4D712F
    mov     ecx, [esp+588h+var_4BC]
    xor     eax, eax
    test    ecx, ecx
    jz      short loc_4D7117

    loc_4D7109:                             ; CODE XREF: sub_4D6C60+4B5j
    mov     edx, [ecx-4]
    mov     [ecx-4], eax
    mov     eax, ecx
    mov     ecx, edx
    test    edx, edx
    jnz     short loc_4D7109

    loc_4D7117:                             ; CODE XREF: sub_4D6C60+4A7j
    test    eax, eax
    jz      short loc_4D712F

    loc_4D711B:                             ; CODE XREF: sub_4D6C60+4CDj
    mov     edi, [eax-4]
    sub     eax, 8
    push    eax
    mov     eax, [esi+28h]
    push    eax
    call    dword ptr [esi+24h]
    test    edi, edi
    mov     eax, edi
    jnz     short loc_4D711B

    loc_4D712F:                             ; CODE XREF: sub_4D6C60+49Aj
                                            ; sub_4D6C60+4B9j
    pop     edi
    pop     esi
    pop     ebp
    mov     eax, 0FFFFFFFCh
    pop     ebx
    add     esp, 578h
    retn    20h
    sub_4D6C60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D7150 proc near                    ; CODE XREF: sub_4D5F00+66Ep

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch
    arg_1C= dword ptr  20h

    mov     eax, [esp+arg_C]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_14]
    push    esi
    mov     esi, [esp+0Ch+arg_1C]
    mov     ebx, [esp+0Ch+arg_8]
    push    edi
    mov     edi, [esp+10h+arg_0]
    push    esi
    push    eax
    push    ebp
    push    offset dword_50BFE0
    push    offset dword_50BF60
    push    101h
    push    edi
    push    ebx
    call    sub_4D6C60
    test    eax, eax
    jz      short loc_4D71E3
    cmp     eax, 0FFFFFFFDh
    jnz     short loc_4D7198
    mov     dword ptr [esi+18h], offset aOversubscrib_0 ; "oversubscribed literal/length tree"
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D7198:                             ; CODE XREF: sub_4D7150+38j
    cmp     eax, 0FFFFFFFBh
    jnz     loc_4D729D
    mov     ecx, [ebp+0]
    xor     eax, eax
    test    ecx, ecx
    jz      short loc_4D71B8

    loc_4D71AA:                             ; CODE XREF: sub_4D7150+66j
    mov     edx, [ecx-4]
    mov     [ecx-4], eax
    mov     eax, ecx
    mov     ecx, edx
    test    edx, edx
    jnz     short loc_4D71AA

    loc_4D71B8:                             ; CODE XREF: sub_4D7150+58j
    test    eax, eax
    jz      short loc_4D71D0

    loc_4D71BC:                             ; CODE XREF: sub_4D7150+7Ej
    mov     ecx, [esi+28h]
    mov     edi, [eax-4]
    sub     eax, 8
    push    eax
    push    ecx
    call    dword ptr [esi+24h]
    test    edi, edi
    mov     eax, edi
    jnz     short loc_4D71BC

    loc_4D71D0:                             ; CODE XREF: sub_4D7150+6Aj
    mov     dword ptr [esi+18h], offset aIncompleteLite ; "incomplete literal/length tree"
    mov     eax, 0FFFFFFFDh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D71E3:                             ; CODE XREF: sub_4D7150+33j
    mov     edx, [esp+10h+arg_10]
    mov     ebp, [esp+10h+arg_18]
    mov     eax, [esp+10h+arg_4]
    push    esi
    push    edx
    push    ebp
    push    offset dword_50C0D8
    push    offset dword_50C060
    push    0
    lea     ecx, [ebx+edi*4]
    push    eax
    push    ecx
    call    sub_4D6C60
    mov     ebx, eax
    test    ebx, ebx
    jz      loc_4D729B
    cmp     ebx, 0FFFFFFFDh
    jnz     short loc_4D7220
    mov     dword ptr [esi+18h], offset aOversubscrib_0 ; "oversubscribed literal/length tree"
    jmp     short loc_4D7260
    ; ---------------------------------------------------------------------------

    loc_4D7220:                             ; CODE XREF: sub_4D7150+C5j
    cmp     ebx, 0FFFFFFFBh
    jnz     short loc_4D7260
    mov     ecx, [ebp+0]
    xor     eax, eax
    test    ecx, ecx
    jz      short loc_4D723C

    loc_4D722E:                             ; CODE XREF: sub_4D7150+EAj
    mov     edx, [ecx-4]
    mov     [ecx-4], eax
    mov     eax, ecx
    mov     ecx, edx
    test    edx, edx
    jnz     short loc_4D722E

    loc_4D723C:                             ; CODE XREF: sub_4D7150+DCj
    test    eax, eax
    jz      short loc_4D7254

    loc_4D7240:                             ; CODE XREF: sub_4D7150+102j
    mov     edx, [esi+28h]
    mov     edi, [eax-4]
    sub     eax, 8
    push    eax
    push    edx
    call    dword ptr [esi+24h]
    test    edi, edi
    mov     eax, edi
    jnz     short loc_4D7240

    loc_4D7254:                             ; CODE XREF: sub_4D7150+EEj
    mov     dword ptr [esi+18h], offset aIncompleteLite ; "incomplete literal/length tree"
    mov     ebx, 0FFFFFFFDh

    loc_4D7260:                             ; CODE XREF: sub_4D7150+CEj
                                            ; sub_4D7150+D3j
    mov     ecx, [esp+18h+arg_C]
    xor     eax, eax
    mov     ecx, [ecx]
    test    ecx, ecx
    jz      short loc_4D727A

    loc_4D726C:                             ; CODE XREF: sub_4D7150+128j
    mov     edx, [ecx-4]
    mov     [ecx-4], eax
    mov     eax, ecx
    mov     ecx, edx
    test    edx, edx
    jnz     short loc_4D726C

    loc_4D727A:                             ; CODE XREF: sub_4D7150+11Aj
    test    eax, eax
    jz      short loc_4D7292

    loc_4D727E:                             ; CODE XREF: sub_4D7150+140j
    mov     edx, [esi+28h]
    mov     edi, [eax-4]
    sub     eax, 8
    push    eax
    push    edx
    call    dword ptr [esi+24h]
    test    edi, edi
    mov     eax, edi
    jnz     short loc_4D727E

    loc_4D7292:                             ; CODE XREF: sub_4D7150+12Cj
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    ; ---------------------------------------------------------------------------

    loc_4D729B:                             ; CODE XREF: sub_4D7150+BCj
    xor     eax, eax

    loc_4D729D:                             ; CODE XREF: sub_4D7150+4Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    20h
    sub_4D7150 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D72B0 proc near                    ; CODE XREF: sub_4D5F00+EAp

    var_4BC= dword ptr -4BCh
    var_4B8= dword ptr -4B8h
    var_498= dword ptr -498h
    var_494= dword ptr -494h
    var_490= dword ptr -490h
    var_480= dword ptr -480h
    var_240= dword ptr -240h
    var_80= dword ptr -80h
    var_20= dword ptr -20h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, dword_528990
    sub     esp, 4BCh
    test    eax, eax
    jnz     loc_4D73A8
    lea     eax, [esp+4BCh+var_4BC]
    push    edi
    mov     [esp+4C0h+var_490], eax
    mov     ecx, 90h
    mov     eax, 8
    lea     edi, [esp+4C0h+var_480]
    rep stosd
    mov     ecx, 70h
    mov     eax, 9
    lea     edi, [esp+4C0h+var_240]
    lea     edx, [esp+4C0h+var_480]
    rep stosd
    mov     ecx, 18h
    mov     eax, 7
    lea     edi, [esp+4C0h+var_80]
    mov     [esp+4C0h+var_4BC], 212h
    rep stosd
    mov     ecx, 8
    lea     edi, [esp+4C0h+var_20]
    mov     eax, ecx
    mov     [esp+4C0h+var_498], offset loc_4D73F0
    rep stosd
    lea     ecx, [esp+4C0h+var_4B8]
    mov     [esp+4C0h+var_494], 0
    push    ecx
    push    offset dword_52898C
    push    offset dword_5278F4
    push    offset dword_50BFE0
    push    offset dword_50BF60
    push    101h
    push    120h
    push    edx
    mov     dword_52898C, 7
    call    sub_4D6C60
    mov     ecx, 1Eh
    mov     eax, 5
    lea     edi, [esp+4C0h+var_480]
    mov     dword_528988, eax
    rep stosd
    lea     eax, [esp+4C0h+var_4B8]
    lea     ecx, [esp+4C0h+var_480]
    push    eax
    push    offset dword_528988
    push    offset dword_5278F0
    push    offset dword_50C0D8
    push    offset dword_50C060
    push    0
    push    1Eh
    push    ecx
    call    sub_4D6C60
    mov     dword_528990, 1
    pop     edi

    loc_4D73A8:                             ; CODE XREF: sub_4D72B0+Dj
    mov     edx, [esp+4BCh+arg_0]
    mov     eax, dword_52898C
    mov     ecx, [esp+4BCh+arg_4]
    mov     [edx], eax
    mov     edx, dword_528988
    mov     eax, [esp+4BCh+arg_8]
    mov     [ecx], edx
    mov     ecx, dword_5278F4
    mov     edx, [esp+4BCh+arg_C]
    mov     [eax], ecx
    mov     eax, dword_5278F0
    mov     [edx], eax
    xor     eax, eax
    add     esp, 4BCh
    retn    10h
    sub_4D72B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    loc_4D73F0:                             ; DATA XREF: sub_4D72B0+6Co
    mov     eax, [esp+4]
    mov     ecx, [esp+8]
    mov     edx, [eax]
    sub     edx, ecx
    mov     [eax], edx
    mov     eax, edx
    lea     eax, ds:5278F8h[eax*8]
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D7410 proc near                    ; CODE XREF: sub_4D5E00+45p
                                            ; sub_4D5E00+4Fp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     ecx, [esp+arg_0]
    xor     eax, eax
    push    esi
    push    edi
    test    ecx, ecx
    jz      short loc_4D742A

    loc_4D741C:                             ; CODE XREF: sub_4D7410+18j
    mov     edx, [ecx-4]
    mov     [ecx-4], eax
    mov     eax, ecx
    mov     ecx, edx
    test    edx, edx
    jnz     short loc_4D741C

    loc_4D742A:                             ; CODE XREF: sub_4D7410+Aj
    test    eax, eax
    jz      short loc_4D7446
    mov     edi, [esp+8+arg_4]

    loc_4D7432:                             ; CODE XREF: sub_4D7410+34j
    mov     esi, [eax-4]
    sub     eax, 8
    push    eax
    mov     eax, [edi+28h]
    push    eax
    call    dword ptr [edi+24h]
    test    esi, esi
    mov     eax, esi
    jnz     short loc_4D7432

    loc_4D7446:                             ; CODE XREF: sub_4D7410+1Cj
    pop     edi
    xor     eax, eax
    pop     esi
    retn    8
    sub_4D7410 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D7450 proc near                    ; CODE XREF: sub_4D5F00+108p
                                            ; sub_4D5F00+694p

    var_8= byte ptr -8
    var_4= byte ptr -4
    arg_0= dword ptr  4
    arg_10= dword ptr  14h

    mov     eax, [esp+arg_10]
    push    1Ah
    push    1
    mov     ecx, [eax+28h]
    push    ecx
    call    dword ptr [eax+20h]
    test    eax, eax
    jz      short locret_4D7485
    mov     dl, byte ptr [esp+arg_0]
    mov     cl, [esp+8]
    mov     [eax+10h], dl
    mov     edx, [esp+0Ch]
    mov     [eax+11h], cl
    mov     ecx, [esp+10h]
    mov     dword ptr [eax], 0
    mov     [eax+12h], edx
    mov     [eax+16h], ecx

    locret_4D7485:                          ; CODE XREF: sub_4D7450+11j
    retn    14h
    sub_4D7450 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D7490 proc near                    ; CODE XREF: sub_4D5F00+708p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 14h
    push    ebx
    mov     ebx, [esp+18h+arg_4]
    push    ebp
    push    esi
    mov     esi, [esp+20h+arg_0]
    mov     eax, [ebx]
    mov     ecx, [ebx+4]
    mov     [esp+20h+arg_4], eax
    mov     edx, [esi+20h]
    mov     eax, [esi+2Ch]
    mov     ebp, [esi+0Ch]
    mov     [esp+20h+arg_0], edx
    mov     edx, [esi+30h]
    push    edi
    mov     edi, [esi+1Ch]
    cmp     edx, eax
    mov     [esp+24h+var_14], ecx
    jnb     short loc_4D74C8
    sub     eax, edx
    dec     eax
    jmp     short loc_4D74CD
    ; ---------------------------------------------------------------------------

    loc_4D74C8:                             ; CODE XREF: sub_4D7490+31j
    mov     eax, [esi+28h]
    sub     eax, edx

    loc_4D74CD:                             ; CODE XREF: sub_4D7490+36j
    mov     [esp+24h+var_10], eax

    loc_4D74D1:                             ; CODE XREF: sub_4D7490+F4j
                                            ; sub_4D7490+1A4j ...
    mov     ecx, [ebp+0]
    cmp     ecx, 9                          ; switch 10 cases
    ja      loc_4D7BBC                      ; default
    jmp     ds:off_4D7BF8[ecx*4]            ; switch jump

    loc_4D74E4:                             ; DATA XREF: .text:004D7BF8o
    cmp     eax, 102h                       ; case 0x0
    jb      loc_4D7589
    cmp     [esp+24h+var_14], 0Ah
    jb      loc_4D7589
    mov     eax, [esp+24h+arg_0]
    mov     ecx, [esp+24h+var_14]
    mov     [esi+20h], eax
    mov     eax, [esp+24h+arg_4]
    mov     [esi+1Ch], edi
    mov     edi, [ebx]
    mov     [ebx+4], ecx
    mov     ecx, eax
    sub     ecx, edi
    mov     edi, [ebx+8]
    add     edi, ecx
    mov     [ebx], eax
    mov     [ebx+8], edi
    mov     [esi+30h], edx
    mov     edx, [ebp+16h]
    mov     eax, [ebp+12h]
    push    ebx
    push    esi
    push    edx
    xor     ecx, ecx
    mov     cl, [ebp+11h]
    xor     edx, edx
    mov     dl, [ebp+10h]
    push    eax
    push    ecx
    push    edx
    call    sub_4D7D70
    mov     edx, [ebx+4]
    mov     ecx, eax
    mov     eax, [ebx]
    mov     edi, [esi+1Ch]
    mov     [esp+24h+arg_4], eax
    mov     eax, [esi+20h]
    mov     [esp+24h+var_14], edx
    mov     edx, [esi+30h]
    mov     [esp+24h+arg_0], eax
    mov     eax, [esi+2Ch]
    cmp     edx, eax
    mov     [esp+24h+arg_8], ecx
    jnb     short loc_4D7569
    sub     eax, edx
    dec     eax
    jmp     short loc_4D756E
    ; ---------------------------------------------------------------------------

    loc_4D7569:                             ; CODE XREF: sub_4D7490+D2j
    mov     eax, [esi+28h]
    sub     eax, edx

    loc_4D756E:                             ; CODE XREF: sub_4D7490+D7j
    test    ecx, ecx
    mov     [esp+24h+var_10], eax
    jz      short loc_4D7589
    dec     ecx
    neg     ecx
    sbb     ecx, ecx
    and     ecx, 2
    add     ecx, 7
    mov     [ebp+0], ecx
    jmp     loc_4D74D1
    ; ---------------------------------------------------------------------------

    loc_4D7589:                             ; CODE XREF: sub_4D7490+59j
                                            ; sub_4D7490+64j ...
    mov     eax, [ebp+12h]
    xor     ecx, ecx
    mov     cl, [ebp+10h]
    mov     [ebp+8], eax
    mov     [ebp+0Ch], ecx
    mov     dword ptr [ebp+0], 1

    loc_4D759E:                             ; CODE XREF: sub_4D7490+4Dj
                                            ; DATA XREF: .text:004D7BF8o
    mov     eax, [ebp+0Ch]                  ; case 0x1
    cmp     edi, eax
    jnb     short loc_4D75E9

    loc_4D75A5:                             ; CODE XREF: sub_4D7490+157j
    mov     eax, [esp+24h+var_14]
    test    eax, eax
    jz      loc_4D7A14
    dec     eax
    xor     ecx, ecx
    mov     [esp+24h+var_14], eax
    mov     eax, [esp+24h+arg_4]
    mov     [esp+24h+arg_8], 0
    mov     cl, [eax]
    mov     eax, ecx
    mov     ecx, edi
    shl     eax, cl
    mov     ecx, [esp+24h+arg_0]
    add     edi, 8
    or      ecx, eax
    mov     eax, [ebp+0Ch]
    mov     [esp+24h+arg_0], ecx
    mov     ecx, [esp+24h+arg_4]
    inc     ecx
    cmp     edi, eax
    mov     [esp+24h+arg_4], ecx
    jb      short loc_4D75A5

    loc_4D75E9:                             ; CODE XREF: sub_4D7490+113j
    mov     ecx, dword_50C218[eax*4]
    mov     eax, [esp+24h+arg_0]
    and     ecx, eax
    mov     eax, [ebp+8]
    lea     eax, [eax+ecx*8]
    xor     ecx, ecx
    mov     [esp+24h+var_C], eax
    mov     cl, [eax+1]
    mov     eax, [esp+24h+arg_0]
    shr     eax, cl
    mov     [esp+24h+var_8], ecx
    mov     [esp+24h+arg_0], eax
    mov     eax, ecx
    mov     ecx, [esp+24h+var_C]
    sub     edi, eax
    xor     eax, eax
    mov     al, [ecx]
    test    eax, eax
    jnz     short loc_4D7639
    mov     ecx, [ecx+4]
    mov     eax, [esp+24h+var_10]
    mov     [ebp+8], ecx
    mov     dword ptr [ebp+0], 6
    jmp     loc_4D74D1
    ; ---------------------------------------------------------------------------

    loc_4D7639:                             ; CODE XREF: sub_4D7490+191j
    test    al, 10h
    jz      short loc_4D7659
    and     eax, 0Fh
    mov     [ebp+8], eax
    mov     eax, [ecx+4]
    mov     [ebp+4], eax
    mov     eax, [esp+24h+var_10]
    mov     dword ptr [ebp+0], 2
    jmp     loc_4D74D1
    ; ---------------------------------------------------------------------------

    loc_4D7659:                             ; CODE XREF: sub_4D7490+1ABj
    test    al, 40h
    jnz     short loc_4D766F
    mov     [ebp+0Ch], eax
    mov     ecx, [ecx+4]
    mov     eax, [esp+24h+var_10]
    mov     [ebp+8], ecx
    jmp     loc_4D74D1
    ; ---------------------------------------------------------------------------

    loc_4D766F:                             ; CODE XREF: sub_4D7490+1CBj
    test    al, 20h
    jz      loc_4D7A52
    mov     eax, [esp+24h+var_10]
    mov     dword ptr [ebp+0], 7
    jmp     loc_4D74D1
    ; ---------------------------------------------------------------------------

    loc_4D7687:                             ; CODE XREF: sub_4D7490+4Dj
                                            ; DATA XREF: .text:004D7BF8o
    mov     eax, [ebp+8]                    ; case 0x2
    cmp     edi, eax
    jnb     short loc_4D76D0

    loc_4D768E:                             ; CODE XREF: sub_4D7490+23Ej
    mov     eax, [esp+24h+var_14]
    test    eax, eax
    jz      loc_4D7AAB
    mov     ecx, [esp+24h+arg_4]
    dec     eax
    mov     [esp+24h+var_14], eax
    xor     eax, eax
    mov     al, [ecx]
    mov     ecx, edi
    shl     eax, cl
    mov     ecx, [esp+24h+arg_0]
    add     edi, 8
    mov     [esp+24h+arg_8], 0
    or      ecx, eax
    mov     eax, [ebp+8]
    mov     [esp+24h+arg_0], ecx
    mov     ecx, [esp+24h+arg_4]
    inc     ecx
    cmp     edi, eax
    mov     [esp+24h+arg_4], ecx
    jb      short loc_4D768E

    loc_4D76D0:                             ; CODE XREF: sub_4D7490+1FCj
    mov     eax, dword_50C218[eax*4]
    mov     ecx, [esp+24h+arg_0]
    and     eax, ecx
    mov     ecx, [ebp+4]
    add     ecx, eax
    mov     eax, [esp+24h+arg_0]
    mov     [ebp+4], ecx
    mov     ecx, [ebp+8]
    shr     eax, cl
    mov     dword ptr [ebp+0], 3
    mov     [esp+24h+arg_0], eax
    mov     eax, ecx
    sub     edi, eax
    mov     eax, [ebp+16h]
    xor     ecx, ecx
    mov     [ebp+8], eax
    mov     cl, [ebp+11h]
    mov     [ebp+0Ch], ecx

    loc_4D770B:                             ; CODE XREF: sub_4D7490+4Dj
                                            ; DATA XREF: .text:004D7BF8o
    mov     eax, [ebp+0Ch]                  ; case 0x3
    cmp     edi, eax
    jnb     short loc_4D7756

    loc_4D7712:                             ; CODE XREF: sub_4D7490+2C4j
    mov     eax, [esp+24h+var_14]
    test    eax, eax
    jz      loc_4D7AAB
    dec     eax
    xor     ecx, ecx
    mov     [esp+24h+var_14], eax
    mov     eax, [esp+24h+arg_4]
    mov     [esp+24h+arg_8], 0
    mov     cl, [eax]
    mov     eax, ecx
    mov     ecx, edi
    shl     eax, cl
    mov     ecx, [esp+24h+arg_0]
    add     edi, 8
    or      ecx, eax
    mov     eax, [ebp+0Ch]
    mov     [esp+24h+arg_0], ecx
    mov     ecx, [esp+24h+arg_4]
    inc     ecx
    cmp     edi, eax
    mov     [esp+24h+arg_4], ecx
    jb      short loc_4D7712

    loc_4D7756:                             ; CODE XREF: sub_4D7490+280j
    mov     ecx, dword_50C218[eax*4]
    mov     eax, [esp+24h+arg_0]
    and     ecx, eax
    mov     eax, [ebp+8]
    lea     eax, [eax+ecx*8]
    xor     ecx, ecx
    mov     [esp+24h+var_C], eax
    mov     cl, [eax+1]
    mov     eax, [esp+24h+arg_0]
    shr     eax, cl
    mov     [esp+24h+var_8], ecx
    mov     [esp+24h+arg_0], eax
    mov     eax, ecx
    mov     ecx, [esp+24h+var_C]
    sub     edi, eax
    xor     eax, eax
    mov     al, [ecx]
    test    al, 10h
    jz      short loc_4D77AC
    and     eax, 0Fh
    mov     [ebp+8], eax
    mov     ecx, [ecx+4]
    mov     eax, [esp+24h+var_10]
    mov     [ebp+0Ch], ecx
    mov     dword ptr [ebp+0], 4
    jmp     loc_4D74D1
    ; ---------------------------------------------------------------------------

    loc_4D77AC:                             ; CODE XREF: sub_4D7490+2FEj
    test    al, 40h
    jnz     loc_4D7A9B
    mov     [ebp+0Ch], eax
    mov     eax, [ecx+4]
    mov     [ebp+8], eax
    mov     eax, [esp+24h+var_10]
    jmp     loc_4D74D1
    ; ---------------------------------------------------------------------------

    loc_4D77C6:                             ; CODE XREF: sub_4D7490+4Dj
                                            ; DATA XREF: .text:004D7BF8o
    mov     eax, [ebp+8]                    ; case 0x4
    cmp     edi, eax
    jnb     short loc_4D7811

    loc_4D77CD:                             ; CODE XREF: sub_4D7490+37Fj
    mov     eax, [esp+24h+var_14]
    test    eax, eax
    jz      loc_4D7AAB
    dec     eax
    xor     ecx, ecx
    mov     [esp+24h+var_14], eax
    mov     eax, [esp+24h+arg_4]
    mov     [esp+24h+arg_8], 0
    mov     cl, [eax]
    mov     eax, ecx
    mov     ecx, edi
    shl     eax, cl
    mov     ecx, [esp+24h+arg_0]
    add     edi, 8
    or      ecx, eax
    mov     eax, [ebp+8]
    mov     [esp+24h+arg_0], ecx
    mov     ecx, [esp+24h+arg_4]
    inc     ecx
    cmp     edi, eax
    mov     [esp+24h+arg_4], ecx
    jb      short loc_4D77CD

    loc_4D7811:                             ; CODE XREF: sub_4D7490+33Bj
    mov     ecx, dword_50C218[eax*4]
    mov     eax, [esp+24h+arg_0]
    and     ecx, eax
    mov     eax, [ebp+0Ch]
    add     eax, ecx
    mov     ecx, [ebp+8]
    mov     [ebp+0Ch], eax
    mov     eax, [esp+24h+arg_0]
    shr     eax, cl
    mov     dword ptr [ebp+0], 5
    mov     [esp+24h+arg_0], eax
    mov     eax, ecx
    sub     edi, eax

    loc_4D783E:                             ; CODE XREF: sub_4D7490+4Dj
                                            ; DATA XREF: .text:004D7BF8o
    mov     eax, [esi+24h]                  ; case 0x5
    mov     ecx, edx
    sub     ecx, eax
    mov     eax, [ebp+0Ch]
    cmp     ecx, eax
    jnb     short loc_4D7861
    mov     eax, [esi+28h]
    mov     ecx, [esi+24h]
    sub     eax, ecx
    mov     ecx, [ebp+0Ch]
    sub     eax, ecx
    add     eax, edx
    mov     [esp+24h+var_8], eax
    jmp     short loc_4D7869
    ; ---------------------------------------------------------------------------

    loc_4D7861:                             ; CODE XREF: sub_4D7490+3BAj
    mov     ecx, edx
    sub     ecx, eax
    mov     [esp+24h+var_8], ecx

    loc_4D7869:                             ; CODE XREF: sub_4D7490+3CFj
    mov     eax, [ebp+4]
    test    eax, eax
    mov     eax, [esp+24h+var_10]
    jz      loc_4D7A08

    loc_4D7878:                             ; CODE XREF: sub_4D7490+4B7j
    test    eax, eax
    jnz     loc_4D7914
    mov     ecx, [esi+28h]
    cmp     edx, ecx
    mov     [esp+24h+var_C], ecx
    jnz     short loc_4D78AC
    mov     eax, [esi+2Ch]
    mov     ecx, [esi+24h]
    cmp     eax, ecx
    jz      short loc_4D78A8
    mov     edx, ecx
    cmp     edx, eax
    jnb     short loc_4D78A0
    sub     eax, edx
    dec     eax
    jmp     short loc_4D78AC
    ; ---------------------------------------------------------------------------

    loc_4D78A0:                             ; CODE XREF: sub_4D7490+409j
    mov     eax, [esp+24h+var_C]
    sub     eax, edx
    jmp     short loc_4D78AC
    ; ---------------------------------------------------------------------------

    loc_4D78A8:                             ; CODE XREF: sub_4D7490+403j
    mov     eax, [esp+24h+var_10]

    loc_4D78AC:                             ; CODE XREF: sub_4D7490+3F9j
                                            ; sub_4D7490+40Ej ...
    test    eax, eax
    jnz     short loc_4D7914
    mov     [esi+30h], edx
    mov     edx, [esp+24h+arg_8]
    push    edx
    push    ebx
    push    esi
    call    sub_4D7C40
    mov     edx, [esi+30h]
    mov     [esp+24h+arg_8], eax
    mov     eax, [esi+2Ch]
    cmp     edx, eax
    mov     [esp+24h+var_4], eax
    jnb     short loc_4D78D6
    sub     eax, edx
    dec     eax
    jmp     short loc_4D78DB
    ; ---------------------------------------------------------------------------

    loc_4D78D6:                             ; CODE XREF: sub_4D7490+43Fj
    mov     eax, [esi+28h]
    sub     eax, edx

    loc_4D78DB:                             ; CODE XREF: sub_4D7490+444j
    mov     ecx, [esi+28h]
    mov     [esp+24h+var_10], eax
    cmp     edx, ecx
    mov     [esp+24h+var_C], ecx
    jnz     short loc_4D790C
    mov     ecx, [esi+24h]
    mov     eax, [esp+24h+var_4]
    cmp     eax, ecx
    jz      short loc_4D7908
    mov     edx, ecx
    cmp     edx, eax
    jnb     short loc_4D7900
    sub     eax, edx
    dec     eax
    jmp     short loc_4D790C
    ; ---------------------------------------------------------------------------

    loc_4D7900:                             ; CODE XREF: sub_4D7490+469j
    mov     eax, [esp+24h+var_C]
    sub     eax, edx
    jmp     short loc_4D790C
    ; ---------------------------------------------------------------------------

    loc_4D7908:                             ; CODE XREF: sub_4D7490+463j
    mov     eax, [esp+24h+var_10]

    loc_4D790C:                             ; CODE XREF: sub_4D7490+458j
                                            ; sub_4D7490+46Ej ...
    test    eax, eax
    jz      loc_4D7AE9

    loc_4D7914:                             ; CODE XREF: sub_4D7490+3EAj
                                            ; sub_4D7490+41Ej
    mov     ecx, [esp+24h+var_8]
    inc     edx
    mov     [esp+24h+arg_8], 0
    mov     cl, [ecx]
    mov     [edx-1], cl
    mov     ecx, [esp+24h+var_8]
    inc     ecx
    dec     eax
    cmp     ecx, [esi+28h]
    mov     [esp+24h+var_8], ecx
    mov     [esp+24h+var_10], eax
    jnz     short loc_4D7940
    mov     ecx, [esi+24h]
    mov     [esp+24h+var_8], ecx

    loc_4D7940:                             ; CODE XREF: sub_4D7490+4A7j
    mov     ecx, [ebp+4]
    dec     ecx
    mov     [ebp+4], ecx
    jnz     loc_4D7878
    mov     dword ptr [ebp+0], 0
    jmp     loc_4D74D1
    ; ---------------------------------------------------------------------------

    loc_4D7959:                             ; CODE XREF: sub_4D7490+4Dj
                                            ; DATA XREF: .text:004D7BF8o
    test    eax, eax                        ; case 0x6
    jnz     loc_4D79F5
    mov     ecx, [esi+28h]
    cmp     edx, ecx
    mov     [esp+24h+var_C], ecx
    jnz     short loc_4D798D
    mov     eax, [esi+2Ch]
    mov     ecx, [esi+24h]
    cmp     eax, ecx
    jz      short loc_4D7989
    mov     edx, ecx
    cmp     edx, eax
    jnb     short loc_4D7981
    sub     eax, edx
    dec     eax
    jmp     short loc_4D798D
    ; ---------------------------------------------------------------------------

    loc_4D7981:                             ; CODE XREF: sub_4D7490+4EAj
    mov     eax, [esp+24h+var_C]
    sub     eax, edx
    jmp     short loc_4D798D
    ; ---------------------------------------------------------------------------

    loc_4D7989:                             ; CODE XREF: sub_4D7490+4E4j
    mov     eax, [esp+24h+var_10]

    loc_4D798D:                             ; CODE XREF: sub_4D7490+4DAj
                                            ; sub_4D7490+4EFj ...
    test    eax, eax
    jnz     short loc_4D79F5
    mov     [esi+30h], edx
    mov     edx, [esp+24h+arg_8]
    push    edx
    push    ebx
    push    esi
    call    sub_4D7C40
    mov     edx, [esi+30h]
    mov     [esp+24h+arg_8], eax
    mov     eax, [esi+2Ch]
    cmp     edx, eax
    mov     [esp+24h+var_4], eax
    jnb     short loc_4D79B7
    sub     eax, edx
    dec     eax
    jmp     short loc_4D79BC
    ; ---------------------------------------------------------------------------

    loc_4D79B7:                             ; CODE XREF: sub_4D7490+520j
    mov     eax, [esi+28h]
    sub     eax, edx

    loc_4D79BC:                             ; CODE XREF: sub_4D7490+525j
    mov     ecx, [esi+28h]
    mov     [esp+24h+var_10], eax
    cmp     edx, ecx
    mov     [esp+24h+var_C], ecx
    jnz     short loc_4D79ED
    mov     ecx, [esi+24h]
    mov     eax, [esp+24h+var_4]
    cmp     eax, ecx
    jz      short loc_4D79E9
    mov     edx, ecx
    cmp     edx, eax
    jnb     short loc_4D79E1
    sub     eax, edx
    dec     eax
    jmp     short loc_4D79ED
    ; ---------------------------------------------------------------------------

    loc_4D79E1:                             ; CODE XREF: sub_4D7490+54Aj
    mov     eax, [esp+24h+var_C]
    sub     eax, edx
    jmp     short loc_4D79ED
    ; ---------------------------------------------------------------------------

    loc_4D79E9:                             ; CODE XREF: sub_4D7490+544j
    mov     eax, [esp+24h+var_10]

    loc_4D79ED:                             ; CODE XREF: sub_4D7490+539j
                                            ; sub_4D7490+54Fj ...
    test    eax, eax
    jz      loc_4D7AE9

    loc_4D79F5:                             ; CODE XREF: sub_4D7490+4CBj
                                            ; sub_4D7490+4FFj
    mov     cl, [ebp+8]
    mov     [esp+24h+arg_8], 0
    mov     [edx], cl
    inc     edx
    dec     eax
    mov     [esp+24h+var_10], eax

    loc_4D7A08:                             ; CODE XREF: sub_4D7490+3E2j
    mov     dword ptr [ebp+0], 0
    jmp     loc_4D74D1
    ; ---------------------------------------------------------------------------

    loc_4D7A14:                             ; CODE XREF: sub_4D7490+11Bj
    mov     eax, [esp+24h+arg_0]
    mov     [esi+1Ch], edi
    mov     [esi+20h], eax
    mov     eax, [esp+24h+arg_4]
    mov     edi, [ebx]
    mov     ebp, [ebx+8]
    mov     ecx, eax
    mov     dword ptr [ebx+4], 0
    sub     ecx, edi
    mov     [ebx], eax
    add     ebp, ecx
    mov     [ebx+8], ebp
    mov     [esi+30h], edx
    mov     edx, [esp+24h+arg_8]
    push    edx
    push    ebx
    push    esi
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D7A52:                             ; CODE XREF: sub_4D7490+1E1j
    mov     dword ptr [ebp+0], 9
    mov     dword ptr [ebx+18h], offset aInvalidLiteral ; "invalid literal/length code"

    loc_4D7A60:                             ; CODE XREF: sub_4D7490+4Dj
                                            ; sub_4D7490+619j
                                            ; DATA XREF: ...
    mov     eax, [esp+24h+arg_0]            ; case 0x9
    mov     ecx, [esp+24h+var_14]
    mov     [esi+20h], eax
    mov     eax, [esp+24h+arg_4]
    mov     [esi+1Ch], edi
    mov     ebp, [ebx]
    mov     edi, [ebx+8]
    mov     [ebx+4], ecx
    mov     ecx, eax
    push    0FFFFFFFDh
    sub     ecx, ebp
    push    ebx
    add     edi, ecx
    mov     [ebx], eax
    mov     [ebx+8], edi
    push    esi
    mov     [esi+30h], edx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D7A9B:                             ; CODE XREF: sub_4D7490+31Ej
    mov     dword ptr [ebp+0], 9
    mov     dword ptr [ebx+18h], offset aInvalidDistanc ; "invalid distance code"
    jmp     short loc_4D7A60                ; case 0x9
    ; ---------------------------------------------------------------------------

    loc_4D7AAB:                             ; CODE XREF: sub_4D7490+204j
                                            ; sub_4D7490+288j ...
    mov     eax, [esp+24h+arg_0]
    mov     [esi+1Ch], edi
    mov     [esi+20h], eax
    mov     eax, [esp+24h+arg_4]
    mov     edi, [ebx]
    mov     ebp, [ebx+8]
    mov     ecx, eax
    mov     dword ptr [ebx+4], 0
    sub     ecx, edi
    mov     [ebx], eax
    add     ebp, ecx
    mov     [ebx+8], ebp
    mov     [esi+30h], edx
    mov     edx, [esp+24h+arg_8]
    push    edx
    push    ebx
    push    esi
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D7AE9:                             ; CODE XREF: sub_4D7490+47Ej
                                            ; sub_4D7490+55Fj
    mov     eax, [esp+24h+arg_0]
    mov     ecx, [esp+24h+var_14]
    mov     [esi+20h], eax
    mov     eax, [esp+24h+arg_4]
    mov     [esi+1Ch], edi
    mov     edi, [ebx]
    mov     ebp, [ebx+8]
    mov     [ebx+4], ecx
    mov     ecx, eax
    mov     [ebx], eax
    sub     ecx, edi
    add     ebp, ecx
    mov     [ebx+8], ebp
    mov     [esi+30h], edx
    mov     edx, [esp+24h+arg_8]
    push    edx
    push    ebx
    push    esi
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D7B27:                             ; CODE XREF: sub_4D7490+4Dj
                                            ; DATA XREF: .text:004D7BF8o
    mov     eax, [esp+24h+arg_8]            ; case 0x7
    mov     [esi+30h], edx
    push    eax
    push    ebx
    push    esi
    call    sub_4D7C40
    mov     edx, [esi+30h]
    mov     ecx, [esi+2Ch]
    cmp     ecx, edx
    jz      short loc_4D7B7A
    mov     ecx, [esp+24h+arg_0]
    mov     [esi+1Ch], edi
    mov     [esi+20h], ecx
    mov     ecx, [esp+24h+var_14]
    mov     ebp, [ebx]
    mov     [ebx+4], ecx
    mov     ecx, [esp+24h+arg_4]
    push    eax
    mov     edi, ecx
    push    ebx
    sub     edi, ebp
    mov     ebp, [ebx+8]
    add     ebp, edi
    mov     [ebx], ecx
    mov     [ebx+8], ebp
    push    esi
    mov     [esi+30h], edx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D7B7A:                             ; CODE XREF: sub_4D7490+6AEj
    mov     dword ptr [ebp+0], 8

    loc_4D7B81:                             ; CODE XREF: sub_4D7490+4Dj
                                            ; DATA XREF: .text:004D7BF8o
    mov     eax, [esp+24h+arg_0]            ; case 0x8
    mov     ecx, [esp+24h+var_14]
    mov     [esi+20h], eax
    mov     eax, [esp+24h+arg_4]
    mov     [esi+1Ch], edi
    mov     ebp, [ebx]
    mov     edi, [ebx+8]
    mov     [ebx+4], ecx
    mov     ecx, eax
    push    1
    sub     ecx, ebp
    push    ebx
    add     edi, ecx
    mov     [ebx], eax
    mov     [ebx+8], edi
    push    esi
    mov     [esi+30h], edx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D7BBC:                             ; CODE XREF: sub_4D7490+47j
    mov     eax, [esp+24h+arg_0]            ; default
    mov     ecx, [esp+24h+var_14]
    mov     [esi+20h], eax
    mov     eax, [esp+24h+arg_4]
    mov     [esi+1Ch], edi
    mov     ebp, [ebx]
    mov     edi, [ebx+8]
    mov     [ebx+4], ecx
    mov     ecx, eax
    push    0FFFFFFFEh
    sub     ecx, ebp
    push    ebx
    add     edi, ecx
    mov     [ebx], eax
    mov     [ebx+8], edi
    push    esi
    mov     [esi+30h], edx
    call    sub_4D7C40
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    0Ch
    sub_4D7490 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4D7BF8 dd offset loc_4D74E4         ; DATA XREF: sub_4D7490+4Dr
    dd offset loc_4D759E                    ; jump table for switch statement
    dd offset loc_4D7687
    dd offset loc_4D770B
    dd offset loc_4D77C6
    dd offset loc_4D783E
    dd offset loc_4D7959
    dd offset loc_4D7B27
    dd offset loc_4D7B81
    dd offset loc_4D7A60

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D7C20 proc near                    ; CODE XREF: sub_4D5E00+3Bp
                                            ; sub_4D5F00+727p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    push    eax
    mov     eax, [esp+4+arg_4]
    mov     ecx, [eax+28h]
    push    ecx
    call    dword ptr [eax+24h]
    retn    8
    sub_4D7C20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D7C40 proc near                    ; CODE XREF: sub_4D5F00+211p
                                            ; sub_4D5F00+7B8p ...

    var_1C= dword ptr -1Ch
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    push    ebx
    mov     ebx, [esp+8+arg_0]
    push    ebp
    push    esi
    mov     esi, [esp+10h+arg_4]
    mov     ebp, [ebx+30h]
    push    edi
    mov     edi, [ebx+2Ch]
    mov     eax, [esi+0Ch]
    cmp     edi, ebp
    mov     [esp+14h+var_4], eax
    mov     [esp+14h+arg_0], edi
    jbe     short loc_4D7C65
    mov     ebp, [ebx+28h]

    loc_4D7C65:                             ; CODE XREF: sub_4D7C40+20j
    mov     eax, [esi+10h]
    sub     ebp, edi
    cmp     ebp, eax
    jbe     short loc_4D7C70
    mov     ebp, eax

    loc_4D7C70:                             ; CODE XREF: sub_4D7C40+2Cj
    test    ebp, ebp
    jz      short loc_4D7C83
    cmp     [esp+14h+arg_8], 0FFFFFFFBh
    jnz     short loc_4D7C83
    mov     [esp+14h+arg_8], 0

    loc_4D7C83:                             ; CODE XREF: sub_4D7C40+32j
                                            ; sub_4D7C40+39j
    mov     edx, [esi+14h]
    sub     eax, ebp
    add     edx, ebp
    mov     [esi+10h], eax
    mov     [esi+14h], edx
    mov     eax, [ebx+34h]
    test    eax, eax
    jz      short loc_4D7CA5
    mov     ecx, [ebx+38h]
    push    ebp
    push    edi
    push    ecx
    call    eax
    mov     [ebx+38h], eax
    mov     [esi+30h], eax

    loc_4D7CA5:                             ; CODE XREF: sub_4D7C40+55j
    mov     ecx, ebp
    mov     esi, edi
    mov     edi, [esp+14h+var_4]
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     eax, [esp+14h+arg_0]
    mov     ecx, edx
    and     ecx, 3
    add     eax, ebp
    rep movsb
    mov     edi, [esp+14h+var_4]
    mov     ecx, [ebx+28h]
    add     edi, ebp
    cmp     eax, ecx
    mov     [esp+14h+var_4], edi
    jnz     short loc_4D7D50
    mov     eax, [ebx+30h]
    mov     esi, [ebx+24h]
    cmp     eax, ecx
    mov     [esp+14h+arg_0], esi
    jnz     short loc_4D7CE3
    mov     [ebx+30h], esi

    loc_4D7CE3:                             ; CODE XREF: sub_4D7C40+9Ej
    mov     edi, [esp+14h+arg_4]
    mov     ebp, [ebx+30h]
    sub     ebp, esi
    mov     eax, [edi+10h]
    cmp     ebp, eax
    jbe     short loc_4D7CF5
    mov     ebp, eax

    loc_4D7CF5:                             ; CODE XREF: sub_4D7C40+B1j
    test    ebp, ebp
    jz      short loc_4D7D08
    cmp     [esp+14h+arg_8], 0FFFFFFFBh
    jnz     short loc_4D7D08
    mov     [esp+14h+arg_8], 0

    loc_4D7D08:                             ; CODE XREF: sub_4D7C40+B7j
                                            ; sub_4D7C40+BEj
    mov     edx, [edi+14h]
    sub     eax, ebp
    add     edx, ebp
    mov     [edi+10h], eax
    mov     [edi+14h], edx
    mov     eax, [ebx+34h]
    test    eax, eax
    jz      short loc_4D7D2A
    mov     ecx, [ebx+38h]
    push    ebp
    push    esi
    push    ecx
    call    eax
    mov     [ebx+38h], eax
    mov     [edi+30h], eax

    loc_4D7D2A:                             ; CODE XREF: sub_4D7C40+DAj
    mov     eax, [esp+14h+var_4]
    mov     ecx, ebp
    mov     edx, ecx
    mov     edi, eax
    shr     ecx, 2
    rep movsd
    add     eax, ebp
    mov     ecx, edx
    mov     [esp+14h+var_4], eax
    mov     eax, [esp+14h+arg_0]
    and     ecx, 3
    add     eax, ebp
    rep movsb
    mov     [esp+14h+arg_0], eax

    loc_4D7D50:                             ; CODE XREF: sub_4D7C40+90j
    mov     ecx, [esp+14h+arg_4]
    mov     edx, [esp+14h+var_4]
    pop     edi
    pop     esi
    mov     [ecx+0Ch], edx
    mov     [ebx+2Ch], eax
    mov     eax, [esp+0Ch+arg_8]
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    sub_4D7C40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D7D70 proc near                    ; CODE XREF: sub_4D7490+A8p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    sub     esp, 14h
    mov     eax, [esp+14h+arg_14]
    mov     ecx, [esp+14h+arg_10]
    push    ebx
    push    ebp
    mov     ebp, [ecx+30h]
    mov     edx, [ecx+20h]
    push    esi
    mov     esi, [ecx+2Ch]
    push    edi
    mov     edi, [eax]
    mov     eax, [eax+4]
    cmp     ebp, esi
    mov     [esp+24h+var_14], eax
    mov     eax, [ecx+1Ch]
    mov     [esp+24h+var_C], edi
    jnb     short loc_4D7DA5
    sub     esi, ebp
    dec     esi
    mov     [esp+24h+var_10], esi
    jmp     short loc_4D7DAE
    ; ---------------------------------------------------------------------------

    loc_4D7DA5:                             ; CODE XREF: sub_4D7D70+2Aj
    mov     ecx, [ecx+28h]
    sub     ecx, ebp
    mov     [esp+24h+var_10], ecx

    loc_4D7DAE:                             ; CODE XREF: sub_4D7D70+33j
    mov     ecx, [esp+24h+arg_0]
    mov     ecx, dword_50C218[ecx*4]
    mov     [esp+24h+var_8], ecx
    mov     ecx, [esp+24h+arg_4]
    mov     ecx, dword_50C218[ecx*4]
    mov     [esp+24h+arg_4], ecx

    loc_4D7DCC:                             ; CODE XREF: sub_4D7D70+251j
    cmp     eax, 14h
    jnb     short loc_4D7DF3

    loc_4D7DD1:                             ; CODE XREF: sub_4D7D70+7Dj
    mov     ecx, [esp+24h+var_14]
    dec     ecx
    mov     [esp+24h+var_14], ecx
    xor     ecx, ecx
    mov     cl, [edi]
    mov     esi, ecx
    mov     ecx, eax
    shl     esi, cl
    add     eax, 8
    or      edx, esi
    inc     edi
    cmp     eax, 14h
    jb      short loc_4D7DD1
    mov     [esp+24h+var_C], edi

    loc_4D7DF3:                             ; CODE XREF: sub_4D7D70+5Fj
    mov     ecx, [esp+24h+var_8]
    mov     esi, [esp+24h+arg_8]
    and     ecx, edx
    xor     ebx, ebx
    mov     bl, [esi+ecx*8]
    lea     esi, [esi+ecx*8]
    test    ebx, ebx
    jz      loc_4D7F97
    xor     ecx, ecx
    mov     cl, [esi+1]
    shr     edx, cl
    sub     eax, ecx
    mov     [esp+24h+arg_0], ecx
    test    bl, 10h
    jnz     short loc_4D7E56

    loc_4D7E1F:                             ; CODE XREF: sub_4D7D70+E4j
    test    bl, 40h
    jnz     loc_4D8016
    mov     ecx, dword_50C218[ebx*4]
    mov     esi, [esi+4]
    and     ecx, edx
    xor     ebx, ebx
    mov     bl, [esi+ecx*8]
    lea     esi, [esi+ecx*8]
    test    ebx, ebx
    jz      loc_4D7F97
    xor     ecx, ecx
    mov     cl, [esi+1]
    shr     edx, cl
    sub     eax, ecx
    mov     [esp+24h+arg_0], ecx
    test    bl, 10h
    jz      short loc_4D7E1F

    loc_4D7E56:                             ; CODE XREF: sub_4D7D70+ADj
    and     ebx, 0Fh
    sub     eax, ebx
    mov     ecx, dword_50C218[ebx*4]
    and     ecx, edx
    add     ecx, [esi+4]
    mov     [esp+24h+var_4], ecx
    mov     ecx, ebx
    shr     edx, cl
    cmp     eax, 0Fh
    jnb     short loc_4D7E96

    loc_4D7E74:                             ; CODE XREF: sub_4D7D70+120j
    mov     ecx, [esp+24h+var_14]
    dec     ecx
    mov     [esp+24h+var_14], ecx
    xor     ecx, ecx
    mov     cl, [edi]
    mov     esi, ecx
    mov     ecx, eax
    shl     esi, cl
    add     eax, 8
    or      edx, esi
    inc     edi
    cmp     eax, 0Fh
    jb      short loc_4D7E74
    mov     [esp+24h+var_C], edi

    loc_4D7E96:                             ; CODE XREF: sub_4D7D70+102j
    mov     ecx, [esp+24h+arg_4]
    mov     esi, [esp+24h+arg_C]
    and     ecx, edx
    xor     ebx, ebx
    mov     bl, [esi+ecx*8]
    lea     esi, [esi+ecx*8]
    xor     ecx, ecx
    mov     cl, [esi+1]
    shr     edx, cl
    sub     eax, ecx
    mov     [esp+24h+arg_0], ecx
    test    bl, 10h
    jnz     short loc_4D7EE9

    loc_4D7EBA:                             ; CODE XREF: sub_4D7D70+177j
    test    bl, 40h
    jnz     loc_4D7FC6
    mov     ecx, dword_50C218[ebx*4]
    mov     esi, [esi+4]
    and     ecx, edx
    xor     ebx, ebx
    mov     bl, [esi+ecx*8]
    lea     esi, [esi+ecx*8]
    xor     ecx, ecx
    mov     cl, [esi+1]
    shr     edx, cl
    sub     eax, ecx
    mov     [esp+24h+arg_0], ecx
    test    bl, 10h
    jz      short loc_4D7EBA

    loc_4D7EE9:                             ; CODE XREF: sub_4D7D70+148j
    and     ebx, 0Fh
    cmp     eax, ebx
    jnb     short loc_4D7F1B
    jmp     short loc_4D7EF6
    ; ---------------------------------------------------------------------------

    loc_4D7EF2:                             ; CODE XREF: sub_4D7D70+1A9j
    mov     edi, [esp+24h+var_C]

    loc_4D7EF6:                             ; CODE XREF: sub_4D7D70+180j
    mov     ecx, [esp+24h+var_14]
    dec     ecx
    mov     [esp+24h+var_14], ecx
    xor     ecx, ecx
    mov     cl, [edi]
    mov     edi, ecx
    mov     ecx, eax
    shl     edi, cl
    mov     ecx, [esp+24h+var_C]
    add     eax, 8
    or      edx, edi
    inc     ecx
    cmp     eax, ebx
    mov     [esp+24h+var_C], ecx
    jb      short loc_4D7EF2

    loc_4D7F1B:                             ; CODE XREF: sub_4D7D70+17Ej
    mov     edi, dword_50C218[ebx*4]
    mov     ecx, [esi+4]
    and     edi, edx
    sub     eax, ebx
    add     edi, ecx
    mov     ecx, ebx
    mov     ebx, [esp+24h+var_4]
    mov     esi, ebp
    shr     edx, cl
    mov     ecx, [esp+24h+var_10]
    sub     ecx, ebx
    mov     [esp+24h+var_10], ecx
    mov     ecx, [esp+24h+arg_10]
    mov     ecx, [ecx+24h]
    sub     esi, ecx
    cmp     esi, edi
    jb      short loc_4D7F63
    mov     esi, ebp
    sub     esi, edi
    inc     ebp
    mov     cl, [esi]
    inc     esi
    mov     [ebp-1], cl
    inc     ebp
    mov     cl, [esi]
    inc     esi
    mov     [ebp-1], cl
    sub     ebx, 2
    jmp     short loc_4D7F87
    ; ---------------------------------------------------------------------------

    loc_4D7F63:                             ; CODE XREF: sub_4D7D70+1DAj
    add     edi, ecx
    mov     ecx, [esp+24h+arg_10]
    sub     edi, ebp
    mov     esi, [ecx+28h]
    sub     esi, edi
    cmp     ebx, edi
    jbe     short loc_4D7F87
    sub     ebx, edi

    loc_4D7F76:                             ; CODE XREF: sub_4D7D70+20Ej
    mov     cl, [esi]
    mov     [ebp+0], cl
    inc     ebp
    inc     esi
    dec     edi
    jnz     short loc_4D7F76
    mov     ecx, [esp+24h+arg_10]
    mov     esi, [ecx+24h]

    loc_4D7F87:                             ; CODE XREF: sub_4D7D70+1F1j
                                            ; sub_4D7D70+202j ...
    mov     cl, [esi]
    mov     [ebp+0], cl
    inc     ebp
    inc     esi
    dec     ebx
    jnz     short loc_4D7F87
    mov     edi, [esp+24h+var_C]
    jmp     short loc_4D7FB0
    ; ---------------------------------------------------------------------------

    loc_4D7F97:                             ; CODE XREF: sub_4D7D70+97j
                                            ; sub_4D7D70+CEj
    xor     ecx, ecx
    mov     cl, [esi+1]
    shr     edx, cl
    sub     eax, ecx
    mov     cl, [esi+4]
    mov     [ebp+0], cl
    mov     ecx, [esp+24h+var_10]
    inc     ebp
    dec     ecx
    mov     [esp+24h+var_10], ecx

    loc_4D7FB0:                             ; CODE XREF: sub_4D7D70+225j
    cmp     [esp+24h+var_10], 102h
    jb      short loc_4D7FD6
    cmp     [esp+24h+var_14], 0Ah
    jb      short loc_4D7FD6
    jmp     loc_4D7DCC
    ; ---------------------------------------------------------------------------

    loc_4D7FC6:                             ; CODE XREF: sub_4D7D70+14Dj
    mov     ecx, [esp+24h+arg_14]
    mov     dword ptr [ecx+18h], offset aInvalidDistanc ; "invalid distance code"
    jmp     loc_4D8069
    ; ---------------------------------------------------------------------------

    loc_4D7FD6:                             ; CODE XREF: sub_4D7D70+248j
                                            ; sub_4D7D70+24Fj
    mov     esi, [esp+24h+arg_10]
    mov     ecx, eax
    and     eax, 7
    shr     ecx, 3
    mov     [esi+20h], edx
    mov     edx, [esp+24h+var_14]
    mov     [esi+1Ch], eax
    mov     eax, [esp+24h+arg_14]
    sub     edi, ecx
    add     ecx, edx
    mov     ebx, [eax]
    mov     edx, [eax+8]
    mov     [eax+4], ecx
    mov     ecx, edi
    sub     ecx, ebx
    mov     [eax], edi
    add     edx, ecx
    mov     [eax+8], edx
    mov     [esi+30h], ebp
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4D8016:                             ; CODE XREF: sub_4D7D70+B2j
    test    bl, 20h
    jz      short loc_4D805E
    mov     esi, [esp+24h+arg_10]
    mov     ecx, eax
    and     eax, 7
    shr     ecx, 3
    mov     [esi+20h], edx
    mov     edx, [esp+24h+var_14]
    mov     [esi+1Ch], eax
    mov     eax, [esp+24h+arg_14]
    sub     edi, ecx
    add     ecx, edx
    mov     ebx, [eax]
    mov     edx, [eax+8]
    mov     [eax+4], ecx
    mov     ecx, edi
    sub     ecx, ebx
    mov     [eax], edi
    add     edx, ecx
    mov     [eax+8], edx
    mov     [esi+30h], ebp
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    18h
    ; ---------------------------------------------------------------------------

    loc_4D805E:                             ; CODE XREF: sub_4D7D70+2A9j
    mov     ecx, [esp+24h+arg_14]
    mov     dword ptr [ecx+18h], offset aInvalidLiteral ; "invalid literal/length code"

    loc_4D8069:                             ; CODE XREF: sub_4D7D70+261j
    mov     ebx, [esp+24h+arg_10]
    mov     esi, eax
    shr     esi, 3
    mov     [ebx+20h], edx
    mov     edx, [esp+24h+var_14]
    sub     edi, esi
    and     eax, 7
    add     esi, edx
    mov     [ebx+1Ch], eax
    mov     edx, [ecx+8]
    mov     [ecx+4], esi
    mov     esi, [ecx]
    mov     eax, edi
    sub     eax, esi
    mov     [ecx], edi
    add     edx, eax
    pop     edi
    mov     [ecx+8], edx
    mov     [ebx+30h], ebp
    pop     esi
    pop     ebp
    mov     eax, 0FFFFFFFDh
    pop     ebx
    add     esp, 14h
    retn    18h
    sub_4D7D70 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     al, byte_5289B4
    test    al, al
    jnz     short locret_4D80C0
    mov     byte_5289B8, 1

    locret_4D80C0:                          ; CODE XREF: .text:004D80B7j
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D80D0 proc near                    ; CODE XREF: sub_4D8360+Dp
                                            ; sub_4D83C0+15p ...
    mov     cl, byte_528994
    mov     eax, 1
    test    al, cl
    mov     byte_5289B4, al
    jnz     short loc_4D8121
    or      cl, al
    push    0                               ; int
    mov     byte_528994, cl
    mov     cl, byte_5289B8
    push    offset aMemfrontalign           ; int
    push    offset aMemnofussy              ; int
    push    offset aMemfussy                ; int
    push    ecx                             ; char
    push    eax                             ; int
    push    offset aMemfussy_0              ; int
    mov     ecx, offset byte_5289A4
    call    sub_4D9FE0
    push    offset nullsub_18               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4D8121:                             ; CODE XREF: sub_4D80D0+12j
    mov     al, byte_5289A4
    retn
    sub_4D80D0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_18. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8140 proc near                    ; CODE XREF: sub_4D86B0+1p
    mov     cl, byte_5289B0
    mov     eax, 1
    test    al, cl
    jnz     short loc_4D8180
    push    0                               ; int
    push    0                               ; int
    push    offset aGonzo                   ; int
    or      cl, al
    push    0                               ; int
    push    eax                             ; char
    mov     byte_5289B0, cl
    push    eax                             ; int
    push    offset aGonzo_0                 ; int
    mov     ecx, offset byte_5289A0
    call    sub_4D9FE0
    push    offset nullsub_19               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4D8180:                             ; CODE XREF: sub_4D8140+Dj
    mov     al, byte_5289A0
    retn
    sub_4D8140 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_19. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    sub     esp, 8
    push    esi
    push    edi
    call    sub_4D8200
    test    al, al
    jz      short loc_4D81F6
    call    sub_4D8260
    test    eax, eax
    jz      short loc_4D81F6
    call    sub_4D8260
    mov     edx, [esp+18h]
    mov     esi, [esp+14h]
    mov     [esp+0Ch], eax
    mov     [esp+8], eax
    xor     ecx, ecx

    loc_4D81CE:                             ; CODE XREF: .text:004D81E4j
    mov     eax, [esp+ecx+8]
    mov     edi, eax
    sub     edi, edx
    cmp     edi, esi
    jg      short loc_4D81E0
    add     eax, edx
    cmp     esi, eax
    jle     short loc_4D81EE

    loc_4D81E0:                             ; CODE XREF: .text:004D81D8j
    inc     ecx
    cmp     ecx, 4
    jb      short loc_4D81CE
    xor     al, al
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4D81EE:                             ; CODE XREF: .text:004D81DEj
    mov     al, 1
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4D81F6:                             ; CODE XREF: .text:004D81ACj
                                            ; .text:004D81B5j
    pop     edi
    xor     al, al
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8200 proc near                    ; CODE XREF: .text:004D81A5p
                                            ; sub_4D83C0+65p
    mov     cl, byte_5289AC
    mov     eax, 1
    test    al, cl
    jnz     short loc_4D8244
    push    0                               ; int
    push    0                               ; int
    push    offset aMemnoset                ; int
    or      cl, al
    push    offset aMemset                  ; int
    push    0                               ; char
    mov     byte_5289AC, cl
    push    eax                             ; int
    push    offset aSetmemory               ; int
    mov     ecx, offset byte_52899C
    call    sub_4D9FE0
    push    offset nullsub_20               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4D8244:                             ; CODE XREF: sub_4D8200+Dj
    mov     al, byte_52899C
    retn
    sub_4D8200 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_20. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8260 proc near                    ; CODE XREF: .text:004D81AEp
                                            ; .text:004D81B7p ...
    mov     cl, byte_5289A8
    mov     al, 1
    test    al, cl
    jnz     short loc_4D829F
    or      cl, al
    push    offset aMemset                  ; "-memset"
    push    0DEADBEEFh
    mov     byte_5289A8, cl
    push    0DEADBEEFh
    push    offset aSetvalue                ; "setvalue"
    mov     ecx, offset dword_528998
    call    sub_4DA040
    push    offset nullsub_21               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4D829F:                             ; CODE XREF: sub_4D8260+Aj
    mov     eax, dword_528998
    retn
    sub_4D8260 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_21. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D82C0 proc near                    ; CODE XREF: sub_4D83C0+76p
                                            ; sub_4DACF0+277p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_8]
    push    edi
    cmp     esi, 4
    mov     edi, ebx
    jb      short loc_4D82E8
    mov     eax, [esp+8+arg_4]
    mov     edx, esi
    shr     edx, 2
    mov     ecx, edx
    rep stosd
    lea     edi, [ebx+edx*4]

    loc_4D82E2:                             ; CODE XREF: sub_4D82C0+26j
    sub     esi, 4
    dec     edx
    jnz     short loc_4D82E2

    loc_4D82E8:                             ; CODE XREF: sub_4D82C0+10j
    test    esi, esi
    jbe     short loc_4D8300
    mov     ecx, esi
    lea     esi, [esp+8+arg_4]
    mov     eax, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4D8300:                             ; CODE XREF: sub_4D82C0+2Aj
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_4D82C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4D8310 proc near                    ; CODE XREF: sub_4DB7D0+A9p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebp
    mov     ebp, esp
    mov     ecx, [ebp+arg_8]
    mov     eax, [ebp+arg_0]
    push    ebx
    push    esi
    cmp     ecx, 4
    jb      short loc_4D8336
    mov     esi, [ebp+arg_4]
    mov     edx, ecx
    shr     edx, 2

    loc_4D8328:                             ; CODE XREF: sub_4D8310+24j
    cmp     [eax], esi
    jz      short loc_4D832D
    int     3                               ; Trap to Debugger

    loc_4D832D:                             ; CODE XREF: sub_4D8310+1Aj
    add     eax, 4
    sub     ecx, 4
    dec     edx
    jnz     short loc_4D8328

    loc_4D8336:                             ; CODE XREF: sub_4D8310+Ej
    test    ecx, ecx
    jbe     short loc_4D834F
    lea     edx, [ebp+arg_4]
    mov     esi, ecx
    sub     edx, eax

    loc_4D8341:                             ; CODE XREF: sub_4D8310+3Dj
    mov     cl, [eax]
    mov     bl, [eax+edx]
    cmp     cl, bl
    jz      short loc_4D834B
    int     3                               ; Trap to Debugger

    loc_4D834B:                             ; CODE XREF: sub_4D8310+38j
    inc     eax
    dec     esi
    jnz     short loc_4D8341

    loc_4D834F:                             ; CODE XREF: sub_4D8310+28j
    pop     esi
    pop     ebx
    pop     ebp
    retn
    sub_4D8310 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8360 proc near                    ; CODE XREF: Network_ReAllocPacketBuffer_Internal+37p
                                            ; sub_4D85B0+37p ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jnz     short loc_4D836D
    xor     eax, eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4D836D:                             ; CODE XREF: sub_4D8360+7j
    call    sub_4D80D0
    test    al, al
    push    esi
    jz      short loc_4D8381
    call    sub_4DBAE0
    add     esp, 4
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4D8381:                             ; CODE XREF: sub_4D8360+15j
    call    __msize
    add     esp, 4
    pop     esi
    retn
    sub_4D8360 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_22. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_23. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D83B0 proc near                    ; CODE XREF: sub_40E9E0+8Cp
                                            ; .text:00417AC7p ...

    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    eax                             ; int
    call    sub_4D83C0
    add     esp, 4
    retn
    sub_4D83B0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4D83C0(int)
    sub_4D83C0 proc near                    ; CODE XREF: sub_4D83B0+5p
                                            ; sub_4D8450+5p ...

    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    call    sub_4DA780
    mov     ebx, eax
    push    ebx                             ; lpCriticalSection
    call    ds:EnterCriticalSection
    mov     edi, [esp+arg_0]

    loc_4D83D5:                             ; CODE XREF: sub_4D83C0+5Fj
    call    sub_4D80D0
    test    al, al
    jz      short loc_4D83ED
    push    0
    push    edi
    call    sub_4DACF0
    add     esp, 8
    mov     esi, eax
    jmp     short loc_4D8405
    ; ---------------------------------------------------------------------------

    loc_4D83ED:                             ; CODE XREF: sub_4D83C0+1Cj
    push    edi                             ; size_t
    call    _malloc
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jz      short loc_4D8409
    push    edi
    call    sub_4DA7D0
    add     esp, 4

    loc_4D8405:                             ; CODE XREF: sub_4D83C0+2Bj
    test    esi, esi
    jnz     short loc_4D8425

    loc_4D8409:                             ; CODE XREF: sub_4D83C0+3Aj
    mov     eax, dword_5289BC
    test    eax, eax
    jz      short loc_4D8414
    call    eax

    loc_4D8414:                             ; CODE XREF: sub_4D83C0+50j
    test    esi, esi
    jnz     short loc_4D8425
    mov     eax, dword_5289BC
    test    eax, eax
    jnz     short loc_4D83D5
    test    esi, esi
    jz      short loc_4D843E

    loc_4D8425:                             ; CODE XREF: sub_4D83C0+47j
                                            ; sub_4D83C0+56j
    call    sub_4D8200
    test    al, al
    jz      short loc_4D843E
    push    edi
    call    sub_4D8260
    push    eax
    push    esi
    call    sub_4D82C0
    add     esp, 0Ch

    loc_4D843E:                             ; CODE XREF: sub_4D83C0+63j
                                            ; sub_4D83C0+6Cj
    push    ebx                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_4D83C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8450 proc near                    ; CODE XREF: sub_470C10+51p
                                            ; sub_4B3770+B4p ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax                             ; int
    call    sub_4D83C0
    add     esp, 4
    retn
    sub_4D8450 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8460 proc near                    ; CODE XREF: sub_4B3750+Cp
                                            ; sub_4B3770+1CFp

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    esi
    mov     esi, [esp+arg_4]
    imul    esi, [esp+arg_0]
    push    esi                             ; int
    call    sub_4D83C0
    mov     edx, eax
    add     esp, 4
    test    edx, edx
    jz      short loc_4D848D
    mov     ecx, esi
    push    edi
    xor     eax, eax
    mov     edi, edx
    shr     ecx, 2
    rep stosd
    mov     ecx, esi
    and     ecx, 3
    rep stosb
    pop     edi

    loc_4D848D:                             ; CODE XREF: sub_4D8460+17j
    mov     eax, edx
    pop     esi
    retn
    sub_4D8460 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl Network_ReAllocPacketBuffer(int,int,int)
    Network_ReAllocPacketBuffer proc near   ; CODE XREF: sub_4224B0+93p
                                            ; sub_429700+A1p ...

    arg_0= dword ptr  4
    arg_8= dword ptr  0Ch

    mov     eax, [esp+arg_8]
    mov     ecx, [esp+arg_0]
    push    eax                             ; int
    push    ecx                             ; int
    call    Network_ReAllocPacketBuffer_Internal
    add     esp, 8
    retn
    Network_ReAllocPacketBuffer endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl Network_ReAllocPacketBuffer_Internal(int,int)
    Network_ReAllocPacketBuffer_Internal proc near ; CODE XREF: Network_ReAllocPacketBuffer+Ap

    lpCriticalSection= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4DA780
    push    eax                             ; lpCriticalSection
    mov     [esp+18h+lpCriticalSection], eax
    call    ds:EnterCriticalSection
    mov     esi, [esp+14h+arg_4]
    mov     ebx, [esp+14h+arg_0]

    loc_4D84DD:                             ; CODE XREF: Network_ReAllocPacketBuffer_Internal+9Dj
    call    sub_4D80D0
    test    al, al
    jz      short loc_4D84F6
    push    0
    push    esi
    push    ebx
    call    sub_4DBA40
    add     esp, 0Ch
    mov     edi, eax
    jmp     short loc_4D853B
    ; ---------------------------------------------------------------------------

    loc_4D84F6:                             ; CODE XREF: Network_ReAllocPacketBuffer_Internal+24j
    push    ebx
    call    sub_4D8360
    add     esp, 4
    mov     ebp, eax
    test    ebx, ebx
    jnz     short loc_4D850D
    test    esi, esi
    jnz     short loc_4D850D
    xor     edi, edi
    jmp     short loc_4D8519
    ; ---------------------------------------------------------------------------

    loc_4D850D:                             ; CODE XREF: Network_ReAllocPacketBuffer_Internal+43j
                                            ; Network_ReAllocPacketBuffer_Internal+47j
    push    esi                             ; size_t
    push    ebx                             ; void *
    call    _realloc
    add     esp, 8
    mov     edi, eax

    loc_4D8519:                             ; CODE XREF: Network_ReAllocPacketBuffer_Internal+4Bj
    test    edi, edi
    jnz     short loc_4D8521
    test    esi, esi
    jnz     short loc_4D853B

    loc_4D8521:                             ; CODE XREF: Network_ReAllocPacketBuffer_Internal+5Bj
    test    ebx, ebx
    jz      short loc_4D852E
    push    ebp
    call    sub_4DA840
    add     esp, 4

    loc_4D852E:                             ; CODE XREF: Network_ReAllocPacketBuffer_Internal+63j
    test    esi, esi
    jz      short loc_4D853B
    push    esi
    call    sub_4DA7D0
    add     esp, 4

    loc_4D853B:                             ; CODE XREF: Network_ReAllocPacketBuffer_Internal+34j
                                            ; Network_ReAllocPacketBuffer_Internal+5Fj ...
    test    edi, edi
    jnz     short loc_4D8563
    test    esi, esi
    jz      short loc_4D854E
    mov     eax, dword_5289BC
    test    eax, eax
    jz      short loc_4D854E
    call    eax

    loc_4D854E:                             ; CODE XREF: Network_ReAllocPacketBuffer_Internal+81j
                                            ; Network_ReAllocPacketBuffer_Internal+8Aj
    test    edi, edi
    jnz     short loc_4D8563
    test    esi, esi
    jz      short loc_4D8563
    mov     eax, dword_5289BC
    test    eax, eax
    jnz     loc_4D84DD

    loc_4D8563:                             ; CODE XREF: Network_ReAllocPacketBuffer_Internal+7Dj
                                            ; Network_ReAllocPacketBuffer_Internal+90j ...
    mov     eax, [esp+14h+lpCriticalSection]
    push    eax                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    Network_ReAllocPacketBuffer_Internal endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8580 proc near                    ; CODE XREF: sub_470C10+30p
                                            ; sub_4B3770+111p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    push    eax                             ; int
    push    0                               ; int
    push    ecx                             ; int
    call    Network_ReAllocPacketBuffer
    add     esp, 0Ch
    retn
    sub_4D8580 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4D85A0(int)
    sub_4D85A0 proc near                    ; CODE XREF: sub_40EB30+7p
                                            ; .text:0041785Bp ...

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax                             ; int
    call    sub_4D85B0
    add     esp, 4
    retn
    sub_4D85A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4D85B0(int)
    sub_4D85B0 proc near                    ; CODE XREF: sub_4D85A0+5p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jz      short loc_4D8609
    push    edi
    call    sub_4DA780
    mov     edi, eax
    push    edi                             ; lpCriticalSection
    call    ds:EnterCriticalSection
    call    sub_4D80D0
    test    al, al
    jz      short loc_4D85E6
    push    0
    push    esi
    call    sub_4DB7D0
    add     esp, 8
    push    edi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4D85E6:                             ; CODE XREF: sub_4D85B0+1Fj
    push    esi
    call    sub_4D8360
    add     esp, 4
    push    eax
    call    sub_4DA840
    add     esp, 4
    push    esi                             ; void *
    call    _free
    add     esp, 4
    push    edi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    pop     edi

    loc_4D8609:                             ; CODE XREF: sub_4D85B0+7j
    pop     esi
    retn
    sub_4D85B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8610 proc near                    ; CODE XREF: sub_42D2E0+AAp
                                            ; sub_4B4560+77p ...

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    test    esi, esi
    jnz     short loc_4D861D
    xor     eax, eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4D861D:                             ; CODE XREF: sub_4D8610+7j
    push    edi
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    push    ecx                             ; int
    call    sub_4D83C0
    mov     edx, eax
    add     esp, 4
    test    edx, edx
    jz      short loc_4D8657
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4D8657:                             ; CODE XREF: sub_4D8610+26j
    pop     edi
    mov     eax, edx
    pop     esi
    retn
    sub_4D8610 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4D8660(int)
    sub_4D8660 proc near                    ; CODE XREF: sub_4B4F10+5p
                                            ; .text:004B4F35p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax                             ; int
    call    sub_4D83C0
    add     esp, 4
    retn
    sub_4D8660 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8670 proc near                    ; CODE XREF: sub_4B4F20+5p
                                            ; .text:004B4F45p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    eax                             ; int
    call    sub_4D85A0
    add     esp, 4
    retn
    sub_4D8670 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_58. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     eax, [esp+8]
    mov     ecx, [esp+4]
    push    2
    push    eax
    push    ecx
    call    sub_4D86B0
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4D86B0(int,int,DWORD flNewProtect)
    sub_4D86B0 proc near                    ; CODE XREF: .text:004D869Cp
                                            ; .text:004D86FCp ...

    flOldProtect= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    flNewProtect= dword ptr  0Ch

    push    ecx
    call    sub_4D8140
    test    al, al
    jz      short loc_4D86ED
    mov     eax, [esp+4+arg_0]
    mov     edx, [esp+4+arg_4]
    lea     ecx, [eax+0FFFh]
    add     eax, edx
    and     ecx, 0FFFFF000h
    and     eax, 0FFFFF000h
    cmp     ecx, eax
    jnb     short loc_4D86ED
    lea     edx, [esp+4+flOldProtect]
    sub     eax, ecx
    push    edx                             ; lpflOldProtect
    mov     edx, [esp+8+flNewProtect]
    push    edx                             ; flNewProtect
    push    eax                             ; dwSize
    push    ecx                             ; lpAddress
    call    ds:VirtualProtect

    loc_4D86ED:                             ; CODE XREF: sub_4D86B0+8j
                                            ; sub_4D86B0+27j
    pop     ecx
    retn
    sub_4D86B0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+8]
    mov     ecx, [esp+4]
    push    4
    push    eax
    push    ecx
    call    sub_4D86B0
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000010 BYTES: COLLAPSED FUNCTION _iswlower. PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4D8720(int,DWORD flNewProtect)
    sub_4D8720 proc near                    ; CODE XREF: _iswlower+7p _iswdigit+7p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    flNewProtect= dword ptr  8

    push    ecx
    mov     eax, [esp+4+arg_0]
    push    eax
    mov     [esp+8+arg_0], eax
    call    sub_4D8360
    mov     ecx, [esp+8+arg_0]
    add     esp, 4
    add     eax, ecx
    mov     [esp+4+var_4], eax
    call    sub_4D80D0
    test    al, al
    jz      short loc_4D8757
    lea     edx, [esp+4+var_4]
    lea     eax, [esp+4+arg_0]
    push    edx
    push    eax
    call    sub_4DBB90
    add     esp, 8

    loc_4D8757:                             ; CODE XREF: sub_4D8720+23j
    mov     edx, [esp+4+var_4]
    mov     eax, [esp+4+arg_0]
    mov     ecx, [esp+4+flNewProtect]
    sub     edx, eax
    push    ecx                             ; flNewProtect
    push    edx                             ; int
    push    eax                             ; int
    call    sub_4D86B0
    add     esp, 0Ch
    pop     ecx
    retn
    sub_4D8720 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000010 BYTES: COLLAPSED FUNCTION _iswdigit. PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8790 proc near                    ; CODE XREF: sub_4D8C50+21p
                                            ; .text:004DAB78p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= byte ptr  10h
    arg_30= dword ptr  34h

    mov     al, [esp+arg_C]
    test    al, al
    jz      short loc_4D87BF
    mov     ecx, [esp+arg_8]
    mov     edx, [esp+arg_0]
    lea     eax, [esp+arg_C]
    push    eax
    mov     eax, [esp+4+arg_4]
    push    ecx
    mov     ecx, [esp+8+arg_30]
    push    edx
    push    eax
    push    offset aBlockInfoLdByt          ; "\tBlock info: %ld bytes at %08lX - Alloc"...
    push    ecx
    call    _sprintf
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------

    loc_4D87BF:                             ; CODE XREF: sub_4D8790+6j
    mov     edx, [esp+arg_8]
    mov     eax, [esp+arg_0]
    mov     ecx, [esp+arg_4]
    push    edx
    mov     edx, [esp+4+arg_30]
    push    eax
    push    ecx
    push    offset aBlockInfoLdB_0          ; "\tBlock info: %ld bytes at %08lX - Alloc"...
    push    edx
    call    _sprintf
    add     esp, 14h
    retn
    sub_4D8790 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D87F0 proc near                    ; CODE XREF: .text:004D8BD3p
                                            ; .text:004D8C05p ...
    push    esi
    mov     esi, ecx
    push    0                               ; lpString2
    mov     dword ptr [esi], 0
    mov     dword ptr [esi+4], 0
    mov     dword ptr [esi+8], 0FFFFFFFFh
    call    sub_4D8850
    mov     eax, esi
    pop     esi
    retn
    sub_4D87F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4D8820(int,int,int,int,LPCSTR lpString2)
    sub_4D8820 proc near                    ; CODE XREF: sub_4DAA30+25p
                                            ; sub_4DACF0+2ACp ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    lpString2= dword ptr  14h

    mov     eax, [esp+arg_0]
    mov     edx, [esp+arg_8]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+4+arg_4]
    mov     [esi], eax
    mov     eax, [esp+4+lpString2]
    mov     [esi+4], ecx
    push    eax                             ; lpString2
    mov     ecx, esi
    mov     [esi+8], edx
    call    sub_4D8850
    mov     ecx, [esp+4+arg_C]
    mov     eax, esi
    mov     [esi+2Ch], ecx
    pop     esi
    retn    14h
    sub_4D8820 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4D8850(LPCSTR lpString2)
    sub_4D8850 proc near                    ; CODE XREF: sub_4D87F0+19p
                                            ; sub_4D8820+1Ep

    lpString2= dword ptr  4

    mov     eax, [esp+lpString2]
    test    eax, eax
    jz      short loc_4D8868
    push    20h                             ; iMaxLength
    add     ecx, 0Ch
    push    eax                             ; lpString2
    push    ecx                             ; lpString1
    call    ds:lstrcpynA
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D8868:                             ; CODE XREF: sub_4D8850+6j
    mov     byte ptr [ecx+0Ch], 0
    retn    4
    sub_4D8850 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4D8870 proc near                    ; CODE XREF: .text:004D8BDBp
                                            ; .text:004D8BE6p ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    push    ebp
    mov     ebp, esp
    sub     esp, 0Ch
    push    esi
    mov     esi, ecx
    lea     ecx, [esi+44h]
    mov     [ebp+var_C], ebp
    mov     [ebp+var_4], esp
    lea     eax, ds:4D8882h
    mov     [ebp+var_8], eax
    mov     eax, [ebp+var_4]
    lea     edx, [ecx+40h]
    push    edx
    lea     edx, [ecx+3Ch]
    push    1
    push    edx
    lea     edx, [ecx+38h]
    mov     [ecx+44h], eax
    push    edx
    mov     edx, [ebp+var_C]
    push    0Eh
    push    ecx
    mov     ecx, [ebp+var_8]
    push    0
    push    ecx
    push    eax
    push    edx
    call    sub_4DE600
    add     esp, 28h
    mov     byte ptr [esi], 0
    mov     dword ptr [esi+40h], 0FFFFFFFFh
    mov     eax, esi
    pop     esi
    mov     esp, ebp
    pop     ebp
    retn
    sub_4D8870 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4D88D0 proc near                    ; CODE XREF: .text:004D8C1Dp

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebp
    mov     ebp, esp
    sub     esp, 0Ch
    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    lea     ecx, [ebx+44h]
    mov     [ebp+var_C], ebp
    mov     [ebp+var_4], esp
    lea     eax, ds:4D88E4h
    mov     [ebp+var_8], eax
    mov     eax, [ebp+var_4]
    lea     edx, [ecx+40h]
    push    edx
    lea     edx, [ecx+3Ch]
    push    1
    push    edx
    lea     edx, [ecx+38h]
    mov     [ecx+44h], eax
    push    edx
    mov     edx, [ebp+var_8]
    push    0Eh
    push    ecx
    mov     ecx, [ebp+arg_8]
    inc     ecx
    push    ecx
    push    edx
    push    eax
    mov     eax, [ebp+var_C]
    push    eax
    call    sub_4DE600
    mov     edx, [ebp+arg_0]
    add     esp, 28h
    test    edx, edx
    jz      short loc_4D899A
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, edx
    cmp     ecx, 40h
    jb      short loc_4D896C
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     edi, [ecx+edx-3Fh]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ebx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     ecx, [ebp+arg_4]
    mov     [ebx+40h], ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D896C:                             ; CODE XREF: sub_4D88D0+62j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    mov     eax, ebx
    and     ecx, 3
    rep movsb
    mov     ecx, [ebp+arg_4]
    mov     [ebx+40h], ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4D899A:                             ; CODE XREF: sub_4D88D0+4Fj
    mov     ecx, [ebp+arg_4]
    pop     edi
    mov     byte ptr [ebx], 0
    mov     [ebx+40h], ecx
    mov     eax, ebx
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    0Ch
    sub_4D88D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D89B0 proc near                    ; CODE XREF: sub_4D8C50+78p
                                            ; sub_4D8C50+D5p

    var_3E8= dword ptr -3E8h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 3E8h
    xor     eax, eax
    push    ebx
    mov     ebx, [esp+3ECh+arg_0]
    push    ebp
    push    esi
    mov     ebp, ecx
    push    edi
    mov     edi, offset byte_50319C
    or      ecx, 0FFFFFFFFh
    mov     byte ptr [ebx], 0
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    cmp     byte ptr [ebp+0], 0
    jz      loc_4D8A77
    lea     ecx, [esp+3F8h+var_3E8]
    push    ebp
    push    ecx
    call    sub_4DE8A0
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    mov     edx, [ebp+40h]
    lea     eax, [esp+3F8h+var_3E8]
    not     ecx
    dec     ecx
    push    edx
    add     ecx, ebx
    push    eax
    push    offset aSD_1                    ; "%s(%d)"
    push    ecx
    call    _sprintf
    mov     edi, offset asc_50C32C          ; " : "
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, offset byte_50319C
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4D8A77:                             ; CODE XREF: sub_4D89B0+3Cj
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     ebp, 44h
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ebx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    add     edx, ebx
    push    ebp
    repne scasb
    mov     eax, [esp+3FCh+arg_4]
    not     ecx
    dec     ecx
    sub     eax, ecx
    mov     ecx, [ebp+38h]
    push    ecx
    push    0Eh
    push    eax
    push    edx
    call    sub_4DEA00
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 14h
    repne scasb
    not     ecx
    dec     ecx
    jz      short loc_4D8AC8
    cmp     byte ptr [ecx+ebx-1], 0Ah
    jnz     short loc_4D8AC8
    mov     byte ptr [ecx+ebx-1], 0

    loc_4D8AC8:                             ; CODE XREF: sub_4D89B0+10Aj
                                            ; sub_4D89B0+111j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 3E8h
    retn    8
    sub_4D89B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    mov     esi, [esp+0Ch]
    mov     ebx, ecx
    push    edi
    mov     ecx, 23h
    mov     edi, ebx
    xor     eax, eax
    rep movsd
    mov     [ebx+0B8h], eax
    mov     [ebx+8Ch], eax
    mov     [ebx+90h], eax
    mov     [ebx+94h], eax
    mov     [ebx+0BCh], eax
    mov     eax, [esp+14h]
    push    eax
    mov     ecx, ebx
    call    sub_4D8B30
    pop     edi
    mov     eax, ebx
    pop     esi
    pop     ebx
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4D8B30(LPCSTR lpString2)
    sub_4D8B30 proc near                    ; CODE XREF: .text:004D8B19p

    lpString2= dword ptr  4

    mov     eax, [esp+lpString2]
    test    eax, eax
    jz      short loc_4D8B4B
    push    20h                             ; iMaxLength
    add     ecx, 98h
    push    eax                             ; lpString2
    push    ecx                             ; lpString1
    call    ds:lstrcpynA
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4D8B4B:                             ; CODE XREF: sub_4D8B30+6j
    mov     byte ptr [ecx+98h], 0
    retn    4
    sub_4D8B30 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     edx, [ecx+8Ch]
    mov     eax, [esp+4]
    test    edx, edx
    push    esi
    jnz     short loc_4D8B7D
    mov     [ecx+94h], eax
    mov     [ecx+90h], eax
    jmp     short loc_4D8B99
    ; ---------------------------------------------------------------------------

    loc_4D8B7D:                             ; CODE XREF: .text:004D8B6Dj
    cmp     eax, [ecx+90h]
    jnb     short loc_4D8B8B
    mov     [ecx+90h], eax

    loc_4D8B8B:                             ; CODE XREF: .text:004D8B83j
    cmp     eax, [ecx+94h]
    jbe     short loc_4D8B99
    mov     [ecx+94h], eax

    loc_4D8B99:                             ; CODE XREF: .text:004D8B7Bj
                                            ; .text:004D8B91j
    mov     esi, [ecx+0B8h]
    add     esi, eax
    mov     [ecx+0B8h], esi
    mov     eax, [ecx+0BCh]
    adc     eax, 0
    inc     edx
    mov     [ecx+0BCh], eax
    mov     [ecx+8Ch], edx
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, ecx
    call    sub_4D87F0
    lea     ecx, [esi+30h]
    call    sub_4D8870
    lea     ecx, [esi+0BCh]
    call    sub_4D8870
    mov     byte ptr [esi+148h], 0
    mov     eax, esi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    push    ebx
    push    esi
    push    edi
    mov     ebx, ecx
    call    sub_4D87F0
    mov     eax, [esp+1Ch]
    mov     ecx, [esp+18h]
    mov     edx, [esp+14h]
    inc     eax
    push    eax
    push    ecx
    push    edx
    lea     ecx, [ebx+30h]
    call    sub_4D88D0
    lea     ecx, [ebx+0BCh]
    call    sub_4D8870
    mov     esi, [esp+10h]
    mov     ecx, 0Ch
    mov     edi, ebx
    mov     eax, ebx
    rep movsd
    pop     edi
    mov     byte ptr [ebx+148h], 0
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8C50 proc near                    ; CODE XREF: .text:004D8D55p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch

    push    ecx
    push    ebx
    mov     ebx, [esp+8+arg_0]
    push    ebp
    mov     ebp, [esp+0Ch+arg_4]
    push    esi
    push    edi
    push    ebp
    push    ebx
    mov     esi, ecx
    sub     esp, 30h
    mov     ecx, 0Ch
    mov     edi, esp
    mov     [esp+4Ch+var_4], esi
    rep movsd
    call    sub_4D8790
    mov     edi, offset aAllocatedFrom      ; ", allocated from:"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 38h
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ebx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    add     edx, ebx
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, ebp
    sub     eax, ecx
    mov     ecx, [esp+14h+var_4]
    push    eax
    push    edx
    add     ecx, 30h
    call    sub_4D89B0
    mov     al, [esp+14h+arg_8]
    test    al, al
    jz      short loc_4D8D2A
    mov     edi, offset aFreedFrom          ; "\n\tfreed from:"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ebx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    add     edx, ebx
    repne scasb
    mov     eax, [esp+14h+var_4]
    not     ecx
    dec     ecx
    sub     ebp, ecx
    lea     ecx, [eax+0BCh]
    push    ebp
    push    edx
    call    sub_4D89B0

    loc_4D8D2A:                             ; CODE XREF: sub_4D8C50+83j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn    0Ch
    sub_4D8C50 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    sub     esp, 7D0h
    lea     edx, [esp+0]
    push    eax
    push    7D0h
    push    edx
    call    sub_4D8C50
    add     esp, 7D0h
    retn    4
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4D8D70 proc near                    ; CODE XREF: sub_4D8DF0+4p
                                            ; sub_4D8E20+4p ...

    Buffer= _MEMORY_BASIC_INFORMATION ptr -20h
    lpAddress= dword ptr -4
    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebp
    mov     ebp, esp
    sub     esp, 20h
    push    esi
    mov     [ebp+lpAddress], esp
    mov     eax, TlsIndex
    mov     ecx, large fs:2Ch
    mov     esi, [ecx+eax*4]
    mov     eax, [ebp+lpAddress]
    mov     cl, [esi+0Ch]
    mov     [esi+4], eax
    test    cl, cl
    jnz     short loc_4D8DC3
    lea     edx, [ebp+Buffer]
    push    1Ch                             ; dwLength
    push    edx                             ; lpBuffer
    push    eax                             ; lpAddress
    mov     byte ptr [esi+0Ch], 1
    call    ds:VirtualQuery
    cmp     eax, 1Ch
    jnz     short loc_4D8DE6
    mov     eax, [ebp+Buffer.BaseAddress]
    mov     ecx, [ebp+Buffer.RegionSize]
    add     eax, ecx
    mov     [esi+8], eax

    loc_4D8DC3:                             ; CODE XREF: sub_4D8D70+2Aj
    mov     eax, [ebp+arg_0]
    mov     ecx, [esi+4]
    cmp     eax, ecx
    jb      short loc_4D8DE6
    mov     edx, [ebp+arg_4]
    add     edx, eax
    mov     eax, [esi+8]
    cmp     edx, eax
    ja      short loc_4D8DE6
    xor     al, al
    pop     esi
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------

    loc_4D8DE6:                             ; CODE XREF: sub_4D8D70+43j
                                            ; sub_4D8D70+5Ej ...
    mov     al, 1
    pop     esi
    mov     esp, ebp
    pop     ebp
    retn
    sub_4D8D70 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8DF0 proc near                    ; CODE XREF: sub_4DED60+3B2p
    push    0
    push    0
    call    sub_4D8D70
    mov     eax, TlsIndex
    mov     ecx, large fs:2Ch
    add     esp, 8
    mov     edx, [ecx+eax*4]
    mov     eax, [edx+4]
    retn
    sub_4D8DF0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8E20 proc near                    ; CODE XREF: sub_4DED60+3ACp
    push    0
    push    0
    call    sub_4D8D70
    mov     eax, TlsIndex
    mov     ecx, large fs:2Ch
    add     esp, 8
    mov     edx, [ecx+eax*4]
    mov     eax, [edx+8]
    retn
    sub_4D8E20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8E50 proc near                    ; CODE XREF: sub_495A30+8Ep
                                            ; sub_49E6F0+5p ...

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    mov     eax, dword_5289BC
    mov     dword_5289BC, ecx
    retn
    sub_4D8E50 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D8E60 proc near                    ; CODE XREF: sub_49E680+3Fp
                                            ; sub_4CBAB0+Dp ...

    var_143F0= dword ptr -143F0h
    var_143EC= dword ptr -143ECh
    hFile= dword ptr -143E8h
    NumberOfBytesWritten= dword ptr -143E4h
    FileName= byte ptr -143E0h
    var_13FF8= byte ptr -13FF8h
    Buffer= byte ptr -13C10h
    Filename= byte ptr -0C8B8h
    var_C4D0= dword ptr -0C4D0h
    String2= byte ptr -0A44Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, 143F0h
    call    __alloca_probe
    mov     eax, dword_5289C0
    test    eax, eax
    jz      short loc_4D8E7C
    xor     eax, eax
    add     esp, 143F0h
    retn
    ; ---------------------------------------------------------------------------

    loc_4D8E7C:                             ; CODE XREF: sub_4D8E60+11j
    mov     eax, [esp+143F0h+arg_0]
    push    edi
    push    esi
    push    ebp
    mov     dword_5289C0, 1
    mov     ebp, [eax+4]
    push    ebx
    mov     ebx, [eax]
    mov     eax, [ebp+0B8h]
    mov     ecx, [ebp+0C4h]
    mov     edx, [ebp+0B4h]
    push    0
    push    eax
    push    ecx
    push    edx
    lea     ecx, [esp+14410h+var_C4D0]
    call    sub_4D9C60
    lea     ecx, [esp+14400h+var_C4D0]
    call    sub_4D9CA0
    lea     eax, [esp+14400h+FileName]
    push    3E8h                            ; nSize
    push    eax                             ; lpFilename
    push    0                               ; hModule
    call    ds:GetModuleFileNameA
    test    eax, eax
    jz      short loc_4D8EF4
    lea     ecx, [esp+14400h+FileName]
    push    5Ch                             ; int
    push    ecx                             ; char *
    call    _strrchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4D8EF4
    mov     byte ptr [eax+1], 0
    jmp     short loc_4D8F1A
    ; ---------------------------------------------------------------------------

    loc_4D8EF4:                             ; CODE XREF: sub_4D8E60+79j
                                            ; sub_4D8E60+8Cj
    mov     edi, offset aC_0                ; "C:\\"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+14400h+FileName]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4D8F1A:                             ; CODE XREF: sub_4D8E60+92j
    mov     edi, offset aErrorlog_txt       ; "ErrorLog.txt"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+14400h+FileName]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    eax                             ; hTemplateFile
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    push    80h                             ; dwFlagsAndAttributes
    push    4                               ; dwCreationDisposition
    mov     ecx, edx
    push    eax                             ; lpSecurityAttributes
    push    eax                             ; dwShareMode
    and     ecx, 3
    lea     eax, [esp+14414h+FileName]
    push    40000000h                       ; dwDesiredAccess
    rep movsb
    push    eax                             ; lpFileName
    call    ds:CreateFileA
    test    eax, eax
    mov     [esp+14400h+hFile], eax
    jz      short loc_4D8F77
    push    2                               ; dwMoveMethod
    push    0                               ; lpDistanceToMoveHigh
    push    0                               ; lDistanceToMove
    push    eax                             ; hFile
    call    ds:SetFilePointer

    loc_4D8F77:                             ; CODE XREF: sub_4D8E60+108j
    mov     [esp+14400h+Buffer], 0
    mov     ecx, [ebx]
    push    ecx
    call    sub_4D98C0
    add     esp, 4
    lea     edx, [esp+14400h+Filename]
    mov     [esp+14400h+var_143F0], eax
    push    3E8h                            ; nSize
    push    edx                             ; lpFilename
    push    0                               ; hModule
    call    ds:GetModuleFileNameA
    test    eax, eax
    jbe     loc_4D90B8
    lea     eax, [esp+14400h+Filename]
    push    5Ch                             ; int
    push    eax                             ; char *
    call    _strrchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4D8FC8
    inc     eax
    mov     [esp+14400h+var_143EC], eax
    jmp     short loc_4D8FD5
    ; ---------------------------------------------------------------------------

    loc_4D8FC8:                             ; CODE XREF: sub_4D8E60+15Fj
    lea     ecx, [esp+14400h+Filename]
    mov     [esp+14400h+var_143EC], ecx
    mov     eax, ecx

    loc_4D8FD5:                             ; CODE XREF: sub_4D8E60+166j
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+14400h+var_13FF8]
    repne scasb
    not     ecx
    sub     edi, ecx
    push    2Eh                             ; int
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+14404h+var_13FF8]
    push    ecx                             ; char *
    call    _strrchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4D9014
    mov     byte ptr [eax], 0

    loc_4D9014:                             ; CODE XREF: sub_4D8E60+1AFj
    mov     edx, [esp+14400h+var_143F0]
    lea     eax, [esp+14400h+var_13FF8]
    push    edx
    push    eax
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    offset aSCausedAnSIn            ; "%s caused an %s in\n"
    repne scasb
    not     ecx
    dec     ecx
    lea     ecx, [esp+ecx+1440Ch+Buffer]
    push    ecx
    call    _sprintf
    lea     edi, [esp+14410h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    mov     edx, [ebp+0B8h]
    not     ecx
    dec     ecx
    push    edx
    mov     edx, [esp+14404h+var_143EC]
    lea     eax, [esp+ecx+14404h+Buffer]
    mov     ecx, [ebp+0BCh]
    push    ecx
    push    edx
    push    offset aModuleSAt04x08          ; "module %s at %04x:%08lx.\n"
    push    eax
    call    _sprintf
    mov     edx, [esp+14414h+hFile]
    add     esp, 14h
    test    edx, edx
    jz      short loc_4D90B0
    lea     eax, [esp+14400h+NumberOfBytesWritten]
    push    0                               ; lpOverlapped
    push    eax                             ; lpNumberOfBytesWritten
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    ecx                             ; nNumberOfBytesToWrite
    lea     ecx, [esp+1440Ch+Buffer]
    push    ecx                             ; lpBuffer
    push    edx                             ; hFile
    call    ds:WriteFile

    loc_4D90B0:                             ; CODE XREF: sub_4D8E60+226j
    mov     [esp+14400h+Buffer], 0

    loc_4D90B8:                             ; CODE XREF: sub_4D8E60+145j
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [esp+14400h+arg_4]
    repne scasb
    not     ecx
    dec     ecx
    push    edx
    push    offset aExceptionHandl          ; "Exception handler called in %s. "
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     edi, [esp+14400h+Buffer]
    lea     edx, [esp+ecx+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, 7358h
    sub     eax, ecx
    push    eax
    push    edx
    call    sub_4DED60
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+0B8h]
    push    ecx
    push    offset aInstructionPoi          ; "Instruction pointer is %08lX\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [ebx]
    not     ecx
    dec     ecx
    push    edx
    push    offset aExceptioncode0          ; "ExceptionCode = %08lX"
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    mov     eax, [esp+1440Ch+var_143F0]
    add     esp, 0Ch
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    push    eax
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    offset aS_0                     ; " - %s\n"
    lea     ecx, [esp+ecx+14408h+Buffer]
    push    ecx
    call    _sprintf
    mov     eax, [ebx]
    add     esp, 0Ch
    cmp     eax, 0C0000005h
    jnz     short loc_4D9220
    cmp     dword ptr [ebx+10h], 2
    jb      short loc_4D9220
    mov     edx, [ebx+18h]
    push    edx
    call    unknown_libname_58
    add     esp, 4
    test    al, al
    jz      short loc_4D91E4
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    offset aErrorWriteToRe          ; "Error: Write to read only memory attemp"...
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14404h+Buffer]
    push    eax
    call    _sprintf
    add     esp, 8

    loc_4D91E4:                             ; CODE XREF: sub_4D8E60+35Cj
    mov     eax, [ebx+14h]
    mov     edx, offset aWrite              ; "write"
    test    eax, eax
    jnz     short loc_4D91F5
    mov     edx, offset aRead               ; "read"

    loc_4D91F5:                             ; CODE XREF: sub_4D8E60+38Ej
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebx+18h]
    push    ecx
    push    edx
    push    offset aAccessViolatio          ; "Access violation: Illegal %s, data addr"...
    push    eax
    call    _sprintf
    add     esp, 10h

    loc_4D9220:                             ; CODE XREF: sub_4D8E60+346j
                                            ; sub_4D8E60+34Cj
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [ebx+4]
    repne scasb
    not     ecx
    dec     ecx
    push    edx
    push    offset aExceptionflags          ; "ExceptionFlags = %08lX\t"
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebx+0Ch]
    push    ecx
    push    offset aExceptionaddre          ; "ExceptionAddress = %08lX\n"
    push    eax
    call    _sprintf
    mov     eax, [ebx+10h]
    add     esp, 0Ch
    test    eax, eax
    jbe     loc_4D930D
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    offset aParameters              ; "Parameters = "
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+ecx+14404h+Buffer]
    push    edx
    call    _sprintf
    mov     eax, [ebx+10h]
    add     esp, 8
    xor     esi, esi
    test    eax, eax
    jbe     short loc_4D930D
    lea     ecx, [ebx+14h]
    mov     [esp+14400h+var_143F0], ecx

    loc_4D92B5:                             ; CODE XREF: sub_4D8E60+4ABj
    dec     eax
    cmp     esi, eax
    jz      short loc_4D92CB
    mov     eax, esi
    xor     edx, edx
    mov     ecx, 3
    div     ecx
    cmp     edx, ecx
    mov     dl, 9
    jnz     short loc_4D92CD

    loc_4D92CB:                             ; CODE XREF: sub_4D8E60+458j
    mov     dl, 0Ah

    loc_4D92CD:                             ; CODE XREF: sub_4D8E60+469j
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     edi, [esp+14400h+var_143F0]
    not     ecx
    dec     ecx
    movsx   edx, dl
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [edi]
    push    edx
    push    ecx
    push    offset a08lxC                   ; "%08lX%c"
    push    eax
    call    _sprintf
    mov     eax, [ebx+10h]
    add     esp, 10h
    inc     esi
    add     edi, 4
    cmp     esi, eax
    mov     [esp+14400h+var_143F0], edi
    jb      short loc_4D92B5

    loc_4D930D:                             ; CODE XREF: sub_4D8E60+419j
                                            ; sub_4D8E60+44Cj
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    offset byte_50319C
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+ecx+14404h+Buffer]
    push    edx
    call    _sprintf
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    dec     ecx
    push    offset aRegisters               ; "Registers:\n"
    lea     eax, [esp+ecx+14404h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    mov     edx, [ebp+0B8h]
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+0C0h]
    push    ecx
    mov     ecx, [ebp+0BCh]
    push    edx
    mov     edx, [ebp+0B0h]
    push    ecx
    push    edx
    push    offset aEax08lxCs04lxE          ; "EAX=%08lX CS=%04lX EIP=%08lX EFLGS=%08l"...
    push    eax
    call    _sprintf
    lea     edi, [esp+14418h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 18h
    repne scasb
    mov     edx, [ebp+0C4h]
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+0B4h]
    push    ecx
    mov     ecx, [ebp+0C8h]
    push    edx
    mov     edx, [ebp+0A4h]
    push    ecx
    push    edx
    push    offset aEbx08lxSs04lxE          ; "EBX=%08lX SS=%04lX ESP=%08lX EBP=%08lX\n"...
    push    eax
    call    _sprintf
    lea     edi, [esp+14418h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 18h
    repne scasb
    mov     edx, [ebp+0A0h]
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+90h]
    push    ecx
    mov     ecx, [ebp+98h]
    push    edx
    mov     edx, [ebp+0ACh]
    push    ecx
    push    edx
    push    offset aEcx08lxDs04lxE          ; "ECX=%08lX DS=%04lX ESI=%08lX FS=%08lX\n"
    push    eax
    call    _sprintf
    add     esp, 18h
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     edx, [ebp+9Ch]
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+8Ch]
    push    ecx
    mov     ecx, [ebp+94h]
    push    edx
    mov     edx, [ebp+0A8h]
    push    ecx
    push    edx
    push    offset aEdx08lxEs04lxE          ; "EDX=%08lX ES=%04lX EDI=%08lX GS=%08lX\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+14418h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 18h
    repne scasb
    not     ecx
    dec     ecx
    push    offset byte_50319C
    lea     eax, [esp+ecx+14404h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    dec     ecx
    push    offset aBytesAtCsEip            ; "Bytes at CS:EIP:\n"
    lea     ecx, [esp+ecx+14404h+Buffer]
    push    ecx
    call    _sprintf
    mov     ebx, [ebp+0B8h]
    add     esp, 8
    xor     esi, esi

    loc_4D94B5:                             ; CODE XREF: sub_4D8E60+696j
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     esi, 0Fh
    setnz   dl
    dec     edx
    lea     eax, [esp+ecx+14400h+Buffer]
    and     edx, 0FFFFFFEAh
    add     edx, 20h
    movsx   ecx, dl
    xor     edx, edx
    push    ecx
    mov     dl, [esi+ebx]
    push    edx
    push    offset a02xC                    ; "%02x%c"
    push    eax
    call    _sprintf
    add     esp, 10h
    inc     esi
    cmp     esi, 10h
    jl      short loc_4D94B5
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    offset byte_50319C
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14404h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, 7358h
    sub     eax, ecx
    sub     eax, 3E8h
    test    eax, eax
    jle     loc_4D9856
    lea     ecx, [esp+14400h+String2]
    push    eax                             ; iMaxLength
    push    ecx                             ; lpString2
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+ecx+14408h+Buffer]
    push    edx                             ; lpString1
    call    ds:lstrcpynA
    lea     edi, [esp+14400h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    offset byte_50319C
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14404h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+4]
    push    ecx
    push    offset aDr008lx                 ; "Dr0 = %08lX\t"
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [ebp+8]
    not     ecx
    dec     ecx
    push    edx
    push    offset aDr108lx                 ; "Dr1 = %08lX\t"
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+0Ch]
    push    ecx
    push    offset aDr208lx                 ; "Dr2 = %08lX\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [ebp+10h]
    not     ecx
    dec     ecx
    push    edx
    push    offset aDr308lx                 ; "Dr3 = %08lX\t"
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+14h]
    push    ecx
    push    offset aDr608lx                 ; "Dr6 = %08lX\t"
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [ebp+18h]
    not     ecx
    dec     ecx
    push    edx
    push    offset aDr708lx                 ; "Dr7 = %08lX\n"
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    push    offset byte_50319C
    lea     eax, [esp+ecx+14404h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+0]
    push    ecx
    push    offset aContextflags08          ; "ContextFlags = %08lX\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [ebp+1Ch]
    not     ecx
    dec     ecx
    push    edx
    push    offset aControlWord08l          ; "Control Word = %08lX\t\t"
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+20h]
    push    ecx
    push    offset aStatusword08lx          ; "StatusWord = %08lX\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [ebp+24h]
    not     ecx
    dec     ecx
    push    edx
    push    offset aTagword08lx             ; "TagWord = %08lX\t\t"
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+28h]
    push    ecx
    push    offset aErroroffset08l          ; "ErrorOffset = %08lX\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [ebp+2Ch]
    not     ecx
    dec     ecx
    push    edx
    push    offset aErrorselector0          ; "ErrorSelector = %08lX\t"
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+30h]
    push    ecx
    push    offset aDataoffset08lx          ; "DataOffset = %08lX\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     edx, [ebp+34h]
    not     ecx
    dec     ecx
    push    edx
    push    offset aDataselector08          ; "DataSelector = %08lX\t\t"
    lea     eax, [esp+ecx+14408h+Buffer]
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+14400h+Buffer]
    mov     ecx, [ebp+88h]
    push    ecx
    push    offset aCr0npxstate08l          ; "Cr0NpxState = %08lX\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+1440Ch+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    push    offset asc_50C35C               ; "\n\n\n\n\n"
    lea     edx, [esp+ecx+14404h+Buffer]
    push    edx
    call    _sprintf
    add     esp, 8

    loc_4D9856:                             ; CODE XREF: sub_4D8E60+6DDj
    lea     eax, [esp+14400h+Buffer]
    push    7358h
    push    eax
    call    sub_4DA3F0
    mov     esi, [esp+14408h+hFile]
    add     esp, 8
    test    esi, esi
    jz      short loc_4D98A2
    lea     ecx, [esp+14400h+NumberOfBytesWritten]
    push    0                               ; lpOverlapped
    push    ecx                             ; lpNumberOfBytesWritten
    lea     edi, [esp+14408h+Buffer]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+14408h+Buffer]
    push    ecx                             ; nNumberOfBytesToWrite
    push    edx                             ; lpBuffer
    push    esi                             ; hFile
    call    ds:WriteFile
    push    esi                             ; hObject
    call    ds:CloseHandle

    loc_4D98A2:                             ; CODE XREF: sub_4D8E60+A11j
    call    sub_4DE110
    pop     ebx
    pop     ebp
    pop     esi
    xor     eax, eax
    pop     edi
    add     esp, 143F0h
    retn
    sub_4D8E60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D98C0 proc near                    ; CODE XREF: sub_4D8E60+122p

    var_C0= dword ptr -0C0h
    var_BC= dword ptr -0BCh
    var_B8= dword ptr -0B8h
    var_B4= dword ptr -0B4h
    var_B0= dword ptr -0B0h
    var_AC= dword ptr -0ACh
    var_A8= dword ptr -0A8h
    var_A4= dword ptr -0A4h
    var_A0= dword ptr -0A0h
    var_9C= dword ptr -9Ch
    var_98= dword ptr -98h
    var_94= dword ptr -94h
    var_90= dword ptr -90h
    var_8C= dword ptr -8Ch
    var_88= dword ptr -88h
    var_84= dword ptr -84h
    var_80= dword ptr -80h
    var_7C= dword ptr -7Ch
    var_78= dword ptr -78h
    var_74= dword ptr -74h
    var_70= dword ptr -70h
    var_6C= dword ptr -6Ch
    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 0C0h
    mov     edx, [esp+0C0h+arg_0]
    mov     [esp+0C0h+var_C0], 40010005h
    mov     [esp+0C0h+var_BC], offset aControlC ; "Control-C"
    mov     [esp+0C0h+var_B8], 40010008h
    mov     [esp+0C0h+var_B4], offset aControlBreak ; "Control-Break"
    mov     [esp+0C0h+var_B0], 80000002h
    mov     [esp+0C0h+var_AC], offset aDatatypeMisali ; "Datatype Misalignment"
    mov     [esp+0C0h+var_A8], 80000003h
    mov     [esp+0C0h+var_A4], offset aBreakpoint ; "Breakpoint"
    mov     [esp+0C0h+var_A0], 0C0000005h
    mov     [esp+0C0h+var_9C], offset aAccessViolat_0 ; "Access Violation"
    mov     [esp+0C0h+var_98], 0C0000006h
    mov     [esp+0C0h+var_94], offset aInPageError ; "In Page Error"
    mov     [esp+0C0h+var_90], 0C0000017h
    mov     [esp+0C0h+var_8C], offset aNoMemory ; "No Memory"
    mov     [esp+0C0h+var_88], 0C000001Dh
    mov     [esp+0C0h+var_84], offset aIllegalInstruc ; "Illegal Instruction"
    mov     [esp+0C0h+var_80], 0C0000025h
    mov     [esp+0C0h+var_7C], offset aNoncontinuable ; "Noncontinuable Exception"
    mov     [esp+0C0h+var_78], 0C0000026h
    mov     [esp+0C0h+var_74], offset aInvalidDisposi ; "Invalid Disposition"
    mov     [esp+0C0h+var_70], 0C000008Ch
    mov     [esp+0C0h+var_6C], offset aArrayBoundsExc ; "Array Bounds Exceeded"
    mov     [esp+0C0h+var_68], 0C000008Dh
    mov     [esp+0C0h+var_64], offset aFloatDenormalO ; "Float Denormal Operand"
    mov     [esp+0C0h+var_60], 0C000008Eh
    mov     [esp+0C0h+var_5C], offset aFloatDivideByZ ; "Float Divide by Zero"
    mov     [esp+0C0h+var_58], 0C000008Fh
    mov     [esp+0C0h+var_54], offset aFloatInexactRe ; "Float Inexact Result"
    mov     [esp+0C0h+var_50], 0C0000090h
    mov     [esp+0C0h+var_4C], offset aFloatInvalidOp ; "Float Invalid Operation"
    mov     [esp+0C0h+var_48], 0C0000091h
    mov     [esp+0C0h+var_44], offset aFloatOverflow ; "Float Overflow"
    mov     [esp+0C0h+var_40], 0C0000092h
    mov     [esp+0C0h+var_3C], offset aFloatStackChec ; "Float Stack Check"
    mov     [esp+0C0h+var_38], 0C0000093h
    mov     [esp+0C0h+var_34], offset aFloatUnderflow ; "Float Underflow"
    mov     [esp+0C0h+var_30], 0C0000094h
    mov     [esp+0C0h+var_2C], offset aIntegerDivideB ; "Integer Divide by Zero"
    mov     [esp+0C0h+var_28], 0C0000095h
    mov     [esp+0C0h+var_24], offset aIntegerOverflo ; "Integer Overflow"
    mov     [esp+0C0h+var_20], 0C0000096h
    mov     [esp+0C0h+var_1C], offset aPrivilegedInst ; "Privileged Instruction"
    mov     [esp+0C0h+var_18], 0C00000FDh
    mov     [esp+0C0h+var_14], offset aStackOverflow ; "Stack Overflow"
    mov     [esp+0C0h+var_10], 0C0000142h
    mov     [esp+0C0h+var_C], offset aDllInitializat ; "DLL Initialization Failed"
    mov     [esp+0C0h+var_8], 0E06D7363h
    mov     [esp+0C0h+var_4], offset aMicrosoftCExce ; "Microsoft C++ Exception"
    xor     eax, eax
    lea     ecx, [esp+0C0h+var_C0]

    loc_4D9A83:                             ; CODE XREF: sub_4D98C0+1CEj
    cmp     edx, [ecx]
    jz      short loc_4D9A9C
    inc     eax
    add     ecx, 8
    cmp     eax, 18h
    jb      short loc_4D9A83
    mov     eax, offset aUnknownExcepti     ; "Unknown exception type"
    add     esp, 0C0h
    retn
    ; ---------------------------------------------------------------------------

    loc_4D9A9C:                             ; CODE XREF: sub_4D98C0+1C5j
    mov     eax, [esp+eax*8+0C0h+var_BC]
    add     esp, 0C0h
    retn
    sub_4D98C0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset stru_4FDC28
    push    offset __except_handler3
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    add     esp, 0FFFFFC00h
    push    ebx
    push    esi
    push    edi
    mov     [ebp-18h], esp
    mov     ebx, [ebp+8]
    test    ebx, ebx
    jz      loc_4D9BED
    push    3E8h
    lea     eax, [ebp-400h]
    push    eax
    push    0
    call    ds:GetModuleFileNameA
    test    eax, eax
    jbe     loc_4D9BED
    push    5Ch
    lea     ecx, [ebp-400h]
    push    ecx
    call    _strrchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4D9B1B
    mov     byte ptr [eax+1], 0
    jmp     short loc_4D9B43
    ; ---------------------------------------------------------------------------

    loc_4D9B1B:                             ; CODE XREF: .text:004D9B13j
    lea     edx, [ebp-400h]
    mov     edi, offset aC_0                ; "C:\\"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4D9B43:                             ; CODE XREF: .text:004D9B19j
    lea     edx, [ebp-400h]
    mov     edi, offset aErrorlog_txt       ; "ErrorLog.txt"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    dec     edi
    mov     ecx, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    push    eax
    push    80h
    push    4
    push    eax
    push    eax
    push    40000000h
    lea     eax, [ebp-400h]
    push    eax
    call    ds:CreateFileA
    mov     esi, eax
    test    esi, esi
    jz      short loc_4D9BED
    push    2
    push    0
    push    0
    push    esi
    call    ds:SetFilePointer
    push    0
    lea     ecx, [ebp-40Ch]
    push    ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    push    ebx
    push    esi
    mov     ebx, ds:WriteFile
    call    ebx ; WriteFile
    push    0
    lea     edx, [ebp-40Ch]
    push    edx
    mov     edi, offset asc_50C8C8          ; "\r\n\r\n"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    ecx
    push    offset asc_50C8C8               ; "\r\n\r\n"
    push    esi
    call    ebx ; WriteFile
    push    esi
    call    ds:CloseHandle
    mov     ebx, [ebp+8]

    loc_4D9BED:                             ; CODE XREF: .text:004D9ADEj
                                            ; .text:004D9AFAj ...
    mov     dword ptr [ebp-4], 0
    int     3                               ; Trap to Debugger
    mov     dword ptr [ebp-4], 0FFFFFFFFh
    jmp     short loc_4D9C22

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D9BFE proc near                    ; DATA XREF: .rdata:004FDC28o
    push    offset aFatalErrorHand          ; "fatal error handler"
    mov     eax, [ebp-14h]
    push    eax
    call    sub_4D8E60
    add     esp, 8

    unknown_libname_59:
    mov     eax, 1
    retn
    sub_4D9BFE endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D9C15 proc near                    ; DATA XREF: .rdata:004FDC28o
    mov     esp, [ebp-18h]
    mov     dword ptr [ebp-4], 0FFFFFFFFh
    mov     ebx, [ebp+8]

    loc_4D9C22:                             ; CODE XREF: .text:004D9BFCj
    test    ebx, ebx
    jz      short loc_4D9C39
    push    41010h                          ; uType
    push    offset aCavedog                 ; lpCaption
    push    ebx                             ; lpText
    push    0                               ; hWnd
    call    ds:MessageBoxA

    loc_4D9C39:                             ; CODE XREF: sub_4D9C15+Fj
    call    nullsub_22
    call    sub_4DA0C0
    mov     ecx, [ebp-10h]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    sub_4D9C15 endp ; sp =  4

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D9C60 proc near                    ; CODE XREF: sub_4D8E60+54p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_4]
    lea     edx, [ecx+207Ch]
    push    edx
    lea     edx, [ecx+7Ch]
    push    800h
    push    edx
    lea     edx, [ecx+78h]
    mov     [ecx+2080h], eax
    push    edx
    mov     edx, [esp+10h+arg_8]
    push    1Eh
    push    ecx
    mov     ecx, [esp+18h+arg_C]
    push    ecx
    push    edx
    push    eax
    mov     eax, [esp+24h+arg_0]
    push    eax
    call    sub_4DE600
    add     esp, 28h
    retn    10h
    sub_4D9C60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D9CA0 proc near                    ; CODE XREF: sub_4D8E60+60p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 18h
    mov     eax, [ecx+207Ch]
    mov     edx, [ecx+2080h]
    push    ebx
    push    ebp
    push    esi
    mov     esi, [ecx+78h]
    test    esi, esi
    push    edi
    mov     [esp+28h+var_8], ecx
    mov     [esp+28h+var_14], eax
    mov     [esp+28h+var_4], edx
    mov     [esp+28h+var_C], esi
    mov     [esp+28h+var_18], 0A44Ch
    lea     ebx, [ecx+2084h]
    jle     loc_4D9DC8
    push    offset aCallStack               ; "Call stack:\n"
    push    ebx
    call    _sprintf
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, 0A44Ch
    sub     eax, ecx
    mov     edi, ebx
    mov     [esp+28h+var_18], eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    xor     ebp, ebp
    repne scasb
    not     ecx
    dec     ecx
    add     ebx, ecx
    test    esi, esi
    jle     loc_4D9DCB
    mov     eax, [esp+28h+var_8]
    mov     [esp+28h+var_10], eax
    jmp     short loc_4D9D27
    ; ---------------------------------------------------------------------------

    loc_4D9D23:                             ; CODE XREF: sub_4D9CA0+120j
    mov     esi, [esp+28h+var_C]

    loc_4D9D27:                             ; CODE XREF: sub_4D9CA0+81j
    cmp     [esp+28h+var_18], 1Eh
    jbe     loc_4D9DCB
    mov     ecx, [esp+28h+var_10]
    mov     edx, [ecx]
    push    edx
    push    offset a08lx                    ; "%08lX"
    push    ebx
    call    _sprintf
    add     esp, 0Ch
    dec     esi
    cmp     ebp, esi
    jz      short loc_4D9D64
    mov     eax, ebp
    mov     edi, offset asc_50C8E8          ; " "
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 7
    xor     eax, edx
    sub     eax, edx
    cmp     eax, 7
    jnz     short loc_4D9D69

    loc_4D9D64:                             ; CODE XREF: sub_4D9CA0+AAj
    mov     edi, offset byte_50319C

    loc_4D9D69:                             ; CODE XREF: sub_4D9CA0+C2j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     edx, [esp+28h+var_18]
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ebx
    sub     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+28h+var_C]
    mov     [esp+28h+var_18], edx
    not     ecx
    dec     ecx
    add     ebx, ecx
    mov     ecx, [esp+28h+var_10]
    inc     ebp
    add     ecx, 4
    cmp     ebp, eax
    mov     [esp+28h+var_10], ecx
    jl      loc_4D9D23
    jmp     short loc_4D9DCB
    ; ---------------------------------------------------------------------------

    loc_4D9DC8:                             ; CODE XREF: sub_4D9CA0+36j
    mov     byte ptr [ebx], 0

    loc_4D9DCB:                             ; CODE XREF: sub_4D9CA0+73j
                                            ; sub_4D9CA0+8Cj ...
    mov     eax, [esp+28h+var_14]
    test    eax, eax
    jle     loc_4D9F1F
    cmp     [esp+28h+var_18], 1Eh
    jbe     loc_4D9F1F
    push    offset aStackDump               ; "Stack dump:\n"
    push    ebx
    call    _sprintf
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 8
    repne scasb
    mov     ebp, [esp+28h+var_18]
    mov     edi, ebx
    not     ecx
    dec     ecx
    sub     ebp, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+28h+var_14]
    mov     [esp+28h+var_18], ebp
    not     ecx
    dec     ecx
    xor     ebp, ebp
    add     ebx, ecx
    test    eax, eax
    jle     loc_4D9F1F
    mov     ecx, [esp+28h+var_8]
    mov     eax, [esp+28h+var_4]
    add     ecx, 7Ch
    mov     [esp+28h+var_10], eax
    mov     [esp+28h+var_C], ecx

    loc_4D9E33:                             ; CODE XREF: sub_4D9CA0+279j
    cmp     [esp+28h+var_18], 1Eh
    jbe     loc_4D9F1F
    mov     eax, ebp
    cdq
    xor     eax, edx
    sub     eax, edx
    and     eax, 7
    xor     eax, edx
    mov     esi, eax
    sub     esi, edx
    jnz     short loc_4D9E87
    mov     edx, [esp+28h+var_10]
    push    edx
    push    offset a08lx_0                  ; "%08lX: "
    push    ebx
    call    _sprintf
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    mov     eax, [esp+28h+var_18]
    mov     edi, ebx
    not     ecx
    dec     ecx
    sub     eax, ecx
    or      ecx, 0FFFFFFFFh
    mov     [esp+28h+var_18], eax
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    add     ebx, ecx

    loc_4D9E87:                             ; CODE XREF: sub_4D9CA0+1AEj
    mov     eax, [esp+28h+var_C]
    mov     ecx, [eax]
    push    ecx
    push    offset a08lx                    ; "%08lX"
    push    ebx
    call    _sprintf
    mov     edx, [esp+34h+var_14]
    add     esp, 0Ch
    dec     edx
    cmp     ebp, edx
    jz      short loc_4D9EAF
    cmp     esi, 7
    mov     edi, offset asc_50C8E8          ; " "
    jnz     short loc_4D9EB4

    loc_4D9EAF:                             ; CODE XREF: sub_4D9CA0+203j
    mov     edi, offset byte_50319C

    loc_4D9EB4:                             ; CODE XREF: sub_4D9CA0+20Dj
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     edx, [esp+28h+var_10]
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     esi, [esp+28h+var_18]
    mov     edi, ebx
    not     ecx
    dec     ecx
    sub     esi, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, 4
    add     ebx, ecx
    mov     ecx, [esp+28h+var_C]
    add     edx, eax
    add     ecx, eax
    mov     eax, [esp+28h+var_14]
    inc     ebp
    cmp     ebp, eax
    mov     [esp+28h+var_18], esi
    mov     [esp+28h+var_10], edx
    mov     [esp+28h+var_C], ecx
    jl      loc_4D9E33

    loc_4D9F1F:                             ; CODE XREF: sub_4D9CA0+131j
                                            ; sub_4D9CA0+13Cj ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn
    sub_4D9CA0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+8]
    sub     eax, 0
    jz      short loc_4D9F45
    dec     eax
    jnz     short loc_4D9F45
    mov     eax, [esp+4]
    mov     dword_5289C4, eax

    loc_4D9F45:                             ; CODE XREF: .text:004D9F37j
                                            ; .text:004D9F3Aj
    mov     eax, 1
    retn    0Ch
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D9F50 proc near                    ; CODE XREF: .text:004DA517p
                                            ; sub_4DA540+27p ...
    mov     eax, dword_5289C4
    retn
    sub_4D9F50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4D9F60 proc near                    ; CODE XREF: sub_4D9FE0+Ep
                                            ; sub_4D9FE0+1Fp ...

    arg_0= dword ptr  0Ch

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_0]
    push    esi
    test    ebp, ebp
    push    edi
    jz      short loc_4D9FCF
    call    ds:GetCommandLineA
    mov     esi, eax
    test    esi, esi
    jz      short loc_4D9FCF
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, ecx
    jz      short loc_4D9FCF
    cmp     byte ptr [esi], 0
    jz      short loc_4D9FCF

    loc_4D9F8D:                             ; CODE XREF: sub_4D9F60+5Ej
    push    edi                             ; size_t
    push    ebp                             ; char *
    push    esi                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4D9FB8
    mov     bl, [edi+esi]
    test    bl, bl
    jz      short loc_4D9FC7
    movsx   eax, bl
    push    eax                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jnz     short loc_4D9FC7
    cmp     bl, 3Dh
    jz      short loc_4D9FC7

    loc_4D9FB8:                             ; CODE XREF: sub_4D9F60+3Aj
    mov     al, [esi+1]
    inc     esi
    test    al, al
    jnz     short loc_4D9F8D
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4D9FC7:                             ; CODE XREF: sub_4D9F60+41j
                                            ; sub_4D9F60+51j ...
    lea     eax, [edi+esi]
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4D9FCF:                             ; CODE XREF: sub_4D9F60+Aj
                                            ; sub_4D9F60+16j ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn
    sub_4D9F60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4D9FE0(int,int,char,int,int,int,int)
    sub_4D9FE0 proc near                    ; CODE XREF: sub_4D80D0+3Fp
                                            ; sub_4D8140+2Ep ...

    arg_8= byte ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    mov     al, [esp+arg_8]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+4+arg_C]
    push    ecx
    mov     [esi], al
    call    sub_4D9F60
    add     esp, 4
    test    eax, eax
    jnz     short loc_4DA00B
    mov     edx, [esp+4+arg_14]
    push    edx
    call    sub_4D9F60
    add     esp, 4
    test    eax, eax
    jz      short loc_4DA00E

    loc_4DA00B:                             ; CODE XREF: sub_4D9FE0+18j
    mov     byte ptr [esi], 1

    loc_4DA00E:                             ; CODE XREF: sub_4D9FE0+29j
    mov     eax, [esp+4+arg_10]
    push    eax
    call    sub_4D9F60
    add     esp, 4
    test    eax, eax
    jnz     short loc_4DA030
    mov     ecx, [esp+4+arg_18]
    push    ecx
    call    sub_4D9F60
    add     esp, 4
    test    eax, eax
    jz      short loc_4DA033

    loc_4DA030:                             ; CODE XREF: sub_4D9FE0+3Dj
    mov     byte ptr [esi], 0

    loc_4DA033:                             ; CODE XREF: sub_4D9FE0+4Ej
    mov     eax, esi
    pop     esi
    retn    1Ch
    sub_4D9FE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA040 proc near                    ; CODE XREF: sub_4D8260+2Dp

    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    mov     eax, [esp+arg_8]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+4+arg_C]
    push    ecx
    mov     [esi], eax
    call    sub_4D9F60
    add     esp, 4
    test    eax, eax
    jz      short loc_4DA0A4

    loc_4DA05A:                             ; CODE XREF: sub_4DA040+2Cj
    mov     cl, [eax]
    cmp     cl, 20h
    jz      short loc_4DA06B
    cmp     cl, 9
    jz      short loc_4DA06B
    cmp     cl, 3Dh
    jnz     short loc_4DA06E

    loc_4DA06B:                             ; CODE XREF: sub_4DA040+1Fj
                                            ; sub_4DA040+24j
    inc     eax
    jmp     short loc_4DA05A
    ; ---------------------------------------------------------------------------

    loc_4DA06E:                             ; CODE XREF: sub_4DA040+29j
    cmp     byte ptr [eax], 30h
    jnz     short loc_4DA095
    mov     cl, [eax+1]
    cmp     cl, 78h
    jz      short loc_4DA080
    cmp     cl, 58h
    jnz     short loc_4DA095

    loc_4DA080:                             ; CODE XREF: sub_4DA040+39j
    push    esi
    push    offset asc_50D26C               ; "%x"
    push    eax
    call    _sscanf
    add     esp, 0Ch
    mov     eax, esi
    pop     esi
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4DA095:                             ; CODE XREF: sub_4DA040+31j
                                            ; sub_4DA040+3Ej
    push    esi
    push    offset aD_0                     ; "%d"
    push    eax
    call    _sscanf
    add     esp, 0Ch

    loc_4DA0A4:                             ; CODE XREF: sub_4DA040+18j
    mov     eax, esi
    pop     esi
    retn    10h
    sub_4DA040 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, 3E4h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA0C0 proc near                    ; CODE XREF: sub_4D9C15+29p
                                            ; sub_4DA150+67p
    call    nullsub_22
    push    16h
    call    _raise
    add     esp, 4
    push    3                               ; int
    call    __exit
    ; ---------------------------------------------------------------------------
    add     esp, 4
    retn
    sub_4DA0C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4DA0E0(char *)
    sub_4DA0E0 proc near                    ; CODE XREF: sub_49EE30+DBp

    arg_0= dword ptr  8

    push    ebx
    mov     ebx, [esp+arg_0]
    push    esi
    push    edi
    mov     esi, offset off_50C908

    loc_4DA0EC:                             ; CODE XREF: sub_4DA0E0+32j
    mov     edx, [esi]
    or      ecx, 0FFFFFFFFh
    mov     edi, edx
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    ecx                             ; size_t
    push    ebx                             ; char *
    push    edx                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4DA11A
    add     esi, 4
    cmp     esi, offset dword_50C954
    jb      short loc_4DA0EC
    xor     al, al
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4DA11A:                             ; CODE XREF: sub_4DA0E0+27j
    mov     al, 1
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_4DA0E0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    ; int __cdecl sub_4DA120(LPCSTR lpText)
    sub_4DA120 proc near                    ; CODE XREF: sub_4DA150+46p
                                            ; sub_4DA150+5Fp

    lpText= dword ptr  8

    push    ebp
    mov     ebp, esp
    mov     eax, [ebp+lpText]
    push    eax                             ; lpOutputString
    call    ds:OutputDebugStringA
    push    0                               ; uType
    push    offset aCavedog                 ; lpCaption
    mov     ecx, [ebp+lpText]
    push    ecx                             ; lpText
    push    0                               ; hWnd
    call    ds:MessageBoxA
    pop     ebp
    retn
    sub_4DA120 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4DA150 proc near                    ; CODE XREF: sub_4DA1D0+53p

    var_8= dword ptr -8
    hLibModule= dword ptr -4
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    sub     esp, 8
    push    offset aDebughelper_dl          ; lpLibFileName
    call    ds:LoadLibraryA
    mov     [ebp+hLibModule], eax
    cmp     [ebp+hLibModule], 0
    jz      short loc_4DA1AA
    push    offset aDebugfunc1              ; lpProcName
    mov     eax, [ebp+hLibModule]
    push    eax                             ; hModule
    call    ds:GetProcAddress
    mov     [ebp+var_8], eax
    cmp     [ebp+var_8], 0
    jz      short loc_4DA191
    mov     ecx, [ebp+arg_0]
    push    ecx
    call    [ebp+var_8]
    add     esp, 4
    mov     [ebp+arg_0], eax
    jmp     short loc_4DA19E
    ; ---------------------------------------------------------------------------

    loc_4DA191:                             ; CODE XREF: sub_4DA150+30j
    push    offset aCouldnTFindFun          ; lpText
    call    sub_4DA120
    add     esp, 4

    loc_4DA19E:                             ; CODE XREF: sub_4DA150+3Fj
    mov     edx, [ebp+hLibModule]
    push    edx                             ; hLibModule
    call    ds:FreeLibrary
    jmp     short loc_4DA1B7
    ; ---------------------------------------------------------------------------

    loc_4DA1AA:                             ; CODE XREF: sub_4DA150+18j
    push    offset aCouldnTFindLib          ; lpText
    call    sub_4DA120
    add     esp, 4

    loc_4DA1B7:                             ; CODE XREF: sub_4DA150+58j
    call    sub_4DA0C0
    mov     eax, [ebp+arg_0]
    mov     esp, ebp
    pop     ebp
    retn
    sub_4DA150 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4DA1D0 proc near                    ; CODE XREF: sub_49E830+Cp
                                            ; .text:004DA3E5p

    ThreadId= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    sub     esp, 10h
    xor     eax, eax
    mov     al, byte_5289CC
    test    eax, eax
    jz      short loc_4DA1E6
    jmp     loc_4DA297
    ; ---------------------------------------------------------------------------

    loc_4DA1E6:                             ; CODE XREF: sub_4DA1D0+Fj
    mov     byte_5289CC, 1
    push    offset aDebughelper             ; "-debughelper"
    call    sub_4D9F60
    add     esp, 4
    mov     [ebp+var_4], eax
    cmp     [ebp+var_4], 0
    jz      short loc_4DA22B
    mov     [ebp+var_8], 0
    lea     ecx, [ebp+var_8]
    push    ecx
    push    offset aD_4                     ; "=%d"
    mov     edx, [ebp+var_4]
    push    edx
    call    _sscanf
    add     esp, 0Ch
    mov     eax, [ebp+var_8]
    push    eax
    call    sub_4DA150
    add     esp, 4

    loc_4DA22B:                             ; CODE XREF: sub_4DA1D0+31j
    push    offset aWindir                  ; char *
    call    _getenv
    add     esp, 4
    mov     ecx, [ebp+arg_0]
    and     ecx, 2
    test    ecx, ecx
    jnz     short loc_4DA24D
    push    offset TopLevelExceptionFilter  ; lpTopLevelExceptionFilter
    call    ds:SetUnhandledExceptionFilter

    loc_4DA24D:                             ; CODE XREF: sub_4DA1D0+70j
    mov     edx, [ebp+arg_0]
    and     edx, 4
    test    edx, edx
    jnz     short loc_4DA25C
    call    sub_4DF160

    loc_4DA25C:                             ; CODE XREF: sub_4DA1D0+85j
    mov     eax, [ebp+arg_0]
    and     eax, 8
    test    eax, eax
    jnz     short loc_4DA297
    lea     ecx, [ebp+ThreadId]
    push    ecx                             ; lpThreadId
    push    0                               ; dwCreationFlags
    push    0                               ; lpParameter
    push    offset StartAddress             ; lpStartAddress
    push    1F40h                           ; dwStackSize
    push    0                               ; lpThreadAttributes
    call    ds:CreateThread
    mov     [ebp+var_C], eax
    cmp     [ebp+var_C], 0
    jz      short loc_4DA297

    loc_4DA289:                             ; CODE XREF: sub_4DA1D0+C5j
    xor     edx, edx
    mov     dl, byte_5289C8
    test    edx, edx
    jnz     short loc_4DA297
    jmp     short loc_4DA289
    ; ---------------------------------------------------------------------------

    loc_4DA297:                             ; CODE XREF: sub_4DA1D0+11j
                                            ; sub_4DA1D0+94j ...
    mov     esp, ebp
    pop     ebp
    retn
    sub_4DA1D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; LONG __stdcall TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *)
    TopLevelExceptionFilter proc near       ; DATA XREF: sub_4DA1D0+72o

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    offset aGlobalExceptio          ; "Global Exception Handler"
    push    eax
    call    sub_4D8E60
    add     esp, 8
    retn    4
    TopLevelExceptionFilter endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    ; DWORD __stdcall StartAddress(LPVOID)
    StartAddress proc near                  ; DATA XREF: sub_4DA1D0+9Eo

    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    mov     eax, [ebp+arg_0]
    push    eax
    call    sub_4DA2E0
    add     esp, 4
    xor     eax, eax
    pop     ebp
    retn    4
    StartAddress endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4DA2E0 proc near                    ; CODE XREF: StartAddress+7p

    nPriority= dword ptr -28h
    Msg= MSG ptr -24h
    var_8= dword ptr -8
    hThread= dword ptr -4

    push    ebp
    mov     ebp, esp
    sub     esp, 28h
    call    ds:GetCurrentThread
    mov     [ebp+hThread], eax
    mov     eax, [ebp+hThread]
    push    eax                             ; hThread
    call    ds:GetThreadPriority
    mov     [ebp+nPriority], eax
    push    1                               ; nPriority
    mov     ecx, [ebp+hThread]
    push    ecx                             ; hThread
    call    ds:SetThreadPriority
    call    sub_4E1460
    call    sub_4DFE80
    mov     edx, [ebp+nPriority]
    push    edx                             ; nPriority
    mov     eax, [ebp+hThread]
    push    eax                             ; hThread
    call    ds:SetThreadPriority
    mov     byte_5289C8, 1

    loc_4DA327:                             ; CODE XREF: sub_4DA2E0+8Cj
    push    0                               ; wMsgFilterMax
    push    0                               ; wMsgFilterMin
    push    0                               ; hWnd
    lea     ecx, [ebp+Msg]
    push    ecx                             ; lpMsg
    call    ds:GetMessageA
    mov     [ebp+var_8], eax
    cmp     [ebp+var_8], 0
    jz      short loc_4DA36E
    cmp     [ebp+var_8], 0FFFFFFFFh
    jnz     short loc_4DA348
    jmp     short loc_4DA36C
    ; ---------------------------------------------------------------------------

    loc_4DA348:                             ; CODE XREF: sub_4DA2E0+64j
    lea     edx, [ebp+Msg]
    push    edx                             ; lpMsg
    call    sub_4DA380
    add     esp, 4
    test    eax, eax
    jnz     short loc_4DA36C
    lea     eax, [ebp+Msg]
    push    eax                             ; lpMsg
    call    ds:TranslateMessage
    lea     ecx, [ebp+Msg]
    push    ecx                             ; lpMsg
    call    ds:DispatchMessageA

    loc_4DA36C:                             ; CODE XREF: sub_4DA2E0+66j
                                            ; sub_4DA2E0+76j
    jmp     short loc_4DA327
    ; ---------------------------------------------------------------------------

    loc_4DA36E:                             ; CODE XREF: sub_4DA2E0+5Ej
    mov     esp, ebp
    pop     ebp
    retn
    sub_4DA2E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    ; int __cdecl sub_4DA380(LPMSG lpMsg)
    sub_4DA380 proc near                    ; CODE XREF: sub_4DA2E0+6Cp

    hWnd= dword ptr -8
    hDlg= dword ptr -4
    lpMsg= dword ptr  8

    push    ebp
    mov     ebp, esp
    sub     esp, 8
    mov     eax, [ebp+lpMsg]
    mov     ecx, [eax]
    mov     [ebp+hWnd], ecx
    mov     edx, [ebp+hWnd]
    mov     [ebp+hDlg], edx

    loc_4DA394:                             ; CODE XREF: sub_4DA380+2Dj
    cmp     [ebp+hWnd], 0
    jz      short loc_4DA3AF
    mov     eax, [ebp+hWnd]
    mov     [ebp+hDlg], eax
    mov     ecx, [ebp+hWnd]
    push    ecx                             ; hWnd
    call    ds:GetParent
    mov     [ebp+hWnd], eax
    jmp     short loc_4DA394
    ; ---------------------------------------------------------------------------

    loc_4DA3AF:                             ; CODE XREF: sub_4DA380+18j
    cmp     [ebp+hDlg], 0
    jz      short loc_4DA3CE
    mov     edx, [ebp+lpMsg]
    push    edx                             ; lpMsg
    mov     eax, [ebp+hDlg]
    push    eax                             ; hDlg
    call    ds:IsDialogMessageA
    test    eax, eax
    jz      short loc_4DA3CE
    mov     eax, 1
    jmp     short loc_4DA3D0
    ; ---------------------------------------------------------------------------

    loc_4DA3CE:                             ; CODE XREF: sub_4DA380+33j
                                            ; sub_4DA380+45j
    xor     eax, eax

    loc_4DA3D0:                             ; CODE XREF: sub_4DA380+4Cj
    mov     esp, ebp
    pop     ebp
    retn
    sub_4DA380 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebp
    mov     ebp, esp
    push    0
    call    sub_4DA1D0
    add     esp, 4
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA3F0 proc near                    ; CODE XREF: sub_4D8E60+A03p

    arg_0= dword ptr  10h
    arg_4= dword ptr  14h

    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     eax, [esp+4+arg_4]
    mov     bl, 0Ah
    not     ecx
    dec     ecx
    sub     eax, ecx
    lea     edi, [eax+esi-1]
    mov     al, [esi]
    mov     ebp, edi
    sub     ebp, esi
    test    al, al
    jz      short loc_4DA429
    mov     edx, esi

    loc_4DA41C:                             ; CODE XREF: sub_4DA3F0+37j
    cmp     al, bl
    jnz     short loc_4DA421
    dec     ebp

    loc_4DA421:                             ; CODE XREF: sub_4DA3F0+2Ej
    mov     al, [edx+1]
    inc     edx
    test    al, al
    jnz     short loc_4DA41C

    loc_4DA429:                             ; CODE XREF: sub_4DA3F0+28j
    test    ebp, ebp
    jle     short loc_4DA46D
    inc     ecx
    push    ecx                             ; size_t
    push    esi                             ; void *
    push    edi                             ; void *
    call    _memcpy
    mov     al, [edi]
    add     esp, 0Ch
    test    al, al
    jz      short loc_4DA46A

    loc_4DA43F:                             ; CODE XREF: sub_4DA3F0+78j
    cmp     al, 0Dh
    jnz     short loc_4DA453
    mov     [esi], al
    inc     esi
    mov     [esi], bl
    mov     al, [edi+1]
    inc     esi
    cmp     al, bl
    jnz     short loc_4DA462
    inc     edi
    jmp     short loc_4DA462
    ; ---------------------------------------------------------------------------

    loc_4DA453:                             ; CODE XREF: sub_4DA3F0+51j
    cmp     al, bl
    jnz     short loc_4DA45F
    mov     byte ptr [esi], 0Dh
    inc     esi
    mov     [esi], bl
    jmp     short loc_4DA461
    ; ---------------------------------------------------------------------------

    loc_4DA45F:                             ; CODE XREF: sub_4DA3F0+65j
    mov     [esi], al

    loc_4DA461:                             ; CODE XREF: sub_4DA3F0+6Dj
    inc     esi

    loc_4DA462:                             ; CODE XREF: sub_4DA3F0+5Ej
                                            ; sub_4DA3F0+61j
    mov     al, [edi+1]
    inc     edi
    test    al, al
    jnz     short loc_4DA43F

    loc_4DA46A:                             ; CODE XREF: sub_4DA3F0+4Dj
    mov     byte ptr [esi], 0

    loc_4DA46D:                             ; CODE XREF: sub_4DA3F0+3Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4DA3F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA480 proc near                    ; CODE XREF: .text:004DA4F6p
                                            ; sub_4DA540+6p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    push    esi
    push    edi
    xor     esi, esi
    xor     edi, edi
    sub     eax, 66h
    jz      short loc_4DA4AF
    dec     eax
    jz      short loc_4DA4A3
    sub     eax, 1Ah
    jnz     short loc_4DA4B9
    mov     esi, offset dword_50C958
    mov     edi, 3E0h
    jmp     short loc_4DA4B9
    ; ---------------------------------------------------------------------------

    loc_4DA4A3:                             ; CODE XREF: sub_4DA480+10j
    mov     esi, offset dword_50CED8
    mov     edi, 2C0h
    jmp     short loc_4DA4B9
    ; ---------------------------------------------------------------------------

    loc_4DA4AF:                             ; CODE XREF: sub_4DA480+Dj
    mov     esi, offset dword_50CD38
    mov     edi, 1A0h

    loc_4DA4B9:                             ; CODE XREF: sub_4DA480+15j
                                            ; sub_4DA480+21j ...
    test    esi, esi
    jz      short loc_4DA4DF
    test    edi, edi
    jz      short loc_4DA4DF
    push    edi                             ; dwBytes
    push    40h                             ; uFlags
    call    ds:GlobalAlloc
    mov     ecx, edi
    mov     edi, eax
    mov     edx, ecx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4DA4DF:                             ; CODE XREF: sub_4DA480+3Bj
                                            ; sub_4DA480+3Fj
    pop     edi
    xor     eax, eax
    pop     esi
    retn
    sub_4DA480 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    esi
    push    eax
    call    sub_4DA480
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jnz     short loc_4DA506
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4DA506:                             ; CODE XREF: .text:004DA502j
    mov     ecx, [esp+14h]
    mov     edx, [esp+10h]
    mov     eax, [esp+0Ch]
    push    edi
    push    ecx
    push    edx
    push    eax
    push    esi
    call    sub_4D9F50
    push    eax
    call    ds:DialogBoxIndirectParamA      ; Create a modal dialog box from a
                                            ; dialog box template in memory
    push    esi
    mov     edi, eax
    call    ds:GlobalFree
    mov     eax, edi
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA540 proc near                    ; CODE XREF: sub_4DF250+Fp
                                            ; sub_4E05C0+Fp

    arg_0= dword ptr  4
    hWndParent= dword ptr  8
    lpDialogFunc= dword ptr  0Ch
    dwInitParam= dword ptr  10h

    mov     eax, [esp+arg_0]
    push    esi
    push    eax
    call    sub_4DA480
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jnz     short loc_4DA556
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4DA556:                             ; CODE XREF: sub_4DA540+12j
    mov     ecx, [esp+4+dwInitParam]
    mov     edx, [esp+4+lpDialogFunc]
    mov     eax, [esp+4+hWndParent]
    push    edi
    push    ecx                             ; dwInitParam
    push    edx                             ; lpDialogFunc
    push    eax                             ; hWndParent
    push    esi                             ; lpTemplate
    call    sub_4D9F50
    push    eax                             ; hInstance
    call    ds:CreateDialogIndirectParamA   ; Create a modeless dialog box from
                                            ; a dialog box template in memory
    push    esi                             ; hMem
    mov     edi, eax
    call    ds:GlobalFree
    mov     eax, edi
    pop     edi
    pop     esi
    retn
    sub_4DA540 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    esi
    mov     esi, [esp+8]
    push    5Ch
    push    esi
    call    _strrchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4DA5A7
    inc     eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4DA5A7:                             ; CODE XREF: .text:004DA5A2j
    mov     eax, esi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA5B0 proc near                    ; CODE XREF: sub_4DF590+3E4p
                                            ; sub_4E0B90+79Ap

    hKey= dword ptr -9CCh
    cbValue= dword ptr -9C8h
    Value= byte ptr -9C4h
    File= byte ptr -7D0h
    Text= byte ptr -3E8h
    hWnd= dword ptr  4
    lpFile= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 9CCh
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+9DCh+lpFile]
    xor     esi, esi
    test    edi, edi
    jz      short loc_4DA5E5
    mov     eax, [esp+9DCh+hWnd]
    push    1                               ; nShowCmd
    push    offset Directory                ; lpDirectory
    push    esi                             ; lpParameters
    push    edi                             ; lpFile
    push    offset aOpen                    ; lpOperation
    push    eax                             ; hwnd
    call    ds:ShellExecuteA                ; Opens or prints a specified file
    mov     esi, eax

    loc_4DA5E5:                             ; CODE XREF: sub_4DA5B0+15j
    cmp     esi, 1Fh
    jg      loc_4DA771
    mov     eax, [esp+9DCh+arg_8]
    test    eax, eax
    jnz     short loc_4DA610
    test    edi, edi
    jz      short loc_4DA608
    push    2Eh                             ; int
    push    edi                             ; char *
    call    _strrchr
    add     esp, 8

    loc_4DA608:                             ; CODE XREF: sub_4DA5B0+4Bj
    test    eax, eax
    jz      loc_4DA738

    loc_4DA610:                             ; CODE XREF: sub_4DA5B0+47j
    mov     ebx, ds:RegOpenKeyA
    lea     ecx, [esp+9DCh+hKey]
    push    ecx                             ; phkResult
    push    eax                             ; lpSubKey
    push    80000000h                       ; hKey
    mov     [esp+9E8h+cbValue], 1F3h
    call    ebx ; RegOpenKeyA
    test    eax, eax
    jnz     loc_4DA738
    mov     ecx, [esp+9DCh+hKey]
    lea     edx, [esp+9DCh+cbValue]
    lea     eax, [esp+9DCh+Value]
    push    edx                             ; lpcbValue
    push    eax                             ; lpValue
    push    0                               ; lpSubKey
    push    ecx                             ; hKey
    call    ds:RegQueryValueA
    test    eax, eax
    jnz     loc_4DA738
    mov     edx, [esp+9DCh+hKey]
    mov     ebp, ds:RegCloseKey
    push    edx                             ; hKey
    call    ebp ; RegCloseKey
    mov     eax, [esp+9DCh+cbValue]
    lea     ecx, [esp+9DCh+Value]
    push    ecx
    lea     edx, [esp+9E0h+Text]
    push    offset aSShellOpenComm          ; "%s\\shell\\open\\command"
    push    edx
    mov     [esp+eax+9E8h+Value], 0
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+9DCh+hKey]
    lea     ecx, [esp+9DCh+Text]
    mov     [esp+9DCh+cbValue], 3E7h
    push    eax                             ; phkResult
    push    ecx                             ; lpSubKey
    push    80000000h                       ; hKey
    call    ebx ; RegOpenKeyA
    test    eax, eax
    jnz     loc_4DA738
    mov     ecx, [esp+9DCh+hKey]
    lea     edx, [esp+9DCh+cbValue]
    lea     eax, [esp+9DCh+File]
    push    edx                             ; lpcbValue
    push    eax                             ; lpValue
    push    0                               ; lpSubKey
    push    ecx                             ; hKey
    call    ds:RegQueryValueA
    test    eax, eax
    jnz     short loc_4DA738
    mov     edx, [esp+9DCh+hKey]
    push    edx                             ; hKey
    call    ebp ; RegCloseKey
    mov     eax, [esp+9DCh+cbValue]
    mov     [esp+eax+9DCh+File], 0
    mov     al, [esp+9DCh+File]
    cmp     al, 22h
    jnz     short loc_4DA6FA
    lea     ecx, [esp+20Dh]
    push    22h                             ; int
    push    ecx                             ; char *
    call    _strchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4DA713
    jmp     short loc_4DA710
    ; ---------------------------------------------------------------------------

    loc_4DA6FA:                             ; CODE XREF: sub_4DA5B0+130j
    lea     edx, [esp+9DCh+File]
    push    20h                             ; int
    push    edx                             ; char *
    call    _strchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4DA713

    loc_4DA710:                             ; CODE XREF: sub_4DA5B0+148j
    mov     byte ptr [eax], 0

    loc_4DA713:                             ; CODE XREF: sub_4DA5B0+146j
                                            ; sub_4DA5B0+15Ej
    mov     ecx, [esp+9DCh+hWnd]
    push    1                               ; nShowCmd
    push    offset Directory                ; lpDirectory
    lea     eax, [esp+9E4h+File]
    push    edi                             ; lpParameters
    push    eax                             ; lpFile
    push    offset aOpen                    ; lpOperation
    push    ecx                             ; hwnd
    call    ds:ShellExecuteA                ; Opens or prints a specified file
    mov     esi, eax

    loc_4DA738:                             ; CODE XREF: sub_4DA5B0+5Aj
                                            ; sub_4DA5B0+7Dj ...
    cmp     esi, 1Fh
    jg      short loc_4DA771
    push    esi
    push    edi
    lea     edx, [esp+9E4h+Text]
    push    offset aCannotStartS_S          ; "Cannot start %s. ShellExecute result is"...
    push    edx
    call    _sprintf
    mov     ecx, [esp+9ECh+hWnd]
    add     esp, 10h
    lea     eax, [esp+9DCh+Text]
    push    0                               ; uType
    push    offset aCavedog                 ; lpCaption
    push    eax                             ; lpText
    push    ecx                             ; hWnd
    call    ds:MessageBoxA

    loc_4DA771:                             ; CODE XREF: sub_4DA5B0+38j
                                            ; sub_4DA5B0+18Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 9CCh
    retn
    sub_4DA5B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA780 proc near                    ; CODE XREF: sub_4D83C0+3p
                                            ; Network_ReAllocPacketBuffer_Internal+5p ...
    mov     cl, byte_5289EC
    mov     al, 1
    test    al, cl
    jnz     short loc_4DA7AC
    or      cl, al
    push    offset CriticalSection          ; lpCriticalSection
    mov     byte_5289EC, cl
    call    ds:InitializeCriticalSection
    push    offset nullsub_24               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4DA7AC:                             ; CODE XREF: sub_4DA780+Aj
    mov     eax, offset CriticalSection
    retn
    sub_4DA780 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_24. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA7D0 proc near                    ; CODE XREF: sub_4D83C0+3Dp
                                            ; Network_ReAllocPacketBuffer_Internal+73p ...

    arg_0= dword ptr  4

    mov     eax, dword_528A04
    mov     ecx, dword_528A1C
    inc     eax
    mov     dword_528A04, eax
    mov     eax, dword_528A08
    inc     eax
    cmp     eax, ecx
    mov     dword_528A08, eax
    jbe     short loc_4DA7F5
    mov     dword_528A1C, eax

    loc_4DA7F5:                             ; CODE XREF: sub_4DA7D0+1Ej
    mov     eax, dword_5289DC
    mov     ecx, [esp+arg_0]
    add     eax, ecx
    cmp     eax, 3B9ACA00h
    mov     dword_5289DC, eax
    jb      short loc_4DA821
    sub     eax, 3B9ACA00h
    mov     dword_5289DC, eax
    mov     eax, dword_5289FC
    inc     eax
    mov     dword_5289FC, eax

    loc_4DA821:                             ; CODE XREF: sub_4DA7D0+3Aj
    mov     eax, dword_5289F8
    add     eax, ecx
    mov     ecx, dword_5289D8
    cmp     eax, ecx
    mov     dword_5289F8, eax
    jbe     short locret_4DA83C
    mov     dword_5289D8, eax

    locret_4DA83C:                          ; CODE XREF: sub_4DA7D0+65j
    retn
    sub_4DA7D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA840 proc near                    ; CODE XREF: Network_ReAllocPacketBuffer_Internal+66p
                                            ; sub_4D85B0+40p ...

    arg_0= dword ptr  4

    mov     eax, dword_528A08
    mov     ecx, dword_5289F8
    dec     eax
    mov     dword_528A08, eax
    mov     eax, [esp+arg_0]
    sub     ecx, eax
    mov     dword_5289F8, ecx
    retn
    sub_4DA840 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA860 proc near                    ; CODE XREF: sub_4E0B90+76Bp
    xor     eax, eax
    mov     dword_528A1C, eax
    mov     dword_528A08, eax
    mov     dword_528A04, eax
    mov     dword_5289D8, eax
    mov     dword_5289F8, eax
    mov     dword_5289DC, eax
    mov     dword_5289D0, eax
    mov     dword_5289F0, eax
    mov     dword_5289FC, eax
    mov     dword_528A00, eax
    retn
    sub_4DA860 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA8A0 proc near                    ; CODE XREF: sub_4DACF0+3Ep
                                            ; sub_4DB7D0+159p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    add     eax, 0FFFh
    and     eax, 0FFFFF000h
    shl     eax, 1
    retn
    sub_4DA8A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA8C0 proc near                    ; CODE XREF: sub_4DACF0+2Fp
                                            ; sub_4DB7D0+143p

    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    add     eax, 0FFFh
    and     eax, 0FFFFF000h
    retn
    sub_4DA8C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA8D0 proc near                    ; CODE XREF: sub_4DAA30+2Ap
                                            ; sub_4DAA30+3Fp ...

    var_9= byte ptr -9
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     eax, dword_528A44
    sub     esp, 0Ch
    push    ebx
    xor     ebx, ebx
    push    ebp
    push    esi
    cmp     eax, ebx
    push    edi
    jnz     loc_4DA9E3
    mov     ebp, ds:GlobalAlloc
    push    10h                             ; dwBytes
    push    ebx                             ; uFlags
    call    ebp ; GlobalAlloc
    mov     edi, eax
    cmp     edi, ebx
    jz      loc_4DA9DC
    mov     cl, [esp+1Ch+var_9]
    mov     al, [esp+1Ch+var_9]
    mov     [edi+1], cl
    lea     ecx, [esp+1Ch+var_4]
    mov     [edi], al
    mov     [edi+8], bl
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    cmp     dword_528A50, ebx
    jnz     short loc_4DA93F
    push    40h
    mov     ecx, edi
    call    sub_4DDDF0
    mov     [eax+4], ebx
    mov     dword ptr [eax+3Ch], 1
    mov     dword_528A50, eax
    mov     [eax], ebx
    mov     edx, dword_528A50
    mov     [edx+8], ebx

    loc_4DA93F:                             ; CODE XREF: sub_4DA8D0+4Aj
    mov     eax, dword_528A50
    mov     edx, dword_528A4C
    mov     [esp+1Ch+var_8], eax
    mov     eax, dword_5289E0
    inc     edx
    cmp     eax, ebx
    mov     dword_528A4C, edx
    jnz     short loc_4DA9A4

    loc_4DA95E:                             ; CODE XREF: sub_4DA8D0+B1j
    push    2000h                           ; dwBytes
    push    ebx                             ; uFlags
    call    ebp ; GlobalAlloc
    mov     esi, eax
    cmp     esi, ebx
    jnz     short loc_4DA98B
    mov     eax, dword_5289BC
    cmp     eax, ebx
    jz      short loc_4DA977
    call    eax

    loc_4DA977:                             ; CODE XREF: sub_4DA8D0+A3j
    cmp     esi, ebx
    jnz     short loc_4DA98B
    cmp     dword_5289BC, ebx
    jnz     short loc_4DA95E
    cmp     esi, ebx
    jnz     short loc_4DA98B
    xor     eax, eax
    jmp     short loc_4DA9AC
    ; ---------------------------------------------------------------------------

    loc_4DA98B:                             ; CODE XREF: sub_4DA8D0+9Aj
                                            ; sub_4DA8D0+A9j ...
    mov     eax, dword_5289E0
    mov     ecx, 80h

    loc_4DA995:                             ; CODE XREF: sub_4DA8D0+CDj
    mov     [esi], eax
    mov     eax, esi
    add     esi, 40h
    dec     ecx
    jnz     short loc_4DA995
    mov     dword_5289E0, eax

    loc_4DA9A4:                             ; CODE XREF: sub_4DA8D0+8Cj
    mov     ecx, [eax]
    mov     dword_5289E0, ecx

    loc_4DA9AC:                             ; CODE XREF: sub_4DA8D0+B9j
    mov     edx, [esp+1Ch+var_8]
    mov     [eax+3Ch], ebx
    mov     [eax+4], edx
    mov     [edi+4], eax
    mov     [edi+0Ch], ebx
    mov     [eax], eax
    mov     eax, [edi+4]
    lea     ecx, [esp+1Ch+var_4]
    mov     [eax+8], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, edi
    mov     dword_528A44, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4DA9DC:                             ; CODE XREF: sub_4DA8D0+25j
    xor     eax, eax
    mov     dword_528A44, eax

    loc_4DA9E3:                             ; CODE XREF: sub_4DA8D0+10j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_4DA8D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DA9F0 proc near                    ; CODE XREF: .text:004DABDEp
                                            ; .text:004DABEBp ...

    var_1= byte ptr -1

    push    ecx
    mov     eax, dword_528A48
    push    esi
    xor     esi, esi
    cmp     eax, esi
    jnz     short loc_4DAA2B
    push    14h                             ; dwBytes
    push    esi                             ; uFlags
    call    ds:GlobalAlloc
    cmp     eax, esi
    jz      short loc_4DAA24
    mov     cl, [esp+8+var_1]
    mov     [eax+4], esi
    mov     [eax], cl
    mov     [eax+8], esi
    mov     [eax+0Ch], esi
    mov     [eax+10h], esi
    mov     dword_528A48, eax
    pop     esi
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4DAA24:                             ; CODE XREF: sub_4DA9F0+18j
    xor     eax, eax
    mov     dword_528A48, eax

    loc_4DAA2B:                             ; CODE XREF: sub_4DA9F0+Bj
    pop     esi
    pop     ecx
    retn
    sub_4DA9F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DAA30 proc near                    ; CODE XREF: .text:004DAB36p

    var_34= dword ptr -34h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 34h
    push    ebx
    push    esi
    push    edi
    call    sub_4DA780
    mov     ebx, eax
    push    ebx                             ; lpCriticalSection
    call    ds:EnterCriticalSection
    mov     eax, [esp+40h+arg_0]
    push    0                               ; lpString2
    push    0                               ; int
    push    0                               ; int
    push    0                               ; int
    push    eax                             ; int
    lea     ecx, [esp+54h+var_30]
    call    sub_4D8820
    call    sub_4DA8D0
    lea     ecx, [esp+40h+var_30]
    push    ecx
    mov     ecx, eax
    call    sub_4DD7D0
    mov     [esp+40h+var_34], eax
    call    sub_4DA8D0
    mov     esi, [esp+40h+var_34]
    mov     ecx, [eax+4]
    xor     edx, edx
    cmp     esi, ecx
    setz    dl
    test    dl, dl
    jz      short loc_4DAA99
    mov     eax, [esp+40h+arg_8]
    mov     dword ptr [eax], 0
    mov     dword ptr [eax+4], 0
    jmp     short loc_4DAAA7
    ; ---------------------------------------------------------------------------

    loc_4DAA99:                             ; CODE XREF: sub_4DAA30+54j
    mov     edi, [esp+40h+arg_8]
    add     esi, 0Ch
    mov     ecx, 0Ch
    rep movsd

    loc_4DAAA7:                             ; CODE XREF: sub_4DAA30+67j
    call    sub_4DA8D0
    mov     eax, [eax+4]
    mov     edx, [esp+40h+var_34]
    xor     ecx, ecx
    cmp     edx, [eax]
    setz    cl
    test    cl, cl
    jz      short loc_4DAADD
    mov     eax, [esp+40h+arg_4]
    push    ebx                             ; lpCriticalSection
    mov     dword ptr [eax], 0
    mov     dword ptr [eax+4], 0
    call    ds:LeaveCriticalSection
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DAADD:                             ; CODE XREF: sub_4DAA30+8Cj
    lea     ecx, [esp+40h+var_34]
    call    sub_4DD820
    mov     eax, [esp+40h+var_34]
    mov     edi, [esp+40h+arg_4]
    mov     ecx, 0Ch
    push    ebx                             ; lpCriticalSection
    lea     esi, [eax+0Ch]
    rep movsd
    call    ds:LeaveCriticalSection
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 34h
    retn
    sub_4DAA30 endp

    ; ---------------------------------------------------------------------------
    align 10h
    sub     esp, 60h
    lea     ecx, [esp+0]
    push    esi
    push    edi
    call    sub_4D87F0
    lea     ecx, [esp+38h]
    call    sub_4D87F0
    mov     esi, [esp+6Ch]
    lea     eax, [esp+38h]
    lea     ecx, [esp+8]
    push    eax
    push    ecx
    push    esi
    call    sub_4DAA30
    mov     eax, [esp+14h]
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4DAB86
    cmp     esi, eax
    jb      short loc_4DAB58
    mov     edx, [esp+0Ch]
    add     edx, eax
    cmp     esi, edx
    jnb     short loc_4DAB58
    mov     al, 1
    jmp     short loc_4DAB5A
    ; ---------------------------------------------------------------------------

    loc_4DAB58:                             ; CODE XREF: .text:004DAB48j
                                            ; .text:004DAB52j
    xor     al, al

    loc_4DAB5A:                             ; CODE XREF: .text:004DAB56j
    test    al, al
    jz      short loc_4DAB86
    mov     eax, [esp+74h]
    mov     ecx, [esp+70h]
    push    eax
    push    ecx
    sub     esp, 30h
    mov     ecx, 0Ch
    lea     esi, [esp+40h]
    mov     edi, esp
    rep movsd
    call    sub_4D8790
    add     esp, 38h
    pop     edi
    pop     esi
    add     esp, 60h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DAB86:                             ; CODE XREF: .text:004DAB44j
                                            ; .text:004DAB5Cj
    mov     edi, offset aAddressIsNotWi     ; "Address is not within an allocated bloc"...
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, [esp+70h]
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    pop     edi
    pop     esi
    add     esp, 60h
    retn
    ; ---------------------------------------------------------------------------
    sub     esp, 34h
    push    ebp
    push    esi
    call    sub_4DA780
    mov     esi, eax
    push    esi
    mov     [esp+0Ch], esi
    call    ds:EnterCriticalSection
    mov     ebp, [esp+44h]
    mov     byte ptr [ebp+0], 0
    call    sub_4D80D0
    test    al, al
    jz      loc_4DACD8
    push    edi
    push    ebx
    call    sub_4DA9F0
    mov     esi, [eax+8]
    mov     byte ptr [esp+4Ch], 0
    call    sub_4DA9F0
    cmp     esi, [eax+4]
    jz      loc_4DACC1
    mov     ebx, [esp+50h]
    jmp     short loc_4DAC03
    ; ---------------------------------------------------------------------------

    loc_4DABFF:                             ; CODE XREF: .text:004DACBBj
    mov     esi, [esp+50h]

    loc_4DAC03:                             ; CODE XREF: .text:004DABFDj
    cmp     ebx, 64h
    jbe     loc_4DACC1
    sub     esi, 30h
    mov     ecx, 0Ch
    lea     edi, [esp+14h]
    mov     [esp+50h], esi
    rep movsd
    mov     eax, [esp+14h]
    mov     ecx, [esp+48h]
    cmp     ecx, eax
    jb      short loc_4DAC38
    mov     edx, [esp+18h]
    add     edx, eax
    cmp     ecx, edx
    jnb     short loc_4DAC38
    mov     al, 1
    jmp     short loc_4DAC3A
    ; ---------------------------------------------------------------------------

    loc_4DAC38:                             ; CODE XREF: .text:004DAC28j
                                            ; .text:004DAC32j
    xor     al, al

    loc_4DAC3A:                             ; CODE XREF: .text:004DAC36j
    test    al, al
    jz      short loc_4DACAD
    mov     al, [esp+4Ch]
    test    al, al
    jz      short loc_4DAC70
    mov     edi, offset byte_50319C
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4DAC70:                             ; CODE XREF: .text:004DAC44j
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    ebx
    repne scasb
    not     ecx
    dec     ecx
    lea     esi, [esp+18h]
    add     ecx, ebp
    push    ecx
    mov     ecx, 0Ch
    sub     esp, 30h
    mov     edi, esp
    rep movsd
    call    sub_4D8790
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 38h
    repne scasb
    not     ecx
    dec     ecx
    mov     byte ptr [esp+4Ch], 1
    add     ebp, ecx
    sub     ebx, ecx

    loc_4DACAD:                             ; CODE XREF: .text:004DAC3Cj
    call    sub_4DA9F0
    mov     ecx, [esp+50h]
    mov     edx, [eax+4]
    cmp     ecx, edx
    jnz     loc_4DABFF

    loc_4DACC1:                             ; CODE XREF: .text:004DABF3j
                                            ; .text:004DAC06j
    mov     edx, [esp+10h]
    push    edx
    call    ds:LeaveCriticalSection
    mov     al, [esp+4Ch]
    pop     ebx
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DACD8:                             ; CODE XREF: .text:004DABD6j
    push    esi
    call    ds:LeaveCriticalSection
    pop     esi
    xor     al, al
    pop     ebp
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DACF0 proc near                    ; CODE XREF: sub_4D83C0+21p
                                            ; sub_4DBA40+3Ap

    var_68= dword ptr -68h
    var_64= dword ptr -64h
    var_60= dword ptr -60h
    var_5C= dword ptr -5Ch
    var_58= dword ptr -58h
    var_54= dword ptr -54h
    lpCriticalSection= dword ptr -50h
    dwSize= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    var_40= dword ptr -40h
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_30= dword ptr -30h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 68h
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4DA780
    mov     edi, eax
    push    edi                             ; lpCriticalSection
    mov     [esp+7Ch+lpCriticalSection], edi
    call    ds:EnterCriticalSection
    mov     esi, [esp+78h+arg_0]
    mov     [esp+78h+var_54], 0
    test    esi, esi
    jnz     short loc_4DAD1E
    mov     esi, 1

    loc_4DAD1E:                             ; CODE XREF: sub_4DACF0+27j
    push    esi
    call    sub_4DA8C0
    add     esp, 4
    mov     ebx, eax
    mov     [esp+78h+dwSize], ebx
    push    esi
    call    sub_4DA8A0
    mov     ebp, eax
    add     esp, 4
    cmp     ebp, ebx
    mov     [esp+78h+var_68], ebp
    jnb     short loc_4DAD51
    push    edi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DAD51:                             ; CODE XREF: sub_4DACF0+4Ej
    call    sub_4DB610
    mov     edi, eax
    xor     esi, esi
    cmp     [edi+0Ch], esi
    jbe     loc_4DAEDE
    mov     eax, dword_5289D4
    lea     ecx, [esp+78h+var_40]
    lea     edx, [esp+78h+var_64]
    push    ecx
    push    edx
    mov     ecx, edi
    mov     [esp+80h+var_40], eax
    mov     [esp+80h+var_3C], esi
    call    sub_4DC620
    lea     eax, [esp+78h+var_5C]
    mov     ecx, edi
    push    eax
    call    sub_4DBEB0
    mov     eax, [esp+78h+var_64]
    mov     ebx, [esp+78h+var_5C]
    xor     ecx, ecx
    cmp     eax, ebx
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jz      short loc_4DADE0
    lea     edx, [esp+78h+var_48]
    push    esi
    push    edx
    lea     ecx, [esp+80h+var_5C]
    mov     [esp+80h+var_5C], eax
    call    sub_4DBE10
    mov     eax, [esp+78h+var_5C]
    mov     edx, dword_5289D4
    mov     ecx, [eax+0Ch]
    cmp     edx, ecx
    jb      short loc_4DADDC
    mov     ebx, [eax+10h]
    add     ebx, ecx
    lea     ecx, [ebp+edx+0]
    cmp     ecx, ebx
    ja      short loc_4DADDC
    mov     [esp+78h+var_64], eax
    jmp     short loc_4DADE0
    ; ---------------------------------------------------------------------------

    loc_4DADDC:                             ; CODE XREF: sub_4DACF0+D7j
                                            ; sub_4DACF0+E4j
    mov     eax, [esp+78h+var_64]

    loc_4DADE0:                             ; CODE XREF: sub_4DACF0+B3j
                                            ; sub_4DACF0+EAj
    mov     [esp+78h+var_60], eax

    loc_4DADE4:                             ; CODE XREF: sub_4DACF0+150j
    mov     ebx, [edi+4]
    xor     edx, edx
    cmp     eax, ebx
    setz    dl
    test    dl, dl
    jz      short loc_4DAE1E
    lea     eax, [esp+78h+var_5C]
    mov     ecx, edi
    push    eax
    call    sub_4DBEB0
    mov     edx, dword_528A00
    mov     eax, [esp+78h+var_5C]
    inc     edx
    mov     [esp+78h+var_60], eax
    mov     dword_5289D4, 0
    mov     dword_528A00, edx
    inc     esi

    loc_4DAE1E:                             ; CODE XREF: sub_4DACF0+100j
    cmp     [eax+10h], ebp
    jnb     short loc_4DAE42
    lea     ecx, [esp+78h+var_48]
    push    0
    push    ecx
    lea     ecx, [esp+80h+var_60]
    call    sub_4DBD80
    cmp     esi, 2
    jge     loc_4DAEDE
    mov     eax, [esp+78h+var_60]
    jmp     short loc_4DADE4
    ; ---------------------------------------------------------------------------

    loc_4DAE42:                             ; CODE XREF: sub_4DACF0+131j
    mov     ebp, [eax+10h]
    mov     esi, [eax+0Ch]
    lea     edx, [esp+78h+var_48]
    push    eax
    push    edx
    mov     ecx, edi
    mov     [esp+80h+var_58], ebp
    call    sub_4DBD00
    mov     ebx, dword_5289D4
    test    ebx, ebx
    jnz     short loc_4DAE6B
    mov     ebx, esi
    mov     dword_5289D4, ebx

    loc_4DAE6B:                             ; CODE XREF: sub_4DACF0+171j
    cmp     ebx, esi
    jb      short loc_4DAE7C
    mov     eax, [esp+78h+var_68]
    lea     ecx, [esi+ebp]
    add     eax, ebx
    cmp     eax, ecx
    jbe     short loc_4DAE7E

    loc_4DAE7C:                             ; CODE XREF: sub_4DACF0+17Dj
    mov     ebx, esi

    loc_4DAE7E:                             ; CODE XREF: sub_4DACF0+18Aj
    cmp     ebx, esi
    jbe     short loc_4DAE9F
    lea     eax, [esp+78h+var_48]
    mov     edx, ebx
    lea     ecx, [esp+78h+var_38]
    push    eax
    sub     edx, esi
    push    ecx
    mov     ecx, edi
    mov     [esp+80h+var_48], esi
    mov     [esp+80h+var_44], edx
    call    sub_4DBBC0

    loc_4DAE9F:                             ; CODE XREF: sub_4DACF0+190j
    mov     edx, [esp+78h+var_68]
    mov     eax, [esp+78h+var_58]
    lea     ebp, [ebx+edx]
    lea     ecx, [esi+eax]
    cmp     ebp, ecx
    jnb     short loc_4DAED2
    sub     esi, ebx
    mov     ecx, edi
    add     esi, eax
    mov     eax, edx
    sub     esi, eax
    lea     edx, [esp+78h+var_48]
    lea     eax, [esp+78h+var_38]
    push    edx
    push    eax
    mov     [esp+80h+var_48], ebp
    mov     [esp+80h+var_44], esi
    call    sub_4DBBC0

    loc_4DAED2:                             ; CODE XREF: sub_4DACF0+1BFj
    mov     dword_5289D4, ebp
    mov     ebp, [esp+78h+var_68]
    jmp     short loc_4DAEF8
    ; ---------------------------------------------------------------------------

    loc_4DAEDE:                             ; CODE XREF: sub_4DACF0+6Dj
                                            ; sub_4DACF0+146j
    push    ebp
    mov     ecx, edi
    call    sub_4DB450
    test    al, al
    jz      short loc_4DAEF6
    push    ebp
    mov     ecx, edi
    call    sub_4DB1C0
    mov     ebx, eax
    jmp     short loc_4DAEF8
    ; ---------------------------------------------------------------------------

    loc_4DAEF6:                             ; CODE XREF: sub_4DACF0+1F8j
    xor     ebx, ebx

    loc_4DAEF8:                             ; CODE XREF: sub_4DACF0+1ECj
                                            ; sub_4DACF0+204j
    test    ebx, ebx
    jz      short loc_4DAF25
    mov     ecx, [esp+78h+dwSize]
    push    4                               ; flProtect
    push    1000h                           ; flAllocationType
    push    ecx                             ; dwSize
    push    ebx                             ; lpAddress
    call    ds:VirtualAlloc
    test    eax, eax
    mov     [esp+78h+var_54], eax
    jnz     short loc_4DAF25
    call    sub_4DB610
    push    ebp
    push    ebx
    mov     ecx, eax
    call    sub_4DB000

    loc_4DAF25:                             ; CODE XREF: sub_4DACF0+20Aj
                                            ; sub_4DACF0+225j
    mov     ebx, [esp+78h+var_54]
    test    ebx, ebx
    jnz     short loc_4DAF42
    mov     edx, [esp+78h+lpCriticalSection]
    push    edx                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DAF42:                             ; CODE XREF: sub_4DACF0+23Bj
    mov     edi, [esp+78h+arg_0]
    mov     esi, edi
    and     esi, 0FFFh
    neg     esi
    and     esi, 0FFFh
    call    sub_4DB760
    test    al, al
    push    esi
    jz      short loc_4DAF73
    call    sub_4DB7C0
    push    eax
    push    ebx
    call    sub_4D82C0
    add     esp, 0Ch
    add     ebx, esi
    jmp     short loc_4DAF85
    ; ---------------------------------------------------------------------------

    loc_4DAF73:                             ; CODE XREF: sub_4DACF0+26Ej
    call    sub_4DB7C0
    push    eax
    lea     eax, [ebx+edi]
    push    eax
    call    sub_4D82C0
    add     esp, 0Ch

    loc_4DAF85:                             ; CODE XREF: sub_4DACF0+281j
    mov     ecx, [esp+78h+arg_4]
    mov     edx, dword_528A04
    push    0                               ; lpString2
    push    ecx                             ; int
    push    edx                             ; int
    push    edi                             ; int
    push    ebx                             ; int
    lea     ecx, [esp+8Ch+var_30]
    call    sub_4D8820
    call    sub_4DA8D0
    lea     ecx, [esp+78h+var_30]
    lea     edx, [esp+78h+var_38]
    push    ecx
    push    edx
    mov     ecx, eax
    call    sub_4DC680
    push    edi
    call    sub_4DA7D0
    mov     eax, dword_5289F0
    mov     ecx, dword_5289D0
    add     edi, 0FFFh
    add     esp, 4
    and     edi, 0FFFFF000h
    add     eax, edi
    cmp     eax, ecx
    mov     dword_5289F0, eax
    jbe     short loc_4DAFE7
    mov     dword_5289D0, eax

    loc_4DAFE7:                             ; CODE XREF: sub_4DACF0+2F0j
    mov     eax, [esp+78h+lpCriticalSection]
    push    eax                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    add     esp, 68h
    retn
    sub_4DACF0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DB000 proc near                    ; CODE XREF: sub_4DACF0+230p
                                            ; sub_4DB1C0+23Fp ...

    var_15= dword ptr -15h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    lea     eax, [esp+24h+arg_0]
    push    edi
    mov     ebp, ecx
    push    eax
    call    sub_4DD250
    mov     esi, eax
    mov     eax, [ebp+4]
    mov     [esp+28h+var_15+1], esi
    xor     ecx, ecx
    cmp     esi, [eax]
    setz    cl
    test    cl, cl
    jz      short loc_4DB02D
    mov     [esp+28h+var_15+1], eax
    jmp     short loc_4DB03A
    ; ---------------------------------------------------------------------------

    loc_4DB02D:                             ; CODE XREF: sub_4DB000+25j
    lea     ecx, [esp+28h+var_15+1]
    call    sub_4DD2A0
    mov     eax, [esp+28h+var_15+1]

    loc_4DB03A:                             ; CODE XREF: sub_4DB000+2Bj
    mov     ecx, [ebp+4]
    xor     edx, edx
    cmp     esi, ecx
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      short loc_4DB078
    mov     ecx, [esp+28h+arg_4]
    mov     edx, [esp+28h+arg_0]
    mov     edi, [esi+0Ch]
    add     edx, ecx
    cmp     edi, edx
    jnz     short loc_4DB078
    mov     edi, [esi+10h]
    lea     eax, [esp+28h+var_C]
    add     ecx, edi
    push    esi
    mov     [esp+2Ch+arg_4], ecx
    push    eax
    mov     ecx, ebp
    call    sub_4DC130
    mov     eax, [esp+28h+var_15+1]

    loc_4DB078:                             ; CODE XREF: sub_4DB000+4Bj
                                            ; sub_4DB000+5Cj
    mov     ebx, [ebp+4]
    xor     ecx, ecx
    cmp     eax, ebx
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jz      short loc_4DB0BB
    mov     ecx, [eax+10h]
    mov     edi, [eax+0Ch]
    mov     esi, [esp+28h+arg_0]
    mov     edx, ecx
    add     edx, edi
    cmp     edx, esi
    jnz     short loc_4DB0BB
    mov     edx, [esp+28h+arg_4]
    push    eax
    add     edx, ecx
    mov     [esp+2Ch+arg_4], edx
    mov     ecx, [eax+0Ch]
    lea     edx, [esp+2Ch+var_C]
    mov     [esp+2Ch+arg_0], ecx
    push    edx
    mov     ecx, ebp
    call    sub_4DC130

    loc_4DB0BB:                             ; CODE XREF: sub_4DB000+89j
                                            ; sub_4DB000+9Bj
    mov     edi, [ebp+4]
    lea     ecx, [esp+28h+var_C]
    mov     bl, 1
    mov     esi, [edi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, dword_528A54
    cmp     esi, ecx
    jz      short loc_4DB0F4
    mov     eax, [esp+28h+arg_0]

    loc_4DB0DA:                             ; CODE XREF: sub_4DB000+F2j
    mov     ebx, [esi+0Ch]
    mov     edi, esi
    cmp     eax, ebx
    sbb     ebx, ebx
    neg     ebx
    test    bl, bl
    jz      short loc_4DB0ED
    mov     esi, [esi]
    jmp     short loc_4DB0F0
    ; ---------------------------------------------------------------------------

    loc_4DB0ED:                             ; CODE XREF: sub_4DB000+E7j
    mov     esi, [esi+8]

    loc_4DB0F0:                             ; CODE XREF: sub_4DB000+EBj
    cmp     esi, ecx
    jnz     short loc_4DB0DA

    loc_4DB0F4:                             ; CODE XREF: sub_4DB000+D4j
    lea     ecx, [esp+28h+var_C]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     al, [ebp+8]
    test    al, al
    jz      short loc_4DB121
    lea     eax, [esp+28h+arg_0]
    lea     ecx, [esp+28h+var_C]
    push    eax
    push    edi
    push    esi
    push    ecx
    mov     ecx, ebp
    call    sub_4DCE60
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DB121:                             ; CODE XREF: sub_4DB000+102j
    test    bl, bl
    mov     [esp+28h+var_10], edi
    jz      short loc_4DB160
    mov     edx, [ebp+4]
    xor     eax, eax
    cmp     edi, [edx]
    setz    al
    test    al, al
    jz      short loc_4DB157
    lea     ecx, [esp+28h+var_15]
    lea     edx, [esp+28h+arg_0]
    push    ecx
    push    edx
    push    edi
    lea     eax, [esp+34h+var_C]
    push    esi
    push    eax
    mov     ecx, ebp
    mov     byte ptr [esp+3Ch+var_15], 1
    call    sub_4DCE60
    push    eax
    jmp     short loc_4DB1A4
    ; ---------------------------------------------------------------------------

    loc_4DB157:                             ; CODE XREF: sub_4DB000+135j
    lea     ecx, [esp+28h+var_10]
    call    sub_4DD2A0

    loc_4DB160:                             ; CODE XREF: sub_4DB000+127j
    mov     ecx, [esp+28h+var_10]
    mov     ebx, [esp+28h+arg_0]
    mov     edx, [ecx+0Ch]
    cmp     edx, ebx
    sbb     eax, eax
    neg     eax
    test    al, al
    jz      short loc_4DB195
    lea     ecx, [esp+28h+var_15]
    lea     edx, [esp+28h+arg_0]
    push    ecx
    push    edx
    push    edi
    lea     eax, [esp+34h+var_C]
    push    esi
    push    eax
    mov     ecx, ebp
    mov     byte ptr [esp+3Ch+var_15], 1
    call    sub_4DCE60
    push    eax
    jmp     short loc_4DB1A4
    ; ---------------------------------------------------------------------------

    loc_4DB195:                             ; CODE XREF: sub_4DB000+173j
    lea     ecx, [esp+28h+var_15]
    lea     edx, [esp+28h+var_10]
    push    ecx
    mov     byte ptr [esp+2Ch+var_15], 0
    push    edx

    loc_4DB1A4:                             ; CODE XREF: sub_4DB000+155j
                                            ; sub_4DB000+193j
    lea     ecx, [esp+30h+var_8]
    call    sub_4DDBE0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    sub_4DB000 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DB1C0 proc near                    ; CODE XREF: sub_4DACF0+1FDp
                                            ; sub_4DB1C0+24Bp ...

    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 1Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    xor     edi, edi
    mov     eax, [ebp+0Ch]
    mov     [esp+2Ch+var_1C], ebp
    cmp     eax, edi
    jbe     loc_4DB35A
    mov     eax, dword_5289D4
    lea     ecx, [esp+2Ch+var_10]
    push    ecx
    mov     ecx, ebp
    mov     [esp+30h+var_10], eax
    mov     [esp+30h+var_C], edi
    call    sub_4DD250
    mov     edx, [ebp+4]
    mov     esi, eax
    xor     eax, eax
    cmp     esi, [edx]
    setz    al
    neg     al
    sbb     eax, eax
    inc     eax
    test    al, al
    jz      short loc_4DB241
    lea     ecx, [esp+2Ch+var_18]
    mov     [esp+2Ch+var_18], esi
    call    sub_4DD2A0
    mov     ecx, [esp+2Ch+var_18]
    mov     edx, dword_5289D4
    mov     eax, [ecx+0Ch]
    cmp     edx, eax
    jb      short loc_4DB241
    mov     ebx, [ecx+10h]
    add     ebx, eax
    mov     [esp+2Ch+var_18], ebx
    mov     ebx, [esp+2Ch+arg_0]
    mov     eax, [esp+2Ch+var_18]
    add     edx, ebx
    cmp     edx, eax
    ja      short loc_4DB245
    mov     esi, ecx
    jmp     short loc_4DB245
    ; ---------------------------------------------------------------------------

    loc_4DB241:                             ; CODE XREF: sub_4DB1C0+46j
                                            ; sub_4DB1C0+64j
    mov     ebx, [esp+2Ch+arg_0]

    loc_4DB245:                             ; CODE XREF: sub_4DB1C0+7Bj
                                            ; sub_4DB1C0+7Fj ...
    mov     eax, [ebp+4]
    xor     ecx, ecx
    cmp     esi, eax
    setz    cl
    test    cl, cl
    jz      short loc_4DB26D
    mov     ecx, dword_528A00
    mov     esi, [eax]
    inc     ecx
    mov     dword_5289D4, 0
    mov     dword_528A00, ecx
    inc     edi

    loc_4DB26D:                             ; CODE XREF: sub_4DB1C0+91j
    cmp     [esi+10h], ebx
    jnb     short loc_4DB2C0
    lea     ecx, [esp+2Ch+var_18]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DB293
    push    eax
    call    sub_4DD1B0
    add     esp, 4
    jmp     short loc_4DB2AA
    ; ---------------------------------------------------------------------------

    loc_4DB293:                             ; CODE XREF: sub_4DB1C0+C6j
    mov     eax, [esi+4]
    cmp     esi, [eax+8]
    jnz     short loc_4DB2A5

    loc_4DB29B:                             ; CODE XREF: sub_4DB1C0+E3j
    mov     esi, eax
    mov     eax, [eax+4]
    cmp     esi, [eax+8]
    jz      short loc_4DB29B

    loc_4DB2A5:                             ; CODE XREF: sub_4DB1C0+D9j
    cmp     [esi+8], eax
    jz      short loc_4DB2AC

    loc_4DB2AA:                             ; CODE XREF: sub_4DB1C0+D1j
    mov     esi, eax

    loc_4DB2AC:                             ; CODE XREF: sub_4DB1C0+E8j
    lea     ecx, [esp+2Ch+var_18]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    cmp     edi, 2
    jge     loc_4DB35E
    jmp     short loc_4DB245
    ; ---------------------------------------------------------------------------

    loc_4DB2C0:                             ; CODE XREF: sub_4DB1C0+B0j
    mov     ecx, [esp+2Ch+var_1C]
    mov     edi, [esi+0Ch]
    mov     ebp, [esi+10h]
    lea     edx, [esp+2Ch+var_18]
    push    esi
    push    edx
    call    sub_4DC130
    mov     esi, dword_5289D4
    test    esi, esi
    jnz     short loc_4DB2E7
    mov     esi, edi
    mov     dword_5289D4, esi

    loc_4DB2E7:                             ; CODE XREF: sub_4DB1C0+11Dj
    cmp     esi, edi
    jb      short loc_4DB2F5
    lea     eax, [ebx+esi]
    lea     ecx, [edi+ebp]
    cmp     eax, ecx
    jbe     short loc_4DB2F7

    loc_4DB2F5:                             ; CODE XREF: sub_4DB1C0+129j
    mov     esi, edi

    loc_4DB2F7:                             ; CODE XREF: sub_4DB1C0+133j
    cmp     esi, edi
    jbe     short loc_4DB31A
    lea     eax, [esp+2Ch+var_18]
    mov     edx, esi
    lea     ecx, [esp+2Ch+var_8]
    push    eax
    sub     edx, edi
    push    ecx
    mov     ecx, [esp+34h+var_1C]
    mov     [esp+34h+var_18], edi
    mov     [esp+34h+var_14], edx
    call    sub_4DBEC0

    loc_4DB31A:                             ; CODE XREF: sub_4DB1C0+139j
    add     ebx, esi
    lea     edx, [edi+ebp]
    cmp     ebx, edx
    jnb     short loc_4DB348
    mov     ecx, [esp+2Ch+arg_0]
    lea     eax, [esp+2Ch+var_18]
    sub     edi, ecx
    lea     ecx, [esp+2Ch+var_8]
    add     edi, ebp
    push    eax
    sub     edi, esi
    push    ecx
    mov     ecx, [esp+34h+var_1C]
    mov     [esp+34h+var_18], ebx
    mov     [esp+34h+var_14], edi
    call    sub_4DBEC0

    loc_4DB348:                             ; CODE XREF: sub_4DB1C0+161j
    mov     dword_5289D4, ebx
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4DB35A:                             ; CODE XREF: sub_4DB1C0+14j
    mov     ebx, [esp+2Ch+arg_0]

    loc_4DB35E:                             ; CODE XREF: sub_4DB1C0+F8j
    mov     esi, 10000000h
    lea     edx, [ebx+ebx]
    cmp     edx, esi
    jbe     short loc_4DB380
    cmp     ebx, 40000000h
    jnb     short loc_4DB380
    lea     esi, [ebx+1FFFh]
    and     esi, 0FFFFE000h
    shl     esi, 1

    loc_4DB380:                             ; CODE XREF: sub_4DB1C0+1A8j
                                            ; sub_4DB1C0+1B0j
    cmp     ebx, esi
    jbe     short loc_4DB390
    lea     esi, [ebx+1FFFh]
    and     esi, 0FFFFE000h

    loc_4DB390:                             ; CODE XREF: sub_4DB1C0+1C2j
    mov     ebp, ds:VirtualAlloc
    lea     edi, [esi+2000h]
    push    4                               ; flProtect
    push    2000h                           ; flAllocationType
    push    edi                             ; dwSize
    push    0                               ; lpAddress
    call    ebp ; VirtualAlloc
    mov     ebx, ds:VirtualFree

    loc_4DB3AE:                             ; CODE XREF: sub_4DB1C0+232j
    test    eax, eax
    jz      short loc_4DB3CA
    lea     ecx, [eax+esi]
    cmp     ecx, 80000000h
    jbe     short loc_4DB3F4
    test    eax, eax
    jz      short loc_4DB3CA
    push    8000h                           ; dwFreeType
    push    edi                             ; dwSize
    push    eax                             ; lpAddress
    call    ebx ; VirtualFree

    loc_4DB3CA:                             ; CODE XREF: sub_4DB1C0+1F0j
                                            ; sub_4DB1C0+1FFj
    shr     esi, 1
    and     esi, 7FFFE000h
    cmp     esi, 10000h
    jb      short loc_4DB41A
    cmp     esi, [esp+2Ch+arg_0]
    jb      short loc_4DB41A
    lea     edi, [esi+2000h]
    push    4                               ; flProtect
    push    2000h                           ; flAllocationType
    push    edi                             ; dwSize
    push    0                               ; lpAddress
    call    ebp ; VirtualAlloc
    jmp     short loc_4DB3AE
    ; ---------------------------------------------------------------------------

    loc_4DB3F4:                             ; CODE XREF: sub_4DB1C0+1FBj
    mov     edi, [esp+2Ch+var_1C]
    push    esi
    push    eax
    mov     ecx, edi
    add     [edi+10h], esi
    call    sub_4DB000
    mov     edx, [esp+2Ch+arg_0]
    mov     ecx, edi
    push    edx
    call    sub_4DB1C0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4DB41A:                             ; CODE XREF: sub_4DB1C0+218j
                                            ; sub_4DB1C0+21Ej
    xor     al, al
    test    al, al
    jz      short loc_4DB43A
    mov     edi, [esp+2Ch+var_1C]
    mov     edx, [esp+2Ch+arg_0]
    push    edx
    mov     ecx, edi
    call    sub_4DB1C0
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4DB43A:                             ; CODE XREF: sub_4DB1C0+25Ej
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 1Ch
    retn    4
    sub_4DB1C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DB450 proc near                    ; CODE XREF: sub_4DACF0+1F1p

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 14h
    mov     eax, [esp+14h+arg_0]
    push    ebx
    push    ebp
    mov     [esp+1Ch+var_14], ecx
    push    esi
    mov     esi, 10000000h
    lea     ecx, [eax+eax]
    push    edi
    cmp     ecx, esi
    jbe     short loc_4DB480
    cmp     eax, 40000000h
    jnb     short loc_4DB480
    lea     esi, [eax+1FFFh]
    and     esi, 0FFFFE000h
    shl     esi, 1

    loc_4DB480:                             ; CODE XREF: sub_4DB450+19j
                                            ; sub_4DB450+20j
    cmp     eax, esi
    jbe     short loc_4DB490
    lea     esi, [eax+1FFFh]
    and     esi, 0FFFFE000h

    loc_4DB490:                             ; CODE XREF: sub_4DB450+32j
    mov     ebx, ds:VirtualAlloc
    lea     edi, [esi+2000h]
    push    4                               ; flProtect
    push    2000h                           ; flAllocationType
    push    edi                             ; dwSize
    push    0                               ; lpAddress
    call    ebx ; VirtualAlloc
    mov     ebp, ds:VirtualFree

    loc_4DB4AE:                             ; CODE XREF: sub_4DB450+AAj
    test    eax, eax
    jz      short loc_4DB4CA
    lea     edx, [eax+esi]
    cmp     edx, 80000000h
    jbe     short loc_4DB4FC
    test    eax, eax
    jz      short loc_4DB4CA
    push    8000h                           ; dwFreeType
    push    edi                             ; dwSize
    push    eax                             ; lpAddress
    call    ebp ; VirtualFree

    loc_4DB4CA:                             ; CODE XREF: sub_4DB450+60j
                                            ; sub_4DB450+6Fj
    shr     esi, 1
    and     esi, 7FFFE000h
    cmp     esi, 10000h
    jb      loc_4DB600
    cmp     esi, [esp+24h+arg_0]
    jb      loc_4DB600
    lea     edi, [esi+2000h]
    push    4                               ; flProtect
    push    2000h                           ; flAllocationType
    push    edi                             ; dwSize
    push    0                               ; lpAddress
    call    ebx ; VirtualAlloc
    jmp     short loc_4DB4AE
    ; ---------------------------------------------------------------------------

    loc_4DB4FC:                             ; CODE XREF: sub_4DB450+6Bj
    mov     edi, [esp+24h+var_14]
    mov     [esp+24h+var_8], eax
    lea     eax, [esp+24h+var_8]
    lea     ecx, [esp+24h+var_14]
    mov     edx, [edi+10h]
    push    eax
    add     edx, esi
    push    ecx
    mov     ecx, edi
    mov     [edi+10h], edx
    mov     [esp+2Ch+var_4], esi
    call    sub_4DC620
    mov     edx, [esp+24h+var_14]
    lea     eax, [esp+24h+var_10]
    push    eax
    mov     ecx, edi
    mov     [esp+28h+arg_0], edx
    call    sub_4DBEB0
    mov     edx, [esp+24h+arg_0]
    mov     esi, [esp+24h+var_10]
    xor     ecx, ecx
    cmp     edx, esi
    setz    cl
    test    cl, cl
    jz      short loc_4DB551
    mov     ecx, [edi+4]
    mov     [esp+24h+arg_0], ecx
    jmp     short loc_4DB55E
    ; ---------------------------------------------------------------------------

    loc_4DB551:                             ; CODE XREF: sub_4DB450+F6j
    lea     ecx, [esp+24h+arg_0]
    call    sub_4DD2A0
    mov     ecx, [esp+24h+arg_0]

    loc_4DB55E:                             ; CODE XREF: sub_4DB450+FFj
    mov     eax, [esp+24h+var_14]
    mov     esi, [edi+4]
    xor     edx, edx
    cmp     eax, esi
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      short loc_4DB5A0
    mov     edx, [esp+24h+var_4]
    mov     esi, [esp+24h+var_8]
    mov     ebx, [eax+0Ch]
    add     esi, edx
    cmp     ebx, esi
    jnz     short loc_4DB5A0
    mov     esi, [eax+10h]
    push    eax
    lea     eax, [esp+28h+var_10]
    add     edx, esi
    push    eax
    mov     ecx, edi
    mov     [esp+2Ch+var_4], edx
    call    sub_4DC130
    mov     ecx, [esp+24h+arg_0]

    loc_4DB5A0:                             ; CODE XREF: sub_4DB450+123j
                                            ; sub_4DB450+134j
    mov     ebp, [edi+4]
    xor     edx, edx
    cmp     ecx, ebp
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      short loc_4DB5E3
    mov     eax, [ecx+10h]
    mov     ebx, [ecx+0Ch]
    mov     esi, [esp+24h+var_8]
    mov     edx, eax
    add     edx, ebx
    cmp     edx, esi
    jnz     short loc_4DB5E3
    mov     esi, [esp+24h+var_4]
    push    ecx
    add     esi, eax
    mov     [esp+28h+var_4], esi
    mov     eax, [ecx+0Ch]
    lea     ecx, [esp+28h+var_10]
    mov     [esp+28h+var_8], eax
    push    ecx
    mov     ecx, edi
    call    sub_4DC130

    loc_4DB5E3:                             ; CODE XREF: sub_4DB450+161j
                                            ; sub_4DB450+173j
    lea     edx, [esp+24h+var_8]
    lea     eax, [esp+24h+var_10]
    push    edx
    push    eax
    mov     ecx, edi
    call    sub_4DBEC0
    mov     al, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4DB600:                             ; CODE XREF: sub_4DB450+88j
                                            ; sub_4DB450+92j
    pop     edi
    pop     esi
    pop     ebp
    xor     al, al
    pop     ebx
    add     esp, 14h
    retn    4
    sub_4DB450 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DB610 proc near                    ; CODE XREF: sub_4DACF0+61p
                                            ; sub_4DACF0+227p ...

    var_9= byte ptr -9
    var_8= dword ptr -8
    var_4= dword ptr -4

    mov     eax, dword_528A40
    sub     esp, 0Ch
    push    ebx
    xor     ebx, ebx
    push    ebp
    push    esi
    cmp     eax, ebx
    push    edi
    jnz     loc_4DB754
    push    14h                             ; dwBytes
    push    ebx                             ; uFlags
    call    ds:GlobalAlloc
    mov     ebp, eax
    cmp     ebp, ebx
    jz      loc_4DB74D
    mov     cl, [esp+1Ch+var_9]
    mov     al, [esp+1Ch+var_9]
    mov     [ebp+1], cl
    lea     ecx, [esp+1Ch+var_4]
    mov     [ebp+0], al
    mov     [ebp+8], bl
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    cmp     dword_528A54, ebx
    jnz     short loc_4DB67E
    push    18h
    mov     ecx, ebp
    call    sub_4DDD70
    mov     [eax+4], ebx
    mov     dword ptr [eax+14h], 1
    mov     dword_528A54, eax
    mov     [eax], ebx
    mov     edx, dword_528A54
    mov     [edx+8], ebx

    loc_4DB67E:                             ; CODE XREF: sub_4DB610+49j
    mov     ecx, dword_528A58
    mov     esi, dword_528A54
    inc     ecx
    push    18h
    mov     dword_528A58, ecx
    mov     ecx, ebp
    call    sub_4DDD70
    mov     [eax+4], esi
    mov     [eax+14h], ebx
    mov     [ebp+4], eax
    mov     [ebp+0Ch], ebx
    mov     [eax], eax
    mov     eax, [ebp+4]
    lea     ecx, [esp+1Ch+var_4]
    mov     [eax+8], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edi, ds:VirtualAlloc
    mov     [ebp+10h], ebx
    mov     [esp+1Ch+var_8], 4

    loc_4DB6C8:                             ; CODE XREF: sub_4DB610+12Cj
    push    4                               ; flProtect
    push    2000h                           ; flAllocationType
    mov     esi, 10000000h
    push    10002000h                       ; dwSize

    loc_4DB6D9:                             ; CODE XREF: sub_4DB610+110j
    push    ebx                             ; lpAddress
    call    edi ; VirtualAlloc
    cmp     eax, ebx
    jz      short loc_4DB702
    lea     ecx, [eax+esi]
    cmp     ecx, 80000000h
    jbe     short loc_4DB722
    cmp     eax, ebx
    jz      short loc_4DB702
    lea     edx, [esi+2000h]
    push    8000h                           ; dwFreeType
    push    edx                             ; dwSize
    push    eax                             ; lpAddress
    call    ds:VirtualFree

    loc_4DB702:                             ; CODE XREF: sub_4DB610+CEj
                                            ; sub_4DB610+DDj
    shr     esi, 1
    and     esi, 7FFFE000h
    cmp     esi, 10000h
    jb      short loc_4DB733
    push    4
    lea     eax, [esi+2000h]
    push    2000h
    push    eax
    jmp     short loc_4DB6D9
    ; ---------------------------------------------------------------------------

    loc_4DB722:                             ; CODE XREF: sub_4DB610+D9j
    mov     ecx, [ebp+10h]
    push    esi
    add     ecx, esi
    push    eax
    mov     [ebp+10h], ecx
    mov     ecx, ebp
    call    sub_4DB000

    loc_4DB733:                             ; CODE XREF: sub_4DB610+100j
    mov     eax, [esp+1Ch+var_8]
    dec     eax
    mov     [esp+1Ch+var_8], eax
    jnz     short loc_4DB6C8
    mov     eax, ebp
    mov     dword_528A40, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4DB74D:                             ; CODE XREF: sub_4DB610+23j
    xor     eax, eax
    mov     dword_528A40, eax

    loc_4DB754:                             ; CODE XREF: sub_4DB610+10j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_4DB610 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DB760 proc near                    ; CODE XREF: sub_4DACF0+266p
                                            ; sub_4DB7D0+88p
    mov     cl, byte_5289F4
    mov     eax, 1
    test    al, cl
    jnz     short loc_4DB7A0
    push    0                               ; int
    push    0                               ; int
    push    offset aMemfrontalign           ; int
    or      cl, al
    push    0                               ; int
    push    eax                             ; char
    mov     byte_5289F4, cl
    push    eax                             ; int
    push    offset aBackalign               ; int
    mov     ecx, offset byte_528A20
    call    sub_4D9FE0
    push    offset nullsub_25               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4DB7A0:                             ; CODE XREF: sub_4DB760+Dj
    mov     al, byte_528A20
    retn
    sub_4DB760 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_25. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DB7C0 proc near                    ; CODE XREF: sub_4DACF0+270p
                                            ; sub_4DACF0+283p ...
    mov     eax, 0CCCCCCCCh
    retn
    sub_4DB7C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DB7D0 proc near                    ; CODE XREF: sub_4D85B0+24p
                                            ; sub_4DBA40+83p

    var_4C= dword ptr -4Ch
    var_48= dword ptr -48h
    var_44= dword ptr -44h
    lpCriticalSection= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    arg_0= dword ptr  4

    sub     esp, 4Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+5Ch+arg_0]
    test    edi, edi
    jz      loc_4DBA38
    call    sub_4DA780
    mov     esi, eax
    push    esi                             ; lpCriticalSection
    mov     [esp+60h+lpCriticalSection], esi
    call    ds:EnterCriticalSection
    call    sub_4DA8D0
    push    0                               ; lpString2
    push    0                               ; int
    push    0                               ; int
    push    0                               ; int
    push    edi                             ; int
    lea     ecx, [esp+70h+var_30]
    mov     ebx, eax
    call    sub_4D8820
    lea     eax, [esp+5Ch+var_30]
    lea     ecx, [esp+5Ch+var_4C]
    push    eax
    push    ecx
    mov     ecx, ebx
    call    sub_4DCE00
    call    sub_4DA8D0
    mov     ecx, [esp+5Ch+var_4C]
    mov     ebx, [eax+4]
    xor     edx, edx
    cmp     ecx, ebx
    setz    dl
    test    dl, dl
    jz      short loc_4DB845
    push    esi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 4Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4DB845:                             ; CODE XREF: sub_4DB7D0+64j
    mov     ebx, [ecx+10h]
    mov     esi, ebx
    and     esi, 0FFFh
    neg     esi
    and     esi, 0FFFh
    call    sub_4DB760
    test    al, al
    push    esi
    jz      short loc_4DB86F
    call    sub_4DB7C0
    push    eax
    mov     eax, edi
    sub     eax, esi
    push    eax
    jmp     short loc_4DB879
    ; ---------------------------------------------------------------------------

    loc_4DB86F:                             ; CODE XREF: sub_4DB7D0+90j
    call    sub_4DB7C0
    lea     ecx, [ebx+edi]
    push    eax
    push    ecx

    loc_4DB879:                             ; CODE XREF: sub_4DB7D0+9Dj
    call    sub_4D8310
    mov     edx, [esp+68h+var_4C]
    add     esp, 0Ch
    lea     esi, [edx+0Ch]
    call    sub_4DA9F0
    mov     ebp, eax
    mov     eax, [ebp+10h]
    cmp     eax, 2000h
    jnb     short loc_4DB8A9
    mov     eax, [ebp+8]
    push    esi
    push    1
    push    eax
    mov     ecx, ebp
    call    sub_4DD8C0
    jmp     short loc_4DB8C4
    ; ---------------------------------------------------------------------------

    loc_4DB8A9:                             ; CODE XREF: sub_4DB7D0+C7j
    mov     edi, [ebp+4]
    and     eax, 1FFFh
    lea     ecx, [eax+eax*2]
    shl     ecx, 4
    add     edi, ecx
    mov     ecx, 0Ch
    rep movsd
    mov     edi, [esp+5Ch+arg_0]

    loc_4DB8C4:                             ; CODE XREF: sub_4DB7D0+D7j
    mov     esi, [ebp+10h]
    inc     esi
    mov     [ebp+10h], esi
    mov     esi, [esp+5Ch+var_4C]
    call    sub_4DA8D0
    lea     edx, [esp+5Ch+arg_0]
    push    esi
    push    edx
    mov     ecx, eax
    call    sub_4DC910
    push    ebx
    call    sub_4DA840
    mov     edx, dword_5289F0
    lea     eax, [ebx+0FFFh]
    and     eax, 0FFFFF000h
    add     esp, 4
    sub     edx, eax
    and     edi, 0FFFFF000h
    test    ebx, ebx
    mov     dword_5289F0, edx
    jnz     short loc_4DB912
    mov     ebx, 1

    loc_4DB912:                             ; CODE XREF: sub_4DB7D0+13Bj
    push    ebx
    call    sub_4DA8C0
    add     esp, 4
    push    4000h                           ; dwFreeType
    push    eax                             ; dwSize
    push    edi                             ; lpAddress
    call    ds:VirtualFree
    push    ebx
    call    sub_4DA8A0
    add     esp, 4
    mov     ebx, eax
    call    sub_4DB610
    lea     ecx, [esp+5Ch+var_38]
    mov     esi, eax
    lea     edx, [esp+5Ch+var_48]
    push    ecx
    push    edx
    mov     ecx, esi
    mov     [esp+64h+var_38], edi
    mov     [esp+64h+var_34], ebx
    call    sub_4DBD20
    mov     eax, [esp+5Ch+var_48]
    lea     ecx, [esp+5Ch+var_44]
    push    ecx
    mov     ecx, esi
    mov     [esp+60h+arg_0], eax
    call    sub_4DBEB0
    mov     eax, [esp+5Ch+arg_0]
    mov     ecx, [esp+5Ch+var_44]
    xor     edx, edx
    cmp     eax, ecx
    setz    dl
    test    dl, dl
    jz      short loc_4DB983
    mov     ecx, [esi+4]
    mov     [esp+5Ch+arg_0], ecx
    jmp     short loc_4DB997
    ; ---------------------------------------------------------------------------

    loc_4DB983:                             ; CODE XREF: sub_4DB7D0+1A8j
    lea     ecx, [esp+5Ch+var_44]
    push    0
    push    ecx
    lea     ecx, [esp+64h+arg_0]
    call    sub_4DBE10
    mov     ecx, [esp+5Ch+arg_0]

    loc_4DB997:                             ; CODE XREF: sub_4DB7D0+1B1j
    mov     eax, [esp+5Ch+var_48]
    mov     edi, [esi+4]
    xor     edx, edx
    cmp     eax, edi
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      short loc_4DB9D9
    mov     edx, [esp+5Ch+var_34]
    mov     edi, [esp+5Ch+var_38]
    mov     ebx, [eax+0Ch]
    add     edi, edx
    cmp     ebx, edi
    jnz     short loc_4DB9D9
    mov     edi, [eax+10h]
    push    eax
    lea     eax, [esp+60h+var_44]
    add     edx, edi
    push    eax
    mov     ecx, esi
    mov     [esp+64h+var_34], edx
    call    sub_4DBD00
    mov     ecx, [esp+5Ch+arg_0]

    loc_4DB9D9:                             ; CODE XREF: sub_4DB7D0+1DCj
                                            ; sub_4DB7D0+1EDj
    mov     ebp, [esi+4]
    xor     edx, edx
    cmp     ecx, ebp
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      short loc_4DBA1C
    mov     eax, [ecx+10h]
    mov     ebx, [ecx+0Ch]
    mov     edi, [esp+5Ch+var_38]
    mov     edx, eax
    add     edx, ebx
    cmp     edx, edi
    jnz     short loc_4DBA1C
    mov     edi, [esp+5Ch+var_34]
    push    ecx
    add     edi, eax
    mov     [esp+60h+var_34], edi
    mov     eax, [ecx+0Ch]
    lea     ecx, [esp+60h+var_44]
    mov     [esp+60h+var_38], eax
    push    ecx
    mov     ecx, esi
    call    sub_4DBD00

    loc_4DBA1C:                             ; CODE XREF: sub_4DB7D0+21Aj
                                            ; sub_4DB7D0+22Cj
    lea     edx, [esp+5Ch+var_38]
    lea     eax, [esp+5Ch+var_44]
    push    edx
    push    eax
    mov     ecx, esi
    call    sub_4DBBC0
    mov     ecx, [esp+5Ch+lpCriticalSection]
    push    ecx                             ; lpCriticalSection
    call    ds:LeaveCriticalSection

    loc_4DBA38:                             ; CODE XREF: sub_4DB7D0+Dj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 4Ch
    retn
    sub_4DB7D0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBA40 proc near                    ; CODE XREF: Network_ReAllocPacketBuffer_Internal+2Ap

    lpCriticalSection= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4DA780
    push    eax                             ; lpCriticalSection
    mov     [esp+18h+lpCriticalSection], eax
    call    ds:EnterCriticalSection
    mov     ebp, [esp+14h+arg_0]
    xor     ebx, ebx
    xor     edi, edi
    test    ebp, ebp
    jz      short loc_4DBA6C
    push    ebp
    call    sub_4D8360
    add     esp, 4
    mov     edi, eax

    loc_4DBA6C:                             ; CODE XREF: sub_4DBA40+1Fj
    mov     esi, [esp+14h+arg_4]
    test    esi, esi
    jbe     short loc_4DBAB9
    mov     eax, [esp+14h+arg_8]
    push    eax
    push    esi
    call    sub_4DACF0
    mov     ebx, eax
    add     esp, 8
    test    ebx, ebx
    jnz     short loc_4DBA9B
    mov     ecx, [esp+14h+lpCriticalSection]
    push    ecx                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4DBA9B:                             ; CODE XREF: sub_4DBA40+46j
    cmp     edi, esi
    mov     ecx, esi
    jnb     short loc_4DBAA3
    mov     ecx, edi

    loc_4DBAA3:                             ; CODE XREF: sub_4DBA40+5Fj
    test    ecx, ecx
    jbe     short loc_4DBAB9
    mov     edx, ecx
    mov     esi, ebp
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4DBAB9:                             ; CODE XREF: sub_4DBA40+32j
                                            ; sub_4DBA40+65j
    test    ebp, ebp
    jz      short loc_4DBACB
    mov     eax, [esp+14h+arg_8]
    push    eax
    push    ebp
    call    sub_4DB7D0
    add     esp, 8

    loc_4DBACB:                             ; CODE XREF: sub_4DBA40+7Bj
    mov     ecx, [esp+14h+lpCriticalSection]
    push    ecx                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    pop     edi
    pop     esi
    mov     eax, ebx
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_4DBA40 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBAE0 proc near                    ; CODE XREF: sub_4D8360+17p

    var_34= dword ptr -34h
    var_30= dword ptr -30h
    arg_0= dword ptr  4

    sub     esp, 34h
    push    esi
    push    edi
    call    sub_4DA780
    mov     edi, eax
    push    edi                             ; lpCriticalSection
    call    ds:EnterCriticalSection
    call    sub_4DA8D0
    push    0                               ; lpString2
    mov     esi, eax
    mov     eax, [esp+40h+arg_0]
    push    0                               ; int
    push    0                               ; int
    push    0                               ; int
    push    eax                             ; int
    lea     ecx, [esp+50h+var_30]
    call    sub_4D8820
    lea     ecx, [esp+3Ch+var_30]
    lea     edx, [esp+3Ch+arg_0]
    push    ecx
    push    edx
    mov     ecx, esi
    call    sub_4DD3D0
    mov     esi, [esi+4]
    mov     eax, [esp+3Ch+arg_0]
    xor     ecx, ecx
    cmp     eax, esi
    setz    cl
    test    cl, cl
    jnz     short loc_4DBB4A
    mov     edx, [esp+3Ch+var_30]
    mov     ecx, [eax+0Ch]
    cmp     edx, ecx
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_4DBB4A
    lea     eax, [esp+3Ch+arg_0]
    jmp     short loc_4DBB52
    ; ---------------------------------------------------------------------------

    loc_4DBB4A:                             ; CODE XREF: sub_4DBAE0+51j
                                            ; sub_4DBAE0+62j
    mov     [esp+3Ch+var_34], esi
    lea     eax, [esp+3Ch+var_34]

    loc_4DBB52:                             ; CODE XREF: sub_4DBAE0+68j
    mov     esi, [eax]
    call    sub_4DA8D0
    mov     edx, [eax+4]
    xor     ecx, ecx
    cmp     esi, edx
    setz    cl
    test    cl, cl
    jz      short loc_4DBB76
    push    edi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    xor     eax, eax
    pop     edi
    pop     esi
    add     esp, 34h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DBB76:                             ; CODE XREF: sub_4DBAE0+85j
    mov     esi, [esi+10h]
    push    edi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    mov     eax, esi
    pop     edi
    pop     esi
    add     esp, 34h
    retn
    sub_4DBAE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBB90 proc near                    ; CODE XREF: sub_4D8720+2Fp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    mov     ecx, [eax]
    and     ecx, 0FFFFF000h
    mov     [eax], ecx
    mov     eax, [esp+arg_4]
    mov     ecx, [eax]
    add     ecx, 0FFFh
    and     ecx, 0FFFFF000h
    mov     [eax], ecx
    retn
    sub_4DBB90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBBC0 proc near                    ; CODE XREF: sub_4DACF0+1AAp
                                            ; sub_4DACF0+1DDp ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= byte ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    lea     ecx, [esp+20h+var_C]
    mov     edi, [ebp+4]
    mov     bl, 1
    mov     esi, [edi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, dword_528A54
    cmp     esi, ecx
    jz      short loc_4DBC04
    mov     eax, [esp+20h+arg_4]
    mov     eax, [eax]

    loc_4DBBEA:                             ; CODE XREF: sub_4DBBC0+42j
    mov     ebx, [esi+0Ch]
    mov     edi, esi
    cmp     eax, ebx
    sbb     ebx, ebx
    neg     ebx
    test    bl, bl
    jz      short loc_4DBBFD
    mov     esi, [esi]
    jmp     short loc_4DBC00
    ; ---------------------------------------------------------------------------

    loc_4DBBFD:                             ; CODE XREF: sub_4DBBC0+37j
    mov     esi, [esi+8]

    loc_4DBC00:                             ; CODE XREF: sub_4DBBC0+3Bj
    cmp     esi, ecx
    jnz     short loc_4DBBEA

    loc_4DBC04:                             ; CODE XREF: sub_4DBBC0+22j
    lea     ecx, [esp+20h+var_C]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     al, [ebp+8]
    test    al, al
    jz      short loc_4DBC3E
    mov     ecx, [esp+20h+arg_4]
    lea     edx, [esp+20h+arg_4]
    push    ecx
    push    edi
    push    esi
    push    edx
    mov     ecx, ebp
    call    sub_4DCE60
    mov     edx, [eax]
    mov     eax, [esp+20h+arg_0]
    mov     cl, 1
    mov     [eax], edx
    mov     [eax+4], cl
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DBC3E:                             ; CODE XREF: sub_4DBBC0+52j
    test    bl, bl
    mov     [esp+20h+var_10], edi
    jz      short loc_4DBC87
    mov     eax, [ebp+4]
    xor     ecx, ecx
    cmp     edi, [eax]
    setz    cl
    test    cl, cl
    jz      short loc_4DBC7E
    mov     edx, [esp+20h+arg_4]
    lea     eax, [esp+20h+arg_4]
    push    edx
    push    edi
    push    esi
    push    eax
    mov     ecx, ebp
    call    sub_4DCE60
    mov     edx, [eax]
    mov     eax, [esp+20h+arg_0]
    mov     cl, 1
    mov     [eax], edx
    mov     [eax+4], cl
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DBC7E:                             ; CODE XREF: sub_4DBBC0+92j
    lea     ecx, [esp+20h+var_10]
    call    sub_4DD2A0

    loc_4DBC87:                             ; CODE XREF: sub_4DBBC0+84j
    mov     ecx, [esp+20h+var_10]
    mov     eax, [esp+20h+arg_4]
    mov     edx, [ecx+0Ch]
    mov     ecx, [eax]
    cmp     edx, ecx
    sbb     ecx, ecx
    neg     ecx
    test    cl, cl
    jz      short loc_4DBCC4
    push    eax
    push    edi
    lea     edx, [esp+28h+arg_4]
    push    esi
    push    edx
    mov     ecx, ebp
    call    sub_4DCE60
    mov     edx, [eax]
    mov     eax, [esp+20h+arg_0]
    mov     cl, 1
    mov     [eax], edx
    mov     [eax+4], cl
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DBCC4:                             ; CODE XREF: sub_4DBBC0+DCj
    lea     eax, [esp+20h+arg_4]
    lea     ecx, [esp+20h+var_10]
    push    eax
    push    ecx
    lea     ecx, [esp+28h+var_8]
    mov     byte ptr [esp+28h+arg_4], 0
    call    sub_4DDBE0
    mov     eax, [esp+20h+arg_0]
    mov     cl, [esp+20h+var_4]
    mov     edx, [esp+20h+var_8]
    pop     edi
    pop     esi
    pop     ebp
    mov     [eax], edx
    mov     [eax+4], cl
    pop     ebx
    add     esp, 10h
    retn    8
    sub_4DBBC0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBD00 proc near                    ; CODE XREF: sub_4DACF0+164p
                                            ; sub_4DB7D0+200p ...

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    lea     edx, [esp+arg_4]
    push    eax
    push    edx
    call    sub_4DC130
    mov     ecx, [eax]
    mov     eax, [esp+arg_0]
    mov     [eax], ecx
    retn    8
    sub_4DBD00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBD20 proc near                    ; CODE XREF: sub_4DB7D0+17Ep

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esi+4]
    mov     esi, ecx
    mov     eax, [ecx+4]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DBD5F
    mov     edx, [esp+8+arg_4]
    push    edi
    mov     edi, [edx]

    loc_4DBD46:                             ; CODE XREF: sub_4DBD20+3Cj
    cmp     edi, [eax+0Ch]
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_4DBD57
    mov     esi, eax
    mov     eax, [eax]
    jmp     short loc_4DBD5A
    ; ---------------------------------------------------------------------------

    loc_4DBD57:                             ; CODE XREF: sub_4DBD20+2Fj
    mov     eax, [eax+8]

    loc_4DBD5A:                             ; CODE XREF: sub_4DBD20+35j
    cmp     eax, ecx
    jnz     short loc_4DBD46
    pop     edi

    loc_4DBD5F:                             ; CODE XREF: sub_4DBD20+1Dj
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [esp+8+arg_0]
    mov     [eax], esi
    pop     esi
    pop     ecx
    retn    8
    sub_4DBD20 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBD80 proc near                    ; CODE XREF: sub_4DACF0+13Ep

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+14h+var_4]
    mov     ebx, [edi]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, dword_528A54
    mov     esi, [eax+8]
    cmp     esi, ecx
    jz      short loc_4DBDCC
    lea     ecx, [esp+14h+var_8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DBDBF

    loc_4DBDB7:                             ; CODE XREF: sub_4DBD80+3Dj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4DBDB7

    loc_4DBDBF:                             ; CODE XREF: sub_4DBD80+35j
    lea     ecx, [esp+14h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     [edi], esi
    jmp     short loc_4DBDEB
    ; ---------------------------------------------------------------------------

    loc_4DBDCC:                             ; CODE XREF: sub_4DBD80+20j
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax+8]
    jnz     short loc_4DBDE2

    loc_4DBDD6:                             ; CODE XREF: sub_4DBD80+60j
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax+8]
    jz      short loc_4DBDD6

    loc_4DBDE2:                             ; CODE XREF: sub_4DBD80+54j
    mov     ecx, [edi]
    cmp     [ecx+8], eax
    jz      short loc_4DBDEB
    mov     [edi], eax

    loc_4DBDEB:                             ; CODE XREF: sub_4DBD80+4Aj
                                            ; sub_4DBD80+67j
    lea     ecx, [esp+14h+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [esp+14h+arg_0]
    pop     edi
    pop     esi
    mov     [eax], ebx
    pop     ebx
    add     esp, 8
    retn    8
    sub_4DBD80 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBE10 proc near                    ; CODE XREF: sub_4DACF0+C3p
                                            ; sub_4DB7D0+1BEp

    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+14h+var_4]
    mov     ebx, [edi]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_4DBE3B
    mov     ecx, [eax+4]
    cmp     [ecx+4], eax
    jnz     short loc_4DBE3B
    mov     edx, [eax+8]
    mov     [edi], edx
    jmp     short loc_4DBE89
    ; ---------------------------------------------------------------------------

    loc_4DBE3B:                             ; CODE XREF: sub_4DBE10+1Aj
                                            ; sub_4DBE10+22j
    mov     esi, [eax]
    mov     ecx, dword_528A54
    cmp     esi, ecx
    jz      short loc_4DBE73
    lea     ecx, [esp+14h+var_8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DBE66

    loc_4DBE5D:                             ; CODE XREF: sub_4DBE10+54j
    mov     esi, eax
    mov     eax, [esi+8]
    cmp     eax, ecx
    jnz     short loc_4DBE5D

    loc_4DBE66:                             ; CODE XREF: sub_4DBE10+4Bj
    lea     ecx, [esp+14h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     [edi], esi
    jmp     short loc_4DBE89
    ; ---------------------------------------------------------------------------

    loc_4DBE73:                             ; CODE XREF: sub_4DBE10+35j
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax]
    jnz     short loc_4DBE87

    loc_4DBE7C:                             ; CODE XREF: sub_4DBE10+75j
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax]
    jz      short loc_4DBE7C

    loc_4DBE87:                             ; CODE XREF: sub_4DBE10+6Aj
    mov     [edi], eax

    loc_4DBE89:                             ; CODE XREF: sub_4DBE10+29j
                                            ; sub_4DBE10+61j
    lea     ecx, [esp+14h+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [esp+14h+arg_0]
    pop     edi
    pop     esi
    mov     [eax], ebx
    pop     ebx
    add     esp, 8
    retn    8
    sub_4DBE10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBEB0 proc near                    ; CODE XREF: sub_4DACF0+98p
                                            ; sub_4DACF0+109p ...

    arg_0= dword ptr  4

    mov     eax, [ecx+4]
    mov     ecx, [eax]
    mov     eax, [esp+arg_0]
    mov     [eax], ecx
    retn    4
    sub_4DBEB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DBEC0 proc near                    ; CODE XREF: sub_4DB1C0+155p
                                            ; sub_4DB1C0+183p ...

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10h
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    lea     ecx, [esp+20h+var_8]
    mov     edi, [ebp+4]
    mov     bl, 1
    mov     esi, [edi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, dword_528A54
    cmp     esi, ecx
    jz      short loc_4DBF04
    mov     eax, [esp+20h+arg_4]
    mov     eax, [eax]

    loc_4DBEEA:                             ; CODE XREF: sub_4DBEC0+42j
    mov     ebx, [esi+0Ch]
    mov     edi, esi
    cmp     eax, ebx
    sbb     ebx, ebx
    neg     ebx
    test    bl, bl
    jz      short loc_4DBEFD
    mov     esi, [esi]
    jmp     short loc_4DBF00
    ; ---------------------------------------------------------------------------

    loc_4DBEFD:                             ; CODE XREF: sub_4DBEC0+37j
    mov     esi, [esi+8]

    loc_4DBF00:                             ; CODE XREF: sub_4DBEC0+3Bj
    cmp     esi, ecx
    jnz     short loc_4DBEEA

    loc_4DBF04:                             ; CODE XREF: sub_4DBEC0+22j
    lea     ecx, [esp+20h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     al, [ebp+8]
    test    al, al
    jz      loc_4DC0B0
    lea     ecx, [esp+20h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    xor     ebx, ebx
    mov     ecx, ebp
    push    ebx
    push    edi
    call    sub_4DDC00
    mov     ecx, dword_528A54
    mov     edx, eax
    mov     [esp+20h+var_10], edx
    mov     [edx], ecx
    mov     eax, dword_528A54
    mov     ecx, [esp+20h+arg_4]
    mov     [edx+8], eax
    lea     eax, [edx+0Ch]
    cmp     eax, ebx
    jz      short loc_4DBF5B
    mov     edx, [ecx]
    mov     [eax], edx
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esp+20h+var_10]

    loc_4DBF5B:                             ; CODE XREF: sub_4DBEC0+8Bj
    mov     eax, [ebp+0Ch]
    inc     eax
    mov     [ebp+0Ch], eax
    mov     eax, [ebp+4]
    cmp     edi, eax
    jz      short loc_4DBF90
    cmp     esi, dword_528A54
    jnz     short loc_4DBF90
    mov     eax, [ecx]
    mov     ecx, [edi+0Ch]
    cmp     eax, ecx
    sbb     ecx, ecx
    neg     ecx
    test    cl, cl
    jnz     short loc_4DBF90
    mov     [edi+8], edx
    mov     eax, [ebp+4]
    cmp     edi, [eax+8]
    jnz     short loc_4DBFAA
    mov     [eax+8], edx
    jmp     short loc_4DBFAA
    ; ---------------------------------------------------------------------------

    loc_4DBF90:                             ; CODE XREF: sub_4DBEC0+A7j
                                            ; sub_4DBEC0+AFj ...
    mov     [edi], edx
    mov     eax, [ebp+4]
    cmp     edi, eax
    jnz     short loc_4DBFA4
    mov     [eax+4], edx
    mov     eax, [ebp+4]
    mov     [eax+8], edx
    jmp     short loc_4DBFAA
    ; ---------------------------------------------------------------------------

    loc_4DBFA4:                             ; CODE XREF: sub_4DBEC0+D7j
    cmp     edi, [eax]
    jnz     short loc_4DBFAA
    mov     [eax], edx

    loc_4DBFAA:                             ; CODE XREF: sub_4DBEC0+C9j
                                            ; sub_4DBEC0+CEj ...
    mov     ecx, [ebp+4]
    mov     esi, edx
    cmp     edx, [ecx+4]
    jz      loc_4DC082

    loc_4DBFB8:                             ; CODE XREF: sub_4DBEC0+1BCj
    mov     eax, [esi+4]
    cmp     [eax+14h], ebx
    jnz     loc_4DC082
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     short loc_4DC026
    mov     ecx, [edx+8]
    cmp     [ecx+14h], ebx
    jnz     short loc_4DBFF4
    mov     edx, 1
    mov     [eax+14h], edx
    mov     [ecx+14h], edx
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+14h], ebx
    mov     ecx, [esi+4]
    mov     esi, [ecx+4]
    jmp     loc_4DC076
    ; ---------------------------------------------------------------------------

    loc_4DBFF4:                             ; CODE XREF: sub_4DBEC0+113j
    cmp     esi, [eax+8]
    jnz     short loc_4DC003
    mov     esi, eax
    mov     ecx, ebp
    push    esi
    call    sub_4DD150

    loc_4DC003:                             ; CODE XREF: sub_4DBEC0+137j
    mov     edx, [esi+4]
    mov     dword ptr [edx+14h], 1
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+14h], ebx
    mov     edx, [esi+4]
    mov     ecx, ebp
    mov     eax, [edx+4]
    push    eax
    call    sub_4DD1F0
    jmp     short loc_4DC076
    ; ---------------------------------------------------------------------------

    loc_4DC026:                             ; CODE XREF: sub_4DBEC0+10Bj
    cmp     [ecx+14h], ebx
    jnz     short loc_4DC047
    mov     edx, 1
    mov     [eax+14h], edx
    mov     [ecx+14h], edx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     [edx+14h], ebx
    mov     eax, [esi+4]
    mov     esi, [eax+4]
    jmp     short loc_4DC076
    ; ---------------------------------------------------------------------------

    loc_4DC047:                             ; CODE XREF: sub_4DBEC0+169j
    cmp     esi, [eax]
    jnz     short loc_4DC055
    mov     esi, eax
    mov     ecx, ebp
    push    esi
    call    sub_4DD1F0

    loc_4DC055:                             ; CODE XREF: sub_4DBEC0+189j
    mov     ecx, [esi+4]
    mov     dword ptr [ecx+14h], 1
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+14h], ebx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     ecx, ebp
    push    edx
    call    sub_4DD150

    loc_4DC076:                             ; CODE XREF: sub_4DBEC0+12Fj
                                            ; sub_4DBEC0+164j ...
    mov     eax, [ebp+4]
    cmp     esi, [eax+4]
    jnz     loc_4DBFB8

    loc_4DC082:                             ; CODE XREF: sub_4DBEC0+F2j
                                            ; sub_4DBEC0+FEj
    mov     ecx, [ebp+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+20h+var_4]
    mov     dword ptr [edx+14h], 1
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [esp+20h+arg_0]
    mov     ecx, [esp+20h+var_10]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DC0B0:                             ; CODE XREF: sub_4DBEC0+52j
    mov     ecx, edi
    test    bl, bl
    mov     [esp+20h+var_C], ecx
    jz      short loc_4DC0E3
    mov     edx, [ebp+4]
    xor     eax, eax
    cmp     edi, [edx]
    setz    al
    test    al, al
    jz      short loc_4DC0D6
    mov     ecx, [esp+20h+arg_4]
    lea     edx, [esp+20h+arg_4]
    push    ecx
    push    edi
    push    esi
    push    edx
    jmp     short loc_4DC0FC
    ; ---------------------------------------------------------------------------

    loc_4DC0D6:                             ; CODE XREF: sub_4DBEC0+206j
    lea     ecx, [esp+20h+var_C]
    call    sub_4DD2A0
    mov     ecx, [esp+20h+var_C]

    loc_4DC0E3:                             ; CODE XREF: sub_4DBEC0+1F8j
    mov     eax, [esp+20h+arg_4]
    mov     edx, [ecx+0Ch]
    cmp     edx, [eax]
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_4DC119
    push    eax
    push    edi
    lea     eax, [esp+28h+arg_4]
    push    esi
    push    eax

    loc_4DC0FC:                             ; CODE XREF: sub_4DBEC0+214j
    mov     ecx, ebp
    call    sub_4DCE60
    mov     ecx, [eax]
    mov     eax, [esp+20h+arg_0]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 10h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DC119:                             ; CODE XREF: sub_4DBEC0+232j
    mov     eax, [esp+20h+arg_0]
    pop     edi
    pop     esi
    pop     ebp
    mov     [eax], ecx
    mov     byte ptr [eax+4], 0
    pop     ebx
    add     esp, 10h
    retn    8
    sub_4DBEC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DC130 proc near                    ; CODE XREF: sub_4DB000+6Fp
                                            ; sub_4DB000+B6p ...

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    push    ebx
    push    ebp
    mov     [esp+1Ch+var_14], ecx
    push    esi
    push    edi
    mov     edi, [esp+24h+arg_4]
    lea     ecx, [esp+24h+arg_4]
    call    sub_4DD340
    mov     ebp, edi
    lea     ecx, [esp+24h+var_4]
    mov     [esp+24h+var_10], ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     esi, [edi]
    mov     edx, dword_528A54
    lea     ebx, [edi+8]
    cmp     esi, edx
    mov     eax, ebx
    jnz     short loc_4DC16C
    mov     esi, [ebx]
    jmp     short loc_4DC1A7
    ; ---------------------------------------------------------------------------

    loc_4DC16C:                             ; CODE XREF: sub_4DC130+36j
    mov     ecx, [ebx]
    cmp     ecx, edx
    jz      short loc_4DC1A7
    mov     esi, ecx
    lea     ecx, [esp+24h+var_C]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DC191

    loc_4DC189:                             ; CODE XREF: sub_4DC130+5Fj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4DC189

    loc_4DC191:                             ; CODE XREF: sub_4DC130+57j
    lea     ecx, [esp+24h+var_C]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    lea     eax, [esi+8]
    mov     [esp+24h+var_10], esi
    mov     ebp, [esp+24h+var_10]
    mov     esi, [eax]

    loc_4DC1A7:                             ; CODE XREF: sub_4DC130+3Aj
                                            ; sub_4DC130+40j
    cmp     ebp, edi
    jz      short loc_4DC20E
    mov     ecx, [edi]
    mov     [ecx+4], ebp
    mov     edx, [edi]
    mov     [ebp+0], edx
    mov     ecx, [ebx]
    cmp     ebp, ecx
    jnz     short loc_4DC1C0
    mov     [esi+4], ebp
    jmp     short loc_4DC1D4
    ; ---------------------------------------------------------------------------

    loc_4DC1C0:                             ; CODE XREF: sub_4DC130+89j
    mov     ecx, [ebp+4]
    mov     [esi+4], ecx
    mov     edx, [ebp+4]
    mov     [edx], esi
    mov     ecx, [ebx]
    mov     [eax], ecx
    mov     edx, [ebx]
    mov     [edx+4], ebp

    loc_4DC1D4:                             ; CODE XREF: sub_4DC130+8Ej
    mov     eax, [esp+24h+var_14]
    mov     eax, [eax+4]
    cmp     [eax+4], edi
    jnz     short loc_4DC1E5
    mov     [eax+4], ebp
    jmp     short loc_4DC1F3
    ; ---------------------------------------------------------------------------

    loc_4DC1E5:                             ; CODE XREF: sub_4DC130+AEj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_4DC1F0
    mov     [eax], ebp
    jmp     short loc_4DC1F3
    ; ---------------------------------------------------------------------------

    loc_4DC1F0:                             ; CODE XREF: sub_4DC130+BAj
    mov     [eax+8], ebp

    loc_4DC1F3:                             ; CODE XREF: sub_4DC130+B3j
                                            ; sub_4DC130+BEj
    mov     ecx, [edi+4]
    mov     [esp+24h+var_10], edi
    mov     [ebp+4], ecx
    mov     edx, [edi+14h]
    mov     eax, [ebp+14h]
    mov     [ebp+14h], edx
    mov     [edi+14h], eax
    jmp     loc_4DC2C6
    ; ---------------------------------------------------------------------------

    loc_4DC20E:                             ; CODE XREF: sub_4DC130+79j
    mov     eax, [ebp+4]
    mov     ebp, [esp+24h+var_14]
    mov     [esi+4], eax
    mov     eax, [ebp+4]
    cmp     [eax+4], edi
    jnz     short loc_4DC225
    mov     [eax+4], esi
    jmp     short loc_4DC233
    ; ---------------------------------------------------------------------------

    loc_4DC225:                             ; CODE XREF: sub_4DC130+EEj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_4DC230
    mov     [eax], esi
    jmp     short loc_4DC233
    ; ---------------------------------------------------------------------------

    loc_4DC230:                             ; CODE XREF: sub_4DC130+FAj
    mov     [eax+8], esi

    loc_4DC233:                             ; CODE XREF: sub_4DC130+F3j
                                            ; sub_4DC130+FEj
    mov     eax, [ebp+4]
    cmp     [eax], edi
    jnz     short loc_4DC27A
    mov     ecx, [ebx]
    mov     edx, dword_528A54
    cmp     ecx, edx
    jnz     short loc_4DC24D
    mov     edx, [edi+4]
    mov     [eax], edx
    jmp     short loc_4DC27A
    ; ---------------------------------------------------------------------------

    loc_4DC24D:                             ; CODE XREF: sub_4DC130+114j
    lea     ecx, [esp+24h+var_8]
    mov     ebx, esi
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DC26C

    loc_4DC264:                             ; CODE XREF: sub_4DC130+13Aj
    mov     ebx, eax
    mov     eax, [ebx]
    cmp     eax, ecx
    jnz     short loc_4DC264

    loc_4DC26C:                             ; CODE XREF: sub_4DC130+132j
    lea     ecx, [esp+24h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [ebp+4]
    mov     [eax], ebx

    loc_4DC27A:                             ; CODE XREF: sub_4DC130+108j
                                            ; sub_4DC130+11Bj
    mov     eax, [ebp+4]
    cmp     [eax+8], edi
    jnz     short loc_4DC2C6
    mov     ecx, [edi]
    mov     edx, dword_528A54
    cmp     ecx, edx
    jnz     short loc_4DC296
    mov     edx, [edi+4]
    mov     [eax+8], edx
    jmp     short loc_4DC2C6
    ; ---------------------------------------------------------------------------

    loc_4DC296:                             ; CODE XREF: sub_4DC130+15Cj
    lea     ecx, [esp+24h+var_8]
    mov     edi, esi
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DC2B7

    loc_4DC2AE:                             ; CODE XREF: sub_4DC130+185j
    mov     edi, eax
    mov     eax, [edi+8]
    cmp     eax, ecx
    jnz     short loc_4DC2AE

    loc_4DC2B7:                             ; CODE XREF: sub_4DC130+17Cj
    lea     ecx, [esp+24h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [ebp+4]
    mov     [eax+8], edi

    loc_4DC2C6:                             ; CODE XREF: sub_4DC130+D9j
                                            ; sub_4DC130+150j ...
    mov     eax, [esp+24h+var_10]
    mov     ebx, 1
    xor     ebp, ebp
    cmp     [eax+14h], ebx
    jnz     loc_4DC5E3
    mov     ecx, [esp+24h+var_14]
    mov     edx, [ecx+4]
    cmp     esi, [edx+4]
    jz      loc_4DC5DC

    loc_4DC2EA:                             ; CODE XREF: sub_4DC130+2E7j
    cmp     [esi+14h], ebx
    jnz     loc_4DC5DC
    mov     eax, [esi+4]
    mov     edi, [eax]
    cmp     esi, edi
    jnz     loc_4DC387
    mov     edi, [eax+8]
    cmp     [edi+14h], ebp
    jnz     short loc_4DC36B
    mov     [edi+14h], ebx
    mov     eax, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [eax+14h], ebp
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_528A54
    jz      short loc_4DC332
    mov     [ecx+4], edi

    loc_4DC332:                             ; CODE XREF: sub_4DC130+1FDj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DC349
    mov     [ecx+4], eax
    jmp     short loc_4DC357
    ; ---------------------------------------------------------------------------

    loc_4DC349:                             ; CODE XREF: sub_4DC130+212j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4DC354
    mov     [ecx], eax
    jmp     short loc_4DC357
    ; ---------------------------------------------------------------------------

    loc_4DC354:                             ; CODE XREF: sub_4DC130+21Ej
    mov     [ecx+8], eax

    loc_4DC357:                             ; CODE XREF: sub_4DC130+217j
                                            ; sub_4DC130+222j
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx+8]

    loc_4DC36B:                             ; CODE XREF: sub_4DC130+1D6j
    mov     eax, [edi]
    cmp     [eax+14h], ebx
    jnz     loc_4DC422
    mov     ecx, [edi+8]
    cmp     [ecx+14h], ebx
    jnz     loc_4DC422
    jmp     loc_4DC407
    ; ---------------------------------------------------------------------------

    loc_4DC387:                             ; CODE XREF: sub_4DC130+1CAj
    cmp     [edi+14h], ebp
    jnz     short loc_4DC3F0
    mov     [edi+14h], ebx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_C]
    mov     [edx+14h], ebp
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A54
    jz      short loc_4DC3B6
    mov     [ecx+4], edi

    loc_4DC3B6:                             ; CODE XREF: sub_4DC130+281j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DC3CD
    mov     [ecx+4], eax
    jmp     short loc_4DC3DC
    ; ---------------------------------------------------------------------------

    loc_4DC3CD:                             ; CODE XREF: sub_4DC130+296j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4DC3DA
    mov     [ecx+8], eax
    jmp     short loc_4DC3DC
    ; ---------------------------------------------------------------------------

    loc_4DC3DA:                             ; CODE XREF: sub_4DC130+2A3j
    mov     [ecx], eax

    loc_4DC3DC:                             ; CODE XREF: sub_4DC130+29Bj
                                            ; sub_4DC130+2A8j
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_C]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_4DC3F0:                             ; CODE XREF: sub_4DC130+25Aj
    mov     eax, [edi+8]
    cmp     [eax+14h], ebx
    jnz     loc_4DC50C
    mov     ecx, [edi]
    cmp     [ecx+14h], ebx
    jnz     loc_4DC50C

    loc_4DC407:                             ; CODE XREF: sub_4DC130+252j
    mov     edx, [esp+24h+var_14]
    mov     [edi+14h], ebp
    mov     esi, [esi+4]
    mov     eax, [edx+4]
    cmp     esi, [eax+4]
    jnz     loc_4DC2EA
    jmp     loc_4DC5DC
    ; ---------------------------------------------------------------------------

    loc_4DC422:                             ; CODE XREF: sub_4DC130+240j
                                            ; sub_4DC130+24Cj
    mov     ecx, [edi+8]
    cmp     [ecx+14h], ebx
    jnz     short loc_4DC48B
    mov     edx, [edi]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+14h], ebx
    mov     [edi+14h], ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A54
    jz      short loc_4DC450
    mov     [ecx+4], edi

    loc_4DC450:                             ; CODE XREF: sub_4DC130+31Bj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DC467
    mov     [ecx+4], eax
    jmp     short loc_4DC476
    ; ---------------------------------------------------------------------------

    loc_4DC467:                             ; CODE XREF: sub_4DC130+330j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4DC474
    mov     [ecx+8], eax
    jmp     short loc_4DC476
    ; ---------------------------------------------------------------------------

    loc_4DC474:                             ; CODE XREF: sub_4DC130+33Dj
    mov     [ecx], eax

    loc_4DC476:                             ; CODE XREF: sub_4DC130+335j
                                            ; sub_4DC130+342j
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx+8]

    loc_4DC48B:                             ; CODE XREF: sub_4DC130+2F8j
    mov     eax, [esi+4]
    mov     ecx, [eax+14h]
    mov     [edi+14h], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+14h], ebx
    mov     eax, [edi+8]
    mov     [eax+14h], ebx
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_528A54
    jz      short loc_4DC4C1
    mov     [ecx+4], edi

    loc_4DC4C1:                             ; CODE XREF: sub_4DC130+38Cj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DC4E4
    mov     [ecx+4], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4DC5D7
    ; ---------------------------------------------------------------------------

    loc_4DC4E4:                             ; CODE XREF: sub_4DC130+3A1j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4DC4FB
    mov     [ecx], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4DC5D7
    ; ---------------------------------------------------------------------------

    loc_4DC4FB:                             ; CODE XREF: sub_4DC130+3B9j
    mov     [ecx+8], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4DC5D7
    ; ---------------------------------------------------------------------------

    loc_4DC50C:                             ; CODE XREF: sub_4DC130+2C6j
                                            ; sub_4DC130+2D1j
    mov     edx, [edi]
    cmp     [edx+14h], ebx
    jnz     short loc_4DC572
    mov     eax, [edi+8]
    lea     ecx, [esp+24h+var_8]
    mov     [eax+14h], ebx
    mov     [edi+14h], ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_528A54
    jz      short loc_4DC53A
    mov     [ecx+4], edi

    loc_4DC53A:                             ; CODE XREF: sub_4DC130+405j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DC551
    mov     [ecx+4], eax
    jmp     short loc_4DC55F
    ; ---------------------------------------------------------------------------

    loc_4DC551:                             ; CODE XREF: sub_4DC130+41Aj
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4DC55C
    mov     [ecx], eax
    jmp     short loc_4DC55F
    ; ---------------------------------------------------------------------------

    loc_4DC55C:                             ; CODE XREF: sub_4DC130+426j
    mov     [ecx+8], eax

    loc_4DC55F:                             ; CODE XREF: sub_4DC130+41Fj
                                            ; sub_4DC130+42Aj
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_4DC572:                             ; CODE XREF: sub_4DC130+3E1j
    mov     eax, [esi+4]
    mov     ecx, [eax+14h]
    mov     [edi+14h], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+14h], ebx
    mov     eax, [edi]
    mov     [eax+14h], ebx
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A54
    jz      short loc_4DC5A7
    mov     [ecx+4], edi

    loc_4DC5A7:                             ; CODE XREF: sub_4DC130+472j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DC5BE
    mov     [ecx+4], eax
    jmp     short loc_4DC5CD
    ; ---------------------------------------------------------------------------

    loc_4DC5BE:                             ; CODE XREF: sub_4DC130+487j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4DC5CB
    mov     [ecx+8], eax
    jmp     short loc_4DC5CD
    ; ---------------------------------------------------------------------------

    loc_4DC5CB:                             ; CODE XREF: sub_4DC130+494j
    mov     [ecx], eax

    loc_4DC5CD:                             ; CODE XREF: sub_4DC130+48Cj
                                            ; sub_4DC130+499j
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]

    loc_4DC5D7:                             ; CODE XREF: sub_4DC130+3AFj
                                            ; sub_4DC130+3C6j ...
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4DC5DC:                             ; CODE XREF: sub_4DC130+1B4j
                                            ; sub_4DC130+1BDj ...
    mov     eax, [esp+24h+var_10]
    mov     [esi+14h], ebx

    loc_4DC5E3:                             ; CODE XREF: sub_4DC130+1A4j
    cmp     eax, ebp
    jz      short loc_4DC5F4
    mov     edx, dword_528A10
    mov     [eax], edx
    mov     dword_528A10, eax

    loc_4DC5F4:                             ; CODE XREF: sub_4DC130+4B5j
    mov     eax, [esp+24h+var_14]
    mov     esi, [esp+24h+arg_0]
    mov     ecx, [eax+0Ch]
    dec     ecx
    mov     [eax+0Ch], ecx
    mov     eax, [esp+24h+arg_4]
    lea     ecx, [esp+24h+var_4]
    mov     [esi], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    sub_4DC130 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DC620 proc near                    ; CODE XREF: sub_4DACF0+8Cp
                                            ; sub_4DB450+CCp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esi+4]
    mov     esi, ecx
    mov     eax, [ecx+4]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DC65F
    mov     edx, [esp+8+arg_4]
    push    edi
    mov     edi, [edx]

    loc_4DC646:                             ; CODE XREF: sub_4DC620+3Cj
    cmp     edi, [eax+0Ch]
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_4DC657
    mov     esi, eax
    mov     eax, [eax]
    jmp     short loc_4DC65A
    ; ---------------------------------------------------------------------------

    loc_4DC657:                             ; CODE XREF: sub_4DC620+2Fj
    mov     eax, [eax+8]

    loc_4DC65A:                             ; CODE XREF: sub_4DC620+35j
    cmp     eax, ecx
    jnz     short loc_4DC646
    pop     edi

    loc_4DC65F:                             ; CODE XREF: sub_4DC620+1Dj
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [esp+8+arg_0]
    mov     [eax], esi
    pop     esi
    pop     ecx
    retn    8
    sub_4DC620 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DC680 proc near                    ; CODE XREF: sub_4DACF0+2C2p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     bl, 1
    lea     ecx, [esp+28h+var_10]
    mov     [esp+28h+var_C], edi
    mov     esi, [edi+4]
    mov     [esp+28h+var_18], esi
    mov     ebp, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, dword_528A50
    cmp     ebp, ecx
    jz      short loc_4DC6D3
    mov     eax, [esp+28h+arg_4]
    mov     eax, [eax]

    loc_4DC6B2:                             ; CODE XREF: sub_4DC680+4Dj
    mov     ebx, [ebp+0Ch]
    mov     [esp+28h+var_18], ebp
    cmp     eax, ebx
    sbb     ebx, ebx
    neg     ebx
    test    bl, bl
    jz      short loc_4DC6C8
    mov     ebp, [ebp+0]
    jmp     short loc_4DC6CB
    ; ---------------------------------------------------------------------------

    loc_4DC6C8:                             ; CODE XREF: sub_4DC680+41j
    mov     ebp, [ebp+8]

    loc_4DC6CB:                             ; CODE XREF: sub_4DC680+46j
    cmp     ebp, ecx
    jnz     short loc_4DC6B2
    mov     esi, [esp+28h+var_18]

    loc_4DC6D3:                             ; CODE XREF: sub_4DC680+2Aj
    lea     ecx, [esp+28h+var_10]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     al, [edi+8]
    test    al, al
    jz      loc_4DC886
    lea     ecx, [esp+28h+var_8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    xor     ebx, ebx
    mov     ecx, edi
    push    ebx
    push    esi
    call    sub_4DDCE0
    mov     ecx, dword_528A50
    mov     edx, eax
    mov     [esp+28h+var_4], edx
    mov     [edx], ecx
    mov     eax, dword_528A50
    mov     [edx+8], eax
    lea     eax, [edx+0Ch]
    cmp     eax, ebx
    jz      short loc_4DC72D
    mov     esi, [esp+28h+arg_4]
    mov     ecx, 0Ch
    mov     edi, eax
    rep movsd
    mov     esi, [esp+28h+var_18]
    mov     edi, [esp+28h+var_C]

    loc_4DC72D:                             ; CODE XREF: sub_4DC680+96j
    mov     ecx, [edi+0Ch]
    mov     eax, [edi+4]
    inc     ecx
    cmp     esi, eax
    mov     [edi+0Ch], ecx
    jz      short loc_4DC766
    cmp     ebp, dword_528A50
    jnz     short loc_4DC766
    mov     ecx, [esp+28h+arg_4]
    mov     eax, [ecx]
    mov     ecx, [esi+0Ch]
    cmp     eax, ecx
    sbb     ecx, ecx
    neg     ecx
    test    cl, cl
    jnz     short loc_4DC766
    mov     [esi+8], edx
    mov     eax, [edi+4]
    cmp     esi, [eax+8]
    jnz     short loc_4DC780
    mov     [eax+8], edx
    jmp     short loc_4DC780
    ; ---------------------------------------------------------------------------

    loc_4DC766:                             ; CODE XREF: sub_4DC680+B9j
                                            ; sub_4DC680+C1j ...
    mov     [esi], edx
    mov     eax, [edi+4]
    cmp     esi, eax
    jnz     short loc_4DC77A
    mov     [eax+4], edx
    mov     eax, [edi+4]
    mov     [eax+8], edx
    jmp     short loc_4DC780
    ; ---------------------------------------------------------------------------

    loc_4DC77A:                             ; CODE XREF: sub_4DC680+EDj
    cmp     esi, [eax]
    jnz     short loc_4DC780
    mov     [eax], edx

    loc_4DC780:                             ; CODE XREF: sub_4DC680+DFj
                                            ; sub_4DC680+E4j ...
    mov     ecx, [edi+4]
    mov     esi, edx
    cmp     edx, [ecx+4]
    jz      loc_4DC858

    loc_4DC78E:                             ; CODE XREF: sub_4DC680+1D2j
    mov     eax, [esi+4]
    cmp     [eax+3Ch], ebx
    jnz     loc_4DC858
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     short loc_4DC7FC
    mov     ecx, [edx+8]
    cmp     [ecx+3Ch], ebx
    jnz     short loc_4DC7CA
    mov     edx, 1
    mov     [eax+3Ch], edx
    mov     [ecx+3Ch], edx
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+3Ch], ebx
    mov     ecx, [esi+4]
    mov     esi, [ecx+4]
    jmp     loc_4DC84C
    ; ---------------------------------------------------------------------------

    loc_4DC7CA:                             ; CODE XREF: sub_4DC680+129j
    cmp     esi, [eax+8]
    jnz     short loc_4DC7D9
    mov     esi, eax
    mov     ecx, edi
    push    esi
    call    sub_4DD710

    loc_4DC7D9:                             ; CODE XREF: sub_4DC680+14Dj
    mov     edx, [esi+4]
    mov     dword ptr [edx+3Ch], 1
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+3Ch], ebx
    mov     edx, [esi+4]
    mov     ecx, edi
    mov     eax, [edx+4]
    push    eax
    call    sub_4DD770
    jmp     short loc_4DC84C
    ; ---------------------------------------------------------------------------

    loc_4DC7FC:                             ; CODE XREF: sub_4DC680+121j
    cmp     [ecx+3Ch], ebx
    jnz     short loc_4DC81D
    mov     edx, 1
    mov     [eax+3Ch], edx
    mov     [ecx+3Ch], edx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     [edx+3Ch], ebx
    mov     eax, [esi+4]
    mov     esi, [eax+4]
    jmp     short loc_4DC84C
    ; ---------------------------------------------------------------------------

    loc_4DC81D:                             ; CODE XREF: sub_4DC680+17Fj
    cmp     esi, [eax]
    jnz     short loc_4DC82B
    mov     esi, eax
    mov     ecx, edi
    push    esi
    call    sub_4DD770

    loc_4DC82B:                             ; CODE XREF: sub_4DC680+19Fj
    mov     ecx, [esi+4]
    mov     dword ptr [ecx+3Ch], 1
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+3Ch], ebx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     ecx, edi
    push    edx
    call    sub_4DD710

    loc_4DC84C:                             ; CODE XREF: sub_4DC680+145j
                                            ; sub_4DC680+17Aj ...
    mov     eax, [edi+4]
    cmp     esi, [eax+4]
    jnz     loc_4DC78E

    loc_4DC858:                             ; CODE XREF: sub_4DC680+108j
                                            ; sub_4DC680+114j
    mov     ecx, [edi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+28h+var_8]
    mov     dword ptr [edx+3Ch], 1
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [esp+28h+arg_0]
    mov     ecx, [esp+28h+var_4]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DC886:                             ; CODE XREF: sub_4DC680+61j
    mov     ecx, esi
    test    bl, bl
    mov     [esp+28h+var_14], ecx
    jz      short loc_4DC8B9
    mov     edx, [edi+4]
    xor     eax, eax
    cmp     esi, [edx]
    setz    al
    test    al, al
    jz      short loc_4DC8AC
    mov     ecx, [esp+28h+arg_4]
    lea     edx, [esp+28h+arg_4]
    push    ecx
    push    esi
    push    ebp
    push    edx
    jmp     short loc_4DC8D2
    ; ---------------------------------------------------------------------------

    loc_4DC8AC:                             ; CODE XREF: sub_4DC680+21Cj
    lea     ecx, [esp+28h+var_14]
    call    sub_4DD820
    mov     ecx, [esp+28h+var_14]

    loc_4DC8B9:                             ; CODE XREF: sub_4DC680+20Ej
    mov     eax, [esp+28h+arg_4]
    mov     edx, [ecx+0Ch]
    cmp     edx, [eax]
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_4DC8EF
    push    eax
    push    esi
    lea     eax, [esp+30h+arg_4]
    push    ebp
    push    eax

    loc_4DC8D2:                             ; CODE XREF: sub_4DC680+22Aj
    mov     ecx, edi
    call    sub_4DD430
    mov     ecx, [eax]
    mov     eax, [esp+28h+arg_0]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DC8EF:                             ; CODE XREF: sub_4DC680+248j
    mov     eax, [esp+28h+arg_0]
    pop     edi
    pop     esi
    pop     ebp
    mov     [eax], ecx
    mov     byte ptr [eax+4], 0
    pop     ebx
    add     esp, 18h
    retn    8
    sub_4DC680 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DC910 proc near                    ; CODE XREF: sub_4DB7D0+10Cp

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    push    ebx
    push    ebp
    mov     [esp+1Ch+var_14], ecx
    push    esi
    push    edi
    mov     edi, [esp+24h+arg_4]
    lea     ecx, [esp+24h+arg_4]
    call    sub_4DDE70
    mov     ebp, edi
    lea     ecx, [esp+24h+var_4]
    mov     [esp+24h+var_10], ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     esi, [edi]
    mov     edx, dword_528A50
    lea     ebx, [edi+8]
    cmp     esi, edx
    mov     eax, ebx
    jnz     short loc_4DC94C
    mov     esi, [ebx]
    jmp     short loc_4DC987
    ; ---------------------------------------------------------------------------

    loc_4DC94C:                             ; CODE XREF: sub_4DC910+36j
    mov     ecx, [ebx]
    cmp     ecx, edx
    jz      short loc_4DC987
    mov     esi, ecx
    lea     ecx, [esp+24h+var_C]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_528A50
    cmp     eax, ecx
    jz      short loc_4DC971

    loc_4DC969:                             ; CODE XREF: sub_4DC910+5Fj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4DC969

    loc_4DC971:                             ; CODE XREF: sub_4DC910+57j
    lea     ecx, [esp+24h+var_C]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    lea     eax, [esi+8]
    mov     [esp+24h+var_10], esi
    mov     ebp, [esp+24h+var_10]
    mov     esi, [eax]

    loc_4DC987:                             ; CODE XREF: sub_4DC910+3Aj
                                            ; sub_4DC910+40j
    cmp     ebp, edi
    jz      short loc_4DC9EE
    mov     ecx, [edi]
    mov     [ecx+4], ebp
    mov     edx, [edi]
    mov     [ebp+0], edx
    mov     ecx, [ebx]
    cmp     ebp, ecx
    jnz     short loc_4DC9A0
    mov     [esi+4], ebp
    jmp     short loc_4DC9B4
    ; ---------------------------------------------------------------------------

    loc_4DC9A0:                             ; CODE XREF: sub_4DC910+89j
    mov     ecx, [ebp+4]
    mov     [esi+4], ecx
    mov     edx, [ebp+4]
    mov     [edx], esi
    mov     ecx, [ebx]
    mov     [eax], ecx
    mov     edx, [ebx]
    mov     [edx+4], ebp

    loc_4DC9B4:                             ; CODE XREF: sub_4DC910+8Ej
    mov     eax, [esp+24h+var_14]
    mov     eax, [eax+4]
    cmp     [eax+4], edi
    jnz     short loc_4DC9C5
    mov     [eax+4], ebp
    jmp     short loc_4DC9D3
    ; ---------------------------------------------------------------------------

    loc_4DC9C5:                             ; CODE XREF: sub_4DC910+AEj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_4DC9D0
    mov     [eax], ebp
    jmp     short loc_4DC9D3
    ; ---------------------------------------------------------------------------

    loc_4DC9D0:                             ; CODE XREF: sub_4DC910+BAj
    mov     [eax+8], ebp

    loc_4DC9D3:                             ; CODE XREF: sub_4DC910+B3j
                                            ; sub_4DC910+BEj
    mov     ecx, [edi+4]
    mov     [esp+24h+var_10], edi
    mov     [ebp+4], ecx
    mov     edx, [edi+3Ch]
    mov     eax, [ebp+3Ch]
    mov     [ebp+3Ch], edx
    mov     [edi+3Ch], eax
    jmp     loc_4DCAA6
    ; ---------------------------------------------------------------------------

    loc_4DC9EE:                             ; CODE XREF: sub_4DC910+79j
    mov     eax, [ebp+4]
    mov     ebp, [esp+24h+var_14]
    mov     [esi+4], eax
    mov     eax, [ebp+4]
    cmp     [eax+4], edi
    jnz     short loc_4DCA05
    mov     [eax+4], esi
    jmp     short loc_4DCA13
    ; ---------------------------------------------------------------------------

    loc_4DCA05:                             ; CODE XREF: sub_4DC910+EEj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_4DCA10
    mov     [eax], esi
    jmp     short loc_4DCA13
    ; ---------------------------------------------------------------------------

    loc_4DCA10:                             ; CODE XREF: sub_4DC910+FAj
    mov     [eax+8], esi

    loc_4DCA13:                             ; CODE XREF: sub_4DC910+F3j
                                            ; sub_4DC910+FEj
    mov     eax, [ebp+4]
    cmp     [eax], edi
    jnz     short loc_4DCA5A
    mov     ecx, [ebx]
    mov     edx, dword_528A50
    cmp     ecx, edx
    jnz     short loc_4DCA2D
    mov     edx, [edi+4]
    mov     [eax], edx
    jmp     short loc_4DCA5A
    ; ---------------------------------------------------------------------------

    loc_4DCA2D:                             ; CODE XREF: sub_4DC910+114j
    lea     ecx, [esp+24h+var_8]
    mov     ebx, esi
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_528A50
    cmp     eax, ecx
    jz      short loc_4DCA4C

    loc_4DCA44:                             ; CODE XREF: sub_4DC910+13Aj
    mov     ebx, eax
    mov     eax, [ebx]
    cmp     eax, ecx
    jnz     short loc_4DCA44

    loc_4DCA4C:                             ; CODE XREF: sub_4DC910+132j
    lea     ecx, [esp+24h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [ebp+4]
    mov     [eax], ebx

    loc_4DCA5A:                             ; CODE XREF: sub_4DC910+108j
                                            ; sub_4DC910+11Bj
    mov     eax, [ebp+4]
    cmp     [eax+8], edi
    jnz     short loc_4DCAA6
    mov     ecx, [edi]
    mov     edx, dword_528A50
    cmp     ecx, edx
    jnz     short loc_4DCA76
    mov     edx, [edi+4]
    mov     [eax+8], edx
    jmp     short loc_4DCAA6
    ; ---------------------------------------------------------------------------

    loc_4DCA76:                             ; CODE XREF: sub_4DC910+15Cj
    lea     ecx, [esp+24h+var_8]
    mov     edi, esi
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     ecx, dword_528A50
    cmp     eax, ecx
    jz      short loc_4DCA97

    loc_4DCA8E:                             ; CODE XREF: sub_4DC910+185j
    mov     edi, eax
    mov     eax, [edi+8]
    cmp     eax, ecx
    jnz     short loc_4DCA8E

    loc_4DCA97:                             ; CODE XREF: sub_4DC910+17Cj
    lea     ecx, [esp+24h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [ebp+4]
    mov     [eax+8], edi

    loc_4DCAA6:                             ; CODE XREF: sub_4DC910+D9j
                                            ; sub_4DC910+150j ...
    mov     eax, [esp+24h+var_10]
    mov     ebx, 1
    xor     ebp, ebp
    cmp     [eax+3Ch], ebx
    jnz     loc_4DCDC3
    mov     ecx, [esp+24h+var_14]
    mov     edx, [ecx+4]
    cmp     esi, [edx+4]
    jz      loc_4DCDBC

    loc_4DCACA:                             ; CODE XREF: sub_4DC910+2E7j
    cmp     [esi+3Ch], ebx
    jnz     loc_4DCDBC
    mov     eax, [esi+4]
    mov     edi, [eax]
    cmp     esi, edi
    jnz     loc_4DCB67
    mov     edi, [eax+8]
    cmp     [edi+3Ch], ebp
    jnz     short loc_4DCB4B
    mov     [edi+3Ch], ebx
    mov     eax, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [eax+3Ch], ebp
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_528A50
    jz      short loc_4DCB12
    mov     [ecx+4], edi

    loc_4DCB12:                             ; CODE XREF: sub_4DC910+1FDj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DCB29
    mov     [ecx+4], eax
    jmp     short loc_4DCB37
    ; ---------------------------------------------------------------------------

    loc_4DCB29:                             ; CODE XREF: sub_4DC910+212j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4DCB34
    mov     [ecx], eax
    jmp     short loc_4DCB37
    ; ---------------------------------------------------------------------------

    loc_4DCB34:                             ; CODE XREF: sub_4DC910+21Ej
    mov     [ecx+8], eax

    loc_4DCB37:                             ; CODE XREF: sub_4DC910+217j
                                            ; sub_4DC910+222j
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx+8]

    loc_4DCB4B:                             ; CODE XREF: sub_4DC910+1D6j
    mov     eax, [edi]
    cmp     [eax+3Ch], ebx
    jnz     loc_4DCC02
    mov     ecx, [edi+8]
    cmp     [ecx+3Ch], ebx
    jnz     loc_4DCC02
    jmp     loc_4DCBE7
    ; ---------------------------------------------------------------------------

    loc_4DCB67:                             ; CODE XREF: sub_4DC910+1CAj
    cmp     [edi+3Ch], ebp
    jnz     short loc_4DCBD0
    mov     [edi+3Ch], ebx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_C]
    mov     [edx+3Ch], ebp
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A50
    jz      short loc_4DCB96
    mov     [ecx+4], edi

    loc_4DCB96:                             ; CODE XREF: sub_4DC910+281j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DCBAD
    mov     [ecx+4], eax
    jmp     short loc_4DCBBC
    ; ---------------------------------------------------------------------------

    loc_4DCBAD:                             ; CODE XREF: sub_4DC910+296j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4DCBBA
    mov     [ecx+8], eax
    jmp     short loc_4DCBBC
    ; ---------------------------------------------------------------------------

    loc_4DCBBA:                             ; CODE XREF: sub_4DC910+2A3j
    mov     [ecx], eax

    loc_4DCBBC:                             ; CODE XREF: sub_4DC910+29Bj
                                            ; sub_4DC910+2A8j
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_C]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_4DCBD0:                             ; CODE XREF: sub_4DC910+25Aj
    mov     eax, [edi+8]
    cmp     [eax+3Ch], ebx
    jnz     loc_4DCCEC
    mov     ecx, [edi]
    cmp     [ecx+3Ch], ebx
    jnz     loc_4DCCEC

    loc_4DCBE7:                             ; CODE XREF: sub_4DC910+252j
    mov     edx, [esp+24h+var_14]
    mov     [edi+3Ch], ebp
    mov     esi, [esi+4]
    mov     eax, [edx+4]
    cmp     esi, [eax+4]
    jnz     loc_4DCACA
    jmp     loc_4DCDBC
    ; ---------------------------------------------------------------------------

    loc_4DCC02:                             ; CODE XREF: sub_4DC910+240j
                                            ; sub_4DC910+24Cj
    mov     ecx, [edi+8]
    cmp     [ecx+3Ch], ebx
    jnz     short loc_4DCC6B
    mov     edx, [edi]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+3Ch], ebx
    mov     [edi+3Ch], ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A50
    jz      short loc_4DCC30
    mov     [ecx+4], edi

    loc_4DCC30:                             ; CODE XREF: sub_4DC910+31Bj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DCC47
    mov     [ecx+4], eax
    jmp     short loc_4DCC56
    ; ---------------------------------------------------------------------------

    loc_4DCC47:                             ; CODE XREF: sub_4DC910+330j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4DCC54
    mov     [ecx+8], eax
    jmp     short loc_4DCC56
    ; ---------------------------------------------------------------------------

    loc_4DCC54:                             ; CODE XREF: sub_4DC910+33Dj
    mov     [ecx], eax

    loc_4DCC56:                             ; CODE XREF: sub_4DC910+335j
                                            ; sub_4DC910+342j
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx+8]

    loc_4DCC6B:                             ; CODE XREF: sub_4DC910+2F8j
    mov     eax, [esi+4]
    mov     ecx, [eax+3Ch]
    mov     [edi+3Ch], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+3Ch], ebx
    mov     eax, [edi+8]
    mov     [eax+3Ch], ebx
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_528A50
    jz      short loc_4DCCA1
    mov     [ecx+4], edi

    loc_4DCCA1:                             ; CODE XREF: sub_4DC910+38Cj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DCCC4
    mov     [ecx+4], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4DCDB7
    ; ---------------------------------------------------------------------------

    loc_4DCCC4:                             ; CODE XREF: sub_4DC910+3A1j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4DCCDB
    mov     [ecx], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4DCDB7
    ; ---------------------------------------------------------------------------

    loc_4DCCDB:                             ; CODE XREF: sub_4DC910+3B9j
    mov     [ecx+8], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4DCDB7
    ; ---------------------------------------------------------------------------

    loc_4DCCEC:                             ; CODE XREF: sub_4DC910+2C6j
                                            ; sub_4DC910+2D1j
    mov     edx, [edi]
    cmp     [edx+3Ch], ebx
    jnz     short loc_4DCD52
    mov     eax, [edi+8]
    lea     ecx, [esp+24h+var_8]
    mov     [eax+3Ch], ebx
    mov     [edi+3Ch], ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_528A50
    jz      short loc_4DCD1A
    mov     [ecx+4], edi

    loc_4DCD1A:                             ; CODE XREF: sub_4DC910+405j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DCD31
    mov     [ecx+4], eax
    jmp     short loc_4DCD3F
    ; ---------------------------------------------------------------------------

    loc_4DCD31:                             ; CODE XREF: sub_4DC910+41Aj
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4DCD3C
    mov     [ecx], eax
    jmp     short loc_4DCD3F
    ; ---------------------------------------------------------------------------

    loc_4DCD3C:                             ; CODE XREF: sub_4DC910+426j
    mov     [ecx+8], eax

    loc_4DCD3F:                             ; CODE XREF: sub_4DC910+41Fj
                                            ; sub_4DC910+42Aj
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_4DCD52:                             ; CODE XREF: sub_4DC910+3E1j
    mov     eax, [esi+4]
    mov     ecx, [eax+3Ch]
    mov     [edi+3Ch], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+3Ch], ebx
    mov     eax, [edi]
    mov     [eax+3Ch], ebx
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A50
    jz      short loc_4DCD87
    mov     [ecx+4], edi

    loc_4DCD87:                             ; CODE XREF: sub_4DC910+472j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DCD9E
    mov     [ecx+4], eax
    jmp     short loc_4DCDAD
    ; ---------------------------------------------------------------------------

    loc_4DCD9E:                             ; CODE XREF: sub_4DC910+487j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4DCDAB
    mov     [ecx+8], eax
    jmp     short loc_4DCDAD
    ; ---------------------------------------------------------------------------

    loc_4DCDAB:                             ; CODE XREF: sub_4DC910+494j
    mov     [ecx], eax

    loc_4DCDAD:                             ; CODE XREF: sub_4DC910+48Cj
                                            ; sub_4DC910+499j
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]

    loc_4DCDB7:                             ; CODE XREF: sub_4DC910+3AFj
                                            ; sub_4DC910+3C6j ...
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4DCDBC:                             ; CODE XREF: sub_4DC910+1B4j
                                            ; sub_4DC910+1BDj ...
    mov     eax, [esp+24h+var_10]
    mov     [esi+3Ch], ebx

    loc_4DCDC3:                             ; CODE XREF: sub_4DC910+1A4j
    cmp     eax, ebp
    jz      short loc_4DCDD4
    mov     edx, dword_5289E0
    mov     [eax], edx
    mov     dword_5289E0, eax

    loc_4DCDD4:                             ; CODE XREF: sub_4DC910+4B5j
    mov     eax, [esp+24h+var_14]
    mov     esi, [esp+24h+arg_0]
    mov     ecx, [eax+0Ch]
    dec     ecx
    mov     [eax+0Ch], ecx
    mov     eax, [esp+24h+arg_4]
    lea     ecx, [esp+24h+var_4]
    mov     [esi], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    sub_4DC910 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DCE00 proc near                    ; CODE XREF: sub_4DB7D0+4Ap

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    esi
    push    edi
    mov     edi, [esp+0Ch+arg_4]
    mov     esi, ecx
    push    edi
    call    sub_4DDC90
    mov     esi, [esi+4]
    xor     ecx, ecx
    cmp     eax, esi
    mov     [esp+0Ch+arg_4], eax
    setz    cl
    test    cl, cl
    jnz     short loc_4DCE42
    mov     edx, [edi]
    mov     edi, [eax+0Ch]
    cmp     edx, edi
    sbb     eax, eax
    neg     eax
    test    al, al
    jnz     short loc_4DCE42
    lea     eax, [esp+0Ch+arg_4]
    mov     ecx, [eax]
    mov     eax, [esp+0Ch+arg_0]
    mov     [eax], ecx
    pop     edi
    pop     esi
    pop     ecx
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DCE42:                             ; CODE XREF: sub_4DCE00+1Fj
                                            ; sub_4DCE00+2Ej
    lea     eax, [esp+0Ch+var_4]
    mov     [esp+0Ch+var_4], esi
    pop     edi
    pop     esi
    mov     ecx, [eax]
    mov     eax, [esp+4+arg_0]
    mov     [eax], ecx
    pop     ecx
    retn    8
    sub_4DCE00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DCE60 proc near                    ; CODE XREF: sub_4DB000+112p
                                            ; sub_4DB000+14Fp ...

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebx, ecx
    push    esi
    push    edi
    lea     ecx, [esp+1Ch+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    push    18h
    mov     ecx, ebx
    call    sub_4DDD70
    mov     edi, eax
    mov     eax, [esp+1Ch+arg_8]
    mov     [esp+1Ch+var_C], edi
    mov     [edi+4], eax
    mov     dword ptr [edi+14h], 0
    mov     ecx, dword_528A54
    mov     [edi], ecx
    mov     edx, dword_528A54
    lea     ecx, [edi+0Ch]
    mov     [edi+8], edx
    mov     edx, [esp+1Ch+arg_C]
    test    ecx, ecx
    jz      short loc_4DCEB5
    mov     esi, [edx]
    mov     [ecx], esi
    mov     esi, [edx+4]
    mov     [ecx+4], esi

    loc_4DCEB5:                             ; CODE XREF: sub_4DCE60+49j
    mov     esi, [ebx+0Ch]
    mov     ecx, [ebx+4]
    inc     esi
    cmp     eax, ecx
    mov     [ebx+0Ch], esi
    jz      short loc_4DCEF0
    mov     ecx, [esp+1Ch+arg_4]
    mov     esi, dword_528A54
    cmp     ecx, esi
    jnz     short loc_4DCEF0
    mov     edx, [edx]
    mov     ebp, [eax+0Ch]
    cmp     edx, ebp
    sbb     ecx, ecx
    neg     ecx
    test    cl, cl
    jnz     short loc_4DCEF0
    mov     [eax+8], edi
    mov     ecx, [ebx+4]
    cmp     eax, [ecx+8]
    jnz     short loc_4DCF0A
    mov     [ecx+8], edi
    jmp     short loc_4DCF0A
    ; ---------------------------------------------------------------------------

    loc_4DCEF0:                             ; CODE XREF: sub_4DCE60+61j
                                            ; sub_4DCE60+6Fj ...
    mov     [eax], edi
    mov     ecx, [ebx+4]
    cmp     eax, ecx
    jnz     short loc_4DCF04
    mov     [ecx+4], edi
    mov     edx, [ebx+4]
    mov     [edx+8], edi
    jmp     short loc_4DCF0A
    ; ---------------------------------------------------------------------------

    loc_4DCF04:                             ; CODE XREF: sub_4DCE60+97j
    cmp     eax, [ecx]
    jnz     short loc_4DCF0A
    mov     [ecx], edi

    loc_4DCF0A:                             ; CODE XREF: sub_4DCE60+89j
                                            ; sub_4DCE60+8Ej ...
    mov     eax, [ebx+4]
    mov     esi, edi
    mov     ebp, 1
    cmp     edi, [eax+4]
    jz      loc_4DD126

    loc_4DCF1D:                             ; CODE XREF: sub_4DCE60+2C0j
    mov     eax, [esi+4]
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     loc_4DD126
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     loc_4DD036
    mov     ecx, [edx+8]
    mov     edx, [ecx+14h]
    test    edx, edx
    jnz     short loc_4DCF60
    mov     [eax+14h], ebp
    mov     [ecx+14h], ebp
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     dword ptr [edx+14h], 0
    mov     eax, [esi+4]
    mov     esi, [eax+4]
    jmp     loc_4DD11A
    ; ---------------------------------------------------------------------------

    loc_4DCF60:                             ; CODE XREF: sub_4DCE60+E0j
    cmp     esi, [eax+8]
    jnz     short loc_4DCFB4
    lea     ecx, [esp+1Ch+arg_8]
    mov     esi, eax
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     ecx, [eax]
    mov     [esi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_528A54
    jz      short loc_4DCF85
    mov     [ecx+4], esi

    loc_4DCF85:                             ; CODE XREF: sub_4DCE60+120j
    mov     edx, [esi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     esi, [ecx+4]
    jnz     short loc_4DCF98
    mov     [ecx+4], eax
    jmp     short loc_4DCFA6
    ; ---------------------------------------------------------------------------

    loc_4DCF98:                             ; CODE XREF: sub_4DCE60+131j
    mov     ecx, [esi+4]
    cmp     esi, [ecx]
    jnz     short loc_4DCFA3
    mov     [ecx], eax
    jmp     short loc_4DCFA6
    ; ---------------------------------------------------------------------------

    loc_4DCFA3:                             ; CODE XREF: sub_4DCE60+13Dj
    mov     [ecx+8], eax

    loc_4DCFA6:                             ; CODE XREF: sub_4DCE60+136j
                                            ; sub_4DCE60+141j
    mov     [eax], esi
    lea     ecx, [esp+1Ch+arg_8]
    mov     [esi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4DCFB4:                             ; CODE XREF: sub_4DCE60+103j
    mov     eax, [esi+4]
    mov     [eax+14h], ebp
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+arg_C]
    mov     dword ptr [edx+14h], 0
    mov     eax, [esi+4]
    mov     edi, [eax+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A54
    jz      short loc_4DCFEB
    mov     [ecx+4], edi

    loc_4DCFEB:                             ; CODE XREF: sub_4DCE60+186j
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DD00B
    mov     [ecx+4], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4DD111
    ; ---------------------------------------------------------------------------

    loc_4DD00B:                             ; CODE XREF: sub_4DCE60+197j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4DD025
    mov     [ecx+8], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4DD111
    ; ---------------------------------------------------------------------------

    loc_4DD025:                             ; CODE XREF: sub_4DCE60+1B1j
    mov     [ecx], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4DD111
    ; ---------------------------------------------------------------------------

    loc_4DD036:                             ; CODE XREF: sub_4DCE60+D2j
    mov     edx, [ecx+14h]
    test    edx, edx
    jnz     short loc_4DD05B
    mov     [eax+14h], ebp
    mov     [ecx+14h], ebp
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     dword ptr [ecx+14h], 0
    mov     edx, [esi+4]
    mov     esi, [edx+4]
    jmp     loc_4DD11A
    ; ---------------------------------------------------------------------------

    loc_4DD05B:                             ; CODE XREF: sub_4DCE60+1DBj
    cmp     esi, [eax]
    jnz     short loc_4DD0B0
    lea     ecx, [esp+1Ch+arg_4]
    mov     esi, eax
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, [eax+8]
    mov     [esi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A54
    jz      short loc_4DD07F
    mov     [ecx+4], esi

    loc_4DD07F:                             ; CODE XREF: sub_4DCE60+21Aj
    mov     edx, [esi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     esi, [ecx+4]
    jnz     short loc_4DD092
    mov     [ecx+4], eax
    jmp     short loc_4DD0A1
    ; ---------------------------------------------------------------------------

    loc_4DD092:                             ; CODE XREF: sub_4DCE60+22Bj
    mov     ecx, [esi+4]
    cmp     esi, [ecx+8]
    jnz     short loc_4DD09F
    mov     [ecx+8], eax
    jmp     short loc_4DD0A1
    ; ---------------------------------------------------------------------------

    loc_4DD09F:                             ; CODE XREF: sub_4DCE60+238j
    mov     [ecx], eax

    loc_4DD0A1:                             ; CODE XREF: sub_4DCE60+230j
                                            ; sub_4DCE60+23Dj
    mov     [eax+8], esi
    lea     ecx, [esp+1Ch+arg_4]
    mov     [esi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4DD0B0:                             ; CODE XREF: sub_4DCE60+1FDj
    mov     eax, [esi+4]
    mov     [eax+14h], ebp
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+var_8]
    mov     dword ptr [edx+14h], 0
    mov     eax, [esi+4]
    mov     edi, [eax+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_528A54
    jz      short loc_4DD0E7
    mov     [ecx+4], edi

    loc_4DD0E7:                             ; CODE XREF: sub_4DCE60+282j
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DD0FA
    mov     [ecx+4], eax
    jmp     short loc_4DD108
    ; ---------------------------------------------------------------------------

    loc_4DD0FA:                             ; CODE XREF: sub_4DCE60+293j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4DD105
    mov     [ecx], eax
    jmp     short loc_4DD108
    ; ---------------------------------------------------------------------------

    loc_4DD105:                             ; CODE XREF: sub_4DCE60+29Fj
    mov     [ecx+8], eax

    loc_4DD108:                             ; CODE XREF: sub_4DCE60+298j
                                            ; sub_4DCE60+2A3j
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+var_8]

    loc_4DD111:                             ; CODE XREF: sub_4DCE60+1A6j
                                            ; sub_4DCE60+1C0j ...
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edi, [esp+1Ch+var_C]

    loc_4DD11A:                             ; CODE XREF: sub_4DCE60+FBj
                                            ; sub_4DCE60+1F6j
    mov     eax, [ebx+4]
    cmp     esi, [eax+4]
    jnz     loc_4DCF1D

    loc_4DD126:                             ; CODE XREF: sub_4DCE60+B7j
                                            ; sub_4DCE60+C5j
    mov     ecx, [ebx+4]
    mov     esi, [esp+1Ch+arg_0]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+var_4]
    mov     [edx+14h], ebp
    mov     [esi], edi
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    10h
    sub_4DCE60 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD150 proc near                    ; CODE XREF: sub_4DBEC0+13Ep
                                            ; sub_4DBEC0+1B1p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx+8]
    mov     edx, [eax]
    mov     [ecx+8], edx
    mov     edx, [eax]
    cmp     edx, dword_528A54
    jz      short loc_4DD176
    mov     [edx+4], ecx

    loc_4DD176:                             ; CODE XREF: sub_4DD150+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_4DD189
    mov     [edx+4], eax
    jmp     short loc_4DD197
    ; ---------------------------------------------------------------------------

    loc_4DD189:                             ; CODE XREF: sub_4DD150+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx]
    jnz     short loc_4DD194
    mov     [edx], eax
    jmp     short loc_4DD197
    ; ---------------------------------------------------------------------------

    loc_4DD194:                             ; CODE XREF: sub_4DD150+3Ej
    mov     [edx+8], eax

    loc_4DD197:                             ; CODE XREF: sub_4DD150+37j
                                            ; sub_4DD150+42j
    mov     [eax], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     esi
    pop     ecx
    retn    4
    sub_4DD150 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD1B0 proc near                    ; CODE XREF: sub_4DB1C0+C9p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     esi, [esp+8+arg_0]
    mov     ecx, dword_528A54
    mov     eax, [esi]
    cmp     eax, ecx
    jz      short loc_4DD1D3

    loc_4DD1CB:                             ; CODE XREF: sub_4DD1B0+21j
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4DD1CB

    loc_4DD1D3:                             ; CODE XREF: sub_4DD1B0+19j
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     esi
    pop     ecx
    retn
    sub_4DD1B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD1F0 proc near                    ; CODE XREF: sub_4DBEC0+15Fp
                                            ; sub_4DBEC0+190p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx]
    mov     edx, [eax+8]
    mov     [ecx], edx
    mov     edx, [eax+8]
    cmp     edx, dword_528A54
    jz      short loc_4DD216
    mov     [edx+4], ecx

    loc_4DD216:                             ; CODE XREF: sub_4DD1F0+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_4DD229
    mov     [edx+4], eax
    jmp     short loc_4DD238
    ; ---------------------------------------------------------------------------

    loc_4DD229:                             ; CODE XREF: sub_4DD1F0+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx+8]
    jnz     short loc_4DD236
    mov     [edx+8], eax
    jmp     short loc_4DD238
    ; ---------------------------------------------------------------------------

    loc_4DD236:                             ; CODE XREF: sub_4DD1F0+3Fj
    mov     [edx], eax

    loc_4DD238:                             ; CODE XREF: sub_4DD1F0+37j
                                            ; sub_4DD1F0+44j
    mov     [eax+8], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     esi
    pop     ecx
    retn    4
    sub_4DD1F0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD250 proc near                    ; CODE XREF: sub_4DB000+Ep
                                            ; sub_4DB1C0+2Ep

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esi+4]
    mov     esi, ecx
    mov     eax, [ecx+4]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DD28F
    mov     edx, [esp+8+arg_0]
    push    edi
    mov     edi, [edx]

    loc_4DD276:                             ; CODE XREF: sub_4DD250+3Cj
    cmp     edi, [eax+0Ch]
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_4DD287
    mov     esi, eax
    mov     eax, [eax]
    jmp     short loc_4DD28A
    ; ---------------------------------------------------------------------------

    loc_4DD287:                             ; CODE XREF: sub_4DD250+2Fj
    mov     eax, [eax+8]

    loc_4DD28A:                             ; CODE XREF: sub_4DD250+35j
    cmp     eax, ecx
    jnz     short loc_4DD276
    pop     edi

    loc_4DD28F:                             ; CODE XREF: sub_4DD250+1Dj
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_4DD250 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD2A0 proc near                    ; CODE XREF: sub_4DB000+31p
                                            ; sub_4DB000+15Bp ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+14h]
    test    ecx, ecx
    jnz     short loc_4DD2D5
    mov     ecx, [eax+4]
    cmp     [ecx+4], eax
    jnz     short loc_4DD2D5
    mov     edx, [eax+8]
    lea     ecx, [esp+10h+var_4]
    mov     [edi], edx
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4DD2D5:                             ; CODE XREF: sub_4DD2A0+17j
                                            ; sub_4DD2A0+1Fj
    mov     esi, [eax]
    mov     ecx, dword_528A54
    cmp     esi, ecx
    jz      short loc_4DD31A
    lea     ecx, [esp+10h+var_8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DD300

    loc_4DD2F7:                             ; CODE XREF: sub_4DD2A0+5Ej
    mov     esi, eax
    mov     eax, [esi+8]
    cmp     eax, ecx
    jnz     short loc_4DD2F7

    loc_4DD300:                             ; CODE XREF: sub_4DD2A0+55j
    lea     ecx, [esp+10h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4DD31A:                             ; CODE XREF: sub_4DD2A0+3Fj
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax]
    jnz     short loc_4DD32E

    loc_4DD323:                             ; CODE XREF: sub_4DD2A0+8Cj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax]
    jz      short loc_4DD323

    loc_4DD32E:                             ; CODE XREF: sub_4DD2A0+81j
    lea     ecx, [esp+10h+var_4]
    mov     [edi], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4DD2A0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD340 proc near                    ; CODE XREF: sub_4DC130+13p

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, dword_528A54
    mov     esi, [eax+8]
    cmp     esi, ecx
    jz      short loc_4DD396
    lea     ecx, [esp+10h+var_8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_528A54
    cmp     eax, ecx
    jz      short loc_4DD37C

    loc_4DD374:                             ; CODE XREF: sub_4DD340+3Aj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4DD374

    loc_4DD37C:                             ; CODE XREF: sub_4DD340+32j
    lea     ecx, [esp+10h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4DD396:                             ; CODE XREF: sub_4DD340+1Dj
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax+8]
    jnz     short loc_4DD3AC

    loc_4DD3A0:                             ; CODE XREF: sub_4DD340+6Aj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax+8]
    jz      short loc_4DD3A0

    loc_4DD3AC:                             ; CODE XREF: sub_4DD340+5Ej
    mov     ecx, [edi]
    cmp     [ecx+8], eax
    jz      short loc_4DD3B5
    mov     [edi], eax

    loc_4DD3B5:                             ; CODE XREF: sub_4DD340+71j
    lea     ecx, [esp+10h+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4DD340 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD3D0 proc near                    ; CODE XREF: sub_4DBAE0+3Cp

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esi+4]
    mov     esi, ecx
    mov     eax, [ecx+4]
    mov     ecx, dword_528A50
    cmp     eax, ecx
    jz      short loc_4DD40F
    mov     edx, [esp+8+arg_4]
    push    edi
    mov     edi, [edx]

    loc_4DD3F6:                             ; CODE XREF: sub_4DD3D0+3Cj
    cmp     [eax+0Ch], edi
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_4DD406
    mov     eax, [eax+8]
    jmp     short loc_4DD40A
    ; ---------------------------------------------------------------------------

    loc_4DD406:                             ; CODE XREF: sub_4DD3D0+2Fj
    mov     esi, eax
    mov     eax, [eax]

    loc_4DD40A:                             ; CODE XREF: sub_4DD3D0+34j
    cmp     eax, ecx
    jnz     short loc_4DD3F6
    pop     edi

    loc_4DD40F:                             ; CODE XREF: sub_4DD3D0+1Dj
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [esp+8+arg_0]
    mov     [eax], esi
    pop     esi
    pop     ecx
    retn    8
    sub_4DD3D0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD430 proc near                    ; CODE XREF: sub_4DC680+254p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebx, ecx
    push    esi
    push    edi
    lea     ecx, [esp+1Ch+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    push    40h
    mov     ecx, ebx
    call    sub_4DDDF0
    mov     ebp, eax
    mov     eax, [esp+1Ch+arg_8]
    mov     [esp+1Ch+var_C], ebp
    mov     [ebp+4], eax
    mov     dword ptr [ebp+3Ch], 0
    mov     ecx, dword_528A50
    lea     edi, [ebp+0Ch]
    mov     [ebp+0], ecx
    mov     edx, dword_528A50
    mov     [ebp+8], edx
    mov     edx, [esp+1Ch+arg_C]
    test    edi, edi
    jz      short loc_4DD485
    mov     ecx, 0Ch
    mov     esi, edx
    rep movsd

    loc_4DD485:                             ; CODE XREF: sub_4DD430+4Aj
    mov     esi, [ebx+0Ch]
    mov     ecx, [ebx+4]
    inc     esi
    cmp     eax, ecx
    mov     [ebx+0Ch], esi
    jz      short loc_4DD4C0
    mov     ecx, [esp+1Ch+arg_4]
    mov     esi, dword_528A50
    cmp     ecx, esi
    jnz     short loc_4DD4C0
    mov     edx, [edx]
    mov     edi, [eax+0Ch]
    cmp     edx, edi
    sbb     ecx, ecx
    neg     ecx
    test    cl, cl
    jnz     short loc_4DD4C0
    mov     [eax+8], ebp
    mov     ecx, [ebx+4]
    cmp     eax, [ecx+8]
    jnz     short loc_4DD4DA
    mov     [ecx+8], ebp
    jmp     short loc_4DD4DA
    ; ---------------------------------------------------------------------------

    loc_4DD4C0:                             ; CODE XREF: sub_4DD430+61j
                                            ; sub_4DD430+6Fj ...
    mov     [eax], ebp
    mov     ecx, [ebx+4]
    cmp     eax, ecx
    jnz     short loc_4DD4D4
    mov     [ecx+4], ebp
    mov     edx, [ebx+4]
    mov     [edx+8], ebp
    jmp     short loc_4DD4DA
    ; ---------------------------------------------------------------------------

    loc_4DD4D4:                             ; CODE XREF: sub_4DD430+97j
    cmp     eax, [ecx]
    jnz     short loc_4DD4DA
    mov     [ecx], ebp

    loc_4DD4DA:                             ; CODE XREF: sub_4DD430+89j
                                            ; sub_4DD430+8Ej ...
    mov     eax, [ebx+4]
    mov     ecx, [esp+1Ch+var_C]
    mov     esi, ebp
    mov     ebp, 1
    cmp     ecx, [eax+4]
    jz      loc_4DD6E2

    loc_4DD4F1:                             ; CODE XREF: sub_4DD430+2ACj
    mov     eax, [esi+4]
    xor     edi, edi
    cmp     [eax+3Ch], edi
    jnz     loc_4DD6E2
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     loc_4DD600
    mov     ecx, [edx+8]
    cmp     [ecx+3Ch], edi
    jnz     short loc_4DD52E
    mov     [eax+3Ch], ebp
    mov     [ecx+3Ch], ebp
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+3Ch], edi
    mov     ecx, [esi+4]
    mov     esi, [ecx+4]
    jmp     loc_4DD6D6
    ; ---------------------------------------------------------------------------

    loc_4DD52E:                             ; CODE XREF: sub_4DD430+E2j
    cmp     esi, [eax+8]
    jnz     short loc_4DD582
    lea     ecx, [esp+1Ch+arg_8]
    mov     esi, eax
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     edx, [eax]
    mov     [esi+8], edx
    mov     ecx, [eax]
    cmp     ecx, dword_528A50
    jz      short loc_4DD553
    mov     [ecx+4], esi

    loc_4DD553:                             ; CODE XREF: sub_4DD430+11Ej
    mov     ecx, [esi+4]
    mov     [eax+4], ecx
    mov     ecx, [ebx+4]
    cmp     esi, [ecx+4]
    jnz     short loc_4DD566
    mov     [ecx+4], eax
    jmp     short loc_4DD574
    ; ---------------------------------------------------------------------------

    loc_4DD566:                             ; CODE XREF: sub_4DD430+12Fj
    mov     ecx, [esi+4]
    cmp     esi, [ecx]
    jnz     short loc_4DD571
    mov     [ecx], eax
    jmp     short loc_4DD574
    ; ---------------------------------------------------------------------------

    loc_4DD571:                             ; CODE XREF: sub_4DD430+13Bj
    mov     [ecx+8], eax

    loc_4DD574:                             ; CODE XREF: sub_4DD430+134j
                                            ; sub_4DD430+13Fj
    mov     [eax], esi
    lea     ecx, [esp+1Ch+arg_8]
    mov     [esi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4DD582:                             ; CODE XREF: sub_4DD430+101j
    mov     edx, [esi+4]
    mov     [edx+3Ch], ebp
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+3Ch], edi
    mov     edx, [esi+4]
    lea     ecx, [esp+1Ch+arg_C]
    mov     edi, [edx+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A50
    jz      short loc_4DD5B5
    mov     [ecx+4], edi

    loc_4DD5B5:                             ; CODE XREF: sub_4DD430+180j
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DD5D5
    mov     [ecx+4], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4DD6D1
    ; ---------------------------------------------------------------------------

    loc_4DD5D5:                             ; CODE XREF: sub_4DD430+191j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4DD5EF
    mov     [ecx+8], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4DD6D1
    ; ---------------------------------------------------------------------------

    loc_4DD5EF:                             ; CODE XREF: sub_4DD430+1ABj
    mov     [ecx], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4DD6D1
    ; ---------------------------------------------------------------------------

    loc_4DD600:                             ; CODE XREF: sub_4DD430+D6j
    cmp     [ecx+3Ch], edi
    jnz     short loc_4DD61F
    mov     [eax+3Ch], ebp
    mov     [ecx+3Ch], ebp
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+3Ch], edi
    mov     edx, [esi+4]
    mov     esi, [edx+4]
    jmp     loc_4DD6D6
    ; ---------------------------------------------------------------------------

    loc_4DD61F:                             ; CODE XREF: sub_4DD430+1D3j
    cmp     esi, [eax]
    jnz     short loc_4DD674
    lea     ecx, [esp+1Ch+arg_4]
    mov     esi, eax
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, [eax+8]
    mov     [esi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_528A50
    jz      short loc_4DD643
    mov     [ecx+4], esi

    loc_4DD643:                             ; CODE XREF: sub_4DD430+20Ej
    mov     edx, [esi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     esi, [ecx+4]
    jnz     short loc_4DD656
    mov     [ecx+4], eax
    jmp     short loc_4DD665
    ; ---------------------------------------------------------------------------

    loc_4DD656:                             ; CODE XREF: sub_4DD430+21Fj
    mov     ecx, [esi+4]
    cmp     esi, [ecx+8]
    jnz     short loc_4DD663
    mov     [ecx+8], eax
    jmp     short loc_4DD665
    ; ---------------------------------------------------------------------------

    loc_4DD663:                             ; CODE XREF: sub_4DD430+22Cj
    mov     [ecx], eax

    loc_4DD665:                             ; CODE XREF: sub_4DD430+224j
                                            ; sub_4DD430+231j
    mov     [eax+8], esi
    lea     ecx, [esp+1Ch+arg_4]
    mov     [esi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4DD674:                             ; CODE XREF: sub_4DD430+1F1j
    mov     eax, [esi+4]
    mov     [eax+3Ch], ebp
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+var_8]
    mov     [edx+3Ch], edi
    mov     eax, [esi+4]
    mov     edi, [eax+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_528A50
    jz      short loc_4DD6A7
    mov     [ecx+4], edi

    loc_4DD6A7:                             ; CODE XREF: sub_4DD430+272j
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4DD6BA
    mov     [ecx+4], eax
    jmp     short loc_4DD6C8
    ; ---------------------------------------------------------------------------

    loc_4DD6BA:                             ; CODE XREF: sub_4DD430+283j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4DD6C5
    mov     [ecx], eax
    jmp     short loc_4DD6C8
    ; ---------------------------------------------------------------------------

    loc_4DD6C5:                             ; CODE XREF: sub_4DD430+28Fj
    mov     [ecx+8], eax

    loc_4DD6C8:                             ; CODE XREF: sub_4DD430+288j
                                            ; sub_4DD430+293j
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+var_8]

    loc_4DD6D1:                             ; CODE XREF: sub_4DD430+1A0j
                                            ; sub_4DD430+1BAj ...
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4DD6D6:                             ; CODE XREF: sub_4DD430+F9j
                                            ; sub_4DD430+1EAj
    mov     eax, [ebx+4]
    cmp     esi, [eax+4]
    jnz     loc_4DD4F1

    loc_4DD6E2:                             ; CODE XREF: sub_4DD430+BBj
                                            ; sub_4DD430+C9j
    mov     ecx, [ebx+4]
    mov     esi, [esp+1Ch+arg_0]
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+var_4]
    mov     [edx+3Ch], ebp
    mov     [esi], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    10h
    sub_4DD430 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD710 proc near                    ; CODE XREF: sub_4DC680+154p
                                            ; sub_4DC680+1C7p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx+8]
    mov     edx, [eax]
    mov     [ecx+8], edx
    mov     edx, [eax]
    cmp     edx, dword_528A50
    jz      short loc_4DD736
    mov     [edx+4], ecx

    loc_4DD736:                             ; CODE XREF: sub_4DD710+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_4DD749
    mov     [edx+4], eax
    jmp     short loc_4DD757
    ; ---------------------------------------------------------------------------

    loc_4DD749:                             ; CODE XREF: sub_4DD710+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx]
    jnz     short loc_4DD754
    mov     [edx], eax
    jmp     short loc_4DD757
    ; ---------------------------------------------------------------------------

    loc_4DD754:                             ; CODE XREF: sub_4DD710+3Ej
    mov     [edx+8], eax

    loc_4DD757:                             ; CODE XREF: sub_4DD710+37j
                                            ; sub_4DD710+42j
    mov     [eax], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     esi
    pop     ecx
    retn    4
    sub_4DD710 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD770 proc near                    ; CODE XREF: sub_4DC680+175p
                                            ; sub_4DC680+1A6p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx]
    mov     edx, [eax+8]
    mov     [ecx], edx
    mov     edx, [eax+8]
    cmp     edx, dword_528A50
    jz      short loc_4DD796
    mov     [edx+4], ecx

    loc_4DD796:                             ; CODE XREF: sub_4DD770+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_4DD7A9
    mov     [edx+4], eax
    jmp     short loc_4DD7B8
    ; ---------------------------------------------------------------------------

    loc_4DD7A9:                             ; CODE XREF: sub_4DD770+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx+8]
    jnz     short loc_4DD7B6
    mov     [edx+8], eax
    jmp     short loc_4DD7B8
    ; ---------------------------------------------------------------------------

    loc_4DD7B6:                             ; CODE XREF: sub_4DD770+3Fj
    mov     [edx], eax

    loc_4DD7B8:                             ; CODE XREF: sub_4DD770+37j
                                            ; sub_4DD770+44j
    mov     [eax+8], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     esi
    pop     ecx
    retn    4
    sub_4DD770 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD7D0 proc near                    ; CODE XREF: sub_4DAA30+36p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esi+4]
    mov     esi, ecx
    mov     eax, [ecx+4]
    mov     ecx, dword_528A50
    cmp     eax, ecx
    jz      short loc_4DD80F
    mov     edx, [esp+8+arg_0]
    push    edi
    mov     edi, [edx]

    loc_4DD7F6:                             ; CODE XREF: sub_4DD7D0+3Cj
    cmp     edi, [eax+0Ch]
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_4DD807
    mov     esi, eax
    mov     eax, [eax]
    jmp     short loc_4DD80A
    ; ---------------------------------------------------------------------------

    loc_4DD807:                             ; CODE XREF: sub_4DD7D0+2Fj
    mov     eax, [eax+8]

    loc_4DD80A:                             ; CODE XREF: sub_4DD7D0+35j
    cmp     eax, ecx
    jnz     short loc_4DD7F6
    pop     edi

    loc_4DD80F:                             ; CODE XREF: sub_4DD7D0+1Dj
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_4DD7D0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD820 proc near                    ; CODE XREF: sub_4DAA30+B1p
                                            ; sub_4DC680+230p

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+3Ch]
    test    ecx, ecx
    jnz     short loc_4DD855
    mov     ecx, [eax+4]
    cmp     [ecx+4], eax
    jnz     short loc_4DD855
    mov     edx, [eax+8]
    lea     ecx, [esp+10h+var_4]
    mov     [edi], edx
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4DD855:                             ; CODE XREF: sub_4DD820+17j
                                            ; sub_4DD820+1Fj
    mov     esi, [eax]
    mov     ecx, dword_528A50
    cmp     esi, ecx
    jz      short loc_4DD89A
    lea     ecx, [esp+10h+var_8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     ecx, dword_528A50
    cmp     eax, ecx
    jz      short loc_4DD880

    loc_4DD877:                             ; CODE XREF: sub_4DD820+5Ej
    mov     esi, eax
    mov     eax, [esi+8]
    cmp     eax, ecx
    jnz     short loc_4DD877

    loc_4DD880:                             ; CODE XREF: sub_4DD820+55j
    lea     ecx, [esp+10h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4DD89A:                             ; CODE XREF: sub_4DD820+3Fj
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax]
    jnz     short loc_4DD8AE

    loc_4DD8A3:                             ; CODE XREF: sub_4DD820+8Cj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax]
    jz      short loc_4DD8A3

    loc_4DD8AE:                             ; CODE XREF: sub_4DD820+81j
    lea     ecx, [esp+10h+var_4]
    mov     [edi], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4DD820 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DD8C0 proc near                    ; CODE XREF: sub_4DB7D0+D2p

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 0Ch
    push    ebx
    push    ebp
    push    esi
    mov     esi, ecx
    mov     eax, 2AAAAAABh
    push    edi
    mov     ebx, [esi+8]
    mov     ecx, [esi+0Ch]
    sub     ecx, ebx
    mov     edi, [esp+1Ch+arg_4]
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    mov     [esp+1Ch+var_C], esi
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, edi
    jnb     loc_4DDA80
    mov     esi, [esi+4]
    test    esi, esi
    jnz     short loc_4DD8FD
    xor     edx, edx
    jmp     short loc_4DD912
    ; ---------------------------------------------------------------------------

    loc_4DD8FD:                             ; CODE XREF: sub_4DD8C0+37j
    mov     ecx, ebx
    mov     eax, 2AAAAAABh
    sub     ecx, esi
    imul    ecx
    sar     edx, 3
    mov     ecx, edx
    shr     ecx, 1Fh
    add     edx, ecx

    loc_4DD912:                             ; CODE XREF: sub_4DD8C0+3Bj
    cmp     edi, edx
    jnb     short loc_4DD937
    test    esi, esi
    jnz     short loc_4DD91E
    xor     ecx, ecx
    jmp     short loc_4DD939
    ; ---------------------------------------------------------------------------

    loc_4DD91E:                             ; CODE XREF: sub_4DD8C0+58j
    mov     ecx, ebx
    mov     eax, 2AAAAAABh
    sub     ecx, esi
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     ecx, edx
    jmp     short loc_4DD939
    ; ---------------------------------------------------------------------------

    loc_4DD937:                             ; CODE XREF: sub_4DD8C0+54j
    mov     ecx, edi

    loc_4DD939:                             ; CODE XREF: sub_4DD8C0+5Cj
                                            ; sub_4DD8C0+75j
    test    esi, esi
    jnz     short loc_4DD941
    xor     edx, edx
    jmp     short loc_4DD954
    ; ---------------------------------------------------------------------------

    loc_4DD941:                             ; CODE XREF: sub_4DD8C0+7Bj
    sub     ebx, esi
    mov     eax, 2AAAAAABh
    imul    ebx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4DD954:                             ; CODE XREF: sub_4DD8C0+7Fj
    mov     esi, ds:GlobalAlloc
    lea     eax, [edx+ecx]
    lea     ebp, [eax+eax*2]
    shl     ebp, 4
    mov     [esp+1Ch+var_4], ebp

    loc_4DD967:                             ; CODE XREF: sub_4DD8C0+CCj
    push    ebp                             ; dwBytes
    push    0                               ; uFlags
    call    esi ; GlobalAlloc
    mov     ebx, eax
    test    ebx, ebx
    mov     [esp+1Ch+var_8], ebx
    jnz     short loc_4DD98E
    mov     eax, dword_5289BC
    test    eax, eax
    jz      short loc_4DD981
    call    eax

    loc_4DD981:                             ; CODE XREF: sub_4DD8C0+BDj
    test    ebx, ebx
    jnz     short loc_4DD98E
    mov     eax, dword_5289BC
    test    eax, eax
    jnz     short loc_4DD967

    loc_4DD98E:                             ; CODE XREF: sub_4DD8C0+B4j
                                            ; sub_4DD8C0+C3j
    mov     ecx, [esp+1Ch+var_C]
    mov     esi, [esp+1Ch+arg_0]
    mov     eax, [ecx+4]
    cmp     eax, esi
    jz      short loc_4DD9BE

    loc_4DD99D:                             ; CODE XREF: sub_4DD8C0+F8j
    test    ebx, ebx
    jz      short loc_4DD9AC
    mov     ecx, 0Ch
    mov     esi, eax
    mov     edi, ebx
    rep movsd

    loc_4DD9AC:                             ; CODE XREF: sub_4DD8C0+DFj
    mov     esi, [esp+1Ch+arg_0]
    add     eax, 30h
    add     ebx, 30h
    cmp     eax, esi
    jnz     short loc_4DD99D
    mov     edi, [esp+1Ch+arg_4]

    loc_4DD9BE:                             ; CODE XREF: sub_4DD8C0+DBj
    test    edi, edi
    mov     eax, ebx
    jbe     short loc_4DD9E7
    mov     ebp, [esp+1Ch+arg_8]
    mov     edx, edi

    loc_4DD9CA:                             ; CODE XREF: sub_4DD8C0+11Dj
    test    eax, eax
    jz      short loc_4DD9D9
    mov     ecx, 0Ch
    mov     esi, ebp
    mov     edi, eax
    rep movsd

    loc_4DD9D9:                             ; CODE XREF: sub_4DD8C0+10Cj
    add     eax, 30h
    dec     edx
    jnz     short loc_4DD9CA
    mov     esi, [esp+1Ch+arg_0]
    mov     edi, [esp+1Ch+arg_4]

    loc_4DD9E7:                             ; CODE XREF: sub_4DD8C0+102j
    mov     eax, [esp+1Ch+var_C]
    lea     ecx, [edi+edi*2]
    shl     ecx, 4
    mov     ebp, [eax+8]
    cmp     esi, ebp
    lea     edx, [ebx+ecx]
    jz      short loc_4DDA20
    mov     eax, edx
    sub     eax, ebx
    add     eax, esi
    sub     eax, ecx

    loc_4DDA03:                             ; CODE XREF: sub_4DD8C0+15Aj
    test    edx, edx
    jz      short loc_4DDA12
    mov     ecx, 0Ch
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_4DDA12:                             ; CODE XREF: sub_4DD8C0+145j
    add     eax, 30h
    add     edx, 30h
    cmp     eax, ebp
    jnz     short loc_4DDA03
    mov     edi, [esp+1Ch+arg_4]

    loc_4DDA20:                             ; CODE XREF: sub_4DD8C0+139j
    mov     esi, [esp+1Ch+var_C]
    mov     eax, [esi+4]
    test    eax, eax
    mov     [esp+1Ch+arg_4], eax
    jz      short loc_4DDA36
    push    eax                             ; hMem
    call    ds:GlobalFree

    loc_4DDA36:                             ; CODE XREF: sub_4DD8C0+16Dj
    mov     ebx, [esp+1Ch+var_8]
    mov     ecx, [esp+1Ch+var_4]
    mov     eax, [esi+4]
    lea     edx, [ebx+ecx]
    test    eax, eax
    mov     [esi+0Ch], edx
    jnz     short loc_4DDA4F
    xor     edx, edx
    jmp     short loc_4DDA65
    ; ---------------------------------------------------------------------------

    loc_4DDA4F:                             ; CODE XREF: sub_4DD8C0+189j
    mov     ecx, [esi+8]
    sub     ecx, eax
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax

    loc_4DDA65:                             ; CODE XREF: sub_4DD8C0+18Dj
    lea     eax, [edi+edx]
    mov     [esi+4], ebx
    lea     ecx, [eax+eax*2]
    shl     ecx, 4
    add     ecx, ebx
    mov     [esi+8], ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DDA80:                             ; CODE XREF: sub_4DD8C0+2Cj
    mov     ebp, [esp+1Ch+arg_0]
    mov     ecx, ebx
    sub     ecx, ebp
    mov     eax, 2AAAAAABh
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    cmp     edx, edi
    jnb     loc_4DDB3B
    lea     ecx, [edi+edi*2]
    shl     ecx, 4
    cmp     ebp, ebx
    mov     [esp+1Ch+arg_0], ecx
    lea     edx, [ebp+ecx+0]
    jz      short loc_4DDAD4
    mov     eax, edx
    sub     eax, ecx

    loc_4DDAB7:                             ; CODE XREF: sub_4DD8C0+20Ej
    test    edx, edx
    jz      short loc_4DDAC6
    mov     ecx, 0Ch
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_4DDAC6:                             ; CODE XREF: sub_4DD8C0+1F9j
    add     eax, 30h
    add     edx, 30h
    cmp     eax, ebx
    jnz     short loc_4DDAB7
    mov     edi, [esp+1Ch+arg_4]

    loc_4DDAD4:                             ; CODE XREF: sub_4DD8C0+1F1j
    mov     ecx, [esp+1Ch+var_C]
    mov     eax, 2AAAAAABh
    mov     ebx, [esp+1Ch+arg_8]
    mov     esi, [ecx+8]
    mov     ecx, esi
    sub     ecx, ebp
    imul    ecx
    sar     edx, 3
    mov     eax, edx
    shr     eax, 1Fh
    add     edx, eax
    mov     eax, esi
    sub     edi, edx
    mov     ecx, edi
    jz      short loc_4DDB13
    mov     edx, ecx

    loc_4DDAFE:                             ; CODE XREF: sub_4DD8C0+251j
    test    eax, eax
    jz      short loc_4DDB0D
    mov     ecx, 0Ch
    mov     esi, ebx
    mov     edi, eax
    rep movsd

    loc_4DDB0D:                             ; CODE XREF: sub_4DD8C0+240j
    add     eax, 30h
    dec     edx
    jnz     short loc_4DDAFE

    loc_4DDB13:                             ; CODE XREF: sub_4DD8C0+23Aj
    mov     ecx, [esp+1Ch+var_C]
    mov     eax, ebp
    mov     edx, [ecx+8]
    cmp     ebp, edx
    jz      loc_4DDBBC

    loc_4DDB24:                             ; CODE XREF: sub_4DD8C0+274j
    mov     edi, eax
    add     eax, 30h
    mov     ecx, 0Ch
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_4DDB24
    jmp     loc_4DDBBC
    ; ---------------------------------------------------------------------------

    loc_4DDB3B:                             ; CODE XREF: sub_4DD8C0+1DBj
    test    edi, edi
    jbe     loc_4DDBC7
    lea     ecx, [edi+edi*2]
    mov     eax, ebx
    shl     ecx, 4
    sub     eax, ecx
    mov     edx, ebx
    cmp     eax, ebx
    mov     [esp+1Ch+arg_0], ecx
    jz      short loc_4DDB74

    loc_4DDB57:                             ; CODE XREF: sub_4DD8C0+2AEj
    test    edx, edx
    jz      short loc_4DDB66
    mov     ecx, 0Ch
    mov     esi, eax
    mov     edi, edx
    rep movsd

    loc_4DDB66:                             ; CODE XREF: sub_4DD8C0+299j
    add     eax, 30h
    add     edx, 30h
    cmp     eax, ebx
    jnz     short loc_4DDB57
    mov     ecx, [esp+1Ch+arg_0]

    loc_4DDB74:                             ; CODE XREF: sub_4DD8C0+295j
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [eax+8]
    mov     eax, edx
    sub     eax, ecx
    cmp     ebp, eax
    jz      short loc_4DDB98

    loc_4DDB83:                             ; CODE XREF: sub_4DD8C0+2D6j
    sub     eax, 30h
    sub     edx, 30h
    mov     ecx, 0Ch
    mov     esi, eax
    mov     edi, edx
    cmp     eax, ebp
    rep movsd
    jnz     short loc_4DDB83

    loc_4DDB98:                             ; CODE XREF: sub_4DD8C0+2C1j
    mov     ecx, [esp+1Ch+arg_0]
    mov     eax, ebp
    lea     edx, [ebp+ecx+0]
    cmp     ebp, edx
    jz      short loc_4DDBBC
    mov     ebx, [esp+1Ch+arg_8]

    loc_4DDBAA:                             ; CODE XREF: sub_4DD8C0+2FAj
    mov     edi, eax
    add     eax, 30h
    mov     ecx, 0Ch
    mov     esi, ebx
    cmp     eax, edx
    rep movsd
    jnz     short loc_4DDBAA

    loc_4DDBBC:                             ; CODE XREF: sub_4DD8C0+25Ej
                                            ; sub_4DD8C0+276j ...
    mov     eax, [esp+1Ch+var_C]
    mov     edx, [esp+1Ch+arg_0]
    add     [eax+8], edx

    loc_4DDBC7:                             ; CODE XREF: sub_4DD8C0+27Dj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    0Ch
    sub_4DD8C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DDBE0 proc near                    ; CODE XREF: sub_4DB000+1A8p
                                            ; sub_4DBBC0+117p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     edx, [ecx]
    mov     ecx, [esp+arg_4]
    mov     [eax], edx
    mov     dl, [ecx]
    mov     [eax+4], dl
    retn    8
    sub_4DDBE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DDC00 proc near                    ; CODE XREF: sub_4DBEC0+67p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, dword_528A10
    push    esi
    test    eax, eax
    push    edi
    jnz     short loc_4DDC6A
    mov     edi, ds:GlobalAlloc

    loc_4DDC11:                             ; CODE XREF: sub_4DDC00+36j
    push    2000h                           ; dwBytes
    push    0                               ; uFlags
    call    edi ; GlobalAlloc
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4DDC51
    mov     eax, dword_5289BC
    test    eax, eax
    jz      short loc_4DDC2B
    call    eax

    loc_4DDC2B:                             ; CODE XREF: sub_4DDC00+27j
    test    esi, esi
    jnz     short loc_4DDC51
    mov     eax, dword_5289BC
    test    eax, eax
    jnz     short loc_4DDC11
    test    esi, esi
    jnz     short loc_4DDC51
    mov     edx, [esp+8+arg_0]
    mov     ecx, [esp+8+arg_4]
    xor     eax, eax
    mov     [eax+4], edx
    mov     [eax+14h], ecx
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DDC51:                             ; CODE XREF: sub_4DDC00+1Ej
                                            ; sub_4DDC00+2Dj ...
    mov     eax, dword_528A10
    mov     ecx, 155h

    loc_4DDC5B:                             ; CODE XREF: sub_4DDC00+63j
    mov     [esi], eax
    mov     eax, esi
    add     esi, 18h
    dec     ecx
    jnz     short loc_4DDC5B
    mov     dword_528A10, eax

    loc_4DDC6A:                             ; CODE XREF: sub_4DDC00+9j
    mov     ecx, [eax]
    mov     edx, [esp+8+arg_0]
    mov     dword_528A10, ecx
    mov     ecx, [esp+8+arg_4]
    pop     edi
    mov     [eax+4], edx
    mov     [eax+14h], ecx
    pop     esi
    retn    8
    sub_4DDC00 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DDC90 proc near                    ; CODE XREF: sub_4DCE00+Ap

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esi+4]
    mov     esi, ecx
    mov     eax, [ecx+4]
    mov     ecx, dword_528A50
    cmp     eax, ecx
    jz      short loc_4DDCCF
    mov     edx, [esp+8+arg_0]
    push    edi
    mov     edi, [edx]

    loc_4DDCB6:                             ; CODE XREF: sub_4DDC90+3Cj
    cmp     [eax+0Ch], edi
    sbb     edx, edx
    neg     edx
    test    dl, dl
    jz      short loc_4DDCC6
    mov     eax, [eax+8]
    jmp     short loc_4DDCCA
    ; ---------------------------------------------------------------------------

    loc_4DDCC6:                             ; CODE XREF: sub_4DDC90+2Fj
    mov     esi, eax
    mov     eax, [eax]

    loc_4DDCCA:                             ; CODE XREF: sub_4DDC90+34j
    cmp     eax, ecx
    jnz     short loc_4DDCB6
    pop     edi

    loc_4DDCCF:                             ; CODE XREF: sub_4DDC90+1Dj
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     esi
    pop     ecx
    retn    4
    sub_4DDC90 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DDCE0 proc near                    ; CODE XREF: sub_4DC680+76p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, dword_5289E0
    push    esi
    test    eax, eax
    push    edi
    jnz     short loc_4DDD4A
    mov     edi, ds:GlobalAlloc

    loc_4DDCF1:                             ; CODE XREF: sub_4DDCE0+36j
    push    2000h                           ; dwBytes
    push    0                               ; uFlags
    call    edi ; GlobalAlloc
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4DDD31
    mov     eax, dword_5289BC
    test    eax, eax
    jz      short loc_4DDD0B
    call    eax

    loc_4DDD0B:                             ; CODE XREF: sub_4DDCE0+27j
    test    esi, esi
    jnz     short loc_4DDD31
    mov     eax, dword_5289BC
    test    eax, eax
    jnz     short loc_4DDCF1
    test    esi, esi
    jnz     short loc_4DDD31
    mov     edx, [esp+8+arg_0]
    mov     ecx, [esp+8+arg_4]
    xor     eax, eax
    mov     [eax+4], edx
    mov     [eax+3Ch], ecx
    pop     edi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4DDD31:                             ; CODE XREF: sub_4DDCE0+1Ej
                                            ; sub_4DDCE0+2Dj ...
    mov     eax, dword_5289E0
    mov     ecx, 80h

    loc_4DDD3B:                             ; CODE XREF: sub_4DDCE0+63j
    mov     [esi], eax
    mov     eax, esi
    add     esi, 40h
    dec     ecx
    jnz     short loc_4DDD3B
    mov     dword_5289E0, eax

    loc_4DDD4A:                             ; CODE XREF: sub_4DDCE0+9j
    mov     ecx, [eax]
    mov     edx, [esp+8+arg_0]
    mov     dword_5289E0, ecx
    mov     ecx, [esp+8+arg_4]
    pop     edi
    mov     [eax+4], edx
    mov     [eax+3Ch], ecx
    pop     esi
    retn    8
    sub_4DDCE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DDD70 proc near                    ; CODE XREF: sub_4DB610+4Fp
                                            ; sub_4DB610+85p ...

    arg_0= dword ptr  4

    mov     ecx, dword_528A10
    push    ebx
    push    esi
    push    edi
    test    ecx, ecx
    jnz     short loc_4DDDDE
    mov     ebx, ds:GlobalAlloc
    mov     edi, 2000h

    loc_4DDD88:                             ; CODE XREF: sub_4DDD70+3Dj
    push    2000h                           ; dwBytes
    push    0                               ; uFlags
    call    ebx ; GlobalAlloc
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4DDDBB
    mov     eax, dword_5289BC
    test    eax, eax
    jz      short loc_4DDDA2
    call    eax

    loc_4DDDA2:                             ; CODE XREF: sub_4DDD70+2Ej
    test    esi, esi
    jnz     short loc_4DDDBB
    mov     eax, dword_5289BC
    test    eax, eax
    jnz     short loc_4DDD88
    test    esi, esi
    jnz     short loc_4DDDBB
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4DDDBB:                             ; CODE XREF: sub_4DDD70+25j
                                            ; sub_4DDD70+34j ...
    mov     eax, [esp+0Ch+arg_0]
    mov     ecx, dword_528A10
    cmp     eax, 2000h
    ja      short loc_4DDDDE

    loc_4DDDCC:                             ; CODE XREF: sub_4DDD70+66j
    mov     [esi], ecx
    mov     ecx, esi
    sub     edi, eax
    add     esi, eax
    cmp     edi, eax
    jnb     short loc_4DDDCC
    mov     dword_528A10, ecx

    loc_4DDDDE:                             ; CODE XREF: sub_4DDD70+Bj
                                            ; sub_4DDD70+5Aj
    mov     eax, ecx
    mov     ecx, [ecx]
    pop     edi
    pop     esi
    mov     dword_528A10, ecx
    pop     ebx
    retn    4
    sub_4DDD70 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DDDF0 proc near                    ; CODE XREF: sub_4DA8D0+50p
                                            ; sub_4DD430+16p

    arg_0= dword ptr  4

    mov     ecx, dword_5289E0
    push    ebx
    push    esi
    push    edi
    test    ecx, ecx
    jnz     short loc_4DDE5E
    mov     ebx, ds:GlobalAlloc
    mov     edi, 2000h

    loc_4DDE08:                             ; CODE XREF: sub_4DDDF0+3Dj
    push    2000h                           ; dwBytes
    push    0                               ; uFlags
    call    ebx ; GlobalAlloc
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4DDE3B
    mov     eax, dword_5289BC
    test    eax, eax
    jz      short loc_4DDE22
    call    eax

    loc_4DDE22:                             ; CODE XREF: sub_4DDDF0+2Ej
    test    esi, esi
    jnz     short loc_4DDE3B
    mov     eax, dword_5289BC
    test    eax, eax
    jnz     short loc_4DDE08
    test    esi, esi
    jnz     short loc_4DDE3B
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4DDE3B:                             ; CODE XREF: sub_4DDDF0+25j
                                            ; sub_4DDDF0+34j ...
    mov     eax, [esp+0Ch+arg_0]
    mov     ecx, dword_5289E0
    cmp     eax, 2000h
    ja      short loc_4DDE5E

    loc_4DDE4C:                             ; CODE XREF: sub_4DDDF0+66j
    mov     [esi], ecx
    mov     ecx, esi
    sub     edi, eax
    add     esi, eax
    cmp     edi, eax
    jnb     short loc_4DDE4C
    mov     dword_5289E0, ecx

    loc_4DDE5E:                             ; CODE XREF: sub_4DDDF0+Bj
                                            ; sub_4DDDF0+5Aj
    mov     eax, ecx
    mov     ecx, [ecx]
    pop     edi
    pop     esi
    mov     dword_5289E0, ecx
    pop     ebx
    retn    4
    sub_4DDDF0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DDE70 proc near                    ; CODE XREF: sub_4DC910+13p

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, dword_528A50
    mov     esi, [eax+8]
    cmp     esi, ecx
    jz      short loc_4DDEC6
    lea     ecx, [esp+10h+var_8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_528A50
    cmp     eax, ecx
    jz      short loc_4DDEAC

    loc_4DDEA4:                             ; CODE XREF: sub_4DDE70+3Aj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4DDEA4

    loc_4DDEAC:                             ; CODE XREF: sub_4DDE70+32j
    lea     ecx, [esp+10h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4DDEC6:                             ; CODE XREF: sub_4DDE70+1Dj
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax+8]
    jnz     short loc_4DDEDC

    loc_4DDED0:                             ; CODE XREF: sub_4DDE70+6Aj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax+8]
    jz      short loc_4DDED0

    loc_4DDEDC:                             ; CODE XREF: sub_4DDE70+5Ej
    mov     ecx, [edi]
    cmp     [ecx+8], eax
    jz      short loc_4DDEE5
    mov     [edi], eax

    loc_4DDEE5:                             ; CODE XREF: sub_4DDE70+71j
    lea     ecx, [esp+10h+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4DDE70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4DDF00(HMODULE hModule)
    sub_4DDF00 proc near                    ; CODE XREF: .text:004DE0C2p

    FileName= byte ptr -3E8h
    var_1= byte ptr -1
    hModule= dword ptr  4

    sub     esp, 3E8h
    push    esi
    mov     esi, ecx
    push    0                               ; lpFileName
    call    sub_4E1560
    mov     eax, [esp+3ECh+hModule]
    lea     ecx, [esp+3ECh+FileName]
    push    3E8h                            ; nSize
    push    ecx                             ; lpFilename
    push    eax                             ; hModule
    mov     [esi+14h], eax
    mov     [esi+18h], eax
    mov     [esi+1Ch], eax
    call    ds:GetModuleFileNameA
    test    eax, eax
    jz      short loc_4DDF3F
    mov     [esp+3ECh+var_1], 0
    jmp     short loc_4DDF44
    ; ---------------------------------------------------------------------------

    loc_4DDF3F:                             ; CODE XREF: sub_4DDF00+33j
    mov     [esp+3ECh+FileName], 0

    loc_4DDF44:                             ; CODE XREF: sub_4DDF00+3Dj
    lea     edx, [esp+3ECh+FileName]
    mov     ecx, esi
    push    edx                             ; lpFileName
    call    sub_4E1590
    mov     eax, [esi+1Ch]
    mov     ecx, [eax+3Ch]
    add     eax, ecx
    mov     [esi+20h], eax
    mov     ecx, [eax+0ACh]
    mov     eax, 24924925h
    mul     ecx
    sub     ecx, edx
    mov     dword ptr [esi+24h], 0
    shr     ecx, 1
    add     ecx, edx
    shr     ecx, 4
    mov     eax, ecx
    mov     [esi+28h], ecx
    test    eax, eax
    jz      short loc_4DDF92
    mov     edx, [esi+20h]
    mov     eax, [esi+18h]
    mov     ecx, [edx+0A8h]
    add     ecx, eax
    mov     [esi+24h], ecx

    loc_4DDF92:                             ; CODE XREF: sub_4DDF00+7Fj
    mov     eax, esi
    pop     esi
    add     esp, 3E8h
    retn    4
    sub_4DDF00 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DDFA0 proc near                    ; CODE XREF: sub_4DE020+5p
    push    esi
    push    edi
    mov     edi, [ecx+24h]
    test    edi, edi
    jz      short loc_4DDFDA
    mov     esi, [ecx+28h]
    xor     eax, eax
    test    esi, esi
    jle     short loc_4DDFDA
    lea     edx, [edi+0Ch]

    loc_4DDFB5:                             ; CODE XREF: sub_4DDFA0+20j
    cmp     dword ptr [edx], 3
    jz      short loc_4DDFC7
    inc     eax
    add     edx, 1Ch
    cmp     eax, esi
    jl      short loc_4DDFB5
    xor     eax, eax
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4DDFC7:                             ; CODE XREF: sub_4DDFA0+18j
    mov     edx, eax
    shl     edx, 3
    sub     edx, eax
    mov     eax, [edi+edx*4+18h]
    mov     edx, [ecx+8]
    add     eax, edx
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4DDFDA:                             ; CODE XREF: sub_4DDFA0+7j
                                            ; sub_4DDFA0+10j
    pop     edi
    pop     esi
    xor     eax, eax
    retn
    sub_4DDFA0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DDFE0 proc near                    ; CODE XREF: sub_4DE020+12p
    push    esi
    mov     esi, [ecx+24h]
    test    esi, esi
    jz      short loc_4DE015
    mov     edx, [ecx+28h]
    xor     eax, eax
    test    edx, edx
    jle     short loc_4DE015
    lea     ecx, [esi+0Ch]

    loc_4DDFF4:                             ; CODE XREF: sub_4DDFE0+1Fj
    cmp     dword ptr [ecx], 3
    jz      short loc_4DE005
    inc     eax
    add     ecx, 1Ch
    cmp     eax, edx
    jl      short loc_4DDFF4
    xor     eax, eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE005:                             ; CODE XREF: sub_4DDFE0+17j
    mov     ecx, eax
    shl     ecx, 3
    sub     ecx, eax
    mov     eax, [esi+ecx*4+10h]
    shr     eax, 4
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE015:                             ; CODE XREF: sub_4DDFE0+6j
                                            ; sub_4DDFE0+Fj
    xor     eax, eax
    pop     esi
    retn
    sub_4DDFE0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DE020 proc near                    ; CODE XREF: .text:004DE0DEp

    arg_0= dword ptr  10h

    push    ebx
    push    esi
    push    edi
    mov     ebx, ecx
    call    sub_4DDFA0
    mov     esi, eax
    test    esi, esi
    jz      short loc_4DE095
    mov     ecx, ebx
    call    sub_4DDFE0
    test    eax, eax
    jz      short loc_4DE095
    mov     edi, [esp+arg_0]
    mov     ecx, eax
    cdq
    sub     eax, edx
    mov     edx, [ebx+18h]
    sar     eax, 1
    shl     ecx, 4
    shl     eax, 4
    sub     edi, edx
    add     ecx, esi
    lea     edx, [esi+10h]
    add     eax, esi
    cmp     edx, ecx
    jz      short loc_4DE07E

    loc_4DE05C:                             ; CODE XREF: sub_4DE020+5Cj
    cmp     edi, [eax]
    jnb     short loc_4DE064
    mov     ecx, eax
    jmp     short loc_4DE066
    ; ---------------------------------------------------------------------------

    loc_4DE064:                             ; CODE XREF: sub_4DE020+3Ej
    mov     esi, eax

    loc_4DE066:                             ; CODE XREF: sub_4DE020+42j
    mov     eax, ecx
    sub     eax, esi
    sar     eax, 4
    cdq
    sub     eax, edx
    lea     edx, [esi+10h]
    sar     eax, 1
    shl     eax, 4
    add     eax, esi
    cmp     edx, ecx
    jnz     short loc_4DE05C

    loc_4DE07E:                             ; CODE XREF: sub_4DE020+3Aj
    mov     eax, [esi]
    cmp     edi, eax
    jb      short loc_4DE095
    mov     ecx, [esi+4]
    add     ecx, eax
    cmp     edi, ecx
    jnb     short loc_4DE095
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4DE095:                             ; CODE XREF: sub_4DE020+Ej
                                            ; sub_4DE020+19j ...
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    4
    sub_4DE020 endp

    ; ---------------------------------------------------------------------------
    align 4

    loc_4DE0A0:                             ; DATA XREF: sub_4DE180+2DBo
    mov     cl, byte_528A70
    mov     al, 1
    test    al, cl
    jnz     short loc_4DE0D4
    or      cl, al
    push    0
    mov     byte_528A70, cl
    call    ds:GetModuleHandleA
    push    eax
    mov     ecx, offset dword_528A78
    call    sub_4DDF00
    push    offset unknown_libname_60
    call    _atexit
    add     esp, 4

    loc_4DE0D4:                             ; CODE XREF: .text:004DE0AAj
    mov     eax, [esp+8]
    mov     ecx, offset dword_528A78
    push    eax
    call    sub_4DE020
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_60:                     ; DATA XREF: .text:004DE0C7o
    mov     ecx, offset dword_528A78
    jmp     loc_4E1650
    ; ---------------------------------------------------------------------------
    align 8

    loc_4DE100:                             ; DATA XREF: sub_4DE180+2E5o
    call    sub_4D9F50
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DE110 proc near                    ; CODE XREF: sub_4D8E60+A42p
                                            ; sub_4DE180+30Cp
    mov     eax, hLibModule
    push    ebx
    xor     ebx, ebx
    cmp     eax, ebx
    mov     byte_528AD8, bl
    jz      short loc_4DE13B
    call    ds:GetCurrentProcess
    push    eax
    call    dword_528ABC
    mov     eax, hLibModule
    push    eax                             ; hLibModule
    call    ds:FreeLibrary

    loc_4DE13B:                             ; CODE XREF: sub_4DE110+10j
    mov     hLibModule, ebx
    mov     dword_528AD0, ebx
    mov     dword_528AB8, ebx
    mov     dword_528ABC, ebx
    mov     dword_528AC0, ebx
    mov     dword_528AC4, ebx
    mov     dword_528AC8, ebx
    mov     dword_528ACC, ebx
    mov     dword_528AB4, ebx
    mov     dword_528AD4, ebx
    pop     ebx
    retn
    sub_4DE110 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DE180 proc near                    ; CODE XREF: sub_4DE4D0+49p
                                            ; sub_4DE600+2Ap

    var_4EC= dword ptr -4ECh
    var_3EC= dword ptr -3ECh
    arg_0= byte ptr  4

    mov     al, byte_528A60
    sub     esp, 4E8h
    test    al, 1
    push    ebp
    push    esi
    push    edi
    jnz     short loc_4DE1C7
    push    0                               ; int
    push    0                               ; int
    push    offset aDisableimagehl          ; int
    push    offset aEnableimagehlp          ; int
    push    1                               ; char
    or      al, 1
    push    0                               ; int
    push    offset aImagehlp                ; int
    mov     ecx, offset byte_528A68
    mov     byte_528A60, al
    call    sub_4D9FE0
    push    offset nullsub_26               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4DE1C7:                             ; CODE XREF: sub_4DE180+10j
    mov     al, [esp+4F4h+arg_0]
    test    al, al
    jnz     short loc_4DE1E7
    mov     al, byte_528A68
    test    al, al
    jnz     short loc_4DE1E7
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE1E7:                             ; CODE XREF: sub_4DE180+50j
                                            ; sub_4DE180+59j
    mov     al, byte_528AD8
    test    al, al
    jz      short loc_4DE1FF
    mov     al, byte_528ADC
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE1FF:                             ; CODE XREF: sub_4DE180+6Ej
    push    offset aImagehlp_dll            ; lpLibFileName
    mov     byte_528AD8, 1
    call    ds:LoadLibraryA
    test    eax, eax
    mov     hLibModule, eax
    jnz     short loc_4DE226
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE226:                             ; CODE XREF: sub_4DE180+98j
    mov     esi, ds:GetProcAddress
    push    offset aSymsetoptions           ; lpProcName
    push    eax                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     dword_528AD0, eax
    jnz     short loc_4DE249
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE249:                             ; CODE XREF: sub_4DE180+BBj
    mov     eax, hLibModule
    push    offset aSyminitialize           ; lpProcName
    push    eax                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     dword_528AB8, eax
    jnz     short loc_4DE26B
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE26B:                             ; CODE XREF: sub_4DE180+DDj
    mov     ecx, hLibModule
    push    offset aSymcleanup              ; lpProcName
    push    ecx                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     dword_528ABC, eax
    jnz     short loc_4DE28E
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE28E:                             ; CODE XREF: sub_4DE180+100j
    mov     edx, hLibModule
    push    offset aStackwalk               ; lpProcName
    push    edx                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     dword_528AC0, eax
    jnz     short loc_4DE2B1
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE2B1:                             ; CODE XREF: sub_4DE180+123j
    mov     eax, hLibModule
    push    offset aSymfunctiontab          ; lpProcName
    push    eax                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     dword_528AC4, eax
    jnz     short loc_4DE2D3
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE2D3:                             ; CODE XREF: sub_4DE180+145j
    mov     ecx, hLibModule
    push    offset aSymgetmoduleba          ; lpProcName
    push    ecx                             ; hModule
    call    esi ; GetProcAddress
    test    eax, eax
    mov     dword_528AC8, eax
    jnz     short loc_4DE2F6
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE2F6:                             ; CODE XREF: sub_4DE180+168j
    mov     edx, hLibModule
    push    offset aSymgetsymfroma          ; lpProcName
    push    edx                             ; hModule
    call    esi ; GetProcAddress
    mov     dword_528ACC, eax
    mov     eax, hLibModule
    push    offset aSymgetlinefrom          ; lpProcName
    push    eax                             ; hModule
    call    esi ; GetProcAddress
    mov     ecx, hLibModule
    push    offset aUndecoratesymb          ; lpProcName
    push    ecx                             ; hModule
    mov     dword_528AB4, eax
    call    esi ; GetProcAddress
    mov     ecx, dword_528AB4
    mov     dword_528AD4, eax
    test    ecx, ecx
    mov     eax, 4
    jz      short loc_4DE342
    mov     eax, 14h

    loc_4DE342:                             ; CODE XREF: sub_4DE180+1BBj
    push    eax
    call    dword_528AD0
    lea     edx, [esp+0Ch]
    xor     esi, esi
    push    100h                            ; nSize
    push    edx                             ; lpFilename
    push    esi                             ; hModule
    call    ds:GetModuleFileNameA
    test    eax, eax
    jz      loc_4DE443
    push    offset aWindir                  ; char *
    call    _getenv
    mov     edx, eax
    add     esp, 4
    test    edx, edx
    jz      loc_4DE443
    lea     edi, [esp+0Ch]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, edx
    mov     ebp, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    add     ebp, ecx
    cmp     ebp, 3E8h
    jnb     loc_4DE443
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     ebp, [esp+10Ch]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    push    5Ch                             ; int
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [esp+10h]
    push    ecx                             ; char *
    call    _strrchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4DE43C
    mov     byte ptr [eax], 0
    mov     edi, offset asc_50D370          ; ";"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+10Ch]
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    lea     edx, [esp+10Ch]
    and     ecx, 3
    rep movsb
    lea     edi, [esp+0Ch]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebp, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebp
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebp
    and     ecx, 3
    rep movsb

    loc_4DE43C:                             ; CODE XREF: sub_4DE180+258j
    lea     esi, [esp+10Ch]

    loc_4DE443:                             ; CODE XREF: sub_4DE180+1DEj
                                            ; sub_4DE180+1F5j ...
    mov     edi, ds:GetCurrentProcess
    push    1
    push    esi
    call    edi ; GetCurrentProcess
    push    eax
    call    dword_528AB8
    test    eax, eax
    jnz     short loc_4DE4A4
    push    eax
    push    esi
    mov     dword_528AC4, offset loc_4DE0A0
    mov     dword_528AC8, offset loc_4DE100
    mov     dword_528ACC, eax
    mov     dword_528AB4, eax
    call    edi ; GetCurrentProcess
    push    eax
    call    dword_528AB8
    test    eax, eax
    jnz     short loc_4DE4A4
    call    ds:GetLastError
    call    sub_4DE110
    mov     byte_528AD8, 1
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 4E8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE4A4:                             ; CODE XREF: sub_4DE180+2D7j
                                            ; sub_4DE180+304j
    pop     edi
    pop     esi
    mov     byte_528ADC, 1
    mov     al, 1
    pop     ebp
    add     esp, 4E8h
    retn
    sub_4DE180 endp ; sp = -0Ch

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_26. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DE4D0 proc near                    ; CODE XREF: sub_4DEA00+21p
    mov     al, byte_528A64
    test    al, 1
    jnz     short loc_4DE50E
    push    0                               ; int
    push    0                               ; int
    push    offset aDisableimage_0          ; int
    push    offset aEnableimageh_0          ; int
    push    1                               ; char
    or      al, 1
    push    1                               ; int
    push    offset aImagehlplines           ; int
    mov     ecx, offset byte_528A6C
    mov     byte_528A64, al
    call    sub_4D9FE0
    push    offset nullsub_55               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4DE50E:                             ; CODE XREF: sub_4DE4D0+7j
    mov     al, byte_528A6C
    test    al, al
    jz      short loc_4DE53A
    push    1
    call    sub_4DE180
    add     esp, 4
    test    al, al
    jz      short loc_4DE53A
    mov     eax, dword_528AB4
    test    eax, eax
    jnz     short loc_4DE537
    mov     eax, dword_528ACC
    test    eax, eax
    jz      short loc_4DE53A

    loc_4DE537:                             ; CODE XREF: sub_4DE4D0+5Cj
    mov     al, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE53A:                             ; CODE XREF: sub_4DE4D0+45j
                                            ; sub_4DE4D0+53j ...
    xor     al, al
    retn
    sub_4DE4D0 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_55. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DE550 proc near                    ; CODE XREF: sub_4DEA00+EAp

    var_24= dword ptr -24h
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_8= dword ptr  0Ch

    mov     eax, dword_528AB4
    sub     esp, 18h
    test    eax, eax
    push    esi
    push    edi
    jz      loc_4DE5ED
    mov     al, byte_528AAC
    test    al, 1
    jnz     short loc_4DE57D
    or      al, 1
    mov     byte_528AAC, al
    call    ds:GetCurrentProcess
    mov     dword_528AA4, eax

    loc_4DE57D:                             ; CODE XREF: sub_4DE550+19j
    xor     eax, eax
    lea     ecx, [esp+20h+var_14]
    mov     [esp+20h+var_10], eax
    lea     edx, [esp+20h+var_18]
    mov     [esp+20h+var_C], eax
    push    ecx
    mov     [esp+24h+var_8], eax
    push    edx
    mov     [esp+28h+var_4], eax
    mov     eax, [esp+28h+arg_0]
    mov     [esp+28h+var_4], eax
    push    eax
    mov     eax, dword_528AA4
    mov     [esp+2Ch+var_14], 14h
    push    eax
    mov     [esp+30h+var_18], 0
    call    dword_528AB4
    test    eax, eax
    jz      short loc_4DE5D9
    mov     edi, [esp+30h+var_8]
    mov     ecx, 5
    lea     esi, [esp+30h+var_24]
    mov     al, 1
    rep movsd
    pop     edi
    pop     esi
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE5D9:                             ; CODE XREF: sub_4DE550+70j
    call    ds:GetLastError
    mov     ecx, [esp+30h+var_4]
    mov     [ecx], eax
    xor     al, al
    pop     edi
    pop     esi
    add     esp, 18h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE5ED:                             ; CODE XREF: sub_4DE550+Cj
    mov     edx, [esp+20h+arg_8]
    pop     edi
    xor     al, al
    pop     esi
    mov     dword ptr [edx], 0
    add     esp, 18h
    retn
    sub_4DE550 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DE600 proc near                    ; CODE XREF: sub_4D8870+3Dp
                                            ; sub_4D88D0+42p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch
    arg_18= dword ptr  20h
    arg_1C= dword ptr  24h
    arg_20= dword ptr  28h
    arg_24= dword ptr  2Ch

    push    ebx
    mov     ebx, [esp+arg_18]
    push    ebp
    mov     ebp, [esp+4+arg_C]
    push    esi
    push    edi
    mov     edi, [esp+0Ch+arg_8]
    mov     dword ptr [ebx], 0
    test    ebp, ebp
    jnz     short loc_4DE627
    mov     eax, [esp+0Ch+arg_10]
    mov     [eax], edi
    mov     eax, [ebx]
    inc     eax
    mov     [ebx], eax
    jmp     short loc_4DE628
    ; ---------------------------------------------------------------------------

    loc_4DE627:                             ; CODE XREF: sub_4DE600+18j
    dec     ebp

    loc_4DE628:                             ; CODE XREF: sub_4DE600+25j
    push    0
    call    sub_4DE180
    mov     esi, [esp+10h+arg_4]
    add     esp, 4
    test    al, al
    jz      short loc_4DE658
    mov     ecx, [esp+0Ch+arg_14]
    mov     edx, [esp+0Ch+arg_10]
    mov     eax, [esp+0Ch+arg_0]
    push    ebx
    push    ecx
    inc     ebp
    push    edx
    push    ebp
    push    edi
    push    esi
    push    eax
    call    sub_4DE700
    add     esp, 1Ch
    jmp     short loc_4DE6A5
    ; ---------------------------------------------------------------------------

    loc_4DE658:                             ; CODE XREF: sub_4DE600+38j
    mov     ecx, [esp+0Ch+arg_14]
    mov     eax, [ebx]
    mov     edi, [esp+0Ch+arg_0]
    cmp     eax, ecx
    jge     short loc_4DE6A5

    loc_4DE666:                             ; CODE XREF: sub_4DE600+A3j
    push    8
    push    edi
    call    sub_4D8D70
    add     esp, 8
    test    al, al
    jnz     short loc_4DE6A5
    cmp     edi, esi
    jb      short loc_4DE6A5
    cmp     [edi], edi
    jle     short loc_4DE6A5
    mov     eax, [edi+4]
    test    eax, eax
    jz      short loc_4DE6A5
    test    ebp, ebp
    jnz     short loc_4DE698
    mov     edx, [ebx]
    mov     ecx, [esp+0Ch+arg_10]
    mov     [ecx+edx*4], eax
    mov     eax, [ebx]
    inc     eax
    mov     [ebx], eax
    jmp     short loc_4DE699
    ; ---------------------------------------------------------------------------

    loc_4DE698:                             ; CODE XREF: sub_4DE600+86j
    dec     ebp

    loc_4DE699:                             ; CODE XREF: sub_4DE600+96j
    mov     edx, [esp+0Ch+arg_14]
    mov     eax, [ebx]
    mov     edi, [edi]
    cmp     eax, edx
    jl      short loc_4DE666

    loc_4DE6A5:                             ; CODE XREF: sub_4DE600+56j
                                            ; sub_4DE600+64j ...
    mov     ebp, [esp+0Ch+arg_20]
    xor     ebx, ebx
    test    esi, esi
    jz      short loc_4DE6D5
    test    ebp, ebp
    jle     short loc_4DE6D5
    mov     edi, [esp+0Ch+arg_1C]
    sub     edi, esi

    loc_4DE6B9:                             ; CODE XREF: sub_4DE600+D3j
    push    4
    push    esi
    call    sub_4D8D70
    add     esp, 8
    test    al, al
    jnz     short loc_4DE6D5
    mov     eax, [esi]
    inc     ebx
    mov     [edi+esi], eax
    add     esi, 4
    cmp     ebx, ebp
    jl      short loc_4DE6B9

    loc_4DE6D5:                             ; CODE XREF: sub_4DE600+ADj
                                            ; sub_4DE600+B1j ...
    mov     ecx, [esp+0Ch+arg_24]
    cmp     ebx, ebp
    mov     [ecx], ebx
    jge     short loc_4DE6EE
    mov     edx, [esp+0Ch+arg_1C]
    mov     ecx, ebp
    sub     ecx, ebx
    xor     eax, eax
    lea     edi, [edx+ebx*4]
    rep stosd

    loc_4DE6EE:                             ; CODE XREF: sub_4DE600+DDj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4DE600 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DE700 proc near                    ; CODE XREF: sub_4DE600+4Ep

    var_94= dword ptr -94h
    var_7C= dword ptr -7Ch
    var_70= dword ptr -70h
    var_68= dword ptr -68h
    var_58= dword ptr -58h
    var_50= dword ptr -50h
    var_4C= dword ptr -4Ch
    var_44= dword ptr -44h
    var_18= dword ptr -18h
    var_C= dword ptr -0Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    sub     esp, 70h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     ecx, 1Ch
    xor     eax, eax
    lea     edi, [esp+80h+var_70]
    mov     edx, [esp+80h+arg_0]
    rep stosd
    mov     eax, [esp+80h+arg_8]
    mov     ecx, [esp+80h+arg_4]
    mov     [esp+80h+var_70], eax
    mov     eax, 3
    mov     [esp+80h+var_68], eax
    mov     [esp+80h+var_44], eax
    mov     [esp+80h+var_50], eax
    mov     al, byte_528AA8
    test    al, 1
    mov     [esp+80h+var_4C], ecx
    mov     [esp+80h+var_58], edx
    jnz     short loc_4DE761
    or      al, 1
    mov     byte_528AA8, al
    call    ds:GetCurrentProcess
    mov     dword_528AB0, eax

    loc_4DE761:                             ; CODE XREF: sub_4DE700+4Dj
    call    ds:GetCurrentThread
    mov     esi, [esp+80h+arg_18]
    mov     ebx, eax
    mov     eax, [esp+80h+arg_14]
    cmp     [esi], eax
    jge     loc_4DE807
    mov     edi, [esp+80h+arg_10]
    mov     ebp, [esp+80h+arg_C]

    loc_4DE78D:                             ; CODE XREF: sub_4DE700+E9j
    mov     ecx, dword_528AC8
    mov     edx, dword_528AC4
    push    0
    push    ecx
    mov     ecx, dword_528AB0
    push    edx
    push    0
    lea     eax, [esp+90h+var_70]
    push    0
    push    eax
    push    ebx
    push    ecx
    push    14Ch
    call    dword_528AC0
    test    eax, eax
    jz      short loc_4DE7F3
    mov     eax, [esp+80h+var_58]
    test    eax, eax
    jz      short loc_4DE807
    mov     eax, [esp+80h+var_70]
    test    eax, eax
    jz      short loc_4DE807
    test    ebp, ebp
    jnz     short loc_4DE7DD
    mov     edx, [esi]
    mov     [edi+edx*4], eax
    mov     eax, [esi]
    inc     eax
    mov     [esi], eax
    jmp     short loc_4DE7DE
    ; ---------------------------------------------------------------------------

    loc_4DE7DD:                             ; CODE XREF: sub_4DE700+CFj
    dec     ebp

    loc_4DE7DE:                             ; CODE XREF: sub_4DE700+DBj
    mov     eax, [esp+80h+arg_14]
    mov     ecx, [esi]
    cmp     ecx, eax
    jl      short loc_4DE78D
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn
    ; ---------------------------------------------------------------------------

    loc_4DE7F3:                             ; CODE XREF: sub_4DE700+BBj
    cmp     dword ptr [esi], 0
    jnz     short loc_4DE807
    mov     ecx, [esp+80h+arg_8]
    mov     dword ptr [esi], 1
    mov     [edi], ecx

    loc_4DE807:                             ; CODE XREF: sub_4DE700+79j
                                            ; sub_4DE700+C3j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 70h
    retn
    sub_4DE700 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DE810 proc near                    ; CODE XREF: sub_4DE8A0+118p
                                            ; sub_4DE8A0+131p

    var_40C= dword ptr -40Ch
    var_3E8= dword ptr -3E8h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 40Ch
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+40Ch+var_3E8]
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+418h+arg_0]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     edx, [esp+418h+var_3E8]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, [esp+418h+arg_4]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    lea     eax, [esp+418h+var_40C]
    and     ecx, 3
    push    eax
    rep movsb
    lea     ecx, [esp+41Ch+var_3E8]
    push    ecx
    call    __stat
    add     esp, 8
    test    eax, eax
    pop     edi
    pop     esi
    setz    al
    pop     ebx
    add     esp, 40Ch
    retn
    sub_4DE810 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DE8A0 proc near                    ; CODE XREF: sub_4D89B0+48p
                                            ; sub_4DEA00+103p

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h

    push    ebx
    push    ebp
    mov     ebp, [esp+arg_4]
    push    esi
    push    edi
    push    5Ch                             ; int
    push    ebp                             ; char *
    mov     ebx, offset Data
    call    _strchr
    add     esp, 8
    test    eax, eax
    jnz     loc_4DE9E2
    mov     al, byte_528AE4
    test    al, al
    jnz     loc_4DE9B2
    push    offset aMsdevdir                ; char *
    mov     byte_528AE4, 1
    call    _getenv
    add     esp, 4
    test    eax, eax
    jz      loc_4DE9B2
    mov     edi, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    3Bh                             ; int
    repne scasb
    not     ecx
    sub     edi, ecx
    push    offset byte_528AE8              ; char *
    mov     eax, ecx
    mov     esi, edi
    mov     edi, offset byte_528AE8
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    call    _strchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4DE921
    mov     byte ptr [eax], 0

    loc_4DE921:                             ; CODE XREF: sub_4DE8A0+7Cj
    push    5Ch                             ; int
    push    offset byte_528AE8              ; char *
    call    _strrchr
    add     esp, 8
    test    eax, eax
    jz      short loc_4DE937
    mov     byte ptr [eax], 0

    loc_4DE937:                             ; CODE XREF: sub_4DE8A0+92j
    or      ecx, 0FFFFFFFFh
    mov     edi, offset byte_528AE8
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, offset dword_528ED0
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, offset aVcCrtSrc           ; "\\vc\\crt\\src\\"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, offset byte_528AE8
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     edi, offset aVcMfcSrc           ; "\\vc\\mfc\\src\\"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, offset dword_528ED0
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4DE9B2:                             ; CODE XREF: sub_4DE8A0+27j
                                            ; sub_4DE8A0+43j
    push    ebp
    push    offset dword_528ED0
    call    sub_4DE810
    add     esp, 8
    test    al, al
    jz      short loc_4DE9CB
    mov     ebx, offset dword_528ED0
    jmp     short loc_4DE9E2
    ; ---------------------------------------------------------------------------

    loc_4DE9CB:                             ; CODE XREF: sub_4DE8A0+122j
    push    ebp
    push    offset byte_528AE8
    call    sub_4DE810
    add     esp, 8
    test    al, al
    jz      short loc_4DE9E2
    mov     ebx, offset byte_528AE8

    loc_4DE9E2:                             ; CODE XREF: sub_4DE8A0+1Aj
                                            ; sub_4DE8A0+129j ...
    mov     eax, [esp+8+arg_0]
    push    ebp
    push    ebx
    push    offset aSS_2                    ; "%s%s"
    push    eax
    call    _sprintf
    add     esp, 10h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4DE8A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DEA00 proc near                    ; CODE XREF: sub_4D89B0+F6p

    var_E08= dword ptr -0E08h
    var_E04= dword ptr -0E04h
    var_E00= dword ptr -0E00h
    var_DF9= byte ptr -0DF9h
    var_DF8= dword ptr -0DF8h
    var_DF4= dword ptr -0DF4h
    var_DF0= dword ptr -0DF0h
    var_DEC= dword ptr -0DECh
    var_DE8= dword ptr -0DE8h
    var_DE4= dword ptr -0DE4h
    var_DDC= dword ptr -0DDCh
    var_DD8= dword ptr -0DD8h
    var_DD0= dword ptr -0DD0h
    var_DCC= dword ptr -0DCCh
    var_DC0= dword ptr -0DC0h
    var_BB8= dword ptr -0BB8h
    var_7F0= dword ptr -7F0h
    var_7E0= dword ptr -7E0h
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    sub     esp, 0DFCh
    mov     ecx, [esp+0DFCh+arg_4]
    push    ebx
    push    ebp
    push    esi
    dec     ecx
    push    edi
    mov     [esp+0E0Ch+var_DF8], 0
    mov     [esp+0E0Ch+arg_4], ecx
    call    sub_4DE4D0
    mov     dl, al
    mov     edi, offset aCallStack          ; "Call stack:\n"
    test    dl, dl
    mov     [esp+0E0Ch+var_DF9], dl
    jnz     short loc_4DEA3A
    mov     edi, offset aCallStack_0        ; "Call stack: "

    loc_4DEA3A:                             ; CODE XREF: sub_4DEA00+33j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     ebp, [esp+0E0Ch+arg_0]
    mov     [esp+0E0Ch+var_DEC], 0Fh
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+0E0Ch+arg_4]
    mov     edi, ebp
    not     ecx
    dec     ecx
    sub     eax, ecx
    or      ecx, 0FFFFFFFFh
    mov     [esp+0E0Ch+arg_4], eax
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    add     ebp, ecx
    test    dl, dl
    jz      short loc_4DEA9C
    mov     [esp+0E0Ch+var_DEC], 320h

    loc_4DEA9C:                             ; CODE XREF: sub_4DEA00+92j
    mov     eax, [esp+0E0Ch+arg_C]
    xor     bl, bl
    test    eax, eax
    jle     loc_4DED47
    mov     esi, [esp+0E0Ch+arg_10]
    mov     [esp+0E0Ch+var_DF4], esi
    jmp     short loc_4DEAC2
    ; ---------------------------------------------------------------------------

    loc_4DEABA:                             ; CODE XREF: sub_4DEA00+341j
    mov     dl, [esp+0E0Ch+var_DF9]
    mov     esi, [esp+0E0Ch+var_DF4]

    loc_4DEAC2:                             ; CODE XREF: sub_4DEA00+B8j
    mov     ecx, [esp+0E0Ch+var_DEC]
    mov     eax, [esp+0E0Ch+arg_4]
    cmp     eax, ecx
    jle     loc_4DED47
    test    dl, dl
    jz      loc_4DEC9D
    mov     ecx, [esi]
    lea     edx, [esp+0E0Ch+var_DE8]
    lea     eax, [esp+0E0Ch+var_DE4]
    push    edx
    push    eax
    push    ecx
    call    sub_4DE550
    add     esp, 0Ch
    test    al, al
    jz      short loc_4DEB2D
    mov     edx, [esp+0E0Ch+var_DD8]
    lea     eax, [esp+0E0Ch+var_BB8]
    push    edx
    push    eax
    call    sub_4DE8A0
    mov     ecx, [esi]
    mov     edx, [esp+0E14h+var_DDC]
    add     esp, 8
    lea     eax, [esp+0E0Ch+var_BB8]
    push    ecx
    push    edx
    push    eax
    push    offset aSD08lx                  ; "%s(%d) : %08lX"
    push    ebp
    call    _sprintf
    add     esp, 14h
    mov     bl, 1
    jmp     short loc_4DEB3E
    ; ---------------------------------------------------------------------------

    loc_4DEB2D:                             ; CODE XREF: sub_4DEA00+F4j
    mov     ecx, [esi]
    push    ecx
    push    offset a08lx                    ; "%08lX"
    push    ebp
    call    _sprintf
    add     esp, 0Ch

    loc_4DEB3E:                             ; CODE XREF: sub_4DEA00+12Bj
    mov     ecx, [esi]
    lea     edx, [esp+0E0Ch+var_DD0]
    lea     eax, [esp+0E0Ch+var_DF0]
    push    edx
    push    eax
    push    ecx
    mov     [esp+0E18h+var_DD0], 218h
    mov     [esp+0E18h+var_DC0], 200h
    mov     [esp+0E18h+var_DF0], 0
    call    ds:GetCurrentProcess
    push    eax
    call    dword_528ACC
    test    eax, eax
    jz      loc_4DEC71
    mov     eax, dword_528AD4
    test    eax, eax
    jz      short loc_4DEBA7
    push    0
    lea     edx, [esp+0E20h+var_7E0]
    push    7D0h
    lea     ecx, [esp+0E24h+var_DCC]
    push    edx
    push    ecx
    call    eax
    test    eax, eax
    jbe     short loc_4DEBA7
    lea     edx, [esp+0E2Ch+var_7F0]
    jmp     loc_4DEC4D
    ; ---------------------------------------------------------------------------

    loc_4DEBA7:                             ; CODE XREF: sub_4DEA00+17Fj
                                            ; sub_4DEA00+199j
    mov     esi, offset a??2@yapaxi@z       ; "??2@YAPAXI@Z"
    lea     eax, [esp+0E1Ch+var_DCC]

    loc_4DEBB0:                             ; CODE XREF: sub_4DEA00+1D2j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4DEBD8
    test    cl, cl
    jz      short loc_4DEBD4
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4DEBD8
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4DEBB0

    loc_4DEBD4:                             ; CODE XREF: sub_4DEA00+1BCj
    xor     eax, eax
    jmp     short loc_4DEBDD
    ; ---------------------------------------------------------------------------

    loc_4DEBD8:                             ; CODE XREF: sub_4DEA00+1B8j
                                            ; sub_4DEA00+1C8j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4DEBDD:                             ; CODE XREF: sub_4DEA00+1D6j
    test    eax, eax
    jz      short loc_4DEC1B
    mov     esi, offset a??2@yapaxipbdh     ; "??2@YAPAXIPBDH@Z"
    lea     eax, [esp+0E1Ch+var_DCC]

    loc_4DEBEA:                             ; CODE XREF: sub_4DEA00+20Cj
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4DEC12
    test    cl, cl
    jz      short loc_4DEC0E
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4DEC12
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4DEBEA

    loc_4DEC0E:                             ; CODE XREF: sub_4DEA00+1F6j
    xor     eax, eax
    jmp     short loc_4DEC17
    ; ---------------------------------------------------------------------------

    loc_4DEC12:                             ; CODE XREF: sub_4DEA00+1F2j
                                            ; sub_4DEA00+202j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4DEC17:                             ; CODE XREF: sub_4DEA00+210j
    test    eax, eax
    jnz     short loc_4DEC49

    loc_4DEC1B:                             ; CODE XREF: sub_4DEA00+1DFj
    mov     edi, offset aOperatorNew        ; " - operator new"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+0E1Ch+var_DCC]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     ebx, ecx
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, ebx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, ebx
    and     ecx, 3
    rep movsb

    loc_4DEC49:                             ; CODE XREF: sub_4DEA00+219j
    lea     edx, [esp+0E1Ch+var_DCC]

    loc_4DEC4D:                             ; CODE XREF: sub_4DEA00+1A2j
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     eax, [esp+0E1Ch+var_E00]
    not     ecx
    dec     ecx
    push    eax
    add     ecx, ebp
    push    edx
    push    offset aSD_2                    ; " - %s + %d"
    push    ecx
    call    _sprintf
    add     esp, 10h
    mov     bl, 1

    loc_4DEC71:                             ; CODE XREF: sub_4DEA00+172j
    test    bl, bl
    jnz     short loc_4DECD4
    mov     eax, [esp+0E1Ch]
    lea     ecx, [eax-1]
    mov     eax, [esp+0E1Ch+var_E08]
    cmp     eax, ecx
    jz      short loc_4DECD4
    mov     ecx, [esp+0E1Ch+var_4]
    cdq
    idiv    ecx
    dec     ecx
    cmp     edx, ecx
    jz      short loc_4DECD4
    mov     edi, offset asc_50C8E8          ; " "
    jmp     short loc_4DECD9
    ; ---------------------------------------------------------------------------

    loc_4DEC9D:                             ; CODE XREF: sub_4DEA00+D7j
    mov     eax, [esi]
    push    eax
    push    offset a08lx                    ; "%08lX"
    push    ebp
    call    _sprintf
    mov     ecx, [esp+0E18h+arg_C]
    mov     eax, [esp+0E18h+var_DF8]
    add     esp, 0Ch
    dec     ecx
    cmp     eax, ecx
    jz      short loc_4DECD4
    mov     ecx, [esp+0E0Ch+arg_8]
    cdq
    idiv    ecx
    dec     ecx
    cmp     edx, ecx
    jz      short loc_4DECD4
    mov     edi, offset asc_50C8E8          ; " "
    jmp     short loc_4DECD9
    ; ---------------------------------------------------------------------------

    loc_4DECD4:                             ; CODE XREF: sub_4DEA00+273j
                                            ; sub_4DEA00+285j ...
    mov     edi, offset byte_50319C

    loc_4DECD9:                             ; CODE XREF: sub_4DEA00+29Bj
                                            ; sub_4DEA00+2D2j
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edx, ecx
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    mov     edx, [esp+0E1Ch+var_E04]
    and     ecx, 3
    add     edx, 4
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     esi, [esp+0E1Ch+var_8]
    mov     edi, ebp
    not     ecx
    dec     ecx
    mov     [esp+0E1Ch+var_E04], edx
    sub     esi, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+0E1Ch+var_E08]
    mov     [esp+0E1Ch+var_8], esi
    not     ecx
    dec     ecx
    add     ebp, ecx
    mov     ecx, [esp+0E1Ch]
    inc     eax
    cmp     eax, ecx
    mov     [esp+0E1Ch+var_E08], eax
    jl      loc_4DEABA

    loc_4DED47:                             ; CODE XREF: sub_4DEA00+A7j
                                            ; sub_4DEA00+CFj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0DFCh
    retn
    sub_4DEA00 endp ; sp = -10h

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DED60 proc near                    ; CODE XREF: sub_4D8E60+2B6p

    FatTime= word ptr -0D88h
    var_D84= dword ptr -0D84h
    FatDate= word ptr -0D80h
    nSize= dword ptr -0D7Ch
    FileTime= FILETIME ptr -0D78h
    var_D70= dword ptr -0D70h
    var_D68= dword ptr -0D68h
    SystemInfo= _SYSTEM_INFO ptr -0D50h
    var_D2C= tm ptr -0D2Ch
    var_D08= tm ptr -0D08h
    Buffer= byte ptr -0CE4h
    var_BB8= byte ptr -0BB8h
    FileName= byte ptr -3E8h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 0D88h
    mov     al, Data
    push    ebx
    push    esi
    push    edi
    mov     [esp+0D94h+var_BB8], al
    mov     ecx, 1F3h
    xor     eax, eax
    lea     edi, [esp+1DDh]
    rep stosd
    stosw
    push    0                               ; time_t *
    stosb
    call    _time
    add     esp, 4
    lea     ecx, [esp+0D94h+var_D84]
    mov     [esp+0D94h+var_D84], eax
    push    ecx                             ; time_t *
    call    _localtime
    mov     ecx, 9
    mov     esi, eax
    lea     edi, [esp+0D98h+var_D08]
    xor     eax, eax
    rep movsd
    lea     edi, [esp+0D98h+var_BB8]
    or      ecx, 0FFFFFFFFh
    add     esp, 4
    lea     edx, [esp+0D94h+var_D08]
    repne scasb
    not     ecx
    dec     ecx
    push    edx                             ; struct tm *
    lea     esi, [esp+ecx+0D98h+var_BB8]
    call    _asctime
    add     esp, 4
    push    eax
    push    offset aTimeS                   ; "Time: %s"
    push    esi
    call    _sprintf
    add     esp, 0Ch
    lea     eax, [esp+0D94h+nSize]
    lea     ecx, [esp+0D94h+Buffer]
    mov     [esp+0D94h+nSize], 12Ch
    push    eax                             ; nSize
    push    ecx                             ; lpBuffer
    call    ds:GetUserNameA
    test    eax, eax
    jnz     short loc_4DEE30
    mov     edi, offset aUnknownUser        ; "unknown user"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+0D94h+Buffer]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4DEE30:                             ; CODE XREF: sub_4DED60+A7j
    push    offset aComputername            ; char *
    call    _getenv
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    jnz     short loc_4DEE48
    mov     ebx, offset aUnknownMachine     ; "unknown machine"

    loc_4DEE48:                             ; CODE XREF: sub_4DED60+E1j
    lea     ecx, [esp+0D94h+FileName]
    push    3E8h                            ; nSize
    push    ecx                             ; lpFilename
    push    0                               ; hModule
    call    ds:GetModuleFileNameA
    test    eax, eax
    jnz     short loc_4DEE88
    mov     edi, offset aUnknown            ; "Unknown"
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+0D94h+FileName]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb

    loc_4DEE88:                             ; CODE XREF: sub_4DED60+FFj
    lea     ecx, [esp+0D94h+Buffer]
    push    ebx
    push    ecx
    lea     edi, [esp+0D9Ch+var_BB8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+0D9Ch+FileName]
    push    edx
    push    offset aSRunBySOnS              ; "%s, run by %s on %s\n"
    lea     eax, [esp+ecx+0DA4h+var_BB8]
    push    eax
    call    _sprintf
    add     esp, 14h
    lea     ecx, [esp+0D94h+FileName]
    push    0                               ; hTemplateFile
    push    80h                             ; dwFlagsAndAttributes
    push    3                               ; dwCreationDisposition
    push    0                               ; lpSecurityAttributes
    push    1                               ; dwShareMode
    push    80000000h                       ; dwDesiredAccess
    push    ecx                             ; lpFileName
    call    ds:CreateFileA
    mov     esi, eax
    test    esi, esi
    jz      loc_4DEFAC
    push    0                               ; lpFileSizeHigh
    push    esi                             ; hFile
    call    ds:GetFileSize
    lea     edx, [esp+0D94h+FileTime]
    mov     ebx, eax
    push    edx                             ; lpLastWriteTime
    push    0                               ; lpLastAccessTime
    push    0                               ; lpCreationTime
    push    esi                             ; hFile
    call    ds:GetFileTime
    test    eax, eax
    jz      loc_4DEFA5
    lea     eax, [esp+0D94h+FileTime]
    lea     ecx, [esp+0D94h+FileTime]
    push    eax                             ; lpLocalFileTime
    push    ecx                             ; lpFileTime
    call    ds:FileTimeToLocalFileTime
    test    eax, eax
    jz      loc_4DEFA5
    lea     edx, [esp+0D94h+FatTime]
    lea     eax, [esp+0D94h+FatDate]
    push    edx                             ; lpFatTime
    lea     ecx, [esp+0D98h+FileTime]
    push    eax                             ; lpFatDate
    push    ecx                             ; lpFileTime
    call    ds:FileTimeToDosDateTime
    test    eax, eax
    jz      short loc_4DEFA5
    lea     edi, [esp+0D94h+var_BB8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    mov     eax, dword ptr [esp+0D94h+FatDate]
    and     eax, 0FFFFh
    lea     edx, [esp+ecx+0D94h+var_BB8]
    mov     ecx, dword ptr [esp+0D94h+FatTime]
    and     ecx, 0FFFFh
    mov     edi, ecx
    and     edi, 1Fh
    shl     edi, 1
    push    edi
    mov     edi, ecx
    shr     edi, 5
    and     edi, 3Fh
    shr     ecx, 0Bh
    push    edi
    push    ecx
    mov     ecx, eax
    shr     ecx, 9
    add     ecx, 7BCh
    push    ecx
    mov     ecx, eax
    shr     eax, 5
    and     ecx, 1Fh
    and     eax, 0Fh
    push    ecx
    push    eax
    push    ebx
    push    offset aExecutableIsDB          ; "Executable is %d bytes long and dated %"...
    push    edx
    call    _sprintf
    add     esp, 24h

    loc_4DEFA5:                             ; CODE XREF: sub_4DED60+1A6j
                                            ; sub_4DED60+1BEj ...
    push    esi                             ; hObject
    call    ds:CloseHandle

    loc_4DEFAC:                             ; CODE XREF: sub_4DED60+183j
    push    0                               ; lpModuleName
    call    ds:GetModuleHandleA
    mov     ecx, [eax+3Ch]
    add     ecx, eax
    lea     ebx, [ecx+8]
    push    ebx                             ; time_t *
    call    _gmtime
    mov     ecx, 9
    mov     esi, eax
    lea     edi, [esp+0D98h+var_D2C]
    xor     eax, eax
    rep movsd
    lea     edi, [esp+0D98h+var_BB8]
    or      ecx, 0FFFFFFFFh
    add     esp, 4
    lea     edx, [esp+0D94h+var_D2C]
    repne scasb
    not     ecx
    dec     ecx
    push    edx                             ; struct tm *
    lea     esi, [esp+ecx+0D98h+var_BB8]
    call    _asctime
    add     esp, 4
    push    eax
    mov     eax, [ebx]
    push    eax
    push    offset aUtcLinkTime08l          ; "UTC link time: %08lx - %s"
    push    esi
    call    _sprintf
    lea     edi, [esp+0DA4h+var_BB8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 10h
    repne scasb
    not     ecx
    dec     ecx
    mov     edi, offset aLibraryDateSta     ; "Library date stamp: "
    lea     edx, [esp+ecx+0D94h+var_BB8]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     edi, dword_50D4D0
    not     ecx
    dec     ecx
    add     ecx, edi
    push    ecx
    push    3E4h
    push    offset aLibraryVersion          ; "Library version %d. Library date %s\n"
    push    edx
    call    _sprintf
    add     esp, 10h
    lea     ecx, [esp+0D94h+SystemInfo]
    push    ecx                             ; lpSystemInfo
    call    ds:GetSystemInfo
    mov     edx, [esp+0D94h+SystemInfo.dwNumberOfProcessors]
    cmp     edx, 1
    jbe     short loc_4DF087
    lea     edi, [esp+0D94h+var_BB8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    edx
    repne scasb
    not     ecx
    dec     ecx
    push    offset aDProcessors             ; "%d processors\n"
    lea     eax, [esp+ecx+0D9Ch+var_BB8]
    push    eax
    call    _sprintf
    add     esp, 0Ch
    jmp     short loc_4DF0AD
    ; ---------------------------------------------------------------------------

    loc_4DF087:                             ; CODE XREF: sub_4DED60+2FCj
    lea     edi, [esp+0D94h+var_BB8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    offset a1Processor              ; "1 processor\n"
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [esp+ecx+0D98h+var_BB8]
    push    edx
    call    _sprintf
    add     esp, 8

    loc_4DF0AD:                             ; CODE XREF: sub_4DED60+325j
    lea     eax, [esp+0D94h+var_D70]
    mov     [esp+0D94h+var_D70], 20h
    push    eax                             ; lpBuffer
    call    ds:GlobalMemoryStatus
    lea     edi, [esp+0D94h+var_BB8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [esp+ecx+0D94h+var_BB8]
    mov     ecx, [esp+0D94h+var_D68]
    add     ecx, 0DBBA0h
    shr     ecx, 14h
    push    ecx
    push    offset aDMbytesPhysica          ; "%d MBytes physical memory\n"
    push    eax
    call    _sprintf
    lea     edi, [esp+0DA0h+var_BB8]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 0Ch
    repne scasb
    not     ecx
    dec     ecx
    lea     esi, [esp+ecx+0D94h+var_BB8]
    call    sub_4D8E20
    push    eax
    call    sub_4D8DF0
    push    eax
    push    offset aStackGoesFrom0          ; "Stack goes from %08lX to %08lX\n"
    push    esi
    call    _sprintf
    mov     esi, [esp+0DA4h+arg_4]
    mov     edi, [esp+0DA4h+arg_0]
    add     esp, 10h
    lea     edx, [esp+0D94h+var_BB8]
    push    esi                             ; size_t
    push    edx                             ; char *
    push    edi                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [esi+edi-1], 0
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 0D88h
    retn
    sub_4DED60 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DF160 proc near                    ; CODE XREF: sub_4DA1D0+87p
    mov     cl, byte_5292B8
    mov     eax, 1
    test    al, cl
    jnz     short loc_4DF1A4
    push    0                               ; int
    push    0                               ; int
    push    offset aFpunofussy              ; int
    or      cl, al
    push    offset aFpufussy                ; int
    push    0                               ; char
    mov     byte_5292B8, cl
    push    eax                             ; int
    push    offset aFpufussy_0              ; int
    mov     ecx, offset byte_5292BC
    call    sub_4D9FE0
    push    offset nullsub_27               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4DF1A4:                             ; CODE XREF: sub_4DF160+Dj
    mov     al, byte_5292BC
    push    18h
    test    al, al
    jz      short loc_4DF1BA
    push    0
    call    __controlfp
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4DF1BA:                             ; CODE XREF: sub_4DF160+4Dj
    push    18h
    call    __controlfp
    add     esp, 8
    retn
    sub_4DF160 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_27. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DF1E0 proc near                    ; CODE XREF: sub_4DFD10+1Bp
    push    esi
    mov     esi, ecx
    mov     eax, offset aThisIsAUniqueI     ; "This is a unique identifier, isn't it -"...
    test    eax, eax
    mov     dword ptr [esi+24h], offset aThisIsAUniqueI ; "This is a unique identifier, isn't it -"...
    jnz     short loc_4DF1FA
    mov     dword ptr [esi+24h], offset Data

    loc_4DF1FA:                             ; CODE XREF: sub_4DF1E0+11j
    lea     ecx, [esi+21Ch]
    mov     byte ptr [esi+28h], 0
    call    sub_4E17C0
    or      eax, 0FFFFFFFFh
    mov     dword ptr [esi], 0
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     byte ptr [esi+20h], 0
    call    sub_4E1BE0
    mov     ecx, dword_529DCC
    mov     [esi+18h], ecx
    mov     edx, dword_529DF8
    mov     [esi+1Ch], edx
    call    sub_4E1730
    fstp    qword ptr [esi+10h]
    mov     ecx, esi
    call    sub_4DF250
    mov     eax, esi
    pop     esi
    retn
    sub_4DF1E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DF250 proc near                    ; CODE XREF: sub_4DF1E0+5Dp
    push    ecx
    push    offset sub_4DF330
    call    ds:GetDesktopWindow
    push    eax
    push    67h
    call    sub_4DA540
    add     esp, 10h
    test    eax, eax
    jnz     short locret_4DF27D
    push    eax                             ; uType
    push    offset aCavedog                 ; lpCaption
    push    offset aPerformanceDia          ; lpText
    push    eax                             ; hWnd
    call    ds:MessageBoxA

    locret_4DF27D:                          ; CODE XREF: sub_4DF250+19j
    retn
    sub_4DF250 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DF280 proc near                    ; CODE XREF: sub_4DF590+221p
                                            ; sub_4DF590+703p ...

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    test    al, al
    mov     esi, ecx
    jz      short loc_4DF2EA
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4DF2E2
    push    1                               ; bEnable
    push    eax                             ; hWnd
    call    ds:EnableWindow                 ; Enable/disable mouse and keyboard input
    mov     eax, [esi]
    push    eax                             ; hWnd
    call    ds:SetFocus
    mov     ecx, [esi]
    push    ecx                             ; hWnd
    call    ds:SetForegroundWindow
    mov     edx, dword_50D660
    mov     eax, [esi]
    push    3FF00000h
    push    0
    push    3FF00000h
    push    0
    push    edx
    push    eax
    call    sub_4E33D0
    mov     ecx, [esi]
    add     esp, 18h
    push    0                               ; lpTimerFunc
    push    0C8h                            ; uElapse
    push    1                               ; nIDEvent
    push    ecx                             ; hWnd
    call    ds:SetTimer
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4DF2E2:                             ; CODE XREF: sub_4DF280+Fj
    mov     byte ptr [esi+20h], 1
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4DF2EA:                             ; CODE XREF: sub_4DF280+9j
    mov     edx, [esi]
    push    edx                             ; hWnd
    call    ds:IsWindowVisible
    test    eax, eax
    jz      short loc_4DF31F
    mov     eax, [esi]
    push    1                               ; uIDEvent
    push    eax                             ; hWnd
    call    ds:KillTimer
    mov     ecx, dword_50D660
    mov     edx, [esi]
    push    ecx
    push    edx
    call    sub_4E3400
    mov     eax, [esi]
    add     esp, 8
    push    0                               ; nCmdShow
    push    eax                             ; hWnd
    call    ds:ShowWindow

    loc_4DF31F:                             ; CODE XREF: sub_4DF280+75j
    pop     esi
    retn    4
    sub_4DF280 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DF330 proc near                    ; DATA XREF: sub_4DF250+1o

    hWnd= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    dwNewLong= dword ptr  14h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+hWnd]
    push    edi
    mov     edi, [esp+8+dwNewLong]
    cmp     ebx, 110h
    jnz     short loc_4DF353
    push    edi                             ; dwNewLong
    push    0FFFFFFEBh                      ; nIndex
    push    esi                             ; hWnd
    call    ds:SetWindowLongA
    mov     [edi], esi

    loc_4DF353:                             ; CODE XREF: sub_4DF330+15j
    push    0FFFFFFEBh                      ; nIndex
    push    esi                             ; hWnd
    call    ds:GetWindowLongA
    test    eax, eax
    jz      short loc_4DF374
    mov     ecx, [esp+8+arg_8]
    push    edi
    push    ecx
    push    ebx
    mov     ecx, eax
    call    sub_4DF590
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4DF374:                             ; CODE XREF: sub_4DF330+2Ej
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    10h
    sub_4DF330 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DF380 proc near                    ; CODE XREF: sub_4DF590+1D7p
                                            ; sub_4DF590+5AAp

    lpCriticalSection= dword ptr -1FCh
    var_1F8= dword ptr -1F8h
    String= byte ptr -1F4h

    sub     esp, 1FCh
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     ebx, ecx
    call    sub_4E1AC0
    push    eax                             ; lpCriticalSection
    mov     [esp+210h+lpCriticalSection], eax
    call    ds:EnterCriticalSection
    call    sub_4E1A90
    mov     ebp, eax
    xor     ecx, ecx
    mov     eax, [ebp+4]
    mov     edi, [eax]
    cmp     edi, eax
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jz      loc_4DF4BE

    loc_4DF3BC:                             ; CODE XREF: sub_4DF380+D4j
    mov     eax, [edi+0Ch]
    mov     esi, [ebx+24h]
    cmp     eax, esi
    jz      short loc_4DF3F7

    loc_4DF3C6:                             ; CODE XREF: sub_4DF380+64j
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4DF3EA
    test    cl, cl
    jz      short loc_4DF3E6
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4DF3EA
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4DF3C6

    loc_4DF3E6:                             ; CODE XREF: sub_4DF380+50j
    xor     eax, eax
    jmp     short loc_4DF3EF
    ; ---------------------------------------------------------------------------

    loc_4DF3EA:                             ; CODE XREF: sub_4DF380+4Cj
                                            ; sub_4DF380+5Aj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4DF3EF:                             ; CODE XREF: sub_4DF380+68j
    test    eax, eax
    jz      short loc_4DF3F7
    xor     eax, eax
    jmp     short loc_4DF3FC
    ; ---------------------------------------------------------------------------

    loc_4DF3F7:                             ; CODE XREF: sub_4DF380+44j
                                            ; sub_4DF380+71j
    mov     eax, 1

    loc_4DF3FC:                             ; CODE XREF: sub_4DF380+75j
    test    al, al
    jnz     short loc_4DF45C
    lea     ecx, [esp+20Ch+var_1F8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, dword_5292C4
    cmp     eax, ecx
    jz      short loc_4DF421
    push    eax
    call    sub_4E04E0
    add     esp, 4
    jmp     short loc_4DF438
    ; ---------------------------------------------------------------------------

    loc_4DF421:                             ; CODE XREF: sub_4DF380+94j
    mov     eax, [edi+4]
    cmp     edi, [eax+8]
    jnz     short loc_4DF433

    loc_4DF429:                             ; CODE XREF: sub_4DF380+B1j
    mov     edi, eax
    mov     eax, [eax+4]
    cmp     edi, [eax+8]
    jz      short loc_4DF429

    loc_4DF433:                             ; CODE XREF: sub_4DF380+A7j
    cmp     [edi+8], eax
    jz      short loc_4DF43A

    loc_4DF438:                             ; CODE XREF: sub_4DF380+9Fj
    mov     edi, eax

    loc_4DF43A:                             ; CODE XREF: sub_4DF380+B6j
    lea     ecx, [esp+20Ch+var_1F8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     ecx, [ebp+4]
    xor     eax, eax
    cmp     edi, ecx
    setz    al
    neg     al
    sbb     eax, eax
    inc     eax
    test    al, al
    jnz     loc_4DF3BC
    jmp     short loc_4DF4BE
    ; ---------------------------------------------------------------------------

    loc_4DF45C:                             ; CODE XREF: sub_4DF380+7Ej
    mov     edx, [ebx]
    lea     ecx, [esp+20Ch+String]
    push    1F4h                            ; nMaxCount
    push    ecx                             ; lpString
    push    3F0h                            ; nIDDlgItem
    push    edx                             ; hDlg
    call    ds:GetDlgItemTextA
    test    eax, eax
    jz      short loc_4DF4AC
    lea     esi, [edi+10h]
    lea     eax, [esp+20Ch+String]

    loc_4DF47F:                             ; CODE XREF: sub_4DF380+11Dj
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4DF4A3
    test    cl, cl
    jz      short loc_4DF49F
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4DF4A3
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4DF47F

    loc_4DF49F:                             ; CODE XREF: sub_4DF380+109j
    xor     eax, eax
    jmp     short loc_4DF4A8
    ; ---------------------------------------------------------------------------

    loc_4DF4A3:                             ; CODE XREF: sub_4DF380+105j
                                            ; sub_4DF380+113j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4DF4A8:                             ; CODE XREF: sub_4DF380+121j
    test    eax, eax
    jz      short loc_4DF4BE

    loc_4DF4AC:                             ; CODE XREF: sub_4DF380+F6j
    mov     eax, [ebx]
    add     edi, 10h
    push    edi                             ; lpString
    push    3F0h                            ; nIDDlgItem
    push    eax                             ; hDlg
    call    ds:SetDlgItemTextA

    loc_4DF4BE:                             ; CODE XREF: sub_4DF380+36j
                                            ; sub_4DF380+DAj ...
    mov     ecx, [esp+20Ch+lpCriticalSection]
    push    ecx                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1FCh
    retn
    sub_4DF380 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DF4E0 proc near                    ; CODE XREF: sub_4DF590+417p
                                            ; sub_4DF590+6F3p

    var_1= dword ptr -1

    push    ecx
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    call    sub_4E1680
    test    al, al
    jz      short loc_4DF4FE
    mov     al, byte_529DD8
    mov     byte ptr [esp+11h+var_1], 1
    test    al, al
    jnz     short loc_4DF503

    loc_4DF4FE:                             ; CODE XREF: sub_4DF4E0+Ej
    mov     byte ptr [esp+11h+var_1], 0

    loc_4DF503:                             ; CODE XREF: sub_4DF4E0+1Cj
    mov     esi, [esp+11h+var_1]
    mov     eax, [edi]
    mov     ebx, ds:GetDlgItem
    and     esi, 0FFh
    push    esi                             ; bEnable
    push    3F5h                            ; nIDDlgItem
    push    eax                             ; hDlg
    call    ebx ; GetDlgItem
    mov     ebp, ds:EnableWindow            ; Enable/disable mouse and keyboard input
    push    eax                             ; hWnd
    call    ebp ; EnableWindow              ; Enable/disable mouse and keyboard input
    mov     ecx, [edi]
    push    esi                             ; bEnable
    push    3EDh                            ; nIDDlgItem
    push    ecx                             ; hDlg
    call    ebx ; GetDlgItem
    push    eax                             ; hWnd
    call    ebp ; EnableWindow              ; Enable/disable mouse and keyboard input
    mov     edx, [edi]
    push    esi                             ; bEnable
    push    3F3h                            ; nIDDlgItem
    push    edx                             ; hDlg
    call    ebx ; GetDlgItem
    push    eax                             ; hWnd
    call    ebp ; EnableWindow              ; Enable/disable mouse and keyboard input
    mov     eax, [edi]
    push    esi                             ; bEnable
    push    3EEh                            ; nIDDlgItem
    push    eax                             ; hDlg
    call    ebx ; GetDlgItem
    push    eax                             ; hWnd
    call    ebp ; EnableWindow              ; Enable/disable mouse and keyboard input
    mov     ecx, [edi]
    push    esi                             ; bEnable
    push    3F1h                            ; nIDDlgItem
    push    ecx                             ; hDlg
    call    ebx ; GetDlgItem
    push    eax                             ; hWnd
    call    ebp ; EnableWindow              ; Enable/disable mouse and keyboard input
    mov     edx, [edi]
    push    esi                             ; bEnable
    push    3F6h                            ; nIDDlgItem
    push    edx                             ; hDlg
    call    ebx ; GetDlgItem
    push    eax                             ; hWnd
    call    ebp ; EnableWindow              ; Enable/disable mouse and keyboard input
    mov     eax, [edi]
    push    esi                             ; bEnable
    push    3F7h                            ; nIDDlgItem
    push    eax                             ; hDlg
    call    ebx ; GetDlgItem
    push    eax                             ; hWnd
    call    ebp ; EnableWindow              ; Enable/disable mouse and keyboard input
    mov     ecx, [edi]
    push    esi                             ; bEnable
    push    3F8h                            ; nIDDlgItem
    push    ecx                             ; hDlg
    call    ebx ; GetDlgItem
    push    eax                             ; hWnd
    call    ebp ; EnableWindow              ; Enable/disable mouse and keyboard input
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_4DF4E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DF590 proc near                    ; CODE XREF: sub_4DF330+39p

    wParam= dword ptr -2Ch
    var_28= dword ptr -28h
    var_24= dword ptr -24h
    var_20= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    var_14= dword ptr -14h
    Rect= tagRECT ptr -10h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_0]
    sub     esp, 2Ch
    cmp     eax, 312h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     ebx, ecx
    ja      loc_4DFCC4                      ; default
    jz      loc_4DFCA7
    sub     eax, 110h
    jz      loc_4DFB4B
    dec     eax
    jz      loc_4DF77F
    sub     eax, 2
    jnz     loc_4DFCC4                      ; default
    mov     eax, [ebx]
    push    eax                             ; hWnd
    call    ds:IsWindowVisible
    test    eax, eax
    jz      loc_4DFCC4                      ; default
    mov     edx, [ebx]
    lea     ecx, [esp+3Ch+Rect]
    push    ecx                             ; lpRect
    push    edx                             ; hWnd
    call    ds:GetWindowRect
    mov     eax, [esp+3Ch+Rect.left]
    mov     ecx, [ebx+4]
    cmp     eax, ecx
    mov     ecx, [esp+3Ch+Rect.top]
    jnz     short loc_4DF5FC
    cmp     ecx, [ebx+8]
    jz      short loc_4DF613

    loc_4DF5FC:                             ; CODE XREF: sub_4DF590+65j
    mov     [ebx+4], eax
    mov     [ebx+8], ecx
    mov     eax, dword_50D660
    mov     ecx, [ebx]
    push    eax
    push    ecx
    call    sub_4E3400
    add     esp, 8

    loc_4DF613:                             ; CODE XREF: sub_4DF590+6Aj
    call    sub_4E1AC0
    mov     edi, eax
    push    edi                             ; lpCriticalSection
    mov     [esp+40h+var_1C], edi
    call    ds:EnterCriticalSection
    call    sub_4E1A90
    mov     esi, eax
    mov     [esp+3Ch+var_28], esi
    mov     al, [esi+10h]
    test    al, al
    jz      loc_4DF765
    mov     edx, [esi+4]
    mov     ecx, [ebx]
    push    0                               ; lParam
    push    0                               ; wParam
    mov     eax, [edx]
    push    184h                            ; Msg
    or      edi, 0FFFFFFFFh
    push    3F4h                            ; nIDDlgItem
    push    ecx                             ; hDlg
    mov     [esp+50h+wParam], edi
    mov     [esp+50h+arg_0], 0
    mov     [esp+50h+arg_4], eax
    call    ds:SendDlgItemMessageA
    lea     ebp, [ebx+21Ch]
    mov     ecx, ebp
    call    sub_4E18C0
    mov     eax, [esp+3Ch+arg_4]
    mov     ecx, [esi+4]
    xor     edx, edx
    cmp     eax, ecx
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      loc_4DF743

    loc_4DF692:                             ; CODE XREF: sub_4DF590+1A7j
    add     eax, 0Ch
    mov     ecx, ebp
    push    eax
    call    sub_4E1990
    mov     eax, [esp+3Ch+arg_4]
    mov     edx, [ebx]
    mov     ecx, [eax+0Ch]
    push    ecx                             ; lParam
    push    0                               ; wParam
    push    180h                            ; Msg
    push    3F4h                            ; nIDDlgItem
    push    edx                             ; hDlg
    call    ds:SendDlgItemMessageA
    mov     eax, [esp+3Ch+arg_4]
    mov     edi, [ebx+24h]
    mov     esi, [eax+0Ch]
    cmp     esi, edi
    jz      short loc_4DF6FD

    loc_4DF6C8:                             ; CODE XREF: sub_4DF590+15Aj
    mov     cl, [esi]
    mov     dl, [edi]
    mov     al, cl
    cmp     cl, dl
    jnz     short loc_4DF6F0
    test    al, al
    jz      short loc_4DF6EC
    mov     dl, [esi+1]
    mov     cl, [edi+1]
    mov     al, dl
    cmp     dl, cl
    jnz     short loc_4DF6F0
    add     esi, 2
    add     edi, 2
    test    al, al
    jnz     short loc_4DF6C8

    loc_4DF6EC:                             ; CODE XREF: sub_4DF590+144j
    xor     eax, eax
    jmp     short loc_4DF6F5
    ; ---------------------------------------------------------------------------

    loc_4DF6F0:                             ; CODE XREF: sub_4DF590+140j
                                            ; sub_4DF590+150j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4DF6F5:                             ; CODE XREF: sub_4DF590+15Ej
    test    eax, eax
    jz      short loc_4DF6FD
    xor     eax, eax
    jmp     short loc_4DF702
    ; ---------------------------------------------------------------------------

    loc_4DF6FD:                             ; CODE XREF: sub_4DF590+136j
                                            ; sub_4DF590+167j
    mov     eax, 1

    loc_4DF702:                             ; CODE XREF: sub_4DF590+16Bj
    test    al, al
    jz      short loc_4DF70E
    mov     eax, [esp+3Ch+arg_0]
    mov     [esp+3Ch+wParam], eax

    loc_4DF70E:                             ; CODE XREF: sub_4DF590+174j
    mov     edi, [esp+3Ch+arg_0]
    lea     ecx, [esp+3Ch+arg_4]
    inc     edi
    mov     [esp+3Ch+arg_0], edi
    call    sub_4E0450
    mov     edx, [esp+3Ch+var_28]
    mov     eax, [esp+3Ch+arg_4]
    xor     ecx, ecx
    cmp     eax, [edx+4]
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     loc_4DF692
    mov     edi, [esp+3Ch+wParam]
    mov     esi, edx

    loc_4DF743:                             ; CODE XREF: sub_4DF590+FCj
    test    edi, edi
    jl      short loc_4DF75D
    mov     eax, [ebx]
    push    0                               ; lParam
    push    edi                             ; wParam
    push    186h                            ; Msg
    push    3F4h                            ; nIDDlgItem
    push    eax                             ; hDlg
    call    ds:SendDlgItemMessageA

    loc_4DF75D:                             ; CODE XREF: sub_4DF590+1B5j
    mov     edi, [esp+3Ch+var_1C]
    mov     byte ptr [esi+10h], 0

    loc_4DF765:                             ; CODE XREF: sub_4DF590+A5j
    mov     ecx, ebx
    call    sub_4DF380
    push    edi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DF77F:                             ; CODE XREF: sub_4DF590+2Aj
    mov     ecx, [esp+3Ch+arg_4]
    mov     eax, ecx
    and     eax, 0FFFFh
    cmp     eax, 3EEh
    jg      loc_4DF951
    cmp     eax, 3EDh
    jge     short loc_4DF7C2
    test    eax, eax
    jle     loc_4DFCC4                      ; default
    cmp     eax, 2
    jg      loc_4DFCC4                      ; default
    push    0
    mov     ecx, ebx
    call    sub_4DF280
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DF7C2:                             ; CODE XREF: sub_4DF590+20Aj
    mov     edx, ecx
    shr     edx, 10h
    cmp     edx, 1
    jnz     loc_4DFCC4                      ; default
    xor     edi, edi
    xor     esi, esi
    cmp     cx, 3EEh
    mov     [esp+3Ch+var_20], esi
    jnz     short loc_4DF7E5
    mov     esi, edx
    mov     [esp+3Ch+var_20], esi

    loc_4DF7E5:                             ; CODE XREF: sub_4DF590+24Dj
    push    edi                             ; lParam
    push    edi                             ; wParam
    push    147h                            ; Msg
    push    eax                             ; nIDDlgItem
    mov     eax, [ebx]
    push    eax                             ; hDlg
    call    ds:SendDlgItemMessageA
    mov     ebp, 1
    mov     ecx, esi
    shl     ebp, cl
    mov     ecx, [ebx+18h]
    mov     [esp+3Ch+var_28], edi
    cmp     ecx, edi
    mov     [esp+3Ch+var_1C], edi
    mov     [esp+3Ch+var_14], ebp
    jle     loc_4DFA45
    xor     ecx, ecx
    mov     [esp+3Ch+arg_0], ecx

    loc_4DF81C:                             ; CODE XREF: sub_4DF590+3A5j
    mov     edx, [ebx+1Ch]
    add     ecx, edx
    test    [ecx+8], ebp
    jz      loc_4DF91C
    cmp     [esp+3Ch+var_28], eax
    jnz     loc_4DF918
    mov     edx, [ecx]
    shl     esi, 4
    lea     eax, dword_529E00[esi]
    mov     dword_529E00[esi], edx
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [ecx+8]
    mov     [eax+8], edx
    mov     ecx, [ecx+0Ch]
    mov     [eax+0Ch], ecx
    mov     al, byte_529DC8
    test    al, al
    jz      loc_4DF911
    mov     edx, [ebx+1Ch]
    mov     eax, [esp+3Ch+arg_0]
    mov     ecx, [eax+edx+0Ch]
    test    ecx, ecx
    jz      loc_4DF911
    mov     eax, [ebx+18h]
    mov     edx, ebp
    xor     edi, edi
    not     edx
    cmp     eax, edi
    mov     [esp+3Ch+var_18], edx
    mov     [esp+3Ch+var_24], edi
    jle     loc_4DF911
    mov     [esp+3Ch+wParam], edi

    loc_4DF894:                             ; CODE XREF: sub_4DF590+37Fj
    mov     ecx, [ebx+1Ch]
    mov     eax, [esp+3Ch+wParam]
    add     eax, ecx
    test    [eax+8], edx
    jz      short loc_4DF8F6
    mov     ebp, [esp+3Ch+arg_0]
    mov     edx, [eax]
    cmp     edx, [ebp+ecx+0Ch]
    jnz     short loc_4DF8ED
    mov     ecx, offset dword_529E10
    push    0                               ; lParam
    sub     ecx, esi
    push    edi                             ; wParam
    push    14Eh                            ; Msg
    mov     [ecx], edx
    mov     edx, [eax+4]
    mov     [ecx+4], edx
    mov     edx, [eax+8]
    mov     [ecx+8], edx
    mov     eax, [eax+0Ch]
    mov     [ecx+0Ch], eax
    mov     edx, [ebx]
    xor     ecx, ecx
    cmp     word ptr [esp+48h+arg_4], 3EDh
    setz    cl
    add     ecx, 3EDh
    push    ecx                             ; nIDDlgItem
    push    edx                             ; hDlg
    call    ds:SendDlgItemMessageA

    loc_4DF8ED:                             ; CODE XREF: sub_4DF590+31Cj
    mov     edx, [esp+3Ch+var_18]
    mov     ebp, [esp+3Ch+var_14]
    inc     edi

    loc_4DF8F6:                             ; CODE XREF: sub_4DF590+310j
    mov     ecx, [esp+3Ch+wParam]
    mov     eax, [esp+3Ch+var_24]
    add     ecx, 10h
    inc     eax
    mov     [esp+3Ch+wParam], ecx
    mov     ecx, [ebx+18h]
    cmp     eax, ecx
    mov     [esp+3Ch+var_24], eax
    jl      short loc_4DF894

    loc_4DF911:                             ; CODE XREF: sub_4DF590+2CEj
                                            ; sub_4DF590+2E1j ...
    mov     esi, [esp+3Ch+var_20]
    or      eax, 0FFFFFFFFh

    loc_4DF918:                             ; CODE XREF: sub_4DF590+29Ej
    inc     [esp+3Ch+var_28]

    loc_4DF91C:                             ; CODE XREF: sub_4DF590+294j
    mov     edx, [esp+3Ch+var_1C]
    mov     ecx, [esp+3Ch+arg_0]
    mov     edi, [ebx+18h]
    inc     edx
    add     ecx, 10h
    cmp     edx, edi
    mov     [esp+3Ch+var_1C], edx
    mov     [esp+3Ch+arg_0], ecx
    jl      loc_4DF81C
    push    0
    call    sub_4E1B10
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DF951:                             ; CODE XREF: sub_4DF590+1FFj
    lea     edx, [eax-3EFh]                 ; switch 12 cases
    cmp     edx, 0Bh
    ja      loc_4DFCC4                      ; default
    jmp     ds:off_4DFCD0[edx*4]            ; switch jump

    loc_4DF967:                             ; DATA XREF: .text:004DFCD0o
    mov     eax, [ebx]                      ; case 0x3fa
    push    offset a_htm                    ; ".htm"
    push    offset aHttp10_0_150_1          ; "http://10.0.150.18/programming/library/"...
    push    eax
    call    sub_4DA5B0
    add     esp, 0Ch
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DF988:                             ; CODE XREF: sub_4DF590+3D0j
                                            ; DATA XREF: .text:004DFCD0o
    mov     dl, byte_529DD8                 ; case 0x3ef
    xor     ecx, ecx
    test    dl, dl
    setz    cl
    push    0
    mov     byte_529DD8, cl
    call    sub_4E1B10
    add     esp, 4
    mov     ecx, ebx
    call    sub_4DF4E0
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DF9B8:                             ; CODE XREF: sub_4DF590+3D0j
                                            ; DATA XREF: .text:004DFCD0o
    mov     bl, byte_529DD4                 ; case 0x3f1
    xor     edx, edx
    test    bl, bl
    setz    dl
    push    0
    mov     byte_529DD4, dl
    call    sub_4E1B10
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DF9E1:                             ; CODE XREF: sub_4DF590+3D0j
                                            ; DATA XREF: .text:004DFCD0o
    mov     dl, byte_529DDC                 ; case 0x3f6
    xor     eax, eax
    test    dl, dl
    setz    al
    push    0
    mov     byte_529DDC, al
    call    sub_4E1B10
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DFA09:                             ; CODE XREF: sub_4DF590+3D0j
                                            ; DATA XREF: .text:004DFCD0o
    mov     dl, byte_529E64                 ; case 0x3f7
    xor     ecx, ecx
    test    dl, dl
    setz    cl
    push    0
    mov     byte_529E64, cl
    call    sub_4E1B10
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DFA32:                             ; CODE XREF: sub_4DF590+3D0j
                                            ; DATA XREF: .text:004DFCD0o
    mov     bl, byte_529DC8                 ; case 0x3f8
    xor     edx, edx
    test    bl, bl
    setz    dl
    mov     byte_529DC8, dl

    loc_4DFA45:                             ; CODE XREF: sub_4DF590+280j
    push    0
    call    sub_4E1B10
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DFA5B:                             ; CODE XREF: sub_4DF590+3D0j
                                            ; DATA XREF: .text:004DFCD0o
    shr     ecx, 10h                        ; case 0x3f4
    cmp     ecx, 1
    jnz     loc_4DFCC4                      ; default
    push    0                               ; lParam
    push    0                               ; wParam
    push    188h                            ; Msg
    push    eax                             ; nIDDlgItem
    mov     eax, [ebx]
    push    eax                             ; hDlg
    call    ds:SendDlgItemMessageA
    mov     esi, [ebx+220h]
    mov     [esp+3Ch+arg_4], eax
    xor     eax, eax
    xor     ecx, ecx
    mov     ebp, [esi]
    cmp     ebp, esi
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jz      loc_4DFB38
    jmp     short loc_4DFAA2
    ; ---------------------------------------------------------------------------

    loc_4DFA9E:                             ; CODE XREF: sub_4DF590+5A2j
    mov     eax, [esp+3Ch+arg_0]

    loc_4DFAA2:                             ; CODE XREF: sub_4DF590+50Cj
    cmp     eax, [esp+3Ch+arg_4]
    jnz     short loc_4DFAB5
    lea     esi, [ebp+0Ch]
    lea     edi, [ebx+24h]
    mov     ecx, 7Eh
    rep movsd

    loc_4DFAB5:                             ; CODE XREF: sub_4DF590+516j
    inc     eax
    lea     ecx, [esp+3Ch+var_18]
    mov     [esp+3Ch+arg_0], eax
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [ebp+8]
    mov     ecx, dword_5292C4
    cmp     eax, ecx
    jz      short loc_4DFAFC
    lea     ecx, [esp+3Ch+var_14]
    mov     ebp, eax
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [ebp+0]
    mov     ecx, dword_5292C4
    cmp     eax, ecx
    jz      short loc_4DFAF1

    loc_4DFAE8:                             ; CODE XREF: sub_4DF590+55Fj
    mov     ebp, eax
    mov     eax, [ebp+0]
    cmp     eax, ecx
    jnz     short loc_4DFAE8

    loc_4DFAF1:                             ; CODE XREF: sub_4DF590+556j
    lea     ecx, [esp+3Ch+var_14]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    jmp     short loc_4DFB15
    ; ---------------------------------------------------------------------------

    loc_4DFAFC:                             ; CODE XREF: sub_4DF590+53Ej
    mov     eax, [ebp+4]
    cmp     ebp, [eax+8]
    jnz     short loc_4DFB0E

    loc_4DFB04:                             ; CODE XREF: sub_4DF590+57Cj
    mov     ebp, eax
    mov     eax, [eax+4]
    cmp     ebp, [eax+8]
    jz      short loc_4DFB04

    loc_4DFB0E:                             ; CODE XREF: sub_4DF590+572j
    cmp     [ebp+8], eax
    jz      short loc_4DFB15
    mov     ebp, eax

    loc_4DFB15:                             ; CODE XREF: sub_4DF590+56Aj
                                            ; sub_4DF590+581j
    lea     ecx, [esp+3Ch+var_18]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edi, [ebx+220h]
    xor     edx, edx
    cmp     ebp, edi
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     loc_4DFA9E

    loc_4DFB38:                             ; CODE XREF: sub_4DF590+506j
    mov     ecx, ebx
    call    sub_4DF380
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DFB4B:                             ; CODE XREF: sub_4DF590+23j
    mov     ecx, [ebx]
    lea     eax, [esp+3Ch+Rect]
    push    eax                             ; lpRect
    push    ecx                             ; hWnd
    call    ds:GetWindowRect
    mov     edx, [esp+3Ch+Rect.left]
    mov     eax, [esp+3Ch+Rect.top]
    mov     [ebx+4], edx
    mov     [ebx+8], eax
    xor     ebp, ebp

    loc_4DFB69:                             ; CODE XREF: sub_4DF590+678j
    mov     eax, 1
    mov     ecx, ebp
    shl     eax, cl
    cmp     ebp, 1
    mov     esi, 3EDh
    mov     [esp+3Ch+var_14], eax
    jnz     short loc_4DFB85
    mov     esi, 3EEh

    loc_4DFB85:                             ; CODE XREF: sub_4DF590+5EEj
    mov     eax, [ebx+18h]
    xor     edi, edi
    cmp     eax, edi
    mov     [esp+3Ch+var_1C], edi
    mov     [esp+3Ch+arg_4], edi
    jle     short loc_4DFBEE
    xor     eax, eax
    mov     [esp+3Ch+arg_0], eax

    loc_4DFB9C:                             ; CODE XREF: sub_4DF590+65Cj
    mov     ecx, [ebx+1Ch]
    mov     edx, [esp+3Ch+var_14]
    add     eax, ecx
    test    [eax+8], edx
    jz      short loc_4DFBD3
    mov     edx, [eax]
    mov     ecx, ebp
    shl     ecx, 4
    cmp     edx, dword_529E00[ecx]
    jnz     short loc_4DFBBD
    mov     [esp+3Ch+var_1C], edi

    loc_4DFBBD:                             ; CODE XREF: sub_4DF590+627j
    mov     eax, [eax+4]
    mov     ecx, [ebx]
    push    eax                             ; lParam
    push    0                               ; wParam
    push    143h                            ; Msg
    push    esi                             ; nIDDlgItem
    push    ecx                             ; hDlg
    inc     edi
    call    ds:SendDlgItemMessageA

    loc_4DFBD3:                             ; CODE XREF: sub_4DF590+618j
    mov     ecx, [esp+3Ch+arg_4]
    mov     eax, [esp+3Ch+arg_0]
    mov     edx, [ebx+18h]
    inc     ecx
    add     eax, 10h
    cmp     ecx, edx
    mov     [esp+3Ch+arg_4], ecx
    mov     [esp+3Ch+arg_0], eax
    jl      short loc_4DFB9C

    loc_4DFBEE:                             ; CODE XREF: sub_4DF590+604j
    mov     edx, [esp+3Ch+var_1C]
    mov     eax, [ebx]
    push    0                               ; lParam
    push    edx                             ; wParam
    push    14Eh                            ; Msg
    push    esi                             ; nIDDlgItem
    push    eax                             ; hDlg
    call    ds:SendDlgItemMessageA
    inc     ebp
    cmp     ebp, 2
    jl      loc_4DFB69
    mov     ecx, [ebx]
    push    24h                             ; vk
    push    1                               ; fsModifiers
    push    0Ah                             ; id
    push    ecx                             ; hWnd
    call    ds:RegisterHotKey
    mov     eax, [ebx]
    mov     esi, ds:CheckDlgButton          ; Change the check state of a button control
    xor     edx, edx
    mov     dl, byte_529DD8
    push    edx                             ; uCheck
    push    3EFh                            ; nIDButton
    push    eax                             ; hDlg
    call    esi ; CheckDlgButton            ; Change the check state of a button control
    mov     edx, [ebx]
    xor     ecx, ecx
    mov     cl, byte_529DD4
    push    ecx                             ; uCheck
    push    3F1h                            ; nIDButton
    push    edx                             ; hDlg
    call    esi ; CheckDlgButton            ; Change the check state of a button control
    mov     ecx, [ebx]
    xor     eax, eax
    mov     al, byte_529DDC
    push    eax                             ; uCheck
    push    3F6h                            ; nIDButton
    push    ecx                             ; hDlg
    call    esi ; CheckDlgButton            ; Change the check state of a button control
    mov     eax, [ebx]
    xor     edx, edx
    mov     dl, byte_529E64
    push    edx                             ; uCheck
    push    3F7h                            ; nIDButton
    push    eax                             ; hDlg
    call    esi ; CheckDlgButton            ; Change the check state of a button control
    mov     edx, [ebx]
    xor     ecx, ecx
    mov     cl, byte_529DC8
    push    ecx                             ; uCheck
    push    3F8h                            ; nIDButton
    push    edx                             ; hDlg
    call    esi ; CheckDlgButton            ; Change the check state of a button control
    mov     ecx, ebx
    call    sub_4DF4E0
    mov     al, [ebx+20h]
    test    al, al
    jz      short loc_4DFC98
    push    1
    mov     ecx, ebx
    call    sub_4DF280

    loc_4DFC98:                             ; CODE XREF: sub_4DF590+6FDj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4DFCA7:                             ; CODE XREF: sub_4DF590+18j
    cmp     [esp+3Ch+arg_4], 0Ah
    jnz     short loc_4DFCC4                ; default
    mov     eax, [ebx]
    push    eax                             ; hWnd
    call    ds:IsWindowVisible
    neg     eax
    sbb     eax, eax
    mov     ecx, ebx
    inc     eax
    push    eax
    call    sub_4DF280

    loc_4DFCC4:                             ; CODE XREF: sub_4DF590+12j
                                            ; sub_4DF590+33j ...
    pop     edi                             ; default
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 2Ch
    retn    0Ch
    sub_4DF590 endp

    ; ---------------------------------------------------------------------------
    off_4DFCD0 dd offset loc_4DF988         ; DATA XREF: sub_4DF590+3D0r
    dd offset loc_4DFCC4                    ; jump table for switch statement
    dd offset loc_4DF9B8
    dd offset loc_4DFCC4
    dd offset loc_4DFCC4
    dd offset loc_4DFA5B
    dd offset loc_4DFCC4
    dd offset loc_4DF9E1
    dd offset loc_4DFA09
    dd offset loc_4DFA32
    dd offset loc_4DFCC4
    dd offset loc_4DF967
    ; ---------------------------------------------------------------------------

    loc_4DFD00:                             ; CODE XREF: sub_4DFE80+16j
    push    1
    call    sub_4DFD10
    mov     ecx, eax
    call    sub_4DF280
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DFD10 proc near                    ; CODE XREF: .text:004DFD02p
                                            ; sub_4DFE80p
    mov     cl, byte_5292C8
    mov     al, 1
    test    al, cl
    jnz     short loc_4DFD3D
    mov     dl, cl
    mov     ecx, offset dword_5292D0
    or      dl, al
    mov     byte_5292C8, dl
    call    sub_4DF1E0
    push    offset sub_4DFD50               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4DFD3D:                             ; CODE XREF: sub_4DFD10+Aj
    mov     eax, offset dword_5292D0
    retn
    sub_4DFD10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; void sub_4DFD50(void)
    sub_4DFD50 proc near                    ; DATA XREF: sub_4DFD10+20o

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    mov     ecx, dword_5294F0
    mov     edx, dword_5294F8
    push    ebp
    xor     ebp, ebp
    mov     eax, [ecx]
    push    esi
    push    edi
    cmp     edx, ebp
    mov     edi, ecx
    mov     [esp+14h+var_8], eax
    jz      short loc_4DFDCC
    mov     esi, eax
    xor     edx, edx
    cmp     eax, esi
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jnz     short loc_4DFDCC
    lea     ecx, [esp+14h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, dword_5294F0
    mov     ecx, [eax+4]
    push    ecx
    mov     ecx, offset dword_5294EC
    call    sub_4E03F0
    mov     edx, dword_5294F0
    mov     eax, dword_5292C4
    lea     ecx, [esp+14h+var_4]
    mov     [edx+4], eax
    mov     eax, dword_5294F0
    mov     dword_5294F8, ebp
    mov     [eax], eax
    mov     eax, dword_5294F0
    mov     [eax+8], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    jmp     short loc_4DFE0B
    ; ---------------------------------------------------------------------------

    loc_4DFDCC:                             ; CODE XREF: sub_4DFD50+1Ej
                                            ; sub_4DFD50+30j
    xor     edx, edx
    cmp     eax, ecx
    setz    dl
    neg     dl
    sbb     edx, edx
    inc     edx
    test    dl, dl
    jz      short loc_4DFE11

    loc_4DFDDC:                             ; CODE XREF: sub_4DFD50+B9j
    lea     ecx, [esp+14h+var_8]
    mov     esi, eax
    call    sub_4E0450
    lea     eax, [esp+14h+var_4]
    push    esi
    push    eax
    mov     ecx, offset dword_5294EC
    call    sub_4DFEA0
    mov     eax, [esp+14h+var_8]
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_4DFDDC

    loc_4DFE0B:                             ; CODE XREF: sub_4DFD50+7Aj
    mov     ecx, dword_5294F0

    loc_4DFE11:                             ; CODE XREF: sub_4DFD50+8Aj
    cmp     ecx, ebp
    mov     eax, ecx
    jz      short loc_4DFE24
    mov     edx, dword_529E58
    mov     [ecx], edx
    mov     dword_529E58, eax

    loc_4DFE24:                             ; CODE XREF: sub_4DFD50+C5j
    lea     ecx, [esp+14h+var_4]
    mov     dword_5294F0, ebp
    mov     dword_5294F8, ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, dword_529500
    dec     eax
    mov     dword_529500, eax
    jnz     short loc_4DFE62
    mov     eax, dword_5292C4
    cmp     eax, ebp
    jz      short loc_4DFE5C
    mov     ecx, dword_529E58
    mov     [eax], ecx
    mov     dword_529E58, eax

    loc_4DFE5C:                             ; CODE XREF: sub_4DFD50+FDj
    mov     dword_5292C4, ebp

    loc_4DFE62:                             ; CODE XREF: sub_4DFD50+F4j
    lea     ecx, [esp+14h+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    pop     ebp
    add     esp, 8
    retn
    sub_4DFD50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DFE80 proc near                    ; CODE XREF: sub_4DA2E0+2Dp
    call    sub_4DFD10
    push    offset aPerformancesta          ; "-performancestatus"
    call    sub_4D9F60
    add     esp, 4
    test    eax, eax
    jz      short locret_4DFE9B
    jmp     loc_4DFD00
    ; ---------------------------------------------------------------------------

    locret_4DFE9B:                          ; CODE XREF: sub_4DFE80+14j
    retn
    sub_4DFE80 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4DFEA0 proc near                    ; CODE XREF: sub_4DFD50+A2p
                                            ; sub_4E18C0+A2p ...

    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 14h
    push    ebx
    push    ebp
    mov     [esp+1Ch+var_14], ecx
    push    esi
    push    edi
    mov     edi, [esp+24h+arg_4]
    lea     ecx, [esp+24h+arg_4]
    call    sub_4E0450
    mov     ebp, edi
    lea     ecx, [esp+24h+var_4]
    mov     [esp+24h+var_10], ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     esi, [edi]
    mov     edx, dword_5292C4
    lea     ebx, [edi+8]
    cmp     esi, edx
    mov     eax, ebx
    jnz     short loc_4DFEDC
    mov     esi, [ebx]
    jmp     short loc_4DFF17
    ; ---------------------------------------------------------------------------

    loc_4DFEDC:                             ; CODE XREF: sub_4DFEA0+36j
    mov     ecx, [ebx]
    cmp     ecx, edx
    jz      short loc_4DFF17
    mov     esi, ecx
    lea     ecx, [esp+24h+var_C]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_5292C4
    cmp     eax, ecx
    jz      short loc_4DFF01

    loc_4DFEF9:                             ; CODE XREF: sub_4DFEA0+5Fj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4DFEF9

    loc_4DFF01:                             ; CODE XREF: sub_4DFEA0+57j
    lea     ecx, [esp+24h+var_C]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    lea     eax, [esi+8]
    mov     [esp+24h+var_10], esi
    mov     ebp, [esp+24h+var_10]
    mov     esi, [eax]

    loc_4DFF17:                             ; CODE XREF: sub_4DFEA0+3Aj
                                            ; sub_4DFEA0+40j
    cmp     ebp, edi
    jz      short loc_4DFF8A
    mov     ecx, [edi]
    mov     [ecx+4], ebp
    mov     edx, [edi]
    mov     [ebp+0], edx
    mov     ecx, [ebx]
    cmp     ebp, ecx
    jnz     short loc_4DFF30
    mov     [esi+4], ebp
    jmp     short loc_4DFF44
    ; ---------------------------------------------------------------------------

    loc_4DFF30:                             ; CODE XREF: sub_4DFEA0+89j
    mov     ecx, [ebp+4]
    mov     [esi+4], ecx
    mov     edx, [ebp+4]
    mov     [edx], esi
    mov     ecx, [ebx]
    mov     [eax], ecx
    mov     edx, [ebx]
    mov     [edx+4], ebp

    loc_4DFF44:                             ; CODE XREF: sub_4DFEA0+8Ej
    mov     eax, [esp+24h+var_14]
    mov     eax, [eax+4]
    cmp     [eax+4], edi
    jnz     short loc_4DFF55
    mov     [eax+4], ebp
    jmp     short loc_4DFF63
    ; ---------------------------------------------------------------------------

    loc_4DFF55:                             ; CODE XREF: sub_4DFEA0+AEj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_4DFF60
    mov     [eax], ebp
    jmp     short loc_4DFF63
    ; ---------------------------------------------------------------------------

    loc_4DFF60:                             ; CODE XREF: sub_4DFEA0+BAj
    mov     [eax+8], ebp

    loc_4DFF63:                             ; CODE XREF: sub_4DFEA0+B3j
                                            ; sub_4DFEA0+BEj
    mov     ecx, [edi+4]
    mov     [esp+24h+var_10], edi
    mov     [ebp+4], ecx
    mov     edx, [edi+204h]
    mov     eax, [ebp+204h]
    mov     [ebp+204h], edx
    mov     [edi+204h], eax
    jmp     loc_4E0042
    ; ---------------------------------------------------------------------------

    loc_4DFF8A:                             ; CODE XREF: sub_4DFEA0+79j
    mov     eax, [ebp+4]
    mov     ebp, [esp+24h+var_14]
    mov     [esi+4], eax
    mov     eax, [ebp+4]
    cmp     [eax+4], edi
    jnz     short loc_4DFFA1
    mov     [eax+4], esi
    jmp     short loc_4DFFAF
    ; ---------------------------------------------------------------------------

    loc_4DFFA1:                             ; CODE XREF: sub_4DFEA0+FAj
    mov     eax, [edi+4]
    cmp     [eax], edi
    jnz     short loc_4DFFAC
    mov     [eax], esi
    jmp     short loc_4DFFAF
    ; ---------------------------------------------------------------------------

    loc_4DFFAC:                             ; CODE XREF: sub_4DFEA0+106j
    mov     [eax+8], esi

    loc_4DFFAF:                             ; CODE XREF: sub_4DFEA0+FFj
                                            ; sub_4DFEA0+10Aj
    mov     eax, [ebp+4]
    cmp     [eax], edi
    jnz     short loc_4DFFF6
    mov     ecx, [ebx]
    mov     edx, dword_5292C4
    cmp     ecx, edx
    jnz     short loc_4DFFC9
    mov     edx, [edi+4]
    mov     [eax], edx
    jmp     short loc_4DFFF6
    ; ---------------------------------------------------------------------------

    loc_4DFFC9:                             ; CODE XREF: sub_4DFEA0+120j
    lea     ecx, [esp+24h+var_8]
    mov     ebx, esi
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_5292C4
    cmp     eax, ecx
    jz      short loc_4DFFE8

    loc_4DFFE0:                             ; CODE XREF: sub_4DFEA0+146j
    mov     ebx, eax
    mov     eax, [ebx]
    cmp     eax, ecx
    jnz     short loc_4DFFE0

    loc_4DFFE8:                             ; CODE XREF: sub_4DFEA0+13Ej
    lea     ecx, [esp+24h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [ebp+4]
    mov     [eax], ebx

    loc_4DFFF6:                             ; CODE XREF: sub_4DFEA0+114j
                                            ; sub_4DFEA0+127j
    mov     eax, [ebp+4]
    cmp     [eax+8], edi
    jnz     short loc_4E0042
    mov     ecx, [edi]
    mov     edx, dword_5292C4
    cmp     ecx, edx
    jnz     short loc_4E0012
    mov     edx, [edi+4]
    mov     [eax+8], edx
    jmp     short loc_4E0042
    ; ---------------------------------------------------------------------------

    loc_4E0012:                             ; CODE XREF: sub_4DFEA0+168j
    lea     ecx, [esp+24h+var_8]
    mov     edi, esi
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     ecx, dword_5292C4
    cmp     eax, ecx
    jz      short loc_4E0033

    loc_4E002A:                             ; CODE XREF: sub_4DFEA0+191j
    mov     edi, eax
    mov     eax, [edi+8]
    cmp     eax, ecx
    jnz     short loc_4E002A

    loc_4E0033:                             ; CODE XREF: sub_4DFEA0+188j
    lea     ecx, [esp+24h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [ebp+4]
    mov     [eax+8], edi

    loc_4E0042:                             ; CODE XREF: sub_4DFEA0+E5j
                                            ; sub_4DFEA0+15Cj ...
    mov     eax, [esp+24h+var_10]
    mov     ebx, 1
    xor     ebp, ebp
    cmp     [eax+204h], ebx
    jnz     loc_4E03B3
    mov     ecx, [esp+24h+var_14]
    mov     edx, [ecx+4]
    cmp     esi, [edx+4]
    jz      loc_4E03A9

    loc_4E0069:                             ; CODE XREF: sub_4DFEA0+31Aj
    cmp     [esi+204h], ebx
    jnz     loc_4E03A9
    mov     eax, [esi+4]
    mov     edi, [eax]
    cmp     esi, edi
    jnz     loc_4E0118
    mov     edi, [eax+8]
    cmp     [edi+204h], ebp
    jnz     short loc_4E00F6
    mov     [edi+204h], ebx
    mov     eax, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [eax+204h], ebp
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_5292C4
    jz      short loc_4E00BD
    mov     [ecx+4], edi

    loc_4E00BD:                             ; CODE XREF: sub_4DFEA0+218j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4E00D4
    mov     [ecx+4], eax
    jmp     short loc_4E00E2
    ; ---------------------------------------------------------------------------

    loc_4E00D4:                             ; CODE XREF: sub_4DFEA0+22Dj
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4E00DF
    mov     [ecx], eax
    jmp     short loc_4E00E2
    ; ---------------------------------------------------------------------------

    loc_4E00DF:                             ; CODE XREF: sub_4DFEA0+239j
    mov     [ecx+8], eax

    loc_4E00E2:                             ; CODE XREF: sub_4DFEA0+232j
                                            ; sub_4DFEA0+23Dj
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx+8]

    loc_4E00F6:                             ; CODE XREF: sub_4DFEA0+1EBj
    mov     eax, [edi]
    cmp     [eax+204h], ebx
    jnz     loc_4E01C5
    mov     ecx, [edi+8]
    cmp     [ecx+204h], ebx
    jnz     loc_4E01C5
    jmp     loc_4E01A7
    ; ---------------------------------------------------------------------------

    loc_4E0118:                             ; CODE XREF: sub_4DFEA0+1DCj
    cmp     [edi+204h], ebp
    jnz     short loc_4E018A
    mov     [edi+204h], ebx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_C]
    mov     [edx+204h], ebp
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_5292C4
    jz      short loc_4E0150
    mov     [ecx+4], edi

    loc_4E0150:                             ; CODE XREF: sub_4DFEA0+2ABj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4E0167
    mov     [ecx+4], eax
    jmp     short loc_4E0176
    ; ---------------------------------------------------------------------------

    loc_4E0167:                             ; CODE XREF: sub_4DFEA0+2C0j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4E0174
    mov     [ecx+8], eax
    jmp     short loc_4E0176
    ; ---------------------------------------------------------------------------

    loc_4E0174:                             ; CODE XREF: sub_4DFEA0+2CDj
    mov     [ecx], eax

    loc_4E0176:                             ; CODE XREF: sub_4DFEA0+2C5j
                                            ; sub_4DFEA0+2D2j
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_C]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_4E018A:                             ; CODE XREF: sub_4DFEA0+27Ej
    mov     eax, [edi+8]
    cmp     [eax+204h], ebx
    jnz     loc_4E02C4
    mov     ecx, [edi]
    cmp     [ecx+204h], ebx
    jnz     loc_4E02C4

    loc_4E01A7:                             ; CODE XREF: sub_4DFEA0+273j
    mov     edx, [esp+24h+var_14]
    mov     [edi+204h], ebp
    mov     esi, [esi+4]
    mov     eax, [edx+4]
    cmp     esi, [eax+4]
    jnz     loc_4E0069
    jmp     loc_4E03A9
    ; ---------------------------------------------------------------------------

    loc_4E01C5:                             ; CODE XREF: sub_4DFEA0+25Ej
                                            ; sub_4DFEA0+26Dj
    mov     ecx, [edi+8]
    cmp     [ecx+204h], ebx
    jnz     short loc_4E0237
    mov     edx, [edi]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+204h], ebx
    mov     [edi+204h], ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_5292C4
    jz      short loc_4E01FC
    mov     [ecx+4], edi

    loc_4E01FC:                             ; CODE XREF: sub_4DFEA0+357j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4E0213
    mov     [ecx+4], eax
    jmp     short loc_4E0222
    ; ---------------------------------------------------------------------------

    loc_4E0213:                             ; CODE XREF: sub_4DFEA0+36Cj
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4E0220
    mov     [ecx+8], eax
    jmp     short loc_4E0222
    ; ---------------------------------------------------------------------------

    loc_4E0220:                             ; CODE XREF: sub_4DFEA0+379j
    mov     [ecx], eax

    loc_4E0222:                             ; CODE XREF: sub_4DFEA0+371j
                                            ; sub_4DFEA0+37Ej
    mov     [eax+8], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx+8]

    loc_4E0237:                             ; CODE XREF: sub_4DFEA0+32Ej
    mov     eax, [esi+4]
    mov     ecx, [eax+204h]
    mov     [edi+204h], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+204h], ebx
    mov     eax, [edi+8]
    mov     [eax+204h], ebx
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_5292C4
    jz      short loc_4E0279
    mov     [ecx+4], edi

    loc_4E0279:                             ; CODE XREF: sub_4DFEA0+3D4j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4E029C
    mov     [ecx+4], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4E03A4
    ; ---------------------------------------------------------------------------

    loc_4E029C:                             ; CODE XREF: sub_4DFEA0+3E9j
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4E02B3
    mov     [ecx], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4E03A4
    ; ---------------------------------------------------------------------------

    loc_4E02B3:                             ; CODE XREF: sub_4DFEA0+401j
    mov     [ecx+8], eax
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]
    jmp     loc_4E03A4
    ; ---------------------------------------------------------------------------

    loc_4E02C4:                             ; CODE XREF: sub_4DFEA0+2F3j
                                            ; sub_4DFEA0+301j
    mov     edx, [edi]
    cmp     [edx+204h], ebx
    jnz     short loc_4E0333
    mov     eax, [edi+8]
    lea     ecx, [esp+24h+var_8]
    mov     [eax+204h], ebx
    mov     [edi+204h], ebp
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_5292C4
    jz      short loc_4E02FB
    mov     [ecx+4], edi

    loc_4E02FB:                             ; CODE XREF: sub_4DFEA0+456j
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4E0312
    mov     [ecx+4], eax
    jmp     short loc_4E0320
    ; ---------------------------------------------------------------------------

    loc_4E0312:                             ; CODE XREF: sub_4DFEA0+46Bj
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4E031D
    mov     [ecx], eax
    jmp     short loc_4E0320
    ; ---------------------------------------------------------------------------

    loc_4E031D:                             ; CODE XREF: sub_4DFEA0+477j
    mov     [ecx+8], eax

    loc_4E0320:                             ; CODE XREF: sub_4DFEA0+470j
                                            ; sub_4DFEA0+47Bj
    mov     [eax], edi
    lea     ecx, [esp+24h+var_8]
    mov     [edi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     edx, [esi+4]
    mov     edi, [edx]

    loc_4E0333:                             ; CODE XREF: sub_4DFEA0+42Cj
    mov     eax, [esi+4]
    mov     ecx, [eax+204h]
    mov     [edi+204h], ecx
    mov     edx, [esi+4]
    lea     ecx, [esp+24h+var_8]
    mov     [edx+204h], ebx
    mov     eax, [edi]
    mov     [eax+204h], ebx
    mov     edi, [esi+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_5292C4
    jz      short loc_4E0374
    mov     [ecx+4], edi

    loc_4E0374:                             ; CODE XREF: sub_4DFEA0+4CFj
    mov     edx, [edi+4]
    mov     ecx, [esp+24h+var_14]
    mov     [eax+4], edx
    mov     ecx, [ecx+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4E038B
    mov     [ecx+4], eax
    jmp     short loc_4E039A
    ; ---------------------------------------------------------------------------

    loc_4E038B:                             ; CODE XREF: sub_4DFEA0+4E4j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4E0398
    mov     [ecx+8], eax
    jmp     short loc_4E039A
    ; ---------------------------------------------------------------------------

    loc_4E0398:                             ; CODE XREF: sub_4DFEA0+4F1j
    mov     [ecx], eax

    loc_4E039A:                             ; CODE XREF: sub_4DFEA0+4E9j
                                            ; sub_4DFEA0+4F6j
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+24h+var_8]

    loc_4E03A4:                             ; CODE XREF: sub_4DFEA0+3F7j
                                            ; sub_4DFEA0+40Ej ...
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4E03A9:                             ; CODE XREF: sub_4DFEA0+1C3j
                                            ; sub_4DFEA0+1CFj ...
    mov     eax, [esp+24h+var_10]
    mov     [esi+204h], ebx

    loc_4E03B3:                             ; CODE XREF: sub_4DFEA0+1B3j
    cmp     eax, ebp
    jz      short loc_4E03C4
    mov     edx, dword_529E58
    mov     [eax], edx
    mov     dword_529E58, eax

    loc_4E03C4:                             ; CODE XREF: sub_4DFEA0+515j
    mov     eax, [esp+24h+var_14]
    mov     esi, [esp+24h+arg_0]
    mov     ecx, [eax+0Ch]
    dec     ecx
    mov     [eax+0Ch], ecx
    mov     eax, [esp+24h+arg_4]
    lea     ecx, [esp+24h+var_4]
    mov     [esi], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn    8
    sub_4DFEA0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E03F0 proc near                    ; CODE XREF: sub_4DFD50+49p
                                            ; sub_4E03F0+24p ...

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    ebx
    mov     ebx, ecx
    push    esi
    push    edi
    lea     ecx, [esp+10h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     edi, [esp+10h+arg_0]
    mov     eax, dword_5292C4
    cmp     edi, eax
    mov     esi, edi
    jz      short loc_4E0438

    loc_4E040E:                             ; CODE XREF: sub_4E03F0+46j
    mov     eax, [esi+8]
    mov     ecx, ebx
    push    eax
    call    sub_4E03F0
    mov     esi, [esi]
    test    edi, edi
    jz      short loc_4E042D
    mov     ecx, dword_529E58
    mov     [edi], ecx
    mov     dword_529E58, edi

    loc_4E042D:                             ; CODE XREF: sub_4E03F0+2Dj
    mov     eax, dword_5292C4
    mov     edi, esi
    cmp     esi, eax
    jnz     short loc_4E040E

    loc_4E0438:                             ; CODE XREF: sub_4E03F0+1Cj
    lea     ecx, [esp+10h+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn    4
    sub_4E03F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E0450 proc near                    ; CODE XREF: sub_4DF590+18Bp
                                            ; sub_4DFD50+92p ...

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, dword_5292C4
    mov     esi, [eax+8]
    cmp     esi, ecx
    jz      short loc_4E04A6
    lea     ecx, [esp+10h+var_8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, dword_5292C4
    cmp     eax, ecx
    jz      short loc_4E048C

    loc_4E0484:                             ; CODE XREF: sub_4E0450+3Aj
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4E0484

    loc_4E048C:                             ; CODE XREF: sub_4E0450+32j
    lea     ecx, [esp+10h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E04A6:                             ; CODE XREF: sub_4E0450+1Dj
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax+8]
    jnz     short loc_4E04BC

    loc_4E04B0:                             ; CODE XREF: sub_4E0450+6Aj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax+8]
    jz      short loc_4E04B0

    loc_4E04BC:                             ; CODE XREF: sub_4E0450+5Ej
    mov     ecx, [edi]
    cmp     [ecx+8], eax
    jz      short loc_4E04C5
    mov     [edi], eax

    loc_4E04C5:                             ; CODE XREF: sub_4E0450+71j
    lea     ecx, [esp+10h+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4E0450 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E04E0 proc near                    ; CODE XREF: sub_4DF380+97p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     esi, [esp+8+arg_0]
    mov     ecx, dword_5292C4
    mov     eax, [esi]
    cmp     eax, ecx
    jz      short loc_4E0503

    loc_4E04FB:                             ; CODE XREF: sub_4E04E0+21j
    mov     esi, eax
    mov     eax, [esi]
    cmp     eax, ecx
    jnz     short loc_4E04FB

    loc_4E0503:                             ; CODE XREF: sub_4E04E0+19j
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     esi
    pop     ecx
    retn
    sub_4E04E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E0520 proc near                    ; CODE XREF: sub_4E0570+38p
                                            ; sub_4E0B90+7C2p

    var_8= dword ptr -8
    phkResult= dword ptr  4

    mov     eax, lpSubKey
    sub     esp, 8
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+0Ch+phkResult]
    push    offset aCavedoglibrary          ; int
    push    eax                             ; lpSubKey
    push    ecx                             ; phkResult
    lea     ecx, [esp+18h+var_8]
    call    sub_4E2BE0
    add     esi, 79h
    push    0
    push    esi
    push    offset aWorkingset              ; "WorkingSet"
    lea     ecx, [esp+18h+var_8]
    call    sub_4E2FE0
    lea     ecx, [esp+0Ch+var_8]
    call    nullsub_31
    pop     esi
    add     esp, 8
    retn    4
    sub_4E0520 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E0570 proc near                    ; CODE XREF: sub_4E1410+1Bp
    push    esi
    mov     esi, ecx
    push    edi
    xor     edx, edx
    lea     edi, [esi+18h]
    mov     ecx, 14h
    xor     eax, eax
    mov     [edi+50h], edx
    mov     [edi+54h], edx
    mov     [edi+58h], edx
    rep stosd
    or      eax, 0FFFFFFFFh
    mov     [esi], edx
    mov     [esi+4], edx
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    mov     [esi+78h], dl
    call    sub_4E1730
    fstp    qword ptr [esi+10h]
    push    1
    mov     ecx, esi
    call    sub_4E0520
    mov     ecx, esi
    call    sub_4E05C0
    mov     eax, esi
    pop     edi
    pop     esi
    retn
    sub_4E0570 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E05C0 proc near                    ; CODE XREF: sub_4E0570+3Fp
    push    ecx
    push    offset sub_4E06A0
    call    ds:GetDesktopWindow
    push    eax
    push    66h
    call    sub_4DA540
    add     esp, 10h
    test    eax, eax
    jnz     short locret_4E05ED
    push    eax                             ; uType
    push    offset aCavedog                 ; lpCaption
    push    offset aPerformanceDia          ; lpText
    push    eax                             ; hWnd
    call    ds:MessageBoxA

    locret_4E05ED:                          ; CODE XREF: sub_4E05C0+19j
    retn
    sub_4E05C0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E05F0 proc near                    ; CODE XREF: sub_4E0B90+820p
                                            ; sub_4E0B90+852p ...

    arg_0= byte ptr  4

    mov     al, [esp+arg_0]
    push    esi
    test    al, al
    mov     esi, ecx
    jz      short loc_4E065A
    mov     eax, [esi]
    test    eax, eax
    jz      short loc_4E0652
    push    1                               ; bEnable
    push    eax                             ; hWnd
    call    ds:EnableWindow                 ; Enable/disable mouse and keyboard input
    mov     eax, [esi]
    push    eax                             ; hWnd
    call    ds:SetFocus
    mov     ecx, [esi]
    push    ecx                             ; hWnd
    call    ds:SetForegroundWindow
    mov     edx, lpSubKey
    mov     eax, [esi]
    push    3FF00000h
    push    0
    push    3FF00000h
    push    0
    push    edx
    push    eax
    call    sub_4E33D0
    mov     ecx, [esi]
    add     esp, 18h
    push    0                               ; lpTimerFunc
    push    0C8h                            ; uElapse
    push    1                               ; nIDEvent
    push    ecx                             ; hWnd
    call    ds:SetTimer
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4E0652:                             ; CODE XREF: sub_4E05F0+Fj
    mov     byte ptr [esi+78h], 1
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4E065A:                             ; CODE XREF: sub_4E05F0+9j
    mov     edx, [esi]
    push    edx                             ; hWnd
    call    ds:IsWindowVisible
    test    eax, eax
    jz      short loc_4E0694
    mov     eax, [esi]
    push    1                               ; uIDEvent
    push    eax                             ; hWnd
    call    ds:KillTimer
    mov     ecx, lpSubKey
    mov     edx, [esi]
    push    ecx
    push    edx
    call    sub_4E3400
    mov     eax, [esi]
    add     esp, 8
    push    0                               ; nCmdShow
    push    eax                             ; hWnd
    call    ds:ShowWindow
    call    sub_4E0790

    loc_4E0694:                             ; CODE XREF: sub_4E05F0+75j
    pop     esi
    retn    4
    sub_4E05F0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E06A0 proc near                    ; DATA XREF: sub_4E05C0+1o

    hWnd= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    dwNewLong= dword ptr  14h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+hWnd]
    push    edi
    mov     edi, [esp+8+dwNewLong]
    cmp     ebx, 110h
    jnz     short loc_4E06C3
    push    edi                             ; dwNewLong
    push    0FFFFFFEBh                      ; nIndex
    push    esi                             ; hWnd
    call    ds:SetWindowLongA
    mov     [edi], esi

    loc_4E06C3:                             ; CODE XREF: sub_4E06A0+15j
    push    0FFFFFFEBh                      ; nIndex
    push    esi                             ; hWnd
    call    ds:GetWindowLongA
    test    eax, eax
    jz      short loc_4E06E4
    mov     ecx, [esp+8+arg_8]
    push    edi
    push    ecx
    push    ebx
    mov     ecx, eax
    call    sub_4E0B90
    pop     edi
    pop     esi
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4E06E4:                             ; CODE XREF: sub_4E06A0+2Ej
    pop     edi
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    10h
    sub_4E06A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E06F0 proc near                    ; CODE XREF: .text:004E0741p
                                            ; sub_4E0790+1p ...
    mov     cl, byte_5295C4
    mov     al, 1
    test    al, cl
    jnz     short loc_4E071C
    or      cl, al
    push    offset dword_529510             ; lpCriticalSection
    mov     byte_5295C4, cl
    call    ds:InitializeCriticalSection
    push    offset nullsub_28               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4E071C:                             ; CODE XREF: sub_4E06F0+Aj
    mov     eax, offset dword_529510
    retn
    sub_4E06F0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_28. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    push    esi
    call    sub_4E06F0
    mov     esi, eax
    push    esi
    call    ds:EnterCriticalSection
    mov     eax, dword_5295BC
    test    eax, eax
    jz      short loc_4E0773
    push    eax
    call    ds:FreeLibrary
    mov     dword_5295BC, 0
    mov     dword_529508, 0

    loc_4E0773:                             ; CODE XREF: .text:004E0756j
    push    esi
    mov     byte_5295CC, 1
    call    ds:LeaveCriticalSection
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E0790 proc near                    ; CODE XREF: sub_4E05F0+9Fp
    push    esi
    call    sub_4E06F0
    mov     esi, eax
    push    esi                             ; lpCriticalSection
    call    ds:EnterCriticalSection
    mov     eax, dword_5295BC
    test    eax, eax
    jz      short loc_4E07C3
    push    eax                             ; hLibModule
    call    ds:FreeLibrary
    mov     dword_5295BC, 0
    mov     dword_529508, 0

    loc_4E07C3:                             ; CODE XREF: sub_4E0790+16j
    push    esi                             ; lpCriticalSection
    mov     byte_5295CC, 0
    call    ds:LeaveCriticalSection
    pop     esi
    retn
    sub_4E0790 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E07E0 proc near                    ; CODE XREF: sub_4E0B90+69Ep

    lpCriticalSection= dword ptr -61AE8h
    var_61AE4= dword ptr -61AE4h
    var_61AD0= dword ptr -61AD0h
    var_61ABC= dword ptr -61ABCh
    var_61AA8= dword ptr -61AA8h
    var_61A94= dword ptr -61A94h
    var_61A8C= dword ptr -61A8Ch
    var_61A88= dword ptr -61A88h
    var_61A80= dword ptr -61A80h
    arg_0= dword ptr  4

    mov     eax, 61AE8h
    call    __alloca_probe
    push    ebx
    push    ebp
    push    esi
    push    edi
    call    sub_4E06F0
    mov     esi, eax
    push    esi                             ; lpCriticalSection
    mov     [esp+61AFCh+lpCriticalSection], esi
    call    ds:EnterCriticalSection
    mov     eax, dword_5295D0
    test    eax, eax
    jl      short loc_4E0817
    dec     eax
    test    eax, eax
    mov     dword_5295D0, eax
    jg      loc_4E0926

    loc_4E0817:                             ; CODE XREF: sub_4E07E0+27j
    mov     al, byte_5295CC
    test    al, al
    jnz     short loc_4E0857
    push    offset aPsapi_dll               ; lpLibFileName
    call    ds:LoadLibraryA
    test    eax, eax
    mov     dword_5295BC, eax
    jz      short loc_4E0845
    push    offset aQueryworkingse          ; lpProcName
    push    eax                             ; hModule
    call    ds:GetProcAddress
    mov     dword_529508, eax

    loc_4E0845:                             ; CODE XREF: sub_4E07E0+52j
    call    ds:GetCurrentProcess
    mov     dword_529530, eax
    mov     byte_5295CC, 1

    loc_4E0857:                             ; CODE XREF: sub_4E07E0+3Ej
    mov     eax, dword_529508
    test    eax, eax
    jnz     short loc_4E0874
    push    esi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 61AE8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4E0874:                             ; CODE XREF: sub_4E07E0+7Ej
    mov     edx, dword_529530
    lea     ecx, [esp+61AF8h+var_61A80]
    push    61A80h
    push    ecx
    push    edx
    call    eax
    test    eax, eax
    jnz     short loc_4E089F
    push    esi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 61AE8h
    retn
    ; ---------------------------------------------------------------------------

    loc_4E089F:                             ; CODE XREF: sub_4E07E0+A9j
    mov     eax, [esp+61B04h+var_61A8C]
    mov     ecx, dword_5295D4
    cmp     eax, ecx
    mov     dword_5295C8, eax
    jbe     short loc_4E08B7
    mov     dword_5295D4, eax

    loc_4E08B7:                             ; CODE XREF: sub_4E07E0+D0j
    xor     esi, esi
    xor     ebx, ebx
    xor     edi, edi
    mov     dword_5295C0, esi
    test    eax, eax
    mov     dword_5295B8, ebx
    mov     dword_529528, edi
    jbe     short loc_4E091A
    lea     edx, [esp+61B04h+var_61A88]
    mov     ebp, eax

    loc_4E08D9:                             ; CODE XREF: sub_4E07E0+126j
    mov     eax, [edx]
    mov     ecx, eax
    and     eax, 0FFFFF000h
    and     ecx, 0FFFh
    cmp     eax, 0C0000000h
    jb      short loc_4E08F9
    cmp     eax, 0E0000000h
    ja      short loc_4E08F9
    inc     esi
    jmp     short loc_4E0902
    ; ---------------------------------------------------------------------------

    loc_4E08F9:                             ; CODE XREF: sub_4E07E0+10Dj
                                            ; sub_4E07E0+114j
    test    ch, 1
    jz      short loc_4E0901
    inc     ebx
    jmp     short loc_4E0902
    ; ---------------------------------------------------------------------------

    loc_4E0901:                             ; CODE XREF: sub_4E07E0+11Cj
    inc     edi

    loc_4E0902:                             ; CODE XREF: sub_4E07E0+117j
                                            ; sub_4E07E0+11Fj
    add     edx, 4
    dec     ebp
    jnz     short loc_4E08D9
    mov     dword_529528, edi
    mov     dword_5295B8, ebx
    mov     dword_5295C0, esi

    loc_4E091A:                             ; CODE XREF: sub_4E07E0+F1j
    mov     dword_5295D0, 0Ah
    jmp     short loc_4E092C
    ; ---------------------------------------------------------------------------

    loc_4E0926:                             ; CODE XREF: sub_4E07E0+31j
    mov     esi, dword_5295C0

    loc_4E092C:                             ; CODE XREF: sub_4E07E0+144j
    shl     esi, 0Ch
    mov     byte ptr [esp+61AF8h+var_61A94], 0
    lea     ebp, [esp+61AF8h+var_61A94]
    lea     ecx, [esp+61AF8h+var_61A94]
    xor     edi, edi

    loc_4E093E:                             ; CODE XREF: sub_4E07E0+194j
    mov     eax, esi
    xor     edx, edx
    mov     ebx, 0Ah
    div     ebx
    mov     eax, 0CCCCCCCDh
    mov     ebx, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebx
    test    edx, edx
    jnz     short loc_4E0972
    test    esi, esi
    jz      short loc_4E0976
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0972:                             ; CODE XREF: sub_4E07E0+188j
    test    esi, esi
    jnz     short loc_4E093E

    loc_4E0976:                             ; CODE XREF: sub_4E07E0+18Cj
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+61AF8h+var_61A94]
    cmp     eax, ecx
    jnb     short loc_4E0992

    loc_4E0982:                             ; CODE XREF: sub_4E07E0+1B0j
    mov     dl, [ecx]
    mov     al, [ebp+0]
    mov     [ebp+0], dl
    inc     ebp
    mov     [ecx], al
    dec     ecx
    cmp     ebp, ecx
    jb      short loc_4E0982

    loc_4E0992:                             ; CODE XREF: sub_4E07E0+1A0j
    mov     esi, dword_5295B8
    mov     byte ptr [esp+61AF8h+var_61ABC], 0
    shl     esi, 0Ch
    lea     ebp, [esp+61AF8h+var_61ABC]
    lea     ecx, [esp+61AF8h+var_61ABC]
    xor     edi, edi

    loc_4E09AA:                             ; CODE XREF: sub_4E07E0+200j
    mov     eax, esi
    xor     edx, edx
    mov     ebx, 0Ah
    div     ebx
    mov     eax, 0CCCCCCCDh
    mov     ebx, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebx
    test    edx, edx
    jnz     short loc_4E09DE
    test    esi, esi
    jz      short loc_4E09E2
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E09DE:                             ; CODE XREF: sub_4E07E0+1F4j
    test    esi, esi
    jnz     short loc_4E09AA

    loc_4E09E2:                             ; CODE XREF: sub_4E07E0+1F8j
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+61AF8h+var_61ABC]
    cmp     eax, ecx
    jnb     short loc_4E09FE

    loc_4E09EE:                             ; CODE XREF: sub_4E07E0+21Cj
    mov     dl, [ecx]
    mov     al, [ebp+0]
    mov     [ebp+0], dl
    inc     ebp
    mov     [ecx], al
    dec     ecx
    cmp     ebp, ecx
    jb      short loc_4E09EE

    loc_4E09FE:                             ; CODE XREF: sub_4E07E0+20Cj
    mov     ebp, dword_529528
    mov     byte ptr [esp+61AF8h+var_61AE4], 0
    shl     ebp, 0Ch
    lea     edi, [esp+61AF8h+var_61AE4]
    lea     ecx, [esp+61AF8h+var_61AE4]
    xor     esi, esi

    loc_4E0A16:                             ; CODE XREF: sub_4E07E0+26Cj
    mov     eax, ebp
    xor     edx, edx
    mov     ebx, 0Ah
    div     ebx
    mov     eax, 0CCCCCCCDh
    mov     ebx, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     ebp
    inc     ecx
    shr     edx, 3
    inc     esi
    mov     ebp, edx
    mov     eax, esi
    cdq
    idiv    ebx
    test    edx, edx
    jnz     short loc_4E0A4A
    test    ebp, ebp
    jz      short loc_4E0A4E
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0A4A:                             ; CODE XREF: sub_4E07E0+260j
    test    ebp, ebp
    jnz     short loc_4E0A16

    loc_4E0A4E:                             ; CODE XREF: sub_4E07E0+264j
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+61AF8h+var_61AE4]
    cmp     eax, ecx
    jnb     short loc_4E0A68

    loc_4E0A5A:                             ; CODE XREF: sub_4E07E0+286j
    mov     dl, [ecx]
    mov     al, [edi]
    mov     [edi], dl
    inc     edi
    mov     [ecx], al
    dec     ecx
    cmp     edi, ecx
    jb      short loc_4E0A5A

    loc_4E0A68:                             ; CODE XREF: sub_4E07E0+278j
    mov     edi, dword_5295D4
    mov     byte ptr [esp+61AF8h+var_61AD0], 0
    shl     edi, 0Ch
    lea     ebp, [esp+61AF8h+var_61AD0]
    lea     ecx, [esp+61AF8h+var_61AD0]
    xor     esi, esi

    loc_4E0A80:                             ; CODE XREF: sub_4E07E0+2D6j
    mov     eax, edi
    xor     edx, edx
    mov     ebx, 0Ah
    div     ebx
    mov     eax, 0CCCCCCCDh
    mov     ebx, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     edi
    inc     ecx
    shr     edx, 3
    inc     esi
    mov     edi, edx
    mov     eax, esi
    cdq
    idiv    ebx
    test    edx, edx
    jnz     short loc_4E0AB4
    test    edi, edi
    jz      short loc_4E0AB8
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0AB4:                             ; CODE XREF: sub_4E07E0+2CAj
    test    edi, edi
    jnz     short loc_4E0A80

    loc_4E0AB8:                             ; CODE XREF: sub_4E07E0+2CEj
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+61AF8h+var_61AD0]
    cmp     eax, ecx
    jnb     short loc_4E0AD4

    loc_4E0AC4:                             ; CODE XREF: sub_4E07E0+2F2j
    mov     dl, [ecx]
    mov     al, [ebp+0]
    mov     [ebp+0], dl
    inc     ebp
    mov     [ecx], al
    dec     ecx
    cmp     ebp, ecx
    jb      short loc_4E0AC4

    loc_4E0AD4:                             ; CODE XREF: sub_4E07E0+2E2j
    mov     esi, dword_5295C8
    mov     byte ptr [esp+61AF8h+var_61AA8], 0
    shl     esi, 0Ch
    lea     ebp, [esp+61AF8h+var_61AA8]
    lea     ecx, [esp+61AF8h+var_61AA8]
    xor     edi, edi

    loc_4E0AEC:                             ; CODE XREF: sub_4E07E0+342j
    mov     eax, esi
    xor     edx, edx
    mov     ebx, 0Ah
    div     ebx
    mov     eax, 0CCCCCCCDh
    mov     ebx, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebx
    test    edx, edx
    jnz     short loc_4E0B20
    test    esi, esi
    jz      short loc_4E0B24
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0B20:                             ; CODE XREF: sub_4E07E0+336j
    test    esi, esi
    jnz     short loc_4E0AEC

    loc_4E0B24:                             ; CODE XREF: sub_4E07E0+33Aj
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+61AF8h+var_61AA8]
    cmp     eax, ecx
    jnb     short loc_4E0B40

    loc_4E0B30:                             ; CODE XREF: sub_4E07E0+35Ej
    mov     dl, [ecx]
    mov     al, [ebp+0]
    mov     [ebp+0], dl
    inc     ebp
    mov     [ecx], al
    dec     ecx
    cmp     ebp, ecx
    jb      short loc_4E0B30

    loc_4E0B40:                             ; CODE XREF: sub_4E07E0+34Ej
    lea     eax, [esp+61AF8h+var_61A94]
    lea     ecx, [esp+61AF8h+var_61ABC]
    push    eax
    lea     edx, [esp+61AFCh+var_61AE4]
    push    ecx
    lea     eax, [esp+61B00h+var_61AD0]
    push    edx
    mov     edx, [esp+61B04h+arg_0]
    lea     ecx, [esp+61B04h+var_61AA8]
    push    eax
    push    ecx
    push    offset aTotalWorkingSe          ; "\r\nTotal Working set:   %13s\r\nMaximum Wo"...
    push    edx
    call    _sprintf
    mov     eax, [esp+61B14h+lpCriticalSection]
    add     esp, 1Ch
    push    eax                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    pop     edi
    pop     esi
    pop     ebp
    mov     al, 1
    pop     ebx
    add     esp, 61AE8h
    retn
    sub_4E07E0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E0B90 proc near                    ; CODE XREF: sub_4E06A0+39p

    var_92C= qword ptr -92Ch
    var_924= dword ptr -924h
    Rect= tagRECT ptr -920h
    var_910= dword ptr -910h
    var_8FC= dword ptr -8FCh
    var_8E8= dword ptr -8E8h
    var_8D4= dword ptr -8D4h
    var_8C0= dword ptr -8C0h
    var_8AC= dword ptr -8ACh
    var_898= dword ptr -898h
    var_884= dword ptr -884h
    var_870= dword ptr -870h
    var_85C= dword ptr -85Ch
    var_848= dword ptr -848h
    var_834= dword ptr -834h
    String= byte ptr -7D0h
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 92Ch
    mov     eax, [esp+92Ch+arg_0]
    push    ebx
    push    ebp
    mov     ebx, ecx
    push    esi
    cmp     eax, 312h
    push    edi
    mov     [esp+93Ch+var_924], ebx
    ja      loc_4E13E7
    jz      loc_4E13C7
    sub     eax, 110h
    jz      loc_4E1366
    dec     eax
    jz      loc_4E12CE
    sub     eax, 2
    jnz     loc_4E13E7
    mov     eax, [ebx]
    push    eax                             ; hWnd
    call    ds:IsWindowVisible
    test    eax, eax
    jz      loc_4E13E7
    mov     edx, [ebx]
    lea     ecx, [esp+93Ch+Rect]
    push    ecx                             ; lpRect
    push    edx                             ; hWnd
    call    ds:GetWindowRect
    mov     eax, [esp+93Ch+Rect.left]
    mov     ecx, [ebx+8]
    cmp     eax, ecx
    mov     ecx, [esp+93Ch+Rect.top]
    jnz     short loc_4E0C06
    cmp     ecx, [ebx+0Ch]
    jz      short loc_4E0C1D

    loc_4E0C06:                             ; CODE XREF: sub_4E0B90+6Fj
    mov     [ebx+8], eax
    mov     [ebx+0Ch], ecx
    mov     eax, lpSubKey
    mov     ecx, [ebx]
    push    eax
    push    ecx
    call    sub_4E3400
    add     esp, 8

    loc_4E0C1D:                             ; CODE XREF: sub_4E0B90+74j
    mov     edx, dword_528A04
    mov     edi, [ebx+4]
    sub     edx, edi
    mov     dword ptr [esp+93Ch+var_92C], edx
    call    sub_4E1730
    fld     st
    fsub    qword ptr [ebx+10h]
    fild    dword ptr [esp+93Ch+var_92C]
    fxch    st(1)
    fxch    st(2)
    fxch    st(1)
    fdiv    st, st(2)
    lea     eax, [ebx+18h]
    fst     [esp+93Ch+var_92C]
    fxch    st(1)
    fstp    qword ptr [ebx+10h]
    mov     ecx, [eax+58h]
    fadd    qword ptr [eax+50h]
    fld     [esp+93Ch+var_92C]
    fxch    st(1)
    fsub    qword ptr [eax+ecx*8]
    lea     ecx, [eax+ecx*8]
    fstp    qword ptr [eax+50h]
    fstp    qword ptr [ecx]
    mov     esi, [eax+58h]
    inc     esi
    mov     ecx, esi
    mov     [eax+58h], esi
    cmp     ecx, 0Ah
    fstp    st
    jnz     short loc_4E0C7C
    mov     dword ptr [eax+58h], 0

    loc_4E0C7C:                             ; CODE XREF: sub_4E0B90+E3j
    mov     edx, dword_528A04
    mov     ecx, 1F3h
    mov     [ebx+4], edx
    mov     al, Data
    mov     [esp+93Ch+String], al
    xor     eax, eax
    lea     edi, [esp+16Dh]
    rep stosd
    stosw
    stosb
    mov     eax, dword_5289FC
    test    eax, eax
    jz      loc_4E0DF8
    mov     ecx, dword_5289DC
    mov     byte ptr [esp+93Ch+var_8AC], 0
    lea     ebx, [esp+93Ch+var_8AC]
    xor     edi, edi
    lea     esi, [ecx+3B9ACA00h]
    lea     ecx, [esp+93Ch+var_8AC]

    loc_4E0CD5:                             ; CODE XREF: sub_4E0B90+17Bj
    mov     eax, esi
    xor     edx, edx
    mov     ebp, 0Ah
    div     ebp
    mov     eax, 0CCCCCCCDh
    mov     ebp, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebp
    test    edx, edx
    jnz     short loc_4E0D09
    test    esi, esi
    jz      short loc_4E0D0D
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0D09:                             ; CODE XREF: sub_4E0B90+16Fj
    test    esi, esi
    jnz     short loc_4E0CD5

    loc_4E0D0D:                             ; CODE XREF: sub_4E0B90+173j
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     edx, [esp+93Ch+var_8AC]
    cmp     edx, ecx
    jnb     short loc_4E0D2A

    loc_4E0D1C:                             ; CODE XREF: sub_4E0B90+198j
    mov     dl, [ecx]
    mov     al, [ebx]
    mov     [ebx], dl
    inc     ebx
    mov     [ecx], al
    dec     ecx
    cmp     ebx, ecx
    jb      short loc_4E0D1C

    loc_4E0D2A:                             ; CODE XREF: sub_4E0B90+18Aj
    lea     edi, [esp+93Ch+var_8AC]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+93Ch+var_848]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     byte ptr [esp+93Ch+var_884], 0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    lea     ebp, [esp+93Ch+var_884]
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     esi, dword_5289FC
    lea     ecx, [esp+93Ch+var_884]
    xor     edi, edi

    loc_4E0D73:                             ; CODE XREF: sub_4E0B90+219j
    mov     eax, esi
    xor     edx, edx
    mov     ebx, 0Ah
    div     ebx
    mov     eax, 0CCCCCCCDh
    mov     ebx, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebx
    test    edx, edx
    jnz     short loc_4E0DA7
    test    esi, esi
    jz      short loc_4E0DAB
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0DA7:                             ; CODE XREF: sub_4E0B90+20Dj
    test    esi, esi
    jnz     short loc_4E0D73

    loc_4E0DAB:                             ; CODE XREF: sub_4E0B90+211j
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     edx, [esp+93Ch+var_884]
    cmp     edx, ecx
    jnb     short loc_4E0DCA

    loc_4E0DBA:                             ; CODE XREF: sub_4E0B90+238j
    mov     dl, [ecx]
    mov     al, [ebp+0]
    mov     [ebp+0], dl
    inc     ebp
    mov     [ecx], al
    dec     ecx
    cmp     ebp, ecx
    jb      short loc_4E0DBA

    loc_4E0DCA:                             ; CODE XREF: sub_4E0B90+228j
    lea     eax, [esp+93Ch+var_848+2]
    lea     ecx, [esp+93Ch+var_884]
    push    eax
    push    ecx
    lea     edx, [esp+944h+var_834]
    push    offset aSS_3                    ; "%s,%s"
    push    edx
    call    _sprintf
    mov     ebx, [esp+94Ch+var_924]
    add     esp, 10h
    jmp     loc_4E0E81
    ; ---------------------------------------------------------------------------

    loc_4E0DF8:                             ; CODE XREF: sub_4E0B90+11Bj
    mov     esi, dword_5289DC
    lea     eax, [esp+93Ch+var_8D4]
    mov     byte ptr [esp+93Ch+var_8D4], 0
    mov     dword ptr [esp+93Ch+var_92C], eax
    lea     ecx, [esp+93Ch+var_8D4]
    xor     edi, edi

    loc_4E0E11:                             ; CODE XREF: sub_4E0B90+2B7j
    mov     eax, esi
    xor     edx, edx
    mov     ebp, 0Ah
    div     ebp
    mov     eax, 0CCCCCCCDh
    mov     ebp, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebp
    test    edx, edx
    jnz     short loc_4E0E45
    test    esi, esi
    jz      short loc_4E0E49
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0E45:                             ; CODE XREF: sub_4E0B90+2ABj
    test    esi, esi
    jnz     short loc_4E0E11

    loc_4E0E49:                             ; CODE XREF: sub_4E0B90+2AFj
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     edx, [esp+93Ch+var_8D4]
    cmp     edx, ecx
    jnb     short loc_4E0E67
    mov     esi, dword ptr [esp+93Ch+var_92C]

    loc_4E0E59:                             ; CODE XREF: sub_4E0B90+2D5j
    mov     dl, [ecx]
    mov     al, [esi]
    mov     [esi], dl
    inc     esi
    mov     [ecx], al
    dec     ecx
    cmp     esi, ecx
    jb      short loc_4E0E59

    loc_4E0E67:                             ; CODE XREF: sub_4E0B90+2C3j
    lea     eax, [esp+93Ch+var_8D4]
    lea     ecx, [esp+93Ch+var_834]
    push    eax
    push    offset aS_1                     ; "%s"
    push    ecx
    call    _sprintf
    add     esp, 0Ch

    loc_4E0E81:                             ; CODE XREF: sub_4E0B90+263j
    fld     qword ptr [ebx+68h]
    fmul    ds:dbl_4FDC38
    fcom    ds:dbl_4FDC40
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4E0E9D
    fstp    [esp+93Ch+var_92C]
    jmp     short loc_4E0EAF
    ; ---------------------------------------------------------------------------

    loc_4E0E9D:                             ; CODE XREF: sub_4E0B90+305j
    fstp    st
    mov     dword ptr [esp+93Ch+var_92C], 0
    mov     dword ptr [esp+93Ch+var_92C+4], 0

    loc_4E0EAF:                             ; CODE XREF: sub_4E0B90+30Bj
    mov     esi, dword_5289D0
    mov     byte ptr [esp+93Ch+var_85C], 0
    lea     ebx, [esp+93Ch+var_85C]
    lea     ecx, [esp+93Ch+var_85C]
    xor     edi, edi

    loc_4E0ECD:                             ; CODE XREF: sub_4E0B90+373j
    mov     eax, esi
    xor     edx, edx
    mov     ebp, 0Ah
    div     ebp
    mov     eax, 0CCCCCCCDh
    mov     ebp, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebp
    test    edx, edx
    jnz     short loc_4E0F01
    test    esi, esi
    jz      short loc_4E0F05
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0F01:                             ; CODE XREF: sub_4E0B90+367j
    test    esi, esi
    jnz     short loc_4E0ECD

    loc_4E0F05:                             ; CODE XREF: sub_4E0B90+36Bj
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     edx, [esp+93Ch+var_85C]
    cmp     edx, ecx
    jnb     short loc_4E0F22

    loc_4E0F14:                             ; CODE XREF: sub_4E0B90+390j
    mov     dl, [ecx]
    mov     al, [ebx]
    mov     [ebx], dl
    inc     ebx
    mov     [ecx], al
    dec     ecx
    cmp     ebx, ecx
    jb      short loc_4E0F14

    loc_4E0F22:                             ; CODE XREF: sub_4E0B90+382j
    mov     esi, dword_5289F0
    mov     byte ptr [esp+93Ch+var_910], 0
    lea     ebx, [esp+93Ch+var_910]
    lea     ecx, [esp+93Ch+var_910]
    xor     edi, edi

    loc_4E0F37:                             ; CODE XREF: sub_4E0B90+3DDj
    mov     eax, esi
    xor     edx, edx
    mov     ebp, 0Ah
    div     ebp
    mov     eax, 0CCCCCCCDh
    mov     ebp, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebp
    test    edx, edx
    jnz     short loc_4E0F6B
    test    esi, esi
    jz      short loc_4E0F6F
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0F6B:                             ; CODE XREF: sub_4E0B90+3D1j
    test    esi, esi
    jnz     short loc_4E0F37

    loc_4E0F6F:                             ; CODE XREF: sub_4E0B90+3D5j
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+93Ch+var_910]
    cmp     eax, ecx
    jnb     short loc_4E0F89

    loc_4E0F7B:                             ; CODE XREF: sub_4E0B90+3F7j
    mov     dl, [ecx]
    mov     al, [ebx]
    mov     [ebx], dl
    inc     ebx
    mov     [ecx], al
    dec     ecx
    cmp     ebx, ecx
    jb      short loc_4E0F7B

    loc_4E0F89:                             ; CODE XREF: sub_4E0B90+3E9j
    mov     esi, dword_5289D8
    mov     byte ptr [esp+93Ch+var_870], 0
    lea     ebx, [esp+93Ch+var_870]
    lea     ecx, [esp+93Ch+var_870]
    xor     edi, edi

    loc_4E0FA7:                             ; CODE XREF: sub_4E0B90+44Dj
    mov     eax, esi
    xor     edx, edx
    mov     ebp, 0Ah
    div     ebp
    mov     eax, 0CCCCCCCDh
    mov     ebp, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebp
    test    edx, edx
    jnz     short loc_4E0FDB
    test    esi, esi
    jz      short loc_4E0FDF
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E0FDB:                             ; CODE XREF: sub_4E0B90+441j
    test    esi, esi
    jnz     short loc_4E0FA7

    loc_4E0FDF:                             ; CODE XREF: sub_4E0B90+445j
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+93Ch+var_870]
    cmp     eax, ecx
    jnb     short loc_4E0FFC

    loc_4E0FEE:                             ; CODE XREF: sub_4E0B90+46Aj
    mov     dl, [ecx]
    mov     al, [ebx]
    mov     [ebx], dl
    inc     ebx
    mov     [ecx], al
    dec     ecx
    cmp     ebx, ecx
    jb      short loc_4E0FEE

    loc_4E0FFC:                             ; CODE XREF: sub_4E0B90+45Cj
    mov     esi, dword_5289F8
    mov     byte ptr [esp+93Ch+var_8FC], 0
    lea     ebx, [esp+93Ch+var_8FC]
    lea     ecx, [esp+93Ch+var_8FC]
    xor     edi, edi

    loc_4E1011:                             ; CODE XREF: sub_4E0B90+4B7j
    mov     eax, esi
    xor     edx, edx
    mov     ebp, 0Ah
    div     ebp
    mov     eax, 0CCCCCCCDh
    mov     ebp, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebp
    test    edx, edx
    jnz     short loc_4E1045
    test    esi, esi
    jz      short loc_4E1049
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E1045:                             ; CODE XREF: sub_4E0B90+4ABj
    test    esi, esi
    jnz     short loc_4E1011

    loc_4E1049:                             ; CODE XREF: sub_4E0B90+4AFj
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+93Ch+var_8FC]
    cmp     eax, ecx
    jnb     short loc_4E1063

    loc_4E1055:                             ; CODE XREF: sub_4E0B90+4D1j
    mov     dl, [ecx]
    mov     al, [ebx]
    mov     [ebx], dl
    inc     ebx
    mov     [ecx], al
    dec     ecx
    cmp     ebx, ecx
    jb      short loc_4E1055

    loc_4E1063:                             ; CODE XREF: sub_4E0B90+4C3j
    mov     eax, [esp+93Ch+var_924]
    mov     byte ptr [esp+93Ch+var_8E8], 0
    lea     ebp, [esp+93Ch+var_8E8]
    lea     ecx, [esp+93Ch+var_8E8]
    mov     esi, [eax+4]
    xor     edi, edi

    loc_4E1079:                             ; CODE XREF: sub_4E0B90+51Fj
    mov     eax, esi
    xor     edx, edx
    mov     ebx, 0Ah
    div     ebx
    mov     eax, 0CCCCCCCDh
    mov     ebx, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebx
    test    edx, edx
    jnz     short loc_4E10AD
    test    esi, esi
    jz      short loc_4E10B1
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E10AD:                             ; CODE XREF: sub_4E0B90+513j
    test    esi, esi
    jnz     short loc_4E1079

    loc_4E10B1:                             ; CODE XREF: sub_4E0B90+517j
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     edx, [esp+93Ch+var_8E8]
    cmp     edx, ecx
    jnb     short loc_4E10CD

    loc_4E10BD:                             ; CODE XREF: sub_4E0B90+53Bj
    mov     dl, [ecx]
    mov     al, [ebp+0]
    mov     [ebp+0], dl
    inc     ebp
    mov     [ecx], al
    dec     ecx
    cmp     ebp, ecx
    jb      short loc_4E10BD

    loc_4E10CD:                             ; CODE XREF: sub_4E0B90+52Bj
    mov     esi, dword_528A1C
    mov     byte ptr [esp+93Ch+var_8C0], 0
    lea     ebx, [esp+93Ch+var_8C0]
    lea     ecx, [esp+93Ch+var_8C0]
    xor     edi, edi

    loc_4E10E2:                             ; CODE XREF: sub_4E0B90+588j
    mov     eax, esi
    xor     edx, edx
    mov     ebp, 0Ah
    div     ebp
    mov     eax, 0CCCCCCCDh
    mov     ebp, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebp
    test    edx, edx
    jnz     short loc_4E1116
    test    esi, esi
    jz      short loc_4E111A
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E1116:                             ; CODE XREF: sub_4E0B90+57Cj
    test    esi, esi
    jnz     short loc_4E10E2

    loc_4E111A:                             ; CODE XREF: sub_4E0B90+580j
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+93Ch+var_8C0]
    cmp     eax, ecx
    jnb     short loc_4E1134

    loc_4E1126:                             ; CODE XREF: sub_4E0B90+5A2j
    mov     dl, [ecx]
    mov     al, [ebx]
    mov     [ebx], dl
    inc     ebx
    mov     [ecx], al
    dec     ecx
    cmp     ebx, ecx
    jb      short loc_4E1126

    loc_4E1134:                             ; CODE XREF: sub_4E0B90+594j
    mov     esi, dword_528A08
    mov     byte ptr [esp+93Ch+var_898], 0
    lea     ebx, [esp+93Ch+var_898]
    lea     ecx, [esp+93Ch+var_898]
    xor     edi, edi

    loc_4E1152:                             ; CODE XREF: sub_4E0B90+5F8j
    mov     eax, esi
    xor     edx, edx
    mov     ebp, 0Ah
    div     ebp
    mov     eax, 0CCCCCCCDh
    mov     ebp, 3
    add     dl, 30h
    mov     [ecx], dl
    mul     esi
    inc     ecx
    shr     edx, 3
    inc     edi
    mov     esi, edx
    mov     eax, edi
    cdq
    idiv    ebp
    test    edx, edx
    jnz     short loc_4E1186
    test    esi, esi
    jz      short loc_4E118A
    mov     byte ptr [ecx], 2Ch
    inc     ecx

    loc_4E1186:                             ; CODE XREF: sub_4E0B90+5ECj
    test    esi, esi
    jnz     short loc_4E1152

    loc_4E118A:                             ; CODE XREF: sub_4E0B90+5F0j
    mov     byte ptr [ecx], 0
    dec     ecx
    lea     eax, [esp+93Ch+var_898]
    cmp     eax, ecx
    jnb     short loc_4E11A7

    loc_4E1199:                             ; CODE XREF: sub_4E0B90+615j
    mov     dl, [ecx]
    mov     al, [ebx]
    mov     [ebx], dl
    inc     ebx
    mov     [ecx], al
    dec     ecx
    cmp     ebx, ecx
    jb      short loc_4E1199

    loc_4E11A7:                             ; CODE XREF: sub_4E0B90+607j
    mov     edx, dword_5289D4
    lea     eax, [esp+93Ch+var_85C]
    lea     ecx, [esp+93Ch+var_910]
    push    eax
    mov     eax, dword_528A00
    push    ecx
    push    edx
    lea     ecx, [esp+948h+var_834]
    push    eax
    lea     edx, [esp+94Ch+var_870]
    push    ecx
    mov     ecx, dword ptr [esp+950h+var_92C+4]
    lea     eax, [esp+950h+var_8FC]
    push    edx
    mov     edx, dword ptr [esp+954h+var_92C]
    push    eax
    push    ecx
    lea     eax, [esp+95Ch+var_8E8]
    push    edx
    lea     ecx, [esp+960h+var_8C0]
    push    eax
    lea     edx, [esp+964h+var_898]
    push    ecx
    push    edx
    lea     eax, [esp+96Ch+String]
    push    offset aCurrentAllocat          ; "Current Allocations:  %13s\r\nMax Allocat"...
    push    eax
    call    _sprintf
    mov     ebp, [esp+974h+var_924]
    add     esp, 38h
    mov     al, [ebp+79h]
    test    al, al
    jz      short loc_4E1236
    lea     edi, [esp+93Ch+String]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    lea     ecx, [esp+ecx+93Ch+String]
    push    ecx
    call    sub_4E07E0
    add     esp, 4

    loc_4E1236:                             ; CODE XREF: sub_4E0B90+683j
    lea     esi, [esp+93Ch+String]
    mov     eax, offset dword_5295D8

    loc_4E1242:                             ; CODE XREF: sub_4E0B90+6D4j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4E126A
    test    cl, cl
    jz      short loc_4E1266
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4E126A
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4E1242

    loc_4E1266:                             ; CODE XREF: sub_4E0B90+6BEj
    xor     eax, eax
    jmp     short loc_4E126F
    ; ---------------------------------------------------------------------------

    loc_4E126A:                             ; CODE XREF: sub_4E0B90+6BAj
                                            ; sub_4E0B90+6CAj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4E126F:                             ; CODE XREF: sub_4E0B90+6D8j
    test    eax, eax
    jz      loc_4E13E7
    mov     ecx, [ebp+0]
    lea     eax, [esp+93Ch+String]
    push    eax                             ; lpString
    push    3E8h                            ; nIDDlgItem
    push    ecx                             ; hDlg
    call    ds:SetDlgItemTextA
    mov     edx, [ebp+0]
    push    edx                             ; hWnd
    call    ds:UpdateWindow
    lea     edi, [esp+93Ch+String]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, offset dword_5295D8
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    xor     eax, eax
    rep movsb
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 92Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4E12CE:                             ; CODE XREF: sub_4E0B90+34j
    mov     eax, [esp+93Ch+arg_4]
    and     eax, 0FFFFh
    cmp     eax, 3EBh
    jg      short loc_4E130F
    jz      short loc_4E12FB
    test    eax, eax
    jle     loc_4E13E7
    cmp     eax, 2
    jg      loc_4E13E7
    push    0
    jmp     loc_4E13E0
    ; ---------------------------------------------------------------------------

    loc_4E12FB:                             ; CODE XREF: sub_4E0B90+751j
    call    sub_4DA860
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 92Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4E130F:                             ; CODE XREF: sub_4E0B90+74Fj
    sub     eax, 3F9h
    jz      short loc_4E1341
    dec     eax
    jnz     loc_4E13E7
    mov     ecx, [ebx]
    push    offset a_htm                    ; ".htm"
    push    offset aHttp10_0_150_0          ; "http://10.0.150.18/programming/library/"...
    push    ecx
    call    sub_4DA5B0
    add     esp, 0Ch
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 92Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4E1341:                             ; CODE XREF: sub_4E0B90+784j
    mov     cl, [ebx+79h]
    xor     edx, edx
    test    cl, cl
    setz    dl
    push    0
    mov     ecx, ebx
    mov     [ebx+79h], dl
    call    sub_4E0520
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 92Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4E1366:                             ; CODE XREF: sub_4E0B90+2Dj
    mov     ecx, [ebx]
    lea     eax, [esp+93Ch+Rect]
    push    eax                             ; lpRect
    push    ecx                             ; hWnd
    call    ds:GetWindowRect
    mov     ecx, [ebx]
    mov     edx, [esp+93Ch+Rect.left]
    mov     eax, [esp+93Ch+Rect.top]
    push    23h                             ; vk
    push    1                               ; fsModifiers
    push    0Ah                             ; id
    push    ecx                             ; hWnd
    mov     [ebx+8], edx
    mov     [ebx+0Ch], eax
    call    ds:RegisterHotKey
    mov     eax, [ebx]
    xor     edx, edx
    mov     dl, [ebx+79h]
    push    edx                             ; uCheck
    push    3F9h                            ; nIDButton
    push    eax                             ; hDlg
    call    ds:CheckDlgButton               ; Change the check state of a button control
    mov     al, [ebx+78h]
    test    al, al
    jz      short loc_4E13B5
    push    1
    mov     ecx, ebx
    call    sub_4E05F0

    loc_4E13B5:                             ; CODE XREF: sub_4E0B90+81Aj
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 92Ch
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4E13C7:                             ; CODE XREF: sub_4E0B90+22j
    cmp     [esp+93Ch+arg_4], 0Ah
    jnz     short loc_4E13E7
    mov     ecx, [ebx]
    push    ecx                             ; hWnd
    call    ds:IsWindowVisible
    neg     eax
    sbb     eax, eax
    inc     eax
    push    eax

    loc_4E13E0:                             ; CODE XREF: sub_4E0B90+766j
    mov     ecx, ebx
    call    sub_4E05F0

    loc_4E13E7:                             ; CODE XREF: sub_4E0B90+1Cj
                                            ; sub_4E0B90+3Dj ...
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 92Ch
    retn    0Ch
    sub_4E0B90 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_4E1400:                             ; CODE XREF: sub_4E1460+16j
    push    1
    call    sub_4E1410
    mov     ecx, eax
    call    sub_4E05F0
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1410 proc near                    ; CODE XREF: .text:004E1402p
                                            ; sub_4E1460p
    mov     cl, byte_52952C
    mov     al, 1
    test    al, cl
    jnz     short loc_4E143D
    mov     dl, cl
    mov     ecx, offset dword_529538
    or      dl, al
    mov     byte_52952C, dl
    call    sub_4E0570
    push    offset nullsub_29               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4E143D:                             ; CODE XREF: sub_4E1410+Aj
    mov     eax, offset dword_529538
    retn
    sub_4E1410 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_29. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1460 proc near                    ; CODE XREF: sub_4DA2E0+28p
    call    sub_4E1410
    push    offset aMemorystatus            ; "-memorystatus"
    call    sub_4D9F60
    add     esp, 4
    test    eax, eax
    jz      short locret_4E147B
    jmp     loc_4E1400
    ; ---------------------------------------------------------------------------

    locret_4E147B:                          ; CODE XREF: sub_4E1460+14j
    retn
    sub_4E1460 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000086 BYTES: COLLAPSED FUNCTION std::_Lockit::_Lockit(void). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000027 BYTES: COLLAPSED FUNCTION std::_CleanUp(void). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000015 BYTES: COLLAPSED FUNCTION std::_Lockit::~_Lockit(void). PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4E1560(LPCSTR lpFileName)
    sub_4E1560 proc near                    ; CODE XREF: sub_4DDF00+Bp

    lpFileName= dword ptr  8

    push    esi
    mov     esi, ecx
    mov     ecx, [esp+lpFileName]
    xor     eax, eax
    cmp     ecx, eax
    mov     dword ptr [esi], 0FFFFFFFFh
    mov     [esi+4], eax
    mov     [esi+8], eax
    mov     [esi+0Ch], eax
    mov     [esi+10h], eax
    jz      short loc_4E1587
    push    ecx                             ; lpFileName
    mov     ecx, esi
    call    sub_4E1590

    loc_4E1587:                             ; CODE XREF: sub_4E1560+1Dj
    mov     eax, esi
    pop     esi
    retn    4
    sub_4E1560 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4E1590(LPCSTR lpFileName)
    sub_4E1590 proc near                    ; CODE XREF: sub_4DDF00+4Bp
                                            ; sub_4E1560+22p

    lpFileName= dword ptr  4

    mov     eax, [esp+lpFileName]
    push    esi
    push    edi
    push    0                               ; hTemplateFile
    push    80h                             ; dwFlagsAndAttributes
    push    3                               ; dwCreationDisposition
    push    0                               ; lpSecurityAttributes
    push    1                               ; dwShareMode
    push    80000000h                       ; dwDesiredAccess
    mov     esi, ecx
    push    eax                             ; lpFileName
    call    ds:CreateFileA
    cmp     eax, 0FFFFFFFFh
    mov     [esi], eax
    jnz     short loc_4E15C4
    mov     dword ptr [esi+10h], 1
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4E15C4:                             ; CODE XREF: sub_4E1590+26j
    push    0                               ; lpFileSizeHigh
    push    eax                             ; hFile
    call    ds:GetFileSize
    mov     ecx, [esi]
    push    0                               ; lpName
    push    0                               ; dwMaximumSizeLow
    push    0                               ; dwMaximumSizeHigh
    push    2                               ; flProtect
    push    0                               ; lpFileMappingAttributes
    push    ecx                             ; hFile
    mov     [esi+0Ch], eax
    call    ds:CreateFileMappingA
    test    eax, eax
    mov     [esi+4], eax
    jnz     short loc_4E1605
    mov     edx, [esi]
    push    edx                             ; hObject
    call    ds:CloseHandle
    mov     dword ptr [esi], 0FFFFFFFFh
    mov     dword ptr [esi+10h], 2
    pop     edi
    pop     esi
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4E1605:                             ; CODE XREF: sub_4E1590+58j
    push    0                               ; dwNumberOfBytesToMap
    push    0                               ; dwFileOffsetLow
    push    0                               ; dwFileOffsetHigh
    push    4                               ; dwDesiredAccess
    push    eax                             ; hFileMappingObject
    call    ds:MapViewOfFile
    test    eax, eax
    mov     [esi+8], eax
    jnz     short loc_4E1640
    mov     eax, [esi+4]
    mov     edi, ds:CloseHandle
    push    eax                             ; hObject
    call    edi ; CloseHandle
    mov     ecx, [esi]
    mov     dword ptr [esi+4], 0
    push    ecx                             ; hObject
    call    edi ; CloseHandle
    mov     dword ptr [esi], 0FFFFFFFFh
    mov     dword ptr [esi+10h], 3

    loc_4E1640:                             ; CODE XREF: sub_4E1590+89j
    pop     edi
    pop     esi
    retn    4
    sub_4E1590 endp

    ; ---------------------------------------------------------------------------
    align 10h

    loc_4E1650:                             ; CODE XREF: .text:004DE0F5j
    push    esi
    mov     esi, ecx
    push    edi
    mov     eax, [esi+8]
    test    eax, eax
    jz      short loc_4E1662
    push    eax
    call    ds:UnmapViewOfFile

    loc_4E1662:                             ; CODE XREF: .text:004E1659j
    mov     eax, [esi+4]
    mov     edi, ds:CloseHandle
    test    eax, eax
    jz      short loc_4E1672
    push    eax
    call    edi ; CloseHandle

    loc_4E1672:                             ; CODE XREF: .text:004E166Dj
    mov     esi, [esi]
    cmp     esi, 0FFFFFFFFh
    jz      short loc_4E167C
    push    esi
    call    edi ; CloseHandle

    loc_4E167C:                             ; CODE XREF: .text:004E1677j
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1680 proc near                    ; CODE XREF: sub_4DF4E0+7p
                                            ; sub_4E1BE0+2Fp ...
    mov     al, byte_529E6C
    test    al, al
    jnz     short loc_4E16A0
    mov     byte_529E6C, 1
    call    sub_4E35B0
    test    al, al
    jz      short loc_4E16A0
    mov     byte_529E70, 1

    loc_4E16A0:                             ; CODE XREF: sub_4E1680+7j
                                            ; sub_4E1680+17j
    mov     al, byte_529E70
    retn
    sub_4E1680 endp

    ; ---------------------------------------------------------------------------
    align 10h
    push    ebp
    mov     ebp, esp
    push    ecx
    mov     al, byte_529E74
    push    ebx
    test    al, al
    jnz     short loc_4E16F0
    mov     byte_529E74, 1
    call    sub_4E1700
    test    al, al
    jz      short loc_4E16F0
    push    eax
    push    ebx
    push    ecx
    push    edx
    mov     eax, 1
    cpuid
    mov     [ebp-4], edx
    pop     edx
    pop     ecx
    pop     ebx
    pop     eax
    test    dword ptr [ebp-4], 800000h
    jz      short loc_4E16F0
    mov     byte_529E78, 1

    loc_4E16F0:                             ; CODE XREF: .text:004E16BCj
                                            ; .text:004E16CCj ...
    mov     al, byte_529E78
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1700 proc near                    ; CODE XREF: .text:004E16C5p

    SystemInfo= _SYSTEM_INFO ptr -24h

    sub     esp, 24h
    lea     eax, [esp+24h+SystemInfo]
    push    eax                             ; lpSystemInfo
    call    ds:GetSystemInfo
    mov     eax, [esp+24h+SystemInfo.dwProcessorType]
    cmp     eax, 182h
    jz      short loc_4E1726
    cmp     eax, 1E6h
    jz      short loc_4E1726
    mov     al, 1
    add     esp, 24h
    retn
    ; ---------------------------------------------------------------------------

    loc_4E1726:                             ; CODE XREF: sub_4E1700+17j
                                            ; sub_4E1700+1Ej
    xor     al, al
    add     esp, 24h
    retn
    sub_4E1700 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1730 proc near                    ; CODE XREF: sub_4DF1E0+53p
                                            ; sub_4E0570+2Cp ...

    PerformanceCount= LARGE_INTEGER ptr -28h
    FileTime= _FILETIME ptr -20h
    Frequency= LARGE_INTEGER ptr -18h
    SystemTime= SYSTEMTIME ptr -10h

    sub     esp, 28h
    lea     eax, [esp+28h+Frequency]
    push    esi
    push    eax                             ; lpFrequency
    call    ds:QueryPerformanceFrequency
    lea     ecx, [esp+2Ch+PerformanceCount]
    mov     esi, eax
    push    ecx                             ; lpPerformanceCount
    call    ds:QueryPerformanceCounter
    cmp     esi, 1
    jnz     short loc_4E1764
    cmp     eax, esi
    jnz     short loc_4E1764
    fild    qword ptr [esp+2Ch+PerformanceCount]
    fild    qword ptr [esp+2Ch+Frequency]
    fdivp   st(1), st
    pop     esi
    add     esp, 28h
    retn
    ; ---------------------------------------------------------------------------

    loc_4E1764:                             ; CODE XREF: sub_4E1730+1Fj
                                            ; sub_4E1730+23j
    lea     edx, [esp+2Ch+SystemTime]
    push    edx                             ; lpSystemTime
    call    ds:GetSystemTime
    lea     eax, [esp+2Ch+FileTime]
    lea     ecx, [esp+2Ch+SystemTime]
    push    eax                             ; lpFileTime
    push    ecx                             ; lpSystemTime
    call    ds:SystemTimeToFileTime
    mov     edx, [esp+2Ch+FileTime.dwLowDateTime]
    mov     ecx, [esp+2Ch+FileTime.dwHighDateTime]
    xor     eax, eax
    mov     dword ptr [esp+2Ch+PerformanceCount], edx
    mov     dword ptr [esp+2Ch+PerformanceCount+4], eax
    mov     [esp+2Ch+FileTime.dwLowDateTime], ecx
    fild    qword ptr [esp+2Ch+PerformanceCount]
    mov     [esp+2Ch+FileTime.dwHighDateTime], eax
    pop     esi
    fild    qword ptr [esp+28h+FileTime.dwLowDateTime]
    fmul    ds:dbl_4FDC48
    fsubp   st(1), st
    fmul    ds:dbl_4FDC50
    add     esp, 28h
    retn
    sub_4E1730 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E17C0 proc near                    ; CODE XREF: sub_4DF1E0+24p
                                            ; sub_4E1A90+19p

    var_9= byte ptr -9
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 0Ch
    mov     al, [esp+0Ch+var_9]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    xor     ebx, ebx
    mov     cl, [esp+1Ch+var_9]
    mov     [edi+1], cl
    lea     ecx, [esp+1Ch+var_4]
    mov     [edi], al
    mov     [edi+8], bl
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    cmp     dword_5292C4, ebx
    jnz     short loc_4E1815
    push    208h
    mov     ecx, edi
    call    sub_4E2B60
    mov     [eax+4], ebx
    mov     dword ptr [eax+204h], 1
    mov     dword_5292C4, eax
    mov     [eax], ebx
    mov     edx, dword_5292C4
    mov     [edx+8], ebx

    loc_4E1815:                             ; CODE XREF: sub_4E17C0+2Aj
    mov     eax, dword_5292C4
    mov     edx, dword_529500
    mov     [esp+1Ch+var_8], eax
    mov     eax, dword_529E58
    inc     edx
    cmp     eax, ebx
    mov     dword_529500, edx
    jnz     short loc_4E1883
    mov     ebp, ds:GlobalAlloc

    loc_4E183A:                             ; CODE XREF: sub_4E17C0+9Dj
    push    2000h                           ; dwBytes
    push    ebx                             ; uFlags
    call    ebp ; GlobalAlloc
    mov     esi, eax
    cmp     esi, ebx
    jnz     short loc_4E1867
    mov     eax, dword_5289BC
    cmp     eax, ebx
    jz      short loc_4E1853
    call    eax

    loc_4E1853:                             ; CODE XREF: sub_4E17C0+8Fj
    cmp     esi, ebx
    jnz     short loc_4E1867
    cmp     dword_5289BC, ebx
    jnz     short loc_4E183A
    cmp     esi, ebx
    jnz     short loc_4E1867
    xor     eax, eax
    jmp     short loc_4E188B
    ; ---------------------------------------------------------------------------

    loc_4E1867:                             ; CODE XREF: sub_4E17C0+86j
                                            ; sub_4E17C0+95j ...
    mov     eax, dword_529E58
    mov     ecx, 0Fh

    loc_4E1871:                             ; CODE XREF: sub_4E17C0+BCj
    mov     [esi], eax
    mov     eax, esi
    add     esi, 208h
    dec     ecx
    jnz     short loc_4E1871
    mov     dword_529E58, eax

    loc_4E1883:                             ; CODE XREF: sub_4E17C0+72j
    mov     ecx, [eax]
    mov     dword_529E58, ecx

    loc_4E188B:                             ; CODE XREF: sub_4E17C0+A5j
    mov     edx, [esp+1Ch+var_8]
    mov     [eax+204h], ebx
    mov     [eax+4], edx
    mov     [edi+4], eax
    mov     [edi+0Ch], ebx
    mov     [eax], eax
    mov     eax, [edi+4]
    lea     ecx, [esp+1Ch+var_4]
    mov     [eax+8], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     [edi+10h], bl
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn
    sub_4E17C0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E18C0 proc near                    ; CODE XREF: sub_4DF590+E2p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 10h
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    mov     ebx, [esi+4]
    mov     ecx, [esi+0Ch]
    test    ecx, ecx
    mov     eax, [ebx]
    mov     [esp+1Ch+var_10], eax
    jz      short loc_4E193F
    mov     edi, eax
    xor     ecx, ecx
    cmp     eax, edi
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_4E193F
    lea     ecx, [esp+1Ch+var_C]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     edx, [esi+4]
    mov     ecx, esi
    mov     eax, [edx+4]
    push    eax
    call    sub_4E03F0
    mov     ecx, [esi+4]
    mov     edx, dword_5292C4
    mov     [ecx+4], edx
    mov     eax, [esi+4]
    mov     dword ptr [esi+0Ch], 0
    mov     ecx, esi
    mov     [eax], eax
    mov     eax, [esi+4]
    mov     [eax+8], eax
    lea     eax, [esp+1Ch+var_8]
    push    eax
    call    sub_4E2240
    lea     ecx, [esp+1Ch+var_C]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     byte ptr [esi+10h], 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10h
    retn
    ; ---------------------------------------------------------------------------

    loc_4E193F:                             ; CODE XREF: sub_4E18C0+16j
                                            ; sub_4E18C0+28j
    xor     ecx, ecx
    cmp     eax, ebx
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jz      short loc_4E197B

    loc_4E194F:                             ; CODE XREF: sub_4E18C0+B9j
    lea     ecx, [esp+1Ch+var_10]
    mov     edi, eax
    call    sub_4E0450
    lea     edx, [esp+1Ch+var_4]
    push    edi
    push    edx
    mov     ecx, esi
    call    sub_4DFEA0
    mov     eax, [esp+1Ch+var_10]
    xor     ecx, ecx
    cmp     eax, ebx
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jnz     short loc_4E194F

    loc_4E197B:                             ; CODE XREF: sub_4E18C0+8Dj
    mov     byte ptr [esi+10h], 1
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 10h
    retn
    sub_4E18C0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1990 proc near                    ; CODE XREF: sub_4DF590+108p
                                            ; sub_4E1E50+23Bp

    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    esi
    push    edi
    mov     esi, ecx
    call    sub_4E1AC0
    mov     edi, eax
    push    edi                             ; lpCriticalSection
    call    ds:EnterCriticalSection
    mov     ebx, [esp+14h+arg_0]
    lea     eax, [esp+14h+arg_0]
    push    ebx
    push    eax
    mov     ecx, esi
    call    sub_4E2580
    mov     eax, [esp+14h+arg_0]
    mov     edx, [esi+4]
    xor     ecx, ecx
    cmp     eax, edx
    setz    cl
    test    cl, cl
    jnz     short loc_4E19DE
    add     eax, 0Ch
    mov     ecx, ebx
    push    eax
    call    sub_4E1A30
    test    al, al
    jnz     short loc_4E19DE
    lea     eax, [esp+14h+arg_0]
    jmp     short loc_4E19E9
    ; ---------------------------------------------------------------------------

    loc_4E19DE:                             ; CODE XREF: sub_4E1990+37j
                                            ; sub_4E1990+46j
    mov     edx, [esi+4]
    lea     eax, [esp+14h+var_8]
    mov     [esp+14h+var_8], edx

    loc_4E19E9:                             ; CODE XREF: sub_4E1990+4Cj
    mov     eax, [eax]
    mov     edx, [esi+4]
    xor     ecx, ecx
    cmp     eax, edx
    setz    cl
    neg     cl
    sbb     ecx, ecx
    inc     ecx
    test    cl, cl
    jz      short loc_4E1A0D
    lea     edx, [esp+14h+arg_0]
    push    eax
    push    edx
    mov     ecx, esi
    call    sub_4DFEA0
    jmp     short loc_4E1A11
    ; ---------------------------------------------------------------------------

    loc_4E1A0D:                             ; CODE XREF: sub_4E1990+6Cj
    mov     byte ptr [esi+10h], 1

    loc_4E1A11:                             ; CODE XREF: sub_4E1990+7Bj
    lea     eax, [esp+14h+var_8]
    push    ebx
    push    eax
    mov     ecx, esi
    call    sub_4E2250
    push    edi                             ; lpCriticalSection
    call    ds:LeaveCriticalSection
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn    4
    sub_4E1990 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1A30 proc near                    ; CODE XREF: sub_4E1990+3Fp
                                            ; sub_4E2250+104p ...

    arg_0= dword ptr  4

    mov     eax, [ecx]
    mov     ecx, [esp+arg_0]
    push    ebx
    push    esi
    mov     esi, [ecx]
    cmp     eax, esi
    jz      short loc_4E1A79

    loc_4E1A3E:                             ; CODE XREF: sub_4E1A30+30j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4E1A66
    test    cl, cl
    jz      short loc_4E1A62
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4E1A66
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4E1A3E

    loc_4E1A62:                             ; CODE XREF: sub_4E1A30+1Aj
    xor     eax, eax
    jmp     short loc_4E1A6B
    ; ---------------------------------------------------------------------------

    loc_4E1A66:                             ; CODE XREF: sub_4E1A30+16j
                                            ; sub_4E1A30+26j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4E1A6B:                             ; CODE XREF: sub_4E1A30+34j
    test    eax, eax
    jge     short loc_4E1A79
    mov     eax, 1
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4E1A79:                             ; CODE XREF: sub_4E1A30+Cj
                                            ; sub_4E1A30+3Dj
    pop     esi
    xor     eax, eax
    pop     ebx
    retn    4
    sub_4E1A30 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4E1A80(DWORD dwBytes)
    sub_4E1A80 proc near                    ; CODE XREF: sub_4E1A90+Bp

    dwBytes= dword ptr  4

    mov     eax, [esp+dwBytes]
    push    eax                             ; dwBytes
    push    0                               ; uFlags
    call    ds:GlobalAlloc
    retn
    sub_4E1A80 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1A90 proc near                    ; CODE XREF: sub_4DF380+1Cp
                                            ; sub_4DF590+95p ...
    mov     eax, dword_529E7C
    test    eax, eax
    jnz     short locret_4E1ABB
    push    14h                             ; dwBytes
    call    sub_4E1A80
    add     esp, 4
    test    eax, eax
    jz      short loc_4E1AB4
    mov     ecx, eax
    call    sub_4E17C0
    mov     dword_529E7C, eax
    retn
    ; ---------------------------------------------------------------------------

    loc_4E1AB4:                             ; CODE XREF: sub_4E1A90+15j
    xor     eax, eax
    mov     dword_529E7C, eax

    locret_4E1ABB:                          ; CODE XREF: sub_4E1A90+7j
    retn
    sub_4E1A90 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1AC0 proc near                    ; CODE XREF: sub_4DF380+Cp
                                            ; sub_4DF590+83p ...
    mov     cl, byte_529E68
    mov     al, 1
    test    al, cl
    jnz     short loc_4E1AEC
    or      cl, al
    push    offset dword_529DE0             ; lpCriticalSection
    mov     byte_529E68, cl
    call    ds:InitializeCriticalSection
    push    offset nullsub_30               ; void (*)(void)
    call    _atexit
    add     esp, 4

    loc_4E1AEC:                             ; CODE XREF: sub_4E1AC0+Aj
    mov     eax, offset dword_529DE0
    retn
    sub_4E1AC0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_30. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1B10 proc near                    ; CODE XREF: sub_4DF590+3ADp
                                            ; sub_4DF590+40Dp ...

    var_8= dword ptr -8
    phkResult= dword ptr  4

    mov     eax, [esp+phkResult]
    sub     esp, 8
    lea     ecx, [esp+8+var_8]
    push    offset aCavedoglibrary          ; int
    push    offset aPerformanceset          ; lpSubKey
    push    eax                             ; phkResult
    call    sub_4E2BE0
    push    0
    push    offset byte_529DD8
    push    offset aEnabledinrelea          ; "EnabledInRelease"
    lea     ecx, [esp+14h+var_8]
    call    sub_4E2FE0
    push    1
    push    offset byte_529DD4
    push    offset aRaisepriority           ; "RaisePriority"
    lea     ecx, [esp+14h+var_8]
    call    sub_4E2FE0
    push    0
    push    offset byte_529DDC
    push    offset aDisplayindebug          ; "DisplayInDebugger"
    lea     ecx, [esp+14h+var_8]
    call    sub_4E2FE0
    push    1
    push    offset byte_529E64
    push    offset aDisplayinwindo          ; "DisplayInWindow"
    lea     ecx, [esp+14h+var_8]
    call    sub_4E2FE0
    push    1
    push    offset byte_529DC8
    push    offset aAutopairing             ; "AutoPairing"
    lea     ecx, [esp+14h+var_8]
    call    sub_4E2FE0
    push    0
    push    0FFFFFFFFh
    push    0
    push    offset dword_529E00
    push    offset aEvent0                  ; "Event0"
    lea     ecx, [esp+1Ch+var_8]
    call    sub_4E2E20
    push    0
    push    0FFFFFFFFh
    push    0
    push    offset dword_529E10
    push    offset aEvent1                  ; "Event1"
    lea     ecx, [esp+1Ch+var_8]
    call    sub_4E2E20
    lea     ecx, [esp+8+var_8]
    call    nullsub_31
    add     esp, 8
    retn
    sub_4E1B10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1BE0 proc near                    ; CODE XREF: sub_4DF1E0+3Cp
                                            ; sub_4E20A0+12p
    mov     eax, dword_529DF8
    push    ebx
    push    ebp
    push    esi
    test    eax, eax
    push    edi
    jnz     loc_4E1D0C
    push    1
    mov     dword_529DF8, offset dword_50DA00
    mov     dword_529DCC, 11h
    call    sub_4E1B10
    add     esp, 4
    call    sub_4E1680
    test    al, al
    jz      loc_4E1D0C
    call    sub_4E39A0
    cmp     eax, 6
    jge     short loc_4E1C3E
    mov     edi, offset dword_50D980
    mov     ecx, 8
    mov     dword_529DF8, edi
    mov     dword_529DCC, ecx
    jmp     short loc_4E1C4A
    ; ---------------------------------------------------------------------------

    loc_4E1C3E:                             ; CODE XREF: sub_4E1BE0+44j
    mov     edi, dword_529DF8
    mov     ecx, dword_529DCC

    loc_4E1C4A:                             ; CODE XREF: sub_4E1BE0+5Cj
    test    ecx, ecx
    jle     short loc_4E1CB4
    mov     edx, dword_529E10
    mov     esi, dword_529E00
    mov     eax, edi

    loc_4E1C5C:                             ; CODE XREF: sub_4E1BE0+D2j
    cmp     esi, [eax]
    jnz     short loc_4E1C85
    mov     ebx, eax
    mov     esi, [ebx]
    mov     dword_529E00, esi
    mov     ebp, [ebx+4]
    mov     dword_529E04, ebp
    mov     ebp, [ebx+8]
    mov     dword_529E08, ebp
    mov     ebx, [ebx+0Ch]
    mov     dword_529E0C, ebx

    loc_4E1C85:                             ; CODE XREF: sub_4E1BE0+7Ej
    cmp     edx, [eax]
    jnz     short loc_4E1CAE
    mov     ebx, eax
    mov     edx, [ebx]
    mov     dword_529E10, edx
    mov     ebp, [ebx+4]
    mov     dword_529E14, ebp
    mov     ebp, [ebx+8]
    mov     dword_529E18, ebp
    mov     ebx, [ebx+0Ch]
    mov     dword_529E1C, ebx

    loc_4E1CAE:                             ; CODE XREF: sub_4E1BE0+A7j
    add     eax, 10h
    dec     ecx
    jnz     short loc_4E1C5C

    loc_4E1CB4:                             ; CODE XREF: sub_4E1BE0+6Cj
    mov     eax, dword_529E04
    test    eax, eax
    jnz     short loc_4E1CE2
    mov     eax, edi
    mov     ecx, [eax]
    mov     dword_529E00, ecx
    mov     edx, [eax+4]
    mov     dword_529E04, edx
    mov     ecx, [eax+8]
    mov     dword_529E08, ecx
    mov     edx, [eax+0Ch]
    mov     dword_529E0C, edx

    loc_4E1CE2:                             ; CODE XREF: sub_4E1BE0+DBj
    mov     eax, dword_529E14
    test    eax, eax
    jnz     short loc_4E1D0C
    mov     eax, [edi]
    mov     dword_529E10, eax
    mov     ecx, [edi+4]
    mov     dword_529E14, ecx
    mov     edx, [edi+8]
    mov     dword_529E18, edx
    mov     eax, [edi+0Ch]
    mov     dword_529E1C, eax

    loc_4E1D0C:                             ; CODE XREF: sub_4E1BE0+Bj
                                            ; sub_4E1BE0+36j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4E1BE0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+4]
    push    esi
    push    eax
    mov     esi, ecx
    push    0
    call    sub_4E1D60
    mov     ecx, esi
    call    sub_4E20A0
    mov     eax, esi
    pop     esi
    fstp    st
    retn    4
    ; ---------------------------------------------------------------------------
    align 4
    mov     eax, [esp+8]
    push    esi
    mov     esi, ecx
    push    eax
    mov     ecx, [esp+0Ch]
    push    ecx
    mov     ecx, esi
    call    sub_4E1D60
    mov     eax, esi
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1D60 proc near                    ; CODE XREF: .text:004E1D2Ap
                                            ; .text:004E1D4Fp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    push    esi
    mov     esi, ecx
    mov     ecx, [esp+4+arg_0]
    mov     [esi+40h], eax
    mov     [esi+44h], ecx
    mov     eax, dword_529DD0
    mov     dl, byte_529DD4
    mov     byte_529E20[eax], 9
    inc     eax
    mov     dword_529DD0, eax
    mov     al, dl
    test    al, al
    mov     [esi+49h], dl
    jz      short loc_4E1DCD
    push    edi
    call    ds:GetCurrentThread
    mov     edi, eax
    push    edi                             ; hThread
    call    ds:GetThreadPriority
    push    1                               ; nPriority
    push    edi                             ; hThread
    mov     [esi+50h], eax
    call    ds:SetThreadPriority
    call    ds:GetCurrentProcess
    mov     edi, eax
    push    edi                             ; hProcess
    call    ds:GetPriorityClass
    push    80h                             ; dwPriorityClass
    push    edi                             ; hProcess
    mov     [esi+4Ch], eax
    call    ds:SetPriorityClass
    pop     edi

    loc_4E1DCD:                             ; CODE XREF: sub_4E1D60+30j
    mov     ecx, esi
    call    sub_4E20A0
    fstp    st
    pop     esi
    retn    8
    sub_4E1D60 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, dword_529DD0
    push    esi
    dec     eax
    mov     esi, ecx
    mov     dword_529DD0, eax
    mov     byte_529E20[eax], 0
    mov     eax, [esi+44h]
    test    eax, eax
    jz      short loc_4E1E03
    push    0
    call    sub_4E1E50

    loc_4E1E03:                             ; CODE XREF: .text:004E1DFAj
    mov     al, [esi+49h]
    test    al, al
    jz      short loc_4E1E2C
    call    ds:GetCurrentProcess
    mov     ecx, [esi+4Ch]
    push    ecx
    push    eax
    call    ds:SetPriorityClass
    call    ds:GetCurrentThread
    mov     edx, [esi+50h]
    push    edx
    push    eax
    call    ds:SetThreadPriority

    loc_4E1E2C:                             ; CODE XREF: .text:004E1E08j
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E1E30 proc near                    ; CODE XREF: sub_4E1E50+8Cp
                                            ; sub_4E1E50+B5p ...
    push    esi
    mov     esi, ecx
    mov     al, [esi+48h]
    test    al, al
    jz      short loc_4E1E3E
    fld     qword ptr [esi]
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4E1E3E:                             ; CODE XREF: sub_4E1E30+8j
    call    sub_4E1730
    fsub    qword ptr [esi]
    pop     esi
    retn
    sub_4E1E30 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4E1E50 proc near                    ; CODE XREF: .text:004E1DFEp

    var_410= qword ptr -410h
    var_3FC= dword ptr -3FCh
    var_3F8= dword ptr -3F8h
    OutputString= byte ptr -204h
    var_10= qword ptr -10h
    var_8= qword ptr -8
    arg_0= dword ptr  8

    push    ebp
    mov     ebp, esp
    sub     esp, 3FCh
    mov     al, byte_529DD8
    push    ebx
    push    esi
    push    edi
    test    al, al
    mov     ebx, ecx
    jz      loc_4E2090
    call    sub_4E1680
    test    al, al
    jz      loc_4E2090
    call    sub_4E1680
    test    al, al
    jz      short loc_4E1EC7
    mov     ecx, 0
    rdpmc
    mov     dword ptr [ebp+var_8], eax
    mov     dword ptr [ebp+var_8+4], edx
    mov     ecx, 1
    rdpmc
    mov     dword ptr [ebp+var_10], eax
    mov     dword ptr [ebp+var_10+4], edx
    mov     eax, [ebx+8]
    mov     ecx, dword ptr [ebp+var_8]
    mov     edi, dword ptr [ebp+var_8+4]
    mov     edx, [ebx+10h]
    mov     esi, dword ptr [ebp+var_10]
    sub     ecx, eax
    mov     eax, [ebx+14h]
    mov     dword ptr [ebp+var_8], ecx
    mov     ecx, [ebx+0Ch]
    sbb     edi, ecx
    mov     ecx, dword ptr [ebp+var_10+4]
    sub     esi, edx
    mov     dword ptr [ebp+var_8+4], edi
    sbb     ecx, eax
    mov     dword ptr [ebp+var_10], esi
    mov     dword ptr [ebp+var_10+4], ecx

    loc_4E1EC7:                             ; CODE XREF: sub_4E1E50+2Fj
    mov     esi, [ebp+arg_0]
    test    esi, esi
    jnz     short loc_4E1EDA
    mov     ecx, [ebx+44h]
    mov     esi, ecx
    mov     [ebp+arg_0], ecx
    test    esi, esi
    jz      short loc_4E1F03

    loc_4E1EDA:                             ; CODE XREF: sub_4E1E50+7Cj
    mov     ecx, ebx
    call    sub_4E1E30
    sub     esp, 8
    lea     edx, [ebp+OutputString]
    fstp    [esp+410h+var_410]
    push    esi
    push    offset byte_529E20
    push    offset aSelapsedTimeFo          ; "%sElapsed time for '%s' is %g sec"
    push    edx
    call    _sprintf
    add     esp, 18h
    jmp     short loc_4E1F29
    ; ---------------------------------------------------------------------------

    loc_4E1F03:                             ; CODE XREF: sub_4E1E50+88j
    mov     ecx, ebx
    call    sub_4E1E30
    sub     esp, 8
    lea     eax, [ebp+OutputString]
    fstp    [esp+410h+var_410]
    push    offset byte_529E20
    push    offset aSelapsedTimeIs          ; "%sElapsed time is %g sec"
    push    eax
    call    _sprintf
    add     esp, 14h

    loc_4E1F29:                             ; CODE XREF: sub_4E1E50+B1j
    lea     esi, [ebp+eax+OutputString]
    call    sub_4E1680
    test    al, al
    jz      loc_4E1FE1
    mov     ecx, dword ptr [ebp+var_8]
    mov     edx, dword_529E04
    push    ecx
    push    edx
    push    offset byte_529E20
    push    offset aSSU                     ; "\r\n\t%s%s: %u"
    push    esi
    call    _sprintf
    mov     ecx, dword_529E10
    add     esi, eax
    mov     eax, dword_529E0C
    add     esp, 14h
    cmp     eax, ecx
    jnz     short loc_4E1F90
    fild    [ebp+var_8]
    sub     esp, 8
    fmul    ds:dbl_4FDC58
    fild    [ebp+var_10]
    fdivp   st(1), st
    fstp    [esp+410h+var_410]
    push    offset a1_2f                    ; " (%1.2f%%)"
    push    esi
    call    _sprintf
    add     esp, 10h
    add     esi, eax

    loc_4E1F90:                             ; CODE XREF: sub_4E1E50+11Aj
    mov     ecx, dword ptr [ebp+var_10]
    mov     edx, dword_529E14
    push    ecx
    push    edx
    push    offset byte_529E20
    push    offset aSSU                     ; "\r\n\t%s%s: %u"
    push    esi
    call    _sprintf
    mov     ecx, dword_529E00
    add     esi, eax
    mov     eax, dword_529E1C
    add     esp, 14h
    cmp     eax, ecx
    jnz     short loc_4E1FE1
    fild    [ebp+var_10]
    sub     esp, 8
    fmul    ds:dbl_4FDC58
    fild    [ebp+var_8]
    fdivp   st(1), st
    fstp    [esp+410h+var_410]
    push    offset a1_2f                    ; " (%1.2f%%)"
    push    esi
    call    _sprintf
    add     esp, 10h

    loc_4E1FE1:                             ; CODE XREF: sub_4E1E50+E7j
                                            ; sub_4E1E50+16Dj
    mov     edi, offset asc_50DD98          ; "\r\n"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp+OutputString]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ecx, edx
    dec     edi
    shr     ecx, 2
    rep movsd
    mov     al, byte_529DDC
    mov     ecx, edx
    and     ecx, 3
    test    al, al
    rep movsb
    jz      short loc_4E202D
    test    byte ptr [ebx+40h], 2
    jz      short loc_4E202D
    lea     eax, [ebp+OutputString]
    push    eax                             ; lpOutputString
    call    ds:OutputDebugStringA

    loc_4E202D:                             ; CODE XREF: sub_4E1E50+1C8j
                                            ; sub_4E1E50+1CEj
    mov     al, byte_529E64
    test    al, al
    jz      short loc_4E2090
    mov     eax, [ebp+arg_0]
    test    eax, eax
    mov     [ebp+var_3FC], eax
    jnz     short loc_4E204D
    mov     [ebp+var_3FC], offset Data

    loc_4E204D:                             ; CODE XREF: sub_4E1E50+1F1j
    lea     edi, [ebp+OutputString]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [ebp+var_3F8]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     byte ptr [ebp+var_3F8], 0
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    lea     ecx, [ebp+var_3FC]
    push    ecx
    call    sub_4E1A90
    mov     ecx, eax
    call    sub_4E1990

    loc_4E2090:                             ; CODE XREF: sub_4E1E50+15j
                                            ; sub_4E1E50+22j ...
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    4
    sub_4E1E50 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4E20A0 proc near                    ; CODE XREF: .text:004E1D31p
                                            ; sub_4E1D60+6Fp

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= qword ptr -8

    push    ebp
    mov     ebp, esp
    sub     esp, 18h
    push    esi
    mov     esi, ecx
    call    sub_4E1680
    test    al, al
    jz      short loc_4E20E0
    call    sub_4E1BE0
    mov     eax, dword_529E00
    push    0
    push    1
    push    0
    push    eax
    call    sub_4E3750
    mov     ecx, dword_529E10
    add     esp, 10h
    push    0
    push    1
    push    1
    push    ecx
    call    sub_4E3750
    add     esp, 10h

    loc_4E20E0:                             ; CODE XREF: sub_4E20A0+10j
    call    sub_4E1730
    mov     al, [esi+48h]
    test    al, al
    jz      short loc_4E20F9
    mov     edx, [esi]
    mov     eax, [esi+4]
    mov     dword ptr [ebp+var_8], edx
    mov     dword ptr [ebp+var_8+4], eax
    jmp     short loc_4E2100
    ; ---------------------------------------------------------------------------

    loc_4E20F9:                             ; CODE XREF: sub_4E20A0+4Aj
    fld     st
    fsub    qword ptr [esi]
    fstp    [ebp+var_8]

    loc_4E2100:                             ; CODE XREF: sub_4E20A0+57j
    fstp    qword ptr [esi]
    mov     byte ptr [esi+48h], 0
    call    sub_4E1680
    test    al, al
    jz      short loc_4E2141
    mov     ecx, 0
    rdpmc
    mov     [ebp+var_10], eax
    mov     [ebp+var_C], edx
    mov     ecx, 1
    rdpmc
    mov     [ebp+var_18], eax
    mov     [ebp+var_14], edx
    mov     ecx, [ebp+var_10]
    mov     eax, [ebp+var_18]
    mov     edx, [ebp+var_C]
    mov     [esi+8], ecx
    mov     ecx, [ebp+var_14]
    mov     [esi+10h], eax
    mov     [esi+0Ch], edx
    mov     [esi+14h], ecx

    loc_4E2141:                             ; CODE XREF: sub_4E20A0+6Dj
    fld     [ebp+var_8]
    pop     esi
    mov     esp, ebp
    pop     ebp
    retn
    sub_4E20A0 endp

    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, ecx
    call    sub_4E1E30
    fstp    qword ptr [esi]
    mov     byte ptr [esi+48h], 1
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    push    esi
    mov     esi, ecx
    mov     al, [esi+48h]
    test    al, al
    jz      short loc_4E2177
    call    sub_4E1730
    fsub    qword ptr [esi]
    mov     byte ptr [esi+48h], 0
    fstp    qword ptr [esi]

    loc_4E2177:                             ; CODE XREF: .text:004E2168j
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8
    mov     dword ptr [ecx], 0
    mov     dword ptr [ecx+4], 0
    mov     byte ptr [ecx+48h], 1
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     al, [ecx+48h]
    test    al, al
    jz      short loc_4E21B2
    fld     qword ptr [ecx]
    fsub    qword ptr [esp+4]
    fstp    qword ptr [ecx]
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4E21B2:                             ; CODE XREF: .text:004E21A5j
    fld     qword ptr [esp+4]
    fadd    qword ptr [ecx]
    fstp    qword ptr [ecx]
    retn    8
    ; ---------------------------------------------------------------------------
    align 4
    push    esi
    mov     esi, ecx
    mov     al, [esi+48h]
    test    al, al
    jz      short loc_4E21DB
    mov     eax, [esp+8]
    mov     ecx, [esp+0Ch]
    mov     [esi], eax
    mov     [esi+4], ecx
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4E21DB:                             ; CODE XREF: .text:004E21C8j
    call    sub_4E1730
    fsub    qword ptr [esp+8]
    fstp    qword ptr [esi]
    pop     esi
    retn    8
    ; ---------------------------------------------------------------------------
    align 8
    push    esi
    mov     esi, ecx
    call    sub_4E1730
    lea     ecx, [esi+18h]
    fld     st
    fsub    qword ptr [ecx]
    fcom    ds:dbl_4FDC60
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4E2214
    fdivr   ds:dbl_4FDC68
    jmp     short loc_4E221C
    ; ---------------------------------------------------------------------------

    loc_4E2214:                             ; CODE XREF: .text:004E220Aj
    fstp    st
    fld     ds:dbl_4FDC60

    loc_4E221C:                             ; CODE XREF: .text:004E2212j
    mov     eax, ecx
    mov     ecx, 4

    loc_4E2223:                             ; CODE XREF: .text:004E2232j
    mov     edx, [eax+8]
    mov     [eax], edx
    mov     edx, [eax+0Ch]
    mov     [eax+4], edx
    add     eax, 8
    dec     ecx
    jnz     short loc_4E2223
    fxch    st(1)
    fstp    qword ptr [esi+38h]
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2240 proc near                    ; CODE XREF: sub_4E18C0+66p

    arg_0= dword ptr  4

    mov     eax, [ecx+4]
    mov     ecx, [eax]
    mov     eax, [esp+arg_0]
    mov     [eax], ecx
    retn    4
    sub_4E2240 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2250 proc near                    ; CODE XREF: sub_4E1990+89p

    var_18= dword ptr -18h
    var_14= dword ptr -14h
    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 18h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ecx
    mov     bl, 1
    lea     ecx, [esp+28h+var_8]
    mov     [esp+28h+var_10], edi
    mov     eax, [edi+4]
    mov     esi, eax
    mov     ebp, [eax+4]
    mov     [esp+28h+var_14], esi
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     edx, dword_5292C4
    cmp     ebp, edx
    jz      short loc_4E22D6
    mov     eax, [esp+28h+arg_4]
    mov     edi, [eax]

    loc_4E2284:                             ; CODE XREF: sub_4E2250+7Cj
    mov     esi, [ebp+0Ch]
    mov     [esp+28h+var_14], ebp
    cmp     edi, esi
    jz      short loc_4E22C5
    mov     eax, edi

    loc_4E2291:                             ; CODE XREF: sub_4E2250+5Fj
    mov     bl, [eax]
    mov     cl, bl
    cmp     bl, [esi]
    jnz     short loc_4E22B5
    test    cl, cl
    jz      short loc_4E22B1
    mov     bl, [eax+1]
    mov     cl, bl
    cmp     bl, [esi+1]
    jnz     short loc_4E22B5
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4E2291

    loc_4E22B1:                             ; CODE XREF: sub_4E2250+4Bj
    xor     eax, eax
    jmp     short loc_4E22BA
    ; ---------------------------------------------------------------------------

    loc_4E22B5:                             ; CODE XREF: sub_4E2250+47j
                                            ; sub_4E2250+55j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4E22BA:                             ; CODE XREF: sub_4E2250+63j
    test    eax, eax
    jge     short loc_4E22C5
    mov     ebp, [ebp+0]
    mov     bl, 1
    jmp     short loc_4E22CA
    ; ---------------------------------------------------------------------------

    loc_4E22C5:                             ; CODE XREF: sub_4E2250+3Dj
                                            ; sub_4E2250+6Cj
    mov     ebp, [ebp+8]
    xor     bl, bl

    loc_4E22CA:                             ; CODE XREF: sub_4E2250+73j
    cmp     ebp, edx
    jnz     short loc_4E2284
    mov     esi, [esp+28h+var_14]
    mov     edi, [esp+28h+var_10]

    loc_4E22D6:                             ; CODE XREF: sub_4E2250+2Cj
    lea     ecx, [esp+28h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     al, [edi+8]
    test    al, al
    jz      loc_4E24AD
    lea     ecx, [esp+28h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    xor     ebx, ebx
    mov     ecx, edi
    push    ebx
    push    esi
    call    sub_4E2A30
    mov     ecx, dword_5292C4
    mov     edx, eax
    mov     [esp+28h+var_18], edx
    mov     [edx], ecx
    mov     eax, dword_5292C4
    lea     edi, [edx+0Ch]
    mov     [edx+8], eax
    cmp     edi, ebx
    jz      short loc_4E232A
    mov     esi, [esp+28h+arg_4]
    mov     ecx, 7Eh
    rep movsd
    mov     esi, [esp+28h+var_14]

    loc_4E232A:                             ; CODE XREF: sub_4E2250+C9j
    mov     edi, [esp+28h+var_10]
    mov     ecx, [edi+0Ch]
    mov     eax, [edi+4]
    inc     ecx
    cmp     esi, eax
    mov     [edi+0Ch], ecx
    jz      loc_4E254B
    cmp     ebp, dword_5292C4
    jnz     loc_4E254B
    lea     ecx, [esi+0Ch]
    push    ecx
    mov     ecx, [esp+2Ch+arg_4]
    call    sub_4E1A30
    mov     edx, [esp+28h+var_18]
    test    al, al
    jnz     loc_4E254B
    mov     [esi+8], edx
    mov     eax, [edi+4]
    cmp     esi, [eax+8]
    jnz     short loc_4E2375
    mov     ecx, edx
    mov     [eax+8], ecx

    loc_4E2375:                             ; CODE XREF: sub_4E2250+11Ej
    mov     edx, [esp+28h+var_18]

    loc_4E2379:                             ; CODE XREF: sub_4E2250+30Dj
                                            ; sub_4E2250+314j ...
    mov     edi, [esp+28h+var_10]
    mov     esi, edx
    mov     ecx, [edi+4]
    cmp     edx, [ecx+4]
    jz      loc_4E247C

    loc_4E238B:                             ; CODE XREF: sub_4E2250+226j
    mov     eax, [esi+4]
    cmp     [eax+204h], ebx
    jnz     loc_4E247C
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     short loc_4E240E
    mov     ecx, [edx+8]
    cmp     [ecx+204h], ebx
    jnz     short loc_4E23D6
    mov     edx, 1
    mov     [eax+204h], edx
    mov     [ecx+204h], edx
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+204h], ebx
    mov     ecx, [esi+4]
    mov     esi, [ecx+4]
    jmp     loc_4E2470
    ; ---------------------------------------------------------------------------

    loc_4E23D6:                             ; CODE XREF: sub_4E2250+15Cj
    cmp     esi, [eax+8]
    jnz     short loc_4E23E5
    mov     esi, eax
    mov     ecx, edi
    push    esi
    call    sub_4E2950

    loc_4E23E5:                             ; CODE XREF: sub_4E2250+189j
    mov     edx, [esi+4]
    mov     dword ptr [edx+204h], 1
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+204h], ebx
    mov     edx, [esi+4]
    mov     ecx, edi
    mov     eax, [edx+4]
    push    eax
    call    sub_4E29B0
    jmp     short loc_4E2470
    ; ---------------------------------------------------------------------------

    loc_4E240E:                             ; CODE XREF: sub_4E2250+151j
    cmp     [ecx+204h], ebx
    jnz     short loc_4E243B
    mov     edx, 1
    mov     [eax+204h], edx
    mov     [ecx+204h], edx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     [edx+204h], ebx
    mov     eax, [esi+4]
    mov     esi, [eax+4]
    jmp     short loc_4E2470
    ; ---------------------------------------------------------------------------

    loc_4E243B:                             ; CODE XREF: sub_4E2250+1C4j
    cmp     esi, [eax]
    jnz     short loc_4E2449
    mov     esi, eax
    mov     ecx, edi
    push    esi
    call    sub_4E29B0

    loc_4E2449:                             ; CODE XREF: sub_4E2250+1EDj
    mov     ecx, [esi+4]
    mov     dword ptr [ecx+204h], 1
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+204h], ebx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    mov     ecx, edi
    push    edx
    call    sub_4E2950

    loc_4E2470:                             ; CODE XREF: sub_4E2250+181j
                                            ; sub_4E2250+1BCj ...
    mov     eax, [edi+4]
    cmp     esi, [eax+4]
    jnz     loc_4E238B

    loc_4E247C:                             ; CODE XREF: sub_4E2250+135j
                                            ; sub_4E2250+144j
    mov     ecx, [edi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+28h+var_4]
    mov     dword ptr [edx+204h], 1
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [esp+28h+arg_0]
    mov     ecx, [esp+28h+var_18]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4E24AD:                             ; CODE XREF: sub_4E2250+94j
    test    bl, bl
    mov     [esp+28h+var_C], esi
    jz      short loc_4E24F5
    mov     edx, [edi+4]
    xor     eax, eax
    cmp     esi, [edx]
    setz    al
    test    al, al
    jz      short loc_4E24EC
    mov     ecx, [esp+28h+arg_4]
    lea     edx, [esp+28h+arg_4]
    push    ecx
    push    esi
    push    ebp
    push    edx
    mov     ecx, edi
    call    sub_4E2620
    mov     ecx, [eax]
    mov     eax, [esp+28h+arg_0]
    mov     [eax], ecx
    mov     byte ptr [eax+4], 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4E24EC:                             ; CODE XREF: sub_4E2250+271j
    lea     ecx, [esp+28h+var_C]
    call    sub_4E2AB0

    loc_4E24F5:                             ; CODE XREF: sub_4E2250+263j
    mov     edx, [esp+28h+var_C]
    mov     ebx, [esp+28h+arg_4]
    push    ebx
    lea     ecx, [edx+0Ch]
    call    sub_4E1A30
    test    al, al
    jz      short loc_4E2525
    lea     eax, [esp+28h+arg_4]
    lea     ecx, [esp+28h+var_4]
    push    eax
    push    ebx
    push    esi
    push    ebp
    push    ecx
    mov     ecx, edi
    mov     byte ptr [esp+3Ch+arg_4], 1
    call    sub_4E2620
    jmp     short loc_4E2533
    ; ---------------------------------------------------------------------------

    loc_4E2525:                             ; CODE XREF: sub_4E2250+2B8j
    lea     edx, [esp+28h+arg_4]
    mov     byte ptr [esp+28h+arg_4], 0
    push    edx
    lea     eax, [esp+2Ch+var_C]

    loc_4E2533:                             ; CODE XREF: sub_4E2250+2D3j
    mov     esi, [esp+2Ch+arg_0]
    push    eax
    mov     ecx, esi
    call    sub_4E2A10
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 18h
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4E254B:                             ; CODE XREF: sub_4E2250+EAj
                                            ; sub_4E2250+F6j ...
    mov     [esi], edx
    mov     eax, [edi+4]
    cmp     esi, eax
    jnz     short loc_4E2562
    mov     [eax+4], edx
    mov     eax, [edi+4]
    mov     [eax+8], edx
    jmp     loc_4E2379
    ; ---------------------------------------------------------------------------

    loc_4E2562:                             ; CODE XREF: sub_4E2250+302j
    cmp     esi, [eax]
    jnz     loc_4E2379
    mov     [eax], edx
    jmp     loc_4E2379
    sub_4E2250 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2580 proc near                    ; CODE XREF: sub_4E1990+22p

    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    push    ecx
    push    ebx
    push    esi
    mov     esi, ecx
    push    edi
    lea     ecx, [esp+10h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+4]
    mov     ebx, eax
    mov     edi, [eax+4]
    mov     eax, dword_5292C4
    cmp     edi, eax
    jz      short loc_4E25FC
    mov     eax, [esp+10h+arg_4]
    push    ebp
    mov     ebp, [eax]

    loc_4E25A7:                             ; CODE XREF: sub_4E2580+79j
    mov     eax, [edi+0Ch]
    cmp     eax, ebp
    jz      short loc_4E25E4
    mov     esi, ebp

    loc_4E25B0:                             ; CODE XREF: sub_4E2580+4Ej
    mov     dl, [eax]
    mov     cl, dl
    cmp     dl, [esi]
    jnz     short loc_4E25D4
    test    cl, cl
    jz      short loc_4E25D0
    mov     dl, [eax+1]
    mov     cl, dl
    cmp     dl, [esi+1]
    jnz     short loc_4E25D4
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4E25B0

    loc_4E25D0:                             ; CODE XREF: sub_4E2580+3Aj
    xor     eax, eax
    jmp     short loc_4E25D9
    ; ---------------------------------------------------------------------------

    loc_4E25D4:                             ; CODE XREF: sub_4E2580+36j
                                            ; sub_4E2580+44j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4E25D9:                             ; CODE XREF: sub_4E2580+52j
    test    eax, eax
    jge     short loc_4E25E4
    mov     eax, 1
    jmp     short loc_4E25E6
    ; ---------------------------------------------------------------------------

    loc_4E25E4:                             ; CODE XREF: sub_4E2580+2Cj
                                            ; sub_4E2580+5Bj
    xor     eax, eax

    loc_4E25E6:                             ; CODE XREF: sub_4E2580+62j
    test    al, al
    jz      short loc_4E25EF
    mov     edi, [edi+8]
    jmp     short loc_4E25F3
    ; ---------------------------------------------------------------------------

    loc_4E25EF:                             ; CODE XREF: sub_4E2580+68j
    mov     ebx, edi
    mov     edi, [edi]

    loc_4E25F3:                             ; CODE XREF: sub_4E2580+6Dj
    cmp     edi, dword_5292C4
    jnz     short loc_4E25A7
    pop     ebp

    loc_4E25FC:                             ; CODE XREF: sub_4E2580+1Ej
    lea     ecx, [esp+10h+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, [esp+10h+arg_0]
    pop     edi
    pop     esi
    mov     [eax], ebx
    pop     ebx
    pop     ecx
    retn    8
    sub_4E2580 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2620 proc near                    ; CODE XREF: sub_4E2250+281p
                                            ; sub_4E2250+2CEp

    var_C= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 0Ch
    push    ebx
    push    ebp
    mov     ebp, ecx
    push    esi
    push    edi
    lea     ecx, [esp+1Ch+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    push    208h
    mov     ecx, ebp
    call    sub_4E2B60
    mov     ebx, [esp+1Ch+arg_8]
    mov     edx, eax
    mov     [esp+1Ch+var_C], edx
    mov     [edx+4], ebx
    mov     dword ptr [edx+204h], 0
    mov     eax, dword_5292C4
    lea     edi, [edx+0Ch]
    mov     [edx], eax
    mov     ecx, dword_5292C4
    mov     eax, [esp+1Ch+arg_C]
    mov     [edx+8], ecx
    test    edi, edi
    jz      short loc_4E2679
    mov     ecx, 7Eh
    mov     esi, eax
    rep movsd

    loc_4E2679:                             ; CODE XREF: sub_4E2620+4Ej
    mov     esi, [ebp+0Ch]
    mov     ecx, [ebp+4]
    inc     esi
    cmp     ebx, ecx
    mov     [ebp+0Ch], esi
    jz      loc_4E292A
    mov     ecx, [esp+1Ch+arg_4]
    mov     esi, dword_5292C4
    cmp     ecx, esi
    jnz     loc_4E292A
    lea     edx, [ebx+0Ch]
    mov     ecx, eax
    push    edx
    call    sub_4E1A30
    test    al, al
    jnz     loc_4E2926
    mov     eax, [esp+1Ch+var_C]
    mov     [ebx+8], eax
    mov     eax, [ebp+4]
    cmp     ebx, [eax+8]
    jnz     short loc_4E26C6
    mov     ecx, [esp+1Ch+var_C]
    mov     [eax+8], ecx

    loc_4E26C6:                             ; CODE XREF: sub_4E2620+9Dj
    mov     edx, [esp+1Ch+var_C]

    loc_4E26CA:                             ; CODE XREF: sub_4E2620+31Cj
                                            ; sub_4E2620+323j ...
    mov     ecx, [ebp+4]
    mov     esi, edx
    mov     ebx, 1
    cmp     edx, [ecx+4]
    jz      loc_4E28FF

    loc_4E26DD:                             ; CODE XREF: sub_4E2620+2D9j
    mov     eax, [esi+4]
    mov     ecx, [eax+204h]
    test    ecx, ecx
    jnz     loc_4E28FF
    mov     edx, [eax+4]
    mov     ecx, [edx]
    cmp     eax, ecx
    jnz     loc_4E2803
    mov     ecx, [edx+8]
    xor     edi, edi
    cmp     [ecx+204h], edi
    jnz     short loc_4E272B
    mov     [eax+204h], ebx
    mov     [ecx+204h], ebx
    mov     edx, [esi+4]
    mov     eax, [edx+4]
    mov     [eax+204h], edi
    mov     ecx, [esi+4]
    mov     esi, [ecx+4]
    jmp     loc_4E28EF
    ; ---------------------------------------------------------------------------

    loc_4E272B:                             ; CODE XREF: sub_4E2620+E6j
    cmp     esi, [eax+8]
    jnz     short loc_4E277F
    lea     ecx, [esp+1Ch+arg_8]
    mov     esi, eax
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     edx, [eax]
    mov     [esi+8], edx
    mov     ecx, [eax]
    cmp     ecx, dword_5292C4
    jz      short loc_4E2750
    mov     [ecx+4], esi

    loc_4E2750:                             ; CODE XREF: sub_4E2620+12Bj
    mov     ecx, [esi+4]
    mov     [eax+4], ecx
    mov     ecx, [ebp+4]
    cmp     esi, [ecx+4]
    jnz     short loc_4E2763
    mov     [ecx+4], eax
    jmp     short loc_4E2771
    ; ---------------------------------------------------------------------------

    loc_4E2763:                             ; CODE XREF: sub_4E2620+13Cj
    mov     ecx, [esi+4]
    cmp     esi, [ecx]
    jnz     short loc_4E276E
    mov     [ecx], eax
    jmp     short loc_4E2771
    ; ---------------------------------------------------------------------------

    loc_4E276E:                             ; CODE XREF: sub_4E2620+148j
    mov     [ecx+8], eax

    loc_4E2771:                             ; CODE XREF: sub_4E2620+141j
                                            ; sub_4E2620+14Cj
    mov     [eax], esi
    lea     ecx, [esp+1Ch+arg_8]
    mov     [esi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4E277F:                             ; CODE XREF: sub_4E2620+10Ej
    mov     edx, [esi+4]
    mov     [edx+204h], ebx
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+204h], edi
    mov     edx, [esi+4]
    lea     ecx, [esp+1Ch+arg_C]
    mov     edi, [edx+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+8]
    mov     [edi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_5292C4
    jz      short loc_4E27B8
    mov     [ecx+4], edi

    loc_4E27B8:                             ; CODE XREF: sub_4E2620+193j
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebp+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4E27D8
    mov     [ecx+4], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4E28EA
    ; ---------------------------------------------------------------------------

    loc_4E27D8:                             ; CODE XREF: sub_4E2620+1A4j
    mov     ecx, [edi+4]
    cmp     edi, [ecx+8]
    jnz     short loc_4E27F2
    mov     [ecx+8], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4E28EA
    ; ---------------------------------------------------------------------------

    loc_4E27F2:                             ; CODE XREF: sub_4E2620+1BEj
    mov     [ecx], eax
    mov     [eax+8], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+arg_C]
    jmp     loc_4E28EA
    ; ---------------------------------------------------------------------------

    loc_4E2803:                             ; CODE XREF: sub_4E2620+D5j
    mov     edx, [ecx+204h]
    xor     edi, edi
    cmp     edx, edi
    jnz     short loc_4E2832
    mov     [eax+204h], ebx
    mov     [ecx+204h], ebx
    mov     eax, [esi+4]
    mov     ecx, [eax+4]
    mov     [ecx+204h], edi
    mov     edx, [esi+4]
    mov     esi, [edx+4]
    jmp     loc_4E28EF
    ; ---------------------------------------------------------------------------

    loc_4E2832:                             ; CODE XREF: sub_4E2620+1EDj
    cmp     esi, [eax]
    jnz     short loc_4E2887
    lea     ecx, [esp+1Ch+arg_4]
    mov     esi, eax
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi]
    mov     ecx, [eax+8]
    mov     [esi], ecx
    mov     ecx, [eax+8]
    cmp     ecx, dword_5292C4
    jz      short loc_4E2856
    mov     [ecx+4], esi

    loc_4E2856:                             ; CODE XREF: sub_4E2620+231j
    mov     edx, [esi+4]
    mov     [eax+4], edx
    mov     ecx, [ebp+4]
    cmp     esi, [ecx+4]
    jnz     short loc_4E2869
    mov     [ecx+4], eax
    jmp     short loc_4E2878
    ; ---------------------------------------------------------------------------

    loc_4E2869:                             ; CODE XREF: sub_4E2620+242j
    mov     ecx, [esi+4]
    cmp     esi, [ecx+8]
    jnz     short loc_4E2876
    mov     [ecx+8], eax
    jmp     short loc_4E2878
    ; ---------------------------------------------------------------------------

    loc_4E2876:                             ; CODE XREF: sub_4E2620+24Fj
    mov     [ecx], eax

    loc_4E2878:                             ; CODE XREF: sub_4E2620+247j
                                            ; sub_4E2620+254j
    mov     [eax+8], esi
    lea     ecx, [esp+1Ch+arg_4]
    mov     [esi+4], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4E2887:                             ; CODE XREF: sub_4E2620+214j
    mov     eax, [esi+4]
    mov     [eax+204h], ebx
    mov     ecx, [esi+4]
    mov     edx, [ecx+4]
    lea     ecx, [esp+1Ch+var_8]
    mov     [edx+204h], edi
    mov     eax, [esi+4]
    mov     edi, [eax+4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi+8]
    mov     ecx, [eax]
    mov     [edi+8], ecx
    mov     ecx, [eax]
    cmp     ecx, dword_5292C4
    jz      short loc_4E28C0
    mov     [ecx+4], edi

    loc_4E28C0:                             ; CODE XREF: sub_4E2620+29Bj
    mov     edx, [edi+4]
    mov     [eax+4], edx
    mov     ecx, [ebp+4]
    cmp     edi, [ecx+4]
    jnz     short loc_4E28D3
    mov     [ecx+4], eax
    jmp     short loc_4E28E1
    ; ---------------------------------------------------------------------------

    loc_4E28D3:                             ; CODE XREF: sub_4E2620+2ACj
    mov     ecx, [edi+4]
    cmp     edi, [ecx]
    jnz     short loc_4E28DE
    mov     [ecx], eax
    jmp     short loc_4E28E1
    ; ---------------------------------------------------------------------------

    loc_4E28DE:                             ; CODE XREF: sub_4E2620+2B8j
    mov     [ecx+8], eax

    loc_4E28E1:                             ; CODE XREF: sub_4E2620+2B1j
                                            ; sub_4E2620+2BCj
    mov     [eax], edi
    mov     [edi+4], eax
    lea     ecx, [esp+1Ch+var_8]

    loc_4E28EA:                             ; CODE XREF: sub_4E2620+1B3j
                                            ; sub_4E2620+1CDj ...
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)

    loc_4E28EF:                             ; CODE XREF: sub_4E2620+106j
                                            ; sub_4E2620+20Dj
    mov     eax, [ebp+4]
    mov     edx, [esp+1Ch+var_C]
    cmp     esi, [eax+4]
    jnz     loc_4E26DD

    loc_4E28FF:                             ; CODE XREF: sub_4E2620+B7j
                                            ; sub_4E2620+C8j
    mov     ecx, [ebp+4]
    mov     esi, [esp+1Ch+arg_0]
    mov     eax, [ecx+4]
    lea     ecx, [esp+1Ch+var_4]
    mov     [eax+204h], ebx
    mov     [esi], edx
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 0Ch
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4E2926:                             ; CODE XREF: sub_4E2620+8Aj
    mov     edx, [esp+1Ch+var_C]

    loc_4E292A:                             ; CODE XREF: sub_4E2620+65j
                                            ; sub_4E2620+77j
    mov     [ebx], edx
    mov     eax, [ebp+4]
    cmp     ebx, eax
    jnz     short loc_4E2941
    mov     [eax+4], edx
    mov     eax, [ebp+4]
    mov     [eax+8], edx
    jmp     loc_4E26CA
    ; ---------------------------------------------------------------------------

    loc_4E2941:                             ; CODE XREF: sub_4E2620+311j
    cmp     ebx, [eax]
    jnz     loc_4E26CA
    mov     [eax], edx
    jmp     loc_4E26CA
    sub_4E2620 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2950 proc near                    ; CODE XREF: sub_4E2250+190p
                                            ; sub_4E2250+21Bp

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx+8]
    mov     edx, [eax]
    mov     [ecx+8], edx
    mov     edx, [eax]
    cmp     edx, dword_5292C4
    jz      short loc_4E2976
    mov     [edx+4], ecx

    loc_4E2976:                             ; CODE XREF: sub_4E2950+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_4E2989
    mov     [edx+4], eax
    jmp     short loc_4E2997
    ; ---------------------------------------------------------------------------

    loc_4E2989:                             ; CODE XREF: sub_4E2950+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx]
    jnz     short loc_4E2994
    mov     [edx], eax
    jmp     short loc_4E2997
    ; ---------------------------------------------------------------------------

    loc_4E2994:                             ; CODE XREF: sub_4E2950+3Ej
    mov     [edx+8], eax

    loc_4E2997:                             ; CODE XREF: sub_4E2950+37j
                                            ; sub_4E2950+42j
    mov     [eax], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     esi
    pop     ecx
    retn    4
    sub_4E2950 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E29B0 proc near                    ; CODE XREF: sub_4E2250+1B7p
                                            ; sub_4E2250+1F4p

    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    ecx
    push    esi
    mov     esi, ecx
    lea     ecx, [esp+8+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     ecx, [esp+8+arg_0]
    mov     eax, [ecx]
    mov     edx, [eax+8]
    mov     [ecx], edx
    mov     edx, [eax+8]
    cmp     edx, dword_5292C4
    jz      short loc_4E29D6
    mov     [edx+4], ecx

    loc_4E29D6:                             ; CODE XREF: sub_4E29B0+21j
    mov     edx, [ecx+4]
    mov     [eax+4], edx
    mov     edx, [esi+4]
    cmp     ecx, [edx+4]
    jnz     short loc_4E29E9
    mov     [edx+4], eax
    jmp     short loc_4E29F8
    ; ---------------------------------------------------------------------------

    loc_4E29E9:                             ; CODE XREF: sub_4E29B0+32j
    mov     edx, [ecx+4]
    cmp     ecx, [edx+8]
    jnz     short loc_4E29F6
    mov     [edx+8], eax
    jmp     short loc_4E29F8
    ; ---------------------------------------------------------------------------

    loc_4E29F6:                             ; CODE XREF: sub_4E29B0+3Fj
    mov     [edx], eax

    loc_4E29F8:                             ; CODE XREF: sub_4E29B0+37j
                                            ; sub_4E29B0+44j
    mov     [eax+8], ecx
    mov     [ecx+4], eax
    lea     ecx, [esp+8+var_4]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     esi
    pop     ecx
    retn    4
    sub_4E29B0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2A10 proc near                    ; CODE XREF: sub_4E2250+2EAp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, ecx
    mov     ecx, [esp+arg_0]
    mov     edx, [ecx]
    mov     ecx, [esp+arg_4]
    mov     [eax], edx
    mov     dl, [ecx]
    mov     [eax+4], dl
    retn    8
    sub_4E2A10 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2A30 proc near                    ; CODE XREF: sub_4E2250+A9p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, dword_529E58
    push    esi
    test    eax, eax
    push    edi
    jnz     short loc_4E2A8C
    mov     edi, ds:GlobalAlloc

    loc_4E2A41:                             ; CODE XREF: sub_4E2A30+36j
    push    2000h                           ; dwBytes
    push    0                               ; uFlags
    call    edi ; GlobalAlloc
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4E2A70
    mov     eax, dword_5289BC
    test    eax, eax
    jz      short loc_4E2A5B
    call    eax

    loc_4E2A5B:                             ; CODE XREF: sub_4E2A30+27j
    test    esi, esi
    jnz     short loc_4E2A70
    mov     eax, dword_5289BC
    test    eax, eax
    jnz     short loc_4E2A41
    test    esi, esi
    jnz     short loc_4E2A70
    xor     eax, eax
    jmp     short loc_4E2A94
    ; ---------------------------------------------------------------------------

    loc_4E2A70:                             ; CODE XREF: sub_4E2A30+1Ej
                                            ; sub_4E2A30+2Dj ...
    mov     eax, dword_529E58
    mov     ecx, 0Fh

    loc_4E2A7A:                             ; CODE XREF: sub_4E2A30+55j
    mov     [esi], eax
    mov     eax, esi
    add     esi, 208h
    dec     ecx
    jnz     short loc_4E2A7A
    mov     dword_529E58, eax

    loc_4E2A8C:                             ; CODE XREF: sub_4E2A30+9j
    mov     ecx, [eax]
    mov     dword_529E58, ecx

    loc_4E2A94:                             ; CODE XREF: sub_4E2A30+3Ej
    mov     edx, [esp+8+arg_0]
    mov     ecx, [esp+8+arg_4]
    pop     edi
    mov     [eax+4], edx
    mov     [eax+204h], ecx
    pop     esi
    retn    8
    sub_4E2A30 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2AB0 proc near                    ; CODE XREF: sub_4E2250+2A0p

    var_8= dword ptr -8
    var_4= dword ptr -4

    sub     esp, 8
    push    esi
    push    edi
    mov     edi, ecx
    lea     ecx, [esp+10h+var_4]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [edi]
    mov     ecx, [eax+204h]
    test    ecx, ecx
    jnz     short loc_4E2AE8
    mov     ecx, [eax+4]
    cmp     [ecx+4], eax
    jnz     short loc_4E2AE8
    mov     edx, [eax+8]
    lea     ecx, [esp+10h+var_4]
    mov     [edi], edx
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E2AE8:                             ; CODE XREF: sub_4E2AB0+1Aj
                                            ; sub_4E2AB0+22j
    mov     esi, [eax]
    mov     ecx, dword_5292C4
    cmp     esi, ecx
    jz      short loc_4E2B2D
    lea     ecx, [esp+10h+var_8]
    call    ??0_Lockit@std@@QAE@XZ          ; std::_Lockit::_Lockit(void)
    mov     eax, [esi+8]
    mov     ecx, dword_5292C4
    cmp     eax, ecx
    jz      short loc_4E2B13

    loc_4E2B0A:                             ; CODE XREF: sub_4E2AB0+61j
    mov     esi, eax
    mov     eax, [esi+8]
    cmp     eax, ecx
    jnz     short loc_4E2B0A

    loc_4E2B13:                             ; CODE XREF: sub_4E2AB0+58j
    lea     ecx, [esp+10h+var_8]
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    lea     ecx, [esp+10h+var_4]
    mov     [edi], esi
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E2B2D:                             ; CODE XREF: sub_4E2AB0+42j
    mov     eax, [eax+4]
    mov     ecx, [edi]
    cmp     ecx, [eax]
    jnz     short loc_4E2B41

    loc_4E2B36:                             ; CODE XREF: sub_4E2AB0+8Fj
    mov     [edi], eax
    mov     eax, [eax+4]
    mov     edx, [edi]
    cmp     edx, [eax]
    jz      short loc_4E2B36

    loc_4E2B41:                             ; CODE XREF: sub_4E2AB0+84j
    lea     ecx, [esp+10h+var_4]
    mov     [edi], eax
    call    ??1_Lockit@std@@QAE@XZ          ; std::_Lockit::~_Lockit(void)
    pop     edi
    pop     esi
    add     esp, 8
    retn
    sub_4E2AB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2B60 proc near                    ; CODE XREF: sub_4E17C0+33p
                                            ; sub_4E2620+19p

    arg_0= dword ptr  4

    mov     ecx, dword_529E58
    push    ebx
    push    esi
    push    edi
    test    ecx, ecx
    jnz     short loc_4E2BCE
    mov     ebx, ds:GlobalAlloc
    mov     edi, 2000h

    loc_4E2B78:                             ; CODE XREF: sub_4E2B60+3Dj
    push    2000h                           ; dwBytes
    push    0                               ; uFlags
    call    ebx ; GlobalAlloc
    mov     esi, eax
    test    esi, esi
    jnz     short loc_4E2BAB
    mov     eax, dword_5289BC
    test    eax, eax
    jz      short loc_4E2B92
    call    eax

    loc_4E2B92:                             ; CODE XREF: sub_4E2B60+2Ej
    test    esi, esi
    jnz     short loc_4E2BAB
    mov     eax, dword_5289BC
    test    eax, eax
    jnz     short loc_4E2B78
    test    esi, esi
    jnz     short loc_4E2BAB
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebx
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4E2BAB:                             ; CODE XREF: sub_4E2B60+25j
                                            ; sub_4E2B60+34j ...
    mov     eax, [esp+0Ch+arg_0]
    mov     ecx, dword_529E58
    cmp     eax, 2000h
    ja      short loc_4E2BCE

    loc_4E2BBC:                             ; CODE XREF: sub_4E2B60+66j
    mov     [esi], ecx
    mov     ecx, esi
    sub     edi, eax
    add     esi, eax
    cmp     edi, eax
    jnb     short loc_4E2BBC
    mov     dword_529E58, ecx

    loc_4E2BCE:                             ; CODE XREF: sub_4E2B60+Bj
                                            ; sub_4E2B60+5Aj
    mov     eax, ecx
    mov     ecx, [ecx]
    pop     edi
    pop     esi
    mov     dword_529E58, ecx
    pop     ebx
    retn    4
    sub_4E2B60 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4E2BE0(HKEY phkResult,LPCSTR lpSubKey,int)
    sub_4E2BE0 proc near                    ; CODE XREF: sub_4E0520+1Ap
                                            ; sub_4E1B10+16p ...

    phkResult= dword ptr  14h
    lpSubKey= dword ptr  18h
    arg_8= dword ptr  1Ch

    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+arg_8]
    mov     esi, ecx
    test    edi, edi
    jnz     short loc_4E2BF4
    mov     edi, dword_529E80

    loc_4E2BF4:                             ; CODE XREF: sub_4E2BE0+Cj
    mov     bl, byte ptr [esp+phkResult]
    mov     dword ptr [esi], 0
    test    bl, bl
    jz      short loc_4E2C55
    mov     ebp, ds:RegOpenKeyA
    lea     eax, [esp+phkResult]
    push    eax                             ; phkResult
    push    offset aSoftwareCavedo          ; lpSubKey
    push    80000001h                       ; hKey
    call    ebp ; RegOpenKeyA
    test    eax, eax
    jnz     short loc_4E2C9C
    mov     edx, [esp+phkResult]
    lea     ecx, [esp+phkResult]
    push    ecx                             ; phkResult
    push    edi                             ; lpSubKey
    push    edx                             ; hKey
    call    ebp ; RegOpenKeyA
    test    eax, eax
    jnz     short loc_4E2C9C
    mov     ecx, [esp+lpSubKey]
    mov     edx, [esp+phkResult]
    lea     eax, [esp+phkResult]
    push    eax                             ; phkResult
    push    ecx                             ; lpSubKey
    push    edx                             ; hKey
    call    ebp ; RegOpenKeyA
    test    eax, eax
    jnz     short loc_4E2C9C
    mov     eax, [esp+phkResult]
    mov     [esi+4], bl
    mov     [esi], eax
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4E2C55:                             ; CODE XREF: sub_4E2BE0+20j
    mov     ebp, ds:RegCreateKeyA
    lea     ecx, [esp+phkResult]
    push    ecx                             ; phkResult
    push    offset aSoftwareCavedo          ; lpSubKey
    push    80000001h                       ; hKey
    call    ebp ; RegCreateKeyA
    test    eax, eax
    jnz     short loc_4E2C9C
    mov     eax, [esp+phkResult]
    lea     edx, [esp+phkResult]
    push    edx                             ; phkResult
    push    edi                             ; lpSubKey
    push    eax                             ; hKey
    call    ebp ; RegCreateKeyA
    test    eax, eax
    jnz     short loc_4E2C9C
    mov     edx, [esp+lpSubKey]
    mov     eax, [esp+phkResult]
    lea     ecx, [esp+phkResult]
    push    ecx                             ; phkResult
    push    edx                             ; lpSubKey
    push    eax                             ; hKey
    call    ebp ; RegCreateKeyA
    test    eax, eax
    jnz     short loc_4E2C9C
    mov     ecx, [esp+phkResult]
    mov     [esi], ecx

    loc_4E2C9C:                             ; CODE XREF: sub_4E2BE0+3Bj
                                            ; sub_4E2BE0+4Cj ...
    mov     [esi+4], bl
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    0Ch
    sub_4E2BE0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_31. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4E2CC0(BYTE Data,int)
    sub_4E2CC0 proc near                    ; CODE XREF: sub_4E3080+17Dp

    Data= byte ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     edx, dword ptr [esp+Data]
    and     eax, 0FFh
    push    eax                             ; int
    push    1                               ; int
    push    0                               ; int
    push    edx                             ; Data
    call    sub_4E2D00
    test    eax, eax
    setnz   al
    retn    8
    sub_4E2CC0 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4E2CE0(LPCSTR lpValueName,int)
    sub_4E2CE0 proc near                    ; CODE XREF: sub_4E3400+18Ep

    lpValueName= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     edx, [esp+lpValueName]
    and     eax, 0FFh
    push    eax                             ; Data
    push    edx                             ; lpValueName
    call    sub_4E2D70
    retn    8
    sub_4E2CE0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4E2D00(BYTE Data,int,int,int)
    sub_4E2D00 proc near                    ; CODE XREF: sub_4E2CC0+13p
                                            ; .text:004E2E7Bp ...

    cbData= dword ptr -8
    Type= dword ptr -4
    Data= byte ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 8
    lea     eax, [esp+8+cbData]
    push    esi
    push    eax                             ; lpcbData
    lea     edx, [esp+10h+Data]
    lea     eax, [esp+10h+Type]
    push    edx                             ; lpData
    mov     edx, dword ptr [esp+14h+Data]
    push    eax                             ; lpType
    mov     eax, [ecx]
    push    0                               ; lpReserved
    mov     esi, 4
    push    edx                             ; lpValueName
    push    eax                             ; hKey
    mov     [esp+24h+cbData], esi
    mov     [esp+24h+Type], esi
    call    ds:RegQueryValueExA
    test    eax, eax
    jnz     short loc_4E2D5F
    cmp     [esp+0Ch+cbData], esi
    jnz     short loc_4E2D5F
    cmp     [esp+0Ch+Type], esi
    jnz     short loc_4E2D5F
    mov     eax, dword ptr [esp+0Ch+Data]
    mov     ecx, [esp+0Ch+arg_4]
    cmp     eax, ecx
    jge     short loc_4E2D4E
    mov     eax, ecx

    loc_4E2D4E:                             ; CODE XREF: sub_4E2D00+4Aj
    mov     ecx, [esp+0Ch+arg_8]
    cmp     eax, ecx
    jle     short loc_4E2D63
    mov     eax, ecx
    pop     esi
    add     esp, 8
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4E2D5F:                             ; CODE XREF: sub_4E2D00+32j
                                            ; sub_4E2D00+38j ...
    mov     eax, [esp+0Ch+arg_C]

    loc_4E2D63:                             ; CODE XREF: sub_4E2D00+54j
    pop     esi
    add     esp, 8
    retn    10h
    sub_4E2D00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4E2D70(LPCSTR lpValueName,BYTE Data)
    sub_4E2D70 proc near                    ; CODE XREF: sub_4E2CE0+Fp
                                            ; .text:004E2E95p ...

    lpValueName= dword ptr  4
    Data= byte ptr  8

    mov     edx, [esp+lpValueName]
    lea     eax, [esp+Data]
    push    4                               ; cbData
    push    eax                             ; lpData
    mov     eax, [ecx]
    push    4                               ; dwType
    push    0                               ; Reserved
    push    edx                             ; lpValueName
    push    eax                             ; hKey
    call    ds:RegSetValueExA
    retn    8
    sub_4E2D70 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4E2D90(BYTE Data,int,int,int)
    sub_4E2D90 proc near                    ; CODE XREF: sub_4E2E20+1Bp

    cbData= dword ptr -8
    Type= dword ptr -4
    Data= byte ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 8
    lea     eax, [esp+8+cbData]
    push    esi
    push    eax                             ; lpcbData
    lea     edx, [esp+10h+Data]
    lea     eax, [esp+10h+Type]
    push    edx                             ; lpData
    mov     edx, dword ptr [esp+14h+Data]
    push    eax                             ; lpType
    mov     eax, [ecx]
    push    0                               ; lpReserved
    mov     esi, 4
    push    edx                             ; lpValueName
    push    eax                             ; hKey
    mov     [esp+24h+cbData], esi
    mov     [esp+24h+Type], esi
    call    ds:RegQueryValueExA
    test    eax, eax
    jnz     short loc_4E2DEF
    cmp     [esp+0Ch+cbData], esi
    jnz     short loc_4E2DEF
    cmp     [esp+0Ch+Type], esi
    jnz     short loc_4E2DEF
    mov     eax, dword ptr [esp+0Ch+Data]
    mov     ecx, [esp+0Ch+arg_4]
    cmp     eax, ecx
    jnb     short loc_4E2DDE
    mov     eax, ecx

    loc_4E2DDE:                             ; CODE XREF: sub_4E2D90+4Aj
    mov     ecx, [esp+0Ch+arg_8]
    cmp     eax, ecx
    jbe     short loc_4E2DF3
    mov     eax, ecx
    pop     esi
    add     esp, 8
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4E2DEF:                             ; CODE XREF: sub_4E2D90+32j
                                            ; sub_4E2D90+38j ...
    mov     eax, [esp+0Ch+arg_C]

    loc_4E2DF3:                             ; CODE XREF: sub_4E2D90+54j
    pop     esi
    add     esp, 8
    retn    10h
    sub_4E2D90 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4E2E00(LPCSTR lpValueName,BYTE Data)
    sub_4E2E00 proc near                    ; CODE XREF: sub_4E2E20+35p

    lpValueName= dword ptr  4
    Data= byte ptr  8

    mov     edx, [esp+lpValueName]
    lea     eax, [esp+Data]
    push    4                               ; cbData
    push    eax                             ; lpData
    mov     eax, [ecx]
    push    4                               ; dwType
    push    0                               ; Reserved
    push    edx                             ; lpValueName
    push    eax                             ; hKey
    call    ds:RegSetValueExA
    retn    8
    sub_4E2E00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2E20 proc near                    ; CODE XREF: sub_4E1B10+98p
                                            ; sub_4E1B10+B1p

    lpValueName= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h

    mov     al, [ecx+4]
    test    al, al
    jz      short loc_4E2E49
    mov     eax, [esp+arg_10]
    mov     edx, [esp+arg_C]
    push    eax                             ; int
    mov     eax, [esp+4+arg_8]
    push    edx                             ; int
    mov     edx, [esp+8+lpValueName]
    push    eax                             ; int
    push    edx                             ; Data
    call    sub_4E2D90
    mov     ecx, [esp+arg_4]
    mov     [ecx], eax
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4E2E49:                             ; CODE XREF: sub_4E2E20+5j
    mov     edx, [esp+arg_4]
    mov     eax, [edx]
    mov     edx, [esp+lpValueName]
    push    eax                             ; Data
    push    edx                             ; lpValueName
    call    sub_4E2E00
    retn    14h
    sub_4E2E20 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     al, [ecx+4]
    test    al, al
    jz      short loc_4E2E89
    mov     eax, [esp+14h]
    mov     edx, [esp+10h]
    push    eax
    mov     eax, [esp+10h]
    push    edx
    mov     edx, [esp+0Ch]
    push    eax
    push    edx
    call    sub_4E2D00
    mov     ecx, [esp+8]
    mov     [ecx], eax
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4E2E89:                             ; CODE XREF: .text:004E2E65j
    mov     edx, [esp+8]
    mov     eax, [edx]
    mov     edx, [esp+4]
    push    eax
    push    edx
    call    sub_4E2D70
    retn    14h
    ; ---------------------------------------------------------------------------
    align 4
    mov     al, [ecx+4]
    test    al, al
    jz      short loc_4E2EC9
    mov     eax, [esp+14h]
    mov     edx, [esp+10h]
    push    eax
    mov     eax, [esp+10h]
    push    edx
    mov     edx, [esp+0Ch]
    push    eax
    push    edx
    call    sub_4E2D00
    mov     ecx, [esp+8]
    mov     [ecx], eax
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4E2EC9:                             ; CODE XREF: .text:004E2EA5j
    mov     edx, [esp+8]
    mov     eax, [edx]
    mov     edx, [esp+4]
    push    eax
    push    edx
    call    sub_4E2D70
    retn    14h
    ; ---------------------------------------------------------------------------
    align 4
    mov     al, [ecx+4]
    test    al, al
    jz      short loc_4E2F0D
    movsx   eax, word ptr [esp+14h]
    movsx   edx, word ptr [esp+10h]
    push    eax
    push    edx
    movsx   eax, word ptr [esp+14h]
    mov     edx, [esp+0Ch]
    push    eax
    push    edx
    call    sub_4E2D00
    mov     ecx, [esp+8]
    mov     [ecx], ax
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4E2F0D:                             ; CODE XREF: .text:004E2EE5j
    mov     edx, [esp+8]
    movsx   eax, word ptr [edx]
    mov     edx, [esp+4]
    push    eax
    push    edx
    call    sub_4E2D70
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h
    mov     al, [ecx+4]
    test    al, al
    jz      short loc_4E2F6A
    mov     eax, [esp+14h]
    mov     edx, [esp+10h]
    and     eax, 0FFFFh
    and     edx, 0FFFFh
    push    eax
    mov     eax, [esp+10h]
    push    edx
    mov     edx, [esp+0Ch]
    and     eax, 0FFFFh
    push    eax
    push    edx
    call    sub_4E2D00
    mov     ecx, [esp+8]
    mov     [ecx], ax
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4E2F6A:                             ; CODE XREF: .text:004E2F35j
    mov     eax, [esp+8]
    xor     edx, edx
    mov     dx, [eax]
    push    edx
    mov     edx, [esp+8]
    push    edx
    call    sub_4E2D70
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h
    mov     al, [ecx+4]
    test    al, al
    jz      short loc_4E2FBC
    movsx   eax, byte ptr [esp+14h]
    movsx   edx, byte ptr [esp+10h]
    push    eax
    push    edx
    movsx   eax, byte ptr [esp+14h]
    mov     edx, [esp+0Ch]
    push    eax
    push    edx
    call    sub_4E2D00
    mov     ecx, [esp+8]
    mov     [ecx], al
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4E2FBC:                             ; CODE XREF: .text:004E2F95j
    mov     edx, [esp+8]
    movsx   eax, byte ptr [edx]
    mov     edx, [esp+4]
    push    eax
    push    edx
    call    sub_4E2D70
    retn    14h
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E2FE0 proc near                    ; CODE XREF: sub_4E0520+2Ep
                                            ; sub_4E1B10+2Bp ...

    lpValueName= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     al, [ecx+4]
    test    al, al
    jz      short loc_4E300D
    mov     eax, [esp+arg_8]
    mov     edx, [esp+lpValueName]
    and     eax, 0FFh
    push    eax                             ; int
    push    1                               ; int
    push    0                               ; int
    push    edx                             ; Data
    call    sub_4E2D00
    mov     ecx, [esp+arg_4]
    test    eax, eax
    setnz   al
    mov     [ecx], al
    retn    0Ch
    ; ---------------------------------------------------------------------------

    loc_4E300D:                             ; CODE XREF: sub_4E2FE0+5j
    mov     eax, [esp+arg_4]
    xor     edx, edx
    mov     dl, [eax]
    push    edx                             ; Data
    mov     edx, [esp+4+lpValueName]
    push    edx                             ; lpValueName
    call    sub_4E2D70
    retn    0Ch
    sub_4E2FE0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    mov     al, [ecx+4]
    test    al, al
    jz      short loc_4E3069
    mov     eax, [esp+14h]
    mov     edx, [esp+10h]
    and     eax, 0FFh
    and     edx, 0FFh
    push    eax
    mov     eax, [esp+10h]
    push    edx
    mov     edx, [esp+0Ch]
    and     eax, 0FFh
    push    eax
    push    edx
    call    sub_4E2D00
    mov     ecx, [esp+8]
    mov     [ecx], al
    retn    14h
    ; ---------------------------------------------------------------------------

    loc_4E3069:                             ; CODE XREF: .text:004E3035j
    mov     eax, [esp+8]
    xor     edx, edx
    mov     dl, [eax]
    push    edx
    mov     edx, [esp+8]
    push    edx
    call    sub_4E2D70
    retn    14h
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E3080 proc near                    ; CODE XREF: sub_4E33D0+20p

    var_136= byte ptr -136h
    var_135= byte ptr -135h
    uFlags= dword ptr -134h
    var_130= dword ptr -130h
    var_12C= dword ptr -12Ch
    pvParam= dword ptr -124h
    var_120= dword ptr -120h
    var_11C= dword ptr -11Ch
    var_118= dword ptr -118h
    var_114= dword ptr -114h
    var_110= dword ptr -110h
    var_10C= dword ptr -10Ch
    var_108= dword ptr -108h
    Rect= tagRECT ptr -104h
    wndpl= WINDOWPLACEMENT ptr -0F4h
    SubKey= byte ptr -0C8h
    hWnd= dword ptr  4
    arg_4= dword ptr  8
    arg_8= qword ptr  0Ch
    arg_10= qword ptr  14h
    arg_18= byte ptr  1Ch

    sub     esp, 138h
    push    ebx
    push    ebp
    push    esi
    mov     esi, ds:GetSystemMetrics
    push    edi
    xor     edi, edi
    push    edi                             ; nIndex
    mov     [esp+14Ch+pvParam], edi
    mov     [esp+14Ch+var_120], edi
    call    esi ; GetSystemMetrics
    push    1                               ; nIndex
    mov     [esp+14Ch+var_11C], eax
    call    esi ; GetSystemMetrics
    mov     [esp+148h+var_118], eax
    lea     eax, [esp+148h+pvParam]
    push    edi                             ; fWinIni
    push    eax                             ; pvParam
    push    edi                             ; uiParam
    push    30h                             ; uiAction
    call    ds:SystemParametersInfoA
    mov     ebp, [esp+148h+hWnd]
    lea     ecx, [esp+148h+wndpl]
    push    ecx                             ; lpwndpl
    push    ebp                             ; hWnd
    mov     [esp+150h+wndpl.length], 2Ch
    call    ds:GetWindowPlacement
    mov     edi, offset aWindowposition     ; "WindowPositions\\"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    lea     edx, [esp+148h+SubKey]
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, 0C7h
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+148h+SubKey]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+148h+arg_4]
    not     ecx
    dec     ecx
    sub     edx, ecx
    lea     ecx, [esp+148h+SubKey]
    push    edx                             ; size_t
    push    eax                             ; char *
    push    ecx                             ; char *
    call    _strncat
    add     esp, 0Ch
    lea     edx, [esp+148h+SubKey]
    lea     ecx, [esp+148h+var_12C]
    push    offset aCavedogLibrary          ; int
    push    edx                             ; lpSubKey
    push    1                               ; phkResult
    call    sub_4E2BE0
    push    0FFFFFE0Ch                      ; int
    push    0C350h                          ; int
    push    0FFFFFE0Ch                      ; int
    push    offset aLeftedge                ; Data
    lea     ecx, [esp+158h+var_12C]
    call    sub_4E2D00
    push    0FFFFFE0Ch                      ; int
    push    0C350h                          ; int
    push    0FFFFFE0Ch                      ; int
    push    offset aTopedge                 ; Data
    lea     ecx, [esp+158h+var_12C]
    mov     ebx, eax
    call    sub_4E2D00
    push    0FFFFFFF0h                      ; nIndex
    push    ebp                             ; hWnd
    mov     [esp+150h+var_130], eax
    call    ds:GetWindowLongA
    mov     esi, eax
    mov     [esp+148h+var_135], 0
    lea     eax, [esp+148h+Rect]
    push    eax                             ; lpRect
    push    ebp                             ; hWnd
    call    ds:GetWindowRect
    and     esi, 40000h
    cmp     esi, 40000h
    jnz     short loc_4E321C
    mov     ecx, [esp+148h+var_11C]
    mov     edi, [esp+148h+pvParam]
    sub     ecx, edi
    push    0                               ; int
    push    ecx                             ; int
    push    0                               ; int
    push    offset aWidth_0                 ; Data
    lea     ecx, [esp+158h+var_12C]
    mov     [esp+158h+var_135], 1
    call    sub_4E2D00
    mov     edx, [esp+148h+var_118]
    mov     edi, [esp+148h+var_120]
    sub     edx, edi
    push    0                               ; int
    push    edx                             ; int
    push    0                               ; int
    push    offset aHeight_0                ; Data
    lea     ecx, [esp+158h+var_12C]
    mov     esi, eax
    call    sub_4E2D00
    push    0                               ; int
    push    offset aZoomed                  ; Data
    lea     ecx, [esp+150h+var_12C]
    mov     edi, eax
    call    sub_4E2CC0
    cmp     esi, 64h
    mov     [esp+148h+var_136], al
    jge     short loc_4E3210
    mov     esi, 64h

    loc_4E3210:                             ; CODE XREF: sub_4E3080+189j
    cmp     edi, 32h
    jge     short loc_4E3235
    mov     edi, 32h
    jmp     short loc_4E3235
    ; ---------------------------------------------------------------------------

    loc_4E321C:                             ; CODE XREF: sub_4E3080+12Dj
    mov     esi, [esp+148h+Rect.right]
    mov     ecx, [esp+148h+Rect.left]
    mov     edi, [esp+148h+Rect.bottom]
    mov     eax, [esp+148h+Rect.top]
    sub     esi, ecx
    sub     edi, eax
    mov     [esp+148h+var_136], 0

    loc_4E3235:                             ; CODE XREF: sub_4E3080+193j
                                            ; sub_4E3080+19Aj
    mov     dl, [esp+148h+arg_18]
    mov     [esp+148h+uFlags], 4
    test    dl, dl
    jz      short loc_4E3250
    mov     [esp+148h+uFlags], 44h

    loc_4E3250:                             ; CODE XREF: sub_4E3080+1C6j
    cmp     ebx, 0FFFFFE0Ch
    jz      loc_4E3302
    mov     ecx, [esp+148h+var_130]
    cmp     ecx, 0FFFFFE0Ch
    jz      loc_4E3302
    test    esi, esi
    jle     loc_4E3302
    test    edi, edi
    jle     loc_4E3302
    mov     eax, esi
    cdq
    sub     eax, edx
    mov     edx, [esp+148h+pvParam]
    sar     eax, 1
    sub     edx, eax
    cmp     ebx, edx
    jge     short loc_4E328F
    mov     ebx, edx

    loc_4E328F:                             ; CODE XREF: sub_4E3080+20Bj
    mov     edx, [esp+148h+var_120]
    cmp     ecx, edx
    jge     short loc_4E329D
    mov     [esp+148h+var_130], edx
    mov     ecx, edx

    loc_4E329D:                             ; CODE XREF: sub_4E3080+215j
    lea     edx, [ebx+eax]
    cmp     edx, [esp+148h+var_11C]
    jle     short loc_4E32AC
    mov     ebx, [esp+148h+var_11C]
    sub     ebx, eax

    loc_4E32AC:                             ; CODE XREF: sub_4E3080+224j
    mov     eax, edi
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     edx, [ecx+eax]
    cmp     edx, [esp+148h+var_118]
    jle     short loc_4E32C6
    mov     ecx, [esp+148h+var_118]
    sub     ecx, eax
    mov     [esp+148h+var_130], ecx

    loc_4E32C6:                             ; CODE XREF: sub_4E3080+23Aj
    mov     eax, [esp+148h+uFlags]
    push    eax                             ; uFlags
    push    edi                             ; cy
    push    esi                             ; cx
    push    ecx                             ; Y
    push    ebx                             ; X
    push    0                               ; hWndInsertAfter
    push    ebp                             ; hWnd
    call    ds:SetWindowPos
    mov     al, [esp+148h+var_135]
    test    al, al
    jz      short loc_4E3337
    mov     al, [esp+148h+var_136]
    test    al, al
    jnz     loc_4E33AB
    lea     ecx, [esp+148h+var_12C]
    call    nullsub_31
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 138h
    retn
    ; ---------------------------------------------------------------------------

    loc_4E3302:                             ; CODE XREF: sub_4E3080+1D6j
                                            ; sub_4E3080+1E6j ...
    fld     [esp+148h+arg_8]
    fcomp   ds:dbl_4FDC70
    fnstsw  ax
    test    ah, 40h
    jz      short loc_4E334D
    fld     [esp+148h+arg_10]
    fcomp   ds:dbl_4FDC70
    fnstsw  ax
    test    ah, 40h
    jz      short loc_4E334D
    test    dl, dl
    jz      short loc_4E3337
    push    1                               ; nCmdShow
    push    ebp                             ; hWnd
    call    ds:ShowWindow

    loc_4E3337:                             ; CODE XREF: sub_4E3080+25Ej
                                            ; sub_4E3080+2ACj
    lea     ecx, [esp+148h+var_12C]
    call    nullsub_31
    xor     al, al
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 138h
    retn
    ; ---------------------------------------------------------------------------

    loc_4E334D:                             ; CODE XREF: sub_4E3080+294j
                                            ; sub_4E3080+2A8j
    lea     ecx, [esp+148h+var_114]
    push    ecx                             ; lpRect
    push    ebp                             ; hWnd
    call    ds:GetWindowRect
    mov     edx, [esp+148h+var_108]
    mov     esi, [esp+148h+var_110]
    mov     eax, [esp+148h+uFlags]
    sub     edx, esi
    mov     [esp+148h+uFlags], edx
    or      al, 2
    fild    [esp+148h+uFlags]
    push    eax                             ; uFlags
    fmul    [esp+14Ch+arg_10]
    call    __ftol
    mov     ebx, [esp+14Ch+var_114]
    push    eax                             ; cy
    mov     eax, [esp+150h+var_10C]
    sub     eax, ebx
    mov     [esp+150h+uFlags], eax
    fild    [esp+150h+uFlags]
    fmul    [esp+150h+arg_8]
    call    __ftol
    push    eax                             ; cx
    push    0                               ; Y
    push    0                               ; X
    push    0                               ; hWndInsertAfter
    push    ebp                             ; hWnd
    call    ds:SetWindowPos

    loc_4E33AB:                             ; CODE XREF: sub_4E3080+266j
    lea     ecx, [esp+148h+var_12C]
    call    nullsub_31
    pop     edi
    pop     esi
    pop     ebp
    mov     al, 1
    pop     ebx
    add     esp, 138h
    retn
    sub_4E3080 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E33D0 proc near                    ; CODE XREF: sub_4DF280+44p
                                            ; sub_4E05F0+44p

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h

    mov     eax, [esp+arg_14]
    mov     ecx, [esp+arg_10]
    mov     edx, [esp+arg_C]
    push    1
    push    eax
    mov     eax, [esp+8+arg_8]
    push    ecx
    mov     ecx, [esp+0Ch+arg_4]
    push    edx
    mov     edx, [esp+10h+arg_0]
    push    eax
    push    ecx
    push    edx
    call    sub_4E3080
    add     esp, 1Ch
    retn
    sub_4E33D0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E3400 proc near                    ; CODE XREF: sub_4DF280+8Cp
                                            ; sub_4DF590+7Bp ...

    Data= byte ptr -10Ch
    var_FC= dword ptr -0FCh
    wndpl= WINDOWPLACEMENT ptr -0F4h
    SubKey= byte ptr -0C8h
    hWnd= dword ptr  4
    arg_4= dword ptr  8

    sub     esp, 10Ch
    push    ebx
    mov     ebx, [esp+110h+hWnd]
    push    ebp
    mov     ebp, ds:IsIconic
    push    ebx                             ; hWnd
    call    ebp ; IsIconic
    test    eax, eax
    jnz     loc_4E359E
    push    edi
    mov     edi, offset aWindowposition     ; "WindowPositions\\"
    or      ecx, 0FFFFFFFFh
    push    esi
    repne scasb
    not     ecx
    sub     edi, ecx
    lea     edx, [esp+11Ch+SubKey]
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    mov     edx, 0C7h
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    lea     edi, [esp+11Ch+SubKey]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+11Ch+arg_4]
    not     ecx
    dec     ecx
    sub     edx, ecx
    lea     ecx, [esp+11Ch+SubKey]
    push    edx                             ; size_t
    push    eax                             ; char *
    push    ecx                             ; char *
    call    _strncat
    add     esp, 0Ch
    lea     edx, [esp+11Ch+SubKey]
    lea     ecx, [esp+11Ch+var_FC]
    push    offset aCavedogLibrary          ; int
    push    edx                             ; lpSubKey
    push    0                               ; phkResult
    call    sub_4E2BE0
    lea     eax, [esp+11Ch+wndpl]
    mov     [esp+11Ch+wndpl.length], 2Ch
    push    eax                             ; lpwndpl
    push    ebx                             ; hWnd
    call    ds:GetWindowPlacement
    test    eax, eax
    jz      loc_4E3593
    mov     ecx, [esp+11Ch+wndpl.rcNormalPosition.left]
    mov     edx, [esp+11Ch+wndpl.rcNormalPosition.top]
    mov     eax, [esp+11Ch+wndpl.rcNormalPosition.right]
    mov     esi, ds:IsZoomed
    mov     dword ptr [esp+11Ch+Data], ecx
    mov     ecx, [esp+11Ch+wndpl.rcNormalPosition.bottom]
    push    ebx                             ; hWnd
    mov     [esp+18h], edx
    mov     [esp+1Ch], eax
    mov     [esp+20h], ecx
    call    esi ; IsZoomed
    test    eax, eax
    jnz     short loc_4E34E2
    push    ebx                             ; hWnd
    call    ebp ; IsIconic
    test    eax, eax
    jnz     short loc_4E34E2
    lea     edx, [esp+11Ch+Data]
    push    edx                             ; lpRect
    push    ebx                             ; hWnd
    call    ds:GetWindowRect

    loc_4E34E2:                             ; CODE XREF: sub_4E3400+CDj
                                            ; sub_4E3400+D4j
    mov     eax, dword ptr [esp+11Ch+Data]
    mov     ebp, [esp+18h]
    mov     ecx, [esp+14h]
    mov     edi, [esp+1Ch]
    sub     ebp, eax
    sub     edi, ecx
    cmp     eax, 0FFFFFE0Ch
    mov     [esp+18h], ebp
    mov     [esp+1Ch], edi
    jg      short loc_4E350E
    mov     eax, 0FFFFFE0Dh
    mov     dword ptr [esp+11Ch+Data], eax

    loc_4E350E:                             ; CODE XREF: sub_4E3400+103j
    cmp     ecx, 0FFFFFE0Ch
    jg      short loc_4E351E
    mov     dword ptr [esp+14h], 0FFFFFE0Dh

    loc_4E351E:                             ; CODE XREF: sub_4E3400+114j
    push    eax                             ; Data
    push    offset aLeftedge                ; lpValueName
    lea     ecx, [esp+124h+var_FC]
    call    sub_4E2D70
    mov     eax, [esp+14h]
    lea     ecx, [esp+11Ch+var_FC]
    push    eax                             ; Data
    push    offset aTopedge                 ; lpValueName
    call    sub_4E2D70
    push    0FFFFFFF0h                      ; nIndex
    push    ebx                             ; hWnd
    call    ds:GetWindowLongA
    and     eax, 40000h
    cmp     eax, 40000h
    jnz     short loc_4E3593
    mov     ecx, [esp+18h]
    push    ecx                             ; Data
    push    offset aWidth_0                 ; lpValueName
    lea     ecx, [esp+124h+var_FC]
    call    sub_4E2D70
    mov     edx, [esp+1Ch]
    lea     ecx, [esp+11Ch+var_FC]
    push    edx                             ; Data
    push    offset aHeight_0                ; lpValueName
    call    sub_4E2D70
    push    ebx                             ; hWnd
    call    esi ; IsZoomed
    neg     eax
    sbb     eax, eax
    lea     ecx, [esp+11Ch+var_FC]
    neg     eax
    push    eax                             ; int
    push    offset aZoomed                  ; lpValueName
    call    sub_4E2CE0

    loc_4E3593:                             ; CODE XREF: sub_4E3400+9Cj
                                            ; sub_4E3400+153j
    lea     ecx, [esp+11Ch+var_FC]
    call    nullsub_31
    pop     esi
    pop     edi

    loc_4E359E:                             ; CODE XREF: sub_4E3400+1Aj
    pop     ebp
    pop     ebx
    add     esp, 10Ch
    retn
    sub_4E3400 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4E35B0 proc near                    ; CODE XREF: sub_4E1680+10p

    VersionInformation= _OSVERSIONINFOA ptr -94h

    push    ebp
    mov     ebp, esp
    sub     esp, 94h
    mov     al, byte_529E9C
    push    ebx
    test    al, al
    push    esi
    jz      short loc_4E35CC
    mov     al, 1
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------

    loc_4E35CC:                             ; CODE XREF: sub_4E35B0+12j
    xor     eax, eax
    mov     dword_529E88, eax
    mov     dword_529E8C, eax
    mov     dword_529E90, eax
    mov     byte_529E94, al
    mov     eax, 0
    cpuid
    mov     dword_529E88, ebx
    mov     dword_529E8C, edx
    mov     dword_529E90, ecx
    mov     esi, offset aGenuineintel       ; "GenuineIntel"
    mov     eax, offset dword_529E88

    loc_4E3605:                             ; CODE XREF: sub_4E35B0+77j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4E362D
    test    cl, cl
    jz      short loc_4E3629
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4E362D
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4E3605

    loc_4E3629:                             ; CODE XREF: sub_4E35B0+61j
    xor     eax, eax
    jmp     short loc_4E3632
    ; ---------------------------------------------------------------------------

    loc_4E362D:                             ; CODE XREF: sub_4E35B0+5Dj
                                            ; sub_4E35B0+6Dj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4E3632:                             ; CODE XREF: sub_4E35B0+7Bj
    test    eax, eax
    jz      short loc_4E3645
    mov     byte_529E9C, 0
    xor     al, al
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------

    loc_4E3645:                             ; CODE XREF: sub_4E35B0+84j
    lea     eax, [ebp+VersionInformation]
    mov     [ebp+VersionInformation.dwOSVersionInfoSize], 94h
    push    eax                             ; lpVersionInformation
    call    ds:GetVersionExA                ; Get extended information about the
                                            ; version of the operating system
    mov     eax, [ebp+VersionInformation.dwPlatformId]
    push    0                               ; hTemplateFile
    push    80h                             ; dwFlagsAndAttributes
    push    3                               ; dwCreationDisposition
    push    0                               ; lpSecurityAttributes
    cmp     eax, 2
    push    0                               ; dwShareMode
    push    80000000h                       ; dwDesiredAccess
    jnz     short loc_4E3680
    push    offset a_Gdperf                 ; "\\\\.\\GDPERF"
    jmp     short loc_4E3685
    ; ---------------------------------------------------------------------------

    loc_4E3680:                             ; CODE XREF: sub_4E35B0+C7j
    push    offset a_Gdperf_vxd             ; lpFileName

    loc_4E3685:                             ; CODE XREF: sub_4E35B0+CEj
    call    ds:CreateFileA
    cmp     eax, 0FFFFFFFFh
    mov     hDevice, eax
    jz      short loc_4E3705
    mov     byte_529E9C, 1
    mov     eax, 1
    cpuid
    mov     ebx, eax
    shr     ebx, 8
    and     ebx, 0Fh
    cmp     ebx, 4
    jz      short loc_4E36BA
    cmp     ebx, 5
    jz      short loc_4E36BF
    cmp     ebx, 6
    jz      short loc_4E36BF

    loc_4E36BA:                             ; CODE XREF: sub_4E35B0+FEj
    mov     ebx, 4

    loc_4E36BF:                             ; CODE XREF: sub_4E35B0+103j
                                            ; sub_4E35B0+108j
    mov     dword_529EA0, ebx
    cmp     dword_529EA0, 6
    jnz     short loc_4E36F4
    push    1
    push    1
    push    0
    push    60790300h
    call    sub_4E3750
    add     esp, 10h
    push    1
    push    1
    push    1
    push    60790300h
    call    sub_4E3750
    add     esp, 10h

    loc_4E36F4:                             ; CODE XREF: sub_4E35B0+11Cj
    cmp     dword_529EA0, 5
    jl      short loc_4E3705
    mov     al, 1
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------

    loc_4E3705:                             ; CODE XREF: sub_4E35B0+E3j
                                            ; sub_4E35B0+14Bj
    pop     esi
    xor     al, al
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    sub_4E35B0 endp

    ; ---------------------------------------------------------------------------
    align 4
    mov     al, byte_529E9C
    test    al, al
    jz      short loc_4E3741
    mov     eax, hDevice
    mov     byte_529E9C, 0
    test    eax, eax
    jz      short loc_4E3741
    push    eax
    call    ds:CloseHandle
    test    eax, eax
    mov     hDevice, 0
    jz      short loc_4E3741
    mov     al, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_4E3741:                             ; CODE XREF: .text:004E3717j
                                            ; .text:004E3727j ...
    xor     al, al
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E3750 proc near                    ; CODE XREF: sub_4E20A0+23p
                                            ; sub_4E20A0+38p ...

    BytesReturned= dword ptr -8
    var_4= dword ptr -4
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= byte ptr  0Ch
    arg_C= byte ptr  10h

    sub     esp, 8
    push    ebx
    push    esi
    mov     esi, [esp+10h+arg_4]
    cmp     esi, 1
    ja      loc_4E38D1
    mov     al, byte_529E9C
    test    al, al
    jz      loc_4E38D1
    mov     ebx, [esp+10h+arg_0]
    mov     eax, dword_529EA0
    mov     ecx, ebx
    shr     ecx, 1Ch
    cmp     ecx, eax
    jnz     loc_4E38D1
    mov     ecx, ebx
    lea     edx, [esi+1]
    shr     ecx, 8
    and     edx, ecx
    test    dl, 3
    jz      loc_4E38D1
    cmp     eax, 5
    jnz     loc_4E386E
    shr     ebx, 10h
    lea     edx, [esp+10h+BytesReturned]
    and     bl, 3Fh
    push    edx                             ; BytesReturned
    push    11h                             ; InBuffer
    mov     byte ptr [esp+18h+arg_4], bl
    call    sub_4E38E0
    mov     ecx, esi
    mov     eax, [esp+18h+BytesReturned]
    add     esp, 8
    neg     ecx
    sbb     ecx, ecx
    and     ecx, 1FFFFh
    add     ecx, 0FFFF0000h
    and     eax, ecx
    mov     ecx, [esp+10h+var_4]
    and     ecx, 0
    mov     [esp+10h+BytesReturned], eax
    push    ecx                             ; int
    push    eax                             ; int
    push    11h                             ; BytesReturned
    mov     [esp+1Ch+var_4], ecx
    call    sub_4E3930
    add     esp, 0Ch
    xor     edx, edx
    test    esi, esi
    setnz   dl
    push    0                               ; int
    add     edx, 12h
    push    0                               ; int
    push    edx                             ; BytesReturned
    call    sub_4E3930
    mov     al, [esp+1Ch+arg_C]
    mov     cl, [esp+1Ch+arg_8]
    add     esp, 0Ch
    mov     esi, [esp+10h+var_4]
    neg     al
    sbb     eax, eax
    and     eax, 40h
    neg     cl
    sbb     ecx, ecx
    and     ecx, 80h
    or      eax, ecx
    mov     ecx, [esp+10h+BytesReturned]
    cdq
    or      ecx, eax
    or      esi, edx
    cmp     bl, 3Fh
    mov     [esp+10h+BytesReturned], ecx
    mov     [esp+10h+var_4], esi
    jnz     short loc_4E384E
    or      ch, 1
    push    esi                             ; int
    push    ecx                             ; int
    push    11h                             ; BytesReturned
    call    sub_4E3930
    add     esp, 0Ch
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E384E:                             ; CODE XREF: sub_4E3750+E7j
    mov     eax, [esp+10h+arg_4]
    and     eax, 0FFh
    cdq
    or      esi, edx
    or      ecx, eax
    push    esi                             ; int
    push    ecx                             ; int
    push    11h                             ; BytesReturned
    call    sub_4E3930
    add     esp, 0Ch
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E386E:                             ; CODE XREF: sub_4E3750+4Bj
    cmp     eax, 6
    jnz     short loc_4E38D1
    mov     al, [esp+10h+arg_8]
    mov     cl, [esp+10h+arg_C]
    mov     edx, ebx
    shr     edx, 10h
    neg     al
    sbb     eax, eax
    mov     byte ptr [esp+10h+arg_4], dl
    and     eax, 10000h
    mov     edx, [esp+10h+arg_4]
    neg     cl
    sbb     ecx, ecx
    and     ebx, 0FFh
    and     ecx, 20000h
    or      bh, 44h
    or      eax, ecx
    and     edx, 0FFh
    shl     ebx, 8
    or      eax, ebx
    or      eax, edx
    cdq
    push    edx                             ; int
    push    eax                             ; int
    xor     eax, eax
    test    esi, esi
    setnz   al
    add     eax, 186h
    push    eax                             ; BytesReturned
    call    sub_4E3930
    add     esp, 0Ch
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E38D1:                             ; CODE XREF: sub_4E3750+Cj
                                            ; sub_4E3750+19j ...
    pop     esi
    xor     al, al
    pop     ebx
    add     esp, 8
    retn
    sub_4E3750 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4E38E0(int InBuffer,DWORD BytesReturned)
    sub_4E38E0 proc near                    ; CODE XREF: sub_4E3750+62p

    InBuffer= dword ptr  4
    BytesReturned= dword ptr  8

    mov     eax, [esp+InBuffer]
    mov     [esp+InBuffer], eax
    mov     al, byte_529E9C
    test    al, al
    jnz     short loc_4E38F4
    xor     al, al
    retn
    ; ---------------------------------------------------------------------------

    loc_4E38F4:                             ; CODE XREF: sub_4E38E0+Fj
    mov     edx, [esp+BytesReturned]
    lea     ecx, [esp+BytesReturned]
    push    0                               ; lpOverlapped
    push    ecx                             ; lpBytesReturned
    mov     ecx, hDevice
    push    8                               ; nOutBufferSize
    push    edx                             ; lpOutBuffer
    lea     eax, [esp+10h+InBuffer]
    push    4                               ; nInBufferSize
    push    eax                             ; lpInBuffer
    push    9C406404h                       ; dwIoControlCode
    push    ecx                             ; hDevice
    call    ds:DeviceIoControl
    cmp     [esp+BytesReturned], 8
    jz      short loc_4E3924
    xor     eax, eax

    loc_4E3924:                             ; CODE XREF: sub_4E38E0+40j
    xor     edx, edx
    test    eax, eax
    setnz   dl
    mov     al, dl
    retn
    sub_4E38E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4E3930(DWORD BytesReturned,int,int)
    sub_4E3930 proc near                    ; CODE XREF: sub_4E3750+95p
                                            ; sub_4E3750+ACp ...

    InBuffer= dword ptr -0Ch
    var_8= dword ptr -8
    var_4= dword ptr -4
    BytesReturned= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     al, byte_529E9C
    sub     esp, 0Ch
    test    al, al
    jnz     short loc_4E3942
    xor     al, al
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4E3942:                             ; CODE XREF: sub_4E3930+Aj
    mov     eax, [esp+0Ch+BytesReturned]
    mov     ecx, [esp+0Ch+arg_4]
    mov     edx, [esp+0Ch+arg_8]
    mov     [esp+0Ch+InBuffer], eax
    lea     eax, [esp+0Ch+BytesReturned]
    push    0                               ; lpOverlapped
    push    eax                             ; lpBytesReturned
    mov     [esp+14h+var_8], ecx
    push    0                               ; nOutBufferSize
    push    0                               ; lpOutBuffer
    lea     ecx, [esp+1Ch+InBuffer]
    mov     [esp+1Ch+var_4], edx
    mov     edx, hDevice
    push    0Ch                             ; nInBufferSize
    push    ecx                             ; lpInBuffer
    push    9C406400h                       ; dwIoControlCode
    push    edx                             ; hDevice
    call    ds:DeviceIoControl
    mov     ecx, [esp+0Ch+BytesReturned]
    test    ecx, ecx
    jz      short loc_4E3988
    xor     eax, eax

    loc_4E3988:                             ; CODE XREF: sub_4E3930+54j
    xor     ecx, ecx
    test    eax, eax
    setnz   cl
    mov     al, cl
    add     esp, 0Ch
    retn
    sub_4E3930 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E39A0 proc near                    ; CODE XREF: sub_4E1BE0+3Cp
    mov     eax, dword_529EA0
    retn
    sub_4E39A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E39B0 proc near                    ; CODE XREF: .text:0046CA11p
                                            ; .text:0046CB91p ...
    mov     eax, dword_529EC0
    push    esi
    push    edi
    cmp     eax, 2
    mov     edi, ecx
    jz      short loc_4E3A26
    test    eax, eax
    jnz     short loc_4E3A08
    push    1                               ; Value
    push    offset dword_529EC0             ; Target
    call    ds:InterlockedExchange
    test    eax, eax
    jnz     short loc_4E39F7
    push    offset dword_529EA8             ; lpCriticalSection
    call    ds:InitializeCriticalSection
    push    offset sub_4E3A40               ; void (*)(void)
    call    _atexit
    mov     eax, 2
    add     esp, 4
    mov     dword_529EC0, eax
    jmp     short loc_4E3A08
    ; ---------------------------------------------------------------------------

    loc_4E39F7:                             ; CODE XREF: sub_4E39B0+21j
    cmp     eax, 2
    jnz     short loc_4E3A03
    mov     dword_529EC0, eax
    jmp     short loc_4E3A08
    ; ---------------------------------------------------------------------------

    loc_4E3A03:                             ; CODE XREF: sub_4E39B0+4Aj
    mov     eax, dword_529EC0

    loc_4E3A08:                             ; CODE XREF: sub_4E39B0+10j
                                            ; sub_4E39B0+45j ...
    cmp     eax, 1
    jnz     short loc_4E3A21
    mov     esi, ds:Sleep

    loc_4E3A13:                             ; CODE XREF: sub_4E39B0+6Fj
    push    1                               ; dwMilliseconds
    call    esi ; Sleep
    mov     eax, dword_529EC0
    cmp     eax, 1
    jz      short loc_4E3A13

    loc_4E3A21:                             ; CODE XREF: sub_4E39B0+5Bj
    cmp     eax, 2
    jnz     short loc_4E3A31

    loc_4E3A26:                             ; CODE XREF: sub_4E39B0+Cj
    push    offset dword_529EA8             ; lpCriticalSection
    call    ds:EnterCriticalSection

    loc_4E3A31:                             ; CODE XREF: sub_4E39B0+74j
    mov     eax, edi
    pop     edi
    pop     esi
    retn
    sub_4E39B0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; void sub_4E3A40(void)
    sub_4E3A40 proc near                    ; DATA XREF: sub_4E39B0+2Eo
    push    3                               ; Value
    push    offset dword_529EC0             ; Target
    call    ds:InterlockedExchange
    xor     ecx, ecx
    cmp     eax, 2
    setz    cl
    mov     eax, ecx
    test    eax, eax
    jz      short locret_4E3A66
    push    offset dword_529EA8             ; lpCriticalSection
    call    ds:DeleteCriticalSection

    locret_4E3A66:                          ; CODE XREF: sub_4E3A40+19j
    retn
    sub_4E3A40 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E3A70 proc near                    ; CODE XREF: .text:0046CA3Bp
                                            ; .text:0046CBBBp ...
    cmp     dword_529EC0, 2
    jnz     short locret_4E3A84
    push    offset dword_529EA8             ; lpCriticalSection
    call    ds:LeaveCriticalSection

    locret_4E3A84:                          ; CODE XREF: sub_4E3A70+7j
    retn
    sub_4E3A70 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E3A90 proc near                    ; CODE XREF: std::basic_string<char,std::char_traits<char>,std::allocator<char>>::erase(uint,uint)+A9p
                                            ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)+Ep ...

    var_3E= byte ptr -3Eh
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_1C= dword ptr -1Ch
    var_C= dword ptr -0Ch
    var_4= dword ptr -4

    push    0FFFFFFFFh
    push    offset loc_4FB8E0
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    sub     esp, 34h
    mov     al, [esp+3]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     byte ptr [esp+50h+var_38], al
    mov     edi, offset aStringTooLong      ; "string too long"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    xor     ebx, ebx
    repne scasb
    not     ecx
    dec     ecx
    push    1
    mov     ebp, ecx
    lea     ecx, [esp+54h+var_38]
    push    ebp
    mov     [esp+58h+var_34], ebx
    mov     [esp+58h+var_30], ebx
    mov     [esp+58h+var_2C], ebx
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4E3B08
    mov     edi, [esp+50h+var_34]
    mov     ecx, ebp
    mov     edx, ecx
    mov     esi, offset aStringTooLong      ; "string too long"
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     eax, [esp+50h+var_34]
    mov     [esp+50h+var_30], ebp
    mov     [ebp+eax+0], bl

    loc_4E3B08:                             ; CODE XREF: sub_4E3A90+51j
    lea     ecx, [esp+50h+var_3C]
    mov     [esp+50h+var_4], ebx
    push    ecx
    lea     ecx, [esp+54h+var_28]
    mov     [esp+54h+var_3C], offset Data
    call    ??0exception@@QAE@ABQBD@Z       ; exception::exception(char const * const &)
    mov     dl, byte ptr [esp+50h+var_38]
    push    ebx
    lea     ecx, [esp+54h+var_1C]
    mov     byte ptr [esp+54h+var_4], 1
    mov     byte ptr [esp+54h+var_1C], dl
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     eax, ds:dword_4FDC1C
    lea     ecx, [esp+50h+var_38]
    push    eax
    push    ebx
    push    ecx
    lea     ecx, [esp+5Ch+var_1C]
    call    ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@II@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::assign(std::basic_string<char,std::char_traits<char>,std::allocator<char>> const &,uint,uint)
    lea     edx, [esp+50h+var_28]
    push    offset dword_4FF070
    push    edx
    mov     byte ptr [esp+58h+var_4], bl
    mov     [esp+58h+var_28], offset off_4FDC7C
    call    __CxxThrowException@8           ; _CxxThrowException(x,x)
    mov     eax, [esp+50h+var_34]
    cmp     eax, ebx
    jz      short loc_4E3B9F
    lea     ecx, [eax-1]
    mov     al, [eax-1]
    cmp     al, bl
    jz      short loc_4E3B96
    cmp     al, 0FFh
    jz      short loc_4E3B96
    dec     al
    mov     [ecx], al
    mov     ecx, [esp+50h+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn
    ; ---------------------------------------------------------------------------

    loc_4E3B96:                             ; CODE XREF: sub_4E3A90+E9j
                                            ; sub_4E3A90+EDj
    push    ecx
    call    sub_4B4F20
    add     esp, 4

    loc_4E3B9F:                             ; CODE XREF: sub_4E3A90+DFj
    mov     ecx, [esp+50h+var_C]
    pop     edi
    pop     esi
    pop     ebp
    mov     large fs:0, ecx
    pop     ebx
    add     esp, 40h
    retn
    sub_4E3A90 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000003E BYTES: COLLAPSED FUNCTION std::basic_string<char,std::char_traits<char>,std::allocator<char>>::~basic_string<char,std::char_traits<char>,std::allocator<char>>(void). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000203 BYTES: COLLAPSED FUNCTION std::basic_string<char,std::char_traits<char>,std::allocator<char>>::assign(std::basic_string<char,std::char_traits<char>,std::allocator<char>> const &,uint,uint). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000006 BYTES: COLLAPSED FUNCTION std::basic_string<char,std::char_traits<char>,std::allocator<char>>::max_size(void). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000004B BYTES: COLLAPSED FUNCTION sub_4E3E20. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E3E70 proc near                    ; DATA XREF: .rdata:004FDC84o

    var_1C= dword ptr -1Ch

    sub     esp, 1Ch
    push    ecx
    lea     ecx, [esp+20h+var_1C]
    call    sub_4E3EB0
    lea     eax, [esp+1Ch+var_1C]
    push    offset dword_4FF070
    push    eax
    call    __CxxThrowException@8           ; _CxxThrowException(x,x)
    add     esp, 1Ch
    retn
    sub_4E3E70 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E3E90 proc near                    ; DATA XREF: .rdata:004FDC7Co

    arg_0= byte ptr  8

    push    esi
    mov     esi, ecx
    call    sub_4E3E20                      ; ??1failure@ios_base@std@@UAE@XZ
                                            ; doubtful name
    test    [esp+arg_0], 1
    jz      short loc_4E3EA8
    push    esi
    call    sub_4B4F20
    add     esp, 4

    loc_4E3EA8:                             ; CODE XREF: sub_4E3E90+Dj
    mov     eax, esi
    pop     esi
    retn    4
    sub_4E3E90 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E3EB0 proc near                    ; CODE XREF: sub_4E3E70+8p

    var_10= dword ptr -10h
    var_C= dword ptr -0Ch
    var_4= dword ptr -4
    arg_0= dword ptr  4

    push    0FFFFFFFFh
    push    offset loc_4FB8F8
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    push    ecx
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+1Ch+arg_0]
    push    edi
    mov     ebx, ecx
    push    esi
    mov     [esp+24h+var_10], ebx
    call    ??0exception@@QAE@ABV0@@Z       ; exception::exception(exception const &)
    mov     al, [esi+0Ch]
    add     esi, 0Ch
    add     ebx, 0Ch
    xor     edi, edi
    mov     [esp+20h+var_4], edi
    mov     [ebx], al
    mov     [ebx+4], edi
    mov     [ebx+8], edi
    mov     [ebx+0Ch], edi
    mov     eax, [esi+8]
    mov     ecx, ds:dword_4FDC1C
    mov     ebp, eax
    cmp     ecx, ebp
    jnb     short loc_4E3F05
    mov     ebp, ecx

    loc_4E3F05:                             ; CODE XREF: sub_4E3EB0+51j
    cmp     ebx, esi
    jnz     short loc_4E3F65
    cmp     ebp, edi
    mov     esi, ecx
    jbe     short loc_4E3F14
    call    sub_4E4010

    loc_4E3F14:                             ; CODE XREF: sub_4E3EB0+5Dj
    mov     ecx, ebx
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    mov     eax, [ebx+8]
    sub     eax, ebp
    cmp     eax, esi
    jnb     short loc_4E3F26
    mov     esi, eax

    loc_4E3F26:                             ; CODE XREF: sub_4E3EB0+72j
    cmp     esi, edi
    jbe     short loc_4E3F5C
    mov     ecx, [ebx+4]
    lea     edx, [ebp+esi+0]
    sub     eax, esi
    add     edx, ecx
    push    eax                             ; size_t
    add     ebp, ecx
    push    edx                             ; void *
    push    ebp                             ; void *
    call    _memcpy
    mov     ebp, [ebx+8]
    add     esp, 0Ch
    sub     ebp, esi
    mov     ecx, ebx
    push    edi
    push    ebp
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4E3F5C
    push    ebp
    mov     ecx, ebx
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4E3F5C:                             ; CODE XREF: sub_4E3EB0+78j
                                            ; sub_4E3EB0+A2j
    mov     ecx, ebx
    call    ?_Split@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Split(void)
    jmp     short loc_4E3FE2
    ; ---------------------------------------------------------------------------

    loc_4E3F65:                             ; CODE XREF: sub_4E3EB0+57j
    cmp     ebp, edi
    jbe     short loc_4E3FAD
    cmp     ebp, eax
    jnz     short loc_4E3FAD
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4E3F79
    mov     eax, offset dword_4FDC98

    loc_4E3F79:                             ; CODE XREF: sub_4E3EB0+C2j
    cmp     byte ptr [eax-1], 0FEh
    jnb     short loc_4E3FAD
    push    1
    mov     ecx, ebx
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     eax, [esi+4]
    cmp     eax, edi
    jnz     short loc_4E3F94
    mov     eax, offset dword_4FDC98

    loc_4E3F94:                             ; CODE XREF: sub_4E3EB0+DDj
    mov     [ebx+4], eax
    mov     ecx, [esi+8]
    mov     [ebx+8], ecx
    mov     edx, [esi+0Ch]
    mov     [ebx+0Ch], edx
    mov     cl, [eax-1]
    inc     cl
    mov     [eax-1], cl
    jmp     short loc_4E3FE2
    ; ---------------------------------------------------------------------------

    loc_4E3FAD:                             ; CODE XREF: sub_4E3EB0+B7j
                                            ; sub_4E3EB0+BBj ...
    push    1
    push    ebp
    mov     ecx, ebx
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4E3FE2
    mov     esi, [esi+4]
    cmp     esi, edi
    jnz     short loc_4E3FC7
    mov     esi, offset dword_4FDC98

    loc_4E3FC7:                             ; CODE XREF: sub_4E3EB0+110j
    mov     edi, [ebx+4]
    mov     ecx, ebp
    mov     eax, ecx
    push    ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    rep movsb
    mov     ecx, ebx
    call    ?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Eos(uint)

    loc_4E3FE2:                             ; CODE XREF: sub_4E3EB0+B3j
                                            ; sub_4E3EB0+FBj ...
    mov     eax, [esp+20h+var_10]
    mov     ecx, [esp+20h+var_C]
    pop     edi
    pop     esi
    mov     dword ptr [eax], offset off_4FDC7C
    pop     ebp
    mov     large fs:0, ecx
    pop     ebx
    add     esp, 10h
    retn    4
    sub_4E3EB0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E4010 proc near                    ; CODE XREF: sub_4C35C0+51p
                                            ; sub_4C3740+51p ...

    var_3E= byte ptr -3Eh
    var_3C= dword ptr -3Ch
    var_38= dword ptr -38h
    var_34= dword ptr -34h
    var_30= dword ptr -30h
    var_2C= dword ptr -2Ch
    var_28= dword ptr -28h
    var_1C= dword ptr -1Ch
    var_C= dword ptr -0Ch
    var_4= dword ptr -4

    push    0FFFFFFFFh
    push    offset loc_4FB920
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    sub     esp, 34h
    mov     al, [esp+3]
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     byte ptr [esp+50h+var_38], al
    mov     edi, offset aInvalidStringP     ; "invalid string position"
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    xor     ebx, ebx
    repne scasb
    not     ecx
    dec     ecx
    push    1
    mov     ebp, ecx
    lea     ecx, [esp+54h+var_38]
    push    ebp
    mov     [esp+58h+var_34], ebx
    mov     [esp+58h+var_30], ebx
    mov     [esp+58h+var_2C], ebx
    call    ?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE_NI_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Grow(uint,bool)
    test    al, al
    jz      short loc_4E4088
    mov     edi, [esp+50h+var_34]
    mov     ecx, ebp
    mov     edx, ecx
    mov     esi, offset aInvalidStringP     ; "invalid string position"
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     eax, [esp+50h+var_34]
    mov     [esp+50h+var_30], ebp
    mov     [ebp+eax+0], bl

    loc_4E4088:                             ; CODE XREF: sub_4E4010+51j
    lea     ecx, [esp+50h+var_3C]
    mov     [esp+50h+var_4], ebx
    push    ecx
    lea     ecx, [esp+54h+var_28]
    mov     [esp+54h+var_3C], offset Data
    call    ??0exception@@QAE@ABQBD@Z       ; exception::exception(char const * const &)
    mov     dl, byte ptr [esp+50h+var_38]
    push    ebx
    lea     ecx, [esp+54h+var_1C]
    mov     byte ptr [esp+54h+var_4], 1
    mov     byte ptr [esp+54h+var_1C], dl
    call    ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEX_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy(bool)
    mov     eax, ds:dword_4FDC1C
    lea     ecx, [esp+50h+var_38]
    push    eax
    push    ebx
    push    ecx
    lea     ecx, [esp+5Ch+var_1C]
    call    ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@II@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::assign(std::basic_string<char,std::char_traits<char>,std::allocator<char>> const &,uint,uint)
    lea     edx, [esp+50h+var_28]
    push    offset dword_4FEFB8
    push    edx
    mov     byte ptr [esp+58h+var_4], bl
    mov     [esp+58h+var_28], offset off_4FDCB4
    call    __CxxThrowException@8           ; _CxxThrowException(x,x)
    mov     eax, [esp+50h+var_34]
    cmp     eax, ebx
    jz      short loc_4E411F
    lea     ecx, [eax-1]
    mov     al, [eax-1]
    cmp     al, bl
    jz      short loc_4E4116
    cmp     al, 0FFh
    jz      short loc_4E4116
    dec     al
    mov     [ecx], al
    mov     ecx, [esp+50h+var_C]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 40h
    retn
    ; ---------------------------------------------------------------------------

    loc_4E4116:                             ; CODE XREF: sub_4E4010+E9j
                                            ; sub_4E4010+EDj
    push    ecx
    call    sub_4B4F20
    add     esp, 4

    loc_4E411F:                             ; CODE XREF: sub_4E4010+DFj
    mov     ecx, [esp+50h+var_C]
    pop     edi
    pop     esi
    pop     ebp
    mov     large fs:0, ecx
    pop     ebx
    add     esp, 40h
    retn
    sub_4E4010 endp

    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_61:
    mov     al, byte_52A500
    push    ebx
    mov     bl, 1
    test    bl, al
    jnz     short loc_4E4153
    or      al, bl
    mov     byte_52A500, al

    loc_4E4153:                             ; CODE XREF: .text:004E414Aj
    call    sub_4E41E0
    mov     al, byte_52A501
    test    bl, al
    jnz     short loc_4E4168
    or      al, bl
    mov     byte_52A501, al

    loc_4E4168:                             ; CODE XREF: .text:004E415Fj
    call    sub_4E41F0
    mov     al, byte_52A4E4
    test    bl, al
    jnz     short loc_4E417D
    or      al, bl
    mov     byte_52A4E4, al

    loc_4E417D:                             ; CODE XREF: .text:004E4174j
    call    sub_4E4200
    mov     al, byte_52A502
    test    bl, al
    jnz     short loc_4E4192
    or      al, bl
    mov     byte_52A502, al

    loc_4E4192:                             ; CODE XREF: .text:004E4189j
    call    sub_4E4210
    mov     al, byte_52A503
    test    bl, al
    jnz     short loc_4E41A7
    or      al, bl
    mov     byte_52A503, al

    loc_4E41A7:                             ; CODE XREF: .text:004E419Ej
    call    sub_4E4220
    mov     al, byte_52A504
    test    bl, al
    jnz     short loc_4E41BC
    or      al, bl
    mov     byte_52A504, al

    loc_4E41BC:                             ; CODE XREF: .text:004E41B3j
    call    sub_4E4230
    mov     al, byte_52A505
    test    bl, al
    jnz     short loc_4E41D1
    or      al, bl
    mov     byte_52A505, al

    loc_4E41D1:                             ; CODE XREF: .text:004E41C8j
    call    sub_4E4240
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E41E0 proc near                    ; CODE XREF: .text:004E4153p
    push    offset nullsub_61               ; void (*)(void)
    call    _atexit
    add     esp, 4
    retn
    sub_4E41E0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E41F0 proc near                    ; CODE XREF: .text:004E4168p
    push    offset nullsub_60               ; void (*)(void)
    call    _atexit
    add     esp, 4
    retn
    sub_4E41F0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E4200 proc near                    ; CODE XREF: .text:004E417Dp
    push    offset nullsub_48               ; void (*)(void)
    call    _atexit
    add     esp, 4
    retn
    sub_4E4200 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E4210 proc near                    ; CODE XREF: .text:004E4192p
    push    offset nullsub_59               ; void (*)(void)
    call    _atexit
    add     esp, 4
    retn
    sub_4E4210 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E4220 proc near                    ; CODE XREF: .text:004E41A7p
    push    offset nullsub_58               ; void (*)(void)
    call    _atexit
    add     esp, 4
    retn
    sub_4E4220 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E4230 proc near                    ; CODE XREF: .text:004E41BCp
    push    offset nullsub_57               ; void (*)(void)
    call    _atexit
    add     esp, 4
    retn
    sub_4E4230 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E4240 proc near                    ; CODE XREF: .text:004E41D1p
    push    offset nullsub_56               ; void (*)(void)
    call    _atexit
    add     esp, 4
    retn
    sub_4E4240 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_56. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_57. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_58. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_59. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_60. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_61. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000068 BYTES: COLLAPSED FUNCTION _sprintf. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000017 BYTES: COLLAPSED FUNCTION __fpmath. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000001 BYTES: COLLAPSED FUNCTION nullsub_32. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000038 BYTES: COLLAPSED FUNCTION __cfltcvt_init. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     ecx, [esp+4]
    mov     eax, dword_529EC4
    mov     dword_529EC4, ecx
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: library function bp-based frame

    __ftol proc near                        ; CODE XREF: sub_401360+4C4p
                                            ; .text:0040267Ep ...

    var_C= qword ptr -0Ch
    var_4= word ptr -4
    var_2= word ptr -2

    push    ebp
    mov     ebp, esp
    add     esp, 0FFFFFFF4h
    fstcw   [ebp+var_2]
    wait
    mov     ax, [ebp+var_2]
    or      ah, 0Ch
    mov     [ebp+var_4], ax
    fldcw   [ebp+var_4]
    fistp   [ebp+var_C]
    fldcw   [ebp+var_2]
    mov     eax, dword ptr [ebp+var_C]
    mov     edx, dword ptr [ebp+var_C+4]
    leave
    retn
    __ftol endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000021 BYTES: COLLAPSED FUNCTION __allshr. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000034 BYTES: COLLAPSED FUNCTION __allmul. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000AA BYTES: COLLAPSED FUNCTION __alldiv. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000001F BYTES: COLLAPSED FUNCTION __allshl. PRESS KEYPAD "+" TO EXPAND]
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E4510 proc near                    ; CODE XREF: sub_40C250+A0p
                                            ; sub_40C250+CAp ...

    arg_0= dword ptr  0Ch
    arg_4= dword ptr  10h
    arg_8= dword ptr  14h

    push    ebx
    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    push    esi
    call    __lock_file
    add     esp, 4
    push    esi
    call    sub_4EAE00
    mov     ecx, [esp+8+arg_4]
    add     esp, 4
    mov     edi, eax
    lea     eax, [esp+4+arg_8]
    push    eax
    push    ecx
    push    esi
    call    __output
    add     esp, 0Ch
    mov     ebx, eax
    push    esi
    push    edi
    call    __ftbuf
    add     esp, 8
    push    esi
    call    __unlock_file
    add     esp, 4
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebx
    retn
    sub_4E4510 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000062 BYTES: COLLAPSED FUNCTION _atof. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000030 BYTES: COLLAPSED FUNCTION __cinit. PRESS KEYPAD "+" TO EXPAND]
    ; [00000012 BYTES: COLLAPSED FUNCTION _exit. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000012 BYTES: COLLAPSED FUNCTION __exit. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    __cexit:
    push    1
    push    0
    push    0
    call    _doexit
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 4

    __c_exit:
    push    1
    push    1
    push    0
    call    _doexit
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [000000B2 BYTES: COLLAPSED FUNCTION _doexit. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000000B BYTES: COLLAPSED FUNCTION __lockexit. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000000B BYTES: COLLAPSED FUNCTION __unlockexit. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000020 BYTES: COLLAPSED FUNCTION __initterm. PRESS KEYPAD "+" TO EXPAND]
    ; [000000FE BYTES: COLLAPSED FUNCTION _strncpy. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000000D BYTES: COLLAPSED FUNCTION _srand. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000002D BYTES: COLLAPSED FUNCTION _rand. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000003D BYTES: COLLAPSED FUNCTION _fclose. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000065 BYTES: COLLAPSED FUNCTION __fclose_lk. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000037 BYTES: COLLAPSED FUNCTION __fsopen. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000015 BYTES: COLLAPSED FUNCTION _fopen. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000080 BYTES: COLLAPSED FUNCTION _strstr. PRESS KEYPAD "+" TO EXPAND]
    ; [0000008F BYTES: COLLAPSED FUNCTION __onexit. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000015 BYTES: COLLAPSED FUNCTION _atexit. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ___onexitinit:
    push    80h
    call    _malloc
    add     esp, 4
    mov     dword_52B658, eax
    test    eax, eax
    jnz     short loc_4E4B05
    push    18h
    call    __amsg_exit
    mov     eax, dword_52B658
    add     esp, 4

    loc_4E4B05:                             ; CODE XREF: .text:004E4AF4j
    mov     dword ptr [eax], 0
    mov     eax, dword_52B658
    mov     dword_52B654, eax
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000002F BYTES: COLLAPSED FUNCTION __alloca_probe. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000038 BYTES: COLLAPSED FUNCTION _strncmp. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000068 BYTES: COLLAPSED FUNCTION __snprintf. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000030 BYTES: COLLAPSED FUNCTION _isalpha. PRESS KEYPAD "+" TO EXPAND]
    ; [0000002A BYTES: COLLAPSED FUNCTION _isupper. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000002A BYTES: COLLAPSED FUNCTION _islower. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000002A BYTES: COLLAPSED FUNCTION _isdigit. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000002F BYTES: COLLAPSED FUNCTION _isxdigit. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000002A BYTES: COLLAPSED FUNCTION _isspace. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000002A BYTES: COLLAPSED FUNCTION _ispunct. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000030 BYTES: COLLAPSED FUNCTION _isalnum. PRESS KEYPAD "+" TO EXPAND]
    ; [00000030 BYTES: COLLAPSED FUNCTION _isprint. PRESS KEYPAD "+" TO EXPAND]
    ; [00000030 BYTES: COLLAPSED FUNCTION _isgraph. PRESS KEYPAD "+" TO EXPAND]
    ; [0000002A BYTES: COLLAPSED FUNCTION _iscntrl. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000000D BYTES: COLLAPSED FUNCTION ___isascii. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000008 BYTES: COLLAPSED FUNCTION ___toascii. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000043 BYTES: COLLAPSED FUNCTION ___iscsymf. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000043 BYTES: COLLAPSED FUNCTION ___iscsym. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000099 BYTES: COLLAPSED FUNCTION _atol. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000000E BYTES: COLLAPSED FUNCTION _atoi. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [000000CE BYTES: COLLAPSED FUNCTION __atoi64. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [000000F9 BYTES: COLLAPSED FUNCTION _floor. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000123 BYTES: COLLAPSED FUNCTION _strncat. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000E8 BYTES: COLLAPSED FUNCTION _strtok. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000019 BYTES: COLLAPSED FUNCTION __CIpow. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    _pow:
    lea     edx, [esp+0Ch]
    call    unknown_libname_96

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E5392 proc near                    ; CODE XREF: __CIpow+10p

    var_8C= qword ptr -8Ch
    var_84= qword ptr -84h
    var_4= word ptr -4
    arg_0= dword ptr  4
    arg_7= byte ptr  0Bh
    arg_A= byte ptr  0Eh
    arg_C= dword ptr  10h
    arg_12= byte ptr  16h

    mov     ecx, eax
    push    eax
    fstcw   [esp+4+var_4]
    cmp     [esp+4+var_4], 27Fh
    jz      short loc_4E53A6
    call    unknown_libname_94

    loc_4E53A6:                             ; CODE XREF: sub_4E5392+Dj
    and     ecx, 7FF00000h
    lea     edx, [esp+4+arg_0]
    cmp     ecx, 7FF00000h
    jz      loc_4E5459
    call    unknown_libname_96
    jz      loc_4E5455
    test    eax, 7FF00000h
    jz      loc_4E54C8

    loc_4E53D2:                             ; CODE XREF: sub_4E5392+143j
    mov     cl, [esp+4+arg_7]
    and     cl, 80h
    jnz     loc_4E5540

    loc_4E53DF:                             ; CODE XREF: sub_4E5392+1B9j
    fyl2x
    call    unknown_libname_93
    cmp     cl, 1
    jnz     short loc_4E53ED
    fchs

    loc_4E53ED:                             ; CODE XREF: sub_4E5392+57j
    cmp     dword_529EC4, 0
    jnz     unknown_libname_98
    lea     ecx, ds:50DEE8h
    mov     edx, 1Dh
    jmp     unknown_libname_101
    ; ---------------------------------------------------------------------------

    loc_4E540A:                             ; CODE XREF: sub_4E5392+B1j
                                            ; sub_4E5392+C1j ...
    cmp     dword_529EC4, 0
    jnz     unknown_libname_98
    lea     ecx, ds:50DEE8h
    mov     edx, 1Dh
    call    unknown_libname_91
    pop     edx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E5429:                             ; CODE XREF: sub_4E5392+D2j
    lea     edx, [esp+8]
    call    unknown_libname_96
    test    [esp+arg_12], 8
    jnz     short loc_4E543C
    inc     ecx
    jmp     short loc_4E546F
    ; ---------------------------------------------------------------------------

    loc_4E543C:                             ; CODE XREF: sub_4E5392+A5j
                                            ; sub_4E5392+B8j
    faddp   st(1), st
    mov     eax, 1
    jmp     short loc_4E540A
    ; ---------------------------------------------------------------------------

    loc_4E5445:                             ; CODE XREF: sub_4E5392+F9j
    test    [esp+arg_A], 8
    jnz     short loc_4E543C

    loc_4E544C:                             ; CODE XREF: sub_4E5392+FDj
    faddp   st(1), st
    mov     eax, 7
    jmp     short loc_4E540A
    ; ---------------------------------------------------------------------------

    loc_4E5455:                             ; CODE XREF: sub_4E5392+2Fj
    xor     ecx, ecx
    jmp     short loc_4E546F
    ; ---------------------------------------------------------------------------

    loc_4E5459:                             ; CODE XREF: sub_4E5392+24j
    xor     ecx, ecx
    and     eax, 0FFFFFh
    or      eax, [esp+10h]
    jnz     short loc_4E5429
    lea     edx, [esp+4+arg_0]
    call    unknown_libname_96

    loc_4E546F:                             ; CODE XREF: sub_4E5392+A8j
                                            ; sub_4E5392+C5j
    mov     eax, [esp+0Ch]
    mov     edx, eax
    and     eax, 7FF00000h
    and     edx, 0FFFFFh
    cmp     eax, 7FF00000h
    jnz     short loc_4E548D
    or      edx, [esp+4+arg_0]
    jnz     short loc_4E5445

    loc_4E548D:                             ; CODE XREF: sub_4E5392+F3j
    test    ecx, ecx
    jnz     short loc_4E544C
    sub     esp, 74h
    mov     ecx, esp
    push    ecx
    sub     esp, 10h
    fstp    [esp+8Ch+var_8C]
    fstp    [esp+8Ch+var_84]
    fsave   byte ptr [ecx+8]
    call    __powhlp
    add     esp, 10h
    pop     ecx
    frstor  byte ptr [ecx+8]
    fld     qword ptr [ecx]
    add     esp, 74h
    test    eax, eax
    jz      unknown_libname_98
    mov     eax, 1
    jmp     loc_4E540A
    ; ---------------------------------------------------------------------------

    loc_4E54C8:                             ; CODE XREF: sub_4E5392+3Aj
    mov     eax, [esp+0Ch]
    and     eax, 0FFFFFh
    or      eax, [esp+4+arg_0]
    jnz     loc_4E53D2
    fstp    st
    mov     eax, [esp+4+arg_C]
    test    eax, 7FF00000h
    jz      short loc_4E5525
    call    sub_4E5565
    mov     ch, [esp+4+arg_7]
    shr     ch, 7
    test    [esp+4+arg_C+3], 80h
    jz      short loc_4E5514
    fld     tbyte_50E360
    test    ch, cl
    jz      short loc_4E550A
    fchs

    loc_4E550A:                             ; CODE XREF: sub_4E5392+174j
    mov     eax, 2
    jmp     loc_4E540A
    ; ---------------------------------------------------------------------------

    loc_4E5514:                             ; CODE XREF: sub_4E5392+16Aj
    fldz
    test    ch, cl
    jz      unknown_libname_98
    fchs
    jmp     unknown_libname_98
    ; ---------------------------------------------------------------------------

    loc_4E5525:                             ; CODE XREF: sub_4E5392+154j
    fstp    st
    and     eax, 0FFFFFh
    or      eax, [esp+10h]
    jnz     short loc_4E5539
    fld1
    jmp     unknown_libname_98
    ; ---------------------------------------------------------------------------

    loc_4E5539:                             ; CODE XREF: sub_4E5392+19Ej
    fldz
    jmp     unknown_libname_98
    ; ---------------------------------------------------------------------------

    loc_4E5540:                             ; CODE XREF: sub_4E5392+47j
    fld     st(1)
    call    sub_4E5565
    fchs
    test    cl, cl
    jnz     loc_4E53DF
    fstp    st
    fstp    st
    fld     tbyte_50E3C0
    mov     eax, 1
    jmp     loc_4E540A
    sub_4E5392 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E5565 proc near                    ; CODE XREF: sub_4E5392+156p
                                            ; sub_4E5392+1B0p
    fld     st
    frndint
    fcomp   st(1)
    mov     cl, 0
    fstsw   ax
    sahf
    jnz     short loc_4E558A
    fmul    dbl_50DEE0
    inc     cl
    fld     st
    frndint
    fcompp  st(1), st
    fstsw   ax
    sahf
    jnz     short locret_4E5589
    inc     cl

    locret_4E5589:                          ; CODE XREF: sub_4E5565+20j
    retn
    ; ---------------------------------------------------------------------------

    loc_4E558A:                             ; CODE XREF: sub_4E5565+Cj
    fstp    st
    retn
    sub_4E5565 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [0000002D BYTES: COLLAPSED FUNCTION _JumpToContinuation(void *,EHRegistrationNode *). PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn    8
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000007 BYTES: COLLAPSED FUNCTION sub_4E55D0. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000007 BYTES: COLLAPSED FUNCTION sub_4E55E0. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000007 BYTES: COLLAPSED FUNCTION sub_4E55F0. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000056 BYTES: COLLAPSED FUNCTION _UnwindNestedFrames(EHRegistrationNode *,EHExceptionRecord *). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000003C BYTES: COLLAPSED FUNCTION ___CxxFrameHandler. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000001D BYTES: COLLAPSED FUNCTION __CxxLongjmpUnwind(x). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000005B BYTES: COLLAPSED FUNCTION _CallCatchBlock2(EHRegistrationNode *,_s_FuncInfo const *,void *,int,ulong). PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000002A BYTES: COLLAPSED FUNCTION CatchGuardHandler(EHExceptionRecord *,CatchGuardRN *,void *,void *). PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000CC BYTES: COLLAPSED FUNCTION unknown_libname_62. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000081 BYTES: COLLAPSED FUNCTION TranslatorGuardHandler(EHExceptionRecord *,TranslatorGuardRN *,void *,void *). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000007F BYTES: COLLAPSED FUNCTION _GetRangeOfTrysToCheck(_s_FuncInfo const *,int,int,uint *,uint *). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000020 BYTES: COLLAPSED FUNCTION __global_unwind2. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    __unwind_handler:                       ; DATA XREF: __local_unwind2+Ao
                                            ; __abnormal_termination+9o
    mov     ecx, [esp+4]
    test    dword ptr [ecx+4], 6
    mov     eax, 1
    jz      short locret_4E5971
    mov     eax, [esp+8]
    mov     edx, [esp+10h]
    mov     [edx], eax
    mov     eax, 3

    locret_4E5971:                          ; CODE XREF: .text:004E5960j
    retn
    ; [00000068 BYTES: COLLAPSED FUNCTION __local_unwind2. PRESS KEYPAD "+" TO EXPAND]
    ; [00000023 BYTES: COLLAPSED FUNCTION __abnormal_termination. PRESS KEYPAD "+" TO EXPAND]
    ; [00000009 BYTES: COLLAPSED FUNCTION __NLG_Notify1. PRESS KEYPAD "+" TO EXPAND]
    ; [00000018 BYTES: COLLAPSED FUNCTION __NLG_Notify. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000008 BYTES: COLLAPSED FUNCTION __tolower. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000082 BYTES: COLLAPSED FUNCTION _tolower. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4E5AC0(const CHAR MultiByteStr)
    sub_4E5AC0 proc near                    ; CODE XREF: _tolower+57p
                                            ; __strcmpi+94p ...

    DestStr= word ptr -8
    MultiByteStr= byte ptr  4

    mov     eax, Locale
    sub     esp, 8
    test    eax, eax
    push    ebx
    jnz     short loc_4E5AEB
    mov     eax, dword ptr [esp+0Ch+MultiByteStr]
    cmp     eax, 41h
    jl      loc_4E5BB9
    cmp     eax, 5Ah
    jg      loc_4E5BB9
    add     eax, 20h
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E5AEB:                             ; CODE XREF: sub_4E5AC0+Bj
    mov     ebx, dword ptr [esp+0Ch+MultiByteStr]
    cmp     ebx, 100h
    jge     short loc_4E5B23
    cmp     cchMultiByte, 1
    jle     short loc_4E5B0D
    push    1                               ; int
    push    ebx                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4E5B18
    ; ---------------------------------------------------------------------------

    loc_4E5B0D:                             ; CODE XREF: sub_4E5AC0+3Ej
    mov     eax, dword_50E020
    mov     al, [eax+ebx*2]
    and     eax, 1

    loc_4E5B18:                             ; CODE XREF: sub_4E5AC0+4Bj
    test    eax, eax
    jnz     short loc_4E5B23
    mov     eax, ebx
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E5B23:                             ; CODE XREF: sub_4E5AC0+35j
                                            ; sub_4E5AC0+5Aj
    mov     edx, dword_50E020
    mov     eax, ebx
    sar     eax, 8
    mov     ecx, eax
    and     ecx, 0FFh
    test    byte ptr [edx+ecx*2+1], 80h
    jz      short loc_4E5B51
    mov     [esp+0Ch+MultiByteStr], al
    mov     [esp+11h], bl
    mov     byte ptr [esp+12h], 0
    mov     eax, 2
    jmp     short loc_4E5B5F
    ; ---------------------------------------------------------------------------

    loc_4E5B51:                             ; CODE XREF: sub_4E5AC0+7Bj
    mov     [esp+0Ch+MultiByteStr], bl
    mov     byte ptr [esp+11h], 0
    mov     eax, 1

    loc_4E5B5F:                             ; CODE XREF: sub_4E5AC0+8Fj
    push    1                               ; int
    push    0                               ; CodePage
    lea     ecx, [esp+14h+DestStr]
    push    3                               ; cchDest
    push    ecx                             ; lpDestStr
    lea     edx, [esp+1Ch+MultiByteStr]
    push    eax                             ; lpWideCharStr
    mov     eax, Locale
    push    edx                             ; lpMultiByteStr
    push    100h                            ; dwMapFlags
    push    eax                             ; Locale
    call    sub_4EE520
    add     esp, 20h
    test    eax, eax
    jnz     short loc_4E5B8E
    mov     eax, ebx
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E5B8E:                             ; CODE XREF: sub_4E5AC0+C5j
    cmp     eax, 1
    jnz     short loc_4E5BA1
    mov     eax, dword ptr [esp+0Ch+DestStr]
    and     eax, 0FFh
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E5BA1:                             ; CODE XREF: sub_4E5AC0+D1j
    mov     eax, dword ptr [esp+0Ch+DestStr+1]
    mov     ecx, dword ptr [esp+0Ch+DestStr]
    and     eax, 0FFh
    and     ecx, 0FFh
    shl     eax, 8
    or      eax, ecx

    loc_4E5BB9:                             ; CODE XREF: sub_4E5AC0+14j
                                            ; sub_4E5AC0+1Dj
    pop     ebx
    add     esp, 8
    retn
    sub_4E5AC0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E5BC0 proc near                    ; CODE XREF: sub_44B140+23p
                                            ; sub_44B140+45p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h

    push    esi
    mov     esi, [esp+arg_C]
    push    edi
    push    esi
    call    __lock_file
    mov     eax, [esp+8+arg_8]
    mov     ecx, [esp+8+arg_4]
    mov     edx, [esp+8+arg_0]
    add     esp, 4
    push    esi
    push    eax
    push    ecx
    push    edx
    call    _fread
    add     esp, 10h
    mov     edi, eax
    push    esi
    call    __unlock_file
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn
    sub_4E5BC0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000013C BYTES: COLLAPSED FUNCTION _fread. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E5D40 proc near                    ; CODE XREF: sub_44B230+32p
                                            ; sub_44B230+9Ap ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h

    push    esi
    mov     esi, [esp+arg_C]
    push    edi
    push    esi
    call    __lock_file
    mov     eax, [esp+8+arg_8]
    mov     ecx, [esp+8+arg_4]
    mov     edx, [esp+8+arg_0]
    add     esp, 4
    push    esi
    push    eax
    push    ecx
    push    edx
    call    _fwrite
    add     esp, 10h
    mov     edi, eax
    push    esi
    call    __unlock_file
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn
    sub_4E5D40 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000146 BYTES: COLLAPSED FUNCTION _fwrite. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000001A5 BYTES: COLLAPSED FUNCTION _qsort. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000059 BYTES: COLLAPSED FUNCTION _shortsort. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000002C BYTES: COLLAPSED FUNCTION _swap. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000000B BYTES: COLLAPSED FUNCTION __purecall. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000007B BYTES: COLLAPSED FUNCTION __beginthreadex. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000AD BYTES: COLLAPSED FUNCTION _threadstartex(x). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000037 BYTES: COLLAPSED FUNCTION __endthreadex. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000001E6 BYTES: COLLAPSED FUNCTION _localtime. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000012C BYTES: COLLAPSED FUNCTION _time. PRESS KEYPAD "+" TO EXPAND]
    align 8

    loc_4E65B0:                             ; CODE XREF: _strchr+1Dj
    lea     eax, [edx-1]
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [000000BC BYTES: COLLAPSED FUNCTION _strchr. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000042 BYTES: COLLAPSED FUNCTION _sscanf. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000003E BYTES: COLLAPSED FUNCTION _strcspn. PRESS KEYPAD "+" TO EXPAND]
    align 4
    push    esi
    inc     ebx
    xor     dh, [eax]
    pop     eax
    inc     ebx
    xor     [eax], dh
    ; [000000BD BYTES: COLLAPSED FUNCTION __except_handler3. PRESS KEYPAD "+" TO EXPAND]
    ; [0000001B BYTES: COLLAPSED FUNCTION _seh_longjmp_unwind(x). PRESS KEYPAD "+" TO EXPAND]
    ; [00000014 BYTES: COLLAPSED FUNCTION __CIacos. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    _acos:
    lea     edx, [esp+4]
    call    unknown_libname_96
    ; [000000AE BYTES: COLLAPSED FUNCTION sub_4E680D. PRESS KEYPAD "+" TO EXPAND]
    align 8

    _signal:
    push    ebx
    push    ebp
    push    esi
    mov     esi, [esp+14h]
    cmp     esi, 4
    push    edi
    jz      loc_4E6A85
    cmp     esi, 3
    jz      loc_4E6A85
    mov     ebp, [esp+14h]
    cmp     ebp, 2
    jz      loc_4E69A9
    cmp     ebp, 15h
    jz      loc_4E69A9
    cmp     ebp, 16h
    jz      loc_4E69A9
    cmp     ebp, 0Fh
    jz      loc_4E69A9
    cmp     ebp, 8
    jz      short loc_4E6915
    cmp     ebp, 4
    jz      short loc_4E6915
    cmp     ebp, 0Bh
    jnz     loc_4E6A85

    loc_4E6915:                             ; CODE XREF: .text:004E6905j
                                            ; .text:004E690Aj
    call    __getptd
    mov     ebx, eax
    cmp     dword ptr [ebx+50h], offset dword_50E6D0
    jnz     short loc_4E695D
    mov     eax, dword_50E750
    push    eax
    call    _malloc
    add     esp, 4
    mov     [ebx+50h], eax
    test    eax, eax
    jz      loc_4E6A85
    mov     ecx, dword_50E750
    mov     esi, offset dword_50E6D0
    mov     edx, ecx
    mov     edi, eax
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb
    mov     esi, [esp+18h]

    loc_4E695D:                             ; CODE XREF: .text:004E6923j
    mov     eax, [ebx+50h]
    push    eax
    push    ebp
    call    _siglookup
    add     esp, 8
    test    eax, eax
    jz      loc_4E6A85
    mov     ecx, [eax+4]
    mov     edi, [eax+8]
    cmp     ecx, ebp
    jnz     loc_4E6A7E

    loc_4E6980:                             ; CODE XREF: .text:004E69A0j
    mov     [eax+8], esi
    mov     ecx, dword_50E754
    mov     edx, [ebx+50h]
    add     eax, 0Ch
    lea     ecx, [ecx+ecx*2]
    lea     ecx, [edx+ecx*4]
    cmp     eax, ecx
    jnb     loc_4E6A7E
    cmp     [eax+4], ebp
    jz      short loc_4E6980
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E69A9:                             ; CODE XREF: .text:004E68E1j
                                            ; .text:004E68EAj ...
    push    1
    call    __lock
    add     esp, 4
    cmp     ebp, 2
    jz      short loc_4E69BD
    cmp     ebp, 15h
    jnz     short loc_4E69E1

    loc_4E69BD:                             ; CODE XREF: .text:004E69B6j
    mov     eax, dword_529F38
    test    eax, eax
    jnz     short loc_4E69E1
    push    1
    push    offset _ctrlevent_capture@4     ; ctrlevent_capture(x)
    call    ds:SetConsoleCtrlHandler
    cmp     eax, 1
    jnz     loc_4E6A98
    mov     dword_529F38, eax

    loc_4E69E1:                             ; CODE XREF: .text:004E69BBj
                                            ; .text:004E69C4j
    add     ebp, 0FFFFFFFEh
    cmp     ebp, 14h
    ja      loc_4E6A70
    xor     edx, edx
    mov     dl, ss:byte_4E6AD8[ebp]
    jmp     ds:off_4E6AC4[edx*4]

    loc_4E69FC:                             ; DATA XREF: .text:004E6AC4o
    mov     edi, dword_529F28
    push    1
    mov     dword_529F28, esi
    call    __unlock
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E6A19:                             ; CODE XREF: .text:004E69F5j
                                            ; DATA XREF: .text:004E6ACCo
    mov     edi, dword_529F2C
    push    1
    mov     dword_529F2C, esi
    call    __unlock
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E6A36:                             ; CODE XREF: .text:004E69F5j
                                            ; DATA XREF: .text:004E6AD0o
    mov     edi, dword_529F30
    push    1
    mov     dword_529F30, esi
    call    __unlock
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E6A53:                             ; CODE XREF: .text:004E69F5j
                                            ; DATA XREF: .text:004E6AC8o
    mov     edi, dword_529F34
    push    1
    mov     dword_529F34, esi
    call    __unlock
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E6A70:                             ; CODE XREF: .text:004E69E7j
                                            ; .text:004E69F5j
                                            ; DATA XREF: ...
    mov     edi, [esp+18h]
    push    1
    call    __unlock
    add     esp, 4

    loc_4E6A7E:                             ; CODE XREF: .text:004E697Aj
                                            ; .text:004E6997j
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E6A85:                             ; CODE XREF: .text:004E68CBj
                                            ; .text:004E68D4j ...
    call    __errno
    mov     dword ptr [eax], 16h
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E6A98:                             ; CODE XREF: .text:004E69D6j
    call    ds:GetLastError
    mov     esi, eax
    call    ___doserrno
    push    1
    mov     [eax], esi
    call    __unlock
    add     esp, 4
    call    __errno
    pop     edi
    pop     esi
    mov     dword ptr [eax], 16h
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    off_4E6AC4 dd offset loc_4E69FC         ; DATA XREF: .text:004E69F5r
    dd offset loc_4E6A53
    dd offset loc_4E6A19
    dd offset loc_4E6A36
    dd offset loc_4E6A70
    byte_4E6AD8 db 0                        ; DATA XREF: .text:004E69EFr
    dd 3 dup(4040404h), 4040401h, 3020404h
    align 4
    ; [00000084 BYTES: COLLAPSED FUNCTION ctrlevent_capture(x). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000001D8 BYTES: COLLAPSED FUNCTION _raise. PRESS KEYPAD "+" TO EXPAND]
    off_4E6D58 dd offset loc_4E6BAE         ; DATA XREF: _raise+27r
    dd offset loc_4E6C12
    dd offset loc_4E6C12
    dd offset loc_4E6C12
    dd offset loc_4E6BF9
    dd offset loc_4E6BC7
    dd offset loc_4E6BE0
    dd offset loc_4E6D4D
    byte_4E6D78 db 0                        ; DATA XREF: _raise+21r
    ; ---------------------------------------------------------------------------
    pop     es
    add     [edi], eax
    pop     es
    pop     es
    add     al, [edi]
    pop     es
    add     eax, [edi]
    pop     es
    pop     es
    add     al, 7
    pop     es
    pop     es
    pop     es
    pop     es
    add     eax, 90909006h
    ; [0000003F BYTES: COLLAPSED FUNCTION _siglookup. PRESS KEYPAD "+" TO EXPAND]
    align 4

    ___fpecode:
    call    __getptd
    add     eax, 58h
    retn
    ; ---------------------------------------------------------------------------
    align 8
    ; [00000009 BYTES: COLLAPSED FUNCTION ___pxcptinfoptrs. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000027 BYTES: COLLAPSED FUNCTION _strrchr. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000171 BYTES: COLLAPSED FUNCTION __splitpath. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000001A8 BYTES: COLLAPSED FUNCTION start. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000002A BYTES: COLLAPSED FUNCTION __amsg_exit. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E7180 proc near                    ; CODE XREF: start+62p start+75p

    arg_0= dword ptr  4

    cmp     dword_529F44, 1
    jnz     short loc_4E718E
    call    __FF_MSGBANNER

    loc_4E718E:                             ; CODE XREF: sub_4E7180+7j
    mov     eax, [esp+arg_0]
    push    eax
    call    __NMSG_WRITE
    add     esp, 4
    push    0FFh                            ; uExitCode
    call    ds:ExitProcess
    retn
    sub_4E7180 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000008 BYTES: COLLAPSED FUNCTION __toupper. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000082 BYTES: COLLAPSED FUNCTION _toupper. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4E7250(const CHAR MultiByteStr)
    sub_4E7250 proc near                    ; CODE XREF: _toupper+57p

    DestStr= word ptr -8
    MultiByteStr= byte ptr  4

    mov     eax, Locale
    sub     esp, 8
    test    eax, eax
    push    ebx
    jnz     short loc_4E727B
    mov     eax, dword ptr [esp+0Ch+MultiByteStr]
    cmp     eax, 61h
    jl      loc_4E7349
    cmp     eax, 7Ah
    jg      loc_4E7349
    sub     eax, 20h
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E727B:                             ; CODE XREF: sub_4E7250+Bj
    mov     ebx, dword ptr [esp+0Ch+MultiByteStr]
    cmp     ebx, 100h
    jge     short loc_4E72B3
    cmp     cchMultiByte, 1
    jle     short loc_4E729D
    push    2                               ; int
    push    ebx                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4E72A8
    ; ---------------------------------------------------------------------------

    loc_4E729D:                             ; CODE XREF: sub_4E7250+3Ej
    mov     eax, dword_50E020
    mov     al, [eax+ebx*2]
    and     eax, 2

    loc_4E72A8:                             ; CODE XREF: sub_4E7250+4Bj
    test    eax, eax
    jnz     short loc_4E72B3
    mov     eax, ebx
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E72B3:                             ; CODE XREF: sub_4E7250+35j
                                            ; sub_4E7250+5Aj
    mov     edx, dword_50E020
    mov     eax, ebx
    sar     eax, 8
    mov     ecx, eax
    and     ecx, 0FFh
    test    byte ptr [edx+ecx*2+1], 80h
    jz      short loc_4E72E1
    mov     [esp+0Ch+MultiByteStr], al
    mov     [esp+11h], bl
    mov     byte ptr [esp+12h], 0
    mov     eax, 2
    jmp     short loc_4E72EF
    ; ---------------------------------------------------------------------------

    loc_4E72E1:                             ; CODE XREF: sub_4E7250+7Bj
    mov     [esp+0Ch+MultiByteStr], bl
    mov     byte ptr [esp+11h], 0
    mov     eax, 1

    loc_4E72EF:                             ; CODE XREF: sub_4E7250+8Fj
    push    1                               ; int
    push    0                               ; CodePage
    lea     ecx, [esp+14h+DestStr]
    push    3                               ; cchDest
    push    ecx                             ; lpDestStr
    lea     edx, [esp+1Ch+MultiByteStr]
    push    eax                             ; lpWideCharStr
    mov     eax, Locale
    push    edx                             ; lpMultiByteStr
    push    200h                            ; dwMapFlags
    push    eax                             ; Locale
    call    sub_4EE520
    add     esp, 20h
    test    eax, eax
    jnz     short loc_4E731E
    mov     eax, ebx
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E731E:                             ; CODE XREF: sub_4E7250+C5j
    cmp     eax, 1
    jnz     short loc_4E7331
    mov     eax, dword ptr [esp+0Ch+DestStr]
    and     eax, 0FFh
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4E7331:                             ; CODE XREF: sub_4E7250+D1j
    mov     eax, dword ptr [esp+0Ch+DestStr+1]
    mov     ecx, dword ptr [esp+0Ch+DestStr]
    and     eax, 0FFh
    and     ecx, 0FFh
    shl     eax, 8
    or      eax, ecx

    loc_4E7349:                             ; CODE XREF: sub_4E7250+14j
                                            ; sub_4E7250+1Dj
    pop     ebx
    add     esp, 8
    retn
    sub_4E7250 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000028 BYTES: COLLAPSED FUNCTION _ftell. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000001A4 BYTES: COLLAPSED FUNCTION __ftell_lk. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000032 BYTES: COLLAPSED FUNCTION _fseek. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000097 BYTES: COLLAPSED FUNCTION __fseek_lk. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4E7610 proc near                    ; CODE XREF: sub_4B3C60+5A4p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, uNumber
    push    esi
    mov     esi, [esp+4+arg_0]
    push    edi
    cmp     esi, eax
    jnb     short loc_4E7661
    mov     eax, esi
    mov     ecx, esi
    and     eax, 1Fh
    sar     ecx, 5
    lea     edx, [eax+eax*8]
    mov     eax, dword_52B540[ecx*4]
    test    byte ptr [eax+edx*4+4], 1
    jz      short loc_4E7661
    push    esi
    call    __lock_fhandle
    mov     ecx, [esp+0Ch+arg_4]
    add     esp, 4
    push    ecx
    push    esi
    call    __chsize_lk
    add     esp, 8
    mov     edi, eax
    push    esi
    call    __unlock_fhandle
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4E7661:                             ; CODE XREF: sub_4E7610+Dj
                                            ; sub_4E7610+28j
    call    __errno
    mov     dword ptr [eax], 9
    pop     edi
    or      eax, 0FFFFFFFFh
    pop     esi
    retn
    sub_4E7610 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000014E BYTES: COLLAPSED FUNCTION __chsize_lk. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000080 BYTES: COLLAPSED FUNCTION __beginthread. PRESS KEYPAD "+" TO EXPAND]
    ; [000000A7 BYTES: COLLAPSED FUNCTION _threadstart(x). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000043 BYTES: COLLAPSED FUNCTION __endthread. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4E7950(LPCSTR lpExistingFileName,LPCSTR lpNewFileName)
    sub_4E7950 proc near                    ; CODE XREF: sub_4BBC10+Ap

    lpExistingFileName= dword ptr  4
    lpNewFileName= dword ptr  8

    mov     eax, [esp+lpNewFileName]
    mov     ecx, [esp+lpExistingFileName]
    push    eax                             ; lpNewFileName
    push    ecx                             ; lpExistingFileName
    call    ds:MoveFileA
    test    eax, eax
    jnz     short loc_4E796C
    call    ds:GetLastError
    jmp     short loc_4E796E
    ; ---------------------------------------------------------------------------

    loc_4E796C:                             ; CODE XREF: sub_4E7950+12j
    xor     eax, eax

    loc_4E796E:                             ; CODE XREF: sub_4E7950+1Aj
    test    eax, eax
    jz      short unknown_libname_64
    push    eax
    call    __dosmaperr
    add     esp, 4
    or      eax, 0FFFFFFFFh
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_64:                     ; CODE XREF: sub_4E7950+20j
    xor     eax, eax
    retn
    sub_4E7950 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000002D BYTES: COLLAPSED FUNCTION _remove. PRESS KEYPAD "+" TO EXPAND]
    align 4
    mov     eax, [esp+4]
    push    eax
    call    _remove
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [000000A4 BYTES: COLLAPSED FUNCTION __filelength. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000043 BYTES: COLLAPSED FUNCTION __getdrive. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000080 BYTES: COLLAPSED FUNCTION __chdrive. PRESS KEYPAD "+" TO EXPAND]
    ; [0000002F BYTES: COLLAPSED FUNCTION __getcwd. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000032 BYTES: COLLAPSED FUNCTION __getdcwd. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000012B BYTES: COLLAPSED FUNCTION __getdcwd_lk. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000040 BYTES: COLLAPSED FUNCTION __validdrive. PRESS KEYPAD "+" TO EXPAND]
    ; [00000099 BYTES: COLLAPSED FUNCTION __chdir. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000101 BYTES: COLLAPSED FUNCTION __findfirst. PRESS KEYPAD "+" TO EXPAND]
    align 4
    off_4E7ED4 dd offset loc_4E7E0B         ; DATA XREF: __findfirst+34r
    dd offset loc_4E7E21
    dd offset loc_4E7E0B
    dd offset loc_4E7E37
    byte_4E7EE4 db 0                        ; DATA XREF: __findfirst+2Er
    align 2
    add     eax, [ebx]
    add     eax, [ebx]
    add     [ebx], eax
    add     eax, [ebx]
    add     eax, [ebx]
    add     eax, [ebx]
    add     eax, [ebx]
    add     dl, [eax-6F6F6F70h]
    nop
    nop
    nop
    nop
    nop
    nop
    ; [000000F9 BYTES: COLLAPSED FUNCTION __findnext. PRESS KEYPAD "+" TO EXPAND]
    align 4
    off_4E7FFC dd offset loc_4E7F37         ; DATA XREF: __findnext+30r
    dd offset loc_4E7F4C
    dd offset loc_4E7F37
    dd offset loc_4E7F61
    byte_4E800C db 0                        ; DATA XREF: __findnext+2Ar
    align 2
    dd 3030303h, 3030301h, 3030303h, 90020303h
    align 4
    ; [00000021 BYTES: COLLAPSED FUNCTION __findclose. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000008C BYTES: COLLAPSED FUNCTION ___timet_from_ft. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000002F BYTES: COLLAPSED FUNCTION __mkdir. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000075 BYTES: COLLAPSED FUNCTION _rewind. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000011 BYTES: COLLAPSED FUNCTION exception::exception(void). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000001E BYTES: COLLAPSED FUNCTION exception::`scalar deleting destructor'(uint). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000005A BYTES: COLLAPSED FUNCTION exception::exception(char const * const &). PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000006D BYTES: COLLAPSED FUNCTION exception::exception(exception const &). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000020 BYTES: COLLAPSED FUNCTION exception::operator=(exception const &). PRESS KEYPAD "+" TO EXPAND]
    ; [0000001A BYTES: COLLAPSED FUNCTION exception::~exception(void). PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000000D BYTES: COLLAPSED FUNCTION exception::what(void). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000002F BYTES: COLLAPSED FUNCTION type_info::~type_info(void). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000001E BYTES: COLLAPSED FUNCTION type_info::`scalar deleting destructor'(uint). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000053 BYTES: COLLAPSED FUNCTION type_info::operator==(type_info const &). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000053 BYTES: COLLAPSED FUNCTION type_info::operator!=(type_info const &). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000053 BYTES: COLLAPSED FUNCTION type_info::before(type_info const &). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000004 BYTES: COLLAPSED FUNCTION type_info::raw_name(void). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     eax, ecx
    mov     dword ptr [eax], offset off_4FDD34
    retn    4
    ; ---------------------------------------------------------------------------
    align 8
    ; [00000005 BYTES: COLLAPSED FUNCTION type_info::operator=(type_info const &). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000047 BYTES: COLLAPSED FUNCTION _CxxThrowException(x,x). PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; void *__cdecl memcpy(void *,const void *,size_t)
    _memcpy:                                ; CODE XREF: sub_4C35C0+7Fp
                                            ; sub_4C3740+7Fp ...
    push    ebp
    mov     ebp, esp
    push    edi
    push    esi
    mov     esi, [ebp+0Ch]
    mov     ecx, [ebp+10h]
    mov     edi, [ebp+8]
    mov     eax, ecx
    mov     edx, ecx
    add     eax, esi
    cmp     edi, esi
    jbe     short loc_4E8500
    cmp     edi, eax
    jb      loc_4E8678

    loc_4E8500:                             ; CODE XREF: .text:004E84F6j
    test    edi, 3
    jnz     short loc_4E851C
    shr     ecx, 2
    and     edx, 3
    cmp     ecx, 8
    jb      short near ptr dword_4E853C
    rep movsd
    jmp     ds:off_4E8628[edx*4]
    ; ---------------------------------------------------------------------------

    loc_4E851C:                             ; CODE XREF: .text:004E8506j
    mov     eax, edi
    mov     edx, 3
    sub     ecx, 4
    jb      short loc_4E8534
    and     eax, 3
    add     ecx, eax
    jmp     ds:dword_4E8540[eax*4]
    ; ---------------------------------------------------------------------------

    loc_4E8534:                             ; CODE XREF: .text:004E8526j
    jmp     ds:dword_4E8638[ecx*4]
    ; ---------------------------------------------------------------------------
    align 4
    dword_4E853C dd 0BC8D24FFh              ; CODE XREF: .text:004E8511j
    dword_4E8540 dd 90004E85h               ; DATA XREF: .text:004E852Dr
    dd offset dword_4E8550
    dd offset dword_4E857C
    dd offset dword_4E85A0
    dword_4E8550 dd 68AD123h, 468A0788h, 1478801h, 0C102468Ah, 478802E9h, 3C68302h, 8303C783h
                                            ; DATA XREF: .text:004E8544o
    dd 0CC7208F9h, 24FFA5F3h, 4E862895h, 0C08B2E00h
    dword_4E857C dd 68AD123h, 468A0788h, 2E9C101h, 83014788h, 0C78302C6h, 8F98302h, 0A5F3A672h
                                            ; DATA XREF: .text:004E8548o
    dd 289524FFh, 90004E86h
    dword_4E85A0 dd 68AD123h, 0C1460788h, 834702E9h, 8C7208F9h, 24FFA5F3h, 4E862895h, 0C08B2E00h
                                            ; DATA XREF: .text:004E854Co
    dd 4E861Fh, 4E860Ch, 4E8604h, 4E85FCh, 4E85F4h, 4E85ECh, 4E85E4h, 4E85DCh
    dd 0E48E448Bh, 0E48F4489h, 0E88E448Bh, 0E88F4489h, 0EC8E448Bh, 0EC8F4489h
    dd 0F08E448Bh, 0F08F4489h, 0F48E448Bh, 0F48F4489h, 0F88E448Bh, 0F88F4489h
    dd 0FC8E448Bh, 0FC8F4489h, 8D048Dh, 3000000h, 0FFF803F0h, 86289524h, 0C08B004Eh
    off_4E8628 dd offset dword_4E8638       ; DATA XREF: .text:004E8515r
    dd offset loc_4E8640
    dd offset loc_4E864C
    dd offset loc_4E8660
    dword_4E8638 dd 5E08458Bh               ; CODE XREF: .text:004E8515j
                                            ; DATA XREF: .text:004E8534r ...
    ; ---------------------------------------------------------------------------
    pop     edi
    leave
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_4E8640:                             ; CODE XREF: .text:004E8515j
                                            ; DATA XREF: .text:004E862Co
    mov     al, [esi]
    mov     [edi], al
    mov     eax, [ebp+8]
    pop     esi
    pop     edi
    leave
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_4E864C:                             ; CODE XREF: .text:004E8515j
                                            ; DATA XREF: .text:004E8630o
    mov     al, [esi]
    mov     [edi], al
    mov     al, [esi+1]
    mov     [edi+1], al
    mov     eax, [ebp+8]
    pop     esi
    pop     edi
    leave
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_4E8660:                             ; CODE XREF: .text:004E8515j
                                            ; DATA XREF: .text:004E8634o
    mov     al, [esi]
    mov     [edi], al
    mov     al, [esi+1]
    mov     [edi+1], al
    mov     al, [esi+2]
    mov     [edi+2], al
    mov     eax, [ebp+8]
    pop     esi
    pop     edi
    leave
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_4E8678:                             ; CODE XREF: .text:004E84FAj
    lea     esi, [ecx+esi-4]
    lea     edi, [ecx+edi-4]
    test    edi, 3
    jnz     short loc_4E86AC
    shr     ecx, 2
    and     edx, 3
    cmp     ecx, 8
    jb      short loc_4E86A0
    std
    rep movsd
    cld
    jmp     ds:off_4E87C0[edx*4]
    ; ---------------------------------------------------------------------------
    align 4

    loc_4E86A0:                             ; CODE XREF: .text:004E8691j
                                            ; .text:004E86E8j ...
    neg     ecx
    jmp     ds:off_4E8770[ecx*4]
    ; ---------------------------------------------------------------------------
    align 4

    loc_4E86AC:                             ; CODE XREF: .text:004E8686j
    mov     eax, edi
    mov     edx, 3
    cmp     ecx, 4
    jb      short near ptr dword_4E86C4
    and     eax, 3
    sub     ecx, eax
    jmp     ds:dword_4E86C8[eax*4]
    ; ---------------------------------------------------------------------------
    dword_4E86C4 dd 0C08D24FFh              ; CODE XREF: .text:004E86B6j
    dword_4E86C8 dd 90004E87h               ; DATA XREF: .text:004E86BDr
    ; ---------------------------------------------------------------------------
    fadd    dword ptr [esi-7907FFB2h]
    dec     esi
    add     [eax], ah
    xchg    ecx, [esi+0]
    mov     al, [esi+3]
    and     edx, ecx
    mov     [edi+3], al
    dec     esi
    shr     ecx, 2
    dec     edi
    cmp     ecx, 8
    jb      short loc_4E86A0
    std
    rep movsd
    cld
    jmp     ds:off_4E87C0[edx*4]
    ; ---------------------------------------------------------------------------
    align 4
    mov     al, [esi+3]
    and     edx, ecx
    mov     [edi+3], al
    mov     al, [esi+2]
    shr     ecx, 2
    mov     [edi+2], al
    sub     esi, 2
    sub     edi, 2
    cmp     ecx, 8
    jb      short loc_4E86A0
    std
    rep movsd
    cld
    jmp     ds:off_4E87C0[edx*4]
    ; ---------------------------------------------------------------------------
    align 4
    mov     al, [esi+3]
    and     edx, ecx
    mov     [edi+3], al
    mov     al, [esi+2]
    mov     [edi+2], al
    mov     al, [esi+1]
    shr     ecx, 2
    mov     [edi+1], al
    sub     esi, 3
    sub     edi, 3
    cmp     ecx, 8
    jb      loc_4E86A0
    std
    rep movsd
    cld
    jmp     ds:off_4E87C0[edx*4]
    ; ---------------------------------------------------------------------------
    align 4
    dd offset loc_4E8774
    dd offset loc_4E877C
    dd offset loc_4E8784
    dd offset loc_4E878C
    dd offset loc_4E8794
    dd offset loc_4E879C
    dd offset loc_4E87A4
    off_4E8770 dd offset loc_4E87B7         ; DATA XREF: .text:004E86A2r
    ; ---------------------------------------------------------------------------

    loc_4E8774:                             ; DATA XREF: .text:004E8754o
    mov     eax, [esi+ecx*4+1Ch]
    mov     [edi+ecx*4+1Ch], eax

    loc_4E877C:                             ; DATA XREF: .text:004E8758o
    mov     eax, [esi+ecx*4+18h]
    mov     [edi+ecx*4+18h], eax

    loc_4E8784:                             ; DATA XREF: .text:004E875Co
    mov     eax, [esi+ecx*4+14h]
    mov     [edi+ecx*4+14h], eax

    loc_4E878C:                             ; DATA XREF: .text:004E8760o
    mov     eax, [esi+ecx*4+10h]
    mov     [edi+ecx*4+10h], eax

    loc_4E8794:                             ; DATA XREF: .text:004E8764o
    mov     eax, [esi+ecx*4+0Ch]
    mov     [edi+ecx*4+0Ch], eax

    loc_4E879C:                             ; DATA XREF: .text:004E8768o
    mov     eax, [esi+ecx*4+8]
    mov     [edi+ecx*4+8], eax

    loc_4E87A4:                             ; DATA XREF: .text:004E876Co
    mov     eax, [esi+ecx*4+4]
    mov     [edi+ecx*4+4], eax
    lea     eax, ds:0[ecx*4]
    add     esi, eax
    add     edi, eax

    loc_4E87B7:                             ; CODE XREF: .text:004E86A2j
                                            ; DATA XREF: .text:004E8770o
    jmp     ds:off_4E87C0[edx*4]
    ; ---------------------------------------------------------------------------
    align 4
    off_4E87C0 dd offset loc_4E87D0         ; DATA XREF: .text:004E8697r
                                            ; .text:004E86EEr ...
    dd offset loc_4E87D8
    dd offset loc_4E87E8
    dd offset loc_4E87FC
    ; ---------------------------------------------------------------------------

    loc_4E87D0:                             ; CODE XREF: .text:004E8697j
                                            ; .text:004E86EEj ...
    mov     eax, [ebp+8]
    pop     esi
    pop     edi
    leave
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_4E87D8:                             ; CODE XREF: .text:004E8697j
                                            ; DATA XREF: .text:004E87C4o
    mov     al, [esi+3]
    mov     [edi+3], al
    mov     eax, [ebp+8]
    pop     esi
    pop     edi
    leave
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_4E87E8:                             ; CODE XREF: .text:004E8697j
                                            ; DATA XREF: .text:004E87C8o
    mov     al, [esi+3]
    mov     [edi+3], al
    mov     al, [esi+2]
    mov     [edi+2], al
    mov     eax, [ebp+8]
    pop     esi
    pop     edi
    leave
    retn
    ; ---------------------------------------------------------------------------
    align 4

    loc_4E87FC:                             ; CODE XREF: .text:004E8697j
                                            ; DATA XREF: .text:004E87CCo
    mov     al, [esi+3]
    mov     [edi+3], al
    mov     al, [esi+2]
    mov     [edi+2], al
    mov     al, [esi+1]
    mov     [edi+1], al
    mov     eax, [ebp+8]
    pop     esi
    pop     edi
    leave
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000068 BYTES: COLLAPSED FUNCTION _free. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000014 BYTES: COLLAPSED FUNCTION _malloc. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000044 BYTES: COLLAPSED FUNCTION __nh_malloc. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000055 BYTES: COLLAPSED FUNCTION __heap_alloc. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4E8960(LPCSTR lpMultiByteStr)
    sub_4E8960 proc near                    ; CODE XREF: sub_434BF0+1F9p
                                            ; sub_435A20+9Bp ...

    var_4= dword ptr -4
    lpMultiByteStr= dword ptr  4

    push    ecx
    mov     eax, Locale
    push    ebx
    push    ebp
    xor     ebp, ebp
    push    esi
    push    edi
    test    eax, eax
    jnz     short loc_4E899E
    mov     eax, [esp+14h+lpMultiByteStr]
    mov     edx, eax
    cmp     byte ptr [eax], 0
    jz      loc_4E8AD9

    loc_4E897F:                             ; CODE XREF: sub_4E8960+36j
    mov     cl, [edx]
    cmp     cl, 41h
    jl      short loc_4E8990
    cmp     cl, 5Ah
    jg      short loc_4E8990
    add     cl, 20h
    mov     [edx], cl

    loc_4E8990:                             ; CODE XREF: sub_4E8960+24j
                                            ; sub_4E8960+29j
    mov     cl, [edx+1]
    inc     edx
    test    cl, cl
    jnz     short loc_4E897F
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E899E:                             ; CODE XREF: sub_4E8960+Ej
    push    offset Addend                   ; lpAddend
    call    ds:InterlockedIncrement
    mov     eax, dword_52B648
    test    eax, eax
    jz      short loc_4E89D1
    push    offset Addend                   ; lpAddend
    call    ds:InterlockedDecrement
    push    13h
    call    __lock
    add     esp, 4
    mov     [esp+14h+var_4], 1
    jmp     short loc_4E89D9
    ; ---------------------------------------------------------------------------

    loc_4E89D1:                             ; CODE XREF: sub_4E8960+50j
    mov     [esp+14h+var_4], 0

    loc_4E89D9:                             ; CODE XREF: sub_4E8960+6Fj
    mov     eax, Locale
    test    eax, eax
    jnz     short loc_4E8A2F
    mov     eax, [esp+14h+var_4]
    test    eax, eax
    jz      short loc_4E89F6
    push    13h
    call    __unlock
    add     esp, 4
    jmp     short loc_4E8A01
    ; ---------------------------------------------------------------------------

    loc_4E89F6:                             ; CODE XREF: sub_4E8960+88j
    push    offset Addend                   ; lpAddend
    call    ds:InterlockedDecrement

    loc_4E8A01:                             ; CODE XREF: sub_4E8960+94j
    mov     eax, [esp+14h+lpMultiByteStr]
    mov     edx, eax
    cmp     byte ptr [eax], 0
    jz      loc_4E8AD9

    loc_4E8A10:                             ; CODE XREF: sub_4E8960+C7j
    mov     cl, [edx]
    cmp     cl, 41h
    jl      short loc_4E8A21
    cmp     cl, 5Ah
    jg      short loc_4E8A21
    add     cl, 20h
    mov     [edx], cl

    loc_4E8A21:                             ; CODE XREF: sub_4E8960+B5j
                                            ; sub_4E8960+BAj
    mov     cl, [edx+1]
    inc     edx
    test    cl, cl
    jnz     short loc_4E8A10
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E8A2F:                             ; CODE XREF: sub_4E8960+80j
    mov     ebx, [esp+14h+lpMultiByteStr]
    push    1                               ; int
    push    0                               ; CodePage
    push    0                               ; cchDest
    push    0                               ; lpDestStr
    push    0FFFFFFFFh                      ; lpWideCharStr
    push    ebx                             ; lpMultiByteStr
    push    100h                            ; dwMapFlags
    push    eax                             ; Locale
    call    sub_4EE520
    mov     esi, eax
    add     esp, 20h
    test    esi, esi
    jz      short loc_4E8AA0
    push    esi                             ; size_t
    call    _malloc
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jz      short loc_4E8AA0
    mov     eax, Locale
    push    1                               ; int
    push    0                               ; CodePage
    push    esi                             ; cchDest
    push    ebp                             ; lpDestStr
    push    0FFFFFFFFh                      ; lpWideCharStr
    push    ebx                             ; lpMultiByteStr
    push    100h                            ; dwMapFlags
    push    eax                             ; Locale
    call    sub_4EE520
    add     esp, 20h
    test    eax, eax
    jz      short loc_4E8AA0
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4E8AA0:                             ; CODE XREF: sub_4E8960+F0j
                                            ; sub_4E8960+FFj ...
    mov     eax, [esp+14h+var_4]
    test    eax, eax
    jz      short loc_4E8AC3
    push    13h
    call    __unlock
    add     esp, 4
    push    ebp                             ; void *
    call    _free
    add     esp, 4
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E8AC3:                             ; CODE XREF: sub_4E8960+146j
    push    offset Addend                   ; lpAddend
    call    ds:InterlockedDecrement
    push    ebp                             ; void *
    call    _free
    add     esp, 4
    mov     eax, ebx

    loc_4E8AD9:                             ; CODE XREF: sub_4E8960+19j
                                            ; sub_4E8960+AAj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_4E8960 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4E8AE0(LPCSTR lpMultiByteStr)
    sub_4E8AE0 proc near                    ; CODE XREF: .text:004C9383p

    var_4= dword ptr -4
    lpMultiByteStr= dword ptr  4

    push    ecx
    mov     eax, Locale
    push    ebx
    push    ebp
    xor     ebp, ebp
    push    esi
    push    edi
    test    eax, eax
    jnz     short loc_4E8B1E
    mov     eax, [esp+14h+lpMultiByteStr]
    mov     edx, eax
    cmp     byte ptr [eax], 0
    jz      loc_4E8C59

    loc_4E8AFF:                             ; CODE XREF: sub_4E8AE0+36j
    mov     cl, [edx]
    cmp     cl, 61h
    jl      short loc_4E8B10
    cmp     cl, 7Ah
    jg      short loc_4E8B10
    sub     cl, 20h
    mov     [edx], cl

    loc_4E8B10:                             ; CODE XREF: sub_4E8AE0+24j
                                            ; sub_4E8AE0+29j
    mov     cl, [edx+1]
    inc     edx
    test    cl, cl
    jnz     short loc_4E8AFF
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E8B1E:                             ; CODE XREF: sub_4E8AE0+Ej
    push    offset Addend                   ; lpAddend
    call    ds:InterlockedIncrement
    mov     eax, dword_52B648
    test    eax, eax
    jz      short loc_4E8B51
    push    offset Addend                   ; lpAddend
    call    ds:InterlockedDecrement
    push    13h
    call    __lock
    add     esp, 4
    mov     [esp+14h+var_4], 1
    jmp     short loc_4E8B59
    ; ---------------------------------------------------------------------------

    loc_4E8B51:                             ; CODE XREF: sub_4E8AE0+50j
    mov     [esp+14h+var_4], 0

    loc_4E8B59:                             ; CODE XREF: sub_4E8AE0+6Fj
    mov     eax, Locale
    test    eax, eax
    jnz     short loc_4E8BAF
    mov     eax, [esp+14h+var_4]
    test    eax, eax
    jz      short loc_4E8B76
    push    13h
    call    __unlock
    add     esp, 4
    jmp     short loc_4E8B81
    ; ---------------------------------------------------------------------------

    loc_4E8B76:                             ; CODE XREF: sub_4E8AE0+88j
    push    offset Addend                   ; lpAddend
    call    ds:InterlockedDecrement

    loc_4E8B81:                             ; CODE XREF: sub_4E8AE0+94j
    mov     eax, [esp+14h+lpMultiByteStr]
    mov     edx, eax
    cmp     byte ptr [eax], 0
    jz      loc_4E8C59

    loc_4E8B90:                             ; CODE XREF: sub_4E8AE0+C7j
    mov     cl, [edx]
    cmp     cl, 61h
    jl      short loc_4E8BA1
    cmp     cl, 7Ah
    jg      short loc_4E8BA1
    sub     cl, 20h
    mov     [edx], cl

    loc_4E8BA1:                             ; CODE XREF: sub_4E8AE0+B5j
                                            ; sub_4E8AE0+BAj
    mov     cl, [edx+1]
    inc     edx
    test    cl, cl
    jnz     short loc_4E8B90
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E8BAF:                             ; CODE XREF: sub_4E8AE0+80j
    mov     ebx, [esp+14h+lpMultiByteStr]
    push    1                               ; int
    push    0                               ; CodePage
    push    0                               ; cchDest
    push    0                               ; lpDestStr
    push    0FFFFFFFFh                      ; lpWideCharStr
    push    ebx                             ; lpMultiByteStr
    push    200h                            ; dwMapFlags
    push    eax                             ; Locale
    call    sub_4EE520
    mov     esi, eax
    add     esp, 20h
    test    esi, esi
    jz      short loc_4E8C20
    push    esi                             ; size_t
    call    _malloc
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jz      short loc_4E8C20
    mov     eax, Locale
    push    1                               ; int
    push    0                               ; CodePage
    push    esi                             ; cchDest
    push    ebp                             ; lpDestStr
    push    0FFFFFFFFh                      ; lpWideCharStr
    push    ebx                             ; lpMultiByteStr
    push    200h                            ; dwMapFlags
    push    eax                             ; Locale
    call    sub_4EE520
    add     esp, 20h
    test    eax, eax
    jz      short loc_4E8C20
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     edx, ecx
    mov     esi, edi
    mov     edi, ebx
    shr     ecx, 2
    rep movsd
    mov     ecx, edx
    and     ecx, 3
    rep movsb

    loc_4E8C20:                             ; CODE XREF: sub_4E8AE0+F0j
                                            ; sub_4E8AE0+FFj ...
    mov     eax, [esp+14h+var_4]
    test    eax, eax
    jz      short loc_4E8C43
    push    13h
    call    __unlock
    add     esp, 4
    push    ebp                             ; void *
    call    _free
    add     esp, 4
    mov     eax, ebx
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E8C43:                             ; CODE XREF: sub_4E8AE0+146j
    push    offset Addend                   ; lpAddend
    call    ds:InterlockedDecrement
    push    ebp                             ; void *
    call    _free
    add     esp, 4
    mov     eax, ebx

    loc_4E8C59:                             ; CODE XREF: sub_4E8AE0+19j
                                            ; sub_4E8AE0+AAj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    sub_4E8AE0 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000018 BYTES: COLLAPSED FUNCTION __statusfp. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000019 BYTES: COLLAPSED FUNCTION __clearfp. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000003B BYTES: COLLAPSED FUNCTION __control87. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000018 BYTES: COLLAPSED FUNCTION __controlfp. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    __fpreset:
    push    esi
    call    ___pxcptinfoptrs
    mov     esi, [eax]
    fninit
    call    __setdefaultprecision
    test    esi, esi
    jz      short loc_4E8D2C
    mov     eax, [esi+4]
    test    dword ptr [eax], 10008h
    jz      short loc_4E8D2C
    mov     dword ptr [eax+20h], 0
    mov     dword ptr [eax+24h], 0FFFFh

    loc_4E8D2C:                             ; CODE XREF: .text:004E8D11j
                                            ; .text:004E8D1Cj
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [00000096 BYTES: COLLAPSED FUNCTION __abstract_cw. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000008B BYTES: COLLAPSED FUNCTION __hw_cw. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000037 BYTES: COLLAPSED FUNCTION __abstract_sw. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: library function

    ; void *__cdecl calloc(size_t,size_t)
    _calloc proc near                       ; CODE XREF: .text:004D0A77p
                                            ; .text:004D0A97p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_4]
    imul    ebx, [esp+arg_0]
    push    ebp
    push    esi
    cmp     ebx, 0FFFFFFE0h
    push    edi
    ja      short loc_4E8EC3
    test    ebx, ebx
    jbe     short loc_4E8EBE
    add     ebx, 0Fh
    and     ebx, 0FFFFFFF0h
    jmp     short loc_4E8EC3
    ; ---------------------------------------------------------------------------

    loc_4E8EBE:                             ; CODE XREF: _calloc+14j
    mov     ebx, 10h

    loc_4E8EC3:                             ; CODE XREF: _calloc+10j _calloc+1Cj
    mov     ebp, ds:HeapAlloc

    loc_4E8EC9:                             ; CODE XREF: _calloc+9Dj
    xor     esi, esi
    cmp     ebx, 0FFFFFFE0h
    ja      short loc_4E8F25
    cmp     ebx, dword_5109EC
    ja      short loc_4E8F14
    push    9
    call    __lock
    mov     eax, ebx
    add     esp, 4
    shr     eax, 4
    push    eax
    call    ___sbh_alloc_block
    add     esp, 4
    mov     esi, eax
    push    9
    call    __unlock
    add     esp, 4
    test    esi, esi
    jz      short loc_4E8F18
    mov     ecx, ebx
    xor     eax, eax
    mov     edx, ecx
    mov     edi, esi
    shr     ecx, 2
    rep stosd
    mov     ecx, edx
    and     ecx, 3
    rep stosb

    loc_4E8F14:                             ; CODE XREF: _calloc+36j
    test    esi, esi
    jnz     short loc_4E8F44

    loc_4E8F18:                             ; CODE XREF: _calloc+5Ej
    mov     eax, hHeap
    push    ebx                             ; dwBytes
    push    8                               ; dwFlags
    push    eax                             ; hHeap
    call    ebp ; HeapAlloc
    mov     esi, eax

    loc_4E8F25:                             ; CODE XREF: _calloc+2Ej
    test    esi, esi
    jnz     short loc_4E8F44
    mov     eax, dword_52A430
    test    eax, eax
    jz      short loc_4E8F44
    push    ebx
    call    __callnewh
    add     esp, 4
    test    eax, eax
    jnz     short loc_4E8EC9
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4E8F44:                             ; CODE XREF: _calloc+76j _calloc+87j ...
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    _calloc endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [0000005B BYTES: COLLAPSED FUNCTION _printf. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000063 BYTES: COLLAPSED FUNCTION __msize. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000001B0 BYTES: COLLAPSED FUNCTION _realloc. PRESS KEYPAD "+" TO EXPAND]
    ; [00000028 BYTES: COLLAPSED FUNCTION _getenv. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000008E BYTES: COLLAPSED FUNCTION __getenv_lk. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [000000C2 BYTES: COLLAPSED FUNCTION ___dtoxmode. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000033F BYTES: COLLAPSED FUNCTION __stat. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000007F BYTES: COLLAPSED FUNCTION _IsRootUNCName. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000168 BYTES: COLLAPSED FUNCTION _gmtime. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000ED BYTES: COLLAPSED FUNCTION _asctime. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000034 BYTES: COLLAPSED FUNCTION _store_dt. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000130 BYTES: COLLAPSED FUNCTION __flsbuf. PRESS KEYPAD "+" TO EXPAND]
    ; [0000087C BYTES: COLLAPSED FUNCTION __output. PRESS KEYPAD "+" TO EXPAND]
    off_4EA36C dd offset $NORMAL_STATE$8072 ; DATA XREF: __output+7Dr
    dd offset loc_4E9B74
    dd offset loc_4E9B99
    dd offset loc_4E9C02
    dd offset loc_4E9C4C
    dd offset loc_4E9C55
    dd offset loc_4E9C9A
    dd offset loc_4E9D6A
    off_4EA38C dd offset loc_4E9BD5         ; DATA XREF: __output+C0r
    dd offset loc_4E9BE4
    dd offset loc_4E9BC6
    dd offset loc_4E9BB7
    dd offset loc_4E9BF3
    dd offset loc_4EA32A
    byte_4EA3A4 db 0                        ; DATA XREF: __output+BAr
    dd 5010505h, 5050505h, 5020505h, 4050503h
    align 4
    off_4EA3B8 dd offset loc_4E9CC7         ; DATA XREF: __output+1C1r
    dd offset loc_4E9D4B
    dd offset loc_4E9CB8
    dd offset loc_4E9D5A
    dd offset loc_4EA32A
    byte_4EA3CC db 0                        ; DATA XREF: __output+1BBr
    dd 7 dup(4040404h), 4010404h, 4020404h, 2 dup(4040404h)
    db 4, 3, 90h
    off_4EA3FC dd offset loc_4E9D88         ; DATA XREF: __output+291r
    dd offset loc_4E9F57
    dd offset loc_4E9F57
    dd offset loc_4E9E6C
    dd offset loc_4EA060
    dd offset loc_4E9E03
    dd offset loc_4E9D9A
    dd offset loc_4EA03A
    dd offset loc_4E9F62
    dd offset loc_4EA03A
    dd offset loc_4E9F16
    dd offset loc_4EA09C
    dd offset loc_4EA058
    dd offset loc_4E9E7E
    dd offset loc_4EA04E
    dd offset loc_4EA06A
    dd offset loc_4EA210
    byte_4EA440 db 0                        ; DATA XREF: __output+28Br
    ; ---------------------------------------------------------------------------
    adc     [ecx], al
    adc     [edx], al
    adc     [eax], dl
    adc     [eax], dl
    adc     [eax], dl
    adc     [eax], dl
    adc     [eax], dl
    adc     [ebx], al
    adc     [eax], dl
    adc     [eax], dl
    add     al, 10h
    add     eax, 10101010h
    adc     [eax], dl
    adc     [eax], dl
    push    es
    pop     es
    or      [eax], cl
    or      [eax], dl
    or      [eax], edx
    adc     [eax], dl
    adc     [edx], cl
    or      ecx, [eax+edx]
    adc     ds:10100E10h, cl
    seto    byte ptr [eax-6F6F6F70h]
    nop
    nop
    nop
    nop
    ; [00000042 BYTES: COLLAPSED FUNCTION _write_char. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000039 BYTES: COLLAPSED FUNCTION _write_multi_char. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000003D BYTES: COLLAPSED FUNCTION _write_string. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000011 BYTES: COLLAPSED FUNCTION _get_int_arg. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000012 BYTES: COLLAPSED FUNCTION _get_int64_arg. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000012 BYTES: COLLAPSED FUNCTION _get_short_arg. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000013 BYTES: COLLAPSED FUNCTION __setdefaultprecision. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000050 BYTES: COLLAPSED FUNCTION __ms_p5_test_fdiv. PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: library function

    __ms_p5_mp_test_fdiv proc near          ; CODE XREF: __fpmath+5p
    push    offset aKernel32                ; lpModuleName
    call    ds:GetModuleHandleA
    test    eax, eax
    jz      short loc_4EA644
    push    offset aIsprocessorfea          ; lpProcName
    push    eax                             ; hModule
    call    ds:GetProcAddress
    test    eax, eax
    jz      short loc_4EA644
    push    0
    call    eax
    retn
    ; ---------------------------------------------------------------------------

    loc_4EA644:                             ; CODE XREF: __ms_p5_mp_test_fdiv+Dj
                                            ; __ms_p5_mp_test_fdiv+1Dj
    jmp     __ms_p5_test_fdiv
    __ms_p5_mp_test_fdiv endp

    ; ---------------------------------------------------------------------------
    align 8

    __forcdecpt:                            ; DATA XREF: __cfltcvt_init+1Eo
    push    esi
    mov     esi, [esp+8]
    movsx   eax, byte ptr [esi]
    push    eax
    call    _tolower
    add     esp, 4
    cmp     eax, 65h
    jz      short loc_4EA693

    loc_4EA666:                             ; CODE XREF: .text:004EA691j
    mov     eax, cchMultiByte
    inc     esi
    cmp     eax, 1
    jle     short loc_4EA681
    movsx   ecx, byte ptr [esi]
    push    4
    push    ecx
    call    __isctype
    add     esp, 8
    jmp     short loc_4EA68F
    ; ---------------------------------------------------------------------------

    loc_4EA681:                             ; CODE XREF: .text:004EA66Fj
    movsx   edx, byte ptr [esi]
    mov     eax, dword_50E020
    mov     al, [eax+edx*2]
    and     eax, 4

    loc_4EA68F:                             ; CODE XREF: .text:004EA67Fj
    test    eax, eax
    jnz     short loc_4EA666

    loc_4EA693:                             ; CODE XREF: .text:004EA664j
    mov     cl, byte_50E230
    mov     al, [esi]
    mov     [esi], cl
    inc     esi

    loc_4EA69E:                             ; CODE XREF: .text:004EA6A9j
    mov     cl, [esi]
    mov     [esi], al
    mov     dl, [esi]
    inc     esi
    test    dl, dl
    mov     al, cl
    jnz     short loc_4EA69E
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    __cropzeros:                            ; DATA XREF: __cfltcvt_init+5o
    mov     eax, [esp+4]
    push    ebx
    mov     bl, byte_50E230
    mov     cl, [eax]
    test    cl, cl
    jz      short loc_4EA6CD

    loc_4EA6C1:                             ; CODE XREF: .text:004EA6CBj
    cmp     cl, bl
    jz      short loc_4EA6CD
    mov     cl, [eax+1]
    inc     eax
    test    cl, cl
    jnz     short loc_4EA6C1

    loc_4EA6CD:                             ; CODE XREF: .text:004EA6BFj
                                            ; .text:004EA6C3j
    mov     cl, [eax]
    inc     eax
    test    cl, cl
    jz      short loc_4EA719
    mov     cl, [eax]
    test    cl, cl
    jz      short loc_4EA6EC

    loc_4EA6DA:                             ; CODE XREF: .text:004EA6EAj
    cmp     cl, 65h
    jz      short loc_4EA6EC
    cmp     cl, 45h
    jz      short loc_4EA6EC
    mov     cl, [eax+1]
    inc     eax
    test    cl, cl
    jnz     short loc_4EA6DA

    loc_4EA6EC:                             ; CODE XREF: .text:004EA6D8j
                                            ; .text:004EA6DDj ...
    mov     cl, [eax-1]
    mov     edx, eax
    dec     eax
    cmp     cl, 30h
    jnz     short loc_4EA700

    loc_4EA6F7:                             ; CODE XREF: .text:004EA6FEj
    mov     cl, [eax-1]
    dec     eax
    cmp     cl, 30h
    jz      short loc_4EA6F7

    loc_4EA700:                             ; CODE XREF: .text:004EA6F5j
    cmp     [eax], bl
    jnz     short loc_4EA705
    dec     eax

    loc_4EA705:                             ; CODE XREF: .text:004EA702j
    mov     cl, [edx]
    inc     eax
    inc     edx
    test    cl, cl
    mov     [eax], cl
    jz      short loc_4EA719

    loc_4EA70F:                             ; CODE XREF: .text:004EA717j
    mov     cl, [edx]
    inc     eax
    inc     edx
    test    cl, cl
    mov     [eax], cl
    jnz     short loc_4EA70F

    loc_4EA719:                             ; CODE XREF: .text:004EA6D2j
                                            ; .text:004EA70Dj
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 8

    __positive:                             ; DATA XREF: __cfltcvt_init+28o
    mov     eax, [esp+4]
    fld     qword ptr [eax]
    fcomp   ds:dbl_4FDE40
    fnstsw  ax
    test    ah, 1
    jnz     short loc_4EA739
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_4EA739:                             ; CODE XREF: .text:004EA731j
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    align 8

    __fassign:                              ; DATA XREF: __cfltcvt_init+14o
    mov     eax, [esp+4]
    sub     esp, 8
    test    eax, eax
    jz      short loc_4EA772
    mov     eax, [esp+14h]
    lea     ecx, [esp+0]
    push    eax
    push    ecx
    call    sub_4F3A50
    mov     eax, [esp+18h]
    mov     edx, [esp+8]
    mov     ecx, [esp+0Ch]
    add     esp, 8
    mov     [eax], edx
    mov     [eax+4], ecx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4EA772:                             ; CODE XREF: .text:004EA749j
    mov     edx, [esp+14h]
    lea     eax, [esp+14h]
    push    edx
    push    eax
    call    sub_4F3AD0
    mov     ecx, [esp+18h]
    mov     edx, [esp+1Ch]
    add     esp, 8
    mov     [ecx], edx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000073 BYTES: COLLAPSED FUNCTION __cftoe. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000F2 BYTES: COLLAPSED FUNCTION __cftoe2. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000066 BYTES: COLLAPSED FUNCTION __cftof. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000B6 BYTES: COLLAPSED FUNCTION __cftof2. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000B6 BYTES: COLLAPSED FUNCTION __cftog. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    __cfltcvt:                              ; DATA XREF: __cfltcvt_inito
    mov     eax, [esp+0Ch]
    cmp     eax, 65h
    jz      short loc_4EAB58
    cmp     eax, 45h
    jz      short loc_4EAB58
    cmp     eax, 66h
    jnz     short loc_4EAB3B
    mov     eax, [esp+10h]
    mov     ecx, [esp+8]
    mov     edx, [esp+4]
    push    eax
    push    ecx
    push    edx
    call    __cftof
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4EAB3B:                             ; CODE XREF: .text:004EAB21j
    mov     eax, [esp+14h]
    mov     ecx, [esp+10h]
    mov     edx, [esp+8]
    push    eax
    mov     eax, [esp+8]
    push    ecx
    push    edx
    push    eax
    call    __cftog
    add     esp, 10h
    retn
    ; ---------------------------------------------------------------------------

    loc_4EAB58:                             ; CODE XREF: .text:004EAB17j
                                            ; .text:004EAB1Cj
    mov     ecx, [esp+14h]
    mov     edx, [esp+10h]
    mov     eax, [esp+8]
    push    ecx
    mov     ecx, [esp+8]
    push    edx
    push    eax
    push    ecx
    call    __cftoe
    add     esp, 10h
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000029 BYTES: COLLAPSED FUNCTION __shift. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000002B BYTES: COLLAPSED FUNCTION __mtinitlocks. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000072 BYTES: COLLAPSED FUNCTION __mtdeletelocks. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000076 BYTES: COLLAPSED FUNCTION __lock. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000016 BYTES: COLLAPSED FUNCTION __unlock. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000036 BYTES: COLLAPSED FUNCTION __lock_file. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000028 BYTES: COLLAPSED FUNCTION __lock_file2. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000036 BYTES: COLLAPSED FUNCTION __unlock_file. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000028 BYTES: COLLAPSED FUNCTION __unlock_file2. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    __lockerr_exit:
    mov     eax, [esp+4]
    push    eax
    push    0
    call    ds:FatalAppExitA
    push    0FFh
    call    ds:ExitProcess
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4EAE00 proc near                    ; CODE XREF: sub_4E4510+11p
                                            ; _printf+16p

    arg_0= dword ptr  8

    push    esi
    mov     esi, [esp+arg_0]
    push    edi
    mov     eax, [esi+10h]
    push    eax
    call    __isatty
    add     esp, 4
    test    eax, eax
    jz      loc_4EAEB3
    cmp     esi, offset dword_510A10
    jnz     short loc_4EAE26
    xor     edi, edi
    jmp     short loc_4EAE37
    ; ---------------------------------------------------------------------------

    loc_4EAE26:                             ; CODE XREF: sub_4EAE00+20j
    cmp     esi, offset dword_510A30
    jnz     loc_4EAEB3
    mov     edi, 1

    loc_4EAE37:                             ; CODE XREF: sub_4EAE00+24j
    mov     ecx, dword_52A438
    inc     ecx
    mov     dword_52A438, ecx
    mov     eax, [esi+0Ch]
    test    eax, 10Ch
    jnz     short loc_4EAEB3
    mov     eax, dword_529FF8[edi*4]
    test    eax, eax
    jnz     short loc_4EAE86
    push    1000h                           ; size_t
    call    _malloc
    add     esp, 4
    mov     dword_529FF8[edi*4], eax
    test    eax, eax
    jnz     short loc_4EAE86
    lea     eax, [esi+14h]
    mov     [esi+8], eax
    mov     [esi], eax
    mov     eax, 2
    mov     [esi+18h], eax
    mov     [esi+4], eax
    jmp     short loc_4EAEA0
    ; ---------------------------------------------------------------------------

    loc_4EAE86:                             ; CODE XREF: sub_4EAE00+57j
                                            ; sub_4EAE00+6Fj
    mov     edi, dword_529FF8[edi*4]
    mov     dword ptr [esi+18h], 1000h
    mov     [esi+8], edi
    mov     [esi], edi
    mov     dword ptr [esi+4], 1000h

    loc_4EAEA0:                             ; CODE XREF: sub_4EAE00+84j
    mov     eax, [esi+0Ch]
    or      eax, 1102h
    mov     [esi+0Ch], eax
    mov     eax, 1
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4EAEB3:                             ; CODE XREF: sub_4EAE00+14j
                                            ; sub_4EAE00+2Cj ...
    pop     edi
    xor     eax, eax
    pop     esi
    retn
    sub_4EAE00 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000003D BYTES: COLLAPSED FUNCTION __ftbuf. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000096 BYTES: COLLAPSED FUNCTION __fltin2. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000095 BYTES: COLLAPSED FUNCTION __isctype. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000005C BYTES: COLLAPSED FUNCTION __mtinit. PRESS KEYPAD "+" TO EXPAND]
    align 8

    __mtterm:
    call    __mtdeletelocks
    mov     eax, dwTlsIndex
    cmp     eax, 0FFFFFFFFh
    jz      short locret_4EB0C0
    push    eax
    call    ds:TlsFree                      ; Release a thread local storage (TLS) index
    mov     dwTlsIndex, 0FFFFFFFFh

    locret_4EB0C0:                          ; CODE XREF: .text:004EB0ADj
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000013 BYTES: COLLAPSED FUNCTION __initptd. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000007A BYTES: COLLAPSED FUNCTION __getptd. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4EB170 proc near                    ; CODE XREF: __endthreadex+22p
                                            ; __endthread+31p

    arg_0= dword ptr  4

    mov     eax, dwTlsIndex
    cmp     eax, 0FFFFFFFFh
    jz      locret_4EB21F
    push    esi
    mov     esi, [esp+4+arg_0]
    test    esi, esi
    jnz     short loc_4EB194
    push    eax                             ; dwTlsIndex
    call    ds:TlsGetValue
    mov     esi, eax
    test    esi, esi
    jz      short loc_4EB210

    loc_4EB194:                             ; CODE XREF: sub_4EB170+15j
    mov     eax, [esi+24h]
    test    eax, eax
    jz      short loc_4EB1A4
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4EB1A4:                             ; CODE XREF: sub_4EB170+29j
    mov     eax, [esi+28h]
    test    eax, eax
    jz      short loc_4EB1B4
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4EB1B4:                             ; CODE XREF: sub_4EB170+39j
    mov     eax, [esi+30h]
    test    eax, eax
    jz      short loc_4EB1C4
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4EB1C4:                             ; CODE XREF: sub_4EB170+49j
    mov     eax, [esi+38h]
    test    eax, eax
    jz      short loc_4EB1D4
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4EB1D4:                             ; CODE XREF: sub_4EB170+59j
    mov     eax, [esi+40h]
    test    eax, eax
    jz      short loc_4EB1E4
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4EB1E4:                             ; CODE XREF: sub_4EB170+69j
    mov     eax, [esi+44h]
    test    eax, eax
    jz      short loc_4EB1F4
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4EB1F4:                             ; CODE XREF: sub_4EB170+79j
    mov     eax, [esi+50h]
    cmp     eax, offset dword_50E6D0
    jz      short loc_4EB207
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4EB207:                             ; CODE XREF: sub_4EB170+8Cj
    push    esi                             ; void *
    call    _free
    add     esp, 4

    loc_4EB210:                             ; CODE XREF: sub_4EB170+22j
    mov     eax, dwTlsIndex
    push    0                               ; lpTlsValue
    push    eax                             ; dwTlsIndex
    call    ds:TlsSetValue
    pop     esi

    locret_4EB21F:                          ; CODE XREF: sub_4EB170+8j
    retn
    sub_4EB170 endp

    ; ---------------------------------------------------------------------------
    jmp     ds:GetCurrentThreadId
    ; ---------------------------------------------------------------------------
    align 10h
    jmp     ds:GetCurrentThread
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000068 BYTES: COLLAPSED FUNCTION __close. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000090 BYTES: COLLAPSED FUNCTION __close_lk. PRESS KEYPAD "+" TO EXPAND]
    ; [00000033 BYTES: COLLAPSED FUNCTION __freebuf. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    _fflush:
    push    esi
    mov     esi, [esp+8]
    test    esi, esi
    jnz     short loc_4EB394
    push    esi
    call    _flsall
    add     esp, 4
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4EB394:                             ; CODE XREF: .text:004EB387j
    push    edi
    push    esi
    call    __lock_file
    add     esp, 4
    push    esi
    call    __fflush_lk
    add     esp, 4
    mov     edi, eax
    push    esi
    call    __unlock_file
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000035 BYTES: COLLAPSED FUNCTION __fflush_lk. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000006E BYTES: COLLAPSED FUNCTION __flush. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000000B BYTES: COLLAPSED FUNCTION __flushall. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000BB BYTES: COLLAPSED FUNCTION _flsall. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000015B BYTES: COLLAPSED FUNCTION __openfile. PRESS KEYPAD "+" TO EXPAND]
    align 4
    off_4EB69C dd offset loc_4EB5B7         ; DATA XREF: __openfile+70r
    dd offset loc_4EB624
    dd offset loc_4EB60D
    dd offset loc_4EB600
    dd offset loc_4EB61A
    dd offset loc_4EB5CA
    dd offset loc_4EB5DE
    dd offset loc_4EB5EF
    dd offset loc_4EB5D4
    dd offset loc_4EB62C
    byte_4EB6C4 db 0                        ; DATA XREF: __openfile+6Ar
    dd 6 dup(9090909h), 9090901h, 2 dup(9090909h), 3020909h, 9090904h, 2 dup(9090909h)
    dd 6050909h, 2 dup(9090909h), 9070909h, 9090909h
    db 8, 2 dup(90h)
    ; [000000D9 BYTES: COLLAPSED FUNCTION __getstream. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000015 BYTES: COLLAPSED FUNCTION __frnd. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000050 BYTES: COLLAPSED FUNCTION __handle_qnan1. PRESS KEYPAD "+" TO EXPAND]
    ; [00000073 BYTES: COLLAPSED FUNCTION __handle_qnan2. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000BC BYTES: COLLAPSED FUNCTION __except1. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000EE BYTES: COLLAPSED FUNCTION __except2. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000324 BYTES: COLLAPSED FUNCTION __raise_exc. PRESS KEYPAD "+" TO EXPAND]
    off_4EBDB4 dd offset loc_4EBD4F         ; DATA XREF: __raise_exc+29Br
    dd offset loc_4EBD43                    ; jump table for switch statement
    dd offset loc_4EBD39
    dd offset loc_4EBD32
    align 10h
    ; [00000330 BYTES: COLLAPSED FUNCTION __handle_exc. PRESS KEYPAD "+" TO EXPAND]
    ; [000000AD BYTES: COLLAPSED FUNCTION __umatherr. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000028 BYTES: COLLAPSED FUNCTION __set_errno. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000025 BYTES: COLLAPSED FUNCTION __get_fname. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000037 BYTES: COLLAPSED FUNCTION __errcode. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000039 BYTES: COLLAPSED FUNCTION __set_exp. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000015 BYTES: COLLAPSED FUNCTION __get_exp. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     eax, [esp+0Ah]
    mov     edx, [esp+0Ch]
    shr     eax, 4
    and     eax, 7FFh
    movsx   ecx, ax
    lea     eax, [ecx+edx-3FEh]
    mov     ecx, [esp+8]
    mov     edx, [esp+4]
    push    eax
    push    ecx
    push    edx
    call    __set_exp
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 4

    __set_bexp:
    sub     esp, 8
    mov     eax, [esp+0Ch]
    mov     edx, [esp+12h]
    mov     ecx, [esp+10h]
    mov     [esp+0], eax
    mov     eax, [esp+14h]
    and     edx, 800Fh
    shl     eax, 4
    or      edx, eax
    mov     [esp+4], ecx
    mov     [esp+6], dx
    fld     qword ptr [esp+0]
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000005C BYTES: COLLAPSED FUNCTION __sptype. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000103 BYTES: COLLAPSED FUNCTION __decomp. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000010 BYTES: COLLAPSED FUNCTION __statfp. PRESS KEYPAD "+" TO EXPAND]
    ; [00000011 BYTES: COLLAPSED FUNCTION __clrfp. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000028 BYTES: COLLAPSED FUNCTION __ctrlfp. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000059 BYTES: COLLAPSED FUNCTION __set_statfp. PRESS KEYPAD "+" TO EXPAND]
    align 8
    mov     byte ptr [ebp-90h], 0FEh
    or      ch, ch
    jnz     short loc_4EC5A6
    fxch    st(1)

    loc_4EC55D:                             ; CODE XREF: .text:004EC5BCj
    fyl2x
    jmp     short loc_4EC56E
    ; ---------------------------------------------------------------------------

    unknown_libname_65:
    mov     byte ptr [ebp-90h], 0FEh
    xor     ch, ch
    fldl2e
    fmulp   st(1), st

    loc_4EC56E:                             ; CODE XREF: .text:004EC55Fj
    call    unknown_libname_71
    fld1
    faddp   st(1), st
    test    byte ptr [ebp-9Fh], 1
    jz      short loc_4EC594
    fld1
    cmp     dword_529EC8, 1
    jz      short loc_4EC58F
    fdivrp  st(1), st
    jmp     short loc_4EC594
    ; ---------------------------------------------------------------------------

    loc_4EC58F:                             ; CODE XREF: .text:004EC589j
    call    unknown_libname_119

    loc_4EC594:                             ; CODE XREF: .text:004EC57Ej
                                            ; .text:004EC58Dj
    test    dl, 40h
    jnz     short loc_4EC59B
    fscale

    loc_4EC59B:                             ; CODE XREF: .text:004EC597j
    or      ch, ch
    jz      short loc_4EC5A1
    fchs

    loc_4EC5A1:                             ; CODE XREF: .text:004EC59Dj
    jmp     unknown_libname_75
    ; ---------------------------------------------------------------------------

    loc_4EC5A6:                             ; CODE XREF: .text:004EC559j
    call    sub_4EC6F1
    or      eax, eax
    jz      short loc_4EC5C3
    xor     ch, ch
    cmp     eax, 2
    jz      short loc_4EC5B8
    not     ch

    loc_4EC5B8:                             ; CODE XREF: .text:004EC5B4j
    fxch    st(1)
    fabs
    jmp     short loc_4EC55D
    ; ---------------------------------------------------------------------------
    jmp     unknown_libname_81
    ; ---------------------------------------------------------------------------

    loc_4EC5C3:                             ; CODE XREF: .text:004EC5ADj
                                            ; .text:004EC5EFj ...
    jmp     unknown_libname_87
    ; ---------------------------------------------------------------------------

    unknown_libname_66:
    fstp    st

    unknown_libname_67:
    fstp    st
    fld     tbyte_50E360
    mov     byte ptr [ebp-90h], 2
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_68:
    fldln2
    fxch    st(1)
    ftst
    fstsw   word ptr [ebp-0A0h]
    wait
    test    byte ptr [ebp-9Fh], 41h
    jnz     short loc_4EC5C3
    fyl2x
    retn
    ; ---------------------------------------------------------------------------
    mov     byte ptr [ebp-90h], 2
    fstp    st
    fld     tbyte_50E36A
    retn
    ; ---------------------------------------------------------------------------
    or      cl, cl
    jnz     short loc_4EC65B
    retn
    ; ---------------------------------------------------------------------------
    fldlg2
    jmp     short loc_4EC60F
    ; ---------------------------------------------------------------------------
    fldln2

    loc_4EC60F:                             ; CODE XREF: .text:004EC60Bj
    fxch    st(1)
    or      cl, cl
    jnz     short loc_4EC5C3
    fyl2x
    retn
    ; ---------------------------------------------------------------------------
    jmp     unknown_libname_81
    ; ---------------------------------------------------------------------------
    call    sub_4EC6F1
    fstp    st
    fstp    st
    or      cl, cl
    jnz     short loc_4EC638
    fldz
    cmp     eax, 1
    jnz     short locret_4EC637
    or      ch, ch
    jz      short locret_4EC637
    fchs

    locret_4EC637:                          ; CODE XREF: .text:004EC62Fj
                                            ; .text:004EC633j ...
    retn
    ; ---------------------------------------------------------------------------

    loc_4EC638:                             ; CODE XREF: .text:004EC628j
    mov     byte ptr [ebp-90h], 2
    fld     tbyte_50E360
    cmp     eax, 1
    jnz     short locret_4EC637
    or      ch, ch
    jz      short locret_4EC637
    fchs
    jmp     short locret_4EC637
    ; ---------------------------------------------------------------------------
    fstp    st

    loc_4EC654:                             ; CODE XREF: .text:004EC6A3j
    jmp     unknown_libname_80
    ; ---------------------------------------------------------------------------
    fstp    st

    loc_4EC65B:                             ; CODE XREF: .text:004EC606j
    jmp     unknown_libname_88
    ; ---------------------------------------------------------------------------

    loc_4EC660:                             ; CODE XREF: unknown_libname_71+1Bj
    pop     eax
    ftst
    fstsw   word ptr [ebp-0A0h]
    wait
    test    byte ptr [ebp-9Fh], 1
    jnz     short loc_4EC683
    fstp    st
    fld     tbyte_50E360
    or      ch, ch
    jz      short locret_4EC682
    fchs

    locret_4EC682:                          ; CODE XREF: .text:004EC67Ej
    retn
    ; ---------------------------------------------------------------------------

    loc_4EC683:                             ; CODE XREF: .text:004EC672j
    mov     byte ptr [ebp-90h], 4
    jmp     unknown_libname_80
    ; ---------------------------------------------------------------------------

    unknown_libname_69:
    fstp    st

    unknown_libname_70:
    fstp    st
    fld     tbyte_50E360
    mov     byte ptr [ebp-90h], 3
    retn
    ; ---------------------------------------------------------------------------
    or      cl, cl
    jnz     short loc_4EC654
    fstp    st
    fld     tbyte_50E360
    retn
    ; [00000043 BYTES: COLLAPSED FUNCTION unknown_libname_71. PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4EC6F1 proc near                    ; CODE XREF: .text:004EC5A6p
                                            ; .text:004EC61Dp
    fld     st
    frndint
    fcomp   st(1)
    fstsw   ax
    sahf
    jnz     short loc_4EC717
    fld     st
    fmul    dbl_50E392
    fld     st
    frndint
    fcompp  st(1), st
    fstsw   ax
    sahf
    jz      short loc_4EC71E
    mov     eax, 1

    locret_4EC716:                          ; CODE XREF: sub_4EC6F1+2Bj
                                            ; sub_4EC6F1+32j
    retn
    ; ---------------------------------------------------------------------------

    loc_4EC717:                             ; CODE XREF: sub_4EC6F1+Aj
    mov     eax, 0
    jmp     short locret_4EC716
    ; ---------------------------------------------------------------------------

    loc_4EC71E:                             ; CODE XREF: sub_4EC6F1+1Ej
    mov     eax, 2
    jmp     short locret_4EC716
    sub_4EC6F1 endp

    ; ---------------------------------------------------------------------------
    push    esi
    sub     esp, 74h
    mov     esi, esp
    push    esi
    sub     esp, 8
    fstp    qword ptr [esp]
    sub     esp, 8
    fstp    qword ptr [esp]
    fsave   byte ptr [esi+8]
    call    __powhlp
    add     esp, 14h
    frstor  byte ptr [esi+8]
    fld     qword ptr [esi]
    add     esp, 74h
    pop     esi
    test    eax, eax
    jz      short locret_4EC756
    jmp     unknown_libname_89
    ; ---------------------------------------------------------------------------

    locret_4EC756:                          ; CODE XREF: .text:004EC74Fj
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    unknown_libname_72:
    cmp     byte ptr [edx+0Eh], 5
    jnz     short loc_4EC777
    mov     bx, [ebp-0A4h]
    or      bh, 2
    and     bh, 0FEh
    mov     bl, 3Fh
    jmp     short loc_4EC77B
    ; ---------------------------------------------------------------------------

    loc_4EC777:                             ; CODE XREF: .text:004EC764j
    mov     bx, 133Fh

    loc_4EC77B:                             ; CODE XREF: .text:004EC775j
    mov     [ebp-0A2h], bx
    fldcw   word ptr [ebp-0A2h]
    mov     ebx, offset dword_50E3DC
    fxam
    mov     [ebp-94h], edx
    fstsw   word ptr [ebp-0A0h]
    mov     byte ptr [ebp-90h], 0
    wait
    mov     cl, [ebp-9Fh]
    shl     cl, 1
    sar     cl, 1
    rol     cl, 1
    mov     al, cl
    and     al, 0Fh
    xlat
    movsx   eax, al
    and     ecx, 404h
    mov     ebx, edx
    add     ebx, eax
    add     ebx, 10h
    jmp     dword ptr [ebx]
    ; ---------------------------------------------------------------------------

    unknown_libname_73:
    cmp     byte ptr [edx+0Eh], 5
    jnz     short loc_4EC7DE
    mov     bx, [ebp-0A4h]
    or      bh, 2
    and     bh, 0FEh
    mov     bl, 3Fh
    jmp     short loc_4EC7E2
    ; ---------------------------------------------------------------------------

    loc_4EC7DE:                             ; CODE XREF: .text:004EC7CBj
    mov     bx, 133Fh

    loc_4EC7E2:                             ; CODE XREF: .text:004EC7DCj
    mov     [ebp-0A2h], bx
    fldcw   word ptr [ebp-0A2h]
    mov     ebx, offset dword_50E3DC
    fxam
    mov     [ebp-94h], edx
    fstsw   word ptr [ebp-0A0h]
    mov     byte ptr [ebp-90h], 0
    fxch    st(1)
    mov     cl, [ebp-9Fh]
    fxam
    fstsw   word ptr [ebp-0A0h]
    fxch    st(1)
    mov     ch, [ebp-9Fh]
    shl     ch, 1
    sar     ch, 1
    rol     ch, 1
    mov     al, ch
    and     al, 0Fh
    xlat
    mov     ah, al
    shl     cl, 1
    sar     cl, 1
    rol     cl, 1
    mov     al, cl
    and     al, 0Fh
    xlat
    shl     ah, 1
    shl     ah, 1
    or      al, ah
    movsx   eax, al
    and     ecx, 404h
    mov     ebx, edx
    add     ebx, eax
    add     ebx, 10h
    jmp     dword ptr [ebx]
    ; ---------------------------------------------------------------------------

    unknown_libname_74:
    call    unknown_libname_89

    unknown_libname_75:                     ; CODE XREF: .text:004EC5A1j
    fxch    st(1)

    unknown_libname_76:                     ; CODE XREF: .text:004EC862j
    fstp    st

    unknown_libname_77:
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_78:
    call    unknown_libname_89
    jmp     short unknown_libname_76
    ; ---------------------------------------------------------------------------

    unknown_libname_79:
    fstp    st

    unknown_libname_80:                     ; CODE XREF: .text:004EC654j
                                            ; .text:004EC68Aj
    fstp    st
    fldz
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_81:                     ; CODE XREF: .text:004EC5BEj
                                            ; .text:004EC618j
    fstp    st

    unknown_libname_82:
    fstp    st
    fld1
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_83:
    fstp    tbyte ptr [ebp-9Eh]
    fld     tbyte ptr [ebp-9Eh]
    test    byte ptr [ebp-97h], 40h
    jz      short loc_4EC88F
    mov     byte ptr [ebp-90h], 7
    retn
    ; ---------------------------------------------------------------------------

    loc_4EC88F:                             ; CODE XREF: .text:004EC885j
    mov     byte ptr [ebp-90h], 1
    fadd    dbl_50E3D4
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_84:
    fxch    st(1)

    unknown_libname_85:
    fstp    tbyte ptr [ebp-9Eh]
    fld     tbyte ptr [ebp-9Eh]
    test    byte ptr [ebp-97h], 40h
    jz      short loc_4EC8BD
    mov     byte ptr [ebp-90h], 7
    jmp     short loc_4EC8C4
    ; ---------------------------------------------------------------------------

    loc_4EC8BD:                             ; CODE XREF: .text:004EC8B2j
    mov     byte ptr [ebp-90h], 1

    loc_4EC8C4:                             ; CODE XREF: .text:004EC8BBj
    faddp   st(1), st
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_86:
    fstp    tbyte ptr [ebp-9Eh]
    fld     tbyte ptr [ebp-9Eh]
    test    byte ptr [ebp-97h], 40h
    jz      short loc_4EC8FC
    fxch    st(1)
    fstp    tbyte ptr [ebp-9Eh]
    fld     tbyte ptr [ebp-9Eh]
    test    byte ptr [ebp-97h], 40h
    jz      short loc_4EC8FC
    mov     byte ptr [ebp-90h], 7
    jmp     short loc_4EC903
    ; ---------------------------------------------------------------------------

    loc_4EC8FC:                             ; CODE XREF: .text:004EC8DAj
                                            ; .text:004EC8F1j
    mov     byte ptr [ebp-90h], 1

    loc_4EC903:                             ; CODE XREF: .text:004EC8FAj
    faddp   st(1), st
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_87:                     ; CODE XREF: .text:004EC5C3j
    fstp    st

    unknown_libname_88:                     ; CODE XREF: .text:004EC65Bj
    fstp    st
    fld     tbyte_50E3C0
    cmp     byte ptr [ebp-90h], 0
    jg      short loc_4EC920
    ; [0000000A BYTES: COLLAPSED FUNCTION unknown_libname_89. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    unknown_libname_90:
    or      cl, cl
    jz      short locret_4EC929
    fchs

    locret_4EC929:                          ; CODE XREF: .text:004EC925j
    retn
    ; ---------------------------------------------------------------------------
    align 8
    ; [00000017 BYTES: COLLAPSED FUNCTION unknown_libname_91. PRESS KEYPAD "+" TO EXPAND]
    ; [0000003C BYTES: COLLAPSED FUNCTION unknown_libname_92. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000015 BYTES: COLLAPSED FUNCTION unknown_libname_93. PRESS KEYPAD "+" TO EXPAND]
    ; [00000017 BYTES: COLLAPSED FUNCTION unknown_libname_94. PRESS KEYPAD "+" TO EXPAND]
    ; [00000019 BYTES: COLLAPSED FUNCTION unknown_libname_95. PRESS KEYPAD "+" TO EXPAND]
    ; [00000043 BYTES: COLLAPSED FUNCTION unknown_libname_96. PRESS KEYPAD "+" TO EXPAND]
    ; [00000016 BYTES: COLLAPSED FUNCTION unknown_libname_97. PRESS KEYPAD "+" TO EXPAND]
    ; [0000000D BYTES: COLLAPSED FUNCTION unknown_libname_98. PRESS KEYPAD "+" TO EXPAND]
    ; [0000002A BYTES: COLLAPSED FUNCTION unknown_libname_99. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    unknown_libname_100:
    sub     esp, 8
    fst     qword ptr [esp]
    mov     eax, [esp+4]
    add     esp, 8
    and     eax, 7FF00000h
    jmp     short loc_4ECA8D
    ; ---------------------------------------------------------------------------

    unknown_libname_101:                    ; CODE XREF: sub_4E5392+73j
    sub     esp, 8
    fst     qword ptr [esp]
    mov     eax, [esp+4]
    add     esp, 8
    and     eax, 7FF00000h
    jz      short loc_4ECACA

    loc_4ECA8D:                             ; CODE XREF: .text:004ECA77j
    cmp     eax, 7FF00000h
    jz      short loc_4ECAF3
    mov     ax, [esp]
    cmp     ax, 27Fh
    jz      short loc_4ECAC8
    and     ax, 20h
    jnz     short loc_4ECAC5
    fstsw   ax
    and     ax, 20h
    jz      short loc_4ECAC5
    mov     eax, 8

    loc_4ECAB2:                             ; CODE XREF: .text:004ECAE9j
                                            ; .text:004ECAF1j ...
    cmp     edx, 1Dh
    jz      short loc_4ECABE
    call    unknown_libname_92
    pop     edx
    retn
    ; ---------------------------------------------------------------------------

    loc_4ECABE:                             ; CODE XREF: .text:004ECAB5j
    call    unknown_libname_91
    pop     edx
    retn
    ; ---------------------------------------------------------------------------

    loc_4ECAC5:                             ; CODE XREF: .text:004ECAA2j
                                            ; .text:004ECAABj
    fldcw   word ptr [esp]

    loc_4ECAC8:                             ; CODE XREF: .text:004ECA9Cj
    pop     edx
    retn
    ; ---------------------------------------------------------------------------

    loc_4ECACA:                             ; CODE XREF: .text:004ECA8Bj
    fld     ds:dbl_4FDF4C
    fxch    st(1)
    fscale
    fstp    st(1)
    fld     st
    fabs
    fcomp   ds:dbl_4FDF3C
    fstsw   ax
    sahf
    mov     eax, 4
    jnb     short loc_4ECAB2
    fmul    ds:dbl_4FDF5C
    jmp     short loc_4ECAB2
    ; ---------------------------------------------------------------------------

    loc_4ECAF3:                             ; CODE XREF: .text:004ECA92j
    fld     ds:dbl_4FDF44
    fxch    st(1)
    fscale
    fstp    st(1)
    fld     st
    fabs
    fcomp   ds:dbl_4FDF34
    fstsw   ax
    sahf
    mov     eax, 3
    jbe     short loc_4ECAB2
    fmul    ds:dbl_4FDF54
    jmp     short loc_4ECAB2
    ; ---------------------------------------------------------------------------
    align 8
    ; [00000221 BYTES: COLLAPSED FUNCTION __powhlp. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000081 BYTES: COLLAPSED FUNCTION __d_inttype. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4ECDE0 proc near                    ; CODE XREF: ___CxxFrameHandler+27p
                                            ; CatchGuardHandler(EHExceptionRecord *,CatchGuardRN *,void *,void *)+20p ...

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h
    arg_C= dword ptr  14h
    arg_10= dword ptr  18h
    arg_14= dword ptr  1Ch
    arg_18= dword ptr  20h
    arg_1C= dword ptr  24h

    push    esi
    mov     esi, [esp+arg_10]
    cmp     dword ptr [esi], 19930520h
    jz      short loc_4ECDF2
    call    sub_4ED910

    loc_4ECDF2:                             ; CODE XREF: sub_4ECDE0+Bj
    mov     eax, [esp+arg_0]
    test    byte ptr [eax+4], 66h
    jz      short loc_4ECE2F
    mov     eax, [esi+4]
    test    eax, eax
    jz      loc_4ECEA6
    mov     eax, [esp+arg_14]
    test    eax, eax
    jnz     loc_4ECEA6
    mov     eax, [esp+arg_C]
    mov     ecx, [esp+arg_4]
    push    0FFFFFFFFh
    push    esi
    push    eax
    push    ecx
    call    ___FrameUnwindToState
    add     esp, 10h
    mov     eax, 1
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4ECE2F:                             ; CODE XREF: sub_4ECDE0+1Aj
    mov     ecx, [esi+0Ch]
    test    ecx, ecx
    jz      short loc_4ECEA6
    cmp     dword ptr [eax], 0E06D7363h
    jnz     short loc_4ECE7E
    cmp     dword ptr [eax+14h], 19930520h
    jbe     short loc_4ECE7E
    mov     edx, [eax+1Ch]
    mov     ecx, [edx+8]
    test    ecx, ecx
    jz      short loc_4ECE7E
    mov     edx, [esp+arg_1C]
    and     edx, 0FFh
    push    edx
    mov     edx, [esp+4+arg_18]
    push    edx
    mov     edx, [esp+8+arg_14]
    push    edx
    mov     edx, [esp+0Ch+arg_C]
    push    esi
    push    edx
    mov     edx, [esp+14h+arg_8]
    push    edx
    mov     edx, [esp+18h+arg_4]
    push    edx
    push    eax
    call    ecx
    add     esp, 20h
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4ECE7E:                             ; CODE XREF: sub_4ECDE0+5Cj
                                            ; sub_4ECDE0+65j ...
    mov     ecx, [esp+arg_18]
    mov     edx, [esp+arg_14]
    push    ecx
    mov     ecx, [esp+4+arg_1C]
    push    edx
    mov     edx, [esp+8+arg_C]
    push    ecx
    mov     ecx, [esp+0Ch+arg_8]
    push    esi
    push    edx
    mov     edx, [esp+14h+arg_4]
    push    ecx
    push    edx
    push    eax
    call    ?FindHandler@@YAXPAUEHExceptionRecord@@PAUEHRegistrationNode@@PAU_CONTEXT@@PAXPBU_s_FuncInfo@@EH1@Z ; FindHandler(EHExceptionRecord *,EHRegistrationNode *,_CONTEXT *,void *,_s_FuncInfo const *,uchar,int,EHRegistrationNode *)
    add     esp, 20h

    loc_4ECEA6:                             ; CODE XREF: sub_4ECDE0+21j
                                            ; sub_4ECDE0+2Dj ...
    mov     eax, 1
    pop     esi
    retn
    sub_4ECDE0 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [000002BB BYTES: COLLAPSED FUNCTION FindHandler(EHExceptionRecord *,EHRegistrationNode *,_CONTEXT *,void *,_s_FuncInfo const *,uchar,int,EHRegistrationNode *). PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000D7 BYTES: COLLAPSED FUNCTION FindHandlerForForeignException(EHExceptionRecord *,EHRegistrationNode *,_CONTEXT *,void *,_s_FuncInfo const *,int,int,EHRegistrationNode *). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000B5 BYTES: COLLAPSED FUNCTION ___FrameUnwindToState. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000016 BYTES: COLLAPSED FUNCTION sub_4ED310. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000089 BYTES: COLLAPSED FUNCTION CatchIt(EHExceptionRecord *,EHRegistrationNode *,_CONTEXT *,void *,_s_FuncInfo const *,_s_HandlerType const *,_s_CatchableType const *,_s_TryBlockMapEntry const *,int,EHRegistrationNode *). PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000B7 BYTES: COLLAPSED FUNCTION CallCatchBlock(EHExceptionRecord *,EHRegistrationNode *,_CONTEXT *,_s_FuncInfo const *,void *,int,ulong). PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------
    mov     edx, [ebp-14h]
    push    edx
    call    ?ExFilterRethrow@@YAHPAU_EXCEPTION_POINTERS@@@Z ; ExFilterRethrow(_EXCEPTION_POINTERS *)
    add     esp, 4
    retn
    ; ---------------------------------------------------------------------------
    mov     esp, [ebp-18h]
    mov     dword ptr [ebp-2Ch], 0
    push    0FFFFFFFFh
    lea     eax, [ebp-10h]
    push    eax
    call    __local_unwind2
    add     esp, 8
    xor     eax, eax
    mov     ecx, [ebp-10h]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4ED4AF proc near                    ; DATA XREF: .rdata:004FDF90o
    mov     esi, [ebp+0Ch]
    mov     edi, [ebp+8]
    mov     ebx, [ebp-2Ch]
    sub_4ED4AF endp

    ; [0000004E BYTES: COLLAPSED FUNCTION sub_4ED4B8. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------
    mov     eax, ebx
    mov     ecx, [ebp-10h]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------
    align 8
    ; [0000002D BYTES: COLLAPSED FUNCTION ExFilterRethrow(_EXCEPTION_POINTERS *). PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000201 BYTES: COLLAPSED FUNCTION BuildCatchObject(EHExceptionRecord *,EHRegistrationNode *,_s_HandlerType const *,_s_CatchableType const *). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000075 BYTES: COLLAPSED FUNCTION _DestructExceptionObject(EHExceptionRecord *,uchar). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000025 BYTES: COLLAPSED FUNCTION AdjustPointer(void *,PMD const &). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000004C BYTES: COLLAPSED FUNCTION unknown_libname_102. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000077 BYTES: COLLAPSED FUNCTION terminate(void). PRESS KEYPAD "+" TO EXPAND]
    ; [00000006 BYTES: COLLAPSED FUNCTION sub_4ED8D7. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------
    mov     ecx, [ebp-10h]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [00000019 BYTES: COLLAPSED FUNCTION unexpected(void). PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: bp-based frame

    sub_4ED910 proc near                    ; CODE XREF: _GetRangeOfTrysToCheck(_s_FuncInfo const *,int,int,uint *,uint *)+24p
                                            ; _GetRangeOfTrysToCheck(_s_FuncInfo const *,int,int,uint *,uint *)+6Ap ...

    var_18= dword ptr -18h
    var_10= dword ptr -10h
    var_4= dword ptr -4

    push    ebp
    mov     ebp, esp
    push    0FFFFFFFFh
    push    offset stru_4FDFE0
    push    offset __except_handler3
    mov     eax, large fs:0
    push    eax
    mov     large fs:0, esp
    sub     esp, 8
    push    ebx
    push    esi
    push    edi
    mov     [ebp+var_18], esp
    mov     [ebp+var_4], 0
    mov     eax, dword_50E400
    test    eax, eax
    jz      short loc_4ED961
    mov     [ebp+var_4], 1
    call    eax ; terminate(void)           ; terminate(void)
    jmp     short loc_4ED95A
    ; ---------------------------------------------------------------------------
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------
    mov     esp, [ebp+var_18]

    loc_4ED95A:                             ; CODE XREF: sub_4ED910+3Fj
    mov     [ebp+var_4], 0

    loc_4ED961:                             ; CODE XREF: sub_4ED910+34j
    mov     [ebp+var_4], 0FFFFFFFFh
    call    sub_4ED97E
    mov     ecx, [ebp+var_10]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    sub_4ED910 endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4ED97E proc near                    ; CODE XREF: sub_4ED910+58p
                                            ; DATA XREF: .rdata:004FDFE0o
    call    ?terminate@@YAXXZ               ; terminate(void)
    retn
    sub_4ED97E endp

    ; ---------------------------------------------------------------------------
    mov     ecx, [ebp-10h]
    mov     large fs:0, ecx
    pop     edi
    pop     esi
    pop     ebx
    mov     esp, ebp
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    _setlocale:
    sub     esp, 90h
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, [esp+0A4h]
    xor     ebp, ebp
    cmp     edi, ebp
    jl      loc_4EDC5B
    cmp     edi, 5
    jg      loc_4EDC5B
    push    13h
    call    __lock
    mov     ecx, dword_52B648
    mov     eax, Addend
    add     esp, 4
    inc     ecx
    cmp     eax, ebp
    mov     dword_52B648, ecx
    jz      short loc_4ED9F6
    mov     esi, ds:Sleep

    loc_4ED9EA:                             ; CODE XREF: .text:004ED9F4j
    push    1
    call    esi ; Sleep
    cmp     Addend, ebp
    jnz     short loc_4ED9EA

    loc_4ED9F6:                             ; CODE XREF: .text:004ED9E2j
    cmp     edi, ebp
    jz      short loc_4EDA23
    mov     eax, [esp+0A8h]
    cmp     eax, ebp
    jz      short loc_4EDA14
    push    eax
    push    edi
    call    __setlocale_set_cat
    add     esp, 8
    jmp     loc_4EDC37
    ; ---------------------------------------------------------------------------

    loc_4EDA14:                             ; CODE XREF: .text:004EDA03j
    lea     eax, [edi+edi*2]
    mov     esi, dword_50E414[eax*4]
    jmp     loc_4EDC39
    ; ---------------------------------------------------------------------------

    loc_4EDA23:                             ; CODE XREF: .text:004ED9F8j
    mov     ebx, [esp+0A8h]
    mov     dword ptr [esp+14h], 1
    cmp     ebx, ebp
    mov     [esp+10h], ebp
    jz      loc_4EDC32
    cmp     byte ptr [ebx], 4Ch
    jnz     loc_4EDB75
    cmp     byte ptr [ebx+1], 43h
    jnz     loc_4EDB75
    cmp     byte ptr [ebx+2], 5Fh
    jnz     loc_4EDB75
    push    offset asc_4FE038               ; "=;"
    push    ebx
    call    _strpbrk
    mov     ebp, eax
    add     esp, 8
    test    ebp, ebp
    jz      loc_4EDB53

    loc_4EDA73:                             ; CODE XREF: .text:004EDB4Dj
    mov     edi, ebp
    sub     edi, ebx
    mov     [esp+14h], edi
    jz      loc_4EDB53
    cmp     byte ptr [ebp+0], 3Bh
    jz      loc_4EDB53
    mov     dword ptr [esp+18h], 1
    mov     esi, offset off_50E41C

    loc_4EDA98:                             ; CODE XREF: .text:004EDACFj
    mov     ecx, [esi]
    push    edi
    push    ebx
    push    ecx
    call    _strncmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4EDABD
    mov     edi, [esi]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+14h]
    not     ecx
    dec     ecx
    cmp     eax, ecx
    jz      short loc_4EDAD1
    mov     edi, eax

    loc_4EDABD:                             ; CODE XREF: .text:004EDAA7j
    mov     edx, [esp+18h]
    add     esi, 0Ch
    inc     edx
    cmp     esi, offset off_50E44C
    mov     [esp+18h], edx
    jle     short loc_4EDA98

    loc_4EDAD1:                             ; CODE XREF: .text:004EDAB9j
    inc     ebp
    push    offset asc_50D370               ; ";"
    push    ebp
    call    _strcspn
    mov     esi, eax
    add     esp, 8
    test    esi, esi
    jnz     short loc_4EDAEC
    cmp     byte ptr [ebp+0], 3Bh
    jnz     short loc_4EDB53

    loc_4EDAEC:                             ; CODE XREF: .text:004EDAE4j
    mov     edi, [esp+18h]
    cmp     edi, 5
    jg      short loc_4EDB1F
    push    esi
    lea     edx, [esp+20h]
    push    ebp
    push    edx
    call    _strncpy
    add     esp, 0Ch
    lea     eax, [esp+1Ch]
    mov     byte ptr [esp+esi+1Ch], 0
    push    eax
    push    edi
    call    __setlocale_set_cat
    add     esp, 8
    test    eax, eax
    jz      short loc_4EDB1F
    inc     dword ptr [esp+10h]

    loc_4EDB1F:                             ; CODE XREF: .text:004EDAF3j
                                            ; .text:004EDB19j
    mov     al, [ebp+esi+0]
    lea     ebx, [ebp+esi+0]
    test    al, al
    jz      loc_4EDC26
    mov     al, [ebx+1]
    inc     ebx
    test    al, al
    jz      loc_4EDC26
    push    offset asc_4FE038               ; "=;"
    push    ebx
    call    _strpbrk
    mov     ebp, eax
    add     esp, 8
    test    ebp, ebp
    jnz     loc_4EDA73

    loc_4EDB53:                             ; CODE XREF: .text:004EDA6Dj
                                            ; .text:004EDA7Bj ...
    push    13h
    call    __unlock
    mov     eax, dword_52B648
    add     esp, 4
    dec     eax
    mov     dword_52B648, eax
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 90h
    retn
    ; ---------------------------------------------------------------------------

    loc_4EDB75:                             ; CODE XREF: .text:004EDA41j
                                            ; .text:004EDA4Bj ...
    push    ebp
    push    ebp
    lea     ecx, [esp+24h]
    push    ebp
    push    ecx
    push    ebx
    call    __expandlocale
    mov     esi, eax
    add     esp, 14h
    cmp     esi, ebp
    jz      loc_4EDC39
    mov     edi, offset dword_50E414

    loc_4EDB95:                             ; CODE XREF: .text:004EDBFAj
    cmp     edi, offset dword_50E414
    jz      short loc_4EDBF0
    mov     esi, [edi]
    lea     eax, [esp+1Ch]

    loc_4EDBA3:                             ; CODE XREF: .text:004EDBC5j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4EDBCB
    test    cl, cl
    jz      short loc_4EDBC7
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4EDBCB
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4EDBA3

    loc_4EDBC7:                             ; CODE XREF: .text:004EDBAFj
    xor     eax, eax
    jmp     short loc_4EDBD0
    ; ---------------------------------------------------------------------------

    loc_4EDBCB:                             ; CODE XREF: .text:004EDBABj
                                            ; .text:004EDBBBj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4EDBD0:                             ; CODE XREF: .text:004EDBC9j
    test    eax, eax
    jz      short loc_4EDBEC
    lea     eax, [esp+1Ch]
    push    eax
    push    ebp
    call    __setlocale_set_cat
    add     esp, 8
    test    eax, eax
    jnz     short loc_4EDBEC
    mov     [esp+14h], eax
    jmp     short loc_4EDBF0
    ; ---------------------------------------------------------------------------

    loc_4EDBEC:                             ; CODE XREF: .text:004EDBD2j
                                            ; .text:004EDBE4j
    inc     dword ptr [esp+10h]

    loc_4EDBF0:                             ; CODE XREF: .text:004EDB9Bj
                                            ; .text:004EDBEAj
    add     edi, 0Ch
    inc     ebp
    cmp     edi, offset off_50E450
    jle     short loc_4EDB95
    mov     eax, [esp+14h]
    test    eax, eax
    jz      short loc_4EDC26
    call    __setlocale_get_all
    mov     ecx, dword_50E414
    mov     esi, eax
    push    ecx
    call    _free
    add     esp, 4
    mov     dword_50E414, 0
    jmp     short loc_4EDC39
    ; ---------------------------------------------------------------------------

    loc_4EDC26:                             ; CODE XREF: .text:004EDB29j
                                            ; .text:004EDB35j ...
    mov     eax, [esp+10h]
    test    eax, eax
    jnz     short loc_4EDC32
    xor     esi, esi
    jmp     short loc_4EDC39
    ; ---------------------------------------------------------------------------

    loc_4EDC32:                             ; CODE XREF: .text:004EDA38j
                                            ; .text:004EDC2Cj
    call    __setlocale_get_all

    loc_4EDC37:                             ; CODE XREF: .text:004EDA0Fj
    mov     esi, eax

    loc_4EDC39:                             ; CODE XREF: .text:004EDA1Ej
                                            ; .text:004EDB8Aj ...
    push    13h
    call    __unlock
    mov     eax, dword_52B648
    add     esp, 4
    dec     eax
    mov     dword_52B648, eax
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 90h
    retn
    ; ---------------------------------------------------------------------------

    loc_4EDC5B:                             ; CODE XREF: .text:004ED9B5j
                                            ; .text:004ED9BEj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 90h
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000155 BYTES: COLLAPSED FUNCTION __setlocale_set_cat. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000011B BYTES: COLLAPSED FUNCTION __setlocale_get_all. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000001F2 BYTES: COLLAPSED FUNCTION __expandlocale. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    unknown_libname_104:
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000044 BYTES: COLLAPSED FUNCTION __strcats. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4EE150 proc near                    ; CODE XREF: __expandlocale+E8p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_0]
    push    ebx
    push    ebp
    mov     ebp, [esp+8+arg_4]
    push    esi
    push    edi
    mov     ecx, 22h
    xor     eax, eax
    mov     edi, edx
    rep stosd
    mov     al, [ebp+0]
    test    al, al
    jnz     short loc_4EE175
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE175:                             ; CODE XREF: sub_4EE150+1Cj
    cmp     al, 2Eh
    jnz     short loc_4EE1AD
    mov     al, [ebp+1]
    lea     edi, [ebp+1]
    test    al, al
    jz      short loc_4EE1AD
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     edx, 80h
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     eax, ecx
    mov     esi, edi
    mov     edi, edx
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    and     ecx, 3
    xor     eax, eax
    rep movsb
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE1AD:                             ; CODE XREF: sub_4EE150+27j
                                            ; sub_4EE150+31j
    push    offset byte_4FE040              ; char *
    push    ebp                             ; char *
    xor     edi, edi
    call    _strcspn
    mov     esi, eax
    add     esp, 8
    test    esi, esi
    jz      loc_4EE24F

    loc_4EE1C7:                             ; CODE XREF: sub_4EE150+EEj
    mov     bl, [esi+ebp]
    test    edi, edi
    jnz     short loc_4EE1E1
    cmp     esi, 40h
    jge     short loc_4EE1E1
    cmp     bl, 2Eh
    jz      short loc_4EE1E1
    mov     ecx, [esp+10h+arg_0]
    push    esi
    push    ebp
    push    ecx
    jmp     short loc_4EE216
    ; ---------------------------------------------------------------------------

    loc_4EE1E1:                             ; CODE XREF: sub_4EE150+7Cj
                                            ; sub_4EE150+81j ...
    cmp     edi, 1
    jnz     short loc_4EE1FC
    cmp     esi, 40h
    jge     short loc_4EE1FC
    cmp     bl, 5Fh
    jz      short loc_4EE1FC
    mov     edx, [esp+10h+arg_0]
    push    esi
    add     edx, 40h
    push    ebp
    push    edx
    jmp     short loc_4EE216
    ; ---------------------------------------------------------------------------

    loc_4EE1FC:                             ; CODE XREF: sub_4EE150+94j
                                            ; sub_4EE150+99j ...
    cmp     edi, 2
    jnz     short loc_4EE24F
    test    bl, bl
    jz      short loc_4EE20A
    cmp     bl, 2Ch
    jnz     short loc_4EE24F

    loc_4EE20A:                             ; CODE XREF: sub_4EE150+B3j
    mov     eax, [esp+10h+arg_0]
    push    esi                             ; size_t
    add     eax, 80h
    push    ebp                             ; char *
    push    eax                             ; char *

    loc_4EE216:                             ; CODE XREF: sub_4EE150+8Fj
                                            ; sub_4EE150+AAj
    call    _strncpy
    add     esp, 0Ch
    cmp     bl, 2Ch
    jz      short loc_4EE248
    test    bl, bl
    jz      short loc_4EE248
    lea     ebp, [esi+ebp+1]
    push    offset byte_4FE040              ; char *
    push    ebp                             ; char *
    inc     edi
    call    _strcspn
    mov     esi, eax
    add     esp, 8
    test    esi, esi
    jnz     short loc_4EE1C7
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE248:                             ; CODE XREF: sub_4EE150+D1j
                                            ; sub_4EE150+D5j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE24F:                             ; CODE XREF: sub_4EE150+71j
                                            ; sub_4EE150+AFj ...
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn
    sub_4EE150 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000006A BYTES: COLLAPSED FUNCTION ___lc_lctostr. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ___crtLCMapStringW:
    mov     eax, dword_52A02C
    push    ebx
    mov     ebx, ds:LCMapStringW
    push    ebp
    push    esi
    push    edi
    test    eax, eax
    jnz     short loc_4EE32C
    push    0
    push    0
    push    1
    push    offset SrcStr
    push    100h
    push    0
    call    ebx ; LCMapStringW
    test    eax, eax
    jz      short loc_4EE302
    mov     eax, 1
    jmp     short loc_4EE327
    ; ---------------------------------------------------------------------------

    loc_4EE302:                             ; CODE XREF: .text:004EE2F9j
    push    0
    push    0
    push    1
    push    offset String1
    push    100h
    push    0
    call    ds:LCMapStringA
    test    eax, eax
    jz      loc_4EE4D0
    mov     eax, 2

    loc_4EE327:                             ; CODE XREF: .text:004EE300j
    mov     dword_52A02C, eax

    loc_4EE32C:                             ; CODE XREF: .text:004EE2E1j
    mov     esi, [esp+20h]
    test    esi, esi
    jle     short loc_4EE34B
    mov     edi, [esp+1Ch]
    push    esi
    push    edi
    call    _wcsncnt
    mov     esi, eax
    mov     eax, dword_52A02C
    add     esp, 8
    jmp     short loc_4EE34F
    ; ---------------------------------------------------------------------------

    loc_4EE34B:                             ; CODE XREF: .text:004EE332j
    mov     edi, [esp+1Ch]

    loc_4EE34F:                             ; CODE XREF: .text:004EE349j
    cmp     eax, 1
    jnz     short loc_4EE371
    mov     eax, [esp+28h]
    mov     ecx, [esp+24h]
    mov     edx, [esp+18h]
    push    eax
    mov     eax, [esp+18h]
    push    ecx
    push    esi
    push    edi
    push    edx
    push    eax
    call    ebx ; LCMapStringW
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE371:                             ; CODE XREF: .text:004EE352j
    cmp     eax, 2
    jnz     loc_4EE479
    mov     ebx, [esp+2Ch]
    mov     dword ptr [esp+20h], 0
    test    ebx, ebx
    jnz     short loc_4EE390
    mov     ebx, CodePage

    loc_4EE390:                             ; CODE XREF: .text:004EE388j
    push    0
    push    0
    push    0
    push    0
    push    esi
    push    edi
    push    220h
    push    ebx
    call    ds:WideCharToMultiByte
    mov     edi, eax
    test    edi, edi
    jnz     short loc_4EE3B1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE3B1:                             ; CODE XREF: .text:004EE3AAj
    push    edi
    call    _malloc
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jnz     short loc_4EE3C5
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE3C5:                             ; CODE XREF: .text:004EE3BEj
    mov     ecx, [esp+1Ch]
    push    0
    push    0
    push    edi
    push    ebp
    push    esi
    push    ecx
    push    220h
    push    ebx
    call    ds:WideCharToMultiByte
    test    eax, eax
    jz      loc_4EE4BA
    mov     edx, [esp+18h]
    mov     eax, [esp+14h]
    push    0
    push    0
    push    edi
    push    ebp
    push    edx
    push    eax
    call    ds:LCMapStringA
    mov     esi, eax
    test    esi, esi
    jz      loc_4EE4BA
    push    esi
    call    _malloc
    add     esp, 4
    mov     [esp+20h], eax
    test    eax, eax
    jz      loc_4EE4BA
    mov     ecx, [esp+14h]
    push    esi
    push    eax
    push    edi
    mov     edi, [esp+24h]
    push    ebp
    push    edi
    push    ecx
    call    ds:LCMapStringA
    test    eax, eax
    jz      loc_4EE4BA
    test    edi, 400h
    jz      short loc_4EE47E
    mov     eax, [esp+28h]
    mov     edi, esi
    test    eax, eax
    jz      short loc_4EE461
    cmp     eax, esi
    jl      short loc_4EE44E
    mov     eax, esi

    loc_4EE44E:                             ; CODE XREF: .text:004EE44Aj
    mov     edx, [esp+20h]
    push    eax
    mov     eax, [esp+28h]
    push    edx
    push    eax
    call    _strncpy
    add     esp, 0Ch

    loc_4EE461:                             ; CODE XREF: .text:004EE446j
                                            ; .text:004EE49Dj ...
    push    ebp
    call    _free
    mov     edx, [esp+24h]
    add     esp, 4
    push    edx
    call    _free
    add     esp, 4
    mov     eax, edi

    loc_4EE479:                             ; CODE XREF: .text:004EE374j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE47E:                             ; CODE XREF: .text:004EE43Cj
    mov     eax, [esp+28h]
    test    eax, eax
    jnz     short loc_4EE49F
    mov     ecx, [esp+20h]
    push    eax
    push    eax
    push    esi
    push    ecx
    push    1
    push    ebx
    call    ds:MultiByteToWideChar
    mov     edi, eax
    test    edi, edi
    jz      short loc_4EE4BA
    jmp     short loc_4EE461
    ; ---------------------------------------------------------------------------

    loc_4EE49F:                             ; CODE XREF: .text:004EE484j
    mov     edx, [esp+24h]
    push    eax
    mov     eax, [esp+24h]
    push    edx
    push    esi
    push    eax
    push    1
    push    ebx
    call    ds:MultiByteToWideChar
    mov     edi, eax
    test    edi, edi
    jnz     short loc_4EE461

    loc_4EE4BA:                             ; CODE XREF: .text:004EE3DFj
                                            ; .text:004EE3FFj ...
    push    ebp
    call    _free
    mov     ecx, [esp+24h]
    add     esp, 4
    push    ecx
    call    _free
    add     esp, 4

    loc_4EE4D0:                             ; CODE XREF: .text:004EE31Cj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000035 BYTES: COLLAPSED FUNCTION _wcsncnt. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4EE520(LCID Locale,DWORD dwMapFlags,LPCSTR lpMultiByteStr,void *lpWideCharStr,LPWSTR lpDestStr,int cchDest,UINT CodePage,int)
    sub_4EE520 proc near                    ; CODE XREF: sub_4E5AC0+BBp
                                            ; sub_4E7250+BBp ...

    Locale= dword ptr  4
    dwMapFlags= dword ptr  8
    lpMultiByteStr= dword ptr  0Ch
    lpWideCharStr= dword ptr  10h
    lpDestStr= dword ptr  14h
    cchDest= dword ptr  18h
    CodePage= dword ptr  1Ch
    arg_1C= dword ptr  20h

    mov     eax, dword_52A030
    push    ebx
    mov     ebx, ds:LCMapStringA
    push    ebp
    push    esi
    push    edi
    test    eax, eax
    jnz     short loc_4EE57C
    push    0                               ; cchDest
    push    0                               ; lpDestStr
    push    1                               ; cchSrc
    push    offset SrcStr                   ; lpSrcStr
    push    100h                            ; dwMapFlags
    push    0                               ; Locale
    call    ds:LCMapStringW
    test    eax, eax
    jz      short loc_4EE556
    mov     eax, 1
    jmp     short loc_4EE577
    ; ---------------------------------------------------------------------------

    loc_4EE556:                             ; CODE XREF: sub_4EE520+2Dj
    push    0                               ; cchDest
    push    0                               ; lpDestStr
    push    1                               ; cchSrc
    push    offset String1                  ; lpSrcStr
    push    100h                            ; dwMapFlags
    push    0                               ; Locale
    call    ebx ; LCMapStringA
    test    eax, eax
    jz      loc_4EE73E
    mov     eax, 2

    loc_4EE577:                             ; CODE XREF: sub_4EE520+34j
    mov     dword_52A030, eax

    loc_4EE57C:                             ; CODE XREF: sub_4EE520+11j
    mov     esi, [esp+10h+lpWideCharStr]
    test    esi, esi
    jle     short loc_4EE59B
    mov     edi, [esp+10h+lpMultiByteStr]
    push    esi
    push    edi
    call    _strncnt
    mov     esi, eax
    mov     eax, dword_52A030
    add     esp, 8
    jmp     short loc_4EE59F
    ; ---------------------------------------------------------------------------

    loc_4EE59B:                             ; CODE XREF: sub_4EE520+62j
    mov     edi, [esp+10h+lpMultiByteStr]

    loc_4EE59F:                             ; CODE XREF: sub_4EE520+79j
    cmp     eax, 2
    jnz     short loc_4EE5C1
    mov     eax, [esp+10h+cchDest]
    mov     ecx, [esp+10h+lpDestStr]
    mov     edx, [esp+10h+dwMapFlags]
    push    eax                             ; cchDest
    mov     eax, [esp+14h+Locale]
    push    ecx                             ; lpDestStr
    push    esi                             ; cchSrc
    push    edi                             ; lpSrcStr
    push    edx                             ; dwMapFlags
    push    eax                             ; Locale
    call    ebx ; LCMapStringA
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE5C1:                             ; CODE XREF: sub_4EE520+82j
    cmp     eax, 1
    jnz     loc_4EE6A7
    mov     ebp, [esp+10h+CodePage]
    mov     [esp+10h+lpWideCharStr], 0
    test    ebp, ebp
    jnz     short loc_4EE5E6
    mov     ecx, CodePage
    mov     [esp+10h+CodePage], ecx
    mov     ebp, ecx

    loc_4EE5E6:                             ; CODE XREF: sub_4EE520+B8j
    mov     edx, [esp+10h+arg_1C]
    push    0                               ; cchWideChar
    neg     edx
    sbb     edx, edx
    push    0                               ; lpWideCharStr
    and     edx, 8
    push    esi                             ; cchMultiByte
    inc     edx
    push    edi                             ; lpMultiByteStr
    push    edx                             ; dwFlags
    push    ebp                             ; CodePage
    call    ds:MultiByteToWideChar
    mov     edi, eax
    test    edi, edi
    jnz     short loc_4EE60B
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE60B:                             ; CODE XREF: sub_4EE520+E4j
    lea     eax, [edi+edi]
    push    eax                             ; size_t
    call    _malloc
    mov     ebx, eax
    add     esp, 4
    test    ebx, ebx
    jnz     short loc_4EE622
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE622:                             ; CODE XREF: sub_4EE520+FBj
    mov     ecx, [esp+10h+lpMultiByteStr]
    push    edi                             ; cchWideChar
    push    ebx                             ; lpWideCharStr
    push    esi                             ; cchMultiByte
    push    ecx                             ; lpMultiByteStr
    push    1                               ; dwFlags
    push    ebp                             ; CodePage
    call    ds:MultiByteToWideChar
    test    eax, eax
    jz      loc_4EE728
    mov     ebp, [esp+10h+dwMapFlags]
    mov     edx, [esp+10h+Locale]
    push    0                               ; cchDest
    push    0                               ; lpDestStr
    push    edi                             ; cchSrc
    push    ebx                             ; lpSrcStr
    push    ebp                             ; dwMapFlags
    push    edx                             ; Locale
    call    ds:LCMapStringW
    mov     esi, eax
    test    esi, esi
    jz      loc_4EE728
    test    ebp, 400h
    jz      short loc_4EE6AC
    mov     eax, [esp+10h+cchDest]
    test    eax, eax
    jz      short loc_4EE68F
    cmp     esi, eax
    jg      loc_4EE728
    mov     ecx, [esp+10h+Locale]
    push    eax                             ; cchDest
    mov     eax, [esp+14h+lpDestStr]
    push    eax                             ; lpDestStr
    push    edi                             ; cchSrc
    push    ebx                             ; lpSrcStr
    push    ebp                             ; dwMapFlags
    push    ecx                             ; Locale
    call    ds:LCMapStringW
    test    eax, eax
    jz      loc_4EE728

    loc_4EE68F:                             ; CODE XREF: sub_4EE520+149j
                                            ; sub_4EE520+1E0j ...
    push    ebx                             ; void *
    call    _free
    mov     edx, [esp+14h+lpWideCharStr]
    add     esp, 4
    push    edx                             ; void *
    call    _free
    add     esp, 4
    mov     eax, esi

    loc_4EE6A7:                             ; CODE XREF: sub_4EE520+A4j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4EE6AC:                             ; CODE XREF: sub_4EE520+141j
    lea     edx, [esi+esi]
    push    edx                             ; size_t
    call    _malloc
    add     esp, 4
    mov     [esp+10h+lpWideCharStr], eax
    test    eax, eax
    jz      short loc_4EE728
    mov     ecx, [esp+10h+Locale]
    push    esi                             ; cchDest
    push    eax                             ; lpDestStr
    push    edi                             ; cchSrc
    push    ebx                             ; lpSrcStr
    push    ebp                             ; dwMapFlags
    push    ecx                             ; Locale
    call    ds:LCMapStringW
    test    eax, eax
    jz      short loc_4EE728
    mov     eax, [esp+10h+cchDest]
    push    0                               ; lpUsedDefaultChar
    test    eax, eax
    push    0                               ; lpDefaultChar
    jnz     short loc_4EE702
    mov     edx, [esp+18h+lpWideCharStr]
    mov     eax, [esp+18h+CodePage]
    push    0                               ; cchMultiByte
    push    0                               ; lpMultiByteStr
    push    esi                             ; cchWideChar
    push    edx                             ; lpWideCharStr
    push    220h                            ; dwFlags
    push    eax                             ; CodePage
    call    ds:WideCharToMultiByte
    mov     esi, eax
    test    esi, esi
    jz      short loc_4EE728
    jmp     short loc_4EE68F                ; lpDefaultChar
    ; ---------------------------------------------------------------------------

    loc_4EE702:                             ; CODE XREF: sub_4EE520+1BEj
    mov     ecx, [esp+18h+lpDestStr]
    mov     edx, [esp+18h+lpWideCharStr]
    push    eax                             ; cchMultiByte
    mov     eax, [esp+1Ch+CodePage]
    push    ecx                             ; lpMultiByteStr
    push    esi                             ; cchWideChar
    push    edx                             ; lpWideCharStr
    push    220h                            ; dwFlags
    push    eax                             ; CodePage
    call    ds:WideCharToMultiByte
    mov     esi, eax
    test    esi, esi
    jnz     loc_4EE68F

    loc_4EE728:                             ; CODE XREF: sub_4EE520+115j
                                            ; sub_4EE520+135j ...
    push    ebx                             ; void *
    call    _free
    mov     ecx, [esp+14h+lpWideCharStr]
    add     esp, 4
    push    ecx                             ; void *
    call    _free
    add     esp, 4

    loc_4EE73E:                             ; CODE XREF: sub_4EE520+4Cj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    retn
    sub_4EE520 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000002F BYTES: COLLAPSED FUNCTION _strncnt. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [000000EF BYTES: COLLAPSED FUNCTION __filbuf. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000072 BYTES: COLLAPSED FUNCTION __read. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000225 BYTES: COLLAPSED FUNCTION __read_lk. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000072 BYTES: COLLAPSED FUNCTION __write. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000209 BYTES: COLLAPSED FUNCTION __write_lk. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000073 BYTES: COLLAPSED FUNCTION __dosmaperr. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000009 BYTES: COLLAPSED FUNCTION __errno. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000009 BYTES: COLLAPSED FUNCTION ___doserrno. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000020D BYTES: COLLAPSED FUNCTION __XcptFilter. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000003C BYTES: COLLAPSED FUNCTION _xcptlookup. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000032 BYTES: COLLAPSED FUNCTION ___tzset. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000001A BYTES: COLLAPSED FUNCTION __tzset. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000002D8 BYTES: COLLAPSED FUNCTION __tzset_lk. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000028 BYTES: COLLAPSED FUNCTION __isindst. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4EF410 proc near                    ; CODE XREF: __isindst+10p

    arg_0= dword ptr  4

    mov     eax, dword_50E75C
    push    esi
    test    eax, eax
    push    edi
    jnz     short loc_4EF420
    xor     eax, eax
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4EF420:                             ; CODE XREF: sub_4EF410+9j
    mov     esi, [esp+8+arg_0]
    mov     ecx, dword_50E7F0
    mov     eax, [esi+14h]
    cmp     eax, ecx
    jnz     short loc_4EF43D
    cmp     eax, dword_50E800
    jz      loc_4EF5E4

    loc_4EF43D:                             ; CODE XREF: sub_4EF410+1Fj
    mov     ecx, dword_52A038
    test    ecx, ecx
    jz      loc_4EF5A7
    cmp     stru_52A040.DaylightDate.wYear, 0
    jnz     short loc_4EF4AB
    mov     edx, dword ptr stru_52A040.DaylightDate.wSecond
    xor     ecx, ecx
    mov     cx, stru_52A040.DaylightDate.wMilliseconds
    and     edx, 0FFFFh
    push    ecx
    xor     ecx, ecx
    mov     cx, stru_52A040.DaylightDate.wMinute
    push    edx
    mov     edx, dword ptr stru_52A040.DaylightDate.wHour
    push    ecx
    mov     ecx, dword ptr stru_52A040.DaylightDate.wDayOfWeek
    and     edx, 0FFFFh
    push    edx
    and     ecx, 0FFFFh
    push    0
    push    ecx
    xor     edx, edx
    xor     ecx, ecx
    mov     dx, stru_52A040.DaylightDate.wDay
    mov     cx, stru_52A040.DaylightDate.wMonth
    push    edx
    push    ecx
    push    eax
    push    1
    jmp     short loc_4EF4F4
    ; ---------------------------------------------------------------------------

    loc_4EF4AB:                             ; CODE XREF: sub_4EF410+43j
    mov     ecx, dword ptr stru_52A040.DaylightDate.wSecond
    xor     edx, edx
    mov     dx, stru_52A040.DaylightDate.wMilliseconds
    and     ecx, 0FFFFh
    push    edx
    xor     edx, edx
    mov     dx, stru_52A040.DaylightDate.wMinute
    push    ecx
    mov     ecx, dword ptr stru_52A040.DaylightDate.wHour
    push    edx
    and     ecx, 0FFFFh
    xor     edx, edx
    mov     dx, stru_52A040.DaylightDate.wDay
    push    ecx
    xor     ecx, ecx
    push    edx
    mov     cx, stru_52A040.DaylightDate.wMonth
    push    0
    push    0
    push    ecx
    push    eax
    push    0

    loc_4EF4F4:                             ; CODE XREF: sub_4EF410+99j
    push    1
    call    _cvtdate
    add     esp, 2Ch
    cmp     stru_52A040.StandardDate.wYear, 0
    jnz     short loc_4EF55B
    mov     eax, dword ptr stru_52A040.StandardDate.wSecond
    xor     edx, edx
    mov     dx, stru_52A040.StandardDate.wMilliseconds
    and     eax, 0FFFFh
    push    edx
    mov     edx, dword ptr stru_52A040.StandardDate.wHour
    xor     ecx, ecx
    push    eax
    mov     cx, stru_52A040.StandardDate.wMinute
    mov     eax, dword ptr stru_52A040.StandardDate.wDayOfWeek
    and     edx, 0FFFFh
    push    ecx
    push    edx
    and     eax, 0FFFFh
    xor     ecx, ecx
    xor     edx, edx
    mov     cx, stru_52A040.StandardDate.wDay
    mov     dx, stru_52A040.StandardDate.wMonth
    push    0
    push    eax
    mov     eax, [esi+14h]
    push    ecx
    push    edx
    push    eax
    jmp     short loc_4EF5D8
    ; ---------------------------------------------------------------------------

    loc_4EF55B:                             ; CODE XREF: sub_4EF410+F6j
    mov     edx, dword ptr stru_52A040.StandardDate.wSecond
    xor     ecx, ecx
    mov     cx, stru_52A040.StandardDate.wMilliseconds
    and     edx, 0FFFFh
    push    ecx
    mov     ecx, dword ptr stru_52A040.StandardDate.wHour
    xor     eax, eax
    push    edx
    mov     ax, stru_52A040.StandardDate.wMinute
    xor     edx, edx
    mov     dx, stru_52A040.StandardDate.wDay
    and     ecx, 0FFFFh
    push    eax
    push    ecx
    mov     ecx, [esi+14h]
    xor     eax, eax
    mov     ax, stru_52A040.StandardDate.wMonth
    push    edx
    push    0
    push    0
    push    eax
    push    ecx
    push    0
    jmp     short loc_4EF5DA
    ; ---------------------------------------------------------------------------

    loc_4EF5A7:                             ; CODE XREF: sub_4EF410+35j
    push    0
    push    0
    push    0
    push    2
    push    0
    push    0
    push    1
    push    4
    push    eax
    push    1
    push    1
    call    _cvtdate
    add     esp, 2Ch
    mov     edx, [esi+14h]
    push    0
    push    0
    push    0
    push    2
    push    0
    push    0
    push    5
    push    0Ah
    push    edx

    loc_4EF5D8:                             ; CODE XREF: sub_4EF410+149j
    push    1

    loc_4EF5DA:                             ; CODE XREF: sub_4EF410+195j
    push    0
    call    _cvtdate
    add     esp, 2Ch

    loc_4EF5E4:                             ; CODE XREF: sub_4EF410+27j
    mov     edx, dword_50E7F4
    mov     eax, dword_50E804
    mov     ecx, [esi+1Ch]
    cmp     edx, eax
    jge     short loc_4EF60E
    cmp     ecx, edx
    jl      short loc_4EF61E
    cmp     ecx, eax
    jg      short loc_4EF61E
    cmp     ecx, edx
    jle     short loc_4EF623
    cmp     ecx, eax
    jge     short loc_4EF623
    mov     eax, 1
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4EF60E:                             ; CODE XREF: sub_4EF410+1E4j
    cmp     ecx, eax
    jl      short loc_4EF671
    cmp     ecx, edx
    jg      short loc_4EF671
    cmp     ecx, eax
    jle     short loc_4EF623
    cmp     ecx, edx
    jge     short loc_4EF623

    loc_4EF61E:                             ; CODE XREF: sub_4EF410+1E8j
                                            ; sub_4EF410+1ECj
    xor     eax, eax
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4EF623:                             ; CODE XREF: sub_4EF410+1F0j
                                            ; sub_4EF410+1F4j ...
    mov     eax, [esi+8]
    mov     edi, [esi+4]
    mov     esi, [esi]
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*4]
    lea     eax, [edi+eax*4]
    lea     eax, [eax+eax*2]
    lea     eax, [eax+eax*4]
    lea     eax, [esi+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    lea     eax, [eax+eax*4]
    shl     eax, 3
    cmp     ecx, edx
    jnz     short loc_4EF65F
    mov     edx, dword_50E7F8
    xor     ecx, ecx
    cmp     eax, edx
    setnl   cl
    mov     eax, ecx
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4EF65F:                             ; CODE XREF: sub_4EF410+23Bj
    mov     ecx, dword_50E808
    xor     edx, edx
    cmp     eax, ecx
    setl    dl
    mov     eax, edx
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4EF671:                             ; CODE XREF: sub_4EF410+200j
                                            ; sub_4EF410+204j
    pop     edi
    mov     eax, 1
    pop     esi
    retn
    sub_4EF410 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [0000019C BYTES: COLLAPSED FUNCTION _cvtdate. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000E2 BYTES: COLLAPSED FUNCTION ___loctotime_t. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4EF910 proc near                    ; CODE XREF: _sscanf+35p

    var_1CD= byte ptr -1CDh
    var_1CC= dword ptr -1CCh
    var_1C7= byte ptr -1C7h
    var_1C6= byte ptr -1C6h
    var_1C5= byte ptr -1C5h
    var_1C4= dword ptr -1C4h
    var_1C0= byte ptr -1C0h
    var_1BF= byte ptr -1BFh
    var_1BE= byte ptr -1BEh
    var_1BD= byte ptr -1BDh
    var_1BC= dword ptr -1BCh
    var_1B8= dword ptr -1B8h
    var_1B4= dword ptr -1B4h
    var_1B0= dword ptr -1B0h
    var_1AC= dword ptr -1ACh
    var_1A8= dword ptr -1A8h
    var_1A4= dword ptr -1A4h
    var_19E= byte ptr -19Eh
    var_19C= dword ptr -19Ch
    var_198= dword ptr -198h
    var_194= dword ptr -194h
    var_18E= word ptr -18Eh
    var_188= dword ptr -188h
    var_184= dword ptr -184h
    var_180= dword ptr -180h
    var_175= byte ptr -175h
    var_160= dword ptr -160h
    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    sub     esp, 1D0h
    xor     eax, eax
    push    ebx
    mov     [esp+1D4h+var_1BF], al
    mov     [esp+1D4h+var_1CC], eax
    mov     [esp+1D4h+var_1AC], eax
    mov     eax, [esp+1D4h+arg_4]
    push    ebp
    push    esi
    mov     al, [eax]
    push    edi
    test    al, al
    jz      loc_4F0562
    mov     ebp, [esp+1E0h+arg_0]
    mov     ebx, [esp+54h]
    mov     esi, [esp+1E0h+arg_4]
    xor     edi, edi

    loc_4EF94D:                             ; CODE XREF: sub_4EF910+C22j
    cmp     cchMultiByte, 1
    jle     short loc_4EF968
    and     eax, 0FFh
    push    8                               ; int
    push    eax                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4EF979
    ; ---------------------------------------------------------------------------

    loc_4EF968:                             ; CODE XREF: sub_4EF910+44j
    mov     ecx, dword_50E020
    and     eax, 0FFh
    mov     al, [ecx+eax*2]
    and     eax, 8

    loc_4EF979:                             ; CODE XREF: sub_4EF910+56j
    cmp     eax, edi
    jz      short loc_4EF9D0
    mov     eax, [esp+1E0h+var_1CC]
    push    ebp
    lea     edx, [esp+1E4h+var_1CC]
    dec     eax
    push    ebp
    push    edx
    mov     [esp+1ECh+var_1CC], eax
    call    __whiteout
    add     esp, 8
    push    eax
    call    __un_inc
    add     esp, 8
    inc     esi
    xor     eax, eax
    mov     [esp+1E0h+arg_4], esi
    mov     al, [esi]
    push    eax                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jz      short loc_4EF9D0

    loc_4EF9B7:                             ; CODE XREF: sub_4EF910+BEj
    inc     esi
    xor     ecx, ecx
    mov     [esp+1E0h+arg_4], esi
    mov     cl, [esi]
    push    ecx                             ; int
    call    _isspace
    add     esp, 4
    test    eax, eax
    jnz     short loc_4EF9B7

    loc_4EF9D0:                             ; CODE XREF: sub_4EF910+6Bj
                                            ; sub_4EF910+A5j
    cmp     byte ptr [esi], 25h
    jnz     loc_4F04B7
    mov     ecx, [esp+1E0h+arg_4]
    mov     [esp+1E0h+var_1A4], edi
    mov     byte ptr [esp+1E0h+var_1B4], 0
    mov     [esp+1E0h+var_1A8], edi
    mov     [esp+1E0h+var_1B0], edi
    mov     [esp+1E0h+var_1C4], edi
    mov     [esp+1E0h+var_1BD], 0
    mov     [esp+1E0h+var_1BE], 0
    mov     [esp+1E0h+var_1C5], 0
    mov     [esp+1E0h+var_1CD], 0
    mov     [esp+1E0h+var_1C0], 0
    mov     [esp+1E0h+var_1C7], 0
    mov     [esp+1E0h+var_1C6], 1
    mov     [esp+1E0h+var_188], edi

    loc_4EFA1C:                             ; CODE XREF: sub_4EF910+1E0j
    mov     eax, cchMultiByte
    inc     ecx
    xor     edx, edx
    cmp     eax, 1
    mov     dl, [ecx]
    mov     [esp+1E0h+arg_4], ecx
    mov     esi, edx
    jle     short loc_4EFA4F
    mov     eax, esi
    push    4                               ; int
    and     eax, 0FFh
    push    eax                             ; int
    call    __isctype
    mov     ecx, [esp+1E8h+arg_4]
    add     esp, 8
    jmp     short loc_4EFA62
    ; ---------------------------------------------------------------------------

    loc_4EFA4F:                             ; CODE XREF: sub_4EF910+122j
    mov     eax, dword_50E020
    mov     edx, esi
    and     edx, 0FFh
    mov     al, [eax+edx*2]
    and     eax, 4

    loc_4EFA62:                             ; CODE XREF: sub_4EF910+13Dj
    test    eax, eax
    jz      short loc_4EFA80
    mov     eax, [esp+1E0h+var_1B0]
    inc     eax
    mov     [esp+1E0h+var_1B0], eax
    mov     eax, [esp+1E0h+var_1C4]
    lea     edx, [eax+eax*4]
    lea     eax, [esi+edx*2-30h]
    mov     [esp+1E0h+var_1C4], eax
    jmp     short loc_4EFAEA
    ; ---------------------------------------------------------------------------

    loc_4EFA80:                             ; CODE XREF: sub_4EF910+154j
    lea     eax, [esi-2Ah]
    cmp     eax, 4Dh
    ja      short loc_4EFAE6
    xor     edx, edx
    mov     dl, ds:byte_4F05B0[eax]
    jmp     ds:off_4F058C[edx*4]

    loc_4EFA97:                             ; DATA XREF: .text:004F05A0o
    mov     dl, [esp+1E0h+var_1C6]
    mov     al, [esp+1E0h+var_1C7]
    dec     dl
    dec     al
    mov     [esp+1E0h+var_1C6], dl
    mov     [esp+1E0h+var_1C7], al
    jmp     short loc_4EFAEA
    ; ---------------------------------------------------------------------------

    loc_4EFAAD:                             ; CODE XREF: sub_4EF910+180j
                                            ; DATA XREF: .text:004F0594o
    cmp     byte ptr [ecx+1], 36h
    jnz     short loc_4EFAE6
    cmp     byte ptr [ecx+2], 34h
    jnz     short loc_4EFAE6
    add     ecx, 2
    inc     edi
    xor     eax, eax
    mov     [esp+1E0h+arg_4], ecx
    mov     [esp+1E0h+var_19C], eax
    mov     [esp+1E0h+var_198], eax
    jmp     short loc_4EFAEA
    ; ---------------------------------------------------------------------------

    loc_4EFAD0:                             ; CODE XREF: sub_4EF910+180j
                                            ; DATA XREF: .text:004F0598o
    inc     [esp+1E0h+var_1C6]
    jmp     short loc_4EFAEA
    ; ---------------------------------------------------------------------------

    loc_4EFAD6:                             ; CODE XREF: sub_4EF910+180j
                                            ; DATA XREF: .text:004F05A4o
    inc     [esp+1E0h+var_1C6]

    loc_4EFADA:                             ; CODE XREF: sub_4EF910+180j
                                            ; DATA XREF: .text:004F05A8o
    inc     [esp+1E0h+var_1C7]
    jmp     short loc_4EFAEA
    ; ---------------------------------------------------------------------------

    loc_4EFAE0:                             ; CODE XREF: sub_4EF910+180j
                                            ; DATA XREF: .text:004F058Co
    inc     [esp+1E0h+var_1C5]
    jmp     short loc_4EFAEA
    ; ---------------------------------------------------------------------------

    loc_4EFAE6:                             ; CODE XREF: sub_4EF910+176j
                                            ; sub_4EF910+180j ...
    inc     [esp+1E0h+var_1CD]

    loc_4EFAEA:                             ; CODE XREF: sub_4EF910+16Ej
                                            ; sub_4EF910+180j ...
    mov     al, [esp+1E0h+var_1CD]
    test    al, al
    jz      loc_4EFA1C
    mov     al, [esp+1E0h+var_1C5]
    mov     [esp+1E0h+var_188], edi
    test    al, al
    jnz     short loc_4EFB1E
    mov     eax, [esp+1E0h+arg_8]
    mov     [esp+54h], eax
    add     eax, 4
    mov     [esp+1E0h+arg_8], eax
    mov     eax, [eax-4]
    mov     [esp+1E0h+var_1B8], eax

    loc_4EFB1E:                             ; CODE XREF: sub_4EF910+1F0j
    mov     al, [esp+1E0h+var_1C7]
    mov     [esp+1E0h+var_1CD], 0
    test    al, al
    jnz     short loc_4EFB3F
    mov     al, [ecx]
    cmp     al, 53h
    jz      short loc_4EFB3A
    cmp     al, 43h
    mov     [esp+1E0h+var_1C7], 0FFh
    jnz     short loc_4EFB3F

    loc_4EFB3A:                             ; CODE XREF: sub_4EF910+21Fj
    mov     [esp+1E0h+var_1C7], 1

    loc_4EFB3F:                             ; CODE XREF: sub_4EF910+219j
                                            ; sub_4EF910+228j
    xor     eax, eax
    mov     al, [ecx]
    or      al, 20h
    cmp     eax, 6Eh
    mov     [esp+1E0h+var_1BC], eax
    jz      short loc_4EFB7C
    cmp     eax, 63h
    jz      short loc_4EFB68
    cmp     eax, 7Bh
    jz      short loc_4EFB68
    lea     ecx, [esp+1E0h+var_1CC]
    push    ebp
    push    ecx
    call    __whiteout
    add     esp, 8
    jmp     short loc_4EFB7A
    ; ---------------------------------------------------------------------------

    loc_4EFB68:                             ; CODE XREF: sub_4EF910+241j
                                            ; sub_4EF910+246j
    mov     esi, [esp+1E0h+var_1CC]
    push    ebp
    inc     esi
    mov     [esp+1E4h+var_1CC], esi
    call    _fgetc
    add     esp, 4

    loc_4EFB7A:                             ; CODE XREF: sub_4EF910+256j
    mov     ebx, eax

    loc_4EFB7C:                             ; CODE XREF: sub_4EF910+23Cj
    mov     ecx, [esp+1E0h+var_1B0]
    test    ecx, ecx
    jz      short loc_4EFB90
    mov     eax, [esp+1E0h+var_1C4]
    test    eax, eax
    jz      loc_4F054D

    loc_4EFB90:                             ; CODE XREF: sub_4EF910+272j
    mov     esi, [esp+1E0h+var_1BC]
    lea     eax, [esi-63h]
    cmp     eax, 18h
    ja      loc_4F045F
    xor     edx, edx
    mov     dl, ds:byte_4F0630[eax]
    jmp     ds:off_4F0600[edx*4]

    loc_4EFBAF:                             ; DATA XREF: .text:004F0600o
    test    ecx, ecx
    jnz     short loc_4EFBC4
    mov     eax, [esp+1E0h+var_1C4]
    mov     [esp+1E0h+var_1B0], 1
    inc     eax
    mov     [esp+1E0h+var_1C4], eax

    loc_4EFBC4:                             ; CODE XREF: sub_4EF910+2A1j
    mov     al, [esp+1E0h+var_1C7]
    test    al, al
    jle     short loc_4EFBD1
    mov     [esp+1E0h+var_1C0], 1

    loc_4EFBD1:                             ; CODE XREF: sub_4EF910+2BAj
    mov     edx, offset asc_50E814          ; "]"
    jmp     short loc_4EFC0E
    ; ---------------------------------------------------------------------------

    loc_4EFBD8:                             ; CODE XREF: sub_4EF910+298j
                                            ; DATA XREF: .text:004F061Co
    mov     al, [esp+1E0h+var_1C7]
    test    al, al
    jle     short loc_4EFBE5
    mov     [esp+1E0h+var_1C0], 1

    loc_4EFBE5:                             ; CODE XREF: sub_4EF910+2CEj
    mov     edx, offset asc_50E80C          ; " \t-\r]"
    jmp     short loc_4EFC0E
    ; ---------------------------------------------------------------------------

    loc_4EFBEC:                             ; CODE XREF: sub_4EF910+298j
                                            ; DATA XREF: .text:004F0628o
    mov     al, [esp+1E0h+var_1C7]
    test    al, al
    jle     short loc_4EFBF9
    mov     [esp+1E0h+var_1C0], 1

    loc_4EFBF9:                             ; CODE XREF: sub_4EF910+2E2j
    mov     edx, [esp+1E0h+arg_4]
    inc     edx
    mov     [esp+1E0h+arg_4], edx
    cmp     byte ptr [edx], 5Eh
    jnz     short loc_4EFC13
    inc     edx

    loc_4EFC0E:                             ; CODE XREF: sub_4EF910+2C6j
                                            ; sub_4EF910+2DAj
    mov     [esp+1E0h+var_1BD], 0FFh

    loc_4EFC13:                             ; CODE XREF: sub_4EF910+2FBj
    mov     ecx, 8
    xor     eax, eax
    lea     edi, [esp+1E0h+var_180]
    cmp     esi, 7Bh
    rep stosd
    jnz     short loc_4EFC35
    cmp     byte ptr [edx], 5Dh
    jnz     short loc_4EFC35
    mov     byte ptr [esp+1E0h+var_1B4], 5Dh
    inc     edx
    mov     [esp+1E0h+var_175], 20h

    loc_4EFC35:                             ; CODE XREF: sub_4EF910+313j
                                            ; sub_4EF910+318j
    mov     al, [edx]
    cmp     al, 5Dh
    jz      loc_4EFCE3

    loc_4EFC3F:                             ; CODE XREF: sub_4EF910+3CDj
    mov     cl, al
    inc     edx
    cmp     cl, 2Dh
    mov     byte ptr [esp+1E0h+var_184], cl
    jnz     short loc_4EFCB9
    mov     al, byte ptr [esp+1E0h+var_1B4]
    test    al, al
    jz      short loc_4EFCB9
    mov     al, [edx]
    cmp     al, 5Dh
    jz      short loc_4EFCB9
    mov     cl, byte ptr [esp+1E0h+var_1B4]
    inc     edx
    cmp     cl, al
    jnb     short loc_4EFC68
    mov     byte ptr [esp+1E0h+var_194], al
    jmp     short loc_4EFC72
    ; ---------------------------------------------------------------------------

    loc_4EFC68:                             ; CODE XREF: sub_4EF910+350j
    mov     byte ptr [esp+1E0h+var_194], cl
    mov     byte ptr [esp+1E0h+var_1B4], al
    mov     cl, al

    loc_4EFC72:                             ; CODE XREF: sub_4EF910+356j
    cmp     cl, byte ptr [esp+1E0h+var_194]
    ja      short loc_4EFCAB
    mov     esi, [esp+1E0h+var_1B4]
    mov     ebp, [esp+1E0h+var_194]
    and     esi, 0FFh
    and     ebp, 0FFh
    sub     ebp, esi
    inc     ebp

    loc_4EFC8F:                             ; CODE XREF: sub_4EF910+399j
    mov     eax, esi
    mov     ecx, esi
    shr     eax, 3
    and     ecx, 7
    lea     edi, [esp+eax+1E0h+var_180]
    mov     al, 1
    shl     al, cl
    mov     cl, [edi]
    or      cl, al
    inc     esi
    dec     ebp
    mov     [edi], cl
    jnz     short loc_4EFC8F

    loc_4EFCAB:                             ; CODE XREF: sub_4EF910+366j
    mov     ebp, [esp+1E0h+arg_0]
    mov     byte ptr [esp+1E0h+var_1B4], 0
    jmp     short loc_4EFCD9
    ; ---------------------------------------------------------------------------

    loc_4EFCB9:                             ; CODE XREF: sub_4EF910+339j
                                            ; sub_4EF910+341j ...
    mov     byte ptr [esp+1E0h+var_1B4], cl
    mov     ecx, [esp+1E0h+var_184]
    and     ecx, 0FFh
    mov     eax, ecx
    and     ecx, 7
    shr     eax, 3
    lea     esi, [esp+eax+1E0h+var_180]
    mov     al, 1
    shl     al, cl
    or      [esi], al

    loc_4EFCD9:                             ; CODE XREF: sub_4EF910+3A7j
    mov     al, [edx]
    cmp     al, 5Dh
    jnz     loc_4EFC3F

    loc_4EFCE3:                             ; CODE XREF: sub_4EF910+329j
    cmp     byte ptr [edx], 0
    jz      loc_4F0566
    cmp     [esp+1E0h+var_1BC], 7Bh
    jnz     short loc_4EFCFA
    mov     [esp+1E0h+arg_4], edx

    loc_4EFCFA:                             ; CODE XREF: sub_4EF910+3E1j
    mov     eax, [esp+1E0h+var_1CC]
    mov     edi, [esp+1E0h+var_1B8]
    dec     eax
    push    ebp
    push    ebx
    mov     esi, edi
    mov     [esp+1E8h+var_1CC], eax
    call    __un_inc
    add     esp, 8

    loc_4EFD13:                             ; CODE XREF: sub_4EF910+4BCj
                                            ; sub_4EF910+4C4j ...
    mov     eax, [esp+1E0h+var_1B0]
    test    eax, eax
    jz      short loc_4EFD2E
    mov     eax, [esp+1E0h+var_1C4]
    mov     ecx, eax
    dec     eax
    test    ecx, ecx
    mov     [esp+1E0h+var_1C4], eax
    jz      loc_4EFDF8

    loc_4EFD2E:                             ; CODE XREF: sub_4EF910+409j
    mov     ebx, [esp+1E0h+var_1CC]
    push    ebp
    inc     ebx
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    mov     ebx, eax
    add     esp, 4
    cmp     ebx, 0FFFFFFFFh
    jz      loc_4EFDDF
    mov     ecx, ebx
    mov     edx, 1
    and     ecx, 7
    sar     eax, 3
    shl     edx, cl
    movsx   ecx, byte ptr [esp+eax+1E0h+var_180]
    movsx   eax, [esp+1E0h+var_1BD]
    xor     ecx, eax
    test    ecx, edx
    jz      short loc_4EFDDF
    mov     al, [esp+1E0h+var_1C5]
    test    al, al
    jnz     short loc_4EFDD9
    mov     al, [esp+1E0h+var_1C0]
    test    al, al
    jz      short loc_4EFDD1
    mov     edx, dword_50E020
    mov     ecx, ebx
    and     ecx, 0FFh
    mov     [esp+1E0h+var_19E], bl
    test    byte ptr [edx+ecx*2+1], 80h
    jz      short loc_4EFDA9
    mov     eax, [esp+1E0h+var_1CC]
    push    ebp
    inc     eax
    mov     [esp+1E4h+var_1CC], eax
    call    _fgetc
    add     esp, 4
    mov     [esp+43h], al

    loc_4EFDA9:                             ; CODE XREF: sub_4EF910+481j
    mov     eax, cchMultiByte
    lea     ecx, [esp+1E0h+var_19E]
    push    eax                             ; size_t
    lea     edx, [esp+1E4h+var_18E]
    push    ecx                             ; char *
    push    edx                             ; wchar_t *
    call    _mbtowc
    mov     ax, [esp+1ECh+var_18E]
    add     esp, 0Ch
    mov     [edi], ax
    add     edi, 2
    jmp     loc_4EFD13
    ; ---------------------------------------------------------------------------

    loc_4EFDD1:                             ; CODE XREF: sub_4EF910+468j
    mov     [edi], bl
    inc     edi
    jmp     loc_4EFD13
    ; ---------------------------------------------------------------------------

    loc_4EFDD9:                             ; CODE XREF: sub_4EF910+460j
    inc     esi
    jmp     loc_4EFD13
    ; ---------------------------------------------------------------------------

    loc_4EFDDF:                             ; CODE XREF: sub_4EF910+435j
                                            ; sub_4EF910+458j
    mov     eax, [esp+1E0h+var_1CC]
    push    ebp
    dec     eax
    push    ebx
    mov     [esp+1E8h+var_1B8], edi
    mov     [esp+1E8h+var_1CC], eax
    call    __un_inc
    add     esp, 8
    jmp     short loc_4EFDFC
    ; ---------------------------------------------------------------------------

    loc_4EFDF8:                             ; CODE XREF: sub_4EF910+418j
    mov     [esp+1E0h+var_1B8], edi

    loc_4EFDFC:                             ; CODE XREF: sub_4EF910+4E6j
    cmp     esi, edi
    jz      loc_4F0566
    mov     al, [esp+1E0h+var_1C5]
    test    al, al
    jnz     loc_4F0498
    mov     ecx, [esp+1E0h+var_1AC]
    mov     eax, [esp+1E0h+var_1BC]
    inc     ecx
    cmp     eax, 63h
    mov     [esp+1E0h+var_1AC], ecx
    jz      loc_4F0498
    mov     al, [esp+1E0h+var_1C0]
    test    al, al
    jz      short loc_4EFE3C
    mov     ecx, [esp+1E0h+var_1B8]
    mov     word ptr [ecx], 0
    jmp     loc_4F0498
    ; ---------------------------------------------------------------------------

    loc_4EFE3C:                             ; CODE XREF: sub_4EF910+51Cj
    mov     edx, [esp+1E0h+var_1B8]
    mov     byte ptr [edx], 0
    jmp     loc_4F0498
    ; ---------------------------------------------------------------------------

    loc_4EFE48:                             ; CODE XREF: sub_4EF910+298j
                                            ; DATA XREF: .text:004F060Co
    mov     esi, 64h
    mov     [esp+1E0h+var_1BC], esi

    loc_4EFE51:                             ; CODE XREF: sub_4EF910+298j
                                            ; DATA XREF: .text:004F0624o
    cmp     ebx, 2Dh
    jnz     short loc_4EFE5D
    mov     [esp+1E0h+var_1BE], 1
    jmp     short loc_4EFE62
    ; ---------------------------------------------------------------------------

    loc_4EFE5D:                             ; CODE XREF: sub_4EF910+544j
    cmp     ebx, 2Bh
    jnz     short loc_4EFE8C

    loc_4EFE62:                             ; CODE XREF: sub_4EF910+54Bj
    mov     eax, [esp+1E0h+var_1C4]
    dec     eax
    mov     [esp+1E0h+var_1C4], eax
    jnz     short loc_4EFE78
    test    ecx, ecx
    jz      short loc_4EFE78
    mov     [esp+1E0h+var_1CD], 1
    jmp     short loc_4EFE8C
    ; ---------------------------------------------------------------------------

    loc_4EFE78:                             ; CODE XREF: sub_4EF910+55Bj
                                            ; sub_4EF910+55Fj
    mov     ebx, [esp+1E0h+var_1CC]
    push    ebp
    inc     ebx
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    add     esp, 4
    mov     ebx, eax

    loc_4EFE8C:                             ; CODE XREF: sub_4EF910+550j
                                            ; sub_4EF910+566j
    cmp     ebx, 30h
    jnz     loc_4EFF44
    mov     ebx, [esp+1E0h+var_1CC]
    push    ebp
    inc     ebx
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    mov     ebx, eax
    add     esp, 4
    cmp     bl, 78h
    jz      short loc_4EFEE5
    cmp     bl, 58h
    jz      short loc_4EFEE5
    cmp     esi, 78h
    mov     [esp+1E0h+var_1A8], 1
    jz      short loc_4EFECB
    mov     esi, 6Fh
    mov     [esp+1E0h+var_1BC], esi
    jmp     short loc_4EFF44
    ; ---------------------------------------------------------------------------

    loc_4EFECB:                             ; CODE XREF: sub_4EF910+5AEj
    mov     eax, [esp+1E0h+var_1CC]
    push    ebp
    dec     eax
    push    ebx
    mov     [esp+1E8h+var_1CC], eax
    call    __un_inc
    add     esp, 8
    mov     ebx, 30h
    jmp     short loc_4EFF44
    ; ---------------------------------------------------------------------------

    loc_4EFEE5:                             ; CODE XREF: sub_4EF910+59Cj
                                            ; sub_4EF910+5A1j
    mov     esi, [esp+1E0h+var_1CC]
    push    ebp
    inc     esi
    mov     [esp+1E4h+var_1CC], esi
    call    _fgetc
    mov     esi, 78h
    add     esp, 4
    mov     ebx, eax
    mov     [esp+1E0h+var_1BC], esi
    jmp     short loc_4EFF44
    ; ---------------------------------------------------------------------------

    loc_4EFF04:                             ; CODE XREF: sub_4EF910+298j
                                            ; DATA XREF: .text:004F0618o
    mov     [esp+1E0h+var_1C6], 1

    loc_4EFF09:                             ; CODE XREF: sub_4EF910+298j
                                            ; DATA XREF: .text:004F0604o ...
    cmp     ebx, 2Dh
    jnz     short loc_4EFF15
    mov     [esp+1E0h+var_1BE], 1
    jmp     short loc_4EFF1A
    ; ---------------------------------------------------------------------------

    loc_4EFF15:                             ; CODE XREF: sub_4EF910+5FCj
    cmp     ebx, 2Bh
    jnz     short loc_4EFF44

    loc_4EFF1A:                             ; CODE XREF: sub_4EF910+603j
    mov     eax, [esp+1E0h+var_1C4]
    dec     eax
    mov     [esp+1E0h+var_1C4], eax
    jnz     short loc_4EFF30
    test    ecx, ecx
    jz      short loc_4EFF30
    mov     [esp+1E0h+var_1CD], 1
    jmp     short loc_4EFF44
    ; ---------------------------------------------------------------------------

    loc_4EFF30:                             ; CODE XREF: sub_4EF910+613j
                                            ; sub_4EF910+617j
    mov     ebx, [esp+1E0h+var_1CC]
    push    ebp
    inc     ebx
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    add     esp, 4
    mov     ebx, eax

    loc_4EFF44:                             ; CODE XREF: sub_4EF910+57Fj
                                            ; sub_4EF910+5B9j ...
    mov     al, [esp+1E0h+var_1CD]
    test    edi, edi
    jz      loc_4F00A9
    test    al, al
    jnz     loc_4F0081
    mov     ebp, [esp+1E0h+arg_0]
    mov     esi, [esp+1E0h+var_19C]
    mov     edi, [esp+1E0h+var_198]

    loc_4EFF67:                             ; CODE XREF: sub_4EF910+763j
    mov     eax, [esp+1E0h+var_1BC]
    cmp     eax, 78h
    mov     eax, cchMultiByte
    jnz     short loc_4EFFBA
    cmp     eax, 1
    jle     short loc_4EFF8A
    push    80h                             ; int
    push    ebx                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4EFF97
    ; ---------------------------------------------------------------------------

    loc_4EFF8A:                             ; CODE XREF: sub_4EF910+668j
    mov     eax, dword_50E020
    mov     al, [eax+ebx*2]
    and     eax, 80h

    loc_4EFF97:                             ; CODE XREF: sub_4EF910+678j
    test    eax, eax
    jz      short loc_4F000D
    mov     ecx, 4
    mov     eax, esi
    mov     edx, edi
    call    __allshl
    push    ebx
    mov     esi, eax
    mov     edi, edx
    call    __hextodec
    add     esp, 4
    mov     ebx, eax
    jmp     short loc_4F0011
    ; ---------------------------------------------------------------------------

    loc_4EFFBA:                             ; CODE XREF: sub_4EF910+663j
    cmp     eax, 1
    jle     short loc_4EFFCC
    push    4                               ; int
    push    ebx                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4EFFD8
    ; ---------------------------------------------------------------------------

    loc_4EFFCC:                             ; CODE XREF: sub_4EF910+6ADj
    mov     ecx, dword_50E020
    mov     al, [ecx+ebx*2]
    and     eax, 4

    loc_4EFFD8:                             ; CODE XREF: sub_4EF910+6BAj
    test    eax, eax
    jz      short loc_4F000D
    cmp     [esp+1E0h+var_1BC], 6Fh
    jnz     short loc_4EFFFC
    cmp     ebx, 38h
    jge     short loc_4F000D
    mov     ecx, 3
    mov     eax, esi
    mov     edx, edi
    call    __allshl
    mov     esi, eax
    mov     edi, edx
    jmp     short loc_4F0011
    ; ---------------------------------------------------------------------------

    loc_4EFFFC:                             ; CODE XREF: sub_4EF910+6D1j
    push    0
    push    0Ah
    push    edi
    push    esi
    call    __allmul
    mov     esi, eax
    mov     edi, edx
    jmp     short loc_4F0011
    ; ---------------------------------------------------------------------------

    loc_4F000D:                             ; CODE XREF: sub_4EF910+689j
                                            ; sub_4EF910+6CAj ...
    inc     [esp+1E0h+var_1CD]

    loc_4F0011:                             ; CODE XREF: sub_4EF910+6A8j
                                            ; sub_4EF910+6EAj ...
    mov     al, [esp+1E0h+var_1CD]
    test    al, al
    jnz     short loc_4F005A
    mov     edx, [esp+1E0h+var_1A8]
    lea     eax, [ebx-30h]
    inc     edx
    mov     [esp+1E0h+var_1A8], edx
    cdq
    add     esi, eax
    mov     eax, [esp+1E0h+var_1B0]
    adc     edi, edx
    test    eax, eax
    jz      short loc_4F0044
    mov     eax, [esp+1E0h+var_1C4]
    dec     eax
    mov     [esp+1E0h+var_1C4], eax
    jnz     short loc_4F0044
    mov     [esp+1E0h+var_1CD], 1
    jmp     short loc_4F006D
    ; ---------------------------------------------------------------------------

    loc_4F0044:                             ; CODE XREF: sub_4EF910+720j
                                            ; sub_4EF910+72Bj
    mov     ebx, [esp+1E0h+var_1CC]
    push    ebp
    inc     ebx
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    add     esp, 4
    mov     ebx, eax
    jmp     short loc_4F006D
    ; ---------------------------------------------------------------------------

    loc_4F005A:                             ; CODE XREF: sub_4EF910+707j
    mov     eax, [esp+1E0h+var_1CC]
    push    ebp
    dec     eax
    push    ebx
    mov     [esp+1E8h+var_1CC], eax
    call    __un_inc
    add     esp, 8

    loc_4F006D:                             ; CODE XREF: sub_4EF910+732j
                                            ; sub_4EF910+748j
    mov     al, [esp+1E0h+var_1CD]
    test    al, al
    jz      loc_4EFF67
    mov     [esp+1E0h+var_198], edi
    mov     [esp+1E0h+var_19C], esi

    loc_4F0081:                             ; CODE XREF: sub_4EF910+642j
    mov     al, [esp+1E0h+var_1BE]
    test    al, al
    jz      loc_4F01B0
    mov     edx, [esp+1E0h+var_19C]
    mov     eax, [esp+1E0h+var_198]
    neg     edx
    adc     eax, 0
    mov     [esp+1E0h+var_19C], edx
    neg     eax
    mov     [esp+1E0h+var_198], eax
    jmp     loc_4F01B0
    ; ---------------------------------------------------------------------------

    loc_4F00A9:                             ; CODE XREF: sub_4EF910+63Aj
    mov     edi, [esp+1E0h+var_1A4]
    test    al, al
    jnz     loc_4F01A2

    loc_4F00B5:                             ; CODE XREF: sub_4EF910+888j
    cmp     esi, 78h
    jz      short loc_4F00FB
    cmp     esi, 70h
    jz      short loc_4F00FB
    cmp     cchMultiByte, 1
    jle     short loc_4F00D5
    push    4                               ; int
    push    ebx                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4F00E1
    ; ---------------------------------------------------------------------------

    loc_4F00D5:                             ; CODE XREF: sub_4EF910+7B6j
    mov     ecx, dword_50E020
    mov     al, [ecx+ebx*2]
    and     eax, 4

    loc_4F00E1:                             ; CODE XREF: sub_4EF910+7C3j
    test    eax, eax
    jz      short loc_4F0136
    cmp     esi, 6Fh
    jnz     short loc_4F00F4
    cmp     ebx, 38h
    jge     short loc_4F0136
    shl     edi, 3
    jmp     short loc_4F013A
    ; ---------------------------------------------------------------------------

    loc_4F00F4:                             ; CODE XREF: sub_4EF910+7D8j
    lea     edi, [edi+edi*4]
    shl     edi, 1
    jmp     short loc_4F013A
    ; ---------------------------------------------------------------------------

    loc_4F00FB:                             ; CODE XREF: sub_4EF910+7A8j
                                            ; sub_4EF910+7ADj
    cmp     cchMultiByte, 1
    jle     short loc_4F0114
    push    80h                             ; int
    push    ebx                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4F0122
    ; ---------------------------------------------------------------------------

    loc_4F0114:                             ; CODE XREF: sub_4EF910+7F2j
    mov     edx, dword_50E020
    mov     al, [edx+ebx*2]
    and     eax, 80h

    loc_4F0122:                             ; CODE XREF: sub_4EF910+802j
    test    eax, eax
    jz      short loc_4F0136
    push    ebx
    shl     edi, 4
    call    __hextodec
    add     esp, 4
    mov     ebx, eax
    jmp     short loc_4F013A
    ; ---------------------------------------------------------------------------

    loc_4F0136:                             ; CODE XREF: sub_4EF910+7D3j
                                            ; sub_4EF910+7DDj ...
    inc     [esp+1E0h+var_1CD]

    loc_4F013A:                             ; CODE XREF: sub_4EF910+7E2j
                                            ; sub_4EF910+7E9j ...
    mov     al, [esp+1E0h+var_1CD]
    test    al, al
    jnz     short loc_4F017F
    mov     ecx, [esp+1E0h+var_1A8]
    mov     eax, [esp+1E0h+var_1B0]
    inc     ecx
    lea     edi, [edi+ebx-30h]
    test    eax, eax
    mov     [esp+1E0h+var_1A8], ecx
    jz      short loc_4F0169
    mov     eax, [esp+1E0h+var_1C4]
    dec     eax
    mov     [esp+1E0h+var_1C4], eax
    jnz     short loc_4F0169
    mov     [esp+1E0h+var_1CD], 1
    jmp     short loc_4F0192
    ; ---------------------------------------------------------------------------

    loc_4F0169:                             ; CODE XREF: sub_4EF910+845j
                                            ; sub_4EF910+850j
    mov     ebx, [esp+1E0h+var_1CC]
    push    ebp
    inc     ebx
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    add     esp, 4
    mov     ebx, eax
    jmp     short loc_4F0192
    ; ---------------------------------------------------------------------------

    loc_4F017F:                             ; CODE XREF: sub_4EF910+830j
    mov     eax, [esp+1E0h+var_1CC]
    push    ebp
    dec     eax
    push    ebx
    mov     [esp+1E8h+var_1CC], eax
    call    __un_inc
    add     esp, 8

    loc_4F0192:                             ; CODE XREF: sub_4EF910+857j
                                            ; sub_4EF910+86Dj
    mov     al, [esp+1E0h+var_1CD]
    test    al, al
    jz      loc_4F00B5
    mov     [esp+1E0h+var_1A4], edi

    loc_4F01A2:                             ; CODE XREF: sub_4EF910+79Fj
    mov     al, [esp+1E0h+var_1BE]
    test    al, al
    jz      short loc_4F01B0
    neg     edi
    mov     [esp+1E0h+var_1A4], edi

    loc_4F01B0:                             ; CODE XREF: sub_4EF910+777j
                                            ; sub_4EF910+794j ...
    cmp     [esp+1E0h+var_1BC], 46h
    jnz     short loc_4F01BB
    xor     eax, eax
    jmp     short loc_4F01BF
    ; ---------------------------------------------------------------------------

    loc_4F01BB:                             ; CODE XREF: sub_4EF910+8A5j
    mov     eax, [esp+1E0h+var_1A8]

    loc_4F01BF:                             ; CODE XREF: sub_4EF910+8A9j
    test    eax, eax
    jz      loc_4F0566
    mov     al, [esp+1E0h+var_1C5]
    test    al, al
    jnz     loc_4F0491
    mov     eax, [esp+1E0h+var_1AC]
    mov     ebp, [esp+1E0h+arg_0]
    mov     ecx, [esp+1E0h+var_1B8]
    mov     edi, [esp+1E0h+var_188]
    inc     eax
    mov     [esp+1E0h+var_1AC], eax
    mov     eax, [esp+1E0h+var_1A4]
    jmp     short loc_4F0205
    ; ---------------------------------------------------------------------------

    loc_4F01F1:                             ; CODE XREF: sub_4EF910+298j
                                            ; DATA XREF: .text:004F0610o
    mov     cl, [esp+1E0h+var_1C5]
    mov     eax, [esp+1E0h+var_1CC]
    test    cl, cl
    jnz     loc_4F0498
    mov     ecx, [esp+1E0h+var_1B8]

    loc_4F0205:                             ; CODE XREF: sub_4EF910+8DFj
    test    edi, edi
    jz      short loc_4F021B
    mov     eax, [esp+1E0h+var_19C]
    mov     edx, [esp+1E0h+var_198]
    mov     [ecx], eax
    mov     [ecx+4], edx
    jmp     loc_4F0498
    ; ---------------------------------------------------------------------------

    loc_4F021B:                             ; CODE XREF: sub_4EF910+8F7j
    mov     dl, [esp+1E0h+var_1C6]
    test    dl, dl
    jz      short loc_4F022A
    mov     [ecx], eax
    jmp     loc_4F0498
    ; ---------------------------------------------------------------------------

    loc_4F022A:                             ; CODE XREF: sub_4EF910+911j
    mov     [ecx], ax
    jmp     loc_4F0498
    ; ---------------------------------------------------------------------------

    loc_4F0232:                             ; CODE XREF: sub_4EF910+298j
                                            ; DATA XREF: .text:004F0608o
    cmp     ebx, 2Dh
    lea     esi, [esp+1E0h+var_160]
    jnz     short loc_4F024E
    mov     byte ptr [esp+1E0h+var_160], bl
    lea     esi, [esp+1E0h+var_160+1]
    jmp     short loc_4F0253
    ; ---------------------------------------------------------------------------

    loc_4F024E:                             ; CODE XREF: sub_4EF910+92Cj
    cmp     ebx, 2Bh
    jnz     short loc_4F0270

    loc_4F0253:                             ; CODE XREF: sub_4EF910+93Cj
    mov     ebx, [esp+1E0h+var_1C4]
    mov     edi, [esp+1E0h+var_1CC]
    dec     ebx
    inc     edi
    push    ebp
    mov     [esp+1E4h+var_1C4], ebx
    mov     [esp+1E4h+var_1CC], edi
    call    _fgetc
    add     esp, 4
    mov     ebx, eax

    loc_4F0270:                             ; CODE XREF: sub_4EF910+941j
    mov     eax, [esp+1E0h+var_1B0]
    test    eax, eax
    jz      short loc_4F0282
    cmp     [esp+1E0h+var_1C4], 15Dh
    jle     short loc_4F028A

    loc_4F0282:                             ; CODE XREF: sub_4EF910+966j
    mov     [esp+1E0h+var_1C4], 15Dh

    loc_4F028A:                             ; CODE XREF: sub_4EF910+970j
    mov     edi, [esp+1E0h+var_1A8]

    loc_4F028E:                             ; CODE XREF: sub_4EF910+9CAj
    cmp     cchMultiByte, 1
    jle     short loc_4F02A4
    push    4                               ; int
    push    ebx                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4F02AF
    ; ---------------------------------------------------------------------------

    loc_4F02A4:                             ; CODE XREF: sub_4EF910+985j
    mov     eax, dword_50E020
    mov     al, [eax+ebx*2]
    and     eax, 4

    loc_4F02AF:                             ; CODE XREF: sub_4EF910+992j
    test    eax, eax
    jz      short loc_4F02DC
    mov     eax, [esp+1E0h+var_1C4]
    mov     ecx, eax
    dec     eax
    test    ecx, ecx
    mov     [esp+1E0h+var_1C4], eax
    jz      short loc_4F02DC
    mov     [esi], bl
    mov     ebx, [esp+1E0h+var_1CC]
    inc     edi
    inc     esi
    inc     ebx
    push    ebp
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    add     esp, 4
    mov     ebx, eax
    jmp     short loc_4F028E
    ; ---------------------------------------------------------------------------

    loc_4F02DC:                             ; CODE XREF: sub_4EF910+9A1j
                                            ; sub_4EF910+9B0j
    cmp     byte_50E230, bl
    jnz     short loc_4F035E
    mov     eax, [esp+1E0h+var_1C4]
    mov     edx, eax
    dec     eax
    test    edx, edx
    mov     [esp+1E0h+var_1C4], eax
    jz      short loc_4F035E
    mov     ebx, [esp+1E0h+var_1CC]
    push    ebp
    inc     ebx
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    mov     ebx, eax
    mov     al, byte_50E230
    add     esp, 4
    mov     [esi], al
    inc     esi

    loc_4F030F:                             ; CODE XREF: sub_4EF910+A4Cj
    cmp     cchMultiByte, 1
    jle     short loc_4F0325
    push    4                               ; int
    push    ebx                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4F0331
    ; ---------------------------------------------------------------------------

    loc_4F0325:                             ; CODE XREF: sub_4EF910+A06j
    mov     ecx, dword_50E020
    mov     al, [ecx+ebx*2]
    and     eax, 4

    loc_4F0331:                             ; CODE XREF: sub_4EF910+A13j
    test    eax, eax
    jz      short loc_4F035E
    mov     eax, [esp+1E0h+var_1C4]
    mov     edx, eax
    dec     eax
    test    edx, edx
    mov     [esp+1E0h+var_1C4], eax
    jz      short loc_4F035E
    mov     [esi], bl
    mov     ebx, [esp+1E0h+var_1CC]
    inc     edi
    inc     esi
    inc     ebx
    push    ebp
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    add     esp, 4
    mov     ebx, eax
    jmp     short loc_4F030F
    ; ---------------------------------------------------------------------------

    loc_4F035E:                             ; CODE XREF: sub_4EF910+9D2j
                                            ; sub_4EF910+9E1j ...
    test    edi, edi
    jz      loc_4F0411
    cmp     ebx, 65h
    jz      short loc_4F0374
    cmp     ebx, 45h
    jnz     loc_4F0411

    loc_4F0374:                             ; CODE XREF: sub_4EF910+A59j
    mov     eax, [esp+1E0h+var_1C4]
    mov     ecx, eax
    dec     eax
    test    ecx, ecx
    mov     [esp+1E0h+var_1C4], eax
    jz      loc_4F0411
    mov     ebx, [esp+1E0h+var_1CC]
    mov     byte ptr [esi], 65h
    inc     esi
    inc     ebx
    push    ebp
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    mov     ebx, eax
    add     esp, 4
    cmp     ebx, 2Dh
    jnz     short loc_4F03A9
    mov     [esi], al
    inc     esi
    jmp     short loc_4F03AE
    ; ---------------------------------------------------------------------------

    loc_4F03A9:                             ; CODE XREF: sub_4EF910+A92j
    cmp     ebx, 2Bh
    jnz     short loc_4F03D7

    loc_4F03AE:                             ; CODE XREF: sub_4EF910+A97j
    mov     eax, [esp+1E0h+var_1C4]
    mov     edx, eax
    dec     eax
    test    edx, edx
    mov     [esp+1E0h+var_1C4], eax
    jnz     short loc_4F03C3
    mov     [esp+1E0h+var_1C4], edx
    jmp     short loc_4F03D7
    ; ---------------------------------------------------------------------------

    loc_4F03C3:                             ; CODE XREF: sub_4EF910+AABj
                                            ; sub_4EF910+AFFj
    mov     ebx, [esp+1E0h+var_1CC]
    push    ebp
    inc     ebx
    mov     [esp+1E4h+var_1CC], ebx
    call    _fgetc
    add     esp, 4
    mov     ebx, eax

    loc_4F03D7:                             ; CODE XREF: sub_4EF910+A9Cj
                                            ; sub_4EF910+AB1j
    cmp     cchMultiByte, 1
    jle     short loc_4F03ED
    push    4                               ; int
    push    ebx                             ; int
    call    __isctype
    add     esp, 8
    jmp     short loc_4F03F8
    ; ---------------------------------------------------------------------------

    loc_4F03ED:                             ; CODE XREF: sub_4EF910+ACEj
    mov     eax, dword_50E020
    mov     al, [eax+ebx*2]
    and     eax, 4

    loc_4F03F8:                             ; CODE XREF: sub_4EF910+ADBj
    test    eax, eax
    jz      short loc_4F0411
    mov     eax, [esp+1E0h+var_1C4]
    mov     ecx, eax
    dec     eax
    test    ecx, ecx
    mov     [esp+1E0h+var_1C4], eax
    jz      short loc_4F0411
    inc     edi
    mov     [esi], bl
    inc     esi
    jmp     short loc_4F03C3
    ; ---------------------------------------------------------------------------

    loc_4F0411:                             ; CODE XREF: sub_4EF910+A50j
                                            ; sub_4EF910+A5Ej ...
    mov     ecx, [esp+1E0h+var_1CC]
    push    ebp
    dec     ecx
    push    ebx
    mov     [esp+1E8h+var_1CC], ecx
    call    __un_inc
    add     esp, 8
    test    edi, edi
    jz      loc_4F0566
    mov     al, [esp+1E0h+var_1C5]
    test    al, al
    jnz     short loc_4F0498
    mov     ecx, [esp+1E0h+var_1AC]
    mov     eax, [esp+1E0h+var_1B8]
    inc     ecx
    lea     edx, [esp+1E0h+var_160]
    mov     [esp+1E0h+var_1AC], ecx
    push    edx
    movsx   ecx, [esp+1E4h+var_1C6]
    dec     ecx
    push    eax
    push    ecx
    mov     byte ptr [esi], 0
    call    off_50DF50
    add     esp, 0Ch
    jmp     short loc_4F0498
    ; ---------------------------------------------------------------------------

    loc_4F045F:                             ; CODE XREF: sub_4EF910+28Aj
                                            ; sub_4EF910+298j
                                            ; DATA XREF: ...
    mov     eax, [esp+1E0h+arg_4]
    xor     edx, edx
    mov     dl, [eax]
    cmp     edx, ebx
    jnz     loc_4F054D
    mov     cl, [esp+1E0h+var_1BF]
    mov     al, [esp+1E0h+var_1C5]
    dec     cl
    test    al, al
    mov     [esp+1E0h+var_1BF], cl
    jnz     short loc_4F0498
    mov     ecx, [esp+54h]
    mov     [esp+1E0h+arg_8], ecx
    jmp     short loc_4F0498
    ; ---------------------------------------------------------------------------

    loc_4F0491:                             ; CODE XREF: sub_4EF910+8BDj
    mov     ebp, [esp+1E0h+arg_0]

    loc_4F0498:                             ; CODE XREF: sub_4EF910+4FAj
                                            ; sub_4EF910+510j ...
    mov     cl, [esp+1E0h+var_1BF]
    mov     eax, [esp+1E0h+arg_4]
    inc     cl
    inc     eax
    mov     [esp+1E0h+var_1BF], cl
    mov     [esp+1E0h+arg_4], eax
    xor     edi, edi
    mov     esi, eax
    jmp     short loc_4F0513
    ; ---------------------------------------------------------------------------

    loc_4F04B7:                             ; CODE XREF: sub_4EF910+C3j
    mov     eax, [esp+1E0h+var_1CC]
    push    ebp
    inc     eax
    mov     [esp+1E4h+var_1CC], eax
    call    _fgetc
    xor     edx, edx
    add     esp, 4
    mov     dl, [esi]
    mov     ebx, eax
    inc     esi
    cmp     edx, ebx
    mov     [esp+1E0h+arg_4], esi
    jnz     short loc_4F054D
    mov     ecx, dword_50E020
    and     eax, 0FFh
    test    byte ptr [ecx+eax*2+1], 80h
    jz      short loc_4F0513
    mov     ecx, [esp+1E0h+var_1CC]
    push    ebp
    inc     ecx
    mov     [esp+1E4h+var_1CC], ecx
    call    _fgetc
    xor     edx, edx
    add     esp, 4
    mov     dl, [esi]
    inc     esi
    cmp     edx, eax
    mov     [esp+1E0h+arg_4], esi
    jnz     short loc_4F053A
    dec     [esp+1E0h+var_1CC]

    loc_4F0513:                             ; CODE XREF: sub_4EF910+BA5j
                                            ; sub_4EF910+BDBj
    cmp     ebx, 0FFFFFFFFh
    jnz     short loc_4F052E
    cmp     byte ptr [esi], 25h
    jnz     short loc_4F0566
    mov     eax, [esp+1E0h+arg_4]
    cmp     byte ptr [eax+1], 6Eh
    jnz     short loc_4F0566
    xor     edi, edi
    mov     esi, eax

    loc_4F052E:                             ; CODE XREF: sub_4EF910+C06j
    mov     al, [esi]
    test    al, al
    jnz     loc_4EF94D
    jmp     short loc_4F0566
    ; ---------------------------------------------------------------------------

    loc_4F053A:                             ; CODE XREF: sub_4EF910+BFDj
    mov     esi, [esp+1E0h+var_1CC]
    push    ebp
    dec     esi
    push    eax
    mov     [esp+1E8h+var_1CC], esi
    call    __un_inc
    add     esp, 8

    loc_4F054D:                             ; CODE XREF: sub_4EF910+27Aj
                                            ; sub_4EF910+B5Cj ...
    mov     esi, [esp+1E0h+var_1CC]
    push    ebp
    dec     esi
    push    ebx
    mov     [esp+1E8h+var_1CC], esi
    call    __un_inc
    add     esp, 8
    jmp     short loc_4F0566
    ; ---------------------------------------------------------------------------

    loc_4F0562:                             ; CODE XREF: sub_4EF910+23j
    mov     ebx, [esp+54h]

    loc_4F0566:                             ; CODE XREF: sub_4EF910+3D6j
                                            ; sub_4EF910+4EEj ...
    mov     eax, [esp+1E0h+var_1AC]
    cmp     ebx, 0FFFFFFFFh
    jnz     short loc_4F057E
    test    eax, eax
    jnz     short loc_4F057E
    mov     cl, [esp+1E0h+var_1BF]
    test    cl, cl
    jnz     short loc_4F057E
    or      eax, 0FFFFFFFFh

    loc_4F057E:                             ; CODE XREF: sub_4EF910+C5Dj
                                            ; sub_4EF910+C61j ...
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1D0h
    retn
    sub_4EF910 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4F058C dd offset loc_4EFAE0         ; DATA XREF: sub_4EF910+180r
    dd offset loc_4EFAEA
    dd offset loc_4EFAAD
    dd offset loc_4EFAD0
    dd offset loc_4EFAEA
    dd offset loc_4EFA97
    dd offset loc_4EFAD6
    dd offset loc_4EFADA
    dd offset loc_4EFAE6
    byte_4F05B0 db 0                        ; DATA XREF: sub_4EF910+17Ar
    dd 6 dup(8080808h), 1080808h, 8020808h, 4080308h, 6 dup(8080808h), 8080508h
    dd 8080608h, 2 dup(8080808h)
    db 7, 8Bh, 0FFh
    off_4F0600 dd offset loc_4EFBAF         ; DATA XREF: sub_4EF910+298r
    dd offset loc_4EFF09
    dd offset loc_4F0232
    dd offset loc_4EFE48
    dd offset loc_4F01F1
    dd offset loc_4EFF09
    dd offset loc_4EFF04
    dd offset loc_4EFBD8
    dd offset loc_4EFF09
    dd offset loc_4EFE51
    dd offset loc_4EFBEC
    dd offset loc_4F045F
    byte_4F0630 db 0                        ; DATA XREF: sub_4EF910+292r
    ; ---------------------------------------------------------------------------
    add     [edx], eax
    add     al, [edx]
    or      eax, [ebx]
    or      ecx, [ebx]
    or      ecx, [ebx]
    add     al, 5
    push    es
    or      ecx, [ebx]
    pop     es
    or      ecx, [eax]
    or      ecx, [ebx]
    or      [ebx], ecx
    or      ecx, [edx]
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    ; [00000039 BYTES: COLLAPSED FUNCTION __hextodec. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000021 BYTES: COLLAPSED FUNCTION _fgetc. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000018 BYTES: COLLAPSED FUNCTION __un_inc. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000048 BYTES: COLLAPSED FUNCTION __whiteout. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F0730 proc near                    ; CODE XREF: ___initmbctable+2p

    CPInfo= _cpinfo ptr -14h
    arg_0= dword ptr  4

    sub     esp, 14h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    19h
    call    __lock
    mov     eax, [esp+28h+arg_0]
    add     esp, 4
    push    eax
    call    _getSystemCP
    mov     ecx, eax
    mov     eax, lpString1
    add     esp, 4
    cmp     ecx, eax
    mov     [esp+24h+arg_0], ecx
    jnz     short loc_4F0771
    push    19h
    call    __unlock
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F0771:                             ; CODE XREF: sub_4F0730+2Bj
    test    ecx, ecx
    jnz     short loc_4F0793
    call    _setSBCS
    call    sub_4F0A50
    push    19h
    call    __unlock
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F0793:                             ; CODE XREF: sub_4F0730+43j
    xor     edx, edx
    mov     eax, offset dword_50E820

    loc_4F079A:                             ; CODE XREF: sub_4F0730+7Bj
    cmp     [eax], ecx
    jz      loc_4F08B0
    add     eax, 30h
    inc     edx
    cmp     eax, offset dword_50E910
    jb      short loc_4F079A
    lea     edx, [esp+24h+CPInfo]
    push    edx                             ; lpCPInfo
    push    ecx                             ; CodePage
    call    ds:GetCPInfo
    mov     esi, 1
    cmp     eax, esi
    jnz     loc_4F0874
    mov     ecx, 40h
    xor     eax, eax
    mov     edi, offset byte_52A0F8
    rep stosd
    mov     ecx, [esp+24h+CPInfo.MaxCharSize]
    stosb
    mov     edi, [esp+24h+arg_0]
    xor     eax, eax
    cmp     ecx, esi
    mov     lpString1, edi
    mov     dword_52A304, eax
    jbe     short loc_4F085C
    mov     al, [esp+24h+CPInfo.LeadByte]
    test    al, al
    jz      short loc_4F082D
    lea     edx, [esp+24h+CPInfo.LeadByte+1]

    loc_4F07FA:                             ; CODE XREF: sub_4F0730+FBj
    mov     cl, [edx]
    test    cl, cl
    jz      short loc_4F082D
    xor     eax, eax
    and     ecx, 0FFh
    mov     al, [edx-1]
    cmp     eax, ecx
    ja      short loc_4F0823

    loc_4F080F:                             ; CODE XREF: sub_4F0730+F1j
    mov     bl, byte_52A0F9[eax]
    or      bl, 4
    mov     byte_52A0F9[eax], bl
    inc     eax
    cmp     eax, ecx
    jbe     short loc_4F080F

    loc_4F0823:                             ; CODE XREF: sub_4F0730+DDj
    mov     al, [edx+1]
    add     edx, 2
    test    al, al
    jnz     short loc_4F07FA

    loc_4F082D:                             ; CODE XREF: sub_4F0730+C4j
                                            ; sub_4F0730+CEj
    mov     eax, esi

    loc_4F082F:                             ; CODE XREF: sub_4F0730+114j
    mov     bl, byte_52A0F9[eax]
    or      bl, 8
    mov     byte_52A0F9[eax], bl
    inc     eax
    cmp     eax, 0FFh
    jb      short loc_4F082F
    push    edi
    call    _CPtoLCID
    add     esp, 4
    mov     dword_52A304, eax
    mov     dword_52B644, esi
    jmp     short loc_4F0861
    ; ---------------------------------------------------------------------------

    loc_4F085C:                             ; CODE XREF: sub_4F0730+BCj
    mov     dword_52B644, eax

    loc_4F0861:                             ; CODE XREF: sub_4F0730+12Aj
    xor     eax, eax
    mov     dword_52A308, eax
    mov     dword_52A30C, eax
    mov     dword_52A310, eax
    jmp     short loc_4F0882
    ; ---------------------------------------------------------------------------

    loc_4F0874:                             ; CODE XREF: sub_4F0730+90j
    mov     eax, dword_52A314
    test    eax, eax
    jz      short loc_4F089B
    call    _setSBCS

    loc_4F0882:                             ; CODE XREF: sub_4F0730+142j
                                            ; sub_4F0730+226j
    call    sub_4F0A50
    push    19h
    call    __unlock
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F089B:                             ; CODE XREF: sub_4F0730+14Bj
    push    19h
    call    __unlock
    add     esp, 4
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F08B0:                             ; CODE XREF: sub_4F0730+6Cj
    mov     ecx, 40h
    xor     eax, eax
    mov     edi, offset byte_52A0F8
    lea     ebx, [edx+edx*2]
    rep stosd
    stosb
    xor     edi, edi
    shl     ebx, 4
    lea     ebp, dword_50E830[ebx]

    loc_4F08CD:                             ; CODE XREF: sub_4F0730+1DDj
    mov     al, [ebp+0]
    mov     esi, ebp
    test    al, al
    jz      short loc_4F0906

    loc_4F08D6:                             ; CODE XREF: sub_4F0730+1D4j
    mov     cl, [esi+1]
    test    cl, cl
    jz      short loc_4F0906
    xor     eax, eax
    and     ecx, 0FFh
    mov     al, [esi]
    cmp     eax, ecx
    ja      short loc_4F08FC
    mov     dl, byte_50E818[edi]

    loc_4F08F1:                             ; CODE XREF: sub_4F0730+1CAj
    or      byte_52A0F9[eax], dl
    inc     eax
    cmp     eax, ecx
    jbe     short loc_4F08F1

    loc_4F08FC:                             ; CODE XREF: sub_4F0730+1B9j
    mov     al, [esi+2]
    add     esi, 2
    test    al, al
    jnz     short loc_4F08D6

    loc_4F0906:                             ; CODE XREF: sub_4F0730+1A4j
                                            ; sub_4F0730+1ABj
    inc     edi
    add     ebp, 8
    cmp     edi, 4
    jb      short loc_4F08CD
    mov     eax, [esp+24h+arg_0]
    mov     dword_52B644, 1
    push    eax
    mov     lpString1, eax
    call    _CPtoLCID
    mov     ecx, dword_50E824[ebx]
    mov     edx, dword_50E828[ebx]
    mov     dword_52A304, eax
    lea     eax, dword_50E824[ebx]
    add     esp, 4
    mov     dword_52A308, ecx
    mov     eax, [eax+8]
    mov     dword_52A30C, edx
    mov     dword_52A310, eax
    jmp     loc_4F0882
    sub_4F0730 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [0000004D BYTES: COLLAPSED FUNCTION _getSystemCP. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000038 BYTES: COLLAPSED FUNCTION _CPtoLCID. PRESS KEYPAD "+" TO EXPAND]
    off_4F09E8 dd offset loc_4F09CD         ; DATA XREF: _CPtoLCID+16r
    dd offset loc_4F09D3
    dd offset loc_4F09D9
    dd offset loc_4F09DF
    dd offset loc_4F09E5
    byte_4F09FC db 0                        ; DATA XREF: _CPtoLCID+10r
    ; ---------------------------------------------------------------------------
    add     al, 4
    add     al, 1
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, [ebx]
    nop
    ; [00000032 BYTES: COLLAPSED FUNCTION _setSBCS. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F0A50 proc near                    ; CODE XREF: sub_4F0730+4Ap
                                            ; sub_4F0730+152p

    CPInfo= _cpinfo ptr -514h
    MultiByteStr= byte ptr -500h
    DestStr= word ptr -400h
    var_300= dword ptr -300h
    CharType= word ptr -200h

    mov     ecx, lpString1
    sub     esp, 514h
    lea     eax, [esp+514h+CPInfo]
    push    ebx
    push    eax                             ; lpCPInfo
    push    ecx                             ; CodePage
    call    ds:GetCPInfo
    cmp     eax, 1
    jnz     loc_4F0BC4
    push    edi
    push    esi
    xor     eax, eax

    loc_4F0A76:                             ; CODE XREF: sub_4F0A50+30j
    mov     [esp+eax+520h+MultiByteStr], al
    inc     eax
    cmp     eax, 100h
    jb      short loc_4F0A76
    mov     al, [esp+520h+CPInfo.LeadByte]
    mov     [esp+520h+MultiByteStr], 20h
    test    al, al
    jz      short loc_4F0AC4
    lea     edx, [esp+520h+CPInfo.LeadByte+1]

    loc_4F0A93:                             ; CODE XREF: sub_4F0A50+72j
    xor     ecx, ecx
    and     eax, 0FFh
    mov     cl, [edx]
    cmp     eax, ecx
    ja      short loc_4F0ABA
    sub     ecx, eax
    lea     edi, [esp+eax+520h+MultiByteStr]
    inc     ecx
    mov     eax, 20202020h
    mov     esi, ecx
    shr     ecx, 2
    rep stosd
    mov     ecx, esi
    and     ecx, 3
    rep stosb

    loc_4F0ABA:                             ; CODE XREF: sub_4F0A50+4Ej
    mov     al, [edx+1]
    add     edx, 2
    test    al, al
    jnz     short loc_4F0A93

    loc_4F0AC4:                             ; CODE XREF: sub_4F0A50+3Dj
    mov     edx, dword_52A304
    mov     eax, lpString1
    push    0                               ; int
    push    edx                             ; int
    lea     ecx, [esp+528h+CharType]
    push    eax                             ; int
    push    ecx                             ; lpCharType
    lea     edx, [esp+530h+MultiByteStr]
    push    100h                            ; cchMultiByte
    push    edx                             ; lpMultiByteStr
    push    1                               ; dwInfoType
    call    sub_4F4680
    mov     eax, lpString1
    add     esp, 1Ch
    lea     ecx, [esp+520h+DestStr]
    lea     edx, [esp+520h+MultiByteStr]
    push    0                               ; int
    push    eax                             ; CodePage
    mov     eax, dword_52A304
    push    100h                            ; cchDest
    push    ecx                             ; lpDestStr
    push    100h                            ; lpWideCharStr
    push    edx                             ; lpMultiByteStr
    push    100h                            ; dwMapFlags
    push    eax                             ; Locale
    call    sub_4EE520
    mov     ecx, lpString1
    add     esp, 20h
    lea     edx, [esp+520h+var_300]
    lea     eax, [esp+520h+MultiByteStr]
    push    0                               ; int
    push    ecx                             ; CodePage
    mov     ecx, dword_52A304
    push    100h                            ; cchDest
    push    edx                             ; lpDestStr
    push    100h                            ; lpWideCharStr
    push    eax                             ; lpMultiByteStr
    push    200h                            ; dwMapFlags
    push    ecx                             ; Locale
    call    sub_4EE520
    add     esp, 20h
    xor     eax, eax
    lea     edx, [esp+520h+CharType]
    mov     bl, 10h

    loc_4F0B60:                             ; CODE XREF: sub_4F0A50+168j
    mov     cx, [edx]
    test    cl, 1
    jz      short loc_4F0B85
    mov     cl, byte_52A0F9[eax]
    or      cl, bl
    mov     byte_52A0F9[eax], cl
    mov     cl, byte ptr [esp+eax+520h+DestStr]
    mov     byte_52A200[eax], cl
    jmp     short loc_4F0BAF
    ; ---------------------------------------------------------------------------

    loc_4F0B85:                             ; CODE XREF: sub_4F0A50+116j
    test    cl, 2
    jz      short loc_4F0BA8
    mov     cl, byte_52A0F9[eax]
    or      cl, 20h
    mov     byte_52A0F9[eax], cl
    mov     cl, byte ptr [esp+eax+520h+var_300]
    mov     byte_52A200[eax], cl
    jmp     short loc_4F0BAF
    ; ---------------------------------------------------------------------------

    loc_4F0BA8:                             ; CODE XREF: sub_4F0A50+138j
    mov     byte_52A200[eax], 0

    loc_4F0BAF:                             ; CODE XREF: sub_4F0A50+133j
                                            ; sub_4F0A50+156j
    inc     eax
    add     edx, 2
    cmp     eax, 100h
    jb      short loc_4F0B60
    pop     esi
    pop     edi
    pop     ebx
    add     esp, 514h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F0BC4:                             ; CODE XREF: sub_4F0A50+1Cj
    xor     eax, eax
    mov     bl, 10h

    loc_4F0BC8:                             ; CODE XREF: sub_4F0A50+1D0j
    cmp     eax, 41h
    jb      short loc_4F0BED
    cmp     eax, 5Ah
    ja      short loc_4F0BED
    mov     dl, byte_52A0F9[eax]
    or      dl, bl
    mov     byte_52A0F9[eax], dl
    mov     dl, al
    add     dl, 20h
    mov     byte_52A200[eax], dl
    jmp     short loc_4F0C1A
    ; ---------------------------------------------------------------------------

    loc_4F0BED:                             ; CODE XREF: sub_4F0A50+17Bj
                                            ; sub_4F0A50+180j
    cmp     eax, 61h
    jb      short loc_4F0C13
    cmp     eax, 7Ah
    ja      short loc_4F0C13
    mov     cl, byte_52A0F9[eax]
    or      cl, 20h
    mov     byte_52A0F9[eax], cl
    mov     cl, al
    sub     cl, 20h
    mov     byte_52A200[eax], cl
    jmp     short loc_4F0C1A
    ; ---------------------------------------------------------------------------

    loc_4F0C13:                             ; CODE XREF: sub_4F0A50+1A0j
                                            ; sub_4F0A50+1A5j
    mov     byte_52A200[eax], 0

    loc_4F0C1A:                             ; CODE XREF: sub_4F0A50+19Bj
                                            ; sub_4F0A50+1C1j
    inc     eax
    cmp     eax, 100h
    jb      short loc_4F0BC8
    pop     ebx
    add     esp, 514h
    retn
    sub_4F0A50 endp

    ; ---------------------------------------------------------------------------
    align 8
    mov     eax, dword_52B644
    mov     ecx, lpString1
    neg     eax
    sbb     eax, eax
    and     eax, ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000000B BYTES: COLLAPSED FUNCTION ___initmbctable. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000A7 BYTES: COLLAPSED FUNCTION __mbsnbcpy. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     eax, [esp+4]
    push    1
    push    0
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __ismbbkprint:
    mov     eax, [esp+4]
    push    3
    push    0
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __ismbbkpunct:
    mov     eax, [esp+4]
    push    2
    push    0
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __ismbbalnum:
    mov     eax, [esp+4]
    push    1
    push    107h
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __ismbbalpha:
    mov     eax, [esp+4]
    push    1
    push    103h
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __ismbbgraph:
    mov     eax, [esp+4]
    push    3
    push    117h
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __ismbbprint:
    mov     eax, [esp+4]
    push    3
    push    157h
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __ismbbpunct:
    mov     eax, [esp+4]
    push    2
    push    10h
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000012 BYTES: COLLAPSED FUNCTION __ismbblead. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    __ismbbtrail:
    mov     eax, [esp+4]
    push    8
    push    0
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __ismbbkana:
    cmp     lpString1, 3A4h
    jnz     short loc_4F0E77
    mov     eax, [esp+4]
    push    3
    push    0
    push    eax
    call    _x_ismbbtype
    add     esp, 0Ch
    test    eax, eax
    jz      short loc_4F0E77
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_4F0E77:                             ; CODE XREF: .text:004F0E5Aj
                                            ; .text:004F0E6Fj
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    align 8
    ; [0000003A BYTES: COLLAPSED FUNCTION _x_ismbbtype. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000EE BYTES: COLLAPSED FUNCTION __setenvp. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000009E BYTES: COLLAPSED FUNCTION __setargv. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000020F BYTES: COLLAPSED FUNCTION _parse_cmdline. PRESS KEYPAD "+" TO EXPAND]
    align 4

    ___crtGetEnvironmentStringsW:
    sub     esp, 8
    mov     eax, dword_52A41C
    push    ebx
    push    ebp
    push    esi
    mov     esi, ds:GetEnvironmentStringsW
    xor     ebx, ebx
    push    edi
    mov     edi, ds:GetEnvironmentStrings
    test    eax, eax
    mov     [esp+10h], ebx
    mov     [esp+14h], ebx
    jnz     short loc_4F12B3
    call    esi ; GetEnvironmentStringsW
    test    eax, eax
    mov     [esp+10h], eax
    jz      short loc_4F1297
    mov     eax, 1
    jmp     short loc_4F12AA
    ; ---------------------------------------------------------------------------

    loc_4F1297:                             ; CODE XREF: .text:004F128Ej
    call    edi ; GetEnvironmentStrings
    test    eax, eax
    mov     [esp+10h], eax
    jz      loc_4F1452
    mov     eax, 2

    loc_4F12AA:                             ; CODE XREF: .text:004F1295j
    mov     ebx, [esp+10h]
    mov     dword_52A41C, eax

    loc_4F12B3:                             ; CODE XREF: .text:004F1284j
    cmp     eax, 1
    jnz     loc_4F133C
    test    ebx, ebx
    jnz     short loc_4F12D6
    call    esi ; GetEnvironmentStringsW
    test    eax, eax
    mov     [esp+10h], eax
    jnz     short loc_4F12D2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F12D2:                             ; CODE XREF: .text:004F12C8j
    mov     ebx, [esp+10h]

    loc_4F12D6:                             ; CODE XREF: .text:004F12BEj
    cmp     word ptr [ebx], 0
    mov     eax, ebx
    jz      short loc_4F12F0

    loc_4F12DE:                             ; CODE XREF: .text:004F12E5j
                                            ; .text:004F12EEj
    add     eax, 2
    cmp     word ptr [eax], 0
    jnz     short loc_4F12DE
    add     eax, 2
    cmp     word ptr [eax], 0
    jnz     short loc_4F12DE

    loc_4F12F0:                             ; CODE XREF: .text:004F12DCj
    sub     eax, ebx
    add     eax, 2
    mov     esi, eax
    push    esi
    call    _malloc
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jnz     short loc_4F1317
    push    ebx
    call    ds:FreeEnvironmentStringsW
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F1317:                             ; CODE XREF: .text:004F1304j
    mov     ecx, esi
    mov     esi, ebx
    mov     eax, ecx
    mov     edi, ebp
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    push    ebx
    and     ecx, 3
    rep movsb
    call    ds:FreeEnvironmentStringsW
    mov     eax, ebp
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F133C:                             ; CODE XREF: .text:004F12B6j
    cmp     eax, 2
    jnz     loc_4F1436
    test    ebx, ebx
    jnz     short loc_4F135F
    call    edi
    test    eax, eax
    mov     [esp+10h], eax
    jnz     short loc_4F135B
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F135B:                             ; CODE XREF: .text:004F1351j
    mov     ebx, [esp+10h]

    loc_4F135F:                             ; CODE XREF: .text:004F1347j
    mov     al, [ebx]
    mov     esi, ebx
    test    al, al
    jz      short loc_4F13A7

    loc_4F1367:                             ; CODE XREF: .text:004F13A5j
    mov     ecx, CodePage
    push    0
    push    0
    push    0FFFFFFFFh
    push    esi
    push    1
    push    ecx
    call    ds:MultiByteToWideChar
    test    eax, eax
    jz      loc_4F1452
    mov     ebp, [esp+14h]
    mov     edi, esi
    add     ebp, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    mov     [esp+14h], ebp
    repne scasb
    not     ecx
    dec     ecx
    mov     al, [esi+ecx+1]
    lea     esi, [esi+ecx+1]
    test    al, al
    jnz     short loc_4F1367

    loc_4F13A7:                             ; CODE XREF: .text:004F1365j
    mov     eax, [esp+14h]
    inc     eax
    mov     [esp+14h], eax
    lea     edx, [eax+eax]
    push    edx
    call    _malloc
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    jnz     short loc_4F13D3
    push    ebx
    call    ds:FreeEnvironmentStringsA
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F13D3:                             ; CODE XREF: .text:004F13C0j
    mov     eax, [esp+10h]
    mov     esi, ebp
    cmp     byte ptr [eax], 0
    jz      short loc_4F1424

    loc_4F13DE:                             ; CODE XREF: .text:004F1422j
    mov     edx, [esp+14h]
    mov     ecx, esi
    sub     ecx, ebp
    mov     eax, CodePage
    sar     ecx, 1
    sub     edx, ecx
    push    edx
    push    esi
    push    0FFFFFFFFh
    push    ebx
    push    1
    push    eax
    call    ds:MultiByteToWideChar
    test    eax, eax
    jz      short loc_4F143E
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    push    esi
    repne scasb
    not     ecx
    dec     ecx
    lea     ebx, [ebx+ecx+1]
    call    _wcslen
    lea     esi, [esi+eax*2+2]
    mov     al, [ebx]
    add     esp, 4
    test    al, al
    jnz     short loc_4F13DE

    loc_4F1424:                             ; CODE XREF: .text:004F13DCj
    mov     edx, [esp+10h]
    mov     word ptr [esi], 0
    push    edx
    call    ds:FreeEnvironmentStringsA
    mov     eax, ebp

    loc_4F1436:                             ; CODE XREF: .text:004F133Fj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F143E:                             ; CODE XREF: .text:004F13FFj
    push    ebp
    call    _free
    mov     ecx, [esp+14h]
    add     esp, 4
    push    ecx
    call    ds:FreeEnvironmentStringsA

    loc_4F1452:                             ; CODE XREF: .text:004F129Fj
                                            ; .text:004F137Fj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 8
    ; [00000156 BYTES: COLLAPSED FUNCTION ___crtGetEnvironmentStringsA. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000020C BYTES: COLLAPSED FUNCTION __ioinit. PRESS KEYPAD "+" TO EXPAND]
    align 8

    __ioterm:
    push    ebx
    push    ebp
    mov     ebp, ds:DeleteCriticalSection
    push    esi
    push    edi
    mov     ebx, offset dword_52B540

    loc_4F17DF:                             ; CODE XREF: .text:004F1828j
    mov     esi, [ebx]
    test    esi, esi
    jz      short loc_4F181F
    lea     eax, [esi+480h]
    cmp     esi, eax
    jnb     short loc_4F180E
    lea     edi, [esi+0Ch]

    loc_4F17F2:                             ; CODE XREF: .text:004F180Cj
    mov     eax, [edi-4]
    test    eax, eax
    jz      short loc_4F17FC
    push    edi
    call    ebp ; DeleteCriticalSection

    loc_4F17FC:                             ; CODE XREF: .text:004F17F7j
    mov     ecx, [ebx]
    add     esi, 24h
    add     ecx, 480h
    add     edi, 24h
    cmp     esi, ecx
    jb      short loc_4F17F2

    loc_4F180E:                             ; CODE XREF: .text:004F17EDj
    mov     edx, [ebx]
    push    edx
    call    _free
    add     esp, 4
    mov     dword ptr [ebx], 0

    loc_4F181F:                             ; CODE XREF: .text:004F17E3j
    add     ebx, 4
    cmp     ebx, offset uNumber
    jl      short loc_4F17DF
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [00000037 BYTES: COLLAPSED FUNCTION __heap_init. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    __heap_term:
    push    esi
    push    edi
    mov     edi, ds:VirtualFree
    mov     esi, offset off_50E9C8

    loc_4F187D:                             ; CODE XREF: .text:004F1896j
    mov     eax, [esi+10h]
    test    eax, eax
    jz      short loc_4F188E
    push    8000h
    push    0
    push    eax
    call    edi ; VirtualFree

    loc_4F188E:                             ; CODE XREF: .text:004F1882j
    mov     esi, [esi]
    cmp     esi, offset off_50E9C8
    jnz     short loc_4F187D
    mov     eax, hHeap
    push    eax
    call    ds:HeapDestroy
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000003D BYTES: COLLAPSED FUNCTION __FF_MSGBANNER. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [000001D6 BYTES: COLLAPSED FUNCTION __NMSG_WRITE. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    __GET_RTERRMSG:
    mov     edx, [esp+4]
    xor     ecx, ecx
    mov     eax, offset dword_50E938

    loc_4F1ADB:                             ; CODE XREF: .text:004F1AE8j
    cmp     edx, [eax]
    jz      short loc_4F1AEA
    add     eax, 8
    inc     ecx
    cmp     eax, offset off_50E9C8
    jb      short loc_4F1ADB

    loc_4F1AEA:                             ; CODE XREF: .text:004F1ADDj
    cmp     edx, dword_50E938[ecx*8]
    jnz     short loc_4F1AFB
    mov     eax, lpBuffer[ecx*8]
    retn
    ; ---------------------------------------------------------------------------

    loc_4F1AFB:                             ; CODE XREF: .text:004F1AF1j
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [00000072 BYTES: COLLAPSED FUNCTION __lseek. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000080 BYTES: COLLAPSED FUNCTION __lseek_lk. PRESS KEYPAD "+" TO EXPAND]
    ; [00000168 BYTES: COLLAPSED FUNCTION __alloc_osfhnd. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000A1 BYTES: COLLAPSED FUNCTION __set_osfhnd. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000093 BYTES: COLLAPSED FUNCTION __free_osfhnd. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000049 BYTES: COLLAPSED FUNCTION __get_osfhandle. PRESS KEYPAD "+" TO EXPAND]
    align 8

    __open_osfhandle:
    mov     eax, [esp+8]
    push    ebx
    xor     bl, bl
    push    esi
    test    al, 8
    push    edi
    jz      short loc_4F1F1F
    mov     bl, 20h

    loc_4F1F1F:                             ; CODE XREF: .text:004F1F1Bj
    test    ah, 40h
    jz      short loc_4F1F27
    or      bl, 80h

    loc_4F1F27:                             ; CODE XREF: .text:004F1F22j
    mov     edi, [esp+10h]
    push    edi
    call    ds:GetFileType
    test    eax, eax
    jnz     short loc_4F1F4C
    call    ds:GetLastError
    push    eax
    call    __dosmaperr
    add     esp, 4
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F1F4C:                             ; CODE XREF: .text:004F1F34j
    cmp     eax, 2
    jnz     short loc_4F1F56
    or      bl, 40h
    jmp     short loc_4F1F5E
    ; ---------------------------------------------------------------------------

    loc_4F1F56:                             ; CODE XREF: .text:004F1F4Fj
    cmp     eax, 3
    jnz     short loc_4F1F5E
    or      bl, 8

    loc_4F1F5E:                             ; CODE XREF: .text:004F1F54j
                                            ; .text:004F1F59j
    call    __alloc_osfhnd
    mov     esi, eax
    cmp     esi, 0FFFFFFFFh
    jnz     short loc_4F1F86
    call    __errno
    mov     dword ptr [eax], 18h
    call    ___doserrno
    mov     dword ptr [eax], 0
    or      eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F1F86:                             ; CODE XREF: .text:004F1F68j
    push    edi
    push    esi
    call    __set_osfhnd
    mov     eax, esi
    mov     ecx, esi
    and     eax, 1Fh
    add     esp, 8
    sar     ecx, 5
    lea     edx, [eax+eax*8]
    or      bl, 1
    mov     eax, dword_52B540[ecx*4]
    push    esi
    mov     [eax+edx*4+4], bl
    call    __unlock_fhandle
    add     esp, 4
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 8
    ; [00000065 BYTES: COLLAPSED FUNCTION __lock_fhandle. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000022 BYTES: COLLAPSED FUNCTION __unlock_fhandle. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     eax, uNumber
    push    esi
    mov     esi, [esp+8]
    push    edi
    cmp     esi, eax
    jnb     short loc_4F20B1
    mov     eax, esi
    mov     ecx, esi
    and     eax, 1Fh
    sar     ecx, 5
    lea     edx, [eax+eax*8]
    mov     eax, dword_52B540[ecx*4]
    test    byte ptr [eax+edx*4+4], 1
    jz      short loc_4F20B1
    push    esi
    call    __lock_fhandle
    mov     ecx, [esp+14h]
    add     esp, 4
    push    ecx
    push    esi
    call    __setmode_lk
    add     esp, 8
    mov     edi, eax
    push    esi
    call    __unlock_fhandle
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4F20B1:                             ; CODE XREF: .text:004F206Dj
                                            ; .text:004F2088j
    call    __errno
    mov     dword ptr [eax], 9
    pop     edi
    or      eax, 0FFFFFFFFh
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000064 BYTES: COLLAPSED FUNCTION __setmode_lk. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F2140 proc near                    ; CODE XREF: __chdir+4Dp

    DestStr= word ptr -8
    MultiByteStr= byte ptr  4

    sub     esp, 8
    push    ebx
    mov     ebx, dword ptr [esp+0Ch+MultiByteStr]
    cmp     ebx, 0FFh
    jbe     short loc_4F21BC
    mov     eax, ebx
    mov     [esp+11h], bl
    shr     eax, 8
    mov     [esp+0Ch+MultiByteStr], al
    mov     ecx, dword ptr [esp+0Ch+MultiByteStr]
    and     ecx, 0FFh
    test    byte_52A0F9[ecx], 4
    jz      short loc_4F21D7
    mov     edx, lpString1
    push    1                               ; int
    push    edx                             ; CodePage
    mov     edx, dword_52A304
    lea     eax, [esp+14h+DestStr]
    push    2                               ; cchDest
    push    eax                             ; lpDestStr
    lea     ecx, [esp+1Ch+MultiByteStr]
    push    2                               ; lpWideCharStr
    push    ecx                             ; lpMultiByteStr
    push    200h                            ; dwMapFlags
    push    edx                             ; Locale
    call    sub_4EE520
    add     esp, 20h
    test    eax, eax
    jz      short loc_4F21D7
    mov     eax, dword ptr [esp+0Ch+DestStr]
    mov     ecx, dword ptr [esp+0Ch+DestStr+1]
    and     eax, 0FFh
    and     ecx, 0FFh
    shl     eax, 8
    add     eax, ecx
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F21BC:                             ; CODE XREF: sub_4F2140+Ej
    mov     dl, byte_52A0F9[ebx]
    and     dl, 20h
    cmp     dl, 20h
    jnz     short loc_4F21D7
    xor     eax, eax
    mov     al, byte_52A200[ebx]
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F21D7:                             ; CODE XREF: sub_4F2140+2Ej
                                            ; sub_4F2140+5Dj ...
    mov     eax, ebx
    pop     ebx
    add     esp, 8
    retn
    sub_4F2140 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000053 BYTES: COLLAPSED FUNCTION __CxxUnhandledExceptionFilter(_EXCEPTION_POINTERS *). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000011 BYTES: COLLAPSED FUNCTION __CxxSetUnhandledExceptionFilter(void). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000000D BYTES: COLLAPSED FUNCTION __CxxRestoreUnhandledExceptionFilter(void). PRESS KEYPAD "+" TO EXPAND]
    align 4
    mov     eax, dword_5109EC
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __set_sbh_threshold:
    mov     eax, [esp+4]
    add     eax, 0Fh
    and     al, 0F0h
    cmp     eax, 780h
    ja      short loc_4F229B
    mov     dword_5109EC, eax
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_4F229B:                             ; CODE XREF: .text:004F228Ej
    xor     eax, eax
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [00000162 BYTES: COLLAPSED FUNCTION ___sbh_new_region. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000005B BYTES: COLLAPSED FUNCTION ___sbh_release_region. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000CD BYTES: COLLAPSED FUNCTION ___sbh_decommit_pages. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000059 BYTES: COLLAPSED FUNCTION ___sbh_find_block. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000053 BYTES: COLLAPSED FUNCTION ___sbh_free_block. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000233 BYTES: COLLAPSED FUNCTION ___sbh_alloc_block. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000172 BYTES: COLLAPSED FUNCTION ___sbh_alloc_block_from_page. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000C4 BYTES: COLLAPSED FUNCTION ___sbh_resize_block. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ___sbh_heap_check:
    sub     esp, 1Ch
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     edi, edi
    mov     edx, offset off_50E9C8
    mov     [esp+20h], edi
    mov     [esp+1Ch], edx

    loc_4F2AA6:                             ; CODE XREF: .text:004F2BDDj
    cmp     dword_5109E8, edx
    jnz     short loc_4F2AB2
    inc     dword ptr [esp+20h]

    loc_4F2AB2:                             ; CODE XREF: .text:004F2AACj
    mov     ecx, [edx+10h]
    cmp     ecx, 0FFFFFFFFh
    jz      loc_4F2BCF
    mov     ebx, ecx
    lea     eax, [edx+18h]
    mov     [esp+24h], edi
    mov     [esp+10h], edi
    lea     ebp, [ebx+8]
    mov     [esp+28h], eax

    loc_4F2AD2:                             ; CODE XREF: .text:004F2BC9j
    cmp     dword ptr [eax], 0FFFFFFFFh
    jnz     short loc_4F2AEF
    cmp     [esp+10h], edi
    jnz     short loc_4F2AE6
    cmp     [edx+0Ch], eax
    jnz     loc_4F2BE2

    loc_4F2AE6:                             ; CODE XREF: .text:004F2ADBj
    inc     dword ptr [esp+10h]
    jmp     loc_4F2BA7
    ; ---------------------------------------------------------------------------

    loc_4F2AEF:                             ; CODE XREF: .text:004F2AD5j
    mov     edx, [ebx]
    lea     ecx, [ebp+0F0h]
    cmp     edx, ecx
    jnb     loc_4F2BED
    cmp     byte ptr [ecx], 0FFh
    jnz     loc_4F2BFA
    xor     edx, edx
    xor     ecx, ecx
    mov     [esp+14h], ecx
    mov     [esp+18h], edi

    loc_4F2B14:                             ; CODE XREF: .text:004F2B89j
    lea     esi, [edx+ebp]
    cmp     esi, [ebx]
    jnz     short loc_4F2B20
    inc     ecx
    mov     [esp+14h], ecx

    loc_4F2B20:                             ; CODE XREF: .text:004F2B19j
    cmp     byte ptr [esi], 0
    jnz     short loc_4F2B32
    mov     esi, [esp+18h]
    inc     esi
    inc     edi
    mov     [esp+18h], esi
    inc     edx
    jmp     short loc_4F2B83
    ; ---------------------------------------------------------------------------

    loc_4F2B32:                             ; CODE XREF: .text:004F2B23j
    cmp     edi, [eax+4]
    jge     loc_4F2C07
    cmp     ecx, 1
    jnz     short loc_4F2B51
    cmp     edi, [ebp-4]
    jl      loc_4F2C14
    mov     dword ptr [esp+14h], 2

    loc_4F2B51:                             ; CODE XREF: .text:004F2B3Ej
    xor     eax, eax
    lea     ecx, [edx+1]
    mov     al, [esi]
    mov     esi, edx
    add     esi, eax
    xor     edi, edi
    cmp     ecx, esi
    jge     short loc_4F2B79

    loc_4F2B62:                             ; CODE XREF: .text:004F2B77j
    cmp     byte ptr [ecx+ebp], 0
    jnz     loc_4F2C21
    xor     eax, eax
    inc     ecx
    mov     al, [edx+ebx+8]
    add     eax, edx
    cmp     ecx, eax
    jl      short loc_4F2B62

    loc_4F2B79:                             ; CODE XREF: .text:004F2B60j
    mov     eax, [esp+28h]
    mov     edx, ecx
    mov     ecx, [esp+14h]

    loc_4F2B83:                             ; CODE XREF: .text:004F2B30j
    cmp     edx, 0F0h
    jl      short loc_4F2B14
    mov     edx, [esp+18h]
    mov     esi, [eax]
    cmp     edx, esi
    jnz     loc_4F2C2E
    test    ecx, ecx
    jz      loc_4F2C3B
    mov     edx, [esp+1Ch]
    xor     edi, edi

    loc_4F2BA7:                             ; CODE XREF: .text:004F2AEAj
    mov     ecx, [esp+24h]
    add     eax, 8
    inc     ecx
    add     ebx, 1000h
    add     ebp, 1000h
    cmp     ecx, 400h
    mov     [esp+24h], ecx
    mov     [esp+28h], eax
    jl      loc_4F2AD2

    loc_4F2BCF:                             ; CODE XREF: .text:004F2AB8j
    mov     edx, [edx]
    cmp     edx, offset off_50E9C8
    mov     [esp+1Ch], edx
    jz      short loc_4F2C48
    jmp     loc_4F2AA6
    ; ---------------------------------------------------------------------------

    loc_4F2BE2:                             ; CODE XREF: .text:004F2AE0j
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4F2BED:                             ; CODE XREF: .text:004F2AF9j
    mov     eax, 0FFFFFFFEh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4F2BFA:                             ; CODE XREF: .text:004F2B02j
    mov     eax, 0FFFFFFFDh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4F2C07:                             ; CODE XREF: .text:004F2B35j
    mov     eax, 0FFFFFFFCh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4F2C14:                             ; CODE XREF: .text:004F2B43j
    mov     eax, 0FFFFFFFBh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4F2C21:                             ; CODE XREF: .text:004F2B66j
    mov     eax, 0FFFFFFFAh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4F2C2E:                             ; CODE XREF: .text:004F2B93j
    mov     eax, 0FFFFFFF9h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4F2C3B:                             ; CODE XREF: .text:004F2B9Bj
    mov     eax, 0FFFFFFF8h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------

    loc_4F2C48:                             ; CODE XREF: .text:004F2BDBj
    mov     eax, [esp+20h]
    pop     edi
    neg     eax
    sbb     eax, eax
    pop     esi
    and     eax, 9
    pop     ebp
    add     eax, 0FFFFFFF7h
    pop     ebx
    add     esp, 1Ch
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [00000028 BYTES: COLLAPSED FUNCTION _set_new_handler(int (*)(uint)). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    mov     eax, dword_52A434
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000020 BYTES: COLLAPSED FUNCTION __callnewh. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    ___initstdio:
    mov     eax, dword_52B520
    push    esi
    test    eax, eax
    jnz     short loc_4F2CD1
    mov     eax, 200h
    jmp     short loc_4F2CDB
    ; ---------------------------------------------------------------------------

    loc_4F2CD1:                             ; CODE XREF: .text:004F2CC8j
    cmp     eax, 14h
    jge     short loc_4F2CE0
    mov     eax, 14h

    loc_4F2CDB:                             ; CODE XREF: .text:004F2CCFj
    mov     dword_52B520, eax

    loc_4F2CE0:                             ; CODE XREF: .text:004F2CD4j
    push    4
    push    eax
    call    _calloc
    add     esp, 8
    mov     dword_52A508, eax
    test    eax, eax
    jnz     short loc_4F2D22
    push    4
    push    14h
    mov     dword_52B520, 14h
    call    _calloc
    add     esp, 8
    mov     dword_52A508, eax
    test    eax, eax
    jnz     short loc_4F2D22
    push    1Ah
    call    __amsg_exit
    mov     eax, dword_52A508
    add     esp, 4

    loc_4F2D22:                             ; CODE XREF: .text:004F2CF2j
                                            ; .text:004F2D11j
    xor     edx, edx
    mov     ecx, offset off_5109F0
    jmp     short loc_4F2D30
    ; ---------------------------------------------------------------------------

    loc_4F2D2B:                             ; CODE XREF: .text:004F2D3Fj
    mov     eax, dword_52A508

    loc_4F2D30:                             ; CODE XREF: .text:004F2D29j
    mov     [eax+edx], ecx
    add     ecx, 20h
    add     edx, 4
    cmp     ecx, offset dword_510C70
    jl      short loc_4F2D2B
    xor     ecx, ecx
    mov     edx, offset dword_510A00

    loc_4F2D48:                             ; CODE XREF: .text:004F2D78j
    mov     esi, ecx
    mov     eax, ecx
    sar     esi, 5
    and     eax, 1Fh
    mov     esi, dword_52B540[esi*4]
    lea     eax, [eax+eax*8]
    mov     eax, [esi+eax*4]
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4F2D68
    test    eax, eax
    jnz     short loc_4F2D6E

    loc_4F2D68:                             ; CODE XREF: .text:004F2D62j
    mov     dword ptr [edx], 0FFFFFFFFh

    loc_4F2D6E:                             ; CODE XREF: .text:004F2D66j
    add     edx, 20h
    inc     ecx
    cmp     edx, offset dword_510A60
    jl      short loc_4F2D48
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ___endstdio:
    call    __flushall
    mov     al, byte_529F04
    test    al, al
    jz      short locret_4F2D93
    jmp     __fcloseall
    ; ---------------------------------------------------------------------------

    locret_4F2D93:                          ; CODE XREF: .text:004F2D8Cj
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000003B BYTES: COLLAPSED FUNCTION __mbsnbicoll. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000007A BYTES: COLLAPSED FUNCTION ___wtomb_environ. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000001A5 BYTES: COLLAPSED FUNCTION __mbsicmp. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000090 BYTES: COLLAPSED FUNCTION __mbsrchr. PRESS KEYPAD "+" TO EXPAND]
    ; [000000CA BYTES: COLLAPSED FUNCTION __fullpath. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F3170 proc near                    ; CODE XREF: __stat+44p

    DestStr= word ptr -8
    MultiByteStr= byte ptr  4

    sub     esp, 8
    push    ebx
    mov     ebx, dword ptr [esp+0Ch+MultiByteStr]
    cmp     ebx, 0FFh
    jbe     short loc_4F31EC
    mov     eax, ebx
    mov     [esp+11h], bl
    shr     eax, 8
    mov     [esp+0Ch+MultiByteStr], al
    mov     ecx, dword ptr [esp+0Ch+MultiByteStr]
    and     ecx, 0FFh
    test    byte_52A0F9[ecx], 4
    jz      short loc_4F3207
    mov     edx, lpString1
    push    1                               ; int
    push    edx                             ; CodePage
    mov     edx, dword_52A304
    lea     eax, [esp+14h+DestStr]
    push    2                               ; cchDest
    push    eax                             ; lpDestStr
    lea     ecx, [esp+1Ch+MultiByteStr]
    push    2                               ; lpWideCharStr
    push    ecx                             ; lpMultiByteStr
    push    100h                            ; dwMapFlags
    push    edx                             ; Locale
    call    sub_4EE520
    add     esp, 20h
    test    eax, eax
    jz      short loc_4F3207
    mov     eax, dword ptr [esp+0Ch+DestStr]
    mov     ecx, dword ptr [esp+0Ch+DestStr+1]
    and     eax, 0FFh
    and     ecx, 0FFh
    shl     eax, 8
    add     eax, ecx
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F31EC:                             ; CODE XREF: sub_4F3170+Ej
    mov     dl, byte_52A0F9[ebx]
    and     dl, 10h
    cmp     dl, 10h
    jnz     short loc_4F3207
    xor     eax, eax
    mov     al, byte_52A200[ebx]
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F3207:                             ; CODE XREF: sub_4F3170+2Ej
                                            ; sub_4F3170+5Dj ...
    mov     eax, ebx
    pop     ebx
    add     esp, 8
    retn
    sub_4F3170 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [000000AD BYTES: COLLAPSED FUNCTION __mbspbrk. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000005D BYTES: COLLAPSED FUNCTION __getbuf. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000002B BYTES: COLLAPSED FUNCTION __isatty. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000006C BYTES: COLLAPSED FUNCTION _wctomb. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000072 BYTES: COLLAPSED FUNCTION __wctomb_lk. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000068 BYTES: COLLAPSED FUNCTION __aulldiv. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000075 BYTES: COLLAPSED FUNCTION __aullrem. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000066 BYTES: COLLAPSED FUNCTION __ZeroTail. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000069 BYTES: COLLAPSED FUNCTION __IncMan. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000009D BYTES: COLLAPSED FUNCTION __RoundMan. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000001D BYTES: COLLAPSED FUNCTION __CopyMan. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000000F BYTES: COLLAPSED FUNCTION __FillZeroMan. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000001D BYTES: COLLAPSED FUNCTION __IsZeroMan. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [000000B1 BYTES: COLLAPSED FUNCTION __ShrMan. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000001CF BYTES: COLLAPSED FUNCTION __ld12cvt. PRESS KEYPAD "+" TO EXPAND]
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F3990 proc near                    ; CODE XREF: __fltin2+4Bp
                                            ; sub_4F3A50+2Cp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    push    offset dword_510CE0
    push    eax
    push    ecx
    call    __ld12cvt
    add     esp, 0Ch
    retn
    sub_4F3990 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F39B0 proc near                    ; CODE XREF: sub_4F3AD0+2Cp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    mov     ecx, [esp+arg_0]
    push    offset dword_510CF8
    push    eax
    push    ecx
    call    __ld12cvt
    add     esp, 0Ch
    retn
    sub_4F39B0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000080 BYTES: COLLAPSED FUNCTION __ld12told. PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F3A50 proc near                    ; CODE XREF: .text:004EA755p

    var_C= dword ptr -0Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    sub     esp, 0Ch
    lea     ecx, [esp+0Ch+arg_4]
    lea     edx, [esp+0Ch+var_C]
    push    0
    push    0
    push    0
    push    0
    push    eax
    push    ecx
    push    edx
    call    ___strgtold12
    mov     eax, [esp+28h+arg_0]
    add     esp, 1Ch
    lea     ecx, [esp+0Ch+var_C]
    push    eax
    push    ecx
    call    sub_4F3990
    add     esp, 8
    add     esp, 0Ch
    retn
    sub_4F3A50 endp

    ; ---------------------------------------------------------------------------
    align 10h

    __atoldbl:
    mov     eax, [esp+8]
    sub     esp, 0Ch
    lea     ecx, [esp+14h]
    lea     edx, [esp+0]
    push    0
    push    0
    push    0
    push    1
    push    eax
    push    ecx
    push    edx
    call    ___strgtold12
    mov     eax, [esp+2Ch]
    add     esp, 1Ch
    lea     ecx, [esp+0]
    push    eax
    push    ecx
    call    __ld12told
    add     esp, 8
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F3AD0 proc near                    ; CODE XREF: .text:004EA77Cp

    var_C= dword ptr -0Ch
    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     eax, [esp+arg_4]
    sub     esp, 0Ch
    lea     ecx, [esp+0Ch+arg_4]
    lea     edx, [esp+0Ch+var_C]
    push    0
    push    0
    push    0
    push    0
    push    eax
    push    ecx
    push    edx
    call    ___strgtold12
    mov     eax, [esp+28h+arg_0]
    add     esp, 1Ch
    lea     ecx, [esp+0Ch+var_C]
    push    eax
    push    ecx
    call    sub_4F39B0
    add     esp, 8
    add     esp, 0Ch
    retn
    sub_4F3AD0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000091 BYTES: COLLAPSED FUNCTION __fptostr. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000008B BYTES: COLLAPSED FUNCTION __fltout2. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [000000BE BYTES: COLLAPSED FUNCTION ___dtold. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000000B BYTES: COLLAPSED FUNCTION __fptrap. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000660 BYTES: COLLAPSED FUNCTION ___strgtold12. PRESS KEYPAD "+" TO EXPAND]
    off_4F4370 dd offset loc_4F3D9E         ; DATA XREF: ___strgtold12+87r
    dd offset loc_4F3E05
    dd offset loc_4F3E4D
    dd offset loc_4F3E8B
    dd offset loc_4F3F31
    dd offset loc_4F3FEE
    dd offset loc_4F404C
    dd offset loc_4F40AF
    dd offset loc_4F4081
    dd offset loc_4F40DE
    dd offset loc_4F41E3
    dd offset loc_4F419F
    off_4F43A0 dd offset loc_4F3FE3         ; DATA XREF: ___strgtold12+136r
    dd offset loc_4F3FE3
    dd offset loc_4F3E84
    dd offset loc_4F3FD9
    dd offset loc_4F3FD9
    dd offset loc_4F41DD
    byte_4F43B8 db 0                        ; DATA XREF: ___strgtold12+130r
    dd 5050105h, 5050502h, 4 dup(5050505h), 5050303h, 7 dup(5050505h)
    db 2 dup(4), 90h
    off_4F43F4 dd offset loc_4F3FE3         ; DATA XREF: ___strgtold12+21Ar
    dd offset loc_4F3FE3
    dd offset loc_4F3FD9
    dd offset loc_4F3FD9
    dd offset loc_4F41DD
    byte_4F4408 db 0                        ; DATA XREF: ___strgtold12+214r
    dd 4040104h, 5 dup(4040404h), 4040202h, 3 dup(4040404h)
    db 2 dup(4)
    dword_4F4433 dd 3 dup(4040404h), 3030404h ; DATA XREF: .data:005036F0o
    align 4
    off_4F4444 dd offset loc_4F3FE3         ; DATA XREF: ___strgtold12+2C2r
    dd offset loc_4F3FE3
    dd offset loc_4F3FD9
    dd offset loc_4F3FD9
    dd offset loc_4F41DD
    byte_4F4458 db 0                        ; DATA XREF: ___strgtold12+2BCr
    ; ---------------------------------------------------------------------------
    add     al, 1
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, [edx]
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     eax, [ebx]
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop

    ___STRINGTOLD:
    mov     eax, [esp+10h]
    mov     ecx, [esp+0Ch]
    mov     edx, [esp+8]
    sub     esp, 0Ch
    push    esi
    push    0
    push    0
    push    0
    push    eax
    push    ecx
    lea     eax, [esp+18h]
    push    edx
    push    eax
    call    ___strgtold12
    mov     ecx, [esp+30h]
    add     esp, 1Ch
    lea     edx, [esp+4]
    mov     esi, eax
    push    ecx
    push    edx
    call    __ld12told
    add     esp, 8
    cmp     eax, 1
    jnz     short loc_4F44E2
    or      esi, 2

    loc_4F44E2:                             ; CODE XREF: .text:004F44DDj
    mov     eax, esi
    pop     esi
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 8
    ; [00000184 BYTES: COLLAPSED FUNCTION ___crtGetStringTypeW. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4F4680(DWORD dwInfoType,LPCSTR lpMultiByteStr,int cchMultiByte,LPWORD lpCharType,int,int,int)
    sub_4F4680 proc near                    ; CODE XREF: __isctype+74p
                                            ; sub_4F0A50+97p ...

    dwInfoType= dword ptr  4
    lpMultiByteStr= dword ptr  8
    cchMultiByte= dword ptr  0Ch
    lpCharType= dword ptr  10h
    arg_10= dword ptr  14h
    arg_14= dword ptr  18h
    arg_18= dword ptr  1Ch

    push    ecx
    mov     eax, dword_52A440
    push    ebx
    push    ebp
    push    esi
    mov     esi, ds:GetStringTypeA
    push    edi
    xor     edi, edi
    cmp     eax, edi
    jnz     short loc_4F46BC
    lea     eax, [esp+12h]
    push    eax                             ; lpCharType
    push    1                               ; cchSrc
    push    offset SrcStr                   ; lpSrcStr
    push    1                               ; dwInfoType
    call    ds:GetStringTypeW
    test    eax, eax
    jz      loc_4F478C
    mov     eax, 1
    mov     dword_52A440, eax

    loc_4F46BC:                             ; CODE XREF: sub_4F4680+14j
                                            ; sub_4F4680+12Bj
    cmp     eax, 2
    jnz     short loc_4F46EB
    mov     eax, [esp+14h+arg_14]
    cmp     eax, edi
    jnz     short loc_4F46CE
    mov     eax, Locale

    loc_4F46CE:                             ; CODE XREF: sub_4F4680+47j
    mov     edx, [esp+14h+lpCharType]
    mov     ecx, [esp+14h+cchMultiByte]
    push    edx                             ; lpCharType
    mov     edx, [esp+18h+lpMultiByteStr]
    push    ecx                             ; cchSrc
    mov     ecx, [esp+1Ch+dwInfoType]
    push    edx                             ; lpSrcStr
    push    ecx                             ; dwInfoType
    push    eax                             ; Locale
    call    esi ; GetStringTypeA
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F46EB:                             ; CODE XREF: sub_4F4680+3Fj
    cmp     eax, 1
    jnz     loc_4F4786
    mov     ebx, [esp+14h+arg_10]
    mov     [esp+14h+arg_14], edi
    cmp     ebx, edi
    jnz     short loc_4F4706
    mov     ebx, CodePage

    loc_4F4706:                             ; CODE XREF: sub_4F4680+7Ej
    mov     eax, [esp+14h+arg_18]
    mov     ebp, [esp+14h+cchMultiByte]
    mov     edx, [esp+14h+lpMultiByteStr]
    push    edi                             ; cchWideChar
    neg     eax
    sbb     eax, eax
    push    edi                             ; lpWideCharStr
    and     eax, 8
    push    ebp                             ; cchMultiByte
    inc     eax
    push    edx                             ; lpMultiByteStr
    push    eax                             ; dwFlags
    push    ebx                             ; CodePage
    call    ds:MultiByteToWideChar
    mov     esi, eax
    test    esi, esi
    jz      short loc_4F4777
    push    esi                             ; size_t
    push    2                               ; size_t
    call    _calloc
    mov     edi, eax
    add     esp, 8
    test    edi, edi
    jz      short loc_4F4777
    mov     ecx, [esp+14h+lpMultiByteStr]
    push    esi                             ; cchWideChar
    push    edi                             ; lpWideCharStr
    push    ebp                             ; cchMultiByte
    push    ecx                             ; lpMultiByteStr
    push    1                               ; dwFlags
    push    ebx                             ; CodePage
    call    ds:MultiByteToWideChar
    test    eax, eax
    jz      short loc_4F4777
    mov     edx, [esp+14h+lpCharType]
    push    edx                             ; lpCharType
    push    eax                             ; cchSrc
    mov     eax, [esp+1Ch+dwInfoType]
    push    edi                             ; lpSrcStr
    push    eax                             ; dwInfoType
    call    ds:GetStringTypeW
    push    edi                             ; void *
    mov     esi, eax
    call    _free
    add     esp, 4
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F4777:                             ; CODE XREF: sub_4F4680+AAj
                                            ; sub_4F4680+BBj ...
    mov     esi, [esp+14h+arg_14]
    push    edi                             ; void *
    call    _free
    add     esp, 4
    mov     eax, esi

    loc_4F4786:                             ; CODE XREF: sub_4F4680+6Ej
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F478C:                             ; CODE XREF: sub_4F4680+2Cj
    lea     ecx, [esp+12h]
    push    ecx
    push    1
    push    offset String1
    push    1
    push    edi
    call    esi
    test    eax, eax
    jz      short loc_4F47B0
    mov     eax, 2
    mov     dword_52A440, eax
    jmp     loc_4F46BC
    ; ---------------------------------------------------------------------------

    loc_4F47B0:                             ; CODE XREF: sub_4F4680+11Fj
    pop     edi
    pop     esi
    pop     ebp
    xor     eax, eax
    pop     ebx
    pop     ecx
    retn
    sub_4F4680 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000009E BYTES: COLLAPSED FUNCTION __commit. PRESS KEYPAD "+" TO EXPAND]
    align 4
    mov     eax, [esp+0Ch]
    mov     ecx, [esp+8]
    mov     edx, [esp+4]
    push    eax
    push    40h
    push    ecx
    push    edx
    call    sub_4F4880
    add     esp, 10h
    retn
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4880 proc near                    ; CODE XREF: __openfile+111p
                                            ; .text:004F4871p

    var_11= byte ptr -11h
    dwDesiredAccess= dword ptr -10h
    SecurityAttributes= _SECURITY_ATTRIBUTES ptr -0Ch
    lpFileName= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch
    arg_C= dword ptr  10h

    sub     esp, 14h
    mov     ecx, [esp+14h+arg_4]
    push    ebx
    push    ebp
    push    esi
    mov     dl, 80h
    xor     esi, esi
    test    dl, cl
    push    edi
    mov     [esp+24h+SecurityAttributes.nLength], 0Ch
    mov     [esp+24h+SecurityAttributes.lpSecurityDescriptor], esi
    jz      short loc_4F48AA
    mov     [esp+24h+SecurityAttributes.bInheritHandle], esi
    mov     [esp+24h+var_11], 10h
    jmp     short loc_4F48B7
    ; ---------------------------------------------------------------------------

    loc_4F48AA:                             ; CODE XREF: sub_4F4880+1Dj
    mov     [esp+24h+SecurityAttributes.bInheritHandle], 1
    mov     [esp+24h+var_11], 0

    loc_4F48B7:                             ; CODE XREF: sub_4F4880+28j
    test    ch, 80h
    jnz     short loc_4F48D1
    test    ch, 40h
    jnz     short loc_4F48CD
    cmp     dword_52A4C4, 8000h
    jz      short loc_4F48D1

    loc_4F48CD:                             ; CODE XREF: sub_4F4880+3Fj
    or      [esp+24h+var_11], dl

    loc_4F48D1:                             ; CODE XREF: sub_4F4880+3Aj
                                            ; sub_4F4880+4Bj
    mov     eax, ecx
    and     eax, 3
    sub     eax, esi
    jz      short loc_4F48F8
    dec     eax
    jz      short loc_4F48EE
    dec     eax
    jnz     loc_4F4BB4
    mov     [esp+24h+dwDesiredAccess], 0C0000000h
    jmp     short loc_4F4900
    ; ---------------------------------------------------------------------------

    loc_4F48EE:                             ; CODE XREF: sub_4F4880+5Bj
    mov     [esp+24h+dwDesiredAccess], 40000000h
    jmp     short loc_4F4900
    ; ---------------------------------------------------------------------------

    loc_4F48F8:                             ; CODE XREF: sub_4F4880+58j
    mov     [esp+24h+dwDesiredAccess], 80000000h

    loc_4F4900:                             ; CODE XREF: sub_4F4880+6Cj
                                            ; sub_4F4880+76j
    mov     eax, [esp+24h+arg_8]
    add     eax, 0FFFFFFF0h
    cmp     eax, 30h
    ja      loc_4F4BB4
    xor     ebx, ebx
    mov     bl, ds:byte_4F4BE8[eax]
    jmp     ds:off_4F4BD4[ebx*4]

    loc_4F491F:                             ; DATA XREF: .text:004F4BD4o
    xor     ebx, ebx
    jmp     short loc_4F4936
    ; ---------------------------------------------------------------------------

    loc_4F4923:                             ; CODE XREF: sub_4F4880+98j
                                            ; DATA XREF: .text:004F4BD8o
    mov     ebx, 1
    jmp     short loc_4F4936
    ; ---------------------------------------------------------------------------

    loc_4F492A:                             ; CODE XREF: sub_4F4880+98j
                                            ; DATA XREF: .text:004F4BDCo
    mov     ebx, 2
    jmp     short loc_4F4936
    ; ---------------------------------------------------------------------------

    loc_4F4931:                             ; CODE XREF: sub_4F4880+98j
                                            ; DATA XREF: .text:004F4BE0o
    mov     ebx, 3

    loc_4F4936:                             ; CODE XREF: sub_4F4880+A1j
                                            ; sub_4F4880+A8j ...
    mov     eax, ecx
    and     eax, 700h
    cmp     eax, 100h
    jg      short loc_4F4956
    jz      short loc_4F494F
    cmp     eax, esi
    jz      short loc_4F4986
    jmp     loc_4F4BB4
    ; ---------------------------------------------------------------------------

    loc_4F494F:                             ; CODE XREF: sub_4F4880+C4j
    mov     ebp, 4
    jmp     short loc_4F49AB
    ; ---------------------------------------------------------------------------

    loc_4F4956:                             ; CODE XREF: sub_4F4880+C2j
    cmp     eax, 300h
    jg      short loc_4F4972
    jz      short loc_4F496B
    cmp     eax, 200h
    jz      short loc_4F49A6
    jmp     loc_4F4BB4
    ; ---------------------------------------------------------------------------

    loc_4F496B:                             ; CODE XREF: sub_4F4880+DDj
    mov     ebp, 2
    jmp     short loc_4F49AB
    ; ---------------------------------------------------------------------------

    loc_4F4972:                             ; CODE XREF: sub_4F4880+DBj
    cmp     eax, 500h
    jg      short loc_4F498D
    jz      short loc_4F499F
    cmp     eax, 400h
    jnz     loc_4F4BB4

    loc_4F4986:                             ; CODE XREF: sub_4F4880+C8j
    mov     ebp, 3
    jmp     short loc_4F49AB
    ; ---------------------------------------------------------------------------

    loc_4F498D:                             ; CODE XREF: sub_4F4880+F7j
    cmp     eax, 600h
    jz      short loc_4F49A6
    cmp     eax, 700h
    jnz     loc_4F4BB4

    loc_4F499F:                             ; CODE XREF: sub_4F4880+F9j
    mov     ebp, 1
    jmp     short loc_4F49AB
    ; ---------------------------------------------------------------------------

    loc_4F49A6:                             ; CODE XREF: sub_4F4880+E4j
                                            ; sub_4F4880+112j
    mov     ebp, 5

    loc_4F49AB:                             ; CODE XREF: sub_4F4880+D4j
                                            ; sub_4F4880+F0j ...
    test    ch, 1
    mov     edi, 80h
    jz      short loc_4F49CC
    mov     esi, dword_529ECC
    mov     eax, [esp+24h+arg_C]
    not     esi
    and     eax, esi
    test    dl, al
    jnz     short loc_4F49CC
    mov     edi, 1

    loc_4F49CC:                             ; CODE XREF: sub_4F4880+133j
                                            ; sub_4F4880+145j
    test    cl, 40h
    jz      short loc_4F49E4
    mov     eax, [esp+24h+dwDesiredAccess]
    or      edi, 4000000h
    or      eax, 10000h
    mov     [esp+24h+dwDesiredAccess], eax

    loc_4F49E4:                             ; CODE XREF: sub_4F4880+14Fj
    test    ch, 10h
    jz      short loc_4F49EF
    or      edi, 100h

    loc_4F49EF:                             ; CODE XREF: sub_4F4880+167j
    test    cl, 20h
    jz      short loc_4F49FC
    or      edi, 8000000h
    jmp     short loc_4F4A07
    ; ---------------------------------------------------------------------------

    loc_4F49FC:                             ; CODE XREF: sub_4F4880+172j
    test    cl, 10h
    jz      short loc_4F4A07
    or      edi, 10000000h

    loc_4F4A07:                             ; CODE XREF: sub_4F4880+17Aj
                                            ; sub_4F4880+17Fj
    call    __alloc_osfhnd
    mov     esi, eax
    cmp     esi, 0FFFFFFFFh
    jnz     short loc_4F4A33
    call    __errno
    mov     dword ptr [eax], 18h
    call    ___doserrno
    mov     dword ptr [eax], 0
    or      eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F4A33:                             ; CODE XREF: sub_4F4880+191j
    mov     edx, [esp+24h+dwDesiredAccess]
    mov     eax, [esp+24h+lpFileName]
    push    0                               ; hTemplateFile
    push    edi                             ; dwFlagsAndAttributes
    lea     ecx, [esp+2Ch+SecurityAttributes]
    push    ebp                             ; dwCreationDisposition
    push    ecx                             ; lpSecurityAttributes
    push    ebx                             ; dwShareMode
    push    edx                             ; dwDesiredAccess
    push    eax                             ; lpFileName
    call    ds:CreateFileA
    mov     edi, eax
    cmp     edi, 0FFFFFFFFh
    jz      short loc_4F4A66
    push    edi                             ; hFile
    call    ds:GetFileType
    test    eax, eax
    jnz     short loc_4F4A89
    push    edi                             ; hObject
    call    ds:CloseHandle

    loc_4F4A66:                             ; CODE XREF: sub_4F4880+1D2j
    call    ds:GetLastError
    push    eax
    call    __dosmaperr
    add     esp, 4
    push    esi
    call    __unlock_fhandle
    add     esp, 4
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F4A89:                             ; CODE XREF: sub_4F4880+1DDj
    cmp     eax, 2
    jnz     short loc_4F4A96
    mov     al, [esp+24h+var_11]
    or      al, 40h
    jmp     short loc_4F4AA1
    ; ---------------------------------------------------------------------------

    loc_4F4A96:                             ; CODE XREF: sub_4F4880+20Cj
    cmp     eax, 3
    jnz     short loc_4F4AA5
    mov     al, [esp+24h+var_11]
    or      al, 8

    loc_4F4AA1:                             ; CODE XREF: sub_4F4880+214j
    mov     [esp+24h+var_11], al

    loc_4F4AA5:                             ; CODE XREF: sub_4F4880+219j
    push    edi
    push    esi
    call    __set_osfhnd
    mov     bl, [esp+2Ch+var_11]
    mov     eax, esi
    mov     ecx, esi
    or      bl, 1
    and     eax, 1Fh
    mov     [esp+2Ch+var_11], bl
    sar     ecx, 5
    lea     edi, [eax+eax*8]
    mov     al, [esp+2Ch+var_11]
    mov     edx, dword_52B540[ecx*4]
    lea     ebx, ds:52B540h[ecx*4]
    mov     cl, al
    add     esp, 8
    shl     edi, 2
    and     cl, 48h
    mov     [edi+edx+4], al
    mov     byte ptr [esp+24h+lpFileName], cl
    jnz     loc_4F4B83
    test    al, 80h
    jz      loc_4F4B83
    test    byte ptr [esp+24h+arg_4], 2
    jz      loc_4F4B83
    push    2                               ; dwMoveMethod
    push    0FFFFFFFFh                      ; lDistanceToMove
    push    esi                             ; int
    call    __lseek_lk
    mov     ebp, eax
    add     esp, 0Ch
    cmp     ebp, 0FFFFFFFFh
    jnz     short loc_4F4B25
    call    ___doserrno
    cmp     dword ptr [eax], 83h
    jz      short loc_4F4B83
    jmp     short loc_4F4B66
    ; ---------------------------------------------------------------------------

    loc_4F4B25:                             ; CODE XREF: sub_4F4880+294j
    lea     eax, [esp+24h+arg_8]
    push    1                               ; nNumberOfBytesToRead
    push    eax                             ; int
    push    esi                             ; int
    mov     byte ptr [esp+30h+arg_8], 0
    call    __read_lk
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4F4B54
    cmp     byte ptr [esp+24h+arg_8], 1Ah
    jnz     short loc_4F4B54
    push    ebp
    push    esi
    call    __chsize_lk
    add     esp, 8
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4F4B66

    loc_4F4B54:                             ; CODE XREF: sub_4F4880+2BCj
                                            ; sub_4F4880+2C3j
    push    0                               ; dwMoveMethod
    push    0                               ; lDistanceToMove
    push    esi                             ; int
    call    __lseek_lk
    add     esp, 0Ch
    cmp     eax, 0FFFFFFFFh
    jnz     short loc_4F4B83

    loc_4F4B66:                             ; CODE XREF: sub_4F4880+2A3j
                                            ; sub_4F4880+2D2j
    push    esi
    call    __close
    add     esp, 4
    push    esi
    call    __unlock_fhandle
    add     esp, 4
    or      eax, 0FFFFFFFFh
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F4B83:                             ; CODE XREF: sub_4F4880+269j
                                            ; sub_4F4880+271j ...
    mov     al, byte ptr [esp+24h+lpFileName]
    test    al, al
    jnz     short loc_4F4BA1
    test    byte ptr [esp+24h+arg_4], 8
    jz      short loc_4F4BA1
    mov     ecx, [ebx]
    lea     eax, [edi+ecx+4]
    mov     cl, [edi+ecx+4]
    or      cl, 20h
    mov     [eax], cl

    loc_4F4BA1:                             ; CODE XREF: sub_4F4880+309j
                                            ; sub_4F4880+310j
    push    esi
    call    __unlock_fhandle
    add     esp, 4
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F4BB4:                             ; CODE XREF: sub_4F4880+5Ej
                                            ; sub_4F4880+8Aj ...
    call    __errno
    mov     dword ptr [eax], 16h
    call    ___doserrno
    mov     [eax], esi
    pop     edi
    pop     esi
    pop     ebp
    or      eax, 0FFFFFFFFh
    pop     ebx
    add     esp, 14h
    retn
    sub_4F4880 endp

    ; ---------------------------------------------------------------------------
    align 4
    off_4F4BD4 dd offset loc_4F491F         ; DATA XREF: sub_4F4880+98r
    dd offset loc_4F4923
    dd offset loc_4F492A
    dd offset loc_4F4931
    dd offset loc_4F4BB4
    byte_4F4BE8 db 0                        ; DATA XREF: sub_4F4880+92r
    ; ---------------------------------------------------------------------------
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 1
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 2
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 4
    add     al, 3
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_105. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000117 BYTES: COLLAPSED FUNCTION unknown_libname_106. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    unknown_libname_107:
    sub     esp, 2Ch
    and     eax, 3Fh
    jmp     off_510D7E[eax*4]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4D54 proc near                    ; DATA XREF: .data:00510D7Eo
    fdiv    st, st
    add     esp, 2Ch
    retn
    sub_4F4D54 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4D5A proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510D82o
    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4D5F:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510D86o
    fdivr   st, st
    add     esp, 2Ch
    retn
    sub_4F4D5A endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4D65 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510D8Ao
    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4D6A:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510D8Eo
    fdiv    st, st
    add     esp, 2Ch
    retn
    sub_4F4D65 endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4D70 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510D92o
    fdivp   st, st
    add     esp, 2Ch
    retn
    sub_4F4D70 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4D76 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510D96o
    fdivr   st, st
    add     esp, 2Ch
    retn
    sub_4F4D76 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4D7C proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510D9Ao
    fdivrp  st, st
    add     esp, 2Ch
    retn
    sub_4F4D7C endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4D82 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510D9Eo

    arg_8= tbyte ptr  0Ch
    arg_1C= tbyte ptr  20h

    fstp    [esp+arg_8]
    fld     st
    fstp    tbyte ptr [esp+0]
    fstp    [esp+arg_1C]
    call    unknown_libname_106
    fld     [esp+arg_1C]
    fxch    st(1)
    add     esp, 2Ch
    retn
    sub_4F4D82 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4D9E proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DA2o

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4DA3:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DA6o
    fstp    [esp-2Ch+arg_28]
    fstp    [esp-2Ch+arg_34]
    call    unknown_libname_106
    fld     [esp-2Ch+arg_34]
    fxch    st(1)
    add     esp, 2Ch
    retn
    sub_4F4D9E endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4DB9 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DAAo

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h
    arg_48= tbyte ptr  4Ch

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4DBE:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DAEo
    fxch    st(1)
    fstp    [esp-2Ch+arg_34]
    fld     st
    fstp    [esp-2Ch+arg_28]
    fstp    [esp-2Ch+arg_48]
    call    unknown_libname_106
    fld     [esp-2Ch+arg_48]
    add     esp, 2Ch
    retn
    sub_4F4DB9 endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4DDA proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DB2o

    arg_8= tbyte ptr  0Ch

    fstp    tbyte ptr [esp+0]
    fstp    [esp+arg_8]
    call    unknown_libname_106
    add     esp, 2Ch
    retn
    sub_4F4DDA endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4DEA proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DB6o

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fld     [esp+arg_8]
    add     esp, 2Ch
    retn
    sub_4F4DEA endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4DFE proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DBAo

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    add     esp, 2Ch
    retn
    sub_4F4DFE endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4E0E proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DBEo

    arg_8= tbyte ptr  0Ch
    arg_1C= tbyte ptr  20h

    fstp    [esp+arg_8]
    fxch    st(1)
    fld     st
    fstp    tbyte ptr [esp+0]
    fstp    [esp+arg_1C]
    call    unknown_libname_106
    fxch    st(1)
    fld     [esp+arg_1C]
    fxch    st(2)
    add     esp, 2Ch
    retn
    sub_4F4E0E endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4E2E proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DC2o

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4E33:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DC6o
    fstp    [esp-2Ch+arg_28]
    fxch    st(1)
    fstp    [esp-2Ch+arg_34]
    call    unknown_libname_106
    fxch    st(1)
    fld     [esp-2Ch+arg_34]
    fxch    st(2)
    add     esp, 2Ch
    retn
    sub_4F4E2E endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4E4D proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DCAo

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h
    arg_48= tbyte ptr  4Ch

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4E52:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DCEo
    fxch    st(2)
    fstp    [esp-2Ch+arg_34]
    fxch    st(1)
    fld     st
    fstp    [esp-2Ch+arg_28]
    fstp    [esp-2Ch+arg_48]
    call    unknown_libname_106
    fxch    st(1)
    fld     [esp-2Ch+arg_48]
    add     esp, 2Ch
    retn
    sub_4F4E4D endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4E72 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DD2o

    arg_8= tbyte ptr  0Ch

    fstp    tbyte ptr [esp+0]
    fxch    st(1)
    fstp    [esp+arg_8]
    call    unknown_libname_106
    fxch    st(1)
    add     esp, 2Ch
    retn
    sub_4F4E72 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4E86 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DD6o

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(1)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(1)
    fld     [esp+arg_8]
    add     esp, 2Ch
    retn
    sub_4F4E86 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4E9E proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DDAo

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(1)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(1)
    add     esp, 2Ch
    retn
    sub_4F4E9E endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4EB2 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DDEo

    arg_8= tbyte ptr  0Ch
    arg_1C= tbyte ptr  20h

    fstp    [esp+arg_8]
    fxch    st(2)
    fld     st
    fstp    tbyte ptr [esp+0]
    fstp    [esp+arg_1C]
    call    unknown_libname_106
    fxch    st(2)
    fld     [esp+arg_1C]
    fxch    st(3)
    add     esp, 2Ch
    retn
    sub_4F4EB2 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4ED2 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DE2o

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4ED7:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DE6o
    fstp    [esp-2Ch+arg_28]
    fxch    st(2)
    fstp    [esp-2Ch+arg_34]
    call    unknown_libname_106
    fxch    st(2)
    fld     [esp-2Ch+arg_34]
    fxch    st(3)
    add     esp, 2Ch
    retn
    sub_4F4ED2 endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4EF1 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DEAo

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h
    arg_48= tbyte ptr  4Ch

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4EF6:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DEEo
    fxch    st(3)
    fstp    [esp-2Ch+arg_34]
    fxch    st(2)
    fld     st
    fstp    [esp-2Ch+arg_28]
    fstp    [esp-2Ch+arg_48]
    call    unknown_libname_106
    fxch    st(2)
    fld     [esp-2Ch+arg_48]
    add     esp, 2Ch
    retn
    sub_4F4EF1 endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4F16 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DF2o

    arg_8= tbyte ptr  0Ch

    fstp    tbyte ptr [esp+0]
    fxch    st(2)
    fstp    [esp+arg_8]
    call    unknown_libname_106
    fxch    st(2)
    add     esp, 2Ch
    retn
    sub_4F4F16 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4F2A proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DF6o

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(2)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(2)
    fld     [esp+arg_8]
    add     esp, 2Ch
    retn
    sub_4F4F2A endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4F42 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DFAo

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(2)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(2)
    add     esp, 2Ch
    retn
    sub_4F4F42 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4F56 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510DFEo

    arg_8= tbyte ptr  0Ch
    arg_1C= tbyte ptr  20h

    fstp    [esp+arg_8]
    fxch    st(3)
    fld     st
    fstp    tbyte ptr [esp+0]
    fstp    [esp+arg_1C]
    call    unknown_libname_106
    fxch    st(3)
    fld     [esp+arg_1C]
    fxch    st(4)
    add     esp, 2Ch
    retn
    sub_4F4F56 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4F76 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E02o

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4F7B:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E06o
    fstp    [esp-2Ch+arg_28]
    fxch    st(3)
    fstp    [esp-2Ch+arg_34]
    call    unknown_libname_106
    fxch    st(3)
    fld     [esp-2Ch+arg_34]
    fxch    st(4)
    add     esp, 2Ch
    retn
    sub_4F4F76 endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4F95 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E0Ao

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h
    arg_48= tbyte ptr  4Ch

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F4F9A:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E0Eo
    fxch    st(4)
    fstp    [esp-2Ch+arg_34]
    fxch    st(3)
    fld     st
    fstp    [esp-2Ch+arg_28]
    fstp    [esp-2Ch+arg_48]
    call    unknown_libname_106
    fxch    st(3)
    fld     [esp-2Ch+arg_48]
    add     esp, 2Ch
    retn
    sub_4F4F95 endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4FBA proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E12o

    arg_8= tbyte ptr  0Ch

    fstp    tbyte ptr [esp+0]
    fxch    st(3)
    fstp    [esp+arg_8]
    call    unknown_libname_106
    fxch    st(3)
    add     esp, 2Ch
    retn
    sub_4F4FBA endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4FCE proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E16o

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(3)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(3)
    fld     [esp+arg_8]
    add     esp, 2Ch
    retn
    sub_4F4FCE endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4FE6 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E1Ao

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(3)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(3)
    add     esp, 2Ch
    retn
    sub_4F4FE6 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F4FFA proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E1Eo

    arg_8= tbyte ptr  0Ch
    arg_1C= tbyte ptr  20h

    fstp    [esp+arg_8]
    fxch    st(4)
    fld     st
    fstp    tbyte ptr [esp+0]
    fstp    [esp+arg_1C]
    call    unknown_libname_106
    fxch    st(4)
    fld     [esp+arg_1C]
    fxch    st(5)
    add     esp, 2Ch
    retn
    sub_4F4FFA endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F501A proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E22o

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F501F:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E26o
    fstp    [esp-2Ch+arg_28]
    fxch    st(4)
    fstp    [esp-2Ch+arg_34]
    call    unknown_libname_106
    fxch    st(4)
    fld     [esp-2Ch+arg_34]
    fxch    st(5)
    add     esp, 2Ch
    retn
    sub_4F501A endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F5039 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E2Ao

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h
    arg_48= tbyte ptr  4Ch

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F503E:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E2Eo
    fxch    st(5)
    fstp    [esp-2Ch+arg_34]
    fxch    st(4)
    fld     st
    fstp    [esp-2Ch+arg_28]
    fstp    [esp-2Ch+arg_48]
    call    unknown_libname_106
    fxch    st(4)
    fld     [esp-2Ch+arg_48]
    add     esp, 2Ch
    retn
    sub_4F5039 endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F505E proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E32o

    arg_8= tbyte ptr  0Ch

    fstp    tbyte ptr [esp+0]
    fxch    st(4)
    fstp    [esp+arg_8]
    call    unknown_libname_106
    fxch    st(4)
    add     esp, 2Ch
    retn
    sub_4F505E endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F5072 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E36o

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(4)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(4)
    fld     [esp+arg_8]
    add     esp, 2Ch
    retn
    sub_4F5072 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F508A proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E3Ao

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(4)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(4)
    add     esp, 2Ch
    retn
    sub_4F508A endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F509E proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E3Eo

    arg_8= tbyte ptr  0Ch
    arg_1C= tbyte ptr  20h

    fstp    [esp+arg_8]
    fxch    st(5)
    fld     st
    fstp    tbyte ptr [esp+0]
    fstp    [esp+arg_1C]
    call    unknown_libname_106
    fxch    st(5)
    fld     [esp+arg_1C]
    fxch    st(6)
    add     esp, 2Ch
    retn
    sub_4F509E endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F50BE proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E42o

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F50C3:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E46o
    fstp    [esp-2Ch+arg_28]
    fxch    st(5)
    fstp    [esp-2Ch+arg_34]
    call    unknown_libname_106
    fxch    st(5)
    fld     [esp-2Ch+arg_34]
    fxch    st(6)
    add     esp, 2Ch
    retn
    sub_4F50BE endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F50DD proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E4Ao

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h
    arg_48= tbyte ptr  4Ch

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F50E2:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E4Eo
    fxch    st(6)
    fstp    [esp-2Ch+arg_34]
    fxch    st(5)
    fld     st
    fstp    [esp-2Ch+arg_28]
    fstp    [esp-2Ch+arg_48]
    call    unknown_libname_106
    fxch    st(5)
    fld     [esp-2Ch+arg_48]
    add     esp, 2Ch
    retn
    sub_4F50DD endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F5102 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E52o

    arg_8= tbyte ptr  0Ch

    fstp    tbyte ptr [esp+0]
    fxch    st(5)
    fstp    [esp+arg_8]
    call    unknown_libname_106
    fxch    st(5)
    add     esp, 2Ch
    retn
    sub_4F5102 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F5116 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E56o

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(5)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(5)
    fld     [esp+arg_8]
    add     esp, 2Ch
    retn
    sub_4F5116 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F512E proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E5Ao

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(5)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(5)
    add     esp, 2Ch
    retn
    sub_4F512E endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F5142 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E5Eo

    arg_8= tbyte ptr  0Ch
    arg_1C= tbyte ptr  20h

    fstp    [esp+arg_8]
    fxch    st(6)
    fld     st
    fstp    tbyte ptr [esp+0]
    fstp    [esp+arg_1C]
    call    unknown_libname_106
    fxch    st(6)
    fld     [esp+arg_1C]
    fxch    st(7)
    add     esp, 2Ch
    retn
    sub_4F5142 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F5162 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E62o

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F5167:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E66o
    fstp    [esp-2Ch+arg_28]
    fxch    st(6)
    fstp    [esp-2Ch+arg_34]
    call    unknown_libname_106
    fxch    st(6)
    fld     [esp-2Ch+arg_34]
    fxch    st(7)
    add     esp, 2Ch
    retn
    sub_4F5162 endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F5181 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E6Ao

    arg_28= tbyte ptr  2Ch
    arg_34= tbyte ptr  38h
    arg_48= tbyte ptr  4Ch

    add     esp, 2Ch
    int     6                               ;  - internal hardware - UNDEFINED OPCODE (80286+)

    loc_4F5186:                             ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E6Eo
    fxch    st(7)
    fstp    [esp-2Ch+arg_34]
    fxch    st(6)
    fld     st
    fstp    [esp-2Ch+arg_28]
    fstp    [esp-2Ch+arg_48]
    call    unknown_libname_106
    fxch    st(6)
    fld     [esp-2Ch+arg_48]
    add     esp, 2Ch
    retn
    sub_4F5181 endp ; sp =  58h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F51A6 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E72o

    arg_8= tbyte ptr  0Ch

    fstp    tbyte ptr [esp+0]
    fxch    st(6)
    fstp    [esp+arg_8]
    call    unknown_libname_106
    fxch    st(6)
    add     esp, 2Ch
    retn
    sub_4F51A6 endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F51BA proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E76o

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(6)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(6)
    fld     [esp+arg_8]
    add     esp, 2Ch
    retn
    sub_4F51BA endp ; sp =  2Ch

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F51D2 proc near                    ; CODE XREF: .text:004F4D4Dj
                                            ; DATA XREF: .data:00510E7Ao

    arg_8= tbyte ptr  0Ch

    fstp    [esp+arg_8]
    fxch    st(6)
    fstp    tbyte ptr [esp+0]
    call    unknown_libname_106
    fxch    st(6)
    add     esp, 2Ch
    retn
    sub_4F51D2 endp ; sp =  2Ch

    ; [00000013 BYTES: COLLAPSED FUNCTION unknown_libname_108. PRESS KEYPAD "+" TO EXPAND]
    ; [00000013 BYTES: COLLAPSED FUNCTION unknown_libname_109. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    unknown_libname_110:
    push    eax
    mov     eax, [esp+8]
    and     eax, 7F800000h
    cmp     eax, 7F800000h
    jz      short loc_4F5250
    fnstsw  ax
    and     eax, 3800h
    jz      short loc_4F5233
    fld     dword ptr [esp+8]
    call    unknown_libname_108
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F5233:                             ; CODE XREF: .text:004F5224j
    fxch    st(1)
    sub     esp, 0Ch
    fstp    tbyte ptr [esp]
    fld     dword ptr [esp+14h]
    call    unknown_libname_108
    fld     tbyte ptr [esp]
    fxch    st(1)
    add     esp, 0Ch
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F5250:                             ; CODE XREF: .text:004F521Bj
    fdiv    dword ptr [esp+8]
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    unknown_libname_111:
    push    eax
    mov     eax, [esp+0Ch]
    and     eax, 7FF00000h
    cmp     eax, 7FF00000h
    jz      short loc_4F529C
    fnstsw  ax
    and     eax, 3800h
    jz      short loc_4F527F
    fld     qword ptr [esp+8]
    call    unknown_libname_108
    pop     eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4F527F:                             ; CODE XREF: .text:004F5270j
    fxch    st(1)
    sub     esp, 0Ch
    fstp    tbyte ptr [esp]
    fld     qword ptr [esp+14h]
    call    unknown_libname_108
    fld     tbyte ptr [esp]
    fxch    st(1)
    add     esp, 0Ch
    pop     eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4F529C:                             ; CODE XREF: .text:004F5267j
    fdiv    qword ptr [esp+8]
    pop     eax
    retn    8
    ; ---------------------------------------------------------------------------

    unknown_libname_112:
    push    eax
    fnstsw  ax
    and     eax, 3800h
    jz      short loc_4F52BB
    fild    word ptr [esp+8]
    call    unknown_libname_108
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F52BB:                             ; CODE XREF: .text:004F52ACj
    fxch    st(1)
    sub     esp, 0Ch
    fstp    tbyte ptr [esp]
    fild    word ptr [esp+14h]
    call    unknown_libname_108
    fld     tbyte ptr [esp]
    fxch    st(1)
    add     esp, 0Ch
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    unknown_libname_113:
    push    eax
    fnstsw  ax
    and     eax, 3800h
    jz      short loc_4F52EF
    fild    dword ptr [esp+8]
    call    unknown_libname_108
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F52EF:                             ; CODE XREF: .text:004F52E0j
    fxch    st(1)
    sub     esp, 0Ch
    fstp    tbyte ptr [esp]
    fild    dword ptr [esp+14h]
    call    unknown_libname_108
    fld     tbyte ptr [esp]
    fxch    st(1)
    add     esp, 0Ch
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    unknown_libname_114:
    push    eax
    mov     eax, [esp+8]
    and     eax, 7F800000h
    cmp     eax, 7F800000h
    jz      short loc_4F5350
    fnstsw  ax
    and     eax, 3800h
    jz      short loc_4F5333
    fld     dword ptr [esp+8]
    call    unknown_libname_109
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F5333:                             ; CODE XREF: .text:004F5324j
    fxch    st(1)
    sub     esp, 0Ch
    fstp    tbyte ptr [esp]
    fld     dword ptr [esp+14h]
    call    unknown_libname_109
    fld     tbyte ptr [esp]
    fxch    st(1)
    add     esp, 0Ch
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F5350:                             ; CODE XREF: .text:004F531Bj
    fdivr   dword ptr [esp+8]
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    unknown_libname_115:
    push    eax
    mov     eax, [esp+0Ch]
    and     eax, 7FF00000h
    cmp     eax, 7FF00000h
    jz      short loc_4F539C
    fnstsw  ax
    and     eax, 3800h
    jz      short loc_4F537F
    fld     qword ptr [esp+8]
    call    unknown_libname_109
    pop     eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4F537F:                             ; CODE XREF: .text:004F5370j
    fxch    st(1)
    sub     esp, 0Ch
    fstp    tbyte ptr [esp]
    fld     qword ptr [esp+14h]
    call    unknown_libname_109
    fld     tbyte ptr [esp]
    fxch    st(1)
    add     esp, 0Ch
    pop     eax
    retn    8
    ; ---------------------------------------------------------------------------

    loc_4F539C:                             ; CODE XREF: .text:004F5367j
    fdivr   qword ptr [esp+8]
    pop     eax
    retn    8
    ; ---------------------------------------------------------------------------

    unknown_libname_116:
    push    eax
    fnstsw  ax
    and     eax, 3800h
    jz      short loc_4F53BB
    fild    word ptr [esp+8]
    call    unknown_libname_109
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F53BB:                             ; CODE XREF: .text:004F53ACj
    fxch    st(1)
    sub     esp, 0Ch
    fstp    tbyte ptr [esp]
    fild    word ptr [esp+14h]
    call    unknown_libname_109
    fld     tbyte ptr [esp]
    fxch    st(1)
    add     esp, 0Ch
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    unknown_libname_117:
    push    eax
    fnstsw  ax
    and     eax, 3800h
    jz      short loc_4F53EF
    fild    dword ptr [esp+8]
    call    unknown_libname_109
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F53EF:                             ; CODE XREF: .text:004F53E0j
    fxch    st(1)
    sub     esp, 0Ch
    fstp    tbyte ptr [esp]
    fild    dword ptr [esp+14h]
    call    unknown_libname_109
    fld     tbyte ptr [esp]
    fxch    st(1)
    add     esp, 0Ch
    pop     eax
    retn    4
    ; ---------------------------------------------------------------------------

    unknown_libname_118:
    push    eax
    sub     esp, 2Ch
    fstp    tbyte ptr [esp]
    fstp    tbyte ptr [esp+0Ch]
    call    unknown_libname_106
    add     esp, 2Ch
    pop     eax
    retn
    ; [00000015 BYTES: COLLAPSED FUNCTION unknown_libname_119. PRESS KEYPAD "+" TO EXPAND]
    ; [00000206 BYTES: COLLAPSED FUNCTION unknown_libname_120. PRESS KEYPAD "+" TO EXPAND]
    ; [000000B2 BYTES: COLLAPSED FUNCTION unknown_libname_121. PRESS KEYPAD "+" TO EXPAND]
    ; [00000206 BYTES: COLLAPSED FUNCTION unknown_libname_122. PRESS KEYPAD "+" TO EXPAND]
    ; [000000B5 BYTES: COLLAPSED FUNCTION unknown_libname_123. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------

    unknown_libname_124:
    call    unknown_libname_121
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_125:
    call    unknown_libname_123
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_126:
    fpatan
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_127:
    fptan
    retn
    ; ---------------------------------------------------------------------------
    align 8
    ; [00000100 BYTES: COLLAPSED FUNCTION __87except. PRESS KEYPAD "+" TO EXPAND]
    off_4F5AC0 dd offset loc_4F59E6         ; DATA XREF: __87except+1Fr
    dd offset loc_4F5AA4                    ; jump table for switch statement
    dd offset loc_4F5A90
    dd offset loc_4F5A9A
    dd offset loc_4F59E6
    dd offset loc_4F5A50
    dd offset loc_4F5AB8
    dd offset loc_4F5AAE
    ; [0000002B BYTES: COLLAPSED FUNCTION __copysign. PRESS KEYPAD "+" TO EXPAND]
    align 8

    __chgsign:
    sub     esp, 8
    mov     eax, [esp+0Ch]
    mov     [esp+0], eax
    mov     eax, [esp+10h]
    mov     ecx, eax
    not     ecx
    xor     eax, ecx
    and     eax, 7FFFFFFFh
    xor     eax, ecx
    mov     [esp+4], eax
    fld     qword ptr [esp+0]
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    mov     eax, [esp+0Ch]
    mov     ecx, [esp+8]
    mov     edx, [esp+4]
    push    eax
    push    ecx
    push    edx
    call    _ldexp
    add     esp, 0Ch
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __logb:
    push    ecx
    push    ebx
    push    esi
    push    edi
    push    0FFFFh
    push    133Fh
    call    __ctrlfp
    mov     esi, eax
    mov     eax, [esp+22h]
    and     eax, 7FF0h
    add     esp, 8
    cmp     eax, 7FF0h
    jnz     short loc_4F5BF5
    mov     edi, [esp+18h]
    mov     ebx, [esp+14h]
    push    edi
    push    ebx
    call    __sptype
    add     esp, 8
    test    eax, eax
    jle     short loc_4F5BD1
    cmp     eax, 2
    jle     short loc_4F5BBA
    cmp     eax, 3
    jnz     short loc_4F5BD1
    push    esi
    push    edi
    push    ebx
    push    25h
    call    __handle_qnan1
    add     esp, 10h
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5BBA:                             ; CODE XREF: .text:004F5BA1j
    push    0FFFFh
    push    esi
    call    __ctrlfp
    fld     qword ptr [esp+1Ch]
    add     esp, 8
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5BD1:                             ; CODE XREF: .text:004F5B9Cj
                                            ; .text:004F5BA6j
    fld     qword ptr [esp+14h]
    fsub    ds:dbl_4FE378
    push    esi
    sub     esp, 8
    fstp    qword ptr [esp]
    push    edi
    push    ebx
    push    25h
    push    8
    call    __except1
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5BF5:                             ; CODE XREF: .text:004F5B86j
    fld     qword ptr [esp+14h]
    fcomp   ds:dbl_4FE380
    fnstsw  ax
    test    ah, 40h
    jz      short loc_4F5C30
    fld     dbl_50E318
    mov     ecx, [esp+18h]
    mov     edx, [esp+14h]
    push    esi
    sub     esp, 8
    fchs
    fstp    qword ptr [esp]
    push    ecx
    push    edx
    push    25h
    push    4
    call    __except1
    add     esp, 1Ch
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5C30:                             ; CODE XREF: .text:004F5C04j
    mov     ecx, [esp+18h]
    mov     edx, [esp+14h]
    lea     eax, [esp+0Ch]
    push    eax
    push    ecx
    push    edx
    call    __decomp
    mov     eax, [esp+18h]
    add     esp, 0Ch
    dec     eax
    fstp    st
    mov     [esp+14h], eax
    push    0FFFFh
    fild    dword ptr [esp+18h]
    push    esi
    fstp    qword ptr [esp+1Ch]
    call    __ctrlfp
    fld     qword ptr [esp+1Ch]
    add     esp, 8
    pop     edi
    pop     esi
    pop     ebx
    pop     ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __nextafter:
    sub     esp, 14h
    push    ebx
    push    ebp
    push    esi
    push    edi
    push    0FFFFh
    push    133Fh
    call    __ctrlfp
    mov     ebx, eax
    mov     eax, [esp+36h]
    mov     esi, [esp+34h]
    mov     edi, [esp+30h]
    mov     ebp, [esp+3Ch]
    mov     ecx, eax
    and     ecx, 7FF0h
    add     esp, 8
    cmp     ecx, 7FF0h
    mov     ecx, [esp+36h]
    jz      short loc_4F5CCF
    mov     edx, ecx
    and     edx, 7FF0h
    cmp     edx, 7FF0h
    jnz     short loc_4F5D43

    loc_4F5CCF:                             ; CODE XREF: .text:004F5CBDj
    and     eax, 7FF8h
    cmp     ax, 7FF0h
    jnz     short loc_4F5CE6
    test    esi, 7FFFFh
    jnz     short loc_4F5D03
    test    edi, edi
    jnz     short loc_4F5D03

    loc_4F5CE6:                             ; CODE XREF: .text:004F5CD8j
    and     ecx, 7FF8h
    cmp     cx, 7FF0h
    jnz     short loc_4F5D2E
    test    ebp, 7FFFFh
    jnz     short loc_4F5D03
    mov     edx, [esp+30h]
    test    edx, edx
    jz      short loc_4F5D2E

    loc_4F5D03:                             ; CODE XREF: .text:004F5CE0j
                                            ; .text:004F5CE4j ...
    fld     qword ptr [esp+30h]
    fadd    qword ptr [esp+28h]
    mov     eax, [esp+30h]
    push    ebx
    sub     esp, 8
    fstp    qword ptr [esp]
    push    ebp
    push    eax
    push    esi
    push    edi
    push    26h
    push    8
    call    __except2
    add     esp, 24h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5D2E:                             ; CODE XREF: .text:004F5CF1j
                                            ; .text:004F5D01j
    cmp     ax, 7FF8h
    jz      loc_4F5F5C
    cmp     cx, 7FF8h
    jz      loc_4F5F5C

    loc_4F5D43:                             ; CODE XREF: .text:004F5CCDj
    fld     qword ptr [esp+30h]
    fcomp   qword ptr [esp+28h]
    fnstsw  ax
    test    ah, 40h
    jz      short loc_4F5D6C
    push    0FFFFh
    push    ebx
    call    __ctrlfp
    fld     qword ptr [esp+30h]
    add     esp, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5D6C:                             ; CODE XREF: .text:004F5D50j
    fld     qword ptr [esp+28h]
    fcomp   ds:dbl_4FE380
    fnstsw  ax
    test    ah, 40h
    jz      short loc_4F5DA8
    fld     qword ptr [esp+30h]
    fcomp   qword ptr [esp+28h]
    mov     edx, 1
    mov     [esp+18h], edx
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4F5D9D
    xor     ecx, ecx
    mov     [esp+1Ch], ecx
    jmp     short loc_4F5DB0
    ; ---------------------------------------------------------------------------

    loc_4F5D9D:                             ; CODE XREF: .text:004F5D93j
    mov     ecx, 80000000h
    mov     [esp+1Ch], ecx
    jmp     short loc_4F5DB0
    ; ---------------------------------------------------------------------------

    loc_4F5DA8:                             ; CODE XREF: .text:004F5D7Bj
    mov     edx, [esp+18h]
    mov     ecx, [esp+1Ch]

    loc_4F5DB0:                             ; CODE XREF: .text:004F5D9Bj
                                            ; .text:004F5DA6j
    fld     qword ptr [esp+28h]
    fcomp   ds:dbl_4FE380
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4F5DD0
    fld     qword ptr [esp+30h]
    fcomp   qword ptr [esp+28h]
    fnstsw  ax
    test    ah, 1
    jnz     short loc_4F5DF0

    loc_4F5DD0:                             ; CODE XREF: .text:004F5DBFj
    fld     qword ptr [esp+28h]
    fcomp   ds:dbl_4FE380
    fnstsw  ax
    test    ah, 1
    jz      short loc_4F5E06
    fld     qword ptr [esp+30h]
    fcomp   qword ptr [esp+28h]
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4F5E06

    loc_4F5DF0:                             ; CODE XREF: .text:004F5DCEj
    lea     edx, [edi-1]
    mov     ecx, esi
    test    edi, edi
    mov     [esp+18h], edx
    mov     [esp+1Ch], ecx
    jnz     short loc_4F5E5E
    lea     ecx, [esi-1]
    jmp     short loc_4F5E5A
    ; ---------------------------------------------------------------------------

    loc_4F5E06:                             ; CODE XREF: .text:004F5DDFj
                                            ; .text:004F5DEEj
    fld     qword ptr [esp+28h]
    fcomp   ds:dbl_4FE380
    fnstsw  ax
    test    ah, 41h
    jnz     short loc_4F5E26
    fld     qword ptr [esp+30h]
    fcomp   qword ptr [esp+28h]
    fnstsw  ax
    test    ah, 41h
    jz      short loc_4F5E46

    loc_4F5E26:                             ; CODE XREF: .text:004F5E15j
    fld     qword ptr [esp+28h]
    fcomp   ds:dbl_4FE380
    fnstsw  ax
    test    ah, 1
    jz      short loc_4F5E5E
    fld     qword ptr [esp+30h]
    fcomp   qword ptr [esp+28h]
    fnstsw  ax
    test    ah, 1
    jz      short loc_4F5E5E

    loc_4F5E46:                             ; CODE XREF: .text:004F5E24j
    lea     edx, [edi+1]
    mov     ecx, esi
    test    edx, edx
    mov     [esp+18h], edx
    mov     [esp+1Ch], ecx
    jnz     short loc_4F5E5E
    lea     ecx, [esi+1]

    loc_4F5E5A:                             ; CODE XREF: .text:004F5E04j
    mov     [esp+1Ch], ecx

    loc_4F5E5E:                             ; CODE XREF: .text:004F5DFFj
                                            ; .text:004F5E35j ...
    test    dword ptr [esp+1Eh], 7FF0h
    jnz     short loc_4F5ECF
    test    ecx, 0FFFFFh
    jnz     short loc_4F5E74
    test    edx, edx
    jz      short loc_4F5ECF

    loc_4F5E74:                             ; CODE XREF: .text:004F5E6Ej
    lea     eax, [esp+28h]
    push    eax
    push    ecx
    push    edx
    call    __decomp
    mov     ecx, [esp+34h]
    add     esp, 0Ch
    fstp    qword ptr [esp+10h]
    mov     edx, [esp+14h]
    mov     eax, [esp+10h]
    add     ecx, 600h
    push    ecx
    push    edx
    push    eax
    call    __set_exp
    fstp    qword ptr [esp+24h]
    mov     ecx, [esp+28h]
    mov     edx, [esp+24h]
    mov     eax, [esp+3Ch]
    add     esp, 0Ch
    push    ebx
    push    ecx
    push    edx
    push    ebp
    push    eax
    push    esi
    push    edi
    push    26h
    push    12h
    call    __except2
    add     esp, 24h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5ECF:                             ; CODE XREF: .text:004F5E66j
                                            ; .text:004F5E72j
    cmp     ecx, 7FF00000h
    jnz     short loc_4F5EDB
    test    edx, edx
    jz      short loc_4F5EE7

    loc_4F5EDB:                             ; CODE XREF: .text:004F5ED5j
    cmp     ecx, 0FFF00000h
    jnz     short loc_4F5F42
    test    edx, edx
    jnz     short loc_4F5F42

    loc_4F5EE7:                             ; CODE XREF: .text:004F5ED9j
    lea     eax, [esp+28h]
    push    eax
    push    ecx
    push    edx
    call    __decomp
    mov     ecx, [esp+34h]
    add     esp, 0Ch
    fstp    qword ptr [esp+10h]
    mov     edx, [esp+14h]
    mov     eax, [esp+10h]
    add     ecx, 0FFFFFA00h
    push    ecx
    push    edx
    push    eax
    call    __set_exp
    fstp    qword ptr [esp+24h]
    mov     ecx, [esp+28h]
    mov     edx, [esp+24h]
    mov     eax, [esp+3Ch]
    add     esp, 0Ch
    push    ebx
    push    ecx
    push    edx
    push    ebp
    push    eax
    push    esi
    push    edi
    push    26h
    push    11h
    call    __except2
    add     esp, 24h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5F42:                             ; CODE XREF: .text:004F5EE1j
                                            ; .text:004F5EE5j
    push    0FFFFh
    push    ebx
    call    __ctrlfp
    fld     qword ptr [esp+20h]
    add     esp, 8
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5F5C:                             ; CODE XREF: .text:004F5D32j
                                            ; .text:004F5D3Dj
    mov     ecx, [esp+30h]
    push    ebx
    push    ebp
    push    ecx
    push    esi
    push    edi
    push    26h
    call    __handle_qnan2
    add     esp, 18h
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __finite:
    mov     eax, [esp+0Ah]
    xor     ecx, ecx
    and     eax, 7FF0h
    cmp     eax, 7FF0h
    setnz   cl
    mov     eax, ecx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __isnan:
    mov     eax, [esp+0Ah]
    and     eax, 7FF8h
    cmp     ax, 7FF0h
    jnz     short loc_4F5FC1
    test    dword ptr [esp+8], 7FFFFh
    jnz     short loc_4F5FC7
    mov     ecx, [esp+4]
    test    ecx, ecx
    jnz     short loc_4F5FC7

    loc_4F5FC1:                             ; CODE XREF: .text:004F5FADj
    cmp     ax, 7FF8h
    jnz     short loc_4F5FCD

    loc_4F5FC7:                             ; CODE XREF: .text:004F5FB7j
                                            ; .text:004F5FBFj
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    loc_4F5FCD:                             ; CODE XREF: .text:004F5FC5j
    xor     eax, eax
    retn
    ; [0000009B BYTES: COLLAPSED FUNCTION __fpclass. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000020 BYTES: COLLAPSED FUNCTION _ValidateRead(void const *,uint). PRESS KEYPAD "+" TO EXPAND]
    ; [00000020 BYTES: COLLAPSED FUNCTION _ValidateWrite(void *,uint). PRESS KEYPAD "+" TO EXPAND]
    ; [0000001B BYTES: COLLAPSED FUNCTION _ValidateExecute(int (*)(void)). PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [0000001F BYTES: COLLAPSED FUNCTION _abort. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [000000AE BYTES: COLLAPSED FUNCTION ___init_time. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000371 BYTES: COLLAPSED FUNCTION __get_lc_time. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000233 BYTES: COLLAPSED FUNCTION __free_lc_time. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000F6 BYTES: COLLAPSED FUNCTION _storeTimeFmt. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000001F6 BYTES: COLLAPSED FUNCTION ___init_numeric. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000033 BYTES: COLLAPSED FUNCTION _fix_grouping. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000EF BYTES: COLLAPSED FUNCTION ___init_monetary. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000014B BYTES: COLLAPSED FUNCTION __get_lc_lconv. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F6CE0 proc near                    ; CODE XREF: __get_lc_lconv+7Ep

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    mov     al, [ecx]
    test    al, al
    jz      short locret_4F6CFD

    loc_4F6CEA:                             ; CODE XREF: sub_4F6CE0+1Bj
    cmp     al, 30h
    jl      short loc_4F6CFE
    cmp     al, 39h
    jg      short loc_4F6CFE
    sub     al, 30h
    mov     [ecx], al

    loc_4F6CF6:                             ; CODE XREF: sub_4F6CE0+20j
    inc     ecx

    loc_4F6CF7:                             ; CODE XREF: sub_4F6CE0+31j
    mov     al, [ecx]
    test    al, al
    jnz     short loc_4F6CEA

    locret_4F6CFD:                          ; CODE XREF: sub_4F6CE0+8j
    retn
    ; ---------------------------------------------------------------------------

    loc_4F6CFE:                             ; CODE XREF: sub_4F6CE0+Cj
                                            ; sub_4F6CE0+10j
    cmp     al, 3Bh
    jnz     short loc_4F6CF6
    mov     eax, ecx

    loc_4F6D04:                             ; CODE XREF: sub_4F6CE0+2Fj
    mov     dl, [eax+1]
    mov     [eax], dl
    mov     dl, [eax+1]
    inc     eax
    test    dl, dl
    jnz     short loc_4F6D04
    jmp     short loc_4F6CF7
    sub_4F6CE0 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000066 BYTES: COLLAPSED FUNCTION __free_lc_lconv. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F6D90 proc near                    ; DATA XREF: .data:0050E430o

    lpWideCharStr= dword ptr -20h
    var_1C= dword ptr -1Ch
    var_18= dword ptr -18h
    CPInfo= _cpinfo ptr -14h

    mov     eax, Locale
    sub     esp, 20h
    push    ebx
    push    ebp
    push    esi
    push    edi
    xor     ebp, ebp
    xor     edi, edi
    xor     ebx, ebx
    cmp     eax, ebp
    jz      loc_4F7009
    cmp     CodePage, ebp
    jnz     short loc_4F6DD3
    xor     eax, eax
    push    offset CodePage                 ; int
    mov     ax, word_52A474
    push    0Bh                             ; LCType
    push    eax                             ; Locale
    push    ebp                             ; int
    call    ___getlocaleinfo
    add     esp, 10h
    test    eax, eax
    jnz     loc_4F6FCA

    loc_4F6DD3:                             ; CODE XREF: sub_4F6D90+20j
    push    202h                            ; size_t
    call    _malloc
    add     esp, 4
    mov     esi, eax
    mov     [esp+30h+var_18], esi
    push    202h                            ; size_t
    call    _malloc
    add     esp, 4
    mov     ebx, eax
    mov     [esp+30h+var_1C], ebx
    push    101h                            ; size_t
    call    _malloc
    add     esp, 4
    mov     edi, eax
    push    202h                            ; size_t
    call    _malloc
    add     esp, 4
    cmp     esi, ebp
    mov     [esp+30h+lpWideCharStr], eax
    jz      loc_4F6FD0
    cmp     ebx, ebp
    jz      loc_4F6FD0
    cmp     edi, ebp
    jz      loc_4F6FD0
    cmp     eax, ebp
    jz      loc_4F6FD0
    xor     eax, eax

    loc_4F6E3B:                             ; CODE XREF: sub_4F6D90+B4j
    mov     [eax+edi], al
    inc     eax
    cmp     eax, 100h
    jl      short loc_4F6E3B
    mov     edx, CodePage
    lea     ecx, [esp+30h+CPInfo]
    push    ecx                             ; lpCPInfo
    push    edx                             ; CodePage
    call    ds:GetCPInfo
    test    eax, eax
    jz      loc_4F6FD0
    mov     eax, [esp+30h+CPInfo.MaxCharSize]
    cmp     eax, 2
    ja      loc_4F6FD0
    and     eax, 0FFFFh
    cmp     eax, 1
    mov     cchMultiByte, eax
    jle     short loc_4F6EB4
    mov     al, [esp+30h+CPInfo.LeadByte]
    test    al, al
    jz      short loc_4F6EB4
    lea     ecx, [esp+30h+CPInfo.LeadByte+1]

    loc_4F6E88:                             ; CODE XREF: sub_4F6D90+122j
    mov     dl, [ecx]
    test    dl, dl
    jz      short loc_4F6EB4
    xor     eax, eax
    and     edx, 0FFh
    mov     al, [ecx-1]
    cmp     eax, edx
    jg      short loc_4F6EAA

    loc_4F6E9D:                             ; CODE XREF: sub_4F6D90+118j
    xor     edx, edx
    mov     byte ptr [eax+edi], 0
    mov     dl, [ecx]
    inc     eax
    cmp     eax, edx
    jle     short loc_4F6E9D

    loc_4F6EAA:                             ; CODE XREF: sub_4F6D90+10Bj
    mov     al, [ecx+1]
    add     ecx, 2
    test    al, al
    jnz     short loc_4F6E88

    loc_4F6EB4:                             ; CODE XREF: sub_4F6D90+EAj
                                            ; sub_4F6D90+F2j ...
    push    ebp                             ; int
    lea     ebx, [esi+2]
    push    ebp                             ; int
    push    ebp                             ; int
    push    ebx                             ; lpCharType
    push    100h                            ; cchMultiByte
    push    edi                             ; lpMultiByteStr
    push    1                               ; dwInfoType
    call    sub_4F4680
    add     esp, 1Ch
    test    eax, eax
    jz      loc_4F6FD0
    mov     edx, [esp+30h+lpWideCharStr]
    mov     [esi], bp
    mov     ecx, edx
    xor     eax, eax

    loc_4F6EDE:                             ; CODE XREF: sub_4F6D90+15Aj
    mov     [ecx], ax
    add     ecx, 2
    inc     eax
    cmp     eax, 100h
    jl      short loc_4F6EDE
    mov     eax, [esp+30h+var_1C]
    push    0                               ; int
    push    0                               ; CodePage
    lea     ebp, [eax+2]
    push    ebp                             ; lpCharType
    push    100h                            ; cchWideChar
    push    edx                             ; lpWideCharStr
    push    1                               ; dwInfoType
    call    ___crtGetStringTypeW
    add     esp, 18h
    test    eax, eax
    jz      loc_4F6FD0
    mov     ecx, [esp+30h+var_1C]
    mov     word ptr [ecx], 0
    mov     eax, cchMultiByte
    cmp     eax, 1
    jle     short loc_4F6F6B
    mov     al, [esp+30h+CPInfo.LeadByte]
    test    al, al
    jz      short loc_4F6F6B
    lea     esi, [esp+30h+CPInfo.LeadByte+1]

    loc_4F6F2F:                             ; CODE XREF: sub_4F6D90+1D5j
    mov     cl, [esi]
    test    cl, cl
    jz      short loc_4F6F67
    xor     eax, eax
    and     ecx, 0FFh
    mov     al, [esi-1]
    cmp     eax, ecx
    jg      short loc_4F6F5D
    mov     edx, [esp+30h+var_18]
    lea     ecx, [edx+eax*2+2]

    loc_4F6F4C:                             ; CODE XREF: sub_4F6D90+1CBj
    xor     edx, edx
    mov     word ptr [ecx], 8000h
    mov     dl, [esi]
    inc     eax
    add     ecx, 2
    cmp     eax, edx
    jle     short loc_4F6F4C

    loc_4F6F5D:                             ; CODE XREF: sub_4F6D90+1B2j
    mov     al, [esi+1]
    add     esi, 2
    test    al, al
    jnz     short loc_4F6F2F

    loc_4F6F67:                             ; CODE XREF: sub_4F6D90+1A3j
    mov     esi, [esp+30h+var_18]

    loc_4F6F6B:                             ; CODE XREF: sub_4F6D90+191j
                                            ; sub_4F6D90+199j
    mov     eax, dword_52A45C
    mov     dword_50E020, ebx
    test    eax, eax
    mov     dword_50E024, ebp
    jz      short loc_4F6F89
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4F6F89:                             ; CODE XREF: sub_4F6D90+1EEj
    mov     eax, dword_52A460
    mov     dword_52A45C, esi
    test    eax, eax
    jz      short loc_4F6FA1
    push    eax                             ; void *
    call    _free
    add     esp, 4

    loc_4F6FA1:                             ; CODE XREF: sub_4F6D90+206j
    mov     eax, [esp+30h+var_1C]
    push    edi                             ; void *
    mov     dword_52A460, eax
    call    _free
    mov     ecx, [esp+34h+lpWideCharStr]
    add     esp, 4
    push    ecx                             ; void *
    call    _free
    add     esp, 4
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F6FCA:                             ; CODE XREF: sub_4F6D90+3Dj
    mov     esi, [esp+30h+var_18]
    jmp     short loc_4F6FD4
    ; ---------------------------------------------------------------------------

    loc_4F6FD0:                             ; CODE XREF: sub_4F6D90+8Bj
                                            ; sub_4F6D90+93j ...
    mov     ebx, [esp+30h+lpWideCharStr]

    loc_4F6FD4:                             ; CODE XREF: sub_4F6D90+23Ej
    push    esi                             ; void *
    call    _free
    mov     edx, [esp+34h+var_1C]
    add     esp, 4
    push    edx                             ; void *
    call    _free
    add     esp, 4
    push    edi                             ; void *
    call    _free
    add     esp, 4
    push    ebx                             ; void *
    call    _free
    add     esp, 4
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F7009:                             ; CODE XREF: sub_4F6D90+14j
    mov     eax, 50E02Ah
    mov     dword_50E020, eax
    mov     dword_50E024, eax
    mov     eax, dword_52A45C
    push    eax                             ; void *
    call    _free
    mov     ecx, dword_52A460
    add     esp, 4
    push    ecx                             ; void *
    call    _free
    add     esp, 4
    mov     dword_52A45C, ebp
    mov     dword_52A460, ebp
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 20h
    retn
    sub_4F6D90 endp

    ; ---------------------------------------------------------------------------
    align 8
    ; [00000003 BYTES: COLLAPSED FUNCTION unknown_libname_128. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000003A BYTES: COLLAPSED FUNCTION _strpbrk. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F70A0 proc near                    ; CODE XREF: __expandlocale+10Ep

    arg_0= dword ptr  4
    arg_4= dword ptr  8
    arg_8= dword ptr  0Ch

    mov     eax, dword_52A4AC
    push    esi
    test    eax, eax
    push    edi
    jnz     short loc_4F70CA
    call    sub_4F7A00
    test    eax, eax
    jz      short loc_4F70C0
    mov     eax, ds:GetLocaleInfoA
    mov     dword_52A4AC, eax
    jmp     short loc_4F70CA
    ; ---------------------------------------------------------------------------

    loc_4F70C0:                             ; CODE XREF: sub_4F70A0+12j
    mov     dword_52A4AC, offset sub_4F7A40

    loc_4F70CA:                             ; CODE XREF: sub_4F70A0+9j
                                            ; sub_4F70A0+1Ej
    mov     esi, [esp+8+arg_0]
    test    esi, esi
    jz      loc_4F7160
    mov     dword_52A49C, esi
    mov     al, [esi]
    test    al, al
    jz      short loc_4F70F6
    push    offset dword_52A49C
    push    40h
    push    offset off_510E80
    call    sub_4F7240
    add     esp, 0Ch

    loc_4F70F6:                             ; CODE XREF: sub_4F70A0+40j
    lea     eax, [esi+40h]
    test    eax, eax
    mov     dword_52A4A0, eax
    jz      short loc_4F7120
    cmp     byte ptr [eax], 0
    jz      short loc_4F7120
    push    offset dword_52A4A0
    push    16h
    push    offset off_511088
    call    sub_4F7240
    mov     eax, dword_52A4A0
    add     esp, 0Ch

    loc_4F7120:                             ; CODE XREF: sub_4F70A0+60j
                                            ; sub_4F70A0+65j
    mov     ecx, dword_52A49C
    mov     dword_52A4A4, 0
    test    ecx, ecx
    jz      short loc_4F7150
    cmp     byte ptr [ecx], 0
    jz      short loc_4F7150
    test    eax, eax
    jz      short loc_4F7149
    cmp     byte ptr [eax], 0
    jz      short loc_4F7149
    call    sub_4F72A0
    jmp     short loc_4F7165
    ; ---------------------------------------------------------------------------

    loc_4F7149:                             ; CODE XREF: sub_4F70A0+9Bj
                                            ; sub_4F70A0+A0j
    call    sub_4F7610
    jmp     short loc_4F7165
    ; ---------------------------------------------------------------------------

    loc_4F7150:                             ; CODE XREF: sub_4F70A0+92j
                                            ; sub_4F70A0+97j
    test    eax, eax
    jz      short loc_4F7160
    cmp     byte ptr [eax], 0
    jz      short loc_4F7160
    call    sub_4F7750
    jmp     short loc_4F7165
    ; ---------------------------------------------------------------------------

    loc_4F7160:                             ; CODE XREF: sub_4F70A0+30j
                                            ; sub_4F70A0+B2j ...
    call    sub_4F7830

    loc_4F7165:                             ; CODE XREF: sub_4F70A0+A7j
                                            ; sub_4F70A0+AEj ...
    mov     eax, dword_52A4A4
    test    eax, eax
    jz      loc_4F722C
    add     esi, 80h
    push    esi
    call    sub_4F7850
    mov     edi, eax
    add     esp, 4
    test    edi, edi
    jz      loc_4F722C
    mov     ecx, edi
    and     ecx, 0FFFFh
    push    ecx                             ; CodePage
    call    ds:IsValidCodePage
    test    eax, eax
    jz      loc_4F722C
    mov     edx, dword_52A48C
    push    1                               ; dwFlags
    push    edx                             ; Locale
    call    ds:IsValidLocale
    test    eax, eax
    jz      short loc_4F722C
    mov     eax, [esp+8+arg_4]
    test    eax, eax
    jz      short loc_4F71D6
    mov     cx, word ptr dword_52A48C
    mov     [eax], cx
    mov     dx, word ptr dword_52A4A8
    mov     [eax+2], dx
    mov     [eax+4], di

    loc_4F71D6:                             ; CODE XREF: sub_4F70A0+11Bj
    mov     esi, [esp+8+arg_8]
    test    esi, esi
    jz      short loc_4F7224
    mov     eax, dword_52A48C
    push    40h
    push    esi
    push    1001h
    push    eax
    call    dword_52A4AC
    test    eax, eax
    jz      short loc_4F722C
    mov     edx, dword_52A4A8
    lea     ecx, [esi+40h]
    push    40h
    push    ecx
    push    1002h
    push    edx
    call    dword_52A4AC
    test    eax, eax
    jz      short loc_4F722C
    add     esi, 80h
    push    0Ah                             ; int
    push    esi                             ; char *
    push    edi                             ; int
    call    __itoa
    add     esp, 0Ch

    loc_4F7224:                             ; CODE XREF: sub_4F70A0+13Cj
    mov     eax, 1
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4F722C:                             ; CODE XREF: sub_4F70A0+CCj
                                            ; sub_4F70A0+E5j ...
    pop     edi
    xor     eax, eax
    pop     esi
    retn
    sub_4F70A0 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7240 proc near                    ; CODE XREF: sub_4F70A0+4Ep
                                            ; sub_4F70A0+73p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch
    arg_8= dword ptr  10h

    push    ebx
    mov     ebx, [esp+arg_4]
    push    ebp
    push    esi
    push    edi
    xor     edi, edi
    test    ebx, ebx
    mov     eax, 1
    jl      short loc_4F7298
    mov     ebp, [esp+0Ch+arg_8]

    loc_4F7257:                             ; CODE XREF: sub_4F7240+56j
    test    eax, eax
    jz      short loc_4F7298
    lea     eax, [edi+ebx]
    cdq
    sub     eax, edx
    mov     edx, [ebp+0]
    mov     esi, eax
    mov     eax, [esp+0Ch+arg_0]
    sar     esi, 1
    mov     ecx, [eax+esi*8]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_4F728A
    mov     ecx, [esp+0Ch+arg_0]
    lea     edx, [ecx+esi*8+4]
    mov     [ebp+0], edx
    jmp     short loc_4F7294
    ; ---------------------------------------------------------------------------

    loc_4F728A:                             ; CODE XREF: sub_4F7240+3Bj
    jge     short loc_4F7291
    lea     ebx, [esi-1]
    jmp     short loc_4F7294
    ; ---------------------------------------------------------------------------

    loc_4F7291:                             ; CODE XREF: sub_4F7240+4Aj
    lea     edi, [esi+1]

    loc_4F7294:                             ; CODE XREF: sub_4F7240+48j
                                            ; sub_4F7240+4Fj
    cmp     edi, ebx
    jle     short loc_4F7257

    loc_4F7298:                             ; CODE XREF: sub_4F7240+11j
                                            ; sub_4F7240+19j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4F7240 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F72A0 proc near                    ; CODE XREF: sub_4F70A0+A2p
    push    esi
    mov     esi, dword_52A49C
    push    edi
    mov     edi, esi
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     edi, dword_52A4A0
    xor     edx, edx
    not     ecx
    dec     ecx
    cmp     ecx, 3
    setz    dl
    or      ecx, 0FFFFFFFFh
    mov     dword_52A498, edx
    repne scasb
    not     ecx
    dec     ecx
    cmp     ecx, 3
    setz    al
    xor     edi, edi
    mov     dword_52A490, eax
    cmp     edx, edi
    mov     dword_52A48C, edi
    jz      short loc_4F72F3
    mov     dword_52A494, 2
    jmp     short loc_4F7301
    ; ---------------------------------------------------------------------------

    loc_4F72F3:                             ; CODE XREF: sub_4F72A0+45j
    push    esi
    call    _GetPrimaryLen
    add     esp, 4
    mov     dword_52A494, eax

    loc_4F7301:                             ; CODE XREF: sub_4F72A0+51j
    push    1                               ; dwFlags
    push    offset LocaleEnumProc           ; lpLocaleEnumProc
    call    ds:EnumSystemLocalesA
    mov     eax, dword_52A4A4
    test    ah, 1
    jz      short loc_4F7321
    test    ah, 2
    jz      short loc_4F7321
    test    al, 7
    jnz     short loc_4F7327

    loc_4F7321:                             ; CODE XREF: sub_4F72A0+76j
                                            ; sub_4F72A0+7Bj
    mov     dword_52A4A4, edi

    loc_4F7327:                             ; CODE XREF: sub_4F72A0+7Fj
    pop     edi
    pop     esi
    retn
    sub_4F72A0 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; BOOL __stdcall LocaleEnumProc(LPSTR)
    LocaleEnumProc proc near                ; DATA XREF: sub_4F72A0+63o

    var_A8= dword ptr -0A8h
    var_98= dword ptr -98h
    var_88= dword ptr -88h
    var_78= byte ptr -78h
    arg_0= dword ptr  4

    mov     eax, [esp+arg_0]
    sub     esp, 78h
    push    esi
    push    edi
    push    eax
    call    sub_4F7B70
    mov     edx, dword_52A490
    add     esp, 4
    neg     edx
    sbb     edx, edx
    lea     ecx, [esp+80h+var_78]
    and     edx, 0FFFFF005h
    push    78h
    add     edx, 1002h
    mov     esi, eax
    push    ecx
    push    edx
    push    esi
    call    dword_52A4AC
    test    eax, eax
    jnz     short loc_4F737F
    mov     dword_52A4A4, eax
    mov     eax, 1
    pop     edi
    pop     esi
    add     esp, 78h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F737F:                             ; CODE XREF: LocaleEnumProc+3Bj
    mov     ecx, dword_52A4A0
    lea     eax, [esp+80h+var_78]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     loc_4F7491
    mov     eax, dword_52A498
    lea     edx, [esp+80h+var_78]
    neg     eax
    sbb     eax, eax
    push    78h
    and     eax, 0FFFFF002h
    push    edx
    add     eax, 1001h
    push    eax
    push    esi
    call    dword_52A4AC
    test    eax, eax
    jnz     short loc_4F73D3
    mov     dword_52A4A4, eax
    mov     eax, 1
    pop     edi
    pop     esi
    add     esp, 78h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F73D3:                             ; CODE XREF: LocaleEnumProc+8Fj
    mov     edx, dword_52A49C
    lea     ecx, [esp+80h+var_78]
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_4F740B
    mov     eax, dword_52A4A4
    mov     dword_52A4A8, esi
    or      eax, 304h
    mov     dword_52A48C, esi
    mov     dword_52A4A4, eax
    jmp     loc_4F7491
    ; ---------------------------------------------------------------------------

    loc_4F740B:                             ; CODE XREF: LocaleEnumProc+B9j
    test    byte ptr dword_52A4A4, 2
    jnz     short loc_4F7491
    mov     eax, dword_52A494
    test    eax, eax
    jz      short loc_4F7469
    mov     ecx, dword_52A49C
    push    eax                             ; size_t
    lea     eax, [esp+84h+var_78]
    push    eax                             ; char *
    push    ecx                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4F7469
    mov     eax, dword_52A4A4
    mov     edi, dword_52A49C
    or      al, 2
    or      ecx, 0FFFFFFFFh
    mov     dword_52A4A4, eax
    xor     eax, eax
    mov     dword_52A4A8, esi
    repne scasb
    mov     eax, dword_52A494
    not     ecx
    dec     ecx
    cmp     ecx, eax
    jnz     short loc_4F7491
    mov     dword_52A48C, esi
    jmp     short loc_4F7491
    ; ---------------------------------------------------------------------------

    loc_4F7469:                             ; CODE XREF: LocaleEnumProc+EBj
                                            ; LocaleEnumProc+104j
    test    byte ptr dword_52A4A4, 1
    jnz     short loc_4F7491
    push    esi
    call    sub_4F7940
    add     esp, 4
    test    eax, eax
    jz      short loc_4F7491
    mov     eax, dword_52A4A4
    mov     dword_52A4A8, esi
    or      al, 1
    mov     dword_52A4A4, eax

    loc_4F7491:                             ; CODE XREF: LocaleEnumProc+65j
                                            ; LocaleEnumProc+D6j ...
    mov     edx, dword_52A4A4
    and     edx, 300h
    cmp     edx, 300h
    jz      loc_4F75EE
    mov     ecx, dword_52A498
    lea     eax, [esp+80h+var_78]
    neg     ecx
    sbb     ecx, ecx
    push    78h
    and     ecx, 0FFFFF002h
    push    eax
    add     ecx, 1001h
    push    ecx
    push    esi
    call    dword_52A4AC
    test    eax, eax
    jnz     short loc_4F74E4
    mov     dword_52A4A4, eax
    mov     eax, 1
    pop     edi
    pop     esi
    add     esp, 78h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F74E4:                             ; CODE XREF: LocaleEnumProc+1A0j
    mov     eax, dword_52A49C
    lea     edx, [esp+80h+var_78]
    push    edx                             ; char *
    push    eax                             ; char *
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     loc_4F7597
    mov     ecx, dword_52A4A4
    mov     eax, dword_52A498
    or      ch, 2
    test    eax, eax
    mov     dword_52A4A4, ecx
    jz      short loc_4F7532
    mov     eax, dword_52A48C
    or      ch, 1
    test    eax, eax
    mov     dword_52A4A4, ecx
    jnz     loc_4F75EE
    jmp     loc_4F75E8
    ; ---------------------------------------------------------------------------

    loc_4F7532:                             ; CODE XREF: LocaleEnumProc+1E5j
    mov     edx, dword_52A494
    test    edx, edx
    jz      short loc_4F757D
    mov     edi, dword_52A49C
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     ecx, edx
    jnz     short loc_4F757D
    push    1
    push    esi
    call    sub_4F7970
    add     esp, 8
    test    eax, eax
    jz      loc_4F75EE
    mov     ecx, dword_52A4A4
    mov     eax, dword_52A48C
    or      ch, 1
    test    eax, eax
    mov     dword_52A4A4, ecx
    jnz     short loc_4F75EE
    jmp     short loc_4F75E8
    ; ---------------------------------------------------------------------------

    loc_4F757D:                             ; CODE XREF: LocaleEnumProc+20Aj
                                            ; LocaleEnumProc+21Ej
    mov     ecx, dword_52A4A4
    mov     eax, dword_52A48C
    or      ch, 1
    test    eax, eax
    mov     dword_52A4A4, ecx
    jnz     short loc_4F75EE
    jmp     short loc_4F75E8
    ; ---------------------------------------------------------------------------

    loc_4F7597:                             ; CODE XREF: LocaleEnumProc+1C9j
    mov     eax, dword_52A498
    test    eax, eax
    jnz     short loc_4F75EE
    mov     eax, dword_52A494
    test    eax, eax
    jz      short loc_4F75EE
    mov     edx, dword_52A49C
    lea     ecx, [esp+80h+var_78]
    push    eax                             ; size_t
    push    ecx                             ; char *
    push    edx                             ; char *
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4F75EE
    push    eax
    push    esi
    call    sub_4F7970
    add     esp, 8
    test    eax, eax
    jz      short loc_4F75EE
    mov     ecx, dword_52A4A4
    mov     eax, dword_52A48C
    or      ch, 1
    test    eax, eax
    mov     dword_52A4A4, ecx
    jnz     short loc_4F75EE

    loc_4F75E8:                             ; CODE XREF: LocaleEnumProc+1FDj
                                            ; LocaleEnumProc+24Bj ...
    mov     dword_52A48C, esi

    loc_4F75EE:                             ; CODE XREF: LocaleEnumProc+173j
                                            ; LocaleEnumProc+1F7j ...
    mov     eax, dword_52A4A4
    pop     edi
    not     eax
    shr     eax, 2
    and     eax, 1
    pop     esi
    add     esp, 78h
    retn    4
    LocaleEnumProc endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7610 proc near                    ; CODE XREF: sub_4F70A0+A9p
    mov     edx, dword_52A49C
    push    edi
    mov     edi, edx
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    cmp     ecx, 3
    setz    al
    test    eax, eax
    mov     dword_52A498, eax
    jz      short loc_4F763E
    mov     dword_52A494, 2
    jmp     short loc_4F764C
    ; ---------------------------------------------------------------------------

    loc_4F763E:                             ; CODE XREF: sub_4F7610+20j
    push    edx
    call    _GetPrimaryLen
    add     esp, 4
    mov     dword_52A494, eax

    loc_4F764C:                             ; CODE XREF: sub_4F7610+2Cj
    push    1                               ; dwFlags
    push    offset loc_4F7670               ; lpLocaleEnumProc
    call    ds:EnumSystemLocalesA
    test    byte ptr dword_52A4A4, 4
    jnz     short loc_4F766C
    mov     dword_52A4A4, 0

    loc_4F766C:                             ; CODE XREF: sub_4F7610+50j
    pop     edi
    retn
    sub_4F7610 endp

    ; ---------------------------------------------------------------------------
    align 4

    loc_4F7670:                             ; DATA XREF: sub_4F7610+3Eo
    mov     eax, [esp+4]
    sub     esp, 78h
    push    esi
    push    eax
    call    sub_4F7B70
    mov     edx, dword_52A498
    add     esp, 4
    neg     edx
    sbb     edx, edx
    lea     ecx, [esp+4]
    and     edx, 0FFFFF002h
    push    78h
    add     edx, 1001h
    mov     esi, eax
    push    ecx
    push    edx
    push    esi
    call    dword_52A4AC
    test    eax, eax
    jnz     short loc_4F76BD
    mov     dword_52A4A4, eax
    mov     eax, 1
    pop     esi
    add     esp, 78h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F76BD:                             ; CODE XREF: .text:004F76AAj
    mov     ecx, dword_52A49C
    lea     eax, [esp+4]
    push    eax
    push    ecx
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    mov     eax, dword_52A498
    jnz     short loc_4F76EF
    test    eax, eax
    jnz     short loc_4F7722
    push    1
    push    esi
    call    sub_4F7970
    add     esp, 8
    test    eax, eax
    jz      short loc_4F773A
    jmp     short loc_4F7722
    ; ---------------------------------------------------------------------------

    loc_4F76EF:                             ; CODE XREF: .text:004F76D8j
    test    eax, eax
    jnz     short loc_4F773A
    mov     eax, dword_52A494
    test    eax, eax
    jz      short loc_4F773A
    push    eax
    mov     eax, dword_52A49C
    lea     edx, [esp+8]
    push    edx
    push    eax
    call    __strnicmp
    add     esp, 0Ch
    test    eax, eax
    jnz     short loc_4F773A
    push    eax
    push    esi
    call    sub_4F7970
    add     esp, 8
    test    eax, eax
    jz      short loc_4F773A

    loc_4F7722:                             ; CODE XREF: .text:004F76DCj
                                            ; .text:004F76EDj
    mov     eax, dword_52A4A4
    mov     dword_52A4A8, esi
    or      al, 4
    mov     dword_52A48C, esi
    mov     dword_52A4A4, eax

    loc_4F773A:                             ; CODE XREF: .text:004F76EBj
                                            ; .text:004F76F1j ...
    mov     eax, dword_52A4A4
    pop     esi
    not     eax
    shr     eax, 2
    and     eax, 1
    add     esp, 78h
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7750 proc near                    ; CODE XREF: sub_4F70A0+B9p
    push    edi
    mov     edi, dword_52A4A0
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    dec     ecx
    push    1                               ; dwFlags
    cmp     ecx, 3
    push    offset loc_4F7790               ; lpLocaleEnumProc
    setz    al
    mov     dword_52A490, eax
    call    ds:EnumSystemLocalesA
    test    byte ptr dword_52A4A4, 4
    jnz     short loc_4F778C
    mov     dword_52A4A4, 0

    loc_4F778C:                             ; CODE XREF: sub_4F7750+30j
    pop     edi
    retn
    sub_4F7750 endp

    ; ---------------------------------------------------------------------------
    align 4

    loc_4F7790:                             ; DATA XREF: sub_4F7750+16o
    mov     eax, [esp+4]
    sub     esp, 78h
    push    esi
    push    eax
    call    sub_4F7B70
    mov     edx, dword_52A490
    add     esp, 4
    neg     edx
    sbb     edx, edx
    lea     ecx, [esp+4]
    and     edx, 0FFFFF005h
    push    78h
    add     edx, 1002h
    mov     esi, eax
    push    ecx
    push    edx
    push    esi
    call    dword_52A4AC
    test    eax, eax
    jnz     short loc_4F77DD
    mov     dword_52A4A4, eax
    mov     eax, 1
    pop     esi
    add     esp, 78h
    retn    4
    ; ---------------------------------------------------------------------------

    loc_4F77DD:                             ; CODE XREF: .text:004F77CAj
    mov     ecx, dword_52A4A0
    lea     eax, [esp+4]
    push    eax
    push    ecx
    call    __strcmpi
    add     esp, 8
    test    eax, eax
    jnz     short loc_4F781A
    push    esi
    call    sub_4F7940
    add     esp, 4
    test    eax, eax
    jz      short loc_4F781A
    mov     eax, dword_52A4A4
    mov     dword_52A4A8, esi
    or      al, 4
    mov     dword_52A48C, esi
    mov     dword_52A4A4, eax

    loc_4F781A:                             ; CODE XREF: .text:004F77F3j
                                            ; .text:004F7800j
    mov     eax, dword_52A4A4
    pop     esi
    not     eax
    shr     eax, 2
    and     eax, 1
    add     esp, 78h
    retn    4
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7830 proc near                    ; CODE XREF: sub_4F70A0+C0p
    or      dword_52A4A4, 104h
    call    ds:GetUserDefaultLCID
    mov     dword_52A4A8, eax
    mov     dword_52A48C, eax
    retn
    sub_4F7830 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7850 proc near                    ; CODE XREF: sub_4F70A0+D9p

    var_18= dword ptr -18h
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 8
    push    ebx
    push    esi
    push    edi
    mov     edi, [esp+14h+arg_0]
    test    edi, edi
    jz      loc_4F78FC
    cmp     byte ptr [edi], 0
    jz      loc_4F78FC
    mov     esi, offset off_4FEA0C
    mov     eax, edi

    loc_4F7872:                             ; CODE XREF: sub_4F7850+44j
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4F789A
    test    cl, cl
    jz      short loc_4F7896
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4F789A
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4F7872

    loc_4F7896:                             ; CODE XREF: sub_4F7850+2Ej
    xor     eax, eax
    jmp     short loc_4F789F
    ; ---------------------------------------------------------------------------

    loc_4F789A:                             ; CODE XREF: sub_4F7850+2Aj
                                            ; sub_4F7850+3Aj
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4F789F:                             ; CODE XREF: sub_4F7850+48j
    test    eax, eax
    jz      short loc_4F78FC
    mov     esi, offset off_4FEA08
    mov     eax, edi

    loc_4F78AA:                             ; CODE XREF: sub_4F7850+7Cj
    mov     dl, [eax]
    mov     bl, [esi]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4F78D2
    test    cl, cl
    jz      short loc_4F78CE
    mov     dl, [eax+1]
    mov     bl, [esi+1]
    mov     cl, dl
    cmp     dl, bl
    jnz     short loc_4F78D2
    add     eax, 2
    add     esi, 2
    test    cl, cl
    jnz     short loc_4F78AA

    loc_4F78CE:                             ; CODE XREF: sub_4F7850+66j
    xor     eax, eax
    jmp     short loc_4F78D7
    ; ---------------------------------------------------------------------------

    loc_4F78D2:                             ; CODE XREF: sub_4F7850+62j
                                            ; sub_4F7850+72j
    sbb     eax, eax
    sbb     eax, 0FFFFFFFFh

    loc_4F78D7:                             ; CODE XREF: sub_4F7850+80j
    test    eax, eax
    jnz     short loc_4F7923
    mov     ecx, dword_52A4A8
    lea     eax, [esp+14h+var_8]
    push    8
    push    eax
    push    0Bh
    push    ecx
    call    dword_52A4AC
    test    eax, eax
    jnz     short loc_4F791F
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F78FC:                             ; CODE XREF: sub_4F7850+Cj
                                            ; sub_4F7850+15j ...
    mov     eax, dword_52A4A8
    lea     edx, [esp+14h+var_8]
    push    8
    push    edx
    push    1004h
    push    eax
    call    dword_52A4AC
    test    eax, eax
    jnz     short loc_4F791F
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------

    loc_4F791F:                             ; CODE XREF: sub_4F7850+A3j
                                            ; sub_4F7850+C6j
    lea     edi, [esp+0Ch]

    loc_4F7923:                             ; CODE XREF: sub_4F7850+89j
    push    edi                             ; char *
    call    _atol
    add     esp, 4
    pop     edi
    pop     esi
    pop     ebx
    add     esp, 8
    retn
    sub_4F7850 endp ; sp = -4

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7940 proc near                    ; CODE XREF: LocaleEnumProc+143p
                                            ; .text:004F77F6p

    arg_0= dword ptr  4

    mov     ecx, [esp+arg_0]
    mov     eax, offset dword_511140

    loc_4F7949:                             ; CODE XREF: sub_4F7940+16j
    cmp     cx, [eax]
    jz      short unknown_libname_130
    add     eax, 2
    cmp     eax, offset dword_511154
    jb      short loc_4F7949

    unknown_libname_129:
    mov     eax, 1
    retn
    ; ---------------------------------------------------------------------------

    unknown_libname_130:                    ; CODE XREF: sub_4F7940+Cj
    xor     eax, eax
    retn
    sub_4F7940 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7970 proc near                    ; CODE XREF: LocaleEnumProc+223p
                                            ; LocaleEnumProc+294p ...

    var_88= dword ptr -88h
    var_78= dword ptr -78h
    var_8= dword ptr -8
    arg_0= dword ptr  4

    sub     esp, 78h
    lea     eax, [esp+78h+var_78]
    push    esi
    mov     esi, [esp+7Ch+arg_0]
    mov     ecx, esi
    push    edi
    and     ecx, 3FFh
    push    78h
    push    eax
    or      ch, 4
    push    1
    push    ecx
    call    dword_52A4AC
    test    eax, eax
    jnz     short loc_4F79A1
    pop     edi
    pop     esi
    add     esp, 78h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F79A1:                             ; CODE XREF: sub_4F7970+29j
    lea     edx, [esp+80h+var_78]
    push    edx
    call    sub_4F7B70
    add     esp, 4
    cmp     esi, eax
    jz      short loc_4F79E7
    mov     eax, [esp+88h]
    test    eax, eax
    jz      short loc_4F79E7
    mov     eax, dword_52A49C
    push    eax
    call    _GetPrimaryLen
    mov     edi, dword_52A49C
    mov     edx, eax
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esp, 4
    repne scasb
    not     ecx
    dec     ecx
    cmp     edx, ecx
    jnz     short loc_4F79E7
    pop     edi
    pop     esi
    add     esp, 78h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F79E7:                             ; CODE XREF: sub_4F7970+40j
                                            ; sub_4F7970+4Bj ...
    pop     edi
    mov     eax, 1
    pop     esi
    add     esp, 78h
    retn
    sub_4F7970 endp

    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7A00 proc near                    ; CODE XREF: sub_4F70A0+Bp

    VersionInformation= _OSVERSIONINFOA ptr -94h

    sub     esp, 94h
    lea     eax, [esp+94h+VersionInformation]
    mov     [esp+94h+VersionInformation.dwOSVersionInfoSize], 94h
    push    eax                             ; lpVersionInformation
    call    ds:GetVersionExA                ; Get extended information about the
                                            ; version of the operating system
    test    eax, eax
    jz      short loc_4F7A30
    cmp     [esp+94h+VersionInformation.dwPlatformId], 2
    jnz     short loc_4F7A30
    mov     eax, 1
    add     esp, 94h
    retn
    ; ---------------------------------------------------------------------------

    loc_4F7A30:                             ; CODE XREF: sub_4F7A00+1Bj
                                            ; sub_4F7A00+22j
    xor     eax, eax
    add     esp, 94h
    retn
    sub_4F7A00 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __stdcall sub_4F7A40(LCID Locale,LCTYPE LCType,char *lpLCData,int cchData)
    sub_4F7A40 proc near                    ; DATA XREF: sub_4F70A0+20o

    Locale= dword ptr  8
    LCType= dword ptr  0Ch
    lpLCData= dword ptr  10h
    cchData= dword ptr  14h

    push    ebx
    mov     ebx, [esp+Locale]
    push    ebp
    push    esi
    push    edi
    xor     esi, esi
    mov     edi, 1Ah
    xor     ebp, ebp

    loc_4F7A51:                             ; CODE XREF: sub_4F7A40+3Cj
    lea     eax, [edi+esi]
    cdq
    sub     eax, edx
    sar     eax, 1
    lea     ecx, [eax+eax*4]
    lea     edx, [eax+ecx*2]
    mov     ecx, dword_511158[edx*4]
    mov     edx, [esp+0Ch+LCType]
    cmp     ebx, ecx
    jz      short loc_4F7A97
    cmp     ebx, ecx
    jnb     short loc_4F7A77
    lea     edi, [eax-1]
    jmp     short loc_4F7A7A
    ; ---------------------------------------------------------------------------

    loc_4F7A77:                             ; CODE XREF: sub_4F7A40+30j
    lea     esi, [eax+1]

    loc_4F7A7A:                             ; CODE XREF: sub_4F7A40+35j
    cmp     esi, edi
    jle     short loc_4F7A51

    loc_4F7A7E:                             ; CODE XREF: sub_4F7A40+F3j
    mov     edi, [esp+0Ch+cchData]

    loc_4F7A82:                             ; CODE XREF: sub_4F7A40+100j
    mov     eax, [esp+0Ch+lpLCData]
    push    edi                             ; cchData
    push    eax                             ; lpLCData
    push    edx                             ; LCType
    push    ebx                             ; Locale
    call    ds:GetLocaleInfoA
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    ; ---------------------------------------------------------------------------

    loc_4F7A97:                             ; CODE XREF: sub_4F7A40+2Cj
    cmp     edx, 7
    ja      short loc_4F7AD9
    jz      short loc_4F7ACA
    mov     ecx, edx
    dec     ecx
    jz      short loc_4F7ABB
    sub     ecx, 2
    jnz     loc_4F7B31
    lea     ecx, [eax+eax*4]
    lea     eax, [eax+ecx*2]
    lea     ebp, ds:511168h[eax*4]
    jmp     short loc_4F7B31
    ; ---------------------------------------------------------------------------

    loc_4F7ABB:                             ; CODE XREF: sub_4F7A40+61j
    lea     ecx, [eax+eax*4]
    lea     eax, [eax+ecx*2]
    lea     ebp, ds:51115Ch[eax*4]
    jmp     short loc_4F7B31
    ; ---------------------------------------------------------------------------

    loc_4F7ACA:                             ; CODE XREF: sub_4F7A40+5Cj
    lea     ecx, [eax+eax*4]
    lea     eax, [eax+ecx*2]
    lea     ebp, ds:511170h[eax*4]
    jmp     short loc_4F7B31
    ; ---------------------------------------------------------------------------

    loc_4F7AD9:                             ; CODE XREF: sub_4F7A40+5Aj
    cmp     edx, 1001h
    ja      short loc_4F7B06
    jz      short loc_4F7AF7
    cmp     edx, 0Bh
    jnz     short loc_4F7B31
    lea     ecx, [eax+eax*4]
    lea     eax, [eax+ecx*2]
    lea     ebp, ds:511174h[eax*4]
    jmp     short loc_4F7B31
    ; ---------------------------------------------------------------------------

    loc_4F7AF7:                             ; CODE XREF: sub_4F7A40+A1j
    lea     ecx, [eax+eax*4]
    lea     eax, [eax+ecx*2]
    mov     ebp, dword_511164[eax*4]
    jmp     short loc_4F7B31
    ; ---------------------------------------------------------------------------

    loc_4F7B06:                             ; CODE XREF: sub_4F7A40+9Fj
    mov     ecx, edx
    sub     ecx, 1002h
    jz      short loc_4F7B24
    sub     ecx, 2
    jnz     short loc_4F7B31
    lea     ecx, [eax+eax*4]
    lea     eax, [eax+ecx*2]
    lea     ebp, ds:51117Ch[eax*4]
    jmp     short loc_4F7B31
    ; ---------------------------------------------------------------------------

    loc_4F7B24:                             ; CODE XREF: sub_4F7A40+CEj
    lea     ecx, [eax+eax*4]
    lea     eax, [eax+ecx*2]
    mov     ebp, off_51116C[eax*4]

    loc_4F7B31:                             ; CODE XREF: sub_4F7A40+66j
                                            ; sub_4F7A40+79j ...
    test    ebp, ebp
    jz      loc_4F7A7E
    mov     edi, [esp+0Ch+cchData]
    cmp     edi, 1
    jl      loc_4F7A82
    mov     esi, [esp+0Ch+lpLCData]
    lea     ecx, [edi-1]
    push    ecx                             ; size_t
    push    ebp                             ; char *
    push    esi                             ; char *
    call    _strncpy
    add     esp, 0Ch
    mov     byte ptr [edi+esi-1], 0
    mov     eax, 1
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn    10h
    sub_4F7A40 endp

    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7B70 proc near                    ; CODE XREF: LocaleEnumProc+Ap
                                            ; .text:004F7679p ...

    arg_0= dword ptr  4

    mov     edx, [esp+arg_0]
    xor     eax, eax
    mov     cl, [edx]
    inc     edx
    test    cl, cl
    jz      short locret_4F7BAD

    loc_4F7B7D:                             ; CODE XREF: sub_4F7B70+3Bj
    cmp     cl, 61h
    jl      short loc_4F7B8C
    cmp     cl, 66h
    jg      short loc_4F7B8C
    add     cl, 0D9h
    jmp     short loc_4F7B99
    ; ---------------------------------------------------------------------------

    loc_4F7B8C:                             ; CODE XREF: sub_4F7B70+10j
                                            ; sub_4F7B70+15j
    cmp     cl, 41h
    jl      short loc_4F7B99
    cmp     cl, 46h
    jg      short loc_4F7B99
    add     cl, 0F9h

    loc_4F7B99:                             ; CODE XREF: sub_4F7B70+1Aj
                                            ; sub_4F7B70+1Fj ...
    add     eax, 0FFFFFFDh
    movsx   ecx, cl
    shl     eax, 4
    add     eax, ecx
    mov     cl, [edx]
    inc     edx
    test    cl, cl
    jnz     short loc_4F7B7D

    locret_4F7BAD:                          ; CODE XREF: sub_4F7B70+Bj
    retn
    sub_4F7B70 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000021 BYTES: COLLAPSED FUNCTION _GetPrimaryLen. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000071 BYTES: COLLAPSED FUNCTION _wcstombs. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000001EA BYTES: COLLAPSED FUNCTION __wcstombs_lk. PRESS KEYPAD "+" TO EXPAND]
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F7E50 proc near                    ; CODE XREF: __wcstombs_lk+7Dp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_0]
    push    esi
    mov     esi, [esp+4+arg_4]
    mov     eax, edx
    mov     ecx, esi
    test    ecx, ecx
    jz      short loc_4F7E7E

    loc_4F7E61:                             ; CODE XREF: sub_4F7E50+1Bj
    cmp     word ptr [eax], 0
    jz      short loc_4F7E6D
    add     eax, 2
    dec     ecx
    jnz     short loc_4F7E61

    loc_4F7E6D:                             ; CODE XREF: sub_4F7E50+15j
    test    ecx, ecx
    jz      short loc_4F7E7E
    cmp     word ptr [eax], 0
    jnz     short loc_4F7E7E
    sub     eax, edx
    sar     eax, 1
    inc     eax
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4F7E7E:                             ; CODE XREF: sub_4F7E50+Fj
                                            ; sub_4F7E50+1Fj ...
    mov     eax, esi
    pop     esi
    retn
    sub_4F7E50 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000071 BYTES: COLLAPSED FUNCTION _mbtowc. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000FE BYTES: COLLAPSED FUNCTION __mbtowc_lk. PRESS KEYPAD "+" TO EXPAND]
    align 4

    _ungetc:
    push    esi
    mov     esi, [esp+0Ch]
    push    edi
    push    esi
    call    __lock_file
    mov     eax, [esp+10h]
    add     esp, 4
    push    esi
    push    eax
    call    sub_4F8040
    add     esp, 8
    mov     edi, eax
    push    esi
    call    __unlock_file
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F8040 proc near                    ; CODE XREF: __un_inc+Fp
                                            ; .text:004F8025p

    arg_0= dword ptr  8
    arg_4= dword ptr  0Ch

    push    ebx
    mov     ebx, [esp+arg_0]
    cmp     ebx, 0FFFFFFFFh
    push    esi
    jz      short loc_4F80BD
    mov     esi, [esp+4+arg_4]
    mov     eax, [esi+0Ch]
    test    al, 1
    jnz     short loc_4F805E
    test    al, 80h
    jz      short loc_4F80BD
    test    al, 2
    jnz     short loc_4F80BD

    loc_4F805E:                             ; CODE XREF: sub_4F8040+14j
    mov     eax, [esi+8]
    test    eax, eax
    jnz     short loc_4F806E
    push    esi
    call    __getbuf
    add     esp, 4

    loc_4F806E:                             ; CODE XREF: sub_4F8040+23j
    mov     eax, [esi]
    mov     ecx, [esi+8]
    cmp     eax, ecx
    jnz     short loc_4F8081
    mov     ecx, [esi+4]
    test    ecx, ecx
    jnz     short loc_4F80BD
    inc     eax
    mov     [esi], eax

    loc_4F8081:                             ; CODE XREF: sub_4F8040+35j
    test    byte ptr [esi+0Ch], 40h
    jz      short loc_4F809B
    mov     edx, [esi]
    dec     edx
    mov     eax, edx
    mov     [esi], edx
    cmp     [eax], bl
    jz      short loc_4F80A2
    inc     eax
    mov     [esi], eax
    or      eax, 0FFFFFFFFh
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F809B:                             ; CODE XREF: sub_4F8040+45j
    mov     eax, [esi]
    dec     eax
    mov     [esi], eax
    mov     [eax], bl

    loc_4F80A2:                             ; CODE XREF: sub_4F8040+50j
    mov     eax, [esi+0Ch]
    mov     edx, [esi+4]
    and     al, 0EFh
    inc     edx
    or      al, 1
    mov     [esi+4], edx
    mov     [esi+0Ch], eax
    mov     eax, ebx
    and     eax, 0FFh
    pop     esi
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F80BD:                             ; CODE XREF: sub_4F8040+9j
                                            ; sub_4F8040+18j ...
    pop     esi
    or      eax, 0FFFFFFFFh
    pop     ebx
    retn
    sub_4F8040 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000001E BYTES: COLLAPSED FUNCTION _wcslen. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000008F BYTES: COLLAPSED FUNCTION ___crtMessageBoxA. PRESS KEYPAD "+" TO EXPAND]
    align 4

    __fcloseall:                            ; CODE XREF: .text:004F2D8Ej
    push    ebp
    push    esi
    push    2
    xor     ebp, ebp
    call    __lock
    mov     eax, dword_52B520
    mov     esi, 3
    add     esp, 4
    cmp     eax, esi
    jle     short loc_4F8204
    push    edi
    mov     edi, ds:DeleteCriticalSection
    push    ebx
    mov     bl, 83h

    loc_4F81A6:                             ; CODE XREF: .text:004F8200j
    mov     eax, dword_52A508
    mov     eax, [eax+esi*4]
    test    eax, eax
    jz      short loc_4F81F8
    test    [eax+0Ch], bl
    jz      short loc_4F81C6
    push    eax
    call    _fclose
    add     esp, 4
    cmp     eax, 0FFFFFFFFh
    jz      short loc_4F81C6
    inc     ebp

    loc_4F81C6:                             ; CODE XREF: .text:004F81B5j
                                            ; .text:004F81C3j
    cmp     esi, 14h
    jl      short loc_4F81F8
    mov     ecx, dword_52A508
    mov     edx, [ecx+esi*4]
    add     edx, 20h
    push    edx
    call    edi ; DeleteCriticalSection
    mov     eax, dword_52A508
    mov     ecx, [eax+esi*4]
    push    ecx
    call    _free
    mov     edx, dword_52A508
    add     esp, 4
    mov     dword ptr [edx+esi*4], 0

    loc_4F81F8:                             ; CODE XREF: .text:004F81B0j
                                            ; .text:004F81C9j
    mov     eax, dword_52B520
    inc     esi
    cmp     esi, eax
    jl      short loc_4F81A6
    pop     ebx
    pop     edi

    loc_4F8204:                             ; CODE XREF: .text:004F819Aj
    push    2
    call    __unlock
    add     esp, 4
    mov     eax, ebp
    pop     esi
    pop     ebp
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ___crtCompareStringW:
    mov     eax, dword_52A4BC
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     edi, ds:CompareStringW
    test    eax, eax
    jnz     short loc_4F8281
    push    1
    push    offset SrcStr
    push    1
    push    offset SrcStr
    push    0
    push    0
    call    edi ; CompareStringW
    test    eax, eax
    jz      short loc_4F8257
    mov     dword_52A4BC, 1
    jmp     short loc_4F8281
    ; ---------------------------------------------------------------------------

    loc_4F8257:                             ; CODE XREF: .text:004F8249j
    push    1
    push    offset String1
    push    1
    push    offset String1
    push    0
    push    0
    call    ds:CompareStringA
    test    eax, eax
    jz      loc_4F83C4
    mov     dword_52A4BC, 2

    loc_4F8281:                             ; CODE XREF: .text:004F8231j
                                            ; .text:004F8255j
    mov     esi, [esp+20h]
    test    esi, esi
    jle     short loc_4F829B
    mov     ebx, [esp+1Ch]
    push    esi
    push    ebx
    call    sub_4F8430
    add     esp, 8
    mov     esi, eax
    jmp     short loc_4F829F
    ; ---------------------------------------------------------------------------

    loc_4F829B:                             ; CODE XREF: .text:004F8287j
    mov     ebx, [esp+1Ch]

    loc_4F829F:                             ; CODE XREF: .text:004F8299j
    mov     eax, [esp+28h]
    test    eax, eax
    jle     short loc_4F82B9
    push    eax
    mov     eax, [esp+28h]
    push    eax
    call    sub_4F8430
    add     esp, 8
    mov     [esp+28h], eax

    loc_4F82B9:                             ; CODE XREF: .text:004F82A5j
    test    esi, esi
    jz      loc_4F8402
    test    eax, eax
    jz      loc_4F8402
    mov     ecx, dword_52A4BC
    cmp     ecx, 1
    jnz     short loc_4F82ED
    mov     ecx, [esp+24h]
    mov     edx, [esp+18h]
    push    eax
    mov     eax, [esp+18h]
    push    ecx
    push    esi
    push    ebx
    push    edx
    push    eax
    call    edi ; CompareStringW
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F82ED:                             ; CODE XREF: .text:004F82D2j
    cmp     ecx, 2
    jnz     loc_4F841D
    mov     edi, [esp+2Ch]
    mov     dword ptr [esp+20h], 0
    test    edi, edi
    jnz     short loc_4F830C
    mov     edi, CodePage

    loc_4F830C:                             ; CODE XREF: .text:004F8304j
    push    0
    push    0
    push    0
    push    0
    push    esi
    push    ebx
    mov     ebx, ds:WideCharToMultiByte
    push    220h
    push    edi
    call    ebx ; WideCharToMultiByte
    mov     ebp, eax
    test    ebp, ebp
    jnz     short loc_4F832F
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F832F:                             ; CODE XREF: .text:004F8328j
    push    ebp
    call    _malloc
    add     esp, 4
    mov     [esp+2Ch], eax
    test    eax, eax
    jnz     short loc_4F8345
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F8345:                             ; CODE XREF: .text:004F833Ej
    mov     ecx, [esp+1Ch]
    push    0
    push    0
    push    ebp
    push    eax
    push    esi
    push    ecx
    push    220h
    push    edi
    call    ebx ; WideCharToMultiByte
    test    eax, eax
    jz      short loc_4F83AA
    mov     edx, [esp+28h]
    mov     eax, [esp+24h]
    push    0
    push    0
    push    0
    push    0
    push    edx
    push    eax
    push    220h
    push    edi
    call    ebx ; WideCharToMultiByte
    mov     esi, eax
    test    esi, esi
    jz      short loc_4F83AA
    push    esi
    call    _malloc
    add     esp, 4
    mov     [esp+20h], eax
    test    eax, eax
    jz      short loc_4F83AA
    mov     ecx, [esp+28h]
    mov     edx, [esp+24h]
    push    0
    push    0
    push    esi
    push    eax
    push    ecx
    push    edx
    push    220h
    push    edi
    call    ebx ; WideCharToMultiByte
    test    eax, eax
    jnz     short loc_4F83CB

    loc_4F83AA:                             ; CODE XREF: .text:004F835Bj
                                            ; .text:004F837Bj ...
    mov     eax, [esp+2Ch]
    push    eax
    call    _free
    mov     ecx, [esp+24h]
    add     esp, 4
    push    ecx
    call    _free
    add     esp, 4

    loc_4F83C4:                             ; CODE XREF: .text:004F8271j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F83CB:                             ; CODE XREF: .text:004F83A8j
    mov     edi, [esp+20h]
    mov     ebx, [esp+2Ch]
    mov     edx, [esp+18h]
    mov     eax, [esp+14h]
    push    esi
    push    edi
    push    ebp
    push    ebx
    push    edx
    push    eax
    call    ds:CompareStringA
    push    ebx
    mov     esi, eax
    call    _free
    add     esp, 4
    push    edi
    call    _free
    add     esp, 4
    mov     eax, esi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F8402:                             ; CODE XREF: .text:004F82BBj
                                            ; .text:004F82C3j
    sub     esi, eax
    jnz     short loc_4F8410
    mov     eax, 2
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4F8410:                             ; CODE XREF: .text:004F8404j
    xor     eax, eax
    test    esi, esi
    setnl   al
    dec     eax
    and     al, 0FEh
    add     eax, 3

    loc_4F841D:                             ; CODE XREF: .text:004F82F0j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F8430 proc near                    ; CODE XREF: .text:004F828Fp
                                            ; .text:004F82ADp

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    push    edi
    test    edx, edx
    mov     eax, esi
    lea     ecx, [edx-1]
    jz      short loc_4F8453

    loc_4F8443:                             ; CODE XREF: sub_4F8430+21j
    cmp     word ptr [eax], 0
    jz      short loc_4F8459
    add     eax, 2
    mov     edi, ecx
    dec     ecx
    test    edi, edi
    jnz     short loc_4F8443

    loc_4F8453:                             ; CODE XREF: sub_4F8430+11j
    cmp     word ptr [eax], 0
    jnz     short loc_4F8460

    loc_4F8459:                             ; CODE XREF: sub_4F8430+17j
    sub     eax, esi
    sar     eax, 1
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4F8460:                             ; CODE XREF: sub_4F8430+27j
    pop     edi
    mov     eax, edx
    pop     esi
    retn
    sub_4F8430 endp

    ; ---------------------------------------------------------------------------
    align 10h
    ; [000002C5 BYTES: COLLAPSED FUNCTION ___crtCompareStringA. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4F8740 proc near                    ; CODE XREF: ___crtCompareStringA+72p
                                            ; ___crtCompareStringA+90p

    arg_0= dword ptr  4
    arg_4= dword ptr  8

    mov     edx, [esp+arg_4]
    push    esi
    mov     esi, [esp+4+arg_0]
    test    edx, edx
    push    edi
    mov     eax, esi
    lea     ecx, [edx-1]
    jz      short loc_4F8760

    loc_4F8753:                             ; CODE XREF: sub_4F8740+1Ej
    cmp     byte ptr [eax], 0
    jz      short loc_4F8760
    inc     eax
    mov     edi, ecx
    dec     ecx
    test    edi, edi
    jnz     short loc_4F8753

    loc_4F8760:                             ; CODE XREF: sub_4F8740+11j
                                            ; sub_4F8740+16j
    cmp     byte ptr [eax], 0
    jnz     short loc_4F876A
    sub     eax, esi
    pop     edi
    pop     esi
    retn
    ; ---------------------------------------------------------------------------

    loc_4F876A:                             ; CODE XREF: sub_4F8740+23j
    pop     edi
    pop     esi
    mov     eax, edx
    retn
    sub_4F8740 endp

    ; ---------------------------------------------------------------------------
    align 4
    ; [00000203 BYTES: COLLAPSED FUNCTION ___crtsetenv. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000074 BYTES: COLLAPSED FUNCTION _findenv. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000006F BYTES: COLLAPSED FUNCTION _copy_environ. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [000000D0 BYTES: COLLAPSED FUNCTION __strcmpi. PRESS KEYPAD "+" TO EXPAND]
    ; [00000023 BYTES: COLLAPSED FUNCTION ___addl. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000068 BYTES: COLLAPSED FUNCTION ___add_12. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000002E BYTES: COLLAPSED FUNCTION ___shl_12. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000002D BYTES: COLLAPSED FUNCTION ___shr_12. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [000000F1 BYTES: COLLAPSED FUNCTION ___mtold12. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000382 BYTES: COLLAPSED FUNCTION _$I10_OUTPUT. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000002B8 BYTES: COLLAPSED FUNCTION ___ld12mul. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000008A BYTES: COLLAPSED FUNCTION ___multtenpow12. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000255 BYTES: COLLAPSED FUNCTION _ldexp. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    __Getdays:
    sub     esp, 8
    mov     edx, dword_5116AC
    push    ebx
    push    ebp
    push    esi
    push    edi
    mov     [esp+10h], edx
    xor     esi, esi
    mov     ebp, 7

    loc_4F9698:                             ; CODE XREF: .text:004F96BCj
    mov     edi, [edx+1Ch]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     edx, 4
    repne scasb
    mov     edi, [edx-4]
    not     ecx
    dec     ecx
    mov     ebx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    add     ecx, esi
    dec     ebp
    lea     esi, [ecx+ebx+2]
    jnz     short loc_4F9698
    inc     esi
    push    esi
    call    _malloc
    add     esp, 4
    mov     [esp+14h], eax
    test    eax, eax
    jz      loc_4F975C
    mov     ebx, [esp+10h]
    mov     edx, eax
    mov     dword ptr [esp+10h], 7

    loc_4F96E2:                             ; CODE XREF: .text:004F9753j
    mov     byte ptr [edx], 3Ah
    mov     edi, [ebx]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    inc     edx
    add     ebx, 4
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebp, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    add     edx, ecx
    or      ecx, 0FFFFFFFFh
    mov     byte ptr [edx], 3Ah
    mov     edi, [ebx+18h]
    inc     edx
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebp, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+10h]
    not     ecx
    dec     ecx
    add     edx, ecx
    dec     eax
    mov     [esp+10h], eax
    jnz     short loc_4F96E2
    mov     eax, [esp+14h]
    mov     byte ptr [edx], 0

    loc_4F975C:                             ; CODE XREF: .text:004F96CEj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 10h

    __Getmonths:
    sub     esp, 8
    mov     edx, dword_5116AC
    push    ebx
    push    ebp
    push    esi
    mov     [esp+0Ch], edx
    xor     esi, esi
    push    edi
    add     edx, 38h
    mov     ebp, 0Ch

    loc_4F978B:                             ; CODE XREF: .text:004F97AEj
    mov     edi, [edx]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     edx, 4
    repne scasb
    mov     edi, [edx+2Ch]
    not     ecx
    dec     ecx
    mov     ebx, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    add     ecx, esi
    dec     ebp
    lea     esi, [ecx+ebx+2]
    jnz     short loc_4F978B
    inc     esi
    push    esi
    call    _malloc
    add     esp, 4
    mov     [esp+14h], eax
    test    eax, eax
    jz      loc_4F9852
    mov     edx, eax
    mov     eax, [esp+10h]
    mov     dword ptr [esp+10h], 0Ch
    lea     ebx, [eax+68h]

    loc_4F97D7:                             ; CODE XREF: .text:004F9849j
    mov     byte ptr [edx], 3Ah
    mov     edi, [ebx-30h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    inc     edx
    add     ebx, 4
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebp, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    add     edx, ecx
    or      ecx, 0FFFFFFFFh
    mov     byte ptr [edx], 3Ah
    mov     edi, [ebx-4]
    inc     edx
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebp, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+10h]
    not     ecx
    dec     ecx
    add     edx, ecx
    dec     eax
    mov     [esp+10h], eax
    jnz     short loc_4F97D7
    mov     eax, [esp+14h]
    mov     byte ptr [edx], 0

    loc_4F9852:                             ; CODE XREF: .text:004F97C0j
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 8
    retn
    ; ---------------------------------------------------------------------------
    align 8

    __Gettnames:
    sub     esp, 14h
    push    ebx
    mov     ebx, dword_5116AC
    push    ebp
    push    esi
    push    edi
    mov     [esp+10h], ebx
    xor     edx, edx
    mov     esi, ebx
    mov     dword ptr [esp+14h], 7

    loc_4F987D:                             ; CODE XREF: .text:004F98A8j
    mov     edi, [esi]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esi, 4
    repne scasb
    mov     edi, [esi+18h]
    not     ecx
    dec     ecx
    mov     ebp, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+14h]
    not     ecx
    dec     ecx
    add     ecx, edx
    dec     eax
    mov     [esp+14h], eax
    lea     edx, [ecx+ebp+2]
    jnz     short loc_4F987D
    lea     esi, [ebx+38h]
    mov     dword ptr [esp+14h], 0Ch

    loc_4F98B5:                             ; CODE XREF: .text:004F98E1j
    mov     edi, [esi+30h]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    add     esi, 4
    repne scasb
    mov     edi, [esi-4]
    not     ecx
    dec     ecx
    mov     ebp, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+14h]
    not     ecx
    dec     ecx
    add     ecx, edx
    dec     eax
    mov     [esp+14h], eax
    lea     edx, [ecx+ebp+2]
    jnz     short loc_4F98B5
    mov     edi, [ebx+9Ch]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    mov     edi, [ebx+98h]
    not     ecx
    dec     ecx
    mov     esi, ecx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    mov     edi, [ebx+0A0h]
    dec     ecx
    add     ecx, edx
    lea     edx, [ecx+esi+2]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     edi, [ebx+0A4h]
    not     ecx
    dec     ecx
    lea     edx, [edx+ecx+1]
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     edi, [ebx+0A8h]
    not     ecx
    dec     ecx
    lea     edx, [edx+ecx+1]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     eax, [edx+ecx+1]
    add     eax, 0ACh
    push    eax
    call    _malloc
    mov     ebp, eax
    add     esp, 4
    test    ebp, ebp
    mov     [esp+20h], ebp
    jz      loc_4F9BB8
    mov     esi, dword_5116AC
    mov     ecx, 2Bh
    mov     edi, ebp
    add     ebx, 1Ch
    rep movsd
    mov     ecx, [esp+10h]
    lea     edx, [ebp+0ACh]
    sub     eax, ecx
    mov     [esp+14h], ebp
    mov     [esp+1Ch], eax
    mov     dword ptr [esp+18h], 7

    loc_4F9989:                             ; CODE XREF: .text:004F9A0Dj
    mov     [ebp+0], edx
    mov     edi, [ebx-1Ch]
    or      ecx, 0FFFFFFFFh
    xor     eax, eax
    repne scasb
    not     ecx
    sub     edi, ecx
    add     ebx, 4
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebp, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [edx+ecx+1]
    mov     ecx, [esp+1Ch]
    mov     [ecx+ebx-4], edx
    mov     edi, [ebx-4]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebp, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     ebp, [esp+14h]
    mov     eax, [esp+18h]
    not     ecx
    dec     ecx
    add     ebp, 4
    dec     eax
    mov     [esp+14h], ebp
    lea     edx, [edx+ecx+1]
    mov     [esp+18h], eax
    jnz     loc_4F9989
    mov     ecx, [esp+20h]
    mov     eax, [esp+10h]
    add     ecx, 68h
    mov     dword ptr [esp+18h], 0Ch
    mov     [esp+14h], ecx
    lea     ebx, [eax+38h]

    loc_4F9A2D:                             ; CODE XREF: .text:004F9AB2j
    mov     ecx, [esp+1Ch]
    xor     eax, eax
    mov     [ebx+ecx], edx
    mov     edi, [ebx]
    or      ecx, 0FFFFFFFFh
    add     ebx, 4
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebp, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [edx+ecx+1]
    mov     ecx, [esp+14h]
    mov     [ecx], edx
    mov     edi, [ebx+2Ch]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebp, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebp
    or      ecx, 0FFFFFFFFh
    repne scasb
    mov     eax, [esp+18h]
    not     ecx
    dec     ecx
    lea     edx, [edx+ecx+1]
    mov     ecx, [esp+14h]
    add     ecx, 4
    dec     eax
    mov     [esp+14h], ecx
    mov     [esp+18h], eax
    jnz     loc_4F9A2D
    mov     ebp, [esp+20h]
    mov     ecx, [esp+10h]
    xor     eax, eax
    mov     [ebp+98h], edx
    mov     edi, [ecx+98h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    shr     ecx, 2
    mov     ebx, edi
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    or      ecx, 0FFFFFFFFh
    mov     edi, ebx
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [edx+ecx+1]
    mov     ecx, [esp+10h]
    mov     [ebp+9Ch], edx
    mov     edi, [ecx+9Ch]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebx, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [edx+ecx+1]
    mov     ecx, [esp+10h]
    mov     [ebp+0A0h], edx
    mov     edi, [ecx+0A0h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebx, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [edx+ecx+1]
    mov     ecx, [esp+10h]
    mov     [ebp+0A4h], edx
    mov     edi, [ecx+0A4h]
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    sub     edi, ecx
    mov     esi, edi
    mov     eax, ecx
    mov     edi, edx
    mov     ebx, edi
    shr     ecx, 2
    rep movsd
    mov     ecx, eax
    xor     eax, eax
    and     ecx, 3
    rep movsb
    mov     edi, ebx
    or      ecx, 0FFFFFFFFh
    repne scasb
    not     ecx
    dec     ecx
    lea     edx, [edx+ecx+1]
    mov     [ebp+0A8h], edx

    loc_4F9BB8:                             ; CODE XREF: .text:004F9955j
    pop     edi
    mov     eax, ebp
    pop     esi
    pop     ebp
    pop     ebx
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000001F BYTES: COLLAPSED FUNCTION _strftime. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000141 BYTES: COLLAPSED FUNCTION __Strftime. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000004E6 BYTES: COLLAPSED FUNCTION __expandtime. PRESS KEYPAD "+" TO EXPAND]
    align 4
    off_4FA228 dd offset loc_4FA20D         ; DATA XREF: __expandtime+1Dr
    dd offset loc_4F9D8A
    dd offset loc_4F9DD8
    dd offset loc_4F9EAF
    dd offset loc_4F9EDC
    dd offset loc_4F9F71
    dd offset loc_4F9FEA
    dd offset loc_4FA016
    dd offset loc_4FA058
    dd offset loc_4FA123
    dd offset loc_4FA188
    dd offset loc_4FA1DB
    dd offset loc_4F9D64
    dd offset loc_4F9DB1
    dd offset loc_4F9DFF
    dd offset loc_4F9E82
    dd offset loc_4F9F15
    dd offset loc_4F9F43
    dd offset loc_4F9F9C
    dd offset loc_4FA02B
    dd offset loc_4FA0C0
    dd offset loc_4FA155
    dd offset loc_4FA1DB
    dd offset loc_4FA221
    byte_4FA288 db 0                        ; DATA XREF: __expandtime+17r
    dd 6 dup(17171717h), 1171717h, 17171702h, 4031717h, 5171717h, 17171717h
    dd 7170617h, 0A090817h, 1717170Bh, 0C171717h, 170F0E0Dh, 17171717h, 11171710h
    dd 17121717h, 17171717h, 15141317h
    ; ---------------------------------------------------------------------------
    push    ss
    nop
    nop
    ; [0000002D BYTES: COLLAPSED FUNCTION __store_str. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000093 BYTES: COLLAPSED FUNCTION __store_num. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000065 BYTES: COLLAPSED FUNCTION __store_number. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000002AB BYTES: COLLAPSED FUNCTION __store_winword. PRESS KEYPAD "+" TO EXPAND]
    align 4
    off_4FA6CC dd offset loc_4FA659         ; DATA XREF: __store_winword+5Dr
    dd offset loc_4FA611
    dd offset loc_4FA5B1
    dd offset loc_4FA484
    dd offset loc_4FA611
    dd offset loc_4FA531
    dd offset loc_4FA591
    dd offset loc_4FA5D1
    dd offset loc_4FA5F1
    dd offset loc_4FA56D
    dd offset loc_4FA4A1                    ; default
    byte_4FA6F8 db 0                        ; DATA XREF: __store_winword+57r
    dd 6 dup(0A0A0A0Ah), 0A0A010Ah, 0A0A0A0Ah, 0A0A0A02h, 0A0A030Ah, 4 dup(0A0A0A0Ah)
    dd 0A0A040Ah, 0A0A0A05h, 0A0A0A06h, 0A0A070Ah, 80A0A0Ah, 0A0A0A0Ah
    db 0Ah, 9, 90h
    off_4FA74C dd offset loc_4FA491         ; DATA XREF: __store_winword+6Ar
    dd offset loc_4FA49B                    ; jump table for switch statement
    dd offset loc_4FA51B
    dd offset loc_4FA526
    off_4FA75C dd offset loc_4FA542         ; DATA XREF: __store_winword+11Br
    dd offset loc_4FA54C                    ; jump table for switch statement
    dd offset loc_4FA557
    dd offset loc_4FA562
    align 8
    ; [000001AC BYTES: COLLAPSED FUNCTION ___getlocaleinfo. PRESS KEYPAD "+" TO EXPAND]
    align 8
    mov     eax, dword_5116E8
    retn
    ; ---------------------------------------------------------------------------
    align 10h
    ; [0000003D BYTES: COLLAPSED FUNCTION __itoa. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [00000061 BYTES: COLLAPSED FUNCTION _xtoa. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000041 BYTES: COLLAPSED FUNCTION __ltoa. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [0000001E BYTES: COLLAPSED FUNCTION __ultoa. PRESS KEYPAD "+" TO EXPAND]
    align 4
    ; [0000004A BYTES: COLLAPSED FUNCTION __i64toa. PRESS KEYPAD "+" TO EXPAND]
    align 8
    ; [00000081 BYTES: COLLAPSED FUNCTION x64toa(x,x,x,x,x). PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000020 BYTES: COLLAPSED FUNCTION __ui64toa. PRESS KEYPAD "+" TO EXPAND]
    ; [00000101 BYTES: COLLAPSED FUNCTION __strnicmp. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [000000C2 BYTES: COLLAPSED FUNCTION __mbschr. PRESS KEYPAD "+" TO EXPAND]
    align 10h
    ; [00000050 BYTES: COLLAPSED FUNCTION __strdup. PRESS KEYPAD "+" TO EXPAND]
    ; [00000130 BYTES: COLLAPSED FUNCTION ___crtGetLocaleInfoW. PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; int __cdecl sub_4FAEB0(LCID Locale,LCTYPE LCType,LPSTR lpMultiByteStr,int cchData,UINT CodePage)
    sub_4FAEB0 proc near                    ; CODE XREF: ___getlocaleinfo+43p
                                            ; ___getlocaleinfo+61p ...

    Locale= dword ptr  4
    LCType= dword ptr  8
    lpMultiByteStr= dword ptr  0Ch
    cchData= dword ptr  10h
    CodePage= dword ptr  14h

    mov     eax, dword_52A4E0
    push    ebx
    push    ebp
    push    esi
    mov     esi, ds:GetLocaleInfoA
    push    edi
    test    eax, eax
    jnz     short loc_4FAEF8
    push    0                               ; cchData
    push    0                               ; lpLCData
    push    1                               ; LCType
    push    0                               ; Locale
    call    ds:GetLocaleInfoW
    test    eax, eax
    jz      short loc_4FAEDC
    mov     eax, 1
    jmp     short loc_4FAEF3
    ; ---------------------------------------------------------------------------

    loc_4FAEDC:                             ; CODE XREF: sub_4FAEB0+23j
    push    0                               ; cchData
    push    0                               ; lpLCData
    push    1                               ; LCType
    push    0                               ; Locale
    call    esi ; GetLocaleInfoA
    test    eax, eax
    jz      loc_4FAFD8
    mov     eax, 2

    loc_4FAEF3:                             ; CODE XREF: sub_4FAEB0+2Aj
    mov     dword_52A4E0, eax

    loc_4FAEF8:                             ; CODE XREF: sub_4FAEB0+11j
    cmp     eax, 2
    jnz     short loc_4FAF18
    mov     eax, [esp+10h+cchData]
    mov     ecx, [esp+10h+lpMultiByteStr]
    mov     edx, [esp+10h+LCType]
    push    eax                             ; cchData
    mov     eax, [esp+14h+Locale]
    push    ecx                             ; lpLCData
    push    edx                             ; LCType
    push    eax                             ; Locale
    call    esi ; GetLocaleInfoA
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4FAF18:                             ; CODE XREF: sub_4FAEB0+4Bj
    cmp     eax, 1
    jnz     loc_4FAFEA
    mov     eax, [esp+10h+CodePage]
    test    eax, eax
    jnz     short loc_4FAF33
    mov     ecx, CodePage
    mov     [esp+10h+CodePage], ecx

    loc_4FAF33:                             ; CODE XREF: sub_4FAEB0+77j
    mov     ebx, [esp+10h+LCType]
    mov     ebp, [esp+10h+Locale]
    push    0                               ; cchData
    push    0                               ; lpLCData
    push    ebx                             ; LCType
    push    ebp                             ; Locale
    call    ds:GetLocaleInfoW
    mov     edi, eax
    test    edi, edi
    jnz     short loc_4FAF52
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4FAF52:                             ; CODE XREF: sub_4FAEB0+9Bj
    lea     edx, [edi+edi]
    push    edx                             ; size_t
    call    _malloc
    mov     esi, eax
    add     esp, 4
    test    esi, esi
    jnz     short loc_4FAF69
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4FAF69:                             ; CODE XREF: sub_4FAEB0+B2j
    push    edi                             ; cchData
    push    esi                             ; lpLCData
    push    ebx                             ; LCType
    push    ebp                             ; Locale
    call    ds:GetLocaleInfoW
    test    eax, eax
    jz      short loc_4FAFCF
    mov     eax, [esp+10h+cchData]
    push    0                               ; lpUsedDefaultChar
    test    eax, eax
    push    0                               ; lpDefaultChar
    jnz     short loc_4FAFB0
    mov     eax, [esp+18h+CodePage]
    push    0                               ; cchMultiByte
    push    0                               ; lpMultiByteStr
    push    0FFFFFFFFh                      ; cchWideChar
    push    esi                             ; lpWideCharStr
    push    220h                            ; dwFlags
    push    eax                             ; CodePage
    call    ds:WideCharToMultiByte
    mov     edi, eax
    test    edi, edi
    jz      short loc_4FAFCF
    push    esi                             ; void *
    call    _free
    add     esp, 4
    mov     eax, edi
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn                                    ; lpDefaultChar
    ; ---------------------------------------------------------------------------

    loc_4FAFB0:                             ; CODE XREF: sub_4FAEB0+D1j
    mov     ecx, [esp+18h+lpMultiByteStr]
    mov     edx, [esp+18h+CodePage]
    push    eax                             ; cchMultiByte
    push    ecx                             ; lpMultiByteStr
    push    0FFFFFFFFh                      ; cchWideChar
    push    esi                             ; lpWideCharStr
    push    220h                            ; dwFlags
    push    edx                             ; CodePage
    call    ds:WideCharToMultiByte
    mov     edi, eax
    test    edi, edi
    jnz     short loc_4FAFDF

    loc_4FAFCF:                             ; CODE XREF: sub_4FAEB0+C5j
                                            ; sub_4FAEB0+EEj
    push    esi                             ; void *
    call    _free
    add     esp, 4

    loc_4FAFD8:                             ; CODE XREF: sub_4FAEB0+38j
    xor     eax, eax
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    ; ---------------------------------------------------------------------------

    loc_4FAFDF:                             ; CODE XREF: sub_4FAEB0+11Dj
    push    esi                             ; void *
    call    _free
    add     esp, 4
    mov     eax, edi

    loc_4FAFEA:                             ; CODE XREF: sub_4FAEB0+6Bj
    pop     edi
    pop     esi
    pop     ebp
    pop     ebx
    retn
    sub_4FAEB0 endp

    ; ---------------------------------------------------------------------------
    align 4

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: thunk

    DirectPlayEnumerateA proc near          ; CODE XREF: .text:004CA435p
    jmp     ds:__imp_DirectPlayEnumerateA
    DirectPlayEnumerateA endp

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    ; Attributes: thunk

    DirectPlayLobbyCreateA proc near        ; CODE XREF: sub_4CA490+47p
    jmp     ds:__imp_DirectPlayLobbyCreateA
    DirectPlayLobbyCreateA endp

    ; [00000006 BYTES: COLLAPSED FUNCTION DirectPlayCreate. PRESS KEYPAD "+" TO EXPAND]
    ; [00000006 BYTES: COLLAPSED FUNCTION DirectSoundCreate. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------
    jmp     ds:auxGetVolume                 ; Get the current volume setting of
                                            ; the specified auxiliary output device
    ; ---------------------------------------------------------------------------
    jmp     ds:waveOutGetVolume
    ; ---------------------------------------------------------------------------
    jmp     ds:auxGetDevCapsA               ; Get the capabilities of a given
                                            ; auxiliary output device
    ; ---------------------------------------------------------------------------
    jmp     ds:auxGetNumDevs                ; Get number of auxiliary output
                                            ; devices present in the system
    ; ---------------------------------------------------------------------------
    jmp     ds:waveOutGetNumDevs
    ; ---------------------------------------------------------------------------
    jmp     ds:waveOutSetVolume
    ; ---------------------------------------------------------------------------
    jmp     ds:auxSetVolume
    ; ---------------------------------------------------------------------------
    jmp     ds:GlobalLock
    ; ---------------------------------------------------------------------------
    jmp     ds:GlobalSize
    ; ---------------------------------------------------------------------------
    jmp     ds:GetVersionExA                ; Get extended information about the
                                            ; version of the operating system
    ; ---------------------------------------------------------------------------
    jmp     ds:SetEvent
    ; ---------------------------------------------------------------------------
    jmp     ds:InterlockedExchange
    ; ---------------------------------------------------------------------------
    jmp     ds:GetDriveTypeA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetVolumeInformationA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetFullPathNameA
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateEventA
    ; ---------------------------------------------------------------------------
    jmp     ds:ResetEvent
    ; ---------------------------------------------------------------------------
    jmp     ds:OutputDebugStringA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetCurrentThreadId
    ; ---------------------------------------------------------------------------
    jmp     ds:LeaveCriticalSection
    ; ---------------------------------------------------------------------------
    jmp     ds:EnterCriticalSection
    ; ---------------------------------------------------------------------------
    jmp     ds:VirtualProtect
    ; ---------------------------------------------------------------------------
    jmp     ds:VirtualQuery
    ; ---------------------------------------------------------------------------
    jmp     ds:GetCommandLineA
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateThread
    ; ---------------------------------------------------------------------------
    jmp     ds:SetUnhandledExceptionFilter
    ; ---------------------------------------------------------------------------
    jmp     ds:GetThreadPriority
    ; ---------------------------------------------------------------------------
    jmp     ds:GlobalAlloc
    ; ---------------------------------------------------------------------------
    jmp     ds:InitializeCriticalSection
    ; ---------------------------------------------------------------------------
    jmp     ds:VirtualAlloc
    ; ---------------------------------------------------------------------------
    jmp     ds:VirtualFree
    ; ---------------------------------------------------------------------------
    jmp     ds:GetModuleHandleA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetCurrentProcess
    ; ---------------------------------------------------------------------------
    jmp     ds:GetLastError
    ; ---------------------------------------------------------------------------
    jmp     ds:GetSystemInfo
    ; ---------------------------------------------------------------------------
    jmp     ds:FileTimeToDosDateTime
    ; ---------------------------------------------------------------------------
    jmp     ds:FileTimeToLocalFileTime
    ; ---------------------------------------------------------------------------
    jmp     ds:GetFileTime
    ; ---------------------------------------------------------------------------
    jmp     ds:GetFileSize
    ; ---------------------------------------------------------------------------
    jmp     ds:DeleteCriticalSection
    ; ---------------------------------------------------------------------------
    jmp     ds:MapViewOfFile
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateFileMappingA
    ; ---------------------------------------------------------------------------
    jmp     ds:UnmapViewOfFile
    ; ---------------------------------------------------------------------------
    jmp     ds:SystemTimeToFileTime
    ; ---------------------------------------------------------------------------
    jmp     ds:GetSystemTime
    ; ---------------------------------------------------------------------------
    jmp     ds:QueryPerformanceFrequency
    ; ---------------------------------------------------------------------------
    jmp     ds:SetPriorityClass
    ; ---------------------------------------------------------------------------
    jmp     ds:GetPriorityClass
    ; ---------------------------------------------------------------------------
    jmp     ds:DeviceIoControl
    ; ---------------------------------------------------------------------------
    jmp     ds:ExitProcess
    ; ---------------------------------------------------------------------------
    jmp     ds:TerminateProcess
    ; [00000006 BYTES: COLLAPSED FUNCTION RtlUnwind. PRESS KEYPAD "+" TO EXPAND]
    ; ---------------------------------------------------------------------------
    jmp     ds:InterlockedDecrement
    ; ---------------------------------------------------------------------------
    jmp     ds:InterlockedIncrement
    ; ---------------------------------------------------------------------------
    jmp     ds:TlsSetValue
    ; ---------------------------------------------------------------------------
    jmp     ds:ExitThread
    ; ---------------------------------------------------------------------------
    jmp     ds:GetTimeZoneInformation
    ; ---------------------------------------------------------------------------
    jmp     ds:GetLocalTime
    ; ---------------------------------------------------------------------------
    jmp     ds:SetConsoleCtrlHandler
    ; ---------------------------------------------------------------------------
    jmp     ds:GetStartupInfoA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetVersion                   ; Get current version number of Windows
                                            ; and information about the operating system platform
    ; ---------------------------------------------------------------------------
    jmp     ds:SetEndOfFile
    ; ---------------------------------------------------------------------------
    jmp     ds:ResumeThread
    ; ---------------------------------------------------------------------------
    jmp     ds:MoveFileA
    ; ---------------------------------------------------------------------------
    jmp     ds:DeleteFileA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetCurrentDirectoryA
    ; ---------------------------------------------------------------------------
    jmp     ds:SetEnvironmentVariableA
    ; ---------------------------------------------------------------------------
    jmp     ds:FindFirstFileA
    ; ---------------------------------------------------------------------------
    jmp     ds:FindNextFileA
    ; ---------------------------------------------------------------------------
    jmp     ds:FindClose
    ; ---------------------------------------------------------------------------
    jmp     ds:FileTimeToSystemTime
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateDirectoryA
    ; ---------------------------------------------------------------------------
    jmp     ds:RaiseException
    ; ---------------------------------------------------------------------------
    jmp     ds:HeapFree
    ; ---------------------------------------------------------------------------
    jmp     ds:HeapAlloc
    ; ---------------------------------------------------------------------------
    jmp     ds:HeapSize
    ; ---------------------------------------------------------------------------
    jmp     ds:HeapReAlloc
    ; ---------------------------------------------------------------------------
    jmp     ds:FatalAppExitA
    ; ---------------------------------------------------------------------------
    jmp     ds:TlsAlloc                     ; Allocate a thread local storage (TLS) index
    ; ---------------------------------------------------------------------------
    jmp     ds:TlsFree                      ; Release a thread local storage (TLS) index
    ; ---------------------------------------------------------------------------
    jmp     ds:SetLastError
    ; ---------------------------------------------------------------------------
    jmp     ds:TlsGetValue
    ; ---------------------------------------------------------------------------
    jmp     ds:MultiByteToWideChar
    ; ---------------------------------------------------------------------------
    jmp     ds:WideCharToMultiByte
    ; ---------------------------------------------------------------------------
    jmp     ds:LCMapStringA
    ; ---------------------------------------------------------------------------
    jmp     ds:LCMapStringW
    ; ---------------------------------------------------------------------------
    jmp     ds:ReadFile
    ; ---------------------------------------------------------------------------
    jmp     ds:UnhandledExceptionFilter
    ; ---------------------------------------------------------------------------
    jmp     ds:GetCPInfo
    ; ---------------------------------------------------------------------------
    jmp     ds:GetACP
    ; ---------------------------------------------------------------------------
    jmp     ds:GetOEMCP
    ; ---------------------------------------------------------------------------
    jmp     ds:FreeEnvironmentStringsA
    ; ---------------------------------------------------------------------------
    jmp     ds:FreeEnvironmentStringsW
    ; ---------------------------------------------------------------------------
    jmp     ds:GetEnvironmentStrings
    ; ---------------------------------------------------------------------------
    jmp     ds:GetEnvironmentStringsW
    ; ---------------------------------------------------------------------------
    jmp     ds:SetHandleCount
    ; ---------------------------------------------------------------------------
    jmp     ds:GetStdHandle
    ; ---------------------------------------------------------------------------
    jmp     ds:GetFileType
    ; ---------------------------------------------------------------------------
    jmp     ds:HeapDestroy
    ; ---------------------------------------------------------------------------
    jmp     ds:HeapCreate
    ; ---------------------------------------------------------------------------
    jmp     ds:SetStdHandle
    ; ---------------------------------------------------------------------------
    jmp     ds:GetStringTypeA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetStringTypeW
    ; ---------------------------------------------------------------------------
    jmp     ds:FlushFileBuffers
    ; ---------------------------------------------------------------------------
    jmp     ds:IsBadReadPtr
    ; ---------------------------------------------------------------------------
    jmp     ds:IsBadWritePtr
    ; ---------------------------------------------------------------------------
    jmp     ds:IsBadCodePtr
    ; ---------------------------------------------------------------------------
    jmp     ds:IsValidLocale
    ; ---------------------------------------------------------------------------
    jmp     ds:IsValidCodePage
    ; ---------------------------------------------------------------------------
    jmp     ds:GetLocaleInfoA
    ; ---------------------------------------------------------------------------
    jmp     ds:EnumSystemLocalesA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetUserDefaultLCID
    ; ---------------------------------------------------------------------------
    jmp     ds:CompareStringA
    ; ---------------------------------------------------------------------------
    jmp     ds:CompareStringW
    ; ---------------------------------------------------------------------------
    jmp     ds:GetLocaleInfoW
    ; ---------------------------------------------------------------------------
    jmp     ds:CloseClipboard
    ; ---------------------------------------------------------------------------
    jmp     ds:GetClipboardData
    ; ---------------------------------------------------------------------------
    jmp     ds:OpenClipboard
    ; ---------------------------------------------------------------------------
    jmp     ds:IsCharAlphaA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetSystemMetrics
    ; ---------------------------------------------------------------------------
    jmp     ds:DestroyWindow
    ; ---------------------------------------------------------------------------
    jmp     ds:UpdateWindow
    ; ---------------------------------------------------------------------------
    jmp     ds:ShowWindow
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateWindowExA
    ; ---------------------------------------------------------------------------
    jmp     ds:RegisterClassA
    ; ---------------------------------------------------------------------------
    jmp     ds:LoadCursorA
    ; ---------------------------------------------------------------------------
    jmp     ds:LoadIconA
    ; ---------------------------------------------------------------------------
    jmp     ds:SystemParametersInfoA
    ; ---------------------------------------------------------------------------
    jmp     ds:DefWindowProcA
    ; ---------------------------------------------------------------------------
    jmp     ds:PostMessageA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetAsyncKeyState             ; Determine whether a key is up or down
    ; ---------------------------------------------------------------------------
    jmp     ds:SetCursorPos
    ; ---------------------------------------------------------------------------
    jmp     ds:OffsetRect                   ; Move the specified rectangle by
                                            ; the specified offsets
    ; ---------------------------------------------------------------------------
    jmp     ds:GetClientRect                ; Get the coordinates of a window's client area
    ; ---------------------------------------------------------------------------
    jmp     ds:SendMessageA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetClassNameA
    ; ---------------------------------------------------------------------------
    jmp     ds:EnumWindows
    ; ---------------------------------------------------------------------------
    jmp     ds:IsDialogMessageA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetParent
    ; ---------------------------------------------------------------------------
    jmp     ds:DialogBoxIndirectParamA      ; Create a modal dialog box from a
                                            ; dialog box template in memory
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateDialogIndirectParamA   ; Create a modeless dialog box from
                                            ; a dialog box template in memory
    ; ---------------------------------------------------------------------------
    jmp     ds:GetDesktopWindow
    ; ---------------------------------------------------------------------------
    jmp     ds:KillTimer
    ; ---------------------------------------------------------------------------
    jmp     ds:IsWindowVisible
    ; ---------------------------------------------------------------------------
    jmp     ds:SetTimer
    ; ---------------------------------------------------------------------------
    jmp     ds:SetForegroundWindow
    ; ---------------------------------------------------------------------------
    jmp     ds:SetFocus
    ; ---------------------------------------------------------------------------
    jmp     ds:EnableWindow                 ; Enable/disable mouse and keyboard input
    ; ---------------------------------------------------------------------------
    jmp     ds:GetWindowLongA
    ; ---------------------------------------------------------------------------
    jmp     ds:SetWindowLongA
    ; ---------------------------------------------------------------------------
    jmp     ds:SetDlgItemTextA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetDlgItemTextA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetDlgItem
    ; ---------------------------------------------------------------------------
    jmp     ds:CheckDlgButton               ; Change the check state of a button control
    ; ---------------------------------------------------------------------------
    jmp     ds:RegisterHotKey
    ; ---------------------------------------------------------------------------
    jmp     ds:SendDlgItemMessageA
    ; ---------------------------------------------------------------------------
    jmp     ds:GetWindowRect
    ; ---------------------------------------------------------------------------
    jmp     ds:GetWindowPlacement
    ; ---------------------------------------------------------------------------
    jmp     ds:IsZoomed
    ; ---------------------------------------------------------------------------
    jmp     ds:IsIconic
    ; ---------------------------------------------------------------------------
    jmp     ds:RealizePalette
    ; ---------------------------------------------------------------------------
    jmp     ds:SelectPalette
    ; ---------------------------------------------------------------------------
    jmp     ds:SelectObject
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateDIBSection
    ; ---------------------------------------------------------------------------
    jmp     ds:CreateCompatibleDC
    ; ---------------------------------------------------------------------------
    jmp     ds:DeleteObject
    ; ---------------------------------------------------------------------------
    jmp     ds:DeleteDC
    ; ---------------------------------------------------------------------------
    jmp     ds:GetStockObject
    ; ---------------------------------------------------------------------------
    jmp     ds:TextOutA
    ; ---------------------------------------------------------------------------
    jmp     ds:SetTextColor
    ; ---------------------------------------------------------------------------
    jmp     ds:SetBkMode
    ; ---------------------------------------------------------------------------
    jmp     ds:SetDIBColorTable
    ; ---------------------------------------------------------------------------
    jmp     ds:CreatePalette
    ; ---------------------------------------------------------------------------
    jmp     ds:GetPaletteEntries
    ; ---------------------------------------------------------------------------
    jmp     ds:BitBlt
    ; ---------------------------------------------------------------------------
    jmp     ds:RegCreateKeyExA
    ; ---------------------------------------------------------------------------
    jmp     ds:RegQueryValueA
    ; ---------------------------------------------------------------------------
    jmp     ds:RegOpenKeyA
    ; ---------------------------------------------------------------------------
    jmp     ds:RegCreateKeyA
    ; ---------------------------------------------------------------------------
    jmp     ds:ShellExecuteA                ; Opens or prints a specified file
    ; [0000001F BYTES: COLLAPSED FUNCTION __hypot. PRESS KEYPAD "+" TO EXPAND]
    align 4

    __cabs:
    mov     eax, [esp+10h]
    mov     ecx, [esp+0Ch]
    mov     edx, [esp+8]
    push    11h
    push    eax
    mov     eax, [esp+0Ch]
    push    ecx
    push    edx
    push    eax
    call    __hypothlp
    add     esp, 14h
    retn
    ; ---------------------------------------------------------------------------
    align 4
    ; [00000316 BYTES: COLLAPSED FUNCTION __hypothlp. PRESS KEYPAD "+" TO EXPAND]
    align 10h

    __CIsqrt:
    sub     esp, 8
    fst     qword ptr [esp]
    call    unknown_libname_97
    call    loc_4FB7BD
    add     esp, 8
    retn
    ; [000000A6 BYTES: COLLAPSED FUNCTION _sqrt. PRESS KEYPAD "+" TO EXPAND]
    align 8

    loc_4FB860:                             ; DATA XREF: sub_4441A0+5o
    mov     eax, offset stru_4FED38
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 8

    loc_4FB870:                             ; DATA XREF: .text:00444585o
    mov     eax, offset stru_4FED90
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 8

    loc_4FB880:                             ; DATA XREF: sub_45B250+5o
    mov     eax, offset stru_4FEDE8
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 8

    loc_4FB890:                             ; DATA XREF: sub_45B490+5o
    mov     eax, offset stru_4FEE40
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 8

    loc_4FB8A0:                             ; DATA XREF: sub_45B670+5o
    mov     eax, offset stru_4FEE98
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 8

    loc_4FB8B0:                             ; DATA XREF: sub_49EE30+5o
    mov     eax, offset stru_4FEEF0
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 8

    loc_4FB8C0:                             ; DATA XREF: sub_4C4FA0+5o
    mov     eax, offset stru_4FEFE8
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 8
    ; [00000008 BYTES: COLLAPSED FUNCTION unknown_libname_131. PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4FB8D8 proc near                    ; DATA XREF: .rdata:004FF080o
    lea     ecx, [ebp-28h]
    jmp     ??1exception@@UAE@XZ            ; exception::~exception(void)
    sub_4FB8D8 endp

    ; ---------------------------------------------------------------------------

    loc_4FB8E0:                             ; DATA XREF: sub_4E3A90+2o
    mov     eax, offset stru_4FF080
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 8

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4FB8F0 proc near                    ; DATA XREF: .rdata:004FF0B0o
    mov     ecx, [ebp-10h]
    jmp     ??1exception@@UAE@XZ            ; exception::~exception(void)
    sub_4FB8F0 endp

    ; ---------------------------------------------------------------------------

    loc_4FB8F8:                             ; DATA XREF: sub_4E3EB0+2o
    mov     eax, offset stru_4FF0B0
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 10h
    ; [00000008 BYTES: COLLAPSED FUNCTION unknown_libname_132. PRESS KEYPAD "+" TO EXPAND]

    ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

    sub_4FB918 proc near                    ; DATA XREF: .rdata:004FF0D8o
    lea     ecx, [ebp-28h]
    jmp     ??1exception@@UAE@XZ            ; exception::~exception(void)
    sub_4FB918 endp

    ; ---------------------------------------------------------------------------

    loc_4FB920:                             ; DATA XREF: sub_4E4010+2o
    mov     eax, offset stru_4FF0D8
    jmp     ___CxxFrameHandler
    ; ---------------------------------------------------------------------------
    align 100h
    _text ends

    ; Section 2. (virtual address 000FC000)
    ; Virtual size                  : 0000468C (  18060.)
    ; Section size in file          : 00004800 (  18432.)
    ; Offset to raw data for section: 000FAE00
    ; Flags 40000040: Data Readable
    ; Alignment     : 16 bytes ?
    ;
    ; Imports from ADVAPI32
    ;
    ; ---------------------------------------------------------------------------

    ; Segment type: Externs
    ; _idata
    ; LONG __stdcall RegOpenKeyExA(HKEY hKey,LPCSTR lpSubKey,DWORD ulOptions,REGSAM samDesired,PHKEY phkResult)
    extrn RegOpenKeyExA:dword               ; DATA XREF: sub_49E830+25Dr
                                            ; sub_49E830+4C0r ...
    ; LONG __stdcall RegQueryValueExA(HKEY hKey,LPCSTR lpValueName,LPDWORD lpReserved,LPDWORD lpType,LPBYTE lpData,LPDWORD lpcbData)
    extrn RegQueryValueExA:dword            ; DATA XREF: sub_49E830+281r
                                            ; .text:0049F84Er ...
    ; LONG __stdcall RegCreateKeyA(HKEY hKey,LPCSTR lpSubKey,PHKEY phkResult)
    extrn RegCreateKeyA:dword               ; DATA XREF: sub_4E2BE0+75r
                                            ; sub_4E2BE0+8Ar ...
    ; LONG __stdcall RegOpenKeyA(HKEY hKey,LPCSTR lpSubKey,PHKEY phkResult)
    extrn RegOpenKeyA:dword                 ; DATA XREF: sub_4DA5B0+60r
                                            ; sub_4DA5B0+79r ...
    ; LONG __stdcall RegQueryValueA(HKEY hKey,LPCSTR lpSubKey,LPSTR lpValue,PLONG lpcbValue)
    extrn RegQueryValueA:dword              ; DATA XREF: sub_4DA5B0+94r
                                            ; sub_4DA5B0+10Ar ...
    ; LONG __stdcall RegCreateKeyExA(HKEY hKey,LPCSTR lpSubKey,DWORD Reserved,LPSTR lpClass,DWORD dwOptions,REGSAM samDesired,LPSECURITY_ATTRIBUTES lpSecurityAttributes,PHKEY phkResult,LPDWORD lpdwDisposition)
    extrn RegCreateKeyExA:dword             ; DATA XREF: WriteRegistryValue+1Fr
                                            ; WriteRegistryValue+4Br ...
    ; LONG __stdcall RegSetValueExA(HKEY hKey,LPCSTR lpValueName,DWORD Reserved,DWORD dwType,const BYTE *lpData,DWORD cbData)
    extrn RegSetValueExA:dword              ; DATA XREF: sub_49E830+29Er
                                            ; sub_49E830+4E7r ...
    ; LONG __stdcall RegFlushKey(HKEY hKey)
    extrn RegFlushKey:dword                 ; DATA XREF: sub_49E830+333r
                                            ; sub_49E830+4F2r ...
                                            ; Write all the attributes of the
                                            ; specified open key into the registry
    ; LONG __stdcall RegCloseKey(HKEY hKey)
    extrn RegCloseKey:dword                 ; DATA XREF: sub_49E830+33Er
                                            ; sub_49E830+4FDr ...
    ; BOOL __stdcall GetUserNameA(LPSTR lpBuffer,LPDWORD nSize)
    extrn GetUserNameA:dword                ; DATA XREF: sub_441080+A3r
                                            ; sub_4517B0+130r ...

    ;
    ; Imports from DDRAW
    ;
    ; HRESULT __stdcall __imp_DirectDrawCreate(GUID *lpGUID,LPDIRECTDRAW *lplpDD,IUnknown *pUnkOuter)
    extrn __imp_DirectDrawCreate:dword      ; DATA XREF: DirectDrawCreater

    ;
    ; Imports from DPLAYX
    ;
    extrn __imp_DirectPlayEnumerateA:dword  ; DATA XREF: DirectPlayEnumerateAr
    extrn __imp_DirectPlayCreate:dword      ; DATA XREF: DirectPlayCreater
    extrn __imp_DirectPlayLobbyCreateA:dword ; DATA XREF: DirectPlayLobbyCreateAr

    ;
    ; Imports from DSOUND
    ;
    extrn __imp_DirectSoundCreate:dword     ; DATA XREF: DirectSoundCreater

    ;
    ; Imports from GDI32
    ;
    ; COLORREF __stdcall SetTextColor(HDC,COLORREF)
    extrn SetTextColor:dword                ; DATA XREF: .text:004B6646r
                                            ; .text:004FB3FEr
    ; BOOL __stdcall DeleteDC(HDC)
    extrn DeleteDC:dword                    ; DATA XREF: sub_4B5510+7Dr
                                            ; sub_4B5980+2D2r ...
    ; UINT __stdcall SetDIBColorTable(HDC,UINT,UINT,const RGBQUAD *)
    extrn SetDIBColorTable:dword            ; DATA XREF: sub_4BA200+20Ar
                                            ; .text:004FB40Ar
    ; int __stdcall SetBkMode(HDC,int)
    extrn SetBkMode:dword                   ; DATA XREF: .text:004B65FAr
                                            ; .text:004FB404r
    ; HPALETTE __stdcall CreatePalette(const LOGPALETTE *)
    extrn CreatePalette:dword               ; DATA XREF: sub_4BA200+1EBr
                                            ; .text:004FB410r
    ; UINT __stdcall RealizePalette(HDC)
    extrn RealizePalette:dword              ; DATA XREF: .text:004B4F7Er
                                            ; sub_4B5CC0+371r ...
    ; UINT __stdcall GetSystemPaletteEntries(HDC,UINT,UINT,LPPALETTEENTRY)
    extrn GetSystemPaletteEntries:dword     ; DATA XREF: sub_47BF70+E9r
                                            ; .text:0047C24Cr ...
    ; HGDIOBJ __stdcall SelectObject(HDC,HGDIOBJ)
    extrn SelectObject:dword                ; DATA XREF: sub_4B5510+394r
                                            ; .text:004B6605r ...
    ; HBITMAP __stdcall CreateDIBSection(HDC,const BITMAPINFO *,UINT,void **,HANDLE,DWORD)
    extrn CreateDIBSection:dword            ; DATA XREF: sub_4B5510+35Ar
                                            ; .text:004FB3DAr
    ; HPALETTE __stdcall SelectPalette(HDC,HPALETTE,BOOL)
    extrn SelectPalette:dword               ; DATA XREF: .text:004B4F77r
                                            ; sub_4B5CC0+36Ar ...
    ; UINT __stdcall GetPaletteEntries(HPALETTE,UINT,UINT,LPPALETTEENTRY)
    extrn GetPaletteEntries:dword           ; DATA XREF: .text:004BA4F3r
                                            ; .text:004FB416r
    ; BOOL __stdcall DeleteObject(HGDIOBJ)
    extrn DeleteObject:dword                ; DATA XREF: sub_4B5510+8Br
                                            ; sub_4B5510+99r ...
    ; BOOL __stdcall PatBlt(HDC,int,int,int,int,DWORD)
    extrn PatBlt:dword                      ; DATA XREF: .text:0047C358r
                                            ; .text:0049F830r
    ; BOOL __stdcall BitBlt(HDC,int,int,int,int,HDC,int,int,DWORD)
    extrn BitBlt:dword                      ; DATA XREF: sub_4C60D0+36r
                                            ; sub_4C60D0+63r ...
    ; HGDIOBJ __stdcall GetStockObject(int)
    extrn GetStockObject:dword              ; DATA XREF: sub_4B5980+24Dr
                                            ; .text:004FB3F2r
    ; HDC __stdcall CreateCompatibleDC(HDC)
    extrn CreateCompatibleDC:dword          ; DATA XREF: sub_4B5510+2C6r
                                            ; .text:004FB3E0r
    ; BOOL __stdcall TextOutA(HDC,int,int,LPCSTR,int)
    extrn TextOutA:dword                    ; DATA XREF: .text:004B665Br
                                            ; .text:004FB3F8r

    ;
    ; Imports from KERNEL32
    ;
    ; FARPROC __stdcall GetProcAddress(HMODULE hModule,LPCSTR lpProcName)
    extrn GetProcAddress:dword              ; DATA XREF: sub_45B250+189r
                                            ; sub_45B250+1C9r ...
    ; BOOL __stdcall GlobalUnlock(HGLOBAL hMem)
    extrn GlobalUnlock:dword                ; DATA XREF: sub_441C30+38Br
                                            ; .text:0049F758r ...
    ; HGLOBAL __stdcall GlobalFree(HGLOBAL hMem)
    extrn GlobalFree:dword                  ; DATA XREF: sub_441C30+395r
                                            ; .text:0049F752r ...
    ; BOOL __stdcall SetCurrentDirectoryA(LPCSTR lpPathName)
    extrn SetCurrentDirectoryA:dword        ; DATA XREF: sub_49F540+27r
                                            ; .text:0049F7BEr ...
    ; DWORD __stdcall SetFilePointer(HANDLE hFile,LONG lDistanceToMove,PLONG lpDistanceToMoveHigh,DWORD dwMoveMethod)
    extrn SetFilePointer:dword              ; DATA XREF: sub_49E700+AFr
                                            ; .text:0049F7ACr ...
    ; DWORD __stdcall GetModuleFileNameA(HMODULE hModule,LPSTR lpFilename,DWORD nSize)
    extrn GetModuleFileNameA:dword          ; DATA XREF: sub_45B250+56r
                                            ; sub_45B490+42r ...
    ; HANDLE __stdcall OpenSemaphoreA(DWORD dwDesiredAccess,BOOL bInheritHandle,LPCSTR lpName)
    extrn OpenSemaphoreA:dword              ; DATA XREF: sub_49E830+55r
                                            ; .text:0049F7B8r
    ; HANDLE __stdcall CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,LONG lInitialCount,LONG lMaximumCount,LPCSTR lpName)
    extrn CreateSemaphoreA:dword            ; DATA XREF: sub_49E830+7Br
                                            ; .text:0049F7B2r
    ; void __stdcall GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer)
    extrn GlobalMemoryStatus:dword          ; DATA XREF: .text:00490AB0r
                                            ; sub_491200+5r ...
    ; BOOL __stdcall WriteFile(HANDLE hFile,LPCVOID lpBuffer,DWORD nNumberOfBytesToWrite,LPDWORD lpNumberOfBytesWritten,LPOVERLAPPED lpOverlapped)
    extrn WriteFile:dword                   ; DATA XREF: sub_49E700+D2r
                                            ; .text:0049F7A6r ...
    ; BOOL __stdcall QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
    extrn QueryPerformanceCounter:dword     ; DATA XREF: sub_497180+Cr
                                            ; .text:0049F7A0r ...
    ; BOOL __stdcall FreeLibrary(HMODULE hLibModule)
    extrn FreeLibrary:dword                 ; DATA XREF: sub_45B640+Ar
                                            ; LoadReporter+1E9r ...
    ; DWORD __stdcall GetPrivateProfileStringA(LPCSTR lpAppName,LPCSTR lpKeyName,LPCSTR lpDefault,LPSTR lpReturnedString,DWORD nSize,LPCSTR lpFileName)
    extrn GetPrivateProfileStringA:dword    ; DATA XREF: .text:00426938r
                                            ; .text:00426B28r ...
    ; DWORD __stdcall WaitForSingleObject(HANDLE hHandle,DWORD dwMilliseconds)
    extrn WaitForSingleObject:dword         ; DATA XREF: sub_451640+C7r
                                            ; .text:0049F770r ...
    ; HANDLE GetCurrentThread(void)
    extrn GetCurrentThread:dword            ; DATA XREF: sub_461020+12Fr
                                            ; .text:00461800r ...
    ; BOOL __stdcall SetThreadPriority(HANDLE hThread,int nPriority)
    extrn SetThreadPriority:dword           ; DATA XREF: sub_461020+136r
                                            ; .text:00461807r ...
    ; HMODULE __stdcall LoadLibraryA(LPCSTR lpLibFileName)
    extrn LoadLibraryA:dword                ; DATA XREF: sub_45B250+EFr
                                            ; sub_45B490+C7r ...
    ; UINT __stdcall GetPrivateProfileIntA(LPCSTR lpAppName,LPCSTR lpKeyName,INT nDefault,LPCSTR lpFileName)
    extrn GetPrivateProfileIntA:dword       ; DATA XREF: .text:00426962r
                                            ; .text:00426B52r ...
    ; DWORD _imp_GetTickCount(void)
    extrn __imp_GetTickCount:dword          ; DATA XREF: .text:0041D8C3r
                                            ; sub_41D920+4r ...
    ; void __stdcall Sleep(DWORD dwMilliseconds)
    extrn Sleep:dword                       ; DATA XREF: .text:00417B38r
                                            ; sub_451640+F7r ...
    ; void DebugBreak(void)
    extrn DebugBreak:dword                  ; DATA XREF: .text:00417B3Er
                                            ; .text:0049F734r
    ; HANDLE __stdcall CreateFileA(LPCSTR lpFileName,DWORD dwDesiredAccess,DWORD dwShareMode,LPSECURITY_ATTRIBUTES lpSecurityAttributes,DWORD dwCreationDisposition,DWORD dwFlagsAndAttributes,HANDLE hTemplateFile)
    extrn CreateFileA:dword                 ; DATA XREF: sub_416240+17r
                                            ; sub_49E700+9Cr ...
    ; BOOL __stdcall CloseHandle(HANDLE hObject)
    extrn CloseHandle:dword                 ; DATA XREF: sub_416240+22r
                                            ; sub_49E700+D9r ...
    ; LPSTR __stdcall lstrcpynA(LPSTR lpString1,LPCSTR lpString2,int iMaxLength)
    extrn lstrcpynA:dword                   ; DATA XREF: .text:00404F3Er
                                            ; sub_440D70+11Dr ...
    ; LPSTR __stdcall lstrcpyA(LPSTR lpString1,LPCSTR lpString2)
    extrn lstrcpyA:dword                    ; DATA XREF: sub_441C30+9Dr
                                            ; sub_441C30+A9r ...
    ; int __stdcall lstrlenA(LPCSTR lpString)
    extrn lstrlenA:dword                    ; DATA XREF: sub_441C30+BCr
                                            ; sub_441C30+DDr ...
    ; HGLOBAL __stdcall GlobalHandle(LPCVOID pMem)
    extrn GlobalHandle:dword                ; DATA XREF: sub_441C30+381r
                                            ; sub_441C30+388r ...
    ; void __stdcall ExitProcess(UINT uExitCode)
    extrn ExitProcess:dword                 ; DATA XREF: _doexit+A8r
                                            ; sub_4E7180+20r ...
    ; int __stdcall MultiByteToWideChar(UINT CodePage,DWORD dwFlags,LPCSTR lpMultiByteStr,int cchMultiByte,LPWSTR lpWideCharStr,int cchWideChar)
    extrn MultiByteToWideChar:dword         ; DATA XREF: .text:004EE491r
                                            ; .text:004EE4AEr ...
    ; LPVOID __stdcall TlsGetValue(DWORD dwTlsIndex)
    extrn TlsGetValue:dword                 ; DATA XREF: __getptd+10r
                                            ; sub_4EB170+18r ...
    ; DWORD __stdcall GetFileSize(HANDLE hFile,LPDWORD lpFileSizeHigh)
    extrn GetFileSize:dword                 ; DATA XREF: sub_4DED60+18Cr
                                            ; sub_4E1590+37r ...
    ; int __stdcall GetLocaleInfoW(LCID Locale,LCTYPE LCType,LPWSTR lpLCData,int cchData)
    extrn GetLocaleInfoW:dword              ; DATA XREF: ___crtGetLocaleInfoW+8r
                                            ; ___crtGetLocaleInfoW+1Br ...
    ; int __stdcall CompareStringW(LCID Locale,DWORD dwCmpFlags,LPCWSTR lpString1,int cchCount1,LPCWSTR lpString2,int cchCount2)
    extrn CompareStringW:dword              ; DATA XREF: .text:004F8229r
                                            ; .text:004F8245r ...
    ; int __stdcall CompareStringA(LCID Locale,DWORD dwCmpFlags,LPCSTR lpString1,int cchCount1,LPCSTR lpString2,int cchCount2)
    extrn CompareStringA:dword              ; DATA XREF: .text:004F8269r
                                            ; .text:004F83E1r ...
    ; LCID GetUserDefaultLCID(void)
    extrn GetUserDefaultLCID:dword          ; DATA XREF: sub_4F7830+Ar
                                            ; .text:004FB2A2r
    ; BOOL __stdcall EnumSystemLocalesA(LOCALE_ENUMPROCA lpLocaleEnumProc,DWORD dwFlags)
    extrn EnumSystemLocalesA:dword          ; DATA XREF: sub_4F72A0+68r
                                            ; sub_4F7610+43r ...
    ; int __stdcall GetLocaleInfoA(LCID Locale,LCTYPE LCType,LPSTR lpLCData,int cchData)
    extrn GetLocaleInfoA:dword              ; DATA XREF: sub_4F70A0+14r
                                            ; sub_4F7A40+4Ar ...
    ; BOOL __stdcall IsValidCodePage(UINT CodePage)
    extrn IsValidCodePage:dword             ; DATA XREF: sub_4F70A0+F4r
                                            ; .text:004FB290r
    ; BOOL __stdcall IsValidLocale(LCID Locale,DWORD dwFlags)
    extrn IsValidLocale:dword               ; DATA XREF: sub_4F70A0+10Br
                                            ; .text:004FB28Ar
    ; BOOL __stdcall IsBadCodePtr(FARPROC lpfn)
    extrn IsBadCodePtr:dword                ; DATA XREF: _ValidateExecute(int (*)(void))+Br
                                            ; .text:004FB284r
    ; BOOL __stdcall IsBadWritePtr(LPVOID lp,UINT ucb)
    extrn IsBadWritePtr:dword               ; DATA XREF: _ValidateWrite(void *,uint)+10r
                                            ; .text:004FB27Er
    ; BOOL __stdcall IsBadReadPtr(const void *lp,UINT ucb)
    extrn IsBadReadPtr:dword                ; DATA XREF: _ValidateRead(void const *,uint)+10r
                                            ; .text:004FB278r
    ; BOOL __stdcall FlushFileBuffers(HANDLE hFile)
    extrn FlushFileBuffers:dword            ; DATA XREF: __commit+4Er
                                            ; .text:004FB272r
    ; BOOL __stdcall GetStringTypeW(DWORD dwInfoType,LPCWSTR lpSrcStr,int cchSrc,LPWORD lpCharType)
    extrn GetStringTypeW:dword              ; DATA XREF: ___crtGetStringTypeW+Br
                                            ; ___crtGetStringTypeW+24r ...
    ; BOOL __stdcall GetStringTypeA(LCID Locale,DWORD dwInfoType,LPCSTR lpSrcStr,int cchSrc,LPWORD lpCharType)
    extrn GetStringTypeA:dword              ; DATA XREF: ___crtGetStringTypeW+40r
                                            ; ___crtGetStringTypeW+134r ...
    ; BOOL __stdcall SetStdHandle(DWORD nStdHandle,HANDLE hHandle)
    extrn SetStdHandle:dword                ; DATA XREF: __set_osfhnd+4Br
                                            ; __set_osfhnd+5Fr ...
    ; HANDLE __stdcall HeapCreate(DWORD flOptions,DWORD dwInitialSize,DWORD dwMaximumSize)
    extrn HeapCreate:dword                  ; DATA XREF: __heap_init+9r
                                            ; .text:004FB25Ar
    ; BOOL __stdcall HeapDestroy(HANDLE hHeap)
    extrn HeapDestroy:dword                 ; DATA XREF: __heap_init+28r
                                            ; .text:004F189Er ...
    ; DWORD __stdcall GetFileType(HANDLE hFile)
    extrn GetFileType:dword                 ; DATA XREF: __ioinit+140r
                                            ; __ioinit+1B9r ...
    ; HANDLE __stdcall GetStdHandle(DWORD nStdHandle)
    extrn GetStdHandle:dword                ; DATA XREF: __ioinit+178r
                                            ; __ioinit+1AFr ...
    ; UINT __stdcall SetHandleCount(UINT uNumber)
    extrn SetHandleCount:dword              ; DATA XREF: __ioinit+1FEr
                                            ; .text:004FB242r
    ; LPWSTR GetEnvironmentStringsW(void)
    extrn GetEnvironmentStringsW:dword      ; DATA XREF: .text:004F126Br
                                            ; .text:004F1286r ...
    ; LPVOID __stdcall GlobalLock(HGLOBAL hMem)
    extrn GlobalLock:dword                  ; DATA XREF: sub_4AB720+184r
                                            ; .text:004FB032r
    ; DWORD __stdcall GlobalSize(HGLOBAL hMem)
    extrn GlobalSize:dword                  ; DATA XREF: sub_4AB720+173r
                                            ; .text:004FB038r
    ; BOOL __stdcall GetVersionExA(LPOSVERSIONINFOA lpVersionInformation)
    extrn GetVersionExA:dword               ; DATA XREF: sub_4B5070+ACr
                                            ; sub_4E35B0+A6r ...
                                            ; Get extended information about the
                                            ; version of the operating system
    ; BOOL __stdcall SetEvent(HANDLE hEvent)
    extrn SetEvent:dword                    ; DATA XREF: sub_4B5510+29Br
                                            ; sub_4B5510+3E1r ...
    ; LONG __stdcall InterlockedExchange(LPLONG Target,LONG Value)
    extrn InterlockedExchange:dword         ; DATA XREF: sub_4B5510+1Dr
                                            ; sub_4B5510+28Er ...
    ; UINT __stdcall GetDriveTypeA(LPCSTR lpRootPathName)
    extrn GetDriveTypeA:dword               ; DATA XREF: sub_4BB190+27r
                                            ; sub_4BB190+48r ...
    ; BOOL __stdcall GetVolumeInformationA(LPCSTR lpRootPathName,LPSTR lpVolumeNameBuffer,DWORD nVolumeNameSize,LPDWORD lpVolumeSerialNumber,LPDWORD lpMaximumComponentLength,LPDWORD lpFileSystemFlags,LPSTR lpFileSystemNameBuffer,DWORD nFileSystemNameSize)
    extrn GetVolumeInformationA:dword       ; DATA XREF: .text:004BB248r
                                            ; sub_4BB260+4Br ...
    ; DWORD __stdcall GetFullPathNameA(LPCSTR lpFileName,DWORD nBufferLength,LPSTR lpBuffer,LPSTR *lpFilePart)
    extrn GetFullPathNameA:dword            ; DATA XREF: sub_4BDD70+68r
                                            ; sub_4BE0B0+27r ...
    ; HANDLE __stdcall CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes,BOOL bManualReset,BOOL bInitialState,LPCSTR lpName)
    extrn CreateEventA:dword                ; DATA XREF: .text:004C22C3r
                                            ; .text:004D0A03r ...
    ; BOOL __stdcall ResetEvent(HANDLE hEvent)
    extrn ResetEvent:dword                  ; DATA XREF: .text:004C22B4r
                                            ; .text:004D09F4r ...
    ; void __stdcall OutputDebugStringA(LPCSTR lpOutputString)
    extrn OutputDebugStringA:dword          ; DATA XREF: .text:004CBBB1r
                                            ; .text:004CBBCBr ...
    ; DWORD GetCurrentThreadId(void)
    extrn GetCurrentThreadId:dword          ; DATA XREF: DoNetworkCompression+Ar
                                            ; sub_4D1480+7r ...
    ; void __stdcall LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
    extrn LeaveCriticalSection:dword        ; DATA XREF: sub_4D83C0+7Fr
                                            ; Network_ReAllocPacketBuffer_Internal+A8r ...
    ; void __stdcall EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
    extrn EnterCriticalSection:dword        ; DATA XREF: sub_4D83C0+Br
                                            ; Network_ReAllocPacketBuffer_Internal+Fr ...
    ; BOOL __stdcall VirtualProtect(LPVOID lpAddress,DWORD dwSize,DWORD flNewProtect,PDWORD lpflOldProtect)
    extrn VirtualProtect:dword              ; DATA XREF: sub_4D86B0+37r
                                            ; .text:004FB086r
    ; DWORD __stdcall VirtualQuery(LPCVOID lpAddress,PMEMORY_BASIC_INFORMATION lpBuffer,DWORD dwLength)
    extrn VirtualQuery:dword                ; DATA XREF: sub_4D8D70+3Ar
                                            ; .text:004FB08Cr
    ; LPSTR GetCommandLineA(void)
    extrn GetCommandLineA:dword             ; DATA XREF: sub_4D9F60+Cr start+8Er ...
    ; HANDLE __stdcall CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes,DWORD dwStackSize,LPTHREAD_START_ROUTINE lpStartAddress,LPVOID lpParameter,DWORD dwCreationFlags,LPDWORD lpThreadId)
    extrn CreateThread:dword                ; DATA XREF: sub_4DA1D0+AAr
                                            ; __beginthreadex+4Er ...
    ; LPTOP_LEVEL_EXCEPTION_FILTER __stdcall SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
    extrn SetUnhandledExceptionFilter:dword ; DATA XREF: sub_4DA1D0+77r
                                            ; __CxxSetUnhandledExceptionFilter(void)+5r ...
    ; int __stdcall GetThreadPriority(HANDLE hThread)
    extrn GetThreadPriority:dword           ; DATA XREF: sub_4DA2E0+13r
                                            ; sub_4E1D60+3Cr ...
    ; HGLOBAL __stdcall GlobalAlloc(UINT uFlags,DWORD dwBytes)
    extrn GlobalAlloc:dword                 ; DATA XREF: sub_4DA480+44r
                                            ; sub_4DA8D0+16r ...
    ; void __stdcall InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
    extrn InitializeCriticalSection:dword   ; DATA XREF: sub_4DA780+19r
                                            ; sub_4E06F0+19r ...
    ; LPVOID __stdcall VirtualAlloc(LPVOID lpAddress,DWORD dwSize,DWORD flAllocationType,DWORD flProtect)
    extrn VirtualAlloc:dword                ; DATA XREF: sub_4DACF0+219r
                                            ; sub_4DB1C0+1D0r ...
    ; BOOL __stdcall VirtualFree(LPVOID lpAddress,DWORD dwSize,DWORD dwFreeType)
    extrn VirtualFree:dword                 ; DATA XREF: sub_4DB1C0+1E8r
                                            ; sub_4DB1C0+208r ...
    ; HMODULE __stdcall GetModuleHandleA(LPCSTR lpModuleName)
    extrn GetModuleHandleA:dword            ; DATA XREF: .text:004DE0B6r
                                            ; sub_4DED60+24Er ...
    ; HANDLE GetCurrentProcess(void)
    extrn GetCurrentProcess:dword           ; DATA XREF: sub_4DE110+12r
                                            ; sub_4DE180+2C3r ...
    ; DWORD GetLastError(void)
    extrn GetLastError:dword                ; DATA XREF: sub_4DE180+306r
                                            ; sub_4DE550+89r ...
    ; void __stdcall GetSystemInfo(LPSYSTEM_INFO lpSystemInfo)
    extrn GetSystemInfo:dword               ; DATA XREF: sub_4DED60+2EFr
                                            ; sub_4E1700+8r ...
    ; BOOL __stdcall FileTimeToDosDateTime(const FILETIME *lpFileTime,LPWORD lpFatDate,LPWORD lpFatTime)
    extrn FileTimeToDosDateTime:dword       ; DATA XREF: sub_4DED60+1D3r
                                            ; .text:004FB0DAr
    ; BOOL __stdcall FileTimeToLocalFileTime(const FILETIME *lpFileTime,LPFILETIME lpLocalFileTime)
    extrn FileTimeToLocalFileTime:dword     ; DATA XREF: sub_4DED60+1B6r
                                            ; ___timet_from_ft+19r ...
    ; BOOL __stdcall GetFileTime(HANDLE hFile,LPFILETIME lpCreationTime,LPFILETIME lpLastAccessTime,LPFILETIME lpLastWriteTime)
    extrn GetFileTime:dword                 ; DATA XREF: sub_4DED60+19Er
                                            ; .text:004FB0E6r
    ; BOOL __stdcall FreeEnvironmentStringsA(LPSTR)
    extrn FreeEnvironmentStringsA:dword     ; DATA XREF: .text:004F13C3r
                                            ; .text:004F142Er ...
    ; void __stdcall DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
    extrn DeleteCriticalSection:dword       ; DATA XREF: std::_CleanUp(void)+20r
                                            ; sub_4E3A40+20r ...
    ; LPVOID __stdcall MapViewOfFile(HANDLE hFileMappingObject,DWORD dwDesiredAccess,DWORD dwFileOffsetHigh,DWORD dwFileOffsetLow,DWORD dwNumberOfBytesToMap)
    extrn MapViewOfFile:dword               ; DATA XREF: sub_4E1590+7Er
                                            ; .text:004FB0F8r
    ; HANDLE __stdcall CreateFileMappingA(HANDLE hFile,LPSECURITY_ATTRIBUTES lpFileMappingAttributes,DWORD flProtect,DWORD dwMaximumSizeHigh,DWORD dwMaximumSizeLow,LPCSTR lpName)
    extrn CreateFileMappingA:dword          ; DATA XREF: sub_4E1590+4Dr
                                            ; .text:004FB0FEr
    ; BOOL __stdcall UnmapViewOfFile(LPCVOID lpBaseAddress)
    extrn UnmapViewOfFile:dword             ; DATA XREF: .text:004E165Cr
                                            ; .text:004FB104r
    ; BOOL __stdcall SystemTimeToFileTime(const SYSTEMTIME *lpSystemTime,LPFILETIME lpFileTime)
    extrn SystemTimeToFileTime:dword        ; DATA XREF: sub_4E1730+49r
                                            ; .text:004FB10Ar
    ; void __stdcall GetSystemTime(LPSYSTEMTIME lpSystemTime)
    extrn GetSystemTime:dword               ; DATA XREF: sub_4E1730+39r _time+16r ...
    ; BOOL __stdcall QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency)
    extrn QueryPerformanceFrequency:dword   ; DATA XREF: sub_4E1730+9r
                                            ; .text:004FB116r
    ; BOOL __stdcall SetPriorityClass(HANDLE hProcess,DWORD dwPriorityClass)
    extrn SetPriorityClass:dword            ; DATA XREF: sub_4E1D60+66r
                                            ; .text:004E1E15r ...
    ; DWORD __stdcall GetPriorityClass(HANDLE hProcess)
    extrn GetPriorityClass:dword            ; DATA XREF: sub_4E1D60+57r
                                            ; .text:004FB122r
    ; BOOL __stdcall DeviceIoControl(HANDLE hDevice,DWORD dwIoControlCode,LPVOID lpInBuffer,DWORD nInBufferSize,LPVOID lpOutBuffer,DWORD nOutBufferSize,LPDWORD lpBytesReturned,LPOVERLAPPED lpOverlapped)
    extrn DeviceIoControl:dword             ; DATA XREF: sub_4E38E0+35r
                                            ; sub_4E3930+48r ...
    ; LPSTR GetEnvironmentStrings(void)
    extrn GetEnvironmentStrings:dword       ; DATA XREF: .text:004F1274r
                                            ; .text:004F1297r ...
    ; BOOL __stdcall TerminateProcess(HANDLE hProcess,UINT uExitCode)
    extrn TerminateProcess:dword            ; DATA XREF: _doexit+1Er
                                            ; .text:004FB134r
    extrn __imp_RtlUnwind:dword             ; DATA XREF: RtlUnwindr
    ; LONG __stdcall InterlockedDecrement(LPLONG lpAddend)
    extrn InterlockedDecrement:dword        ; DATA XREF: _tolower+2Er _tolower+3Dr ...
    ; LONG __stdcall InterlockedIncrement(LPLONG lpAddend)
    extrn InterlockedIncrement:dword        ; DATA XREF: _tolower+23r _toupper+23r ...
    ; BOOL __stdcall TlsSetValue(DWORD dwTlsIndex,LPVOID lpTlsValue)
    extrn TlsSetValue:dword                 ; DATA XREF: _threadstartex(x)+30r
                                            ; _threadstart(x)+30r ...
    ; void __stdcall ExitThread(DWORD dwExitCode)
    extrn ExitThread:dword                  ; DATA XREF: __endthreadex+2Fr
                                            ; __endthread+3Br ...
    ; DWORD __stdcall GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
    extrn GetTimeZoneInformation:dword      ; DATA XREF: _time+6Er __tzset_lk+54r ...
    ; void __stdcall GetLocalTime(LPSYSTEMTIME lpSystemTime)
    extrn GetLocalTime:dword                ; DATA XREF: _time+Br .text:004FB15Er
    ; BOOL __stdcall SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine,BOOL Add)
    extrn SetConsoleCtrlHandler:dword       ; DATA XREF: .text:004E69CDr
                                            ; .text:004FB164r
    ; void __stdcall GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
    extrn GetStartupInfoA:dword             ; DATA XREF: start+125r __ioinit+6Ar ...
    ; DWORD GetVersion(void)
    extrn GetVersion:dword                  ; DATA XREF: start+26r .text:004FB170r
                                            ; Get current version number of Windows
                                            ; and information about the operating system platform
    ; BOOL __stdcall SetEndOfFile(HANDLE hFile)
    extrn SetEndOfFile:dword                ; DATA XREF: __chsize_lk+F9r
                                            ; .text:004FB176r
    ; DWORD __stdcall ResumeThread(HANDLE hThread)
    extrn ResumeThread:dword                ; DATA XREF: __beginthread+4Cr
                                            ; .text:004FB17Cr
    ; BOOL __stdcall MoveFileA(LPCSTR lpExistingFileName,LPCSTR lpNewFileName)
    extrn MoveFileA:dword                   ; DATA XREF: sub_4E7950+Ar
                                            ; .text:004FB182r
    ; BOOL __stdcall DeleteFileA(LPCSTR lpFileName)
    extrn DeleteFileA:dword                 ; DATA XREF: _remove+5r
                                            ; .text:004FB188r
    ; DWORD __stdcall GetCurrentDirectoryA(DWORD nBufferLength,LPSTR lpBuffer)
    extrn GetCurrentDirectoryA:dword        ; DATA XREF: __getdrive+13r
                                            ; __getdcwd_lk+7Fr ...
    ; BOOL __stdcall SetEnvironmentVariableA(LPCSTR lpName,LPCSTR lpValue)
    extrn SetEnvironmentVariableA:dword     ; DATA XREF: __chdir+6Dr
                                            ; ___crtsetenv+19Fr ...
    ; HANDLE __stdcall FindFirstFileA(LPCSTR lpFileName,LPWIN32_FIND_DATAA lpFindFileData)
    extrn FindFirstFileA:dword              ; DATA XREF: __findfirst+11r
                                            ; __stat+60r ...
    ; BOOL __stdcall FindNextFileA(HANDLE hFindFile,LPWIN32_FIND_DATAA lpFindFileData)
    extrn FindNextFileA:dword               ; DATA XREF: __findnext+10r
                                            ; .text:004FB1A0r
    ; BOOL __stdcall FindClose(HANDLE hFindFile)
    extrn FindClose:dword                   ; DATA XREF: __findclose+5r
                                            ; __stat+2D3r ...
    ; BOOL __stdcall FileTimeToSystemTime(const FILETIME *lpFileTime,LPSYSTEMTIME lpSystemTime)
    extrn FileTimeToSystemTime:dword        ; DATA XREF: ___timet_from_ft+2Dr
                                            ; __stat+152r ...
    ; BOOL __stdcall CreateDirectoryA(LPCSTR lpPathName,LPSECURITY_ATTRIBUTES lpSecurityAttributes)
    extrn CreateDirectoryA:dword            ; DATA XREF: __mkdir+7r
                                            ; .text:004FB1B2r
    ; void __stdcall RaiseException(DWORD dwExceptionCode,DWORD dwExceptionFlags,DWORD nNumberOfArguments,const DWORD *lpArguments)
    extrn RaiseException:dword              ; DATA XREF: _CxxThrowException(x,x)+39r
                                            ; __raise_exc+25Br ...
    ; BOOL __stdcall HeapFree(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem)
    extrn HeapFree:dword                    ; DATA XREF: _free+5Fr
                                            ; ___sbh_new_region+156r ...
    ; LPVOID __stdcall HeapAlloc(HANDLE hHeap,DWORD dwFlags,DWORD dwBytes)
    extrn HeapAlloc:dword                   ; DATA XREF: __heap_alloc+4Cr
                                            ; _calloc+23r ...
    ; DWORD __stdcall HeapSize(HANDLE hHeap,DWORD dwFlags,LPCVOID lpMem)
    extrn HeapSize:dword                    ; DATA XREF: __msize+56r
                                            ; .text:004FB1CAr
    ; LPVOID __stdcall HeapReAlloc(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes)
    extrn HeapReAlloc:dword                 ; DATA XREF: _realloc+178r
                                            ; .text:004FB1D0r
    ; void __stdcall FatalAppExitA(UINT uAction,LPCSTR lpMessageText)
    extrn FatalAppExitA:dword               ; DATA XREF: .text:004EADE7r
                                            ; .text:004FB1D6r
    ; DWORD TlsAlloc(void)
    extrn TlsAlloc:dword                    ; DATA XREF: __mtinit+6r
                                            ; .text:004FB1DCr
                                            ; Allocate a thread local storage (TLS) index
    ; BOOL __stdcall TlsFree(DWORD dwTlsIndex)
    extrn TlsFree:dword                     ; DATA XREF: .text:004EB0B0r
                                            ; .text:004FB1E2r
                                            ; Release a thread local storage (TLS) index
    ; void __stdcall SetLastError(DWORD dwErrCode)
    extrn SetLastError:dword                ; DATA XREF: __getptd+59r __getptd+6Fr ...
    ; BOOL __stdcall ReadFile(HANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped)
    extrn ReadFile:dword                    ; DATA XREF: __read_lk+86r
                                            ; __read_lk+167r ...
    ; BOOL __stdcall FreeEnvironmentStringsW(LPWSTR)
    extrn FreeEnvironmentStringsW:dword     ; DATA XREF: .text:004F1307r
                                            ; .text:004F132Cr ...
    ; int __stdcall WideCharToMultiByte(UINT CodePage,DWORD dwFlags,LPCWSTR lpWideCharStr,int cchWideChar,LPSTR lpMultiByteStr,int cchMultiByte,LPCSTR lpDefaultChar,LPBOOL lpUsedDefaultChar)
    extrn WideCharToMultiByte:dword         ; DATA XREF: .text:004EE3A0r
                                            ; .text:004EE3D7r ...
    ; int __stdcall LCMapStringA(LCID Locale,DWORD dwMapFlags,LPCSTR lpSrcStr,int cchSrc,LPSTR lpDestStr,int cchDest)
    extrn LCMapStringA:dword                ; DATA XREF: .text:004EE314r
                                            ; .text:004EE3F5r ...
    ; int __stdcall LCMapStringW(LCID Locale,DWORD dwMapFlags,LPCWSTR lpSrcStr,int cchSrc,LPWSTR lpDestStr,int cchDest)
    extrn LCMapStringW:dword                ; DATA XREF: .text:004EE2D6r
                                            ; .text:004EE2F5r ...
    ; LONG __stdcall UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
    extrn UnhandledExceptionFilter:dword    ; DATA XREF: __XcptFilter+201r
                                            ; .text:004FB212r
    ; BOOL __stdcall GetCPInfo(UINT CodePage,LPCPINFO lpCPInfo)
    extrn GetCPInfo:dword                   ; DATA XREF: sub_4F0730+83r
                                            ; sub_4F0A50+13r ...
    ; UINT GetACP(void)
    extrn GetACP:dword                      ; DATA XREF: _getSystemCP+32r
                                            ; .text:004FB21Er
    ; UINT GetOEMCP(void)
    extrn GetOEMCP:dword                    ; DATA XREF: _getSystemCP+1Dr
                                            ; .text:004FB224r

    ;
    ; Imports from SHELL32
    ;
    ; HINSTANCE __stdcall ShellExecuteA(HWND hwnd,LPCSTR lpOperation,LPCSTR lpFile,LPCSTR lpParameters,LPCSTR lpDirectory,INT nShowCmd)
    extrn ShellExecuteA:dword               ; DATA XREF: sub_4DA5B0+2Dr
                                            ; sub_4DA5B0+180r ...
                                            ; Opens or prints a specified file

    ;
    ; Imports from USER32
    ;
    ; int __stdcall GetClassNameA(HWND hWnd,LPSTR lpClassName,int nMaxCount)
    extrn GetClassNameA:dword               ; DATA XREF: EnumFunc+1Br
                                            ; .text:004FB332r
    ; BOOL __stdcall MessageBeep(UINT uType)
    extrn MessageBeep:dword                 ; DATA XREF: sub_49EE30+5AFr
                                            ; .text:0049F824r
    ; BOOL __stdcall EnumWindows(WNDENUMPROC lpEnumFunc,LPARAM lParam)
    extrn EnumWindows:dword                 ; DATA XREF: sub_4CE260+98r
                                            ; .text:004FB338r
    ; BOOL __stdcall IsDialogMessageA(HWND hDlg,LPMSG lpMsg)
    extrn IsDialogMessageA:dword            ; DATA XREF: sub_4DA380+3Dr
                                            ; .text:004FB33Er
    ; LRESULT __stdcall DefWindowProcA(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
    extrn DefWindowProcA:dword              ; DATA XREF: sub_4B5CC0+118r
                                            ; sub_4B5CC0+15Cr ...
    ; BOOL __stdcall PostMessageA(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
    extrn PostMessageA:dword                ; DATA XREF: sub_4B6230+52r
                                            ; .text:004FB30Er
    ; BOOL __stdcall PeekMessageA(LPMSG lpMsg,HWND hWnd,UINT wMsgFilterMin,UINT wMsgFilterMax,UINT wRemoveMsg)
    extrn PeekMessageA:dword                ; DATA XREF: sub_47C6C0+14r
                                            ; sub_47C6C0+28r ...
    ; BOOL __stdcall GetMessageA(LPMSG lpMsg,HWND hWnd,UINT wMsgFilterMin,UINT wMsgFilterMax)
    extrn GetMessageA:dword                 ; DATA XREF: sub_49E830+470r
                                            ; .text:0049F81Er ...
    ; BOOL __stdcall IsIconic(HWND hWnd)
    extrn IsIconic:dword                    ; DATA XREF: sub_4E3400+Fr
                                            ; sub_4E3400+16r ...
    ; HWND GetFocus(void)
    extrn GetFocus:dword                    ; DATA XREF: sub_41CE90+8Cr
                                            ; sub_47C3A0+4r ...
    ; BOOL __stdcall GetCursorPos(LPPOINT lpPoint)
    extrn GetCursorPos:dword                ; DATA XREF: sub_41CE90+57r
                                            ; .text:0049F7CAr ...
    ; int wsprintfA(LPSTR,LPCSTR,...)
    extrn wsprintfA:dword                   ; DATA XREF: sub_41E420+EAr
                                            ; sub_41E420+2B2r ...
    ; SHORT __stdcall GetKeyState(int nVirtKey)
    extrn GetKeyState:dword                 ; DATA XREF: sub_425D80+1EEr
                                            ; .text:0049F7D6r
    ; BOOL __stdcall SetWindowPos(HWND hWnd,HWND hWndInsertAfter,int X,int Y,int cx,int cy,UINT uFlags)
    extrn SetWindowPos:dword                ; DATA XREF: sub_47BF70+174r
                                            ; sub_491A70+8Br ...
    ; int __stdcall ReleaseDC(HWND hWnd,HDC hDC)
    extrn ReleaseDC:dword                   ; DATA XREF: sub_47BF70+12Ar
                                            ; .text:0047C28Dr ...
    ; HDC __stdcall GetDC(HWND hWnd)
    extrn GetDC:dword                       ; DATA XREF: sub_47BF70+D5r
                                            ; .text:0047C238r ...
    ; BOOL __stdcall ClientToScreen(HWND hWnd,LPPOINT lpPoint)
    extrn ClientToScreen:dword              ; DATA XREF: sub_47BF70+21r
                                            ; .text:0049F7EEr ...
                                            ; Convert the client coordinates of a
                                            ; specified point to screen coordinates.
    ; int __stdcall MessageBoxA(HWND hWnd,LPCSTR lpText,LPCSTR lpCaption,UINT uType)
    extrn MessageBoxA:dword                 ; DATA XREF: sub_47C150+C8r
                                            ; .text:0047C520r ...
    ; BOOL __stdcall EndPaint(HWND hWnd,const PAINTSTRUCT *lpPaint)
    extrn EndPaint:dword                    ; DATA XREF: .text:0047C364r
                                            ; .text:0049F7FAr
    ; HDC __stdcall BeginPaint(HWND hWnd,LPPAINTSTRUCT lpPaint)
    extrn BeginPaint:dword                  ; DATA XREF: .text:0047C341r
                                            ; .text:0049F800r
    ; void __stdcall PostQuitMessage(int nExitCode)
    extrn PostQuitMessage:dword             ; DATA XREF: sub_47C6C0+A2r
                                            ; .text:0049F806r ...
    ; LONG __stdcall DispatchMessageA(const MSG *lpMsg)
    extrn DispatchMessageA:dword            ; DATA XREF: sub_47C6C0+66r
                                            ; sub_49E830+48Ar ...
    ; BOOL CloseClipboard(void)
    extrn CloseClipboard:dword              ; DATA XREF: sub_4AB720+204r
                                            ; .text:004FB2BAr
    ; HANDLE __stdcall GetClipboardData(UINT uFormat)
    extrn GetClipboardData:dword            ; DATA XREF: sub_4AB720+15Er
                                            ; .text:004FB2C0r
    ; BOOL __stdcall OpenClipboard(HWND hWndNewOwner)
    extrn OpenClipboard:dword               ; DATA XREF: sub_4AB720+14Er
                                            ; .text:004FB2C6r
    ; BOOL __stdcall IsCharAlphaA(CHAR ch)
    extrn IsCharAlphaA:dword                ; DATA XREF: sub_4ADC70+81r
                                            ; .text:004FB2CCr
    ; int __stdcall GetSystemMetrics(int nIndex)
    extrn GetSystemMetrics:dword            ; DATA XREF: sub_4B5370+1Ar
                                            ; sub_4B5370+ACr ...
    ; BOOL __stdcall DestroyWindow(HWND hWnd)
    extrn DestroyWindow:dword               ; DATA XREF: sub_4B5980+313r
                                            ; sub_4B5CC0+B8r ...
    ; BOOL __stdcall UpdateWindow(HWND hWnd)
    extrn UpdateWindow:dword                ; DATA XREF: sub_4B5980+2ABr
                                            ; sub_4E0B90+702r ...
    ; BOOL __stdcall ShowWindow(HWND hWnd,int nCmdShow)
    extrn ShowWindow:dword                  ; DATA XREF: sub_4B5980+2A1r
                                            ; sub_4DF280+99r ...
    ; HWND __stdcall CreateWindowExA(DWORD dwExStyle,LPCSTR lpClassName,LPCSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam)
    extrn CreateWindowExA:dword             ; DATA XREF: sub_4B5980+28Fr
                                            ; .text:004FB2EAr
    ; ATOM __stdcall RegisterClassA(const WNDCLASSA *lpWndClass)
    extrn RegisterClassA:dword              ; DATA XREF: sub_4B5980+25Ar
                                            ; .text:004FB2F0r
    ; HCURSOR __stdcall LoadCursorA(HINSTANCE hInstance,LPCSTR lpCursorName)
    extrn LoadCursorA:dword                 ; DATA XREF: sub_4B5980+233r
                                            ; .text:004FB2F6r
    ; HICON __stdcall LoadIconA(HINSTANCE hInstance,LPCSTR lpIconName)
    extrn LoadIconA:dword                   ; DATA XREF: sub_4B5980+225r
                                            ; .text:004FB2FCr
    ; BOOL __stdcall SystemParametersInfoA(UINT uiAction,UINT uiParam,PVOID pvParam,UINT fWinIni)
    extrn SystemParametersInfoA:dword       ; DATA XREF: sub_4B5980+24r
                                            ; sub_4B5980+48r ...
    ; BOOL __stdcall GetWindowPlacement(HWND hWnd,WINDOWPLACEMENT *lpwndpl)
    extrn GetWindowPlacement:dword          ; DATA XREF: sub_4E3080+4Dr
                                            ; sub_4E3400+94r ...
    ; BOOL __stdcall IsZoomed(HWND hWnd)
    extrn IsZoomed:dword                    ; DATA XREF: sub_4E3400+AEr
                                            ; sub_4E3400+C9r ...
    ; SHORT __stdcall GetAsyncKeyState(int vKey)
    extrn GetAsyncKeyState:dword            ; DATA XREF: sub_4C1B80+23r
                                            ; sub_4C1B80+37r ...
                                            ; Determine whether a key is up or down
    ; BOOL __stdcall SetCursorPos(int X,int Y)
    extrn SetCursorPos:dword                ; DATA XREF: sub_4C22F0+Ar
                                            ; .text:004FB31Ar
    ; BOOL __stdcall OffsetRect(LPRECT lprc,int dx,int dy)
    extrn OffsetRect:dword                  ; DATA XREF: sub_4C63A0+345r
                                            ; .text:004FB320r
                                            ; Move the specified rectangle by
                                            ; the specified offsets
    ; BOOL __stdcall GetClientRect(HWND hWnd,LPRECT lpRect)
    extrn GetClientRect:dword               ; DATA XREF: sub_4C63A0+2F9r
                                            ; .text:004FB326r
                                            ; Get the coordinates of a window's client area
    ; LRESULT __stdcall SendMessageA(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
    extrn SendMessageA:dword                ; DATA XREF: sub_4CE190+Ar
                                            ; sub_4CE190+17r ...
    ; BOOL __stdcall TranslateMessage(const MSG *lpMsg)
    extrn TranslateMessage:dword            ; DATA XREF: sub_47C6C0+5Br
                                            ; sub_49E830+47Fr ...
    ; HWND __stdcall SetFocus(HWND hWnd)
    extrn SetFocus:dword                    ; DATA XREF: sub_4DF280+1Dr
                                            ; sub_4E05F0+1Dr ...
    ; BOOL __stdcall EnableWindow(HWND hWnd,BOOL bEnable)
    extrn EnableWindow:dword                ; DATA XREF: sub_4DF280+14r
                                            ; sub_4DF4E0+3Er ...
                                            ; Enable/disable mouse and keyboard input
    ; HWND __stdcall GetParent(HWND hWnd)
    extrn GetParent:dword                   ; DATA XREF: sub_4DA380+24r
                                            ; .text:004FB344r
    ; int __stdcall DialogBoxIndirectParamA(HINSTANCE hInstance,LPCDLGTEMPLATEA hDialogTemplate,HWND hWndParent,DLGPROC lpDialogFunc,LPARAM dwInitParam)
    extrn DialogBoxIndirectParamA:dword     ; DATA XREF: .text:004DA51Dr
                                            ; .text:004FB34Ar
                                            ; Create a modal dialog box from a
                                            ; dialog box template in memory
    ; HWND __stdcall CreateDialogIndirectParamA(HINSTANCE hInstance,LPCDLGTEMPLATEA lpTemplate,HWND hWndParent,DLGPROC lpDialogFunc,LPARAM dwInitParam)
    extrn CreateDialogIndirectParamA:dword  ; DATA XREF: sub_4DA540+2Dr
                                            ; .text:004FB350r
                                            ; Create a modeless dialog box from
                                            ; a dialog box template in memory
    ; HWND GetDesktopWindow(void)
    extrn GetDesktopWindow:dword            ; DATA XREF: sub_4DF250+6r
                                            ; sub_4E05C0+6r ...
    ; BOOL __stdcall KillTimer(HWND hWnd,UINT uIDEvent)
    extrn KillTimer:dword                   ; DATA XREF: sub_4DF280+7Cr
                                            ; sub_4E05F0+7Cr ...
    ; BOOL __stdcall IsWindowVisible(HWND hWnd)
    extrn IsWindowVisible:dword             ; DATA XREF: sub_4DF280+6Dr
                                            ; sub_4DF590+3Cr ...
    ; UINT __stdcall SetTimer(HWND hWnd,UINT nIDEvent,UINT uElapse,TIMERPROC lpTimerFunc)
    extrn SetTimer:dword                    ; DATA XREF: sub_4DF280+58r
                                            ; sub_4E05F0+58r ...
    ; BOOL __stdcall SetForegroundWindow(HWND hWnd)
    extrn SetForegroundWindow:dword         ; DATA XREF: sub_4DF280+26r
                                            ; sub_4E05F0+26r ...
    ; UINT __stdcall GetDlgItemTextA(HWND hDlg,int nIDDlgItem,LPSTR lpString,int nMaxCount)
    extrn GetDlgItemTextA:dword             ; DATA XREF: sub_4DF380+EEr
                                            ; .text:004FB392r
    ; HWND __stdcall GetDlgItem(HWND hDlg,int nIDDlgItem)
    extrn GetDlgItem:dword                  ; DATA XREF: sub_4DF4E0+29r
                                            ; sub_4DF4E0+3Cr ...
    ; LONG __stdcall GetWindowLongA(HWND hWnd,int nIndex)
    extrn GetWindowLongA:dword              ; DATA XREF: sub_4DF330+26r
                                            ; sub_4E06A0+26r ...
    ; LONG __stdcall SetWindowLongA(HWND hWnd,int nIndex,LONG dwNewLong)
    extrn SetWindowLongA:dword              ; DATA XREF: sub_4DF330+1Br
                                            ; sub_4E06A0+1Br ...
    ; BOOL __stdcall SetDlgItemTextA(HWND hDlg,int nIDDlgItem,LPCSTR lpString)
    extrn SetDlgItemTextA:dword             ; DATA XREF: sub_4DF380+138r
                                            ; sub_4E0B90+6F8r ...
    ; LONG __stdcall SendDlgItemMessageA(HWND hDlg,int nIDDlgItem,UINT Msg,WPARAM wParam,LPARAM lParam)
    extrn SendDlgItemMessageA:dword         ; DATA XREF: sub_4DF590+D4r
                                            ; sub_4DF590+124r ...
    ; BOOL __stdcall CheckDlgButton(HWND hDlg,int nIDButton,UINT uCheck)
    extrn CheckDlgButton:dword              ; DATA XREF: sub_4DF590+68Fr
                                            ; sub_4DF590+6A4r ...
                                            ; Change the check state of a button control
    ; BOOL __stdcall RegisterHotKey(HWND hWnd,int id,UINT fsModifiers,UINT vk)
    extrn RegisterHotKey:dword              ; DATA XREF: sub_4DF590+687r
                                            ; sub_4E0B90+7FBr ...
    ; BOOL __stdcall GetWindowRect(HWND hWnd,LPRECT lpRect)
    extrn GetWindowRect:dword               ; DATA XREF: sub_4DF590+52r
                                            ; sub_4DF590+5C3r ...

    ;
    ; Imports from WINMM
    ;
    ; UINT waveOutGetNumDevs(void)
    extrn waveOutGetNumDevs:dword           ; DATA XREF: sub_4CFF30+9r
                                            ; .text:004FB020r
    ; MMRESULT __stdcall auxSetVolume(UINT uDeviceID,DWORD dwVolume)
    extrn auxSetVolume:dword                ; DATA XREF: sub_4D00D0+43r
                                            ; sub_4D0130+71r ...
    ; MMRESULT __stdcall auxGetVolume(UINT uDeviceID,LPDWORD pdwVolume)
    extrn auxGetVolume:dword                ; DATA XREF: sub_4CFF30+83r
                                            ; sub_4D0040+Er ...
                                            ; Get the current volume setting of
                                            ; the specified auxiliary output device
    ; MMRESULT __stdcall waveOutGetVolume(HWAVEOUT hwo,LPDWORD pdwVolume)
    extrn waveOutGetVolume:dword            ; DATA XREF: sub_4CFF30+56r
                                            ; sub_4CFF30+62r ...
    ; MMRESULT __stdcall auxGetDevCapsA(UINT uDeviceID,LPAUXCAPSA pac,UINT cbac)
    extrn auxGetDevCapsA:dword              ; DATA XREF: sub_4CFF30+27r
                                            ; sub_4CFF30+35r ...
                                            ; Get the capabilities of a given
                                            ; auxiliary output device
    ; UINT auxGetNumDevs(void)
    extrn auxGetNumDevs:dword               ; DATA XREF: sub_4CFF30+19r
                                            ; .text:004FB01Ar
                                            ; Get number of auxiliary output
                                            ; devices present in the system
    ; MMRESULT __stdcall waveOutSetVolume(HWAVEOUT hwo,DWORD dwVolume)
    extrn waveOutSetVolume:dword            ; DATA XREF: sub_4D0070+2Ar
                                            ; sub_4D0070+39r ...
    ; BOOL __stdcall PlaySoundA(LPCSTR pszSound,HMODULE hmod,DWORD fdwSound)
    extrn PlaySoundA:dword                  ; DATA XREF: sub_49F620+Er
                                            ; .text:0049F649r ...
                                            ; Play a sound specified by the given
                                            ; filename, resource, or system event
    ; MCIERROR __stdcall mciSendStringA(LPCSTR lpstrCommand,LPSTR lpstrReturnString,UINT uReturnLength,HWND hwndCallback)
    extrn mciSendStringA:dword              ; DATA XREF: sub_490FE0+65r
                                            ; sub_490FE0+78r ...

    ;
    ; Imports from smackw32
    ;
    ; __stdcall SmackNextFrame(x)
    extrn _SmackNextFrame@4:dword           ; DATA XREF: sub_47C3A0+11Br
                                            ; .text:0049F890r
    ; __stdcall SmackDoFrame(x)
    extrn _SmackDoFrame@4:dword             ; DATA XREF: sub_47C3A0+AAr
                                            ; .text:0049F89Cr
    ; __stdcall SmackToBuffer(x,x,x,x,x,x,x)
    extrn _SmackToBuffer@28:dword           ; DATA XREF: sub_47C3A0+A1r
                                            ; .text:0049F8A2r
    ; __stdcall SmackSummary(x,x)
    extrn _SmackSummary@8:dword             ; DATA XREF: .text:0047C53Cr
                                            ; .text:0049F8A8r
    ; __stdcall SmackGoto(x,x)
    extrn _SmackGoto@8:dword                ; DATA XREF: .text:0047C385r
                                            ; .text:0049F88Ar
    ; __stdcall SmackToBufferRect(x,x)
    extrn _SmackToBufferRect@8:dword        ; DATA XREF: sub_47C3A0+BAr
                                            ; .text:0049F896r
    ; __stdcall SmackClose(x)
    extrn _SmackClose@4:dword               ; DATA XREF: sub_47BF20+6r
                                            ; .text:0049F872r
    ; __stdcall SmackSimulate(x)
    extrn _SmackSimulate@4:dword            ; DATA XREF: sub_47BDF0+1Dr
                                            ; .text:0049F86Cr
    ; __stdcall SmackSoundUseDirectSound(x)
    extrn _SmackSoundUseDirectSound@4:dword ; DATA XREF: sub_47BDF0+30r
                                            ; .text:0049F866r
    ; __stdcall SmackOpen(x,x,x)
    extrn _SmackOpen@12:dword               ; DATA XREF: sub_47BDF0+42r
                                            ; .text:0049F860r
    ; __stdcall SmackSoundOnOff(x,x)
    extrn _SmackSoundOnOff@8:dword          ; DATA XREF: sub_47BDF0+63r
                                            ; .text:0047C373r ...
    ; __stdcall SmackWait(x)
    extrn _SmackWait@4:dword                ; DATA XREF: sub_47C6C0+71r
                                            ; .text:0049F8AEr
    ; __stdcall SmackBufferOpen(x,x,x,x,x,x)
    extrn _SmackBufferOpen@24:dword         ; DATA XREF: sub_47BF70+197r
                                            ; .text:0049F884r
    ; __stdcall SmackBufferNewPalette(x,x,x)
    extrn _SmackBufferNewPalette@12:dword   ; DATA XREF: sub_47BF70+1AEr
                                            ; .text:0049F87Er
    ; __stdcall SmackColorRemap(x,x,x,x)
    extrn _SmackColorRemap@16:dword         ; DATA XREF: sub_47BF70+1C6r
                                            ; .text:0049F878r

    ; ---------------------------------------------------------------------------

    ; Segment type: Pure data
    ; Segment permissions: Read
    _rdata segment para public 'DATA' use32
    assume cs:_rdata
    ;org 4FC420h
    dd 0, 35C0B9E5h, 0, 4, 110h, 0, 110E00h, 0, 35C0B9E5h, 0, 3, 0EC60h, 0
    dd 110F10h, 0, 35C0B9E5h, 0, 2, 36h, 0, 11FB70h, 7FC0200h
    flt_4FC478 dd 0.0                       ; DATA XREF: sub_401180+7r
                                            ; sub_4011C0+3r ...
    dd 0
    dbl_4FC480 dq -7.0e-1                   ; DATA XREF: sub_401360+EEr
                                            ; sub_401360+1BCr ...
    dbl_4FC488 dq -5.0e-1                   ; DATA XREF: sub_401360+100r
                                            ; sub_401360+1C4r ...
    off_4FC490 dd offset aStopping          ; DATA XREF: sub_403180+2o
                                            ; "Stopping"
    dd offset sub_401C20
    dd 2 dup(0), 13h, 5012A800h, 50129C00h, 40216000h, 43974000h, 800h, 2800100h
    dd 128C0000h, 12800050h, 30100050h, 40h, 0, 60130000h, 80000100h, 74005012h
    dd 40005012h, 4030h, 0, 13000000h, 10060h, 501274h, 501268h, 403070h, 2 dup(0)
    dd 1006013h, 50125C00h, 50125000h, 4030A000h, 2 dup(0), 601300h, 12440001h
    dd 12340050h, 30D00050h, 40h, 0, 60130000h, 20000100h, 34005012h, 5012h
    dd 4031h, 0, 13000000h, 10060h, 50120Ch, 501200h, 402640h, 2 dup(0), 10010C13h
    dd 5011F000h, 50120000h, 402B7000h, 2 dup(0), 1401300h, 11E4000Ch, 11CC0050h
    dd 20100050h, 40h, 0, 40130000h, 0BC000400h, 0CC005011h, 10005011h, 4020h
    dd 0, 13000000h, 0, 5011ACh, 5011A0h, 402D10h, 2 dup(0), 2413h, 50119400h
    dd 50118000h, 402DA000h, 2 dup(0), 2241300h, 11740000h, 11600050h, 2FC00050h
    dd 40h, 0, 24130000h, 54000000h, 40005011h, 0C0005011h, 401Ch, 0, 13000000h
    dd 4, 501130h, 501128h, 401CE0h, 2 dup(0), 413h, 50112000h, 50110C00h
    dd 401FD000h, 2 dup(0), 2041300h, 10FC0000h, 129C0050h, 1E000050h, 40h
    dd 0, 4130000h, 0F0000000h, 0E8005010h, 0F0005010h, 4021h, 0, 13000000h
    dd 20h, 5010D8h, 5010CCh, 402430h, 2 dup(0), 20413h, 5010C001h, 5010AC00h
    dd 40316000h, 4394E000h, 200h, 4000E00h, 10A40000h, 10AC0050h, 31600050h
    dd 94E00040h, 20043h, 70000h, 9C000004h, 5010h
    flt_4FC6D0 dd 0.0                       ; DATA XREF: .text:004025FBr
                                            ; .text:00402ACBr ...
    flt_4FC6D4 dd 1.0                       ; DATA XREF: .text:00402666r
    dbl_4FC6D8 dq -7.0e-1                   ; DATA XREF: .text:004026B9r
    dbl_4FC6E0 dq -5.0e-1                   ; DATA XREF: .text:004026CBr
    off_4FC6E8 dd offset aStandby           ; DATA XREF: sub_406BF0+2o
                                            ; "Standby"
    dd offset sub_405FE0
    dd 0, 10h, 200000Fh, 2 dup(50151800h), 40609000h, 0, 1000h, 0F00h, 15080102h
    dd 15000050h, 31D00050h, 94E00040h, 120043h, 20E0000h, 0F4000004h, 0E8005014h
    dd 5014h, 0E0004063h, 12004394h, 5000000h, 200h, 5014D8h, 5014C4h, 4038A0h
    dd 439740h, 8, 41001h, 5014B800h, 50129C00h, 4034A000h, 43974000h, 800h
    dd 2800100h, 14A80000h, 129C0050h, 32600050h, 97400040h, 80043h, 10000h
    dd 98000006h, 88005014h, 90005014h, 40004031h, 8004397h, 1000000h, 680h
    dd 501478h, 501470h, 4061A0h, 2 dup(0), 0Eh, 50146800h, 50145C00h, 4033A000h
    dd 4394E000h, 1200h, 4120700h, 14540000h, 144C0050h, 67800050h, 97400040h
    dd 80043h, 0C0000h, 3C000002h, 30005014h, 5014h, 40004069h, 8004397h, 0D000000h
    dd 400h, 501420h, 501414h, 406AA0h, 439740h, 8, 60009h, 50140800h, 50120000h
    dd 403A2000h, 438C0000h, 1300h, 5080000h, 13FC0010h, 12000050h, 3F700050h
    dd 97400040h, 180043h, 8060000h, 0F0001002h, 0E0005013h, 80005013h, 0E0004059h
    dd 12004394h, 7000000h, 412h, 5013D0h, 5010CCh, 405300h, 4394E0h, 12h
    dd 10020006h, 5013C400h, 5013B800h, 40427000h, 43974000h, 800h, 2000400h
    dd 13B00000h, 13A00050h, 4DB00050h, 94E00040h, 120043h, 0B0000h, 94000002h
    dd 88005013h, 0D0005013h, 0E000404Ah, 12004394h, 0B000000h, 100800h, 501380h
    dd 501388h, 404730h, 4394E0h, 12h, 1002000Bh, 50137400h, 5010CC00h, 40574000h
    dd 43974000h, 1800h, 2000600h, 13600000h, 50h
    dbl_4FC910 dq 8.0                       ; DATA XREF: .text:00403BD6r
                                            ; .text:004044B2r ...
    dbl_4FC918 dq -8.0                      ; DATA XREF: .text:00403C1Ar
                                            ; .text:004044F7r ...
    flt_4FC920 dd 0.0                       ; DATA XREF: .text:00403EF1r
                                            ; .text:00404094r ...
    dd 0
    dbl_4FC928 dq 1.6e1                     ; DATA XREF: .text:00404027r
    flt_4FC930 dd 3.0e1                     ; DATA XREF: .text:0040435Fr
                                            ; .text:00404371r
    flt_4FC934 dd 5.0000002e-4              ; DATA XREF: .text:00404365r
    flt_4FC938 dd -7.1428572e-3             ; DATA XREF: .text:00404377r
    flt_4FC93C dd -1.5e2                    ; DATA XREF: .text:0040437Fr
    flt_4FC940 dd -5.0e-1                   ; DATA XREF: .text:00404BC6r
    flt_4FC944 dd 1.5e1                     ; DATA XREF: .text:00404BCCr
    dbl_4FC948 dq 3.0e-1                    ; DATA XREF: .text:00404FC8r
    dbl_4FC950 dq 2.0e-1                    ; DATA XREF: .text:004059F6r
                                            ; .text:00405B2Ar ...
    dbl_4FC958 dq 1.5                       ; DATA XREF: .text:00406A46r
    off_4FC960 dd offset sub_405D90         ; DATA XREF: .text:00405A47o
    dd 0
    flt_4FC968 dd 0.0                       ; DATA XREF: sub_406F80+BBr
                                            ; sub_408670+26r ...
    dd 0
    dbl_4FC970 dq 6.5536e4                  ; DATA XREF: sub_407D40+40r
                                            ; sub_407D40+60r ...
    dd 40000000h, 0
    off_4FC980 dd offset nullsub_33         ; DATA XREF: sub_407350+1Co
                                            ; std::locale::facet::`scalar deleting destructor'(uint)+9o ...
    dd offset ??_Gfacet@locale@std@@UAEPAXI@Z ; std::locale::facet::`scalar deleting destructor'(uint)
    off_4FC988 dd offset sub_4077E0         ; DATA XREF: .text:0040795Do
                                            ; sub_408CB0+10Ao ...
    dd offset sub_407980
    off_4FC990 dd offset sub_4079F0         ; DATA XREF: .text:004079C6o
                                            ; sub_408CB0+152o ...
    dd offset sub_4079D0
    off_4FC998 dd offset sub_407AE0         ; DATA XREF: .text:00407AACo
                                            ; sub_408CB0+213o
    dd offset sub_407AC0
    off_4FC9A0 dd offset sub_407E90         ; DATA XREF: sub_407D40+111o
    dd offset sub_407E70
    off_4FC9A8 dd offset sub_408100         ; DATA XREF: .text:004085ECo
                                            ; sub_408CB0+8Do
    dd offset sub_408600
    off_4FC9B0 dd offset sub_4086D0         ; DATA XREF: sub_4087E0+1Co
                                            ; sub_408CB0+56o
    dd offset sub_408810
    flt_4FC9B8 dd 0.0                       ; DATA XREF: .text:004095E7r
                                            ; .text:00409615r ...
    flt_4FC9BC dd -9.9999998e-3             ; DATA XREF: .text:00409630r
                                            ; sub_409730+1C1r
    flt_4FC9C0 dd -2.0000001e-3             ; DATA XREF: .text:0040964Br
                                            ; sub_409730+1DCr
    flt_4FC9C4 dd 3.0e1                     ; DATA XREF: sub_409730+39Ar
                                            ; sub_409730+3CAr
    flt_4FC9C8 dd -2.4999999e-3             ; DATA XREF: sub_409730+48Fr
                                            ; sub_409730+4C9r ...
    flt_4FC9CC dd 5.0                       ; DATA XREF: sub_409730+49Er
                                            ; sub_409730+4D9r ...
    flt_4FC9D0 dd 1.0e2                     ; DATA XREF: sub_409730+4A4r
                                            ; sub_409730+4BBr ...
    flt_4FC9D4 dd -2.0e-2                   ; DATA XREF: sub_409730+586r
    dbl_4FC9D8 dq 0.0                       ; DATA XREF: sub_40AA40+13Cr
    flt_4FC9E0 dd -1.5258789e-5             ; DATA XREF: sub_40AA40+203r
                                            ; sub_40AA40+211r ...
    dd 0
    dbl_4FC9E8 dq 6.5536e4                  ; DATA XREF: sub_40AA40+295r
                                            ; sub_40AA40+2A4r ...
    flt_4FC9F0 dd 5.0e1                     ; DATA XREF: sub_40BB00+31r
                                            ; sub_40BB00+184r
    flt_4FC9F4 dd 2.5e1                     ; DATA XREF: sub_40BB00+57r
    flt_4FC9F8 dd 1.25e-1                   ; DATA XREF: sub_40BB00+102r
    flt_4FC9FC dd 2.5e-1                    ; DATA XREF: sub_40BB00+132r
    flt_4FCA00 dd 1.0                       ; DATA XREF: sub_40BB00+158r
                                            ; sub_40BB00+16Er
    flt_4FCA04 dd 2.0e2                     ; DATA XREF: sub_40BB00+19Cr
    flt_4FCA08 dd 3.0                       ; DATA XREF: sub_40BB00+1B2r
    dd 0
    dword_4FCA10 dd 503C2800h               ; DATA XREF: .text:0040D880r
                                            ; sub_40E630+2Ar
    dword_4FCA14 dd 283C5064h               ; DATA XREF: .text:0040D888r
                                            ; sub_40E630+32r
    off_4FCA18 dd offset aStandby           ; DATA XREF: sub_415B20+2o
                                            ; "Standby"
    dd offset sub_40F7D0
    dd 2 dup(0), 200000Fh, 501AFC00h, 50150000h, 40FA2000h, 4394E000h, 200h
    dd 4020E00h, 1AF00000h, 1AE80050h, 18E00050h, 97400041h, 80043h, 0E0000h
    dd 0D8000006h, 4C00501Ah, 0B0005014h, 40004111h, 8004397h, 8000000h, 200h
    dd 501ACCh, 501430h, 411560h, 439740h, 8, 40009h, 501AC000h, 5014E800h
    dd 40FBE000h, 4394E000h, 200h, 2000500h, 1AB40000h, 145C0050h, 0E700050h
    dd 94E00041h, 20043h, 12070000h, 0A8000004h, 9C00501Ah, 5000501Ah, 4000411Fh
    dd 8004397h, 2000000h, 600h, 501A90h, 501A80h, 412D40h, 439740h, 8, 20001h
    dd 501A7400h, 501A8000h, 41271000h, 43974000h, 800h, 2000100h, 1A680000h
    dd 1A800050h, 34700050h, 97400041h, 80043h, 10000h, 54000002h, 501Ah, 80005012h
    dd 413Dh, 300438Ch, 0, 100508h, 501A40h, 501200h, 414380h, 439740h, 8
    dd 10020806h, 501A3000h, 5013E000h, 4152F000h, 4394E000h, 200h, 4120700h
    dd 1A1C0000h, 10CC0050h, 4E700050h, 94E00041h, 20043h, 60000h, 0C001002h
    dd 8800501Ah, 70005013h, 0E0004147h, 2004394h, 0B000000h, 100800h, 5019FCh
    dd 501388h, 414A80h, 4394E0h, 2, 1002000Bh, 5019E800h, 5019E000h, 413BC000h
    dd 2 dup(0), 1300h, 19D40000h, 19C00050h, 3E00050h, 41h, 0, 130000h, 0B0000006h
    dd 9C005019h, 50005019h, 4108h, 0, 13000000h, 600h, 50198Ch, 50197Ch, 415250h
    dd 2 dup(0), 20013h, 50196800h, 50195800h, 40F2A000h, 2 dup(0), 4001300h
    dd 19480000h, 50h
    flt_4FCC40 dd 0.0                       ; DATA XREF: .text:00411E9Ar
                                            ; .text:004142C4r ...
    dd 2 dup(0), 40000000h
    flt_4FCC50 dd 3.0e1                     ; DATA XREF: .text:004123ECr
                                            ; .text:0041492Br
    flt_4FCC54 dd -5.0e-1                   ; DATA XREF: .text:00414925r
    dbl_4FCC58 dq 2.0e-1                    ; DATA XREF: .text:0041548Fr
                                            ; .text:00415672r ...
    off_4FCC60 dd offset sub_410C70         ; DATA XREF: .text:00410A92o
    off_4FCC64 dd offset sub_4158D0         ; DATA XREF: .text:004154E0o
    byte_4FCC68 db 4                        ; DATA XREF: sub_418310+2EEr
    dd 0A0Eh
    align 4
    dbl_4FCC70 dq 6.5536e4                  ; DATA XREF: .text:004167CBr
    flt_4FCC78 dd 2.56e2                    ; DATA XREF: .text:00416DC0r
                                            ; .text:00416DDEr
    flt_4FCC7C dd -1.0e3                    ; DATA XREF: sub_4170C0+23r
                                            ; sub_4170C0+51r
    flt_4FCC80 dd 1.0e-1                    ; DATA XREF: .text:004172A9r
    dd 0
    flt_4FCC88 dd 0.0                       ; DATA XREF: sub_41ACE0+17r
                                            ; sub_41BA60+13r ...
    flt_4FCC8C dd 1.0                       ; DATA XREF: sub_41BA60+90r
                                            ; sub_41BA60+1A5r ...
    dbl_4FCC90 dq -7.0e-1                   ; DATA XREF: sub_41BA60+16Ar
    dbl_4FCC98 dq -5.0e-1                   ; DATA XREF: sub_41BA60+17Cr
    flt_4FCCA0 dd -1.0                      ; DATA XREF: sub_41BD10+4Dr
                                            ; sub_41BD10+6Cr
    dd 0, 0D7B70EE0h, 11CF4340h, 200063B0h, 35CDC2AFh, 593817A0h, 11CF7DB3h
    dd 0AA00DEA2h, 5633B900h, 6C14DB80h, 11CEA733h, 200021A5h, 60E50BAFh
    dword_4FCCD8 dd 0B3A6F3E0h, 11CF2B43h, 0AA00DEA2h, 5633B900h, 6C14DB81h, 11CEA733h
                                            ; DATA XREF: sub_4B5370+158o
    dd 200021A5h, 60E50BAFh, 57805885h, 11CF6EECh, 23A84194h, 270EC103h, 0DA044E00h
    dd 11D069B2h, 0AA00D5A1h, 0BBDFB800h, 6C14DB84h, 11CEA733h, 200021A5h
    dd 60E50BAFh, 6C14DB85h, 11CEA733h, 200021A5h, 60E50BAFh, 4B9F0EE0h, 11D00D7Eh
    dd 0A000069Bh, 0B8A303C9h, 2B74F7C0h, 11CF9154h, 0AA00CDA9h, 0E3866800h
    dd 9D460580h, 11CFA822h, 80000C96h, 824E53C7h, 133EFE40h, 11D032DCh, 0A000FB9Ch
    dd 0CB430AC9h
    dword_4FCD78 dd 133EFE41h, 11D032DCh, 0A000FB9Ch, 0CB430AC9h, 0D1EB6D20h, 11D08923h
                                            ; DATA XREF: sub_4CA5D0+ACo
                                            ; sub_4CA900+31o
    dd 0A000979Dh, 0CB430AC9h
    dword_4FCD98 dd 685BC400h, 11CF9D2Ch, 0AA00CDA9h, 0E3866800h ; DATA XREF: sub_441460+3Do
                                            ; sub_441460+8Eo ...
    dword_4FCDA8 dd 36E95EE0h, 11CF8577h, 80000C96h, 824E53C7h ; DATA XREF: sub_441460+2Bo
                                            ; sub_441460+7Co ...
    dword_4FCDB8 dd 0F1D6860h, 11CF88D9h, 0A0004E9Ch, 5E4205C9h ; DATA XREF: sub_441460+4Fo
                                            ; sub_441460+A2o ...
    dword_4FCDC8 dd 44EAA760h               ; DATA XREF: sub_441460+19o
                                            ; sub_441460+6Ao ...
    dword_4FCDCC dd 11CFCB68h               ; DATA XREF: .text:00443103r
    dword_4FCDD0 dd 0A0004E9Ch              ; DATA XREF: .text:0044310Er
    dword_4FCDD4 dd 5E4205C9h               ; DATA XREF: .text:00443126r
    dd 5454E9A0h, 11CEDB65h, 0AA001C92h, 72496C00h, 0AF465C71h, 11CF9588h
    dd 0AA0020A0h, 0AC576100h, 26C66A70h, 11CFB367h, 0AA0024A0h, 0AC576100h
    dd 194C220h, 11D0A303h, 0A0004F9Ch, 5E4205C9h
    dword_4FCE18 dd 1BB4AF80h, 11D0A303h, 0A0004F9Ch, 5E4205C9h, 2FE8F810h, 11D0B2A5h, 87A7h
                                            ; DATA XREF: sub_4CA490+59o
    dd 0FCAB03F8h, 762CCDA1h, 11D0D916h, 0C00039BAh, 67EDD74Fh, 0F56920A0h
    dd 11D0D218h, 0C00039BAh, 67EDD74Fh, 0B4319322h, 11D0D20Dh, 0C00039BAh
    dd 67EDD74Fh, 48784000h, 11D0D219h, 0C00039BAh, 67EDD74Fh, 1318F560h, 11D0912Ch
    dd 0A000AA9Dh, 0CB430AC9h
    dword_4FCE88 dd 7D916C0h                ; DATA XREF: sub_441C30+4Er
                                            ; sub_441C30+16Fr ...
    dword_4FCE8C dd 11CFE0AFh               ; DATA XREF: sub_441C30+54r
                                            ; sub_441C30+175r ...
    dword_4FCE90 dd 0A0004E9Ch              ; DATA XREF: sub_441C30+5Er
                                            ; sub_441C30+188r ...
    dword_4FCE94 dd 5E4205C9h               ; DATA XREF: sub_441C30+7Br
                                            ; sub_441C30+192r ...
    dd 59B95640h, 11D09667h, 7DA7h, 0FCAB03F8h
    dword_4FCEA8 dd 78EC89A0h               ; DATA XREF: sub_441C30+116r
    dword_4FCEAC dd 11CFE0AFh               ; DATA XREF: sub_441C30+110r
    dword_4FCEB0 dd 0A0004E9Ch              ; DATA XREF: sub_441C30+11Br
    dword_4FCEB4 dd 5E4205C9h               ; DATA XREF: sub_441C30+129r
    dd 0BA5A7A70h, 11D09DBFh, 0A000C19Ch, 5E4205C9h
    dword_4FCEC8 dd 0F6DCC200h              ; DATA XREF: sub_441C30+B1r
                                            ; sub_443070+11o
    dword_4FCECC dd 11D0A2FEh               ; DATA XREF: sub_441C30+ABr
    dword_4FCED0 dd 0A0004F9Ch              ; DATA XREF: sub_441C30+B7r
    dword_4FCED4 dd 5E4205C9h               ; DATA XREF: sub_441C30+CAr
    dd 1FD92E0h, 11D0A2FFh, 0A0004F9Ch, 5E4205C9h
    dword_4FCEE8 dd 0C4A54DA0h              ; DATA XREF: sub_441C30+1D7r
    dword_4FCEEC dd 11CFE0AFh               ; DATA XREF: sub_441C30+1D2r
    dword_4FCEF0 dd 0A0004E9Ch              ; DATA XREF: sub_441C30+1DDr
    dword_4FCEF4 dd 5E4205C9h               ; DATA XREF: sub_441C30+1EBr
    dd 0E63232A0h, 11D09DBFh, 0A000C19Ch, 5E4205C9h
    dword_4FCF08 dd 0F2F0CE00h              ; DATA XREF: sub_441C30+2A8r
    dword_4FCF0C dd 11CFE0AFh               ; DATA XREF: sub_441C30+2ADr
    dword_4FCF10 dd 0A0004E9Ch              ; DATA XREF: sub_441C30+2B3r
    dword_4FCF14 dd 5E4205C9h               ; DATA XREF: sub_441C30+2BDr
    dd 47D4D946h, 11CF62E8h, 4544BC93h, 5453h, 0B0210780h, 11D089CDh, 0A00008AFh
    dd 16CD25C9h, 279AFA83h, 11CE4981h, 200021A5h, 60E50BAFh, 279AFA85h, 11CE4981h
    dd 200021A5h, 60E50BAFh, 279AFA84h, 11CE4981h, 200021A5h, 60E50BAFh
    dword_4FCF68 dd 279AFA86h, 11CE4981h, 200021A5h, 60E50BAFh, 0B0210781h, 11D089CDh, 0A00008AFh
                                            ; DATA XREF: sub_4CF570+136o
    dd 16CD25C9h, 0B0210782h, 11D089CDh, 0A00008AFh, 16CD25C9h, 0B0210783h
    dd 11D089CDh, 0A00008AFh, 16CD25C9h, 31EFAC30h, 11D0515Ch, 0AA00AAA9h
    dd 93BE6100h
    dword_4FCFB8 dd 99797420h, 11CFF5F5h, 0A0002798h, 0C8961424h ; DATA XREF: .text:004446F9o
                                            ; sub_49EE30+53Co
    dword_4FCFC8 dd 0D8D29744h, 11D0208Ah, 0A0009DBCh, 0B6672924h, 0D1714F40h, 11D05989h
                                            ; DATA XREF: .data:0050A788o
    dd 4544849Ah, 5453h, 25462BA0h, 11CFCE8Dh, 0AA009B83h, 4830B900h, 4595FD80h
    dd 11D11D4Dh, 6000FC99h, 5ABF6A97h
    flt_4FD008 dd 6.666667e-2               ; DATA XREF: sub_41E420+285r
                                            ; sub_41E420+30Dr ...
    flt_4FD00C dd 1.0                       ; DATA XREF: sub_41E420+28Br
                                            ; sub_41E420+313r ...
    dbl_4FD010 dq 1.33                      ; DATA XREF: sub_420D20+61r
    dbl_4FD018 dq 3.2e1                     ; DATA XREF: sub_420D20+B4r
    flt_4FD020 dd 1.5259022e-5              ; DATA XREF: sub_421700+2B9r
                                            ; sub_421700+2C4r ...
    flt_4FD024 dd 5.12e2                    ; DATA XREF: sub_421700+444r
                                            ; sub_421700+46Dr
    flt_4FD028 dd 6.5535e4                  ; DATA XREF: sub_421700+47Fr
                                            ; sub_421700+494r ...
    dd 0
    flt_4FD030 dd 0.0                       ; DATA XREF: sub_422040+5Ar
    dd 0
    dbl_4FD038 dq 3.0e1                     ; DATA XREF: sub_4224B0+840r
    dbl_4FD040 dq -7.0e-1                   ; DATA XREF: sub_4237D0+107r
                                            ; sub_4237D0+161r
    dbl_4FD048 dq -5.0e-1                   ; DATA XREF: sub_4237D0+10Fr
                                            ; sub_4237D0+173r
    aWarningTheCurr db 'Warning! The currently installed version of Microsoft%sDirec'
                                            ; DATA XREF: .text:004266BDo
    db 'tX may not function properly with Total Annihilation.%sPleas'
    db 'e install the version of DirectX included on the%sTotal Anni'
    db 'hilation setup CD.',0
    align 4
    aWarningYourCop db 'Warning!  Your copy of Revision.GPF is the wrong version for'
                                            ; DATA XREF: sub_429000+93o
                                            ; sub_429000+BDo
    db ' this executable.  You may experience some problems if you c'
    db 'ontinue playing.  Please download the latest version of the '
    db 'TA patch from www.cavedog.com and reinstall the patch.',0
    dd 0
    align 4
    dbl_4FD208 dq 1.0e1                     ; DATA XREF: sub_42A8D0+780r
    flt_4FD210 dd 0.0                       ; DATA XREF: sub_42BF40+B29r
    dd 0
    dbl_4FD218 dq 1.3                       ; DATA XREF: sub_42D2E0+120r
    flt_4FD220 dd 1.0                       ; DATA XREF: sub_42D2E0+132r
    dd 0
    dbl_4FD228 dq 6.25e-2                   ; DATA XREF: sub_42D2E0+15Ar
    dbl_4FD230 dq 5.0                       ; DATA XREF: sub_42D2E0+160r
    flt_4FD238 dd 5.0                       ; DATA XREF: sub_42D2E0+16Fr
    dd 0
    dbl_4FD240 dq 2.184533333333333e3       ; DATA XREF: sub_42E440+86r
                                            ; sub_42E440+A4r
    dbl_4FD248 dq 7.281777777777778e1       ; DATA XREF: sub_42E440+C2r
    dbl_4FD250 dq 3.0e1                     ; DATA XREF: sub_42E440+10Br
                                            ; sub_42E440+184r ...
    dbl_4FD258 dq 3.333333333333333e-2      ; DATA XREF: sub_42E440+1CEr
    dbl_4FD260 dq 1.745329251994328e-2      ; DATA XREF: sub_42E440+2E9r
    flt_4FD268 dd 0.0                       ; DATA XREF: sub_435DA0+A21r
                                            ; sub_435DA0+A32r ...
    dd 0
    flt_4FD270 dd 0.0                       ; DATA XREF: sub_437840+15r
                                            ; sub_437910+11r
    dd 0
    dbl_4FD278 dq 1.52587890625e-5          ; DATA XREF: sub_437840+A0r
    flt_4FD280 dd 3.0e1                     ; DATA XREF: sub_437D60+10r
                                            ; sub_437D60+48r ...
    flt_4FD284 dd 0.0                       ; DATA XREF: sub_438320+D9r
                                            ; sub_438320+E9r ...
    off_4FD288 dd offset aReady             ; DATA XREF: sub_43C050+F5o
                                            ; "Ready"
    dd offset sub_439EA0
    dd 2 dup(0), 0Fh, 5119B800h
    db 0
    byte_4FD2A1 db 3 dup(0)                 ; DATA XREF: sub_43C050+110o
    flt_4FD2A4 dd 1.0e1                     ; DATA XREF: sub_438650+15r
                                            ; sub_438650+2Ar
    flt_4FD2A8 dd 3.0e2                     ; DATA XREF: sub_438650+82r
    dd 0
    dbl_4FD2B0 dq 6.28318530717958          ; DATA XREF: sub_438EA0+21r
    dbl_4FD2B8 dq 1.25e-1                   ; DATA XREF: sub_438EA0+27r
    dbl_4FD2C0 dq 8.9e-1                    ; DATA XREF: sub_4399F0+60r
    off_4FD2C8 dd offset sub_438870         ; DATA XREF: sub_43A0C0+71o
                                            ; sub_43A1F0+8o ...
    off_4FD2CC dd offset nullsub_34         ; DATA XREF: sub_43A0C0+1Ao
                                            ; sub_43A420+12o
    flt_4FD2D0 dd 1.5258789e-5              ; DATA XREF: sub_43D290+80r
                                            ; sub_43D290+115r ...
    dd 0
    dbl_4FD2D8 dq 6.5536e4                  ; DATA XREF: sub_43D290+157r
                                            ; sub_43D290+1A9r ...
    flt_4FD2E0 dd 8.0                       ; DATA XREF: sub_43D290+2FBr
                                            ; sub_43D290+30Ar
    dd 40000000h
    flt_4FD2E8 dd 0.0                       ; DATA XREF: sub_43E490+5B8r
                                            ; sub_43E490+695r ...
    dd 0
    dbl_4FD2F0 dq 2.0                       ; DATA XREF: sub_443480+7Dr
    off_4FD2F8 dd offset sub_44CE50         ; DATA XREF: .text:0044CE26o
                                            ; sub_44CE50+9o ...
    dd offset sub_44CE80
    dd offset unknown_libname_13
    dd offset unknown_libname_17
    dd offset sub_44CF00
    dd offset unknown_libname_16
    dd offset sub_44CE90
    dd offset unknown_libname_14
    dd offset __purecall
    dd offset sub_44CF40
    dd offset nullsub_62
    dd offset unknown_libname_15
    off_4FD328 dd offset sub_44CFF0         ; DATA XREF: sub_44CF60+5o
                                            ; sub_44D010+16o
    dd offset sub_44D090
    dd offset __RTC_NumErrors
    dd offset unknown_libname_17
    dd offset sub_44D310
    dd offset sub_44D290
    dd offset sub_44D0E0
    dd offset sub_44D350
    dd offset sub_44D2C0
    dd offset sub_44CF40
    dd offset nullsub_62
    dd offset unknown_libname_15
    off_4FD358 dd offset sub_44D450         ; DATA XREF: sub_44D3B0+5o
                                            ; sub_44D470+16o
    dd offset sub_44D500
    dd offset sub_44D440
    dd offset unknown_libname_17
    dd offset sub_44D800
    dd offset sub_44D7C0
    dd offset sub_44D560
    dd offset sub_44D840
    dd offset sub_44D720
    dd offset sub_44CF40
    dd offset nullsub_62
    dd offset unknown_libname_15
    off_4FD388 dd offset sub_44D910         ; DATA XREF: sub_44D8A0+10o
                                            ; sub_44D930+19o
    dd offset sub_44D9A0
    dd offset sub_44D900
    dd offset unknown_libname_17
    dd offset sub_44CF00
    dd offset sub_44DCB0
    dd offset sub_44DA00
    dd offset sub_44DD00
    dd offset sub_44DC60
    dd offset sub_44CF40
    dd offset nullsub_62
    dd offset unknown_libname_15
    off_4FD3B8 dd offset sub_44DF80         ; DATA XREF: sub_44DE80+2Bo
                                            ; sub_44E080+2Co ...
    dd offset sub_44DFB0
    dd offset unknown_libname_18
    dd offset unknown_libname_19
    dd offset sub_44E5B0
    dd offset unknown_libname_16
    dd offset sub_44CE90
    dd offset unknown_libname_14
    dd offset sub_44E3C0
    dd offset sub_44E530
    dd offset sub_44DDC0
    dd offset sub_44E3A0
    flt_4FD3E8 dd 1.5258789e-5              ; DATA XREF: sub_44E5B0+52r
                                            ; sub_44EB60+3Cr
    flt_4FD3EC dd 5.0e-1                    ; DATA XREF: sub_44E5B0+81r
    flt_4FD3F0 dd 4.8e1                     ; DATA XREF: sub_44EB60+45r
    dd 0
    off_4FD3F8 dd offset sub_44E7B0         ; DATA XREF: sub_44E740+Ao
                                            ; sub_44E7D0+19o ...
    dd offset sub_44E880
    dd offset sub_44E7A0
    dd offset unknown_libname_21
    dd offset sub_44EB60
    dd offset unknown_libname_16
    dd offset sub_44CE90
    dd offset unknown_libname_14
    dd offset sub_44EA60
    dd offset sub_44EB40
    dd offset sub_44E930
    dd offset unknown_libname_20
    off_4FD428 dd offset sub_44EF60         ; DATA XREF: sub_44EF20+6o
                                            ; sub_44EF60+9o ...
    dd offset sub_44EF90
    dd offset nullsub_63
    dd offset nullsub_64
    dd offset nullsub_65
    dd offset sub_44EF80
    dd offset unknown_libname_23
    dd offset unknown_libname_22
    dd offset nullsub_66
    dd offset nullsub_67
    dd offset nullsub_68
    dd 0
    off_4FD458 dd offset sub_44F040         ; DATA XREF: sub_44F010+17o
                                            ; sub_44F040+4o ...
    dd offset sub_44F2A0
    dd offset sub_44F1A0
    dd offset sub_44F150
    dd offset nullsub_65
    dd offset sub_44F290
    dd offset sub_44F260
    dd offset sub_44F480
    dd offset sub_44F4A0
    dd offset nullsub_67
    dd offset sub_417E00
    dd 0
    off_4FD488 dd offset sub_44F590         ; DATA XREF: sub_44F570+Eo
    dd offset sub_44EF90
    dd offset nullsub_63
    dd offset sub_44F650
    dd offset nullsub_65
    dd offset sub_44F5B0
    dd offset unknown_libname_23
    dd offset unknown_libname_22
    dd offset nullsub_66
    dd offset sub_44F5C0
    dd offset nullsub_68
    dd 0
    flt_4FD4B8 dd 3.3333334e-1              ; DATA XREF: sub_457D30+110r
    flt_4FD4BC dd 5.0e-1                    ; DATA XREF: sub_457D30+22Er
    flt_4FD4C0 dd 0.0                       ; DATA XREF: sub_4586A0+45r
                                            ; sub_458810+94r ...
    flt_4FD4C4 dd 2.55e2                    ; DATA XREF: sub_458DD0+C8r
    flt_4FD4C8 dd 9.9999998e-3              ; DATA XREF: sub_4597F0+Er
                                            ; sub_4597F0+16r ...
    flt_4FD4CC dd 5.0                       ; DATA XREF: sub_459C70+671r
    aOnline_dll db 'online.dll',0           ; DATA XREF: sub_45B250+BBo
                                            ; sub_45B490+97o ...
    dd 0
    align 4
    flt_4FD4E0 dd 0.0                       ; DATA XREF: sub_45B9B0+46r
                                            ; .text:0045BB8Ar ...
    dd 0
    dbl_4FD4E8 dq -1.0                      ; DATA XREF: sub_45B9B0+53r
                                            ; .text:0045BB97r ...
    flt_4FD4F0 dd -4.1666668e-2             ; DATA XREF: sub_45BCC0+Cr
                                            ; .text:0045BD8Cr ...
    dd 0
    dbl_4FD4F8 dq 5.0e-1                    ; DATA XREF: sub_45BCC0+12r
                                            ; .text:0045BD92r ...
    flt_4FD500 dd 1.5625e-2                 ; DATA XREF: sub_45D7C0+120r
                                            ; sub_45DE30+116r
    flt_4FD504 dd 5.0000001e-2              ; DATA XREF: sub_45E5E0+483r
                                            ; sub_45ED50+382r
    flt_4FD508 dd 4.7619049e-2              ; DATA XREF: sub_45ED50+10Cr
    flt_4FD50C dd 1.5384615e-2              ; DATA XREF: sub_45ED50+1A8r
    flt_4FD510 dd 3.3333335e-2              ; DATA XREF: sub_45ED50+2DFr
    off_4FD514 dd offset sub_461340         ; DATA XREF: sub_460E20+101o
                                            ; sub_460F60+Ao ...
    off_4FD518 dd offset sub_462CC0         ; DATA XREF: sub_460E20+F7o
                                            ; sub_460F60+14o ...
    dd 0
    dbl_4FD520 dq 8.0e-1                    ; DATA XREF: sub_464060+146r
    dbl_4FD528 dq -1.5                      ; DATA XREF: sub_464060+16Dr
    dbl_4FD530 dq 1.38e2                    ; DATA XREF: sub_464060+17Br
    flt_4FD538 dd 0.0                       ; DATA XREF: sub_464B30+5Er
                                            ; sub_464C60+5Er
    dd 0
    dbl_4FD540 dq -7.0e-1                   ; DATA XREF: sub_464B30+EEr
                                            ; sub_464C60+EEr ...
    dbl_4FD548 dq -5.0e-1                   ; DATA XREF: sub_464B30+100r
                                            ; sub_464C60+101r ...
    flt_4FD550 dd 1.0e2                     ; DATA XREF: UpdateDatePlayers+4AFr
                                            ; UpdateDatePlayers+51Br
    off_4FD554 dd offset sub_467980         ; DATA XREF: GameUnit_LOS_Radar+1A7o
    off_4FD558 dd offset sub_467960         ; DATA XREF: GameUnit_LOS_Radar+1A2o
    off_4FD55C dd offset sub_467840         ; DATA XREF: GameUnit_LOS_Radar+DCo
    dbl_4FD560 dq 1.0e-3                    ; DATA XREF: sub_468380+61r
                                            ; sub_468380+14Br
    flt_4FD568 dd 0.0                       ; DATA XREF: GameUnit_LOS_Unknown1+3CDr
                                            ; GameUnit_LOS_Unknown1+449r ...
    flt_4FD56C dd 9.9999e4                  ; DATA XREF: GameUnit_LOS_Unknown1+584r
    flt_4FD570 dd -9.9999e4                 ; DATA XREF: GameUnit_LOS_Unknown1+612r
    dd 0
    dbl_4FD578 dq 5.0e-1                    ; DATA XREF: sub_46BC70+46r
    off_4FD580 dd offset sub_470AE0         ; DATA XREF: sub_470A90+1Bo
                                            ; sub_470AE0+Co ...
    dd 0
    off_4FD588 dd offset sub_471430         ; DATA XREF: .text:0047138Bo
                                            ; sub_471FD0+54o
    dd offset sub_472D50
    dd offset sub_472E30
    dd offset sub_472E70
    dd offset sub_4737C0
    dd offset sub_472E00
    dd offset sub_4736E0
    dd 0
    off_4FD5A8 dd offset sub_471CD0         ; DATA XREF: sub_471430+25o
                                            ; sub_471560+25o ...
    dd offset __purecall
    dd offset __purecall
    dd offset __purecall
    off_4FD5B8 dd offset sub_471560         ; DATA XREF: .text:004714BBo
                                            ; sub_4720D0+85o ...
    dd offset sub_472EB0
    dd offset sub_472F90
    dd offset sub_472FD0
    dd offset sub_473D50
    dd offset sub_472F60
    dd offset sub_473B50
    dd 0
    off_4FD5D8 dd offset sub_4716A0         ; DATA XREF: .text:004715EBo
                                            ; sub_472330+54o ...
    dd offset sub_473010
    dd offset sub_4730F0
    dd offset sub_473130
    dd offset sub_4743A0
    dd offset sub_4730C0
    dd offset sub_4742C0
    dd 0
    off_4FD5F8 dd offset sub_4717E0         ; DATA XREF: .text:0047172Bo
                                            ; sub_472430+54o ...
    dd offset sub_473170
    dd offset sub_473250
    dd offset sub_473290
    dd offset sub_474880
    dd offset sub_473220
    dd offset sub_474760
    dd 0
    off_4FD618 dd offset sub_474D10         ; DATA XREF: sub_474CD0+1Bo
    dd offset sub_475340
    dd offset sub_475470
    dd offset sub_474F80
    dd offset sub_474DF0
    dd offset sub_475440
    dd offset sub_474D50
    dd 0
    off_4FD638 dd offset sub_475110         ; DATA XREF: sub_4750B0+1Bo
    dd offset sub_475600
    dd offset sub_475700
    dd offset unknown_libname_41
    dd offset sub_4751C0
    dd offset sub_4750F0
    dd offset sub_475150
    dd 0
    dbl_4FD658 dq 8.928571428571428e-3      ; DATA XREF: .text:004788FCr
    off_4FD660 dd offset sub_47ED30         ; DATA XREF: .text:0047CACDo
                                            ; sub_47D0E0+1D9o ...
    flt_4FD664 dd 0.0                       ; DATA XREF: sub_47EA40+EAr
                                            ; sub_47EA40+139r
    flt_4FD668 dd 0.0                       ; DATA XREF: sub_480770+2DAr
    flt_4FD66C dd -9.9e1                    ; DATA XREF: sub_480770+2F8r
    byte_4FD670 db 0                        ; DATA XREF: sub_40DA70+27r
                                            ; sub_40E050+74r ...
    dd 0FFFFFFh
    db 3 dup(1)
    byte_4FD678 db 0FFh                     ; DATA XREF: sub_40DA70+2Er
                                            ; sub_40E050+7Fr ...
    dd 10100FFh
    db 1, 0, 0FFh
    dbl_4FD680 dq 6.5536e4                  ; DATA XREF: sub_483610+1F5r
                                            ; sub_483610+215r
    dbl_4FD688 dq 1.111111111111111e-3      ; DATA XREF: sub_483610+1FBr
                                            ; sub_483610+21Br
    flt_4FD690 dd 0.0                       ; DATA XREF: sub_483610+244r
    dd 0
    off_4FD698 dd offset sub_480C50         ; DATA XREF: sub_485D40+4Do
    dd offset sub_480CE0
    dd offset sub_480D50
    dd offset sub_480DB0
    dd offset sub_480DF0
    dd offset sub_480C30
    dd offset sub_480CB0
    dd offset sub_480E30
    dd offset sub_480E50
    dd offset sub_480E70
    dd offset nullsub_69
    dd offset nullsub_70
    dd offset sub_480EB0
    dd offset sub_481140
    dd offset sub_481340
    dd offset UnitScriptingData_DropUnit
    dd offset sub_480B20
    dd offset sub_480770
    dd offset sub_481430
    dd offset sub_481470
    dd offset sub_485E30
    dd 0
    off_4FD6F0 dd offset sub_481490         ; DATA XREF: sub_485E90+36o
                                            ; sub_485F50+119o ...
    dd offset sub_4814B0
    flt_4FD6F8 dd 0.0                       ; DATA XREF: sub_4864B0+128r
                                            ; sub_4866D0+209r ...
    flt_4FD6FC dd 1.0                       ; DATA XREF: sub_4866D0+5E7r
    dbl_4FD700 dq -7.0e-1                   ; DATA XREF: sub_4866D0+624r
    dbl_4FD708 dq -5.0e-1                   ; DATA XREF: sub_4866D0+636r
    dbl_4FD710 dq 6.5536e4                  ; DATA XREF: sub_487BF0+134r
                                            ; sub_487BF0+146r ...
    flt_4FD718 dd 3.0e1                     ; DATA XREF: sub_487BF0+316r
                                            ; sub_487BF0+55Fr
    dd 0
    dbl_4FD720 dq 0.0                       ; DATA XREF: sub_488F30+Ar
    flt_4FD728 dd 0.0                       ; DATA XREF: sub_488F30+26r
                                            ; sub_488F30+4Fr ...
    dd 0
    flt_4FD730 dd 1.5258789e-5              ; DATA XREF: sub_489280+105r
                                            ; sub_489280+14Fr
    dd 0
    dbl_4FD738 dq 4.0e-1                    ; DATA XREF: sub_489280+129r
                                            ; sub_489280+17Fr
    dbl_4FD740 dq 5.4931640625e-3           ; DATA XREF: sub_489280+1D4r
    flt_4FD748 dd 0.0                       ; DATA XREF: sub_489A90+F3r
                                            ; sub_48AD30+F9r ...
    flt_4FD74C dd -2.54e2                   ; DATA XREF: sub_48B200+5Fr
    flt_4FD750 dd 3.9215689e-3              ; DATA XREF: sub_48B3F0+DAr
    off_4FD754 dd offset sub_489600         ; DATA XREF: sub_4895C0+11o
                                            ; sub_489600+8o ...
    flt_4FD758 dd 0.0                       ; DATA XREF: sub_48BD50+4Ar
                                            ; sub_48BE00+9Ar ...
    dd 0
    dbl_4FD760 dq 6.5536e4                  ; DATA XREF: sub_48CF30+F2r
                                            ; sub_48CF30+10Er
    off_4FD768 dd offset sub_48FC40         ; DATA XREF: sub_48E010+942o
    dd 0
    off_4FD770 dd offset sub_48FC70         ; DATA XREF: sub_48E010+93Co
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48FCD0
    dd offset sub_48FD10
    off_4FD788 dd offset sub_48FB30         ; DATA XREF: sub_48E010+8E4o
    dd 0
    off_4FD790 dd offset sub_48FB60         ; DATA XREF: sub_48E010+8DEo
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48FBC0
    dd offset sub_48FC00
    off_4FD7A8 dd offset sub_48FD50         ; DATA XREF: sub_48E010+882o
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48FD70
    dd offset sub_48FDB0
    off_4FD7C0 dd offset sub_48EA00         ; DATA XREF: sub_48E010+807o
    dd offset sub_48F8C0
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48F900
    dd offset sub_48F950
    off_4FD7D8 dd offset sub_48F9A0         ; DATA XREF: sub_48E010+750o
    dd 0
    off_4FD7E0 dd offset sub_48EA00         ; DATA XREF: sub_48E010+74Ao
    dd offset sub_48F9D0
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48FAB0
    dd offset sub_48FAF0
    off_4FD7F8 dd offset sub_48F790         ; DATA XREF: sub_48E010+6E2o
                                            ; sub_48E010+9C1o ...
    dd 0
    off_4FD800 dd offset sub_48F7E0         ; DATA XREF: sub_48E010+6DCo
                                            ; sub_48E010+9BBo ...
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48F840
    dd offset sub_48F880
    off_4FD818 dd offset sub_48EA00         ; DATA XREF: sub_48E010+68Eo
    dd offset sub_48F6B0
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48F710
    dd offset sub_48F750
    off_4FD830 dd offset sub_48F610         ; DATA XREF: sub_48E010+648o
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48F630
    dd offset sub_48F670
    off_4FD848 dd offset sub_48F4C0         ; DATA XREF: sub_48E010+5B0o
    dd 0
    off_4FD850 dd offset sub_48F530         ; DATA XREF: sub_48E010+5A9o
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48F590
    dd offset sub_48F5D0
    off_4FD868 dd offset sub_48F370         ; DATA XREF: sub_48E010+4C7o
    dd 0
    off_4FD870 dd offset sub_48F3E0         ; DATA XREF: sub_48E010+4C0o
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48F440
    dd offset sub_48F480
    off_4FD888 dd offset sub_48F250         ; DATA XREF: sub_48E010+3CFo
    dd 0
    off_4FD890 dd offset sub_48F200         ; DATA XREF: sub_48E010+3C8o
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48F2F0
    dd offset sub_48F330
    off_4FD8A8 dd offset __purecall         ; DATA XREF: sub_48E010+3B4o
    dd 0
    off_4FD8B0 dd offset sub_48EA00         ; DATA XREF: sub_48E010+2EEo
    dd offset sub_48F0F0
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48F160
    dd offset sub_48F1B0
    off_4FD8C8 dd offset sub_48EF80         ; DATA XREF: sub_48E010+240o
    dd 0
    off_4FD8D0 dd offset sub_48EA00         ; DATA XREF: sub_48E010+23Ao
    dd offset sub_48EFB0
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48F070
    dd offset sub_48F0B0
    off_4FD8E8 dd offset sub_48EA00         ; DATA XREF: sub_48E010+1B4o
    dd offset nullsub_71
    dd offset sub_48EEB0
    dd offset nullsub_73
    dd offset sub_48EF00
    dd offset sub_48EF40
    off_4FD900 dd offset sub_48ED50         ; DATA XREF: sub_48E010+130o
    dd 0
    off_4FD908 dd offset sub_48EDB0         ; DATA XREF: sub_48E010+12Ao
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48EE30
    dd offset sub_48EE70
    off_4FD920 dd offset sub_48EC00         ; DATA XREF: sub_48E010+C8o
    dd 0
    off_4FD928 dd offset sub_48EA00         ; DATA XREF: sub_48E010+C2o
    dd offset sub_48EC20
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48ECB0
    dd offset sub_48ED00
    off_4FD940 dd offset __purecall         ; DATA XREF: sub_48E010+BBo
                                            ; sub_48E010+11Ao ...
    dd 0
    off_4FD948 dd offset sub_48EB40         ; DATA XREF: sub_48E010+7Do
                                            ; sub_48E010+980o ...
    dd offset nullsub_71
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48EB80
    dd offset sub_48EBC0
    off_4FD960 dd offset sub_48EA00         ; DATA XREF: sub_48E010+3Fo
    dd offset sub_48EA40
    dd offset nullsub_72
    dd offset nullsub_73
    dd offset sub_48EAC0
    dd offset sub_48EB00
    flt_4FD978 dd 0.0                       ; DATA XREF: sub_48ED50+1Ar
                                            ; sub_48F250+42r ...
    dd 0
    off_4FD980 dd offset sub_490630         ; DATA XREF: .text:004905F2o
                                            ; sub_4907E0+12o ...
    dd offset sub_44EF90
    dd offset sub_490690
    dd offset nullsub_64
    dd offset sub_490650
    dd offset sub_44EF80
    dd offset unknown_libname_23
    dd offset unknown_libname_22
    dd offset nullsub_66
    dd offset nullsub_67
    dd offset nullsub_68
    dd 0
    off_4FD9B0 dd offset sub_490840         ; DATA XREF: sub_4907E0+4Fo
    dd offset sub_490860
    dd offset sub_490880
    dd offset nullsub_64
    dd offset sub_490650
    dd offset sub_44EF80
    dd offset unknown_libname_23
    dd offset sub_4908B0
    dd offset sub_4908C0
    dd offset nullsub_67
    dd offset nullsub_68
    dd 0
    off_4FD9E0 dd offset sub_4909A0         ; DATA XREF: sub_490940+46o
                                            ; sub_4909A0+6o ...
    dd offset sub_44EF90
    dd offset sub_490690
    dd offset nullsub_64
    dd offset sub_490650
    dd offset sub_44EF80
    dd offset unknown_libname_23
    dd offset unknown_libname_22
    dd offset nullsub_66
    dd offset sub_490A10
    dd offset nullsub_68
    dd 0
    dbl_4FDA10 dq 1.0                       ; DATA XREF: sub_490C40+11Er
    flt_4FDA18 dd -4.1666668e-2             ; DATA XREF: sub_491200+298r
    dd 0
    dbl_4FDA20 dq 5.0e-1                    ; DATA XREF: sub_491200+29Er
    dbl_4FDA28 dq 1.0e-1                    ; DATA XREF: sub_495230+87r
    dbl_4FDA30 dq 3.703703703703704e-4      ; DATA XREF: sub_495230+111r
    dbl_4FDA38 dq 1.0e-2                    ; DATA XREF: sub_495230+117r
                                            ; sub_495230+126r
    dbl_4FDA40 dq 1.5                       ; DATA XREF: sub_497F40+7CCr
    stru_4FDA48 dd 0FFFFFFFFh                           ; _unk ; DATA XREF: sub_497C70+5o
    dd offset loc_497CAB                    ; FilterProc
    dd offset loc_497CBA                    ; ExitProc
    dd 0
    flt_4FDA58 dd 1.0                       ; DATA XREF: sub_49A120+29Er
                                            ; sub_49A120+2AEr
    dd 0
    dbl_4FDA60 dq -2.0                      ; DATA XREF: sub_49A890+78r
    dbl_4FDA68 dq 0.0                       ; DATA XREF: sub_49A890+D6r
                                            ; sub_49A890+123r ...
    dd 0, 40000000h
    dbl_4FDA78 dq 1.570796326794895         ; DATA XREF: sub_49A890+17Br
    dbl_4FDA80 dq 7.853981633974475e-1      ; DATA XREF: sub_49A890+194r
                                            ; sub_49A890+1B8r
    dbl_4FDA88 dq 3.2768e4                  ; DATA XREF: sub_49A890+1C5r
    dbl_4FDA90 dq 3.18309886183791e-1       ; DATA XREF: sub_49A890+1CBr
    dbl_4FDA98 dq 1.25                      ; DATA XREF: sub_49E070+9Dr
    aDirectxregiste db 'DirectXRegisterApplicationA',0 ; DATA XREF: sub_49EE30+581o
    dd 0
    aDsetup_dll db 'dsetup.dll',0           ; DATA XREF: sub_49EE30+570o
    dd 0
    align 4
    stru_4FDAD0 dd 0FFFFFFFFh                           ; _unk ; DATA XREF: sub_49E680+5o
    dd offset loc_49E6B7                    ; FilterProc
    dd offset loc_49E6CD                    ; ExitProc
    dd 0
    stru_4FDAE0 dd 0FFFFFFFFh                           ; _unk ; DATA XREF: WinMain(x,x,x,x)+5o
    dd offset sub_49EDFC                    ; FilterProc
    dd offset sub_49EE0B                    ; ExitProc
    dd 0
    dword_4FDAF0 dd 0                       ; DATA XREF: sub_4CA250+2Ar
    dword_4FDAF4 dd 0                       ; DATA XREF: sub_4CA250+24r
    dword_4FDAF8 dd 0                       ; DATA XREF: sub_4CA250+2Fr
    dword_4FDAFC dd 0                       ; DATA XREF: sub_4CA250+3Fr
    off_4FDB00 dd offset __purecall         ; DATA XREF: sub_4B0610+Ao
                                            ; sub_4B06B0+6o ...
    dd offset __purecall
    dd offset __purecall
    dd offset __purecall
    dd offset __purecall
    dd offset __purecall
    dd offset __purecall
    dd offset sub_4B1E50
    dd offset sub_4B1E60
    dd offset sub_4B1E70
    dd offset nullsub_74
    dd offset nullsub_75
    dd offset nullsub_76
    dd offset nullsub_77
    dd offset nullsub_78
    dd offset nullsub_79
    dd offset nullsub_80
    dd offset sub_4B0680
    dd offset sub_4B0690
    dd offset unknown_libname_48
    dd offset sub_4B06B0
    dd 0
    aSoftwareMicros db 'Software\Microsoft\DirectX',0 ; DATA XREF: sub_4B5070+D3o
    dd 0
    align 4
    aVersion_2 db 'Version',0               ; DATA XREF: sub_4B5070+133o
    aInstalledversi db 'InstalledVersion',0 ; DATA XREF: sub_4B5070+10Fo
    align 4
    a__1:                                   ; DATA XREF: sub_4B5070+1DEo
                                            ; sub_4B5070+1F7o ...
    unicode 0, <.>,0
    aDsetup_dll_0 db 'dsetup.dll',0         ; DATA XREF: sub_4B5070+Co
    dd 0
    align 4
    aDirectxsetupge db 'DirectXSetupGetVersion',0 ; DATA XREF: sub_4B5070+2Do
    align 4
    dbl_4FDBC0 dq 2.55e2                    ; DATA XREF: sub_4BA200+D3r
                                            ; sub_4BA200+101r ...
    flt_4FDBC8 dd 2.55e2                    ; DATA XREF: sub_4BA200+E2r
                                            ; sub_4BA200+110r ...
    dd 0
    dbl_4FDBD0 dq -3.333333333333333e-2     ; DATA XREF: sub_4BABD0+57r
    dbl_4FDBD8 dq 1.0                       ; DATA XREF: sub_4BABD0+63r
    dd 2 dup(0)
    dbl_4FDBE8 dq -6.875000000000001e-2     ; DATA XREF: sub_4BADF0+FFr
    aCopyright0000C db 'Copyright 0000 Cavedog Entertainment',0 ; DATA XREF: .text:004BD315o
                                            ; sub_4BDD70+CBo ...
    align 4
    dword_4FDC18 dd 0                       ; DATA XREF: sub_4C35C0+CBo
                                            ; sub_4C35C0+E6o ...
    dword_4FDC1C dd 0FFFFFFFFh              ; DATA XREF: sub_4C35C0+39r
                                            ; sub_4C3740+18r ...
    dbl_4FDC20 dq 6.5536e4                  ; DATA XREF: sub_4C4800+84r
    stru_4FDC28 dd 0FFFFFFFFh                           ; _unk ; DATA XREF: .text:004D9AB5o
    dd offset sub_4D9BFE                    ; FilterProc
    dd offset sub_4D9C15                    ; ExitProc
    dd 0
    dbl_4FDC38 dq 1.0e-1                    ; DATA XREF: sub_4E0B90+2F4r
    dbl_4FDC40 dq 0.0                       ; DATA XREF: sub_4E0B90+2FAr
    dbl_4FDC48 dq -4.294967296e9            ; DATA XREF: sub_4E1730+72r
    dbl_4FDC50 dq 1.0e-7                    ; DATA XREF: sub_4E1730+7Ar
    dbl_4FDC58 dq 1.0e2                     ; DATA XREF: sub_4E1E50+122r
                                            ; sub_4E1E50+175r
    dbl_4FDC60 dq 0.0                       ; DATA XREF: .text:004E21FFr
                                            ; .text:004E2216r
    dbl_4FDC68 dq 5.0                       ; DATA XREF: .text:004E220Cr
    dbl_4FDC70 dq 1.0                       ; DATA XREF: sub_4E3080+289r
                                            ; sub_4E3080+29Dr
    dd offset dword_4FEC20
    off_4FDC7C dd offset sub_4E3E90         ; DATA XREF: sub_4E3A90+CCo
                                            ; sub_4E3EB0+13Co
    dd offset unknown_libname_52
    dd offset sub_4E3E70
    aStringTooLong db 'string too long',0   ; DATA XREF: sub_4E3A90+24o
                                            ; sub_4E3A90+5Bo
    dword_4FDC98 dd 2 dup(0), 4FEC58h       ; DATA XREF: std::basic_string<char,std::char_traits<char>,std::allocator<char>>::assign(std::basic_string<char,std::char_traits<char>,std::allocator<char>> const &,uint,uint)+F9o
                                            ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::assign(std::basic_string<char,std::char_traits<char>,std::allocator<char>> const &,uint,uint)+13Ao ...
    off_4FDCA4 dd offset sub_4C38F0         ; DATA XREF: sub_4C35C0+ACo
                                            ; sub_4C35C0+106o ...
    dd offset unknown_libname_52
    dd offset sub_4C3740
    dd offset dword_4FECA8
    off_4FDCB4 dd offset sub_4C3C60         ; DATA XREF: sub_4C3490+C6o
                                            ; sub_4C3AF0+150o ...
    dd offset unknown_libname_52
    dd offset sub_4C3AF0
    aInvalidStringP db 'invalid string position',0 ; DATA XREF: sub_4E4010+24o
                                            ; sub_4E4010+5Bo
    dbl_4FDCD8 dq -1.0                      ; DATA XREF: _floor+7Er
    stru_4FDCE0 dd 0FFFFFFFFh                           ; _unk ; DATA XREF: _threadstartex(x)+5o
    dd offset loc_4E620D                    ; FilterProc
    dd offset loc_4E6222                    ; ExitProc
    dd 0
    stru_4FDCF0 dd 0FFFFFFFFh                           ; _unk ; DATA XREF: start+5o
    dd offset loc_4E70FD                    ; FilterProc
    dd offset loc_4E7112                    ; ExitProc
    dd 0
    stru_4FDD00 dd 0FFFFFFFFh                           ; _unk ; DATA XREF: _threadstart(x)+5o
    dd offset loc_4E78B7                    ; FilterProc
    dd offset loc_4E78CC                    ; ExitProc
    dd 0, 4FECD8h
    off_4FDD14 dd offset ??_Gexception@@UAEPAXI@Z ; DATA XREF: exception::exception(void)+4o
                                            ; exception::exception(char const * const &)+Co ...
                                            ; exception::`scalar deleting destructor'(uint)
    dd offset ?what@exception@@UBEPBDXZ     ; exception::what(void)
    aUnknownExcep_0 db 'Unknown exception',0 ; DATA XREF: exception::what(void)+7o
    align 4
    dd offset dword_4FED20
    off_4FDD34 dd offset ??_Gtype_info@@UAEPAXI@Z ; DATA XREF: type_info::~type_info(void)+5o
                                            ; .text:004E8472o ...
                                            ; type_info::`scalar deleting destructor'(uint)
    dword_4FDD38 dd 0E06D7363h, 1, 2 dup(0), 3, 19930520h, 2 dup(0)
                                            ; DATA XREF: _CxxThrowException(x,x)+Eo
    TlsDirectory dd offset TlsStart
    TlsEnd_ptr dd offset TlsEnd
    TlsIndex_ptr dd offset TlsIndex
    TlsCallbacks_ptr dd offset TlsCallbacks
    TlsSizeOfZeroFill dd 0
    TlsCharacteristics dd 0
    a_com db '.com',0                       ; DATA XREF: ___dtoxmode+95o
    align 4
    byte_4FDD78 db 2Eh                      ; DATA XREF: ___dtoxmode+83o
                                            ; __output+58r
    dd 746162h
    align 4
    a_cmd db '.cmd',0                       ; DATA XREF: ___dtoxmode+71o
    align 4
    a_exe db '.exe',0                       ; DATA XREF: ___dtoxmode+5Fo
    align 4
    a__2 db './\',0                         ; DATA XREF: __stat+71o
    a? db '?*',0                            ; DATA XREF: __stat+11o
    align 4
    byte_4FDD98 db 6                        ; DATA XREF: __output+65r
    dd 60000h, 10000001h, 60300h, 4100206h, 5454545h, 5050505h, 50003035h
    dd 0, 50382820h, 80758h, 57303037h, 750h, 82020h, 8000000h, 60606860h
    dd 6060h, 78787070h, 7087878h, 7000008h, 8080800h, 80000h, 8070008h, 28000000h
    dd 75006E00h, 6C006C00h, 2900h, 28000000h, 6C6C756Eh, 29h
    align 4
    dbl_4FDE10 dq 1.0                       ; DATA XREF: __ms_p5_test_fdiv+34r
    aIsprocessorfea db 'IsProcessorFeaturePresent',0 ; DATA XREF: __ms_p5_mp_test_fdiv+Fo
    align 4
    aKernel32 db 'KERNEL32',0               ; DATA XREF: __ms_p5_mp_test_fdivo
    align 4
    dbl_4FDE40 dq 0.0                       ; DATA XREF: .text:004EA726r
    dword_4FDE48 dd 30302B65h               ; DATA XREF: __cftoe2+59r
    word_4FDE4C dw 30h                      ; DATA XREF: __cftoe2+6Cr
    align 4
    dd 6E795Fh, 31795Fh, 30795Fh, 78657266h, 70h, 646F6D66h, 0, 7079685Fh
    dd 746Fh, 6261635Fh, 73h, 7865646Ch, 70h, 66646F6Dh, 0, 73626166h, 0, 6F6F6C66h
    dd 72h, 6C696563h, 0, 6E6174h, 736F63h, 6E6973h, 74727173h, 0, 6E617461h
    dd 32h, 6E617461h, 0, 736F6361h, 0, 6E697361h, 0, 686E6174h, 0, 68736F63h
    dd 0, 686E6973h, 0, 31676F6Ch, 30h, 676F6Ch, 776F70h, 707865h, 0
    dbl_4FDF08 dq 0.0                       ; DATA XREF: __handle_exc+98r
                                            ; __handle_exc+E9r ...
    dbl_4FDF10 dq 0.0                       ; DATA XREF: __decomp+4r __decomp+5Cr
    dd 2 dup(0)
    dbl_4FDF20 dq 1.0                       ; DATA XREF: unknown_libname_95+Dr
    dd 0C235027Fh, 0DAA22168h, 403EC90Fh
    dbl_4FDF34 dq 1.797693134862316e308     ; DATA XREF: .text:004ECB03r
    dbl_4FDF3C dq 2.225073858507201e-308    ; DATA XREF: .text:004ECADAr
    dbl_4FDF44 dq -1.536e3                  ; DATA XREF: .text:004ECAF3r
    dbl_4FDF4C dq 1.536e3                   ; DATA XREF: .text:004ECACAr
    dbl_4FDF54 dq 1.797693134862316e308     ; DATA XREF: .text:004ECB14r
    dbl_4FDF5C dq 0.0                       ; DATA XREF: .text:004ECAEBr
    dd 0
    dbl_4FDF68 dq 0.0                       ; DATA XREF: __powhlp+4r __powhlp+112r ...
    dbl_4FDF70 dq 1.0                       ; DATA XREF: __powhlp+48r __powhlp+73r ...
    dbl_4FDF78 dq 2.0                       ; DATA XREF: __d_inttype+3Cr
    stru_4FDF80 dd 0FFFFFFFFh                           ; _unk
                                            ; DATA XREF: ___FrameUnwindToState+5o
    dd offset loc_4ED2C6                    ; FilterProc
    dd offset loc_4ED2D3                    ; ExitProc
    dd 0
    stru_4FDF90 dd 0FFFFFFFFh                           ; _unk
                                            ; DATA XREF: CallCatchBlock(EHExceptionRecord *,EHRegistrationNode *,_CONTEXT *,_s_FuncInfo const *,void *,int,ulong)+5o
    dd 0                                    ; FilterProc
    dd offset sub_4ED4AF                    ; ExitProc
    dd 0, 4ED477h, 4ED484h
    stru_4FDFA8 dd 0FFFFFFFFh                           ; _unk
                                            ; DATA XREF: BuildCatchObject(EHExceptionRecord *,EHRegistrationNode *,_s_HandlerType const *,_s_CatchableType const *)+5o
    dd offset loc_4ED72B                    ; FilterProc
    dd offset loc_4ED731                    ; ExitProc
    dd 0
    stru_4FDFB8 dd 0FFFFFFFFh                           ; _unk
                                            ; DATA XREF: _DestructExceptionObject(EHExceptionRecord *,uchar)+5o
    dd offset loc_4ED7AA                    ; FilterProc
    dd offset loc_4ED7B5                    ; ExitProc
    dd 0
    stru_4FDFC8 dd 0FFFFFFFFh                           ; _unk ; DATA XREF: terminate(void)+5o
    dd 0                                    ; FilterProc
    dd offset sub_4ED8D7                    ; ExitProc
    dd 0, 4ED8AAh, 4ED8B0h
    stru_4FDFE0 dd 0FFFFFFFFh                           ; _unk ; DATA XREF: sub_4ED910+5o
    dd 0                                    ; FilterProc
    dd offset sub_4ED97E                    ; ExitProc
    dd 0, 4ED951h, 4ED957h
    aLc_time db 'LC_TIME',0                 ; DATA XREF: .data:0050E44Co
    aLc_numeric db 'LC_NUMERIC',0           ; DATA XREF: .data:0050E440o
    align 4
    aLc_monetary db 'LC_MONETARY',0         ; DATA XREF: .data:0050E434o
    aLc_ctype db 'LC_CTYPE',0               ; DATA XREF: .data:0050E428o
    align 4
    aLc_collate db 'LC_COLLATE',0           ; DATA XREF: .data:0050E41Co
    align 4
    aLc_all db 'LC_ALL',0
    align 4
    asc_4FE038 db '=;',0                    ; DATA XREF: .text:004EDA5Bo
                                            ; .text:004EDB3Bo
    align 4
    asc_4FE03C:                             ; DATA XREF: __setlocale_get_all+3Do
                                            ; __setlocale_get_all+D1o
    unicode 0, <=>,0
    ; char byte_4FE040
    byte_4FE040 db '_'                      ; DATA XREF: sub_4EE150+5Do
                                            ; sub_4EE150+DBo
    db 2Eh, 2Ch, 0
    dword_4FE044 dd 5Fh                     ; DATA XREF: ___lc_lctostr+34o
    ; const CHAR String1
    String1 db 0                            ; DATA XREF: .text:004EE308o
                                            ; sub_4EE520+3Co ...
    align 4
    ; const WCHAR SrcStr
    SrcStr dw 0                             ; DATA XREF: .text:004EE2E9o
                                            ; sub_4EE520+19o ...
    align 4
    byte_4FE050 db 53h                      ; DATA XREF: _asctime+3Fr
    aUnmontuewedthu db 'unMonTueWedThuFriSat',0
    db 0
    byte_4FE067 db 0                        ; DATA XREF: _asctime+49r
    aJanfebmaraprma db 'JanFebMarAprMayJunJulAugSepOctNovDec',0
    align 4
    aTz db 'TZ',0                           ; DATA XREF: __tzset_lk+2Eo
    align 4
    aRuntimeError db 'runtime error ',0
    align 4
    aTlossError db 'TLOSS error',0Dh,0Ah,0
    align 4
    aSingError db 'SING error',0Dh,0Ah,0
    align 4
    aDomainError db 'DOMAIN error',0Dh,0Ah,0
    align 4
    aR6028UnableToI db 'R6028',0Dh,0Ah
    db '- unable to initialize heap',0Dh,0Ah,0
    align 4
    aR6027NotEnough db 'R6027',0Dh,0Ah
    db '- not enough space for lowio initialization',0Dh,0Ah,0
    align 4
    aR6026NotEnough db 'R6026',0Dh,0Ah
    db '- not enough space for stdio initialization',0Dh,0Ah,0
    align 4
    aR6025PureVirtu db 'R6025',0Dh,0Ah
    db '- pure virtual function call',0Dh,0Ah,0
    align 4
    aR6024NotEnough db 'R6024',0Dh,0Ah
    db '- not enough space for _onexit/atexit table',0Dh,0Ah,0
    align 4
    aR6019UnableToO db 'R6019',0Dh,0Ah
    db '- unable to open console device',0Dh,0Ah,0
    align 4
    aR6018Unexpecte db 'R6018',0Dh,0Ah
    db '- unexpected heap error',0Dh,0Ah,0
    align 4
    aR6017Unexpecte db 'R6017',0Dh,0Ah
    db '- unexpected multithread lock error',0Dh,0Ah,0
    align 4
    aR6016NotEnough db 'R6016',0Dh,0Ah
    db '- not enough space for thread data',0Dh,0Ah,0
    aAbnormalProgra db 0Dh,0Ah
    db 'abnormal program termination',0Dh,0Ah,0
    align 4
    aR6009NotEnough db 'R6009',0Dh,0Ah
    db '- not enough space for environment',0Dh,0Ah,0
    aR6008NotEnough db 'R6008',0Dh,0Ah
    db '- not enough space for arguments',0Dh,0Ah,0
    align 4
    aR6002FloatingP db 'R6002',0Dh,0Ah      ; DATA XREF: .data:0050E93Co
    db '- floating point not loaded',0Dh,0Ah,0
    align 4
    aMicrosoftVisua db 'Microsoft Visual C++ Runtime Library',0 ; DATA XREF: __NMSG_WRITE+128o
    align 4
    aRuntimeErrorPr db 'Runtime Error!',0Ah ; DATA XREF: __NMSG_WRITE+D9o
    db 0Ah
    db 'Program: ',0
    align 4
    aProgramNameUnk db '<program name unknown>',0 ; DATA XREF: __NMSG_WRITE+7Ao
    align 4
    dbl_4FE378 dq -1.0                      ; DATA XREF: .text:004F5BD5r
    dbl_4FE380 dq 0.0                       ; DATA XREF: .text:004F5BF9r
                                            ; .text:004F5D70r ...
    aParaguay db 'Paraguay',0
    align 4
    aUruguay db 'Uruguay',0
    aChile db 'Chile',0
    align 4
    aEcuador db 'Ecuador',0
    aArgentina db 'Argentina',0
    align 4
    aPeru db 'Peru',0
    align 4
    aColombia db 'Colombia',0
    align 4
    aVenezuela db 'Venezuela',0
    align 4
    aDominicanRepub db 'Dominican Republic',0
    align 4
    aSouthAfrica db 'South Africa',0
    align 4
    aPanama db 'Panama',0
    align 4
    aLuxembourg db 'Luxembourg',0
    align 4
    aCostaRica db 'Costa Rica',0
    align 4
    aSwitzerland db 'Switzerland',0
    aGuatemala db 'Guatemala',0
    align 4
    aCanada db 'Canada',0
    align 4
    aSpanishModernS db 'Spanish - Modern Sort',0
    align 4
    aAustralia db 'Australia',0
    align 4
    aEnglish_0 db 'English',0
    aAustria db 'Austria',0
    aGerman db 'German',0
    align 4
    aBelgium db 'Belgium',0
    aMexico db 'Mexico',0
    align 4
    aSpanish_0 db 'Spanish',0
    aBasque db 'Basque',0
    align 4
    aSweden db 'Sweden',0
    align 4
    aSwedish db 'Swedish',0
    aIceland db 'Iceland',0
    aIcelandic db 'Icelandic',0
    align 4
    aFrance db 'France',0
    align 4
    aFrench db 'French',0
    align 4
    aFinland db 'Finland',0
    aFinnish db 'Finnish',0
    aSpain db 'Spain',0                     ; DATA XREF: .data:0051116Co
    align 4
    aSpanishTraditi db 'Spanish - Traditional Sort',0
    align 4
    aUnitedStates db 'united-states',0      ; DATA XREF: .data:00511130o
    align 4
    aUnitedKingdom db 'united-kingdom',0    ; DATA XREF: .data:00511128o
    align 4
    aTrinidadTobago db 'trinidad & tobago',0 ; DATA XREF: .data:00511118o
    align 4
    aSouthKorea db 'south-korea',0          ; DATA XREF: .data:00511110o
    aSouthAfrica_0 db 'south-africa',0      ; DATA XREF: .data:00511108o
    align 4
    aSouthKorea_0 db 'south korea',0        ; DATA XREF: .data:00511100o
    aSouthAfrica_1 db 'south africa',0      ; DATA XREF: .data:005110F8o
    align 4
    aSlovak db 'slovak',0                   ; DATA XREF: .data:005110F0o
    align 4
    aPuertoRico db 'puerto-rico',0          ; DATA XREF: .data:005110E8o
    aPrChina db 'pr-china',0                ; DATA XREF: .data:005110E0o
    align 4
    aPrChina_0 db 'pr china',0              ; DATA XREF: .data:005110D8o
    align 4
    aNz db 'nz',0                           ; DATA XREF: .data:005110D0o
    align 4
    aNewZealand db 'new-zealand',0          ; DATA XREF: .data:005110C8o
    aHongKong db 'hong-kong',0              ; DATA XREF: .data:005110C0o
    align 4
    aHolland db 'holland',0                 ; DATA XREF: .data:005110B8o
    aGreatBritain db 'great britain',0      ; DATA XREF: .data:005110B0o
    align 4
    aEngland db 'england',0                 ; DATA XREF: .data:005110A8o
    aCzech db 'czech',0                     ; DATA XREF: .data:005110A0o
    align 4
    aChina db 'china',0                     ; DATA XREF: .data:00511098o
    align 4
    aBritain db 'britain',0                 ; DATA XREF: .data:00511090o
    aAmerica db 'america',0                 ; DATA XREF: .data:00511088o
    aUsa db 'usa',0
    aUs db 'us',0                           ; DATA XREF: .data:00511138o
    align 4
    aUk db 'uk',0                           ; DATA XREF: .data:00511120o
    align 4
    aSwiss db 'swiss',0
    align 4
    aSwedishFinland db 'swedish-finland',0
    aSpanishVenezue db 'spanish-venezuela',0
    align 4
    aSpanishUruguay db 'spanish-uruguay',0
    aSpanishPuertoR db 'spanish-puerto rico',0
    aSpanishPeru db 'spanish-peru',0
    align 4
    aSpanishParagua db 'spanish-paraguay',0
    align 4
    aSpanishPanama db 'spanish-panama',0
    align 4
    aSpanishNicarag db 'spanish-nicaragua',0
    align 4
    aSpanishModern db 'spanish-modern',0
    align 4
    aSpanishMexican db 'spanish-mexican',0
    aSpanishHondura db 'spanish-honduras',0
    align 4
    aSpanishGuatema db 'spanish-guatemala',0
    align 4
    aSpanishElSalva db 'spanish-el salvador',0
    aSpanishEcuador db 'spanish-ecuador',0
    aSpanishDominic db 'spanish-dominican republic',0
    align 4
    aSpanishCostaRi db 'spanish-costa rica',0
    align 4
    aSpanishColombi db 'spanish-colombia',0
    align 4
    aSpanishChile db 'spanish-chile',0
    align 4
    aSpanishBolivia db 'spanish-bolivia',0
    aSpanishArgenti db 'spanish-argentina',0
    align 4
    aPortugueseBraz db 'portuguese-brazilian',0
    align 4
    aNorwegianNynor db 'norwegian-nynorsk',0
    align 4
    aNorwegianBokma db 'norwegian-bokmal',0
    align 4
    aNorwegian db 'norwegian',0
    align 4
    aItalianSwiss db 'italian-swiss',0
    align 4
    aIrishEnglish db 'irish-english',0
    align 4
    aGermanSwiss db 'german-swiss',0
    align 4
    aGermanLuxembou db 'german-luxembourg',0
    align 4
    aGermanLichtens db 'german-lichtenstein',0
    aGermanAustrian db 'german-austrian',0
    aFrenchSwiss db 'french-swiss',0
    align 4
    aFrenchLuxembou db 'french-luxembourg',0
    align 4
    aFrenchCanadian db 'french-canadian',0
    aFrenchBelgian db 'french-belgian',0
    align 4
    aEnglishUsa db 'english-usa',0
    aEnglishUs db 'english-us',0
    align 4
    aEnglishUk db 'english-uk',0
    align 4
    aEnglishTrinida db 'english-trinidad y tobago',0
    align 4
    aEnglishSouthAf db 'english-south africa',0
    align 4
    aEnglishNz db 'english-nz',0
    align 4
    aEnglishJamaica db 'english-jamaica',0
    aEnglishIre db 'english-ire',0
    aEnglishCaribbe db 'english-caribbean',0
    align 4
    aEnglishCan db 'english-can',0
    aEnglishBelize db 'english-belize',0
    align 4
    aEnglishAus db 'english-aus',0
    aEnglishAmerica db 'english-american',0
    align 4
    aDutchBelgian db 'dutch-belgian',0
    align 4
    aChineseTraditi db 'chinese-traditional',0
    aChineseSingapo db 'chinese-singapore',0
    align 4
    aChineseSimplif db 'chinese-simplified',0
    align 4
    aChineseHongkon db 'chinese-hongkong',0
    align 4
    aChinese db 'chinese',0
    aChi db 'chi',0
    aChh db 'chh',0
    aCanadian db 'canadian',0
    align 4
    aBelgian db 'belgian',0
    aAustralian db 'australian',0
    align 4
    aAmericanEnglis db 'american-english',0
    align 4
    aAmericanEngl_0 db 'american english',0
    align 4
    aAmerican db 'american',0               ; DATA XREF: .data:00510E80o
    align 4
    off_4FEA08 dd offset aSoundCategorie+0Fh ; DATA XREF: sub_4F7850+53o
    off_4FEA0C dd offset aSoundCategorie+1  ; DATA XREF: sub_4F7850+1Bo
    aGetlastactivep db 'GetLastActivePopup',0 ; DATA XREF: ___crtMessageBoxA+3Eo
    align 4
    aGetactivewindo db 'GetActiveWindow',0  ; DATA XREF: ___crtMessageBoxA+36o
    aMessageboxa db 'MessageBoxA',0         ; DATA XREF: ___crtMessageBoxA+25o
    aUser32_dll db 'user32.dll',0           ; DATA XREF: ___crtMessageBoxA+Eo
    align 4
    dword_4FEA4C dd 4E512331h               ; DATA XREF: _$I10_OUTPUT+141r
    word_4FEA50 dw 4E41h                    ; DATA XREF: _$I10_OUTPUT+14Cr
    byte_4FEA52 db 0                        ; DATA XREF: _$I10_OUTPUT+157r
    align 4
    dword_4FEA54 dd 4E492331h               ; DATA XREF: _$I10_OUTPUT+11Dr
    word_4FEA58 dw 46h                      ; DATA XREF: _$I10_OUTPUT+128r
    align 4
    dword_4FEA5C dd 4E492331h               ; DATA XREF: _$I10_OUTPUT+EDr
    word_4FEA60 dw 44h                      ; DATA XREF: _$I10_OUTPUT+F8r
    align 4
    dword_4FEA64 dd 4E532331h               ; DATA XREF: _$I10_OUTPUT+AEr
    word_4FEA68 dw 4E41h                    ; DATA XREF: _$I10_OUTPUT+BAr
    byte_4FEA6A db 0                        ; DATA XREF: _$I10_OUTPUT+C5r
    dd 0
    align 4
    dbl_4FEA70 dq -1.0                      ; DATA XREF: _ldexp+70r
    dbl_4FEA78 dq 0.0                       ; DATA XREF: _ldexp+A6r
    aHMmSs db 'H:mm:ss',0                   ; DATA XREF: .data:005116A8o
    aDdddMmmmDdYyyy db 'dddd, MMMM dd, yyyy',0 ; DATA XREF: .data:005116A4o
    aMDYy db 'M/d/yy',0                     ; DATA XREF: .data:005116A0o
    align 4
    aPm db 'PM',0                           ; DATA XREF: .data:0051169Co
    align 4
    aAm db 'AM',0                           ; DATA XREF: .data:00511698o
    align 4
    aDecember db 'December',0               ; DATA XREF: .data:00511694o
    align 4
    aNovember db 'November',0               ; DATA XREF: .data:00511690o
    align 4
    aOctober db 'October',0                 ; DATA XREF: .data:0051168Co
    aSeptember db 'September',0             ; DATA XREF: .data:00511688o
    align 4
    aAugust db 'August',0                   ; DATA XREF: .data:00511684o
    align 4
    aJuly db 'July',0                       ; DATA XREF: .data:00511680o
    align 4
    aJune db 'June',0                       ; DATA XREF: .data:0051167Co
    align 4
    aApril db 'April',0                     ; DATA XREF: .data:00511674o
    align 4
    aMarch db 'March',0                     ; DATA XREF: .data:00511670o
    align 4
    aFebruary db 'February',0               ; DATA XREF: .data:0051166Co
    align 4
    aJanuary db 'January',0                 ; DATA XREF: .data:00511668o
    aDec db 'Dec',0                         ; DATA XREF: .data:00511664o
    aNov db 'Nov',0                         ; DATA XREF: .data:00511660o
    aOct db 'Oct',0                         ; DATA XREF: .data:0051165Co
    aSep db 'Sep',0                         ; DATA XREF: .data:00511658o
    aAug db 'Aug',0                         ; DATA XREF: .data:00511654o
    aJul db 'Jul',0                         ; DATA XREF: .data:00511650o
    aJun db 'Jun',0                         ; DATA XREF: .data:0051164Co
    aMay db 'May',0                         ; DATA XREF: .data:00511648o
                                            ; .data:00511678o
    aApr db 'Apr',0                         ; DATA XREF: .data:00511644o
    aMar db 'Mar',0                         ; DATA XREF: .data:00511640o
    aFeb db 'Feb',0                         ; DATA XREF: .data:0051163Co
    aJan db 'Jan',0                         ; DATA XREF: .data:00511638o
    aSaturday db 'Saturday',0               ; DATA XREF: .data:00511634o
    align 4
    aFriday db 'Friday',0                   ; DATA XREF: .data:00511630o
    align 4
    aThursday db 'Thursday',0               ; DATA XREF: .data:0051162Co
    align 4
    aWednesday db 'Wednesday',0             ; DATA XREF: .data:00511628o
    align 4
    aTuesday db 'Tuesday',0                 ; DATA XREF: .data:00511624o
    aMonday db 'Monday',0                   ; DATA XREF: .data:00511620o
    align 4
    aSunday db 'Sunday',0                   ; DATA XREF: .data:0051161Co
    align 4
    aSat db 'Sat',0                         ; DATA XREF: .data:00511618o
    aFri db 'Fri',0                         ; DATA XREF: .data:00511614o
    aThu db 'Thu',0                         ; DATA XREF: .data:00511610o
    aWed db 'Wed',0                         ; DATA XREF: .data:0051160Co
    aTue db 'Tue',0                         ; DATA XREF: .data:00511608o
    aMon db 'Mon',0                         ; DATA XREF: .data:00511604o
    aSun db 'Sun',0                         ; DATA XREF: .data:00511600o
    ; char byte_4FEBA4
    byte_4FEBA4 db 'a'                      ; DATA XREF: __store_winword+215o
    db 2Fh, 70h, 0
    aAmPm db 'am/pm',0                      ; DATA XREF: __store_winword+1F1o
    align 4
    dbl_4FEBB0 dq 0.0                       ; DATA XREF: __hypothlp+4Fr
                                            ; __hypothlp+6Ar ...
    dd offset off_50A618
    dd 2 dup(0), 0FFFFFFFFh, 2 dup(0), 50A630h, 1, 0, 0FFFFFFFFh, 2 dup(0)
    dd 50DE90h, 2, 0, 0FFFFFFFFh, 2 dup(0), 4FEBE8h, 4FEBD0h, 4FEBB8h, 3 dup(0)
    dd 3, 4FEC00h
    dword_4FEC20 dd 3 dup(0), 50DE90h, 4FEC10h, 0, 4FEBD0h, 4FEBB8h, 4 dup(0), 2, 4FEC38h
                                            ; DATA XREF: .rdata:004FDC78o
    dd 3 dup(0), 50A630h, 4FEC48h, 0, 50A650h, 2, 0, 0FFFFFFFFh, 2 dup(0)
    dd 4FEC70h, 4FEBD0h, 4FEBB8h, 3 dup(0), 3, 4FEC88h
    dword_4FECA8 dd 3 dup(0), 50A650h, 4FEC98h, 4FEBB8h, 4 dup(0), 1, 4FECBCh, 3 dup(0)
                                            ; DATA XREF: .rdata:004FDCB0o
    dd 50A618h, 4FECC8h, 0, 50DF18h, 2 dup(0), 0FFFFFFFFh, 2 dup(0), 4FECF0h
    dd 3 dup(0), 1, 4FED08h
    dword_4FED20 dd 3 dup(0), 50DF18h, 4FED10h, 0 ; DATA XREF: .rdata:004FDD30o
    stru_4FED38 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB860o
    dd 2                                    ; Count
    dd offset stru_4FED38.Info              ; InfoPtr
    dd 1                                    ; CountDtr
    dd offset stru_4FED68                   ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    stru_4FED68 dd 0, 0, 1                              ; _unk ; DATA XREF: .rdata:004FED38o
    dd 1                                    ; Count
    dd offset stru_4FED80                   ; RttiBlkPtr
    dd 0
    stru_4FED80 dd 0                                    ; _unk ; DATA XREF: .rdata:004FED68o
    dd 0                                    ; RttiPtr
    dd 0                                    ; spoff
    dd offset loc_444359                    ; Dtr
    stru_4FED90 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB870o
    dd 2                                    ; Count
    dd offset stru_4FED90.Info              ; InfoPtr
    dd 1                                    ; CountDtr
    dd offset stru_4FEDC0                   ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    stru_4FEDC0 dd 0, 0, 1                              ; _unk ; DATA XREF: .rdata:004FED90o
    dd 1                                    ; Count
    dd offset stru_4FEDD8                   ; RttiBlkPtr
    dd 0
    stru_4FEDD8 dd 0                                    ; _unk ; DATA XREF: .rdata:004FEDC0o
    dd 0                                    ; RttiPtr
    dd 0                                    ; spoff
    dd offset sub_44474E                    ; Dtr
    stru_4FEDE8 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB880o
    dd 2                                    ; Count
    dd offset stru_4FEDE8.Info              ; InfoPtr
    dd 1                                    ; CountDtr
    dd offset stru_4FEE18                   ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    stru_4FEE18 dd 0, 0, 1                              ; _unk ; DATA XREF: .rdata:004FEDE8o
    dd 1                                    ; Count
    dd offset stru_4FEE30                   ; RttiBlkPtr
    dd 0
    stru_4FEE30 dd 0                                    ; _unk ; DATA XREF: .rdata:004FEE18o
    dd 0                                    ; RttiPtr
    dd 0                                    ; spoff
    dd offset sub_45B44C                    ; Dtr
    stru_4FEE40 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB890o
    dd 2                                    ; Count
    dd offset stru_4FEE40.Info              ; InfoPtr
    dd 1                                    ; CountDtr
    dd offset stru_4FEE70                   ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    stru_4FEE70 dd 0, 0, 1                              ; _unk ; DATA XREF: .rdata:004FEE40o
    dd 1                                    ; Count
    dd offset stru_4FEE88                   ; RttiBlkPtr
    dd 0
    stru_4FEE88 dd 0                                    ; _unk ; DATA XREF: .rdata:004FEE70o
    dd 0                                    ; RttiPtr
    dd 0                                    ; spoff
    dd offset sub_45B624                    ; Dtr
    stru_4FEE98 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB8A0o
    dd 2                                    ; Count
    dd offset stru_4FEE98.Info              ; InfoPtr
    dd 1                                    ; CountDtr
    dd offset stru_4FEEC8                   ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    stru_4FEEC8 dd 0, 0, 1                              ; _unk ; DATA XREF: .rdata:004FEE98o
    dd 1                                    ; Count
    dd offset stru_4FEEE0                   ; RttiBlkPtr
    dd 0
    stru_4FEEE0 dd 0                                    ; _unk ; DATA XREF: .rdata:004FEEC8o
    dd 0                                    ; RttiPtr
    dd 0                                    ; spoff
    dd offset sub_45B7EB                    ; Dtr
    stru_4FEEF0 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB8B0o
    dd 2                                    ; Count
    dd offset stru_4FEEF0.Info              ; InfoPtr
    dd 1                                    ; CountDtr
    dd offset stru_4FEF20                   ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    stru_4FEF20 dd 0, 0, 1                              ; _unk ; DATA XREF: .rdata:004FEEF0o
    dd 1                                    ; Count
    dd offset stru_4FEF38                   ; RttiBlkPtr
    dd 0
    stru_4FEF38 dd 0                                    ; _unk ; DATA XREF: .rdata:004FEF20o
    dd 0                                    ; RttiPtr
    dd 0                                    ; spoff
    dd offset loc_49F0A0                    ; Dtr
    dd 0, 50A618h, 0, 0FFFFFFFFh, 0, 0Ch, 4E8230h, 2 dup(0), 50A630h, 0, 0FFFFFFFFh
    dd 0, 1Ch, 4C3950h, 2 dup(0), 50A650h, 0, 0FFFFFFFFh, 0, 1Ch, 4C3CC0h
    dd 0, 3, 4FEF88h, 4FEF68h, 4FEF48h
    dword_4FEFB8 dd 0, 4C3AA0h, 0, 4FEFA8h, 2, 4FEF68h, 4FEF48h, 0 ; DATA XREF: sub_4C3490+C0o
                                            ; sub_4C3AF0+14Ao ...
    dword_4FEFD8 dd 0, 4C38A0h, 0, 4FEFC8h  ; DATA XREF: sub_4C3740+142o
    stru_4FEFE8 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB8C0o
    dd 2                                    ; Count
    dd offset stru_4FEFE8.Info              ; InfoPtr
    dd 1                                    ; CountDtr
    dd offset stru_4FF018                   ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    dd -1                                   ; Info.Id
    dd 0                                    ; Info.Proc
    stru_4FF018 dd 0, 0, 1                              ; _unk ; DATA XREF: .rdata:004FEFE8o
    dd 1                                    ; Count
    dd offset stru_4FF030                   ; RttiBlkPtr
    dd 0
    stru_4FF030 dd 0                                    ; _unk ; DATA XREF: .rdata:004FF018o
    dd 0                                    ; RttiPtr
    dd 0                                    ; spoff
    dd offset loc_4C5000                    ; Dtr
    dd 0, 50DE90h, 0, 0FFFFFFFFh, 0, 1Ch, 4E3EB0h, 0, 3, 4FF040h, 4FEF68h
    dd 4FEF48h
    dword_4FF070 dd 0, 4E3E20h, 0, 4FF060h  ; DATA XREF: sub_4E3A90+C2o
                                            ; sub_4E3E70+11o
    stru_4FF080 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB8E0o
    dd 2                                    ; Count
    dd offset stru_4FF080.Info              ; InfoPtr
    dd 0                                    ; CountDtr
    dd 0                                    ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd offset unknown_libname_131           ; Info.Proc
    dd 0                                    ; Info.Id
    dd offset sub_4FB8D8                    ; Info.Proc
    stru_4FF0B0 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB8F8o
    dd 1                                    ; Count
    dd offset stru_4FF0B0.Info              ; InfoPtr
    dd 0                                    ; CountDtr
    dd 0                                    ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd offset sub_4FB8F0                    ; Info.Proc
    stru_4FF0D8 dd 19930520h                            ; Magic ; DATA XREF: .text:004FB920o
    dd 2                                    ; Count
    dd offset stru_4FF0D8.Info              ; InfoPtr
    dd 0                                    ; CountDtr
    dd 0                                    ; DtrPtr
    dd 3 dup(0)                             ; _unk
    dd -1                                   ; Info.Id
    dd offset unknown_libname_132           ; Info.Proc
    dd 0                                    ; Info.Id
    dd offset sub_4FB918                    ; Info.Proc
    dd 0FF210h, 2 dup(0), 0FF618h, 0FC02Ch, 0FF59Ch, 2 dup(0), 0FF642h, 0FC3B8h
    dd 0FF278h, 2 dup(0), 0FF824h, 0FC094h, 0FF4A0h, 2 dup(0), 0FF92Ch, 0FC2BCh
    dd 0FF230h, 2 dup(0), 0FF95Ch, 0FC04Ch, 0FF1E4h, 2 dup(0), 0FF9C8h, 0FC000h
    dd 0FF5C4h, 2 dup(0), 0FF9D6h, 0FC3E0h, 0FF218h, 2 dup(0), 0FF9E4h, 0FC034h
    dd 0FF228h, 2 dup(0), 0FFA04h, 0FC044h, 0FF498h, 2 dup(0), 100680h, 0FC2B4h
    dd 5 dup(0), 0FF9B8h, 0FF9A4h, 100660h, 100652h, 100640h, 10062Eh, 0FF992h
    dd 0FF984h, 0FF976h, 0FF966h, 0, 0FF604h, 0, 80000002h, 80000001h, 80000004h
    dd 0, 0FF9F0h, 0, 1005D0h, 1005A6h, 1005ECh, 1005E0h, 100600h, 10053Ah
    dd 0FF938h, 10055Ch, 10056Ch, 10054Ch, 100610h, 100596h, 0FF952h, 100624h
    dd 1005B2h, 100580h, 1005C4h, 0, 0FF72Ah, 0FF6DCh, 0FF6CEh, 0FF80Ch, 0FF7D4h
    dd 0FF74Ch, 0FF7FAh, 0FF7E6h, 0FF798h, 0FF7C8h, 0FF7AEh, 0FF762h, 0FF6B2h
    dd 0FF714h, 0FF784h, 0FF770h, 0FF73Ch, 0FF69Ah, 0FF68Ah, 0FF682h, 0FF674h
    dd 0FF666h, 0FF658h, 0FF64Ch, 0FF708h, 0FF6FCh, 0FF6ECh, 0FFDB4h, 0FFFDEh
    dd 0FFFD0h, 0FFCD8h, 100222h, 100210h, 1001FEh, 1001E8h, 1001D2h, 1001C0h
    dd 1001AEh, 10019Eh, 10018Eh, 10017Eh, 10016Eh, 10015Ah, 100148h, 100136h
    dd 100126h, 100118h, 10010Ah, 1000FCh, 1000ECh, 1000DAh, 1000C0h, 0FFA8Eh
    dd 0FFA9Ch, 0FFAAAh, 0FFABAh, 0FFAC6h, 0FFADCh, 0FFAECh, 0FFB04h, 0FFB18h
    dd 0FFB28h, 0FFB36h, 0FFB4Ch, 0FFB62h, 0FFB7Ah, 0FFB92h, 0FFBA4h, 0FFBB4h
    dd 0FFBC6h, 0FFBD6h, 0FFBF4h, 0FFC08h, 0FFC16h, 0FFC32h, 0FFC42h, 0FFC50h
    dd 0FFC64h, 0FFC78h, 0FFC88h, 0FFC98h, 0FFCB0h, 0FFCCAh, 100074h, 0FFCE6h
    dd 0FFCFEh, 0FFD0Eh, 0FFD24h, 0FFD36h, 0FFD4Eh, 0FFD5Eh, 0FFD7Ah, 0FFD8Eh
    dd 0FFDA2h, 1000A8h, 0FFDC2h, 0FFDD6h, 0FFDE2h, 0FFDFAh, 0FFE12h, 0FFE20h
    dd 0FFE2Eh, 0FFE48h, 0FFE58h, 0FFE70h, 0FFE82h, 0FFE90h, 0FFEA0h, 0FFEB0h
    dd 0FFEBCh, 0FFECAh, 0FFEE2h, 0FFEFCh, 0FFF0Eh, 0FFF1Eh, 0FFF2Ah, 0FFF42h
    dd 0FFF56h, 0FFF68h, 0FFF74h, 0FFF80h, 0FFF8Ch, 0FFF9Ah, 0FFFAAh, 0FFFB6h
    dd 0FFFC0h, 10002Ah, 10008Eh, 0FFFF4h, 10000Ah, 10001Ah, 100036h, 100052h
    dd 10005Eh, 100068h, 0, 100670h, 0, 100386h, 0FF91Eh, 100396h, 1003A4h
    dd 100312h, 100324h, 0FF900h, 0FF910h, 10052Eh, 0FF832h, 0FF83Eh, 0FF84Eh
    dd 0FF85Ah, 0FF868h, 0FF878h, 0FF884h, 0FF88Ch, 0FF89Eh, 0FF8ACh, 0FF8B8h
    dd 0FF8C6h, 0FF8D8h, 100234h, 100246h, 10025Ah, 10026Ah, 10027Ah, 10028Eh
    dd 10029Eh, 1002AEh, 1002BCh, 1002CEh, 1002E0h, 1002EEh, 1002FAh, 10050Ch
    dd 100522h, 100334h, 100348h, 100358h, 100366h, 100376h, 0FF8ECh, 100450h
    dd 10045Ch, 1003B8h, 1003C4h, 1003DEh, 1003FCh, 100410h, 10041Ch, 10042Eh
    dd 10043Ah, 1004A2h, 1004B4h, 10046Ch, 10047Eh, 100490h, 1004E6h, 1004C2h
    dd 1004D4h, 1004FCh, 0, 0FFA56h, 0FFA7Eh, 0FFA10h, 0FFA20h, 0FFA34h, 0FFA46h
    dd 0FFA6Ah, 0FF634h, 0FF622h, 0, 80000015h, 80000013h, 80000017h, 80000014h
    dd 8000001Bh, 8000001Ch, 80000012h, 8000000Fh, 80000026h, 8000000Eh, 80000011h
    dd 80000020h, 80000002h, 80000005h, 80000019h, 0, 69440005h, 74636572h
    dd 77617244h, 61657243h, 6574h, 41524444h, 6C642E57h, 34006Ch, 5369636Dh
    dd 53646E65h, 6E697274h, 4167h, 6C50000Bh, 6F537961h, 41646E75h, 49570000h
    dd 2E4D4D4Eh, 6C6C64h, 736C029Eh, 70637274h, 416E79h, 6C430018h, 4865736Fh
    dd 6C646E61h, 310065h, 61657243h, 69466574h, 41656Ch, 65440048h, 42677562h
    dd 6B616572h, 23F0000h, 65656C53h, 1450070h, 54746547h, 436B6369h, 746E756Fh
    dd 10C0000h, 50746547h, 61766972h, 72506574h, 6C69666Fh, 746E4965h, 1120041h
    dd 50746547h, 61766972h, 72506574h, 6C69666Fh, 72745365h, 41676E69h, 15C0000h
    dd 626F6C47h, 72466C61h, 6565h, 6C470166h, 6C61626Fh, 6F6C6E55h, 6B63h
    dd 6C47015Fh, 6C61626Fh, 646E6148h, 656Ch, 736C02A1h, 656C7274h, 416Eh
    dd 736C029Bh, 70637274h, 4179h, 6157026Ah, 6F467469h, 6E695372h, 4F656C67h
    dd 63656A62h, 1160074h, 50746547h, 41636F72h, 65726464h, 7373h, 6F4C0190h
    dd 694C6461h, 72617262h, 4179h, 654700FCh, 646F4D74h, 46656C75h, 4E656C69h
    dd 41656D61h, 980000h, 65657246h, 7262694Ch, 797261h, 65530233h, 72685474h
    dd 50646165h, 726F6972h, 797469h, 654700D5h, 72754374h, 746E6572h, 65726854h
    dd 6461h, 6C470161h, 6C61626Fh, 6F6D654Dh, 74537972h, 73757461h, 1C50000h
    dd 72657551h, 72655079h, 6D726F66h, 65636E61h, 6E756F43h, 726574h, 7257027Bh
    dd 46657469h, 656C69h, 65530219h, 6C694674h, 696F5065h, 7265746Eh, 400000h
    dd 61657243h, 65536574h, 6870616Dh, 4165726Fh, 1B60000h, 6E65704Fh, 616D6553h
    dd 726F6870h, 4165h, 6553020Ch, 72754374h, 746E6572h, 65726944h, 726F7463h
    dd 4179h, 4E52454Bh, 32334C45h, 6C6C642Eh, 0F80000h, 46746547h, 7375636Fh
    dd 0ED0000h, 43746547h, 6F737275h, 736F5072h, 2640000h, 72707377h, 66746E69h
    dd 1010041h, 4B746547h, 74537965h, 657461h, 6553021Eh, 6E695774h, 50776F64h
    dd 736Fh, 655201CDh, 7361656Ch, 434465h, 654700EEh, 434474h, 6C430036h
    dd 746E6569h, 63536F54h, 6E656572h, 1950000h, 7373654Dh, 42656761h, 41786Fh
    dd 6E4500B6h, 69615064h, 746Eh, 65420009h, 506E6967h, 746E6961h, 1B30000h
    dd 74736F50h, 74697551h, 7373654Dh, 656761h, 69440090h, 74617073h, 654D6863h
    dd 67617373h, 4165h, 72540245h, 6C736E61h, 4D657461h, 61737365h, 6567h
    dd 655001AFh, 654D6B65h, 67617373h, 4165h, 65470115h, 73654D74h, 65676173h
    dd 1940041h
    dd 7373654Dh, 42656761h, 706565h, 52455355h, 642E3233h, 6C6Ch, 654700FCh
    dd 73795374h, 506D6574h, 74656C61h, 6E456574h, 65697274h, 1220073h, 42746150h
    dd 746Ch, 33494447h, 6C642E32h, 9F006Ch, 55746547h, 4E726573h, 41656D61h
    dd 1170000h, 43676552h, 65736F6Ch, 79654Bh, 65520128h, 756C4667h, 654B6873h
    dd 1410079h, 53676552h, 61567465h, 4565756Ch, 4178h, 65520136h, 65755167h
    dd 61567972h, 4565756Ch, 4178h, 6552012Eh, 65704F67h, 79654B6Eh, 417845h
    dd 41564441h, 32334950h, 6C6C642Eh, 6D730000h, 776B6361h, 442E3233h, 4C4Ch
    dd 414C5044h, 642E5859h, 6C6Ch, 69440003h, 74636572h, 6E756F53h, 65724364h
    dd 657461h, 554F5344h, 642E444Eh, 6C6Ch, 75610015h, 74654778h, 756C6F56h
    dd 656Dh, 617700B5h, 754F6576h, 74654774h, 756C6F56h, 656Dh, 75610012h
    dd 74654778h, 43766544h, 41737061h, 140000h, 47787561h, 754E7465h, 7665446Dh
    dd 0B10073h, 65766177h, 4774754Fh, 754E7465h, 7665446Dh, 0BE0073h, 65766177h
    dd 5374754Fh, 6F567465h, 656D756Ch, 170000h, 53787561h, 6F567465h, 656D756Ch
    dd 1600000h, 626F6C47h, 6F4C6C61h, 6B63h, 6C470163h, 6C61626Fh, 657A6953h
    dd 14D0000h, 56746547h, 69737265h, 78456E6Fh, 2140041h, 45746553h, 746E6576h
    dd 17C0000h, 65746E49h, 636F6C72h, 4564656Bh, 61686378h, 65676Eh, 654700DFh
    dd 69724474h, 79546576h, 416570h, 6547014Fh, 6C6F5674h, 49656D75h, 726F666Eh
    dd 6974616Dh, 416E6Fh, 654700F0h, 6C754674h, 7461506Ch, 6D614E68h, 4165h
    dd 7243002Eh, 65746165h, 6E657645h, 4174h, 655201E1h, 45746573h, 746E6576h
    dd 1BA0000h, 7074754Fh, 65447475h, 53677562h, 6E697274h, 4167h, 654700D6h
    dd 72754374h, 746E6572h, 65726854h, 64496461h, 18F0000h, 7661654Ch, 69724365h
    dd 61636974h, 6365536Ch, 6E6F6974h, 580000h, 65746E45h, 69724372h, 61636974h
    dd 6365536Ch, 6E6F6974h, 2610000h, 74726956h, 506C6175h, 65746F72h, 7463h
    dd 69560263h, 61757472h, 6575516Ch, 7972h, 654700AAh, 6D6F4374h, 646E616Dh
    dd 656E694Ch, 430041h, 61657243h, 68546574h, 64616572h, 2360000h, 55746553h
    dd 6E61686Eh, 64656C64h, 65637845h, 6F697470h, 6C69466Eh, 726574h, 65470141h
    dd 72685474h, 50646165h, 726F6972h, 797469h, 6C470155h, 6C61626Fh, 6F6C6C41h
    dd 1790063h, 74696E49h, 696C6169h, 7243657Ah, 63697469h, 65536C61h, 6F697463h
    dd 25B006Eh, 74726956h, 416C6175h, 636F6C6Ch, 25E0000h, 74726956h, 466C6175h
    dd 656572h, 654700FEh, 646F4D74h, 48656C75h, 6C646E61h, 4165h, 654700D3h
    dd 72754374h, 746E6572h, 636F7250h, 737365h, 654700F4h, 73614C74h, 72724574h
    dd 726Fh, 65470133h, 73795374h, 496D6574h, 6F666Eh, 69460076h, 6954656Ch
    dd 6F54656Dh, 44736F44h, 54657461h, 656D69h, 69460077h, 6954656Ch, 6F54656Dh
    dd 61636F4Ch, 6C69466Ch, 6D695465h, 0EE0065h, 46746547h, 54656C69h, 656D69h
    dd 654700EDh, 6C694674h, 7A695365h, 4C0065h, 656C6544h, 72436574h, 63697469h
    dd 65536C61h, 6F697463h, 1A4006Eh, 5670614Dh, 4F776569h, 6C694666h, 320065h
    dd 61657243h, 69466574h, 614D656Ch, 6E697070h, 4167h, 6E550253h, 5670616Dh
    dd 4F776569h, 6C694666h, 2440065h, 74737953h, 69546D65h, 6F54656Dh, 656C6946h
    dd 656D6954h, 1350000h, 53746547h, 65747379h, 6D69546Dh, 1C60065h, 72657551h
    dd 72655079h, 6D726F66h, 65636E61h, 71657246h, 636E6575h, 2240079h, 50746553h
    dd 726F6972h, 43797469h, 7373616Ch, 10B0000h, 50746547h, 726F6972h, 43797469h
    dd 7373616Ch, 500000h, 69766544h, 6F496563h, 746E6F43h, 6C6F72h, 7845006Bh
    dd 72507469h, 7365636Fh, 2460073h, 6D726554h, 74616E69h, 6F725065h, 73736563h
    dd 1E50000h, 556C7452h, 6E69776Eh, 17B0064h, 65746E49h, 636F6C72h, 4464656Bh
    dd 65726365h, 746E656Dh, 17E0000h, 65746E49h, 636F6C72h, 4964656Bh, 6572636Eh
    dd 746E656Dh, 24B0000h, 53736C54h, 61567465h, 65756Ch, 7845006Ch, 68547469h
    dd 64616572h, 1480000h, 54746547h, 5A656D69h, 49656E6Fh, 726F666Eh, 6974616Dh
    dd 6E6Fh, 654700F5h, 636F4C74h, 69546C61h, 656Dh, 655301F5h, 6E6F4374h
    dd 656C6F73h, 6C727443h, 646E6148h, 72656Ch, 65470128h, 61745374h, 70757472h
    dd 6F666E49h, 14C0041h, 56746547h, 69737265h, 6E6Fh, 65530210h, 646E4574h
    dd 6946664Fh, 656Ch, 655201E2h, 656D7573h, 65726854h, 6461h, 6F4D01A6h
    dd 69466576h, 41656Ch, 6544004Eh, 6574656Ch, 656C6946h, 0D10041h, 43746547h
    dd 65727275h, 6944746Eh, 74636572h, 4179726Fh, 2110000h, 45746553h, 7269766Eh
    dd 656D6E6Fh, 6156746Eh, 62616972h, 41656Ch, 69460082h, 6946646Eh, 46747372h
    dd 41656C69h, 870000h, 646E6946h, 7478654Eh, 656C6946h, 7E0041h, 646E6946h
    dd 736F6C43h, 780065h, 656C6946h, 656D6954h, 79536F54h, 6D657473h, 656D6954h
    dd 2A0000h, 61657243h, 69446574h, 74636572h, 4179726Fh, 1C90000h, 73696152h
    dd 63784565h, 69747065h, 6E6Fh, 6548016Eh, 72467061h, 6565h, 65480168h
    dd 6C417061h, 636F6Ch, 65480172h, 69537061h, 657Ah, 65480171h, 65527061h
    dd 6F6C6C41h, 730063h, 61746146h, 7070416Ch, 74697845h, 2480041h, 41736C54h
    dd 636F6C6Ch, 2490000h, 46736C54h, 656572h, 6553021Eh, 73614C74h, 72724574h
    dd 726Fh, 6C54024Ah, 74654773h, 756C6156h, 1AB0065h, 746C754Dh, 74794269h
    dd 576F5465h, 43656469h, 726168h, 6957026Eh, 68436564h, 6F547261h
    aMultibyte db 'MultiByte',0             ; DATA XREF: sub_42BF40+CD3o
                                            ; sub_43CD20+94o
    dd 434C018Dh, 5370614Dh, 6E697274h, 4167h, 434C018Eh, 5370614Dh, 6E697274h
    dd 5767h, 655201D6h, 69466461h, 656Ch, 6E550250h, 646E6168h, 4564656Ch
    dd 70656378h, 6E6F6974h, 746C6946h, 7265h, 654700A3h, 49504374h, 6F666Eh
    dd 6547009Dh, 50434174h, 1090000h, 4F746547h, 50434D45h, 960000h, 65657246h
    dd 69766E45h, 6D6E6F72h, 53746E65h, 6E697274h, 417367h, 72460097h, 6E456565h
    dd 6F726976h, 6E656D6Eh, 72745374h, 73676E69h, 0E10057h, 45746547h, 7269766Eh
    dd 656D6E6Fh, 7453746Eh, 676E6972h, 0E30073h, 45746547h, 7269766Eh, 656D6E6Fh
    dd 7453746Eh, 676E6972h, 5773h, 6553021Bh, 6E614874h, 43656C64h, 746E756Fh
    dd 12A0000h, 53746547h, 61486474h, 656C646Eh, 0EF0000h, 46746547h, 54656C69h
    dd 657079h, 6548016Ch, 65447061h, 6F727473h, 16A0079h, 70616548h, 61657243h
    dd 6574h, 65530229h, 64745374h, 646E6148h, 656Ch, 6547012Bh, 72745374h
    dd 54676E69h, 41657079h, 12E0000h, 53746547h, 6E697274h, 70795467h, 5765h
    dd 6C46008Eh, 46687375h, 42656C69h, 65666675h, 7372h, 73490183h, 52646142h
    dd 50646165h, 7274h, 73490186h, 57646142h, 65746972h, 727450h, 73490180h
    dd 43646142h, 5065646Fh, 7274h, 7349018Ch, 696C6156h, 636F4C64h, 656C61h
    dd 7349018Bh, 696C6156h, 646F4364h, 67615065h, 0F60065h, 4C746547h, 6C61636Fh
    dd 666E4965h, 416Fh, 6E450065h, 79536D75h, 6D657473h, 61636F4Ch, 4173656Ch
    dd 1490000h, 55746547h, 44726573h, 75616665h, 434C746Ch, 4449h, 6F43001Eh
    dd 7261706Dh, 72745365h, 41676E69h, 1F0000h, 706D6F43h, 53657261h, 6E697274h
    dd 5767h, 654700F7h, 636F4C74h, 49656C61h, 576F666Eh, 380000h, 736F6C43h
    dd 696C4365h, 616F6270h, 6472h, 654700E6h, 696C4374h, 616F6270h, 61446472h
    dd 6174h, 704F01A6h, 6C436E65h, 6F627069h, 647261h, 73490155h, 72616843h
    dd 68706C41h, 4161h, 6547012Ch, 73795374h, 4D6D6574h, 69727465h, 7363h
    dd 6544008Ah, 6F727473h, 6E695779h, 776F64h, 70550251h, 65746164h, 646E6957h
    dd 776Fh, 6853022Dh, 6957776Fh, 776F646Eh, 550000h, 61657243h, 69576574h
    dd 776F646Eh, 417845h, 655201BEh, 74736967h, 6C437265h, 41737361h, 1720000h
    dd 64616F4Ch, 73727543h, 41726Fh, 6F4C0176h, 63496461h, 416E6Fh, 79530234h
    dd 6D657473h, 61726150h, 6574656Dh, 6E497372h, 416F66h, 65440080h, 6E695766h
    dd 50776F64h, 41636F72h, 1B10000h, 74736F50h, 7373654Dh, 41656761h, 0D70000h
    dd 41746547h, 636E7973h, 5379654Bh, 65746174h, 1EE0000h, 43746553h, 6F737275h
    dd 736F5072h, 1A50000h, 7366664Fh, 65527465h, 7463h, 654700E4h, 696C4374h
    dd 52746E65h, 746365h, 655301DAh, 654D646Eh, 67617373h, 4165h, 654700E1h
    dd 616C4374h, 614E7373h, 41656Dh, 6E4500C8h, 69576D75h, 776F646Eh, 1600073h
    dd 69447349h, 676F6C61h, 7373654Dh, 41656761h, 11D0000h, 50746547h, 6E657261h
    dd 8B0074h, 6C616944h, 6F42676Fh, 646E4978h, 63657269h, 72615074h, 416D61h
    dd 72430048h, 65746165h, 6C616944h, 6E49676Fh, 65726964h, 61507463h, 416D6172h
    dd 0F00000h, 44746547h, 746B7365h, 6957706Fh, 776F646Eh, 16D0000h, 6C6C694Bh
    dd 656D6954h, 16A0072h, 69577349h, 776F646Eh, 69736956h, 656C62h, 65530216h
    dd 6D695474h, 7265h, 655301F6h, 726F4674h, 6F726765h, 57646E75h, 6F646E69h
    dd 1F50077h, 46746553h, 7375636Fh, 0B20000h, 62616E45h, 6957656Ch, 776F646Eh
    dd 13A0000h, 57746547h, 6F646E69h, 6E6F4C77h, 4167h, 6553021Bh, 6E695774h
    dd 4C776F64h, 41676E6Fh, 1F20000h, 44746553h, 7449676Ch, 65546D65h, 417478h
    dd 654700F5h, 676C4474h, 6D657449h, 74786554h, 0F30041h, 44746547h, 7449676Ch
    dd 6D65h, 6843002Fh, 446B6365h, 7542676Ch, 6E6F7474h, 1C40000h, 69676552h
    dd 72657473h, 4B746F48h, 7965h, 655301D8h, 6C44646Eh, 65744967h, 73654D6Dh
    dd 65676173h, 13D0041h, 57746547h, 6F646E69h, 63655277h, 13C0074h, 57746547h
    dd 6F646E69h, 616C5077h, 656D6563h, 746Eh, 7349016Bh, 6D6F6F5Ah, 6465h
    dd 73490164h, 6E6F6349h, 6369h, 65520137h, 7A696C61h, 6C615065h, 65747465h
    dd 14B0000h, 656C6553h, 61507463h, 7474656Ch, 14A0065h, 656C6553h, 624F7463h
    dd 7463656Ah, 240000h, 61657243h, 49446574h, 63655342h, 6E6F6974h, 1F0000h
    dd 61657243h, 6F436574h, 7461706Dh, 656C6269h, 4344h, 65440046h, 6574656Ch
    dd 656A624Fh, 7463h, 65440043h, 6574656Ch, 4344h, 654700FAh, 6F745374h
    dd 624F6B63h, 7463656Ah, 1830000h, 74786554h, 4174754Fh, 1720000h, 54746553h
    dd 43747865h, 726F6C6Fh, 1510000h, 42746553h, 646F4D6Bh, 1560065h, 44746553h
    dd 6F434249h, 54726F6Ch, 656C6261h, 350000h, 61657243h, 61506574h, 7474656Ch
    dd 0EF0065h, 50746547h, 74656C61h, 6E456574h, 65697274h, 0A0073h, 42746942h
    dd 746Ch, 6552011Bh, 65724367h, 4B657461h, 78457965h, 1350041h, 51676552h
    dd 79726575h, 756C6156h, 4165h, 6552012Dh, 65704F67h, 79654B6Eh, 11A0041h
    dd 43676552h, 74616572h, 79654B65h, 610041h, 6C656853h, 6578456Ch, 65747563h
    dd 48530041h, 334C4C45h, 6C642E32h, 6Ch, 5Ch dup(0)
    align 4
    _rdata ends

    ; Section 3. (virtual address 00101000)
    ; Virtual size                  : 0002A65C ( 173660.)
    ; Section size in file          : 00010A00 (  68096.)
    ; Offset to raw data for section: 000FF600
    ; Flags C0000040: Data Readable Writable
    ; Alignment     : 16 bytes ?
    ; ---------------------------------------------------------------------------

    ; Segment type: Pure data
    ; Segment permissions: Read/Write
    _data segment para public 'DATA' use32
    assume cs:_data
    ;org 501000h
    dword_501000 dd 0, 4205F0h, 434A30h, 438450h, 440230h, 44F720h, 44F7E0h, 460E20h, 463BA0h
                                            ; DATA XREF: __cinit+22o
    dd 471C80h, 4814C0h, 4889D0h, 49E610h, 4B2290h, 4B7590h, 4B75A0h, 4C22A0h
    dd 4D09E0h, 4E4140h
    dword_50104C dd 0                       ; DATA XREF: __cinit+1Do
    dword_501050 dd 0, 4E4AE0h, 4F2CC0h, 4F2240h ; DATA XREF: __cinit+10o
    dword_501060 dd 0                       ; DATA XREF: __cinit+Bo
    TlsCallbacks dd 0                       ; DATA XREF: .rdata:004FDD64o
    dd 0
    dword_50106C dd 0, 4F2D80h              ; DATA XREF: _doexit+71o
    dword_501074 dd 0                       ; DATA XREF: _doexit+6Co
    dword_501078 dd 0, 4F2260h              ; DATA XREF: _doexit+83o
    dword_501080 dd 4 dup(0)                ; DATA XREF: _doexit+7Eo
    aU04xacc db 'u%04xacc',0                ; DATA XREF: sub_4010B0+19o
                                            ; sub_401110+19o
    align 4
    aQpatrol_0 db 'QPatrol',0               ; DATA XREF: .text:00402DF0o
    aQmove_0 db 'QMove',0                   ; DATA XREF: .text:00402DE2o
    align 4
    aReadyWithOrder db 'Ready with orders',0
    align 4
    aSelfrepair_0 db 'SelfRepair',0
    align 4
    aRepairing db 'Repairing',0             ; DATA XREF: .text:00405406o
                                            ; .text:00414FA2o
    align 4
    aGuard_nomove db 'Guard_NoMove',0
    align 4
    aReady db 'Ready',0                     ; DATA XREF: .rdata:004FD288o
    align 4
    aAttackutype_0 db 'AttackUType',0
    aWaitforattac_0 db 'WaitForAttack',0
    align 4
    aWaitingForAtta db 'Waiting for attack',0
    align 4
    aWait_0 db 'Wait',0
    align 4
    aWaiting db 'Waiting',0
    aMakeselectab_0 db 'MakeSelectable',0
    align 4
    aUnitIsAvailabl db 'Unit is available',0
    align 4
    aBecarried_0 db 'BeCarried',0
    align 4
    aBeingTransport db 'Being transported',0
    align 4
    aGetbuilt_1 db 'GetBuilt',0
    align 4
    aUnderConstruct db 'Under construction',0
    align 4
    aParalyze_0 db 'Paralyze',0
    align 4
    aParalyzed db 'Paralyzed',0
    align 4
    aSelfdestruct_0 db 'SelfDestructFG',0
    align 4
    aSelfdestruct_1 db 'SelfDestruct',0
    align 4
    aSelfDestructEn db 'SELF DESTRUCT ENGAGED',0
    align 4
    aBuildweapon_0 db 'BuildWeapon',0
    aBuildingbuild db 'BuildingBuild',0     ; DATA XREF: .text:004065BFo
                                            ; .text:0040FF71o ...
    align 4
    aNanolathing db 'Nanolathing',0
    aStanding_fireo db 'Standing_FireOrder',0 ; DATA XREF: sub_48CF30+187o
    align 4
    aStanding_moveo db 'Standing_MoveOrder',0 ; DATA XREF: sub_48CF30+1B4o
    align 4
    aAcknowledged db 'Acknowledged',0
    align 4
    aCloak_off_0 db 'Cloak_Off',0
    align 4
    aDecloaking db 'Decloaking',0
    align 4
    aCloak_on_0 db 'Cloak_On',0
    align 4
    aCloaking db 'Cloaking',0
    align 4
    aDeactivate db 'Deactivate',0           ; DATA XREF: sub_48B090+96o
    align 4
    aActivate db 'Activate',0               ; DATA XREF: sub_48B090+71o
    align 4
    aAttack_nomov_0 db 'Attack_NoMove',0
    align 4
    aAttacking db 'Attacking',0             ; DATA XREF: .text:00412114o
                                            ; .text:004128D2o ...
    align 4
    aStop_0 db 'Stop',0
    align 4
    aStopping db 'Stopping',0               ; DATA XREF: .rdata:004FC490o
    align 4
    aVtol_landifcan db 'VTOL_LANDIFCAN',0   ; DATA XREF: sub_401C20+66o
                                            ; sub_40F7D0+141o
    align 4
    aUnitRepaired db 'Unit repaired',0      ; DATA XREF: .text:00402489o
                                            ; .text:004056F6o ...
    align 4
    aRepairAborted_ db 'Repair aborted.',0  ; DATA XREF: .text:00402446o
                                            ; .text:00415260o
    aGetbuilt db 'getbuilt',0               ; DATA XREF: .text:0040299Bo
                                            ; .text:00403DBBo
    align 4
    aStartingConstr db 'Starting construction',0 ; DATA XREF: .text:0040292Fo
                                            ; .text:00403D98o ...
    align 4
    aUnableToCreate db 'Unable to create any more units',0 ; DATA XREF: .text:004028FFo
                                            ; .text:00403D70o ...
    aQuerybuildinfo db 'QueryBuildInfo',0   ; DATA XREF: .text:004027EEo
    align 4
    aConstructionSt db 'Construction stopped',0 ; DATA XREF: .text:0040272Eo
    align 4
    aPark db 'PARK',0                       ; DATA XREF: .text:00402EF0o
    align 4
    aRepairunitnomo db 'RepairUnitNoMove',0
    align 4
    aReclaimunit_0 db 'ReclaimUnit',0
    aReclaim_0 db 'Reclaim',0
    aReclaiming db 'Reclaiming',0           ; DATA XREF: .text:004047BAo
                                            ; .text:00414825o ...
    align 4
    aResurrect_0 db 'Resurrect',0
    align 4
    aResurrecting db 'Resurrecting',0
    align 4
    aCapture_0 db 'Capture',0
    aCapturing db 'Capturing',0             ; DATA XREF: .text:00404342o
    align 4
    aRepairunit_0 db 'RepairUnit',0
    align 4
    aRepairpatrol_0 db 'RepairPatrol',0
    align 4
    aRepairPatrol db 'Repair patrol',0
    align 4
    aHelpbuild_0 db 'HelpBuild',0           ; DATA XREF: .text:00406636o
    align 4
    aMobilebuild_0 db 'MobileBuild',0       ; DATA XREF: .text:004065A0o
                                            ; .text:0040FF52o ...
    aTeleport_0 db 'Teleport',0
    align 4
    aTeleporting db 'Teleporting',0
    aGround_unloa_0 db 'Ground_Unload',0
    align 4
    aUnloading db 'Unloading',0             ; DATA XREF: .text:00406980o
                                            ; .text:004115BBo
    align 4
    aGround_picku_0 db 'Ground_Pickup',0
    align 4
    aLoading db 'Loading',0                 ; DATA XREF: .text:00411288o
    aPatrol_0 db 'Patrol',0
    align 4
    aPatrolling db 'Patrolling',0           ; DATA XREF: .text:004110ECo
                                            ; .text:00415820o
    align 4
    aPark_0 db 'Park',0
    align 4
    aParking db 'Parking',0
    aAttackspecia_0 db 'AttackSpecial',0
    align 4
    aAnnihilating db 'Annihilating',0
    align 4
    aAttack_kamik_0 db 'Attack_Kamikaze',0
    aAttack_chase_0 db 'Attack_Chase',0
    align 4
    aSuppress_0 db 'Suppress',0
    align 4
    aSuppressingFir db 'Suppressing fire',0
    align 4
    aFollow_groun_0 db 'Follow_Ground',0
    align 4
    aGuarding db 'Guarding',0               ; DATA XREF: .text:00406705o
                                            ; .text:0041027Bo
    align 4
    aMove_ground_0 db 'Move_Ground',0
    aMoving db 'Moving',0
    align 4
    aStandby_mine db 'Standby_Mine',0
    align 4
    aStandby db 'Standby',0                 ; DATA XREF: .rdata:004FC6E8o
                                            ; .rdata:004FCA18o
    aSelfdestruct db 'SELFDESTRUCT',0       ; DATA XREF: .text:004032E4o
                                            ; .text:004060F5o ...
    align 4
    aBuildingComple db 'Building complete',0 ; DATA XREF: .text:00403F31o
                                            ; .text:00404227o ...
    align 4
    aTargetAreaWasB db 'Target area was blocked',0 ; DATA XREF: .text:00403D08o
                                            ; .text:0041404Do
    aWaitingForTarg db 'Waiting for target area to clear',0 ; DATA XREF: .text:00403CD7o
                                            ; .text:00414018o
    align 4
    aICanTReachTheC db 'I can',27h,'t reach the construction site',0
                                            ; DATA XREF: .text:00403C3Do
    aConstructionTe db 'Construction terminated',0 ; DATA XREF: .text:00403A34o
                                            ; .text:00403FA8o ...
    aICanTGetThere db 'I can',27h,'t get there',0 ; DATA XREF: .text:00404072o
    align 4
    aCaptureFailed db 'Capture failed',0    ; DATA XREF: .text:004046F6o
    align 4
    aThatUnitIsAClo db 'That unit is a cloud of vapor and cannot be captured',0
                                            ; DATA XREF: .text:00404326o
    align 4
    aThatUnitCannot db 'That unit cannot be captured',0 ; DATA XREF: .text:004042F7o
    align 4
    aReclamationFai db 'Reclamation failed',0 ; DATA XREF: .text:0040479Eo
                                            ; .text:004047DEo ...
    align 4
    aThatUnitCann_0 db 'That unit cannot be reclaimed',0 ; DATA XREF: .text:00404791o
                                            ; .text:00414D89o
    align 4
    aResurrectionCo db 'Resurrection complete',0 ; DATA XREF: .text:00405247o
    align 4
    aRessurectionFa db 'Ressurection failed',0 ; DATA XREF: .text:00404F6Fo
    aResurrectionFa db 'Resurrection failed',0 ; DATA XREF: .text:00404DEFo
    aRepairsUnsucce db 'Repairs unsuccessful.',0 ; DATA XREF: .text:00405316o
                                            ; .text:004053A2o ...
    align 4
    aReclaim db 'RECLAIM',0                 ; DATA XREF: .text:00405BEFo
                                            ; .text:00405D05o ...
    aVtol_move db 'VTOL_MOVE',0             ; DATA XREF: .text:00406240o
                                            ; sub_43F0E0+79Do ...
    align 4
    aTransportMissi db 'Transport mission failed',0 ; DATA XREF: .text:004068CFo
                                            ; .text:004111FFo ...
    align 4
    aTransportpicku db 'TransportPickup',0  ; DATA XREF: .text:0040682Fo
    aLoadingUnit db 'Loading unit',0        ; DATA XREF: .text:004067F9o
    align 4
    aUnitIsTooLarge db 'Unit is too large to transport',0 ; DATA XREF: .text:004067E2o
    align 4
    aTransportdrop db 'TransportDrop',0     ; DATA XREF: .text:004069BAo
    align 4
    aUnloadingProce db 'Unloading process is proceeding non-optimally',0
                                            ; DATA XREF: .text:0040690Eo
    align 4
    dword_501774 dd 1                       ; DATA XREF: sub_406C90+6w
                                            ; sub_406C90+4Bw ...
    aHard_0 db 'hard',0                     ; DATA XREF: sub_406C90+C6o
    align 4
    aMedium_0 db 'medium',0                 ; DATA XREF: sub_406C90+93o
    align 4
    aEasy_0 db 'easy',0                     ; DATA XREF: sub_406C90+60o
    align 4
    aAny db 'any',0                         ; DATA XREF: sub_406C90+2Co
    aLimit db 'limit',0                     ; DATA XREF: sub_406F00+29o
    align 4
    aWeight db 'weight',0                   ; DATA XREF: sub_406F00+18o
    align 4
    aPlan db 'plan',0                       ; DATA XREF: sub_406F00+7o
    align 4
    a3d3d3d3dSS db ' - %3d : %3d : %3d = %3d - ',27h,'%s',9,9,':%s',27h,0Dh,0Ah,0
                                            ; DATA XREF: sub_40C250+24Co
    align 4
    a4d db '%4d',0                          ; DATA XREF: sub_40C250+212o
    aNA db 'n/a ',0                         ; DATA XREF: sub_40C250+201o
    align 4
    aLimitBaseBasem db '<limit> - <base:baseML:baseEL> : <end result - before econom'
                                            ; DATA XREF: sub_40C250+1BEo
    db 'y-based tweaks> - <unit name>',0Dh,0Ah,0
    asc_50183C db '================================================',0Dh,0Ah,0
                                            ; DATA XREF: sub_40C250+1B0o
    align 4
    aDifficultyS db 'difficulty: ',27h,'%s',27h,0Dh,0Ah,0 ; DATA XREF: sub_40C250+1A2o
    align 4
    aHard_1 db 'HARD',0                     ; DATA XREF: sub_40C250+195o
    align 4
    aMedium_1 db 'MEDIUM',0                 ; DATA XREF: sub_40C250+187o
    align 4
    aEasy_1 db 'EASY',0                     ; DATA XREF: sub_40C250+17Fo
    align 4
    aProfileS db 'profile:    ',27h,'%s',27h,0Dh,0Ah,0 ; DATA XREF: sub_40C250+16Bo
    align 4
    aTerrainS db 'terrain:    ',27h,'%s',27h,0Dh,0Ah,0 ; DATA XREF: sub_40C250+14Ao
    align 4
    aControllerS db 'controller: %s',0Dh,0Ah,0 ; DATA XREF: sub_40C250+124o
    align 4
    aHuman db 'HUMAN',0                     ; DATA XREF: sub_40C250+FDo
    align 4
    aAi_0 db 'AI',0                         ; DATA XREF: sub_40C250+F2o
                                            ; .data:00501FD0o
    align 4
    aInvalid db 'INVALID',0                 ; DATA XREF: sub_40C250+EBo
    aPlayerSNumD db 'player:   ',27h,'%s',27h,' num: %d',0Dh,0Ah,0 ; DATA XREF: sub_40C250+C4o
    align 4
    aGametimeS db 'gametime: ',27h,'%s',27h,0Dh,0Ah,0 ; DATA XREF: sub_40C250+9Ao
    align 4
    a02d02d02d db '%02d:%02d:%02d',0        ; DATA XREF: sub_40C250+80o
                                            ; sub_491EC0+2F5o
    align 4
    aAisearchTouche db 'AISearch touched mapentries',0 ; DATA XREF: sub_40E9E0+87o
    aVtol_landifc_0 db 'VTOL_LandIfCan',0
    align 4
    aSeekingToLand db 'Seeking to land',0
    aVtol_getrepair db 'VTOL_GetRepaired',0
    align 4
    aUnderRepair db 'Under repair',0
    align 4
    aVtol_seekgua_0 db 'VTOL_SeekGuard',0
    align 4
    aSeekingToGuard db 'Seeking to guard',0
    align 4
    aVtol_seekatt_0 db 'VTOL_SeekAttack',0
    aSeekingToAttac db 'Seeking to attack',0
    align 4
    aVtol_evade_0 db 'VTOL_Evade',0
    align 4
    aEvading db 'Evading',0
    aVtol_reclaim_0 db 'VTOL_ReclaimUnit',0
    align 4
    aVtol_reclaim_1 db 'VTOL_Reclaim',0
    align 4
    aVtol_repairu_0 db 'VTOL_RepairUnit',0
    aVtol_repairp_0 db 'VTOL_RepairPatrol',0
    align 4
    aVtol_helpbui_0 db 'VTOL_HelpBuild',0   ; DATA XREF: .text:004100C2o
    align 4
    aVtol_mobileb_0 db 'VTOL_MobileBuild',0 ; DATA XREF: .text:0040FF90o
                                            ; sub_43A420+28Co ...
    align 4
    aAirtogroundh_0 db 'AirToGroundHover',0
    align 4
    aAirtoground_0 db 'AirToGround',0
    aAirtoair_0 db 'AirToAir',0
    align 4
    aEngagingTarget db 'Engaging target',0
    aAirstrike_0 db 'AirStrike',0
    align 4
    aAirstrike_1 db 'Airstrike',0
    align 4
    aVtol_patrol_0 db 'VTOL_Patrol',0
    aVtol_follow_0 db 'VTOL_Follow',0
    aVtol_unload_0 db 'VTOL_Unload',0
    aVtol_pickup_0 db 'VTOL_Pickup',0
    aVtol_landing_0 db 'VTOL_Landing',0
    align 4
    aLanding db 'Landing',0                 ; DATA XREF: .text:00411953o
    aVtol_move_0 db 'VTOL_Move',0
    align 4
    aVtol_standby db 'VTOL_Standby',0
    align 4
    aEndtransport db 'EndTransport',0       ; DATA XREF: GameUnit_EndTransport+22Eo
                                            ; .text:00411488o ...
    align 4
    aVtol_seekguard db 'VTOL_SEEKGUARD',0   ; DATA XREF: .text:00410369o
    align 4
    aVtol_helpbuild db 'VTOL_HELPBUILD',0   ; DATA XREF: .text:0041008Bo
                                            ; .text:004155D3o ...
    align 4
    aHelpbuild db 'HELPBUILD',0             ; DATA XREF: .text:00410071o
                                            ; sub_43F0E0+9B0o
    align 4
    aVtol_reclaimun db 'VTOL_RECLAIMUNIT',0 ; DATA XREF: .text:0041005Do
                                            ; sub_43F0E0+5E1o ...
    align 4
    aReclaimunit db 'RECLAIMUNIT',0         ; DATA XREF: .text:00410043o
                                            ; sub_43F0E0+957o
    aVtol_reclaim db 'VTOL_RECLAIM',0       ; DATA XREF: .text:0041002Fo
                                            ; .text:00415778o ...
    align 4
    aVtol_repairuni db 'VTOL_REPAIRUNIT',0  ; DATA XREF: .text:00410001o
                                            ; sub_43F0E0+3D1o ...
    aRepairunit db 'REPAIRUNIT',0           ; DATA XREF: .text:0040FFE7o
                                            ; sub_43F0E0+9F9o
    align 4
    aVtol_landing db 'VTOL_LANDING',0       ; DATA XREF: .text:004105B9o
                                            ; .text:00410A13o ...
    align 4
    aBegintransport db 'BeginTransport',0   ; DATA XREF: .text:004113EAo
                                            ; .text:004113FDo
    align 4
    aQuerytransport db 'QueryTransport',0   ; DATA XREF: .text:004113ACo
    align 4
    aPreparingForTr db 'Preparing for transport',0 ; DATA XREF: .text:0041138Ao
    aUnitIsTooHeavy db 'Unit is too heavy to transport',0 ; DATA XREF: .text:0041126Do
    align 4
    aUnableToUnload db 'Unable to unload unit',0 ; DATA XREF: .text:00411769o
    align 4
    aQuerylandingpa db 'QueryLandingPad',0  ; DATA XREF: .text:00411887o
                                            ; .text:00411A30o ...
    aSelfrepair db 'SELFREPAIR',0           ; DATA XREF: .text:00411ECEo
    align 4
    aLandingAbort_1 db 'Landing aborted: no pads available',0 ; DATA XREF: .text:00411DF9o
    align 4
    aLandingAbort_0 db 'Landing aborted: all pads are occupied',0 ; DATA XREF: .text:00411D2Eo
    align 4
    aLandingFailed db 'Landing failed',0    ; DATA XREF: .text:00411C32o
    align 4
    aLandingAborted db 'Landing aborted',0  ; DATA XREF: .text:00411903o
    aVtol_seekattac db 'VTOL_SEEKATTACK',0  ; DATA XREF: .text:00411FABo
                                            ; .text:0041202Bo ...
    aVtol_evade db 'VTOL_EVADE',0           ; DATA XREF: .text:00413352o
    align 4
    aGetbuilt_0 db 'GETBUILT',0             ; DATA XREF: .text:004140E9o
    align 4
    aBuilding db 'Building',0               ; DATA XREF: .text:00413E0Fo
                                            ; .text:00414410o
    align 4
    aConstruction_0 db 'Construction terminated by hostile action',0
                                            ; DATA XREF: .text:00414734o
    align 4
    aRepairMissionF db 'Repair mission failed',0 ; DATA XREF: .text:00414F86o
    dd 0
    align 4
    byte_501D18 db 0                        ; DATA XREF: sub_417F60+121r
                                            ; sub_417F60+1E8r
    dd 2 dup(0), 6D6E6F00h, 586A6B6Ch, 54555657h, 50515253h, 0FFFFFFFFh
    db 3 dup(0FFh)
    off_501D38 dd offset aNoshake           ; DATA XREF: sub_419560+47o
                                            ; "NoShake"
    dd offset sub_416E60
    dd 1, 50243Ch, 416DB0h, 1, 502430h, 416CF0h, 1, 502428h, 416D20h, 1, 502420h
    dd 416BD0h, 1, 502418h, 4167F0h, 1, 502410h, 416810h, 1, 502408h, 416820h
    dd 1, 502400h, 416420h, 1, 5023F4h, 416510h, 1, 5023ECh, 416550h, 1, 5023E4h
    dd 416590h, 1, 5023D8h, 4165C0h, 1, 5023D0h, 416630h, 1, 5023C8h, 416660h
    dd 1, 5023C0h, 416690h, 1, 5023B8h, 4166C0h, 1, 5023B0h, 416710h, 1, 5023A4h
    dd 416460h, 1, 502398h, 4175E0h, 1, 502390h, 4168D0h, 1, 502384h, 417130h
    dd 1, 50237Ch, 417290h, 1, 502374h, 417300h, 1, 502368h, 417570h, 1, 502360h
    dd 4172E0h, 1, 502358h, 417150h, 1, 50234Ch, 4171F0h, 1, 502340h, 4174E0h
    dd 1, 50233Ch, 416E90h, 1, 502334h, 4177A0h, 1, 502328h, 418CA0h, 1, 50231Ch
    dd 418CD0h, 1, 502310h, 418D90h, 1, 502300h, 418E50h, 1, 5022F4h, 418FD0h
    dd 1, 5022E8h, 419090h, 1, 5022DCh, 4194C0h, 1, 5022CCh, 419340h, 1, 5022BCh
    dd 419400h, 1, 5022B0h, 4194D0h, 1, 5022ACh, 419540h, 1, 5022A8h, 419550h
    dd 1, 3 dup(0)
    off_501F48 dd offset aRadar             ; DATA XREF: sub_419560+69o
                                            ; "Radar"
    dd offset sub_417090
    dd 2, 50229Ch, 4170C0h, 2, 502294h, 416B50h, 2, 502290h, 416D50h, 2, 502288h
    dd 416D80h, 2, 50227Ch, 417030h, 2, 502270h, 417060h, 2, 502268h, 417540h
    dd 2, 502260h, 417760h, 2, 502254h, 417600h, 2, 4 dup(0)
    off_501FD0 dd offset aAi_0              ; DATA XREF: sub_419560+73o
                                            ; "AI"
    dd offset sub_416280
    dd 4, 50224Ch, 416AB0h, 4, 502244h, 4164B0h, 4, 50223Ch, 4169D0h, 4, 502234h
    dd 416A30h, 4, 50222Ch, 417330h, 4, 502220h, 4173E0h, 4, 502218h, 416370h
    dd 4, 502210h, 416310h, 4, 502208h, 416390h, 4, 502200h, 4163A0h, 4, 5021F4h
    dd 417A60h, 4, 5021ECh, 416380h, 4, 5021E4h, 416730h, 4, 5021DCh, 4177E0h
    dd 4, 5021D8h, 416270h, 4, 5021D0h, 416240h, 4, 5021C8h, 416860h, 4, 5021B8h
    dd 418BB0h, 4, 5021B0h, 417520h, 4, 5021A8h, 417490h, 4, 502194h, 4174D0h
    dd 4, 50218Ch, 417430h, 4, 502180h, 416A90h, 4, 502178h, 416780h, 4, 50216Ch
    dd 416E00h, 4, 502160h, 418C70h, 4, 502154h, 416E30h, 4, 50214Ch, 4163D0h
    dd 4, 502144h, 416500h, 4, 3 dup(0), 6675425Ah, 726566h, 74616546h, 657275h
    dd 65657254h, 74616544h, 68h, 646E6553h, 6F727265h, 72h, 426C6553h, 7365786Fh
    dd 0, 72616553h, 6863h, 4C616553h, 6C657665h, 0
    aSave db 'Save',0                       ; DATA XREF: sub_44C420+19Eo
                                            ; sub_44C7E0+5D7o
    align 4
    aReloadaiprofil db 'ReloadAIProfiles',0
    align 4
    aReload db 'Reload',0                   ; DATA XREF: .text:00416F85o
    align 4
    aProfile db 'Profile',0
    aPrintweights db 'PrintWeights',0
    align 4
    aMove_1 db 'Move',0
    align 4
    aMemdump db 'MemDump',0
    aMem db 'Mem',0
    aInclude db 'Include',0                 ; DATA XREF: .text:00416F3Do
    aEdge db 'Edge',0
    align 4
    aDprint db 'DPrint',0
    align 4
    aDebugbreak db 'DebugBreak',0
    align 4
    aBurnone db 'BurnOne',0
    aBurnall db 'BurnAll',0
    aAssign db 'Assign',0
    align 4
    aAssert db 'Assert',0                   ; DATA XREF: .text:00416FC9o
    align 4
    aFilmspeed db 'FilmSpeed',0
    align 4
    aFilm db 'Film',0                       ; DATA XREF: .text:00416EADo
    align 4
    aIlose db 'ILose',0
    align 4
    aIwin db 'IWin',0
    align 4
    aKill_0 db 'Kill',0
    align 4
    aControl_0 db 'Control',0
    aMakeposter db 'MakePoster',0
    align 4
    aMeteor_0 db 'Meteor',0                 ; DATA XREF: sub_438180+5o
                                            ; sub_438250+5o
    align 4
    aNowisee db 'NowISee',0
    aHalfshot db 'HalfShot',0
    align 4
    aDoubleshot db 'DoubleShot',0
    align 4
    aMapping_0 db 'Mapping',0               ; DATA XREF: sub_4326B0+232o
                                            ; sub_47A0E0+4C4o ...
    aLos_0 db 'LOS',0                       ; DATA XREF: sub_441460+6A6o
    aView db 'View',0
    align 4
    dd offset loc_4D543D+4
    aRadar db 'Radar',0                     ; DATA XREF: .data:00501F48o
    align 4
    aSfx db 'SFX',0                         ; DATA XREF: GameUnit_LOS_Unknown1+16A0o
    aBps db 'BPS',0
    aCompression db 'Compression',0
    aSetshareenergy db 'SetShareEnergy',0
    align 4
    aSetsharemetal db 'SetShareMetal',0
    align 4
    aShowranges db 'ShowRanges',0
    align 4
    aShareall db 'ShareAll',0
    align 4
    aShareradar db 'ShareRadar',0
    align 4
    aSharemapping db 'ShareMapping',0
    align 4
    aShareenergy db 'ShareEnergy',0
    aSharemetal db 'ShareMetal',0
    align 4
    aShootall db 'ShootAll',0
    align 4
    aDrop db 'Drop',0
    align 4
    aNow db 'Now',0
    aBigbrother db 'BigBrother',0
    align 4
    aNoenergy db 'NoEnergy',0
    align 4
    aNometal db 'NoMetal',0
    aSing_0 db 'Sing',0
    align 4
    aNetstats db 'NetStats',0
    align 4
    aClock_0 db 'Clock',0
    align 4
    aGamma db 'Gamma',0                     ; DATA XREF: WriteRegistrySettings_1+7FBo
                                            ; WriteRegistrySettings_1+856o ...
    align 4
    aScreenchat_0 db 'ScreenChat',0
    align 4
    aLogo db 'Logo',0                       ; DATA XREF: sub_466050+210o
                                            ; sub_4662F0+22Eo
    align 4
    aMusicmode_0 db 'MusicMode',0
    align 4
    aSelectable db 'Selectable',0
    align 4
    aRcache db 'RCache',0
    align 4
    aLight db 'Light',0
    align 4
    aLostype_0 db 'LOSType',0
    aFshadow db 'FShadow',0
    aTshadow db 'TShadow',0
    aSwitchalt db 'SwitchAlt',0             ; DATA XREF: WriteRegistrySettings_1+86Ao
                                            ; WriteRegistrySettings_1+8C5o ...
    align 4
    aDither db 'Dither',0
    align 4
    aShadow_0 db 'Shadow',0
    align 4
    aAntialias db 'AntiAlias',0
    align 4
    aShading db 'Shading',0                 ; DATA XREF: WriteRegistrySettings_1+72Fo
                                            ; WriteRegistrySettings_1+780o ...
    aSound3d db 'Sound3D',0
    aCdstop_0 db 'CDStop',0
    align 4
    aCdplay_0 db 'CDPlay',0
    align 4
    aGive db 'Give',0
    align 4
    aIface db 'IFace',0
    align 4
    aScrollspeed_0 db 'ScrollSpeed',0
    aContour db 'Contour',0
    aNoshake db 'NoShake',0                 ; DATA XREF: .data:00501D38o
    aPs4dPr4dSD4dRD db 'pS=%4d pR=%4d (S=%d/%4d, R=%d/%4d) C=%3d%%',0Ah,0
                                            ; DATA XREF: sub_415FA0+198o
    aMemdump_txt db 'memdump.txt',0         ; DATA XREF: sub_416240+12o
    aMove db 'move',0                       ; DATA XREF: .text:00416865o
    align 4
    aInvalidLogoSet db 'Invalid logo setting',0 ; DATA XREF: TextCommand_Logo+EEo
    align 4
    aEnergy_0 db 'energy',0                 ; DATA XREF: .text:00416C92o
                                            ; sub_4224B0+59Fo
    align 4
    aMetal_0 db 'metal',0                   ; DATA XREF: .text:00416C3Do
                                            ; sub_4224B0+58Bo
    align 4
    aChris db 'Chris',0                     ; DATA XREF: .text:00416EF5o
    align 4
    aGenericGameDes db 'Generic Game Description',0 ; DATA XREF: .text:00417475o
    align 4
    aSavegame db 'savegame',0               ; DATA XREF: .text:00417462o
    align 4
    aSavegameS_sav db 'savegame\%s.sav',0   ; DATA XREF: .text:00417454o
    aBigshot db 'BIGSHOT',0                 ; DATA XREF: sub_417600+132o
    aSScreenshots db '%s\screenshots',0     ; DATA XREF: sub_417600+112o
                                            ; sub_499890+B5o
    align 4
    aAll db 'all',0                         ; DATA XREF: sub_417600+47o
    aDebugdatS_txt db 'debugdat\%s.txt',0   ; DATA XREF: .text:004177F9o
                                            ; sub_417890+139o
    aForceOutOfMemo db 'FORCE OUT-OF-MEMORY',0 ; DATA XREF: .text:00417AC2o
    aG_0:                                   ; DATA XREF: sub_418310+394o
    unicode 0, <G>,0
    aWB db 'w+b',0                          ; DATA XREF: .text:00418C1Fo
                                            ; sub_4B39C0+98o ...
    aToggledShareme db 'Toggled ShareMetal to: %s',0 ; DATA XREF: TextCommand_ShareMetal+86o
                                            ; TextCommand_ShareAll+94o
    align 4
    aOff db 'OFF',0                         ; DATA XREF: TextCommand_ShareMetal+7Co
                                            ; TextCommand_ShareEnergy+7Co ...
    aOn db 'ON',0                           ; DATA XREF: TextCommand_ShareMetal+75o
                                            ; TextCommand_ShareEnergy+75o ...
    db    0 ;
    aToggledShareen db 'Toggled ShareEnergy to: %s',0 ; DATA XREF: TextCommand_ShareEnergy+86o
                                            ; TextCommand_ShareAll+137o
    align 4
    aToggledSharema db 'Toggled ShareMapping to: %s',0 ; DATA XREF: TextCommand_ShareMapping+86o
                                            ; TextCommand_ShareAll+1DAo
    aToggledSharelo db 'Toggled ShareLOS to: %s',0 ; DATA XREF: TextCommand_ShareLOS+86o
    aToggledSharera db 'Toggled ShareRadar to: %s',0 ; DATA XREF: TextCommand_ShareRadar+86o
                                            ; TextCommand_ShareAll+27Do
    align 4
    aOk_WillShareMe db 'OK.  Will share metal if above %d',0
                                            ; DATA XREF: TextCommand_SetShareMetal+97o
    align 4
    aOk_WillShareEn db 'OK.  Will share energy if above %d',0
                                            ; DATA XREF: TextCommand_SetShareEnergy+97o
    align 4
    aOk_OutgoingPac db 'Ok.  Outgoing packet compression turned %s',0
                                            ; DATA XREF: .text:00419516o
    align 4
    aVtol_mobilebui db 'VTOL_MOBILEBUILD',0 ; DATA XREF: sub_419670+12Fo
                                            ; sub_43F0E0+6E3o
    align 4
    aMobilebuild db 'MOBILEBUILD',0         ; DATA XREF: sub_419670+112o
                                            ; sub_419B00+6Do ...
    aD_1 db '+%d',0                         ; DATA XREF: .text:00419987o
                                            ; sub_4199B0+6Eo
    aD db ' +%d',0                          ; DATA XREF: sub_4199B0+B7o
    align 4
    aD_0 db '%d',0                          ; DATA XREF: sub_4199B0+98o
                                            ; sub_441460+3C1o ...
    align 4
    aOnoff db 'ONOFF',0                     ; DATA XREF: sub_419AC0+5o
                                            ; sub_41A120+E3o ...
    align 4
    aBuildweapon db 'BUILDWEAPON',0         ; DATA XREF: sub_419B00+9Eo
                                            ; sub_487BF0+516o
    aBuildingbuil_0 db 'BUILDINGBUILD',0    ; DATA XREF: sub_419B00+76o
                                            ; sub_487BF0+4D8o
    align 4
    aMakeanti db 'MAKEANTI',0               ; DATA XREF: sub_419B00+4Eo
    align 4
    aMakenuke db 'MAKENUKE',0               ; DATA XREF: sub_419B00+3Co
    align 4
    aSubbuild db 'subbuild',0               ; DATA XREF: sub_419B00+2Eo
    align 4
    aAddbuild db 'addbuild',0               ; DATA XREF: sub_419B00+27o
                                            ; sub_41AA00+197o
    align 4
    aLoad db 'LOAD',0                       ; DATA XREF: sub_419BE0+4C7o
                                            ; sub_41A120+2F2o ...
    align 4
    aUnload db 'UNLOAD',0                   ; DATA XREF: sub_419BE0+455o
                                            ; sub_41A120+30Bo
    align 4
    aCapture db 'CAPTURE',0                 ; DATA XREF: sub_419BE0+3E4o
                                            ; sub_41A120+2CAo ...
    aPatrol db 'PATROL',0                   ; DATA XREF: sub_419BE0+2FBo
                                            ; sub_41A120+253o ...
    align 4
    aSpecialorders db 'specialorders',0     ; DATA XREF: sub_419BE0+2BCo
                                            ; sub_419BE0+3A5o ...
    align 4
    aRepair db 'REPAIR',0                   ; DATA XREF: sub_419BE0+287o
                                            ; sub_41A120+2A2o
    align 4
    aDefend db 'DEFEND',0                   ; DATA XREF: sub_419BE0+213o
                                            ; sub_41A120+22Bo
    align 4
    aBlast db 'BLAST',0                     ; DATA XREF: sub_419BE0+19Eo
                                            ; sub_41A120+332o ...
    align 4
    aAttack db 'ATTACK',0                   ; DATA XREF: sub_419BE0+12Ao
                                            ; sub_41A120+204o
    align 4
    aStop db 'STOP',0                       ; DATA XREF: sub_419BE0+C4o
                                            ; sub_419BE0+100o ...
    align 4
    aImmediateorder db 'immediateorders',0  ; DATA XREF: sub_419BE0+85o
                                            ; sub_419BE0+15Fo ...
    aMove_0 db 'MOVE',0                     ; DATA XREF: sub_419BE0+50o
                                            ; sub_41A120+1B4o
    align 4
    aFireord db 'FIREORD',0                 ; DATA XREF: sub_41A120+160o
                                            ; sub_41A490+149o
    aMoveord db 'MOVEORD',0                 ; DATA XREF: sub_41A120+123o
                                            ; sub_41A490+4Ao
    aCloak db 'CLOAK',0                     ; DATA XREF: sub_41A120+A3o
                                            ; sub_41A490+29Do
    align 4
    aOrders db 'ORDERS',0                   ; DATA XREF: sub_41A120+5Eo
                                            ; sub_41AA00+DFo
    align 4
    aBuild db 'BUILD',0                     ; DATA XREF: sub_41A120+14o
                                            ; sub_41AA00+120o
    align 4
    aDeactivate_0 db 'DEACTIVATE',0         ; DATA XREF: sub_41A490+3ADo
    align 4
    aActivate_0 db 'ACTIVATE',0             ; DATA XREF: sub_41A490+374o
                                            ; sub_41A490+3D8o
    align 4
    aCloak_on db 'CLOAK_ON',0               ; DATA XREF: sub_41A490+2EEo
    align 4
    aCloak_off db 'CLOAK_OFF',0             ; DATA XREF: sub_41A490+2CCo
    align 4
    aStatus_0 db 'STATUS',0                 ; DATA XREF: sub_41A490+251o
                                            ; sub_441460+612o
    align 4
    aSetfireorders db 'setfireorders',0     ; DATA XREF: sub_41A490+21Fo
    align 4
    aStanding_fir_0 db 'STANDING_FIREORDER',0 ; DATA XREF: sub_41A490+18Bo
                                            ; sub_41A490+1C4o ...
    align 4
    aSetmoveorders db 'setmoveorders',0     ; DATA XREF: sub_41A490+11Co
    align 4
    aStanding_mov_0 db 'STANDING_MOVEORDER',0 ; DATA XREF: sub_41A490+88o
                                            ; sub_41A490+C1o ...
    align 4
    aSnext db '%sNEXT',0                    ; DATA XREF: .text:0041A9C6o
                                            ; sub_41ACE0+2E2o
    align 4
    aSprev db '%sPREV',0                    ; DATA XREF: .text:0041A971o
                                            ; sub_41ACE0+28Eo
    align 4
    aBuildbutton db 'buildbutton',0         ; DATA XREF: sub_41AA00+139o
    aOrdersbutton db 'ordersbutton',0       ; DATA XREF: sub_41AA00+F8o
    align 4
    aNext db 'NEXT',0                       ; DATA XREF: sub_41AA00+AAo
                                            ; sub_4AA8F0+42Eo
    align 4
    aPrev db 'PREV',0                       ; DATA XREF: sub_41AA00+75o
                                            ; sub_442050+159o ...
    align 4
    aSdl db '%sDL',0                        ; DATA XREF: sub_41ACE0+AEo
    align 4
    aGuis db 'guis',0                       ; DATA XREF: sub_41ACE0+4Co
                                            ; sub_42A610+EEo ...
    align 4
    off_502828 dd offset loc_495544+3       ; DATA XREF: sub_41ACE0+37o
                                            ; sub_42D2E0+544o ...
    aSgen_gui db '%sGEN.GUI',0              ; DATA XREF: sub_41B0F0+4Bo
    align 4
    aSD_gui db '%s%d.GUI',0                 ; DATA XREF: .text:0041B286o
                                            ; sub_41B2E0+503o
    align 4
    aBuilder_gui db 'BUILDER.GUI',0         ; DATA XREF: sub_41B8D0+98o
    aNextbuildmenu db 'nextbuildmenu',0     ; DATA XREF: sub_41BDE0+11Co
                                            ; sub_41BF10+137o ...
    align 4
    aCommander_0 db 'Commander',0           ; DATA XREF: sub_41C310+10o
                                            ; sub_4933E0+26o
    align 4
    aTalk_gui db 'TALK.GUI',0               ; DATA XREF: sub_41CE90+C7o
                                            ; sub_494050+9Do
    align 4
    aXPosition db 'X Position',0            ; DATA XREF: sub_41D2B0+3Bo
                                            ; sub_41D360+1Do
    align 4
    aZPosition db 'Z Position',0            ; DATA XREF: sub_41D2B0+1Eo
                                            ; sub_41D360+38o
    align 4
    aCamera db 'Camera',0                   ; DATA XREF: sub_41D2B0+6o
                                            ; sub_41D360+5o
    align 4
    dword_502898 dd 1                       ; DATA XREF: sub_41D4A0+4w
    dword_50289C dd 1                       ; DATA XREF: sub_41D4C0r sub_41D6A0r ...
    aCS db '%c:\%s',0                       ; DATA XREF: sub_41D4C0+18Eo
    align 4
    aC_hpi db '%c:\*.hpi',0                 ; DATA XREF: sub_41D4C0+157o
    align 4
    a_hpi db '*.HPI',0                      ; DATA XREF: sub_41D4C0+F4o
    align 4
    a_ufo db '*.UFO',0                      ; DATA XREF: sub_41D4C0+BAo
    align 4
    a_ccx db '*.CCX',0                      ; DATA XREF: sub_41D4C0+80o
    align 4
    aRevS_gp3 db 'rev%s.GP3',0              ; DATA XREF: sub_41D4C0+2Co
    align 4
    a31 db '31',0                           ; DATA XREF: sub_41D4C0+20o
    align 4
    aContents db 'Contents',0               ; DATA XREF: sub_41D6A0+B6o
    align 4
    aCTotala_id db '%c:\TOTALA.ID',0        ; DATA XREF: sub_41D6A0+7Fo
    align 4
    aCampaign db 'Campaign',0               ; DATA XREF: sub_41D6A0+3Ao
                                            ; sub_4326B0+B0o ...
    align 4
    aMultiplayer db 'Multiplayer',0         ; DATA XREF: sub_41D6A0+33o
    ; const CHAR Directory
    Directory dw 2Eh                        ; DATA XREF: sub_41D7B0+6Fo
                                            ; sub_4290F0+4Ao ...
    align 4
    aCSS db '%c:\%s\%s',0                   ; DATA XREF: sub_41D7B0+49o
    align 4
    a111636 db '11:16:36',0                 ; DATA XREF: sub_41D920+57o
    align 4
    aJul301998 db 'Jul 30 1998',0           ; DATA XREF: sub_41D920+50o
    aOutcome0 db 'Outcome0',0               ; DATA XREF: sub_41DA60+1A0o
    align 4
    aOutcome1 db 'Outcome1',0               ; DATA XREF: sub_41DA60+18Do
    align 4
    aGlamourArm01_p db 'glamour\Arm01.PCX',0 ; DATA XREF: sub_41DA60+11Eo
    align 4
    aBitmapsGlamour db 'bitmaps\glamour',0  ; DATA XREF: sub_41DA60+FAo
    aPcx db 'PCX',0                         ; DATA XREF: sub_41DA60+F0o
                                            ; sub_429290+Fo ...
    aPalette db 'Palette',0                 ; DATA XREF: sub_41DA60+78o
                                            ; sub_4288D0+F9o ...
    aCurrentpalette db 'currentPalette',0   ; DATA XREF: sub_41DA60+43o
    align 4
    aDesiredpalette db 'desiredPalette',0   ; DATA XREF: sub_41DA60+25o
    align 4
    aFadetable db 'FadeTable',0             ; DATA XREF: sub_41DA60+Do
    align 4
    aScoreD db 'Score%d',0                  ; DATA XREF: sub_41E420+5B1o
    aMwastedD db 'MWasted%d',0              ; DATA XREF: sub_41E420+533o
    align 4
    aEwastedD db 'EWasted%d',0              ; DATA XREF: sub_41E420+4B5o
    align 4
    aMproducedD db 'MProduced%d',0          ; DATA XREF: sub_41E420+437o
    aEproducedD db 'EProduced%d',0          ; DATA XREF: sub_41E420+3B9o
    aLossesD db 'Losses%d',0                ; DATA XREF: sub_41E420+33Bo
    align 4
    aKillsD db 'Kills%d',0                  ; DATA XREF: sub_41E420+2BDo
    aText_0 db 'TEXT',0                     ; DATA XREF: sub_41E420+201o
                                            ; sub_45F1D0+11Fo ...
    align 4
    aPlayercolorD db 'PlayerColor%d',0      ; DATA XREF: sub_41E420+E4o
    align 4
    aScrollitems1 db 'ScrollItems1',0       ; DATA XREF: sub_41EAA0+Do
    align 4
    ; char byte_502A20
    byte_502A20 db '&'                      ; DATA XREF: .text:0041EBDFo
                                            ; sub_4A3780+265o ...
    db 47h, 2 dup(0)
    aScrollitems2 db 'ScrollItems2',0       ; DATA XREF: .text:0041EB73o
    align 4
    aPleaseInsert_0 db 'Please insert the Campaign CD (Disc 2) and try again',0
                                            ; DATA XREF: sub_41EC50+2F2o
                                            ; .text:0041F6CDo ...
    align 4
    aSkirmish db 'SKirmish',0               ; DATA XREF: sub_41EC50+23Bo
                                            ; sub_47AE60+ACFo
    align 4
    aDifficulty db 'Difficulty',0           ; DATA XREF: sub_41EC50+225o
                                            ; sub_41F400+F0o ...
    align 4
    aCCavedogWarg_0 db 'c:\cavedog\wargame\endgame.cpp',0 ; DATA XREF: sub_41EC50+1F8o
                                            ; sub_41EC50+3AFo ...
    align 4
    aMainmenu db 'MainMenu',0               ; DATA XREF: sub_41EC50+1DDo
                                            ; sub_41F0A0+138o ...
    align 4
    aMissions db 'Missions',0               ; DATA XREF: sub_41EC50+1CAo
                                            ; sub_41EC50+34Bo ...
    align 4
    aStart db 'Start',0                     ; DATA XREF: sub_41EC50+1B7o
                                            ; sub_41F0A0+F8o ...
    align 4
    aSavegame_0 db 'SaveGame',0             ; DATA XREF: sub_41EC50+184o
                                            ; sub_41F400+A7o ...
    align 4
    aBigbutton db 'BigButton',0             ; DATA XREF: sub_41EC50+162o
                                            ; sub_41EC50+195o ...
    align 4
    aLoadgame db 'LoadGame',0               ; DATA XREF: sub_41EC50+151o
                                            ; sub_41F400+8Eo ...
    align 4
    ; char byte_502AE8
    byte_502AE8 db 'O'                      ; DATA XREF: sub_41F0A0+30Co
                                            ; .text:0041F68Bo ...
    db 4Bh, 2 dup(0)
    aKnob db 'KNOB',0                       ; DATA XREF: sub_41F0A0+20Bo
                                            ; sub_41F400+BEo
    align 4
    aOutcome0_0 db 'outcome0',0             ; DATA XREF: sub_41F0A0+128o
    align 4
    aOutcome1_0 db 'outcome1',0             ; DATA XREF: sub_41F0A0+EBo
    align 4
    aEndmsngui db 'EndMsnGUI',0             ; DATA XREF: sub_41F0A0+42o
    align 4
    aEndmsn_gui db 'ENDMSN.GUI',0           ; DATA XREF: sub_41F0A0+33o
    align 4
    aAdjustdiff db 'AdjustDiff',0           ; DATA XREF: sub_41F400+107o
    align 4
    aSD db '%s%d',0                         ; DATA XREF: .text:0041F5EBo
                                            ; .text:00420046o ...
    align 4
    aOptions db 'Options',0                 ; DATA XREF: .text:0041F69Co
                                            ; sub_4441A0+29Do ...
    aCdcheck_gui db 'CDCHECK.GUI',0         ; DATA XREF: .text:0041F70Fo
                                            ; .text:0041FB98o
    aEndgamescore db 'EndGameScore',0       ; DATA XREF: .text:004204DAo
    align 4
    aEndgamestatbar db 'EndGameStatBar',0   ; DATA XREF: .text:004202C1o
                                            ; .text:00420319o ...
    align 4
    aActivateallsta db 'ActivateAllStatBars',0 ; DATA XREF: .text:0042024Ao
    aScore db 'Score',0                     ; DATA XREF: .text:00420211o
                                            ; .text:0042049Fo
    align 4
    aMwasted db 'MWasted',0                 ; DATA XREF: .text:004201C3o
                                            ; .text:00420447o
    aEwasted db 'EWasted',0                 ; DATA XREF: .text:00420174o
                                            ; .text:004203EEo
    aMproduced db 'MProduced',0             ; DATA XREF: .text:00420127o
                                            ; .text:00420394o
    align 4
    aEproduced db 'EProduced',0             ; DATA XREF: .text:004200D9o
                                            ; .text:00420339o
    align 4
    aLosses db 'Losses',0                   ; DATA XREF: .text:0042008Ao
                                            ; .text:004202E0o ...
    align 4
    aKills db 'Kills',0                     ; DATA XREF: .text:0042003Do
                                            ; .text:00420286o ...
    align 4
    aClickToContinu db 'Click to continue.',0 ; DATA XREF: .text:0041FF15o
    align 4
    aMsgbox_gui db 'MSGBOX.GUI',0           ; DATA XREF: .text:0041F97Co
                                            ; sub_4436E0+C4o ...
    align 4
    aCopyOfLastGame db 'Copy of last game frame',0 ; DATA XREF: .text:0041F859o
    dword_502BF8 dd 10000h, 30002h, 10002h, 50006h, 30000h, 70004h, 1, 60007h, 20003h, 40005h
                                            ; DATA XREF: sub_420620+27Co
    dd 50004h, 70006h
    aExplodepiece db 'explodepiece',0       ; DATA XREF: sub_420620+1BDo
                                            ; sub_420620+2CCo
    align 4
    aCalcedexplosio db 'CalcedExplosion',0  ; DATA XREF: sub_420620+2Fo
                                            ; sub_420620+F5o ...
    aExplosionframe db 'ExplosionFrame',0   ; DATA XREF: sub_420D20+1Co
    align 4
    aFeatureUnit db 'Feature Unit',0        ; DATA XREF: sub_421F20+68o
    align 4
    aFeatureAnimDat db 'FEATURE ANIM DATA',0 ; DATA XREF: sub_421F20+Eo
    align 4
    aFeatures db 'features',0               ; DATA XREF: sub_4222E0+44o
                                            ; sub_436C30+553o
    align 4
    a_tdf db '*.tdf',0                      ; DATA XREF: sub_4222E0+3Fo
    align 4
    aBurnweapon db 'burnweapon',0           ; DATA XREF: sub_4224B0+859o
    align 4
    aSparktime db 'sparktime',0             ; DATA XREF: sub_4224B0+836o
    align 4
    aFortification_ db 'Fortification_Core',0 ; DATA XREF: sub_4224B0+818o
    align 4
    aFortification db 'Fortification',0     ; DATA XREF: sub_4224B0+7F8o
    align 4
    aDragonsteeth_c db 'DragonsTeeth_Core',0 ; DATA XREF: sub_4224B0+7D8o
    align 4
    aDragonsteeth db 'DragonsTeeth',0       ; DATA XREF: sub_4224B0+7A0o
    align 4
    aNodrawundergra db 'nodrawundergray',0  ; DATA XREF: sub_4224B0+77Co
    aNodisplayinfo db 'nodisplayinfo',0     ; DATA XREF: sub_4224B0+752o
    align 4
    aIndestructible db 'indestructible',0   ; DATA XREF: sub_4224B0+728o
    align 4
    aAutoreclaimabl db 'autoreclaimable',0  ; DATA XREF: sub_4224B0+6FEo
    aReclaimable db 'reclaimable',0         ; DATA XREF: sub_4224B0+6D3o
    aBlocking db 'blocking',0               ; DATA XREF: sub_4224B0+6B3o
    align 4
    aGeothermal db 'geothermal',0           ; DATA XREF: sub_4224B0+67Fo
    align 4
    aFlamable db 'flamable',0               ; DATA XREF: sub_4224B0+655o
    align 4
    aShadtrans db 'shadtrans',0             ; DATA XREF: sub_4224B0+62Bo
    align 4
    aAnimtrans db 'animtrans',0             ; DATA XREF: sub_4224B0+601o
    align 4
    aAnimating db 'animating',0             ; DATA XREF: sub_4224B0+5E2o
    align 4
    aDamage_0 db 'damage',0                 ; DATA XREF: sub_4224B0+5C0o
    align 4
    aReproducearea db 'reproducearea',0     ; DATA XREF: sub_4224B0+577o
    align 4
    aReproduce db 'reproduce',0             ; DATA XREF: sub_4224B0+563o
    align 4
    aSpreadchance db 'spreadchance',0       ; DATA XREF: sub_4224B0+54Fo
    align 4
    aSeqnamerecla_0 db 'seqnamereclamateshad',0 ; DATA XREF: sub_4224B0+504o
    align 4
    aSeqnamereclama db 'seqnamereclamate',0 ; DATA XREF: sub_4224B0+4AFo
    align 4
    aSeqnamedieshad db 'seqnamedieshad',0   ; DATA XREF: sub_4224B0+45Ao
    align 4
    aSeqnamedie db 'seqnamedie',0           ; DATA XREF: sub_4224B0+405o
    align 4
    aSeqnameburnsha db 'seqnameburnshad',0  ; DATA XREF: sub_4224B0+3B0o
    aSeqnameburn db 'seqnameburn',0         ; DATA XREF: sub_4224B0+35Bo
    aSeqnameshad db 'seqnameshad',0         ; DATA XREF: sub_4224B0+306o
    aSeqname db 'seqname',0                 ; DATA XREF: sub_4224B0+2B1o
    aAnims db 'anims',0                     ; DATA XREF: sub_4224B0+262o
                                            ; sub_429700+58o ...
    align 4
    off_502E38 dd offset loc_464146+1       ; DATA XREF: sub_4224B0+255o
                                            ; sub_429700+4Eo ...
    aReuse db 'REUSE',0                     ; DATA XREF: sub_4224B0+212o
    align 4
    aFilename db 'filename',0               ; DATA XREF: sub_4224B0+18Bo
                                            ; .text:004AE476o ...
    align 4
    aObject db 'object',0                   ; DATA XREF: sub_4224B0+137o
    align 4
    aHeight db 'height',0                   ; DATA XREF: sub_4224B0+11Co
                                            ; sub_4ACE50+28Eo ...
    align 4
    aFootprintz db 'footprintz',0           ; DATA XREF: sub_4224B0+107o
    align 4
    aFootprintx db 'footprintx',0           ; DATA XREF: sub_4224B0+F2o
    align 4
    aDescription db 'Description',0         ; DATA XREF: sub_4224B0+E3o
                                            ; sub_4326B0+2C3o ...
    aFeatures_0 db 'FEATURES',0             ; DATA XREF: sub_4224B0+8Do
    align 4
    aRecordSMissing db 'Record "%s" missing from feature files',0 ; DATA XREF: sub_4224B0+5Co
    align 4
    aFeatureburnt db 'featureburnt',0       ; DATA XREF: sub_422EA0+1DFo
    align 4
    aFeaturereclama db 'featurereclamate',0 ; DATA XREF: sub_422EA0+137o
    align 4
    aFeaturedead db 'featuredead',0         ; DATA XREF: sub_422EA0+8Fo
    aTreeburn db 'treeburn',0               ; DATA XREF: sub_4233A0+160o
    align 4
    aNormalFeatures db 'Normal Features',0  ; DATA XREF: sub_424890+323o
                                            ; sub_424C00+358o
    aNumberOfAnimat db 'Number of Animating Features',0 ; DATA XREF: sub_424890+2F1o
                                            ; sub_424C00+3D5o
    align 4
    aNumberOf3dFeat db 'Number of 3D Features',0 ; DATA XREF: sub_424890+2DEo
                                            ; sub_424C00+503o
    align 4
    aNumberOfNormal db 'Number of Normal Features',0 ; DATA XREF: sub_424890+2CFo
                                            ; sub_424C00+34Co
    align 4
    aAnimatingFeatu db 'Animating Features',0 ; DATA XREF: sub_424890+264o
                                            ; sub_424C00+3E1o
    align 4
    a3dFeatures db '3D Features',0          ; DATA XREF: sub_424890+174o
                                            ; sub_424C00+50Fo
    aFeatureTypeNam db 'Feature Type Names',0 ; DATA XREF: sub_424890+B1o
                                            ; sub_424C00+38o
    align 4
    aFeatures_1 db 'Features',0             ; DATA XREF: sub_424890+11o
                                            ; sub_424C00+11o
    align 4
    dd 10h
    aCodeSegmentChe db 'Code segment checksum error found when switching FE states.',0Ah
                                            ; DATA XREF: .text:004256F3o
                                            ; sub_4257E0+23o ...
    db 'State change called from [line %d, file %s]',0
    aCCavedogWargam db 'c:\cavedog\wargame\frontend.cpp',0 ; DATA XREF: sub_425860+6Co
                                            ; .text:00425955o ...
    aCredits db 'Credits',0                 ; DATA XREF: sub_425D80+31Do
    aExit_0 db 'exit',0                     ; DATA XREF: sub_425D80+2F6o
    align 4
    aExit db 'EXIT',0                       ; DATA XREF: sub_425D80+2E5o
                                            ; sub_4609B0+2B6o
    align 4
    aPleaseInsertAT db 'Please insert a Total Annihilation CD and try again',0
                                            ; DATA XREF: sub_425D80+1AEo
                                            ; sub_425D80+3A5o
    aDebugYouMustBe db 'Debug:  You must be in full-screen mode to play a movie.',0
                                            ; DATA XREF: sub_425D80+185o
                                            ; sub_425D80+35Fo
    align 4
    aSmlbutton_1 db 'smlButton',0           ; DATA XREF: sub_425D80+164o
                                            ; sub_425D80+332o
    align 4
    aIntro db 'INTRO',0                     ; DATA XREF: sub_425D80+14Fo
    align 4
    aPleaseInsert_1 db 'Please insert the Multiplayer CD (Disc 1) and try again',0
                                            ; DATA XREF: sub_425D80+10Do
                                            ; .text:004603A5o ...
    aMaps_0 db 'maps',0                     ; DATA XREF: sub_425D80+9Eo
    align 4
    aMultiplay db 'multiplay',0             ; DATA XREF: sub_425D80+95o
    align 4
    aTdf db 'tdf',0                         ; DATA XREF: sub_425D80+90o
                                            ; sub_429000+10o ...
    aMulti db 'MULTI',0                     ; DATA XREF: sub_425D80+65o
    align 4
    aSingle_0 db 'SINGLE',0                 ; DATA XREF: sub_425D80+2Co
    align 4
    aChoice2 db 'CHOICE2',0                 ; DATA XREF: .text:004261D9o
                                            ; sub_426200+58o ...
    aChoice1 db 'CHOICE1',0                 ; DATA XREF: .text:004261B3o
                                            ; sub_426200+44o ...
    aSmallbutton db 'SmallButton',0         ; DATA XREF: .text:004261A6o
                                            ; .text:00478DE2o ...
    aTitle db 'TITLE',0                     ; DATA XREF: sub_426200+161o
                                            ; sub_446080+67o ...
    align 4
    aCloseWindowsCd db 'Close Windows CD Player?',0 ; DATA XREF: sub_426200+129o
    align 4
    aNo db 'No',0                           ; DATA XREF: sub_426200+110o
                                            ; sub_441460+4BEo ...
    align 4
    aYes db 'Yes',0                         ; DATA XREF: sub_426200+83o
                                            ; sub_441460+4B0o ...
    aYesorno_gui db 'YESORNO.GUI',0         ; DATA XREF: sub_426200+13o
                                            ; sub_446080+1Eo ...
    aNoSoundDriverI db 'No sound driver is available for use.',0Ah,0
                                            ; DATA XREF: .text:0042672Co
    align 4
    ; char byte_50319C
    byte_50319C db 0Ah                      ; DATA XREF: .text:004266A9o
                                            ; .text:004266AEo ...
    align 4
    aSparks db 'SPARKS',0                   ; DATA XREF: .text:00426640o
    align 4
    aDebugstring db 'DebugString',0         ; DATA XREF: .text:0042657Co
                                            ; .text:004265C3o ...
    aV3_1 db 'v3.1',0                       ; DATA XREF: .text:00426551o
    align 4
    aPalettes db 'palettes',0               ; DATA XREF: .text:004264DDo
                                            ; sub_429330+1Co ...
    align 4
    aGuipal db 'guipal',0                   ; DATA XREF: .text:004264D4o
                                            ; sub_497F40+1CEo
    align 4
    off_5031D0 dd offset loc_4C4150         ; DATA XREF: .text:004264CFo
                                            ; sub_429330+16o ...
    ; char off_5031D4
    off_5031D4 dd offset loc_4D4742         ; DATA XREF: .text:0042644Eo
                                            ; sub_45DA90+2C8o
    aFrontendx db 'FrontendX',0             ; DATA XREF: .text:0042642Do
                                            ; .text:00426479o ...
    align 4
    aMainmenu_gui db 'MAINMENU.GUI',0       ; DATA XREF: .text:0042641Co
    align 4
    aData db 'Data',0                       ; DATA XREF: .text:0042679Co
                                            ; sub_484F50+17o ...
    align 4
    aZrb db 'zrb',0                         ; DATA XREF: .text:00426792o
    aWarpDmission db 'warp%dmission',0      ; DATA XREF: .text:00426943o
                                            ; .text:00426B33o
    align 4
    aWarplevels db 'WARPLEVELS',0           ; DATA XREF: .text:00426933o
                                            ; .text:0042695Do ...
    align 4
    aDefault db 'default',0                 ; DATA XREF: .text:0042692Do
                                            ; .text:00426B1Do ...
    aWarpDcampaign db 'warp%dcampaign',0    ; DATA XREF: .text:00426909o
                                            ; .text:00426AF1o
    align 4
    aWarp_ini db '\Warp.ini',0              ; DATA XREF: .text:004268C6o
                                            ; .text:00426ABDo
    align 4
    aMainmenu_0 db 'MAINMENU',0             ; DATA XREF: .text:00426BDCo
                                            ; sub_460800+1Bo ...
    align 4
    aAnErrorOccurre db 'An error occurred trying to use this service',0
    align 4
    a4_zrb db '4.zrb',0
    align 4
    a3_zrb db '3.zrb',0
    align 4
    a5_zrb db '5.zrb',0
    align 4
    a2_zrb db '2.zrb',0
    align 4
    a1_zrb db '1.zrb',0
    align 4
    aParseErrorRead db 'parse error reading AI profile %s',0Ah ; DATA XREF: .text:00428F01o
                                            ; .text:00428F94o
    db '%s',0Ah
    db 'last string =',0
    align 4
    aExpectingInt db 'expecting int',0      ; DATA XREF: .text:00428EEAo
    align 4
    aTotalAnnihil_0 db 'Total Annihilation',0 ; DATA XREF: .text:0042F939o
                                            ; sub_42F960+Fo ...
    dd 0
    align 4
    aTotalAnnihil_1 db 'Total Annihilation\Skirmish',0
                                            ; DATA XREF: WriteRegistrySettings_1+129Bo
                                            ; WriteRegistrySettings_1+12DFo ...
    dword_50331C dd 50332Ch                 ; DATA XREF: sub_432520+21r
                                            ; sub_4325B0+1Cr ...
    ; char *off_503320
    off_503320 dd offset aSummary_0         ; DATA XREF: sub_432520+1Cr
                                            ; sub_432520+53r ...
                                            ; "Summary"
    aSummary_0 db 'Summary',0               ; DATA XREF: .text:0047C518o
                                            ; .data:00503320o
    aTotalAnnihil_2 db 'Total Annihilation 3.0',0
    align 4
    aV3_0 db 'v3.0',0                       ; DATA XREF: sub_429000+7Bo
    align 4
    aGpfversion db 'GPFVersion',0           ; DATA XREF: sub_429000+62o
    align 4
    aVersion db 'Version',0                 ; DATA XREF: sub_429000+41o
                                            ; sub_42A8D0+744o ...
    aGamedata db 'gamedata',0               ; DATA XREF: sub_429000+1Eo
                                            ; sub_429870+641o ...
    align 4
    aVersion_1 db 'version',0               ; DATA XREF: sub_429000+15o
    ; char byte_503374
    byte_503374 db '\'                      ; DATA XREF: sub_4290F0+D5o
                                            ; sub_495930+3Co ...
    align 4
    aSSS db '%s-%s\%s',0                    ; DATA XREF: sub_4290F0+24o
                                            ; sub_435430+B3o
    align 4
    aBitmaps db 'bitmaps',0                 ; DATA XREF: sub_429290+15o
                                            ; .text:0047676Eo
    aFonts db 'fonts',0                     ; DATA XREF: .text:004292F5o
                                            ; sub_42A320+15o ...
    align 4
    aFnt db 'FNT',0                         ; DATA XREF: .text:004292EFo
                                            ; sub_42A320+Bo ...
    off_503398 dd offset loc_444851+2       ; DATA XREF: sub_429330+106o
                                            ; sub_42E1D0+Bo
    dword_50339C dd 54484Ch                 ; DATA XREF: sub_429330+E3o
                                            ; sub_42E260+Bo
    off_5033A0 dd offset aNoDescriptionA+5  ; DATA XREF: sub_429330+C0o
                                            ; sub_42E140+Bo
    aPalette_0 db 'PALETTE',0               ; DATA XREF: sub_429330+70o
                                            ; sub_429330+C5o ...
    aRadarpic db 'RADARPIC',0               ; DATA XREF: sub_4295B0+58o
    align 4
    aAnimationFiles db 'Animation Files',0  ; DATA XREF: sub_429700+9Bo
    aPanelbot db 'PANELBOT',0               ; DATA XREF: sub_429870+751o
    align 4
    aPanelside db 'PANELSIDE',0             ; DATA XREF: sub_429870+739o
    align 4
    aPaneltop db 'PANELTOP',0               ; DATA XREF: sub_429870+721o
    align 4
    aIntgaf db 'intgaf',0                   ; DATA XREF: sub_429870+6FCo
    align 4
    aSideD db 'SIDE%d',0                    ; DATA XREF: sub_429870+6C0o
                                            ; sub_431A60+54o ...
    align 4
    aBaseheight db 'baseheight',0           ; DATA XREF: sub_429870+691o
    align 4
    aGeneral db 'GENERAL',0                 ; DATA XREF: sub_429870+65Eo
    aSidedata db 'sidedata',0               ; DATA XREF: sub_429870+638o
                                            ; sub_42D2E0+65Co ...
    align 4
    off_50341C dd offset loc_464454         ; DATA XREF: sub_429870+633o
                                            ; sub_42A8D0+B0o ...
    aCursorrevive db 'cursorrevive',0       ; DATA XREF: sub_429870+60Do
    align 4
    aPathicon db 'pathicon',0               ; DATA XREF: sub_429870+5F6o
    align 4
    aCursorhourglas db 'cursorhourglass',0  ; DATA XREF: sub_429870+5DFo
    aCursornormal db 'cursornormal',0       ; DATA XREF: sub_429870+5C8o
    align 4
    aCursorgrn db 'cursorgrn',0             ; DATA XREF: sub_429870+5B1o
    align 4
    aCursorred db 'cursorred',0             ; DATA XREF: sub_429870+59Ao
    align 4
    aCursorfindsite db 'cursorfindsite',0   ; DATA XREF: sub_429870+583o
    align 4
    aCursorselect db 'cursorselect',0       ; DATA XREF: sub_429870+56Co
    align 4
    aCursormove db 'cursormove',0           ; DATA XREF: sub_429870+555o
    align 4
    aCursorunload db 'cursorunload',0       ; DATA XREF: sub_429870+53Eo
    align 4
    aCursorload db 'cursorload',0           ; DATA XREF: sub_429870+527o
    align 4
    aCursorreclamat db 'cursorreclamate',0  ; DATA XREF: sub_429870+510o
    aCursorteleport db 'cursorteleport',0   ; DATA XREF: sub_429870+4F9o
    align 4
    aCursorpickup db 'cursorpickup',0       ; DATA XREF: sub_429870+4E2o
    align 4
    aCursorpatrol db 'cursorpatrol',0       ; DATA XREF: sub_429870+4CBo
    align 4
    aCursorrepair db 'cursorrepair',0       ; DATA XREF: sub_429870+4B4o
    align 4
    aCursordefend db 'cursordefend',0       ; DATA XREF: sub_429870+49Do
    align 4
    aCursorcapture db 'cursorcapture',0     ; DATA XREF: sub_429870+486o
    align 4
    aCursortoofar db 'cursortoofar',0       ; DATA XREF: sub_429870+46Fo
    align 4
    aCursorairstrik db 'cursorairstrike',0  ; DATA XREF: sub_429870+458o
    aCursorattack db 'cursorattack',0       ; DATA XREF: sub_429870+435o
    align 4
    aCursors db 'cursors',0                 ; DATA XREF: sub_429870+41Fo
    aGray4 db 'Gray4',0                     ; DATA XREF: sub_429870+408o
    align 4
    aGray3 db 'Gray3',0                     ; DATA XREF: sub_429870+3F1o
    align 4
    aGray2 db 'Gray2',0                     ; DATA XREF: sub_429870+3DAo
    align 4
    aGray1 db 'Gray1',0                     ; DATA XREF: sub_429870+3C3o
    align 4
    aBlack4 db 'Black4',0                   ; DATA XREF: sub_429870+3ACo
    align 4
    aBlack3 db 'Black3',0                   ; DATA XREF: sub_429870+395o
    align 4
    aBlack2 db 'Black2',0                   ; DATA XREF: sub_429870+37Eo
    align 4
    aBlack1 db 'Black1',0                   ; DATA XREF: sub_429870+35Bo
    align 4
    aFog db 'fog',0                         ; DATA XREF: sub_429870+345o
    aVismask db 'vismask',0                 ; DATA XREF: sub_429870+323o
    aVismasks db 'vismasks',0               ; DATA XREF: sub_429870+30Do
    align 4
    aIgpaused db 'igpaused',0               ; DATA XREF: sub_429870+2F6o
    align 4
    aIgdefeat db 'igdefeat',0               ; DATA XREF: sub_429870+2DFo
    align 4
    aIgvictory db 'igvictory',0             ; DATA XREF: sub_429870+2BDo
    align 4
    aIgtitles db 'igtitles',0               ; DATA XREF: sub_429870+2A7o
    align 4
    aShadow db 'shadow',0                   ; DATA XREF: sub_429870+281o
    align 4
    aNuke1 db 'nuke1',0                     ; DATA XREF: sub_429870+25Bo
    align 4
    aExplode5 db 'explode5',0               ; DATA XREF: sub_429870+235o
    align 4
    aExplode4 db 'explode4',0               ; DATA XREF: sub_429870+20Fo
    align 4
    aExplode3 db 'explode3',0               ; DATA XREF: sub_429870+1E9o
    align 4
    aExplode2 db 'explode2',0               ; DATA XREF: sub_429870+1C3o
    align 4
    aExplosion db 'explosion',0             ; DATA XREF: sub_429870+1ACo
    align 4
    aFlamestream db 'flamestream',0         ; DATA XREF: sub_429870+195o
    aUltrashell db 'ultrashell',0           ; DATA XREF: sub_429870+167o
    align 4
    aPlasmamd db 'plasmamd',0               ; DATA XREF: sub_429870+150o
    align 4
    aPlasmasm db 'plasmasm',0               ; DATA XREF: sub_429870+139o
                                            ; sub_429870+17Eo
    align 4
    aCannonshell db 'cannonshell',0         ; DATA XREF: sub_429870+113o
    aLavasplash db 'lavasplash',0           ; DATA XREF: sub_429870+EDo
    align 4
    aH2oboom2 db 'h2oboom2',0               ; DATA XREF: sub_429870+D6o
    align 4
    aNuclogo db 'nuclogo',0                 ; DATA XREF: sub_429870+BFo
    aRadlogohigh db 'radlogohigh',0         ; DATA XREF: sub_429870+A8o
    aRadlogo db 'radlogo',0                 ; DATA XREF: sub_429870+83o
    aAlfboom1 db 'alfboom1',0               ; DATA XREF: sub_429870+6Ao
    align 4
    aFire1 db 'fire1',0                     ; DATA XREF: sub_429870+53o
    align 4
    aSmoke2 db 'smoke 2',0                  ; DATA XREF: sub_429870+3Co
    aSmoke1 db 'smoke 1',0                  ; DATA XREF: sub_429870+19o
    aFx db 'fx',0                           ; DATA XREF: sub_429870+9o
    align 4
    aAnimplayPointe db 'Animplay Pointers',0 ; DATA XREF: .text:0042A0F9o
                                            ; sub_42A140+10Fo
    align 4
    aObjects3d db 'objects3d',0             ; DATA XREF: sub_42A2C0+19o
                                            ; sub_42D2E0+473o ...
    align 4
    off_5036F0 dd offset dword_4F4433       ; DATA XREF: sub_42A2C0+13o
                                            ; sub_42D2E0+46Do ...
    aSmlfont db 'smlfont',0                 ; DATA XREF: sub_42A320+46o
    aComix db 'COMIX',0                     ; DATA XREF: sub_42A320+10o
    align 4
    aLogos_gaf db 'logos.GAF',0             ; DATA XREF: sub_42A440+87o
    align 4
    aTexturePtrs db 'TEXTURE PTRS',0        ; DATA XREF: sub_42A440+3Bo
    align 4
    aTextures db 'textures',0               ; DATA XREF: sub_42A440+17o
                                            ; sub_42A440+AFo ...
    align 4
    asc_50372C:                             ; DATA XREF: sub_42A440+12o
                                            ; sub_42A610+B5o ...
    unicode 0, <*>,0
    aDownload db 'download',0               ; DATA XREF: sub_42A610+194o
                                            ; sub_42DCF0+1Eo ...
    align 4
    aGui db 'gui',0                         ; DATA XREF: sub_42A610+AEo
                                            ; sub_42A610+138o
    aScripts db 'scripts',0                 ; DATA XREF: sub_42A610+3Fo
                                            ; sub_42D1F0+94o ...
    aCob db 'cob',0                         ; DATA XREF: sub_42A610+39o
    aIncompatibleUn db 'Incompatible units found.  They will be ignored.  Please dow'
                                            ; DATA XREF: sub_42A8D0+A3Bo
    db 'nload the latest version of the game.',0
    align 4
    aCopyright db 'Copyright',0             ; DATA XREF: sub_42A8D0+827o
    align 4
    aRunToTheVillag db 'Run to the Village!  Warn your brother!',0 ; DATA XREF: sub_42A8D0+816o
    aSelfdestructas db 'selfdestructas',0   ; DATA XREF: sub_42A8D0+6C9o
                                            ; sub_42BF40+F8Eo
    align 4
    aExplodeas db 'explodeas',0             ; DATA XREF: sub_42A8D0+653o
                                            ; sub_42BF40+F4Bo
    align 4
    aWeapon3 db 'weapon3',0                 ; DATA XREF: sub_42A8D0+5DCo
                                            ; sub_42BF40+F16o
    aWeapon2 db 'weapon2',0                 ; DATA XREF: sub_42A8D0+565o
                                            ; sub_42BF40+EE3o
    aWeapon1 db 'weapon1',0                 ; DATA XREF: sub_42A8D0+4F5o
                                            ; sub_42BF40+E9Eo
    aWacky db 'wacky',0                     ; DATA XREF: sub_42A8D0+4C9o
    align 4
    aNorestrict db 'norestrict',0           ; DATA XREF: sub_42A8D0+49Ao
                                            ; sub_42BF40+BE9o
    align 4
    aBuildcostmetal db 'buildcostmetal',0   ; DATA XREF: sub_42A8D0+47Co
                                            ; sub_42BF40+1BEo
    align 4
    aBuildcostenerg db 'buildcostenergy',0  ; DATA XREF: sub_42A8D0+470o
                                            ; sub_42BF40+1B3o
    aObjectname db 'objectname',0           ; DATA XREF: sub_42A8D0+440o
                                            ; sub_42BF40+182o
    align 4
    aAi_limit db 'ai_limit',0               ; DATA XREF: sub_42A8D0+420o
    align 4
    aAi_weight db 'ai_weight',0             ; DATA XREF: sub_42A8D0+408o
    align 4
    aSide db 'side',0                       ; DATA XREF: sub_42A8D0+3ECo
                                            ; WriteRegistrySettings_1+11Bo ...
    align 4
    aUnitname db 'unitname',0               ; DATA XREF: sub_42A8D0+3D0o
                                            ; sub_42BF40+61o
    align 4
    aName db 'name',0                       ; DATA XREF: sub_42A8D0+3B2o
                                            ; sub_42BF40+70o ...
    align 4
    aNoFile db '<NO FILE>',0                ; DATA XREF: sub_42A8D0+382o
    align 4
    aU db '%u',0                            ; DATA XREF: sub_42A8D0+350o
    align 4
    aCompatability db 'Compatability',0     ; DATA XREF: sub_42A8D0+333o
    align 4
    aTaUnitOverride db 'TA Unit Override',0 ; DATA XREF: sub_42A8D0+320o
    align 4
    off_5038C0 dd offset dword_52564F       ; DATA XREF: sub_42A8D0+2FBo
    aNone db 'None',0                       ; DATA XREF: sub_42A8D0+1FBo
                                            ; sub_45C220+CBo ...
    align 4
    aCopyright0000H db 'Copyright 0000 Humongous Entertainment. All rights reserved.'
                                            ; DATA XREF: sub_42A8D0+1EFo
                                            ; sub_42A8D0+249o ...
    db 0
    align 4
    a0000 db '0000',0                       ; DATA XREF: sub_42A8D0+1E7o
                                            ; sub_42A8D0+832r ...
    align 4
    aUnitinfo db 'UNITINFO',0               ; DATA XREF: sub_42A8D0+1B1o
                                            ; sub_42A8D0+398o ...
    align 4
    aUnits db 'units',0                     ; DATA XREF: sub_42A8D0+155o
                                            ; sub_42A8D0+298o ...
    align 4
    off_503928 dd offset sub_494246         ; DATA XREF: sub_42A8D0+147o
                                            ; sub_42A8D0+26Eo ...
    aWeapons db 'Weapons',0                 ; DATA XREF: sub_42A8D0+BBo
                                            ; sub_42E310+8Bo
    aWeapons_tdf db 'Weapons\*.tdf',0       ; DATA XREF: sub_42A8D0+1Co
                                            ; sub_42E310+40o
    align 4
    aHeySomebodyFor db 'Hey!  Somebody forgot to set downloadable=1 for %s',0
                                            ; DATA XREF: .text:0042BDA7o
                                            ; sub_42DCF0+380o
    align 4
    aBuildingYard db 'BUILDING YARD',0      ; DATA XREF: sub_42BF40+1030o
    align 4
    aYardmap db 'YardMap',0                 ; DATA XREF: sub_42BF40+1013o
    aMovementclass db 'movementclass',0     ; DATA XREF: sub_42BF40+DC6o
    align 4
    aCorpse db 'corpse',0                   ; DATA XREF: sub_42BF40+D8Ao
    align 4
    aSoundcategory db 'soundcategory',0     ; DATA XREF: sub_42BF40+D14o
    align 4
    aCategory db 'category',0               ; DATA XREF: sub_42BF40+CEEo
    align 4
    aSelfdestructco db 'selfdestructcountdown',0 ; DATA XREF: sub_42BF40+C88o
    align 4
    aCantbetranspor db 'cantbetransported',0 ; DATA XREF: sub_42BF40+C66o
    align 4
    aCommander db 'commander',0             ; DATA XREF: sub_42BF40+C3Do
                                            ; sub_431A60+113o
    align 4
    aShowplayername db 'showplayername',0   ; DATA XREF: sub_42BF40+C10o
    align 4
    aKamikazedistan db 'kamikazedistance',0 ; DATA XREF: sub_42BF40+BD8o
                                            ; sub_4390A0+35Fo
    align 4
    aKamikaze db 'kamikaze',0               ; DATA XREF: sub_42BF40+BAAo
    align 4
    aAttackrunlengt db 'attackrunlength',0  ; DATA XREF: sub_42BF40+B94o
    aManeuverleashl db 'maneuverleashlength',0 ; DATA XREF: sub_42BF40+B7Fo
    aCandgun db 'candgun',0                 ; DATA XREF: sub_42BF40+B63o
    aCancapture db 'cancapture',0           ; DATA XREF: sub_42BF40+B08o
    align 4
    aCanresurrect db 'canresurrect',0       ; DATA XREF: sub_42BF40+AD5o
    align 4
    aCanreclamate db 'canreclamate',0       ; DATA XREF: sub_42BF40+AAFo
    align 4
    aCanload db 'canload',0                 ; DATA XREF: sub_42BF40+A89o
    aCanmove db 'canmove',0                 ; DATA XREF: sub_42BF40+A63o
    aCanpatrol db 'canpatrol',0             ; DATA XREF: sub_42BF40+A3Do
    align 4
    aCanguard db 'canguard',0               ; DATA XREF: sub_42BF40+A17o
    align 4
    aCanattack db 'canattack',0             ; DATA XREF: sub_42BF40+9F1o
    align 4
    aCanstop db 'canstop',0                 ; DATA XREF: sub_42BF40+9CBo
    aFirestandorder db 'firestandorders',0  ; DATA XREF: sub_42BF40+99Do
    aMobilestandord db 'mobilestandorders',0 ; DATA XREF: sub_42BF40+984o
    align 4
    aOnoffable db 'onoffable',0             ; DATA XREF: sub_42BF40+95Ao
    align 4
    aDigger db 'digger',0                   ; DATA XREF: sub_42BF40+935o
    align 4
    aAntiweapons db 'antiweapons',0         ; DATA XREF: sub_42BF40+90Co
    aHoverattack db 'hoverattack',0         ; DATA XREF: sub_42BF40+8E3o
    aImmunetoparaly db 'immunetoparalyzer',0 ; DATA XREF: sub_42BF40+8BAo
    align 4
    aNoshadow db 'noshadow',0               ; DATA XREF: sub_42BF40+891o
    align 4
    aIsfeature db 'isfeature',0             ; DATA XREF: sub_42BF40+868o
    align 4
    aAmphibious db 'amphibious',0           ; DATA XREF: sub_42BF40+83Fo
    align 4
    aFloater db 'floater',0                 ; DATA XREF: sub_42BF40+816o
    aUpright db 'upright',0                 ; DATA XREF: sub_42BF40+7EDo
    aCanhover db 'canhover',0               ; DATA XREF: sub_42BF40+7C1o
    align 4
    aCanfly db 'canfly',0                   ; DATA XREF: sub_42BF40+7A1o
    align 4
    aActivatewhenbu db 'activatewhenbuilt',0 ; DATA XREF: sub_42BF40+778o
    align 4
    aArmoredstate db 'armoredstate',0       ; DATA XREF: sub_42BF40+74Fo
    align 4
    aShootme db 'shootme',0                 ; DATA XREF: sub_42BF40+725o
    aHidedamage db 'hidedamage',0           ; DATA XREF: sub_42BF40+703o
    align 4
    aTeleporter db 'teleporter',0           ; DATA XREF: sub_42BF40+6DDo
    align 4
    aIstargetingupg db 'istargetingupgrade',0 ; DATA XREF: sub_42BF40+6B7o
    align 4
    aIsairbase db 'isairbase',0             ; DATA XREF: sub_42BF40+68Bo
    align 4
    aZbuffer db 'zbuffer',0                 ; DATA XREF: sub_42BF40+666o
    aCruisealt db 'cruisealt',0             ; DATA XREF: sub_42BF40+650o
    align 4
    aSortbias db 'sortbias',0               ; DATA XREF: sub_42BF40+63Ao
    align 4
    aBuilddistance db 'builddistance',0     ; DATA XREF: sub_42BF40+624o
    align 4
    aBuildangle db 'buildangle',0           ; DATA XREF: sub_42BF40+60Eo
    align 4
    aMincloakdistan db 'mincloakdistance',0 ; DATA XREF: sub_42BF40+5F1o
    align 4
    aCloakcostmovin db 'cloakcostmoving',0  ; DATA XREF: sub_42BF40+5E6o
    aCloakcost db 'cloakcost',0             ; DATA XREF: sub_42BF40+5BEo
    align 4
    aStealth db 'stealth',0                 ; DATA XREF: sub_42BF40+598o
    aBuilder db 'builder',0                 ; DATA XREF: sub_42BF40+572o
    aDownloadable db 'downloadable',0       ; DATA XREF: sub_42BF40+54Co
    align 4
    aInit_cloaked db 'init_cloaked',0       ; DATA XREF: sub_42BF40+526o
    align 4
    aStandingfireor db 'standingfireorder',0 ; DATA XREF: sub_42BF40+4F7o
    align 4
    aStandingmoveor db 'standingmoveorder',0 ; DATA XREF: sub_42BF40+4D9o
    align 4
    aBmcode db 'bmcode',0                   ; DATA XREF: sub_42BF40+4C2o
    align 4
    aSonardistancej db 'sonardistancejam',0 ; DATA XREF: sub_42BF40+4ACo
    align 4
    aRadardistancej db 'radardistancejam',0 ; DATA XREF: sub_42BF40+496o
    align 4
    aSonardistance db 'sonardistance',0     ; DATA XREF: sub_42BF40+480o
    align 4
    aRadardistance db 'radardistance',0     ; DATA XREF: sub_42BF40+46Ao
    align 4
    aSightdistance db 'sightdistance',0     ; DATA XREF: sub_42BF40+455o
    align 4
    aMaxdamage db 'maxdamage',0             ; DATA XREF: sub_42BF40+43Fo
    align 4
    aHealtime db 'healtime',0               ; DATA XREF: sub_42BF40+429o
    align 4
    aWorkertime db 'workertime',0           ; DATA XREF: sub_42BF40+414o
    align 4
    aBuildtime db 'buildtime',0             ; DATA XREF: sub_42BF40+3FFo
    align 4
    aMetalstorage db 'metalstorage',0       ; DATA XREF: sub_42BF40+3F4o
    align 4
    aEnergystorage db 'energystorage',0     ; DATA XREF: sub_42BF40+3D8o
    align 4
    aTidalgenerator db 'tidalgenerator',0   ; DATA XREF: sub_42BF40+3C2o
    align 4
    aWindgenerator db 'windgenerator',0     ; DATA XREF: sub_42BF40+3ACo
    align 4
    aMakesmetal db 'makesmetal',0           ; DATA XREF: sub_42BF40+392o
    align 4
    aExtractsmetal db 'extractsmetal',0     ; DATA XREF: sub_42BF40+381o
    align 4
    aMetalmake db 'metalmake',0             ; DATA XREF: sub_42BF40+36Bo
    align 4
    aEnergyuse db 'energyuse',0             ; DATA XREF: sub_42BF40+355o
    align 4
    aEnergymake db 'energymake',0           ; DATA XREF: sub_42BF40+33Fo
    align 4
    aTransportcapac db 'transportcapacity',0 ; DATA XREF: sub_42BF40+325o
    align 4
    aTransportsize db 'transportsize',0     ; DATA XREF: sub_42BF40+310o
    align 4
    aWaterline db 'waterline',0             ; DATA XREF: sub_42BF40+2FAo
    align 4
    aTurnrate db 'turnrate',0               ; DATA XREF: sub_42BF40+2EFo
                                            ; sub_42E440+1BCo
    align 4
    aMoverate2_0 db 'moverate2',0           ; DATA XREF: sub_42BF40+2D7o
    align 4
    aMoverate1_0 db 'moverate1',0           ; DATA XREF: sub_42BF40+2AFo
    align 4
    aDamagemodifier db 'damagemodifier',0   ; DATA XREF: sub_42BF40+28Fo
    align 4
    aPitchscale db 'pitchscale',0           ; DATA XREF: sub_42BF40+268o
    align 4
    aBankscale db 'bankscale',0             ; DATA XREF: sub_42BF40+24Co
    align 4
    aAcceleration db 'acceleration',0       ; DATA XREF: sub_42BF40+22Fo
    align 4
    aBrakerate db 'brakerate',0             ; DATA XREF: sub_42BF40+20Bo
    align 4
    aMaxvelocity db 'maxvelocity',0         ; DATA XREF: sub_42BF40+1E9o
    aNochasecategor db 'noChaseCategory',0  ; DATA XREF: sub_42BF40+14Co
    aWspe_badtarget db 'wspe_badTargetCategory',0 ; DATA XREF: sub_42BF40+126o
    align 4
    aWsec_badtarget db 'wsec_badTargetCategory',0 ; DATA XREF: sub_42BF40+102o
    align 4
    aWpri_badtarget db 'wpri_badTargetCategory',0 ; DATA XREF: sub_42BF40+CEo
    align 4
    aNone_0 db 'none',0                     ; DATA XREF: sub_42BF40+BFo
                                            ; sub_42BF40+F3o ...
    align 4
    aDefaultmission db 'defaultmissiontype',0 ; DATA XREF: sub_42BF40+A2o
    align 4
    aDescription_0 db 'description',0       ; DATA XREF: sub_42BF40+87o
    off_503EC8 dd offset loc_424F3E+5       ; DATA XREF: sub_42D1F0+8Ao
                                            ; sub_42D2E0+5F5o
    aCanbuildS db 'CANBUILD %s',0           ; DATA XREF: sub_42D2E0+7D2o
    aCanbuildD db 'canbuild%d',0            ; DATA XREF: sub_42D2E0+734o
                                            ; sub_42D2E0+789o
    align 4
    aCanbuild db 'CANBUILD',0               ; DATA XREF: sub_42D2E0+6FCo
    align 4
    aTempUtypeList db 'TEMP UTYPE LIST',0   ; DATA XREF: sub_42D2E0+693o
    aCanTLoadGameda db 'Can',27h,'t load GAMEDATA.TDF',0 ; DATA XREF: sub_42D2E0+682o
    aS0 db '%s0',0                          ; DATA XREF: sub_42D2E0+52Eo
    aModelPtrs db 'MODEL PTRS',0            ; DATA XREF: sub_42D2E0+3AEo
    align 4
    aClassD db 'CLASS%d',0                  ; DATA XREF: sub_42D2E0+59o
    aCanTLoadMovein db 'Can',27h,'t load MOVEINFO.TDF',0 ; DATA XREF: sub_42D2E0+3Eo
    aMoveinfo db 'moveinfo',0               ; DATA XREF: sub_42D2E0+18o
    align 4
    aUnitname_1 db 'UNITNAME',0             ; DATA XREF: sub_42DCF0+1EAo
                                            ; sub_431A60+931o
    align 4
    aButton db 'BUTTON',0                   ; DATA XREF: sub_42DCF0+1C3o
    align 4
    aMenu db 'MENU',0                       ; DATA XREF: sub_42DCF0+1A0o
    align 4
    aUnitmenu db 'UNITMENU',0               ; DATA XREF: sub_42DCF0+11Co
    align 4
    aDownloadmenu db 'DOWNLOADMENU',0       ; DATA XREF: sub_42DCF0+7Fo
    align 4
    aDamage db 'DAMAGE',0                   ; DATA XREF: sub_42E440+B3Fo
    align 4
    aSoundwater db 'soundwater',0           ; DATA XREF: sub_42E440+B13o
    align 4
    aSoundhit db 'soundhit',0               ; DATA XREF: sub_42E440+AD9o
    align 4
    aSoundstart db 'soundstart',0           ; DATA XREF: sub_42E440+A9Ao
    align 4
    aWaterexplosi_0 db 'waterexplosionart',0 ; DATA XREF: sub_42E440+A5Co
    align 4
    aWaterexplosion db 'waterexplosiongaf',0 ; DATA XREF: sub_42E440+A3Do
    align 4
    aLavaexplosiona db 'lavaexplosionart',0 ; DATA XREF: sub_42E440+A11o
    align 4
    aLavaexplosiong db 'lavaexplosiongaf',0 ; DATA XREF: sub_42E440+9EEo
    align 4
    aExplosionart db 'explosionart',0       ; DATA XREF: sub_42E440+996o
    align 4
    aExplosiongaf db 'explosiongaf',0       ; DATA XREF: sub_42E440+972o
    align 4
    aModel db 'model',0                     ; DATA XREF: sub_42E440+844o
    align 4
    aShakeduration db 'shakeduration',0     ; DATA XREF: sub_42E440+813o
    align 4
    aShakemagnitude db 'shakemagnitude',0   ; DATA XREF: sub_42E440+7FCo
    align 4
    aPitchtolerance db 'pitchtolerance',0   ; DATA XREF: sub_42E440+7E7o
    align 4
    aTolerance db 'tolerance',0             ; DATA XREF: sub_42E440+7D2o
    align 4
    aAccuracy db 'accuracy',0               ; DATA XREF: sub_42E440+7BEo
    align 4
    aEndsmoke db 'endsmoke',0               ; DATA XREF: sub_42E440+799o
    align 4
    aStartsmoke db 'startsmoke',0           ; DATA XREF: sub_42E440+774o
    align 4
    aParalyzer db 'paralyzer',0             ; DATA XREF: sub_42E440+755o
    align 4
    aNoradar db 'noradar',0                 ; DATA XREF: sub_42E440+72Ao
    aMeteor db 'meteor',0                   ; DATA XREF: sub_42E440+705o
                                            ; sub_438320+17o
    align 4
    aVlaunch db 'vlaunch',0                 ; DATA XREF: sub_42E440+6E0o
    aDropped db 'dropped',0                 ; DATA XREF: sub_42E440+6BBo
    aShellweapon db 'shellweapon',0         ; DATA XREF: sub_42E440+696o
    aBeamweapon db 'beamweapon',0           ; DATA XREF: sub_42E440+671o
    align 4
    aInterceptor db 'interceptor',0         ; DATA XREF: sub_42E440+649o
    aTargetable db 'targetable',0           ; DATA XREF: sub_42E440+627o
    align 4
    aStockpile db 'stockpile',0             ; DATA XREF: sub_42E440+5F9o
    align 4
    aCommandfire db 'commandfire',0         ; DATA XREF: sub_42E440+5D1o
    aCruise db 'cruise',0                   ; DATA XREF: sub_42E440+5A9o
    align 4
    aTwophase db 'twophase',0               ; DATA XREF: sub_42E440+581o
    align 4
    aBurnblow db 'burnblow',0               ; DATA XREF: sub_42E440+559o
    align 4
    aNoexplode db 'noexplode',0             ; DATA XREF: sub_42E440+531o
    align 4
    aPropeller db 'propeller',0             ; DATA XREF: sub_42E440+509o
    align 4
    aSelfprop db 'selfprop',0               ; DATA XREF: sub_42E440+4E7o
    align 4
    aTurret db 'turret',0                   ; DATA XREF: sub_42E440+4B9o
                                            ; .data:00505CF4o
    align 4
    aSmoketrail db 'smoketrail',0           ; DATA XREF: sub_42E440+491o
    align 4
    aToairweapon db 'toairweapon',0         ; DATA XREF: sub_42E440+469o
    aWaterweapon db 'waterweapon',0         ; DATA XREF: sub_42E440+441o
    aGroundbounce db 'groundbounce',0       ; DATA XREF: sub_42E440+41Co
    align 4
    aUnitsonly db 'unitsonly',0             ; DATA XREF: sub_42E440+3F7o
    align 4
    aBallistic db 'ballistic',0             ; DATA XREF: sub_42E440+3CCo
    align 4
    aLineofsight db 'lineofsight',0         ; DATA XREF: sub_42E440+3B6o
                                            ; sub_435DA0+5FFo
    aTracks db 'tracks',0                   ; DATA XREF: sub_42E440+38Bo
    align 4
    aGuidance db 'guidance',0               ; DATA XREF: sub_42E440+366o
    align 4
    aSoundtrigger db 'soundtrigger',0       ; DATA XREF: sub_42E440+341o
    align 4
    aColor2 db 'color2',0                   ; DATA XREF: sub_42E440+32Do
    align 4
    aColor db 'color',0                     ; DATA XREF: sub_42E440+319o
    align 4
    aRendertype db 'rendertype',0           ; DATA XREF: sub_42E440+305o
    align 4
    aFirestarter db 'firestarter',0         ; DATA XREF: sub_42E440+2F1o
    aMinbarrelangle db 'minbarrelangle',0   ; DATA XREF: sub_42E440+2D6o
    align 4
    aHoldtime db 'holdtime',0               ; DATA XREF: sub_42E440+2B1o
    align 4
    aFlighttime db 'flighttime',0           ; DATA XREF: sub_42E440+28Fo
    align 4
    aSmokedelay db 'smokedelay',0           ; DATA XREF: sub_42E440+26Do
    align 4
    aRandomdecay db 'randomdecay',0         ; DATA XREF: sub_42E440+24Bo
    aDuration db 'duration',0               ; DATA XREF: sub_42E440+229o
    align 4
    aSprayangle db 'sprayangle',0           ; DATA XREF: sub_42E440+212o
    align 4
    aBurstrate db 'burstrate',0             ; DATA XREF: sub_42E440+1F2o
    align 4
    aBurst db 'burst',0                     ; DATA XREF: sub_42E440+1DBo
    align 4
    aNoautorange db 'noautorange',0         ; DATA XREF: sub_42E440+191o
    aWeapontimer db 'weapontimer',0         ; DATA XREF: sub_42E440+178o
    aEdgeeffectiven db 'edgeeffectiveness',0 ; DATA XREF: sub_42E440+15Bo
    align 4
    aAreaofeffect db 'areaofeffect',0       ; DATA XREF: sub_42E440+14Bo
    align 4
    aMetalpershot db 'metalpershot',0       ; DATA XREF: sub_42E440+137o
    align 4
    aEnergypershot db 'energypershot',0     ; DATA XREF: sub_42E440+11Ao
    align 4
    aReloadtime db 'reloadtime',0           ; DATA XREF: sub_42E440+F9o
    align 4
    aCoverage db 'coverage',0               ; DATA XREF: sub_42E440+E3o
    align 4
    aRange db 'range',0                     ; DATA XREF: sub_42E440+D2o
                                            ; .text:004ADFEEo ...
    align 4
    aWeaponaccelera db 'weaponacceleration',0 ; DATA XREF: sub_42E440+B3o
    align 4
    aStartvelocity db 'startvelocity',0     ; DATA XREF: sub_42E440+95o
    align 4
    aWeaponvelocity db 'weaponvelocity',0   ; DATA XREF: sub_42E440+7Ao
    align 4
    aId db 'ID',0                           ; DATA XREF: sub_42E440+1Ao
    align 4
    aSayChoiceArray db 'Say Choice Array',0 ; DATA XREF: sub_42F450+84o
                                            ; sub_42F450+9Fo
    align 4
    aSS_2 db '%s%s',0                       ; DATA XREF: sub_42F450+41o
                                            ; sub_43A420+B3o ...
    align 4
    aText db 'text',0                       ; DATA XREF: sub_42F450+34o
                                            ; .text:004ADAF1o ...
    align 4
    aSI db '%s%i',0                         ; DATA XREF: sub_42F580+126o
                                            ; sub_42F580+151o
    align 4
    aSoundCategorie db 'Sound Categories',0 ; DATA XREF: sub_42F580+86o
                                            ; .rdata:004FEA0Co ...
    align 4
    aSound db 'sound',0                     ; DATA XREF: sub_42F580+2Eo
                                            ; sub_42F7E0+7Bo
    align 4
    aAllsound db 'allsound',0               ; DATA XREF: sub_42F7E0+19o
    align 4
    aTrackD db 'track%d',0                  ; DATA XREF: .text:0042F920o
    aAllmissions db 'AllMissions',0         ; DATA XREF: WriteRegistrySettings_1+150Ao
                                            ; sub_432B60+Fo
    aGames db 'Games',0                     ; DATA XREF: WriteRegistrySettings_1+14A3o
    align 4
    aDisplaymodedep db 'DisplaymodeDepth',0 ; DATA XREF: WriteRegistrySettings_1+147Do
    align 4
    aPlaymovie db 'PlayMovie',0             ; DATA XREF: WriteRegistrySettings_1+1442o
                                            ; WriteRegistrySettings_2+82Ao
    align 4
    aPlayerDenergy db 'Player%dEnergy',0    ; DATA XREF: WriteRegistrySettings_1+13EBo
                                            ; WriteRegistrySettings_2+7E3o
    align 4
    aPlayerDmetal db 'Player%dMetal',0      ; DATA XREF: WriteRegistrySettings_1+13A9o
                                            ; WriteRegistrySettings_2+7B4o
    align 4
    aPlayerDallygro db 'Player%dAllyGroup',0 ; DATA XREF: WriteRegistrySettings_1+1363o
                                            ; WriteRegistrySettings_2+784o
    align 4
    aPlayerDcolor db 'Player%dColor',0      ; DATA XREF: WriteRegistrySettings_1+1322o
                                            ; WriteRegistrySettings_2+754o
    align 4
    aPlayerDside db 'Player%dSide',0        ; DATA XREF: WriteRegistrySettings_1+12CAo
                                            ; WriteRegistrySettings_2+725o
    align 4
    aPlayerDcontrol db 'Player%dController',0 ; DATA XREF: WriteRegistrySettings_1+1286o
                                            ; WriteRegistrySettings_2+6F6o
    align 4
    aSkirmishmap db 'SkirmishMap',0         ; DATA XREF: WriteRegistrySettings_1+11D8o
                                            ; WriteRegistrySettings_1+124Fo ...
    aSkirmishlocati db 'SkirmishLocation',0 ; DATA XREF: WriteRegistrySettings_1+1166o
                                            ; WriteRegistrySettings_1+11AAo ...
    align 4
    aSkirmishdiffic db 'SkirmishDifficulty',0 ; DATA XREF: WriteRegistrySettings_1+10FDo
                                            ; WriteRegistrySettings_1+1152o ...
    align 4
    aSkirmishlostyp db 'SkirmishLOSType',0  ; DATA XREF: WriteRegistrySettings_1+10A5o
                                            ; WriteRegistrySettings_1+10E9o ...
    aSkirmishlineof db 'SkirmishLineOfSight',0 ; DATA XREF: WriteRegistrySettings_1+104Do
                                            ; WriteRegistrySettings_1+1091o ...
    aSkirmishmappin db 'SkirmishMapping',0  ; DATA XREF: WriteRegistrySettings_1+FF5o
                                            ; WriteRegistrySettings_1+1039o ...
    aSkirmishcomman db 'SkirmishCommanderDeath',0 ; DATA XREF: WriteRegistrySettings_1+F9Do
                                            ; WriteRegistrySettings_1+FE1o ...
    align 4
    aMultilostype db 'MultiLOSType',0       ; DATA XREF: WriteRegistrySettings_1+F4Co
                                            ; WriteRegistrySettings_1+F89o ...
    align 4
    aMultilineofsig db 'MultiLineOfSight',0 ; DATA XREF: WriteRegistrySettings_1+EFBo
                                            ; WriteRegistrySettings_1+F38o ...
    align 4
    aMultimapping db 'MultiMapping',0       ; DATA XREF: WriteRegistrySettings_1+EAAo
                                            ; WriteRegistrySettings_1+EE7o ...
    align 4
    aMulticommander db 'MultiCommanderDeath',0 ; DATA XREF: WriteRegistrySettings_1+E59o
                                            ; WriteRegistrySettings_1+E96o ...
    aNumskirmishpla db 'NumSkirmishPlayers',0 ; DATA XREF: WriteRegistrySettings_1+E0Ao
                                            ; sub_432B80+Co
    align 4
    aClock db 'clock',0                     ; DATA XREF: WriteRegistrySettings_1+DC3o
                                            ; WriteRegistrySettings_2+495o
    align 4
    aMusicvol db 'musicvol',0               ; DATA XREF: WriteRegistrySettings_1+D8Ao
                                            ; WriteRegistrySettings_2+56Co
    align 4
    aFxvol db 'fxvol',0                     ; DATA XREF: WriteRegistrySettings_1+D51o
                                            ; WriteRegistrySettings_2+551o
    align 4
    aSpeechfx db 'speechfx',0               ; DATA XREF: WriteRegistrySettings_1+D0Co
                                            ; WriteRegistrySettings_2+535o
    align 4
    aBuildfx db 'buildfx',0                 ; DATA XREF: WriteRegistrySettings_1+CC7o
                                            ; WriteRegistrySettings_2+513o
    aAckfx db 'ackfx',0                     ; DATA XREF: WriteRegistrySettings_1+C82o
                                            ; WriteRegistrySettings_2+4F2o
    align 4
    aCdmode db 'cdmode',0                   ; DATA XREF: WriteRegistrySettings_1+C4Co
                                            ; WriteRegistrySettings_2+4D0o
    align 4
    aMusicmode db 'musicmode',0             ; DATA XREF: WriteRegistrySettings_1+C02o
                                            ; WriteRegistrySettings_2+4B3o
    align 4
    aUnitchattext db 'unitchattext',0       ; DATA XREF: WriteRegistrySettings_1+BCCo
                                            ; WriteRegistrySettings_2+402o
    align 4
    aUnitchat db 'unitchat',0               ; DATA XREF: WriteRegistrySettings_1+B97o
                                            ; WriteRegistrySettings_2+3E4o
    align 4
    aGamespeed db 'gamespeed',0             ; DATA XREF: WriteRegistrySettings_1+B4Co
                                            ; WriteRegistrySettings_2+473o
    align 4
    aMousespeed db 'mousespeed',0           ; DATA XREF: WriteRegistrySettings_1+B17o
                                            ; WriteRegistrySettings_2+455o
    align 4
    aTextscroll db 'textscroll',0           ; DATA XREF: WriteRegistrySettings_1+AE1o
                                            ; WriteRegistrySettings_2+43Ao
    align 4
    aTextlines db 'textlines',0             ; DATA XREF: WriteRegistrySettings_1+AACo
                                            ; WriteRegistrySettings_2+41Eo
    align 4
    aMovieOutputRat db 'Movie Output Rate',0 ; DATA XREF: WriteRegistrySettings_1+A77o
                                            ; WriteRegistrySettings_2+3BBo
    align 4
    aSS db '%s\%s',0                        ; DATA XREF: WriteRegistrySettings_1+A64o
                                            ; sub_435430+1A0o ...
    align 4
    aUser_images db 'user_images',0         ; DATA XREF: WriteRegistrySettings_1+A22o
    aImageOutputDir db 'Image Output Directory',0 ; DATA XREF: WriteRegistrySettings_1+9F9o
                                            ; WriteRegistrySettings_2+38Co
    align 4
    aGameName db 'Game Name',0              ; DATA XREF: WriteRegistrySettings_1+9C4o
                                            ; WriteRegistrySettings_2+368o
    align 4
    aNickname db 'Nickname',0               ; DATA XREF: WriteRegistrySettings_1+95Co
                                            ; WriteRegistrySettings_2+34Co
    align 4
    aPassword db 'Password',0               ; DATA XREF: WriteRegistrySettings_1+8E4o
                                            ; WriteRegistrySettings_2+332o
    align 4
    aDitheredfog db 'DitheredFog',0         ; DATA XREF: WriteRegistrySettings_1+794o
                                            ; WriteRegistrySettings_1+7E7o ...
    aVehicleshadows db 'VehicleShadows',0   ; DATA XREF: WriteRegistrySettings_1+6CAo
                                            ; WriteRegistrySettings_1+71Bo ...
    align 4
    aFeatureshadows db 'FeatureShadows',0   ; DATA XREF: WriteRegistrySettings_1+660o
                                            ; WriteRegistrySettings_1+6B6o ...
    align 4
    aShadows db 'Shadows',0                 ; DATA XREF: WriteRegistrySettings_1+5FBo
                                            ; WriteRegistrySettings_1+64Co ...
    aAntiAlias db 'Anti-Alias',0            ; DATA XREF: WriteRegistrySettings_1+598o
                                            ; WriteRegistrySettings_1+5E7o ...
    align 4
    aCdaudiovolume db 'CDAudioVolume',0     ; DATA XREF: WriteRegistrySettings_1+56Co
                                            ; WriteRegistrySettings_2+1F4o
    align 4
    aWaveoutvolume db 'WaveOutVolume',0     ; DATA XREF: WriteRegistrySettings_1+541o
                                            ; WriteRegistrySettings_2+1D6o
    align 4
    aRestorevolume db 'RestoreVolume',0     ; DATA XREF: WriteRegistrySettings_1+4E7o
                                            ; WriteRegistrySettings_2+18Do
    align 4
    aMixingbuffers db 'MixingBuffers',0     ; DATA XREF: WriteRegistrySettings_1+4AFo
                                            ; WriteRegistrySettings_2+1ABo
    align 4
    aSoundMode db 'Sound Mode',0            ; DATA XREF: WriteRegistrySettings_1+40Fo
                                            ; WriteRegistrySettings_1+480o ...
    align 4
    aDamagebars db 'damagebars',0           ; DATA XREF: WriteRegistrySettings_1+3ACo
                                            ; WriteRegistrySettings_1+3FBo ...
    align 4
    aScreenchat db 'screenchat',0           ; DATA XREF: WriteRegistrySettings_1+35Bo
                                            ; WriteRegistrySettings_1+398o ...
    align 4
    aSinglelostype db 'SingleLOSType',0     ; DATA XREF: WriteRegistrySettings_1+30Ao
                                            ; WriteRegistrySettings_1+347o ...
    align 4
    aSinglelineofsi db 'SingleLineOfSight',0 ; DATA XREF: WriteRegistrySettings_1+2B9o
                                            ; WriteRegistrySettings_1+2F6o ...
    align 4
    aSinglemapping db 'SingleMapping',0     ; DATA XREF: WriteRegistrySettings_1+268o
                                            ; WriteRegistrySettings_1+2A5o ...
    align 4
    aSinglecommande db 'SingleCommanderDeath',0 ; DATA XREF: WriteRegistrySettings_1+217o
                                            ; WriteRegistrySettings_1+254o ...
    align 4
    aScrollspeed db 'scrollspeed',0         ; DATA XREF: WriteRegistrySettings_1+1C2o
                                            ; WriteRegistrySettings_1+203o ...
    aDisplaymodehei db 'DisplaymodeHeight',0 ; DATA XREF: WriteRegistrySettings_1+C6o
                                            ; WriteRegistrySettings_1+107o ...
    align 4
    aDisplaymodewid db 'DisplaymodeWidth',0 ; DATA XREF: WriteRegistrySettings_1+71o
                                            ; WriteRegistrySettings_1+B2o ...
    align 4
    aInterfaceType db 'Interface Type',0    ; DATA XREF: WriteRegistrySettings_1+Fo
                                            ; WriteRegistrySettings_1+5Do ...
    align 4
    aFixedlocations db 'FixedLocations',0   ; DATA XREF: WriteRegistrySettings_2+87o
    align 4
    a32xlogos db '32xlogos',0               ; DATA XREF: sub_4318C0+2Fo
    align 4
    aLogos db 'logos',0                     ; DATA XREF: sub_4318C0+Fo
    align 4
    aY2 db 'y2',0                           ; DATA XREF: sub_431950+A6o
                                            ; sub_431A60+260o ...
    align 4
    aX2 db 'x2',0                           ; DATA XREF: sub_431950+94o
                                            ; sub_431A60+24Eo ...
    align 4
    aY1 db 'y1',0                           ; DATA XREF: sub_431950+76o
                                            ; sub_431A60+23Bo ...
    align 4
    aX1 db 'x1',0                           ; DATA XREF: sub_431950+6Ao
                                            ; sub_431A60+228o ...
    align 4
    aNoSInGamedataS db 'No [%s] in GAMEDATA/SIDEDATA.TDF for side:%s',0
                                            ; DATA XREF: sub_431950+39o
                                            ; sub_431A60+205o ...
    align 4
    aReloadD db 'RELOAD%d',0                ; DATA XREF: sub_431A60+A3Fo
    align 4
    aDescription_1 db 'DESCRIPTION',0       ; DATA XREF: sub_431A60+A17o
                                            ; sub_444A20+152o
    aName_0 db 'NAME',0                     ; DATA XREF: sub_431A60+A00o
                                            ; .text:004427F2o ...
    align 4
    aDamagebar2 db 'DAMAGEBAR2',0           ; DATA XREF: sub_431A60+9E9o
    align 4
    aUnitname2 db 'UNITNAME2',0             ; DATA XREF: sub_431A60+9D2o
    align 4
    aMissiontext db 'MISSIONTEXT',0         ; DATA XREF: sub_431A60+9BBo
    aUnitenergyuse db 'UNITENERGYUSE',0     ; DATA XREF: sub_431A60+9A4o
    align 4
    aUnitenergymake db 'UNITENERGYMAKE',0   ; DATA XREF: sub_431A60+98Do
    align 4
    aUnitmetaluse db 'UNITMETALUSE',0       ; DATA XREF: sub_431A60+976o
    align 4
    aUnitmetalmake db 'UNITMETALMAKE',0     ; DATA XREF: sub_431A60+95Fo
    align 4
    aDamagebar db 'DAMAGEBAR',0             ; DATA XREF: sub_431A60+948o
    align 4
    aLogo2 db 'LOGO2',0                     ; DATA XREF: sub_431A60+91Ao
    align 4
    aMetalconsumed db 'METALCONSUMED',0     ; DATA XREF: sub_431A60+903o
    align 4
    aMetalproduced db 'METALPRODUCED',0     ; DATA XREF: sub_431A60+8ECo
    align 4
    aEnergyconsumed db 'ENERGYCONSUMED',0   ; DATA XREF: sub_431A60+8D5o
    align 4
    aEnergyproduced db 'ENERGYPRODUCED',0   ; DATA XREF: sub_431A60+8BEo
    align 4
    aMetalmax db 'METALMAX',0               ; DATA XREF: sub_431A60+81Do
                                            ; sub_431A60+832o
    align 4
    aEnergymax db 'ENERGYMAX',0             ; DATA XREF: sub_431A60+780o
                                            ; sub_431A60+795o
    align 4
    aMetal0 db 'METAL0',0                   ; DATA XREF: sub_431A60+6D7o
                                            ; sub_431A60+6ECo
    align 4
    aEnergy0 db 'ENERGY0',0                 ; DATA XREF: sub_431A60+62Eo
                                            ; sub_431A60+643o
    aTotaltime db 'TOTALTIME',0             ; DATA XREF: sub_431A60+591o
                                            ; sub_431A60+5A6o
    align 4
    aTotalunits db 'TOTALUNITS',0           ; DATA XREF: sub_431A60+4F4o
                                            ; sub_431A60+509o
    align 4
    aMetalnum db 'METALNUM',0               ; DATA XREF: sub_431A60+457o
                                            ; sub_431A60+46Co
    align 4
    aMetalbar db 'METALBAR',0               ; DATA XREF: sub_431A60+3BAo
                                            ; sub_431A60+3CFo
    align 4
    aEnergynum db 'ENERGYNUM',0             ; DATA XREF: sub_431A60+31Do
                                            ; sub_431A60+332o
    align 4
    aEnergybar db 'ENERGYBAR',0             ; DATA XREF: sub_431A60+280o
                                            ; sub_431A60+295o
    align 4
    aLogo_0 db 'LOGO',0                     ; DATA XREF: sub_431A60+1E4o
                                            ; sub_431A60+1F9o
    align 4
    aMetalcolor db 'metalcolor',0           ; DATA XREF: sub_431A60+1CBo
    align 4
    aEnergycolor db 'energycolor',0         ; DATA XREF: sub_431A60+1B5o
    aFont db 'font',0                       ; DATA XREF: sub_431A60+158o
    align 4
    aNameprefix db 'nameprefix',0           ; DATA XREF: sub_431A60+D1o
    align 4
    aMaxunits db 'maxunits',0               ; DATA XREF: sub_432610+12o
                                            ; sub_432610+24o ...
    align 4
    aRadarImage db 'Radar Image',0          ; DATA XREF: sub_4326B0+313o
                                            ; sub_491EC0+C9o
    aGameTime db 'Game Time',0              ; DATA XREF: sub_4326B0+2F3o
                                            ; PlayerStatusMenu+1AFo ...
    align 4
    aGameId db 'Game ID',0                  ; DATA XREF: sub_4326B0+2DDo
    aBetweenmission db 'BetweenMissions',0  ; DATA XREF: sub_4326B0+292o
                                            ; sub_492360+6AFo ...
    aLineofsighttyp db 'LineOfSightType',0  ; DATA XREF: sub_4326B0+274o
                                            ; sub_492360+5C3o
    aLineofsight_0 db 'LineOfSight',0       ; DATA XREF: sub_4326B0+253o
                                            ; sub_47A0E0+53Eo ...
    aLocation db 'Location',0               ; DATA XREF: sub_4326B0+211o
                                            ; sub_492360+548o
    align 4
    aCommanderdeath db 'CommanderDeath',0   ; DATA XREF: sub_4326B0+1F0o
                                            ; sub_47A0E0+44Ao ...
    align 4
    aThumbs db 'Thumbs',0                   ; DATA XREF: sub_4326B0+1B9o
                                            ; sub_492360+46Co
    align 4
    aGametype db 'Gametype',0               ; DATA XREF: sub_4326B0+19Co
                                            ; sub_491EC0+143o ...
    align 4
    aPlayers db 'Players',0                 ; DATA XREF: sub_4326B0+180o
                                            ; sub_444A20+60o ...
    aSide_0 db 'Side',0                     ; DATA XREF: sub_4326B0+162o
                                            ; sub_466050+227o ...
    align 4
    aMap db 'Map',0                         ; DATA XREF: sub_4326B0+10Bo
                                            ; sub_491EC0+24Co ...
    aMission db 'Mission',0                 ; DATA XREF: sub_4326B0+ECo
                                            ; sub_491EC0+220o ...
    aBuildTimeS db 'BUILD TIME: %s',0       ; DATA XREF: sub_4326B0+62o
    align 4
    aBuildDateS db 'BUILD DATE: %s',0       ; DATA XREF: sub_4326B0+36o
    align 4
    aArmcamp db 'ArmCamp',0                 ; DATA XREF: .text:00432A96o
                                            ; .text:00432B16o
    aCorecamp db 'CoreCamp',0               ; DATA XREF: .text:00432A8Fo
                                            ; .text:00432B0Fo
    align 4
    aNumtables db 'numtables',0             ; DATA XREF: sub_433130+60o
    align 4
    aTableinfo db 'TABLEINFO',0             ; DATA XREF: sub_433130+43o
    align 4
    aLos db 'los',0                         ; DATA XREF: sub_433130+17o
    aNumlines db 'numlines',0               ; DATA XREF: sub_433380+4Fo
    align 4
    aTableD db 'TABLE%d',0                  ; DATA XREF: sub_433380+17o
    ; char asc_504A00
    asc_504A00 db ', ',0                    ; DATA XREF: sub_4336F0+54o
                                            ; sub_4336F0+F6o ...
    align 4
    aLineD db 'line%d',0                    ; DATA XREF: sub_4336F0+17o
    align 4
    aMaps db 'Maps',0                       ; DATA XREF: sub_434BF0+14Ao
                                            ; sub_435DA0+1EBo ...
    align 4
    off_504A14 dd offset sub_41544F         ; DATA XREF: sub_434BF0+13Do
                                            ; sub_435DA0+1DEo ...
    aMaps_ota db 'Maps\*.ota',0             ; DATA XREF: sub_434BF0+E0o
    align 4
    aMultiMaps db 'MULTI MAPS',0            ; DATA XREF: sub_434BF0+4Fo
                                            ; sub_434BF0+BBo ...
    align 4
    aTheRequestedCa db 'The requested campaign file, %s, does not exist.',0
                                            ; DATA XREF: sub_435110+128o
    align 4
    aCamps db 'camps',0                     ; DATA XREF: sub_435110+C6o
                                            ; .text:004352E4o ...
    align 4
    aBriefing db 'Briefing',0               ; DATA XREF: .text:0043536Eo
                                            ; sub_435DA0+4B8o
    align 4
    aMissionD db 'MISSION%d',0              ; DATA XREF: .text:0043571Eo
                                            ; sub_435760+51o ...
    align 4
    aErrorUnnamedMi db 'Error -- Unnamed Mission',0 ; DATA XREF: sub_435760+12Eo
    align 4
    aMissionname db 'missionname',0         ; DATA XREF: sub_435760+FDo
                                            ; sub_435DA0+1A1o
    aMissionlist db 'MissionList',0         ; DATA XREF: sub_435760+8Do
    aEnglish db 'english',0                 ; DATA XREF: sub_435A20+58o
                                            ; sub_441460+2A0o ...
    aMeteorinterval db 'MeteorInterval',0   ; DATA XREF: sub_435DA0+A07o
                                            ; sub_438320+BAo
    align 4
    aMeteorduration db 'MeteorDuration',0   ; DATA XREF: sub_435DA0+9F1o
                                            ; sub_438320+A5o
    align 4
    aMeteordensity db 'MeteorDensity',0     ; DATA XREF: sub_435DA0+9D7o
                                            ; sub_438320+8Do
    align 4
    aMeteorradius db 'MeteorRadius',0       ; DATA XREF: sub_435DA0+9C5o
                                            ; sub_438320+7Bo
    align 4
    aMeteorweapon db 'MeteorWeapon',0       ; DATA XREF: sub_435DA0+99Do
                                            ; sub_438320+62o
    align 4
    aAi db 'ai',0                           ; DATA XREF: sub_435DA0+950o
                                            ; sub_435DA0+984o
    align 4
    aTxt_0 db 'txt',0                       ; DATA XREF: sub_435DA0+94Ao
                                            ; sub_435DA0+97Ao
    aAiprofile db 'aiprofile',0             ; DATA XREF: sub_435DA0+935o
    align 4
    aSurfacemetal db 'SurfaceMetal',0       ; DATA XREF: sub_435DA0+913o
    align 4
    aComputerenergy db 'ComputerEnergy',0   ; DATA XREF: sub_435DA0+8F5o
    align 4
    aComputermetal db 'ComputerMetal',0     ; DATA XREF: sub_435DA0+8D7o
    align 4
    aHumanenergy db 'HumanEnergy',0         ; DATA XREF: sub_435DA0+8B9o
    aHumanmetal db 'HumanMetal',0           ; DATA XREF: sub_435DA0+8A1o
    align 4
    aNoSuitableSche db 'No suitable schema type in mission file!',0 ; DATA XREF: sub_435DA0+88Co
    align 4
    aMapError db 'Map error',0              ; DATA XREF: sub_435DA0+887o
    align 4
    aTimemul db 'timemul',0                 ; DATA XREF: sub_435DA0+85Eo
    aKillmul db 'killmul',0                 ; DATA XREF: sub_435DA0+846o
    aWaterdamage db 'waterdamage',0         ; DATA XREF: sub_435DA0+812o
    aWaterdoesdamag db 'waterdoesdamage',0  ; DATA XREF: sub_435DA0+7FCo
    aNosealeveltrig db 'nosealeveltrigger',0 ; DATA XREF: sub_435DA0+7E6o
    align 4
    aLavaworld db 'lavaworld',0             ; DATA XREF: sub_435DA0+7D6o
    align 4
    aTidalstrength db 'tidalstrength',0     ; DATA XREF: sub_435DA0+7BAo
    align 4
    aGravity db 'gravity',0                 ; DATA XREF: sub_435DA0+7A2o
    aMaxwindspeed db 'maxwindspeed',0       ; DATA XREF: sub_435DA0+78Co
    align 4
    aMinwindspeed db 'minwindspeed',0       ; DATA XREF: sub_435DA0+77Co
    align 4
    aMissiondescrip db 'missiondescription',0 ; DATA XREF: sub_435DA0+6C7o
    align 4
    aNoDescriptionA db 'No description available',0 ; DATA XREF: sub_435DA0+6ACo
                                            ; .data:005033A0o
    align 4
    aNomovie db 'nomovie',0                 ; DATA XREF: sub_435DA0+69Co
    aPlanet db 'Planet',0                   ; DATA XREF: sub_435DA0+68Co
    align 4
    aNumplayers db 'numplayers',0           ; DATA XREF: sub_435DA0+66Do
    align 4
    aMemory db 'memory',0                   ; DATA XREF: sub_435DA0+623o
    align 4
    aMapping db 'mapping',0                 ; DATA XREF: sub_435DA0+5EEo
                                            ; sub_49EE30+1ACo
    aCampsUseonly db 'camps\useonly',0      ; DATA XREF: sub_435DA0+5DBo
    align 4
    aUseonlyunits db 'UseOnlyUnits',0       ; DATA XREF: sub_435DA0+5C2o
    align 4
    aGlamoursound db 'glamoursound',0       ; DATA XREF: sub_435DA0+591o
    align 4
    aGlamour db 'glamour',0                 ; DATA XREF: sub_435DA0+55Co
    aCampsHints db 'camps\hints',0          ; DATA XREF: sub_435DA0+53Co
    aMissionhint db 'missionhint',0         ; DATA XREF: sub_435DA0+522o
    aWav db 'WAV',0                         ; DATA XREF: sub_435DA0+500o
                                            ; sub_435DA0+5A0o ...
    aNarration db 'narration',0             ; DATA XREF: sub_435DA0+4ECo
    align 4
    aCampsBriefs db 'camps\briefs',0        ; DATA XREF: sub_435DA0+464o
                                            ; sub_435DA0+506o ...
    align 4
    aTxt db 'TXT',0                         ; DATA XREF: sub_435DA0+45Eo
                                            ; sub_435DA0+536o
    aBrief db 'brief',0                     ; DATA XREF: sub_435DA0+444o
    align 4
    aNoGlobalheader db 'No GlobalHeader block in mission file!',0 ; DATA XREF: sub_435DA0+415o
    align 4
    aOldTedFormatNo db 'Old TED format no longer supported!',0 ; DATA XREF: sub_435DA0+30Fo
    aHeyJokerMissio db 'Hey, joker!  Mission file %s is corrupt (no header found).',0
                                            ; DATA XREF: sub_435DA0+2D6o
    align 4
    aTnt db 'TNT',0                         ; DATA XREF: sub_435DA0+2AEo
                                            ; sub_435DA0+3E1o
    aGlobalheader db 'GlobalHeader',0       ; DATA XREF: sub_435DA0+26Co
                                            ; sub_435DA0+3FAo ...
    align 4
    aHeyJokerThereI db 'Hey, joker!  There is no mission defintion for this mission:'
                                            ; DATA XREF: sub_435DA0+21Ao
    db ' %s',0
    aMissionfile db 'missionfile',0         ; DATA XREF: sub_435DA0+1BEo
    aTheRequestedMi db 'The requested mission file, %s, does not exist.',0
                                            ; DATA XREF: sub_435DA0+171o
    aStartpos db 'StartPos',0               ; DATA XREF: sub_436860+277o
                                            ; sub_436860+29Co ...
    align 4
    aSpecialwhat db 'specialwhat',0         ; DATA XREF: sub_436860+25Bo
                                            ; sub_436C30+46Fo
    aSpecials db 'specials',0               ; DATA XREF: sub_436860+225o
                                            ; sub_436C30+3E0o
    align 4
    aType db 'type',0                       ; DATA XREF: sub_436860+1D5o
    align 4
    aSchemaI db 'Schema %i',0               ; DATA XREF: sub_436860+1A2o
    align 4
    aVeryBadNewsNoM db 'Very bad news!  No MSG!',0 ; DATA XREF: sub_436860+18Fo
    aNetwork4 db 'Network 4',0              ; DATA XREF: sub_436860+6Ao
    align 4
    aNetwork3 db 'Network 3',0              ; DATA XREF: sub_436860+62o
    align 4
    aNetwork2 db 'Network 2',0              ; DATA XREF: sub_436860+5Ao
    align 4
    aNetwork1 db 'Network 1',0              ; DATA XREF: sub_436860+52o
    align 4
    aHard db 'Hard',0                       ; DATA XREF: sub_436860+4Ao
                                            ; sub_45F1D0+111o ...
    align 4
    aMedium db 'Medium',0                   ; DATA XREF: sub_436860+42o
                                            ; sub_45F1D0+109o ...
    align 4
    aEasy db 'Easy',0                       ; DATA XREF: sub_436860+3Ao
                                            ; sub_45F1D0+101o ...
    align 4
    aFeaturename db 'Featurename',0         ; DATA XREF: sub_436C30+5E5o
    aMissionfeature db 'MISSIONFEATURE DATA',0 ; DATA XREF: sub_436C30+5A2o
    aMissionruleDat db 'MISSIONRULE DATA',0 ; DATA XREF: sub_436C30+41Ao
    align 4
    aImmunity db 'Immunity',0               ; DATA XREF: sub_436C30+3A0o
    align 4
    aInitialgroup db 'InitialGroup',0       ; DATA XREF: sub_436C30+38Ao
    align 4
    aAiprioritytarg db 'AiPriorityTarget',0 ; DATA XREF: sub_436C30+36Co
    align 4
    aAiignore db 'AiIgnore',0               ; DATA XREF: sub_436C30+34Eo
    align 4
    aMissioncritica db 'MissionCriticalUnit',0 ; DATA XREF: sub_436C30+330o
    aCreationcountd db 'CreationCountdown',0 ; DATA XREF: sub_436C30+31Eo
    align 4
    aBuildpriority db 'BuildPriority',0     ; DATA XREF: sub_436C30+30Co
    align 4
    aHealthpercenta db 'HealthPercentage',0 ; DATA XREF: sub_436C30+2FEo
    align 4
    aPlayer db 'Player',0                   ; DATA XREF: sub_436C30+2DCo
                                            ; sub_464290+14Do ...
    align 4
    aAngle db 'Angle',0                     ; DATA XREF: sub_436C30+2B8o
    align 4
    aZpos db 'ZPos',0                       ; DATA XREF: sub_436C30+2A4o
                                            ; sub_436C30+4DFo ...
    align 4
    aYpos db 'YPos',0                       ; DATA XREF: sub_436C30+290o
    align 4
    aXpos db 'XPos',0                       ; DATA XREF: sub_436C30+27Fo
                                            ; sub_436C30+4CBo ...
    align 4
    aMissionunitDat db 'MISSIONUNIT DATA',0 ; DATA XREF: sub_436C30+174o
    align 4
    aInitialmission db 'InitialMission',0   ; DATA XREF: sub_436C30+112o
                                            ; sub_436C30+24Ao
    align 4
    aIdent db 'Ident',0                     ; DATA XREF: sub_436C30+DBo
                                            ; sub_436C30+20Bo
    align 4
    aUnitname_0 db 'Unitname',0             ; DATA XREF: sub_436C30+A4o
                                            ; sub_436C30+1CEo
    align 4
    aGlobalheader_0 db 'globalheader',0     ; DATA XREF: sub_436C30+20o
    align 4
    aRawFeatureData db 'Raw Feature Data',0 ; DATA XREF: sub_4373A0+11Do
    align 4
    aRawPlotData db 'Raw Plot Data',0       ; DATA XREF: sub_4373A0+CAo
    align 4
    aSetspeed db 'SetSpeed',0               ; DATA XREF: sub_437840+BDo
                                            ; sub_437910+75o
    align 4
    aSetdirection db 'SetDirection',0       ; DATA XREF: sub_437910+49o
    align 4
    aCmemorycacheCc db 'CMemoryCache CCH',0 ; DATA XREF: sub_4379B0+20o
    align 4
    aTargetZ db 'Target Z',0                ; DATA XREF: sub_438180+B2o
                                            ; sub_438250+A8o
    align 4
    aTargetX db 'Target X',0                ; DATA XREF: sub_438180+9Eo
                                            ; sub_438250+94o
    align 4
    aOriginZ db 'Origin Z',0                ; DATA XREF: sub_438180+8Ao
                                            ; sub_438250+80o
    align 4
    aOriginX db 'Origin X',0                ; DATA XREF: sub_438180+76o
                                            ; sub_438250+6Do
    align 4
    aNextHitTime db 'Next Hit Time',0       ; DATA XREF: sub_438180+62o
                                            ; sub_438250+5Ao
    align 4
    aTimeStrikeEnds db 'Time Strike Ends',0 ; DATA XREF: sub_438180+51o
                                            ; sub_438250+47o
    align 4
    aNextStrikeTime db 'Next Strike Time',0 ; DATA XREF: sub_438180+3Fo
                                            ; sub_438250+34o
    align 4
    aActive db 'Active',0                   ; DATA XREF: sub_438180+2Ao
                                            ; sub_438250+21o
    align 4
    aEnabled db 'Enabled',0                 ; DATA XREF: sub_438180+19o
                                            ; sub_438250+13o
    aHeyHoserTheDef db 'Hey, hoser!  The default meteor shower data was bogus!',0
                                            ; DATA XREF: sub_438320+107o
    align 4
    aDefault_0 db 'Default',0               ; DATA XREF: sub_438320+41o
    aBecarried db 'BECARRIED',0             ; DATA XREF: sub_4384A0+7Eo
    align 4
    aStartbuilding db 'StartBuilding',0     ; DATA XREF: sub_438590+7o
                                            ; sub_489800+76o ...
    align 4
    aStopbuilding db 'StopBuilding',0       ; DATA XREF: sub_4385F0+14o
                                            ; sub_43A1F0+3Ao ...
    align 4
    aWeapon3Range db 'weapon3 range',0      ; DATA XREF: sub_4390A0+412o
    align 4
    aWeapon2Range db 'weapon2 range',0      ; DATA XREF: sub_4390A0+3E7o
    align 4
    aWeapon1Range db 'weapon1 range',0      ; DATA XREF: sub_4390A0+3B9o
    align 4
    aManeuver db 'maneuver',0               ; DATA XREF: sub_4390A0+329o
    align 4
    aBuildDistance db 'build distance',0    ; DATA XREF: sub_4390A0+2ECo
    align 4
    aSonarjam db 'sonarjam',0               ; DATA XREF: sub_4390A0+2AAo
    align 4
    aRadarjam db 'radarjam',0               ; DATA XREF: sub_4390A0+270o
    align 4
    aSonar db 'sonar',0                     ; DATA XREF: sub_4390A0+236o
    align 4
    aRadar_0 db 'radar',0                   ; DATA XREF: sub_4390A0+1FCo
    align 4
    aSight db 'sight',0                     ; DATA XREF: sub_4390A0+1C2o
    align 4
    aMincloak db 'mincloak',0               ; DATA XREF: sub_4390A0+184o
    align 4
    aAttackLength db 'attack length',0      ; DATA XREF: sub_439740+1F0o
    align 4
    aWeaponDCoverag db 'weapon %d - coverage',0 ; DATA XREF: sub_439740+198o
    align 4
    aWeaponDAreaOfE db 'weapon %d - area of effect',0 ; DATA XREF: sub_439740+155o
    align 4
    aUtypename4d db 'UTYPENAME%4d',0        ; DATA XREF: .text:0043A2EDo
                                            ; .text:0043A378o ...
    align 4
    aG:                                     ; DATA XREF: sub_43A420+3ACo
                                            ; sub_43A970+29Co
    unicode 0, <g>,0
    a_name db '_name',0                     ; DATA XREF: sub_43A420+A6o
                                            ; sub_43A970+138o
    dd 0, 37190000h
    db 46h, 55h, 64h
    byte_505205 db 64h                      ; DATA XREF: sub_43CC20+41r
    dd 1419324Bh
    db 0Fh, 0
    aMoverate1 db 'MoveRate1',0             ; DATA XREF: sub_43DA70+ACo
    align 4
    aMoverate2 db 'MoveRate2',0             ; DATA XREF: sub_43DA70+A1o
    align 4
    aMoverate3 db 'MoveRate3',0             ; DATA XREF: sub_43DA70+96o
    align 4
    aStartmoving db 'StartMoving',0         ; DATA XREF: sub_43DA70+77o
    aStopmoving db 'StopMoving',0           ; DATA XREF: sub_43DA70+68o
    align 4
    aSetsfxoccupy db 'setSFXoccupy',0       ; DATA XREF: sub_43DB50+93o
    align 4
    aU04xmob db 'u%04xmob',0                ; DATA XREF: sub_43DD70+78o
                                            ; sub_43DE30+19o
    align 4
    aQuerytertiary db 'QueryTertiary',0     ; DATA XREF: sub_43E1E0+2Co
                                            ; sub_43E240+2Do ...
    align 4
    aQuerysecondary db 'QuerySecondary',0   ; DATA XREF: sub_43E1E0+24o
                                            ; sub_43E240+25o ...
    align 4
    aQueryprimary db 'QueryPrimary',0       ; DATA XREF: sub_43E1E0+1Co
                                            ; sub_43E240+1Do ...
    align 4
    aAimfromtertiar db 'AimFromTertiary',0  ; DATA XREF: sub_43E2E0+28o
    aAimfromseconda db 'AimFromSecondary',0 ; DATA XREF: sub_43E2E0+20o
    align 4
    aAimfromprimary db 'AimFromPrimary',0   ; DATA XREF: sub_43E2E0+18o
    align 4
    aSweetspot db 'SweetSpot',0             ; DATA XREF: sub_43E3C0+17o
    align 4
    aQuerynanopiece db 'QueryNanoPiece',0   ; DATA XREF: sub_43E400+1Ao
    align 4
    aMove_ground db 'MOVE_GROUND',0         ; DATA XREF: sub_43F0E0+10E2o
    aResurrect db 'RESURRECT',0             ; DATA XREF: sub_43F0E0+F70o
    align 4
    aFollow_ground db 'FOLLOW_GROUND',0     ; DATA XREF: sub_43F0E0+ACDo
    align 4
    aGround_pickup db 'GROUND_PICKUP',0     ; DATA XREF: sub_43F0E0+A85o
    align 4
    aQmove db 'QMOVE',0                     ; DATA XREF: sub_43F0E0+77Eo
    align 4
    aTeleport db 'TELEPORT',0               ; DATA XREF: sub_43F0E0+737o
    align 4
    aAttackspecial db 'ATTACKSPECIAL',0     ; DATA XREF: sub_43F0E0+71Eo
    align 4
    aGround_unload db 'GROUND_UNLOAD',0     ; DATA XREF: sub_43F0E0+6AAo
                                            ; .data:00511168o ...
    align 4
    aVtol_unload db 'VTOL_UNLOAD',0         ; DATA XREF: sub_43F0E0+695o
    aVtol_pickup db 'VTOL_PICKUP',0         ; DATA XREF: sub_43F0E0+63Fo
                                            ; sub_43F0E0+8B4o ...
    aVtol_follow db 'VTOL_FOLLOW',0         ; DATA XREF: sub_43F0E0+407o
                                            ; sub_43F0E0+8D7o ...
    aVtol_patrol db 'VTOL_PATROL',0         ; DATA XREF: sub_43F0E0+35Eo
    aRepairpatrol db 'REPAIRPATROL',0       ; DATA XREF: sub_43F0E0+338o
    align 4
    aVtol_repairpat db 'VTOL_REPAIRPATROL',0 ; DATA XREF: sub_43F0E0+31Fo
    align 4
    aQpatrol db 'QPATROL',0                 ; DATA XREF: sub_43F0E0+2F1o
    aAttack_kamikaz db 'ATTACK_KAMIKAZE',0  ; DATA XREF: sub_43F0E0+2C4o
    aAttack_nomove db 'ATTACK_NOMOVE',0     ; DATA XREF: sub_43F0E0+295o
    align 4
    aAttack_chase db 'ATTACK_CHASE',0       ; DATA XREF: sub_43F0E0+272o
    align 4
    aAirtogroundhov db 'AIRTOGROUNDHOVER',0 ; DATA XREF: sub_43F0E0+253o
    align 4
    aAirtoground db 'AIRTOGROUND',0         ; DATA XREF: sub_43F0E0+226o
    aAirtoair db 'AIRTOAIR',0               ; DATA XREF: sub_43F0E0+1FBo
    align 4
    aAirstrike db 'AIRSTRIKE',0             ; DATA XREF: sub_43F0E0+1D6o
    align 4
    aSuppress db 'SUPPRESS',0               ; DATA XREF: sub_43F0E0+C2o
    align 4
    aBadwaterslope db 'badwaterslope',0     ; DATA XREF: sub_440340+AAo
    align 4
    aMaxwaterslope db 'maxwaterslope',0     ; DATA XREF: sub_440340+92o
    align 4
    aBadslope db 'badslope',0               ; DATA XREF: sub_440340+7Co
    align 4
    aMaxslope db 'maxslope',0               ; DATA XREF: sub_440340+64o
    align 4
    aMinwaterdepth db 'minwaterdepth',0     ; DATA XREF: sub_440340+4Do
    align 4
    aMaxwaterdepth db 'maxwaterdepth',0     ; DATA XREF: sub_440340+37o
    align 4
    aFootprintz_0 db 'FootPrintZ',0         ; DATA XREF: sub_440340+21o
    align 4
    aFootprintx_0 db 'FootPrintX',0         ; DATA XREF: sub_440340+Eo
    align 4
    dword_505490 dd 1C200h                  ; DATA XREF: sub_442380+Fr
    dd 0E100h, 9600h, 4B00h, 3840h, 2580h
    dword_5054A8 dd 10h                     ; DATA XREF: sub_4436E0+33o
                                            ; sub_4436E0+41r ...
    dd 0
    dword_5054B0 dd 505604h                 ; DATA XREF: sub_4455B0+38r
                                            ; sub_4455B0+48o ...
    dd offset aReadyx                       ; "READYx"
    dd offset aLogox                        ; "LOGOx"
    dd offset aSidex                        ; "SIDEx"
    dd offset aPingx                        ; "PINGx"
    dd offset aMemx                         ; "MEMx"
    dd offset aResx                         ; "RESx"
    dd offset aAllyx                        ; "ALLYx"
    dd offset aCdx                          ; "CDx"
    dd offset aTeamiconsx                   ; "TEAMICONSx"
    dd 2 dup(0), 5055B0h, 5055A4h, 505598h, 505590h, 505584h, 50557Ch, 505570h
    dd 505568h, 505560h, 505558h, 0
    dword_50550C dd 0FFFFFFFFh              ; DATA XREF: Battleroom_Unknown1+20w
                                            ; .text:0044A939r ...
    dword_505510 dd 0FFFFFFFFh              ; DATA XREF: .text:00446044r
                                            ; sub_446080+13w ...
    dd 0
    ; char *off_505518
    off_505518 dd offset aCommander_1       ; DATA XREF: Battleroom_Unknown1+465r
                                            ; Battleroom_Unknown1+46Ao
                                            ; "COMMANDER"
    dd offset aMapping_1                    ; "MAPPING"
    dd offset aLostype                      ; "LOSTYPE"
    dd offset aWatching_0                   ; "WATCHING"
    dd offset aCheating_0                   ; "CHEATING"
    dd offset aFixedloc_0                   ; "FIXEDLOC"
    dd offset aGameopen                     ; "GAMEOPEN"
    dd 0
    aGameopen db 'GAMEOPEN',0               ; DATA XREF: sub_445ED0+137o
                                            ; .text:004464B0o ...
    align 4
    aLostype db 'LOSTYPE',0                 ; DATA XREF: sub_445ED0+A2o
                                            ; sub_447B10+A42o ...
    aCommander_1 db 'COMMANDER',0           ; DATA XREF: sub_441460+681o
                                            ; sub_445ED0+49o ...
    align 4
    aEnergy_1 db 'ENERGY',0                 ; DATA XREF: sub_441460+65Co
                                            ; sub_445D60+9o ...
    align 4
    aMetal_1 db 'METAL',0                   ; DATA XREF: sub_441460+637o
                                            ; sub_445C70+9o ...
    align 4
    aUnits_1 db 'UNITS',0
    align 4
    aCheating_0 db 'CHEATING',0             ; DATA XREF: sub_445ED0+E9o
                                            ; sub_447B10+B2Do ...
    align 4
    aSharing db 'SHARING',0
    aTechlevl db 'TECHLEVL',0
    align 4
    aMapping_1 db 'MAPPING',0               ; DATA XREF: sub_445ED0+6Fo
                                            ; sub_447B10+BB8o ...
    aFixedloc_0 db 'FIXEDLOC',0             ; DATA XREF: sub_445ED0+10Eo
                                            ; sub_447B10+B64o ...
    align 4
    aWatching_0 db 'WATCHING',0             ; DATA XREF: sub_445ED0+C4o
                                            ; .text:00446487o ...
    align 4
    aCommnder db 'COMMNDER',0
    align 4
    aTeamiconsx db 'TEAMICONSx',0           ; DATA XREF: sub_4478B0+99o
                                            ; sub_4478B0+D5o ...
    align 4
    aCdx db 'CDx',0                         ; DATA XREF: .data:005054D0o
    aAllyx db 'ALLYx',0                     ; DATA XREF: sub_4478B0+35o
                                            ; sub_4478B0+87o ...
    align 4
    aResx db 'RESx',0                       ; DATA XREF: .data:005054C8o
    align 4
    aMemx db 'MEMx',0                       ; DATA XREF: Battleroom_Unknown1+4BAo
                                            ; .data:005054C4o
    align 4
    aPingx db 'PINGx',0                     ; DATA XREF: .data:005054C0o
    align 4
    aSidex db 'SIDEx',0                     ; DATA XREF: sub_479C50+182o
                                            ; .data:005054BCo
    align 4
    aLogox db 'LOGOx',0                     ; DATA XREF: .data:005054B8o
    align 4
    aReadyx db 'READYx',0                   ; DATA XREF: .data:005054B4o
    align 4
    aPlayerx db 'PLAYERx',0
    aPrevious db 'Previous',0               ; DATA XREF: sub_440D70+2D2o
                                            ; sub_442050+17Ao ...
    align 4
    aCancel_0 db 'CANCEL',0                 ; DATA XREF: sub_440D70+2C0o
                                            ; .text:0044622Bo ...
    align 4
    aYouMustEnterYo db 'You must enter your name',0 ; DATA XREF: sub_440D70+223o
                                            ; sub_4437C0+349o
    align 4
    aYouMustEnterAG db 'You must enter a game name',0 ; DATA XREF: sub_440D70+198o
    align 4
    aPassword_0 db 'PASSWORD',0             ; DATA XREF: sub_440D70+60o
                                            ; sub_440D70+74o ...
    align 4
    aNickname_0 db 'NICKNAME',0             ; DATA XREF: sub_440D70+34o
                                            ; sub_440D70+48o ...
    align 4
    aGamename db 'GAMENAME',0               ; DATA XREF: sub_440D70+23o
                                            ; sub_440D70+125o ...
    align 4
    aCreatenew db 'createnew',0             ; DATA XREF: sub_441080+32o
    align 4
    aNewmulti_gui db 'NEWMULTI.GUI',0       ; DATA XREF: sub_441080+12o
    align 4
    aPasswordtext db 'PASSWORDTEXT',0       ; DATA XREF: sub_441220+1C8o
    align 4
    aJoingame db 'JOINGAME',0               ; DATA XREF: sub_441220+12Fo
                                            ; sub_4437C0+1A8o
    align 4
    aWatch db 'WATCH',0                     ; DATA XREF: sub_441220+2Do
                                            ; sub_4437C0+190o ...
    align 4
    aFullmap db 'FULLMAP',0                 ; DATA XREF: sub_441460+6F0o
    aPing db 'PING',0                       ; DATA XREF: sub_441460+6CBo
    align 4
    aMapname db 'MAPNAME',0                 ; DATA XREF: sub_441460+5EDo
                                            ; sub_444A20+11o ...
    aPlayers_0 db 'PLAYERS',0               ; DATA XREF: sub_441460+5C8o
                                            ; sub_4936F0+1D2o
    aGray db 'Gray',0                       ; DATA XREF: sub_441460+4FEo
    align 4
    aBlk db 'Blk',0                         ; DATA XREF: sub_441460+4F7o
    aDm db 'DM',0                           ; DATA XREF: sub_441460+4B7o
    align 4
    aVer db 'VER!',0                        ; DATA XREF: sub_441460+38Do
    align 4
    aS_1 db '%s',0                          ; DATA XREF: sub_441460+379o
                                            ; sub_441460+398o ...
    align 4
    aOpen_0 db 'Open',0                     ; DATA XREF: sub_441460+36Do
                                            ; sub_4797E0+8Eo ...
    align 4
    aPlay db 'Play',0                       ; DATA XREF: sub_441460+366o
    align 4
    aLock_0 db 'Lock',0                     ; DATA XREF: sub_441460+35Ao
    align 4
    aDD_0 db '%d/%d',0                      ; DATA XREF: sub_441460+214o
    align 4
    aUpdating___ db 'Updating...',0         ; DATA XREF: sub_441460+BDo
    aConnectingEscT db 'Connecting  (ESC to abort)',0 ; DATA XREF: sub_441460+B6o
    align 4
    aCompoundAddr db 'COMPOUND ADDR',0      ; DATA XREF: sub_441C30+342o
    align 4
    aAddress db 'ADDRESS',0                 ; DATA XREF: sub_441C30+19Fo
                                            ; sub_442050+C2o ...
    aNumber db 'NUMBER',0                   ; DATA XREF: sub_441C30+F6o
                                            ; .text:00442824o ...
    align 4
    aCCavedogWarg_2 db 'c:\cavedog\wargame\multi.cpp',0 ; DATA XREF: sub_442050+168o
                                            ; sub_4423C0+16Do ...
    align 4
    aTcpaddr db 'TCPADDR',0                 ; DATA XREF: sub_442050+148o
                                            ; .text:004422A0o
    aSmlbutton_2 db 'Smlbutton',0           ; DATA XREF: sub_442050+B6o
                                            ; sub_442050+127o
    align 4
    aJoin db 'JOIN',0                       ; DATA XREF: sub_442050+52o
                                            ; sub_4423C0+94o ...
    align 4
    aTcp_gui db 'TCP.GUI',0                 ; DATA XREF: .text:00442203o
    aSerport db 'SERPORT',0                 ; DATA XREF: sub_4423C0+148o
                                            ; .text:00442637o
    aPorts db 'PORTS',0                     ; DATA XREF: sub_4423C0+12Fo
                                            ; .text:004425C6o ...
    align 4
    aSerbaud db 'SERBAUD',0                 ; DATA XREF: sub_4423C0+121o
                                            ; .text:004425FBo
    aSpeeds db 'SPEEDS',0                   ; DATA XREF: sub_4423C0+108o
                                            ; .text:004425E6o ...
    align 4
    aSmlbutton_0 db 'SMLBUTTON',0           ; DATA XREF: sub_4423C0+81o
                                            ; sub_4423C0+FEo ...
    align 4
    aHost db 'HOST',0                       ; DATA XREF: sub_4423C0+1Do
                                            ; sub_442A30+251o
    align 4
    a115200 db '115200',0                   ; DATA XREF: .text:004425DBo
    a57600 db '57600',0
    a38400 db '38400',0
    a19200 db '19200',0
    a14400 db '14400',0
    a9600 db '9600',0
    aCom1 db 'COM1',0                       ; DATA XREF: .text:004425BCo
    aCom2 db 'COM2',0
    aCom3 db 'COM3',0
    aCom4 db 'COM4',0
    aSerial_gui db 'SERIAL.GUI',0           ; DATA XREF: .text:00442573o
    align 4
    aAccounts db 'ACCOUNTS',0               ; DATA XREF: sub_4426E0+5Fo
                                            ; sub_4426E0+91o ...
    align 4
    aModemnumbers db 'MODEMNUMBERS',0       ; DATA XREF: .text:00442A18o
                                            ; sub_442A30+38Do ...
    align 4
    aConnecting___P db 'Connecting... press ESC to abort',0 ; DATA XREF: sub_442A30+61Do
    align 4
    aAccountnames db 'ACCOUNTNAMES',0       ; DATA XREF: .text:00443349o
    align 4
    aUnused db 'UNUSED',0                   ; DATA XREF: .text:00443304o
                                            ; sub_448C70+641o
    align 4
    aModemaccounts db 'MODEMACCOUNTS',0     ; DATA XREF: .text:004432CFo
    align 4
    aModems db 'MODEMS',0                   ; DATA XREF: .text:004432BFo
    align 4
    aUnableToFindAn db 'Unable to find any modems',0 ; DATA XREF: .text:00443250o
    align 4
    aModeminfo db 'MODEMINFO',0             ; DATA XREF: .text:004431F1o
    align 4
    aModemaddr db 'MODEMADDR',0             ; DATA XREF: .text:004431B6o
    align 4
    aModem_gui db 'MODEM.GUI',0             ; DATA XREF: .text:00443138o
    align 4
    aChkD db 'CHK%d',0                      ; DATA XREF: sub_443480+49o
                                            ; sub_4435A0+67o
    align 4
    aServiceD db 'SERVICE%d',0              ; DATA XREF: sub_4435A0+90o
                                            ; sub_44474E+75o
    align 4
    aScorebg db 'scorebg',0                 ; DATA XREF: sub_4435A0+32o
    aReport_gui db 'REPORT.GUI',0           ; DATA XREF: sub_4435A0+14o
    align 4
    aReporterror db 'ReportError',0         ; DATA XREF: sub_4436E0+B4o
    aUnableToInitia db 'Unable to initialize scores reporting.',0 ; DATA XREF: sub_4436E0+91o
    align 4
    aYouDoNotHaveAC db 'You do not have a compatible version for this game.',0
                                            ; DATA XREF: sub_4437C0+4C8o
    aStartnew db 'STARTNEW',0               ; DATA XREF: sub_4437C0+1D8o
    align 4
    aPrevmenu db 'PREVMENU',0               ; DATA XREF: sub_4437C0+159o
                                            ; sub_4441A0+266o ...
    align 4
    aMulti_0 db 'Multi',0                   ; DATA XREF: sub_4437C0+12Bo
                                            ; sub_4437C0+415o ...
    align 4
    aUpdate db 'UPDATE',0                   ; DATA XREF: sub_4437C0+BBo
    align 4
    aInvalidTcpIpAd db 'Invalid TCP/IP Address',0 ; DATA XREF: sub_443CB0+1EDo
    align 4
    aDataD db 'DATA%d',0                    ; DATA XREF: sub_443CB0+8Ao
    align 4
    aPlayerShared db 'PLAYER SHARED',0      ; DATA XREF: sub_443CB0+64o
    align 4
    aGameDescriptio db 'GAME DESCRIPTIONS',0 ; DATA XREF: sub_443CB0+4Co
    align 4
    aSelectgame2x db 'selectgame2x',0       ; DATA XREF: sub_443CB0+3Ao
    align 4
    aSelgame_gui db 'SELGAME.GUI',0         ; DATA XREF: sub_443CB0+1Ao
    aDplayConnectio db 'DPLAY CONNECTION INFO',0 ; DATA XREF: sub_443FF0+104o
    align 4
    aSettings db 'SETTINGS',0               ; DATA XREF: sub_4441A0+28Co
    align 4
    aTheSServiceFai db 'The %s service failed or took%stoo long. Please see the read'
                                            ; DATA XREF: sub_4441A0+21Bo
    db 'me%sfile for more information.',0
    align 4
    asc_505A64 db 0Ah                       ; DATA XREF: sub_4441A0+206o
                                            ; sub_4441A0+20Bo ...
    db 0Ah,0
    align 4
    aService db 'SERVICE',0                 ; DATA XREF: sub_4441A0+112o
    aSelect db 'SELECT',0                   ; DATA XREF: sub_4441A0+FDo
                                            ; sub_44474E+131o ...
    align 4
    aDplay db 'DPLAY',0                     ; DATA XREF: sub_4441A0+EAo
                                            ; sub_4441A0+2DEo ...
    align 4
    aServicex db 'SERVICEX',0               ; DATA XREF: .text:00444729o
    align 4
    aDplayConnect_0 db 'DPLAY CONNECTIONS',0 ; DATA XREF: .text:004446A6o
    align 4
    aProviderGuids db 'PROVIDER GUIDS',0    ; DATA XREF: .text:0044468Bo
    align 4
    aProviderDescri db 'PROVIDER DESCRIPTIONS',0 ; DATA XREF: .text:0044466Do
    align 4
    aSelconnect2 db 'selconnect2',0         ; DATA XREF: .text:0044465Eo
    aSelprov_gui db 'SELPROV.GUI',0         ; DATA XREF: .text:004445B4o
                                            ; .text:00444633o
    aLogos_0 db 'LOGOS',0                   ; DATA XREF: .text:00444917o
                                            ; sub_444930+49o ...
    align 4
    aCancel db 'Cancel',0                   ; DATA XREF: sub_444930+67o
                                            ; sub_44C420+2DCo ...
    align 4
    aMappic db 'MAPPIC',0                   ; DATA XREF: sub_444A20+B3o
                                            ; .text:00444C81o ...
    align 4
    aSize db 'SIZE',0                       ; DATA XREF: sub_444A20+A3o
                                            ; sub_4AF5B0+7Do
    align 4
    aSSS_1 db '%s  %s: %s',0                ; DATA XREF: sub_444A20+82o
    align 4
    aDviewmap db 'DVIEWMAP',0               ; DATA XREF: .text:00444C00o
                                            ; sub_447B10+104Co
    align 4
    aViewmap_gui db 'VIEWMAP.GUI',0         ; DATA XREF: .text:00444BEFo
                                            ; sub_447B10+103Bo
    aMapnames db 'MAPNAMES',0               ; DATA XREF: .text:00444C45o
                                            ; sub_444CB0+82o ...
    align 4
    aDselectmap2 db 'DSELECTMAP2',0         ; DATA XREF: sub_444EA0+11Ao
                                            ; sub_47AAF0+7Ao
    aSelectMapData db 'SELECT MAP DATA',0   ; DATA XREF: sub_444EA0+FBo
                                            ; sub_47AAF0+5Bo
    aSelmap_gui db 'SELMAP.GUI',0           ; DATA XREF: sub_444EA0+ECo
                                            ; sub_47AAF0+4Co
    align 4
    aThereAreNoMult db 'There are no multiplayer maps to choose from',0
                                            ; DATA XREF: sub_444EA0+38o
                                            ; sub_444EA0+BBo
    align 4
    aOldmapname db 'OLDMAPNAME',0           ; DATA XREF: sub_444EA0+9o
    align 4
    aActualAnimseqs db 'ACTUAL ANIMSEQS',0  ; DATA XREF: .text:00445183o
    aAnimseqPtrList db 'ANIMSEQ PTR LIST',0 ; DATA XREF: .text:0044516Fo
    align 4
    aSelectTeamLogo db 'SELECT TEAM LOGO',0 ; DATA XREF: .text:00445135o
    align 4
    aLogosel_gui db 'LOGOSEL.GUI',0         ; DATA XREF: .text:00445126o
    aReadyD db 'READY%d',0                  ; DATA XREF: sub_4455B0+2E1o
                                            ; sub_447B10+5FBo ...
    aPlayerD db 'PLAYER%d',0                ; DATA XREF: sub_4455B0+217o
                                            ; sub_447380+53o ...
    align 4
    aMaxunitstext db 'MAXUNITSTEXT',0       ; DATA XREF: sub_445B70+87o
    align 4
    aMaxunits_0 db 'MAXUNITS',0             ; DATA XREF: sub_445B70+9o
                                            ; Battleroom_Unknown1+6FDo ...
    align 4
    aMetaltext db 'METALTEXT',0             ; DATA XREF: sub_445C70+5Bo
                                            ; Battleroom_Unknown1+652o ...
    align 4
    aEnergytext db 'ENERGYTEXT',0           ; DATA XREF: sub_445D60+5Bo
                                            ; Battleroom_Unknown1+670o ...
    align 4
    aSS? db '%s %s?',0                      ; DATA XREF: sub_446080+DAo
    align 4
    aReject_0 db 'Reject',0                 ; DATA XREF: sub_446080+CBo
    align 4
    aExit_1 db 'Exit',0                     ; DATA XREF: .text:0044623Co
                                            ; .text:004605DAo
    align 4
    aModes db 'MODES',0                     ; DATA XREF: .text:0044620Do
                                            ; .text:0044628Bo
    align 4
    aAvailableModes db 'AVAILABLE MODES',0  ; DATA XREF: sub_446310+4Co
                                            ; sub_45E5E0+107o
    aDisplayModes db 'DISPLAY MODES',0      ; DATA XREF: sub_446310+1Bo
                                            ; sub_45E5E0+DDo
    align 4
    aSelectVideoMod db 'SELECT VIDEO MODE',0 ; DATA XREF: sub_446310+7o
                                            ; sub_45E5E0+C6o
    align 4
    aLiveplyrD db 'LIVEPLYR%d',0            ; DATA XREF: .text:0044650Fo
                                            ; sub_447380+2FEo ...
    align 4
    aControl_gui db 'CONTROL.GUI',0         ; DATA XREF: sub_4466B0+40o
    aTeamiconsD db 'TEAMICONS%d',0          ; DATA XREF: sub_446A50+C0o
                                            ; sub_446A50+DFo ...
    aLiveallyD db 'LIVEALLY%d',0            ; DATA XREF: sub_446FB0+13Eo
                                            ; sub_447150+5Fo ...
    align 4
    aAllies_gui db 'ALLIES.GUI',0           ; DATA XREF: sub_446FB0+28o
                                            ; sub_4478B0+13o
    align 4
    aVictory db 'VICTORY',0                 ; DATA XREF: sub_447150+16Bo
                                            ; sub_447150+1BAo ...
    aSS_4 db ' %s %s',0                     ; DATA XREF: sub_447150+118o
                                            ; sub_447B10+51Ao
    align 4
    aBrokeAllianceW db 'broke alliance with',0 ; DATA XREF: sub_447150+FAo
                                            ; sub_447B10+4F8o
    aAlliedWith db 'allied with',0          ; DATA XREF: sub_447150+F3o
                                            ; sub_447B10+4F1o
    asc_505CE0:                             ; DATA XREF: sub_447380+257o
    unicode 0, <|>,0
    aAllyD db 'ALLY%d',0                    ; DATA XREF: sub_447380+79o
                                            ; sub_447380+1D7o ...
    align 4
    aLogoD db 'LOGO%d',0                    ; DATA XREF: sub_447380+66o
                                            ; sub_447380+1C4o ...
    align 4
    ; char off_505CF4
    off_505CF4 dd offset aTurret+5          ; DATA XREF: sub_447B10+FE5o
                                            ; sub_448C70+385o ...
    aRestrictions db 'RESTRICTIONS',0       ; DATA XREF: sub_447B10+FBAo
                                            ; Battleroom_Unknown1+602o
    align 4
    aThereAreNotEno db 'There are not enough game CDs present to play',0
                                            ; DATA XREF: sub_447B10+F2Do
    align 4
    aCanNotStartGam db 'Can not start game with all players on the same team.',0
                                            ; DATA XREF: sub_447B10+D9Ao
    align 4
    aSyncerr db '+syncerr',0                ; DATA XREF: sub_447B10+911o
    align 4
    aMessage db 'MESSAGE',0                 ; DATA XREF: sub_447B10+8D7o
                                            ; sub_447B10+8EEo ...
    aCanTAddAnother db 'Can',27h,'t add another player when game is closed.',0
                                            ; DATA XREF: sub_447B10+80Co
    align 4
    aStart_0 db 'START',0                   ; DATA XREF: sub_447B10+70Eo
                                            ; sub_447B10+737o ...
    align 4
    aResD db 'RES%d',0                      ; DATA XREF: sub_447B10+5CAo
                                            ; sub_448C70+787o ...
    align 4
    aAlly db 'Ally',0                       ; DATA XREF: sub_447B10+4D7o
                                            ; sub_447B10+56Co ...
    align 4
    aS_3 db ':s',0                          ; DATA XREF: sub_448C70+D3Bo
    align 4
    aDxD db '%dx%d',0                       ; DATA XREF: sub_448C70+C45o
    align 4
    aNA_0 db 'n/a',0                        ; DATA XREF: sub_448C70+C0Bo
                                            ; sub_448C70+D93o ...
    aMemD db 'MEM%d',0                      ; DATA XREF: sub_448C70+7D3o
                                            ; sub_448C70+DB2o
    align 4
    aPingD db 'PING%d',0                    ; DATA XREF: sub_448C70+7ADo
                                            ; sub_448C70+CAFo
    align 4
    aS_2 db '[%s]',0                        ; DATA XREF: sub_448C70+65Ao
                                            ; .text:004ACD0Fo ...
    align 4
    aBlocked db 'BLOCKED',0                 ; DATA XREF: sub_448C70+648o
    aCdD db 'CD%d',0                        ; DATA XREF: sub_448C70+5EAo
                                            ; sub_448C70+838o
    align 4
    aDoesNotHaveThi db 'does not have this map',0 ; DATA XREF: sub_448C70+2F7o
    align 4
    aViewmap_gui_0 db 'viewmap.gui',0       ; DATA XREF: sub_448C70+216o
                                            ; .text:0044AB56o
    aNotSelected db 'NOT SELECTED',0        ; DATA XREF: sub_448C70+1A6o
    align 4
    aOutput db 'OUTPUT',0                   ; DATA XREF: sub_448C70+23o
                                            ; Battleroom_Unknown1+622o ...
    align 4
    aBattlestart db 'battlestart',0         ; DATA XREF: Battleroom_Unknown1+A3Eo
                                            ; Battleroom_Unknown1+A4Co ...
    aCouldNotFindTh db 'Could not find the multiplayer map!!',0
                                            ; DATA XREF: Battleroom_Unknown1+93Co
    align 4
    a0:                                     ; DATA XREF: Battleroom_Unknown1+640o
                                            ; Battleroom_Unknown1+665o ...
    unicode 0, <0>,0
    aLoungeChatter db 'LOUNGE CHATTER',0    ; DATA XREF: Battleroom_Unknown1+49Co
                                            ; sub_453A50+D7o
    align 4
    aViewMap db 'View Map',0                ; DATA XREF: Battleroom_Unknown1+192o
    align 4
    aBattleroom db 'battleroom',0           ; DATA XREF: Battleroom_Unknown1+116o
    align 4
    aLounge2_gui db 'LOUNGE2.GUI',0         ; DATA XREF: Battleroom_Unknown1+E0o
                                            ; Battleroom_Unknown1+A26o ...
    aI_I db '%i.%i',0                       ; DATA XREF: .text:0044AEC1o
    align 4
    aLogoI db 'LOGO%i',0                    ; DATA XREF: .text:0044AE79o
    align 4
    aPanel db 'Panel',0                     ; DATA XREF: .text:0044ACE8o
                                            ; sub_460160+1CBo ...
    align 4
    aSynching db 'SYNCHING',0               ; DATA XREF: .text:0044AC59o
                                            ; .text:0044ADF5o
    align 4
    aPlayer0 db 'PLAYER0',0                 ; DATA XREF: .text:0044A7A3o
    aResult db 'RESULT',0                   ; DATA XREF: .text:0044B0CCo
    align 4
    aFailure db 'Failure',0                 ; DATA XREF: .text:0044B0B2o
    aVictory_0 db 'Victory',0               ; DATA XREF: .text:0044B0ABo
    aEndmulti_gui db 'ENDMULTI.GUI',0       ; DATA XREF: .text:0044B088o
    align 4
    aMission02winbw db 'Mission02WinBW',0   ; DATA XREF: .text:0044B031o
    align 4
    aRb db 'rb',0                           ; DATA XREF: sub_44B140+9o
                                            ; sub_4BB2E0+CFo ...
    align 4
    aWb_0 db 'wb+',0                        ; DATA XREF: sub_44B230+7o
    aGames_0 db 'GAMES',0                   ; DATA XREF: .text:0044B344o
                                            ; .text:0044B407o ...
    align 4
    aSavegameDescs db 'SAVEGAME DESCS',0    ; DATA XREF: sub_44B4E0+7Fo
                                            ; sub_492B10+81o
    align 4
    aSavegameNames db 'SAVEGAME NAMES',0    ; DATA XREF: sub_44B4E0+67o
                                            ; sub_492B10+69o
    align 4
    aLst db 'LST',0                         ; DATA XREF: sub_44B4E0+10o
                                            ; sub_44B690+2C2o
    aDelete db 'DELETE',0                   ; DATA XREF: sub_44B690+9Eo
                                            ; sub_44B990+125o ...
    align 4
    aSaveGame db 'Save Game',0              ; DATA XREF: sub_44B990+65o
                                            ; sub_493060+69o
    align 4
    aDsavelist db 'DSaveList',0             ; DATA XREF: sub_44B990+36o
    align 4
    aSavelist_gui db 'SAVELIST.GUI',0       ; DATA XREF: sub_44B990+16o
    align 4
    aThereAreNoSa_0 db 'There are no saved lists to choose from',0 ; DATA XREF: sub_44BC10+6Bo
    aDloadlist db 'DLoadList',0             ; DATA XREF: sub_44BC10+33o
    align 4
    aLoadlist_gui db 'LOADLIST.GUI',0       ; DATA XREF: sub_44BC10+13o
    align 4
    aNoLimit db 'No Limit',0                ; DATA XREF: sub_44BE70+55o
    align 4
    aCountD db 'COUNT%d',0                  ; DATA XREF: sub_44BE70+38o
    aDesclist db 'DESCLIST',0               ; DATA XREF: sub_44BE70+25o
                                            ; sub_44BFD0+Eo ...
    align 4
    aSliderD db 'SLIDER%d',0                ; DATA XREF: sub_44BFD0+47o
                                            ; sub_44C7E0+416o
    align 4
    aUnitpics db 'unitpics',0               ; DATA XREF: sub_44C0D0+B8o
                                            ; sub_4942E0+141o
    align 4
    aPiclist db 'PICLIST',0                 ; DATA XREF: sub_44C0D0+13o
                                            ; .text:0044C235o ...
    aReset db 'Reset',0                     ; DATA XREF: sub_44C420+1CBo
                                            ; sub_44C7E0+5EFo
    align 4
    aLoad_0 db 'Load',0                     ; DATA XREF: sub_44C420+171o
                                            ; sub_44C7E0+5BFo
    align 4
    aScrollslider db 'SCROLLSLIDER',0       ; DATA XREF: sub_44C7E0+453o
                                            ; sub_44C7E0+474o
    align 4
    aSSDmDe db '%s',0Dh,'%s %dM  %dE',0     ; DATA XREF: sub_44C7E0+2DAo
    align 4
    aOldcounts db 'OLDCOUNTS',0             ; DATA XREF: sub_44C7E0+236o
    align 4
    aUnitspics db 'UNITSPICS',0             ; DATA XREF: sub_44C7E0+1C9o
    align 4
    aUnitsrestricti db 'UNITSRESTRICTINFO',0 ; DATA XREF: sub_44C7E0+179o
    align 4
    aUnittextarray db 'UNITTEXTARRAY',0     ; DATA XREF: sub_44C7E0+14Bo
    align 4
    aUnitpicarray db 'UNITPICARRAY',0       ; DATA XREF: sub_44C7E0+107o
    align 4
    aFlags db 'FLAGS',0                     ; DATA XREF: sub_44C7E0+88o
    align 4
    aUnitrestrict5x db 'UnitRestrict5x',0   ; DATA XREF: sub_44C7E0+65o
    align 4
    aRestrict2_gui db 'RESTRICT2.GUI',0     ; DATA XREF: sub_44C7E0+2Eo
    align 4
    aNetcondenserBu db 'netCondenser: BUFFER_ACC_SIZE = %ld, requested send size = %'
                                            ; DATA XREF: sub_44F940+3Do
    db 'ld , resized buffer to accomodate.',0Ah,0
    aNetcondenser3N db 'netCondenser[3]: needed %ld, had client buffersize = %ld',0Ah
                                            ; DATA XREF: sub_44F9C0+22Co
    db 0
    align 4
    aNetcondenser2R db 'netCondenser[2]: r_unpackedSize = %ld, client buffersize = %'
                                            ; DATA XREF: sub_44F9C0+1A0o
    db 'ld',0Ah,0
    aNetcondenser1R db 'netCondenser[1]: r_unpackedSize = %ld, client buffersize = %'
                                            ; DATA XREF: sub_44F9C0+2Do
    db 'ld',0Ah,0
    ; int dword_5061B8
    dword_5061B8 dd 506270h                 ; DATA XREF: sub_450380+11Br
    dd offset aHasBeenShownTh               ; "has been shown the door"
    dd offset aHasGoneToABett               ; "has gone to a better place"
    dd offset aHasBowedOut                  ; "has bowed out"
    dd offset aHasTerminated                ; "has terminated"
    dd offset aHasBeenEradica               ; "has been eradicated"
    dd offset aHasBeenLiquida               ; "has been liquidated"
    dd offset aHasBeenObliter               ; "has been obliterated"
    dword_5061D8 dd 0FFFFFFFFh              ; DATA XREF: .text:0045373Cr
                                            ; .text:004538BEr ...
    aHasBeenObliter db 'has been obliterated',0 ; DATA XREF: .data:005061D4o
    align 4
    aHasBeenLiquida db 'has been liquidated',0 ; DATA XREF: .data:005061D0o
    aHasBeenEradica db 'has been eradicated',0 ; DATA XREF: .data:005061CCo
    aHasTerminated db 'has terminated',0    ; DATA XREF: .data:005061C8o
    align 4
    aHasBowedOut db 'has bowed out',0       ; DATA XREF: .data:005061C4o
    align 4
    aHasGoneToABett db 'has gone to a better place',0 ; DATA XREF: .data:005061C0o
    align 4
    aHasBeenShownTh db 'has been shown the door',0 ; DATA XREF: .data:005061BCo
    aHasLeftTheScen db 'has left the scene',0
    align 4
    aComputer db 'COMPUTER',0               ; DATA XREF: .text:004501DCo
                                            ; .text:00450203o ...
    align 4
    aSS_0 db '%s %s',0                      ; DATA XREF: sub_450380+131o
                                            ; Network_Process+15DDo ...
    align 4
    aYouWereRejecte db 'You were rejected from the game',0 ; DATA XREF: sub_450E20+12Fo
                                            ; sub_452C40+53o ...
    aTheCreatorHasL db 'The creator has left the game',0 ; DATA XREF: sub_450E20+122o
                                            ; sub_452C40+4Bo ...
    align 4
    aNoWatchingIsAl db 'No watching is allowed for this game',0 ; DATA XREF: sub_450E20+115o
                                            ; sub_452C40+43o ...
    align 4
    aYouNeedANewerV db 'You need a newer version of the game to enter',0
                                            ; DATA XREF: sub_450E20+108o
                                            ; sub_452C40+3Bo ...
    align 4
    aYouNeedAUnitYo db 'You need a unit you don',27h,'t have for this game',0
                                            ; DATA XREF: sub_450E20+FBo
                                            ; sub_452C40+33o ...
    align 4
    aYouHaveLostCon db 'You have lost connection with the game',0 ; DATA XREF: sub_450E20+EEo
                                            ; sub_452C40+2Bo ...
    align 4
    aTheGameIsFull db 'The game is full',0  ; DATA XREF: sub_450E20+E1o
                                            ; sub_452C40+23o ...
    align 4
    aTheGameIsClose db 'The game is closed',0 ; DATA XREF: sub_450E20+D4o
                                            ; sub_452C40+1Bo ...
    align 4
    aYouDidNotHaveT db 'You did not have the correct password',0 ; DATA XREF: sub_450E20+C7o
                                            ; sub_452C40+13o ...
    align 4
    aDirectPlayFa_0 db 'Direct Play failed to add new player.',0Ah ; DATA XREF: sub_451220+2EFo
    db 0Ah
    db 'Recommended you go to previous screen and re-join the game s'
    db 'ession.',0Ah,0
    aDirectPlayFail db 'Direct Play failed to add new player.',0Ah ; DATA XREF: sub_451220+2BAo
    db 0Ah
    db 'Recommended you go to previous screen and re-create the game'
    db ' session.',0Ah,0
    align 4
    aAiS db 'AI:%s',0                       ; DATA XREF: sub_451220+F0o
    align 4
    aTimedOutWhileC db 'Timed out while connecting to DirectPlay lobby!',0
                                            ; DATA XREF: sub_451640+FDo
    aLobbyJoinInfo db 'LOBBY JOIN INFO',0   ; DATA XREF: sub_451640+5Eo
    aUnableToConnec db 'Unable to connect to DirectPlay lobby.',0 ; DATA XREF: sub_4517B0+22Co
    align 4
    aPacketData db 'PACKET DATA',0          ; DATA XREF: sub_451FD0+360o
    aPacketDataAgai db 'PACKET DATA AGAIN',0 ; DATA XREF: HAPINET_GetPacket+7Fo
                                            ; HAPINET_GetPacket+108o
    align 4
    aTimetext db 'TIMETEXT',0               ; DATA XREF: .text:00453890o
    align 4
    aWillBeRejected db 'will be rejected in %d seconds',0 ; DATA XREF: .text:00453865o
    align 4
    aReject db 'REJECT',0                   ; DATA XREF: sub_4538F0+124o
    align 4
    aTalk db 'TALK',0                       ; DATA XREF: sub_4538F0+43o
                                            ; sub_4538F0+56o ...
    align 4
    aTimeout_gui db 'TIMEOUT.GUI',0         ; DATA XREF: sub_453A50+Eo
                                            ; sub_453A50+C5o ...
    aHasModifiedHis db 'has modified his executable.  Game integrity breached.',0
                                            ; DATA XREF: Network_Process+15C3o
    align 4
    aPlayerSHasDisc db 'Player %s has disconnected',0 ; DATA XREF: Network_Process+1291o
    align 4
    a_02d02d02d db '_%02d%02d%02d',0        ; DATA XREF: .text:0045787Co
    align 4
    aTotala db 'TotalA',0                   ; DATA XREF: .text:00457810o
    align 4
    flt_5065F8 dd -8.0000001e-1             ; DATA XREF: sub_4597F0+26w
                                            ; sub_459C70+64Dr
    flt_5065FC dd 1.0                       ; DATA XREF: sub_4597F0+2Ew
                                            ; sub_459C70+65Ar
    flt_506600 dd 2.5e-1                    ; DATA XREF: sub_4597F0+34w
                                            ; sub_459C70+669r
    aCompositebuffe db 'CompositeBuffer',0  ; DATA XREF: sub_458180+1Fo
    aObjectState db 'Object State',0        ; DATA XREF: sub_45A8D0+36o
                                            ; sub_45A950+3Ao
    align 4
    aPointList db 'Point List',0            ; DATA XREF: sub_45AEC0+2Fo
    align 4
    aFaultWhileTryi db 'Fault while trying to execute button action.',0
                                            ; DATA XREF: sub_45B44C+13o
    align 4
    aOnlprocessbutt db 'ONLProcessButtonCommand',0 ; DATA XREF: sub_45B250+1C3o
    aOnlgetversion db 'ONLGetVersion',0     ; DATA XREF: sub_45B250+183o
                                            ; sub_45B490+106o ...
    align 4
    aPleaseInsertTh db 'Please insert the Installation CD (Disc 1) and select%s"%s" '
                                            ; DATA XREF: sub_45B250+113o
    db 'again.',0
    align 4
    ; char asc_5066CC
    asc_5066CC db '/\',0                    ; DATA XREF: sub_45B250+8Eo
                                            ; sub_45B490+70o ...
    align 4
    aOnlgetlinkinfo db 'ONLGetLinkInfo',0   ; DATA XREF: sub_45B490+136o
    align 4
    aOnlloadconfigf db 'ONLLoadConfigFile',0 ; DATA XREF: sub_45B670+148o
    dd 0, 68580000h, 0FFF00050h, 684CFFFFh, 100050h, 68400000h, 400050h, 0
    dd 0FFFF0000h, 6830FFFFh, 0FFFB0050h, 684CFFFFh, 50050h, 68200000h, 140050h
    dd 0, 0FFFF0000h, 6818FFFFh, 50h, 68040000h, 20050h, 67F80000h, 40050h
    dd 67E80000h, 60050h, 67D80000h, 80050h, 67C40000h, 0A0050h, 0, 0FFFE0000h
    dd 67BCFFFFh, 67B00050h, 67A40050h, 67980050h, 678C0050h, 50h
    align 4
    dword_506788 dd 1                       ; DATA XREF: .text:0045FD64w
                                            ; .text:0045FF1Cw ...
    aSpectrak db 'SPECTRAK',0
    align 4
    aRepttrak db 'REPTTRAK',0
    align 4
    aRandtrak db 'RANDTRAK',0
    align 4
    aNormtrak db 'NORMTRAK',0
    align 4
    aNotrak db 'NOTRAK',0                   ; DATA XREF: sub_45D130+14o
                                            ; sub_45D280+61o ...
    align 4
    aAllInfoChatted db 'All info chatted',0
    align 4
    aHighChatLevel db 'High chat level',0
    aDetailedChat db 'Detailed chat',0
    align 4
    aMediumChat db 'Medium chat',0
    aOnlyImportantI db 'Only important info',0
    aNoChat db 'No Chat',0
    aDRapidFire db '%d  Rapid Fire',0
    align 4
    aDSluggish db '%d  Sluggish',0
    align 4
    aDFast db '%d  Fast',0
    align 4
    aDNormal db '%d  Normal',0
    align 4
    aDSlow db '%d  Slow',0
    align 4
    aDXD db '%d X %d',0                     ; DATA XREF: .text:0045BBCEo
                                            ; .text:0045BC63o ...
    aVidval db 'VIDVAL',0                   ; DATA XREF: .text:0045BBADo
                                            ; .text:0045BC68o ...
    align 4
    aVidsldr db 'VIDSLDR',0                 ; DATA XREF: .text:0045BBF6o
                                            ; sub_45E5E0+11Fo ...
    aGamma_0 db 'GAMMA',0                   ; DATA XREF: .text:0045BD24o
                                            ; sub_45E5E0+41Ao ...
    align 4
    aFxvol_0 db 'FXVOL',0                   ; DATA XREF: .text:0045BDE4o
                                            ; .text:0045DA2Do ...
    align 4
    aMusicvol_0 db 'MUSICVOL',0             ; DATA XREF: .text:0045BEA4o
                                            ; sub_45D130+54o ...
    align 4
    aSS_5 db '%s (%s)',0                    ; DATA XREF: .text:0045BFCCo
    aFaster db 'Faster',0                   ; DATA XREF: .text:0045BFBAo
    align 4
    aFast db 'Fast',0                       ; DATA XREF: .text:0045BFB3o
    align 4
    aSlower db 'Slower',0                   ; DATA XREF: .text:0045BF9Eo
    align 4
    aSlow db 'Slow',0                       ; DATA XREF: .text:0045BF8Co
    align 4
    aNormal db 'Normal',0                   ; DATA XREF: .text:0045BF76o
                                            ; PlayerStatusMenu+258o
    align 4
    aGame db 'GAME',0                       ; DATA XREF: .text:0045C0ADo
                                            ; sub_45ED50+87o ...
    align 4
    aScreen db 'SCREEN',0                   ; DATA XREF: sub_45C170+6o
                                            ; sub_45ED50+147o ...
    align 4
    aMaxlinestext db 'MAXLINESTEXT',0       ; DATA XREF: sub_45C220+F8o
                                            ; sub_45ED50+270o
    align 4
    aMaxlines db 'MAXLINES',0               ; DATA XREF: sub_45C220+Do
                                            ; sub_45ED50+280o ...
    align 4
    aTextscrolltext db 'TEXTSCROLLTEXT',0   ; DATA XREF: sub_45C330+85o
    align 4
    aDSecs db '%d secs',0                   ; DATA XREF: sub_45C330+70o
    aTxtscrol db 'TXTSCROL',0               ; DATA XREF: sub_45C330+8o
                                            ; sub_45ED50+324o ...
    align 4
    aTracknum db 'TRACKNUM',0               ; DATA XREF: sub_45C3F0+C7o
                                            ; sub_45C3F0+E3o ...
    align 4
    aNoDisc db 'NO DISC',0                  ; DATA XREF: sub_45C3F0+85o
    aTracktype db 'TRACKTYPE',0             ; DATA XREF: sub_45C3F0+1Co
                                            ; sub_45C3F0+57o ...
    align 4
    aPanel_0 db 'PANEL',0                   ; DATA XREF: sub_45CE80+9o
                                            ; sub_45CE80+86o ...
    align 4
    aMusic db 'MUSIC',0                     ; DATA XREF: sub_45CFC0+A1o
                                            ; sub_45D7C0+4Fo ...
    align 4
    aStartopt_gui db 'STARTOPT.GUI',0       ; DATA XREF: sub_45CFC0+51o
    align 4
    aPrefs_gui db 'PREFS.GUI',0             ; DATA XREF: sub_45CFC0+20o
    align 4
    aCdnext db 'CDNEXT',0                   ; DATA XREF: sub_45D130+D8o
                                            ; sub_45D280+108o
    align 4
    aCdplay db 'CDPLAY',0                   ; DATA XREF: sub_45D130+B7o
                                            ; sub_45D280+CAo
    align 4
    aCdstop db 'CDSTOP',0                   ; DATA XREF: sub_45D130+96o
                                            ; sub_45D280+1A8o
    align 4
    aCdprev db 'CDPREV',0                   ; DATA XREF: sub_45D130+75o
                                            ; sub_45D280+15Fo
    align 4
    aTrackmode db 'TRACKMODE',0             ; DATA XREF: sub_45D130+33o
                                            ; sub_45D130+F9o ...
    align 4
    aRestore db 'RESTORE',0                 ; DATA XREF: sub_45D280+2BCo
                                            ; sub_45DA90+E5o ...
    aUndo db 'UNDO',0                       ; DATA XREF: sub_45D280+1F7o
                                            ; sub_45DA90+CCo ...
    align 4
    aOptmusic4x db 'optmusic4x',0           ; DATA XREF: sub_45D7C0+60o
    align 4
    aMusicrt_gui db 'MUSICRT.GUI',0         ; DATA XREF: sub_45D7C0+38o
    aSpeech db 'SPEECH',0                   ; DATA XREF: .text:0045DA75o
                                            ; sub_45DA90+34o ...
    align 4
    aTest db 'TEST',0                       ; DATA XREF: .text:0045DA51o
                                            ; sub_45DA90+1D0o ...
    align 4
    aVoltext db 'VOLTEXT',0                 ; DATA XREF: .text:0045DA09o
                                            ; sub_45DA90+30Bo ...
    aMode db 'MODE',0                       ; DATA XREF: .text:0045D9E4o
                                            ; sub_45DA90+23Ao ...
    align 4
    aSoundsExplode_ db 'sounds\explode.wav',0 ; DATA XREF: sub_45DA90+1DFo
    align 4
    aSound_0 db 'SOUND',0                   ; DATA XREF: sub_45DE30+91o
                                            ; .text:0045FF2Bo
    align 4
    aOptsound4x db 'optsound4x',0           ; DATA XREF: sub_45DE30+5Do
    align 4
    aSounds_0 db 'SOUNDS',0                 ; DATA XREF: sub_45DE30+4Co
    align 4
    aSoundsrt_gui db 'SOUNDSRT.GUI',0       ; DATA XREF: sub_45DE30+3Ao
    align 4
    aSelvmode_gui db 'selvmode.gui',0       ; DATA XREF: sub_45E100+348o
    align 4
    aShading_0 db 'SHADING',0               ; DATA XREF: sub_45E100+189o
                                            ; sub_45E100+1A4o ...
    aBshadows db 'BSHADOWS',0               ; DATA XREF: sub_45E100+CBo
                                            ; sub_45E100+EAo ...
    align 4
    aAnti db 'ANTI',0                       ; DATA XREF: sub_45E100+6Do
                                            ; sub_45E100+88o ...
    align 4
    aVisuals db 'VISUALS',0                 ; DATA XREF: sub_45E5E0+36Co
                                            ; .text:0045FCFCo
    ; char off_506A4C
    off_506A4C dd offset loc_444956         ; DATA XREF: sub_45E5E0+2E9o
                                            ; sub_45E5E0+2FDo
    aOptvisual4x db 'optvisual4x',0         ; DATA XREF: sub_45E5E0+8Fo
    aVisuals_gui db 'VISUALS.GUI',0         ; DATA XREF: sub_45E5E0+81o
    aVisualrt_gui db 'VISUALRT.GUI',0       ; DATA XREF: sub_45E5E0+6Fo
    align 4
    aSelvmode_gui_0 db 'SELVMODE.GUI',0     ; DATA XREF: sub_45E5E0+20o
    align 4
    aUnitchat_0 db 'UNITCHAT',0             ; DATA XREF: sub_45EAD0+85o
                                            ; sub_45EAD0+B1o ...
    align 4
    aLeftclick db 'LEFTCLICK',0             ; DATA XREF: sub_45EAD0+2Fo
                                            ; sub_45EAD0+56o ...
    align 4
    aOptinterface4x db 'optinterface4x',0   ; DATA XREF: sub_45ED50+5Fo
    align 4
    aSpeeds_gui db 'SPEEDS.GUI',0           ; DATA XREF: sub_45ED50+4Eo
    align 4
    aSpeedsrt_gui db 'SPEEDSRT.GUI',0       ; DATA XREF: sub_45ED50+3Co
    align 4
    aMaxUnits db 'Max Units:',0             ; DATA XREF: sub_45F1D0+4D6o
    align 4
    aStartingEnergy db 'Starting Energy:',0 ; DATA XREF: sub_45F1D0+45Do
    align 4
    aStartingMetal db 'Starting Metal:',0   ; DATA XREF: sub_45F1D0+3E5o
    aMap_0 db 'Map:',0                      ; DATA XREF: sub_45F1D0+398o
    align 4
    aDifficulty_0 db 'Difficulty:',0        ; DATA XREF: sub_45F1D0+346o
    aWatching_1 db 'Watching:',0            ; DATA XREF: sub_45F1D0+2F9o
    align 4
    aCheatCodes db 'Cheat Codes:',0         ; DATA XREF: sub_45F1D0+2A7o
    align 4
    aLineOfSight db 'Line of Sight:',0      ; DATA XREF: sub_45F1D0+229o
    align 4
    aMappingMode db 'Mapping Mode:',0       ; DATA XREF: sub_45F1D0+1D8o
    align 4
    aStartingLocati db 'Starting Locations:',0 ; DATA XREF: sub_45F1D0+15Eo
    aPermanent db 'Permanent',0             ; DATA XREF: sub_45F1D0+E9o
    align 4
    aCircular db 'Circular',0               ; DATA XREF: sub_45F1D0+E1o
    align 4
    aTrue db 'True',0                       ; DATA XREF: sub_45F1D0+D9o
    align 4
    aUnmapped db 'Unmapped',0               ; DATA XREF: sub_45F1D0+D1o
    align 4
    aMapped db 'Mapped',0                   ; DATA XREF: sub_45F1D0+C9o
    align 4
    aFixed db 'Fixed',0                     ; DATA XREF: sub_45F1D0+C1o
    align 4
    aDisallowed db 'Disallowed',0           ; DATA XREF: sub_45F1D0+BCo
    align 4
    aRandom db 'Random',0                   ; DATA XREF: sub_45F1D0+B1o
    align 4
    aDeathmatch_0 db 'Deathmatch',0         ; DATA XREF: sub_45F1D0+A9o
    align 4
    aAllowed db 'Allowed',0                 ; DATA XREF: sub_45F1D0+A4o
    aGameEnds db 'Game Ends',0              ; DATA XREF: sub_45F1D0+8Co
    align 4
    aGameContinues db 'Game Continues',0    ; DATA XREF: sub_45F1D0+7Ao
    align 4
    aCommanderDeath db 'Commander Death:',0 ; DATA XREF: sub_45F1D0+6Bo
    align 4
    aGamesettings db 'GameSettings',0       ; DATA XREF: sub_45F1D0+2Fo
    align 4
    aGameoptions_gu db 'GAMEOPTIONS.GUI',0  ; DATA XREF: sub_45F1D0+19o
    aMorebar db 'MOREBAR',0                 ; DATA XREF: .text:0045F7BDo
                                            ; .text:0045F81Do ...
    aTextregion db 'TextRegion',0           ; DATA XREF: .text:0045F7AEo
                                            ; .text:0045F838o ...
    align 4
    aIgmbrief db 'igmbrief',0               ; DATA XREF: .text:0045F86Fo
                                            ; sub_4609B0+261o
    align 4
    aBriefing_gui db 'BRIEFING.GUI',0       ; DATA XREF: .text:0045F80Do
                                            ; sub_4609B0+1FFo
    align 4
    aLineD_0 db 'Line%d',0                  ; DATA XREF: sub_45F8C0+BAo
    align 4
    aHelp_0 db 'Help',0                     ; DATA XREF: sub_45F8C0+5Eo
    align 4
    aHelp db 'help',0                       ; DATA XREF: sub_45F8C0+2Eo
                                            ; sub_4ACE50+4BFo ...
    align 4
    aPage db 'Page',0                       ; DATA XREF: .text:0045FAEAo
                                            ; .text:0045FB07o
    align 4
    aDhelp db 'dhelp',0                     ; DATA XREF: .text:0045FB53o
                                            ; sub_4609B0+159o
    align 4
    aHelp_gui db 'HELP.GUI',0               ; DATA XREF: .text:0045FB40o
                                            ; sub_4609B0+146o
    align 4
    aLightbar db 'LIGHTBAR',0               ; DATA XREF: sub_45FFB0+57o
                                            ; sub_4679A0+Do ...
    align 4
    aOptions4x db 'options4x',0             ; DATA XREF: sub_460160+DFo
    align 4
    aBkupsurface db 'BKUPSURFACE',0         ; DATA XREF: sub_460160+88o
    aFlipsurface db 'FLIPSURFACE',0         ; DATA XREF: sub_460160+2Bo
    aRestart db 'RESTART',0                 ; DATA XREF: .text:0046035Eo
                                            ; sub_460800+7Ao ...
    aMissionname1 db 'MISSIONNAME1',0       ; DATA XREF: sub_4604A0+D7o
    align 4
    aMissionname_0 db 'MISSIONNAME',0       ; DATA XREF: sub_4604A0+39o
                                            ; sub_4604A0+AEo
    aDrestart db 'drestart',0               ; DATA XREF: sub_4604A0+26o
    align 4
    aRestart_gui db 'RESTART.GUI',0         ; DATA XREF: sub_4604A0+12o
    aSurrenderThi_0 db 'Surrender this battle and exit to Windows?',0
                                            ; DATA XREF: sub_460680+124o
    align 4
    aExitTheBattle db 'Exit the Battle',0   ; DATA XREF: sub_460680+111o
    aSurrenderThisB db 'Surrender this battle and return to main menu?',0
                                            ; DATA XREF: sub_460680+F4o
    align 4
    aExitgame db 'EXITGAME',0               ; DATA XREF: sub_460800+43o
    align 4
    aRestart_0 db 'Restart',0               ; DATA XREF: sub_4608B0+79o
    aExitmenu_gui db 'EXITMENU.GUI',0       ; DATA XREF: sub_4608B0+Fo
    align 4
    aMission_0 db 'MISSION',0               ; DATA XREF: sub_4609B0+1BAo
                                            ; sub_460CC0+E2o ...
    aHelp_1 db 'HELP',0                     ; DATA XREF: sub_4609B0+116o
    align 4
    aPrefs db 'PREFS',0                     ; DATA XREF: sub_4609B0+F2o
    align 4
    aSavegame_1 db 'SAVEGAME',0             ; DATA XREF: sub_4609B0+CEo
                                            ; sub_460CC0+43o
    align 4
    aLoadgame_0 db 'LOADGAME',0             ; DATA XREF: sub_4609B0+AAo
                                            ; sub_460CC0+80o
    align 4
    aSettings_0 db 'Settings',0             ; DATA XREF: sub_460CC0+CDo
    align 4
    aArmopt_gui db 'ARMOPT.GUI',0           ; DATA XREF: sub_460CC0+10o
    align 4
    dword_506DBC dd 1                       ; DATA XREF: sub_434BF0+2C4r
                                            ; sub_447B10+955r ...
    aSettingM_defau db 'setting m_defaultSendPacingMs to: %lums',0Ah,0
                                            ; DATA XREF: sub_461020+42o
                                            ; sub_4619E0+4Co
    align 4
    aBytesToSendToD db 'bytes to send to (DPID)(%ld): %ld',0Ah,0 ; DATA XREF: .text:0046118Do
                                            ; .text:00461932o ...
    align 4
    aForceAllocated db 'force-allocated a previously-used buffer, ix=%ld',0Ah,0
                                            ; DATA XREF: sub_461B10+EDo
    align 4
    aBufferEligible db 'buffer eligible for reuse:  all packets have been sent more '
                                            ; DATA XREF: sub_461B10+B5o
                                            ; sub_461C20+D1o ...
    db 'than %lu game ticks ago',0Ah,0
    align 4
    aCurGameTimeLdM db 'cur game time: %ld, min retain=%ld, mustBeSentBefore=%ld',0Ah
                                            ; DATA XREF: sub_461B10+5Co
                                            ; sub_461C20+79o ...
    db 0
    align 4
    aCurrentPacketP db 'current packet pool index set to: %ld',0Ah,0
                                            ; DATA XREF: sub_461C20+114o
                                            ; sub_461FD0+35Ao
    align 4
    aForceInitializ db 'force-initializing a in-use buffer which was not eligible fo'
                                            ; DATA XREF: sub_461C20+F3o
    db 'r reuse!',0Ah,0
    align 4
    aCurrentPacke_0 db 'current packet pool index: %ld',0Ah,0 ; DATA XREF: sub_461C20+11o
    aCurrentBuffe_0 db 'current buffer pool ix: %d, current packet pool ix: %d',0Ah,0
                                            ; DATA XREF: sub_461FD0+3Co
    aBufsToGrowByDP db 'bufs to grow by: %d, packets to grow by: %d',0Ah,0
                                            ; DATA XREF: sub_461FD0+28o
    align 4
    aCurrentBufferP db 'current buffer pool count: %d, current packet pool count: %d'
                                            ; DATA XREF: sub_461FD0+11o
    db 0Ah,0
    align 4
    aSendingLdPacke db 'sending %ld packets in frame: %ld',0Ah,0 ; DATA XREF: sub_4624A0+172o
    align 4
    aExtractedPacke db 'extracted packet (len=%ld, type=%d, data="%s")',0Ah,0
                                            ; DATA XREF: sub_4624A0+ECo
    aAssigningPacke db 'assigning packets to frame number: %ld',0Ah,0
                                            ; DATA XREF: sub_4624A0+72o
    aPlayerLdTicksB db 'player: %ld, ticks betw sends=%lu, nextsend=%lu, gametimerea'
                                            ; DATA XREF: sub_4624A0+1Do
    db 'l=%lu',0Ah,0
    align 4
    aOutOfSpaceInBu db 'out of space in buffer!',0Ah,0 ; DATA XREF: sub_4628D0+C6o
    align 4
    aAssignedPacket db 'assigned packet count this buf: %ld',0Ah,0 ; DATA XREF: sub_4628D0+ADo
    align 4
    aSetFirstPacket db 'set first packet ix to: %ld',0Ah,0 ; DATA XREF: sub_4628D0+96o
    align 4
    aCurrentBufferL db 'current buffer length: %ld, toadd=%ld, max=%ld',0Ah,0
                                            ; DATA XREF: sub_4628D0+2Do
    aAddingPacketLd db 'adding packet %ld (data="%s")',0Ah,0 ; DATA XREF: sub_4628D0+12o
    align 4
    aInitializeFree db 'initialize freeing packet %ld',0Ah,0 ; DATA XREF: sub_4629B0+3Co
    align 4
    aFreeingPackets db 'freeing packets assigned. range: %ld for %ld',0Ah,0
                                            ; DATA XREF: sub_4629B0+21o
    align 4
    aWarningRemovep db 'Warning! RemovePacket called for packet in pending queue!',0Ah
                                            ; DATA XREF: sub_462AE0+36o
    db 0
    align 4
    aRemovingPacket db 'removing packet (len=%ld, type=%d, data="%s")',0Ah,0
                                            ; DATA XREF: sub_462AE0+20o
    align 4
    aPlayerframeinf db 'PlayerFrameInfo::Initialize: %ld',0 ; DATA XREF: sub_462D90+59o
                                            ; sub_462D90+C0o ...
    align 4
    aHapinet_receiv db 'HAPINET_receivepacket failed (%s)',0Ah,0 ; DATA XREF: sub_462F30+503o
    align 4
    aNoMemoryForAll db 'no memory for allocating saved receive frame',0Ah,0
                                            ; DATA XREF: sub_462F30+31Do
    align 4
    aMessagearrived db 'MessageArrived',0   ; DATA XREF: sub_463CA0+154o
    align 4
    aSSSS db '<%s%s%s> %s',0                ; DATA XREF: ChatHandling_1+3Co
    asc_5072D4 db '->',0                    ; DATA XREF: ChatHandling_1+17o
    align 4
    aCore db 'Core',0                       ; DATA XREF: sub_464290+177o
                                            ; sub_464290+1F0o ...
    align 4
    aArm db 'Arm',0                         ; DATA XREF: sub_464290+16Fo
                                            ; sub_464290+1DFo ...
    aPlayerDSecond db 'Player %d Second',0  ; DATA XREF: sub_4644D0+D8o
    align 4
    aPlayerDFirst db 'Player %d First',0    ; DATA XREF: sub_4644D0+97o
    aAiDefault_txt db 'ai\default.txt',0    ; DATA XREF: sub_4648E0+31o
    align 4
    aYouReOutContin db 'You',27h,'re out!  Continue Watching?',0 ; DATA XREF: sub_464E70+81o
                                            ; UpdateDatePlayers+7E3o
    aYouArePlacedIn db 'You are placed in watch mode because you are hosting AI play'
                                            ; DATA XREF: UpdateDatePlayers+87Eo
    db 'ers which are still alive.  If you exit, they will be termin'
    db 'ated.',0
    align 4
    aController db 'Controller',0           ; DATA XREF: sub_465FB0+52o
                                            ; sub_4662F0+214o
    align 4
    aPlayerI db 'Player%i',0                ; DATA XREF: sub_465FB0+19o
                                            ; sub_466050+84o ...
    align 4
    aAlliances db 'Alliances',0             ; DATA XREF: sub_466050+23Co
                                            ; sub_4662F0+250o
    align 4
    aDisplaytimer db 'DisplayTimer',0       ; DATA XREF: sub_466050+1FCo
                                            ; sub_4662F0+204o
    align 4
    aWinlosetime db 'WinLoseTime',0         ; DATA XREF: sub_466050+1E8o
                                            ; sub_4662F0+1F1o
    aUpdatetime db 'UpdateTime',0           ; DATA XREF: sub_466050+1DAo
                                            ; sub_4662F0+1DCo
    align 4
    aAddplayerstora db 'AddPlayerStorage',0 ; DATA XREF: sub_466050+18Bo
                                            ; sub_4662F0+1A1o
    align 4
    aPlayermetalsto db 'PlayerMetalStorage',0 ; DATA XREF: sub_466050+177o
                                            ; sub_4662F0+18Do
    align 4
    aPlayerenergyst db 'PlayerEnergyStorage',0 ; DATA XREF: sub_466050+161o
                                            ; sub_4662F0+175o
    aMetalwasted db 'MetalWasted',0         ; DATA XREF: sub_466050+14Bo
                                            ; sub_4662F0+15Bo
    aEnergywasted db 'EnergyWasted',0       ; DATA XREF: sub_466050+135o
                                            ; sub_4662F0+141o
    align 4
    aTotalmetalcons db 'TotalMetalConsumed',0 ; DATA XREF: sub_466050+11Fo
                                            ; sub_4662F0+127o
    align 4
    aTotalenergycon db 'TotalEnergyConsumed',0 ; DATA XREF: sub_466050+109o
                                            ; sub_4662F0+10Do
    aTotalmetalprod db 'TotalMetalProduced',0 ; DATA XREF: sub_466050+F3o
                                            ; sub_4662F0+F3o
    align 4
    aTotalenergypro db 'TotalEnergyProduced',0 ; DATA XREF: sub_466050+DDo
                                            ; sub_4662F0+D9o
    aMetal db 'Metal',0                     ; DATA XREF: sub_466050+C7o
                                            ; sub_4662F0+C1o ...
    align 4
    aEnergy db 'Energy',0                   ; DATA XREF: sub_466050+B1o
                                            ; sub_4662F0+A9o ...
    align 4
    aGametime db 'GameTime',0               ; DATA XREF: sub_466050+2Fo
                                            ; sub_4662F0+36o
    align 4
    aHumanPlayer db 'Human Player',0        ; DATA XREF: sub_466050+1Do
                                            ; sub_4662F0+2Co
    align 4
    aTempRadarPic db 'TEMP RADAR PIC',0     ; DATA XREF: sub_4665D0+CFo
    align 4
    aRadarpicTemp db 'RADARPIC TEMP',0      ; DATA XREF: sub_466780+F4o
    align 4
    aRadarPicture db 'RADAR PICTURE',0      ; DATA XREF: sub_466780+8Ao
    align 4
    aRadarMapped db 'RADAR MAPPED',0        ; DATA XREF: sub_4669B0+45o
    align 4
    aRadarFinal db 'RADAR FINAL',0          ; DATA XREF: sub_4669B0+1Ao
    aDS db '%d %s',0                        ; DATA XREF: sub_467CB0+72o
                                            ; LOS_GUIText+B11o
    align 4
    aDSS db '%d %s - %s',0                  ; DATA XREF: sub_467CB0+4Eo
                                            ; LOS_GUIText+AE8o
    align 4
    aVeteran db 'Veteran',0                 ; DATA XREF: sub_467CB0+34o
                                            ; LOS_GUIText+AC7o
    aKill db 'kill',0                       ; DATA XREF: sub_467CB0+Fo
                                            ; LOS_GUIText+A98o
    align 4
    aKills_0 db 'kills',0                   ; DATA XREF: sub_467CB0+5o
                                            ; LOS_GUIText+A82o
    align 4
    aBackgroundMiss db 'Background Mission Q:',0 ; DATA XREF: sub_467E50+40Do
    align 4
    aSStateD db '    ',27h,'%s',27h,' state: %d',0Ah,0 ; DATA XREF: sub_467E50+3CCo
                                            ; sub_467E50+46Bo
    aSStateDTgtS db '    ',27h,'%s',27h,' state: %d  tgt: ',27h,'%s',27h,0Ah,0
                                            ; DATA XREF: sub_467E50+3A6o
                                            ; sub_467E50+445o
    align 4
    aMissionQ db 'Mission Q:',0             ; DATA XREF: sub_467E50+36Eo
    align 4
    aAutotargetWPri db 'autotarget w[pri:sec:spe]: w[%c:%c:%c]',0Ah,0
                                            ; DATA XREF: sub_467E50+338o
    aOccupyS db 'occupy: %s',0Ah,0          ; DATA XREF: sub_467E50+2BAo
    off_5075DC dd offset dword_524941       ; DATA XREF: sub_467E50+2ABo
    aGround db 'GROUND',0                   ; DATA XREF: sub_467E50+2A3o
    align 4
    aNone_1 db 'NONE',0                     ; DATA XREF: sub_467E50+29Bo
    align 4
    aDamageD db 'damage: %d',0Ah,0          ; DATA XREF: sub_467E50+26Bo
    aBuildtimeleft1 db 'buildtimeleft: %1.3f',0Ah,0 ; DATA XREF: sub_467E50+23Eo
    align 4
    aControllerD db 'controller: %d',0Ah,0  ; DATA XREF: sub_467E50+20Bo
    aPlayernoDSSS db 'playerno: %d ',27h,'%s',27h,' %s - %s',0Ah,0 ; DATA XREF: sub_467E50+1D8o
                                            ; .text:00468785o
    align 4
    aRemote db 'REMOTE',0                   ; DATA XREF: sub_467E50+1C0o
                                            ; .text:0046876Do
    align 4
    aLocal db 'LOCAL',0                     ; DATA XREF: sub_467E50+1B9o
                                            ; .text:00468766o
    align 4
    aBuilding_0 db 'BUILDING',0             ; DATA XREF: sub_467E50+19Co
                                            ; .text:00468749o
    align 4
    aMobile db 'MOBILE',0                   ; DATA XREF: sub_467E50+18Do
                                            ; .text:00468740o
    align 4
    aUid03d04xS db 'uid: %03d/%04x ',27h,'%s',27h,0Ah,0 ; DATA XREF: sub_467E50+162o
    align 4
    asc_50767C db '================',0      ; DATA XREF: sub_467E50+141o
    align 4
    aUnitStateProbe db 'Unit State Probe',0 ; DATA XREF: sub_467E50+12Co
    align 4
    aReceive1_1fKS db 'Receive - %1.1f K/s',0 ; DATA XREF: sub_468380+160o
    aSend1_1fKS db 'Send - %1.1f K/s',0     ; DATA XREF: sub_468380+6Ao
    align 4
    a3dS db '       %3d %% - ',27h,'%s',27h,0Ah,0 ; DATA XREF: .text:00468948o
    align 4
    aUnitsICanBuild db 'Units I can build, and the probabilities:',0Ah,0
                                            ; DATA XREF: .text:00468836o
    align 4
    aControllerD_0 db 'controller: %d',0Ah  ; DATA XREF: .text:004687B8o
    db 0Ah,0
    align 4
    aUid03dS db 'uid: %03d ',27h,'%s',27h,0Ah,0 ; DATA XREF: .text:0046870Fo
    asc_507734 db '==================',0    ; DATA XREF: .text:004686EFo
    align 4
    aUnitBuilderPro db 'Unit Builder Probe',0 ; DATA XREF: .text:004686DAo
    align 4
    aD_6 db ' (%+d)',0                      ; DATA XREF: PlayerStatusMenu+2DCo
    align 4
    aGameSpeed db 'Game Speed',0            ; DATA XREF: PlayerStatusMenu+292o
                                            ; sub_490DF0+78o
    align 4
    aD_5 db '%+d',0                         ; DATA XREF: PlayerStatusMenu+27Fo
    aSDMaxD db '%s : %d  (Max %d)',0        ; DATA XREF: PlayerStatusMenu+221o
    align 4
    aTotalUnits db 'Total Units',0          ; DATA XREF: PlayerStatusMenu+212o
    aS02d02d02d db '%s : %02d:%02d:%02d',0  ; DATA XREF: PlayerStatusMenu+1BEo
                                            ; GameUnit_LOS_Unknown1+1563o
    aMisc db 'Misc',0                       ; DATA XREF: GameUnit_LOS_Unknown1+16C2o
    align 4
    aWeapon db 'Weapon',0                   ; DATA XREF: GameUnit_LOS_Unknown1+16B1o
                                            ; LOS_GUIText+C17o
    align 4
    aRenderFog db 'Render Fog',0            ; DATA XREF: GameUnit_LOS_Unknown1+168Fo
    align 4
    aRenderStuff db 'Render Stuff',0        ; DATA XREF: GameUnit_LOS_Unknown1+167Eo
    align 4
    aRenderStatic db 'Render Static',0      ; DATA XREF: GameUnit_LOS_Unknown1+166Do
    align 4
    aLogic db 'Logic',0                     ; DATA XREF: GameUnit_LOS_Unknown1+165Co
    align 4
    aUnits_0 db 'Units',0                   ; DATA XREF: GameUnit_LOS_Unknown1+164Bo
                                            ; sub_486FD0+11o ...
    align 4
    aNetwork db 'Network',0                 ; DATA XREF: GameUnit_LOS_Unknown1+163Ao
    aModeSInfoS db 'MODE %s INFO %s',0      ; DATA XREF: GameUnit_LOS_Unknown1+13AEo
    aNormal_0 db 'NORMAL',0                 ; DATA XREF: GameUnit_LOS_Unknown1+13A0o
    align 4
    aDebug db 'DEBUG',0                     ; DATA XREF: GameUnit_LOS_Unknown1+1394o
    align 4
    aRelease db '[Release]',0               ; DATA XREF: GameUnit_LOS_Unknown1+136Bo
    align 4
    aFrateD db 'FRATE: %d',0Ah,0            ; DATA XREF: GameUnit_LOS_Unknown1+1337o
    align 4
    a_1f db '%.1f',0                        ; DATA XREF: GameUnit_LOS_Unknown1+888o
                                            ; GameUnit_LOS_Unknown1+8DFo
    align 4
    off_50783C dd offset loc_4B6425         ; DATA XREF: GameUnit_LOS_Unknown1+5B5o
                                            ; GameUnit_LOS_Unknown1+646o
    aSSS_0 db '%s %s%s',0                   ; DATA XREF: LOS_GUIText+1016o
    aED db ' E:%d',0                        ; DATA XREF: LOS_GUIText+FC5o
    align 4
    aMD db ' M:%d',0                        ; DATA XREF: LOS_GUIText+F87o
    align 4
    aUnidentifiedOb db 'Unidentified object',0 ; DATA XREF: LOS_GUIText+EABo
    aR db 'R: ',0                           ; DATA XREF: LOS_GUIText+EA6o
    aS_4 db 'S: ',0                         ; DATA XREF: LOS_GUIText+E99o
    a_0f_0 db '-%.0f',0                     ; DATA XREF: LOS_GUIText+A2Ao
    align 4
    a_1f_1 db '-%.1f',0                     ; DATA XREF: LOS_GUIText+9D2o
    align 4
    a_0f db '+%.0f',0                       ; DATA XREF: LOS_GUIText+965o
    align 4
    a_1f_0 db '+%.1f',0                     ; DATA XREF: LOS_GUIText+90Do
    align 4
    aSMDED db '%s  M:%d E:%d',0             ; DATA XREF: LOS_GUIText+61Eo
    align 4
    aCorbuild db 'CORBUILD',0               ; DATA XREF: LOS_GUIText+5CAo
    align 4
    aXyhDDD db 'XYH: %d %d %d',0Ah,0        ; DATA XREF: LOS_GUIText+312o
    align 4
    aPacketsDDD db 'PACKETS: %d %d %d',0Ah,0 ; DATA XREF: LOS_GUIText+2B3o
    align 4
    aUnitsDD db 'UNITS %d\%d',0Ah,0         ; DATA XREF: LOS_GUIText+26Eo
    align 4
    aXDYD db 'X: %d  Y: %d',0Ah,0           ; DATA XREF: LOS_GUIText+230o
    align 4
    aGametimeD db 'GAMETIME: %d',0Ah,0      ; DATA XREF: LOS_GUIText+1EFo
    align 4
    aDeltatimeD db 'DELTATIME: %d',0Ah,0    ; DATA XREF: LOS_GUIText+1B7o
    align 4
    aMoveordDFireor db 'MOVEORD: %d FIREORD: %d',0Ah,0 ; DATA XREF: LOS_GUIText+17Fo
    align 4
    aPfstateDPfable db 'PFSTATE %d, PFABLE %d',0Ah,0 ; DATA XREF: LOS_GUIText+113o
    align 4
    dword_507948 dd 5072E0h                 ; DATA XREF: sub_46C2A0+11Dr
    dd offset aCore                         ; "Core"
    dword_507950 dd 502BB8h                 ; DATA XREF: sub_46C2A0+1ECr
    dword_507954 dd 502BB0h                 ; DATA XREF: sub_46C2A0+20Er
    dword_507958 dd 5079D4h                 ; DATA XREF: sub_46C2A0+22Br
    dword_50795C dd 5079C4h                 ; DATA XREF: sub_46C2A0+24Fr
    dword_507960 dd 5079B4h                 ; DATA XREF: sub_46C2A0+274r
    dword_507964 dd 5079A4h                 ; DATA XREF: sub_46C2A0+298r
    dword_507968 dd 507990h                 ; DATA XREF: sub_46C2A0+2BCr
    dword_50796C dd 507980h                 ; DATA XREF: sub_46C2A0+2E3r
    dword_507970 dd 507974h                 ; DATA XREF: sub_46C2A0+303r
    aIAmWinner db 'I am Winner',0
    aCommandersLost db 'Commanders Lost',0
    aCommandersKill db 'Commanders Killed',0
    align 4
    aExcessMetal db 'Excess Metal',0
    align 4
    aExcessEnergy db 'Excess Energy',0
    align 4
    aMetalProduced db 'Metal Produced',0
    align 4
    aEnergyProduced db 'Energy Produced',0
    aScoresD db 'Scores%d',0                ; DATA XREF: sub_46BCE0+193o
    align 4
    aPpscoresD db 'ppScores%d',0            ; DATA XREF: sub_46BCE0+14Fo
    align 4
    aScoreboardD db 'ScoreBoard%d',0        ; DATA XREF: sub_46BCE0+117o
    align 4
    aAlliesD db 'Allies%d',0                ; DATA XREF: sub_46BCE0+D9o
                                            ; sub_479660+2Eo ...
    align 4
    aPlayerinfoD db 'PlayerInfo%d',0        ; DATA XREF: sub_46BCE0+A2o
    align 4
    aScoresarray db 'ScoresArray',0         ; DATA XREF: sub_46BCE0+31o
    aScoreboardsarr db 'ScoreBoardsArray',0 ; DATA XREF: sub_46BCE0+1Do
    align 4
    aPlayersarray db 'PlayersArray',0       ; DATA XREF: sub_46BCE0+9o
    align 4
    aTotalAnnihilat db 'Total Annihilation',0 ; DATA XREF: LoadReporter+1B8o
                                            ; sub_49E700+EEo ...
    align 4
    a_riterminate@0 db '_RITerminate@0',0   ; DATA XREF: LoadReporter+1A7o
    align 4
    a_riintervaltim db '_RIIntervalTimer@0',0 ; DATA XREF: LoadReporter+190o
    align 4
    a_risetcallback db '_RISetCallbacks@8',0 ; DATA XREF: LoadReporter+176o
    align 4
    a_rireportgamec db '_RIReportGameChat@8',0 ; DATA XREF: LoadReporter+15Bo
    a_rireport@40 db '_RIReport@40',0       ; DATA XREF: LoadReporter+140o
    align 4
    a_riinitializee db '_RIInitializeEx@8',0 ; DATA XREF: LoadReporter+126o
    align 4
    a_rigetversion@ db '_RIGetVersion@4',0  ; DATA XREF: LoadReporter+10Bo
    a_rienable@4 db '_RIEnable@4',0         ; DATA XREF: LoadReporter+F0o
    aReporter_dll db 'reporter.dll',0       ; DATA XREF: LoadReporter+D2o
    align 4
    aPacketsSentDAc db 'packets sent=%d  ackd=%d',0 ; DATA XREF: sub_46DF40+95o
    align 4
    aExpectedDUnits db 'expected %d units, got %d',0 ; DATA XREF: sub_46DF40+72o
                                            ; sub_46DF40+86o
    align 4
    aNoUnits_expect db 'No units_expected sent from player',0 ; DATA XREF: sub_46DF40+5Bo
    dd 0, 100h
    align 4
    dword_507B6C dd 1                       ; DATA XREF: .text:00477BCDr
                                            ; .text:00477E47r ...
    byte_507B70 db 35h                      ; DATA XREF: sub_476EF0+310r
                                            ; sub_476EF0+39Er ...
    byte_507B71 db 33h                      ; DATA XREF: sub_476EF0+26Br
    a@UvrUvrUvrUvr db '@ðuVRÈuVRÈuVRÈuVRÈ',0
    align 4
    ; int dword_507B88
    dword_507B88 dd 507BD8h                 ; DATA XREF: sub_47BD70+34r
    dd offset aVerminHaveBeen               ; "vermin have been exterminated"
    dd offset aForcesHaveGone               ; "forces have gone to a better place"
    aForcesHaveGone db 'forces have gone to a better place',0 ; DATA XREF: .data:00507B90o
    align 4
    aVerminHaveBeen db 'vermin have been exterminated',0 ; DATA XREF: .data:00507B8Co
    align 4
    aForcesHaveBeen db 'forces have been obliterated',0
    align 4
    aSidelist db 'SideList',0               ; DATA XREF: sub_476830+1Bo
    align 4
    aCampaignNames db 'CAMPAIGN NAMES',0    ; DATA XREF: .text:00476957o
                                            ; .text:00476A24o
    align 4
    ; char off_507C14
    off_507C14 dd offset sub_4C4C41         ; DATA XREF: sub_476A60+151o
                                            ; sub_488E70+8Bo
    aCampaignside db 'campaignside',0       ; DATA XREF: sub_476A60+F7o
    align 4
    aHeader db 'HEADER',0                   ; DATA XREF: sub_476A60+D2o
    align 4
    aCampaignNames2 db 'CAMPAIGN NAMES2',0  ; DATA XREF: sub_476A60+61o
    aCampaignNames1 db 'CAMPAIGN NAMES1',0  ; DATA XREF: sub_476A60+4Do
    aTempstorage db 'TempStorage',0         ; DATA XREF: sub_476CD0+17o
    aSolarsystem db 'SOLARSYSTEM',0         ; DATA XREF: sub_476D80+26o
                                            ; .text:00478815o ...
    aMore___ db 'MORE...',0                 ; DATA XREF: sub_476EF0+237o
    aBackToStart db 'BACK TO START',0       ; DATA XREF: sub_476EF0+216o
    align 4
    aSide1 db 'Side1',0                     ; DATA XREF: sub_477360+A2o
                                            ; .text:00477D9Ao ...
    align 4
    aSide0 db 'Side0',0                     ; DATA XREF: sub_477360+53o
                                            ; .text:00477D74o ...
    align 4
    aAnymsn db 'AnyMsn',0                   ; DATA XREF: .text:00477543o
                                            ; .text:00477563o ...
    align 4
    aDrdeath db 'DRDEATH',0                 ; DATA XREF: .text:00477516o
    aBigbutton_0 db 'bigButton',0           ; DATA XREF: .text:00477734o
                                            ; .text:00477B6Eo
    align 4
    aPrevmenu_0 db 'PrevMenu',0             ; DATA XREF: .text:004776E1o
                                            ; .text:00477CC7o ...
    align 4
    aOptions_0 db 'options',0               ; DATA XREF: .text:004776C1o
    aSkirmish_1 db 'skirmish',0             ; DATA XREF: .text:00477622o
    align 4
    aSkirmish_0 db 'Skirmish',0             ; DATA XREF: .text:00477601o
                                            ; .text:004778FBo ...
    align 4
    aNewcamp db 'NewCamp',0                 ; DATA XREF: .text:004775AFo
    aSpanish db 'spanish',0                 ; DATA XREF: .text:004778D8o
    aSinglebg db 'singlebg',0               ; DATA XREF: .text:004777D3o
    align 4
    aSingle_gui db 'SINGLE.GUI',0           ; DATA XREF: .text:004777ADo
    align 4
    aSmlbutton db 'smlbutton',0             ; DATA XREF: .text:0047796Ao
                                            ; .text:00477EA0o ...
    align 4
    aSideselect db 'SideSelect',0           ; DATA XREF: .text:0047802Ao
    align 4
    aSideselect2 db 'SideSelect2',0         ; DATA XREF: .text:00477DEFo
    aSmlbutton_3 db 'SmlButton',0           ; DATA XREF: .text:00477D0Bo
    align 4
    aCoreCampaign db 'Core Campaign',0      ; DATA XREF: .text:00477C17o
    align 4
    aArmCampaign db 'Arm Campaign',0        ; DATA XREF: .text:00477C0Ao
    align 4
    aMissionsknob db 'MissionsKnob',0       ; DATA XREF: .text:0047861Fo
    align 4
    aCampaignknob db 'CampaignKnob',0       ; DATA XREF: .text:00478330o
                                            ; .text:00478503o
    align 4
    aNewcampaign4 db 'newcampaign4',0       ; DATA XREF: .text:004782DBo
    align 4
    aNewcampaign4x db 'newcampaign4x',0     ; DATA XREF: .text:004782C5o
    align 4
    aPlayanygame4 db 'playanygame4',0       ; DATA XREF: .text:00478292o
    align 4
    aNewgame_gui db 'NEWGAME.GUI',0         ; DATA XREF: .text:00478265o
    aPanmask db 'Panmask',0                 ; DATA XREF: .text:00478AC8o
    aS_1f db '%s : %.1f',0                  ; DATA XREF: .text:00478914o
    align 4
    aGravity_0 db 'Gravity',0               ; DATA XREF: .text:00478905o
    aSD_0 db '%s : %d',0                    ; DATA XREF: .text:00478894o
    aWindSpeed db 'Wind Speed',0            ; DATA XREF: .text:00478885o
    align 4
    aShutup db 'SHUTUP',0                   ; DATA XREF: sub_478B40+4Co
                                            ; sub_478B40+5Co ...
    align 4
    aMore db 'More',0                       ; DATA XREF: .text:00478E5Fo
    align 4
    aPlanet_0 db 'PLANET',0                 ; DATA XREF: .text:00479402o
    align 4
    aPanorama db 'PANORAMA',0               ; DATA XREF: .text:004793AEo
    align 4
    aCrystalrotate db 'CrystalRotate',0     ; DATA XREF: .text:00479332o
    align 4
    aAcidrotate db 'AcidRotate',0           ; DATA XREF: .text:00479327o
    align 4
    aWaterrotate db 'WaterRotate',0         ; DATA XREF: .text:0047931Co
    aSlaterotate db 'SlateRotate',0         ; DATA XREF: .text:00479311o
    aLushrotate db 'LushRotate',0           ; DATA XREF: .text:00479306o
    align 4
    aIcerotate db 'IceRotate',0             ; DATA XREF: .text:004792FBo
    align 4
    aLunar2rotate db 'Lunar2Rotate',0       ; DATA XREF: .text:004792F0o
    align 4
    aMetalrotate db 'MetalRotate',0         ; DATA XREF: .text:004792E5o
    aLunarrotate db 'LunarRotate',0         ; DATA XREF: .text:004792DAo
    aMarsrotate db 'MarsRotate',0           ; DATA XREF: .text:004792CFo
    align 4
    aLavarotate db 'LavaRotate',0           ; DATA XREF: .text:004792C4o
    align 4
    aDdesrotate db 'DDesRotate',0           ; DATA XREF: .text:004792B9o
    align 4
    aWdesertrotate db 'WDesertRotate',0     ; DATA XREF: .text:004792AEo
    align 4
    aArchirotate db 'ArchiRotate',0         ; DATA XREF: .text:004792A3o
    aGreenrotate db 'GreenRotate',0         ; DATA XREF: .text:00479298o
    aCrystpan db 'CrystPan',0               ; DATA XREF: .text:00479286o
    align 4
    aAcidpan db 'AcidPan',0                 ; DATA XREF: .text:0047927Bo
    aWaterpan db 'WaterPan',0               ; DATA XREF: .text:00479270o
    align 4
    aSlatepan db 'SlatePan',0               ; DATA XREF: .text:00479265o
    align 4
    aLushpan db 'LushPan',0                 ; DATA XREF: .text:0047925Ao
    aIcepan db 'IcePan',0                   ; DATA XREF: .text:0047924Fo
    align 4
    aLunar2pan db 'Lunar2Pan',0             ; DATA XREF: .text:00479244o
    align 4
    aMetalpan db 'MetalPan',0               ; DATA XREF: .text:00479239o
    align 4
    aLunarpan db 'LunarPan',0               ; DATA XREF: .text:0047922Eo
    align 4
    aMarspan db 'MarsPan',0                 ; DATA XREF: .text:00479223o
    aLavapan db 'LavaPan',0                 ; DATA XREF: .text:00479218o
    aDdespan db 'DDesPan',0                 ; DATA XREF: .text:0047920Do
    aWdespan db 'WDesPan',0                 ; DATA XREF: .text:00479202o
    aArchipan db 'ArchiPan',0               ; DATA XREF: .text:004791F7o
    align 4
    aGreenpan db 'GreenPan',0               ; DATA XREF: .text:004791ECo
    align 4
    aCrystalbrief db 'Crystalbrief',0       ; DATA XREF: .text:004791E0o
    align 4
    aAcidbrief db 'Acidbrief',0             ; DATA XREF: .text:004791D8o
    align 4
    aWaterbrief db 'Waterbrief',0           ; DATA XREF: .text:004791D0o
    align 4
    aSlatebrief db 'Slatebrief',0           ; DATA XREF: .text:004791C8o
    align 4
    aLushbrief db 'Lushbrief',0             ; DATA XREF: .text:004791C0o
    align 4
    aIcebrief db 'Icebrief',0               ; DATA XREF: .text:004791B8o
    align 4
    aLunar2brief db 'Lunar2brief',0         ; DATA XREF: .text:004791B0o
    aMetalbrief db 'Metalbrief',0           ; DATA XREF: .text:004791A8o
    align 4
    aLunarbrief db 'Lunarbrief',0           ; DATA XREF: .text:004791A0o
    align 4
    aMarsbrief db 'Marsbrief',0             ; DATA XREF: .text:00479198o
    align 4
    aLavabrief db 'Lavabrief',0             ; DATA XREF: .text:00479190o
    align 4
    aDesertbrief db 'Desertbrief',0         ; DATA XREF: .text:00479188o
    aWdesertbrief db 'WDesertbrief',0       ; DATA XREF: .text:00479180o
    align 4
    aArchibrief db 'Archibrief',0           ; DATA XREF: .text:00479178o
    align 4
    aCrystal db 'Crystal',0                 ; DATA XREF: .text:0047915Eo
    aAcid db 'Acid',0                       ; DATA XREF: .text:00479153o
    align 4
    aWaterWorld db 'Water World',0          ; DATA XREF: .text:00479148o
    aSlate db 'Slate',0                     ; DATA XREF: .text:00479140o
    align 4
    aLush db 'Lush',0                       ; DATA XREF: .text:00479138o
    align 4
    aIce db 'Ice',0                         ; DATA XREF: .text:00479130o
    aLunar2 db 'Lunar2',0                   ; DATA XREF: .text:00479128o
    align 4
    aRedPlanet db 'Red Planet',0            ; DATA XREF: .text:00479110o
    align 4
    aLava db 'Lava',0                       ; DATA XREF: .text:00479108o
    align 4
    aDesert db 'Desert',0                   ; DATA XREF: .text:00479100o
    align 4
    aWetDesert db 'Wet Desert',0            ; DATA XREF: .text:004790F8o
    align 4
    aArchipelago db 'Archipelago',0         ; DATA XREF: .text:004790F0o
    aGreenPlanet db 'Green planet',0        ; DATA XREF: .text:004790E6o
    align 4
    aGreenbrief db 'Greenbrief',0           ; DATA XREF: .text:004790DDo
                                            ; .text:00479170o
    align 4
    a2:                                     ; DATA XREF: .text:004790B3o
    unicode 0, <2>,0
    aLunar db 'Lunar',0                     ; DATA XREF: .text:00479072o
                                            ; .text:00479118o
    align 4
    aMsnbrief_gui db 'MSNBRIEF.GUI',0       ; DATA XREF: .text:00478EF0o
    align 4
    aMbriefS db 'mbrief%s',0                ; DATA XREF: .text:00478ED1o
    align 4
    aColorD db 'Color%d',0                  ; DATA XREF: sub_4797E0+1F5o
                                            ; sub_4797E0+29Ao ...
    aEnergyD db 'Energy%d',0                ; DATA XREF: sub_4797E0+1CCo
                                            ; sub_4797E0+3ABo ...
    align 4
    aMetalD db 'Metal%d',0                  ; DATA XREF: sub_4797E0+1A3o
                                            ; sub_4797E0+382o ...
    aSideD_0 db 'Side%d',0                  ; DATA XREF: sub_4797E0+151o
                                            ; sub_4797E0+330o ...
    align 4
    aComputer_0 db 'Computer',0             ; DATA XREF: sub_4797E0+E4o
                                            ; sub_47A0E0+FFo
    align 4
    aPlayerD_0 db 'Player%d',0              ; DATA XREF: sub_4797E0+1Co
                                            ; sub_4797E0+128o ...
    align 4
    aLeftClickToI_0 db 'Left click to increase energy. Right click to decrease energ'
                                            ; DATA XREF: sub_479C50+412o
    db 'y.',0
    align 4
    aLeftClickToInc db 'Left click to increase metal. Right click to decrease metal.'
                                            ; DATA XREF: sub_479C50+353o
    db 0
    align 4
    aSkirmmet db 'skirmmet',0               ; DATA XREF: sub_479C50+317o
                                            ; sub_479C50+3D6o
    align 4
    aClickToSelectA db 'Click to select an allegiance symbol.',0 ; DATA XREF: sub_479C50+266o
    align 4
    aSkirmname db 'skirmname',0             ; DATA XREF: sub_479C50+F6o
    align 4
    aMapname_0 db 'MapName',0               ; DATA XREF: sub_47A0E0+5F1o
                                            ; sub_47A910+16Fo
    aTerrainEleva_0 db 'Terrain elevations do not affect a unit',27h,'s view.',0
                                            ; DATA XREF: sub_47A0E0+5ACo
                                            ; sub_47AE60+A03o
    aTerrainElevati db 'Terrain elevations affect a unit',27h,'s view.',0
                                            ; DATA XREF: sub_47A0E0+59Eo
                                            ; sub_47AE60+9DEo
    align 4
    aAllMappedTerra db 'All mapped terrain is visible.',0 ; DATA XREF: sub_47A0E0+587o
                                            ; sub_47AE60+A1Ao
    align 4
    aTerrainIsVisib db 'Terrain is visible.',0 ; DATA XREF: sub_47A0E0+51Co
                                            ; sub_47AE60+96Do
    aTerrainIsBlack db 'Terrain is blacked out until explored.',0 ; DATA XREF: sub_47A0E0+50Eo
                                            ; sub_47AE60+963o
    align 4
    aGameContinuesA db 'Game continues after Commander is destroyed.',0
                                            ; DATA XREF: sub_47A0E0+4A2o
                                            ; sub_47AE60+871o
    align 4
    aGameEndsWhenCo db 'Game ends when commander is destroyed.',0 ; DATA XREF: sub_47A0E0+494o
                                            ; sub_47AE60+867o
    align 4
    aCommandersAreR db 'Commanders are randomly placed on the battle field.',0
                                            ; DATA XREF: sub_47A0E0+428o
                                            ; sub_47AE60+8EFo
    aCommandersAreP db 'Commanders are placed at pre-determined locations.',0
                                            ; DATA XREF: sub_47A0E0+41Ao
                                            ; sub_47AE60+8E5o
    align 4
    aStartlocation db 'StartLocation',0     ; DATA XREF: sub_47A0E0+3DEo
                                            ; sub_47AE60+87Bo ...
    align 4
    aThereAreNoSkir db 'There are no skirmish maps to choose from',0 ; DATA XREF: sub_47AAF0+1Bo
    align 4
    aSelectmap db 'SelectMap',0             ; DATA XREF: sub_47AE60+A7Bo
    align 4
    aColor_0 db 'Color',0                   ; DATA XREF: sub_47AE60+42Fo
    align 4
    aAllies db 'Allies',0                   ; DATA XREF: sub_47AE60+3AFo
                                            ; sub_493BF0+38Eo
    align 4
    aThereMustBeAtL db 'There must be at least one player and one computer opponent',0
                                            ; DATA XREF: sub_47AE60+266o
    aAllPlayersMayN db 'All players may not be in the same allied group.',0
                                            ; DATA XREF: sub_47AE60+1E5o
    align 4
    aThereAreTooMan db 'There are too many players enabled for this map',0
                                            ; DATA XREF: sub_47AE60+1A3o
    aTheTerrainForT db 'The terrain for the selected map does not exist.',0
                                            ; DATA XREF: sub_47AE60+127o
    align 4
    aSkirmishcheat db 'SkirmishCheat',0     ; DATA XREF: sub_47B9F0+18Do
    align 4
    ; char asc_508470
    asc_508470 db '*X',0                    ; DATA XREF: sub_47B9F0+106o
    align 4
    aIx db '*IX',0                          ; DATA XREF: sub_47B9F0+E5o
    aIii db '*III',0                        ; DATA XREF: sub_47B9F0+C4o
    align 4
    aViii db '*VIII',0                      ; DATA XREF: sub_47B9F0+A3o
    align 4
    aVii db '*VII',0                        ; DATA XREF: sub_47B9F0+7Fo
    align 4
    ; char off_508490
    off_508490 dd offset sub_49562A         ; DATA XREF: sub_47B9F0+5Bo
    ; char byte_508494
    byte_508494 db '*'                      ; DATA XREF: sub_47B9F0+37o
    db 56h, 2 dup(0)
    ; char byte_508498
    byte_508498 db '*'                      ; DATA XREF: sub_47B9F0+9o
    db 49h, 56h, 0
    aSkirmsetup4x db 'Skirmsetup4x',0       ; DATA XREF: .text:0047BBE0o
    align 4
    aSkirmish_gui db 'SKIRMISH.GUI',0       ; DATA XREF: .text:0047BBC2o
    align 4
    aCouldNotSetupD db 'Could not setup Direct Draw to play movie.',0
                                            ; DATA XREF: sub_47BDF0+E9o
    align 4
    aCouldNotOpenMo db 'Could not open movie file, please check filename in INI.',0
                                            ; DATA XREF: sub_47BDF0+4Eo
    align 4
    aUnsupportedPix db 'Unsupported pixel format.',0 ; DATA XREF: sub_47C150+C1o
    align 4
    aSmackerError db 'Smacker Error',0      ; DATA XREF: sub_47C150+BCo
    align 4
    aStats_txt db 'stats.txt',0             ; DATA XREF: .text:0047C4E7o
                                            ; .text:0047C547o
    align 4
    aR_0:                                   ; DATA XREF: .text:0047C4E2o
    unicode 0, <r>,0
    aHighestextraus db 'HighestExtraUsed',9,'%d',0Ah,0 ; DATA XREF: .text:0047C6A2o
    align 4
    aTotalextramemo db 'TotalExtraMemory',9,'%d',0Ah,0 ; DATA XREF: .text:0047C68Fo
    align 4
    aHighestmemamou db 'HighestMemAmount',9,'%d',0Ah,0 ; DATA XREF: .text:0047C67Co
    align 4
    aHighest1secrat db 'Highest1SecRate',9,'%d',0Ah,0 ; DATA XREF: .text:0047C669o
    aAverageframesi db 'AverageFrameSize',9,'%d',0Ah,0 ; DATA XREF: .text:0047C656o
    align 4
    aSlowest2framet db 'Slowest2FrameTime',9,'%d',0Ah,0 ; DATA XREF: .text:0047C643o
    align 4
    aSlowestframeti db 'SlowestFrameTime',9,'%d',0Ah,0 ; DATA XREF: .text:0047C630o
    align 4
    aTotalreadspeed db 'TotalReadSpeed',9,'%d bytes/sec',0Ah,0 ; DATA XREF: .text:0047C61Do
    align 4
    aTotaldecomptim db 'TotalDecompTime',9,'%d',0Ah,0 ; DATA XREF: .text:0047C60Ao
    aTotalreadtimeD db 'TotalReadTime',9,'%d',0Ah,0 ; DATA XREF: .text:0047C5F7o
    align 4
    aTotalblittimeD db 'TotalBlitTime',9,'%d',0Ah,0 ; DATA XREF: .text:0047C5E4o
    align 4
    aSkippedframesD db 'SkippedFrames',9,'%d',0Ah,0 ; DATA XREF: .text:0047C5D1o
    align 4
    aTotalFramesPla db 'Total Frames Played',9,'%d',0Ah,0 ; DATA XREF: .text:0047C5BEo
    aTimeToOpenFile db 'Time to Open File',9,'%d',0Ah,0 ; DATA XREF: .text:0047C5ABo
    align 4
    aTotalPlaybackT db 'Total Playback Time',9,'%d',0Ah,0 ; DATA XREF: .text:0047C598o
    aFramesPerSecD db 'Frames Per Sec',9,'%d',0Ah,0 ; DATA XREF: .text:0047C575o
    align 4
    aW:                                     ; DATA XREF: .text:0047C542o
                                            ; sub_4B4D70+Co
    unicode 0, <w>,0
    dd 2 dup(0)
    dword_5086DC dd 0                       ; DATA XREF: sub_47FAD0+D4r
                                            ; sub_47FAD0+E1r ...
    dword_5086E0 dd 0                       ; DATA XREF: sub_47FD70+17Er
    dd 0
    ; int dword_5086E8
    dword_5086E8 dd 0                       ; DATA XREF: sub_47F780+3Dr
                                            ; sub_47F7E0+46r ...
    dword_5086EC dd 0                       ; DATA XREF: sub_47EE30+91o
                                            ; sub_47FAD0+20r ...
    dd 1, 0Ah, 0
    off_5086FC dd offset aSelect_0          ; DATA XREF: sub_42F580+103o
                                            ; "select"
    dd 2 dup(0), 2, 9, 14h, 508A64h, 508A54h, 0, 3, 4, 2, 508A48h, 2 dup(0)
    dd 2 dup(4), 2, 508A3Ch, 2 dup(0), 2 dup(5), 1, 508A38h, 2 dup(0), 6, 3
    dd 4, 508A30h, 508A28h, 0, 7, 8, 1, 508A20h, 508A10h, 0, 8, 2 dup(3), 508A00h
    dd 5089ECh, 0, 9, 4, 2, 5089E4h, 2 dup(0), 0Ah, 3, 1, 5089DCh, 2 dup(0)
    dd 0Bh, 2, 1, 5089D4h, 2 dup(0), 0Ch, 7, 1, 5089CCh, 2 dup(0), 0Dh, 7
    dd 1, 5089C4h, 2 dup(0), 0Eh, 7, 1, 5089BCh, 5089B4h, 0, 0Fh, 7, 1, 5089ACh
    dd 5089A4h, 0, 10h, 4, 1, 50899Ch, 2 dup(0), 11h, 0Ah, 0, 508994h, 50898Ch
    dd 0, 12h, 0Ah, 0, 508984h, 50897Ch, 0, 13h, 0Ah, 0, 508974h, 50896Ch
    dd 0, 14h, 0Ah, 0, 508964h, 508960h, 0, 15h, 0Ah, 0, 508958h, 508954h
    dd 0, 16h, 0Ah, 0, 50894Ch, 508944h, 0, 17h, 0Ah, 0, 508934h, 508918h
    dd 0, 666C6553h, 73656420h, 63757274h
    dword_508924 dd 65742074h, 6E696D72h    ; DATA XREF: sub_42F580+179o
    aAted db 'ated',0                       ; DATA XREF: sub_47EE30+9Fo
    align 4
    aCanceldestruct db 'canceldestruct',0
    align 4
    aZero db 'zero',0
    align 4
    aCount0 db 'count0',0
    align 4
    aOne db 'one',0
    aCount1 db 'count1',0
    align 4
    aTwo db 'two',0
    aCount2 db 'count2',0
    align 4
    aThree db 'three',0
    align 4
    aCount3 db 'count3',0
    align 4
    aFour db 'four',0
    align 4
    aCount4 db 'count4',0
    align 4
    aFive db 'five',0
    align 4
    aCount5 db 'count5',0
    align 4
    aCapture_1 db 'capture',0
    aVisible db 'Visible',0
    aUncloak db 'uncloak',0
    aCloaked db 'Cloaked',0
    aCloak_0 db 'cloak',0
    align 4
    aUnload_0 db 'unload',0
    align 4
    aLoad_1 db 'load',0
    align 4
    aWorking db 'working',0
    aRepair_0 db 'repair',0
    align 4
    aBuild_0 db 'build',0
    align 4
    aNanolatheCompl db 'Nanolathe Complete',0
    align 4
    aUnitcomplete db 'unitcomplete',0
    align 4
    aCannotComply db 'Cannot Comply',0
    align 4
    aCant db 'cant',0
    align 4
    aArrived db 'Arrived',0
    aArrived_0 db 'arrived',0
    aOk db 'ok',0
    align 4
    aDeactivate_1 db 'deactivate',0
    align 4
    aActivate_1 db 'activate',0
    align 4
    aUnderAttack db 'Under Attack',0
    align 4
    aUnderattack db 'underattack',0
    aSelect_0 db 'select',0                 ; DATA XREF: .data:005086FCo
    align 4
    aErrorSoundSyst db 'Error:  Sound system initialization failed.',0
                                            ; DATA XREF: sub_47ED40+92o
    aUsewindowssoun db 'UseWindowsSound',0  ; DATA XREF: sub_47ED40+1Fo
    aNodirectsound db 'NoDirectSound',0     ; DATA XREF: sub_47ED40+5o
    align 4
    aSounds db 'sounds',0                   ; DATA XREF: sub_47EFE0+34o
                                            ; sub_47FD70+FAo
    align 4
    aSpeechText db 'Speech Text',0          ; DATA XREF: sub_47FAD0+17Co
    aSS_1 db '%s: %s',0                     ; DATA XREF: sub_47FD70+1F9o
                                            ; sub_497F40+784o
    align 4
    aHonk db 'honk',0                       ; DATA XREF: sub_47FD70+D8o
    align 4
    aSing db 'sing',0                       ; DATA XREF: sub_47FD70+D1o
    align 4
    aSquads db 'SQUADS',0                   ; DATA XREF: sub_480190+Co
    align 4
    aEyeballMemory db 'EYEBALL MEMORY',0    ; DATA XREF: .text:0048150Ao
                                            ; sub_483610+77Do
    align 4
    aSortLineCount db 'SORT LINE COUNT',0   ; DATA XREF: sub_483610+75Ao
    aSortIndices db 'SORT INDICES',0        ; DATA XREF: sub_483610+747o
    align 4
    aSortUnitList db 'SORT UNIT LIST',0     ; DATA XREF: sub_483610+72Do
    align 4
    aMappedMemory db 'MAPPED MEMORY',0      ; DATA XREF: sub_483610+6F3o
    align 4
    aTileSet db 'TILE SET',0                ; DATA XREF: sub_483610+54Eo
    align 4
    aPlotMemory db 'PLOT MEMORY',0          ; DATA XREF: sub_483610+388o
    aTileMap db 'TILE MAP',0                ; DATA XREF: sub_483610+34Do
    align 4
    aTedGeneratedPi db 'TED GENERATED PIC',0 ; DATA XREF: sub_483610+2E0o
    align 4
    aUnknownTntVers db 'Unknown TNT version:  0x%08x',0 ; DATA XREF: sub_483610+47o
    align 4
    aPlotmap db 'Plotmap',0                 ; DATA XREF: sub_484CE0+51o
                                            ; sub_484D60+18o ...
    aPlayerfeatures db 'PlayerFeatures',0   ; DATA XREF: sub_484DF0+8o
                                            ; sub_484E80+8o
    align 4
    aHotRadarUnits db 'HOT RADAR UNITS',0   ; DATA XREF: sub_4854A0+F1o
    aHotUnits db 'HOT UNITS',0              ; DATA XREF: sub_4854A0+D8o
    align 4
    aUnitMemory db 'UNIT MEMORY',0          ; DATA XREF: sub_4854A0+70o
    aCreate db 'Create',0                   ; DATA XREF: sub_485D40+A1o
    align 4
    aKilled db 'Killed',0                   ; DATA XREF: sub_4864B0+10Eo
                                            ; sub_4866D0+1A2o
    align 4
    aSHasTakenTheLe db '%s has taken the lead with %d kills',0 ; DATA XREF: sub_4866D0+576o
    aNumberOfUnits db 'Number of Units',0   ; DATA XREF: sub_486FD0+36o
                                            ; sub_487080+5Co ...
    aScriptI db 'Script%i',0                ; DATA XREF: sub_487080+55Co
                                            ; sub_4876C0+59o
    align 4
    aU04xm04x db 'u%04xm%04x',0             ; DATA XREF: sub_487080+4ECo
                                            ; sub_4876C0+9Do ...
    align 4
    aSelfdestructfg db 'SELFDESTRUCTFG',0   ; DATA XREF: sub_487BF0+5FEo
    align 4
    aWaitforattack db 'WAITFORATTACK',0     ; DATA XREF: sub_487BF0+5D7o
    align 4
    aAZaZ09_ db ' %[a-zA-Z0-9.]',0          ; DATA XREF: sub_487BF0+59Do
    align 4
    aWait db 'WAIT',0                       ; DATA XREF: sub_487BF0+57Bo
    align 4
    aFD db ' %f %d',0                       ; DATA XREF: sub_487BF0+544o
    align 4
    aD_2 db ' %d',0                         ; DATA XREF: sub_487BF0+4FAo
    aAZaZ09__DFF db ' %[a-zA-Z0-9_.] %d %f %f',0 ; DATA XREF: sub_487BF0+449o
    align 4
    aAttackutype db 'ATTACKUTYPE',0         ; DATA XREF: sub_487BF0+3FCo
    aFFF db ' %f %f %f',0                   ; DATA XREF: sub_487BF0+2BFo
    align 4
    aMakeselectable db 'MAKESELECTABLE',0   ; DATA XREF: sub_487BF0+290o
                                            ; sub_487BF0+624o
    align 4
    aAZaZ09__ db ' %[a-zA-Z0-9_.]',0        ; DATA XREF: sub_487BF0+20Do
                                            ; sub_487BF0+3CCo ...
    aFF db ' %f %f',0                       ; DATA XREF: sub_487BF0+125o
                                            ; sub_487BF0+19Do ...
    align 4
    aDD db ' %d %d',0                       ; DATA XREF: sub_487BF0+DBo
    align 4
    ; char asc_508CE4
    asc_508CE4:                             ; DATA XREF: sub_487BF0+4Do
    unicode 0, <,>,0
    aPlayerNumberDI db 'Player number %d invalid for unit %s',0 ; DATA XREF: sub_488310+107o
    align 4
    aSN db ' %s %n',0                       ; DATA XREF: sub_488E70+1Bo
                                            ; sub_488E70+70o
    align 4
    off_508D18 dd offset loc_412F4C+2       ; DATA XREF: sub_489280+1F5o
                                            ; sub_489280+21Ao ...
    a_0fS db '%.0f %s',0                    ; DATA XREF: sub_489280+1DDo
    aDegS db 'deg/s',0                      ; DATA XREF: sub_489280+1A2o
    align 4
    a_2fS db '%.2f %s',0                    ; DATA XREF: sub_489280+188o
    aMSS db 'm/s/s',0                       ; DATA XREF: sub_489280+15Co
    align 4
    a_1fS db '%.1f %s ',0                   ; DATA XREF: sub_489280+132o
    align 4
    aMS db 'm/s',0                          ; DATA XREF: sub_489280+100o
    aProplist db 'PropList',0               ; DATA XREF: sub_489280+Ao
    align 4
    aTargetcleared db 'TargetCleared',0     ; DATA XREF: sub_489800+93o
                                            ; sub_4898B0+93o ...
    align 4
    aTakedamage db 'TakeDamage',0           ; DATA XREF: sub_489CE0+2A9o
    align 4
    aHitbyweapon db 'HitByWeapon',0         ; DATA XREF: sub_489CE0+25Eo
    aParalyze db 'paralyze',0               ; DATA XREF: sub_489CE0+169o
                                            ; .text:00489FEBo
    align 4
    aSelectmultiple db 'SelectMultipleUnits',0 ; DATA XREF: sub_48C390+2ECo
    aCtrl_f db 'CTRL_F',0                   ; DATA XREF: sub_48D9A0+7o
                                            ; sub_48D9A0+25o ...
    align 4
    aAnyunitpassesz db 'AnyUnitPassesZ',0   ; DATA XREF: sub_48E010+90Eo
    align 4
    aAnyunitpassesx db 'AnyUnitPassesX',0   ; DATA XREF: sub_48E010+8B0o
    align 4
    aDeathtimerruns db 'DeathTimerRunsOut',0 ; DATA XREF: sub_48E010+85Bo
    align 4
    aUnittypekilled db 'UnitTypeKilled',0   ; DATA XREF: sub_48E010+7ABo
    align 4
    aAllunitskill_0 db 'AllUnitsKilledOfType',0 ; DATA XREF: sub_48E010+715o
    align 4
    aAllunitskilled db 'AllUnitsKilled',0   ; DATA XREF: sub_48E010+6B3o
    align 4
    aCommanderkille db 'CommanderKilled',0  ; DATA XREF: sub_48E010+66Co
    aVictorytimerru db 'VictoryTimerRunsOut',0 ; DATA XREF: sub_48E010+621o
    aUnittypepass_0 db 'UnitTypePassesZ',0  ; DATA XREF: sub_48E010+545o
    aUnittypepasses db 'UnitTypePassesX',0  ; DATA XREF: sub_48E010+45Co
    aAnytype db 'ANYTYPE',0                 ; DATA XREF: sub_48E010+3AFo
                                            ; sub_48E010+4AFo ...
    aAZaZIII db '%[a-zA-Z],%i,%i,%i',0      ; DATA XREF: sub_48E010+374o
    align 4
    aMoveunittoradi db 'MoveUnitToRadius',0 ; DATA XREF: sub_48E010+343o
    align 4
    aAZaZI db '%[a-zA-Z],%i',0              ; DATA XREF: sub_48E010+2B6o
                                            ; sub_48E010+480o ...
    align 4
    aKillunittype db 'KillUnitType',0       ; DATA XREF: sub_48E010+292o
    align 4
    aKillalloftype db 'KillAllOfType',0     ; DATA XREF: sub_48E010+205o
    align 4
    aCaptureunittyp db 'CaptureUnitType',0  ; DATA XREF: sub_48E010+186o
    aBuildunittype db 'BuildUnitType',0     ; DATA XREF: sub_48E010+F5o
    align 4
    aKillallmobileu db 'KillAllMobileUnits',0 ; DATA XREF: sub_48E010+99o
    align 4
    aDestroyallunit db 'DestroyAllUnits',0  ; DATA XREF: sub_48E010+5Bo
    aKillenemycomma db 'KillEnemyCommander',0 ; DATA XREF: sub_48E010+19o
    align 4
    aVictoryConditi db 'Victory Condition',0 ; DATA XREF: sub_48EA40+61o
                                            ; sub_48EB40+1Bo ...
    align 4
    aCelebrated db 'Celebrated',0           ; DATA XREF: sub_48EAC0+28o
                                            ; sub_48EB00+24o ...
    align 4
    aSatisfied db 'Satisfied',0             ; DATA XREF: sub_48EAC0+1Ao
                                            ; sub_48EB00+16o ...
    align 4
    aVictoryconditi db 'VictoryCondition_KillEnemyCommander',0 ; DATA XREF: sub_48EAC0+8o
                                            ; sub_48EB00+8o
    aVictorycondi_0 db 'VictoryCondition_DestroyAllUnits',0 ; DATA XREF: sub_48EB80+8o
                                            ; sub_48EBC0+8o
    align 4
    aNumunits db 'NumUnits',0               ; DATA XREF: sub_48ECB0+1Ao
                                            ; sub_48ED00+16o
    align 4
    aVictorycondi_1 db 'VictoryCondition_KillAllMobileUnits',0 ; DATA XREF: sub_48ECB0+8o
                                            ; sub_48ED00+8o
    aVictorycondi_2 db 'VictoryCondition_BuildUnitType',0 ; DATA XREF: sub_48EE30+8o
                                            ; sub_48EE70+8o
    align 4
    aVictorycondi_3 db 'VictoryCondition_CaptureUnitType',0 ; DATA XREF: sub_48EF00+8o
                                            ; sub_48EF40+8o
    align 4
    aVictorycondi_4 db 'VictoryCondition_KillAllOfType',0 ; DATA XREF: sub_48F070+8o
                                            ; sub_48F0B0+8o
    align 4
    aNumlefttokill db 'NumLeftToKill',0     ; DATA XREF: sub_48F160+1Ao
                                            ; sub_48F1B0+16o ...
    align 4
    aVictorycondi_5 db 'VictoryCondition_KillUnitType',0 ; DATA XREF: sub_48F160+8o
                                            ; sub_48F1B0+8o
    align 4
    aVictorycondi_6 db 'VictoryCondition_MoveUnitToRadius',0 ; DATA XREF: sub_48F2F0+8o
                                            ; sub_48F330+8o
    align 4
    aVictorycondi_7 db 'VictoryCondition_UnitTypePassesX',0 ; DATA XREF: sub_48F440+8o
                                            ; sub_48F480+8o
    align 4
    aVictorycondi_8 db 'VictoryCondition_UnitTypePassesZ',0 ; DATA XREF: sub_48F590+8o
                                            ; sub_48F5D0+8o
    align 4
    aVictorycondi_9 db 'VictoryCondition_VictoryTimerRunsOut',0 ; DATA XREF: sub_48F630+8o
                                            ; sub_48F670+8o
    align 4
    aDefeatconditio db 'DefeatCondition_CommanderKilled',0 ; DATA XREF: sub_48F710+8o
                                            ; sub_48F750+8o
    aDefeatcondit_0 db 'DefeatCondition_AllUnitsKilled',0 ; DATA XREF: sub_48F840+8o
                                            ; sub_48F880+8o
    align 4
    aDefeatcondit_1 db 'DefeatCondition_UnitTypeKilled',0 ; DATA XREF: sub_48F900+8o
                                            ; sub_48F950+8o
    align 4
    aDefeatcondit_2 db 'DefeatCondition_AllUnitsKilledOfType',0 ; DATA XREF: sub_48FAB0+8o
                                            ; sub_48FAF0+8o
    align 4
    aDefeatcondit_3 db 'DefeatCondition_AnyUnitPassesX',0 ; DATA XREF: sub_48FBC0+8o
                                            ; sub_48FC00+8o
    align 4
    aDefeatcondit_4 db 'DefeatCondition_AnyUnitPassesZ',0 ; DATA XREF: sub_48FCD0+8o
                                            ; sub_48FD10+8o
    align 4
    aDefeatcondit_5 db 'DefeatCondition_DeathTimerRunsOut',0 ; DATA XREF: sub_48FD70+8o
                                            ; sub_48FDB0+8o
    align 4
    dword_5091C8 dd 506D8Ch                 ; DATA XREF: .text:0044B45Dr
                                            ; sub_44B4E0r ...
    dword_5091CC dd 1                       ; DATA XREF: sub_493BF0+235r
                                            ; sub_497180+84w ...
    dword_5091D0 dd 0FFFFFFFFh              ; DATA XREF: sub_494E70+ADr
                                            ; sub_494E70+12Bw
    aOffscreen db 'OFFSCREEN',0             ; DATA XREF: .text:00490AD3o
                                            ; sub_491200+50o ...
    align 4
    aSCD db '%s  %c%d',0Ah,0                ; DATA XREF: sub_490DF0+87o
    align 4
    aGameSpeedNorma db 'Game Speed Normal',0 ; DATA XREF: sub_490DF0+38o
    align 4
    aCdlists db 'CDLISTS',0                 ; DATA XREF: .text:00490F53o
                                            ; sub_490F80+4Co ...
    aOpenCdaudio db 'open cdaudio',0        ; DATA XREF: sub_490FE0+8Do
                                            ; sub_4CE260+55o ...
    align 4
    aCloseCdaudio db 'close cdaudio',0      ; DATA XREF: sub_490FE0+80o
                                            ; sub_4CE260+120o ...
    align 4
    aStopCdaudio db 'stop cdaudio',0        ; DATA XREF: sub_490FE0+71o
                                            ; sub_4CDB40+2Bo ...
    align 4
    aUnitlimit db 'UnitLimit',0             ; DATA XREF: sub_491200+444o
    align 4
    aHattfont11 db 'hattfont11',0           ; DATA XREF: sub_491200+371o
    align 4
    aHattfont12 db 'hattfont12',0           ; DATA XREF: sub_491200+35Eo
    align 4
    aCommongui db 'commongui',0             ; DATA XREF: sub_491200+342o
    align 4
    aSkirmishinfo db 'SkirmishInfo',0       ; DATA XREF: sub_491200+1DDo
    align 4
    aAssemPts db 'ASSEM PTS',0              ; DATA XREF: sub_4917D0+173o
    align 4
    aTempProjectedP db 'TEMP PROJECTED PTS',0 ; DATA XREF: sub_4917D0+155o
    align 4
    aTempXformPts db 'TEMP XFORM PTS',0     ; DATA XREF: sub_4917D0+13Do
    align 4
    aDiff db 'DIFF',0                       ; DATA XREF: sub_491EC0+3BCo
                                            ; sub_491EC0+3F4o
    align 4
    aSide_1 db 'SIDE',0                     ; DATA XREF: sub_491EC0+36Do
                                            ; sub_491EC0+3E2o
    align 4
    aTime db 'TIME',0                       ; DATA XREF: sub_491EC0+30Ao
                                            ; sub_491EC0+43Co
    align 4
    aCamptext db 'CAMPTEXT',0               ; DATA XREF: sub_491EC0+206o
                                            ; sub_491EC0+232o
    align 4
    aCampaign_0 db 'CAMPAIGN',0             ; DATA XREF: sub_491EC0+1F9o
                                            ; sub_491EC0+213o ...
    align 4
    aGametype_0 db 'GAMETYPE',0             ; DATA XREF: sub_491EC0+1ABo
                                            ; sub_491EC0+42Ao
    align 4
    a??? db '???',0                         ; DATA XREF: sub_491EC0+182o
                                            ; sub_491EC0+344o
    aSkirmishDPlaye db 'Skirmish (%d players)',0 ; DATA XREF: sub_491EC0+16Eo
    align 4
    aSingle db 'Single',0                   ; DATA XREF: sub_491EC0+162o
    align 4
    aRadar_1 db 'RADAR',0                   ; DATA XREF: sub_491EC0+D8o
                                            ; sub_491EC0+128o
    align 4
    aInvalidSavegam db 'Invalid savegame file',0 ; DATA XREF: .text:0049233Ao
                                            ; sub_492360+782o
    align 4
    aCCavedogWarg_1 db 'c:\cavedog\wargame\wargame.cpp',0 ; DATA XREF: sub_492360+72Ao
    align 4
    aSummary db 'summary',0                 ; DATA XREF: sub_492360+30Fo
                                            ; sub_492360+4F5o ...
    aSavegame2 db 'SAVEGAME2',0             ; DATA XREF: sub_492B10+EAo
    align 4
    aSav db 'SAV',0                         ; DATA XREF: sub_492B10+10o
                                            ; sub_492DF0+224o
    aDsavegame2 db 'DSAVEGAME2',0           ; DATA XREF: sub_493060+3Eo
    align 4
    aLoadgame_gui db 'LOADGAME.GUI',0       ; DATA XREF: sub_493060+1Eo
                                            ; sub_4931D0+11o
    align 4
    aThereAreNoSave db 'There are no saved games to choose from',0 ; DATA XREF: sub_4931D0+65o
    aDloadgame2 db 'DLOADGAME2',0           ; DATA XREF: sub_4931D0+31o
    align 4
    aMetal_2 db 'METAL#',0                  ; DATA XREF: sub_493340+3Do
                                            ; sub_4936F0+348o
    align 4
    aEnergy_2 db 'ENERGY#',0                ; DATA XREF: sub_493390+3Do
                                            ; sub_4936F0+397o
    aSharunit db 'SHARUNIT',0               ; DATA XREF: sub_4934B0+54o
                                            ; sub_4934B0+1B3o
    align 4
    aMapinfo db 'MAPINFO',0                 ; DATA XREF: sub_4934B0+45o
                                            ; sub_4934B0+1C8o
    aPlyrlist db 'PLYRLIST',0               ; DATA XREF: sub_4934B0+17o
                                            ; sub_4934B0+A0o ...
    align 4
    aShare_gui db 'SHARE.GUI',0             ; DATA XREF: sub_4936F0+46o
    align 4
    aEnemies db 'Enemies',0                 ; DATA XREF: sub_493BF0+37Fo
    ; char asc_5093F4
    asc_5093F4 db ',:;',0                   ; DATA XREF: sub_493BF0+2CFo
    aSendto db 'SENDTO',0                   ; DATA XREF: sub_493BF0+EAo
                                            ; sub_494050+100o ...
    align 4
    aSendtype db 'SENDTYPE',0               ; DATA XREF: sub_493BF0+91o
                                            ; sub_493BF0+15Fo ...
    align 4
    aLiveplyr db 'LIVEPLYR',0               ; DATA XREF: sub_493BF0+49o
    align 4
    aTalk2_gui db 'TALK2.GUI',0             ; DATA XREF: sub_494050+96o
    align 4
    aDone db 'DONE',0                       ; DATA XREF: .text:00494258o
    align 4
    aHotr db 'HOTR',0                       ; DATA XREF: sub_4942E0+FDo
    align 4
    aTurnRate db 'Turn Rate',0              ; DATA XREF: sub_4942E0+35Bo
    align 4
    aAcceleration_0 db 'Acceleration',0     ; DATA XREF: sub_4942E0+315o
    align 4
    aMaxVelocity db 'Max Velocity',0        ; DATA XREF: sub_4942E0+2CCo
    align 4
    aStatistics db 'Statistics',0           ; DATA XREF: sub_4942E0+286o
    align 4
    aBuildTime db 'Build Time',0            ; DATA XREF: sub_4942E0+240o
    align 4
    aCost db 'Cost',0                       ; DATA XREF: sub_4942E0+176o
    align 4
    aUnitinfox_gui db 'UNITINFOx.GUI',0     ; DATA XREF: sub_4942E0+E2o
    align 4
    aAllies_0 db 'ALLIES',0                 ; DATA XREF: .text:004947EDo
                                            ; sub_495010+129o ...
    align 4
    aControl db 'CONTROL',0                 ; DATA XREF: .text:004947C3o
                                            ; sub_495010+174o ...
    aShare db 'SHARE',0                     ; DATA XREF: .text:00494799o
                                            ; sub_495010+141o ...
    align 4
    aOptions_1 db 'OPTIONS',0               ; DATA XREF: .text:00494763o
    aTabmenu_gui db 'TABMENU.GUI',0         ; DATA XREF: sub_495010+25o
                                            ; sub_495010+83o
    aSSS04i_S db '%s%s%s%04i.%s',0          ; DATA XREF: sub_495930+E5o
    align 4
    aSSS_S db '%s%s%s*.%s',0                ; DATA XREF: sub_495930+61o
    align 4
    aScreenshot db 'ScreenShot',0           ; DATA XREF: sub_495A30+98o
                                            ; sub_495A30+B5o
    align 4
    aBmp db 'bmp',0                         ; DATA XREF: sub_495A30+19o
    aCtrl_c db 'CTRL_C',0                   ; DATA XREF: .text:004963FFo
    align 4
    aCtrl_C db 'CTRL_%c',0                  ; DATA XREF: .text:004963E0o
    aFram db 'FRAM',0                       ; DATA XREF: .text:004962CCo
                                            ; sub_496790+28Bo
    align 4
    aSMovie03i db '%s\MOVIE%03i',0          ; DATA XREF: .text:0049629Fo
    align 4
    aSMovie db '%s\MOVIE*',0                ; DATA XREF: .text:00496215o
    align 4
    aSelectsquad db 'SelectSquad',0         ; DATA XREF: sub_495E90+173o
                                            ; sub_496020+1o ...
    aCreatesquad db 'CreateSquad',0         ; DATA XREF: sub_495E90+11Ao
    aErrorCouldNotF db 'Error: Could not find start position number %i on the map!',0
                                            ; DATA XREF: sub_496EE0+12Eo
    align 4
    aSmain2_gui db '%sMAIN2.GUI',0          ; DATA XREF: sub_497180+A24o
    aLoadThread db 'Load Thread',0          ; DATA XREF: sub_497C70+3Bo
    aS_IS db '%s.  %i %s',0                 ; DATA XREF: sub_497CE0+21Bo
    align 4
    aWaitingForOthe db 'Waiting for other players',0 ; DATA XREF: sub_497CE0+20Co
    align 4
    aPlayersReady db 'players ready',0      ; DATA XREF: sub_497CE0+200o
    align 4
    aPlayerReady db 'player ready',0        ; DATA XREF: sub_497CE0+1F9o
    align 4
    aSynchronizatio db 'Synchronization complete',0 ; DATA XREF: sub_497CE0+55o
    align 4
    aExplosions db 'Explosions',0           ; DATA XREF: sub_497F40+CCCo
    align 4
    a3dData db '3D Data',0                  ; DATA XREF: sub_497F40+BD7o
    aAnimation db 'Animation',0             ; DATA XREF: sub_497F40+AFFo
    align 4
    aTerrain db 'Terrain',0                 ; DATA XREF: sub_497F40+957o
    aTextures_0 db 'Textures',0             ; DATA XREF: sub_497F40+87Eo
    align 4
    aUnableToStartT db 'Unable to start the loading thread!',0 ; DATA XREF: sub_497F40+393o
    aLoadgame2bg db 'loadgame2bg',0         ; DATA XREF: sub_497F40+230o
    aNotoktobuild db 'notoktobuild',0       ; DATA XREF: sub_498F70+A8o
    align 4
    aOktobuild db 'oktobuild',0             ; DATA XREF: sub_498F70+2Fo
    align 4
    aShot db 'SHOT',0                       ; DATA XREF: sub_499890+D1o
    dd 0
    align 4
    ; int FunctionName
    FunctionName dd 5096DCh                 ; DATA XREF: sub_49C9C0+1C6r
                                            ; sub_49CC20+121r ...
    dd offset aFiresecondary                ; "FireSecondary"
    dd offset aFiretertiary                 ; "FireTertiary"
    dd 0
    dword_509688 dd 5096B0h                 ; DATA XREF: sub_49E1A0+166r
                                            ; sub_49E1A0+1D0r ...
    dd offset aAimsecondary                 ; "AimSecondary"
    dd offset aAimtertiary                  ; "AimTertiary"
    aAimtertiary db 'AimTertiary',0         ; DATA XREF: .data:00509690o
    aAimsecondary db 'AimSecondary',0       ; DATA XREF: .data:0050968Co
    align 4
    aAimprimary db 'AimPrimary',0
    align 4
    aFiretertiary db 'FireTertiary',0       ; DATA XREF: .data:00509680o
    align 4
    aFiresecondary db 'FireSecondary',0     ; DATA XREF: .data:0050967Co
    align 4
    aFireprimary db 'FirePrimary',0
    aWeaponArray db 'WEAPON ARRAY',0        ; DATA XREF: sub_499A30+6o
    align 4
    aRockunit db 'RockUnit',0               ; DATA XREF: .text:00499C57o
                                            ; sub_49C9C0+226o ...
    align 4
    aSetmaxreloadti db 'SetMaxReloadTime',0 ; DATA XREF: sub_49E070+111o
    align 4
    dword_509718 dd 509724h                 ; DATA XREF: sub_49E830+F9r
    ; LPCSTR lpName
    lpName dd offset aTotalAnnihilat        ; DATA XREF: sub_49E830+47r
                                            ; sub_49E830+6Fr ...
                                            ; "Total Annihilation"
    dword_509720 dd 1                       ; DATA XREF: sub_49E830+38Bw
                                            ; sub_49E830+3A2r ...
    aTotalAnnihil_3 db 'Total Annihilation Class',0
    align 4
    aDebug_fil db 'DEBUG.FIL',0             ; DATA XREF: .text:0049E642o
                                            ; .text:0049E652o
    align 4
    aOutOfMemoryHan db 'Out of memory handler',0 ; DATA XREF: sub_49E700+DFo
    align 4
    aOutOfMemoryYou db 'Out of memory!',0Dh,0Ah ; DATA XREF: sub_49E700+BCo
                                            ; sub_49E700+CCo ...
    db 'Your hard disk may be full',0Dh,0Ah,0
    align 4
    aErrorlog_txt db 'ErrorLog.txt',0       ; DATA XREF: sub_49E700+5Ao
                                            ; sub_4D8E60+BAo ...
    align 4
    aC_0 db 'C:\',0                         ; DATA XREF: sub_49E700+34o
                                            ; sub_4D8E60+94o ...
    aCdshell db 'cdshell',0                 ; DATA XREF: sub_49E830+2DBo
                                            ; sub_49E830+324o ...
    aSoftwareClasse db 'SOFTWARE\Classes\AudioCD\shell',0 ; DATA XREF: sub_49E830+247o
                                            ; sub_49E830+4B6o
    align 4
    aGamedataTransl db 'gamedata\translate.tdf',0 ; DATA XREF: sub_49E830+1FEo
    align 4
    aLanguage db 'language',0               ; DATA XREF: sub_49E830+1C2o
    align 4
    aWargame db 'Wargame',0                 ; DATA XREF: sub_49E830+16Bo
    aMainThread db 'Main Thread',0          ; DATA XREF: sub_49EDFCo
    aDirectplayRegi db 'DirectPlay registration failed.',0 ; DATA XREF: sub_49EE30+5B5o
    aWatching db 'watching',0               ; DATA XREF: sub_49EE30+21Ao
    align 4
    aCheating db 'cheating',0               ; DATA XREF: sub_49EE30+204o
    align 4
    aPermlos db 'permlos',0                 ; DATA XREF: sub_49EE30+1EEo
    aTruelos db 'truelos',0                 ; DATA XREF: sub_49EE30+1D8o
    aCirclos db 'circlos',0                 ; DATA XREF: sub_49EE30+1C2o
    aFixedloc db 'fixedloc',0               ; DATA XREF: sub_49EE30+196o
    align 4
    aDeathmatch db 'deathmatch',0           ; DATA XREF: sub_49EE30+180o
    align 4
    aDeathplays db 'deathplays',0           ; DATA XREF: sub_49EE30+16Ao
    align 4
    aDeathends db 'deathends',0             ; DATA XREF: sub_49EE30+154o
    align 4
    aLock db 'lock',0                       ; DATA XREF: sub_49EE30+131o
    align 4
    ; char asc_509890
    asc_509890 db ' ',9,0                   ; DATA XREF: sub_49EE30+8Eo
                                            ; sub_49EE30+10Fo ...
    align 4
    aPreferences db 'Preferences',0         ; DATA XREF: ReadIniFileValue+54o
    aSTotala_ini db '%s\totala.ini',0       ; DATA XREF: ReadIniFileValue+2Eo
    align 4
    aErrorInGuiLayo db 'Error in GUI layout',0 ; DATA XREF: sub_49FF90+6Ao
                                            ; sub_4A0010+6Ao ...
    aHelptext db 'HELPTEXT',0               ; DATA XREF: sub_4A0090+5Eo
                                            ; sub_4A9FD0+604o
    align 4
    aInternalError db 'Internal error',0    ; DATA XREF: sub_4A0D00+18o
    align 4
    aScrollitems db 'SCROLLITEMS',0         ; DATA XREF: .text:004A31CFo
    aButtons0 db 'BUTTONS0',0               ; DATA XREF: .text:004A8052o
                                            ; sub_4A81E0+B05o
    align 4
    aStagebuttnD db 'stagebuttn%d',0        ; DATA XREF: .text:004A8018o
                                            ; sub_4A81E0+A9Fo
    align 4
    aCheckbox db 'CHECKBOX',0               ; DATA XREF: .text:004A7FEEo
                                            ; sub_4A81E0+A24o
    align 4
    aSaveUnder db 'SAVE UNDER',0            ; DATA XREF: sub_4A81E0+ED0o
    align 4
    aGuiSurface db 'GUI SURFACE',0          ; DATA XREF: sub_4A81E0+E8Co
    a_fnt db '.FNT',0                       ; DATA XREF: sub_4A81E0+D7Fo
    align 4
    aStagebuttn1 db 'stagebuttn1',0         ; DATA XREF: sub_4A81E0+AAFo
    aOffOn db 'Off|On',0                    ; DATA XREF: sub_4A81E0+A3Do
    align 4
    aListbox db 'LISTBOX',0                 ; DATA XREF: sub_4A81E0+844o
    aTextinput db 'TEXTINPUT',0             ; DATA XREF: sub_4A81E0+7CDo
    align 4
    aSliders db 'SLIDERS',0                 ; DATA XREF: sub_4A81E0+495o
                                            ; sub_4A81E0+4C2o
    aBacktile db 'BackTile',0               ; DATA XREF: sub_4A81E0+447o
    align 4
    a_gadget db '_gadget',0                 ; DATA XREF: sub_4A81E0+28Ao
    aTitl db 'TITL',0                       ; DATA XREF: .text:004AC1FEo
                                            ; .text:004AC37Fo ...
    align 4
    aConfirm_gui db 'CONFIRM.GUI',0
    aChc2 db 'CHC2',0                       ; DATA XREF: .text:004AC14Ao
                                            ; .text:004AC1B6o ...
    align 4
    aChc1 db 'CHC1',0                       ; DATA XREF: .text:004AC137o
                                            ; .text:004AC1A2o ...
    align 4
    aNotexist_gui db 'NOTEXIST.GUI',0       ; DATA XREF: .text:004AC0A8o
    align 4
    aChc3 db 'CHC3',0                       ; DATA XREF: .text:004AC157o
                                            ; .text:004AC1DAo
    align 4
    aChoice3_gui db 'CHOICE3.GUI',0         ; DATA XREF: .text:004AC178o
    aInpt db 'INPT',0                       ; DATA XREF: .text:004AC327o
                                            ; .text:004AC367o
    align 4
    aInput_gui db 'INPUT.GUI',0             ; DATA XREF: .text:004AC348o
    align 4
    aWordwrap db 'WordWrap',0               ; DATA XREF: sub_4AC4C0+69o
    align 4
    aD_3:                                   ; DATA XREF: sub_4AC4C0+35o
                                            ; sub_4AC4C0+41o
    unicode 0, <d>,0
    a___ db '...',0                         ; DATA XREF: sub_4AC610+62o
                                            ; sub_4AC610+D3o ...
    aCols db 'COLS',0                       ; DATA XREF: .text:004AC8D0o
                                            ; .text:004AC97Fo ...
    align 4
    aBlue db 'BLUE',0                       ; DATA XREF: .text:004ACA7Co
    align 4
    aGren db 'GREN',0                       ; DATA XREF: .text:004ACA4Co
    align 4
    off_509A00 dd offset sub_444552         ; DATA XREF: .text:004ACA2Do
    dword_509A04 dd 0A7Bh                   ; DATA XREF: .text:004ACD8Bo
                                            ; sub_4AD4F0+EBo ...
    dword_509A08 dd 0A7Dh                   ; DATA XREF: .text:004ACDC6o
                                            ; sub_4AD4F0+258o ...
    aSS_6 db '%s=%s;',0Ah,0                 ; DATA XREF: sub_4ACDE0+3Bo
                                            ; sub_4ACE50+61o ...
    aGaffile db 'gaffile',0                 ; DATA XREF: sub_4ACE50+4E8o
                                            ; sub_4AD350+171o
    aCommonattribs db 'commonattribs',0     ; DATA XREF: sub_4ACE50+4AFo
                                            ; sub_4AD350+123o
    align 4
    aActive_0 db 'active',0                 ; DATA XREF: sub_4ACE50+465o
                                            ; sub_4AD350+111o
    align 4
    aFontnumber db 'fontnumber',0           ; DATA XREF: sub_4ACE50+416o
                                            ; sub_4AD350+FFo
    align 4
    aTexturenumber db 'texturenumber',0     ; DATA XREF: sub_4ACE50+3C7o
                                            ; sub_4AD350+EDo
    align 4
    aColorb db 'colorb',0                   ; DATA XREF: sub_4ACE50+378o
                                            ; sub_4AD350+D6o
    align 4
    aColorf db 'colorf',0                   ; DATA XREF: sub_4ACE50+32Ao
                                            ; sub_4AD350+BFo
    align 4
    aAttribs db 'attribs',0                 ; DATA XREF: sub_4ACE50+2DCo
                                            ; sub_4AD350+ADo
    aWidth db 'width',0                     ; DATA XREF: sub_4ACE50+23Fo
                                            ; sub_4AD350+87o
    align 4
    aYpos_0 db 'ypos',0                     ; DATA XREF: sub_4ACE50+1F0o
                                            ; sub_4AD350+74o
    align 4
    aXpos_0 db 'xpos',0                     ; DATA XREF: sub_4ACE50+180o
                                            ; sub_4AD350+61o
    align 4
    aAssoc db 'assoc',0                     ; DATA XREF: sub_4ACE50+C6o
                                            ; sub_4AD350+2Eo
    align 4
    aId_0 db 'id',0                         ; DATA XREF: sub_4ACE50+5Co
                                            ; sub_4AD350+22o
    align 4
    aCommon db 'COMMON',0                   ; DATA XREF: sub_4AD350+5o
                                            ; .text:004AE747o
    align 4
    aDefaultfocus db 'defaultfocus',0       ; DATA XREF: sub_4AD4F0+37Ao
                                            ; sub_4AD890+81o
    align 4
    aEscdefault db 'escdefault',0           ; DATA XREF: sub_4AD4F0+345o
                                            ; sub_4AD890+66o
    align 4
    aCrdefault db 'crdefault',0             ; DATA XREF: sub_4AD4F0+306o
                                            ; sub_4AD890+48o
    align 4
    aPanel_1 db 'panel',0                   ; DATA XREF: sub_4AD4F0+2B3o
                                            ; sub_4AD890+20o
    align 4
    aRevision db 'revision',0               ; DATA XREF: sub_4AD4F0+20Co
                                            ; sub_4AD890+CCo
    align 4
    aMinor db 'minor',0                     ; DATA XREF: sub_4AD4F0+19Fo
                                            ; sub_4AD890+B7o
    align 4
    aMajor db 'major',0                     ; DATA XREF: sub_4AD4F0+132o
                                            ; sub_4AD890+A2o
    align 4
    aVersion_0 db 'VERSION',0               ; DATA XREF: sub_4AD4F0+85o
                                            ; sub_4AD890+8Co
    aTotalgadgets db 'totalgadgets',0       ; DATA XREF: sub_4AD4F0+54o
                                            ; sub_4AD890+Bo
    align 4
    aStatus db 'status',0                   ; DATA XREF: .text:004AD9D1o
                                            ; .text:004ADA16o ...
    align 4
    aStages db 'stages',0                   ; DATA XREF: .text:004ADC2Co
                                            ; sub_4ADC70+C4o ...
    align 4
    aGrayedout db 'grayedout',0             ; DATA XREF: .text:004ADBCBo
                                            ; sub_4ADC70+AFo ...
    align 4
    aQuickkey db 'quickkey',0               ; DATA XREF: .text:004ADB5Do
                                            ; sub_4ADC70+71o ...
    align 4
    aItemheight db 'itemheight',0           ; DATA XREF: .text:004ADDB1o
                                            ; .text:004ADE08o ...
    align 4
    aMaxchars db 'maxchars',0               ; DATA XREF: .text:004ADE74o
                                            ; .text:004ADF19o ...
    align 4
    aKnobsize db 'knobsize',0               ; DATA XREF: .text:004AE125o
                                            ; .text:004AE1C4o ...
    align 4
    aKnobpos db 'knobpos',0                 ; DATA XREF: .text:004AE0C5o
                                            ; .text:004AE1AEo ...
    aThick db 'thick',0                     ; DATA XREF: .text:004AE059o
                                            ; .text:004AE188o ...
    align 4
    aLink db 'link',0                       ; DATA XREF: .text:004AE2C2o
                                            ; .text:004AE360o ...
    align 4
    aHotornot db 'hotornot',0               ; DATA XREF: .text:004AE3D3o
                                            ; .text:004AE416o ...
    align 4
    aNuttin db 'nuttin',0                   ; DATA XREF: .text:004AE5D0o
                                            ; .text:004AE616o ...
    align 4
    aGadgetD db 'GADGET%d',0                ; DATA XREF: .text:004AE6DAo
    align 4
    aBgu db 'BGU',0                         ; DATA XREF: .text:004AE66Co
    aPtrList2 db 'PTR LIST2',0              ; DATA XREF: sub_4AEFA0+50o
    align 4
    aPtrList1 db 'PTR LIST1',0              ; DATA XREF: sub_4AEFA0+38o
    align 4
    aSortedList2 db 'SORTED LIST2',0        ; DATA XREF: sub_4AEFA0+22o
    align 4
    aSortedList1 db 'SORTED LIST1',0        ; DATA XREF: sub_4AEFA0+Co
    align 4
    aDir db '<DIR>',0                       ; DATA XREF: sub_4AF320+C8o
    align 4
    a__0 db '*.',0                          ; DATA XREF: sub_4AF320+52o
    align 4
    aFiletimes db 'FILETIMES',0             ; DATA XREF: sub_4AF320+16o
    align 4
    aSwin db 'SWIN',0                       ; DATA XREF: sub_4AF5B0+66o
                                            ; sub_4AF670+6Bo ...
    align 4
    aVdrv db 'VDRV',0                       ; DATA XREF: sub_4AF670+216o
    align 4
    aDdrv db 'DDRV',0                       ; DATA XREF: sub_4AF670+1EFo
    align 4
    aCdrv db 'CDRV',0                       ; DATA XREF: sub_4AF670+1C8o
    align 4
    aBdrv db 'BDRV',0                       ; DATA XREF: sub_4AF670+1A1o
    align 4
    aAdrv db 'ADRV',0                       ; DATA XREF: sub_4AF670+17Ao
    align 4
    aPath db 'PATH',0                       ; DATA XREF: sub_4AF670+A2o
                                            ; .text:004AFB01o
    align 4
    aCanc db 'CANC',0                       ; DATA XREF: sub_4AF670+82o
    align 4
    aFileSizes db 'FILE SIZES',0            ; DATA XREF: .text:004AFB99o
    align 4
    aFileNames db 'FILE NAMES',0            ; DATA XREF: .text:004AFB68o
    align 4
    aSlid db 'SLID',0                       ; DATA XREF: .text:004AFB1Fo
    align 4
    aMask db 'MASK',0                       ; DATA XREF: .text:004AFAF3o
    align 4
    aNoPath db 'NO PATH',0                  ; DATA XREF: .text:004AFAA6o
    aFileRequesterD db 'FILE REQUESTER DATA',0 ; DATA XREF: .text:004AFA58o
    aFilereq_gui db 'FILEREQ.GUI',0         ; DATA XREF: .text:004AFA38o
    aBlinkwords db 'BlinkWords',0           ; DATA XREF: sub_4AFC60+31o
    align 4
    aListbox_0 db 'Listbox',0               ; DATA XREF: sub_4B0230+34o
    aStaticVaribles db 'Static Varibles',0  ; DATA XREF: sub_4B0720+43o
    aObjectStates db 'Object States',0      ; DATA XREF: sub_4B0720+28o
    align 4
    aPieceStates db 'Piece States',0        ; DATA XREF: sub_4B2040+103o
    align 4
    aHapibankOpenba db '[HapiBank::OpenBank] Decompression Error: %s',0
                                            ; DATA XREF: sub_4B3770+F3o
    align 4
    aHapibank db 'HAPIBANK',0               ; DATA XREF: sub_4B3770+47o
                                            ; sub_4B39C0+CBo
    align 4
    a_cpa db '.cpa',0                       ; DATA XREF: sub_4B39C0+5Eo
    align 4
    aHapibankLoadac db '[HapiBank::LoadAccount] Decompression Error: %s',0Ah
                                            ; DATA XREF: sub_4B4270+D2o
    db 'File: %s',0
    align 4
    aEof db '----------EOF----------',0Ah,0 ; DATA XREF: sub_4B4D70+179o
    align 4
    asc_509D40 db '}',0Ah                   ; DATA XREF: sub_4B4D70+146o
    db 0Ah,0
    aSafeDepositB_0 db '   Safe-Deposit Box #%i contains %i bytes',0Ah,0
                                            ; DATA XREF: sub_4B4D70+12Do
    align 4
    aSafeDepositBox db '   Safe-Deposit Box "%s" contains %i bytes',0Ah,0
                                            ; DATA XREF: sub_4B4D70+11Eo
    aItemSIntegerI0 db '   Item "%s" Integer:  %i (0x%08x)',0Ah,0 ; DATA XREF: sub_4B4D70+D8o
    aItemSDoubleF db '   Item "%s" Double:  %f',0Ah,0 ; DATA XREF: sub_4B4D70+C9o
    align 4
    aItemSStringS db '   Item "%s" String:  "%s"',0Ah,0 ; DATA XREF: sub_4B4D70+AEo
    aItemSUninitial db '   Item "%s" Uninitialized or Unknown',0Ah,0 ; DATA XREF: sub_4B4D70+97o
    align 4
    aAccountS db 'Account:  "%s"',0Ah       ; DATA XREF: sub_4B4D70+6Ao
    db '{',0Ah,0
    align 4
    aNumberOfAccoun db 'Number of accounts: %i',0Ah ; DATA XREF: sub_4B4D70+3Do
    db 0Ah,0
    align 4
    aHapibankAuditF db 'HapiBank Audit File',0Ah ; DATA XREF: sub_4B4D70+2Ao
    db 0Ah,0
    align 4
    aErrorEnvironme db 'Error:  Environment Initialization Failed!',0Ah
                                            ; DATA XREF: sub_4B5980+2FAo
    db 'Check your DirectX setup',0
    aFrateD_0 db 'FRATE %d',0               ; DATA XREF: .text:004B662Bo
    align 4
    aCavedogEnterta db 'Cavedog Entertainment',0 ; DATA XREF: WriteRegistryValue+68o
    align 4
    aSoftware db 'Software',0               ; DATA XREF: WriteRegistryValue+31o
    align 4
    aError db 'Error',0                     ; DATA XREF: sub_4B6B80+9o
    dd 3 dup(0)
    align 4
    dbl_509EF0 dq 1.043037835047e4          ; DATA XREF: sub_4B715A+Br
    dbl_509EF8 dq 9.587379924285e-5         ; DATA XREF: sub_4B7173+19r
    dd 650000h, 12E00C9h, 1F60192h, 2BF025Bh, 3870323h, 44E03EBh, 51504B2h
    dd 5DB0579h, 6A1063Eh, 7650703h, 82807C6h, 8EA0889h, 9AA094Ah, 0A690A0Ah
    dd 0B260AC8h, 0BE20B84h, 0C9C0C3Fh, 0D530CF8h, 0E090DAFh, 0EBD0E63h, 0F6E0F16h
    dd 101D0FC6h, 10C91074h, 1173111Fh, 121A11C7h, 12BF126Dh, 13601310h, 13FF13B0h
    dd 149A144Dh, 153314E7h, 15C7157Dh, 16591611h, 16E716A1h, 1772172Dh, 17F917B6h
    dd 187C183Bh, 18FC18BDh, 1977193Ah, 19EF19B4h, 1A631A2Ah, 1AD31A9Bh, 1B3E1B09h
    dd 1BA61B73h, 1C091BD8h, 1C681C39h, 1CC21C95h, 1D181CEDh, 1D691D41h, 1DB61D90h
    dd 1DFF1DDBh, 1E421E21h, 1E811E63h, 1EBC1E9Fh, 1EF11ED7h, 1F221F0Ah, 1F4E1F39h
    dd 1F761F63h, 1F981F87h, 1FB51FA7h, 1FCE1FC2h, 1FE21FD9h, 1FF11FEAh, 1FFA1FF6h
    dd 1FFF1FFEh, 1FFF2000h, 1FFA1FFEh, 1FF11FF6h, 1FE21FEAh, 1FCE1FD9h, 1FB51FC2h
    dd 1F981FA7h, 1F761F87h, 1F4E1F63h, 1F221F39h, 1EF11F0Ah, 1EBC1ED7h, 1E811E9Fh
    dd 1E421E63h, 1DFF1E21h, 1DB61DDBh, 1D691D90h, 1D181D41h, 1CC21CEDh, 1C681C95h
    dd 1C091C39h, 1BA61BD8h, 1B3E1B73h, 1AD31B09h, 1A631A9Bh, 19EF1A2Ah, 197719B4h
    dd 18FC193Ah, 187C18BDh, 17F9183Bh, 177217B6h, 16E7172Dh, 165916A1h, 15C71611h
    dd 1533157Dh, 149A14E7h, 13FF144Dh, 136013B0h, 12BF1310h, 121A126Dh, 117311C7h
    dd 10C9111Fh, 101D1074h, 0F6E0FC6h, 0EBD0F16h, 0E090E63h, 0D530DAFh, 0C9C0CF8h
    dd 0BE20C3Fh, 0B260B84h, 0A690AC8h, 9AA0A0Ah, 8EA094Ah, 8280889h, 76507C6h
    dd 6A10703h, 5DB063Eh, 5150579h, 44E04B2h, 38703EBh, 2BF0323h, 1F6025Bh
    dd 12E0192h, 6500C9h, 0FF9B0000h, 0FED2FF37h, 0FE0AFE6Eh, 0FD41FDA5h, 0FC79FCDDh
    dd 0FBB2FC15h, 0FAEBFB4Eh, 0FA25FA87h, 0F95FF9C2h, 0F89BF8FDh, 0F7D8F83Ah
    dd 0F716F777h, 0F656F6B6h, 0F597F5F6h, 0F4DAF538h, 0F41EF47Ch, 0F364F3C1h
    dd 0F2ADF308h, 0F1F7F251h, 0F143F19Dh, 0F092F0EAh, 0EFE3F03Ah, 0EF37EF8Ch
    dd 0EE8DEEE1h, 0EDE6EE39h, 0ED41ED93h, 0ECA0ECF0h, 0EC01EC50h, 0EB66EBB3h
    dd 0EACDEB19h, 0EA39EA83h, 0E9A7E9EFh, 0E919E95Fh, 0E88EE8D3h, 0E807E84Ah
    dd 0E784E7C5h, 0E704E743h, 0E689E6C6h, 0E611E64Ch, 0E59DE5D6h, 0E52DE565h
    dd 0E4C2E4F7h, 0E45AE48Dh, 0E3F7E428h, 0E398E3C7h, 0E33EE36Bh, 0E2E8E313h
    dd 0E297E2BFh, 0E24AE270h, 0E201E225h, 0E1BEE1DFh, 0E17FE19Dh, 0E144E161h
    dd 0E10FE129h, 0E0DEE0F6h, 0E0B2E0C7h, 0E08AE09Dh, 0E068E079h, 0E04BE059h
    dd 0E032E03Eh, 0E01EE027h, 0E00FE016h, 0E006E00Ah, 0E001E002h, 0E001E000h
    dd 0E006E002h, 0E00FE00Ah, 0E01EE016h, 0E032E027h, 0E04BE03Eh, 0E068E059h
    dd 0E08AE079h, 0E0B2E09Dh, 0E0DEE0C7h, 0E10FE0F6h, 0E144E129h, 0E17FE161h
    dd 0E1BEE19Dh, 0E201E1DFh, 0E24AE225h, 0E297E270h, 0E2E8E2BFh, 0E33EE313h
    dd 0E398E36Bh, 0E3F7E3C7h, 0E45AE428h, 0E4C2E48Dh, 0E52DE4F7h, 0E59DE565h
    dd 0E611E5D6h, 0E689E64Ch, 0E704E6C6h, 0E784E743h, 0E807E7C5h, 0E88EE84Ah
    dd 0E919E8D3h, 0E9A7E95Fh, 0EA39E9EFh, 0EACDEA83h, 0EB66EB19h, 0EC01EBB3h
    dd 0ECA0EC50h, 0ED41ECF0h, 0EDE6ED93h, 0EE8DEE39h, 0EF37EEE1h, 0EFE3EF8Ch
    dd 0F092F03Ah, 0F143F0EAh, 0F1F7F19Dh, 0F2ADF251h, 0F364F308h, 0F41EF3C1h
    dd 0F4DAF47Ch, 0F597F538h, 0F656F5F6h, 0F716F6B6h, 0F7D8F777h, 0F89BF83Ah
    dd 0F95FF8FDh, 0FA25F9C2h, 0FAEBFA87h, 0FBB2FB4Eh, 0FC79FC15h, 0FD41FCDDh
    dd 0FE0AFDA5h, 0FED2FE6Eh, 0FF9BFF37h, 650000h, 12E00C9h, 1F60192h, 2BF025Bh
    dd 3870323h, 44E03EBh, 51504B2h, 5DB0579h, 6A1063Eh, 7650703h, 82807C6h
    dd 8EA0889h, 9AA094Ah, 0A690A0Ah, 0B260AC8h, 0BE20B84h, 0C9C0C3Fh, 0D530CF8h
    dd 0E090DAFh, 0EBD0E63h, 0F6E0F16h, 101D0FC6h, 10C91074h, 1173111Fh, 121A11C7h
    dd 12BF126Dh, 13601310h, 13FF13B0h, 149A144Dh, 153314E7h, 15C7157Dh, 16591611h
    dd 16E716A1h, 1772172Dh, 17F917B6h, 187C183Bh, 18FC18BDh, 1977193Ah, 19EF19B4h
    dd 1A631A2Ah, 1AD31A9Bh, 1B3E1B09h, 1BA61B73h, 1C091BD8h, 1C681C39h, 1CC21C95h
    dd 1D181CEDh, 1D691D41h, 1DB61D90h, 1DFF1DDBh, 1E421E21h, 1E811E63h, 1EBC1E9Fh
    dd 1EF11ED7h, 1F221F0Ah, 1F4E1F39h, 1F761F63h, 1F981F87h, 1FB51FA7h, 1FCE1FC2h
    dd 1FE21FD9h, 1FF11FEAh, 1FFA1FF6h, 1FFF1FFEh
    dword_50A400 dd 0                       ; DATA XREF: .text:004B71D8w
                                            ; .text:004B72F1r
    dword_50A404 dd 0                       ; DATA XREF: .text:004B7230w
                                            ; .text:004B731Fr
    dword_50A408 dd 0                       ; DATA XREF: .text:004B7254w
                                            ; .text:004B734Er
    dword_50A40C dd 0                       ; DATA XREF: .text:004B7266w
                                            ; .text:004B7300r
    dword_50A410 dd 0                       ; DATA XREF: .text:004B728Aw
                                            ; .text:004B732Er
    dword_50A414 dd 0                       ; DATA XREF: .text:004B72AFw
                                            ; .text:004B735Dr
    dword_50A418 dd 0                       ; DATA XREF: .text:004B72B7w
                                            ; .text:004B730Fr
    dword_50A41C dd 0                       ; DATA XREF: .text:004B72C8w
                                            ; .text:004B733Dr
    dword_50A420 dd 0                       ; DATA XREF: .text:004B72D7w
                                            ; .text:004B736Cr
    aLensframe db 'LensFrame',0             ; DATA XREF: sub_4B91B0+25o
    align 4
    aAlphaTable db 'ALPHA TABLE',0          ; DATA XREF: sub_4BA5C0+5o
    aShadeTable db 'SHADE TABLE',0          ; DATA XREF: sub_4BA610+5o
    aLightTable db 'LIGHT TABLE',0          ; DATA XREF: sub_4BA660+5o
    aGrayTable db 'GRAY TABLE',0            ; DATA XREF: sub_4BA6B0+5o
    align 4
    aBlueTable db 'BLUE TABLE',0            ; DATA XREF: sub_4BA700+5o
    align 4
    aC db '%c:\',0                          ; DATA XREF: sub_4BB190+35o
                                            ; .text:004BB20Do ...
    align 4
    aAB db 'a+b',0                          ; DATA XREF: sub_4BB2C0+4o
    aBlockSizes db 'Block Sizes',0          ; DATA XREF: sub_4BB2E0+166o
                                            ; sub_4BD830+1F0o
    aFileHandle db 'File Handle',0          ; DATA XREF: sub_4BB2E0+Eo
                                            ; sub_4BB6A0+21o
    aNameS db 'name = ',27h,'%s',27h,0Ah,0  ; DATA XREF: sub_4BB7C0+253o
    align 4
    aLengthD db 'length = %d',0Ah,0         ; DATA XREF: sub_4BB7C0+22Fo
    align 4
    aBaseNameS db 'base name ',27h,'%s',27h,0Ah,0 ; DATA XREF: sub_4BB7C0+202o
    aBlockDOfD db 'block %d of %d',0Ah,0    ; DATA XREF: sub_4BB7C0+1E0o
    aHapi_readfromf db '[HAPI_readfromfile] Decompression Error: %s',0Ah,0
                                            ; DATA XREF: sub_4BB7C0+1BAo
    align 4
    aCompressedBuff db 'Compressed Buffer',0 ; DATA XREF: sub_4BB7C0+121o
    align 4
    aUncompressedBl db 'Uncompressed Block',0 ; DATA XREF: sub_4BB7C0+100o
    align 4
    aWb db 'wb',0                           ; DATA XREF: sub_4BC290+5o
                                            ; .text:004BD209o ...
    align 4
    a_ db '*.*',0                           ; DATA XREF: sub_4BC4B0+ACo
    aFindFilesStruc db 'Find Files structure',0 ; DATA XREF: sub_4BC4B0+9o
    align 4
    a__ db '..',0                           ; DATA XREF: sub_4BC930+6Ao
                                            ; sub_4BCA30+6Fo ...
    align 4
    aS db '%s\*',0                          ; DATA XREF: sub_4BCB50+19o
    align 4
    aCopyBuffer db 'COPY BUFFER',0          ; DATA XREF: .text:004BCFF4o
    aI db '%i',0                            ; DATA XREF: .text:004BD30Ao
    align 4
    aHapi db 'HAPI',0                       ; DATA XREF: .text:004BD1B9o
                                            ; sub_4BDD70+86o
    align 4
    aPackageData db 'Package Data',0        ; DATA XREF: .text:004BD189o
                                            ; sub_4BD3B0+20o ...
    align 4
    asc_50A57C db '\*',0                    ; DATA XREF: sub_4BD3B0+8Bo
    align 4
    aDataBuffer db 'Data Buffer',0          ; DATA XREF: sub_4BD830+241o
    aPackBuffer db 'Pack Buffer',0          ; DATA XREF: sub_4BD830+229o
    aHapifileHeader db 'HAPIFILE header',0  ; DATA XREF: sub_4BDD70+189o
    aOpenhapifileSt db 'OPENHAPIFILE structure',0 ; DATA XREF: sub_4BDD70+32o
    align 4
    aHapifileArray db 'HAPIFILE array',0    ; DATA XREF: sub_4BE0B0+98o
    align 4
    aSavemouse3 db 'SAVEMOUSE 3',0          ; DATA XREF: sub_4C2BD0+75o
    aSavemouse2 db 'SAVEMOUSE 2',0          ; DATA XREF: sub_4C2BD0+5Eo
    aSavemouse1 db 'SAVEMOUSE 1',0          ; DATA XREF: sub_4C2BD0+47o
    aMouseEvents db 'MOUSE EVENTS',0        ; DATA XREF: sub_4C2BD0+1Ao
    align 4
    aRoot db 'root',0                       ; DATA XREF: sub_4C2F60+16Ao
                                            ; sub_4C3120+FBo
    align 4
    aTdfFile db 'TDF file',0                ; DATA XREF: sub_4C2F60+10Fo
                                            ; sub_4C3120+AFo
    align 4
    off_50A618 dd offset off_4FDD34         ; DATA XREF: .rdata:004FEBB8o
    dd 0, 56413F2Eh, 65637865h, 6F697470h, 40406Eh, 4FDD34h, 0, 56413F2Eh
    dd 69676F6Ch, 72655F63h, 40726F72h, 40647473h, 40h, 4FDD34h, 0, 56413F2Eh
    dd 5F74756Fh, 725F666Fh, 65676E61h, 64747340h, 4040h
    aInvalidVectorT db 'invalid vector<T> subscript',0 ; DATA XREF: sub_4C3490+66o
                                            ; sub_4C3490+8Fo ...
    aNameSFromFileS db ' - name = ',27h,'%s',27h,' from file %s',0 ; DATA XREF: sub_4C3E40+3F9o
    aEndOfFileNextb db 'End of file - nextblock not zero',0 ; DATA XREF: sub_4C3E40+3ADo
    align 4
    aSubRecordOpeni db 'Sub-record - opening ',27h,'{',27h,' not found',0
                                            ; DATA XREF: sub_4C3E40+365o
    align 4
    aSubRecordClosi db 'Sub-record - closing ',27h,']',27h,' not found',0
                                            ; DATA XREF: sub_4C3E40+35Eo
    align 4
    aDataFieldNot_0 db 'Data field - ',27h,';',27h,' not found',0 ; DATA XREF: sub_4C3E40+2E9o
    align 4
    aDataFieldNotFo db 'Data field - ',27h,'=',27h,' not found',0 ; DATA XREF: sub_4C3E40+2DFo
    align 4
    aParseErrorIn_t db 'Parse error in .TDF File! ',0 ; DATA XREF: sub_4C3E40+17o
    align 4
    aLoadedSurface db 'Loaded Surface',0    ; DATA XREF: sub_4C6F80+44o
    align 4
    dword_50A778 dd 1                       ; DATA XREF: sub_4C9180+2r
                                            ; sub_4C9180+9w ...
    dword_50A77C dd 0                       ; DATA XREF: sub_4C9180+Fo
                                            ; sub_4C91B0+60o ...
    Global_GuaranteePackets dd 1            ; DATA XREF: HAPINET_GuaranteePackets+Er
                                            ; HAPINET_GuaranteePackets+16w ...
    dd 0
    off_50A788 dd offset dword_4FCFC8       ; DATA XREF: sub_4CA100+1Eo
    dd offset dword_4FCFC8+10h
    dd offset dword_4FCFC8+20h
    dd offset dword_4FCFC8+30h
    aDperr_sessionl db 'DPERR_SESSIONLOST - The session was lost. ',0
                                            ; DATA XREF: sub_4C9530+203o
                                            ; sub_4CA100+39o
    align 4
    aDperr_uninitia db 'DPERR_UNINITIALIZED - An object was not initialized. ',0
                                            ; DATA XREF: sub_4C9530+1FBo
    align 4
    aDp_okTheReques db 'DP_OK - The request completed successfully.',0
                                            ; DATA XREF: sub_4C9530+1F3o
    aDperr_ihavenob db 'DPERR_IHAVENOBLOODYIDEA - DirectPlay returned an undocumente'
                                            ; DATA XREF: sub_4C9530+1EBo
    db 'd return value.',0
    aDperr_usercanc db 'DPERR_USERCANCEL - The user canceled the connection process '
                                            ; DATA XREF: sub_4C9530+1D1o
    db 'during a call to the IDirectPlay::Open method.',0
    align 4
    aDperr_busyTheD db 'DPERR_BUSY - The DirectPlay message queue is full. ',0
                                            ; DATA XREF: sub_4C9530+1C9o
    aDperr_unavaila db 'DPERR_UNAVAILABLE - The requested service provider or sessio'
                                            ; DATA XREF: sub_4C9530+1B1o
    db 'n is not available. ',0
    align 4
    aDperr_timeoutT db 'DPERR_TIMEOUT - The operation could not be completed in the '
                                            ; DATA XREF: sub_4C9530+1A9o
    db 'specified time. ',0
    align 4
    aDperr_sendtoob db 'DPERR_SENDTOOBIG - The message buffer passed to the IDirectP'
                                            ; DATA XREF: sub_4C9530+191o
    db 'lay::Send method is larger than allowed. ',0
    align 4
    aDperr_nosessio db 'DPERR_NOSESSIONS - There are no existing sessions for this g'
                                            ; DATA XREF: sub_4C9530+189o
    db 'ame. ',0
    align 4
    aDperr_noplayer db 'DPERR_NOPLAYERS - There are no active players in the session'
                                            ; DATA XREF: sub_4C9530+171o
    db '. ',0
    align 4
    aDperr_nonamese db 'DPERR_NONAMESERVERFOUND - No name server could be found or c'
                                            ; DATA XREF: sub_4C9530+169o
    db 'reated. A name server must exist in order to create a player'
    db '. ',0
    align 4
    aDperr_nomessag db 'DPERR_NOMESSAGES - There are no messages to be received. ',0
                                            ; DATA XREF: sub_4C9530+14Do
    align 4
    aDperr_noconnec db 'DPERR_NOCONNECTION - No communication link was established. '
                                            ; DATA XREF: sub_4C9530+145o
    db 0
    align 4
    aDperr_nocapsTh db 'DPERR_NOCAPS - The communication link underneath DirectPlay '
                                            ; DATA XREF: sub_4C9530+129o
    db 'is not capable of this function.',0
    align 4
    aDperr_invali_0 db 'DPERR_INVALIDPLAYER - The player ID is not recognized as a v'
                                            ; DATA XREF: sub_4C9530+121o
    db 'alid player ID for this game session.',0
    align 4
    aDperr_invalido db 'DPERR_INVALIDOBJECT - The DirectPlay object pointer is inval'
                                            ; DATA XREF: sub_4C9530+105o
    db 'id. ',0
    align 4
    aDperr_invalidf db 'DPERR_INVALIDFLAGS - The flags passed to this function are i'
                                            ; DATA XREF: sub_4C9530+FDo
    db 'nvalid. ',0
    align 4
    aDperr_exceptio db 'DPERR_EXCEPTION - An exception occurred when processing the '
                                            ; DATA XREF: sub_4C9530+E1o
    db 'request. ',0
    align 4
    aDperr_capsnota db 'DPERR_CAPSNOTAVAILABLEYET - The capabilities of the DirectPl'
                                            ; DATA XREF: sub_4C9530+D9o
    db 'ay object have not been determined yet.',0
    aDperr_cantcrea db 'DPERR_CANTCREATEPLAYER - A new player cannot be created. ',0
                                            ; DATA XREF: sub_4C9530+BDo
    align 4
    aDperr_cantaddp db 'DPERR_CANTADDPLAYER - The player cannot be added to the sess'
                                            ; DATA XREF: sub_4C9530+B5o
    db 'ion.',0
    align 4
    aDperr_bufferto db 'DPERR_BUFFERTOOSMALL - The supplied buffer is not large enou'
                                            ; DATA XREF: sub_4C9530+99o
    db 'gh to contain the requested data.',0
    align 4
    aDperr_activepl db 'DPERR_ACTIVEPLAYERS - The requested operation cannot be perf'
                                            ; DATA XREF: sub_4C9530+91o
    db 'ormed because there are existing active players.',0
    align 4
    aDperr_accessde db 'DPERR_ACCESSDENIED - The session is full or an incorrect pas'
                                            ; DATA XREF: sub_4C9530+75o
    db 'sword was supplied.',0
    aDperr_alreadyi db 'DPERR_ALREADYINITIALIZED - This object is already initialize'
                                            ; DATA XREF: sub_4C9530+6Do
    db 'd. ',0
    aDperr_invalidp db 'DPERR_INVALIDPARAMS - One or more of the parameters passed t'
                                            ; DATA XREF: sub_4C9530+51o
    db 'o the function are invalid.',0
    aDperr_outofmem db 'DPERR_OUTOFMEMORY - There is insufficient memory to perform '
                                            ; DATA XREF: sub_4C9530+49o
    db 'the requested operation. ',0
    align 4
    aDperr_genericA db 'DPERR_GENERIC - An undefined error condition occurred. ',0
                                            ; DATA XREF: sub_4C9530+2Do
    aDperr_unsuppor db 'DPERR_UNSUPPORTED - The function is not available in this im'
                                            ; DATA XREF: sub_4C9530+25o
    db 'plementation. ',0
    align 4
    aHapinet_getdpe db 'HAPINET_GetDPErrorString',0Ah,0 ; DATA XREF: sub_4C9530o
    align 4
    ; char asc_50B0C8
    asc_50B0C8 db ' - ',0                   ; DATA XREF: sub_4C9750+19o
    aHapinet_guaran db 'HAPINET_guaranteepackets',0Ah,0 ; DATA XREF: HAPINET_GuaranteePacketso
                                            ; sub_4CA490+CFo
    align 4
    aHapinet_sendpa db 'HAPINET_sendpacket',0Ah,0 ; DATA XREF: HAPINET_SendPacketo
    aHapinet_send_0 db 'HAPINET_sendpacketguaranteed',0Ah,0
                                            ; DATA XREF: HAPINET_SendPacketGuaranteedo
    align 4
    aHapinet_rece_0 db 'HAPINET_receivepacket',0Ah,0 ; DATA XREF: HAPINET_ReceivePacketo
    align 4
    aHapinet_update db 'HAPINET_updategameinfo',0Ah,0 ; DATA XREF: sub_4C9890+2o
    aDpSessionData2 db 'DP SESSION DATA2',0 ; DATA XREF: sub_4C9920+E7o
                                            ; sub_4C9FD0+BCo
    align 4
    aHapinet_crea_1 db 'HAPINET_createnewgame',0Ah,0 ; DATA XREF: sub_4C9920+3o
    align 4
    aHapinet_crea_2 db 'HAPINET_createorjoinlobbygame',0Ah,0 ; DATA XREF: sub_4C9A70+4o
    align 4
    aHapinet_uninit db 'HAPINET_uninitmultiplay',0Ah,0 ; DATA XREF: sub_4C9B70+2o
    align 4
    aHapinet_init_0 db 'HAPINET_initmultiplaydefaults',0Ah,0 ; DATA XREF: sub_4C9C20o
    align 4
    aHapinet_getg_0 db 'HAPINET_getgamescallback',0Ah,0 ; DATA XREF: .text:004C9C50o
    align 4
    aHapinet_juston db 'HAPINET_justone',0Ah,0 ; DATA XREF: .text:004C9D10o
    align 4
    aHapinet_setp_0 db 'HAPINET_setplayerdatabuffer',0Ah,0 ; DATA XREF: .text:004C9D30o
    align 4
    aHapinet_getp_1 db 'HAPINET_getplayerdatabuffer',0Ah,0 ; DATA XREF: .text:004C9D80o
    align 4
    aDpSessionData db 'DP SESSION DATA',0   ; DATA XREF: .text:004C9E0Co
    aHapinet_getcur db 'HAPINET_getcurrentplayers',0Ah,0 ; DATA XREF: .text:004C9DD2o
    align 4
    aHapinet_getgam db 'HAPINET_getgames',0Ah,0 ; DATA XREF: sub_4C9E50+7o
    align 4
    aHapinet_quitga db 'HAPINET_quitgame',0Ah,0 ; DATA XREF: sub_4C9F90o
    align 4
    aHapinet_joinga db 'HAPINET_joingame',0Ah,0 ; DATA XREF: sub_4C9FD0+3o
    align 4
    aDplayConnect_1 db 'DPLAY CONNECTION',0 ; DATA XREF: sub_4CA100+4Fo
    align 4
    aHapinet_enumco db 'HAPINET_enumconnections',0Ah,0 ; DATA XREF: sub_4CA100+Ao
    align 4
    aHapinet_getcon db 'HAPINET_getconnections',0Ah,0 ; DATA XREF: sub_4CA250+5o
    aSD_D db '%s %d.%d',0                   ; DATA XREF: sub_4CA330+67o
    align 4
    aHapinet_enumpr db 'HAPINET_enumproviders',0Ah,0 ; DATA XREF: sub_4CA330+9o
    align 4
    aHapinet_getpro db 'HAPINET_getproviders',0Ah,0 ; DATA XREF: .text:004CA400o
    align 4
    aHapinet_passwo db 'HAPINET_passwordrequired',0Ah,0 ; DATA XREF: sub_4CA450o
    align 4
    aDplayLobbyConn db 'DPLAY LOBBY CONNECTION',0 ; DATA XREF: sub_4CA490+91o
    align 4
    aHapinet_initlo db 'HAPINET_initlobbiedconnection',0Ah,0 ; DATA XREF: sub_4CA490+2o
    align 4
    aHapinet_initco db 'HAPINET_initconnection',0Ah,0 ; DATA XREF: sub_4CA590o
    aHapinet_initmu db 'HAPINET_initmultiplay',0Ah,0 ; DATA XREF: sub_4CA5D0+4o
    align 4
    aHapinet_addpla db 'HAPINET_addplayer',0Ah,0 ; DATA XREF: sub_4CA6A0+4o
    align 4
    aHapinet_remove db 'HAPINET_removeplayer',0Ah,0 ; DATA XREF: sub_4CA780o
    align 4
    aHapinet_getpla db 'HAPINET_getplayername',0Ah,0 ; DATA XREF: sub_4CA7C0o
    align 4
    aHapinet_setpla db 'HAPINET_setplayername',0Ah,0 ; DATA XREF: sub_4CA800o
    align 4
    aHapinet_enumpl db 'HAPINET_enumplayers',0Ah,0 ; DATA XREF: sub_4CA840o
    align 4
    aHapinet_create db 'HAPINET_createcompoundaddress',0Ah,0 ; DATA XREF: sub_4CA880o
    align 4
    aHapinet_enumad db 'HAPINET_enumaddress',0Ah,0 ; DATA XREF: sub_4CA8C0o
    align 4
    aHapinet_crea_0 db 'HAPINET_createdplayinterface',0Ah,0 ; DATA XREF: sub_4CA900+1o
    align 4
    aHapinet_releas db 'HAPINET_releasedplayinterface',0Ah,0 ; DATA XREF: sub_4CA940+2o
    align 4
    aHapinet_getp_0 db 'HAPINET_getplayeraddress',0Ah,0 ; DATA XREF: sub_4CA990o
    align 4
    aColorMap db 'COLOR MAP',0              ; DATA XREF: sub_4CAA40+A6o
    align 4
    aPcxBody db 'PCX BODY',0                ; DATA XREF: sub_4CAA40+92o
    align 4
    aSSS04i_pcx db '%s%s%s%04i.pcx',0       ; DATA XREF: sub_4CB170+100o
    align 4
    aSSS_pcx db '%s%s%s*.pcx',0             ; DATA XREF: sub_4CB170+7Ao
    aCouldnTFindL_0 db 'Couldn',27h,'t find library.',0Ah,0 ; DATA XREF: .text:004CBBC6o
    aCouldnTFindF_0 db 'Couldn',27h,'t find function.',0Ah,0 ; DATA XREF: .text:004CBBACo
    align 4
    aDebugfunc1 db 'DebugFunc1',0           ; DATA XREF: .text:004CBB82o
                                            ; sub_4DA150+1Ao
    align 4
    aDebughelper_dl db 'DebugHelper.dll',0  ; DATA XREF: .text:004CBB71o
                                            ; sub_4DA150+6o
    dword_50B540 dd 0FFFFFFFFh              ; DATA XREF: sub_4CDB40+5Cr
                                            ; sub_4CDB40+158r ...
    dword_50B544 dd 0FFFFFFFFh              ; DATA XREF: sub_4CDB40+67r
                                            ; sub_4CDB40+164r ...
    aOther db 'other',0                     ; DATA XREF: sub_4CDA00+B2o
                                            ; sub_4CE460+70o
    align 4
    aAudio db 'audio',0                     ; DATA XREF: sub_4CDA00+7Co
                                            ; sub_4CE460+30o
    align 4
    aStatusCdaudioT db 'status cdaudio type track 1',0 ; DATA XREF: sub_4CDA00+71o
                                            ; sub_4CE460+21o
    aSetCdaudioTime db 'set cdaudio time format tmsf',0 ; DATA XREF: sub_4CDA00+62o
                                            ; sub_4CE460+11o ...
    align 4
    aStatusCdaudioN db 'status cdaudio number of tracks',0 ; DATA XREF: sub_4CDA00+3Do
    aPlaying db 'playing',0                 ; DATA XREF: sub_4CDB40+D8o
                                            ; sub_4CDB40+19Bo ...
    aStatusCdaudioM db 'status cdaudio mode',0 ; DATA XREF: sub_4CDB40+CBo
                                            ; sub_4CDB40+18Co ...
    aSje_cdplayercl db 'SJE_CdPlayerClass',0 ; DATA XREF: EnumFunc+21o
    align 4
    aSetCdaudioTi_0 db 'set cdaudio time format milliseconds',0 ; DATA XREF: sub_4CE260+FAo
                                            ; sub_4CEB60+1C1o
    align 4
    aStatusCdaudioL db 'status cdaudio length track %i',0 ; DATA XREF: .text:004CE53Co
    align 4
    aStatusCdaudioP db 'status cdaudio position',0 ; DATA XREF: .text:004CE88Co
                                            ; sub_4CE910+D6o
    aPauseCdaudio db 'pause cdaudio',0      ; DATA XREF: sub_4CE910+212o
    align 4
    aNotify db ' notify',0                  ; DATA XREF: sub_4CE910+1D0o
                                            ; sub_4CEB60+17Do
    aTo db ' to ',0                         ; DATA XREF: sub_4CE910+174o
    align 4
    aStatusCdaudi_0 db 'status cdaudio position track %i',0 ; DATA XREF: sub_4CE910+151o
    align 4
    aFrom db ' from ',0                     ; DATA XREF: sub_4CE910+C2o
    align 4
    aPlayCdaudio db 'play cdaudio',0        ; DATA XREF: sub_4CE910+A2o
    align 4
    aStatusCdaudioC db 'status cdaudio current track',0 ; DATA XREF: sub_4CE910+69o
    align 4
    aToI db ' to %i',0                      ; DATA XREF: sub_4CEB60+142o
    align 4
    aPlayCdaudioFro db 'play cdaudio from %i',0 ; DATA XREF: sub_4CEB60+124o
    align 4
    dd 1, 50B8B8h, 2B110108h, 40000h, 0B89C0000h, 1100050h, 2B11h, 2, 50B880h
    dd 2B110208h, 80000h, 0B8640000h, 2100050h, 2B11h, 10h, 50B84Ch, 56220108h
    dd 400000h, 0B8340000h, 1100050h, 5622h, 20h, 50B818h, 56220208h, 800000h
    dd 0B7FC0000h, 2100050h, 5622h, 100h, 50B7E4h, 0AC440108h, 4000000h, 0B7CC0000h
    dd 1100050h, 0AC44h, 200h, 50B7B4h, 0AC440208h, 8000000h, 0B7980000h, 2100050h
    dd 0AC44h, 4 dup(0), 312E3434h, 7A486B20h, 7473202Ch, 6F657265h, 3631202Ch
    dd 7469622Dh, 0, 312E3434h, 7A486B20h, 7473202Ch, 6F657265h, 2D38202Ch
    dd 746962h, 312E3434h, 7A486B20h, 6F6D202Ch, 202C6F6Eh, 622D3631h, 7469h
    dd 312E3434h, 7A486B20h, 6F6D202Ch, 202C6F6Eh, 69622D38h, 74h, 302E3232h
    dd 486B2035h, 73202C7Ah, 65726574h, 31202C6Fh, 69622D36h, 74h, 302E3232h
    dd 486B2035h, 73202C7Ah, 65726574h, 38202C6Fh, 7469622Dh, 0, 302E3232h
    dd 486B2035h, 6D202C7Ah, 2C6F6E6Fh, 2D363120h, 746962h, 302E3232h, 486B2035h
    dd 6D202C7Ah, 2C6F6E6Fh, 622D3820h, 7469h, 302E3131h, 6B203532h, 202C7A48h
    dd 72657473h, 202C6F65h, 622D3631h, 7469h, 302E3131h, 6B203532h, 202C7A48h
    dd 72657473h, 202C6F65h, 69622D38h, 74h, 302E3131h, 6B203532h, 202C7A48h
    dd 6F6E6F6Dh, 3631202Ch, 7469622Dh, 0, 302E3131h, 6B203532h, 202C7A48h
    dd 6F6E6F6Dh, 2D38202Ch, 746962h
    aDigitalAudioSa db 'Digital Audio Sample',0 ; DATA XREF: sub_4CF230+109o
                                            ; sub_4CF370+130o
    align 4
    aWave db 'WAVE',0                       ; DATA XREF: sub_4D01B0+C8o
    align 4
    aRiff db 'RIFF',0                       ; DATA XREF: sub_4D01B0+9Bo
    align 4
    aSdat db 'SDAT',0                       ; DATA XREF: sub_4D01B0+7Ao
    align 4
    aHshd db 'HSHD',0                       ; DATA XREF: sub_4D01B0+4Do
    align 4
    aDigi db 'DIGI',0                       ; DATA XREF: sub_4D01B0+20o
    align 4
    aData_0 db 'data',0                     ; DATA XREF: sub_4D02A0+183o
                                            ; sub_4D02A0+1D5o ...
    align 4
    aFmt db 'fmt ',0                        ; DATA XREF: sub_4D02A0+A2o
                                            ; sub_4D02A0+F4o ...
    align 4
    aHeyTheWindowBu db 'Hey!  The window buffer ptr is not pointing to anything!',0Ah
                                            ; DATA XREF: .text:004D0AB9o
                                            ; DoNetworkCompression+4BDo ...
    db 0
    align 4
    aHeyTheTreePtrI db 'Hey!  The tree ptr is not pointing to anything!',0Ah,0
                                            ; DATA XREF: .text:004D0AE9o
                                            ; DoNetworkCompression+496o ...
    align 4
    aCouldNotAllocC db 'Could not alloc compression tree.',0Ah,0
                                            ; DATA XREF: DoNetworkCompression+E6o
                                            ; .text:004D16BFo
    align 4
    aCouldNotAllocD db 'Could not alloc decompression window.',0Ah,0
                                            ; DATA XREF: DoNetworkCompression+8Ao
                                            ; sub_4D1480+6Fo ...
    dd 0
    align 4
    dword_50B9E0 dd 50BA84h                 ; DATA XREF: sub_4D1C60+9r
    dd offset aSquasherr_badh               ; "SQUASHERR_BADHEADER"
    dd offset aSquasherr_badc               ; "SQUASHERR_BADCHECKSUM"
    dd offset aSquasherr_badu               ; "SQUASHERR_BADUNPACKSIZE"
    dd offset aSquasherr_ba_0               ; "SQUASHERR_BADUNPACKTYPE"
    dd offset aSquasherr_badp               ; "SQUASHERR_BADPACKTYPESQUASHERR_BADPARAM"...
    dd 0
    aSquasherr_badp db 'SQUASHERR_BADPACKTYPESQUASHERR_BADPARAMS',0 ; DATA XREF: .data:0050B9F4o
    align 4
    aSquasherr_ba_0 db 'SQUASHERR_BADUNPACKTYPE',0 ; DATA XREF: .data:0050B9F0o
    aSquasherr_badu db 'SQUASHERR_BADUNPACKSIZE',0 ; DATA XREF: .data:0050B9ECo
    aSquasherr_badc db 'SQUASHERR_BADCHECKSUM',0 ; DATA XREF: .data:0050B9E8o
    align 4
    aSquasherr_badh db 'SQUASHERR_BADHEADER',0 ; DATA XREF: .data:0050B9E4o
    aSquasherr_ok db 'SQUASHERR_OK',0
    align 4
    aSqsh db 'SQSH',0                       ; DATA XREF: sub_4D1820+CFr
                                            ; sub_4D1970+Fo ...
    align 4
    aHeader_unpacke db 'header.unpackedSize = %ld',0Ah,0 ; DATA XREF: .text:004D1C40o
    align 4
    aHeader_packeds db 'header.packedSize   = %ld',0Ah,0 ; DATA XREF: .text:004D1C2Fo
    align 4
    aHeader_encrypt db 'header.encryptType  = %d',0Ah,0 ; DATA XREF: .text:004D1C1Eo
    align 4
    aHeader_packtyp db 0Ah                  ; DATA XREF: .text:004D1C0Bo
    db 'header.packType     = %d',0Ah,0
    align 4
    a1_0_4 db '1.0.4',0                     ; DATA XREF: sub_4D1C80+21o
                                            ; sub_4D1D20+27o ...
    dd 0, 64200000h, 616C6665h, 31206574h, 342E302Eh, 706F4320h, 67697279h
    dd 31207468h, 2D353939h, 36393931h, 61654A20h, 6F6C2D6Eh, 47207075h, 6C6C6961h
    dd 2079h
    align 4
    word_50BB50 dw 0                        ; DATA XREF: sub_4D1DE0+28Ar
                                            ; .text:004D22A5r ...
    word_50BB52 dw 0                        ; DATA XREF: sub_4D1DE0+280r
                                            ; .text:004D229Br ...
    word_50BB54 dw 0                        ; DATA XREF: sub_4D1DE0+296r
                                            ; .text:004D22B1r ...
    word_50BB56 dw 0                        ; DATA XREF: sub_4D1DE0+2A5r
                                            ; .text:004D22C0r ...
    off_50BB58 dd offset sub_4D28F0         ; DATA XREF: .text:004D2351r
                                            ; .text:004D2358r ...
    dd 40004h, 40008h, 4D2C70h, 50004h, 80010h, 4D2C70h, 60004h, 200020h, 4D2C70h
    dd 40004h, 100010h, 4D3100h, 100008h, 200020h, 4D3100h, 100008h, 800080h
    dd 4D3100h, 200008h, 1000080h, 4D3100h, 800020h, 4000102h, 4D3100h, 1020020h
    dd 10000102h, 4D3100h
    aNeedDictionary db 'need dictionary',0  ; DATA XREF: sub_4D37A0+3ABo
                                            ; .data:0050BC38o
    aIncorrectDataC db 'incorrect data check',0 ; DATA XREF: sub_4D37A0+282o
    align 4
    aIncorrectHeade db 'incorrect header check',0 ; DATA XREF: sub_4D37A0+10Do
    align 4
    aInvalidWindowS db 'invalid window size',0 ; DATA XREF: sub_4D37A0+B1o
    aUnknownCompres db 'unknown compression method',0 ; DATA XREF: sub_4D37A0+8Co
    align 4
    dd offset aNeedDictionary               ; "need dictionary"
    dd offset aStreamEnd                    ; "stream end"
    dd offset Data
    dd offset aFileError                    ; "file error"
    dword_50BC48 dd 50BCA8h                 ; DATA XREF: sub_4D23C0+457r
    dd offset aDataError                    ; "data error"
    dword_50BC50 dd 50BC88h                 ; DATA XREF: sub_4D1DE0+2DBr
    dword_50BC54 dd 50BC78h                 ; DATA XREF: sub_4D23C0+66r
                                            ; sub_4D23C0+1F3r ...
    dd offset aIncompatibleVe               ; "incompatible version"
    dd offset Data
    aIncompatibleVe db 'incompatible version',0 ; DATA XREF: .data:0050BC58o
    align 4
    aBufferError db 'buffer error',0
    align 4
    aInsufficientMe db 'insufficient memory',0
    aDataError db 'data error',0            ; DATA XREF: .data:0050BC4Co
    align 4
    aStreamError db 'stream error',0
    align 4
    aFileError db 'file error',0            ; DATA XREF: .data:0050BC44o
    align 4
    aStreamEnd db 'stream end',0            ; DATA XREF: .data:0050BC3Co
    align 4
    dword_50BCD0 dd 0                       ; DATA XREF: sub_4D3DA0+1Cr
                                            ; sub_4D5810+19Er ...
    dd 7 dup(0), 4 dup(1), 4 dup(2), 4 dup(3), 4 dup(4), 4 dup(5), 2 dup(0)
    dword_50BD48 dd 0                       ; DATA XREF: sub_4D3DA0+73r
                                            ; sub_4D3DA0+C6r ...
    dd 3 dup(0), 2 dup(1), 2 dup(2), 2 dup(3), 2 dup(4), 2 dup(5), 2 dup(6)
    dd 2 dup(7), 2 dup(8), 2 dup(9), 2 dup(0Ah), 2 dup(0Bh), 2 dup(0Ch), 2 dup(0Dh)
    dword_50BDC0 dd 10h dup(0), 2, 3, 7, 0  ; DATA XREF: sub_4D56E0+DAo
    byte_50BE10 db 10h                      ; DATA XREF: sub_4D4590+CCr
                                            ; sub_4D4590+417r ...
    dd 8001211h, 0A060907h, 0C040B05h, 0E020D03h, 0F01h
    align 4
    off_50BE28 dd offset byte_527378        ; DATA XREF: sub_4D3DA0+266o
    dd offset dword_50BCD0
    dd 101h, 11Eh, 0Fh, 0
    off_50BE40 dd offset dword_5277F8       ; DATA XREF: sub_4D3DA0+276o
    dd offset dword_50BD48
    dd 0, 1Eh, 0Fh, 0
    dword_50BE58 dd 0, 50BDC0h, 0, 13h, 7, 0 ; DATA XREF: sub_4D3DA0+286o
    dword_50BE70 dd 10h                     ; DATA XREF: sub_4D5F00+3F1r
                                            ; sub_4D5F00+426r
    dd 11h, 12h, 0, 8, 7, 9, 6, 0Ah, 5, 0Bh, 4, 0Ch, 3, 0Dh, 2, 0Eh, 1, 0Fh
    aInvalidBitLeng db 'invalid bit length repeat',0 ; DATA XREF: sub_4D5F00+9FAo
    align 4
    aTooManyLengthO db 'too many length or distance symbols',0 ; DATA XREF: sub_4D5F00+960o
    aInvalidStoredB db 'invalid stored block lengths',0 ; DATA XREF: sub_4D5F00+85Do
    align 4
    aInvalidBlockTy db 'invalid block type',0 ; DATA XREF: sub_4D5F00+7DBo
    align 4
    aInflate1_0_4Co db ' inflate 1.0.4 Copyright 1995-1996 Mark Adler ',0
    align 4
    dword_50BF60 dd 3, 4, 5, 6, 7, 8, 9, 0Ah, 0Bh, 0Dh, 0Fh, 11h, 13h, 17h, 1Bh, 1Fh, 23h
                                            ; DATA XREF: sub_4D7150+20o
                                            ; sub_4D72B0+92o
    dd 2Bh, 33h, 3Bh, 43h, 53h, 63h, 73h, 83h, 0A3h, 0C3h, 0E3h, 102h, 3 dup(0)
    dword_50BFE0 dd 8 dup(0), 4 dup(1), 4 dup(2), 4 dup(3), 4 dup(4), 4 dup(5), 0, 2 dup(0C0h)
                                            ; DATA XREF: sub_4D7150+1Bo
                                            ; sub_4D72B0+8Do
    dd 0
    dword_50C060 dd 1, 2, 3, 4, 5, 7, 9, 0Dh, 11h, 19h, 21h, 31h, 41h, 61h, 81h, 0C1h, 101h
                                            ; DATA XREF: sub_4D7150+A7o
                                            ; sub_4D72B0+DEo
    dd 181h, 201h, 301h, 401h, 601h, 801h, 0C01h, 1001h, 1801h, 2001h, 3001h
    dd 4001h, 6001h
    dword_50C0D8 dd 4 dup(0), 2 dup(1), 2 dup(2), 2 dup(3), 2 dup(4), 2 dup(5), 2 dup(6)
                                            ; DATA XREF: sub_4D7150+A2o
                                            ; sub_4D72B0+D9o
    dd 2 dup(7), 2 dup(8), 2 dup(9), 2 dup(0Ah), 2 dup(0Bh), 2 dup(0Ch), 2 dup(0Dh)
    aIncompleteDyna db 'incomplete dynamic bit lengths tree',0 ; DATA XREF: sub_4D6BE0+67o
    aOversubscribed db 'oversubscribed dynamic bit lengths tree',0 ; DATA XREF: sub_4D6BE0+28o
    aIncompleteLite db 'incomplete literal/length tree',0 ; DATA XREF: sub_4D7150+80o
                                            ; sub_4D7150+104o
    align 4
    aOversubscrib_0 db 'oversubscribed literal/length tree',0 ; DATA XREF: sub_4D7150+3Ao
                                            ; sub_4D7150+C7o
    align 4
    aInvalidDistanc db 'invalid distance code',0 ; DATA XREF: sub_4D7490+612o
                                            ; sub_4D7D70+25Ao
    align 4
    aInvalidLiteral db 'invalid literal/length code',0 ; DATA XREF: sub_4D7490+5C9o
                                            ; sub_4D7D70+2F2o
    dd 0
    dword_50C218 dd 0                       ; DATA XREF: sub_4D5F00+4D5r
                                            ; sub_4D5F00+57Fr ...
    dd 1, 3, 7, 0Fh, 1Fh, 3Fh, 7Fh, 0FFh, 1FFh, 3FFh, 7FFh, 0FFFh, 1FFFh, 3FFFh
    dd 7FFFh, 0FFFFh
    aMemfussy_0 db 'memfussy',0             ; DATA XREF: sub_4D80D0+35o
    align 4
    aMemfussy db '-memfussy',0              ; DATA XREF: sub_4D80D0+2Eo
                                            ; .data:0050C908o
    align 4
    aMemnofussy db '-memnofussy',0          ; DATA XREF: sub_4D80D0+29o
                                            ; .data:0050C90Co
    aMemfrontalign db '-memfrontalign',0    ; DATA XREF: sub_4D80D0+24o
                                            ; sub_4DB760+13o ...
    align 4
    aGonzo_0 db 'gonzo',0                   ; DATA XREF: sub_4D8140+24o
    align 4
    aGonzo db '-gonzo',0                    ; DATA XREF: sub_4D8140+13o
                                            ; .data:0050C914o
    align 4
    aSetmemory db 'setmemory',0             ; DATA XREF: sub_4D8200+28o
    align 4
    aMemset db '-memset',0                  ; DATA XREF: sub_4D8200+1Ao
                                            ; sub_4D8260+Eo ...
    aMemnoset db '-memnoset',0              ; DATA XREF: sub_4D8200+13o
                                            ; .data:0050C91Co
    align 4
    aSetvalue db 'setvalue',0               ; DATA XREF: sub_4D8260+23o
    align 4
    aBlockInfoLdB_0 db 9,'Block info: %ld bytes at %08lX - Alloc #%d',0
                                            ; DATA XREF: sub_4D8790+42o
    aBlockInfoLdByt db 9,'Block info: %ld bytes at %08lX - Alloc #%d - ',27h,'%s',27h
                                            ; DATA XREF: sub_4D8790+20o
    db 0
    align 4
    asc_50C32C db ' : ',0                   ; DATA XREF: sub_4D89B0+72o
    aSD_1 db '%s(%d)',0                     ; DATA XREF: sub_4D89B0+67o
    align 4
    aFreedFrom db 0Ah                       ; DATA XREF: sub_4D8C50+85o
    db 9,'freed from:',0
    align 4
    aAllocatedFrom db ', allocated from:',0 ; DATA XREF: sub_4D8C50+26o
    align 4
    asc_50C35C db 0Ah                       ; DATA XREF: sub_4D8E60+9E1o
    db 0Ah
    db 0Ah
    db 0Ah
    db 0Ah,0
    align 4
    aCr0npxstate08l db 'Cr0NpxState = %08lX',0Ah,0 ; DATA XREF: sub_4D8E60+9C2o
    align 4
    aDataselector08 db 'DataSelector = %08lX',9,9,0 ; DATA XREF: sub_4D8E60+98Eo
    align 4
    aDataoffset08lx db 'DataOffset = %08lX',0Ah,0 ; DATA XREF: sub_4D8E60+96Bo
    aErrorselector0 db 'ErrorSelector = %08lX',9,0 ; DATA XREF: sub_4D8E60+93Ao
    align 4
    aErroroffset08l db 'ErrorOffset = %08lX',0Ah,0 ; DATA XREF: sub_4D8E60+917o
    align 4
    aTagword08lx db 'TagWord = %08lX',9,9,0 ; DATA XREF: sub_4D8E60+8E6o
    align 4
    aStatusword08lx db 'StatusWord = %08lX',0Ah,0 ; DATA XREF: sub_4D8E60+8C3o
    aControlWord08l db 'Control Word = %08lX',9,9,0 ; DATA XREF: sub_4D8E60+892o
    align 4
    aContextflags08 db 'ContextFlags = %08lX',0Ah,0 ; DATA XREF: sub_4D8E60+86Fo
    align 4
    aDr708lx db 'Dr7 = %08lX',0Ah,0         ; DATA XREF: sub_4D8E60+818o
    align 4
    aDr608lx db 'Dr6 = %08lX',9,0           ; DATA XREF: sub_4D8E60+7F5o
    align 4
    aDr308lx db 'Dr3 = %08lX',9,0           ; DATA XREF: sub_4D8E60+7C4o
    align 4
    aDr208lx db 'Dr2 = %08lX',0Ah,0         ; DATA XREF: sub_4D8E60+7A1o
    align 4
    aDr108lx db 'Dr1 = %08lX',9,0           ; DATA XREF: sub_4D8E60+770o
    align 4
    aDr008lx db 'Dr0 = %08lX',9,0           ; DATA XREF: sub_4D8E60+74Do
    align 4
    a02xC db '%02x%c',0                     ; DATA XREF: sub_4D8E60+684o
    align 4
    aBytesAtCsEip db 'Bytes at CS:EIP:',0Ah,0 ; DATA XREF: sub_4D8E60+638o
    align 4
    aEdx08lxEs04lxE db 'EDX=%08lX ES=%04lX EDI=%08lX GS=%08lX',0Ah,0
                                            ; DATA XREF: sub_4D8E60+5F3o
    align 4
    aEcx08lxDs04lxE db 'ECX=%08lX DS=%04lX ESI=%08lX FS=%08lX',0Ah,0
                                            ; DATA XREF: sub_4D8E60+5B1o
    align 4
    aEbx08lxSs04lxE db 'EBX=%08lX SS=%04lX ESP=%08lX EBP=%08lX',0Ah,0
                                            ; DATA XREF: sub_4D8E60+56Fo
    aEax08lxCs04lxE db 'EAX=%08lX CS=%04lX EIP=%08lX EFLGS=%08lX',0Ah,0
                                            ; DATA XREF: sub_4D8E60+52Do
    align 4
    aRegisters db 'Registers:',0Ah,0        ; DATA XREF: sub_4D8E60+4E4o
    a08lxC db '%08lX%c',0                   ; DATA XREF: sub_4D8E60+490o
    aParameters db 'Parameters = ',0        ; DATA XREF: sub_4D8E60+42Bo
    align 4
    aExceptionaddre db 'ExceptionAddress = %08lX',0Ah,0 ; DATA XREF: sub_4D8E60+406o
    align 4
    aExceptionflags db 'ExceptionFlags = %08lX',9,0 ; DATA XREF: sub_4D8E60+3D5o
    aAccessViolatio db 'Access violation: Illegal %s, data address 0x%08lX',0Ah,0
                                            ; DATA XREF: sub_4D8E60+3B2o
    aRead db 'read',0                       ; DATA XREF: sub_4D8E60+390o
    align 4
    aWrite db 'write',0                     ; DATA XREF: sub_4D8E60+387o
    align 4
    aErrorWriteToRe db 'Error: Write to read only memory attempted',0Ah,0
                                            ; DATA XREF: sub_4D8E60+36Ao
    aS_0 db ' - %s',0Ah,0                   ; DATA XREF: sub_4D8E60+32Ao
    align 4
    aExceptioncode0 db 'ExceptionCode = %08lX',0 ; DATA XREF: sub_4D8E60+2FFo
    align 4
    aInstructionPoi db 'Instruction pointer is %08lX',0Ah,0 ; DATA XREF: sub_4D8E60+2DDo
    align 4
    aExceptionHandl db 'Exception handler called in %s. ',0 ; DATA XREF: sub_4D8E60+271o
    align 4
    aModuleSAt04x08 db 'module %s at %04x:%08lx.',0Ah,0 ; DATA XREF: sub_4D8E60+212o
    align 4
    aSCausedAnSIn db '%s caused an %s in',0Ah,0 ; DATA XREF: sub_4D8E60+1CDo
    aUnknownExcepti db 'Unknown exception type',0 ; DATA XREF: sub_4D98C0+1D0o
    align 4
    aMicrosoftCExce db 'Microsoft C++ Exception',0 ; DATA XREF: sub_4D98C0+1B2o
    aDllInitializat db 'DLL Initialization Failed',0 ; DATA XREF: sub_4D98C0+19Co
    align 4
    aStackOverflow db 'Stack Overflow',0    ; DATA XREF: sub_4D98C0+186o
    align 4
    aPrivilegedInst db 'Privileged Instruction',0 ; DATA XREF: sub_4D98C0+170o
    align 4
    aIntegerOverflo db 'Integer Overflow',0 ; DATA XREF: sub_4D98C0+15Ao
    align 4
    aIntegerDivideB db 'Integer Divide by Zero',0 ; DATA XREF: sub_4D98C0+144o
    align 4
    aFloatUnderflow db 'Float Underflow',0  ; DATA XREF: sub_4D98C0+12Eo
    aFloatStackChec db 'Float Stack Check',0 ; DATA XREF: sub_4D98C0+118o
    align 4
    aFloatOverflow db 'Float Overflow',0    ; DATA XREF: sub_4D98C0+105o
    align 4
    aFloatInvalidOp db 'Float Invalid Operation',0 ; DATA XREF: sub_4D98C0+F5o
    aFloatInexactRe db 'Float Inexact Result',0 ; DATA XREF: sub_4D98C0+E5o
    align 4
    aFloatDivideByZ db 'Float Divide by Zero',0 ; DATA XREF: sub_4D98C0+D5o
    align 4
    aFloatDenormalO db 'Float Denormal Operand',0 ; DATA XREF: sub_4D98C0+C5o
    align 4
    aArrayBoundsExc db 'Array Bounds Exceeded',0 ; DATA XREF: sub_4D98C0+B5o
    align 4
    aInvalidDisposi db 'Invalid Disposition',0 ; DATA XREF: sub_4D98C0+A5o
    aNoncontinuable db 'Noncontinuable Exception',0 ; DATA XREF: sub_4D98C0+95o
    align 4
    aIllegalInstruc db 'Illegal Instruction',0 ; DATA XREF: sub_4D98C0+85o
    aNoMemory db 'No Memory',0              ; DATA XREF: sub_4D98C0+75o
    align 4
    aInPageError db 'In Page Error',0       ; DATA XREF: sub_4D98C0+65o
    align 4
    aAccessViolat_0 db 'Access Violation',0 ; DATA XREF: sub_4D98C0+55o
    align 4
    aBreakpoint db 'Breakpoint',0           ; DATA XREF: sub_4D98C0+45o
    align 4
    aDatatypeMisali db 'Datatype Misalignment',0 ; DATA XREF: sub_4D98C0+35o
    align 4
    aControlBreak db 'Control-Break',0      ; DATA XREF: sub_4D98C0+25o
    align 4
    aControlC db 'Control-C',0              ; DATA XREF: sub_4D98C0+15o
    align 4
    aCavedog db 'Cavedog',0                 ; DATA XREF: sub_4D9C15+16o
                                            ; sub_4DA120+Fo ...
    aFatalErrorHand db 'fatal error handler',0 ; DATA XREF: sub_4D9BFEo
    asc_50C8C8 db 0Dh,0Ah                   ; DATA XREF: .text:004D9BCBo
                                            ; .text:004D9BDBo
    db 0Dh,0Ah,0
    align 4
    a08lx_0 db '%08lX: ',0                  ; DATA XREF: sub_4D9CA0+1B5o
    aStackDump db 'Stack dump:',0Ah,0       ; DATA XREF: sub_4D9CA0+142o
    align 4
    asc_50C8E8:                             ; DATA XREF: sub_4D9CA0+AEo
                                            ; sub_4D9CA0+208o ...
    unicode 0, < >,0
    a08lx db '%08lX',0                      ; DATA XREF: sub_4D9CA0+99o
                                            ; sub_4D9CA0+1EEo ...
    align 4
    aCallStack db 'Call stack:',0Ah,0       ; DATA XREF: sub_4D9CA0+3Co
                                            ; sub_4DEA00+28o
    dd 0
    align 4
    off_50C908 dd offset aMemfussy          ; DATA XREF: sub_4DA0E0+7o
                                            ; "-memfussy"
    dd offset aMemnofussy                   ; "-memnofussy"
    dd offset aMemfrontalign                ; "-memfrontalign"
    dd offset aGonzo                        ; "-gonzo"
    dd offset aMemset                       ; "-memset"
    dd offset aMemnoset                     ; "-memnoset"
    dd offset aFpufussy                     ; "-fpufussy"
    dd offset aFpunofussy                   ; "-fpunofussy"
    dd offset aDprinton                     ; "-dprinton"
    dd offset aDprintoff                    ; "-dprintoff"
    dd offset aDprintfile                   ; "-dprintfile"
    dd offset aMemorystatus                 ; "-memorystatus"
    dd offset aPerformancesta               ; "-performancestatus"
    dd offset aDisableimagehl               ; "-disableimagehlp"
    dd offset aEnableimagehlp               ; "-enableimagehlp"
    dd offset aDisableimage_0               ; "-disableimagehlplines"
    dd offset aEnableimageh_0               ; "-enableimagehlplines"
    dd offset aDebughelper                  ; "-debughelper"
    dd offset aSaveresources                ; "-saveresources"
    dword_50C954 dd 0                       ; DATA XREF: sub_4DA0E0+2Co
    dword_50C958 dd 80C000C0h, 0, 11h, 1750000h, 0D4h, 430000h, 760061h, 640065h, 67006Fh
                                            ; DATA XREF: sub_4DA480+17o
    dd 450020h, 74006Eh, 720065h, 610074h, 6E0069h, 65006Dh, 74006Eh, 410020h
    dd 730073h, 720065h, 200074h, 690044h, 700073h, 61006Ch, 79h, 4D0008h
    dd 200053h, 610053h, 73006Eh, 530020h, 720065h, 660069h, 0, 50020000h
    dd 0, 50007h, 8004Ch, 0FFFFFFFFh, 440082h, 620065h, 670075h, 410020h, 730073h
    dd 720065h, 690074h, 6E006Fh, 460020h, 690061h, 65006Ch, 210064h, 0, 50A00804h
    dd 0, 110007h, 5C0167h, 0FFFF03EFh, 81h, 0, 50020000h, 0, 720007h, 800B0h
    dd 0FFFF03F4h, 440082h, 730065h, 720063h, 620069h, 200065h, 750026h, 64006Eh
    dd 720065h, 770020h, 610068h, 200074h, 690063h, 630072h, 6D0075h, 740073h
    dd 6E0061h, 650063h, 200073h, 680074h, 730069h, 610020h, 730073h, 720065h
    dd 200074h, 700061h, 650070h, 720061h, 3A0073h, 0, 50A11004h, 0, 7F0007h
    dd 260167h, 0FFFF03F0h, 81h, 0, 50010000h, 0, 0AB0007h, 0E0032h, 0FFFF03ECh
    dd 260080h, 6F0043h, 790070h, 0, 50010000h, 0, 0BF0007h, 0E0032h, 0FFFF0003h
    dd 260080h, 620041h, 72006Fh, 74h, 0, 50010000h, 0, 0AB004Dh, 0E0032h
    dd 0FFFF03F1h, 260080h, 610053h, 650076h, 0, 50010000h, 0, 0BF004Dh, 0E0032h
    dd 0FFFF03EDh, 260080h, 650044h, 750062h, 67h, 0, 50010000h, 0, 0AB0093h
    dd 0E0032h, 0FFFF03F2h, 530080h, 760061h, 200065h, 260026h, 260020h, 61004Dh
    dd 6C0069h, 0, 50010000h, 0, 0BF0093h, 0E0032h, 0FFFF03EEh, 490080h, 6E0067h
    dd 72006Fh, 200065h, 6C0041h, 770026h, 790061h, 73h, 0, 50010000h, 0, 0AB00D9h
    dd 0E0032h, 0FFFF03F3h, 440080h, 730069h, 620061h, 65006Ch, 410020h, 6C0026h
    dd 6Ch, 0, 50010001h, 0, 0BF00D9h, 0E0032h, 0FFFF0001h, 260080h, 670049h
    dd 6F006Eh, 650072h, 4F0020h, 63006Eh, 65h, 0, 50010000h, 0, 0A70111h
    dd 0E001Ch, 0FFFF03FCh, 410080h, 6F0062h, 740072h, 260020h, 32h, 0, 50010000h
    dd 0, 0B80111h, 0E001Ch, 0FFFF03FDh, 410080h, 6F0062h, 740072h, 260020h
    dd 33h, 0, 50010000h, 0, 0A70132h, 0E001Ch, 0FFFF03FEh, 410080h, 6F0062h
    dd 740072h, 260020h, 34h, 0, 50010000h, 0, 0A70152h, 0E001Ch, 0FFFF03FFh
    dd 410080h, 6F0062h, 740072h, 260020h, 35h, 0, 50010000h, 0, 0BF013Ch
    dd 0E0032h, 0FFFF03FAh, 260080h, 650048h, 70006Ch, 0, 88C800C0h, 0, 7
    dd 0DE0000h, 0A9h, 430000h
    dword_50CD38 dd 88C800C0h, 0, 7, 0DE0000h, 0A9h, 430000h, 760061h, 640065h, 67006Fh
                                            ; DATA XREF: sub_4DA480+2Fo
    dd 4D0020h, 6D0065h, 72006Fh, 200079h, 740053h, 740061h, 730075h, 0A0000h
    dd 6F0043h, 720075h, 650069h, 72h, 50010001h, 0, 7009Eh, 0E0039h, 0FFFF0001h
    dd 430080h, 6F006Ch, 650073h, 0, 50810804h, 0, 70007h, 9B0092h, 0FFFF03E8h
    dd 81h, 0, 50010000h, 0, 4E009Eh, 0E0039h, 0FFFF03E9h, 260080h, 750044h
    dd 70006Dh, 640020h, 740065h, 690061h, 73006Ch, 0, 50010000h, 0, 3C009Eh
    dd 0E0039h, 0FFFF03EAh, 260080h, 650052h, 650073h, 200074h, 650064h, 610074h
    dd 6C0069h, 73h, 0, 50010000h, 0, 22009Eh, 0E0039h, 0FFFF03EBh, 520080h
    dd 730065h, 740065h, 610020h, 6C006Ch, 0, 50010003h, 0, 62009Eh, 0A003Ch
    dd 0FFFF03F9h, 260080h, 6F0057h, 6B0072h, 6E0069h, 200067h, 650073h, 74h
    dd 0, 50010000h, 0, 9400A5h, 0E0032h, 0FFFF03FAh, 260080h, 650048h, 70006Ch
    dd 2 dup(0), 88C800C0h, 0, 1000Dh, 1780002h, 9Dh, 430000h
    dword_50CED8 dd 88C800C0h, 0, 1000Dh, 1780002h, 9Dh, 430000h, 760061h, 640065h, 67006Fh
                                            ; DATA XREF: sub_4DA480+23o
    dd 500020h, 720065h, 6F0066h, 6D0072h, 6E0061h, 650063h, 4D0020h, 6E006Fh
    dd 740069h, 72006Fh, 6E0069h, 67h, 4D0008h, 200053h, 610053h, 73006Eh
    dd 530020h, 720065h, 660069h, 0, 50020000h, 0, 90007h, 8001Ch, 0FFFF03F5h
    dd 450082h, 650076h, 74006Eh, 260020h, 3A0031h, 0, 50210002h, 0, 70023h
    dd 0A60083h, 0FFFF03EDh, 85h, 0, 50020000h, 0, 190007h, 8001Ch, 0FFFF03F3h
    dd 450082h, 650076h, 74006Eh, 260020h, 3A0032h, 0, 50210002h, 0, 180023h
    dd 0A50084h, 0FFFF03EEh, 85h, 0, 50010003h, 0, 800AAh, 0A0041h, 0FFFF03EFh
    dd 260080h, 6E0045h, 620061h, 65006Ch, 700020h, 6F0072h, 690066h, 69006Ch
    dd 67006Eh, 0, 50010003h, 0, 1900AAh, 0A0038h, 0FFFF03F1h, 260080h, 610052h
    dd 730069h, 200065h, 720070h, 6F0069h, 690072h, 790074h, 0, 50010003h
    dd 0, 800ECh, 0A004Eh, 0FFFF03F6h, 440080h, 730069h, 6C0070h, 790061h
    dd 690020h, 20006Eh, 640026h, 620065h, 670075h, 650067h, 72h, 0, 50010003h
    dd 0, 1900ECh, 0A0037h, 0FFFF03F7h, 440080h, 730069h, 6C0070h, 790061h
    dd 680020h, 650026h, 650072h, 0, 50010003h, 0, 8013Ch, 0A0035h, 0FFFF03F8h
    dd 260080h, 750041h, 6F0074h, 700020h, 690061h, 690072h, 67006Eh, 0, 50010001h
    dd 0, 28013Fh, 0E0032h, 0FFFF0001h, 430080h, 6F006Ch, 650073h, 0, 50A10101h
    dd 0, 390007h, 5D0069h, 0FFFF03F4h, 83h, 0, 50810884h, 0, 390076h, 5D00FBh
    dd 0FFFF03F0h, 81h, 0, 50010000h, 0, 280105h, 0E0032h, 0FFFF03FAh, 260080h
    dd 650048h, 70006Ch, 2 dup(0), 3402C8h, 560000h, 5F0053h, 450056h, 530052h
    dd 4F0049h
    aSaveresources db '-saveresources',0    ; DATA XREF: .data:0050C950o
    align 4
    aDebughelper db '-debughelper',0        ; DATA XREF: sub_4DA1D0+1Do
                                            ; .data:0050C94Co
    align 4
    aEnableimageh_0 db '-enableimagehlplines',0 ; DATA XREF: sub_4DE4D0+12o
                                            ; .data:0050C948o
    align 4
    aDisableimage_0 db '-disableimagehlplines',0 ; DATA XREF: sub_4DE4D0+Do
                                            ; .data:0050C944o
    align 4
    aEnableimagehlp db '-enableimagehlp',0  ; DATA XREF: sub_4DE180+1Bo
                                            ; .data:0050C940o
    aDisableimagehl db '-disableimagehlp',0 ; DATA XREF: sub_4DE180+16o
                                            ; .data:0050C93Co
    align 4
    aPerformancesta db '-performancestatus',0 ; DATA XREF: sub_4DFE80+5o
                                            ; .data:0050C938o
    align 4
    aMemorystatus db '-memorystatus',0      ; DATA XREF: sub_4E1460+5o
                                            ; .data:0050C934o
    align 4
    aDprintfile db '-dprintfile',0          ; DATA XREF: .data:0050C930o
    aDprintoff db '-dprintoff',0            ; DATA XREF: .data:0050C92Co
    align 4
    aDprinton db '-dprinton',0              ; DATA XREF: .data:0050C928o
    align 4
    aFpunofussy db '-fpunofussy',0          ; DATA XREF: sub_4DF160+13o
                                            ; .data:0050C924o
    aFpufussy db '-fpufussy',0              ; DATA XREF: sub_4DF160+1Ao
                                            ; .data:0050C920o
    align 4
    asc_50D26C db '%x',0                    ; DATA XREF: sub_4DA040+41o
    align 4
    aCouldnTFindLib db 'Couldn',27h,'t find library ',27h,'debughelper.dll',27h,0Ah,0
                                            ; DATA XREF: sub_4DA150+5Ao
    align 4
    aCouldnTFindFun db 'Couldn',27h,'t find function ',27h,'DebugFunc1',27h,0Ah,0
                                            ; DATA XREF: sub_4DA150+41o
    align 4
    aWindir db 'windir',0                   ; DATA XREF: sub_4DA1D0+5Bo
                                            ; sub_4DE180+1E4o
    align 4
    aD_4 db '=%d',0                         ; DATA XREF: sub_4DA1D0+3Eo
    aGlobalExceptio db 'Global Exception Handler',0 ; DATA XREF: TopLevelExceptionFilter+4o
    align 4
    aCannotStartS_S db 'Cannot start %s. ShellExecute result is %d',0
                                            ; DATA XREF: sub_4DA5B0+196o
    align 4
    aSShellOpenComm db '%s\shell\open\command',0 ; DATA XREF: sub_4DA5B0+BFo
    align 4
    aOpen db 'open',0                       ; DATA XREF: sub_4DA5B0+27o
                                            ; sub_4DA5B0+17Ao
    align 4
    aAddressIsNotWi db 'Address is not within an allocated block.',0
                                            ; DATA XREF: .text:004DAB86o
    align 4
    aBackalign db 'backalign',0             ; DATA XREF: sub_4DB760+24o
    align 4
    asc_50D370:                             ; DATA XREF: sub_4DE180+25Do
                                            ; .text:004EDAD2o ...
    unicode 0, <;>,0
    aUndecoratesymb db 'UnDecorateSymbolName',0 ; DATA XREF: sub_4DE180+19Co
    align 4
    aSymgetlinefrom db 'SymGetLineFromAddr',0 ; DATA XREF: sub_4DE180+18Eo
    align 4
    aSymgetsymfroma db 'SymGetSymFromAddr',0 ; DATA XREF: sub_4DE180+17Co
    align 4
    aSymgetmoduleba db 'SymGetModuleBase',0 ; DATA XREF: sub_4DE180+159o
    align 4
    aSymfunctiontab db 'SymFunctionTableAccess',0 ; DATA XREF: sub_4DE180+136o
    align 4
    aStackwalk db 'StackWalk',0             ; DATA XREF: sub_4DE180+114o
    align 4
    aSymcleanup db 'SymCleanup',0           ; DATA XREF: sub_4DE180+F1o
    align 4
    aSyminitialize db 'SymInitialize',0     ; DATA XREF: sub_4DE180+CEo
    align 4
    aSymsetoptions db 'SymSetOptions',0     ; DATA XREF: sub_4DE180+ACo
    align 4
    aImagehlp_dll db 'IMAGEHLP.DLL',0       ; DATA XREF: sub_4DE180+7Fo
    align 4
    aImagehlp db 'imagehlp',0               ; DATA XREF: sub_4DE180+26o
    align 4
    aImagehlplines db 'imagehlplines',0     ; DATA XREF: sub_4DE4D0+1Do
    align 4
    aVcMfcSrc db '\vc\mfc\src\',0           ; DATA XREF: sub_4DE8A0+E7o
    align 4
    aVcCrtSrc db '\vc\crt\src\',0           ; DATA XREF: sub_4DE8A0+BCo
    align 4
    aMsdevdir db 'MSDevDir',0               ; DATA XREF: sub_4DE8A0+2Do
    align 4
    aSD_2 db ' - %s + %d',0                 ; DATA XREF: sub_4DEA00+261o
    align 4
    aOperatorNew db ' - operator new',0     ; DATA XREF: sub_4DEA00+21Bo
    a??2@yapaxipbdh db '??2@YAPAXIPBDH@Z',0 ; DATA XREF: sub_4DEA00+1E1o
    align 4
    a??2@yapaxi@z db '??2@YAPAXI@Z',0       ; DATA XREF: sub_4DEA00+1A7o
    align 4
    aSD08lx db '%s(%d) : %08lX',0           ; DATA XREF: sub_4DEA00+11Bo
    align 4
    aCallStack_0 db 'Call stack: ',0        ; DATA XREF: sub_4DEA00+35o
    align 4
    dword_50D4D0 dd 50D4D4h                 ; DATA XREF: sub_4DED60+2CBr
    aLibraryDateS_0 db 'Library date stamp: Jun 30 1998 16:08:53',0
    align 4
    aStackGoesFrom0 db 'Stack goes from %08lX to %08lX',0Ah,0 ; DATA XREF: sub_4DED60+3B8o
    aDMbytesPhysica db '%d MBytes physical memory',0Ah,0 ; DATA XREF: sub_4DED60+386o
    align 4
    a1Processor db '1 processor',0Ah,0      ; DATA XREF: sub_4DED60+333o
    align 4
    aDProcessors db '%d processors',0Ah,0   ; DATA XREF: sub_4DED60+310o
    align 4
    aLibraryVersion db 'Library version %d. Library date %s',0Ah,0 ; DATA XREF: sub_4DED60+2DCo
    align 4
    aLibraryDateSta db 'Library date stamp: ',0 ; DATA XREF: sub_4DED60+2BAo
    align 4
    aUtcLinkTime08l db 'UTC link time: %08lx - %s',0 ; DATA XREF: sub_4DED60+29Bo
    align 4
    aExecutableIsDB db 'Executable is %d bytes long and dated %d/%d/%d %02d:%02d:%02'
                                            ; DATA XREF: sub_4DED60+237o
    db 'd',0Ah,0
    align 4
    aSRunBySOnS db '%s, run by %s on %s',0Ah,0 ; DATA XREF: sub_4DED60+14Ao
    align 4
    aUnknown db 'Unknown',0                 ; DATA XREF: sub_4DED60+101o
    aUnknownMachine db 'unknown machine',0  ; DATA XREF: sub_4DED60+E3o
    aComputername db 'computername',0       ; DATA XREF: sub_4DED60+D0o
    align 4
    aUnknownUser db 'unknown user',0        ; DATA XREF: sub_4DED60+A9o
    align 4
    aTimeS db 'Time: %s',0                  ; DATA XREF: sub_4DED60+7Co
    align 4
    aFpufussy_0 db 'fpufussy',0             ; DATA XREF: sub_4DF160+28o
    align 4
    dword_50D660 dd 50D664h                 ; DATA XREF: sub_4DF280+2Cr
                                            ; sub_4DF280+82r ...
    aPerformanceSta db 'Performance status',0
    align 4
    aThisIsAUniqueI db 'This is a unique identifier, isn',27h,'t it - tell me the tr'
                                            ; DATA XREF: sub_4DF1E0+3o
                                            ; sub_4DF1E0+Ao
    db 'uth!',0
    align 4
    aPerformanceDia db 'Performance dialog failed to open',0 ; DATA XREF: sub_4DF250+21o
                                            ; sub_4E05C0+21o
    align 4
    aHttp10_0_150_1 db 'http://10.0.150.18/programming/library/extras/performancesta'
                                            ; DATA XREF: sub_4DF590+3DEo
    db 'tusdialog.html',0
    align 4
    a_htm db '.htm',0                       ; DATA XREF: sub_4DF590+3D9o
                                            ; sub_4E0B90+78Fo
    align 4
    ; LPCSTR lpSubKey
    lpSubKey dd offset aMemoryStatus        ; DATA XREF: sub_4E0520r
                                            ; sub_4E05F0+2Cr ...
                                            ; "Memory Status"
    aMemoryStatus db 'Memory Status',0      ; DATA XREF: .data:0050D72Co
    align 4
    aWorkingset db 'WorkingSet',0           ; DATA XREF: sub_4E0520+25o
    align 4
    aCavedoglibrary db 'CavedogLibrary',0   ; DATA XREF: sub_4E0520+Fo
                                            ; sub_4E1B10+Bo
    align 4
    aTotalWorkingSe db 0Dh,0Ah              ; DATA XREF: sub_4E07E0+380o
    db 'Total Working set:   %13s',0Dh,0Ah
    db 'Maximum Working set: %13s',0Dh,0Ah
    db 'Private:             %13s',0Dh,0Ah
    db 'Shared:              %13s',0Dh,0Ah
    db 'Page Tables:         %13s',0Dh,0Ah,0
    align 4
    aQueryworkingse db 'QueryWorkingSet',0  ; DATA XREF: sub_4E07E0+54o
    aPsapi_dll db 'psapi.dll',0             ; DATA XREF: sub_4E07E0+40o
    align 4
    aHttp10_0_150_0 db 'http://10.0.150.18/programming/library/extras/memorystatusdi'
                                            ; DATA XREF: sub_4E0B90+794o
    db 'alog.html',0
    align 4
    aCurrentAllocat db 'Current Allocations:  %13s',0Dh,0Ah ; DATA XREF: sub_4E0B90+66Co
    db 'Max Allocations:      %13s',0Dh,0Ah
    db 'Allocation Requests:  %13s',0Dh,0Ah
    db 'Allocations per second:  %10.1f',0Dh,0Ah
    db 0Dh,0Ah
    db 'Current Bytes:        %13s',0Dh,0Ah
    db 'Max Bytes:            %13s',0Dh,0Ah
    db 'Bytes Requested:  %17s',0Dh,0Ah
    db 0Dh,0Ah
    db 'Next Alloc Location:    %2X:%08lX',0Dh,0Ah
    db 'Current with padding: %13s',0Dh,0Ah
    db 'Max with padding:     %13s',0Dh,0Ah,0
    align 4
    aSS_3 db '%s,%s',0                      ; DATA XREF: sub_4E0B90+251o
    dd 0
    align 4
    dword_50D980 dd 50000300h, 50DD0Ch, 3, 0, 50010300h, 50DCF8h, 3, 0, 500B0300h, 50DCD4h
                                            ; DATA XREF: sub_4E1BE0+46o
    dd 3, 50280300h, 50220300h, 50DCB8h, 3, 0, 50280300h, 50DCA0h, 3, 0, 50370100h
    dd 50DC80h, 3, 2 dup(50370200h), 50DC6Ch, 3, 0, 503F0300h, 50DC60h, 3
    dd 0
    dword_50DA00 dd 60050300h, 50DCD4h, 3, 60430300h, 60100100h, 50DC48h, 1, 0, 60110200h
                                            ; DATA XREF: sub_4E1BE0+13o
    dd 50DC30h, 2, 0, 60120200h, 50DC24h, 2, 0, 60130200h, 50DC1Ch, 2, 0, 60140200h
    dd 50DC08h, 2, 0, 60290301h, 50DBF0h, 3, 2 dup(6029030Fh), 50DBE0h, 3
    dd 0, 602A0301h, 50DBC8h, 3, 2 dup(602A030Fh), 50DBB8h, 3, 0, 60430300h
    dd 50DBA0h, 3, 0, 60790300h, 50DC60h, 3, 0, 60800300h, 50DB84h, 3, 0, 60810300h
    dd 50DB64h, 3, 0, 60C10100h, 50DB4Ch, 1, 0, 60C40300h, 50DB30h, 3, 0, 60C50300h
    dd 50DB10h, 3, 60C40300h, 6E617242h, 4D206863h, 72707369h, 63696465h, 6E6F6974h
    dd 65522073h, 65726974h, 64h, 6E617242h, 49206863h, 7274736Eh, 69746375h
    dd 20736E6Fh, 69746552h, 646572h, 6F205046h, 61726570h, 6E6F6974h, 65722073h
    dd 65726974h, 64h, 61746F54h, 6E49206Ch, 75727473h, 6F697463h, 6546206Eh
    dd 20686374h, 7373694Dh, 7365h, 61746F54h, 6E49206Ch, 75727473h, 6F697463h
    dd 6546206Eh, 65686374h, 73h, 61746144h, 6D654D20h, 2079726Fh, 65666552h
    dd 636E6572h, 7365h, 4320324Ch, 65686361h, 69725720h, 736574h, 4320324Ch
    dd 65686361h, 69725720h, 4D206574h, 65737369h, 73h, 4320324Ch, 65686361h
    dd 61655220h, 7364h, 4320324Ch, 65686361h, 61655220h, 694D2064h, 73657373h
    dd 0, 6C637943h, 44207365h, 64697669h, 42207265h, 797375h, 69766944h, 736564h
    dd 746C754Dh, 696C7069h, 7365h, 4D205046h, 6F726369h, 65646F63h, 63784520h
    dd 69747065h, 736E6Fh, 43205046h, 75706D6Fh, 69746174h, 6C616E6Fh, 2E704F20h
    dd 0, 636F6C43h, 6369746Bh, 736Bh, 75746552h, 20736E72h, 64657250h, 65746369h
    dd 64h, 75746552h, 20736E72h, 64657250h, 65746369h, 6E492064h, 72726F63h
    dd 6C746365h, 79h, 61746144h, 61657220h, 6F207364h, 72772072h, 73657469h
    dd 0, 616F6C46h, 676E6974h, 696F5020h, 4F20746Eh, 61726570h, 6E6F6974h
    dd 73h, 6173694Dh, 6E67696Ch, 44206465h, 20617461h, 6F6D654Dh, 52207972h
    dd 72656665h, 65636E65h, 0, 61746144h, 63614320h, 57206568h, 65746972h
    dd 73h, 61746144h, 63614320h, 52206568h, 73646165h, 0
    aEvent1 db 'Event1',0                   ; DATA XREF: sub_4E1B10+A8o
    align 4
    aEvent0 db 'Event0',0                   ; DATA XREF: sub_4E1B10+8Fo
    align 4
    aAutopairing db 'AutoPairing',0         ; DATA XREF: sub_4E1B10+76o
    aDisplayinwindo db 'DisplayInWindow',0  ; DATA XREF: sub_4E1B10+61o
    aDisplayindebug db 'DisplayInDebugger',0 ; DATA XREF: sub_4E1B10+4Co
    align 4
    aRaisepriority db 'RaisePriority',0     ; DATA XREF: sub_4E1B10+37o
    align 4
    aEnabledinrelea db 'EnabledInRelease',0 ; DATA XREF: sub_4E1B10+22o
    align 4
    aPerformanceset db 'PerformanceSettings',0 ; DATA XREF: sub_4E1B10+10o
    asc_50DD98 db 0Dh,0Ah,0                 ; DATA XREF: sub_4E1E50+191o
    align 4
    a1_2f db ' (%1.2f%%)',0                 ; DATA XREF: sub_4E1E50+130o
                                            ; sub_4E1E50+183o
    align 4
    aSSU db 0Dh,0Ah                         ; DATA XREF: sub_4E1E50+FDo
                                            ; sub_4E1E50+150o
    db 9,'%s%s: %u',0
    aSelapsedTimeIs db '%sElapsed time is %g sec',0 ; DATA XREF: sub_4E1E50+CBo
    align 4
    aSelapsedTimeFo db '%sElapsed time for ',27h,'%s',27h,' is %g sec',0
                                            ; DATA XREF: sub_4E1E50+A3o
    align 4
    aSoftwareCavedo db 'Software\Cavedog Entertainment',0 ; DATA XREF: sub_4E2BE0+2Do
                                            ; sub_4E2BE0+80o
    align 4
    aZoomed db 'Zoomed',0                   ; DATA XREF: sub_4E3080+172o
                                            ; sub_4E3400+189o
    align 4
    aHeight_0 db 'Height',0                 ; DATA XREF: sub_4E3080+160o
                                            ; sub_4E3400+171o
    align 4
    aWidth_0 db 'Width',0                   ; DATA XREF: sub_4E3080+13Eo
                                            ; sub_4E3400+15Ao
    align 4
    aTopedge db 'TopEdge',0                 ; DATA XREF: sub_4E3080+F1o
                                            ; sub_4E3400+136o
    aLeftedge db 'LeftEdge',0               ; DATA XREF: sub_4E3080+D4o
                                            ; sub_4E3400+11Fo
    align 4
    aCavedogLibrary db 'Cavedog library',0  ; DATA XREF: sub_4E3080+B8o
                                            ; sub_4E3400+79o
    aWindowposition db 'WindowPositions\',0 ; DATA XREF: sub_4E3080+53o
                                            ; sub_4E3400+21o
    align 4
    a_Gdperf_vxd db '\\.\GDPERF.VXD',0      ; DATA XREF: sub_4E35B0+D0o
    align 4
    a_Gdperf db '\\.\GDPERF',0              ; DATA XREF: sub_4E35B0+C9o
    align 4
    aGenuineintel db 'GenuineIntel',0       ; DATA XREF: sub_4E35B0+4Bo
    align 4
    dd offset off_4FDD34
    dd 0, 56413F2Eh, 676E656Ch, 655F6874h, 726F7272h, 64747340h, 4040h, 9875h
    dd 9873h
    dword_50DEB8 dd 4E4320h                 ; DATA XREF: __cinitr
    dword_50DEBC dd 4E4340h                 ; DATA XREF: _threadstartex(x)+4Cr
                                            ; _threadstart(x)+44r
    dword_50DEC0 dd 4E4340h                 ; DATA XREF: __endthreadexr
                                            ; __endthreadr
    dd 3 dup(0)
    dword_50DED0 dd 173Fh                   ; DATA XREF: _floorr
    dd 3 dup(0)
    dbl_50DEE0 dq 5.0e-1                    ; DATA XREF: sub_4E5565+Er
    dd 776F70h
    dword_50DEEC dd 19930520h, 4 dup(0), 736F6361h, 3 dup(0) ; DATA XREF: __NLG_Notify1+2o
                                            ; __NLG_Notify+2o
    off_50DF10 dd offset __exit             ; DATA XREF: __amsg_exit+20r
    dword_50DF14 dd 2                       ; DATA XREF: __FF_MSGBANNER+Er
                                            ; __NMSG_WRITE+43r ...
    dd offset off_4FDD34
    dd 0, 56413F2Eh, 65707974h, 666E695Fh, 40406Fh, 4F21E0h, 3 dup(0)
    dword_50DF40 dd 4FDE04h                 ; DATA XREF: __output+361r
                                            ; __output+3FDr
    dword_50DF44 dd 4FDDF4h                 ; DATA XREF: __output+3C3r
    off_50DF48 dd offset __fptrap           ; DATA XREF: __cfltcvt_init+Fw
                                            ; __output+4DDr
    off_50DF4C dd offset __fptrap           ; DATA XREF: __cfltcvt_init+5w
                                            ; __output+512r
    off_50DF50 dd offset __fptrap           ; DATA XREF: __cfltcvt_init+14w
                                            ; sub_4EF910+B44r
    off_50DF54 dd offset __fptrap           ; DATA XREF: __cfltcvt_init+1Ew
                                            ; __output+4FBr
    dword_50DF58 dd 4F3D00h                 ; DATA XREF: __cfltcvt_init+28w
    dword_50DF5C dd 4F3D00h                 ; DATA XREF: __cfltcvt_init+32w
    dword_50DF60 dd 0                       ; DATA XREF: __mtdeletelocks+8o
                                            ; __lock+7r ...
    dword_50DF64 dd 529F98h                 ; DATA XREF: __mtinitlocks+21r
                                            ; __mtdeletelocks+2Bo ...
    dd 7 dup(0)
    dword_50DF84 dd 529FC8h                 ; DATA XREF: __mtinitlocks+18r
                                            ; __mtdeletelocks+23o ...
    dd 3 dup(0)
    dword_50DF94 dd 529FE0h                 ; DATA XREF: __mtinitlocks+Fr
                                            ; __mtdeletelocks+1Bo ...
    dd 3 dup(0)
    ; LPCRITICAL_SECTION lpCriticalSection
    lpCriticalSection dd offset dword_529FB0 ; DATA XREF: __mtinitlocksr
                                            ; __mtdeletelocks+13o ...
    dd 1Eh dup(0)
    dword_50E020 dd 50E02Ah                 ; DATA XREF: _atof+23r _isalpha+20r ...
    dword_50E024 dd 50E02Ah                 ; DATA XREF: sub_4F6D90+1E8w
                                            ; sub_4F6D90+283w
    public __ctype
    ; unsigned __int16 _ctype[]
    __ctype dd    200000h                   ; DATA XREF: _x_ismbbtype+1Fr
    unicode 0, <        (((((                  H>
    dd 7 dup(100010h), 840010h, 4 dup(840084h), 100084h, 3 dup(100010h), 3 dup(810081h)
    dd 0Ah dup(10001h), 3 dup(100010h), 3 dup(820082h), 0Ah dup(20002h), 2 dup(100010h)
    dd 20h, 40h dup(0)
    ; int cchMultiByte
    cchMultiByte dd 1                       ; DATA XREF: _atof+9r _isalphar ...
    byte_50E230 db 2Eh                      ; DATA XREF: .text:004EA693r
                                            ; .text:004EA6B5r ...
    align 4
    dword_50E234 dd 1                       ; DATA XREF: ___init_numeric+1E5w
    ; DWORD dwTlsIndex
    dwTlsIndex dd 0FFFFFFFFh                ; DATA XREF: _threadstartex(x)+2Ar
                                            ; _threadstart(x)+2Ar ...
    dd 0
    dword_50E240 dd 14h                     ; DATA XREF: __get_fname+6o
    dword_50E244 dd 4FDF00h                 ; DATA XREF: __get_fname+1Dr
    dd 1Dh, 4FDEFCh, 1Ah, 4FDEF8h, 1Bh, 4FDEF0h, 1Fh, 4FDEE8h, 13h, 4FDEE0h
    dd 21h, 4FDED8h, 0Eh, 4FDED0h, 0Dh, 4FDEC8h, 0Fh, 4FDEC0h, 10h, 4FDEB8h
    dd 5, 4FDEB0h, 1Eh, 4FDEACh, 12h, 4FDEA8h, 20h, 4FDEA4h, 0Ch, 4FDE9Ch
    dd 0Bh, 4FDE94h, 15h, 4FDE8Ch, 1Ch, 4FDE84h, 19h, 4FDE7Ch, 11h, 4FDE74h
    dd 18h, 4FDE6Ch, 16h, 4FDE64h, 17h, 4FDE5Ch, 22h, 4FDE58h, 23h, 4FDE54h
    dd 24h, 4FDE50h
    dbl_50E318 dq 1.797693134862316e308     ; DATA XREF: __handle_exc+A5r
                                            ; __handle_exc+C0r ...
    dword_50E320 dd 0                       ; DATA XREF: __powhlp+E7r
    dword_50E324 dd 0FFF80000h              ; DATA XREF: __powhlp+F4r
    dbl_50E328 dq 1.797693134862316e308     ; DATA XREF: __handle_exc+F6r
                                            ; __handle_exc+159r ...
    dd 0, 100000h
    dword_50E338 dd 0                       ; DATA XREF: __powhlp+1E8r
    dword_50E33C dd 80000000h               ; DATA XREF: __powhlp+1EDr
    tbyte_50E340 dt 2.3562723457267347066e313 ; DATA XREF: __set_statfp+Er
                                            ; __set_statfp+20r
    dd 0
    align 4
    tbyte_50E350 dt 1.9149954921904370718e-1233 ; DATA XREF: __set_statfp+32r
    dd 0
    align 4
    tbyte_50E360 dt 1.1897314953572317651e4932 ; DATA XREF: sub_4E5392+16Cr
                                            ; .text:004EC5CCr ...
    tbyte_50E36A dt -1.1897314953572317651e4932 ; DATA XREF: .text:004EC5FDr
    dd 0B9D7A7DCh, 0B1716685h
    db 0Dh, 40h
    tbyte_50E37E dt 3.27675e4               ; DATA XREF: unknown_libname_71+4r
    dd 0C4336F7h, 95F61998h
    db 0FDh, 3Fh
    dbl_50E392 dq 5.0e-1                    ; DATA XREF: sub_4EC6F1+Er
    dd 70786503h, 2 dup(0), 140100h, 4EC561h, 4EC86Dh, 4EC872h, 4EC6A1h, 0
    align 4
    tbyte_50E3C0 dt -1.7845972430358476476e4932 ; DATA XREF: sub_4E5392+1C3r
                                            ; sub_4E680D+84r ...
    dd 2168C235h, 0C90FDAA2h
    db 0FFh, 3Fh
    dbl_50E3D4 dq 1.0                       ; DATA XREF: .text:004EC896r
    dword_50E3DC dd 2 dup(8080408h), 2 dup(80C0400h), 0, 4F21E0h, 3 dup(0)
                                            ; DATA XREF: .text:004EC788o
                                            ; .text:004EC7EFo
    dword_50E400 dd 4ED860h                 ; DATA XREF: sub_4ED910+2Dr
    dd 0
    dword_50E408 dd 43h, 0, 4FE030h         ; DATA XREF: __setlocale_set_cat+134o
                                            ; .data:0050E438o ...
    ; void *dword_50E414
    dword_50E414 dd 0                       ; DATA XREF: .text:004EDA17r
                                            ; .text:004EDB90o ...
    dword_50E418 dd 4EE0F0h                 ; DATA XREF: __setlocale_set_cat+EDr
    off_50E41C dd offset aLc_collate        ; DATA XREF: .text:004EDA93o
                                            ; __setlocale_get_all+30r
                                            ; "LC_COLLATE"
    dword_50E420 dd 50E408h                 ; DATA XREF: __setlocale_get_all+2Br
                                            ; __setlocale_get_all+4Bo
    dd offset unknown_libname_128
    dd offset aLc_ctype                     ; "LC_CTYPE"
    dword_50E42C dd 50E408h                 ; DATA XREF: __setlocale_get_all+103r
    dd offset sub_4F6D90
    dd offset aLc_monetary                  ; "LC_MONETARY"
    dd offset dword_50E408
    dd offset ___init_monetary
    dd offset aLc_numeric                   ; "LC_NUMERIC"
    dd offset dword_50E408
    dd offset ___init_numeric
    off_50E44C dd offset aLc_time           ; DATA XREF: .text:004EDAC5o
                                            ; "LC_TIME"
    off_50E450 dd offset dword_50E408       ; DATA XREF: .text:004EDBF4o
                                            ; __setlocale_get_all+E4o
    dd offset ___init_time
    dword_50E458 dd 43h, 21h dup(0)         ; DATA XREF: __expandlocale+ACo
                                            ; __expandlocale+159o ...
    dword_50E4E0 dd 43h, 21h dup(0)         ; DATA XREF: __expandlocale+74o
                                            ; __expandlocale+132o ...
    dword_50E568 dd 1                       ; DATA XREF: __dosmaperr+Eo
    dword_50E56C dd 16h                     ; DATA XREF: __dosmaperr+68r
    dd 2 dup(2), 3, 2, 4, 18h, 5, 0Dh, 6, 9, 7, 0Ch, 8, 0Ch, 9, 0Ch, 0Ah, 7
    dd 0Bh, 8, 0Ch, 16h, 0Dh, 16h, 0Fh, 2, 10h, 0Dh, 11h, 2 dup(12h), 2, 21h
    dd 0Dh, 35h, 2, 41h, 0Dh, 43h, 2, 50h, 11h, 52h, 0Dh, 53h, 0Dh, 57h, 16h
    dd 59h, 0Bh, 6Ch, 0Dh, 6Dh, 20h, 70h, 1Ch, 72h, 9, 6, 16h, 80h, 0Ah, 81h
    dd 0Ah, 82h, 9, 83h, 16h, 84h, 0Dh, 91h, 29h, 9Eh, 0Dh, 0A1h, 2, 0A4h
    dd 0Bh, 0A7h, 0Dh, 0B7h, 11h, 0CEh, 2, 0D7h, 0Bh, 718h, 0Ch
    dword_50E6D0 dd 0C0000005h, 0Bh, 0, 0C000001Dh, 4, 0, 0C0000096h, 4, 0, 0C000008Dh
                                            ; DATA XREF: .text:004E691Co
                                            ; .text:004E6944o ...
    dd 8, 0, 0C000008Eh, 8, 0, 0C000008Fh, 8, 0, 0C0000090h, 8, 0, 0C0000091h
    dd 8, 0, 0C0000092h, 8, 0, 0C0000093h, 8, 0
    dword_50E748 dd 3                       ; DATA XREF: _raise+138r _raise+15Br ...
    dword_50E74C dd 7                       ; DATA XREF: _raise+13Dr _raise+161r ...
    dword_50E750 dd 78h                     ; DATA XREF: .text:004E6925r
                                            ; .text:004E693Er
    dword_50E754 dd 0Ah                     ; DATA XREF: .text:004E6983r
                                            ; _siglookup+Ar ...
    dword_50E758 dd 7080h                   ; DATA XREF: _localtime+23r
                                            ; _localtime+A2r ...
    dword_50E75C dd 1                       ; DATA XREF: _localtime+39r
                                            ; __tzset_lk+B4w ...
    dword_50E760 dd 0FFFFF1F0h              ; DATA XREF: _localtime+5Ar
                                            ; _localtime+9Cr ...
    dd 0
    dword_50E768 dd 545350h, 0Fh dup(0)     ; DATA XREF: .data:0050E7E8o
    dword_50E7A8 dd 544450h, 0Fh dup(0)     ; DATA XREF: .data:0050E7ECo
    ; char *off_50E7E8
    off_50E7E8 dd offset dword_50E768       ; DATA XREF: __tzset_lk+D7r
                                            ; __tzset_lk+10Cr ...
    ; char *off_50E7EC
    off_50E7EC dd offset dword_50E7A8       ; DATA XREF: __tzset_lk+EAr
                                            ; __tzset_lk+FFr ...
    dword_50E7F0 dd 0FFFFFFFFh              ; DATA XREF: __tzset_lk+24w
                                            ; sub_4EF410+14r ...
    dword_50E7F4 dd 0                       ; DATA XREF: sub_4EF410+1D4r
                                            ; _cvtdate+E5w
    dword_50E7F8 dd 0                       ; DATA XREF: sub_4EF410+23Dr
                                            ; _cvtdate+119w
    dd 0
    dword_50E800 dd 0FFFFFFFFh              ; DATA XREF: __tzset_lk+1Aw
                                            ; sub_4EF410+21r ...
    dword_50E804 dd 0                       ; DATA XREF: sub_4EF410+1DAr
                                            ; _cvtdate+12Cw
    dword_50E808 dd 0                       ; DATA XREF: sub_4EF410+24Fr
                                            ; _cvtdate+164w ...
    asc_50E80C db ' ',9,'-',0Dh,']',0       ; DATA XREF: sub_4EF910+2D5o
    align 4
    asc_50E814:                             ; DATA XREF: sub_4EF910+2C1o
    unicode 0, <]>,0
    byte_50E818 db 1                        ; DATA XREF: sub_4F0730+1BBr
    dd 80402h
    align 4
    dword_50E820 dd 3A4h                    ; DATA XREF: sub_4F0730+65o
    dword_50E824 dd 82798260h               ; DATA XREF: sub_4F0730+1F8r
                                            ; sub_4F0730+209r
    dword_50E828 dd 21h                     ; DATA XREF: sub_4F0730+1FEr
    dd 0
    dword_50E830 dd 0DFA6h                  ; DATA XREF: sub_4F0730+197r
    dd 0, 0A5A1h, 0, 0FCE09F81h, 0, 0FC807E40h, 0, 3A8h, 0A3DAA3C1h, 20h, 5 dup(0)
    dd 0FE81h, 0, 0FE40h, 0, 3B5h, 0A3DAA3C1h, 20h, 5 dup(0), 0FE81h, 0, 0FE41h
    dd 0, 3B6h, 0A2E4A2CFh, 0A2E5001Ah, 5BA2E8h, 4 dup(0), 0FE81h, 0, 0FEA17E40h
    dd 0, 551h, 0DA5EDA51h, 0DA5F0020h, 32DA6Ah, 4 dup(0), 0DED8D381h, 0F9E0h
    dd 0FE817E31h, 0
    dword_50E910 dd 0FFFFFFFFh, 0A00h, 7 dup(0), 1000h ; DATA XREF: _rewind+42o
                                            ; __flsbuf+C9o ...
    dword_50E938 dd 2                       ; DATA XREF: __NMSG_WRITE+Ao
                                            ; __NMSG_WRITE+24r ...
    ; LPCVOID lpBuffer
    lpBuffer dd offset aR6002FloatingP      ; DATA XREF: __NMSG_WRITE+14Br
                                            ; __NMSG_WRITE+1A8r ...
                                            ; "R6002\r\n- floating point not loaded\r\n"
    dd 8, 4FE2C8h, 9, 4FE29Ch, 0Ah, 4FE278h, 10h, 4FE24Ch, 11h, 4FE21Ch, 12h
    dd 4FE1F8h, 13h, 4FE1CCh, 18h, 4FE194h, 19h, 4FE16Ch, 1Ah, 4FE134h, 1Bh
    dd 4FE0FCh, 1Ch, 4FE0D4h, 78h, 4FE0C4h, 79h, 4FE0B4h, 7Ah, 4FE0A4h, 0FCh
    dd 50DD98h, 0FFh, 4FE094h
    off_50E9C8 dd offset off_50E9C8         ; DATA XREF: .text:004F1878o
                                            ; .text:004F1890o ...
    dword_50E9CC dd 50E9C8h                 ; DATA XREF: ___sbh_new_region+83r
                                            ; ___sbh_new_region+8Cw ...
    dd offset dword_50E9E0
    dd offset dword_50E9E0
    dword_50E9D8 dd 0FFFFFFFFh              ; DATA XREF: ___sbh_new_regionr
                                            ; ___sbh_release_region+4Fw
    dd 0FFFFFFFFh
    dword_50E9E0 dd 0F0h, 0F1h, 800h dup(0) ; DATA XREF: .data:0050E9D0o
                                            ; .data:0050E9D4o
    dword_5109E8 dd 50E9C8h                 ; DATA XREF: ___sbh_release_region+16r
                                            ; ___sbh_release_region+21w ...
    dword_5109EC dd 1E0h                    ; DATA XREF: __heap_alloc+9r
                                            ; _calloc+30r ...
    off_5109F0 dd offset dword_52A520       ; DATA XREF: __lock_file+6o
                                            ; __lock_file+14o ...
    dd 0, 52A520h, 101h
    dword_510A00 dd 2 dup(0), 1000h, 0      ; DATA XREF: .text:004F2D43o
    dword_510A10 dd 3 dup(0), 2, 1, 3 dup(0) ; DATA XREF: _printf+2o _printf+11o ...
    dword_510A30 dd 3 dup(0), 2 dup(2), 7 dup(0) ; DATA XREF: __flsbuf+55o
                                            ; sub_4EAE00+26o
    dword_510A60 dd 7Ch dup(0)              ; DATA XREF: .text:004F2D72o
    dword_510C50 dd 7 dup(0)                ; DATA XREF: __lock_file+Do
                                            ; __unlock_file+Do
    dword_510C6C dd 0                       ; DATA XREF: _cvtdate+2Br _cvtdate+BEr
    dword_510C70 dd 0FFFFFFFFh              ; DATA XREF: _gmtime+C4o _cvtdate+9Er ...
    dd 1Eh, 3Bh, 5Ah, 78h, 97h, 0B5h, 0D4h, 0F3h, 111h, 130h, 14Eh, 16Dh
    dword_510CA4 dd 0                       ; DATA XREF: _cvtdate+3Er _cvtdate+CBr ...
    dword_510CA8 dd 0FFFFFFFFh              ; DATA XREF: _gmtime+CBo _cvtdate+A6r
    dd 1Eh, 3Ah, 59h, 77h, 96h, 0B4h, 0D3h, 0F2h, 110h, 12Fh, 14Dh, 16Ch, 0
    dword_510CE0 dd 400h, 0FFFFFC01h, 35h, 0Bh, 40h, 3FFh ; DATA XREF: sub_4F3990+8o
    dword_510CF8 dd 80h, 0FFFFFF81h, 18h, 8, 20h, 7Fh ; DATA XREF: sub_4F39B0+8o
    dword_510D10 dd 2694h                   ; DATA XREF: __handle_qnan1r
                                            ; __handle_qnan2+Br ...
    dd 3 dup(0)
    byte_510D20 db 0                        ; DATA XREF: unknown_libname_106+26r
    dd 4000001h, 70000h, 0A00h
    db 0Dh, 2 dup(0)
    flt_510D30 dd 9.375e-1                  ; DATA XREF: unknown_libname_106+6Cr
                                            ; unknown_libname_106+74r
    flt_510D34 dd 1.0625                    ; DATA XREF: unknown_libname_106+83r
                                            ; unknown_libname_106+8Br
    flt_510D38 dd 9.223372e18               ; DATA XREF: unknown_libname_106+F6r
    byte_510D3C db 0                        ; DATA XREF: unknown_libname_120+1Dr
                                            ; unknown_libname_122+1Dr
    dd 4000001h, 70000h, 0A00h, 0Dh, 0
    align 2
    db 0EEh, 3Fh
    dbl_510D54 dq 1.844674407370955e19      ; DATA XREF: unknown_libname_121+68r
                                            ; unknown_libname_121+72r ...
    dbl_510D5C dq 5.421010862427522e-20     ; DATA XREF: unknown_libname_120+1CDr
                                            ; unknown_libname_122+1CDr
    dd 0, 3FF00000h
    dbl_510D6C dq 5.0e-1                    ; DATA XREF: unknown_libname_120+161r
                                            ; unknown_libname_122+161r
    tbyte_510D74 dt 1.1897133414953030964e4932 ; DATA XREF: unknown_libname_120+17Cr
                                            ; unknown_libname_122+17Cr
    off_510D7E dd offset sub_4F4D54         ; DATA XREF: .text:004F4D4Dr
    dd offset sub_4F4D5A
    dd offset loc_4F4D5F
    dd offset sub_4F4D65
    dd offset loc_4F4D6A
    dd offset sub_4F4D70
    dd offset sub_4F4D76
    dd offset sub_4F4D7C
    dd offset sub_4F4D82
    dd offset sub_4F4D9E
    dd offset loc_4F4DA3
    dd offset sub_4F4DB9
    dd offset loc_4F4DBE
    dd offset sub_4F4DDA
    dd offset sub_4F4DEA
    dd offset sub_4F4DFE
    dd offset sub_4F4E0E
    dd offset sub_4F4E2E
    dd offset loc_4F4E33
    dd offset sub_4F4E4D
    dd offset loc_4F4E52
    dd offset sub_4F4E72
    dd offset sub_4F4E86
    dd offset sub_4F4E9E
    dd offset sub_4F4EB2
    dd offset sub_4F4ED2
    dd offset loc_4F4ED7
    dd offset sub_4F4EF1
    dd offset loc_4F4EF6
    dd offset sub_4F4F16
    dd offset sub_4F4F2A
    dd offset sub_4F4F42
    dd offset sub_4F4F56
    dd offset sub_4F4F76
    dd offset loc_4F4F7B
    dd offset sub_4F4F95
    dd offset loc_4F4F9A
    dd offset sub_4F4FBA
    dd offset sub_4F4FCE
    dd offset sub_4F4FE6
    dd offset sub_4F4FFA
    dd offset sub_4F501A
    dd offset loc_4F501F
    dd offset sub_4F5039
    dd offset loc_4F503E
    dd offset sub_4F505E
    dd offset sub_4F5072
    dd offset sub_4F508A
    dd offset sub_4F509E
    dd offset sub_4F50BE
    dd offset loc_4F50C3
    dd offset sub_4F50DD
    dd offset loc_4F50E2
    dd offset sub_4F5102
    dd offset sub_4F5116
    dd offset sub_4F512E
    dd offset sub_4F5142
    dd offset sub_4F5162
    dd offset loc_4F5167
    dd offset sub_4F5181
    dd offset loc_4F5186
    dd offset sub_4F51A6
    dd offset sub_4F51BA
    dd offset sub_4F51D2
    align 4
    off_510E80 dd offset aAmerican          ; DATA XREF: sub_4F70A0+49o
                                            ; "american"
    dd 554E45h, 4FE9E8h, 554E45h, 4FE9D4h, 554E45h, 4FE9C8h, 414E45h, 4FE9C0h
    dd 424C4Eh, 4FE9B4h, 434E45h, 4FE9B0h, 48485Ah, 4FE9ACh, 49485Ah, 4FE9A4h
    dd 534843h, 4FE990h, 48485Ah, 4FE97Ch, 534843h, 4FE968h, 49485Ah, 4FE954h
    dd 544843h, 4FE944h, 424C4Eh, 4FE930h, 554E45h, 4FE924h, 414E45h, 4FE914h
    dd 4C4E45h, 4FE908h, 434E45h, 4FE8F4h, 424E45h, 4FE8E8h, 494E45h, 4FE8D8h
    dd 4A4E45h, 4FE8CCh, 5A4E45h, 4FE8B4h, 534E45h, 4FE898h, 544E45h, 4FE88Ch
    dd 474E45h, 4FE880h, 554E45h, 4FE874h, 554E45h, 4FE864h, 425246h, 4FE854h
    dd 435246h, 4FE840h, 4C5246h, 4FE830h, 535246h, 4FE820h, 414544h, 4FE80Ch
    dd 434544h, 4FE7F8h, 4C4544h, 4FE7E8h, 534544h, 4FE7D8h, 494E45h, 4FE7C8h
    dd 535449h, 4FE7BCh, 524F4Eh, 4FE7A8h, 524F4Eh, 4FE794h, 4E4F4Eh, 4FE77Ch
    dd 425450h, 4FE768h, 535345h, 4FE758h, 425345h, 4FE748h, 4C5345h, 4FE734h
    dd 4F5345h, 4FE720h, 435345h, 4FE704h, 445345h, 4FE6F4h, 465345h, 4FE6E0h
    dd 455345h, 4FE6CCh, 475345h, 4FE6B8h, 485345h, 4FE6A8h, 4D5345h, 4FE698h
    dd 4E5345h, 4FE684h, 495345h, 4FE674h, 415345h, 4FE660h, 5A5345h, 4FE650h
    dd 525345h, 4FE63Ch, 555345h, 4FE62Ch, 595345h, 4FE618h, 565345h, 4FE608h
    dd 465653h, 4FE600h, 534544h, 4FE5FCh, 474E45h, 4FE5F8h, 554E45h, 4FE5F4h
    dd 554E45h
    off_511088 dd offset aAmerica           ; DATA XREF: sub_4F70A0+6Eo
                                            ; "america"
    dd offset loc_415353+2
    dd offset aBritain                      ; "britain"
    dd offset dword_524247
    dd offset aChina                        ; "china"
    dd offset loc_4E4842+1
    dd offset aCzech                        ; "czech"
    dd offset loc_455A43
    dd offset aEngland                      ; "england"
    dd offset dword_524247
    dd offset aGreatBritain                 ; "great britain"
    dd offset dword_524247
    dd offset aHolland                      ; "holland"
    dd offset loc_444C4D+1
    dd offset aHongKong                     ; "hong-kong"
    dd offset sub_474B48
    dd offset aNewZealand                   ; "new-zealand"
    dd offset loc_4C5A4E
    dd offset aNz                           ; "nz"
    dd offset loc_4C5A4E
    dd offset aPrChina_0                    ; "pr china"
    dd offset loc_4E4842+1
    dd offset aPrChina                      ; "pr-china"
    dd offset loc_4E4842+1
    dd offset aPuertoRico                   ; "puerto-rico"
    dd offset loc_49524F+1
    dd offset aSlovak                       ; "slovak"
    dd offset loc_4B5652+1
    dd offset aSouthAfrica_1                ; "south africa"
    dd offset loc_464158+2
    dd offset aSouthKorea_0                 ; "south korea"
    dd offset dword_524F4B
    dd offset aSouthAfrica_0                ; "south-africa"
    dd offset loc_464158+2
    dd offset aSouthKorea                   ; "south-korea"
    dd offset dword_524F4B
    dd offset aTrinidadTobago               ; "trinidad & tobago"
    dd offset loc_4F5453+1
    dd offset aUk                           ; "uk"
    dd offset dword_524247
    dd offset aUnitedKingdom                ; "united-kingdom"
    dd offset dword_524247
    dd offset aUnitedStates                 ; "united-states"
    dd offset loc_415353+2
    dd offset aUs                           ; "us"
    dd offset loc_415353+2
    dword_511140 dd 0C1A0C0Ch, 4361007h, 42D080Ch, 100C0403h, 81D0810h
                                            ; DATA XREF: sub_4F7940+4o
    dword_511154 dd 0                       ; DATA XREF: sub_4F7940+11o
    dword_511158 dd 40Ah                    ; DATA XREF: sub_4F7A40+1Fr
    a040a db '040a',0
    align 4
    dword_511164 dd 4FE4E4h                 ; DATA XREF: sub_4F7A40+BDr
    dd offset aGround_unload+5
    ; char *off_51116C
    off_51116C dd offset aSpain             ; DATA XREF: sub_4F7A40+EAr
                                            ; "Spain"
    dd offset aGround_unload+5
    dd 303538h, 0, 32353231h, 0, 40Bh, 62303430h, 0, 4FE4D4h, 4E4946h, 4FE4CCh
    dd 4E4946h, 303538h, 0, 32353231h, 0, 40Ch, 63303430h, 0, 4FE4C4h, 415246h
    dd 4FE4BCh, 415246h, 303538h, 0, 32353231h, 0, 40Fh, 66303430h, 0, 4FE4B0h
    dd 4C5349h, 4FE4A8h, 4C5349h, 303538h, 0, 32353231h, 0, 41Dh, 64313430h
    dd 0, 4FE4A0h, 455653h, 4FE498h, 455753h, 303538h, 0, 32353231h, 0, 42Dh
    dd 64323430h, 0, 4FE490h, 515545h, 4FE4DCh, 505345h, 303538h, 0, 32353231h
    dd 0, 80Ah, 61303830h, 0, 4FE488h, 4D5345h, 4FE480h, 58454Dh, 303538h
    dd 0, 32353231h, 0, 80Ch, 63303830h, 0, 4FE4C4h, 425246h, 4FE478h, 4C4542h
    dd 303538h, 0, 32353231h, 0, 0C07h, 37306330h, 0, 4FE470h, 414544h, 4FE468h
    dd 545541h, 303538h, 0, 32353231h, 0, 0C09h, 39306330h, 0, 4FE460h, 414E45h
    dd 4FE454h, 535541h, 303538h, 0, 32353231h, 0, 0C0Ah, 61306330h, 0, 4FE43Ch
    dd 4E5345h, 4FE4DCh, 505345h, 303538h, 0, 32353231h, 0, 0C0Ch, 63306330h
    dd 0, 4FE4C4h, 435246h, 4FE434h, 4E4143h, 303538h, 0, 32353231h, 0, 100Ah
    dd 61303031h, 0, 4FE488h, 475345h, 4FE428h, 4D5447h, 303538h, 0, 32353231h
    dd 0, 100Ch, 63303031h, 0, 4FE4C4h, 535246h, 4FE41Ch, 454843h, 303538h
    dd 0, 32353231h, 0, 140Ah, 61303431h, 0, 4FE488h, 435345h, 4FE410h, 495243h
    dd 303538h, 0, 32353231h, 0, 140Ch, 63303431h, 0, 4FE4C4h, 4C5246h, 4FE404h
    dd 58554Ch, 303538h, 0, 32353231h, 0, 180Ah, 61303831h, 0, 4FE488h, 415345h
    dd 4FE3FCh, 4E4150h, 303538h, 0, 32353231h, 0, 1C09h, 39306331h, 0, 4FE460h
    dd 534E45h, 4FE3ECh, 46415Ah, 373334h, 0, 32353231h, 0, 1C0Ah, 61306331h
    dd 0, 4FE488h, 445345h, 4FE3D8h, 4D4F44h, 303538h, 0, 32353231h, 0, 200Ah
    dd 61303032h, 0, 4FE488h, 565345h, 4FE3CCh, 4E4556h, 303538h, 0, 32353231h
    dd 0, 240Ah, 61303432h, 0, 4FE488h, 4F5345h, 4FE3C0h, 4C4F43h, 303538h
    dd 0, 32353231h, 0, 280Ah, 61303832h, 0, 4FE488h, 525345h, 4FE3B8h, 524550h
    dd 303538h, 0, 32353231h, 0, 2C0Ah, 61306332h, 0, 4FE488h, 535345h, 4FE3ACh
    dd 475241h, 303538h, 0, 32353231h, 0, 300Ah, 61303033h, 0, 4FE488h, 465345h
    dd 4FE3A4h, 554345h, 303538h, 0, 32353231h, 0, 340Ah, 61303433h, 0, 4FE488h
    dd 4C5345h, 4FE39Ch, 4C4843h, 303538h, 0, 32353231h, 0, 380Ah, 61303833h
    dd 0, 4FE488h, 595345h, 4FE394h, 595255h, 303538h, 0, 32353231h, 0, 3C0Ah
    dd 61306333h, 0, 4FE488h, 5A5345h, 4FE388h, 595250h, 303538h, 0, 32353231h
    dd 2 dup(0)
    off_511600 dd offset aSun               ; DATA XREF: ___init_time+7Fo
                                            ; "Sun"
    dd offset aMon                          ; "Mon"
    dd offset aTue                          ; "Tue"
    dd offset aWed                          ; "Wed"
    dd offset aThu                          ; "Thu"
    dd offset aFri                          ; "Fri"
    dd offset aSat                          ; "Sat"
    dd offset aSunday                       ; "Sunday"
    dd offset aMonday                       ; "Monday"
    dd offset aTuesday                      ; "Tuesday"
    dd offset aWednesday                    ; "Wednesday"
    dd offset aThursday                     ; "Thursday"
    dd offset aFriday                       ; "Friday"
    dd offset aSaturday                     ; "Saturday"
    dd offset aJan                          ; "Jan"
    dd offset aFeb                          ; "Feb"
    dd offset aMar                          ; "Mar"
    dd offset aApr                          ; "Apr"
    dd offset aMay                          ; "May"
    dd offset aJun                          ; "Jun"
    dd offset aJul                          ; "Jul"
    dd offset aAug                          ; "Aug"
    dd offset aSep                          ; "Sep"
    dd offset aOct                          ; "Oct"
    dd offset aNov                          ; "Nov"
    dd offset aDec                          ; "Dec"
    dd offset aJanuary                      ; "January"
    dd offset aFebruary                     ; "February"
    dd offset aMarch                        ; "March"
    dd offset aApril                        ; "April"
    dd offset aMay                          ; "May"
    dd offset aJune                         ; "June"
    dd offset aJuly                         ; "July"
    dd offset aAugust                       ; "August"
    dd offset aSeptember                    ; "September"
    dd offset aOctober                      ; "October"
    dd offset aNovember                     ; "November"
    dd offset aDecember                     ; "December"
    dd offset aAm                           ; "AM"
    dd offset aPm                           ; "PM"
    dd offset aMDYy                         ; "M/d/yy"
    dd offset aDdddMmmmDdYyyy               ; "dddd, MMMM dd, yyyy"
    dd offset aHMmSs                        ; "H:mm:ss"
    dword_5116AC dd 511600h                 ; DATA XREF: ___init_time+51w
                                            ; ___init_time+7Fw ...
    dword_5116B0 dd 2Eh, 0                  ; DATA XREF: ___init_numeric+B6o
    dword_5116B8 dd 5116B0h                 ; DATA XREF: ___init_monetary+A2w
                                            ; ___init_monetary+C0o
    dword_5116BC dd 52A4D8h                 ; DATA XREF: ___init_monetary+ABw
    dword_5116C0 dd 52A4D8h                 ; DATA XREF: ___init_monetary+B9w
    dd offset dword_52A4D8
    dd offset dword_52A4D8
    dd offset dword_52A4D8
    dd offset dword_52A4D8
    dd offset dword_52A4D8
    dd offset dword_52A4D8
    dd offset dword_52A4D8
    dd 2 dup(7F7F7F7Fh)
    dword_5116E8 dd 5116B8h                 ; DATA XREF: ___init_numeric+AEr
                                            ; ___init_numeric+C3r ...
    dd 0
    dword_5116F0 dd 2 dup(0), 4002A000h, 2 dup(0), 4005C800h, 2 dup(0), 4008FA00h, 2 dup(0)
                                            ; DATA XREF: ___multtenpow12+Ao
    dd 400C9C40h, 2 dup(0), 400FC350h, 2 dup(0), 4012F424h, 0, 80000000h, 40169896h
    dd 0, 20000000h, 4019BEBCh, 0, 0C9BF0400h, 40348E1Bh, 0A1000000h, 1BCECCEDh
    dd 404ED3C2h, 0B59EF020h, 0ADA82B70h, 40699DC5h, 25FD5DD0h, 4F8E1AE5h
    dd 4083EB19h, 95D79671h, 8D050E43h, 409EAF29h, 44A0BFF9h, 8F1281EDh, 40B98281h
    dd 0A6D53CBFh, 1F49FFCFh, 40D3C278h, 8CE0C66Fh, 47C980E9h, 41A893BAh, 556B85BCh
    dd 0F78D3927h, 427CE070h, 0DE8EDDBCh, 0EBFB9DF9h, 4351AA7Eh, 0E376E6A1h
    dd 2F29F2CCh, 44268184h, 0AA171028h, 0E310AEF8h, 44FAC4C5h, 0F3D4A7EBh
    dd 4AE1EBF7h, 45CF957Ah, 91C7CC65h, 0A0AEA60Eh, 46A3E319h, 0C17650Dh, 75868175h
    dd 4D48C976h, 0A7E44258h, 353B3993h, 53EDB2B8h, 5DE5A74Dh, 3B5DC53Dh, 5A929E8Bh
    dd 0F0A65DFFh, 54C020A1h, 61378CA5h, 5A8BFDD1h, 5D25D88Bh, 67DBF989h, 0F3F895AAh
    dd 0C8A2BF27h, 6E80DD5Dh, 979BC94Ch, 52028A20h, 7525C460h, 0
    dword_511850 dd 0CCCDCCCDh, 0CCCCCCCCh, 3FFBCCCCh, 0D70A3D71h, 0A3D70A3h, 3FF8A3D7h
                                            ; DATA XREF: ___multtenpow12+18o
    dd 0DF3B645Ah, 6E978D4Fh, 3FF58312h, 652CD3C3h, 1758E219h, 3FF1D1B7h, 84230FD0h
    dd 0AC471B47h, 3FEEA7C5h, 69B6A640h, 0BD05AF6Ch, 3FEB8637h, 42BC3D33h
    dd 94D5E57Ah, 3FE7D6BFh, 0CEFDFDC2h, 77118461h, 3FE4ABCCh, 0E15B4C2Fh
    dd 94BEC44Dh, 3FC9E695h, 3B53C492h, 14CD4475h, 3FAF9ABEh, 94BA67DEh, 1EAD4539h
    dd 3F94CFB1h, 0E2C62324h, 313BBABCh, 3F7A8B61h, 0C1595561h, 7C53B17Eh
    dd 3F5FBB12h, 8D2FEED7h, 8592BE06h, 3F44FB15h, 0E9A53F24h, 0EA27A539h
    dd 3F2AA87Fh, 0E4A1AC7Dh, 467C64BCh, 3E55DDD0h, 0CC067B63h, 83775423h
    dd 3D8191FFh, 193AFA91h, 4325637Ah, 3CACC031h, 38D18921h, 0B8974782h, 3BD7FD00h
    dd 85888DCh, 0E3E8B11Bh, 3B03A686h, 424584C6h, 7599B607h, 3A2EDB37h, 0D21C7133h
    dd 0EE32DB23h, 395A9049h, 0C0BE87A6h, 82A5DA57h, 32B5A2A6h, 11B268E2h
    dd 449F52A7h, 2C10B759h, 2DE44925h, 534F3436h, 256BCEAEh, 0A404598Fh, 7DC2DEC0h
    dd 1EC6E8FBh, 5A88E79Eh, 0BF3C9157h, 18228350h, 62654B4Eh, 0AF8F83FDh
    dd 117D9406h, 9FDE2DE4h, 4C8D2CEh, 0AD8A6DDh, 0, 74727173h, 0
    ; BYTE Data
    Data db 0                               ; DATA XREF: sub_406C90+31o
                                            ; sub_406C90+65o ...
    dd 0
    align 4
    dword_5119C0 dd 0                       ; DATA XREF: sub_409DC0+Cr
                                            ; sub_409E90+Cr ...
    dd 9 dup(0)
    dword_5119E8 dd 0                       ; DATA XREF: sub_40A100+3Ao
                                            ; sub_40E9E0+10Co ...
    dd 5 dup(0)
    dd 4 dup(?)
    dword_511A10 dd ?                       ; DATA XREF: sub_40E9E0+12Eo
                                            ; sub_40EB70+4Fr ...
    dd 9 dup(?)
    dword_511A38 dd ?                       ; DATA XREF: sub_40EB70+35r
                                            ; sub_40EB70+40w ...
    dd ?
    dword_511A40 dd ?                       ; DATA XREF: sub_416150+49r
                                            ; sub_416150+4Fw
    dword_511A44 dd ?                       ; DATA XREF: sub_415FA0+95w
                                            ; sub_415FA0+9Cw ...
    dword_511A48 dd ?                       ; DATA XREF: sub_416150+5Dw
                                            ; sub_416150+7Ar
    dword_511A4C dd ?                       ; DATA XREF: sub_415FA0+A6r
                                            ; sub_415FA0+CCw
    dword_511A50 dd ?                       ; DATA XREF: sub_416150+71w
                                            ; sub_416150+87r
    dd ?
    dword_511A58 dd ?                       ; DATA XREF: sub_415EF0+2Fr
                                            ; sub_415EF0+36w
    dword_511A5C dd ?                       ; DATA XREF: sub_4161F0+1Er
    dword_511A60 dd ?                       ; DATA XREF: .text:00415EB6w
                                            ; sub_4161F0+13r ...
    dword_511A64 dd ?                       ; DATA XREF: .text:00415EBCw
                                            ; sub_417570+31w ...
    dd 56h dup(?)
    dword_511BC0 dd ?                       ; DATA XREF: .text:00415E9Dw
                                            ; sub_415EF0+8r ...
    dword_511BC4 dd ?                       ; DATA XREF: .text:00415EA9w
                                            ; sub_415FA0+38r ...
    Global_PacketSumSize_1 dd ?             ; DATA XREF: .text:00415EDDw
                                            ; HAPINET_PacketStatistics+1Br ...
    dword_511BCC dd ?                       ; DATA XREF: sub_415FA0+EAr
                                            ; sub_415FA0+EFw
    ; char byte_511BD0
    byte_511BD0 db ?                        ; DATA XREF: InterpretCommand+12o
                                            ; InterpretCommand+1Co
    dd 13h dup(?)
    align 4
    dword_511C20 dd ?                       ; DATA XREF: .text:00415EA3w
                                            ; sub_417570+18w ...
    dword_511C24 dd ?                       ; DATA XREF: sub_415FA0+112r
                                            ; sub_415FA0+117w
    dword_511C28 dd ?                       ; DATA XREF: sub_415FA0+13Br
                                            ; sub_415FA0+140w
    dword_511C2C dd ?                       ; DATA XREF: sub_416150+1Br
                                            ; sub_416150+33w
    dword_511C30 dd ?                       ; DATA XREF: sub_415FA0+10Dw
                                            ; sub_415FA0+16Br
    Global_PacketCount_1 dd ?               ; DATA XREF: .text:00415ED7w
                                            ; HAPINET_PacketStatistics+16r ...
    dword_511C38 dd ?                       ; DATA XREF: sub_415FA0+68w
                                            ; sub_415FA0+185r
    dword_511C3C dd ?                       ; DATA XREF: sub_415FA0+79w
                                            ; sub_415FA0+18Cr
    dword_511C40 dd ?                       ; DATA XREF: sub_415FA0+1Er
                                            ; sub_415FA0+47w
    dword_511C44 dd ?                       ; DATA XREF: sub_415FA0+2Er
                                            ; sub_415FA0+62w
    Global_PacketCount_2 dd ?               ; DATA XREF: .text:00415EE3w
                                            ; HAPINET_PacketStatistics+36r ...
    dword_511C4C dd ?                       ; DATA XREF: sub_415FA0+E5w
                                            ; sub_415FA0+178r
    Global_PacketSumSize_2 dd ?             ; DATA XREF: .text:00415EE9w
                                            ; HAPINET_PacketStatistics+3Cr ...
    dd ?
    dword_511C58 dd ?                       ; DATA XREF: sub_415EF0+3Cr
                                            ; sub_415EF0+44w ...
    dd ?
    dword_511C60 dd ?                       ; DATA XREF: .text:00415EC2w
                                            ; sub_417570+37w ...
    dword_511C64 dd 57h dup(?)              ; DATA XREF: .text:00415EAFo
                                            ; sub_4161F0+Co ...
    dword_511DC0 dd ?                       ; DATA XREF: sub_415FA0+161w
                                            ; sub_415FA0+171r
    dword_511DC4 dd ?                       ; DATA XREF: sub_415FA0+136w
                                            ; sub_415FA0+17Er
    dword_511DC8 dd ?                       ; DATA XREF: HAPINET_PacketStatistics+8w
                                            ; sub_415FA0+5Cr
    dword_511DCC dd ?                       ; DATA XREF: sub_415FA0+80r
                                            ; sub_415FA0+B1w
    dword_511DD0 dd ?                       ; DATA XREF: .text:00416DD4w
                                            ; sub_417F60+A9r ...
    dword_511DD4 dd ?                       ; DATA XREF: .text:00416DE9w
                                            ; sub_417F60+B4r
    dword_511DD8 dd ?                       ; DATA XREF: sub_415FA0+6r
                                            ; sub_415FA0+19w
    dword_511DDC dd ?                       ; DATA XREF: sub_416150+6r
                                            ; sub_416150+21w
    dword_511DE0 dd ?                       ; DATA XREF: sub_41D4B0+4w
                                            ; sub_41D6A0+4Ar
    dword_511DE4 dd ?                       ; DATA XREF: sub_41D6A0+95w
                                            ; sub_41D8B0r
    ; char *TAdynmemStructPtr
    TAdynmemStructPtr dd ?                  ; DATA XREF: sub_401070+13r
                                            ; sub_401360+DBr ...
    dword_511DEC dd ?                       ; DATA XREF: .text:0041FE20w
                                            ; .text:0041FE3Ar ...
    dword_511DF0 dd 64h dup(?)              ; DATA XREF: sub_420620+2F1o
                                            ; sub_420B00+7o ...
    dword_511F80 dd 4 dup(?)                ; DATA XREF: .text:004205F0o
                                            ; .text:00420610o ...
    dword_511F90 dd ?                       ; DATA XREF: sub_420620+3Fw
    dword_511F94 dd ?                       ; DATA XREF: sub_420620+49w
    dword_511F98 dd ?                       ; DATA XREF: sub_420620+4Fw
    dword_511F9C dd ?                       ; DATA XREF: sub_420620+59w
                                            ; sub_420620+D5r
    dword_511FA0 dd ?                       ; DATA XREF: sub_420620+5Ew
                                            ; sub_420620+E5r
    dword_511FA4 dd ?                       ; DATA XREF: sub_420620+68w
                                            ; sub_420620+DDr
    dword_511FA8 dd ?                       ; DATA XREF: sub_420620+72w
                                            ; sub_420620+151r
    dword_511FAC dd ?                       ; DATA XREF: sub_420620+77w
                                            ; sub_420620+161r
    dword_511FB0 dd ?                       ; DATA XREF: sub_420620+81w
                                            ; sub_420620+159r
    dword_511FB4 dd ?                       ; DATA XREF: sub_4222E0+25w
                                            ; sub_4222E0+2Cw ...
    ; char byte_511FB8
    byte_511FB8 db ?                        ; DATA XREF: sub_425730+Ao
                                            ; .text:00425751o ...
    dd 3Fh dup(?)
    align 4
    dword_5120B8 dd ?                       ; DATA XREF: sub_428730+3o
                                            ; sub_4287B0+8o ...
    dword_5120BC dd ?                       ; DATA XREF: .text:0042676Fr
                                            ; .text:0042882Dr ...
    dword_5120C0 dd 58h dup(?)              ; DATA XREF: .text:00426484o
                                            ; .text:004287DEo ...
    dword_512220 dd ?                       ; DATA XREF: sub_4288D0+12Ar
                                            ; sub_4288D0+147o
    ; int dword_512224
    dword_512224 dd ?                       ; DATA XREF: sub_4288D0+139r
    dd 8 dup(?)
    dword_512248 dd 2 dup(?)                ; DATA XREF: sub_428730+68o
    dword_512250 dd 0Eh dup(?)              ; DATA XREF: .text:004264C5o
                                            ; .text:00428818o ...
    dword_512288 dd ?                       ; DATA XREF: .text:00426BCFr
    dword_51228C dd ?                       ; DATA XREF: .text:00426684r
                                            ; .text:0042669Aw
    dword_512290 dd ?                       ; DATA XREF: .text:0042674Dr
                                            ; .text:0042675Bw
    dword_512294 dd ?                       ; DATA XREF: .text:0042670Ar
                                            ; .text:00426747w
    ; int dword_512298
    dword_512298 dd ?                       ; DATA XREF: .text:00425BA3r
                                            ; sub_425D80+14r ...
    dword_51229C dd ?                       ; DATA XREF: .text:0042665Br
                                            ; .text:0042667Ew
    dword_5122A0 dd ?                       ; DATA XREF: sub_42A8D0+8Bw
                                            ; sub_42A8D0+93w ...
    dword_5122A4 dd ?                       ; DATA XREF: sub_42A8D0+A5r
                                            ; sub_42A8D0+F3w ...
    dword_5122A8 dd ?                       ; DATA XREF: sub_42A8D0+5Dw
                                            ; sub_42A8D0+988w
    dd ?
    byte_5122B0 db ?                        ; DATA XREF: sub_436860+26Cr
                                            ; sub_436860+27Cw
    align 4
    ; size_t dword_5122B4
    dword_5122B4 dd ?                       ; DATA XREF: sub_436C30+4A7w
                                            ; sub_436C30+4ADr ...
    byte_5122B8 db ?                        ; DATA XREF: sub_436C30+484r
                                            ; sub_436C30+494w
    dd ?
    align 4
    byte_5122C0 db ?                        ; DATA XREF: .text:00434A3Aw
                                            ; sub_4373A0+192o
    align 4
    dword_5122C4 dd ?                       ; DATA XREF: .text:00434A41w
                                            ; .text:00434A61r ...
    dword_5122C8 dd ?                       ; DATA XREF: .text:00434A46w
                                            ; .text:00434A68r ...
    dword_5122CC dd ?                       ; DATA XREF: .text:00434A4Bw
                                            ; .text:00434A9Cw
    ; size_t dword_5122D0
    dword_5122D0 dd ?                       ; DATA XREF: sub_436860+28Bw
                                            ; sub_436860+291r
    ; int dword_5122D4
    dword_5122D4 dd ?                       ; DATA XREF: sub_434B90r
                                            ; sub_434B90+16w ...
    dword_5122D8 dd ?                       ; DATA XREF: sub_434B90+21w
                                            ; sub_434BF0+28r ...
    dword_5122DC dd ?                       ; DATA XREF: sub_434B90+27w
                                            ; sub_434BF0+49r ...
    dword_5122E0 dd ?                       ; DATA XREF: sub_434B90+2Dw
                                            ; sub_434BF0+32r ...
    dd ?
    ; int dword_5122E8
    dword_5122E8 dd ?                       ; DATA XREF: sub_437CD0+14w
                                            ; sub_437DE0+6r ...
    dd ?
    ; char dword_5122F0
    dword_5122F0 dd 8 dup(?)                ; DATA XREF: sub_437CD0+5o
                                            ; sub_437D60+1Eo
    dword_512310 dd ?                       ; DATA XREF: sub_437D60+32w
                                            ; sub_437DE0+1BDr
    dword_512314 dd ?                       ; DATA XREF: sub_437CD0r
                                            ; sub_437D60+40w ...
    ; int dword_512318
    dword_512318 dd ?                       ; DATA XREF: sub_437CD0+Aw
                                            ; sub_437DE0+27w ...
    ; int dword_51231C
    dword_51231C dd ?                       ; DATA XREF: sub_437DE0+41w
                                            ; sub_437DE0+26Fr ...
    dword_512320 dd ?                       ; DATA XREF: sub_437DE0+110w
                                            ; sub_437DE0+166r ...
    dword_512324 dd ?                       ; DATA XREF: sub_437D60+53w
                                            ; sub_437DE0+22r ...
    dword_512328 dd ?                       ; DATA XREF: sub_437CD0+20w
                                            ; sub_437CD0+33w ...
    ; int dword_51232C
    dword_51232C dd ?                       ; DATA XREF: sub_437D40w sub_437D50w ...
    ; int dword_512330
    dword_512330 dd ?                       ; DATA XREF: sub_437DE0+52w
                                            ; sub_437DE0+136r ...
    dword_512334 dd ?                       ; DATA XREF: sub_437DE0+A3w
                                            ; sub_437DE0+E7r ...
    dword_512338 dd ?                       ; DATA XREF: sub_437D60+68w
                                            ; sub_437DE0+39r ...
    dd ?
    byte_512340 db ?                        ; DATA XREF: .text:0043845Aw
                                            ; sub_43BC90+B9o ...
    align 4
    dword_512344 dd ?                       ; DATA XREF: .text:00438461w
                                            ; .text:00438480r ...
    dword_512348 dd ?                       ; DATA XREF: .text:00438466w
                                            ; .text:00438495w ...
    dword_51234C dd ?                       ; DATA XREF: .text:0043846Bw
                                            ; .text:0043849Aw ...
    dd 2 dup(?)
    dword_512358 dd ?                       ; DATA XREF: sub_42D2E0+4Co
                                            ; sub_440420+9o ...
    db 2 dup(?)
    dword_51235E dd 4 dup(?)                ; DATA XREF: .text:00440233o
    align 4
    dword_512370 dd 0FAh dup(?)             ; DATA XREF: sub_440940+29o
                                            ; sub_440A00+2o
    byte_512758 db ?                        ; DATA XREF: sub_42D2E0+C4o
                                            ; .text:00440290r ...
    dd ?
    align 4
    dword_512760 dd ?                       ; DATA XREF: sub_4455B0+9Aw
    ; int dword_512764
    dword_512764 dd ?                       ; DATA XREF: sub_4455B0+Br
                                            ; Battleroom_Unknown1+147w
    dword_512768 dd ?                       ; DATA XREF: sub_44C0D0+21r
                                            ; sub_44C0D0+4Dw ...
    dword_51276C dd ?                       ; DATA XREF: sub_4455B0+A6w
    dword_512770 dd ?                       ; DATA XREF: sub_440940+A2o
                                            ; sub_440A00+2Eo ...
    dword_512774 dd ?                       ; DATA XREF: sub_442380+16w
    dword_512778 dd ?                       ; DATA XREF: sub_441C30+2CAw
    dword_51277C dd ?                       ; DATA XREF: sub_441C30+2D4w
    dword_512780 dd ?                       ; DATA XREF: sub_441C30+2DEw
    dd ?
    dword_512788 dd 10h dup(?)              ; DATA XREF: sub_4436E0+2Eo
                                            ; sub_4436E0+55o
    dword_5127C8 dd ?                       ; DATA XREF: sub_4441A0+1A0r
                                            ; .text:0044473Fo
    dword_5127CC dd 6Bh dup(?)              ; DATA XREF: sub_44474E+59o
    dword_512978 dd ?                       ; DATA XREF: sub_44C0D0+3Ew
                                            ; sub_44C0D0+CFr ...
    dword_51297C dd ?                       ; DATA XREF: sub_44C0D0+39w
                                            ; sub_44C0D0+114r ...
    ; int dword_512980
    dword_512980 dd ?                       ; DATA XREF: sub_441C30+8Br
                                            ; sub_442A30+1Er ...
    dword_512984 dd ?                       ; DATA XREF: sub_443070+6Bw
                                            ; .text:00443229w ...
    ; int dword_512988
    dword_512988 dd ?                       ; DATA XREF: sub_4426E0+Cr
                                            ; sub_4426E0+36r ...
    ; int dword_51298C
    dword_51298C dd ?                       ; DATA XREF: sub_4426E0+1r
                                            ; sub_4426E0+73r ...
    ; int dword_512990
    dword_512990 dd ?                       ; DATA XREF: sub_444CB0+60r
                                            ; sub_444CB0+72w ...
    dword_512994 dd ?                       ; DATA XREF: sub_4455B0+356w
                                            ; sub_447B10+45w ...
    dd 3 dup(?)
    dword_5129A4 dd ?                       ; DATA XREF: .text:0044AC8Fr
                                            ; .text:0044ACCAr ...
    dword_5129A8 dd ?                       ; DATA XREF: .text:0044AF4Er
                                            ; .text:0044AF60w
    ; int dword_5129AC
    dword_5129AC dd ?                       ; DATA XREF: .text:0044B100r
                                            ; .text:0044B12Ew ...
    ; int dword_5129B0
    dword_5129B0 dd ?                       ; DATA XREF: .text:0044B112r
                                            ; .text:0044B124w ...
    ; void *dword_5129B4
    dword_5129B4 dd ?                       ; DATA XREF: sub_44B140+9Br
                                            ; sub_44B230+69r ...
    ; int dword_5129B8
    dword_5129B8 dd ?                       ; DATA XREF: sub_44C0D0+33r
                                            ; sub_44C420+29r ...
    dd ?
    dword_5129C0 dd ?                       ; DATA XREF: sub_44C7E0+623w
    ; int dword_5129C4
    dword_5129C4 dd ?                       ; DATA XREF: sub_44C420+118r
                                            ; sub_44C420+330r ...
    dword_5129C8 dd ?                       ; DATA XREF: .text:0044C249r
                                            ; .text:0044C259w
    dd ?
    dword_5129D0 dd ?                       ; DATA XREF: .text:0044F7F0w
                                            ; .text:0044F860r ...
    dword_5129D4 dd ?                       ; DATA XREF: .text:0044F7F5w
    dword_5129D8 dd ?                       ; DATA XREF: .text:0044F800w
    dword_5129DC dd ?                       ; DATA XREF: .text:0044F806w
    dword_5129E0 dd ?                       ; DATA XREF: .text:0044F814w
                                            ; .text:0044F86Br
    dword_5129E4 dd ?                       ; DATA XREF: .text:0044F838w
                                            ; .text:0044F887r
    dword_5129E8 dd ?                       ; DATA XREF: .text:0044F826w
                                            ; .text:0044F879r
    byte_5129EC db ?                        ; DATA XREF: .text:0044F83Dw
    dword_5129ED dd 0                       ; DATA XREF: .text:0044F843w
    dword_5129F1 dd ?                       ; DATA XREF: .text:0044F84Ew
                                            ; .text:004611A3w ...
    align 4
    dword_5129F8 dd ?                       ; DATA XREF: .text:0044F730w
                                            ; .text:0044F7A0r ...
    dword_5129FC dd ?                       ; DATA XREF: .text:0044F735w
    dword_512A00 dd ?                       ; DATA XREF: .text:0044F740w
    dword_512A04 dd ?                       ; DATA XREF: .text:0044F746w
    dword_512A08 dd ?                       ; DATA XREF: .text:0044F754w
                                            ; .text:0044F7ABr
    dword_512A0C dd ?                       ; DATA XREF: .text:0044F778w
                                            ; .text:0044F7C7r
    dword_512A10 dd ?                       ; DATA XREF: .text:0044F766w
                                            ; .text:0044F7B9r
    byte_512A14 db ?                        ; DATA XREF: .text:0044F77Dw
    dword_512A15 dd ?                       ; DATA XREF: .text:0044F783w
    dword_512A19 dd ?                       ; DATA XREF: .text:0044F78Ew
    align 4
    dword_512A20 dd ?                       ; DATA XREF: .text:0044FDA5r
    dd ?
    dword_512A28 dd ?                       ; DATA XREF: sub_451FD0+98w
    dword_512A2C dd ?                       ; DATA XREF: sub_451FD0+336w
    dd ?
    dword_512A34 dd ?                       ; DATA XREF: sub_451FD0+B2w
    dword_512A38 dd ?                       ; DATA XREF: sub_451FD0+C8w
    dword_512A3C dd ?                       ; DATA XREF: sub_451FD0+DEw
    dword_512A40 dd ?                       ; DATA XREF: sub_451FD0+F4w
    dword_512A44 dd ?                       ; DATA XREF: sub_451FD0+10Ew
    dword_512A48 dd ?                       ; DATA XREF: sub_451FD0+124w
    dword_512A4C dd ?                       ; DATA XREF: sub_451FD0+133w
    dword_512A50 dd ?                       ; DATA XREF: sub_451FD0+142w
    dword_512A54 dd ?                       ; DATA XREF: sub_451FD0+151w
    dword_512A58 dd ?                       ; DATA XREF: sub_451FD0+160w
    dword_512A5C dd ?                       ; DATA XREF: sub_451FD0+16Bw
    dword_512A60 dd ?                       ; DATA XREF: sub_451FD0+17Aw
    dword_512A64 dd ?                       ; DATA XREF: sub_451FD0+17Fw
    dword_512A68 dd ?                       ; DATA XREF: sub_451FD0+18Aw
    dword_512A6C dd ?                       ; DATA XREF: sub_451FD0+199w
    dword_512A70 dd ?                       ; DATA XREF: sub_451FD0+1AEw
    dword_512A74 dd ?                       ; DATA XREF: sub_451FD0+1B9w
    dword_512A78 dd ?                       ; DATA XREF: sub_451FD0+1CEw
    dword_512A7C dd ?                       ; DATA XREF: sub_451FD0+1D9w
    dword_512A80 dd ?                       ; DATA XREF: sub_451FD0+1EAw
    dword_512A84 dd ?                       ; DATA XREF: sub_451FD0+1FBw
    dword_512A88 dd ?                       ; DATA XREF: sub_451FD0+232w
    dword_512A8C dd ?                       ; DATA XREF: sub_451FD0+20Cw
    dword_512A90 dd ?                       ; DATA XREF: sub_451FD0+21Dw
    dword_512A94 dd ?                       ; DATA XREF: sub_451FD0+247w
    dword_512A98 dd ?                       ; DATA XREF: sub_451FD0+29Ew
    dword_512A9C dd ?                       ; DATA XREF: sub_451FD0+2AFw
    dword_512AA0 dd ?                       ; DATA XREF: sub_451FD0+2C4w
    dword_512AA4 dd ?                       ; DATA XREF: sub_451FD0+2D9w
    dword_512AA8 dd ?                       ; DATA XREF: sub_451FD0+2EAw
    dword_512AAC dd ?                       ; DATA XREF: sub_451FD0+27Cw
    dword_512AB0 dd ?                       ; DATA XREF: sub_451FD0+28Dw
    dword_512AB4 dd ?                       ; DATA XREF: sub_451FD0+252w
    dword_512AB8 dd ?                       ; DATA XREF: sub_451FD0+267w
    dword_512ABC dd ?                       ; DATA XREF: sub_451FD0+2FFw
    dword_512AC0 dd ?                       ; DATA XREF: sub_451FD0+314w
    dword_512AC4 dd ?                       ; DATA XREF: sub_451FD0+325w
    dword_512AC8 dd ?                       ; DATA XREF: sub_451FD0+347w
    dd ?
    dword_512AD0 dd ?                       ; DATA XREF: sub_451FD0+119w
    dd ?
    word_512AD8 dw ?                        ; DATA XREF: sub_463790+1A1r
                                            ; sub_463790+289r ...
    align 4
    dword_512ADC dd ?                       ; DATA XREF: sub_451FD0+Bo
    dword_512AE0 dd ?                       ; DATA XREF: sub_451FD0+8Ew
    dword_512AE4 dd ?                       ; DATA XREF: sub_451FD0+330w
    dd ?
    dword_512AEC dd ?                       ; DATA XREF: sub_451FD0+A8w
    dword_512AF0 dd ?                       ; DATA XREF: sub_451FD0+C2w
    dword_512AF4 dd ?                       ; DATA XREF: sub_451FD0+D8w
    dword_512AF8 dd ?                       ; DATA XREF: sub_451FD0+EEw
    dword_512AFC dd ?                       ; DATA XREF: sub_451FD0+104w
    dword_512B00 dd ?                       ; DATA XREF: sub_451FD0+11Ew
    dword_512B04 dd ?                       ; DATA XREF: sub_451FD0+129w
    dword_512B08 dd ?                       ; DATA XREF: sub_451FD0+138w
    dword_512B0C dd ?                       ; DATA XREF: sub_451FD0+147w
    dword_512B10 dd ?                       ; DATA XREF: sub_451FD0+156w
    dword_512B14 dd ?                       ; DATA XREF: sub_451FD0+165w
    dword_512B18 dd ?                       ; DATA XREF: sub_451FD0+170w
    dword_512B1C dd ?                       ; DATA XREF: sub_451FD0+4Dw
    dword_512B20 dd ?                       ; DATA XREF: sub_451FD0+184w
    dword_512B24 dd ?                       ; DATA XREF: sub_451FD0+18Fw
    dword_512B28 dd ?                       ; DATA XREF: sub_451FD0+1A4w
    dword_512B2C dd ?                       ; DATA XREF: sub_451FD0+1B3w
    dword_512B30 dd ?                       ; DATA XREF: sub_451FD0+1C4w
    dword_512B34 dd ?                       ; DATA XREF: sub_451FD0+1D3w
    dword_512B38 dd ?                       ; DATA XREF: sub_451FD0+1E4w
    dword_512B3C dd ?                       ; DATA XREF: sub_451FD0+1F5w
    dword_512B40 dd ?                       ; DATA XREF: sub_451FD0+228w
    dword_512B44 dd ?                       ; DATA XREF: sub_451FD0+206w
    dword_512B48 dd ?                       ; DATA XREF: sub_451FD0+217w
    dword_512B4C dd ?                       ; DATA XREF: sub_451FD0+23Dw
    dword_512B50 dd ?                       ; DATA XREF: sub_451FD0+298w
    dword_512B54 dd ?                       ; DATA XREF: sub_451FD0+2A9w
    dword_512B58 dd ?                       ; DATA XREF: sub_451FD0+2BAw
    dword_512B5C dd ?                       ; DATA XREF: sub_451FD0+2CFw
    dword_512B60 dd ?                       ; DATA XREF: sub_451FD0+2E4w
    dword_512B64 dd ?                       ; DATA XREF: sub_451FD0+272w
    dword_512B68 dd ?                       ; DATA XREF: sub_451FD0+287w
    dword_512B6C dd ?                       ; DATA XREF: sub_451FD0+24Cw
    dword_512B70 dd ?                       ; DATA XREF: sub_451FD0+25Dw
    dword_512B74 dd ?                       ; DATA XREF: sub_451FD0+2F5w
    dword_512B78 dd ?                       ; DATA XREF: sub_451FD0+30Aw
    dword_512B7C dd ?                       ; DATA XREF: sub_451FD0+31Fw
    dword_512B80 dd ?                       ; DATA XREF: sub_451FD0+341w
    dd ?
    dword_512B88 dd ?                       ; DATA XREF: sub_451FD0+113w
    dd ?
    dword_512B90 dd ?                       ; DATA XREF: sub_451DF0+146o
                                            ; sub_451DF0+16Fr ...
    dd 0Bh dup(?)
    byte_512BC0 db ?                        ; DATA XREF: Network_Process+A18r
                                            ; Network_Process+A35r ...
    dd ?
    align 4
    dword_512BC8 dd ?                       ; DATA XREF: sub_451FD0+A2w
    dword_512BCC dd ?                       ; DATA XREF: sub_451FD0+33Bw
    dd ?
    dword_512BD4 dd ?                       ; DATA XREF: sub_451FD0+BCw
    dword_512BD8 dd ?                       ; DATA XREF: sub_451FD0+D2w
    dword_512BDC dd ?                       ; DATA XREF: sub_451FD0+E8w
    dword_512BE0 dd ?                       ; DATA XREF: sub_451FD0+FEw
    dword_512BE4 dd ?                       ; DATA XREF: sub_451FD0+17w
    dword_512BE8 dd ?                       ; DATA XREF: sub_451FD0+23w
    dword_512BEC dd ?                       ; DATA XREF: sub_451FD0+29w
    dword_512BF0 dd ?                       ; DATA XREF: sub_451FD0+2Fw
    dword_512BF4 dd ?                       ; DATA XREF: sub_451FD0+35w
    dword_512BF8 dd ?                       ; DATA XREF: sub_451FD0+3Bw
    dword_512BFC dd ?                       ; DATA XREF: sub_451FD0+41w
    dword_512C00 dd ?                       ; DATA XREF: sub_451FD0+47w
    dword_512C04 dd ?                       ; DATA XREF: sub_451FD0+53w
    dword_512C08 dd ?                       ; DATA XREF: sub_451FD0+59w
    dword_512C0C dd ?                       ; DATA XREF: sub_451FD0+19Ew
    dword_512C10 dd ?                       ; DATA XREF: sub_451FD0+5Fw
    dword_512C14 dd ?                       ; DATA XREF: sub_451FD0+1BEw
    dword_512C18 dd ?                       ; DATA XREF: sub_451FD0+65w
    dword_512C1C dd ?                       ; DATA XREF: sub_451FD0+1DEw
    dword_512C20 dd ?                       ; DATA XREF: sub_451FD0+1EFw
    dword_512C24 dd ?                       ; DATA XREF: sub_451FD0+200w
    dword_512C28 dd ?                       ; DATA XREF: sub_451FD0+237w
    dword_512C2C dd ?                       ; DATA XREF: sub_451FD0+211w
    dword_512C30 dd ?                       ; DATA XREF: sub_451FD0+222w
    dd ?
    dword_512C38 dd ?                       ; DATA XREF: sub_451FD0+2A3w
    dword_512C3C dd ?                       ; DATA XREF: sub_451FD0+2B4w
    dword_512C40 dd ?                       ; DATA XREF: sub_451FD0+2C9w
    dword_512C44 dd ?                       ; DATA XREF: sub_451FD0+2DEw
    dword_512C48 dd ?                       ; DATA XREF: sub_451FD0+2EFw
    dword_512C4C dd ?                       ; DATA XREF: sub_451FD0+281w
    dword_512C50 dd ?                       ; DATA XREF: sub_451FD0+292w
    dword_512C54 dd ?                       ; DATA XREF: sub_451FD0+257w
    dword_512C58 dd ?                       ; DATA XREF: sub_451FD0+26Cw
    dword_512C5C dd ?                       ; DATA XREF: sub_451FD0+304w
    dword_512C60 dd ?                       ; DATA XREF: sub_451FD0+319w
    dword_512C64 dd ?                       ; DATA XREF: sub_451FD0+32Aw
    dword_512C68 dd ?                       ; DATA XREF: sub_451FD0+34Cw
    dd ?
    dword_512C70 dd ?                       ; DATA XREF: sub_451FD0+1Dw
    ; int dword_512C74
    dword_512C74 dd ?                       ; DATA XREF: .text:0045368Fr
                                            ; .text:004536D8r ...
    dword_512C78 dd ?                       ; DATA XREF: .text:0045366Ar
                                            ; .text:0045367Aw
    dword_512C7C dd ?                       ; DATA XREF: sub_453C20+27w
                                            ; sub_453C20+55r ...
    dword_512C80 dd ?                       ; DATA XREF: sub_443FF0+17r
                                            ; sub_443FF0+4Ew ...
    dword_512C84 dd ?                       ; DATA XREF: sub_442050+19r
                                            ; .text:004422E0r ...
    dd ?
    dword_512C8C dd ?                       ; DATA XREF: sub_451640+3Br
    dd ?
    dword_512C94 dd ?                       ; DATA XREF: sub_461020r
    byte_512C98 db ?                        ; DATA XREF: .text:004577CAr
                                            ; .text:004577D9o ...
    dd 3 dup(?)
    align 4
    ; char byte_512CA8
    byte_512CA8 db ?                        ; DATA XREF: WriteRegistrySettings_1+97Fr
                                            ; WriteRegistrySettings_1+98Fo ...
    dd 0Fh dup(?)
    align 4
    byte_512CE8 db ?                        ; DATA XREF: Battleroom_Unknown1+909r
                                            ; Battleroom_Unknown1+918o
    dd 0Fh dup(?)
    align 4
    ; const CHAR String2
    String2 db ?                            ; DATA XREF: sub_443FF0+15Ar
                                            ; sub_443FF0+171o ...
    dd 7 dup(?)
    align 4
    ; char byte_512D48
    byte_512D48 db ?                        ; DATA XREF: WriteRegistrySettings_1+919r
                                            ; WriteRegistrySettings_1+929o ...
    dd 7 dup(?)
    align 4
    dword_512D68 dd ?                       ; DATA XREF: Battleroom_Unknown1+1F2r
    dword_512D6C dd ?                       ; DATA XREF: Battleroom_Unknown1+1CEr
                                            ; Battleroom_Unknown1+1E4r
    dword_512D70 dd ?                       ; DATA XREF: Battleroom_Unknown1+285r
    dword_512D74 dd ?                       ; DATA XREF: Battleroom_Unknown1+292r
    dword_512D78 dd ?                       ; DATA XREF: Battleroom_Unknown1+21Ar
    dword_512D7C dd ?                       ; DATA XREF: Battleroom_Unknown1+29Fr
    dword_512D80 dd ?                       ; DATA XREF: Battleroom_Unknown1+2DBr
    dword_512D84 dd ?                       ; DATA XREF: Battleroom_Unknown1+308r
    dword_512D88 dd ?                       ; DATA XREF: Battleroom_Unknown1+335r
    dword_512D8C dd ?                       ; DATA XREF: Battleroom_Unknown1+363r
    ; char byte_512D90
    byte_512D90 db ?                        ; DATA XREF: sub_442050+10r
                                            ; sub_442050+25w ...
    dd 0Fh dup(?)
    db 2 dup(?)
    byte_512DCF db ?                        ; DATA XREF: sub_45B250+7Ar
                                            ; sub_45B490+5Fr ...
    ; CHAR Filename
    Filename db ?                           ; DATA XREF: sub_45B250+3Dr
                                            ; sub_45B250+4Fo ...
    dd 40h dup(?)
    align 4
    byte_512ED4 db ?                        ; DATA XREF: sub_45B250+64w
                                            ; sub_45B490+4Dw ...
    dd 4 dup(?)
    align 4
    dword_512EE8 dd ?                       ; DATA XREF: sub_45B660r
                                            ; sub_45B670+24w ...
    ; HMODULE hModule
    hModule dd ?                            ; DATA XREF: sub_45B250+DDr
                                            ; sub_45B250+F5w ...
    dword_512EF0 dd ?                       ; DATA XREF: sub_45F8C0+Ar
                                            ; .text:0045FB7Dw ...
    dd ?
    dword_512EF8 dd ?                       ; DATA XREF: sub_45FFB0+12Dr
                                            ; sub_45FFB0+174o ...
    dd 5 dup(?)
    dword_512F10 dd ?                       ; DATA XREF: sub_45FFB0+EAr
                                            ; sub_45FFB0+120r ...
    dword_512F14 dd ?                       ; DATA XREF: sub_45FFB0+44r
                                            ; sub_45FFB0+8Cr ...
    dword_512F18 dd 5 dup(?)                ; DATA XREF: .text:0045CDF2o
                                            ; sub_460160+FAo
    dword_512F2C dd ?                       ; DATA XREF: .text:0045CA9Fr
                                            ; .text:0045CD98r ...
    dd 2 dup(?)
    byte_512F38 db ?                        ; DATA XREF: sub_45CAE0+7r
                                            ; sub_45CAE0+2Ar ...
    align 2
    dword_512F3A dd ?                       ; DATA XREF: sub_45CAE0+D8r
    dword_512F3E dd ?                       ; DATA XREF: sub_45C820+5r
    dword_512F42 dd ?                       ; DATA XREF: .text:0045C955r
                                            ; .text:0045CC5Br ...
    byte_512F46 db ?                        ; DATA XREF: .text:0045C9A2r
                                            ; .text:0045C9C9r ...
    align 4
    byte_512F48 db ?                        ; DATA XREF: .text:0045C97Ar
                                            ; .text:0045CC7Fr ...
    byte_512F49 db ?                        ; DATA XREF: sub_45C820+CFr
                                            ; .text:0045CAB0r ...
    byte_512F4A db ?                        ; DATA XREF: .text:0045CAC1r
                                            ; .text:0045CDBBr ...
    byte_512F4B db ?                        ; DATA XREF: sub_45C820+18r
                                            ; sub_45C820+3Br ...
    db ?
    dword_512F4D dd ?                       ; DATA XREF: sub_45CAE0+F2r
    dword_512F51 dd ?                       ; DATA XREF: sub_45CAE0+103r
    dword_512F55 dd ?                       ; DATA XREF: .text:0045CA55r
                                            ; .text:0045CD4Fr ...
    dword_512F59 dd ?                       ; DATA XREF: .text:0045CAD3r
                                            ; .text:0045CDCCr ...
    dd 3 dup(?)
    db 2 dup(?)
    word_512F6B dw ?                        ; DATA XREF: .text:0045CE02r
                                            ; .text:0045CE16w ...
    dword_512F6D dd ?                       ; DATA XREF: .text:0045CA66r
                                            ; .text:0045CA7Ar ...
    dword_512F71 dd ?                       ; DATA XREF: .text:0045CA8Dr
                                            ; .text:0045CD87r ...
    byte_512F75 db ?                        ; DATA XREF: .text:0045C95Co
                                            ; .text:0045CC61o ...
    dd 18h dup(?)
    db 3 dup(?)
    dword_512FD9 dd ?                       ; DATA XREF: .text:0045C9E4r
                                            ; .text:0045CCE9r ...
    align 4
    dword_512FE0 dd ?                       ; DATA XREF: sub_45C3F0+35r
                                            ; sub_45C3F0+FCr ...
    dword_512FE4 dd ?                       ; DATA XREF: .text:0045FF88w
                                            ; sub_45FFB0r ...
    dword_512FE8 dd ?                       ; DATA XREF: .text:0045FF73r
                                            ; .text:0045FF82w ...
    dword_512FEC dd ?                       ; DATA XREF: sub_45FFB0+10r
                                            ; sub_45FFB0+27w ...
    dword_512FF0 dd ?                       ; DATA XREF: sub_45FFB0+94r
                                            ; sub_45FFB0+9Fw ...
    dword_512FF4 dd ?                       ; DATA XREF: .text:0045FF50r
                                            ; .text:0045FF62r ...
    dword_512FF8 dd ?                       ; DATA XREF: .text:00460607r
                                            ; sub_460680+E5r ...
    dd ?
    dword_513000 dd ?                       ; DATA XREF: sub_4161F0+3Co
                                            ; sub_434BF0+2CDo ...
    dword_513004 dd ?                       ; DATA XREF: sub_460E20+8w
                                            ; sub_461020+47w ...
    dword_513008 dd ?                       ; DATA XREF: sub_451DF0+E5o
                                            ; sub_461020+FDo
    dword_51300C dd ?                       ; DATA XREF: sub_461020+54o
    dword_513010 dd 40Fh dup(?)             ; DATA XREF: sub_460E20+12o
    dword_51404C dd 28AAh dup(?)            ; DATA XREF: sub_461020+107o
    dword_51E2F4 dd ?                       ; DATA XREF: sub_460E20+8Fw
                                            ; sub_4624A0+18Er ...
    dword_51E2F8 dd ?                       ; DATA XREF: sub_460E20+95w
                                            ; sub_4624A0+196r ...
    dword_51E2FC dd ?                       ; DATA XREF: sub_460E20+9Bw
                                            ; sub_460F60+61o
    Global_UnknownFunctionPtr_1 dd 0                                    ; FunctionPtr
                                            ; DATA XREF: HAPINET_GetPacket+3Bo
                                            ; sub_460E20+F7w ...
    db 10h dup(0)                           ; field_4
    dd 0                                    ; field_14
    db 30h dup(0)                           ; field_18
    dd 0                                    ; field_48
    db 1E0h dup(0)                          ; field_4C
    dd 0                                    ; field_22C
    dd 0                                    ; field_230
    dd 0                                    ; field_234
    dd 0                                    ; field_238
    dword_51E53C dd ?                       ; DATA XREF: UpdateDatePlayers+60Dr
                                            ; UpdateDatePlayers+615w
    dword_51E540 dd ?                       ; DATA XREF: sub_467E50+B9r
                                            ; sub_467E50+495w ...
    dword_51E544 dd ?                       ; DATA XREF: PlayerStatusMenu+1Ar
                                            ; PlayerStatusMenu+30w
    _RIReportGameChat dd ?                  ; DATA XREF: LoadReporter+165w
                                            ; RIWrapper_ReportGameChat+84r
    _RIInitializeEx dd ?                    ; DATA XREF: sub_460F60+2Eo
                                            ; LoadReporter+130w ...
    ; int dword_51E550
    dword_51E550 dd ?                       ; DATA XREF: sub_46BCE0+46w
                                            ; sub_46BCE0+85r ...
    _RIGetVersion dd ?                      ; DATA XREF: LoadReporter+115w
                                            ; LoadReporter+1BDr
    _RITerminate dd ?                       ; DATA XREF: LoadReporter+1B1w
                                            ; LoadReporter+1DCr ...
    dd ?
    dword_51E560 dd ?                       ; DATA XREF: RIWrapper_Report+9Aw
                                            ; RIWrapper_Report+D0o ...
    dword_51E564 dd ?                       ; DATA XREF: RIWrapper_Report+A3w
    dword_51E568 dd ?                       ; DATA XREF: RIWrapper_Report+ABw
    dword_51E56C dd ?                       ; DATA XREF: RIWrapper_Report+B4w
    byte_51E570 db ?                        ; DATA XREF: RIWrapper_Report+C1w
    align 4
    ; int dword_51E574
    dword_51E574 dd ?                       ; DATA XREF: sub_46BCE0+16w
                                            ; sub_46BCE0+3Br ...
    _RISetCallbacks dd ?                    ; DATA XREF: LoadReporter+180w
                                            ; LoadReporter+205r
    ; int dword_51E57C
    dword_51E57C dd ?                       ; DATA XREF: sub_46BCE0+2Aw
                                            ; sub_46BCE0+51r ...
    _RIIntervalTimer dd ?                   ; DATA XREF: LoadReporter+19Aw
                                            ; RIWrapper_IntervalTimer+9r
    _RIReport dd ?                          ; DATA XREF: LoadReporter+14Aw
                                            ; RIWrapper_Report+1C7r
    _RIEnable dd ?                          ; DATA XREF: RIWrapper_Enabler
                                            ; LoadReporter+FAw
    ReporterDLLHandle dd ?                  ; DATA XREF: IsReporterDLLLoadedr
                                            ; LoadReporter+C5r ...
    ReporterInterfaceStarted dd ?           ; DATA XREF: LoadReporter+B6w
                                            ; LoadReporter+240r ...
    dword_51E594 dd ?                       ; DATA XREF: RIWrapper_Report+117w
                                            ; RIWrapper_Report+11Cr ...
    dword_51E598 dd ?                       ; DATA XREF: .text:0046CA23r
                                            ; .text:0046CA31w ...
    dword_51E59C dd ?                       ; DATA XREF: .text:0046CA16r
                                            ; .text:0046CA1Cw ...
    dword_51E5A0 dd 1Ah dup(?)              ; DATA XREF: sub_46DF40+9Ao
                                            ; sub_46DF40+A7o
    byte_51E608 db ?                        ; DATA XREF: .text:00419550w
                                            ; .text:00471340r ...
    dd ?
    align 4
    dword_51E610 dd 9 dup(?)                ; DATA XREF: .text:00471357o
                                            ; sub_471430+2Eo ...
    byte_51E634 db ?                        ; DATA XREF: .text:00471CA0r
                                            ; .text:00471CAEw
    dd ?
    align 4
    dword_51E63C dd ?                       ; DATA XREF: sub_476D80+C2w
                                            ; sub_476D80+CCw ...
    word_51E640 dw ?                        ; DATA XREF: sub_478B40+B8o
                                            ; sub_478B40+C2r ...
    dd 2 dup(?)
    align 4
    dword_51E64C dd ?                       ; DATA XREF: sub_476EF0+48w
                                            ; sub_476EF0+11Ar ...
    dword_51E650 dd ?                       ; DATA XREF: sub_476D80+A5w
                                            ; sub_476EF0+33r ...
    dword_51E654 dd ?                       ; DATA XREF: .text:004787DAr
                                            ; .text:004787E5w ...
    dd ?
    dword_51E65C dd ?                       ; DATA XREF: .text:0047794Cr
                                            ; .text:0047795Ew ...
    dword_51E660 dd ?                       ; DATA XREF: .text:004779E0r
                                            ; .text:004779FBw ...
    dd ?
    dword_51E668 dd ?                       ; DATA XREF: .text:00477B16r
                                            ; .text:00477B3Fr ...
    dword_51E66C dd ?                       ; DATA XREF: sub_476EF0+42w
                                            ; sub_476EF0+5Ar
    dword_51E670 dd ?                       ; DATA XREF: .text:004787B1r
                                            ; .text:004787C6w ...
    word_51E674 dw ?                        ; DATA XREF: .text:0047899Fr
                                            ; .text:004789ACw ...
    align 4
    dword_51E678 dd ?                       ; DATA XREF: .text:00478997r
                                            ; .text:004789C5w
    dword_51E67C dd ?                       ; DATA XREF: sub_478B40+B0r
    dword_51E680 dd ?                       ; DATA XREF: sub_478B40+23r
                                            ; sub_478B40+34w
    dword_51E684 dd ?                       ; DATA XREF: sub_47C780r sub_47D2E0+Ew ...
    dword_51E688 dd ?                       ; DATA XREF: sub_47C770r
                                            ; sub_47D2E0+14w ...
    dword_51E68C dd ?                       ; DATA XREF: sub_47ED40+DBw
                                            ; sub_47ED40+E3w ...
    dword_51E690 dd ?                       ; DATA XREF: sub_47ED40+18w
                                            ; sub_47ED40+4Aw ...
    dword_51E694 dd ?                       ; DATA XREF: sub_47ED40+2Dw
                                            ; sub_47ED40+33r ...
    dword_51E698 dd ?                       ; DATA XREF: .text:004172E0r
                                            ; .text:004172EDw ...
    dword_51E69C dd ?                       ; DATA XREF: sub_47F0C0+2Ar
                                            ; sub_47F0C0+96r ...
    byte_51E6A0 db ?                        ; DATA XREF: .text:004814CAw
                                            ; .text:004814F0o ...
    align 4
    dword_51E6A4 dd ?                       ; DATA XREF: .text:004814D1w
    dword_51E6A8 dd ?                       ; DATA XREF: .text:004814D6w
    dword_51E6AC dd ?                       ; DATA XREF: .text:004814DBw
    byte_51E6B0 db ?                        ; DATA XREF: .text:004889DAw
                                            ; sub_488C50+A9o
    align 4
    dword_51E6B4 dd ?                       ; DATA XREF: .text:004889E1w
                                            ; .text:00488A01r ...
    dword_51E6B8 dd ?                       ; DATA XREF: .text:004889E6w
                                            ; .text:00488A08r ...
    dword_51E6BC dd ?                       ; DATA XREF: .text:004889EBw
                                            ; .text:00488A3Cw
    dword_51E6C0 dd ?                       ; DATA XREF: sub_488BE0w
                                            ; sub_488BF0+4Ew
    dword_51E6C4 dd ?                       ; DATA XREF: sub_490360+1Cr
                                            ; sub_490360+4Cw ...
    dword_51E6C8 dd ?                       ; DATA XREF: sub_497F40+3CFw
                                            ; sub_497F40+6A5r ...
    dword_51E6CC dd ?                       ; DATA XREF: sub_497F40+3DCw
                                            ; sub_497F40+BAFw ...
    ; int dword_51E6D0
    dword_51E6D0 dd ?                       ; DATA XREF: sub_4934B0+BEr
                                            ; sub_4936F0+1F3o ...
    dd 9 dup(?)
    dword_51E6F8 dd 6 dup(?)                ; DATA XREF: sub_491EC0+107o
                                            ; sub_491EC0+111o
    dword_51E710 dd ?                       ; DATA XREF: sub_4917D0+231o
                                            ; sub_494E70+151w ...
    dd 1Dh dup(?)
    dword_51E788 dd 22h dup(?)              ; DATA XREF: sub_493BF0+119o
                                            ; sub_493BF0+3FEo ...
    dword_51E810 dd ?                       ; DATA XREF: sub_4948B0+18w
                                            ; sub_4948E0+37r ...
    dword_51E814 dd ?                       ; DATA XREF: sub_497F40+3C9w
    word_51E818 dw ?                        ; DATA XREF: sub_497F40+3D5w
    dd ?
    align 4
    dword_51E820 dd ?                       ; DATA XREF: sub_497F40+3B9w
                                            ; sub_497F40+84Er ...
    word_51E824 dw ?                        ; DATA XREF: sub_497F40+3BEw
                                            ; sub_497F40+BA7r ...
    align 4
    dword_51E828 dd 8 dup(?)                ; DATA XREF: .text:00490F4Eo
                                            ; .text:00490F67o ...
    dword_51E848 dd ?                       ; DATA XREF: sub_490FE0+E0o
                                            ; sub_490FE0+1D7w
    dword_51E84C dd ?                       ; DATA XREF: sub_490F80+2Dw
                                            ; sub_490FE0+147o ...
    dword_51E850 dd ?                       ; DATA XREF: sub_490FE0+1C6w
    dword_51E854 dd ?                       ; DATA XREF: sub_490FE0+1CBw
    dword_51E858 dd ?                       ; DATA XREF: sub_490FE0+1D1w
    dd 279h dup(?)
    dword_51F240 dd 22h dup(?)              ; DATA XREF: sub_490FE0+192o
    dword_51F2C8 dd ?                       ; DATA XREF: sub_4948B0+Aw
                                            ; sub_4948E0+24r ...
    dword_51F2CC dd ?                       ; DATA XREF: sub_497F40+3ACw
    word_51F2D0 dw ?                        ; DATA XREF: sub_497F40+3B3w
    dd ?
    align 4
    ; int dword_51F2D8
    dword_51F2D8 dd ?                       ; DATA XREF: sub_4917D0+28Ew
                                            ; sub_4948E0+A6r ...
    dword_51F2DC dd ?                       ; DATA XREF: sub_4917D0+286w
                                            ; sub_494E70+6Dr ...
    ; int dword_51F2E0
    dword_51F2E0 dd ?                       ; DATA XREF: sub_491E50r
                                            ; sub_491E50+4Cw ...
    ; int dword_51F2E4
    dword_51F2E4 dd ?                       ; DATA XREF: sub_491E50+15r
                                            ; sub_491E50+46w ...
    ; int dword_51F2E8
    dword_51F2E8 dd ?                       ; DATA XREF: sub_490FE0+EFo
                                            ; sub_491E50+27r ...
    ; int dword_51F2EC
    dword_51F2EC dd ?                       ; DATA XREF: sub_491E50+39r
                                            ; sub_491E50+5Dw ...
    dword_51F2F0 dd ?                       ; DATA XREF: sub_494050+37r
                                            ; sub_494050+4Cw
    dword_51F2F4 dd ?                       ; DATA XREF: sub_4948E0+Fr
                                            ; sub_4948E0+1Dw
    dword_51F2F8 dd ?                       ; DATA XREF: sub_494E70+36r
                                            ; sub_494E70+166w
    dword_51F2FC dd ?                       ; DATA XREF: sub_494E70+59r
                                            ; sub_494E70+62w ...
    dword_51F300 dd ?                       ; DATA XREF: sub_496790+145r
                                            ; sub_496790+157w
    dword_51F304 dd ?                       ; DATA XREF: .text:00496D3Er
                                            ; .text:00496D4Ew
    dword_51F308 dd ?                       ; DATA XREF: sub_497F40+691r
                                            ; sub_497F40+69Ew
    dd ?
    dword_51F310 dd 3 dup(?)                ; DATA XREF: .text:0049E610o
                                            ; .text:0049E630o
    byte_51F31C db ?                        ; DATA XREF: sub_49E830+1Er
                                            ; sub_49E830+34w
    align 4
    dword_51F320 dd ?                       ; DATA XREF: sub_49E830+BDo
                                            ; sub_49E830+D9o ...
    dword_51F324 dd ?                       ; DATA XREF: sub_49E830+117w
    dword_51F328 dd ?                       ; DATA XREF: sub_49E830+11Fw
    dword_51F32C dd ?                       ; DATA XREF: sub_49E830+13Cw
    dd ?
    dword_51F334 dd ?                       ; DATA XREF: sub_49E830+141w
    dd 32h dup(?)
    dword_51F400 dd ?                       ; DATA XREF: sub_49E830+350r
                                            ; sub_49E830+41Dr
    dd 3 dup(?)
    dword_51F410 dd ?                       ; DATA XREF: sub_49E830+495r
    dd 41h dup(?)
    db 2 dup(?)
    dword_51F51A dd ?                       ; DATA XREF: sub_49E830+ECw
    dword_51F51E dd ?                       ; DATA XREF: sub_49E830+10Bw
    word_51F522 dw ?                        ; DATA XREF: sub_49E830+CDr
                                            ; sub_49E830+D3r ...
    dd 189h dup(?)
    dword_51FB48 dd ?                       ; DATA XREF: sub_49E830+C7r
                                            ; sub_49EE30+285w ...
    dd ?
    ; char byte_51FB50
    byte_51FB50 db ?                        ; DATA XREF: sub_49E830+17Bo
                                            ; sub_49E830+1BDo ...
    dd 0Fh dup(?)
    align 4
    dword_51FB90 dd ?                       ; DATA XREF: sub_49E830+37Ew
                                            ; sub_49E830+3F5r
    dword_51FB94 dd ?                       ; DATA XREF: sub_49E830+43Ar
                                            ; sub_49E830+45Dw
    dd ?
    ; LPCSTR pszSound
    pszSound dd ?                           ; DATA XREF: sub_49F620r
                                            ; .text:0049F66Bw ...
    ; int dword_51FBA0
    dword_51FBA0 dd ?                       ; DATA XREF: .text:0049F64Fr
                                            ; .text:0049F661w ...
    dword_51FBA4 dd ?                       ; DATA XREF: sub_4A1810+8Ar
                                            ; sub_4A1B40+CDr ...
    dword_51FBA8 dd ?                       ; DATA XREF: sub_4ACE50+1B7r
    dword_51FBAC dd ?                       ; DATA XREF: sub_4A6AE0+448r
                                            ; sub_4A6AE0+452w ...
    dword_51FBB0 dd ?                       ; DATA XREF: sub_4A6AE0+432r
                                            ; sub_4A6AE0+443w
    dword_51FBB4 dd ?                       ; DATA XREF: sub_4A9FD0+1A4r
                                            ; sub_4A9FD0+1BBw
    dword_51FBB8 dd ?                       ; DATA XREF: .text:004B22E5r
                                            ; .text:004B22F4w ...
    dword_51FBBC dd ?                       ; DATA XREF: .text:004B22B9r
                                            ; .text:004B22D2w ...
    byte_51FBC0 db ?                        ; DATA XREF: .text:004B22A5w
                                            ; sub_4B2340+3Fo ...
    byte_51FBC1 db ?                        ; DATA XREF: .text:004B229Bw
    align 4
    dword_51FBC4 dd ?                       ; DATA XREF: .text:004B2305w
                                            ; .text:004B2312r ...
    byte_51FBC8 db ?                        ; DATA XREF: .text:004B22AEw
                                            ; sub_4B26F0+5Cr
    align 4
    dword_51FBCC dd ?                       ; DATA XREF: .text:004B230Aw
                                            ; sub_4B2340+3r ...
    dword_51FBD0 dd ?                       ; DATA XREF: .text:004B4F50r
                                            ; .text:004B4F68r ...
    dd ?
    dword_51FBD8 dd ?                       ; DATA XREF: sub_4B63F0+A6w
    dword_51FBDC dd ?                       ; DATA XREF: sub_4B63F0+B0w
    dword_51FBE0 dd ?                       ; DATA XREF: sub_4B62D0+1Ao
                                            ; sub_4B6370+3Co ...
    dword_51FBE4 dd ?                       ; DATA XREF: sub_4B63F0+C0w
    dd 24h dup(?)
    dword_51FC78 dd ?                       ; DATA XREF: sub_4B4FD0+8w
                                            ; sub_4B5CC0+95r
    dword_51FC7C dd ?                       ; DATA XREF: sub_4B4FD0+Dw
                                            ; sub_4B5CC0+9Er
    dword_51FC80 dd ?                       ; DATA XREF: sub_4B62D0+10w
                                            ; sub_4B62D0+28o ...
    dword_51FC84 dd ?                       ; DATA XREF: sub_4B62D0+4Dw
                                            ; sub_4B6370+20r ...
    dword_51FC88 dd ?                       ; DATA XREF: GetRandom+11r
                                            ; GetRandom+57w ...
    dd ?
    dword_51FC90 dd ?                       ; DATA XREF: .text:004B7592w
                                            ; sub_4B78E0+8w ...
    dword_51FC94 dd ?                       ; DATA XREF: .text:004B7597w
                                            ; sub_4B78E0+Dw ...
    db ?
    byte_51FC99 db ?                        ; DATA XREF: .text:004B75AAw
                                            ; sub_4B7620+FAo ...
    db 3 dup(?)
    dword_51FC9D dd ?                       ; DATA XREF: .text:004B75B1w
                                            ; .text:004B75D1r ...
    dword_51FCA1 dd ?                       ; DATA XREF: .text:004B75B6w
                                            ; .text:004B75D8r ...
    dword_51FCA5 dd ?                       ; DATA XREF: .text:004B75BBw
                                            ; .text:004B760Cw
    dd ?
    db 2 dup(?)
    byte_51FCAF db ?                        ; DATA XREF: sub_4BA000+7Ew
    byte_51FCB0 db ?                        ; DATA XREF: sub_4B9ED0+3Er
                                            ; sub_4BA000+5Ew ...
    dd 3Fh dup(?)
    align 4
    dword_51FDB0 dd ?                       ; DATA XREF: sub_4B9ED0+2Br
                                            ; sub_4B9ED0+34w ...
    dd ?
    dword_51FDB8 dd ?                       ; DATA XREF: sub_4C54F0+20r
                                            ; sub_4C54F0+8Fw ...
    dd ?
    ; char byte_51FDC0
    byte_51FDC0 db ?                        ; DATA XREF: sub_4C54F0+Ao
                                            ; sub_4C54F0+B2o ...
    dd 0Fh dup(?)
    align 4
    dword_51FE00 dd ?                       ; DATA XREF: .text:004C5D90r
                                            ; .text:004C5DC0r ...
    dd ?
    dword_51FE08 dd ?                       ; DATA XREF: .text:004C5DA5w
                                            ; sub_4C5E70+10Bw
    byte_51FE0C db ?                        ; DATA XREF: .text:004C5DABw
                                            ; sub_4C5DF0+Fr ...
    dd 0Ch dup(?)
    align 4
    dword_51FE40 dd ?                       ; DATA XREF: .text:004C7244w
                                            ; .text:004C7290r ...
    dd ?
    dword_51FE48 dd ?                       ; DATA XREF: .text:004C7095w
                                            ; .text:004C70A0w ...
    dd 13h dup(?)
    dword_51FE98 dd ?                       ; DATA XREF: .text:004C71F0r
                                            ; .text:004C7228w
    dd ?
    dword_51FEA0 dd ?                       ; DATA XREF: .text:004C70ABw
                                            ; .text:004C70B7w ...
    dd 13h dup(?)
    dword_51FEF0 dd ?                       ; DATA XREF: .text:004C7124w
                                            ; .text:004C714Cr ...
    dword_51FEF4 dd ?                       ; DATA XREF: .text:004C720Aw
                                            ; .text:004C7223w
    dword_51FEF8 dd ?                       ; DATA XREF: .text:004C70D8r
                                            ; .text:004C71F8r
    dword_51FEFC dd ?                       ; DATA XREF: .text:004C70EAw
                                            ; .text:004C7103w
    dword_51FF00 dd ?                       ; DATA XREF: .text:004C70D0r
                                            ; .text:004C7108w
    dword_51FF04 dd ?                       ; DATA XREF: sub_4CAA20+Dw
    dword_51FF08 dd ?                       ; DATA XREF: sub_4CAA20+8w
    dword_51FF0C dd ?                       ; DATA XREF: sub_4C9750r
                                            ; sub_4C9E50+D5w
    dword_51FF10 dd ?                       ; DATA XREF: .text:004CE5E6r
                                            ; .text:004CE5F3w ...
    dword_51FF14 dd ?                       ; DATA XREF: .text:004CE05Fr
                                            ; .text:004CE0D9r ...
    ; HWND hWnd
    hWnd dd ?                               ; DATA XREF: sub_4CE190r
                                            ; sub_4CE190+19r ...
    dd ?
    dword_51FF20 dd ?                       ; DATA XREF: sub_4CE690+1Fw
    dd 9 dup(?)
    dword_51FF48 dd ?                       ; DATA XREF: sub_4CF540+Cw
                                            ; sub_4CF540+1Bw ...
    dd 3 dup(?)
    dword_51FF58 dd ?                       ; DATA XREF: .text:004D06A3r
                                            ; sub_4D06C0+39w
    dd ?
    dword_51FF60 dd 1Ch dup(?)              ; DATA XREF: .text:004D06B1o
                                            ; sub_4D06C0+21o
    dword_51FFD0 dd 406h dup(?)             ; DATA XREF: DoNetworkCompression+14Fo
                                            ; sub_4D1480+CAo ...
    dword_520FE8 dd 0C97h dup(?)            ; DATA XREF: DoNetworkCompression+162o
                                            ; .text:004D1783o
    db 3 dup(?)
    dword_524247 dd 1BEh dup(?)             ; DATA XREF: .data:00511094o
                                            ; .data:005110ACo ...
    db 2 dup(?)
    dword_524941 dd 182h dup(?)             ; DATA XREF: .data:005075DCo
    db 2 dup(?)
    dword_524F4B dd 1C1h dup(?)             ; DATA XREF: .data:00511104o
                                            ; .data:00511114o
    dword_52564F dd 668h dup(?)             ; DATA XREF: .data:005038C0o
    align 4
    dword_526FF0 dd ?                       ; DATA XREF: .text:004D0A10r
                                            ; .text:004D0A1Er ...
    dword_526FF4 dd ?                       ; DATA XREF: .text:004D0A7Fw
                                            ; .text:004D0AB0r ...
    dword_526FF8 dd ?                       ; DATA XREF: DoNetworkCompression+129r
                                            ; sub_4D1480+B1r ...
    Global_NetworkCompressData dd ?         ; DATA XREF: DoNetworkCompression+13Cr
                                            ; sub_4D1480+BBr ...
    dword_527000 dd ?                       ; DATA XREF: sub_4D3DA0+35r
                                            ; sub_4D56E0+5Ar ...
    dd 3Fh dup(?)
    dword_527100 dd ?                       ; DATA XREF: sub_4D3DA0+2Aw
                                            ; sub_4D5810+1ACr
    dd 1Dh dup(?)
    dword_527178 dd ?                       ; DATA XREF: sub_4D3DA0+9Ar
                                            ; sub_4D56E0+79r ...
    dd 3Fh dup(?)
    dword_527278 dd ?                       ; DATA XREF: sub_4D3DA0+F5r
                                            ; sub_4D56E0+86r ...
    dd 3Fh dup(?)
    byte_527378 db 2 dup(?)                 ; DATA XREF: sub_4D3DA0+1B9o
                                            ; sub_4D4590+1C7o ...
    dword_52737A dd 8Fh dup(?)              ; DATA XREF: sub_4D3DA0+12Bo
    dword_5275B6 dd ?                       ; DATA XREF: sub_4D3DA0+13Ao
    dword_5275BA dd 6Fh dup(?)              ; DATA XREF: sub_4D3DA0+146o
    byte_527776 db 2 dup(?)                 ; DATA XREF: sub_4D3DA0+155o
    dword_527778 dd ?                       ; DATA XREF: sub_4D4210+9Dr
                                            ; sub_4D4210+251r ...
    dd 16h dup(?)
    db 2 dup(?)
    dword_5277D6 dd ?                       ; DATA XREF: sub_4D3DA0+175o
    dword_5277DA dd 6 dup(?)                ; DATA XREF: sub_4D3DA0+181o
    align 4
    byte_5277F4 db 2 dup(?)                 ; DATA XREF: sub_4D3DA0+1F6o
    byte_5277F6 db 2 dup(?)                 ; DATA XREF: sub_4D3DA0+190o
    dword_5277F8 dd 1Eh dup(?)              ; DATA XREF: sub_4D3DA0+200o
                                            ; sub_4D4590+1C2o ...
    dword_527870 dd ?                       ; DATA XREF: sub_4D3DA0+81w
                                            ; sub_4D3DA0+D2w ...
    dd 1Dh dup(?)
    dword_5278E8 dd ?                       ; DATA XREF: sub_4D3DA0r
                                            ; sub_4D3DA0+233w
    dd ?
    dword_5278F0 dd ?                       ; DATA XREF: sub_4D72B0+D4o
                                            ; sub_4D72B0+12Br
    dword_5278F4 dd ?                       ; DATA XREF: sub_4D72B0+88o
                                            ; sub_4D72B0+11Cr
    dd 424h dup(?)
    dword_528988 dd ?                       ; DATA XREF: sub_4D72B0+BFw
                                            ; sub_4D72B0+CFo ...
    dword_52898C dd ?                       ; DATA XREF: sub_4D72B0+83o
                                            ; sub_4D72B0+A2w ...
    dword_528990 dd ?                       ; DATA XREF: sub_4D72B0r
                                            ; sub_4D72B0+EDw
    byte_528994 db ?                        ; DATA XREF: sub_4D80D0r
                                            ; sub_4D80D0+18w
    align 4
    dword_528998 dd ?                       ; DATA XREF: sub_4D8260+28o
                                            ; sub_4D8260+3Fr
    byte_52899C db ?                        ; DATA XREF: sub_4D8200+2Do
                                            ; sub_4D8200+44r
    align 4
    byte_5289A0 db ?                        ; DATA XREF: sub_4D8140+29o
                                            ; sub_4D8140+40r
    align 4
    byte_5289A4 db ?                        ; DATA XREF: sub_4D80D0+3Ao
                                            ; sub_4D80D0+51r
    align 4
    byte_5289A8 db ?                        ; DATA XREF: sub_4D8260r
                                            ; sub_4D8260+18w
    align 4
    byte_5289AC db ?                        ; DATA XREF: sub_4D8200r
                                            ; sub_4D8200+21w
    align 4
    byte_5289B0 db ?                        ; DATA XREF: sub_4D8140r
                                            ; sub_4D8140+1Dw
    align 4
    byte_5289B4 db ?                        ; DATA XREF: .text:004D80B0r
                                            ; sub_4D80D0+Dw
    align 4
    byte_5289B8 db ?                        ; DATA XREF: .text:004D80B9w
                                            ; sub_4D80D0+1Er
    align 4
    dword_5289BC dd ?                       ; DATA XREF: sub_4D83C0+49r
                                            ; sub_4D83C0+58r ...
    dword_5289C0 dd ?                       ; DATA XREF: sub_4D8E60+Ar
                                            ; sub_4D8E60+26w
    dword_5289C4 dd ?                       ; DATA XREF: .text:004D9F40w
                                            ; sub_4D9F50r
    byte_5289C8 db ?                        ; DATA XREF: sub_4DA1D0+BBr
                                            ; sub_4DA2E0+40w
    align 4
    byte_5289CC db ?                        ; DATA XREF: sub_4DA1D0+8r
                                            ; sub_4DA1D0+16w
    align 4
    dword_5289D0 dd ?                       ; DATA XREF: sub_4DA860+20w
                                            ; sub_4DACF0+2D2r ...
    dword_5289D4 dd ?                       ; DATA XREF: sub_4DACF0+73r
                                            ; sub_4DACF0+CCr ...
    dword_5289D8 dd ?                       ; DATA XREF: sub_4DA7D0+58r
                                            ; sub_4DA7D0+67w ...
    dword_5289DC dd ?                       ; DATA XREF: sub_4DA7D0+25r
                                            ; sub_4DA7D0+35w ...
    dword_5289E0 dd ?                       ; DATA XREF: sub_4DA8D0+7Er
                                            ; sub_4DA8D0+BBr ...
    dd 2 dup(?)
    byte_5289EC db ?                        ; DATA XREF: sub_4DA780r
                                            ; sub_4DA780+13w
    align 4
    dword_5289F0 dd ?                       ; DATA XREF: sub_4DA860+25w
                                            ; sub_4DACF0+2CDr ...
    byte_5289F4 db ?                        ; DATA XREF: sub_4DB760r
                                            ; sub_4DB760+1Dw
    align 4
    dword_5289F8 dd ?                       ; DATA XREF: sub_4DA7D0+51r
                                            ; sub_4DA7D0+60w ...
    dword_5289FC dd ?                       ; DATA XREF: sub_4DA7D0+46r
                                            ; sub_4DA7D0+4Cw ...
    dword_528A00 dd ?                       ; DATA XREF: sub_4DA860+2Fw
                                            ; sub_4DACF0+10Er ...
    ; int dword_528A04
    dword_528A04 dd ?                       ; DATA XREF: sub_4DA7D0r sub_4DA7D0+Cw ...
    dword_528A08 dd ?                       ; DATA XREF: sub_4DA7D0+11r
                                            ; sub_4DA7D0+19w ...
    dd ?
    dword_528A10 dd ?                       ; DATA XREF: sub_4DC130+4B7r
                                            ; sub_4DC130+4BFw ...
    dd 2 dup(?)
    dword_528A1C dd ?                       ; DATA XREF: sub_4DA7D0+5r
                                            ; sub_4DA7D0+20w ...
    byte_528A20 db ?                        ; DATA XREF: sub_4DB760+29o
                                            ; sub_4DB760+40r
    dd ?
    align 4
    ; struct _RTL_CRITICAL_SECTION CriticalSection
    CriticalSection dd ?                                    ; DebugInfo
                                            ; DATA XREF: sub_4DA780+Eo
                                            ; sub_4DA780+2Co
    dd ?                                    ; LockCount
    dd ?                                    ; RecursionCount
    dd ?                                    ; OwningThread
    dd ?                                    ; LockSemaphore
    dd ?                                    ; SpinCount
    dword_528A40 dd ?                       ; DATA XREF: sub_4DB610r
                                            ; sub_4DB610+130w ...
    dword_528A44 dd ?                       ; DATA XREF: sub_4DA8D0r
                                            ; sub_4DA8D0+FFw ...
    dword_528A48 dd ?                       ; DATA XREF: sub_4DA9F0+1r
                                            ; sub_4DA9F0+2Cw ...
    dword_528A4C dd ?                       ; DATA XREF: sub_4DA8D0+74r
                                            ; sub_4DA8D0+86w
    dword_528A50 dd ?                       ; DATA XREF: sub_4DA8D0+44r
                                            ; sub_4DA8D0+5Fw ...
    dword_528A54 dd ?                       ; DATA XREF: sub_4DB000+CCr
                                            ; sub_4DB1C0+BEr ...
    dword_528A58 dd ?                       ; DATA XREF: sub_4DB610+6Er
                                            ; sub_4DB610+7Dw
    dd ?
    byte_528A60 db ?                        ; DATA XREF: sub_4DE180r
                                            ; sub_4DE180+30w
    align 4
    byte_528A64 db ?                        ; DATA XREF: sub_4DE4D0r
                                            ; sub_4DE4D0+27w
    align 4
    byte_528A68 db ?                        ; DATA XREF: sub_4DE180+2Bo
                                            ; sub_4DE180+52r
    align 4
    byte_528A6C db ?                        ; DATA XREF: sub_4DE4D0+22o
                                            ; sub_4DE4D0+3Er
    align 4
    byte_528A70 db ?                        ; DATA XREF: .text:004DE0A0r
                                            ; .text:004DE0B0w
    dd ?
    align 4
    dword_528A78 dd 0Bh dup(?)              ; DATA XREF: .text:004DE0BDo
                                            ; .text:004DE0D8o ...
    dword_528AA4 dd ?                       ; DATA XREF: sub_4DE550+28w
                                            ; sub_4DE550+52r
    byte_528AA8 db ?                        ; DATA XREF: sub_4DE700+3Er
                                            ; sub_4DE700+51w
    align 4
    byte_528AAC db ?                        ; DATA XREF: sub_4DE550+12r
                                            ; sub_4DE550+1Dw
    align 4
    dword_528AB0 dd ?                       ; DATA XREF: sub_4DE700+5Cw
                                            ; sub_4DE700+9Cr
    dword_528AB4 dd ?                       ; DATA XREF: sub_4DE110+5Bw
                                            ; sub_4DE180+1A2w ...
    dword_528AB8 dd ?                       ; DATA XREF: sub_4DE110+37w
                                            ; sub_4DE180+D8w ...
    dword_528ABC dd ?                       ; DATA XREF: sub_4DE110+19r
                                            ; sub_4DE110+3Dw ...
    dword_528AC0 dd ?                       ; DATA XREF: sub_4DE110+43w
                                            ; sub_4DE180+11Ew ...
    dword_528AC4 dd ?                       ; DATA XREF: sub_4DE110+49w
                                            ; sub_4DE180+140w ...
    dword_528AC8 dd ?                       ; DATA XREF: sub_4DE110+4Fw
                                            ; sub_4DE180+163w ...
    dword_528ACC dd ?                       ; DATA XREF: sub_4DE110+55w
                                            ; sub_4DE180+184w ...
    dword_528AD0 dd ?                       ; DATA XREF: sub_4DE110+31w
                                            ; sub_4DE180+B6w ...
    dword_528AD4 dd ?                       ; DATA XREF: sub_4DE110+61w
                                            ; sub_4DE180+1AFw ...
    byte_528AD8 db ?                        ; DATA XREF: sub_4DE110+Aw
                                            ; sub_4DE180+67r ...
    align 4
    byte_528ADC db ?                        ; DATA XREF: sub_4DE180+70r
                                            ; sub_4DE180+326w
    align 4
    ; HMODULE hLibModule
    hLibModule dd ?                         ; DATA XREF: sub_4DE110r
                                            ; sub_4DE110+1Fr ...
    byte_528AE4 db ?                        ; DATA XREF: sub_4DE8A0+20r
                                            ; sub_4DE8A0+32w
    align 4
    ; char byte_528AE8
    byte_528AE8 db ?                        ; DATA XREF: sub_4DE8A0+58o
                                            ; sub_4DE8A0+61o ...
    dd 0F9h dup(?)
    align 4
    dword_528ED0 dd 0FAh dup(?)             ; DATA XREF: sub_4DE8A0+ABo
                                            ; sub_4DE8A0+F9o ...
    byte_5292B8 db ?                        ; DATA XREF: sub_4DF160r
                                            ; sub_4DF160+21w
    align 4
    byte_5292BC db ?                        ; DATA XREF: sub_4DF160+2Do
                                            ; sub_4DF160+44r
    dd ?
    align 4
    dword_5292C4 dd ?                       ; DATA XREF: sub_4DF380+8Cr
                                            ; sub_4DF590+536r ...
    byte_5292C8 db ?                        ; DATA XREF: sub_4DFD10r
                                            ; sub_4DFD10+15w
    dd ?
    align 4
    dword_5292D0 dd 87h dup(?)              ; DATA XREF: sub_4DFD10+Eo
                                            ; sub_4DFD10+2Do
    dword_5294EC dd ?                       ; DATA XREF: sub_4DFD50+44o
                                            ; sub_4DFD50+9Do
    dword_5294F0 dd ?                       ; DATA XREF: sub_4DFD50+3r
                                            ; sub_4DFD50+3Br ...
    dd ?
    dword_5294F8 dd ?                       ; DATA XREF: sub_4DFD50+9r
                                            ; sub_4DFD50+65w ...
    dd ?
    dword_529500 dd ?                       ; DATA XREF: sub_4DFD50+E9r
                                            ; sub_4DFD50+EFw ...
    dd ?
    dword_529508 dd ?                       ; DATA XREF: .text:004E0769w
                                            ; sub_4E0790+29w ...
    dd ?
    dword_529510 dd 6 dup(?)                ; DATA XREF: sub_4E06F0+Eo
                                            ; sub_4E06F0+2Co
    dword_529528 dd ?                       ; DATA XREF: sub_4E07E0+EBw
                                            ; sub_4E07E0+128w ...
    byte_52952C db ?                        ; DATA XREF: sub_4E1410r
                                            ; sub_4E1410+15w
    align 4
    dword_529530 dd ?                       ; DATA XREF: sub_4E07E0+6Bw
                                            ; sub_4E07E0+94r
    dd ?
    dword_529538 dd 20h dup(?)              ; DATA XREF: sub_4E1410+Eo
                                            ; sub_4E1410+2Do
    dword_5295B8 dd ?                       ; DATA XREF: sub_4E07E0+E5w
                                            ; sub_4E07E0+12Ew ...
    dword_5295BC dd ?                       ; DATA XREF: .text:004E074Fr
                                            ; .text:004E075Fw ...
    dword_5295C0 dd ?                       ; DATA XREF: sub_4E07E0+DDw
                                            ; sub_4E07E0+134w ...
    byte_5295C4 db ?                        ; DATA XREF: sub_4E06F0r
                                            ; sub_4E06F0+13w
    align 4
    dword_5295C8 dd ?                       ; DATA XREF: sub_4E07E0+CBw
                                            ; sub_4E07E0+2F4r
    byte_5295CC db ?                        ; DATA XREF: .text:004E0774w
                                            ; sub_4E0790+34w ...
    align 4
    dword_5295D0 dd ?                       ; DATA XREF: sub_4E07E0+20r
                                            ; sub_4E07E0+2Cw ...
    dword_5295D4 dd ?                       ; DATA XREF: sub_4E07E0+C3r
                                            ; sub_4E07E0+D2w ...
    dword_5295D8 dd 1F4h dup(?)             ; DATA XREF: sub_4E0B90+6ADo
                                            ; sub_4E0B90+71Eo
    dword_529DA8 dd 6 dup(?)                ; DATA XREF: std::_Lockit::_Lockit(void)+23o
                                            ; std::_Lockit::_Lockit(void)+76o ...
    dword_529DC0 dd ?                       ; DATA XREF: std::_Lockit::_Lockit(void)r
                                            ; std::_Lockit::_Lockit(void)+14o ...
    dd ?
    byte_529DC8 db ?                        ; DATA XREF: sub_4DF590+2C7r
                                            ; sub_4DF590+4A2r ...
    align 4
    dword_529DCC dd ?                       ; DATA XREF: sub_4DF1E0+41r
                                            ; sub_4E1BE0+1Dw ...
    dword_529DD0 dd ?                       ; DATA XREF: sub_4E1D60+11r
                                            ; sub_4E1D60+24w ...
    byte_529DD4 db ?                        ; DATA XREF: sub_4DF590+428r
                                            ; sub_4DF590+437w ...
    align 4
    byte_529DD8 db ?                        ; DATA XREF: sub_4DF4E0+10r
                                            ; sub_4DF590+3F8r ...
    align 4
    byte_529DDC db ?                        ; DATA XREF: sub_4DF590+451r
                                            ; sub_4DF590+460w ...
    align 4
    dword_529DE0 dd 6 dup(?)                ; DATA XREF: sub_4E1AC0+Eo
                                            ; sub_4E1AC0+2Co
    dword_529DF8 dd ?                       ; DATA XREF: sub_4DF1E0+4Ar
                                            ; sub_4E1BE0r ...
    dd ?
    dword_529E00 dd ?                       ; DATA XREF: sub_4DF590+2A9r
                                            ; sub_4DF590+2AFw ...
    dword_529E04 dd ?                       ; DATA XREF: sub_4E1BE0+8Dw
                                            ; sub_4E1BE0+D4r ...
    dword_529E08 dd ?                       ; DATA XREF: sub_4E1BE0+96w
                                            ; sub_4E1BE0+F3w
    dword_529E0C dd ?                       ; DATA XREF: sub_4E1BE0+9Fw
                                            ; sub_4E1BE0+FCw ...
    dword_529E10 dd ?                       ; DATA XREF: sub_4DF590+31Eo
                                            ; sub_4E1B10+A3o ...
    dword_529E14 dd ?                       ; DATA XREF: sub_4E1BE0+B6w
                                            ; sub_4E1BE0+102r ...
    dword_529E18 dd ?                       ; DATA XREF: sub_4E1BE0+BFw
                                            ; sub_4E1BE0+11Ew
    dword_529E1C dd ?                       ; DATA XREF: sub_4E1BE0+C8w
                                            ; sub_4E1BE0+127w ...
    byte_529E20 db ?                        ; DATA XREF: sub_4E1D60+1Cw
                                            ; .text:004E1DEEw ...
    dd 0Dh dup(?)
    align 4
    dword_529E58 dd ?                       ; DATA XREF: sub_4DFD50+C7r
                                            ; sub_4DFD50+CFw ...
    dd 2 dup(?)
    byte_529E64 db ?                        ; DATA XREF: sub_4DF590+479r
                                            ; sub_4DF590+488w ...
    align 4
    byte_529E68 db ?                        ; DATA XREF: sub_4E1AC0r
                                            ; sub_4E1AC0+13w
    align 4
    byte_529E6C db ?                        ; DATA XREF: sub_4E1680r sub_4E1680+9w
    align 4
    byte_529E70 db ?                        ; DATA XREF: sub_4E1680+19w
                                            ; sub_4E1680+20r
    align 4
    byte_529E74 db ?                        ; DATA XREF: .text:004E16B4r
                                            ; .text:004E16BEw
    align 4
    byte_529E78 db ?                        ; DATA XREF: .text:004E16E9w
                                            ; .text:004E16F0r
    align 4
    dword_529E7C dd ?                       ; DATA XREF: sub_4E1A90r
                                            ; sub_4E1A90+1Ew ...
    dword_529E80 dd ?                       ; DATA XREF: sub_4E2BE0+Er
    dd ?
    dword_529E88 dd ?                       ; DATA XREF: sub_4E35B0+1Ew
                                            ; sub_4E35B0+39w ...
    dword_529E8C dd ?                       ; DATA XREF: sub_4E35B0+23w
                                            ; sub_4E35B0+3Fw
    dword_529E90 dd ?                       ; DATA XREF: sub_4E35B0+28w
                                            ; sub_4E35B0+45w
    byte_529E94 db ?                        ; DATA XREF: sub_4E35B0+2Dw
    align 4
    ; HANDLE hDevice
    hDevice dd ?                            ; DATA XREF: sub_4E35B0+DEw
                                            ; .text:004E3719r ...
    byte_529E9C db ?                        ; DATA XREF: sub_4E35B0+9r
                                            ; sub_4E35B0+86w ...
    align 4
    dword_529EA0 dd ?                       ; DATA XREF: sub_4E35B0+10Fw
                                            ; sub_4E35B0+115r ...
    dd ?
    dword_529EA8 dd 6 dup(?)                ; DATA XREF: sub_4E39B0+23o
                                            ; sub_4E39B0+76o ...
    dword_529EC0 dd ?                       ; DATA XREF: sub_4E39B0r
                                            ; sub_4E39B0+14o ...
    dword_529EC4 dd ?                       ; DATA XREF: .text:004E4394r
                                            ; .text:004E4399w ...
    dword_529EC8 dd ?                       ; DATA XREF: __fpmath+Aw
                                            ; .text:004EC582r
    dword_529ECC dd ?                       ; DATA XREF: sub_4F4880+135r
    dword_529ED0 dd ?                       ; DATA XREF: start+52w
    dword_529ED4 dd ?                       ; DATA XREF: start+49w
    dword_529ED8 dd ?                       ; DATA XREF: start+3Ew
    dword_529EDC dd ?                       ; DATA XREF: start+30w
    dword_529EE0 dd ?                       ; DATA XREF: __setargv+94w
    dword_529EE4 dd ?                       ; DATA XREF: __setargv+8Dw
    dd ?
    dword_529EEC dd ?                       ; DATA XREF: __getenv_lk+1r
                                            ; __getenv_lk+20r ...
    dword_529EF0 dd ?                       ; DATA XREF: ___crtsetenv+31r
    dword_529EF4 dd ?                       ; DATA XREF: __getenv_lk+Er
                                            ; ___wtomb_environ+1r ...
    dd ?
    dword_529EFC dd ?                       ; DATA XREF: __setargv+1Dw
    dd ?
    byte_529F04 db ?                        ; DATA XREF: _doexit+38w
                                            ; .text:004F2D85r
    align 4
    dword_529F08 dd ?                       ; DATA XREF: _doexit+2Ew
    dword_529F0C dd ?                       ; DATA XREF: _doexit+8r _doexit+9Ew
    dword_529F10 dd ?                       ; DATA XREF: _time+62r _time+BEw
    dd ?
    dword_529F18 dd ?                       ; DATA XREF: _time+59r _time+AAw ...
    dword_529F1C dd ?                       ; DATA XREF: _time+B4w _time+3Dr
    dword_529F20 dd ?                       ; DATA XREF: _time+2Fr _time+C3w ...
    dword_529F24 dd ?                       ; DATA XREF: _time+C9w
    dword_529F28 dd ?                       ; DATA XREF: .text:004E69FCr
                                            ; .text:004E6A04w ...
    dword_529F2C dd ?                       ; DATA XREF: .text:004E6A19r
                                            ; .text:004E6A21w ...
    dword_529F30 dd ?                       ; DATA XREF: .text:004E6A36r
                                            ; .text:004E6A3Ew ...
    dword_529F34 dd ?                       ; DATA XREF: .text:004E6A53r
                                            ; .text:004E6A5Bw ...
    dword_529F38 dd ?                       ; DATA XREF: .text:004E69BDr
                                            ; .text:004E69DCw
    ; void *dword_529F3C
    dword_529F3C dd ?                       ; DATA XREF: start+9Ew __setenvp+1r ...
    dd ?
    dword_529F44 dd ?                       ; DATA XREF: __amsg_exitr sub_4E7180r ...
    TlsIndex dd ?                           ; DATA XREF: sub_4D8D70+Ar
                                            ; sub_4D8DF0+9r ...
    dd ?
    dword_529F50 dd 0Ah dup(?)              ; DATA XREF: _gmtime+35o
    dword_529F78 dd 0Eh dup(?)              ; DATA XREF: _asctime+21o
    dword_529FB0 dd 12h dup(?)              ; DATA XREF: .data:0050DFA4o
    dword_529FF8 dd ?                       ; DATA XREF: sub_4EAE00+4Er
                                            ; sub_4EAE00+66w ...
    dd ?
    dword_52A000 dd ?                       ; DATA XREF: __expandlocale+108o
                                            ; __expandlocale+197r
    dword_52A004 dd ?                       ; DATA XREF: __expandlocale+123r
                                            ; __expandlocale+19Fr
    dword_52A008 dd ?                       ; DATA XREF: __expandlocale+137w
                                            ; __expandlocale+1B5r
    dd ?
    dword_52A010 dd ?                       ; DATA XREF: __setlocale_set_cat+6Er
                                            ; __setlocale_set_cat+C9w ...
    dd ?
    ; LCID Locale
    Locale dd ?                             ; DATA XREF: _tolowerr sub_4E5AC0r ...
    dword_52A01C dd ?                       ; DATA XREF: ___init_monetaryr
    dword_52A020 dd ?                       ; DATA XREF: ___init_numericr
    dword_52A024 dd ?                       ; DATA XREF: ___init_timer
    ; UINT CodePage
    CodePage dd ?                           ; DATA XREF: __setlocale_set_cat+8Cr
                                            ; __setlocale_set_cat+E8w ...
    dword_52A02C dd ?                       ; DATA XREF: .text:004EE2D0r
                                            ; .text:004EE327w ...
    dword_52A030 dd ?                       ; DATA XREF: sub_4EE520r
                                            ; sub_4EE520+57w ...
    dd ?
    dword_52A038 dd ?                       ; DATA XREF: __tzset_lk+14w
                                            ; __tzset_lk+78w ...
    dd ?
    ; struct _TIME_ZONE_INFORMATION stru_52A040
    stru_52A040 dd ?                                    ; Bias ; DATA XREF: __tzset_lk+4Fo
                                            ; __tzset_lk+63r ...
    dw 20h dup(?)                           ; StandardName
    dw ?                                    ; StandardDate.wYear
    dw ?                                    ; StandardDate.wMonth
    dw ?                                    ; StandardDate.wDayOfWeek
    dw ?                                    ; StandardDate.wDay
    dw ?                                    ; StandardDate.wHour
    dw ?                                    ; StandardDate.wMinute
    dw ?                                    ; StandardDate.wSecond
    dw ?                                    ; StandardDate.wMilliseconds
    dd ?                                    ; StandardBias
    dw 20h dup(?)                           ; DaylightName
    dw ?                                    ; DaylightDate.wYear
    dw ?                                    ; DaylightDate.wMonth
    dw ?                                    ; DaylightDate.wDayOfWeek
    dw ?                                    ; DaylightDate.wDay
    dw ?                                    ; DaylightDate.wHour
    dw ?                                    ; DaylightDate.wMinute
    dw ?                                    ; DaylightDate.wSecond
    dw ?                                    ; DaylightDate.wMilliseconds
    dd ?                                    ; DaylightBias
    ; void *dword_52A0EC
    dword_52A0EC dd ?                       ; DATA XREF: __tzset_lk+125r
                                            ; __tzset_lk+185w
    dword_52A0F0 dd ?                       ; DATA XREF: ___tzsetr ___tzset+10r ...
    dd ?
    byte_52A0F8 db ?                        ; DATA XREF: sub_4F0730+9Do
                                            ; sub_4F0730+187o ...
    byte_52A0F9 db ?                        ; DATA XREF: __splitpath+6Br
                                            ; sub_4F0730+DFr ...
    dd 41h dup(?)
    align 4
    byte_52A200 db ?                        ; DATA XREF: sub_4F0A50+12Dw
                                            ; sub_4F0A50+150w ...
    dd 3Fh dup(?)
    align 4
    ; void *lpString1
    lpString1 dd ?                          ; DATA XREF: sub_4F0730+1Dr
                                            ; sub_4F0730+B1w ...
    ; int dword_52A304
    dword_52A304 dd ?                       ; DATA XREF: sub_4F0730+B7w
                                            ; sub_4F0730+11Fw ...
    dword_52A308 dd ?                       ; DATA XREF: sub_4F0730+133w
                                            ; sub_4F0730+212w ...
    dword_52A30C dd ?                       ; DATA XREF: sub_4F0730+138w
                                            ; sub_4F0730+21Bw ...
    dword_52A310 dd ?                       ; DATA XREF: sub_4F0730+13Dw
                                            ; sub_4F0730+221w ...
    dword_52A314 dd ?                       ; DATA XREF: sub_4F0730+144r
                                            ; _getSystemCP+4w ...
    dword_52A318 dd 41h dup(?)              ; DATA XREF: __setargv+Ao
                                            ; __setargv+1Do ...
    dword_52A41C dd ?                       ; DATA XREF: .text:004F1263r
                                            ; .text:004F12AEw
    dword_52A420 dd ?                       ; DATA XREF: ___crtGetEnvironmentStringsAr
                                            ; ___crtGetEnvironmentStringsA+3Dw
    dword_52A424 dd ?                       ; DATA XREF: __FF_MSGBANNER+21r
    ; LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter
    lpTopLevelExceptionFilter dd ?          ; DATA XREF: __CxxUnhandledExceptionFilter(_EXCEPTION_POINTERS *)+2Cr
                                            ; __CxxUnhandledExceptionFilter(_EXCEPTION_POINTERS *)+43r ...
    dword_52A42C dd ?                       ; DATA XREF: ___sbh_decommit_pages+49r
                                            ; ___sbh_decommit_pages+50w ...
    dword_52A430 dd ?                       ; DATA XREF: _mallocr _calloc+89r ...
    dword_52A434 dd ?                       ; DATA XREF: _set_new_handler(int (*)(uint))+Cr
                                            ; _set_new_handler(int (*)(uint))+15w ...
    dword_52A438 dd ?                       ; DATA XREF: sub_4EAE00+37r
                                            ; sub_4EAE00+3Ew ...
    dword_52A43C dd ?                       ; DATA XREF: ___crtGetStringTypeW+1r
                                            ; ___crtGetStringTypeW+53w
    dword_52A440 dd ?                       ; DATA XREF: sub_4F4680+1r
                                            ; sub_4F4680+37w ...
    dword_52A444 dd ?                       ; DATA XREF: __openfile+Er
    ; void *dword_52A448
    dword_52A448 dd ?                       ; DATA XREF: ___init_time+4Cr
                                            ; ___init_time+5Dr ...
    ; void *dword_52A44C
    dword_52A44C dd ?                       ; DATA XREF: ___init_numeric+1Bo
                                            ; ___init_numeric+69r ...
    ; void *dword_52A450
    dword_52A450 dd ?                       ; DATA XREF: ___init_numeric+2Fo
                                            ; ___init_numeric+75r ...
    ; void *dword_52A454
    dword_52A454 dd ?                       ; DATA XREF: ___init_numeric+43o
                                            ; ___init_numeric+57r ...
    ; void *dword_52A458
    dword_52A458 dd ?                       ; DATA XREF: ___init_monetary+6Er
                                            ; ___init_monetary+7Fr ...
    ; void *dword_52A45C
    dword_52A45C dd ?                       ; DATA XREF: sub_4F6D90+1DBr
                                            ; sub_4F6D90+1FEw ...
    ; void *dword_52A460
    dword_52A460 dd ?                       ; DATA XREF: sub_4F6D90+1F9r
                                            ; sub_4F6D90+216w ...
    dd 4 dup(?)
    word_52A474 dw ?                        ; DATA XREF: sub_4F6D90+29r
    dd ?
    align 4
    word_52A47C dw ?                        ; DATA XREF: __get_lc_lconv+8r
    dd ?
    word_52A482 dw ?                        ; DATA XREF: ___init_numeric+Dr
    db 2 dup(?)
    word_52A486 dw ?                        ; DATA XREF: __get_lc_time+Br
    word_52A488 dw ?                        ; DATA XREF: __get_lc_time+12r
    align 4
    dword_52A48C dd ?                       ; DATA XREF: sub_4F70A0+102r
                                            ; sub_4F70A0+11Dr ...
    dword_52A490 dd ?                       ; DATA XREF: sub_4F72A0+38w
                                            ; LocaleEnumProc+Fr ...
    ; size_t dword_52A494
    dword_52A494 dd ?                       ; DATA XREF: sub_4F72A0+47w
                                            ; sub_4F72A0+5Cw ...
    dword_52A498 dd ?                       ; DATA XREF: sub_4F72A0+25w
                                            ; LocaleEnumProc+6Br ...
    ; char *dword_52A49C
    dword_52A49C dd ?                       ; DATA XREF: sub_4F70A0+36w
                                            ; sub_4F70A0+42o ...
    ; char *dword_52A4A0
    dword_52A4A0 dd ?                       ; DATA XREF: sub_4F70A0+5Bw
                                            ; sub_4F70A0+67o ...
    dword_52A4A4 dd ?                       ; DATA XREF: sub_4F70A0+86w
                                            ; sub_4F70A0+C5r ...
    dword_52A4A8 dd ?                       ; DATA XREF: sub_4F70A0+127r
                                            ; sub_4F70A0+156r ...
    dword_52A4AC dd ?                       ; DATA XREF: sub_4F70A0r
                                            ; sub_4F70A0+19w ...
    dword_52A4B0 dd ?                       ; DATA XREF: ___crtMessageBoxAr
                                            ; ___crtMessageBoxA+2Fw ...
    dword_52A4B4 dd ?                       ; DATA XREF: ___crtMessageBoxA+44w
                                            ; ___crtMessageBoxA+50r
    dword_52A4B8 dd ?                       ; DATA XREF: ___crtMessageBoxA+4Bw
                                            ; ___crtMessageBoxA+61r
    dword_52A4BC dd ?                       ; DATA XREF: .text:004F8220r
                                            ; .text:004F824Bw ...
    dword_52A4C0 dd ?                       ; DATA XREF: ___crtCompareStringAr
                                            ; ___crtCompareStringA+32w ...
    dword_52A4C4 dd ?                       ; DATA XREF: sub_4F4880+41r
    dword_52A4C8 dd ?                       ; DATA XREF: __Strftime+C8w
                                            ; __Strftime+D3w ...
    dword_52A4CC dd ?                       ; DATA XREF: __expandtime+150w
                                            ; __expandtime+17Dw ...
    ; WCHAR WideCharStr
    WideCharStr dd 2 dup(?)                 ; DATA XREF: ___getlocaleinfo+119o
                                            ; ___getlocaleinfo+133o
    dword_52A4D8 dd ?                       ; DATA XREF: __free_lc_lconv+Co
                                            ; ___getlocaleinfo+187o ...
    dword_52A4DC dd ?                       ; DATA XREF: ___crtGetLocaleInfoWr
                                            ; ___crtGetLocaleInfoW+43w
    dword_52A4E0 dd ?                       ; DATA XREF: sub_4FAEB0r
                                            ; sub_4FAEB0+43w
    byte_52A4E4 db ?                        ; DATA XREF: .text:00463BA0r
                                            ; .text:00463BAEw ...
    align 4
    ; __int32 Target
    Target dd ?                             ; DATA XREF: sub_4B5510+18o
                                            ; sub_4B5510+283o ...
    dword_52A4EC dd ?                       ; DATA XREF: sub_4B5510+27r
                                            ; sub_4B5510+3Bw ...
    ; HANDLE hHandle
    hHandle dd ?                            ; DATA XREF: sub_4B5510+2Fr
                                            ; sub_4B5510+294r ...
    dword_52A4F4 dd ?                       ; DATA XREF: DoNetworkCompression+28r
                                            ; DoNetworkCompression+3Cw ...
    ; HANDLE hEvent
    hEvent dd ?                             ; DATA XREF: .text:004D09E0r
                                            ; .text:004D0A09w ...
    dword_52A4FC dd ?                       ; DATA XREF: .text:004D09E5w
                                            ; DoNetworkCompression+19o ...
    byte_52A500 db ?                        ; DATA XREF: .text:004E4140r
                                            ; .text:004E414Ew
    byte_52A501 db ?                        ; DATA XREF: .text:004E4158r
                                            ; .text:004E4163w
    byte_52A502 db ?                        ; DATA XREF: .text:004E4182r
                                            ; .text:004E418Dw
    byte_52A503 db ?                        ; DATA XREF: .text:004E4197r
                                            ; .text:004E41A2w
    byte_52A504 db ?                        ; DATA XREF: .text:004E41ACr
                                            ; .text:004E41B7w
    byte_52A505 db ?                        ; DATA XREF: .text:004E41C1r
                                            ; .text:004E41CCw
    align 4
    dword_52A508 dd ?                       ; DATA XREF: _flsall+26r _flsall+3Er ...
    dd 5 dup(?)
    dword_52A520 dd 400h dup(?)             ; DATA XREF: .data:005109F0o
    dword_52B520 dd ?                       ; DATA XREF: _flsall+14r _flsall+96r ...
    ; HANDLE hHeap
    hHeap dd ?                              ; DATA XREF: _free+52r
                                            ; __heap_alloc+42r ...
    dd 6 dup(?)
    dword_52B540 dd ?                       ; DATA XREF: __ftell_lk+76r
                                            ; sub_4E7610+1Cr ...
    dword_52B544 dd 3Fh dup(?)              ; DATA XREF: __ioinit+B1o
    ; UINT uNumber
    uNumber dd ?                            ; DATA XREF: sub_4E7610r __filelengthr ...
    dword_52B644 dd ?                       ; DATA XREF: sub_4F0730+124w
                                            ; sub_4F0730+12Cw ...
    dword_52B648 dd ?                       ; DATA XREF: _tolower+29r _toupper+29r ...
    ; __int32 Addend
    Addend dd ?                             ; DATA XREF: _tolower+1Eo _tolower+38o ...
    dword_52B650 dd ?                       ; DATA XREF: start+94w start+A7r ...
    dword_52B654 dd ?                       ; DATA XREF: _doexit+4Ar __onexit+11r ...
    ; void *dword_52B658
    dword_52B658 dd ?                       ; DATA XREF: _doexit+40r _doexit+5Fr ...
    _data ends

    ; Section 4. (virtual address 0012C000)
    ; Virtual size                  : 00000014 (     20.)
    ; Section size in file          : 00000200 (    512.)
    ; Offset to raw data for section: 00110000
    ; Flags C0000040: Data Readable Writable
    ; Alignment     : 16 bytes ?
    ; ---------------------------------------------------------------------------

    ; Segment type: Pure data
    ; Segment permissions: Read/Write
    _tls segment para public 'DATA' use32
    assume cs:_tls
    ;org 52C000h
    TlsStart dd offset TlsStart             ; DATA XREF: .rdata:004FDD58o
                                            ; .tls:0052C000o
    dd 3 dup(0)
    TlsEnd dd offset TlsEnd                 ; DATA XREF: .rdata:004FDD5Co
                                            ; .tls:0052C010o
    align 200h
    _tls ends

    ; Section 5. (virtual address 0012D000)
    ; Virtual size                  : 00000A58 (   2648.)
    ; Section size in file          : 00000C00 (   3072.)
    ; Offset to raw data for section: 00110200
    ; Flags 40000040: Data Readable
    ; Alignment     : 16 bytes ?
    ; ---------------------------------------------------------------------------

    ; Segment type: Pure data
    ; Segment permissions: Read
    _rsrc segment para public 'DATA' use32
    assume cs:_rsrc
    ;org 52D000h
    dd 3 dup(0), 50000h, 1, 80000038h, 3, 80000050h, 0Ch, 80000070h, 0Eh, 80000088h
    dd 10h, 800000A0h, 3 dup(0), 10000h, 3, 800000B8h, 3 dup(0), 20000h, 1
    dd 800000D0h, 2, 800000E8h, 3 dup(0), 10000h, 67h, 80000100h, 3 dup(0)
    dd 10000h, 7F00h, 80000118h, 3 dup(0), 10000h, 1, 80000130h, 3 dup(0)
    dd 10000h, 409h, 148h, 3 dup(0), 10000h, 409h, 158h, 3 dup(0), 10000h
    dd 409h, 168h, 3 dup(0), 10000h, 409h, 178h, 3 dup(0), 10000h, 409h, 188h
    dd 3 dup(0), 10000h, 409h, 198h, 12D5E8h, 134h, 2 dup(0), 12D1B0h, 2E8h
    dd 2 dup(0), 12D498h, 128h, 2 dup(0), 12D720h, 14h, 2 dup(0), 12D5C0h
    dd 22h, 2 dup(0), 12D738h, 31Ch, 4 dup(0), 28h, 20h, 40h, 40001h, 0, 200h
    dd 5 dup(0), 800000h, 8000h, 808000h, 80h, 800080h, 8080h, 0C0C0C0h, 808080h
    dd 0FF0000h, 0FF00h, 0FFFF00h, 0FFh, 0FF00FFh, 0FFFFh, 0FFFFFFh, 0B000000h
    dd 2 dup(0), 0B0h, 0B1000000h, 0B0h, 0B000000h, 1Bh, 0B1000000h, 0B0h
    dd 0B000000h, 1Bh, 0B1090000h, 0B0h, 0B000000h, 1Bh, 110B0000h, 0B0h, 0B000000h
    dd 0B011h, 110B0000h, 0B0h, 0B000000h, 0B011h, 119B0000h, 0BB0B00B0h, 0B00B0BBh
    dd 0B911h, 1B10000h, 0B0BBB0h, 0BBB0B00h, 1B10h, 1B10900h, 0BBh, 0BB000000h
    dd 1B10h, 1B10900h, 0B0h, 0B000000h, 901B10h, 1109B00h, 0B1h, 1B000000h
    dd 0B00110h, 109B00h, 101Bh, 0B1010000h, 0B90100h, 109B00h, 0B101h, 101B0000h
    dd 0B90100h, 0B109h, 101B00h, 0B10100h, 901B0000h, 0B109h, 0B10100h, 101B00h
    dd 901B0000h, 0B109h, 101B0000h, 0B101h, 901B0000h, 109B00h, 0B1010000h
    dd 101Bh, 0B90100h, 0B10900h, 1B000000h, 0B1h, 901B00h, 10BB0900h, 1000000h
    dd 10h, 90BB01h, 0B1B10900h, 2 dup(0), 901B1Bh, 1BB10900h, 10h, 1000000h
    dd 901BB1h, 119B0000h, 0B1h, 1B000000h, 0B911h, 109B0000h, 101Bh, 0B1010000h
    dd 0B901h, 109B0000h, 0B101h, 101B0000h, 0B901h, 0B1090000h, 101B00h, 0B10100h
    dd 901Bh, 9B000000h, 0B10110h, 1101B00h, 0B9h, 9000000h, 101B00B1h, 1B00B101h
    dd 90h, 0, 0B101119Bh, 0B911101Bh, 2 dup(0), 1BB1BB09h, 90BB1BB1h, 2 dup(0)
    dd 0BB9B9900h, 99B9BBh, 2 dup(0), 99090000h, 9099h, 5 dup(0), 7FFFFFFEh
    dd 2 dup(3FFE7FFCh), 3FFE7FF8h, 2 dup(1FFE7FF8h), 0F1E78F0h, 0F0240F0h
    dd 0F0000E0h, 70000E0h, 70000C0h, 2 dup(30000C0h), 3 dup(1000080h), 30000C0h
    dd 4 dup(70000E0h), 3 dup(0F0000F0h), 1F0000F8h, 3F0000FCh, 7F0000FEh
    dd 0FF0000FFh, 0FF0180FFh, 0FF03C0FFh, 0FF1FF8FFh, 0FFFFFFFFh, 28h, 10h
    dd 20h, 40001h, 0, 80h, 5 dup(0), 800000h, 8000h, 808000h, 80h, 800080h
    dd 8080h, 0C0C0C0h, 808080h, 0FF0000h, 0FF00h, 0FFFF00h, 0FFh, 0FF00FFh
    dd 0FFFFh, 0FFFFFFh, 900h, 900000h, 909000h, 90900h, 909000h, 90900h, 99909000h
    dd 90999h, 0B99000h, 99B00h, 0B00009h, 90000B00h, 0B0009h, 9000B000h, 0B0000009h
    dd 9000000Bh, 0B00B009h, 900B00B0h, 0B09h, 90B00000h, 0B00009h, 90000B00h
    dd 0BB009h, 900BB000h, 0B0009B00h, 0B9000Bh, 0BB00900h, 900BB0h, 0B09B0000h
    dd 0B90Bh, 99090000h, 9099h, 90B9F7EFh, 0CE00E3C7h, 0E3C7h, 0CCCC23C4h
    dd 90B903C0h, 0CE000180h, 8770180h, 0C000180h, 90B90180h, 0CC000180h, 7000180h
    dd 70070180h, 0B903C0h, 0C07E0h, 70770FF0h, 7001FF8h, 10000h, 20200002h
    dd 10010h, 2E80004h, 10000h, 101010h, 40001h, 128h, 2, 2 dup(0), 28h, 20h
    dd 40h, 10001h, 0, 80h, 5 dup(0), 0FFFFFFh, 20h dup(0), 20h dup(0FFFFFFFFh)
    dd 0, 20000h, 200001h, 10040h, 1340001h, 30000h, 0, 34031Ch, 560000h, 5F0053h
    dd 450056h, 530052h, 4F0049h, 5F004Eh, 4E0049h, 4F0046h, 0, 0FEEF04BDh
    dd 10000h, 30001h, 0, 30001h, 0, 3Fh, 0, 40004h, 1, 3 dup(0), 27Ah, 530001h
    dd 720074h, 6E0069h, 460067h, 6C0069h, 490065h, 66006Eh, 6Fh, 256h, 300001h
    dd 300034h, 300039h, 620034h, 30h, 16004Ch, 430001h, 6D006Fh, 610070h
    dd 79006Eh, 61004Eh, 65006Dh, 0, 610043h, 650076h, 6F0064h, 200067h, 6E0045h
    dd 650074h, 740072h, 690061h, 6D006Eh, 6E0065h, 74h, 13004Eh, 460001h
    dd 6C0069h, 440065h, 730065h, 720063h, 700069h, 690074h, 6E006Fh, 0, 6F0054h
    dd 610074h, 20006Ch, 6E0041h, 69006Eh, 690068h, 61006Ch, 690074h, 6E006Fh
    dd 0, 5002Ah, 460001h, 6C0069h, 560065h, 720065h, 690073h, 6E006Fh, 0
    dd 330076h, 31002Eh, 0, 130046h, 490001h, 74006Eh, 720065h, 61006Eh, 4E006Ch
    dd 6D0061h, 65h, 6F0054h, 610074h, 20006Ch, 6E0041h, 69006Eh, 690068h
    dd 61006Ch, 690074h, 6E006Fh, 0, 110046h, 4C0001h, 670065h, 6C0061h, 6F0043h
    dd 790070h, 690072h, 680067h, 74h, 6F0043h, 790070h, 690072h, 680067h
    dd 200074h, 2000A9h, 390031h, 370039h, 0, 0B003Eh, 4F0001h, 690072h, 690067h
    dd 61006Eh, 46006Ch, 6C0069h, 6E0065h, 6D0061h, 65h, 6F0054h, 610074h
    dd 61006Ch, 65002Eh, 650078h, 0, 2B0076h, 500001h, 6F0072h, 750064h, 740063h
    dd 61004Eh, 65006Dh, 0, 610043h, 650076h, 6F0064h, 200067h, 6E0045h, 650074h
    dd 740072h, 690061h, 6D006Eh, 6E0065h, 270074h, 200073h, 6F0054h, 610074h
    dd 20006Ch, 6E0041h, 69006Eh, 690068h, 61006Ch, 690074h, 6E006Fh, 0, 5002Eh
    dd 500001h, 6F0072h, 750064h, 740063h, 650056h, 730072h, 6F0069h
    dd 6Eh, 330076h, 31002Eh, 0, 44h, 560001h, 720061h, 690046h, 65006Ch, 6E0049h
    dd 6F0066h, 0, 40024h, 540000h, 610072h, 73006Eh, 61006Ch, 690074h, 6E006Fh
    dd 0, 4B00409h, 6Bh dup(0)
    _rsrc ends